using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("200Recoil")]
[assembly: AssemblyTitle("200Recoil")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 EmpressMods.CursedRecoilUnified
{
[BepInPlugin("empress.repo.cursedrecoil.unified", "Cursed Recoil Unified", "1.2.0")]
public sealed class CursedRecoilUnifiedPlugin : BaseUnityPlugin
{
public const string PluginGuid = "empress.repo.cursedrecoil.unified";
public const string PluginName = "Cursed Recoil Unified";
public const string PluginVersion = "1.2.0";
internal static ManualLogSource Log;
internal static Harmony Harmony;
internal static ConfigEntry<float> RecoilForceGuns;
internal static ConfigEntry<bool> EnforceEveryUpdate;
internal static ConfigEntry<bool> CartCannonEnabled;
internal static ConfigEntry<float> CartCannonMultiplier;
private void Awake()
{
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
RecoilForceGuns = ((BaseUnityPlugin)this).Config.Bind<float>("Guns", "RecoilForce", 200f, "Absolute recoil impulse for all ItemGun instances (ForceMode.Impulse at muzzle).");
EnforceEveryUpdate = ((BaseUnityPlugin)this).Config.Bind<bool>("Guns", "EnforceEveryUpdate", true, "If true, force-set gun recoil each Update/FixedUpdate so nothing reduces it.");
CartCannonEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("CartCannon", "Enabled", true, "Enable cart cannon recoil scaling.");
CartCannonMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("CartCannon", "Multiplier", 2f, "Scale cart cannon recoil impulse by this factor (2.0 = 200%).");
Harmony = new Harmony("empress.repo.cursedrecoil.unified");
Harmony.PatchAll(typeof(CursedRecoilUnifiedPlugin).Assembly);
Log.LogInfo((object)string.Format("{0} {1} loaded. Guns: Force={2}, Enforce={3}. CartCannon: Enabled={4}, Mult={5}", "Cursed Recoil Unified", "1.2.0", RecoilForceGuns.Value, EnforceEveryUpdate.Value, CartCannonEnabled.Value, CartCannonMultiplier.Value));
}
private void OnDestroy()
{
try
{
Harmony harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
catch (Exception ex)
{
ManualLogSource log = Log;
if (log != null)
{
log.LogError((object)ex);
}
}
}
}
[HarmonyPatch]
internal static class ItemGun_RecoilPatches
{
private static Type _itemGunType;
private static FieldInfo _f_gunRecoilForce;
private static bool EnsureRefs(object instance)
{
if (instance == null)
{
return false;
}
if (_itemGunType == null)
{
_itemGunType = instance.GetType();
_f_gunRecoilForce = _itemGunType.GetField("gunRecoilForce", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (_f_gunRecoilForce == null)
{
CursedRecoilUnifiedPlugin.Log.LogError((object)"[CursedRecoilUnified] Field 'gunRecoilForce' not found on ItemGun. Send me the exact script/field if your build differs.");
return false;
}
}
return true;
}
private static void ForceSetRecoil(object instance)
{
if (EnsureRefs(instance))
{
float num = Mathf.Max(0f, CursedRecoilUnifiedPlugin.RecoilForceGuns.Value);
_f_gunRecoilForce.SetValue(instance, num);
}
}
[HarmonyPatch(typeof(ItemGun), "Start")]
[HarmonyPostfix]
private static void ItemGun_Start_Postfix(object __instance)
{
ForceSetRecoil(__instance);
}
[HarmonyPatch(typeof(ItemGun), "Update")]
[HarmonyPostfix]
private static void ItemGun_Update_Postfix(object __instance)
{
if (CursedRecoilUnifiedPlugin.EnforceEveryUpdate.Value)
{
ForceSetRecoil(__instance);
}
}
[HarmonyPatch(typeof(ItemGun), "FixedUpdate")]
[HarmonyPostfix]
private static void ItemGun_FixedUpdate_Postfix(object __instance)
{
if (CursedRecoilUnifiedPlugin.EnforceEveryUpdate.Value)
{
ForceSetRecoil(__instance);
}
}
}
internal static class CartCannonGate
{
[ThreadStatic]
internal static bool Active;
[ThreadStatic]
internal static float Mult;
}
[HarmonyPatch(typeof(ItemCartCannon), "ShootLogic")]
internal static class Patch_ItemCartCannon_ShootLogic
{
private static void Prefix()
{
if (CursedRecoilUnifiedPlugin.CartCannonEnabled.Value)
{
CartCannonGate.Active = true;
float value = CursedRecoilUnifiedPlugin.CartCannonMultiplier.Value;
CartCannonGate.Mult = ((value <= 0f) ? 1f : value);
}
}
private static void Finalizer(Exception __exception)
{
CartCannonGate.Active = false;
CartCannonGate.Mult = 1f;
}
}
[HarmonyPatch(typeof(Rigidbody))]
[HarmonyPatch("AddForceAtPosition", new Type[]
{
typeof(Vector3),
typeof(Vector3),
typeof(ForceMode)
})]
internal static class Patch_Rigidbody_AddForceAtPosition
{
private static void Prefix(ref Vector3 force, ref Vector3 position, ref ForceMode mode)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
if (CursedRecoilUnifiedPlugin.CartCannonEnabled.Value && CartCannonGate.Active)
{
force *= CartCannonGate.Mult;
}
}
}
}
namespace _200Recoil
{
[BepInPlugin("Omniscye.200Recoil", "_200Recoil", "1.0")]
public class _200Recoil : BaseUnityPlugin
{
internal static _200Recoil Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void Update()
{
}
}
}