This repository has been archived by the owner on May 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Designer225/v0.4.0
v0.4.0
- Loading branch information
Showing
35 changed files
with
228 additions
and
218 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file modified
BIN
+16 KB
(100%)
CustomTroopUpgrades/.vs/CustomTroopUpgrades/v16/Server/sqlite3/storage.ide
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using System.Xml.Serialization; | ||
using System.ComponentModel; | ||
|
||
namespace CustomTroopUpgrades | ||
{ | ||
public class CustomTroopReplaceOperation | ||
{ | ||
// For XMLSerializer only | ||
private CustomTroopReplaceOperation() { } | ||
|
||
public CustomTroopReplaceOperation(string src, string dest, int copyUpgrades = 0) | ||
{ | ||
Source = src; | ||
Destination = dest; | ||
ReplaceFlag = copyUpgrades; | ||
} | ||
|
||
[XmlAttribute] | ||
public string Source { get; set; } | ||
|
||
[XmlAttribute] | ||
public string Destination { get; set; } | ||
|
||
[XmlAttribute] | ||
[DefaultValue(ReplaceFlags.AllFlags)] | ||
public int ReplaceFlag { get; set; } | ||
} | ||
|
||
public static class ReplaceFlags | ||
{ | ||
public const int | ||
AllFlagsZero = 0, | ||
Age = 1, | ||
IsBasicTroop = 1 << 1, // 2 | ||
TattooTags = 1 << 2, // 4 | ||
IsSoldier = 1 << 3, // 8 | ||
IsBasicHero = 1 << 4, // 16 | ||
UpgradeTargets = 1 << 5, // 32 | ||
UpgradeRequires = 1 << 6, // 64 | ||
Culture = 1 << 7, // 128 | ||
DefaultGroup = 1 << 8, // 256 | ||
BodyProperties = 1 << 9, // 512 | ||
FormationPositionPreference = 1 << 10, // 1024 | ||
IsFemale = 1 << 11, // 2048 | ||
Level = 1 << 12, // 4096 | ||
Name = 1 << 13, // 8192 | ||
Occupation = 1 << 14, // 16384 | ||
Skills = 1 << 15, // 32768 | ||
Traits = 1 << 16, // 65536 | ||
Feats = 1 << 17, // 131072 | ||
HairTags = 1 << 18, // 262144 | ||
BeardTags = 1 << 19, // 524288 | ||
CivilianTemplate = 1 << 20, // 1048576 | ||
BattleTemplate = 1 << 21, // 2097152 | ||
Equipments = 1 << 22, // 4194304 | ||
|
||
Upgrades = UpgradeTargets, | ||
FormationPosition = FormationPositionPreference, | ||
Face = TattooTags | HairTags | BeardTags | BodyProperties, // 786948 | ||
|
||
AllFlags = Age | IsBasicTroop | Face | IsSoldier | IsBasicHero | UpgradeTargets | UpgradeRequires | Culture | DefaultGroup | FormationPositionPreference | ||
| IsFemale | Level | Name | Occupation | Skills | Traits | Feats | CivilianTemplate | BattleTemplate | Equipments; // 8388607 | ||
|
||
public static bool HasFlag(int combinedFlag, int specificFlag) | ||
{ | ||
return (combinedFlag & specificFlag) == specificFlag; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Xml.Serialization; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
|
||
namespace CustomTroopUpgrades | ||
{ | ||
|
||
[XmlRoot("CustomTroopUpgrades", IsNullable = false)] | ||
public class CustomTroopUpgrades : IComparable<CustomTroopUpgrades> | ||
{ | ||
internal static readonly string[] DefaultModules = { "Native", "SandBoxCore", "Sandbox", "StoryMode", "CustomBattle" }; | ||
|
||
// For XMLSerializer only | ||
private CustomTroopUpgrades() { } | ||
|
||
public CustomTroopUpgrades(string[] modules = null, int priority = 1000, CustomTroopUpgradeOperation[] ctuOps = null, CustomTroopReplaceOperation[] ctrOps = null) | ||
{ | ||
DependentModules = modules; | ||
ProcessModules(); | ||
Priority = priority; | ||
CustomTroopUpgradeOps = ctuOps; | ||
CustomTroopReplaceOps = ctrOps; | ||
ProcessArrays(); | ||
} | ||
|
||
[XmlArray] | ||
[XmlArrayItem(typeof(string), ElementName = "Module")] | ||
public string[] DependentModules { get; set; } | ||
|
||
[XmlAttribute] | ||
[DefaultValue(1000)] | ||
public int Priority { get; set; } | ||
|
||
[XmlArray("CustomTroopUpgradeOperations")] | ||
[XmlArrayItem(typeof(CustomTroopUpgradeOperation), ElementName = "CustomTroopUpgrade")] | ||
public CustomTroopUpgradeOperation[] CustomTroopUpgradeOps { get; set; } | ||
|
||
[XmlArray("CustomTroopReplaceOperations")] | ||
[XmlArrayItem(typeof(CustomTroopReplaceOperation), ElementName = "CustomTroopReplacement")] | ||
public CustomTroopReplaceOperation[] CustomTroopReplaceOps { get; set; } | ||
|
||
public int CompareTo(CustomTroopUpgrades other) | ||
{ | ||
int value = Priority.CompareTo(other.Priority); | ||
|
||
if (value == 0) | ||
{ | ||
value = DependentModules.Count().CompareTo(other.DependentModules.Count()); | ||
|
||
if (value == 0) | ||
{ | ||
for (int i = 0; i < DependentModules.Count() && i < other.DependentModules.Count(); i++) | ||
{ | ||
value = DependentModules[i].CompareTo(other.DependentModules[i]); | ||
|
||
if (value != 0) | ||
break; | ||
} | ||
} | ||
} | ||
|
||
return value; | ||
} | ||
|
||
internal void ProcessModules() | ||
{ | ||
var combined = new List<string>(DefaultModules); | ||
if (DependentModules != null) | ||
combined.AddRange(DependentModules); | ||
for (int i = 0; i < combined.Count; i++) | ||
{ | ||
combined[i] = combined[i].ToLowerInvariant(); | ||
} | ||
combined = combined.ToHashSet().ToList(); | ||
combined.Sort(); | ||
DependentModules = combined.ToArray(); | ||
} | ||
|
||
internal void ProcessArrays() | ||
{ | ||
if (CustomTroopUpgradeOps == null) | ||
CustomTroopUpgradeOps = new CustomTroopUpgradeOperation[] { }; | ||
if (CustomTroopReplaceOps == null) | ||
CustomTroopReplaceOps = new CustomTroopReplaceOperation[] { }; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.