using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Firemodes;
using HBMF.ModMenu;
using HarmonyLib;
using Il2CppFirearmSystem;
using Il2CppInteractionSystem;
using Il2CppSystem;
using MelonLoader;
using MelonLoader.Preferences;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Mod), "Firemodes", "1.2.0", "korbykob", null)]
[assembly: MelonGame("GexagonVR", "Hard Bullet")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Firemodes")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Firemodes")]
[assembly: AssemblyTitle("Firemodes")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Firemodes;
[HarmonyPatch]
public class Mod : MelonMod
{
private static MelonPreferences_Entry<bool> enabled;
public override void OnInitializeMelon()
{
enabled = MelonPreferences.CreateCategory("Firemodes").CreateEntry<bool>("Enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
Menu.CreateCategory("FIREMODES").CreateBool("ENABLE", enabled.Value, (Action<bool>)delegate(bool value)
{
enabled.Value = value;
});
}
[HarmonyPatch(typeof(GrabPoint), "AttemptGrab", new Type[] { typeof(Grab) })]
[HarmonyPostfix]
public static void GrabPatch(GrabPoint __instance, Grab grab)
{
if (!((Object)(object)((Component)__instance).GetComponentInParent<FirearmEntity>() != (Object)null) || !(((Object)__instance).name != "GrabPoint[Handle]") || !((Object)__instance).name.Contains("GrabPoint") || !(((Object)((Component)__instance).transform.parent).name == "Interaction") || !((Object)(object)((Component)__instance).GetComponent<Usable>() == (Object)null))
{
return;
}
Usable val = ((Component)__instance).gameObject.AddComponent<Usable>();
val._grabbable = grab.Grabbable;
val._allowedGrabPoint = (AbstractGrabPoint)(object)__instance;
GameObject firearm = ((Component)((Component)__instance).transform.parent.parent.Find("Firearm")).gameObject;
val.OnDropClipButtonPressed = Action<Usable>.op_Implicit((Action<Usable>)delegate
{
if (enabled.Value)
{
FirearmSingleShootingMode val2 = default(FirearmSingleShootingMode);
FirearmBurstShootingMode val3 = default(FirearmBurstShootingMode);
FirearmAutoShootingMode val4 = default(FirearmAutoShootingMode);
if (firearm.TryGetComponent<FirearmSingleShootingMode>(ref val2))
{
((FirearmShootingMode)val2).Dispose();
Object.Destroy((Object)(object)val2);
((FirearmShootingMode)firearm.AddComponent<FirearmBurstShootingMode>()).Initiate(firearm.GetComponent<Firearm>());
}
else if (firearm.TryGetComponent<FirearmBurstShootingMode>(ref val3))
{
((FirearmShootingMode)val3).Dispose();
Object.Destroy((Object)(object)val3);
((FirearmShootingMode)firearm.AddComponent<FirearmAutoShootingMode>()).Initiate(firearm.GetComponent<Firearm>());
}
else if (firearm.TryGetComponent<FirearmAutoShootingMode>(ref val4))
{
((FirearmShootingMode)val4).Dispose();
Object.Destroy((Object)(object)val4);
((FirearmShootingMode)firearm.AddComponent<FirearmSingleShootingMode>()).Initiate(firearm.GetComponent<Firearm>());
}
}
});
val.OnEnable();
}
}