Decompiled source of MoreGuns v1.3.0

MoreGunsMono.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using HarmonyLib;
using MelonLoader;
using MelonLoader.Preferences;
using ModManagerPhoneApp;
using MoreGunsMono;
using MoreGunsMono.Dialogue;
using MoreGunsMono.Gui;
using MoreGunsMono.Guns;
using MoreGunsMono.Patches;
using MoreGunsMono.Sync;
using ScheduleOne;
using ScheduleOne.Audio;
using ScheduleOne.AvatarFramework;
using ScheduleOne.AvatarFramework.Equipping;
using ScheduleOne.DevUtilities;
using ScheduleOne.Dialogue;
using ScheduleOne.Equipping;
using ScheduleOne.FX;
using ScheduleOne.ItemFramework;
using ScheduleOne.Levelling;
using ScheduleOne.NPCs;
using ScheduleOne.Networking;
using ScheduleOne.PlayerScripts;
using ScheduleOne.Tools;
using ScheduleOne.Trash;
using ScheduleOne.UI;
using Steamworks;
using UnityEngine;
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: MelonInfo(typeof(MoreGunsMod), "MoreGuns", "1.2.0", "Voidane", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: AssemblyTitle("MoreGunsMono")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoreGunsMono")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0acfbd7a-0bd3-4fb9-b8ae-1bee6f4573e3")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.2.0.0")]
namespace MoreGunsMono
{
	public static class Config
	{
		public static string folderPath = "UserData/MoreGuns.cfg";

		public const string PREFIX = "MoreGuns";

		public static MelonPreferences_Category Category { get; private set; }

		public static MelonPreferences_Entry<bool> EnableCrosshairForGuns { get; private set; }

		public static void Initialize()
		{
			Category = MelonPreferences.CreateCategory("MoreGuns-! User Settings");
			EnableCrosshairForGuns = Category.CreateEntry<bool>("Allow Gun Crosshair", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			Category.SetFilePath(folderPath);
			Category.SaveToFile(true);
		}
	}
	public class GunConfiguration
	{
		public static string folderPath = "UserData/MoreGuns.cfg";

		public string ID { get; private set; }

		public MelonPreferences_Category Category { get; private set; }

		public MelonPreferences_Entry<float> Damage { get; private set; }

		public MelonPreferences_Entry<float> ImpactForce { get; private set; }

		public MelonPreferences_Entry<float> AimFOVReduction { get; private set; }

		public MelonPreferences_Entry<float> AccuracyChangeDuration { get; private set; }

		public MelonPreferences_Entry<int> MagazineSize { get; private set; }

		public MelonPreferences_Entry<string> DisplayItemName { get; private set; }

		public MelonPreferences_Entry<string> DisplayDescription { get; private set; }

		public MelonPreferences_Entry<Color> LabelDisplayColor { get; private set; }

		public MelonPreferences_Entry<ELegalStatus> LegalStatus { get; private set; }

		public MelonPreferences_Entry<FullRank> RequiredRank { get; private set; }

		public MelonPreferences_Entry<string> MagDisplayItemName { get; private set; }

		public MelonPreferences_Entry<string> MagDisplayDescription { get; private set; }

		public MelonPreferences_Entry<Color> MagLabelDisplayColor { get; private set; }

		public MelonPreferences_Entry<ELegalStatus> MagLegalStatus { get; private set; }

		public MelonPreferences_Entry<FullRank> MagRequiredRank { get; private set; }

		public MelonPreferences_Entry<float> PurchasePrice { get; private set; }

		public MelonPreferences_Entry<float> MagPurchasePrice { get; private set; }

		public MelonPreferences_Entry<string> ItemName { get; private set; }

		public MelonPreferences_Entry<string> MagItemName { get; private set; }

		public MelonPreferences_Entry<bool> Available { get; private set; }

		public MelonPreferences_Entry<bool> MagAvailable { get; private set; }

		public MelonPreferences_Entry<string> AvailableReason { get; private set; }

		public MelonPreferences_Entry<string> MagAvailableReason { get; private set; }

		public event Action OnSettingChanged;

		public GunConfiguration(WeaponBase weapon)
		{
			string iD = weapon.ID;
			string text = "MoreGuns-" + iD + " Settings";
			string text2 = iD + " Settings";
			Category = MelonPreferences.CreateCategory(text, text2);
			InitializePreferences(iD, weapon);
			Category.SetFilePath(folderPath);
			Category.SaveToFile(true);
			MelonLogger.Msg("Loaded configuration for " + iD + " from: " + folderPath);
		}

		private void InitializePreferences(string ID, WeaponBase weapon)
		{
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			Equippable_RangedWeapon gunRangedWeapon = weapon.gunRangedWeapon;
			Damage = Category.CreateEntry<float>(ID + " Damage", gunRangedWeapon.Damage, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			ImpactForce = Category.CreateEntry<float>(ID + " Impact Force", gunRangedWeapon.ImpactForce, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			AimFOVReduction = Category.CreateEntry<float>(ID + " Aim FOV Reduction", gunRangedWeapon.AimFOVReduction, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			AccuracyChangeDuration = Category.CreateEntry<float>(ID + " Accuracy Change Duration", gunRangedWeapon.AccuracyChangeDuration, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			MagazineSize = Category.CreateEntry<int>(ID + " Magazine Size", gunRangedWeapon.MagazineSize, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			IntegerItemDefinition gunIntItemDef = weapon.gunIntItemDef;
			DisplayItemName = Category.CreateEntry<string>(ID + " Display Name", ((ItemDefinition)gunIntItemDef).Name, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			DisplayDescription = Category.CreateEntry<string>(ID + " Display Description", ((ItemDefinition)gunIntItemDef).Description, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			LabelDisplayColor = Category.CreateEntry<Color>(ID + " Label Color", ((ItemDefinition)gunIntItemDef).LabelDisplayColor, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			LegalStatus = Category.CreateEntry<ELegalStatus>(ID + " Legal Status", ((ItemDefinition)gunIntItemDef).legalStatus, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			RequiredRank = Category.CreateEntry<FullRank>(ID + " Required Rank", ((StorableItemDefinition)gunIntItemDef).RequiredRank, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			IntegerItemDefinition magIntItemDef = weapon.magIntItemDef;
			MagDisplayItemName = Category.CreateEntry<string>(ID + " Mag Display Name", ((ItemDefinition)magIntItemDef).Name, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			MagDisplayDescription = Category.CreateEntry<string>(ID + " Mag Display Description", ((ItemDefinition)magIntItemDef).Description, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			MagLabelDisplayColor = Category.CreateEntry<Color>(ID + " Mag Label Color", ((ItemDefinition)magIntItemDef).LabelDisplayColor, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			MagLegalStatus = Category.CreateEntry<ELegalStatus>(ID + " Mag Legal Status", (ELegalStatus)0, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			MagRequiredRank = Category.CreateEntry<FullRank>(ID + " Mag Required Rank", new FullRank((ERank)8, 3), (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			Shopping gunShop = weapon.gunShop;
			PurchasePrice = Category.CreateEntry<float>(ID + " Price", gunShop.purchasePrice, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			ItemName = Category.CreateEntry<string>(ID + " Name", gunShop.displayName, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			Available = Category.CreateEntry<bool>(ID + " Shop Availability", gunShop.available, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			AvailableReason = Category.CreateEntry<string>(ID + " Non-Available Reason", gunShop.nonAvailableReason, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			Shopping magShop = weapon.magShop;
			MagPurchasePrice = Category.CreateEntry<float>(ID + " Magazine Price", magShop.purchasePrice, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			MagItemName = Category.CreateEntry<string>(ID + " Magazine Name", magShop.displayName, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			MagAvailable = Category.CreateEntry<bool>(ID + " Magazine Shop Availability", magShop.available, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			MagAvailableReason = Category.CreateEntry<string>(ID + " Magazine Non-Available Reason", magShop.nonAvailableReason, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		}

		public void HandleSettingsUpdate()
		{
			MelonLogger.Msg("Updating More Guns Settings");
			Category.LoadFromFile(true);
			this.OnSettingChanged?.Invoke();
		}
	}
	[Serializable]
	public class GunConfigData
	{
		public string ID;

		public float Damage;

		public float ImpactForce;

		public float AimFOVReduction;

		public float AccuracyChangeDuration;

		public int MagazineSize;

		public string DisplayItemName;

		public string DisplayDescription;

		public Color LabelDisplayColor;

		public ELegalStatus LegalStatus;

		public FullRank RequiredRank;

		public string MagDisplayItemName;

		public string MagDisplayDescription;

		public Color MagLabelDisplayColor;

		public ELegalStatus MagLegalStatus;

		public FullRank MagRequiredRank;

		public float PurchasePrice;

		public float MagPurchasePrice;

		public string ItemName;

		public string MagItemName;

		public bool Available;

		public bool MagAvailable;

		public string AvailableReason;

		public string MagAvailableReason;

		public string ToJson()
		{
			return JsonUtility.ToJson((object)this);
		}

		public static GunConfigData FromJson(string json)
		{
			try
			{
				return JsonUtility.FromJson<GunConfigData>(json);
			}
			catch (Exception ex)
			{
				MelonLogger.Error("Failed to parse gun config data: " + ex.Message);
				return null;
			}
		}

		public static GunConfigData FromConfig(GunConfiguration config)
		{
			//IL_0090: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			return new GunConfigData
			{
				ID = config.ID,
				Damage = config.Damage.Value,
				ImpactForce = config.ImpactForce.Value,
				AimFOVReduction = config.AimFOVReduction.Value,
				AccuracyChangeDuration = config.AccuracyChangeDuration.Value,
				MagazineSize = config.MagazineSize.Value,
				DisplayItemName = config.DisplayItemName.Value,
				DisplayDescription = config.DisplayDescription.Value,
				LabelDisplayColor = config.LabelDisplayColor.Value,
				LegalStatus = config.LegalStatus.Value,
				RequiredRank = config.RequiredRank.Value,
				MagDisplayItemName = config.MagDisplayItemName.Value,
				MagDisplayDescription = config.MagDisplayDescription.Value,
				MagLabelDisplayColor = config.MagLabelDisplayColor.Value,
				MagLegalStatus = config.MagLegalStatus.Value,
				MagRequiredRank = config.MagRequiredRank.Value,
				PurchasePrice = config.PurchasePrice.Value,
				MagPurchasePrice = config.MagPurchasePrice.Value,
				ItemName = config.ItemName.Value,
				MagItemName = config.MagItemName.Value,
				Available = config.Available.Value,
				MagAvailable = config.MagAvailable.Value,
				AvailableReason = config.AvailableReason.Value,
				MagAvailableReason = config.MagAvailableReason.Value
			};
		}
	}
	public class MoreGunsMod : MelonMod
	{
		public static Transform map;

		public static Transform container;

		public static Transform midcanal;

		public static Transform stanNPC;

		public static AssetBundle assetBundle;

		public static bool isInitialized;

		public static Harmony harmony;

		public override void OnInitializeMelon()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			MelonLogger.Msg("MoreGuns Is Initializing");
			MelonLogger.Msg("Thank you for using More Guns! Discord: discord.gg/XB7ruKtJje");
			Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MoreGunsMono.voidanesguns");
			if (manifestResourceStream == null)
			{
				MelonLogger.Error("Could not find manifest resource stream. MoreGuns will not run.");
				isInitialized = false;
				return;
			}
			harmony = new Harmony("com.voidane.moreguns");
			harmony.PatchAll();
			MelonLogger.Msg("All harmony patches patched.");
			assetBundle = AssetBundle.LoadFromStream(manifestResourceStream);
			manifestResourceStream.Close();
			if ((Object)(object)assetBundle != (Object)null)
			{
				isInitialized = true;
				MelonLogger.Msg("Assetbundle loaded in.");
				Config.Initialize();
				new AK47();
				new MiniGun();
				TryLoadingDependencies();
			}
			else
			{
				MelonLogger.Error("Assetbundle was not loaded in. MoreGuns will not run.");
				MelonLogger.Warning("All patches were unpatched.");
				StopProcess();
			}
		}

		public override void OnApplicationQuit()
		{
			harmony.UnpatchSelf();
		}

		private static void TryLoadingDependencies()
		{
			try
			{
				MelonLogger.Msg("Subscribing to all guns configuration events to phone manager");
				foreach (WeaponBase allWeapon in WeaponBase.allWeapons)
				{
					allWeapon.config.OnSettingChanged += allWeapon.ApplySettingsFromConfig;
					ModSettingsEvents.OnPreferencesSaved += allWeapon.config.HandleSettingsUpdate;
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Warning(ex.Message ?? "");
			}
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (sceneName == "Main")
			{
				NetworkController.SyncConfiguration();
				Reticle.Initialize();
				Transform transform = GameObject.Find("UI/HUD").transform;
				ReloadMessage.Initialize(transform);
				WindupIndicator.Initialize(transform);
			}
			else
			{
				ItemRegistryPatch.isWeaponsRegistered = false;
			}
		}

		public static void StopProcess()
		{
			harmony.UnpatchSelf();
			isInitialized = false;
		}
	}
	public static class Resource
	{
		private static Dictionary<string, Object> _customResources = new Dictionary<string, Object>(StringComparer.OrdinalIgnoreCase);

		public static void RegisterAsset(string path, Object asset)
		{
			_customResources[path] = asset;
			MelonLogger.Msg("Registered custom asset at path: " + path);
		}

		public static Object TryGetAsset(string path)
		{
			if (_customResources.TryGetValue(path, out var value))
			{
				return value;
			}
			return null;
		}
	}
	public struct Shopping
	{
		public float purchasePrice;

		public string displayName;

		public bool available;

		public string nonAvailableReason;
	}
	public static class Tools
	{
		public static class Color
		{
			public static Color StringRGBAToColor(string rgba)
			{
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				string text = rgba.Replace("RGBA(", "").Replace(")", "");
				string[] array = text.Split(new char[1] { ',' });
				if (!float.TryParse(array[0].Trim(), out var result))
				{
					throw new ArgumentException("Could not parse RGBA value");
				}
				if (!float.TryParse(array[1].Trim(), out var result2))
				{
					throw new ArgumentException("Could not parse RGBA value");
				}
				if (!float.TryParse(array[2].Trim(), out var result3))
				{
					throw new ArgumentException("Could not parse RGBA value");
				}
				if (!float.TryParse(array[3].Trim(), out var result4))
				{
					throw new ArgumentException("Could not parse RGBA value");
				}
				return new Color(result, result2, result3, result4);
			}
		}

		public static class LegalStatus
		{
			public static ELegalStatus StringConvertToELegalStatus(string eLegalStatus)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				if (Enum.TryParse<ELegalStatus>(eLegalStatus, out ELegalStatus result))
				{
					return result;
				}
				throw new ArgumentException("Error in converting ELegalStatus.");
			}
		}

		public static class Rank
		{
			public static FullRank StringConvertToFullRank(string pRank)
			{
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				string[] array = pRank.Split(new char[1] { ' ' });
				if (array.Length != 2)
				{
					throw new ArgumentException("Error in amount of arguments for FullRank Convet.");
				}
				string value = array[0].Trim();
				string text = array[1].Trim();
				if (!Enum.TryParse<ERank>(value, out ERank result))
				{
					throw new ArgumentException("Error in converting FullRank Rank.");
				}
				int num = 1;
				num = text switch
				{
					"I" => 1, 
					"II" => 2, 
					"III" => 3, 
					"IV" => 4, 
					"V" => 5, 
					_ => throw new ArgumentException("Error in converting FullRank Tier. Was not a"), 
				};
				FullRank result2 = default(FullRank);
				result2.Rank = result;
				result2.Tier = num;
				return result2;
			}
		}
	}
}
namespace MoreGunsMono.Sync
{
	public static class NetworkController
	{
		[CompilerGenerated]
		private sealed class <SyncHostToLobbyPayload>d__11 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			private List<WeaponBase>.Enumerator <>s__1;

			private WeaponBase <weapon>5__2;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<>s__1 = default(List<WeaponBase>.Enumerator);
				<weapon>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Expected O, but got Unknown
				//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_0222: Unknown result type (might be due to invalid IL or missing references)
				//IL_0288: 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_02ce: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					int num = <>1__state;
					if (num != 0)
					{
						if (num != 1)
						{
							return false;
						}
						<>1__state = -3;
						goto IL_0096;
					}
					<>1__state = -1;
					<>s__1 = WeaponBase.allWeapons.GetEnumerator();
					<>1__state = -3;
					goto IL_040c;
					IL_0096:
					if (!<weapon>5__2.IsConfigurationFinished)
					{
						MelonLogger.Msg("config not ready");
						<>2__current = (object)new WaitForSeconds(0.05f);
						<>1__state = 1;
						return true;
					}
					MelonLogger.Msg("Adding new gun");
					payload.Append("@" + <weapon>5__2.ID + ":" + $"{<weapon>5__2.gunRangedWeapon.Damage}:" + $"{<weapon>5__2.gunRangedWeapon.ImpactForce}:" + $"{<weapon>5__2.gunRangedWeapon.AimFOVReduction}:" + $"{<weapon>5__2.gunRangedWeapon.AccuracyChangeDuration}:" + $"{<weapon>5__2.gunRangedWeapon.MagazineSize}" + ":" + ((ItemDefinition)<weapon>5__2.gunIntItemDef).Name + ":" + ((ItemDefinition)<weapon>5__2.gunIntItemDef).Description + ":" + $"{((ItemDefinition)<weapon>5__2.gunIntItemDef).LabelDisplayColor}:" + $"{((ItemDefinition)<weapon>5__2.gunIntItemDef).legalStatus}:" + $"{((StorableItemDefinition)<weapon>5__2.gunIntItemDef).RequiredRank}" + ":" + ((ItemDefinition)<weapon>5__2.magIntItemDef).Name + ":" + ((ItemDefinition)<weapon>5__2.magIntItemDef).Description + ":" + $"{((ItemDefinition)<weapon>5__2.magIntItemDef).LabelDisplayColor}:" + $"{((ItemDefinition)<weapon>5__2.magIntItemDef).legalStatus}:" + $"{((StorableItemDefinition)<weapon>5__2.magIntItemDef).RequiredRank}" + ":" + <weapon>5__2.rangedGun.Name + ":" + $"{<weapon>5__2.rangedGun.Price}:" + $"{<weapon>5__2.rangedGun.IsAvailable}:" + <weapon>5__2.rangedGun.NotAvailableReason + ":" + <weapon>5__2.ammoGun.Name + ":" + $"{<weapon>5__2.ammoGun.Price}:" + $"{<weapon>5__2.ammoGun.IsAvailable}:" + <weapon>5__2.ammoGun.NotAvailableReason);
					MelonLogger.Msg("init " + <weapon>5__2.ID);
					<weapon>5__2 = null;
					goto IL_040c;
					IL_040c:
					if (<>s__1.MoveNext())
					{
						<weapon>5__2 = <>s__1.Current;
						<weapon>5__2.ApplySettingsFromConfig();
						goto IL_0096;
					}
					<>m__Finally1();
					<>s__1 = default(List<WeaponBase>.Enumerator);
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				((IDisposable)<>s__1).Dispose();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <WaitOnLobbyPayload>d__10 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			private string <data>5__1;

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

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

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

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

			private bool MoveNext()
			{
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					<data>5__1 = null;
					break;
				}
				MelonLogger.Msg("Getting lobby info");
				<data>5__1 = SteamMatchmaking.GetLobbyData(Singleton<Lobby>.Instance.LobbySteamID, "MoreGunsConfig");
				MelonLogger.Msg("Lobby data fetched: " + <data>5__1);
				if (!string.IsNullOrEmpty(<data>5__1))
				{
					MelonLogger.Msg("payload: " + payload.ToString());
					HostToClientConfigurationSync(<data>5__1);
					return false;
				}
				MelonLogger.Msg("Waiting for payload.");
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 1;
				return true;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private const string IDENTIFICATION_PREFIX = "moreguns_settings";

		private static readonly string version = typeof(MoreGunsMod).Assembly.GetName().Version.ToString();

		public static StringBuilder payload;

		public static bool forceHost = false;

		public static bool forceClient = false;

		public static bool IsSynced { get; private set; } = false;


		public static void SyncConfiguration()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			Lobby instance = Singleton<Lobby>.Instance;
			bool flag = instance != null && instance.IsHost;
			Lobby instance2 = Singleton<Lobby>.Instance;
			int num;
			if (instance2 != null && !instance2.IsHost)
			{
				Lobby instance3 = Singleton<Lobby>.Instance;
				num = ((instance3 != null && instance3.IsInLobby) ? 1 : 0);
			}
			else
			{
				num = 0;
			}
			bool flag2 = (byte)num != 0;
			MelonLogger.Msg($"Player joined with ID: {Singleton<Lobby>.Instance.LocalPlayerID}. Syncing configuration file.");
			payload = new StringBuilder();
			payload.Append("moreguns_settings_" + version + "|");
			if ((flag && !forceClient) || forceHost)
			{
				MelonLogger.Msg("Host loaded!");
				MelonCoroutines.Start(SyncHostToLobbyPayload());
				MelonLogger.Msg("Attempting to send payload");
				Singleton<Lobby>.Instance.SetLobbyData("MoreGunsConfig", payload.ToString());
				MelonLogger.Msg("Sent payload to netowkrk: " + payload.ToString());
				return;
			}
			if ((flag2 && !forceHost) || forceClient)
			{
				MelonLogger.Msg("Client loaded!");
				MelonCoroutines.Start(WaitOnLobbyPayload());
				return;
			}
			MelonLogger.Msg("Singleplayer");
			foreach (WeaponBase allWeapon in WeaponBase.allWeapons)
			{
				allWeapon.ApplySettingsFromConfig();
			}
			MelonCoroutines.Start(SyncHostToLobbyPayload());
		}

		[IteratorStateMachine(typeof(<WaitOnLobbyPayload>d__10))]
		public static IEnumerator WaitOnLobbyPayload()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitOnLobbyPayload>d__10(0);
		}

		[IteratorStateMachine(typeof(<SyncHostToLobbyPayload>d__11))]
		private static IEnumerator SyncHostToLobbyPayload()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SyncHostToLobbyPayload>d__11(0);
		}

		private static void HostToClientConfigurationSync(string data)
		{
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			MelonLogger.Msg(data ?? "");
			string[] array = (from item in data.Split(new char[1] { '|' })
				where !string.IsNullOrEmpty(item)
				select item).ToArray();
			if (!IsModValidForSync(array[0]))
			{
				MelonLogger.Warning("MoreGuns is outdated with the host or server.");
				MelonLogger.Warning("Your Version: moreguns_settings_" + version + ", Host Version: " + array[0]);
			}
			string[] array2 = (from item in array[1].Split(new char[1] { '@' })
				where !string.IsNullOrEmpty(item)
				select item).ToArray();
			string[] array3 = array2;
			foreach (string text in array3)
			{
				int num = 0;
				string[] array4 = text.Split(new char[1] { ':' });
				if (!WeaponBase.weaponsByName.TryGetValue(array4[0], out var value) || !float.TryParse(array4[1], out var result) || !float.TryParse(array4[2], out var result2) || !float.TryParse(array4[3], out var result3) || !float.TryParse(array4[4], out var result4) || !int.TryParse(array4[5], out var result5))
				{
					continue;
				}
				string name = array4[6];
				string description = array4[7];
				Color labelDisplayColor = Tools.Color.StringRGBAToColor(array4[8]);
				ELegalStatus legalStatus = Tools.LegalStatus.StringConvertToELegalStatus(array4[9]);
				FullRank requiredRank = Tools.Rank.StringConvertToFullRank(array4[10]);
				string name2 = array4[11];
				string description2 = array4[12];
				Color labelDisplayColor2 = Tools.Color.StringRGBAToColor(array4[13]);
				ELegalStatus legalStatus2 = Tools.LegalStatus.StringConvertToELegalStatus(array4[14]);
				FullRank requiredRank2 = Tools.Rank.StringConvertToFullRank(array4[15]);
				string name3 = array4[16];
				if (float.TryParse(array4[17], out var result6) && bool.TryParse(array4[18], out var result7))
				{
					string notAvailableReason = array4[19];
					string name4 = array4[20];
					if (float.TryParse(array4[21], out var result8) && bool.TryParse(array4[22], out var result9))
					{
						string notAvailableReason2 = array4[23];
						value.gunRangedWeapon.Damage = result;
						value.gunRangedWeapon.ImpactForce = result2;
						value.gunRangedWeapon.AimFOVReduction = result3;
						value.gunRangedWeapon.AccuracyChangeDuration = result4;
						value.gunRangedWeapon.MagazineSize = result5;
						((ItemDefinition)value.gunIntItemDef).Name = name;
						((ItemDefinition)value.gunIntItemDef).Description = description;
						((ItemDefinition)value.gunIntItemDef).LabelDisplayColor = labelDisplayColor;
						((ItemDefinition)value.gunIntItemDef).legalStatus = legalStatus;
						((StorableItemDefinition)value.gunIntItemDef).RequiredRank = requiredRank;
						((ItemDefinition)value.magIntItemDef).Name = name2;
						((ItemDefinition)value.magIntItemDef).Description = description2;
						((ItemDefinition)value.magIntItemDef).LabelDisplayColor = labelDisplayColor2;
						((ItemDefinition)value.magIntItemDef).legalStatus = legalStatus2;
						((StorableItemDefinition)value.magIntItemDef).RequiredRank = requiredRank2;
						value.rangedGun.Name = name3;
						value.rangedGun.Price = result6;
						value.rangedGun.IsAvailable = result7;
						value.rangedGun.NotAvailableReason = notAvailableReason;
						value.ammoGun.Name = name4;
						value.ammoGun.Price = result8;
						value.ammoGun.IsAvailable = result9;
						value.ammoGun.NotAvailableReason = notAvailableReason2;
					}
				}
			}
		}

		private static bool IsModValidForSync(string pIdentify)
		{
			string text = "moreguns_settings_" + version;
			return pIdentify == text;
		}
	}
}
namespace MoreGunsMono.Patches
{
	[HarmonyPatch]
	public static class BulletTrailPatch
	{
		[HarmonyPatch(typeof(FXManager), "CreateBulletTrail")]
		[HarmonyPrefix]
		public static bool Prefix(FXManager __instance, Vector3 start, Vector3 dir, float speed, float range, LayerMask mask)
		{
			return false;
		}
	}
	[HarmonyPatch]
	public static class CameraJoltPatch
	{
		public static string ID = "";

		[HarmonyPatch(typeof(PlayerCamera), "JoltCamera")]
		[HarmonyPrefix]
		public static bool Prefix(PlayerCamera __instance)
		{
			if (WeaponBase.weaponsByName.TryGetValue(ID, out var value))
			{
				if (!value.settings.cameraJolt)
				{
					return false;
				}
				return true;
			}
			return true;
		}

		[HarmonyPatch(typeof(Equippable_RangedWeapon), "Fire")]
		[HarmonyPrefix]
		public static void Prefix(Equippable_RangedWeapon __instance)
		{
			ID = ((Object)((Component)__instance).gameObject).name.Replace("_Equippable(Clone)", "").ToLower();
		}
	}
	[HarmonyPatch]
	public static class DialoguePatch
	{
		public static bool called;

		[HarmonyPatch(typeof(DialogueHandler), "ShowNode")]
		[HarmonyPrefix]
		public static void Prefix(DialogueHandler __instance, DialogueNodeData node)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			if (!called && node.Guid == "925ea1d9-9b7e-47a0-b016-6a3b787290c3")
			{
				List<DialogueChoiceData> list = node.choices.ToList();
				DialogueChoiceData item = list[3];
				list[3] = new DialogueChoiceData
				{
					Guid = "voiddial-stan-guns-opti-reloadmultgn",
					ChoiceText = "Reload Guns",
					ChoiceLabel = "Reload Guns"
				};
				list.Add(item);
				node.choices = list.ToArray();
				called = true;
			}
		}

		[HarmonyPatch(typeof(DialogueController_ArmsDealer), "ChoiceCallback")]
		[HarmonyPrefix]
		public static void Prefix(DialogueController_ArmsDealer __instance, string choiceLabel)
		{
			if (choiceLabel == "Reload Guns")
			{
				StanDialogue.StartSpecialGunReloads();
			}
		}
	}
	[HarmonyPatch]
	public static class Equippale_RangedWeaponPatch
	{
		private static float timeSinceLastAutoFire;

		private static float timeSinceWindingUp;

		[HarmonyPatch(typeof(Equippable_RangedWeapon), "UpdateInput")]
		[HarmonyPostfix]
		public static void Postfix(Equippable_RangedWeapon __instance)
		{
			GunSettings gunSettings = default(GunSettings);
			if (Time.timeScale == 0f || Singleton<PauseMenu>.Instance.IsPaused || !((Component)__instance).gameObject.TryGetComponent<GunSettings>(ref gunSettings))
			{
				return;
			}
			bool button = GameInput.GetButton((ButtonCode)0);
			bool button2 = GameInput.GetButton((ButtonCode)1);
			if (gunSettings.requiredWindup)
			{
				PlayAnimation component = ((Component)((Component)__instance).transform.GetChild(0)).GetComponent<PlayAnimation>();
				AudioSourceController component2 = ((Component)((Component)component).transform.Find("Windup Sound")).GetComponent<AudioSourceController>();
				AudioSourceController component3 = ((Component)((Component)component).transform.Find("Shutdown Sound")).GetComponent<AudioSourceController>();
				timeSinceWindingUp += Time.deltaTime;
				WindupIndicator.SetValueByTime(timeSinceWindingUp, gunSettings.windupTime);
				if (button2)
				{
					if (timeSinceWindingUp <= gunSettings.windupTime || !button)
					{
						component.Play("MiniGun Windup");
						if (!component2.isPlaying)
						{
							component2.Play();
						}
					}
				}
				else
				{
					WindupIndicator.SetValue(0);
					timeSinceWindingUp = 0f;
					component2.Stop();
				}
			}
			if ((!gunSettings.isAutomatic || !gunSettings.requiredWindup || !(timeSinceWindingUp > gunSettings.windupTime)) && (!gunSettings.isAutomatic || gunSettings.requiredWindup))
			{
				return;
			}
			timeSinceLastAutoFire += Time.deltaTime;
			if (button)
			{
				if (!(timeSinceLastAutoFire >= __instance.FireCooldown))
				{
					return;
				}
				timeSinceLastAutoFire = 0f;
				if ((bool)AccessTools.Method(typeof(Equippable_RangedWeapon), "CanFire", (Type[])null, (Type[])null).Invoke(__instance, new object[1] { false }) && __instance.Ammo > 0)
				{
					if (!__instance.MustBeCocked || __instance.IsCocked)
					{
						AccessTools.Method(typeof(Equippable_RangedWeapon), "Fire", (Type[])null, (Type[])null).Invoke(__instance, null);
					}
					else
					{
						AccessTools.Method(typeof(Equippable_RangedWeapon), "Cock", (Type[])null, (Type[])null).Invoke(__instance, null);
					}
				}
			}
			else
			{
				timeSinceLastAutoFire = __instance.FireCooldown;
			}
		}

		[HarmonyPatch(typeof(Equippable_RangedWeapon), "Fire")]
		[HarmonyPrefix]
		public static bool Prefix(Equippable_RangedWeapon __instance)
		{
			GunSettings gunSettings = default(GunSettings);
			if (((Component)__instance).gameObject.TryGetComponent<GunSettings>(ref gunSettings) && gunSettings.requiredWindup && timeSinceWindingUp < gunSettings.windupTime)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Registry), "_GetItem")]
	public static class ItemRegistryPatch
	{
		public static bool isWeaponsRegistered;

		public static void Prefix(Registry __instance, string ID)
		{
			if (!isWeaponsRegistered)
			{
				foreach (WeaponBase allWeapon in WeaponBase.allWeapons)
				{
					__instance.AddToRegistry((ItemDefinition)(object)allWeapon.magIntItemDef);
					MelonLogger.Msg("Registered " + allWeapon.ID + " magazine item def");
					__instance.AddToRegistry((ItemDefinition)(object)allWeapon.gunIntItemDef);
					MelonLogger.Msg("Registered " + allWeapon.ID + " item def");
				}
			}
			isWeaponsRegistered = true;
		}
	}
	[HarmonyPatch]
	public static class RangedWeaponEquipPatch
	{
		[HarmonyPatch(typeof(Equippable_RangedWeapon), "Equip")]
		[HarmonyPostfix]
		public static void PostfixEquip(Equippable_RangedWeapon __instance)
		{
			Reticle.reticle.SetActive(Config.EnableCrosshairForGuns.Value);
			GunSettings component = ((Component)__instance).GetComponent<GunSettings>();
			if ((Object)(object)component != (Object)null)
			{
				if (component.requiredWindup)
				{
					WindupIndicator.Show(shown: true);
				}
				PlayerSingleton<PlayerMovement>.Instance.MoveSpeedMultiplier = component.speedMultiplier;
			}
		}

		[HarmonyPatch(typeof(Equippable_RangedWeapon), "Unequip")]
		[HarmonyPostfix]
		public static void PostfixUnequip(Equippable_RangedWeapon __instance)
		{
			Reticle.reticle.SetActive(false);
			WindupIndicator.Show(shown: false);
			PlayerSingleton<PlayerMovement>.Instance.MoveSpeedMultiplier = 1f;
		}
	}
	[HarmonyPatch]
	public static class ReloadingPatch
	{
		[HarmonyPatch(typeof(Equippable_RangedWeapon), "Reload")]
		[HarmonyPrefix]
		public static bool Prefix(Equippable_RangedWeapon __instance)
		{
			GunSettings component = ((Component)__instance).gameObject.GetComponent<GunSettings>();
			if ((Object)(object)component != (Object)null && !component.canManuallyReload)
			{
				ReloadMessage.Show(show: true);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch]
	public static class SetAnimationPatch
	{
	}
	[HarmonyPatch]
	public static class SetEquippablePatch
	{
		[HarmonyPatch(typeof(Avatar), "SetEquippable")]
		[HarmonyPrefix]
		public static bool Prefix(ref AvatarEquippable __result, string assetPath, Avatar __instance)
		{
			Object obj = Resources.Load(assetPath);
			GameObject val = (GameObject)(object)((obj is GameObject) ? obj : null);
			if ((Object)(object)val != (Object)null)
			{
				return true;
			}
			if (string.IsNullOrEmpty(assetPath))
			{
				return true;
			}
			if ((Object)(object)__instance.CurrentEquippable != (Object)null)
			{
				__instance.CurrentEquippable.Unequip();
			}
			Object obj2 = Resource.TryGetAsset(assetPath);
			GameObject val2 = (GameObject)(object)((obj2 is GameObject) ? obj2 : null);
			if ((Object)(object)val2 == (Object)null)
			{
				MelonLogger.Error("asset couldntbe found");
			}
			GameObject val3 = Object.Instantiate<GameObject>(val2, (Transform)null);
			AvatarEquippable component = val3.GetComponent<AvatarEquippable>();
			if ((Object)(object)component == (Object)null)
			{
				MelonLogger.Msg("avatar equip was null");
			}
			AccessTools.Property(typeof(Avatar), "CurrentEquippable").SetValue(__instance, component);
			component.Equip(__instance);
			__result = component;
			return false;
		}
	}
	[HarmonyPatch]
	public static class StanNPCPatch
	{
		[CompilerGenerated]
		private sealed class <InitializeStore>d__2 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public Stan __instance;

			private DialogueController_ArmsDealer <dialogueController_ArmsDealer>5__1;

			private FieldInfo <allWeaponsFields>5__2;

			private List<WeaponOption> <allWeapons>5__3;

			private List<WeaponBase>.Enumerator <>s__4;

			private WeaponBase <weapon>5__5;

			private List<WeaponBase>.Enumerator <>s__6;

			private WeaponBase <weapon>5__7;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<dialogueController_ArmsDealer>5__1 = null;
				<allWeaponsFields>5__2 = null;
				<allWeapons>5__3 = null;
				<>s__4 = default(List<WeaponBase>.Enumerator);
				<weapon>5__5 = null;
				<>s__6 = default(List<WeaponBase>.Enumerator);
				<weapon>5__7 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					goto IL_005a;
				case 1:
					<>1__state = -1;
					goto IL_005a;
				case 2:
					{
						<>1__state = -1;
						break;
					}
					IL_005a:
					if (!ItemRegistryPatch.isWeaponsRegistered)
					{
						MelonLogger.Msg("Attempting to setup stan store, waiting on registries!");
						<>2__current = (object)new WaitForSeconds(0.5f);
						<>1__state = 1;
						return true;
					}
					if ((Object)(object)MoreGunsMod.stanNPC != (Object)null)
					{
						<>2__current = false;
						<>1__state = 2;
						return true;
					}
					break;
				}
				MoreGunsMod.stanNPC = GameObject.Find("Stan/Dialogue").transform;
				if ((Object)(object)MoreGunsMod.stanNPC == (Object)null)
				{
					MelonLogger.Msg("stan dialogue was not loaded in");
				}
				<dialogueController_ArmsDealer>5__1 = ((Component)MoreGunsMod.stanNPC).GetComponent<DialogueController_ArmsDealer>();
				if ((Object)(object)<dialogueController_ArmsDealer>5__1 == (Object)null)
				{
					MelonLogger.Error("Dialogue comp not found");
				}
				<allWeaponsFields>5__2 = typeof(DialogueController_ArmsDealer).GetField("allWeapons", BindingFlags.Instance | BindingFlags.NonPublic);
				if (<allWeaponsFields>5__2 != null)
				{
					<allWeapons>5__3 = <allWeaponsFields>5__2.GetValue(<dialogueController_ArmsDealer>5__1) as List<WeaponOption>;
					if (<allWeapons>5__3 != null)
					{
						<>s__4 = WeaponBase.allWeapons.GetEnumerator();
						try
						{
							while (<>s__4.MoveNext())
							{
								<weapon>5__5 = <>s__4.Current;
								if (!<allWeapons>5__3.Contains(<weapon>5__5.rangedGun))
								{
									<allWeapons>5__3.Add(<weapon>5__5.rangedGun);
								}
								if (!<allWeapons>5__3.Contains(<weapon>5__5.ammoGun))
								{
									<allWeapons>5__3.Add(<weapon>5__5.ammoGun);
								}
								MelonLogger.Msg("[MoreGuns] Loaded " + <weapon>5__5.ID + " to the store!");
								<weapon>5__5 = null;
							}
						}
						finally
						{
							((IDisposable)<>s__4).Dispose();
						}
						<>s__4 = default(List<WeaponBase>.Enumerator);
						MelonLogger.Msg("[MoreGuns] Finished adding new guns to store!");
					}
					else
					{
						MelonLogger.Error("[MoreGuns] All weapons was null");
					}
					<allWeapons>5__3 = null;
				}
				else
				{
					MelonLogger.Error("[MoreGuns] Weapon field was null");
				}
				<>s__6 = WeaponBase.allWeapons.GetEnumerator();
				try
				{
					while (<>s__6.MoveNext())
					{
						<weapon>5__7 = <>s__6.Current;
						if (!<dialogueController_ArmsDealer>5__1.RangedWeapons.Contains(<weapon>5__7.rangedGun))
						{
							<dialogueController_ArmsDealer>5__1.RangedWeapons.Add(<weapon>5__7.rangedGun);
						}
						if (!<dialogueController_ArmsDealer>5__1.Ammo.Contains(<weapon>5__7.ammoGun))
						{
							<dialogueController_ArmsDealer>5__1.Ammo.Add(<weapon>5__7.ammoGun);
						}
						<weapon>5__7 = null;
					}
				}
				finally
				{
					((IDisposable)<>s__6).Dispose();
				}
				<>s__6 = default(List<WeaponBase>.Enumerator);
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static object coroutine;

		[HarmonyPatch(typeof(Stan), "Loaded")]
		public static void Postfix(Stan __instance)
		{
			MelonLogger.Msg("Stan Loaded in");
			MelonCoroutines.Start(InitializeStore(__instance));
		}

		[IteratorStateMachine(typeof(<InitializeStore>d__2))]
		public static IEnumerator InitializeStore(Stan __instance)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <InitializeStore>d__2(0)
			{
				__instance = __instance
			};
		}
	}
	[HarmonyPatch]
	public static class TrashRegistryPatch
	{
		[HarmonyPatch(typeof(TrashManager), "Start")]
		[HarmonyPrefix]
		public static void Prefix(TrashManager __instance)
		{
			List<TrashItem> list = __instance.TrashPrefabs.ToList();
			foreach (WeaponBase allWeapon in WeaponBase.allWeapons)
			{
				if (!list.Contains(allWeapon.gunMagTrashItem))
				{
					MelonLogger.Msg("Added " + allWeapon.ID + " gun trash to TrashManager");
					list.Add(allWeapon.gunMagTrashItem);
				}
			}
			__instance.TrashPrefabs = list.ToArray();
		}
	}
}
namespace MoreGunsMono.Guns
{
	public class AK47 : WeaponBase
	{
		private static AK47 instance;

		public static AK47 Instance => instance;

		public AK47()
		{
			if (instance == null)
			{
				string iD = "ak47";
				Shopping shopping = new Shopping
				{
					purchasePrice = 15000f,
					displayName = "AK47",
					available = true,
					nonAvailableReason = ""
				};
				Shopping shopping2 = new Shopping
				{
					purchasePrice = 1000f,
					displayName = "AK47 Magazine",
					available = true,
					nonAvailableReason = ""
				};
				GunSettings gunSettings = new GunSettings
				{
					isAutomatic = true,
					cameraJolt = true,
					speedMultiplier = 1f,
					requiredWindup = false,
					windupTime = 0f,
					canManuallyReload = true
				};
				Init(iD, shopping, shopping2, gunSettings);
				instance = this;
			}
		}
	}
	public class GunSettings : MonoBehaviour
	{
		public bool isAutomatic;

		public float speedMultiplier = 1f;

		public bool cameraJolt = true;

		public bool requiredWindup;

		public float windupTime = 0f;

		public bool canManuallyReload = true;
	}
	public class MiniGun : WeaponBase
	{
		private static MiniGun instance;

		public static MiniGun Instance => instance;

		public MiniGun()
		{
			if (instance == null)
			{
				string iD = "minigun";
				Shopping shopping = new Shopping
				{
					purchasePrice = 75000f,
					displayName = "MiniGun",
					available = true,
					nonAvailableReason = ""
				};
				Shopping shopping2 = new Shopping
				{
					purchasePrice = 10000f,
					displayName = "MiniGun Magazine",
					available = true,
					nonAvailableReason = ""
				};
				GunSettings gunSettings = new GunSettings
				{
					isAutomatic = true,
					speedMultiplier = 0.75f,
					cameraJolt = false,
					requiredWindup = true,
					windupTime = 2f,
					canManuallyReload = false
				};
				Init(iD, shopping, shopping2, gunSettings);
				instance = this;
			}
		}
	}
	public class WeaponBase
	{
		[CompilerGenerated]
		private sealed class <LoadGun>d__27 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public WeaponBase <>4__this;

			private AssetBundleRequest <rqGunEquippable>5__1;

			private GameObject <_GunEquippable>5__2;

			private AssetBundleRequest <rqGunMagIntItemDef>5__3;

			private IntegerItemDefinition <_GunMagIntItemDef>5__4;

			private AssetBundleRequest <rqGunIntItemDef>5__5;

			private IntegerItemDefinition <_GunIntItemDef>5__6;

			private AssetBundleRequest <rqGunMagTrash>5__7;

			private GameObject <_GunMagTrash>5__8;

			private AssetBundleRequest <rqGunPrefab>5__9;

			private GameObject <_GunHandgun>5__10;

			private AssetBundleRequest <rqGunMagAvatarEquippable>5__11;

			private GameObject <_GunMagAvatarEquippable>5__12;

			private GunSettings <_settings>5__13;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<rqGunEquippable>5__1 = null;
				<_GunEquippable>5__2 = null;
				<rqGunMagIntItemDef>5__3 = null;
				<_GunMagIntItemDef>5__4 = null;
				<rqGunIntItemDef>5__5 = null;
				<_GunIntItemDef>5__6 = null;
				<rqGunMagTrash>5__7 = null;
				<_GunMagTrash>5__8 = null;
				<rqGunPrefab>5__9 = null;
				<_GunHandgun>5__10 = null;
				<rqGunMagAvatarEquippable>5__11 = null;
				<_GunMagAvatarEquippable>5__12 = null;
				<_settings>5__13 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<rqGunEquippable>5__1 = MoreGunsMod.assetBundle.LoadAssetAsync<GameObject>(<>4__this.ID + "_Equippable");
					<>2__current = <rqGunEquippable>5__1;
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					ref GameObject reference4 = ref <_GunEquippable>5__2;
					Object asset4 = <rqGunEquippable>5__1.asset;
					reference4 = (GameObject)(object)((asset4 is GameObject) ? asset4 : null);
					if (!CheckAssetLoaded((Object)(object)<_GunEquippable>5__2, <>4__this.ID + "_Equippable", <>4__this.ID ?? ""))
					{
						return false;
					}
					<rqGunMagIntItemDef>5__3 = MoreGunsMod.assetBundle.LoadAssetAsync<IntegerItemDefinition>(<>4__this.ID + "_Magazine");
					<>2__current = <rqGunMagIntItemDef>5__3;
					<>1__state = 2;
					return true;
				}
				case 2:
				{
					<>1__state = -1;
					ref IntegerItemDefinition reference2 = ref <_GunMagIntItemDef>5__4;
					Object asset2 = <rqGunMagIntItemDef>5__3.asset;
					reference2 = (IntegerItemDefinition)(object)((asset2 is IntegerItemDefinition) ? asset2 : null);
					if (!CheckAssetLoaded((Object)(object)<_GunMagIntItemDef>5__4, <>4__this.ID + "_Magazine", <>4__this.ID ?? ""))
					{
						return false;
					}
					<rqGunIntItemDef>5__5 = MoreGunsMod.assetBundle.LoadAssetAsync<IntegerItemDefinition>(<>4__this.ID ?? "");
					<>2__current = <rqGunIntItemDef>5__5;
					<>1__state = 3;
					return true;
				}
				case 3:
				{
					<>1__state = -1;
					ref IntegerItemDefinition reference3 = ref <_GunIntItemDef>5__6;
					Object asset3 = <rqGunIntItemDef>5__5.asset;
					reference3 = (IntegerItemDefinition)(object)((asset3 is IntegerItemDefinition) ? asset3 : null);
					if (!CheckAssetLoaded((Object)(object)<_GunIntItemDef>5__6, <>4__this.ID ?? "", <>4__this.ID ?? ""))
					{
						return false;
					}
					<rqGunMagTrash>5__7 = MoreGunsMod.assetBundle.LoadAssetAsync<GameObject>("assets/resources/weapons/" + <>4__this.ID + "/magazine/" + <>4__this.ID + "_Magazine_Trash.prefab");
					<>2__current = <rqGunMagTrash>5__7;
					<>1__state = 4;
					return true;
				}
				case 4:
				{
					<>1__state = -1;
					ref GameObject reference5 = ref <_GunMagTrash>5__8;
					Object asset5 = <rqGunMagTrash>5__7.asset;
					reference5 = (GameObject)(object)((asset5 is GameObject) ? asset5 : null);
					if (!CheckAssetLoaded((Object)(object)<_GunMagTrash>5__8, "assets/resources/weapons/" + <>4__this.ID + "/magazine/" + <>4__this.ID + "_Magazine_Trash.prefab", <>4__this.ID ?? ""))
					{
						return false;
					}
					<rqGunPrefab>5__9 = MoreGunsMod.assetBundle.LoadAssetAsync<GameObject>("assets/resources/avatar/equippables/" + <>4__this.ID + ".prefab");
					<>2__current = <rqGunPrefab>5__9;
					<>1__state = 5;
					return true;
				}
				case 5:
				{
					<>1__state = -1;
					ref GameObject reference6 = ref <_GunHandgun>5__10;
					Object asset6 = <rqGunPrefab>5__9.asset;
					reference6 = (GameObject)(object)((asset6 is GameObject) ? asset6 : null);
					if (!CheckAssetLoaded((Object)(object)<_GunHandgun>5__10, "assets/resources/avatar/equippables/" + <>4__this.ID + ".prefab", <>4__this.ID ?? ""))
					{
						return false;
					}
					<rqGunMagAvatarEquippable>5__11 = MoreGunsMod.assetBundle.LoadAssetAsync<GameObject>("assets/resources/weapons/" + <>4__this.ID + "/magazine/" + <>4__this.ID + "_magazine_avatarequippable.prefab");
					<>2__current = <rqGunMagAvatarEquippable>5__11;
					<>1__state = 6;
					return true;
				}
				case 6:
				{
					<>1__state = -1;
					ref GameObject reference = ref <_GunMagAvatarEquippable>5__12;
					Object asset = <rqGunMagAvatarEquippable>5__11.asset;
					reference = (GameObject)(object)((asset is GameObject) ? asset : null);
					if (!CheckAssetLoaded((Object)(object)<_GunMagAvatarEquippable>5__12, "assets/resources/weapons/" + <>4__this.ID + "/magazine/" + <>4__this.ID + "_magazine_avatarequippable.prefab", <>4__this.ID ?? ""))
					{
						return false;
					}
					<_settings>5__13 = <_GunEquippable>5__2.AddComponent<GunSettings>();
					<>4__this.ApplyGunSettings(<_settings>5__13);
					<>4__this.gunEquippable = <_GunEquippable>5__2;
					<>4__this.magIntItemDef = <_GunMagIntItemDef>5__4;
					<>4__this.gunIntItemDef = <_GunIntItemDef>5__6;
					<>4__this.gunMagTrash = <_GunMagTrash>5__8;
					<>4__this.gunHandgun = <_GunHandgun>5__10;
					<>4__this.magAvatarEquippable = <_GunMagAvatarEquippable>5__12;
					<>4__this.gunRangedWeapon = <>4__this.gunEquippable.GetComponent<Equippable_RangedWeapon>();
					<>4__this.gunMagTrashItem = <>4__this.gunMagTrash.GetComponent<TrashItem>();
					<>4__this.CreateConfig();
					<>4__this.SetCustomItemUI();
					<>4__this.LoadAnimations();
					<>4__this.ApplySettingsFromConfig();
					Resource.RegisterAsset("Avatar/Equippables/" + <>4__this.ID.ToUpper(), (Object)(object)<>4__this.gunHandgun);
					Resource.RegisterAsset("Weapons/" + <>4__this.ID + "/Magazine/" + <>4__this.ID.ToUpper() + "_Magazine_AvatarEquippable", (Object)(object)<>4__this.magAvatarEquippable);
					allWeapons.Add(<>4__this);
					weaponsByName.Add(<>4__this.ID ?? "", <>4__this);
					MelonLogger.Msg("Finished Initializing " + <>4__this.ID);
					return false;
				}
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public string ID;

		public GameObject gunEquippable;

		public Equippable_RangedWeapon gunRangedWeapon;

		public GameObject gunHandgun;

		public GameObject magAvatarEquippable;

		public IntegerItemDefinition gunIntItemDef;

		public IntegerItemDefinition magIntItemDef;

		public WeaponOption rangedGun;

		public WeaponOption ammoGun;

		public GameObject gunMagTrash;

		public TrashItem gunMagTrashItem;

		public Dictionary<string, AnimationClip> animations = new Dictionary<string, AnimationClip>();

		public GunConfiguration config;

		public Shopping gunShop;

		public Shopping magShop;

		public GunSettings settings;

		public static List<WeaponBase> allWeapons = new List<WeaponBase>();

		public static Dictionary<string, WeaponBase> weaponsByName = new Dictionary<string, WeaponBase>();

		public bool IsConfigurationFinished { get; private set; }

		public void Init(string ID, Shopping gunShop, Shopping magShop, GunSettings settings)
		{
			this.ID = ID;
			this.gunShop = gunShop;
			this.magShop = magShop;
			this.settings = settings;
			MelonLogger.Msg("Initializing " + ID);
			MelonCoroutines.Start(LoadGun());
		}

		private void SetCustomItemUI()
		{
			Object obj = Resources.Load("Weapons/M1911/M1911");
			ItemDefinition val = (ItemDefinition)(object)((obj is ItemDefinition) ? obj : null);
			if ((Object)(object)val == (Object)null)
			{
				MelonLogger.Error("m1911 couldnt be loaded? Unable to register UI to custom guns!");
				return;
			}
			((ItemDefinition)gunIntItemDef).CustomItemUI = val.CustomItemUI;
			((ItemDefinition)magIntItemDef).CustomItemUI = val.CustomItemUI;
		}

		private void CreateDialogueControllerOptions()
		{
			//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)
			//IL_001d: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			rangedGun = new WeaponOption
			{
				Name = config.ItemName.Value,
				Price = config.PurchasePrice.Value,
				IsAvailable = config.Available.Value,
				NotAvailableReason = config.AvailableReason.Value,
				Item = (StorableItemDefinition)(object)gunIntItemDef
			};
			ammoGun = new WeaponOption
			{
				Name = config.MagItemName.Value,
				Price = config.MagPurchasePrice.Value,
				IsAvailable = config.MagAvailable.Value,
				NotAvailableReason = config.MagAvailableReason.Value,
				Item = (StorableItemDefinition)(object)magIntItemDef
			};
			IsConfigurationFinished = true;
		}

		public void CreateConfig()
		{
			config = new GunConfiguration(this);
			MelonLogger.Msg("Created new config");
		}

		public static bool CheckAssetLoaded(Object asset, string assetName, string weaponName)
		{
			if (asset == (Object)null)
			{
				MelonLogger.Error("Could not load asset: " + assetName);
				MoreGunsMod.StopProcess();
				return false;
			}
			MelonLogger.Msg("Loaded asset for " + weaponName + " : " + assetName);
			return true;
		}

		[IteratorStateMachine(typeof(<LoadGun>d__27))]
		private IEnumerator LoadGun()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LoadGun>d__27(0)
			{
				<>4__this = this
			};
		}

		public void ApplySettingsFromConfig()
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			gunRangedWeapon.Damage = config.Damage.Value;
			gunRangedWeapon.ImpactForce = config.ImpactForce.Value;
			gunRangedWeapon.AimFOVReduction = config.AimFOVReduction.Value;
			gunRangedWeapon.AccuracyChangeDuration = config.AccuracyChangeDuration.Value;
			gunRangedWeapon.MagazineSize = config.MagazineSize.Value;
			((ItemDefinition)gunIntItemDef).Name = config.DisplayItemName.Value;
			((ItemDefinition)gunIntItemDef).Description = config.DisplayDescription.Value;
			((ItemDefinition)gunIntItemDef).LabelDisplayColor = config.LabelDisplayColor.Value;
			((ItemDefinition)gunIntItemDef).legalStatus = config.LegalStatus.Value;
			((StorableItemDefinition)gunIntItemDef).RequiredRank = config.RequiredRank.Value;
			((ItemDefinition)magIntItemDef).Name = config.MagDisplayItemName.Value;
			((ItemDefinition)magIntItemDef).Description = config.MagDisplayDescription.Value;
			((ItemDefinition)magIntItemDef).LabelDisplayColor = config.MagLabelDisplayColor.Value;
			((ItemDefinition)magIntItemDef).legalStatus = config.MagLegalStatus.Value;
			((StorableItemDefinition)magIntItemDef).RequiredRank = config.MagRequiredRank.Value;
			CreateDialogueControllerOptions();
		}

		private void LoadAnimations()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			Equippable_RangedWeapon val = (Equippable_RangedWeapon)((ItemDefinition)gunIntItemDef).Equippable;
			RuntimeAnimatorController animatorController = ((Equippable_AvatarViewmodel)val).AnimatorController;
			AnimationClip[] animationClips = animatorController.animationClips;
			foreach (AnimationClip val2 in animationClips)
			{
				if (((Object)val2).name.Contains("Idle"))
				{
					animations.Add("BothHands_Grip_Lowered", val2);
				}
				if (((Object)val2).name.Contains("Aiming"))
				{
					animations.Add("BothHands_Grip_Raised", val2);
				}
				if (((Object)val2).name.Contains("Fire") && !animations.ContainsKey("BothHands_Grip_Recoil"))
				{
					animations.Add("BothHands_Grip_Recoil", val2);
				}
			}
		}

		private void ApplyGunSettings(GunSettings _settings)
		{
			_settings.isAutomatic = settings.isAutomatic;
			_settings.speedMultiplier = settings.speedMultiplier;
			_settings.cameraJolt = settings.cameraJolt;
			_settings.requiredWindup = settings.requiredWindup;
			_settings.windupTime = settings.windupTime;
			_settings.canManuallyReload = settings.canManuallyReload;
		}
	}
}
namespace MoreGunsMono.Gui
{
	public static class ReloadMessage
	{
		[CompilerGenerated]
		private sealed class <Fade>d__5 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public GameObject o;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(4f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					o.SetActive(false);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <LoadAsset>d__3 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public Transform parent;

			private AssetBundleRequest <rqMessage>5__1;

			private GameObject <_Message>5__2;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<rqMessage>5__1 = MoreGunsMod.assetBundle.LoadAssetAsync<GameObject>("assets/ui/Reload Message.prefab");
					<>2__current = <rqMessage>5__1;
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					ref GameObject reference = ref <_Message>5__2;
					Object asset = <rqMessage>5__1.asset;
					reference = (GameObject)(object)((asset is GameObject) ? asset : null);
					message = Object.Instantiate<GameObject>(<_Message>5__2, parent);
					message.SetActive(false);
					messageText = message.GetComponent<Text>();
					return false;
				}
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static GameObject message;

		public static Text messageText;

		public static void Initialize(Transform parent)
		{
			MelonCoroutines.Start(LoadAsset(parent));
		}

		[IteratorStateMachine(typeof(<LoadAsset>d__3))]
		public static IEnumerator LoadAsset(Transform parent)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LoadAsset>d__3(0)
			{
				parent = parent
			};
		}

		public static void Show(bool show)
		{
			message.SetActive(show);
			MelonCoroutines.Start(Fade(message));
		}

		[IteratorStateMachine(typeof(<Fade>d__5))]
		public static IEnumerator Fade(GameObject o)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Fade>d__5(0)
			{
				o = o
			};
		}

		public static void SetText(string message)
		{
			messageText.text = message;
		}
	}
	public static class Reticle
	{
		[CompilerGenerated]
		private sealed class <FindAndInstantiateCrosshair>d__2 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					bool flag = true;
					if ((Object)(object)Singleton<HUD>.Instance.crosshair == (Object)null)
					{
						MelonLogger.Msg("Searching for crosshair in scene...");
						<>2__current = (object)new WaitForSeconds(0.5f);
						<>1__state = 1;
						return true;
					}
					reticle = Object.Instantiate<GameObject>(((Component)Singleton<HUD>.Instance.crosshair).gameObject, ((Component)Singleton<HUD>.Instance.crosshair).transform.parent);
					reticle.SetActive(false);
					break;
				}
				case 1:
					<>1__state = -1;
					break;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static GameObject reticle;

		public static void Initialize()
		{
			MelonCoroutines.Start(FindAndInstantiateCrosshair());
		}

		[IteratorStateMachine(typeof(<FindAndInstantiateCrosshair>d__2))]
		public static IEnumerator FindAndInstantiateCrosshair()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FindAndInstantiateCrosshair>d__2(0);
		}
	}
	public static class WindupIndicator
	{
		[CompilerGenerated]
		private sealed class <LoadAsset>d__5 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public Transform parent;

			private AssetBundleRequest <rqWindupIndicator>5__1;

			private GameObject <_windupIndicator>5__2;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<rqWindupIndicator>5__1 = MoreGunsMod.assetBundle.LoadAssetAsync<GameObject>("assets/ui/Windup Indicator.prefab");
					<>2__current = <rqWindupIndicator>5__1;
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					ref GameObject reference = ref <_windupIndicator>5__2;
					Object asset = <rqWindupIndicator>5__1.asset;
					reference = (GameObject)(object)((asset is GameObject) ? asset : null);
					windupIndicator = Object.Instantiate<GameObject>(<_windupIndicator>5__2, parent);
					windupIndicator.SetActive(false);
					windupIndicatorSlider = windupIndicator.GetComponent<Slider>();
					backgroundImage = ((Component)windupIndicator.transform.GetChild(0)).GetComponent<Image>();
					fillImage = ((Component)windupIndicator.transform.GetChild(1).GetChild(0)).GetComponent<Image>();
					return false;
				}
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static GameObject windupIndicator;

		public static Slider windupIndicatorSlider;

		public static Image backgroundImage;

		public static Image fillImage;

		public static void Initialize(Transform parent)
		{
			MelonCoroutines.Start(LoadAsset(parent));
		}

		[IteratorStateMachine(typeof(<LoadAsset>d__5))]
		public static IEnumerator LoadAsset(Transform parent)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LoadAsset>d__5(0)
			{
				parent = parent
			};
		}

		public static void Show(bool shown)
		{
			windupIndicator.SetActive(shown);
		}

		public static void SetValueByTime(float from, float to)
		{
			if (from >= to)
			{
				SetValue(100);
				return;
			}
			int value = (int)(from * 100f / to);
			SetValue(value);
		}

		public static void SetValue(int value)
		{
			windupIndicatorSlider.value = value;
			if (value == 100)
			{
				Show(shown: false);
			}
			else
			{
				Show(shown: true);
			}
		}
	}
}
namespace MoreGunsMono.Dialogue
{
	public static class StanDialogue
	{
		public const string allWeaponCategoryOptions = "925ea1d9-9b7e-47a0-b016-6a3b787290c3";

		public static List<ItemInstance> allGuns = new List<ItemInstance>();

		public static Dictionary<string, ItemInstance> allMags = new Dictionary<string, ItemInstance>();

		public static void StartSpecialGunReloads()
		{
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				allGuns.Clear();
				allMags.Clear();
				foreach (HotbarSlot hotbarSlot in PlayerSingleton<PlayerInventory>.Instance.hotbarSlots)
				{
					object obj;
					if (hotbarSlot == null)
					{
						obj = null;
					}
					else
					{
						ItemInstance itemInstance = ((ItemSlot)hotbarSlot).ItemInstance;
						obj = ((itemInstance != null) ? itemInstance.Definition : null);
					}
					if (!((Object)obj == (Object)null))
					{
						string iD = ((ItemSlot)hotbarSlot).ItemInstance.Definition.ID;
						if (WeaponBase.weaponsByName.ContainsKey(iD))
						{
							allGuns.Add(((ItemSlot)hotbarSlot).ItemInstance);
						}
						if (iD.EndsWith("mag"))
						{
							allMags.Add(iD, ((ItemSlot)hotbarSlot).ItemInstance);
						}
					}
				}
				foreach (ItemInstance allGun in allGuns)
				{
					if (allMags.TryGetValue(allGun.Definition.ID + "mag", out var value))
					{
						Equippable_RangedWeapon val = (Equippable_RangedWeapon)allGun.Definition.Equippable;
						IntegerItemInstance val2 = (IntegerItemInstance)allGun;
						IntegerItemInstance val3 = (IntegerItemInstance)value;
						int magazineSize = val.MagazineSize;
						int num = magazineSize - val2.Value;
						int num2 = val3.Value - num;
						if (num2 <= 0)
						{
							int value2 = val2.Value + val3.Value;
							val2.SetValue(value2);
							val3.SetValue(0);
							value.ChangeQuantity(-1);
							Vector3 val4 = ((Component)PlayerSingleton<PlayerCamera>.Instance).transform.position - ((Component)PlayerSingleton<PlayerCamera>.Instance).transform.up * 0.4f;
							NetworkSingleton<TrashManager>.Instance.CreateTrashItem(val.ReloadTrash.ID, val4, Random.rotation, default(Vector3), "", false);
						}
						else
						{
							val2.SetValue(magazineSize);
							val3.SetValue(num2);
						}
					}
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Error("Exception in StartSpecialGunReloads: " + ex.Message);
				MelonLogger.Error("Stack trace: " + ex.StackTrace);
			}
		}
	}
}