Decompiled source of MoreWorldModifiers v1.2.0

MoreWorldModifiers.dll

Decompiled 7 months ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using JFUtils.Valheim;
using JetBrains.Annotations;
using LocalizationManager;
using Microsoft.CodeAnalysis;
using ServerSync;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.BufferedDeserialization;
using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: Guid("46BDCABE-BEB1-491F-8631-310F5186A3DB")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyProduct("MoreWorldModifiers")]
[assembly: AssemblyCompany("JustAFrogger")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("MoreWorldModifiers")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: <8091639b-f00e-4c56-b9d9-4f7d5d33cfeb>RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<f85bc3e1-8a02-4b60-881e-5fdd2e20eda9>Embedded]
	internal sealed class <f85bc3e1-8a02-4b60-881e-5fdd2e20eda9>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[<f85bc3e1-8a02-4b60-881e-5fdd2e20eda9>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class <745c43d2-7dd8-466e-b8a0-d19d450aa6b6>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <745c43d2-7dd8-466e-b8a0-d19d450aa6b6>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <745c43d2-7dd8-466e-b8a0-d19d450aa6b6>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[<f85bc3e1-8a02-4b60-881e-5fdd2e20eda9>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class <d7e6d120-13d8-49a7-bb0a-0197a0c127fb>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <d7e6d120-13d8-49a7-bb0a-0197a0c127fb>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[<f85bc3e1-8a02-4b60-881e-5fdd2e20eda9>Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class <8091639b-f00e-4c56-b9d9-4f7d5d33cfeb>RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public <8091639b-f00e-4c56-b9d9-4f7d5d33cfeb>RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
internal sealed class ConfigurationManagerAttributes
{
	public bool? Browsable;

	public string Category;

	public Action<ConfigEntryBase> CustomDrawer;

	public object DefaultValue;

	public string Description;

	public string DispName;

	public bool? HideDefaultButton;

	public bool? HideSettingName;

	public bool? IsAdvanced;

	public Func<object, string> ObjToStr;

	public int? Order;

	public bool? ReadOnly;

	public bool? ShowRangeAsPercent;

	public Func<string, object> StrToObj;
}
namespace MoreWorldModifiers
{
	[HarmonyPatch]
	internal static class AllRecipesUnlockedPatch
	{
		[HarmonyPatch(typeof(Player), "Start")]
		[HarmonyPostfix]
		public static void ApplyAllRecipesUnlockedEffect(Player __instance)
		{
			//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)
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name != "main" || (Object)(object)__instance != (Object)(object)Player.m_localPlayer || !ZoneSystem.instance.GetGlobalKey("AllRecipesUnlocked"))
			{
				return;
			}
			foreach (Recipe recipe in ObjectDB.instance.m_recipes)
			{
				if (recipe.m_enabled && Object.op_Implicit((Object)(object)recipe.m_item) && !__instance.m_knownRecipes.Contains(recipe.m_item.m_itemData.m_shared.m_name))
				{
					__instance.AddKnownRecipe(recipe);
				}
			}
			__instance.UpdateKnownRecipesList();
		}
	}
	[HarmonyPatch]
	internal static class ClearWeatherPatch
	{
		[HarmonyPatch(typeof(Game), "SpawnPlayer")]
		[HarmonyPostfix]
		public static void ApplyNoHuginEffect(Game __instance)
		{
			if (ZoneSystem.instance.GetGlobalKey("ClearWeather"))
			{
				EnvMan.instance.m_debugEnv = "Clear";
			}
		}
	}
	[HarmonyPatch]
	internal static class HigherStacksPatch
	{
		[HarmonyPatch(typeof(Game), "SpawnPlayer")]
		[HarmonyPostfix]
		public static void ApplyHigherStacksEffect()
		{
			if (!Game.instance.m_firstSpawn)
			{
				return;
			}
			bool globalKey = ZoneSystem.instance.GetGlobalKey("HigherStacks-Less");
			bool globalKey2 = ZoneSystem.instance.GetGlobalKey("HigherStacks-More");
			bool globalKey3 = ZoneSystem.instance.GetGlobalKey("HigherStacks-High");
			foreach (GameObject item in ObjectDB.instance.m_items)
			{
				ItemDrop component = item.GetComponent<ItemDrop>();
				int maxStackSize = component.m_itemData.m_shared.m_maxStackSize;
				if (maxStackSize != 1)
				{
					if (globalKey)
					{
						component.m_itemData.m_shared.m_maxStackSize = Mathf.FloorToInt((float)maxStackSize / 1.5f);
					}
					if (globalKey2)
					{
						component.m_itemData.m_shared.m_maxStackSize = Mathf.FloorToInt((float)maxStackSize * 1.5f);
					}
					if (globalKey3)
					{
						component.m_itemData.m_shared.m_maxStackSize = Mathf.FloorToInt((float)maxStackSize * 2.5f);
					}
				}
			}
		}
	}
	[HarmonyPatch]
	internal static class MapExplorationPatch
	{
		[HarmonyPatch(typeof(Game), "SpawnPlayer")]
		[HarmonyPostfix]
		public static void ApplyMapExplorationEffect()
		{
			if (Game.instance.m_firstSpawn)
			{
				if (ZoneSystem.instance.GetGlobalKey("ExploreMap-Less"))
				{
					Minimap instance = Minimap.instance;
					instance.m_exploreRadius /= 1.5f;
				}
				if (ZoneSystem.instance.GetGlobalKey("ExploreMap-More"))
				{
					Minimap instance2 = Minimap.instance;
					instance2.m_exploreRadius *= 1.5f;
				}
				if (ZoneSystem.instance.GetGlobalKey("ExploreMap-High"))
				{
					Minimap instance3 = Minimap.instance;
					instance3.m_exploreRadius *= 2.5f;
				}
				if (ZoneSystem.instance.GetGlobalKey("ExploreMap-All"))
				{
					Minimap.instance.ExploreAll();
				}
			}
		}
	}
	[HarmonyPatch]
	internal static class MaxWeightPatch
	{
		[HarmonyPatch(typeof(Game), "SpawnPlayer")]
		[HarmonyPostfix]
		public static void ApplyMapExplorationEffect()
		{
			if (Game.instance.m_firstSpawn)
			{
				if (ZoneSystem.instance.GetGlobalKey("MaxWeight-Less"))
				{
					Player localPlayer = Player.m_localPlayer;
					localPlayer.m_maxCarryWeight /= 1.5f;
				}
				if (ZoneSystem.instance.GetGlobalKey("MaxWeight-More"))
				{
					Player localPlayer2 = Player.m_localPlayer;
					localPlayer2.m_maxCarryWeight *= 1.5f;
				}
				if (ZoneSystem.instance.GetGlobalKey("MaxWeight-High"))
				{
					Player localPlayer3 = Player.m_localPlayer;
					localPlayer3.m_maxCarryWeight *= 2.5f;
				}
				if (ZoneSystem.instance.GetGlobalKey("MaxWeight-All"))
				{
					Player.m_localPlayer.m_maxCarryWeight = 999999f;
				}
			}
		}
	}
	[HarmonyPatch]
	internal static class InitializePanelPatch
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__4_0;

			public static UnityAction <>9__4_1;

			internal void <CreateButtons>b__4_0()
			{
				panel.SetActive(false);
				((Component)((Component)ServerOptionsGUI.m_instance).transform.GetChild(0)).gameObject.SetActive(true);
				tooltipText.SetParent(tooltipTextParent);
			}

			internal void <CreateButtons>b__4_1()
			{
				panel.SetActive(true);
				((Component)((Component)ServerOptionsGUI.m_instance).transform.GetChild(0)).gameObject.SetActive(false);
				tooltipText.SetParent(panel.transform);
			}
		}

		internal static GameObject panel;

		internal static Transform tooltipText;

		internal static Transform tooltipTextParent;

		internal static List<string> keysAdded = new List<string>();

		private static void CreateButtons()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_0161: 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_013e: Expected O, but got Unknown
			Transform val = Utils.FindChild(((Component)ServerOptionsGUI.m_instance).transform, "Cancel");
			Button component = ((Component)Object.Instantiate<Transform>(val, panel.transform)).GetComponent<Button>();
			((Component)component).transform.position = new Vector3(((Component)component).transform.position.x + 100f, ((Component)component).transform.position.y - 60f, ((Component)component).transform.position.z);
			((Object)component).name = "Cloce Advanced Modifiers";
			((UnityEventBase)component.onClick).RemoveAllListeners();
			component.onClick = new ButtonClickedEvent();
			((TMP_Text)((Component)component).GetComponentInChildren<TextMeshProUGUI>()).text = "$back_button";
			ButtonClickedEvent onClick = component.onClick;
			object obj = <>c.<>9__4_0;
			if (obj == null)
			{
				UnityAction val2 = delegate
				{
					panel.SetActive(false);
					((Component)((Component)ServerOptionsGUI.m_instance).transform.GetChild(0)).gameObject.SetActive(true);
					tooltipText.SetParent(tooltipTextParent);
				};
				<>c.<>9__4_0 = val2;
				obj = (object)val2;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			Button component2 = ((Component)Object.Instantiate<Transform>(val, ((Component)val).transform.parent)).GetComponent<Button>();
			((Object)((Component)component2).gameObject).name = "Show Advanced Modifiers";
			((UnityEventBase)component2.onClick).RemoveAllListeners();
			component2.onClick = new ButtonClickedEvent();
			ButtonClickedEvent onClick2 = component2.onClick;
			object obj2 = <>c.<>9__4_1;
			if (obj2 == null)
			{
				UnityAction val3 = delegate
				{
					panel.SetActive(true);
					((Component)((Component)ServerOptionsGUI.m_instance).transform.GetChild(0)).gameObject.SetActive(false);
					tooltipText.SetParent(panel.transform);
				};
				<>c.<>9__4_1 = val3;
				obj2 = (object)val3;
			}
			((UnityEvent)onClick2).AddListener((UnityAction)obj2);
			((TMP_Text)((Component)component2).GetComponentInChildren<TextMeshProUGUI>()).text = "$advancedModifiers";
			((Component)component2).transform.position = ((Component)component).transform.position;
		}

		private static void CreatePanel()
		{
			panel = Object.Instantiate<GameObject>(((Component)((Component)ServerOptionsGUI.m_instance).transform.GetChild(0)).gameObject, ((Component)ServerOptionsGUI.m_instance).transform.GetChild(0).parent);
			((Object)panel).name = "New Modifiers";
			panel.SetActive(false);
			Transform val = Utils.FindChild(panel.transform, "topic");
			TextMeshProUGUI component = ((Component)val).GetComponent<TextMeshProUGUI>();
			((TMP_Text)component).text = "$advancedModifiers";
			for (int i = 0; i < panel.transform.childCount; i++)
			{
				GameObject gameObject = ((Component)panel.transform.GetChild(i)).gameObject;
				if (((Object)gameObject).name != "bkg" && ((Object)gameObject).name != "topic")
				{
					Object.Destroy((Object)(object)gameObject);
				}
			}
			tooltipText = Utils.FindChild(((Component)ServerOptionsGUI.m_instance).transform, "Tooltips");
			tooltipTextParent = tooltipText.parent;
			TextMeshProUGUI componentInChildren = panel.GetComponentInChildren<TextMeshProUGUI>();
			((TMP_Text)componentInChildren).text = "$advancedModifiers";
		}

		[HarmonyPatch(typeof(ServerOptionsGUI), "Awake")]
		[HarmonyPostfix]
		public static void AddMoreWorldModifiers(ServerOptionsGUI __instance)
		{
			CreatePanel();
			CreateButtons();
			CreateToggles();
			CreateSliders();
		}

		private static void CreateSliders()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//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)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Expected O, but got Unknown
			//IL_01a5: 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_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Expected O, but got Unknown
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: 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)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Expected O, but got Unknown
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Expected O, but got Unknown
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Expected O, but got Unknown
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Expected O, but got Unknown
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: 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_0319: Expected O, but got Unknown
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Expected O, but got Unknown
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Expected O, but got Unknown
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Expected O, but got Unknown
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Expected O, but got Unknown
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Expected O, but got Unknown
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Expected O, but got Unknown
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d7: Expected O, but got Unknown
			CreateSlider("MapExploration", new Vector3(0f, 90f, 0f), new SliderSetting
			{
				m_name = "$slider_Less",
				m_toolTip = "$ExploreMap_Less_ToolTip",
				m_modifierValue = (WorldModifierOption)11,
				m_keys = new List<string> { "ExploreMap-Less" }
			}, new SliderSetting
			{
				m_name = "$slider_Normal",
				m_toolTip = "$ExploreMap_Normal_ToolTip",
				m_modifierValue = (WorldModifierOption)0,
				m_keys = new List<string>()
			}, new SliderSetting
			{
				m_name = "$slider_More",
				m_toolTip = "$ExploreMap_More_ToolTip",
				m_modifierValue = (WorldModifierOption)8,
				m_keys = new List<string> { "ExploreMap-More" }
			}, new SliderSetting
			{
				m_name = "$slider_High",
				m_toolTip = "$ExploreMap_High_ToolTip",
				m_modifierValue = (WorldModifierOption)6,
				m_keys = new List<string> { "ExploreMap-High" }
			}, new SliderSetting
			{
				m_name = "$slider_All",
				m_toolTip = "$ExploreMap_All_ToolTip",
				m_modifierValue = (WorldModifierOption)7,
				m_keys = new List<string> { "ExploreMap-All" }
			});
			CreateSlider("SkillsSpeed", new Vector3(0f, 40f, 0f), new SliderSetting
			{
				m_name = "$slider_Less",
				m_toolTip = "$SkillsSpeed_Less_ToolTip",
				m_modifierValue = (WorldModifierOption)11,
				m_keys = new List<string> { "SkillsSpeed-Less" }
			}, new SliderSetting
			{
				m_name = "$slider_Normal",
				m_toolTip = "$SkillsSpeed_Normal_ToolTip",
				m_modifierValue = (WorldModifierOption)0,
				m_keys = new List<string>()
			}, new SliderSetting
			{
				m_name = "$slider_More",
				m_toolTip = "$SkillsSpeed_More_ToolTip",
				m_modifierValue = (WorldModifierOption)8,
				m_keys = new List<string> { "SkillsSpeed-More" }
			}, new SliderSetting
			{
				m_name = "$slider_High",
				m_toolTip = "$SkillsSpeed_High_ToolTip",
				m_modifierValue = (WorldModifierOption)6,
				m_keys = new List<string> { "SkillsSpeed-High" }
			}, new SliderSetting
			{
				m_name = "$slider_All",
				m_toolTip = "$SkillsSpeed_All_ToolTip",
				m_modifierValue = (WorldModifierOption)7,
				m_keys = new List<string> { "SkillsSpeed-All" }
			});
			CreateSlider("HigherStacks", new Vector3(0f, -10f, 0f), new SliderSetting
			{
				m_name = "$slider_Less",
				m_toolTip = "$HigherStacks_Less_ToolTip",
				m_modifierValue = (WorldModifierOption)11,
				m_keys = new List<string> { "HigherStacks-Less" }
			}, new SliderSetting
			{
				m_name = "$slider_Normal",
				m_toolTip = "$HigherStacks_Normal_ToolTip",
				m_modifierValue = (WorldModifierOption)0,
				m_keys = new List<string>()
			}, new SliderSetting
			{
				m_name = "$slider_More",
				m_toolTip = "$HigherStacks_More_ToolTip",
				m_modifierValue = (WorldModifierOption)8,
				m_keys = new List<string> { "HigherStacks-More" }
			}, new SliderSetting
			{
				m_name = "$slider_High",
				m_toolTip = "$HigherStacks_High_ToolTip",
				m_modifierValue = (WorldModifierOption)6,
				m_keys = new List<string> { "HigherStacks-High" }
			});
			CreateSlider("MaxWeight", new Vector3(0f, -60f, 0f), new SliderSetting
			{
				m_name = "$slider_Less",
				m_toolTip = "$MaxWeight_Less_ToolTip",
				m_modifierValue = (WorldModifierOption)11,
				m_keys = new List<string> { "MaxWeight-Less" }
			}, new SliderSetting
			{
				m_name = "$slider_Normal",
				m_toolTip = "$MaxWeight_Normal_ToolTip",
				m_modifierValue = (WorldModifierOption)0,
				m_keys = new List<string>()
			}, new SliderSetting
			{
				m_name = "$slider_More",
				m_toolTip = "$MaxWeight_More_ToolTip",
				m_modifierValue = (WorldModifierOption)8,
				m_keys = new List<string> { "MaxWeight-More" }
			}, new SliderSetting
			{
				m_name = "$slider_High",
				m_toolTip = "$MaxWeight_High_ToolTip",
				m_modifierValue = (WorldModifierOption)6,
				m_keys = new List<string> { "MaxWeight-High" }
			}, new SliderSetting
			{
				m_name = "$slider_All",
				m_toolTip = "$MaxWeight_All_ToolTip",
				m_modifierValue = (WorldModifierOption)7,
				m_keys = new List<string> { "MaxWeight-All" }
			});
		}

		private static void CreateToggles()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_00cf: 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)
			CreateToggle("PowersBossesOnStart", new Vector3(-110f, 240f, 0f));
			CreateToggle("NoStaminaCost", new Vector3(55f, 240f, 0f));
			CreateToggle("NoDurabilityLoss", new Vector3(220f, 240f, 0f));
			CreateToggle("AllRecipesUnlocked", new Vector3(-110f, 190f, 0f));
			CreateToggle("NoFallDamage", new Vector3(55f, 190f, 0f));
			CreateToggle("NoWet", new Vector3(220f, 190f, 0f));
			CreateToggle("NoHugin", new Vector3(-110f, 140f, 0f));
			CreateToggle("ClearWeather", new Vector3(55f, 140f, 0f));
		}

		private static void CreateToggle(string key, Vector3 pos)
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Invalid comparison between Unknown and I4
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Invalid comparison between Unknown and I4
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Invalid comparison between Unknown and I4
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Invalid comparison between Unknown and I4
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//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_0121: Unknown result type (might be due to invalid IL or missing references)
			Transform val = Utils.FindChild(((Component)ServerOptionsGUI.m_instance).transform, "PlayerBasedEvents");
			KeyToggle component = ((Component)Object.Instantiate<Transform>(val, ((Component)val).transform.parent)).GetComponent<KeyToggle>();
			((Object)component).name = key;
			component.m_enabledKey = key;
			component.m_toolTip = "$" + key + "_Tooltip";
			((TMP_Text)((Component)component).GetComponentInChildren<TextMeshProUGUI>()).text = "$" + key + "_DisplayName";
			List<KeyUI> list = ServerOptionsGUI.m_modifiers.ToList();
			list.Add((KeyUI)(object)component);
			ServerOptionsGUI.m_modifiers = list.ToArray();
			((Component)component).transform.SetParent(panel.transform);
			((Component)component).transform.localPosition = pos;
			Transform transform = ((Component)component).transform;
			RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			Edge val3 = (Edge)2;
			int num = (((int)val3 == 2 || (int)val3 == 3) ? 1 : 0);
			float num2 = (((int)val3 == 2 || (int)val3 == 1) ? 1f : 0f);
			Vector2 anchorMin = val2.anchorMin;
			((Vector2)(ref anchorMin))[num] = num2;
			val2.anchorMin = anchorMin;
			Vector2 anchorMax = val2.anchorMax;
			((Vector2)(ref anchorMax))[num] = num2;
			val2.anchorMax = anchorMax;
			keysAdded.Add(key);
		}

		private static void CreateSlider(string key, Vector3 pos, params SliderSetting[] settings)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Invalid comparison between Unknown and I4
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Invalid comparison between Unknown and I4
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Invalid comparison between Unknown and I4
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Invalid comparison between Unknown and I4
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			Transform val = Utils.FindChild(((Component)ServerOptionsGUI.m_instance).transform, "Portals");
			GameObject gameObject = ((Component)Object.Instantiate<Transform>(val, ((Component)val).transform.parent)).gameObject;
			KeySlider componentInChildren = gameObject.GetComponentInChildren<KeySlider>();
			((Object)gameObject).name = key;
			componentInChildren.m_modifier = (WorldModifiers)0;
			((TMP_Text)((Component)gameObject.transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = "$" + key + "_DisplayName";
			componentInChildren.m_settings = settings.ToList();
			componentInChildren.m_toolTip = "$" + key + "_Tooltip";
			((Component)componentInChildren).GetComponent<Slider>().maxValue = componentInChildren.m_settings.Count - 1;
			List<KeyUI> list = ServerOptionsGUI.m_modifiers.ToList();
			list.Add((KeyUI)(object)componentInChildren);
			ServerOptionsGUI.m_modifiers = list.ToArray();
			gameObject.transform.SetParent(panel.transform);
			gameObject.transform.localPosition = pos;
			Transform transform = gameObject.transform;
			RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			Edge val3 = (Edge)2;
			int num = (((int)val3 == 2 || (int)val3 == 3) ? 1 : 0);
			float num2 = (((int)val3 == 2 || (int)val3 == 1) ? 1f : 0f);
			Vector2 anchorMin = val2.anchorMin;
			((Vector2)(ref anchorMin))[num] = num2;
			val2.anchorMin = anchorMin;
			Vector2 anchorMax = val2.anchorMax;
			((Vector2)(ref anchorMax))[num] = num2;
			val2.anchorMax = anchorMax;
		}
	}
	[HarmonyPatch]
	internal static class NoDurabilityLossPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(Game), "SpawnPlayer")]
		public static void ApplyNoDurabilityLossEffect()
		{
			if (!Game.instance.m_firstSpawn || !ZoneSystem.instance.GetGlobalKey("NoDurabilityLoss"))
			{
				return;
			}
			foreach (GameObject item in ObjectDB.instance.m_items)
			{
				item.GetComponent<ItemDrop>().m_itemData.m_shared.m_useDurability = false;
				item.GetComponent<ItemDrop>().m_itemData.m_shared.m_durabilityDrain = 0f;
				item.GetComponent<ItemDrop>().m_itemData.m_shared.m_useDurabilityDrain = 0f;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Player), "PlacePiece")]
		public static void ApplyNoDurabilityLossEffect_Hammer(Player __instance)
		{
			if (ZoneSystem.instance.GetGlobalKey("NoDurabilityLoss"))
			{
				ItemData rightItem = ((Humanoid)__instance).GetRightItem();
				if (rightItem != null)
				{
					rightItem.m_durability = rightItem.m_shared.m_maxDurability;
				}
			}
		}
	}
	[HarmonyPatch]
	internal static class NoFallDamagePatch
	{
		[HarmonyPatch(typeof(SEMan), "ModifyFallDamage")]
		[HarmonyPrefix]
		public static bool ApplyNoStaminaCostEffect_UseStamina(SEMan __instance, ref float baseDamage, ref float damage)
		{
			if (!__instance.m_character.IsPlayer() || (Object)(object)__instance.m_character != (Object)(object)Player.m_localPlayer)
			{
				return true;
			}
			if (ZoneSystem.instance.GetGlobalKey("NoFallDamage"))
			{
				damage = 0f;
				baseDamage = 0f;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch]
	internal static class NoHuginPatch
	{
		[HarmonyPatch(typeof(Tutorial), "ShowText")]
		[HarmonyPrefix]
		public static bool ApplyNoHuginEffect()
		{
			bool globalKey = ZoneSystem.instance.GetGlobalKey("NoHugin");
			return !globalKey;
		}
	}
	[HarmonyPatch]
	internal static class NoStaminaCostPatch
	{
		[HarmonyPatch(typeof(Player), "UseStamina")]
		[HarmonyPrefix]
		public static bool ApplyNoStaminaCostEffect_UseStamina(Player __instance)
		{
			bool globalKey = ZoneSystem.instance.GetGlobalKey("NoStaminaCost");
			return !globalKey;
		}

		[HarmonyPatch(typeof(Player), "HaveStamina")]
		[HarmonyPrefix]
		public static bool ApplyNoStaminaCostEffect_HaveStamina(Player __instance, ref bool __result)
		{
			if (!ZoneSystem.instance.GetGlobalKey("NoStaminaCost"))
			{
				return true;
			}
			__result = true;
			return false;
		}
	}
	[HarmonyPatch]
	internal static class NoWetPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(SEMan), "AddStatusEffect", new Type[]
		{
			typeof(int),
			typeof(bool),
			typeof(int),
			typeof(float)
		})]
		public static bool ApplyNoWetEffect(SEMan __instance, int nameHash)
		{
			if (!__instance.m_character.IsPlayer() || (Object)(object)__instance.m_character != (Object)(object)Player.m_localPlayer || !Object.op_Implicit((Object)(object)ZoneSystem.instance))
			{
				return true;
			}
			if (!ZoneSystem.instance.GetGlobalKey("NoWet"))
			{
				return true;
			}
			if (nameHash == StringExtensionMethods.GetStableHashCode("Wet"))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch]
	internal static class PowersBossesOnStartPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(BossStone), "Start")]
		public static void ApplyPowersBossesOnStartEffectPatch(BossStone __instance)
		{
			((MonoBehaviour)__instance).StartCoroutine(ApplyPowersBossesOnStartEffect(__instance));
		}

		public static IEnumerator ApplyPowersBossesOnStartEffect(BossStone bossStone)
		{
			yield return (object)new WaitWhile((Func<bool>)(() => !Object.op_Implicit((Object)(object)Player.m_localPlayer)));
			if (!ZoneSystem.instance.GetGlobalKey("PowersBossesOnStart") || !Object.op_Implicit((Object)(object)bossStone.m_itemStand) || !Object.op_Implicit((Object)(object)bossStone.m_itemStand.m_nview) || !bossStone.m_itemStand.m_nview.IsOwner() || bossStone.m_itemStand.HaveAttachment())
			{
				yield break;
			}
			ItemData item = bossStone.m_itemStand.m_supportedItems[0].m_itemData;
			foreach (ItemDrop drop in ObjectDB.m_instance.GetAllItems((ItemType)13, ""))
			{
				if (drop.m_itemData.m_shared.m_name == item.m_shared.m_name)
				{
					item.m_dropPrefab = ((Component)drop).gameObject;
					break;
				}
			}
			ModBase.Debug($"localPlayer is {Player.m_localPlayer}");
			((Humanoid)Player.m_localPlayer).GetInventory().AddItem(item);
			bossStone.m_itemStand.m_queuedItem = item;
			((MonoBehaviour)bossStone.m_itemStand).CancelInvoke("UpdateAttach");
			((MonoBehaviour)bossStone.m_itemStand).InvokeRepeating("UpdateAttach", 0f, 0.1f);
			bossStone.m_itemStand.m_queuedItem = item;
		}
	}
	[HarmonyPatch]
	internal static class RemoveKeysPatch
	{
		[HarmonyPatch(typeof(Game), "SpawnPlayer")]
		[HarmonyPostfix]
		public static void RemoveKeys(Game __instance)
		{
			if (!__instance.m_firstSpawn)
			{
				return;
			}
			List<string> startingGlobalKeys = WorldGenerator.instance.m_world.m_startingGlobalKeys;
			List<string> keysAdded = InitializePanelPatch.keysAdded;
			foreach (string item in keysAdded)
			{
				if (!startingGlobalKeys.Contains(item.ToLower()))
				{
					ZoneSystem.instance.RemoveGlobalKey(item);
				}
			}
		}
	}
	[HarmonyPatch]
	internal static class SkillsSpeedPatch
	{
		[HarmonyPatch(typeof(Player), "RaiseSkill")]
		[HarmonyPrefix]
		public static void ApplySkillsSpeedEffect(Player __instance, ref float value)
		{
			if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && value != 10000f)
			{
				if (ZoneSystem.instance.GetGlobalKey("SkillsSpeed-Less"))
				{
					value /= 1.5f;
				}
				if (ZoneSystem.instance.GetGlobalKey("SkillsSpeed-More"))
				{
					value *= 1.5f;
				}
				if (ZoneSystem.instance.GetGlobalKey("SkillsSpeed-High"))
				{
					value *= 2.5f;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "Start")]
		[HarmonyPostfix]
		public static void ApplySkillsSpeedEffect_All(Player __instance)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || !ZoneSystem.instance.GetGlobalKey("SkillsSpeed-All"))
			{
				return;
			}
			foreach (SkillDef skill in Player.m_localPlayer.m_skills.m_skills)
			{
				Player.m_localPlayer.m_skills.GetSkill(skill.m_skill).m_level = 100f;
			}
		}
	}
	[BepInPlugin("com.Frogger.MoreWorldModifiers", "MoreWorldModifiers", "1.2.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModName = "MoreWorldModifiers";

		public const string ModAuthor = "Frogger";

		public const string ModVersion = "1.2.0";

		public const string ModGUID = "com.Frogger.MoreWorldModifiers";

		private void Awake()
		{
			ModBase.CreateMod((BaseUnityPlugin)(object)this, "MoreWorldModifiers", "Frogger", "1.2.0");
			Localizer.Load();
		}
	}
}
namespace LocalizationManager
{
	[PublicAPI]
	public class Localizer
	{
		private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors;

		private static readonly Dictionary<string, Dictionary<string, string>> loadedTexts;

		private static readonly ConditionalWeakTable<Localization, string> localizationLanguage;

		private static readonly List<WeakReference<Localization>> localizationObjects;

		[<745c43d2-7dd8-466e-b8a0-d19d450aa6b6>Nullable(2)]
		private static BaseUnityPlugin _plugin;

		private static readonly List<string> fileExtensions;

		private static BaseUnityPlugin plugin
		{
			get
			{
				//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Expected O, but got Unknown
				if (_plugin == null)
				{
					IEnumerable<TypeInfo> source;
					try
					{
						source = Assembly.GetExecutingAssembly().DefinedTypes.ToList();
					}
					catch (ReflectionTypeLoadException ex)
					{
						source = from t in ex.Types
							where t != null
							select t.GetTypeInfo();
					}
					_plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First((TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
				}
				return _plugin;
			}
		}

		static Localizer()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			PlaceholderProcessors = new Dictionary<string, Dictionary<string, Func<string>>>();
			loadedTexts = new Dictionary<string, Dictionary<string, string>>();
			localizationLanguage = new ConditionalWeakTable<Localization, string>();
			localizationObjects = new List<WeakReference<Localization>>();
			fileExtensions = new List<string> { ".json", ".yml" };
			Harmony val = new Harmony("org.bepinex.helpers.LocalizationManager");
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private static void UpdatePlaceholderText(Localization localization, string key)
		{
			localizationLanguage.TryGetValue(localization, out var value);
			string text = loadedTexts[value][key];
			if (PlaceholderProcessors.TryGetValue(key, out var value2))
			{
				text = value2.Aggregate(text, (string current, KeyValuePair<string, Func<string>> kv) => current.Replace("{" + kv.Key + "}", kv.Value()));
			}
			localization.AddWord(key, text);
		}

		public static void AddPlaceholder<[<745c43d2-7dd8-466e-b8a0-d19d450aa6b6>Nullable(1)] T>(string key, string placeholder, ConfigEntry<T> config, [<745c43d2-7dd8-466e-b8a0-d19d450aa6b6>Nullable(new byte[] { 2, 0, 0 })] Func<T, string> convertConfigValue = null)
		{
			if (convertConfigValue == null)
			{
				convertConfigValue = (T val) => val.ToString();
			}
			if (!PlaceholderProcessors.ContainsKey(key))
			{
				PlaceholderProcessors[key] = new Dictionary<string, Func<string>>();
			}
			config.SettingChanged += delegate
			{
				UpdatePlaceholder();
			};
			if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage()))
			{
				UpdatePlaceholder();
			}
			void UpdatePlaceholder()
			{
				PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value);
				UpdatePlaceholderText(Localization.instance, key);
			}
		}

		public static void AddText(string key, string text)
		{
			List<WeakReference<Localization>> list = new List<WeakReference<Localization>>();
			foreach (WeakReference<Localization> localizationObject in localizationObjects)
			{
				if (localizationObject.TryGetTarget(out var target))
				{
					Dictionary<string, string> dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)];
					if (!target.m_translations.ContainsKey(key))
					{
						dictionary[key] = text;
						target.AddWord(key, text);
					}
				}
				else
				{
					list.Add(localizationObject);
				}
			}
			foreach (WeakReference<Localization> item in list)
			{
				localizationObjects.Remove(item);
			}
		}

		public static void Load()
		{
			LoadLocalization(Localization.instance, Localization.instance.GetSelectedLanguage());
		}

		private static void LoadLocalization(Localization __instance, string language)
		{
			if (!localizationLanguage.Remove(__instance))
			{
				localizationObjects.Add(new WeakReference<Localization>(__instance));
			}
			localizationLanguage.Add(__instance, language);
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			foreach (string item in from f in Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories)
				where fileExtensions.IndexOf(Path.GetExtension(f)) >= 0
				select f)
			{
				string text = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' })[1];
				if (dictionary.ContainsKey(text))
				{
					Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped."));
				}
				else
				{
					dictionary[text] = item;
				}
			}
			byte[] array = LoadTranslationFromAssembly("English");
			if (array == null)
			{
				throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml.");
			}
			Dictionary<string, string> dictionary2 = new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(Encoding.UTF8.GetString(array));
			if (dictionary2 == null)
			{
				throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty.");
			}
			string text2 = null;
			if (language != "English")
			{
				if (dictionary.ContainsKey(language))
				{
					text2 = File.ReadAllText(dictionary[language]);
				}
				else
				{
					byte[] array2 = LoadTranslationFromAssembly(language);
					if (array2 != null)
					{
						text2 = Encoding.UTF8.GetString(array2);
					}
				}
			}
			if (text2 == null && dictionary.ContainsKey("English"))
			{
				text2 = File.ReadAllText(dictionary["English"]);
			}
			if (text2 != null)
			{
				foreach (KeyValuePair<string, string> item2 in new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(text2) ?? new Dictionary<string, string>())
				{
					dictionary2[item2.Key] = item2.Value;
				}
			}
			loadedTexts[language] = dictionary2;
			foreach (KeyValuePair<string, string> item3 in dictionary2)
			{
				UpdatePlaceholderText(__instance, item3.Key);
			}
		}

		[return: <745c43d2-7dd8-466e-b8a0-d19d450aa6b6>Nullable(2)]
		private static byte[] LoadTranslationFromAssembly(string language)
		{
			foreach (string fileExtension in fileExtensions)
			{
				byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension);
				if (array != null)
				{
					return array;
				}
			}
			return null;
		}

		[<d7e6d120-13d8-49a7-bb0a-0197a0c127fb>NullableContext(2)]
		public static byte[] ReadEmbeddedFileBytes([<745c43d2-7dd8-466e-b8a0-d19d450aa6b6>Nullable(0)] string resourceFileName, Assembly containingAssembly = null)
		{
			using MemoryStream memoryStream = new MemoryStream();
			if ((object)containingAssembly == null)
			{
				containingAssembly = Assembly.GetCallingAssembly();
			}
			string text = containingAssembly.GetManifestResourceNames().FirstOrDefault((string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal));
			if (text != null)
			{
				containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream);
			}
			return (memoryStream.Length == 0L) ? null : memoryStream.ToArray();
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[<9b9268fa-2884-41f9-993f-1d4be2084e79>Embedded]
	[CompilerGenerated]
	internal sealed class <9b9268fa-2884-41f9-993f-1d4be2084e79>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[<9b9268fa-2884-41f9-993f-1d4be2084e79>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class <19838e05-66f2-4d08-9b26-4db06ccdcdd5>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <19838e05-66f2-4d08-9b26-4db06ccdcdd5>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <19838e05-66f2-4d08-9b26-4db06ccdcdd5>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	[<9b9268fa-2884-41f9-993f-1d4be2084e79>Embedded]
	internal sealed class <8b4514a8-68dc-4d71-a2e7-b6d39287019e>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <8b4514a8-68dc-4d71-a2e7-b6d39287019e>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[<9b9268fa-2884-41f9-993f-1d4be2084e79>Embedded]
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace JFUtils
{
	internal static class EnumerableExtension
	{
		[CanBeNull]
		public static List<T> _Distinct<T>(this List<T> list)
		{
			List<T> list2 = list?.Distinct().ToList();
			if (list2 != null)
			{
				list = list2;
			}
			return list2;
		}

		public static Dictionary<TKey, TValue> Dictionary<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> list)
		{
			return list.Select((KeyValuePair<TKey, TValue> x) => x).ToDictionary((KeyValuePair<TKey, TValue> x) => x.Key, (KeyValuePair<TKey, TValue> y) => y.Value);
		}

		public static T Random<T>(this List<T> list)
		{
			if (list == null || list.Count == 0)
			{
				return default(T);
			}
			return list[Random.Range(0, list.Count)];
		}

		public static T Random<T>(this T[] array)
		{
			if (array == null || array.Length == 0)
			{
				return default(T);
			}
			return array[Random.Range(0, array.Length)];
		}

		public static List<Vector3> RoundCords(this List<Vector3> list)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list2 = new List<Vector3>();
			for (int i = 0; i < list.Count; i++)
			{
				list2.Add(new Vector3((float)(int)list[i].x, (float)(int)list[i].y, (float)(int)list[i].z));
			}
			return list2;
		}

		public static List<Vector2> RoundCords(this List<Vector2> list)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			List<Vector2> list2 = new List<Vector2>();
			for (int i = 0; i < list.Count; i++)
			{
				list2.Add(new Vector2((float)(int)list[i].x, (float)(int)list[i].y));
			}
			return list2;
		}

		public static string GetString<T>(this IEnumerable<T> list, string separator = ", ")
		{
			return string.Join(separator, list);
		}

		public static void TryAdd<T>(this List<T> sequence, T item)
		{
			if (!sequence.Contains(item))
			{
				sequence.Add(item);
			}
		}

		public static T Next<T>(this List<T> list, T current)
		{
			if (list == null || list.Count == 0)
			{
				return default(T);
			}
			T val = list[list.Count - 1];
			if (current.Equals(val))
			{
				return list[0];
			}
			if (!list.Contains(current))
			{
				Debug.LogWarning((object)$"[{list}.Next] list not contains this element {current}");
				return list[0];
			}
			return list[list.IndexOf(current) + 1];
		}

		public static T Nearest<T>(this IEnumerable<T> list, Vector3 nearestTo) where T : Component
		{
			//IL_0047: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			T result = default(T);
			float num = 2.1474836E+09f;
			if (list == null || list.Count() == 0)
			{
				return result;
			}
			foreach (T item in list)
			{
				Vector3 position = ((Component)item).transform.position;
				float num2 = Utils.DistanceXZ(nearestTo, position);
				if (num2 < num)
				{
					result = item;
					num = num2;
				}
			}
			return result;
		}
	}
	internal static class GameObjectExtension
	{
		public static string GetPrefabName(this GameObject gameObject)
		{
			string text = Utils.GetPrefabName(gameObject);
			for (int i = 0; i < 80; i++)
			{
				text = text.Replace($" ({i})", "");
			}
			return text;
		}

		public static string GetPrefabName<T>(this T gameObject) where T : MonoBehaviour
		{
			string text = Utils.GetPrefabName(((Component)(object)gameObject).gameObject);
			for (int i = 0; i < 80; i++)
			{
				text = text.Replace($" ({i})", "");
			}
			return text;
		}

		public static GameObject OrNull(this GameObject @this)
		{
			return Object.op_Implicit((Object)(object)@this) ? @this : null;
		}

		public static T OrNull<T>(this T @this) where T : Object
		{
			return Object.op_Implicit((Object)(object)@this) ? @this : default(T);
		}

		public static T GetOrAddComponent<T>(this GameObject gameObject) where T : Component
		{
			return gameObject.GetComponent<T>() ?? gameObject.AddComponent<T>();
		}

		public static Component AddComponentCopy<T>(this GameObject gameObject, T duplicate) where T : Component
		{
			Component val = gameObject.AddComponent(((object)duplicate).GetType());
			PropertyInfo[] properties = ((object)duplicate).GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (PropertyInfo propertyInfo in properties)
			{
				if (!(propertyInfo.Name == "rayTracingMode") && propertyInfo.CanWrite && propertyInfo.GetMethod != null)
				{
					propertyInfo.SetValue(val, propertyInfo.GetValue(duplicate));
				}
			}
			FieldInfo[] fields = ((object)duplicate).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (FieldInfo fieldInfo in fields)
			{
				if (!(fieldInfo.Name == "rayTracingMode"))
				{
					fieldInfo.SetValue(val, fieldInfo.GetValue(duplicate));
				}
			}
			return val;
		}

		internal static GameObject SetToTextHeight(this GameObject go)
		{
			go.GetComponent<RectTransform>().SetSizeWithCurrentAnchors((Axis)1, go.GetComponentInChildren<Text>().preferredHeight + 3f);
			return go;
		}

		internal static GameObject SetUpperLeft(this GameObject go)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = go.GetComponent<RectTransform>();
			component.anchorMax = new Vector2(0f, 1f);
			component.anchorMin = new Vector2(0f, 1f);
			component.pivot = new Vector2(0f, 1f);
			component.anchoredPosition = new Vector2(0f, 0f);
			return go;
		}

		internal static GameObject SetMiddleLeft(this GameObject go)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = go.GetComponent<RectTransform>();
			component.anchorMax = new Vector2(0f, 0.5f);
			component.anchorMin = new Vector2(0f, 0.5f);
			component.pivot = new Vector2(0f, 0.5f);
			component.anchoredPosition = new Vector2(0f, 0f);
			return go;
		}

		internal static GameObject SetBottomLeft(this GameObject go)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = go.GetComponent<RectTransform>();
			component.anchorMax = new Vector2(0f, 0f);
			component.anchorMin = new Vector2(0f, 0f);
			component.pivot = new Vector2(0f, 0f);
			component.anchoredPosition = new Vector2(0f, 0f);
			return go;
		}

		internal static GameObject SetUpperRight(this GameObject go)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = go.GetComponent<RectTransform>();
			component.anchorMax = new Vector2(1f, 1f);
			component.anchorMin = new Vector2(1f, 1f);
			component.pivot = new Vector2(1f, 1f);
			component.anchoredPosition = new Vector2(0f, 0f);
			return go;
		}

		internal static GameObject SetMiddleRight(this GameObject go)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = go.GetComponent<RectTransform>();
			component.anchorMax = new Vector2(1f, 0.5f);
			component.anchorMin = new Vector2(1f, 0.5f);
			component.pivot = new Vector2(1f, 0.5f);
			component.anchoredPosition = new Vector2(0f, 0f);
			return go;
		}

		internal static GameObject SetBottomRight(this GameObject go)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = go.GetComponent<RectTransform>();
			component.anchorMax = new Vector2(1f, 0f);
			component.anchorMin = new Vector2(1f, 0f);
			component.pivot = new Vector2(1f, 0f);
			component.anchoredPosition = new Vector2(0f, 0f);
			return go;
		}

		internal static GameObject SetUpperCenter(this GameObject go)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = go.GetComponent<RectTransform>();
			component.anchorMax = new Vector2(0.5f, 1f);
			component.anchorMin = new Vector2(0.5f, 1f);
			component.pivot = new Vector2(0.5f, 1f);
			component.anchoredPosition = new Vector2(0f, 0f);
			return go;
		}

		internal static GameObject SetMiddleCenter(this GameObject go)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = go.GetComponent<RectTransform>();
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(0.5f, 0.5f);
			component.anchoredPosition = new Vector2(0f, 0f);
			return go;
		}

		internal static GameObject SetBottomCenter(this GameObject go)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = go.GetComponent<RectTransform>();
			component.anchorMax = new Vector2(0.5f, 0f);
			component.anchorMin = new Vector2(0.5f, 0f);
			component.pivot = new Vector2(0.5f, 0f);
			component.anchoredPosition = new Vector2(0f, 0f);
			return go;
		}

		internal static GameObject SetSize(this GameObject go, float width, float height)
		{
			RectTransform component = go.GetComponent<RectTransform>();
			component.SetSizeWithCurrentAnchors((Axis)0, width);
			component.SetSizeWithCurrentAnchors((Axis)1, height);
			return go;
		}

		internal static GameObject SetWidth(this GameObject go, float width)
		{
			RectTransform component = go.GetComponent<RectTransform>();
			component.SetSizeWithCurrentAnchors((Axis)0, width);
			return go;
		}

		internal static GameObject SetHeight(this GameObject go, float height)
		{
			RectTransform component = go.GetComponent<RectTransform>();
			component.SetSizeWithCurrentAnchors((Axis)1, height);
			return go;
		}

		internal static float GetWidth(this GameObject go)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = go.GetComponent<RectTransform>();
			Rect rect = component.rect;
			return ((Rect)(ref rect)).width;
		}

		internal static float GetHeight(this GameObject go)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = go.GetComponent<RectTransform>();
			Rect rect = component.rect;
			return ((Rect)(ref rect)).height;
		}

		internal static float GetTextHeight(this GameObject go)
		{
			return go.GetComponent<Text>().preferredHeight;
		}

		internal static GameObject SetText(this GameObject go, string text)
		{
			go.GetComponent<Text>().text = text;
			return go;
		}
	}
	internal static class MonoBehaviourExtension
	{
		public static T SetActiveGO<T>(this T behaviour, bool flag) where T : Component
		{
			((Component)behaviour).gameObject.SetActive(flag);
			return behaviour;
		}
	}
	internal static class ObjectExtension
	{
		public static string GetObjectString(this object obj, bool includePrivate = false)
		{
			if (obj == null)
			{
				return "null";
			}
			string text = $"{obj}";
			Type type = obj.GetType();
			IEnumerable<FieldInfo> enumerable = from f in type.GetFields()
				where f.IsPublic
				select f;
			foreach (FieldInfo item in enumerable)
			{
				object value = item.GetValue(obj);
				string text2 = ((value == null) ? "null" : value.ToString());
				text = text + "\n " + item.Name + ": " + text2;
			}
			FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
			FieldInfo[] array = fields;
			foreach (FieldInfo fieldInfo in array)
			{
				object value2 = fieldInfo.GetValue(obj);
				string text3 = ((value2 == null) ? "null" : value2.ToString());
				text = text + "\n[private] " + fieldInfo.Name + ": " + text3;
			}
			PropertyInfo[] properties = type.GetProperties();
			PropertyInfo[] array2 = properties;
			foreach (PropertyInfo propertyInfo in array2)
			{
				object value3 = propertyInfo.GetValue(obj, null);
				string text4 = ((value3 == null) ? "null" : value3.ToString());
				text = text + "\n " + propertyInfo.Name + ": " + text4;
			}
			return text;
		}

		public static ZNetView GeZNetView(this Object obj)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			return (ZNetView)((object)obj).GetType().GetField("m_nview", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(obj);
		}
	}
	internal static class RectTransformExtension
	{
		public static bool Overlaps(this RectTransform a, RectTransform b)
		{
			//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_000b: Unknown result type (might be due to invalid IL or missing references)
			Rect val = a.WorldRect();
			return ((Rect)(ref val)).Overlaps(b.WorldRect());
		}

		public static bool Overlaps(this RectTransform a, RectTransform b, bool allowInverse)
		{
			//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_000b: Unknown result type (might be due to invalid IL or missing references)
			Rect val = a.WorldRect();
			return ((Rect)(ref val)).Overlaps(b.WorldRect(), allowInverse);
		}

		public static Rect WorldRect(this RectTransform rectTransform)
		{
			//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_0008: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			Vector2 sizeDelta = rectTransform.sizeDelta;
			float num = sizeDelta.x * ((Transform)rectTransform).lossyScale.x;
			float num2 = sizeDelta.y * ((Transform)rectTransform).lossyScale.y;
			Vector3 position = ((Transform)rectTransform).position;
			return new Rect(position.x - num / 2f, position.y - num2 / 2f, num, num2);
		}
	}
	internal static class RendererExtension
	{
		private class CoroutineHandler : MonoBehaviour
		{
		}

		private static readonly CoroutineHandler coroutineHandler;

		private static readonly List<Renderer> flashingRenderers;

		static RendererExtension()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			flashingRenderers = new List<Renderer>();
			coroutineHandler = new GameObject("CoroutineHandler").AddComponent<CoroutineHandler>();
			Object.DontDestroyOnLoad((Object)(object)coroutineHandler);
		}

		public static async void Flash(this Renderer renderer, Color color, Color returnColor, float time = 0.3f, Action callback = null)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (!flashingRenderers.Contains(renderer))
			{
				await HighlightObject(renderer, color, returnColor, time);
				callback?.Invoke();
			}
		}

		private static async Task HighlightObject(Renderer obj, Color color, Color returnColor, float time)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			flashingRenderers.Add(obj);
			Renderer[] renderersInChildren = ((Component)obj).GetComponentsInChildren<Renderer>();
			Material heightmapMaterial = null;
			if (((Object)obj).name == "Terrain")
			{
				Heightmap heightmap = ((Component)obj).GetComponent<Heightmap>();
				heightmapMaterial = Object.Instantiate<Material>(new Material(((Renderer)heightmap.m_meshRenderer).material));
				((Renderer)heightmap.m_meshRenderer).material.shader = Shader.Find("Standard");
			}
			Renderer[] array = renderersInChildren;
			foreach (Renderer renderer in array)
			{
				Material[] materials = renderer.materials;
				foreach (Material material in materials)
				{
					if (material.HasProperty("_EmissionColor"))
					{
						material.SetColor("_EmissionColor", color * 0.7f);
					}
					material.color = color;
				}
			}
			await Task.Delay((int)TimeSpan.FromSeconds(time).TotalMilliseconds);
			if (((Object)obj).name == "Terrain" && Object.op_Implicit((Object)(object)heightmapMaterial))
			{
				obj.material = heightmapMaterial;
			}
			Renderer[] array2 = renderersInChildren;
			foreach (Renderer renderer2 in array2)
			{
				Material[] materials2 = renderer2.materials;
				foreach (Material material2 in materials2)
				{
					if (material2.HasProperty("_EmissionColor"))
					{
						material2.SetColor("_EmissionColor", returnColor * 0f);
					}
					material2.color = returnColor;
				}
			}
			flashingRenderers.Remove(obj);
		}
	}
	internal struct SimpleVector2 : IEquatable<SimpleVector2>
	{
		public float x;

		public float y;

		public SimpleVector2(float x, float y)
		{
			this.x = x;
			this.y = y;
		}

		public SimpleVector2()
		{
			x = 0f;
			y = 0f;
		}

		public bool Equals(SimpleVector2 other)
		{
			return x == other.x && y == other.y;
		}

		public override string ToString()
		{
			return $"X: {x}, Y: {y}";
		}

		public Vector2 ToVector2()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			return new Vector2(x, y);
		}
	}
	internal static class SimpleVector2Ext
	{
		public static SimpleVector2 ToSimpleVector2(this Vector2 vector2)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return new SimpleVector2(vector2.x, vector2.y);
		}
	}
	internal struct SimpleVector3 : IEquatable<SimpleVector3>
	{
		public float x;

		public float y;

		public float z;

		public SimpleVector3(float x, float y, float z)
		{
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public SimpleVector3()
		{
			x = 0f;
			y = 0f;
			z = 0f;
		}

		public bool Equals(SimpleVector3 other)
		{
			return x == other.x && y == other.y && z == other.z;
		}

		public override string ToString()
		{
			return $"X: {x}, Y: {y}, Z: {z}";
		}

		public Vector3 ToVector3()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(x, y, z);
		}
	}
	internal static class SimpleVector3Ext
	{
		public static SimpleVector3 ToSimpleVector3(this Vector3 vector3)
		{
			//IL_0001: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			return new SimpleVector3(vector3.x, vector3.y, vector3.z);
		}
	}
	internal static class StringExtension
	{
		public static bool IsGood(this string str)
		{
			return !string.IsNullOrEmpty(str) && !string.IsNullOrWhiteSpace(str);
		}

		public static List<string> Split_(this string str)
		{
			return str.Split(new string[1] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList();
		}
	}
	[Description("Thanks to Azu ;)")]
	internal static class TimeUtils
	{
		private static string GetCurrentTimeString()
		{
			return string.Format("<b>{0}</b>", GetCurrentTime().ToString("HH:mm"));
		}

		[Description("HH.mm")]
		public static (int, int) GetCurrentTimeValue()
		{
			DateTime currentTime = GetCurrentTime();
			if (currentTime == DateTime.Now)
			{
				return (-1, -1);
			}
			return (currentTime.Hour, currentTime.Minute);
		}

		private static DateTime GetCurrentTime()
		{
			DateTime now = DateTime.Now;
			if (!Object.op_Implicit((Object)(object)EnvMan.instance))
			{
				return now;
			}
			float smoothDayFraction = EnvMan.instance.m_smoothDayFraction;
			int num = (int)(smoothDayFraction * 24f);
			int num2 = (int)((smoothDayFraction * 24f - (float)num) * 60f);
			int second = (int)(((smoothDayFraction * 24f - (float)num) * 60f - (float)num2) * 60f);
			return new DateTime(now.Year, now.Month, now.Day, num, num2, second);
		}
	}
	internal static class TransformExtension
	{
		public static Transform FindChildByName(this Transform transform, string name)
		{
			return Utils.FindChild(transform, name);
		}

		public static float DistanceXZ(this Transform transform, Transform other)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return Utils.DistanceXZ(transform.position, other.position);
		}

		public static float DistanceXZ(this Transform transform, Component otherGameObject)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			return Utils.DistanceXZ(transform.position, otherGameObject.transform.position);
		}

		public static float DistanceXZ(this Transform transform, GameObject otherGameObject)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			return Utils.DistanceXZ(transform.position, otherGameObject.transform.position);
		}

		public static float DistanceXZ(this Transform transform, Vector3 otherPos)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return Utils.DistanceXZ(transform.position, otherPos);
		}
	}
	internal class Utilities
	{
		public static AssetBundle GetAssetBundleFromResources(string filename)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename));
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			return AssetBundle.LoadFromStream(stream);
		}
	}
	internal static class VectorExtension
	{
		public static Vector2 ToV2(this Vector3 vector3)
		{
			//IL_0001: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			return new Vector2(vector3.x, vector3.z);
		}

		public static Vector3 ToV3(this Vector2 vector2)
		{
			//IL_0001: 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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(vector2.x, 0f, vector2.y);
		}

		public static Vector3 RoundCords(this Vector3 vector3)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3((float)(int)vector3.x, (float)(int)vector3.y, (float)(int)vector3.z);
		}

		public static Vector2 RoundCords(this Vector2 vector3)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			return new Vector2((float)(int)vector3.x, (float)(int)vector3.y);
		}

		public static Vector3 WithY(this Vector3 vector3, float y)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(vector3.x, y, vector3.z);
		}

		public static Vector2 WithY(this Vector2 vector3, float y)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			return new Vector2(vector3.x, y);
		}

		public static float DistanceXZ(this Vector3 pos, Vector3 otherPos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return Utils.DistanceXZ(pos, otherPos);
		}

		public static float DistanceXZ(this Vector3 pos, Transform otherPos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return Utils.DistanceXZ(pos, otherPos.position);
		}

		public static float DistanceXZ(this Vector3 pos, Component otherPos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return Utils.DistanceXZ(pos, otherPos.transform.position);
		}

		public static float DistanceXZ(this Vector3 pos, GameObject otherPos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return Utils.DistanceXZ(pos, otherPos.transform.position);
		}
	}
	internal static class Weather
	{
		public static readonly string ClearSkies = "Clear";

		public static readonly string MeadowsClearSkies = "Heath_clear";

		public static readonly string LightRain = "LightRain";

		public static readonly string Rain = "Rain";

		public static readonly string ThunderStorm = "ThunderStorm";

		public static readonly string ClearThunderStorm = "nofogts";

		public static readonly string SwampRain = "SwampRain";

		public static readonly string MistlandsDark = "Darklands_dark";

		public static readonly string AshlandsAshrain = "Ashrain";

		public static readonly string MountainSnow = "Snow";

		public static readonly string MountainBlizzard = "SnowStorm";

		public static readonly string BlackForestFog = "DeepForest Mist";

		public static readonly string Fog = "Misty";

		public static readonly string DeepNorthSnow = "Twilight_Snow";

		public static readonly string DeepNorthSnowStorm = "Twilight_SnowStorm";

		public static readonly string DeepNorthClear = "Twilight_Clear";

		public static readonly string EikthyrsThunderstorm = "Eikthyr";

		public static readonly string EldersHaze = "GDKing";

		public static readonly string BonemassDownpour = "Bonemass";

		public static readonly string ModersVortex = "Moder";

		public static readonly string YagluthsMagicBlizzard = "GoblinKing";

		public static readonly string Crypt = "Crypt";

		public static readonly string SunkenCrypt = "SunkenCrypt";
	}
}
namespace JFUtils.Valheim
{
	internal sealed class ModBase
	{
		public enum Toggle
		{
			On = 1,
			Off = 0
		}

		private static bool sendDebugMessagesToHud;

		private static ConfigEntry<bool> sendDebugMessagesToHudConfig;

		public static string ModName;

		public static string ModAuthor;

		public static string ModVersion;

		public static string ModGUID;

		public static ModBase mod;

		public static BaseUnityPlugin plugin;

		private readonly Harmony harmony;

		public Action OnConfigurationChanged;

		public AssetBundle bundle;

		private readonly string ConfigFileName = "-1";

		private DateTime LastConfigChange;

		public ConfigSync configSync;

		private static ConfigEntry<bool> serverConfigLocked;

		public AssetBundle LoadAssetBundle(string filename)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename));
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			bundle = AssetBundle.LoadFromStream(stream);
			return bundle;
		}

		private ModBase(string modName, string modAuthor, string modVersion)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			ModName = modName;
			ModAuthor = modAuthor;
			ModVersion = modVersion;
			ModGUID = "com." + ModAuthor + "." + ModName;
			harmony = new Harmony(ModGUID);
			ConfigFileName = ModGUID + ".cfg";
		}

		public static ModBase CreateMod(BaseUnityPlugin plugin, string modName, string modAuthor, string modVersion)
		{
			if ((bool)mod)
			{
				throw new Exception("Trying to create new mod " + modName + ", but " + ModName + " already exists");
			}
			mod = new ModBase(modName, modAuthor, modVersion);
			ModBase.plugin = plugin;
			mod.Init();
			return mod;
		}

		private void Init()
		{
			configSync = new ConfigSync(ModName)
			{
				DisplayName = ModName,
				CurrentVersion = ModVersion,
				MinimumRequiredVersion = ModVersion
			};
			plugin.Config.SaveOnConfigSet = false;
			SetupWatcher();
			plugin.Config.ConfigReloaded += delegate
			{
				UpdateConfiguration();
			};
			serverConfigLocked = config("General", "ServerConfigLock", value: true, "");
			configSync.AddLockingConfigEntry<bool>(serverConfigLocked);
			sendDebugMessagesToHudConfig = config("Debug", "Send debug messages to hud", value: true, "");
			plugin.Config.SaveOnConfigSet = true;
			plugin.Config.Save();
			harmony.PatchAll();
		}

		public static implicit operator bool(ModBase modBase)
		{
			return modBase != null;
		}

		public static void Debug(object msg)
		{
			plugin.Logger.LogInfo(msg);
			msg = $"[{ModName}] {msg}";
			if (Console.IsVisible())
			{
				((Terminal)Console.instance).AddString(msg.ToString());
			}
			if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Player.m_debugMode && sendDebugMessagesToHud)
			{
				((Character)Player.m_localPlayer).Message((MessageType)1, msg.ToString(), 0, (Sprite)null);
			}
		}

		public static void DebugError(object msg, bool showWriteToDev = true)
		{
			if (Console.IsVisible())
			{
				((Terminal)Console.instance).AddString($"<color=red>[{ModName}] {msg}</color>");
			}
			if (showWriteToDev)
			{
				msg = msg?.ToString() + "Write to the developer and moderator if this happens often.";
			}
			plugin.Logger.LogError(msg);
		}

		public static void DebugWarning(object msg, bool showWriteToDev = true)
		{
			if (Console.IsVisible())
			{
				((Terminal)Console.instance).AddString($"<color=yellow>[{ModName}] {msg}</color>");
			}
			if (showWriteToDev)
			{
				msg = msg?.ToString() + "Write to the developer and moderator if this happens often.";
			}
			plugin.Logger.LogWarning(msg);
		}

		public ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true)
		{
			ConfigEntry<T> val = plugin.Config.Bind<T>(group, name, value, description);
			SyncedConfigEntry<T> syncedConfigEntry = configSync.AddConfigEntry<T>(val);
			syncedConfigEntry.SynchronizedConfig = synchronizedSetting;
			return val;
		}

		public ConfigEntry<T> config<T>(string group, string name, T value, string description, bool synchronizedSetting = true)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting);
		}

		private void SetupWatcher()
		{
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName);
			fileSystemWatcher.Changed += ConfigChanged;
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		private void ConfigChanged(object sender, FileSystemEventArgs e)
		{
			if ((DateTime.Now - LastConfigChange).TotalSeconds <= 2.0)
			{
				return;
			}
			LastConfigChange = DateTime.Now;
			try
			{
				plugin.Config.Reload();
			}
			catch
			{
				DebugError("Unable reload config");
			}
		}

		private void UpdateConfiguration()
		{
			try
			{
				sendDebugMessagesToHud = sendDebugMessagesToHudConfig.Value;
				OnConfigurationChanged?.Invoke();
				if (OnConfigurationChanged == null)
				{
					Debug("Configuration Received");
				}
			}
			catch (Exception ex)
			{
				DebugError("Configuration error: " + ex.Message, showWriteToDev: false);
			}
		}
	}
	internal static class BiomeExtension
	{
		public static string GetLocalizationKey(this Biome biome)
		{
			return "$biome_" + ((object)(Biome)(ref biome)).ToString().ToLower();
		}
	}
	internal static class InventoryExtension
	{
		public static bool RemoveOneItemByLocKey(this Inventory inventory, string itemLocKey)
		{
			ItemData val = inventory.m_inventory.Find((ItemData x) => x.m_shared.m_name == itemLocKey);
			if (val == null)
			{
				return false;
			}
			if (val.m_stack > 1)
			{
				val.m_stack--;
				inventory.Changed();
			}
			else
			{
				inventory.m_inventory.Remove(val);
				inventory.Changed();
			}
			return true;
		}

		public static bool GiveItemIfNotHave(this Inventory inventory, string prefabName, int count = 1)
		{
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(prefabName);
			ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return false;
			}
			if (inventory.ContainsItemByName(val.m_itemData.m_shared.m_name))
			{
				return false;
			}
			inventory.AddItem(((Component)val).gameObject, count);
			return true;
		}

		public static bool ContainsItemByLocKey(this Inventory inventory, string localizedName)
		{
			foreach (ItemData item in inventory.m_inventory)
			{
				if (item.m_shared.m_name == localizedName)
				{
					return true;
				}
			}
			return false;
		}
	}
	internal static class ItemDropExtension
	{
		public static string LocalizeName(this ItemDrop drop)
		{
			return drop.m_itemData.LocalizeName();
		}

		public static string LocalizeName(this ItemData drop)
		{
			return drop.m_shared.LocalizeName();
		}

		public static string LocalizeName(this SharedData drop)
		{
			return drop.m_name.Localize();
		}
	}
	internal static class MinimapExtension
	{
		public static void ForceUpdateLocationPins(this Minimap minimap)
		{
			minimap.m_updateLocationsTimer = -1f;
			minimap.UpdateLocationPins(0f);
		}
	}
	internal static class ObjectDBExtension
	{
		public static ItemDrop GetItem(this ObjectDB objectDB, string name)
		{
			GameObject itemPrefab = objectDB.GetItemPrefab(name);
			return (itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null;
		}

		public static ItemDrop GetItem(this ObjectDB objectDB, int hash)
		{
			GameObject itemPrefab = objectDB.GetItemPrefab(hash);
			return (itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null;
		}
	}
	internal static class RecipeExtension
	{
		public static IEnumerable<(SharedData, int)> ToList(this Recipe recipe)
		{
			if (!Object.op_Implicit((Object)(object)recipe) || recipe.m_resources == null)
			{
				return null;
			}
			(SharedData, int)[] array = new(SharedData, int)[recipe.m_resources.Length];
			for (int i = 0; i < recipe.m_resources.Length; i++)
			{
				Requirement val = recipe.m_resources[i];
				array[i] = (val.m_resItem?.m_itemData.m_shared, val.m_amount);
			}
			return array;
		}

		public static IEnumerable<(string, int)> ToListStr(this Recipe recipe)
		{
			if (!Object.op_Implicit((Object)(object)recipe) || recipe.m_resources == null)
			{
				return null;
			}
			(string, int)[] array = new(string, int)[recipe.m_resources.Length];
			for (int i = 0; i < recipe.m_resources.Length; i++)
			{
				Requirement val = recipe.m_resources[i];
				array[i] = (((Object)val.m_resItem).name, val.m_amount);
			}
			return array;
		}
	}
	internal static class SkillsExtension
	{
		public static Skill GetCustomSkill(this Skills skills, string skillName)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return skills.GetSkill(skills.GetCustomSkillType(skillName));
		}

		public static SkillDef GetCustomSkillDef(this Skills skills, string skillName)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return skills.GetSkillDef(skills.GetCustomSkillType(skillName));
		}

		public static SkillType GetCustomSkillType(this Skills skills, string skillName)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (!Enum.TryParse<SkillType>(skillName, out SkillType result))
			{
				SkillDef skillDef = skills.GetSkillDef((SkillType)Mathf.Abs(StringExtensionMethods.GetStableHashCode(skillName)));
				if (skillDef == null)
				{
					return (SkillType)0;
				}
				result = skillDef.m_skill;
			}
			return result;
		}

		public static string LocalizeSkill(this Skill skill)
		{
			if (skill == null || skill.m_info == null)
			{
				return "NULL";
			}
			string text = ((object)(SkillType)(ref skill.m_info.m_skill)).ToString();
			SkillType result;
			return Enum.TryParse<SkillType>(text, out result) ? Localization.instance.Localize("$skill_" + text.ToLower()) : Localization.instance.Localize("$skill_" + Mathf.Abs(StringExtensionMethods.GetStableHashCode(text)));
		}
	}
	internal static class StringExtension
	{
		public static string Localize(this string str)
		{
			return Localization.instance.Localize(str);
		}
	}
	internal static class ZNetSceneExtension
	{
		public static ItemDrop GetItem(this ZNetScene zNetScene, string name)
		{
			GameObject prefab = zNetScene.GetPrefab(name);
			return (prefab != null) ? prefab.GetComponent<ItemDrop>() : null;
		}

		public static ItemDrop GetItem(this ZNetScene zNetScene, int hash)
		{
			GameObject prefab = zNetScene.GetPrefab(hash);
			return (prefab != null) ? prefab.GetComponent<ItemDrop>() : null;
		}
	}
	internal static class ZoneSystemExtension
	{
		internal static List<Vector3> tempPoints = new List<Vector3>();

		public static bool creatingValidPlacesForLocation;

		public static string creatingPlacesFor = "";

		public static void SetGlobalKey(this ZoneSystem zoneSystem, string key, object value)
		{
			zoneSystem.SetGlobalKey($"{key} {value}");
		}

		public static string GetGlobalKeyValue(this ZoneSystem zoneSystem, string key)
		{
			string result = default(string);
			zoneSystem.GetGlobalKey(key, ref result);
			return result;
		}

		public static string GetOrAddGlobalKey(this ZoneSystem zoneSystem, string key, string defaultValue)
		{
			string result = default(string);
			if (zoneSystem.GetGlobalKey(key, ref result))
			{
				return result;
			}
			zoneSystem.SetGlobalKey(key, defaultValue);
			return defaultValue;
		}

		public static (Vector2i, LocationInstance)[] GetGeneratedLocationsByName(this ZoneSystem zoneSystem, string key)
		{
			return (from x in ZoneSystem.instance.m_locationInstances
				where x.Value.m_location.m_prefabName == key
				select (x.Key, x.Value)).ToArray();
		}

		public static List<Vector3> CreateValidPlacesForLocation(this ZoneSystem zoneSystem, string key, int count)
		{
			tempPoints.Clear();
			ZoneLocation location = ZoneSystem.instance.GetLocation(key);
			if (location == null)
			{
				ModBase.DebugWarning("Could not find location with name '" + key + "'");
				return null;
			}
			creatingPlacesFor = location.m_prefabName;
			creatingValidPlacesForLocation = true;
			int quantity = location.m_quantity;
			location.m_quantity = count;
			bool unique = location.m_unique;
			location.m_unique = false;
			ZoneSystem.instance.GenerateLocations(location);
			location.m_quantity = quantity;
			location.m_unique = unique;
			creatingPlacesFor = string.Empty;
			creatingValidPlacesForLocation = false;
			return tempPoints;
		}
	}
}
namespace JFUtils.Valheim.WithPatch
{
	[HarmonyPatch]
	internal static class RegisterObjectsInstances
	{
		internal static List<Pickable> AllPickables { get; } = new List<Pickable>();


		internal static List<Plant> AllPlants { get; } = new List<Plant>();


		internal static List<Door> AllDoors { get; } = new List<Door>();


		internal static List<Sign> AllSigns { get; } = new List<Sign>();


		internal static List<Container> AllContainers { get; private set; } = new List<Container>();


		internal static List<Bed> AllBeds { get; } = new List<Bed>();


		[HarmonyPatch(typeof(Bed), "Awake")]
		[HarmonyPatch(typeof(Container), "Awake")]
		[HarmonyPatch(typeof(Door), "Awake")]
		[HarmonyPatch(typeof(Plant), "Awake")]
		[HarmonyPatch(typeof(Pickable), "Awake")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		[HarmonyPatch(typeof(Sign), "Awake")]
		private static void AddToInstanceCollection(MonoBehaviour __instance)
		{
			__instance.StartCoroutine(enumerator<MonoBehaviour>(__instance));
		}

		private static IEnumerator enumerator<T>(T component) where T : MonoBehaviour
		{
			ZNetView m_nview = ((Object)(object)component).GeZNetView();
			yield return (object)new WaitWhile((Func<bool>)(() => m_nview.m_ghost || !m_nview.IsValid()));
			object obj = component;
			Pickable pickable = (Pickable)((obj is Pickable) ? obj : null);
			if (pickable != null)
			{
				AllPickables.TryAdd(pickable);
				AllPickables.RemoveAll((Pickable item) => (Object)(object)item == (Object)null);
				yield break;
			}
			object obj2 = component;
			Plant plant = (Plant)((obj2 is Plant) ? obj2 : null);
			if (plant != null)
			{
				AllPlants.TryAdd(plant);
				AllPlants.RemoveAll((Plant item) => (Object)(object)item == (Object)null);
				yield break;
			}
			object obj3 = component;
			Door door = (Door)((obj3 is Door) ? obj3 : null);
			if (door != null)
			{
				AllDoors.TryAdd(door);
				AllDoors.RemoveAll((Door item) => (Object)(object)item == (Object)null);
				yield break;
			}
			object obj4 = component;
			Sign sign = (Sign)((obj4 is Sign) ? obj4 : null);
			if (sign != null)
			{
				AllSigns.TryAdd(sign);
				AllSigns.RemoveAll((Sign item) => (Object)(object)item == (Object)null);
				yield break;
			}
			object obj5 = component;
			Container container = (Container)((obj5 is Container) ? obj5 : null);
			if (container != null)
			{
				AllContainers.TryAdd(container);
				AllContainers = AllContainers.Where((Container x) => (Object)(object)x != (Object)null).ToList();
				yield break;
			}
			object obj6 = component;
			Bed bed = (Bed)((obj6 is Bed) ? obj6 : null);
			if (bed != null)
			{
				AllBeds.TryAdd(bed);
				AllBeds.RemoveAll((Bed item) => (Object)(object)item == (Object)null);
			}
		}
	}
	internal static class ObjectsInstances
	{
		public static List<Pickable> allPickables => RegisterObjectsInstances.AllPickables;

		public static List<Plant> allPlants => RegisterObjectsInstances.AllPlants;

		public static List<Door> allDoors => RegisterObjectsInstances.AllDoors;

		public static List<Sign> allSigns => RegisterObjectsInstances.AllSigns;

		public static List<Container> allContainers => RegisterObjectsInstances.AllContainers;

		public static List<CraftingStation> allCraftingStations => CraftingStation.m_allStations;

		public static List<Bed> allBeds => RegisterObjectsInstances.AllBeds;

		static ObjectsInstances()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("Extensions.Valheim.WithPatch.RegisterObjectsInstances").PatchAll(typeof(RegisterObjectsInstances));
			Debug.Log((object)"RegisterObjectsInstances pa