Skip to content
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
14 changes: 9 additions & 5 deletions EXILED/Exiled.Events/Patches/Events/Scp173/BeingObserved.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@

namespace Exiled.Events.Patches.Events.Scp173
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;

using API.Features;

using Exiled.API.Features.Pools;
using Exiled.Events.Attributes;
using Exiled.Events.EventArgs.Scp173;
using HarmonyLib;

using PlayerRoles.PlayableScps;
using PlayerRoles.PlayableScps.Scp173;
using PlayerRoles.Subroutines;

Expand All @@ -35,13 +40,12 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi

Label continueLabel = generator.DefineLabel();

int offset = 1;
int index = newInstructions.FindIndex(x => x.opcode == OpCodes.Brtrue_S) + offset;

int offset = 4;
int index = newInstructions.FindIndex(x => x.Calls(PropertyGetter(typeof(VisionInformation), nameof(VisionInformation.IsLooking)))) + offset;
newInstructions.InsertRange(index, new CodeInstruction[]
{
// Player.Get(target)
new(OpCodes.Ldarg_1),
new CodeInstruction(OpCodes.Ldarg_1).MoveLabelsFrom(newInstructions[index]),
new(OpCodes.Call, Method(typeof(API.Features.Player), nameof(API.Features.Player.Get), new[] { typeof(ReferenceHub) })),

// Player.Get(base.Owner)
Expand Down Expand Up @@ -78,4 +82,4 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
ListPool<CodeInstruction>.Pool.Return(newInstructions);
}
}
}
}