Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
Added IsChildTemplate to replaceable fields
Browse files Browse the repository at this point in the history
Tied with IsTemplate flag since it seems related.
  • Loading branch information
Designer225 committed Sep 28, 2020
1 parent aebdfe1 commit 6911c46
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
Binary file modified CustomTroopUpgrades/.vs/CustomTroopUpgrades/v16/.suo
Binary file not shown.
30 changes: 18 additions & 12 deletions CustomTroopUpgrades/CustomTroopUpgradesCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,27 @@ public static void ApplyOperations(CustomTroopUpgrades upgrades, Game g = null)
private static readonly FieldInfo IsBasicHeroField =
typeof(BasicCharacterObject).GetField("_isBasicHero", AllAccessFlag);

private static readonly PropertyInfo UpgradeTargetsProperty =
typeof(CharacterObject).GetProperty(nameof(CharacterObject.UpgradeTargets), AllAccessFlag);

private static readonly PropertyInfo UpgradeRequiresItemFromCategoryProperty =
typeof(CharacterObject).GetProperty(nameof(CharacterObject.UpgradeRequiresItemFromCategory), AllAccessFlag);

private static readonly PropertyInfo DefaultFormationClassProperty =
typeof(BasicCharacterObject).GetProperty(nameof(BasicCharacterObject.DefaultFormationClass), AllAccessFlag);

private static readonly FieldInfo DynamicBodyPropertiesField =
typeof(BasicCharacterObject).GetField("_dynamicBodyProperties", AllAccessFlag);

private static readonly PropertyInfo StaticBodyPropertiesProperty =
typeof(Hero).GetProperty("StaticBodyProperties", AllAccessFlag);

private static readonly PropertyInfo FormationPositionPreferenceProperty =
typeof(BasicCharacterObject).GetProperty(nameof(BasicCharacterObject.FormationPositionPreference), AllAccessFlag);

private static readonly PropertyInfo OccupationProperty =
typeof(CharacterObject).GetProperty(nameof(CharacterObject.Occupation), AllAccessFlag);

private static readonly FieldInfo CharacterSkillsField =
typeof(BasicCharacterObject).GetField("_characterSkills", AllAccessFlag);

private static readonly PropertyInfo UpgradeTargetsProperty =
typeof(CharacterObject).GetProperty(nameof(CharacterObject.UpgradeTargets), AllAccessFlag);

private static readonly PropertyInfo UpgradeRequiresItemFromCategoryProperty =
typeof(CharacterObject).GetProperty(nameof(CharacterObject.UpgradeRequiresItemFromCategory), AllAccessFlag);

private static readonly PropertyInfo OccupationProperty =
typeof(CharacterObject).GetProperty(nameof(CharacterObject.Occupation), AllAccessFlag);

private static readonly FieldInfo CharacterTraitsField =
typeof(CharacterObject).GetField("_characterTraits", AllAccessFlag);

Expand All @@ -142,9 +139,15 @@ public static void ApplyOperations(CustomTroopUpgrades upgrades, Game g = null)
private static readonly PropertyInfo IsTemplateProperty =
typeof(CharacterObject).GetProperty(nameof(CharacterObject.IsTemplate), AllAccessFlag);

private static readonly PropertyInfo IsChildTemplateProperty =
typeof(CharacterObject).GetProperty(nameof(CharacterObject.IsChildTemplate), AllAccessFlag);

private static readonly FieldInfo PersonaField =
typeof(CharacterObject).GetField("_persona", AllAccessFlag);

private static readonly PropertyInfo StaticBodyPropertiesProperty =
typeof(Hero).GetProperty("StaticBodyProperties", AllAccessFlag);

internal static void ApplyReplaceOperations(CustomTroopUpgrades upgrades, List<CharacterObject> objectList)
{
foreach (CustomTroopReplaceOperation operation in upgrades.CustomTroopReplaceOps)
Expand Down Expand Up @@ -214,7 +217,10 @@ internal static void ApplyReplaceOperations(CustomTroopUpgrades upgrades, List<C
else
destination.InitializeEquipmentsOnLoad(destination.AllEquipments.ToList());
if (replaceFlag.HasFlag(ReplaceFlags.IsTemplate))
{
IsTemplateProperty.SetValue(destination, source.IsTemplate);
IsChildTemplateProperty.SetValue(destination, source.IsChildTemplate);
}
if (replaceFlag.HasFlag(ReplaceFlags.Persona))
PersonaField.SetValue(destination, PersonaField.GetValue(source));
}
Expand Down
2 changes: 1 addition & 1 deletion SubModule.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Module>
<Name value="Custom Troop Upgrade And Replacer Mod"/>
<Id value="CustomTroopUpgrades"/>
<Version value="v0.4.1"/>
<Version value="v0.5.1"/>
<SingleplayerModule value="true"/>
<MultiplayerModule value="false"/>
<Official value="false"/>
Expand Down
Binary file modified bin/Win64_Shipping_Client/CustomTroopUpgrades.dll
Binary file not shown.
Binary file modified bin/Win64_Shipping_Client/CustomTroopUpgrades.pdb
Binary file not shown.

0 comments on commit 6911c46

Please sign in to comment.