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.0
Seasonality.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.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.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyFileVersion("3.8.0")] [assembly: AssemblyCompany("RustyMods")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("3.8.0.0")] [module: <ae650d74-94f2-479b-8dd0-feb21e5725ca>RefSafetyRules(11)] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [<3e1f5bd2-754e-4a19-b0c5-f7a086bba6bc>Embedded] internal sealed class <3e1f5bd2-754e-4a19-b0c5-f7a086bba6bc>EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [<3e1f5bd2-754e-4a19-b0c5-f7a086bba6bc>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class <e20e6f32-22c3-4b84-81bd-a666c1d7c470>NullableAttribute : Attribute { public readonly byte[] NullableFlags; public <e20e6f32-22c3-4b84-81bd-a666c1d7c470>NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public <e20e6f32-22c3-4b84-81bd-a666c1d7c470>NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [<3e1f5bd2-754e-4a19-b0c5-f7a086bba6bc>Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContextAttribute : Attribute { public readonly byte Flag; public <3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [<3e1f5bd2-754e-4a19-b0c5-f7a086bba6bc>Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class <ae650d74-94f2-479b-8dd0-feb21e5725ca>RefSafetyRulesAttribute : Attribute { public readonly int Version; public <ae650d74-94f2-479b-8dd0-feb21e5725ca>RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LocalizationManager { [PublicAPI] [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(0)] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] public class Localizer { private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors; private static readonly Dictionary<string, Dictionary<string, string>> loadedTexts; private static readonly ConditionalWeakTable<Localization, string> localizationLanguage; private static readonly List<WeakReference<Localization>> localizationObjects; [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(2)] private static BaseUnityPlugin _plugin; private static readonly List<string> fileExtensions; private static BaseUnityPlugin plugin { get { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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([<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(2)] [method: <3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(2)] [field: <e20e6f32-22c3-4b84-81bd-a666c1d7c470>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, [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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, [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>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 += [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0224: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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: <e20e6f32-22c3-4b84-81bd-a666c1d7c470>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; } [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(2)] public static byte[] ReadEmbeddedFileBytes([<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(1)] string resourceFileName, Assembly containingAssembly = null) { using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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 { [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(1)] public const string Version = "1.4.1"; } } namespace Seasonality { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(0)] public class SeasonalIce : MonoBehaviour { private static GameObject Ice = null; private static readonly ZoneVegetation ZoneVeg = new ZoneVegetation(); private static readonly List<SeasonalIce> m_instances = new List<SeasonalIce>(); private Destructible m_destructible; public void Awake() { m_destructible = ((Component)this).GetComponent<Destructible>(); m_instances.Add(this); ((MonoBehaviour)this).InvokeRepeating("CheckSeason", 0f, 10f); } public void OnDestroy() { m_instances.Remove(this); } public void CheckSeason() { if (Configs.m_season.Value != 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 (Configs.m_season.Value == Season.Winter && Configs.m_addIceShelves.Value == Toggle.On) { if (!ZoneSystem.instance.m_vegetation.Contains(ZoneVeg)) { ZoneSystem.instance.m_vegetation.Add(ZoneVeg); } } else { ZoneSystem.instance.m_vegetation.Remove(ZoneVeg); } } public static void Setup() { Clone clone = new Clone("ice1", "SeasonalIce"); clone.OnCreated += delegate(GameObject p) { //IL_0049: 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) p.AddComponent<SeasonalIce>(); ZoneVeg.m_name = "SeasonalIce"; ZoneVeg.m_prefab = p; ZoneVeg.m_min = 10f; ZoneVeg.m_max = 20f; ZoneVeg.m_biome = (Biome)539; ZoneVeg.m_biomeArea = (BiomeArea)3; ZoneVeg.m_blockCheck = true; ZoneVeg.m_minAltitude = -1000f; ZoneVeg.m_maxAltitude = -1f; UpdateZoneVeg(); Ice = p; }; } } public class RandomColors : MonoBehaviour { [HarmonyPatch(typeof(ZNetScene), "Awake")] private static class ZNetScene_Awake_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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); } } }; } } [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(new byte[] { 2, 1 })] public Renderer[] m_renderers; [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(2)] public ParticleSystem m_particleSystem; public MinMaxGradient m_originalGradient; [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(1)] public static readonly List<RandomColors> m_instances = new List<RandomColors>(); [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(1)] private static readonly List<GameObject> m_modifiedPrefabs = new List<GameObject>(); public void Awake() { if (Configs.m_randomColors.Value != 0 && 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) if (Configs.m_particlesController.Value != 0 && !((Object)(object)m_particleSystem == (Object)null)) { MainModule main = m_particleSystem.main; m_originalGradient = ((MainModule)(ref main)).startColor; MinMaxGradient startColor; switch (Configs.m_season.Value) { 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; } } } } [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(0)] public class FrozenWaterLOD : MonoBehaviour { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] [HarmonyPatch(typeof(Game), "Start")] private static class Game_Start_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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; public Material m_originalMat; public bool m_frozen; private static readonly List<FrozenWaterLOD> Instances = new List<FrozenWaterLOD>(); public static void UpdateAll() { foreach (FrozenWaterLOD instance in Instances) { if (Configs.m_season.Value == Season.Winter && Configs.m_waterFreezes.Value == Toggle.On) { instance.Freeze(); } else { instance.Thaw(); } } } public void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) m_originalPos = ((Component)this).transform.position; m_renderer = ((Component)this).GetComponent<MeshRenderer>(); m_originalMat = ((Renderer)m_renderer).material; SetInitialValues(); Instances.Add(this); } private void SetInitialValues() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)m_renderer)) { if (Configs.m_waterFreezes.Value == Toggle.On && Configs.m_season.Value == Season.Winter) { ((Renderer)m_renderer).material = SeasonalityPlugin.FrozenWaterMat1; ((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 void OnDestroy() { Instances.Remove(this); } public void Thaw() { //IL_0021: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!m_frozen) { ((Renderer)m_renderer).material = SeasonalityPlugin.FrozenWaterMat1; ((Component)this).transform.position = m_originalPos + new Vector3(0f, -0.2f, 0f); m_frozen = true; } } } [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(0)] public class FrozenZones : MonoBehaviour { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] [HarmonyPatch(typeof(ZoneSystem), "Start")] private static class ZoneSystem_Start_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] private static void Postfix(ZoneSystem __instance) { if (Object.op_Implicit((Object)(object)__instance)) { __instance.m_zonePrefab.AddComponent<FrozenZones>(); } } } public MeshCollider m_surfaceCollider; public MeshRenderer m_surfaceRenderer; public WaterVolume m_waterVolume; public Material m_originalMaterial; private static readonly List<FrozenZones> Instances = new List<FrozenZones>(); public bool m_frozen; public static void UpdateAll() { foreach (FrozenZones instance in Instances) { if (Configs.m_waterFreezes.Value == Toggle.Off) { instance.ThawWater(); } else if (Configs.m_season.Value == Season.Winter) { instance.FreezeWater(); } else { instance.ThawWater(); } } } public void Awake() { 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; m_surfaceCollider.sharedMesh = component.sharedMesh; SetInitialValues(); if (!Instances.Contains(this)) { Instances.Add(this); } } public void OnDestroy() { Instances.Remove(this); } private void SetInitialValues() { if (Configs.m_season.Value == Season.Winter && Configs.m_waterFreezes.Value == Toggle.On) { ((Renderer)m_surfaceRenderer).material = SeasonalityPlugin.FrozenWaterMat1; ((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 = SeasonalityPlugin.FrozenWaterMat1; ((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_" + Configs.m_season.Value.ToString().ToLower()); } } } public class MossController : MonoBehaviour { [HarmonyPatch(typeof(BossStone), "Start")] private static class BossStone_Start_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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(); } } } [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(1)] private readonly Dictionary<Material, Texture> m_textureMap = new Dictionary<Material, Texture>(); private static readonly int MossTex = Shader.PropertyToID("_MossTex"); [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>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 (Configs.m_season.Value) { 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); } } } [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(0)] public class LocationFix : MonoBehaviour { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] [HarmonyPatch(typeof(ZoneSystem), "SpawnLocation")] private static class ZoneSystem_SpawnLocation_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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; 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_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_0018: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 Biome biome = WorldGenerator.instance.GetBiome(((Component)this).transform.position); Texture val; if ((int)biome <= 2) { if ((int)biome == 1) { goto IL_0037; } if ((int)biome != 2) { goto IL_0093; } val = TextureManager.stonemoss_swamp.m_tex; } else { if ((int)biome == 8) { goto IL_0037; } if ((int)biome != 16) { if ((int)biome != 512) { goto IL_0093; } val = (((Object)((Component)this).transform).name.ToLower().Contains("dvergr") ? TextureManager.groundcreep_d.m_tex : TextureManager.stonemoss_bw.m_tex); } else { val = TextureManager.Stonemoss_heath.m_tex; } } goto IL_009e; IL_009e: if (!((Object)(object)val != (Object)null)) { return current; } return val; IL_0037: val = TextureManager.stonemoss.m_tex; goto IL_009e; IL_0093: val = TextureManager.stonemoss.m_tex; goto IL_009e; } 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 if ((int)WorldGenerator.instance.GetBiome(((Component)this).transform.position) == 4) { return; } switch (Configs.m_season.Value) { 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(); } } } [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(0)] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] public static class SeasonSE { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] [HarmonyPatch(typeof(ObjectDB), "Awake")] private static class ObjectDB_Awake_Patch { private static void Postfix() { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && Object.op_Implicit((Object)(object)ZNetScene.instance)) { SE_Season sE_Season = ScriptableObject.CreateInstance<SE_Season>(); ((Object)sE_Season).name = "SE_Seasons"; ((StatusEffect)sE_Season).m_name = "Seasonality"; ((StatusEffect)sE_Season).m_icon = GetIcon(); if (!ObjectDB.instance.m_StatusEffects.Contains((StatusEffect)(object)sE_Season)) { ObjectDB.instance.m_StatusEffects.Add((StatusEffect)(object)sE_Season); } } } } [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(0)] public class SE_Season : StatusEffect { public override void Setup(Character character) { Update(); ((StatusEffect)this).Setup(character); } public void Update() { base.m_name = ((Configs.m_displayType.Value == DisplayType.Above) ? GetSeasonName() : ""); base.m_icon = ((Configs.m_displaySeason.Value == Toggle.On) ? GetIcon() : null); } public override string GetTooltipString() { StringBuilder stringBuilder = new StringBuilder(); string text = Localization.instance.Localize("$season_" + Configs.m_season.Value.ToString().ToLower() + "_tooltip"); if (!text.Contains("[")) { stringBuilder.Append("$season_" + Configs.m_season.Value.ToString().ToLower() + "_tooltip\n"); } stringBuilder.Append("Modifiers Enabled: " + Configs.m_enableModifiers.Value.ToString() + "\n"); stringBuilder.Append(GetToolTip("Carry Weight", "$se_max_carryweight")); stringBuilder.Append(GetToolTip("Health Regeneration", "$se_healthregen")); stringBuilder.Append(GetToolTip("Damage", "$se_damage")); stringBuilder.Append(GetToolTip("Speed", "$item_movement_modifier")); stringBuilder.Append(GetToolTip("Eitr Regeneration", "$se_eitrregen")); stringBuilder.Append(GetToolTip("Raise Skill", "$se_skill_modifier")); stringBuilder.Append(GetToolTip("Stamina Regeneration", "$se_staminaregen")); return Localization.instance.Localize(stringBuilder.ToString()); } private string GetToolTip(string key, string token) { if (!Configs.m_effectConfigs.TryGetValue(Configs.m_season.Value, out var value)) { return ""; } if (!value.TryGetValue(key, out var value2)) { return ""; } return FormatTooltip(token, value2, key == "Carry Weight"); } private string FormatTooltip(string token, [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(2)] ConfigEntry<float> config, bool integer) { float num = ((!integer) ? (config?.Value ?? 1f) : (config?.Value ?? 0f)); string text = ((integer ? (num > 0f) : (num > 1f)) ? "+" : ""); string text2 = (integer ? "" : "%"); float num2 = (integer ? num : (num * 100f - 100f)); if (num2 == 0f) { return ""; } return $"{token}: <color=orange>{text}{Math.Round(num2, 1)}{text2}</color>\n"; } public override string GetIconText() { if (!Object.op_Implicit((Object)(object)EnvMan.instance)) { return ""; } if (Configs.m_displayTimer.Value != 0) { if (Configs.m_displayType.Value != 0) { return GetSeasonName() + "\n" + GetSeasonTime(); } return GetSeasonTime(); } if (Configs.m_displayType.Value != 0) { return GetSeasonName(); } return ""; } private static string GetSeasonName() { return Localization.instance.Localize("$season_" + Configs.m_season.Value.ToString().ToLower()); } public override void ModifyStaminaRegen(ref float staminaRegen) { if (Configs.m_enableModifiers.Value != 0) { staminaRegen *= Configs.m_effectConfigs.GetOrDefault(Configs.m_season.Value, "Stamina Regeneration", 1f); } } public override void ModifyMaxCarryWeight(float baseLimit, ref float limit) { if (Configs.m_enableModifiers.Value != 0) { limit += Configs.m_effectConfigs.GetOrDefault("Carry Weight", 0f); } } public override void ModifyRaiseSkill(SkillType skill, ref float value) { if (Configs.m_enableModifiers.Value != 0) { value *= Configs.m_effectConfigs.GetOrDefault("Raise Skill", 1f); } } public override void ModifyEitrRegen(ref float eitrRegen) { if (Configs.m_enableModifiers.Value != 0) { eitrRegen *= Configs.m_effectConfigs.GetOrDefault("Eitr Regeneration", 1f); } } public override void ModifyHealthRegen(ref float regenMultiplier) { if (Configs.m_enableModifiers.Value != 0) { regenMultiplier *= Configs.m_effectConfigs.GetOrDefault("Health Regeneration", 1f); } } public override void ModifyAttack(SkillType skill, ref HitData hitData) { if (Configs.m_enableModifiers.Value != 0) { hitData.ApplyModifier(Configs.m_effectConfigs.GetOrDefault("Damage", 1f)); } } public override void ModifySpeed(float baseSpeed, ref float speed, Character character, Vector3 dir) { if (Configs.m_enableModifiers.Value != 0) { speed *= Configs.m_effectConfigs.GetOrDefault("Speed", 1f); } } public override void OnDamaged(HitData hit, Character attacker) { if (FadeToBlack.m_fading && Configs.m_fadeToBlackImmune.Value == Toggle.On) { hit.ApplyModifier(0f); } } } private const string SE_Seasons = "SE_Seasons"; private static readonly int SE_Season_StableHashCode = StringExtensionMethods.GetStableHashCode("SE_Seasons"); private static float m_timer; public static void CheckOrSet(float dt) { m_timer += dt; if (!(m_timer <= 10f)) { m_timer = 0f; if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && !((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(SE_Season_StableHashCode)) { ((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(SE_Season_StableHashCode, false, 0, 0f); } } } public static void UpdateStatus() { if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && ((Character)Player.m_localPlayer).GetSEMan().GetStatusEffect(SE_Season_StableHashCode) is SE_Season sE_Season) { sE_Season.Update(); } } private static bool ShouldCount() { return GetTotalSeconds() > 0.0; } [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(2)] private static Sprite GetIcon() { return (Sprite)(Configs.m_season.Value switch { Season.Spring => SpriteManager.SpringIcon, Season.Summer => SpriteManager.SummerIcon, Season.Fall => SpriteManager.FallIcon, Season.Winter => SpriteManager.WinterIcon, _ => SpriteManager.ValknutIcon, }); } private static double GetTotalSeconds() { //IL_0020: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) ConfigEntry<Vector3> value; Vector3 val = (Configs.m_durations.TryGetValue(Configs.m_season.Value, out value) ? value.Value : Vector3.zero); double num = val.x * 86400f; double num2 = val.y * 3600f; double num3 = val.z * 60f; return num + num2 + num3; } public static void OnSeasonDisplayConfigChange(object sender, EventArgs e) { if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)Hud.instance)) { if (((Character)Player.m_localPlayer).GetSEMan().GetStatusEffect(SE_Season_StableHashCode) is SE_Season sE_Season) { sE_Season.Update(); } if (Hud.instance.m_tempStatusEffects.Find([<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] (StatusEffect x) => x.m_nameHash == SE_Season_StableHashCode) is SE_Season sE_Season2) { sE_Season2.Update(); } } } private static string GetSeasonTime() { if (!ShouldCount()) { return ""; } TimeSpan timeSpan = TimeSpan.FromSeconds(SeasonalTimer.GetTimeDifference()); int days = timeSpan.Days; int hours = timeSpan.Hours; int minutes = timeSpan.Minutes; int seconds = timeSpan.Seconds; if (SeasonalTimer.m_sleepOverride) { return Localization.instance.Localize("$msg_ready"); } if (days <= 0) { if (hours <= 0) { if (minutes <= 0) { return $"{seconds}"; } return $"{minutes}:{seconds:D2}"; } return $"{hours}:{minutes:D2}:{seconds:D2}"; } return string.Format("{0} {1}", days, Localization.instance.Localize((days > 1) ? "$label_days" : "$label_day")); } } public class TerrainController : MonoBehaviour { [HarmonyPatch(typeof(Heightmap), "Awake")] private static class Heightmap_Awake_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] private static void Postfix(Heightmap __instance) { ((Component)__instance).gameObject.AddComponent<TerrainController>(); } } [HarmonyPatch(typeof(Heightmap), "OnEnable")] private static class Heightmap_OnEnable_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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 { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_004d: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 //IL_0017: 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_0036: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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 switch (Configs.m_season.Value) { 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; } } } [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(1)] private static readonly List<TerrainController> m_instances = new List<TerrainController>(); [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(2)] private Heightmap m_heightmap; [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017a: 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 { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] private static void Postfix(Player __instance) { ((Component)__instance).gameObject.AddComponent<VisEquipController>(); } } [HarmonyPatch(typeof(VisEquipment), "SetChestEquipped")] private static class VisEquipment_SetChestEquipped_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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 { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] private static void Postfix(VisEquipment __instance, bool __result) { VisEquipController visEquipController = default(VisEquipController); if (__result && ((Component)__instance).TryGetComponent<VisEquipController>(ref visEquipController)) { visEquipController.UpdateLegTexture(); } } } [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(1)] public static readonly List<VisEquipController> m_instances = new List<VisEquipController>(); [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>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(Configs.m_season.Value, 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(Configs.m_season.Value, 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(); } } } [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(0)] public static class WeatherManager { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] [HarmonyPatch(typeof(EnvMan), "GetAvailableEnvironments")] private static class GetAvailableEnvironments_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] private static void Postfix(Biome biome, ref List<EnvEntry> __result) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (Configs.m_weatherEnabled.Value != 0 && (((int)biome != 0 && (int)biome != 32) || 1 == 0)) { __result = GetEnvironments(biome, __result); } } } [HarmonyPatch(typeof(EnvMan), "Awake")] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] private static class EnvMan_Awake_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] private static void Postfix(EnvMan __instance) { if (Object.op_Implicit((Object)(object)__instance)) { RegisterEnvironments(__instance); if (Configs.m_weatherEnabled.Value != 0) { __instance.m_environmentDuration = Configs.m_weatherDuration.Value * 60; } } } } [HarmonyPatch(typeof(EnvMan), "IsCold")] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] private static class EnvMan_IsCold_Patch { private static void Postfix(ref bool __result) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Configs.m_winterAlwaysCold.Value != 0 && Configs.m_season.Value == Season.Winter && (int)Player.m_localPlayer.GetCurrentBiome() != 32) { __result = true; } } } [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] [HarmonyPatch(typeof(ObjectDB), "Awake")] private static class ObjectDB_Awake_Patch { private static void Postfix() { if (Object.op_Implicit((Object)(object)ObjectDB.instance) && Object.op_Implicit((Object)(object)ZNetScene.instance)) { SE_WeatherMan sE_WeatherMan = ScriptableObject.CreateInstance<SE_WeatherMan>(); ((Object)sE_WeatherMan).name = "SE_Weatherman"; ((StatusEffect)sE_WeatherMan).m_name = "Weatherman"; ((StatusEffect)sE_WeatherMan).m_icon = SpriteManager.ValknutIcon; if (!ObjectDB.instance.m_StatusEffects.Contains((StatusEffect)(object)sE_WeatherMan)) { ObjectDB.instance.m_StatusEffects.Add((StatusEffect)(object)sE_WeatherMan); } } } } [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(0)] public class SE_WeatherMan : StatusEffect { public override void Setup(Character character) { ((StatusEffect)this).Setup(character); Update(); } public void Update() { base.m_icon = ((Configs.m_displayWeather.Value == Toggle.On) ? SpriteManager.ValknutIcon : null); } public override string GetTooltipString() { string text = Localization.instance.Localize("$weather_" + EnvMan.instance.m_currentEnv.m_name.ToLower().Replace(" ", "_") + "_tooltip"); if (text.Contains("[")) { text = ""; } return base.m_tooltip + text; } public override string GetIconText() { if ((Object)(object)EnvMan.instance == (Object)null) { return ""; } string name = EnvMan.instance.m_currentEnv.m_name; string text = Localization.instance.Localize("$weather_" + EnvMan.instance.m_currentEnv.m_name.ToLower().Replace(" ", "_")); base.m_name = (text.Contains("[") ? name : text); if (Configs.m_displayWeatherTimer.Value == Toggle.Off) { return ""; } double num = EnvMan.instance.m_totalSeconds / (double)EnvMan.instance.m_environmentDuration; double num2 = 1.0 - (num - Math.Truncate(num)); double num3 = num2 * (double)EnvMan.instance.m_environmentDuration; int hours = TimeSpan.FromSeconds(num3).Hours; int minutes = TimeSpan.FromSeconds(num3).Minutes; int seconds = TimeSpan.FromSeconds(num3).Seconds; if (num3 < 0.0) { return ""; } if (hours <= 0) { if (minutes <= 0) { return $"{seconds}"; } return $"{minutes}:{seconds:D2}"; } return $"{hours}:{minutes:D2}:{seconds:D2}"; } } private const string SE_Weather = "SE_Weatherman"; private static readonly int SE_Weather_StableHashCode = StringExtensionMethods.GetStableHashCode("SE_Weatherman"); private static float m_timer; private static void RegisterEnvironments(EnvMan __instance) { EnvSetup env = __instance.GetEnv("Snow"); EnvSetup env2 = __instance.GetEnv("SnowStorm"); if (env != null && env2 != null) { EnvSetup val = env.Clone(); val.m_isFreezing = false; val.m_isFreezingAtNight = false; val.m_name = "WarmSnow"; EnvSetup val2 = env2.Clone(); val2.m_isFreezing = false; val2.m_isFreezingAtNight = false; val2.m_name = "WarmSnowStorm"; EnvSetup val3 = env.Clone(); val3.m_isFreezing = false; val3.m_name = "NightFrost"; val3.m_isFreezingAtNight = true; RegisterEnv(val); RegisterEnv(val2); RegisterEnv(val3); } } private static void RegisterEnv(EnvSetup setup) { if (Object.op_Implicit((Object)(object)EnvMan.instance) && !EnvMan.instance.m_environments.Contains(setup)) { EnvMan.instance.m_environments.Add(setup); } } public static void OnWeatherDurationChange(object sender, EventArgs e) { if (Object.op_Implicit((Object)(object)EnvMan.instance) && Configs.m_weatherEnabled.Value != 0) { EnvMan.instance.m_environmentDuration = Configs.m_weatherDuration.Value * 60; } } private static List<EnvEntry> GetEnvironments(Biome biome, List<EnvEntry> entries) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)EnvMan.instance)) { return entries; } List<EnvEntry> list = new List<EnvEntry>(); if (!Configs.m_weatherOptions.TryGetValue(Configs.m_season.Value, out var value)) { return entries; } if (!value.TryGetValue(biome, out var value2)) { return entries; } if (Utility.IsNullOrWhiteSpace(value2.Value)) { return entries; } foreach (WeatherConfig.WeatherData environment in new WeatherConfig(value2.Value).environments) { EnvSetup env = EnvMan.instance.GetEnv(environment.name); if (env != null) { EnvEntry item = new EnvEntry { m_environment = environment.name, m_weight = environment.weight, m_env = env }; list.Add(item); } } if (list.Count <= 0) { return entries; } return list; } public static void OnDisplayConfigChange(object sender, EventArgs e) { if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && ((Character)Player.m_localPlayer).GetSEMan().GetStatusEffect(SE_Weather_StableHashCode) is SE_WeatherMan sE_WeatherMan) { sE_WeatherMan.Update(); } } public static void CheckOrSet(float dt) { if (Configs.m_displayWeather.Value == Toggle.Off) { return; } m_timer += dt; if (!(m_timer < 10f)) { m_timer = 0f; if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && !((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(SE_Weather_StableHashCode)) { ((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(SE_Weather_StableHashCode, false, 0, 0f); } } } } [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(0)] public static class BeeHiveTweaks { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] [HarmonyPatch(typeof(Beehive), "Interact")] private static class Beehive_Interact_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] private static bool Prefix(Beehive __instance, Humanoid character) { switch (Configs.m_season.Value) { case Season.Summer: if (SummerEnabled.Value == Toggle.Off) { ((Character)character).Message((MessageType)2, __instance.m_areaText, 0, (Sprite)null); return false; } return true; case Season.Fall: if (FallEnabled.Value == Toggle.Off) { ((Character)character).Message((MessageType)2, __instance.m_areaText, 0, (Sprite)null); return false; } return true; case Season.Spring: if (SpringEnabled.Value == Toggle.Off) { ((Character)character).Message((MessageType)2, __instance.m_areaText, 0, (Sprite)null); return false; } return true; case Season.Winter: if (WinterEnabled.Value == Toggle.Off) { ((Character)character).Message((MessageType)2, __instance.m_areaText, 0, (Sprite)null); 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"); } } [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(0)] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] public static class BuildTweaks { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] [HarmonyPatch(typeof(PieceTable), "UpdateAvailable")] private static class PieceTable_UpdateAvailable { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] private static void Postfix(PieceTable __instance, Player player) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Invalid comparison between Unknown and I4 //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected I4, but got Unknown if (m_enabled.Value == Toggle.Off) { return; } Piece component = 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 component) || !player.HaveRequirements(component, (RequirementMode)2)) { continue; } if ((int)component.m_category == 100) { foreach (List<Piece> item in __instance.m_availablePieces.Where((List<Piece> list) => !list.Contains(component))) { item.Add(component); } } else { List<Piece> list2 = __instance.m_availablePieces[(int)component.m_category]; if (!list2.Contains(component)) { list2.Add(component); } } } } } 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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() { return (ConfigEntry<string>)(Configs.m_season.Value switch { Season.Summer => m_summerPieces, Season.Spring => m_springPieces, Season.Fall => m_fallPieces, Season.Winter => m_winterPieces, _ => m_summerPieces, }); } } 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 Configs.m_season.Value != Season.Winter; } } [HarmonyPatch(typeof(Fish), "GetHoverText")] private static class Fish_GetHoverText_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] private static void Postfix(ref string __result) { if (m_enabled.Value != 0 && Configs.m_season.Value == Season.Winter) { __result += Localization.instance.Localize("\n $cannot_pick"); } } } [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>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"); } } [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(0)] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] public static class PickableTweaks { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] [HarmonyPatch(typeof(Pickable), "Awake")] private static class Pickable_Awake_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] [UsedImplicitly] private static void Postfix(Pickable __instance) { if (m_enabled.Value != 0 && GetHarvestData(((Object)__instance).name.Replace("(Clone)", string.Empty), out var result)) { __instance.m_amount = result.Amount; } } } [HarmonyPatch(typeof(Pickable), "Interact")] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] private static class Pickable_Interact_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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; } } [HarmonyPatch(typeof(Pickable), "GetHoverText")] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] private static class Pickable_GetHoverText_Patch { [UsedImplicitly] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] private static void Postfix(Pickable __instance, ref string __result) { if (m_enabled.Value != 0 && GetHarvestData(((Object)__instance).name.Replace("(Clone)", string.Empty), out var result) && !result.CanHarvest) { __result += Localization.instance.Localize("\n <color=red>$cannot_pick</color>"); } } } [Serializable] [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(0)] public class Harvest { [Serializable] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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 (Configs.m_season.Value) { 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(); } } [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(0)] public static class PlantTweaks { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] [HarmonyPatch(typeof(Plant), "Grow")] private static class Plant_Grow_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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; } return Configs.m_season.Value switch { Season.Spring => value.Spring.CanHarvest, Season.Summer => value.Summer.CanHarvest, Season.Fall => value.Fall.CanHarvest, Season.Winter => value.Winter.CanHarvest, _ => true, }; } } [HarmonyPatch(typeof(Plant), "GetStatus")] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] private static class Plant_GetStatus_Patch { [UsedImplicitly] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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 (Configs.m_season.Value) { 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; } } } [HarmonyPatch(typeof(Plant), "GetHoverText")] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] private static class Plant_GetHoverText_Patch { [UsedImplicitly] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] 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 (Configs.m_season.Value) { 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>$" + Configs.m_season.Value.ToString().ToLower() + "_cannot_grow</color>"); } } [HarmonyPatch(typeof(Plant), "Awake")] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] private static class Plant_Awake_Patch { [UsedImplicitly] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] private static void Postfix(Plant __instance) { if (m_enabled.Value != 0 && m_data.TryGetValue(((Object)__instance).name.Replace("(Clone)", string.Empty), out var value)) { Plants.Data data; switch (Configs.m_season.Value) { 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] [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(0)] public class Plants { [Serializable] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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(); } } [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(0)] public static class SpawnTweaks { [HarmonyPatch(typeof(SpawnSystem), "Spawn")] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] private static class SpawnSystem_Spawn_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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(Configs.m_season.Value, out value2) || value2; } } [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] [HarmonyPatch(typeof(SpawnArea), "SpawnOne")] private static class SpawnArea_SpawnOne_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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(Configs.m_season.Value, out var value2) && !value2) { return false; } } return true; } } [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] [HarmonyPatch(typeof(BaseAI), "UpdateAI")] private static class BaseAI_UpdateAI_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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(Configs.m_season.Value, 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)); } } } [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(0)] public static class TraderTweaks { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] [HarmonyPatch(typeof(Trader), "GetAvailableItems")] private static class Trader_GetAvailableItems_Patch { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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() { return (ConfigEntry<string>)(Configs.m_season.Value switch { Season.Summer => m_summerItems, Season.Fall => m_fallItems, Season.Winter => m_winterItems, Season.Spring => m_springItems, _ => m_summerItems, }); } } [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(0)] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(2)] public static class TweaksManager { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] [HarmonyPatch(typeof(ZNet), "Awake")] private static class ZNet_Awake_Patch { [UsedImplicitly] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] private static void Postfix(ZNet __instance) { if (__instance.IsServer()) { TweaksManager.OnZNetAwake?.Invoke(); } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(0)] private static class ZNetScene_Awake_Patch { [UsedImplicitly] [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] 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(); } } [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(1)] private static readonly string ConfigFolder; [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(1)] public static readonly string FolderPath; public static event Action OnZNetAwake; [<e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(new byte[] { 2, 1 })] [method: <e20e6f32-22c3-4b84-81bd-a666c1d7c470>Nullable(new byte[] { 2, 1 })] [field: <e20e6f32-22c3-4b84-81bd-a666c1d7c470>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 { [<3d484f37-b8bf-4db0-963a-5fc4e45f8ce1>NullableContext(1)] public static void Postfix(Player __instance) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Invalid comparison between Unknown and I4 //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 if (enabled.Value == Toggle.Off || Configs.m_season.Value != 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) {