using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using ConditionalConfigSync; using HarmonyLib; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Seasons; using Seasons.Compatibility; using Seasons.Controllers; using Splatform; using TMPro; using UnityEngine; using UnityEngine.Experimental.Rendering; using UnityEngine.Networking; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Seasons")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Seasons")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("076e7e5f-9182-41e5-a76b-5c051d6b3957")] [assembly: AssemblyFileVersion("1.8.2")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.8.2.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } public struct HSLColor { public float h; public float s; public float l; public float a; public HSLColor(float h, float s, float l, float a) { this.h = h; this.s = s; this.l = l; this.a = a; } public HSLColor(float h, float s, float l) { this.h = h; this.s = s; this.l = l; a = 1f; } public HSLColor(Color c) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) HSLColor hSLColor = FromRGBA(c); h = hSLColor.h; s = hSLColor.s; l = hSLColor.l; a = hSLColor.a; } public static HSLColor FromRGBA(Color c) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) float num = c.a; float num2 = Mathf.Min(Mathf.Min(c.r, c.g), c.b); float num3 = Mathf.Max(Mathf.Max(c.r, c.g), c.b); float num4 = (num2 + num3) / 2f; float num5; float num6; if (num2 == num3) { num5 = 0f; num6 = 0f; } else { float num7 = num3 - num2; num5 = ((num4 <= 0.5f) ? (num7 / (num3 + num2)) : (num7 / (2f - (num3 + num2)))); num6 = 0f; if (c.r == num3) { num6 = (c.g - c.b) / num7; } else if (c.g == num3) { num6 = 2f + (c.b - c.r) / num7; } else if (c.b == num3) { num6 = 4f + (c.r - c.g) / num7; } num6 = Mathf.Repeat(num6 * 60f, 360f); } return new HSLColor(num6, num5, num4, num); } public Color ToRGBA() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) float num = a; float num2 = ((l <= 0.5f) ? (l * (1f + s)) : (l + s - l * s)); float n = 2f * l - num2; float num3; float num4; float num5; if (s == 0f) { num3 = (num4 = (num5 = l)); } else { num3 = Value(n, num2, h + 120f); num4 = Value(n, num2, h); num5 = Value(n, num2, h - 120f); } return new Color(num3, num4, num5, num); } private static float Value(float n1, float n2, float hue) { hue = Mathf.Repeat(hue, 360f); if (hue < 60f) { return n1 + (n2 - n1) * hue / 60f; } if (hue < 180f) { return n2; } if (hue < 240f) { return n1 + (n2 - n1) * (240f - hue) / 60f; } return n1; } public static implicit operator HSLColor(Color src) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return FromRGBA(src); } public static implicit operator Color(HSLColor src) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) return src.ToRGBA(); } } namespace LocalizationManager { [PublicAPI] public class Localizer { private const string defaultLanguage = "English"; private static readonly Dictionary>> PlaceholderProcessors; private static readonly Dictionary> loadedTexts; private static readonly ConditionalWeakTable localizationLanguage; private static readonly List> localizationObjects; private static BaseUnityPlugin? _plugin; private static readonly List fileExtensions; private static BaseUnityPlugin Plugin { get { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown if (_plugin == null) { IEnumerable source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First((TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } private static void UpdatePlaceholderText(Localization localization, string key) { localizationLanguage.TryGetValue(localization, out string value); string text = loadedTexts[value][key]; if (PlaceholderProcessors.TryGetValue(key, out Dictionary> value2)) { text = value2.Aggregate(text, (string current, KeyValuePair> kv) => current.Replace("{" + kv.Key + "}", kv.Value())); } localization.AddWord(key, text); } public static void AddPlaceholder(string key, string placeholder, ConfigEntry config, Func? convertConfigValue = null) where T : notnull { if (convertConfigValue == null) { convertConfigValue = (T val) => val.ToString(); } if (!PlaceholderProcessors.ContainsKey(key)) { PlaceholderProcessors[key] = new Dictionary>(); } config.SettingChanged += delegate { UpdatePlaceholder(); }; if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage())) { UpdatePlaceholder(); } void UpdatePlaceholder() { PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value); UpdatePlaceholderText(Localization.instance, key); } } public static void AddText(string key, string text) { List> list = new List>(); foreach (WeakReference localizationObject in localizationObjects) { if (localizationObject.TryGetTarget(out var target)) { Dictionary dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)]; if (!target.m_translations.ContainsKey(key)) { dictionary[key] = text; target.AddWord(key, text); } } else { list.Add(localizationObject); } } foreach (WeakReference item in list) { localizationObjects.Remove(item); } } public static IEnumerator Load() { yield return (object)new WaitUntil((Func)(() => PlatformManager.DistributionPlatform != null && PlatformInitializer.PreferencesInitialized)); if (string.IsNullOrEmpty(PlatformPrefs.GetString("language", ""))) { PlatformPrefs.SetString("language", "English"); } LoadLocalization(Localization.instance, Localization.instance.GetSelectedLanguage()); } private static void LoadLocalization(Localization __instance, string language) { if (!localizationLanguage.Remove(__instance)) { localizationObjects.Add(new WeakReference(__instance)); } localizationLanguage.Add(__instance, language); Dictionary localizationFiles = new Dictionary(); string[] prefixes = new string[2] { Plugin.Info.Metadata.Name + ".", Plugin.Info.Metadata.Name.Replace(" ", "") + "." }; Scan(Paths.ConfigPath, warn: true); Scan(Paths.PluginPath, warn: false); byte[] array = LoadTranslationFromAssembly("English"); if (array == null) { throw new Exception("Found no English localizations in mod " + Plugin.Info.Metadata.Name + ". Expected an embedded resource Translations/English.json or Translations/English.yml."); } Dictionary dictionary = JsonConvert.DeserializeObject>(Encoding.UTF8.GetString(array)) ?? throw new Exception("Localization for mod " + Plugin.Info.Metadata.Name + " failed: Localization file was empty."); string text = null; if (language != "English") { if (localizationFiles.ContainsKey(language)) { text = File.ReadAllText(localizationFiles[language]); } else { byte[] array2 = LoadTranslationFromAssembly(language); if (array2 != null) { text = Encoding.UTF8.GetString(array2); } } } if (text == null && localizationFiles.ContainsKey("English")) { text = File.ReadAllText(localizationFiles["English"]); } if (text != null) { foreach (KeyValuePair item in JsonConvert.DeserializeObject>(text) ?? new Dictionary()) { dictionary[item.Key] = item.Value; } } loadedTexts[language] = dictionary; foreach (KeyValuePair item2 in dictionary) { UpdatePlaceholderText(__instance, item2.Key); } void Scan(string root, bool warn) { foreach (string item3 in from f in Directory.GetFiles(root, "*.*", SearchOption.AllDirectories) where fileExtensions.Contains(Path.GetExtension(f)) select f) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(item3); string[] array3 = prefixes; foreach (string text2 in array3) { if (fileNameWithoutExtension.StartsWith(text2)) { string text3 = fileNameWithoutExtension.Substring(text2.Length); if (!string.IsNullOrWhiteSpace(text3)) { if (localizationFiles.ContainsKey(text3)) { if (warn) { global::Seasons.Seasons.LogWarning("Duplicate localization '" + text3 + "' for " + Plugin.Info.Metadata.Name + ". Skipping " + item3); } } else { localizationFiles[text3] = item3; } } break; } } } } } static Localizer() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown PlaceholderProcessors = new Dictionary>>(); loadedTexts = new Dictionary>(); localizationLanguage = new ConditionalWeakTable(); localizationObjects = new List>(); fileExtensions = new List { ".json", ".yml" }; Harmony val = new Harmony("org.bepinex.helpers.LocalizationManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static byte[]? LoadTranslationFromAssembly(string language) { foreach (string fileExtension in fileExtensions) { byte[] array = ReadEmbeddedFileBytes("Translations." + language + fileExtension); if (array != null) { return array; } } return null; } public static byte[]? ReadEmbeddedFileBytes(string resourceFileName, Assembly? containingAssembly = null) { using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = containingAssembly.GetManifestResourceNames().FirstOrDefault((string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal)); if (text != null) { containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream); } return (memoryStream.Length == 0L) ? null : memoryStream.ToArray(); } } } namespace Seasons { public static class LoadingTips { [HarmonyPatch(typeof(Hud), "Awake")] public static class Hud_Awake_LoadingTips { private static void Postfix() { UpdateLoadingTips(); } } private static readonly List summerHeatCombinedTips = new List(); public static void UpdateLoadingTips() { if (Seasons.UseTextureControllers() && !((Object)(object)Hud.instance == (Object)null) && SeasonState.IsActive) { UpdateTipBasedOnValue("$seasons_loadscreen_tip_ice", Seasons.enableFrozenWater.Value); UpdateTipBasedOnValue("$seasons_loadscreen_tip_torch", Seasons.seasonState.GetSeasonSettings(Seasons.Season.Winter).m_torchAsFiresource); UpdateTipBasedOnValue("$seasons_loadscreen_tip_harvests", Seasons.seasonState.GetSeasonSettings(Seasons.Season.Spring).m_plantsGrowthMultiplier != 1f || Seasons.seasonState.GetSeasonSettings(Seasons.Season.Summer).m_plantsGrowthMultiplier != 1f); UpdateTipBasedOnValue("$seasons_loadscreen_tip_nights", Seasons.seasonState.GetSeasonSettings(Seasons.Season.Winter).m_nightLength > 30 || Seasons.controlLightings.Value); UpdateTipBasedOnValue("$seasons_loadscreen_tip_overheat", !Seasons.summerHeatEnabled.Value && Seasons.summerHeatAddsExtraWarmCloth.Value && Seasons.seasonState.GetSeasonSettings(Seasons.Season.Summer).m_overheatIn2WarmClothes); UpdateTipBasedOnValue("$seasons_loadscreen_tip_summer_heat", Seasons.summerHeatEnabled.Value); UpdateTipBasedOnValue("$seasons_loadscreen_tip_summer_heat_cold_food", Seasons.summerHeatEnabled.Value && !string.IsNullOrWhiteSpace(Seasons.summerHeatCoolingFoods.Value)); UpdateTipBasedOnValue("$seasons_loadscreen_tip_summer_heat_risk", Seasons.summerHeatEnabled.Value); UpdateTipBasedOnValue("$seasons_loadscreen_tip_firewood", Seasons.seasonState.GetSeasonSettings(Seasons.Season.Winter).m_fireplaceDrainMultiplier > 1f); UpdateTipBasedOnValue("$seasons_loadscreen_tip_perish", Seasons.cropsDiesAfterSetDayInWinter.Value != 0); UpdateTipBasedOnValue("$seasons_loadscreen_tip_traders", Seasons.controlTraders.Value); UpdateTipBasedOnValue("$seasons_loadscreen_tip_stats", Seasons.controlStats.Value); UpdateTipBasedOnValue("$seasons_loadscreen_tip_wolves", Seasons.controlRandomEvents.Value); UpdateTipBasedOnValue("$seasons_loadscreen_tip_swimming", Seasons.freezingSwimmingInWinter.Value); UpdateTipBasedOnValue("$seasons_loadscreen_tip_clutter", Seasons.controlGrass.Value); UpdateSummerHeatCombinedTips(); Hud.instance.m_haveSetupLoadScreen = false; Seasons.LogInfo("Loading tips updated."); } } private static void UpdateTipBasedOnValue(string tip, bool value) { if (Seasons.enableLoadingTips.Value && value && !Hud.instance.m_loadingTips.Contains(tip)) { Hud.instance.m_loadingTips.Add(tip); } else if ((!Seasons.enableLoadingTips.Value || !value) && Hud.instance.m_loadingTips.Contains(tip)) { Hud.instance.m_loadingTips.Remove(tip); } } private static void UpdateSummerHeatCombinedTips() { foreach (string summerHeatCombinedTip in summerHeatCombinedTips) { Hud.instance.m_loadingTips.Remove(summerHeatCombinedTip); } summerHeatCombinedTips.Clear(); if (Seasons.enableLoadingTips.Value && Seasons.summerHeatEnabled.Value) { AddSummerHeatCombinedTips(BuildSummerHeatOutfitTipParts()); AddSummerHeatCombinedTips(BuildSummerHeatBehaviorTipParts()); } } private static IEnumerable BuildSummerHeatOutfitTipParts() { bool armorHeatEnabled = Seasons.summerHeatArmorHeatEnabled.Value; bool hasOutfitSpecificRules = HasText(Seasons.summerHeatOpenHelmetItems.Value) || HasText(Seasons.summerHeatOpenChestItems.Value) || HasText(Seasons.summerHeatOpenLegItems.Value) || HasText(Seasons.summerHeatLightCloakItems.Value) || HasColdWeatherArmorHeatRules(); if (armorHeatEnabled) { yield return "$seasons_loadscreen_tip_summer_heat_clothing"; } if (armorHeatEnabled && hasOutfitSpecificRules) { yield return "$seasons_loadscreen_tip_summer_heat_cold_clothing"; } if (armorHeatEnabled && HasText(Seasons.summerHeatBareHeadHairItems.Value)) { yield return "$seasons_loadscreen_tip_summer_heat_hairstyle"; } } private static IEnumerable BuildSummerHeatBehaviorTipParts() { if (Seasons.summerHeatInstantHeatSources.Value || Seasons.summerHeatEncumberedAddsHeat.Value) { yield return "$seasons_loadscreen_tip_summer_heat_activity"; } if (Seasons.summerHeatCampFireAddsHeat.Value) { yield return "$seasons_loadscreen_tip_summer_heat_campfire"; } if (Seasons.summerHeatNoonEffectPercent.Value > 0f || Seasons.summerHeatNightFactor.Value < 1f) { yield return "$seasons_loadscreen_tip_summer_heat_day_night"; } } private static void AddSummerHeatCombinedTips(IEnumerable parts) { List list = parts.Where((string part) => !string.IsNullOrWhiteSpace(part)).ToList(); if (list.Count == 0) { return; } string text = "$seasons_loadscreen_tip_summer_heat_prefix"; for (int num = 0; num < list.Count; num += 3) { string item = text + " " + string.Join(" ", list.Skip(num).Take(3)); summerHeatCombinedTips.Add(item); if (!Hud.instance.m_loadingTips.Contains(item)) { Hud.instance.m_loadingTips.Add(item); } } } private static bool HasText(string value) { return !string.IsNullOrWhiteSpace(value); } private static bool HasColdWeatherArmorHeatRules() { return Seasons.summerHeatColdArmorHeating.Value > 0f || Seasons.summerHeatColdArmorCoolingPenalty.Value > 0f || Seasons.summerHeatColdCloakHeating.Value > 0f || Seasons.summerHeatColdCloakCoolingPenalty.Value > 0f; } } public static class ControlledComponentsExtentions { public static string Localize(this string text) { return Localization.instance.Localize(text); } public static bool ShouldBePickedInWinter(this Pickable pickable) { return pickable.CanBePicked() && !pickable.GetPicked() && pickable.IsVulnerableToWinter() && Seasons.seasonState.GetCurrentDay() >= Seasons.cropsDiesAfterSetDayInWinter.Value && !((MonoBehaviour)(object)pickable).IsProtectedPosition() && !((MonoBehaviour)(object)pickable).ProtectedWithHeat(); } public static bool IsVulnerableToWinter(this Pickable pickable) { return Seasons.seasonState.GetPlantsGrowthMultiplier() == 0f && Seasons.seasonState.GetCurrentSeason() == Seasons.Season.Winter && !((MonoBehaviour)(object)pickable).ShouldSurviveWinter() && !pickable.SurvivedCurrentWinter(); } public static bool SurvivedCurrentWinter(this Pickable pickable) { return Object.op_Implicit((Object)(object)pickable.m_nview) && pickable.m_nview.IsValid() && Seasons.seasonState.GetCurrentSeason() == Seasons.Season.Winter && Mathf.Abs(pickable.m_nview.GetZDO().GetInt(SeasonsVars.s_cropSurvivedWinterDayHash, 0) - Seasons.seasonState.GetCurrentWorldDay()) <= Seasons.seasonState.GetDaysInSeason(); } public static bool IsFreezingToDeath(this Pickable pickable) { return Object.op_Implicit((Object)(object)pickable.m_nview) && pickable.m_nview.IsValid() && Seasons.seasonState.GetCurrentSeason() == Seasons.Season.Winter && pickable.GetSecondsToFreeze() > 0.0; } public static double GetSecondsToFreeze(this Pickable pickable) { if (Object.op_Implicit((Object)(object)pickable.m_nview) && pickable.m_nview.IsValid() && Object.op_Implicit((Object)(object)ZNet.instance)) { long num = pickable.m_nview.GetZDO().GetLong(SeasonsVars.s_cropStartedFreezingHash, 0L); if (num <= 0) { return 0.0; } float num2 = Seasons.secondsToFreezeForCropInWinter.Value; if (num2 % 60f == 0f) { num2 -= 2f; } return (new DateTime(num).AddSeconds(num2) - ZNet.instance.GetTime()).TotalSeconds; } return 0.0; } public static bool CheckForPerishInWinter(this Pickable pickable) { if (!pickable.ShouldBePickedInWinter()) { pickable.SetFreezing(freezing: false); return false; } if (Seasons.secondsToFreezeForCropInWinter.Value > 0f) { pickable.SetFreezing(freezing: true); } if (pickable.IsFreezingToDeath()) { return false; } ((MonoBehaviour)pickable).StartCoroutine(Seasons.PickableSetPickedInWinter(pickable)); return true; } public static void SetFreezing(this Pickable pickable, bool freezing) { if (!Object.op_Implicit((Object)(object)pickable.m_nview) || !pickable.m_nview.IsValid() || !Object.op_Implicit((Object)(object)ZNet.instance)) { return; } ZDO zDO = pickable.m_nview.GetZDO(); if (zDO != null) { if (freezing && zDO.GetLong(SeasonsVars.s_cropStartedFreezingHash, 0L) == 0L && Seasons.seasonState.GetCurrentSeason() == Seasons.Season.Winter && Seasons.seasonState.GetCurrentDay() >= Seasons.cropsDiesAfterSetDayInWinter.Value) { zDO.Set(SeasonsVars.s_cropStartedFreezingHash, ZNet.instance.GetTime().Ticks); } else if (!freezing) { zDO.Set(SeasonsVars.s_cropStartedFreezingHash, 0L); } } } public static bool IsIgnored(this Pickable pickable) { return (Object)(object)pickable.m_nview == (Object)null || !pickable.m_nview.IsValid() || (pickable.m_nview.HasOwner() && !pickable.m_nview.IsOwner()) || !((MonoBehaviour)(object)pickable).ControlPlantGrowth() || ((MonoBehaviour)(object)pickable).IsIgnoredPosition(); } public static string GetColdStatus(this Pickable pickable) { if (((MonoBehaviour)(object)pickable).ShouldSurviveWinter()) { return "$seasons_plant_frost_resistant"; } if (((MonoBehaviour)(object)pickable).ProtectedWithHeat()) { return "$seasons_plant_heat_protected"; } if (pickable.SurvivedCurrentWinter()) { return "$seasons_plant_survived_winter"; } double secondsToFreeze = pickable.GetSecondsToFreeze(); if (secondsToFreeze != 0.0 && Seasons.secondsToFreezeForCropInWinter.Value > 0f) { if (secondsToFreeze > 0.0) { return "$seasons_plant_is_freezing\n" + Seasons.FromPercent(secondsToFreeze / (double)Seasons.secondsToFreezeForCropInWinter.Value); } return "$seasons_plant_is_frozen"; } if (Seasons.seasonState.GetCurrentDay() > Seasons.cropsDiesAfterSetDayInWinter.Value) { return "$seasons_plant_will_perish"; } return "$seasons_plant_is_exposed"; } public static bool ControlPlantGrowth(this MonoBehaviour behaviour) { return Seasons.ControlPlantGrowth(((Component)behaviour).gameObject); } public static bool ShouldSurviveWinter(this MonoBehaviour behaviour) { return Seasons.PlantWillSurviveWinter(((Component)behaviour).gameObject); } public static bool IsIgnoredPosition(this MonoBehaviour behaviour) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return Seasons.IsIgnoredPosition(((Component)behaviour).transform.position); } public static bool IsProtectedPosition(this MonoBehaviour behaviour) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return Seasons.IsProtectedPosition(((Component)behaviour).transform.position); } public static bool ProtectedWithHeat(this MonoBehaviour behaviour) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return Seasons.ProtectedWithHeat(((Component)behaviour).transform.position); } } public static class TerrainDecultivation { public static int terrainCompVersion; public static int m_operations; public static Vector3 m_lastOpPoint; public static float m_lastOpRadius; public static bool[] m_modifiedHeight; public static float[] m_levelDelta; public static float[] m_smoothDelta; public static bool[] m_modifiedPaint; public static Color[] m_paintMask; public static bool DecultivateGround(ZDO zdo) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Expected O, but got Unknown //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) byte[] byteArray = zdo.GetByteArray(ZDOVars.s_TCData, (byte[])null); if (byteArray == null) { return false; } ZPackage val = new ZPackage(Utils.Decompress(byteArray)); terrainCompVersion = val.ReadInt(); if (terrainCompVersion != 1) { Seasons.LogWarning("Season can not decultivate ground due to changes in terrain compiler data"); return false; } bool flag = false; m_operations = val.ReadInt(); m_lastOpPoint = val.ReadVector3(); m_lastOpRadius = val.ReadSingle(); m_modifiedHeight = new bool[val.ReadInt()]; m_levelDelta = new float[m_modifiedHeight.Length]; m_smoothDelta = new float[m_modifiedHeight.Length]; for (int i = 0; i < m_modifiedHeight.Length; i++) { m_modifiedHeight[i] = val.ReadBool(); if (m_modifiedHeight[i]) { m_levelDelta[i] = val.ReadSingle(); m_smoothDelta[i] = val.ReadSingle(); } else { m_levelDelta[i] = 0f; m_smoothDelta[i] = 0f; } } m_modifiedPaint = new bool[val.ReadInt()]; m_paintMask = (Color[])(object)new Color[m_modifiedPaint.Length]; for (int j = 0; j < m_modifiedPaint.Length; j++) { m_modifiedPaint[j] = val.ReadBool(); if (m_modifiedPaint[j]) { Color val2 = new Color { r = val.ReadSingle(), g = val.ReadSingle(), b = val.ReadSingle(), a = val.ReadSingle() }; if (val2.g > 0f) { val2.r = Mathf.Max(val2.r, val2.g); val2.g = 0f; flag = true; } m_paintMask[j] = val2; } else { m_paintMask[j] = Color.black; } } if (!flag) { return false; } ZPackage val3 = new ZPackage(); val3.Write(terrainCompVersion); val3.Write(m_operations); val3.Write(m_lastOpPoint); val3.Write(m_lastOpRadius); val3.Write(m_modifiedHeight.Length); for (int k = 0; k < m_modifiedHeight.Length; k++) { val3.Write(m_modifiedHeight[k]); if (m_modifiedHeight[k]) { val3.Write(m_levelDelta[k]); val3.Write(m_smoothDelta[k]); } } val3.Write(m_modifiedPaint.Length); for (int l = 0; l < m_modifiedPaint.Length; l++) { val3.Write(m_modifiedPaint[l]); if (m_modifiedPaint[l]) { val3.Write(m_paintMask[l].r); val3.Write(m_paintMask[l].g); val3.Write(m_paintMask[l].b); val3.Write(m_paintMask[l].a); } } byte[] array = Utils.Compress(val3.GetArray()); zdo.Set(ZDOVars.s_TCData, array); return true; } } [Serializable] public class CachedData { [Serializable] public class TextureData { public string name; public byte[] originalPNG; public TextureProperties properties; public Dictionary> variants = new Dictionary>(); public bool Initialized() { return variants.Any((KeyValuePair> variant) => variant.Value.Count > 0); } public TextureData(TextureVariants textureVariants) { if (textureVariants == null) { return; } originalPNG = textureVariants.originalPNG; name = textureVariants.originalName; properties = textureVariants.properties; foreach (KeyValuePair> season in textureVariants.seasons) { variants.Add(season.Key, new Dictionary()); foreach (KeyValuePair item in season.Value) { variants[season.Key].Add(item.Key, ImageConversion.EncodeToPNG(item.Value)); } } } public TextureData(DirectoryInfo texDirectory) { FileInfo[] files = texDirectory.GetFiles("properties.json"); if (files.Length != 0) { properties = JsonUtility.FromJson(File.ReadAllText(files[0].FullName)); } foreach (Seasons.Season value in Enum.GetValues(typeof(Seasons.Season))) { variants.Add(value, new Dictionary()); for (int i = 0; i < 4; i++) { FileInfo[] files2 = texDirectory.GetFiles(SeasonFileName(value, i)); if (files2.Length != 0) { variants[value].Add(i, File.ReadAllBytes(files2[0].FullName)); } } } } } internal const string cacheSubdirectory = "Cache"; internal const string prefabCacheCommonFile = "cache.bin"; internal const string prefabCacheFileName = "cache.json"; internal const string texturesDirectory = "textures"; internal const string originalPostfix = ".orig.png"; internal const string texturePropertiesFileName = "properties.json"; public Dictionary controllers = new Dictionary(); public Dictionary textures = new Dictionary(); public uint revision = 0u; public CachedData(uint revision) { this.revision = revision; } public bool Initialized() { return controllers.Count > 0 && textures.Count > 0; } public void SaveOnDisk() { if (Initialized()) { if (Seasons.cacheStorageFormat.Value == Seasons.CacheFormat.Binary) { SaveToBinary(); return; } if (Seasons.cacheStorageFormat.Value == Seasons.CacheFormat.Json) { SaveToJSON(); return; } SaveToJSON(); SaveToBinary(); } } public void LoadFromDisk() { if (Seasons.cacheStorageFormat.Value == Seasons.CacheFormat.Json) { LoadFromJSON(); } else { LoadFromBinary(); } } private void SaveToJSON() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown string text = CacheDirectory(); Directory.CreateDirectory(text); string text2 = Path.Combine(text, "cache.json"); File.WriteAllText(text2, JsonConvert.SerializeObject((object)controllers, (Formatting)1, new JsonSerializerSettings { NullValueHandling = (NullValueHandling)1, DefaultValueHandling = (DefaultValueHandling)1 })); string text3 = Path.Combine(text, "textures"); Seasons.LogInfo("Saved cache file " + text2); foreach (KeyValuePair texture in textures) { string text4 = Path.Combine(text3, texture.Key.ToString()); Directory.CreateDirectory(text4); File.WriteAllBytes(Path.Combine(text4, texture.Value.name + ".orig.png"), texture.Value.originalPNG); File.WriteAllText(Path.Combine(text4, "properties.json"), JsonUtility.ToJson((object)texture.Value.properties, true)); foreach (KeyValuePair> variant in texture.Value.variants) { foreach (KeyValuePair item in variant.Value) { File.WriteAllBytes(Path.Combine(text4, SeasonFileName(variant.Key, item.Key)), item.Value); } } } Seasons.LogInfo($"Saved {textures.Count} textures at {text3}"); } private void LoadFromJSON() { string text = CacheDirectory(); DirectoryInfo directoryInfo = new DirectoryInfo(text); if (!directoryInfo.Exists) { return; } FileInfo[] files = directoryInfo.GetFiles("cache.json"); if (files.Length == 0) { Seasons.LogInfo("File not found: " + Path.Combine(text, "cache.json")); return; } try { controllers = JsonConvert.DeserializeObject>(File.ReadAllText(files[0].FullName)); } catch (Exception arg) { Seasons.LogWarning($"Error loading JSON cache data from {files[0].FullName}\n{arg}"); return; } DirectoryInfo[] directories = directoryInfo.GetDirectories("textures"); if (directories.Length == 0) { return; } DirectoryInfo[] directories2 = directories[0].GetDirectories(); foreach (DirectoryInfo directoryInfo2 in directories2) { int key = int.Parse(directoryInfo2.Name); if (!textures.ContainsKey(key)) { TextureData textureData = new TextureData(directoryInfo2); if (textureData.Initialized()) { textures.Add(key, textureData); } } } } private void SaveToBinary() { string text = CacheDirectory(); Directory.CreateDirectory(text); using (FileStream fileStream = new FileStream(Path.Combine(text, "cache.bin"), FileMode.Create)) { BinaryFormatter binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(fileStream, this); fileStream.Dispose(); } Seasons.LogInfo("Saved cache file " + Path.Combine(text, "cache.bin")); } private void LoadFromBinary() { string path = CacheDirectory(); string text = Path.Combine(path, "cache.bin"); if (!File.Exists(text)) { Seasons.LogInfo("File not found: " + text); return; } try { using FileStream fileStream = new FileStream(text, FileMode.Open, FileAccess.Read, FileShare.Read); BinaryFormatter binaryFormatter = new BinaryFormatter(); CachedData cachedData = (CachedData)binaryFormatter.Deserialize(fileStream); fileStream.Dispose(); DictionaryExt.Copy(controllers, cachedData.controllers); DictionaryExt.Copy(textures, cachedData.textures); cachedData = null; } catch (Exception arg) { Seasons.LogWarning($"Error loading binary cache data from {text}:\n {arg}"); } } public string CacheDirectory() { return Path.Combine(Seasons.cacheDirectory, revision.ToString()); } public static string SeasonFileName(Seasons.Season season, int variant) { return $"{season}_{variant + 1}.png"; } } [Serializable] public class PrefabController { [Serializable] public class CachedMaterial { public string name = string.Empty; public string shaderName = string.Empty; public Dictionary textureProperties = new Dictionary(); public Dictionary colorVariants = new Dictionary(); public CachedMaterial() { } public CachedMaterial(string materialName, string shader, string propertyName, int textureID) { name = materialName; shaderName = shader; AddTexture(propertyName, textureID); } public CachedMaterial(string materialName, string shader, string propertyName, Color[] colors) { name = materialName; shaderName = shader; AddColors(propertyName, colors); } public void AddTexture(string propertyName, int textureID) { if (!textureProperties.ContainsKey(propertyName)) { textureProperties.Add(propertyName, textureID); } } public void AddColors(string propertyName, Color[] colors) { List vec = new List(); CollectionExtensions.Do((IEnumerable)colors, (Action)delegate(Color x) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) vec.Add("#" + ColorUtility.ToHtmlStringRGBA(x)); }); if (!colorVariants.ContainsKey(propertyName)) { colorVariants.Add(propertyName, vec.ToArray()); } } } [Serializable] public class CachedRenderer { public string name = string.Empty; public string type = string.Empty; public Dictionary materials = new Dictionary(); public CachedRenderer() { } public CachedRenderer(string rendererName, string rendererType) { name = rendererName; type = rendererType; } public bool Initialized() { return materials.Any((KeyValuePair m) => m.Value.textureProperties.Count > 0 || m.Value.colorVariants.Count > 0); } public void AddMaterialTexture(Material material, string propertyName, int textureID) { if (!materials.TryGetValue(((Object)material).name, out var value)) { materials.Add(((Object)material).name, new CachedMaterial(((Object)material).name, ((Object)material.shader).name, propertyName, textureID)); } else { value.AddTexture(propertyName, textureID); } } public void AddMaterialColors(Material material, string propertyName, Color[] colors) { if (!materials.TryGetValue(((Object)material).name, out var value)) { materials.Add(((Object)material).name, new CachedMaterial(((Object)material).name, ((Object)material.shader).name, propertyName, colors)); } else { value.AddColors(propertyName, colors); } } } public Dictionary>> lodsInHierarchy = new Dictionary>>(); public Dictionary> lodLevelMaterials = new Dictionary>(); public Dictionary renderersInHierarchy = new Dictionary(); public CachedRenderer cachedRenderer; public Dictionary particleSystemStartColors; [NonSerialized] public long elapsedTicks = 0L; public bool Initialized() { return lodsInHierarchy.Count > 0 || lodLevelMaterials.Count > 0 || renderersInHierarchy.Count > 0 || cachedRenderer != null || particleSystemStartColors != null; } public override string ToString() { return ((cachedRenderer == null) ? "" : " 1 main renderer") + ((particleSystemStartColors == null) ? "" : " 1 particles start color") + " " + ((lodsInHierarchy.Count > 0) ? $" {lodsInHierarchy.Count} LOD groups" : "") + ((lodLevelMaterials.Count > 0) ? $" {lodLevelMaterials.Count} LODs" : "") + ((renderersInHierarchy.Count > 0) ? $" {renderersInHierarchy.Count} renderersInHierarchy" : "") + ((elapsedTicks > 0) ? $" in {(double)elapsedTicks / (double)Stopwatch.Frequency * 1000.0:F2} ms" : ""); } } public class SeasonalTextureVariants { public Dictionary controllers = new Dictionary(); public Dictionary textures = new Dictionary(); public uint revision = 0u; public bool Initialize(bool force = false) { if (!force && Initialized()) { return true; } controllers.Clear(); textures.Clear(); revision = SeasonalTexturePrefabCache.GetRevision(); CachedData cachedData = new CachedData(revision); if (force && Directory.Exists(cachedData.CacheDirectory())) { Directory.Delete(cachedData.CacheDirectory(), recursive: true); } cachedData.LoadFromDisk(); if (cachedData.Initialized()) { DictionaryExt.Copy(controllers, cachedData.controllers); foreach (KeyValuePair texture in cachedData.textures) { if (!textures.ContainsKey(texture.Key)) { TextureVariants textureVariants = new TextureVariants(texture.Value); if (textureVariants.Initialized()) { textures.Add(texture.Key, textureVariants); } } } Seasons.LogInfo($"Loaded from cache revision:{revision} controllers:{controllers.Count} textures:{textures.Count}"); } else if (!Seasons.runTextureCachingSync.Value) { TextureCachingController.StartCaching(this); } else { SeasonalTexturePrefabCache.SetCurrentTextureVariants(this); Seasons.StartCoroutineSync(SeasonalTexturePrefabCache.FillWithGameData()); Seasons.StartCoroutineSync(SaveCacheOnDisk()); } return Initialized(); } public IEnumerator SaveCacheOnDisk() { if (!Initialized()) { yield break; } CachedData cachedData = new CachedData(revision); cachedData.textures.Clear(); foreach (KeyValuePair texVariants in textures) { CachedData.TextureData texData = new CachedData.TextureData(texVariants.Value); if (texData.Initialized()) { cachedData.textures.Add(texVariants.Key, texData); } } Thread internalThread = new Thread((ThreadStart)delegate { DictionaryExt.Copy(cachedData.controllers, controllers); if (Directory.Exists(cachedData.CacheDirectory())) { Directory.Delete(cachedData.CacheDirectory(), recursive: true); } cachedData.SaveOnDisk(); }); internalThread.Start(); while (internalThread.IsAlive) { yield return Seasons.waitForFixedUpdate; } ApplyTexturesToGPU(); } public bool Initialized() { return controllers.Count > 0 && textures.Count > 0; } public void ApplyTexturesToGPU() { foreach (KeyValuePair texture in textures) { texture.Value.ApplyTextures(); } } public IEnumerator ReloadCache() { Stopwatch stopwatch = Stopwatch.StartNew(); CachedData cachedData = new CachedData(SeasonalTexturePrefabCache.GetRevision()); Thread internalThread = new Thread((ThreadStart)delegate { cachedData.LoadFromDisk(); }); internalThread.Start(); while (internalThread.IsAlive) { yield return Seasons.waitForFixedUpdate; } if (cachedData.Initialized()) { revision = cachedData.revision; foreach (KeyValuePair texData in cachedData.textures) { if (!textures.ContainsKey(texData.Key)) { TextureVariants texVariants = new TextureVariants(texData.Value); if (texVariants.Initialized()) { textures.Add(texData.Key, texVariants); } } } internalThread = new Thread((ThreadStart)delegate { DictionaryExt.Copy(controllers, cachedData.controllers); }); internalThread.Start(); while (internalThread.IsAlive) { yield return Seasons.waitForFixedUpdate; } Seasons.LogInfo($"Loaded from cache revision:{revision} controllers:{controllers.Count} textures:{textures.Count} in {stopwatch.Elapsed.TotalSeconds,-4:F2} seconds"); stopwatch.Restart(); ClutterVariantController.Reinitialize(); PrefabVariantController.ReinitializePrefabVariants(); yield return Seasons.waitForFixedUpdate; PrefabVariantController.UpdatePrefabColors(); ClutterVariantController.Instance.UpdateColors(); Seasons.LogInfo($"Colors reinitialized in {stopwatch.Elapsed.TotalSeconds,-4:F2} seconds"); } else { yield return RebuildCache(); } } public IEnumerator RebuildCache() { SeasonalTextureVariants newTexturesVariants = new SeasonalTextureVariants(); SeasonalTexturePrefabCache.SetCurrentTextureVariants(newTexturesVariants); PrefabVariantController.instance?.RevertPrefabsState(); ClutterVariantController.Instance?.RevertColors(); yield return Seasons.waitForFixedUpdate; yield return SeasonalTexturePrefabCache.FillWithGameData(); if (newTexturesVariants.Initialized()) { Stopwatch stopwatch = Stopwatch.StartNew(); controllers.Clear(); textures.Clear(); revision = newTexturesVariants.revision; Thread internalThread = new Thread((ThreadStart)delegate { DictionaryExt.Copy(controllers, newTexturesVariants.controllers); DictionaryExt.Copy(textures, newTexturesVariants.textures); }); internalThread.Start(); while (internalThread.IsAlive) { yield return Seasons.waitForFixedUpdate; } yield return SaveCacheOnDisk(); SeasonalTexturePrefabCache.SetCurrentTextureVariants(this); ClutterVariantController.Reinitialize(); PrefabVariantController.ReinitializePrefabVariants(); yield return Seasons.waitForFixedUpdate; Seasons.LogInfo($"Colors reinitialized in {stopwatch.Elapsed.TotalSeconds,-4:F2} seconds"); } yield return Seasons.waitForFixedUpdate; SeasonalTexturePrefabCache.SetCurrentTextureVariants(this); PrefabVariantController.UpdatePrefabColors(); ClutterVariantController.Instance?.UpdateColors(); Seasons.LogInfo("Cache rebuild ended"); } } public class TextureVariants { public Texture2D original; public string originalName; public byte[] originalPNG; public TextureProperties properties; public Dictionary> seasons = new Dictionary>(); public TextureVariants(CachedData.TextureData texData) { if (texData == null) { return; } properties = texData.properties; foreach (Seasons.Season value3 in Enum.GetValues(typeof(Seasons.Season))) { if (!texData.variants.TryGetValue(value3, out var value)) { continue; } for (int i = 0; i < 4; i++) { if (value.TryGetValue(i, out var value2)) { Texture2D val = properties.CreateTexture(); if (ImageConversion.LoadImage(val, value2, true)) { AddVariant(value3, i, val); } else { Object.Destroy((Object)(object)val); } } } } } public TextureVariants(Texture texture) { SetOriginalTexture(texture); } public void SetOriginalTexture(Texture texture) { original = (Texture2D)(object)((texture is Texture2D) ? texture : null); properties = new TextureProperties((Texture2D)(object)((texture is Texture2D) ? texture : null)); originalName = ((Object)original).name; } public bool Initialized() { return seasons.Any((KeyValuePair> season) => season.Value.Count > 0); } public bool HaveOriginalTexture() { return Object.op_Implicit((Object)(object)original); } public void ApplyTextures() { foreach (KeyValuePair> season in seasons) { foreach (KeyValuePair item in season.Value) { item.Value.Apply(true, true); } } } public void AddVariant(Seasons.Season season, int variant, Texture2D tex) { if (!seasons.TryGetValue(season, out var value)) { value = new Dictionary(); seasons.Add(season, value); } if (!value.ContainsKey(variant)) { value.Add(variant, tex); } } public Texture2D GetSeasonalVariant(Seasons.Season season, int variant) { if (CustomTextures.HaveCustomTexture(originalName, season, variant, properties, out var texture)) { return texture; } if (seasons.TryGetValue(season, out var value) && value.TryGetValue(variant, out var value2)) { return value2; } return original; } } [Serializable] public class TextureProperties { public TextureFormat format = (TextureFormat)5; public int mipmapCount = 1; public TextureWrapMode wrapMode = (TextureWrapMode)0; public FilterMode filterMode = (FilterMode)0; public int anisoLevel = 1; public float mipMapBias = 0f; public int width = 2; public int height = 2; public TextureProperties(Texture2D tex) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) mipmapCount = ((Texture)tex).mipmapCount; wrapMode = ((Texture)tex).wrapMode; filterMode = ((Texture)tex).filterMode; anisoLevel = ((Texture)tex).anisoLevel; mipMapBias = ((Texture)tex).mipMapBias; width = ((Texture)tex).width; height = ((Texture)tex).height; } public Texture2D CreateTexture() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown return new Texture2D(width, height, format, mipmapCount, false) { filterMode = filterMode, anisoLevel = anisoLevel, mipMapBias = mipMapBias, wrapMode = wrapMode }; } } public class SE_SummerHeat : SE_Stats { private const char DefaultBarSymbol = '▄'; private const float PartialSegmentEpsilon = 0.0001f; private static readonly StringBuilder TooltipBuilder = new StringBuilder(256); private float _damageTimer; public override void Setup(Character character) { StatusEffectHud.EnsureTimeTextRichText(); ((StatusEffect)this).m_name = "$seasons_status_summer_heat_name"; ((StatusEffect)this).m_tooltip = "$seasons_status_summer_heat_description"; if (((StatusEffect)this).m_icon == null) { ((StatusEffect)this).m_icon = Seasons.iconWarm ?? Seasons.iconSummer; } ((StatusEffect)this).m_ttl = 0f; ((StatusEffect)this).m_cooldownIcon = false; ((StatusEffect)this).m_flashIcon = false; ((SE_Stats)this).Setup(character); } public override void UpdateStatusEffect(float dt) { //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: 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_014b: Unknown result type (might be due to invalid IL or missing references) ((SE_Stats)this).UpdateStatusEffect(dt); if (SummerHeat.IsReady && SummerHeat.IsMechanicActive) { Character character = ((StatusEffect)this).m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null) { float maxEffectFactor = SummerHeat.MaxEffectFactor; if (maxEffectFactor <= 0f) { _damageTimer = 0f; return; } _damageTimer += dt; if (_damageTimer < Mathf.Max(0.1f, Seasons.summerHeatDamageTickInterval.Value)) { return; } _damageTimer = 0f; float minSoftHpCap = SummerHeatUtils.GetMinSoftHpCap(); float num = Mathf.Lerp(1f, minSoftHpCap, maxEffectFactor); if (!(((Character)val).GetHealthPercentage() <= num) && (!Seasons.summerHeatDamageMaxOnly.Value || SummerHeat.CurrentZone == HeatZone.Max)) { float num2 = Mathf.Abs(Seasons.summerHeatDamageHealthPerTick.Value); if (!(num2 <= 0f)) { HitData val2 = new HitData(); val2.m_damage.m_damage = num2; val2.m_hitType = Seasons.summerHeatDamageHitType.Value; val2.m_point = ((Character)val).GetTopPoint(); ((Character)val).Damage(val2); } } return; } } _damageTimer = 0f; } public override string GetIconText() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (!SummerHeat.IsReady || !SummerHeat.IsMechanicActive) { return string.Empty; } Seasons.SummerHeatDisplayMode value = Seasons.summerHeatDisplayMode.Value; if (1 == 0) { } string result = value switch { Seasons.SummerHeatDisplayMode.None => string.Empty, Seasons.SummerHeatDisplayMode.Bar => BuildBarText(), Seasons.SummerHeatDisplayMode.Percent => ColorizeText($"{SummerHeat.HeatPercent:0}%", GetHeatDisplayColor()), _ => BuildBarText(), }; if (1 == 0) { } return result; } public override string GetTooltipString() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) TooltipBuilder.Clear(); TooltipBuilder.Append("$seasons_status_summer_heat_description".Localize()).Append('\n').Append('\n'); TooltipBuilder.AppendFormat("{0}: {1}\n", "$seasons_status_summer_heat_current".Localize(), ColorizeText($"{SummerHeat.HeatPercent:0}%", GetHeatDisplayColor())); TooltipBuilder.AppendFormat("{0}: {1}\n", "$seasons_status_summer_heat_zone".Localize(), GetZoneText(SummerHeat.CurrentZone).Localize()); TooltipBuilder.AppendFormat("{0}: {1}\n", "$seasons_status_summer_heat_weather".Localize(), (SummerHeat.IsSunny ? "$seasons_status_summer_heat_sunny" : "$seasons_status_summer_heat_not_sunny").Localize()); TooltipBuilder.AppendFormat("{0}: {1}\n", "$seasons_status_summer_heat_exposure".Localize(), GetExposureText().Localize()); string modifierSummary = GetModifierSummary(); if (!string.IsNullOrEmpty(modifierSummary)) { TooltipBuilder.Append(modifierSummary); } AppendActiveFactors(TooltipBuilder); if (SummerHeat.MaxEffectFactor > 0f) { float minSoftHpCap = SummerHeatUtils.GetMinSoftHpCap(); float num = Mathf.Lerp(1f, minSoftHpCap, SummerHeat.MaxEffectFactor) * 100f; TooltipBuilder.AppendFormat("{0}\n", string.Format("$seasons_status_summer_heat_cap_warning".Localize(), num.ToString("0"))); } AppendTechnicalInfo(TooltipBuilder); return TooltipBuilder.ToString(); } public override void ModifyHealthRegen(ref float regenMultiplier) { if (SummerHeat.IsMechanicActive) { ApplyMultiplier(ref regenMultiplier, GetHeatMultiplier(Seasons.summerHeatHealthRegenMultiplier.Value), regenStyle: true); } } public override void ModifyStaminaRegen(ref float staminaRegen) { if (SummerHeat.IsMechanicActive) { ApplyMultiplier(ref staminaRegen, GetHeatMultiplier(Seasons.summerHeatStaminaRegenMultiplier.Value), regenStyle: true); } } public override void ModifyEitrRegen(ref float eitrRegen) { if (SummerHeat.IsMechanicActive) { ApplyMultiplier(ref eitrRegen, GetHeatMultiplier(Seasons.summerHeatEitrRegenMultiplier.Value), regenStyle: true); } } public override void ModifyRunStaminaDrain(float baseDrain, ref float drain, Vector3 dir) { if (SummerHeat.IsMechanicActive) { drain += baseDrain * GetSignedModifier(Seasons.summerHeatStaminaUseMultiplier.Value); } } public override void ModifyAdrenaline(float baseValue, ref float use) { if (SummerHeat.IsMechanicActive) { use += baseValue * GetSignedModifier(Seasons.summerHeatAdrenalineMultiplier.Value); } } private static void ApplyMultiplier(ref float value, float multiplier, bool regenStyle) { if (!Mathf.Approximately(multiplier, 1f)) { if (regenStyle && multiplier > 1f) { value += multiplier - 1f; } else { value *= multiplier; } } } private string BuildBarText() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Clamp(Seasons.summerHeatBarSegments.Value, 1, 32); char barSymbol = GetBarSymbol(); GetBarBrightness(out var emptyAlpha, out var fullAlpha); float num2 = Mathf.Clamp01(SummerHeat.HeatFactor) * (float)num; int num3 = Mathf.Clamp(Mathf.FloorToInt(num2), 0, num); float num4 = num2 - (float)num3; bool flag = num4 > 0.0001f && num3 < num; int num5 = Mathf.Max(0, num - num3 - (flag ? 1 : 0)); float alpha = Mathf.Lerp(emptyAlpha, fullAlpha, Mathf.Clamp01(num4)); Color heatDisplayColor = GetHeatDisplayColor(); string value = ((num3 > 0) ? new string(barSymbol, num3) : string.Empty); string value2 = (flag ? barSymbol.ToString() : string.Empty); string value3 = ((num5 > 0) ? new string(barSymbol, num5) : string.Empty); return WrapBarText(ColorizeText(value, heatDisplayColor, fullAlpha) + ColorizeText(value2, heatDisplayColor, alpha) + ColorizeText(value3, heatDisplayColor, emptyAlpha)); } private static string WrapBarText(string barText) { Seasons.SummerHeatBarTagMode value = Seasons.summerHeatBarTagMode.Value; if (1 == 0) { } string result = value switch { Seasons.SummerHeatBarTagMode.None => barText, Seasons.SummerHeatBarTagMode.Sub => "" + barText + "", _ => "" + barText + "", }; if (1 == 0) { } return result; } private static char GetBarSymbol() { string value = Seasons.summerHeatBarSymbol.Value; if (string.IsNullOrWhiteSpace(value)) { return '▄'; } value = value.Trim(); return (value.Length > 0) ? value[0] : '▄'; } private static void GetBarBrightness(out float emptyAlpha, out float fullAlpha) { float num = Mathf.Clamp01(Seasons.summerHeatBarMinBrightness.Value); float num2 = Mathf.Clamp01(Seasons.summerHeatBarMaxBrightness.Value); emptyAlpha = Mathf.Min(num, num2); fullAlpha = Mathf.Max(num, num2); } private static Color GetHeatDisplayColor() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) Color value = Seasons.summerHeatBarBonusColor.Value; Color value2 = Seasons.summerHeatBarNeutralColor.Value; Color value3 = Seasons.summerHeatBarPenaltyColor.Value; Color value4 = Seasons.summerHeatBarMaxColor.Value; if (SummerHeat.MaxEffectFactor > 0f) { return Color.Lerp(value3, value4, SummerHeat.MaxEffectFactor); } if (SummerHeat.RedFactor > 0f) { return Color.Lerp(value2, value3, SummerHeat.RedFactor); } if (SummerHeat.GreenFactor > 0f) { return Color.Lerp(value2, value, SummerHeat.GreenFactor); } return value2; } private static string ColorizeText(string value, Color color, float alpha = 1f) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(value)) { return string.Empty; } return "" + value + ""; } private static string ColorHex(Color color, float alpha) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Clamp(Mathf.RoundToInt(Mathf.Clamp01(color.r) * 255f), 0, 255); int num2 = Mathf.Clamp(Mathf.RoundToInt(Mathf.Clamp01(color.g) * 255f), 0, 255); int num3 = Mathf.Clamp(Mathf.RoundToInt(Mathf.Clamp01(color.b) * 255f), 0, 255); int num4 = Mathf.Clamp(Mathf.RoundToInt(Mathf.Clamp01(alpha) * Mathf.Clamp01(color.a) * 255f), 0, 255); return $"{num:x2}{num2:x2}{num3:x2}{num4:x2}"; } private static float GetHeatMultiplier(float configuredEffect) { configuredEffect = Mathf.Clamp01(configuredEffect); if (Mathf.Approximately(configuredEffect, 0f)) { return 1f; } float num = Mathf.Lerp(1f, 1f + configuredEffect, SummerHeat.GreenFactor); float num2 = Mathf.Max(SummerHeat.RedFactor, SummerHeat.MaxEffectFactor); float num3 = Mathf.Lerp(1f, 1f - configuredEffect, num2); return (num2 > 0f) ? num3 : num; } private static float GetSignedModifier(float configuredValue) { configuredValue = Mathf.Clamp01(configuredValue); float num = Mathf.Max(SummerHeat.RedFactor, SummerHeat.MaxEffectFactor); if (num > 0f) { return configuredValue * num; } return 0f - configuredValue * SummerHeat.GreenFactor; } private static void AppendTechnicalInfo(StringBuilder builder) { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) if (Seasons.summerHeatRavenTechnicalInfo.Value && TextsDialog_AddActiveEffects_SeasonTooltipWhenBuffDisabled.isActiveEffectsListCall && SummerHeat.IsReady) { bool flag = (Object)(object)SummerHeat.Instance == (Object)null || SummerHeat.Instance.IsDaytime(); float nightFactor = SummerHeatUtils.GetNightFactor(); GetThresholds(flag, nightFactor, out var greenThreshold, out var neutralThreshold, out var maxThreshold); float num = Mathf.Max(0.1f, SummerHeatUtils.ScaleHeatPercentForTime(SummerHeatUtils.ClampPercent(Seasons.summerHeatGreenFadeWidth.Value), flag, nightFactor)); float num2 = Mathf.Max(0.1f, SummerHeatUtils.ScaleHeatPercentForTime(SummerHeatUtils.ClampPercent(Seasons.summerHeatRedRampWidth.Value), flag, nightFactor)); float value = Mathf.Max(0f, greenThreshold - num); float value2 = greenThreshold + num; float value3 = Mathf.Min(maxThreshold, neutralThreshold + num2); float value4 = (flag ? 100f : (100f * nightFactor)); float value5 = SummerHeatUtils.ClampPercent(Seasons.summerHeatMaxOverflow.Value); Color heatDisplayColor = GetHeatDisplayColor(); Color value6 = Seasons.summerHeatBarBonusColor.Value; Color value7 = Seasons.summerHeatBarPenaltyColor.Value; Color value8 = Seasons.summerHeatBarMaxColor.Value; builder.Append('\n'); builder.AppendFormat("{0}\n", "$seasons_status_summer_heat_technical".Localize()); builder.AppendFormat("{0}: {1} / {2}\n", "$seasons_status_summer_heat_technical_heat_values".Localize(), FormatPercent(SummerHeat.HeatPercent, heatDisplayColor), FormatPercent(SummerHeat.OverflowHeatPercent, value8)); builder.AppendFormat("{0}: {1} / {2} / {3}\n", "$seasons_status_summer_heat_technical_factors".Localize(), FormatFactorPercent(SummerHeat.GreenFactor, value6), FormatFactorPercent(SummerHeat.RedFactor, value7), FormatBoolColored(SummerHeat.MaxEffectFactor > 0f, value8)); builder.AppendFormat("{0}: {1}\n", "$seasons_status_summer_heat_technical_direction".Localize(), GetTrendText().Localize()); builder.AppendFormat("{0}: {1} / {2} / {3} / {4}\n", "$seasons_status_summer_heat_technical_conditions".Localize(), FormatBool(flag), FormatBool(SummerHeat.IsSunny), FormatBool(SummerHeat.IsInShade), FormatBool(SummerHeatVisuals.IsWorldHazeActive())); AppendArmorTechnicalInfo(builder); builder.AppendFormat("{0}: {1}\n", "$seasons_status_summer_heat_technical_heat_scale".Localize(), BuildTechnicalHeatScale(flag)); builder.AppendFormat("{0}: {1} / {2} / {3}\n", "$seasons_status_summer_heat_technical_comfort_range".Localize(), FormatPercent(value, value6), FormatPercent(greenThreshold, value6), FormatPercent(value2, value6)); builder.AppendFormat("{0}: {1} / {2}\n", "$seasons_status_summer_heat_technical_penalty_ramp".Localize(), FormatPercent(neutralThreshold, value7), FormatPercent(value3, value7)); builder.AppendFormat("{0}: {1} / {2} / {3}\n", "$seasons_status_summer_heat_technical_overheated".Localize(), FormatPercent(maxThreshold, value8), FormatPercent(value4, value8), FormatPercent(value5, value8)); } } private static void GetThresholds(bool isDaytime, float nightFactor, out float greenThreshold, out float neutralThreshold, out float maxThreshold) { float num = SummerHeatUtils.ClampPercent(Seasons.summerHeatGreenThreshold.Value); float num2 = SummerHeatUtils.ClampPercent(Mathf.Max(num + 1f, Seasons.summerHeatNeutralThreshold.Value)); float value = SummerHeatUtils.ClampPercent(Mathf.Max(num2 + 1f, Seasons.summerHeatMaxThreshold.Value)); greenThreshold = SummerHeatUtils.ScaleHeatPercentForTime(num, isDaytime, nightFactor); neutralThreshold = SummerHeatUtils.ScaleHeatPercentForTime(num2, isDaytime, nightFactor); maxThreshold = SummerHeatUtils.ScaleHeatPercentForTime(value, isDaytime, nightFactor); } private static string FormatPercent(float value, Color color) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) return ColorizeText($"{value:0.#}%", color); } private static string FormatFactorPercent(float value, Color color) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) return ColorizeText($"{Mathf.Clamp01(value) * 100f:0}%", color); } private static string FormatBool(bool value) { return (value ? "$seasons_status_summer_heat_yes" : "$seasons_status_summer_heat_no").Localize(); } private static string FormatBoolColored(bool value, Color yesColor) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) string text = FormatBool(value); return value ? ColorizeText(text, yesColor) : text; } private static void AppendArmorTechnicalInfo(StringBuilder builder) { if (Seasons.summerHeatArmorHeatEnabled.Value && !((Object)(object)SummerHeat.Instance == (Object)null)) { SummerHeatArmorState armorState = SummerHeat.Instance.ArmorState; builder.AppendFormat("{0}: {1} / {2}\n", "$seasons_status_summer_heat_technical_armor".Localize(), FormatArmorModifier(armorState.HeatingModifier, positiveIsGood: false), FormatArmorModifier(armorState.CoolingModifier, positiveIsGood: true)); builder.AppendFormat("{0}: {1} / {2} / {3} / {4}\n", "$seasons_status_summer_heat_technical_armor_slots".Localize(), LocalizeState(armorState.HeadState), LocalizeState(armorState.CloakState), LocalizeState(armorState.ChestState), LocalizeState(armorState.LegsState)); } } private static string FormatArmorModifier(float value, bool positiveIsGood) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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) Color value2 = Seasons.summerHeatBarBonusColor.Value; Color value3 = Seasons.summerHeatBarNeutralColor.Value; Color value4 = Seasons.summerHeatBarPenaltyColor.Value; Color color = (Mathf.Approximately(value, 0f) ? value3 : ((value > 0f == positiveIsGood) ? value2 : value4)); return ColorizeText($"{value * 100f:+0;-0;0}%", color); } private static string LocalizeState(string token) { return string.IsNullOrEmpty(token) ? string.Empty : token.Localize(); } private static string BuildTechnicalHeatScale(bool isDaytime) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(2400); for (int i = 0; i < 100; i++) { float heatPercent = (float)i * 100f / 99f; stringBuilder.Append(ColorizeText('|'.ToString(), GetHeatDisplayColorForValue(heatPercent, isDaytime))); } return $"{stringBuilder}"; } private static Color GetHeatDisplayColorForValue(float heatPercent, bool isDaytime) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) float nightFactor = SummerHeatUtils.GetNightFactor(); GetThresholds(isDaytime, nightFactor, out var greenThreshold, out var neutralThreshold, out var maxThreshold); float num = Mathf.Max(0.1f, SummerHeatUtils.ScaleHeatPercentForTime(SummerHeatUtils.ClampPercent(Seasons.summerHeatGreenFadeWidth.Value), isDaytime, nightFactor)); float num2 = Mathf.Max(0.1f, SummerHeatUtils.ScaleHeatPercentForTime(SummerHeatUtils.ClampPercent(Seasons.summerHeatRedRampWidth.Value), isDaytime, nightFactor)); Color value = Seasons.summerHeatBarBonusColor.Value; Color value2 = Seasons.summerHeatBarNeutralColor.Value; Color value3 = Seasons.summerHeatBarPenaltyColor.Value; Color value4 = Seasons.summerHeatBarMaxColor.Value; if (!isDaytime && nightFactor <= 0f) { return value2; } if (heatPercent >= maxThreshold) { return value4; } if (heatPercent > neutralThreshold) { float num3 = Mathf.Min(maxThreshold, neutralThreshold + num2); float num4 = ((heatPercent < num3) ? Mathf.InverseLerp(neutralThreshold, num3, heatPercent) : 1f); return Color.Lerp(value2, value3, num4); } float num5 = Mathf.Max(0f, greenThreshold - num); float num6 = greenThreshold + num; if (heatPercent >= num5 && heatPercent <= num6) { float num7 = ((heatPercent <= greenThreshold) ? Mathf.InverseLerp(num5, greenThreshold, heatPercent) : (1f - Mathf.InverseLerp(greenThreshold, num6, heatPercent))); float num8 = Mathf.Lerp(0.25f, 1f, num7); return Color.Lerp(value2, value, num8); } return value2; } private static string GetZoneText(HeatZone zone) { if (1 == 0) { } string result = zone switch { HeatZone.Green => "$seasons_status_summer_heat_zone_green", HeatZone.Neutral => "$seasons_status_summer_heat_zone_neutral", HeatZone.Red => "$seasons_status_summer_heat_zone_red", HeatZone.Max => "$seasons_status_summer_heat_zone_max", _ => "$seasons_status_summer_heat_zone_neutral", }; if (1 == 0) { } return result; } private static string GetExposureText() { if (SummerHeat.IsInSun) { return "$seasons_status_summer_heat_exposure_sun"; } if (SummerHeat.IsInShade) { return "$seasons_status_summer_heat_exposure_shade"; } return "$seasons_status_summer_heat_exposure_none"; } private static string GetTrendText() { if (SummerHeat.Direction > 0) { return "$seasons_status_summer_heat_trend_heating"; } if (SummerHeat.Direction < 0) { return "$seasons_status_summer_heat_trend_cooling"; } return "$seasons_status_summer_heat_trend_stable"; } private static string GetModifierSummary() { StringBuilder stringBuilder = new StringBuilder(128); AppendModifierLine(stringBuilder, "$seasons_status_summer_heat_modifier_health_regen", GetHeatMultiplier(Seasons.summerHeatHealthRegenMultiplier.Value)); AppendModifierLine(stringBuilder, "$seasons_status_summer_heat_modifier_stamina_regen", GetHeatMultiplier(Seasons.summerHeatStaminaRegenMultiplier.Value)); AppendModifierLine(stringBuilder, "$seasons_status_summer_heat_modifier_eitr_regen", GetHeatMultiplier(Seasons.summerHeatEitrRegenMultiplier.Value)); AppendModifierLine(stringBuilder, "$seasons_status_summer_heat_modifier_stamina_use", 1f + GetSignedModifier(Seasons.summerHeatStaminaUseMultiplier.Value)); AppendModifierLine(stringBuilder, "$seasons_status_summer_heat_modifier_adrenaline", 1f + GetSignedModifier(Seasons.summerHeatAdrenalineMultiplier.Value)); if (stringBuilder.Length == 0) { return string.Empty; } return "\n" + stringBuilder; } private static void AppendActiveFactors(StringBuilder builder) { bool flag = false; if ((Object)(object)SummerHeat.Instance != (Object)null && SummerHeat.Instance.HasCoolingFood()) { builder.AppendFormat("{0}\n", "$seasons_status_summer_heat_factor_cooling_food".Localize()); flag = true; } if ((Object)(object)SummerHeat.Instance != (Object)null && SummerHeat.Instance.HasCampFireHeat()) { builder.AppendFormat("{0}\n", "$seasons_status_summer_heat_factor_campfire".Localize()); flag = true; } if ((Object)(object)SummerHeat.Instance != (Object)null && SummerHeat.Instance.HasEncumberedHeat()) { builder.AppendFormat("{0}\n", "$seasons_status_summer_heat_factor_encumbered".Localize()); flag = true; } if (flag) { builder.Append('\n'); } } private static void AppendModifierLine(StringBuilder builder, string label, float multiplier) { if (!Mathf.Approximately(multiplier, 1f)) { builder.AppendFormat("{0}: {1}%\n", label.Localize(), ((multiplier - 1f) * 100f).ToString("+0;-0")); } } } internal struct SummerHeatArmorState { public static readonly SummerHeatArmorState Empty = new SummerHeatArmorState { HeadState = "$seasons_status_summer_heat_armor_disabled", CloakState = "$seasons_status_summer_heat_armor_disabled", ChestState = "$seasons_status_summer_heat_armor_disabled", LegsState = "$seasons_status_summer_heat_armor_disabled" }; public float HeatingModifier; public float CoolingModifier; public string HeadState; public string CloakState; public string ChestState; public string LegsState; } internal class SummerHeatController : MonoBehaviour { internal const float EvaluationInterval = 1f; internal const float DaytimeHeatCap = 100f; internal const float ShadowRayDistance = 100f; internal const float StableEpsilon = 0.01f; internal const float WetCoolingPerSecond = 5f; internal const float ShelterCoolingPerSecond = 2f; internal const float BurningHeatPerSecond = 5f; internal const float RunningHeatPerSecond = 0.5f; internal const float WalkingCoolingPerSecond = 0.5f; internal const float StandingCoolingPerSecond = 1f; internal const float CoolingFoodHeatPerSecond = 5f; internal const float CampFireHeatPerSecond = 0.5f; internal const float EncumberedHeatPerSecond = 0.5f; internal const float MovementThreshold = 0.1f; internal const float NoonPeak = 0.5f; internal const float NoonStart = 0.42f; internal const float NoonEnd = 0.58f; internal const float SecondaryAttackHeat = 1f; internal const float PrimaryAttackHeat = 0.5f; internal const float DodgeHeat = 0.5f; internal const float JumpHeat = 0.25f; internal const float BlockHeat = 1f; internal const float PerfectBlockHeat = 0.5f; internal const float FireDamageHeat = 10f; internal const float FrostDamageHeat = -10f; private const float BareHeadHairHeatRateBonus = 0.2f; private static readonly HashSet s_configuredNonSunnySystems = new HashSet(StringComparer.OrdinalIgnoreCase); private static readonly HashSet s_openHelmetItems = new HashSet(StringComparer.OrdinalIgnoreCase); private static readonly HashSet s_bareHeadHairItems = new HashSet(StringComparer.OrdinalIgnoreCase); private static readonly HashSet s_lightCloakItems = new HashSet(StringComparer.OrdinalIgnoreCase); private static readonly HashSet s_openChestItems = new HashSet(StringComparer.OrdinalIgnoreCase); private static readonly HashSet s_openLegItems = new HashSet(StringComparer.OrdinalIgnoreCase); private static string s_configuredNonSunnySystemsValue = string.Empty; private static string s_openHelmetItemsValue = string.Empty; private static string s_bareHeadHairItemsValue = string.Empty; private static string s_lightCloakItemsValue = string.Empty; private static string s_openChestItemsValue = string.Empty; private static string s_openLegItemsValue = string.Empty; private float _evaluationTimer; private float _overflowHeat; private SummerHeatMode _mode = SummerHeatMode.Stable; private SummerHeatState _state; private string _currentEnvironmentName = string.Empty; private bool _isDaytime = true; private bool _hasWetStatus; private bool _hasShelterStatus; private bool _hasBurningStatus; private bool _hasColdStatus; private bool _hasCoolingFood; private bool _hasCampFireStatus; private bool _biomeAllowsSummerHeat = true; private Biome _currentBiome = (Biome)0; private SummerHeatArmorState _armorState = SummerHeatArmorState.Empty; internal static SummerHeatController Instance { get; private set; } internal Player Player { get; private set; } internal SummerHeatState State => _state; internal SummerHeatArmorState ArmorState => _armorState; private void Awake() { Player = ((Component)this).GetComponent(); if ((Object)(object)Player != (Object)(object)Player.m_localPlayer) { ((Behaviour)this).enabled = false; return; } Instance = this; EvaluateState(forceStatusRefresh: true); } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } SummerHeatVisuals.UpdateHazeState(); } private void Update() { if (!((Object)(object)Player == (Object)null) && !((Object)(object)Player != (Object)(object)Player.m_localPlayer) && !((Character)Player).IsDead()) { float deltaTime = Time.deltaTime; _evaluationTimer += deltaTime; if (_evaluationTimer >= 1f) { _evaluationTimer = 0f; EvaluateState(forceStatusRefresh: false); } UpdateHeat(deltaTime); SummerHeatVisuals.UpdateHazeState(); } } internal static void EnsureForPlayer(Player player) { SummerHeatController summerHeatController = default(SummerHeatController); if (!((Object)(object)player == (Object)null) && !((Object)(object)player != (Object)(object)Player.m_localPlayer) && !((Component)player).TryGetComponent(ref summerHeatController)) { ((Component)player).gameObject.AddComponent(); } } internal static HeatZone GetZoneForHeat(float heatPercent, HeatZone previousZone, bool biomeSupported, bool isDaytime, float overflowHeat) { if (!biomeSupported) { return HeatZone.Neutral; } float greenThreshold = GetGreenThreshold(isDaytime); float neutralThreshold = GetNeutralThreshold(isDaytime); float maxThreshold = GetMaxThreshold(isDaytime); float zoneHysteresis = GetZoneHysteresis(isDaytime); if (heatPercent <= 0f && overflowHeat <= 0f && maxThreshold <= 0f) { return HeatZone.Neutral; } float greenReturnThreshold = greenThreshold + zoneHysteresis * 0.5f; float num = greenThreshold + zoneHysteresis; float num2 = neutralThreshold - zoneHysteresis; if (overflowHeat > 0f || heatPercent >= maxThreshold) { return HeatZone.Max; } if (1 == 0) { } HeatZone result = previousZone switch { HeatZone.Green => (heatPercent >= num) ? HeatZone.Neutral : HeatZone.Green, HeatZone.Red => (heatPercent < num2) ? HeatZone.Neutral : HeatZone.Red, HeatZone.Max => HeatZone.Red, _ => ResolveNeutralZone(heatPercent, greenReturnThreshold, neutralThreshold), }; if (1 == 0) { } return result; } internal string GetCurrentEnvironmentName() { return _currentEnvironmentName; } internal bool IsDaytime() { return _isDaytime; } internal void RefreshState(bool forceStatusRefresh = true) { EvaluateState(forceStatusRefresh); } internal void AddInstantHeat(float amount, bool useConfigGate = false) { if (!Seasons.summerHeatEnabled.Value || Mathf.Approximately(amount, 0f) || (useConfigGate && !Seasons.summerHeatInstantHeatSources.Value) || !_biomeAllowsSummerHeat) { return; } if (amount > 0f) { if (!_state.SeasonHeatWindowActive || _hasColdStatus || _hasCoolingFood) { return; } } else if (!_state.SeasonHeatWindowActive && _state.TotalHeatPercent <= 0f) { return; } float totalHeatPercent = _state.TotalHeatPercent; ApplyHeatDelta(amount, GetCurrentHeatCap()); RefreshDerivedState(totalHeatPercent, forceStatusRefresh: false); } private static HeatZone ResolveNeutralZone(float heatPercent, float greenReturnThreshold, float neutralThreshold) { if (heatPercent < greenReturnThreshold) { return HeatZone.Green; } if (heatPercent >= neutralThreshold) { return HeatZone.Red; } return HeatZone.Neutral; } private void EvaluateState(bool forceStatusRefresh) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (!Seasons.summerHeatEnabled.Value) { ClearHeatState(forceStatusRefresh); return; } _isDaytime = !EnvMan.IsNight(); _currentBiome = (Biome)(((Object)(object)Player != (Object)null) ? ((int)Player.GetCurrentBiome()) : 0); _biomeAllowsSummerHeat = AllowsSummerHeatBiome(_currentBiome); bool flag = _biomeAllowsSummerHeat && IsSeasonHeatWindowActive(); EnvSetup env = EnvMan.instance?.m_currentEnv; _currentEnvironmentName = GetEnvironmentName(env); bool flag2 = flag && IsEnvironmentSunny(env); bool flag3 = false; bool flag4 = false; if (flag && flag2 && _isDaytime) { flag4 = ComputeShade(Player); flag3 = !flag4; } else { flag4 = true; } SEMan sEMan = ((Character)Player).GetSEMan(); _hasWetStatus = sEMan.HaveStatusEffect(SEMan.s_statusEffectWet); _hasShelterStatus = sEMan.HaveStatusEffect(SEMan.s_statusEffectShelter); _hasBurningStatus = sEMan.HaveStatusEffect(SEMan.s_statusEffectBurning); _hasCampFireStatus = sEMan.HaveStatusEffect(SEMan.s_statusEffectCampFire); _hasColdStatus = sEMan.HaveStatusEffect(SEMan.s_statusEffectCold) || sEMan.HaveStatusEffect(SEMan.s_statusEffectFreezing) || sEMan.HaveStatusEffect(SEMan.s_statusEffectFrost); _hasCoolingFood = SeasonState.HasCoolingFood(Player); bool flag5 = IsPlayerCoolingByWater(Player); bool isHeating = flag && flag2 && _isDaytime && flag3 && !flag5; _mode = GetMode(flag, isHeating, flag5, flag4); _state.SeasonHeatWindowActive = flag; _state.IsSunny = flag2; _state.IsInSun = flag3; _state.IsInShade = flag4; _state.BiomeSupported = _biomeAllowsSummerHeat; RefreshArmorState(); RefreshDerivedState(_state.TotalHeatPercent, forceStatusRefresh); } private void ClearHeatState(bool forceStatusRefresh) { float totalHeatPercent = _state.TotalHeatPercent; _overflowHeat = 0f; _mode = SummerHeatMode.Stable; _currentEnvironmentName = string.Empty; _isDaytime = !EnvMan.IsNight(); _hasWetStatus = false; _hasShelterStatus = false; _hasBurningStatus = false; _hasColdStatus = false; _hasCoolingFood = false; _hasCampFireStatus = false; _biomeAllowsSummerHeat = false; _state.SetHeat(0f, 0f, 0f, 100f, HeatZone.Neutral, 0f, 0f, 0f); _state.Direction = ((totalHeatPercent > 0f) ? (-1) : 0); _state.IsCooling = false; _state.IsSunny = false; _state.IsInSun = false; _state.IsInShade = true; _state.SeasonHeatWindowActive = false; _state.BiomeSupported = false; _state.MechanicActive = false; _armorState = SummerHeatArmorState.Empty; EnsureStatusEffect(shouldHaveEffect: false); SummerHeatVisuals.UpdateHazeState(); } private void UpdateHeat(float dt) { float totalHeatPercent = _state.TotalHeatPercent; if (!Seasons.summerHeatEnabled.Value) { ClearHeatState(forceStatusRefresh: true); return; } if (!_biomeAllowsSummerHeat) { _overflowHeat = 0f; _state.SetHeat(0f, 0f, 0f, 100f, HeatZone.Neutral, 0f, 0f, 0f); _state.Direction = ((totalHeatPercent > 0f) ? (-1) : 0); _state.IsCooling = totalHeatPercent > 0f; _state.MechanicActive = false; EnsureStatusEffect(shouldHaveEffect: false); return; } float currentHeatCap = GetCurrentHeatCap(); float num = 0f; float num2 = 100f / Mathf.Max(1f, Seasons.summerHeatTimeToMax.Value); switch (_mode) { case SummerHeatMode.Heating: num += num2 * dt; break; case SummerHeatMode.CoolingFast: num -= num2 * 2.5f * dt; break; case SummerHeatMode.CoolingNormal: num -= num2 * 1.25f * dt; break; case SummerHeatMode.CoolingSlow: num -= num2 * 0.4f * dt; break; } if (_state.SeasonHeatWindowActive) { if (_hasBurningStatus) { num += 5f * dt; } if (_hasWetStatus) { num -= 5f * dt; } if (_hasShelterStatus) { num -= 2f * dt; } num += GetActivityHeatDelta(Player, dt); } num = ApplyDynamicRateModifiers(num); num = ApplyArmorRateModifiers(num); ApplyHeatDelta(num, currentHeatCap); if (_hasColdStatus) { _overflowHeat = 0f; ApplyHeatDelta(0f - GetLiveTotalHeat(), currentHeatCap); } else if (_hasCoolingFood) { ApplyHeatDelta(GetCoolingDeltaTowards(GetGreenThreshold(_isDaytime), 5f, dt), currentHeatCap); } if (_state.SeasonHeatWindowActive) { if (Seasons.summerHeatCampFireAddsHeat.Value && _hasCampFireStatus) { ApplyHeatDelta(GetHeatingDeltaTowards(GetGreenThreshold(_isDaytime), 0.5f, dt), currentHeatCap); } if (Seasons.summerHeatEncumberedAddsHeat.Value && ((Character)Player).IsEncumbered()) { ApplyHeatDelta(GetHeatingDeltaTowards(GetNeutralThreshold(_isDaytime), 0.5f, dt), currentHeatCap); } } RefreshDerivedState(totalHeatPercent, forceStatusRefresh: false); } private void RefreshDerivedState(float previousTotalHeat, bool forceStatusRefresh) { float currentHeatCap = GetCurrentHeatCap(); float num = Mathf.Clamp(_state.HeatPercent, 0f, currentHeatCap); float num2 = Mathf.Max(0f, num + _overflowHeat); HeatZone zoneForHeat = GetZoneForHeat(num, _state.Zone, _biomeAllowsSummerHeat, _isDaytime, _overflowHeat); float greenFactor = CalculateGreenFactor(num); float redFactor = CalculateRedFactor(num); float maxFactor = CalculateMaxFactor(num, num2, currentHeatCap); _state.SetHeat(num, _overflowHeat, num2, 100f, zoneForHeat, greenFactor, redFactor, maxFactor); float num3 = num2 - previousTotalHeat; _state.Direction = ((!(Mathf.Abs(num3) <= 0.01f)) ? ((num3 > 0f) ? 1 : (-1)) : 0); _state.IsCooling = _hasColdStatus || (_hasCoolingFood && num2 > GetGreenThreshold(_isDaytime)) || _hasWetStatus || _hasShelterStatus || _state.Direction < 0; _state.MechanicActive = _state.SeasonHeatWindowActive || num2 > 0f; _state.BiomeSupported = _biomeAllowsSummerHeat; if (forceStatusRefresh || _state.MechanicActive != ((Character)Player).GetSEMan().HaveStatusEffect(SeasonsVars.s_statusEffectSummerHeatHash)) { EnsureStatusEffect(_state.MechanicActive); } } private void RefreshArmorState() { _armorState = CalculateArmorState(Player, _state.IsInSun); } private static SummerHeatArmorState CalculateArmorState(Player player, bool isInDirectSun) { if (!Seasons.summerHeatArmorHeatEnabled.Value || (Object)(object)player == (Object)null) { return SummerHeatArmorState.Empty; } SummerHeatArmorState state = new SummerHeatArmorState { HeadState = "$seasons_status_summer_heat_armor_empty", CloakState = "$seasons_status_summer_heat_armor_empty", ChestState = "$seasons_status_summer_heat_armor_empty", LegsState = "$seasons_status_summer_heat_armor_empty" }; ApplyHeadArmor(player, isInDirectSun, ref state); ApplyCloakArmor(player, ref state); ApplyBodyArmor(player, (ItemType)7, GetConfiguredItemList(Seasons.summerHeatOpenChestItems, ref s_openChestItemsValue, s_openChestItems), ref state.HeatingModifier, ref state.CoolingModifier, ref state.ChestState); ApplyBodyArmor(player, (ItemType)11, GetConfiguredItemList(Seasons.summerHeatOpenLegItems, ref s_openLegItemsValue, s_openLegItems), ref state.HeatingModifier, ref state.CoolingModifier, ref state.LegsState); state.HeatingModifier = Mathf.Clamp(state.HeatingModifier, -0.95f, 3f); state.CoolingModifier = Mathf.Clamp(state.CoolingModifier, -0.95f, 3f); return state; } private static void ApplyHeadArmor(Player player, bool isInDirectSun, ref SummerHeatArmorState state) { ItemData equippedItem = GetEquippedItem(player, (ItemType)6); if (equippedItem == null) { bool flag = IsBareHeadHair(player); if (isInDirectSun) { state.HeatingModifier += SummerHeatUtils.ClampEffect(Seasons.summerHeatUncoveredHeadSunHeating.Value) + (flag ? 0.2f : 0f); state.HeadState = (flag ? "$seasons_status_summer_heat_armor_bald_head" : "$seasons_status_summer_heat_armor_uncovered_sun"); } else { state.CoolingModifier += SummerHeatUtils.ClampEffect(Seasons.summerHeatUncoveredHeadShadeCooling.Value) + (flag ? 0.2f : 0f); state.HeadState = (flag ? "$seasons_status_summer_heat_armor_bald_head" : "$seasons_status_summer_heat_armor_uncovered_shade"); } } else if (IsConfiguredItem(equippedItem, GetConfiguredItemList(Seasons.summerHeatOpenHelmetItems, ref s_openHelmetItemsValue, s_openHelmetItems))) { state.HeatingModifier += SummerHeatUtils.ClampEffect(Seasons.summerHeatOpenHelmetHeating.Value); state.HeadState = "$seasons_status_summer_heat_armor_open_helmet"; } else { state.HeatingModifier += SummerHeatUtils.ClampEffect(Seasons.summerHeatClosedHelmetHeating.Value); state.CoolingModifier -= SummerHeatUtils.ClampEffect(Seasons.summerHeatClosedHelmetCoolingPenalty.Value); state.HeadState = "$seasons_status_summer_heat_armor_closed_helmet"; } } private static void ApplyCloakArmor(Player player, ref SummerHeatArmorState state) { ItemData equippedItem = GetEquippedItem(player, (ItemType)17); if (equippedItem == null) { state.HeatingModifier -= SummerHeatUtils.ClampEffect(Seasons.summerHeatNoCloakHeatingReduction.Value); state.CoolingModifier += SummerHeatUtils.ClampEffect(Seasons.summerHeatNoCloakCoolingBonus.Value); state.CloakState = "$seasons_status_summer_heat_armor_no_cloak"; } else if (IsConfiguredItem(equippedItem, GetConfiguredItemList(Seasons.summerHeatLightCloakItems, ref s_lightCloakItemsValue, s_lightCloakItems))) { state.HeatingModifier -= SummerHeatUtils.ClampEffect(Seasons.summerHeatLightCloakHeatingReduction.Value); state.CoolingModifier += SummerHeatUtils.ClampEffect(Seasons.summerHeatLightCloakCoolingBonus.Value); state.CloakState = "$seasons_status_summer_heat_armor_light_cloak"; } else if (IsFrostResistantItem(equippedItem)) { state.HeatingModifier += SummerHeatUtils.ClampEffect(Seasons.summerHeatColdCloakHeating.Value); state.CoolingModifier -= SummerHeatUtils.ClampEffect(Seasons.summerHeatColdCloakCoolingPenalty.Value); state.CloakState = "$seasons_status_summer_heat_armor_cold_cloak"; } else { state.HeatingModifier += SummerHeatUtils.ClampEffect(Seasons.summerHeatCloakHeating.Value); state.CloakState = "$seasons_status_summer_heat_armor_cloak"; } } private static void ApplyBodyArmor(Player player, ItemType itemType, HashSet openItems, ref float heatingModifier, ref float coolingModifier, ref string stateKey) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ItemData equippedItem = GetEquippedItem(player, itemType); if (equippedItem == null) { heatingModifier -= SummerHeatUtils.ClampEffect(Seasons.summerHeatEmptyArmorSlotHeatingReduction.Value); coolingModifier += SummerHeatUtils.ClampEffect(Seasons.summerHeatEmptyArmorSlotCoolingBonus.Value); stateKey = "$seasons_status_summer_heat_armor_empty"; } else if (IsConfiguredItem(equippedItem, openItems)) { heatingModifier -= SummerHeatUtils.ClampEffect(Seasons.summerHeatOpenArmorHeatingReduction.Value); coolingModifier += SummerHeatUtils.ClampEffect(Seasons.summerHeatOpenArmorCoolingBonus.Value); stateKey = "$seasons_status_summer_heat_armor_open_armor"; } else if (IsFrostResistantItem(equippedItem)) { heatingModifier += SummerHeatUtils.ClampEffect(Seasons.summerHeatColdArmorHeating.Value); coolingModifier -= SummerHeatUtils.ClampEffect(Seasons.summerHeatColdArmorCoolingPenalty.Value); stateKey = "$seasons_status_summer_heat_armor_cold_armor"; } else { heatingModifier += SummerHeatUtils.ClampEffect(Seasons.summerHeatClosedArmorHeating.Value); stateKey = "$seasons_status_summer_heat_armor_closed_armor"; } } private static ItemData GetEquippedItem(Player player, ItemType itemType) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null)) { Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory != null) { return ((IEnumerable)inventory.GetEquippedItems()).FirstOrDefault((Func)((ItemData item) => item != null && item.m_shared != null && item.m_shared.m_itemType == itemType)); } } return null; } private static bool IsFrostResistantItem(ItemData item) { return item?.m_shared?.m_damageModifiers != null && item.m_shared.m_damageModifiers.Any(SeasonState.IsFrostResistant); } private static bool IsConfiguredItem(ItemData item, HashSet configuredItems) { if (item?.m_shared == null || configuredItems == null || configuredItems.Count == 0) { return false; } if (!string.IsNullOrEmpty(item.m_shared.m_name) && configuredItems.Contains(item.m_shared.m_name)) { return true; } string text = (((Object)(object)item.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : string.Empty); return !string.IsNullOrEmpty(text) && (configuredItems.Contains(text) || configuredItems.Contains(text.GetItemName())); } private static bool IsBareHeadHair(Player player) { HashSet configuredItemList = GetConfiguredItemList(Seasons.summerHeatBareHeadHairItems, ref s_bareHeadHairItemsValue, s_bareHeadHairItems); if ((Object)(object)player == (Object)null || configuredItemList.Count == 0) { return false; } string text = ((Humanoid)player).m_hairItem ?? string.Empty; if (string.IsNullOrWhiteSpace(text)) { return configuredItemList.Contains("none") || configuredItemList.Contains("bald") || configuredItemList.Contains("balded") || configuredItemList.Contains("HairNone") || configuredItemList.Contains("HairNone".GetItemName()); } return configuredItemList.Contains(text) || configuredItemList.Contains(text.GetItemName()); } private static HashSet GetConfiguredItemList(ConfigEntry config, ref string cachedValue, HashSet cache) { string text = config?.Value ?? string.Empty; if (text == cachedValue) { return cache; } cachedValue = text; cache.Clear(); string[] array = text.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text2 in array) { string text3 = text2.Trim(); if (!string.IsNullOrEmpty(text3)) { cache.Add(text3); cache.Add(text3.GetItemName()); } } return cache; } private static float GetActivityHeatDelta(Player player, float dt) { if ((Object)(object)player == (Object)null) { return 0f; } if (((Character)player).IsRunning()) { return 0.5f * dt; } if (((Character)player).IsWalking()) { return 0f - 0.5f * dt; } if (((Vector3)(ref ((Character)player).m_moveDir)).magnitude > 0.1f) { return 0f; } return 0f - 1f * dt; } private void ApplyHeatDelta(float delta, float heatCap) { if (Mathf.Approximately(delta, 0f)) { return; } float num = Mathf.Clamp(_state.HeatPercent, 0f, heatCap); if (delta > 0f) { float num2 = Mathf.Max(0f, heatCap - num); float num3 = Mathf.Min(num2, delta); num += num3; float num4 = delta - num3; if (num4 > 0f) { _overflowHeat = Mathf.Clamp(_overflowHeat + num4, 0f, SummerHeatUtils.ClampPercent(Seasons.summerHeatMaxOverflow.Value)); } } else { float num5 = 0f - delta; if (_overflowHeat > 0f) { float num6 = Mathf.Min(_overflowHeat, num5); _overflowHeat -= num6; num5 -= num6; } if (num5 > 0f) { num = Mathf.Max(0f, num - num5); } } _state.HeatPercent = Mathf.Clamp(num, 0f, heatCap); } private float ApplyDynamicRateModifiers(float delta) { if (Mathf.Approximately(delta, 0f)) { return 0f; } float num = Mathf.Clamp01(Seasons.summerHeatWindEffectPercent.Value); float num2 = 0f - num; EnvMan instance = EnvMan.instance; float num3 = Mathf.Lerp(num, num2, Mathf.Clamp01((instance != null) ? instance.GetWindIntensity() : 0f)); float num4 = Mathf.Clamp01(Seasons.summerHeatNoonEffectPercent.Value) * GetNoonInfluence(); float num5 = num3 + num4; float num6 = ((delta > 0f) ? (1f + num5) : (1f - num5)); return delta * Mathf.Max(0.05f, num6); } private float ApplyArmorRateModifiers(float delta) { if (!Seasons.summerHeatArmorHeatEnabled.Value || Mathf.Approximately(delta, 0f)) { return delta; } float num = ((delta > 0f) ? _armorState.HeatingModifier : _armorState.CoolingModifier); if (Mathf.Approximately(num, 0f)) { return delta; } return delta * Mathf.Max(0.05f, 1f + num); } private static float GetNoonInfluence() { if ((Object)(object)EnvMan.instance == (Object)null) { return 0f; } float smoothDayFraction = EnvMan.instance.m_smoothDayFraction; if (smoothDayFraction <= 0.42f || smoothDayFraction >= 0.58f) { return 0f; } float num = 0.08f; return Mathf.Clamp01(1f - Mathf.Abs(smoothDayFraction - 0.5f) / num); } private float GetCurrentHeatCap() { float nightFactor = SummerHeatUtils.GetNightFactor(); return _isDaytime ? 100f : (100f * nightFactor); } private static float GetGreenThreshold(bool isDaytime) { return SummerHeatUtils.ScaleHeatPercentForTime(SummerHeatUtils.ClampPercent(Seasons.summerHeatGreenThreshold.Value), isDaytime); } private static float GetNeutralThreshold(bool isDaytime) { return SummerHeatUtils.ScaleHeatPercentForTime(SummerHeatUtils.ClampPercent(Mathf.Max(GetGreenThreshold(isDaytime: true) + 1f, Seasons.summerHeatNeutralThreshold.Value)), isDaytime); } private static float GetMaxThreshold(bool isDaytime) { return SummerHeatUtils.ScaleHeatPercentForTime(SummerHeatUtils.ClampPercent(Mathf.Max(GetNeutralThreshold(isDaytime: true) + 1f, Seasons.summerHeatMaxThreshold.Value)), isDaytime); } private static float GetZoneHysteresis(bool isDaytime) { return SummerHeatUtils.ScaleHeatPercentForTime(SummerHeatUtils.ClampPercent(Seasons.summerHeatZoneHysteresis.Value), isDaytime); } private static float CalculateGreenFactor(float heat) { bool isDaytime = (Object)(object)Instance == (Object)null || Instance._isDaytime; float greenThreshold = GetGreenThreshold(isDaytime); float num = Mathf.Max(0.1f, SummerHeatUtils.ScaleHeatPercentForTime(SummerHeatUtils.ClampPercent(Seasons.summerHeatGreenFadeWidth.Value), isDaytime)); float num2 = Mathf.Max(0f, greenThreshold - num); float num3 = greenThreshold + num; if (heat <= num2 || heat >= num3) { return 0f; } if (heat <= greenThreshold) { return Mathf.InverseLerp(num2, greenThreshold, heat); } return 1f - Mathf.InverseLerp(greenThreshold, num3, heat); } private static float CalculateRedFactor(float heat) { bool isDaytime = (Object)(object)Instance == (Object)null || Instance._isDaytime; float neutralThreshold = GetNeutralThreshold(isDaytime); float maxThreshold = GetMaxThreshold(isDaytime); float num = Mathf.Max(0.1f, SummerHeatUtils.ScaleHeatPercentForTime(SummerHeatUtils.ClampPercent(Seasons.summerHeatRedRampWidth.Value), isDaytime)); float num2 = Mathf.Min(maxThreshold, neutralThreshold + num); if (heat <= neutralThreshold) { return 0f; } if (heat < num2) { return Mathf.InverseLerp(neutralThreshold, num2, heat); } return 1f; } private static float CalculateMaxFactor(float heat, float totalHeat, float heatCap) { bool isDaytime = (Object)(object)Instance == (Object)null || Instance._isDaytime; float maxThreshold = GetMaxThreshold(isDaytime); if (totalHeat <= maxThreshold) { return 0f; } if (totalHeat >= heatCap || ((Object)(object)Instance != (Object)null && Instance._overflowHeat > 0f)) { return 1f; } return Mathf.InverseLerp(maxThreshold, heatCap, Mathf.Clamp(heat, maxThreshold, heatCap)); } private float GetCoolingDeltaTowards(float target, float unitsPerSecond, float dt) { float liveTotalHeat = GetLiveTotalHeat(); if (liveTotalHeat <= target) { return 0f; } float num = Mathf.Max(0f, unitsPerSecond) * dt; return 0f - Mathf.Min(num, liveTotalHeat - target); } private float GetHeatingDeltaTowards(float target, float unitsPerSecond, float dt) { float liveTotalHeat = GetLiveTotalHeat(); if (liveTotalHeat >= target) { return 0f; } float num = Mathf.Max(0f, unitsPerSecond) * dt; return Mathf.Min(num, target - liveTotalHeat); } private float GetLiveTotalHeat() { return Mathf.Max(0f, _state.HeatPercent + _overflowHeat); } private void EnsureStatusEffect(bool shouldHaveEffect) { SEMan sEMan = ((Character)Player).GetSEMan(); bool flag = sEMan.HaveStatusEffect(SeasonsVars.s_statusEffectSummerHeatHash); if (shouldHaveEffect) { if (!flag) { sEMan.AddStatusEffect(SeasonsVars.s_statusEffectSummerHeatHash, false, 0, 0f); } } else if (flag) { sEMan.RemoveStatusEffect(SeasonsVars.s_statusEffectSummerHeatHash, false); } } private static SummerHeatMode GetMode(bool seasonHeatWindowActive, bool isHeating, bool isCoolingByWater, bool isInShade) { if (isCoolingByWater) { return SummerHeatMode.CoolingFast; } if (isHeating) { return SummerHeatMode.Heating; } if (seasonHeatWindowActive && isInShade) { return SummerHeatMode.CoolingNormal; } return SummerHeatMode.CoolingSlow; } private bool IsSeasonHeatWindowActive() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (!Seasons.summerHeatEnabled.Value || Seasons.seasonState == null) { return false; } if (Seasons.seasonState.GetCurrentSeason() != Seasons.Season.Summer) { return false; } Vector2 value = Seasons.summerHeatDays.Value; int currentDay = Seasons.seasonState.GetCurrentDay(); int num = Mathf.RoundToInt(Mathf.Min(value.x, value.y)); int num2 = Mathf.RoundToInt(Mathf.Max(value.x, value.y)); return currentDay >= num && currentDay <= num2; } private static string GetEnvironmentName(EnvSetup env) { return env?.m_name ?? string.Empty; } private static bool IsPlayerCoolingByWater(Player player) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return false; } float liquidLevel = Floating.GetLiquidLevel(((Component)player).transform.position, 1f, (LiquidType)10); return ((Character)player).IsSwimming() || liquidLevel > ((Component)player).transform.position.y + 0.1f; } private static bool ComputeShade(Player player) { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || (Object)(object)EnvMan.instance?.m_dirLight == (Object)null || (Object)(object)StealthSystem.instance == (Object)null) { return false; } if (((Character)player).InInterior() || player.InShelter()) { return true; } float num = 0.5f; if (((Character)player).InEmote()) { if (player.m_emoteState == "rest") { num = 0.1f; } else if (player.m_emoteState == "sit") { num = 0.25f; } } Vector3 val = Vector3.Lerp(((Component)player).transform.position, ((Character)player).GetEyePoint(), num); Vector3 val2 = -((Component)EnvMan.instance.m_dirLight).transform.forward; return Physics.Raycast(val, val2, 100f, LayerMask.op_Implicit(StealthSystem.instance.m_shadowTestMask)); } private static bool IsEnvironmentSunny(EnvSetup env) { if (env == null) { return true; } HashSet configuredNonSunnySystems = GetConfiguredNonSunnySystems(); if (configuredNonSunnySystems.Count == 0) { return true; } return !IsInConfiguredWeatherList(env, configuredNonSunnySystems); } private static HashSet GetConfiguredNonSunnySystems() { string text = Seasons.summerHeatNonSunnyEnvironments.Value ?? string.Empty; if (text == s_configuredNonSunnySystemsValue) { return s_configuredNonSunnySystems; } s_configuredNonSunnySystemsValue = text; s_configuredNonSunnySystems.Clear(); string[] array = text.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text2 in array) { string text3 = text2.Trim(); if (text3.Length > 0) { s_configuredNonSunnySystems.Add(text3); } } return s_configuredNonSunnySystems; } private static bool IsInConfiguredWeatherList(EnvSetup env, HashSet environmentSystems) { return ((Object)(object)env.m_envObject != (Object)null && environmentSystems.Contains(((Object)env.m_envObject).name)) || (env.m_psystems != null && env.m_psystems.Any((GameObject ps) => (Object)(object)ps != (Object)null && ((Object)ps).name != null && environmentSystems.Contains(((Object)ps).name))); } private static bool AllowsSummerHeatBiome(Biome biome) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 return (int)biome != 32 && (int)biome != 64 && (int)biome != 4; } internal bool HasCoolingFood() { return _hasCoolingFood; } internal bool HasCampFireHeat() { return _state.SeasonHeatWindowActive && Seasons.summerHeatCampFireAddsHeat.Value && _hasCampFireStatus && GetLiveTotalHeat() < GetGreenThreshold(_isDaytime); } internal bool HasEncumberedHeat() { return _state.SeasonHeatWindowActive && Seasons.summerHeatEncumberedAddsHeat.Value && ((Character)Player).IsEncumbered() && GetLiveTotalHeat() < GetNeutralThreshold(_isDaytime); } internal static bool IsSecondaryAttack(Humanoid humanoid) { return humanoid.m_currentAttackIsSecondary; } internal static bool WasPerfectBlock(Humanoid humanoid) { return humanoid.m_blockTimer > 0f && humanoid.m_blockTimer <= 0.25f; } } [HarmonyPatch(typeof(Humanoid), "StartAttack")] internal static class Humanoid_StartAttack_SummerHeat { private static void Postfix(Humanoid __instance, ref bool __result) { if (__result && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { float amount = (SummerHeatController.IsSecondaryAttack(__instance) ? 1f : 0.5f); SummerHeatController.Instance?.AddInstantHeat(amount, useConfigGate: true); } } } [HarmonyPatch(typeof(Player), "UpdateDodge")] internal static class Player_UpdateDodge_SummerHeat { private static void Prefix(bool ___m_inDodge, ref bool __state) { __state = ___m_inDodge; } private static void Postfix(Player __instance, bool ___m_inDodge, bool __state) { if (!__state && ___m_inDodge && (Object)(object)__instance == (Object)(object)Player.m_localPlayer) { SummerHeatController.Instance?.AddInstantHeat(0.5f, useConfigGate: true); } } } [HarmonyPatch(typeof(Character), "Jump")] internal static class Character_Jump_SummerHeat { private static void Postfix(Character __instance) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer) { SummerHeatController.Instance?.AddInstantHeat(0.25f, useConfigGate: true); } } } [HarmonyPatch(typeof(Humanoid), "BlockAttack")] internal static class Humanoid_BlockAttack_SummerHeat { private static void Postfix(Humanoid __instance, bool __result) { if (__result && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { SummerHeatController.Instance?.AddInstantHeat(SummerHeatController.WasPerfectBlock(__instance) ? 0.5f : 1f, useConfigGate: true); } } } [HarmonyPatch(typeof(Character), "ApplyDamage")] internal static class Character_ApplyDamage_SummerHeat { private static void Postfix(Character __instance, ref HitData hit) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && hit != null) { if (hit.m_damage.m_fire > 0f) { SummerHeatController.Instance?.AddInstantHeat(10f); } else if (hit.m_damage.m_frost > 0f) { SummerHeatController.Instance?.AddInstantHeat(-10f); } } } } [HarmonyPatch(typeof(Player), "OnSpawned")] internal static class Player_OnSpawned_SummerHeat { private static void Postfix(Player __instance) { SummerHeatController.EnsureForPlayer(__instance); } } internal enum HeatZone { Green, Neutral, Red, Max } internal enum SummerHeatMode { Stable, Heating, CoolingFast, CoolingNormal, CoolingSlow } internal struct SummerHeatState { public bool MechanicActive; public bool SeasonHeatWindowActive; public bool IsSunny; public bool IsInSun; public bool IsInShade; public bool IsCooling; public bool BiomeSupported; public float HeatPercent; public float OverflowHeatPercent; public float TotalHeatPercent; public float HeatFactor; public float GreenFactor; public float RedFactor; public float MaxFactor; public HeatZone Zone; public int Direction; public void SetHeat(float heatPercent, float overflowHeatPercent, float totalHeatPercent, float displayCap, HeatZone zone, float greenFactor, float redFactor, float maxFactor) { HeatPercent = Mathf.Clamp(heatPercent, 0f, 100f); OverflowHeatPercent = Mathf.Max(0f, overflowHeatPercent); TotalHeatPercent = Mathf.Max(0f, totalHeatPercent); HeatFactor = Mathf.Clamp01((displayCap <= 0f) ? 0f : (HeatPercent / displayCap)); GreenFactor = Mathf.Clamp01(greenFactor); RedFactor = Mathf.Clamp01(redFactor); MaxFactor = Mathf.Clamp01(maxFactor); Zone = zone; } } internal static class SummerHeat { public static SummerHeatController Instance => SummerHeatController.Instance; public static bool IsReady => (Object)(object)Instance != (Object)null && (Object)(object)Instance.Player != (Object)null; public static bool IsMechanicActive => (Object)(object)Instance != (Object)null && Instance.State.MechanicActive; public static bool IsSeasonHeatWindowActive => (Object)(object)Instance != (Object)null && Instance.State.SeasonHeatWindowActive; public static bool IsSunny => (Object)(object)Instance != (Object)null && Instance.State.IsSunny; public static bool IsInSun => (Object)(object)Instance != (Object)null && Instance.State.IsInSun; public static bool IsInShade => (Object)(object)Instance != (Object)null && Instance.State.IsInShade; public static bool IsCooling => (Object)(object)Instance != (Object)null && Instance.State.IsCooling; public static bool IsBiomeSupported => (Object)(object)Instance != (Object)null && Instance.State.BiomeSupported; public static float HeatPercent => ((Object)(object)Instance != (Object)null) ? Instance.State.HeatPercent : 0f; public static float TotalHeatPercent => ((Object)(object)Instance != (Object)null) ? Instance.State.TotalHeatPercent : 0f; public static float OverflowHeatPercent => ((Object)(object)Instance != (Object)null) ? Instance.State.OverflowHeatPercent : 0f; public static float HeatFactor => ((Object)(object)Instance != (Object)null) ? Instance.State.HeatFactor : 0f; public static float GreenFactor => ((Object)(object)Instance != (Object)null) ? Instance.State.GreenFactor : 0f; public static float RedFactor => ((Object)(object)Instance != (Object)null) ? Instance.State.RedFactor : 0f; public static float MaxEffectFactor => ((Object)(object)Instance != (Object)null) ? Instance.State.MaxFactor : 0f; public static int Direction => ((Object)(object)Instance != (Object)null) ? Instance.State.Direction : 0; public static HeatZone CurrentZone => (!((Object)(object)Instance != (Object)null)) ? HeatZone.Neutral : Instance.State.Zone; } public static class SummerHeatVisuals { public const string SummerHeatHazeObjectName = "SummerHeatHaze"; private static GameObject _hazeObject; private static bool _summerHeatColorApplied; private static bool _hasDefaultHeatDistortionColor; private static Color _defaultHeatDistortionColor; internal static void Initialize() { DestroyHazeObject(); if (!Object.op_Implicit((Object)(object)ZoneSystem.instance)) { return; } GameObject val = FindAshlandsHaze(); Game instance = Game.instance; object obj; if (instance == null) { obj = null; } else { GameObject gameObject = ((Component)instance).gameObject; if (gameObject == null) { obj = null; } else { Transform transform = gameObject.transform; obj = ((transform != null) ? transform.Find("_Environment/FollowPlayer") : null); } } Transform val2 = (Transform)obj; if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2)) { _hazeObject = Object.Instantiate(val, val2); ((Object)_hazeObject).name = "SummerHeatHaze"; _hazeObject.SetActive(false); for (int num = _hazeObject.transform.childCount - 1; num >= 0; num--) { Transform child = _hazeObject.transform.GetChild(num); switch (((Object)child).name) { case "ash": case "zinder": case "fx_ember_rain": child.parent = null; Object.Destroy((Object)(object)((Component)child).gameObject); break; case "mist": ((Component)child).gameObject.SetActive(false); break; case "vfx_Ashlands_HeatDistortion": AdaptAshlandsHeatDistortion(((Component)child).GetComponent(), ((Component)child).GetComponent()); break; } } } else { Seasons.LogWarning($"Error when initializing summer heat: Haze object {(Object)(object)val != (Object)null} FollowPlayer {(Object)(object)val2 != (Object)null}"); } } private static void AdaptAshlandsHeatDistortion(ParticleSystem ps, ParticleSystemRenderer psRenderer) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ps == (Object)null)) { MainModule main = ps.main; ((MainModule)(ref main)).simulationSpeed = 1f; ((MainModule)(ref main)).maxParticles = 200; MinMaxGradient startColor = ((MainModule)(ref main)).startColor; ((MinMaxGradient)(ref startColor)).colorMax = new Color(1f, 1f, 1f, 0.75f); ((MainModule)(ref main)).startColor = startColor; EmissionModule emission = ps.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(100f); if ((Object)(object)((Component)ps).transform.parent != (Object)null) { ((Component)ps).transform.parent.localScale = new Vector3(3f, 1.5f, 3f); } ((Component)ps).transform.localPosition = new Vector3(0f, -5f, 0f); } } internal static void Reset() { DestroyHazeObject(); _summerHeatColorApplied = false; _hasDefaultHeatDistortionColor = false; } internal static void UpdateHazeState() { if (!((Object)(object)_hazeObject == (Object)null)) { bool flag = IsWorldHazeActive(); if (_hazeObject.activeSelf != flag) { _hazeObject.SetActive(flag); } } } internal static bool IsWorldHazeActive() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Invalid comparison between Unknown and I4 if (!Seasons.summerHeatEnabled.Value || !Seasons.summerHeatWorldHazeEnabled.Value || !SummerHeat.IsReady || !SummerHeat.IsSeasonHeatWindowActive || !SummerHeat.IsSunny || !SummerHeat.IsBiomeSupported) { return false; } if ((Object)(object)SummerHeat.Instance == (Object)null || !SummerHeat.Instance.IsDaytime()) { return false; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && (int)localPlayer.GetCurrentBiome() == 512) { return false; } return true; } internal static float GetVisualIntensity() { if (!IsPersonalVisualStateActive()) { return 0f; } bool flag = (Object)(object)SummerHeat.Instance == (Object)null || SummerHeat.Instance.IsDaytime(); float nightFactor = SummerHeatUtils.GetNightFactor(); float num = (flag ? 1f : nightFactor); float num2 = 100f * num; float num3 = SummerHeatUtils.ClampPercent(Seasons.summerHeatGreenThreshold.Value) * num; float num4 = Mathf.Max(0.1f, SummerHeatUtils.ClampPercent(Seasons.summerHeatGreenFadeWidth.Value) * num); float num5 = Mathf.Min(num2, num3 + num4); if (num2 <= num5) { return (SummerHeat.HeatPercent >= num2) ? 1f : 0f; } if (SummerHeat.HeatPercent <= num5) { return 0f; } return Mathf.InverseLerp(num5, num2, SummerHeat.HeatPercent); } internal static void ApplyCameraDistortion(HeatDistortImageEffect heatDistortImageEffect) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)heatDistortImageEffect == (Object)null) { return; } if (!_hasDefaultHeatDistortionColor) { _defaultHeatDistortionColor = heatDistortImageEffect.m_color; _hasDefaultHeatDistortionColor = true; } float visualIntensity = GetVisualIntensity(); if (visualIntensity <= 0f) { if (_summerHeatColorApplied) { heatDistortImageEffect.m_color = _defaultHeatDistortionColor; _summerHeatColorApplied = false; } return; } ((Behaviour)heatDistortImageEffect).enabled = true; heatDistortImageEffect.m_intensity = Mathf.Max(heatDistortImageEffect.m_intensity, visualIntensity); float num = Mathf.Max(1f, SummerHeatUtils.ClampPercent(Seasons.summerHeatMaxOverflow.Value)); float num2 = Mathf.Clamp01(SummerHeat.OverflowHeatPercent / num); Color defaultHeatDistortionColor = _defaultHeatDistortionColor; defaultHeatDistortionColor.a = Mathf.Lerp(_defaultHeatDistortionColor.a, 0.85f, num2); heatDistortImageEffect.m_color = defaultHeatDistortionColor; _summerHeatColorApplied = true; } private static bool IsPersonalVisualStateActive() { return Seasons.summerHeatEnabled.Value && Seasons.summerHeatPersonalDistortionEnabled.Value && SummerHeat.IsReady && SummerHeat.IsMechanicActive && SummerHeat.HeatFactor > 0f; } private static GameObject FindAshlandsHaze() { GameObject val = ((IEnumerable)ZoneSystem.instance.m_locationLists).FirstOrDefault((Func)((GameObject locList) => ((Object)locList).name == "_LocationList_Ashlands")); if ((Object)(object)val == (Object)null) { return null; } Transform obj = val.transform.Find("environment_effects/FollowPlayer/Ashlands_AshRain"); return (obj != null) ? ((Component)obj).gameObject : null; } private static void DestroyHazeObject() { if (!((Object)(object)_hazeObject == (Object)null)) { Object.Destroy((Object)(object)_hazeObject); _hazeObject = null; } } } [HarmonyPatch(typeof(ZoneSystem), "Start")] internal static class ZoneSystem_Start_SummerHeatVisuals { private static void Postfix(ZoneSystem __instance) { SummerHeatVisuals.Initialize(); SummerHeatVisuals.UpdateHazeState(); } } [HarmonyPatch(typeof(ZoneSystem), "OnDestroy")] internal static class ZoneSystem_OnDestroy_SummerHeatVisuals { private static void Prefix() { SummerHeatVisuals.Reset(); } } [HarmonyPatch(typeof(Character), "UpdateHeatEffects")] internal static class Character_UpdateHeatEffects_SummerHeatVisuals { private static void Postfix(Character __instance) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { SummerHeatVisuals.UpdateHazeState(); SummerHeatVisuals.ApplyCameraDistortion(GameCamera.instance?.m_heatDistortImageEffect); } } } internal class CustomConfigs { internal class ConfigurationManagerAttributes { [UsedImplicitly] public Action? CustomDrawer; [UsedImplicitly] public bool? ShowRangeAsPercent = false; } internal static object? configManager; internal static Type? configManagerStyles; internal static GUIStyle GetStyle(GUIStyle other) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown if (configManagerStyles == null) { return other; } FieldInfo fieldInfo = AccessTools.Field(configManagerStyles, "fontSize"); if (fieldInfo == null) { return other; } return new GUIStyle(other) { fontSize = (int)fieldInfo.GetValue(configManagerStyles) }; } internal static void Awake() { Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "ConfigurationManager"); Type type = assembly?.GetType("ConfigurationManager.ConfigurationManager"); configManager = ((type == null) ? null : Chainloader.ManagerObject.GetComponent(type)); configManagerStyles = assembly?.GetType("ConfigurationManager.ConfigurationManagerStyles"); } internal static Action DrawSeparatedStrings(string splitString) { return delegate(ConfigEntryBase cfg) { //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown bool valueOrDefault = cfg.Description.Tags.Select((object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : ((bool?)null)).FirstOrDefault((bool? v) => v.HasValue) == true; bool flag = false; GUILayout.BeginVertical(Array.Empty()); List list = new List(); List list2 = ((string)cfg.BoxedValue).Split(new string[1] { splitString }, StringSplitOptions.None).ToList(); for (int num = 0; num < list2.Count; num++) { GUILayout.BeginHorizontal(Array.Empty()); string text = list2[num]; string text2 = GUILayout.TextField(text, GetStyle(GUI.skin.textArea), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (text2 != text && !valueOrDefault) { flag = true; } if (GUILayout.Button("x", new GUIStyle(GetStyle(GUI.skin.button)) { fixedWidth = 21f }, Array.Empty()) && !valueOrDefault) { flag = true; } else { list.Add(text2); } if (GUILayout.Button("+", new GUIStyle(GetStyle(GUI.skin.button)) { fixedWidth = 21f }, Array.Empty()) && !valueOrDefault) { flag = true; list.Add(""); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); if (flag) { cfg.BoxedValue = string.Join(splitString, list); } }; } internal static Action DrawOrderedFixedStrings(string splitString) { return delegate(ConfigEntryBase cfg) { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown bool valueOrDefault = cfg.Description.Tags.Select((object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : ((bool?)null)).FirstOrDefault((bool? v) => v.HasValue) == true; bool flag = false; GUILayout.BeginVertical(Array.Empty()); string[] array = ((string)cfg.BoxedValue).Split(new string[1] { splitString }, StringSplitOptions.None).ToArray(); for (int num = 0; num < array.Length; num++) { GUILayout.BeginHorizontal(Array.Empty()); string text = array[num]; GUILayout.Label(text, GetStyle(GUI.skin.textArea), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (GUILayout.Button("ʌ", new GUIStyle(GetStyle(GUI.skin.button)) { fixedWidth = 21f }, Array.Empty()) && !valueOrDefault && (flag = num > 0)) { ref string reference = ref array[num]; ref string reference2 = ref array[num - 1]; string text2 = array[num - 1]; string text3 = array[num]; reference = text2; reference2 = text3; } if (GUILayout.Button("v", new GUIStyle(GetStyle(GUI.skin.button)) { fixedWidth = 21f }, Array.Empty()) && !valueOrDefault && (flag = num < array.Length - 1)) { ref string reference = ref array[num]; ref string reference3 = ref array[num + 1]; string text3 = array[num + 1]; string text2 = array[num]; reference = text3; reference3 = text2; } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); if (flag) { cfg.BoxedValue = string.Join(splitString, array); } }; } } internal static class CustomMusic { internal class MusicSettings { public float m_volume = 1f; public float m_fadeInTime = 3f; public bool m_alwaysFadeout = false; public bool m_loop = true; public bool m_resume = true; public bool m_enabled = true; public bool m_ambientMusic = true; } public const string subdirectory = "Custom music"; public static readonly Dictionary audioClips = new Dictionary(); public static readonly Dictionary clipSettings = new Dictionary(); internal static void SetupConfigWatcher() { string filter = "*.*"; FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(GetSubdirectory(), filter); fileSystemWatcher.Changed += UpdateClipOnChange; fileSystemWatcher.Created += UpdateClipOnChange; fileSystemWatcher.Renamed += UpdateClipOnChange; fileSystemWatcher.Deleted += UpdateClipOnChange; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; UpdateCustomMusic(); CheckMusicList(); SeasonEnvironment.ClearCachedObjects(); } internal static void CheckMusicList() { if (!Object.op_Implicit((Object)(object)MusicMan.instance)) { return; } foreach (KeyValuePair clip in audioClips) { (MusicMan.instance.m_music.Find((NamedMusic music) => music.m_name == clip.Key) ?? GetNewMusic(clip.Key)).m_clips = (AudioClip[])(object)new AudioClip[1] { clip.Value }; } MusicMan.instance.m_musicHashes.Clear(); foreach (NamedMusic item in MusicMan.instance.m_music) { if (clipSettings.TryGetValue(item.m_name, out var value)) { item.m_ambientMusic = value.m_ambientMusic; item.m_resume = value.m_resume; item.m_alwaysFadeout = value.m_alwaysFadeout; item.m_enabled = value.m_enabled; item.m_fadeInTime = value.m_fadeInTime; item.m_loop = value.m_loop; item.m_volume = value.m_volume; } if (item.m_enabled && item.m_clips.Length != 0 && (Object)(object)item.m_clips[0] != (Object)null) { MusicMan.instance.m_musicHashes[StringExtensionMethods.GetStableHashCode(item.m_name)] = item; } } } private static NamedMusic GetNewMusic(string name) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown MusicSettings musicSettings = GeneralExtensions.GetValueSafe(clipSettings, name) ?? new MusicSettings(); NamedMusic val = new NamedMusic { m_name = name, m_ambientMusic = musicSettings.m_ambientMusic, m_resume = musicSettings.m_resume, m_alwaysFadeout = musicSettings.m_alwaysFadeout, m_enabled = musicSettings.m_enabled, m_fadeInTime = musicSettings.m_fadeInTime, m_loop = musicSettings.m_loop, m_volume = musicSettings.m_volume }; MusicMan.instance.m_music.Add(val); return val; } private static string GetSubdirectory() { string text = Path.Combine(Seasons.configDirectory, "Custom music"); Directory.CreateDirectory(text); return text; } private static void UpdateCustomMusic() { string path = GetSubdirectory(); if (!Directory.Exists(path)) { return; } foreach (FileInfo item in from file in new DirectoryInfo(path).EnumerateFiles("*.*", SearchOption.AllDirectories) orderby file.Extension.ToLower() != ".json" select file) { UpdateFile(item.Name, item.FullName); } } private static void UpdateClipOnChange(object sender, FileSystemEventArgs eargs) { UpdateFile(eargs.Name, eargs.FullPath); if (eargs is RenamedEventArgs) { audioClips.Remove(Path.GetFileNameWithoutExtension((eargs as RenamedEventArgs).OldName)); } CheckMusicList(); SeasonEnvironment.ClearCachedObjects(); } private static void UpdateFile(string fileName, string filePath) { if (Path.GetExtension(fileName).Equals(".json", StringComparison.OrdinalIgnoreCase)) { UpdateSettings(Path.GetFileNameWithoutExtension(fileName), filePath); } else { UpdateClip(Path.GetFileNameWithoutExtension(fileName), filePath); } } private static void UpdateClip(string clipName, string fileName) { bool flag = audioClips.Remove(clipName); if (TryGetAudioClip(fileName, out var audioClip)) { audioClips.Add(clipName, audioClip); Seasons.LogInfo("Custom music " + (flag ? "updated" : "added") + ": " + clipName); } } private static void UpdateSettings(string clipName, string fileName) { bool flag = clipSettings.Remove(clipName); if (TryGetMusicSettings(fileName, out var musicSettings)) { clipSettings.Add(clipName, musicSettings); Seasons.LogInfo("Custom music settings " + (flag ? "updated" : "added") + ": " + clipName); } } internal static bool TryGetAudioClip(string path, out AudioClip audioClip) { audioClip = null; string text = "file:///" + path.Replace("\\", "/"); UnityWebRequest audioClip2 = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)0); if (audioClip2 == null) { return false; } audioClip2.SendWebRequest(); while (!audioClip2.isDone) { } if (audioClip2.error != null) { Seasons.LogWarning("Failed to load audio from " + path + ": " + audioClip2.error); return false; } DownloadHandler downloadHandler = audioClip2.downloadHandler; DownloadHandler obj = ((downloadHandler is DownloadHandlerAudioClip) ? downloadHandler : null); audioClip = ((obj != null) ? ((DownloadHandlerAudioClip)obj).audioClip : null); if (Object.op_Implicit((Object)(object)audioClip)) { ((Object)audioClip).name = Path.GetFileNameWithoutExtension(path); return true; } return false; } internal static bool TryGetMusicSettings(string path, out MusicSettings musicSettings) { musicSettings = null; if (!File.Exists(path)) { return false; } try { musicSettings = JsonUtility.FromJson(File.ReadAllText(path)); } catch (Exception ex) { Seasons.LogWarning("Error reading file (" + path + ")! Error: " + ex.Message); return false; } return true; } } internal class CustomPrefabs { [HarmonyPatch(typeof(ZNetView), "Awake")] public static class ZNetView_Awake_AddPrefab { [HarmonyPriority(800)] private static bool Prefix() { return !prefabInit; } } [HarmonyPatch(typeof(ZSyncTransform), "Awake")] public static class ZSyncTransform_Awake_AddPrefab { [HarmonyPriority(800)] private static bool Prefix() { return !prefabInit; } } [HarmonyPatch(typeof(ZSyncTransform), "OnEnable")] public static class ZSyncTransform_OnEnable_AddPrefab { [HarmonyPriority(800)] private static bool Prefix() { return !prefabInit; } } [HarmonyPatch(typeof(ItemDrop), "Awake")] public static class ItemDrop_Awake_AddPrefab { [HarmonyPriority(800)] private static bool Prefix() { return !prefabInit; } } [HarmonyPatch(typeof(ItemDrop), "Start")] public static class ItemDrop_Start_AddPrefab { [HarmonyPriority(800)] private static bool Prefix() { return !prefabInit; } } private const string c_rootObjectName = "_shudnalRoot"; private const string c_rootPrefabsName = "Prefabs"; private static GameObject rootObject; private static GameObject rootPrefabs; public static bool prefabInit; private static void InitRootObject() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown if ((Object)(object)rootObject == (Object)null) { rootObject = (GameObject)(((object)GameObject.Find("_shudnalRoot")) ?? ((object)new GameObject("_shudnalRoot"))); } Object.DontDestroyOnLoad((Object)(object)rootObject); if ((Object)(object)rootPrefabs == (Object)null) { Transform obj = rootObject.transform.Find("Prefabs"); rootPrefabs = ((obj != null) ? ((Component)obj).gameObject : null); if ((Object)(object)rootPrefabs == (Object)null) { rootPrefabs = new GameObject("Prefabs"); rootPrefabs.transform.SetParent(rootObject.transform, false); rootPrefabs.SetActive(false); } } } internal static GameObject InitPrefabClone(GameObject prefabToClone, string prefabName) { InitRootObject(); prefabInit = true; GameObject val = Object.Instantiate(prefabToClone, rootPrefabs.transform, false); prefabInit = false; ((Object)val).name = prefabName; return val; } } internal class CustomTextures { public const string texturesSubdirectory = "Custom textures"; public const string defaultsSubdirectory = "Defaults"; public const string versionFileName = "version"; public static readonly Dictionary>> textures = new Dictionary>>(); public static Dictionary> seasonVariantsFileNames; public static void SetupConfigWatcher() { string filter = "*.png"; FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(GetSubdirectory(), filter); fileSystemWatcher.Changed += UpdateTexturesOnChange; fileSystemWatcher.Created += UpdateTexturesOnChange; fileSystemWatcher.Renamed += UpdateTexturesOnChange; fileSystemWatcher.Deleted += UpdateTexturesOnChange; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; UpdateTexturesOnChange(); } public static void UpdateTexturesOnChange(object sender = null, FileSystemEventArgs eargs = null) { UpdateTextures(); PrefabVariantController.MaterialVariants.UpdateSeasonalMaterials(); PrefabVariantController.UpdatePrefabColors(); ClutterVariantController.Instance?.UpdateColors(); } public static void UpdateTextures() { foreach (KeyValuePair>> texture in textures) { foreach (KeyValuePair> item in texture.Value) { foreach (KeyValuePair item2 in item.Value) { Object.Destroy((Object)(object)item2.Value); } } } textures.Clear(); if (Seasons.customTextures.Value) { LoadCustomTextures(GetDefaultsSubdirectory()); LoadCustomTextures(GetSubdirectory()); if (textures.Count > 0) { Seasons.LogInfo($"Loaded {textures.Count} custom textures."); } } } public static bool HaveCustomTexture(string textureName, Seasons.Season season, int variant, TextureProperties properties, out Texture2D texture) { texture = null; if (textureName == null) { return false; } Dictionary> value; Dictionary value2; bool flag = textures.TryGetValue(textureName, out value) && value.TryGetValue(season, out value2) && value2.TryGetValue(variant, out texture) && (Object)(object)texture != (Object)null; if (flag && ((Texture)texture).isReadable) { Color32[] pixels = texture.GetPixels32(); if (pixels.Length != properties.width * properties.height) { properties.width = ((Texture)texture).width; properties.height = ((Texture)texture).height; properties.mipmapCount = Math.Min(Mathf.FloorToInt(Mathf.Log((float)Math.Min(properties.width, properties.height), 2f)), properties.mipmapCount); } Object.Destroy((Object)(object)texture); texture = properties.CreateTexture(); texture.SetPixels32(pixels); texture.Apply(true, true); textures[textureName][season][variant] = texture; } return flag; } public static void LoadCustomTextures(string path) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown if (!Directory.Exists(path)) { return; } DirectoryInfo[] directories = new DirectoryInfo(path).GetDirectories(); foreach (DirectoryInfo directoryInfo in directories) { if (directoryInfo.Name == "version" || directoryInfo.Name == "Defaults") { continue; } string name = directoryInfo.Name; textures.Remove(name); FileInfo[] files = directoryInfo.GetFiles(); foreach (FileInfo fileInfo in files) { if (!TryGetSeasonVariant(fileInfo.Name, out var season, out var variant)) { continue; } Texture2D val = new Texture2D(2, 2); if (!ImageConversion.LoadImage(val, File.ReadAllBytes(fileInfo.FullName))) { Object.Destroy((Object)(object)val); continue; } ((Object)val).name = name; if (!textures.ContainsKey(name)) { textures.Add(name, new Dictionary>()); } if (!textures[name].ContainsKey(season)) { textures[name].Add(season, new Dictionary()); } textures[name][season][variant] = val; } } } public static void SaveDefaults() { string text = GetDefaultsSubdirectory(); if (Directory.Exists(text)) { string text2 = Directory.GetFiles(text, "version").FirstOrDefault(); if (text2 != null && File.ReadAllText(text2) == "1.8.2") { return; } Directory.Delete(text, recursive: true); } Directory.CreateDirectory(text); Assembly executingAssembly = Assembly.GetExecutingAssembly(); string separator = ".Textures."; foreach (string item in from str in executingAssembly.GetManifestResourceNames() where str.IndexOf(separator) != -1 select str) { string text3 = item.Substring(item.IndexOf(separator) + separator.Length); int num = text3.IndexOf('.'); if (num != -1) { string path = text3.Substring(0, num); string text4 = text3.Substring(num + 1); if (TryGetSeasonVariant(text4, out var _, out var _)) { Stream manifestResourceStream = executingAssembly.GetManifestResourceStream(item); byte[] array = new byte[manifestResourceStream.Length]; manifestResourceStream.Read(array, 0, array.Length); File.WriteAllBytes(Path.Combine(Directory.CreateDirectory(Path.Combine(text, path)).FullName, text4), array); } } } File.WriteAllText(Path.Combine(text, "version"), "1.8.2"); } public static string GetSubdirectory() { string text = Path.Combine(Seasons.configDirectory, "Custom textures"); Directory.CreateDirectory(text); return text; } public static string GetDefaultsSubdirectory() { return Path.Combine(GetSubdirectory(), "Defaults"); } public static bool TryGetSeasonVariant(string filename, out Seasons.Season season, out int variant) { if (seasonVariantsFileNames == null) { seasonVariantsFileNames = new Dictionary>(); foreach (Seasons.Season value in Enum.GetValues(typeof(Seasons.Season))) { for (int i = 0; i < 4; i++) { seasonVariantsFileNames[CachedData.SeasonFileName(value, i)] = Tuple.Create(value, i); } } } season = Seasons.Season.Spring; variant = 0; if (!seasonVariantsFileNames.ContainsKey(filename)) { return false; } season = seasonVariantsFileNames[filename].Item1; variant = seasonVariantsFileNames[filename].Item2; return true; } } internal sealed class DictionaryContentComparer : IEqualityComparer> { public static readonly DictionaryContentComparer Instance = new DictionaryContentComparer(); public bool Equals(Dictionary first, Dictionary second) { if (first == second) { return true; } if (first == null || second == null || first.Count != second.Count) { return false; } EqualityComparer equalityComparer = EqualityComparer.Default; foreach (KeyValuePair item in first) { if (!second.TryGetValue(item.Key, out var value) || !equalityComparer.Equals(item.Value, value)) { return false; } } return true; } public int GetHashCode(Dictionary dictionary) { return dictionary?.Count ?? 0; } } internal static class CustomSyncedValuesSynchronizer { private enum AssignmentMode { Default, IfChanged, AndNotify } private sealed class PendingAssignment { public CustomSyncedValueBase Target; public Action AssignDefault; public Action AssignIfChanged; public Action AssignAndNotify; public AssignmentMode Mode; public long Sequence; } private static readonly Dictionary pendingAssignments = new Dictionary(); private static readonly WaitWhile waitForTextureCaching = new WaitWhile((Func)(() => TextureCachingController.InProcess)); private static bool coordinatorRunning; private static long nextSequence; public static void AssignValueSafe(this CustomSyncedValue syncedValue, T value) { QueueAssignment((CustomSyncedValueBase)(object)syncedValue, delegate { syncedValue.AssignLocalValue(value); }, delegate { syncedValue.AssignLocalValueIfChanged(value); }, delegate { syncedValue.AssignLocalValueAndNotify(value); }, AssignmentMode.Default); } public static void AssignValueSafe(this CustomSyncedValue syncedValue, Func function) { QueueAssignment((CustomSyncedValueBase)(object)syncedValue, delegate { syncedValue.AssignLocalValue(function()); }, delegate { syncedValue.AssignLocalValueIfChanged(function()); }, delegate { syncedValue.AssignLocalValueAndNotify(function()); }, AssignmentMode.Default); } public static void AssignValueSafeIfChanged(this CustomSyncedValue syncedValue, T value) { QueueAssignment((CustomSyncedValueBase)(object)syncedValue, delegate { syncedValue.AssignLocalValue(value); }, delegate { syncedValue.AssignLocalValueIfChanged(value); }, delegate { syncedValue.AssignLocalValueAndNotify(value); }, AssignmentMode.IfChanged); } public static void AssignValueSafeIfChanged(this CustomSyncedValue syncedValue, Func function) { QueueAssignment((CustomSyncedValueBase)(object)syncedValue, delegate { syncedValue.AssignLocalValue(function()); }, delegate { syncedValue.AssignLocalValueIfChanged(function()); }, delegate { syncedValue.AssignLocalValueAndNotify(function()); }, AssignmentMode.IfChanged); } public static void AssignValueSafeAndNotify(this CustomSyncedValue syncedValue, T value) { QueueAssignment((CustomSyncedValueBase)(object)syncedValue, delegate { syncedValue.AssignLocalValue(value); }, delegate { syncedValue.AssignLocalValueIfChanged(value); }, delegate { syncedValue.AssignLocalValueAndNotify(value); }, AssignmentMode.AndNotify); } public static void AssignValueSafeAndNotify(this CustomSyncedValue syncedValue, Func function) { QueueAssignment((CustomSyncedValueBase)(object)syncedValue, delegate { syncedValue.AssignLocalValue(function()); }, delegate { syncedValue.AssignLocalValueIfChanged(function()); }, delegate { syncedValue.AssignLocalValueAndNotify(function()); }, AssignmentMode.AndNotify); } private static void QueueAssignment(CustomSyncedValueBase syncedValue, Action assignDefault, Action assignIfChanged, Action assignAndNotify, AssignmentMode mode) { if (!TextureCachingController.InProcess && pendingAssignments.Count == 0 && !coordinatorRunning) { ApplyAssignment(assignDefault, assignIfChanged, assignAndNotify, mode); return; } if (pendingAssignments.TryGetValue(syncedValue, out var value)) { value.AssignDefault = assignDefault; value.AssignIfChanged = assignIfChanged; value.AssignAndNotify = assignAndNotify; value.Mode = MergeModes(value.Mode, mode); } else { pendingAssignments.Add(syncedValue, new PendingAssignment { Target = syncedValue, AssignDefault = assignDefault, AssignIfChanged = assignIfChanged, AssignAndNotify = assignAndNotify, Mode = mode, Sequence = nextSequence++ }); } if (!coordinatorRunning) { coordinatorRunning = true; ((MonoBehaviour)Seasons.instance).StartCoroutine(AssignmentCoordinator()); } } private static AssignmentMode MergeModes(AssignmentMode current, AssignmentMode next) { return (current == AssignmentMode.AndNotify || next == AssignmentMode.AndNotify) ? AssignmentMode.AndNotify : next; } private static void ApplyAssignment(Action assignDefault, Action assignIfChanged, Action assignAndNotify, AssignmentMode mode) { switch (mode) { case AssignmentMode.AndNotify: assignAndNotify(); break; case AssignmentMode.IfChanged: assignIfChanged(); break; default: assignDefault(); break; } } private static IEnumerator AssignmentCoordinator() { try { while (pendingAssignments.Count > 0) { yield return waitForTextureCaching; PendingAssignment[] assignments = (from pendingAssignment in pendingAssignments.Values orderby pendingAssignment.Target.Priority descending, pendingAssignment.Sequence select pendingAssignment).ToArray(); pendingAssignments.Clear(); PendingAssignment[] array = assignments; foreach (PendingAssignment assignment in array) { ApplyAssignment(assignment.AssignDefault, assignment.AssignIfChanged, assignment.AssignAndNotify, assignment.Mode); } } } finally { coordinatorRunning = false; if (pendingAssignments.Count > 0) { coordinatorRunning = true; ((MonoBehaviour)Seasons.instance).StartCoroutine(AssignmentCoordinator()); } } } } public class IceFloeClimb : MonoBehaviour, Hoverable, Interactable { public float m_useDistance = 3f; public float m_radius = 4f; public void Start() { ZNetView component = ((Component)this).GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component.m_body != (Object)null) { float num = component.GetZDO().GetFloat(SeasonsVars.s_iceFloeMass, 0f); if (num != 0f) { component.m_body.mass = num; } } } public bool Interact(Humanoid character, bool hold, bool alt) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (hold) { return false; } if (!InUseDistance(character)) { return false; } ((Component)character).transform.position = Vector3.Lerp(((Component)character).transform.position, ((Component)this).transform.position, 0.35f) + Vector3.up; Physics.SyncTransforms(); return false; } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetHoverText() { if (!InUseDistance((Humanoid)(object)Player.m_localPlayer)) { return ""; } return "[$KEY_Use] $seasons_ice_floe_climb".Localize(); } public string GetHoverName() { return ""; } public bool InUseDistance(Humanoid human) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (((Component)this).transform.position.y - ((Component)human).transform.position.y < 0.5f) { return false; } Vector3 val = ((Component)human).transform.position - ((Component)this).transform.position; val.y = 0f; float num = Mathf.Max(0.0001f, ((Component)this).transform.lossyScale.x); float num2 = Mathf.Max(0.0001f, ((Component)this).transform.lossyScale.z); float num3 = Mathf.Sqrt(val.x * val.x / (num * num) + val.z * val.z / (num2 * num2)); return m_radius < num3 && num3 < m_radius + m_useDistance; } } public class MinimapVariantController : MonoBehaviour { private Minimap m_minimap; private static MinimapVariantController m_instance; private bool m_initialized = false; private Color32[] m_mapTexture; private Color32[] m_mapWinterTexture; private Texture2D m_forestTex; private bool m_isWinter = false; public static MinimapVariantController instance => m_instance; private void Awake() { m_instance = this; m_minimap = Minimap.instance; } private void Start() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown Texture texture = m_minimap.m_mapLargeShader.GetTexture("_ForestTex"); m_forestTex = new Texture2D(texture.width, texture.height, texture.graphicsFormat, (TextureCreationFlags)0); Graphics.CopyTexture(texture, (Texture)(object)m_forestTex); ((MonoBehaviour)this).StartCoroutine(GenerateWinterWorldMap()); } private void OnDestroy() { RevertTextures(); m_instance = null; } public void RevertTextures() { if (m_initialized) { SetMapTextures(m_isWinter, m_forestTex); } } public void UpdateColors() { if (m_initialized) { if (!Seasons.controlMinimap.Value) { RevertTextures(); return; } Seasons.Season currentSeason = Seasons.seasonState.GetCurrentSeason(); bool winterChanged = m_isWinter != (m_isWinter = currentSeason == Seasons.Season.Winter); SetMapTextures(winterChanged, GetSeasonalForestTex(currentSeason)); } } public Texture2D GetSeasonalForestTex(Seasons.Season season) { if (1 == 0) { } Texture2D result = (Texture2D)(season switch { Seasons.Season.Spring => m_forestTex, Seasons.Season.Summer => Seasons.Minimap_Summer_ForestTex, Seasons.Season.Fall => Seasons.Minimap_Fall_ForestTex, Seasons.Season.Winter => Seasons.Minimap_Winter_ForestTex, _ => m_forestTex, }); if (1 == 0) { } return result; } private void SetMapTextures(bool winterChanged, Texture2D forestTex) { try { if (winterChanged) { m_minimap.m_mapTexture.SetPixels32(m_isWinter ? m_mapWinterTexture : m_mapTexture); m_minimap.m_mapTexture.Apply(); MarketplaceCompat.UpdateMap(); } } catch (Exception ex) { Seasons.LogWarning(string.Format("Error applying {0}map texture length {1} to minimap texture length {2}:\n{3}", m_isWinter ? "winter " : "", (m_isWinter ? m_mapWinterTexture : m_mapTexture).Length, ((Texture)m_minimap.m_mapTexture).height * ((Texture)m_minimap.m_mapTexture).width, ex)); } m_minimap.m_mapLargeShader.SetTexture("_ForestTex", (Texture)(object)forestTex); m_minimap.m_mapSmallShader.SetTexture("_ForestTex", (Texture)(object)forestTex); } public IEnumerator GenerateWinterWorldMap() { int num = m_minimap.m_textureSize / 2; float num2 = m_minimap.m_pixelSize / 2f; m_mapWinterTexture = (Color32[])(object)new Color32[m_minimap.m_textureSize * m_minimap.m_textureSize]; m_mapTexture = (Color32[])(object)new Color32[m_minimap.m_textureSize * m_minimap.m_textureSize]; yield return (object)new WaitUntil((Func)(() => WorldGenerator.instance != null)); Stopwatch stopwatch = Stopwatch.StartNew(); Thread internalThread = new Thread((ThreadStart)delegate { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < m_minimap.m_textureSize; i++) { for (int j = 0; j < m_minimap.m_textureSize; j++) { float num3 = (float)(j - num) * m_minimap.m_pixelSize + num2; float num4 = (float)(i - num) * m_minimap.m_pixelSize + num2; Biome biome = WorldGenerator.instance.GetBiome(num3, num4, 0.02f, false); m_mapWinterTexture[i * m_minimap.m_textureSize + j] = Color32.op_Implicit(GetWinterPixelColor(biome)); m_mapTexture[i * m_minimap.m_textureSize + j] = Color32.op_Implicit(Minimap.instance.GetPixelColor(biome)); } } }); internalThread.Start(); yield return (object)new WaitWhile((Func)(() => internalThread.IsAlive)); m_initialized = true; Seasons.LogInfo($"Minimap variant controller initialized in {stopwatch.Elapsed.TotalSeconds,-4:F2} seconds"); UpdateColors(); } public static Color GetWinterPixelColor(Biome biome) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (SeasonState.seasonBiomeSettings.SeasonalWinterMapColors.TryGetValue(biome, out var value)) { return value; } return Object.op_Implicit((Object)(object)Minimap.instance) ? Minimap.instance.GetPixelColor(biome) : Color.white; } } [HarmonyPatch(typeof(Minimap), "Start")] public static class Minimap_Start_MinimapContollerInit { [HarmonyPriority(0)] private static void Postfix(Minimap __instance) { if (Seasons.UseTextureControllers()) { ((Component)((Component)__instance).transform).gameObject.AddComponent(); } } } [HarmonyPatch(typeof(Minimap), "GenerateWorldMap")] public static class Minimap_GenerateWorldMap_MinimapContollerInit { private static void Postfix() { if (Seasons.UseTextureControllers()) { MinimapVariantController.instance.UpdateColors(); } } } [Serializable] public class SeasonBiomeEnvironments { [Serializable] public class SeasonBiomeEnvironment { public class EnvironmentAdd { public string m_name; public EnvEntry m_environment; public EnvironmentAdd(string name, EnvEntry environment) { m_name = name; m_environment = environment; } } [Serializable] public class EnvironmentRemove { public string m_name; public string m_environment; public EnvironmentRemove(string name, string environment) { m_name = name; m_environment = environment; } } [Serializable] public class EnvironmentReplace { public string m_environment; public string replace_to; public EnvironmentReplace(string environment, string replaceTo) { m_environment = environment; replace_to = replaceTo; } } [Serializable] public class EnvironmentReplacePair { public string m_environment; public string replace_to; } public List add = new List(); public List remove = new List(); public List replace = new List(); } public SeasonBiomeEnvironment Spring = new SeasonBiomeEnvironment(); public SeasonBiomeEnvironment Summer = new SeasonBiomeEnvironment(); public SeasonBiomeEnvironment Fall = new SeasonBiomeEnvironment(); public SeasonBiomeEnvironment Winter = new SeasonBiomeEnvironment(); public SeasonBiomeEnvironments(bool loadDefaults = false) { //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Expected O, but got Unknown //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Expected O, but got Unknown //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Expected O, but got Unknown //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Expected O, but got Unknown //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Expected O, but got Unknown //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Expected O, but got Unknown //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Expected O, but got Unknown //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Expected O, but got Unknown //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Expected O, but got Unknown //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Expected O, but got Unknown //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Expected O, but got Unknown //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Expected O, but got Unknown //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Expected O, but got Unknown //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04fd: Expected O, but got Unknown //IL_0513: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Expected O, but got Unknown //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_054e: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Expected O, but got Unknown //IL_057f: Unknown result type (might be due to invalid IL or missing references) //IL_0584: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_059f: Expected O, but got Unknown //IL_05b5: Unknown result type (might be due to invalid IL or missing references) //IL_05ba: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Expected O, but got Unknown //IL_074b: Unknown result type (might be due to invalid IL or missing references) //IL_0750: Unknown result type (might be due to invalid IL or missing references) //IL_075b: Unknown result type (might be due to invalid IL or missing references) //IL_076b: Expected O, but got Unknown //IL_0781: Unknown result type (might be due to invalid IL or missing references) //IL_0786: Unknown result type (might be due to invalid IL or missing references) //IL_0791: Unknown result type (might be due to invalid IL or missing references) //IL_07a1: Expected O, but got Unknown //IL_07b7: Unknown result type (might be due to invalid IL or missing references) //IL_07bc: Unknown result type (might be due to invalid IL or missing references) //IL_07c7: Unknown result type (might be due to invalid IL or missing references) //IL_07d7: Expected O, but got Unknown //IL_07ed: Unknown result type (might be due to invalid IL or missing references) //IL_07f2: Unknown result type (might be due to invalid IL or missing references) //IL_07fd: Unknown result type (might be due to invalid IL or missing references) //IL_080d: Expected O, but got Unknown //IL_0823: Unknown result type (might be due to invalid IL or missing references) //IL_0828: Unknown result type (might be due to invalid IL or missing references) //IL_0833: Unknown result type (might be due to invalid IL or missing references) //IL_0843: Expected O, but got Unknown if (loadDefaults) { Summer.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Clear", "Clear Summer")); Summer.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Misty", "Misty Summer")); Summer.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("DeepForest Mist", "DeepForest Mist Summer")); Summer.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Mistlands_clear", "Mistlands_clear Summer")); Summer.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Heath clear", "Heath clear Summer")); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Meadows", new EnvEntry { m_environment = "Heath clear", m_weight = 2f })); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Black forest", new EnvEntry { m_environment = "LightRain", m_weight = 0.1f })); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Black forest", new EnvEntry { m_environment = "Clear", m_weight = 0.2f })); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Swamp", new EnvEntry { m_environment = "SwampRain Summer", m_weight = 0.1f })); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Swamp", new EnvEntry { m_environment = "Swamp Summer", m_weight = 0.1f })); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Mountain", new EnvEntry { m_environment = "Twilight_Clear", m_weight = 1f })); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Mountain", new EnvEntry { m_environment = "Twilight_Snow", m_weight = 1f })); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Plains", new EnvEntry { m_environment = "ThunderStorm", m_weight = 0.1f })); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Ocean", new EnvEntry { m_environment = "Heath clear", m_weight = 1f })); Summer.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Mistlands", new EnvEntry { m_environment = "Heath clear", m_weight = 0.5f })); Fall.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("ThunderStorm", "ThunderStorm Fall")); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Meadows", new EnvEntry { m_environment = "DeepForest Mist", m_weight = 0.2f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Meadows", new EnvEntry { m_environment = "SwampRain Fall", m_weight = 0.2f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Black forest", new EnvEntry { m_environment = "LightRain", m_weight = 0.1f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Black forest", new EnvEntry { m_environment = "SwampRain Fall", m_weight = 0.1f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Swamp", new EnvEntry { m_environment = "ThunderStorm", m_weight = 0.1f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Mountain", new EnvEntry { m_environment = "Twilight_SnowStorm", m_weight = 0.5f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Plains", new EnvEntry { m_environment = "Rain", m_weight = 0.4f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Plains", new EnvEntry { m_environment = "ThunderStorm", m_weight = 0.2f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Plains", new EnvEntry { m_environment = "SwampRain Fall", m_weight = 0.1f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Ocean", new EnvEntry { m_environment = "SwampRain Fall", m_weight = 0.1f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Ocean", new EnvEntry { m_environment = "DeepForest Mist", m_weight = 0.1f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Mistlands", new EnvEntry { m_environment = "SwampRain Fall", m_weight = 0.1f })); Fall.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Mistlands", new EnvEntry { m_environment = "DeepForest Mist", m_weight = 0.1f })); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Rain", "Rain Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("LightRain", "LightRain Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("ThunderStorm", "ThunderStorm Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Clear", "Clear Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Misty", "Misty Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("DeepForest Mist", "DeepForest Mist Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("SwampRain", "SwampRain Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Mistlands_clear", "Mistlands_clear Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Mistlands_rain", "Mistlands_rain Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Mistlands_thunder", "Mistlands_thunder Winter")); Winter.replace.Add(new SeasonBiomeEnvironment.EnvironmentReplace("Heath clear", "Heath clear Winter")); Winter.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Mountain", new EnvEntry { m_environment = "Twilight_SnowStorm", m_weight = 1f })); Winter.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Plains", new EnvEntry { m_environment = "Snow", m_weight = 0.5f })); Winter.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Ocean", new EnvEntry { m_environment = "Darklands_dark Winter", m_weight = 0.1f })); Winter.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Mistlands", new EnvEntry { m_environment = "Twilight_Snow", m_weight = 0.1f })); Winter.add.Add(new SeasonBiomeEnvironment.EnvironmentAdd("Mistlands", new EnvEntry { m_environment = "Twilight_SnowStorm", m_weight = 0.1f })); } } public SeasonBiomeEnvironment GetSeasonBiomeEnvironment(Seasons.Season season) { if (1 == 0) { } SeasonBiomeEnvironment result = season switch { Seasons.Season.Spring => Spring, Seasons.Season.Summer => Summer, Seasons.Season.Fall => Fall, Seasons.Season.Winter => Winter, _ => new SeasonBiomeEnvironment(), }; if (1 == 0) { } return result; } } [Serializable] public class SeasonBiomeSettings { [Serializable] public class SeasonalBiomeColors { public string biome; public string spring; public string summer; public string fall; public string winter; public Biome GetBiome() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) return ParseBiome(biome); } public Dictionary GetSeasonalOverride() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); if (!Utility.IsNullOrWhiteSpace(spring)) { dictionary.Add(Seasons.Season.Spring, ParseBiome(spring)); } if (!Utility.IsNullOrWhiteSpace(summer)) { dictionary.Add(Seasons.Season.Summer, ParseBiome(summer)); } if (!Utility.IsNullOrWhiteSpace(fall)) { dictionary.Add(Seasons.Season.Fall, ParseBiome(fall)); } if (!Utility.IsNullOrWhiteSpace(winter)) { dictionary.Add(Seasons.Season.Winter, ParseBiome(winter)); } return dictionary; } } public static Color s_meadowsColor = new Color(0.573f, 0.655f, 0.361f); public static Color s_blackforestColor = new Color(0.42f, 0.455f, 0.247f); public static Color s_heathColor = new Color(0.906f, 0.671f, 0.47f); public static Color s_swampColor = new Color(0.639f, 0.447f, 0.345f); public static Color s_mistlandsColor = new Color(0.2f, 0.2f, 0.2f); [NonSerialized] private Dictionary> _seasonalBiomeColorOverride; [NonSerialized] private Dictionary _seasonalWinterMapColors; [NonSerialized] private static readonly Dictionary s_winterColors = new Dictionary(); [NonSerialized] private static readonly Dictionary s_nameToBiome = new Dictionary(); public List seasonalGroundColors = new List(); public Dictionary winterMapColors = new Dictionary(); [JsonIgnore] internal Dictionary> SeasonalBiomeColorOverride { get { if (_seasonalBiomeColorOverride == null) { ParseSeasonalGroundColors(); } return _seasonalBiomeColorOverride; } } [JsonIgnore] internal Dictionary SeasonalWinterMapColors { get { if (_seasonalWinterMapColors == null) { ParseWinterMapColors(); } return _seasonalWinterMapColors; } } public SeasonBiomeSettings(bool loadDefaults = false) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) if (loadDefaults) { s_nameToBiome.Clear(); seasonalGroundColors.Add(new SeasonalBiomeColors { biome = ((object)(Biome)1/*cast due to .constrained prefix*/).ToString(), fall = ((object)(Biome)16/*cast due to .constrained prefix*/).ToString(), winter = ((object)(Biome)4/*cast due to .constrained prefix*/).ToString() }); seasonalGroundColors.Add(new SeasonalBiomeColors { biome = ((object)(Biome)8/*cast due to .constrained prefix*/).ToString(), fall = ((object)(Biome)2/*cast due to .constrained prefix*/).ToString(), winter = ((object)(Biome)4/*cast due to .constrained prefix*/).ToString() }); seasonalGroundColors.Add(new SeasonalBiomeColors { biome = ((object)(Biome)16/*cast due to .constrained prefix*/).ToString(), spring = ((object)(Biome)1/*cast due to .constrained prefix*/).ToString(), winter = ((object)(Biome)4/*cast due to .constrained prefix*/).ToString() }); seasonalGroundColors.Add(new SeasonalBiomeColors { biome = ((object)(Biome)512/*cast due to .constrained prefix*/).ToString(), winter = ((object)(Biome)4/*cast due to .constrained prefix*/).ToString() }); seasonalGroundColors.Add(new SeasonalBiomeColors { biome = ((object)(Biome)2/*cast due to .constrained prefix*/).ToString(), winter = ((object)(Biome)4/*cast due to .constrained prefix*/).ToString() }); winterMapColors[((object)(Biome)1/*cast due to .constrained prefix*/).ToString()] = ToHexRGBA(GetWinterColor(Object.op_Implicit((Object)(object)Minimap.instance) ? Minimap.instance.m_meadowsColor : s_meadowsColor)); winterMapColors[((object)(Biome)8/*cast due to .constrained prefix*/).ToString()] = ToHexRGBA(GetWinterColor(Object.op_Implicit((Object)(object)Minimap.instance) ? Minimap.instance.m_blackforestColor : s_blackforestColor)); winterMapColors[((object)(Biome)16/*cast due to .constrained prefix*/).ToString()] = ToHexRGBA(GetWinterColor(Object.op_Implicit((Object)(object)Minimap.instance) ? Minimap.instance.m_heathColor : s_heathColor)); winterMapColors[((object)(Biome)2/*cast due to .constrained prefix*/).ToString()] = ToHexRGBA(GetWinterColor(Object.op_Implicit((Object)(object)Minimap.instance) ? Minimap.instance.m_swampColor : s_swampColor)); winterMapColors[((object)(Biome)512/*cast due to .constrained prefix*/).ToString()] = ToHexRGBA(GetWinterColor(Object.op_Implicit((Object)(object)Minimap.instance) ? Minimap.instance.m_mistlandsColor : s_mistlandsColor)); } } private void ParseSeasonalGroundColors() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) _seasonalBiomeColorOverride = new Dictionary>(); foreach (SeasonalBiomeColors seasonalGroundColor in seasonalGroundColors) { _seasonalBiomeColorOverride[seasonalGroundColor.GetBiome()] = seasonalGroundColor.GetSeasonalOverride(); } } private void ParseWinterMapColors() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) _seasonalWinterMapColors = new Dictionary(); Color value = default(Color); foreach (KeyValuePair winterMapColor in winterMapColors) { if (ColorUtility.TryParseHtmlString(winterMapColor.Value, ref value)) { _seasonalWinterMapColors[ParseBiome(winterMapColor.Key)] = value; } } } private static Biome ParseBiome(string biomeName) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) if (s_nameToBiome.Count == 0) { foreach (Biome value3 in Enum.GetValues(typeof(Biome))) { s_nameToBiome[((object)value3/*cast due to .constrained prefix*/).ToString().ToLowerInvariant()] = value3; } } if (s_nameToBiome.TryGetValue(biomeName.ToLowerInvariant(), out var value2)) { return value2; } Biome result; int result2; return (Biome)((!Enum.TryParse(biomeName, out result)) ? (int.TryParse(biomeName, out result2) ? result2 : 0) : ((int)result)); } private static Color GetWinterColor(Color color) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) if (!s_winterColors.ContainsKey(color)) { Color val = default(Color); ((Color)(ref val))..ctor(0.98f, 0.98f, 1f, color.a); s_winterColors[color] = new HSLColor(Color.Lerp(color, val, 0.6f)).ToRGBA(); } return s_winterColors[color]; } private static string ToHexRGBA(Color color) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return "#" + ColorUtility.ToHtmlStringRGBA(color); } } [Serializable] public class SeasonClutterSettings { [Serializable] public class SeasonalClutter { public string clutterName; public bool spring; public bool summer; public bool fall; public bool winter; public bool GetSeasonState(Seasons.Season season) { if (1 == 0) { } bool result = season switch { Seasons.Season.Spring => spring, Seasons.Season.Summer => summer, Seasons.Season.Fall => fall, Seasons.Season.Winter => winter, _ => false, }; if (1 == 0) { } return result; } } public List seasonalClutters = new List(); public SeasonClutterSettings(bool loadDefaults = false) { if (loadDefaults) { seasonalClutters.Add(new SeasonalClutter { clutterName = "meadows flowers", spring = true }); seasonalClutters.Add(new SeasonalClutter { clutterName = "forest groundcover bloom", spring = true }); seasonalClutters.Add(new SeasonalClutter { clutterName = "swampgrass bloom", spring = true }); seasonalClutters.Add(new SeasonalClutter { clutterName = "instanced_meadows_flowers", spring = true }); seasonalClutters.Add(new SeasonalClutter { clutterName = "instanced_forest_groundcover_bloom", spring = true }); seasonalClutters.Add(new SeasonalClutter { clutterName = "instanced_swamp_grass_bloom", spring = true }); } } public Dictionary GetSeasonalClutterState() { return GetSeasonalClutterState(Seasons.seasonState.GetCurrentSeason()); } public Dictionary GetSeasonalClutterState(Seasons.Season season) { Dictionary dictionary = new Dictionary(); foreach (SeasonalClutter seasonalClutter in seasonalClutters) { dictionary.Add(seasonalClutter.clutterName, seasonalClutter.GetSeasonState(season)); } return dictionary; } } [Serializable] public class SeasonEnvironment { public string m_cloneFrom = ""; public string m_name = ""; public bool m_default; [JsonProperty(/*Could not decode attribute arguments.*/)] public bool m_isWet; [JsonProperty(/*Could not decode attribute arguments.*/)] public bool m_isFreezing; [JsonProperty(/*Could not decode attribute arguments.*/)] public bool m_isFreezingAtNight; [JsonProperty(/*Could not decode attribute arguments.*/)] public bool m_isCold; [JsonProperty(/*Could not decode attribute arguments.*/)] public bool m_isColdAtNight; [JsonProperty(/*Could not decode attribute arguments.*/)] public bool m_alwaysDark; public string m_ambColorNight; public string m_ambColorDay; public string m_fogColorNight; public string m_fogColorMorning; public string m_fogColorDay; public string m_fogColorEvening; public string m_fogColorSunNight; public string m_fogColorSunMorning; public string m_fogColorSunDay; public string m_fogColorSunEvening; public float m_fogDensityNight; public float m_fogDensityMorning; public float m_fogDensityDay; public float m_fogDensityEvening; public string m_sunColorNight; public string m_sunColorMorning; public string m_sunColorDay; public string m_sunColorEvening; public float m_lightIntensityDay; public float m_lightIntensityNight; public float m_sunAngle; public float m_windMin; public float m_windMax; public string m_envObject; public string m_psystems; public bool m_psystemsOutsideOnly; public float m_rainCloudAlpha; public string m_ambientLoop; public float m_ambientVol; public string m_ambientList; public string m_musicMorning; public string m_musicEvening; public string m_musicDay; public string m_musicNight; private static readonly Dictionary usedObjects = new Dictionary(); private static readonly Dictionary usedAudioClips = new Dictionary(); public SeasonEnvironment() { } public SeasonEnvironment(EnvSetup env) { //IL_0160: Unknown result type (might be due to invalid IL or missing references) FieldInfo[] fields = ((object)env).GetType().GetFields(); foreach (FieldInfo fieldInfo in fields) { FieldInfo field = GetType().GetField(fieldInfo.Name); if (field == null) { continue; } switch (fieldInfo.Name) { case "m_envObject": if ((Object)(object)env.m_envObject != (Object)null) { m_envObject = ((Object)env.m_envObject).name; } break; case "m_psystems": if (env.m_psystems != null) { m_psystems = GeneralExtensions.Join(env.m_psystems.Select((GameObject ps) => ((Object)ps).name), (Func)null, ","); } break; case "m_ambientLoop": if ((Object)(object)env.m_ambientLoop != (Object)null) { m_ambientLoop = ((Object)env.m_ambientLoop).name; } break; default: field.SetValue(this, (fieldInfo.FieldType == typeof(Color)) ? ("#" + ColorUtility.ToHtmlStringRGBA((Color)fieldInfo.GetValue(env))) : fieldInfo.GetValue(env)); break; } } } public EnvSetup ToEnvSetup() { //IL_0370: Unknown result type (might be due to invalid IL or missing references) EnvSetup val = EnvMan.instance.m_environments.Find((EnvSetup e) => e.m_name == m_cloneFrom); if (val == null) { Seasons.LogWarning("Environment \"" + m_name + "\" clone source \"" + m_cloneFrom + "\" was not found. Falling back to \"Clear\"."); val = EnvMan.instance.GetEnv("Clear") ?? EnvMan.instance.m_environments.FirstOrDefault(); } if (val == null) { throw new InvalidOperationException("No environment is available to clone for \"" + m_name + "\"."); } SeasonEnvironment obj = new SeasonEnvironment(); EnvSetup val2 = val.Clone(); FieldInfo[] fields = ((object)val2).GetType().GetFields(); Color val3 = default(Color); foreach (FieldInfo fieldInfo in fields) { FieldInfo field = GetType().GetField(fieldInfo.Name); if (field == null || field.GetValue(this) == null || (field.FieldType != typeof(bool) && field.GetValue(this).Equals(field.GetValue(obj)))) { continue; } switch (fieldInfo.Name) { case "m_envObject": { if (usedObjects.TryGetValue(m_envObject, out var value2) && (Object)(object)value2 != (Object)null) { val2.m_envObject = value2; break; } Seasons.LogWarning("Environment object \"" + m_envObject + "\" was not found for environment \"" + m_name + "\"."); break; } case "m_psystems": { List list = new List(); string[] array = m_psystems.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { string text2 = text.Trim(); if (usedObjects.TryGetValue(text2, out var value) && (Object)(object)value != (Object)null) { list.Add(value); continue; } Seasons.LogWarning("Particle system \"" + text2 + "\" was not found for environment \"" + m_name + "\"."); } val2.m_psystems = list.ToArray(); break; } case "m_ambientLoop": val2.m_ambientLoop = GeneralExtensions.GetValueSafe(usedAudioClips, m_ambientLoop) ?? GeneralExtensions.GetValueSafe(CustomMusic.audioClips, m_ambientLoop); if ((Object)(object)val2.m_ambientLoop == (Object)null) { Seasons.LogWarning("Ambient loop \"" + m_ambientLoop + "\" was not found for environment \"" + m_name + "\"."); } break; default: fieldInfo.SetValue(val2, (fieldInfo.FieldType == typeof(Color) && ColorUtility.TryParseHtmlString(field.GetValue(this).ToString(), ref val3)) ? ((object)val3) : field.GetValue(this)); break; } } return val2; } public static List GetDefaultCustomEnvironments() { return new List { new SeasonEnvironment { m_name = "Clear Winter", m_cloneFrom = "Clear", m_isCold = true, m_isColdAtNight = true }, new SeasonEnvironment { m_name = "Clear Summer", m_cloneFrom = "Clear", m_isCold = false, m_isColdAtNight = false }, new SeasonEnvironment { m_name = "Misty Winter", m_cloneFrom = "Misty", m_isCold = true, m_isColdAtNight = true }, new SeasonEnvironment { m_name = "Misty Summer", m_cloneFrom = "Misty", m_isCold = false, m_isColdAtNight = false }, new SeasonEnvironment { m_name = "DeepForest Mist Winter", m_cloneFrom = "DeepForest Mist", m_isCold = true, m_isColdAtNight = true }, new SeasonEnvironment { m_name = "DeepForest Mist Summer", m_cloneFrom = "DeepForest Mist", m_isCold = false, m_isColdAtNight = false }, new SeasonEnvironment { m_name = "Rain Winter", m_cloneFrom = "Rain", m_isWet = true, m_isFreezingAtNight = true, m_isCold = true, m_isColdAtNight = true, m_alwaysDark = true, m_psystems = "SnowStorm", m_ambientLoop = "Wind_BlowingLoop3" }, new SeasonEnvironment { m_name = "LightRain Winter", m_cloneFrom = "LightRain", m_isWet = true, m_isCold = true, m_isColdAtNight = true, m_alwaysDark = true, m_psystems = "GroundMist,Snow,FogClouds", m_ambientLoop = "Wind_ColdLoop3" }, new SeasonEnvironment { m_name = "ThunderStorm Winter", m_cloneFrom = "ThunderStorm", m_isWet = true, m_isCold = true, m_isFreezing = true, m_isFreezingAtNight = true, m_isColdAtNight = true, m_alwaysDark = true, m_psystems = "SnowStorm", m_ambientLoop = "Wind_BlowingLoop3" }, new SeasonEnvironment { m_name = "ThunderStorm Fall", m_cloneFrom = "ThunderStorm", m_isWet = true, m_isCold = true, m_isColdAtNight = true, m_alwaysDark = true }, new SeasonEnvironment { m_name = "SwampRain Winter", m_cloneFrom = "SwampRain", m_isWet = true, m_isCold = true, m_isColdAtNight = true, m_alwaysDark = true, m_psystems = "Snow,GroundMist", m_ambientLoop = "Wind_ColdLoop3" }, new SeasonEnvironment { m_name = "SwampRain Fall", m_cloneFrom = "SwampRain", m_isWet = true, m_isCold = true, m_isColdAtNight = true, m_alwaysDark = false }, new SeasonEnvironment { m_name = "Mistlands_clear Winter", m_cloneFrom = "Mistlands_clear", m_isCold = true, m_isColdAtNight = true }, new SeasonEnvironment { m_name = "Mistlands_clear Summer", m_cloneFrom = "Mistlands_clear", m_isCold = false, m_isColdAtNight = false }, new SeasonEnvironment { m_name = "Mistlands_rain Winter", m_cloneFrom = "Mistlands_rain", m_isWet = true, m_isCold = true, m_isColdAtNight = true, m_isFreezingAtNight = true, m_alwaysDark = true, m_psystems = "Snow,GroundMist", m_ambientLoop = "Wind_ColdLoop3" }, new SeasonEnvironment { m_name = "Mistlands_thunder Winter", m_cloneFrom = "Mistlands_thunder", m_isWet = true, m_isCold = true, m_isColdAtNight = true, m_isFreezing = true, m_isFreezingAtNight = true, m_alwaysDark = true, m_psystems = "SnowStorm,MistlandsThunder", m_ambientLoop = "Wind_BlowingLoop3" }, new SeasonEnvironment { m_name = "Darklands_dark Winter", m_cloneFrom = "Darklands_dark", m_isCold = true, m_isColdAtNight = true, m_isFreezingAtNight = true, m_alwaysDark = false, m_psystems = "Snow,Darklands,GroundMist", m_ambientLoop = "Wind_ColdLoop3" }, new SeasonEnvironment { m_name = "Heath clear Winter", m_cloneFrom = "Heath clear", m_isCold = true, m_isColdAtNight = true }, new SeasonEnvironment { m_name = "Heath clear Summer", m_cloneFrom = "Heath clear", m_isColdAtNight = false }, new SeasonEnvironment { m_name = "Swamp Summer", m_cloneFrom = "Darklands_dark", m_isCold = false, m_isColdAtNight = false, m_alwaysDark = true, m_psystems = "LightRain,GroundMist", m_ambientLoop = "SW008_Wendland_Autumn_Wind_In_Reeds_Medium_Distance_Leaves_Only" }, new SeasonEnvironment { m_name = "SwampRain Summer", m_cloneFrom = "SwampRain", m_isWet = false, m_isColdAtNight = false, m_alwaysDark = true, m_psystems = "GroundMist", m_ambientLoop = "SW008_Wendland_Autumn_Wind_In_Reeds_Medium_Distance_Leaves_Only" } }; } public static void ClearCachedObjects() { usedObjects.Clear(); usedAudioClips.Clear(); } public static void RebuildCachedObjects() { ClearCachedObjects(); AddCachedObjectsFromCurrentEnvironments(); } public static void AddCachedObjectsFromCurrentEnvironments() { if ((Object)(object)EnvMan.instance == (Object)null || EnvMan.instance.m_environments == null) { return; } foreach (EnvSetup environment in EnvMan.instance.m_environments) { AddCachedObjects(environment); } } public static void AddCachedObjects(EnvSetup env) { if (env == null) { return; } AddCachedObject(env.m_envObject); if (env.m_psystems != null) { GameObject[] psystems = env.m_psystems; foreach (GameObject obj in psystems) { AddCachedObject(obj); } } AddCachedAudioClip(env.m_ambientLoop); } private static void AddCachedObject(GameObject obj) { if (!((Object)(object)obj == (Object)null) && !string.IsNullOrWhiteSpace(((Object)obj).name) && !usedObjects.ContainsKey(((Object)obj).name)) { usedObjects.Add(((Object)obj).name, obj); } } private static void AddCachedAudioClip(AudioClip clip) { if (!((Object)(object)clip == (Object)null) && !string.IsNullOrWhiteSpace(((Object)clip).name) && !usedAudioClips.ContainsKey(((Object)clip).name)) { usedAudioClips.Add(((Object)clip).name, clip); } } } [Serializable] public class SeasonGrassSettings { [Serializable] public class SeasonGrass { public int m_day = 1; public float m_grassPatchSize = 10f; public float m_amountScale = 1.5f; public float m_scaleMin = 1f; public float m_scaleMax = 1f; } public List Spring = new List(); public List Summer = new List(); public List Fall = new List(); public List Winter = new List(); public SeasonGrassSettings(bool loadDefaults = false) { if (loadDefaults) { Winter.Add(new SeasonGrass { m_day = 1, m_grassPatchSize = 15f, m_scaleMax = 0.75f }); Winter.Add(new SeasonGrass { m_day = 2, m_grassPatchSize = 20f, m_scaleMax = 0.5f }); Winter.Add(new SeasonGrass { m_day = 3, m_grassPatchSize = 25f, m_scaleMax = 0.25f }); Winter.Add(new SeasonGrass { m_day = 4, m_scaleMax = 0f }); Winter.Add(new SeasonGrass { m_day = 10, m_scaleMax = 0f }); Spring.Add(new SeasonGrass { m_day = 1, m_grassPatchSize = 20f, m_amountScale = 2f, m_scaleMin = 0.6f, m_scaleMax = 0.6f }); Spring.Add(new SeasonGrass { m_day = 3, m_scaleMin = 0.7f, m_scaleMax = 0.75f }); Spring.Add(new SeasonGrass { m_day = 8, m_scaleMin = 0.85f, m_scaleMax = 0.9f }); Spring.Add(new SeasonGrass { m_day = 10, m_grassPatchSize = 11f, m_scaleMax = 1.1f }); Summer.Add(new SeasonGrass { m_day = 1, m_scaleMin = 0.9f, m_scaleMax = 1.1f, m_grassPatchSize = 11f }); Summer.Add(new SeasonGrass { m_day = 6, m_scaleMin = 1.1f, m_scaleMax = 1.4f, m_grassPatchSize = 14f, m_amountScale = 1.4f }); Summer.Add(new SeasonGrass { m_day = 9, m_scaleMax = 1.1f }); Fall.Add(new SeasonGrass { m_day = 1, m_scaleMax = 1.1f }); Fall.Add(new SeasonGrass { m_day = 5, m_scaleMax = 1.3f }); Fall.Add(new SeasonGrass { m_day = 10, m_grassPatchSize = 12f, m_amountScale = 1.2f, m_scaleMin = 0.8f }); } } public SeasonGrass GetGrassSettings() { return GetGrassSettings(Seasons.seasonState.GetCurrentDay()); } public SeasonGrass GetGrassSettings(int day) { if (Seasons.seasonState.GetCurrentWorldDay() > Seasons.seasonState.GetDaysInSeason(Seasons.Season.Spring)) { List seasonGrass = GetSeasonGrass(Seasons.seasonState.GetCurrentSeason()); for (int i = 0; i < seasonGrass.Count; i++) { SeasonGrass seasonGrass2 = seasonGrass[i]; if (day == seasonGrass2.m_day || (day <= seasonGrass2.m_day && i == 0) || (day >= seasonGrass2.m_day && i == seasonGrass.Count - 1)) { return seasonGrass2; } if (seasonGrass2.m_day >= day) { if (seasonGrass[i].m_day == seasonGrass[i - 1].m_day) { break; } float num = (float)(day - seasonGrass[i - 1].m_day) / (float)(seasonGrass[i].m_day - seasonGrass[i - 1].m_day); return new SeasonGrass { m_day = day, m_grassPatchSize = Mathf.Lerp(seasonGrass[i - 1].m_grassPatchSize, seasonGrass[i].m_grassPatchSize, num), m_amountScale = Mathf.Lerp(seasonGrass[i - 1].m_amountScale, seasonGrass[i].m_amountScale, num), m_scaleMin = Mathf.Lerp(seasonGrass[i - 1].m_scaleMin, seasonGrass[i].m_scaleMin, num), m_scaleMax = Mathf.Lerp(seasonGrass[i - 1].m_scaleMax, seasonGrass[i].m_scaleMax, num) }; } } } return new SeasonGrass { m_day = day, m_grassPatchSize = Seasons.grassDefaultPatchSize.Value, m_amountScale = Seasons.grassDefaultAmountScale.Value, m_scaleMin = Seasons.grassSizeDefaultScaleMin.Value, m_scaleMax = Seasons.grassSizeDefaultScaleMax.Value }; } private List GetSeasonGrass(Seasons.Season season) { if (1 == 0) { } List result = season switch { Seasons.Season.Spring => Spring, Seasons.Season.Summer => Summer, Seasons.Season.Fall => Fall, Seasons.Season.Winter => Winter, _ => new List(), }; if (1 == 0) { } return result; } } [Serializable] public class SeasonLightings { [Serializable] public class LightingSettings { public float luminanceMultiplier = 1f; public float fogDensityMultiplier = 1f; } [Serializable] public class SeasonLightingSettings { public LightingSettings indoors = new LightingSettings(); public LightingSettings morning = new LightingSettings(); public LightingSettings day = new LightingSettings(); public LightingSettings evening = new LightingSettings(); public LightingSettings night = new LightingSettings(); public float lightIntensityDayMultiplier = 1f; public float lightIntensityNightMultiplier = 1f; } public SeasonLightingSettings Spring = new SeasonLightingSettings(); public SeasonLightingSettings Summer = new SeasonLightingSettings(); public SeasonLightingSettings Fall = new SeasonLightingSettings(); public SeasonLightingSettings Winter = new SeasonLightingSettings(); public SeasonLightings(bool loadDefaults = false) { if (loadDefaults) { Summer.indoors.fogDensityMultiplier = 0.9f; Summer.morning.luminanceMultiplier = 1.1f; Summer.morning.fogDensityMultiplier = 0.9f; Summer.evening.luminanceMultiplier = 1.1f; Summer.evening.fogDensityMultiplier = 0.9f; Summer.night.luminanceMultiplier = 1.1f; Summer.night.fogDensityMultiplier = 0.9f; Summer.lightIntensityNightMultiplier = 0.9f; Fall.morning.luminanceMultiplier = 0.95f; Fall.morning.fogDensityMultiplier = 1.1f; Fall.evening.luminanceMultiplier = 0.95f; Fall.evening.fogDensityMultiplier = 1.1f; Fall.night.luminanceMultiplier = 0.9f; Fall.night.fogDensityMultiplier = 1.3f; Fall.lightIntensityNightMultiplier = 1.2f; Winter.indoors.luminanceMultiplier = 0.9f; Winter.indoors.fogDensityMultiplier = 1.1f; Winter.morning.luminanceMultiplier = 0.9f; Winter.morning.fogDensityMultiplier = 1.2f; Winter.evening.luminanceMultiplier = 0.9f; Winter.evening.fogDensityMultiplier = 1.2f; Winter.night.luminanceMultiplier = 0.8f; Winter.night.fogDensityMultiplier = 1.7f; Winter.lightIntensityNightMultiplier = 1.5f; } } public SeasonLightingSettings GetSeasonLighting(Seasons.Season season) { if (1 == 0) { } SeasonLightingSettings result = season switch { Seasons.Season.Spring => Spring, Seasons.Season.Summer => Summer, Seasons.Season.Fall => Fall, Seasons.Season.Winter => Winter, _ => new SeasonLightingSettings(), }; if (1 == 0) { } return result; } } [Serializable] public class SeasonRandomEvents { [Serializable] public class SeasonRandomEvent { public string m_name; public string m_biomes; public int m_weight; public SeasonRandomEvent() { } public SeasonRandomEvent(RandomEvent randomEvent) { m_name = randomEvent.m_name; m_weight = 1; m_biomes = ((object)Unsafe.As(ref randomEvent.m_biome)/*cast due to .constrained prefix*/).ToString(); } public Biome GetBiome() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) return (Biome)Enum.Parse(typeof(Biome), m_biomes); } } public List Spring = new List(); public List Summer = new List(); public List Fall = new List(); public List Winter = new List(); public SeasonRandomEvents(bool loadDefaults = false) { if (loadDefaults) { Spring.Add(new SeasonRandomEvent { m_name = "foresttrolls", m_weight = 2 }); Spring.Add(new SeasonRandomEvent { m_name = "bats", m_weight = 0 }); Spring.Add(new SeasonRandomEvent { m_name = "army_eikthyr", m_weight = 2 }); Spring.Add(new SeasonRandomEvent { m_name = "army_theelder", m_weight = 2 }); Summer.Add(new SeasonRandomEvent { m_name = "bats", m_weight = 2 }); Summer.Add(new SeasonRandomEvent { m_name = "surtlings", m_weight = 2 }); Summer.Add(new SeasonRandomEvent { m_name = "wolves", m_weight = 0 }); Summer.Add(new SeasonRandomEvent { m_name = "army_goblin", m_weight = 2 }); Fall.Add(new SeasonRandomEvent { m_name = "skeletons", m_weight = 2 }); Fall.Add(new SeasonRandomEvent { m_name = "blobs", m_weight = 2 }); Fall.Add(new SeasonRandomEvent { m_name = "army_bonemass", m_weight = 2 }); Winter.Add(new SeasonRandomEvent { m_name = "wolves", m_biomes = "Meadows, Swamp, Mountain, BlackForest, Plains, DeepNorth", m_weight = 2 }); Winter.Add(new SeasonRandomEvent { m_name = "army_moder", m_weight = 2 }); Winter.Add(new SeasonRandomEvent { m_name = "skeletons", m_weight = 0 }); Winter.Add(new SeasonRandomEvent { m_name = "foresttrolls", m_weight = 0 }); Winter.Add(new SeasonRandomEvent { m_name = "surtlings", m_weight = 0 }); Winter.Add(new SeasonRandomEvent { m_name = "blobs", m_weight = 0 }); } } public List GetSeasonEvents(Seasons.Season season) { if (1 == 0) { } List result = season switch { Seasons.Season.Spring => Spring, Seasons.Season.Summer => Summer, Seasons.Season.Fall => Fall, Seasons.Season.Winter => Winter, _ => new List(), }; if (1 == 0) { } return result; } } [HarmonyPatch(typeof(ZoneSystem), "Start")] public static class ZoneSystem_Start_SeasonsCache { private static void Postfix() { SeasonalTexturePrefabCache.SetupConfigWatcher(); SeasonalTexturePrefabCache.SaveDefaults(); CustomTextures.SaveDefaults(); if (Seasons.UseTextureControllers()) { ClutterVariantController.AddSeasonalClutter(); if (Seasons.texturesVariants.Initialize()) { SeasonState.InitializeTextureControllers(); } } } } [HarmonyPatch(typeof(ZoneSystem), "OnDestroy")] public static class ZoneSystem_OnDestroy_SeasonsCache { private static void Postfix() { if (Seasons.UseTextureControllers()) { Seasons.texturesVariants = new SeasonalTextureVariants(); } } } public static class SeasonalTexturePrefabCache { [Serializable] public struct FloatRange { public float start; public float end; public FloatRange(float start, float end) { this.start = start; this.end = end; } public readonly bool Fits(float value) { return (start == 0f || start <= value) && (end == 0f || value <= end); } public override readonly string ToString() { return $"{start}-{end}"; } } [Serializable] public struct IntRange { public int start; public int end; public IntRange(int start, int end) { this.start = start; this.end = end; } public readonly bool Fits(int value) { return (start == 0 || start <= value) && (end == 0 || value <= end); } public override readonly string ToString() { return $"{start}-{end}"; } } [Serializable] public class MaterialCacheSettings { public List particleSystemStartColors = new List(); public Dictionary shadersTypes = new Dictionary(); public Dictionary shaderColors = new Dictionary(); public Dictionary materialColors = new Dictionary(); public Dictionary shaderTextures = new Dictionary(); public Dictionary materialTextures = new Dictionary(); public Dictionary shaderIgnoreMaterial = new Dictionary(); public Dictionary shaderOnlyMaterial = new Dictionary(); public List effectPrefab = new List(); public List creaturePrefab = new List(); public List piecePrefab = new List(); public List piecePrefabPartialName = new List(); public List ignorePrefab = new List(); public List ignorePrefabPartialName = new List(); public List itemsPrefab = new List(); public MaterialCacheSettings(bool loadDefaults = false) { if (loadDefaults) { particleSystemStartColors = new List { "leaf_particles", "vfx_bush_destroyed", "vfx_bush_destroyed_heath", "vfx_bush_leaf_puff", "vfx_bush_leaf_puff_heath", "vfx_bush2_e_hit", "vfx_bush2_en_destroyed", "vfx_shrub_2_hit" }; shaderColors = new Dictionary { { "Custom/StaticRock", new string[1] { "_MossColor" } }, { "Custom/Yggdrasil_root", new string[1] { "_MossColor" } } }; materialColors = new Dictionary { { "Vines_Mat", new string[1] { "_Color" } }, { "carrot_blast", new string[1] { "_Color" } }, { "barley_sapling", new string[1] { "_Color" } }, { "Bush01_raspberry", new string[1] { "_Color" } }, { "grasscross_mistlands_short", new string[1] { "_Color" } }, { "Bush02_en", new string[1] { "_Color" } }, { "shrub_heath", new string[1] { "_Color" } }, { "bfp_straw_roof", new string[1] { "_Color" } }, { "bfp_straw_roof_alpha", new string[1] { "_Color" } }, { "bfp_straw_roof_corner_alpha", new string[1] { "_Color" } }, { "bcp_clay", new string[1] { "_Color" } }, { "Grausten_RoofSlab_mat", new string[1] { "_Color" } }, { "Vine_Sapling_ashlands_mat", new string[1] { "_Color" } }, { "Vines_ashlands_mat", new string[1] { "_Color" } }, { "bca_Bush01_raspberry", new string[1] { "_Color" } } }; materialTextures = new Dictionary { { "swamptree1_log", new string[1] { "_MossTex" } }, { "swamptree2_log", new string[1] { "_MossTex" } }, { "swamptree1_bark", new string[1] { "_MossTex" } }, { "swamptree2_bark", new string[1] { "_MossTex" } }, { "swamptree_stump", new string[1] { "_MossTex" } }, { "beech_bark", new string[1] { "_MossTex" } }, { "oak_bark", new string[1] { "_MossTex" } }, { "yggdrasil_branch", new string[1] { "_MossTex" } }, { "Vines_Mat", new string[0] }, { "Grausten_RoofSlab_mat", new string[0] }, { "Vine_Sapling_ashlands_mat", new string[0] }, { "Vines_ashlands_mat", new string[0] } }; shaderTextures = new Dictionary { { "Custom/Vegetation", new string[1] { "_MainTex" } }, { "Custom/Grass", new string[2] { "_MainTex", "_TerrainColorTex" } }, { "Custom/Creature", new string[1] { "_MainTex" } }, { "Custom/Piece", new string[1] { "_MainTex" } }, { "Custom/StaticRock", new string[1] { "_MossTex" } }, { "Standard", new string[1] { "_MainTex" } }, { "Particles/Standard Surface2", new string[1] { "_MainTex" } }, { "Custom/Yggdrasil", new string[1] { "_MainTex" } } }; shaderIgnoreMaterial = new Dictionary { { "Custom/Vegetation", new string[10] { "bark", "trunk", "_wood", "HildirFlowerGirland_", "HildirTentCloth_", "TraderTent_", "VinesBranch_mat", "VinesBranch_Ashlands_mat", "BogWitchHutCurtains2_mat", "BogWitchHutCurtains_mat" } } }; shaderOnlyMaterial = new Dictionary { { "Custom/Piece", new string[10] { "straw", "RoofShingles", "beehive", "Midsummerpole_mat", "Pine_tree_xmas", "ReworkedValheim", "shipyardNewCloth", "M_Cloth_01", "bcp_clay", "Grausten_RoofSlab_mat" } }, { "Custom/Creature", new string[12] { "HildirsLox", "lox", "lox_calf", "Draugr_Archer_mat", "Draugr_mat", "Draugr_elite_mat", "Abomination_mat", "greyling", "greydwarf", "greydwarf_elite", "greydwarf_shaman", "neck" } }, { "Standard", new string[7] { "beech_particle", "birch_particle", "branch_particle", "branch_dead_particle", "oak_particle", "shoot_leaf_particle", "Dandelion" } }, { "Particles/Standard Surface2", new string[3] { "shrub2_leafparticle", "shrub2_leafparticle_heath", "leaf_en" } } }; shadersTypes = new Dictionary { { typeof(MeshRenderer).Name, new string[7] { "Custom/Vegetation", "Custom/Grass", "Custom/StaticRock", "Custom/Piece", "Custom/Yggdrasil", "Custom/Yggdrasil_root", "Standard" } }, { typeof(InstanceRenderer).Name, new string[2] { "Custom/Vegetation", "Custom/Grass" } }, { typeof(SkinnedMeshRenderer).Name, new string[1] { "Custom/Creature" } }, { typeof(ParticleSystemRenderer).Name, new string[2] { "Standard", "Particles/Standard Surface2" } } }; effectPrefab = new List { "lox_ragdoll", "loxcalf_ragdoll", "Draugr_elite_ragdoll", "Draugr_ragdoll", "Draugr_ranged_ragdoll", "Abomination_ragdoll", "Greydwarf_ragdoll", "Greydwarf_elite_ragdoll", "Greydwarf_Shaman_ragdoll", "Greyling_ragdoll", "vfx_beech_cut", "vfx_oak_cut", "vfx_yggashoot_cut", "vfx_bush_destroyed", "vfx_bush_destroyed_heath", "vfx_bush_leaf_puff", "vfx_bush_leaf_puff_heath", "vfx_bush2_e_hit", "vfx_bush2_en_destroyed" }; creaturePrefab = new List { "Lox", "Lox_Calf", "Draugr", "Draugr_Elite", "Draugr_Ranged", "Abomination", "Greydwarf", "Greydwarf_Elite", "Greydwarf_Shaman", "Greyling" }; piecePrefab = new List { "vines", "piece_beehive", "piece_maypole", "piece_xmastree", "VineAsh", "VineAsh_sapling" }; piecePrefabPartialName = new List { "wood_roof", "copper_roof", "goblin_roof", "roof_wood_", "roof_darkwood_", "elvenwood_roof", "BFP_FineWoodRoof", "cloth_roof", "BFP_ClayRoof", "piece_grausten_roof", "VineAsh" }; ignorePrefab = new List { "Rock_destructible_test", "HugeRoot1", "Hildir_cave", "PineTree_log", "PineTree_log_half", "MountainGrave01", "PineTree_log_halfOLD", "PineTree_logOLD", "sapling_magecap", "FirTree_log", "FirTree_log_half", "Hildir_crypt", "MountainGraveStone01", "crypt_skeleton_chest", "dungeon_sunkencrypt_irongate_rusty", "stonechest", "SunkenKit_int_towerwall", "SunkenKit_int_towerwall_LOD", "marker01", "marker02", "TheHive", "StoneVillage2", "VoltureNest", "CharredStone_Spawner", "SulfurArch", "FaderLocation", "LeviathanLava", "FernFiddleHeadAshlands", "DevKitchen", "DevDressingRoom", "DevGarden", "DevForge", "DevCombatRange", "DevCombatRing", "rock4_ashlands_frac", "Runestone_Ashlands", "instanced_meadows_flowers", "instanced_forest_groundcover_bloom", "instanced_swamp_grass_bloom" }; ignorePrefabPartialName = new List { "Mistlands_GuardTower", "WoodHouse", "DevHouse", "StoneTower", "SunkenCrypt", "MountainCave", "Mistlands_Lighthouse", "Mistlands_Viaduct", "Mistlands_Dvergr", "Mistlands_Statue", "Mistlands_Excavation", "Mistlands_Giant", "Mistlands_Harbour", "Mistlands_Mine", "dvergrtown_", "OLD_wood_roof", "AbandonedLogCabin", "DrakeNest", "CharredRuins", "MorgenHole", "CharredTowerRuins", "CharredRuins", "CharredFortress", "PlaceofMystery", "DevWall", "blackmarble_creep_slope", "lavarock_", "lavabomb_", "FlametalRockstand", "cliff_ashlands", "AshlandsTree", "AshlandsBush", "AshlandsBranch", "Ashlands_rock", "instanced_ashlands_grass", "MWL_AshlandsFort", "_inshield_seasons" }; itemsPrefab = new List { "BH_Pickable", "Pickable_Dandelion" }; } } } [Serializable] public class ColorsCacheSettings { [Serializable] public class ColorVariant { public bool useColor = true; public string color; public float targetProportion = 0f; public bool preserveAlphaChannel = true; public bool reduceOriginalColorToGrayscale = false; public bool restoreLuminance = true; [NonSerialized] public Color colorValue = Color.black; public Color MergeColors(Color colorToMerge) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) if (!useColor) { return colorToMerge; } if (colorValue == Color.black && ColorUtility.ToHtmlStringRGBA(colorValue) != color && !ColorUtility.TryParseHtmlString(color, ref colorValue)) { Seasons.LogInfo("Error at parsing color: (" + color + ")"); } Color val = default(Color); ((Color)(ref val))..ctor(colorValue.r, colorValue.g, colorValue.b, preserveAlphaChannel ? colorToMerge.a : colorValue.a); Color val2 = (Color)(reduceOriginalColorToGrayscale ? new Color(((Color)(ref colorToMerge)).grayscale, ((Color)(ref colorToMerge)).grayscale, ((Color)(ref colorToMerge)).grayscale, colorToMerge.a) : colorToMerge); HSLColor hSLColor = new HSLColor(Color.Lerp(val2, val, targetProportion)); if (restoreLuminance) { hSLColor.l = new HSLColor(colorToMerge).l; } return hSLColor.ToRGBA(); } public ColorVariant() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) useColor = false; } public ColorVariant(Color color, float t) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) this.color = "#" + ColorUtility.ToHtmlStringRGBA(color); targetProportion = t; } public ColorVariant(Color color, float t, bool grayscale, bool restoreLuminance) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) this.color = "#" + ColorUtility.ToHtmlStringRGBA(color); targetProportion = t; reduceOriginalColorToGrayscale = grayscale; this.restoreLuminance = restoreLuminance; } } [Serializable] public class SeasonalColorVariants { public List Spring = new List(); public List Summer = new List(); public List Fall = new List(); public List Winter = new List(); public ColorVariant GetColorVariant(Seasons.Season season, int pos) { if (1 == 0) { } ColorVariant result = season switch { Seasons.Season.Spring => (pos > Spring.Count - 1) ? new ColorVariant() : Spring[Mathf.Clamp(pos, 0, 3)], Seasons.Season.Summer => (pos > Summer.Count - 1) ? new ColorVariant() : Summer[Mathf.Clamp(pos, 0, 3)], Seasons.Season.Fall => (pos > Fall.Count - 1) ? new ColorVariant() : Fall[Mathf.Clamp(pos, 0, 3)], Seasons.Season.Winter => (pos > Winter.Count - 1) ? new ColorVariant() : Winter[Mathf.Clamp(pos, 0, 3)], _ => (pos > Spring.Count - 1) ? new ColorVariant() : Spring[Mathf.Clamp(pos, 0, 3)], }; if (1 == 0) { } return result; } } [Serializable] public class SeasonalColorOverride { public SeasonalColorVariants colors = new SeasonalColorVariants(); } [Serializable] public class PrefabOverrides : SeasonalColorOverride { public List prefab = new List(); public PrefabOverrides(List prefab, SeasonalColorVariants colors) { this.prefab = prefab; base.colors = colors; } } [Serializable] public class MaterialOverrides : SeasonalColorOverride { public List material = new List(); public MaterialOverrides(List material, SeasonalColorVariants colors) { this.material = material; base.colors = colors; } } public SeasonalColorVariants seasonal = new SeasonalColorVariants(); public SeasonalColorVariants grass = new SeasonalColorVariants(); public SeasonalColorVariants moss = new SeasonalColorVariants(); public SeasonalColorVariants creature = new SeasonalColorVariants(); public SeasonalColorVariants piece = new SeasonalColorVariants(); public SeasonalColorVariants conifer = new SeasonalColorVariants(); public SeasonalColorVariants bush = new SeasonalColorVariants(); public List prefabOverrides = new List(); public List materialOverrides = new List(); private readonly Dictionary _prefabs = new Dictionary(); private readonly Dictionary _materials = new Dictionary(); public ColorsCacheSettings(bool loadDefaults = false) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_05a2: Unknown result type (might be due to invalid IL or missing references) //IL_05d3: Unknown result type (might be due to invalid IL or missing references) //IL_0604: Unknown result type (might be due to invalid IL or missing references) //IL_0635: Unknown result type (might be due to invalid IL or missing references) //IL_0666: Unknown result type (might be due to invalid IL or missing references) //IL_06ab: Unknown result type (might be due to invalid IL or missing references) //IL_06da: Unknown result type (might be due to invalid IL or missing references) //IL_0709: Unknown result type (might be due to invalid IL or missing references) //IL_0738: Unknown result type (might be due to invalid IL or missing references) //IL_0767: Unknown result type (might be due to invalid IL or missing references) //IL_0796: Unknown result type (might be due to invalid IL or missing references) //IL_07c5: Unknown result type (might be due to invalid IL or missing references) //IL_07f4: Unknown result type (might be due to invalid IL or missing references) //IL_0823: Unknown result type (might be due to invalid IL or missing references) //IL_0852: Unknown result type (might be due to invalid IL or missing references) //IL_0881: Unknown result type (might be due to invalid IL or missing references) //IL_08b2: Unknown result type (might be due to invalid IL or missing references) //IL_08e3: Unknown result type (might be due to invalid IL or missing references) //IL_0914: Unknown result type (might be due to invalid IL or missing references) //IL_0945: Unknown result type (might be due to invalid IL or missing references) //IL_0974: Unknown result type (might be due to invalid IL or missing references) //IL_09a3: Unknown result type (might be due to invalid IL or missing references) //IL_09e8: Unknown result type (might be due to invalid IL or missing references) //IL_0a17: Unknown result type (might be due to invalid IL or missing references) //IL_0a46: Unknown result type (might be due to invalid IL or missing references) //IL_0a75: Unknown result type (might be due to invalid IL or missing references) //IL_0aa4: Unknown result type (might be due to invalid IL or missing references) //IL_0ad3: Unknown result type (might be due to invalid IL or missing references) //IL_0b02: Unknown result type (might be due to invalid IL or missing references) //IL_0b31: Unknown result type (might be due to invalid IL or missing references) //IL_0b60: Unknown result type (might be due to invalid IL or missing references) //IL_0b91: Unknown result type (might be due to invalid IL or missing references) //IL_0bc2: Unknown result type (might be due to invalid IL or missing references) //IL_0bf3: Unknown result type (might be due to invalid IL or missing references) //IL_0c24: Unknown result type (might be due to invalid IL or missing references) //IL_0c53: Unknown result type (might be due to invalid IL or missing references) //IL_0c82: Unknown result type (might be due to invalid IL or missing references) //IL_0cc7: Unknown result type (might be due to invalid IL or missing references) //IL_0cf6: Unknown result type (might be due to invalid IL or missing references) //IL_0d25: Unknown result type (might be due to invalid IL or missing references) //IL_0d54: Unknown result type (might be due to invalid IL or missing references) //IL_0d83: Unknown result type (might be due to invalid IL or missing references) //IL_0db2: Unknown result type (might be due to invalid IL or missing references) //IL_0de1: Unknown result type (might be due to invalid IL or missing references) //IL_0e10: Unknown result type (might be due to invalid IL or missing references) //IL_0e3f: Unknown result type (might be due to invalid IL or missing references) //IL_0e70: Unknown result type (might be due to invalid IL or missing references) //IL_0ea1: Unknown result type (might be due to invalid IL or missing references) //IL_0ed2: Unknown result type (might be due to invalid IL or missing references) //IL_0f03: Unknown result type (might be due to invalid IL or missing references) //IL_0f34: Unknown result type (might be due to invalid IL or missing references) //IL_0f65: Unknown result type (might be due to invalid IL or missing references) //IL_0f96: Unknown result type (might be due to invalid IL or missing references) //IL_0fc7: Unknown result type (might be due to invalid IL or missing references) //IL_0ff8: Unknown result type (might be due to invalid IL or missing references) //IL_1029: Unknown result type (might be due to invalid IL or missing references) //IL_105a: Unknown result type (might be due to invalid IL or missing references) //IL_10a3: Unknown result type (might be due to invalid IL or missing references) //IL_10ca: Unknown result type (might be due to invalid IL or missing references) //IL_10f1: Unknown result type (might be due to invalid IL or missing references) //IL_1118: Unknown result type (might be due to invalid IL or missing references) //IL_1171: Unknown result type (might be due to invalid IL or missing references) //IL_1198: Unknown result type (might be due to invalid IL or missing references) //IL_11bf: Unknown result type (might be due to invalid IL or missing references) //IL_11e6: Unknown result type (might be due to invalid IL or missing references) //IL_1272: Unknown result type (might be due to invalid IL or missing references) //IL_1299: Unknown result type (might be due to invalid IL or missing references) //IL_12c0: Unknown result type (might be due to invalid IL or missing references) //IL_12e7: Unknown result type (might be due to invalid IL or missing references) if (!loadDefaults) { return; } seasonal.Spring.Add(new ColorVariant(new Color(0.27f, 0.8f, 0.27f), 0.75f)); seasonal.Spring.Add(new ColorVariant(new Color(0.69f, 0.84f, 0.15f), 0.75f)); seasonal.Spring.Add(new ColorVariant(new Color(0.43f, 0.56f, 0.11f), 0.75f)); seasonal.Spring.Add(new ColorVariant()); seasonal.Summer.Add(new ColorVariant(new Color(0.5f, 0.7f, 0.2f), 0.5f)); seasonal.Summer.Add(new ColorVariant(new Color(0.7f, 0.7f, 0.2f), 0.5f)); seasonal.Summer.Add(new ColorVariant(new Color(0.5f, 0.5f, 0f), 0.5f)); seasonal.Summer.Add(new ColorVariant(new Color(0.7f, 0.7f, 0f), 0.2f)); seasonal.Fall.Add(new ColorVariant(new Color(0.8f, 0.5f, 0f), 0.75f)); seasonal.Fall.Add(new ColorVariant(new Color(0.8f, 0.3f, 0f), 0.75f)); seasonal.Fall.Add(new ColorVariant(new Color(0.8f, 0.2f, 0f), 0.7f)); seasonal.Fall.Add(new ColorVariant(new Color(0.7f, 0.7f, 0f), 0.2f)); seasonal.Winter.Add(new ColorVariant(new Color(1f, 0.98f, 0.98f), 0.65f, grayscale: true, restoreLuminance: false)); seasonal.Winter.Add(new ColorVariant(new Color(1f, 1f, 1f), 0.6f, grayscale: true, restoreLuminance: false)); seasonal.Winter.Add(new ColorVariant(new Color(0.98f, 0.98f, 1f), 0.65f, grayscale: true, restoreLuminance: false)); seasonal.Winter.Add(new ColorVariant(new Color(1f, 1f, 1f), 0.65f, grayscale: true, restoreLuminance: false)); grass.Spring.Add(new ColorVariant(new Color(0.45f, 0.8f, 0.27f), 0.5f)); grass.Spring.Add(new ColorVariant(new Color(0.69f, 0.84f, 0.15f), 0.45f)); grass.Spring.Add(new ColorVariant(new Color(0.51f, 0.65f, 0.13f), 0.5f)); grass.Spring.Add(new ColorVariant()); grass.Summer.Add(new ColorVariant(new Color(0.5f, 0.7f, 0.2f), 0.5f)); grass.Summer.Add(new ColorVariant(new Color(0.7f, 0.75f, 0.2f), 0.5f)); grass.Summer.Add(new ColorVariant(new Color(0.5f, 0.5f, 0f), 0.5f)); grass.Summer.Add(new ColorVariant(new Color(0.7f, 0.7f, 0f), 0.2f)); grass.Fall.Add(new ColorVariant(new Color(0.8f, 0.6f, 0.2f), 0.5f)); grass.Fall.Add(new ColorVariant(new Color(0.8f, 0.5f, 0f), 0.5f)); grass.Fall.Add(new ColorVariant(new Color(0.8f, 0.3f, 0f), 0.4f)); grass.Fall.Add(new ColorVariant(new Color(0.7f, 0.7f, 0f), 0.4f)); grass.Winter.Add(new ColorVariant(new Color(1f, 0.98f, 0.98f), 0.65f, grayscale: true, restoreLuminance: false)); grass.Winter.Add(new ColorVariant(new Color(1f, 1f, 1f), 0.6f, grayscale: true, restoreLuminance: false)); grass.Winter.Add(new ColorVariant(new Color(0.98f, 0.98f, 1f), 0.65f, grayscale: true, restoreLuminance: false)); grass.Winter.Add(new ColorVariant(new Color(1f, 1f, 1f), 0.65f, grayscale: true, restoreLuminance: false)); moss.Spring.Add(new ColorVariant(new Color(0.43f, 0.56f, 0.11f), 0.25f)); moss.Spring.Add(new ColorVariant()); moss.Spring.Add(new ColorVariant(new Color(0.27f, 0.8f, 0.27f), 0.25f)); moss.Spring.Add(new ColorVariant(new Color(0.69f, 0.84f, 0.15f), 0.25f)); moss.Summer.Add(new ColorVariant(new Color(0.5f, 0.5f, 0f), 0.2f)); moss.Summer.Add(new ColorVariant(new Color(0.7f, 0.7f, 0f), 0.07f)); moss.Summer.Add(new ColorVariant(new Color(0.5f, 0.7f, 0.2f), 0.2f)); moss.Summer.Add(new ColorVariant(new Color(0.7f, 0.75f, 0.2f), 0.2f)); moss.Fall.Add(new ColorVariant(new Color(0.8f, 0.3f, 0f), 0.2f)); moss.Fall.Add(new ColorVariant(new Color(0.7f, 0.7f, 0f), 0.1f)); moss.Fall.Add(new ColorVariant(new Color(0.8f, 0.6f, 0.2f), 0.2f)); moss.Fall.Add(new ColorVariant(new Color(0.8f, 0.5f, 0f), 0.2f)); moss.Winter.Add(new ColorVariant(new Color(0.98f, 0.98f, 1f), 0.65f, grayscale: true, restoreLuminance: false)); moss.Winter.Add(new ColorVariant(new Color(1f, 1f, 1f), 0.65f, grayscale: true, restoreLuminance: false)); moss.Winter.Add(new ColorVariant(new Color(1f, 0.98f, 0.98f), 0.65f, grayscale: true, restoreLuminance: false)); moss.Winter.Add(new ColorVariant(new Color(1f, 1f, 1f), 0.6f, grayscale: true, restoreLuminance: false)); conifer.Spring.Add(new ColorVariant(new Color(0.27f, 0.8f, 0.27f), 0.35f)); conifer.Spring.Add(new ColorVariant(new Color(0.69f, 0.84f, 0.15f), 0.35f)); conifer.Spring.Add(new ColorVariant(new Color(0.43f, 0.56f, 0.11f), 0.35f)); conifer.Spring.Add(new ColorVariant()); conifer.Summer.Add(new ColorVariant(new Color(0.5f, 0.7f, 0.2f), 0.25f)); conifer.Summer.Add(new ColorVariant(new Color(0.7f, 0.7f, 0.2f), 0.25f)); conifer.Summer.Add(new ColorVariant(new Color(0.5f, 0.5f, 0f), 0.25f)); conifer.Summer.Add(new ColorVariant(new Color(0.7f, 0.7f, 0f), 0.1f)); conifer.Fall.Add(new ColorVariant(new Color(0.8f, 0.5f, 0f), 0.25f)); conifer.Fall.Add(new ColorVariant(new Color(0.8f, 0.3f, 0f), 0.2f)); conifer.Fall.Add(new ColorVariant(new Color(0.8f, 0.2f, 0f), 0.15f)); conifer.Fall.Add(new ColorVariant(new Color(0.7f, 0.7f, 0f), 0.1f)); conifer.Winter.Add(new ColorVariant(new Color(1f, 0.98f, 0.98f), 0.45f, grayscale: true, restoreLuminance: false)); conifer.Winter.Add(new ColorVariant(new Color(1f, 1f, 1f), 0.4f, grayscale: true, restoreLuminance: false)); conifer.Winter.Add(new ColorVariant(new Color(0.98f, 0.98f, 1f), 0.45f, grayscale: true, restoreLuminance: false)); conifer.Winter.Add(new ColorVariant(new Color(1f, 1f, 1f), 0.45f, grayscale: true, restoreLuminance: false)); bush.Spring.Add(new ColorVariant(new Color(0.27f, 0.8f, 0.27f), 0.6f)); bush.Spring.Add(new ColorVariant(new Color(0.69f, 0.84f, 0.15f), 0.6f)); bush.Spring.Add(new ColorVariant(new Color(0.43f, 0.56f, 0.11f), 0.6f)); bush.Spring.Add(new ColorVariant()); bush.Summer.Add(new ColorVariant(new Color(0.5f, 0.7f, 0.2f), 0.5f)); bush.Summer.Add(new ColorVariant(new Color(0.7f, 0.7f, 0.2f), 0.5f)); bush.Summer.Add(new ColorVariant(new Color(0.5f, 0.5f, 0f), 0.5f)); bush.Summer.Add(new ColorVariant(new Color(0.7f, 0.7f, 0f), 0.2f)); bush.Fall.Add(new ColorVariant(new Color(0.8f, 0.5f, 0f), 0.5f)); bush.Fall.Add(new ColorVariant(new Color(0.8f, 0.3f, 0f), 0.5f)); bush.Fall.Add(new ColorVariant(new Color(0.8f, 0.2f, 0f), 0.4f)); bush.Fall.Add(new ColorVariant(new Color(0.7f, 0.7f, 0f), 0.2f)); bush.Winter.Add(new ColorVariant(new Color(1f, 0.98f, 0.98f), 0.65f, grayscale: true, restoreLuminance: false)); bush.Winter.Add(new ColorVariant(new Color(1f, 1f, 1f), 0.6f, grayscale: true, restoreLuminance: false)); bush.Winter.Add(new ColorVariant(new Color(0.98f, 0.98f, 1f), 0.65f, grayscale: true, restoreLuminance: false)); bush.Winter.Add(new ColorVariant(new Color(1f, 1f, 1f), 0.65f, grayscale: true, restoreLuminance: false)); creature.Winter.Add(new ColorVariant(new Color(1f, 0.98f, 0.98f), 0.25f, grayscale: true, restoreLuminance: false)); creature.Winter.Add(new ColorVariant(new Color(1f, 1f, 1f), 0.2f, grayscale: true, restoreLuminance: false)); creature.Winter.Add(new ColorVariant(new Color(0.98f, 0.98f, 1f), 0.25f, grayscale: true, restoreLuminance: false)); creature.Winter.Add(new ColorVariant(new Color(1f, 1f, 1f), 0.25f, grayscale: true, restoreLuminance: false)); piece.Winter.Add(new ColorVariant(new Color(1f, 0.98f, 0.98f), 0.4f, grayscale: true, restoreLuminance: false)); piece.Winter.Add(new ColorVariant(new Color(1f, 1f, 1f), 0.3f, grayscale: true, restoreLuminance: false)); piece.Winter.Add(new ColorVariant(new Color(0.98f, 0.98f, 1f), 0.4f, grayscale: true, restoreLuminance: false)); piece.Winter.Add(new ColorVariant(new Color(1f, 1f, 1f), 0.4f, grayscale: true, restoreLuminance: false)); prefabOverrides.Add(new PrefabOverrides(new List { "lox" }, new SeasonalColorVariants { Winter = new List { new ColorVariant(new Color(1f, 0.98f, 0.98f), 0.5f, grayscale: true, restoreLuminance: false), new ColorVariant(new Color(1f, 1f, 1f), 0.4f, grayscale: true, restoreLuminance: false), new ColorVariant(new Color(0.98f, 0.98f, 1f), 0.5f, grayscale: true, restoreLuminance: false), new ColorVariant(new Color(1f, 1f, 1f), 0.5f, grayscale: true, restoreLuminance: false) } })); prefabOverrides.Add(new PrefabOverrides(new List { "goblin" }, new SeasonalColorVariants { Winter = new List { new ColorVariant(new Color(1f, 0.98f, 0.98f), 0.35f, grayscale: true, restoreLuminance: false), new ColorVariant(new Color(1f, 1f, 1f), 0.3f, grayscale: true, restoreLuminance: false), new ColorVariant(new Color(0.98f, 0.98f, 1f), 0.35f, grayscale: true, restoreLuminance: false), new ColorVariant(new Color(1f, 1f, 1f), 0.35f, grayscale: true, restoreLuminance: false) } })); prefabOverrides.Add(new PrefabOverrides(new List { "YggdrasilBranch" }, new SeasonalColorVariants { Spring = seasonal.Spring, Summer = seasonal.Summer, Fall = seasonal.Fall, Winter = new List { new ColorVariant(new Color(1f, 0.98f, 0.98f), 0.21f, grayscale: true, restoreLuminance: false), new ColorVariant(new Color(1f, 1f, 1f), 0.2f, grayscale: true, restoreLuminance: false), new ColorVariant(new Color(0.98f, 0.98f, 1f), 0.21f, grayscale: true, restoreLuminance: false), new ColorVariant(new Color(1f, 1f, 1f), 0.21f, grayscale: true, restoreLuminance: false) } })); prefabOverrides.Add(new PrefabOverrides(new List { "grasscross_heath_green" }, new SeasonalColorVariants { Spring = grass.Summer, Summer = grass.Spring, Fall = grass.Summer, Winter = grass.Winter })); prefabOverrides.Add(new PrefabOverrides(new List { "instanced_heathgrass" }, new SeasonalColorVariants { Spring = grass.Spring.Select((ColorVariant variant) => JsonUtility.FromJson(JsonUtility.ToJson((object)variant))).Select(delegate(ColorVariant variant) { if (!variant.useColor) { variant = grass.Spring[0]; } variant.targetProportion += 0.2f; return variant; }).ToList(), Summer = grass.Summer, Fall = grass.Fall, Winter = grass.Winter })); materialOverrides.Add(new MaterialOverrides(new List { "Pine_tree_small_dead", "swamptree1_branch", "swamptree2_branch" }, new SeasonalColorVariants { Winter = seasonal.Winter })); materialOverrides.Add(new MaterialOverrides(new List { "Midsummerpole_mat" }, new SeasonalColorVariants { Spring = seasonal.Spring, Summer = seasonal.Summer, Fall = seasonal.Fall, Winter = seasonal.Winter })); materialOverrides.Add(new MaterialOverrides(new List { "yggdrasil_branch" }, new SeasonalColorVariants { Spring = grass.Spring, Summer = grass.Summer, Fall = grass.Fall, Winter = grass.Winter })); } public SeasonalColorVariants GetPrefabOverride(string name) { if (_prefabs.Count == 0 && prefabOverrides.Count != 0) { foreach (PrefabOverrides prefabOverride in prefabOverrides) { foreach (string item in prefabOverride.prefab) { _prefabs.Add(item, prefabOverride.colors); } } } return GeneralExtensions.GetValueSafe(_prefabs, name); } public SeasonalColorVariants GetMaterialOverride(string name) { if (_materials.Count == 0 && materialOverrides.Count != 0) { foreach (MaterialOverrides materialOverride in materialOverrides) { foreach (string item in materialOverride.material) { _materials.Add(item, materialOverride.colors); } } } return GeneralExtensions.GetValueSafe(_materials, name); } public static bool IsGrass(string shaderName) { return shaderName == "Custom/Grass"; } public static bool IsMoss(string textureName) { return textureName.IndexOf("moss", StringComparison.OrdinalIgnoreCase) >= 0; } public static bool IsPiece(Material material) { return ((Object)material.shader).name == "Custom/Piece" || ((Object)material).name.StartsWith("GoblinVillage"); } public static bool IsCreature(string shaderName) { return shaderName == "Custom/Creature"; } public static bool IsPine(string materialName, string prefab) { return materialName.IndexOf("pine", StringComparison.OrdinalIgnoreCase) >= 0 || prefab.IndexOf("pine", StringComparison.OrdinalIgnoreCase) >= 0; } public static bool IsBush(string materialName, string prefab) { return materialName.IndexOf("bush", StringComparison.OrdinalIgnoreCase) >= 0 || prefab.IndexOf("bush", StringComparison.OrdinalIgnoreCase) >= 0 || materialName.IndexOf("shrub", StringComparison.OrdinalIgnoreCase) >= 0 || prefab.IndexOf("shrub", StringComparison.OrdinalIgnoreCase) >= 0; } } [Serializable] public class ColorReplacementSpecifications { [Serializable] public class ColorFits { public FloatRange hue; public FloatRange saturation; public FloatRange luminance; public ColorFits(float hue1 = 0f, float hue2 = 360f, float s1 = 0f, float s2 = 1f, float l1 = 0f, float l2 = 1f) { hue = new FloatRange(hue1, hue2); saturation = new FloatRange(s1, s2); luminance = new FloatRange(l1, l2); } public bool Fits(HSLColor hslcolor) { return hue.Fits(hslcolor.h) && saturation.Fits(hslcolor.s) && luminance.Fits(hslcolor.l); } public override string ToString() { return $"hue:{hue} sat:{saturation} lum:{luminance}"; } } [Serializable] public class ColorSpecific { public List material = new List(); public List colors = new List(); public ColorSpecific(List material, List colors) { this.material = material; this.colors = colors; } public bool FitsMaterial(string prefabName, string rendererName, string materialName) { return MaterialFits.FitsMaterial(material, prefabName, rendererName, materialName); } public bool FitsColor(HSLColor color) { return Fits(colors, color); } } public List seasonal = new List(); public List grass = new List(); public List moss = new List(); public List specific = new List(); public ColorReplacementSpecifications(bool loadDefaults = false) { if (loadDefaults) { seasonal.Add(new ColorFits(80f, 160f, 0.15f)); seasonal.Add(new ColorFits(55f, 91f, 0.2f, 1f, 0.18f)); seasonal.Add(new ColorFits(33f, 57f, 0.28f, 1f, 0.26f)); moss.Add(new ColorFits()); grass.Add(new ColorFits(65f, 135f, 0.13f)); grass.Add(new ColorFits(55f, 65f, 0.53f, 1f, 0.5f)); grass.Add(new ColorFits(35f, 65f, 0f, 0.39f, 0.28f)); grass.Add(new ColorFits(40f, 60f, 0.4f)); specific.Add(new ColorSpecific(new List { new MaterialFits("HildirsLox"), new MaterialFits(null, "Lox"), new MaterialFits(null, "lox_ragdoll"), new MaterialFits(null, null, "Furr", only: true, partial: true) }, new List { new ColorFits(19f, 51f, 0.4f, 1f, 0f, 0.45f), new ColorFits(43f, 51f, 0f, 0.45f, 0f, 0.45f) })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "Lox_Calf", null, only: true), new MaterialFits(null, null, "Furr", only: true, partial: true) }, new List { new ColorFits(38f, 62f, 0f, 0.55f, 0.18f) })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "draugr", null, only: true, partial: true) }, new List { new ColorFits(80f, 160f, 0.15f), new ColorFits(55f, 91f, 0.19f, 1f, 0f, 0.4f) })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "Abomination", null, only: true, partial: true) }, new List { new ColorFits(80f, 160f, 0.15f), new ColorFits(55f, 91f, 0.19f, 1f, 0f, 0.5f) })); specific.Add(new ColorSpecific(new List { new MaterialFits("Dandelion") }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "grey", null, only: true, partial: true) }, new List { new ColorFits(80f, 160f, 0.15f), new ColorFits(51f, 91f, 0.18f, 1f, 0f, 0.5f) })); specific.Add(new ColorSpecific(new List { new MaterialFits("Vines_Mat", null, null, only: true) }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits("Vine_Sapling_ashlands_mat", null, null, only: true) }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits("Vines_ashlands_mat", null, null, only: true) }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "goblin_roof", null, only: true, partial: true), new MaterialFits("GoblinVillage_Cloth", null, null, only: true, partial: true) }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "darkwood_roof", null, only: true, partial: true), new MaterialFits("RoofShingles", null, null, only: true, partial: true) }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "copper_roof", null, only: true, partial: true), new MaterialFits("RoofShingles", null, null, only: true, partial: true) }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "wood_roof", null, only: true, partial: true), new MaterialFits("straw", null, null, only: true, partial: true) }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits("Pine_tree_small_dead", null, null, only: true) }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "shrub_2_heath", null, only: true), new MaterialFits("shrub_heath", null, null, only: true) }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "instanced_meadows_grass", null, only: true), new MaterialFits("grasscross_meadows", null, null, only: true) }, new List { new ColorFits(2f) })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "instanced_meadows_grass_short", null, only: true), new MaterialFits("grasscross_meadows_short", null, null, only: true) }, new List { new ColorFits(2f) })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "instanced_mistlands_grass_short", null, only: true), new MaterialFits("grasscross_mistlands_short", null, null, only: true) }, new List { new ColorFits(2f) })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "instanced_forest_groundcover_brown", null, only: true), new MaterialFits("grasscross_forest_brown", null, null, only: true) }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits("neck", null, null, only: true), new MaterialFits(null, "Neck", null, only: true), new MaterialFits(null, null, "Lillies", only: true) }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits("leafparticle", null, null, only: true, partial: true) }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "roof_wood_", null, only: true, partial: true), new MaterialFits("straw", null, null, only: true, partial: true) }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "roof_darkwood_", null, only: true, partial: true), new MaterialFits("RoofShingles", null, null, only: true, partial: true) }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "elvenwood_roof", null, only: true, partial: true), new MaterialFits("straw", null, null, only: false, partial: true), new MaterialFits("ReworkedValheim", null, null, only: false, partial: true) }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "BFP_FineWoodRoof", null, only: true, partial: true), new MaterialFits("straw", null, null, only: true, partial: true) }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "cloth_roof", null, only: true, partial: true), new MaterialFits("shipyardNewCloth", null, null, only: false, partial: true), new MaterialFits("M_Cloth_01", null, null, only: false, partial: true) }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "BFP_ClayRoof", null, only: true, partial: true), new MaterialFits("bcp_clay", null, null, only: true, partial: true) }, new List { new ColorFits() })); specific.Add(new ColorSpecific(new List { new MaterialFits(null, "piece_grausten_roof", null, only: true, partial: true), new MaterialFits("Grausten_RoofSlab_mat", null, null, only: true, partial: true) }, new List { new ColorFits() })); } } public bool ReplaceColor(Color color, bool isGrass, bool isMoss, string prefabName = null, string rendererName = null, string materialName = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (color.a == 0f) { return false; } HSLColor color2 = new HSLColor(color); if (prefabName != null || rendererName != null || materialName != null) { foreach (ColorSpecific item in specific) { if (item.FitsMaterial(prefabName, rendererName, materialName)) { return item.FitsColor(color2); } } } if (isGrass) { return Fits(grass, color2); } if (isMoss) { return Fits(moss, color2); } return Fits(seasonal, color2); } private static bool Fits(List list, HSLColor color) { foreach (ColorFits item in list) { if (item.Fits(color)) { return true; } } return false; } } [Serializable] public class MaterialFits { public string material; public string prefab; public string renderer; public bool only = false; public bool partial = false; public bool not = false; public MaterialFits(string material = null, string prefab = null, string renderer = null, bool only = false, bool partial = false, bool not = false) { this.material = material; this.prefab = prefab; this.renderer = renderer; this.only = only; this.partial = partial; this.not = not; } public bool Fits(string prefabName = null, string rendererName = null, string materialName = null) { return Compare(prefabName, prefab) || Compare(rendererName, renderer) || Compare(materialName, material); } private bool Compare(string name, string value) { if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(value)) { return false; } bool flag = (partial ? (name.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0) : (name == value)); return not ? (!flag) : flag; } public static bool FitsMaterial(List materials, string prefabName, string rendererName, string materialName) { bool flag = true; bool flag2 = false; int num = 0; foreach (MaterialFits material in materials) { if (material.only) { flag = flag && material.Fits(prefabName, rendererName, materialName); continue; } flag2 = flag2 || material.Fits(prefabName, rendererName, materialName); num++; } return flag && (num == 0 || flag2); } } [Serializable] public class ColorPositionsSettings { [Serializable] public class PositionFits { public IntRange height; public IntRange width; public bool not = false; public PositionFits(int heightStart = 0, int heightEnd = 0, int widthStart = 0, int widthEnd = 0, bool not = false) { height = new IntRange(heightStart, heightEnd); width = new IntRange(widthStart, widthEnd); this.not = not; } public bool Fits(int textureWidth, int textureHeight, int pos) { int value = pos % textureWidth; int value2 = textureHeight - pos / textureWidth; bool flag = height.Fits(value2) && width.Fits(value); return not ? (!flag) : flag; } public override string ToString() { return $"height:{height} width:{width} not:{not}"; } } [Serializable] public class PositionSpecific { public List material = new List(); public List bounds = new List(); public PositionSpecific(List material, List bounds) { this.material = material; this.bounds = bounds; } public bool FitsMaterial(string prefabName, string rendererName, string materialName) { return MaterialFits.FitsMaterial(material, prefabName, rendererName, materialName); } public bool FitsPosition(int textureWidth, int textureHeight, int pos) { return bounds.Any((PositionFits position) => position.Fits(textureWidth, textureHeight, pos)); } } public List positions = new List(); public ColorPositionsSettings(bool loadDefaults = false) { if (loadDefaults) { positions.Add(new PositionSpecific(new List { new MaterialFits("Pine_tree_", null, null, only: false, partial: true) }, new List { new PositionFits(0, 44, 0, 93, not: true) })); positions.Add(new PositionSpecific(new List { new MaterialFits("Fir_tree_sapling", null, null, only: false, partial: true) }, new List { new PositionFits(0, 11, 0, 20, not: true) })); positions.Add(new PositionSpecific(new List { new MaterialFits(null, "FirTree") }, new List { new PositionFits(0, 164, 0, 371, not: true) })); positions.Add(new PositionSpecific(new List { new MaterialFits(null, "Pinetree_01") }, new List { new PositionFits(0, 0, 127, 0, not: true) })); positions.Add(new PositionSpecific(new List { new MaterialFits("beehive") }, new List { new PositionFits(0, 46, 98) })); positions.Add(new PositionSpecific(new List { new MaterialFits("Midsummerpole_mat") }, new List { new PositionFits(0, 175), new PositionFits(0, 183, 54) })); positions.Add(new PositionSpecific(new List { new MaterialFits(null, "goblin_roof", null, only: true, partial: true), new MaterialFits("GoblinVillage_Cloth", null, null, only: true, partial: true) }, new List { new PositionFits(0, 230, 0, 130), new PositionFits(0, 85, 0, 201) })); positions.Add(new PositionSpecific(new List { new MaterialFits(null, "darkwood_roof", null, only: true, partial: true), new MaterialFits("RoofShingles", null, null, only: true, partial: true) }, new List { new PositionFits(0, 0, 0, 54) })); positions.Add(new PositionSpecific(new List { new MaterialFits(null, "copper_roof", null, only: true, partial: true), new MaterialFits("RoofShingles", null, null, only: true, partial: true) }, new List { new PositionFits(0, 0, 0, 54) })); positions.Add(new PositionSpecific(new List { new MaterialFits(null, "wood_roof", null, only: true, partial: true), new MaterialFits("straw", null, null, only: true, partial: true) }, new List { new PositionFits() })); positions.Add(new PositionSpecific(new List { new MaterialFits(null, "shrub_2_heath", null, only: true), new MaterialFits("shrub_heath", null, null, only: true) }, new List { new PositionFits(14, 0, 14) })); positions.Add(new PositionSpecific(new List { new MaterialFits(null, "instanced_meadows_grass", null, only: true), new MaterialFits("grasscross_meadows", null, null, only: true) }, new List { new PositionFits() })); positions.Add(new PositionSpecific(new List { new MaterialFits(null, "instanced_meadows_grass_short", null, only: true), new MaterialFits("grasscross_meadows_short", null, null, only: true) }, new List { new PositionFits() })); positions.Add(new PositionSpecific(new List { new MaterialFits("neck", null, null, only: true), new MaterialFits(null, "Neck", null, only: true), new MaterialFits(null, null, "Lillies", only: true) }, new List { new PositionFits(24, 40, 38, 54), new PositionFits(50, 0, 52) })); positions.Add(new PositionSpecific(new List { new MaterialFits(null, "roof_wood_", null, only: true, partial: true), new MaterialFits("straw", null, null, only: true, partial: true) }, new List { new PositionFits() })); positions.Add(new PositionSpecific(new List { new MaterialFits(null, "roof_darkwood_", null, only: true, partial: true), new MaterialFits("RoofShingles", null, null, only: true, partial: true) }, new List { new PositionFits() })); positions.Add(new PositionSpecific(new List { new MaterialFits(null, "elvenwood_roof", null, only: true, partial: true), new MaterialFits("straw", null, null, only: false, partial: true), new MaterialFits("ReworkedValheim", null, null, only: false, partial: true) }, new List { new PositionFits() })); positions.Add(new PositionSpecific(new List { new MaterialFits(null, "BFP_FineWoodRoof", null, only: true, partial: true), new MaterialFits("straw", null, null, only: true, partial: true) }, new List { new PositionFits() })); positions.Add(new PositionSpecific(new List { new MaterialFits(null, "cloth_roof", null, only: true, partial: true), new MaterialFits("shipyardNewCloth", null, null, only: false, partial: true), new MaterialFits("M_Cloth_01", null, null, only: false, partial: true) }, new List { new PositionFits() })); positions.Add(new PositionSpecific(new List { new MaterialFits(null, "BFP_ClayRoof", null, only: true, partial: true), new MaterialFits("bcp_clay", null, null, only: true, partial: true) }, new List { new PositionFits() })); positions.Add(new PositionSpecific(new List { new MaterialFits(null, "piece_grausten_roof", null, only: true, partial: true), new MaterialFits("Grausten_RoofSlab_mat", null, null, only: true, partial: true) }, new List { new PositionFits() })); positions.Add(new PositionSpecific(new List { new MaterialFits("Dandelion") }, new List { new PositionFits(0, 0, 16) })); } } public bool IsPixelToChange(Color color, int pos, TextureProperties properties, bool isGrass, bool isMoss, Material material, PositionSpecific positionSpec, ColorReplacementSpecifications.ColorSpecific colorSpec) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) if (color.a == 0f) { return false; } if (positionSpec != null && !positionSpec.FitsPosition(properties.width, properties.height, pos)) { return false; } if (colorSpec != null) { return colorSpec.FitsColor(color); } if (ColorsCacheSettings.IsCreature(((Object)material.shader).name) && positionSpec == null && colorSpec == null) { return false; } return colorReplacement.ReplaceColor(color, isGrass, isMoss); } } public const string settingsSubdirectory = "Cache settings"; public const string defaultsSubdirectory = "Defaults"; public const string materialsSettingsFileName = "Materials.json"; public const string colorsSettingsFileName = "Colors.json"; public const string colorsReplacementsFileName = "Color ranges.json"; public const string colorsPositionsFileName = "Color positions.json"; public static MaterialCacheSettings materialSettings = new MaterialCacheSettings(loadDefaults: true); public static ColorsCacheSettings colorSettings = new ColorsCacheSettings(loadDefaults: true); public static ColorReplacementSpecifications colorReplacement = new ColorReplacementSpecifications(loadDefaults: true); public static ColorPositionsSettings colorPositions = new ColorPositionsSettings(loadDefaults: true); private static SeasonalTextureVariants currentTextureVariants = Seasons.texturesVariants; private const float locationWeight = 15f; private const float branchWeight = 20f; private const float clutterWeight = 30f; private static readonly Stopwatch stopwatchController = new Stopwatch(); private const string globalRevision = "1.5.0"; private static readonly List renderers = new List(); private static readonly List mrenderers = new List(); private static readonly List srenderers = new List(); private static readonly List psrenderers = new List(); private static readonly List psystems = new List(); public static void SetCurrentTextureVariants(SeasonalTextureVariants texturesVariants) { currentTextureVariants = texturesVariants; } public static void OnCacheRevisionChange() { Seasons.LogInfo($"Cache revision updated {Seasons.cacheRevision.Value}"); if (!((ConditionalConfigSync)Seasons.configSync).InitialSyncDone && !((ConditionalConfigSync)Seasons.configSync).IsSourceOfTruth && Seasons.texturesVariants.revision != 0 && Seasons.cacheRevision.Value != Seasons.texturesVariants.revision) { ((MonoBehaviour)Seasons.instance).StartCoroutine(Seasons.texturesVariants.ReloadCache()); } } public static void SetupConfigWatcher() { string filter = "*.json"; FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(CacheSettingsDirectory(), filter); fileSystemWatcher.Changed += ReadConfigs; fileSystemWatcher.Created += ReadConfigs; fileSystemWatcher.Renamed += ReadConfigs; fileSystemWatcher.Deleted += ReadConfigs; fileSystemWatcher.IncludeSubdirectories = false; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; FileInfo[] files = new DirectoryInfo(CacheSettingsDirectory()).GetFiles("*.json", SearchOption.TopDirectoryOnly); foreach (FileInfo fileInfo in files) { ReadConfigFile(fileInfo.Name, fileInfo.FullName); } Seasons.cacheRevision.AssignValueSafe(GetRevision); } private static void ReadConfigs(object sender, FileSystemEventArgs eargs) { ReadConfigFile(eargs.Name, eargs.FullPath); if (eargs is RenamedEventArgs && GetSyncedValueToAssign((eargs as RenamedEventArgs).OldName, out var customSyncedValue, out var logMessage)) { customSyncedValue.AssignValueSafeIfChanged(""); Seasons.LogInfo(logMessage); } Seasons.cacheRevision.AssignValueSafeIfChanged(GetRevision); } private static void ReadConfigFile(string filename, string fullname) { if (GetSyncedValueToAssign(filename, out var customSyncedValue, out var logMessage)) { string value; try { value = File.ReadAllText(fullname); } catch (Exception ex) { Seasons.LogWarning("Error reading file (" + fullname + ")! Error: " + ex.Message); value = ""; logMessage += " defaults"; } customSyncedValue.AssignValueSafeIfChanged(value); Seasons.LogInfo(logMessage); } } private static bool GetSyncedValueToAssign(string filename, out CustomSyncedValue customSyncedValue, out string logMessage) { if (filename.Equals("Materials.json", StringComparison.OrdinalIgnoreCase)) { customSyncedValue = Seasons.customMaterialSettingsJSON; logMessage = "Custom materials settings loaded"; } else if (filename.Equals("Colors.json", StringComparison.OrdinalIgnoreCase)) { customSyncedValue = Seasons.customColorSettingsJSON; logMessage = "Custom color settings loaded"; } else if (filename.Equals("Color ranges.json", StringComparison.OrdinalIgnoreCase)) { customSyncedValue = Seasons.customColorReplacementJSON; logMessage = "Custom color replacements loaded"; } else if (filename.Equals("Color positions.json", StringComparison.OrdinalIgnoreCase)) { customSyncedValue = Seasons.customColorPositionsJSON; logMessage = "Custom color positions loaded"; } else { customSyncedValue = null; logMessage = ""; } return customSyncedValue != null; } public static bool GetColorVariants(string prefabName, string rendererName, Material material, string propertyName, Color color, out Color[] colors, bool isPlant) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) colors = null; bool flag = ColorsCacheSettings.IsGrass(((Object)material.shader).name); bool flag2 = ColorsCacheSettings.IsMoss(propertyName); bool flag3 = ColorsCacheSettings.IsCreature(((Object)material.shader).name); if (!colorReplacement.ReplaceColor(color, flag, flag2, prefabName, rendererName, ((Object)material).name)) { return false; } ColorsCacheSettings.SeasonalColorVariants seasonalColorVariants = colorSettings.GetPrefabOverride(prefabName) ?? colorSettings.GetMaterialOverride(((Object)material).name); if (seasonalColorVariants == null) { seasonalColorVariants = (ColorsCacheSettings.IsPine(((Object)material).name, prefabName) ? colorSettings.conifer : (ColorsCacheSettings.IsPiece(material) ? colorSettings.piece : ((flag || isPlant) ? colorSettings.grass : (flag2 ? colorSettings.moss : (flag3 ? colorSettings.creature : ((!ColorsCacheSettings.IsBush(((Object)material).name, prefabName)) ? colorSettings.seasonal : colorSettings.bush)))))); } List list = new List(); foreach (Seasons.Season value in Enum.GetValues(typeof(Seasons.Season))) { for (int i = 0; i <= 3; i++) { list.Add(seasonalColorVariants.GetColorVariant(value, i).MergeColors(color)); } } colors = list.ToArray(); return true; } public static bool GetTextureVariants(string prefabName, string rendererName, Material material, string propertyName, Texture texture, out TextureVariants textureVariants, bool isPlant) { //IL_01d4: Unknown result type (might be due to invalid IL or missing references) textureVariants = new TextureVariants(texture); Color[] texturePixels = GetTexturePixels(texture, textureVariants.properties, out textureVariants.originalPNG); if (texturePixels.Length < 1) { return false; } bool flag = ColorsCacheSettings.IsGrass(((Object)material.shader).name); bool flag2 = ColorsCacheSettings.IsMoss(propertyName); bool flag3 = ColorsCacheSettings.IsCreature(((Object)material.shader).name); ColorPositionsSettings.PositionSpecific positionSpec = null; foreach (ColorPositionsSettings.PositionSpecific position in colorPositions.positions) { if (position.FitsMaterial(prefabName, rendererName, ((Object)material).name)) { positionSpec = position; Seasons.LogInfo("Position specific prefab:" + prefabName + " renderer:" + rendererName + " material:" + ((Object)material).name + " " + GeneralExtensions.Join((IEnumerable)position.bounds, (Func)null, ", ")); break; } } ColorReplacementSpecifications.ColorSpecific colorSpec = null; foreach (ColorReplacementSpecifications.ColorSpecific item in colorReplacement.specific) { if (item.FitsMaterial(prefabName, rendererName, ((Object)material).name)) { colorSpec = item; Seasons.LogInfo("Color specific prefab:" + prefabName + " renderer:" + rendererName + " material:" + ((Object)material).name + " " + GeneralExtensions.Join((IEnumerable)item.colors, (Func)null, ", ")); break; } } List list = new List(); for (int i = 0; i < texturePixels.Length; i++) { if (colorPositions.IsPixelToChange(texturePixels[i], i, textureVariants.properties, flag, flag2, material, positionSpec, colorSpec)) { list.Add(i); } } if (list.Count == 0) { return false; } ColorsCacheSettings.SeasonalColorVariants seasonalColorVariants = colorSettings.GetPrefabOverride(prefabName) ?? colorSettings.GetMaterialOverride(((Object)material).name); if (seasonalColorVariants == null) { seasonalColorVariants = (ColorsCacheSettings.IsPine(((Object)material).name, prefabName) ? colorSettings.conifer : (ColorsCacheSettings.IsPiece(material) ? colorSettings.piece : ((flag || isPlant) ? colorSettings.grass : (flag2 ? colorSettings.moss : (flag3 ? colorSettings.creature : ((!ColorsCacheSettings.IsBush(((Object)material).name, prefabName)) ? colorSettings.seasonal : colorSettings.bush)))))); } foreach (Seasons.Season value in Enum.GetValues(typeof(Seasons.Season))) { List list2 = new List(); for (int j = 0; j <= 3; j++) { list2.Add(seasonalColorVariants.GetColorVariant(value, j)); } GenerateTextureVariants(value, list2.ToArray(), texturePixels, list.ToArray(), textureVariants.properties, textureVariants); } return textureVariants.Initialized(); } private static Color[] GetTexturePixels(Texture texture, TextureProperties texProperties, out byte[] originalPNG) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) RenderTexture temporary = RenderTexture.GetTemporary(texture.width, texture.height, 24, (RenderTextureFormat)0); temporary.autoGenerateMips = true; temporary.useMipMap = true; ((Texture)temporary).anisoLevel = texProperties.anisoLevel; ((Texture)temporary).mipMapBias = texProperties.mipMapBias; ((Texture)temporary).wrapMode = texProperties.wrapMode; ((Texture)temporary).filterMode = texProperties.filterMode; Graphics.Blit(texture, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val = texProperties.CreateTexture(); val.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0, true); val.Apply(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); Color[] pixels = val.GetPixels(); originalPNG = ImageConversion.EncodeToPNG(val); Object.Destroy((Object)(object)val); return pixels; } private static void GenerateTextureVariants(Seasons.Season season, ColorsCacheSettings.ColorVariant[] colorVariants, Color[] pixels, int[] pixelsToChange, TextureProperties texProperties, TextureVariants textureVariants) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) List list = new List(); for (int i = 0; i < colorVariants.Length; i++) { list.Add(pixels.ToArray()); } foreach (int num in pixelsToChange) { for (int k = 0; k < colorVariants.Length; k++) { list[k][num] = colorVariants[k].MergeColors(pixels[num]); } } for (int l = 0; l < colorVariants.Length; l++) { Texture2D val = texProperties.CreateTexture(); val.SetPixels(list[l]); val.Apply(); textureVariants.AddVariant(season, l, val); } } public static uint GetRevision() { InitSettings(); StringBuilder stringBuilder = new StringBuilder(4); stringBuilder.Append(JsonConvert.SerializeObject((object)materialSettings)); stringBuilder.Append(JsonConvert.SerializeObject((object)colorSettings)); stringBuilder.Append(JsonConvert.SerializeObject((object)colorReplacement)); stringBuilder.Append(JsonConvert.SerializeObject((object)colorPositions)); stringBuilder.Append("1.5.0"); return (uint)StringExtensionMethods.GetStableHashCode(stringBuilder.ToString()); } private static string CacheSettingsDirectory() { string text = Path.Combine(Seasons.configDirectory, "Cache settings"); Directory.CreateDirectory(text); return text; } public static void InitSettings() { if (!string.IsNullOrEmpty(Seasons.customMaterialSettingsJSON.Value)) { try { materialSettings = JsonConvert.DeserializeObject(Seasons.customMaterialSettingsJSON.Value); Seasons.LogInfo("Custom materials settings applied"); } catch (Exception arg) { materialSettings = new MaterialCacheSettings(loadDefaults: true); Seasons.LogWarning($"Error parsing custom materials settings:\n{arg}"); } } else { materialSettings = new MaterialCacheSettings(loadDefaults: true); } if (!string.IsNullOrEmpty(Seasons.customColorSettingsJSON.Value)) { try { colorSettings = JsonConvert.DeserializeObject(Seasons.customColorSettingsJSON.Value); Seasons.LogInfo("Custom color settings applied"); } catch (Exception arg2) { colorSettings = new ColorsCacheSettings(loadDefaults: true); Seasons.LogWarning($"Error parsing custom color settings:\n{arg2}"); } } else { colorSettings = new ColorsCacheSettings(loadDefaults: true); } if (!string.IsNullOrEmpty(Seasons.customColorReplacementJSON.Value)) { try { colorReplacement = JsonConvert.DeserializeObject(Seasons.customColorReplacementJSON.Value); Seasons.LogInfo("Custom color replacements applied"); } catch (Exception arg3) { colorReplacement = new ColorReplacementSpecifications(loadDefaults: true); Seasons.LogWarning($"Error parsing custom color replacements:\n{arg3}"); } } else { colorReplacement = new ColorReplacementSpecifications(loadDefaults: true); } if (!string.IsNullOrEmpty(Seasons.customColorPositionsJSON.Value)) { try { colorPositions = JsonConvert.DeserializeObject(Seasons.customColorPositionsJSON.Value); Seasons.LogInfo("Custom color positions applied"); return; } catch (Exception arg4) { colorPositions = new ColorPositionsSettings(loadDefaults: true); Seasons.LogWarning($"Error parsing custom color positions:\n{arg4}"); return; } } colorPositions = new ColorPositionsSettings(loadDefaults: true); } public static void SaveDefaults() { string text = Path.Combine(CacheSettingsDirectory(), "Defaults"); Directory.CreateDirectory(text); Seasons.LogInfo("Saving default materials settings"); File.WriteAllText(Path.Combine(text, "Materials.json"), JsonConvert.SerializeObject((object)new MaterialCacheSettings(loadDefaults: true), (Formatting)1)); Seasons.LogInfo("Saving default colors settings"); File.WriteAllText(Path.Combine(text, "Colors.json"), JsonConvert.SerializeObject((object)new ColorsCacheSettings(loadDefaults: true), (Formatting)1)); Seasons.LogInfo("Saving default colors ranges"); File.WriteAllText(Path.Combine(text, "Color ranges.json"), JsonConvert.SerializeObject((object)new ColorReplacementSpecifications(loadDefaults: true), (Formatting)1)); Seasons.LogInfo("Saving default colors positions"); File.WriteAllText(Path.Combine(text, "Color positions.json"), JsonConvert.SerializeObject((object)new ColorPositionsSettings(loadDefaults: true), (Formatting)1)); } public static IEnumerator FillWithGameData() { Stopwatch stopwatch = Stopwatch.StartNew(); TextureCachingController.SetupLoadingIndicator(20f + (float)ClutterSystem.instance.m_clutter.Count * 30f + (float)ZNetScene.instance.m_prefabs.Count + (float)ZoneSystem.instance.m_locations.Count * 15f); Seasons.LogInfo("Initializing cache settings"); currentTextureVariants.revision = GetRevision(); Seasons.LogInfo($"Cache settings revision {currentTextureVariants.revision}"); Seasons.LogInfo("Caching yggdrasil branch"); yield return AddYggdrasilBranch(); Seasons.LogInfo("Caching clutters"); yield return AddClutters(); Seasons.LogInfo("Caching locations"); yield return AddLocations(); Seasons.LogInfo("Caching prefabs"); yield return AddZNetScenePrefabs(); stopwatch.Stop(); Seasons.LogInfo($"Created cache revision {currentTextureVariants.revision} with {currentTextureVariants.controllers.Count} controllers, {currentTextureVariants.textures.Count} textures in {stopwatch.Elapsed.TotalSeconds,-4:F2} seconds."); if (Seasons.logControllersTime.Value) { Seasons.LogInfo(""); Seasons.LogInfo($"Prefab caching time in descending order. Combined time: {new TimeSpan(currentTextureVariants.controllers.Values.Sum((PrefabController c) => c.elapsedTicks)).TotalSeconds,-4:F2} seconds"); CollectionExtensions.Do(from x in currentTextureVariants.controllers orderby x.Value.elapsedTicks descending select x.Key, (Action)LogPrefabController); } } private static void UpdateLoadingIndicator(float counter = 1f) { TextureCachingController.UpdateLoadingIndicator(counter); } private static void LogPrefabController(string prefabName) { if (currentTextureVariants.controllers.TryGetValue(prefabName, out var value)) { Seasons.LogInfo($"Processed {prefabName} {value}"); } } private static List GetMeshRenderers(this GameObject root) { mrenderers.Clear(); root.GetComponentsInChildren(false, mrenderers); return mrenderers; } private static List GetSkinnedMeshRenderers(this GameObject root) { srenderers.Clear(); root.GetComponentsInChildren(false, srenderers); return srenderers; } private static List GetParticleSystemRenderers(this GameObject root) { psrenderers.Clear(); root.GetComponentsInChildren(false, psrenderers); return psrenderers; } private static List GetParticleSystems(this GameObject root) { psystems.Clear(); root.GetComponentsInChildren(false, psystems); return psystems; } private static IEnumerator AddYggdrasilBranch() { UpdateLoadingIndicator(20f); string prefabName = "YggdrasilBranch"; Transform yggdrasilBranch = ((Component)EnvMan.instance).transform.Find(prefabName); if (!((Object)(object)yggdrasilBranch == (Object)null)) { CollectionExtensions.Do((IEnumerable)((Component)yggdrasilBranch).gameObject.GetMeshRenderers(), (Action)delegate(MeshRenderer renderer) { CacheMaterials((Renderer)(object)renderer, prefabName, -1, isSingleRenderer: false, isLodInHierarchy: false, isPlant: true); }); LogPrefabController(prefabName); yield return null; } } private static IEnumerator AddLocations() { HashSet cachedLocations = new HashSet(); bool foundNewLocations; do { foundNewLocations = false; List locations = ZoneSystem.instance.m_locations; for (int i = 0; i < locations.Count; i++) { ZoneLocation loc = locations[i]; if (loc == null || !cachedLocations.Add(loc)) { continue; } foundNewLocations = true; UpdateLoadingIndicator(15f); if (!loc.m_prefab.IsValid) { yield return null; continue; } string prefabName = loc.m_prefabName; if (materialSettings.ignorePrefab.Contains(prefabName)) { yield return null; continue; } if (materialSettings.ignorePrefabPartialName.Any((string namepart) => prefabName.Contains(namepart))) { yield return null; continue; } try { loc.m_prefab.Load(); Transform root = loc.m_prefab.Asset.transform.Find("exterior") ?? loc.m_prefab.Asset.transform; CollectionExtensions.Do((IEnumerable)((Component)root).gameObject.GetMeshRenderers(), (Action)delegate(MeshRenderer renderer) { CacheMaterials((Renderer)(object)renderer, prefabName); }); CollectionExtensions.Do((IEnumerable)((Component)root).gameObject.GetSkinnedMeshRenderers(), (Action)delegate(SkinnedMeshRenderer renderer) { CacheMaterials((Renderer)(object)renderer, prefabName); }); LogPrefabController(prefabName); } catch (Exception ex) { Exception e = ex; Seasons.LogWarning($"Skipped processing location {prefabName}. Error:\n{e}"); } finally { if (loc.m_prefab.IsValid) { loc.m_prefab.Release(); } } yield return null; } } while (foundNewLocations); } private static IEnumerator AddClutters() { HashSet cachedClutters = new HashSet(); bool foundNewClutters; InstanceRenderer irenderer = default(InstanceRenderer); do { foundNewClutters = false; List clutters = ClutterSystem.instance.m_clutter; for (int i = 0; i < clutters.Count; i++) { Clutter clutter = clutters[i]; if (clutter == null || !cachedClutters.Add(clutter)) { continue; } foundNewClutters = true; UpdateLoadingIndicator(30f); GameObject prefab = clutter.m_prefab; if ((Object)(object)prefab == (Object)null) { yield return null; continue; } string prefabName = ((Object)prefab).name; if (materialSettings.ignorePrefab.Contains(prefabName)) { yield return null; continue; } if (materialSettings.ignorePrefabPartialName.Any((string namepart) => prefabName.Contains(namepart))) { yield return null; continue; } if (prefab.TryGetComponent(ref irenderer)) { CacheMaterials((Material[])(object)new Material[1] { irenderer.m_material }, prefabName, ((Object)irenderer).name, ((object)irenderer).GetType().Name, Utils.GetPath(((Component)irenderer).transform)); } else { CollectionExtensions.Do((IEnumerable)prefab.GetMeshRenderers(), (Action)delegate(MeshRenderer renderer) { CacheMaterials((Renderer)(object)renderer, prefabName); }); } LogPrefabController(prefabName); yield return null; irenderer = null; } } while (foundNewClutters); } private static void CacheMaterials(Renderer renderer, string prefabName, int lodLevel = -1, bool isSingleRenderer = false, bool isLodInHierarchy = false, bool isPlant = false) { if (!((Object)(object)renderer.sharedMaterial == (Object)null) && !((Object)(object)renderer.sharedMaterial.shader == (Object)null)) { CacheMaterials(renderer.sharedMaterials, prefabName, ((Object)renderer).name, ((object)renderer).GetType().Name, Utils.GetPath(((Component)renderer).transform), lodLevel, isSingleRenderer, isLodInHierarchy, isPlant); } } private static void CacheMaterials(Material[] materials, string prefabName, string rendererName, string rendererType, string transformPath, int lodLevel = -1, bool isSingleRenderer = false, bool isLodInHierarchy = false, bool isPlant = false) { //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) stopwatchController.Restart(); PrefabController value = null; foreach (Material material in materials) { if ((Object)(object)material == (Object)null || !materialSettings.shadersTypes.TryGetValue(rendererType, out var value2) || !value2.Contains(((Object)material.shader).name) || (!materialSettings.materialTextures.ContainsKey(((Object)material).name) && !materialSettings.materialColors.ContainsKey(((Object)material).name) && ((materialSettings.shaderIgnoreMaterial.TryGetValue(((Object)material.shader).name, out var value3) && value3.Any((string ignore) => ((Object)material).name.IndexOf(ignore, StringComparison.OrdinalIgnoreCase) >= 0)) || (materialSettings.shaderOnlyMaterial.TryGetValue(((Object)material.shader).name, out var value4) && !value4.Any((string onlymat) => ((Object)material).name.IndexOf(onlymat, StringComparison.OrdinalIgnoreCase) >= 0))))) { continue; } bool flag = !currentTextureVariants.controllers.TryGetValue(prefabName, out value); if (flag) { value = new PrefabController(); } if (!value.renderersInHierarchy.TryGetValue(transformPath, out var value5)) { value5 = new PrefabController.CachedRenderer(rendererName, rendererType); } string[] value7; if (materialSettings.materialColors.TryGetValue(((Object)material).name, out var value6)) { string[] array = value6; foreach (string text in array) { Color color = material.GetColor(text); if (!(color == Color.clear) && !(color == Color.white) && !(color == Color.black) && GetColorVariants(prefabName, rendererName, material, text, color, out var colors, isPlant)) { value5.AddMaterialColors(material, text, colors); } } } else if (materialSettings.shaderColors.TryGetValue(((Object)material.shader).name, out value7)) { string[] array2 = value7; foreach (string text2 in array2) { Color color2 = material.GetColor(text2); if (!(color2 == Color.clear) && !(color2 == Color.white) && !(color2 == Color.black) && GetColorVariants(prefabName, rendererName, material, text2, color2, out var colors2, isPlant)) { value5.AddMaterialColors(material, text2, colors2); } } } string[] textureNames; if (materialSettings.materialTextures.TryGetValue(((Object)material).name, out var materialTextureNames)) { foreach (string item in from mat in material.GetTexturePropertyNames() where materialTextureNames.Any((string value11) => mat.IndexOf(value11, StringComparison.OrdinalIgnoreCase) >= 0) select mat) { Texture texture = material.GetTexture(item); if (!((Object)(object)texture == (Object)null)) { int instanceID = ((Object)texture).GetInstanceID(); TextureVariants textureVariants; if (currentTextureVariants.textures.ContainsKey(instanceID)) { value5.AddMaterialTexture(material, item, instanceID); } else if (GetTextureVariants(prefabName, rendererName, material, item, texture, out textureVariants, isPlant)) { currentTextureVariants.textures.Add(instanceID, textureVariants); value5.AddMaterialTexture(material, item, instanceID); } } } } else if (materialSettings.shaderTextures.TryGetValue(((Object)material.shader).name, out textureNames)) { foreach (string item2 in from mat in material.GetTexturePropertyNames() where textureNames.Any((string value11) => mat.IndexOf(value11, StringComparison.OrdinalIgnoreCase) >= 0) select mat) { Texture texture2 = material.GetTexture(item2); if (!((Object)(object)texture2 == (Object)null)) { int instanceID2 = ((Object)texture2).GetInstanceID(); TextureVariants textureVariants2; if (currentTextureVariants.textures.ContainsKey(instanceID2)) { value5.AddMaterialTexture(material, item2, instanceID2); } else if (GetTextureVariants(prefabName, rendererName, material, item2, texture2, out textureVariants2, isPlant)) { currentTextureVariants.textures.Add(instanceID2, textureVariants2); value5.AddMaterialTexture(material, item2, instanceID2); } } } } if (!value5.Initialized()) { continue; } if (lodLevel >= 0) { List value10; if (isLodInHierarchy) { if (!value.lodsInHierarchy.TryGetValue(transformPath, out var value8)) { value.lodsInHierarchy.Add(transformPath, new Dictionary>()); value8 = value.lodsInHierarchy[transformPath]; } if (!value8.TryGetValue(lodLevel, out var value9)) { value8.Add(lodLevel, new List { value5 }); } else { value9.Add(value5); } } else if (!value.lodLevelMaterials.TryGetValue(lodLevel, out value10)) { value.lodLevelMaterials.Add(lodLevel, new List { value5 }); } else { value10.Add(value5); } } else if (isSingleRenderer) { value.cachedRenderer = value5; } else if (!value.renderersInHierarchy.ContainsKey(transformPath)) { value.renderersInHierarchy.Add(transformPath, value5); } if (value.Initialized()) { if (flag) { currentTextureVariants.controllers.Add(prefabName, value); } if (isSingleRenderer) { break; } } } stopwatchController.Stop(); if (value != null) { value.elapsedTicks += stopwatchController.ElapsedTicks; } } private static IEnumerator AddZNetScenePrefabs() { HashSet cachedPrefab = new HashSet(); bool foundNewPrefabs; do { foundNewPrefabs = false; List prefabs = ZNetScene.instance.m_prefabs; int count = prefabs.Count; int step = Math.Max(1, count / 100); for (int i = 0; i < prefabs.Count; i++) { UpdateLoadingIndicator(); if (i % step == 0) { yield return null; } GameObject prefab = prefabs[i]; if (!((Object)(object)prefab == (Object)null) && !cachedPrefab.Contains(prefab)) { foundNewPrefabs = true; CacheZNetScenePrefab(prefab); } } } while (foundNewPrefabs); void CacheZNetScenePrefab(GameObject val) { if (!((Object)(object)val == (Object)null)) { cachedPrefab.Add(val); string prefabName = ((Object)val).name; Ship val2 = default(Ship); Pickable val3 = default(Pickable); Plant val4 = default(Plant); if (!materialSettings.ignorePrefab.Contains(prefabName) && !materialSettings.ignorePrefabPartialName.Any((string namepart) => prefabName.Contains(namepart)) && (val.layer != 12 || materialSettings.itemsPrefab.Contains(prefabName)) && (val.layer != 8 || materialSettings.effectPrefab.Contains(prefabName)) && (val.layer != 0 || !val.TryGetComponent(ref val2)) && (val.layer != 16 || val.TryGetComponent(ref val3) || val.TryGetComponent(ref val4)) && (val.layer != 10 || materialSettings.piecePrefab.Contains(prefabName) || materialSettings.piecePrefabPartialName.Any((string namepart) => prefabName.IndexOf(namepart, StringComparison.OrdinalIgnoreCase) >= 0) || val.TryGetComponent(ref val3) || val.TryGetComponent(ref val4))) { MineRock5 val5 = default(MineRock5); MineRock val6 = default(MineRock); if (val.layer == 15 && (val.TryGetComponent(ref val5) || val.TryGetComponent(ref val6))) { MeshRenderer componentInChildren = val.GetComponentInChildren(); if (!((Object)(object)componentInChildren == (Object)null) && !((Object)(object)((Renderer)componentInChildren).sharedMaterial == (Object)null) && !((Object)(object)((Renderer)componentInChildren).sharedMaterial.shader == (Object)null)) { CacheMaterials((Renderer)(object)componentInChildren, prefabName, -1, isSingleRenderer: true); LogPrefabController(prefabName); } } else { TimedDestruction val7 = default(TimedDestruction); if (val.TryGetComponent(ref val7)) { CollectionExtensions.Do((IEnumerable)val.GetParticleSystemRenderers(), (Action)delegate(ParticleSystemRenderer renderer) { CacheMaterials((Renderer)(object)renderer, prefabName); }); CollectionExtensions.Do((IEnumerable)val.GetParticleSystems(), (Action)delegate(ParticleSystem ps) { CacheParticleSystemStartColor(ps, prefabName); }); } if (val.layer == 8) { LODGroup componentInChildren2 = val.GetComponentInChildren(); if ((Object)(object)componentInChildren2 == (Object)null || !CachePrefabLODGroup(componentInChildren2, prefabName, isLodInHierarchy: true)) { CollectionExtensions.Do((IEnumerable)val.gameObject.GetSkinnedMeshRenderers(), (Action)delegate(SkinnedMeshRenderer renderer) { CacheMaterials((Renderer)(object)renderer, prefabName); }); } } else if (val.layer != 9) { Plant val8 = default(Plant); bool isPlant = val.TryGetComponent(ref val8); if (isPlant) { renderers.Clear(); if ((Object)(object)val8.m_healthy != (Object)null) { renderers.AddRange((IEnumerable)val8.m_healthy.GetMeshRenderers()); } if ((Object)(object)val8.m_healthyGrown != (Object)null) { renderers.AddRange((IEnumerable)val8.m_healthyGrown.GetMeshRenderers()); } if ((Object)(object)val8.m_unhealthy != (Object)null) { renderers.AddRange((IEnumerable)val8.m_unhealthy.GetMeshRenderers()); } if ((Object)(object)val8.m_unhealthyGrown != (Object)null) { renderers.AddRange((IEnumerable)val8.m_unhealthyGrown.GetMeshRenderers()); } CollectionExtensions.Do((IEnumerable)renderers, (Action)delegate(Renderer renderer) { CacheMaterials(renderer, prefabName, -1, isSingleRenderer: false, isLodInHierarchy: false, isPlant); }); } else { isPlant = val.TryGetComponent(ref val3); } WearNTear val9 = default(WearNTear); if (val.TryGetComponent(ref val9)) { LODGroup lodGroup = default(LODGroup); if ((Object)(object)val9.m_new != (Object)null && val9.m_new.TryGetComponent(ref lodGroup)) { CachePrefabLODGroup(lodGroup, prefabName, isLodInHierarchy: true); } LODGroup lodGroup2 = default(LODGroup); if ((Object)(object)val9.m_worn != (Object)null && val9.m_worn.TryGetComponent(ref lodGroup2)) { CachePrefabLODGroup(lodGroup2, prefabName, isLodInHierarchy: true); } LODGroup lodGroup3 = default(LODGroup); if ((Object)(object)val9.m_broken != (Object)null && val9.m_broken.TryGetComponent(ref lodGroup3)) { CachePrefabLODGroup(lodGroup3, prefabName, isLodInHierarchy: true); } LODGroup lodGroup4 = default(LODGroup); if ((Object)(object)val9.m_wet != (Object)null && val9.m_wet.TryGetComponent(ref lodGroup4)) { CachePrefabLODGroup(lodGroup4, prefabName, isLodInHierarchy: true); } } LODGroup componentInChildren3 = val.GetComponentInChildren(); if (componentInChildren3 == null || componentInChildren3.lodCount < 2 || !CachePrefabLODGroup(componentInChildren3, prefabName, (Object)(object)((Component)componentInChildren3).gameObject != (Object)(object)val, isPlant)) { CollectionExtensions.Do((IEnumerable)val.GetMeshRenderers(), (Action)delegate(MeshRenderer renderer) { CacheMaterials((Renderer)(object)renderer, prefabName, -1, isSingleRenderer: false, isLodInHierarchy: false, isPlant); }); } } else { LODGroup componentInChildren4 = val.GetComponentInChildren(); if ((Object)(object)componentInChildren4 == (Object)null || !CachePrefabLODGroup(componentInChildren4, prefabName, isLodInHierarchy: true)) { CollectionExtensions.Do((IEnumerable)val.GetSkinnedMeshRenderers(), (Action)delegate(SkinnedMeshRenderer renderer) { CacheMaterials((Renderer)(object)renderer, prefabName); }); } } TreeBase val10 = default(TreeBase); Destructible val11 = default(Destructible); if (val.TryGetComponent(ref val10) || val.TryGetComponent(ref val11)) { CollectionExtensions.Do((IEnumerable)val.GetParticleSystemRenderers(), (Action)delegate(ParticleSystemRenderer renderer) { CacheMaterials((Renderer)(object)renderer, prefabName); }); CollectionExtensions.Do((IEnumerable)val.GetParticleSystems(), (Action)delegate(ParticleSystem ps) { CacheParticleSystemStartColor(ps, prefabName); }); } LogPrefabController(prefabName); } } } } } private static bool CachePrefabLODGroup(LODGroup lodGroup, string prefabName, bool isLodInHierarchy, bool isPlant = false) { //IL_0014: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) bool result = false; LOD[] lODs = lodGroup.GetLODs(); for (int i = 0; i < lodGroup.lodCount; i++) { LOD val = lODs[i]; for (int j = 0; j < val.renderers.Length; j++) { Renderer val2 = val.renderers[j]; if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.sharedMaterial == (Object)null) && !((Object)(object)val2.sharedMaterial.shader == (Object)null)) { CacheMaterials(val2.sharedMaterials, prefabName, ((Object)val2).name, ((object)val2).GetType().Name, Utils.GetPath(((Component)lodGroup).transform), i, isSingleRenderer: false, isLodInHierarchy, isPlant); result = true; } } } return result; } private static void CacheParticleSystemStartColor(ParticleSystem ps, string prefabName) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) MainModule main = ps.main; MinMaxGradient startColor = ((MainModule)(ref main)).startColor; if (((MinMaxGradient)(ref startColor)).color == Color.white || (!materialSettings.particleSystemStartColors.Contains(((Object)ps).name) && !materialSettings.particleSystemStartColors.Contains(prefabName))) { return; } string path = Utils.GetPath(((Component)ps).transform); PrefabController value; bool flag = !currentTextureVariants.controllers.TryGetValue(prefabName, out value); if (flag) { value = new PrefabController(); } else if (value.particleSystemStartColors != null && value.particleSystemStartColors.ContainsKey(path)) { return; } ColorsCacheSettings.SeasonalColorVariants seasonalColorVariants = colorSettings.GetPrefabOverride(prefabName) ?? colorSettings.seasonal; List list = new List(); foreach (Seasons.Season value2 in Enum.GetValues(typeof(Seasons.Season))) { for (int i = 0; i <= 3; i++) { ColorsCacheSettings.ColorVariant colorVariant = seasonalColorVariants.GetColorVariant(value2, i); main = ps.main; startColor = ((MainModule)(ref main)).startColor; Color val = colorVariant.MergeColors(((MinMaxGradient)(ref startColor)).color); list.Add("#" + ColorUtility.ToHtmlStringRGBA(val)); } } PrefabController prefabController = value; if (prefabController.particleSystemStartColors == null) { prefabController.particleSystemStartColors = new Dictionary(); } value.particleSystemStartColors.Add(path, list.ToArray()); if (value.Initialized()) { if (flag) { currentTextureVariants.controllers.Add(prefabName, value); } Seasons.LogInfo($"Processed {prefabName}{value}"); } } } public class ClutterVariantController : MonoBehaviour { [HarmonyPatch(typeof(ClutterSystem), "Awake")] public static class ClutterSystem_Awake_AddSeasonalClutter { private static void Postfix() { if (!Object.op_Implicit((Object)(object)FejdStartup.instance)) { AddSeasonalClutter(); } } } [HarmonyPatch] public static class InstanceRenderer_AddInstance_PreventInProtectedArea { private static readonly Dictionary s_isShieldedGrassByRendererName = new Dictionary(StringComparer.Ordinal); private static bool IsShieldedGrass(InstanceRenderer instance) { string name = ((Object)instance).name; if (s_isShieldedGrassByRendererName.TryGetValue(name, out var value)) { return value; } value = s_shieldedPrefabs.ContainsKey(Utils.GetPrefabName(name)); s_isShieldedGrassByRendererName[name] = value; return value; } private static IEnumerable TargetMethods() { yield return AccessTools.Method(typeof(InstanceRenderer), "AddInstance", new Type[3] { typeof(Vector3), typeof(Quaternion), typeof(float) }, (Type[])null); yield return AccessTools.Method(typeof(InstanceRenderer), "AddInstance", new Type[2] { typeof(Vector3), typeof(Quaternion) }, (Type[])null); } [HarmonyPriority(800)] private static bool Prefix(InstanceRenderer __instance, Vector3 pos) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (!isAnyShieldActive) { return true; } bool flag = IsShieldedGrass(__instance); if (SeasonState.IsActive && Seasons.IsShieldedPosition(pos)) { return flag && ShieldDomeImageEffect_SetShieldData_ProtectedStateChange.IsCoveredByShield(pos); } return !flag; } } private static ClutterVariantController m_instance; private static readonly Dictionary prefabOffsets = new Dictionary { { "instanced_meadows_grass", 0 }, { "instanced_shrub", 1 }, { "instanced_meadows_grass_short", 2 }, { "instanced_waterlilies", 3 }, { "instanced_forest_groundcover", 1 }, { "instanced_ormbunke", 2 }, { "instanced_forest_groundcover_brown", 3 }, { "instanced_forest_groundcover_bloom", 4 }, { "instanced_heathgrass", 1 }, { "instanced_heathflowers", 2 }, { "grasscross_heath_green", 3 }, { "instanced_mistlands_grass_short", 0 }, { "instanced_mistlands_rockplant", 2 }, { "instanced_swamp_ormbunke", 1 }, { "instanced_swamp_grass_bloom", 2 }, { "instanced_swamp_grass", 3 } }; private static readonly Dictionary s_shieldedPrefabs = new Dictionary(); private static readonly List s_tempColors = new List(); private readonly Dictionary> m_materialVariants = new Dictionary>(); private readonly Dictionary> m_colorVariants = new Dictionary>(); private readonly Dictionary m_materialVariantOffset = new Dictionary(); private readonly Dictionary m_originalColors = new Dictionary(); private readonly Dictionary> m_clutterDefaults = new Dictionary>(); private static readonly List s_tempRenderers = new List(); private static float s_grassPatchSize; private static float s_amountScale; public const string c_meadowsFlowersName = "meadows flowers"; public const string c_meadowsFlowersPrefabName = "instanced_meadows_flowers"; public const string c_forestBloomName = "forest groundcover bloom"; public const string c_forestBloomPrefabName = "instanced_forest_groundcover_bloom"; public const string c_swampGrassBloomName = "swampgrass bloom"; public const string c_swampGrassBloomPrefabName = "instanced_swamp_grass_bloom"; public const string c_shieldedGrassSuffix = "_inshield_seasons"; private static GameObject s_meadowsFlowers; private static GameObject s_forestBloom; private static GameObject s_swampBloom; public static Texture2D s_instanced_meadows_flowers = new Texture2D(64, 128, (TextureFormat)4, false); public static Texture2D s_instanced_forest_groundcover_bloom = new Texture2D(32, 32, (TextureFormat)4, false); public static Texture2D s_instanced_swampgrass_bloom = new Texture2D(64, 64, (TextureFormat)4, false); private static bool isAnyShieldActive = false; public static ClutterVariantController Instance => m_instance; private void Awake() { m_instance = this; } private void Start() { s_grassPatchSize = ClutterSystem.instance.m_grassPatchSize; s_amountScale = ClutterSystem.instance.m_amountScale; m_clutterDefaults.Clear(); foreach (Clutter item in ClutterSystem.instance.m_clutter.Where((Clutter c) => (Object)(object)c?.m_prefab != (Object)null)) { string clutterName = GetClutterName(item); if (!m_clutterDefaults.ContainsKey(clutterName)) { m_clutterDefaults.Add(clutterName, Tuple.Create(item.m_enabled, item.m_scaleMin, item.m_scaleMax)); } if (!m_clutterDefaults.ContainsKey(((Object)item.m_prefab).name)) { m_clutterDefaults.Add(((Object)item.m_prefab).name, Tuple.Create(item.m_enabled, item.m_scaleMin, item.m_scaleMax)); } if (!Seasons.texturesVariants.controllers.TryGetValue(Utils.GetPrefabName(item.m_prefab), out var value)) { continue; } GameObject prefab = item.m_prefab; foreach (KeyValuePair item2 in value.renderersInHierarchy) { if (item2.Value.type == typeof(InstanceRenderer).ToString()) { AddCachedInstanceRenderer(prefab, item2.Key, item2.Value); continue; } string text = item2.Key; if (text.Contains(((Object)prefab).name)) { text = item2.Key.Substring(item2.Key.IndexOf(((Object)prefab).name) + ((Object)prefab).name.Length); if (text.StartsWith("/")) { text = text.Substring(1); } } string[] transformPath = text.Split(new char[1] { '/' }, StringSplitOptions.RemoveEmptyEntries); s_tempRenderers.Clear(); CheckRenderersInHierarchy(prefab.transform, item2.Value.type, transformPath, 0, s_tempRenderers); foreach (Renderer s_tempRenderer in s_tempRenderers) { AddMaterialVariants(((Object)prefab).name, s_tempRenderer, item2.Key, item2.Value); } } } ((Behaviour)this).enabled = m_materialVariants.Any((KeyValuePair> variant) => variant.Value.Count > 0); UpdateColors(); } private void OnEnable() { UpdateColors(); } private void OnDisable() { RevertColors(); } private void OnDestroy() { m_instance = null; } private void AddCachedInstanceRenderer(GameObject prefab, string path, PrefabController.CachedRenderer cachedRenderer) { //IL_0201: Unknown result type (might be due to invalid IL or missing references) InstanceRenderer component = prefab.GetComponent(); if ((Object)(object)component.m_material == (Object)null || m_materialVariants.ContainsKey(component.m_material) || path != Utils.GetPath(((Component)component).transform) || cachedRenderer.name != ((Object)component).name || !cachedRenderer.materials.TryGetValue(((Object)component.m_material).name, out var value) || value.shaderName != ((Object)component.m_material.shader).name) { return; } foreach (KeyValuePair textureProperty in value.textureProperties) { if (Seasons.texturesVariants.textures.ContainsKey(textureProperty.Value)) { if (!m_materialVariants.TryGetValue(component.m_material, out var value2)) { value2 = new Dictionary(); m_materialVariants.Add(component.m_material, value2); } value2.Add(textureProperty.Key, Seasons.texturesVariants.textures[textureProperty.Value]); } } Color item = default(Color); foreach (KeyValuePair colorVariant in value.colorVariants) { if (!m_colorVariants.TryGetValue(component.m_material, out var value3)) { value3 = new Dictionary(); m_colorVariants.Add(component.m_material, value3); } s_tempColors.Clear(); string[] value4 = colorVariant.Value; foreach (string text in value4) { if (ColorUtility.TryParseHtmlString(text, ref item)) { s_tempColors.Add(item); } } value3.Add(colorVariant.Key, s_tempColors.ToArray()); } m_materialVariantOffset.Add(component.m_material, GeneralExtensions.GetValueSafe(prefabOffsets, ((Object)prefab).name)); } private void CheckRenderersInHierarchy(Transform transform, string rendererType, string[] transformPath, int index, List renderers) { if (transformPath.Length == 0) { Component component = ((Component)transform).GetComponent(rendererType); Renderer val = (Renderer)(object)((component is Renderer) ? component : null); if ((Object)(object)val != (Object)null) { renderers.Add(val); } return; } for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); if (!(((Object)child).name == transformPath[index])) { continue; } if (index == transformPath.Length - 1) { Component component2 = ((Component)child).GetComponent(rendererType); Renderer val2 = (Renderer)(object)((component2 is Renderer) ? component2 : null); if ((Object)(object)val2 != (Object)null) { renderers.Add(val2); } } else { CheckRenderersInHierarchy(child, rendererType, transformPath, index + 1, renderers); } } } private void AddMaterialVariants(string prefabName, Renderer renderer, string path, PrefabController.CachedRenderer cachedRenderer) { //IL_01f9: Unknown result type (might be due to invalid IL or missing references) Color item = default(Color); for (int i = 0; i < renderer.sharedMaterials.Length; i++) { Material val = renderer.sharedMaterials[i]; if ((Object)(object)val == (Object)null) { continue; } if ((Object)(object)val == (Object)null || m_materialVariants.ContainsKey(val) || path != Utils.GetPath(((Component)renderer).transform) || cachedRenderer.name != ((Object)renderer).name || !cachedRenderer.materials.TryGetValue(((Object)val).name, out var value) || value.shaderName != ((Object)val.shader).name) { break; } foreach (KeyValuePair textureProperty in value.textureProperties) { if (Seasons.texturesVariants.textures.ContainsKey(textureProperty.Value)) { if (!m_materialVariants.TryGetValue(val, out var value2)) { value2 = new Dictionary(); m_materialVariants.Add(val, value2); } value2.Add(textureProperty.Key, Seasons.texturesVariants.textures[textureProperty.Value]); } } foreach (KeyValuePair colorVariant in value.colorVariants) { if (!m_colorVariants.TryGetValue(val, out var value3)) { value3 = new Dictionary(); m_colorVariants.Add(val, value3); } s_tempColors.Clear(); string[] value4 = colorVariant.Value; foreach (string text in value4) { if (ColorUtility.TryParseHtmlString(text, ref item)) { s_tempColors.Add(item); } } value3.Add(colorVariant.Key, s_tempColors.ToArray()); } m_materialVariantOffset.Add(val, GeneralExtensions.GetValueSafe(prefabOffsets, prefabName)); } } public void RevertColors() { //IL_00b1: 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) foreach (KeyValuePair> materialVariant in m_materialVariants) { foreach (KeyValuePair item in materialVariant.Value) { if (Object.op_Implicit((Object)(object)materialVariant.Key)) { if (item.Value.HaveOriginalTexture()) { materialVariant.Key.SetTexture(item.Key, (Texture)(object)item.Value.original); } if (m_originalColors.ContainsKey(materialVariant.Key)) { materialVariant.Key.SetColor("_Color", m_originalColors[materialVariant.Key]); } } } } foreach (KeyValuePair> colorVariant in m_colorVariants) { foreach (KeyValuePair item2 in colorVariant.Value) { if (Object.op_Implicit((Object)(object)colorVariant.Key) && m_originalColors.ContainsKey(colorVariant.Key)) { colorVariant.Key.SetColor(item2.Key, m_originalColors[colorVariant.Key]); } } } RevertGrass(); RevertSeasonalClutter(); } public void UpdateColors() { //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) int currentMainVariant = GetCurrentMainVariant(); foreach (KeyValuePair> materialVariant in m_materialVariants) { foreach (KeyValuePair item in materialVariant.Value) { int key = (currentMainVariant + GeneralExtensions.GetValueSafe(m_materialVariantOffset, materialVariant.Key)) % 4; if (item.Value.seasons.TryGetValue(Seasons.seasonState.GetCurrentSeason(), out var value) && value.TryGetValue(key, out var value2)) { if (!item.Value.HaveOriginalTexture()) { item.Value.SetOriginalTexture(materialVariant.Key.GetTexture(item.Key)); } if (!m_originalColors.ContainsKey(materialVariant.Key)) { m_originalColors.Add(materialVariant.Key, materialVariant.Key.color); } Texture2D texture; if (item.Key == "_TerrainColorTex" && materialVariant.Value.ContainsKey("_MainTex")) { materialVariant.Key.SetTexture(item.Key, (Texture)null); } else if (CustomTextures.HaveCustomTexture(item.Value.originalName, Seasons.seasonState.GetCurrentSeason(), currentMainVariant, item.Value.properties, out texture)) { materialVariant.Key.SetTexture(item.Key, (Texture)(object)texture); } else { materialVariant.Key.SetTexture(item.Key, (Texture)(object)value2); } if (materialVariant.Key.color == Color.clear) { materialVariant.Key.color = m_originalColors[materialVariant.Key]; } } } } foreach (KeyValuePair> colorVariant in m_colorVariants) { foreach (KeyValuePair item2 in colorVariant.Value) { if (!m_originalColors.ContainsKey(colorVariant.Key)) { m_originalColors.Add(colorVariant.Key, colorVariant.Key.color); } int num = (currentMainVariant + GeneralExtensions.GetValueSafe(m_materialVariantOffset, colorVariant.Key)) % 4; colorVariant.Key.SetColor(item2.Key, item2.Value[(int)Seasons.seasonState.GetCurrentSeason() * 4 + num]); } } UpdateGrass(); } public static void UpdateGrassOnSettingChanged() { if (!((Object)(object)Instance == (Object)null) && !((Object)(object)ClutterSystem.instance == (Object)null)) { Instance.UpdateGrass(); } } public void UpdateGrass() { if (!Seasons.controlGrass.Value) { RevertGrass(); return; } SeasonGrassSettings.SeasonGrass grassSettings = SeasonState.seasonGrassSettings.GetGrassSettings(); ClutterSystem.instance.m_grassPatchSize = grassSettings.m_grassPatchSize; ClutterSystem.instance.m_amountScale = grassSettings.m_amountScale; foreach (Clutter item in ClutterSystem.instance.m_clutter.Where((Clutter c) => (Object)(object)c?.m_prefab != (Object)null)) { if (Seasons.ControlGrassSize(item.m_prefab) && m_clutterDefaults.TryGetValue(GetClutterName(item), out var value)) { item.m_scaleMin = value.Item2 * grassSettings.m_scaleMin; item.m_scaleMax = value.Item3 * grassSettings.m_scaleMax; item.m_enabled = value.Item1 && item.m_scaleMax != 0f; } } UpdateSeasonalClutter(); ClutterSystem.instance.ClearAll(); } public void RevertGrass() { ClutterSystem.instance.m_grassPatchSize = s_grassPatchSize; ClutterSystem.instance.m_amountScale = s_amountScale; foreach (Clutter item in ClutterSystem.instance.m_clutter.Where((Clutter c) => (Object)(object)c?.m_prefab != (Object)null)) { if (Seasons.ControlGrassSize(item.m_prefab) && m_clutterDefaults.TryGetValue(GetClutterName(item), out var value)) { item.m_scaleMin = value.Item2; item.m_scaleMax = value.Item3; item.m_enabled = value.Item1; } } UpdateSeasonalClutter(); ClutterSystem.instance.ClearAll(); } public void UpdateSeasonalClutter() { Dictionary seasonalClutterState = SeasonState.seasonClutterSettings.GetSeasonalClutterState(); foreach (Clutter item in ClutterSystem.instance.m_clutter) { if (item == null) { continue; } if (item.m_name != null && seasonalClutterState.TryGetValue(item.m_name, out var value)) { item.m_enabled = value; } else if ((Object)(object)item.m_prefab != (Object)null) { object key; if (item == null) { key = null; } else { GameObject prefab = item.m_prefab; key = ((prefab != null) ? ((Object)prefab).name : null); } if (seasonalClutterState.TryGetValue((string)key, out var value2)) { item.m_enabled = value2; } } } } public void RevertSeasonalClutter() { Dictionary seasonalClutterState = SeasonState.seasonClutterSettings.GetSeasonalClutterState(); foreach (Clutter item in ClutterSystem.instance.m_clutter) { if (item != null) { if (item.m_name != null && seasonalClutterState.ContainsKey(item.m_name)) { item.m_enabled = false; } else if ((Object)(object)item.m_prefab != (Object)null && seasonalClutterState.ContainsKey(((Object)item.m_prefab).name)) { item.m_enabled = false; } } } } public IEnumerator UpdateDayState() { yield return (object)new WaitForSeconds(Seasons.fadeOnSeasonChangeDuration.Value); UpdateShieldActiveState(); UpdateColors(); } private int GetCurrentMainVariant() { double variantFactor = GetVariantFactor(Seasons.seasonState.GetCurrentWorldDay() / 2); if (variantFactor < -0.5) { return 0; } if (variantFactor < 0.0) { return 1; } if (variantFactor < 0.5) { return 2; } return 3; } private double GetVariantFactor(int day) { int num = ((ZNet.m_world != null) ? ZNet.m_world.m_seed : ((WorldGenerator.instance != null) ? WorldGenerator.instance.GetSeed() : 0)); if (num == 0) { num = 1; } double num2 = Math.Log10(Math.Abs(num)); return (Math.Sin((double)Math.Sign(num) * num2 * (double)day) + Math.Sin(Math.Sqrt(num2) * Math.E * (double)day) + Math.Sin(Math.PI * (double)day)) / 2.0; } private static string GetClutterName(Clutter clutter) { if (clutter == null) { return ""; } string name = clutter.m_name; GameObject prefab = clutter.m_prefab; string text = ((prefab != null) ? ((Object)prefab).name : null); if (!string.IsNullOrWhiteSpace(name) && !string.IsNullOrWhiteSpace(text)) { return name + "_" + text; } if (!string.IsNullOrWhiteSpace(text)) { return text; } return name; } internal static void AddSeasonalClutter() { AddMeadowsFlowers(); AddForestBloom(); AddSwampgrassBloom(); AddShieldedGrass(); } internal static void AddShieldedGrass() { //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown string[] array = new string[7] { "instanced_meadows_grass", "instanced_meadows_grass_short", "instanced_forest_groundcover", "instanced_forest_groundcover_brown", "instanced_heathgrass", "instanced_swamp_grass", "instanced_mistlands_grass_short" }; foreach (string clutterName in array) { Clutter val = ClutterSystem.instance.m_clutter.Find(delegate(Clutter clutter) { int result; if (!(clutter?.m_name == clutterName)) { object obj; if (clutter == null) { obj = null; } else { GameObject prefab = clutter.m_prefab; obj = ((prefab != null) ? ((Object)prefab).name : null); } result = (((string?)obj == clutterName) ? 1 : 0); } else { result = 1; } return (byte)result != 0; }); if (val == null || (Object)(object)val.m_prefab == (Object)null) { continue; } string clutterShieldedName = val.m_name + "_inshield_seasons"; if (!ClutterSystem.instance.m_clutter.Any(delegate(Clutter clutter) { int result; if (!(clutter?.m_name == clutterShieldedName)) { object obj; if (clutter == null) { obj = null; } else { GameObject prefab = clutter.m_prefab; obj = ((prefab != null) ? ((Object)prefab).name : null); } result = (((string?)obj == clutterShieldedName) ? 1 : 0); } else { result = 1; } return (byte)result != 0; })) { Clutter val2 = JsonUtility.FromJson(JsonUtility.ToJson((object)val)); val2.m_name = clutterShieldedName; val2.m_enabled = false; clutterShieldedName = ((Object)val.m_prefab).name + "_inshield_seasons"; if (!s_shieldedPrefabs.TryGetValue(clutterShieldedName, out var value) || !Object.op_Implicit((Object)(object)value)) { value = CustomPrefabs.InitPrefabClone(val.m_prefab, clutterShieldedName); InstanceRenderer component = value.GetComponent(); Material material = new Material(component.m_material) { name = clutterShieldedName }; component.m_material = material; s_shieldedPrefabs.Add(((Object)value).name, value); } val2.m_prefab = value; ClutterSystem.instance.m_clutter.Add(val2); } } } internal static void AddMeadowsFlowers() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown if (ClutterSystem.instance.m_clutter.Any(delegate(Clutter clutter) { int result; if (!(clutter?.m_name == "meadows flowers")) { object obj; if (clutter == null) { obj = null; } else { GameObject prefab = clutter.m_prefab; obj = ((prefab != null) ? ((Object)prefab).name : null); } result = (((string?)obj == "instanced_meadows_flowers") ? 1 : 0); } else { result = 1; } return (byte)result != 0; })) { return; } Clutter val = ClutterSystem.instance.m_clutter.Find(delegate(Clutter clutter) { int result; if (!(clutter?.m_name == "heath flowers")) { object obj; if (clutter == null) { obj = null; } else { GameObject prefab = clutter.m_prefab; obj = ((prefab != null) ? ((Object)prefab).name : null); } result = (((string?)obj == "instanced_heathflowers") ? 1 : 0); } else { result = 1; } return (byte)result != 0; }); if (val != null && !((Object)(object)val.m_prefab == (Object)null)) { Clutter val2 = JsonUtility.FromJson(JsonUtility.ToJson((object)val)); val2.m_name = "meadows flowers"; val2.m_biome = (Biome)1; val2.m_enabled = false; if (!Object.op_Implicit((Object)(object)s_meadowsFlowers)) { s_meadowsFlowers = CustomPrefabs.InitPrefabClone(val2.m_prefab, "instanced_meadows_flowers"); Seasons.LoadTexture("instanced_meadows_flowers.png", ref s_instanced_meadows_flowers); InstanceRenderer component = s_meadowsFlowers.GetComponent(); component.m_material = new Material(component.m_material) { name = "instanced_meadows_flowers" }; component.m_material.SetTexture("_MainTex", (Texture)(object)s_instanced_meadows_flowers); } val2.m_prefab = s_meadowsFlowers; val2.m_amount = 100; val2.m_maxTilt = 25f; ClutterSystem.instance.m_clutter.Add(val2); } } internal static void AddForestBloom() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown if (ClutterSystem.instance.m_clutter.Any(delegate(Clutter clutter) { int result; if (!(clutter?.m_name == "forest groundcover bloom")) { object obj; if (clutter == null) { obj = null; } else { GameObject prefab = clutter.m_prefab; obj = ((prefab != null) ? ((Object)prefab).name : null); } result = (((string?)obj == "instanced_forest_groundcover_bloom") ? 1 : 0); } else { result = 1; } return (byte)result != 0; })) { return; } Clutter val = ClutterSystem.instance.m_clutter.Find(delegate(Clutter clutter) { int result; if (!(clutter?.m_name == "forest groundcover")) { object obj; if (clutter == null) { obj = null; } else { GameObject prefab = clutter.m_prefab; obj = ((prefab != null) ? ((Object)prefab).name : null); } result = (((string?)obj == "instanced_forest_groundcover") ? 1 : 0); } else { result = 1; } return (byte)result != 0; }); if (val != null && !((Object)(object)val.m_prefab == (Object)null)) { Clutter val2 = JsonUtility.FromJson(JsonUtility.ToJson((object)val)); val2.m_name = "forest groundcover bloom"; val2.m_biome = (Biome)8; val2.m_enabled = false; if (!Object.op_Implicit((Object)(object)s_forestBloom)) { s_forestBloom = CustomPrefabs.InitPrefabClone(val2.m_prefab, "instanced_forest_groundcover_bloom"); Seasons.LoadTexture("instanced_forest_groundcover_bloom.png", ref s_instanced_forest_groundcover_bloom); InstanceRenderer component = s_forestBloom.GetComponent(); component.m_material = new Material(component.m_material) { name = "instanced_forest_groundcover_bloom" }; component.m_material.SetTexture("_MainTex", (Texture)(object)s_instanced_forest_groundcover_bloom); } val2.m_prefab = s_forestBloom; val2.m_fractalTresholdMin = 0f; val2.m_fractalTresholdMax = 0.5f; ClutterSystem.instance.m_clutter.Add(val2); } } internal static void AddSwampgrassBloom() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown if (ClutterSystem.instance.m_clutter.Any(delegate(Clutter clutter) { int result; if (!(clutter?.m_name == "swampgrass bloom")) { object obj; if (clutter == null) { obj = null; } else { GameObject prefab = clutter.m_prefab; obj = ((prefab != null) ? ((Object)prefab).name : null); } result = (((string?)obj == "instanced_swamp_grass_bloom") ? 1 : 0); } else { result = 1; } return (byte)result != 0; })) { return; } Clutter val = ClutterSystem.instance.m_clutter.Find(delegate(Clutter clutter) { int result; if (!(clutter?.m_name == "swampgrass")) { object obj; if (clutter == null) { obj = null; } else { GameObject prefab = clutter.m_prefab; obj = ((prefab != null) ? ((Object)prefab).name : null); } result = (((string?)obj == "instanced_swamp_grass") ? 1 : 0); } else { result = 1; } return (byte)result != 0; }); if (val != null && !((Object)(object)val.m_prefab == (Object)null)) { Clutter val2 = JsonUtility.FromJson(JsonUtility.ToJson((object)val)); val2.m_name = "swampgrass bloom"; val2.m_biome = (Biome)2; val2.m_enabled = false; if (!Object.op_Implicit((Object)(object)s_swampBloom)) { s_swampBloom = CustomPrefabs.InitPrefabClone(val2.m_prefab, "instanced_swamp_grass_bloom"); Seasons.LoadTexture("instanced_swamp_grass_bloom.png", ref s_instanced_swampgrass_bloom); InstanceRenderer component = s_swampBloom.GetComponent(); component.m_material = new Material(component.m_material) { name = "instanced_swamp_grass_bloom" }; component.m_material.SetTexture("_MainTex", (Texture)(object)s_instanced_swampgrass_bloom); } val2.m_prefab = s_swampBloom; val2.m_fractalTresholdMin = 0f; val2.m_fractalTresholdMax = 0.5f; ClutterSystem.instance.m_clutter.Add(val2); } } public static void Initialize() { if (Seasons.UseTextureControllers()) { ((Component)((Component)ClutterSystem.instance).transform).gameObject.AddComponent(); } } public static void Reinitialize() { if ((Object)(object)Instance != (Object)null) { Object.Destroy((Object)(object)Instance); } m_instance = null; Seasons.LogInfo("Reinitializing clutter colors"); Initialize(); } public static void UpdateShieldActiveState() { if (isAnyShieldActive == (isAnyShieldActive = ShieldDomeImageEffect_SetShieldData_ProtectedStateChange.IsThereAnyActiveShieldedArea()) || !Object.op_Implicit((Object)(object)ClutterSystem.instance)) { return; } CollectionExtensions.Do(ClutterSystem.instance.m_clutter.Where((Clutter clutter) => clutter != null && (Object)(object)clutter.m_prefab != (Object)null && s_shieldedPrefabs.ContainsKey(((Object)clutter.m_prefab).name)), (Action)delegate(Clutter clutter) { clutter.m_enabled = isAnyShieldActive; }); CollectionExtensions.Do>(ShieldDomeImageEffect_SetShieldData_ProtectedStateChange.shieldRadius.Where((KeyValuePair kvp) => !Seasons.IsIgnoredPosition(kvp.Key.GetShieldPosition())), (Action>)delegate(KeyValuePair kvp) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) ClutterSystem instance = ClutterSystem.instance; if (instance != null) { instance.ResetGrass(kvp.Key.GetShieldPosition(), (float)(kvp.Value + 1)); } }); } } [BepInPlugin("shudnal.Seasons", "Seasons", "1.8.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInIncompatibility("RustyMods.Seasonality")] [BepInIncompatibility("TastyChickenLegs.LongerDays")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Seasons : BaseUnityPlugin { public enum Season { Spring, Summer, Fall, Winter } public enum CacheFormat { Binary, Json, SaveBothLoadBinary } public enum TimerFormat { None, CurrentDay, TimeToEnd, CurrentDayAndTimeToEnd } public enum StationHover { Vanilla, Percentage, MinutesSeconds, Bar } public enum SummerHeatStatusEffectDisplay { StatusList, RavenMenuOnly, None } public enum SummerHeatDisplayMode { Bar, Percent, None } public enum SummerHeatBarTagMode { Sup, None, Sub } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static EventHandler <>9__233_0; public static EventHandler <>9__233_1; public static EventHandler <>9__233_2; public static EventHandler <>9__233_3; public static EventHandler <>9__233_4; public static EventHandler <>9__233_5; public static EventHandler <>9__233_6; public static EventHandler <>9__233_7; public static EventHandler <>9__233_8; public static EventHandler <>9__233_9; public static EventHandler <>9__233_10; public static EventHandler <>9__233_11; public static EventHandler <>9__233_12; public static EventHandler <>9__233_13; public static EventHandler <>9__233_14; public static EventHandler <>9__233_15; public static EventHandler <>9__233_16; public static EventHandler <>9__233_17; public static EventHandler <>9__233_18; public static EventHandler <>9__233_19; public static EventHandler <>9__233_20; public static EventHandler <>9__233_21; public static EventHandler <>9__233_22; public static EventHandler <>9__233_23; public static EventHandler <>9__233_24; public static EventHandler <>9__233_25; public static EventHandler <>9__233_26; public static EventHandler <>9__233_27; public static EventHandler <>9__233_28; public static EventHandler <>9__233_29; public static EventHandler <>9__233_30; public static EventHandler <>9__233_31; public static EventHandler <>9__233_32; public static EventHandler <>9__233_33; public static EventHandler <>9__233_34; public static EventHandler <>9__233_35; public static EventHandler <>9__233_36; public static EventHandler <>9__233_37; public static EventHandler <>9__233_38; public static EventHandler <>9__233_39; public static EventHandler <>9__233_40; public static EventHandler <>9__233_41; public static EventHandler <>9__233_42; public static EventHandler <>9__233_43; public static EventHandler <>9__233_44; public static EventHandler <>9__233_45; public static EventHandler <>9__233_46; public static ConsoleEventFailable <>9__234_0; public static Func <>9__252_2; public static Func <>9__252_3; public static Func <>9__252_5; public static Func <>9__252_6; internal void b__233_0(object sender, EventArgs args) { LoadingTips.UpdateLoadingTips(); } internal void b__233_1(object sender, EventArgs args) { SeasonState.UpdateEnvironmentControlState(); } internal void b__233_2(object sender, EventArgs args) { LoadingTips.UpdateLoadingTips(); } internal void b__233_3(object sender, EventArgs args) { LoadingTips.UpdateLoadingTips(); } internal void b__233_4(object sender, EventArgs args) { SE_Season.UpdateSeasonStatusEffectStats(); LoadingTips.UpdateLoadingTips(); } internal void b__233_5(object sender, EventArgs args) { ClutterVariantController.UpdateGrassOnSettingChanged(); LoadingTips.UpdateLoadingTips(); } internal void b__233_6(object sender, EventArgs args) { LoadingTips.UpdateLoadingTips(); } internal void b__233_7(object sender, EventArgs args) { CustomTextures.UpdateTexturesOnChange(); } internal void b__233_8(object sender, EventArgs args) { LoadingTips.UpdateLoadingTips(); } internal void b__233_9(object sender, EventArgs args) { SE_Season.UpdateSeasonStatusEffectStats(); } internal void b__233_10(object sender, EventArgs args) { LoadingTips.UpdateLoadingTips(); } internal void b__233_11(object sender, EventArgs args) { FillListsToControl(); } internal void b__233_12(object sender, EventArgs args) { FillListsToControl(); } internal void b__233_13(object sender, EventArgs args) { FillListsToControl(); } internal void b__233_14(object sender, EventArgs args) { FillListsToControl(); } internal void b__233_15(object sender, EventArgs args) { seasonState?.UpdateWinterBloomEffect(); } internal void b__233_16(object sender, EventArgs args) { ZoneSystemVariantController.SnowStormReduceParticlesChanged(); } internal void b__233_17(object sender, EventArgs args) { PrefabVariantController.UpdateShieldStateAfterConfigChange(); } internal void b__233_18(object sender, EventArgs args) { PrefabVariantController.UpdateShieldStateAfterConfigChange(); } internal void b__233_19(object sender, EventArgs args) { ClutterVariantController.UpdateGrassOnSettingChanged(); } internal void b__233_20(object sender, EventArgs args) { ClutterVariantController.UpdateGrassOnSettingChanged(); } internal void b__233_21(object sender, EventArgs args) { ClutterVariantController.UpdateGrassOnSettingChanged(); } internal void b__233_22(object sender, EventArgs args) { ClutterVariantController.UpdateGrassOnSettingChanged(); } internal void b__233_23(object sender, EventArgs args) { ClutterVariantController.UpdateGrassOnSettingChanged(); } internal void b__233_24(object sender, EventArgs args) { StatusEffectHud.EnsureTimeTextRichText(); SE_Season.UpdateSeasonStatusEffectStats(); } internal void b__233_25(object sender, EventArgs args) { SeasonState.CheckSeasonChange(); } internal void b__233_26(object sender, EventArgs args) { SeasonState.CheckSeasonChange(); } internal void b__233_27(object sender, EventArgs args) { SeasonState.CheckSeasonChange(); } internal void b__233_28(object sender, EventArgs args) { SeasonState.CheckSeasonChange(); } internal void b__233_29(object sender, EventArgs args) { ZoneSystemVariantController.UpdateWaterState(); LoadingTips.UpdateLoadingTips(); } internal void b__233_30(object sender, EventArgs args) { ZoneSystemVariantController.UpdateWaterState(); } internal void b__233_31(object sender, EventArgs args) { ZoneSystemVariantController.UpdateWaterState(); } internal void b__233_32(object sender, EventArgs args) { ZoneSystemVariantController.UpdateWaterState(); } internal void b__233_33(object sender, EventArgs args) { ZoneSystemVariantController.UpdateWaterState(); } internal void b__233_34(object sender, EventArgs args) { ZoneSystemVariantController.UpdateShipsPositions(); } internal void b__233_35(object sender, EventArgs args) { ZoneSystemVariantController.UpdateFloatingPositions(); } internal void b__233_36(object sender, EventArgs args) { seasonState?.CheckOverheatStatus(Player.m_localPlayer); SummerHeatController.Instance?.RefreshState(); SummerHeatVisuals.UpdateHazeState(); LoadingTips.UpdateLoadingTips(); } internal void b__233_37(object sender, EventArgs args) { StatusEffectHud.EnsureTimeTextRichText(); } internal void b__233_38(object sender, EventArgs args) { seasonState?.UpdateGlobalKeys(); } internal void b__233_39(object sender, EventArgs args) { seasonState?.UpdateGlobalKeys(); } internal void b__233_40(object sender, EventArgs args) { seasonState?.UpdateGlobalKeys(); } internal void b__233_41(object sender, EventArgs args) { seasonState?.UpdateGlobalKeys(); } internal void b__233_42(object sender, EventArgs args) { seasonState?.UpdateGlobalKeys(); } internal void b__233_43(object sender, EventArgs args) { seasonState?.UpdateGlobalKeys(); } internal void b__233_44(object sender, EventArgs args) { ZoneSystemVariantController.UpdateTerrainColors(); } internal void b__233_45(object sender, EventArgs args) { ZoneSystemVariantController.UpdateTerrainColors(); } internal void b__233_46(object sender, EventArgs args) { ZoneSystemVariantController.UpdateTerrainColors(); } internal object b__234_0(ConsoleEventArgs args) { if (!SeasonState.IsActive) { args.Context.AddString("Start the game before rebuilding cache"); return false; } StartCacheRebuild(); args.Context.AddString("Texture cache rebuilding process started"); return true; } internal bool b__252_2(GameObject prefab) { return ControlPlantGrowth(prefab); } internal bool b__252_3(GameObject prefab) { return PlantWillSurviveWinter(prefab); } internal string b__252_5(string p) { return p.Trim().ToLower(); } internal bool b__252_6(string p) { return !string.IsNullOrWhiteSpace(p); } } public const string pluginID = "shudnal.Seasons"; public const string pluginName = "Seasons"; public const string pluginVersion = "1.8.2"; private readonly Harmony harmony = new Harmony("shudnal.Seasons"); internal static readonly ConfigSync configSync = new ConfigSync("shudnal.Seasons") { DisplayName = "Seasons", CurrentVersion = "1.8.2", MinimumRequiredVersion = "1.8.2", ModRequired = true }; private static ConfigEntry configLocked; private static ConfigEntry loggingEnabled; public static ConfigEntry dayLengthSec; public static ConfigEntry enableLoadingTips; public static ConfigEntry cacheStorageFormat; public static ConfigEntry logTime; public static ConfigEntry logFloes; public static ConfigEntry logControllersTime; public static ConfigEntry plainsSwampBorderFix; public static ConfigEntry frozenKarvePositionFix; public static ConfigEntry lastDayTerrainFactor; public static ConfigEntry firstDayTerrainFactor; public static ConfigEntry runTextureCachingSync; public static ConfigEntry overrideSeason; public static ConfigEntry seasonOverrided; public static ConfigEntry overrideSeasonDay; public static ConfigEntry seasonDayOverrided; public static ConfigEntry controlEnvironments; public static ConfigEntry controlRandomEvents; public static ConfigEntry controlLightings; public static ConfigEntry controlStats; public static ConfigEntry controlMinimap; public static ConfigEntry controlYggdrasil; public static ConfigEntry controlTraders; public static ConfigEntry controlGrass; public static ConfigEntry customTextures; public static ConfigEntry showCurrentSeasonBuff; public static ConfigEntry seasonsTimerFormat; public static ConfigEntry hideSecondsInTimer; public static ConfigEntry showCurrentSeasonInRaven; public static ConfigEntry seasonsTimerFormatInRaven; public static ConfigEntry overrideNewDayMessagesOnSeasonStartEnd; public static ConfigEntry disableBloomInWinter; public static ConfigEntry reduceSnowStormInWinter; public static ConfigEntry enableSeasonalItems; public static ConfigEntry preventDeathFromFreezing; public static ConfigEntry freezingSwimmingInWinter; public static ConfigEntry seasonalStatsOutdoorsOnly; public static ConfigEntry changeSeasonOnlyAfterSleep; public static ConfigEntry cropsDiesAfterSetDayInWinter; public static ConfigEntry cropsToSurviveInWinter; public static ConfigEntry cropsToControlGrowth; public static ConfigEntry woodListToControlDrop; public static ConfigEntry meatListToControlDrop; public static ConfigEntry shieldGeneratorProtection; public static ConfigEntry shieldGeneratorOnlyWinter; public static ConfigEntry fireHeatProtectsFromPerish; public static ConfigEntry gettingWetInWinterCausesCold; public static ConfigEntry changeNightLengthGradually; public static ConfigEntry disableTorchWarmthInInterior; public static ConfigEntry summerHeatAddsExtraWarmCloth; public static ConfigEntry gettingWetInMountainsCausesCold; public static ConfigEntry wearing2WarmPiecesPreventsWetCold; public static ConfigEntry mountainInWinterRequires2WarmPieces; public static ConfigEntry chanceToProduceACropInWinter; public static ConfigEntry secondsToFreezeForCropInWinter; public static ConfigEntry cultivatedGroundTurnsIntoDirtInWinter; public static ConfigEntry enableFrozenWater; public static ConfigEntry waterFreezesInWinterDays; public static ConfigEntry enableIceFloes; public static ConfigEntry iceFloesInWinterDays; public static ConfigEntry amountOfIceFloesInWinterDays; public static ConfigEntry enableNightMusicOnFrozenOcean; public static ConfigEntry frozenOceanSlipperiness; public static ConfigEntry placeShipAboveFrozenOcean; public static ConfigEntry placeFloatingContainersAboveFrozenOcean; public static ConfigEntry iceFloesScale; public static ConfigEntry iceFloesHealth; public static ConfigEntry summerHeatCoolingFoods; public static ConfigEntry summerHeatEnabled; public static ConfigEntry summerHeatDays; public static ConfigEntry summerHeatTimeToMax; public static ConfigEntry summerHeatGreenThreshold; public static ConfigEntry summerHeatNeutralThreshold; public static ConfigEntry summerHeatMaxThreshold; public static ConfigEntry summerHeatNightFactor; public static ConfigEntry summerHeatZoneHysteresis; public static ConfigEntry summerHeatGreenFadeWidth; public static ConfigEntry summerHeatRedRampWidth; public static ConfigEntry summerHeatMaxOverflow; public static ConfigEntry summerHeatWorldHazeEnabled; public static ConfigEntry summerHeatPersonalDistortionEnabled; public static ConfigEntry summerHeatDamageTickInterval; public static ConfigEntry summerHeatDamageHealthPerTickMinHealthPercentage; public static ConfigEntry summerHeatDamageHealthPerTick; public static ConfigEntry summerHeatDamageHitType; public static ConfigEntry summerHeatDamageMaxOnly; public static ConfigEntry summerHeatStaminaUseMultiplier; public static ConfigEntry summerHeatAdrenalineMultiplier; public static ConfigEntry summerHeatHealthRegenMultiplier; public static ConfigEntry summerHeatStaminaRegenMultiplier; public static ConfigEntry summerHeatEitrRegenMultiplier; public static ConfigEntry summerHeatNonSunnyEnvironments; public static ConfigEntry summerHeatStatusEffectDisplay; public static ConfigEntry summerHeatRavenTechnicalInfo; public static ConfigEntry summerHeatDisplayMode; public static ConfigEntry summerHeatBarTagMode; public static ConfigEntry summerHeatBarSegments; public static ConfigEntry summerHeatBarSymbol; public static ConfigEntry summerHeatBarMinBrightness; public static ConfigEntry summerHeatBarMaxBrightness; public static ConfigEntry summerHeatBarBonusColor; public static ConfigEntry summerHeatBarNeutralColor; public static ConfigEntry summerHeatBarPenaltyColor; public static ConfigEntry summerHeatBarMaxColor; public static ConfigEntry summerHeatInstantHeatSources; public static ConfigEntry summerHeatCampFireAddsHeat; public static ConfigEntry summerHeatEncumberedAddsHeat; public static ConfigEntry summerHeatWindEffectPercent; public static ConfigEntry summerHeatNoonEffectPercent; public static ConfigEntry summerHeatArmorHeatEnabled; public static ConfigEntry summerHeatOpenHelmetItems; public static ConfigEntry summerHeatBareHeadHairItems; public static ConfigEntry summerHeatLightCloakItems; public static ConfigEntry summerHeatOpenChestItems; public static ConfigEntry summerHeatOpenLegItems; public static ConfigEntry summerHeatUncoveredHeadSunHeating; public static ConfigEntry summerHeatUncoveredHeadShadeCooling; public static ConfigEntry summerHeatOpenHelmetHeating; public static ConfigEntry summerHeatClosedHelmetHeating; public static ConfigEntry summerHeatClosedHelmetCoolingPenalty; public static ConfigEntry summerHeatNoCloakHeatingReduction; public static ConfigEntry summerHeatNoCloakCoolingBonus; public static ConfigEntry summerHeatLightCloakHeatingReduction; public static ConfigEntry summerHeatLightCloakCoolingBonus; public static ConfigEntry summerHeatCloakHeating; public static ConfigEntry summerHeatColdCloakHeating; public static ConfigEntry summerHeatColdCloakCoolingPenalty; public static ConfigEntry summerHeatEmptyArmorSlotHeatingReduction; public static ConfigEntry summerHeatEmptyArmorSlotCoolingBonus; public static ConfigEntry summerHeatOpenArmorHeatingReduction; public static ConfigEntry summerHeatOpenArmorCoolingBonus; public static ConfigEntry summerHeatClosedArmorHeating; public static ConfigEntry summerHeatColdArmorHeating; public static ConfigEntry summerHeatColdArmorCoolingPenalty; public static ConfigEntry grassDefaultPatchSize; public static ConfigEntry grassDefaultAmountScale; public static ConfigEntry grassToControlSize; public static ConfigEntry grassSizeDefaultScaleMin; public static ConfigEntry grassSizeDefaultScaleMax; public static ConfigEntry showFadeOnSeasonChange; public static ConfigEntry fadeOnSeasonChangeDuration; public static ConfigEntry hoverBeeHive; public static ConfigEntry hoverBeeHiveTotal; public static ConfigEntry hoverPlant; public static ConfigEntry hoverPickable; public static ConfigEntry seasonalMinimapBorderColor; public static ConfigEntry enableSeasonalGlobalKeys; public static ConfigEntry seasonalGlobalKeyFall; public static ConfigEntry seasonalGlobalKeySpring; public static ConfigEntry seasonalGlobalKeySummer; public static ConfigEntry seasonalGlobalKeyWinter; public static ConfigEntry seasonalGlobalKeyDay; public static Seasons instance; public static SeasonState seasonState; internal const int seasonsCount = 4; public const int seasonColorVariants = 4; public static Sprite iconSpring; public static Sprite iconSummer; public static Sprite iconFall; public static Sprite iconWinter; public static Sprite iconWarm; public static Texture2D Minimap_Summer_ForestTex; public static Texture2D Minimap_Fall_ForestTex; public static Texture2D Minimap_Winter_ForestTex; public static string configDirectory; public static string cacheDirectory; public static SeasonalTextureVariants texturesVariants = new SeasonalTextureVariants(); private const int syncPrioritySeasonDay = 0; private const int syncPriorityCustomEnvironments = 700; private const int syncPriorityCustomBiomeEnvironments = 699; private const int syncPriorityCustomEvents = 698; private const int syncPriorityCustomLightings = 697; private const int syncPriorityCustomStats = 696; private const int syncPriorityCustomTraderItems = 695; private const int syncPriorityCustomWorldSettings = 694; private const int syncPriorityCustomGrassSettings = 693; private const int syncPriorityCustomClutterSettings = 692; private const int syncPriorityCustomBiomeSettings = 691; private const int syncPrioritySeasonsSettings = 690; private const int syncPriorityCustomMaterialSettings = 203; private const int syncPriorityCustomColorSettings = 202; private const int syncPriorityCustomColorReplacement = 201; private const int syncPriorityCustomColorPositions = 200; public static readonly CustomSyncedValue currentSeasonDay = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Current season and day", 1, 0, (IEqualityComparer)null); public static readonly CustomSyncedValue customEnvironmentsJSON = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Custom environments JSON", "", 700, (IEqualityComparer)null); public static readonly CustomSyncedValue customBiomeEnvironmentsJSON = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Custom biome environments JSON", "", 699, (IEqualityComparer)null); public static readonly CustomSyncedValue customEventsJSON = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Custom events JSON", "", 698, (IEqualityComparer)null); public static readonly CustomSyncedValue customLightingsJSON = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Custom lightings JSON", "", 697, (IEqualityComparer)null); public static readonly CustomSyncedValue customStatsJSON = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Custom stats JSON", "", 696, (IEqualityComparer)null); public static readonly CustomSyncedValue customTraderItemsJSON = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Custom traders JSON", "", 695, (IEqualityComparer)null); public static readonly CustomSyncedValue customWorldSettingsJSON = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Custom world settings JSON", "", 694, (IEqualityComparer)null); public static readonly CustomSyncedValue customGrassSettingsJSON = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Custom grass settings JSON", "", 693, (IEqualityComparer)null); public static readonly CustomSyncedValue customClutterSettingsJSON = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Custom clutter settings JSON", "", 692, (IEqualityComparer)null); public static readonly CustomSyncedValue customBiomeSettingsJSON = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Custom biome settings JSON", "", 691, (IEqualityComparer)null); public static readonly CustomSyncedValue> seasonsSettingsJSON = new CustomSyncedValue>((ConditionalConfigSync)(object)configSync, "Seasons settings JSON", new Dictionary(), 690, (IEqualityComparer>)DictionaryContentComparer.Instance); public static readonly CustomSyncedValue customMaterialSettingsJSON = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Custom material settings JSON", "", 203, (IEqualityComparer)null); public static readonly CustomSyncedValue customColorSettingsJSON = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Custom color settings JSON", "", 202, (IEqualityComparer)null); public static readonly CustomSyncedValue customColorReplacementJSON = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Custom color replacements JSON", "", 201, (IEqualityComparer)null); public static readonly CustomSyncedValue customColorPositionsJSON = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Custom color positions JSON", "", 200, (IEqualityComparer)null); public static readonly CustomSyncedValue cacheRevision = new CustomSyncedValue((ConditionalConfigSync)(object)configSync, "Cache revision", 0u, 100, (IEqualityComparer)null); public static Color minimapBorderColor = Color.clear; public static WaitForFixedUpdate waitForFixedUpdate = new WaitForFixedUpdate(); public static WaitForSeconds waitFor1Second = new WaitForSeconds(1f); public static WaitForSeconds waitFor5Seconds = new WaitForSeconds(5f); internal static HashSet _PlantsToControlGrowth = new HashSet(); internal static HashSet _PlantsToSurviveWinter = new HashSet(); internal static HashSet _WoodToControlDrop = new HashSet(); internal static HashSet _MeatToControlDrop = new HashSet(); internal static HashSet _GrassToControlSize = new HashSet(); private static int _instanceChangeIDShieldGeneratorCache; private static readonly Dictionary _cachedIgnoredPositions = new Dictionary(); private static readonly Dictionary _cachedShieldedPositions = new Dictionary(); private static int _cachedShieldedPositionsChangeID; private static readonly Dictionary _treeRegrowthPrefabs = new Dictionary(); private void Awake() { instance = this; MyLittleUICompat.CheckForCompatibility(); ConfigInit(); ((ConditionalConfigSync)configSync).AddLockingConfigEntry(configLocked); EpicLootCompat.CheckForCompatibility(); MarketplaceCompat.CheckForCompatibility(); EWDCompat.CheckForCompatibility(); HoneyPlusCompat.CheckForCompatibility(); harmony.PatchAll(); ((CustomSyncedValueBase)currentSeasonDay).ValueChanged += SeasonState.OnSeasonDayChange; ((CustomSyncedValueBase)customBiomeSettingsJSON).ValueChanged += SeasonState.UpdateBiomeSettings; ((CustomSyncedValueBase)customClutterSettingsJSON).ValueChanged += SeasonState.UpdateClutterSettings; ((CustomSyncedValueBase)customGrassSettingsJSON).ValueChanged += SeasonState.UpdateGrassSettings; ((CustomSyncedValueBase)customTraderItemsJSON).ValueChanged += SeasonState.UpdateTraderItems; ((CustomSyncedValueBase)customStatsJSON).ValueChanged += SeasonState.UpdateStats; ((CustomSyncedValueBase)customLightingsJSON).ValueChanged += SeasonState.UpdateLightings; ((CustomSyncedValueBase)customEventsJSON).ValueChanged += SeasonState.UpdateRandomEvents; ((CustomSyncedValueBase)customBiomeEnvironmentsJSON).ValueChanged += SeasonState.UpdateBiomeEnvironments; ((CustomSyncedValueBase)customEnvironmentsJSON).ValueChanged += SeasonState.UpdateSeasonEnvironments; ((CustomSyncedValueBase)customWorldSettingsJSON).ValueChanged += SeasonState.UpdateWorldSettings; ((CustomSyncedValueBase)seasonsSettingsJSON).ValueChanged += SeasonState.UpdateSeasonSettings; ((CustomSyncedValueBase)cacheRevision).ValueChanged += SeasonalTexturePrefabCache.OnCacheRevisionChange; Game.isModded = true; if (UseTextureControllers()) { LoadIcons(); } seasonState = new SeasonState(); ((MonoBehaviour)this).StartCoroutine(Localizer.Load()); } private void FixedUpdate() { Player localPlayer = Player.m_localPlayer; if (localPlayer != null && ((Character)localPlayer).IsOwner() && !((Character)localPlayer).IsDead()) { SummerHeatController.EnsureForPlayer(localPlayer); SEMan sEMan = ((Character)localPlayer).GetSEMan(); if (sEMan != null && !sEMan.HaveStatusEffect(SeasonsVars.s_statusEffectSeasonHash)) { sEMan.AddStatusEffect(SeasonsVars.s_statusEffectSeasonHash, false, 0, 0f); } } } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } public static void LogInfo(object data) { if (loggingEnabled.Value) { ((BaseUnityPlugin)instance).Logger.LogInfo(data); } } public static void LogWarning(object data) { ((BaseUnityPlugin)instance).Logger.LogWarning(data); } private ConfigDescription GetDescriptionSeparatedStrings(string description) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown return Chainloader.PluginInfos.ContainsKey("_shudnal.ConfigurationManager") ? new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty()) : new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { new CustomConfigs.ConfigurationManagerAttributes { CustomDrawer = CustomConfigs.DrawSeparatedStrings(",") } }); } public void ConfigInit() { //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Expected O, but got Unknown //IL_0bfe: Unknown result type (might be due to invalid IL or missing references) //IL_0c42: Unknown result type (might be due to invalid IL or missing references) //IL_0c6b: Unknown result type (might be due to invalid IL or missing references) //IL_0c94: Unknown result type (might be due to invalid IL or missing references) //IL_0ece: Unknown result type (might be due to invalid IL or missing references) //IL_0f2a: Unknown result type (might be due to invalid IL or missing references) //IL_0f34: Expected O, but got Unknown //IL_0f62: Unknown result type (might be due to invalid IL or missing references) //IL_0f6c: Expected O, but got Unknown //IL_0f9a: Unknown result type (might be due to invalid IL or missing references) //IL_0fa4: Expected O, but got Unknown //IL_0fe7: Unknown result type (might be due to invalid IL or missing references) //IL_0ff1: Expected O, but got Unknown //IL_101f: Unknown result type (might be due to invalid IL or missing references) //IL_1029: Expected O, but got Unknown //IL_1057: Unknown result type (might be due to invalid IL or missing references) //IL_1061: Expected O, but got Unknown //IL_108f: Unknown result type (might be due to invalid IL or missing references) //IL_1099: Expected O, but got Unknown //IL_10c7: Unknown result type (might be due to invalid IL or missing references) //IL_10d1: Expected O, but got Unknown //IL_11c2: Unknown result type (might be due to invalid IL or missing references) //IL_11cc: Expected O, but got Unknown //IL_120f: Unknown result type (might be due to invalid IL or missing references) //IL_1219: Expected O, but got Unknown //IL_1330: Unknown result type (might be due to invalid IL or missing references) //IL_133a: Expected O, but got Unknown //IL_137d: Unknown result type (might be due to invalid IL or missing references) //IL_1387: Expected O, but got Unknown //IL_13ca: Unknown result type (might be due to invalid IL or missing references) //IL_13d4: Expected O, but got Unknown //IL_1417: Unknown result type (might be due to invalid IL or missing references) //IL_1421: Expected O, but got Unknown //IL_1464: Unknown result type (might be due to invalid IL or missing references) //IL_146e: Expected O, but got Unknown //IL_14b1: Unknown result type (might be due to invalid IL or missing references) //IL_14bb: Expected O, but got Unknown //IL_14fe: Unknown result type (might be due to invalid IL or missing references) //IL_1508: Expected O, but got Unknown //IL_154b: Unknown result type (might be due to invalid IL or missing references) //IL_1555: Expected O, but got Unknown //IL_1598: Unknown result type (might be due to invalid IL or missing references) //IL_15a2: Expected O, but got Unknown //IL_15e5: Unknown result type (might be due to invalid IL or missing references) //IL_15ef: Expected O, but got Unknown //IL_1632: Unknown result type (might be due to invalid IL or missing references) //IL_163c: Expected O, but got Unknown //IL_167f: Unknown result type (might be due to invalid IL or missing references) //IL_1689: Expected O, but got Unknown //IL_16cc: Unknown result type (might be due to invalid IL or missing references) //IL_16d6: Expected O, but got Unknown //IL_1719: Unknown result type (might be due to invalid IL or missing references) //IL_1723: Expected O, but got Unknown //IL_1766: Unknown result type (might be due to invalid IL or missing references) //IL_1770: Expected O, but got Unknown //IL_17b3: Unknown result type (might be due to invalid IL or missing references) //IL_17bd: Expected O, but got Unknown //IL_1800: Unknown result type (might be due to invalid IL or missing references) //IL_180a: Expected O, but got Unknown //IL_184d: Unknown result type (might be due to invalid IL or missing references) //IL_1857: Expected O, but got Unknown //IL_189a: Unknown result type (might be due to invalid IL or missing references) //IL_18a4: Expected O, but got Unknown //IL_1906: Unknown result type (might be due to invalid IL or missing references) //IL_1910: Expected O, but got Unknown //IL_19a9: Unknown result type (might be due to invalid IL or missing references) //IL_19b3: Expected O, but got Unknown //IL_19f6: Unknown result type (might be due to invalid IL or missing references) //IL_1a00: Expected O, but got Unknown //IL_1a43: Unknown result type (might be due to invalid IL or missing references) //IL_1a4d: Expected O, but got Unknown //IL_1a90: Unknown result type (might be due to invalid IL or missing references) //IL_1a9a: Expected O, but got Unknown //IL_1add: Unknown result type (might be due to invalid IL or missing references) //IL_1ae7: Expected O, but got Unknown //IL_1b92: Unknown result type (might be due to invalid IL or missing references) //IL_1b9d: Expected O, but got Unknown //IL_1c00: Unknown result type (might be due to invalid IL or missing references) //IL_1c0b: Expected O, but got Unknown //IL_1c4e: Unknown result type (might be due to invalid IL or missing references) //IL_1c59: Expected O, but got Unknown //IL_1c7d: Unknown result type (might be due to invalid IL or missing references) //IL_1cb1: Unknown result type (might be due to invalid IL or missing references) //IL_1ce5: Unknown result type (might be due to invalid IL or missing references) //IL_1d19: Unknown result type (might be due to invalid IL or missing references) configLocked = serverConfig("General", "Lock Configuration", defaultValue: true, "Configuration is locked and can be changed by server admins only."); loggingEnabled = config("General", "Logging enabled", defaultValue: false, "Enable logging.", synchronizedSetting: false); dayLengthSec = serverConfig("General", "Day length in seconds", 1800L, "Day length in seconds. Vanilla - 1800 seconds. Set to 0 to disable."); enableLoadingTips = config("General", "Loading tips enabled", defaultValue: true, "Show seasonal tips on loading screen.", synchronizedSetting: false); enableLoadingTips.SettingChanged += delegate { LoadingTips.UpdateLoadingTips(); }; controlEnvironments = serverConfig("Season - Control", "Control environments", defaultValue: true, "Enables seasonal weathers"); controlRandomEvents = serverConfig("Season - Control", "Control random events", defaultValue: true, "Enables seasonal random events"); controlLightings = serverConfig("Season - Control", "Control lightings", defaultValue: true, "Enables seasonal lightings change (basically gamma or brightness)"); controlStats = serverConfig("Season - Control", "Control stats", defaultValue: true, "Enables seasonal stats change (status effect)"); controlMinimap = serverConfig("Season - Control", "Control minimap", defaultValue: true, "Enables seasonal minimap colors"); controlYggdrasil = serverConfig("Season - Control", "Control yggdrasil branch and roots", defaultValue: true, "Enables seasonal coloring of yggdrasil branch in the sky and roots on the ground"); controlTraders = serverConfig("Season - Control", "Control trader seasonal items list", defaultValue: true, "Enables seasonal changes of trader additional item availability"); controlGrass = serverConfig("Season - Control", "Control grass", defaultValue: true, "Enables seasonal changes of grass thickness, size and sparseness"); customTextures = serverConfig("Season - Control", "Custom textures", defaultValue: true, "Enables custom textures"); controlEnvironments.SettingChanged += delegate { SeasonState.UpdateEnvironmentControlState(); }; controlRandomEvents.SettingChanged += delegate { LoadingTips.UpdateLoadingTips(); }; controlLightings.SettingChanged += delegate { LoadingTips.UpdateLoadingTips(); }; controlStats.SettingChanged += delegate { SE_Season.UpdateSeasonStatusEffectStats(); LoadingTips.UpdateLoadingTips(); }; controlGrass.SettingChanged += delegate { ClutterVariantController.UpdateGrassOnSettingChanged(); LoadingTips.UpdateLoadingTips(); }; controlTraders.SettingChanged += delegate { LoadingTips.UpdateLoadingTips(); }; customTextures.SettingChanged += delegate { CustomTextures.UpdateTexturesOnChange(); }; disableBloomInWinter = config("Season", "Disable Bloom in Winter", defaultValue: true, "Force disables Bloom graphics setting while in Winter and restores it in other seasons (it will not change Graphics setting, only disables posteffect).\nBloom in Winter is what makes you blind with that much of white.", synchronizedSetting: false); reduceSnowStormInWinter = config("Season", "Reduce SnowStorm particles in Winter", new Vector2(250f, 1000f), "Reduce SnowStorm particles emission rate and maximum amount. Vanilla values is 500:2000\nFirst parameter is emission rate and second is max particles amount.\nHelps fps in Winter. Doesn't affect Mountains, Ashlands and DeepNorth.\nSet to 0:0 to return Vanilla behaviour.", synchronizedSetting: false); enableSeasonalItems = serverConfig("Season", "Enable seasonal items", defaultValue: true, "Enables seasonal (Halloween, Midsummer, Yule) items in the corresponding season"); preventDeathFromFreezing = serverConfig("Season", "Prevent death from freezing", defaultValue: true, "Prevents death from freezing when not in mountains or deep north"); seasonalStatsOutdoorsOnly = serverConfig("Season", "Seasonal stats works only outdoors", defaultValue: true, "Make seasonal stats works only outdoors"); freezingSwimmingInWinter = serverConfig("Season", "Get freezing when swimming in cold water in winter", defaultValue: true, "Swimming in cold water during winter will get you freezing debuff"); changeSeasonOnlyAfterSleep = serverConfig("Season", "Change season only after sleep", defaultValue: false, "Season can be changed regular way only after sleep"); cropsDiesAfterSetDayInWinter = serverConfig("Season", "Crops will die after set day in winter", 3, "Crops and pickables will perish after set day in winter"); fireHeatProtectsFromPerish = serverConfig("Season", "Crops will survive if protected by fire", defaultValue: true, "Crops and pickables will not perish in winter if there are fire source nearby"); chanceToProduceACropInWinter = serverConfig("Season", "Crops will have a chance to survive winter", 0.33f, new ConfigDescription("Crops and pickables will have given chance to produce a harvest instead of complete perish.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); secondsToFreezeForCropInWinter = serverConfig("Season", "Crops will be freezing for seconds until perish", 120f, "After crop is hit by winter it will not perish immediately but will start to gradually freeze to death."); cultivatedGroundTurnsIntoDirtInWinter = serverConfig("Season", "Cultivated ground turns into regular Dirt in Winter", defaultValue: true, "With the onset of winter, any ground cultivated by player turns into ordinary dirt and has to be recultivated. It happens once per year."); cropsToSurviveInWinter = serverConfig("Season", "Crops will survive in winter", "Pickable_Carrot,Pickable_Barley,Pickable_Barley_Wild,Pickable_Flax,Pickable_Flax_Wild,Pickable_Thistle,Pickable_Mushroom_Magecap", GetDescriptionSeparatedStrings("Crops and pickables from the list will not perish after set day in winter")); cropsToControlGrowth = serverConfig("Season", "Crops to control growth", "Pickable_Barley,Pickable_Barley_Wild,Pickable_Dandelion,Pickable_Flax,Pickable_Flax_Wild,Pickable_SeedCarrot,Pickable_SeedOnion,Pickable_SeedTurnip,Pickable_Thistle,Pickable_Turnip", GetDescriptionSeparatedStrings("All consumable crops will be added automatically. Set only unconsumable crops here.Crops and pickables from the list will be controlled by growth multiplier in addition to consumable crops")); woodListToControlDrop = serverConfig("Season", "Wood to control drop", "Wood,FineWood,RoundLog,ElderBark,YggdrasilWood", GetDescriptionSeparatedStrings("Wood item names to control drop from trees")); meatListToControlDrop = serverConfig("Season", "Meat to control drop", "RawMeat,DeerMeat,NeckTail,WolfMeat,LoxMeat,ChickenMeat,HareMeat,SerpentMeat", GetDescriptionSeparatedStrings("Meat item names to control drop from characters")); shieldGeneratorProtection = serverConfig("Season", "Shield generator protects from weather", defaultValue: true, "If enabled - objects inside shield generator dome will be protected from seasonal effects both positive and negative."); shieldGeneratorOnlyWinter = serverConfig("Season", "Shield generator protects from Winter only", defaultValue: true, "If enabled - objects inside shield generator dome will be protected from Winter only. If disabled - protection will work through all seasons."); gettingWetInWinterCausesCold = serverConfig("Season", "Getting Wet in winter causes Cold", defaultValue: true, "If you get Wet status during winter you will get Cold status,\nunless you have frost resistance mead or you are near a fire or in shelter"); changeNightLengthGradually = serverConfig("Season", "Change night length gradually", defaultValue: true, "If enabled - night length from seasonal settings will peak at mid season and gradually change to the next season.\nIf disabled - it will be fixed value for any day of a season."); disableTorchWarmthInInterior = serverConfig("Season", "Disable torch warmth in dungeons in winter", defaultValue: true, "If enabled - torch will not provide heat in dungeons."); gettingWetInMountainsCausesCold = serverConfig("Season", "Getting Wet in Mountains causes Cold", defaultValue: true, "If you get Wet status in Mountains in dungeon you will get Cold status in all seasons,\nunless you have frost resistance mead or you are near a fire or in shelter"); wearing2WarmPiecesPreventsWetCold = serverConfig("Season", "Wearing 2 warm armor pieces prevents Cold caused by Wet", defaultValue: true, "If you get Wet status in Mountains or in Winter you will not get Cold status caused by\nGetting Wet in winter causes Cold or Getting Wet in Mountains causes Cold configs"); mountainInWinterRequires2WarmPieces = serverConfig("Season", "Mountains in Winter require 2 warm armor pieces", defaultValue: true, "If enabled - you have to wear 2 armor pieces with frost resistance in Winter or get frost resistance mead."); cropsDiesAfterSetDayInWinter.SettingChanged += delegate { LoadingTips.UpdateLoadingTips(); }; seasonalStatsOutdoorsOnly.SettingChanged += delegate { SE_Season.UpdateSeasonStatusEffectStats(); }; freezingSwimmingInWinter.SettingChanged += delegate { LoadingTips.UpdateLoadingTips(); }; cropsToSurviveInWinter.SettingChanged += delegate { FillListsToControl(); }; cropsToControlGrowth.SettingChanged += delegate { FillListsToControl(); }; woodListToControlDrop.SettingChanged += delegate { FillListsToControl(); }; meatListToControlDrop.SettingChanged += delegate { FillListsToControl(); }; disableBloomInWinter.SettingChanged += delegate { seasonState?.UpdateWinterBloomEffect(); }; reduceSnowStormInWinter.SettingChanged += delegate { ZoneSystemVariantController.SnowStormReduceParticlesChanged(); }; shieldGeneratorProtection.SettingChanged += delegate { PrefabVariantController.UpdateShieldStateAfterConfigChange(); }; shieldGeneratorOnlyWinter.SettingChanged += delegate { PrefabVariantController.UpdateShieldStateAfterConfigChange(); }; grassDefaultPatchSize = serverConfig("Season - Grass", "Default patch size", 10f, "Default size of grass patch (sparseness or how wide a single grass \"node\" is across the ground)Increase to make grass more sparse and decrease to make grass more tight"); grassDefaultAmountScale = serverConfig("Season - Grass", "Default amount scale", 1.5f, "Default amount scale (grass density or how many grass patches created around you at once)"); grassToControlSize = serverConfig("Season - Grass", "List of grass prefabs to control size", "instanced_meadows_grass,instanced_forest_groundcover_brown,instanced_forest_groundcover,instanced_swamp_grass,instanced_heathgrass,grasscross_heath_green,instanced_meadows_grass_short,instanced_heathflowers,instanced_mistlands_grass_short", GetDescriptionSeparatedStrings("Grass with set prefabs to be hidden in winter and to change size in other seasons")); grassSizeDefaultScaleMin = serverConfig("Season - Grass", "Default minimum size multiplier", 1f, "Default minimum size of grass will be multiplier by given number"); grassSizeDefaultScaleMax = serverConfig("Season - Grass", "Default maximum size multiplier", 1f, "Default maximum size of grass will be multiplier by given number"); grassDefaultPatchSize.SettingChanged += delegate { ClutterVariantController.UpdateGrassOnSettingChanged(); }; grassDefaultAmountScale.SettingChanged += delegate { ClutterVariantController.UpdateGrassOnSettingChanged(); }; grassToControlSize.SettingChanged += delegate { ClutterVariantController.UpdateGrassOnSettingChanged(); }; grassSizeDefaultScaleMin.SettingChanged += delegate { ClutterVariantController.UpdateGrassOnSettingChanged(); }; grassSizeDefaultScaleMax.SettingChanged += delegate { ClutterVariantController.UpdateGrassOnSettingChanged(); }; showCurrentSeasonBuff = config("Season - Buff", "Show current season buff", defaultValue: true, "Show current season buff."); seasonsTimerFormat = config("Season - Buff", "Timer format", TimerFormat.CurrentDay, "What to show at season buff timer"); hideSecondsInTimer = config("Season - Buff", "Hide seconds", defaultValue: true, "Hide seconds at season buff timer"); showCurrentSeasonInRaven = config("Season - Buff", "Raven menu Show current season", defaultValue: true, "Show current season tooltip in Raven menu"); seasonsTimerFormatInRaven = config("Season - Buff", "Raven menu Timer format", TimerFormat.CurrentDayAndTimeToEnd, "What to show at season buff timer in Raven menu"); overrideNewDayMessagesOnSeasonStartEnd = config("Season - Buff", "Show seasonal messages on morning", defaultValue: true, "Show messages \"Season is coming\" on last day and \"Season has come\" on first day of season"); EventHandler eventHandler = delegate { StatusEffectHud.EnsureTimeTextRichText(); SE_Season.UpdateSeasonStatusEffectStats(); }; showCurrentSeasonBuff.SettingChanged += eventHandler; seasonsTimerFormat.SettingChanged += eventHandler; hideSecondsInTimer.SettingChanged += eventHandler; showCurrentSeasonInRaven.SettingChanged += eventHandler; seasonsTimerFormatInRaven.SettingChanged += eventHandler; showFadeOnSeasonChange = config("Season - Fade", "Show fade effect on season change", defaultValue: true, "Show black fade loading screen when season is changed."); fadeOnSeasonChangeDuration = config("Season - Fade", "Duration of fade effect", 0.5f, "Fade duration"); hoverBeeHive = config("Season - UI", "Bee Hive Hover", StationHover.Vanilla, "Hover text for bee hive."); hoverBeeHiveTotal = config("Season - UI", "Bee Hive Show total", defaultValue: true, "Show total needed time/percent for bee hive."); hoverPlant = config("Season - UI", "Plants Hover", StationHover.Vanilla, "Hover text for plants."); hoverPickable = config("Season - UI", "Pickables Hover", StationHover.Vanilla, "Hover text for pickables."); seasonalMinimapBorderColor = config("Season - UI", "Seasonal colored minimap border", defaultValue: true, "Change minimap border color according to current season."); overrideSeason = serverConfig("Season - Override", "Override", defaultValue: false, "The season will be overridden by set season."); seasonOverrided = serverConfig("Season - Override", "Season", Season.Spring, "The season to set."); overrideSeasonDay = serverConfig("Season - Override", "Day override", defaultValue: false, "The season day will be overridden by set day."); seasonDayOverrided = serverConfig("Season - Override", "Day", 1, "The season day to set."); overrideSeason.SettingChanged += delegate { SeasonState.CheckSeasonChange(); }; seasonOverrided.SettingChanged += delegate { SeasonState.CheckSeasonChange(); }; overrideSeasonDay.SettingChanged += delegate { SeasonState.CheckSeasonChange(); }; seasonDayOverrided.SettingChanged += delegate { SeasonState.CheckSeasonChange(); }; enableFrozenWater = serverConfig("Season - Winter ocean", "Enable frozen water", defaultValue: true, "Enable frozen water in winter"); waterFreezesInWinterDays = serverConfig("Season - Winter ocean", "Freeze the water at given days from to", new Vector2(6f, 9f), "Water will freeze in the first set day of winter and will be unfrozen after second set day"); enableIceFloes = serverConfig("Season - Winter ocean", "Enable ice floes in winter", defaultValue: true, "Enable ice floes in winter"); iceFloesInWinterDays = serverConfig("Season - Winter ocean", "Fill the water with ice floes at given days from to", new Vector2(4f, 10f), "Ice floes will be spawned in the first set day of winter and will be removed after second set day"); amountOfIceFloesInWinterDays = serverConfig("Season - Winter ocean", "Amount of ice floes in one zone", new Vector2(10f, 20f), "Game will take random value between set numbers and will try to spawn that amount of ice floes in one zone (square 64x64)"); iceFloesScale = serverConfig("Season - Winter ocean", "Scale of ice floes", new Vector2(0.75f, 2f), "Size of spawned ice floe random to XYZ axes"); iceFloesHealth = serverConfig("Season - Winter ocean", "Health of ice floes", 20f, "Health of ice floe of average size. Health changes proportionally the volume of an ice floe. Floes respawn is required to apply changes."); enableNightMusicOnFrozenOcean = config("Season - Winter ocean", "Enable music while travelling frozen ocean at night", defaultValue: true, "Enables special frozen ocean music"); frozenOceanSlipperiness = serverConfig("Season - Winter ocean", "Frozen ocean surface slipperiness factor", 1f, "Slipperiness factor of the frozen ocean surface"); placeShipAboveFrozenOcean = serverConfig("Season - Winter ocean", "Place ship above frozen ocean surface", defaultValue: false, "Place ship above frozen ocean surface to move them without destroying"); placeFloatingContainersAboveFrozenOcean = serverConfig("Season - Winter ocean", "Place floating containers above frozen ocean surface", defaultValue: false, "Place floating containers above frozen ocean surface"); enableFrozenWater.SettingChanged += delegate { ZoneSystemVariantController.UpdateWaterState(); LoadingTips.UpdateLoadingTips(); }; enableIceFloes.SettingChanged += delegate { ZoneSystemVariantController.UpdateWaterState(); }; waterFreezesInWinterDays.SettingChanged += delegate { ZoneSystemVariantController.UpdateWaterState(); }; iceFloesInWinterDays.SettingChanged += delegate { ZoneSystemVariantController.UpdateWaterState(); }; amountOfIceFloesInWinterDays.SettingChanged += delegate { ZoneSystemVariantController.UpdateWaterState(); }; placeShipAboveFrozenOcean.SettingChanged += delegate { ZoneSystemVariantController.UpdateShipsPositions(); }; placeFloatingContainersAboveFrozenOcean.SettingChanged += delegate { ZoneSystemVariantController.UpdateFloatingPositions(); }; summerHeatCoolingFoods = serverConfig("Season - Summer heat", "Cooling foods", "Eyescream,$item_eyescream", GetDescriptionSeparatedStrings("Foods that help cool you down in summer. Use prefab names or localization keys. While a cooling food is active, new heat bursts are blocked. It also protects from the older warm-clothes overheat status when the main Summer Heat mechanic is disabled.")); summerHeatEnabled = serverConfig("Season - Summer heat", "Enabled", defaultValue: true, "Turns the new Summer Heat mechanic on or off. When disabled, the heat meter, status effect, bonuses, penalties and visual heat effects are removed. The older warm-clothes overheat status can still work if 'Warm clothes add heat' is enabled."); summerHeatAddsExtraWarmCloth = serverConfig("Season - Summer heat", "Warm clothes add heat", defaultValue: true, "Controls the older warm-clothes overheat status. The new Summer Heat mechanic uses the Armor heat settings below, so individual armor pieces can affect heat in a more detailed way."); summerHeatDays = serverConfig("Season - Summer heat", "Heat days from to", new Vector2(4f, 7f), "Which summer days can become dangerously hot. The first number starts the hot period, the second number ends it."); summerHeatTimeToMax = serverConfig("Season - Summer heat", "Time to max heat", 180f, "How long it takes to reach 100% heat while standing in direct sun with no shade, water or other cooling help."); summerHeatGreenThreshold = serverConfig("Season - Summer heat", "Comfortable heat", 25f, new ConfigDescription("Heat percent where the warm-weather bonus is strongest. With the default 25% threshold and 20% bonus range, the bonus starts at 5%, reaches full strength at 25%, then fades out by 45%.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); summerHeatNeutralThreshold = serverConfig("Season - Summer heat", "Too hot threshold", 60f, new ConfigDescription("Heat percent where penalties begin. With the default 60% threshold and 20% penalty range, negative effects start at 60% and reach full strength at 80%.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); summerHeatMaxThreshold = serverConfig("Season - Summer heat", "Overheated threshold", 95f, new ConfigDescription("Heat percent where the worst heat state begins. This is where the soft HP cap damage can become active.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); summerHeatNightFactor = serverConfig("Season - Summer heat", "Night warmth factor", 0.5f, new ConfigDescription("How warm summer nights remain compared to daytime. At 50%, night can only hold about half of the daytime heat: the air is still warm, but without direct sun you should cool down toward a safer level instead of building up to full overheating. Set to 0% to reduce the normal night heat cap to zero.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatZoneHysteresis = serverConfig("Season - Summer heat", "State switch buffer", 10f, new ConfigDescription("Small buffer around heat states, in percentage points. It prevents the status from rapidly switching back and forth when your heat is close to a boundary.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); summerHeatGreenFadeWidth = serverConfig("Season - Summer heat", "Comfortable heat range", 20f, new ConfigDescription("How wide the bonus area is around comfortable heat, in percentage points. With the default 25% threshold and 20% range, the bonus starts at 5%, reaches full strength at 25%, then fades out by 45%.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); summerHeatRedRampWidth = serverConfig("Season - Summer heat", "Penalty buildup range", 20f, new ConfigDescription("How gradually penalties build after you become too hot, in percentage points. With the default 60% threshold and 20% range, negative effects start at 60% and reach full strength at 80%.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); summerHeatMaxOverflow = serverConfig("Season - Summer heat", "Overheat buffer", 5f, new ConfigDescription("Small hidden heat reserve above 100%, in percentage points. It makes full overheating take a little time to cool off instead of disappearing instantly.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f), Array.Empty())); summerHeatWorldHazeEnabled = config("Season - Summer heat", "World heat haze", defaultValue: true, "Shows a subtle world haze during hot sunny summer days. This is only visual and does not change heat buildup."); summerHeatPersonalDistortionEnabled = config("Season - Summer heat", "Personal heat distortion", defaultValue: true, "Shows the personal camera heat distortion when your own heat rises above the comfortable range. This is only visual and does not change heat buildup."); summerHeatNonSunnyEnvironments = serverConfig("Season - Summer heat", "Weather without direct sun", "Rain,LightRain,MistlandsRain,SlimeRain,SnowStorm,Thunder,MistlandsThunder,AshlandsThunder,Ashlands_SeaStorm,Mist,Ashlands_Misty,Ashlands_RainCinder,Ashlands_CinderRain", GetDescriptionSeparatedStrings("Technical weather list. Use internal EnvMan weather object names or particle system names, separated by commas. If the current weather matches one of these names, Summer Heat treats the sky as not sunny and direct sunlight heat stops.")); summerHeatInstantHeatSources = serverConfig("Season - Summer heat", "Actions add heat", defaultValue: true, "If enabled, jumps, attacks, dodges and blocks add small heat bursts during Summer Heat."); summerHeatCampFireAddsHeat = serverConfig("Season - Summer heat", "Campfire adds heat", defaultValue: true, "If enabled, standing near a campfire can warm you up even during summer."); summerHeatEncumberedAddsHeat = serverConfig("Season - Summer heat", "Heavy load adds heat", defaultValue: true, "If enabled, carrying too much weight makes you heat up slowly."); summerHeatWindEffectPercent = serverConfig("Season - Summer heat", "Wind effect", 0.25f, new ConfigDescription("How strongly wind changes heating and cooling. With 25%, still air makes heating faster and cooling slower; strong wind does the opposite.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatNoonEffectPercent = serverConfig("Season - Summer heat", "Midday effect", 0.25f, new ConfigDescription("How much stronger the sun feels around midday. With 25%, heat builds faster and cools slower near noon.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatArmorHeatEnabled = serverConfig("Season - Summer heat - Armor heat", "Enabled", defaultValue: true, "Let equipped armor change how quickly you heat up and cool down. This replaces the simple 'two warm pieces add heat' rule inside the new Summer Heat mechanic."); summerHeatOpenHelmetItems = serverConfig("Season - Summer heat - Armor heat", "Open helmets", "HelmetAshlandsMediumHood,HelmetBerserkerUndead,HelmetBronze,HelmetDverger,HelmetFishingHat,HelmetMidsummerCrown,HelmetTrollLeather,HelmetHat1,HelmetHat2,HelmetHat5,HelmetHat6,HelmetHat7,HelmetHat10", GetDescriptionSeparatedStrings("Helmets that leave enough of the head open to trap less heat. Use prefab names or localization keys, separated by commas. Items in this list heat less than closed helmets.")); summerHeatBareHeadHairItems = serverConfig("Season - Summer heat - Armor heat", "Bare head hairstyles", "HairNone,Hair9,Hair24,Hair14", GetDescriptionSeparatedStrings("Hairstyles that leave the head fully exposed to heat. Use internal hair item names, separated by commas. When no helmet is equipped, listed hairstyles add another 20% heating in direct sun and another 20% cooling outside direct sun. For an empty hair slot, use none, bald, balded or HairNone.")); summerHeatLightCloakItems = serverConfig("Season - Summer heat - Armor heat", "Light cloaks", "", GetDescriptionSeparatedStrings("Cloaks that should behave like light summer clothing. Use prefab names or localization keys, separated by commas. Items in this list reduce heat gain and help cooling a little.")); summerHeatOpenChestItems = serverConfig("Season - Summer heat - Armor heat", "Open chest armor", "ArmorBerserkerChest,ArmorBerserkerUndeadChest", GetDescriptionSeparatedStrings("Chest pieces that leave the body more open. Use prefab names or localization keys, separated by commas. Items in this list heat less than closed armor.")); summerHeatOpenLegItems = serverConfig("Season - Summer heat - Armor heat", "Open leg armor", "ArmorBerserkerLegs,ArmorBerserkerUndeadLegs", GetDescriptionSeparatedStrings("Leg pieces that leave the body more open. Use prefab names or localization keys, separated by commas. Items in this list heat less than closed armor.")); summerHeatUncoveredHeadSunHeating = serverConfig("Season - Summer heat - Armor heat", "Uncovered head sun heating", 0.25f, new ConfigDescription("How much faster you heat up in direct sun with no helmet. At 25%, sun heat becomes 25% stronger.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatUncoveredHeadShadeCooling = serverConfig("Season - Summer heat - Armor heat", "Uncovered head shade cooling", 0.2f, new ConfigDescription("How much faster you cool down without a helmet when you are not in direct sun. At 20%, cooling becomes 20% stronger.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatOpenHelmetHeating = serverConfig("Season - Summer heat - Armor heat", "Open helmet heating", 0.1f, new ConfigDescription("Extra heat gain from helmets listed as open. At 10%, you heat up 10% faster while wearing one.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatClosedHelmetHeating = serverConfig("Season - Summer heat - Armor heat", "Closed helmet heating", 0.2f, new ConfigDescription("Extra heat gain from any helmet not listed as open. At 20%, you heat up 20% faster while wearing one.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatClosedHelmetCoolingPenalty = serverConfig("Season - Summer heat - Armor heat", "Closed helmet cooling penalty", 0.1f, new ConfigDescription("How much closed helmets slow cooling. At 10%, cooling becomes 10% weaker while wearing one.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatNoCloakHeatingReduction = serverConfig("Season - Summer heat - Armor heat", "No cloak heating reduction", 0.1f, new ConfigDescription("How much slower you heat up without a cloak. At 10%, heat gain becomes 10% weaker.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatNoCloakCoolingBonus = serverConfig("Season - Summer heat - Armor heat", "No cloak cooling bonus", 0.15f, new ConfigDescription("How much faster you cool down without a cloak. At 15%, cooling becomes 15% stronger.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatLightCloakHeatingReduction = serverConfig("Season - Summer heat - Armor heat", "Light cloak heating reduction", 0.05f, new ConfigDescription("How much slower you heat up with a cloak listed as light. At 5%, heat gain becomes 5% weaker.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatLightCloakCoolingBonus = serverConfig("Season - Summer heat - Armor heat", "Light cloak cooling bonus", 0.1f, new ConfigDescription("How much faster you cool down with a cloak listed as light. At 10%, cooling becomes 10% stronger.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatCloakHeating = serverConfig("Season - Summer heat - Armor heat", "Cloak heating", 0.15f, new ConfigDescription("Extra heat gain from ordinary cloaks. At 15%, you heat up 15% faster while wearing one.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatColdCloakHeating = serverConfig("Season - Summer heat - Armor heat", "Cold cloak heating", 0.3f, new ConfigDescription("Extra heat gain from cloaks with frost resistance. At 30%, you heat up 30% faster while wearing one.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatColdCloakCoolingPenalty = serverConfig("Season - Summer heat - Armor heat", "Cold cloak cooling penalty", 0.1f, new ConfigDescription("How much frost-resistant cloaks slow cooling. At 10%, cooling becomes 10% weaker.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatEmptyArmorSlotHeatingReduction = serverConfig("Season - Summer heat - Armor heat", "Empty body slot heating reduction", 0.1f, new ConfigDescription("How much slower you heat up for each empty chest or leg armor slot. At 10%, each empty slot reduces heat gain by 10%.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatEmptyArmorSlotCoolingBonus = serverConfig("Season - Summer heat - Armor heat", "Empty body slot cooling bonus", 0.15f, new ConfigDescription("How much faster you cool down for each empty chest or leg armor slot. At 15%, each empty slot improves cooling by 15%.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatOpenArmorHeatingReduction = serverConfig("Season - Summer heat - Armor heat", "Open armor heating reduction", 0.05f, new ConfigDescription("How much slower you heat up with chest or leg armor listed as open. At 5%, each matching item reduces heat gain by 5%.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatOpenArmorCoolingBonus = serverConfig("Season - Summer heat - Armor heat", "Open armor cooling bonus", 0.05f, new ConfigDescription("How much faster you cool down with chest or leg armor listed as open. At 5%, each matching item improves cooling by 5%.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatClosedArmorHeating = serverConfig("Season - Summer heat - Armor heat", "Closed armor heating", 0.1f, new ConfigDescription("Extra heat gain from ordinary chest and leg armor. At 10%, each closed item makes you heat up 10% faster.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatColdArmorHeating = serverConfig("Season - Summer heat - Armor heat", "Cold armor heating", 0.25f, new ConfigDescription("Extra heat gain from chest and leg armor with frost resistance. At 25%, each warm item makes you heat up 25% faster.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatColdArmorCoolingPenalty = serverConfig("Season - Summer heat - Armor heat", "Cold armor cooling penalty", 0.1f, new ConfigDescription("How much frost-resistant chest and leg armor slows cooling. At 10%, each warm item makes cooling 10% weaker.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatDamageTickInterval = serverConfig("Season - Summer heat - Damage in red zone", "Damage tick interval", 2f, "Seconds between damage ticks while heat is forcing your health down."); summerHeatDamageHealthPerTickMinHealthPercentage = serverConfig("Season - Summer heat - Damage in red zone", "Soft HP cap percentage", 0.8f, new ConfigDescription("Lowest health percentage that Summer Heat can push you toward. You will take constant damage when your HP is higher than this percent. This damage only lowers current HP toward the set mark; it does not reduce your real maximum HP. Values below 1% are treated as 1%.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatDamageHealthPerTick = serverConfig("Season - Summer heat - Damage in red zone", "Damage per tick", 2f, "How much damage is dealt each tick while Summer Heat is pushing your HP down toward the soft cap."); summerHeatDamageHitType = serverConfig("Season - Summer heat - Damage in red zone", "Damage hit type", (HitType)14, "How the game should mark this damage. Most players can leave this unchanged."); summerHeatDamageMaxOnly = serverConfig("Season - Summer heat - Damage in red zone", "Damage only when overheated", defaultValue: true, "If enabled, HP cap damage waits until the status reaches Overheated. If disabled, the damage can start as soon as the top heat damage ramp begins near the end of the red zone."); summerHeatStaminaUseMultiplier = serverConfig("Season - Summer heat - Multipliers", "Stamina use effect", 0.2f, new ConfigDescription("How strongly heat changes running stamina cost. With 20%, red heat can make running cost up to 20% more, while comfortable heat can make it cost up to 20% less.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatAdrenalineMultiplier = serverConfig("Season - Summer heat - Multipliers", "Adrenaline effect", 0.15f, new ConfigDescription("How strongly heat changes adrenaline use. With 15%, red heat can cost up to 15% more, while comfortable heat can cost up to 15% less.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatHealthRegenMultiplier = serverConfig("Season - Summer heat - Multipliers", "Health regen effect", 0.15f, new ConfigDescription("How strongly heat changes health regeneration. With 15%, red heat can reduce regeneration by up to 15%, while comfortable heat can increase it by up to 15%.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatStaminaRegenMultiplier = serverConfig("Season - Summer heat - Multipliers", "Stamina regen effect", 0.15f, new ConfigDescription("How strongly heat changes stamina regeneration. With 15%, red heat can reduce regeneration by up to 15%, while comfortable heat can increase it by up to 15%.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatEitrRegenMultiplier = serverConfig("Season - Summer heat - Multipliers", "Eitr regen effect", 0.1f, new ConfigDescription("How strongly heat changes eitr regeneration. With 10%, red heat can reduce regeneration by up to 10%, while comfortable heat can increase it by up to 10%.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); bool flag = MyLittleUICompat.IsMapStatusEffectListElementEnabled(); SummerHeatBarTagMode defaultValue = ((!flag) ? SummerHeatBarTagMode.None : SummerHeatBarTagMode.Sup); int defaultValue2 = (flag ? 12 : 10); summerHeatStatusEffectDisplay = config("Season - Summer heat - Status", "Status effect visibility", SummerHeatStatusEffectDisplay.StatusList, "Where to show the Summer Heat status effect. StatusList shows it normally, RavenMenuOnly hides it from the status list but keeps it in the Raven active effects menu, None hides it everywhere."); summerHeatRavenTechnicalInfo = config("Season - Summer heat - Status", "Raven menu technical info", defaultValue: false, "Show extra heat numbers in the Raven active effects menu. Useful for server admins while tuning the mechanic."); summerHeatDisplayMode = config("Season - Summer heat - Status", "Value display mode", SummerHeatDisplayMode.Bar, "How the status icon shows current heat: bar, percent, or nothing."); summerHeatBarTagMode = config("Season - Summer heat - Status", "Bar vertical tag", defaultValue, "Optional rich-text tag around the heat bar. Sup makes compact raised blocks, Sub lowers them, None draws the bar without vertical adjustment. Defaults to None when My Little UI custom map status-effect elements are enabled."); summerHeatBarSegments = config("Season - Summer heat - Status", "Bar segments", defaultValue2, new ConfigDescription("Number of blocks in the heat bar. Defaults to 10 when My Little UI custom map status-effect elements are enabled.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 32), Array.Empty())); summerHeatBarSymbol = config("Season - Summer heat - Status", "Bar symbol", "▄", "Character used for each heat bar block. Use one character, for example ▄, ▀, ■ or ▬."); summerHeatBarMinBrightness = config("Season - Summer heat - Status", "Bar minimum brightness", 0.2f, new ConfigDescription("Brightness of empty bar blocks. Higher values make the empty part easier to see.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatBarMaxBrightness = config("Season - Summer heat - Status", "Bar maximum brightness", 1f, new ConfigDescription("Brightness of filled bar blocks. Lower values make the whole bar less bright.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), new object[1] { new CustomConfigs.ConfigurationManagerAttributes { ShowRangeAsPercent = true } })); summerHeatBarBonusColor = config("Season - Summer heat - Status", "Bar color bonus", new Color(0.49804f, 0.72941f, 0.03529f, 1f), "Color used when current heat gives bonuses."); summerHeatBarNeutralColor = config("Season - Summer heat - Status", "Bar color neutral", new Color(0.84314f, 0.72941f, 0.03529f, 1f), "Color used when current heat is safe but gives no bonus."); summerHeatBarPenaltyColor = config("Season - Summer heat - Status", "Bar color penalty", new Color(0.6902f, 0.34902f, 0.03529f, 1f), "Color used when current heat applies penalties."); summerHeatBarMaxColor = config("Season - Summer heat - Status", "Bar color overheat", new Color(0.72941f, 0.03529f, 0.03529f, 1f), "Color used when current heat reaches the most dangerous state."); EventHandler eventHandler2 = delegate { seasonState?.CheckOverheatStatus(Player.m_localPlayer); SummerHeatController.Instance?.RefreshState(); SummerHeatVisuals.UpdateHazeState(); LoadingTips.UpdateLoadingTips(); }; summerHeatEnabled.SettingChanged += eventHandler2; summerHeatAddsExtraWarmCloth.SettingChanged += eventHandler2; summerHeatCoolingFoods.SettingChanged += eventHandler2; summerHeatDays.SettingChanged += eventHandler2; summerHeatTimeToMax.SettingChanged += eventHandler2; summerHeatGreenThreshold.SettingChanged += eventHandler2; summerHeatNeutralThreshold.SettingChanged += eventHandler2; summerHeatMaxThreshold.SettingChanged += eventHandler2; summerHeatNightFactor.SettingChanged += eventHandler2; summerHeatZoneHysteresis.SettingChanged += eventHandler2; summerHeatGreenFadeWidth.SettingChanged += eventHandler2; summerHeatRedRampWidth.SettingChanged += eventHandler2; summerHeatMaxOverflow.SettingChanged += eventHandler2; summerHeatWorldHazeEnabled.SettingChanged += eventHandler2; summerHeatPersonalDistortionEnabled.SettingChanged += eventHandler2; summerHeatNonSunnyEnvironments.SettingChanged += eventHandler2; summerHeatDamageTickInterval.SettingChanged += eventHandler2; summerHeatDamageHealthPerTickMinHealthPercentage.SettingChanged += eventHandler2; summerHeatDamageHealthPerTick.SettingChanged += eventHandler2; summerHeatDamageHitType.SettingChanged += eventHandler2; summerHeatDamageMaxOnly.SettingChanged += eventHandler2; summerHeatStaminaUseMultiplier.SettingChanged += eventHandler2; summerHeatAdrenalineMultiplier.SettingChanged += eventHandler2; summerHeatHealthRegenMultiplier.SettingChanged += eventHandler2; summerHeatStaminaRegenMultiplier.SettingChanged += eventHandler2; summerHeatEitrRegenMultiplier.SettingChanged += eventHandler2; summerHeatInstantHeatSources.SettingChanged += eventHandler2; summerHeatCampFireAddsHeat.SettingChanged += eventHandler2; summerHeatEncumberedAddsHeat.SettingChanged += eventHandler2; summerHeatWindEffectPercent.SettingChanged += eventHandler2; summerHeatNoonEffectPercent.SettingChanged += eventHandler2; summerHeatArmorHeatEnabled.SettingChanged += eventHandler2; summerHeatOpenHelmetItems.SettingChanged += eventHandler2; summerHeatBareHeadHairItems.SettingChanged += eventHandler2; summerHeatLightCloakItems.SettingChanged += eventHandler2; summerHeatOpenChestItems.SettingChanged += eventHandler2; summerHeatOpenLegItems.SettingChanged += eventHandler2; summerHeatUncoveredHeadSunHeating.SettingChanged += eventHandler2; summerHeatUncoveredHeadShadeCooling.SettingChanged += eventHandler2; summerHeatOpenHelmetHeating.SettingChanged += eventHandler2; summerHeatClosedHelmetHeating.SettingChanged += eventHandler2; summerHeatClosedHelmetCoolingPenalty.SettingChanged += eventHandler2; summerHeatNoCloakHeatingReduction.SettingChanged += eventHandler2; summerHeatNoCloakCoolingBonus.SettingChanged += eventHandler2; summerHeatLightCloakHeatingReduction.SettingChanged += eventHandler2; summerHeatLightCloakCoolingBonus.SettingChanged += eventHandler2; summerHeatCloakHeating.SettingChanged += eventHandler2; summerHeatColdCloakHeating.SettingChanged += eventHandler2; summerHeatColdCloakCoolingPenalty.SettingChanged += eventHandler2; summerHeatEmptyArmorSlotHeatingReduction.SettingChanged += eventHandler2; summerHeatEmptyArmorSlotCoolingBonus.SettingChanged += eventHandler2; summerHeatOpenArmorHeatingReduction.SettingChanged += eventHandler2; summerHeatOpenArmorCoolingBonus.SettingChanged += eventHandler2; summerHeatClosedArmorHeating.SettingChanged += eventHandler2; summerHeatColdArmorHeating.SettingChanged += eventHandler2; summerHeatColdArmorCoolingPenalty.SettingChanged += eventHandler2; EventHandler eventHandler3 = delegate { StatusEffectHud.EnsureTimeTextRichText(); }; summerHeatStatusEffectDisplay.SettingChanged += eventHandler3; summerHeatRavenTechnicalInfo.SettingChanged += eventHandler3; summerHeatDisplayMode.SettingChanged += eventHandler3; summerHeatBarTagMode.SettingChanged += eventHandler3; summerHeatBarSegments.SettingChanged += eventHandler3; summerHeatBarSymbol.SettingChanged += eventHandler3; summerHeatBarMinBrightness.SettingChanged += eventHandler3; summerHeatBarMaxBrightness.SettingChanged += eventHandler3; summerHeatBarBonusColor.SettingChanged += eventHandler3; summerHeatBarNeutralColor.SettingChanged += eventHandler3; summerHeatBarPenaltyColor.SettingChanged += eventHandler3; summerHeatBarMaxColor.SettingChanged += eventHandler3; enableSeasonalGlobalKeys = serverConfig("Seasons - Global keys", "Enable setting seasonal Global Keys", defaultValue: false, "Enables setting seasonal global key"); seasonalGlobalKeyFall = serverConfig("Seasons - Global keys", "Fall", "Season_Fall", "Seasonal global key for autumn. You can set config value like \"Season Fall\" space separated and it will be treated as key value pair."); seasonalGlobalKeySpring = serverConfig("Seasons - Global keys", "Spring", "Season_Spring", "Seasonal global key for spring. You can set config value like \"Season Spring\" space separated and it will be treated as key value pair."); seasonalGlobalKeySummer = serverConfig("Seasons - Global keys", "Summer", "Season_Summer", "Seasonal global key for summer. You can set config value like \"Season Summer\" space separated and it will be treated as key value pair."); seasonalGlobalKeyWinter = serverConfig("Seasons - Global keys", "Winter", "Season_Winter", "Seasonal global key for winter. You can set config value like \"Season Winter\" space separated and it will be treated as key value pair."); seasonalGlobalKeyDay = serverConfig("Seasons - Global keys", "Day number", "SeasonDay_{0}", "Seasonal global key for current day number. You can set config value like \"SeasonDay {0}\" space separated and it will be treated as key value pair."); enableSeasonalGlobalKeys.SettingChanged += delegate { seasonState?.UpdateGlobalKeys(); }; seasonalGlobalKeyFall.SettingChanged += delegate { seasonState?.UpdateGlobalKeys(); }; seasonalGlobalKeySpring.SettingChanged += delegate { seasonState?.UpdateGlobalKeys(); }; seasonalGlobalKeySummer.SettingChanged += delegate { seasonState?.UpdateGlobalKeys(); }; seasonalGlobalKeyWinter.SettingChanged += delegate { seasonState?.UpdateGlobalKeys(); }; seasonalGlobalKeyDay.SettingChanged += delegate { seasonState?.UpdateGlobalKeys(); }; cacheStorageFormat = clientConfig("Test", "Cache format", CacheFormat.Binary, "Cache files format. Binary for fast loading of single non humanreadable file. JSON for humanreadable cache.json + textures subdirectory."); logTime = clientConfig("Test", "Log time", defaultValue: false, "Log time info on state update"); logFloes = clientConfig("Test", "Log ice floes", defaultValue: false, "Log ice floes spawning/destroying"); logControllersTime = clientConfig("Test", "Log prefab caching time", defaultValue: false, "Log elapsed time of prefabs caching process in descending order"); plainsSwampBorderFix = clientConfig("Test", "Plains Swamp border fix", defaultValue: true, "Fix clipping into ground on Plains - Swamp border"); frozenKarvePositionFix = serverConfig("Test", "Fix position for frozen Karve", defaultValue: false, "Make Karve storage always available if frozen. If Karve is below certain level it will be pushed to the surface."); lastDayTerrainFactor = clientConfig("Test", "Last day terrain factor", 0f, "Last day"); firstDayTerrainFactor = clientConfig("Test", "First day terrain factor", 0f, "First day"); runTextureCachingSync = clientConfig("Test", "Run texture caching without indicator", defaultValue: false, "It is significantly faster than running with loading indicator but lacks visual progress"); plainsSwampBorderFix.SettingChanged += delegate { ZoneSystemVariantController.UpdateTerrainColors(); }; lastDayTerrainFactor.SettingChanged += delegate { ZoneSystemVariantController.UpdateTerrainColors(); }; firstDayTerrainFactor.SettingChanged += delegate { ZoneSystemVariantController.UpdateTerrainColors(); }; configDirectory = Path.Combine(Paths.ConfigPath, "shudnal.Seasons"); cacheDirectory = Path.Combine(Paths.CachePath, "shudnal.Seasons"); TerminalCommandsInit(); } public void TerminalCommandsInit() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown object obj = <>c.<>9__234_0; if (obj == null) { ConsoleEventFailable val = delegate(ConsoleEventArgs args) { if (!SeasonState.IsActive) { args.Context.AddString("Start the game before rebuilding cache"); return false; } StartCacheRebuild(); args.Context.AddString("Texture cache rebuilding process started"); return true; }; <>c.<>9__234_0 = val; obj = (object)val; } new ConsoleCommand("resetseasonscache", "Rebuild Seasons texture cache", (ConsoleEventFailable)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } private ConfigEntry config(string group, string name, T defaultValue, ConfigDescription description, bool synchronizedSetting = true) { return ((ConditionalConfigSync)configSync).AddConfigEntry(((BaseUnityPlugin)this).Config, group, name, defaultValue, description, (ConfigSyncMode)1, synchronizedSetting).SourceConfig; } private ConfigEntry serverConfig(string group, string name, T defaultValue, ConfigDescription description) { return ((ConditionalConfigSync)configSync).AddConfigEntry(((BaseUnityPlugin)this).Config, group, name, defaultValue, description, (ConfigSyncMode)0, true).SourceConfig; } private ConfigEntry clientConfig(string group, string name, T defaultValue, ConfigDescription description) { return ((ConditionalConfigSync)configSync).AddConfigEntry(((BaseUnityPlugin)this).Config, group, name, defaultValue, description, (ConfigSyncMode)2, true).SourceConfig; } private ConfigEntry config(string group, string name, T defaultValue, string description, bool synchronizedSetting = true) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return config(group, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty()), synchronizedSetting); } private ConfigEntry serverConfig(string group, string name, T defaultValue, string description) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown return serverConfig(group, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty())); } private ConfigEntry clientConfig(string group, string name, T defaultValue, string description) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown return clientConfig(group, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty())); } private void LoadIcons() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown LoadIcon("season_spring.png", ref iconSpring); LoadIcon("season_summer.png", ref iconSummer); LoadIcon("season_fall.png", ref iconFall); LoadIcon("season_winter.png", ref iconWinter); LoadIcon("valheim_warm.png", ref iconWarm); Minimap_Summer_ForestTex = new Texture2D(512, 512, (TextureFormat)4, false); LoadTexture("Minimap_Summer_ForestTex.png", ref Minimap_Summer_ForestTex); ((Texture)Minimap_Summer_ForestTex).wrapMode = (TextureWrapMode)0; ((Texture)Minimap_Summer_ForestTex).filterMode = (FilterMode)1; Minimap_Fall_ForestTex = new Texture2D(512, 512, (TextureFormat)4, false); LoadTexture("Minimap_Fall_ForestTex.png", ref Minimap_Fall_ForestTex); ((Texture)Minimap_Fall_ForestTex).wrapMode = (TextureWrapMode)0; ((Texture)Minimap_Fall_ForestTex).filterMode = (FilterMode)1; Minimap_Winter_ForestTex = new Texture2D(512, 512, (TextureFormat)4, false); LoadTexture("Minimap_Winter_ForestTex.png", ref Minimap_Winter_ForestTex); ((Texture)Minimap_Winter_ForestTex).wrapMode = (TextureWrapMode)0; ((Texture)Minimap_Winter_ForestTex).filterMode = (FilterMode)1; } internal static void LoadIcon(string filename, ref Sprite icon) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) Texture2D tex = new Texture2D(2, 2); if (LoadTexture(filename, ref tex)) { icon = Sprite.Create(tex, new Rect(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height), Vector2.zero); } } internal static bool LoadTexture(string filename, ref Texture2D tex) { string text = Path.Combine(configDirectory, filename); if (File.Exists(text)) { LogInfo("Loaded image: " + text); return ImageConversion.LoadImage(tex, File.ReadAllBytes(text)); } Assembly executingAssembly = Assembly.GetExecutingAssembly(); string text2 = executingAssembly.GetManifestResourceNames().FirstOrDefault((string str) => str.EndsWith(filename)); if (text2 == null) { return false; } using Stream stream = executingAssembly.GetManifestResourceStream(text2); if (stream == null) { return false; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); ((Object)tex).name = Path.GetFileNameWithoutExtension(filename); return ImageConversion.LoadImage(tex, array, true); } private Sprite GetSpriteConfig(string fieldName) { object? value = ((object)this).GetType().GetField(fieldName).GetValue(this); return (Sprite)((value is Sprite) ? value : null); } public static string GetSeasonTooltip(Season season) { return "$seasons_season_" + season.ToString().ToLower() + "_has_come"; } public static string GetSeasonName(Season season) { return "$seasons_season_" + season.ToString().ToLower() + "_name"; } public static string GetSeasonIsComing(Season season) { return "$seasons_season_" + season.ToString().ToLower() + "_is_coming"; } public static Sprite GetSeasonIcon(Season season) { return showCurrentSeasonBuff.Value ? instance.GetSpriteConfig($"icon{season}") : null; } public static string FromSeconds(double seconds) { if (seconds <= 0.0) { return "$hud_ready".Localize(); } TimeSpan timeSpan = TimeSpan.FromSeconds(seconds); return timeSpan.ToString((timeSpan.Hours > 0) ? "h\\:mm\\:ss" : "m\\:ss"); } public static string FromPercent(double percent) { return "▀▀▀▀▀▀▀▀▀▀".Insert(Mathf.Clamp(Mathf.RoundToInt((float)percent * 10f), 0, 10) + 16, ""); } public static bool UseTextureControllers() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 int result; if ((int)SystemInfo.graphicsDeviceType != 4) { ZNet obj = ZNet.instance; result = ((obj == null || !obj.IsDedicated()) ? 1 : 0); } else { result = 0; } return (byte)result != 0; } public static void FillListsToControl() { //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Invalid comparison between Unknown and I4 _PlantsToControlGrowth = ConfigToHashSet(cropsToControlGrowth.Value); _PlantsToSurviveWinter = ConfigToHashSet(cropsToSurviveInWinter.Value); _WoodToControlDrop = ConfigToHashSet(woodListToControlDrop.Value); _MeatToControlDrop = ConfigToHashSet(meatListToControlDrop.Value); _GrassToControlSize = ConfigToHashSet(grassToControlSize.Value); _GrassToControlSize.Add("instanced_meadows_flowers".ToLower()); _GrassToControlSize.Add("instanced_forest_groundcover_bloom".ToLower()); _GrassToControlSize.Add("swampgrass bloom".ToLower()); _treeRegrowthPrefabs.Clear(); if (ZNetScene.instance?.m_prefabs == null) { return; } Dictionary stubs = new Dictionary(); Pickable val = default(Pickable); ItemDrop val2 = default(ItemDrop); TreeBase val3 = default(TreeBase); Destructible destructible = default(Destructible); foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if (prefab != null && prefab.TryGetComponent(ref val) && (Object)(object)val.m_itemPrefab != (Object)null && val.m_itemPrefab.TryGetComponent(ref val2) && (int)val2.m_itemData.m_shared.m_itemType == 2) { _PlantsToControlGrowth.Add(((Object)((Component)val).gameObject).name.ToLower()); } if (prefab != null && prefab.TryGetComponent(ref val3) && (Object)(object)val3.m_stubPrefab != (Object)null && val3.m_stubPrefab.TryGetComponent(ref destructible) && IsTree(destructible)) { stubs.Add(prefab, val3.m_stubPrefab); } } Plant val4 = default(Plant); foreach (GameObject prefab2 in ZNetScene.instance.m_prefabs) { if (prefab2 == null || !prefab2.TryGetComponent(ref val4) || val4.m_grownPrefabs == null) { continue; } if (val4.m_grownPrefabs.Any((GameObject prefab) => ControlPlantGrowth(prefab))) { _PlantsToControlGrowth.Add(((Object)((Component)val4).gameObject).name.ToLower()); } if (val4.m_tolerateCold || val4.m_grownPrefabs.Any((GameObject prefab) => PlantWillSurviveWinter(prefab))) { _PlantsToSurviveWinter.Add(((Object)((Component)val4).gameObject).name.ToLower()); } foreach (GameObject item in val4.m_grownPrefabs.Where((GameObject grown) => stubs.ContainsKey(grown))) { string name = ((Object)stubs[item]).name; if (!_treeRegrowthPrefabs.ContainsKey(name)) { _treeRegrowthPrefabs.Add(name, prefab2); } } } static HashSet ConfigToHashSet(string configString) { return new HashSet((from p in configString.Split(',') select p.Trim().ToLower() into p where !string.IsNullOrWhiteSpace(p) select p).ToList()); } static bool IsTree(Destructible val5) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 try { return (int)val5.GetDestructibleType() == 2; } catch { return (int)val5.m_destructibleType == 2; } } } public static bool ControlPlantGrowth(GameObject gameObject) { return _PlantsToControlGrowth.Contains(PrefabVariantController.GetPrefabName(gameObject).ToLower()); } public static bool PlantWillSurviveWinter(GameObject gameObject) { return _PlantsToSurviveWinter.Contains(PrefabVariantController.GetPrefabName(gameObject).ToLower()); } public static bool ControlWoodDrop(GameObject gameObject) { return _WoodToControlDrop.Contains(PrefabVariantController.GetPrefabName(gameObject).ToLower()); } public static bool ControlMeatDrop(GameObject gameObject) { return _MeatToControlDrop.Contains(PrefabVariantController.GetPrefabName(gameObject).ToLower()); } public static GameObject TreeToRegrowth(GameObject gameObject) { return GeneralExtensions.GetValueSafe(_treeRegrowthPrefabs, PrefabVariantController.GetPrefabName(gameObject)); } public static bool ControlGrassSize(GameObject gameObject) { return _GrassToControlSize.Contains(PrefabVariantController.GetPrefabName(gameObject).ToLower()); } public static void InvalidatePositionsCache() { _cachedIgnoredPositions.Clear(); _cachedShieldedPositions.Clear(); _cachedShieldedPositionsChangeID = ShieldGenerator.m_instanceChangeID; } public static bool IsIgnoredPosition(Vector3 position) { //IL_0001: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Invalid comparison between Unknown and I4 //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Invalid comparison between Unknown and I4 //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Invalid comparison between Unknown and I4 //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if (Character.InInterior(position)) { return true; } if (WorldGenerator.instance == null) { return true; } Vector2 key = default(Vector2); ((Vector2)(ref key))..ctor(position.x, position.z); if (_cachedIgnoredPositions.TryGetValue(key, out var value)) { return value; } if (_cachedIgnoredPositions.Count > 15000) { InvalidatePositionsCache(); } Biome biome = WorldGenerator.instance.GetBiome(position); value = (int)biome == 32 || (int)biome == 64 || ((int)biome == 4 && WorldGenerator.instance.GetBaseHeight(position.x, position.z, false) > 0.45000002f); _cachedIgnoredPositions[key] = value; return value; } public static bool IsShieldProtectionActive() { return shieldGeneratorProtection.Value && (!shieldGeneratorOnlyWinter.Value || seasonState.GetCurrentSeason() == Season.Winter); } public static bool IsShieldedPosition(Vector3 position) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) if (!IsShieldProtectionActive()) { return false; } int instanceChangeID = ShieldGenerator.m_instanceChangeID; if (_cachedShieldedPositionsChangeID != instanceChangeID) { _cachedShieldedPositions.Clear(); _cachedShieldedPositionsChangeID = instanceChangeID; } Vector2 key = default(Vector2); ((Vector2)(ref key))..ctor(position.x, position.z); if (_cachedShieldedPositions.TryGetValue(key, out var value)) { return value; } if (_cachedShieldedPositions.Count > 15000) { _cachedShieldedPositions.Clear(); } value = ShieldGenerator.IsInsideShieldCached(position, ref _instanceChangeIDShieldGeneratorCache); _cachedShieldedPositions[key] = value; return value; } public static bool IsProtectedPosition(Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) return IsIgnoredPosition(position) || IsShieldedPosition(position); } public static bool ProtectedWithHeat(Vector3 position) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) return fireHeatProtectsFromPerish.Value && Object.op_Implicit((Object)(object)EffectArea.IsPointInsideArea(position, (Type)1, 0f)); } public static void StartCacheRebuild() { if (SeasonState.IsActive) { ((MonoBehaviour)instance).StartCoroutine(texturesVariants.RebuildCache()); } } public static void StartCoroutineSync(IEnumerator routine) { while (routine.MoveNext()) { if (routine.Current != null) { IEnumerator routine2; try { routine2 = (IEnumerator)routine.Current; } catch (InvalidCastException) { continue; } StartCoroutineSync(routine2); } } } public static IEnumerator PickableSetPickedInWinter(Pickable pickable) { yield return waitFor1Second; if (pickable.ShouldBePickedInWinter() && Object.op_Implicit((Object)(object)pickable.m_nview) && pickable.m_nview.IsValid()) { if (Random.Range(0f, 1f) < Mathf.Clamp01(chanceToProduceACropInWinter.Value)) { pickable.m_nview.GetZDO().Set(SeasonsVars.s_cropSurvivedWinterDayHash, seasonState.GetCurrentWorldDay(), false); yield break; } pickable.m_nview.InvokeRPC(ZNetView.Everybody, "RPC_SetPicked", new object[1] { true }); } } public static IEnumerator ReplantTree(GameObject prefab, Vector3 position, Quaternion rotation, float scale) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_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) yield return waitFor5Seconds; if (ZoneSystem.instance.IsBlocked(position) || Object.op_Implicit((Object)(object)EffectArea.IsPointInsideArea(position, (Type)4, 0f))) { yield break; } GameObject result = Object.Instantiate(prefab, position, rotation); yield return waitForFixedUpdate; ZNetView m_nview = default(ZNetView); if ((Object)(object)result != (Object)null && result.TryGetComponent(ref m_nview) && m_nview.IsValid()) { m_nview.GetZDO().Set(SeasonsVars.s_treeRegrowthHaveGrowSpace, true); Plant plant = default(Plant); if (scale != 0f && result.TryGetComponent(ref plant)) { plant.m_minScale = scale; plant.m_maxScale = scale; } } LogInfo($"Replanted {prefab}"); } } public class SeasonSettings { public const string defaultsSubdirectory = "Default settings"; public const string customEnvironmentsFileName = "Custom environments.json"; public const string customBiomeEnvironmentsFileName = "Custom Biome Environments.json"; public const string customEventsFileName = "Custom events.json"; public const string customLightingsFileName = "Custom lightings.json"; public const string customStatsFileName = "Custom stats.json"; public const string customTraderItemsFileName = "Custom trader items.json"; public const string customWorldSettingsFileName = "Custom world settings.json"; public const string customGrassSettingsFileName = "Custom grass settings.json"; public const string customClutterSettingsFileName = "Custom clutter settings.json"; public const string customBiomesSettingsFileName = "Custom biome settings.json"; public const int nightLentghDefault = 30; public const string itemDropNameTorch = "$item_torch"; public const string itemNameTorch = "Torch"; public int m_daysInSeason = 10; public int m_nightLength = 30; public bool m_torchAsFiresource = false; public float m_torchDurabilityDrain = 0.1f; public float m_plantsGrowthMultiplier = 1f; public float m_beehiveProductionMultiplier = 1f; public float m_foodDrainMultiplier = 1f; public float m_staminaDrainMultiplier = 1f; public float m_fireplaceDrainMultiplier = 1f; public float m_sapCollectingSpeedMultiplier = 1f; public bool m_rainProtection = false; public float m_woodFromTreesMultiplier = 1f; public float m_windIntensityMultiplier = 1f; public float m_restedBuffDurationMultiplier = 1f; public float m_livestockProcreationMultiplier = 1f; public bool m_overheatIn2WarmClothes = false; public float m_meatFromAnimalsMultiplier = 1f; public float m_treesRegrowthChance = 0f; internal static FileSystemWatcher configWatcher; public SeasonSettings(Seasons.Season season) { LoadDefaultSeasonSettings(season); } public SeasonSettings(Seasons.Season season, SeasonSettingsFile settings) { LoadDefaultSeasonSettings(season); FieldInfo[] fields = settings.GetType().GetFields(); foreach (FieldInfo fieldInfo in fields) { object value = fieldInfo.GetValue(settings); if (value != null) { typeof(SeasonSettings).GetField("m_" + fieldInfo.Name)?.SetValue(this, value); } } } public void SaveToJSON(string filename) { File.WriteAllText(filename, JsonConvert.SerializeObject((object)new SeasonSettingsFile(this), (Formatting)1)); } private void LoadDefaultSeasonSettings(Seasons.Season season) { switch (season) { case Seasons.Season.Spring: m_plantsGrowthMultiplier = 2f; m_beehiveProductionMultiplier = 0.5f; m_fireplaceDrainMultiplier = 0.75f; m_sapCollectingSpeedMultiplier = 2f; m_woodFromTreesMultiplier = 0.75f; m_windIntensityMultiplier = 0.9f; m_restedBuffDurationMultiplier = 1.25f; m_livestockProcreationMultiplier = 1.5f; m_meatFromAnimalsMultiplier = 0.5f; m_treesRegrowthChance = 0.9f; break; case Seasons.Season.Summer: m_plantsGrowthMultiplier = 1.5f; m_beehiveProductionMultiplier = 2f; m_foodDrainMultiplier = 0.75f; m_nightLength = 15; m_staminaDrainMultiplier = 0.8f; m_fireplaceDrainMultiplier = 0.25f; m_sapCollectingSpeedMultiplier = 1.25f; m_woodFromTreesMultiplier = 0.75f; m_windIntensityMultiplier = 1.1f; m_restedBuffDurationMultiplier = 1.5f; m_livestockProcreationMultiplier = 1.25f; m_overheatIn2WarmClothes = true; m_meatFromAnimalsMultiplier = 0.75f; m_treesRegrowthChance = 0.75f; break; case Seasons.Season.Fall: m_plantsGrowthMultiplier = 0.5f; m_beehiveProductionMultiplier = 1.5f; m_fireplaceDrainMultiplier = 1f; m_torchAsFiresource = true; m_sapCollectingSpeedMultiplier = 0.5f; m_woodFromTreesMultiplier = 1.25f; m_windIntensityMultiplier = 1.2f; m_restedBuffDurationMultiplier = 0.85f; m_livestockProcreationMultiplier = 0.75f; m_meatFromAnimalsMultiplier = 1.25f; m_treesRegrowthChance = 0.25f; break; case Seasons.Season.Winter: m_plantsGrowthMultiplier = 0f; m_beehiveProductionMultiplier = 0f; m_foodDrainMultiplier = 1.25f; m_nightLength = 45; m_torchAsFiresource = true; m_staminaDrainMultiplier = 1.2f; m_fireplaceDrainMultiplier = 2f; m_sapCollectingSpeedMultiplier = 0.25f; m_rainProtection = true; m_woodFromTreesMultiplier = 1.5f; m_windIntensityMultiplier = 0.9f; m_restedBuffDurationMultiplier = 0.75f; m_livestockProcreationMultiplier = 0.5f; m_meatFromAnimalsMultiplier = 1.5f; m_treesRegrowthChance = 0f; break; } } public static bool TryGetSeasonByFilename(string filename, out Seasons.Season season) { season = Seasons.Season.Spring; foreach (Seasons.Season value in Enum.GetValues(typeof(Seasons.Season))) { if (filename.Equals(SeasonState.GetSeasonalFileName(value), StringComparison.OrdinalIgnoreCase)) { season = value; return true; } } return false; } public static void SetupConfigWatcher(bool enabled) { if (enabled) { ReadInitialConfigs(); } if (configWatcher == null) { configWatcher = new FileSystemWatcher(Seasons.configDirectory, "*.json"); configWatcher.Changed += ReadConfigs; configWatcher.Created += ReadConfigs; configWatcher.Renamed += ReadConfigs; configWatcher.Deleted += ReadConfigs; configWatcher.IncludeSubdirectories = false; configWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; } configWatcher.EnableRaisingEvents = enabled; } private static void ReadInitialConfigs() { foreach (string item in new List { "Custom environments.json", "Custom Biome Environments.json", "Custom events.json", "Custom lightings.json", "Custom stats.json", "Custom trader items.json", "Custom world settings.json", "Custom grass settings.json", "Custom clutter settings.json", "Custom biome settings.json" }) { ReadConfigFile(item, Path.Combine(Seasons.configDirectory, item), initial: true); } ReadSeasonsSettings(initial: true); } internal static Dictionary GetSeasonalSettings() { Dictionary dictionary = new Dictionary(); FileInfo[] files = new DirectoryInfo(Seasons.configDirectory).GetFiles("*.json", SearchOption.TopDirectoryOnly); foreach (FileInfo fileInfo in files) { try { if (TryGetSeasonByFilename(fileInfo.Name, out var season)) { dictionary.Add((int)season, File.ReadAllText(fileInfo.FullName)); } } catch (Exception ex) { Seasons.LogWarning("Error reading file (" + fileInfo.FullName + ")! Error: " + ex.Message); } } return dictionary; } private static void ReadSeasonsSettings(bool initial = false) { if (initial) { Seasons.seasonsSettingsJSON.AssignValueSafeAndNotify(GetSeasonalSettings); } else { Seasons.seasonsSettingsJSON.AssignValueSafeIfChanged(GetSeasonalSettings); } } private static void ReadConfigs(object sender, FileSystemEventArgs eargs) { ReadConfigFile(eargs.Name, eargs.FullPath); if (eargs is RenamedEventArgs) { Seasons.Season season; if (GetSyncedValueToAssign((eargs as RenamedEventArgs).OldName, out var customSyncedValue, out var logMessage)) { customSyncedValue.AssignValueSafeIfChanged(""); Seasons.LogInfo(logMessage + " defaults"); } else if (TryGetSeasonByFilename(eargs.Name, out season)) { ReadSeasonsSettings(); } } } private static void ReadConfigFile(string filename, string fullname, bool initial = false) { if (!GetSyncedValueToAssign(filename, out var customSyncedValue, out var logMessage)) { if (TryGetSeasonByFilename(filename, out var _)) { ReadSeasonsSettings(); } return; } string value; try { value = File.ReadAllText(fullname); } catch (Exception ex) { if (!initial) { Seasons.LogWarning("Error reading file (" + fullname + ")! Error: " + ex.Message); } value = ""; logMessage += " defaults"; } if (initial) { customSyncedValue.AssignValueSafeAndNotify(value); } else { customSyncedValue.AssignValueSafeIfChanged(value); } Seasons.LogInfo(logMessage); } private static bool GetSyncedValueToAssign(string filename, out CustomSyncedValue customSyncedValue, out string logMessage) { if (filename.Equals("Custom environments.json", StringComparison.OrdinalIgnoreCase)) { customSyncedValue = Seasons.customEnvironmentsJSON; logMessage = "Custom environments file loaded"; } else if (filename.Equals("Custom Biome Environments.json", StringComparison.OrdinalIgnoreCase)) { customSyncedValue = Seasons.customBiomeEnvironmentsJSON; logMessage = "Custom biome environments file loaded"; } else if (filename.Equals("Custom events.json", StringComparison.OrdinalIgnoreCase)) { customSyncedValue = Seasons.customEventsJSON; logMessage = "Custom events file loaded"; } else if (filename.Equals("Custom lightings.json", StringComparison.OrdinalIgnoreCase)) { customSyncedValue = Seasons.customLightingsJSON; logMessage = "Custom lightings file loaded"; } else if (filename.Equals("Custom stats.json", StringComparison.OrdinalIgnoreCase)) { customSyncedValue = Seasons.customStatsJSON; logMessage = "Custom stats file loaded"; } else if (filename.Equals("Custom trader items.json", StringComparison.OrdinalIgnoreCase)) { customSyncedValue = Seasons.customTraderItemsJSON; logMessage = "Custom trader items file loaded"; } else if (filename.Equals("Custom world settings.json", StringComparison.OrdinalIgnoreCase)) { customSyncedValue = Seasons.customWorldSettingsJSON; logMessage = "Custom world settings file loaded"; } else if (filename.Equals("Custom grass settings.json", StringComparison.OrdinalIgnoreCase)) { customSyncedValue = Seasons.customGrassSettingsJSON; logMessage = "Custom grass settings file loaded"; } else if (filename.Equals("Custom clutter settings.json", StringComparison.OrdinalIgnoreCase)) { customSyncedValue = Seasons.customClutterSettingsJSON; logMessage = "Custom clutter settings file loaded"; } else if (filename.Equals("Custom biome settings.json", StringComparison.OrdinalIgnoreCase)) { customSyncedValue = Seasons.customBiomeSettingsJSON; logMessage = "Custom biomes settings file loaded"; } else { customSyncedValue = null; logMessage = ""; } return customSyncedValue != null; } public static void SaveDefaultEnvironments(string folder) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown List list = new List(); EnvMan instance = EnvMan.instance; if (instance != null) { CollectionExtensions.Do((IEnumerable)instance.m_environments, (Action)delegate(EnvSetup env) { list.Add(new SeasonEnvironment(env)); }); } Seasons.LogInfo("Saving default environments settings"); File.WriteAllText(Path.Combine(folder, "Default environments.json"), JsonConvert.SerializeObject((object)list, (Formatting)1)); JsonSerializerSettings val = new JsonSerializerSettings { DefaultValueHandling = (DefaultValueHandling)1, NullValueHandling = (NullValueHandling)1 }; Seasons.LogInfo("Saving default custom environments settings"); File.WriteAllText(Path.Combine(folder, "Custom environments.json"), JsonConvert.SerializeObject((object)SeasonEnvironment.GetDefaultCustomEnvironments(), (Formatting)1, val)); Seasons.LogInfo("Saving default biome environments settings"); File.WriteAllText(Path.Combine(folder, "Default biome environments.json"), JsonConvert.SerializeObject((object)EnvMan.instance?.m_biomes.ToList(), (Formatting)1)); Seasons.LogInfo("Saving default custom biome environments settings"); File.WriteAllText(Path.Combine(folder, "Custom Biome Environments.json"), JsonConvert.SerializeObject((object)new SeasonBiomeEnvironments(loadDefaults: true), (Formatting)1)); } public static void SaveDefaultEvents(string folder) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown List list = new List(); RandEventSystem instance = RandEventSystem.instance; if (instance != null) { CollectionExtensions.DoIf((IEnumerable)instance.m_events, (Func)((RandomEvent randevent) => randevent.m_random), (Action)delegate(RandomEvent randevent) { list.Add(new SeasonRandomEvents.SeasonRandomEvent(randevent)); }); } JsonSerializerSettings val = new JsonSerializerSettings { NullValueHandling = (NullValueHandling)1 }; Seasons.LogInfo("Saving default events settings"); File.WriteAllText(Path.Combine(folder, "Default events.json"), JsonConvert.SerializeObject((object)list, (Formatting)1, val)); Seasons.LogInfo("Saving default custom events settings"); File.WriteAllText(Path.Combine(folder, "Custom events.json"), JsonConvert.SerializeObject((object)new SeasonRandomEvents(loadDefaults: true), (Formatting)1, val)); } public static void SaveDefaultLightings(string folder) { Seasons.LogInfo("Saving default custom ligthing settings"); File.WriteAllText(Path.Combine(folder, "Custom lightings.json"), JsonConvert.SerializeObject((object)new SeasonLightings(loadDefaults: true), (Formatting)1)); } public static void SaveDefaultStats(string folder) { Seasons.LogInfo("Saving default custom stats settings"); File.WriteAllText(Path.Combine(folder, "Custom stats.json"), JsonConvert.SerializeObject((object)new SeasonStats(loadDefaults: true), (Formatting)1)); } public static void SaveDefaultTraderItems(string folder) { Seasons.LogInfo("Saving default custom trader items settings"); File.WriteAllText(Path.Combine(folder, "Custom trader items.json"), JsonConvert.SerializeObject((object)new SeasonTraderItems(loadDefaults: true), (Formatting)1)); } public static void SaveDefaultWorldSettings(string folder) { Seasons.LogInfo("Saving default custom world settings"); File.WriteAllText(Path.Combine(folder, "Custom world settings.json"), JsonConvert.SerializeObject((object)new SeasonWorldSettings(loadDefaults: true), (Formatting)1)); } public static void SaveDefaultGrassSettings(string folder) { Seasons.LogInfo("Saving default custom grass settings"); File.WriteAllText(Path.Combine(folder, "Custom grass settings.json"), JsonConvert.SerializeObject((object)new SeasonGrassSettings(loadDefaults: true), (Formatting)1)); } public static void SaveDefaultClutterSettings(string folder) { Seasons.LogInfo("Saving default custom clutter settings"); File.WriteAllText(Path.Combine(folder, "Custom clutter settings.json"), JsonConvert.SerializeObject((object)new SeasonClutterSettings(loadDefaults: true), (Formatting)1)); } public static void SaveDefaultBiomesSettings(string folder) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown Seasons.LogInfo("Saving default custom biomes settings"); File.WriteAllText(Path.Combine(folder, "Custom biome settings.json"), JsonConvert.SerializeObject((object)new SeasonBiomeSettings(loadDefaults: true), (Formatting)1, new JsonSerializerSettings { NullValueHandling = (NullValueHandling)1 })); } } [HarmonyPatch(typeof(ZoneSystem), "Start")] public static class ZoneSystem_Start_InitSeasonStateAndConfigWatcher { [HarmonyPriority(0)] [HarmonyAfter(new string[] { "expand_world_data" })] private static void Postfix() { Seasons.seasonState = new SeasonState(initialize: true); EWDCompat.MarkWorldInitialized(); SeasonSettings.SetupConfigWatcher(enabled: true); SeasonState.ReapplyEnvironmentStateAfterWorldInitialization(); } } [HarmonyPatch(typeof(ZoneSystem), "OnDestroy")] public static class ZoneSystem_OnDestroy_DisableConfigWatcher { private static void Postfix() { SeasonSettings.SetupConfigWatcher(enabled: false); SeasonState.ResetCurrentSeasonDay(); SeasonState.ResetEnvironmentStateTracking(); EWDCompat.ResetWorldState(); } } [Serializable] public class SeasonSettingsFile { public int? daysInSeason; public int? nightLength; public bool? torchAsFiresource; public float? torchDurabilityDrain; public float? plantsGrowthMultiplier; public float? beehiveProductionMultiplier; public float? foodDrainMultiplier; public float? staminaDrainMultiplier; public float? fireplaceDrainMultiplier; public float? sapCollectingSpeedMultiplier; public bool? rainProtection; public float? woodFromTreesMultiplier; public float? windIntensityMultiplier; public float? restedBuffDurationMultiplier; public float? livestockProcreationMultiplier; public bool? overheatIn2WarmClothes; public float? meatFromAnimalsMultiplier; public float? treesRegrowthChance; public SeasonSettingsFile(SeasonSettings settings) { daysInSeason = settings.m_daysInSeason; nightLength = settings.m_nightLength; torchAsFiresource = settings.m_torchAsFiresource; torchDurabilityDrain = settings.m_torchDurabilityDrain; plantsGrowthMultiplier = settings.m_plantsGrowthMultiplier; beehiveProductionMultiplier = settings.m_beehiveProductionMultiplier; foodDrainMultiplier = settings.m_foodDrainMultiplier; staminaDrainMultiplier = settings.m_staminaDrainMultiplier; fireplaceDrainMultiplier = settings.m_fireplaceDrainMultiplier; sapCollectingSpeedMultiplier = settings.m_sapCollectingSpeedMultiplier; rainProtection = settings.m_rainProtection; woodFromTreesMultiplier = settings.m_woodFromTreesMultiplier; windIntensityMultiplier = settings.m_windIntensityMultiplier; restedBuffDurationMultiplier = settings.m_restedBuffDurationMultiplier; livestockProcreationMultiplier = settings.m_livestockProcreationMultiplier; overheatIn2WarmClothes = settings.m_overheatIn2WarmClothes; meatFromAnimalsMultiplier = settings.m_meatFromAnimalsMultiplier; treesRegrowthChance = settings.m_treesRegrowthChance; } public SeasonSettingsFile() { } } internal class SeasonStatePatches { [HarmonyPatch(typeof(Humanoid), "UpdateEquipment")] public static class Humanoid_UpdateEquipment_ToggleTorchesWarmth { private static void Prefix(Humanoid __instance) { if (!((Object)(object)__instance == (Object)null) && ((Character)__instance).IsPlayer()) { Seasons.seasonState.PatchTorchItemData(__instance.m_rightItem); Seasons.seasonState.PatchTorchItemData(__instance.m_leftItem); } } } [HarmonyPatch(typeof(ObjectDB), "Awake")] public static class ObjectDB_Awake_TorchPatch { [HarmonyPriority(0)] private static void Postfix() { Seasons.seasonState.UpdateTorchesFireWarmth(); } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] public static class ObjectDB_CopyOtherDB_TorchPatch { [HarmonyPriority(0)] private static void Postfix() { Seasons.seasonState.UpdateTorchesFireWarmth(); } } [HarmonyPatch(typeof(Player), "AddKnownItem")] public static class Player_AddKnownItem_TorchPatch { private static void Postfix(ref ItemData item) { if (!(item.m_shared.m_name != "$item_torch")) { Seasons.seasonState.PatchTorchItemData(item); } } } [HarmonyPatch(typeof(Player), "OnSpawned")] public class Player_OnSpawned_TorchPatch { public static void Postfix(Player __instance) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { Seasons.seasonState.PatchTorchesInInventory(((Humanoid)__instance).GetInventory()); } } } [HarmonyPatch(typeof(Inventory), "Load")] public class Inventory_Load_TorchPatch { public static void Postfix(Inventory __instance) { Seasons.seasonState.PatchTorchesInInventory(__instance); } } [HarmonyPatch(typeof(ItemDrop), "Start")] public static class ItemDrop_Start_TorchPatch { private static void Postfix(ref ItemDrop __instance) { if (!(__instance.GetPrefabName(((Object)__instance).name) != "Torch")) { Seasons.seasonState.PatchTorchItemData(__instance.m_itemData); } } } [HarmonyPatch(typeof(SeasonalItemGroup), "IsInSeason")] public static class SeasonalItemGroup_IsInSeason_SeasonalItems { private static void Postfix(SeasonalItemGroup __instance, ref bool __result) { if (Seasons.enableSeasonalItems.Value) { Seasons.Season currentSeason = Seasons.seasonState.GetCurrentSeason(); __result = (((Object)__instance).name == "Halloween" && currentSeason == Seasons.Season.Fall) || (((Object)__instance).name == "Midsummer" && currentSeason == Seasons.Season.Summer) || (((Object)__instance).name == "Yule" && currentSeason == Seasons.Season.Winter); } } } [HarmonyPatch(typeof(Character), "ApplyDamage")] public static class Character_ApplyDamage_PreventDeathFromFreezing { private static bool Prefix(Character __instance, ref HitData hit) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Invalid comparison between Unknown and I4 //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Invalid comparison between Unknown and I4 if (!Seasons.preventDeathFromFreezing.Value) { return true; } if (!__instance.IsPlayer()) { return true; } if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } if ((int)hit.m_hitType != 6) { return true; } Biome currentBiome = ((Player)((__instance is Player) ? __instance : null)).GetCurrentBiome(); if ((int)currentBiome == 4 || (int)currentBiome == 64) { return true; } return __instance.GetHealth() >= 5f; } } [HarmonyPatch(typeof(Pickable), "Awake")] public static class Pickable_Awake_PlantsGrowthMultiplier { [HarmonyPriority(0)] private static void Postfix(Pickable __instance) { ZNetView nview = __instance.m_nview; if (nview != null && nview.IsValid() && !__instance.m_nview.HasOwner()) { __instance.m_nview.ClaimOwnership(); } if (!__instance.IsIgnored() && !__instance.CheckForPerishInWinter() && !((MonoBehaviour)__instance).IsInvoking("UpdateRespawn")) { ((MonoBehaviour)__instance).InvokeRepeating("UpdateRespawn", Random.Range(1f, 5f), 60f); } } } [HarmonyPatch(typeof(Pickable), "UpdateRespawn")] public static class Pickable_UpdateRespawn_PlantsGrowthMultiplier { private static bool Prefix(Pickable __instance, ref float ___m_respawnTimeMinutes, ref float __state) { __state = 0f; if (__instance.IsIgnored()) { return true; } if (__instance.CheckForPerishInWinter()) { return false; } if (Seasons.seasonState.GetPlantsGrowthMultiplier() == 0f) { return false; } if (___m_respawnTimeMinutes == 0f) { return false; } __state = ___m_respawnTimeMinutes; ___m_respawnTimeMinutes = (float)Seasons.seasonState.GetSecondsToRespawnPickable(__instance) / 60f; return true; } private static void Postfix(ref float ___m_respawnTimeMinutes, ref float __state) { if (__state != 0f) { ___m_respawnTimeMinutes = __state; } } } [HarmonyPatch(typeof(Pickable), "SetPicked")] public static class Pickable_SetPicked_FreezingTime { private static void Prefix(Pickable __instance, bool picked) { if (!__instance.IsIgnored() && picked) { __instance.SetFreezing(freezing: false); } } } [HarmonyPatch(typeof(Pickable), "GetHoverText")] public static class Pickable_GetHoverText_FireWarmthPerishProtection { private static void Postfix(Pickable __instance, ref string __result) { if (Seasons.hoverPickable.Value != Seasons.StationHover.Vanilla && __instance.m_picked && __instance.m_enabled > 0 && (Object)(object)__instance.m_nview != (Object)null && __instance.m_nview.IsValid()) { long num = __instance.m_nview.GetZDO().GetLong(ZDOVars.s_pickedTime, 0L); if (num > 1) { if (string.IsNullOrWhiteSpace(__result)) { __result = __instance.GetHoverName().Localize(); } TimeSpan timeSpan = ZNet.instance.GetTime() - new DateTime(num); double secondsToRespawnPickable = Seasons.seasonState.GetSecondsToRespawnPickable(__instance); if (Seasons.hoverPickable.Value == Seasons.StationHover.Percentage) { __result += $"\n{timeSpan.TotalSeconds / secondsToRespawnPickable:P0}"; } else if (Seasons.hoverPickable.Value == Seasons.StationHover.Bar) { __result = __result + "\n" + Seasons.FromPercent(timeSpan.TotalSeconds / secondsToRespawnPickable); } else if (Seasons.hoverPickable.Value == Seasons.StationHover.MinutesSeconds) { __result = __result + "\n" + Seasons.FromSeconds(secondsToRespawnPickable - timeSpan.TotalSeconds); } } } if (!__instance.IsIgnored() && Seasons.seasonState.GetCurrentSeason() == Seasons.Season.Winter && __instance.CanBePicked()) { if (string.IsNullOrWhiteSpace(__result)) { __result = __instance.GetHoverName().Localize(); } __result = __result + "\n" + __instance.GetColdStatus().Localize() + ""; } } } [HarmonyPatch(typeof(Vine), "UpdateGrow")] public static class Vine_UpdateGrow_VinesGrowthWinterStop { private static float m_growTime; private static float m_growTimePerBranch; private static bool Prefix(Vine __instance, ref bool __state) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (Seasons.IsProtectedPosition(((Component)__instance).transform.position) || __instance.m_initialGrowItterations > 0 || __instance.IsDoneGrowing) { return true; } float plantsGrowthMultiplier = Seasons.seasonState.GetPlantsGrowthMultiplier(); if (plantsGrowthMultiplier == 0f) { return false; } m_growTime = __instance.m_growTime; m_growTimePerBranch = __instance.m_growTimePerBranch; __state = true; __instance.m_growTime *= plantsGrowthMultiplier; __instance.m_growTimePerBranch *= plantsGrowthMultiplier; return true; } private static void Postfix(Vine __instance, bool __state) { if (__state) { __instance.m_growTime = m_growTime; __instance.m_growTimePerBranch = m_growTimePerBranch; } } } [HarmonyPatch(typeof(Plant), "UpdateHealth")] public static class Pickable_UpdateHealth_PlantsPerishInWinter { private static bool isProtected; private static void Prefix(Plant __instance, ref double timeSincePlanted) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!(isProtected = Seasons.IsProtectedPosition(((Component)__instance).transform.position)) && timeSincePlanted == 0.0 && Seasons.seasonState.GetPlantsGrowthMultiplier() == 0f && Seasons.seasonState.GetCurrentSeason() == Seasons.Season.Winter) { timeSincePlanted = 11.0; } } private static void Postfix(Plant __instance, ref Status ___m_status) { if (!isProtected && (int)___m_status == 0 && Seasons.seasonState.GetPlantsGrowthMultiplier() == 0f && Seasons.seasonState.GetCurrentSeason() == Seasons.Season.Winter && !((MonoBehaviour)(object)__instance).ShouldSurviveWinter() && !((MonoBehaviour)(object)__instance).ProtectedWithHeat()) { ___m_status = (Status)7; } } } [HarmonyPatch(typeof(Plant), "TimeSincePlanted")] public static class Plant_TimeSincePlanted_PlantsGrowthMultiplier { private static void Postfix(Plant __instance, ref double __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!Seasons.IsProtectedPosition(((Component)__instance).transform.position)) { double num = Seasons.seasonState.GetTotalSeconds(); double num2 = Seasons.seasonState.GetStartOfCurrentSeason(); Seasons.Season season = Seasons.seasonState.GetCurrentSeason(); double num3 = 0.0; do { num3 += ((num - num2 >= __result) ? __result : (num - num2)) * (double)Seasons.seasonState.GetPlantsGrowthMultiplier(season); __result -= num - num2; num = num2; season = Seasons.seasonState.GetPreviousSeason(season); num2 -= (double)(Seasons.seasonState.GetDaysInSeason(season) * Seasons.seasonState.GetDayLengthInSeconds()); } while (__result > 0.0); __result = num3; } } } [HarmonyPatch(typeof(Plant), "GetHoverText")] public static class Plant_GetHoverText_Duration { private static void Postfix(Plant __instance, ref string __result) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 if (Seasons.hoverPlant.Value != Seasons.StationHover.Vanilla && !Utility.IsNullOrWhiteSpace(__result) && (int)__instance.GetStatus() <= 0) { if (Seasons.hoverPlant.Value == Seasons.StationHover.Percentage) { __result += $"\n{__instance.TimeSincePlanted() / (double)__instance.GetGrowTime():P0}"; } else if (Seasons.hoverPlant.Value == Seasons.StationHover.Bar) { __result = __result + "\n" + Seasons.FromPercent(__instance.TimeSincePlanted() / (double)__instance.GetGrowTime()); } else if (Seasons.hoverPlant.Value == Seasons.StationHover.MinutesSeconds) { __result = __result + "\n" + Seasons.FromSeconds(Seasons.seasonState.GetSecondsToGrowPlant(__instance)); } } } } [HarmonyPatch(typeof(Minimap), "Start")] public static class Minimap_Start_MinimapSeasonalBorderColor { private static void Postfix() { if (SeasonState.IsActive) { Seasons.seasonState.UpdateMinimapBorder(); } } } [HarmonyPatch(typeof(Beehive), "Interact")] public static class Beehive_Interact_BeesInteractionMessage { private static void Prefix(Beehive __instance, ref string __state) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!Seasons.IsProtectedPosition(((Component)__instance).transform.position)) { __state = __instance.m_happyText; if (Seasons.seasonState.GetBeehiveProductionMultiplier() == 0f) { __instance.m_happyText = __instance.m_sleepText; } } } private static void Postfix(Beehive __instance, ref string __state) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!Seasons.IsProtectedPosition(((Component)__instance).transform.position)) { __instance.m_happyText = __state; } } } [HarmonyPatch(typeof(Beehive), "GetTimeSinceLastUpdate")] public static class Beehive_GetTimeSinceLastUpdate_BeesProduction { private static void Postfix(Beehive __instance, ref float __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!Seasons.IsProtectedPosition(((Component)__instance).transform.position)) { __result *= Seasons.seasonState.GetBeehiveProductionMultiplier(); } } } [HarmonyPatch(typeof(Beehive), "GetHoverText")] public static class Beehive_GetHoverText_Duration { private static void Postfix(Beehive __instance, ref string __result) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (Seasons.hoverBeeHive.Value == Seasons.StationHover.Vanilla || Utility.IsNullOrWhiteSpace(__result)) { return; } int honeyLevel = __instance.GetHoneyLevel(); if (!PrivateArea.CheckAccess(((Component)__instance).transform.position, 0f, false, false) || honeyLevel == __instance.m_maxHoney) { return; } float num = __instance.m_nview.GetZDO().GetFloat(ZDOVars.s_product, 0f); if (Seasons.hoverBeeHive.Value == Seasons.StationHover.Percentage) { __result += $"\n{num / __instance.m_secPerUnit:P0}"; } else if (Seasons.hoverBeeHive.Value == Seasons.StationHover.Bar) { __result = __result + "\n" + Seasons.FromPercent(num / __instance.m_secPerUnit); } else if (Seasons.hoverBeeHive.Value == Seasons.StationHover.MinutesSeconds) { __result = __result + "\n" + Seasons.FromSeconds(Seasons.seasonState.GetSecondsToMakeHoney(__instance, 1, num)); } if (Seasons.hoverBeeHiveTotal.Value && honeyLevel < 3) { if (Seasons.hoverBeeHive.Value == Seasons.StationHover.Percentage) { __result += $"\n{(num + __instance.m_secPerUnit * (float)honeyLevel) / (__instance.m_secPerUnit * (float)__instance.m_maxHoney):P0}"; } else if (Seasons.hoverBeeHive.Value == Seasons.StationHover.Bar) { __result = __result + "\n" + Seasons.FromPercent((num + __instance.m_secPerUnit * (float)honeyLevel) / (__instance.m_secPerUnit * (float)__instance.m_maxHoney)); } else if (Seasons.hoverBeeHive.Value == Seasons.StationHover.MinutesSeconds) { __result = __result + "\n" + Seasons.FromSeconds(Seasons.seasonState.GetSecondsToMakeHoney(__instance, __instance.m_maxHoney - honeyLevel, num)); } } } } [HarmonyPatch(typeof(Beehive), "UpdateBees")] public static class Beehive_UpdateBees_BeesSleeping { private static void Postfix(Beehive __instance, ref GameObject ___m_beeEffect) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!Seasons.IsProtectedPosition(((Component)__instance).transform.position) && Seasons.seasonState.GetBeehiveProductionMultiplier() == 0f) { ___m_beeEffect.SetActive(false); } } } [HarmonyPatch(typeof(Player), "UpdateFood")] public static class Player_UpdateFood_FoodDrainMultiplier { private static void Prefix(Player __instance, float dt, bool forceUpdate) { if (Seasons.seasonState.GetFoodDrainMultiplier() == 1f || (Object)(object)__instance == (Object)null || ((Character)__instance).InInterior() || __instance.InShelter() || !(dt + __instance.m_foodUpdateTimer >= 1f || forceUpdate)) { return; } foreach (Food food in __instance.m_foods) { food.m_time += 1f - Math.Max(0f, Seasons.seasonState.GetFoodDrainMultiplier()); } } } [HarmonyPatch(typeof(Player), "UseStamina")] public static class Player_UseStamina_StaminaDrainMultiplier { private static void Prefix(Player __instance, ref float v) { if (!((Object)(object)__instance == (Object)null) && !((Character)__instance).InInterior() && !__instance.InShelter()) { v *= Math.Max(0f, Seasons.seasonState.GetStaminaDrainMultiplier()); } } } [HarmonyPatch(typeof(Fireplace), "GetTimeSinceLastUpdate")] private static class Fireplace_GetTimeSinceLastUpdate_FireplaceDrainMultiplier { private static void Postfix(Fireplace __instance, ref double __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!Seasons.IsProtectedPosition(((Component)__instance).transform.position)) { __result *= Math.Max(0f, Seasons.seasonState.GetFireplaceDrainMultiplier()); } } } [HarmonyPatch(typeof(Smelter), "GetDeltaTime")] private static class Smelter_GetDeltaTime_FireplaceDrainMultiplier_SmeltingSpeedMultiplier { private static void Postfix(Smelter __instance, ref double __result) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (!(__instance.m_name != "$piece_bathtub") && !Seasons.IsProtectedPosition(((Component)__instance).transform.position)) { __result *= Math.Max(0f, Seasons.seasonState.GetFireplaceDrainMultiplier()); } } } [HarmonyPatch(typeof(CookingStation), "UpdateFuel")] private static class CookingStation_UpdateFuel_FireplaceDrainMultiplier { private static void Prefix(CookingStation __instance, ref float dt, ref float __state) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!Seasons.IsProtectedPosition(((Component)__instance).transform.position)) { __state = dt; dt *= Math.Max(0f, Seasons.seasonState.GetFireplaceDrainMultiplier()); } } private static void Postfix(CookingStation __instance, ref float dt, float __state) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!Seasons.IsProtectedPosition(((Component)__instance).transform.position)) { dt = __state; } } } [HarmonyPatch(typeof(SapCollector), "GetTimeSinceLastUpdate")] private static class SapCollector_GetTimeSinceLastUpdate_SapCollectingSpeedMultiplier { private static void Postfix(SapCollector __instance, ref float __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!Seasons.IsProtectedPosition(((Component)__instance).transform.position)) { __result *= Math.Max(0f, Seasons.seasonState.GetSapCollectingSpeedMultiplier()); } } } [HarmonyPatch(typeof(WearNTear), "UpdateWear")] public static class WearNTear_UpdateWear_RainProtection { private static void Prefix(WearNTear __instance, ZNetView ___m_nview, ref bool ___m_noRoofWear, ref bool __state) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (Seasons.seasonState.GetRainProtection() && !((Object)(object)___m_nview == (Object)null) && ___m_nview.IsValid() && !Seasons.IsProtectedPosition(((Component)__instance).transform.position)) { __state = ___m_noRoofWear; ___m_noRoofWear = false; } } private static void Postfix(ref bool ___m_noRoofWear, bool __state) { if (Seasons.seasonState.GetRainProtection() && __state) { ___m_noRoofWear = __state; } } } [HarmonyPatch(typeof(TreeLog), "Destroy")] public static class TreeLog_Destroy_TreeWoodDrop { public static void ApplyWoodMultiplier(DropTable m_dropWhenDestroyed) { if (m_dropWhenDestroyed.m_drops.Any((DropData dd) => Seasons.ControlWoodDrop(dd.m_item))) { m_dropWhenDestroyed.m_dropMax = Mathf.CeilToInt((float)m_dropWhenDestroyed.m_dropMax * Seasons.seasonState.GetWoodFromTreesMultiplier()); if (m_dropWhenDestroyed.m_dropMin < m_dropWhenDestroyed.m_dropMax) { m_dropWhenDestroyed.m_dropMin = m_dropWhenDestroyed.m_dropMax; } } } private static void Prefix(TreeLog __instance, ZNetView ___m_nview, ref DropTable ___m_dropWhenDestroyed) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (Seasons.seasonState.GetWoodFromTreesMultiplier() != 1f && !((Object)(object)___m_nview == (Object)null) && ___m_nview.IsValid() && ___m_nview.IsOwner() && !Seasons.IsProtectedPosition(((Component)__instance).transform.position)) { ApplyWoodMultiplier(___m_dropWhenDestroyed); } } } [HarmonyPatch(typeof(Destructible), "Destroy")] public static class Destructible_Destroy_TreeRegrowth { private static void Prefix(Destructible __instance, ZNetView ___m_nview) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Invalid comparison between Unknown and I4 //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) if (!(Random.Range(0f, 1f) > Seasons.seasonState.GetTreesReqrowthChance()) && !((Object)(object)___m_nview == (Object)null) && ___m_nview.IsValid() && ___m_nview.IsOwner() && (int)__instance.GetDestructibleType() == 2) { GameObject val = Seasons.TreeToRegrowth(((Component)__instance).gameObject); if (val != null && !Seasons.IsProtectedPosition(((Component)__instance).transform.position) && !Object.op_Implicit((Object)(object)EffectArea.IsPointInsideArea(((Component)__instance).transform.position, (Type)4, 0f))) { float scale = ___m_nview.GetZDO().GetFloat(ZDOVars.s_scaleScalarHash, 0f); ((MonoBehaviour)Seasons.instance).StartCoroutine(Seasons.ReplantTree(val, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation, scale)); } } } } [HarmonyPatch(typeof(Plant), "HaveGrowSpace")] public static class Plant_HaveGrowSpace_TreeRegrowth { private static bool Prefix(ZNetView ___m_nview, ref bool __result) { if ((Object)(object)___m_nview == (Object)null || !___m_nview.IsValid() || !___m_nview.IsOwner()) { return true; } __result = __result || ___m_nview.GetZDO().GetBool(SeasonsVars.s_treeRegrowthHaveGrowSpace, false); return !__result; } } [HarmonyPatch(typeof(DropOnDestroyed), "OnDestroyed")] public static class DropOnDestroyed_OnDestroyed_TreeWoodDrop { private static void Prefix(DropOnDestroyed __instance, ref DropTable ___m_dropWhenDestroyed) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) Destructible val = default(Destructible); if (Seasons.seasonState.GetWoodFromTreesMultiplier() != 1f && ((Component)__instance).TryGetComponent(ref val) && (int)val.GetDestructibleType() == 2 && !Seasons.IsProtectedPosition(((Component)__instance).transform.position)) { TreeLog_Destroy_TreeWoodDrop.ApplyWoodMultiplier(___m_dropWhenDestroyed); } } } [HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")] public static class CharacterDrop_GenerateDropList_MeatDrop { public static void ApplyMeatMultiplier(List m_drops) { foreach (Drop m_drop in m_drops) { if (!((Object)(object)m_drop.m_prefab == (Object)null) && Seasons.ControlMeatDrop(m_drop.m_prefab)) { m_drop.m_amountMax = Mathf.CeilToInt((float)m_drop.m_amountMax * Seasons.seasonState.GetMeatFromAnimalsMultiplier()); if (m_drop.m_amountMin < m_drop.m_amountMax) { m_drop.m_amountMin = m_drop.m_amountMax; } } } } private static void Prefix(CharacterDrop __instance, ref List ___m_drops) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (Seasons.seasonState.GetMeatFromAnimalsMultiplier() != 1f && !Seasons.IsProtectedPosition(((Component)__instance).transform.position)) { ApplyMeatMultiplier(___m_drops); } } } [HarmonyPatch(typeof(SE_Rested), "UpdateTTL")] public static class SE_Rested_UpdateTTL_RestedBuffDuration { private static void Prefix(ref float ___m_baseTTL, ref float ___m_TTLPerComfortLevel, ref Tuple __state) { if (Seasons.seasonState.GetRestedBuffDurationMultiplier() != 1f) { __state = new Tuple(___m_baseTTL, ___m_TTLPerComfortLevel); ___m_baseTTL *= Seasons.seasonState.GetRestedBuffDurationMultiplier(); ___m_TTLPerComfortLevel *= Seasons.seasonState.GetRestedBuffDurationMultiplier(); } } private static void Postfix(ref float ___m_baseTTL, ref float ___m_TTLPerComfortLevel, Tuple __state) { if (Seasons.seasonState.GetRestedBuffDurationMultiplier() != 1f) { ___m_baseTTL = __state.Item1; ___m_TTLPerComfortLevel = __state.Item2; } } } [HarmonyPatch(typeof(Procreation), "Procreate")] public static class Procreation_Procreate_ProcreationMultiplier { private class ProcreateState { public float m_totalCheckRange; public float m_partnerCheckRange; public float m_pregnancyChance; public float m_pregnancyDuration; } private static readonly ProcreateState _procreateState = new ProcreateState(); private static void Prefix(ref Procreation __instance) { if (Seasons.seasonState.GetLivestockProcreationMultiplier() != 1f) { _procreateState.m_totalCheckRange = __instance.m_totalCheckRange; _procreateState.m_partnerCheckRange = __instance.m_partnerCheckRange; _procreateState.m_pregnancyChance = __instance.m_pregnancyChance; _procreateState.m_pregnancyDuration = __instance.m_pregnancyDuration; Procreation obj = __instance; obj.m_pregnancyChance *= Seasons.seasonState.GetLivestockProcreationMultiplier(); Procreation obj2 = __instance; obj2.m_partnerCheckRange *= Seasons.seasonState.GetLivestockProcreationMultiplier(); if (Seasons.seasonState.GetLivestockProcreationMultiplier() != 0f) { Procreation obj3 = __instance; obj3.m_totalCheckRange /= Seasons.seasonState.GetLivestockProcreationMultiplier(); Procreation obj4 = __instance; obj4.m_pregnancyDuration /= Seasons.seasonState.GetLivestockProcreationMultiplier(); } } } private static void Postfix(ref Procreation __instance) { if (Seasons.seasonState.GetLivestockProcreationMultiplier() != 1f) { __instance.m_pregnancyChance = _procreateState.m_pregnancyChance; __instance.m_totalCheckRange = _procreateState.m_totalCheckRange; __instance.m_partnerCheckRange = _procreateState.m_partnerCheckRange; __instance.m_pregnancyDuration = _procreateState.m_pregnancyDuration; } } } [HarmonyPatch] public static class Player_Food_OverheatIn2WarmClothesExcludeEyescream { private static IEnumerable TargetMethods() { yield return AccessTools.Method(typeof(Player), "UpdateFood", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(Player), "ClearFood", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(Player), "EatFood", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(Player), "RemoveOneFood", (Type[])null, (Type[])null); } private static void Prefix(Player __instance, ref int __state) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer) { __state = __instance.GetFoods().Count; } } private static void Postfix(Player __instance, int __state) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && __state != __instance.GetFoods().Count) { Seasons.seasonState.CheckOverheatStatus(__instance); } } } [HarmonyPatch(typeof(Player), "UpdateEnvStatusEffects")] public static class Player_UpdateEnvStatusEffects_ColdStatus { public static bool removeFrostResistanceFromArmor = false; private static int warmPieces; private static readonly int s_wetStatusHash = SEMan.s_statusEffectWet; private static int GetWarmClothesCountCached(Player player) { return (warmPieces != -1) ? warmPieces : (warmPieces = SeasonState.GetWarmClothesCount(player)); } private static void ClearWarmClothesCache() { warmPieces = -1; } private static void Prefix(Player __instance) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Invalid comparison between Unknown and I4 ClearWarmClothesCache(); bool num; if ((int)__instance.GetCurrentBiome() != 4) { if (!Seasons.gettingWetInWinterCausesCold.Value) { goto IL_0089; } num = Seasons.seasonState.GetCurrentSeason() == Seasons.Season.Winter; } else { num = Seasons.gettingWetInMountainsCausesCold.Value; } if (num) { bool flag = EnvMan.IsCold() && ((Character)__instance).GetSEMan().HaveStatusEffect(s_wetStatusHash); bool flag2 = Seasons.wearing2WarmPiecesPreventsWetCold.Value && GetWarmClothesCountCached(__instance) > 1; removeFrostResistanceFromArmor = flag && (!flag2 || ((Character)__instance).IsSwimming()); } goto IL_0089; IL_0089: if (Seasons.mountainInWinterRequires2WarmPieces.Value && (int)__instance.GetCurrentBiome() == 4 && Seasons.seasonState.GetCurrentSeason() == Seasons.Season.Winter && GetWarmClothesCountCached(__instance) < 2) { removeFrostResistanceFromArmor = true; } } private static void Postfix() { removeFrostResistanceFromArmor = false; } } [HarmonyPatch(typeof(Player), "ApplyArmorDamageMods")] public static class Player_ApplyArmorDamageMods_ColdStatusWhenWet { public static bool IsFrostResistant(DamageModifiers mods) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 DamageModifier modifier = ((DamageModifiers)(ref mods)).GetModifier((DamageType)64); return (int)modifier == 1 || (int)modifier == 5 || (int)modifier == 7; } private static void Prefix(DamageModifiers mods, ref bool __state) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) __state = IsFrostResistant(mods); } [HarmonyPriority(0)] private static void Postfix(ref DamageModifiers mods, bool __state) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (!__state && Player_UpdateEnvStatusEffects_ColdStatus.removeFrostResistanceFromArmor && IsFrostResistant(mods)) { mods.m_frost = (DamageModifier)0; } } } [HarmonyPatch(typeof(Humanoid), "EquipItem")] public static class Humanoid_EquipItem_OverheatIn2WarmClothes { private static void Postfix(Humanoid __instance) { if (((Character)__instance).IsPlayer()) { Seasons.seasonState.CheckOverheatStatus((Player)(object)((__instance is Player) ? __instance : null)); } } } [HarmonyPatch(typeof(Humanoid), "UnequipItem")] public static class Humanoid_UnequipItem_OverheatIn2WarmClothes { private static void Postfix(Humanoid __instance) { if (((Character)__instance).IsPlayer()) { Seasons.seasonState.CheckOverheatStatus((Player)(object)((__instance is Player) ? __instance : null)); } } } [HarmonyPatch(typeof(RandEventSystem), "GetPossibleRandomEvents")] public static class RandEventSystem_GetPossibleRandomEvents_RandomEventWeights { private static void Prefix(RandEventSystem __instance, ref List __state) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (!Seasons.controlRandomEvents.Value) { return; } List seasonEvents = SeasonState.seasonRandomEvents.GetSeasonEvents(Seasons.seasonState.GetCurrentSeason()); __state = new List(); for (int i = 0; i < __instance.m_events.Count; i++) { RandomEvent randEvent = __instance.m_events[i]; __state.Add(JsonUtility.FromJson(JsonUtility.ToJson((object)randEvent))); SeasonRandomEvents.SeasonRandomEvent seasonRandomEvent = seasonEvents.Find((SeasonRandomEvents.SeasonRandomEvent re) => re.m_name == randEvent.m_name); if (seasonRandomEvent == null) { continue; } if (seasonRandomEvent.m_biomes != null) { randEvent.m_biome = seasonRandomEvent.GetBiome(); randEvent.m_spawn.ForEach(delegate(SpawnData spawn) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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) spawn.m_biome |= randEvent.m_biome; }); } if (seasonRandomEvent.m_weight == 0) { randEvent.m_enabled = false; } else if (seasonRandomEvent.m_weight > 1) { for (int num = 2; num <= seasonRandomEvent.m_weight; num++) { RandEventSystem.instance.m_events.Insert(i, randEvent); i++; } } } } private static void Postfix(ref RandEventSystem __instance, List __state) { if (Seasons.controlRandomEvents.Value) { __instance.m_events.Clear(); __instance.m_events.AddRange(__state.ToList()); } } } [HarmonyPatch(typeof(FootStep), "FindBestStepEffect")] public static class FootStep_FindBestStepEffect_SnowFootsteps { private static void Prefix(FootStep __instance, ref GroundMaterial material) { if (Seasons.IsShieldProtectionActive()) { Character character = __instance.m_character; if ((Object)(object)((character != null) ? character.GetLastGroundCollider() : null) != (Object)null && ZoneSystemVariantController.IsProtectedHeightmap(((Component)__instance.m_character.GetLastGroundCollider()).GetComponent())) { return; } } if (Seasons.seasonState.GetCurrentSeason() == Seasons.Season.Winter && ((int)material == 32 || (int)material == 64 || (int)material == 128)) { material = (GroundMaterial)16; } else if (ZoneSystemVariantController.IsWaterSurfaceFrozen() && (int)material == 2) { material = (GroundMaterial)16; } } } [HarmonyPatch(typeof(Hud), "UpdateBlackScreen")] public static class Hud_UpdateBlackScreen_BlackScreenFadeOnSeasonChange { private static bool Prefix() { return !Seasons.seasonState.GetSeasonIsChanging(); } } [HarmonyPatch(typeof(Bed), "CheckFire")] public static class Bed_CheckFire_PreventSleepingWithTorchFiresource { [HarmonyPriority(800)] private static void Prefix(Humanoid human) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 if ((Object)(object)human == (Object)(object)Player.m_localPlayer && Seasons.seasonState.GetTorchAsFiresource() && ((human.GetLeftItem() != null && (int)human.GetLeftItem().m_shared.m_itemType == 15) || (human.GetRightItem() != null && (int)human.GetRightItem().m_shared.m_itemType == 15))) { human.HideHandItems(false, true); } } } [HarmonyPatch(typeof(Trader), "GetAvailableItems")] public static class Trader_GetAvailableItems_SeasonalTraderItems { [HarmonyPriority(800)] private static void Postfix(Trader __instance, ref List __result) { if (Seasons.controlTraders.Value) { SeasonState.seasonTraderItems.AddSeasonalTraderItems(__instance, __result); } } } [HarmonyPatch(typeof(Game), "UpdateSleeping")] public static class Game_UpdateSleeping_ForceUpdateState { [HarmonyPriority(800)] private static void Prefix(bool ___m_sleeping, ref bool __state) { __state = ___m_sleeping; } [HarmonyPriority(0)] private static void Postfix(bool ___m_sleeping, bool __state) { if (!___m_sleeping && __state) { EnvManPatches.sleepingUpdated = true; } } } [HarmonyPatch(typeof(Terminal), "TryRunCommand")] public static class Terminal_TryRunCommand_ForceUpdateState { private static void Postfix(string text) { if (text.IndexOf("skiptime") > -1 && SeasonState.IsActive && Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsServer()) { EnvManPatches.skiptimeUsed = true; } } } [HarmonyPatch(typeof(Settings), "ApplyAndClose")] public static class Settings_ApplyAndClose_ForceUpdateState { private static void Postfix() { Seasons.seasonState?.UpdateWinterBloomEffect(); } } } internal static class EnvManPatches { [HarmonyPatch] public static class EnvMan_DayLength { private static IEnumerable TargetMethods() { yield return AccessTools.Method(typeof(EnvMan), "Awake", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnvMan), "FixedUpdate", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnvMan), "GetCurrentDay", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnvMan), "GetDay", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnvMan), "GetMorningStartSec", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnvMan), "SkipToMorning", (Type[])null, (Type[])null); } [HarmonyPriority(800)] private static void Prefix(ref long ___m_dayLengthSec) { if (Seasons.dayLengthSec.Value != 0L && ___m_dayLengthSec != Seasons.dayLengthSec.Value) { ___m_dayLengthSec = Seasons.dayLengthSec.Value; SeasonState.CheckSeasonChange(); } } } [HarmonyPatch] public static class EnvMan_TotalSecondsUpdate { private static IEnumerable TargetMethods() { yield return AccessTools.Method(typeof(EnvMan), "Awake", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(EnvMan), "OnDestroy", (Type[])null, (Type[])null); } private static void Postfix() { totalSecondsCached = 0; } } [HarmonyPatch(typeof(EnvMan), "UpdateTriggers")] public static class EnvMan_UpdateTriggers_SeasonStateUpdate { private static int secondUpdated; private static void Postfix(float oldDayFraction, float newDayFraction) { float dayFractionForSeasonChange = SeasonState.GetDayFractionForSeasonChange(); bool flag = oldDayFraction > 0.16f && oldDayFraction <= dayFractionForSeasonChange && newDayFraction >= dayFractionForSeasonChange && newDayFraction < 0.3f; if (Seasons.logTime.Value && flag) { Seasons.LogInfo($"It's time to check for seasons change {oldDayFraction} -> {newDayFraction}"); } bool flag2 = totalSecondsCached != 0 && Math.Abs(totalSecondsCached - (int)Seasons.seasonState.GetTotalSeconds()) > 10; if (Seasons.logTime.Value && flag2) { Seasons.LogInfo("Force update season after total seconds was changed significantly"); } if (!flag2 && skiptimeUsed) { flag2 = true; Seasons.LogInfo("Force update season state after skiptime command"); } if (!flag2 && settingsUpdated) { flag2 = true; Seasons.LogInfo("Force update season state after settings update"); } if (!flag2 && sleepingUpdated) { flag2 = true; Seasons.LogInfo("Force update season state after sleeping update"); } skiptimeUsed = false; settingsUpdated = false; sleepingUpdated = false; if (secondUpdated != (secondUpdated = DateTime.Now.Second) || flag || flag2) { totalSecondsCached = (int)Seasons.seasonState.GetTotalSeconds(); Seasons.seasonState.UpdateState(flag, flag2); } } } [HarmonyPatch(typeof(EnvMan), "RescaleDayFraction")] public static class EnvMan_RescaleDayFraction_DayNightLength { [HarmonyPriority(800)] public static bool Prefix(float fraction, ref float __result) { float num = Seasons.seasonState.DayStartFraction(); if (num == 0.15f) { return true; } float num2 = 1f - num; if (fraction >= num && fraction <= num2) { __result = 0.25f + (fraction - num) / (num2 - num) * 0.5f; return false; } if (fraction < 0.5f) { __result = fraction / num * 0.25f; return false; } __result = 0.75f + (fraction - num2) / num * 0.25f; return false; } } [HarmonyPatch(typeof(EnvMan), "GetMorningStartSec")] public static class EnvMan_GetMorningStartSec_DayNightLength { [HarmonyPriority(800)] public static bool Prefix(EnvMan __instance, int day, ref double __result) { __result = (double)(day * __instance.m_dayLengthSec) + (double)((float)__instance.m_dayLengthSec * Seasons.seasonState.DayStartFraction(Seasons.seasonState.GetSeason(day), Seasons.seasonState.GetDayInSeason(day))); return false; } } [HarmonyPatch(typeof(EnvMan), "SkipToMorning")] public static class EnvMan_SkipToMorning_DayNightLength { [HarmonyPriority(800)] public static bool Prefix(EnvMan __instance, ref bool ___m_skipTime, ref double ___m_skipToTime, ref double ___m_timeSkipSpeed) { float num = Seasons.seasonState.DayStartFraction(); if (num == 0.15f) { return true; } double timeSeconds = ZNet.instance.GetTimeSeconds(); double num2 = timeSeconds - (double)((float)__instance.m_dayLengthSec * num); int day = __instance.GetDay(num2); double morningStartSec = __instance.GetMorningStartSec(day + 1); ___m_skipTime = true; ___m_skipToTime = morningStartSec; ___m_timeSkipSpeed = (morningStartSec - timeSeconds) / 12.0; Seasons.LogInfo($"Time: {timeSeconds,-10:F2} Day: {day} Next morning: {morningStartSec,-10:F2} Skipspeed: {___m_timeSkipSpeed,-5:F2}"); return false; } } [HarmonyPatch(typeof(EnvMan), "FixedUpdate")] public static class EnvMan_FixedUpdate_UpdateWarmStatus { private static void Prefix(ref bool __state) { __state = SeasonState.IsCold(); } private static void Postfix(bool __state) { if (__state != SeasonState.IsCold()) { Seasons.seasonState.CheckOverheatStatus(Player.m_localPlayer); } } } [HarmonyPatch(typeof(EnvMan), "SetEnv")] public static class EnvMan_SetEnv_LuminancePatch { private class LightState { public Color m_ambColorNight; public Color m_fogColorNight; public Color m_fogColorSunNight; public Color m_sunColorNight; public Color m_ambColorDay; public Color m_fogColorMorning; public Color m_fogColorDay; public Color m_fogColorEvening; public Color m_fogColorSunMorning; public Color m_fogColorSunDay; public Color m_fogColorSunEvening; public Color m_sunColorMorning; public Color m_sunColorDay; public Color m_sunColorEvening; public float m_lightIntensityDay; public float m_lightIntensityNight; public float m_fogDensityNight; public float m_fogDensityMorning; public float m_fogDensityDay; public float m_fogDensityEvening; } private static readonly LightState _lightState = new LightState(); private static Color ChangeColorLuminance(Color color, float luminanceMultiplier) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) HSLColor hSLColor = new HSLColor(color); hSLColor.l *= luminanceMultiplier; return hSLColor.ToRGBA(); } private static void SaveLightState(EnvSetup env) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) _lightState.m_ambColorNight = env.m_ambColorNight; _lightState.m_sunColorNight = env.m_sunColorNight; _lightState.m_fogColorNight = env.m_fogColorNight; _lightState.m_fogColorSunNight = env.m_fogColorSunNight; _lightState.m_ambColorDay = env.m_ambColorDay; _lightState.m_sunColorDay = env.m_sunColorDay; _lightState.m_fogColorDay = env.m_fogColorDay; _lightState.m_fogColorSunDay = env.m_fogColorSunDay; _lightState.m_sunColorMorning = env.m_sunColorMorning; _lightState.m_fogColorMorning = env.m_fogColorMorning; _lightState.m_fogColorSunMorning = env.m_fogColorSunMorning; _lightState.m_sunColorEvening = env.m_sunColorEvening; _lightState.m_fogColorEvening = env.m_fogColorEvening; _lightState.m_fogColorSunEvening = env.m_fogColorSunEvening; _lightState.m_lightIntensityDay = env.m_lightIntensityDay; _lightState.m_lightIntensityNight = env.m_lightIntensityNight; _lightState.m_fogDensityNight = env.m_fogDensityNight; _lightState.m_fogDensityMorning = env.m_fogDensityMorning; _lightState.m_fogDensityDay = env.m_fogDensityDay; _lightState.m_fogDensityEvening = env.m_fogDensityEvening; } private static void ChangeEnvColor(EnvSetup env, SeasonLightings.SeasonLightingSettings lightingSettings, bool indoors = false) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) env.m_ambColorNight = ChangeColorLuminance(env.m_ambColorNight, indoors ? lightingSettings.indoors.luminanceMultiplier : lightingSettings.night.luminanceMultiplier); env.m_fogColorNight = ChangeColorLuminance(env.m_fogColorNight, indoors ? lightingSettings.indoors.luminanceMultiplier : lightingSettings.night.luminanceMultiplier); env.m_fogColorSunNight = ChangeColorLuminance(env.m_fogColorSunNight, indoors ? lightingSettings.indoors.luminanceMultiplier : lightingSettings.night.luminanceMultiplier); env.m_sunColorNight = ChangeColorLuminance(env.m_sunColorNight, indoors ? lightingSettings.indoors.luminanceMultiplier : lightingSettings.night.luminanceMultiplier); env.m_fogColorMorning = ChangeColorLuminance(env.m_fogColorMorning, indoors ? lightingSettings.indoors.luminanceMultiplier : lightingSettings.morning.luminanceMultiplier); env.m_fogColorSunMorning = ChangeColorLuminance(env.m_fogColorSunMorning, indoors ? lightingSettings.indoors.luminanceMultiplier : lightingSettings.morning.luminanceMultiplier); env.m_sunColorMorning = ChangeColorLuminance(env.m_sunColorMorning, indoors ? lightingSettings.indoors.luminanceMultiplier : lightingSettings.morning.luminanceMultiplier); env.m_ambColorDay = ChangeColorLuminance(env.m_ambColorDay, indoors ? lightingSettings.indoors.luminanceMultiplier : lightingSettings.day.luminanceMultiplier); env.m_fogColorDay = ChangeColorLuminance(env.m_fogColorDay, indoors ? lightingSettings.indoors.luminanceMultiplier : lightingSettings.day.luminanceMultiplier); env.m_fogColorSunDay = ChangeColorLuminance(env.m_fogColorSunDay, indoors ? lightingSettings.indoors.luminanceMultiplier : lightingSettings.day.luminanceMultiplier); env.m_sunColorDay = ChangeColorLuminance(env.m_sunColorDay, indoors ? lightingSettings.indoors.luminanceMultiplier : lightingSettings.day.luminanceMultiplier); env.m_fogColorEvening = ChangeColorLuminance(env.m_fogColorEvening, indoors ? lightingSettings.indoors.luminanceMultiplier : lightingSettings.evening.luminanceMultiplier); env.m_fogColorSunEvening = ChangeColorLuminance(env.m_fogColorSunEvening, indoors ? lightingSettings.indoors.luminanceMultiplier : lightingSettings.evening.luminanceMultiplier); env.m_sunColorEvening = ChangeColorLuminance(env.m_sunColorEvening, indoors ? lightingSettings.indoors.luminanceMultiplier : lightingSettings.evening.luminanceMultiplier); env.m_fogDensityNight *= (indoors ? lightingSettings.indoors.fogDensityMultiplier : lightingSettings.night.fogDensityMultiplier); env.m_fogDensityMorning *= (indoors ? lightingSettings.indoors.fogDensityMultiplier : lightingSettings.morning.fogDensityMultiplier); env.m_fogDensityDay *= (indoors ? lightingSettings.indoors.fogDensityMultiplier : lightingSettings.day.fogDensityMultiplier); env.m_fogDensityEvening *= (indoors ? lightingSettings.indoors.fogDensityMultiplier : lightingSettings.evening.fogDensityMultiplier); env.m_lightIntensityDay *= lightingSettings.lightIntensityDayMultiplier; env.m_lightIntensityNight *= lightingSettings.lightIntensityNightMultiplier; } public static void ChangeLightState(EnvSetup env) { SaveLightState(env); SeasonLightings.SeasonLightingSettings seasonLighting = SeasonState.seasonLightings.GetSeasonLighting(Seasons.seasonState.GetCurrentSeason()); ChangeEnvColor(env, seasonLighting, (Object)(object)Player.m_localPlayer != (Object)null && ((Character)Player.m_localPlayer).InInterior()); } public static void ResetLightState(EnvSetup env) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) env.m_ambColorNight = _lightState.m_ambColorNight; env.m_sunColorNight = _lightState.m_sunColorNight; env.m_fogColorNight = _lightState.m_fogColorNight; env.m_fogColorSunNight = _lightState.m_fogColorSunNight; env.m_ambColorDay = _lightState.m_ambColorDay; env.m_sunColorDay = _lightState.m_sunColorDay; env.m_fogColorDay = _lightState.m_fogColorDay; env.m_fogColorSunDay = _lightState.m_fogColorSunDay; env.m_sunColorMorning = _lightState.m_sunColorMorning; env.m_fogColorMorning = _lightState.m_fogColorMorning; env.m_fogColorSunMorning = _lightState.m_fogColorSunMorning; env.m_sunColorEvening = _lightState.m_sunColorEvening; env.m_fogColorEvening = _lightState.m_fogColorEvening; env.m_fogColorSunEvening = _lightState.m_fogColorSunEvening; env.m_fogDensityNight = _lightState.m_fogDensityNight; env.m_fogDensityMorning = _lightState.m_fogDensityMorning; env.m_fogDensityDay = _lightState.m_fogDensityDay; env.m_fogDensityEvening = _lightState.m_fogDensityEvening; env.m_lightIntensityDay = _lightState.m_lightIntensityDay; env.m_lightIntensityNight = _lightState.m_lightIntensityNight; } [HarmonyPriority(0)] [HarmonyBefore(new string[] { "shudnal.GammaOfNightLights" })] public static void Prefix(EnvSetup env) { if (Seasons.controlLightings.Value && Seasons.UseTextureControllers()) { ChangeLightState(env); } } [HarmonyPriority(800)] [HarmonyAfter(new string[] { "shudnal.GammaOfNightLights" })] public static void Postfix(EnvSetup env) { if (Seasons.controlLightings.Value && Seasons.UseTextureControllers()) { ResetLightState(env); } } } [HarmonyPatch(typeof(EnvMan), "CalculateFreezing")] public static class EnvMan_CalculateFreezing_SwimmingInWinterIsFreezing { private static void Postfix(ref bool __result) { if (Seasons.freezingSwimmingInWinter.Value) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { __result = __result || (((Character)localPlayer).IsSwimming() && Seasons.seasonState.GetCurrentSeason() == Seasons.Season.Winter && SeasonState.IsCold()); } } } } [HarmonyPatch(typeof(EnvMan), "OnMorning")] public static class EnvMan_OnMorning_SeasonChangeAnnouncement { private static void ShowMessage(string message) { MessageHud.instance.m_msgQeue.Clear(); MessageHud.instance.ShowMessage((MessageType)2, message, 0, (Sprite)null, false); } private static void Postfix() { if (!Seasons.overrideNewDayMessagesOnSeasonStartEnd.Value) { return; } Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { if (Seasons.seasonState.GetCurrentDay() == 1) { ShowMessage(Seasons.GetSeasonTooltip(Seasons.seasonState.GetCurrentSeason())); } else if (Seasons.seasonState.GetCurrentDay() == Seasons.seasonState.GetDaysInSeason()) { ShowMessage(Seasons.GetSeasonIsComing(Seasons.seasonState.GetNextSeason())); } } } } [HarmonyPatch(typeof(EnvMan), "GetWindForce")] public static class EnvMan_GetWindForce_WindIntensityMultiplier { private static float s_multiplier; private static void Prefix(ref Vector4 ___m_wind, ref float __state) { s_multiplier = Seasons.seasonState.GetWindIntensityMultiplier(); if (s_multiplier != 1f) { __state = ___m_wind.w; ___m_wind.w *= s_multiplier; } } private static void Postfix(ref Vector4 ___m_wind, float __state) { if (s_multiplier != 1f) { ___m_wind.w = __state; } } } [HarmonyPatch(typeof(EnvMan), "GetWindIntensity")] public static class EnvMan_GetWindIntensity_WindIntensityMultiplier { private static void Postfix(ref float __result) { __result *= Seasons.seasonState.GetWindIntensityMultiplier(); } } private static int totalSecondsCached; internal static bool skiptimeUsed; internal static bool settingsUpdated; internal static bool sleepingUpdated; } public class SeasonState { private Seasons.Season m_season = Seasons.Season.Spring; private int m_day = 0; private int m_worldDay = 0; private int m_dayInSeasonGlobal = 0; private bool m_seasonIsChanging = false; private bool m_isUsingIngameDays = true; private int m_dayStartFractionCacheWorldDay = int.MinValue; private float m_dayStartFractionCached = 0.15f; public static readonly Dictionary seasonsSettings = new Dictionary(); public static List seasonEnvironments = SeasonEnvironment.GetDefaultCustomEnvironments(); public static SeasonBiomeEnvironments seasonBiomeEnvironments = new SeasonBiomeEnvironments(loadDefaults: true); public static SeasonRandomEvents seasonRandomEvents = new SeasonRandomEvents(loadDefaults: true); public static SeasonLightings seasonLightings = new SeasonLightings(loadDefaults: true); public static SeasonStats seasonStats = new SeasonStats(loadDefaults: true); public static SeasonTraderItems seasonTraderItems = new SeasonTraderItems(loadDefaults: true); public static SeasonWorldSettings seasonWorldSettings = new SeasonWorldSettings(); public static SeasonGrassSettings seasonGrassSettings = new SeasonGrassSettings(loadDefaults: true); public static SeasonClutterSettings seasonClutterSettings = new SeasonClutterSettings(loadDefaults: true); public static SeasonBiomeSettings seasonBiomeSettings = new SeasonBiomeSettings(loadDefaults: true); private static readonly Seasons.Season[] _seasons = (Seasons.Season[])Enum.GetValues(typeof(Seasons.Season)); private static readonly Dictionary biomesDefault = new Dictionary(); private static readonly Dictionary replacedEnvironmentDefaults = new Dictionary(StringComparer.Ordinal); private static readonly Dictionary appliedSeasonEnvironmentObjects = new Dictionary(StringComparer.Ordinal); private static readonly List _itemDataList = new List(); private static readonly HashSet _coolingFoodNames = new HashSet(StringComparer.OrdinalIgnoreCase); private static int _pendingSeasonChange = 0; private static string _coolingFoodNamesValue = string.Empty; private static readonly FieldInfo[] envEntryFields = typeof(EnvEntry).GetFields(BindingFlags.Instance | BindingFlags.Public); private static readonly HashSet unresolvedSeasonEnvironmentRules = new HashSet(StringComparer.OrdinalIgnoreCase); private SeasonSettings settings { get { if (!seasonsSettings.ContainsKey(m_season)) { seasonsSettings.Add(m_season, new SeasonSettings(m_season)); } return seasonsSettings[m_season]; } } public static bool IsActive => Seasons.seasonState != null && (Object)(object)EnvMan.instance != (Object)null; public SeasonState(bool initialize = false) { if (!initialize) { return; } ClearBiomesDefault(); ResetEnvironmentStateTracking(); Seasons.Season[] seasons = _seasons; foreach (Seasons.Season season in seasons) { if (!seasonsSettings.ContainsKey(season)) { seasonsSettings.Add(season, new SeasonSettings(season)); } } string text = Path.Combine(Seasons.configDirectory, "Default settings"); Directory.CreateDirectory(text); Seasons.LogInfo("Saving default seasons settings"); foreach (KeyValuePair seasonsSetting in seasonsSettings) { string filename = Path.Combine(text, GetSeasonalFileName(seasonsSetting.Key)); seasonsSetting.Value.SaveToJSON(filename); } SeasonSettings.SaveDefaultEnvironments(text); SeasonSettings.SaveDefaultEvents(text); SeasonSettings.SaveDefaultLightings(text); SeasonSettings.SaveDefaultStats(text); SeasonSettings.SaveDefaultTraderItems(text); SeasonSettings.SaveDefaultWorldSettings(text); SeasonSettings.SaveDefaultGrassSettings(text); SeasonSettings.SaveDefaultClutterSettings(text); SeasonSettings.SaveDefaultBiomesSettings(text); UpdateUsingOfIngameDays(); } public static string GetSeasonalFileName(Seasons.Season season) { return $"{season}.json"; } public static long GetDayLengthInSecondsEnvMan() { return (!((Object)(object)EnvMan.instance == (Object)null)) ? EnvMan.instance.m_dayLengthSec : ((Seasons.dayLengthSec.Value != 0L) ? Seasons.dayLengthSec.Value : 1800); } public int GetWorldDay(double seconds) { return (int)(seconds / (double)GetDayLengthInSeconds()); } public int GetCurrentWorldDay() { return GetWorldDay(GetTotalSeconds()); } public void UpdateState(bool timeForSeasonToChange = false, bool forceSeasonChange = false) { if (!IsActive || !ZNet.instance.IsServer()) { return; } int currentWorldDay = GetCurrentWorldDay(); m_dayInSeasonGlobal = GetDayInSeason(currentWorldDay); Seasons.Season season = GetSeason(currentWorldDay); int season2 = (int)m_season; forceSeasonChange = forceSeasonChange || !m_isUsingIngameDays || season == GetPreviousSeason(m_season) || Math.Abs(m_worldDay - currentWorldDay) > 1; bool flag = forceSeasonChange || !Seasons.changeSeasonOnlyAfterSleep.Value || Game.instance.m_sleeping; if (Seasons.logTime.Value) { Seasons.LogInfo($"Current: {m_season,-6} {m_day} {m_worldDay} New: {season,-6} {m_dayInSeasonGlobal} {currentWorldDay} Time: {EnvMan.instance.GetDayFraction(),-6:F4} TotalSeconds: {GetTotalSeconds(),-10:F2} TimeToChange:{timeForSeasonToChange,-5} SleepCheck:{flag,-5} Force:{forceSeasonChange,-5} ToPast:{timeForSeasonToChange && !forceSeasonChange && !flag && m_isUsingIngameDays && Seasons.changeSeasonOnlyAfterSleep.Value && GetCurrentDay() == GetDaysInSeason() && m_dayInSeasonGlobal != GetCurrentDay(),-5}"); } Seasons.Season season3 = m_season; if (Seasons.overrideSeason.Value) { season3 = Seasons.seasonOverrided.Value; } else if (season != GetCurrentSeason() && (timeForSeasonToChange || forceSeasonChange)) { if (timeForSeasonToChange && !forceSeasonChange && !flag && m_isUsingIngameDays && Seasons.changeSeasonOnlyAfterSleep.Value && GetCurrentDay() == GetDaysInSeason() && m_dayInSeasonGlobal != GetCurrentDay()) { double val = ZNet.instance.GetTimeSeconds() - (double)EnvMan.instance.m_dayLengthSec; ZNet.instance.SetNetTime(Math.Max(val, 0.0)); ZNet.instance.SendNetTime(); EnvMan.instance.m_skipTime = false; EnvMan.instance.m_totalSeconds = ZNet.instance.GetTimeSeconds(); currentWorldDay = GetCurrentWorldDay(); m_dayInSeasonGlobal = GetDayInSeason(currentWorldDay); season = GetSeason(currentWorldDay); } season3 = season; } if (Seasons.overrideSeasonDay.Value) { m_dayInSeasonGlobal = Math.Clamp(Seasons.seasonDayOverrided.Value, 1, GetDaysInSeason(season3)); } if (!CheckIfSeasonChanged(season2, season3, m_dayInSeasonGlobal, currentWorldDay)) { CheckIfDayChanged(m_dayInSeasonGlobal, currentWorldDay, forceSeasonChange); } } public void OnBiomeChange(Biome previousBiome, Biome currentBiome) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_003c: 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) if ((int)previousBiome != 0 && previousBiome != currentBiome) { if (GetCurrentSeason() == Seasons.Season.Winter && ((int)previousBiome == 32 || (int)currentBiome == 32)) { ZoneSystemVariantController.UpdateWaterState(); } if (GetTorchAsFiresource() && TorchHeatInBiome(previousBiome) != TorchHeatInBiome(currentBiome)) { UpdateTorchesFireWarmth(); } } } public void OnInteriorChanged(bool inInterior) { if (Seasons.disableTorchWarmthInInterior.Value) { UpdateTorchesFireWarmth(); } } private World GetCurrentWorld() { return ZNet.m_world ?? WorldGenerator.instance?.m_world; } private void UpdateUsingOfIngameDays() { bool isUsingIngameDays = m_isUsingIngameDays; m_isUsingIngameDays = !seasonWorldSettings.HasWorldSettings(GetCurrentWorld()); if (m_isUsingIngameDays != isUsingIngameDays) { UpdateState(timeForSeasonToChange: false, forceSeasonChange: true); } } private DateTime GetStartTimeUTC() { return seasonWorldSettings.GetStartTimeUTC(GetCurrentWorld()); } public double GetTotalSeconds() { return m_isUsingIngameDays ? ZNet.instance.GetTimeSeconds() : DateTime.UtcNow.Subtract(GetStartTimeUTC()).TotalSeconds; } public long GetDayLengthInSeconds() { return Math.Max(5L, m_isUsingIngameDays ? GetDayLengthInSecondsEnvMan() : seasonWorldSettings.GetDayLengthSeconds(GetCurrentWorld())); } public Seasons.Season GetCurrentSeason() { return m_season; } public bool GetSeasonIsChanging() { return Seasons.showFadeOnSeasonChange.Value && m_seasonIsChanging; } public int GetCurrentDay() { return m_day; } public int GetDaysInSeason() { return Math.Max(1, settings.m_daysInSeason); } public int GetDaysInSeason(Seasons.Season season) { return Math.Max(1, GetSeasonSettings(season).m_daysInSeason); } public long GetSecondsInSeason() { return GetDaysInSeason() * GetDayLengthInSeconds(); } public long GetSecondsInSeason(Seasons.Season season) { return GetDaysInSeason(season) * GetDayLengthInSeconds(); } public float GetPlantsGrowthMultiplier() { return GetPlantsGrowthMultiplier(GetCurrentSeason()); } public float GetPlantsGrowthMultiplier(Seasons.Season season) { return GetSeasonSettings(season).m_plantsGrowthMultiplier; } public Seasons.Season GetPreviousSeason() { return GetPreviousSeason(m_season); } public Seasons.Season GetNextSeason() { return GetNextSeason(m_season); } public Seasons.Season GetPreviousSeason(Seasons.Season season) { return (Seasons.Season)((int)(4 + season - 1) % 4); } public Seasons.Season GetNextSeason(Seasons.Season season) { return (Seasons.Season)((int)(season + 1) % 4); } public int GetNightLength() { int currentWorldDay = GetCurrentWorldDay(); return GetNightLength(GetSeason(currentWorldDay), GetDayInSeason(currentWorldDay)); } public int GetNightLength(Seasons.Season season, int dayInSeason) { int nightLength = GetSeasonSettings(season).m_nightLength; if (!Seasons.changeNightLengthGradually.Value) { return nightLength; } int daysInSeason = GetDaysInSeason(season); float num = (float)daysInSeason / 2f; int num2 = Mathf.CeilToInt(num); int num3 = Mathf.FloorToInt(num); if (dayInSeason == num3 || dayInSeason == num2) { return nightLength; } if (dayInSeason < num3) { Seasons.Season previousSeason = GetPreviousSeason(season); int daysInSeason2 = GetDaysInSeason(season); num2 = Mathf.CeilToInt((float)daysInSeason2 / 2f); int num4 = daysInSeason2 - num2; int nightLength2 = GetSeasonSettings(previousSeason).m_nightLength; return Mathf.RoundToInt(Mathf.Lerp((float)nightLength2, (float)nightLength, (float)(dayInSeason + num4) / (float)(num3 + num4))); } if (dayInSeason > num2) { Seasons.Season nextSeason = GetNextSeason(season); int daysInSeason3 = GetDaysInSeason(nextSeason); num3 = Mathf.FloorToInt((float)daysInSeason3 / 2f); int num5 = daysInSeason - num2; int nightLength3 = GetSeasonSettings(nextSeason).m_nightLength; return Mathf.RoundToInt(Mathf.Lerp((float)nightLength, (float)nightLength3, (float)(dayInSeason - num2) / (float)(num3 + num5))); } return nightLength; } public static void InitializeTextureControllers() { ((Component)ZoneSystem.instance).gameObject.AddComponent(); PrefabVariantController.AddControllerToPrefabs(); ClutterVariantController.Initialize(); ((Component)ZoneSystem.instance).gameObject.AddComponent().Initialize(ZoneSystem.instance); Seasons.FillListsToControl(); Seasons.InvalidatePositionsCache(); CustomTextures.SetupConfigWatcher(); CustomMusic.SetupConfigWatcher(); } public static void ClearBiomesDefault() { biomesDefault.Clear(); } public static void RefreshBiomesDefault(bool forceUpdate) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (forceUpdate) { ClearBiomesDefault(); } if (!Object.op_Implicit((Object)(object)EnvMan.instance)) { return; } foreach (BiomeEnvSetup biome in EnvMan.instance.m_biomes) { if (biomesDefault.TryGetValue(biome.m_biome, out var value)) { if (forceUpdate) { BiomeEnvSetup val = JsonUtility.FromJson(value); val.m_environments.AddRange(biome.m_environments); biomesDefault[biome.m_biome] = JsonUtility.ToJson((object)val); } } else { biomesDefault[biome.m_biome] = JsonUtility.ToJson((object)biome); } } } private void UpdateBiomesSetup() { RefreshBiomesDefault(forceUpdate: false); if (EWDCompat.ShouldApplySeasonalRulesToAvailableEnvironments()) { RefreshBiomeEnvironmentReferences(); UpdateCurrentEnvironment(); return; } SeasonBiomeEnvironments.SeasonBiomeEnvironment biomeEnv = (Seasons.controlEnvironments.Value ? seasonBiomeEnvironments.GetSeasonBiomeEnvironment(Seasons.seasonState.GetCurrentSeason()) : null); EnvMan.instance.m_biomes.Clear(); CollectionExtensions.Do>((IEnumerable>)biomesDefault, (Action>)delegate(KeyValuePair kvp) { ChangeBiomeEnvironment(kvp.Value); }); RefreshBiomeEnvironmentReferences(); UpdateCurrentEnvironment(); EWDCompat.OnSeasonsBiomeSetupApplied(); void ChangeBiomeEnvironment(string biomeEnvironmentDefault) { try { BiomeEnvSetup val = JsonUtility.FromJson(biomeEnvironmentDefault); if (biomeEnv != null) { val.m_environments = ApplySeasonBiomeEnvironmentRules(biomeEnv, val, val.m_environments); } EnvMan.instance.AppendBiomeSetup(val); } catch (Exception arg) { Seasons.LogWarning($"Error appending biome setup:\n{biomeEnvironmentDefault}\n{arg}"); } } } public static void UpdateSeasonSettings() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (!IsActive) { return; } JsonSerializerSettings val = new JsonSerializerSettings { DefaultValueHandling = (DefaultValueHandling)1 }; seasonsSettings.Clear(); foreach (KeyValuePair item in Seasons.seasonsSettingsJSON.Value) { try { if (!string.IsNullOrEmpty(item.Value)) { seasonsSettings[(Seasons.Season)item.Key] = new SeasonSettings((Seasons.Season)item.Key, JsonConvert.DeserializeObject(item.Value, val)); Seasons.LogInfo($"Settings updated: {(Seasons.Season)item.Key}"); } } catch (Exception arg) { Seasons.LogWarning($"Error parsing settings: {(Seasons.Season)item.Key}\n{arg}"); } } Seasons.seasonState.UpdateUsingOfIngameDays(); Seasons.seasonState.UpdateTorchesFireWarmth(); LoadingTips.UpdateLoadingTips(); EnvManPatches.settingsUpdated = true; } public static void UpdateSeasonEnvironments() { UpdateSeasonEnvironments(rebuildBiomeSetup: true); } private static void UpdateSeasonEnvironments(bool rebuildBiomeSetup) { if (!IsActive || (Object)(object)EnvMan.instance == (Object)null) { return; } unresolvedSeasonEnvironmentRules.Clear(); if (!Seasons.controlEnvironments.Value) { RestoreEnvironmentControlState(); return; } RemoveAppliedSeasonEnvironments(); CustomMusic.CheckMusicList(); SeasonEnvironment.RebuildCachedObjects(); if (!string.IsNullOrEmpty(Seasons.customEnvironmentsJSON.Value)) { try { seasonEnvironments = JsonConvert.DeserializeObject>(Seasons.customEnvironmentsJSON.Value); seasonEnvironments = SortCustomEnvironmentsByCloneDependencies(seasonEnvironments); Seasons.LogInfo("Custom environments updated"); } catch (Exception arg) { Seasons.LogWarning($"Error parsing custom environments:\n{arg}"); } } else { seasonEnvironments = SeasonEnvironment.GetDefaultCustomEnvironments(); seasonEnvironments = SortCustomEnvironmentsByCloneDependencies(seasonEnvironments); Seasons.LogInfo("Custom environments loaded defaults"); } SeasonEnvironment.AddCachedObjectsFromCurrentEnvironments(); foreach (SeasonEnvironment seasonEnvironment in seasonEnvironments) { if (seasonEnvironment != null && !string.IsNullOrWhiteSpace(seasonEnvironment.m_name)) { EnvSetup env = EnvMan.instance.GetEnv(seasonEnvironment.m_name); if (env != null) { replacedEnvironmentDefaults[seasonEnvironment.m_name] = env; EnvMan.instance.m_environments.Remove(env); } EnvSetup val = seasonEnvironment.ToEnvSetup(); EnvMan.instance.AppendEnvironment(val); appliedSeasonEnvironmentObjects[seasonEnvironment.m_name] = val; SeasonEnvironment.AddCachedObjects(val); } } if (rebuildBiomeSetup) { Seasons.seasonState.UpdateBiomesSetup(); } else { UpdateCurrentEnvironment(); } } public static void UpdateEnvironmentControlState() { if (IsActive) { if (Seasons.controlEnvironments.Value) { UpdateSeasonEnvironments(rebuildBiomeSetup: false); UpdateBiomeEnvironments(); } else { RestoreEnvironmentControlState(); } } LoadingTips.UpdateLoadingTips(); } public static void PrepareForExternalEnvironmentUpdate() { if (!((Object)(object)EnvMan.instance == (Object)null) && appliedSeasonEnvironmentObjects.Count != 0 && !appliedSeasonEnvironmentObjects.Values.Any((EnvSetup environment) => environment != null && EnvMan.instance.m_environments.Contains(environment))) { ResetEnvironmentStateTracking(); } } public static void ResetEnvironmentStateTracking() { replacedEnvironmentDefaults.Clear(); appliedSeasonEnvironmentObjects.Clear(); } private static void RestoreEnvironmentControlState() { unresolvedSeasonEnvironmentRules.Clear(); RemoveAppliedSeasonEnvironments(); Seasons.seasonState.UpdateBiomesSetup(); } private static void RemoveAppliedSeasonEnvironments() { if ((Object)(object)EnvMan.instance == (Object)null) { ResetEnvironmentStateTracking(); return; } foreach (EnvSetup value in appliedSeasonEnvironmentObjects.Values) { if (value != null) { EnvMan.instance.m_environments.Remove(value); } } foreach (KeyValuePair replacedEnvironmentDefault in replacedEnvironmentDefaults) { if (replacedEnvironmentDefault.Value != null && EnvMan.instance.GetEnv(replacedEnvironmentDefault.Key) == null) { EnvMan.instance.AppendEnvironment(replacedEnvironmentDefault.Value); } } ResetEnvironmentStateTracking(); } private static void RefreshBiomeEnvironmentReferences() { if (EnvMan.instance?.m_biomes == null) { return; } HashSet hashSet = new HashSet(); foreach (BiomeEnvSetup biome in EnvMan.instance.m_biomes) { if (biome == null) { continue; } EnvMan.instance.InitializeBiomeEnvSetup(biome); foreach (EnvEntry environment in biome.m_environments) { if (environment != null && environment.m_env == null && !string.IsNullOrWhiteSpace(environment.m_environment)) { hashSet.Add(environment.m_environment); } } } if (hashSet.Count > 0) { Seasons.LogWarning("Unresolved biome environment references: " + string.Join(", ", hashSet.OrderBy((string name) => name))); } } public static void ReapplyEnvironmentStateAfterWorldInitialization() { if (IsActive) { UpdateSeasonEnvironments(rebuildBiomeSetup: false); UpdateBiomeEnvironments(); if (Seasons.currentSeasonDay.Value > 0) { OnSeasonDayChange(); } } } private static void UpdateCurrentEnvironment() { EnvMan.instance.m_environmentPeriod = -1L; } public static void UpdateBiomeEnvironments() { if (!IsActive) { return; } unresolvedSeasonEnvironmentRules.Clear(); if (!Seasons.controlEnvironments.Value) { return; } if (!string.IsNullOrEmpty(Seasons.customBiomeEnvironmentsJSON.Value)) { try { seasonBiomeEnvironments = JsonConvert.DeserializeObject(Seasons.customBiomeEnvironmentsJSON.Value); Seasons.LogInfo("Custom biome environments updated"); } catch (Exception arg) { Seasons.LogWarning($"Error parsing custom biome environments:\n{arg}"); } } else { seasonBiomeEnvironments = new SeasonBiomeEnvironments(loadDefaults: true); Seasons.LogInfo("Custom biome environments loaded defaults"); } Seasons.seasonState.UpdateBiomesSetup(); } public static void UpdateRandomEvents() { if (!IsActive) { return; } if (!string.IsNullOrEmpty(Seasons.customEventsJSON.Value)) { try { seasonRandomEvents = JsonConvert.DeserializeObject(Seasons.customEventsJSON.Value); Seasons.LogInfo("Custom events updated"); return; } catch (Exception arg) { Seasons.LogWarning($"Error parsing custom events:\n{arg}"); return; } } seasonRandomEvents = new SeasonRandomEvents(loadDefaults: true); Seasons.LogInfo("Custom events loaded defaults"); } public static void UpdateLightings() { if (!IsActive) { return; } if (!string.IsNullOrEmpty(Seasons.customLightingsJSON.Value)) { try { seasonLightings = JsonConvert.DeserializeObject(Seasons.customLightingsJSON.Value); Seasons.LogInfo("Custom lightings updated"); return; } catch (Exception arg) { Seasons.LogWarning($"Error parsing custom lightings:\n{arg}"); return; } } seasonLightings = new SeasonLightings(loadDefaults: true); Seasons.LogInfo("Custom lightings loaded defaults"); } public static void UpdateStats() { if (!IsActive) { return; } if (!string.IsNullOrEmpty(Seasons.customStatsJSON.Value)) { try { seasonStats = JsonConvert.DeserializeObject(Seasons.customStatsJSON.Value); Seasons.LogInfo("Custom stats updated"); } catch (Exception arg) { Seasons.LogWarning($"Error parsing custom stats:\n{arg}"); } } else { seasonStats = new SeasonStats(loadDefaults: true); Seasons.LogInfo("Custom stats loaded defaults"); } SE_Season.UpdateSeasonStatusEffectStats(); } public static void UpdateTraderItems() { if (!IsActive) { return; } if (!string.IsNullOrEmpty(Seasons.customTraderItemsJSON.Value)) { try { seasonTraderItems = JsonConvert.DeserializeObject(Seasons.customTraderItemsJSON.Value); Seasons.LogInfo("Custom trader items updated"); return; } catch (Exception arg) { Seasons.LogWarning($"Error parsing custom trader items:\n{arg}"); return; } } seasonTraderItems = new SeasonTraderItems(loadDefaults: true); Seasons.LogInfo("Custom trader items loaded defaults"); } public static void UpdateWorldSettings() { if (!IsActive) { return; } if (!string.IsNullOrEmpty(Seasons.customWorldSettingsJSON.Value)) { try { seasonWorldSettings = JsonConvert.DeserializeObject(Seasons.customWorldSettingsJSON.Value); Seasons.LogInfo("Custom world settings updated"); } catch (Exception arg) { Seasons.LogWarning($"Error parsing world settings items:\n{arg}"); } } else { seasonWorldSettings = new SeasonWorldSettings(); Seasons.LogInfo("Custom world settings loaded defaults"); } Seasons.seasonState.UpdateUsingOfIngameDays(); } public static void UpdateGrassSettings() { if (!IsActive) { return; } if (!string.IsNullOrEmpty(Seasons.customGrassSettingsJSON.Value)) { try { seasonGrassSettings = JsonConvert.DeserializeObject(Seasons.customGrassSettingsJSON.Value); Seasons.LogInfo("Custom grass settings updated"); } catch (Exception arg) { Seasons.LogWarning($"Error parsing custom grass settings:\n{arg}"); } } else { seasonGrassSettings = new SeasonGrassSettings(loadDefaults: true); Seasons.LogInfo("Custom grass settings loaded defaults"); } StartClutterUpdate(); } public static void UpdateClutterSettings() { if (!IsActive) { return; } if (!string.IsNullOrEmpty(Seasons.customClutterSettingsJSON.Value)) { try { seasonClutterSettings = JsonConvert.DeserializeObject(Seasons.customClutterSettingsJSON.Value); Seasons.LogInfo("Custom clutter settings updated"); } catch (Exception arg) { Seasons.LogWarning($"Error parsing custom clutter settings:\n{arg}"); } } else { seasonClutterSettings = new SeasonClutterSettings(loadDefaults: true); Seasons.LogInfo("Custom clutter settings loaded defaults"); } StartClutterUpdate(); } public static void UpdateBiomeSettings() { if (!IsActive) { return; } if (!string.IsNullOrEmpty(Seasons.customBiomeSettingsJSON.Value)) { try { seasonBiomeSettings = JsonConvert.DeserializeObject(Seasons.customBiomeSettingsJSON.Value); Seasons.LogInfo("Custom biomes settings updated"); } catch (Exception arg) { Seasons.LogWarning($"Error parsing custom biomes settings:\n{arg}"); } } else { seasonBiomeSettings = new SeasonBiomeSettings(loadDefaults: true); Seasons.LogInfo("Custom biomes settings loaded defaults"); } ZoneSystemVariantController.UpdateTerrainColors(); } public void UpdateGlobalKeys() { if (IsActive) { Seasons.Season[] seasons = _seasons; foreach (Seasons.Season season in seasons) { ZoneSystem.instance.RemoveGlobalKey(GetSeasonalGlobalKey(season)); } string seasonalGlobalKey = GetSeasonalGlobalKey(GetCurrentSeason()); if (Seasons.enableSeasonalGlobalKeys.Value) { ZoneSystem.instance.SetGlobalKey(seasonalGlobalKey); } for (int j = 0; j <= Seasons.seasonState.GetYearLengthInDays(); j++) { ZoneSystem.instance.RemoveGlobalKey(GetSeasonalDayGlobalKey(j)); } if (Seasons.enableSeasonalGlobalKeys.Value && !Utility.IsNullOrWhiteSpace(seasonalGlobalKey = GetSeasonalDayGlobalKey(Seasons.seasonState.GetCurrentDay()))) { ZoneSystem.instance.SetGlobalKey(seasonalGlobalKey); } } } public string GetSeasonalGlobalKey(Seasons.Season season) { if (1 == 0) { } string result = season switch { Seasons.Season.Spring => Seasons.seasonalGlobalKeySpring.Value, Seasons.Season.Summer => Seasons.seasonalGlobalKeySummer.Value, Seasons.Season.Fall => Seasons.seasonalGlobalKeyFall.Value, Seasons.Season.Winter => Seasons.seasonalGlobalKeyWinter.Value, _ => Seasons.seasonalGlobalKeySpring.Value, }; if (1 == 0) { } return result; } public string GetSeasonalDayGlobalKey(int day) { return string.Format(Seasons.seasonalGlobalKeyDay.Value, day.ToString()); } public double GetTimeToCurrentSeasonEnd() { return GetEndOfCurrentSeason() + (double)(Seasons.seasonState.DayStartFraction() * (1f - (0.25f - GetDayFractionForSeasonChange()) * Seasons.seasonState.DayStartFraction() / 0.25f) * (float)Seasons.seasonState.GetDayLengthInSeconds()) - Seasons.seasonState.GetTotalSeconds(); } public double GetEndOfCurrentSeason() { return GetStartOfCurrentSeason() + (double)Seasons.seasonState.GetSecondsInSeason(); } public double GetStartOfCurrentSeason() { double num = GetTotalSeconds() - GetTotalSeconds() % (double)GetDayLengthInSeconds(); return num - (double)((GetCurrentDay() - ((!IsPendingSeasonChange()) ? 1 : 0)) * GetDayLengthInSeconds()); } public bool IsPendingSeasonChange() { return 0 < m_dayInSeasonGlobal && m_dayInSeasonGlobal < GetCurrentDay(); } public float DayStartFraction() { int currentWorldDay = GetCurrentWorldDay(); if (m_dayStartFractionCacheWorldDay == currentWorldDay) { return m_dayStartFractionCached; } m_dayStartFractionCacheWorldDay = currentWorldDay; m_dayStartFractionCached = DayStartFraction(GetSeason(currentWorldDay), GetDayInSeason(currentWorldDay)); return m_dayStartFractionCached; } public float DayStartFraction(Seasons.Season season, int dayInSeason) { return (float)Seasons.seasonState.GetNightLength(season, dayInSeason) / 2f / 100f; } public bool GetTorchAsFiresource() { return settings.m_torchAsFiresource; } public float GetTorchDurabilityDrain() { return settings.m_torchDurabilityDrain; } public float GetBeehiveProductionMultiplier() { return GetBeehiveProductionMultiplier(Seasons.seasonState.GetCurrentSeason()); } public float GetBeehiveProductionMultiplier(Seasons.Season season) { return GetSeasonSettings(season).m_beehiveProductionMultiplier; } public float GetFoodDrainMultiplier() { return settings.m_foodDrainMultiplier; } public float GetStaminaDrainMultiplier() { return settings.m_staminaDrainMultiplier; } public float GetFireplaceDrainMultiplier() { return GetFireplaceDrainMultiplier(Seasons.seasonState.GetCurrentSeason()); } public float GetFireplaceDrainMultiplier(Seasons.Season season) { return GetSeasonSettings(season).m_fireplaceDrainMultiplier; } public float GetSapCollectingSpeedMultiplier() { return GetSapCollectingSpeedMultiplier(Seasons.seasonState.GetCurrentSeason()); } public float GetSapCollectingSpeedMultiplier(Seasons.Season season) { return GetSeasonSettings(season).m_sapCollectingSpeedMultiplier; } public bool GetRainProtection() { return settings.m_rainProtection; } public float GetWoodFromTreesMultiplier() { return settings.m_woodFromTreesMultiplier; } public float GetMeatFromAnimalsMultiplier() { return settings.m_meatFromAnimalsMultiplier; } public float GetWindIntensityMultiplier() { return settings.m_windIntensityMultiplier; } public float GetRestedBuffDurationMultiplier() { return settings.m_restedBuffDurationMultiplier; } public float GetLivestockProcreationMultiplier() { return settings.m_livestockProcreationMultiplier; } public bool GetOverheatIn2WarmClothes() { return settings.m_overheatIn2WarmClothes; } public float GetTreesReqrowthChance() { return settings.m_treesRegrowthChance; } public SeasonSettings GetSeasonSettings(Seasons.Season season) { return seasonsSettings.ContainsKey(season) ? seasonsSettings[season] : new SeasonSettings(season); } public Seasons.Season GetSeason(int day) { int dayOfYear = GetDayOfYear(day); int num = 0; Seasons.Season[] seasons = _seasons; foreach (Seasons.Season season in seasons) { num += GetDaysInSeason(season); if (dayOfYear <= num) { return season; } } return Seasons.Season.Winter; } public int GetDayInSeason(int day) { int dayOfYear = GetDayOfYear(day); int num = 0; int num2 = 0; Seasons.Season[] seasons = _seasons; foreach (Seasons.Season season in seasons) { num2 = GetDaysInSeason(season); if (dayOfYear <= num + num2) { return dayOfYear - num; } num += num2; } return (dayOfYear >= num) ? num2 : (dayOfYear - num); } public int GetDayOfYear(int day) { int yearLengthInDays = GetYearLengthInDays(); int num = day % yearLengthInDays; return (num == day) ? num : ((num == 0) ? yearLengthInDays : num); } public float GetWaterSurfaceFreezeStatus() { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (!Seasons.enableFrozenWater.Value) { return 0f; } if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null && (int)localPlayer.GetCurrentBiome() == 32) { return 0f; } if (ZoneSystemVariantController.IsBeyondWorldEdge(((Component)Player.m_localPlayer).transform.position)) { return 0f; } } int currentDay = GetCurrentDay(); int daysInSeason = GetDaysInSeason(); int val = Mathf.Clamp((int)Seasons.waterFreezesInWinterDays.Value.x, 0, daysInSeason + 1); int num = Mathf.Clamp((int)Seasons.waterFreezesInWinterDays.Value.y, 0, daysInSeason + 1); if (currentDay == 0 || GetCurrentSeason() != Seasons.Season.Winter || num == 0 || num > daysInSeason) { return 0f; } return (currentDay > num) ? Mathf.Clamp01((float)(daysInSeason - currentDay) / (float)Math.Max(daysInSeason - num, 1)) : Mathf.Clamp01((float)currentDay / (float)Math.Max(val, 1)); } public double GetSecondsToMakeHoney(Beehive beehive, int amount = 1, float product = -1f) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (!beehive.m_nview.IsValid()) { return 0.0; } if (product == -1f) { product = beehive.m_nview.GetZDO().GetFloat(ZDOVars.s_product, 0f); } double num = beehive.m_secPerUnit * (float)amount - product; if (Seasons.IsProtectedPosition(((Component)beehive).transform.position)) { return num; } return GetSecondsLeftWithSeasonalMultiplier(num, GetBeehiveProductionMultiplier); } public double GetSecondsToGrowPlant(Plant plant) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (!plant.m_nview.IsValid()) { return 0.0; } double num = (double)plant.GetGrowTime() - plant.TimeSincePlanted(); if (Seasons.IsProtectedPosition(((Component)plant).transform.position)) { return num; } return GetSecondsLeftWithSeasonalMultiplier(num, GetPlantsGrowthMultiplier); } public double GetSecondsToRespawnPickable(Pickable pickable) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!pickable.m_nview.IsValid()) { return 0.0; } double num = pickable.m_respawnTimeMinutes * 60f; if (Seasons.IsProtectedPosition(((Component)pickable).transform.position) || num <= 0.0) { return num; } double totalSeconds = TimeSpan.FromTicks(pickable.m_nview.GetZDO().GetLong(ZDOVars.s_pickedTime, 0L)).TotalSeconds; int worldDay = GetWorldDay(totalSeconds); Seasons.Season season = GetSeason(worldDay); double num2 = totalSeconds - totalSeconds % (double)GetDayLengthInSeconds(); double num3 = num2 - (double)((GetDayInSeason(worldDay) - ((worldDay != GetCurrentWorldDay() || !IsPendingSeasonChange()) ? 1 : 0)) * GetDayLengthInSeconds()); double num4 = num3 + (double)GetSecondsInSeason(season); float num5 = DayStartFraction(); float num6 = num5 * (1f - (0.25f - GetDayFractionForSeasonChange()) * num5 / 0.25f) * (float)GetDayLengthInSeconds(); double num7 = num4 + (double)num6 - totalSeconds; double num8 = 0.0; float plantsGrowthMultiplier = GetPlantsGrowthMultiplier(season); do { double num9 = ((plantsGrowthMultiplier == 0f) ? num7 : Math.Min(num / (double)plantsGrowthMultiplier, num7)); num8 += num9; num -= num9 * (double)plantsGrowthMultiplier; season = GetNextSeason(season); plantsGrowthMultiplier = GetPlantsGrowthMultiplier(season); num7 = GetDaysInSeason(season) * GetDayLengthInSeconds(); } while (num > 0.0); return num8; } public double GetSecondsToBurnFire(Fireplace fireplace) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (!fireplace.m_nview.IsValid()) { return 0.0; } double num = fireplace.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 0f) * fireplace.m_secPerFuel; if (num == 0.0 || Seasons.IsProtectedPosition(((Component)fireplace).transform.position)) { return num; } return GetSecondsLeftWithSeasonalMultiplier(num, GetFireplaceDrainMultiplier); } public double GetSecondsToBurnFire(Smelter smelter) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (!smelter.m_nview.IsValid() || smelter.m_fuelPerProduct == 0) { return 0.0; } double num = smelter.GetFuel() * smelter.m_secPerProduct / (float)smelter.m_fuelPerProduct; if (num == 0.0 || Seasons.IsProtectedPosition(((Component)smelter).transform.position)) { return num; } return GetSecondsLeftWithSeasonalMultiplier(num, GetFireplaceDrainMultiplier); } public double GetSecondsToBurnFire(CookingStation cookingStation) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (!cookingStation.m_nview.IsValid()) { return 0.0; } double num = cookingStation.GetFuel() * (float)cookingStation.m_secPerFuel; if (num == 0.0 || Seasons.IsProtectedPosition(((Component)cookingStation).transform.position)) { return num; } return GetSecondsLeftWithSeasonalMultiplier(num, GetFireplaceDrainMultiplier); } public double GetSecondsToFillSap(SapCollector sapCollector) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (!sapCollector.m_nview.IsValid()) { return 0.0; } double num = (float)(sapCollector.m_maxLevel - sapCollector.GetLevel()) * sapCollector.m_secPerUnit - sapCollector.m_nview.GetZDO().GetFloat(ZDOVars.s_product, 0f); if (num == 0.0 || Seasons.IsProtectedPosition(((Component)sapCollector).transform.position)) { return num; } return GetSecondsLeftWithSeasonalMultiplier(num, GetSapCollectingSpeedMultiplier); } private double GetSecondsLeftWithSeasonalMultiplier(double secondsLeft, Func getMultiplier) { Seasons.Season season = GetCurrentSeason(); float num = getMultiplier(season); double num2 = 0.0; double num3 = GetTimeToCurrentSeasonEnd(); do { double num4 = ((num == 0f) ? num3 : Math.Min(secondsLeft / (double)num, num3)); num2 += num4; secondsLeft -= num4 * (double)num; season = GetNextSeason(season); num = getMultiplier(season); num3 = GetDaysInSeason(season) * GetDayLengthInSeconds(); } while (secondsLeft > 0.0); return num2; } private bool CheckIfSeasonChanged(int currentSeason, Seasons.Season setSeason, int dayInSeason, int worldDay) { if (currentSeason == (int)setSeason) { return false; } m_worldDay = worldDay; SetCurrentSeasonDay(setSeason, dayInSeason); return true; } private void CheckIfDayChanged(int dayInSeason, int worldDay, bool forceSeasonChange) { if (m_day != dayInSeason || m_worldDay != worldDay) { m_worldDay = worldDay; if (dayInSeason > m_day || forceSeasonChange) { SetCurrentDay(dayInSeason, forceSeasonChange); } } } public void StartSeasonChange() { if (!Seasons.showFadeOnSeasonChange.Value || (Object)(object)Hud.instance == (Object)null || ((Behaviour)Hud.instance.m_loadingScreen).isActiveAndEnabled || Hud.instance.m_loadingScreen.alpha > 0f) { OnSeasonChange(); } else { ((MonoBehaviour)Seasons.instance).StartCoroutine(Seasons.seasonState.SeasonChangedFadeEffect()); } } public IEnumerator SeasonChangedFadeEffect() { m_seasonIsChanging = true; Player player = Player.m_localPlayer; if ((Object)(object)player == (Object)null || ((Character)player).IsDead() || ((Character)player).IsTeleporting() || Game.instance.IsShuttingDown() || player.IsSleeping()) { OnSeasonChange(); m_seasonIsChanging = false; yield break; } float fadeDuration = Seasons.fadeOnSeasonChangeDuration.Value / 2f; ((Component)Hud.instance.m_loadingScreen).gameObject.SetActive(true); Hud.instance.m_loadingProgress.SetActive(false); Hud.instance.m_sleepingProgress.SetActive(false); Hud.instance.m_teleportingProgress.SetActive(false); while (Hud.instance.m_loadingScreen.alpha <= 0.99f) { if ((Object)(object)player == (Object)null || ((Character)player).IsDead() || ((Character)player).IsTeleporting() || Game.instance.IsShuttingDown() || player.IsSleeping()) { OnSeasonChange(); m_seasonIsChanging = false; yield break; } Hud.instance.m_loadingScreen.alpha = Mathf.MoveTowards(Hud.instance.m_loadingScreen.alpha, 1f, Time.fixedDeltaTime / fadeDuration); yield return Seasons.waitForFixedUpdate; } OnSeasonChange(); while (Hud.instance.m_loadingScreen.alpha > 0f) { if ((Object)(object)player == (Object)null || ((Character)player).IsDead() || ((Character)player).IsTeleporting() || Game.instance.IsShuttingDown() || player.IsSleeping()) { m_seasonIsChanging = false; yield break; } Hud.instance.m_loadingScreen.alpha = Mathf.MoveTowards(Hud.instance.m_loadingScreen.alpha, 0f, Time.fixedDeltaTime / fadeDuration); yield return Seasons.waitForFixedUpdate; } ((Component)Hud.instance.m_loadingScreen).gameObject.SetActive(false); m_seasonIsChanging = false; } private void OnSeasonChange() { UpdateBiomesSetup(); UpdateGlobalKeys(); UpdateWinterBloomEffect(); ZoneSystemVariantController.UpdateWaterState(); UpdateCurrentEnvironment(); if (Seasons.UseTextureControllers()) { ClutterVariantController.UpdateShieldActiveState(); ClutterVariantController.Instance?.UpdateColors(); PrefabVariantController.UpdatePrefabColors(); ZoneSystemVariantController.UpdateTerrainColors(); UpdateTorchesFireWarmth(); if ((Object)(object)MinimapVariantController.instance != (Object)null) { MinimapVariantController.instance.UpdateColors(); UpdateMinimapBorder(); } if ((Object)(object)Player.m_localPlayer != (Object)null) { Player.m_localPlayer.UpdateCurrentSeason(); CheckOverheatStatus(Player.m_localPlayer); } } } public void UpdateWinterBloomEffect() { if (IsActive && Seasons.UseTextureControllers()) { CameraEffects.instance.SetBloom((!Seasons.disableBloomInWinter.Value || GetCurrentSeason() != Seasons.Season.Winter) && PlatformPrefs.GetInt("Bloom", 1) == 1); } } public int GetYearLengthInDays() { int num = 0; Seasons.Season[] seasons = _seasons; foreach (Seasons.Season season in seasons) { num += GetDaysInSeason(season); } return num; } public override string ToString() { return $"{m_season} day:{m_day}"; } public void PatchTorchItemData(ItemData torch) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 if (torch != null && (int)torch.m_shared.m_itemType == 15) { if (Seasons.seasonState.GetTorchAsFiresource() && IsActive && (EnvMan.IsWet() || IsCold())) { torch.m_shared.m_durabilityDrain = Seasons.seasonState.GetTorchDurabilityDrain(); } else { torch.m_shared.m_durabilityDrain = 0.0333f; } } } public void UpdateTorchesFireWarmth() { UpdateTorchFireWarmth("GoblinTorch"); UpdateTorchFireWarmth("Torch"); if ((Object)(object)Player.m_localPlayer != (Object)null) { PatchTorchesInInventory(((Humanoid)Player.m_localPlayer).GetInventory()); } } public void PatchTorchesInInventory(Inventory inventory) { _itemDataList.Clear(); inventory.GetAllItems("$item_torch", _itemDataList); foreach (ItemData itemData in _itemDataList) { PatchTorchItemData(itemData); } } public void UpdateTorchFireWarmth(string prefabName) { //IL_0056: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(prefabName); if ((Object)(object)itemPrefab == (Object)null) { return; } EffectArea componentInChildren = itemPrefab.GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null) { return; } bool flag = Seasons.seasonState.GetTorchAsFiresource() && (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || (TorchHeatInBiome(Player.m_localPlayer.GetCurrentBiome()) && (!Seasons.disableTorchWarmthInInterior.Value || !((Character)Player.m_localPlayer).InInterior()))); componentInChildren.m_type = (Type)(flag ? 3 : 2); componentInChildren.m_isHeatType = ((Enum)componentInChildren.m_type).HasFlag((Enum)(object)(Type)1); ItemDrop component = itemPrefab.GetComponent(); PatchTorchItemData(component.m_itemData); if (!((Object)(object)Player.m_localPlayer != (Object)null)) { return; } if (((Humanoid)Player.m_localPlayer).m_visEquipment.m_rightItem == prefabName) { GameObject rightItemInstance = ((Humanoid)Player.m_localPlayer).m_visEquipment.m_rightItemInstance; EffectArea val = ((rightItemInstance != null) ? rightItemInstance.GetComponentInChildren(true) : null); if (val != null) { val.m_type = componentInChildren.m_type; val.m_isHeatType = componentInChildren.m_isHeatType; } } if (((Humanoid)Player.m_localPlayer).m_visEquipment.m_leftItem == prefabName) { GameObject leftItemInstance = ((Humanoid)Player.m_localPlayer).m_visEquipment.m_leftItemInstance; EffectArea val2 = ((leftItemInstance != null) ? leftItemInstance.GetComponentInChildren(true) : null); if (val2 != null) { val2.m_type = componentInChildren.m_type; val2.m_isHeatType = componentInChildren.m_isHeatType; } } } public void UpdateMinimapBorder() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) Image val = default(Image); if (Seasons.seasonalMinimapBorderColor.Value && !((Object)(object)Minimap.instance == (Object)null) && Minimap.instance.m_smallRoot.TryGetComponent(ref val) && !((Object)(object)val.sprite == (Object)null) && !(((Object)val.sprite).name != "InputFieldBackground")) { if (Seasons.minimapBorderColor == Color.clear) { Seasons.minimapBorderColor = ((Graphic)val).color; } switch (GetCurrentSeason()) { case Seasons.Season.Spring: ((Graphic)val).color = new Color(0.44f, 0.56f, 0.03f, Seasons.minimapBorderColor.a / 2f); break; case Seasons.Season.Summer: ((Graphic)val).color = new Color(0.82f, 0.72f, 0.04f, Seasons.minimapBorderColor.a / 2f); break; case Seasons.Season.Fall: ((Graphic)val).color = new Color(0.79f, 0.32f, 0f, Seasons.minimapBorderColor.a / 2f); break; case Seasons.Season.Winter: ((Graphic)val).color = new Color(0.89f, 0.94f, 0.96f, Seasons.minimapBorderColor.a / 2f); break; } } } public void CheckOverheatStatus(Player player) { if ((Object)(object)player == (Object)null || player.m_isLoading || (Object)(object)((Character)player).m_nview == (Object)null || !((Character)player).m_nview.IsValid()) { return; } bool flag = ((Character)player).GetSEMan().HaveStatusEffect(SeasonsVars.s_statusEffectOverheatHash); if (Seasons.summerHeatEnabled.Value || !Seasons.summerHeatAddsExtraWarmCloth.Value || !((Object)(object)player == (Object)(object)Player.m_localPlayer) || Seasons.seasonState.GetCurrentSeason() != Seasons.Season.Summer || !Seasons.seasonState.GetOverheatIn2WarmClothes() || IsCold() || HasCoolingFood(player)) { if (flag) { ((Character)player).GetSEMan().RemoveStatusEffect(SeasonsVars.s_statusEffectOverheatHash, false); } return; } int warmClothesCount = GetWarmClothesCount(player); if (!flag && warmClothesCount > 1) { ((Character)player).GetSEMan().AddStatusEffect(SeasonsVars.s_statusEffectOverheatHash, false, 0, 0f); } else if (flag && warmClothesCount <= 1) { ((Character)player).GetSEMan().RemoveStatusEffect(SeasonsVars.s_statusEffectOverheatHash, false); } } public static int GetWarmClothesCount(Player player) { if (!((Object)(object)player == (Object)null)) { Inventory inventory = ((Humanoid)player).GetInventory(); if (inventory != null) { return inventory.GetEquippedItems().Count((ItemData itemData) => itemData.m_shared.m_damageModifiers.Any(IsFrostResistant)); } } return 0; } public static bool IsFrostResistant(DamageModPair damageMod) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_0014: 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_001b: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 //IL_0026: 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 return (int)damageMod.m_type == 64 && ((int)damageMod.m_modifier == 7 || (int)damageMod.m_modifier == 1 || (int)damageMod.m_modifier == 5 || (int)damageMod.m_modifier == 3); } public static bool HasCoolingFood(Player player) { return (Object)(object)player != (Object)null && player.GetFoods().Any((Food food) => IsCoolingFood(food.m_item)); } public static bool IsCoolingFood(ItemData item) { if (item == null) { return false; } return GetCoolingFoodNames().Contains(item.m_shared?.m_name); } private static HashSet GetCoolingFoodNames() { string text = Seasons.summerHeatCoolingFoods?.Value ?? string.Empty; if (_coolingFoodNamesValue == text) { return _coolingFoodNames; } _coolingFoodNamesValue = text; _coolingFoodNames.Clear(); string[] array = text.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string input in array) { string itemName = input.GetItemName(); if (!string.IsNullOrEmpty(itemName)) { _coolingFoodNames.Add(itemName); } } return _coolingFoodNames; } public static bool IsCold() { return EnvMan.IsFreezing() || EnvMan.IsCold(); } private void SetCurrentSeasonDay(Seasons.Season season, int day) { UpdateCurrentSeasonDay((int)season * 10000 + day); } private void SetCurrentDay(int day, bool forceSeasonChange) { SetCurrentSeasonDay((_pendingSeasonChange == 0 || forceSeasonChange) ? m_season : GetPendingSeasonDay().Item1, day); } private void UpdateCurrentSeasonDay(int newValue) { if (Seasons.cacheRevision.Value == 0) { Seasons.LogInfo("Season update pending prevented: cache revision 0"); } else if (_pendingSeasonChange != newValue) { _pendingSeasonChange = newValue; Seasons.currentSeasonDay.AssignValueSafeAndNotify(delegate { Seasons.Season season = (Seasons.Season)(newValue / 10000 % 4); int num = newValue % 10000; Seasons.LogInfo(string.Format("Season update pending: {0} -> {1}{2}, ", m_season, season, Seasons.overrideSeason.Value ? "(override)" : "") + string.Format("Day: {0} -> {1}{2}, ", m_day, num, Seasons.overrideSeasonDay.Value ? "(override)" : "") + $"World Day: {m_worldDay}"); return newValue; }); } } internal static float GetDayFractionForSeasonChange() { return Seasons.changeSeasonOnlyAfterSleep.Value ? 0.2498f : 0.24f; } public static void CheckSeasonChange() { if (IsActive) { Seasons.seasonState.UpdateState(timeForSeasonToChange: false, forceSeasonChange: true); } } public static void ResetCurrentSeasonDay() { _pendingSeasonChange = 0; Seasons.cacheRevision.AssignValueSafe(0u); Seasons.currentSeasonDay.AssignValueSafe(0); } public static void OnSeasonDayChange() { if (IsActive) { _pendingSeasonChange = 0; Tuple syncedCurrentSeasonDay = GetSyncedCurrentSeasonDay(); bool flag = Seasons.seasonState.m_day != syncedCurrentSeasonDay.Item2; bool flag2 = Seasons.seasonState.m_season != syncedCurrentSeasonDay.Item1; Seasons.seasonState.m_season = syncedCurrentSeasonDay.Item1; Seasons.seasonState.m_day = syncedCurrentSeasonDay.Item2; if (flag2 || flag) { Seasons.LogInfo($"Season: {Seasons.seasonState.m_season}, day: {Seasons.seasonState.m_day}"); } if (flag2) { Seasons.seasonState.StartSeasonChange(); } else if (flag) { OnDayChange(); } } } private static void OnDayChange() { StartClutterUpdate(); ZoneSystemVariantController.UpdateWaterState(); Seasons.seasonState.UpdateGlobalKeys(); Seasons.seasonState.UpdateWinterBloomEffect(); UpdateCurrentEnvironment(); } internal static bool TorchHeatInBiome(Biome biome) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 return (int)biome != 4 && (int)biome != 64 && (int)biome != 32; } private static void StartClutterUpdate() { if (Seasons.UseTextureControllers()) { ClutterVariantController instance = ClutterVariantController.Instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(ClutterVariantController.Instance.UpdateDayState()); } } } public static Tuple GetSyncedCurrentSeasonDay() { return Tuple.Create((Seasons.Season)(Seasons.currentSeasonDay.Value / 10000 % 4), Seasons.currentSeasonDay.Value % 10000); } public static Tuple GetPendingSeasonDay() { return Tuple.Create((Seasons.Season)(_pendingSeasonChange / 10000 % 4), _pendingSeasonChange % 10000); } internal static List ApplySeasonBiomeEnvironmentRules(Biome biome, List environments) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!IsActive || !Seasons.controlEnvironments.Value || environments == null) { return environments; } SeasonBiomeEnvironments.SeasonBiomeEnvironment seasonBiomeEnvironment = seasonBiomeEnvironments.GetSeasonBiomeEnvironment(Seasons.seasonState.GetCurrentSeason()); return ApplySeasonBiomeEnvironmentRules(seasonBiomeEnvironment, biome, environments); } private static List ApplySeasonBiomeEnvironmentRules(SeasonBiomeEnvironments.SeasonBiomeEnvironment biomeEnv, BiomeEnvSetup biomeEnvironment, List environments) { return ApplySeasonBiomeEnvironmentRules(biomeEnv, environments, (string configuredName) => BiomeNameMatches(configuredName, biomeEnvironment), preserveSourceEntries: false); } private static List ApplySeasonBiomeEnvironmentRules(SeasonBiomeEnvironments.SeasonBiomeEnvironment biomeEnv, Biome biome, List environments) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return ApplySeasonBiomeEnvironmentRules(biomeEnv, environments, (string configuredName) => BiomeNameMatches(configuredName, biome), preserveSourceEntries: true); } private static List ApplySeasonBiomeEnvironmentRules(SeasonBiomeEnvironments.SeasonBiomeEnvironment biomeEnv, List environments, Func biomeMatches, bool preserveSourceEntries) { List list = ((environments == null) ? new List() : (from environment in environments where environment != null select preserveSourceEntries ? environment : CloneEnvEntry(environment)).ToList()); RefreshEnvironmentReferences(list); if (biomeEnv == null) { return list; } foreach (SeasonBiomeEnvironments.SeasonBiomeEnvironment.EnvironmentAdd item in biomeEnv.add) { if (item != null && item.m_environment != null && biomeMatches(item.m_name)) { EnvEntry val = CloneEnvEntry(item.m_environment); if (TryResolveSeasonEnvironmentReference(val, "add rule for biome " + item.m_name)) { list.Add(val); } } } foreach (SeasonBiomeEnvironments.SeasonBiomeEnvironment.EnvironmentReplace item2 in biomeEnv.replace) { if (item2 == null || string.IsNullOrWhiteSpace(item2.m_environment) || string.IsNullOrWhiteSpace(item2.replace_to)) { continue; } for (int num = 0; num < list.Count; num++) { EnvEntry val2 = list[num]; if (string.Equals(val2.m_environment, item2.m_environment, StringComparison.Ordinal)) { EnvEntry val3 = CloneEnvEntry(val2); val3.m_environment = item2.replace_to; if (TryResolveSeasonEnvironmentReference(val3, "replace rule " + item2.m_environment + " -> " + item2.replace_to)) { list[num] = val3; } } } } foreach (SeasonBiomeEnvironments.SeasonBiomeEnvironment.EnvironmentRemove remove in biomeEnv.remove) { if (remove != null && !string.IsNullOrWhiteSpace(remove.m_environment) && biomeMatches(remove.m_name)) { list.RemoveAll((EnvEntry environment) => string.Equals(environment.m_environment, remove.m_environment, StringComparison.Ordinal)); } } return list; } private static EnvEntry CloneEnvEntry(EnvEntry source) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown EnvEntry val = new EnvEntry(); if (source == null) { return val; } FieldInfo[] array = envEntryFields; foreach (FieldInfo fieldInfo in array) { if (!(fieldInfo.Name == "m_env")) { fieldInfo.SetValue(val, fieldInfo.GetValue(source)); } } val.m_env = null; return val; } private static void RefreshEnvironmentReferences(IEnumerable environments) { if ((Object)(object)EnvMan.instance == (Object)null || environments == null) { return; } foreach (EnvEntry environment in environments) { if (environment != null && !string.IsNullOrWhiteSpace(environment.m_environment)) { environment.m_env = EnvMan.instance.GetEnv(environment.m_environment); } } } private static bool TryResolveSeasonEnvironmentReference(EnvEntry environment, string ruleDescription) { if (environment == null || string.IsNullOrWhiteSpace(environment.m_environment) || (Object)(object)EnvMan.instance == (Object)null) { return false; } environment.m_env = EnvMan.instance.GetEnv(environment.m_environment); if (environment.m_env != null) { return true; } string item = ruleDescription + "|" + environment.m_environment; if (unresolvedSeasonEnvironmentRules.Add(item)) { Seasons.LogWarning("Seasonal biome environment " + ruleDescription + " references missing environment " + environment.m_environment + "; the rule was skipped."); } return false; } private static bool BiomeNameMatches(string configuredName, BiomeEnvSetup biomeEnvironment) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(configuredName) || biomeEnvironment == null) { return false; } if (!string.IsNullOrWhiteSpace(biomeEnvironment.m_name) && string.Equals(NormalizeBiomeName(configuredName), NormalizeBiomeName(biomeEnvironment.m_name), StringComparison.OrdinalIgnoreCase)) { return true; } return BiomeNameMatches(configuredName, biomeEnvironment.m_biome); } private unsafe static bool BiomeNameMatches(string configuredName, Biome biome) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(configuredName)) { return false; } string a = NormalizeBiomeName(configuredName); if (string.Equals(a, NormalizeBiomeName(((object)(*(Biome*)(&biome))/*cast due to .constrained prefix*/).ToString()), StringComparison.OrdinalIgnoreCase)) { return true; } string displayName; return EWDCompat.TryGetBiomeDisplayName(biome, out displayName) && string.Equals(a, NormalizeBiomeName(displayName), StringComparison.OrdinalIgnoreCase); } private static string NormalizeBiomeName(string biomeName) { if (string.IsNullOrWhiteSpace(biomeName)) { return string.Empty; } return biomeName.Replace(" ", "").Replace("_", "").Replace("-", ""); } private static List SortCustomEnvironmentsByCloneDependencies(List environments) { if (environments == null || environments.Count == 0) { return new List(); } Dictionary dictionary = new Dictionary(); HashSet hashSet = new HashSet(); for (int i = 0; i < environments.Count; i++) { SeasonEnvironment seasonEnvironment = environments[i]; if (seasonEnvironment == null || string.IsNullOrWhiteSpace(seasonEnvironment.m_name)) { Seasons.LogWarning("Custom environment with empty m_name was skipped."); continue; } if (dictionary.ContainsKey(seasonEnvironment.m_name)) { hashSet.Add(seasonEnvironment.m_name); } dictionary[seasonEnvironment.m_name] = i; } foreach (string item in hashSet) { Seasons.LogWarning("Duplicate custom environment name \"" + item + "\". The last definition will be used."); } List list = new List(); Dictionary dictionary2 = new Dictionary(); for (int j = 0; j < environments.Count; j++) { SeasonEnvironment seasonEnvironment2 = environments[j]; if (seasonEnvironment2 != null && !string.IsNullOrWhiteSpace(seasonEnvironment2.m_name) && dictionary[seasonEnvironment2.m_name] == j) { list.Add(seasonEnvironment2); dictionary2[seasonEnvironment2.m_name] = seasonEnvironment2; } } HashSet hashSet2 = (from environment in EnvMan.instance.m_environments where environment != null && !string.IsNullOrWhiteSpace(environment.m_name) select environment.m_name).ToHashSet(); List list2 = new List(); HashSet hashSet3 = new HashSet(); HashSet hashSet4 = new HashSet(); bool flag; do { flag = false; foreach (SeasonEnvironment item2 in list) { if (!hashSet4.Contains(item2.m_name)) { string cloneFrom = item2.m_cloneFrom; if (string.IsNullOrWhiteSpace(cloneFrom) || hashSet2.Contains(cloneFrom) || hashSet3.Contains(cloneFrom)) { list2.Add(item2); hashSet4.Add(item2.m_name); hashSet3.Add(item2.m_name); flag = true; } } } } while (flag); foreach (SeasonEnvironment item3 in list) { if (!hashSet4.Contains(item3.m_name)) { if (dictionary2.ContainsKey(item3.m_cloneFrom)) { Seasons.LogWarning("Custom environment \"" + item3.m_name + "\" has unresolved clone dependency \"" + item3.m_cloneFrom + "\". This is probably a circular clone dependency."); } else { Seasons.LogWarning("Custom environment \"" + item3.m_name + "\" clone source \"" + item3.m_cloneFrom + "\" was not found."); } list2.Add(item3); hashSet4.Add(item3.m_name); } } return list2; } } [Serializable] public class SeasonStats { [Serializable] public class Stats { [Header("__SE_Stats__")] [Header("HP per tick")] public float m_tickInterval; public float m_healthPerTickMinHealthPercentage; public float m_healthPerTick; public string m_healthHitType = ""; [Header("Stamina")] public float m_runStaminaDrainModifier; public float m_jumpStaminaUseModifier; public float m_attackStaminaUseModifier; public float m_blockStaminaUseModifier; public float m_blockStaminaUseFlatValue; public float m_dodgeStaminaUseModifier; public float m_swimStaminaUseModifier; public float m_homeItemStaminaUseModifier; public float m_sneakStaminaUseModifier; public float m_runStaminaUseModifier; [Header("Regen modifiers")] public float m_healthRegenMultiplier = 1f; public float m_staminaRegenMultiplier = 1f; public float m_eitrRegenMultiplier = 1f; [Header("Skills modifiers")] public Dictionary m_raiseSkills = new Dictionary(); public Dictionary m_skillLevels = new Dictionary(); public Dictionary m_modifyAttackSkills = new Dictionary(); [Header("Hit modifier")] public Dictionary m_damageModifiers = new Dictionary(); [Header("Sneak")] public float m_noiseModifier; public float m_stealthModifier; [Header("Carry weight")] public float m_addMaxCarryWeight; [Header("Speed")] public float m_speedModifier; public float m_swimSpeedModifier; [Header("Fall")] public float m_maxMaxFallSpeed; public float m_fallDamageModifier; [Header("Adrenaline")] public float m_adrenalineModifier; [Header("Stagger")] public float m_staggerModifier; public float m_timedBlockBonus; public void SetStatusEffectStats(SE_Season statusEffect) { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) FieldInfo[] fields = GetType().GetFields(); foreach (FieldInfo fieldInfo in fields) { FieldInfo field = ((object)statusEffect).GetType().GetField(fieldInfo.Name); if (!(field == null)) { field.SetValue(statusEffect, fieldInfo.GetValue(this)); } } ((SE_Stats)statusEffect).m_mods.Clear(); foreach (KeyValuePair damageModifier in m_damageModifiers) { if (Enum.TryParse(damageModifier.Key, out DamageType result) && Enum.TryParse(damageModifier.Value, out DamageModifier result2)) { ((SE_Stats)statusEffect).m_mods.Add(new DamageModPair { m_type = result, m_modifier = result2 }); } } ((SE_Stats)statusEffect).m_hitType = (HitType)0; if (Enum.TryParse(m_healthHitType, out HitType result3)) { ((SE_Stats)statusEffect).m_hitType = result3; } statusEffect.m_customRaiseSkills.Clear(); foreach (KeyValuePair raiseSkill in m_raiseSkills) { if (ParseSkill(raiseSkill.Key, out var skill)) { statusEffect.m_customRaiseSkills.Add(skill, raiseSkill.Value); } } statusEffect.m_customSkillLevels.Clear(); foreach (KeyValuePair skillLevel in m_skillLevels) { if (ParseSkill(skillLevel.Key, out var skill2)) { statusEffect.m_customSkillLevels.Add(skill2, skillLevel.Value); } } statusEffect.m_customModifyAttackSkills.Clear(); foreach (KeyValuePair modifyAttackSkill in m_modifyAttackSkills) { if (ParseSkill(modifyAttackSkill.Key, out var skill3)) { statusEffect.m_customModifyAttackSkills.Add(skill3, modifyAttackSkill.Value); } } } public bool ParseSkill(string skillName, out SkillType skill) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected I4, but got Unknown if (Enum.TryParse(skillName, out skill)) { return true; } SkillType fromSkillManager = (SkillType)Math.Abs(StringExtensionMethods.GetStableHashCode(skillName)); if (Player.m_localPlayer.m_skills.m_skills.Any((SkillDef skl) => skl.m_skill == fromSkillManager)) { skill = (SkillType)(int)fromSkillManager; return true; } return false; } } public Stats Spring = new Stats(); public Stats Summer = new Stats(); public Stats Fall = new Stats(); public Stats Winter = new Stats(); public SeasonStats(bool loadDefaults = false) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_04a5: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_0547: Unknown result type (might be due to invalid IL or missing references) //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) if (loadDefaults) { Spring.m_tickInterval = 5f; Spring.m_healthPerTick = 1f; Spring.m_damageModifiers.Add(((object)(DamageType)256/*cast due to .constrained prefix*/).ToString(), ((object)(DamageModifier)1/*cast due to .constrained prefix*/).ToString()); Spring.m_raiseSkills.Add(((object)(SkillType)100/*cast due to .constrained prefix*/).ToString(), 1.2f); Spring.m_raiseSkills.Add(((object)(SkillType)101/*cast due to .constrained prefix*/).ToString(), 1.2f); Spring.m_raiseSkills.Add(((object)(SkillType)102/*cast due to .constrained prefix*/).ToString(), 1.2f); Spring.m_raiseSkills.Add(((object)(SkillType)103/*cast due to .constrained prefix*/).ToString(), 1.2f); Spring.m_skillLevels.Add(((object)(SkillType)100/*cast due to .constrained prefix*/).ToString(), 15f); Spring.m_skillLevels.Add(((object)(SkillType)101/*cast due to .constrained prefix*/).ToString(), 15f); Spring.m_skillLevels.Add(((object)(SkillType)102/*cast due to .constrained prefix*/).ToString(), 15f); Spring.m_skillLevels.Add(((object)(SkillType)103/*cast due to .constrained prefix*/).ToString(), 15f); Summer.m_runStaminaDrainModifier = -0.1f; Summer.m_jumpStaminaUseModifier = -0.1f; Summer.m_healthRegenMultiplier = 1.1f; Summer.m_noiseModifier = -0.2f; Summer.m_stealthModifier = 0.2f; Summer.m_speedModifier = 0.05f; Summer.m_raiseSkills.Add(((object)(SkillType)100/*cast due to .constrained prefix*/).ToString(), 1.1f); Summer.m_raiseSkills.Add(((object)(SkillType)101/*cast due to .constrained prefix*/).ToString(), 1.1f); Summer.m_raiseSkills.Add(((object)(SkillType)102/*cast due to .constrained prefix*/).ToString(), 1.1f); Summer.m_raiseSkills.Add(((object)(SkillType)103/*cast due to .constrained prefix*/).ToString(), 1.1f); Summer.m_skillLevels.Add(((object)(SkillType)100/*cast due to .constrained prefix*/).ToString(), 10f); Summer.m_skillLevels.Add(((object)(SkillType)101/*cast due to .constrained prefix*/).ToString(), 10f); Summer.m_skillLevels.Add(((object)(SkillType)102/*cast due to .constrained prefix*/).ToString(), 10f); Summer.m_skillLevels.Add(((object)(SkillType)103/*cast due to .constrained prefix*/).ToString(), 10f); Fall.m_eitrRegenMultiplier = 1.1f; Fall.m_raiseSkills.Add(((object)(SkillType)13/*cast due to .constrained prefix*/).ToString(), 1.2f); Fall.m_raiseSkills.Add(((object)(SkillType)104/*cast due to .constrained prefix*/).ToString(), 1.2f); Fall.m_raiseSkills.Add(((object)(SkillType)12/*cast due to .constrained prefix*/).ToString(), 1.2f); Fall.m_skillLevels.Add(((object)(SkillType)13/*cast due to .constrained prefix*/).ToString(), 15f); Fall.m_skillLevels.Add(((object)(SkillType)104/*cast due to .constrained prefix*/).ToString(), 15f); Fall.m_skillLevels.Add(((object)(SkillType)12/*cast due to .constrained prefix*/).ToString(), 15f); Winter.m_staminaRegenMultiplier = 1.1f; Winter.m_noiseModifier = 0.2f; Winter.m_stealthModifier = -0.2f; Winter.m_speedModifier = -0.05f; Winter.m_fallDamageModifier = -0.3f; Winter.m_damageModifiers.Add(((object)(DamageType)32/*cast due to .constrained prefix*/).ToString(), ((object)(DamageModifier)1/*cast due to .constrained prefix*/).ToString()); Winter.m_raiseSkills.Add(((object)(SkillType)13/*cast due to .constrained prefix*/).ToString(), 1.1f); Winter.m_raiseSkills.Add(((object)(SkillType)104/*cast due to .constrained prefix*/).ToString(), 1.1f); Winter.m_raiseSkills.Add(((object)(SkillType)12/*cast due to .constrained prefix*/).ToString(), 1.1f); Winter.m_skillLevels.Add(((object)(SkillType)13/*cast due to .constrained prefix*/).ToString(), 10f); Winter.m_skillLevels.Add(((object)(SkillType)104/*cast due to .constrained prefix*/).ToString(), 10f); Winter.m_skillLevels.Add(((object)(SkillType)12/*cast due to .constrained prefix*/).ToString(), 10f); } } public Stats GetSeasonStats() { return GetSeasonStats(Seasons.seasonState.GetCurrentSeason()); } private Stats GetSeasonStats(Seasons.Season season) { if (1 == 0) { } Stats result = season switch { Seasons.Season.Spring => Spring, Seasons.Season.Summer => Summer, Seasons.Season.Fall => Fall, Seasons.Season.Winter => Winter, _ => new Stats(), }; if (1 == 0) { } return result; } } [Serializable] public class SeasonTraderItems { [Serializable] public class TradeableItem { public string prefab; public int stack = 1; public int price = 1; public string requiredGlobalKey = ""; public override string ToString() { return string.Format("{0} x{1}, {2} coins {3}", prefab, stack, price, (!Utility.IsNullOrWhiteSpace(requiredGlobalKey)) ? (", " + requiredGlobalKey) : ""); } } public Dictionary> Spring = new Dictionary>(); public Dictionary> Summer = new Dictionary>(); public Dictionary> Fall = new Dictionary>(); public Dictionary> Winter = new Dictionary>(); public SeasonTraderItems(bool loadDefaults = false) { if (loadDefaults) { Spring.Add("haldor", new List { new TradeableItem { prefab = "Honey", price = 200, stack = 10, requiredGlobalKey = "defeated_eikthyr" }, new TradeableItem { prefab = "RawMeat", price = 150, stack = 10, requiredGlobalKey = "defeated_eikthyr" }, new TradeableItem { prefab = "NeckTail", price = 150, stack = 10, requiredGlobalKey = "defeated_eikthyr" }, new TradeableItem { prefab = "DeerMeat", price = 200, stack = 10, requiredGlobalKey = "defeated_gdking" }, new TradeableItem { prefab = "WolfMeat", price = 350, stack = 10, requiredGlobalKey = "defeated_dragon" }, new TradeableItem { prefab = "LoxMeat", price = 500, stack = 5, requiredGlobalKey = "defeated_goblinking" }, new TradeableItem { prefab = "HareMeat", price = 500, stack = 10, requiredGlobalKey = "defeated_queen" }, new TradeableItem { prefab = "SerpentMeat", price = 500, stack = 5, requiredGlobalKey = "defeated_serpent" } }); Fall.Add("haldor", new List { new TradeableItem { prefab = "Raspberry", price = 150, stack = 10, requiredGlobalKey = "defeated_eikthyr" }, new TradeableItem { prefab = "Blueberries", price = 200, stack = 10, requiredGlobalKey = "defeated_eikthyr" }, new TradeableItem { prefab = "Carrot", price = 300, stack = 10, requiredGlobalKey = "defeated_gdking" }, new TradeableItem { prefab = "Turnip", price = 350, stack = 10, requiredGlobalKey = "defeated_bonemass" }, new TradeableItem { prefab = "Onion", price = 400, stack = 10, requiredGlobalKey = "defeated_dragon" }, new TradeableItem { prefab = "Barley", price = 500, stack = 10, requiredGlobalKey = "defeated_goblinking" }, new TradeableItem { prefab = "Flax", price = 500, stack = 10, requiredGlobalKey = "defeated_goblinking" }, new TradeableItem { prefab = "Cloudberry", price = 300, stack = 10, requiredGlobalKey = "defeated_goblinking" } }); Winter.Add("haldor", new List { new TradeableItem { prefab = "Honey", price = 300, stack = 10, requiredGlobalKey = "defeated_eikthyr" }, new TradeableItem { prefab = "Acorn", price = 100, stack = 1, requiredGlobalKey = "defeated_gdking" }, new TradeableItem { prefab = "BeechSeeds", price = 50, stack = 10, requiredGlobalKey = "defeated_eikthyr" }, new TradeableItem { prefab = "BirchSeeds", price = 150, stack = 10, requiredGlobalKey = "defeated_gdking" }, new TradeableItem { prefab = "FirCone", price = 150, stack = 10, requiredGlobalKey = "defeated_gdking" }, new TradeableItem { prefab = "PineCone", price = 150, stack = 10, requiredGlobalKey = "defeated_gdking" }, new TradeableItem { prefab = "CarrotSeeds", price = 50, stack = 10, requiredGlobalKey = "defeated_gdking" }, new TradeableItem { prefab = "TurnipSeeds", price = 80, stack = 10, requiredGlobalKey = "defeated_bonemass" }, new TradeableItem { prefab = "OnionSeeds", price = 100, stack = 10, requiredGlobalKey = "defeated_dragon" }, new TradeableItem { prefab = "SerpentMeat", price = 500, stack = 5, requiredGlobalKey = "defeated_serpent" }, new TradeableItem { prefab = "SerpentScale", price = 300, stack = 5, requiredGlobalKey = "defeated_serpent" }, new TradeableItem { prefab = "Bloodbag", price = 500, stack = 10, requiredGlobalKey = "killed_surtling" } }); Summer.Add("hildir", new List { new TradeableItem { prefab = "HelmetMidsummerCrown", price = 100, stack = 1 } }); Fall.Add("hildir", new List { new TradeableItem { prefab = "HelmetPointyHat", price = 300, stack = 1 } }); Winter.Add("hildir", new List { new TradeableItem { prefab = "HelmetYule", price = 100, stack = 1 } }); Summer.Add("bogwitch", new List { new TradeableItem { prefab = "Root", price = 250, stack = 5 } }); Fall.Add("bogwitch", new List { new TradeableItem { prefab = "Pukeberries", price = 100, stack = 10 } }); Winter.Add("bogwitch", new List { new TradeableItem { prefab = "Resin", price = 200, stack = 20 } }); } } public void AddSeasonalTraderItems(Trader trader, List itemList) { //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown foreach (TradeableItem currentSeasonalTraderItem in GetCurrentSeasonalTraderItems(trader)) { if (!string.IsNullOrEmpty(currentSeasonalTraderItem.requiredGlobalKey) && !ZoneSystem.instance.GetGlobalKey(currentSeasonalTraderItem.requiredGlobalKey)) { continue; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(currentSeasonalTraderItem.prefab); if ((Object)(object)itemPrefab == (Object)null) { continue; } ItemDrop prefab = itemPrefab.GetComponent(); if ((Object)(object)prefab == (Object)null) { continue; } if (itemList.Exists((TradeItem x) => (Object)(object)x.m_prefab == (Object)(object)prefab)) { TradeItem val = itemList.First((TradeItem x) => (Object)(object)x.m_prefab == (Object)(object)prefab); val.m_price = currentSeasonalTraderItem.price; val.m_stack = currentSeasonalTraderItem.stack; val.m_requiredGlobalKey = currentSeasonalTraderItem.requiredGlobalKey; } else { itemList.Add(new TradeItem { m_prefab = prefab, m_price = currentSeasonalTraderItem.price, m_stack = currentSeasonalTraderItem.stack, m_requiredGlobalKey = currentSeasonalTraderItem.requiredGlobalKey }); } } } private List GetCurrentSeasonalTraderItems(Trader trader) { List list = new List { ((Object)trader).name, Utils.GetPrefabName(((Component)trader).gameObject), trader.m_name, trader.m_name.ToLower().Replace("$npc_", ""), trader.m_name.Localize() }; Seasons.Season currentSeason = Seasons.seasonState.GetCurrentSeason(); foreach (string item in list) { List seasonItems = GetSeasonItems(item, currentSeason); if (seasonItems != null) { return seasonItems; } } return new List(); } private Dictionary> GetSeasonList(Seasons.Season season) { if (1 == 0) { } Dictionary> result = season switch { Seasons.Season.Spring => Spring, Seasons.Season.Summer => Summer, Seasons.Season.Fall => Fall, Seasons.Season.Winter => Winter, _ => new Dictionary>(), }; if (1 == 0) { } return result; } private List GetSeasonItems(string trader, Seasons.Season season) { return GetSeasonList(season).FirstOrDefault((KeyValuePair> kvp) => kvp.Key.Equals(trader, StringComparison.OrdinalIgnoreCase)).Value; } } [Serializable] public class SeasonWorldSettings { [Serializable] public class SeasonWorld { public string startTimeUTC = ""; public long dayLengthSeconds = 0L; public SeasonWorld(DateTime timeUTC, long seconds) { startTimeUTC = timeUTC.ToString("o", CultureInfo.InvariantCulture); dayLengthSeconds = seconds; } } public Dictionary worlds = new Dictionary(); public SeasonWorldSettings(bool loadDefaults = false) { if (loadDefaults) { worlds.Add("ExampleSeasonsWorld", new SeasonWorld(DateTime.UtcNow, 86400L)); } } public DateTime GetStartTimeUTC(World world) { if (HasWorldSettings(world) && DateTime.TryParse(GetWorldSettings(world).startTimeUTC, null, DateTimeStyles.RoundtripKind, out var result)) { return (DateTime.Compare(result, new DateTime(2023, 1, 1, 0, 0, 0)) < 0) ? new DateTime(2023, 1, 1, 0, 0, 0) : result; } return DateTime.UtcNow.Subtract(TimeSpan.FromSeconds(ZNet.instance.GetTimeSeconds())); } public long GetDayLengthSeconds(World world) { if (!HasWorldSettings(world)) { return SeasonState.GetDayLengthInSecondsEnvMan(); } return Math.Max(GetWorldSettings(world).dayLengthSeconds, 5L); } public bool HasWorldSettings(World world) { return world != null && worlds.ContainsKey(world.m_name); } public SeasonWorld GetWorldSettings(World world) { if (!HasWorldSettings(world)) { return null; } return worlds[world.m_name]; } } public class SE_Season : SE_Stats { private Seasons.Season m_season = Seasons.Season.Spring; private bool m_indoors = false; [Header("Skills modifiers")] public Dictionary m_customRaiseSkills = new Dictionary(); public Dictionary m_customSkillLevels = new Dictionary(); public Dictionary m_customModifyAttackSkills = new Dictionary(); private static readonly StringBuilder _sb = new StringBuilder(100); private static readonly SeasonStats.Stats emptyStats = new SeasonStats.Stats(); public override void UpdateStatusEffect(float dt) { if (m_season != Seasons.seasonState.GetCurrentSeason()) { ((StatusEffect)this).Setup(((StatusEffect)this).m_character); } else if (Seasons.seasonalStatsOutdoorsOnly.Value && (Object)(object)((StatusEffect)this).m_character != (Object)null && (Object)(object)((StatusEffect)this).m_character == (Object)(object)Player.m_localPlayer && ((StatusEffect)this).m_character.InInterior() != m_indoors) { ((StatusEffect)this).Setup(((StatusEffect)this).m_character); } else { ((SE_Stats)this).UpdateStatusEffect(dt); } } public override void Setup(Character character) { StatusEffectHud.EnsureTimeTextRichText(); m_season = Seasons.seasonState.GetCurrentSeason(); if (m_indoors != (m_indoors = (Object)(object)((StatusEffect)this).m_character != (Object)null && (Object)(object)((StatusEffect)this).m_character == (Object)(object)Player.m_localPlayer && ((StatusEffect)this).m_character.InInterior())) { Seasons.seasonState.OnInteriorChanged(m_indoors); } UpdateSeasonStatusEffect(); ((SE_Stats)this).Setup(character); } public override string GetTooltipString() { //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) if (!Seasons.showCurrentSeasonInRaven.Value) { return ""; } _sb.Clear(); _sb.AppendFormat("{0}\n", GetSeasonTooltip()); if (Seasons.seasonsTimerFormatInRaven.Value == Seasons.TimerFormat.CurrentDay || Seasons.seasonsTimerFormatInRaven.Value == Seasons.TimerFormat.CurrentDayAndTimeToEnd) { _sb.AppendFormat("{0} / {1}\n", $"$hud_mapday {Seasons.seasonState.GetCurrentDay()}".Localize(), Seasons.seasonState.GetDaysInSeason()); } if (Seasons.seasonsTimerFormatInRaven.Value == Seasons.TimerFormat.TimeToEnd || Seasons.seasonsTimerFormatInRaven.Value == Seasons.TimerFormat.CurrentDayAndTimeToEnd) { _sb.AppendFormat("{0}: {1}\n", MessageNextSeason(), TimerString(Seasons.seasonState.GetTimeToCurrentSeasonEnd())); } string tooltipString = ((SE_Stats)this).GetTooltipString(); if (tooltipString.Length > 0) { _sb.Append(tooltipString); } foreach (KeyValuePair item in m_customSkillLevels.Where((KeyValuePair kvp) => kvp.Value != 0f)) { _sb.AppendFormat("{0} {1}\n", SkillLocalized(item.Key), item.Value.ToString("+0;-0")); } foreach (KeyValuePair item2 in m_customModifyAttackSkills.Where((KeyValuePair kvp) => kvp.Value != 0f)) { _sb.AppendFormat("$inventory_dmgmod: {0} {1}%\n", SkillLocalized(item2.Key), item2.Value.ToString("+0;-0")); } _sb.Append("\n"); return _sb.ToString(); unsafe static string SkillLocalized(SkillType skill) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 return (((int)skill == 999) ? "$inventory_skills" : ("$skill_" + ((object)(*(SkillType*)(&skill))/*cast due to .constrained prefix*/).ToString().ToLower())).Localize(); } } public override string GetIconText() { if (Seasons.seasonsTimerFormat.Value == Seasons.TimerFormat.None) { return ""; } _sb.Clear(); if (Seasons.seasonsTimerFormat.Value == Seasons.TimerFormat.CurrentDay || Seasons.seasonsTimerFormat.Value == Seasons.TimerFormat.CurrentDayAndTimeToEnd) { _sb.Append((Seasons.seasonState.GetCurrentDay() >= Seasons.seasonState.GetDaysInSeason() && !string.IsNullOrEmpty(MessageNextSeason())) ? MessageNextSeason() : $"$hud_mapday {Seasons.seasonState.GetCurrentDay()}".Localize()); } if (Seasons.seasonsTimerFormat.Value == Seasons.TimerFormat.CurrentDayAndTimeToEnd) { _sb.Append(" ("); } if (Seasons.seasonsTimerFormat.Value == Seasons.TimerFormat.TimeToEnd || Seasons.seasonsTimerFormat.Value == Seasons.TimerFormat.CurrentDayAndTimeToEnd) { _sb.AppendFormat(TimerString(Seasons.seasonState.GetTimeToCurrentSeasonEnd(), icon: true)); } if (Seasons.seasonsTimerFormat.Value == Seasons.TimerFormat.CurrentDayAndTimeToEnd) { _sb.Append(")"); } return _sb.ToString(); } public override void ModifyRaiseSkill(SkillType skill, ref float value) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (m_customRaiseSkills.ContainsKey(skill)) { value += m_customRaiseSkills[skill]; } else if (m_customRaiseSkills.ContainsKey((SkillType)999)) { value += m_customRaiseSkills[(SkillType)999]; } } public override void ModifySkillLevel(SkillType skill, ref float value) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (m_customSkillLevels.ContainsKey(skill)) { value += m_customSkillLevels[skill]; } else if (m_customSkillLevels.ContainsKey((SkillType)999)) { value += m_customSkillLevels[(SkillType)999]; } } public override void ModifyAttack(SkillType skill, ref HitData hitData) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (m_customModifyAttackSkills.ContainsKey(skill)) { ((DamageTypes)(ref hitData.m_damage)).Modify(m_customModifyAttackSkills[skill]); } else if (m_customModifyAttackSkills.ContainsKey((SkillType)999)) { ((DamageTypes)(ref hitData.m_damage)).Modify(m_customModifyAttackSkills[(SkillType)999]); } } private string GetSeasonTooltip() { return Seasons.GetSeasonTooltip(m_season); } public void UpdateSeasonStatusEffect() { ((StatusEffect)this).m_name = Seasons.GetSeasonName(m_season); ((StatusEffect)this).m_icon = Seasons.GetSeasonIcon(m_season); SeasonStats.Stats stats = ((!Seasons.controlStats.Value || (Seasons.seasonalStatsOutdoorsOnly.Value && m_indoors)) ? emptyStats : SeasonState.seasonStats.GetSeasonStats()); stats.SetStatusEffectStats(this); } public static void UpdateSeasonStatusEffectStats() { Player localPlayer = Player.m_localPlayer; SE_Season obj = ((localPlayer != null) ? ((Character)localPlayer).GetSEMan().GetStatusEffect(SeasonsVars.s_statusEffectSeasonHash) : null) as SE_Season; if (obj != null) { ((StatusEffect)obj).Setup((Character)(object)Player.m_localPlayer); } } private static string MessageNextSeason() { return Seasons.GetSeasonIsComing(Seasons.seasonState.GetNextSeason()).Localize(); } private static string TimerString(double seconds, bool icon = false) { if (seconds < 60.0) { return DateTime.FromBinary(599266080000000000L).AddSeconds(Math.Abs(seconds)).ToString("ss\\s"); } TimeSpan timeSpan = TimeSpan.FromSeconds(seconds); if (Seasons.hideSecondsInTimer.Value) { if (icon) { if (timeSpan.Hours > 0) { return string.Format(((int)seconds % 2 == 0) ? "{0:d2}:{1:d2}" : "{0:d2}:{1:d2}", (int)timeSpan.TotalHours, timeSpan.Minutes); } return new DateTime(timeSpan.Ticks).ToString("mm\\:ss"); } if (timeSpan.Hours > 0) { return $"{(int)timeSpan.TotalHours}{new DateTime(timeSpan.Ticks):\\h mm\\m}"; } return new DateTime(timeSpan.Ticks).ToString("mm\\m ss\\s"); } if (timeSpan.TotalHours > 24.0) { return $"{(int)timeSpan.TotalHours:d2}:{timeSpan.Minutes:d2}:{timeSpan.Seconds:d2}"; } return timeSpan.ToString((timeSpan.Hours > 0) ? "hh\\:mm\\:ss" : "mm\\:ss"); } } [HarmonyPatch(typeof(ObjectDB), "Awake")] public static class ObjectDB_Awake_AddStatusEffects { public static void AddCustomStatusEffects(ObjectDB odb) { //IL_0176: Unknown result type (might be due to invalid IL or missing references) if (odb.m_StatusEffects.Count > 0) { if (!odb.m_StatusEffects.Any((StatusEffect se) => ((Object)se).name == "Season")) { SE_Season sE_Season = ScriptableObject.CreateInstance(); ((Object)sE_Season).name = "Season"; ((StatusEffect)sE_Season).m_nameHash = SeasonsVars.s_statusEffectSeasonHash; ((StatusEffect)sE_Season).m_icon = Seasons.iconSpring; odb.m_StatusEffects.Add((StatusEffect)(object)sE_Season); } if (!odb.m_StatusEffects.Any((StatusEffect se) => ((Object)se).name == "SummerHeat")) { SE_SummerHeat sE_SummerHeat = ScriptableObject.CreateInstance(); ((Object)sE_SummerHeat).name = "SummerHeat"; ((StatusEffect)sE_SummerHeat).m_nameHash = SeasonsVars.s_statusEffectSummerHeatHash; ((StatusEffect)sE_SummerHeat).m_icon = Seasons.iconWarm; odb.m_StatusEffects.Add((StatusEffect)(object)sE_SummerHeat); } if (!odb.m_StatusEffects.Any((StatusEffect se) => ((Object)se).name == "Overheat")) { SE_Stats val = ScriptableObject.CreateInstance(); ((Object)val).name = "Overheat"; ((StatusEffect)val).m_nameHash = SeasonsVars.s_statusEffectOverheatHash; ((StatusEffect)val).m_icon = Seasons.iconWarm; ((StatusEffect)val).m_name = "$seasons_status_overheat_name"; ((StatusEffect)val).m_tooltip = "$seasons_status_overheat_description"; ((StatusEffect)val).m_startMessage = "$seasons_status_overheat_message"; ((StatusEffect)val).m_startMessageType = (MessageType)2; val.m_staminaRegenMultiplier = 0.8f; val.m_eitrRegenMultiplier = 0.8f; odb.m_StatusEffects.Add((StatusEffect)(object)val); } } } private static void Postfix(ObjectDB __instance) { AddCustomStatusEffects(__instance); } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] public static class ObjectDB_CopyOtherDB_SE_Season { private static void Postfix(ObjectDB __instance) { ObjectDB_Awake_AddStatusEffects.AddCustomStatusEffects(__instance); } } [HarmonyPatch(typeof(TextsDialog), "AddActiveEffects")] public static class TextsDialog_AddActiveEffects_SeasonTooltipWhenBuffDisabled { public static bool isActiveEffectsListCall; private static void Prefix() { isActiveEffectsListCall = true; } private static void Postfix() { isActiveEffectsListCall = false; } } [HarmonyPatch(typeof(SEMan), "GetHUDStatusEffects")] public static class SEMan_GetHUDStatusEffects_CustomStatusEffectVisibility { private static void Postfix(Character ___m_character, List ___m_statusEffects, List effects) { if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)___m_character != (Object)(object)Player.m_localPlayer) { return; } bool isActiveEffectsListCall = TextsDialog_AddActiveEffects_SeasonTooltipWhenBuffDisabled.isActiveEffectsListCall; if (isActiveEffectsListCall && !effects.Any((StatusEffect effect) => effect is SE_Season)) { StatusEffect val = ___m_statusEffects.Find((StatusEffect se) => se is SE_Season); if ((Object)(object)val != (Object)null) { effects.Insert(0, val); } } StatusEffect val2 = ___m_statusEffects.Find((StatusEffect se) => se is SE_SummerHeat); if ((Object)(object)val2 == (Object)null) { return; } switch (Seasons.summerHeatStatusEffectDisplay.Value) { case Seasons.SummerHeatStatusEffectDisplay.StatusList: break; case Seasons.SummerHeatStatusEffectDisplay.RavenMenuOnly: effects.RemoveAll((StatusEffect effect) => effect is SE_SummerHeat); if (isActiveEffectsListCall) { effects.Insert(Math.Min(1, effects.Count), val2); } break; case Seasons.SummerHeatStatusEffectDisplay.None: effects.RemoveAll((StatusEffect effect) => effect is SE_SummerHeat); break; } } } public class PrefabVariantController : MonoBehaviour { public class MaterialVariants { public Material m_originalMaterial; public Dictionary m_textureVariants = new Dictionary(); public Dictionary m_colorVariants = new Dictionary(); public Material[] seasonalMaterials = Array.Empty(); public Seasons.Season season; public bool updateSeasonalMaterials = true; public static readonly Dictionary s_materialVariants = new Dictionary(); private static readonly List s_tempMaterials = new List(); private MaterialVariants(Material originalMaterial) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown m_originalMaterial = originalMaterial; seasonalMaterials = (Material[])(object)new Material[4]; for (int i = 0; i < 4; i++) { seasonalMaterials[i] = new Material(m_originalMaterial); } updateSeasonalMaterials = true; s_materialVariants[m_originalMaterial] = this; } public void InitializeTextureVariants(Dictionary cachedTextures) { foreach (KeyValuePair cachedTexture in cachedTextures) { m_textureVariants[cachedTexture.Key] = Seasons.texturesVariants.textures[cachedTexture.Value]; } foreach (KeyValuePair textureVariant in m_textureVariants) { if (!textureVariant.Value.HaveOriginalTexture()) { textureVariant.Value.SetOriginalTexture(m_originalMaterial.GetTexture(textureVariant.Key)); } } } public void InitializeColorVariants(Dictionary cachedColors) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) Color item = default(Color); foreach (KeyValuePair cachedColor in cachedColors) { if (m_colorVariants.ContainsKey(cachedColor.Key)) { continue; } s_tempColors.Clear(); string[] value = cachedColor.Value; foreach (string text in value) { if (ColorUtility.TryParseHtmlString(text, ref item)) { s_tempColors.Add(item); } } m_colorVariants.Add(cachedColor.Key, s_tempColors.ToArray()); } } public void ReplaceSharedMaterial(Renderer renderer, int materialIndex, int variant) { //IL_00da: Unknown result type (might be due to invalid IL or missing references) if (updateSeasonalMaterials || season != Seasons.seasonState.GetCurrentSeason()) { updateSeasonalMaterials = false; season = Seasons.seasonState.GetCurrentSeason(); for (int i = 0; i < 4; i++) { foreach (KeyValuePair textureVariant in m_textureVariants) { seasonalMaterials[i].SetTexture(textureVariant.Key, (Texture)(object)textureVariant.Value.GetSeasonalVariant(season, i)); } foreach (KeyValuePair colorVariant in m_colorVariants) { seasonalMaterials[i].SetColor(colorVariant.Key, colorVariant.Value[(int)season * 4 + variant]); } } } ApplySharedMaterial(renderer, materialIndex, seasonalMaterials[variant]); } public void RevertSharedMaterial(Renderer renderer, int materialIndex) { ApplySharedMaterial(renderer, materialIndex, m_originalMaterial); } public static void ApplySharedMaterial(Renderer renderer, int materialIndex, Material material) { if (!((Object)(object)renderer == (Object)null) && !((Object)(object)material == (Object)null)) { s_tempMaterials.Clear(); renderer.GetSharedMaterials(s_tempMaterials); if (s_tempMaterials.Count > materialIndex) { s_tempMaterials[materialIndex] = material; renderer.SetSharedMaterials(s_tempMaterials); } } } public static MaterialVariants GetMaterialVariants(Material material) { if (s_materialVariants.TryGetValue(material, out var value)) { return value; } return new MaterialVariants(material); } public static void UpdateSeasonalMaterials() { CollectionExtensions.Do((IEnumerable)s_materialVariants.Values, (Action)delegate(MaterialVariants matVar) { matVar.updateSeasonalMaterials = true; }); } public static void Clear() { s_tempMaterials.Clear(); CollectionExtensions.Do((IEnumerable)s_materialVariants.Values, (Action)delegate(MaterialVariants matVar) { CollectionExtensions.Do((IEnumerable)matVar.seasonalMaterials, (Action)Object.Destroy); }); s_materialVariants.Clear(); } } public class PrefabVariant { private ZNetView m_nview; private WearNTear m_wnt; private GameObject m_gameObject; private MeshRenderer m_renderer; public string m_prefabName; private double m_springFactor; private double m_summerFactor; private double m_fallFactor; private double m_winterFactor; private bool m_isVines = false; private bool m_covered = true; private float m_nextCoveredStatusCheckTime = -1f; private const float CoveredStatusCheckInterval = 5f; private readonly Dictionary> m_materialVariants = new Dictionary>(); private readonly Dictionary m_startColors = new Dictionary(); public bool Initialize(PrefabController controller, GameObject gameObject, string prefabName = null, ZNetView netView = null, WearNTear wnt = null, MeshRenderer meshRenderer = null) { //IL_03ea: Unknown result type (might be due to invalid IL or missing references) m_gameObject = gameObject; m_wnt = wnt ?? m_gameObject.GetComponent(); m_nview = netView ?? (((Object)(object)m_wnt == (Object)null) ? m_gameObject.GetComponent() : m_wnt.m_nview); if ((Object)(object)m_nview != (Object)null && (!m_nview.IsValid() || m_nview.m_ghost)) { return false; } m_prefabName = (string.IsNullOrEmpty(prefabName) ? GetPrefabName(m_gameObject) : prefabName); m_renderer = meshRenderer; if ((Object)(object)m_renderer != (Object)null) { AddMaterialVariants((Renderer)(object)m_renderer, controller.cachedRenderer); } else { LODGroup lodGroup = default(LODGroup); foreach (KeyValuePair>> item in controller.lodsInHierarchy) { string relativePath = GetRelativePath(item.Key, m_prefabName); Transform val = m_gameObject.transform.Find(relativePath); if (!((Object)(object)val == (Object)null) && ((Component)val).gameObject.TryGetComponent(ref lodGroup)) { AddLODGroupMaterialVariants(lodGroup, item.Value); } } LODGroup lodGroup2 = default(LODGroup); if (controller.lodLevelMaterials.Count > 0 && m_gameObject.TryGetComponent(ref lodGroup2)) { AddLODGroupMaterialVariants(lodGroup2, controller.lodLevelMaterials); } foreach (KeyValuePair item2 in controller.renderersInHierarchy) { string text = item2.Key; if (text.Contains(m_prefabName)) { text = item2.Key.Substring(item2.Key.IndexOf(m_prefabName) + m_prefabName.Length); if (text.StartsWith("/")) { text = text.Substring(1); } } string[] transformPath = text.Split(new char[1] { '/' }, StringSplitOptions.RemoveEmptyEntries); s_tempRenderers.Clear(); CheckRenderersInHierarchy(m_gameObject.transform, item2.Value.type, transformPath, 0, s_tempRenderers); foreach (Renderer s_tempRenderer in s_tempRenderers) { AddMaterialVariants(s_tempRenderer, item2.Value); } } if (controller.cachedRenderer != null) { Component component = m_gameObject.GetComponent(controller.cachedRenderer.type); Renderer val2 = (Renderer)(object)((component is Renderer) ? component : null); if ((Object)(object)val2 != (Object)null) { AddMaterialVariants(val2, controller.cachedRenderer); } } if (controller.particleSystemStartColors != null) { ParticleSystem ps = default(ParticleSystem); foreach (KeyValuePair particleSystemStartColor in controller.particleSystemStartColors) { string relativePath2 = GetRelativePath(particleSystemStartColor.Key, m_prefabName); Transform val3 = m_gameObject.transform.Find(relativePath2); if (!((Object)(object)val3 == (Object)null) && ((Component)val3).gameObject.TryGetComponent(ref ps)) { AddStartColorVariants(ps, particleSystemStartColor.Value); } } } } if (m_materialVariants.Count == 0 && m_startColors.Count == 0) { return false; } WorldToMapPoint(m_gameObject.transform.position, out var mx, out var my); UpdateFactors(mx, my); CheckIsVine(); return true; } public bool Reinitialize(PrefabController controller) { if ((Object)(object)m_gameObject == (Object)null) { return false; } m_materialVariants.Clear(); m_startColors.Clear(); return Initialize(controller, m_gameObject, m_prefabName, m_nview, m_wnt, m_renderer); } public void RevertState() { foreach (KeyValuePair> materialVariant in m_materialVariants) { foreach (KeyValuePair item in materialVariant.Value) { item.Value.RevertSharedMaterial(materialVariant.Key, item.Key); } } } public void CheckCoveredStatus() { if (!(Time.time < m_nextCoveredStatusCheckTime)) { m_nextCoveredStatusCheckTime = Time.time + 5f; bool flag = HaveRoof(); if (m_covered != flag) { m_covered = flag; UpdateColors(); } } } public void CheckIsVine() { m_isVines = m_prefabName == "vines" || ((Object)(object)m_wnt != (Object)null && (Object)(object)m_gameObject.GetComponent() != (Object)null); } public void UpdateColors() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_nview != (Object)null && !m_nview.IsValid()) { return; } if (((Object)(object)m_wnt != (Object)null && m_covered) || (m_gameObject.layer != 9 && Seasons.IsProtectedPosition(m_gameObject.transform.position))) { RevertState(); return; } int currentVariant = GetCurrentVariant(); foreach (KeyValuePair> materialVariant in m_materialVariants) { foreach (KeyValuePair item in materialVariant.Value) { item.Value.ReplaceSharedMaterial(materialVariant.Key, item.Key, currentVariant); } } foreach (KeyValuePair startColor in m_startColors) { MainModule main = startColor.Key.main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(startColor.Value[(int)Seasons.seasonState.GetCurrentSeason() * 4 + currentVariant]); } } public void AddToPrefabList() { instance.m_prefabVariants.Add(m_gameObject, this); if ((Object)(object)m_wnt != (Object)null) { instance.m_pieceControllers.Add(m_wnt, this); } UpdateColors(); } public void RemoveFromPrefabList() { if ((Object)(object)m_wnt != (Object)null) { instance.m_pieceControllers.Remove(m_wnt); } instance.m_prefabVariants.Remove(m_gameObject); } public Material GetOriginalMaterial(Renderer renderer, Material material) { int num = Array.IndexOf(renderer.sharedMaterials, material); if (num < 0) { return null; } if (!m_materialVariants.TryGetValue(renderer, out var value)) { return null; } if (value.Count <= num) { return null; } return value[num].m_originalMaterial; } private void UpdateFactors(float m_mx, float m_my) { m_springFactor = GetNoise(m_mx, m_my); m_summerFactor = GetNoise(1f - m_mx, m_my); m_fallFactor = GetNoise(m_mx, 1f - m_my); m_winterFactor = GetNoise(1f - m_mx, 1f - m_my); } private int GetCurrentVariant() { Seasons.Season currentSeason = Seasons.seasonState.GetCurrentSeason(); if (1 == 0) { } int result = currentSeason switch { Seasons.Season.Spring => GetVariant(m_springFactor), Seasons.Season.Summer => GetVariant(m_summerFactor), Seasons.Season.Fall => GetVariant(m_fallFactor), Seasons.Season.Winter => GetVariant(m_winterFactor), _ => GetVariant(m_springFactor), }; if (1 == 0) { } return result; } private void AddLODGroupMaterialVariants(LODGroup lodGroup, Dictionary> lodLevelMaterials) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) LOD[] lODs = lodGroup.GetLODs(); for (int i = 0; i < lodGroup.lodCount; i++) { if (!lodLevelMaterials.TryGetValue(i, out var value)) { continue; } LOD val = lODs[i]; for (int j = 0; j < val.renderers.Length; j++) { Renderer renderer = val.renderers[j]; if ((Object)(object)renderer == (Object)null) { continue; } foreach (PrefabController.CachedRenderer item in value.Where((PrefabController.CachedRenderer cr) => cr.type == ((object)renderer).GetType().Name && cr.name == ((Object)renderer).name)) { AddMaterialVariants(renderer, item); } } } } private void AddMaterialVariants(Renderer renderer, PrefabController.CachedRenderer cachedRenderer) { for (int i = 0; i < renderer.sharedMaterials.Length; i++) { Material val = renderer.sharedMaterials[i]; if ((Object)(object)val == (Object)null) { continue; } foreach (KeyValuePair material in cachedRenderer.materials) { if ((material.Value.textureProperties.Count > 0 || material.Value.colorVariants.Count > 0) && ((Object)val).name.StartsWith(material.Key) && ((Object)val.shader).name == material.Value.shaderName) { if (!m_materialVariants.TryGetValue(renderer, out var value)) { value = new Dictionary(); m_materialVariants.Add(renderer, value); } if (!value.TryGetValue(i, out var value2)) { value2 = MaterialVariants.GetMaterialVariants(val); value.Add(i, value2); } value2.InitializeTextureVariants(material.Value.textureProperties); value2.InitializeColorVariants(material.Value.colorVariants); } } } } private void AddStartColorVariants(ParticleSystem ps, string[] colorVariants) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (m_startColors.ContainsKey(ps)) { return; } s_tempColors.Clear(); Color item = default(Color); foreach (string text in colorVariants) { if (!ColorUtility.TryParseHtmlString(text, ref item)) { return; } s_tempColors.Add(item); } m_startColors.Add(ps, s_tempColors.ToArray()); } private void CheckRenderersInHierarchy(Transform transform, string rendererType, string[] transformPath, int index, List renderers) { if (transformPath.Length == 0) { Component component = ((Component)transform).GetComponent(rendererType); Renderer val = (Renderer)(object)((component is Renderer) ? component : null); if ((Object)(object)val != (Object)null) { renderers.Add(val); } return; } for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); if (!(((Object)child).name == transformPath[index])) { continue; } if (index == transformPath.Length - 1) { Component component2 = ((Component)child).GetComponent(rendererType); Renderer val2 = (Renderer)(object)((component2 is Renderer) ? component2 : null); if ((Object)(object)val2 != (Object)null) { renderers.Add(val2); } } else { CheckRenderersInHierarchy(child, rendererType, transformPath, index + 1, renderers); } } } private bool HaveRoof() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_wnt == (Object)null || m_isVines) { return false; } if (Seasons.IsProtectedPosition(m_gameObject.transform.position)) { return true; } if (!m_wnt.HaveRoof()) { return false; } int num = Physics.SphereCastNonAlloc(m_gameObject.transform.position + new Vector3(0f, 2f, 0f), 0.15f, Vector3.up, s_raycastHits, 100f, instance.m_rayMask); for (int i = 0; i < num; i++) { if (!((Object)(object)((Component)((RaycastHit)(ref s_raycastHits[i])).collider).transform.root == (Object)(object)((Component)m_wnt).transform.root)) { GameObject gameObject = ((Component)((RaycastHit)(ref s_raycastHits[i])).collider).gameObject; if ((Object)(object)gameObject != (Object)null && (Object)(object)gameObject != (Object)(object)m_wnt && !gameObject.CompareTag("leaky") && !IsWearNTearCollider(gameObject)) { return true; } } } return false; } private bool IsWearNTearCollider(GameObject go) { if (m_wnt.m_colliders == null) { return false; } for (int i = 0; i < m_wnt.m_colliders.Length; i++) { Collider val = m_wnt.m_colliders[i]; if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject == (Object)(object)go) { return true; } } return false; } } public int m_rayMask; private float m_seed; public readonly Dictionary m_prefabVariants = new Dictionary(); public readonly Dictionary m_pieceControllers = new Dictionary(); private static readonly MaterialPropertyBlock s_matBlock = new MaterialPropertyBlock(); private static readonly List s_tempRenderers = new List(); private static readonly List s_tempColors = new List(); private static readonly Dictionary s_tempPrefabNames = new Dictionary(); private static readonly List s_tempObjects = new List(); public static readonly RaycastHit[] s_raycastHits = (RaycastHit[])(object)new RaycastHit[128]; private const float noiseFrequency = 10000f; private const double noiseDivisor = 1.1; private const double noisePower = 1.3; private const string yggdrasilBranch = "YggdrasilBranch"; private static PrefabVariantController m_instance; public static PrefabVariantController instance => m_instance; private void Awake() { m_instance = this; m_rayMask = LayerMask.GetMask(new string[4] { "piece", "static_solid", "Default_small", "terrain" }); int num = ((ZNet.m_world != null) ? ZNet.m_world.m_seed : ((WorldGenerator.instance != null) ? WorldGenerator.instance.GetSeed() : 0)); m_seed = ((num == 0) ? 0f : Mathf.Log10((float)Math.Abs(num))); } private void OnDestroy() { m_pieceControllers.Clear(); RevertPrefabsState(); m_prefabVariants.Clear(); MaterialVariants.Clear(); m_instance = null; } public void RevertPrefabsState() { foreach (KeyValuePair prefabVariant in m_prefabVariants) { if ((Object)(object)prefabVariant.Key != (Object)null) { prefabVariant.Value.RevertState(); } } } public void AddControllerTo(GameObject gameObject, bool checkLocation = true, ZNetView netView = null, WearNTear wnt = null, string prefabName = null, MeshRenderer meshRenderer = null) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) if (!Seasons.UseTextureControllers() || (Object)(object)gameObject == (Object)null || m_prefabVariants.ContainsKey(gameObject)) { return; } if (prefabName == null) { prefabName = GetPrefabName(gameObject); } if ((!(prefabName == "YggdrasilRoot") || Seasons.controlYggdrasil.Value) && Seasons.texturesVariants.controllers.TryGetValue(prefabName, out var value) && (!checkLocation || !Seasons.IsIgnoredPosition(gameObject.transform.position))) { PrefabVariant prefabVariant = new PrefabVariant(); if (prefabVariant.Initialize(value, gameObject, prefabName, netView, wnt, meshRenderer)) { prefabVariant.AddToPrefabList(); } } } public void AddControllerTo(Humanoid humanoid, Ragdoll ragdoll) { if (!((Character)humanoid).InInterior() && !((Object)(object)ragdoll.m_nview == (Object)null) && ragdoll.m_nview.IsValid()) { AddControllerTo(((Component)ragdoll).gameObject, checkLocation: false, ragdoll.m_nview); } } public void AddControllerTo(WearNTear wnt) { if (!m_pieceControllers.ContainsKey(wnt) && !((Object)(object)wnt.m_nview == (Object)null) && wnt.m_nview.IsValid()) { AddControllerTo(((Component)wnt).gameObject, checkLocation: true, wnt.m_nview, wnt); } } public void AddControllerTo(MineRock5 mineRock) { if ((Object)(object)mineRock.m_nview == (Object)null || !mineRock.m_nview.IsValid()) { return; } int prefab = mineRock.m_nview.GetZDO().GetPrefab(); if (prefab != 0) { GameObject prefab2 = ZNetScene.instance.GetPrefab(prefab); if (!((Object)(object)prefab2 == (Object)null)) { AddControllerTo(((Component)mineRock).gameObject, checkLocation: true, mineRock.m_nview, null, ((Object)prefab2).name, mineRock.m_meshRenderer); } } } public void RemoveController(GameObject gameObject) { if (m_prefabVariants.TryGetValue(gameObject, out var value)) { value.RemoveFromPrefabList(); } } private static string GetRelativePath(string rendererPath, string prefabName) { string text = rendererPath; if (text.Contains(prefabName)) { text = rendererPath.Substring(rendererPath.IndexOf(prefabName) + prefabName.Length); if (text.StartsWith("/")) { text = text.Substring(1); } } return text; } public static void UpdatePrefabColors() { if (!((Object)(object)instance == (Object)null)) { UpdatePrefabColorsFromList(instance.m_prefabVariants); } } public static void UpdatePrefabColorsAroundPosition(Vector3 position, float radius, float delay = 0f) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)instance == (Object)null) { return; } if (delay == 0f) { UpdatePrefabColorsFromList(instance.m_prefabVariants.Where((KeyValuePair kvp) => (Object)(object)kvp.Key == (Object)null || Vector3.Distance(kvp.Key.transform.position, position) < radius)); } else { ((MonoBehaviour)instance).StartCoroutine(UpdatePrefabColorsAroundPositionDelayed(position, radius, delay)); } } public static void UpdateShieldStateAfterConfigChange() { ClutterVariantController.UpdateShieldActiveState(); ZoneSystemVariantController.UpdateTerrainColors(); CollectionExtensions.Do>(ShieldDomeImageEffect_SetShieldData_ProtectedStateChange.shieldRadius.Where((KeyValuePair kvp) => !Seasons.IsIgnoredPosition(kvp.Key.GetShieldPosition())), (Action>)delegate(KeyValuePair kvp) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) UpdatePrefabColorsAroundPosition(kvp.Key.GetShieldPosition(), kvp.Value + 1); }); } private static void UpdatePrefabColorsFromList(IEnumerable> variants) { if ((Object)(object)instance == (Object)null) { return; } s_tempObjects.Clear(); foreach (KeyValuePair variant in variants) { if ((Object)(object)variant.Key == (Object)null) { s_tempObjects.Add(variant.Key); } else { variant.Value.UpdateColors(); } } foreach (GameObject s_tempObject in s_tempObjects) { instance.m_prefabVariants.Remove(s_tempObject); } } public static IEnumerator UpdatePrefabColorsAroundPositionDelayed(Vector3 position, float radius, float delay = 0f) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) yield return (object)new WaitForSeconds(delay); UpdatePrefabColorsFromList(instance.m_prefabVariants.Where((KeyValuePair kvp) => (Object)(object)kvp.Key == (Object)null || Vector3.Distance(kvp.Key.transform.position, position) < radius)); } public static int GetVariant(double factor) { if (factor < 0.25) { return 0; } if (factor < 0.5) { return 1; } if (factor < 0.75) { return 2; } return 3; } public static double GetNoise(float mx, float my) { return Math.Round(Math.Pow(((double)Mathf.PerlinNoise(mx * 10000f + instance.m_seed, my * 10000f - instance.m_seed) + (double)Mathf.PerlinNoise(mx * 2f * 10000f - instance.m_seed, my * 2f * 10000f + instance.m_seed) * 0.5) / 1.1, 1.3) * 20.0) / 20.0; } public static void AddControllerToPrefabs() { if (Seasons.controlYggdrasil.Value) { Transform val = ((Component)EnvMan.instance).transform.Find("YggdrasilBranch"); if (!((Object)(object)val == (Object)null)) { instance.AddControllerTo(((Component)val).gameObject, checkLocation: false); } } } public static void ReinitializePrefabVariants() { Seasons.LogInfo("Reinitializing prefabs colors"); List list = new List(); foreach (PrefabVariant value2 in instance.m_prefabVariants.Values) { if (!Seasons.texturesVariants.controllers.TryGetValue(value2.m_prefabName, out var value)) { list.Add(value2); } else if (!value2.Reinitialize(value)) { list.Add(value2); } } foreach (PrefabVariant item in list) { item.RevertState(); item.RemoveFromPrefabList(); } foreach (ZNetView value3 in ZNetScene.instance.m_instances.Values) { if (Object.op_Implicit((Object)(object)value3)) { instance.AddControllerTo(((Component)value3).gameObject); } } UpdatePrefabColors(); } public static string GetPrefabName(GameObject go) { if (!s_tempPrefabNames.TryGetValue(((Object)go).name, out var value)) { value = Utils.GetPrefabName(go); s_tempPrefabNames.Add(((Object)go).name, value); } return value; } public static void WorldToMapPoint(Vector3 p, out float mx, out float my) { //IL_0008: 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) int num = 1024; mx = p.x / 12f + (float)num; my = p.z / 12f + (float)num; mx /= 2048f; my /= 2048f; } } [HarmonyPatch(typeof(ZNetView), "Awake")] public static class ZNetView_Awake_AddPrefabVariantController { private static PrefabVariantController CachedController => PrefabVariantController.instance; private static void Postfix(ZNetView __instance) { PrefabVariantController cachedController = CachedController; if ((Object)(object)cachedController != (Object)null && (Object)(object)__instance != (Object)null && !__instance.m_ghost && __instance.IsValid()) { cachedController.AddControllerTo(((Component)__instance).gameObject, checkLocation: true, __instance); } } } [HarmonyPatch(typeof(ZNetView), "OnDestroy")] public static class ZNetView_OnDestroy_RemovePrefabVariantController { private static void Prefix(ZNetView __instance) { PrefabVariantController.instance?.RemoveController(((Component)__instance).gameObject); } } [HarmonyPatch(typeof(ZNetScene), "Destroy")] public static class ZNetScene_Destroy_RemovePrefabVariantController { private static void Prefix(GameObject go) { PrefabVariantController.instance?.RemoveController(go); } } [HarmonyPatch(typeof(ZNetScene), "OnZDODestroyed")] public static class ZNetScene_OnZDODestroyed_RemovePrefabVariantController { private static void Prefix(Dictionary ___m_instances, ZDO zdo) { if (___m_instances.TryGetValue(zdo, out var value)) { PrefabVariantController.instance?.RemoveController(((Component)value).gameObject); } } } [HarmonyPatch(typeof(ZNetScene), "Shutdown")] public static class ZNetScene_Shutdown_RemovePrefabVariantController { private static void Prefix(Dictionary ___m_instances) { foreach (ZNetView value in ___m_instances.Values) { if (Object.op_Implicit((Object)(object)value)) { PrefabVariantController.instance?.RemoveController(((Component)value).gameObject); } } } } [HarmonyPatch(typeof(ZoneSystem), "SpawnProxyLocation")] public static class ZoneSystem_SpawnProxyLocation_AddPrefabVariantController { private static void Postfix(GameObject __result) { PrefabVariantController.instance?.AddControllerTo(__result); } } [HarmonyPatch(typeof(MineRock5), "Awake")] public static class MineRock5_Awake_AddPrefabVariantController { private static void Postfix(MineRock5 __instance) { if (!((Object)(object)__instance.m_meshRenderer == (Object)null)) { PrefabVariantController.instance?.AddControllerTo(__instance); } } } [HarmonyPatch(typeof(MineRock5), "UpdateMesh")] public static class MineRock5_UpdateMesh_FallbackToDefaultMaterial { private const int materialIndex = 0; private static void Prefix(MineRock5 __instance, ref Material __state) { if (!((Object)(object)__instance.m_meshRenderer == (Object)null) && Object.op_Implicit((Object)(object)PrefabVariantController.instance) && PrefabVariantController.instance.m_prefabVariants.TryGetValue(((Component)__instance).gameObject, out var value) && ((Renderer)__instance.m_meshRenderer).sharedMaterials != null && ((Renderer)__instance.m_meshRenderer).sharedMaterials.Length != 0) { Material originalMaterial = value.GetOriginalMaterial((Renderer)(object)__instance.m_meshRenderer, ((Renderer)__instance.m_meshRenderer).sharedMaterials[0]); if (!((Object)(object)originalMaterial == (Object)null)) { __state = ((Renderer)__instance.m_meshRenderer).sharedMaterials[0]; PrefabVariantController.MaterialVariants.ApplySharedMaterial((Renderer)(object)__instance.m_meshRenderer, 0, originalMaterial); } } } private static void Postfix(MineRock5 __instance, Material __state) { if (!((Object)(object)__state == (Object)null)) { PrefabVariantController.MaterialVariants.ApplySharedMaterial((Renderer)(object)__instance.m_meshRenderer, 0, __state); } } } [HarmonyPatch(typeof(WearNTear), "Awake")] public static class WearNTear_Start_AddPrefabVariantController { private static void Postfix(WearNTear __instance) { PrefabVariantController.instance?.AddControllerTo(__instance); } } [HarmonyPatch(typeof(WearNTear), "SetHealthVisual")] public static class WearNTear_SetHealthVisual_UpdateCoverStatus { private static void Postfix(WearNTear __instance) { PrefabVariantController instance = PrefabVariantController.instance; if ((Object)(object)instance != (Object)null && instance.m_pieceControllers.TryGetValue(__instance, out var value)) { value.CheckCoveredStatus(); } } } [HarmonyPatch(typeof(Humanoid), "OnRagdollCreated")] public static class Humanoid_OnRagdollCreated_AddPrefabVariantController { private static void Postfix(Humanoid __instance, Ragdoll ragdoll) { PrefabVariantController.instance?.AddControllerTo(__instance, ragdoll); } } [HarmonyPatch(typeof(EffectList), "Create")] public static class EffectList_Create_AddPrefabVariantController { private static void Postfix(Transform baseParent, GameObject[] __result) { if (!((Object)(object)baseParent == (Object)null) && __result != null) { foreach (GameObject gameObject in __result) { PrefabVariantController.instance?.AddControllerTo(gameObject); } } } } [HarmonyPatch(typeof(ShieldDomeImageEffect), "SetShieldData")] public static class ShieldDomeImageEffect_SetShieldData_ProtectedStateChange { public static readonly Dictionary shieldRadius = new Dictionary(); private static readonly Dictionary _cachedShieldCoverPositions = new Dictionary(); public static bool IsThereAnyActiveShieldedArea() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (shieldRadius.Count == 0 || !Seasons.IsShieldProtectionActive()) { return false; } foreach (KeyValuePair item in shieldRadius) { if (item.Value <= 0 || Seasons.IsIgnoredPosition(item.Key.GetShieldPosition())) { continue; } return true; } return false; } public static bool IsCoveredByShield(Vector3 position) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) Vector2 key = default(Vector2); ((Vector2)(ref key))..ctor(position.x, position.z); if (_cachedShieldCoverPositions.TryGetValue(key, out var value)) { return value; } if (_cachedShieldCoverPositions.Count > 15000) { _cachedShieldCoverPositions.Clear(); } value = false; foreach (KeyValuePair item in shieldRadius) { if (Vector3.Distance(item.Key.GetShieldPosition(), position) < (float)(item.Value - 2)) { value = true; break; } } _cachedShieldCoverPositions[key] = value; return value; } public static void InvalidateShieldCoverCache() { _cachedShieldCoverPositions.Clear(); } [HarmonyPriority(800)] private static void Prefix(ShieldGenerator shield, Vector3 position, float radius) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) if (!shieldRadius.TryGetValue(shield, out var value) || value / 3 != (int)radius / 3 || ((float)value != radius && (radius == 0f || (float)value == 0f))) { shieldRadius[shield] = (int)radius; InvalidateShieldCoverCache(); if (Seasons.IsShieldProtectionActive()) { ShieldGenerator.m_instanceChangeID++; PrefabVariantController.UpdatePrefabColorsAroundPosition(position, shield.m_maxShieldRadius); ZoneSystemVariantController.UpdateTerrainColorsAroundPosition(position, radius); } } } } public static class ShieldGeneratorExtensions { public static Vector3 GetShieldPosition(this ShieldGenerator shield) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) GameObject shieldDome = shield.m_shieldDome; Vector3? obj; if (shieldDome == null) { obj = null; } else { Transform transform = shieldDome.transform; obj = ((transform != null) ? new Vector3?(transform.position) : ((Vector3?)null)); } return (Vector3)(((??)obj) ?? ((Component)shield).transform.position); } } [HarmonyPatch(typeof(ShieldDomeImageEffect), "RemoveShield")] public static class ShieldDomeImageEffect_RemoveShield_ProtectedStateChange { [HarmonyPriority(800)] private static void Prefix(ShieldGenerator shield) { //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_0028: 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) if (ShieldDomeImageEffect_SetShieldData_ProtectedStateChange.shieldRadius.Remove(shield)) { ShieldDomeImageEffect_SetShieldData_ProtectedStateChange.InvalidateShieldCoverCache(); if (Seasons.IsShieldProtectionActive()) { Vector3 shieldPosition = shield.GetShieldPosition(); PrefabVariantController.UpdatePrefabColorsAroundPosition(shieldPosition, shield.m_maxShieldRadius, 5f); ZoneSystemVariantController.UpdateTerrainColorsAroundPosition(shieldPosition, shield.m_maxShieldRadius, 5f); } } } } public class ZoneSystemVariantController : MonoBehaviour { public class WaterState { public GameObject m_iceSurface; public float m_surfaceOffset; public float m_foamDepth; public Color m_colorTop; public Color m_colorBottom; public Color m_colorBottomShallow; public Color m_colorTopFrozen; public Color m_colorBottomFrozen; public Color m_colorBottomShallowFrozen; public WaterState(WaterVolume waterVolume) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) m_surfaceOffset = waterVolume.m_surfaceOffset; m_foamDepth = ((Renderer)waterVolume.m_waterSurface).sharedMaterial.GetFloat("_FoamDepth"); m_colorTop = ((Renderer)waterVolume.m_waterSurface).sharedMaterial.GetColor("_ColorTop"); m_colorBottom = ((Renderer)waterVolume.m_waterSurface).sharedMaterial.GetColor("_ColorBottom"); m_colorBottomShallow = ((Renderer)waterVolume.m_waterSurface).sharedMaterial.GetColor("_ColorBottomShallow"); InitFrozenColors(); } public WaterState(MeshRenderer waterSurface) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) m_foamDepth = ((Renderer)waterSurface).sharedMaterial.GetFloat("_FoamDepth"); m_colorTop = ((Renderer)waterSurface).sharedMaterial.GetColor("_ColorTop"); m_colorBottom = ((Renderer)waterSurface).sharedMaterial.GetColor("_ColorBottom"); m_colorBottomShallow = ((Renderer)waterSurface).sharedMaterial.GetColor("_ColorBottomShallow"); InitFrozenColors(); } private void InitFrozenColors() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) m_colorTopFrozen = new Color(0.98f, 0.98f, 1f); m_colorBottomFrozen = Color.Lerp(m_colorBottom, Color.white, 0.5f); m_colorBottomShallowFrozen = Color.Lerp(m_colorBottomShallow, Color.white, 0.5f); } } private class FrozenOceanFishPositionGuard : MonoBehaviour { public float m_nextCheckTime; } private static MeshRenderer s_waterPlane; private static WaterState s_waterPlaneState; public static float s_waterEdge; public static bool s_waterEdgeLocalPlayerState; public static float s_waterDistance; public static readonly Dictionary waterStates = new Dictionary(); private static readonly MaterialPropertyBlock s_matBlock = new MaterialPropertyBlock(); private static readonly List m_tempZDOList = new List(); private static readonly List m_tempHits = new List(); private static float s_freezeStatus = 0f; public static float s_colliderHeight = 0f; public const float _winterWaterSurfaceOffset = 2f; public const float _colliderOffset = 0.01f; public const string _iceSurfaceName = "IceSurface"; public static readonly int s_playerDroppedFish = StringExtensionMethods.GetStableHashCode("Seasons_PlayerDroppedFish"); private const float FishIceCheckInterval = 5f; private const float FishIceRayStartAboveWater = 0.5f; private const float FishIceRayEndBelowTarget = 0.25f; private const float FishIceCheckRandomJitter = 1f; private static readonly RaycastHit[] s_fishIceHits = (RaycastHit[])(object)new RaycastHit[8]; public const string _iceFloeName = "ice1"; public static int s_iceFloePrefab = StringExtensionMethods.GetStableHashCode("ice1"); public static Vector2 s_floeSize = new Vector2(8.36f, 8f) / 2f; public static GameObject s_iceSurface; public static ZoneVegetation s_iceFloe; public static int s_zoneCtrlPrefab; public static int s_terrainCompilerPrefab; public const int s_terrainCompVersion = 1; private const float _FoamDepthFrozen = 10f; private const float _WaveVel = 0f; private const float _WaveFoam = 0f; private const float _Glossiness = 0.95f; private const float _Metallic = 0.1f; private const float _DepthFade = 20f; private const float _ShoreFade = 0f; public float m_createDestroyTimer; public RaycastHit[] rayHits = (RaycastHit[])(object)new RaycastHit[200]; private ParticleSystem m_snowStorm; private Biome m_currentBiome; private int m_snowStormMaxParticles; private float m_snowStormEmissionRate; internal static bool waterStateInitialized = false; private static ZoneSystemVariantController m_instance; public readonly List waterVolumesCheckFloes = new List(); private static readonly List tempWaterVolumesList = new List(); private static readonly List m_tempClearAreas = new List(); private static readonly List m_tempSpawnedObjects = new List(); private static readonly List s_tempColors = new List(); private static readonly List s_smoothColors = new List(); private static readonly List s_protectedHeightmaps = new List(); private static readonly List s_tempHeightmaps = new List(); public static ZoneSystemVariantController Instance => m_instance; public static float WaterLevel => (s_colliderHeight == 0f || !IsWaterSurfaceFrozen()) ? ZoneSystem.instance.m_waterLevel : s_colliderHeight; public static bool IsWaterSurfaceFrozen() { return s_freezeStatus == 1f; } public static bool IsTimeForIceFloes() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) return Seasons.enableIceFloes.Value && !IsWaterSurfaceFrozen() && Seasons.seasonState.GetCurrentSeason() == Seasons.Season.Winter && (int)Seasons.iceFloesInWinterDays.Value.x <= Seasons.seasonState.GetCurrentDay() && Seasons.seasonState.GetCurrentDay() <= (int)Seasons.iceFloesInWinterDays.Value.y; } public static bool IsTimeToDecultivateGround() { return Seasons.cultivatedGroundTurnsIntoDirtInWinter.Value && Seasons.seasonState.GetCurrentSeason() == Seasons.Season.Winter; } public static bool IsBeyondWorldEdge(Vector3 position, float offset = 0f) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) return Utils.DistanceXZ(Vector3.zero, position) > s_waterEdge - offset; } private void Awake() { m_instance = this; } public void Update() { float deltaTime = Time.deltaTime; m_createDestroyTimer += deltaTime; if (m_createDestroyTimer >= 1f / 15f && waterVolumesCheckFloes.Count > 0) { m_createDestroyTimer = 0f; CreateDestroyFloes(); } } private void CreateDestroyFloes() { m_tempClearAreas.Clear(); if (!waterStateInitialized) { return; } tempWaterVolumesList.Clear(); foreach (WaterVolume waterVolumesCheckFlo in waterVolumesCheckFloes) { if (!CheckWaterVolumeForIceFloes(waterVolumesCheckFlo)) { tempWaterVolumesList.Add(waterVolumesCheckFlo); } } waterVolumesCheckFloes.Clear(); waterVolumesCheckFloes.AddRange(tempWaterVolumesList); tempWaterVolumesList.Clear(); } private void OnDestroy() { s_waterPlane = null; s_waterPlaneState = null; s_iceSurface = null; waterStates.Clear(); m_instance = null; waterStateInitialized = false; } public void Initialize(ZoneSystem instance) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) Transform val = ((Component)EnvMan.instance).transform.Find("WaterPlane"); if ((Object)(object)val != (Object)null) { s_waterPlane = ((Component)val).GetComponentInChildren(); } s_waterPlaneState = new WaterState(s_waterPlane); Transform val2 = instance.m_zonePrefab.transform.Find("Water"); if ((Object)(object)val2 != (Object)null) { AddIceCollider(val2); } if (s_iceFloe == null) { s_iceFloe = ZoneSystem.instance.m_vegetation.Find(delegate(ZoneVegetation veg) { GameObject prefab = veg.m_prefab; return ((prefab != null) ? ((Object)prefab).name : null) == "ice1"; }).Clone(); } s_iceFloe.m_biome = (Biome)256; IceFloeClimb iceFloeClimb = default(IceFloeClimb); if (!s_iceFloe.m_prefab.TryGetComponent(ref iceFloeClimb)) { s_iceFloe.m_prefab.AddComponent(); } s_iceFloe.m_prefab.GetComponent().m_syncInitialScale = true; } public bool BiomeChanged(Biome biome) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (m_currentBiome == biome) { return false; } m_currentBiome = biome; return true; } public void CheckBiomeChanged(Biome biome) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0167: 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_0086: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Invalid comparison between Unknown and I4 //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Invalid comparison between Unknown and I4 //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Invalid comparison between Unknown and I4 //IL_01ff: Unknown result type (might be due to invalid IL or missing references) if (!Seasons.UseTextureControllers() || !SeasonState.IsActive) { return; } if (Seasons.reduceSnowStormInWinter.Value == Vector2.zero || (Object)(object)Player.m_localPlayer == (Object)null) { if ((Object)(object)m_snowStorm != (Object)null && m_snowStormMaxParticles != 0 && m_snowStormEmissionRate != 0f) { MainModule main = m_snowStorm.main; EmissionModule emission = m_snowStorm.emission; ((EmissionModule)(ref emission)).rateOverTimeMultiplier = m_snowStormEmissionRate; ((MainModule)(ref main)).maxParticles = m_snowStormMaxParticles; } } else { if (!BiomeChanged(biome)) { return; } if ((Object)(object)m_snowStorm == (Object)null) { Transform val = ((Component)EnvMan.instance).transform.Find("FollowPlayer/SnowStorm") ?? Utils.FindChild(((Component)EnvMan.instance).transform, "SnowStorm", (IterativeSearchType)0); if ((Object)(object)val == (Object)null) { return; } Transform val2 = val.Find("snow (1)"); if ((Object)(object)val2 == (Object)null) { return; } m_snowStorm = ((Component)val2).GetComponent(); } MainModule main2 = m_snowStorm.main; EmissionModule emission2 = m_snowStorm.emission; if (m_snowStormMaxParticles == 0) { m_snowStormMaxParticles = ((MainModule)(ref main2)).maxParticles; } if (m_snowStormEmissionRate == 0f) { m_snowStormEmissionRate = ((EmissionModule)(ref emission2)).rateOverTimeMultiplier; } bool flag = Seasons.seasonState.GetCurrentSeason() == Seasons.Season.Winter && (int)biome != 4 && (int)biome != 32 && (int)biome != 64; ((EmissionModule)(ref emission2)).rateOverTimeMultiplier = (flag ? Seasons.reduceSnowStormInWinter.Value.x : m_snowStormEmissionRate); ((MainModule)(ref main2)).maxParticles = (flag ? ((int)Seasons.reduceSnowStormInWinter.Value.y) : m_snowStormMaxParticles); } } public static void SnowStormReduceParticlesChanged() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Instance)) { Instance.m_currentBiome = (Biome)0; } } public static void UpdateTerrainColor(Heightmap heightmap) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)heightmap?.m_renderMesh == (Object)null) { return; } Heightmap_GetBiomeColor_TerrainColor.overrideColor = true; int num = heightmap.m_width + 1; Vector3 val = ((Component)heightmap).transform.position + new Vector3((float)((double)heightmap.m_width * (double)heightmap.m_scale * -0.5), 0f, (float)((double)heightmap.m_width * (double)heightmap.m_scale * -0.5)); s_tempColors.Clear(); bool flag = false; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { if (heightmap.m_isDistantLod) { float num2 = val.x + (float)j * heightmap.m_scale; float num3 = val.z + (float)i * heightmap.m_scale; Biome biome = WorldGenerator.instance.GetBiome(num2, num3, 0.02f, false); s_tempColors.Add(Heightmap.GetBiomeColor(biome)); continue; } float num4 = DUtils.SmoothStep(0f, 1f, (float)j / (float)heightmap.m_width); float num5 = DUtils.SmoothStep(0f, 1f, (float)i / (float)heightmap.m_width); Vector3 position = ((Component)heightmap).transform.position + heightmap.CalcVertex(j, i); if (IsProtectedHeightmap(heightmap) && Seasons.IsShieldedPosition(position)) { flag = true; s_tempColors.Add(Color32.op_Implicit(Heightmap_GetBiomeColor_TerrainColor.GetOriginalColor(heightmap, num4, num5))); } else { s_tempColors.Add(Color32.op_Implicit(heightmap.GetBiomeColor(num4, num5))); } } } Heightmap_GetBiomeColor_TerrainColor.overrideColor = false; if (flag) { SmoothenProtectedBorders(s_tempColors, heightmap.m_width + 1); } heightmap.m_renderMesh.SetColors(s_tempColors); s_tempColors.Clear(); } public static void SmoothenProtectedBorders(List colors, int size) { //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) s_smoothColors.Clear(); s_smoothColors.AddRange(colors); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; for (int k = -1; k <= 1; k++) { for (int l = -1; l <= 1; l++) { int num6 = j + k; int num7 = i + l; if (num6 >= 0 && num6 < size && num7 >= 0 && num7 < size) { Color32 val = colors[num7 * size + num6]; num += val.r; num2 += val.g; num3 += val.b; num4 += val.a; num5++; } } } s_smoothColors[i * size + j] = new Color32((byte)(num / num5), (byte)(num2 / num5), (byte)(num3 / num5), (byte)(num4 / num5)); } } colors.Clear(); colors.AddRange(s_smoothColors); s_smoothColors.Clear(); } public static void UpdateTerrainColors() { UpdateTerrainColorsFromList(Heightmap.Instances.Cast()); } public static void UpdateTerrainColorsFromList(IEnumerable list) { UpdateProtectedHeightmaps(); foreach (Heightmap item in list) { UpdateTerrainColor(item); } } private static void UpdateProtectedHeightmaps() { //IL_0047: 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) s_protectedHeightmaps.Clear(); if (!Seasons.IsShieldProtectionActive()) { return; } foreach (ShieldGenerator instance in ShieldGenerator.m_instances) { GameObject shieldDome = instance.m_shieldDome; Heightmap.FindHeightmap((shieldDome != null) ? shieldDome.transform.position : ((Component)instance).transform.position, instance.m_maxShieldRadius + 1f, s_protectedHeightmaps); } } public static bool IsProtectedHeightmap(Heightmap heightmap) { return (Object)(object)heightmap != (Object)null && s_protectedHeightmaps.Contains(heightmap); } public static void UpdateTerrainColorsAroundPosition(Vector3 position, float radius, float delay = 0f) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Instance == (Object)null)) { if (delay == 0f) { UpdateTerrainAroundPosition(position, radius); } else { ((MonoBehaviour)Instance).StartCoroutine(UpdateTerrainColorsAroundPositionDelayed(position, radius, delay)); } } } public static IEnumerator UpdateTerrainColorsAroundPositionDelayed(Vector3 position, float radius, float delay = 0f) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) yield return (object)new WaitForSeconds(delay); UpdateTerrainAroundPosition(position, radius); } private static void UpdateTerrainAroundPosition(Vector3 position, float radius) { //IL_0012: 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) ClutterVariantController.UpdateShieldActiveState(); s_tempHeightmaps.Clear(); Heightmap.FindHeightmap(position, radius, s_tempHeightmaps); UpdateTerrainColorsFromList(s_tempHeightmaps); ClutterSystem instance = ClutterSystem.instance; if (instance != null) { instance.ResetGrass(position, radius + 1f); } } public static void AddIceCollider(Transform water) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s_iceSurface != (Object)null) { return; } Transform val = water.Find("IceSurface"); if ((Object)(object)val != (Object)null) { s_iceSurface = ((Component)val).gameObject; return; } Transform val2 = water.Find("WaterSurface"); if (s_colliderHeight == 0f) { s_colliderHeight = ((Component)val2).transform.position.y + 0.01f; } s_iceSurface = new GameObject("IceSurface"); s_iceSurface.transform.SetParent(water); s_iceSurface.layer = 0; s_iceSurface.transform.localScale = new Vector3(((Component)val2).transform.localScale.x, Math.Abs(0.01f), ((Component)val2).transform.localScale.z); s_iceSurface.transform.localPosition = new Vector3(0f, 0.01f, 0f); s_iceSurface.SetActive(false); MeshCollider val3 = s_iceSurface.gameObject.AddComponent(); val3.sharedMesh = ((Component)val2).GetComponent().sharedMesh; ((Collider)val3).material.staticFriction = 0.1f; ((Collider)val3).material.dynamicFriction = 0.1f; ((Collider)val3).material.frictionCombine = (PhysicsMaterialCombine)2; val3.cookingOptions = (MeshColliderCookingOptions)16; } public static void UpdateWaterState() { if (!SeasonState.IsActive) { return; } s_freezeStatus = Seasons.seasonState.GetWaterSurfaceFreezeStatus(); waterStateInitialized = true; CheckZDODatabase(); foreach (KeyValuePair waterState in waterStates) { UpdateWater(waterState.Key, waterState.Value); } UpdateWaterSurface(s_waterPlane, s_waterPlaneState); ZoneSystemVariantController instance = Instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(UpdateWaterObjects()); } } public static void UpdateWater(WaterVolume waterVolume, WaterState waterState, bool revertState = false) { SetupIceCollider(waterVolume, waterState, revertState); if (s_freezeStatus == 0f || revertState) { if ((Object)(object)waterVolume.m_waterSurface != (Object)null && ((Renderer)waterVolume.m_waterSurface).HasPropertyBlock()) { ((Renderer)waterVolume.m_waterSurface).SetPropertyBlock((MaterialPropertyBlock)null); } waterVolume.m_surfaceOffset = waterState.m_surfaceOffset; waterVolume.m_useGlobalWind = true; waterVolume.SetupMaterial(); } else { UpdateWaterSurface(waterVolume.m_waterSurface, waterState); waterVolume.m_surfaceOffset = waterState.m_surfaceOffset - (IsWaterSurfaceFrozen() ? 2f : 0f); waterVolume.m_useGlobalWind = !IsWaterSurfaceFrozen(); waterVolume.SetupMaterial(); } } private static void UpdateWaterSurface(MeshRenderer waterSurface, WaterState waterState) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)waterSurface == (Object)null) && waterState != null) { s_matBlock.Clear(); s_matBlock.SetColor("_FoamColor", new Color(0.95f, 0.96f, 0.98f)); s_matBlock.SetFloat("_FoamDepth", Mathf.Lerp(waterState.m_foamDepth, 10f, s_freezeStatus)); s_matBlock.SetColor("_ColorTop", Color.Lerp(waterState.m_colorTop, waterState.m_colorTopFrozen, s_freezeStatus)); s_matBlock.SetColor("_ColorBottom", Color.Lerp(waterState.m_colorBottom, waterState.m_colorBottomFrozen, s_freezeStatus)); s_matBlock.SetColor("_ColorBottomShallow", Color.Lerp(waterState.m_colorBottomShallow, waterState.m_colorBottomShallowFrozen, s_freezeStatus)); if (IsWaterSurfaceFrozen()) { s_matBlock.SetFloat(WaterVolume.s_shaderWaterTime, 0f); s_matBlock.SetFloat(WaterVolume.s_shaderUseGlobalWind, 0f); s_matBlock.SetFloat("_DepthFade", 20f); s_matBlock.SetFloat("_Glossiness", 0.95f); s_matBlock.SetFloat("_Metallic", 0.1f); s_matBlock.SetFloat("_ShoreFade", 0f); s_matBlock.SetFloat("_WaveVel", 0f); s_matBlock.SetFloat("_WaveFoam", 0f); } ((Renderer)waterSurface).SetPropertyBlock(s_matBlock); } } private static void SetupIceCollider(WaterVolume waterVolume, WaterState waterState, bool revertState) { if ((Object)(object)waterState.m_iceSurface == (Object)null) { Transform obj = ((Component)waterVolume).transform.parent.Find("IceSurface"); waterState.m_iceSurface = ((obj != null) ? ((Component)obj).gameObject : null); } if (revertState) { GameObject iceSurface = waterState.m_iceSurface; if (iceSurface != null) { iceSurface.SetActive(false); } } else { GameObject iceSurface2 = waterState.m_iceSurface; if (iceSurface2 != null) { iceSurface2.SetActive(IsWaterSurfaceFrozen()); } } } public static bool LocalPlayerIsOnFrozenOcean() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 return IsWaterSurfaceFrozen() && (Object)(object)Player.m_localPlayer != (Object)null && (int)Player.m_localPlayer.GetCurrentBiome() == 256; } public static IEnumerator UpdateWaterObjects() { yield return Seasons.waitForFixedUpdate; foreach (WaterVolume waterVolume in waterStates.Keys) { foreach (IWaterInteractable waterInteractable in waterVolume.m_inWater) { Fish fish = (Fish)(object)((waterInteractable is Fish) ? waterInteractable : null); if (fish != null) { CheckIfFishAboveSurface(fish); continue; } Character character = (Character)(object)((waterInteractable is Character) ? waterInteractable : null); if (character != null) { CheckIfCharacterBelowSurface(character); continue; } Floating floating = (Floating)(object)((waterInteractable is Floating) ? waterInteractable : null); if (floating != null) { CheckIfFloatingContainerBelowSurface(floating); } } Instance.waterVolumesCheckFloes.Add(waterVolume); } yield return Seasons.waitForFixedUpdate; foreach (Ship ship in Ship.Instances.ToArray().Cast()) { yield return CheckIfShipBelowSurface(ship); } } public static IEnumerator CheckSingleFishPosition(Fish fish) { yield return Seasons.waitForFixedUpdate; CheckIfFishAboveSurface(fish); } public static bool IsUnderwaterAI(Character character, out BaseAI ai) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 return ((Component)character).TryGetComponent(ref ai) && ((int)ai.m_pathAgentType == 7 || (int)ai.m_pathAgentType == 9); } public static void UpdateShipsPositions() { foreach (Ship item in Ship.Instances.ToArray().Cast()) { if (item.m_nview.IsOwner()) { PlaceShip(item); } } } public static void UpdateFloatingPositions() { foreach (Floating item in Floating.Instances.ToArray().Cast()) { CheckIfFloatingContainerBelowSurface(item); } } public static IEnumerator CheckIfShipBelowSurface(Ship ship) { if (!((Object)(object)ship == (Object)null) && !((Object)(object)((Component)ship).gameObject == (Object)null)) { while (ship.m_nview.IsValid() && !ship.m_nview.HasOwner()) { yield return Seasons.waitForFixedUpdate; } if (ship.m_nview.IsValid() && ship.m_nview.IsOwner()) { PlaceShip(ship); } } } public static void PlaceShip(Ship ship) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) ship.m_body.WakeUp(); ship.m_body.isKinematic = false; List list = (from renderer in ((Component)ship).GetComponentsInChildren(true) where (Object)(object)((Renderer)renderer).sharedMaterial != (Object)null && (Object)(object)((Renderer)renderer).sharedMaterial.shader != (Object)null && ((Object)((Renderer)renderer).sharedMaterial.shader).name == "Custom/WaterMask" select renderer).ToList(); CollectionExtensions.Do((IEnumerable)list, (Action)delegate(MeshRenderer renderer) { ((Component)renderer).gameObject.SetActive(true); }); float num = ship.m_body.position.y - (WaterLevel + ship.m_waterLevelOffset); if (num > 0f || !IsWaterSurfaceFrozen()) { return; } ship.m_body.isKinematic = !Seasons.placeShipAboveFrozenOcean.Value; ZSyncTransform val = default(ZSyncTransform); if (((Component)ship).TryGetComponent(ref val)) { val.m_isKinematicBody = ship.m_body.isKinematic; } if (Seasons.placeShipAboveFrozenOcean.Value) { ship.m_body.rotation = Quaternion.identity; ship.m_body.position = new Vector3(ship.m_body.position.x, WaterLevel + ship.m_waterLevelOffset + 0.1f, ship.m_body.position.z); ship.m_body.linearVelocity = Vector3.zero; } else if (Seasons.frozenKarvePositionFix.Value && Utils.GetPrefabName(((Object)ship).name) == "Karve" && num <= -1.43f) { ship.m_body.rotation = Quaternion.identity; ship.m_body.position = new Vector3(ship.m_body.position.x, WaterLevel + ship.m_waterLevelOffset - 1.42f, ship.m_body.position.z); ship.m_body.linearVelocity = Vector3.zero; } else if (num < (0f - ship.m_waterLevelOffset) * 1.5f && ship.m_body.isKinematic) { CollectionExtensions.Do((IEnumerable)list, (Action)delegate(MeshRenderer renderer) { ((Component)renderer).gameObject.SetActive(false); }); } } public static void CheckIfFishAboveSurface(Fish fish) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)fish == (Object)null || (Object)(object)fish.m_nview == (Object)null || !fish.m_nview.IsValid() || IsPlayerDroppedFish(fish) || (fish.m_nview.HasOwner() && !fish.m_nview.IsOwner())) { return; } float num = WaterLevel - 2f - fish.m_height - 1.5f; if (!(((Component)fish).transform.position.y <= num) && IsFishAboveFrozenSurface(fish, num)) { ((Component)fish).transform.position = new Vector3(((Component)fish).transform.position.x, num, ((Component)fish).transform.position.z); fish.m_nview.GetZDO().SetPosition(((Component)fish).transform.position); if ((Object)(object)fish.m_body != (Object)null) { fish.m_body.linearVelocity = Vector3.zero; } fish.m_haveWaypoint = false; fish.m_isJumping = false; } } private static bool IsFishAboveFrozenSurface(Fish fish, float maximumLevel) { //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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) ZoneSystem instance = ZoneSystem.instance; if ((Object)(object)instance == (Object)null) { return false; } Vector3 position = ((Component)fish).transform.position; position.y = Mathf.Max(((Component)fish).transform.position.y + 0.25f, WaterLevel + 0.5f); float num = position.y - (maximumLevel - 0.25f); if (num <= 0f) { return false; } int num2 = Physics.RaycastNonAlloc(position, Vector3.down, s_fishIceHits, num, instance.m_solidRayMask, (QueryTriggerInteraction)1); if (num2 <= 0) { return false; } RaycastHit val = default(RaycastHit); float num3 = float.MaxValue; bool flag = false; for (int i = 0; i < num2; i++) { RaycastHit val2 = s_fishIceHits[i]; if (!((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null) && !((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(((Component)fish).transform) && !(((RaycastHit)(ref val2)).distance >= num3)) { val = val2; num3 = ((RaycastHit)(ref val2)).distance; flag = true; } } return flag && IsIceSurfaceCollider(((RaycastHit)(ref val)).collider); } private static bool IsIceSurfaceCollider(Collider collider) { if ((Object)(object)collider == (Object)null) { return false; } Transform val = ((Component)collider).transform; while ((Object)(object)val != (Object)null) { if (Utils.GetPrefabName(((Object)val).name) == "IceSurface") { return true; } val = val.parent; } return false; } public static bool IsPlayerDroppedFish(Fish fish) { return (Object)(object)fish != (Object)null && (Object)(object)fish.m_nview != (Object)null && fish.m_nview.IsValid() && fish.m_nview.GetZDO().GetBool(s_playerDroppedFish, false); } public static void MarkPlayerDroppedFish(ItemDrop itemDrop) { Fish val = default(Fish); if (!((Object)(object)itemDrop == (Object)null) && ((Component)itemDrop).TryGetComponent(ref val) && !((Object)(object)val.m_nview == (Object)null) && val.m_nview.IsValid()) { val.m_nview.GetZDO().Set(s_playerDroppedFish, true); } } internal static bool ShouldThrottleFishIceCheck(Fish fish) { if ((Object)(object)fish == (Object)null) { return true; } FrozenOceanFishPositionGuard frozenOceanFishPositionGuard = ((Component)fish).GetComponent() ?? ((Component)fish).gameObject.AddComponent(); if (Time.time < frozenOceanFishPositionGuard.m_nextCheckTime) { return true; } frozenOceanFishPositionGuard.m_nextCheckTime = Time.time + 5f + Random.Range(0f, 1f); return false; } public static void CheckIfCharacterBelowSurface(Character character) { //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || (Object)(object)character.m_nview == (Object)null || !character.m_nview.IsValid() || !character.m_nview.IsOwner()) { return; } if (IsUnderwaterAI(character, out var ai)) { if (((Component)character).transform.position.y >= WaterLevel) { m_tempHits.Clear(); Pathfinding.instance.FindGround(((Component)character).transform.position, true, m_tempHits, Pathfinding.instance.GetSettings(ai.m_pathAgentType)); Vector3 val = m_tempHits.Find((Vector3 h) => h.y < WaterLevel); if (val.y != 0f) { character.m_body.linearVelocity = Vector3.zero; ((Component)character).transform.position = new Vector3(((Component)character).transform.position.x, Mathf.Max(WaterLevel - 2f, val.y + 0.1f), ((Component)character).transform.position.z); } } } else if (((Component)character).transform.position.y <= WaterLevel && !character.IsAttachedToShip()) { character.m_body.linearVelocity = Vector3.zero; ((Component)character).transform.position = new Vector3(((Component)character).transform.position.x, WaterLevel + 0.5f, ((Component)character).transform.position.z); character.InvalidateCachedLiquidDepth(); character.m_maxAirAltitude = ((Component)character).transform.position.y; character.m_swimTimer = 0.6f; } } public static void CheckIfFloatingContainerBelowSurface(Floating floating) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) if (Seasons.placeFloatingContainersAboveFrozenOcean.Value && !((Object)(object)floating == (Object)null) && !((Object)(object)floating.m_nview == (Object)null) && floating.m_nview.IsValid() && floating.m_nview.IsOwner() && !((Object)(object)((Component)floating).GetComponent() == (Object)null)) { floating.m_body.WakeUp(); float num = floating.m_body.position.y - (WaterLevel + floating.m_waterLevelOffset); if (!(num > 0f) && IsWaterSurfaceFrozen()) { floating.m_body.rotation = Quaternion.identity; floating.m_body.position = new Vector3(floating.m_body.position.x, WaterLevel + floating.m_waterLevelOffset + 0.1f, floating.m_body.position.z); floating.m_body.linearVelocity = Vector3.zero; } } } public static void CheckZDODatabase() { if (!ZNet.instance.IsServer()) { return; } if (s_zoneCtrlPrefab == 0) { s_zoneCtrlPrefab = StringExtensionMethods.GetStableHashCode(((Object)(object)ZoneSystem.instance == (Object)null) ? "_ZoneCtrl" : Utils.GetPrefabName(ZoneSystem.instance.m_zoneCtrlPrefab)); } if (s_terrainCompilerPrefab == 0) { s_terrainCompilerPrefab = StringExtensionMethods.GetStableHashCode("_TerrainCompiler"); } bool flag = !IsTimeForIceFloes(); bool flag2 = IsTimeToDecultivateGround(); if (!flag && !flag2) { return; } int yearLengthInDays = Seasons.seasonState.GetYearLengthInDays(); int currentWorldDay = Seasons.seasonState.GetCurrentWorldDay(); int num = 0; int num2 = 0; int num3 = 0; foreach (ZDO value in ZDOMan.instance.m_objectsByID.Values) { if (flag) { if (value.GetPrefab() == s_iceFloePrefab && value.GetBool(SeasonsVars.s_iceFloeWatermark, false)) { RemoveObject(value, force: true); num++; } if (value.GetPrefab() == s_zoneCtrlPrefab && value.GetBool(SeasonsVars.s_iceFloesSpawned, false)) { value.Set(SeasonsVars.s_iceFloesSpawned, false); num2++; } } if (flag2 && value.GetPrefab() == s_terrainCompilerPrefab && Mathf.Abs(currentWorldDay - value.GetInt(SeasonsVars.s_terrainDecultivated, 0)) >= yearLengthInDays) { value.Set(SeasonsVars.s_terrainDecultivated, currentWorldDay, false); if (TerrainDecultivation.DecultivateGround(value)) { num3++; } } } LogFloeState($"Removed overworld floes:{num}, Zones refreshed:{num2}"); Seasons.LogInfo($"Terrains decultivated:{num3}"); } public bool CheckWaterVolumeForIceFloes(WaterVolume waterVolume) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Invalid comparison between Unknown and I4 if ((Object)(object)waterVolume == (Object)null || (Object)(object)waterVolume.m_heightmap == (Object)null) { return true; } Vector3 position = ((Component)waterVolume).transform.position; if ((int)WorldGenerator.instance.GetBiome(position) != 256) { return true; } Vector2i zone = ZoneSystem.GetZone(position); if (!ZoneSystem.instance.IsZoneLoaded(zone)) { return false; } m_tempZDOList.Clear(); ZDOMan.instance.FindObjects(zone, m_tempZDOList); m_tempZDOList.RemoveAll((ZDO zdo) => zdo.GetPrefab() != s_iceFloePrefab); if (IsTimeForIceFloes() && m_tempZDOList.Count > 0) { return true; } if (!IsTimeForIceFloes() && m_tempZDOList.Count == 0) { return true; } if (!IsTimeForIceFloes() && m_tempZDOList.Count > 0) { LogFloeState($"Removing occasional floes: {m_tempZDOList.Count}"); foreach (ZDO tempZDO in m_tempZDOList) { RemoveObject(tempZDO, force: true); } } else if (IsTimeForIceFloes() && m_tempZDOList.Count == 0) { Vector3 zonePos = ZoneSystem.GetZonePos(zone); SpawnSystem val = ((IEnumerable)SpawnSystem.m_instances).FirstOrDefault((Func)((SpawnSystem ss) => (Object)(object)ss.m_heightmap == (Object)(object)Heightmap.FindHeightmap(zonePos))); if ((Object)(object)val == (Object)null) { return false; } ZNetView nview = val.m_nview; ZDO val2 = ((nview != null) ? nview.GetZDO() : null); if (val2 != null) { if (val2.GetBool(SeasonsVars.s_iceFloesSpawned, false)) { return true; } val2.Set(SeasonsVars.s_iceFloesSpawned, true); } SpawnMode val3 = (SpawnMode)((!ZNetScene.instance.IsAreaReady(position)) ? 2 : 0); m_tempSpawnedObjects.Clear(); PlaceIceFloes(zone, zonePos, m_tempClearAreas, val3, m_tempSpawnedObjects); LogFloeState($"{zone} {zonePos} Spawned {val3} floes:{m_tempSpawnedObjects.Count}"); if ((int)val3 == 2) { foreach (GameObject tempSpawnedObject in m_tempSpawnedObjects) { Object.Destroy((Object)(object)tempSpawnedObject); } } m_tempSpawnedObjects.Clear(); } return true; } public static void PlaceIceFloes(Vector2i zoneID, Vector3 zoneCenterPos, List clearAreas, SpawnMode mode, List spawnedObjects) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Invalid comparison between Unknown and I4 //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Invalid comparison between Unknown and I4 //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Invalid comparison between Unknown and I4 //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Invalid comparison between Unknown and I4 //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Expected O, but got Unknown State state = Random.state; int seed = WorldGenerator.instance.GetSeed(); float num = ZoneSystem.instance.m_zoneSize / 2f; Random.InitState(seed + zoneID.x * 4271 + zoneID.y * 9187 + s_iceFloePrefab + (SeasonState.IsActive ? Seasons.seasonState.GetCurrentWorldDay() : 0)); int num2 = Random.Range((int)Seasons.amountOfIceFloesInWinterDays.Value.x, (int)Seasons.amountOfIceFloesInWinterDays.Value.y + 1); Vector3 val = default(Vector3); Biome val2 = default(Biome); BiomeArea val3 = default(BiomeArea); Heightmap val4 = default(Heightmap); for (int i = 0; i < num2; i++) { Vector3 p = new Vector3(Random.Range(zoneCenterPos.x - num, zoneCenterPos.x + num), 0f, Random.Range(zoneCenterPos.z - num, zoneCenterPos.z + num)); if (IsBeyondWorldEdge(p, 100f) || ZoneSystem.instance.InsideClearArea(clearAreas, p) || (s_iceFloe.m_blockCheck && ZoneSystem.instance.IsBlocked(p))) { continue; } float num3 = p.y - ZoneSystem.instance.m_waterLevel; if (num3 < s_iceFloe.m_minAltitude || num3 > s_iceFloe.m_maxAltitude) { continue; } ZoneSystem.instance.GetGroundData(ref p, ref val, ref val2, ref val3, ref val4); if ((s_iceFloe.m_biome & val2) == 0 || (s_iceFloe.m_biomeArea & val3) == 0) { continue; } float oceanDepth = val4.GetOceanDepth(p); if (s_iceFloe.m_minOceanDepth != s_iceFloe.m_maxOceanDepth && (oceanDepth < s_iceFloe.m_minOceanDepth || oceanDepth > s_iceFloe.m_maxOceanDepth)) { continue; } float oceanDepthFactor = GetOceanDepthFactor(oceanDepth); float num4 = Random.Range(Seasons.iceFloesScale.Value.x, Seasons.iceFloesScale.Value.y) * oceanDepthFactor; float num5 = PowSquash(Random.Range(Seasons.iceFloesScale.Value.x, Seasons.iceFloesScale.Value.y), 0.6f); float num6 = Random.Range(Seasons.iceFloesScale.Value.x, Seasons.iceFloesScale.Value.y) * oceanDepthFactor; float num7 = s_floeSize.x * num4 / 2f; float num8 = s_floeSize.y * num6 / 2f; float radius = Mathf.Sqrt(num7 * num7 + num8 * num8) + 0.2f; if (!clearAreas.Any((ClearArea area) => IsInside(area, p, radius))) { if (s_iceFloe.m_snapToWater) { p.y = ZoneSystem.instance.m_waterLevel - 2f; } if ((int)mode == 2) { ZNetView.StartGhostInit(); } GameObject val5 = Object.Instantiate(s_iceFloe.m_prefab, p, Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f)); if ((int)mode == 2) { ZNetView.FinishGhostInit(); } ZNetView component = val5.GetComponent(); component.SetLocalScale(new Vector3(num4, num5, num6)); float num9 = Seasons.iceFloesHealth.Value * num4 * num5 * num6; ZDO zDO = component.GetZDO(); zDO.Set(SeasonsVars.s_iceFloeWatermark, true); zDO.Set(SeasonsVars.s_iceFloeMass, component.m_body.mass * PowSquash(Mathf.Sqrt(Mathf.Abs(num4 * num5 * num6)), 0.6f)); zDO.Set(ZDOVars.s_health, num9 + (float)Game.m_worldLevel * num9 * Game.instance.m_worldLevelMineHPMultiplier); if ((int)mode == 2) { spawnedObjects.Add(val5); } clearAreas.Add(new ClearArea(p, GetFloeSize(val5) + 0.5f)); } } Random.state = state; } public static float PowSquash(float x, float gamma = 0.5f) { return Mathf.Pow(Mathf.Max(0f, x), gamma); } public static float GetOceanDepthFactor(float value) { if (value <= 22f) { return 0.8f; } if (value >= 30f) { return 1.3f; } float num = (value - 22f) / 8f; return 0.8f + num * 0.49999994f; } public static bool IsInside(ClearArea area, Vector3 point, float radius) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return Utils.DistanceXZ(area.m_center, point) < area.m_radius + radius; } public static float GetFloeSize(GameObject gameObject) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) Collider componentInChildren = gameObject.GetComponentInChildren(); Bounds bounds; if (Object.op_Implicit((Object)(object)componentInChildren)) { componentInChildren.enabled = false; componentInChildren.enabled = true; bounds = componentInChildren.bounds; float x = ((Bounds)(ref bounds)).size.x; bounds = componentInChildren.bounds; float num = x * ((Bounds)(ref bounds)).size.x / 4f; bounds = componentInChildren.bounds; float z = ((Bounds)(ref bounds)).size.z; bounds = componentInChildren.bounds; return Mathf.Sqrt(num + z * ((Bounds)(ref bounds)).size.z / 4f); } Renderer componentInChildren2 = s_iceFloe.m_prefab.GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren2)) { componentInChildren2.enabled = false; componentInChildren2.enabled = true; bounds = componentInChildren2.bounds; float x2 = ((Bounds)(ref bounds)).size.x; bounds = componentInChildren2.bounds; float num2 = x2 * ((Bounds)(ref bounds)).size.x / 4f; bounds = componentInChildren2.bounds; float z2 = ((Bounds)(ref bounds)).size.z; bounds = componentInChildren2.bounds; return Mathf.Sqrt(num2 + z2 * ((Bounds)(ref bounds)).size.z / 4f); } return 5.8f; } private static void RemoveObject(ZDO zdo, bool force = false) { if (zdo == null || !zdo.IsValid()) { return; } if (!zdo.IsOwner()) { if (!force && !ZNet.instance.IsServer()) { return; } zdo.SetOwner(ZDOMan.GetSessionID()); } if (ZNetScene.instance.m_instances.TryGetValue(zdo, out var value)) { ZNetScene.instance.Destroy(((Component)value).gameObject); } else { ZDOMan.instance.DestroyZDO(zdo); } } private static void LogFloeState(object log) { if (Seasons.logFloes.Value) { Seasons.LogInfo(log); } } } public static class CharacterExtentions_FrozenOceanSliding { private struct SlideStatus { public Vector3 m_iceSlipVelocity; public float m_slip; } [HarmonyPatch(typeof(Character), "OnDestroy")] public static class Character_OnDestroy_WaterVariantControllerInit { private static void Prefix(Character __instance) { __instance.StopIceSliding(); } } [HarmonyPatch(typeof(Player), "SetControls")] public static class Player_SetControls_FrozenOceanSlippery { private static void Prefix(Player __instance, bool run) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (Seasons.frozenOceanSlipperiness.Value != 0f && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && ((Character)(object)__instance).IsOnIce() && !run && ((Character)__instance).m_run) { ((Character)(object)__instance).StartIceSliding(((Character)__instance).m_currentVel, checkMagnitude: false, checkRunning: false); } } } [HarmonyPatch(typeof(Character), "SetRun")] public static class Character_SetRun_FrozenOceanSlippery { private static void Prefix(Character __instance, bool run, ZNetView ___m_nview) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (Seasons.frozenOceanSlipperiness.Value != 0f && __instance.IsOnIce() && ___m_nview.IsValid() && ___m_nview.IsOwner() && !run && __instance.m_run) { __instance.StartIceSliding(__instance.m_currentVel, checkMagnitude: false, checkRunning: false); } } } [HarmonyPatch(typeof(Character), "UpdateGroundContact")] public static class Character_UpdateGroundContact_FrozenOceanSlippery { private struct SlideState { public bool HasValue; public float AirAltitude; public Vector3 BodyVelocity; } [HarmonyPatch(typeof(Character), "SyncVelocity")] public static class Character_SyncVelocity_FrozenOceanSlippery { private static void Prefix(Character __instance) { CheckForSlide(__instance); } } private static readonly Dictionary m_characterSlideVelocity = new Dictionary(64); public static void CheckForSlide(Character characterSyncVelocity) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)characterSyncVelocity == (Object)null) && m_characterSlideVelocity.Count != 0 && m_characterSlideVelocity.TryGetValue(characterSyncVelocity, out var value)) { m_characterSlideVelocity.Remove(characterSyncVelocity); characterSyncVelocity.StartIceSliding(value, checkMagnitude: true); } } private static void Prefix(Character __instance, ZNetView ___m_nview, float ___m_maxAirAltitude, ref SlideState __state) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) __state = default(SlideState); if (Seasons.frozenOceanSlipperiness.Value != 0f && !((Object)(object)___m_nview == (Object)null) && ___m_nview.IsValid() && ___m_nview.IsOwner()) { Vector3 position = ((Component)__instance).transform.position; __state.HasValue = true; __state.AirAltitude = Mathf.Max(0f, ___m_maxAirAltitude - position.y); __state.BodyVelocity = __instance.m_body.linearVelocity; } } private static void Postfix(Character __instance, float ___m_maxAirAltitude, SlideState __state) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (__state.HasValue && !(__state.AirAltitude <= 1f) && !(Seasons.frozenOceanSlipperiness.Value <= 0f)) { float y = ((Component)__instance).transform.position.y; if (___m_maxAirAltitude == y && __instance.IsOnIce()) { m_characterSlideVelocity[__instance] = __state.BodyVelocity; } } } } [HarmonyPatch(typeof(Player), "UpdateDodge")] public static class Player_UpdateDodge_FrozenOceanSlippery { private static bool m_initiateSlide; private static Vector3 m_bodyVelocity = Vector3.zero; [HarmonyPriority(800)] private static void Prefix(Player __instance, bool ___m_inDodge, ref bool __state) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (m_initiateSlide && !___m_inDodge && ((Character)(object)__instance).IsOnIce()) { ((Character)(object)__instance).StartIceSliding(m_bodyVelocity); } __state = Seasons.frozenOceanSlipperiness.Value > 0f && ___m_inDodge && (Object)(object)__instance == (Object)(object)Player.m_localPlayer; } private static void Postfix(Player __instance, bool ___m_inDodge, ref bool __state) { //IL_002a: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) m_initiateSlide = Seasons.frozenOceanSlipperiness.Value > 0f && ___m_inDodge && (Object)(object)__instance == (Object)(object)Player.m_localPlayer; Vector3 queuedDodgeDir = __instance.m_queuedDodgeDir; Vector3 linearVelocity = ((Character)__instance).m_body.linearVelocity; m_bodyVelocity = queuedDodgeDir * ((Vector3)(ref linearVelocity)).magnitude; if (__state && !___m_inDodge && ((Character)(object)__instance).IsOnIce()) { ((Character)(object)__instance).StartIceSliding(m_bodyVelocity); } } } [HarmonyPatch(typeof(Character), "ApplyGroundForce")] public static class Character_ApplyGroundForce_FrozenOceanSlippery { private static void Postfix(Character __instance, ZNetView ___m_nview, ref Vector3 vel) { if (charactersSlides.ContainsKey(__instance)) { if (Seasons.frozenOceanSlipperiness.Value == 0f || !___m_nview.IsValid() || !___m_nview.IsOwner()) { __instance.StopIceSliding(); } else { __instance.UpdateIceSliding(ref vel); } } } } [HarmonyPatch(typeof(Character), "UpdateBodyFriction")] public static class Character_UpdateBodyFriction_FrozenOceanSurface { private static void Postfix(Character __instance, CapsuleCollider ___m_collider) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Invalid comparison between Unknown and I4 if (__instance.IsOnIce()) { PhysicsMaterial material = ((Collider)___m_collider).material; if (material.staticFriction != 0.1f) { material.staticFriction = 0.1f; } if (material.dynamicFriction != 0.1f) { material.dynamicFriction = 0.1f; } if ((int)material.frictionCombine != 2) { material.frictionCombine = (PhysicsMaterialCombine)2; } } } } private static readonly Dictionary charactersSlides = new Dictionary(); public static bool IsOnIce(this Character character) { if (!ZoneSystemVariantController.IsWaterSurfaceFrozen()) { return false; } if (!character.IsOnGround()) { return false; } Collider lastGroundCollider = character.GetLastGroundCollider(); if ((Object)(object)lastGroundCollider == (Object)null) { return false; } return ((Object)lastGroundCollider).name == "IceSurface"; } public static void StartIceSliding(this Character character, Vector3 currentVel, bool checkMagnitude = false, bool checkRunning = true) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!(Seasons.frozenOceanSlipperiness.Value <= 0f) && (!checkRunning || !character.IsRunning())) { SlideStatus valueSafe = GeneralExtensions.GetValueSafe(charactersSlides, character); valueSafe.m_slip = 1f; if (!checkMagnitude || !(((Vector3)(ref valueSafe.m_iceSlipVelocity)).magnitude > ((Vector3)(ref currentVel)).magnitude)) { valueSafe.m_iceSlipVelocity = Vector3.ClampMagnitude(currentVel, 10f); charactersSlides[character] = valueSafe; } } } public static void UpdateIceSliding(this Character character, ref Vector3 currentVel) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) SlideStatus value = charactersSlides[character]; if (value.m_slip > 0f && (character.IsOnIce() || !character.IsOnGround())) { currentVel = Vector3.Lerp(currentVel, value.m_iceSlipVelocity, value.m_slip); float num = (character.IsOnGround() ? (Time.fixedDeltaTime / 2f / Mathf.Abs(Seasons.frozenOceanSlipperiness.Value)) : Time.fixedDeltaTime); value.m_slip = Mathf.MoveTowards(value.m_slip, 0f, num); charactersSlides[character] = value; } else { character.StopIceSliding(); } } public static void StopIceSliding(this Character character) { charactersSlides.Remove(character); } } [HarmonyPatch(typeof(Heightmap), "GetBiomeColor", new Type[] { typeof(Biome) })] public static class Heightmap_GetBiomeColor_TerrainColor { public static bool overrideColor; public static bool overrideSeason; public static Seasons.Season seasonOverride; private static Color GetColorWithoutOverride(Heightmap heightmap, float ix, float iy) { //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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) bool flag = overrideColor; overrideColor = false; Color biomeColor = heightmap.GetBiomeColor(ix, iy); if (flag) { overrideColor = true; } return biomeColor; } private static Color GetColorWithoutOverride(Biome biome) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) bool flag = overrideColor; overrideColor = false; Color result = Color32.op_Implicit(Heightmap.GetBiomeColor(biome)); if (flag) { overrideColor = true; } return result; } private static Color GetColorWithSeasonOverride(Seasons.Season season, Heightmap heightmap, float ix, float iy) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) bool flag = overrideColor; bool flag2 = overrideSeason; Seasons.Season season2 = seasonOverride; overrideColor = true; overrideSeason = true; seasonOverride = season; Color biomeColor = heightmap.GetBiomeColor(ix, iy); overrideSeason = flag2; seasonOverride = season2; overrideColor = flag; return biomeColor; } private static Color GetColorWithSeasonOverride(Seasons.Season season, Biome biome) { //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_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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) bool flag = overrideColor; bool flag2 = overrideSeason; Seasons.Season season2 = seasonOverride; overrideColor = true; overrideSeason = true; seasonOverride = season; Color result = Color32.op_Implicit(Heightmap.GetBiomeColor(biome)); overrideSeason = flag2; seasonOverride = season2; overrideColor = flag; return result; } public static Color GetOriginalColor(Heightmap heightmap, float ix, float iy) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return GetColorWithoutOverride(heightmap, ix, iy); } public static Color GetOriginalColor(Biome biome) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return GetColorWithoutOverride(biome); } public static Color GetSeasonalColor(Seasons.Season season, Biome biome) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) return GetColorWithSeasonOverride(season, biome); } public static Color GetSeasonalColor(Seasons.Season season, Heightmap heightmap, float ix, float iy) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) return GetColorWithSeasonOverride(season, heightmap, ix, iy); } public static bool HasBiomeOverride(Biome biome, Seasons.Season season, out Biome overridedBiome) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) overridedBiome = (Biome)0; Dictionary value; return SeasonState.seasonBiomeSettings.SeasonalBiomeColorOverride.TryGetValue(biome, out value) && value.TryGetValue(season, out overridedBiome); } [HarmonyPriority(800)] private static void Prefix(ref Biome biome, ref Biome __state) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected I4, but got Unknown __state = (Biome)0; if (overrideColor && SeasonState.IsActive && Seasons.UseTextureControllers() && HasBiomeOverride(biome, overrideSeason ? seasonOverride : Seasons.seasonState.GetCurrentSeason(), out var overridedBiome)) { __state = biome; biome = (Biome)(int)overridedBiome; } } [HarmonyPriority(800)] private static void Postfix(ref Biome biome, Biome __state) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected I4, but got Unknown if ((int)__state != 0 && overrideColor && SeasonState.IsActive && Seasons.UseTextureControllers()) { biome = (Biome)(int)__state; } } } [HarmonyPatch(typeof(Heightmap), "GetBiomeColor", new Type[] { typeof(float), typeof(float) })] public static class Heightmap_GetBiomeColor_BiomesEdgeFix { [HarmonyPriority(800)] private static void Postfix(Heightmap __instance, float ix, float iy, ref Color __result) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) if (Seasons.plainsSwampBorderFix.Value && Heightmap_GetBiomeColor_TerrainColor.overrideColor && SeasonState.IsActive && Seasons.UseTextureControllers()) { if (__instance.IsBiomeEdge() && 0f < __result.r && __result.r < 1f && 0f < __result.a && __result.a < 1f) { __result = new Color(0f, __result.g, __result.r, __result.a); } if (Seasons.seasonState.GetCurrentDay() == Seasons.seasonState.GetDaysInSeason() && Seasons.lastDayTerrainFactor.Value != 0f) { __result = Color.Lerp(__result, Heightmap_GetBiomeColor_TerrainColor.GetSeasonalColor(Seasons.seasonState.GetNextSeason(), __instance, ix, iy), Seasons.lastDayTerrainFactor.Value); } else if (Seasons.seasonState.GetCurrentDay() == 1 && Seasons.firstDayTerrainFactor.Value != 0f) { __result = Color.Lerp(__result, Heightmap_GetBiomeColor_TerrainColor.GetSeasonalColor(Seasons.seasonState.GetPreviousSeason(), __instance, ix, iy), Seasons.firstDayTerrainFactor.Value); } } } } [HarmonyPatch(typeof(Heightmap), "RebuildRenderMesh")] public static class Heightmap_RebuildRenderMesh_TerrainColor { [HarmonyPriority(800)] private static void Prefix() { Heightmap_GetBiomeColor_TerrainColor.overrideColor = SeasonState.IsActive && Seasons.UseTextureControllers(); } [HarmonyPriority(800)] private static void Postfix() { Heightmap_GetBiomeColor_TerrainColor.overrideColor = false; } } [HarmonyPatch(typeof(WaterVolume), "Awake")] public static class WaterVolume_Awake_WaterState { [HarmonyPriority(0)] private static void Postfix(WaterVolume __instance) { if (Seasons.UseTextureControllers() && SeasonState.IsActive && __instance.m_useGlobalWind && !((Object)(object)ZoneSystemVariantController.Instance == (Object)null) && !ZoneSystemVariantController.waterStates.ContainsKey(__instance)) { ZoneSystemVariantController.waterStates.Add(__instance, new ZoneSystemVariantController.WaterState(__instance)); ZoneSystemVariantController.Instance.waterVolumesCheckFloes.Add(__instance); } } } [HarmonyPatch(typeof(WaterVolume), "OnEnable")] public static class WaterVolume_OnEnable_WaterState { [HarmonyPriority(0)] private static void Postfix(WaterVolume __instance) { if (Seasons.UseTextureControllers() && SeasonState.IsActive && ZoneSystemVariantController.waterStates.ContainsKey(__instance)) { ZoneSystemVariantController.UpdateWater(__instance, ZoneSystemVariantController.waterStates[__instance]); } } } [HarmonyPatch(typeof(WaterVolume), "OnDisable")] public static class WaterVolume_OnDisable_WaterState { [HarmonyPriority(0)] private static void Postfix(WaterVolume __instance) { if (Seasons.UseTextureControllers() && SeasonState.IsActive && ZoneSystemVariantController.waterStates.ContainsKey(__instance)) { ZoneSystemVariantController.UpdateWater(__instance, ZoneSystemVariantController.waterStates[__instance], revertState: true); } } } [HarmonyPatch(typeof(WaterVolume), "OnDestroy")] public static class WaterVolume_OnDestroy_WaterState { [HarmonyPriority(0)] private static void Postfix(WaterVolume __instance) { if (Seasons.UseTextureControllers() && SeasonState.IsActive && ZoneSystemVariantController.waterStates.ContainsKey(__instance)) { ZoneSystemVariantController.waterStates.Remove(__instance); } } } [HarmonyPatch(typeof(WaterVolume), "UpdateWaterTime")] public static class WaterVolume_UpdateWaterTime_WaterVariantControllerInit { [HarmonyPriority(0)] private static void Postfix() { if (Seasons.UseTextureControllers() && SeasonState.IsActive && ZoneSystemVariantController.IsWaterSurfaceFrozen()) { WaterVolume.s_waterTime = 0f; } } } [HarmonyPatch(typeof(AudioMan), "FindAverageOceanPoint")] public static class AudioMan_FindAverageOceanPoint_DisableOceanSounds { private static bool Prefix() { return !ZoneSystemVariantController.IsWaterSurfaceFrozen(); } } [HarmonyPatch(typeof(FootStep), "GetGroundMaterial")] public static class FootStep_GetGroundMaterial_FrozenOceanFootstep { private static bool Prefix(Character character, ref GroundMaterial __result) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 if ((Object)(object)character == (Object)null || (Object)(object)character != (Object)(object)Player.m_localPlayer) { return true; } if (!character.IsOnIce()) { return true; } __result = (GroundMaterial)(((int)Player.m_localPlayer.GetCurrentBiome() == 256) ? 1 : 16); return false; } } [HarmonyPatch(typeof(MusicMan), "GetEnvironmentMusic")] public static class MusicMan_GetEnvironmentMusic_FrozenOceanNightMusic { private const string frozenOceanMusic = "frozen ocean"; private static void Postfix(MusicMan __instance, ref NamedMusic __result) { if (!Seasons.enableNightMusicOnFrozenOcean.Value || (__result != null && __result.m_name == "home") || !ZoneSystemVariantController.LocalPlayerIsOnFrozenOcean() || !EnvMan.IsNight()) { return; } NamedMusic val = __instance.FindMusic("frozen ocean"); if (val == null) { NamedMusic val2 = __instance.FindMusic("intro"); if (val2 != null) { val = JsonUtility.FromJson(JsonUtility.ToJson((object)val2)); val.m_name = "frozen ocean"; val.m_ambientMusic = true; val.m_loop = Settings.ContinousMusic; val.m_volume = 0.2f; val.m_fadeInTime = 10f; __instance.m_music.Add(val); } } if (val != null) { __result = val; } } } [HarmonyPatch(typeof(EnvMan), "SetEnv")] public static class EnvMan_SetEnv_FrozenOceanWindLoop { private static readonly Dictionary _usedAudioClips = new Dictionary(); public static Dictionary UsedAudioClips { get { if (_usedAudioClips.Count > 0 || (Object)(object)EnvMan.instance == (Object)null) { return _usedAudioClips; } foreach (EnvSetup environment in EnvMan.instance.m_environments) { if ((Object)(object)environment.m_ambientLoop != (Object)null && !_usedAudioClips.ContainsKey(((Object)environment.m_ambientLoop).name)) { _usedAudioClips.Add(((Object)environment.m_ambientLoop).name, environment.m_ambientLoop); } } return _usedAudioClips; } } public static void Prefix(EnvSetup env, ref AudioClip __state) { if (ZoneSystemVariantController.LocalPlayerIsOnFrozenOcean()) { __state = env.m_ambientLoop; if ((Object)(object)env.m_ambientLoop != (Object)(object)UsedAudioClips["Wind_BlowingLoop3"]) { env.m_ambientLoop = UsedAudioClips["Wind_ColdLoop3"]; } } } public static void Postfix(EnvSetup env, AudioClip __state) { if (ZoneSystemVariantController.LocalPlayerIsOnFrozenOcean()) { env.m_ambientLoop = __state; } } } [HarmonyPatch(typeof(Leviathan), "FixedUpdate")] public static class Leviathan_FixedUpdate_FrozenOceanLeviathan { private static bool Prefix(Leviathan __instance, Rigidbody ___m_body, ZNetView ___m_nview) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (Seasons.IsIgnoredPosition(((Component)__instance).transform.position) || !ZoneSystemVariantController.IsWaterSurfaceFrozen()) { return true; } if (___m_nview.IsValid() && ___m_nview.IsOwner()) { Vector3 position = ___m_body.position; position.y = Floating.GetLiquidLevel(___m_body.position, 0f, (LiquidType)10) - 5f; ___m_body.position = position; } return false; } } [HarmonyPatch(typeof(Leviathan), "OnHit")] public static class Leviathan_OnHit_FrozenOceanLeviathan { private static bool Prefix(Leviathan __instance) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return Seasons.IsIgnoredPosition(((Component)__instance).transform.position) || !ZoneSystemVariantController.IsWaterSurfaceFrozen(); } } [HarmonyPatch(typeof(Player), "TeleportTo")] public static class Player_TeleportTo_FrozenOceanMinimapTeleportation { private static void Postfix(bool __result, ref Vector3 ___m_teleportTargetPos) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (__result && ZoneSystemVariantController.IsWaterSurfaceFrozen() && ___m_teleportTargetPos.y == 0f) { ___m_teleportTargetPos = new Vector3(___m_teleportTargetPos.x, ___m_teleportTargetPos.y + ZoneSystemVariantController.WaterLevel, ___m_teleportTargetPos.z); } } } [HarmonyPatch(typeof(WaterVolume), "CalcWave", new Type[] { typeof(Vector3), typeof(float), typeof(float), typeof(float) })] public static class WaterVolume_CalcWave_FrozenOceanNoWaves { private static bool s_isFrozenOcean; private static void Prefix(ref float __state) { s_isFrozenOcean = ZoneSystemVariantController.IsWaterSurfaceFrozen(); if (s_isFrozenOcean) { __state = WaterVolume.s_globalWindAlpha; WaterVolume.s_globalWindAlpha = 0f; } } private static void Postfix(float __state) { if (s_isFrozenOcean) { WaterVolume.s_globalWindAlpha = __state; } } } [HarmonyPatch(typeof(Ship), "Start")] public static class Ship_Start_FrozenOceanShip { private static void Postfix(Ship __instance) { ((MonoBehaviour)__instance).StartCoroutine(ZoneSystemVariantController.CheckIfShipBelowSurface(__instance)); } } [HarmonyPatch(typeof(Character), "Awake")] public static class Character_Awake_FrozenOceanCharacter { private static void Postfix(Character __instance) { if (ZoneSystemVariantController.IsWaterSurfaceFrozen()) { ZoneSystemVariantController.CheckIfCharacterBelowSurface(__instance); } } } [HarmonyPatch(typeof(ItemDrop), "OnPlayerDrop")] public static class ItemDrop_OnPlayerDrop_FrozenOceanFish { private static void Postfix(ItemDrop __instance) { ZoneSystemVariantController.MarkPlayerDroppedFish(__instance); } } [HarmonyPatch(typeof(Fish), "Start")] public static class Fish_Start_FrozenOcean { private static void Postfix(Fish __instance) { if (ZoneSystemVariantController.IsWaterSurfaceFrozen()) { ZoneSystemVariantController instance = ZoneSystemVariantController.Instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(ZoneSystemVariantController.CheckSingleFishPosition(__instance)); } } } } [HarmonyPatch(typeof(Fish), "SetVisible")] public static class Fish_SetVisible_CheckPositionIfBecameVisible { private static void Prefix(Fish __instance, ref bool __state) { __state = __instance.m_lodVisible; } private static void Postfix(Fish __instance, bool __state) { if (ZoneSystemVariantController.IsWaterSurfaceFrozen() && !((Object)(object)__instance.m_lodGroup == (Object)null) && __state != __instance.m_lodVisible && __instance.m_lodVisible) { ZoneSystemVariantController instance = ZoneSystemVariantController.Instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(ZoneSystemVariantController.CheckSingleFishPosition(__instance)); } } } } [HarmonyPatch(typeof(Fish), "ConsiderJump")] public static class Fish_ConsiderJump_FrozenOceanFishNoJumps { private static void Prefix(ref float ___m_JumpHeightStrength, ref float __state) { if (ZoneSystemVariantController.IsWaterSurfaceFrozen()) { __state = ___m_JumpHeightStrength; ___m_JumpHeightStrength = 0f; } } private static void Postfix(ref float ___m_JumpHeightStrength, float __state) { if (ZoneSystemVariantController.IsWaterSurfaceFrozen()) { ___m_JumpHeightStrength = __state; } } } [HarmonyPatch(typeof(Fish), "CustomFixedUpdate")] public static class Fish_CustomFixedUpdate_CheckPosition { private static void Postfix(Fish __instance) { if (ZoneSystemVariantController.IsWaterSurfaceFrozen() && !__instance.m_lodVisible && !ZoneSystemVariantController.ShouldThrottleFishIceCheck(__instance)) { ZoneSystemVariantController.CheckIfFishAboveSurface(__instance); } } } [HarmonyPatch(typeof(WaterVolume), "CalcWave", new Type[] { typeof(Vector3), typeof(float), typeof(Vector4), typeof(float), typeof(float) })] public static class WaterVolume_CalcWave_FrozenOceanPreventWaves { private static void Prefix(ref float waterTime, ref float __state) { if (ZoneSystemVariantController.IsWaterSurfaceFrozen()) { __state = waterTime; waterTime = 0f; } } private static void Postfix(ref float waterTime, float __state) { if (ZoneSystemVariantController.IsWaterSurfaceFrozen()) { waterTime = __state; } } } [HarmonyPatch(typeof(ZoneSystem), "IsBlocked")] public static class ZoneSystem_IsBlocked_VegetationPlacing { private static bool Prefix(Vector3 p, int ___m_blockRayMask, ref bool __result) { //IL_003e: 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_0050: 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) if (!Seasons.UseTextureControllers()) { return true; } if (!SeasonState.IsActive) { return true; } if (!ZoneSystemVariantController.IsWaterSurfaceFrozen()) { return true; } Vector3 val = p; val.y += 2000f; int num = Physics.RaycastNonAlloc(val, Vector3.down, ZoneSystemVariantController.Instance.rayHits, 10000f, ___m_blockRayMask); __result = false; for (int i = 0; i < num; i++) { if (!((Object)(object)((RaycastHit)(ref ZoneSystemVariantController.Instance.rayHits[i])).collider != (Object)null) || !(((Object)((RaycastHit)(ref ZoneSystemVariantController.Instance.rayHits[i])).collider).name == "IceSurface")) { __result = true; break; } } return false; } } [HarmonyPatch(typeof(Floating), "CustomFixedUpdate")] public static class Floating_CustomFixedUpdate_IceFloeRotation { private static readonly Vector3[] positions = (Vector3[])(object)new Vector3[4]; private static void AddWaveForce(Floating floating, float fixedDeltaTime) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) floating.m_body.WakeUp(); Vector3[] array = positions; foreach (Vector3 val in array) { float num = val.y - Floating.GetLiquidLevel(val, 1f, (LiquidType)10); float num2 = 0.5f * Mathf.Clamp01(Mathf.Abs(num / 4f)) * (fixedDeltaTime * 50f) * Mathf.Abs(num); Vector3 val2 = ((num < 0f) ? (Vector3.up * (num2 * 0.6f)) : (Vector3.down * num2)); floating.m_body.AddForceAtPosition(val2 * 0.02f * floating.m_body.mass * 0.25f, val, (ForceMode)1); } } private static float Dampen(float value) { return value / (1f + Mathf.Abs(value)); } private static bool Prefix(Floating __instance, float fixedDeltaTime) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)GameCamera.instance)) { ZNetView nview = __instance.m_nview; if (nview != null && nview.IsValid()) { ZDO zDO = nview.GetZDO(); if (((zDO != null) ? new int?(zDO.GetPrefab()) : ((int?)null)) == ZoneSystemVariantController.s_iceFloePrefab && Object.op_Implicit((Object)(object)__instance.m_body)) { ZSyncTransform component = ((Component)__instance).GetComponent(); bool flag = Utils.DistanceXZ(((Component)GameCamera.instance).transform.position, ((Component)__instance).transform.position) < ZoneSystemVariantController.s_waterDistance; component.m_syncBodyVelocity = flag || !__instance.HaveLiquidLevel(); if (component.m_syncPosition != (component.m_syncPosition = component.m_syncBodyVelocity) && component.m_syncPosition) { component.SyncNow(); } if (!component.m_syncPosition && __instance.HaveLiquidLevel() && !flag) { __instance.m_body.Sleep(); ((Component)__instance).transform.position = new Vector3(((Component)__instance).transform.position.x, ZoneSystemVariantController.WaterLevel + __instance.m_waterLevelOffset + Dampen(__instance.m_waterLevel - ZoneSystemVariantController.WaterLevel), ((Component)__instance).transform.position.z); return false; } if (!nview.IsOwner() || !__instance.HaveLiquidLevel()) { return true; } Vector3 val = Vector4.op_Implicit((WaterVolume.s_globalWindAlpha == 0f) ? WaterVolume.s_globalWind1 : Vector4.Lerp(WaterVolume.s_globalWind1, WaterVolume.s_globalWind2, WaterVolume.s_globalWindAlpha)); Vector3 val2 = Vector3.Cross(val, ((Component)__instance).transform.up); Vector3 worldCenterOfMass = __instance.m_body.worldCenterOfMass; positions[0] = __instance.m_collider.ClosestPoint(worldCenterOfMass + val * 100f); positions[1] = __instance.m_collider.ClosestPoint(worldCenterOfMass - val * 100f); positions[2] = __instance.m_collider.ClosestPoint(worldCenterOfMass + val2 * 100f); positions[3] = __instance.m_collider.ClosestPoint(worldCenterOfMass - val2 * 100f); AddWaveForce(__instance, fixedDeltaTime); return true; } } } return true; } } [HarmonyPatch(typeof(Ship), "CustomFixedUpdate")] public static class Ship_CustomFixedUpdate_FrozenShip { private static void Prefix(ref float ___m_disableLevel, ref float __state) { if (Seasons.UseTextureControllers() && SeasonState.IsActive && ZoneSystemVariantController.IsWaterSurfaceFrozen()) { __state = ___m_disableLevel; ___m_disableLevel -= 2f; } } private static void Postfix(ref float ___m_disableLevel, float __state) { if (Seasons.UseTextureControllers() && SeasonState.IsActive && ZoneSystemVariantController.IsWaterSurfaceFrozen()) { ___m_disableLevel = __state; } } } [HarmonyPatch(typeof(ZoneSystem), "GetGroundHeight", new Type[] { typeof(Vector3) })] public static class ZoneSystem_GetGroundHeight_CheckForIceSurface { public static bool checkForIceSurface; public static int s_terrainRayMask; private static bool Prefix(Vector3 p, ref float __result) { //IL_004a: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) if (!checkForIceSurface) { return true; } checkForIceSurface = false; if (s_terrainRayMask == 0) { s_terrainRayMask = LayerMask.GetMask(new string[2] { "terrain", "Default" }); } __result = p.y; Vector3 val = p; val.y = 6000f; int num = Physics.RaycastNonAlloc(val, Vector3.down, ZoneSystemVariantController.Instance.rayHits, 10000f, s_terrainRayMask); float num2 = 0f; for (int i = 0; i < num; i++) { RaycastHit val2 = ZoneSystemVariantController.Instance.rayHits[i]; if (((Component)((RaycastHit)(ref val2)).collider).gameObject.layer == 0 && ((Object)((RaycastHit)(ref val2)).collider).name == "IceSurface") { num2 = Mathf.Max(((RaycastHit)(ref val2)).point.y, num2); } else if (((Component)((RaycastHit)(ref val2)).collider).gameObject.layer == 11) { num2 = Mathf.Max(((RaycastHit)(ref val2)).point.y, num2); } } if (num2 > 0f) { __result = num2; } return false; } } [HarmonyPatch(typeof(TombStone), "PositionCheck")] public static class TombStone_PositionCheck_FrozenSurfaceCheck { private static void Prefix() { if (Seasons.UseTextureControllers() && SeasonState.IsActive && ZoneSystemVariantController.IsWaterSurfaceFrozen()) { ZoneSystem_GetGroundHeight_CheckForIceSurface.checkForIceSurface = true; } } } [HarmonyPatch(typeof(Player), "UpdateBiome")] public static class Player_UpdateBiome_OnBiomeChange { private static void Prefix(Player __instance, ref Biome __state) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected I4, but got Unknown __state = (Biome)0; if (Seasons.UseTextureControllers() && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && SeasonState.IsActive) { __state = (Biome)(int)__instance.GetCurrentBiome(); } } private static void Postfix(Player __instance, Biome __state) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Seasons.seasonState.OnBiomeChange(__state, __instance.GetCurrentBiome()); } } [HarmonyPatch(typeof(Heightmap), "RebuildRenderMesh")] public static class Heightmap_RebuildRenderMesh_UpdateProtectedHmap { private static void Postfix(Heightmap __instance) { if (Seasons.UseTextureControllers() && SeasonState.IsActive && ZoneSystemVariantController.IsProtectedHeightmap(__instance)) { ZoneSystemVariantController.UpdateTerrainColor(__instance); } } } [HarmonyPatch(typeof(EnvMan), "UpdateEnvironment")] public static class EnvMan_UpdateEnvironment_CheckSnowStormOnBiomeChange { private static void Postfix(EnvMan __instance) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) ZoneSystemVariantController.Instance?.CheckBiomeChanged(__instance.m_currentBiome); } } [HarmonyPatch(typeof(EnvMan), "Awake")] public static class EnvMan_Awake_GetWorldEdge { [HarmonyPriority(0)] [HarmonyAfter(new string[] { "expand_world_size" })] private static void Postfix(EnvMan __instance) { Transform val = ((Component)__instance).transform.Find("WaterPlane").Find("watersurface"); Material sharedMaterial = ((Renderer)((Component)val).GetComponent()).sharedMaterial; ZoneSystemVariantController.s_waterDistance = sharedMaterial.GetFloat("_VisibleMaxDistance"); ZoneSystemVariantController.s_waterEdge = sharedMaterial.GetFloat("_WaterEdge"); ZoneSystemVariantController.s_waterEdgeLocalPlayerState = false; } } [HarmonyPatch(typeof(Player), "OnSpawned")] public static class Player_OnSpawned_CheckForEdgePosition { private static void Postfix(Player __instance) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Player.m_localPlayer != (Object)(object)__instance)) { ZoneSystemVariantController.s_waterEdgeLocalPlayerState = ZoneSystemVariantController.IsBeyondWorldEdge(((Component)__instance).transform.position); } } } [HarmonyPatch(typeof(Player), "EdgeOfWorldKill")] public static class Player_EdgeOfWorldKill_CheckForEdgePosition { private static void Postfix(Player __instance) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Player.m_localPlayer != (Object)(object)__instance) && !((Character)__instance).IsDead() && ZoneSystemVariantController.s_waterEdgeLocalPlayerState != (ZoneSystemVariantController.s_waterEdgeLocalPlayerState = ZoneSystemVariantController.IsBeyondWorldEdge(((Component)__instance).transform.position))) { ZoneSystemVariantController.UpdateWaterState(); } } } public static class ItemNameTokens { [HarmonyPatch(typeof(Player), "Load")] private static class Player_Load_UpdateRegisters { private static void Prefix() { UpdateRegisters(); } } public static readonly Dictionary itemNames = new Dictionary(StringComparer.OrdinalIgnoreCase); public static void UpdateRegisters() { if (!Object.op_Implicit((Object)(object)ObjectDB.instance)) { return; } foreach (GameObject item in ObjectDB.instance.m_items) { if ((Object)(object)item == (Object)null) { continue; } ItemDrop component = item.GetComponent(); if (component == null) { continue; } ItemData itemData = component.m_itemData; if (itemData != null) { SharedData shared = itemData.m_shared; if (shared != null && shared.m_name.StartsWith("$")) { itemNames[((Object)item).name] = shared.m_name; itemNames[shared.m_name] = shared.m_name; } } } } public static string GetItemName(this string input) { return itemNames.GetValueOrDefault(input.Trim(), input); } } public static class StatusEffectHud { public static void EnsureTimeTextRichText() { if ((Object)(object)Hud.instance?.m_statusEffectTemplate == (Object)null) { return; } Transform val = ((Transform)Hud.instance.m_statusEffectTemplate).Find("TimeText"); if (val != null) { TMP_Text component = ((Component)val).GetComponent(); if (component != null) { component.richText = true; } } } } internal static class SummerHeatUtils { internal const float MinSoftHpCap = 0.01f; internal static float ClampPercent(float value) { return Mathf.Clamp(value, 0f, 100f); } internal static float ClampEffect(float value) { return Mathf.Clamp01(value); } internal static float GetNightFactor() { return Mathf.Clamp01(Seasons.summerHeatNightFactor.Value); } internal static float GetMinSoftHpCap() { return Mathf.Clamp(Seasons.summerHeatDamageHealthPerTickMinHealthPercentage.Value, 0.01f, 1f); } internal static float ScaleHeatPercentForTime(float value, bool isDaytime, float nightFactor) { return isDaytime ? value : (value * nightFactor); } internal static float ScaleHeatPercentForTime(float value, bool isDaytime) { return ScaleHeatPercentForTime(value, isDaytime, GetNightFactor()); } } public static class SeasonsVars { public const string s_cropSurvivedWinterDayName = "Seasons_Survived_Winter_Day"; public static int s_cropSurvivedWinterDayHash = StringExtensionMethods.GetStableHashCode("Seasons_Survived_Winter_Day"); public const string s_cropStartedFreezingName = "Seasons_Started_Freezing"; public static int s_cropStartedFreezingHash = StringExtensionMethods.GetStableHashCode("Seasons_Started_Freezing"); public static int s_treeRegrowthHaveGrowSpace = StringExtensionMethods.GetStableHashCode("Seasons_HaveGrowSpace"); public const string s_statusEffectSeasonName = "Season"; public static int s_statusEffectSeasonHash = StringExtensionMethods.GetStableHashCode("Season"); public const string s_statusEffectOverheatName = "Overheat"; public static int s_statusEffectOverheatHash = StringExtensionMethods.GetStableHashCode("Overheat"); public const string s_statusEffectSummerHeatName = "SummerHeat"; public static int s_statusEffectSummerHeatHash = StringExtensionMethods.GetStableHashCode("SummerHeat"); public static int s_iceFloeWatermark = StringExtensionMethods.GetStableHashCode("Seasons_IceFloe"); public static int s_iceFloeMass = StringExtensionMethods.GetStableHashCode("Seasons_IceFloeMass"); public static int s_iceFloesSpawned = StringExtensionMethods.GetStableHashCode("Seasons_IceFloesSpawned"); public static int s_terrainDecultivated = StringExtensionMethods.GetStableHashCode("Seasons_Terrain_Decultivated"); } } namespace Seasons.Controllers { [HarmonyPatch(typeof(Game), "UpdateRespawn")] public static class Game_UpdateRespawn_WaitForTextureCache { public static bool Prefix() { return !TextureCachingController.InProcess; } } public class TextureCachingController : MonoBehaviour { private static TextureCachingController _instance; private SeasonalTextureVariants _texturesVariants; private Coroutine _worker; private static bool _indicatorInitialized; private static string _indicatorText; private static float _indicatorProgress; private static float _indicatorMaxProgress; public static TextureCachingController instance => _instance; public static bool InProcess => (Object)(object)instance != (Object)null && instance._worker != null; public static LoadingIndicator LoadingIndicator => Hud.instance?.m_loadingIndicator; internal static void StartCaching(SeasonalTextureVariants texturesVariants) { ((Component)ZoneSystem.instance).gameObject.AddComponent().Initialize(texturesVariants); } public void Awake() { _instance = this; Seasons.LogInfo("Starting up texture caching process"); } public void Initialize(SeasonalTextureVariants texturesVariants) { _texturesVariants = texturesVariants; SeasonalTexturePrefabCache.SetCurrentTextureVariants(_texturesVariants); _worker = ((MonoBehaviour)this).StartCoroutine(GenerateTextures()); } public static void SetupLoadingIndicator(float maxProgress) { _indicatorProgress = 0f; _indicatorMaxProgress = maxProgress; } public static void UpdateLoadingIndicator(float counter) { if (!Object.op_Implicit((Object)(object)instance)) { return; } _indicatorProgress += counter; if (!((Object)(object)LoadingIndicator == (Object)null)) { if (!_indicatorInitialized) { LoadingIndicator.SetProgress(0f); LoadingIndicator.SetShowProgress(true); LoadingIndicator.SetText(_indicatorText, true); _indicatorInitialized = true; } if (_indicatorMaxProgress != 0f) { LoadingIndicator.SetProgress(Mathf.Clamp01(_indicatorProgress / _indicatorMaxProgress)); } } } public IEnumerator GenerateTextures() { WaitForFixedUpdate wait = new WaitForFixedUpdate(); yield return wait; Seasons.LogInfo("Setting up loading indicator"); _indicatorProgress = 0f; _indicatorText = "$seasons_loadscreen_preparing"; yield return (object)new WaitForSeconds(0.5f); yield return ((MonoBehaviour)this).StartCoroutine(SeasonalTexturePrefabCache.FillWithGameData()); yield return wait; LoadingIndicator loadingIndicator = LoadingIndicator; if (loadingIndicator != null && loadingIndicator.IsVisible) { LoadingIndicator.SetProgress(1f); LoadingIndicator.SetText("$seasons_loadscreen_saving", true); } yield return wait; yield return ((MonoBehaviour)this).StartCoroutine(_texturesVariants.SaveCacheOnDisk()); yield return wait; LoadingIndicator loadingIndicator2 = LoadingIndicator; if (loadingIndicator2 != null && loadingIndicator2.IsVisible) { LoadingIndicator.SetShowProgress(false); } yield return wait; if (_texturesVariants.Initialized()) { SeasonState.InitializeTextureControllers(); } else { Seasons.LogInfo("Missing textures variants"); } _worker = null; } public void OnDestroy() { if (_worker != null) { ((MonoBehaviour)this).StopCoroutine(_worker); } _instance = null; _indicatorInitialized = false; _indicatorText = ""; _indicatorProgress = 0f; _indicatorMaxProgress = 0f; } } } namespace Seasons.Compatibility { public static class HoneyPlusCompat { [HarmonyPatch(typeof(CraftingStation), "CheckUsable")] public static class CraftingStation_CheckUsable_PreventPickingHoneyFromApiaryInWinter { private static void Postfix(CraftingStation __instance, Player player, bool showMessage, ref bool __result) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (isEnabled && __result && !Seasons.IsProtectedPosition(((Component)__instance).transform.position) && __instance.m_name == "$custom_piece_apiary" && Seasons.seasonState.GetBeehiveProductionMultiplier() == 0f && !player.NoCostCheat()) { if (showMessage) { ((Character)player).Message((MessageType)2, "$piece_beehive_sleep", 0, (Sprite)null); } __result = false; } } } public const string GUID = "OhhLoz-HoneyPlus"; public static PluginInfo plugin; public static Assembly assembly; public static bool isEnabled; public static void CheckForCompatibility() { isEnabled = Chainloader.PluginInfos.TryGetValue("OhhLoz-HoneyPlus", out plugin); if (isEnabled && (object)assembly == null) { assembly = Assembly.GetAssembly(((object)plugin.Instance).GetType()); } } } public static class MyLittleUICompat { public const string GUID = "shudnal.MyLittleUI"; private const string MapStatusEffectElementGroup = "Status effects - Map - List element"; private const string CustomElementEnabledName = "Custom element enabled"; public static PluginInfo plugin; public static bool isEnabled; public static void CheckForCompatibility() { isEnabled = Chainloader.PluginInfos.TryGetValue("shudnal.MyLittleUI", out plugin); } public static bool IsMapStatusEffectListElementEnabled() { if (!isEnabled) { CheckForCompatibility(); } if (isEnabled) { PluginInfo obj = plugin; object obj2; if (obj == null) { obj2 = null; } else { BaseUnityPlugin instance = obj.Instance; obj2 = ((instance != null) ? instance.Config : null); } if (obj2 != null) { try { ConfigEntry val = default(ConfigEntry); return plugin.Instance.Config.TryGetEntry("Status effects - Map - List element", "Custom element enabled", ref val) && val.Value; } catch (Exception arg) { Seasons.LogWarning(string.Format("Failed to read My Little UI config '{0}/{1}'\n{2}", "Status effects - Map - List element", "Custom element enabled", arg)); return false; } } } return false; } } public static class EWDCompat { [HarmonyPatch] public static class EWD_EnvironmentManager_Initialize_ResetWorldState { public static MethodBase target; public static bool Prepare(MethodBase original) { if (!TryGetEnvironmentManagerType()) { return false; } if ((object)target == null) { target = AccessTools.Method(environmentManagerType, "Initialize", Type.EmptyTypes, (Type[])null); } if (target == null) { return false; } if (original == null) { Seasons.LogInfo("ExpandWorldData.EnvironmentManager:Initialize method is patched to reset Seasons EWD world state"); } return true; } public static MethodBase TargetMethod() { return target; } public static void Prefix() { ResetWorldState(); } } [HarmonyPatch] public static class EWD_EnvironmentManager_Set_ReapplySeasonEnvironments { public static MethodBase target; public static bool Prepare(MethodBase original) { if (!TryGetEnvironmentManagerType()) { return false; } if ((object)target == null) { target = AccessTools.Method(environmentManagerType, "Set", new Type[1] { typeof(string) }, (Type[])null); } if (target == null) { return false; } if (original == null) { Seasons.LogInfo("ExpandWorldData.EnvironmentManager:Set method is patched to reapply Seasons environments after EWD environment changes"); } return true; } public static MethodBase TargetMethod() { return target; } public static void Postfix() { ReapplySeasonEnvironmentsAfterEwdUpdate(); } } [HarmonyPatch] public static class EWD_BiomeManager_SetupBiomeEnvs_RegisterAuthoritativeSetup { public static MethodBase target; public static bool Prepare(MethodBase original) { if (!TryGetBiomeManagerType()) { return false; } if ((object)target == null) { target = AccessTools.Method(biomeManagerType, "SetupBiomeEnvs", new Type[1] { typeof(List) }, (Type[])null); } if (target == null) { return false; } if (original == null) { Seasons.LogInfo("ExpandWorldData.BiomeManager:SetupBiomeEnvs method is patched to preserve EWD biome entries while applying seasonal rules"); } return true; } public static MethodBase TargetMethod() { return target; } public static void Postfix() { CaptureEwdBiomeSetup(); } } [HarmonyPatch(typeof(EnvMan), "GetAvailableEnvironments")] public static class EnvMan_GetAvailableEnvironments_ApplySeasonalRulesAfterEWD { [HarmonyPriority(0)] [HarmonyAfter(new string[] { "expand_world_data" })] public static void Postfix(Biome biome, ref List __result) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (__result != null && ShouldApplySeasonalRulesToAvailableEnvironments()) { __result = SeasonState.ApplySeasonBiomeEnvironmentRules(biome, __result); } } } public const string GUID = "expand_world_data"; public static PluginInfo plugin; public static Assembly assembly; public static bool isEnabled; private static Type environmentManagerType; private static Type biomeManagerType; private static FieldInfo environmentManagerInitializedField; private static FieldInfo biomeToDisplayNameField; private static bool seasonsWorldInitialized; private static bool ewdBiomeSetupAppliedLast; public static void CheckForCompatibility() { isEnabled = Chainloader.PluginInfos.TryGetValue("expand_world_data", out plugin); if (isEnabled && (object)assembly == null) { assembly = Assembly.GetAssembly(((object)plugin.Instance).GetType()); } } public static void ResetWorldState() { seasonsWorldInitialized = false; ewdBiomeSetupAppliedLast = false; } public static void MarkWorldInitialized() { seasonsWorldInitialized = true; } public static void OnSeasonsBiomeSetupApplied() { if (isEnabled) { ewdBiomeSetupAppliedLast = false; } } public static bool ShouldApplySeasonalRulesToAvailableEnvironments() { return isEnabled && seasonsWorldInitialized && ewdBiomeSetupAppliedLast; } public static bool TryGetBiomeDisplayName(Biome biome, out string displayName) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) displayName = null; if (!TryGetBiomeManagerType()) { return false; } if ((object)biomeToDisplayNameField == null) { biomeToDisplayNameField = AccessTools.Field(biomeManagerType, "BiomeToDisplayName"); } return biomeToDisplayNameField?.GetValue(null) is Dictionary dictionary && dictionary.TryGetValue(biome, out displayName) && !string.IsNullOrWhiteSpace(displayName); } private static bool TryGetEnvironmentManagerType() { if (environmentManagerType != null) { return true; } if (assembly == null && Chainloader.PluginInfos.TryGetValue("expand_world_data", out var value)) { assembly = Assembly.GetAssembly(((object)value.Instance).GetType()); } environmentManagerType = assembly?.GetType("ExpandWorldData.EnvironmentManager"); return environmentManagerType != null; } private static bool TryGetBiomeManagerType() { if (biomeManagerType != null) { return true; } if (assembly == null && Chainloader.PluginInfos.TryGetValue("expand_world_data", out var value)) { assembly = Assembly.GetAssembly(((object)value.Instance).GetType()); } biomeManagerType = assembly?.GetType("ExpandWorldData.BiomeManager"); return biomeManagerType != null; } private static bool IsEnvironmentManagerInitialized() { if (!TryGetEnvironmentManagerType()) { return false; } if ((object)environmentManagerInitializedField == null) { environmentManagerInitializedField = AccessTools.Field(environmentManagerType, "Initialized"); } object obj = environmentManagerInitializedField?.GetValue(null); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } private static void ReapplySeasonEnvironmentsAfterEwdUpdate() { if (seasonsWorldInitialized && IsEnvironmentManagerInitialized() && SeasonState.IsActive) { SeasonState.PrepareForExternalEnvironmentUpdate(); SeasonState.UpdateSeasonEnvironments(); EnvManPatches.settingsUpdated = true; Seasons.LogInfo("Reapplied Seasons environments after Expand World Data environment update."); } } private static void CaptureEwdBiomeSetup() { ewdBiomeSetupAppliedLast = true; if (seasonsWorldInitialized && !((Object)(object)EnvMan.instance == (Object)null)) { SeasonState.RefreshBiomesDefault(forceUpdate: true); EnvMan.instance.m_environmentPeriod = -1L; if (SeasonState.IsActive) { EnvManPatches.settingsUpdated = true; Seasons.LogInfo("Expand World Data biome environment setup registered as authoritative for seasonal weather rules."); } } } } public static class MarketplaceCompat { public const string GUID = "MarketplaceAndServerNPCs"; public static PluginInfo plugin; public static Assembly assembly; public static MethodBase methodDoMapMagic; public static FieldInfo fieldOriginalMapColors; public static bool isEnabled; public static void CheckForCompatibility() { isEnabled = Chainloader.PluginInfos.TryGetValue("MarketplaceAndServerNPCs", out plugin); if (isEnabled && (object)assembly == null) { assembly = Assembly.GetAssembly(((object)plugin.Instance).GetType()); } if (assembly != null) { if ((object)methodDoMapMagic == null) { methodDoMapMagic = AccessTools.Method(assembly.GetType("Marketplace.Modules.TerritorySystem.TerritorySystem_Main_Client"), "DoMapMagic", (Type[])null, (Type[])null); } if (methodDoMapMagic == null) { Seasons.LogInfo("Marketplace.Modules.TerritorySystem.TerritorySystem_Main_Client:DoMapMagic method does not found, there could be incompatibilities in map colors management"); } else if ((object)fieldOriginalMapColors == null) { fieldOriginalMapColors = AccessTools.Field(assembly.GetType("Marketplace.Modules.TerritorySystem.TerritorySystem_Main_Client"), "originalMapColors"); } } } public static void UpdateMap() { if (!isEnabled || methodDoMapMagic == null || fieldOriginalMapColors == null) { return; } try { fieldOriginalMapColors.SetValue(fieldOriginalMapColors, Minimap.instance.m_mapTexture.GetPixels()); } catch (Exception ex) { Seasons.LogInfo("Error while setting TerritorySystem_Main_Client.originalMapColors\n" + ex.ToString()); fieldOriginalMapColors = null; return; } try { methodDoMapMagic.Invoke(methodDoMapMagic, null); } catch (Exception ex2) { Seasons.LogInfo("Error while invoking TerritorySystem_Main_Client.DoMapMagic\n" + ex2.ToString()); methodDoMapMagic = null; } } } public static class EpicLootCompat { [HarmonyPatch] public static class EpicLoot_Adventure_GetAvailableBounties_PreventSerpentsBountyInWinter { public static MethodBase target; public static bool Prepare(MethodBase original) { if (!isEnabled) { return false; } if ((object)target == null) { target = AccessTools.Method(assembly.GetType("EpicLoot.Adventure.Feature.BountiesAdventureFeature"), "AcceptBounty", (Type[])null, (Type[])null); } if (target == null) { return false; } if (original == null) { Seasons.LogInfo("EpicLoot.Adventure.Feature.BountiesAdventureFeature:AcceptBounty method is patched to prevent accepting serpents bounty when water is frozen"); } return true; } public static MethodBase TargetMethod() { return target; } public static bool Prefix(object __1, ref IEnumerator __result) { bool flag = IsSerpent(__1) && ZoneSystemVariantController.IsWaterSurfaceFrozen(); if (flag) { __result = Empty(); } return !flag; } private static IEnumerator Empty() { yield return (object)new WaitForEndOfFrame(); } public static bool IsSerpent(object bountyInfo) { FieldInfo fieldInfo = AccessTools.Field(bountyInfo.GetType(), "Target"); if (fieldInfo == null) { return false; } FieldInfo fieldInfo2 = AccessTools.Field(fieldInfo.GetValue(bountyInfo).GetType(), "MonsterID"); if (fieldInfo2 == null) { return false; } return fieldInfo2.GetValue(fieldInfo.GetValue(bountyInfo)).Equals("Serpent"); } } public const string GUID = "randyknapp.mods.epicloot"; public static PluginInfo plugin; public static Assembly assembly; public static bool isEnabled; public static void CheckForCompatibility() { isEnabled = Chainloader.PluginInfos.TryGetValue("randyknapp.mods.epicloot", out plugin); if (isEnabled && (object)assembly == null) { assembly = Assembly.GetAssembly(((object)plugin.Instance).GetType()); } } } }