using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Climate")] [assembly: AssemblyDescription("https://github.com/bryon82/SailwindClimate")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("raddude")] [assembly: AssemblyProduct("Climate")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("4a46e2fd-fb4e-4529-84b1-ed831d6b6116")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Climate; [BepInPlugin("com.raddude.climate", "Climate", "1.0.0")] public class Climate_Plugin : BaseUnityPlugin { public const string PLUGIN_GUID = "com.raddude.climate"; public const string PLUGIN_NAME = "Climate"; public const string PLUGIN_VERSION = "1.0.0"; private static ManualLogSource _logger; internal static Climate_Plugin Instance { get; private set; } internal static void LogDebug(string message) { _logger.LogDebug((object)message); } internal static void LogInfo(string message) { _logger.LogInfo((object)message); } internal static void LogWarning(string message) { _logger.LogWarning((object)message); } internal static void LogError(string message) { _logger.LogError((object)message); } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Instance = this; _logger = ((BaseUnityPlugin)this).Logger; ((MonoBehaviour)this).StartCoroutine(AssetLoader.LoadAssets()); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.raddude.climate"); SceneManager.sceneLoaded += AddShopItems.SceneLoaded; } } internal class PressurePatches { [HarmonyPatch(typeof(WeatherStorms), "GetNormalizedDistance")] private class GetNormalizedDistancePatch { public static void Postfix(float __result, WanderingStorm ___currentStorm, float ___currentStormRange) { if (GameState.playing) { PressureService.NormalizedDistanceToStorm = __result; float radius = ___currentStorm.GetRadius(); if (PressureService.CurrentStormRadius != radius) { PressureService.CurrentStormRadius = radius; } if (PressureService.CurrentStormRange != ___currentStormRange) { PressureService.CurrentStormRange = ___currentStormRange; } } } } } internal class PrefabLoadingPatches { [HarmonyPatch(typeof(PrefabsDirectory), "PopulateShipItems")] internal class PrefabDirectoryPatches { public static void Prefix(PrefabsDirectory __instance) { if (__instance.directory.Length <= 823) { Array.Resize(ref __instance.directory, 823); } __instance.directory[820] = Items.Barometer; __instance.directory[821] = Items.Thermometer; __instance.directory[822] = Items.Hygrometer; } } private const int NEW_PREFAB_DIR_SIZE = 823; } internal class AddShopItems { internal static void SceneLoaded(Scene scene, LoadSceneMode _) { if (((Scene)(ref scene)).name == "island 1 A Gold Rock") { GoldRockCity(); } if (((Scene)(ref scene)).name == "island 15 M (Fort)") { FortAestrin(); } if (((Scene)(ref scene)).name == "island 9 E Dragon Cliffs") { DragonCliffs(); } } internal static void GoldRockCity() { //IL_0042: 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_0080: 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_00be: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("island 1 A (gold rock) scenery"); if ((Object)(object)val == (Object)null) { Climate_Plugin.LogError("Gold Rock City scenery not found."); return; } MoveShopItem("shop item (221)", val.transform, new Vector3(1524.367f, 7.13f, -385.224f), (Vector3?)new Vector3(0f, 129.6f, 0f)); MakeShopItem("shop item 320", val.transform, new Vector3(1525.5f, 7.006f, -385.2f), new Vector3(90f, 241f, 0f), Items.Barometer); MakeShopItem("shop item 321", val.transform, new Vector3(1526f, 7.006f, -386.05f), new Vector3(90f, 245f, 0f), Items.Thermometer); MakeShopItem("shop item 322", val.transform, new Vector3(1526.7f, 7.006f, -386.76f), new Vector3(90f, 237f, 0f), Items.Hygrometer); } internal static void FortAestrin() { //IL_0042: 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_0080: 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_00be: 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) GameObject val = GameObject.Find("island 15 M (Fort) scenery"); if ((Object)(object)val == (Object)null) { Climate_Plugin.LogError("Fort Aestrin scenery not found."); return; } MakeShopItem("shop item (320)", val.transform, new Vector3(-74.816f, 2.7f, 44.2995f), new Vector3(0f, 180f, 0f), Items.Barometer); MakeShopItem("shop item (321)", val.transform, new Vector3(-75.316f, 2.7f, 44.2995f), new Vector3(0f, 180f, 0f), Items.Thermometer); MakeShopItem("shop item (322)", val.transform, new Vector3(-75.816f, 2.7f, 44.2995f), new Vector3(0f, 180f, 0f), Items.Hygrometer); } internal static void DragonCliffs() { //IL_0042: 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_009e: 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_00fa: 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_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: 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) GameObject val = GameObject.Find("island 9 E (dragon cliffs) scenery"); if ((Object)(object)val == (Object)null) { Climate_Plugin.LogError("Dragon Cliffs scenery not found."); return; } MoveShopItem("shop item spawner (101)", val.transform, new Vector3(-89.108f, 4.507f, -543.922f)); MoveShopItem("shop item spawner (165)", val.transform, new Vector3(-88.906f, 4.5156f, -544.329f)); MoveShopItem("shop item spawner (168)", val.transform, new Vector3(-90.455f, 4.489f, -542.922f)); MoveShopItem("shop item spawner (60)", val.transform, new Vector3(-91.1984f, 4.453f, -542.0734f)); MoveShopItem("shop item spawner (163)", val.transform, new Vector3(-91.05f, 4.513f, -542.25f)); Transform val2 = val.GetComponentsInChildren()?.FirstOrDefault((Func)((Transform t) => ((Object)t).name == "shop item spawner (71)")); if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(false); } MakeShopItem("shop item spawner (320)", val.transform, new Vector3(-89.268f, 4.477f, -544.36f), new Vector3(80f, 230f, 0f), Items.Barometer); MakeShopItem("shop item spawner (321)", val.transform, new Vector3(-90.7f, 4.455f, -542.58f), new Vector3(65f, 230f, 0f), Items.Thermometer); MakeShopItem("shop item spawner (322)", val.transform, new Vector3(-90.95f, 4.505f, -542.78f), new Vector3(70f, 230f, 0f), Items.Hygrometer); } private static void MakeShopItem(string name, Transform parent, Vector3 position, Vector3 rotation, GameObject go) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001b: 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_0029: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.parent = parent; val.transform.localPosition = position; val.transform.localRotation = Quaternion.Euler(rotation); MeshFilter val2 = val.AddComponent(); val2.mesh = go.GetComponent().mesh; val.AddComponent(); ShopItemSpawner val3 = val.AddComponent(); val3.itemPrefab = go; } private static void MoveShopItem(string name, Transform parent, Vector3 position, Vector3? rotation = null) { //IL_003a: 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) Transform val = ((Component)parent).GetComponentsInChildren()?.FirstOrDefault((Func)((Transform t) => ((Object)t).name == name)); if ((Object)(object)val != (Object)null) { val.localPosition = position; if (rotation.HasValue) { val.localRotation = Quaternion.Euler(rotation.Value); } } } } public class ShipItemBarometer : ShipItem { [SerializeField] private Transform needle; private float minAngle; private float maxAngle; private float smoothedAngle; private float smoothingK; public override void OnLoad() { needle = (from t in ((Component)this).gameObject.GetComponentsInChildren(true) where ((Object)t).name == "Needle" select t).FirstOrDefault(); minAngle = -118f; maxAngle = 240f; smoothingK = -6f; } public override void ExtraLateUpdate() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)needle == (Object)null)) { float num = Mathf.Lerp(minAngle, maxAngle, PressureService.GetNormalizedPressure()); smoothedAngle = Mathf.Lerp(smoothedAngle, num, 1f - Mathf.Exp(smoothingK * Time.deltaTime)); needle.localRotation = Quaternion.Euler(smoothedAngle, -90f, 90f); } } } public class ShipItemHygrometer : ShipItem { public Transform needle; private float minAngle; private float maxAngle; private float smoothingK; private float sampleInterval; private float humidity; private float smoothedAngle; private float sampleTimer; public override void OnLoad() { needle = (from t in ((Component)this).gameObject.GetComponentsInChildren(true) where ((Object)t).name == "Needle" select t).FirstOrDefault(); minAngle = -45f; maxAngle = 225f; smoothingK = -2f; sampleInterval = 1f; SampleHumidity(); } public override void ExtraLateUpdate() { sampleTimer += Time.deltaTime; if (sampleTimer >= sampleInterval) { sampleTimer = 0f; SampleHumidity(); } UpdateNeedle(); } private void SampleHumidity() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) Vector3 globeCoords = FloatingOriginManager.instance.GetGlobeCoords(((Component)this).transform); humidity = HumidityService.GetRelativeHumidity(globeCoords, Sun.sun.localTime, GameState.day); } private void UpdateNeedle() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)needle == (Object)null)) { float num = Mathf.Lerp(minAngle, maxAngle, humidity); smoothedAngle = Mathf.Lerp(smoothedAngle, num, 1f - Mathf.Exp(smoothingK * Time.deltaTime)); needle.localRotation = Quaternion.Euler(smoothedAngle, -90f, 90f); } } } public class ShipItemThermometer : ShipItem { private Transform needle; private float minAngle; private float maxAngle; private float smoothingK; private float sampleInterval; private float temperature; private float smoothedAngle; private float sampleTimer; public override void OnLoad() { needle = (from t in ((Component)this).gameObject.GetComponentsInChildren(true) where ((Object)t).name == "Needle" select t).FirstOrDefault(); minAngle = -45f; maxAngle = 225f; smoothingK = -2f; sampleInterval = 1f; SampleTemp(); } public override void ExtraLateUpdate() { sampleTimer += Time.deltaTime; if (sampleTimer >= sampleInterval) { sampleTimer = 0f; SampleTemp(); } UpdateNeedle(); } private void SampleTemp() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) Vector3 globeCoords = FloatingOriginManager.instance.GetGlobeCoords(((Component)this).transform); temperature = TemperatureService.GetNormalizedTemperature(globeCoords, Sun.sun.localTime, GameState.day); } private void UpdateNeedle() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)needle == (Object)null)) { float num = Mathf.Lerp(minAngle, maxAngle, temperature); smoothedAngle = Mathf.Lerp(smoothedAngle, num, 1f - Mathf.Exp(smoothingK * Time.deltaTime)); needle.localRotation = Quaternion.Euler(smoothedAngle, -90f, 90f); } } } internal static class DewPointService { private const float NoiseAmplitude = 3f; internal static float GetDewPoint(Vector3 coords, int day) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ClimateProfile profile = ClimateZones.GetProfile(coords); float num = ClimateZones.GetSeasonalFactor(day) * profile.seasonalDewAmplitude; float num2 = (Mathf.PerlinNoise((float)day * 0.1f, profile.dewNoiseSeed) - 0.5f) * 2f * 3f; return profile.baseDew + num + num2; } } internal static class HumidityService { internal static float GetRelativeHumidity(Vector3 coords, float time, int day) { //IL_0001: 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) float temperature = TemperatureService.GetTemperature(coords, time, day); float dewPoint = DewPointService.GetDewPoint(coords, day); dewPoint = Mathf.Min(dewPoint, temperature); return Mathf.Clamp(MagnusRH(temperature, dewPoint), 0.05f, 1f); } private static float MagnusRH(float temp, float dew) { float num = Mathf.Exp(17.625f * dew / (243.04f + dew)); float num2 = Mathf.Exp(17.625f * temp / (243.04f + temp)); return num / num2; } } internal class PressureService { internal static float CurrentStormRadius { get; set; } internal static float NormalizedDistanceToStorm { get; set; } internal static float CurrentStormRange { get; set; } internal static float GetPressure() { if (NormalizedDistanceToStorm >= 1f) { float num = Mathf.Clamp01((WeatherStorms.currentStormDistance - CurrentStormRadius - CurrentStormRange) / 12000f); return Mathf.Lerp(29.7f, 31.9f, num); } if (NormalizedDistanceToStorm <= 0f) { float num2 = Mathf.Clamp01(WeatherStorms.currentStormDistance / CurrentStormRadius); return Mathf.Lerp(26f, 27.65f, num2); } return Mathf.Lerp(27.65f, 29.7f, NormalizedDistanceToStorm); } internal static float GetNormalizedPressure() { float pressure = GetPressure(); return Mathf.InverseLerp(26f, 31.9f, pressure); } internal static bool IsNearStorm() { return NormalizedDistanceToStorm < 0.68f; } } internal static class TemperatureService { internal static float minTemp = -12.2222f; internal static float maxTemp = 46.1111f; private const float NoiseAmplitude = 3.8889f; private const float ReferenceLatitude = 31f; private const float ReferenceTemperature = 30f; private const float TempLatConversionFactor = 1.2f; internal static float GetTemperature(Vector3 coords, float time, int day) { //IL_0006: 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) float num = 30f - (coords.z - 31f) * 1.2f; ClimateProfile profile = ClimateZones.GetProfile(coords); float num2 = ClimateZones.GetSeasonalFactor(day) * profile.seasonalTempAmplitude; float num3 = Mathf.Sin(time / 24f * (float)Math.PI * 2f - (float)Math.PI / 2f) * (profile.tempAmplitude / 2f); float num4 = (Mathf.PerlinNoise((float)day * 0.15f, profile.tempNoiseSeed) - 0.5f) * 2f * 3.8889f; float num5 = (PressureService.IsNearStorm() ? Mathf.Lerp(-5f, 0f, PressureService.GetNormalizedPressure()) : 0f); return num + num2 + num3 + num4 + num5; } internal static float GetNormalizedTemperature(Vector3 coords, float time, int day) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) float temperature = GetTemperature(coords, time, day); return Mathf.InverseLerp(minTemp, maxTemp, temperature); } } public class WeatherService { public static float GetCurrentNormalizedPressure() { return PressureService.GetNormalizedPressure(); } public static float GetCurrentPressureMb() { return ConvertInHgToMb(GetCurrentPressureInHg()); } public static float GetCurrentPressureInHg() { return PressureService.GetPressure(); } public static float GetNormalizedTemperature(Vector3 coords, float time, int day) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) ValidateTime(time); ValidateDay(day); return TemperatureService.GetNormalizedTemperature(coords, time, day); } public static float GetCurrentNormalizedTemperature(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetNormalizedTemperature(coords, Sun.sun.localTime, GameState.day); } public static float GetTemperatureC(Vector3 coords, float time, int day) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) ValidateTime(time); ValidateDay(day); return TemperatureService.GetTemperature(coords, time, day); } public static float GetCurrentTemperatureC(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetTemperatureC(coords, Sun.sun.localTime, GameState.day); } public static float GetTemperatureF(Vector3 coords, float time, int day) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ConvertCtoF(GetTemperatureC(coords, time, day)); } public static float GetCurrentTemperatureF(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ConvertCtoF(GetCurrentTemperatureC(coords)); } public static float GetWindChillC(float windSpeedKnots, Vector3 coords, float time, int day) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return ConvertFtoC(GetWindChillF(windSpeedKnots, coords, time, day)); } public static float GetCurrentWindChillC(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ConvertFtoC(GetCurrentWindChillF(coords)); } public static float GetWindChillF(float windSpeedKnots, Vector3 coords, float time, int day) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) ValidateWindSpeed(windSpeedKnots); ValidateTime(time); ValidateDay(day); float temperatureF = GetTemperatureF(coords, time, day); float num = ConvertKnotsToMph(windSpeedKnots); if (temperatureF > 50f || num < 3f) { return temperatureF; } return GetWindChill(temperatureF, num); } public static float GetCurrentWindChillF(Vector3 coords) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) return GetWindChillF(((Vector3)(ref Wind.currentWind)).magnitude, coords, Sun.sun.localTime, GameState.day); } public static float GetHeatIndexC(Vector3 coords, float time, int day) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ConvertFtoC(GetHeatIndexF(coords, time, day)); } public static float GetCurrentHeatIndexC(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ConvertFtoC(GetCurrentHeatIndexF(coords)); } public static float GetHeatIndexF(Vector3 coords, float time, int day) { //IL_000f: 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) ValidateTime(time); ValidateDay(day); float temperatureF = GetTemperatureF(coords, time, day); float num = HumidityService.GetRelativeHumidity(coords, time, day) * 100f; if (temperatureF < 80f || num < 40f) { return temperatureF; } return GetHeatIndex(temperatureF, num); } public static float GetCurrentHeatIndexF(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetHeatIndexF(coords, Sun.sun.localTime, GameState.day); } public static float GetApparentTemperatureC(float windSpeedKnots, Vector3 coords, float time, int day) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return ConvertFtoC(GetApparentTemperatureF(windSpeedKnots, coords, time, day)); } public static float GetCurrentApparentTemperatureC(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ConvertFtoC(GetCurrentApparentTemperatureF(coords)); } public static float GetApparentTemperatureF(float windSpeedKnots, Vector3 coords, float time, int day) { //IL_0016: 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) ValidateWindSpeed(windSpeedKnots); ValidateTime(time); ValidateDay(day); float temperatureF = GetTemperatureF(coords, time, day); float num = GetRelativeHumidity(coords, time, day) * 100f; float num2 = ConvertKnotsToMph(windSpeedKnots); if (temperatureF <= 50f && num2 >= 3f) { return GetWindChill(temperatureF, num2); } if (temperatureF >= 80f && num >= 40f) { return GetHeatIndex(temperatureF, num); } return temperatureF; } public static float GetCurrentApparentTemperatureF(Vector3 coords) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) return GetApparentTemperatureF(((Vector3)(ref Wind.currentWind)).magnitude, coords, Sun.sun.localTime, GameState.day); } public static float GetRelativeHumidity(Vector3 coords, float time, int day) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) ValidateTime(time); ValidateDay(day); return HumidityService.GetRelativeHumidity(coords, time, day); } public static float GetCurrentRelativeHumidity(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return HumidityService.GetRelativeHumidity(coords, Sun.sun.localTime, GameState.day); } public static float GetDewPointC(Vector3 coords, int day) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) ValidateDay(day); return DewPointService.GetDewPoint(coords, day); } public static float GetCurrentDewPointC(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetDewPointC(coords, GameState.day); } public static float GetDewPointF(Vector3 coords, int day) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ConvertCtoF(GetDewPointC(coords, day)); } public static float GetCurrentDewPointF(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ConvertCtoF(GetCurrentDewPointC(coords)); } private static void ValidateTime(float time) { if (time < 0f || time > 24f) { throw new ArgumentOutOfRangeException("time", time, "Time must be between 0 and 24 hours (inclusive)."); } } private static void ValidateDay(int day) { if (day < 0) { throw new ArgumentOutOfRangeException("day", day, "Day must be non-negative."); } } private static void ValidateWindSpeed(float windSpeedKnots) { if (windSpeedKnots < 0f) { throw new ArgumentOutOfRangeException("windSpeedKnots", windSpeedKnots, "Wind speed cannot be negative."); } } private static float GetWindChill(float tempF, float windSpeedMph) { return 35.74f + 0.6215f * tempF - 35.75f * Mathf.Pow(windSpeedMph, 0.16f) + 0.4275f * tempF * Mathf.Pow(windSpeedMph, 0.16f); } private static float GetHeatIndex(float tempF, float humidity) { return -42.379f + 2.0490153f * tempF + 10.143332f * humidity - 0.2247554f * tempF * humidity - 0.00683783f * tempF * tempF - 0.05481717f * humidity * humidity + 0.00122874f * tempF * tempF * humidity + 0.00085282f * tempF * humidity * humidity - 1.99E-06f * tempF * tempF * humidity * humidity; } private static float ConvertCtoF(float tempC) { return tempC * 9f / 5f + 32f; } private static float ConvertFtoC(float tempF) { return (tempF - 32f) * 5f / 9f; } private static float ConvertKnotsToMph(float knots) { return knots * 1.150779f; } private static float ConvertInHgToMb(float inHg) { return inHg * 33.8639f; } } internal class AssetLoader { private static readonly List assetPaths = new List { Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Climate_Plugin.Instance).Info.Location), "Assets"), Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Climate_Plugin.Instance).Info.Location)) }; public static string FindAssetPath(string fileName) { foreach (string assetPath in assetPaths) { string text = Path.Combine(assetPath, fileName); if (File.Exists(text)) { return text; } } return null; } internal static IEnumerator LoadAssets() { Climate_Plugin.LogDebug("Loading bundle"); string bundlePath = FindAssetPath("meteorology_tools"); if (string.IsNullOrEmpty(bundlePath)) { Climate_Plugin.LogError("Asset bundle not found"); yield break; } AssetBundleCreateRequest assetBundleRequest = AssetBundle.LoadFromFileAsync(bundlePath); yield return assetBundleRequest; AssetBundle assetBundle = assetBundleRequest.assetBundle; if ((Object)(object)assetBundle == (Object)null) { Climate_Plugin.LogError("Failed to load " + bundlePath); } AssetBundleRequest request = assetBundle.LoadAllAssetsAsync(); yield return request; Object? obj = ((IEnumerable)request.allAssets).FirstOrDefault((Func)((Object a) => a.name == "barometer")); Items.Barometer = (GameObject)(object)((obj is GameObject) ? obj : null); Object? obj2 = ((IEnumerable)request.allAssets).FirstOrDefault((Func)((Object a) => a.name == "thermometer")); Items.Thermometer = (GameObject)(object)((obj2 is GameObject) ? obj2 : null); Object? obj3 = ((IEnumerable)request.allAssets).FirstOrDefault((Func)((Object a) => a.name == "hygrometer")); Items.Hygrometer = (GameObject)(object)((obj3 is GameObject) ? obj3 : null); if ((Object)(object)Items.Barometer == (Object)null || (Object)(object)Items.Thermometer == (Object)null || (Object)(object)Items.Hygrometer == (Object)null) { Climate_Plugin.LogError("Failed to load all required assets from the bundle"); yield break; } Climate_Plugin.LogInfo("Assets loaded"); Items.Initialize(); } } public readonly struct ClimateProfile { public readonly float tempAmplitude; public readonly float baseDew; public readonly float seasonalTempAmplitude; public readonly float seasonalDewAmplitude; public readonly float tempNoiseSeed; public readonly float dewNoiseSeed; public ClimateProfile(float tempAmplitude, float baseDew, float seasonalTempAmplitude, float seasonalDewAmplitude) { this.tempAmplitude = tempAmplitude; this.baseDew = baseDew; this.seasonalTempAmplitude = seasonalTempAmplitude; this.seasonalDewAmplitude = seasonalDewAmplitude; tempNoiseSeed = seasonalTempAmplitude * 11.3f + tempAmplitude * 4.9f; dewNoiseSeed = seasonalDewAmplitude * 8.6f + baseDew * 3.4f; } } public static class ClimateZones { public static readonly ClimateProfile AlAnkh = new ClimateProfile(16f, -2f, 6f, 2f); public static readonly ClimateProfile Emerald = new ClimateProfile(3f, 26f, 1.5f, 1f); public static readonly ClimateProfile Aestrin = new ClimateProfile(6f, 8f, 8f, 6f); private const float buffer = 1f; private const float AlAnkhLon = -0.18f; private const float AestrinLat = 36f; private const float DaysPerYear = 365f; private const int PeakDay = 172; public static ClimateProfile GetProfile(Vector3 coords) { //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) float z = coords.z; float x = coords.x; ClimateProfile climateProfile; if (!(x > -1.1800001f) || !(x < 0.82f)) { climateProfile = ((!(x < -0.18f)) ? Emerald : AlAnkh); } else { float t = Mathf.InverseLerp(-1.1800001f, 0.82f, x); climateProfile = Lerp(AlAnkh, Emerald, t); } if (z > 35f && z < 37f) { float t2 = Mathf.InverseLerp(35f, 37f, z); return Lerp(climateProfile, Aestrin, t2); } return (z > 36f) ? Aestrin : climateProfile; } private static ClimateProfile Lerp(ClimateProfile a, ClimateProfile b, float t) { return new ClimateProfile(Mathf.Lerp(a.tempAmplitude, b.tempAmplitude, t), Mathf.Lerp(a.baseDew, b.baseDew, t), Mathf.Lerp(a.seasonalTempAmplitude, b.seasonalTempAmplitude, t), Mathf.Lerp(a.seasonalDewAmplitude, b.seasonalDewAmplitude, t)); } internal static float GetSeasonalFactor(int day) { int num = day % 365; return Mathf.Cos((float)Math.PI * 2f * (float)(num - 172) / 365f); } } internal class Items { public static GameObject Barometer { get; internal set; } public static GameObject Thermometer { get; internal set; } public static GameObject Hygrometer { get; internal set; } internal static void InitializeBarometer() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) ShipItemBarometer shipItemBarometer = Barometer.AddComponent(); ((PickupableItem)shipItemBarometer).holdDistance = 0.82f; ((PickupableItem)shipItemBarometer).furniturePlaceHeight = 0.15f; ((ShipItem)shipItemBarometer).mass = 1f; ((ShipItem)shipItemBarometer).value = 600; ((ShipItem)shipItemBarometer).name = "barometer"; ((ShipItem)shipItemBarometer).category = (TransactionCategory)3; ((ShipItem)shipItemBarometer).inventoryScale = 1f; ((ShipItem)shipItemBarometer).inventoryRotation = 180f; ((ShipItem)shipItemBarometer).floaterHeight = 1.6f; ((ShipItem)shipItemBarometer).wallAttachment = true; } internal static void InitializeThermometer() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) ShipItemThermometer shipItemThermometer = Thermometer.AddComponent(); ((PickupableItem)shipItemThermometer).holdDistance = 0.82f; ((PickupableItem)shipItemThermometer).furniturePlaceHeight = 0.15f; ((ShipItem)shipItemThermometer).mass = 1f; ((ShipItem)shipItemThermometer).value = 600; ((ShipItem)shipItemThermometer).name = "thermometer"; ((ShipItem)shipItemThermometer).category = (TransactionCategory)3; ((ShipItem)shipItemThermometer).inventoryScale = 1f; ((ShipItem)shipItemThermometer).inventoryRotation = 180f; ((ShipItem)shipItemThermometer).floaterHeight = 1.6f; ((ShipItem)shipItemThermometer).wallAttachment = true; } internal static void InitializeHygrometer() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) ShipItemHygrometer shipItemHygrometer = Hygrometer.AddComponent(); ((PickupableItem)shipItemHygrometer).holdDistance = 0.82f; ((PickupableItem)shipItemHygrometer).furniturePlaceHeight = 0.15f; ((ShipItem)shipItemHygrometer).mass = 1f; ((ShipItem)shipItemHygrometer).value = 600; ((ShipItem)shipItemHygrometer).name = "hygrometer"; ((ShipItem)shipItemHygrometer).category = (TransactionCategory)3; ((ShipItem)shipItemHygrometer).inventoryScale = 1f; ((ShipItem)shipItemHygrometer).inventoryRotation = 180f; ((ShipItem)shipItemHygrometer).floaterHeight = 1.6f; ((ShipItem)shipItemHygrometer).wallAttachment = true; } internal static void Initialize() { InitializeBarometer(); InitializeThermometer(); InitializeHygrometer(); } }