|
| 1 | +// ----------------------------------------------------------------------- |
| 2 | +// <copyright file="WarheadConfigLockGateFix.cs" company="Exiled Team"> |
| 3 | +// Copyright (c) Exiled Team. All rights reserved. |
| 4 | +// Licensed under the CC BY-SA 3.0 license. |
| 5 | +// </copyright> |
| 6 | +// ----------------------------------------------------------------------- |
| 7 | + |
| 8 | +namespace Exiled.Events.Patches.Fixes |
| 9 | +{ |
| 10 | + using System.Collections.Generic; |
| 11 | + using System.Reflection.Emit; |
| 12 | + |
| 13 | + using API.Features.Pools; |
| 14 | + using Footprinting; |
| 15 | + using HarmonyLib; |
| 16 | + using Interactables.Interobjects.DoorUtils; |
| 17 | + using InventorySystem; |
| 18 | + using InventorySystem.Items.Firearms.Ammo; |
| 19 | + using InventorySystem.Items.Pickups; |
| 20 | + |
| 21 | + using static HarmonyLib.AccessTools; |
| 22 | + |
| 23 | + /// <summary> |
| 24 | + /// Patches <see cref="DoorEventOpenerExtension.Trigger"/> delegate. |
| 25 | + /// Fix than NW config "lock_gates_on_countdown" |
| 26 | + /// reported https://git.scpslgame.com/northwood-qa/scpsl-bug-reporting/-/issues/316. |
| 27 | + /// </summary> |
| 28 | + [HarmonyPatch(typeof(DoorEventOpenerExtension), nameof(DoorEventOpenerExtension.Trigger))] |
| 29 | + internal class WarheadConfigLockGateFix |
| 30 | + { |
| 31 | + private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) |
| 32 | + { |
| 33 | + List<CodeInstruction> newInstructions = ListPool<CodeInstruction>.Pool.Get(instructions); |
| 34 | + |
| 35 | + // replace Contains with StartWith |
| 36 | + int index = newInstructions.FindIndex(x => x.operand == (object)Method(typeof(string), nameof(string.Contains))); |
| 37 | + newInstructions[index].operand = Method(typeof(string), nameof(string.StartsWith), new System.Type[] { typeof(string) }); |
| 38 | + |
| 39 | + for (int z = 0; z < newInstructions.Count; z++) |
| 40 | + yield return newInstructions[z]; |
| 41 | + |
| 42 | + ListPool<CodeInstruction>.Pool.Return(newInstructions); |
| 43 | + } |
| 44 | + } |
| 45 | +} |
0 commit comments