Skip to content

Commit

Permalink
Adjustments to base size changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vek17 committed Nov 19, 2024
1 parent 0ec4139 commit a2521fe
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Version 0.7.10
* Adjusted BaseSizeAdjustment to better handle multiple adjustments.

# Version 0.7.9
* Added BuffEnchantAnyWeaponTTT

Expand Down
2 changes: 1 addition & 1 deletion Repository.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Releases": [
{
"Id": "TabletopTweaks-Core",
"Version": "0.7.9"
"Version": "0.7.10"
}
]
}
2 changes: 1 addition & 1 deletion TabletopTweaks-Core/Info.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<BuffEnchantAnyWeaponData>, IUnitActiveEquipmentSetHandler, IGlobalSubscriber, ISubscriber, IUnitEquipmentHandler {

public BlueprintItemEnchantment Enchantment {
Expand Down
16 changes: 12 additions & 4 deletions TabletopTweaks-Core/NewUnitParts/UnitPartBaseSizeAdjustment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -42,7 +51,7 @@ private void UpdateSize() {
}
currentSizeDelta = GetSizeDelta(Owner.OriginalSize);
this.Owner.UpdateSizeModifiers();
EventBus.RaiseEvent<IUnitSizeHandler>(delegate (IUnitSizeHandler h) {
EventBus.RaiseEvent<IUnitSizeHandler>(h => {
h.HandleUnitSizeChanged(this.Owner.Unit);
}, true);
}
Expand Down Expand Up @@ -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<UnitPartBaseSizeAdjustment>();
if (SizePart == null) { return; }
__result += SizePart.currentSizeDelta;
Expand Down

0 comments on commit a2521fe

Please sign in to comment.