Decompiled source of Seasons v1.6.1
Seasons.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Seasons.Compatibility; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.Experimental.Rendering; using UnityEngine.Networking; using UnityEngine.UI; [assembly: AssemblyFileVersion("1.6.1")] [assembly: Guid("076e7e5f-9182-41e5-a76b-5c051d6b3957")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyProduct("Seasons")] [assembly: AssemblyCompany("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("")] [assembly: AssemblyTitle("Seasons")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.6.1.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<2eb33b31-a20f-4362-af52-1a89f7b432ec>Embedded] internal sealed class <2eb33b31-a20f-4362-af52-1a89f7b432ec>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [<2eb33b31-a20f-4362-af52-1a89f7b432ec>Embedded] internal sealed class <3d2f5245-9c6d-4a00-a06d-4774600fa525>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <3d2f5245-9c6d-4a00-a06d-4774600fa525>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <3d2f5245-9c6d-4a00-a06d-4774600fa525>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<2eb33b31-a20f-4362-af52-1a89f7b432ec>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <4c508bcc-8610-420e-91b5-827233b319ed>NullableContextAttribute : Attribute { public readonly byte Flag; public <4c508bcc-8610-420e-91b5-827233b319ed>NullableContextAttribute(byte P_0) { Flag = P_0; } } } public struct HSLColor { public float h; public float s; public float l; public float a; public HSLColor(float h, float s, float l, float a) { this.h = h; this.s = s; this.l = l; this.a = a; } public HSLColor(float h, float s, float l) { this.h = h; this.s = s; this.l = l; a = 1f; } public HSLColor(Color c) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) HSLColor hSLColor = FromRGBA(c); h = hSLColor.h; s = hSLColor.s; l = hSLColor.l; a = hSLColor.a; } public static HSLColor FromRGBA(Color c) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) float num = c.a; float num2 = Mathf.Min(Mathf.Min(c.r, c.g), c.b); float num3 = Mathf.Max(Mathf.Max(c.r, c.g), c.b); float num4 = (num2 + num3) / 2f; float num5; float num6; if (num2 == num3) { num5 = 0f; num6 = 0f; } else { float num7 = num3 - num2; num5 = ((num4 <= 0.5f) ? (num7 / (num3 + num2)) : (num7 / (2f - (num3 + num2)))); num6 = 0f; if (c.r == num3) { num6 = (c.g - c.b) / num7; } else if (c.g == num3) { num6 = 2f + (c.b - c.r) / num7; } else if (c.b == num3) { num6 = 4f + (c.r - c.g) / num7; } num6 = Mathf.Repeat(num6 * 60f, 360f); } return new HSLColor(num6, num5, num4, num); } public Color ToRGBA() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) float num = a; float num2 = ((l <= 0.5f) ? (l * (1f + s)) : (l + s - l * s)); float n = 2f * l - num2; float num5; float num4; float num3; if (s == 0f) { num5 = (num4 = (num3 = l)); } else { num5 = Value(n, num2, h + 120f); num4 = Value(n, num2, h); num3 = Value(n, num2, h - 120f); } return new Color(num5, num4, num3, num); } private static float Value(float n1, float n2, float hue) { hue = Mathf.Repeat(hue, 360f); if (hue < 60f) { return n1 + (n2 - n1) * hue / 60f; } if (hue < 180f) { return n2; } if (hue < 240f) { return n1 + (n2 - n1) * (240f - hue) / 60f; } return n1; } public static implicit operator HSLColor(Color src) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return FromRGBA(src); } public static implicit operator Color(HSLColor src) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) return src.ToRGBA(); } } namespace Seasons { [Serializable] public class CachedData { [Serializable] public class TextureData { public string name; public byte[] originalPNG; public TextureProperties properties; public Dictionary<Seasons.Season, Dictionary<int, byte[]>> variants = new Dictionary<Seasons.Season, Dictionary<int, byte[]>>(); public bool Initialized() { return variants.Any((KeyValuePair<Seasons.Season, Dictionary<int, byte[]>> variant) => variant.Value.Count > 0); } public TextureData(TextureVariants textureVariants) { if (textureVariants == null) { return; } originalPNG = textureVariants.originalPNG; name = textureVariants.originalName; properties = textureVariants.properties; foreach (KeyValuePair<Seasons.Season, Dictionary<int, Texture2D>> season in textureVariants.seasons) { variants.Add(season.Key, new Dictionary<int, byte[]>()); foreach (KeyValuePair<int, Texture2D> item in season.Value) { variants[season.Key].Add(item.Key, ImageConversion.EncodeToPNG(item.Value)); } } } public TextureData(DirectoryInfo texDirectory) { FileInfo[] files = texDirectory.GetFiles("properties.json"); if (files.Length != 0) { properties = JsonUtility.FromJson<TextureProperties>(File.ReadAllText(files[0].FullName)); } foreach (Seasons.Season value in Enum.GetValues(typeof(Seasons.Season))) { variants.Add(value, new Dictionary<int, byte[]>()); for (int i = 0; i < 4; i++) { FileInfo[] files2 = texDirectory.GetFiles(SeasonFileName(value, i)); if (files2.Length != 0) { variants[value].Add(i, File.ReadAllBytes(files2[0].FullName)); } } } } } internal const string cacheSubdirectory = "Cache"; internal const string prefabCacheCommonFile = "cache.bin"; internal const string prefabCacheFileName = "cache.json"; internal const string texturesDirectory = "textures"; internal const string originalPostfix = ".orig.png"; internal const string texturePropertiesFileName = "properties.json"; public Dictionary<string, PrefabController> controllers = new Dictionary<string, PrefabController>(); public Dictionary<int, TextureData> textures = new Dictionary<int, TextureData>(); public uint revision = 0u; public CachedData(uint revision) { this.revision = revision; } public bool Initialized() { return controllers.Count > 0 && textures.Count > 0; } public void SaveOnDisk() { if (Initialized()) { if (Seasons.cacheStorageFormat.Value == Seasons.CacheFormat.Binary) { SaveToBinary(); return; } if (Seasons.cacheStorageFormat.Value == Seasons.CacheFormat.Json) { SaveToJSON(); return; } SaveToJSON(); SaveToBinary(); } } public void LoadFromDisk() { if (Seasons.cacheStorageFormat.Value == Seasons.CacheFormat.Json) { LoadFromJSON(); } else { LoadFromBinary(); } } private void SaveToJSON() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown string text = CacheDirectory(); Directory.CreateDirectory(text); string text2 = Path.Combine(text, "cache.json"); File.WriteAllText(text2, JsonConvert.SerializeObject((object)controllers, (Formatting)1, new JsonSerializerSettings { NullValueHandling = (NullValueHandling)1, DefaultValueHandling = (DefaultValueHandling)1 })); string text3 = Path.Combine(text, "textures"); Seasons.LogInfo("Saved cache file " + text2); foreach (KeyValuePair<int, TextureData> texture in textures) { string text4 = Path.Combine(text3, texture.Key.ToString()); Directory.CreateDirectory(text4); File.WriteAllBytes(Path.Combine(text4, texture.Value.name + ".orig.png"), texture.Value.originalPNG); File.WriteAllText(Path.Combine(text4, "properties.json"), JsonUtility.ToJson((object)texture.Value.properties, true)); foreach (KeyValuePair<Seasons.Season, Dictionary<int, byte[]>> variant in texture.Value.variants) { foreach (KeyValuePair<int, byte[]> item in variant.Value) { File.WriteAllBytes(Path.Combine(text4, SeasonFileName(variant.Key, item.Key)), item.Value); } } } Seasons.LogInfo($"Saved {textures.Count} textures at {text3}"); } private void LoadFromJSON() { string text = CacheDirectory(); DirectoryInfo directoryInfo = new DirectoryInfo(text); if (!directoryInfo.Exists) { return; } FileInfo[] files = directoryInfo.GetFiles("cache.json"); if (files.Length == 0) { Seasons.LogInfo("File not found: " + Path.Combine(text, "cache.json")); return; } try { controllers = JsonConvert.DeserializeObject<Dictionary<string, PrefabController>>(File.ReadAllText(files[0].FullName)); } catch (Exception arg) { Seasons.LogWarning($"Error loading JSON cache data from {files[0].FullName}\n{arg}"); return; } DirectoryInfo[] directories = directoryInfo.GetDirectories("textures"); if (directories.Length == 0) { return; } DirectoryInfo[] directories2 = directories[0].GetDirectories(); foreach (DirectoryInfo directoryInfo2 in directories2) { int key = int.Parse(directoryInfo2.Name); if (!textures.ContainsKey(key)) { TextureData textureData = new TextureData(directoryInfo2); if (textureData.Initialized()) { textures.Add(key, textureData); } } } } private void SaveToBinary() { string text = CacheDirectory(); Directory.CreateDirectory(text); using (FileStream fileStream = new FileStream(Path.Combine(text, "cache.bin"), FileMode.Create)) { BinaryFormatter binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(fileStream, this); fileStream.Dispose(); } Seasons.LogInfo("Saved cache file " + Path.Combine(text, "cache.bin")); } private void LoadFromBinary() { string path = CacheDirectory(); string text = Path.Combine(path, "cache.bin"); if (!File.Exists(text)) { Seasons.LogInfo("File not found: " + text); return; } try { using FileStream fileStream = new FileStream(text, FileMode.Open, FileAccess.Read, FileShare.Read); BinaryFormatter binaryFormatter = new BinaryFormatter(); CachedData cachedData = (CachedData)binaryFormatter.Deserialize(fileStream); fileStream.Dispose(); DictionaryExt.Copy<string, PrefabController>(controllers, cachedData.controllers); DictionaryExt.Copy<int, TextureData>(textures, cachedData.textures); cachedData = null; } catch (Exception arg) { Seasons.LogWarning($"Error loading binary cache data from {text}:\n {arg}"); } } public string CacheDirectory() { return Path.Combine(Seasons.cacheDirectory, revision.ToString()); } public static string SeasonFileName(Seasons.Season season, int variant) { return $"{season}_{variant + 1}.png"; } } [Serializable] public class PrefabController { [Serializable] public class CachedMaterial { public string name = string.Empty; public string shaderName = string.Empty; public Dictionary<string, int> textureProperties = new Dictionary<string, int>(); public Dictionary<string, string[]> colorVariants = new Dictionary<string, string[]>(); public CachedMaterial() { } public CachedMaterial(string materialName, string shader, string propertyName, int textureID) { name = materialName; shaderName = shader; AddTexture(propertyName, textureID); } public CachedMaterial(string materialName, string shader, string propertyName, Color[] colors) { name = materialName; shaderName = shader; AddColors(propertyName, colors); } public void AddTexture(string propertyName, int textureID) { if (!textureProperties.ContainsKey(propertyName)) { textureProperties.Add(propertyName, textureID); } } public void AddColors(string propertyName, Color[] colors) { List<string> vec = new List<string>(); CollectionExtensions.Do<Color>((IEnumerable<Color>)colors, (Action<Color>)delegate(Color x) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) vec.Add("#" + ColorUtility.ToHtmlStringRGBA(x)); }); if (!colorVariants.ContainsKey(propertyName)) { colorVariants.Add(propertyName, vec.ToArray()); } } } [Serializable] public class CachedRenderer { public string name = string.Empty; public string type = string.Empty; public Dictionary<string, CachedMaterial> materials = new Dictionary<string, CachedMaterial>(); public CachedRenderer() { } public CachedRenderer(string rendererName, string rendererType) { name = rendererName; type = rendererType; } public bool Initialized() { return materials.Any((KeyValuePair<string, CachedMaterial> m) => m.Value.textureProperties.Count > 0 || m.Value.colorVariants.Count > 0); } public void AddMaterialTexture(Material material, string propertyName, int textureID) { if (!materials.TryGetValue(((Object)material).name, out var value)) { materials.Add(((Object)material).name, new CachedMaterial(((Object)material).name, ((Object)material.shader).name, propertyName, textureID)); } else { value.AddTexture(propertyName, textureID); } } public void AddMaterialColors(Material material, string propertyName, Color[] colors) { if (!materials.TryGetValue(((Object)material).name, out var value)) { materials.Add(((Object)material).name, new CachedMaterial(((Object)material).name, ((Object)material.shader).name, propertyName, colors)); } else { value.AddColors(propertyName, colors); } } } public Dictionary<string, Dictionary<int, List<CachedRenderer>>> lodsInHierarchy = new Dictionary<string, Dictionary<int, List<CachedRenderer>>>(); public Dictionary<int, List<CachedRenderer>> lodLevelMaterials = new Dictionary<int, List<CachedRenderer>>(); public Dictionary<string, CachedRenderer> renderersInHierarchy = new Dictionary<string, CachedRenderer>(); public CachedRenderer cachedRenderer; public Dictionary<string, string[]> particleSystemStartColors; public bool Initialized() { return lodsInHierarchy.Count > 0 || lodLevelMaterials.Count > 0 || renderersInHierarchy.Count > 0 || cachedRenderer != null || particleSystemStartColors != null; } public override string ToString() { return ((cachedRenderer == null) ? "" : " 1 main renderer") + ((particleSystemStartColors == null) ? "" : " 1 particles start color") + " " + ((lodsInHierarchy.Count > 0) ? $" {lodsInHierarchy.Count} LOD groups" : "") + ((lodLevelMaterials.Count > 0) ? $" {lodLevelMaterials.Count} LODs" : "") + ((renderersInHierarchy.Count > 0) ? $" {renderersInHierarchy.Count} renderersInHierarchy" : ""); } } public class SeasonalTextureVariants { [CompilerGenerated] private sealed class <>c__DisplayClass4_0 { public CachedData cachedData; public SeasonalTextureVariants <>4__this; internal void <SaveCacheOnDisk>b__0() { DictionaryExt.Copy<string, PrefabController>(cachedData.controllers, <>4__this.controllers); if (Directory.Exists(cachedData.CacheDirectory())) { Directory.Delete(cachedData.CacheDirectory(), recursive: true); } cachedData.SaveOnDisk(); } } [CompilerGenerated] private sealed class <>c__DisplayClass7_0 { public CachedData cachedData; public SeasonalTextureVariants <>4__this; internal void <ReloadCache>b__0() { cachedData.LoadFromDisk(); } internal void <ReloadCache>b__1() { DictionaryExt.Copy<string, PrefabController>(<>4__this.controllers, cachedData.controllers); } } [CompilerGenerated] private sealed class <>c__DisplayClass8_0 { public SeasonalTextureVariants <>4__this; public SeasonalTextureVariants newTexturesVariants; internal void <RebuildCache>b__0() { DictionaryExt.Copy<string, PrefabController>(<>4__this.controllers, newTexturesVariants.controllers); DictionaryExt.Copy<int, TextureVariants>(<>4__this.textures, newTexturesVariants.textures); } } [CompilerGenerated] private sealed class <RebuildCache>d__8 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public SeasonalTextureVariants <>4__this; private <>c__DisplayClass8_0 <>8__1; private Stopwatch <stopwatch>5__2; private Thread <internalThread>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <RebuildCache>d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <stopwatch>5__2 = null; <internalThread>5__3 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass8_0(); <>8__1.<>4__this = <>4__this; <>8__1.newTexturesVariants = new SeasonalTextureVariants(); SeasonalTexturePrefabCache.SetCurrentTextureVariants(<>8__1.newTexturesVariants); PrefabVariantController.instance.RevertPrefabsState(); ClutterVariantController.Instance.RevertColors(); <>2__current = Seasons.waitForFixedUpdate; <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = SeasonalTexturePrefabCache.FillWithGameData(); <>1__state = 2; return true; case 2: <>1__state = -1; if (<>8__1.newTexturesVariants.Initialized()) { <stopwatch>5__2 = Stopwatch.StartNew(); <>4__this.controllers.Clear(); <>4__this.textures.Clear(); <>4__this.revision = <>8__1.newTexturesVariants.revision; <internalThread>5__3 = new Thread((ThreadStart)delegate { DictionaryExt.Copy<string, PrefabController>(<>8__1.<>4__this.controllers, <>8__1.newTexturesVariants.controllers); DictionaryExt.Copy<int, TextureVariants>(<>8__1.<>4__this.textures, <>8__1.newTexturesVariants.textures); }); <internalThread>5__3.Start(); goto IL_0185; } goto IL_021f; case 3: <>1__state = -1; goto IL_0185; case 4: <>1__state = -1; SeasonalTexturePrefabCache.SetCurrentTextureVariants(<>4__this); ClutterVariantController.Reinitialize(); PrefabVariantController.ReinitializePrefabVariants(); <>2__current = Seasons.waitForFixedUpdate; <>1__state = 5; return true; case 5: <>1__state = -1; Seasons.LogInfo($"Colors reinitialized in {<stopwatch>5__2.Elapsed.TotalSeconds,-4:F2} seconds"); <stopwatch>5__2 = null; <internalThread>5__3 = null; goto IL_021f; case 6: { <>1__state = -1; SeasonalTexturePrefabCache.SetCurrentTextureVariants(<>4__this); PrefabVariantController.UpdatePrefabColors(); ClutterVariantController.Instance?.UpdateColors(); return false; } IL_021f: <>2__current = Seasons.waitForFixedUpdate; <>1__state = 6; return true; IL_0185: if (<internalThread>5__3.IsAlive) { <>2__current = Seasons.waitForFixedUpdate; <>1__state = 3; return true; } <>2__current = <>4__this.SaveCacheOnDisk(); <>1__state = 4; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <ReloadCache>d__7 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public SeasonalTextureVariants <>4__this; private <>c__DisplayClass7_0 <>8__1; private Stopwatch <stopwatch>5__2; private Thread <internalThread>5__3; private Dictionary<int, CachedData.TextureData>.Enumerator <>s__4; private KeyValuePair<int, CachedData.TextureData> <texData>5__5; private TextureVariants <texVariants>5__6; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ReloadCache>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <stopwatch>5__2 = null; <internalThread>5__3 = null; <>s__4 = default(Dictionary<int, CachedData.TextureData>.Enumerator); <texData>5__5 = default(KeyValuePair<int, CachedData.TextureData>); <texVariants>5__6 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass7_0(); <>8__1.<>4__this = <>4__this; <stopwatch>5__2 = Stopwatch.StartNew(); <>8__1.cachedData = new CachedData(SeasonalTexturePrefabCache.GetRevision()); <internalThread>5__3 = new Thread((ThreadStart)delegate { <>8__1.cachedData.LoadFromDisk(); }); <internalThread>5__3.Start(); goto IL_00c6; case 1: <>1__state = -1; goto IL_00c6; case 2: <>1__state = -1; goto IL_0236; case 3: <>1__state = -1; PrefabVariantController.UpdatePrefabColors(); ClutterVariantController.Instance.UpdateColors(); Seasons.LogInfo($"Colors reinitialized in {<stopwatch>5__2.Elapsed.TotalSeconds,-4:F2} seconds"); break; case 4: { <>1__state = -1; break; } IL_00c6: if (<internalThread>5__3.IsAlive) { <>2__current = Seasons.waitForFixedUpdate; <>1__state = 1; return true; } if (<>8__1.cachedData.Initialized()) { <>4__this.revision = <>8__1.cachedData.revision; <>s__4 = <>8__1.cachedData.textures.GetEnumerator(); try { while (<>s__4.MoveNext()) { <texData>5__5 = <>s__4.Current; if (!<>4__this.textures.ContainsKey(<texData>5__5.Key)) { <texVariants>5__6 = new TextureVariants(<texData>5__5.Value); if (<texVariants>5__6.Initialized()) { <>4__this.textures.Add(<texData>5__5.Key, <texVariants>5__6); <texVariants>5__6 = null; <texData>5__5 = default(KeyValuePair<int, CachedData.TextureData>); } } } } finally { ((IDisposable)<>s__4).Dispose(); } <>s__4 = default(Dictionary<int, CachedData.TextureData>.Enumerator); <internalThread>5__3 = new Thread((ThreadStart)delegate { DictionaryExt.Copy<string, PrefabController>(<>8__1.<>4__this.controllers, <>8__1.cachedData.controllers); }); <internalThread>5__3.Start(); goto IL_0236; } <>2__current = <>4__this.RebuildCache(); <>1__state = 4; return true; IL_0236: if (<internalThread>5__3.IsAlive) { <>2__current = Seasons.waitForFixedUpdate; <>1__state = 2; return true; } Seasons.LogInfo($"Loaded from cache revision:{<>4__this.revision} controllers:{<>4__this.controllers.Count} textures:{<>4__this.textures.Count} in {<stopwatch>5__2.Elapsed.TotalSeconds,-4:F2} seconds"); <stopwatch>5__2.Restart(); ClutterVariantController.Reinitialize(); PrefabVariantController.ReinitializePrefabVariants(); <>2__current = Seasons.waitForFixedUpdate; <>1__state = 3; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <SaveCacheOnDisk>d__4 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public SeasonalTextureVariants <>4__this; private <>c__DisplayClass4_0 <>8__1; private Thread <internalThread>5__2; private Dictionary<int, TextureVariants>.Enumerator <>s__3; private KeyValuePair<int, TextureVariants> <texVariants>5__4; private CachedData.TextureData <texData>5__5; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SaveCacheOnDisk>d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <internalThread>5__2 = null; <>s__3 = default(Dictionary<int, TextureVariants>.Enumerator); <texVariants>5__4 = default(KeyValuePair<int, TextureVariants>); <texData>5__5 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; } else { <>1__state = -1; if (!<>4__this.Initialized()) { goto IL_01ad; } <>8__1 = new <>c__DisplayClass4_0(); <>8__1.<>4__this = <>4__this; <>8__1.cachedData = new CachedData(<>4__this.revision); <>8__1.cachedData.textures.Clear(); <>s__3 = <>4__this.textures.GetEnumerator(); try { while (<>s__3.MoveNext()) { <texVariants>5__4 = <>s__3.Current; <texData>5__5 = new CachedData.TextureData(<texVariants>5__4.Value); if (<texData>5__5.Initialized()) { <>8__1.cachedData.textures.Add(<texVariants>5__4.Key, <texData>5__5); } <texData>5__5 = null; <texVariants>5__4 = default(KeyValuePair<int, TextureVariants>); } } finally { ((IDisposable)<>s__3).Dispose(); } <>s__3 = default(Dictionary<int, TextureVariants>.Enumerator); <internalThread>5__2 = new Thread((ThreadStart)delegate { DictionaryExt.Copy<string, PrefabController>(<>8__1.cachedData.controllers, <>8__1.<>4__this.controllers); if (Directory.Exists(<>8__1.cachedData.CacheDirectory())) { Directory.Delete(<>8__1.cachedData.CacheDirectory(), recursive: true); } <>8__1.cachedData.SaveOnDisk(); }); <internalThread>5__2.Start(); } if (<internalThread>5__2.IsAlive) { <>2__current = Seasons.waitForFixedUpdate; <>1__state = 1; return true; } <>4__this.ApplyTexturesToGPU(); <>8__1 = null; <internalThread>5__2 = null; goto IL_01ad; IL_01ad: return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public Dictionary<string, PrefabController> controllers = new Dictionary<string, PrefabController>(); public Dictionary<int, TextureVariants> textures = new Dictionary<int, TextureVariants>(); public uint revision = 0u; public bool Initialize(bool force = false) { if (!force && Initialized()) { return true; } controllers.Clear(); textures.Clear(); revision = SeasonalTexturePrefabCache.GetRevision(); CachedData cachedData = new CachedData(revision); if (force && Directory.Exists(cachedData.CacheDirectory())) { Directory.Delete(cachedData.CacheDirectory(), recursive: true); } cachedData.LoadFromDisk(); if (cachedData.Initialized()) { DictionaryExt.Copy<string, PrefabController>(controllers, cachedData.controllers); foreach (KeyValuePair<int, CachedData.TextureData> texture in cachedData.textures) { if (!textures.ContainsKey(texture.Key)) { TextureVariants textureVariants = new TextureVariants(texture.Value); if (textureVariants.Initialized()) { textures.Add(texture.Key, textureVariants); } } } Seasons.LogInfo($"Loaded from cache revision:{revision} controllers:{controllers.Count} textures:{textures.Count}"); } else { SeasonalTexturePrefabCache.SetCurrentTextureVariants(this); Seasons.StartCoroutineSync(SeasonalTexturePrefabCache.FillWithGameData()); Seasons.StartCoroutineSync(SaveCacheOnDisk()); } return Initialized(); } [IteratorStateMachine(typeof(<SaveCacheOnDisk>d__4))] public IEnumerator SaveCacheOnDisk() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SaveCacheOnDisk>d__4(0) { <>4__this = this }; } public bool Initialized() { return controllers.Count > 0 && textures.Count > 0; } public void ApplyTexturesToGPU() { foreach (KeyValuePair<int, TextureVariants> texture in textures) { texture.Value.ApplyTextures(); } } [IteratorStateMachine(typeof(<ReloadCache>d__7))] public IEnumerator ReloadCache() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ReloadCache>d__7(0) { <>4__this = this }; } [IteratorStateMachine(typeof(<RebuildCache>d__8))] public IEnumerator RebuildCache() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <RebuildCache>d__8(0) { <>4__this = this }; } } public class TextureVariants { public Texture2D original; public string originalName; public byte[] originalPNG; public TextureProperties properties; public Dictionary<Seasons.Season, Dictionary<int, Texture2D>> seasons = new Dictionary<Seasons.Season, Dictionary<int, Texture2D>>(); public TextureVariants(CachedData.TextureData texData) { if (texData == null) { return; } properties = texData.properties; foreach (Seasons.Season value3 in Enum.GetValues(typeof(Seasons.Season))) { if (!texData.variants.TryGetValue(value3, out var value)) { continue; } for (int i = 0; i < 4; i++) { if (value.TryGetValue(i, out var value2)) { Texture2D val = properties.CreateTexture(); if (ImageConversion.LoadImage(val, value2, true)) { AddVariant(value3, i, val); } else { Object.Destroy((Object)(object)val); } } } } } public TextureVariants(Texture texture) { SetOriginalTexture(texture); } public void SetOriginalTexture(Texture texture) { original = (Texture2D)(object)((texture is Texture2D) ? texture : null); properties = new TextureProperties((Texture2D)(object)((texture is Texture2D) ? texture : null)); originalName = ((Object)original).name; } public bool Initialized() { return seasons.Any((KeyValuePair<Seasons.Season, Dictionary<int, Texture2D>> season) => season.Value.Count > 0); } public bool HaveOriginalTexture() { return Object.op_Implicit((Object)(object)original); } public void ApplyTextures() { foreach (KeyValuePair<Seasons.Season, Dictionary<int, Texture2D>> season in seasons) { foreach (KeyValuePair<int, Texture2D> item in season.Value) { item.Value.Apply(true, true); } } } public void AddVariant(Seasons.Season season, int variant, Texture2D tex) { if (!seasons.TryGetValue(season, out var value)) { value = new Dictionary<int, Texture2D>(); seasons.Add(season, value); } if (!value.ContainsKey(variant)) { value.Add(variant, tex); } } public Texture2D GetSeasonalVariant(Seasons.Season season, int variant) { if (CustomTextures.HaveCustomTexture(originalName, season, variant, properties, out var texture)) { return texture; } if (seasons.TryGetValue(season, out var value) && value.TryGetValue(variant, out var value2)) { return value2; } return original; } } [Serializable] public class TextureProperties { public TextureFormat format = (TextureFormat)5; public int mipmapCount = 1; public TextureWrapMode wrapMode = (TextureWrapMode)0; public FilterMode filterMode = (FilterMode)0; public int anisoLevel = 1; public float mipMapBias = 0f; public int width = 2; public int height = 2; public TextureProperties(Texture2D tex) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) mipmapCount = ((Texture)tex).mipmapCount; wrapMode = ((Texture)tex).wrapMode; filterMode = ((Texture)tex).filterMode; anisoLevel = ((Texture)tex).anisoLevel; mipMapBias = ((Texture)tex).mipMapBias; width = ((Texture)tex).width; height = ((Texture)tex).height; } public Texture2D CreateTexture() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0054: Expected O, but got Unknown return new Texture2D(width, height, format, mipmapCount, false) { filterMode = filterMode, anisoLevel = anisoLevel, mipMapBias = mipMapBias, wrapMode = wrapMode }; } } [<4c508bcc-8610-420e-91b5-827233b319ed>NullableContext(1)] [<3d2f5245-9c6d-4a00-a06d-4774600fa525>Nullable(0)] internal class CustomConfigs { [<4c508bcc-8610-420e-91b5-827233b319ed>NullableContext(0)] internal class ConfigurationManagerAttributes { [<3d2f5245-9c6d-4a00-a06d-4774600fa525>Nullable(new byte[] { 2, 1 })] [UsedImplicitly] public Action<ConfigEntryBase> CustomDrawer; } [<3d2f5245-9c6d-4a00-a06d-4774600fa525>Nullable(2)] internal static object configManager; [<3d2f5245-9c6d-4a00-a06d-4774600fa525>Nullable(2)] internal static Type configManagerStyles; internal static GUIStyle GetStyle(GUIStyle other) { //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_0051: Expected O, but got Unknown if (configManagerStyles == null) { return other; } FieldInfo fieldInfo = AccessTools.Field(configManagerStyles, "fontSize"); if (fieldInfo == null) { return other; } return new GUIStyle(other) { fontSize = (int)fieldInfo.GetValue(configManagerStyles) }; } internal static void Awake() { Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault([<4c508bcc-8610-420e-91b5-827233b319ed>NullableContext(0)] (Assembly a) => a.GetName().Name == "ConfigurationManager"); Type type = assembly?.GetType("ConfigurationManager.ConfigurationManager"); configManager = ((type == null) ? null : Chainloader.ManagerObject.GetComponent(type)); configManagerStyles = assembly?.GetType("ConfigurationManager.ConfigurationManagerStyles"); } internal static Action<ConfigEntryBase> DrawSeparatedStrings(string splitString) { return delegate(ConfigEntryBase cfg) { //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown bool valueOrDefault = cfg.Description.Tags.Select([<4c508bcc-8610-420e-91b5-827233b319ed>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; GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); List<string> list = new List<string>(); List<string> list2 = ((string)cfg.BoxedValue).Split(new string[1] { splitString }, StringSplitOptions.None).ToList(); for (int i = 0; i < list2.Count; i++) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); string text = list2[i]; string text2 = GUILayout.TextField(text, GetStyle(GUI.skin.textArea), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (text2 != text && !valueOrDefault) { flag = true; } if (GUILayout.Button("x", new GUIStyle(GetStyle(GUI.skin.button)) { fixedWidth = 21f }, Array.Empty<GUILayoutOption>()) && !valueOrDefault) { flag = true; } else { list.Add(text2); } if (GUILayout.Button("+", new GUIStyle(GetStyle(GUI.skin.button)) { fixedWidth = 21f }, Array.Empty<GUILayoutOption>()) && !valueOrDefault) { flag = true; list.Add(""); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); if (flag) { cfg.BoxedValue = string.Join(splitString, list); } }; } internal static Action<ConfigEntryBase> DrawOrderedFixedStrings(string splitString) { return delegate(ConfigEntryBase cfg) { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown bool valueOrDefault = cfg.Description.Tags.Select([<4c508bcc-8610-420e-91b5-827233b319ed>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; GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); string[] array = ((string)cfg.BoxedValue).Split(new string[1] { splitString }, StringSplitOptions.None).ToArray(); for (int i = 0; i < array.Length; i++) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); string text = array[i]; GUILayout.Label(text, GetStyle(GUI.skin.textArea), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (GUILayout.Button("ʌ", new GUIStyle(GetStyle(GUI.skin.button)) { fixedWidth = 21f }, Array.Empty<GUILayoutOption>()) && !valueOrDefault && (flag = i > 0)) { ref string reference = ref array[i]; ref string reference2 = ref array[i - 1]; string text2 = array[i - 1]; string text3 = array[i]; reference = text2; reference2 = text3; } if (GUILayout.Button("v", new GUIStyle(GetStyle(GUI.skin.button)) { fixedWidth = 21f }, Array.Empty<GUILayoutOption>()) && !valueOrDefault && (flag = i < array.Length - 1)) { ref string reference = ref array[i]; ref string reference3 = ref array[i + 1]; string text3 = array[i + 1]; string text2 = array[i]; reference = text3; reference3 = text2; } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); if (flag) { cfg.BoxedValue = string.Join(splitString, array); } }; } } internal static class CustomMusic { internal class MusicSettings { public float m_volume = 1f; public float m_fadeInTime = 3f; public bool m_alwaysFadeout = false; public bool m_loop = true; public bool m_resume = true; public bool m_enabled = true; public bool m_ambientMusic = true; } public const string subdirectory = "Custom music"; public static readonly Dictionary<string, AudioClip> audioClips = new Dictionary<string, AudioClip>(); public static readonly Dictionary<string, MusicSettings> clipSettings = new Dictionary<string, MusicSettings>(); internal static void SetupConfigWatcher() { string filter = "*.*"; FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(GetSubdirectory(), filter); fileSystemWatcher.Changed += UpdateClipOnChange; fileSystemWatcher.Created += UpdateClipOnChange; fileSystemWatcher.Renamed += UpdateClipOnChange; fileSystemWatcher.Deleted += UpdateClipOnChange; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; UpdateCustomMusic(); CheckMusicList(); SeasonEnvironment.ClearCachedObjects(); } internal static void CheckMusicList() { if (!Object.op_Implicit((Object)(object)MusicMan.instance)) { return; } foreach (KeyValuePair<string, AudioClip> clip in audioClips) { (MusicMan.instance.m_music.Find((NamedMusic music) => music.m_name == clip.Key) ?? GetNewMusic(clip.Key)).m_clips = (AudioClip[])(object)new AudioClip[1] { clip.Value }; } } private static NamedMusic GetNewMusic(string name) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown MusicSettings musicSettings = GeneralExtensions.GetValueSafe<string, MusicSettings>(clipSettings, name) ?? new MusicSettings(); NamedMusic val = new NamedMusic { m_name = name, m_ambientMusic = musicSettings.m_ambientMusic, m_resume = musicSettings.m_resume, m_alwaysFadeout = musicSettings.m_alwaysFadeout, m_enabled = musicSettings.m_enabled, m_fadeInTime = musicSettings.m_fadeInTime, m_loop = musicSettings.m_loop, m_volume = musicSettings.m_volume }; MusicMan.instance.m_music.Add(val); return val; } private static string GetSubdirectory() { string text = Path.Combine(Seasons.configDirectory, "Custom music"); Directory.CreateDirectory(text); return text; } private static void UpdateCustomMusic() { string path = GetSubdirectory(); if (!Directory.Exists(path)) { return; } foreach (FileInfo item in from file in new DirectoryInfo(path).EnumerateFiles("*.*", SearchOption.AllDirectories) orderby file.Extension.ToLower() != ".json" select file) { UpdateFile(item.Name, item.FullName); } } private static void UpdateClipOnChange(object sender, FileSystemEventArgs eargs) { UpdateFile(eargs.Name, eargs.FullPath); if (eargs is RenamedEventArgs) { audioClips.Remove(Path.GetFileNameWithoutExtension((eargs as RenamedEventArgs).OldName)); } CheckMusicList(); SeasonEnvironment.ClearCachedObjects(); } private static void UpdateFile(string fileName, string filePath) { if (Path.GetExtension(fileName).Equals(".json", StringComparison.OrdinalIgnoreCase)) { UpdateSettings(Path.GetFileNameWithoutExtension(fileName), filePath); } else { UpdateClip(Path.GetFileNameWithoutExtension(fileName), filePath); } } private static void UpdateClip(string clipName, string fileName) { bool flag = audioClips.Remove(clipName); if (TryGetAudioClip(fileName, out var audioClip)) { audioClips.Add(clipName, audioClip); Seasons.LogInfo("Custom music " + (flag ? "updated" : "added") + ": " + clipName); } } private static void UpdateSettings(string clipName, string fileName) { bool flag = clipSettings.Remove(clipName); if (TryGetMusicSettings(fileName, out var musicSettings)) { clipSettings.Add(clipName, musicSettings); Seasons.LogInfo("Custom music settings " + (flag ? "updated" : "added") + ": " + clipName); } } internal static bool TryGetAudioClip(string path, out AudioClip audioClip) { audioClip = null; string text = "file:///" + path.Replace("\\", "/"); UnityWebRequest audioClip2 = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)0); if (audioClip2 == null) { return false; } audioClip2.SendWebRequest(); while (!audioClip2.isDone) { } if (audioClip2.error != null) { Seasons.LogWarning("Failed to load audio from " + path + ": " + audioClip2.error); return false; } DownloadHandler downloadHandler = audioClip2.downloadHandler; DownloadHandler obj = ((downloadHandler is DownloadHandlerAudioClip) ? downloadHandler : null); audioClip = ((obj != null) ? ((DownloadHandlerAudioClip)obj).audioClip : null); if (Object.op_Implicit((Object)(object)audioClip)) { ((Object)audioClip).name = Path.GetFileNameWithoutExtension(path); return true; } return false; } internal static bool TryGetMusicSettings(string path, out MusicSettings musicSettings) { musicSettings = null; if (!File.Exists(path)) { return false; } try { musicSettings = JsonUtility.FromJson<MusicSettings>(File.ReadAllText(path)); } catch (Exception ex) { Seasons.LogWarning("Error reading file (" + path + ")! Error: " + ex.Message); return false; } return true; } } internal class CustomPrefabs { [HarmonyPatch(typeof(ZNetView), "Awake")] public static class ZNetView_Awake_AddPrefab { [HarmonyPriority(800)] private static bool Prefix() { return !prefabInit; } } [HarmonyPatch(typeof(ZSyncTransform), "Awake")] public static class ZSyncTransform_Awake_AddPrefab { [HarmonyPriority(800)] private static bool Prefix() { return !prefabInit; } } [HarmonyPatch(typeof(ZSyncTransform), "OnEnable")] public static class ZSyncTransform_OnEnable_AddPrefab { [HarmonyPriority(800)] private static bool Prefix() { return !prefabInit; } } [HarmonyPatch(typeof(ItemDrop), "Awake")] public static class ItemDrop_Awake_AddPrefab { [HarmonyPriority(800)] private static bool Prefix() { return !prefabInit; } } [HarmonyPatch(typeof(ItemDrop), "Start")] public static class ItemDrop_Start_AddPrefab { [HarmonyPriority(800)] private static bool Prefix() { return !prefabInit; } } private const string c_rootObjectName = "_shudnalRoot"; private const string c_rootPrefabsName = "Prefabs"; private static GameObject rootObject; private static GameObject rootPrefabs; public static bool prefabInit; private static void InitRootObject() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown if ((Object)(object)rootObject == (Object)null) { rootObject = (GameObject)(((object)GameObject.Find("_shudnalRoot")) ?? ((object)new GameObject("_shudnalRoot"))); } Object.DontDestroyOnLoad((Object)(object)rootObject); if ((Object)(object)rootPrefabs == (Object)null) { Transform obj = rootObject.transform.Find("Prefabs"); rootPrefabs = ((obj != null) ? ((Component)obj).gameObject : null); if ((Object)(object)rootPrefabs == (Object)null) { rootPrefabs = new GameObject("Prefabs"); rootPrefabs.transform.SetParent(rootObject.transform, false); rootPrefabs.SetActive(false); } } } internal static GameObject InitPrefabClone(GameObject prefabToClone, string prefabName) { InitRootObject(); prefabInit = true; GameObject val = Object.Instantiate<GameObject>(prefabToClone, rootPrefabs.transform, false); prefabInit = false; ((Object)val).name = prefabName; return val; } } internal class CustomTextures { public const string texturesSubdirectory = "Custom textures"; public const string defaultsSubdirectory = "Defaults"; public const string versionFileName = "version"; public static readonly Dictionary<string, Dictionary<Seasons.Season, Dictionary<int, Texture2D>>> textures = new Dictionary<string, Dictionary<Seasons.Season, Dictionary<int, Texture2D>>>(); public static Dictionary<string, Tuple<Seasons.Season, int>> seasonVariantsFileNames; public static void SetupConfigWatcher() { string filter = "*.png"; FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(GetSubdirectory(), filter); fileSystemWatcher.Changed += UpdateTexturesOnChange; fileSystemWatcher.Created += UpdateTexturesOnChange; fileSystemWatcher.Renamed += UpdateTexturesOnChange; fileSystemWatcher.Deleted += UpdateTexturesOnChange; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; UpdateTexturesOnChange(); } public static void UpdateTexturesOnChange(object sender = null, FileSystemEventArgs eargs = null) { UpdateTextures(); PrefabVariantController.MaterialVariants.UpdateSeasonalMaterials(); PrefabVariantController.UpdatePrefabColors(); ClutterVariantController.Instance?.UpdateColors(); } public static void UpdateTextures() { foreach (KeyValuePair<string, Dictionary<Seasons.Season, Dictionary<int, Texture2D>>> texture in textures) { foreach (KeyValuePair<Seasons.Season, Dictionary<int, Texture2D>> item in texture.Value) { foreach (KeyValuePair<int, Texture2D> item2 in item.Value) { Object.Destroy((Object)(object)item2.Value); } } } textures.Clear(); if (Seasons.customTextures.Value) { LoadCustomTextures(GetDefaultsSubdirectory()); LoadCustomTextures(GetSubdirectory()); if (textures.Count > 0) { Seasons.LogInfo($"Loaded {textures.Count} custom textures."); } } } public static bool HaveCustomTexture(string textureName, Seasons.Season season, int variant, TextureProperties properties, out Texture2D texture) { texture = null; if (textureName == null) { return false; } Dictionary<Seasons.Season, Dictionary<int, Texture2D>> value; Dictionary<int, Texture2D> value2; bool flag = textures.TryGetValue(textureName, out value) && value.TryGetValue(season, out value2) && value2.TryGetValue(variant, out texture) && (Object)(object)texture != (Object)null; if (flag && ((Texture)texture).isReadable) { Color32[] pixels = texture.GetPixels32(); if (pixels.Length != properties.width * properties.height) { properties.width = ((Texture)texture).width; properties.height = ((Texture)texture).height; properties.mipmapCount = Math.Min(Mathf.FloorToInt(Mathf.Log((float)Math.Min(properties.width, properties.height), 2f)), properties.mipmapCount); } Object.Destroy((Object)(object)texture); texture = properties.CreateTexture(); texture.SetPixels32(pixels); texture.Apply(true, true); textures[textureName][season][variant] = texture; } return flag; } public static void LoadCustomTextures(string path) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown if (!Directory.Exists(path)) { return; } DirectoryInfo[] directories = new DirectoryInfo(path).GetDirectories(); foreach (DirectoryInfo directoryInfo in directories) { if (directoryInfo.Name == "version" || directoryInfo.Name == "Defaults") { continue; } string name = directoryInfo.Name; textures.Remove(name); FileInfo[] files = directoryInfo.GetFiles(); foreach (FileInfo fileInfo in files) { if (!TryGetSeasonVariant(fileInfo.Name, out var season, out var variant)) { continue; } Texture2D val = new Texture2D(2, 2); if (!ImageConversion.LoadImage(val, File.ReadAllBytes(fileInfo.FullName))) { Object.Destroy((Object)(object)val); continue; } ((Object)val).name = name; if (!textures.ContainsKey(name)) { textures.Add(name, new Dictionary<Seasons.Season, Dictionary<int, Texture2D>>()); } if (!textures[name].ContainsKey(season)) { textures[name].Add(season, new Dictionary<int, Texture2D>()); } textures[name][season][variant] = val; } } } public static void SaveDefaults() { string text = GetDefaultsSubdirectory(); if (Directory.Exists(text)) { string text2 = Directory.GetFiles(text, "version").FirstOrDefault(); if (text2 != null && File.ReadAllText(text2) == "1.6.1") { return; } Directory.Delete(text, recursive: true); } Directory.CreateDirectory(text); Assembly executingAssembly = Assembly.GetExecutingAssembly(); string separator = ".Textures."; foreach (string item in from str in executingAssembly.GetManifestResourceNames() where str.IndexOf(separator) != -1 select str) { string text3 = item.Substring(item.IndexOf(separator) + separator.Length); int num = text3.IndexOf('.'); if (num != -1) { string path = text3.Substring(0, num); string text4 = text3.Substring(num + 1); if (TryGetSeasonVariant(text4, out var _, out var _)) { Stream manifestResourceStream = executingAssembly.GetManifestResourceStream(item); byte[] array = new byte[manifestResourceStream.Length]; manifestResourceStream.Read(array, 0, array.Length); File.WriteAllBytes(Path.Combine(Directory.CreateDirectory(Path.Combine(text, path)).FullName, text4), array); } } } File.WriteAllText(Path.Combine(text, "version"), "1.6.1"); } public static string GetSubdirectory() { string text = Path.Combine(Seasons.configDirectory, "Custom textures"); Directory.CreateDirectory(text); return text; } public static string GetDefaultsSubdirectory() { return Path.Combine(GetSubdirectory(), "Defaults"); } public static bool TryGetSeasonVariant(string filename, out Seasons.Season season, out int variant) { if (seasonVariantsFileNames == null) { seasonVariantsFileNames = new Dictionary<string, Tuple<Seasons.Season, int>>(); foreach (Seasons.Season value in Enum.GetValues(typeof(Seasons.Season))) { for (int i = 0; i < 4; i++) { seasonVariantsFileNames[CachedData.SeasonFileName(value, i)] = Tuple.Create(value, i); } } } season = Seasons.Season.Spring; variant = 0; if (!seasonVariantsFileNames.ContainsKey(filename)) { return false; } season = seasonVariantsFileNames[filename].Item1; variant = seasonVariantsFileNames[filename].Item2; return true; } } internal static class CustomSyncedValuesSynchronizer { [CompilerGenerated] private sealed class <AssignAfterServerUpdate>d__6<T> : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public CustomSyncedValue<T> syncedValue; public Func<T> function; public bool assignIfChanged; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <AssignAfterServerUpdate>d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = AssignAfterServerUpdate(syncedValue, function(), assignIfChanged); <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <AssignAfterServerUpdate>d__7<T> : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public CustomSyncedValue<T> syncedValue; public T value; public bool assignIfChanged; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <AssignAfterServerUpdate>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (assignIfChanged && syncedValue.Value.Equals(value)) { return false; } <>2__current = waitForServerUpdate; <>1__state = 1; return true; case 1: <>1__state = -1; syncedValue.AssignLocalValue(value); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <CoroutineCoordinator>d__9 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CoroutineCoordinator>d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; coroutines.Dequeue(); goto IL_005c; } <>1__state = -1; goto IL_0081; IL_005c: if (coroutines.Count > 0) { <>2__current = ((MonoBehaviour)Seasons.instance).StartCoroutine(coroutines.Peek()); <>1__state = 1; return true; } if (coroutines.Count == 0) { return false; } goto IL_0081; IL_0081: bool flag = true; goto IL_005c; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static readonly Queue<IEnumerator> coroutines = new Queue<IEnumerator>(); private static readonly WaitWhile waitForServerUpdate = new WaitWhile((Func<bool>)(() => ConfigSync.ProcessingServerUpdate)); public static void AssignValueSafe<T>(this CustomSyncedValue<T> syncedValue, T value) { AddToQueue(AssignAfterServerUpdate(syncedValue, value, assignIfChanged: false)); } public static void AssignValueSafe<T>(this CustomSyncedValue<T> syncedValue, Func<T> function) { AddToQueue(AssignAfterServerUpdate(syncedValue, function, assignIfChanged: false)); } public static void AssignValueIfChanged<T>(this CustomSyncedValue<T> syncedValue, T value) { AddToQueue(AssignAfterServerUpdate(syncedValue, value, assignIfChanged: true)); } public static void AssignValueIfChanged<T>(this CustomSyncedValue<T> syncedValue, Func<T> function) { AddToQueue(AssignAfterServerUpdate(syncedValue, function, assignIfChanged: true)); } [IteratorStateMachine(typeof(<AssignAfterServerUpdate>d__6<>))] private static IEnumerator AssignAfterServerUpdate<T>(CustomSyncedValue<T> syncedValue, Func<T> function, bool assignIfChanged) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <AssignAfterServerUpdate>d__6<T>(0) { syncedValue = syncedValue, function = function, assignIfChanged = assignIfChanged }; } [IteratorStateMachine(typeof(<AssignAfterServerUpdate>d__7<>))] private static IEnumerator AssignAfterServerUpdate<T>(CustomSyncedValue<T> syncedValue, T value, bool assignIfChanged) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <AssignAfterServerUpdate>d__7<T>(0) { syncedValue = syncedValue, value = value, assignIfChanged = assignIfChanged }; } private static void AddToQueue(IEnumerator coroutine) { coroutines.Enqueue(coroutine); if (coroutines.Count == 1) { ((MonoBehaviour)Seasons.instance).StartCoroutine(CoroutineCoordinator()); } } [IteratorStateMachine(typeof(<CoroutineCoordinator>d__9))] private static IEnumerator CoroutineCoordinator() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CoroutineCoordinator>d__9(0); } } public class IceFloeClimb : MonoBehaviour, Hoverable, Interactable { public float m_useDistance = 3f; public float m_radius = 4f; public bool Interact(Humanoid character, bool hold, bool alt) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (hold) { return false; } if (!InUseDistance(character)) { return false; } ((Component)character).transform.position = Vector3.Lerp(((Component)character).transform.position, ((Component)this).transform.position, 0.35f) + Vector3.up; Physics.SyncTransforms(); return false; } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetHoverText() { if (!InUseDistance((Humanoid)(object)Player.m_localPlayer)) { return ""; } return Localization.instance.Localize("[<color=yellow><b>$KEY_Use</b></color>] $piece_use"); } public string GetHoverName() { return ""; } public bool InUseDistance(Humanoid human) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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) if (((Component)this).transform.position.y - ((Component)human).transform.position.y < 0.5f) { return false; } float num = Vector3.Distance(((Component)human).transform.position, ((Component)this).transform.position) / Mathf.Max(((Component)this).transform.localScale.x, ((Component)this).transform.localScale.z); return m_radius < num && num < m_radius + m_useDistance; } } public class MinimapVariantController : MonoBehaviour { [CompilerGenerated] private sealed class <>c__DisplayClass15_0 { public int num; public MinimapVariantController <>4__this; public float num2; public Thread internalThread; internal void <GenerateWinterWorldMap>b__1() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < <>4__this.m_minimap.m_textureSize; i++) { for (int j = 0; j < <>4__this.m_minimap.m_textureSize; j++) { float num = (float)(j - this.num) * <>4__this.m_minimap.m_pixelSize + this.num2; float num2 = (float)(i - this.num) * <>4__this.m_minimap.m_pixelSize + this.num2; Biome biome = WorldGenerator.instance.GetBiome(num, num2, 0.02f, false); <>4__this.m_mapWinterTexture[i * <>4__this.m_minimap.m_textureSize + j] = Color32.op_Implicit(GetWinterPixelColor(biome)); <>4__this.m_mapTexture[i * <>4__this.m_minimap.m_textureSize + j] = Color32.op_Implicit(Minimap.instance.GetPixelColor(biome)); } } } internal bool <GenerateWinterWorldMap>b__2() { return internalThread.IsAlive; } } [CompilerGenerated] private sealed class <GenerateWinterWorldMap>d__15 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public MinimapVariantController <>4__this; private <>c__DisplayClass15_0 <>8__1; private Stopwatch <stopwatch>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <GenerateWinterWorldMap>d__15(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <stopwatch>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass15_0(); <>8__1.<>4__this = <>4__this; <>8__1.num = <>4__this.m_minimap.m_textureSize / 2; <>8__1.num2 = <>4__this.m_minimap.m_pixelSize / 2f; <>4__this.m_mapWinterTexture = (Color32[])(object)new Color32[<>4__this.m_minimap.m_textureSize * <>4__this.m_minimap.m_textureSize]; <>4__this.m_mapTexture = (Color32[])(object)new Color32[<>4__this.m_minimap.m_textureSize * <>4__this.m_minimap.m_textureSize]; <>2__current = (object)new WaitUntil((Func<bool>)(() => WorldGenerator.instance != null)); <>1__state = 1; return true; case 1: <>1__state = -1; <stopwatch>5__2 = Stopwatch.StartNew(); <>8__1.internalThread = new Thread((ThreadStart)delegate { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < <>8__1.<>4__this.m_minimap.m_textureSize; i++) { for (int j = 0; j < <>8__1.<>4__this.m_minimap.m_textureSize; j++) { float num = (float)(j - <>8__1.num) * <>8__1.<>4__this.m_minimap.m_pixelSize + <>8__1.num2; float num2 = (float)(i - <>8__1.num) * <>8__1.<>4__this.m_minimap.m_pixelSize + <>8__1.num2; Biome biome = WorldGenerator.instance.GetBiome(num, num2, 0.02f, false); <>8__1.<>4__this.m_mapWinterTexture[i * <>8__1.<>4__this.m_minimap.m_textureSize + j] = Color32.op_Implicit(GetWinterPixelColor(biome)); <>8__1.<>4__this.m_mapTexture[i * <>8__1.<>4__this.m_minimap.m_textureSize + j] = Color32.op_Implicit(Minimap.instance.GetPixelColor(biome)); } } }); <>8__1.internalThread.Start(); <>2__current = (object)new WaitWhile((Func<bool>)(() => <>8__1.internalThread.IsAlive)); <>1__state = 2; return true; case 2: <>1__state = -1; <>4__this.m_initialized = true; Seasons.LogInfo($"Minimap variant controller initialized in {<stopwatch>5__2.Elapsed.TotalSeconds,-4:F2} seconds"); <>4__this.UpdateColors(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private Minimap m_minimap; private static MinimapVariantController m_instance; private bool m_initialized = false; private Color32[] m_mapTexture; private Color32[] m_mapWinterTexture; private Texture2D m_forestTex; public static MinimapVariantController instance => m_instance; private void Awake() { m_instance = this; m_minimap = Minimap.instance; } private void Start() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown Texture texture = m_minimap.m_mapLargeShader.GetTexture("_ForestTex"); m_forestTex = new Texture2D(texture.width, texture.height, texture.graphicsFormat, (TextureCreationFlags)0); Graphics.CopyTexture(texture, (Texture)(object)m_forestTex); ((MonoBehaviour)this).StartCoroutine(GenerateWinterWorldMap()); } private void OnDestroy() { RevertTextures(); m_instance = null; } public void RevertTextures() { if (m_initialized) { SetMapTextures(winter: false, m_forestTex); } } public void UpdateColors() { if (m_initialized) { if (!Seasons.controlMinimap.Value) { RevertTextures(); return; } Seasons.Season currentSeason = Seasons.seasonState.GetCurrentSeason(); SetMapTextures(currentSeason == Seasons.Season.Winter, GetSeasonalForestTex(currentSeason)); } } public Texture2D GetSeasonalForestTex(Seasons.Season season) { if (1 == 0) { } Texture2D result = (Texture2D)(season switch { Seasons.Season.Spring => m_forestTex, Seasons.Season.Summer => Seasons.Minimap_Summer_ForestTex, Seasons.Season.Fall => Seasons.Minimap_Fall_ForestTex, Seasons.Season.Winter => Seasons.Minimap_Winter_ForestTex, _ => m_forestTex, }); if (1 == 0) { } return result; } private void SetMapTextures(bool winter, Texture2D forestTex) { try { m_minimap.m_mapTexture.SetPixels32(winter ? m_mapWinterTexture : m_mapTexture); m_minimap.m_mapTexture.Apply(); } catch (Exception ex) { Seasons.LogWarning(string.Format("Error applying {0}map texture length {1} to minimap texture length {2}:\n{3}", winter ? "winter " : "", (winter ? m_mapWinterTexture : m_mapTexture).Length, ((Texture)m_minimap.m_mapTexture).height * ((Texture)m_minimap.m_mapTexture).width, ex)); } m_minimap.m_mapLargeShader.SetTexture("_ForestTex", (Texture)(object)forestTex); m_minimap.m_mapSmallShader.SetTexture("_ForestTex", (Texture)(object)forestTex); } [IteratorStateMachine(typeof(<GenerateWinterWorldMap>d__15))] public IEnumerator GenerateWinterWorldMap() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <GenerateWinterWorldMap>d__15(0) { <>4__this = this }; } public static Color GetWinterPixelColor(Biome biome) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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) if (SeasonState.seasonBiomeSettings.SeasonalWinterMapColors.TryGetValue(biome, out var value)) { return value; } return Object.op_Implicit((Object)(object)Minimap.instance) ? Minimap.instance.GetPixelColor(biome) : Color.white; } } [HarmonyPatch(typeof(Minimap), "Start")] public static class Minimap_Start_MinimapContollerInit { [HarmonyPriority(0)] private static void Postfix(Minimap __instance) { if (Seasons.UseTextureControllers()) { ((Component)((Component)__instance).transform).gameObject.AddComponent<MinimapVariantController>(); } } } [HarmonyPatch(typeof(Minimap), "GenerateWorldMap")] public static class Minimap_GenerateWorldMap_MinimapContollerInit { private static void Postfix() { if (Seasons.UseTextureControllers()) { MinimapVariantController.instance.UpdateColors(); } } } [Serializable] public class SeasonBiomeEnvironments { [Serializable] public class SeasonBiomeEnvironment { public class EnvironmentAdd { public string m_name; public EnvEntry m_environment; public EnvironmentAdd(string name, EnvEntry environment) { m_name = name; m_environment = environment; } } [Serializable] public class EnvironmentRemove { public string m_name; public string m_environment; public EnvironmentRemove(string name, string environment) { m_name = name; m_environment = environment; } } [Serializable] public class EnvironmentReplace { public string m_environment; public string replace_to; public EnvironmentReplace(string environment, string replaceTo) { m_environment = environment; replace_to = replaceTo; } } [Serializable] public class EnvironmentReplacePair { public string m_environment; public string replace_to; } public List<EnvironmentAdd> add = new List<EnvironmentAdd>(); public List<EnvironmentRemove> remove = new List<EnvironmentRemove>(); public List<EnvironmentReplace> replace = new List<EnvironmentReplace>(); } public SeasonBiomeEnvironment Spring = new SeasonBiomeEnvironment(); public SeasonBiomeEnvironment Summer = new SeasonBiomeEnvironment(); public SeasonBiomeEnvironment Fall = new SeasonBiomeEnvironment(); public SeasonBiomeEnvironment Winter = new SeasonBiomeEnvironment(); public SeasonBiomeEnvironments(bool loadDefaults = false) { //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_0147: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Expected O, but got Unknown //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Expected O, but got Unknown //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Expected O, but got Unknown //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Expected O, but got Unknown //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Expected O, but got Unknown //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Expected O, but got Unknown //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Expected O, but got Unknown //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Expected O, but got Unknown //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Expected O, but got Unknown //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Expected O, but got Unknown //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Expected O, but got Unknown //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Expected O, but got Unknown //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Expected O, but got Unknown //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04fd: Expected O, but got Unknown //IL_0513: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Expected O, but got Unknown //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_054e: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Expected O, but got Unknown //IL_057f: Unknown result type (might be due to invalid IL or missing references) //IL_0584: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_059f: Expected O, but got Unknown //IL_05b5: Unknown result type (might be due to invalid IL or missing references) //IL_05ba: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Expected O, but got Unknown //IL_074b: Unknown result type (might be due to invalid IL or missing references) //IL_0750: Unknown result type (might be due to invalid IL or missing references) //IL_075b: Unknown result type (might be due to invalid IL or missing references) //IL_076b: Expected O, but got Unknown //IL_0781: Unknown result type (might be due to invalid IL or missing references) //IL_0786: Unknown result type (might be due to invalid IL or missing references) //IL_0791: Unknown result type (might be due to invalid IL or missing references) //IL_07a1: Expected O, but got Unknown //IL_07b7: Unknown result type (might be due to invalid IL or missing references) //IL_07bc: Unknown result type (might be due to invalid IL or missing references) //IL_07c7: Unknown result type (might be due to invalid IL or missing references) //IL_07d7: Expected O, but got Unknown //IL_07ed: Unknown result type (might be due to invalid IL or missing references) //IL_07f2: Unknown result type (might be due to invalid IL or missing references) //IL_07fd: Unknown result type (might be due to invalid IL or missing references) //IL_080d: Expected O, but got Unknown //IL_0823: Unknown result type (might be due to invalid IL or missing references) //IL_0828: Unknown result type (might be due to invalid IL or missing references) //IL_0833: Unknown result type (might be due to invalid IL or missing references) //IL_0843: Expected O, but got Unknown if (loadDefaults) { Summer.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Clear", "Clear Summer")); Summer.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Misty", "Misty Summer")); Summer.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("DeepForest Mist", "DeepForest Mist Summer")); Summer.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Mistlands_clear", "Mistlands_clear Summer")); Summer.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Heath clear", "Heath clear Summer")); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Meadows", new EnvEntry { m_environment = "Heath clear", m_weight = 2f })); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Black forest", new EnvEntry { m_environment = "LightRain", m_weight = 0.1f })); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Black forest", new EnvEntry { m_environment = "Clear", m_weight = 0.2f })); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Swamp", new EnvEntry { m_environment = "SwampRain Summer", m_weight = 0.1f })); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Swamp", new EnvEntry { m_environment = "Swamp Summer", m_weight = 0.1f })); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Mountain", new EnvEntry { m_environment = "Twilight_Clear", m_weight = 1f })); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Mountain", new EnvEntry { m_environment = "Twilight_Snow", m_weight = 1f })); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Plains", new EnvEntry { m_environment = "ThunderStorm", m_weight = 0.1f })); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Ocean", new EnvEntry { m_environment = "Heath clear", m_weight = 1f })); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Mistlands", new EnvEntry { m_environment = "Heath clear", m_weight = 0.5f })); Fall.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("ThunderStorm", "ThunderStorm Fall")); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Meadows", new EnvEntry { m_environment = "DeepForest Mist", m_weight = 0.2f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Meadows", new EnvEntry { m_environment = "SwampRain Fall", m_weight = 0.2f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Black forest", new EnvEntry { m_environment = "LightRain", m_weight = 0.1f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Black forest", new EnvEntry { m_environment = "SwampRain Fall", m_weight = 0.1f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Swamp", new EnvEntry { m_environment = "ThunderStorm", m_weight = 0.1f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Mountain", new EnvEntry { m_environment = "Twilight_SnowStorm", m_weight = 0.5f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Plains", new EnvEntry { m_environment = "Rain", m_weight = 0.4f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Plains", new EnvEntry { m_environment = "ThunderStorm", m_weight = 0.2f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Plains", new EnvEntry { m_environment = "SwampRain Fall", m_weight = 0.1f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Ocean", new EnvEntry { m_environment = "SwampRain Fall", m_weight = 0.1f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Ocean", new EnvEntry { m_environment = "DeepForest Mist", m_weight = 0.1f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Mistlands", new EnvEntry { m_environment = "SwampRain Fall", m_weight = 0.1f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Mistlands", new EnvEntry { m_environment = "DeepForest Mist", m_weight = 0.1f })); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Rain", "Rain Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("LightRain", "LightRain Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("ThunderStorm", "ThunderStorm Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Clear", "Clear Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Misty", "Misty Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("DeepForest Mist", "DeepForest Mist Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("SwampRain", "SwampRain Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Mistlands_clear", "Mistlands_clear Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Mistlands_rain", "Mistlands_rain Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Mistlands_thunder", "Mistlands_thunder Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Heath clear", "Heath clear Winter")); Winter.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Mountain", new EnvEntry { m_environment = "Twilight_SnowStorm", m_weight = 1f })); Winter.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Plains", new EnvEntry { m_environment = "Snow", m_weight = 0.5f })); Winter.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Ocean", new EnvEntry { m_environment = "Darklands_dark Winter", m_weight = 0.1f })); Winter.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Mistlands", new EnvEntry { m_environment = "Twilight_Snow", m_weight = 0.1f })); Winter.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Mistlands", new EnvEntry { m_environment = "Twilight_SnowStorm", m_weight = 0.1f })); } } public SeasonBiomeEnvironment GetSeasonBiomeEnvironment(Seasons.Season season) { if (1 == 0) { } SeasonBiomeEnvironment result = season switch { Seasons.Season.Spring => Spring, Seasons.Season.Summer => Summer, Seasons.Season.Fall => Fall, Seasons.Season.Winter => Winter, _ => new SeasonBiomeEnvironment(), }; if (1 == 0) { } return result; } } [Serializable] public class SeasonBiomeSettings { [Serializable] public class SeasonalBiomeColors { public string biome; public string spring; public string summer; public string fall; public string winter; public Biome GetBiome() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) return ParseBiome(biome); } public Dictionary<Seasons.Season, Biome> GetSeasonalOverride() { //IL_0021: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) Dictionary<Seasons.Season, Biome> dictionary = new Dictionary<Seasons.Season, Biome>(); if (!Utility.IsNullOrWhiteSpace(spring)) { dictionary.Add(Seasons.Season.Spring, ParseBiome(spring)); } if (!Utility.IsNullOrWhiteSpace(summer)) { dictionary.Add(Seasons.Season.Summer, ParseBiome(summer)); } if (!Utility.IsNullOrWhiteSpace(fall)) { dictionary.Add(Seasons.Season.Fall, ParseBiome(fall)); } if (!Utility.IsNullOrWhiteSpace(winter)) { dictionary.Add(Seasons.Season.Winter, ParseBiome(winter)); } return dictionary; } } public static Color s_meadowsColor = new Color(0.573f, 0.655f, 0.361f); public static Color s_blackforestColor = new Color(0.42f, 0.455f, 0.247f); public static Color s_heathColor = new Color(0.906f, 0.671f, 0.47f); public static Color s_swampColor = new Color(0.639f, 0.447f, 0.345f); public static Color s_mistlandsColor = new Color(0.2f, 0.2f, 0.2f); [NonSerialized] private Dictionary<Biome, Dictionary<Seasons.Season, Biome>> _seasonalBiomeColorOverride; [NonSerialized] private Dictionary<Biome, Color> _seasonalWinterMapColors; [NonSerialized] private static readonly Dictionary<Color, Color> s_winterColors = new Dictionary<Color, Color>(); [NonSerialized] private static readonly Dictionary<string, Biome> s_nameToBiome = new Dictionary<string, Biome>(); public List<SeasonalBiomeColors> seasonalGroundColors = new List<SeasonalBiomeColors>(); public Dictionary<string, string> winterMapColors = new Dictionary<string, string>(); [JsonIgnore] internal Dictionary<Biome, Dictionary<Seasons.Season, Biome>> SeasonalBiomeColorOverride { get { if (_seasonalBiomeColorOverride == null) { ParseSeasonalGroundColors(); } return _seasonalBiomeColorOverride; } } [JsonIgnore] internal Dictionary<Biome, Color> SeasonalWinterMapColors { get { if (_seasonalWinterMapColors == null) { ParseWinterMapColors(); } return _seasonalWinterMapColors; } } public SeasonBiomeSettings(bool loadDefaults = false) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) if (loadDefaults) { s_nameToBiome.Clear(); List<SeasonalBiomeColors> list = seasonalGroundColors; SeasonalBiomeColors seasonalBiomeColors = new SeasonalBiomeColors(); Biome val = (Biome)1; seasonalBiomeColors.biome = ((object)(Biome)(ref val)).ToString(); val = (Biome)16; seasonalBiomeColors.fall = ((object)(Biome)(ref val)).ToString(); val = (Biome)4; seasonalBiomeColors.winte