using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using FistVR;
using HarmonyLib;
using Sodalite.Api;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Cursed.RemoveRoundTypeCheck;
[BepInPlugin("dll.cursed.removeroundtypecheck", "CursedDlls - Remove RoundType Checks", "1.6")]
public class RemoveRoundTypeCheckPlugin : BaseUnityPlugin
{
private class AMPatches
{
[HarmonyPatch(typeof(AM), "getRoundMaterial")]
[HarmonyPrefix]
public static bool AM_getRoundMaterial(FireArmRoundType rType, FireArmRoundClass rClass, Dictionary<FireArmRoundType, Dictionary<FireArmRoundClass, DisplayDataClass>> ___TypeDic, ref Material __result)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
try
{
__result = ___TypeDic[rType][rClass].Material;
return false;
}
catch
{
Debug.LogError((object)$"Attempted to spawn round with rType {rType} and rClass {rClass} - AM doesn't have this!");
__result = ___TypeDic[(FireArmRoundType)998][(FireArmRoundClass)50].Material;
return false;
}
}
[HarmonyPatch(typeof(AM), "getRoundMesh")]
[HarmonyPrefix]
public static bool AM_getRoundMesh(FireArmRoundType rType, FireArmRoundClass rClass, Dictionary<FireArmRoundType, Dictionary<FireArmRoundClass, DisplayDataClass>> ___TypeDic, ref Mesh __result)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
try
{
__result = ___TypeDic[rType][rClass].Mesh;
return false;
}
catch
{
Debug.LogError((object)$"Attempted to spawn round with rType {rType} and rClass {rClass} - AM doesn't have this!");
__result = ___TypeDic[(FireArmRoundType)998][(FireArmRoundClass)50].Mesh;
return false;
}
}
[HarmonyPatch(typeof(AM), "getRoundSelfPrefab")]
[HarmonyPrefix]
public static bool AM_getRoundSelfPrefab(FireArmRoundType rType, FireArmRoundClass rClass, Dictionary<FireArmRoundType, Dictionary<FireArmRoundClass, DisplayDataClass>> ___TypeDic, ref FVRObject __result)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
try
{
__result = ___TypeDic[rType][rClass].ObjectID;
return false;
}
catch
{
Debug.LogError((object)$"Attempted to spawn round with rType {rType} and rClass {rClass} - AM doesn't have this!");
__result = ___TypeDic[(FireArmRoundType)998][(FireArmRoundClass)50].ObjectID;
return false;
}
}
}
private static ConfigEntry<bool> _pluginEnabled;
private static ConfigEntry<bool> _typeChecksDisabled;
private static ConfigEntry<bool> _unlimitedPalmAmount;
private static ConfigEntry<float> _timeSinceRoundInsertedOverride;
private void Awake()
{
_pluginEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PluginEnabled", false, "Enables RemoveRoundTypeCheck. RemoveRoundTypeCheck, as it says on the tin, removes the RoundType check, but also allows for unlimited palming amounts and modifying round insertion time.");
_typeChecksDisabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "TypeChecksDisabled", true, "Disables type checking on rounds. This lets you insert any round you want into any gun, magazine, clip, speedloader, or collection of palmed rounds.");
_unlimitedPalmAmount = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UnlimitedPalmAmount", true, "Removes the limit on palm amounts. This lets you palm as many rounds as you want to.");
_timeSinceRoundInsertedOverride = ((BaseUnityPlugin)this).Config.Bind<float>("General", "TimeSinceRoundInsertedOverride", 0.3f, "Overrides how long it takes for a round to be inserted into a clip or magazine.");
LeaderboardAPI.LeaderboardDisabled.TakeLock();
if (_pluginEnabled.Value)
{
Harmony.CreateAndPatchAll(typeof(RemoveRoundTypeCheckPlugin), (string)null);
}
else
{
Harmony.CreateAndPatchAll(typeof(AMPatches), (string)null);
}
}
public static bool TypeCheck(bool condition)
{
if (!condition)
{
return _typeChecksDisabled.Value;
}
return true;
}
public static bool PalmAmount(int proxies, int maxpalm)
{
return proxies < (_unlimitedPalmAmount.Value ? int.MaxValue : maxpalm);
}
[HarmonyPatch(typeof(FVRFireArmMagazine), "AddRound", new Type[]
{
typeof(FireArmRoundClass),
typeof(bool),
typeof(bool)
})]
[HarmonyPatch(typeof(FVRFireArmClip), "AddRound", new Type[]
{
typeof(FireArmRoundClass),
typeof(bool),
typeof(bool)
})]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> AddRoundByClass(IEnumerable<CodeInstruction> instrs)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
return new CodeMatcher(instrs, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdloc(i, (LocalBuilder)null)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdarg(i, (int?)null)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stfld && ((FieldInfo)i.operand).Name == "LR_Class"), (string)null)
}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
{
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Expected O, but got Unknown
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Expected O, but got Unknown
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Expected O, but got Unknown
CodeInstruction instruction = m.Instruction;
m.Advance(2);
Type declaringType = (m.Operand as MemberInfo).DeclaringType;
Type type = null;
int pos = m.Pos;
m.Advance(-m.Pos);
if (m.Opcode == OpCodes.Ldarg_0)
{
m.Advance(1);
if (m.Opcode == OpCodes.Ldfld)
{
type = (m.Operand as MemberInfo).DeclaringType;
m.Advance(pos).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { instruction }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(type, "RoundType"))
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(declaringType, "LR_Type"))
});
}
else
{
m.Advance(pos - 1);
}
}
else
{
m.Advance(pos);
}
}, (Action<string>)null).InstructionEnumeration();
}
[HarmonyPatch(typeof(FVRFireArmMagazine), "AddRound", new Type[]
{
typeof(FVRFireArmRound),
typeof(bool),
typeof(bool),
typeof(bool)
})]
[HarmonyPatch(typeof(FVRFireArmClip), "AddRound", new Type[]
{
typeof(FVRFireArmRound),
typeof(bool),
typeof(bool)
})]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> AddRoundByRound(IEnumerable<CodeInstruction> instrs)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
return new CodeMatcher(instrs, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdloc(i, (LocalBuilder)null)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdarg(i, (int?)null)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld && ((FieldInfo)i.operand).Name == "RoundClass"), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stfld && ((FieldInfo)i.operand).Name == "LR_Class"), (string)null)
}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Expected O, but got Unknown
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
CodeInstruction instruction = m.Instruction;
m.Advance(2);
Type declaringType = (m.Operand as MemberInfo).DeclaringType;
m.Advance(1);
Type declaringType2 = (m.Operand as MemberInfo).DeclaringType;
m.Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { instruction }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldarg_1, (object)null)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(declaringType, "RoundType"))
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(declaringType2, "LR_Type"))
});
}, (Action<string>)null).InstructionEnumeration();
}
[HarmonyPatch(typeof(FVRFireArmMagazine), "DuplicateFromSpawnLock")]
[HarmonyPatch(typeof(FVRFireArmClip), "DuplicateFromSpawnLock")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> DuplicateFromSpawnLockRoundType(IEnumerable<CodeInstruction> instrs)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
return new CodeMatcher(instrs, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdloc(i, (LocalBuilder)null)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldelem_Ref), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld && ((FieldInfo)i.operand).Name == "LR_Class"), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stfld && ((FieldInfo)i.operand).Name == "LR_Class"), (string)null)
}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Expected O, but got Unknown
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Expected O, but got Unknown
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Expected O, but got Unknown
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Expected O, but got Unknown
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Expected O, but got Unknown
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Expected O, but got Unknown
CodeInstruction instruction = m.Instruction;
m.Advance(2);
Type declaringType = (m.Operand as MemberInfo).DeclaringType;
m.Advance(-8);
CodeInstruction instruction2 = m.Instruction;
m.Advance(1);
FieldInfo fieldInfo = m.Operand as FieldInfo;
m.Advance(9).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { instruction2 }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { instruction })
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldelem_Ref, (object)null)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { instruction })
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldelem_Ref, (object)null)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(declaringType, "LR_Type"))
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(declaringType, "LR_Type"))
});
}, (Action<string>)null).InstructionEnumeration();
}
[HarmonyPatch(typeof(FVRFireArmRound), "AddProxy")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> RoundAddProxy(IEnumerable<CodeInstruction> instrs)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
return new CodeMatcher(instrs, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdloc(i, (LocalBuilder)null)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdarg(i, (int?)null)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stfld && ((FieldInfo)i.operand).Name == "Class"), (string)null)
}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Expected O, but got Unknown
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Expected O, but got Unknown
CodeInstruction instruction = m.Instruction;
m.Advance(3).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { instruction }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldarg_2, (object)null)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(AnvilAsset), "GetGameObject", (Type[])null, (Type[])null))
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(GameObject), "GetComponent", (Type[])null, new Type[1] { typeof(FVRFireArmRound) }))
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(FVRFireArmRound), "RoundType"))
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ProxyRound), "Type"))
});
}, (Action<string>)null).InstructionEnumeration();
}
[HarmonyPatch(typeof(FVRFireArmRound), "PalmRound")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> RoundPalmRound(IEnumerable<CodeInstruction> instrs)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
return new CodeMatcher(instrs, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdloc(i, (LocalBuilder)null)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdarg(i, (int?)null)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld && ((FieldInfo)i.operand).Name == "RoundClass"), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stfld && ((FieldInfo)i.operand).Name == "Class"), (string)null)
}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
CodeInstruction instruction = m.Instruction;
m.Advance(4).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { instruction }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldarg_1, (object)null)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(FVRFireArmRound), "RoundType"))
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(ProxyRound), "Type"))
});
}, (Action<string>)null).InstructionEnumeration();
}
[HarmonyPatch(typeof(FVRFireArmRound), "Awake")]
[HarmonyPrefix]
public static bool AddChamberableToRound(FVRFireArmRound __instance)
{
__instance.isManuallyChamberable = true;
return true;
}
[HarmonyPatch(typeof(FVRFireArmClip), "UpdateInteraction")]
[HarmonyPatch(typeof(FVRFireArmMagazine), "UpdateInteraction")]
[HarmonyPatch(typeof(FVRFireArmRound), "UpdateInteraction")]
[HarmonyPatch(typeof(FVRFireArmRound), "FVRFixedUpdate")]
[HarmonyPatch(typeof(FVRFireArmRound), "GetNumRoundsPulled")]
[HarmonyPatch(typeof(FVRFireArmRound), "DuplicateFromSpawnLock")]
[HarmonyPatch(typeof(FVRFireArmRound), "OnTriggerEnter")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> PatchRoundTypeChecksTranspiler(IEnumerable<CodeInstruction> instrs)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
return new CodeMatcher(instrs, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdloc(i, (LocalBuilder)null) || CodeInstructionExtensions.IsLdarg(i, (int?)null)), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld && ((FieldInfo)i.operand).Name == "RoundType"), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Bne_Un || i.opcode == OpCodes.Bne_Un_S), (string)null)
}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
m.Advance(2).SetOpcodeAndAdvance(OpCodes.Brfalse).Advance(-1)
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ceq, (object)null)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(RemoveRoundTypeCheckPlugin), "TypeCheck", (Type[])null, (Type[])null))
});
}, (Action<string>)null).InstructionEnumeration();
}
[HarmonyPatch(typeof(Speedloader), "OnTriggerEnter")]
[HarmonyPatch(typeof(Speedloader), "UpdateInteraction")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> PatchSpeedloaderRoundTypeChecksTranspiler(IEnumerable<CodeInstruction> instrs)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
return new CodeMatcher(instrs, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld && ((FieldInfo)i.operand).Name == "Type"), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Bne_Un || i.opcode == OpCodes.Bne_Un_S), (string)null)
}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
m.Advance(1).SetOpcodeAndAdvance(OpCodes.Brfalse).Advance(-1)
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ceq, (object)null)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(RemoveRoundTypeCheckPlugin), "TypeCheck", (Type[])null, (Type[])null))
});
}, (Action<string>)null).InstructionEnumeration();
}
[HarmonyPatch(typeof(FVRFireArmRound), "FVRFixedUpdate")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> PatchSpeedloaderRoundLoadingTranspiler(IEnumerable<CodeInstruction> instrs)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
return new CodeMatcher(instrs, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stfld), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldarg_0), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld && ((FieldInfo)i.operand).Name == "m_hoverOverReloadTrigger"), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld && ((FieldInfo)i.operand).Name == "SpeedloaderChamber"), (string)null)
}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Expected O, but got Unknown
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Expected O, but got Unknown
m.Advance(2).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(FVRFireArmRound), "m_hoverOverReloadTrigger"))
}).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(FVRFireArmMagazineReloadTrigger), "SpeedloaderChamber"))
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(FVRFireArmRound), "RoundType"))
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(SpeedloaderChamber), "Type"))
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null)
});
}, (Action<string>)null).InstructionEnumeration();
}
[HarmonyPatch(typeof(FVRFirearmBeltDisplayData), "PullPushBelt")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> PatchBeltDisplayDataTranspiler(IEnumerable<CodeInstruction> instrs)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
return new CodeMatcher(instrs, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld && ((FieldInfo)i.operand).Name == "LR_Class"), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldc_I4_0), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldc_I4_0), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Callvirt && ((MethodInfo)i.operand).Name == "AddRound"), (string)null)
}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Expected O, but got Unknown
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Expected O, but got Unknown
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Expected O, but got Unknown
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Expected O, but got Unknown
m.SetOperandAndAdvance((object)AccessTools.Field(typeof(FVRLoadedRound), "LR_Type")).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldloc_S, (object)5)
}).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(FVRLoadedRound), "LR_Class"))
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(AM), "GetRoundSelfPrefab", (Type[])null, (Type[])null))
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(AnvilAsset), "GetGameObject", (Type[])null, (Type[])null))
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(GameObject), "GetComponent", (Type[])null, new Type[1] { typeof(FVRFireArmRound) }))
})
.Advance(2)
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldc_I4_0, (object)null)
})
.SetOperandAndAdvance((object)AccessTools.Method(typeof(FVRFireArmMagazine), "AddRound", new Type[4]
{
typeof(FVRFireArmRound),
typeof(bool),
typeof(bool),
typeof(bool)
}, (Type[])null));
}, (Action<string>)null).InstructionEnumeration();
}
[HarmonyPatch(typeof(FVRFireArmMagazine), "UpdateInteraction")]
[HarmonyPatch(typeof(FVRFireArmClip), "UpdateInteraction")]
[HarmonyPatch(typeof(Speedloader), "UpdateInteraction")]
[HarmonyPatch(typeof(FVRFireArmRound), "UpdateInteraction")]
[HarmonyPatch(typeof(FVRFireArmRound), "OnTriggerEnter")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> MaxPalmedAmountOverride(IEnumerable<CodeInstruction> instrs)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
return new CodeMatcher(instrs, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld && ((FieldInfo)i.operand).Name == "MaxPalmedAmount"), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Bge || i.opcode == OpCodes.Bge_S), (string)null)
}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
m.Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(RemoveRoundTypeCheckPlugin), "PalmAmount", (Type[])null, (Type[])null))
}).SetOpcodeAndAdvance(OpCodes.Brfalse);
}, (Action<string>)null).InstructionEnumeration();
}
[HarmonyPatch(typeof(FVRFireArmRound), "OnTriggerEnter")]
[HarmonyPatch(typeof(FVRFireArmRound), "OnTriggerExit")]
[HarmonyPatch(typeof(FVRFireArmRound), "UpdateInteraction")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> IsPalmableNoOp(IEnumerable<CodeInstruction> instrs)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
return new CodeMatcher(instrs, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldarg_0), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld && ((FieldInfo)i.operand).Name == "isPalmable"), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Brfalse || i.opcode == OpCodes.Brfalse_S), (string)null)
}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
{
m.SetOpcodeAndAdvance(OpCodes.Nop).SetOpcodeAndAdvance(OpCodes.Nop).SetOpcodeAndAdvance(OpCodes.Nop);
}, (Action<string>)null).InstructionEnumeration();
}
[HarmonyPatch(typeof(FVRFireArmRound), "UpdateInteraction")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> DisableIsPalmable(IEnumerable<CodeInstruction> instrs)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
return new CodeMatcher(instrs, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldarg_0), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldfld && ((FieldInfo)i.operand).Name == "MaxPalmedAmount"), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldc_I4_1), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ble || i.opcode == OpCodes.Ble_S), (string)null)
}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
{
m.SetOpcodeAndAdvance(OpCodes.Nop).SetOpcodeAndAdvance(OpCodes.Nop).SetOpcodeAndAdvance(OpCodes.Nop)
.SetOpcodeAndAdvance(OpCodes.Nop);
}, (Action<string>)null).InstructionEnumeration();
}
[HarmonyPatch(typeof(FVRFireArmRound), "FVRFixedUpdate")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> TimeSinceRoundInsertedOverride(IEnumerable<CodeInstruction> instrs)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
return new CodeMatcher(instrs, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Callvirt && ((MethodInfo)i.operand).Name.Contains("TimeSinceRoundInserted")), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.IsLdloc(i, (LocalBuilder)null) || i.opcode == OpCodes.Ldc_R4), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ble_Un || i.opcode == OpCodes.Ble_Un_S), (string)null)
}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
m.Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(RemoveRoundTypeCheckPlugin), "_timeSinceRoundInsertedOverride"))
}).SetInstructionAndAdvance(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(ConfigEntry<float>), "Value")));
}, (Action<string>)null).InstructionEnumeration();
}
[HarmonyPatch(typeof(FVRFireArmRound), "BeginInteraction")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> PickUpCooldownOverride(IEnumerable<CodeInstruction> instrs)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
return new CodeMatcher(instrs, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldarg_0), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Ldc_R4), (string)null),
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Stfld && ((FieldInfo)i.operand).Name == "m_pickUpCooldown"), (string)null)
}).Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
m.Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(RemoveRoundTypeCheckPlugin), "_timeSinceRoundInsertedOverride"))
}).SetInstructionAndAdvance(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(ConfigEntry<float>), "Value")));
}, (Action<string>)null).InstructionEnumeration();
}
[HarmonyPatch(typeof(AmmoSpawnerV2), "LoadIntoHeldObjects")]
[HarmonyPrefix]
public static bool AmmoSpawnerV2_LoadIntoHeldObjects(FireArmRoundType ___m_curAmmoType, FireArmRoundClass ___m_curAmmoClass)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
//IL_031f: Unknown result type (might be due to invalid IL or missing references)
//IL_0320: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < GM.CurrentMovementManager.Hands.Length; i++)
{
if (!((Object)(object)GM.CurrentMovementManager.Hands[i].CurrentInteractable != (Object)null) || !(GM.CurrentMovementManager.Hands[i].CurrentInteractable is FVRPhysicalObject))
{
continue;
}
if (GM.CurrentMovementManager.Hands[i].CurrentInteractable is FVRFireArmMagazine)
{
FVRInteractiveObject currentInteractable = GM.CurrentMovementManager.Hands[i].CurrentInteractable;
FVRFireArmMagazine val = (FVRFireArmMagazine)(object)((currentInteractable is FVRFireArmMagazine) ? currentInteractable : null);
if (TypeCheck(val.RoundType == ___m_curAmmoType))
{
val.m_numRounds = 0;
for (int j = 0; j < val.LoadedRounds.Length; j++)
{
val.AddRound(((AnvilAsset)AM.GetRoundSelfPrefab(___m_curAmmoType, ___m_curAmmoClass)).GetGameObject().GetComponent<FVRFireArmRound>(), false, true, false);
}
val.UpdateBulletDisplay();
}
}
else if (GM.CurrentMovementManager.Hands[i].CurrentInteractable is FVRFireArmClip)
{
FVRInteractiveObject currentInteractable2 = GM.CurrentMovementManager.Hands[i].CurrentInteractable;
FVRFireArmClip val2 = (FVRFireArmClip)(object)((currentInteractable2 is FVRFireArmClip) ? currentInteractable2 : null);
if (TypeCheck(val2.RoundType == ___m_curAmmoType))
{
val2.m_numRounds = 0;
for (int k = 0; k < val2.LoadedRounds.Length; k++)
{
val2.AddRound(((AnvilAsset)AM.GetRoundSelfPrefab(___m_curAmmoType, ___m_curAmmoClass)).GetGameObject().GetComponent<FVRFireArmRound>(), false, true);
}
val2.UpdateBulletDisplay();
}
}
else if (GM.CurrentMovementManager.Hands[i].CurrentInteractable is Speedloader)
{
FVRInteractiveObject currentInteractable3 = GM.CurrentMovementManager.Hands[i].CurrentInteractable;
Speedloader val3 = (Speedloader)(object)((currentInteractable3 is Speedloader) ? currentInteractable3 : null);
if (TypeCheck(val3.Chambers[0].Type == ___m_curAmmoType))
{
for (int l = 0; l < val3.Chambers.Count; l++)
{
val3.Chambers[l].Type = ___m_curAmmoType;
val3.Chambers[l].Load(___m_curAmmoClass, false);
}
}
}
else
{
if (!(GM.CurrentMovementManager.Hands[i].CurrentInteractable is FVRFireArm))
{
continue;
}
FVRInteractiveObject currentInteractable4 = GM.CurrentMovementManager.Hands[i].CurrentInteractable;
FVRFireArm val4 = (FVRFireArm)(object)((currentInteractable4 is FVRFireArm) ? currentInteractable4 : null);
if (TypeCheck(val4.RoundType == ___m_curAmmoType))
{
for (int m = 0; m < val4.FChambers.Count; m++)
{
val4.FChambers[m].SetRound(((AnvilAsset)AM.GetRoundSelfPrefab(___m_curAmmoType, ___m_curAmmoClass)).GetGameObject().GetComponent<FVRFireArmRound>(), false);
}
}
if (TypeCheck(val4.RoundType == ___m_curAmmoType) && (Object)(object)val4.Magazine != (Object)null)
{
val4.Magazine.m_numRounds = 0;
for (int n = 0; n < val4.Magazine.LoadedRounds.Length; n++)
{
val4.Magazine.AddRound(((AnvilAsset)AM.GetRoundSelfPrefab(___m_curAmmoType, ___m_curAmmoClass)).GetGameObject().GetComponent<FVRFireArmRound>(), false, true, false);
}
val4.Magazine.UpdateBulletDisplay();
}
if (TypeCheck(val4.RoundType == ___m_curAmmoType) && (Object)(object)val4.Clip != (Object)null)
{
val4.Clip.m_numRounds = 0;
for (int num = 0; num < val4.Clip.LoadedRounds.Length; num++)
{
val4.Clip.AddRound(((AnvilAsset)AM.GetRoundSelfPrefab(___m_curAmmoType, ___m_curAmmoClass)).GetGameObject().GetComponent<FVRFireArmRound>(), false, true);
}
val4.Clip.UpdateBulletDisplay();
}
}
}
return false;
}
[HarmonyPatch(typeof(AmmoSpawnerV2), "CheckFillButton")]
[HarmonyPrefix]
public static bool AmmoSpawnerV2_CheckFillButton(AmmoSpawnerV2 __instance, FireArmRoundType ___m_curAmmoType, ref bool ___m_hasHeldType, ref FireArmRoundType ___heldType)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected I4, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Expected I4, but got Unknown
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Expected I4, but got Unknown
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Expected I4, but got Unknown
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
bool flag = false;
for (int i = 0; i < GM.CurrentMovementManager.Hands.Length; i++)
{
if (!((Object)(object)GM.CurrentMovementManager.Hands[i].CurrentInteractable != (Object)null) || !(GM.CurrentMovementManager.Hands[i].CurrentInteractable is FVRPhysicalObject))
{
continue;
}
if (GM.CurrentMovementManager.Hands[i].CurrentInteractable is FVRFireArmMagazine)
{
FVRInteractiveObject currentInteractable = GM.CurrentMovementManager.Hands[i].CurrentInteractable;
FVRFireArmMagazine val = (FVRFireArmMagazine)(object)((currentInteractable is FVRFireArmMagazine) ? currentInteractable : null);
___m_hasHeldType = true;
___heldType = (FireArmRoundType)(int)val.RoundType;
if (TypeCheck(val.RoundType == ___m_curAmmoType))
{
flag = true;
}
}
else if (GM.CurrentMovementManager.Hands[i].CurrentInteractable is FVRFireArmClip)
{
FVRInteractiveObject currentInteractable2 = GM.CurrentMovementManager.Hands[i].CurrentInteractable;
FVRFireArmClip val2 = (FVRFireArmClip)(object)((currentInteractable2 is FVRFireArmClip) ? currentInteractable2 : null);
___m_hasHeldType = true;
___heldType = (FireArmRoundType)(int)val2.RoundType;
if (TypeCheck(val2.RoundType == ___m_curAmmoType))
{
flag = true;
}
}
else if (GM.CurrentMovementManager.Hands[i].CurrentInteractable is Speedloader)
{
FVRInteractiveObject currentInteractable3 = GM.CurrentMovementManager.Hands[i].CurrentInteractable;
Speedloader val3 = (Speedloader)(object)((currentInteractable3 is Speedloader) ? currentInteractable3 : null);
___m_hasHeldType = true;
___heldType = (FireArmRoundType)(int)val3.Chambers[0].Type;
if (TypeCheck(val3.Chambers[0].Type == ___m_curAmmoType))
{
flag = true;
}
}
else if (GM.CurrentMovementManager.Hands[i].CurrentInteractable is FVRFireArm)
{
FVRInteractiveObject currentInteractable4 = GM.CurrentMovementManager.Hands[i].CurrentInteractable;
FVRFireArm val4 = (FVRFireArm)(object)((currentInteractable4 is FVRFireArm) ? currentInteractable4 : null);
___m_hasHeldType = true;
___heldType = (FireArmRoundType)(int)val4.RoundType;
if (TypeCheck(val4.RoundType == ___m_curAmmoType) || (Object)(object)val4.Magazine != (Object)null || (Object)(object)val4.Clip != (Object)null)
{
flag = true;
}
}
}
if (flag && !__instance.BTNGO_Fill.activeSelf)
{
__instance.BTNGO_Fill.SetActive(true);
}
else if (!flag && __instance.BTNGO_Fill.activeSelf)
{
__instance.BTNGO_Fill.SetActive(false);
}
if (___m_hasHeldType && !__instance.BTNGO_Select.activeSelf)
{
__instance.BTNGO_Select.SetActive(true);
}
else if (!___m_hasHeldType && __instance.BTNGO_Select.activeSelf)
{
__instance.BTNGO_Select.SetActive(false);
}
return false;
}
[HarmonyPatch(typeof(FVRFireArmClip), "LoadOneRoundFromClipToMag")]
[HarmonyPrefix]
public static bool FVRFireArmClip_LoadOneRoundFromClipToMag(FVRFireArmClip __instance)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance.FireArm == (Object)null || (Object)(object)__instance.FireArm.Magazine == (Object)null || __instance.FireArm.Magazine.IsFull() || !__instance.HasARound())
{
return false;
}
FVRFireArmRound component = __instance.RemoveRound(false).GetComponent<FVRFireArmRound>();
SM.PlayGenericSound(__instance.LoadFromClipToMag, ((Component)__instance).transform.position);
__instance.FireArm.Magazine.AddRound(component, false, true, false);
return false;
}
[HarmonyPatch(typeof(Speedloader), "DuplicateFromSpawnLock")]
[HarmonyPrefix]
public static bool Speedloader_DuplicateFromSpawnLock(Speedloader __instance, ref GameObject __result, FVRViveHand hand)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Object.Instantiate<GameObject>(((AnvilAsset)((FVRPhysicalObject)__instance).ObjectWrapper).GetGameObject(), ((FVRInteractiveObject)__instance).Transform.position, ((FVRInteractiveObject)__instance).Transform.rotation);
FVRPhysicalObject component = val.GetComponent<FVRPhysicalObject>();
hand.ForceSetInteractable((FVRInteractiveObject)(object)component);
component.SetQuickBeltSlot((FVRQuickBeltSlot)null);
((FVRInteractiveObject)component).BeginInteraction(hand);
Speedloader component2 = val.GetComponent<Speedloader>();
for (int i = 0; i < __instance.Chambers.Count; i++)
{
component2.Chambers[i].Type = __instance.Chambers[i].Type;
if (__instance.Chambers[i].IsLoaded)
{
component2.Chambers[i].Load(__instance.Chambers[i].LoadedClass, false);
}
else
{
component2.Chambers[i].Unload();
}
}
__result = val;
return false;
}
[HarmonyPatch(typeof(RevolverCylinder), "LoadFromSpeedLoader")]
[HarmonyPrefix]
public static bool RevolverCylinder_LoadFromSpeedLoader(RevolverCylinder __instance, Speedloader loader)
{
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
__instance.SpeedLoaderID = ((FVRPhysicalObject)loader).ObjectWrapper.ItemID;
__instance.m_hasSpeedLoadedIn = true;
bool flag = false;
for (int i = 0; i < loader.Chambers.Count; i++)
{
if (i < __instance.Revolver.Chambers.Length && loader.Chambers[i].IsLoaded && !__instance.Revolver.Chambers[i].IsFull)
{
__instance.Revolver.Chambers[i].RoundType = loader.Chambers[i].Type;
__instance.Revolver.Chambers[i].Autochamber(loader.Chambers[i].Unload());
if (loader.Chambers[i].IsSpent)
{
__instance.Revolver.Chambers[i].Fire();
}
flag = true;
}
}
if (flag)
{
((FVRFireArm)__instance.Revolver).PlayAudioEvent((FirearmAudioEventType)20, 1f);
GameObject moonClip = __instance.MoonClip;
if (moonClip != null)
{
moonClip.SetActive(true);
}
}
return false;
}
[HarmonyPatch(typeof(RevolvingShotgun), "LoadCylinder")]
[HarmonyPrefix]
public static bool RevolvingShotgun_LoadCylinder(RevolvingShotgun __instance, Speedloader s, ref int ___m_curChamber, ref bool __result)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
if (__instance.CylinderLoaded)
{
return false;
}
__instance.CylinderLoaded = true;
((Component)__instance.ProxyCylinder).gameObject.SetActive(__instance.CylinderLoaded);
((FVRFireArm)__instance).PlayAudioEvent((FirearmAudioEventType)20, 1f);
___m_curChamber = 0;
__instance.ProxyCylinder.localRotation = __instance.GetLocalRotationFromCylinder(___m_curChamber);
for (int i = 0; i < __instance.Chambers.Length; i++)
{
if (s.Chambers[i].IsLoaded)
{
__instance.Chambers[i].RoundType = s.Chambers[i].Type;
__instance.Chambers[i].Autochamber(s.Chambers[i].LoadedClass);
__instance.Chambers[i].IsSpent = s.Chambers[i].IsSpent;
}
else
{
__instance.Chambers[i].Unload();
}
__instance.Chambers[i].UpdateProxyDisplay();
}
__result = true;
return false;
}
[HarmonyPatch(typeof(RevolvingShotgun), "EjectCylinder")]
[HarmonyPrefix]
public static bool RevolvingShotgun_EjectCylinder(RevolvingShotgun __instance, ref Speedloader __result)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
Speedloader component = Object.Instantiate<GameObject>(__instance.CylinderPrefab, __instance.CyclinderMountPoint.position, __instance.CyclinderMountPoint.rotation).GetComponent<Speedloader>();
((FVRFireArm)__instance).PlayAudioEvent((FirearmAudioEventType)21, 1f);
for (int i = 0; i < component.Chambers.Count; i++)
{
if (!__instance.Chambers[i].IsFull)
{
component.Chambers[i].Unload();
}
else if (__instance.Chambers[i].IsSpent)
{
component.Chambers[i].Type = __instance.Chambers[i].GetRound().RoundType;
component.Chambers[i].LoadEmpty(__instance.Chambers[i].GetRound().RoundClass, false);
}
else
{
component.Chambers[i].Type = __instance.Chambers[i].GetRound().RoundType;
component.Chambers[i].Load(__instance.Chambers[i].GetRound().RoundClass, false);
}
__instance.Chambers[i].UpdateProxyDisplay();
}
((FVRFireArm)__instance).EjectDelay = 0.4f;
__instance.CylinderLoaded = false;
((Component)__instance.ProxyCylinder).gameObject.SetActive(__instance.CylinderLoaded);
__result = component;
return false;
}
[HarmonyPatch(typeof(SpeedloaderChamber), "LoadEmpty")]
[HarmonyPrefix]
public static bool SpeedloaderChamber_LoadEmpty(SpeedloaderChamber __instance, FireArmRoundClass rclass, bool playSound = false)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
__instance.IsLoaded = true;
__instance.IsSpent = true;
__instance.LoadedClass = rclass;
if ((Object)(object)((AnvilAsset)AM.GetRoundSelfPrefab(__instance.Type, __instance.LoadedClass)).GetGameObject().GetComponent<FVRFireArmRound>().FiredRenderer != (Object)null)
{
__instance.Filter.mesh = ((Component)((AnvilAsset)AM.GetRoundSelfPrefab(__instance.Type, __instance.LoadedClass)).GetGameObject().GetComponent<FVRFireArmRound>().FiredRenderer).gameObject.GetComponent<MeshFilter>().sharedMesh;
__instance.LoadedRenderer.material = AM.GetRoundMaterial(__instance.Type, __instance.LoadedClass);
__instance.LoadedRenderer.enabled = true;
if (playSound && (Object)(object)__instance.SpeedLoader.ProfileOverride != (Object)null)
{
SM.PlayGenericSound(__instance.SpeedLoader.ProfileOverride.MagazineInsertRound, ((Component)__instance).transform.position);
}
}
else
{
__instance.IsLoaded = false;
__instance.LoadedRenderer.enabled = false;
}
return false;
}
}