Decompiled source of Seasonality v3.5.6

Seasonality.dll

Decompiled 2 weeks 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.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using Seasonality.Behaviors;
using Seasonality.GameplayModifiers;
using Seasonality.Helpers;
using Seasonality.Managers;
using Seasonality.Textures;
using ServerSync;
using TMPro;
using UnityEngine;
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.Callbacks;
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: Guid("E0E2F92E-557C-4A05-9D89-AA92A0BD75C4")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyProduct("Seasonality")]
[assembly: AssemblyCompany("RustyMods")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("Seasonality")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyFileVersion("3.5.6")]
[assembly: AssemblyConfiguration("")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.5.6.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<98d991af-952a-4035-ae67-076ab71b914b>Embedded]
	internal sealed class <98d991af-952a-4035-ae67-076ab71b914b>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[<98d991af-952a-4035-ae67-076ab71b914b>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class <76e2bcee-7be0-4ded-8938-c3ec54ab3119>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <76e2bcee-7be0-4ded-8938-c3ec54ab3119>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <76e2bcee-7be0-4ded-8938-c3ec54ab3119>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[<98d991af-952a-4035-ae67-076ab71b914b>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class <531fca12-380c-459d-a31a-45e831e60ef3>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <531fca12-380c-459d-a31a-45e831e60ef3>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace Seasonality
{
	[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
	[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(1)]
	[BepInPlugin("RustyMods.Seasonality", "Seasonality", "3.5.6")]
	public class SeasonalityPlugin : BaseUnityPlugin
	{
		internal const string ModName = "Seasonality";

		internal const string ModVersion = "3.5.6";

		internal const string Author = "RustyMods";

		private const string ModGUID = "RustyMods.Seasonality";

		private const string ConfigFileName = "RustyMods.Seasonality.cfg";

		private static readonly string ConfigFileFullPath;

		internal static string ConnectionError;

		private readonly Harmony _harmony = new Harmony("RustyMods.Seasonality");

		private static readonly ManualLogSource SeasonalityLogger;

		public static readonly ConfigSync ConfigSync;

		public static SeasonalityPlugin _plugin;

		private static readonly AssetBundle Assets;

		public static Material FrozenWaterMat;

		public static Configs ConfigManager;

		public static bool BadgerHDLoaded;

		public static readonly Records Record;

		public void Awake()
		{
			ConfigManager = new Configs(((BaseUnityPlugin)this).Config, ConfigSync, "RustyMods.Seasonality.cfg", ConfigFileFullPath);
			_plugin = this;
			FrozenWaterMat = Assets.LoadAsset<Material>("BallSnow04");
			Localizer.Load();
			AssetLoader.Read();
			TextureManager.Read();
			TweaksManager.Setup();
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
			BadgerHDLoaded = Chainloader.PluginInfos.ContainsKey("Badgers.HDValheimTextures");
			if (BadgerHDLoaded)
			{
				Record.LogInfo("HD Valheim Textures loaded");
			}
		}

		public void OnDisable()
		{
			Record.Write();
		}

		public static void OnSeasonChange()
		{
			TextureReplacer.UpdateAll();
			RandomColors.UpdateAll();
			LocationMossController.UpdateAll();
			TerrainController.UpdateTerrain();
			FrozenZones.UpdateAll();
			FrozenWaterLOD.UpdateAll();
			MossController.UpdateAll();
			GlobalKeyManager.UpdateSeasonalKey();
			VisEquipController.UpdateAll();
			SeasonSE.UpdateStatus();
		}

		public void Update()
		{
			float deltaTime = Time.deltaTime;
			SeasonTimer.CheckTransition(deltaTime);
			SeasonSE.CheckOrSet(deltaTime);
			WeatherManager.CheckOrSet(deltaTime);
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}

		private static AssetBundle GetAssetBundle(string fileName)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single([<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (string str) => str.EndsWith(fileName));
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			return AssetBundle.LoadFromStream(stream);
		}

		static SeasonalityPlugin()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFileFullPath = configPath + directorySeparatorChar + "RustyMods.Seasonality.cfg";
			ConnectionError = "";
			SeasonalityLogger = Logger.CreateLogSource("Seasonality");
			ConfigSync = new ConfigSync("RustyMods.Seasonality")
			{
				DisplayName = "Seasonality",
				CurrentVersion = "3.5.6",
				MinimumRequiredVersion = "3.5.6"
			};
			_plugin = null;
			Assets = GetAssetBundle("snowmaterialbundle");
			FrozenWaterMat = null;
			ConfigManager = null;
			Record = new Records(SeasonalityLogger, "Seasonality", "Seasonality-LogOutput.log");
		}
	}
	[HarmonyPatch(typeof(ZNet), "OnNewConnection")]
	public static class RegisterAndCheckVersion
	{
		[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(1)]
		private static void Prefix(ZNetPeer peer, ref ZNet __instance)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			SeasonalityPlugin.Record.LogDebug("Registering version RPC handler");
			peer.m_rpc.Register<ZPackage>("Seasonality_VersionCheck", (Action<ZRpc, ZPackage>)RpcHandlers.RPC_Seasonality_Version);
			SeasonalityPlugin.Record.LogInfo("Invoking version check");
			ZPackage val = new ZPackage();
			val.Write("3.5.6");
			val.Write(RpcHandlers.ComputeHashForMod().Replace("-", ""));
			peer.m_rpc.Invoke("Seasonality_VersionCheck", new object[1] { val });
		}
	}
	[HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")]
	public static class VerifyClient
	{
		[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(1)]
		private static void Postfix(ZNet __instance)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "SeasonalityRequestAdminSync", new object[1] { (object)new ZPackage() });
		}
	}
	[HarmonyPatch(typeof(FejdStartup), "ShowConnectError")]
	public class ShowConnectionError
	{
		[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(1)]
		private static void Postfix(FejdStartup __instance)
		{
			if (__instance.m_connectionFailedPanel.activeSelf)
			{
				__instance.m_connectionFailedError.fontSizeMax = 25f;
				__instance.m_connectionFailedError.fontSizeMin = 15f;
				TMP_Text connectionFailedError = __instance.m_connectionFailedError;
				connectionFailedError.text = connectionFailedError.text + "\n" + SeasonalityPlugin.ConnectionError;
			}
		}
	}
	[HarmonyPatch(typeof(ZNet), "Disconnect")]
	public static class RemoveDisconnectedPeerFromVerified
	{
		[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(1)]
		private static void Prefix(ZNetPeer peer, ref ZNet __instance)
		{
			if (__instance.IsServer())
			{
				SeasonalityPlugin.Record.LogInfo("Peer (" + peer.m_rpc.m_socket.GetHostName() + ") disconnected, removing from validated list");
				RpcHandlers.ValidatedPeers.Remove(peer.m_rpc);
			}
		}
	}
	[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(1)]
	[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
	public static class RpcHandlers
	{
		public static readonly List<ZRpc> ValidatedPeers = new List<ZRpc>();

		public static void RPC_Seasonality_Version(ZRpc rpc, ZPackage pkg)
		{
			string text = pkg.ReadString();
			string text2 = pkg.ReadString();
			string text3 = ComputeHashForMod().Replace("-", "");
			SeasonalityPlugin.Record.LogInfo("Version check, local: 3.5.6,  remote: " + text);
			if (text2 != text3 || text != "3.5.6")
			{
				SeasonalityPlugin.ConnectionError = "Seasonality Installed: 3.5.6 " + text3 + "\n Needed: " + text + " " + text2;
				if (ZNet.instance.IsServer())
				{
					SeasonalityPlugin.Record.LogWarning("Peer (" + rpc.m_socket.GetHostName() + ") has incompatible version");
				}
			}
			else if (!ZNet.instance.IsServer())
			{
				SeasonalityPlugin.Record.LogInfo("Received same version from server!");
				SeasonTimer.ValidServer = true;
			}
			else
			{
				SeasonalityPlugin.Record.LogInfo("Adding peer (" + rpc.m_socket.GetHostName() + ") to validated list");
				ValidatedPeers.Add(rpc);
			}
		}

		public static string ComputeHashForMod()
		{
			using SHA256 sHA = SHA256.Create();
			byte[] array = sHA.ComputeHash(File.ReadAllBytes(Assembly.GetExecutingAssembly().Location));
			StringBuilder stringBuilder = new StringBuilder();
			byte[] array2 = array;
			foreach (byte b in array2)
			{
				stringBuilder.Append(b.ToString("X2"));
			}
			return stringBuilder.ToString();
		}
	}
}
namespace Seasonality.Textures
{
	public static class AssetLoader
	{
		[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(1)]
		private static readonly string ConfigFolder;

		public static void Read()
		{
			string configFolder = ConfigFolder;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			string text = configFolder + directorySeparatorChar + Configs.m_rootTextureFolder.Value + ".bundle";
			if (!File.Exists(text))
			{
				return;
			}
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Stopwatch stopwatch = new Stopwatch();
			stopwatch.Start();
			Texture[] array = val.LoadAllAssets<Texture>();
			foreach (Texture val2 in array)
			{
				if (Utils.ParseName(((Object)val2).name, out var materialName, out var season, out var property))
				{
					TextureManager.m_texturePacks.AddOrSet(materialName, new TextureManager.ImageData(val2, ((Object)val2).name + ".png", materialName, season, property));
				}
			}
			stopwatch.Stop();
			SeasonalityPlugin.Record.LogDebug("Reading textures from bundle took: " + stopwatch.ElapsedMilliseconds + "ms");
		}

		static AssetLoader()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFolder = configPath + directorySeparatorChar + "Seasonality";
		}
	}
	[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(1)]
	[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
	public static class TextureReplacer
	{
		[HarmonyPatch(typeof(FejdStartup), "Awake")]
		[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)]
		private static class FejdStartup_Awake_Patch
		{
			private static void Postfix()
			{
				Setup();
				if (!SeasonalityPlugin.BadgerHDLoaded)
				{
					Stopwatch stopwatch = Stopwatch.StartNew();
					int num = Load();
					stopwatch.Stop();
					SeasonalityPlugin.Record.LogDebug($"[FejdStartup Awake] Generation textures time: {stopwatch.ElapsedMilliseconds}ms");
					SeasonalityPlugin.Record.LogDebug($"[FejdStartup Awake]: Registered {num} new materials");
					SeasonalityPlugin.OnSeasonChange();
				}
			}
		}

		[HarmonyPatch(typeof(ZoneSystem), "SetupLocations")]
		[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)]
		private static class ZoneSystem_SetupLocations_Patch
		{
			private static void Postfix()
			{
				if (SeasonalityPlugin.BadgerHDLoaded)
				{
					return;
				}
				Stopwatch stopwatch = Stopwatch.StartNew();
				int num = Load();
				stopwatch.Stop();
				SeasonalityPlugin.Record.LogDebug($"[ZoneSystem SetupLocations] Generation textures time: {stopwatch.ElapsedMilliseconds}ms");
				SeasonalityPlugin.Record.LogDebug($"[ZoneSystem SetupLocations]: Registered {num} new materials");
				SetupFallMaterials();
				if (Configs.m_fixShader.Value == Configs.Toggle.On)
				{
					FixShaders();
				}
				Configs.m_fixShader.SettingChanged += delegate
				{
					if (Configs.m_fixShader.Value == Configs.Toggle.On)
					{
						FixShaders();
					}
				};
				SeasonalityPlugin.OnSeasonChange();
			}
		}

		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		[HarmonyPriority(0)]
		[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)]
		public static class ZNetScene_Awake_Patch
		{
			[HarmonyAfter(new string[] { "Badgers.HDValheimTextures" })]
			private static void Postfix()
			{
				Stopwatch stopwatch = Stopwatch.StartNew();
				int num = Load();
				stopwatch.Stop();
				SeasonalityPlugin.Record.LogDebug($"[ZNetScene Awake] Generation textures time: {stopwatch.ElapsedMilliseconds}ms");
				SeasonalityPlugin.Record.LogDebug($"[ZNetScene Awake]: Registered {num} new materials");
				SeasonalityPlugin.OnSeasonChange();
			}
		}

		[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
		public class MaterialData
		{
			public string m_name;

			public string m_shaderName;

			public Material m_material;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(2)]
			public Texture m_originalTex;

			public Color32 m_originalColor;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(2)]
			public Texture m_originalMossTex;

			public Dictionary<string, Texture> m_originalTextures = new Dictionary<string, Texture>();

			public Dictionary<Configs.Season, Texture> m_mainTextures = new Dictionary<Configs.Season, Texture>();

			public Dictionary<Configs.Season, Color32> m_mainColors = new Dictionary<Configs.Season, Color32>();

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(new byte[] { 1, 1, 1, 2 })]
			public Dictionary<string, Dictionary<Configs.Season, Texture>> m_specialTextures = new Dictionary<string, Dictionary<Configs.Season, Texture>>();

			public Color32 m_originalMossColor;

			public Color32 m_newMossColor;

			public bool m_updateColors;

			public bool m_updateMoss;

			public bool m_updateMossColor;

			public bool m_isAshlandMaterial;

			public readonly bool m_isValid = true;

			public MaterialData Clone(string name)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Expected O, but got Unknown
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				Material val = new Material(m_material);
				((Object)val).name = name;
				MaterialData materialData = new MaterialData(val);
				materialData.m_mainTextures = new Dictionary<Configs.Season, Texture>(m_mainTextures);
				materialData.m_mainColors = new Dictionary<Configs.Season, Color32>(m_mainColors);
				Dictionary<string, Dictionary<Configs.Season, Texture>> dictionary = new Dictionary<string, Dictionary<Configs.Season, Texture>>();
				foreach (KeyValuePair<string, Dictionary<Configs.Season, Texture>> specialTexture in m_specialTextures)
				{
					dictionary[specialTexture.Key] = new Dictionary<Configs.Season, Texture>(specialTexture.Value);
				}
				materialData.m_specialTextures = dictionary;
				materialData.m_newMossColor = m_newMossColor;
				materialData.m_updateColors = m_updateColors;
				materialData.m_updateMoss = m_updateMoss;
				materialData.m_updateMossColor = m_updateMossColor;
				materialData.m_isAshlandMaterial = m_isAshlandMaterial;
				materialData.m_name = name;
				return materialData;
			}

			public MaterialData(Material material)
			{
				//IL_009a: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
				m_shaderName = ((Object)material.shader).name;
				m_name = ((Object)material).name;
				m_material = material;
				if (m_shaderToIgnore.Contains(m_shaderName))
				{
					m_isValid = false;
					return;
				}
				m_originalTex = material.mainTexture;
				if (material.HasProperty("_Color"))
				{
					m_originalColor = Color32.op_Implicit(material.color);
				}
				CacheOriginalTextures();
				CacheMoss();
			}

			private void CacheMoss()
			{
				if (!m_material.HasProperty(MossTex))
				{
					return;
				}
				m_originalMossTex = m_material.GetTexture(MossTex);
				if (!((Object)(object)m_originalMossTex == (Object)null))
				{
					m_updateMoss = true;
					if (((Object)m_originalMossTex).name == "Ash_d")
					{
						m_isAshlandMaterial = true;
					}
				}
			}

			private void CacheOriginalTextures()
			{
				string[] texturePropertyNames = m_material.GetTexturePropertyNames();
				foreach (string text in texturePropertyNames)
				{
					Texture texture = m_material.GetTexture(text);
					if (texture != null)
					{
						m_originalTextures[text] = texture;
					}
				}
			}

			public void ApplySpecialCases()
			{
				if (m_cases.TryGetValue(m_name, out var value))
				{
					value.Run(this);
				}
			}

			[return: <76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(2)]
			private static Texture Create(Texture2D original, TextureManager.ImageData data)
			{
				//IL_0026: 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_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: 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_0087: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_0095: Expected O, but got Unknown
				if (data.m_isTex)
				{
					return data.m_texture;
				}
				try
				{
					Texture2D val = new Texture2D(((Texture)original).width, ((Texture)original).height, original.format, ((Texture)original).mipmapCount > 1)
					{
						anisoLevel = ((Texture)original).anisoLevel,
						filterMode = ((Texture)original).filterMode,
						mipMapBias = ((Texture)original).mipMapBias,
						wrapMode = ((Texture)original).wrapMode,
						wrapModeU = ((Texture)original).wrapModeU,
						wrapModeV = ((Texture)original).wrapModeV,
						wrapModeW = ((Texture)original).wrapModeW
					};
					if (!ImageConversion.LoadImage(val, data.m_bytes))
					{
						return null;
					}
					val.Apply();
					((Object)val).name = data.m_fileName;
					return (Texture)(object)val;
				}
				catch
				{
					SeasonalityPlugin.Record.LogError("Failed to generate texture for: " + data.m_fileName);
					return null;
				}
			}

			public MaterialData(Material material, TextureManager.TexturePack package)
				: this(material)
			{
				foreach (TextureManager.ImageData value2 in package.m_textures.Values)
				{
					if (!Utility.IsNullOrWhiteSpace(value2.m_property))
					{
						if (!m_originalTextures.TryGetValue(value2.m_property, out var value))
						{
							SeasonalityPlugin.Record.LogDebug("Failed to find original texture [" + value2.m_property + "]: " + value2.m_fileName);
							m_isValid = false;
							continue;
						}
						Texture2D val = (Texture2D)(object)((value is Texture2D) ? value : null);
						if (val == null)
						{
							SeasonalityPlugin.Record.LogDebug("Failed to convert " + value2.m_property + " textures to 2D: " + ((Object)material).name);
							m_isValid = false;
							continue;
						}
						Texture val2 = Create(val, value2);
						if (val2 == null)
						{
							SeasonalityPlugin.Record.LogDebug("Failed to create new texture: " + value2.m_fileName);
							m_isValid = false;
						}
						else
						{
							m_specialTextures.AddOrSet(value2.m_property, value2.m_season, val2);
						}
						continue;
					}
					if (!((Object)(object)m_originalTex == (Object)null))
					{
						Texture originalTex = m_originalTex;
						Texture2D val3 = (Texture2D)(object)((originalTex is Texture2D) ? originalTex : null);
						if (val3 != null)
						{
							Texture val4 = Create(val3, value2);
							if (val4 == null)
							{
								SeasonalityPlugin.Record.LogDebug("Failed to create new texture: " + value2.m_fileName);
								m_isValid = false;
							}
							else if (m_mainTextures.ContainsKey(value2.m_season))
							{
								SeasonalityPlugin.Record.LogDebug("Duplicate season, skipping: " + value2.m_fileName);
								m_isValid = false;
							}
							else
							{
								m_mainTextures[value2.m_season] = val4;
							}
							continue;
						}
					}
					SeasonalityPlugin.Record.LogDebug("Failed to convert original texture to 2D: " + ((Object)material).name);
					m_isValid = false;
				}
			}

			public void Update()
			{
				if (!((Object)(object)m_material == (Object)null))
				{
					UpdateMainTex();
					UpdateMoss();
					UpdateTexProperties();
					UpdateColors();
				}
			}

			private void UpdateMainTex()
			{
				if (m_mainTextures.Count > 0)
				{
					m_material.mainTexture = (m_mainTextures.TryGetValue(Configs.m_season.Value, out var value) ? value : m_originalTex);
				}
			}

			private void UpdateTexProperties()
			{
				if (m_specialTextures.Count <= 0)
				{
					return;
				}
				foreach (KeyValuePair<string, Dictionary<Configs.Season, Texture>> specialTexture in m_specialTextures)
				{
					if (m_material.HasProperty(specialTexture.Key))
					{
						Texture value2;
						if (specialTexture.Value.TryGetValue(Configs.m_season.Value, out var value))
						{
							m_material.SetTexture(specialTexture.Key, value);
						}
						else if (m_originalTextures.TryGetValue(specialTexture.Key, out value2))
						{
							m_material.SetTexture(specialTexture.Key, value2);
						}
					}
				}
			}

			public void UpdateColors()
			{
				//IL_004c: 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_004d: Unknown result type (might be due to invalid IL or missing references)
				if (m_updateColors && m_material.HasProperty("_Color"))
				{
					m_material.color = Color32.op_Implicit(m_mainColors.TryGetValue(Configs.m_season.Value, out var value) ? value : m_originalColor);
				}
			}

			private void UpdateMoss()
			{
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				if (!m_updateMoss || m_isAshlandMaterial)
				{
					return;
				}
				switch (Configs.m_season.Value)
				{
				case Configs.Season.Fall:
					m_material.SetTexture(MossTex, TextureManager.Stonemoss_heath.m_tex);
					break;
				case Configs.Season.Winter:
					m_material.SetTexture(MossTex, TextureManager.AshOnRocks_d.m_tex);
					break;
				default:
					if ((Object)(object)m_originalMossTex == (Object)null)
					{
						return;
					}
					m_material.SetTexture(MossTex, m_originalMossTex);
					break;
				}
				if (m_updateMossColor)
				{
					Configs.Season value = Configs.m_season.Value;
					Configs.Season season = value;
					if ((uint)(season - 1) <= 1u)
					{
						m_material.SetColor(MossColor, Color32.op_Implicit(m_newMossColor));
					}
					else
					{
						m_material.SetColor(MossColor, Color32.op_Implicit(m_originalMossColor));
					}
				}
			}
		}

		[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
		private class SpecialCase
		{
			private readonly Func<MaterialData, bool> m_action;

			private bool m_added;

			public SpecialCase(string materialName, Func<MaterialData, bool> action)
			{
				m_action = action;
				m_cases[materialName] = this;
			}

			public void Run(MaterialData data)
			{
				if (!m_added && m_action(data))
				{
					m_added = true;
				}
			}
		}

		private static readonly int MossTex = Shader.PropertyToID("_MossTex");

		private static readonly int MossColor = Shader.PropertyToID("_MossColor");

		private static readonly List<string> m_shaderToIgnore = new List<string>
		{
			"Hidden/BlitCopy", "Hidden/Interal - Flare", "Hidden/Internal-DeferredReflections", "UI/Default", "Sprites/Mask", "Hidden/InternalErroShader", "Sprites/Default", "TextMeshPro/Distance Field", "GUI/Text Shader", "TextMeshPro/Sprite",
			"Custom/GuiScroll", "UI/Heat Distort"
		};

		private static int m_referenceCount;

		public static readonly Dictionary<string, Material> m_allMaterials = new Dictionary<string, Material>();

		public static readonly Dictionary<string, MaterialData> m_materials = new Dictionary<string, MaterialData>();

		public static readonly Dictionary<string, Texture> m_mossTextures = new Dictionary<string, Texture>();

		private static readonly Dictionary<string, SpecialCase> m_cases = new Dictionary<string, SpecialCase>();

		public static readonly Dictionary<string, List<MaterialData>> m_fallMaterials = new Dictionary<string, List<MaterialData>>();

		public static readonly Dictionary<Material, MaterialData> m_mats = new Dictionary<Material, MaterialData>();

		[Description("Setup special cases")]
		private static void Setup()
		{
			SpecialCase specialCase = new SpecialCase("grasscross_mistlands_short", delegate(MaterialData material)
			{
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				foreach (KeyValuePair<Configs.Season, Texture> mainTexture in material.m_mainTextures)
				{
					material.m_mainColors[mainTexture.Key] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
					material.m_updateColors = true;
					material.m_specialTextures.AddOrSetNull("_TerrainColorTex", mainTexture.Key);
				}
				return true;
			});
			SpecialCase specialCase2 = new SpecialCase("grasscross_meadows", delegate(MaterialData material)
			{
				foreach (KeyValuePair<Configs.Season, Texture> mainTexture2 in material.m_mainTextures)
				{
					material.m_specialTextures.AddOrSetNull("_TerrainColorTex", mainTexture2.Key);
				}
				return true;
			});
			SpecialCase specialCase3 = new SpecialCase("grasscross_meadows_short", delegate(MaterialData material)
			{
				foreach (KeyValuePair<Configs.Season, Texture> mainTexture3 in material.m_mainTextures)
				{
					material.m_specialTextures.AddOrSetNull("_TerrainColorTex", mainTexture3.Key);
				}
				return true;
			});
			SpecialCase specialCase4 = new SpecialCase("helmet_trollleather", delegate(MaterialData material)
			{
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				foreach (KeyValuePair<Configs.Season, Texture> mainTexture4 in material.m_mainTextures)
				{
					material.m_mainColors[mainTexture4.Key] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
					material.m_updateColors = true;
				}
				return true;
			});
			SpecialCase specialCase5 = new SpecialCase("rock_mistlands", delegate(MaterialData material)
			{
				//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_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				material.m_originalMossColor = new Color32((byte)202, byte.MaxValue, (byte)121, byte.MaxValue);
				material.m_newMossColor = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
				material.m_updateMossColor = true;
				return true;
			});
			SpecialCase specialCase6 = new SpecialCase("mistlands_cliff", delegate(MaterialData material)
			{
				//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_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				material.m_originalMossColor = new Color32((byte)202, byte.MaxValue, (byte)121, byte.MaxValue);
				material.m_newMossColor = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
				material.m_updateMossColor = true;
				return true;
			});
			SpecialCase specialCase7 = new SpecialCase("mistlands_cliff_internal", delegate(MaterialData material)
			{
				//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_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				material.m_originalMossColor = new Color32((byte)202, byte.MaxValue, (byte)121, byte.MaxValue);
				material.m_newMossColor = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
				material.m_updateMossColor = true;
				return true;
			});
			SpecialCase specialCase8 = new SpecialCase("GiantRustSword_mat", delegate(MaterialData material)
			{
				//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_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				material.m_originalMossColor = new Color32((byte)202, byte.MaxValue, (byte)121, byte.MaxValue);
				material.m_newMossColor = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
				material.m_updateMossColor = true;
				return true;
			});
			SpecialCase specialCase9 = new SpecialCase("GiantRustHelm_mat", delegate(MaterialData material)
			{
				//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_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				material.m_originalMossColor = new Color32((byte)202, byte.MaxValue, (byte)121, byte.MaxValue);
				material.m_newMossColor = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
				material.m_updateMossColor = true;
				return true;
			});
			SpecialCase specialCase10 = new SpecialCase("GiantRust_particle", delegate(MaterialData material)
			{
				//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_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				material.m_originalMossColor = new Color32((byte)202, byte.MaxValue, (byte)121, byte.MaxValue);
				material.m_newMossColor = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
				material.m_updateMossColor = true;
				return true;
			});
			SpecialCase specialCase11 = new SpecialCase("giant_skeleton_exterior", delegate(MaterialData material)
			{
				//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_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				material.m_originalMossColor = new Color32((byte)202, byte.MaxValue, (byte)121, byte.MaxValue);
				material.m_newMossColor = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
				material.m_updateMossColor = true;
				return true;
			});
			SpecialCase specialCase12 = new SpecialCase("yggdrasil_root", delegate(MaterialData material)
			{
				//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_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				material.m_originalMossColor = new Color32((byte)202, byte.MaxValue, (byte)121, byte.MaxValue);
				material.m_newMossColor = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
				material.m_updateMossColor = true;
				return true;
			});
			SpecialCase specialCase13 = new SpecialCase("CapeTrollHide", delegate(MaterialData material)
			{
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				foreach (KeyValuePair<Configs.Season, Texture> mainTexture5 in material.m_mainTextures)
				{
					material.m_mainColors[mainTexture5.Key] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
					material.m_updateColors = true;
				}
				return true;
			});
			SpecialCase specialCase14 = new SpecialCase("clutter_shrub", delegate(MaterialData material)
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				material.m_mainColors[Configs.Season.Fall] = Color32.op_Implicit(Configs.m_fallColor1.Value);
				Configs.m_fallColor1.SettingChanged += [<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (object _, EventArgs _) =>
				{
					//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)
					material.m_mainColors[Configs.Season.Fall] = Color32.op_Implicit(Configs.m_fallColor1.Value);
					material.UpdateColors();
				};
				material.m_updateColors = true;
				return true;
			});
			SpecialCase specialCase15 = new SpecialCase("ormbunke", delegate(MaterialData material)
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				material.m_mainColors[Configs.Season.Fall] = Color32.op_Implicit(Configs.m_fallColor1.Value);
				Configs.m_fallColor1.SettingChanged += [<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (object _, EventArgs _) =>
				{
					//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)
					material.m_mainColors[Configs.Season.Fall] = Color32.op_Implicit(Configs.m_fallColor1.Value);
					material.UpdateColors();
				};
				material.m_updateColors = true;
				return true;
			});
			SpecialCase specialCase16 = new SpecialCase("ormbunke_yellow", delegate(MaterialData material)
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				material.m_mainColors[Configs.Season.Fall] = Color32.op_Implicit(Configs.m_fallColor1.Value);
				Configs.m_fallColor1.SettingChanged += [<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (object _, EventArgs _) =>
				{
					//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)
					material.m_mainColors[Configs.Season.Fall] = Color32.op_Implicit(Configs.m_fallColor1.Value);
					material.UpdateColors();
				};
				material.m_updateColors = true;
				return true;
			});
		}

		[Description("Using registered materials, clone fall variants")]
		private static void SetupFallMaterials()
		{
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			List<ConfigEntry<Color>> colorConfigs = new List<ConfigEntry<Color>>
			{
				Configs.m_fallColor1,
				Configs.m_fallColor2,
				Configs.m_fallColor3,
				Configs.m_fallColor4
			};
			foreach (string name3 in new Configs.SerializedNameList(Configs.m_fallMaterials.Value).m_names)
			{
				if (!m_materials.TryGetValue(name3, out var value))
				{
					continue;
				}
				List<MaterialData> list = new List<MaterialData>();
				for (int i = 0; i < colorConfigs.Count; i++)
				{
					ConfigEntry<Color> color = colorConfigs[i];
					string name = $"{value.m_name}_{i}";
					MaterialData clone = value.Clone(name);
					clone.m_mainColors[Configs.Season.Fall] = Color32.op_Implicit(color.Value);
					color.SettingChanged += [<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (object _, EventArgs _) =>
					{
						//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)
						clone.m_mainColors[Configs.Season.Fall] = Color32.op_Implicit(color.Value);
						clone.UpdateColors();
					};
					clone.m_updateColors = true;
					list.Add(clone);
				}
				m_fallMaterials[value.m_name] = list;
			}
			Configs.m_fallMaterials.SettingChanged += [<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (object _, EventArgs _) =>
			{
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				m_fallMaterials.Clear();
				foreach (string name4 in new Configs.SerializedNameList(Configs.m_fallMaterials.Value).m_names)
				{
					if (m_materials.TryGetValue(name4, out var value2))
					{
						List<MaterialData> list2 = new List<MaterialData>();
						for (int j = 0; j < colorConfigs.Count; j++)
						{
							ConfigEntry<Color> color2 = colorConfigs[j];
							string name2 = $"{value2.m_name}_{j}";
							MaterialData clone2 = value2.Clone(name2);
							clone2.m_mainColors[Configs.Season.Fall] = Color32.op_Implicit(color2.Value);
							color2.SettingChanged += [<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (object _, EventArgs _) =>
							{
								//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)
								clone2.m_mainColors[Configs.Season.Fall] = Color32.op_Implicit(color2.Value);
								clone2.UpdateColors();
							};
							clone2.m_updateColors = true;
							list2.Add(clone2);
						}
						m_fallMaterials[value2.m_name] = list2;
					}
				}
			};
		}

		public static void UpdateAll()
		{
			foreach (MaterialData value in m_mats.Values)
			{
				value.Update();
			}
			foreach (KeyValuePair<string, List<MaterialData>> fallMaterial in m_fallMaterials)
			{
				foreach (MaterialData item in fallMaterial.Value)
				{
					item.Update();
				}
			}
		}

		[Description("Find all materials in resources, and register")]
		private static int Load(bool clear = false)
		{
			if (clear)
			{
				m_materials.Clear();
				m_allMaterials.Clear();
				m_mossTextures.Clear();
				m_fallMaterials.Clear();
				m_mats.Clear();
			}
			m_referenceCount = m_mats.Count;
			Material[] array = Resources.FindObjectsOfTypeAll<Material>();
			foreach (Material val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				if (!m_allMaterials.ContainsKey(((Object)val).name))
				{
					m_allMaterials[((Object)val).name] = val;
				}
				if (m_mats.ContainsKey(val) || !val.HasProperty("_MainTex"))
				{
					continue;
				}
				string text = ((Object)val).name;
				if (text == "oak_leaf_nosnow")
				{
					text = "oak_leaf";
				}
				if (TextureManager.m_texturePacks.TryGetValue(text, out var value))
				{
					MaterialData materialData = new MaterialData(val, value);
					materialData.ApplySpecialCases();
					if (materialData.m_isValid)
					{
						m_materials[((Object)val).name] = materialData;
						m_mats[val] = materialData;
						SeasonalityPlugin.Record.LogSuccess("Registered textures to: " + materialData.m_name);
					}
				}
				else
				{
					if (!val.HasProperty(MossTex))
					{
						continue;
					}
					MaterialData materialData2 = new MaterialData(val);
					materialData2.ApplySpecialCases();
					if (materialData2.m_isValid)
					{
						m_mats[val] = materialData2;
						m_materials[((Object)val).name] = materialData2;
						SeasonalityPlugin.Record.LogSuccess("Registered moss material: " + materialData2.m_name);
						if (!((Object)(object)materialData2.m_originalMossTex == (Object)null) && m_mossTextures.ContainsKey(((Object)materialData2.m_originalMossTex).name))
						{
							m_mossTextures[((Object)materialData2.m_originalMossTex).name] = materialData2.m_originalMossTex;
						}
					}
				}
			}
			return m_mats.Count - m_referenceCount;
		}

		public static void FixShaders()
		{
			foreach (KeyValuePair<string, MaterialData> material in m_materials)
			{
				if (!((Object)(object)material.Value.m_material == (Object)null))
				{
					material.Value.m_material.shader = ShaderFix.GetShader(((Object)material.Value.m_material.shader).name, material.Value.m_material.shader);
				}
			}
			foreach (KeyValuePair<string, List<MaterialData>> fallMaterial in m_fallMaterials)
			{
				foreach (MaterialData item in fallMaterial.Value)
				{
					if (!((Object)(object)item.m_material == (Object)null))
					{
						item.m_material.shader = ShaderFix.GetShader(((Object)item.m_material.shader).name, item.m_material.shader);
					}
				}
			}
		}
	}
	[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
	[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(2)]
	public static class SpriteManager
	{
		public static readonly Sprite ValknutIcon = RegisterSprite("valknutIcon.png");

		public static readonly Sprite SpringIcon = RegisterSprite("spring_icon.png");

		public static readonly Sprite SummerIcon = RegisterSprite("summer_icon.png");

		public static readonly Sprite FallIcon = RegisterSprite("fall_icon.png");

		public static readonly Sprite WinterIcon = RegisterSprite("winter_icon.png");

		[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(1)]
		[return: <76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(2)]
		private static Sprite RegisterSprite(string fileName, string folderName = "icons")
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = "Seasonality." + folderName + "." + fileName;
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			if (stream == null)
			{
				return null;
			}
			byte[] array = new byte[stream.Length];
			int num = stream.Read(array, 0, array.Length);
			Texture2D val = new Texture2D(2, 2);
			Sprite val2 = (ImageConversion.LoadImage(val, array) ? Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero) : null);
			if ((Object)(object)val2 != (Object)null)
			{
				((Object)val2).name = fileName;
			}
			return val2;
		}
	}
	[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
	[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(1)]
	public static class TextureManager
	{
		[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
		public class TextureRef
		{
			private static readonly Texture m_emptyTex = (Texture)new Texture2D(4, 4);

			private readonly string m_name;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(2)]
			private Texture tex;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(2)]
			public Texture m_tex
			{
				[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(2)]
				get
				{
					if ((Object)(object)tex != (Object)null)
					{
						return tex;
					}
					if (GetAllTextures().TryGetValue(m_name, out var value))
					{
						tex = value;
						return tex;
					}
					SeasonalityPlugin.Record.LogWarning("Failed to find reference texture: " + m_name);
					return m_emptyTex;
				}
			}

			public TextureRef(string textureName)
			{
				m_name = textureName;
			}
		}

		[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
		public class TexturePack
		{
			public readonly string m_materialName;

			public readonly Dictionary<string, ImageData> m_textures = new Dictionary<string, ImageData>();

			public TexturePack(ImageData imageData)
			{
				m_materialName = imageData.m_materialName;
				m_textures[imageData.m_fileName] = imageData;
				m_texturePacks[m_materialName] = this;
			}

			public void Add(ImageData imageData)
			{
				m_textures[imageData.m_fileName] = imageData;
			}
		}

		[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
		public class ImageData
		{
			public readonly string m_fileName;

			public readonly string m_materialName = "";

			public readonly string m_property = "";

			public readonly byte[] m_bytes = null;

			public readonly Texture m_texture = null;

			public readonly Configs.Season m_season;

			public readonly bool m_isValid = true;

			public readonly bool m_isTex = false;

			public ImageData(Texture texture, string fileName, string materialName, Configs.Season season, string property)
			{
				m_texture = texture;
				m_fileName = fileName;
				m_materialName = materialName;
				m_season = season;
				m_property = property;
				m_isTex = true;
			}

			public ImageData(string filePath)
			{
				if (!Utils.ParseName((m_fileName = Path.GetFileName(filePath)).Replace(".png", string.Empty), out var materialName, out var season, out var property))
				{
					m_isValid = false;
					return;
				}
				m_property = property;
				m_season = season;
				m_materialName = materialName;
				m_bytes = File.ReadAllBytes(filePath);
			}
		}

		private static readonly string ConfigFolder;

		public static readonly TextureRef Stonemoss_heath;

		public static readonly TextureRef AshOnRocks_d;

		public static readonly TextureRef stonemoss;

		public static readonly TextureRef stonekit_moss;

		public static readonly TextureRef FinalPortal_moss;

		public static readonly TextureRef stonemoss_swamp;

		public static readonly TextureRef dead_moss;

		public static readonly TextureRef stonekit_moss_hildir;

		public static readonly TextureRef stonemoss_bw;

		public static readonly TextureRef groundcreep_d;

		private static readonly Dictionary<string, Texture> m_cachedTextures;

		public static readonly Dictionary<string, TexturePack> m_texturePacks;

		public static Dictionary<string, Texture> GetAllTextures(bool clear = false)
		{
			if (clear)
			{
				m_cachedTextures.Clear();
			}
			if (m_cachedTextures.Count > 0)
			{
				return m_cachedTextures;
			}
			Texture[] array = Resources.FindObjectsOfTypeAll<Texture>();
			foreach (Texture val in array)
			{
				if (!m_cachedTextures.ContainsKey(((Object)val).name))
				{
					m_cachedTextures[((Object)val).name] = val;
				}
			}
			return m_cachedTextures;
		}

		public static void Read()
		{
			Stopwatch stopwatch = Stopwatch.StartNew();
			string configFolder = ConfigFolder;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			string path = configFolder + directorySeparatorChar + Configs.m_rootTextureFolder.Value;
			if (!Directory.Exists(path))
			{
				return;
			}
			string[] files = Directory.GetFiles(path, "*.png", SearchOption.AllDirectories);
			if (files.Length == 0)
			{
				return;
			}
			string[] array = files;
			foreach (string filePath in array)
			{
				ImageData imageData = new ImageData(filePath);
				if (imageData.m_isValid)
				{
					m_texturePacks.AddOrSet(imageData.m_materialName, imageData);
					SeasonalityPlugin.Record.LogSuccess("Registered: " + imageData.m_fileName);
				}
			}
			stopwatch.Stop();
			SeasonalityPlugin.Record.LogDebug($"Reading textures took: {stopwatch.ElapsedMilliseconds}ms");
		}

		[return: <76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(2)]
		private static Texture RegisterTexture(string fileName, string folderName = "assets")
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = "Seasonality." + folderName + "." + fileName;
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			if (stream == null)
			{
				return null;
			}
			byte[] array = new byte[stream.Length];
			int num = stream.Read(array, 0, array.Length);
			Texture2D val = new Texture2D(2, 2);
			((Object)val).name = fileName.Replace(".png", string.Empty);
			return (Texture)(object)(ImageConversion.LoadImage(val, array) ? val : null);
		}

		static TextureManager()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFolder = configPath + directorySeparatorChar + "Seasonality";
			Stonemoss_heath = new TextureRef("stonemoss_heath");
			AshOnRocks_d = new TextureRef("AshOnRocks_d");
			stonemoss = new TextureRef("stonemoss");
			stonekit_moss = new TextureRef("stonekit_moss");
			FinalPortal_moss = new TextureRef("FinalPortal_moss");
			stonemoss_swamp = new TextureRef("stonemoss_swamp");
			dead_moss = new TextureRef("dead_moss");
			stonekit_moss_hildir = new TextureRef("stonekit_moss_hildir");
			stonemoss_bw = new TextureRef("stonemoss_bw");
			groundcreep_d = new TextureRef("groundcreep_d");
			m_cachedTextures = new Dictionary<string, Texture>();
			m_texturePacks = new Dictionary<string, TexturePack>();
		}
	}
}
namespace Seasonality.Managers
{
	[PublicAPI]
	[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
	[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(1)]
	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;

		[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>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([<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
				}
				return _plugin;
			}
		}

		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, [<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (string current, KeyValuePair<string, Func<string>> kv) => current.Replace("{" + kv.Key + "}", kv.Value()));
			}
			localization.AddWord(key, text);
		}

		public static void AddPlaceholder<T>(string key, string placeholder, ConfigEntry<T> config, [<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null)
		{
			if (convertConfigValue == null)
			{
				convertConfigValue = [<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] [return: <76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(1)] (T val) => val.ToString();
			}
			if (!PlaceholderProcessors.ContainsKey(key))
			{
				PlaceholderProcessors[key] = new Dictionary<string, Func<string>>();
			}
			config.SettingChanged += [<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (object _, EventArgs _) =>
			{
				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);
			}
		}

		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);
		}

		[return: <76e2bcee-7be0-4ded-8938-c3ec54ab3119>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;
		}

		[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(2)]
		public static byte[] ReadEmbeddedFileBytes([<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(1)] string resourceFileName, Assembly containingAssembly = null)
		{
			using MemoryStream memoryStream = new MemoryStream();
			if ((object)containingAssembly == null)
			{
				containingAssembly = Assembly.GetCallingAssembly();
			}
			string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal));
			if (text != null)
			{
				containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream);
			}
			return (memoryStream.Length == 0L) ? null : memoryStream.ToArray();
		}
	}
}
namespace Seasonality.Helpers
{
	[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(1)]
	[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
	public class Configs
	{
		[HarmonyPatch(typeof(FejdStartup), "Awake")]
		[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)]
		private static class FejdStartup_Awake_Patch
		{
			private static void Postfix()
			{
				Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager");
				configManager = ((type == null) ? null : Chainloader.ManagerObject.GetComponent(type));
			}
		}

		[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
		public class SerializedNameList
		{
			public readonly List<string> m_names;

			public SerializedNameList(List<string> prefabs)
			{
				m_names = prefabs;
			}

			public SerializedNameList(params string[] prefabs)
			{
				m_names = prefabs.ToList();
			}

			public SerializedNameList(string config)
			{
				m_names = config.Split(new char[1] { ',' }).ToList();
			}

			public override string ToString()
			{
				return string.Join(",", m_names);
			}

			public static void Draw(ConfigEntryBase cfg)
			{
				//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_0103: Expected O, but got Unknown
				//IL_0132: Unknown result type (might be due to invalid IL or missing references)
				//IL_0137: Unknown result type (might be due to invalid IL or missing references)
				//IL_014d: Expected O, but got Unknown
				bool valueOrDefault = cfg.Description.Tags.Select([<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : null).FirstOrDefault((bool? v) => v.HasValue).GetValueOrDefault();
				bool flag = false;
				List<string> list = new List<string>();
				GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
				foreach (string name in new SerializedNameList((string)cfg.BoxedValue).m_names)
				{
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					string item = name;
					string text = GUILayout.TextField(name, Array.Empty<GUILayoutOption>());
					if (text != name && !valueOrDefault)
					{
						flag = true;
						item = text;
					}
					if (GUILayout.Button("x", new GUIStyle(GUI.skin.button)
					{
						fixedWidth = 21f
					}, Array.Empty<GUILayoutOption>()) && !valueOrDefault)
					{
						flag = true;
					}
					else
					{
						list.Add(item);
					}
					if (GUILayout.Button("+", new GUIStyle(GUI.skin.button)
					{
						fixedWidth = 21f
					}, Array.Empty<GUILayoutOption>()) && !valueOrDefault)
					{
						list.Add("");
						flag = true;
					}
					GUILayout.EndHorizontal();
				}
				GUILayout.EndVertical();
				if (flag)
				{
					cfg.BoxedValue = new SerializedNameList(list).ToString();
				}
			}
		}

		[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
		public class StatusEffectConfig
		{
			public readonly string m_name;

			public readonly string m_description;

			public readonly float m_value;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
			public KeyValuePair<float, float> m_range;

			public StatusEffectConfig(string name, string description, float value, float min, float max)
			{
				m_name = name;
				m_description = description;
				m_value = value;
				m_range = new KeyValuePair<float, float>(min, max);
			}

			public static void Draw(ConfigEntryBase cfg)
			{
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Expected O, but got Unknown
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e1: Expected O, but got Unknown
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Expected O, but got Unknown
				//IL_0128: Unknown result type (might be due to invalid IL or missing references)
				//IL_012d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0143: Expected O, but got Unknown
				//IL_015f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0164: Unknown result type (might be due to invalid IL or missing references)
				//IL_017a: Expected O, but got Unknown
				//IL_018b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0190: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a6: Expected O, but got Unknown
				//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_020d: Unknown result type (might be due to invalid IL or missing references)
				bool valueOrDefault = cfg.Description.Tags.Select([<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : null).FirstOrDefault((bool? v) => v.HasValue).GetValueOrDefault();
				Vector3 val = (Vector3)cfg.BoxedValue;
				GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				string s = GUILayout.TextField(val.x.ToString("0"), new GUIStyle(GUI.skin.textField)
				{
					fixedWidth = 50f
				}, Array.Empty<GUILayoutOption>());
				GUILayout.Label("Days", new GUIStyle(GUI.skin.label)
				{
					fixedWidth = 50f
				}, Array.Empty<GUILayoutOption>());
				string s2 = GUILayout.TextField(val.y.ToString("0"), new GUIStyle(GUI.skin.textField)
				{
					fixedWidth = 50f
				}, Array.Empty<GUILayoutOption>());
				GUILayout.Label("Hours", new GUIStyle(GUI.skin.label)
				{
					fixedWidth = 50f
				}, Array.Empty<GUILayoutOption>());
				string s3 = GUILayout.TextField(val.z.ToString("0"), new GUIStyle(GUI.skin.textField)
				{
					fixedWidth = 50f
				}, Array.Empty<GUILayoutOption>());
				GUILayout.Label("Minutes", new GUIStyle(GUI.skin.label)
				{
					fixedWidth = 50f
				}, Array.Empty<GUILayoutOption>());
				GUILayout.EndHorizontal();
				GUILayout.EndVertical();
				if (!valueOrDefault)
				{
					Vector3 val2 = default(Vector3);
					((Vector3)(ref val2))..ctor(float.TryParse(s, out var result) ? result : 0f, float.TryParse(s2, out var result2) ? result2 : 0f, float.TryParse(s3, out var result3) ? result3 : 0f);
					if (val2 != val)
					{
						cfg.BoxedValue = val2;
					}
				}
			}
		}

		[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
		public class SerializedWeather
		{
			[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)]
			public struct WeatherData
			{
				[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(1)]
				public string name;

				public float weight;
			}

			public readonly List<WeatherData> environments;

			public SerializedWeather()
			{
				environments = new List<WeatherData>();
			}

			public SerializedWeather(List<WeatherData> weathers)
			{
				environments = weathers;
			}

			public SerializedWeather(string weathers)
			{
				environments = weathers.Split(new char[1] { ',' }).Select([<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (string input) =>
				{
					string[] array = input.Split(new char[1] { ':' });
					WeatherData result = default(WeatherData);
					result.name = array[0];
					result.weight = ((array.Length > 1 && float.TryParse(array[1], out var result2)) ? result2 : 1f);
					return result;
				}).ToList();
			}

			public void Add(string env, float weight)
			{
				environments.Add(new WeatherData
				{
					name = env,
					weight = weight
				});
			}

			public override string ToString()
			{
				return string.Join(",", environments.Select([<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (WeatherData e) => $"{e.name}:{e.weight}"));
			}

			public static void Draw(ConfigEntryBase cfg)
			{
				//IL_011e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0123: Unknown result type (might be due to invalid IL or missing references)
				//IL_0137: Expected O, but got Unknown
				//IL_0174: Unknown result type (might be due to invalid IL or missing references)
				//IL_0179: Unknown result type (might be due to invalid IL or missing references)
				//IL_018f: Expected O, but got Unknown
				//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e8: Expected O, but got Unknown
				//IL_0231: Unknown result type (might be due to invalid IL or missing references)
				//IL_0236: Unknown result type (might be due to invalid IL or missing references)
				//IL_024c: Expected O, but got Unknown
				bool valueOrDefault = cfg.Description.Tags.Select([<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : null).FirstOrDefault((bool? v) => v.HasValue).GetValueOrDefault();
				List<WeatherData> list = new List<WeatherData>();
				bool flag = false;
				int num = (int)(configManager?.GetType().GetProperty("RightColumnWidth", BindingFlags.Instance | BindingFlags.NonPublic).GetGetMethod(nonPublic: true)
					.Invoke(configManager, Array.Empty<object>()) ?? ((object)130));
				GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
				foreach (WeatherData environment in new SerializedWeather((string)cfg.BoxedValue).environments)
				{
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					float num2 = environment.weight;
					int num3 = Mathf.Max(num - 40 - 21 - 21, 180);
					string text = GUILayout.TextField(environment.name, new GUIStyle(GUI.skin.textField)
					{
						fixedWidth = num3
					}, Array.Empty<GUILayoutOption>());
					string text2 = (valueOrDefault ? environment.name : text);
					flag = flag || text2 != environment.name;
					if (float.TryParse(GUILayout.TextField(num2.ToString(CultureInfo.InvariantCulture), new GUIStyle(GUI.skin.textField)
					{
						fixedWidth = 40f
					}, Array.Empty<GUILayoutOption>()), out var result) && Math.Abs(result - num2) > 0.01f && !valueOrDefault)
					{
						num2 = result;
						flag = true;
					}
					if (GUILayout.Button("x", new GUIStyle(GUI.skin.button)
					{
						fixedWidth = 21f
					}, Array.Empty<GUILayoutOption>()) && !valueOrDefault)
					{
						flag = true;
					}
					else
					{
						list.Add(new WeatherData
						{
							name = text2,
							weight = num2
						});
					}
					if (GUILayout.Button("+", new GUIStyle(GUI.skin.button)
					{
						fixedWidth = 21f
					}, Array.Empty<GUILayoutOption>()) && !valueOrDefault)
					{
						flag = true;
						list.Add(new WeatherData
						{
							weight = 1f,
							name = ""
						});
					}
					GUILayout.EndHorizontal();
				}
				GUILayout.EndVertical();
				if (flag)
				{
					cfg.BoxedValue = new SerializedWeather(list).ToString();
				}
			}
		}

		[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)]
		[PublicAPI]
		public enum Season
		{
			Summer,
			Fall,
			Winter,
			Spring
		}

		[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)]
		public enum Toggle
		{
			On,
			Off
		}

		[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)]
		public enum DisplayType
		{
			Above,
			Below
		}

		[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)]
		public class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order = null;

			[UsedImplicitly]
			public bool? Browsable = null;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(2)]
			[UsedImplicitly]
			public string Category = null;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(new byte[] { 2, 1 })]
			[UsedImplicitly]
			public Action<ConfigEntryBase> CustomDrawer = null;
		}

		private readonly ConfigSync ConfigSync;

		private readonly ConfigFile ConfigFile;

		private readonly string FileName;

		private readonly string FilePath;

		[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(2)]
		public static object configManager;

		public static readonly List<StatusEffectConfig> m_statusEffectConfigs = new List<StatusEffectConfig>
		{
			new StatusEffectConfig("Carry Weight", "Increase or decrease max carry weight", 0f, -500f, 500f),
			new StatusEffectConfig("Health Regeneration", "Multiply the amount of health regeneration from food", 1f, 0f, 10f),
			new StatusEffectConfig("Damage", "Multiply the amount of damage inflicted on enemies", 1f, 0f, 10f),
			new StatusEffectConfig("Speed", "Multiply the speed", 1f, 0f, 10f),
			new StatusEffectConfig("Eitr Regeneration", "Multiply the amount of eitr regeneration from food", 1f, 0f, 10f),
			new StatusEffectConfig("Raise Skill", "Multiply the amount of experience gained for skills", 1f, 0f, 10f),
			new StatusEffectConfig("Stamina Regeneration", "Multiply the amount of stamina regeneration", 1f, 0f, 10f)
		};

		public static ConfigEntry<Season> m_season = null;

		public static ConfigEntry<Toggle> m_waterFreezes = null;

		public static ConfigEntry<Toggle> m_winterAlwaysCold = null;

		public static ConfigEntry<double> m_lastSeasonChange = null;

		public static readonly Dictionary<Season, ConfigEntry<Vector3>> m_durations = new Dictionary<Season, ConfigEntry<Vector3>>();

		public static ConfigEntry<Toggle> m_seasonFades = null;

		public static ConfigEntry<float> m_fadeLength = null;

		public static ConfigEntry<Toggle> m_sleepOverride = null;

		public static ConfigEntry<Toggle> m_displaySeason = null;

		public static ConfigEntry<Toggle> m_displayTimer = null;

		public static ConfigEntry<DisplayType> m_displayType = null;

		public static readonly Dictionary<Season, Dictionary<string, ConfigEntry<float>>> m_effectConfigs = new Dictionary<Season, Dictionary<string, ConfigEntry<float>>>();

		public static ConfigEntry<Toggle> m_fadeToBlackImmune = null;

		public static ConfigEntry<Toggle> m_weatherEnabled = null;

		public static ConfigEntry<int> m_weatherDuration = null;

		public static readonly Dictionary<Season, Dictionary<Biome, ConfigEntry<string>>> m_weatherOptions = new Dictionary<Season, Dictionary<Biome, ConfigEntry<string>>>();

		public static ConfigEntry<Toggle> m_displayWeather = null;

		public static ConfigEntry<Toggle> m_displayWeatherTimer = null;

		public static ConfigEntry<Toggle> m_enableModifiers = null;

		public static ConfigEntry<string> m_rootTextureFolder = null;

		public static ConfigEntry<Toggle> m_randomColors = null;

		public static ConfigEntry<Toggle> m_particlesController = null;

		public static ConfigEntry<Color> m_fallColor1 = null;

		public static ConfigEntry<Color> m_fallColor2 = null;

		public static ConfigEntry<Color> m_fallColor3 = null;

		public static ConfigEntry<Color> m_fallColor4 = null;

		public static ConfigEntry<string> m_fallObjects = null;

		public static ConfigEntry<string> m_fallMaterials = null;

		public static ConfigEntry<Toggle> m_fixShader = null;

		private void Init()
		{
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Expected O, but got Unknown
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Expected O, but got Unknown
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_054f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_062c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0637: Expected O, but got Unknown
			//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b2: Expected O, but got Unknown
			//IL_06f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0704: Unknown result type (might be due to invalid IL or missing references)
			//IL_070b: Invalid comparison between Unknown and I4
			//IL_072f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0732: Invalid comparison between Unknown and I4
			//IL_077e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0793: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ec: Expected O, but got Unknown
			m_season = config("1 - Settings", "Season", Season.Summer, "Set current season");
			m_season.SettingChanged += [<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (object _, EventArgs _) =>
			{
				SeasonalityPlugin.OnSeasonChange();
			};
			m_lastSeasonChange = config("1 - Settings", "Last Season Change", 0.0, "Record of last season change, reset if you create a new world");
			m_sleepOverride = config("1 - Settings", "Sleep Override", Toggle.Off, "If on, season changes when players sleep, instead of on timer end");
			m_seasonFades = config("1 - Settings", "Fade To Black", Toggle.Off, "If on, screen fades to black when season is changing");
			m_fadeLength = config("1 - Settings", "Fade Length (seconds)", 3f, "Set length of fade to black");
			m_fadeToBlackImmune = config("1 - Settings", "Fade Immune", Toggle.Off, "If on, player immune while fading to black");
			m_enableModifiers = config("1 - Settings", "Modifiers Enabled", Toggle.Off, "If on, season status effect modifiers are enabled");
			m_rootTextureFolder = config("1 - Settings", "Texture Folder", "Default", "Set the root folder to register textures");
			m_particlesController = config("1 - Settings", "Particles", Toggle.Off, "If on, particles are affected");
			m_fallObjects = config("Fall", "Fall Objects", new SerializedNameList("Beech1", "Birch1", "Birch2", "Birch1_aut", "Birch2_aut", "Beech_small1", "Beech_small2", "YggaShoot1", "YggaShoot2", "YggaShoot3", "YggaShoot_small1", "Oak1", "vfx_beech_cut", "vfx_birch1_cut", "vfx_birch2_cut", "vfx_birch1_aut_cut", "vfx_birch2_aut_cut", "vfx_oak_cut", "vfx_beech_small1_destroy", "vfx_beech_small2_destroy", "vfx_yggashoot_cut", "vfx_yggashoot_small1_destroy").ToString(), new ConfigDescription("List of objects affected by random fall colors", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "Fall",
					CustomDrawer = SerializedNameList.Draw
				}
			}));
			m_fallMaterials = config("Fall", "Fall Materials", new SerializedNameList("beech_leaf", "beech_particle", "beech_leaf_small", "birch_leaf", "birch_leaf_aut", "oak_leaf", "Shoot_Leaf_mat", "leaf", "birch_particle", "oak_particle", "shoot_leaf_particle").ToString(), new ConfigDescription("List of materials affected by random fall colors", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Category = "Fall",
					CustomDrawer = SerializedNameList.Draw
				}
			}));
			m_displayTimer = config("2 - HUD", "Display Timer", Toggle.On, "If on, timer is displayed");
			m_displayType = config("2 - HUD", "Display Type", DisplayType.Above, "Set where the name of season is displayed");
			m_displaySeason = config("2 - HUD", "Display Season", Toggle.On, "If on, season is displayed as a status effect");
			m_displayWeather = config("2 - HUD", "Display Weather", Toggle.Off, "If on, weather environments are displayed as status effect");
			m_displayWeather.SettingChanged += WeatherManager.OnDisplayConfigChange;
			m_displayWeatherTimer = config("2 - HUD", "Weather Timer", Toggle.Off, "If on, weather timer is displayed");
			m_weatherEnabled = config("1 - Settings", "Weather Enabled", Toggle.On, "If on, plugin overrides weather");
			m_weatherDuration = config("1 - Settings", "Weather Length (minutes)", 20, "Set length of environment weather");
			m_weatherDuration.SettingChanged += WeatherManager.OnWeatherDurationChange;
			m_waterFreezes = config("Winter", "Water Freezes", Toggle.Off, "If on, water freezes and players can walk on it");
			m_waterFreezes.SettingChanged += [<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (object _, EventArgs _) =>
			{
				FrozenZones.UpdateAll();
				FrozenWaterLOD.UpdateAll();
			};
			m_winterAlwaysCold = config("Winter", "Always Cold", Toggle.Off, "If on, winter is always cold, and applies Cold Status Effect");
			m_displaySeason.SettingChanged += SeasonSE.OnSeasonDisplayConfigChange;
			m_randomColors = config("Fall", "Random Colors", Toggle.On, "If on, random colors are applied to targeted prefabs");
			m_fallColor1 = config<Color>("Fall", "Color 1", new Color(0.803f, 0.36f, 0.36f, 1f), "Set fall color 1");
			m_fallColor2 = config<Color>("Fall", "Color 2", new Color(0.855f, 0.647f, 0.125f, 1f), "Set fall color 2");
			m_fallColor3 = config<Color>("Fall", "Color 3", new Color(0.914f, 0.455f, 0.318f, 1f), "Set fall color 3");
			m_fallColor4 = config<Color>("Fall", "Color 4", new Color(0.545f, 0.27f, 0.074f, 1f), "Set fall color 4");
			m_fixShader = config("1 - General", "Fix Shaders", Toggle.Off, "If on, plugin will try to fix shaders");
			foreach (Season value in Enum.GetValues(typeof(Season)))
			{
				m_durations[value] = config<Vector3>(value.ToString(), "In-Game Duration", new Vector3(0f, 5f, 0f), new ConfigDescription("Set length of " + value.ToString().ToLower() + ", days, hours, minutes (30min real-time = 1 day", (AcceptableValueBase)null, new object[1]
				{
					new ConfigurationManagerAttributes
					{
						Category = value.ToString(),
						CustomDrawer = StatusEffectConfig.Draw
					}
				}));
				foreach (StatusEffectConfig statusEffectConfig in m_statusEffectConfigs)
				{
					m_effectConfigs.AddOrSet(value, statusEffectConfig.m_name, config(value.ToString(), statusEffectConfig.m_name, statusEffectConfig.m_value, new ConfigDescription(statusEffectConfig.m_description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(statusEffectConfig.m_range.Key, statusEffectConfig.m_range.Value), Array.Empty<object>())));
				}
				foreach (Biome value2 in Enum.GetValues(typeof(Biome)))
				{
					if (((int)value2 != 0 && (int)value2 != 895) || 1 == 0)
					{
						SerializedWeather serializedWeather = new SerializedWeather();
						if (value == Season.Winter && (int)value2 != 4)
						{
							serializedWeather.Add("WarmSnow", 1f);
							serializedWeather.Add("Twilight_Snow", 0.5f);
							serializedWeather.Add("WarmSnowStorm", 0.1f);
						}
						m_weatherOptions.AddOrSet(value, value2, config(value.ToString(), $"{(object)value2} Weather", serializedWeather.ToString(), new ConfigDescription("List of environment names and weights, [env]:[weight],[env]:[weight],...", (AcceptableValueBase)null, new object[1]
						{
							new ConfigurationManagerAttributes
							{
								Category = value.ToString(),
								CustomDrawer = SerializedWeather.Draw
							}
						})));
					}
				}
			}
		}

		public Configs(ConfigFile file, ConfigSync sync, string fileName, string path)
		{
			ConfigFile = file;
			ConfigSync = sync;
			FileName = fileName;
			FilePath = path;
			Init();
			SetupWatcher();
		}

		private void SetupWatcher()
		{
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, FileName);
			fileSystemWatcher.Changed += ReadConfigValues;
			fileSystemWatcher.Created += ReadConfigValues;
			fileSystemWatcher.Renamed += ReadConfigValues;
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		private void ReadConfigValues(object sender, FileSystemEventArgs e)
		{
			if (!File.Exists(FilePath))
			{
				return;
			}
			try
			{
				SeasonalityPlugin.Record.LogDebug("ReadConfigValues called");
				ConfigFile.Reload();
			}
			catch
			{
				SeasonalityPlugin.Record.LogError("There was an issue loading your " + FilePath);
				SeasonalityPlugin.Record.LogError("Please check your config entries for spelling and format!");
			}
		}

		public ConfigEntry<T> config<[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(description.Description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags);
			ConfigEntry<T> val2 = ConfigFile.Bind<T>(group, name, value, val);
			SyncedConfigEntry<T> syncedConfigEntry = ConfigSync.AddConfigEntry<T>(val2);
			syncedConfigEntry.SynchronizedConfig = synchronizedSetting;
			return val2;
		}

		public ConfigEntry<T> config<[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting);
		}
	}
	[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(1)]
	[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
	public class Records
	{
		private static string ConfigFolder;

		private static string FileName;

		private static string FilePath;

		private readonly ManualLogSource m_manualLogSource;

		private readonly List<string> m_records = new List<string>();

		public Records(ManualLogSource logger, string folderName, string fileName)
		{
			m_manualLogSource = logger;
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFolder = configPath + directorySeparatorChar + folderName;
			FileName = fileName;
			string configFolder = ConfigFolder;
			directorySeparatorChar = Path.DirectorySeparatorChar;
			FilePath = configFolder + directorySeparatorChar + fileName;
		}

		public void LogSuccess(string log)
		{
		}

		public void LogDebug(string log)
		{
			m_records.Add("[Debug]: " + log);
			m_manualLogSource.LogDebug((object)log);
		}

		public void LogInfo(string log)
		{
			m_records.Add("[Info]: " + log);
			m_manualLogSource.LogInfo((object)log);
		}

		public void LogWarning(string log)
		{
			m_records.Add("[Warning]: " + log);
			m_manualLogSource.LogWarning((object)log);
		}

		public void LogError(string log)
		{
			m_records.Add("[Error]: " + log);
			m_manualLogSource.LogError((object)log);
		}

		public void Write()
		{
			if (!Directory.Exists(ConfigFolder))
			{
				Directory.CreateDirectory(ConfigFolder);
			}
			File.WriteAllLines(FilePath, m_records);
			LogInfo(FileName + " wrote to file: " + FilePath);
		}

		static Records()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFolder = configPath + directorySeparatorChar + "Seasonality";
			FileName = "Seasonality-LogOutput.log";
			string configFolder = ConfigFolder;
			directorySeparatorChar = Path.DirectorySeparatorChar;
			FilePath = configFolder + directorySeparatorChar + FileName;
		}
	}
	[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(1)]
	[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
	public static class SeasonCommands
	{
		[HarmonyPatch(typeof(Terminal), "Awake")]
		[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)]
		private static class Terminal_Awake_Patch
		{
			private static void Postfix()
			{
				Setup();
			}
		}

		[HarmonyPatch(typeof(Terminal), "updateSearch")]
		[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
		private static class Terminal_UpdateSearch_Patch
		{
			private static bool Prefix(Terminal __instance, string word)
			{
				if ((Object)(object)__instance.m_search == (Object)null)
				{
					return true;
				}
				string[] array = ((TMP_InputField)__instance.m_input).text.Split(new char[1] { ' ' });
				if (array.Length < 3)
				{
					return true;
				}
				if (array[0] != "seasonality")
				{
					return true;
				}
				return HandleSearch(__instance, word, array);
			}

			private static bool HandleSearch(Terminal __instance, string word, string[] strArray)
			{
				if (!m_commands.TryGetValue(strArray[1], out var value))
				{
					return true;
				}
				if (value.HasOptions() && strArray.Length == 3)
				{
					List<string> list = value.FetchOptions();
					string currentSearch = strArray[2];
					List<string> list2;
					if (!Utility.IsNullOrWhiteSpace(currentSearch))
					{
						int num = list.IndexOf(currentSearch);
						list2 = ((num != -1) ? list.GetRange(num, list.Count - num) : list);
						list2 = list2.FindAll((string x) => x.ToLower().Contains(currentSearch.ToLower()));
					}
					else
					{
						list2 = list;
					}
					if (list2.Count <= 0)
					{
						__instance.m_search.text = value.m_description;
					}
					else
					{
						__instance.m_lastSearch.Clear();
						__instance.m_lastSearch.AddRange(list2);
						__instance.m_lastSearch.Remove(word);
						__instance.m_search.text = "";
						int num2 = 10;
						int num3 = Math.Min(__instance.m_lastSearch.Count, num2);
						for (int i = 0; i < num3; i++)
						{
							string text = __instance.m_lastSearch[i];
							TMP_Text search = __instance.m_search;
							search.text = search.text + text + " ";
						}
						if (__instance.m_lastSearch.Count <= num2)
						{
							return false;
						}
						int num4 = __instance.m_lastSearch.Count - num2;
						TMP_Text search2 = __instance.m_search;
						search2.text += $"... {num4} more.";
					}
				}
				else
				{
					__instance.m_search.text = value.m_description;
				}
				return false;
			}
		}

		[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
		private class SeasonCommand
		{
			public readonly string m_description;

			private readonly bool m_isSecret;

			private readonly bool m_adminOnly;

			private readonly Func<ConsoleEventArgs, bool> m_command;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(new byte[] { 2, 1, 1 })]
			private readonly Func<List<string>> m_optionFetcher;

			public bool Run(ConsoleEventArgs args)
			{
				return !IsAdmin() || m_command(args);
			}

			private bool IsAdmin()
			{
				if (!Object.op_Implicit((Object)(object)ZNet.m_instance))
				{
					return true;
				}
				if (!m_adminOnly || ZNet.m_instance.LocalPlayerIsAdminOrHost())
				{
					return true;
				}
				SeasonalityPlugin.Record.LogWarning("Admin only command");
				return false;
			}

			public bool IsSecret()
			{
				return m_isSecret;
			}

			public List<string> FetchOptions()
			{
				return (m_optionFetcher == null) ? new List<string>() : m_optionFetcher();
			}

			public bool HasOptions()
			{
				return m_optionFetcher != null;
			}

			[Description("Register a custom command with the prefix seasonality")]
			public SeasonCommand(string input, string description, Func<ConsoleEventArgs, bool> command, [<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(new byte[] { 2, 1, 1 })] Func<List<string>> optionsFetcher = null, bool isSecret = false, bool adminOnly = false)
			{
				m_description = description;
				m_command = command;
				m_isSecret = isSecret;
				m_commands[input] = this;
				m_optionFetcher = optionsFetcher;
				m_adminOnly = adminOnly;
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
			public static readonly <>c <>9 = new <>c();

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
			public static ConsoleEventFailable <>9__1_0;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
			public static Func<KeyValuePair<string, SeasonCommand>, bool> <>9__1_11;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
			public static Func<KeyValuePair<string, SeasonCommand>, string> <>9__1_12;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(0)]
			public static ConsoleOptionsFetcher <>9__1_1;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(new byte[] { 0, 1 })]
			public static Func<ConsoleEventArgs, bool> <>9__1_2;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(new byte[] { 0, 1 })]
			public static Func<ConsoleEventArgs, bool> <>9__1_3;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(new byte[] { 0, 1 })]
			public static Func<ConsoleEventArgs, bool> <>9__1_4;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(new byte[] { 0, 1 })]
			public static Func<ConsoleEventArgs, bool> <>9__1_5;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(new byte[] { 0, 1 })]
			public static Func<ConsoleEventArgs, bool> <>9__1_6;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(new byte[] { 0, 1, 1 })]
			public static Func<List<string>> <>9__1_7;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(new byte[] { 0, 1 })]
			public static Func<ConsoleEventArgs, bool> <>9__1_8;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(new byte[] { 0, 1, 1 })]
			public static Func<List<string>> <>9__1_9;

			[<76e2bcee-7be0-4ded-8938-c3ec54ab3119>Nullable(new byte[] { 0, 1 })]
			public static Func<ConsoleEventArgs, bool> <>9__1_10;

			[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)]
			internal object <Setup>b__1_0(ConsoleEventArgs args)
			{
				if (args.Length < 2)
				{
					return false;
				}
				if (!m_commands.TryGetValue(args[1], out var value))
				{
					return false;
				}
				return value.Run(args);
			}

			[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)]
			internal List<string> <Setup>b__1_1()
			{
				return (from x in m_commands
					where !x.Value.IsSecret()
					select x.Key).ToList();
			}

			[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)]
			internal bool <Setup>b__1_11(KeyValuePair<string, SeasonCommand> x)
			{
				return !x.Value.IsSecret();
			}

			[<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)]
			internal string <Setup>b__1_12(KeyValuePair<string, SeasonCommand> x)
			{
				return x.Key;
			}

			internal bool <Setup>b__1_2(ConsoleEventArgs _)
			{
				if (!Object.op_Implicit((Object)(object)EnvMan.instance))
				{
					return false;
				}
				foreach (EnvSetup environment in EnvMan.instance.m_environments)
				{
					SeasonalityPlugin.Record.LogInfo(environment.m_name);
				}
				return true;
			}

			internal bool <Setup>b__1_3(ConsoleEventArgs args)
			{
				if (args.Length < 2)
				{
					return false;
				}
				foreach (KeyValuePair<string, Material> allMaterial in TextureReplacer.m_allMaterials)
				{
					if (allMaterial.Key.ToLower().Contains(args[2].ToLower()))
					{
						Debug.Log((object)allMaterial.Key);
					}
				}
				foreach (KeyValuePair<string, List<TextureReplacer.MaterialData>> fallMaterial in TextureReplacer.m_fallMaterials)
				{
					if (!fallMaterial.Key.ToLower().Contains(args[2].ToLower()))
					{
						continue;
					}
					foreach (TextureReplacer.MaterialData item in fallMaterial.Value)
					{
						Debug.Log((object)item.m_name);
					}
				}
				return true;
			}

			internal bool <Setup>b__1_4(ConsoleEventArgs args)
			{
				if (args.Length < 2)
				{
					return false;
				}
				if (!TextureReplacer.m_allMaterials.TryGetValue(args[2], out var value))
				{
					return false;
				}
				Debug.LogWarning((object)((Object)value).name);
				Debug.LogWarning((object)((Object)value.shader).name);
				if ((Object)(object)value.mainTexture != (Object)null)
				{
					Debug.LogWarning((object)((Object)value.mainTexture).name);
				}
				if (value.HasProperty("_Cutoff"))
				{
					Debug.LogWarning((object)value.GetFloat("_Cutoff"));
				}
				return true;
			}

			internal bool <Setup>b__1_5(ConsoleEventArgs _)
			{
				SeasonalityPlugin.Record.Write();
				return true;
			}

			internal bool <Setup>b__1_6(ConsoleEventArgs args)
			{
				if (args.Length < 2)
				{
					return false;
				}
				foreach (KeyValuePair<string, Texture> allTexture in TextureManager.GetAllTextures())
				{
					if (allTexture.Key.ToLower().Contains(args[2]))
					{
						Debug.Log((object)allTexture.Key);
					}
				}
				return true;
			}

			internal List<string> <Setup>b__1_7()
			{
				return TextureManager.GetAllTextures().Keys.ToList();
			}

			internal bool <Setup>b__1_8(ConsoleEventArgs args)
			{
				if (args.Length < 2)
				{
					return true;
				}
				if (!Enum.TryParse<Configs.Season>(args[2], ignoreCase: true, out var result))
				{
					return false;
				}
				Configs.m_season.Value = result;
				return true;
			}

			internal List<string> <Setup>b__1_9()
			{
				return Enum.GetNames(typeof(Configs.Season)).ToList();
			}

			internal bool <Setup>b__1_10(ConsoleEventArgs _)
			{
				foreach (KeyValuePair<string, SeasonCommand> command in m_commands)
				{
					Debug.Log((object)(command.Key + " - " + command.Value.m_description));
				}
				return true;
			}
		}

		private static readonly Dictionary<string, SeasonCommand> m_commands = new Dictionary<string, SeasonCommand>();

		private static void Setup()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			object obj = <>c.<>9__1_0;
			if (obj == null)
			{
				ConsoleEventFailable val = [<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] (ConsoleEventArgs args) =>
				{
					if (args.Length < 2)
					{
						return false;
					}
					SeasonCommand value2;
					return (!m_commands.TryGetValue(args[1], out value2)) ? ((object)false) : ((object)value2.Run(args));
				};
				<>c.<>9__1_0 = val;
				obj = (object)val;
			}
			object obj2 = <>c.<>9__1_1;
			if (obj2 == null)
			{
				ConsoleOptionsFetcher val2 = [<531fca12-380c-459d-a31a-45e831e60ef3>NullableContext(0)] () => (from x in m_commands
					where !x.Value.IsSecret()
					select x.Key).ToList();
				<>c.<>9__1_1 = val2;
				obj2 = (object)val2;
			}
			ConsoleCommand val3 = new ConsoleCommand("seasonality", "use help to list out commands", (ConsoleEventFailable)obj, false, false, false, false, false, (ConsoleOptionsFetcher)obj2, false, false, false);
			SeasonCommand seasonCommand = new SeasonCommand("weathers", "List of weather names", delegate
			{
				if (!Object.op_Implicit((Object)(object)EnvMan.instance))
				{
					return false;
				}
				foreach (EnvSetup environment in EnvMan.instance.m_environments)
				{
					SeasonalityPlugin.Record.LogInfo(environment.m_name);
				}
				return true;
			});
			SeasonCommand seasonCommand2 = new SeasonCommand("materials", "search materials", delegate(ConsoleEventArgs args)
			{
				if (args.Length < 2)
				{
					return false;
				}
				foreach (KeyValuePair<string, Material> allMaterial in TextureReplacer.m_allMaterials)
				{
					if (allMaterial.Key.ToLower().Contains(args[2].ToLower()))
					{
						Debug.Log((object)allMaterial.Key);
					}
				}
				foreach (KeyValuePair<string, List<TextureReplacer.MaterialData>> fallMaterial in TextureReplacer.m_fallMaterials)
				{
					if (fallMaterial.Key.ToLower().Contains(args[2].ToLower()))
					{
						foreach (TextureReplacer.MaterialData item in fallMaterial.Value)
						{
							Debug.Log((object)item.m_name);
						}
					}
				}
				return true;
			}, null, isSecret: true);
			SeasonCommand seasonCommand3 = new SeasonCommand("material", "", delegate(ConsoleEventArgs args)
			{
				if (args.Length < 2)
				{
					return false;
				}
				if (!TextureReplacer.m_allMaterials.TryGetValue(args[2], out var value))
				{
					return false;
				}
				Debug.Lo