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 BepInEx.Logging;
using FistVR;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Sodalite.ModPanel;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("Feinianyu")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Allows you to configure the cooldown for manually loading rounds into magazines.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Feinianyu.ConfigurableLoad")]
[assembly: AssemblyTitle("ConfigurableLoad")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
{
}
}
}
namespace ConfigurableLoad
{
[BepInProcess("h3vr.exe")]
[BepInPlugin("Feinianyu.ConfigurableLoad", "ConfigurableLoad", "1.0.0")]
public class ConfigurableLoadPlugin : BaseUnityPlugin
{
public static ConfigEntry<int> CooldownConfigMs;
public const string Id = "Feinianyu.ConfigurableLoad";
internal static ManualLogSource Logger { get; private set; }
public static string Name => "ConfigurableLoad";
public static string Version => "1.0.0";
private void Awake()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
AcceptableValueIntRangeStep val = new AcceptableValueIntRangeStep(100, 500, 50);
ConfigDescription val2 = new ConfigDescription("The cooldown in milliseconds (100ms - 500ms) between manually loading rounds. H3VR default: 300ms", (AcceptableValueBase)(object)val, new object[0]);
CooldownConfigMs = ((BaseUnityPlugin)this).Config.Bind<int>("General", "RoundLoadingCooldownMs", 150, val2);
Harmony.CreateAndPatchAll(typeof(ConfigurableLoadPlugin).Assembly, (string)null);
Logger.LogMessage((object)$"Plugin {((BaseUnityPlugin)this).Info.Metadata.Name} v{((BaseUnityPlugin)this).Info.Metadata.Version} is loaded! Round loading cooldown set to: {CooldownConfigMs.Value}ms");
}
}
[HarmonyPatch(typeof(FVRFireArmRound), "FVRFixedUpdate")]
public static class RoundLoadingSpeedPatch
{
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Expected O, but got Unknown
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Expected O, but got Unknown
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Expected O, but got Unknown
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Expected O, but got Unknown
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)0.3f, (string)null)
});
if (val.IsInvalid)
{
ConfigurableLoadPlugin.Logger.LogError((object)"Could not find the round loading speed instruction to patch! The mod may be broken.");
return instructions;
}
FieldInfo fieldInfo = AccessTools.Field(typeof(ConfigurableLoadPlugin), "CooldownConfigMs");
MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(ConfigEntry<int>), "Value");
val.SetInstructionAndAdvance(new CodeInstruction(OpCodes.Ldsfld, (object)fieldInfo)).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Callvirt, (object)methodInfo)
}).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Conv_R4, (object)null)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldc_R4, (object)1000f)
})
.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Div, (object)null)
});
ConfigurableLoadPlugin.Logger.LogInfo((object)"Successfully patched loading speed with unit conversion!");
return val.InstructionEnumeration();
}
}
}