Skip to content

Commit

Permalink
removed redundant transpiler
Browse files Browse the repository at this point in the history
  • Loading branch information
rheirman committed Feb 28, 2020
1 parent ac9c800 commit 1836770
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.vs
Source/Giddy-up-Caravan/.vs/*
Source/Giddy-up-Caravan/obj/*
v1.1/Source/Giddy-up-Core/obj/*
Binary file modified v1.1/Assemblies/GiddyUpCaravan.dll
Binary file not shown.
24 changes: 0 additions & 24 deletions v1.1/Source/Giddy-up-Caravan/Harmony/CaravanTicksPerMoveUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,6 @@ static void Prefix(List<Pawn> pawns, ref int __result)
//__result = Mathf.RoundToInt(Utilities.CaravanUtility.applySpeedBonus(__result, pawns)); //apply static speed bonus as defined in the options.
}

// Ensures adjustTicksPermove is called, which makes sure the ticks per move of the animals being mounted are used, and not the ticks per move of the riders themselves
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
var instructionsList = new List<CodeInstruction>(instructions);
bool flag = false;
for (var i = 0; i < instructionsList.Count; i++)
{
CodeInstruction instruction = instructionsList[i];
yield return instruction;
if (instructionsList[i].operand == typeof(Pawn).GetMethod("get_TicksPerMoveCardinal"))
{
flag = true;
}
if(flag && instructionsList[i].opcode == OpCodes.Stloc_2)
{
yield return new CodeInstruction(OpCodes.Ldloc_2);//load num2 local variable
yield return new CodeInstruction(OpCodes.Ldloc_1);//load i local variable
yield return new CodeInstruction(OpCodes.Ldarg_0);//load Pawns argument
yield return new CodeInstruction(OpCodes.Call, typeof(CaravanTicksPerMoveUtility_GetTicksPerMove).GetMethod("adjustTicksPerMove"));//Injected code
yield return new CodeInstruction(OpCodes.Stloc_2);//load num2 local variable
flag = false;
}
}
}

//makes sure the ticks per move of the animals being mounted are used, and not the ticks per move of the riders themselves
public static float adjustTicksPerMove(float num2, int index, List<Pawn> pawns)
Expand Down

0 comments on commit 1836770

Please sign in to comment.