-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
138 additions
and
28 deletions.
There are no files selected for viewing
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
72 changes: 72 additions & 0 deletions
72
TabletopTweaks-Core/MechanicsChanges/AdditionalActivatableAbilityGroups.cs
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,72 @@ | ||
using HarmonyLib; | ||
using Kingmaker.UnitLogic.ActivatableAbilities; | ||
using Kingmaker.UnitLogic.Parts; | ||
using System; | ||
using TabletopTweaks.Core.NewUnitParts; | ||
|
||
namespace TabletopTweaks.Core.MechanicsChanges { | ||
public static class AdditionalActivatableAbilityGroups { | ||
public enum ExtentedActivatableAbilityGroup : int { | ||
CavalierCharge = 1000 | ||
} | ||
|
||
private static bool IsTTTGroup(this ActivatableAbilityGroup group) { | ||
return Enum.IsDefined(typeof(ExtentedActivatableAbilityGroup), (int)group); | ||
} | ||
|
||
[HarmonyPatch(typeof(UnitPartActivatableAbility), nameof(UnitPartActivatableAbility.IncreaseGroupSize), new Type[] { typeof(ActivatableAbilityGroup) })] | ||
static class UnitPartActivatableAbility_IncreaseGroupSize_Patch { | ||
|
||
static bool Prefix(UnitPartActivatableAbility __instance, ActivatableAbilityGroup group) { | ||
if (group.IsTTTGroup()) { | ||
var extensionPart = __instance.Owner.Ensure<UnitPartActivatableAbilityGroupExtension>(); | ||
extensionPart.IncreaseGroupSize((ExtentedActivatableAbilityGroup)group); | ||
return false; | ||
} | ||
return true; | ||
} | ||
} | ||
|
||
[HarmonyPatch(typeof(UnitPartActivatableAbility), nameof(UnitPartActivatableAbility.DecreaseGroupSize), new Type[] { typeof(ActivatableAbilityGroup) })] | ||
static class UnitPartActivatableAbility_DecreaseGroupSize_Patch { | ||
|
||
static bool Prefix(UnitPartActivatableAbility __instance, ActivatableAbilityGroup group) { | ||
if (group.IsTTTGroup()) { | ||
var extensionPart = __instance.Owner.Ensure<UnitPartActivatableAbilityGroupExtension>(); | ||
extensionPart.DecreaseGroupSize((ExtentedActivatableAbilityGroup)group); | ||
return false; | ||
} | ||
return true; | ||
} | ||
} | ||
|
||
[HarmonyPatch(typeof(UnitPartActivatableAbility), nameof(UnitPartActivatableAbility.GetGroupSize), new Type[] { typeof(ActivatableAbilityGroup) })] | ||
static class UnitPartActivatableAbility_GetGroupSize_Patch { | ||
|
||
static bool Prefix(UnitPartActivatableAbility __instance, ActivatableAbilityGroup group, ref int __result) { | ||
if (group.IsTTTGroup()) { | ||
var extensionPart = __instance.Owner.Ensure<UnitPartActivatableAbilityGroupExtension>(); | ||
__result = extensionPart.GetGroupSize((ExtentedActivatableAbilityGroup)group); | ||
return false; | ||
} | ||
return true; | ||
} | ||
} | ||
|
||
//[HarmonyPatch(typeof(UnitPartActivatableAbility), nameof(UnitPartActivatableAbility.PersistentGroupsSizeIncreases), MethodType.Getter)] | ||
static class UnitPartActivatableAbility_PersistentGroupsSizeIncreases_Getter_Patch { | ||
|
||
static void Postfix(UnitPartActivatableAbility __instance, ref int[] __result) { | ||
|
||
} | ||
} | ||
|
||
//[HarmonyPatch(typeof(UnitPartActivatableAbility), nameof(UnitPartActivatableAbility.PersistentGroupsSizeIncreases), MethodType.Setter)] | ||
static class UnitPartActivatableAbility_PersistentGroupsSizeIncreases_Setter_Patch { | ||
|
||
static void Postfix(UnitPartActivatableAbility __instance) { | ||
|
||
} | ||
} | ||
} | ||
} |
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
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
29 changes: 29 additions & 0 deletions
29
TabletopTweaks-Core/NewUnitParts/UnitPartActivatableAbilityGroupExtension.cs
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,29 @@ | ||
using Kingmaker.UnitLogic; | ||
using System.Collections.Generic; | ||
using static TabletopTweaks.Core.MechanicsChanges.AdditionalActivatableAbilityGroups; | ||
|
||
namespace TabletopTweaks.Core.NewUnitParts { | ||
public class UnitPartActivatableAbilityGroupExtension : OldStyleUnitPart { | ||
|
||
public void IncreaseGroupSize(ExtentedActivatableAbilityGroup group) { | ||
if (m_GroupsSizeIncreases.ContainsKey(group)) { | ||
this.m_GroupsSizeIncreases[group] += 1; | ||
} else { | ||
m_GroupsSizeIncreases.Add(group, 1); | ||
} | ||
} | ||
|
||
public void DecreaseGroupSize(ExtentedActivatableAbilityGroup group) { | ||
if (m_GroupsSizeIncreases.ContainsKey(group)) { | ||
this.m_GroupsSizeIncreases[group] -= 1; | ||
} | ||
} | ||
|
||
public int GetGroupSize(ExtentedActivatableAbilityGroup group) { | ||
this.m_GroupsSizeIncreases.TryGetValue(group, out int result); | ||
return result + 1; | ||
} | ||
|
||
private SortedDictionary<ExtentedActivatableAbilityGroup, int> m_GroupsSizeIncreases = new SortedDictionary<ExtentedActivatableAbilityGroup, int>(); | ||
} | ||
} |
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