using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using PluginConfig.API;
using PluginConfig.API.Fields;
using UnityEngine;
using UnityEngine.AddressableAssets;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("EasySwap")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EasySwap")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3092892-8c2e-4984-9cfb-5c9eedc22d08")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace EasySwap
{
[BepInPlugin("com.the_cat.EasySwap", "EasySwap", "1.3.0")]
public class Plugin : BaseUnityPlugin
{
public const string GUID = "com.the_cat.EasySwap";
public const string PluginName = "EasySwap";
public const string VersionString = "1.3.0";
public static string AssemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "";
public static ManualLogSource Log = new ManualLogSource("EasySwap");
protected bool _configCreated;
public bool configCreated => _configCreated;
public static void EquipWeapon(Swap.Guns WeaponEnum)
{
string text = null;
AssetReference[] array = null;
switch (WeaponEnum)
{
case Swap.Guns.RevolverBlue:
text = "rev0";
array = MonoSingleton<GunSetter>.Instance.revolverRicochet;
break;
case Swap.Guns.RevolverGreen:
text = "rev2";
array = MonoSingleton<GunSetter>.Instance.revolverPierce;
break;
case Swap.Guns.RevolverRed:
text = "rev1";
array = MonoSingleton<GunSetter>.Instance.revolverTwirl;
break;
case Swap.Guns.ShotgunBlue:
text = "sho0";
array = MonoSingleton<GunSetter>.Instance.shotgunGrenade;
break;
case Swap.Guns.ShotgunGreen:
text = "sho1";
array = MonoSingleton<GunSetter>.Instance.shotgunPump;
break;
case Swap.Guns.ShotgunRed:
text = "sho2";
array = MonoSingleton<GunSetter>.Instance.shotgunRed;
break;
case Swap.Guns.NailgunBlue:
text = "nai0";
array = MonoSingleton<GunSetter>.Instance.nailMagnet;
break;
case Swap.Guns.NailgunGreen:
text = "nai1";
array = MonoSingleton<GunSetter>.Instance.nailOverheat;
break;
case Swap.Guns.NailgunRed:
text = "nai2";
array = MonoSingleton<GunSetter>.Instance.nailRed;
break;
case Swap.Guns.RailBlue:
text = "rai0";
array = MonoSingleton<GunSetter>.Instance.railCannon;
break;
case Swap.Guns.RailGreen:
text = "rai1";
array = MonoSingleton<GunSetter>.Instance.railHarpoon;
break;
case Swap.Guns.RailRed:
text = "rai2";
array = MonoSingleton<GunSetter>.Instance.railMalicious;
break;
case Swap.Guns.RocketBlue:
text = "rock0";
array = MonoSingleton<GunSetter>.Instance.rocketBlue;
break;
case Swap.Guns.RocketGreen:
text = "rock1";
array = MonoSingleton<GunSetter>.Instance.rocketGreen;
break;
case Swap.Guns.RocketRed:
text = "rock2";
array = MonoSingleton<GunSetter>.Instance.rocketRed;
break;
}
if (text == null)
{
Log.LogError((object)"Invalid weapon!");
return;
}
int num = ((MonoSingleton<PrefsManager>.Instance.GetInt("weapon." + text, 0) == 2) ? 1 : 0);
MonoSingleton<GunControl>.Instance.ForceWeapon(AddressablesExtensions.ToAsset(array[num]), true);
}
[HarmonyPatch(typeof(GunControl), "SwitchWeapon")]
[HarmonyPostfix]
private static void SwitchWeaponPostPatch(int targetSlotIndex, int? targetVariationIndex, bool useRetainedVariation, bool cycleSlot, bool cycleVariation, GunControl __instance)
{
List<BoolField> list = null;
string text = null;
switch (__instance.currentSlotIndex)
{
case 1:
list = PluginConfig.RevolverRotEnabled;
text = "rev";
break;
case 2:
list = PluginConfig.ShotgunRotEnabled;
text = "sho";
break;
case 3:
list = PluginConfig.NailgunRotEnabled;
text = "nai";
break;
case 4:
list = PluginConfig.RailRotEnabled;
text = "rai";
break;
case 5:
list = PluginConfig.RocketRotEnabled;
text = "rock";
break;
}
if (list != null)
{
int index = MonoSingleton<PrefsManager>.Instance.GetString("weapon." + text + ".order", "1234").IndexOf((char)(49 + __instance.currentVariationIndex));
if (!list[index].value)
{
__instance.SwitchWeapon(__instance.currentSlotIndex, (int?)null, false, false, true);
}
}
}
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"EasySwap,V1.3.0 is loading...");
Log = ((BaseUnityPlugin)this).Logger;
Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"EasySwap,V1.3.0 is loaded.");
}
public static Color[] GetVariantColors()
{
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
Color[] variationColors = MonoSingleton<ColorBlindSettings>.Instance.variationColors;
Color val = default(Color);
((Color)(ref val))..ctor(variationColors[0].r, variationColors[0].g, variationColors[0].b);
Color val2 = default(Color);
((Color)(ref val2))..ctor(variationColors[1].r, variationColors[1].g, variationColors[1].b);
Color val3 = default(Color);
((Color)(ref val3))..ctor(variationColors[2].r, variationColors[2].g, variationColors[2].b);
return (Color[])(object)new Color[3] { val, val2, val3 };
}
private void Update()
{
if (!_configCreated && (Object)(object)MonoSingleton<ColorBlindSettings>.Instance != (Object)null)
{
PluginConfig.InitConfig();
Log.LogInfo((object)"EasySwap,V1.3.0 Plugin Config is loaded.");
_configCreated = true;
}
Swap.SwapOnKeypress();
}
}
public class PluginConfig
{
public static KeyCodeField RevolverBlue;
public static KeyCodeField RevolverRed;
public static KeyCodeField RevolverGreen;
public static List<BoolField> RevolverRotEnabled;
public static KeyCodeField ShotgunBlue;
public static KeyCodeField ShotgunGreen;
public static KeyCodeField ShotgunRed;
public static List<BoolField> ShotgunRotEnabled;
public static KeyCodeField NailgunBlue;
public static KeyCodeField NailgunGreen;
public static KeyCodeField NailgunRed;
public static List<BoolField> NailgunRotEnabled;
public static KeyCodeField RailcannonBlue;
public static KeyCodeField RailcannonGreen;
public static KeyCodeField RailcannonRed;
public static List<BoolField> RailRotEnabled;
public static KeyCodeField RocketBlue;
public static KeyCodeField RocketGreen;
public static KeyCodeField RocketRed;
public static List<BoolField> RocketRotEnabled;
public static void InitConfig()
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Expected O, but got Unknown
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Expected O, but got Unknown
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Expected O, but got Unknown
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Expected O, but got Unknown
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Expected O, but got Unknown
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Expected O, but got Unknown
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Expected O, but got Unknown
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Expected O, but got Unknown
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Expected O, but got Unknown
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Expected O, but got Unknown
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Expected O, but got Unknown
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Expected O, but got Unknown
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Expected O, but got Unknown
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Expected O, but got Unknown
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Expected O, but got Unknown
//IL_027f: Unknown result type (might be due to invalid IL or missing references)
//IL_029a: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Expected O, but got Unknown
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Expected O, but got Unknown
//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
//IL_02e6: Expected O, but got Unknown
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Expected O, but got Unknown
//IL_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Expected O, but got Unknown
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
//IL_0341: Unknown result type (might be due to invalid IL or missing references)
//IL_034b: Expected O, but got Unknown
//IL_0358: Unknown result type (might be due to invalid IL or missing references)
//IL_0362: Expected O, but got Unknown
//IL_0369: Unknown result type (might be due to invalid IL or missing references)
//IL_0385: Unknown result type (might be due to invalid IL or missing references)
//IL_038f: Expected O, but got Unknown
//IL_039c: Unknown result type (might be due to invalid IL or missing references)
//IL_03a6: Expected O, but got Unknown
//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
//IL_03d3: Expected O, but got Unknown
//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
//IL_03e9: Expected O, but got Unknown
//IL_0400: Unknown result type (might be due to invalid IL or missing references)
//IL_040a: Expected O, but got Unknown
//IL_0411: Unknown result type (might be due to invalid IL or missing references)
//IL_042d: Unknown result type (might be due to invalid IL or missing references)
//IL_0437: Expected O, but got Unknown
//IL_0444: Unknown result type (might be due to invalid IL or missing references)
//IL_044e: Expected O, but got Unknown
//IL_0455: Unknown result type (might be due to invalid IL or missing references)
//IL_0471: Unknown result type (might be due to invalid IL or missing references)
//IL_047b: Expected O, but got Unknown
//IL_0488: Unknown result type (might be due to invalid IL or missing references)
//IL_0492: Expected O, but got Unknown
//IL_0499: Unknown result type (might be due to invalid IL or missing references)
//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
//IL_04bf: Expected O, but got Unknown
PluginConfigurator obj = PluginConfigurator.Create("Easy Swap", "com.the_cat.EasySwap");
obj.SetIconWithURL(Path.Combine(Plugin.AssemblyFolder, "icon.png") ?? "");
Color[] variantColors = Plugin.GetVariantColors();
ConfigPanel val = new ConfigPanel(obj.rootPanel, "Revolver", "revlovPanelES");
RevolverRotEnabled = new List<BoolField>();
RevolverBlue = new KeyCodeField(val, "Revolver (Piercer)", "RevlovES1", (KeyCode)0);
RevolverBlue.fieldColor = variantColors[0];
RevolverRotEnabled.Add(new BoolField(val, "Allow rotation", "rev0rot", true));
RevolverGreen = new KeyCodeField(val, "Revolver (Marksman)", "RevlovES2", (KeyCode)0);
RevolverGreen.fieldColor = variantColors[1];
RevolverRotEnabled.Add(new BoolField(val, "Allow rotation", "rev2rot", true));
RevolverRed = new KeyCodeField(val, "Revolver (Sharpshooter)", "RevlovES3", (KeyCode)0);
RevolverRed.fieldColor = variantColors[2];
RevolverRotEnabled.Insert(1, new BoolField(val, "Allow rotation", "rev1rot", true));
ConfigPanel val2 = new ConfigPanel(obj.rootPanel, "Shotgun", "ShotPanelES");
ShotgunRotEnabled = new List<BoolField>();
ShotgunBlue = new KeyCodeField(val2, "Shotgun (Core Eject)", "ShotES1", (KeyCode)0);
ShotgunBlue.fieldColor = variantColors[0];
ShotgunRotEnabled.Add(new BoolField(val2, "Allow rotation", "shot0rot", true));
ShotgunGreen = new KeyCodeField(val2, "Shotgun (Pump)", "ShotES2", (KeyCode)0);
ShotgunGreen.fieldColor = variantColors[1];
ShotgunRotEnabled.Add(new BoolField(val2, "Allow rotation", "shot1rot", true));
ShotgunRed = new KeyCodeField(val2, "Shotgun (Sawed On)", "ShotES3", (KeyCode)0);
ShotgunRed.fieldColor = variantColors[2];
ShotgunRotEnabled.Add(new BoolField(val2, "Allow rotation", "shot2rot", true));
ConfigPanel val3 = new ConfigPanel(obj.rootPanel, "Nailgun", "NailPanelES");
NailgunRotEnabled = new List<BoolField>();
NailgunBlue = new KeyCodeField(val3, "Nailgun (Attractor)", "NailES1", (KeyCode)0);
NailgunBlue.fieldColor = variantColors[0];
NailgunRotEnabled.Add(new BoolField(val3, "Allow rotation", "nai0rot", true));
NailgunGreen = new KeyCodeField(val3, "Nailgun (Overheat)", "NailES2", (KeyCode)0);
NailgunGreen.fieldColor = variantColors[1];
NailgunRotEnabled.Add(new BoolField(val3, "Allow rotation", "nai1rot", true));
NailgunRed = new KeyCodeField(val3, "Nailgun (Jumpstart)", "NailES3", (KeyCode)0);
NailgunRed.fieldColor = variantColors[2];
NailgunRotEnabled.Add(new BoolField(val3, "Allow rotation", "nai2rot", true));
ConfigPanel val4 = new ConfigPanel(obj.rootPanel, "Railcannon", "railPanelES");
RailRotEnabled = new List<BoolField>();
RailcannonBlue = new KeyCodeField(val4, "Railcannon (Electric)", "RailES1", (KeyCode)0);
RailcannonBlue.fieldColor = variantColors[0];
RailRotEnabled.Add(new BoolField(val4, "Allow rotation", "rai0rot", true));
RailcannonGreen = new KeyCodeField(val4, "Railcannon (Screwdriver)", "RailES2", (KeyCode)0);
RailcannonGreen.fieldColor = variantColors[1];
RailRotEnabled.Add(new BoolField(val4, "Allow rotation", "rai1rot", true));
RailcannonRed = new KeyCodeField(val4, "Railcannon (Malicious)", "RailES3", (KeyCode)0);
RailcannonRed.fieldColor = variantColors[2];
RailRotEnabled.Add(new BoolField(val4, "Allow rotation", "rai2rot", true));
ConfigPanel val5 = new ConfigPanel(obj.rootPanel, "Rocket Launcher", "railPanelES");
RocketRotEnabled = new List<BoolField>();
RocketBlue = new KeyCodeField(val5, "Rocket (Freeze Frame)", "RocketES1", (KeyCode)0);
RocketBlue.fieldColor = variantColors[0];
RocketRotEnabled.Add(new BoolField(val5, "Allow rotation", "rock0rot", true));
RocketGreen = new KeyCodeField(val5, "Rocket (S.R.S)", "RocketlES2", (KeyCode)0);
RocketGreen.fieldColor = variantColors[1];
RocketRotEnabled.Add(new BoolField(val5, "Allow rotation", "rock1rot", true));
RocketRed = new KeyCodeField(val5, "Rocket (Firestarter)", "RocketES3", (KeyCode)0);
RocketRed.fieldColor = variantColors[2];
RocketRotEnabled.Add(new BoolField(val5, "Allow rotation", "rock2rot", true));
}
}
public class Swap
{
public enum Guns
{
RevolverBlue = 10,
RevolverRed = 11,
RevolverGreen = 12,
ShotgunBlue = 20,
ShotgunGreen = 21,
ShotgunRed = 22,
NailgunBlue = 30,
NailgunGreen = 31,
NailgunRed = 32,
RailBlue = 40,
RailGreen = 41,
RailRed = 42,
RocketBlue = 50,
RocketGreen = 51,
RocketRed = 52
}
public enum GunType
{
Revolver = 10,
Shotgun = 20,
Nailgun = 30,
Rail = 40,
Rocket = 50
}
public static void SwapOnKeypress()
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)MonoSingleton<OptionsManager>.Instance != (Object)null && (Object)(object)MonoSingleton<NewMovement>.Instance != (Object)null && !MonoSingleton<OptionsManager>.Instance.inIntro && !MonoSingleton<OptionsManager>.Instance.paused && !MonoSingleton<NewMovement>.Instance.dead)
{
if (UnityInput.Current.GetKeyDown(PluginConfig.RevolverBlue.value))
{
Plugin.EquipWeapon(Guns.RevolverBlue);
}
else if (UnityInput.Current.GetKeyDown(PluginConfig.RevolverGreen.value))
{
Plugin.EquipWeapon(Guns.RevolverGreen);
}
else if (UnityInput.Current.GetKeyDown(PluginConfig.RevolverRed.value))
{
Plugin.EquipWeapon(Guns.RevolverRed);
}
else if (UnityInput.Current.GetKeyDown(PluginConfig.ShotgunBlue.value))
{
Plugin.EquipWeapon(Guns.ShotgunBlue);
}
else if (UnityInput.Current.GetKeyDown(PluginConfig.ShotgunGreen.value))
{
Plugin.EquipWeapon(Guns.ShotgunGreen);
}
else if (UnityInput.Current.GetKeyDown(PluginConfig.ShotgunRed.value))
{
Plugin.EquipWeapon(Guns.ShotgunRed);
}
else if (UnityInput.Current.GetKeyDown(PluginConfig.NailgunBlue.value))
{
Plugin.EquipWeapon(Guns.NailgunBlue);
}
else if (UnityInput.Current.GetKeyDown(PluginConfig.NailgunGreen.value))
{
Plugin.EquipWeapon(Guns.NailgunGreen);
}
else if (UnityInput.Current.GetKeyDown(PluginConfig.NailgunRed.value))
{
Plugin.EquipWeapon(Guns.NailgunRed);
}
else if (UnityInput.Current.GetKeyDown(PluginConfig.RailcannonBlue.value))
{
Plugin.EquipWeapon(Guns.RailBlue);
}
else if (UnityInput.Current.GetKeyDown(PluginConfig.RailcannonGreen.value))
{
Plugin.EquipWeapon(Guns.RailGreen);
}
else if (UnityInput.Current.GetKeyDown(PluginConfig.RailcannonRed.value))
{
Plugin.EquipWeapon(Guns.RailRed);
}
else if (UnityInput.Current.GetKeyDown(PluginConfig.RocketBlue.value))
{
Plugin.EquipWeapon(Guns.RocketBlue);
}
else if (UnityInput.Current.GetKeyDown(PluginConfig.RocketGreen.value))
{
Plugin.EquipWeapon(Guns.RocketGreen);
}
else if (UnityInput.Current.GetKeyDown(PluginConfig.RocketRed.value))
{
Plugin.EquipWeapon(Guns.RocketRed);
}
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}