using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using HurricaneVR.Framework.Weapons.Bow;
using HurricaneVR.Framework.Weapons.Guns;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MyShotgunsAccurate")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MyShotgunsAccurate")]
[assembly: AssemblyTitle("MyShotgunsAccurate")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MyShotgunsAccurate;
[BepInPlugin("myshotgunsaccurate.gunmancontracts", "MyShotgunsAccurate", "1.0.0")]
[BepInProcess("GunmanContracts.exe")]
public sealed class Plugin : BasePlugin
{
internal static ManualLogSource Logger;
public override void Load()
{
Logger = ((BasePlugin)this).Log;
Start();
}
public override bool Unload()
{
return false;
}
private static void Start()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: 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_0071: Expected O, but got Unknown
try
{
Harmony val = new Harmony("myshotgunsaccurate.gunmancontracts");
val.PatchAll(typeof(ShotgunAccuracy.Fire));
val.PatchAll(typeof(ShotgunAccuracy.Arrow));
val.PatchAll(typeof(ShotgunAccuracy.Fired));
val.PatchAll(typeof(ShotgunAccuracy.Hit));
Logger.LogInfo((object)"MyShotgunsAccurate enabled: a shotgun blast counts as one shot, and one hit if any pellet lands.");
}
catch (Exception ex)
{
ShotgunAccuracy.Failed = true;
ManualLogSource logger = Logger;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(39, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("MyShotgunsAccurate could not activate: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
}
logger.LogError(val2);
}
}
}
internal static class ShotgunAccuracy
{
[HarmonyPatch(typeof(ANBHVRGunBase), "OnFire")]
internal static class Fire
{
private static void Prefix(ANBHVRGunBase __instance)
{
if (Failed)
{
return;
}
try
{
ShotTally.BeginShot((Object)(object)__instance != (Object)null && __instance.isShotgun);
}
catch (Exception error)
{
Stop(error);
}
}
}
[HarmonyPatch(typeof(HVRPhysicsBow), "ShootArrow")]
internal static class Arrow
{
private static void Prefix()
{
if (Failed)
{
return;
}
try
{
ShotTally.BeginShot(isShotgun: false);
}
catch (Exception error)
{
Stop(error);
}
}
}
[HarmonyPatch(typeof(ANBGameLogic), "AddBullet")]
internal static class Fired
{
private static bool Prefix(ref float bullets)
{
if (Failed)
{
return true;
}
try
{
if (!ShotTally.CountBullet())
{
return false;
}
bullets = 1f;
}
catch (Exception error)
{
Stop(error);
}
return true;
}
}
[HarmonyPatch(typeof(ANBGameLogic), "AddShotHit")]
internal static class Hit
{
private static bool Prefix(ref float num)
{
if (Failed)
{
return true;
}
try
{
if (!ShotTally.CountHit())
{
return false;
}
num = 1f;
}
catch (Exception error)
{
Stop(error);
}
return true;
}
}
internal static bool Failed;
private static void Stop(Exception error)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
Failed = true;
ShotTally.Reset();
ManualLogSource logger = Plugin.Logger;
if (logger != null)
{
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(58, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("MyShotgunsAccurate stopped, accuracy is the game's again: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(error);
}
logger.LogWarning(val);
}
}
}
internal static class ShotTally
{
private static bool blastLive;
private static bool bulletCounted;
private static bool hitCounted;
internal static void BeginShot(bool isShotgun)
{
blastLive = isShotgun;
bulletCounted = false;
hitCounted = false;
}
internal static bool CountBullet()
{
if (!blastLive || bulletCounted)
{
return !blastLive;
}
bulletCounted = true;
return true;
}
internal static bool CountHit()
{
if (!blastLive || hitCounted)
{
return !blastLive;
}
hitCounted = true;
return true;
}
internal static void Reset()
{
BeginShot(isShotgun: false);
}
}