Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interacting scp330 compile fix #43

Merged
merged 5 commits into from
Aug 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi

Label shouldNotSever = generator.DefineLabel();
Label returnLabel = generator.DefineLabel();
Label enableEffectLabel = generator.DefineLabel();

LocalBuilder ev = generator.DeclareLocal(typeof(InteractingScp330EventArgs));

Expand Down Expand Up @@ -74,14 +75,14 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
});

// This is to find the location of RpcMakeSound to remove the original code and add a new sever logic structure (Start point)
int addShouldSeverOffset = 1;
int addShouldSeverOffset = -1;
int addShouldSeverIndex = newInstructions.FindLastIndex(
instruction => instruction.Calls(Method(typeof(Scp330Interobject), nameof(Scp330Interobject.RpcMakeSound)))) + addShouldSeverOffset;

int serverEffectLocationStart = -1;
int enableEffect = newInstructions.FindLastIndex(
instruction => instruction.LoadsField(Field(typeof(PlayerEffectsController), nameof(ReferenceHub.playerEffectsController)))) + serverEffectLocationStart;

instruction => instruction.LoadsField(Field(typeof(ReferenceHub), nameof(ReferenceHub.playerEffectsController)))) + serverEffectLocationStart;
newInstructions[enableEffect].WithLabels(enableEffectLabel);
newInstructions.InsertRange(
addShouldSeverIndex,
new[]
Expand All @@ -91,7 +92,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
new CodeInstruction(OpCodes.Ldloc, ev.LocalIndex),
new(OpCodes.Callvirt, PropertyGetter(typeof(InteractingScp330EventArgs), nameof(InteractingScp330EventArgs.ShouldSever))),
new(OpCodes.Brfalse, shouldNotSever),
new(OpCodes.Br, enableEffect),
new(OpCodes.Br, enableEffectLabel),
});

// This will let us jump to the taken candies code and lock until ldarg_0, meaning we allow base game logic handle candy adding.
Expand Down
Loading