Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of FroggosAtmospherics v1.0.0
Mods/Froggos-Atmospherics.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading.Tasks; using FroggosAtmospherics; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.GameTime; using Il2CppScheduleOne.Map; using Il2CppScheduleOne.PlayerScripts; using Il2CppScheduleOne.UI; using Il2CppScheduleOne.Weather; using Il2CppStylizedWater2; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Reflection; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(AtmosphericsMod), "Froggos-Atmospherics", "1.0.0", "froggonater", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("Froggos-Atmospherics")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Froggos-Atmospherics")] [assembly: AssemblyTitle("Froggos-Atmospherics")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] internal sealed class IsUnmanagedAttribute : Attribute { } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace FroggosAtmospherics { internal sealed class AtmoConfig { public readonly MelonPreferences_Entry<bool> Ocean; public readonly MelonPreferences_Entry<float> DayWaveHeight; public readonly MelonPreferences_Entry<float> NightWaveHeight; public readonly MelonPreferences_Entry<float> NightWaveSpeed; public readonly MelonPreferences_Entry<float> NightStartHour; public readonly MelonPreferences_Entry<float> DayStartHour; public readonly MelonPreferences_Entry<float> TransitionHours; public readonly MelonPreferences_Entry<float> WindDirection; public readonly MelonPreferences_Entry<int> OceanDetail; public readonly MelonPreferences_Entry<bool> RealisticColors; public readonly MelonPreferences_Entry<bool> Reflections; public readonly MelonPreferences_Entry<float> ReflectionQuality; public readonly MelonPreferences_Entry<float> ReflectionDistance; public readonly MelonPreferences_Entry<bool> Swimming; public readonly MelonPreferences_Entry<float> SwimSpeed; public readonly MelonPreferences_Entry<float> MaxDiveDepth; public readonly MelonPreferences_Entry<float> MaxSwimDistance; public readonly MelonPreferences_Entry<bool> UnderwaterEffects; public readonly MelonPreferences_Entry<bool> VerboseLogging; public readonly MelonPreferences_Entry<bool> Lighting; public readonly MelonPreferences_Entry<bool> RealisticSunPath; public readonly MelonPreferences_Entry<float> SunPathTilt; public readonly MelonPreferences_Entry<float> NorthHeading; public readonly MelonPreferences_Entry<float> SunsetStrength; public readonly MelonPreferences_Entry<int> ShadowQuality; public readonly MelonPreferences_Entry<float> ShadowDistance; public readonly MelonPreferences_Entry<int> SkyQuality; public readonly MelonPreferences_Entry<float> CloudSpeed; public readonly MelonPreferences_Entry<bool> ReflectVegetation; public readonly MelonPreferences_Entry<bool> ReflectionShadows; public readonly MelonPreferences_Entry<bool> ReflectionEffects; public readonly MelonPreferences_Entry<bool> ScreenSpaceReflections; public readonly MelonPreferences_Entry<bool> Whitecaps; public readonly MelonPreferences_Entry<float> WaterColorVariety; public readonly MelonPreferences_Entry<bool> SeaFloorCollision; private readonly MelonPreferences_Entry<int> _version; public AtmoConfig() { MelonPreferences_Category val = MelonPreferences.CreateCategory("FroggosAtmospherics", "Froggos Atmospherics"); Ocean = val.CreateEntry<bool>("Ocean", true, "Realistic ocean", "Replace the sea with a rolling, wave-animated ocean surface.", false, false, (ValueValidator)null, (string)null); DayWaveHeight = val.CreateEntry<float>("DayWaveHeight", 1f, "Day wave height", "Wave size during the day (1 = a moderate swell of about a metre, 2 = rough sea, 0 = flat).", false, false, (ValueValidator)null, (string)null); NightWaveHeight = val.CreateEntry<float>("NightWaveHeight", 0.08f, "Night wave height", "Wave size at night, as a fraction of a normal swell. 0 = dead calm, glassy water.", false, false, (ValueValidator)null, (string)null); NightWaveSpeed = val.CreateEntry<float>("NightWaveSpeed", 0.4f, "Night wave speed", "How fast what's left of the waves moves at night (1 = same as day).", false, false, (ValueValidator)null, (string)null); NightStartHour = val.CreateEntry<float>("NightStartHour", 20f, "Night starts (hour)", "Hour (0-24) the sea starts calming down. 20 = 8:00 PM.", false, false, (ValueValidator)null, (string)null); DayStartHour = val.CreateEntry<float>("DayStartHour", 5.5f, "Day starts (hour)", "Hour (0-24) the waves start picking back up. 5.5 = 5:30 AM.", false, false, (ValueValidator)null, (string)null); TransitionHours = val.CreateEntry<float>("TransitionHours", 1.5f, "Transition (hours)", "In-game hours the sea takes to calm down or pick up.", false, false, (ValueValidator)null, (string)null); WindDirection = val.CreateEntry<float>("WindDirection", 25f, "Wind direction", "Compass heading (degrees) the swell travels towards.", false, false, (ValueValidator)null, (string)null); OceanDetail = val.CreateEntry<int>("OceanDetail", 0, "Ocean detail", "Ocean mesh vertices per side (96 - 320). 0 = follow the game's graphics quality (Low 112, Medium 160, High 208, Ultra 256).", false, false, (ValueValidator)null, (string)null); RealisticColors = val.CreateEntry<bool>("RealisticColors", true, "Realistic colours", "Deep blue-green sea with depth-based shallows. Off keeps the game's own water colours.", false, false, (ValueValidator)null, (string)null); Reflections = val.CreateEntry<bool>("Reflections", true, "Reflections", "Mirror the world (buildings, sky, lights) in the water.", false, false, (ValueValidator)null, (string)null); ReflectionQuality = val.CreateEntry<float>("ReflectionQuality", 0.6f, "Reflection quality", "Reflection resolution as a fraction of the screen (0.25 - 1). Lower it if reflections cost you frames.", false, false, (ValueValidator)null, (string)null); ReflectionDistance = val.CreateEntry<float>("ReflectionDistance", 500f, "Reflection distance", "How far away (m) objects still show up in reflections.", false, false, (ValueValidator)null, (string)null); Swimming = val.CreateEntry<bool>("Swimming", true, "Swimming", "Swim and dive in the sea instead of being warped back to shore.", false, false, (ValueValidator)null, (string)null); SwimSpeed = val.CreateEntry<float>("SwimSpeed", 5f, "Swim speed", "Swimming speed in m/s. Sprint swims 50% faster.", false, false, (ValueValidator)null, (string)null); MaxDiveDepth = val.CreateEntry<float>("MaxDiveDepth", 18f, "Max dive depth", "How deep (m) you can dive below the surface.", false, false, (ValueValidator)null, (string)null); MaxSwimDistance = val.CreateEntry<float>("MaxSwimDistance", 300f, "Max swim distance", "How far (m) you can swim from where you got in before the current pushes you back.", false, false, (ValueValidator)null, (string)null); UnderwaterEffects = val.CreateEntry<bool>("UnderwaterEffects", true, "Underwater effects", "Blue-green fog, tint and muffled sound with your head under water.", false, false, (ValueValidator)null, (string)null); ReflectVegetation = val.CreateEntry<bool>("ReflectVegetation", true, "Reflect trees", "Show trees and plants in the water's reflections.", false, false, (ValueValidator)null, (string)null); ReflectionShadows = val.CreateEntry<bool>("ReflectionShadows", false, "Reflection shadows", "Render shadows in the reflection (costs frames).", false, false, (ValueValidator)null, (string)null); ReflectionEffects = val.CreateEntry<bool>("ReflectionEffects", false, "Screen effects in reflections", "Run the game's screen effects (god rays etc.) on the reflection too. They draw pink streaks there, so this is off.", false, false, (ValueValidator)null, (string)null); ScreenSpaceReflections = val.CreateEntry<bool>("ScreenSpaceReflections", false, "Screen-space reflections", "The water's screen-space reflections (reflecting what's on screen). They streak pink along tree edges, so this is off; the planar reflections stay.", false, false, (ValueValidator)null, (string)null); WaterColorVariety = val.CreateEntry<float>("WaterColorVariety", 1f, "Water colour variety", "Colour across the water: teal-green crests, navy troughs, drifting cobalt and teal patches (0 = off, 2 = strong). Medium quality and up.", false, false, (ValueValidator)null, (string)null); Whitecaps = val.CreateEntry<bool>("Whitecaps", true, "Whitecaps", "Foam on the tops of the bigger waves.", false, false, (ValueValidator)null, (string)null); SeaFloorCollision = val.CreateEntry<bool>("SeaFloorCollision", true, "Solid sea floor", "Give the sea floor collision so you can't swim or sink through it.", false, false, (ValueValidator)null, (string)null); Lighting = val.CreateEntry<bool>("Lighting", true, "Realistic lighting", "Real sunlight colours, golden-hour and blue-hour skies, matching ambient light and haze, better shadows.", false, false, (ValueValidator)null, (string)null); RealisticSunPath = val.CreateEntry<bool>("RealisticSunPath", true, "Realistic sun path", "The sun crosses the sky on a tilted arc (highest to the south) instead of straight overhead, so shadows fall at an angle and stretch out at sunrise and sunset.", false, false, (ValueValidator)null, (string)null); SunPathTilt = val.CreateEntry<float>("SunPathTilt", 40f, "Sun path tilt", "How far (degrees) the sun's arc leans south. 40 = sun peaks 50 degrees high at noon; 0 = straight overhead.", false, false, (ValueValidator)null, (string)null); NorthHeading = val.CreateEntry<float>("NorthHeading", 0f, "North heading", "Turns the whole sun path (degrees) to change where the sun rises and sets on the map.", false, false, (ValueValidator)null, (string)null); SunsetStrength = val.CreateEntry<float>("SunsetStrength", 1f, "Sunset strength", "How strong the sunrise/sunset colours, blue hour and night darkening are (0 = the game's own sky, 1.5 = vivid).", false, false, (ValueValidator)null, (string)null); ShadowQuality = val.CreateEntry<int>("ShadowQuality", 2, "Shadow quality", "0 = leave the game's shadow settings, 1 = medium (2048 px, 2 cascades, 100 m), 2 = high (4096 px, 4 cascades, 150 m), 3 = ultra (4096 px, 4 cascades, 220 m, best soft shadows).", false, false, (ValueValidator)null, (string)null); ShadowDistance = val.CreateEntry<float>("ShadowDistance", 0f, "Shadow distance", "Draw shadows at least this far away (m). 0 = use the shadow quality's distance.", false, false, (ValueValidator)null, (string)null); SkyQuality = val.CreateEntry<int>("SkyQuality", -1, "Sky quality", "-1 = follow the game's graphics quality (Low = the game's own sky, Ultra = everything). 0-3 = force Low/Medium/High/Ultra.", false, false, (ValueValidator)null, (string)null); CloudSpeed = val.CreateEntry<float>("CloudSpeed", 1f, "Cloud speed", "How fast the sky's clouds drift round (0 = still).", false, false, (ValueValidator)null, (string)null); VerboseLogging = val.CreateEntry<bool>("VerboseLogging", false, "Verbose logging", "Extra log lines for troubleshooting.", false, false, (ValueValidator)null, (string)null); _version = val.CreateEntry<int>("ConfigVersion", 0, "Config version", "Used by the mod to update old settings. Don't change.", true, false, (ValueValidator)null, (string)null); if (_version.Value < 4) { if (OceanDetail.Value == 192) { OceanDetail.Value = 0; } _version.Value = 4; } if (_version.Value < 2) { if (SwimSpeed.Value <= 3f) { SwimSpeed.Value = 5f; } _version.Value = 2; } if (_version.Value < 3) { ReflectVegetation.Value = true; ReflectionShadows.Value = false; _version.Value = 3; } } } public class AtmosphericsMod : MelonMod { internal static Instance Log; internal static AtmoConfig Cfg; private bool _inWorld; public override void OnInitializeMelon() { Log = ((MelonBase)this).LoggerInstance; Cfg = new AtmoConfig(); Waves.Init(); Log.Msg("Froggos-Atmospherics loaded: realistic ocean, lighting, reflections and swimming."); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { Swimming.Reset(); Underwater.Reset(); Lighting.Reset(); Sky.Reset(); Ocean.Reset(); _inWorld = false; } public override void OnSceneWasInitialized(int buildIndex, string sceneName) { _inWorld = sceneName != "Menu"; } public override void OnUpdate() { if (!_inWorld) { return; } try { Waves.Tick(Time.deltaTime); Ocean.Tick(); Swimming.Tick(); } catch (Exception ex) { Verbose("Update failed: " + ex); } } public override void OnLateUpdate() { if (!_inWorld) { return; } try { Lighting.Tick(); Reflections.Render(); Underwater.LateTick(); } catch (Exception ex) { Verbose("Late update failed: " + ex); } } public override void OnGUI() { if (!_inWorld) { return; } try { Underwater.OnGUI(); } catch { } } internal static void Verbose(string msg) { if (Cfg != null && Cfg.VerboseLogging.Value) { Log.Msg("[verbose] " + msg); } } } internal static class Game { private static Sprite s_icon; public static Camera MainCamera { get { try { if (PlayerSingleton<PlayerCamera>.InstanceExists) { Camera camera = PlayerSingleton<PlayerCamera>.Instance.Camera; if ((Object)(object)camera != (Object)null) { return camera; } } } catch { } return Camera.main; } } public static Transform Camera { get { Camera mainCamera = MainCamera; if (!((Object)(object)mainCamera != (Object)null)) { return null; } return ((Component)mainCamera).transform; } } public static PlayerMovement Movement { get { try { return PlayerSingleton<PlayerMovement>.InstanceExists ? PlayerSingleton<PlayerMovement>.Instance : null; } catch { return null; } } } public static Player LocalPlayer { get { try { return Player.Local; } catch { return null; } } } public static float Hours { get { try { if (!NetworkSingleton<TimeManager>.InstanceExists) { return -1f; } int currentTime = NetworkSingleton<TimeManager>.Instance.CurrentTime; return (float)(currentTime / 100) + (float)(currentTime % 100) / 60f; } catch { return -1f; } } } private static Sprite Icon { get { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_014e: 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) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s_icon != (Object)null) { return s_icon; } Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.05f, 0.35f, 0.55f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.45f, 0.85f, 0.95f); for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num = (float)j / 64f; float num2 = (float)i / 64f; float num3 = num - 0.5f; float num4 = num2 - 0.5f; float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4); float num6 = 0.52f + 0.09f * Mathf.Sin(num * (float)Math.PI * 4f + 0.6f); Color val4 = (Color)((num2 < num6) ? Color.Lerp(val2, val3, num2 / num6) : new Color(0.93f, 0.97f, 1f)); float a = Mathf.Clamp01((0.47f - num5) * 64f * 0.5f); val4.a = a; val.SetPixel(j, i, val4); } } val.Apply(); ((Object)val).hideFlags = (HideFlags)32; s_icon = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f)); ((Object)s_icon).hideFlags = (HideFlags)32; return s_icon; } } public static void Notify(string title, string subtitle, float seconds = 4f) { try { if (Singleton<NotificationsManager>.InstanceExists) { Singleton<NotificationsManager>.Instance.SendNotification(title, subtitle, Icon, seconds, true); } } catch (Exception ex) { AtmosphericsMod.Verbose("Notification failed: " + ex.Message); } } } internal static class Lighting { private struct Slot<T> where T : struct { public T Written; public T Base; public bool Has; } private static DayNightController s_dnc; private static float s_nextFind; private static int s_lastFrame = -1; private static float s_nextShadowCheck; private static bool s_loggedSky; private static Slot<Color> s_sunColor; private static Slot<Color> s_ambSky; private static Slot<Color> s_ambEq; private static Slot<Color> s_ambGround; private static Slot<Color> s_fog; private static Slot<Color> s_skyUp; private static Slot<Color> s_skyMid; private static Slot<Color> s_skyLow; private static Slot<Color> s_sunDisc; private static Slot<Color> s_ambLight; private static Slot<float> s_sunIntensity; private static Slot<float> s_sunShadow; private static Slot<float> s_sunSize; private static Slot<Vector4> s_sunDirProp; private static bool s_rotWritten; private static Quaternion s_writtenLocal; private static Quaternion s_gameLocal; private static Vector3 s_gameToSun = Vector3.up; private static readonly int SkyUpperID = Shader.PropertyToID("_SkyUpperColor"); private static readonly int SkyMiddleID = Shader.PropertyToID("_SkyMiddleColor"); private static readonly int SkyLowerID = Shader.PropertyToID("_SkyLowerColor"); private static readonly int SunDiscID = Shader.PropertyToID("_SunColor"); private static readonly int SunSizeID = Shader.PropertyToID("_SunSize"); private static readonly int SunDirID = Shader.PropertyToID("_SunDirection"); private static readonly int CloudDensityID = Shader.PropertyToID("_CloudDensity"); private static Slot<float> s_cloudDensity; public static float Daylight { get; private set; } = 1f; public static void Reset() { s_dnc = null; s_nextFind = 0f; s_lastFrame = -1; s_nextShadowCheck = 0f; s_sunColor = (s_ambSky = (s_ambEq = (s_ambGround = (s_fog = (s_skyUp = (s_skyMid = (s_skyLow = (s_sunDisc = (s_ambLight = default(Slot<Color>)))))))))); s_sunIntensity = (s_sunShadow = (s_sunSize = (s_cloudDensity = default(Slot<float>)))); s_sunDirProp = default(Slot<Vector4>); s_rotWritten = false; } private static T Base<T>(ref Slot<T> slot, T current) where T : struct { if (slot.Has && slot.Written.Equals(current)) { return slot.Base; } slot.Base = current; return current; } private static void Wrote<T>(ref Slot<T> slot, T value) where T : struct { slot.Written = value; slot.Has = true; } public static void Tick() { if (Time.frameCount == s_lastFrame) { return; } s_lastFrame = Time.frameCount; if (!AtmosphericsMod.Cfg.Lighting.Value) { Sky.Hide(); return; } if ((Object)(object)s_dnc == (Object)null) { if (Time.unscaledTime < s_nextFind) { return; } s_nextFind = Time.unscaledTime + 2f; s_dnc = Object.FindObjectOfType<DayNightController>(); if ((Object)(object)s_dnc == (Object)null) { return; } AtmosphericsMod.Log.Msg("Lighting: found the game's day/night controller."); } try { ApplyShadowQuality(); } catch (Exception ex) { AtmosphericsMod.Verbose("Shadow settings failed: " + ex.Message); } try { Apply(); } catch (Exception ex2) { AtmosphericsMod.Verbose("Lighting failed: " + ex2.Message); } } private static void Apply() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0c51: Unknown result type (might be due to invalid IL or missing references) //IL_0c56: Unknown result type (might be due to invalid IL or missing references) //IL_0c5b: Unknown result type (might be due to invalid IL or missing references) //IL_0c62: Unknown result type (might be due to invalid IL or missing references) //IL_0c67: Unknown result type (might be due to invalid IL or missing references) //IL_0c6c: Unknown result type (might be due to invalid IL or missing references) //IL_0c73: Unknown result type (might be due to invalid IL or missing references) //IL_0c78: Unknown result type (might be due to invalid IL or missing references) //IL_0c7d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0c9d: Unknown result type (might be due to invalid IL or missing references) //IL_0cb3: Unknown result type (might be due to invalid IL or missing references) //IL_0cb8: Unknown result type (might be due to invalid IL or missing references) //IL_0cba: Unknown result type (might be due to invalid IL or missing references) //IL_0ccb: Unknown result type (might be due to invalid IL or missing references) //IL_0cd5: Unknown result type (might be due to invalid IL or missing references) //IL_0cee: Unknown result type (might be due to invalid IL or missing references) //IL_0cf3: Unknown result type (might be due to invalid IL or missing references) //IL_0cf5: Unknown result type (might be due to invalid IL or missing references) //IL_0d01: Unknown result type (might be due to invalid IL or missing references) //IL_0d08: Unknown result type (might be due to invalid IL or missing references) //IL_0d14: Unknown result type (might be due to invalid IL or missing references) //IL_0d1b: Unknown result type (might be due to invalid IL or missing references) //IL_0d27: Unknown result type (might be due to invalid IL or missing references) //IL_0c83: Unknown result type (might be due to invalid IL or missing references) //IL_0c85: Unknown result type (might be due to invalid IL or missing references) //IL_0c89: Unknown result type (might be due to invalid IL or missing references) //IL_0c8e: Unknown result type (might be due to invalid IL or missing references) //IL_0c90: Unknown result type (might be due to invalid IL or missing references) //IL_0c92: Unknown result type (might be due to invalid IL or missing references) //IL_0c96: Unknown result type (might be due to invalid IL or missing references) //IL_0c9b: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0d4e: Unknown result type (might be due to invalid IL or missing references) //IL_0d53: Unknown result type (might be due to invalid IL or missing references) //IL_0d58: Unknown result type (might be due to invalid IL or missing references) //IL_0d62: Unknown result type (might be due to invalid IL or missing references) //IL_0d67: Unknown result type (might be due to invalid IL or missing references) //IL_0d6b: Unknown result type (might be due to invalid IL or missing references) //IL_0d77: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_00fd: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0d8e: Unknown result type (might be due to invalid IL or missing references) //IL_0d93: Unknown result type (might be due to invalid IL or missing references) //IL_0d98: Unknown result type (might be due to invalid IL or missing references) //IL_0d9a: Unknown result type (might be due to invalid IL or missing references) //IL_0d9c: Unknown result type (might be due to invalid IL or missing references) //IL_0da6: Unknown result type (might be due to invalid IL or missing references) //IL_0dab: Unknown result type (might be due to invalid IL or missing references) //IL_0daf: Unknown result type (might be due to invalid IL or missing references) //IL_0dbb: Unknown result type (might be due to invalid IL or missing references) //IL_0dc7: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: 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_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: 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_0b07: Unknown result type (might be due to invalid IL or missing references) //IL_0b09: Unknown result type (might be due to invalid IL or missing references) //IL_0b72: Unknown result type (might be due to invalid IL or missing references) //IL_0b6b: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_0b74: Unknown result type (might be due to invalid IL or missing references) //IL_0b7b: Unknown result type (might be due to invalid IL or missing references) //IL_0b7d: Unknown result type (might be due to invalid IL or missing references) //IL_0b8b: Unknown result type (might be due to invalid IL or missing references) //IL_0b90: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_0bbf: Unknown result type (might be due to invalid IL or missing references) //IL_0bc4: Unknown result type (might be due to invalid IL or missing references) //IL_0ba9: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_0bc9: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_0574: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_0594: Unknown result type (might be due to invalid IL or missing references) //IL_0596: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_05a7: Unknown result type (might be due to invalid IL or missing references) //IL_05c6: Unknown result type (might be due to invalid IL or missing references) //IL_05cb: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Unknown result type (might be due to invalid IL or missing references) //IL_05cf: Unknown result type (might be due to invalid IL or missing references) //IL_05de: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Unknown result type (might be due to invalid IL or missing references) //IL_05f8: Unknown result type (might be due to invalid IL or missing references) //IL_05fa: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_062b: Unknown result type (might be due to invalid IL or missing references) //IL_063f: Unknown result type (might be due to invalid IL or missing references) //IL_0646: Unknown result type (might be due to invalid IL or missing references) //IL_064b: Unknown result type (might be due to invalid IL or missing references) //IL_065c: Unknown result type (might be due to invalid IL or missing references) //IL_0670: Unknown result type (might be due to invalid IL or missing references) //IL_0677: Unknown result type (might be due to invalid IL or missing references) //IL_067c: Unknown result type (might be due to invalid IL or missing references) //IL_068d: Unknown result type (might be due to invalid IL or missing references) //IL_06a1: Unknown result type (might be due to invalid IL or missing references) //IL_06a8: Unknown result type (might be due to invalid IL or missing references) //IL_06ad: Unknown result type (might be due to invalid IL or missing references) //IL_06af: Unknown result type (might be due to invalid IL or missing references) //IL_06b1: Unknown result type (might be due to invalid IL or missing references) //IL_06c0: Unknown result type (might be due to invalid IL or missing references) //IL_06d3: Unknown result type (might be due to invalid IL or missing references) //IL_06d8: Unknown result type (might be due to invalid IL or missing references) //IL_06da: Unknown result type (might be due to invalid IL or missing references) //IL_06dc: Unknown result type (might be due to invalid IL or missing references) //IL_06eb: Unknown result type (might be due to invalid IL or missing references) //IL_06f0: Unknown result type (might be due to invalid IL or missing references) //IL_06f2: Unknown result type (might be due to invalid IL or missing references) //IL_06f4: Unknown result type (might be due to invalid IL or missing references) //IL_0703: Unknown result type (might be due to invalid IL or missing references) //IL_0708: Unknown result type (might be due to invalid IL or missing references) //IL_070a: Unknown result type (might be due to invalid IL or missing references) //IL_071b: Unknown result type (might be due to invalid IL or missing references) //IL_072d: Unknown result type (might be due to invalid IL or missing references) //IL_0732: Unknown result type (might be due to invalid IL or missing references) //IL_0734: Unknown result type (might be due to invalid IL or missing references) //IL_0745: Unknown result type (might be due to invalid IL or missing references) //IL_0757: Unknown result type (might be due to invalid IL or missing references) //IL_075c: Unknown result type (might be due to invalid IL or missing references) //IL_075e: Unknown result type (might be due to invalid IL or missing references) //IL_076f: Unknown result type (might be due to invalid IL or missing references) //IL_0781: Unknown result type (might be due to invalid IL or missing references) //IL_0786: Unknown result type (might be due to invalid IL or missing references) //IL_078f: Unknown result type (might be due to invalid IL or missing references) //IL_0791: Unknown result type (might be due to invalid IL or missing references) //IL_07a2: Unknown result type (might be due to invalid IL or missing references) //IL_07ac: Unknown result type (might be due to invalid IL or missing references) //IL_07b6: Unknown result type (might be due to invalid IL or missing references) //IL_07c3: Unknown result type (might be due to invalid IL or missing references) //IL_07c8: Unknown result type (might be due to invalid IL or missing references) //IL_07ca: Unknown result type (might be due to invalid IL or missing references) //IL_07cc: Unknown result type (might be due to invalid IL or missing references) //IL_07dd: Unknown result type (might be due to invalid IL or missing references) //IL_07e7: Unknown result type (might be due to invalid IL or missing references) //IL_07f1: Unknown result type (might be due to invalid IL or missing references) //IL_07fe: Unknown result type (might be due to invalid IL or missing references) //IL_0803: Unknown result type (might be due to invalid IL or missing references) //IL_0805: Unknown result type (might be due to invalid IL or missing references) //IL_0807: Unknown result type (might be due to invalid IL or missing references) //IL_0818: Unknown result type (might be due to invalid IL or missing references) //IL_0822: Unknown result type (might be due to invalid IL or missing references) //IL_082c: Unknown result type (might be due to invalid IL or missing references) //IL_0839: Unknown result type (might be due to invalid IL or missing references) //IL_083e: Unknown result type (might be due to invalid IL or missing references) //IL_084a: Unknown result type (might be due to invalid IL or missing references) //IL_085a: Unknown result type (might be due to invalid IL or missing references) //IL_085f: Unknown result type (might be due to invalid IL or missing references) //IL_0861: Unknown result type (might be due to invalid IL or missing references) //IL_0863: Unknown result type (might be due to invalid IL or missing references) //IL_0865: Unknown result type (might be due to invalid IL or missing references) //IL_0867: Unknown result type (might be due to invalid IL or missing references) //IL_0871: Unknown result type (might be due to invalid IL or missing references) //IL_087b: Unknown result type (might be due to invalid IL or missing references) //IL_0888: Unknown result type (might be due to invalid IL or missing references) //IL_088d: Unknown result type (might be due to invalid IL or missing references) //IL_08ba: Unknown result type (might be due to invalid IL or missing references) //IL_08c6: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_08fc: Unknown result type (might be due to invalid IL or missing references) //IL_0908: Unknown result type (might be due to invalid IL or missing references) //IL_090f: Unknown result type (might be due to invalid IL or missing references) //IL_0911: Unknown result type (might be due to invalid IL or missing references) //IL_0913: Unknown result type (might be due to invalid IL or missing references) //IL_0915: Unknown result type (might be due to invalid IL or missing references) //IL_08e2: Unknown result type (might be due to invalid IL or missing references) //IL_08ee: Unknown result type (might be due to invalid IL or missing references) //IL_0931: Unknown result type (might be due to invalid IL or missing references) //IL_0936: Unknown result type (might be due to invalid IL or missing references) //IL_093b: Unknown result type (might be due to invalid IL or missing references) //IL_093d: Unknown result type (might be due to invalid IL or missing references) //IL_0946: Unknown result type (might be due to invalid IL or missing references) //IL_0950: Unknown result type (might be due to invalid IL or missing references) //IL_0955: Unknown result type (might be due to invalid IL or missing references) //IL_0959: Unknown result type (might be due to invalid IL or missing references) //IL_096c: Unknown result type (might be due to invalid IL or missing references) //IL_0978: Unknown result type (might be due to invalid IL or missing references) //IL_0c0e: Unknown result type (might be due to invalid IL or missing references) //IL_0c13: Unknown result type (might be due to invalid IL or missing references) //IL_0c17: Unknown result type (might be due to invalid IL or missing references) //IL_09ff: Unknown result type (might be due to invalid IL or missing references) //IL_0a04: Unknown result type (might be due to invalid IL or missing references) //IL_0a09: Unknown result type (might be due to invalid IL or missing references) //IL_0a0b: Unknown result type (might be due to invalid IL or missing references) //IL_0a0d: Unknown result type (might be due to invalid IL or missing references) //IL_0a12: Unknown result type (might be due to invalid IL or missing references) //IL_0a14: Unknown result type (might be due to invalid IL or missing references) //IL_0a16: Unknown result type (might be due to invalid IL or missing references) //IL_0a35: Unknown result type (might be due to invalid IL or missing references) //IL_0a39: Unknown result type (might be due to invalid IL or missing references) //IL_0a5a: Unknown result type (might be due to invalid IL or missing references) //IL_0a5f: Unknown result type (might be due to invalid IL or missing references) //IL_0a63: Unknown result type (might be due to invalid IL or missing references) //IL_0a6a: Unknown result type (might be due to invalid IL or missing references) //IL_0a71: Unknown result type (might be due to invalid IL or missing references) //IL_0a78: Unknown result type (might be due to invalid IL or missing references) //IL_0a8b: Unknown result type (might be due to invalid IL or missing references) //IL_0a97: Unknown result type (might be due to invalid IL or missing references) Light sunLight = s_dnc._sunLight; float timeInHours = s_dnc._timeInHours; DayNightPhaseTimes dayNightPhaseTimes = s_dnc._dayNightPhaseTimes; float num = dayNightPhaseTimes.SunRiseHour; float num2 = dayNightPhaseTimes.SunSetHour; if (num2 <= num) { num = 6f; num2 = 20f; } Vector3 val = SunVector(timeInHours, num, num2); if ((Object)(object)sunLight != (Object)null) { Transform transform = ((Component)sunLight).transform; Quaternion val2; if (s_rotWritten && transform.localRotation == s_writtenLocal) { val2 = (((Object)(object)transform.parent != (Object)null) ? transform.parent.rotation : Quaternion.identity) * s_gameLocal; } else { val2 = transform.rotation; s_gameLocal = transform.localRotation; } s_gameToSun = -(val2 * Vector3.forward); if (AtmosphericsMod.Cfg.RealisticSunPath.Value) { transform.rotation = Quaternion.LookRotation(-val, Vector3.up); s_writtenLocal = transform.localRotation; s_rotWritten = true; } else { if (s_rotWritten) { transform.localRotation = s_gameLocal; } s_rotWritten = false; val = s_gameToSun; } } float num3 = Mathf.Asin(Mathf.Clamp(val.y, -1f, 1f)) * 57.29578f; Material val3 = SkyMaterial(); float num4 = Clarity(val3); float num5 = Mathf.Max(0f, AtmosphericsMod.Cfg.SunsetStrength.Value); int level = SkyQuality.Level; float num6 = num5 * ((level <= 0) ? 0f : ((level == 1) ? 0.7f : 1f)); float num7 = (num + num2) * 0.5f; float num8 = ((timeInHours < num7 && timeInHours > num - 4f) ? 1f : 0f); float num9 = Bell(num3, -3f, 3f, 18f); float num10 = Bell(num3, -9f, -2.5f, 1f); float num11 = Bell(num3, -13f, -7f, -2f); float num12 = Mathf.Clamp01((0f - num3 - 6f) / 8f); float num13 = Mathf.Clamp01((num3 - 4f) / 20f); Daylight = Mathf.Lerp(0.08f, 1f, Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((num3 + 10f) / 28f))) * Mathf.Lerp(0.7f, 1f, num4); if ((Object)(object)sunLight != (Object)null) { Color c = Base<Color>(ref s_sunColor, sunLight.color); Color hue = KelvinToRgb(SunKelvin(num3)); Color value = (sunLight.color = TintKeepLum(c, hue, Mathf.Lerp(0.55f, 0.9f, num9) * Mathf.Lerp(0.6f, 1f, num4))); Wrote<Color>(ref s_sunColor, value); float num14 = Base(ref s_sunIntensity, sunLight.intensity); float num15 = Mathf.Lerp(0.5f, 1.08f, Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(num3 / 30f))); float value2 = (sunLight.intensity = num14 * num15); Wrote(ref s_sunIntensity, value2); sunLight.shadows = (LightShadows)2; float value3 = (sunLight.shadowStrength = Mathf.Lerp(Mathf.Min(Base(ref s_sunShadow, sunLight.shadowStrength), 0.5f), 0.92f, num4)); Wrote(ref s_sunShadow, value3); } Color val5 = Color.black; Color val6 = Color.black; bool flag = false; if ((Object)(object)val3 != (Object)null && val3.HasProperty(SkyLowerID) && val3.HasProperty(SkyUpperID)) { flag = true; Color val7 = Base<Color>(ref s_skyUp, val3.GetColor(SkyUpperID)); Color val8 = (val3.HasProperty(SkyMiddleID) ? Base<Color>(ref s_skyMid, val3.GetColor(SkyMiddleID)) : val7); Color val9 = Base<Color>(ref s_skyLow, val3.GetColor(SkyLowerID)); if (!s_loggedSky) { s_loggedSky = true; AtmosphericsMod.Log.Msg($"Lighting: sky colours at {timeInHours:0.0}h: upper {val7}, middle {val8}, lower {val9}; clarity {num4:0.00}."); } float num18 = num9 * num4 * num6; float num19 = num10 * num4 * num6; float num20 = num11 * Mathf.Lerp(0.5f, 1f, num4) * num6; float num21 = num8; Color hue2 = Color.Lerp(new Color(1f, 0.6f, 0.14f), new Color(1f, 0.8f, 0.6f), num21); Color hue3 = Color.Lerp(new Color(0.96f, 0.36f, 0.14f), new Color(1f, 0.74f, 0.7f), num21); Color hue4 = Color.Lerp(new Color(0.62f, 0.38f, 0.42f), new Color(0.64f, 0.66f, 0.86f), num21); val9 = TintKeepLum(val9, hue2, Mathf.Clamp01(num18 * 0.9f)) * (1f + Mathf.Lerp(0.6f, 0.4f, num21) * num18); val8 = TintKeepLum(val8, hue3, Mathf.Clamp01(num18 * 0.85f)) * (1f + 0.25f * num18); val7 = TintKeepLum(val7, hue4, Mathf.Clamp01(num18 * Mathf.Lerp(0.7f, 0.55f, num21))); Color hue5 = Color.Lerp(new Color(1f, 0.42f, 0.18f), new Color(1f, 0.66f, 0.5f), num21); Color hue6 = Color.Lerp(new Color(0.82f, 0.28f, 0.36f), new Color(0.92f, 0.56f, 0.66f), num21); Color hue7 = Color.Lerp(new Color(0.34f, 0.24f, 0.44f), new Color(0.48f, 0.46f, 0.7f), num21); val9 = TintKeepLum(val9, hue5, Mathf.Clamp01(num19 * 0.85f)) * (1f + 0.3f * num19); val8 = TintKeepLum(val8, hue6, Mathf.Clamp01(num19 * 0.8f)); val7 = TintKeepLum(val7, hue7, Mathf.Clamp01(num19 * 0.7f)); val9 = TintKeepLum(val9, new Color(0.45f, 0.42f, 0.7f), Mathf.Clamp01(num20 * 0.7f)); val8 = TintKeepLum(val8, new Color(0.22f, 0.28f, 0.6f), Mathf.Clamp01(num20 * 0.75f)); val7 = TintKeepLum(val7, new Color(0.08f, 0.13f, 0.38f), Mathf.Clamp01(num20 * 0.8f)); float num22 = num12 * num6; val7 = Color.Lerp(val7, TintKeepLum(val7, new Color(0.05f, 0.08f, 0.22f), 1f) * 0.55f, num22 * 0.8f); val8 = Color.Lerp(val8, TintKeepLum(val8, new Color(0.07f, 0.1f, 0.25f), 1f) * 0.65f, num22 * 0.7f); val9 = Color.Lerp(val9, TintKeepLum(val9, new Color(0.1f, 0.13f, 0.25f), 1f) * 0.75f, num22 * 0.6f); float num23 = num13 * num4 * num6; val7 = Saturate(val7, 1f + 0.3f * num23); val9 = Color.Lerp(val9, Color.Lerp(val9, Gray(val9) * 1.1f, 0.5f), num23 * 0.4f); val7.a = 1f; val8.a = 1f; val9.a = 1f; val3.SetColor(SkyUpperID, val7); Wrote<Color>(ref s_skyUp, val7); if (val3.HasProperty(SkyMiddleID)) { val3.SetColor(SkyMiddleID, val8); Wrote<Color>(ref s_skyMid, val8); } val3.SetColor(SkyLowerID, val9); Wrote<Color>(ref s_skyLow, val9); val5 = val9; val6 = val7; if (val3.HasProperty(SunDiscID)) { Color val10 = Base<Color>(ref s_sunDisc, val3.GetColor(SunDiscID)); Color val11 = TintKeepLum(val10, KelvinToRgb(SunKelvin(num3)), 0.8f); val11.a = val10.a; val3.SetColor(SunDiscID, val11); Wrote<Color>(ref s_sunDisc, val11); } if (val3.HasProperty(SunSizeID)) { float num24 = Base(ref s_sunSize, val3.GetFloat(SunSizeID)) * (1f + 0.35f * num9); val3.SetFloat(SunSizeID, num24); Wrote(ref s_sunSize, num24); } if (val3.HasProperty(SunDirID) && AtmosphericsMod.Cfg.RealisticSunPath.Value) { Vector4 val12 = Base<Vector4>(ref s_sunDirProp, val3.GetVector(SunDirID)); Vector3 val13 = Vector4.op_Implicit(val12); float num25 = ((Vector3.Dot(val13, s_gameToSun) >= 0f) ? 1f : (-1f)); Vector3 val14 = val * num25 * ((((Vector3)(ref val13)).sqrMagnitude > 1E-06f) ? ((Vector3)(ref val13)).magnitude : 1f); Vector4 val15 = default(Vector4); ((Vector4)(ref val15))..ctor(val14.x, val14.y, val14.z, val12.w); val3.SetVector(SunDirID, val15); Wrote<Vector4>(ref s_sunDirProp, val15); } } if ((Object)(object)val3 != (Object)null && val3.HasProperty(CloudDensityID)) { float num26 = Base(ref s_cloudDensity, val3.GetFloat(CloudDensityID)); float num27 = (Sky.CloudsActive ? (num26 * 0.15f) : num26); val3.SetFloat(CloudDensityID, num27); Wrote(ref s_cloudDensity, num27); } SkyFrame f = new SkyFrame { ToSun = val, Elev = num3, Golden = num9 * num4, Afterglow = num10 * num4, Blue = num11, Night = num12, Day = num13, Morning = num8, Clarity = num4, Strength = num6, Horizon = (flag ? val5 : RenderSettings.fogColor), Zenith = val6, SunColor = KelvinToRgb(SunKelvin(num3)), ToMoon = (((Object)(object)s_dnc._moonLight != (Object)null) ? (-((Component)s_dnc._moonLight).transform.forward) : Vector3.zero) }; try { MeshRenderer skyRenderer = s_dnc._skyRenderer; int skyLayer = (((Object)(object)skyRenderer != (Object)null) ? ((Component)skyRenderer).gameObject.layer : 0); float skyRadius; if (!((Object)(object)skyRenderer != (Object)null)) { skyRadius = 0f; } else { Bounds bounds = ((Renderer)skyRenderer).bounds; skyRadius = ((Bounds)(ref bounds)).extents.x; } Sky.Tick(in f, val3, skyLayer, skyRadius); } catch (Exception ex) { AtmosphericsMod.Verbose("Sky layers failed: " + ex.Message); } float num28 = 0.45f * num5; Color val16 = Base<Color>(ref s_ambSky, RenderSettings.ambientSkyColor); Color val17 = Base<Color>(ref s_ambEq, RenderSettings.ambientEquatorColor); Color c2 = Base<Color>(ref s_ambGround, RenderSettings.ambientGroundColor); if (flag) { val16 = TintKeepLum(val16, val6, num28); val17 = TintKeepLum(val17, val5, num28); } val16 *= Mathf.Lerp(1f, 0.85f, num9 * num4); c2 = TintKeepLum(c2, new Color(0.5f, 0.42f, 0.35f), 0.3f) * Mathf.Lerp(1f, 0.8f, num9 * num4); RenderSettings.ambientSkyColor = val16; Wrote<Color>(ref s_ambSky, val16); RenderSettings.ambientEquatorColor = val17; Wrote<Color>(ref s_ambEq, val17); RenderSettings.ambientGroundColor = c2; Wrote<Color>(ref s_ambGround, c2); Light ambientLight = s_dnc._ambientLight; if ((Object)(object)ambientLight != (Object)null && flag) { Color value4 = (ambientLight.color = TintKeepLum(Base<Color>(ref s_ambLight, ambientLight.color), val6, num28 * 0.7f)); Wrote<Color>(ref s_ambLight, value4); } if (flag && !Underwater.Active) { Color val19 = Base<Color>(ref s_fog, RenderSettings.fogColor); Color val20 = TintKeepLum(val19, val5, 0.55f * num5); val20.a = val19.a; RenderSettings.fogColor = val20; Wrote<Color>(ref s_fog, val20); } } private static Vector3 SunVector(float hours, float rise, float set) { //IL_00bf: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) float num = set - rise; float num2; if (hours >= rise && hours <= set) { num2 = (hours - rise) / num * (float)Math.PI; } else { float num3 = 24f - num; float num4 = ((hours > set) ? (hours - set) : (hours + 24f - set)); num2 = (float)Math.PI + num4 / num3 * (float)Math.PI; } float num5 = Mathf.Clamp(AtmosphericsMod.Cfg.SunPathTilt.Value, 0f, 70f) * ((float)Math.PI / 180f); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Mathf.Cos(num2), Mathf.Sin(num2) * Mathf.Cos(num5), (0f - Mathf.Sin(num2)) * Mathf.Sin(num5)); float num6 = AtmosphericsMod.Cfg.NorthHeading.Value * ((float)Math.PI / 180f); Vector3 val2 = Quaternion.Euler(0f, num6 * 57.29578f, 0f) * val; return ((Vector3)(ref val2)).normalized; } private static float SunKelvin(float elev) { float num = Mathf.Clamp01((elev + 1f) / 40f); return Mathf.Lerp(1850f, 6500f, Mathf.Pow(num, 0.6f)); } private static Color KelvinToRgb(float kelvin) { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) float num = kelvin / 100f; float num2; float num3; float num4; if (num <= 66f) { num2 = 255f; num3 = 99.4708f * Mathf.Log(num) - 161.11957f; num4 = ((num <= 19f) ? 0f : (138.51773f * Mathf.Log(num - 10f) - 305.0448f)); } else { num2 = 329.69873f * Mathf.Pow(num - 60f, -0.13320476f); num3 = 288.12216f * Mathf.Pow(num - 60f, -0.075514846f); num4 = 255f; } Color val = default(Color); ((Color)(ref val))..ctor(Mathf.Clamp(num2, 0f, 255f) / 255f, Mathf.Clamp(num3, 0f, 255f) / 255f, Mathf.Clamp(num4, 0f, 255f) / 255f, 1f); float num5 = Mathf.Max(val.r, Mathf.Max(val.g, val.b)); if (!(num5 > 0f)) { return Color.white; } return new Color(val.r / num5, val.g / num5, val.b / num5, 1f); } private static float Lum(Color c) { //IL_0005: 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_001e: Unknown result type (might be due to invalid IL or missing references) return 0.2126f * c.r + 0.7152f * c.g + 0.0722f * c.b; } private static Color Gray(Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) float num = Lum(c); return new Color(num, num, num, c.a); } private static Color Saturate(Color c, float amount) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0008: 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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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) Color val = Gray(c); Color val2 = val + (c - val) * amount; val2.r = Mathf.Max(0f, val2.r); val2.g = Mathf.Max(0f, val2.g); val2.b = Mathf.Max(0f, val2.b); val2.a = c.a; return val2; } private static Color TintKeepLum(Color c, Color hue, float t) { //IL_000a: 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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (t <= 0f) { return c; } float num = Lum(c); float num2 = Lum(hue); Color val = ((num2 > 1E-05f) ? (hue * (num / num2)) : c); Color result = Color.Lerp(c, val, Mathf.Clamp01(t)); result.a = c.a; return result; } private static float Bell(float x, float a, float b, float c) { if (x <= a || x >= c) { return 0f; } if (!(x < b)) { return Mathf.SmoothStep(1f, 0f, (x - b) / (c - b)); } return Mathf.SmoothStep(0f, 1f, (x - a) / (b - a)); } private static float Clarity(Material sky) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)sky == (Object)null || !sky.HasProperty(SkyUpperID)) { return 1f; } float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(s_skyUp.Has ? s_skyUp.Base : sky.GetColor(SkyUpperID), ref num, ref num2, ref num3); if (num3 < 0.04f) { return 1f; } return Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.12f, 0.4f, num2)); } private static Material SkyMaterial() { try { MeshRenderer skyRenderer = s_dnc._skyRenderer; return ((Object)(object)skyRenderer != (Object)null) ? ((Renderer)skyRenderer).sharedMaterial : null; } catch { return null; } } private static void ApplyShadowQuality() { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: 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_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Expected I4, but got Unknown //IL_028f: Unknown result type (might be due to invalid IL or missing references) if (Time.unscaledTime < s_nextShadowCheck) { return; } s_nextShadowCheck = Time.unscaledTime + 2f; int value = AtmosphericsMod.Cfg.ShadowQuality.Value; if (value <= 0) { return; } RenderPipelineAsset currentRenderPipeline = GraphicsSettings.currentRenderPipeline; UniversalRenderPipelineAsset val = ((currentRenderPipeline != null) ? ((Il2CppObjectBase)currentRenderPipeline).TryCast<UniversalRenderPipelineAsset>() : null); if ((Object)(object)val == (Object)null) { RenderPipelineAsset renderPipeline = QualitySettings.renderPipeline; val = ((renderPipeline != null) ? ((Il2CppObjectBase)renderPipeline).TryCast<UniversalRenderPipelineAsset>() : null); } if ((Object)(object)val == (Object)null) { return; } float num = ((value >= 3) ? 150f : ((value == 2) ? 120f : 90f)); int num2 = ((value >= 3) ? 4 : ((value == 2) ? 3 : 2)); ShadowResolution val2 = (ShadowResolution)((value >= 3) ? 4096 : 2048); num = Mathf.Max(num, AtmosphericsMod.Cfg.ShadowDistance.Value); bool flag = false; if (Mathf.Abs(val.shadowDistance - num) > 0.5f) { val.shadowDistance = num; flag = true; } if (val.shadowCascadeCount != num2) { val.shadowCascadeCount = num2; flag = true; } Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(0.06f, 0.18f, 0.45f); if (num2 == 4) { Vector3 val4 = val.cascade4Split - val3; if (((Vector3)(ref val4)).sqrMagnitude > 1E-06f) { val.cascade4Split = val3; flag = true; } } if (num2 == 2 && Mathf.Abs(val.cascade2Split - 0.25f) > 0.0001f) { val.cascade2Split = 0.25f; flag = true; } Vector2 val5 = default(Vector2); ((Vector2)(ref val5))..ctor(0.1f, 0.35f); if (num2 == 3) { Vector2 val6 = val.cascade3Split - val5; if (((Vector2)(ref val6)).sqrMagnitude > 1E-06f) { val.cascade3Split = val5; flag = true; } } if (val.m_MainLightShadowmapResolution != val2) { val.m_MainLightShadowmapResolution = val2; flag = true; } if (!val.supportsSoftShadows) { val.supportsSoftShadows = true; flag = true; } SoftShadowQuality val7 = (SoftShadowQuality)((value >= 3) ? 3 : 2); if (val.softShadowQuality != val7) { val.softShadowQuality = val7; flag = true; } if (Mathf.Abs(val.shadowDepthBias - 0.6f) > 0.001f) { val.shadowDepthBias = 0.6f; flag = true; } if (Mathf.Abs(val.shadowNormalBias - 0.6f) > 0.001f) { val.shadowNormalBias = 0.6f; flag = true; } if (flag) { AtmosphericsMod.Log.Msg($"Shadows: {(int)val2} px, {num2} cascades, {num:0} m, soft ({val7})."); } } } internal static class Ocean { private const float MinOceanArea = 40000f; private static OceanMesh s_mesh; private static Material s_material; private static readonly List<Renderer> s_hidden = new List<Renderer>(); private static readonly List<Behaviour> s_disabled = new List<Behaviour>(); private static List<Rect> s_footprint = new List<Rect>(); private static float s_nextSearch; private static float s_searchStarted = -1f; private static bool s_gaveUp; private static float s_baseNormalStrength = -1f; private static float s_baseSpeed = -1f; private static int s_waterLayer; private static float s_uvPerMeter = 0.1f; private static int s_meshQuality = -1; private static int s_meshDetail = int.MinValue; private static bool s_maskFromPlayer; private static List<StylizedWaterRenderFeature> s_waterFeatures; private static int s_ssrApplied = -1; public static bool Ready { get; private set; } public static float Level { get; private set; } public static Material Material => s_material; public static bool Shown { get; private set; } public static bool VisibleLastFrame { get { try { return s_mesh != null && (Object)(object)s_mesh.Renderer != (Object)null && ((Renderer)s_mesh.Renderer).isVisible; } catch { return true; } } } public static int Layer => s_waterLayer; public static void Reset() { try { s_mesh?.Destroy(); } catch { } Reflections.Reset(); try { if ((Object)(object)s_material != (Object)null) { Object.Destroy((Object)(object)s_material); } } catch { } s_mesh = null; s_material = null; s_hidden.Clear(); s_disabled.Clear(); s_footprint = new List<Rect>(); Ready = false; Shown = false; s_nextSearch = 0f; s_searchStarted = -1f; s_gaveUp = false; s_baseNormalStrength = (s_baseSpeed = -1f); s_maskFromPlayer = false; s_ssrApplied = -1; Shoals.Reset(); Waves.ResetSettle(); WorldFixups.Reset(); } public static float SurfaceHeight(float x, float z) { Vector3 normal; return SurfaceHeight(x, z, out normal); } public static float SurfaceHeight(float x, float z, out Vector3 normal) { //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) normal = Vector3.up; if (!Ready) { return float.NegativeInfinity; } return Waves.SurfaceHeight(Level, x, z, out normal); } public static bool CanSwimAt(Vector3 p) { //IL_0009: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (!Ready) { return false; } if (p.y > Level + 6f || p.y < Level - 80f) { return false; } return OceanMesh.InFootprint(s_footprint, p.x, p.z); } public static void Tick() { //IL_00a9: 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_0123: Unknown result type (might be due to invalid IL or missing references) if (!Ready) { if (s_gaveUp || Time.unscaledTime < s_nextSearch) { return; } s_nextSearch = Time.unscaledTime + 2f; if (s_searchStarted < 0f) { s_searchStarted = Time.unscaledTime; } if (!TryFindSea()) { if (Time.unscaledTime - s_searchStarted > 90f) { s_gaveUp = true; AtmosphericsMod.Log.Warning("Couldn't find the sea in this scene; ocean and swimming are off here."); } return; } } WorldFixups.RestoreAfterReflection(); if (!s_maskFromPlayer && (Object)(object)Game.Movement != (Object)null) { ConfigureGroundMask(s_waterLayer); } Camera mainCamera = Game.MainCamera; if ((Object)(object)mainCamera == (Object)null) { return; } Vector3 position = ((Component)mainCamera).transform.position; Shoals.Tick(position, Level); WorldFixups.Tick(Level, s_footprint); if (s_mesh != null && (s_meshQuality != Mathf.Clamp(SkyQuality.Level, 0, 3) || s_meshDetail != AtmosphericsMod.Cfg.OceanDetail.Value)) { BuildMesh(); } bool value = AtmosphericsMod.Cfg.Ocean.Value; SetOriginalsHidden(value); if (s_mesh != null) { if (value) { s_mesh.Update(position); } else if (s_mesh.Go.activeSelf) { s_mesh.Go.SetActive(false); } } UpdateMaterial(); Shown = value && s_mesh != null; UpdateScreenSpaceReflections(); } private static bool TryFindSea() { //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: 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_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) List<Renderer> list = new List<Renderer>(); try { List<WaterObject> instances = WaterObject.Instances; if (instances != null) { for (int i = 0; i < instances.Count; i++) { WaterObject val = instances[i]; if (!((Object)(object)val == (Object)null)) { Renderer val2 = (Renderer)(((Object)(object)val.meshRenderer != (Object)null) ? ((object)val.meshRenderer) : ((object)((Component)val).GetComponent<Renderer>())); if ((Object)(object)val2 != (Object)null && !list.Contains(val2)) { list.Add(val2); } } } } } catch (Exception ex) { AtmosphericsMod.Verbose("WaterObject.Instances failed: " + ex.Message); } if (list.Count == 0) { foreach (MeshRenderer item in Object.FindObjectsOfType<MeshRenderer>()) { if ((Object)(object)item == (Object)null || ((Object)item).name.StartsWith("FroggosAtmospherics")) { continue; } Material sharedMaterial = ((Renderer)item).sharedMaterial; if (!((Object)(object)sharedMaterial == (Object)null) && !((Object)(object)sharedMaterial.shader == (Object)null)) { string name = ((Object)sharedMaterial.shader).name; if (name.IndexOf("StylizedWater", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Stylized Water", StringComparison.OrdinalIgnoreCase) >= 0) { list.Add((Renderer)(object)item); } } } } if (list.Count == 0) { return false; } Renderer val3 = null; float num = 0f; foreach (Renderer item2 in list) { if (!((Object)item2).name.StartsWith("FroggosAtmospherics")) { Bounds bounds = item2.bounds; float num2 = ((Bounds)(ref bounds)).size.x * ((Bounds)(ref bounds)).size.z; if (num2 > num) { num = num2; val3 = item2; } } } if ((Object)(object)val3 == (Object)null || num < 2500f) { return false; } Bounds bounds2 = val3.bounds; Level = ((Bounds)(ref bounds2)).center.y; List<Renderer> list2 = new List<Renderer>(); bool flag = false; foreach (Renderer item3 in list) { if (((Object)item3).name.StartsWith("FroggosAtmospherics")) { continue; } Bounds bounds3 = item3.bounds; if (!(Mathf.Abs(((Bounds)(ref bounds3)).center.y - Level) > 1.5f) && (!((Object)(object)item3 != (Object)(object)val3) || !(((Bounds)(ref bounds3)).size.x * ((Bounds)(ref bounds3)).size.z < 10000f))) { list2.Add(item3); if ((Object)(object)((Component)item3).GetComponentInParent<WaterGrid>() != (Object)null) { flag = true; } } } s_footprint = new List<Rect>(); if (!flag) { foreach (Renderer item4 in list2) { Bounds bounds4 = item4.bounds; s_footprint.Add(Rect.MinMaxRect(((Bounds)(ref bounds4)).min.x - 4f, ((Bounds)(ref bounds4)).min.z - 4f, ((Bounds)(ref bounds4)).max.x + 4f, ((Bounds)(ref bounds4)).max.z + 4f)); } } Material sharedMaterial2 = val3.sharedMaterial; AtmosphericsMod.Log.Msg($"Found the sea: {list2.Count} surface(s) at Y={Level:0.00}, shader '{(((Object)(object)sharedMaterial2 != (Object)null && (Object)(object)sharedMaterial2.shader != (Object)null) ? ((Object)sharedMaterial2.shader).name : "?")}'" + (flag ? ", endless grid." : $", {num / 1000000f:0.00} km².")); ConfigureGroundMask(((Component)val3).gameObject.layer); Build(val3, sharedMaterial2, list2); Ready = true; WorldFixups.OnSeaFound(); return true; } private static void ConfigureGroundMask(int waterLayer) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) s_waterLayer = waterLayer; int num = -5; try { PlayerMovement movement = Game.Movement; if ((Object)(object)movement != (Object)null) { LayerMask groundDetectionMask = movement.GroundDetectionMask; if (((LayerMask)(ref groundDetectionMask)).value != 0) { groundDetectionMask = movement.GroundDetectionMask; num = ((LayerMask)(ref groundDetectionMask)).value; s_maskFromPlayer = true; } } } catch { } num &= ~(1 << waterLayer); if (Shoals.Mask != num) { Shoals.Reset(); } Shoals.Mask = num; Swimming.GroundMask = num; } private static void Build(Renderer biggest, Material src, List<Renderer> sea) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) s_material = ((!((Object)(object)src != (Object)null)) ? ((Material)null) : new Material(src)); if ((Object)(object)s_material == (Object)null) { AtmosphericsMod.Log.Warning("The sea has no material; leaving it as it is."); return; } ((Object)s_material).name = "FroggosAtmospherics_Ocean"; ApplyLook(s_material); s_uvPerMeter = GuessUvPerMeter(biggest); BuildMesh(); foreach (Renderer item in sea) { s_hidden.Add(item); } foreach (Renderer item2 in sea) { WaterGrid componentInParent = ((Component)item2).GetComponentInParent<WaterGrid>(); if ((Object)(object)componentInParent != (Object)null && !s_disabled.Contains((Behaviour)(object)componentInParent)) { s_disabled.Add((Behaviour)(object)componentInParent); } } } private static void BuildMesh() { try { s_mesh?.Destroy(); } catch { } int num = Mathf.Clamp(SkyQuality.Level, 0, 3); int num2 = AtmosphericsMod.Cfg.OceanDetail.Value; if (num2 <= 0) { num2 = (new int[4] { 96, 128, 160, 192 })[num]; } float num3 = (new float[4] { 0.8f, 0.65f, 0.55f, 0.45f })[num]; s_mesh = new OceanMesh(s_material, s_waterLayer, Level, num2, num3, s_footprint, s_uvPerMeter); s_meshQuality = num; s_meshDetail = AtmosphericsMod.Cfg.OceanDetail.Value; AtmosphericsMod.Verbose($"Ocean mesh: {num2} per side, {num3:0.00} m near you, {Waves.Active} waves."); } private static float GuessUvPerMeter(Renderer r) { //IL_005d: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) try { MeshFilter component = ((Component)r).GetComponent<MeshFilter>(); Mesh val = (((Object)(object)component != (Object)null) ? component.sharedMesh : null); if ((Object)(object)val != (Object)null && val.isReadable) { Il2CppStructArray<Vector2> uv = val.uv; if (uv != null && ((Il2CppArrayBase<Vector2>)(object)uv).Length > 1) { float num = float.MaxValue; float num2 = float.MinValue; for (int i = 0; i < ((Il2CppArrayBase<Vector2>)(object)uv).Length; i++) { num = Mathf.Min(num, ((Il2CppArrayBase<Vector2>)(object)uv)[i].x); num2 = Mathf.Max(num2, ((Il2CppArrayBase<Vector2>)(object)uv)[i].x); } Bounds bounds = r.bounds; float x = ((Bounds)(ref bounds)).size.x; if (x > 1f && num2 > num) { return (num2 - num) / x; } } } } catch { } return 0.1f; } private static void SetOriginalsHidden(bool hidden) { foreach (Renderer item in s_hidden) { if ((Object)(object)item != (Object)null && item.enabled == hidden) { item.enabled = !hidden; } } foreach (Behaviour item2 in s_disabled) { if ((Object)(object)item2 != (Object)null && item2.enabled == hidden) { item2.enabled = !hidden; } } } private static void F(Material m, string name, float v) { if (m.HasProperty(name)) { m.SetFloat(name, v); } } private static void C(Material m, string name, Color v) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (m.HasProperty(name)) { m.SetColor(name, v); } } private static void ApplyLook(Material m) { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) m.DisableKeyword("_WAVES"); F(m, "_WavesOn", 0f); F(m, "_WaveHeight", 0f); m.DisableKeyword("_VERTEXCOLORWAVEFLATTENING_ON"); F(m, "_VertexColorWaveFlattening", 0f); F(m, "_VertexColorFoam", 0f); F(m, "_VertexColorDepth", 0f); F(m, "_Cull", 0f); F(m, "_ZWrite", 0f); F(m, "_TessValue", 1f); F(m, "_TessMin", 0f); F(m, "_TessMax", 1f); if (AtmosphericsMod.Cfg.RealisticColors.Value) { C(m, "_BaseColor", new Color(0.004f, 0.028f, 0.065f, 0.985f)); C(m, "_ShallowColor", new Color(0.015f, 0.1f, 0.12f, 0.35f)); C(m, "_HorizonColor", new Color(0.06f, 0.14f, 0.21f, 1f)); F(m, "_HorizonDistance", 9f); F(m, "_DepthVertical", 3.5f); F(m, "_DepthHorizontal", 0.35f); F(m, "_WaveTint", 0f); F(m, "_TranslucencyOn", 1f); m.EnableKeyword("_TRANSLUCENCY"); F(m, "_TranslucencyStrength", 0.3f); F(m, "_TranslucencyStrengthDirect", 0.06f); F(m, "_TranslucencyExp", 8f); F(m, "_TranslucencyCurvatureMask", 0.7f); F(m, "_ColorAbsorption", 0.25f); } F(m, "_NormalStrength", 0.9f); F(m, "_DistanceNormalsOn", 1f); m.EnableKeyword("_DISTANCE_NORMALS"); m.EnableKeyword("_NORMALMAP"); F(m, "_ReflectionStrength", 0.6f); F(m, "_ReflectionFresnel", 6f); F(m, "_ReflectionDistortion", 0.45f); F(m, "_ReflectionBlur", 0.25f); F(m, "_ReflectionLighting", 0.5f); F(m, "_SunReflectionStrength", 10f); F(m, "_SunReflectionDistortion", 0.8f); F(m, "_PointSpotLightReflectionStrength", 6f); m.EnableKeyword("_REFRACTION"); F(m, "_RefractionOn", 1f); F(m, "_RefractionStrength", 0.2f); m.EnableKeyword("_CAUSTICS"); F(m, "_CausticsOn", 1f); F(m, "_CausticsBrightness", 1.2f); F(m, "_VertexColorFoam", 0f); s_baseNormalStrength = (m.HasProperty("_NormalStrength") ? m.GetFloat("_NormalStrength") : (-1f)); s_baseSpeed = (m.HasProperty("_Speed") ? m.GetFloat("_Speed") : (-1f)); } private static void UpdateMaterial() { if (!((Object)(object)s_material == (Object)null)) { float num = Waves.Night * (1f - Mathf.Clamp01(AtmosphericsMod.Cfg.NightWaveHeight.Value)); if (s_baseNormalStrength >= 0f) { s_material.SetFloat("_NormalStrength", s_baseNormalStrength * Mathf.Lerp(1f, 0.3f, num)); } if (s_baseSpeed >= 0f) { s_material.SetFloat("_Speed", s_baseSpeed * Mathf.Max(0.05f, Waves.Speed)); } } } private static void UpdateScreenSpaceReflections() { bool value = AtmosphericsMod.Cfg.ScreenSpaceReflections.Value; int num = (value ? 1 : 0); if (num == s_ssrApplied) { return; } s_ssrApplied = num; try { if (s_waterFeatures == null) { s_waterFeatures = new List<StylizedWaterRenderFeature>(); foreach (StylizedWaterRenderFeature item in Resources.FindObjectsOfTypeAll<StylizedWaterRenderFeature>()) { if ((Object)(object)item != (Object)null) { s_waterFeatures.Add(item); } } foreach (StylizedWaterRenderFeature s_waterFeature in s_waterFeatures) { AtmosphericsMod.Log.Msg($"Stylized Water feature '{((Object)s_waterFeature).name}': screen-space reflections were {((s_waterFeature.screenSpaceReflectionSettings != null && s_waterFeature.screenSpaceReflectionSettings.enable) ? "ON" : "off")} in the game."); } } foreach (StylizedWaterRenderFeature s_waterFeature2 in s_waterFeatures) { if ((Object)(object)s_waterFeature2 != (Object)null && s_waterFeature2.screenSpaceReflectionSettings != null) { s_waterFeature2.screenSpaceReflectionSettings.enable = value; } } } catch (Exception ex) { AtmosphericsMod.Log.Warning("Screen-space reflection toggle failed: " + ex.Message); } if ((Object)(object)s_material != (Object)null) { if (value) { s_material.EnableKeyword("_SSR"); } else { s_material.DisableKeyword("_SSR"); } } AtmosphericsMod.Log.Msg("Screen-space reflections " + (value ? "ON" : "OFF") + "."); } } internal sealed class OceanMesh { private readonly struct Rgb { public readonly float R; public readonly float G; public readonly float B; public Rgb(float r, float g, float b) { R = r; G = g; B = b; } public static Rgb Lerp(Rgb a, Rgb b, float t) { return new Rgb(a.R + (b.R - a.R) * t, a.G + (b.G - a.G) * t, a.B + (b.B - a.B) * t); } } private const float Reach = 2500f; private readonly float _coreSpacing; private const int ShoalBudget = 2500; public readonly GameObject Go; public readonly MeshRenderer Renderer; public readonly MeshFilter Filter; private readonly Mesh _mesh; private readonly int _n; private readonly float[] _off; private readonly float[] _spacing; private readonly float[][] _aa; private readonly Vector3[] _verts; private readonly Vector3[] _normals; private readonly float[] _shoal; private readonly int[] _nearIdx; private int _shoalCursor; private readonly Il2CppStructArray<Vector3> _vArr; private readonly Il2CppStructArray<Vector3> _nArr; private readonly float[][] _cosA; private readonly float[][] _sinA; private readonly float[][] _cosB; private readonly float[][] _sinB; private readonly Material _waterMat; private readonly Material _tintMat; private bool _tintOn; private readonly Color32[] _tint; private readonly Il2CppStructArray<Color32> _tArr; private const int PatchN = 128; private static float[] s_patchA; private static float[] s_patchB; private static Texture2D s_mottle; private float _patchDrift; private readonly int[] _active = new int[8]; private readonly List<Rect> _footprint; private bool[] _quadMask; private readonly float _uvPerMeter; private readonly float _level; private Vector3 _center = new Vector3(float.NaN, 0f, 0f); private readonly float _snap; private static readonly Rgb Navy = new Rgb(0.002f, 0.012f, 0.045f); private static readonly Rgb Cobalt = new Rgb(0.004f, 0.04f, 0.16f); private static readonly Rgb Teal = new Rgb(0f, 0.075f, 0.085f); private static readonly Rgb CrestGreen = new Rgb(0.012f, 0.2f, 0.17f); private static readonly Rgb Steel = new Rgb(0.05f, 0.08f, 0.12f); private static readonly Rgb Deep = new Rgb(0f, 0.004f, 0.018f); private static readonly Rgb Foam = new Rgb(0.62f, 0.68f, 0.72f); public OceanMesh(Material material, int layer, float level, int detail, float coreSpacing, List<Rect> footprint, float uvPerMeter) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Expected O, but got Unknown //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Expected O, but got Unknown //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_059f: Expected O, but got Unknown _coreSpacing = coreSpacing; _level = level; _footprint = footprint; _uvPerMeter = uvPerMeter; _n = Mathf.Clamp(detail, 96, 320) | 1; int num = _n / 2; int num2 = Mathf.RoundToInt((float)num * 0.42f); float num3 = SolveGrowth(num - num2, total: 2500f - (float)num2 * _coreSpacing, s0: _coreSpacing); float[] array = new float[num + 1]; float num4 = _coreSpacing; for (int i = 1; i <= num; i++) { if (i > num2) { num4 *= num3; } array[i] = array[i - 1] + num4; } _off = new float[_n]; _spacing = new float[_n]; for (int j = 0; j < _n; j++) { int num5 = j - num; _off[j] = ((num5 < 0) ? (0f - array[-num5]) : array[num5]); } for (int k = 0; k < _n; k++) { float num6 = ((k > 0) ? (_off[k] - _off[k - 1]) : (_off[1] - _off[0])); float num7 = ((k < _n - 1) ? (_off[k + 1] - _off[k]) : num6); _spacing[k] = Mathf.Max(num6, num7); } _snap = _coreSpacing * 2f; _aa = new float[8][]; _cosA = new float[8][]; _sinA = new float[8][]; _cosB = new float[8][]; _sinB = new float[8][]; for (int l = 0; l < 8; l++) { _aa[l] = new float[_n]; for (int m = 0; m < _n; m++) { _aa[l][m] = Waves.AntiAlias(l, _spacing[m]); } _cosA[l] = new float[_n]; _sinA[l] = new float[_n]; _cosB[l] = new float[_n]; _sinB[l] = new float[_n]; } int num8 = _n * _n; _verts = (Vector3[])(object)new Vector3[num8]; _normals = (Vector3[])(object)new Vector3[num8]; _shoal = new float[num8]; for (int n = 0; n < num8; n++) { _shoal[n] = 1f; _normals[n] = Vector3.up; } List<int> list = new List<int>(); for (int num9 = 0; num9 < _n; num9++) { for (int num10 = 0; num10 < _n; num10++) { _verts[num9 * _n + num10] = new Vector3(_off[num10], 0f, _off[num9]); if (Mathf.Abs(_off[num10]) <= 180f && Mathf.Abs(_off[num9]) <= 180f) { list.Add(num9 * _n + num10); } } } _nearIdx = list.ToArray(); _vArr = new Il2CppStructArray<Vector3>((long)num8); _nArr = new Il2CppStructArray<Vector3>((long)num8); _mesh = new Mesh { name = "FroggosAtmospherics_Ocean" }; _mesh.indexFormat = (IndexFormat)(num8 > 65000); _mesh.MarkDynamic(); Copy<Vector3>(_verts, _vArr); _mesh.vertices = _vArr; Vector4[] array2 = (Vector4[])(object)new Vector4[num8]; for (int num11 = 0; num11 < num8; num11++) { array2[num11] = new Vector4(1f, 0f, 0f, -1f); } _mesh.tangents = Il2CppStructArray<Vector4>.op_Implicit(array2); Go = new GameObject("FroggosAtmospherics_Ocean"); Go.SetActive(false); Go.layer = layer; Object.DontDestroyOnLoad((Object)(object)Go); Filter = Go.AddComponent<MeshFilter>(); Filter.sharedMesh = _mesh; Renderer = Go.AddComponent<MeshRenderer>(); ((Renderer)Renderer).sharedMaterial = material; ((Renderer)Renderer).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)Renderer).receiveShadows = true; ((Renderer)Renderer).lightProbeUsage = (LightProbeUsage)0; ((Renderer)Renderer).reflectionProbeUsage = (ReflectionProbeUsage)2; _waterMat = material; _tint = (Color32[])(object)new Color32[num8]; _tArr = new Il2CppStructArray<Color32>((long)num8); _mesh.subMeshCount = 2; Shader val = Shader.Find("Sprites/Default"); if ((Object)(object)val != (Object)null) { MakePatches(); _tintMat = new Material(val) { name = "FroggosAtmospherics_OceanTint", renderQueue = material.renderQueue + 1, mainTexture = (Texture)(object)s_mottle }; } } private void SetTint(bool on) { if ((Object)(object)_tintMat == (Object)null) { on = false; } if (on != _tintOn) { _tintOn = on; ((Renderer)Renderer).sharedMaterials = Il2CppReferenceArray<Material>.op_Implicit((Material[])(object)((!on) ? new Material[1] { _waterMat } : new Material[2] { _waterMat, _tintMat })); } } private static void MakePatches() { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_0137: 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) if (s_patchA != null) { return; } s_patchA = new float[16384]; s_patchB = new float[16384]; for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { float num = (float)j / 128f; float num2 = (float)i / 128f; s_patchA[i * 128 + j] = Fbm(num, num2, 3, 4, 11); s_patchB[i * 128 + j] = Fbm(num + 0.37f, num2 + 0.61f, 4, 4, 29); } } Normalize(s_patchA); Normalize(s_patchB); s_mottle = new Texture2D(256, 256, (TextureFormat)4, true) { name = "FroggosAtmospherics_Mottle", wrapMode = (TextureWrapMode)0 }; Color32[] array = (Color32[])(object)new Color32[65536]; for (int k = 0; k < 256; k++) { for (int l = 0; l < 256; l++) { float num3 = Fbm((float)l / 256f, (float)k / 256f, 8, 4, 53); byte b = (byte)(255f * (0.72f + 0.28f * num3)); array[k * 256 + l] = new Color32(b, b, b, byte.MaxValue); } } s_mottle.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array)); s_mottle.Apply(true, true); ((Object)s_mottle).hideFlags = (HideFlags)32; } private static void Normalize(float[] a) { float num = float.MaxValue; float num2 = float.MinValue; foreach (float val in a) { num = Math.Min(num, val); num2 = Math.Max(num2, val); } float num3 = ((num2 > num) ? (1f / (num2 - num)) : 1f); for (int j = 0; j < a.Length; j++) { a[j] = (a[j] - num) * num3; } } private static float Fbm(float u, float v, int f, int octaves, int seed) { float num = 0f; float num2 = 0.5f; float num3 = 0f; for (int i = 0; i < octaves; i++) { num += num2 * ValueNoise(u * (float)f, v * (float)f, f, seed + i * 97); num3 += num2; num2 *= 0.5f; f *= 2; } return num / num3; } private static float ValueNoise(float x, float y, int period, int seed) { int num = (int)Math.Floor(x); int num2 = (int)Math.Floor(y); float num3 = x - (float)num; float num4 = y - (float)num2; num3 = num3 * num3 * (3f - 2f * num3); num4 = num4 * num4 * (3f - 2f * num4); int num5 = (num % period + period) % period; int x2 = (num5 + 1) % period; int num6 = (num2 % period + period) % period; int y2 = (num6 + 1) % period; float num7 = Hash(num5, num6, seed); float num8 = Hash(x2, num6, seed); float num9 = Hash(num5, y2, seed); float num10 = Hash(x2, y2, seed); return num7 + (num8 - num7) * num3 + (num9 - num7) * num4 + (num7 - num8 - num9 + num10) * num3 * num4; } private static float Hash(int x, int y, int seed) { int num = x * 374761393 + y * 668265263 + seed * 1442695041; int num2 = (num ^ (num >>> 13)) * 1274126177; return (float)(uint)((num2 ^ (num2 >>> 16)) & 0xFFFFFF) / 16777215f; } private static float Patch(float[] field, float u, float v) { u -= (float)Math.Floor(u); v -= (float)Math.Floor(v); float num = u * 128f; float num2 = v * 128f; int num3 = (int)num; int num4 = (int)num2; float num5 = num - (float)num3; float num6 = num2 - (float)num4; int num7 = (num3 + 1) % 128; int num8 = (num4 + 1) % 128; num3 %= 128; num4 %= 128; float num9 = field[num4 * 128 + num3]; float num10 = field[num4 * 128 + num7]; float num11 = field[num8 * 128 + num3]; float num12 = field[num8 * 128 + num7]; return num9 + (num10 - num9) * num5 + (num11 - num9) * num6 + (num9 - num10 - num11 + num12) * num5 * num6; } private static float SolveGrowth(int n, float s0, float total) { double num = 1.0001; double num2 = 2.0; for (int i = 0; i < 60; i++) { double num3 = (num + num2) * 0.5; if ((double)s0 * num3 * (Math.Pow(num3, n) - 1.0) / (num3 - 1.0) > (double)total) { num2 = num3; } else { num = num3; } } return (float)((num + num2) * 0.5); } private unsafe static void Copy<T>(T[] src, Il2CppStructArray<T> dst) where T : unmanaged { IntPtr intPtr = IntPtr.Add(((Il2CppObjectBase)dst).Pointer, 4 * IntPtr.Size); long num = (long)src.Length * (long)sizeof(T); fixed (T* source = src) { Buffer.MemoryCopy(source, (void*)intPtr, num, num); } } public void Destroy() { if ((Object)(object)Go != (Object)null) { Object.Destroy((Object)(object)Go); } if ((Object)(object)_mesh != (Object)null) { Object.Destroy((Object)(object)_mesh); } if ((Object)(object)_tintMat != (Object)null) { Object.Destroy((Object)(object)_tintMat); } } public static bool InFootprint(List<Rect> footprint, float x, float z) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (footprint == null || footprint.Count == 0) { return true; } Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(x, z); for (int i = 0; i < footprint.Count; i++) { Rect val2 = footprint[i]; if (((Rect)(ref val2)).Contains(val)) { return true; } } return false; } public void Update(Vector3 cameraPos) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (!Go.activeSelf) { Go.SetActive(true); } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Mathf.Round(cameraPos.x / _snap) * _snap, _level, Mathf.Round(cameraPos.z / _snap) * _snap); if (val.x != _center.x || val.z != _center.z) { _center = val; Go.transform.SetPositionAndRotation(_center, Quaternion.identity); RebuildUv(); RebuildTriangles(); } UpdateShoals(); Displace(); } private void UpdateShoals() { int num = Math.Min(2500, _nearIdx.Length); for (int i = 0; i < num; i++) { if (_shoalCursor >= _nearIdx.Length) { _shoalCursor = 0; } int num2 = _nearIdx[_shoalCursor++]; int num3 = num2 % _n; int num4 = num2 / _n; _shoal[num2] = Shoals.Factor(_center.x + _off[num3], _center.z + _off[num4], _level); } } private void Displace() { //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) int nActive = 0; for (int i = 0; i < 8; i++) { if (Waves.Amp[i] > 1E-05f) { _active[nActive++] = i; } } double num = _center.x; double num2 = _center.z; for (int j = 0; j < nActive; j++) { int num3 = _active[j]; double num4 = Waves.K[num3]; double num5 = Waves.Phase[num3]; float[] array = _cosA[num3]; float[] array2 = _sinA[num3]; float[] array3 = _cosB[num3]; float[] array4 = _sinB[num3]; for (int k = 0; k < _n; k++) { double num6 = num4 * (double)Waves.DirX[num3] * (num + (double)_off[k]) - num5; double num7 = num4 * (double)Waves.DirZ[num3] * (num2 + (double)_off[k]); array[k] = (float)Math.Cos(num6); array2[k] = (float)Math.Sin(num6); array3[k] = (float)Math.Cos(num7); array4[k] = (float)Math.Sin(num7); } } int n = _n; bool flag = AtmosphericsMod.Cfg.Whitecaps.Value && SkyQuality.Level >= 1; float variety = Mathf.Clamp(AtmosphericsMod.Cfg.WaterColorVariety.Value, 0f, 2f); bool tint = SkyQuality.Level >= 1 && (variety > 0.01f || flag); SetTint(tint); float light = Lighting.Daylight; float heightRef = Mathf.Max(0.05f, Waves.MaxAmplitude * 0.45f); _patchDrift += Time.deltaTime * 0.0015f * Mathf.Max(0.2f, Waves.Speed); float drift = _patchDrift; float cxf = _center.x; float czf = _center.z; float capRange = Mathf.Max(0.01f, Waves.MaxAmplitude); float capStrength = (flag ? Mathf.Clamp01((Waves.Height - 0.3f) / 0.5f) : 0f); Parallel.For(0, n, delegate(int num9) { for (int l = 0; l < n; l++) { int num8 = num9 * n + l; float num10 = _shoal[num8]; float num11 = 0f; float num12 = 0f; float num13 = 0f; float num14 = 0f; float num15 = 1f; float num16 = 0f; if (num10 > 0f) { for (int m = 0; m < nActive; m++) { int num17 = _active[m]; float num18 = Math.Min(_aa[num17][l], _aa[num17][num9]) * num10; if (!(num18 <= 0f)) { float num19 = _cosA[num17][l] * _cosB[num17][num9] - _sinA[num17][l] * _sinB[num17][num9]; float num20 = _sinA[num17][l] * _cosB[num17][num9] + _cosA[num17][l] * _sinB[num17][num9]; float num21 = Waves.Amp[num17] * num18; float num22 = Waves.Q[num17] * num21; float num23 = Waves.K[num17] * num21; float num24 = Waves.DirX[num17]; float num25 = Waves.DirZ[num17]; num11 += num22 * num24 * num19; num13 += num22 * num25 * num19; num12 += num21 * num20; num14 -= num24 * n