-
Notifications
You must be signed in to change notification settings - Fork 75
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
6 changed files
with
49 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
"Releases": [ | ||
{ | ||
"Id": "TabletopTweaks-Base", | ||
"Version": "2.6.11" | ||
"Version": "2.6.12" | ||
} | ||
] | ||
} |
36 changes: 36 additions & 0 deletions
36
TabletopTweaks-Base/Bugfixes/General/SelectionHitboxFix.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,36 @@ | ||
using HarmonyLib; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection.Emit; | ||
using System.Reflection; | ||
using Kingmaker.View; | ||
using static TabletopTweaks.Base.Main; | ||
|
||
namespace TabletopTweaks.Base.Bugfixes.General { | ||
internal class SelectionHitboxFix { | ||
[HarmonyPatch(typeof(UnitEntityView), nameof(UnitEntityView.SetupSelectionColliders), new Type[] { typeof(bool) })] | ||
static class Arcanist_ActionBarSpellbookHelper_Patch { | ||
static readonly FieldInfo UnitEntityView_m_Corpulence = AccessTools.Field(typeof(UnitEntityView), "m_Corpulence"); | ||
static readonly MethodInfo UnitEntityView_Corpulence = AccessTools.PropertyGetter(typeof(UnitEntityView), "Corpulence"); | ||
//Prevent Collision radius from scaling with size adjusted corpulance | ||
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { | ||
if (TTTContext.Fixes.BaseFixes.IsDisabled("SelectionHitboxFix")) { return instructions; } | ||
var codes = new List<CodeInstruction>(instructions); | ||
int target = FindInsertionTarget(codes); | ||
codes[target] = new CodeInstruction(OpCodes.Ldfld, UnitEntityView_m_Corpulence); | ||
return codes.AsEnumerable(); | ||
} | ||
private static int FindInsertionTarget(List<CodeInstruction> codes) { | ||
for (int i = 0; i < codes.Count; i++) { | ||
if (codes[i].opcode == OpCodes.Call && codes[i].Calls(UnitEntityView_Corpulence)) { | ||
return i ; | ||
} | ||
} | ||
|
||
TTTContext.Logger.Log("SelectionHitboxFix: COULD NOT FIND TARGET"); | ||
return -1; | ||
} | ||
} | ||
} | ||
} |
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