Decompiled source of BringBackDualGun v1.0.2

BringBackDualGun.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Configgy;
using HarmonyLib;
using ULTRAKILL.Cheats;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ThundergunRevised")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ThundergunRevised")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5711e2a0-d5a7-4ddf-b8d4-00f355fe9397")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: NeutralResourcesLanguage("en-FI")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BringBackDualGun;

[BepInPlugin("plonk.dualgun", "Bring back dual pistol", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class WeaponMakerScript : BaseUnityPlugin
{
	public enum GunType
	{
		Pierce = 1,
		Marksman,
		Sharpshooter
	}

	[HarmonyPatch]
	public class Patches
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(Revolver), "Shoot")]
		public static bool FixShootCharge(Revolver __instance, int shotType)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)((Component)__instance).transform.parent).name.Contains("Revolver Dual 1"))
			{
				__instance.cc.StopShake();
				__instance.shootReady = false;
				__instance.shootCharge = 0f;
				if (__instance.altVersion)
				{
					MonoSingleton<WeaponCharges>.Instance.revaltpickupcharges[__instance.gunVariation] = 2f;
				}
				Bounds bounds;
				AnimatorStateInfo currentAnimatorStateInfo;
				switch (shotType)
				{
				case 1:
				{
					GameObject val2 = Object.Instantiate<GameObject>(__instance.revolverBeam, ((Component)__instance.cc).transform.position, ((Component)__instance.cc).transform.rotation);
					if (Object.op_Implicit((Object)(object)__instance.targeter.CurrentTarget) && __instance.targeter.IsAutoAimed)
					{
						Transform transform2 = val2.transform;
						bounds = __instance.targeter.CurrentTarget.bounds;
						transform2.LookAt(((Bounds)(ref bounds)).center);
					}
					RevolverBeam component2 = val2.GetComponent<RevolverBeam>();
					component2.sourceWeapon = __instance.gc.currentWeapon;
					component2.alternateStartPoint = __instance.gunBarrel.transform.position;
					component2.gunVariation = __instance.gunVariation;
					currentAnimatorStateInfo = __instance.anim.GetCurrentAnimatorStateInfo(0);
					if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("PickUp"))
					{
						component2.quickDraw = true;
					}
					__instance.currentGunShot = Random.Range(0, __instance.gunShots.Length);
					__instance.gunAud.clip = __instance.gunShots[__instance.currentGunShot];
					__instance.gunAud.volume = 0.55f;
					__instance.gunAud.pitch = Random.Range(0.9f, 1.1f);
					__instance.gunAud.Play();
					__instance.cam.fieldOfView = __instance.cam.fieldOfView + __instance.cc.defaultFov / 40f;
					MonoSingleton<RumbleManager>.Instance.SetVibrationTracked(RumbleProperties.GunFire, ((Component)__instance).gameObject);
					break;
				}
				case 2:
				{
					GameObject val = Object.Instantiate<GameObject>(__instance.revolverBeamSuper, ((Component)__instance.cc).transform.position, ((Component)__instance.cc).transform.rotation);
					if (Object.op_Implicit((Object)(object)__instance.targeter.CurrentTarget) && __instance.targeter.IsAutoAimed)
					{
						Transform transform = val.transform;
						bounds = __instance.targeter.CurrentTarget.bounds;
						transform.LookAt(((Bounds)(ref bounds)).center);
					}
					RevolverBeam component = val.GetComponent<RevolverBeam>();
					component.sourceWeapon = __instance.gc.currentWeapon;
					component.alternateStartPoint = __instance.gunBarrel.transform.position;
					component.gunVariation = __instance.gunVariation;
					if (__instance.gunVariation == 2)
					{
						component.ricochetAmount = Mathf.Min(3, Mathf.FloorToInt(__instance.pierceShotCharge / 25f));
					}
					__instance.pierceShotCharge = 0f;
					currentAnimatorStateInfo = __instance.anim.GetCurrentAnimatorStateInfo(0);
					if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("PickUp"))
					{
						component.quickDraw = true;
					}
					__instance.pierceReady = false;
					__instance.pierceCharge = 0f;
					if (__instance.gunVariation == 0)
					{
						__instance.screenAud.clip = __instance.chargingSound;
						__instance.screenAud.loop = true;
						if (__instance.altVersion)
						{
							__instance.screenAud.pitch = 0.5f;
						}
						else
						{
							__instance.screenAud.pitch = 1f;
						}
						__instance.screenAud.volume = 0.55f;
						__instance.screenAud.Play();
					}
					else if (!Object.op_Implicit((Object)(object)__instance.wid) || __instance.wid.delay == 0f)
					{
						WeaponCharges wc = __instance.wc;
						wc.rev2charge -= (float)((((ConfigValueElement<GunType>)(object)rrevtype).Value == GunType.Sharpshooter && ((ConfigValueElement<GunType>)(object)lrevtype).Value == GunType.Sharpshooter) ? 50 : 100);
					}
					if (Object.op_Implicit((Object)(object)__instance.superGunAud))
					{
						__instance.currentGunShot = Random.Range(0, __instance.superGunShots.Length);
						__instance.superGunAud.clip = __instance.superGunShots[__instance.currentGunShot];
						__instance.superGunAud.volume = 0.5f;
						__instance.superGunAud.pitch = Random.Range(0.9f, 1.1f);
						__instance.superGunAud.Play();
					}
					if (__instance.gunVariation == 2 && Object.op_Implicit((Object)(object)__instance.twirlShotSound))
					{
						Object.Instantiate<GameObject>(__instance.twirlShotSound, ((Component)__instance).transform.position, Quaternion.identity);
					}
					__instance.cam.fieldOfView = __instance.cam.fieldOfView + __instance.cc.defaultFov / 20f;
					MonoSingleton<RumbleManager>.Instance.SetVibrationTracked(RumbleProperties.GunFireStrong, ((Component)__instance).gameObject);
					break;
				}
				}
				if (!__instance.altVersion)
				{
					__instance.cylinder.DoTurn();
				}
				__instance.anim.SetFloat("RandomChance", Random.Range(0f, 1f));
				if (shotType == 1)
				{
					__instance.anim.SetTrigger("Shoot");
				}
				else
				{
					__instance.anim.SetTrigger("ChargeShoot");
				}
				__instance.gunReady = false;
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Revolver), "Update")]
		public static bool FixCoinCharge(Revolver __instance)
		{
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a35: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a40: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b09: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)((Component)__instance).transform.parent).name.Contains("Revolver Dual 1"))
			{
				if (!__instance.shootReady)
				{
					float num = Random.Range(0f, 66f);
					if (__instance.shootCharge + (200f - num) * Time.deltaTime < 100f)
					{
						__instance.shootCharge += (200f - num) * Time.deltaTime;
					}
					else
					{
						__instance.shootCharge = 100f;
						__instance.shootReady = true;
					}
				}
				if (!__instance.pierceReady)
				{
					if (__instance.gunVariation == 0)
					{
						if (NoWeaponCooldown.NoCooldown)
						{
							__instance.pierceCharge = 100f;
						}
						float num2 = 1f;
						if (__instance.altVersion)
						{
							num2 = 0.5f;
						}
						if (__instance.pierceCharge + 40f * Time.deltaTime < 100f)
						{
							__instance.pierceCharge += 40f * Time.deltaTime * num2;
						}
						else
						{
							__instance.pierceCharge = 100f;
							__instance.pierceReady = true;
							__instance.screenAud.clip = __instance.chargedSound;
							__instance.screenAud.loop = false;
							__instance.screenAud.volume = 0.35f;
							__instance.screenAud.pitch = Random.Range(1f, 1.1f);
							__instance.screenAud.Play();
						}
						if (__instance.cylinder.spinSpeed > 0f)
						{
							__instance.cylinder.spinSpeed = Mathf.MoveTowards(__instance.cylinder.spinSpeed, 0f, Time.deltaTime * 50f);
						}
						if (__instance.pierceCharge < 50f)
						{
							__instance.screenProps.SetTexture("_MainTex", (Texture)(object)__instance.batteryLow);
							__instance.screenProps.SetColor("_Color", Color.red);
						}
						else if (__instance.pierceCharge < 100f)
						{
							__instance.screenProps.SetTexture("_MainTex", (Texture)(object)__instance.batteryMid);
							__instance.screenProps.SetColor("_Color", Color.yellow);
						}
						else
						{
							__instance.screenProps.SetTexture("_MainTex", (Texture)(object)__instance.batteryFull);
						}
					}
					else if (__instance.pierceCharge + 480f * Time.deltaTime < 100f)
					{
						__instance.pierceCharge += 480f * Time.deltaTime;
					}
					else
					{
						__instance.pierceCharge = 100f;
						__instance.pierceReady = true;
					}
				}
				else if (__instance.gunVariation == 0)
				{
					if (__instance.pierceShotCharge != 0f)
					{
						if (__instance.pierceShotCharge < 50f)
						{
							__instance.screenProps.SetTexture("_MainTex", (Texture)(object)__instance.batteryCharges[0]);
						}
						else if (__instance.pierceShotCharge < 100f)
						{
							__instance.screenProps.SetTexture("_MainTex", (Texture)(object)__instance.batteryCharges[1]);
						}
						else
						{
							__instance.screenProps.SetTexture("_MainTex", (Texture)(object)__instance.batteryCharges[2]);
						}
						((Component)__instance).transform.localPosition = new Vector3(__instance.wpos.currentDefault.x + __instance.pierceShotCharge / 250f * Random.Range(-0.05f, 0.05f), __instance.wpos.currentDefault.y + __instance.pierceShotCharge / 250f * Random.Range(-0.05f, 0.05f), __instance.wpos.currentDefault.z + __instance.pierceShotCharge / 250f * Random.Range(-0.05f, 0.05f));
						__instance.cylinder.spinSpeed = __instance.pierceShotCharge;
					}
					else
					{
						__instance.screenProps.SetTexture("_MainTex", (Texture)(object)__instance.batteryFull);
						if (__instance.cylinder.spinSpeed != 0f)
						{
							__instance.cylinder.spinSpeed = 0f;
						}
					}
				}
				if (__instance.gc.activated)
				{
					if (__instance.gunVariation != 1 && __instance.gunReady)
					{
						float num3 = ((__instance.gunVariation == 0) ? 175 : (__instance.altVersion ? 750 : 150));
						if ((__instance.inman.InputSource.Fire2.WasCanceledThisFrame || (!__instance.inman.PerformingCheatMenuCombo() && !GameStateManager.Instance.PlayerInputLocked && __instance.inman.InputSource.Fire1.IsPressed)) && __instance.shootReady && ((__instance.gunVariation == 0) ? (__instance.pierceShotCharge == 100f) : (__instance.pierceShotCharge >= 25f)))
						{
							if (!Object.op_Implicit((Object)(object)__instance.wid) || __instance.wid.delay == 0f)
							{
								__instance.Shoot(2);
							}
							else
							{
								__instance.shootReady = false;
								__instance.shootCharge = 0f;
								((MonoBehaviour)__instance).Invoke("DelayedShoot2", __instance.wid.delay);
							}
						}
						else if (!__instance.inman.PerformingCheatMenuCombo() && __instance.inman.InputSource.Fire1.IsPressed && __instance.shootReady && !__instance.chargingPierce)
						{
							if (!Object.op_Implicit((Object)(object)__instance.wid) || __instance.wid.delay == 0f)
							{
								__instance.Shoot(1);
							}
							else
							{
								__instance.shootReady = false;
								__instance.shootCharge = 0f;
								((MonoBehaviour)__instance).Invoke("DelayedShoot", __instance.wid.delay);
							}
						}
						else if (__instance.inman.InputSource.Fire2.IsPressed && (__instance.gunVariation == 2 || __instance.shootReady) && ((__instance.gunVariation == 0) ? __instance.pierceReady : (__instance.coinCharge >= (float)(__instance.altVersion ? 300 : 100))))
						{
							if (!__instance.chargingPierce && !__instance.twirlRecovery)
							{
								__instance.latestTwirlRotation = 0f;
							}
							__instance.chargingPierce = true;
							if (__instance.pierceShotCharge + num3 * Time.deltaTime < 100f)
							{
								__instance.pierceShotCharge += num3 * Time.deltaTime;
							}
							else
							{
								__instance.pierceShotCharge = 100f;
							}
						}
						else
						{
							if (__instance.chargingPierce)
							{
								__instance.twirlRecovery = true;
							}
							__instance.chargingPierce = false;
							if (__instance.pierceShotCharge - num3 * Time.deltaTime > 0f)
							{
								__instance.pierceShotCharge -= num3 * Time.deltaTime;
							}
							else
							{
								__instance.pierceShotCharge = 0f;
							}
						}
					}
					else if (__instance.gunVariation == 1)
					{
						if (__instance.inman.InputSource.Fire2.WasPerformedThisFrame && __instance.pierceReady && __instance.coinCharge >= 100f)
						{
							__instance.cc.StopShake();
							if (!Object.op_Implicit((Object)(object)__instance.wid) || __instance.wid.delay == 0f)
							{
								WeaponCharges wc = __instance.wc;
								wc.rev1charge -= (float)((((ConfigValueElement<GunType>)(object)lrevtype).Value == GunType.Marksman && ((ConfigValueElement<GunType>)(object)rrevtype).Value == GunType.Marksman) ? 50 : 100);
							}
							if (!Object.op_Implicit((Object)(object)__instance.wid) || __instance.wid.delay == 0f)
							{
								__instance.ThrowCoin();
							}
							else
							{
								((MonoBehaviour)__instance).Invoke("ThrowCoin", __instance.wid.delay);
								__instance.pierceReady = false;
								__instance.pierceCharge = 0f;
							}
						}
						else if (__instance.gunReady && !__instance.inman.PerformingCheatMenuCombo() && __instance.inman.InputSource.Fire1.IsPressed && __instance.shootReady)
						{
							if (!Object.op_Implicit((Object)(object)__instance.wid) || __instance.wid.delay == 0f)
							{
								__instance.Shoot(1);
							}
							else
							{
								__instance.shootReady = false;
								__instance.shootCharge = 0f;
								((MonoBehaviour)__instance).Invoke("DelayedShoot", __instance.wid.delay);
							}
							if (Object.op_Implicit((Object)(object)__instance.ceaud) && __instance.ceaud.volume != 0f)
							{
								__instance.ceaud.volume = 0f;
							}
						}
					}
				}
				if (Object.op_Implicit((Object)(object)__instance.celight))
				{
					if (__instance.pierceShotCharge == 0f && ((Behaviour)__instance.celight).enabled)
					{
						((Behaviour)__instance.celight).enabled = false;
					}
					else if (__instance.pierceShotCharge != 0f)
					{
						((Behaviour)__instance.celight).enabled = true;
						__instance.celight.range = __instance.pierceShotCharge * 0.01f;
					}
				}
				if (__instance.gunVariation != 1)
				{
					if (__instance.gunVariation == 0)
					{
						__instance.chargeEffect.transform.localScale = Vector3.one * __instance.pierceShotCharge * 0.02f;
						__instance.ceaud.pitch = __instance.pierceShotCharge * 0.005f;
					}
					__instance.ceaud.volume = 0.25f + __instance.pierceShotCharge * 0.005f;
					MonoSingleton<RumbleManager>.Instance.SetVibrationTracked(RumbleProperties.RevolverCharge, ((Component)__instance.ceaud).gameObject).intensityMultiplier = __instance.pierceShotCharge / 250f;
				}
				if (__instance.gunVariation != 0)
				{
					__instance.CheckCoinCharges();
				}
				else if (__instance.pierceCharge == 100f && Object.op_Implicit((Object)(object)MonoSingleton<ColorBlindSettings>.Instance))
				{
					__instance.screenProps.SetColor("_Color", MonoSingleton<ColorBlindSettings>.Instance.variationColors[3]);
				}
				if (__instance.gunVariation == 0)
				{
					((Renderer)__instance.screenMR).SetPropertyBlock(__instance.screenProps);
				}
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Revolver), "LateUpdate")]
		public static bool FixTwirl(Revolver __instance)
		{
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)((Component)__instance).transform.parent).name.Contains("Revolver Dual 1"))
			{
				if (__instance.gunVariation != 2)
				{
					return false;
				}
				if (__instance.chargingPierce || __instance.twirlRecovery)
				{
					__instance.anim.SetBool("Spinning", true);
					bool flag = __instance.latestTwirlRotation < 0f;
					if (__instance.chargingPierce)
					{
						__instance.twirlLevel = Mathf.Min(3f, Mathf.Floor(__instance.pierceShotCharge / 25f)) + 1f;
					}
					else
					{
						__instance.twirlLevel = Mathf.MoveTowards(__instance.twirlLevel, 0.1f, Time.deltaTime * 100f * __instance.twirlLevel);
					}
					__instance.latestTwirlRotation += 1200f * (__instance.twirlLevel / 3f + 0.5f) * Time.deltaTime;
					if (Object.op_Implicit((Object)(object)__instance.twirlSprite))
					{
						__instance.twirlSprite.color = new Color(1f, 1f, 1f, Mathf.Min(2f, Mathf.Floor(__instance.pierceShotCharge / 25f)) / 3f);
					}
					if (!__instance.ceaud.isPlaying)
					{
						__instance.ceaud.Play();
					}
					__instance.ceaud.pitch = 0.5f + __instance.twirlLevel / 2f;
					if (__instance.twirlRecovery && flag && __instance.latestTwirlRotation >= 0f)
					{
						__instance.latestTwirlRotation = 0f;
						__instance.twirlRecovery = false;
						if (Object.op_Implicit((Object)(object)__instance.twirlSprite))
						{
							__instance.twirlSprite.color = new Color(1f, 1f, 1f, 0f);
						}
					}
					else
					{
						while (__instance.latestTwirlRotation > 180f)
						{
							__instance.latestTwirlRotation -= 360f;
						}
						Transform twirlBone = __instance.twirlBone;
						Quaternion localRotation = __instance.twirlBone.localRotation;
						twirlBone.localRotation = Quaternion.Euler(((Quaternion)(ref localRotation)).eulerAngles + (__instance.altVersion ? Vector3.forward : Vector3.forward) * __instance.latestTwirlRotation);
					}
					__instance.anim.SetFloat("TwirlSpeed", __instance.twirlLevel / 3f);
					if (Object.op_Implicit((Object)(object)__instance.wid) && __instance.wid.delay != 0f && !MonoSingleton<NewMovement>.Instance.gc.onGround)
					{
						MonoSingleton<NewMovement>.Instance.rb.AddForce(((Component)MonoSingleton<CameraController>.Instance).transform.up * 400f * __instance.twirlLevel * Time.deltaTime, (ForceMode)5);
						return false;
					}
				}
				else
				{
					__instance.anim.SetBool("Spinning", false);
					if (Object.op_Implicit((Object)(object)__instance.twirlSprite))
					{
						__instance.twirlSprite.color = new Color(1f, 1f, 1f, 0f);
					}
					__instance.ceaud.Stop();
				}
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Revolver), "CheckCoinCharges")]
		public static bool FixCoinSprite(Revolver __instance)
		{
			//IL_0137: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)((Component)__instance).transform.parent).name.Contains("Revolver Dual 1"))
			{
				if (__instance.coinPanelsCharged == null || __instance.coinPanelsCharged.Length == 0)
				{
					__instance.coinPanelsCharged = new bool[__instance.coinPanels.Length];
				}
				__instance.coinCharge = ((__instance.gunVariation == 1) ? __instance.wc.rev1charge : __instance.wc.rev2charge);
				for (int i = 0; i < __instance.coinPanels.Length; i++)
				{
					if (__instance.altVersion && __instance.gunVariation == 2)
					{
						__instance.coinPanels[i].fillAmount = __instance.coinCharge / 300f;
					}
					else
					{
						__instance.coinPanels[i].fillAmount = __instance.coinCharge / 100f - (float)i;
					}
					if (__instance.coinPanels[i].fillAmount < 1f)
					{
						((Graphic)__instance.coinPanels[i]).color = ((__instance.gunVariation == 1) ? Color.red : Color.gray);
						__instance.coinPanelsCharged[i] = false;
						continue;
					}
					if (Object.op_Implicit((Object)(object)MonoSingleton<ColorBlindSettings>.Instance) && ((Graphic)__instance.coinPanels[i]).color != MonoSingleton<ColorBlindSettings>.Instance.variationColors[3])
					{
						((Graphic)__instance.coinPanels[i]).color = MonoSingleton<ColorBlindSettings>.Instance.variationColors[3];
					}
					if (!__instance.coinPanelsCharged[i] && (!Object.op_Implicit((Object)(object)__instance.wid) || __instance.wid.delay == 0f))
					{
						if (!Object.op_Implicit((Object)(object)__instance.screenAud))
						{
							__instance.screenAud = ((Component)((Component)__instance).GetComponentInChildren<Canvas>()).GetComponent<AudioSource>();
						}
						__instance.screenAud.pitch = 1f + (float)i / 2f;
						__instance.screenAud.Play();
						__instance.coinPanelsCharged[i] = true;
					}
				}
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(WeaponIdentifier), "Start")]
		public static void NoDualWield(WeaponIdentifier __instance)
		{
			if (__instance.duplicate && ((Object)((Component)__instance).transform.parent).name.Contains("Revolver Dual 1"))
			{
				Object.Destroy((Object)(object)((Component)__instance).gameObject);
			}
		}
	}

	[Configgable("", "Mod enabled", 0, "Self explanatory")]
	private static ConfigToggle tcenabled = new ConfigToggle(true);

	[Configgable("", "Left revolver type", 0, "BE AWARE: Having two weapons of the same type may cause problems.")]
	public static ConfigDropdown<GunType> lrevtype = new ConfigDropdown<GunType>((GunType[])Enum.GetValues(typeof(GunType)), (string[])null, 0);

	[Configgable("", "Right revolver type", 0, "BE AWARE: Having two weapons of the same type may cause problems.")]
	public static ConfigDropdown<GunType> rrevtype = new ConfigDropdown<GunType>((GunType[])Enum.GetValues(typeof(GunType)), (string[])null, 2);

	[Configgable("", "Revolvers slot position", 0, "Determines the weapon's position in the slot.")]
	public static IntegerSlider slotpos = new IntegerSlider(3, 0, 3);

	public static GameObject bluetc;

	public static GameObject greentc;

	public static AssetBundle tcbundle;

	private static bool candoshit;

	private static bool canswitchstate = true;

	public static ConfigBuilder ConfigBuilder { get; private set; }

	public static void SendHudMessage(string msg, int delay, bool silent)
	{
		MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage(msg, "", "", delay, silent);
	}

	public static Type Fetch<Type>(string name)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		return Addressables.LoadAssetAsync<Type>((object)name).WaitForCompletion();
	}

	public static Type FetchFromBundle<Type>(string name, bool autofill = false) where Type : Object
	{
		if (!autofill)
		{
			return tcbundle.LoadAsset<Type>(name);
		}
		return tcbundle.LoadAsset<Type>("assets/formods/bringbackdualpistol/" + name);
	}

	public static void SetLayerRecursive(GameObject gobject, string layername)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Expected O, but got Unknown
		gobject.layer = LayerMask.NameToLayer(layername);
		foreach (Transform item in gobject.transform)
		{
			Transform val = item;
			((Component)val).gameObject.layer = LayerMask.NameToLayer(layername);
			Transform componentInChildren = ((Component)val).GetComponentInChildren<Transform>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				SetLayerRecursive(((Component)val).gameObject, layername);
			}
		}
	}

	public Vector3 Shake(Vector3 originpos, Vector3 pos, float shakeamt)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: 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_002d: 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)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: 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_009f: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = Vector3.zero;
		val = pos + new Vector3(Random.Range(0f - shakeamt, shakeamt), Random.Range(0f - shakeamt, shakeamt), Random.Range(0f - shakeamt, shakeamt));
		((Vector3)(ref val))..ctor(Mathf.Clamp(val.x, originpos.x - 0.01f, originpos.x + 0.01f), Mathf.Clamp(val.y, originpos.y - 0.01f, originpos.y + 0.01f), Mathf.Clamp(val.z, originpos.z - 0.01f, originpos.z + 0.01f));
		return val;
	}

	public static void Log(string log, int type)
	{
		switch (type)
		{
		case 1:
			Debug.Log((object)log);
			break;
		case 2:
			Debug.LogWarning((object)log);
			break;
		case 3:
			Debug.LogError((object)log);
			break;
		}
	}

	public void Awake()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Expected O, but got Unknown
		ConfigBuilder = new ConfigBuilder("plonk.dualgun", "Bring back dual pistol");
		ConfigBuilder.Build();
		Log("kaboom (bbdg loaded)", 1);
		if ((Object)(object)tcbundle == (Object)null)
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			tcbundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "bringbackdualgun"));
			Log("Got bundle " + (object)tcbundle, 1);
			for (int i = 0; i < tcbundle.GetAllAssetNames().Length; i++)
			{
				Log(tcbundle.GetAllAssetNames()[i].ToString(), 1);
			}
		}
	}

	public static void ResetRevolver()
	{
	}

	public void Start()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("plonk.dualgun");
		val.PatchAll();
	}

	public void Update()
	{
		//IL_049d: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a7: Expected O, but got Unknown
		if (!candoshit && SceneHelper.CurrentScene == "Main Menu")
		{
			if ((Object)(object)tcbundle != (Object)null)
			{
				candoshit = true;
			}
			else
			{
				SendHudMessage("Bring Back Dual gun mod failed to load.\r\n<color=green>The asset bundle (filename \"bringbackdualgun\") is missing or in the wrong place. please place it where the mod's .dll is located.</color>", 0, silent: true);
			}
		}
		if (!candoshit || !(SceneHelper.CurrentScene != "Main Menu"))
		{
			return;
		}
		if (((ConfigValueElement<bool>)(object)tcenabled).Value)
		{
			if ((Object)(object)bluetc == (Object)null)
			{
				bluetc = MakeGun();
			}
			else
			{
				int num = 1;
				if (bluetc.activeSelf && canswitchstate)
				{
					FistControl instance = MonoSingleton<FistControl>.Instance;
					instance.forceNoHold++;
					Debug.Log((object)"added one forcenohold");
					canswitchstate = false;
				}
				if (!bluetc.activeSelf && !canswitchstate)
				{
					FistControl instance2 = MonoSingleton<FistControl>.Instance;
					instance2.forceNoHold--;
					Debug.Log((object)"removed one forcenohold");
					canswitchstate = true;
				}
				if (((ConfigValueElement<GunType>)(object)lrevtype).Value == GunType.Pierce)
				{
					((Component)bluetc.transform.GetChild(1)).gameObject.SetActive(true);
					((Component)bluetc.transform.GetChild(3)).gameObject.SetActive(false);
					((Component)bluetc.transform.GetChild(5)).gameObject.SetActive(false);
				}
				if (((ConfigValueElement<GunType>)(object)lrevtype).Value == GunType.Marksman)
				{
					((Component)bluetc.transform.GetChild(1)).gameObject.SetActive(false);
					((Component)bluetc.transform.GetChild(3)).gameObject.SetActive(true);
					((Component)bluetc.transform.GetChild(5)).gameObject.SetActive(false);
				}
				if (((ConfigValueElement<GunType>)(object)lrevtype).Value == GunType.Sharpshooter)
				{
					((Component)bluetc.transform.GetChild(1)).gameObject.SetActive(false);
					((Component)bluetc.transform.GetChild(3)).gameObject.SetActive(false);
					((Component)bluetc.transform.GetChild(5)).gameObject.SetActive(true);
				}
				if (((ConfigValueElement<GunType>)(object)rrevtype).Value == GunType.Pierce)
				{
					((Component)bluetc.transform.GetChild(0)).gameObject.SetActive(true);
					((Component)bluetc.transform.GetChild(2)).gameObject.SetActive(false);
					((Component)bluetc.transform.GetChild(4)).gameObject.SetActive(false);
				}
				if (((ConfigValueElement<GunType>)(object)rrevtype).Value == GunType.Marksman)
				{
					((Component)bluetc.transform.GetChild(0)).gameObject.SetActive(false);
					((Component)bluetc.transform.GetChild(2)).gameObject.SetActive(true);
					((Component)bluetc.transform.GetChild(4)).gameObject.SetActive(false);
				}
				if (((ConfigValueElement<GunType>)(object)rrevtype).Value == GunType.Sharpshooter)
				{
					((Component)bluetc.transform.GetChild(0)).gameObject.SetActive(false);
					((Component)bluetc.transform.GetChild(2)).gameObject.SetActive(false);
					((Component)bluetc.transform.GetChild(4)).gameObject.SetActive(true);
				}
				int num2 = 0;
				num2 = ((((ConfigValueElement<int>)(object)slotpos).Value <= MonoSingleton<GunControl>.Instance.slots[num - 1].Count - 2) ? ((ConfigValueElement<int>)(object)slotpos).Value : (MonoSingleton<GunControl>.Instance.slots[num - 1].Count - 1));
				if ((Object)(object)MonoSingleton<GunControl>.instance.slots[num - 1][num2] != (Object)(object)bluetc)
				{
					MonoSingleton<GunControl>.Instance.slots[num - 1].Remove(bluetc);
					MonoSingleton<GunControl>.Instance.allWeapons.Remove(bluetc);
					MonoSingleton<GunControl>.Instance.slotDict.Remove(bluetc);
					MonoSingleton<StyleHUD>.Instance.weaponFreshness.Remove(bluetc);
					Object.Destroy((Object)(object)bluetc);
				}
			}
			if ((Object)(object)greentc == (Object)null)
			{
				greentc = new GameObject();
			}
		}
		else if ((Object)(object)bluetc != (Object)null)
		{
			int num3 = 1;
			MonoSingleton<GunControl>.Instance.slots[num3 - 1].Remove(bluetc);
			MonoSingleton<GunControl>.Instance.allWeapons.Remove(bluetc);
			MonoSingleton<GunControl>.Instance.slotDict.Remove(bluetc);
			MonoSingleton<StyleHUD>.Instance.weaponFreshness.Remove(bluetc);
			Object.Destroy((Object)(object)bluetc);
		}
	}

	public static GameObject MakeGun(int slot = 1)
	{
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)MonoSingleton<GunControl>.Instance != (Object)null && (Object)(object)MonoSingleton<StyleHUD>.Instance != (Object)null)
		{
			if (((Behaviour)MonoSingleton<GunControl>.Instance).enabled && ((Behaviour)MonoSingleton<StyleHUD>.Instance).enabled)
			{
				GameObject val = null;
				val = Object.Instantiate<GameObject>((slot == 1) ? WeaponMakerScript.FetchFromBundle<GameObject>("revolver dual 1.prefab", autofill: true) : WeaponMakerScript.FetchFromBundle<GameObject>("shotgun dual.prefab", autofill: true));
				if ((Object)(object)val != (Object)null)
				{
					val.transform.parent = ((Component)MonoSingleton<GunControl>.Instance).transform;
					val.transform.position = ((Component)MonoSingleton<GunControl>.Instance).transform.position;
					val.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
					if (slot <= MonoSingleton<GunControl>.Instance.slots.Count)
					{
						if (((ConfigValueElement<int>)(object)slotpos).Value > MonoSingleton<GunControl>.Instance.slots[slot - 1].Count - 1)
						{
							MonoSingleton<GunControl>.Instance.slots[slot - 1].Add(val);
						}
						else
						{
							MonoSingleton<GunControl>.Instance.slots[slot - 1].Insert(((ConfigValueElement<int>)(object)slotpos).Value, val);
						}
					}
					MonoSingleton<GunControl>.Instance.allWeapons.Add(val);
					MonoSingleton<GunControl>.Instance.slotDict.Add(val, slot - 1);
					MonoSingleton<StyleHUD>.Instance.weaponFreshness.Add(val, 10f);
					val.SetActive(false);
					MonoSingleton<GunControl>.instance.noWeapons = false;
					MonoSingleton<GunControl>.instance.YesWeapon();
					canswitchstate = true;
					Debug.Log((object)"made dual gun");
					for (int i = 0; i < ((Component)MonoSingleton<GunControl>.instance).transform.childCount; i++)
					{
						((Component)((Component)MonoSingleton<GunControl>.instance).transform.GetChild(i)).gameObject.SetActive(false);
					}
					return val;
				}
				Debug.LogError((object)"Failed to create Dual Gun. Prefab not found.");
				return null;
			}
			return null;
		}
		return null;
	}
}