Decompiled source of WeaponsManager v1.2.1

WeaponsManager.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using InControl;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Sonigon;
using SoundImplementation;
using TMPro;
using UnboundLib;
using UnboundLib.GameModes;
using UnityEngine;
using UnityEngine.Audio;
using WeaponsManager;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(/*Could not decode attribute arguments.*/)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RSClasses.Utilities
{
	[Serializable]
	public class PlayerActionsAdditionalData : Object
	{
		public PlayerAction nextWeapon;

		public PlayerAction previousWeapon;

		public PlayerActionsAdditionalData()
		{
			nextWeapon = null;
			previousWeapon = null;
		}
	}
	public static class PlayerActionsExtension : Object
	{
		public static readonly ConditionalWeakTable<PlayerActions, PlayerActionsAdditionalData> data = new ConditionalWeakTable<PlayerActions, PlayerActionsAdditionalData>();

		public static PlayerActionsAdditionalData GetAdditionalData(this PlayerActions playerActions)
		{
			return data.GetOrCreateValue(playerActions);
		}

		public static void AddData(this PlayerActions playerActions, PlayerActionsAdditionalData value)
		{
			try
			{
				data.Add(playerActions, value);
			}
			catch (Exception)
			{
			}
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class PlayerActionsPatchPlayerActions : Object
	{
		private static void Postfix(PlayerActions __instance)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			__instance.GetAdditionalData().nextWeapon = (PlayerAction)typeof(PlayerActions).InvokeMember("CreatePlayerAction", (BindingFlags)292, (Binder)null, (object)__instance, (object[])(object)new Object[1] { (Object)"Next Weapon" });
			__instance.GetAdditionalData().previousWeapon = (PlayerAction)typeof(PlayerActions).InvokeMember("CreatePlayerAction", (BindingFlags)292, (Binder)null, (object)__instance, (object[])(object)new Object[1] { (Object)"Previous Weapon" });
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class PlayerActionsPatchCreateWithControllerBindings : Object
	{
		private static void Postfix(ref PlayerActions __result)
		{
			__result.GetAdditionalData().nextWeapon.AddDefaultBinding((InputControlType)14);
			__result.GetAdditionalData().previousWeapon.AddDefaultBinding((InputControlType)13);
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class PlayerActionsPatchCreateWithKeyboardBindings : Object
	{
		private static void Postfix(ref PlayerActions __result)
		{
			__result.GetAdditionalData().nextWeapon.AddDefaultBinding((Key[])(object)new Key[1] { (Key)40 });
			__result.GetAdditionalData().previousWeapon.AddDefaultBinding((Key[])(object)new Key[1] { (Key)52 });
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class GeneralInputPatchUpdate : Object
	{
		private static void Postfix(GeneralInput __instance)
		{
			if (!((Component)__instance).GetComponent<CharacterData>().view.IsMine)
			{
				return;
			}
			if (((OneAxisInputControl)((Component)__instance).GetComponent<CharacterData>().playerActions.GetAdditionalData().nextWeapon).WasPressed)
			{
				WeaponManager component = ((Component)__instance).GetComponent<WeaponManager>();
				if (component != null)
				{
					((Component)__instance).GetComponent<CharacterData>().view.RPC("RPCNextWeapon", (RpcTarget)0, Array.Empty<object>());
				}
			}
			if (((OneAxisInputControl)((Component)__instance).GetComponent<CharacterData>().playerActions.GetAdditionalData().previousWeapon).WasPressed)
			{
				WeaponManager component2 = ((Component)__instance).GetComponent<WeaponManager>();
				if (component2 != null)
				{
					((Component)__instance).GetComponent<CharacterData>().view.RPC("RPCPreviousWeapon", (RpcTarget)0, Array.Empty<object>());
				}
			}
		}
	}
}
namespace WeaponsManager
{
	public class ManagedWeaponAdder : MonoBehaviour
	{
		public Gun weapon;

		public bool applyCardStats;

		public GameObject icon;

		public string weaponName;

		internal void Apply(Player player, WeaponManager weaponManager)
		{
			SetTeamColor[] componentsInChildren = ((Component)weapon).GetComponentsInChildren<SetTeamColor>();
			int frontSortingLayerID = ((Component)player).gameObject.GetComponentInChildren<SpriteMask>().frontSortingLayerID;
			SetTeamColor[] array = componentsInChildren;
			foreach (SetTeamColor val in array)
			{
				SpriteMask component = ((Component)val).gameObject.GetComponent<SpriteMask>();
				component.frontSortingLayerID = frontSortingLayerID;
				component.backSortingLayerID = frontSortingLayerID;
			}
			weaponManager.AddWeapon(weapon, applyCardStats, icon, weaponName);
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPriority(200)]
	public class ApplyPlayerStatsPatch : Object
	{
		private static void Postfix(ApplyCardStats __instance, Player ___playerToUpgrade)
		{
			ManagedWeaponAdder component = ((Component)__instance).GetComponent<ManagedWeaponAdder>();
			if (component != null)
			{
				WeaponManager orAddComponent = ExtensionMethods.GetOrAddComponent<WeaponManager>(((Component)___playerToUpgrade).gameObject, false);
				component.Apply(___playerToUpgrade, orAddComponent);
			}
		}
	}
	public class RightLeftScale : MonoBehaviour
	{
		public Vector3 leftScale;

		private Vector3 rightScale;

		private Holdable holdable;

		private void Start()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			holdable = ((Component)((Component)this).transform.root).GetComponent<Holdable>();
			rightScale = ((Component)this).transform.localScale;
		}

		private void Update()
		{
			//IL_0036: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)holdable) && Object.op_Implicit((Object)(object)holdable.holder))
			{
				Vector3 localScale = ((((Component)this).transform.root.position.x - 0.1f < ((Component)holdable.holder).transform.position.x) ? leftScale : rightScale);
				((Component)this).transform.localScale = localScale;
			}
		}
	}
	public class WeaponManager : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <RoundStart>d__27 : Object, IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IGameModeHandler gm;

			public WeaponManager <>4__this;

			private Enumerator<Gun> <>s__1;

			private Gun <gun>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <RoundStart>d__27(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<gun>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//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)
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				<>s__1 = <>4__this.weapons.GetEnumerator();
				try
				{
					while (<>s__1.MoveNext())
					{
						<gun>5__2 = <>s__1.Current;
						((Weapon)<gun>5__2).sinceAttack = 100f;
						GunAmmo componentInChildren = ((Component)<gun>5__2).gameObject.GetComponentInChildren<GunAmmo>();
						if (componentInChildren != null)
						{
							componentInChildren.ReloadAmmo(true);
						}
						<gun>5__2 = null;
					}
				}
				finally
				{
					((IDisposable)<>s__1).Dispose();
				}
				return false;
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				throw new NotSupportedException();
			}
		}

		internal List<Gun> weapons = new List<Gun>();

		internal List<bool> shouldUpdateStats = new List<bool>();

		internal List<GameObject> icons = new List<GameObject>();

		internal List<string> names = new List<string>();

		private Player player;

		internal int activeWeapon = 0;

		private WeaponHandler weaponHandler;

		private Holding holding;

		private GameObject visualizer;

		private Transform activeSlot;

		private Transform prevSlot;

		private Transform nextSlot;

		private TextMeshProUGUI activeName;

		private TextMeshProUGUI prevName;

		private TextMeshProUGUI nextName;

		public void Awake()
		{
			player = ((Component)this).GetComponentInParent<Player>();
			weaponHandler = ((Component)this).GetComponentInParent<WeaponHandler>();
			holding = ((Component)this).GetComponentInParent<Holding>();
			Gun gun = player.data.weaponHandler.gun;
			weapons.Add(gun);
			shouldUpdateStats.Add(true);
			if (player.data.view.IsMine)
			{
				visualizer = Object.Instantiate<GameObject>(WeaponsManager.assets.LoadAsset<GameObject>("SlotVisualizer"), GameObject.Find("Game/UI/UI_Game/Canvas").transform);
				visualizer.GetComponent<Canvas>().sortingLayerName = "MostFront";
				activeSlot = visualizer.transform.GetChild(0);
				prevSlot = visualizer.transform.GetChild(1);
				nextSlot = visualizer.transform.GetChild(2);
				activeName = ((Component)activeSlot).GetComponentInChildren<TextMeshProUGUI>();
				prevName = ((Component)prevSlot).GetComponentInChildren<TextMeshProUGUI>();
				nextName = ((Component)nextSlot).GetComponentInChildren<TextMeshProUGUI>();
				names.Add("Pistol");
				icons.Add(Object.Instantiate<GameObject>(WeaponsManager.assets.LoadAsset<GameObject>("PistolIcon"), visualizer.transform));
			}
		}

		public void Start()
		{
			visualizer.SetActive(false);
			GameModeManager.AddHook("RoundStart", (Func<IGameModeHandler, IEnumerator>)RoundStart);
		}

		public void AddWeapon(Gun weapon, bool applyCardStats, GameObject icon, string name)
		{
			Gun val = Object.Instantiate<Gun>(weapon);
			weapons.Add(val);
			shouldUpdateStats.Add(applyCardStats);
			if (player.data.view.IsMine)
			{
				icons.Add(Object.Instantiate<GameObject>(icon, visualizer.transform));
				names.Add(name);
				UpdateIcons();
			}
			((Component)val).gameObject.SetActive(false);
			if (applyCardStats)
			{
				GunAmmo componentInChildren = ((Component)weapons[0]).GetComponentInChildren<GunAmmo>();
				GunAmmo componentInChildren2 = ((Component)val).GetComponentInChildren<GunAmmo>();
				componentInChildren2.ammoReg += componentInChildren.ammoReg;
				componentInChildren2.maxAmmo += componentInChildren.maxAmmo - 3;
				componentInChildren2.maxAmmo = Mathf.Clamp(componentInChildren2.maxAmmo, 1, 90);
				componentInChildren2.reloadTimeMultiplier *= componentInChildren.reloadTime;
				componentInChildren2.reloadTimeAdd += componentInChildren.reloadTimeAdd;
				try
				{
					ApplyCardStats.CopyGunStats(weapons[0], val);
				}
				catch (Object)
				{
				}
			}
			FixedNewGunSound(val);
			visualizer.SetActive(true);
		}

		private void FixedNewGunSound(Gun gun)
		{
			GunAmmo componentInChildren = ((Component)gun).GetComponentInChildren<GunAmmo>();
			SoundGun soundGun = gun.soundGun;
			AudioMixerGroup audioMixerGroup = SoundVolumeManager.Instance.audioMixer.FindMatchingGroups("SFX")[0];
			componentInChildren.soundReloadComplete.variables.audioMixerGroup = audioMixerGroup;
			componentInChildren.soundReloadInProgressLoop.variables.audioMixerGroup = audioMixerGroup;
			SoundEvent[] triggerOnPlaySoundEvents = componentInChildren.soundReloadInProgressLoop.variables.triggerOnPlaySoundEvents;
			foreach (SoundEvent val in triggerOnPlaySoundEvents)
			{
				val.variables.audioMixerGroup = audioMixerGroup;
			}
			SoundEvent[] triggerOnStopSoundEvents = componentInChildren.soundReloadInProgressLoop.variables.triggerOnStopSoundEvents;
			foreach (SoundEvent val2 in triggerOnStopSoundEvents)
			{
				val2.variables.audioMixerGroup = audioMixerGroup;
			}
			soundGun.soundShotModifierBasic.single.variables.audioMixerGroup = audioMixerGroup;
			soundGun.soundShotModifierBasic.singleAutoLoop.variables.audioMixerGroup = audioMixerGroup;
			soundGun.soundShotModifierBasic.singleAutoTail.variables.audioMixerGroup = audioMixerGroup;
			soundGun.soundShotModifierBasic.shotgun.variables.audioMixerGroup = audioMixerGroup;
			soundGun.soundShotModifierBasic.shotgunAutoLoop.variables.audioMixerGroup = audioMixerGroup;
			soundGun.soundShotModifierBasic.shotgunAutoTail.variables.audioMixerGroup = audioMixerGroup;
			soundGun.soundImpactModifierBasic.impactCharacter.variables.audioMixerGroup = audioMixerGroup;
			soundGun.soundImpactModifierBasic.impactEnvironment.variables.audioMixerGroup = audioMixerGroup;
			soundGun.soundImpactModifierDamageToExplosionHuge.impactCharacter.variables.audioMixerGroup = audioMixerGroup;
			soundGun.soundImpactModifierDamageToExplosionHuge.impactEnvironment.variables.audioMixerGroup = audioMixerGroup;
			soundGun.soundImpactModifierDamageToExplosionMedium.impactCharacter.variables.audioMixerGroup = audioMixerGroup;
			soundGun.soundImpactModifierDamageToExplosionMedium.impactEnvironment.variables.audioMixerGroup = audioMixerGroup;
			soundGun.soundImpactBounce.variables.audioMixerGroup = audioMixerGroup;
			soundGun.soundImpactBullet.variables.audioMixerGroup = audioMixerGroup;
		}

		private void UpdateIcons()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: 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_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			Enumerator<GameObject> enumerator = icons.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					GameObject current = enumerator.Current;
					ExtensionMethods.SetYPosition(current.transform, -1000f);
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			if (weapons.Count > 2)
			{
				icons[(activeWeapon + icons.Count - 1) % icons.Count].transform.SetPositionAndRotation(prevSlot.position, prevSlot.rotation);
				icons[(activeWeapon + icons.Count - 1) % icons.Count].transform.localScale = new Vector3(2f, 2f, 2f);
				((TMP_Text)prevName).text = names[(activeWeapon + icons.Count - 1) % icons.Count];
			}
			else
			{
				((TMP_Text)prevName).text = "";
			}
			if (weapons.Count > 1)
			{
				icons[(activeWeapon + 1) % icons.Count].transform.SetPositionAndRotation(nextSlot.position, nextSlot.rotation);
				icons[(activeWeapon + 1) % icons.Count].transform.localScale = new Vector3(2f, 2f, 2f);
				((TMP_Text)nextName).text = names[(activeWeapon + 1) % icons.Count];
			}
			else
			{
				((TMP_Text)nextName).text = "";
			}
			icons[activeWeapon].transform.SetPositionAndRotation(activeSlot.position, activeSlot.rotation);
			icons[activeWeapon].transform.localScale = new Vector3(3f, 3f, 3f);
			((TMP_Text)activeName).text = names[activeWeapon];
		}

		public void RemoveWeapon(Predicate<Gun> weapon)
		{
			int num = weapons.FindIndex(weapon);
			weapons.RemoveAt(num);
			shouldUpdateStats.RemoveAt(num);
			icons.RemoveAt(num);
			names.RemoveAt(num);
		}

		public void NextWeapon()
		{
			SetActiveWeapon((activeWeapon + 1) % weapons.Count);
		}

		public void PreviousWeapon()
		{
			SetActiveWeapon((activeWeapon - 1 + weapons.Count) % weapons.Count);
		}

		private void SetActiveWeapon(int index)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Invalid comparison between Unknown and I4
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Invalid comparison between I4 and Unknown
			((Component)weapons[activeWeapon]).gameObject.SetActive(false);
			((Component)weapons[index]).transform.SetPositionAndRotation(((Component)weapons[activeWeapon]).transform.position, ((Component)weapons[activeWeapon]).transform.rotation);
			activeWeapon = index;
			((Component)weapons[activeWeapon]).gameObject.SetActive(true);
			weaponHandler.gun = weapons[activeWeapon];
			ExtensionMethods.SetFieldValue((object)holding, "gun", (object)weapons[activeWeapon]);
			holding.holdable = ((Component)weapons[activeWeapon]).GetComponentInParent<Holdable>();
			GunAmmo componentInChildren = ((Component)weapons[activeWeapon]).gameObject.GetComponentInChildren<GunAmmo>();
			if ((int)(Int32)ExtensionMethods.GetFieldValue((object)componentInChildren, "currentAmmo") <= 0)
			{
				try
				{
					componentInChildren.reloadAnim.PlayIn();
				}
				catch (Object)
				{
				}
			}
			else
			{
				try
				{
					componentInChildren.reloadAnim.PlayOut();
				}
				catch (Object)
				{
				}
			}
			for (int i = 1; i < ((Component)componentInChildren.populate).transform.childCount; i++)
			{
				if (i <= (int)(Int32)ExtensionMethods.GetFieldValue((object)componentInChildren, "currentAmmo"))
				{
					try
					{
						((Component)((Component)componentInChildren.populate).transform.GetChild(i)).GetComponent<CurveAnimation>().PlayIn();
					}
					catch (Object)
					{
					}
				}
				else
				{
					try
					{
						((Component)((Component)componentInChildren.populate).transform.GetChild(i)).GetComponent<CurveAnimation>().PlayOut();
					}
					catch (Object)
					{
					}
				}
			}
			if (player.data.view.IsMine)
			{
				UpdateIcons();
			}
		}

		public void Reset()
		{
			SetActiveWeapon(0);
			for (int i = weapons.Count - 1; i > 0; i++)
			{
				Object.Destroy((Object)(object)weapons[i]);
			}
			Object.Destroy((Object)(object)this);
		}

		[PunRPC]
		public void RPCNextWeapon()
		{
			NextWeapon();
		}

		[PunRPC]
		public void RPCPreviousWeapon()
		{
			PreviousWeapon();
		}

		[IteratorStateMachine(/*Could not decode attribute arguments.*/)]
		private IEnumerator RoundStart(IGameModeHandler gm)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return (IEnumerator)(object)new <RoundStart>d__27(0)
			{
				<>4__this = this,
				gm = gm
			};
		}

		private void OnDestroy()
		{
			GameModeManager.RemoveHook("RoundStart", (Func<IGameModeHandler, IEnumerator>)RoundStart);
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	public class FullResetPatch : Object
	{
		private static void Prefix(Player __instance)
		{
			WeaponManager component = ((Component)__instance).gameObject.GetComponent<WeaponManager>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.Reset();
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.rsmind.rounds.weaponsmanager", "Weapon Manager", "1.2.1")]
	[BepInProcess("Rounds.exe")]
	public class WeaponsManager : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <GameStart>d__12 : Object, IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IGameModeHandler gm;

			public WeaponsManager <>4__this;

			private Enumerator<Player> <>s__1;

			private Player <player>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <GameStart>d__12(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<player>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				<>s__1 = PlayerManager.instance.players.GetEnumerator();
				try
				{
					while (<>s__1.MoveNext())
					{
						<player>5__2 = <>s__1.Current;
						ExtensionMethods.GetOrAddComponent<WeaponManager>(((Component)<player>5__2).gameObject, false);
						<player>5__2 = null;
					}
				}
				finally
				{
					((IDisposable)<>s__1).Dispose();
				}
				return false;
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				throw new NotSupportedException();
			}
		}

		private const string ModId = "com.rsmind.rounds.weaponsmanager";

		private const string ModName = "Weapon Manager";

		public const string Version = "1.2.1";

		public const string ModInitials = "WM";

		internal static AssetBundle assets;

		public static bool Debug;

		[field: CompilerGenerated]
		[field: DebuggerBrowsable(/*Could not decode attribute arguments.*/)]
		public static WeaponsManager instance
		{
			[CompilerGenerated]
			get;
			[CompilerGenerated]
			private set;
		}

		private void Awake()
		{
			//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("com.rsmind.rounds.weaponsmanager");
			val.PatchAll();
			assets = AssetUtils.LoadAssetBundleFromResources("weaponsmanager", typeof(WeaponsManager).Assembly);
			if ((Object)(object)assets == (Object)null)
			{
				Debug.Log((object)"Failed to load Weapons Manager asset bundle");
			}
		}

		private void Start()
		{
			instance = this;
			GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)GameStart);
		}

		[IteratorStateMachine(/*Could not decode attribute arguments.*/)]
		private IEnumerator GameStart(IGameModeHandler gm)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return (IEnumerator)(object)new <GameStart>d__12(0)
			{
				<>4__this = this,
				gm = gm
			};
		}
	}
}
namespace WeaponsManager.Patches
{
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPriority(600)]
	internal class ApplyCardStatsPatch : Object
	{
		private static void Prefix(ApplyCardStats __instance, Player ___playerToUpgrade, Gun ___myGunStats, out int __state)
		{
			__state = -1;
			WeaponManager component = ((Component)___playerToUpgrade).gameObject.GetComponent<WeaponManager>();
			if (!((Object)(object)component != (Object)null) || component.shouldUpdateStats[component.activeWeapon])
			{
				return;
			}
			GunAmmo componentInChildren = ((Component)component.weapons[component.activeWeapon]).gameObject.GetComponentInChildren<GunAmmo>();
			if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				componentInChildren.ammoReg -= ___myGunStats.ammoReg;
				componentInChildren.maxAmmo -= ___myGunStats.ammo;
				__state = componentInChildren.maxAmmo;
				if (___myGunStats.reloadTime != 0f)
				{
					componentInChildren.reloadTimeMultiplier /= ___myGunStats.reloadTime;
				}
				componentInChildren.reloadTimeAdd -= ___myGunStats.reloadTimeAdd;
			}
		}

		private static void Postfix(ApplyCardStats __instance, Player ___playerToUpgrade, Gun ___myGunStats, int __state)
		{
			WeaponManager component = ((Component)___playerToUpgrade).gameObject.GetComponent<WeaponManager>();
			if (!((Object)(object)component != (Object)null) || !Object.op_Implicit((Object)(object)___myGunStats))
			{
				return;
			}
			if (__state != -1)
			{
				GunAmmo componentInChildren = ((Component)component.weapons[component.activeWeapon]).gameObject.GetComponentInChildren<GunAmmo>();
				componentInChildren.maxAmmo = __state;
			}
			for (int i = 0; i < component.weapons.Count; i++)
			{
				if (i != component.activeWeapon && Object.op_Implicit((Object)(object)component.weapons[i]) && component.shouldUpdateStats[i])
				{
					GunAmmo componentInChildren2 = ((Component)component.weapons[i]).gameObject.GetComponentInChildren<GunAmmo>();
					if (Object.op_Implicit((Object)(object)componentInChildren2))
					{
						componentInChildren2.ammoReg += ___myGunStats.ammoReg;
						componentInChildren2.maxAmmo += ___myGunStats.ammo;
						componentInChildren2.maxAmmo = Mathf.Clamp(componentInChildren2.maxAmmo, 1, 90);
						componentInChildren2.reloadTimeMultiplier *= ___myGunStats.reloadTime;
						componentInChildren2.reloadTimeAdd += ___myGunStats.reloadTimeAdd;
					}
					if (___myGunStats.lockGunToDefault)
					{
						component.weapons[i].defaultCooldown = ___myGunStats.forceSpecificAttackSpeed;
						component.weapons[i].lockGunToDefault = ___myGunStats.lockGunToDefault;
					}
					try
					{
						ApplyCardStats.CopyGunStats(___myGunStats, component.weapons[i]);
					}
					catch (Object)
					{
					}
				}
			}
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPriority(600)]
	internal class CopyGunStatsPatch : Object
	{
		private static bool Prefix(ApplyCardStats __instance, Gun copyToGun)
		{
			if (Object.op_Implicit((Object)(object)copyToGun.player))
			{
				WeaponManager component = ((Component)copyToGun.player).GetComponent<WeaponManager>();
				if (component != null && (Object)(object)component.weapons[component.activeWeapon] == (Object)(object)copyToGun && !component.shouldUpdateStats[component.activeWeapon])
				{
					return false;
				}
			}
			return true;
		}
	}
}