Skip to content

Commit

Permalink
Testing alternative.
Browse files Browse the repository at this point in the history
  • Loading branch information
Undid-Iridium committed Aug 4, 2024
1 parent ccca973 commit a25be5b
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi

int offset = -1;
int index = newInstructions.FindLastIndex(
instruction => instruction.Calls(PropertyGetter(typeof(AttackerDamageHandler), nameof(AttackerDamageHandler.Attacker)))) + offset;
instruction => instruction.LoadsField(Field(typeof(ReferenceHub), nameof(ReferenceHub.networkIdentity)))) + offset;

LocalBuilder ffMulti = generator.DeclareLocal(typeof(float));

Expand All @@ -220,7 +220,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi

newInstructions.InsertRange(
index,
new CodeInstruction[]
new[]
{
// Load Attacker (this.Attacker)
new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]),
Expand Down Expand Up @@ -254,14 +254,14 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
// int ffMultiplierIndex = newInstructions.FindLastIndex(instruction => instruction.opcode == OpCodes.Ret) + ffMultiplierIndexOffset;
newInstructions.InsertRange(
ffMultiplierIndex,
new CodeInstruction[]
new[]
{
// Do not run our custom logic, skip over.
new(OpCodes.Br, normalProcessing),

// AttackerDamageHandler.Damage = AttackerDamageHandler.Damage * ffMulti
new CodeInstruction(OpCodes.Ldarg_0).WithLabels(uniqueFFMulti),
new(OpCodes.Ldloc, ffMulti.LocalIndex),
new (OpCodes.Ldloc, ffMulti.LocalIndex),
new(OpCodes.Ldarg_0),
new(OpCodes.Callvirt, PropertyGetter(typeof(AttackerDamageHandler), nameof(AttackerDamageHandler.Damage))),
new(OpCodes.Mul),
Expand Down

0 comments on commit a25be5b

Please sign in to comment.