-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRayHitReflectPatch.cs
More file actions
73 lines (63 loc) · 2.09 KB
/
RayHitReflectPatch.cs
File metadata and controls
73 lines (63 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using BepInEx;
using HarmonyLib;
using System.Reflection.Emit;
using System.Collections.Generic;
namespace RayHitReflectPatch
{
[BepInDependency("com.willis.rounds.unbound", BepInDependency.DependencyFlags.HardDependency)] // necessary for most modding stuff here
[BepInPlugin(ModId, ModName, Version)]
[BepInProcess("Rounds.exe")]
public class RayHitReflectPatch : BaseUnityPlugin
{
private const string ModId = "pykess.rounds.plugins.rayhitreflectpatch";
private const string ModName = "RayHitReflectPatch";
public const string Version = "0.0.0";
private string CompatibilityModName => ModName.Replace(" ", "");
public static RayHitReflectPatch instance;
private Harmony harmony;
#if DEBUG
public static readonly bool DEBUG = true;
#else
public static readonly bool DEBUG = false;
#endif
internal static void Log(string str)
{
if (DEBUG)
{
UnityEngine.Debug.Log($"[{ModName}] {str}");
}
}
[HarmonyPatch(typeof(RayHitReflect), nameof(RayHitReflect.DoHitEffect))]
class RayHitReflectPatchDoHitEffect
{
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
foreach (var code in instructions)
{
if (code.opcode == OpCodes.Ldc_I4_S && code.OperandIs(10))
{
yield return new CodeInstruction(OpCodes.Ldc_I4_S, 0);
}
else
{
yield return code;
}
}
}
}
private void Awake()
{
instance = this;
harmony = new Harmony(ModId);
harmony.PatchAll();
}
private void Start()
{
}
private void OnDestroy()
{
harmony.UnpatchAll();
}
internal static string GetConfigKey(string key) => $"{RayHitReflectPatch.ModName}_{key}";
}
}