@@ -20,6 +20,7 @@ namespace Exiled.Events.Patches.Events.Scp3114
2020 using PlayerRoles . PlayableScps . Scp3114 ;
2121
2222 using static HarmonyLib . AccessTools ;
23+ using static PlayerRoles . PlayableScps . Scp3114 . Scp3114VoiceLines ;
2324
2425 /// <summary>
2526 /// Patches <see cref="Scp3114VoiceLines.ServerPlayConditionally" />.
@@ -37,29 +38,31 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
3738
3839 LocalBuilder ev = generator . DeclareLocal ( typeof ( VoiceLinesEventArgs ) ) ;
3940
40- int offset = 1 ;
41- int index = newInstructions . FindIndex ( instruction => instruction . opcode == OpCodes . Blt_S ) + offset ;
41+ int offset = 3 ;
42+ int index = newInstructions . FindIndex ( instruction => instruction . Calls ( Method ( typeof ( VoiceLinesDefinition ) , nameof ( VoiceLinesDefinition . TryDrawNext ) ) ) ) + offset ;
4243
4344 newInstructions . InsertRange ( index , new CodeInstruction [ ]
4445 {
45- // this.Owner
46- new ( OpCodes . Ldarg_0 ) ,
47- new ( OpCodes . Callvirt , PropertyGetter ( typeof ( Scp3114VoiceLines ) , nameof ( Scp3114VoiceLines . Owner ) ) ) ,
46+ // this
47+ new CodeInstruction ( OpCodes . Ldarg_0 ) . MoveLabelsFrom ( newInstructions [ index ] ) ,
4848
4949 // voiceLinesDefinition
5050 new ( OpCodes . Ldloc_0 ) ,
5151
52+ // clipId
53+ new ( OpCodes . Ldloc_2 ) ,
54+
5255 // true
5356 new ( OpCodes . Ldc_I4_1 ) ,
5457
55- // VoiceLinesEventArgs ev = new VoiceLinesEventArgs(ReferenceHub , VoiceLinesDefinition, bool);
58+ // VoiceLinesEventArgs ev = new VoiceLinesEventArgs(Scp3114VoiceLines , VoiceLinesDefinition, byte , bool);
5659 new ( OpCodes . Newobj , GetDeclaredConstructors ( typeof ( VoiceLinesEventArgs ) ) [ 0 ] ) ,
5760 new ( OpCodes . Dup ) ,
5861 new ( OpCodes . Dup ) ,
5962 new ( OpCodes . Stloc_S , ev . LocalIndex ) ,
6063
6164 // Handlers.Scp3114.OnVoiceLines(ev);
62- new ( OpCodes . Call , Method ( typeof ( Handlers . Scp3114 ) , nameof ( Handlers . Scp3114 . OnVoiceLines ) ) ) ,
65+ new ( OpCodes . Call , Method ( typeof ( Scp3114 ) , nameof ( Scp3114 . OnVoiceLines ) ) ) ,
6366
6467 // if(!ev.IsAllowed)
6568 // return;
@@ -70,6 +73,11 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
7073 new ( OpCodes . Ldloc_S , ev . LocalIndex ) ,
7174 new ( OpCodes . Callvirt , PropertyGetter ( typeof ( VoiceLinesEventArgs ) , nameof ( VoiceLinesEventArgs . VoiceLine ) ) ) ,
7275 new ( OpCodes . Stloc_S , 0 ) ,
76+
77+ // clipId = ev.ClipId;
78+ new ( OpCodes . Ldloc_S , ev . LocalIndex ) ,
79+ new ( OpCodes . Callvirt , PropertyGetter ( typeof ( VoiceLinesEventArgs ) , nameof ( VoiceLinesEventArgs . ClipId ) ) ) ,
80+ new ( OpCodes . Stloc_S , 2 ) ,
7381 } ) ;
7482
7583 newInstructions [ newInstructions . Count - 1 ] . labels . Add ( returnLabel ) ;
0 commit comments