Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of AstralSkies v0.6.2
BepInEx/plugins/Zephyrfit-AstralSkies/AstralSkies.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; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Runtime.Serialization.Json; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("AstralSkies")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.6.2.0")] [assembly: AssemblyInformationalVersion("0.6.2")] [assembly: AssemblyProduct("AstralSkies")] [assembly: AssemblyTitle("AstralSkies")] [assembly: AssemblyVersion("0.6.2.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 AstralSkies { public static class Astronomy { public struct Vector { public double x; public double y; public double z; public double Length => Math.Sqrt(x * x + y * y + z * z); public Vector(double x, double y, double z) { this.x = x; this.y = y; this.z = z; } public static Vector operator -(Vector a, Vector b) { return new Vector(a.x - b.x, a.y - b.y, a.z - b.z); } } public const double Rad = Math.PI / 180.0; private static readonly double[,] elements = new double[6, 12] { { 0.38709843, 0.20563661, 7.00559432, 252.25166724, 77.45771895, 48.33961819, 0.0, 2.123E-05, -0.00590158, 149472.67486623, 0.15940013, -0.12214182 }, { 0.72332102, 0.00676399, 3.39777545, 181.9797085, 131.76755713, 76.67261496, -2.6E-07, -5.107E-05, 0.00043494, 58517.8156026, 0.05679648, -0.27274174 }, { 1.00000018, 0.01673163, -0.00054346, 100.46691572, 102.93005885, -5.11260389, -3E-08, -3.661E-05, -0.01337178, 35999.37306329, 0.3179526, -0.24123856 }, { 1.52371243, 0.09336511, 1.85181869, -4.56813164, -23.91744784, 49.71320984, 9.7E-07, 9.149E-05, -0.00724757, 19140.29934243, 0.45223625, -0.26852431 }, { 5.20248019, 0.0485359, 1.29861416, 34.33479152, 14.27495244, 100.29282654, -2.864E-05, -0.00018026, -0.00322699, 3034.90371757, 0.18199196, 0.13024619 }, { 9.54149883, 0.05550825, 2.49424102, 50.07571329, 92.86136063, 113.63998702, -3.065E-05, -0.00032044, 0.00451969, 1222.11494724, 0.54179478, -0.25015002 } }; public static double EccentricAnomaly(double mean, double e) { mean = Math.IEEERemainder(mean, Math.PI * 2.0); double num = mean; for (int i = 0; i < 16; i++) { double num2 = (num - e * Math.Sin(num) - mean) / (1.0 - e * Math.Cos(num)); num -= num2; if (Math.Abs(num2) < 1E-12) { break; } } return num; } public static Vector Heliocentric(int body, double days) { if (body < 0 || body > 5 || double.IsNaN(days) || days < -1826250.0 || days > 365250.0) { throw new ArgumentOutOfRangeException(); } double num = days / 36525.0; double num2 = elements[body, 0] + num * elements[body, 6]; double num3 = elements[body, 1] + num * elements[body, 7]; double num4 = (elements[body, 2] + num * elements[body, 8]) * (Math.PI / 180.0); double num5 = (elements[body, 4] + num * elements[body, 10]) * (Math.PI / 180.0); double num6 = (elements[body, 5] + num * elements[body, 11]) * (Math.PI / 180.0); double num7 = elements[body, 3] + num * elements[body, 9] - num5 / (Math.PI / 180.0); if (body == 4) { num7 += -0.00012452 * num * num + 0.0606406 * Math.Cos(38.35125 * num * (Math.PI / 180.0)) - 0.35635438 * Math.Sin(38.35125 * num * (Math.PI / 180.0)); } if (body == 5) { num7 += 0.00025899 * num * num - 0.13434469 * Math.Cos(38.35125 * num * (Math.PI / 180.0)) + 0.87320147 * Math.Sin(38.35125 * num * (Math.PI / 180.0)); } double num8 = EccentricAnomaly(num7 * (Math.PI / 180.0), num3); double num9 = num2 * (Math.Cos(num8) - num3); double num10 = num2 * Math.Sqrt(1.0 - num3 * num3) * Math.Sin(num8); double num11 = num5 - num6; double num12 = Math.Cos(num11); double num13 = Math.Sin(num11); double num14 = Math.Cos(num6); double num15 = Math.Sin(num6); double num16 = Math.Cos(num4); double num17 = Math.Sin(num4); return new Vector((num12 * num14 - num13 * num15 * num16) * num9 + ((0.0 - num13) * num14 - num12 * num15 * num16) * num10, (num12 * num15 + num13 * num14 * num16) * num9 + ((0.0 - num13) * num15 + num12 * num14 * num16) * num10, num13 * num17 * num9 + num12 * num17 * num10); } public static Vector Equatorial(Vector ecliptic) { double num = Math.Cos(0.4090926102968565); double num2 = Math.Sin(0.4090926102968565); return new Vector(ecliptic.x, num * ecliptic.y - num2 * ecliptic.z, num2 * ecliptic.y + num * ecliptic.z); } public static Vector Geocentric(int body, double days) { return Equatorial(Heliocentric(body, days) - Heliocentric(2, days)); } public static double SiderealAngle(double days) { if (days > 365250.0) { return Math.PI * 2.0 * SkyMath.Fraction(days * 1.0027379 + 0.78); } Vector vector = Heliocentric(2, days); Vector vector2 = Equatorial(new Vector(0.0 - vector.x, 0.0 - vector.y, 0.0 - vector.z)); return Math.Atan2(vector2.y, vector2.x) + Math.PI * 2.0 * (SkyMath.Fraction(days) - 0.5); } public static Vector Horizontal(Vector v, double latitude, double sidereal) { double num = Math.Cos(sidereal); double num2 = Math.Sin(sidereal); double num3 = Math.Sin(latitude * (Math.PI / 180.0)); double num4 = Math.Cos(latitude * (Math.PI / 180.0)); double num5 = num * v.x + num2 * v.y; return new Vector((0.0 - num2) * v.x + num * v.y, num4 * num5 + num3 * v.z, (0.0 - num3) * num5 + num4 * v.z); } public static double PlanetMagnitude(int body, double days) { Vector vector = Heliocentric(body, days); Vector vector2 = Heliocentric(2, days); Vector vector3 = vector - vector2; double length = vector.Length; double length2 = vector3.Length; double num = Math.Acos(SkyMath.Clamp((vector.x * vector3.x + vector.y * vector3.y + vector.z * vector3.z) / (length * length2), -1.0, 1.0)); double d = Math.Max(0.001, (Math.Sin(num) + (Math.PI - num) * Math.Cos(num)) / Math.PI); return body switch { 4 => -9.4, 3 => -1.52, 1 => -4.4, 0 => -0.42, _ => -8.88, } + 5.0 * Math.Log10(length * length2) - 2.5 * Math.Log10(d); } public static double StellarFlux(double magnitude) { return Math.Pow(10.0, -0.18 * (magnitude + 1.46)); } public static double MoonWashout(double magnitude, double illumination, double strength) { return Math.Exp((0.0 - SkyMath.Clamp(strength, 0.0, 1.0)) * SkyMath.Clamp(illumination, 0.0, 1.0) * Math.Max(0.0, magnitude - 1.0) * 0.42); } public static double MeteorDuration(long slot, int seed) { return 1.4 + 1.2 * SkyMath.Random((uint)((int)slot + seed + 91)); } public static bool Meteor(double seconds, double rate, int seed, out long slot, out double age) { slot = 0L; age = 0.0; if (rate <= 0.0 || seconds < 0.0 || double.IsNaN(seconds) || double.IsInfinity(seconds) || double.IsNaN(rate) || double.IsInfinity(rate)) { return false; } double num = 60.0 / SkyMath.Clamp(rate, 0.05, 12.0); double num2 = SkyMath.Random((uint)seed) * 0.6 * num; slot = (long)Math.Floor((seconds - num2) / num); age = seconds - num2 - (double)slot * num; if (age >= 0.0) { return age < MeteorDuration(slot, seed); } return false; } public static double NextMeteor(double seconds, double rate, int seed) { if (rate <= 0.0 || seconds < 0.0 || double.IsNaN(seconds) || double.IsInfinity(seconds) || double.IsNaN(rate) || double.IsInfinity(rate)) { return double.PositiveInfinity; } double num = 60.0 / SkyMath.Clamp(rate, 0.05, 12.0); double num2 = SkyMath.Random((uint)seed) * 0.6 * num; return num - (seconds - num2 - Math.Floor((seconds - num2) / num) * num); } } internal sealed class AtmosphereFrame { private readonly Color fog = RenderSettings.fogColor; private readonly Color sky = RenderSettings.ambientSkyColor; private readonly Color equator = RenderSettings.ambientEquatorColor; private readonly Color ground = RenderSettings.ambientGroundColor; private readonly Color ambient = RenderSettings.ambientLight; private readonly Light light = RenderSettings.sun; private readonly SphericalHarmonicsL2 probe = RenderSettings.ambientProbe; private SphericalHarmonicsL2 appliedProbe; private bool probeEdited; private readonly float lightIntensity; private float appliedIntensity; private bool dimmed; private readonly Color lightColor; private readonly Quaternion lightRotation; private Color appliedFog; private Color appliedSky; private Color appliedEquator; private Color appliedGround; private Color appliedAmbient; private Color appliedLight; private Quaternion appliedRotation; private bool tinted; private bool rotated; private readonly bool canRestoreRotation; private EclipseShaderFrame eclipseShaders; public AtmosphereFrame() { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)light)) { lightColor = light.color; lightIntensity = light.intensity; canRestoreRotation = UnityRotation.Normalize(((Component)light).transform.rotation, out var result); lightRotation = result; } } public static Color CopperTint(Color color, float amount) { //IL_0000: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) Astronomy.Vector vector = SkyMath.CopperColor(new Astronomy.Vector(color.r, color.g, color.b), amount); return new Color((float)vector.x, (float)vector.y, (float)vector.z, color.a); } private static bool SameProbe(SphericalHarmonicsL2 a, SphericalHarmonicsL2 b) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { if (((SphericalHarmonicsL2)(ref a))[i, j] != ((SphericalHarmonicsL2)(ref b))[i, j]) { return false; } } } return true; } private static Color ScaleRgb(Color color, float factor) { //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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) return new Color(color.r * factor, color.g * factor, color.b * factor, color.a); } public void Apply(float copper, Vector3? lightDirection, float eclipse = 0f, float raidDarkness = 0f, float eclipseAmbientFloor = 0.06f) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_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_033d: Unknown result type (might be due to invalid IL or missing references) if (eclipse > 0f) { eclipseShaders = new EclipseShaderFrame(eclipse, eclipseAmbientFloor); } if (copper > 0f || eclipse > 0f || raidDarkness > 0f) { tinted = true; RenderSettings.fogColor = CopperTint(fog, copper); RenderSettings.ambientSkyColor = CopperTint(sky, copper); RenderSettings.ambientEquatorColor = CopperTint(equator, copper); RenderSettings.ambientGroundColor = CopperTint(ground, copper); RenderSettings.ambientLight = CopperTint(ambient, copper); if (eclipse > 0f || raidDarkness > 0f) { float factor = Mathf.Lerp(1f, eclipseAmbientFloor, eclipse) * (float)SkyMath.RaidLightFactor(1.0, raidDarkness, 0.8); RenderSettings.fogColor = ScaleRgb(RenderSettings.fogColor, factor); RenderSettings.ambientSkyColor = ScaleRgb(RenderSettings.ambientSkyColor, factor); RenderSettings.ambientEquatorColor = ScaleRgb(RenderSettings.ambientEquatorColor, factor); RenderSettings.ambientGroundColor = ScaleRgb(RenderSettings.ambientGroundColor, factor); RenderSettings.ambientLight = ScaleRgb(RenderSettings.ambientLight, factor); if (Object.op_Implicit((Object)(object)light)) { dimmed = true; appliedIntensity = lightIntensity * Mathf.Lerp(1f, 0.015f, eclipse) * (float)SkyMath.RaidLightFactor(1.0, raidDarkness, 0.7); light.intensity = appliedIntensity; } } if (copper > 0f || eclipse > 0f || raidDarkness > 0f) { float num = Mathf.Lerp(1f, eclipseAmbientFloor, eclipse) * (float)SkyMath.RaidLightFactor(1.0, raidDarkness, 0.8); appliedProbe = probe; for (int i = 0; i < 9; i++) { SphericalHarmonicsL2 val = probe; double x = ((SphericalHarmonicsL2)(ref val))[0, i]; val = probe; double y = ((SphericalHarmonicsL2)(ref val))[1, i]; val = probe; Astronomy.Vector vector = SkyMath.CopperColor(new Astronomy.Vector(x, y, ((SphericalHarmonicsL2)(ref val))[2, i]), copper); ((SphericalHarmonicsL2)(ref appliedProbe))[0, i] = (float)vector.x * num; ((SphericalHarmonicsL2)(ref appliedProbe))[1, i] = (float)vector.y * num; ((SphericalHarmonicsL2)(ref appliedProbe))[2, i] = (float)vector.z * num; } probeEdited = true; RenderSettings.ambientProbe = appliedProbe; } appliedFog = RenderSettings.fogColor; appliedSky = RenderSettings.ambientSkyColor; appliedEquator = RenderSettings.ambientEquatorColor; appliedGround = RenderSettings.ambientGroundColor; appliedAmbient = RenderSettings.ambientLight; if (Object.op_Implicit((Object)(object)light)) { light.color = CopperTint(lightColor, copper); appliedLight = light.color; } } if (Object.op_Implicit((Object)(object)light) && canRestoreRotation && lightDirection.HasValue && UnityRotation.Look(-lightDirection.Value, out appliedRotation)) { rotated = true; string operation = RotationDiagnostics.Operation; RotationDiagnostics.Operation = "Apply normalized sky light rotation"; try { ((Component)light).transform.rotation = appliedRotation; } finally { RotationDiagnostics.Operation = operation; } } } public void Restore() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_0192: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) eclipseShaders?.Restore(); bool num = probeEdited && SameProbe(RenderSettings.ambientProbe, appliedProbe); if (tinted) { if (RenderSettings.fogColor == appliedFog) { RenderSettings.fogColor = fog; } if (RenderSettings.ambientSkyColor == appliedSky) { RenderSettings.ambientSkyColor = sky; } if (RenderSettings.ambientEquatorColor == appliedEquator) { RenderSettings.ambientEquatorColor = equator; } if (RenderSettings.ambientGroundColor == appliedGround) { RenderSettings.ambientGroundColor = ground; } if (RenderSettings.ambientLight == appliedAmbient) { RenderSettings.ambientLight = ambient; } if (Object.op_Implicit((Object)(object)light) && light.color == appliedLight) { light.color = lightColor; } } if (dimmed && Object.op_Implicit((Object)(object)light) && light.intensity == appliedIntensity) { light.intensity = lightIntensity; } if (num) { RenderSettings.ambientProbe = probe; } if (rotated && Object.op_Implicit((Object)(object)light) && ((Component)light).transform.rotation == appliedRotation) { string operation = RotationDiagnostics.Operation; RotationDiagnostics.Operation = "Restore normalized sky light rotation"; try { ((Component)light).transform.rotation = lightRotation; } finally { RotationDiagnostics.Operation = operation; } } } } internal sealed class AuroraColorPicker { private bool lightDraft; internal bool IsOpen { get; private set; } internal int Slot { get; private set; } internal string Design { get; private set; } = ""; internal string Original { get; private set; } = "#000000"; internal string Hex { get; private set; } = "#000000"; internal double Hue { get; private set; } internal double Saturation { get; private set; } internal double Value { get; private set; } internal bool OpenLight(string context, string current) { Cancel(); if (string.IsNullOrEmpty(context) || context.Length > 160 || !AuroraMemory.ValidHex(current)) { return false; } Design = context; Slot = 0; Original = current; Hue = 0.0; SetHex(current); bool flag = (IsOpen = true); lightDraft = flag; return true; } internal bool MatchesLight(string context, string current) { if (IsOpen && lightDraft && Design == context) { return string.Equals(Original, current, StringComparison.OrdinalIgnoreCase); } return false; } internal bool ApplyLight(string context, string current, Func<string, bool> replace) { if (!MatchesLight(context, current)) { Cancel(); return false; } if (replace == null || !replace(Hex)) { return false; } Cancel(); return true; } internal bool Open(int slot, string design, int count, string current) { Cancel(); if (slot < 0 || slot > 2 || count < 1 || count > 3 || slot >= count || !AuroraMemory.Supported(design) || !AuroraMemory.ValidHex(current)) { return false; } Slot = slot; Design = design; Original = current; Hue = 0.0; SetHex(current); IsOpen = true; return true; } internal bool Matches(string design, int count, string current) { if (IsOpen && !lightDraft && Design == design && count >= 1 && count <= 3 && Slot < count) { return string.Equals(Original, current, StringComparison.OrdinalIgnoreCase); } return false; } internal void Cancel() { IsOpen = false; lightDraft = false; } internal bool Apply(string design, int count, string current, Func<int, string, bool> replace) { if (!Matches(design, count, current)) { Cancel(); return false; } if (replace == null || !replace(Slot, Hex)) { return false; } Cancel(); return true; } internal bool SetHex(string hex) { if (!AuroraMemory.ValidHex(hex)) { return false; } uint num = uint.Parse(hex.Substring(1), NumberStyles.HexNumber, CultureInfo.InvariantCulture); double num2 = (double)((num >> 16) & 0xFF) / 255.0; double num3 = (double)((num >> 8) & 0xFF) / 255.0; double num4 = (double)(num & 0xFF) / 255.0; double num5 = Math.Max(num2, Math.Max(num3, num4)); double num6 = Math.Min(num2, Math.Min(num3, num4)); double num7 = num5 - num6; if (num7 > 0.0) { double num8 = ((num5 == num2) ? ((num3 - num4) / num7) : ((num5 == num3) ? (2.0 + (num4 - num2) / num7) : (4.0 + (num2 - num3) / num7))); Hue = (num8 / 6.0 + 1.0) % 1.0; } Saturation = ((num5 == 0.0) ? 0.0 : (num7 / num5)); Value = num5; Hex = hex.ToUpperInvariant(); return true; } private static bool Finite(double n) { if (!double.IsNaN(n)) { return !double.IsInfinity(n); } return false; } private static double Unit(double n) { return Math.Max(0.0, Math.Min(1.0, n)); } internal bool SetHsv(double hue, double saturation, double value) { if (!Finite(hue) || !Finite(saturation) || !Finite(value)) { return false; } Hue = Unit(hue); Saturation = Unit(saturation); Value = Unit(value); Rgb(Hue, Saturation, Value, out var r, out var g, out var b); Hex = "#" + Byte(r).ToString("X2", CultureInfo.InvariantCulture) + Byte(g).ToString("X2", CultureInfo.InvariantCulture) + Byte(b).ToString("X2", CultureInfo.InvariantCulture); return true; } private static int Byte(double n) { return (int)Math.Round(Unit(n) * 255.0, MidpointRounding.AwayFromZero); } internal static void Rgb(double hue, double saturation, double value, out double r, out double g, out double b) { double num = Unit(hue) * 6.0; double num2 = Unit(saturation); double num3 = Unit(value); double num4 = num - Math.Floor(num); double num5 = num3 * (1.0 - num2); double num6 = num3 * (1.0 - num4 * num2); double num7 = num3 * (1.0 - (1.0 - num4) * num2); switch ((int)num % 6) { case 0: r = num3; g = num7; b = num5; break; case 1: r = num6; g = num3; b = num5; break; case 2: r = num5; g = num3; b = num7; break; case 3: r = num5; g = num6; b = num3; break; case 4: r = num7; g = num5; b = num3; break; default: r = num3; g = num5; b = num6; break; } } internal static void Sample(int row, int column, out double hue, out double saturation, out double value) { if (row < 0 || row > 3 || column < 0 || column > 7) { throw new ArgumentOutOfRangeException(); } hue = (double)column / 8.0; saturation = row switch { 1 => 0.45, 3 => 0.0, _ => 1.0, }; value = row switch { 2 => 0.55, 3 => (double)column / 7.0, _ => 1.0, }; } } internal sealed class AuroraDesign : IDisposable { private readonly Texture2D[] structure = (Texture2D[])(object)new Texture2D[2]; private readonly Texture2D[] striations = (Texture2D[])(object)new Texture2D[2]; private readonly float[][] basis = new float[2][]; private readonly float[] builtDensity = new float[2]; private readonly float[] pendingDensity = new float[2]; private readonly double[] changedAt = new double[2]; private readonly Func<double> now; private Color[] pixels; private const int Size = 512; private static readonly string[] Slots = new string[5] { "_AuroraA", "_AuroraD", "_MainStructureSize", "_StriationsSize", "_TotalHeight" }; internal static bool Supported(string name) { if (!(name == "Curtains")) { return name == "Arcs"; } return true; } public AuroraDesign(Func<double> clock = null) { now = clock ?? new Func<double>(Clock); } private static double Clock() { return (double)Stopwatch.GetTimestamp() / (double)Stopwatch.Frequency; } private static int Slot(string name) { return (!(name == "Curtains")) ? 1 : 0; } private static double Wave(double cycles) { return Math.Sin(cycles * 2.0 * Math.PI); } internal static float Mask(string design, double u, double v, bool fine) { double num = 0.12 * Wave(u) + 0.045 * Wave(3.0 * u) + 0.018 * Wave(7.0 * u + v); double num2 = Wave(v + num); double num3 = Wave(2.0 * v - 0.08 * Wave(2.0 * u)); double val = ((design == "Curtains") ? (Math.Exp((0.0 - num2) * num2 * 32.0) * (0.82 + 0.18 * Wave(3.0 * u + 0.04 * Wave(v)))) : Math.Max(Math.Exp((0.0 - num2) * num2 * 20.0), 0.7 * Math.Exp((0.0 - num3) * num3 * 34.0))); if (fine) { val = 0.72 + 0.28 * Math.Pow(0.5 + 0.5 * Wave(9.0 * u + 0.15 * Wave(3.0 * v) + 0.04 * Wave(3.0 * u)), 2.0); } return (float)Math.Max(0.0, Math.Min(1.0, val)); } internal static Color Radiance(string design, double position) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) float num = (float)Math.Max(0.0, Math.Min(1.0, position)); if (!(design == "Curtains")) { return new Color(0.08f + 0.68f * num * num, 0.82f - 0.6f * num * num, 0.38f + 0.42f * num, 1f); } return new Color(0.1f + 0.42f * num * num, 0.92f - 0.5f * num, 0.24f + 0.54f * num, 1f); } private Texture2D Create(string design, bool fine) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00d6: Expected O, but got Unknown if (pixels == null) { pixels = (Color[])(object)new Color[262144]; } for (int i = 0; i < 512; i++) { for (int j = 0; j < 512; j++) { float num = Mask(design, (double)j / 512.0, (double)i / 512.0, fine); pixels[i * 512 + j] = new Color(num, num, num, 1f); } } Texture2D val = new Texture2D(512, 512, (TextureFormat)4, true, true) { name = "AstralSkies " + design + (fine ? " striations" : " structure"), hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)2 }; val.SetPixels(pixels); val.Apply(true, false); return val; } private void Density(string name, int slot, float density) { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if (basis[slot] == null) { basis[slot] = new float[262144]; for (int i = 0; i < 512; i++) { for (int j = 0; j < 512; j++) { basis[slot][i * 512 + j] = Mask(name, (double)j / 512.0, (double)i / 512.0, fine: false); } } } for (int k = 0; k < pixels.Length; k++) { float num = ((density == 0f) ? 0f : ((density == 1f) ? basis[slot][k] : ((float)Math.Pow(basis[slot][k], 1f / density)))); pixels[k] = new Color(num, num, num, 1f); } structure[slot].SetPixels(pixels); structure[slot].Apply(true, false); builtDensity[slot] = density; } internal bool CanApply(Material native, Material target) { if (!Object.op_Implicit((Object)(object)native) || !Object.op_Implicit((Object)(object)target) || (Object)(object)native == (Object)(object)target) { return false; } string[] slots = Slots; foreach (string text in slots) { if (!native.HasProperty(text) || !target.HasProperty(text)) { return false; } } return true; } internal void Apply(string design, Material native, Material target, float width = 1f, float height = 1f, float density = 1f) { if (!CanApply(native, target)) { throw new NotSupportedException("Native structure slots unavailable on scoped sky material"); } float num = native.GetFloat("_MainStructureSize"); float num2 = native.GetFloat("_StriationsSize"); float num3 = native.GetFloat("_TotalHeight"); if (!(num > 0f) || !(num2 > 0f) || !(num3 > 0f) || float.IsInfinity(num) || float.IsInfinity(num2) || float.IsInfinity(num3)) { throw new NotSupportedException("Native aurora structure scale unavailable"); } if (float.IsNaN(width) || float.IsNaN(height) || float.IsNaN(density) || width < 0.25f || width > 3f || height < 0.25f || height > 2f || density < 0f || density > 3f) { throw new ArgumentOutOfRangeException("Aurora shape"); } int num4 = Slot(design); if (!Object.op_Implicit((Object)(object)structure[num4])) { structure[num4] = Create(design, fine: false); striations[num4] = Create(design, fine: true); Density(design, num4, density); pendingDensity[num4] = density; } else if (builtDensity[num4] != density) { double num5 = now(); if (pendingDensity[num4] != density) { pendingDensity[num4] = density; changedAt[num4] = num5; } if (num5 - changedAt[num4] >= 0.12) { Density(design, num4, density); } } else { pendingDensity[num4] = density; } target.SetTexture("_AuroraA", (Texture)(object)structure[num4]); target.SetTexture("_AuroraD", (Texture)(object)striations[num4]); target.SetFloat("_MainStructureSize", num * ((design == "Curtains") ? 1.4f : 2.1f) * width); target.SetFloat("_StriationsSize", num2 * 0.65f * width); target.SetFloat("_TotalHeight", num3 * height); } public void Dispose() { Texture2D[] array = structure; foreach (Texture2D val in array) { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } } array = striations; foreach (Texture2D val2 in array) { if (Object.op_Implicit((Object)(object)val2)) { Object.Destroy((Object)(object)val2); } } } } internal static class AuroraMemory { internal struct Value { internal bool enabled; internal float intensity; internal float hue; internal float saturation; internal float width; internal float height; internal float density; internal float brightness; internal int colors; internal string color1; internal string color2; internal string color3; internal Value(bool enabled, float intensity, float hue, float saturation) { this.enabled = enabled; this.intensity = intensity; this.hue = hue; this.saturation = saturation; width = (height = (density = (brightness = 1f))); colors = 0; color1 = "#32FF80"; color2 = "#36CBDD"; color3 = "#BA70FF"; } } internal static readonly string[] Designs = new string[4] { "Vanilla", "Custom", "Curtains", "Arcs" }; internal static bool ValidHex(string text) { if (text == null || text.Length != 7 || text[0] != '#') { return false; } for (int i = 1; i < 7; i++) { if (!Uri.IsHexDigit(text[i])) { return false; } } return true; } internal static bool Supported(string design) { return Array.IndexOf(Designs, design) >= 0; } internal static Dictionary<string, Value> Defaults() { Dictionary<string, Value> dictionary = new Dictionary<string, Value>(StringComparer.Ordinal); string[] designs = Designs; foreach (string key in designs) { dictionary.Add(key, new Value(enabled: true, 1f, 0f, 1f)); } return dictionary; } private static bool Number(string text, float min, float max, out float value) { if (float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out value) && !float.IsNaN(value) && !float.IsInfinity(value) && value >= min) { return value <= max; } return false; } internal static bool TryParse(string text, out Dictionary<string, Value> result) { result = null; if (string.IsNullOrEmpty(text) || text.Length > 2048) { return false; } string[] array = text.Split(new char[1] { ';' }); if (array.Length != Designs.Length + 1 || (array[0] != "AP1" && array[0] != "AP2" && array[0] != "AP3")) { return false; } bool flag = array[0] != "AP1"; bool flag2 = array[0] == "AP3"; Dictionary<string, Value> dictionary = new Dictionary<string, Value>(StringComparer.Ordinal); for (int i = 1; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { ':' }); if (array2.Length != 2 || !Supported(array2[0]) || dictionary.ContainsKey(array2[0])) { return false; } string[] array3 = array2[1].Split(new char[1] { ',' }); if (array3.Length != (flag2 ? 12 : (flag ? 11 : 4)) || !bool.TryParse(array3[0], out var result2) || !Number(array3[1], 0f, 3f, out var value) || !Number(array3[2], -180f, 180f, out var value2) || !Number(array3[3], 0f, 2f, out var value3)) { return false; } Value value4 = new Value(result2, value, value2, value3); if (flag) { if (!Number(array3[4], 0.25f, 3f, out value4.width) || !Number(array3[5], 0.25f, 2f, out value4.height) || !Number(array3[6], 0f, 3f, out value4.density) || !int.TryParse(array3[7], NumberStyles.Integer, CultureInfo.InvariantCulture, out value4.colors) || value4.colors < 0 || value4.colors > 3 || !ValidHex(array3[8]) || !ValidHex(array3[9]) || !ValidHex(array3[10])) { return false; } value4.color1 = array3[8]; value4.color2 = array3[9]; value4.color3 = array3[10]; } if (flag2 && !Number(array3[11], 0f, 2f, out value4.brightness)) { return false; } dictionary.Add(array2[0], value4); } result = dictionary; return true; } internal static string Serialize(Dictionary<string, Value> values) { StringBuilder stringBuilder = new StringBuilder("AP3"); string[] designs = Designs; foreach (string text in designs) { Value value = values[text]; stringBuilder.Append(';').Append(text).Append(':') .Append(value.enabled ? "true" : "false") .Append(',') .Append(value.intensity.ToString("R", CultureInfo.InvariantCulture)) .Append(',') .Append(value.hue.ToString("R", CultureInfo.InvariantCulture)) .Append(',') .Append(value.saturation.ToString("R", CultureInfo.InvariantCulture)) .Append(',') .Append(value.width.ToString("R", CultureInfo.InvariantCulture)) .Append(',') .Append(value.height.ToString("R", CultureInfo.InvariantCulture)) .Append(',') .Append(value.density.ToString("R", CultureInfo.InvariantCulture)) .Append(',') .Append(value.colors.ToString(CultureInfo.InvariantCulture)) .Append(',') .Append(value.color1) .Append(',') .Append(value.color2) .Append(',') .Append(value.color3) .Append(',') .Append(value.brightness.ToString("R", CultureInfo.InvariantCulture)); } return stringBuilder.ToString(); } } internal static class AuroraPalette { internal struct Gradient { internal int count; internal Color first; internal Color second; internal Color third; internal Color Evaluate(double position) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_008c: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) float num = (float)Math.Max(0.0, Math.Min(1.0, position)); Color val = first; if (count == 1) { return val; } Color val2 = second; if (count == 3) { if (num > 0.5f) { val = val2; val2 = third; num = (num - 0.5f) * 2f; } else { num *= 2f; } } return new Color(val.r + (val2.r - val.r) * num, val.g + (val2.g - val.g) * num, val.b + (val2.b - val.b) * num, 1f); } } private static Color Read(string hex) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Invalid comparison between Unknown and I4 //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) if (!AuroraMemory.ValidHex(hex)) { throw new FormatException("Invalid aurora gradient colour"); } uint num = uint.Parse(hex.Substring(1), NumberStyles.HexNumber, CultureInfo.InvariantCulture); Color result = default(Color); ((Color)(ref result))..ctor((float)((num >> 16) & 0xFF) / 255f, (float)((num >> 8) & 0xFF) / 255f, (float)(num & 0xFF) / 255f, 1f); if ((int)QualitySettings.activeColorSpace != 1) { return result; } return ((Color)(ref result)).linear; } internal static Gradient Create(int count, string first, string second, string third) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (count < 1 || count > 3) { throw new ArgumentOutOfRangeException("count"); } return new Gradient { count = count, first = Read(first), second = (Color)((count > 1) ? Read(second) : default(Color)), third = (Color)((count > 2) ? Read(third) : default(Color)) }; } } internal sealed class ButtonRepeat { private double next; private bool stopped; public string Key { get; private set; } public void Begin(string key, double now) { Key = key; next = now + 0.4; stopped = false; } public bool Tick(string key, double now, bool held, bool inside) { if (Key != key) { return false; } if (!held || !inside) { stopped = true; return false; } if (stopped || now < next) { return false; } next = now + 0.08; return true; } public void Reset() { Key = null; stopped = false; next = 0.0; } } internal sealed class CaptureStatistics { [DataContract] internal sealed class Summary { [DataMember] public int frames; [DataMember] public bool truncated; [DataMember] public double observedFps; [DataMember] public double frameMeanMs; [DataMember] public double frameP95Ms; [DataMember] public double frameP99Ms; [DataMember] public double lateMeanMs; [DataMember] public double cameraMeanMs; [DataMember] public double combinedCpuMeanMs; [DataMember] public double combinedCpuP95Ms; [DataMember] public double frameMaxMs; [DataMember] public double workerMeanMs; [DataMember] public double publishCpuMeanMs; [DataMember] public double publishedFrameMeanMs; [DataMember] public double reusedFrameMeanMs; [DataMember] public double uploadedBytesPerSecond; [DataMember] public int framesOverBudget60Fps; [DataMember] public int framesOver33Ms; [DataMember] public int framesOver50Ms; [DataMember] public int skyPublications; } [DataContract] internal sealed class Trace { [DataMember] public double[] frameMs; [DataMember] public double[] cpuMs; [DataMember] public double[] workerMs; [DataMember] public double[] publishMs; [DataMember] public bool[] skyPublished; } private const int Capacity = 32768; private readonly double[] frame = new double[32768]; private readonly double[] late = new double[32768]; private readonly double[] camera = new double[32768]; private readonly double[] combined = new double[32768]; private readonly double[] worker = new double[32768]; private readonly double[] publish = new double[32768]; private readonly bool[] published = new bool[32768]; private readonly long[] bytes = new long[32768]; private int count; private bool truncated; internal void Add(double frameMs, double lateMs, double cameraMs, double overlapMs) { AddDetailed(frameMs, lateMs, cameraMs, overlapMs, skyPublished: false, 0.0, 0.0, 0L); } internal void AddDetailed(double frameMs, double lateMs, double cameraMs, double overlapMs, bool skyPublished, double workerMs, double publishMs, long uploadedBytes) { if (count == 32768) { truncated = true; } else if (Finite(frameMs) && Finite(lateMs) && Finite(cameraMs) && Finite(overlapMs) && !(frameMs <= 0.0) && !(lateMs < 0.0) && !(cameraMs < 0.0) && !(overlapMs < 0.0)) { frame[count] = frameMs; late[count] = lateMs; camera[count] = cameraMs; combined[count] = Math.Max(0.0, lateMs + cameraMs - overlapMs); published[count] = skyPublished; worker[count] = ((Finite(workerMs) && workerMs >= 0.0) ? workerMs : 0.0); publish[count] = ((Finite(publishMs) && publishMs >= 0.0) ? publishMs : 0.0); bytes[count] = Math.Max(0L, uploadedBytes); count++; } } private static bool Finite(double n) { if (!double.IsNaN(n)) { return !double.IsInfinity(n); } return false; } internal Trace Snapshot() { Trace trace = new Trace { frameMs = new double[count], cpuMs = new double[count], workerMs = new double[count], publishMs = new double[count], skyPublished = new bool[count] }; Array.Copy(frame, trace.frameMs, count); Array.Copy(combined, trace.cpuMs, count); Array.Copy(worker, trace.workerMs, count); Array.Copy(publish, trace.publishMs, count); Array.Copy(published, trace.skyPublished, count); return trace; } private static double Mean(double[] values, int n) { double num = 0.0; for (int i = 0; i < n; i++) { num += values[i]; } if (n != 0) { return num / (double)n; } return 0.0; } private static double Percentile(double[] values, int n, double fraction) { if (n == 0) { return 0.0; } double[] array = new double[n]; Array.Copy(values, array, n); Array.Sort(array); return array[Math.Max(0, (int)Math.Ceiling(fraction * (double)n) - 1)]; } internal Summary Finish() { double num = Mean(frame, count); Summary summary = new Summary { frames = count, truncated = truncated, observedFps = ((num > 0.0) ? (1000.0 / num) : 0.0), frameMeanMs = num, frameP95Ms = Percentile(frame, count, 0.95), frameP99Ms = Percentile(frame, count, 0.99), lateMeanMs = Mean(late, count), cameraMeanMs = Mean(camera, count), combinedCpuMeanMs = Mean(combined, count), combinedCpuP95Ms = Percentile(combined, count, 0.95) }; double num2 = 0.0; double num3 = 0.0; double num4 = 0.0; double num5 = 0.0; double num6 = 0.0; for (int i = 0; i < count; i++) { summary.frameMaxMs = Math.Max(summary.frameMaxMs, frame[i]); if (frame[i] > 16.666666666666668) { summary.framesOverBudget60Fps++; } if (frame[i] > 33.0) { summary.framesOver33Ms++; } if (frame[i] > 50.0) { summary.framesOver50Ms++; } if (published[i]) { summary.skyPublications++; num2 += frame[i]; num4 += worker[i]; num5 += publish[i]; num6 += (double)bytes[i]; } else { num3 += frame[i]; } } if (summary.skyPublications > 0) { summary.publishedFrameMeanMs = num2 / (double)summary.skyPublications; summary.workerMeanMs = num4 / (double)summary.skyPublications; summary.publishCpuMeanMs = num5 / (double)summary.skyPublications; } if (count > summary.skyPublications) { summary.reusedFrameMeanMs = num3 / (double)(count - summary.skyPublications); } if (num > 0.0 && count > 0) { summary.uploadedBytesPerSecond = num6 / (num * (double)count / 1000.0); } return summary; } } internal static class CelestialAppearance { public static bool Identifiable(double altitude, bool disc) { if (!disc) { return EnvironmentMath.Extinction(altitude) > 0.0; } return SolarLunar.Horizon(altitude) > 0.0; } public static double MoonOpacity(double altitude) { return SolarLunar.Horizon(altitude); } public static double MoonRadiance(double fraction, double twilight, double brightness, double gain) { return brightness * gain * (0.16 + 0.84 * SkyMath.NightVisibility(fraction, twilight)); } } internal static class CelestialDetail { public static readonly Astronomy.Vector Andromeda = Equatorial(10.6847, 41.2687); public static readonly Astronomy.Vector Pleiades = Equatorial(56.75, 24.1167); public const double ShowerPeriod = 120.0; public const double ShowerDuration = 40.0; public static Astronomy.Vector Equatorial(double ra, double dec) { ra *= Math.PI / 180.0; dec *= Math.PI / 180.0; return new Astronomy.Vector(Math.Cos(dec) * Math.Cos(ra), Math.Cos(dec) * Math.Sin(ra), Math.Sin(dec)); } public static double GalacticLight(double longitude, double latitude) { double num = 0.06 + 0.015 * Math.Sin(3.0 * longitude + 0.4); double num2 = 0.67 + 0.18 * Math.Sin(5.0 * longitude + latitude * 23.0) + 0.09 * Math.Sin(17.0 * longitude + 0.8 - latitude * 39.0) + 0.035 * Math.Sin(43.0 * longitude + latitude * 117.0) + 0.025 * Math.Cos(71.0 * longitude - latitude * 193.0); double num3 = 0.5 + 0.5 * Math.Cos(longitude); double num4 = latitude - 0.018 * Math.Sin(4.0 * longitude); double num5 = 1.0 - 0.7 * Math.Exp((0.0 - num4) * num4 / 0.00015); double num6 = SolarLunar.Smooth((0.24 - Math.Abs(latitude)) / 0.06); return Math.Exp((0.0 - latitude) * latitude / (2.0 * num * num)) * num2 * (0.55 + 0.85 * num3 * num3) * num5 * num6; } public static double GalaxyProfile(double longitude, double latitude, double width, double contrast) { double num = GalacticLight(longitude, latitude / width); if (!(num <= 0.0)) { return Math.Pow(num, contrast) * Math.Pow(0.35, 1.0 - contrast); } return 0.0; } public static double GalaxyHaloExpansion(double width) { return Math.Min(1.5, 1.5697963267948967 / (0.24 * width)); } public static Astronomy.Vector GalacticSaturation(Astronomy.Vector color, double saturation) { if (saturation == 1.0) { return color; } double num = 0.2126 * color.x + 0.7152 * color.y + 0.0722 * color.z; double num2 = Math.Min(color.x, Math.Min(color.y, color.z)); double num3 = SkyMath.Clamp(saturation, 0.0, 3.0); if (num2 < num) { num3 = Math.Min(num3, num / (num - num2)); } return new Astronomy.Vector(num + (color.x - num) * num3, num + (color.y - num) * num3, num + (color.z - num) * num3); } public static Astronomy.Vector PlanetTint(int body, double emphasis) { double num = 1.0; double num2 = 1.0; double num3 = 1.0; switch (body) { case 0: num = 0.9; num2 = 0.88; num3 = 0.85; break; case 1: num = 1.0; num2 = 0.96; num3 = 0.86; break; case 3: num = 1.0; num2 = 0.55; num3 = 0.32; break; case 4: num = 1.0; num2 = 0.9; num3 = 0.76; break; case 5: num = 1.0; num2 = 0.86; num3 = 0.6; break; } emphasis = SkyMath.Clamp(emphasis, 0.0, 12.0); double num4 = Math.Min(2.0, emphasis); num = SkyMath.Clamp(1.0 + (num - 1.0) * num4, 0.0, 1.0); num2 = SkyMath.Clamp(1.0 + (num2 - 1.0) * num4, 0.0, 1.0); num3 = SkyMath.Clamp(1.0 + (num3 - 1.0) * num4, 0.0, 1.0); if (emphasis > 2.0) { double num5 = Math.Max(num, Math.Max(num2, num3)); double num6 = emphasis / 2.0; num = Math.Max(0.0, num5 - (num5 - num) * num6); num2 = Math.Max(0.0, num5 - (num5 - num2) * num6); num3 = Math.Max(0.0, num5 - (num5 - num3) * num6); } return new Astronomy.Vector(num, num2, num3); } public static bool Shower(double seconds, out double remaining) { if (double.IsNaN(seconds) || double.IsInfinity(seconds) || seconds < 0.0) { remaining = 0.0; return false; } double num = seconds % 120.0; bool flag = num < 40.0; remaining = (flag ? (40.0 - num) : (120.0 - num)); return flag; } public static bool ShowerMeteor(double seconds, double rate, int seed, out long slot, out double age) { double remaining; if (Astronomy.Meteor(seconds, rate, seed, out slot, out age)) { return Shower(seconds - age, out remaining); } return false; } public static double MeteorRate(double baseRate, double density) { if (!(baseRate <= 0.0)) { return SkyMath.Clamp(baseRate * density, 0.05, 12.0); } return 0.0; } } internal sealed class CelestialDiscs : IDisposable { private readonly Settings config; private readonly SolarSurface surface; private Material material; private Mesh quad; private Texture2D sun; private Texture2D halo; private Texture2D rim; private Texture2D chromosphere; private string coronaText; private Color coronaTint; private float chromosphereHeight = -1f; private readonly MaterialPropertyBlock properties = new MaterialPropertyBlock(); public bool Ready { get { if (Object.op_Implicit((Object)(object)material) && Object.op_Implicit((Object)(object)quad) && Object.op_Implicit((Object)(object)sun)) { return Object.op_Implicit((Object)(object)halo); } return false; } } public CelestialDiscs(Settings settings) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: 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) config = settings; surface = new SolarSurface(settings); Shader val = Shader.Find("Sprites/Default"); if (Object.op_Implicit((Object)(object)val) && val.isSupported) { material = new Material(val) { hideFlags = (HideFlags)61, name = "AstralSkies sky discs" }; quad = new Mesh { name = "AstralSkies disc quad", hideFlags = (HideFlags)61 }; quad.vertices = (Vector3[])(object)new Vector3[4] { new Vector3(-1f, -1f, 0f), new Vector3(1f, -1f, 0f), new Vector3(-1f, 1f, 0f), new Vector3(1f, 1f, 0f) }; quad.uv = (Vector2[])(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0f, 1f), new Vector2(1f, 1f) }; quad.colors = (Color[])(object)new Color[4] { Color.white, Color.white, Color.white, Color.white }; quad.triangles = new int[6] { 0, 2, 1, 2, 3, 1 }; sun = Radial(glow: false); halo = Radial(glow: true); rim = Rim(); } } public void UpdateSurface() { surface.Update(); } private static Texture2D Limb(float height) { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //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) Color[] array = (Color[])(object)new Color[262144]; for (int i = 0; i < 512; i++) { for (int j = 0; j < 512; j++) { double num = ((double)j + 0.5) / 512.0 * 2.0 - 1.0; double num2 = ((double)i + 0.5) / 512.0 * 2.0 - 1.0; double num3 = Lighting061Math.Chromosphere(Math.Sqrt(num * num + num2 * num2), height); array[i * 512 + j] = new Color(1f, 1f, 1f, (float)num3); } } Texture2D val = new Texture2D(512, 512, (TextureFormat)4, true, true) { name = "AstralSkies chromosphere limb", wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)2, hideFlags = (HideFlags)61 }; val.SetPixels(array); val.Apply(true, true); return val; } private static Texture2D Rim() { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) Color[] array = (Color[])(object)new Color[16384]; for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { double num = ((double)j + 0.5) / 128.0 * 2.0 - 1.0; double num2 = ((double)i + 0.5) / 128.0 * 2.0 - 1.0; array[i * 128 + j] = new Color(1f, 1f, 1f, (float)SolarSurfaceMath.Rim(Math.Sqrt(num * num + num2 * num2))); } } Texture2D val = new Texture2D(128, 128, (TextureFormat)4, true, true) { name = "AstralSkies subtle solar edge", wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)2, hideFlags = (HideFlags)61 }; val.SetPixels(array); val.Apply(true, true); return val; } private static Texture2D Radial(bool glow) { //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) Color[] array = (Color[])(object)new Color[65536]; for (int i = 0; i < 256; i++) { for (int j = 0; j < 256; j++) { Vector2 val = new Vector2(((float)j + 0.5f) / 256f * 2f - 1f, ((float)i + 0.5f) / 256f * 2f - 1f); float magnitude = ((Vector2)(ref val)).magnitude; float num = (glow ? Mathf.Max(0f, Mathf.Exp((0f - magnitude) * magnitude * 6f) - Mathf.Exp(-6f)) : Mathf.Clamp01((1f - magnitude) * 256f / 2f)); float num2 = (glow ? 1f : (0.8f + 0.2f * Mathf.Sqrt(Mathf.Max(0f, 1f - magnitude * magnitude)))); array[i * 256 + j] = new Color(num2, num2, num2, num); } } Texture2D val2 = new Texture2D(256, 256, (TextureFormat)4, false, true) { name = "AstralSkies analytic solar " + (glow ? "halo" : "disc"), wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; val2.SetPixels(array); val2.Apply(false, true); return val2; } public static Vector3 Direction(double fraction, double phase, float latitude, float yaw) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) Astronomy.Vector vector = SolarLunar.Direction(fraction, phase, latitude); double num = (double)yaw * (Math.PI / 180.0); double num2 = Math.Cos(num); double num3 = Math.Sin(num); return new Vector3((float)(num2 * vector.x + num3 * vector.z), (float)vector.y, (float)((0.0 - num3) * vector.x + num2 * vector.z)); } public static Vector3 Calibrated(Astronomy.Vector v, float yaw) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) double num = (double)yaw * (Math.PI / 180.0); double num2 = Math.Cos(num); double num3 = Math.Sin(num); return new Vector3((float)(num2 * v.x + num3 * v.z), (float)v.y, (float)((0.0 - num3) * v.x + num2 * v.z)); } public bool Draw(CommandBuffer cb, Camera camera, SkyTextures textures, SkyState state, float blood, double fraction, EclipseMath.Frame frame) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_04a5: Unknown result type (might be due to invalid IL or missing references) //IL_04ec: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_0520: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_052f: Unknown result type (might be due to invalid IL or missing references) //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_057f: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) //IL_05ab: Unknown result type (might be due to invalid IL or missing references) //IL_05b0: Unknown result type (might be due to invalid IL or missing references) //IL_05b2: Unknown result type (might be due to invalid IL or missing references) //IL_0616: Unknown result type (might be due to invalid IL or missing references) //IL_061b: Unknown result type (might be due to invalid IL or missing references) //IL_0629: Unknown result type (might be due to invalid IL or missing references) //IL_062a: Unknown result type (might be due to invalid IL or missing references) //IL_0634: Unknown result type (might be due to invalid IL or missing references) //IL_063e: 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_0695: Unknown result type (might be due to invalid IL or missing references) if (!Ready || !Object.op_Implicit((Object)(object)textures.Moon) || !Object.op_Implicit((Object)(object)textures.MoonSilhouette)) { return false; } double phase = state.Phase; SolarLunar.BloodPhase(phase, blood); Vector3 val = Calibrated(frame.Sun, config.NorthYaw.Value); Vector3 val2 = Calibrated(frame.Moon, config.NorthYaw.Value); float num = 1f - Mathf.Clamp01(val.y * 4f); Color val3 = Color.Lerp(new Color(1f, 0.98f, 0.9f), new Color(1f, 0.53f, 0.24f), num * config.TwilightWarmth.Value); float num2 = (float)SolarLunar.Horizon(val.y); Texture texture = (Texture)(object)((config.SunStyle.Value != "Current" && config.SunDetail.Value > 0f && Object.op_Implicit((Object)(object)surface.Texture)) ? surface.Texture : sun); float value = config.SunBrightness.Value; DrawDisc(cb, camera, val, Vector3.up, texture, (float)frame.SunRadius, new Color(val3.r * value, val3.g * value, val3.b * value, num2)); if (config.SunStyle.Value != "Current" && config.SunRim.Value > 0f) { DrawDisc(cb, camera, val, Vector3.up, (Texture)(object)rim, (float)frame.SunRadius * 1.18f, new Color(1f, 0.35f, 0.12f, num2 * config.SunGlare.Value * config.SunRim.Value * 0.12f * (float)EclipseMath.SolarGlare(frame.SolarCoverage))); } float radius = Mathf.Min(0.5f, 0.035f * (float)(frame.SunRadius / 0.00465) * (1f + 0.04f * (config.SunHalo.Value - 2f))); DrawDisc(cb, camera, val, Vector3.up, (Texture)(object)halo, radius, new Color(val3.r, val3.g, val3.b, num2 * config.SunGlare.Value * (float)SolarLunar.HaloOpacity(config.SunHalo.Value) * (float)EclipseMath.SolarGlare(frame.SolarCoverage))); float num3 = (float)EclipseMath.Corona(frame.SolarCoverage); if (coronaText != config.CoronaColor.Value) { coronaText = config.CoronaColor.Value; coronaTint = VisualColor.Parse(coronaText, Color.white); } if (num3 > 0f) { Lighting061Math.Corona(config.CoronaStrength.Value, num3 * num2, out var alpha, out var rgb); Color color = coronaTint * (float)rgb; color.a = (float)alpha; DrawDisc(cb, camera, val, Vector3.up, (Texture)(object)halo, (float)frame.SunRadius * 3f, color); } float num4 = (float)SolarLunar.Smooth((frame.SolarCoverage - 0.9) / 0.1) * config.Chromosphere.Value; if (num4 > 0f) { if (chromosphereHeight != config.ChromosphereExtent.Value || !Object.op_Implicit((Object)(object)chromosphere)) { chromosphereHeight = config.ChromosphereExtent.Value; if (Object.op_Implicit((Object)(object)chromosphere)) { Object.Destroy((Object)(object)chromosphere); } chromosphere = Limb(chromosphereHeight); } DrawDisc(cb, camera, val, Vector3.up, (Texture)(object)chromosphere, (float)frame.SunRadius * (1f + chromosphereHeight), new Color(1f, 0.06f, 0.025f, num2 * num4 * 0.8f)); } if (!EclipseMath.DrawLunarSurface(frame.SolarCoverage)) { DrawDisc(cb, camera, val2, Vector3.up, (Texture)(object)textures.MoonSilhouette, (float)frame.MoonRadius, Color.black); return true; } Vector3 val4 = val - val2 * Vector3.Dot(val, val2); Vector3 val5; Vector3 val6; if (!(((Vector3)(ref val4)).sqrMagnitude > 0.0001f)) { val5 = Vector3.Cross(Vector3.up, val2); val6 = ((Vector3)(ref val5)).normalized; } else { val6 = ((Vector3)(ref val4)).normalized * (float)((Math.Sin(phase * Math.PI * 2.0) >= 0.0) ? 1 : (-1)); } val5 = Vector3.Cross(val6, val2); Vector3 normalized = ((Vector3)(ref val5)).normalized; float num5 = (float)frame.MoonRadius; float num6 = (float)CelestialAppearance.MoonOpacity(val2.y); float num7 = Mathf.Lerp(0.16f, 1f, (float)SkyMath.NightVisibility(fraction, config.EffectiveTwilight)); if (!state.night) { num6 *= num7; } Color val7 = Color.Lerp(Color.white, new Color(1f, 0.28f, 0.09f), blood * config.RedStrength.Value); val7 *= (state.night ? ((float)CelestialAppearance.MoonRadiance(fraction, config.EffectiveTwilight, config.MoonBrightness.Value, config.MoonGain.Value)) : (config.MoonBrightness.Value * config.MoonGain.Value)); val7.a = num6; DrawDisc(cb, camera, val2, normalized, (Texture)(object)textures.Moon, num5, val7); DrawDisc(cb, camera, val2, normalized, (Texture)(object)halo, num5 * 3f, new Color(1f, 0.22f, 0.07f, num6 * blood * 0.12f * Mathf.Min(1f, config.MoonBrightness.Value * config.MoonGain.Value))); return true; } private void DrawDisc(CommandBuffer cb, Camera camera, Vector3 direction, Vector3 up, Texture texture, float radius, Color color) { //IL_0000: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (!(color.a <= 0f)) { float num = camera.farClipPlane * 0.85f; if (UnityRotation.Billboard(direction, up, num, num * Mathf.Tan(radius), out var result)) { properties.Clear(); properties.SetTexture("_MainTex", texture); properties.SetColor("_Color", color); cb.DrawMesh(quad, result, material, 0, 0, properties); } } } public void Dispose() { surface.Dispose(); if (Object.op_Implicit((Object)(object)material)) { Object.Destroy((Object)(object)material); } if (Object.op_Implicit((Object)(object)quad)) { Object.Destroy((Object)(object)quad); } if (Object.op_Implicit((Object)(object)sun)) { Object.Destroy((Object)(object)sun); } if (Object.op_Implicit((Object)(object)halo)) { Object.Destroy((Object)(object)halo); } if (Object.op_Implicit((Object)(object)rim)) { Object.Destroy((Object)(object)rim); } if (Object.op_Implicit((Object)(object)chromosphere)) { Object.Destroy((Object)(object)chromosphere); } } } internal static class ConfigurationLayout { internal const string Marker = "19 - Compatibility/ConfigLayoutVersion"; private static readonly Dictionary<string, string> aliases; static ConfigurationLayout() { aliases = new Dictionary<string, string>(StringComparer.Ordinal); Group("1 - Client", "01 - General", "Enabled"); Group("2 - Stars", "03 - Stars", "Enabled", "Brightness", "MoonWashout", "Scintillation"); Group("2 - Stars", "02 - Performance", "GpuRendering"); Group("2 - Stars", "09 - Observation", "ConstellationGuide"); Group("2 - Stars", "11 - Astronomy", "NorthCalibrationDegrees"); Group("2 - Stars", "19 - Compatibility", "CubemapResolution", "SkyUpdateHz"); Group("3 - Moon", "05 - Sun and Moon", "Enabled", "Brightness"); Add("3 - Moon/SizeMultiplier", "19 - Compatibility/LegacyMoonSizeMultiplier"); Group("4 - Meteors", "08 - Meteors", "Enabled", "PeriodicShowers"); Group("5 - Blood moon", "13 - Blood Moon", "ShowBloodMoon", "Darkening", "RedStrength", "ShowNotice", "NordicNotice"); Group("6 - Server", "18 - Server", "BloodMoonSizeMultiplier", "SkyLatitude", "BloodMoonEnabled", "BloodMoonStormSea", "LunarCycleDays", "PhaseOffsetDays", "MeteorsPerMinute", "TransitionSeconds", "SkySeed", "ExcludedEventNames", "EclipseOrbitCycles"); Group("7 - Planets", "04 - Planets", "Enabled", "Brightness"); Group("8 - Panorama", "10 - Horizon", "HideYggdrasil", "ShowHighClouds", "ShowHorizonClouds", "CloudLayersVersion"); Group("8 - Panorama", "19 - Compatibility", "HideClouds"); Group("9 - Interface", "15 - Interface", "Theme", "Scale", "WindowX", "WindowY"); Group("10 - Visual detail", "03 - Stars", "SkyGain", "StarSize"); Group("10 - Visual detail", "04 - Planets", "PlanetGain", "PlanetSize"); Group("10 - Visual detail", "04 - Planets", "PlanetColorStrength"); Group("10 - Visual detail", "07 - Galaxy", "MilkyWayPalette"); Group("10 - Visual detail", "09 - Observation", "GuideGain"); Group("10 - Visual detail", "07 - Galaxy", "GalacticGlow", "DeepSky", "DeepSkyGain"); Group("10 - Visual detail", "08 - Meteors", "MeteorDensity", "MeteorGain"); Group("10 - Visual detail", "06 - Day Sky", "TwilightLength"); Group("10 - Visual detail", "05 - Sun and Moon", "MoonGain"); Add("10 - Visual detail/MoonScale", "19 - Compatibility/LegacyMoonScale"); Group("2 - Stars", "07 - Galaxy", "MilkyWayStrength"); Group("11 - Experience", "02 - Performance", "Quality"); Group("11 - Experience", "14 - Favorites", "VisualPreset"); Group("11 - Experience", "09 - Observation", "IdentifyAtReticle", "GuideNames", "GuideHighlight", "SummerTriangle", "GuideIdleOpacity", "GuideAnchorsOnly"); Group("11 - Experience", "05 - Sun and Moon", "CoherentSunMoon"); Group("11 - Experience", "06 - Day Sky", "DaySky", "DayRichness", "TwilightWarmth"); Group("11 - Experience", "13 - Blood Moon", "CopperAtmosphere", "CopperStrength"); Group("11 - Experience", "04 - Planets", "PlanetColorStrength"); Group("12 - Discs", "05 - Sun and Moon", "SunDiameter", "MoonDiameter", "LinkMoonToSun", "MoonSunRatio", "SunHalo"); Group("12 - Discs", "13 - Blood Moon", "BloodMoonDiameter"); Group("13 - Day sky", "06 - Day Sky", "Brightness", "Saturation"); Group("15 - Eclipses", "12 - Eclipses", "Enabled", "ShowNotice", "SharedDiameter"); Group("16 - Galaxy", "07 - Galaxy", "Width", "Contrast", "Saturation", "Radiance", "BackgroundStars", "Particles", "ParticleStrength"); Group("18 - Diagnostics", "16 - Diagnostics", "Environment"); } private static void Add(string old, string current) { aliases.Add(old, current); } private static void Group(string old, string current, params string[] keys) { foreach (string text in keys) { Add(old + "/" + text, current + "/" + text); } } internal static string Canonical(string key) { if (!aliases.TryGetValue(key, out var value)) { return key; } return value; } internal static ConfigDefinition Definition(string section, string key) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown string text = Canonical(section + "/" + key); int num = text.IndexOf('/'); return new ConfigDefinition(text.Substring(0, num), text.Substring(num + 1)); } internal static void AddLegacyViews(Dictionary<string, string> values, HashSet<string> keys) { foreach (KeyValuePair<string, string> alias in aliases) { if (values.TryGetValue(alias.Value, out var value) && !values.ContainsKey(alias.Key)) { values.Add(alias.Key, value); keys.Add(alias.Key); } } } internal static string Migrate(ConfigFile file) { string configFilePath = file.ConfigFilePath; if (!File.Exists(configFilePath)) { return "New configuration"; } Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.Ordinal); HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal); string text = ""; bool flag = false; int num = 0; string[] array = File.ReadAllLines(configFilePath); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); if (text2.Length == 0 || text2.StartsWith("#") || text2.StartsWith(";")) { continue; } if (text2.StartsWith("[") && text2.EndsWith("]")) { text = text2.Substring(1, text2.Length - 2); continue; } int num2 = text2.IndexOf('='); if (num2 > 0) { string text3 = text + "/" + text2.Substring(0, num2).Trim(); string text4 = Canonical(text3); string text5 = text2.Substring(num2 + 1).Trim(); flag |= text4 != text3; if (dictionary.TryGetValue(text4, out var value) && value != text5) { num++; } if (text3 == text4) { dictionary[text4] = text5; hashSet.Add(text4); } else if (!hashSet.Contains(text4)) { dictionary[text4] = text5; } } } string value2; bool flag2 = dictionary.TryGetValue("19 - Compatibility/ConfigLayoutVersion", out value2) && value2 == "1"; if (value2 != null && value2 != "1") { throw new InvalidDataException("Unsupported configuration layout " + value2 + "; existing file retained."); } if (!flag && flag2) { return "Configuration layout 1"; } if (dictionary.Count == 0) { return "New configuration"; } string text6 = configFilePath + ".pre-0.6.0.bak"; if (File.Exists(text6)) { text6 = configFilePath + ".pre-0.6.0." + Guid.NewGuid().ToString("N") + ".bak"; } File.Copy(configFilePath, text6); dictionary["19 - Compatibility/ConfigLayoutVersion"] = "1"; StringBuilder stringBuilder = new StringBuilder("# AstralSkies functional configuration; original preserved before migration.\n"); foreach (IGrouping<string, KeyValuePair<string, string>> item in from p in dictionary.OrderBy<KeyValuePair<string, string>, string>((KeyValuePair<string, string> p) => p.Key, StringComparer.Ordinal) group p by p.Key.Substring(0, p.Key.IndexOf('/'))) { stringBuilder.Append('\n').Append('[').Append(item.Key) .Append("]\n"); foreach (KeyValuePair<string, string> item2 in item) { stringBuilder.Append(item2.Key.Substring(item2.Key.IndexOf('/') + 1)).Append(" = ").Append(item2.Value) .Append('\n'); } } string text7 = configFilePath + ".migration-" + Guid.NewGuid().ToString("N") + ".tmp"; try { File.WriteAllText(text7, stringBuilder.ToString(), new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); File.Replace(text7, configFilePath, null); file.Reload(); } finally { if (File.Exists(text7)) { File.Delete(text7); } } return "Migrated legacy configuration; conflicting entries: " + num + " (canonical keys take priority); original backup: " + Path.GetFileName(text6); } } internal sealed class Settings { public readonly ConfigEntry<bool> Enabled; public readonly ConfigEntry<bool> Stars; public readonly ConfigEntry<bool> Moon; public readonly ConfigEntry<bool> Meteors; public readonly ConfigEntry<bool> Blood; public readonly ConfigEntry<bool> Notice; public readonly ConfigEntry<bool> Planets; public readonly ConfigEntry<bool> Gpu; public readonly ConfigEntry<bool> MeteorShowers; public readonly ConfigEntry<bool> NordicNotice; public readonly ConfigEntry<bool> HideTree; public readonly ConfigEntry<bool> HideClouds; public readonly ConfigEntry<bool> ConstellationLines; public readonly ConfigEntry<int> Resolution; public readonly ConfigEntry<int> Seed; public readonly ConfigEntry<int> SkyFps; public readonly ConfigEntry<float> StarBrightness; public readonly ConfigEntry<float> MilkyWay; public readonly ConfigEntry<float> MoonBrightness; public readonly ConfigEntry<float> MoonSize; public readonly ConfigEntry<float> Cycle; public readonly ConfigEntry<float> Offset; public readonly ConfigEntry<float> Rate; public readonly ConfigEntry<float> Fade; public readonly ConfigEntry<float> RedStrength; public readonly ConfigEntry<float> BloodSize; public readonly ConfigEntry<float> Latitude; public readonly ConfigEntry<float> PlanetBrightness; public readonly ConfigEntry<float> NorthYaw; public readonly ConfigEntry<float> MoonWashout; public readonly ConfigEntry<float> Scintillation; public readonly ConfigEntry<string> Exclusions; public readonly ConfigEntry<string> Theme; public readonly ConfigEntry<float> UiScale; public readonly ConfigEntry<float> WindowX; public readonly ConfigEntry<float> WindowY; public readonly ConfigEntry<float> SkyGain; public readonly ConfigEntry<float> StarSize; public readonly ConfigEntry<float> PlanetGain; public readonly ConfigEntry<float> PlanetSize; public readonly ConfigEntry<float> GuideGain; public readonly ConfigEntry<float> GalacticGlow; public readonly ConfigEntry<float> DeepSkyGain; public readonly ConfigEntry<float> MeteorDensity; public readonly ConfigEntry<float> MeteorGain; public readonly ConfigEntry<float> TwilightLength; public readonly ConfigEntry<float> MoonGain; public readonly ConfigEntry<float> MoonScale; public readonly ConfigEntry<bool> DeepSky; private readonly ConfigFile file; public readonly ConfigEntry<bool> GuideHighlight; public readonly ConfigEntry<bool> SummerTriangle; public readonly ConfigEntry<float> GuideIdleOpacity; public readonly ConfigEntry<bool> Identify; public readonly ConfigEntry<bool> GuideNames; public readonly ConfigEntry<bool> GuideAnchorsOnly; public readonly ConfigEntry<bool> CoherentCycle; public readonly ConfigEntry<bool> DaySky; public readonly ConfigEntry<bool> CopperAtmosphere; public readonly ConfigEntry<bool> LocalBloodEnabled; public readonly ConfigEntry<bool> StormSea; public readonly ConfigEntry<string> Quality; public readonly ConfigEntry<string> VisualPreset; public readonly ConfigEntry<string> MilkyWayPalette; public readonly ConfigEntry<float> PlanetColorStrength; public readonly ConfigEntry<float> LocalBloodSize; public readonly ConfigEntry<float> CopperStrength; public readonly ConfigEntry<float> BloodDarkening; public readonly ConfigEntry<float> SunSize; public readonly ConfigEntry<float> SunHalo; public readonly ConfigEntry<float> DayRichness; public readonly ConfigEntry<float> TwilightWarmth; public readonly ConfigEntry<float> MoonDiameter; public readonly ConfigEntry<float> MoonSunRatio; public readonly ConfigEntry<float> DayBrightness; public readonly ConfigEntry<float> DaySaturation; public readonly ConfigEntry<bool> LinkMoonToSun; public readonly ConfigEntry<bool> Eclipses; public readonly ConfigEntry<bool> EclipseNotice; public readonly ConfigEntry<bool> GalaxyParticles; public readonly ConfigEntry<float> EclipseScale; public readonly ConfigEntry<float> EclipseOrbitCycles; public readonly ConfigEntry<float> GalaxyWidth; public readonly ConfigEntry<float> GalaxyContrast; public readonly ConfigEntry<float> GalaxySaturation; public readonly ConfigEntry<float> GalaxyRadiance; public readonly ConfigEntry<float> GalaxyDensity; public readonly ConfigEntry<float> GalaxyParticleStrength; public ConfigEntry<bool> ExpertQuality; public ConfigEntry<int> ExpertSegments; public ConfigEntry<int> ExpertRefresh; public ConfigEntry<int> ExpertMoon; public ConfigEntry<int> ExpertCube; public ConfigEntry<int> ExpertGalaxyColumns; public ConfigEntry<int> ExpertGalaxyRows; public ConfigEntry<int> ConfigLayoutVersion; public ConfigEntry<string> GuideActivation; public ConfigEntry<string> SunStyle; public ConfigEntry<float> IdentifyDwell; public ConfigEntry<float> GuideDwell; public ConfigEntry<float> AimTolerance; public ConfigEntry<float> GuideHold; public ConfigEntry<float> GuideFade; public ConfigEntry<float> GuideAnchorSize; public ConfigEntry<float> StarHalo; public ConfigEntry<float> PlanetHalo; public ConfigEntry<float> SunDetail; public ConfigEntry<float> SunRim; public ConfigEntry<bool> ObservationAngles; public ConfigEntry<string> PositionModel; public ConfigEntry<bool> AllowPosition; public ConfigEntry<bool> PositionTwilight; public ConfigEntry<float> PositionNorth; public ConfigEntry<float> PositionSouth; public ConfigEntry<float> PositionSmoothing; public ConfigEntry<float> SunBrightness; public ConfigEntry<float> SunGlare; public ConfigEntry<bool> ConfineCursor; public ConfigEntry<int> DetailMoon; public ConfigEntry<int> DetailStars; public ConfigEntry<int> DetailPlanets; public ConfigEntry<int> DetailGalaxy; public ConfigEntry<int> DetailDeepSky; public ConfigEntry<float>[] PlanetSaturation; public ConfigEntry<float>[] PlanetLight; public ConfigEntry<string> MoonOwner; public ConfigEntry<string> LunarShaftColor; public ConfigEntry<string> CoronaColor; public ConfigEntry<string> SolarShaftMode; public ConfigEntry<string> SolarShaftColor; public ConfigEntry<string> LunarHaloColor; public ConfigEntry<string> MoonStyle; public ConfigEntry<bool> DayStars; public ConfigEntry<bool> DayBigDipper; public ConfigEntry<bool> DayPlanets; public ConfigEntry<bool> CustomNameColor; public ConfigEntry<string> NameColor; public ConfigEntry<string> CoherentCycleVersion; public ConfigEntry<float> MoonDetail; public ConfigEntry<float> ChromosphereExtent; public ConfigEntry<float> DayStarBrightness; public ConfigEntry<float> DayPlanetBrightness; public ConfigEntry<bool> DayParticles; public ConfigEntry<bool> LunarShafts; public ConfigEntry<bool> LunarGlow; public ConfigEntry<bool> LunarRing; public ConfigEntry<float> SolarShaftIntensity; public ConfigEntry<float> SolarShaftLength; public ConfigEntry<float> LunarGlowStrength; public ConfigEntry<float> LunarGlowExtent; public ConfigEntry<float> LunarRingStrength; public ConfigEntry<float> LunarRingRadius; public ConfigEntry<float> LunarRingWidth; public ConfigEntry<float> DayParticleOpacity; public ConfigEntry<float> DayParticleDensity; public ConfigEntry<float> DayParticleBrightness; public ConfigEntry<float> StellarSpeed; public ConfigEntry<float> LunarShaftIntensity; public ConfigEntry<float> LunarShaftLength; public ConfigEntry<float> CoronaStrength; public ConfigEntry<float> Chromosphere; public ConfigEntry<float> EclipseSkyFloor; public ConfigEntry<bool> ShowHighClouds; public ConfigEntry<bool> ShowHorizonClouds; public ConfigEntry<bool> ShowLowClouds; public ConfigEntry<bool> AuroraEnabled; public ConfigEntry<string> AuroraPreset; public ConfigEntry<string> AuroraProfiles; public ConfigEntry<string> AuroraColor1; public ConfigEntry<string> AuroraColor2; public ConfigEntry<string> AuroraColor3; public ConfigEntry<float> AuroraIntensity; public ConfigEntry<float> AuroraHue; public ConfigEntry<float> AuroraSaturation; public ConfigEntry<float> AuroraWidth; public ConfigEntry<float> AuroraHeight; public ConfigEntry<float> AuroraDensity; public ConfigEntry<float> AuroraBrightness; public ConfigEntry<int> AuroraColorCount; public ConfigEntry<int> CloudLayersVersion; public ConfigEntry<bool> EnvironmentDiagnostics; private HashSet<string> originalKeys; private readonly Dictionary<string, string> originalValues = new Dictionary<string, string>(); private bool restoringAurora; private string activeAuroraProfile; private Dictionary<string, AuroraMemory.Value> auroraProfiles; private readonly ConfigEntry<string>[] favorites = new ConfigEntry<string>[2]; private readonly ConfigEntry<string>[] favoriteNames = new ConfigEntry<string>[2]; public ConfigEntry<string> HorizonMode; public ConfigEntry<float> HorizonFadeDegrees; public ConfigEntry<float> HorizonMaxDip; public ConfigEntry<float> HorizonResponseHeight; public ConfigEntry<float> NamedStarSize; internal static readonly string[] ResetModules = new string[11] { "03 - Stars", "04 - Planets", "05 - Sun and Moon", "06 - Day Sky", "07 - Galaxy", "08 - Meteors", "09 - Observation", "10 - Horizon", "11 - Astronomy", "12 - Eclipses", "13 - Blood Moon" }; public string MigrationStatus { get; private set; } = ""; public float EffectiveMoonDiameter => (float)SolarLunar.MoonDiameter(SunSize.Value, MoonDiameter.Value, MoonSunRatio.Value, LinkMoonToSun.Value); public int QualityRevision { get; private set; } public string ActiveQuality { get; set; } = ""; public bool QualityLoading { get; set; } public int EffectiveResolution => Math.Min(RequestedGraphics.Cube, SystemInfo.maxCubemapSize); public int EffectiveHz => RequestedGraphics.Refresh; public int EffectiveMoon => RequestedGraphics.Moon; public string ConfigDirectory => Path.GetDirectoryName(file.ConfigFilePath); public long ConfigurationRevision { get; private set; } public float PositionTwilightFactor { get; set; } = 1f; public bool PositionAvailable { get; set; } public string SolarSurfaceStatus { get; set; } = ""; public float EffectiveTwilight => TwilightLength.Value * PositionTwilightFactor; public bool NativeSeated { get; set; } public bool GuideEnabled { get { if (ConstellationLines.Value) { if (!(GuideActivation.Value != "Seated")) { return NativeSeated; } return true; } return false; } } public bool SeatedObservation { get { if (GuideEnabled && GuideActivation.Value == "Seated") { return NativeSeated; } return false; } } public bool GuideConnections { get { if (!SeatedObservation) { return !GuideAnchorsOnly.Value; } return true; } } public float EffectiveGuideIdle { get { if (!SeatedObservation) { if (!(GuideActivation.Value == "Aimed")) { return GuideIdleOpacity.Value; } return 0f; } return 1f; } } public bool EffectiveGuideHighlight { get { if (!SeatedObservation) { if (!GuideHighlight.Value) { return GuideActivation.Value == "Aimed"; } return true; } return false; } } internal GraphicsSelection AppliedGraphics { get; private set; } internal GraphicsSelection RequestedGraphics { get { GraphicsSelection result = GraphicsSelection.Profile(Quality.Value); if (ExpertQuality != null && ExpertQuality.Value) { result.Expert = true; result.Segments = ExpertSegments.Value; result.Refresh = ExpertRefresh.Value; result.Moon = ExpertMoon.Value; result.Cube = ExpertCube.Value; result.Columns = ExpertGalaxyColumns.Value; result.Rows = ExpertGalaxyRows.Value; } result.StarSegments = ((DetailStars != null && DetailStars.Value > 0) ? DetailStars.Value : result.Segments); result.PlanetSegments = ((DetailPlanets != null && DetailPlanets.Value > 0) ? DetailPlanets.Value : result.Segments); result.DeepSegments = ((DetailDeepSky != null && DetailDeepSky.Value > 0) ? DetailDeepSky.Value : 48); if (DetailMoon != null && DetailMoon.Value > 0) { result.Moon = DetailMoon.Value; } if (DetailGalaxy != null && DetailGalaxy.Value > 0) { int value = DetailGalaxy.Value; result.Columns = value switch { 2 => 640, 1 => 320, _ => 960, }; result.Rows = value switch { 2 => 48, 1 => 24, _ => 64, }; } return result; } } public bool NightVisibleCycle { get { if (CoherentCycleVersion != null) { return CoherentCycleVersion.Value == "V2"; } return false; } } public float ObservedMoonAltitude { get; set; } = float.NaN; public bool ExternalMoon { get { if (MoonOwner != null) { return MoonOwner.Value == "External"; } return false; } } public string ExternalMoonStatus { get; set; } = "as_061_external_absent"; public bool ExternalMoonDetected { get; set; } public bool LunarShaftAvailable { get; set; } public bool DayParticlesSupported { get; set; } public double StellarAngle { get; set; } = double.NaN; public float HorizonShift { get; set; } public bool HorizonNativeSupported { get; set; } private static ConfigEntry<T> Bind<T>(ConfigFile c, string section, string key, T value, string description) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown return Bind(c, section, key, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>())); } private static ConfigEntry<T> Bind<T>(ConfigFile c, string section, string k