Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Seasonality v3.8.6
Seasonality.dll
Decompiled a week 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.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.UI; using YamlDotNet.Serialization; [assembly: Guid("E0E2F92E-557C-4A05-9D89-AA92A0BD75C4")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyProduct("Seasonality")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyDescription("")] [assembly: AssemblyTitle("Seasonality")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyFileVersion("3.8.6")] [assembly: AssemblyCompany("RustyMods")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("3.8.6.0")] [module: <1f2331bd-34fa-421a-9641-ba1ee3526a9d>RefSafetyRules(11)] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<808f1b38-fc7b-4bb9-ac98-3341bde98eb3>Embedded] internal sealed class <808f1b38-fc7b-4bb9-ac98-3341bde98eb3>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [<808f1b38-fc7b-4bb9-ac98-3341bde98eb3>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<808f1b38-fc7b-4bb9-ac98-3341bde98eb3>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContextAttribute : Attribute { public readonly byte Flag; public <02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContextAttribute(byte P_0) { Flag = P_0; } } [<808f1b38-fc7b-4bb9-ac98-3341bde98eb3>Embedded] [CompilerGenerated] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class <1f2331bd-34fa-421a-9641-ba1ee3526a9d>RefSafetyRulesAttribute : Attribute { public readonly int Version; public <1f2331bd-34fa-421a-9641-ba1ee3526a9d>RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LocalizationManager { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] [PublicAPI] [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(0)] public class Localizer { private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors; private static readonly Dictionary<string, Dictionary<string, string>> loadedTexts; private static readonly ConditionalWeakTable<Localization, string> localizationLanguage; private static readonly List<WeakReference<Localization>> localizationObjects; [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(2)] private static BaseUnityPlugin _plugin; private static readonly List<string> fileExtensions; private static BaseUnityPlugin plugin { get { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown if (_plugin == null) { IEnumerable<TypeInfo> source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(2)] [method: <02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(2)] [field: <4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(2)] public static event Action OnLocalizationComplete; private static void UpdatePlaceholderText(Localization localization, string key) { localizationLanguage.TryGetValue(localization, out var value); string text = loadedTexts[value][key]; if (PlaceholderProcessors.TryGetValue(key, out var value2)) { text = value2.Aggregate(text, [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] (string current, KeyValuePair<string, Func<string>> kv) => current.Replace("{" + kv.Key + "}", kv.Value())); } localization.AddWord(key, text); } public static void AddPlaceholder<T>(string key, string placeholder, ConfigEntry<T> config, [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null) { if (convertConfigValue == null) { convertConfigValue = (T val) => val.ToString(); } if (!PlaceholderProcessors.ContainsKey(key)) { PlaceholderProcessors[key] = new Dictionary<string, Func<string>>(); } config.SettingChanged += [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] (object _, EventArgs _) => { UpdatePlaceholder(); }; if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage())) { UpdatePlaceholder(); } void UpdatePlaceholder() { PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value); UpdatePlaceholderText(Localization.instance, key); } } public static void AddText(string key, string text) { List<WeakReference<Localization>> list = new List<WeakReference<Localization>>(); foreach (WeakReference<Localization> localizationObject in localizationObjects) { if (localizationObject.TryGetTarget(out var target)) { Dictionary<string, string> dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)]; if (!target.m_translations.ContainsKey(key)) { dictionary[key] = text; target.AddWord(key, text); } } else { list.Add(localizationObject); } } foreach (WeakReference<Localization> item in list) { localizationObjects.Remove(item); } } public static void Load() { _ = plugin; } public static void LoadLocalizationLater(Localization __instance) { LoadLocalization(Localization.instance, __instance.GetSelectedLanguage()); } public static void SafeCallLocalizeComplete() { Localizer.OnLocalizationComplete?.Invoke(); } private static void LoadLocalization(Localization __instance, string language) { //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Expected O, but got Unknown if (!localizationLanguage.Remove(__instance)) { localizationObjects.Add(new WeakReference<Localization>(__instance)); } localizationLanguage.Add(__instance, language); Dictionary<string, string> dictionary = new Dictionary<string, string>(); foreach (string item in from f in Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories) where fileExtensions.IndexOf(Path.GetExtension(f)) >= 0 select f) { string[] array = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' }); if (array.Length >= 2) { string text = array[1]; if (dictionary.ContainsKey(text)) { Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped.")); } else { dictionary[text] = item; } } } byte[] array2 = LoadTranslationFromAssembly("English"); if (array2 == null) { throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml."); } Dictionary<string, string> dictionary2 = ((BuilderSkeleton<DeserializerBuilder>)new DeserializerBuilder()).IgnoreFields().Build().Deserialize<Dictionary<string, string>>(Encoding.UTF8.GetString(array2)); if (dictionary2 == null) { throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty."); } string text2 = null; if (language != "English") { if (dictionary.TryGetValue(language, out var value)) { text2 = File.ReadAllText(value); } else { byte[] array3 = LoadTranslationFromAssembly(language); if (array3 != null) { text2 = Encoding.UTF8.GetString(array3); } } } if (text2 == null && dictionary.TryGetValue("English", out var value2)) { text2 = File.ReadAllText(value2); } if (text2 != null) { foreach (KeyValuePair<string, string> item2 in ((BuilderSkeleton<DeserializerBuilder>)new DeserializerBuilder()).IgnoreFields().Build().Deserialize<Dictionary<string, string>>(text2) ?? new Dictionary<string, string>()) { dictionary2[item2.Key] = item2.Value; } } loadedTexts[language] = dictionary2; foreach (KeyValuePair<string, string> item3 in dictionary2) { UpdatePlaceholderText(__instance, item3.Key); } } static Localizer() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown PlaceholderProcessors = new Dictionary<string, Dictionary<string, Func<string>>>(); loadedTexts = new Dictionary<string, Dictionary<string, string>>(); localizationLanguage = new ConditionalWeakTable<Localization, string>(); localizationObjects = new List<WeakReference<Localization>>(); fileExtensions = new List<string>(2) { ".json", ".yml" }; Harmony val = new Harmony("org.bepinex.helpers.LocalizationManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "SetupLanguage", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "SetupGui", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalizationLater", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "SafeCallLocalizeComplete", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } [return: <4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(2)] private static byte[] LoadTranslationFromAssembly(string language) { foreach (string fileExtension in fileExtensions) { byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension); if (array != null) { return array; } } return null; } [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(2)] public static byte[] ReadEmbeddedFileBytes([<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(1)] string resourceFileName, Assembly containingAssembly = null) { using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] (string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal)); if (text != null) { containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream); } return (memoryStream.Length == 0L) ? null : memoryStream.ToArray(); } } public static class LocalizationManagerVersion { [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(1)] public const string Version = "1.4.1"; } } namespace Seasonality { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(0)] public class SeasonalIceMineRock : MonoBehaviour { public static readonly List<SeasonalIceMineRock> m_instances = new List<SeasonalIceMineRock>(); public MineRock5 m_mineRock5; public ZNetView m_nview; public void Awake() { m_nview = ((Component)this).GetComponent<ZNetView>(); m_mineRock5 = ((Component)this).GetComponent<MineRock5>(); m_instances.Add(this); ((MonoBehaviour)this).InvokeRepeating("CheckSeason", 0f, 1f); } public static void UpdateAll() { foreach (SeasonalIceMineRock instance in m_instances) { instance.CheckSeason(); } } public void CheckSeason() { if (!((Object)(object)m_nview == (Object)null) && !((Object)(object)m_mineRock5 == (Object)null) && m_nview.IsValid() && m_nview.IsOwner() && SeasonTime.GetCurrentSeason() != Season.Winter) { m_nview.Destroy(); m_mineRock5.m_allDestroyed = true; } } } [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(0)] public class SeasonalIce : MonoBehaviour { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] [HarmonyPatch(typeof(ZoneSystem), "SpawnZone")] private static class ZoneSystem_SpawnZone_Patch { private static void Prefix() { UpdateZoneVeg(); } } private static readonly List<ZoneVegetation> list = new List<ZoneVegetation>(); private static readonly List<SeasonalIce> m_instances = new List<SeasonalIce>(); private Destructible m_destructible = null; public void Awake() { m_destructible = ((Component)this).GetComponent<Destructible>(); m_instances.Add(this); ((MonoBehaviour)this).InvokeRepeating("CheckSeason", 0f, 1f); } public void OnDestroy() { m_instances.Remove(this); } public void CheckSeason() { if (SeasonTime.GetCurrentSeason() != Season.Winter) { m_destructible.DestroyNow(); } } public static void UpdateAll() { foreach (SeasonalIce instance in m_instances) { instance.CheckSeason(); } } public static void UpdateZoneVeg() { if (!Object.op_Implicit((Object)(object)ZoneSystem.instance)) { return; } if (SeasonTime.GetCurrentSeason() == Season.Winter && Configs.m_addIceShelves.Value == Toggle.On) { foreach (ZoneVegetation item in list) { if (!ZoneSystem.instance.m_vegetation.Contains(item)) { ZoneSystem.instance.m_vegetation.Add(item); } } return; } foreach (ZoneVegetation item2 in list) { ZoneSystem.instance.m_vegetation.Remove(item2); } } public static void Setup() { Clone clone = new Clone("ice1", "SeasonalIce"); clone.OnCreated += delegate(GameObject p) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) p.AddComponent<SeasonalIce>(); DropOnDestroyed val = default(DropOnDestroyed); if (p.TryGetComponent<DropOnDestroyed>(ref val)) { Object.Destroy((Object)(object)val); } ZoneVegetation val2 = new ZoneVegetation(); val2.m_name = "Seasonality Ice"; val2.m_prefab = p; val2.m_min = 7f; val2.m_max = 13f; val2.m_biome = (Biome)539; val2.m_biomeArea = (BiomeArea)3; val2.m_blockCheck = true; val2.m_minAltitude = -1000f; val2.m_maxAltitude = -19f; val2.m_snapToWater = true; val2.m_maxTerrainDelta = 2f; list.Add(val2); }; Clone clone2 = new Clone("IceShore_1", "SeasonalIceShore_1"); clone2.OnCreated += delegate(GameObject p) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) p.AddComponent<SeasonalIce>(); Destructible val = default(Destructible); if (p.TryGetComponent<Destructible>(ref val)) { GameObject spawnWhenDestroyed = val.m_spawnWhenDestroyed; if ((Object)(object)spawnWhenDestroyed != (Object)null) { GameObject val2 = Object.Instantiate<GameObject>(spawnWhenDestroyed, CloneManager.GetRootTransform(), false); ((Object)val2).name = "Seasonal_IceShore_frac"; MineRock5 val3 = default(MineRock5); if (val2.TryGetComponent<MineRock5>(ref val3)) { val3.m_dropItems.m_drops.Clear(); } val2.AddComponent<SeasonalIceMineRock>(); val.m_spawnWhenDestroyed = val2; PrefabManager.RegisterPrefab(val2); CloneManager.prefabs[((Object)val2).name] = val2; } } ZoneVegetation val4 = new ZoneVegetation(); val4.m_name = "Seasonality Ice Shore 1"; val4.m_prefab = p; val4.m_min = 5f; val4.m_max = 10f; val4.m_biome = (Biome)539; val4.m_biomeArea = (BiomeArea)3; val4.m_blockCheck = true; val4.m_minAltitude = -20f; val4.m_maxAltitude = 0.5f; val4.m_snapToWater = true; val4.m_groundOffset = -0.9f; list.Add(val4); ZoneVegetation val5 = new ZoneVegetation(); val5.m_name = "Seasonality Ice Shore 2"; val5.m_prefab = p; val5.m_min = 5f; val5.m_max = 10f; val5.m_biome = (Biome)539; val5.m_biomeArea = (BiomeArea)3; val5.m_blockCheck = true; val5.m_minAltitude = -20f; val5.m_maxAltitude = 0.5f; val5.m_snapToWater = true; val5.m_groundOffset = -0.6f; list.Add(val5); }; } } public static class SnowBuildUp { [HarmonyPatch(typeof(WearNTear), "UpdateWear")] private static class WearNTear_UpdateWear { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Prefix(WearNTear __instance, float time) { UpdateSnow(__instance); } } [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void UpdateSnow(WearNTear wnt) { //IL_0029: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 if (!wnt.m_nview.IsValid() || !wnt.m_nview.IsOwner()) { return; } Biome biome = wnt.m_biome; bool flag = (((int)biome == 32 || (int)biome == 64) ? true : false); if (flag || !Object.op_Implicit((Object)(object)wnt.m_snow)) { return; } if (SeasonTime.m_currentSeason == Season.Winter && Configs.m_addSnow.Value == Toggle.On) { if (wnt.HaveRoof()) { if (!(wnt.m_snowBuildup <= 0f)) { wnt.m_nview.GetZDO().Set(ZDOVars.s_snow, 0f); } } else if (!(wnt.m_snowBuildup >= 1f)) { float num = Mathf.Max(0.26f, Mathf.Clamp01(wnt.m_snowBuildup + Configs.m_snowBuildupSpeed.Value)); wnt.m_nview.GetZDO().Set(ZDOVars.s_snow, num); } } else if (!(wnt.m_snowBuildup <= 0f)) { wnt.m_nview.GetZDO().Set(ZDOVars.s_snow, 0f); } } } public class RandomColors : MonoBehaviour { [HarmonyPatch(typeof(ZNetScene), "Awake")] private static class ZNetScene_Awake_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Postfix(ZNetScene __instance) { foreach (string name in new StringListConfig(Configs.m_fallObjects.Value).m_names) { GameObject prefab = __instance.GetPrefab(name); if (prefab != null) { prefab.AddComponent<RandomColors>(); m_modifiedPrefabs.Add(prefab); } } Configs.m_fallObjects.SettingChanged += delegate { RandomColors randomColors = default(RandomColors); foreach (GameObject modifiedPrefab in m_modifiedPrefabs) { if (modifiedPrefab.TryGetComponent<RandomColors>(ref randomColors)) { Object.Destroy((Object)(object)randomColors); } } m_modifiedPrefabs.Clear(); foreach (string name2 in new StringListConfig(Configs.m_fallObjects.Value).m_names) { GameObject prefab2 = __instance.GetPrefab(name2); if (prefab2 != null) { prefab2.AddComponent<RandomColors>(); m_modifiedPrefabs.Add(prefab2); } } }; } } [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(new byte[] { 2, 1 })] public Renderer[] m_renderers; [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(2)] public ParticleSystem m_particleSystem; public MinMaxGradient m_originalGradient; [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(1)] public static readonly List<RandomColors> m_instances = new List<RandomColors>(); [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(1)] private static readonly List<GameObject> m_modifiedPrefabs = new List<GameObject>(); public void Awake() { if (Configs.m_randomColors.Value != Toggle.Off && new StringListConfig(Configs.m_fallObjects.Value).m_names.Contains(((Object)this).name.Replace("(Clone)", string.Empty))) { m_renderers = ((Component)this).GetComponentsInChildren<Renderer>(true); m_particleSystem = ((Component)this).GetComponentInChildren<ParticleSystem>(); m_instances.Add(this); } } public void Start() { //IL_00f5: 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_00ff: 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) if (m_renderers != null) { Renderer[] renderers = m_renderers; foreach (Renderer val in renderers) { if (val.sharedMaterials == null) { continue; } Material[] sharedMaterials = val.sharedMaterials; for (int j = 0; j < sharedMaterials.Length; j++) { if (!((Object)(object)sharedMaterials[j] == (Object)null)) { string key = ((Object)sharedMaterials[j]).name.Replace("(Instance)", string.Empty).Trim(); if (TextureReplacer.m_fallMaterials.TryGetValue(key, out var value)) { sharedMaterials[j] = value[Random.Range(0, value.Count)].m_material; } } } val.sharedMaterials = sharedMaterials; } } if ((Object)(object)m_particleSystem != (Object)null) { MainModule main = m_particleSystem.main; m_originalGradient = ((MainModule)(ref main)).startColor; } UpdateParticleColors(); } public void OnDestroy() { m_instances.Remove(this); } public static void UpdateAll() { foreach (RandomColors instance in m_instances) { instance.UpdateParticleColors(); } } public void UpdateParticleColors() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_00a3: 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_00d7: 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_00ed: 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_010e: Unknown result type (might be due to invalid IL or missing references) if (Configs.m_particlesController.Value != Toggle.Off && !((Object)(object)m_particleSystem == (Object)null)) { MainModule main = m_particleSystem.main; m_originalGradient = ((MainModule)(ref main)).startColor; MinMaxGradient startColor; switch (SeasonTime.GetCurrentSeason()) { case Season.Fall: startColor = default(MinMaxGradient); ((MinMaxGradient)(ref startColor)).color = Color32.op_Implicit(new Color32((byte)205, (byte)92, (byte)92, byte.MaxValue)); ((MinMaxGradient)(ref startColor)).colorMax = Color32.op_Implicit(new Color32((byte)218, (byte)165, (byte)32, byte.MaxValue)); ((MinMaxGradient)(ref startColor)).colorMin = Color32.op_Implicit(new Color32((byte)233, (byte)116, (byte)81, byte.MaxValue)); ((MinMaxGradient)(ref startColor)).mode = (ParticleSystemGradientMode)4; ((MainModule)(ref main)).startColor = startColor; break; case Season.Winter: startColor = default(MinMaxGradient); ((MinMaxGradient)(ref startColor)).color = Color.white; ((MinMaxGradient)(ref startColor)).mode = (ParticleSystemGradientMode)0; ((MainModule)(ref main)).startColor = startColor; break; default: ((MainModule)(ref main)).startColor = m_originalGradient; break; } } } } [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(0)] public class FrozenWaterLOD : MonoBehaviour { [HarmonyPatch(typeof(Game), "Start")] [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] private static class Game_Start_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Postfix(Game __instance) { if (!Object.op_Implicit((Object)(object)__instance)) { return; } try { ((Component)Utils.FindChild(((Component)__instance).gameObject.transform, "WaterPlane", (IterativeSearchType)0).GetChild(0)).gameObject.AddComponent<FrozenWaterLOD>(); } catch { SeasonalityPlugin.Record.LogDebug("Failed to find water LOD"); } } } public Vector3 m_originalPos; public MeshRenderer m_renderer = null; public Material m_originalMat = null; public static Material m_frozenMat = null; public bool m_frozen; private static readonly List<FrozenWaterLOD> Instances = new List<FrozenWaterLOD>(); public static void UpdateAll() { foreach (FrozenWaterLOD instance in Instances) { if (SeasonTime.GetCurrentSeason() == Season.Winter && Configs.m_waterFreezes.Value == Toggle.On) { instance.Freeze(); } else { instance.Thaw(); } } } public void Awake() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown m_originalPos = ((Component)this).transform.position; m_renderer = ((Component)this).GetComponent<MeshRenderer>(); m_originalMat = ((Renderer)m_renderer).material; if ((Object)(object)m_frozenMat == (Object)null) { m_frozenMat = new Material(((Renderer)m_renderer).material); SetupFrozenMat(); } SetInitialValues(); Instances.Add(this); } private void SetInitialValues() { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //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) if (Object.op_Implicit((Object)(object)m_renderer)) { if (Configs.m_waterFreezes.Value == Toggle.On && SeasonTime.GetCurrentSeason() == Season.Winter) { ((Renderer)m_renderer).material = m_frozenMat; ((Component)this).transform.position = m_originalPos + new Vector3(0f, -0.2f, 0f); m_frozen = true; } else { ((Renderer)m_renderer).material = m_originalMat; ((Component)this).transform.position = m_originalPos; m_frozen = false; } } } public static void SetupFrozenMat() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) Texture texture = SeasonalityPlugin.FrozenWaterMat1.GetTexture("_IceNormal"); m_frozenMat.SetTexture("_Normal", texture); m_frozenMat.SetFloat("_NormalScale", 0.8f); m_frozenMat.SetColor("_SurfaceColor", new Color(0f, 0.64f, 0.75f, 1f)); } public void OnDestroy() { Instances.Remove(this); } public void Thaw() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (m_frozen) { ((Renderer)m_renderer).material = m_originalMat; ((Component)this).transform.position = m_originalPos; m_frozen = false; } } public void Freeze() { //IL_0025: 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_003e: Unknown result type (might be due to invalid IL or missing references) if (!m_frozen) { ((Renderer)m_renderer).material = m_frozenMat; ((Component)this).transform.position = m_originalPos + new Vector3(0f, -0.2f, 0f); m_frozen = true; } } } [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(0)] public class FrozenZones : MonoBehaviour { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] [HarmonyPatch(typeof(Fish), "Awake")] private static class Fish_Awake_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Postfix(Fish __instance) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (SeasonTime.GetCurrentSeason() == Season.Winter && Configs.m_waterFreezes.Value == Toggle.On && ((Component)__instance).transform.position.y >= ZoneSystem.instance.m_waterLevel - 1f) { Transform transform = ((Component)__instance).transform; transform.position += new Vector3(0f, -2f, 0f); } } } [HarmonyPatch(typeof(Character), "UpdateWalking")] [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(0)] private static class Character_UpdateWalking_Patch { private static readonly FieldInfo m_slippingField = AccessTools.Field(typeof(Character), "m_slipping"); private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Stfld && list[i].operand is FieldInfo fieldInfo && fieldInfo == m_slippingField) { List<CodeInstruction> list2 = new List<CodeInstruction>(); list2.Add(new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list2.Add(new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list2.Add(new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list2.Add(new CodeInstruction(OpCodes.Ldfld, (object)m_slippingField)); list2.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Character_UpdateWalking_Patch), "ForceSlipOnWater", (Type[])null, (Type[])null))); list2.Add(new CodeInstruction(OpCodes.Stfld, (object)m_slippingField)); List<CodeInstruction> collection = list2; list.InsertRange(i + 1, collection); break; } } return list; } private static bool ForceSlipOnWater(Character instance, bool originalValue) { if (SeasonTime.GetCurrentSeason() != Season.Winter || Configs.m_waterFreezes.Value == Toggle.Off) { return originalValue; } Collider lastGroundCollider = instance.m_lastGroundCollider; if ((Object)(object)lastGroundCollider != (Object)null && ((Component)lastGroundCollider).gameObject.layer == LayerMask.NameToLayer("Water")) { return true; } return originalValue; } } [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] [HarmonyPatch(typeof(ZoneSystem), "Start")] private static class ZoneSystem_Start_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Postfix(ZoneSystem __instance) { if (Object.op_Implicit((Object)(object)__instance)) { __instance.m_zonePrefab.AddComponent<FrozenZones>(); } } } public MeshCollider m_surfaceCollider = null; public MeshRenderer m_surfaceRenderer = null; public WaterVolume m_waterVolume = null; public Material m_originalMaterial = null; private static readonly List<FrozenZones> Instances = new List<FrozenZones>(); public bool m_frozen; [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(2)] private static PhysicsMaterial _slipMat; private static Material m_frozenMat; [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(2)] private static PhysicsMaterial m_slipperyMat { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(2)] get { if ((Object)(object)_slipMat != (Object)null) { return _slipMat; } _slipMat = ((IEnumerable<PhysicsMaterial>)Resources.FindObjectsOfTypeAll<PhysicsMaterial>()).FirstOrDefault((Func<PhysicsMaterial, bool>)([<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] (PhysicsMaterial m) => ((Object)m).name == "SlipperyIce")); return _slipMat; } } public static void UpdateAll() { foreach (FrozenZones instance in Instances) { if (Configs.m_waterFreezes.Value == Toggle.Off) { instance.ThawWater(); } else if (SeasonTime.GetCurrentSeason() == Season.Winter) { instance.FreezeWater(); } else { instance.ThawWater(); } } } public void Awake() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown Transform val = ((Component)this).transform.Find("Water"); Transform val2 = val.Find("WaterSurface"); Transform val3 = val.Find("WaterVolume"); MeshFilter component = ((Component)val2).GetComponent<MeshFilter>(); m_surfaceRenderer = ((Component)val2).GetComponent<MeshRenderer>(); m_waterVolume = ((Component)val3).GetComponent<WaterVolume>(); m_surfaceCollider = ((Component)val2).gameObject.AddComponent<MeshCollider>(); m_originalMaterial = ((Renderer)m_surfaceRenderer).material; if ((Object)(object)m_frozenMat == (Object)null) { m_frozenMat = new Material(((Renderer)m_surfaceRenderer).material); SetupFrozenMat(); } m_surfaceCollider.sharedMesh = component.sharedMesh; ((Collider)m_surfaceCollider).material = m_slipperyMat; SetInitialValues(); if (!Instances.Contains(this)) { Instances.Add(this); } } public void OnDestroy() { Instances.Remove(this); } public static void SetupFrozenMat() { Texture texture = SeasonalityPlugin.FrozenWaterMat1.GetTexture("_IceNormal"); m_frozenMat.SetTexture("_Normal", texture); m_frozenMat.SetFloat("_NormalScale", 1f); } private void SetInitialValues() { if (SeasonTime.GetCurrentSeason() == Season.Winter && Configs.m_waterFreezes.Value == Toggle.On) { ((Renderer)m_surfaceRenderer).material = m_frozenMat; ((Collider)m_surfaceCollider).enabled = true; m_waterVolume.m_useGlobalWind = false; m_frozen = true; } else { ((Renderer)m_surfaceRenderer).material = m_originalMaterial; ((Collider)m_surfaceCollider).enabled = false; m_waterVolume.m_useGlobalWind = true; m_frozen = false; } } public void FreezeWater() { if (Object.op_Implicit((Object)(object)m_surfaceCollider) && Object.op_Implicit((Object)(object)m_surfaceCollider) && Object.op_Implicit((Object)(object)m_waterVolume) && !m_frozen) { ((Renderer)m_surfaceRenderer).material = m_frozenMat; ((Collider)m_surfaceCollider).enabled = true; m_waterVolume.m_useGlobalWind = false; m_frozen = true; } } public void ThawWater() { if (Object.op_Implicit((Object)(object)m_surfaceCollider) && Object.op_Implicit((Object)(object)m_surfaceCollider) && Object.op_Implicit((Object)(object)m_waterVolume) && m_frozen) { ((Renderer)m_surfaceRenderer).material = m_originalMaterial; ((Collider)m_surfaceCollider).enabled = false; m_waterVolume.m_useGlobalWind = true; m_waterVolume.Start(); m_frozen = false; } } } public static class GlobalKeyManager { public static void UpdateSeasonalKey() { if (Object.op_Implicit((Object)(object)ZoneSystem.instance)) { ClearSeasonalKeys(); SetKey(); } } private static void ClearSeasonalKeys() { if (!Object.op_Implicit((Object)(object)ZoneSystem.instance)) { return; } foreach (string item in ZoneSystem.instance.GetGlobalKeys().ToList()) { if (item.StartsWith("season_")) { ZoneSystem.instance.RemoveGlobalKey(item); } } } private static void SetKey() { if (Object.op_Implicit((Object)(object)ZoneSystem.instance)) { ZoneSystem.instance.SetGlobalKey("season_" + SeasonTime.GetCurrentSeason().ToString().ToLower()); } } } public class MossController : MonoBehaviour { [HarmonyPatch(typeof(BossStone), "Start")] private static class BossStone_Start_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Postfix(BossStone __instance) { if (Object.op_Implicit((Object)(object)__instance) && !Object.op_Implicit((Object)(object)((Component)__instance).GetComponentInParent<LocationFix>())) { MossController mossController = ((Component)__instance).gameObject.AddComponent<MossController>(); mossController.Cache(); mossController.SetMoss(); } } } [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(1)] private readonly Dictionary<Material, Texture> m_textureMap = new Dictionary<Material, Texture>(); private static readonly int MossTex = Shader.PropertyToID("_MossTex"); [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(1)] private static readonly List<MossController> m_instances = new List<MossController>(); public static void UpdateAll() { foreach (MossController instance in m_instances) { instance.SetMoss(); } } public void Awake() { m_instances.Add(this); } public void OnDestroy() { m_instances.Remove(this); } private void Cache() { Renderer[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren<Renderer>(); if (componentsInChildren.Length == 0) { return; } Renderer[] array = componentsInChildren; foreach (Renderer val in array) { Material[] sharedMaterials = val.sharedMaterials; foreach (Material val2 in sharedMaterials) { if (!((Object)(object)val2 == (Object)null) && val2.HasProperty(MossTex)) { Texture tex = TextureManager.stonemoss.m_tex; if (tex != null) { m_textureMap[val2] = tex; } else { m_textureMap[val2] = val2.GetTexture(MossTex); } } } } } public void SetMoss() { switch (SeasonTime.GetCurrentSeason()) { case Season.Fall: { foreach (KeyValuePair<Material, Texture> item in m_textureMap) { item.Key.SetTexture(MossTex, TextureManager.Stonemoss_heath.m_tex); } return; } case Season.Winter: { foreach (KeyValuePair<Material, Texture> item2 in m_textureMap) { item2.Key.SetTexture(MossTex, TextureManager.AshOnRocks_d.m_tex); } return; } } foreach (KeyValuePair<Material, Texture> item3 in m_textureMap) { item3.Key.SetTexture(MossTex, item3.Value); } } } [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(0)] public class LocationFix : MonoBehaviour { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] [HarmonyPatch(typeof(ZoneSystem), "SpawnLocation")] private static class ZoneSystem_SpawnLocation_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Postfix(ref GameObject __result) { if (Object.op_Implicit((Object)(object)__result)) { __result.AddComponent<LocationFix>(); } } } public static readonly List<LocationFix> m_instances = new List<LocationFix>(); public Renderer[] m_renderers = null; public readonly Dictionary<Material, Texture> m_textures = new Dictionary<Material, Texture>(); private static readonly int MossTex = Shader.PropertyToID("_MossTex"); private Texture TryGetOriginalMoss(Texture current) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 Biome biome = WorldGenerator.instance.GetBiome(((Component)this).transform.position); Biome val = biome; Texture val2; if ((int)val <= 2) { if ((int)val == 1) { goto IL_0040; } if ((int)val != 2) { goto IL_009c; } val2 = TextureManager.stonemoss_swamp.m_tex; } else { if ((int)val == 8) { goto IL_0040; } if ((int)val != 16) { if ((int)val != 512) { goto IL_009c; } val2 = (((Object)((Component)this).transform).name.ToLower().Contains("dvergr") ? TextureManager.groundcreep_d.m_tex : TextureManager.stonemoss_bw.m_tex); } else { val2 = TextureManager.Stonemoss_heath.m_tex; } } goto IL_00a9; IL_00a9: return ((Object)(object)val2 != (Object)null) ? val2 : current; IL_009c: val2 = TextureManager.stonemoss.m_tex; goto IL_00a9; IL_0040: val2 = TextureManager.stonemoss.m_tex; goto IL_00a9; } public void Awake() { m_renderers = ((Component)this).GetComponentsInChildren<Renderer>(); m_instances.Add(this); if (m_renderers.Length == 0) { return; } Renderer[] renderers = m_renderers; foreach (Renderer val in renderers) { Material[] sharedMaterials = val.sharedMaterials; for (int j = 0; j < val.sharedMaterials.Length; j++) { Material val2 = val.sharedMaterials[j]; if (val2.HasProperty(MossTex)) { m_textures[val2] = TryGetOriginalMoss(val2.GetTexture(MossTex)); } if (((Object)val2).name.Contains("HildirsLox") && TextureReplacer.m_materials.TryGetValue("lox", out var value)) { sharedMaterials[j] = value.m_material; } } val.sharedMaterials = sharedMaterials; } UpdateMoss(); } public void OnDestroy() { m_instances.Remove(this); } public void UpdateMoss() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 if ((int)WorldGenerator.instance.GetBiome(((Component)this).transform.position) == 4) { return; } switch (SeasonTime.GetCurrentSeason()) { case Season.Winter: { foreach (Material key in m_textures.Keys) { key.SetTexture(MossTex, TextureManager.AshOnRocks_d.m_tex); } return; } case Season.Fall: { foreach (Material key2 in m_textures.Keys) { key2.SetTexture(MossTex, TextureManager.Stonemoss_heath.m_tex); } return; } } foreach (KeyValuePair<Material, Texture> texture in m_textures) { texture.Key.SetTexture(MossTex, texture.Value); } } public static void UpdateAll() { foreach (LocationFix instance in m_instances) { instance.UpdateMoss(); } } } public class TerrainController : MonoBehaviour { [HarmonyPatch(typeof(Heightmap), "Awake")] private static class Heightmap_Awake_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Postfix(Heightmap __instance) { ((Component)__instance).gameObject.AddComponent<TerrainController>(); } } [HarmonyPatch(typeof(Heightmap), "OnEnable")] private static class Heightmap_OnEnable_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Postfix(Heightmap __instance) { TerrainController terrainController = default(TerrainController); if (((Component)__instance).TryGetComponent<TerrainController>(ref terrainController)) { terrainController.Load(); } } } [HarmonyPatch(typeof(Heightmap), "OnDisable")] private static class Heightmap_OnDisable_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Postfix(Heightmap __instance) { TerrainController item = default(TerrainController); if (((Component)__instance).TryGetComponent<TerrainController>(ref item)) { m_instances.Remove(item); } } } [HarmonyPatch(typeof(Heightmap), "GetBiomeColor", new Type[] { typeof(Biome) })] private static class Heightmap_GetBiomeColor_Patch { private static void Postfix(Biome biome, ref Color32 __result) { //IL_0051: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Invalid comparison between Unknown and I4 //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 switch (SeasonTime.GetCurrentSeason()) { case Season.Winter: if ((int)biome <= 8) { if (biome - 1 > 1 && (int)biome != 8) { break; } } else if ((int)biome != 16 && (int)biome != 512) { break; } __result = defaultMap[(Biome)4]; break; case Season.Fall: if ((int)biome == 1) { __result = defaultMap[(Biome)16]; } break; } } } [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(1)] private static readonly List<TerrainController> m_instances = new List<TerrainController>(); [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(2)] private Heightmap m_heightmap; [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(1)] private static readonly Dictionary<Biome, Color32> defaultMap = new Dictionary<Biome, Color32> { { (Biome)1, new Color32((byte)0, (byte)0, (byte)0, (byte)0) }, { (Biome)8, new Color32((byte)0, (byte)0, byte.MaxValue, (byte)0) }, { (Biome)2, new Color32(byte.MaxValue, (byte)0, (byte)0, (byte)0) }, { (Biome)4, new Color32((byte)0, byte.MaxValue, (byte)0, (byte)0) }, { (Biome)16, new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue) }, { (Biome)512, new Color32((byte)0, (byte)0, byte.MaxValue, byte.MaxValue) }, { (Biome)64, new Color32((byte)0, byte.MaxValue, (byte)0, (byte)0) }, { (Biome)32, new Color32(byte.MaxValue, (byte)0, (byte)0, byte.MaxValue) }, { (Biome)256, new Color32((byte)0, (byte)0, (byte)0, (byte)0) } }; public static void UpdateTerrain() { foreach (TerrainController instance in m_instances) { if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.m_heightmap == (Object)null)) { instance.ChangeTerrainColor(); } } } public void OnDestroy() { m_instances.Remove(this); } public void Load() { m_heightmap = ((Component)this).GetComponent<Heightmap>(); m_instances.Add(this); } public void ChangeTerrainColor() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) if (WorldGenerator.instance == null || (Object)(object)m_heightmap == (Object)null || (Object)(object)m_heightmap.m_renderMesh == (Object)null) { return; } Heightmap.s_tempColors.Clear(); Vector3 val = ((Component)this).transform.position + new Vector3((float)((double)m_heightmap.m_width * (double)m_heightmap.m_scale * -0.5), 0f, (float)((double)m_heightmap.m_width * (double)m_heightmap.m_scale * -0.5)); int num = m_heightmap.m_width + 1; for (int i = 0; i < num; i++) { float num2 = DUtils.SmoothStep(0f, 1f, (float)i / (float)m_heightmap.m_width); for (int j = 0; j < num; j++) { float num3 = DUtils.SmoothStep(0f, 1f, (float)j / (float)m_heightmap.m_width); Heightmap.s_tempUVs.Add(new Vector2((float)j / (float)m_heightmap.m_width, (float)i / (float)m_heightmap.m_width)); if (m_heightmap.m_isDistantLod) { float num4 = val.x + (float)j * m_heightmap.m_scale; float num5 = val.z + (float)i * m_heightmap.m_scale; Biome biome = WorldGenerator.instance.GetBiome(num4, num5, 0.02f, false); Heightmap.s_tempColors.Add(Heightmap.GetBiomeColor(biome)); } else { Heightmap.s_tempColors.Add(Color32.op_Implicit(m_heightmap.GetBiomeColor(num3, num2))); } } } m_heightmap.m_renderMesh.SetColors(Heightmap.s_tempColors); } } [RequireComponent(typeof(VisEquipment))] [RequireComponent(typeof(Player))] public class VisEquipController : MonoBehaviour { [HarmonyPatch(typeof(Player), "Awake")] private static class Player_Awake_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Postfix(Player __instance) { ((Component)__instance).gameObject.AddComponent<VisEquipController>(); } } [HarmonyPatch(typeof(VisEquipment), "SetChestEquipped")] private static class VisEquipment_SetChestEquipped_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Postfix(VisEquipment __instance, bool __result) { VisEquipController visEquipController = default(VisEquipController); if (__result && ((Component)__instance).TryGetComponent<VisEquipController>(ref visEquipController)) { visEquipController.UpdateChestTexture(); } } } [HarmonyPatch(typeof(VisEquipment), "SetLegEquipped")] private static class VisEquipment_SetLegsEquipped_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Postfix(VisEquipment __instance, bool __result) { VisEquipController visEquipController = default(VisEquipController); if (__result && ((Component)__instance).TryGetComponent<VisEquipController>(ref visEquipController)) { visEquipController.UpdateLegTexture(); } } } [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(1)] public static readonly List<VisEquipController> m_instances = new List<VisEquipController>(); [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(1)] public static VisEquipment m_visEquipment = null; private static readonly int ChestTex = Shader.PropertyToID("_ChestTex"); private static readonly int LegsTex = Shader.PropertyToID("_LegsTex"); public void Awake() { m_visEquipment = ((Component)this).GetComponent<VisEquipment>(); m_instances.Add(this); } public void OnDestroy() { m_instances.Remove(this); } public void UpdatePlayerMaterial() { UpdateChestTexture(); UpdateLegTexture(); } public void UpdateChestTexture() { if ((Object)(object)m_visEquipment == (Object)null || (Object)(object)m_visEquipment.m_bodyModel == (Object)null) { return; } GameObject itemPrefab = ObjectDB.m_instance.GetItemPrefab(m_visEquipment.m_currentChestItemHash); ItemDrop val = default(ItemDrop); if (itemPrefab == null || !itemPrefab.TryGetComponent<ItemDrop>(ref val)) { return; } Material armorMaterial = val.m_itemData.m_shared.m_armorMaterial; if (armorMaterial == null) { return; } string key = ((Object)armorMaterial).name.Replace("(Instance)", string.Empty).Trim(); if (TextureReplacer.m_materials.TryGetValue(key, out var value) && value.m_specialTextures.TryGetValue("_ChestTex", out var value2)) { Texture value4; if (value2.TryGetValue(SeasonTime.GetCurrentSeason(), out var value3)) { ((Renderer)m_visEquipment.m_bodyModel).material.SetTexture(ChestTex, value3); } else if (value.m_originalTextures.TryGetValue("_ChestTex", out value4)) { ((Renderer)m_visEquipment.m_bodyModel).material.SetTexture(ChestTex, value4); } } } public void UpdateLegTexture() { if ((Object)(object)m_visEquipment == (Object)null || (Object)(object)m_visEquipment.m_bodyModel == (Object)null) { return; } GameObject itemPrefab = ObjectDB.m_instance.GetItemPrefab(m_visEquipment.m_currentLegItemHash); ItemDrop val = default(ItemDrop); if (itemPrefab == null || !itemPrefab.TryGetComponent<ItemDrop>(ref val)) { return; } Material armorMaterial = val.m_itemData.m_shared.m_armorMaterial; if (armorMaterial == null) { return; } string key = ((Object)armorMaterial).name.Replace("(Instance)", string.Empty).Trim(); if (TextureReplacer.m_materials.TryGetValue(key, out var value) && value.m_specialTextures.TryGetValue("_LegsTex", out var value2)) { Texture value4; if (value2.TryGetValue(SeasonTime.GetCurrentSeason(), out var value3)) { ((Renderer)m_visEquipment.m_bodyModel).material.SetTexture(LegsTex, value3); } else if (value.m_originalTextures.TryGetValue("_LegsTex", out value4)) { ((Renderer)m_visEquipment.m_bodyModel).material.SetTexture(LegsTex, value4); } } } public static void UpdateAll() { foreach (VisEquipController instance in m_instances) { instance.UpdatePlayerMaterial(); } } } [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(0)] [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] public static class BeeHiveTweaks { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] [HarmonyPatch(typeof(Beehive), "Interact")] private static class Beehive_Interact_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static bool Prefix(Beehive __instance, Humanoid character) { switch (SeasonTime.GetCurrentSeason()) { case Season.Summer: if (SummerEnabled.Value == Toggle.Off) { ((Character)character).Message((MessageType)2, __instance.m_areaText, 0, (Sprite)null, false); return false; } return true; case Season.Fall: if (FallEnabled.Value == Toggle.Off) { ((Character)character).Message((MessageType)2, __instance.m_areaText, 0, (Sprite)null, false); return false; } return true; case Season.Spring: if (SpringEnabled.Value == Toggle.Off) { ((Character)character).Message((MessageType)2, __instance.m_areaText, 0, (Sprite)null, false); return false; } return true; case Season.Winter: if (WinterEnabled.Value == Toggle.Off) { ((Character)character).Message((MessageType)2, __instance.m_areaText, 0, (Sprite)null, false); return false; } return true; default: return true; } } } private static ConfigEntry<Toggle> SummerEnabled; private static ConfigEntry<Toggle> FallEnabled; private static ConfigEntry<Toggle> SpringEnabled; private static ConfigEntry<Toggle> WinterEnabled; public static void Setup() { SummerEnabled = ConfigManager.config("Tweaks", "Beehive Summer", Toggle.On, "If on, beehive interactable during summer"); FallEnabled = ConfigManager.config("Tweaks", "Beehive Fall", Toggle.On, "If on, beehive interactable during fall"); SpringEnabled = ConfigManager.config("Tweaks", "Beehive Spring", Toggle.On, "If on, beehive interactable during spring"); WinterEnabled = ConfigManager.config("Tweaks", "Beehive Winter", Toggle.On, "If on, beehive interactable during winter"); } } [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(0)] [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] public static class BuildTweaks { [HarmonyPatch(typeof(PieceTable), "UpdateAvailable")] [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] private static class PieceTable_UpdateAvailable { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Postfix(PieceTable __instance, HashSet<string> knownRecipies, Player player, bool hideUnavailable, bool noPlacementCost) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Invalid comparison between Unknown and I4 //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected I4, but got Unknown if (m_enabled.Value == Toggle.Off) { return; } Piece val = default(Piece); foreach (string name in new StringListConfig(GetConfig().Value).m_names) { GameObject prefab = ZNetScene.instance.GetPrefab(name); if (prefab == null || !prefab.TryGetComponent<Piece>(ref val) || !player.HaveRequirements(val, (RequirementMode)2)) { continue; } if ((int)val.m_category == 100) { __instance.m_availablePieces.Add(val); continue; } List<Piece> list = __instance.m_availablePiecesByCategory[(int)val.m_category]; if (!list.Contains(val)) { list.Add(val); } } } } private static ConfigEntry<Toggle> m_enabled = null; private static ConfigEntry<string> m_winterPieces = null; private static ConfigEntry<string> m_springPieces = null; private static ConfigEntry<string> m_fallPieces = null; private static ConfigEntry<string> m_summerPieces = null; private static readonly List<string> m_defaultWinterPieces = new List<string> { "piece_xmascrown", "piece_xmastree", "piece_xmasgarland", "piece_mistletoe", "piece_gift1", "piece_gift2", "piece_gift3" }; private static readonly List<string> m_defaultSpringPieces = new List<string>(); private static readonly List<string> m_defaultFallPieces = new List<string> { "piece_jackoturnip" }; private static readonly List<string> m_defaultSummerPieces = new List<string> { "piece_maypole" }; public static void Setup() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown m_enabled = ConfigManager.config("Tweaks", "Build Pieces Enabled", Toggle.Off, "If on, seasonal build pieces enabled"); m_winterPieces = ConfigManager.config("Tweaks", "Winter Pieces", new StringListConfig(m_defaultWinterPieces).ToString(), new ConfigDescription("Set added winter pieces", (AcceptableValueBase)null, new object[1] { StringListConfig.attributes })); m_springPieces = ConfigManager.config("Tweaks", "Spring Pieces", new StringListConfig(m_defaultSpringPieces).ToString(), new ConfigDescription("Set added spring pieces", (AcceptableValueBase)null, new object[1] { StringListConfig.attributes })); m_fallPieces = ConfigManager.config("Tweaks", "Fall Pieces", new StringListConfig(m_defaultFallPieces).ToString(), new ConfigDescription("Set added fall pieces", (AcceptableValueBase)null, new object[1] { StringListConfig.attributes })); m_summerPieces = ConfigManager.config("Tweaks", "Summer Pieces", new StringListConfig(m_defaultSummerPieces).ToString(), new ConfigDescription("Set added summer pieces", (AcceptableValueBase)null, new object[1] { StringListConfig.attributes })); } private static ConfigEntry<string> GetConfig() { Season currentSeason = SeasonTime.GetCurrentSeason(); if (1 == 0) { } ConfigEntry<string> result = (ConfigEntry<string>)(currentSeason switch { Season.Summer => m_summerPieces, Season.Spring => m_springPieces, Season.Fall => m_fallPieces, Season.Winter => m_winterPieces, _ => m_summerPieces, }); if (1 == 0) { } return result; } } public static class FishTweaks { [HarmonyPatch(typeof(Fish), "Interact")] private static class Fish_Interact_Patch { private static bool Prefix() { if (m_enabled.Value == Toggle.Off) { return true; } return SeasonTime.GetCurrentSeason() != Season.Winter; } } [HarmonyPatch(typeof(Fish), "GetHoverText")] private static class Fish_GetHoverText_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Postfix(ref string __result) { if (m_enabled.Value != Toggle.Off && SeasonTime.GetCurrentSeason() == Season.Winter) { __result += Localization.instance.Localize("\n $cannot_pick"); } } } [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(1)] private static ConfigEntry<Toggle> m_enabled; public static void Setup() { m_enabled = ConfigManager.config("Tweaks", "Frozen Fish", Toggle.Off, "If on, fish cannot be picked up during winter"); } } [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(0)] [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] public static class PickableTweaks { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] [HarmonyPatch(typeof(Pickable), "Awake")] private static class Pickable_Awake_Patch { [UsedImplicitly] [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Postfix(Pickable __instance) { if (m_enabled.Value != Toggle.Off && GetHarvestData(((Object)__instance).name.Replace("(Clone)", string.Empty), out var result)) { __instance.m_amount = result.Amount; } } } [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] [HarmonyPatch(typeof(Pickable), "Interact")] private static class Pickable_Interact_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] [UsedImplicitly] private static bool Prefix(Pickable __instance) { if (m_enabled.Value == Toggle.Off) { return true; } if (!GetHarvestData(((Object)__instance).name.Replace("(Clone)", string.Empty), out var result)) { return true; } return result.CanHarvest; } } [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] [HarmonyPatch(typeof(Pickable), "GetHoverText")] private static class Pickable_GetHoverText_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] [UsedImplicitly] private static void Postfix(Pickable __instance, ref string __result) { if (m_enabled.Value != Toggle.Off && GetHarvestData(((Object)__instance).name.Replace("(Clone)", string.Empty), out var result) && !result.CanHarvest) { __result += Localization.instance.Localize("\n <color=red>$cannot_pick</color>"); } } } [Serializable] [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(0)] public class Harvest { [Serializable] [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] public class HarvestData { public int Amount; public bool CanHarvest; } public HarvestData Summer = new HarvestData(); public HarvestData Fall = new HarvestData(); public HarvestData Winter = new HarvestData(); public HarvestData Spring = new HarvestData(); } private const string FileName = "Pickables.yml"; private static readonly string FilePath; private static readonly CustomSyncedValue<string> ServerPickableConfigs; private static ConfigEntry<Toggle> m_enabled; public static readonly Dictionary<string, Harvest> m_data; private static readonly ISerializer serializer; private static readonly IDeserializer deserializer; public static void Setup() { m_enabled = ConfigManager.config("Tweaks", "Pickable Enabled", Toggle.Off, "If on, pickable tweaks are enabled"); Read(); ServerPickableConfigs.ValueChanged += OnServerValueChanged; if (m_data.Count == 0) { TweaksManager.OnZNetScenePrefab += delegate(GameObject prefab) { Pickable val = default(Pickable); if (!m_data.ContainsKey(((Object)prefab).name) && prefab.TryGetComponent<Pickable>(ref val)) { m_data[((Object)prefab).name] = new Harvest { Summer = CreateData(val.m_amount), Fall = CreateData(val.m_amount), Winter = CreateData(val.m_amount, canHarvest: false), Spring = CreateData(val.m_amount) }; } }; TweaksManager.OnFinishSetup += Write; } TweaksManager.OnZNetAwake += delegate { UpdateServerConfigs(); SetupFileWatch(); }; } private static void OnServerValueChanged() { if (!Object.op_Implicit((Object)(object)ZNet.m_instance) || ZNet.m_instance.IsServer() || string.IsNullOrEmpty(ServerPickableConfigs.Value)) { return; } try { m_data.Clear(); m_data.AddRange(deserializer.Deserialize<Dictionary<string, Harvest>>(ServerPickableConfigs.Value)); } catch { SeasonalityPlugin.Record.LogWarning("Failed to deserialize server pickable configs"); } } public static void SetupFileWatch() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(TweaksManager.FolderPath, "Pickables.yml"); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = false; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; static void ReadConfigValues(object sender, FileSystemEventArgs args) { if (Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsServer()) { Read(); UpdateServerConfigs(); } } } public static void UpdateServerConfigs() { if (Object.op_Implicit((Object)(object)ZNet.m_instance) && ZNet.m_instance.IsServer()) { ServerPickableConfigs.Value = serializer.Serialize((object)m_data); } } private static bool GetHarvestData(string prefabName, out Harvest.HarvestData result) { result = new Harvest.HarvestData(); if (!m_data.TryGetValue(prefabName, out var value)) { return false; } switch (SeasonTime.GetCurrentSeason()) { case Season.Fall: result = value.Fall; break; case Season.Winter: result = value.Winter; break; case Season.Spring: result = value.Spring; break; case Season.Summer: result = value.Summer; break; default: return false; } return true; } public static void Read() { if (!Directory.Exists(TweaksManager.FolderPath)) { Directory.CreateDirectory(TweaksManager.FolderPath); } if (!File.Exists(FilePath)) { return; } try { m_data.Clear(); m_data.AddRange(deserializer.Deserialize<Dictionary<string, Harvest>>(File.ReadAllText(FilePath))); } catch { SeasonalityPlugin.Record.LogWarning("Failed to deserialize: " + Path.GetFileName(FilePath)); } } public static void Write() { if (!Directory.Exists(TweaksManager.FolderPath)) { Directory.CreateDirectory(TweaksManager.FolderPath); } string contents = serializer.Serialize((object)m_data); File.WriteAllText(FilePath, contents); } public static Harvest.HarvestData CreateData(int amount, bool canHarvest = true) { return new Harvest.HarvestData { Amount = amount, CanHarvest = canHarvest }; } static PickableTweaks() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) string folderPath = TweaksManager.FolderPath; char directorySeparatorChar = Path.DirectorySeparatorChar; FilePath = folderPath + directorySeparatorChar + "Pickables.yml"; ServerPickableConfigs = new CustomSyncedValue<string>(ConfigManager.ConfigSync, "ServerPickableConfigs", ""); m_enabled = null; m_data = new Dictionary<string, Harvest>(); serializer = new SerializerBuilder().Build(); deserializer = new DeserializerBuilder().Build(); } } [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(0)] [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] public static class PlantTweaks { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] [HarmonyPatch(typeof(Plant), "Grow")] private static class Plant_Grow_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] [UsedImplicitly] private static bool Prefix(Plant __instance) { if (m_enabled.Value == Toggle.Off) { return true; } if (!m_data.TryGetValue(((Object)__instance).name.Replace("(Clone)", string.Empty), out var value)) { return true; } Season currentSeason = SeasonTime.GetCurrentSeason(); if (1 == 0) { } bool result = currentSeason switch { Season.Spring => value.Spring.CanHarvest, Season.Summer => value.Summer.CanHarvest, Season.Fall => value.Fall.CanHarvest, Season.Winter => value.Winter.CanHarvest, _ => true, }; if (1 == 0) { } return result; } } [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] [HarmonyPatch(typeof(Plant), "GetStatus")] private static class Plant_GetStatus_Patch { [UsedImplicitly] [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Postfix(Plant __instance, ref Status __result) { if (m_enabled.Value == Toggle.Off || !m_data.TryGetValue(((Object)__instance).name.Replace("(Clone)", string.Empty), out var value)) { return; } switch (SeasonTime.GetCurrentSeason()) { case Season.Spring: if (!value.Spring.CanHarvest) { __result = (Status)2; } break; case Season.Summer: if (!value.Summer.CanHarvest) { __result = (Status)2; } break; case Season.Fall: if (!value.Fall.CanHarvest) { __result = (Status)2; } break; case Season.Winter: if (!value.Winter.CanHarvest) { __result = (Status)2; } break; } } } [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] [HarmonyPatch(typeof(Plant), "GetHoverText")] private static class Plant_GetHoverText_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] [UsedImplicitly] private static void Postfix(Plant __instance, ref string __result) { if (m_enabled.Value == Toggle.Off || !m_data.TryGetValue(((Object)__instance).name.Replace("(Clone)", string.Empty), out var value)) { return; } switch (SeasonTime.GetCurrentSeason()) { case Season.Spring: if (value.Spring.CanHarvest) { return; } break; case Season.Summer: if (value.Summer.CanHarvest) { return; } break; case Season.Fall: if (value.Fall.CanHarvest) { return; } break; case Season.Winter: if (value.Winter.CanHarvest) { return; } break; } __result += Localization.instance.Localize("\n <color=red>$" + SeasonTime.GetCurrentSeason().ToString().ToLower() + "_cannot_grow</color>"); } } [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] [HarmonyPatch(typeof(Plant), "Awake")] private static class Plant_Awake_Patch { [UsedImplicitly] [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Postfix(Plant __instance) { if (m_enabled.Value != Toggle.Off && m_data.TryGetValue(((Object)__instance).name.Replace("(Clone)", string.Empty), out var value)) { Plants.Data data; switch (SeasonTime.GetCurrentSeason()) { default: return; case Season.Spring: data = value.Spring; break; case Season.Summer: data = value.Summer; break; case Season.Fall: data = value.Fall; break; case Season.Winter: data = value.Winter; break; } __instance.m_maxScale = data.MaxScale; __instance.m_minScale = data.MinScale; __instance.m_growTimeMax = data.GrowTimeMax; __instance.m_growTime = data.GrowTime; } } } [Serializable] [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(0)] public class Plants { [Serializable] [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] public class Data { public float MaxScale; public float MinScale; public float GrowTimeMax; public float GrowTime; public bool CanHarvest; } public Data Summer = new Data(); public Data Fall = new Data(); public Data Winter = new Data(); public Data Spring = new Data(); } private const string FileName = "Plants.yml"; private static readonly string FilePath; private static readonly CustomSyncedValue<string> ServerConfigs; private static ConfigEntry<Toggle> m_enabled; public static readonly Dictionary<string, Plants> m_data; private static readonly ISerializer serializer; private static readonly IDeserializer deserializer; public static void Setup() { m_enabled = ConfigManager.config("Tweaks", "Plants Tweaks", Toggle.Off, "If on, plant tweaks are enabled"); Read(); ServerConfigs.ValueChanged += OnServerValueChanged; if (m_data.Count == 0) { TweaksManager.OnZNetScenePrefab += delegate(GameObject prefab) { Plant val = default(Plant); if (!m_data.ContainsKey(((Object)prefab).name) && prefab.TryGetComponent<Plant>(ref val)) { m_data[((Object)prefab).name] = new Plants { Summer = Create(val.m_minScale, val.m_maxScale, val.m_growTimeMax, val.m_growTime), Fall = Create(val.m_minScale, val.m_maxScale, val.m_growTimeMax, val.m_growTime), Winter = Create(val.m_minScale, val.m_maxScale, val.m_growTimeMax, val.m_growTime, canHarvest: false), Spring = Create(val.m_minScale, val.m_maxScale, val.m_growTimeMax, val.m_growTime) }; } }; TweaksManager.OnFinishSetup += Write; } TweaksManager.OnZNetAwake += delegate { UpdateServerConfigs(); SetupFileWatch(); }; } private static void OnServerValueChanged() { if (!Object.op_Implicit((Object)(object)ZNet.m_instance) || ZNet.m_instance.IsServer() || string.IsNullOrEmpty(ServerConfigs.Value)) { return; } try { m_data.Clear(); m_data.AddRange(deserializer.Deserialize<Dictionary<string, Plants>>(ServerConfigs.Value)); } catch { SeasonalityPlugin.Record.LogWarning("Failed to deserialize server plant configs"); } } public static void UpdateServerConfigs() { if (Object.op_Implicit((Object)(object)ZNet.m_instance) && ZNet.m_instance.IsServer()) { ServerConfigs.Value = serializer.Serialize((object)m_data); } } public static void SetupFileWatch() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(TweaksManager.FolderPath, "Plants.yml"); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = false; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; static void ReadConfigValues(object sender, FileSystemEventArgs args) { if (Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsServer()) { Read(); UpdateServerConfigs(); } } } public static void Write() { string contents = serializer.Serialize((object)m_data); File.WriteAllText(FilePath, contents); } public static void Read() { if (!File.Exists(FilePath)) { return; } try { m_data.Clear(); m_data.AddRange(deserializer.Deserialize<Dictionary<string, Plants>>(File.ReadAllText(FilePath))); } catch { SeasonalityPlugin.Record.LogWarning("Failed to deserialize plant tweaks: " + Path.GetFileName(FilePath)); } } public static Plants.Data Create(float min, float max, float growTimeMax, float growTime, bool canHarvest = true) { return new Plants.Data { MaxScale = max, MinScale = min, GrowTime = growTime, GrowTimeMax = growTimeMax, CanHarvest = canHarvest }; } static PlantTweaks() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) string folderPath = TweaksManager.FolderPath; char directorySeparatorChar = Path.DirectorySeparatorChar; FilePath = folderPath + directorySeparatorChar + "Plants.yml"; ServerConfigs = new CustomSyncedValue<string>(ConfigManager.ConfigSync, "ServerPlantConfigs", ""); m_enabled = null; m_data = new Dictionary<string, Plants>(); serializer = new SerializerBuilder().Build(); deserializer = new DeserializerBuilder().Build(); } } [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(0)] [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] public static class SpawnTweaks { [HarmonyPatch(typeof(SpawnSystem), "Spawn")] [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] private static class SpawnSystem_Spawn_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static bool Prefix(SpawnData critter) { if (m_enabled.Value == Toggle.Off) { return true; } if (!m_data.TryGetValue(((Object)critter.m_prefab).name, out var value)) { return true; } bool value2; return !value.TryGetValue(SeasonTime.GetCurrentSeason(), out value2) || value2; } } [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] [HarmonyPatch(typeof(SpawnArea), "SpawnOne")] private static class SpawnArea_SpawnOne_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static bool Prefix(SpawnArea __instance) { if (m_enabled.Value == Toggle.Off) { return true; } foreach (SpawnData prefab in __instance.m_prefabs) { if (prefab == null || (Object)(object)prefab.m_prefab == (Object)null || !m_data.TryGetValue(((Object)prefab.m_prefab).name, out var value) || !value.TryGetValue(SeasonTime.GetCurrentSeason(), out var value2) || value2) { continue; } return false; } return true; } } [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] [HarmonyPatch(typeof(BaseAI), "UpdateAI")] private static class BaseAI_UpdateAI_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static bool Prefix(BaseAI __instance, float dt, ref bool __result) { if (m_enabled.Value == Toggle.Off) { return true; } if (!__instance.m_nview.IsValid() || !__instance.m_nview.IsOwner()) { return true; } string prefabName = Utils.GetPrefabName(((Object)__instance).name); if (!m_data.TryGetValue(prefabName, out var value)) { return true; } if (!value.TryGetValue(SeasonTime.GetCurrentSeason(), out var value2)) { return true; } if (value2) { return true; } __instance.MoveAwayAndDespawn(dt, true); __result = false; return false; } } private static readonly string FileName = "SpawnTweaks.yml"; private static readonly string FilePath = Path.Combine(TweaksManager.FolderPath, FileName); public static readonly Dictionary<string, Dictionary<Season, bool>> m_data = new Dictionary<string, Dictionary<Season, bool>>(); private static ConfigEntry<Toggle> m_enabled = null; private static readonly ISerializer serializer = new SerializerBuilder().Build(); private static readonly IDeserializer deserializer = new DeserializerBuilder().Build(); private static readonly CustomSyncedValue<string> ServerSpawnData = new CustomSyncedValue<string>(ConfigManager.ConfigSync, "Seasonality.Server.SpawnData", ""); public static void OnServerValueChanged() { if (!Object.op_Implicit((Object)(object)ZNet.instance) || ZNet.instance.IsServer() || string.IsNullOrEmpty(ServerSpawnData.Value)) { return; } try { m_data.Clear(); m_data.AddRange(deserializer.Deserialize<Dictionary<string, Dictionary<Season, bool>>>(ServerSpawnData.Value)); } catch { SeasonalityPlugin.Record.LogWarning("Failed to parse server spawn data."); } } public static void UpdateServerConfigs() { if (Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsServer()) { ServerSpawnData.Value = serializer.Serialize((object)m_data); } } public static void SetupFileWatch() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(TweaksManager.FolderPath, FileName); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = false; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; static void ReadConfigValues(object sender, FileSystemEventArgs args) { if (Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsServer()) { Read(); UpdateServerConfigs(); } } } public static void Setup() { m_enabled = ConfigManager.config("Tweaks", "Spawns Enabled", Toggle.Off, "If on, spawns are modified per season"); Read(); ServerSpawnData.ValueChanged += OnServerValueChanged; if (m_data.Count == 0) { TweaksManager.OnZNetScenePrefab += delegate(GameObject prefab) { Character val = default(Character); if (!m_data.ContainsKey(((Object)prefab).name) && prefab.TryGetComponent<Character>(ref val) && !(val is Player)) { m_data[((Object)prefab).name] = new Dictionary<Season, bool> { [Season.Spring] = true, [Season.Summer] = true, [Season.Fall] = true, [Season.Winter] = true }; } }; TweaksManager.OnFinishSetup += Write; } TweaksManager.OnZNetAwake += delegate { UpdateServerConfigs(); SetupFileWatch(); }; } public static void Write() { string contents = serializer.Serialize((object)m_data); File.WriteAllText(FilePath, contents); } public static void Read() { if (!File.Exists(FilePath)) { return; } try { m_data.Clear(); m_data.AddRange(deserializer.Deserialize<Dictionary<string, Dictionary<Season, bool>>>(File.ReadAllText(FilePath))); } catch { SeasonalityPlugin.Record.LogWarning("Failed to deserialize spawn tweaks file: " + Path.GetFileName(FilePath)); } } } [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(0)] public static class TraderTweaks { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] [HarmonyPatch(typeof(Trader), "GetAvailableItems")] private static class Trader_GetAvailableItems_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static void Postfix(ref List<TradeItem> __result) { if (m_enabled.Value == Toggle.Off) { return; } foreach (SerializedItems.SeasonalItem item in new SerializedItems(GetConfig().Value).m_items) { TradeItem tradeItem = item.GetTradeItem(); if (tradeItem != null) { __result.Add(tradeItem); } } } } private static ConfigEntry<Toggle> m_enabled = null; private static ConfigEntry<string> m_summerItems = null; private static ConfigEntry<string> m_fallItems = null; private static ConfigEntry<string> m_winterItems = null; private static ConfigEntry<string> m_springItems = null; private static readonly List<SerializedItems.SeasonalItem> m_defaultSummerItems = new List<SerializedItems.SeasonalItem> { new SerializedItems.SeasonalItem("HelmetMidsummerCrown", 1, 300) }; private static readonly List<SerializedItems.SeasonalItem> m_defaultFallItems = new List<SerializedItems.SeasonalItem> { new SerializedItems.SeasonalItem("HelmetPointyHat", 1, 300) }; private static readonly List<SerializedItems.SeasonalItem> m_defaultWinterItems = new List<SerializedItems.SeasonalItem>(); private static readonly List<SerializedItems.SeasonalItem> m_defaultSpringItems = new List<SerializedItems.SeasonalItem>(); public static void Setup() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown m_enabled = ConfigManager.config("Tweaks", "Trader Enabled", Toggle.Off, "If on, trader has extra items for sale depending on season"); m_summerItems = ConfigManager.config("Tweaks", "Summer Items", new SerializedItems(m_defaultSummerItems).ToString(), new ConfigDescription("Set summer items added to trader", (AcceptableValueBase)null, new object[1] { SerializedItems.attributes })); m_fallItems = ConfigManager.config("Tweaks", "Fall Items", new SerializedItems(m_defaultFallItems).ToString(), new ConfigDescription("Set fall items added to trader", (AcceptableValueBase)null, new object[1] { SerializedItems.attributes })); m_winterItems = ConfigManager.config("Tweaks", "Winter Items", new SerializedItems(m_defaultWinterItems).ToString(), new ConfigDescription("Set fall items added to trader", (AcceptableValueBase)null, new object[1] { SerializedItems.attributes })); m_springItems = ConfigManager.config("Tweaks", "Spring Items", new SerializedItems(m_defaultSpringItems).ToString(), new ConfigDescription("Set fall items added to trader", (AcceptableValueBase)null, new object[1] { SerializedItems.attributes })); } private static ConfigEntry<string> GetConfig() { Season currentSeason = SeasonTime.GetCurrentSeason(); if (1 == 0) { } ConfigEntry<string> result = (ConfigEntry<string>)(currentSeason switch { Season.Summer => m_summerItems, Season.Fall => m_fallItems, Season.Winter => m_winterItems, Season.Spring => m_springItems, _ => m_summerItems, }); if (1 == 0) { } return result; } } [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(0)] [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(2)] public static class TweaksManager { [HarmonyPatch(typeof(ZNet), "Awake")] [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] private static class ZNet_Awake_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] [UsedImplicitly] private static void Postfix(ZNet __instance) { if (__instance.IsServer()) { TweaksManager.OnZNetAwake?.Invoke(); } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(0)] private static class ZNetScene_Awake_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] [UsedImplicitly] private static void Postfix(ZNetScene __instance) { foreach (GameObject prefab in __instance.m_prefabs) { if (!((Object)(object)prefab == (Object)null)) { TweaksManager.OnZNetScenePrefab?.Invoke(prefab); } } TweaksManager.OnFinishSetup?.Invoke(); } } [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(1)] private static readonly string ConfigFolder; [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(1)] public static readonly string FolderPath; public static event Action OnZNetAwake; [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(new byte[] { 2, 1 })] [method: <4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(new byte[] { 2, 1 })] [field: <4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(new byte[] { 2, 1 })] public static event Action<GameObject> OnZNetScenePrefab; public static event Action OnFinishSetup; public static void Setup() { if (!Directory.Exists(ConfigFolder)) { Directory.CreateDirectory(ConfigFolder); } if (!Directory.Exists(FolderPath)) { Directory.CreateDirectory(FolderPath); } PickableTweaks.Setup(); PlantTweaks.Setup(); FishTweaks.Setup(); SpawnTweaks.Setup(); TraderTweaks.Setup(); BuildTweaks.Setup(); BeeHiveTweaks.Setup(); WetTweaks.Setup(); } static TweaksManager() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFolder = configPath + directorySeparatorChar + "Seasonality"; string configFolder = ConfigFolder; directorySeparatorChar = Path.DirectorySeparatorChar; FolderPath = configFolder + directorySeparatorChar + "Tweaks"; } } public static class WetTweaks { [HarmonyPatch(typeof(Player), "UpdateEnvStatusEffects")] public static class Player_UpdateEnvStatusEffects { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] public static void Postfix(Player __instance) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Invalid comparison between Unknown and I4 //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Invalid comparison between Unknown and I4 if (enabled.Value == Toggle.Off || SeasonTime.GetCurrentSeason() != Season.Winter || ((Character)__instance).GetSEMan().HaveStatusEffect(SEMan.s_statusEffectFreezing)) { return; } DamageModifiers damageModifiers = ((Character)__instance).GetDamageModifiers((WeakSpot)null); DamageModifier modifier = ((DamageModifiers)(ref damageModifiers)).GetModifier((DamageType)64); if (((int)modifier == 1 || modifier - 3 <= 1) ? true : false) { return; } StatusEffect statusEffect = ((Character)__instance).GetSEMan().GetStatusEffect(SEMan.s_statusEffectWet); if (!((Object)(object)statusEffect == (Object)null)) { StatusEffect val = ((Character)__instance).GetSEMan().AddStatusEffect(SEMan.s_statusEffectFreezing, false, 0, 0f, (short)(-1)); if (!((Object)(object)val == (Object)null)) { val.m_ttl = statusEffect.m_ttl; val.m_category = "Seasonality"; ((Character)__instance).GetSEMan().RemoveStatusEffect(SEMan.s_statusEffectWet, true); ((Character)__instance).GetSEMan().RemoveStatusEffect(SEMan.s_statusEffectCold, true); } } } } [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new Type[] { typeof(int), typeof(bool), typeof(int), typeof(float), typeof(short) })] private static class SEMan_AddStatusEffect_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static bool Prefix(SEMan __instance, int nameHash) { if (enabled.Value == Toggle.Off) { return true; } if (!(__instance.m_character is Player)) { return true; } if (nameHash != SEMan.s_statusEffectWet) { return true; } StatusEffect statusEffect = __instance.GetStatusEffect(SEMan.s_statusEffectFreezing); if ((Object)(object)statusEffect == (Object)null) { return true; } if (statusEffect.m_category != "Seasonality") { return true; } return false; } } [HarmonyPatch(typeof(SEMan), "RemoveStatusEffect", new Type[] { typeof(int), typeof(bool) })] private static class SEMan_RemoveStatusEffect_Patch { [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] private static bool Prefix(SEMan __instance, int nameHash) { if (enabled.Value == Toggle.Off) { return true; } if (nameHash != SEMan.s_statusEffectFreezing) { return true; } if (!(__instance.m_character is Player)) { return true; } StatusEffect statusEffect = __instance.GetStatusEffect(nameHash); if ((Object)(object)statusEffect == (Object)null) { return true; } if (statusEffect.m_category != "Seasonality") { return true; } if (__instance.HaveStatusEffect(SEMan.s_statusEffectCampFire)) { statusEffect.m_ttl -= 0.25f; } return false; } } [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(1)] private static ConfigEntry<Toggle> enabled; public static void Setup() { enabled = ConfigManager.config("Winter", "Wet Freezes", Toggle.Off, "If on, player will freeze if wet during winter"); } } [<4af3f4ef-ea7b-4293-bb3f-53fe8e6a5a3b>Nullable(0)] [<02ad58ae-8ed5-4d3c-913d-a91400407711>NullableContext(1)] public class Records { private static string ConfigFolder; private static string FileName; private static string FilePath; private readonly ManualLogSource m_manualLogSource; private readonly List<string> m_records = new List<string>(); public Records(ManualLogSource logger, string folderName, string fileName) { m_manualLogSource = logger; string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFolder = configPath + directorySeparatorChar + folderName; FileName = fileName; string configFolder = ConfigFolder; directorySeparatorChar = Path.DirectorySeparatorChar; FilePath = configFolder + directorySeparatorChar + fileName; } public void LogSuccess(string log) { m_records.Add("[Success]: " + log); } public void LogDebug(string log) { m_records.Add("[Debug]: " + log); m_manualLogSource.LogDebug((object)log); } public void LogInfo(string log) { m_records.Add("[Info]: " + log); m_manualLogSource.LogInfo((object)log); } public void LogWarning(string log) { m_records.Add("[Warning]: " + log); m_manualLogSource.LogWarning((object)log); } public void LogError(string log) { m_records.Add("[Error]: " + log); m_manualLogSource.LogError((object)log); } public void Write() { if (!Directory.Exists(ConfigFolder)) { Directory.CreateDirectory(ConfigFolder); } File.WriteAllLines(FilePath, m_records); LogInfo(FileName + " wrote to file: " + FilePath); } static Records() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFolder = configPath + direct