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.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; 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.5.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.5.0.0")] [module: UnverifiableCode] namespace Climate { [BepInPlugin("com.raddude.climate", "Climate", "1.5.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.5.0"; private static ManualLogSource _logger; internal static Climate_Plugin Instance { get; private set; } internal static DebugProps DebugProps { get; private set; } = new DebugProps(); public static int MaxWindLatitude { get { return WindService.maxLatitude; } set { WindService.maxLatitude = value; } } public static int MinWindLatitude { get { return WindService.minLatitude; } set { WindService.minLatitude = value; } } public static int MaxWindLongitude { get { return WindService.maxLongitude; } set { WindService.maxLongitude = value; } } public static int MinWindLongitude { get { return WindService.minLongitude; } set { WindService.minLongitude = value; } } public static int MaxPressureCells { get { return PressureCell.maxPressureCells; } set { PressureCell.maxPressureCells = value; } } public static int MaxCellSpawnLatitude { get { return PressureCell.maxSpawnLatitude; } set { PressureCell.maxSpawnLatitude = value; } } public static int MinCellSpawnLatitude { get { return PressureCell.minSpawnLatitude; } set { PressureCell.minSpawnLatitude = value; } } public static int MaxCellSpawnLongitude { get { return PressureCell.maxSpawnLongitude; } set { PressureCell.maxSpawnLongitude = value; } } public static int MinCellSpawnLongitude { get { return PressureCell.minSpawnLongitude; } set { PressureCell.minSpawnLongitude = value; } } 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); } public static void AddPressureSystem(float s_x0, float s_y0, float s_amp, float s_sigmaX, float s_sigmaY, float s_thetaDeg, float w_x0, float w_y0, float w_amp, float w_sigmaX, float w_sigmaY, float w_thetaDeg, float posWiggle, float ampWiggle) { PressureSystem.AddPressureSystem(s_x0, s_y0, s_amp, s_sigmaX, s_sigmaY, s_thetaDeg, w_x0, w_y0, w_amp, w_sigmaX, w_sigmaY, w_thetaDeg, posWiggle, ampWiggle); } private void Awake() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown 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()); Configs.InitializeConfigs(); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.raddude.climate"); SceneManager.sceneLoaded += AddShopItems.SceneLoaded; Sun.OnNewDay += new NewDay(PressureCell.UpdatePressureCells); Sun.OnNewDay += new NewDay(PressureSystem.UpdateAllWiggles); Sun.OnNewDay += new NewDay(WindService.UpdateDailyWindField); Sun.OnNewDay += new NewDay(DateTextUI.UpdateDateText); } } public readonly struct ClimateProfile { public readonly float baseDew; public readonly float seasonalTempAmplitude; public readonly float seasonalDewAmplitude; public readonly float pressureCoolingFactor; public readonly float tempNoiseSeed; public readonly float dewNoiseSeed; public readonly float airmassNoiseSeed; internal static readonly float NOISE_CORRELATION = 0.6f; internal static float AirMassFreq => (Configs.yearLength.Value == 92) ? 0.476f : 0.12f; public ClimateProfile(float baseDew, float seasonalTempAmplitude, float seasonalDewAmplitude, float pressureCoolingFactor) { this.baseDew = baseDew; this.seasonalTempAmplitude = seasonalTempAmplitude; this.seasonalDewAmplitude = seasonalDewAmplitude; this.pressureCoolingFactor = pressureCoolingFactor; tempNoiseSeed = seasonalTempAmplitude * 11.3f; dewNoiseSeed = seasonalDewAmplitude * 8.6f + baseDew * 3.4f; airmassNoiseSeed = seasonalTempAmplitude * 7.1f + seasonalDewAmplitude * 5.3f + baseDew * 2.2f; } } internal class PressureCell : IModDataSaveable { internal Vector2 origin; internal Vector2 velocity; internal float radius; internal float intensity; internal float moistureDelta; internal int spawnDay; internal int lifespanDays; public static int maxPressureCells = 6; public static int maxSpawnLatitude = 42; public static int minSpawnLatitude = 28; public static int maxSpawnLongitude = 6; public static int minSpawnLongitude = -6; private const float WIND_CELL_GRADIENT_SCALE = 20f; private const float WIND_CELL_SAMPLE_DIST = 1f; private const float PRESSURE_MOISTURE_CORRELATION = 0.6f; private const float INTENSITY_SCALE = 1.7f; private const float MOIST_MAX = 10f; private const float DRY_MAX = -5f; private const float SPAWN_BIAS_STRENGTH = 0.5f; private const float WIND_STEERING_STRENGTH = 0.8f; internal static readonly List cells = new List(); internal static void UpdatePressureCells() { //IL_00eb: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_019e: 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_01a9: 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_01b2: Unknown result type (might be due to invalid IL or missing references) cells.RemoveAll((PressureCell cell) => GameState.day - cell.spawnDay > cell.lifespanDays); Vector2 val2 = default(Vector2); while (cells.Count < maxPressureCells) { int num = Random.Range(minSpawnLatitude, maxSpawnLatitude); int num2 = Random.Range(minSpawnLongitude, maxSpawnLongitude); float pressureSystemInfluence = PressureSystem.GetPressureSystemInfluence(num, num2, GameState.day); float num3 = Mathf.Clamp((0f - pressureSystemInfluence) / (float)Configs.maxWindSpeed.Value, -1f, 1f); float num4 = Random.Range(-1f, 1f); float num5 = Mathf.Lerp(num4, num3, 0.5f); float num6 = Random.Range(-1f, 1f); float num7 = Random.Range(-1f, 1f); float num8 = (0f - num5) * 0.6f + num6 * 0.39999998f; float num9 = num5 * 0.6f + num7 * 0.39999998f; Vector3 val = WindService.SampleWind(num, num2); ((Vector2)(ref val2))..ctor(((Vector3)(ref val)).normalized.z, ((Vector3)(ref val)).normalized.x); Vector2 val3 = new Vector2((float)Random.Range(-2, 2), (float)Random.Range(-2, 2)); Vector2 normalized = ((Vector2)(ref val3)).normalized; Vector2 val4; if (!(((Vector2)(ref val2)).sqrMagnitude > 0.0001f)) { val4 = normalized; } else { val3 = Vector2.Lerp(normalized, ((Vector2)(ref val2)).normalized, 0.8f); val4 = ((Vector2)(ref val3)).normalized; } Vector2 val5 = val4; float num10 = Mathf.InverseLerp(0f, (float)Configs.maxWindSpeed.Value, ((Vector3)(ref val)).magnitude); float num11 = Mathf.Lerp(-2f, 2f, num10); PressureCell item = new PressureCell { origin = new Vector2((float)num, (float)num2), velocity = val5 * num11, radius = Random.Range(4f, 9f), intensity = num8 * 1.7f, moistureDelta = ((num9 >= 0f) ? Mathf.Lerp(0f, 10f, num9) : Mathf.Lerp(0f, -5f, 0f - num9)), spawnDay = GameState.day, lifespanDays = Random.Range(2, 5) }; cells.Add(item); } } internal static Vector3 GetWindContribution(Vector3 coords) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_0034: 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_0072: 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_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_00ad: 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) //IL_00af: 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) float num = (P(new Vector3(0f, 0f, 1f)) - P(new Vector3(0f, 0f, -1f))) / 2f; float num2 = (P(new Vector3(1f, 0f, 0f)) - P(new Vector3(-1f, 0f, 0f))) / 2f; return Vector3.ClampMagnitude(new Vector3(0f - num, 0f, num2) * 20f, (float)Configs.pressureCellmaxWindContr.Value); float P(Vector3 offset) { //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_0007: Unknown result type (might be due to invalid IL or missing references) return PressureService.GetPressure(coords + offset, GameState.day, includeStorm: false); } } string IModDataSaveable.SaveString() { FormattableString formattableString = $"{origin.x}|{origin.y}|{velocity.x}|{velocity.y}|{radius}|{intensity}|{moistureDelta}|{spawnDay}|{lifespanDays}"; return formattableString.ToString(CultureInfo.InvariantCulture); } internal static void SavePressureCells() { IModDataSaveable[] data = cells.ToArray(); ModData.AddListEntry("com.raddude.climate.PressureCells", data); } internal static void LoadPressureCells() { List pressureCellListEntry = ModData.GetPressureCellListEntry("com.raddude.climate.PressureCells"); cells.Clear(); cells.AddRange(pressureCellListEntry); if (cells.Count < maxPressureCells) { UpdatePressureCells(); } } public static void CheckPressureCellWindContribution() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_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_002a: 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_0048: 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) Vector3 globeCoords = FloatingOriginManager.instance.GetGlobeCoords(((Component)Refs.observerMirror).transform); Vector3 windContribution = GetWindContribution(globeCoords); Climate_Plugin.LogDebug($"PressureCell wind contribution at lat: {globeCoords.z} lon: {globeCoords.x} - direction: {((Vector3)(ref windContribution)).normalized} {WindService.GetWindDirectionDegrees(((Vector3)(ref windContribution)).normalized)} magnitude: {((Vector3)(ref windContribution)).magnitude}"); } } internal readonly struct PressureSystemParams { internal readonly float x0; internal readonly float y0; internal readonly float amplitude; internal readonly float sigmaX; internal readonly float sigmaY; internal readonly float theta; internal PressureSystemParams(float x0, float y0, float amp, float sigmaX, float sigmaY, float thetaDeg) { this.x0 = x0; this.y0 = y0; amplitude = amp; this.sigmaX = sigmaX; this.sigmaY = sigmaY; theta = thetaDeg * ((float)Math.PI / 180f); } } internal readonly struct PressureSystemSaveData { internal readonly float dx; internal readonly float dy; internal readonly float da; internal PressureSystemSaveData(float dx, float dy, float da) { this.dx = dx; this.dy = dy; this.da = da; } } public class PressureSystem : IModDataSaveable { private readonly PressureSystemParams winter; private readonly PressureSystemParams summer; private readonly float posWiggle; private readonly float ampWiggle; private readonly float persistence; internal float dx; internal float dy; internal float da; internal static readonly List systems = new List { new PressureSystem(new PressureSystemParams(-3f, 27f, 3f, 5f, 3f, 45f), new PressureSystemParams(-1f, 27f, 1f, 7f, 4f, 45f), 0.5f, 0.25f), new PressureSystem(new PressureSystemParams(10f, 33f, 5f, 15f, 7.5f, -10f), new PressureSystemParams(10f, 36f, 5f, 15f, 7.5f, 10f), 2f, 1f), new PressureSystem(new PressureSystemParams(-17f, 36f, 4f, 4f, 8f, 0f), new PressureSystemParams(-14f, 33f, -4f, 5f, 10f, 0f), 2f, 1f), new PressureSystem(new PressureSystemParams(-7f, 41f, -3f, 5f, 7f, -45f), new PressureSystemParams(-6f, 39f, -2f, 4f, 6f, -30f), 3f, 2f), new PressureSystem(new PressureSystemParams(6f, 44f, -5f, 12f, 6f, 0f), new PressureSystemParams(12f, 46f, -2f, 10f, 7f, 0f), 4f, 2f), new PressureSystem(new PressureSystemParams(10f, 5f, -3f, 20f, 15f, -10f), new PressureSystemParams(10f, 20f, -7f, 20f, 15f, 10f), 3f, 1f), new PressureSystem(new PressureSystemParams(-2f, 33f, -3.5f, 5f, 5f, 0f), new PressureSystemParams(-5f, 35f, 0f, 5f, 5f, 0f), 3f, 1f) }; internal PressureSystem(PressureSystemParams winter, PressureSystemParams summer, float posWiggle = 0f, float ampWiggle = 0f, float persistence = 0.93f) { this.winter = winter; this.summer = summer; this.posWiggle = posWiggle; this.ampWiggle = ampWiggle; this.persistence = persistence; } private void ComputeState(int day, out PressureSystemParams s, out float theta) { float num = 0.5f * (1f - Mathf.Cos((float)Math.PI * 2f * (float)day / (float)Configs.yearLength.Value)); s = new PressureSystemParams(Mathf.Lerp(winter.x0, summer.x0, num), Mathf.Lerp(winter.y0, summer.y0, num), Mathf.Lerp(winter.amplitude, summer.amplitude, num), Mathf.Lerp(winter.sigmaX, summer.sigmaX, num), Mathf.Lerp(winter.sigmaY, summer.sigmaY, num), 0f); theta = Mathf.Lerp(winter.theta, summer.theta, num); } private float ComputeP(float x, float y, PressureSystemParams s, float theta, out float xp, out float yp, out float c, out float st) { float num = s.x0 + dx; float num2 = s.y0 + dy; float num3 = s.amplitude + da; float num4 = x - num; float num5 = y - num2; c = Mathf.Cos(theta); st = Mathf.Sin(theta); xp = num4 * c + num5 * st; yp = (0f - num4) * st + num5 * c; float num6 = s.sigmaX * s.sigmaX; float num7 = s.sigmaY * s.sigmaY; return num3 * Mathf.Exp(-0.5f * (xp * xp / num6 + yp * yp / num7)); } internal float Value(float x, float y, int day) { ComputeState(day, out var s, out var theta); float xp; float yp; float c; float st; return ComputeP(x, y, s, theta, out xp, out yp, out c, out st); } internal void Gradient(float x, float y, int day, out float dPdx, out float dPdy) { ComputeState(day, out var s, out var theta); float xp; float yp; float c; float st; float num = ComputeP(x, y, s, theta, out xp, out yp, out c, out st); float num2 = s.sigmaX * s.sigmaX; float num3 = s.sigmaY * s.sigmaY; dPdx = num * (0f - xp * c / num2 + yp * st / num3); dPdy = num * (0f - xp * st / num2 - yp * c / num3); } private static float NextGaussian() { float num = 1f - Random.value; float value = Random.value; return Mathf.Sqrt(-2f * Mathf.Log(num)) * Mathf.Cos((float)Math.PI * 2f * value); } internal void UpdateWiggles() { float num = persistence; dx = num * dx + (1f - num) * posWiggle * NextGaussian(); dy = num * dy + (1f - num) * posWiggle * NextGaussian(); da = num * da + (1f - num) * ampWiggle * NextGaussian(); } internal static void UpdateAllWiggles() { foreach (PressureSystem system in systems) { system.UpdateWiggles(); } } internal static float GetPressureSystemInfluence(float lat, float lon, int day) { float num = 0f; foreach (PressureSystem system in systems) { num += system.Value(lon, lat, day); } return num; } public static void AddPressureSystem(float s_x0, float s_y0, float s_amp, float s_sigmaX, float s_sigmaY, float s_thetaDeg, float w_x0, float w_y0, float w_amp, float w_sigmaX, float w_sigmaY, float w_thetaDeg, float posWiggle, float ampWiggle) { PressureSystemParams pressureSystemParams = new PressureSystemParams(s_x0, s_y0, s_amp, s_sigmaX, s_sigmaY, s_thetaDeg); PressureSystemParams pressureSystemParams2 = new PressureSystemParams(w_x0, w_y0, w_amp, w_sigmaX, w_sigmaY, w_thetaDeg); PressureSystem item = new PressureSystem(pressureSystemParams, pressureSystemParams2, posWiggle, ampWiggle); systems.Add(item); } string IModDataSaveable.SaveString() { FormattableString formattableString = $"{dx}|{dy}|{da}"; return formattableString.ToString(CultureInfo.InvariantCulture); } internal static void SavePressureSystems() { IModDataSaveable[] data = systems.ToArray(); ModData.AddListEntry("com.raddude.climate.PressureSystems", data); } internal static void LoadPressureSystems() { List pressureSystemListEntry = ModData.GetPressureSystemListEntry("com.raddude.climate.PressureSystems"); int count = systems.Count; if (systems.Count > pressureSystemListEntry.Count) { count = pressureSystemListEntry.Count; Climate_Plugin.LogWarning($"Loaded {count} pressure systems, expected {systems.Count}. Non-loaded pressure systems will use default values."); } for (int i = 0; i < count; i++) { PressureSystemSaveData pressureSystemSaveData = pressureSystemListEntry[i]; PressureSystem pressureSystem = systems[i]; pressureSystem.dx = pressureSystemSaveData.dx; pressureSystem.dy = pressureSystemSaveData.dy; pressureSystem.da = pressureSystemSaveData.da; } WindService.UpdateDailyWindField(); } internal static void CheckPressureSystemInfluence() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_003d: Unknown result type (might be due to invalid IL or missing references) Vector3 globeCoords = FloatingOriginManager.instance.GetGlobeCoords(((Component)Refs.observerMirror).transform); float pressureSystemInfluence = GetPressureSystemInfluence(globeCoords.z, globeCoords.x, GameState.day); Climate_Plugin.LogDebug($"PressureSystem pressure influence at lat: {globeCoords.z} lon: {globeCoords.x} - influence: {pressureSystemInfluence}"); } } internal class UIPatches { [HarmonyPatch(typeof(DayLogs), "Awake")] internal class DayLogsAwakePatch { [HarmonyPostfix] public static void Postfix() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(((Component)DayLogs.instance.dayText).gameObject, ((Component)DayLogs.instance.dayText).transform.parent); TextMesh component = val.GetComponent(); ((Object)component).name = "ClimateDateText"; component.alignment = (TextAlignment)0; component.anchor = (TextAnchor)1; ((Component)component).transform.localPosition = new Vector3(0.5f, 0.24f, -0.007f); DateTextUI.textMesh = component; DateTextUI.UpdateDateText(); } } } internal class WeatherPatches { [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; } } } } [HarmonyPatch(typeof(OceanColorBlender), "ApplyPalette")] internal static class FogOverlayPatch { private static float smoothedFog; private const float SMOOTH_RATE = 0.15f; private const float RAIN_SUPPRESSION_THRESHOLD = 0.5f; public static void Postfix() { //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_001c: 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_003e: Unknown result type (might be due to invalid IL or missing references) float fogDensity = RenderSettings.fogDensity; Vector3 globeCoords = FloatingOriginManager.instance.GetGlobeCoords(((Component)Refs.observerMirror).transform); float temperature = TemperatureService.GetTemperature(globeCoords, Sun.sun.localTime, GameState.day); float dewPoint = DewPointService.GetDewPoint(globeCoords, GameState.day); float stabilizingFactor = PressureService.GetStabilizingFactor(globeCoords, GameState.day); float fogDensity2 = EffectsService.GetFogDensity(temperature, dewPoint, stabilizingFactor); smoothedFog = Mathf.Lerp(smoothedFog, fogDensity2, 1f - Mathf.Exp(-0.15f * Time.deltaTime)); float num = Mathf.Clamp01(GameState.rainIntensity / 0.5f); float num2 = (DebugProps.FogDensity = smoothedFog * (1f - num)); DebugProps.TargetFogDensity = fogDensity2; DebugProps.ApplyingFogDensity = num2 > fogDensity; RenderSettings.fogDensity = Mathf.Max(fogDensity, num2); } } [HarmonyPatch(typeof(Weather), "ApplyWeather")] internal static class RainOverlayPatch { private static float smoothedRain; private static float smoothedCloud; private const float SMOOTH_RATE_RAIN = 0.1f; private const float SMOOTH_RATE_CLOUD = 0.08f; public static void Postfix(ParticleSystem ___rain, ParticleSystem ___outerRain, ParticleSystem ___rainSplash, ParticleSystem ___lowerClouds, ParticleSystem ___upperClouds) { //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_0029: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_0141: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_00b5: 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_00c6: 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_00de: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) if (GameState.playing) { Vector3 globeCoords = FloatingOriginManager.instance.GetGlobeCoords(((Component)Refs.observerMirror).transform); float relativeHumidity = HumidityService.GetRelativeHumidity(globeCoords, Sun.sun.localTime, GameState.day); float liftFactor = PressureService.GetLiftFactor(globeCoords, GameState.day); float rainIntensity = GameState.rainIntensity; float physicalRainDensity = EffectsService.GetPhysicalRainDensity(relativeHumidity, liftFactor); smoothedRain = Mathf.Lerp(smoothedRain, physicalRainDensity, 1f - Mathf.Exp(-0.1f * Time.deltaTime)); float num = Mathf.Max(GameState.rainIntensity, smoothedRain); if (num > rainIntensity) { EmissionModule emission = ___rain.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(num * 75f); EmissionModule emission2 = ___outerRain.emission; ((EmissionModule)(ref emission2)).rateOverTime = MinMaxCurve.op_Implicit(num * 125f); EmissionModule emission3 = ___rainSplash.emission; ((EmissionModule)(ref emission3)).rateOverTime = MinMaxCurve.op_Implicit(num * 250f); GameState.rainIntensity = num; } float physicalCloudDensity = EffectsService.GetPhysicalCloudDensity(relativeHumidity, liftFactor); smoothedCloud = Mathf.Lerp(smoothedCloud, physicalCloudDensity, 1f - Mathf.Exp(-0.08f * Time.deltaTime)); EmissionModule emission4 = ___lowerClouds.emission; MinMaxCurve rateOverTime = ((EmissionModule)(ref emission4)).rateOverTime; float constant = ((MinMaxCurve)(ref rateOverTime)).constant; rateOverTime = ((EmissionModule)(ref emission4)).rateOverTime; float num2 = Mathf.Max(((MinMaxCurve)(ref rateOverTime)).constant, smoothedCloud); rateOverTime = ((EmissionModule)(ref emission4)).rateOverTime; if (num2 > ((MinMaxCurve)(ref rateOverTime)).constant) { ((EmissionModule)(ref emission4)).rateOverTime = MinMaxCurve.op_Implicit(num2); EmissionModule emission5 = ___upperClouds.emission; ((EmissionModule)(ref emission5)).rateOverTime = MinMaxCurve.op_Implicit(num2 * 2f); } DebugProps.RainIntensity = smoothedRain; DebugProps.CloudRate = smoothedCloud; DebugProps.TargetRainIntensity = physicalRainDensity; DebugProps.TargetCloudRate = physicalCloudDensity; DebugProps.ApplyingRainIntensity = smoothedRain > rainIntensity; DebugProps.ApplyingCloudRate = smoothedCloud > constant; } } } [HarmonyPatch(typeof(Wind))] internal static class ReplaceWindPatches { [HarmonyPostfix] [HarmonyPatch("Awake")] public static void Awake() { PressureSystem.UpdateAllWiggles(); WindService.UpdateDailyWindField(); PressureCell.UpdatePressureCells(); } [HarmonyPrefix] [HarmonyPatch("GetCurrentTradeWind")] public static bool GetCurrentTradeWind(ref Vector3 __result) { if (!Configs.enableWinds.Value || !GameState.playing) { return true; } return false; } [HarmonyPrefix] [HarmonyPatch("SetNewWindTarget")] public static bool SetNewWindTarget(ref Vector3 ___currentWindTarget) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0048: 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) //IL_004f: 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) //IL_0056: 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_0091: 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_00a4: 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_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_00b9: 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_00c2: 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_00fa: 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_0103: 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) //IL_0107: 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_0112: 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_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: 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_01eb: 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_01fc: 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) if (!Configs.enableWinds.Value || !GameState.playing) { return true; } Wind instance = Wind.instance; Vector3 globeCoords = FloatingOriginManager.instance.GetGlobeCoords(((Component)Refs.observerMirror).transform); Vector3 val = WindService.SampleWind(globeCoords); Vector3 windContribution = PressureCell.GetWindContribution(globeCoords); Vector3 val2 = val + windContribution; Region currentRegion = Weather.instance.currentRegion; float windDirChaos = currentRegion.windDirChaos; float windChaos = currentRegion.windChaos; Vector3 insideUnitSphere = Random.insideUnitSphere; insideUnitSphere.y = 0f; ((Vector3)(ref insideUnitSphere)).Normalize(); Vector3 val3 = Vector3.Lerp(insideUnitSphere, ((Vector3)(ref val2)).normalized, Configs.windStability.Value); Vector3 val4 = Vector3.Lerp(((Vector3)(ref Wind.currentBaseWind)).normalized, val3, windDirChaos); Vector3 normalized = ((Vector3)(ref val4)).normalized; float num = Mathf.Clamp(Random.Range(((Vector3)(ref val2)).magnitude - windChaos, ((Vector3)(ref val2)).magnitude + windChaos), instance.minimumMagnitude, (float)Configs.maxWindSpeed.Value); Vector3 wind = (Wind.currentBaseWind = normalized * num); instance.outCurrentBaseWind = Wind.currentBaseWind; float num2 = Mathf.InverseLerp(13000f, 500f, WeatherStorms.currentStormDistance); float num3 = 26f * num2; float num4 = Mathf.InverseLerp(1500f, 4000f, GameState.distanceToLand); float num5 = ((Vector3)(ref val2)).magnitude * num4 * 0.66f; float num6 = Mathf.Min(num3 + num5, 20f); if (num3 > 0f) { Climate_Plugin.LogInfo($"Wind: storm magnitude is {num3} lerp is {num2}"); } if (num4 > 0f) { Climate_Plugin.LogInfo($"Wind: ocean magnitude is {num5} lerp is {num4}"); } Vector3 val5 = ((Vector3)(ref Wind.currentBaseWind)).normalized * (((Vector3)(ref Wind.currentBaseWind)).magnitude + num6); ___currentWindTarget = val5; DebugProps.PressureSystemWind = WindService.WindString(val); DebugProps.PressureCellWind = WindService.WindString(windContribution); DebugProps.BaseWind = WindService.WindString(wind); DebugProps.StormWindMagnitude = $"{num3:F2}"; DebugProps.LandDistWindMagnitude = $"{num5:F2}"; return false; } } } internal class PrefabLoadingPatches { [HarmonyPatch(typeof(PrefabsDirectory), "PopulateShipItems")] internal class PrefabDirectoryPatches { public static void Prefix(PrefabsDirectory __instance) { if (__instance.directory.Length <= 826) { Array.Resize(ref __instance.directory, 826); } __instance.directory[820] = Items.Barometer; __instance.directory[821] = Items.Thermometer; __instance.directory[822] = Items.Hygrometer; __instance.directory[823] = Items.WinterWindMap; __instance.directory[824] = Items.SpringAutumnWindMap; __instance.directory[825] = Items.SummerWindMap; } } private const int NEW_PREFAB_DIR_SIZE = 826; } 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_017b: 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_01b9: 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_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0235: 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_0273: 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_02b1: 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_013b: 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_0144: 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) //IL_00ca: 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; } Transform val2 = ((IEnumerable)val.GetComponentsInChildren()).FirstOrDefault((Func)((Transform t) => ((Object)t).name == "rad shopkeeper")); if ((Object)(object)val2 == (Object)null) { Transform val3 = ((IEnumerable)val.GetComponentsInChildren()).FirstOrDefault((Func)((Transform t) => ((Object)t).name == "shop (10)")); if ((Object)(object)val3 != (Object)null) { val3.localScale = new Vector3(21.78927f, 13.92925f, 12.39353f); val3.localPosition = new Vector3(1558.77f, 8.4f, -361.33f); } Vector3 pos = default(Vector3); ((Vector3)(ref pos))..ctor(1545f, 7.21f, -361.5f); Vector3 rot = default(Vector3); ((Vector3)(ref rot))..ctor(270f, 238f, 0f); Vector3 shopkeeperPos = default(Vector3); ((Vector3)(ref shopkeeperPos))..ctor(1544f, 5.06f, -360f); Vector3 shopkeeperRot = default(Vector3); ((Vector3)(ref shopkeeperRot))..ctor(0f, 140f, 0f); AddShopStall(val, "market_stall (10)", "shop (11)", pos, rot, "shopkeeper (11)", shopkeeperPos, shopkeeperRot); } MakeShopItem("shop item 320", val.transform, new Vector3(1546.15f, 7.026f, -360.72f), new Vector3(78.5f, 325f, 0f), Items.Barometer); MakeShopItem("shop item 321", val.transform, new Vector3(1546.2f, 6.836f, -361.8f), new Vector3(78.5f, 325f, 0f), Items.Thermometer); MakeShopItem("shop item 322", val.transform, new Vector3(1547.1f, 6.836f, -361.2f), new Vector3(78.5f, 325f, 0f), Items.Hygrometer); MakeShopItem("shop item 323", val.transform, new Vector3(1543.35f, 8.196f, -361.9f), new Vector3(0f, 328f, 0f), Items.WinterWindMap); MakeShopItem("shop item 324", val.transform, new Vector3(1546.2f, 6.97f, -361f), new Vector3(77f, 328f, 20f), Items.SpringAutumnWindMap); MakeShopItem("shop item 325", val.transform, new Vector3(1546.1f, 8.196f, -360.18f), new Vector3(0f, 328f, 0f), Items.SummerWindMap); } internal static void FortAestrin() { //IL_01e0: 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_021e: 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_025c: 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_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_032a: 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_00c7: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0192: 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; } Transform val2 = ((IEnumerable)val.GetComponentsInChildren()).FirstOrDefault((Func)((Transform t) => ((Object)t).name == "rad shopkeeper")); if ((Object)(object)val2 == (Object)null) { Vector3 pos = default(Vector3); ((Vector3)(ref pos))..ctor(-47.74f, 2.26f, 44.77f); Vector3 rot = default(Vector3); ((Vector3)(ref rot))..ctor(270f, 359.7961f, 0f); Vector3 shopkeeperPos = default(Vector3); ((Vector3)(ref shopkeeperPos))..ctor(-47.74f, 2.1f, 43.5f); Vector3 shopkeeperRot = default(Vector3); ((Vector3)(ref shopkeeperRot))..ctor(0f, 359.7961f, 0f); AddShopStall(val, "market stall medi 2 (2)", "shop area (13)", pos, rot, "shopkeeper (3)", shopkeeperPos, shopkeeperRot); Transform val3 = ((IEnumerable)val.GetComponentsInChildren()).FirstOrDefault((Func)((Transform t) => ((Object)t).name == "rad shop")); val3.localScale = new Vector3(6f, 6f, 6f); Transform val4 = ((IEnumerable)val.GetComponentsInChildren()).FirstOrDefault((Func)((Transform t) => ((Object)t).name == "banner M post")); if ((Object)(object)val4 != (Object)null) { GameObject val5 = Object.Instantiate(((Component)val4).gameObject, val.transform); ((Object)val5).name = "rad banner"; val5.transform.localPosition = new Vector3(-44.5009f, 2.43f, 46.2771f); ((Renderer)val5.GetComponent()).enabled = true; ((Renderer)((Component)val5.transform.GetChild(0)).GetComponent()).enabled = true; } } MakeShopItem("shop item (320)", val.transform, new Vector3(-48.447f, 2.95f, 44.35f), new Vector3(77f, 180f, 0f), Items.Barometer); MakeShopItem("shop item (321)", val.transform, new Vector3(-48.166f, 2.85f, 44.82f), new Vector3(77f, 180f, 0f), Items.Thermometer); MakeShopItem("shop item (322)", val.transform, new Vector3(-48.716f, 2.85f, 44.82f), new Vector3(77f, 180f, 0f), Items.Hygrometer); MakeShopItem("shop item (323)", val.transform, new Vector3(-46.7f, 4.5f, 42.75f), new Vector3(0f, 180f, 0f), Items.WinterWindMap); MakeShopItem("shop item (324)", val.transform, new Vector3(-47.75f, 4.5f, 42.75f), new Vector3(0f, 180f, 0f), Items.SpringAutumnWindMap); MakeShopItem("shop item (325)", val.transform, new Vector3(-48.8f, 4.5f, 42.75f), new Vector3(0f, 180f, 0f), Items.SummerWindMap); } internal static void DragonCliffs() { //IL_00f0: 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_012e: 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_016c: 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_01aa: 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_01e8: 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_0226: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00cd: 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; } Transform val2 = ((IEnumerable)val.GetComponentsInChildren()).FirstOrDefault((Func)((Transform t) => ((Object)t).name == "rad shopkeeper")); if ((Object)(object)val2 == (Object)null) { Vector3 pos = default(Vector3); ((Vector3)(ref pos))..ctor(-73.134f, 4.68f, -552.089f); Vector3 rot = default(Vector3); ((Vector3)(ref rot))..ctor(270f, 45f, 0f); Vector3 shopkeeperPos = default(Vector3); ((Vector3)(ref shopkeeperPos))..ctor(-72.574f, 3.603f, -552.519f); Vector3 shopkeeperRot = default(Vector3); ((Vector3)(ref shopkeeperRot))..ctor(0f, 313.5019f, 0f); AddShopStall(val, "market_stall", "shop area (8)", pos, rot, "shopkeeper (3)", shopkeeperPos, shopkeeperRot); } MakeShopItem("shop item spawner (320)", val.transform, new Vector3(-73.474f, 4.6f, -552.5f), new Vector3(76f, 140f, 0f), Items.Barometer); MakeShopItem("shop item spawner (321)", val.transform, new Vector3(-73.574f, 4.502f, -552f), new Vector3(76f, 140f, 0f), Items.Thermometer); MakeShopItem("shop item spawner (322)", val.transform, new Vector3(-73.974f, 4.502f, -552.4f), new Vector3(76f, 140f, 0f), Items.Hygrometer); MakeShopItem("shop item spawner (323)", val.transform, new Vector3(-73.2f, 4.1f, -551.15f), new Vector3(0f, 135f, 0f), Items.WinterWindMap); MakeShopItem("shop item spawner (324)", val.transform, new Vector3(-73.584f, 4.58f, -552.4f), new Vector3(78f, 135f, 20f), Items.SpringAutumnWindMap); MakeShopItem("shop item spawner (325)", val.transform, new Vector3(-74.07f, 4.1f, -552.02f), new Vector3(0f, 135f, 0f), Items.SummerWindMap); } 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 AddShopStall(GameObject scenery, string templateStallName, string templateShop, Vector3 pos, Vector3 rot, string templateShopkeeper, Vector3 shopkeeperPos, Vector3 shopkeeperRot) { //IL_0060: 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_006f: 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_00ce: 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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) Transform val = scenery.GetComponentsInChildren()?.FirstOrDefault((Func)((Transform t) => ((Object)t).name == templateStallName)); GameObject val2 = Object.Instantiate(((Component)val).gameObject, scenery.transform); ((Object)val2).name = "rad market stall"; val2.transform.localPosition = pos; val2.transform.localRotation = Quaternion.Euler(rot); ((Renderer)val2.GetComponent()).enabled = true; Transform val3 = scenery.GetComponentsInChildren()?.FirstOrDefault((Func)((Transform t) => ((Object)t).name == templateShop)); GameObject val4 = Object.Instantiate(((Component)val3).gameObject, scenery.transform); val4.transform.localPosition = pos; val4.transform.localRotation = Quaternion.Euler(rot); ((Object)val4).name = "rad shop"; ShopArea component = val4.GetComponent(); component.itemsForSale.Clear(); Transform val5 = scenery.GetComponentsInChildren()?.FirstOrDefault((Func)((Transform t) => ((Object)t).name == templateShopkeeper)); GameObject val6 = Object.Instantiate(((Component)val5).gameObject, scenery.transform); val6.transform.localPosition = shopkeeperPos; val6.transform.localRotation = Quaternion.Euler(shopkeeperRot); ((Object)val6).name = "rad shopkeeper"; val6.SetPrivateField("shopLocalPos", pos); val6.SetPrivateField("shopRotation", Quaternion.Euler(rot)); component.SetPrivateField("shopkeeper", val6.GetComponent()); val6.SetPrivateField("shop", component); } } public class ShipItemBarometer : ShipItem { private readonly float _minAngle = -118f; private readonly float _maxAngle = 240f; private readonly float _smoothingK = -6f; private readonly float _sampleInterval = 1f; private Transform _needle; private float _sampleTimer; private float _smoothedAngle; private float _pressure; public override void OnLoad() { _needle = (from t in ((Component)this).gameObject.GetComponentsInChildren(true) where ((Object)t).name == "Needle" select t).FirstOrDefault(); SamplePressure(); } public override void ExtraLateUpdate() { _sampleTimer += Time.deltaTime; if (_sampleTimer >= _sampleInterval) { _sampleTimer = 0f; SamplePressure(); } UpdateNeedle(); } private void SamplePressure() { //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); _pressure = PressureService.GetNormalizedPressure(globeCoords, 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, _pressure); _smoothedAngle = Mathf.Lerp(_smoothedAngle, num, 1f - Mathf.Exp(_smoothingK * Time.deltaTime)); _needle.localRotation = Quaternion.Euler(_smoothedAngle, -90f, 90f); } } } public class ShipItemHygrometer : ShipItem { private readonly float _minAngle = -45f; private readonly float _maxAngle = 225f; private readonly float _smoothingK = -2f; private readonly float _sampleInterval = 1f; private Transform _needle; private float _sampleTimer; private float _smoothedAngle; private float _humidity; public override void OnLoad() { _needle = (from t in ((Component)this).gameObject.GetComponentsInChildren(true) where ((Object)t).name == "Needle" select t).FirstOrDefault(); 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 readonly float _minAngle = -45f; private readonly float _maxAngle = 225f; private readonly float _smoothingK = -2f; private readonly float _sampleInterval = 1f; private Transform _needle; private float _sampleTimer; private float _smoothedAngle; private float _temperature; public override void OnLoad() { _needle = (from t in ((Component)this).gameObject.GetComponentsInChildren(true) where ((Object)t).name == "Needle" select t).FirstOrDefault(); 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 DEW_POINT_NOISE_AMP = 3f; private static float NoiseFreq => (Configs.yearLength.Value == 92) ? 0.397f : 0.1f; internal static float GetDewPoint(Vector3 coords, int day) { //IL_0001: 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) ClimateProfile profile = ClimateZones.GetProfile(coords); float num = ClimateZones.GetSeasonalFactor(day) * profile.seasonalDewAmplitude; float num2 = (Mathf.PerlinNoise((float)day * ClimateProfile.AirMassFreq, profile.airmassNoiseSeed) - 0.5f) * 2f; float num3 = (Mathf.PerlinNoise((float)day * NoiseFreq, profile.dewNoiseSeed) - 0.5f) * 2f; float num4 = (num2 * ClimateProfile.NOISE_CORRELATION + num3 * (1f - ClimateProfile.NOISE_CORRELATION)) * 3f; return profile.baseDew + num + num4 + GetPressureCellMoisture(coords, day); } internal static float GetPressureCellMoisture(Vector3 coords, int day) { //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_0061: 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_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_007b: 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_007e: 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) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(coords.z, coords.x); float num = 0f; foreach (PressureCell cell in PressureCell.cells) { int num2 = day - cell.spawnDay; if (!((float)num2 < 0f) && num2 <= cell.lifespanDays) { Vector2 val2 = cell.origin + cell.velocity * (float)num2; Vector2 val3 = val - val2; float sqrMagnitude = ((Vector2)(ref val3)).sqrMagnitude; if (!(sqrMagnitude >= cell.radius * cell.radius)) { float num3 = 1f - Mathf.Sqrt(sqrMagnitude) / cell.radius; float num4 = Mathf.Sin((float)Math.PI * (float)num2 / (float)cell.lifespanDays); num += cell.moistureDelta * num3 * num3 * num4; } } } return num; } } internal static class HumidityService { private const float MIN_HUMIDITY = 0.05f; private const float MAX_HUMIDITY = 1f; internal static float GetRelativeHumidity(Vector3 coords, float time, int day, float temp = -100f) { //IL_0017: 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) if (temp == -100f) { temp = TemperatureService.GetTemperature(coords, time, day); } float dewPoint = DewPointService.GetDewPoint(coords, day); dewPoint = Mathf.Min(dewPoint, temp); return Mathf.Clamp(MagnusRH(temp, 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 static class PressureService { private const float MIN_PRESSURE = 26f; private const float MAX_PRESSURE = 31.9f; private const float BASELINE = 29.7f; private const float LIFT_ONSET = 0.6f; private const float LIFT_FULL = 0.3f; private const float STABILITY_ONSET = 0.3f; private const float STABILITY_FULL = 0.6f; internal static float CurrentStormRadius { get; set; } internal static float NormalizedDistanceToStorm { get; set; } internal static float CurrentStormRange { get; set; } internal static float GetPressure(Vector3 coords, int day, bool includeStorm = true) { //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_0061: 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_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_007b: 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_007e: 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) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(coords.z, coords.x); float num = 29.7f; foreach (PressureCell cell in PressureCell.cells) { int num2 = day - cell.spawnDay; if (!((float)num2 < 0f) && num2 <= cell.lifespanDays) { Vector2 val2 = cell.origin + cell.velocity * (float)num2; Vector2 val3 = val - val2; float sqrMagnitude = ((Vector2)(ref val3)).sqrMagnitude; if (!(sqrMagnitude >= cell.radius * cell.radius)) { float num3 = 1f - Mathf.Sqrt(sqrMagnitude) / cell.radius; float num4 = Mathf.Sin((float)Math.PI * (float)num2 / (float)cell.lifespanDays); num += cell.intensity * num3 * num3 * num4; } } } if (includeStorm) { num -= GetStormDip(); } return Mathf.Clamp(num, 26f, 31.9f); } internal static float GetStormDip() { if (CurrentStormRadius <= 0f) { return 0f; } float result; if (NormalizedDistanceToStorm <= 0f) { float num = Mathf.Clamp01(WeatherStorms.currentStormDistance / CurrentStormRadius); result = Mathf.Lerp(3.7f, 2.05f, num); } else { result = Mathf.Lerp(2.05f, 0f, NormalizedDistanceToStorm); } return result; } internal static float GetNormalizedPressure(Vector3 coords, int day, bool includeStorm = true) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) float pressure = GetPressure(coords, day, includeStorm); return Mathf.InverseLerp(26f, 31.9f, pressure); } internal static float GetLiftFactor(Vector3 coords, int day) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) return Mathf.InverseLerp(0.6f, 0.3f, GetNormalizedPressure(coords, day)); } internal static float GetStabilizingFactor(Vector3 coords, int day) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) return Mathf.InverseLerp(0.3f, 0.6f, GetNormalizedPressure(coords, day)); } } internal static class EffectsService { private const float RH_RAIN_ONSET = 0.9f; private const float RH_RAIN_SATURATED = 0.99f; private const float RH_CLOUD_ONSET = 0.75f; private const float RH_CLOUD_SATURATED = 0.95f; private const float SPREAD_THRESHOLD = 2f; private const float FULL_FOG_SPREAD = 1f; private const float MAX_PHYSICAL_RAIN = 5f; private const float MAX_PHYSICAL_CLOUD_DENSITY = 6f; private const float MAX_PHYSICAL_FOG_DENSITY = 0.01f; internal static float GetFogDensity(float temp, float dew, float stabilityFactor) { float num = temp - dew; float num2 = Mathf.InverseLerp(2f, 1f, num); return num2 * stabilityFactor * 0.01f; } internal static float GetPhysicalRainDensity(float relativeHumidity, float liftFactor) { float num = Mathf.InverseLerp(0.9f, 0.99f, relativeHumidity); return num * Mathf.Clamp01(liftFactor) * 5f; } internal static float GetPhysicalCloudDensity(float relativeHumidity, float liftFactor) { float num = Mathf.InverseLerp(0.75f, 0.95f, relativeHumidity); return num * Mathf.Clamp01(liftFactor) * 6f; } } internal static class TemperatureService { private const float MIN_TEMP = -12.2222f; private const float MAX_TEMP = 46.1111f; private const float NOISE_AMP = 3.8889f; private const float REF_LAT = 31f; private const float REF_TEMP = 30f; private const float TEMP_LAT_CONV = 1.2f; private const float LOW_PRESSURE_COOLING_MAX = 4f; private const float RADIATIVE_COOLING_MAX = 7f; private const float NIGHT_LENGTH_HOURS = 12f; private const float MIN_DIURNAL_AMPLITUDE = 1f; private const float MAX_DIURNAL_AMPLITUDE = 8f; private static float NoiseFreq => (Configs.yearLength.Value == 92) ? 0.595f : 0.15f; 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) //IL_0039: 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_0117: 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.InverseLerp(0f, 90f, Mathf.Abs(coords.z)); float num4 = Mathf.Lerp(1f, 8f, num3); float num5 = Mathf.Sin(time / 24f * (float)Math.PI * 2f - (float)Math.PI / 2f) * (num4 / 2f); float num6 = (Mathf.PerlinNoise((float)day * ClimateProfile.AirMassFreq, profile.airmassNoiseSeed) - 0.5f) * 2f; float num7 = (Mathf.PerlinNoise((float)day * NoiseFreq, profile.tempNoiseSeed) - 0.5f) * 2f; float num8 = (num6 * ClimateProfile.NOISE_CORRELATION + num7 * (1f - ClimateProfile.NOISE_CORRELATION)) * 3.8889f; float num9 = num + num2 + num5 + num8; float normalizedPressure = PressureService.GetNormalizedPressure(coords, day); float num10 = (1f - normalizedPressure) * 4f * profile.pressureCoolingFactor; float num11 = 1f - HumidityService.GetRelativeHumidity(coords, time, day, num9); float num12 = normalizedPressure * num11 * 7f * GetNightProgress(time); return num9 - num10 - num12; } private static float GetNightProgress(float time) { if (time > 6f && time < 18f) { return 0f; } float num = (time + 6f) % 24f; return Mathf.SmoothStep(0f, 1f, num / 12f); } 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(-12.2222f, 46.1111f, temperature); } } internal static class WindService { private const float INFLOW_ANGLE_DEG = 15f; public static int minLatitude = 25; public static int maxLatitude = 50; public static int minLongitude = -15; public static int maxLongitude = 35; internal static Vector3[,] windGrid = new Vector3[maxLatitude - minLatitude + 1, maxLongitude - minLongitude + 1]; internal static void UpdateDailyWindField() { //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) int num = maxLatitude - minLatitude + 1; int num2 = maxLongitude - minLongitude + 1; if (windGrid.GetLength(0) != num || windGrid.GetLength(1) != num2) { Climate_Plugin.LogDebug($"Resizing windGrid to {num}x{num2}"); windGrid = new Vector3[num, num2]; } int value = Configs.maxWindSpeed.Value; float num3 = (float)Math.PI / 12f; float num4 = Mathf.Cos(num3); float num5 = Mathf.Sin(num3); for (int i = minLatitude; i <= maxLatitude; i++) { for (int j = minLongitude; j <= maxLongitude; j++) { float num6 = 0f; float num7 = 0f; foreach (PressureSystem system in PressureSystem.systems) { system.Gradient(j, i, GameState.day, out var dPdx, out var dPdy); num6 += dPdx; num7 += dPdy; } float num8 = (float)(-value) * num7; float num9 = (float)value * num6; float num10 = num8 * num4 - num9 * num5; float num11 = num8 * num5 + num9 * num4; windGrid[i - minLatitude, j - minLongitude] = new Vector3(num10, 0f, num11); } } } internal static Vector3 SampleWind(Vector3 coords) { //IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references) return SampleWind(coords.z, coords.x); } internal static Vector3 SampleWind(float lat, float lon) { //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_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_0059: Unknown result type (might be due to invalid IL or missing references) if (lat > (float)maxLatitude || lat < (float)minLatitude || lon < (float)minLongitude || lon > (float)maxLongitude) { return Vector3.zero; } return windGrid[Mathf.RoundToInt(lat) - minLatitude, Mathf.RoundToInt(lon) - minLongitude]; } public static float GetMaxWindSpeed() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) float num = 0f; Vector3[,] array = windGrid; int upperBound = array.GetUpperBound(0); int upperBound2 = array.GetUpperBound(1); for (int i = array.GetLowerBound(0); i <= upperBound; i++) { for (int j = array.GetLowerBound(1); j <= upperBound2; j++) { Vector3 val = array[i, j]; if (((Vector3)(ref val)).magnitude > num) { num = ((Vector3)(ref val)).magnitude; } } } return num; } public static float GetMinWindSpeed() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) float num = 100f; Vector3[,] array = windGrid; int upperBound = array.GetUpperBound(0); int upperBound2 = array.GetUpperBound(1); for (int i = array.GetLowerBound(0); i <= upperBound; i++) { for (int j = array.GetLowerBound(1); j <= upperBound2; j++) { Vector3 val = array[i, j]; if (((Vector3)(ref val)).magnitude < num) { num = ((Vector3)(ref val)).magnitude; } } } return num; } public static void CheckWindVector() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_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_002a: 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_0048: 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) Vector3 globeCoords = FloatingOriginManager.instance.GetGlobeCoords(((Component)Refs.observerMirror).transform); Vector3 val = SampleWind(globeCoords); Climate_Plugin.LogDebug($"Wind check at lat: {globeCoords.z}, lon: {globeCoords.x} - direction:{((Vector3)(ref val)).normalized} {GetWindDirectionDegrees(((Vector3)(ref val)).normalized)} magnitude: {((Vector3)(ref val)).magnitude}"); } public static void WriteWindGridToFile(bool magnitude = false, bool normalized = false, bool degrees = false) { //IL_00a3: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_0157: 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) string text = Path.Combine(Application.persistentDataPath, "windGrid.csv"); int num = windGrid.GetLength(0) - 1; int length = windGrid.GetLength(1); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(" ,"); stringBuilder.AppendLine(string.Join(",", Enumerable.Range(minLongitude, maxLongitude - minLongitude + 1).ToList())); for (int num2 = num; num2 >= 0; num2--) { stringBuilder.Append($"{minLatitude + num2},"); for (int i = 0; i < length; i++) { Vector3 val = windGrid[num2, i]; if (normalized && !magnitude && !degrees) { stringBuilder.Append(((Vector3)(ref val)).normalized); } else if (magnitude && !normalized && !degrees) { stringBuilder.Append($"{((Vector3)(ref val)).magnitude}"); } else if (degrees && !normalized && !magnitude) { stringBuilder.Append($"{GetWindDirectionDegrees(val)}"); } else { stringBuilder.Append($"{val.x} {val.y} {val.z}"); } if (i < length - 1) { stringBuilder.Append(','); } } stringBuilder.Append('\n'); } try { File.WriteAllText(text, stringBuilder.ToString()); Climate_Plugin.LogDebug($"[WindGridExporter] Wrote {num}x{length} wind speed grid to {text}"); } catch (IOException ex) { Climate_Plugin.LogError("[WindGridExporter] Failed to write wind grid to " + text + ": " + ex.Message); } } internal static float GetWindDirectionDegrees(Vector3 dir) { //IL_0001: 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) float num = Mathf.Atan2(dir.x, dir.z) * 57.29578f; return (num + 360f + 180f) % 360f; } internal static string WindString(Vector3 wind) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return $"{GetWindDirectionDegrees(((Vector3)(ref wind)).normalized):F2} {((Vector3)(ref wind)).magnitude:F2}"; } private static string GetWindArrow(Vector3 dir) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) float windDirectionDegrees = GetWindDirectionDegrees(dir); if (windDirectionDegrees >= 348.75f || windDirectionDegrees < 11.25f) { return "↑"; } if (windDirectionDegrees < 33.75f) { return "N↗"; } if (windDirectionDegrees < 56.25f) { return "↗"; } if (windDirectionDegrees < 78.75f) { return "E↗"; } if (windDirectionDegrees < 101.25f) { return "→"; } if (windDirectionDegrees < 123.75f) { return "E↘"; } if (windDirectionDegrees < 146.25f) { return "↘"; } if (windDirectionDegrees < 168.75f) { return "S↘"; } if (windDirectionDegrees < 191.25f) { return "↓"; } if (windDirectionDegrees < 213.75f) { return "S↙"; } if (windDirectionDegrees < 236.25f) { return "↙"; } if (windDirectionDegrees < 258.75f) { return "W↙"; } if (windDirectionDegrees < 281.25f) { return "←"; } if (windDirectionDegrees < 303.75f) { return "W↖"; } if (windDirectionDegrees < 326.25f) { return "↖"; } if (windDirectionDegrees < 348.75f) { return "N↖"; } return "↑"; } } internal class DateTextUI { internal static TextMesh textMesh; internal static void UpdateDateText() { int num = GameState.day % Configs.yearLength.Value; int num2 = GameState.day / Configs.yearLength.Value; if (Configs.yearLength.Value == 365) { textMesh.text = $"Year: {num2} Day: {num}"; return; } int num3 = Mathf.FloorToInt((float)(Configs.yearLength.Value / 4)); GetSeasonInfo(num, num3, out var season, out var seasonDay); textMesh.text = $"Year: {num2} Day: {num} {season} ({seasonDay}/{num3})"; } private static void GetSeasonInfo(int day, int daysPerSeason, out string season, out int seasonDay) { if (day < daysPerSeason) { season = "Winter"; seasonDay = day + 1; } else if (day < 2 * daysPerSeason) { season = "Spring"; seasonDay = day - daysPerSeason + 1; } else if (day < 3 * daysPerSeason) { season = "Summer"; seasonDay = day - 2 * daysPerSeason + 1; } else { season = "Autumn"; seasonDay = day - 3 * daysPerSeason + 1; } } } 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); Object? obj4 = ((IEnumerable)request.allAssets).FirstOrDefault((Func)((Object a) => a.name == "winter wind map")); Items.WinterWindMap = (GameObject)(object)((obj4 is GameObject) ? obj4 : null); Object? obj5 = ((IEnumerable)request.allAssets).FirstOrDefault((Func)((Object a) => a.name == "spring & autumn wind map")); Items.SpringAutumnWindMap = (GameObject)(object)((obj5 is GameObject) ? obj5 : null); Object? obj6 = ((IEnumerable)request.allAssets).FirstOrDefault((Func)((Object a) => a.name == "summer wind map")); Items.SummerWindMap = (GameObject)(object)((obj6 is GameObject) ? obj6 : null); if ((Object)(object)Items.Barometer == (Object)null || (Object)(object)Items.Thermometer == (Object)null || (Object)(object)Items.Hygrometer == (Object)null || (Object)(object)Items.WinterWindMap == (Object)null || (Object)(object)Items.SpringAutumnWindMap == (Object)null || (Object)(object)Items.SummerWindMap == (Object)null) { Climate_Plugin.LogError("Failed to load all required assets from the bundle"); yield break; } Climate_Plugin.LogInfo("Assets loaded"); Items.Initialize(); } } internal static class ClimateZones { internal static readonly ClimateProfile AlAnkh = new ClimateProfile(-2f, 6f, 2f, 1f); internal static readonly ClimateProfile Emerald = new ClimateProfile(23f, 1.5f, 1f, 0.3f); internal static readonly ClimateProfile Aestrin = new ClimateProfile(10f, 8f, 6f, 0.6f); private const float BLEND_BUFFER = 1.5f; private const float AA_EA_LON = -0.18f; private const float AESTRIN_LAT = 35.2f; private static int PeakDay => (Configs.yearLength.Value == 92) ? 43 : 172; internal 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.6800001f) || !(x < 1.3199999f)) { climateProfile = ((!(x < -0.18f)) ? Emerald : AlAnkh); } else { float t = Mathf.InverseLerp(-1.6800001f, 1.3199999f, x); climateProfile = Lerp(AlAnkh, Emerald, t); } if (z > 33.7f && z < 36.7f) { float t2 = Mathf.InverseLerp(33.7f, 36.7f, z); return Lerp(climateProfile, Aestrin, t2); } return (z > 35.2f) ? Aestrin : climateProfile; } private static ClimateProfile Lerp(ClimateProfile a, ClimateProfile b, float t) { return new ClimateProfile(Mathf.Lerp(a.baseDew, b.baseDew, t), Mathf.Lerp(a.seasonalTempAmplitude, b.seasonalTempAmplitude, t), Mathf.Lerp(a.seasonalDewAmplitude, b.seasonalDewAmplitude, t), Mathf.Lerp(a.pressureCoolingFactor, b.pressureCoolingFactor, t)); } internal static float GetSeasonalFactor(int day) { int num = day % Configs.yearLength.Value; return Mathf.Cos((float)Math.PI * 2f * (float)(num - PeakDay) / (float)Configs.yearLength.Value); } } internal class Configs { internal static ConfigEntry yearLength; internal static ConfigEntry enableWinds; internal static ConfigEntry maxWindSpeed; internal static ConfigEntry windStability; internal static ConfigEntry pressureCellmaxWindContr; internal static void InitializeConfigs() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown ConfigFile config = ((BaseUnityPlugin)Climate_Plugin.Instance).Config; string text = "The length of a year in days. Affects the length of seasons and the timing of weather patterns."; yearLength = config.Bind("Settings", "Days In A Year", 92, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueList(new int[2] { 92, 365 }), Array.Empty())); enableWinds = config.Bind("Settings", "Enable Custom Winds", true, "Disables the default wind system and enables the custom wind system."); string text2 = "The maximum possible trade wind speed. Other factors will also influence this speed, think of this as the maximum baseline wind speed. You will need to wait until midnight or save and reload the game for changes to take effect."; maxWindSpeed = config.Bind("Wind Settings", "Maximum Trade Wind Speed", 22, new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange(1, 40), Array.Empty())); string text3 = "This is the maximum wind speed that can be added to the base trade winds from a pressure cell."; pressureCellmaxWindContr = config.Bind("Wind Settings", "Pressure Cell Max Wind Contribution", 8, new ConfigDescription(text3, (AcceptableValueBase)(object)new AcceptableValueRange(1, 20), Array.Empty())); string text4 = "A value of 0 means the winds are completely chaotic, while a value of 1 means the winds will nearly always align with the trade winds. Base game has this set to 0.25."; windStability = config.Bind("Wind Settings", "Wind Stability", 0.45f, new ConfigDescription(text4, (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); } } internal class DebugProps { internal static Vector3[,] WindGrid => WindService.windGrid; internal static List PressureCells => PressureCell.cells; public static float FogDensity { get; internal set; } public static float TargetFogDensity { get; internal set; } public static float RainIntensity { get; internal set; } public static float TargetRainIntensity { get; internal set; } public static float CloudRate { get; internal set; } public static float TargetCloudRate { get; internal set; } public static bool ApplyingFogDensity { get; internal set; } public static bool ApplyingRainIntensity { get; internal set; } public static bool ApplyingCloudRate { get; internal set; } public static string PressureSystemWind { get; internal set; } public static string PressureCellWind { get; internal set; } public static string BaseWind { get; internal set; } public static string StormWindMagnitude { get; internal set; } public static string LandDistWindMagnitude { get; internal set; } public static float GetMaxWindSpeed() { return WindService.GetMaxWindSpeed(); } public static float GetMinWindSpeed() { return WindService.GetMinWindSpeed(); } public static void WriteWindGridToFile() { WindService.WriteWindGridToFile(); } public static void WriteWindGridNormalizedToFile() { WindService.WriteWindGridToFile(magnitude: false, normalized: true); } public static void WriteWindGridMagnitudeToFile() { WindService.WriteWindGridToFile(magnitude: true); } public static void WriteWindGridDegreesToFile() { WindService.WriteWindGridToFile(magnitude: false, normalized: false, degrees: true); } public static void CheckWindVector() { WindService.CheckWindVector(); } public static void CheckPressureCellWindContribution() { PressureCell.CheckPressureCellWindContribution(); } public static void CheckPressureSystemInfluence() { PressureSystem.CheckPressureSystemInfluence(); } } internal static class Extensions { public static void SetPrivateField(this object obj, string field, object value) { Traverse.Create(obj).Field(field).SetValue(value); } } internal interface IModDataSaveable { string SaveString(); } internal class Items { public static GameObject Barometer { get; internal set; } public static GameObject Thermometer { get; internal set; } public static GameObject Hygrometer { get; internal set; } public static GameObject WinterWindMap { get; internal set; } public static GameObject SpringAutumnWindMap { get; internal set; } public static GameObject SummerWindMap { 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(); } } internal class ModData { public static void AddListEntry(string dataName, IModDataSaveable[] data) { StringBuilder stringBuilder = new StringBuilder(); foreach (IModDataSaveable modDataSaveable in data) { stringBuilder.AppendLine(modDataSaveable.SaveString() ?? ""); } string value = stringBuilder.ToString(); if (GameState.modData.ContainsKey(dataName)) { GameState.modData[dataName] = value; } else { GameState.modData.Add(dataName, value); } } public static List GetPressureCellListEntry(string dataName) { //IL_00b9: 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_00e0: 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) List list = new List(); if (!GameState.modData.ContainsKey(dataName)) { Climate_Plugin.LogWarning("GetModDataEntry: " + dataName + " not found in modData"); return list; } string text = GameState.modData[dataName]; string[] array = text.Split(new char[1] { '\n' }, StringSplitOptions.RemoveEmptyEntries); string[] array2 = array; foreach (string text2 in array2) { string[] array3 = text2.Trim().Split(new char[1] { '|' }); if (array3.Length >= 9) { PressureCell item = new PressureCell { origin = new Vector2(float.Parse(array3[0], CultureInfo.InvariantCulture), float.Parse(array3[1], CultureInfo.InvariantCulture)), velocity = new Vector2(float.Parse(array3[2], CultureInfo.InvariantCulture), float.Parse(array3[3], CultureInfo.InvariantCulture)), radius = float.Parse(array3[4], CultureInfo.InvariantCulture), intensity = float.Parse(array3[5], CultureInfo.InvariantCulture), moistureDelta = float.Parse(array3[6], CultureInfo.InvariantCulture), spawnDay = int.Parse(array3[7]), lifespanDays = int.Parse(array3[8]) }; list.Add(item); } } return list; } public static List GetPressureSystemListEntry(string dataName) { List list = new List(); if (!GameState.modData.ContainsKey(dataName)) { Climate_Plugin.LogWarning("GetModDataEntry: " + dataName + " not found in modData"); return list; } string text = GameState.modData[dataName]; string[] array = text.Split(new char[1] { '\n' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Trim().Split(new char[1] { '|' }); if (array2.Length >= 3) { PressureSystemSaveData item = new PressureSystemSaveData(float.Parse(array2[0], CultureInfo.InvariantCulture), float.Parse(array2[1], CultureInfo.InvariantCulture), float.Parse(array2[2], CultureInfo.InvariantCulture)); list.Add(item); } } return list; } } } namespace Climate.API { public static class WeatherService { private static Vector3 PlayerPos => FloatingOriginManager.instance.GetGlobeCoords(((Component)Refs.observerMirror).transform); private static float TimeNow => Sun.sun.localTime; private static int DayNow => GameState.day; private static float CurrentWind => ((Vector3)(ref Wind.currentWind)).magnitude; public static float GetNormalizedPressure(Vector3 coords, int day, bool includeStorm = true) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return PressureService.GetNormalizedPressure(coords, day, includeStorm); } public static float GetNormalizedPressure(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetNormalizedPressure(coords, DayNow); } public static float GetNormalizedPressure() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetNormalizedPressure(PlayerPos); } public static float GetPressureMb(Vector3 coords, int day, bool includeStorm = true) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ConvertInHgToMb(GetPressureInHg(coords, day, includeStorm)); } public static float GetPressureMb(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ConvertInHgToMb(GetPressureInHg(coords)); } public static float GetPressureMb() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ConvertInHgToMb(GetPressureInHg(PlayerPos)); } public static float GetPressureInHg(Vector3 coords, int day, bool includeStorm = true) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return PressureService.GetPressure(coords, day, includeStorm); } public static float GetPressureInHg(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetPressureInHg(coords, DayNow); } public static float GetPressureInHg() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetPressureInHg(PlayerPos, DayNow); } 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 GetNormalizedTemperature(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetNormalizedTemperature(coords, TimeNow, DayNow); } public static float GetNormalizedTemperature() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetNormalizedTemperature(PlayerPos, TimeNow, DayNow); } 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 GetTemperatureC(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetTemperatureC(coords, TimeNow, DayNow); } public static float GetTemperatureC() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetTemperatureC(PlayerPos, TimeNow, DayNow); } 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 GetTemperatureF(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ConvertCtoF(GetTemperatureC(coords)); } public static float GetTemperatureF() { return ConvertCtoF(GetTemperatureC()); } 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 GetWindChillC(Vector3 coords) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return GetWindChillC(CurrentWind, coords, TimeNow, DayNow); } public static float GetWindChillC() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetWindChillC(PlayerPos); } 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 GetWindChillF(Vector3 coords) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return GetWindChillF(CurrentWind, coords, TimeNow, DayNow); } public static float GetWindChillF() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return GetWindChillF(CurrentWind, PlayerPos, TimeNow, DayNow); } 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 GetHeatIndexC(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetHeatIndexC(coords, TimeNow, DayNow); } public static float GetHeatIndexC() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetHeatIndexC(PlayerPos); } 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 GetHeatIndexF(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetHeatIndexF(coords, TimeNow, DayNow); } public static float GetHeatIndexF() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetHeatIndexF(PlayerPos, TimeNow, DayNow); } 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 GetApparentTemperatureC(Vector3 coords) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return GetApparentTemperatureC(CurrentWind, coords, TimeNow, DayNow); } public static float GetApparentTemperatureC() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetApparentTemperatureC(PlayerPos); } 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 GetApparentTemperatureF(Vector3 coords) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return GetApparentTemperatureF(CurrentWind, coords, TimeNow, DayNow); } public static float GetApparentTemperatureF() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetApparentTemperatureF(PlayerPos); } 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 GetRelativeHumidity(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetRelativeHumidity(coords, TimeNow, DayNow); } public static float GetRelativeHumidity() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetRelativeHumidity(PlayerPos); } 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 GetDewPointC(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetDewPointC(coords, DayNow); } public static float GetDewPointC() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetDewPointC(PlayerPos); } 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 GetDewPointF(Vector3 coords) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetDewPointF(coords, DayNow); } public static float GetDewPointF() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetDewPointF(PlayerPos); } 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; } } } namespace Climate.Patches { internal class SaveLoadPatches { [HarmonyPatch(typeof(SaveLoadManager))] private class SaveLoadManagerPatches { [HarmonyPrefix] [HarmonyPatch("SaveModData")] public static void SaveModData() { PressureSystem.SavePressureSystems(); PressureCell.SavePressureCells(); } [HarmonyPrefix] [HarmonyPatch("LoadModData")] public static void LoadModData() { PressureSystem.LoadPressureSystems(); PressureCell.LoadPressureCells(); DateTextUI.UpdateDateText(); } } } }