From a2521fe35658971398d4585c320c61507ccbb65d Mon Sep 17 00:00:00 2001 From: Sean Petrie Date: Mon, 18 Nov 2024 23:33:28 -0600 Subject: [PATCH] Adjustments to base size changes --- CHANGELOG.md | 3 +++ Repository.json | 2 +- TabletopTweaks-Core/Info.json | 2 +- .../BuffEnchantAnyWeaponTTT.cs | 4 ++++ .../NewUnitParts/UnitPartBaseSizeAdjustment.cs | 16 ++++++++++++---- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf9775e8..2c2a90c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# Version 0.7.10 +* Adjusted BaseSizeAdjustment to better handle multiple adjustments. + # Version 0.7.9 * Added BuffEnchantAnyWeaponTTT diff --git a/Repository.json b/Repository.json index 34648b3d..d2152384 100644 --- a/Repository.json +++ b/Repository.json @@ -2,7 +2,7 @@ "Releases": [ { "Id": "TabletopTweaks-Core", - "Version": "0.7.9" + "Version": "0.7.10" } ] } diff --git a/TabletopTweaks-Core/Info.json b/TabletopTweaks-Core/Info.json index 125d403b..0ce752fe 100644 --- a/TabletopTweaks-Core/Info.json +++ b/TabletopTweaks-Core/Info.json @@ -10,5 +10,5 @@ "Repository": "https://raw.githubusercontent.com/Vek17/TabletopTweaks-Core/master/Repository.json", "Requirements": [], "LoadAfter": [ "MewsiferConsole.Mod" ], - "Version": "0.7.9" + "Version": "0.7.10" } \ No newline at end of file diff --git a/TabletopTweaks-Core/NewComponents/OwlcatReplacements/BuffEnchantAnyWeaponTTT.cs b/TabletopTweaks-Core/NewComponents/OwlcatReplacements/BuffEnchantAnyWeaponTTT.cs index a7c08049..3bee981c 100644 --- a/TabletopTweaks-Core/NewComponents/OwlcatReplacements/BuffEnchantAnyWeaponTTT.cs +++ b/TabletopTweaks-Core/NewComponents/OwlcatReplacements/BuffEnchantAnyWeaponTTT.cs @@ -12,8 +12,12 @@ using UnityEngine; using Kingmaker.UnitLogic.FactLogic; using System.Linq; +using Kingmaker.Blueprints.Facts; +using Kingmaker.Blueprints.JsonSystem; namespace TabletopTweaks.Core.NewComponents.OwlcatReplacements { + [AllowedOn(typeof(BlueprintUnitFact), false)] + [TypeId("04083e8bd6fa4c39b1a5e7590e0ce9bd")] public class BuffEnchantAnyWeaponTTT : UnitBuffComponentDelegate, IUnitActiveEquipmentSetHandler, IGlobalSubscriber, ISubscriber, IUnitEquipmentHandler { public BlueprintItemEnchantment Enchantment { diff --git a/TabletopTweaks-Core/NewUnitParts/UnitPartBaseSizeAdjustment.cs b/TabletopTweaks-Core/NewUnitParts/UnitPartBaseSizeAdjustment.cs index 62505123..fdd0cf22 100644 --- a/TabletopTweaks-Core/NewUnitParts/UnitPartBaseSizeAdjustment.cs +++ b/TabletopTweaks-Core/NewUnitParts/UnitPartBaseSizeAdjustment.cs @@ -15,8 +15,17 @@ public int GetSizeDelta(Size originalSize) { if (adjustment.Type == ChangeType.Value) { return adjustment.Size - originalSize; } - Size result = originalSize.Shift(adjustment.SizeDelta); - return result - originalSize; + var ResultSize = originalSize; + var ValueShift = 0; + foreach (var adj in Adjustments.Where(a => a.Type == ChangeType.Value)) { + ValueShift = adj.Size - originalSize; + } + ResultSize = ResultSize.Shift(ValueShift); + foreach (var adj in Adjustments.Where(a => a.Type == ChangeType.Delta)) { + ResultSize = ResultSize.Shift(adj.SizeDelta); + } + + return ResultSize - originalSize; } public void AddEntry(int sizeDelta, EntityFact source) { Adjustments.Add(new BaseSizeAdjustmentEntry(sizeDelta, source)); @@ -42,7 +51,7 @@ private void UpdateSize() { } currentSizeDelta = GetSizeDelta(Owner.OriginalSize); this.Owner.UpdateSizeModifiers(); - EventBus.RaiseEvent(delegate (IUnitSizeHandler h) { + EventBus.RaiseEvent(h => { h.HandleUnitSizeChanged(this.Owner.Unit); }, true); } @@ -72,7 +81,6 @@ public enum ChangeType { [HarmonyPatch(typeof(UnitState), nameof(UnitState.Size), MethodType.Getter)] class UnitState_Size_Patch { static void Postfix(UnitState __instance, ref Size __result) { - //if (TTTContext.Fixes.BaseFixes.IsDisabled("FixMythicSpellbookSlotsUI")) { return; } var SizePart = __instance.Owner.Get(); if (SizePart == null) { return; } __result += SizePart.currentSizeDelta;