Decompiled source of CWMissing v2.1.1

off_grid.CWMissing.dll

Decompiled a week 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.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DefaultNamespace;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.PropertyVariants;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
using UnityEngine.UI;
using UnityEngine.UI.ProceduralImage;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("off_grid.CWMissing")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.1.0.0")]
[assembly: AssemblyInformationalVersion("2.1.0")]
[assembly: AssemblyProduct("CWMissing")]
[assembly: AssemblyTitle("off_grid.CWMissing")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class LocalizationKeys
{
	public enum Keys
	{
		HelmetWelcome,
		HelmetFailed,
		Sleep,
		Day,
		Views,
		Quota,
		Money,
		Empty,
		Save,
		DivingBellNotReadyMissingPlayersState,
		DivingBellNotReadyDoorOpenState,
		DivingBellReady,
		DivingBellReadySurface,
		DivingBellRechargingState,
		JoinRandom,
		EnterDiveBellDay2Objective,
		EnterDiveBellObjective,
		BuyEquipmentObjective,
		ExtractVideoObjective,
		FilmSomethingScaryObjective,
		GoToBedFailedObjective,
		GoToBedSuccessObjective,
		InviteFriendsObjective,
		LeaveHouseObjective,
		PickupDiscObjective,
		PickupTheCameraObjective,
		ReturnToTheDiveBellObjective,
		UploadVideoObjective,
		WakeUpObjective,
		CelebrateObjective,
		DaysLeft,
		LastDay,
		Buy,
		Left,
		Right,
		NotSleepy,
		StartGame,
		Submerge,
		ReturnToSurface,
		TerminalBusy,
		Help,
		InviteFriends,
		Open,
		Close,
		GameFull,
		GameStarted,
		Offline,
		StartGameTitle,
		StartGameBody,
		StartGameConfirm,
		Cancel,
		PickUp,
		SwitchCategory,
		AddToCart,
		SoldOut,
		Clear,
		Order,
		DeleteSave,
		DeleteSaveConfirm,
		Yes,
		No,
		Interact,
		HelmetDaysLeft,
		HelmetLastDay,
		HelmetForgetCamera,
		Oxygen,
		Distance,
		Items,
		CloseVideo,
		ReplayVideo,
		SaveVideo,
		UploadToSpookTube,
		ShopClosed,
		Lights,
		Medical,
		Gadgets,
		Emotes,
		Emotes2,
		Upgrades,
		Misc,
		SpookTubeViews,
		AdRevenue,
		HospitalBill,
		CalibrationUseVoice,
		CalibrationUseHeadphones,
		CalibrationSelectMic,
		CalibrationSelectVoice,
		CalibrationBrightness,
		CalibrationMonster,
		Brightness,
		Continue,
		OldVersion,
		PleaseUpdate,
		CloseGame,
		CrouchKeybindSetting,
		DropKeybindSetting,
		EmoteKeybindSetting,
		InteractKeybindSetting,
		JumpKeybindSetting,
		ToggleSelfieModeKeybindSetting,
		WalkBackwardKeybindSetting,
		WalkForwardKeybindSetting,
		WalkLeftKeybindSetting,
		WalkRightKeybindSetting,
		AmbientOcclusionSetting,
		BrightnessSetting,
		ChromaticAberrationSetting,
		FullscreenSetting,
		VoiceVolumeSetting,
		VoiceSetting,
		VoiceChatModeSetting,
		VSyncSetting,
		ShadowQualitySetting,
		ScreenResolutionSetting,
		SFXVolumeSetting,
		MouseSensitivitySetting,
		MaxFramerateSetting,
		MasterVolumeSetting,
		SprintKeybindSetting,
		JoinError,
		JoinErrorMismatch,
		Ok,
		VideoSaved,
		VideoSavedAs,
		VideoFailedSave,
		ServerIssues,
		DropItem,
		Battery,
		FilmLeft,
		ToggleLight,
		ZoomKey,
		SelfieMode,
		Aim,
		HostingGame,
		Connecting,
		BoomMic,
		Camera,
		CameraBroken,
		Clapper,
		Defibrilator,
		Disc,
		Flare,
		GooBall,
		Hugger,
		LongFlashlightPro,
		LongFlashlight,
		ModernFlashlightPro,
		ModernFlashlight,
		OldFlashlight,
		PartyPopper,
		ShockStick,
		SoundPlayer,
		WalkieTalkie,
		WideFlashlight2,
		WideFlashlight3,
		Winch,
		Aminalstateu,
		Animalstatue,
		Bone,
		Brainonastick,
		Chorby,
		Container,
		OldPainting,
		Radio,
		Ribcage,
		Skull,
		Spine,
		ReporterMic,
		RescueHook,
		Emote_Applause,
		Emote_Dance1,
		Emote_Dance2,
		Emote_Dance3,
		Emote_FingerScratch,
		Emote_HalfBackflip,
		Emote_Handstand,
		Emote_HuggerHeal,
		Emote_JumpJack,
		Emote_MiddleFings,
		Emote_Peace,
		Emote_PushUp,
		Emote_Shrug,
		Emote_Stretch,
		Emote_Thumbnail1,
		Emote_Thumbnail2,
		Emote_ThumbsUp,
		BoomMic_ToolTips,
		Camera_ToolTips,
		Clapper_ToolTips,
		Defibrilator_ToolTips,
		Disc_ToolTips,
		FakeOldFlashlight,
		FakeOldFlashlight_ToolTips,
		Flare_ToolTips,
		GooBall_ToolTips,
		GrabberArm,
		GrabberArm_ToolTips,
		Hugger_ToolTips,
		LongFlashlightPro_ToolTips,
		LongFlashlight_ToolTips,
		LostDisc,
		LostDisc_ToolTips,
		ModernFlashlightPro_ToolTips,
		ModernFlashlight_ToolTips,
		OldFlashlight_ToolTips,
		PartyPopper_ToolTips,
		ReporterMic_ToolTips,
		ShockStick_ToolTips,
		SoundPlayer_ToolTips,
		WalkieTalkie_ToolTips,
		WideFlashlight2_ToolTips,
		WideFlashlight3_ToolTips,
		Radio_ToolTips,
		Emote_Applause_ToolTips,
		Emote_Dance1_ToolTips,
		Emote_Dance2_ToolTips,
		Emote_Dance3_ToolTips,
		Emote_FingerScratch_ToolTips,
		Emote_HalfBackflip_ToolTips,
		Emote_Handstand_ToolTips,
		Emote_HuggerHeal_ToolTips,
		Emote_JumpJack_ToolTips,
		Emote_MiddleFings_ToolTips,
		Emote_Peace_ToolTips,
		Emote_PushUp_ToolTips,
		Emote_Shrug_ToolTips,
		Emote_Stretch_ToolTips,
		Emote_Thumbnail1_ToolTips,
		Emote_Thumbnail2_ToolTips,
		Emote_ThumbsUp_ToolTips,
		ThrowItemToolTip,
		Endscreen1_1,
		Endscreen1_2,
		Endscreen1_3,
		Endscreen1_4,
		Endscreen1_5,
		Endscreen2_1,
		Endscreen2_2,
		Endscreen2_3,
		Endscreen2_4,
		Endscreen2_5,
		Endscreen3_1,
		Endscreen3_2,
		Endscreen3_3,
		Endscreen3_4,
		Endscreen3_5,
		Endscreen3_6,
		EndscreenDream,
		Bomb,
		Apple,
		Sit,
		Error_Steam_Title,
		Error_Steam_Body,
		Error_Auth_Failed,
		Error_File_Not_Found,
		Error_Save,
		Error_RecordingsFolder,
		Error_NoSave,
		Error_HostLeft,
		Error_Disconnected,
		Error_Join,
		Error_Delete_TempFolder,
		Error_CreateRoom,
		Error_VideoPath,
		AddedToCart,
		PushToTalk,
		VoiceDetection,
		FullScreenMode,
		WindowedMode,
		HighSetting,
		LowSetting,
		OnSetting,
		OffSetting,
		PressAnyKeySetting,
		Emote_Applause_Text,
		Emote_Dance1_Text,
		Emote_Dance2_Text,
		Emote_Dance3_Text,
		Emote_FingerScratch_Text,
		Emote_HalfBackflip_Text,
		Emote_Handstand_Text,
		Emote_HuggerHeal_Text,
		Emote_JumpJack_Text,
		Emote_MiddleFings_Text,
		Emote_Peace_Text,
		Emote_PushUp_Text,
		Emote_Shrug_Text,
		Emote_Stretch_Text,
		Emote_Thumbnail1_Text,
		Emote_Thumbnail2_Text,
		Emote_ThumbsUp_Text,
		Unlock,
		BalaclavaHat,
		BeanieHat,
		BucketHatHat,
		CatEarsHat,
		ChefHat,
		FloppyHat,
		HomburgHat,
		Hair1Hat,
		Hat_BowlerHat,
		Hat_CapHat,
		Hat_ChildHat,
		Hat_ClownHat,
		Hat_CowboyHat,
		Hat_CrownHat,
		Hat_HaloHat,
		Hat_HornsHat,
		Hat_HotdogHat,
		Hat_JesterHat,
		Hat_KnifoHat,
		Hat_MilkHat,
		Hat_NewsHat,
		Hat_PirateHat,
		Hat_RugbyHat,
		Hat_SavannahHat,
		Hat_TooopHat,
		Hat_TopHat,
		PartyHat,
		ShroomHat,
		UshankaHat,
		WitchHat,
		NetworkBingoBongo_0_EmailTitle,
		NetworkBingoBongo_0_DealName,
		NetworkBingoBongo_0_Description,
		NetworkBingoBongo_0_SuccessEmailBody,
		NetworkBingoBongo_0_FailedEmailBody,
		NetworkHoldTheBombo_9_EmailTitle,
		NetworkHoldTheBombo_9_DealName,
		NetworkHoldTheBombo_9_Description,
		NetworkHoldTheBombo_9_SuccessEmailBody,
		NetworkHoldTheBombo_9_FailedEmailBody,
		NetworkInterviewer_2_EmailTitle,
		NetworkInterviewer_2_DealName,
		NetworkInterviewer_2_Description,
		NetworkInterviewer_2_SuccessEmailBody,
		NetworkInterviewer_2_FailedEmailBody,
		NetworkJackass_4_EmailTitle,
		NetworkJackass_4_DealName,
		NetworkJackass_4_Description,
		NetworkJackass_4_SuccessEmailBody,
		NetworkJackass_4_FailedEmailBody,
		NetworkMultiMonsterInFrameAtOnce_5_EmailTitle,
		NetworkMultiMonsterInFrameAtOnce_5_DealName,
		NetworkMultiMonsterInFrameAtOnce_5_Description,
		NetworkMultiMonsterInFrameAtOnce_5_SuccessEmailBody,
		NetworkMultiMonsterInFrameAtOnce_5_FailedEmailBody,
		NetworkTaunting_3_EmailTitle,
		NetworkTaunting_3_DealName,
		NetworkTaunting_3_Description,
		NetworkTaunting_3_SuccessEmailBody,
		NetworkTaunting_3_FailedEmailBody,
		NetworkWalletMoney_1_EmailTitle,
		NetworkWalletMoney_1_DealName,
		NetworkWalletMoney_1_Description,
		NetworkWalletMoney_1_SuccessEmailBody,
		NetworkWalletMoney_1_FailedEmailBody,
		NoHat,
		HatShop_AlreadyOwn,
		HatShop_Buy,
		HatShop_CantAfford
	}

	private static Dictionary<Keys, string> m_StringDictionary;

	private static Dictionary<Locale, Dictionary<Keys, string>> m_LanguageStrings;

	private static bool m_MadeLocaleStrings;

	public static void Initialize()
	{
		Debug.LogWarning((object)"< [OLD ContentWarning]: Initialized LocalizationKeys >");
	}

	public static string GetLocalizedString(Keys key)
	{
		if (!m_MadeLocaleStrings)
		{
			MakeLocaleStrings();
		}
		if (m_StringDictionary == null || !m_StringDictionary.ContainsKey(key))
		{
			Debug.LogError((object)("[OLD CW] Cant find locale key for: " + key));
			return "LOCALIZATION ERROR";
		}
		return m_StringDictionary[key];
	}

	private static string GetLocalizedInternal(Locale locale, Keys key)
	{
		//IL_0012: 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)
		string text = LocalizationSettings.StringDatabase.GetLocalizedString(TableEntryReference.op_Implicit(key.ToString()), locale, (FallbackBehavior)0, Array.Empty<object>());
		if (string.IsNullOrEmpty(text))
		{
			text = LocalizationSettings.StringDatabase.GetLocalizedString(TableEntryReference.op_Implicit(key.ToString()), LocalizationSettings.ProjectLocale, (FallbackBehavior)0, Array.Empty<object>());
			if (string.IsNullOrEmpty(text))
			{
				Debug.LogError((object)("[OLD CW] Cant find locale internal for: " + key));
				text = "LOCALIZATION ERROR";
			}
		}
		return text;
	}

	public static void MakeLocaleStrings()
	{
		if (m_MadeLocaleStrings)
		{
			return;
		}
		m_LanguageStrings = new Dictionary<Locale, Dictionary<Keys, string>>();
		Keys[] array = (Keys[])Enum.GetValues(typeof(Keys));
		int num = array.Length;
		foreach (Locale locale in LocalizationSettings.AvailableLocales.Locales)
		{
			Dictionary<Keys, string> dictionary = new Dictionary<Keys, string>();
			for (int i = 0; i < num; i++)
			{
				Keys key = array[i];
				string localizedInternal = GetLocalizedInternal(locale, key);
				dictionary.Add(key, localizedInternal);
			}
			m_LanguageStrings.Add(locale, dictionary);
		}
		m_MadeLocaleStrings = true;
		OnLanguageSwitch();
	}

	public static void OnLanguageSwitch()
	{
		if (m_MadeLocaleStrings)
		{
			m_StringDictionary = m_LanguageStrings[LocalizationSettings.SelectedLocale];
		}
	}
}
namespace CWMissing
{
	[ContentWarningPlugin("off_grid.CWMissing", "CWMissing", false)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("off_grid.CWMissing", "CWMissing", "2.1.0")]
	public class CWMissing : BaseUnityPlugin, IOnEventCallback, IInRoomCallbacks
	{
		[HarmonyPatch(typeof(RoundSpawner), "Start")]
		public class RoundSpawnerPatch
		{
			private static void Postfix(RoundSpawner __instance)
			{
				Instance.AddMonstersToRoundSpawner(__instance);
			}
		}

		[HarmonyPatch(typeof(ShopHandler))]
		[HarmonyPatch("InitShop")]
		public static class ShopHandler_InitShop_Patch
		{
			private static void Postfix()
			{
				Instance.shopInitialized = true;
			}
		}

		internal static Harmony Harmony = new Harmony("off_grid.CWMissing");

		internal static List<ShopItemCategory> registerCategories = new List<ShopItemCategory>();

		internal static Dictionary<LocalizationKeys.Keys, string> registerLocales = new Dictionary<LocalizationKeys.Keys, string>();

		private bool configSynced;

		private bool shopInitialized;

		private bool LobbyStatus;

		private string? ConfigVersion;

		public ConfigFile config;

		private readonly List<string> NameList = new List<string>
		{
			"Radio", "PersistantRadio", "WalkieTalkie", "Wide Flashlight 2", "Wide Flashlight 3", "GrabberArm", "Emote_Choked", "Emote_Choke", "Emote_Dance4TokTok", "Bomb",
			"FakeOldFlashlight", "NorfGun"
		};

		private readonly List<string> MonsterNameList = new List<string> { "Angler", "Wallo", "MimicMan", "Ghost" };

		public static CWMissing Instance { get; private set; } = null;


		internal static ManualLogSource Logger { get; private set; } = null;


		public static List<Item> AllItems => ((DatabaseAsset<ItemDatabase, Item>)(object)SingletonAsset<ItemDatabase>.Instance).Objects.ToList();

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Logger.LogWarning((object)"< CWMissing uses a modified version of ShopTweaks by ViViKo >");
			LocalizationKeys.Initialize();
			InitializeConfig();
			Harmony.PatchAll();
			AddShopItems();
			Logger.LogWarning((object)"<< Added items to store for you!");
			((MonoBehaviour)this).StartCoroutine(WaitForConfigSync());
			Logger.LogWarning((object)"<< Began awaiting for config sync!");
			Logger.LogInfo((object)"off_grid.CWMissing v2.1.0 has fully loaded!");
		}

		private void InitializeConfig()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			string text = Path.Combine(Paths.ConfigPath, "DAa Mods/CWMissing");
			if (!Directory.Exists(text))
			{
				Directory.CreateDirectory(text);
			}
			string text2 = Path.Combine(text, "config.cfg");
			config = new ConfigFile(text2, true);
			ConfigVersion = config.Bind<string>("Version", "Current Version", "", (ConfigDescription)null).Value;
			if (ConfigVersion != "2.1.0")
			{
				config.Clear();
				DefineConfig();
			}
		}

		public static ShopItemCategory RegisterCategory(string name)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			ShopItemCategory val = EnumUtils.Create<ShopItemCategory>(name);
			registerCategories.Add(val);
			LocalizationKeys.Keys key = EnumUtils.Create<LocalizationKeys.Keys>(name);
			registerLocales.Add(key, name);
			return val;
		}

		private void DefineConfig()
		{
			config.Bind<string>("Version", "Current Version", "2.1.0", "Autoupdates the config / lets the mod know what version of config it is.");
			DefineItemConfig("Radio", 100, purchasable: true, spawnable: true, "epic", "Phonk Radio", "Misc");
			DefineItemConfig("PersistantRadio", 100, purchasable: true, spawnable: true, "epic", "Money Radio", "Misc");
			DefineItemConfig("WalkieTalkie", 25, purchasable: true, spawnable: true, "epic", "Walkie Talkie", "Gadgets");
			DefineItemConfig("Wide Flashlight 2", 600, purchasable: true, spawnable: true, "epic", "Wide Flashlight", "Lights");
			DefineItemConfig("Wide Flashlight 3", 800, purchasable: true, spawnable: true, "legendary", "Wide Flashlight Pro", "Lights");
			DefineItemConfig("GrabberArm", 150, purchasable: true, spawnable: true, "epic", "Grabber", "Gadgets");
			DefineItemConfig("Emote_Choked", 200, purchasable: true, spawnable: false, "epic", "Choked", "Emotes");
			DefineItemConfig("Emote_Choke", 200, purchasable: true, spawnable: false, "epic", "Choke", "Emotes");
			DefineItemConfig("Emote_Dance4TokTok", 200, purchasable: true, spawnable: false, "epic", "Dance 104", "Emotes");
			DefineItemConfig("Bomb", 5, purchasable: true, spawnable: false, "epic", "Firework", "Misc");
			DefineItemConfig("FakeOldFlashlight", 20, purchasable: true, spawnable: false, "epic", "RealOldFlashlight", "Lights");
			DefineItemConfig("NorfGun", 60, purchasable: true, spawnable: true, "legendary", "Nerf Blaster 3000", "Gadgets");
			DefineMonsterConfig("MimicMan", 0.1f, 4, 300, 1, 0, UseSlots: false, isEnabled: true);
			DefineMonsterConfig("Angler", 0.1f, 4, 300, 1, 0, UseSlots: false, isEnabled: true);
			DefineMonsterConfig("Wallo", 0.1f, 4, 300, 1, 0, UseSlots: false, isEnabled: true);
			DefineMonsterConfig("Toolkit_Fan", 0.1f, 4, 300, 1, 0, UseSlots: false, isEnabled: false);
			DefineMonsterConfig("Toolkit_Hammer", 0.1f, 4, 300, 1, 0, UseSlots: false, isEnabled: false);
			DefineMonsterConfig("Toolkit_Iron", 0.1f, 4, 300, 1, 0, UseSlots: false, isEnabled: false);
			DefineMonsterConfig("Toolkit_Vaccuum", 0.1f, 4, 300, 1, 0, UseSlots: false, isEnabled: false);
			DefineMonsterConfig("GoodCatch", 0.1f, 4, 300, 1, 0, UseSlots: false, isEnabled: false);
			DefineMonsterConfig("Ghost", 0.1f, 0, 300, 1, 0, UseSlots: false, isEnabled: true);
		}

		private void DefineItemConfig(string itemName, int price, bool purchasable, bool spawnable, string rarity, string DisplayName, string Category)
		{
			config.Bind<int>(itemName, "Price", price, "Price of the " + itemName + ".");
			config.Bind<bool>(itemName, "Purchasable", purchasable, "Is " + itemName + " purchasable?");
			config.Bind<bool>(itemName, "Spawnable", spawnable, "Is " + itemName + " spawnable?");
			config.Bind<string>(itemName, "Rarity", rarity, "Spawn rarity of the " + itemName + ". Options: always, superCommon, moreCommon, common, lessCommon, uncommon, rare, epic, legendary, mythic");
			config.Bind<string>(itemName, "DisplayName", DisplayName, "Display name for " + itemName + ".");
			config.Bind<string>(itemName, "Category", Category, "Category " + itemName + " will be listed under. Options: Lights, Medical, Gadgets, Emotes, Misc, CWMissing");
		}

		private void DefineMonsterConfig(string monsterName, float spawnWeight, int minDays, int minTime, int maxMonsters, int nsSlots, bool UseSlots, bool isEnabled)
		{
			config.Bind<float>(monsterName, "SpawnWeight", spawnWeight, "Spawn weight for the " + monsterName + ". (0.1 = 10%, 1 = 100%, Will not be accurate if it is in current round*)");
			config.Bind<int>(monsterName, "MinimumDays", minDays, "Minimum days before " + monsterName + " is allowed to spawn.");
			config.Bind<int>(monsterName, "MinimumTime", minTime, "Minimum time before " + monsterName + " is allowed to spawn.");
			config.Bind<int>(monsterName, "MaximumOfEntity", maxMonsters, "Maximum amount of " + monsterName + " that can spawn.");
			config.Bind<int>(monsterName, "Slots", nsSlots, "Amount of slots " + monsterName + " will take up.");
			config.Bind<bool>(monsterName, "UseSlots", UseSlots, "Should slots be used instead of actual monster cost?");
			config.Bind<bool>(monsterName, "Enabled", isEnabled, "Is spawning for " + monsterName + " allowed.");
		}

		private void AddMonstersToRoundSpawner(RoundSpawner spawner)
		{
			if (!PhotonNetwork.IsMasterClient)
			{
				return;
			}
			List<IBudgetCost> list = new List<IBudgetCost>();
			int num = 0;
			foreach (string monsterName in MonsterNameList)
			{
				float value = config.Bind<float>(monsterName, "SpawnWeight", 0.5f, (ConfigDescription)null).Value;
				int value2 = config.Bind<int>(monsterName, "Slots", 10, (ConfigDescription)null).Value;
				bool value3 = config.Bind<bool>(monsterName, "Enabled", false, (ConfigDescription)null).Value;
				if (Random.value <= value && value3)
				{
					IBudgetCost val = LoadMonster(monsterName);
					if (val != null)
					{
						list.Add(val);
						num += val.Cost;
						Logger.LogWarning((object)("< Added: " + monsterName + " to possible spawns! >"));
					}
				}
			}
			spawner.testBudget += num;
			spawner.possibleSpawns = spawner.possibleSpawns.Concat(list.Select((IBudgetCost m) => m.gameObject)).ToArray();
		}

		private IBudgetCost LoadMonster(string monsterName)
		{
			GameObject val = Resources.Load<GameObject>(monsterName ?? "");
			if ((Object)(object)val != (Object)null)
			{
				return val.GetComponent<IBudgetCost>();
			}
			return null;
		}

		private void AddShopItems()
		{
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			foreach (Item allItem in AllItems)
			{
				if (NameList.Contains(((Object)allItem).name))
				{
					int value = config.Bind<int>(((Object)allItem).name, "Price", 100, (ConfigDescription)null).Value;
					bool value2 = config.Bind<bool>(((Object)allItem).name, "Purchasable", false, (ConfigDescription)null).Value;
					bool value3 = config.Bind<bool>(((Object)allItem).name, "Spawnable", false, (ConfigDescription)null).Value;
					string value4 = config.Bind<string>(((Object)allItem).name, "Rarity", "epic", (ConfigDescription)null).Value;
					string value5 = config.Bind<string>(((Object)allItem).name, "Category", "Misc", (ConfigDescription)null).Value;
					string value6 = config.Bind<string>(((Object)allItem).name, "DisplayName", "Null", (ConfigDescription)null).Value;
					allItem.price = value;
					allItem.purchasable = value2;
					allItem.spawnable = value3;
					allItem.toolSpawnRarity = ParseRarity(value4);
					allItem.Category = ParseCategory(value5);
					allItem.displayName = value6;
				}
			}
			ShopHandler.Instance.InitShopHandler();
			Logger.LogWarning((object)"<< Finished with store!");
		}

		public void OnEvent(EventData photonEvent)
		{
			if (photonEvent.Code == 1 && photonEvent.CustomData is object[] array && array.Length != 0 && array[0] is string configData)
			{
				ApplyHostConfig(configData);
			}
		}

		private void ApplyHostConfig(string configData)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			string text = Path.Combine(Paths.ConfigPath, "DAa Mods/CWMissing");
			if (!Directory.Exists(text))
			{
				Directory.CreateDirectory(text);
			}
			string text2 = Path.Combine(text, "HostConfig.cfg");
			File.WriteAllText(text2, FormatConfig(configData));
			config = new ConfigFile(text2, true);
			configSynced = true;
		}

		private string FormatConfig(string brokenConfig)
		{
			string[] array = brokenConfig.Split(new string[3] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
			StringBuilder stringBuilder = new StringBuilder();
			string text = "";
			string[] array2 = array;
			foreach (string text2 in array2)
			{
				string[] array3 = text2.Split(':');
				if (array3.Length > 1)
				{
					if (text != array3[0])
					{
						text = array3[0];
						stringBuilder.AppendLine("[" + text + "]");
					}
					string[] array4 = array3[1].Split('=');
					stringBuilder.AppendLine(array4[0].Trim() + " = " + array4[1].Trim());
				}
				else
				{
					stringBuilder.AppendLine(text2);
				}
			}
			return stringBuilder.ToString();
		}

		private void SendConfigToPlayer(Player player)
		{
			//IL_0018: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			string text = SerializeConfig(config);
			object[] array = new object[1] { text };
			RaiseEventOptions val = new RaiseEventOptions
			{
				Receivers = (ReceiverGroup)0
			};
			PhotonNetwork.RaiseEvent((byte)1, (object)array, val, SendOptions.SendReliable);
		}

		private string SerializeConfig(ConfigFile config)
		{
			using StringWriter stringWriter = new StringWriter();
			foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in config)
			{
				stringWriter.WriteLine($"{item.Key.Section}:{item.Key.Key}={item.Value.BoxedValue}");
			}
			return stringWriter.ToString();
		}

		private ShopItemCategory ParseCategory(string Category)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			return (ShopItemCategory)(Category switch
			{
				"Lights" => 1, 
				"Gadgets" => 3, 
				"Misc" => 7, 
				"Medical" => 2, 
				"Emotes" => 4, 
				_ => 0, 
			});
		}

		private RARITY ParseRarity(string rarity)
		{
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			return (RARITY)(rarity switch
			{
				"always" => 10, 
				"superCommon" => 50, 
				"moreCommon" => 75, 
				"common" => 100, 
				"lessCommon" => 150, 
				"uncommon" => 1000, 
				"rare" => 10000, 
				"epic" => 100000, 
				"legendary" => 1000000, 
				"mythic" => 10000000, 
				_ => 100000, 
			});
		}

		private IEnumerator WaitForConfigSync()
		{
			while (!configSynced && !shopInitialized)
			{
				yield return null;
			}
			AddShopItems();
			Logger.LogWarning((object)"<< Added items to store for you!");
		}

		public void OnPlayerEnteredRoom(Player newPlayer)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				SendConfigToPlayer(newPlayer);
				Logger.LogWarning((object)("<< Sent config to: " + newPlayer.NickName));
			}
		}

		public void OnPlayerLeftRoom(Player otherPlayer)
		{
		}

		public void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged)
		{
		}

		public void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps)
		{
		}

		public void OnMasterClientSwitched(Player newMasterClient)
		{
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "off_grid.CWMissing";

		public const string PLUGIN_NAME = "CWMissing";

		public const string PLUGIN_VERSION = "2.1.0";
	}
}
namespace CWMissing.Patches
{
	[HarmonyPatch(typeof(ShopViewScreen))]
	public class ShopViewScreenPatch
	{
		public static int pageIndex = 0;

		public static int itemsPerPage = 8;

		public static int maxPageIndex = 0;

		public static GameObject leftArrowBtn;

		public static GameObject rightArrowBtn;

		public static GameObject pageNumber;

		public static bool shopClosed = false;

		private static FieldInfo m_CurrentCategoryNameTextField;

		private static FieldInfo m_ItemsGridField;

		private static FieldInfo m_CategoriesGridField;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePatch(ShopViewScreen __instance)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Invalid comparison between Unknown and I4
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: 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_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Expected O, but got Unknown
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			CWMissing.Logger.LogWarning((object)"< Patching ShopViewScreen >");
			ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
			foreach (Item @object in ((DatabaseAsset<ItemDatabase, Item>)(object)instance).Objects)
			{
				if ((int)@object.Category == 5)
				{
					@object.Category = (ShopItemCategory)4;
				}
			}
			if (m_CurrentCategoryNameTextField == null)
			{
				m_CurrentCategoryNameTextField = typeof(ShopViewScreen).GetField("m_CurrentCategoryNameText", BindingFlags.Instance | BindingFlags.NonPublic);
			}
			if (m_ItemsGridField == null)
			{
				m_ItemsGridField = typeof(ShopViewScreen).GetField("m_ItemsGrid", BindingFlags.Instance | BindingFlags.NonPublic);
			}
			if (m_CategoriesGridField == null)
			{
				m_CategoriesGridField = typeof(ShopViewScreen).GetField("m_CategoriesGrid", BindingFlags.Instance | BindingFlags.NonPublic);
			}
			TextMeshProUGUI val = (TextMeshProUGUI)m_CurrentCategoryNameTextField.GetValue(__instance);
			Transform val2 = (Transform)m_ItemsGridField.GetValue(__instance);
			Transform val3 = (Transform)m_CategoriesGridField.GetValue(__instance);
			Vector3 val4 = default(Vector3);
			((Vector3)(ref val4))..ctor(0f, 30f, 0f);
			Transform transform = ((TMP_Text)val).transform;
			transform.localPosition += val4;
			val2.localPosition += val4;
			val3.localPosition += val4;
			GameObject val5 = GameObject.Find("Tools/ShopV2/McScreen/Order/UI_OrderClear");
			GameObject val6 = GameObject.Find("Tools/ShopV2/McScreen/Order/Items");
			TextMeshProUGUI component = val6.GetComponent<TextMeshProUGUI>();
			leftArrowBtn = Object.Instantiate<GameObject>(val5);
			Object.Destroy((Object)(object)leftArrowBtn.GetComponentInChildren<ShopInteractibleClear>());
			Object.Destroy((Object)(object)leftArrowBtn.GetComponentInChildren<ProceduralImage>());
			Object.Destroy((Object)(object)leftArrowBtn.GetComponentInChildren<GameObjectLocalizer>());
			TextMeshProUGUI component2 = ((Component)leftArrowBtn.transform.GetChild(1)).gameObject.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component2).font = ((TMP_Text)component).font;
			((TMP_Text)component2).text = "<-";
			((Graphic)component2).color = Color.black;
			leftArrowBtn.transform.SetParent(val2.parent.parent);
			leftArrowBtn.transform.localPosition = new Vector3(-8f, -206f, 0f);
			leftArrowBtn.transform.localScale = new Vector3(1f, 1f, 1f);
			ShopInteractiblePageBack shopInteractiblePageBack = leftArrowBtn.AddComponent<ShopInteractiblePageBack>();
			rightArrowBtn = Object.Instantiate<GameObject>(val5);
			Object.Destroy((Object)(object)rightArrowBtn.GetComponentInChildren<ShopInteractibleClear>());
			Object.Destroy((Object)(object)rightArrowBtn.GetComponentInChildren<ProceduralImage>());
			Object.Destroy((Object)(object)rightArrowBtn.GetComponentInChildren<GameObjectLocalizer>());
			TextMeshProUGUI component3 = ((Component)rightArrowBtn.transform.GetChild(1)).gameObject.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component3).font = ((TMP_Text)component).font;
			((TMP_Text)component3).text = "->";
			((Graphic)component3).color = Color.black;
			rightArrowBtn.transform.SetParent(val2.parent.parent);
			rightArrowBtn.transform.localPosition = new Vector3(152f, -206f, 0f);
			rightArrowBtn.transform.localScale = new Vector3(1f, 1f, 1f);
			ShopInteractiblePageForward shopInteractiblePageForward = rightArrowBtn.AddComponent<ShopInteractiblePageForward>();
			pageNumber = new GameObject("PageNumber");
			pageNumber.transform.SetParent(val2.parent.parent);
			pageNumber.transform.localPosition = new Vector3(72f, -206f, 0f);
			pageNumber.transform.localScale = new Vector3(1f, 1f, 1f);
			TextMeshProUGUI val7 = pageNumber.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val7).font = ((TMP_Text)component).font;
			((TMP_Text)val7).fontSize = ((TMP_Text)component).fontSize;
			((Behaviour)val7).enabled = true;
			((Graphic)val7).color = ((Graphic)component).color;
			((TMP_Text)val7).alignment = (TextAlignmentOptions)514;
			CWMissing.Logger.LogWarning((object)"< Patched ShopViewScreen >");
		}

		[HarmonyPatch("Init")]
		[HarmonyPrefix]
		private static void InitPatch(ShopViewScreen __instance)
		{
			__instance.excludeCategories.Add((ShopItemCategory)5);
		}

		[HarmonyPatch("DrawItems")]
		[HarmonyPrefix]
		private static void DrawItemsPatch(ShopViewScreen __instance)
		{
			maxPageIndex = (int)Math.Ceiling((double)((__instance.CurrentShopItems.Length - 1) / itemsPerPage));
			int count = pageIndex * itemsPerPage;
			FieldInfo field = typeof(ShopViewScreen).GetField("<CurrentShopItems>k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				field.SetValue(__instance, __instance.CurrentShopItems.Skip(count).Take(itemsPerPage).ToArray());
				TextMeshProUGUI component = pageNumber.GetComponent<TextMeshProUGUI>();
				((TMP_Text)component).text = $"{pageIndex + 1}/{maxPageIndex + 1}";
				bool active = maxPageIndex != 0 && !shopClosed;
				leftArrowBtn.SetActive(active);
				rightArrowBtn.SetActive(active);
				pageNumber.SetActive(active);
				return;
			}
			throw new Exception("Backing field for CurrentShopItems not found.");
		}

		[HarmonyPatch("CloseShop")]
		[HarmonyPrefix]
		private static void CloseShopPatch(ShopViewScreen __instance)
		{
			try
			{
				leftArrowBtn.SetActive(false);
				rightArrowBtn.SetActive(false);
				pageNumber.SetActive(false);
			}
			catch (Exception)
			{
			}
			pageIndex = 0;
			maxPageIndex = 0;
			shopClosed = true;
		}

		[HarmonyPatch("OpenShop")]
		[HarmonyPrefix]
		private static void OpenShopPatch()
		{
			try
			{
				leftArrowBtn.SetActive(true);
				rightArrowBtn.SetActive(true);
				pageNumber.SetActive(true);
			}
			catch (Exception)
			{
			}
			pageIndex = 0;
			maxPageIndex = 0;
			shopClosed = false;
		}

		[HarmonyPatch("ChangeCategory")]
		[HarmonyPrefix]
		private static void ChangeCategoryPatch()
		{
			pageIndex = 0;
		}

		[HarmonyPatch("SetIndex")]
		[HarmonyPrefix]
		private static void SetIndexPatch()
		{
			pageIndex = 0;
		}
	}
	public class ShopInteractiblePageBack : Interactable
	{
		private void Start()
		{
			base.hoverText = "<-";
		}

		public override void Interact(Player player)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			ShopViewScreenPatch.pageIndex--;
			if (ShopViewScreenPatch.pageIndex < 0)
			{
				ShopViewScreenPatch.pageIndex = ShopViewScreenPatch.maxPageIndex;
			}
			ShopHandler.Instance.clickSFX.Play(((Component)ShopHandler.Instance).transform.position, false, 1f, (Transform)null);
			ShopHandler.Instance.ForceUpdate();
		}
	}
	public class ShopInteractiblePageForward : Interactable
	{
		private void Start()
		{
			base.hoverText = "->";
		}

		public override void Interact(Player player)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			ShopViewScreenPatch.pageIndex++;
			if (ShopViewScreenPatch.pageIndex > ShopViewScreenPatch.maxPageIndex)
			{
				ShopViewScreenPatch.pageIndex = 0;
			}
			ShopHandler.Instance.clickSFX.Play(((Component)ShopHandler.Instance).transform.position, false, 1f, (Transform)null);
			ShopHandler.Instance.ForceUpdate();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}