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 StarNavCompass v1.0.0
StarNav.dll
Decompiled a day 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.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("StarNav")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("StarNav")] [assembly: AssemblyTitle("StarNav")] [assembly: AssemblyVersion("1.0.0.0")] namespace StarNav; public static class Astronomy { public const float Deg2Rad = (float)Math.PI / 180f; public static Vector3 ToHorizon(float raDeg, float decDeg, float latitudeDeg, float lstDeg) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) float num = (lstDeg - raDeg) * ((float)Math.PI / 180f); float num2 = decDeg * ((float)Math.PI / 180f); float num3 = latitudeDeg * ((float)Math.PI / 180f); float num4 = Mathf.Sin(num2); float num5 = Mathf.Cos(num2); float num6 = Mathf.Sin(num3); float num7 = Mathf.Cos(num3); float num8 = Mathf.Cos(num); float num9 = Mathf.Sin(num); float num10 = num4 * num6 + num5 * num7 * num8; float num11 = num4 * num7 - num5 * num6 * num8; return new Vector3((0f - num5) * num9, num10, num11); } public static Vector3 PoleDirection(float latitudeDeg) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) float num = latitudeDeg * ((float)Math.PI / 180f); return new Vector3(0f, Mathf.Sin(num), Mathf.Cos(num)); } public static float HeadingDeg(Vector3 dir) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Atan2(dir.x, dir.z) * 57.29578f; if (num < 0f) { num += 360f; } return num; } public static float AltitudeDeg(Vector3 dir) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return Mathf.Asin(Mathf.Clamp(((Vector3)(ref dir)).normalized.y, -1f, 1f)) * 57.29578f; } public static float SunRightAscensionDeg(float dayOfYear) { float num = (dayOfYear - 80f) / 365.25f * 360f * ((float)Math.PI / 180f); float num2 = Mathf.Atan2(Mathf.Cos(0.40910518f) * Mathf.Sin(num), Mathf.Cos(num)) * 57.29578f; if (num2 < 0f) { num2 += 360f; } return num2; } public static Color BVToColor(float bv) { //IL_016d: Unknown result type (might be due to invalid IL or missing references) bv = Mathf.Clamp(bv, -0.4f, 2f); float num; float num2; float num3; if (bv < 0f) { num = 0.62f + 0.35f * (bv + 0.4f) / 0.4f; num2 = 0.72f + 0.2f * (bv + 0.4f) / 0.4f; num3 = 1f; } else if (bv < 0.4f) { num = 0.97f + 0.03f * bv / 0.4f; num2 = 0.92f + 0.06f * bv / 0.4f; num3 = 1f; } else if (bv < 0.8f) { num = 1f; num2 = 0.98f - 0.08f * (bv - 0.4f) / 0.4f; num3 = 1f - 0.25f * (bv - 0.4f) / 0.4f; } else if (bv < 1.4f) { num = 1f; num2 = 0.9f - 0.22f * (bv - 0.8f) / 0.6f; num3 = 0.75f - 0.35f * (bv - 0.8f) / 0.6f; } else { num = 1f; num2 = 0.68f - 0.18f * (bv - 1.4f) / 0.6f; num3 = 0.4f - 0.2f * (bv - 1.4f) / 0.6f; } return new Color(Mathf.Clamp01(num), Mathf.Clamp01(num2), Mathf.Clamp01(num3), 1f); } public static float MagnitudeToFlux(float mag) { return Mathf.Pow(10f, -0.4f * mag); } public static float Extinction(float altDeg) { if (altDeg <= 0f) { return 0f; } float num = Mathf.Max(Mathf.Cos((90f - altDeg) * ((float)Math.PI / 180f)), 0.03f); float num2 = 1f / (num + 0.025f * Mathf.Exp(-11f * num)); float num3 = 0.25f * (num2 - 1f); return Mathf.Pow(10f, -0.4f * num3); } } public class CompassHud : MonoBehaviour { private Texture2D _white; private GUIStyle _cardinal; private GUIStyle _minor; private GUIStyle _degrees; private GUIStyle _starName; private GUIStyle _starInfo; private float _nextStarCheck; private string _starLabel = string.Empty; private string _starInfoText = string.Empty; private float _starLabelAlpha; private Texture2D _faceTex; private Texture2D _needleTex; private bool _raised; private float _raisedAt; private float _raiseAlpha; private float _needleAngle; private float _needleVel; private bool _needleInit; private static readonly string[] s_cardinals = new string[8] { "N", "NE", "E", "SE", "S", "SW", "W", "NW" }; private float _nextEquipCheck; public static CompassHud Instance { get; private set; } public bool IsRaised => _raised; public static void Create() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Instance != (Object)null)) { new GameObject("StarNav_CompassHud").AddComponent<CompassHud>(); } } private void Awake() { Instance = this; } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void EnsureStyles() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0066: Expected O, but got Unknown //IL_0071: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_0144: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_white != (Object)null)) { _white = new Texture2D(1, 1, (TextureFormat)4, false); _white.SetPixel(0, 0, Color.white); _white.Apply(); _cardinal = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontSize = 18, fontStyle = (FontStyle)1 }; _minor = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontSize = 12 }; _degrees = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontSize = 15, fontStyle = (FontStyle)1 }; _starName = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontSize = 17, fontStyle = (FontStyle)1 }; _starInfo = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontSize = 12 }; GUIStyle[] array = (GUIStyle[])(object)new GUIStyle[5] { _cardinal, _minor, _degrees, _starName, _starInfo }; for (int i = 0; i < array.Length; i++) { array[i].normal.textColor = Color.white; } } } private static bool HudAllowed() { if (!StarNavPlugin.CompassEnabled.Value) { return false; } if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)Hud.instance == (Object)null) { return false; } if (Hud.IsUserHidden()) { return false; } if (Minimap.IsOpen()) { return false; } if (Menu.IsVisible() || InventoryGui.IsVisible()) { return false; } return true; } private static bool ShouldShowStrip() { if (HudAllowed() && StarNavPlugin.CompassStrip.Value) { return CompassItem.IsEquipped(); } return false; } private bool ShouldShowRaised() { if (HudAllowed()) { return _raised; } return false; } private static bool ShouldShow() { if (!ShouldShowStrip()) { if ((Object)(object)Instance != (Object)null) { return Instance.ShouldShowRaised(); } return false; } return true; } public void ToggleRaised() { if (_raised && Time.time - _raisedAt > 0.3f) { _raised = false; return; } _raised = true; _raisedAt = Time.time; if (!_needleInit) { _needleAngle = TargetNeedleAngle() + Random.Range(-60f, 60f); _needleInit = true; } _needleVel += Random.Range(140f, 260f) * ((Random.value < 0.5f) ? (-1f) : 1f); } private static float TargetNeedleAngle() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) Camera mainCamera = StarField.MainCamera; return 0f - Astronomy.HeadingDeg((((Object)(object)mainCamera != (Object)null) ? ((Component)mainCamera).transform : ((Component)Player.m_localPlayer).transform).forward); } private void Update() { //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) float deltaTime = Time.deltaTime; if (Time.time >= _nextEquipCheck) { _nextEquipCheck = Time.time + 1f; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && !StarNavPlugin.CompassStrip.Value) { Inventory inventory = ((Humanoid)localPlayer).GetInventory(); if (inventory != null) { foreach (ItemData allItem in inventory.GetAllItems()) { if (allItem.m_equipped && allItem.m_shared != null && allItem.m_shared.m_name == "$item_starnav_compass") { ((Humanoid)localPlayer).UnequipItem(allItem, false); } } } } } float value = StarNavPlugin.CompassShowSeconds.Value; if (_raised && value > 0f && Time.time - _raisedAt > value) { _raised = false; } if (_raised && !HudAllowed()) { _raised = false; } _raiseAlpha = Mathf.MoveTowards(_raiseAlpha, _raised ? 1f : 0f, deltaTime * (_raised ? 4f : 2.5f)); if (_raiseAlpha > 0f && (Object)(object)Player.m_localPlayer != (Object)null) { float num = TargetNeedleAngle(); float num2 = Mathf.DeltaAngle(_needleAngle, num); Player localPlayer2 = Player.m_localPlayer; Vector3 velocity = ((Character)localPlayer2).GetVelocity(); velocity.y = 0f; float magnitude = ((Vector3)(ref velocity)).magnitude; bool flag = ((Character)localPlayer2).IsRunning() && magnitude > 1f; float num3 = Mathf.Clamp01((magnitude - 0.2f) / 2.5f); float num4 = (flag ? 1f : (num3 * 0.35f)); float num5 = Mathf.Lerp(3.2f, 1.2f, num4); _needleVel += (num2 * 40f - _needleVel * num5) * deltaTime; if (num4 > 0.001f) { float num6 = Mathf.PerlinNoise(Time.time * (flag ? 9f : 3.5f), 0.37f) - 0.5f; float num7 = Mathf.PerlinNoise(0.71f, Time.time * (flag ? 14f : 5f)) - 0.5f; _needleVel += (num6 * 420f + num7 * 260f) * num4 * deltaTime * 10f; } _needleAngle = Mathf.Repeat(_needleAngle + _needleVel * deltaTime, 360f); } if (Time.time < _nextStarCheck) { return; } _nextStarCheck = Time.time + 0.15f; _starLabel = string.Empty; if (!StarNavPlugin.CompassShowStarNames.Value || (Object)(object)StarField.Instance == (Object)null || !ShouldShow()) { return; } Camera mainCamera = StarField.MainCamera; if (!((Object)(object)mainCamera == (Object)null) && !(StarField.Instance.Visibility < 0.2f)) { float altitudeDeg; StarRecord? starRecord = StarField.Instance.FindStarNear(((Component)mainCamera).transform.forward, 2f, out altitudeDeg); if (starRecord.HasValue) { StarRecord value2 = starRecord.Value; _starLabel = "✦ " + value2.Name; float heading = Astronomy.HeadingDeg(((Component)mainCamera).transform.forward); _starInfoText = ((value2.Hip == 11767) ? "the Pole Star — true north" : $"{altitudeDeg:0}° up, toward {CardinalName(heading)}"); } } } private static string CardinalName(float heading) { return (new string[16] { "north", "north-northeast", "northeast", "east-northeast", "east", "east-southeast", "southeast", "south-southeast", "south", "south-southwest", "southwest", "west-southwest", "west", "west-northwest", "northwest", "north-northwest" })[Mathf.RoundToInt(heading / 22.5f) % 16]; } private void DrawStarLabel() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) _starLabelAlpha = Mathf.MoveTowards(_starLabelAlpha, (_starLabel.Length > 0) ? 1f : 0f, Time.deltaTime * 6f); if (!(_starLabelAlpha <= 0.02f) && _starLabel.Length != 0) { float num = (float)Screen.height * 0.5f + 28f; GUI.color = new Color(0f, 0f, 0f, 0.35f * _starLabelAlpha); GUI.DrawTexture(new Rect((float)Screen.width * 0.5f - 150f, num - 2f, 300f, 42f), (Texture)(object)_white); GUI.color = new Color(1f, 0.97f, 0.9f, _starLabelAlpha); GUI.Label(new Rect((float)Screen.width * 0.5f - 150f, num, 300f, 22f), _starLabel, _starName); GUI.color = new Color(0.85f, 0.9f, 1f, 0.85f * _starLabelAlpha); GUI.Label(new Rect((float)Screen.width * 0.5f - 150f, num + 20f, 300f, 18f), _starInfoText, _starInfo); GUI.color = Color.white; } } private void DrawRaised() { //IL_00d7: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: 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) if (_raiseAlpha <= 0.01f) { return; } if ((Object)(object)_faceTex == (Object)null) { _faceTex = CompassItem.LoadPng("StarNav.compass_face.png"); } if ((Object)(object)_needleTex == (Object)null) { _needleTex = CompassItem.LoadPng("StarNav.compass_needle.png"); } if (!((Object)(object)_faceTex == (Object)null) && !((Object)(object)_needleTex == (Object)null)) { float value = StarNavPlugin.CompassSize.Value; float num = Mathf.SmoothStep(0f, 1f, _raiseAlpha); float num2 = (float)Screen.width * 0.5f + value * 0.35f; float num3 = (float)Screen.height - value * 0.55f + (1f - num) * value * 0.6f; Rect val = default(Rect); ((Rect)(ref val))..ctor(num2 - value * 0.5f, num3 - value * 0.5f, value, value); Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, num); GUI.DrawTexture(val, (Texture)(object)_faceTex, (ScaleMode)0, true); Matrix4x4 matrix = GUI.matrix; GUIUtility.RotateAroundPivot(_needleAngle, new Vector2(num2, num3)); GUI.DrawTexture(val, (Texture)(object)_needleTex, (ScaleMode)0, true); GUI.matrix = matrix; if (StarNavPlugin.CompassShowDegrees.Value) { float num4 = Astronomy.HeadingDeg((((Object)(object)StarField.MainCamera != (Object)null) ? ((Component)StarField.MainCamera).transform : ((Component)Player.m_localPlayer).transform).forward); GUI.color = new Color(0f, 0f, 0f, 0.45f * num); GUI.DrawTexture(new Rect(num2 - 30f, ((Rect)(ref val)).yMax - value * 0.08f, 60f, 22f), (Texture)(object)_white); GUI.color = new Color(1f, 0.95f, 0.85f, num); GUI.Label(new Rect(num2 - 40f, ((Rect)(ref val)).yMax - value * 0.08f, 80f, 22f), $"{Mathf.RoundToInt(num4) % 360:000}°", _degrees); } GUI.color = color; } } private void OnGUI() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_005e: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0230: 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_0267: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0293: 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_02b9: Unknown result type (might be due to invalid IL or missing references) if ((int)Event.current.type != 7 || (!HudAllowed() && _raiseAlpha <= 0.01f)) { return; } EnsureStyles(); DrawRaised(); if (!ShouldShowStrip()) { DrawStarLabel(); return; } Camera mainCamera = StarField.MainCamera; float num = Astronomy.HeadingDeg((((Object)(object)mainCamera != (Object)null) ? ((Component)mainCamera).transform : ((Component)Player.m_localPlayer).transform).forward); float value = StarNavPlugin.CompassWidth.Value; float num2 = 40f; float num3 = ((float)Screen.width - value) * 0.5f; float value2 = StarNavPlugin.CompassYOffset.Value; float num4 = value / 90f; GUI.color = new Color(0f, 0f, 0f, 0.42f); GUI.DrawTexture(new Rect(num3, value2, value, num2), (Texture)(object)_white); GUI.color = new Color(0.85f, 0.75f, 0.5f, 0.55f); GUI.DrawTexture(new Rect(num3, value2, value, 1f), (Texture)(object)_white); GUI.DrawTexture(new Rect(num3, value2 + num2 - 1f, value, 1f), (Texture)(object)_white); GUI.BeginGroup(new Rect(num3, value2, value, num2)); float num5 = num - 45f; for (int i = Mathf.FloorToInt(num5 / 5f) * 5; (float)i <= num5 + 90f + 5f; i += 5) { float num6 = ((float)i - num5) * num4; if (!(num6 < -20f) && !(num6 > value + 20f)) { int num7 = (i % 360 + 360) % 360; bool flag = num7 % 45 == 0; bool flag2 = num7 % 15 == 0; float num8 = Mathf.Clamp01(Mathf.Min(num6, value - num6) / 40f); float num9 = (flag ? 12f : (flag2 ? 8f : 4f)); GUI.color = new Color(1f, 0.95f, 0.85f, (flag ? 0.95f : 0.6f) * num8); GUI.DrawTexture(new Rect(num6 - 0.5f, num2 - num9 - 2f, flag ? 2f : 1f, num9), (Texture)(object)_white); if (flag) { string text = s_cardinals[num7 / 45]; GUI.color = ((num7 == 0) ? new Color(1f, 0.45f, 0.35f) : new Color(1f, 0.95f, 0.85f)) * new Color(1f, 1f, 1f, num8); GUI.Label(new Rect(num6 - 20f, 1f, 40f, 22f), text, _cardinal); } else if (flag2 && StarNavPlugin.CompassShowDegrees.Value) { GUI.color = new Color(1f, 0.95f, 0.85f, 0.75f * num8); GUI.Label(new Rect(num6 - 16f, 4f, 32f, 16f), num7.ToString(), _minor); } } } GUI.color = new Color(1f, 0.85f, 0.4f, 0.95f); GUI.DrawTexture(new Rect(value * 0.5f - 1f, 0f, 2f, num2), (Texture)(object)_white); GUI.EndGroup(); if (StarNavPlugin.CompassShowDegrees.Value) { GUI.color = new Color(0f, 0f, 0f, 0.42f); GUI.DrawTexture(new Rect(num3 + value * 0.5f - 28f, value2 + num2 + 2f, 56f, 20f), (Texture)(object)_white); GUI.color = new Color(1f, 0.95f, 0.85f, 0.95f); GUI.Label(new Rect(num3 + value * 0.5f - 30f, value2 + num2 + 2f, 60f, 20f), $"{Mathf.RoundToInt(num) % 360:000}°", _degrees); } DrawStarLabel(); GUI.color = Color.white; } } [HarmonyPatch(typeof(GameCamera), "Awake")] internal static class GameCamera_Awake_Hud_Patch { private static void Postfix() { try { CompassHud.Create(); } catch (Exception ex) { StarNavPlugin.Log.LogError((object)("Compass HUD creation failed: " + ex)); } } } [HarmonyPatch(typeof(Terminal), "InitTerminal")] internal static class Terminal_InitTerminal_Patch { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__1_0; internal void <Postfix>b__1_0(ConsoleEventArgs args) { //IL_09ee: Unknown result type (might be due to invalid IL or missing references) //IL_0a04: Unknown result type (might be due to invalid IL or missing references) string text = ((args.Length > 1) ? args[1].ToLowerInvariant() : "info"); if (new HashSet<string> { "sky", "shader", "size", "bright", "force", "matrix", "matrix2", "queue", "test", "test2", "test3", "test4", "test5" }.Contains(text) && !StarNavPlugin.DebugCommands.Value) { args.Context.AddString("Developer command; set DebugCommands=true in the config to enable."); return; } if (new HashSet<string> { "lines", "time", "sky", "shader", "size", "bright", "force", "matrix", "matrix2", "queue", "test", "test2", "test3", "test4", "test5" }.Contains(text) && !StarNavPlugin.Enabled.Value) { args.Context.AddString("The star sky is off (StarSky=false in the config)."); return; } switch (text) { case "hud": StarNavPlugin.CompassStrip.Value = !StarNavPlugin.CompassStrip.Value; args.Context.AddString("Compass HUD strip mode: " + (StarNavPlugin.CompassStrip.Value ? "on (wear it in the utility slot)" : "off (use from the hotbar)")); return; case "lines": StarNavPlugin.ShowConstellationLines.Value = !StarNavPlugin.ShowConstellationLines.Value; args.Context.AddString("Constellation lines: " + (StarNavPlugin.ShowConstellationLines.Value ? "on" : "off")); return; case "sky": if ((Object)(object)StarField.Instance != (Object)null) { StarField.Instance.DumpSkyRenderers(); args.Context.AddString("Sky renderers written to BepInEx/LogOutput.log"); } return; case "shader": if ((Object)(object)StarField.Instance != (Object)null && args.Length > 2) { string shader = args.ArgsAll.Substring(args.ArgsAll.IndexOf(args[2], StringComparison.Ordinal)); args.Context.AddString("Star shader now: " + StarField.Instance.SetShader(shader)); } else { args.Context.AddString("usage: starnav shader <Shader/Name> e.g. 'Custom/Particle (Unlit)', 'Legacy Shaders/Particles/Additive', 'Sprites/Default', 'UI/Default'"); } return; case "size": { if ((Object)(object)StarField.Instance != (Object)null && args.Length > 2 && float.TryParse(args[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2)) { StarNavPlugin.StarSize.Value = Mathf.Clamp(result2, 0.3f, 6f); StarField.Instance.RebuildStars(); args.Context.AddString("Star size x" + StarNavPlugin.StarSize.Value); } else { args.Context.AddString("usage: starnav size <0.3-6>"); } return; } case "bright": { if (args.Length > 2 && float.TryParse(args[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { StarNavPlugin.StarBrightness.Value = Mathf.Clamp(result, 0.1f, 6f); args.Context.AddString("Star brightness x" + StarNavPlugin.StarBrightness.Value); } else { args.Context.AddString("usage: starnav bright <0.1-6>"); } return; } case "force": StarNavPlugin.ForceAlwaysVisible.Value = !StarNavPlugin.ForceAlwaysVisible.Value; args.Context.AddString("Force all stars visible: " + (StarNavPlugin.ForceAlwaysVisible.Value ? "ON" : "off")); return; case "matrix2": if ((Object)(object)StarField.Instance != (Object)null) { args.Context.AddString(StarField.Instance.ToggleMatrix2()); } return; case "matrix": if ((Object)(object)StarField.Instance != (Object)null) { args.Context.AddString(StarField.Instance.ToggleMatrix()); } return; case "queue": { if ((Object)(object)StarField.Instance != (Object)null && args.Length > 2 && int.TryParse(args[2], out var result4)) { StarField.Instance.SetQueue(result4); args.Context.AddString("Star render queue " + result4); } else { args.Context.AddString("usage: starnav queue <2500-3500>"); } return; } case "test4": if ((Object)(object)StarField.Instance != (Object)null) { args.Context.AddString(StarField.Instance.ToggleTestSingles()); } return; case "test5": if ((Object)(object)StarField.Instance != (Object)null) { args.Context.AddString(StarField.Instance.ToggleTestRotQuad()); } return; case "test2": if ((Object)(object)StarField.Instance != (Object)null) { args.Context.AddString(StarField.Instance.ToggleTestFans(rotating: true)); } return; case "test3": if ((Object)(object)StarField.Instance != (Object)null) { args.Context.AddString(StarField.Instance.ToggleTestFans(rotating: false)); } return; case "test": if ((Object)(object)StarField.Instance != (Object)null) { StarField.Instance.ToggleTestQuad(); args.Context.AddString("Toggled test quad (look straight up)"); } return; case "tod": if (!((Object)(object)EnvMan.instance == (Object)null)) { string text2 = ((args.Length > 2) ? args[2].ToLowerInvariant() : "off"); float result3; if (text2 == "off" || text2 == "-1") { EnvMan.instance.m_debugTimeOfDay = false; args.Context.AddString("Time of day: back to world clock"); } else if (float.TryParse(text2, NumberStyles.Float, CultureInfo.InvariantCulture, out result3)) { EnvMan.instance.m_debugTimeOfDay = true; EnvMan.instance.m_debugTime = Mathf.Repeat(result3, 1f); args.Context.AddString($"Time of day fixed at {EnvMan.instance.m_debugTime:0.00} (0 = midnight, 0.25 = sunrise, 0.5 = noon, 0.75 = sunset). 'starnav tod off' to release."); } } return; case "time": if ((Object)(object)EnvMan.instance != (Object)null) { args.Context.AddString($"Day {EnvMan.instance.GetDay()} fraction {EnvMan.instance.GetDayFraction():0.000} LST {StarField.ComputeLst():0.0}°"); } return; } StarField instance = StarField.Instance; Camera mainCamera = StarField.MainCamera; args.Context.AddString("StarNav 1.0.0 star sky " + (StarNavPlugin.Enabled.Value ? "on" : "off")); args.Context.AddString($"night {StarNavPlugin.SkyState.NightInt:0.00} day {StarNavPlugin.SkyState.DayInt:0.00} fog {StarNavPlugin.SkyState.FogDensity:0.0000} clouds {StarNavPlugin.SkyState.CloudOpacity:0.00} wet {StarNavPlugin.SkyState.Wet} -> visibility {(((Object)(object)instance != (Object)null) ? instance.Visibility : 0f):0.00}"); if ((Object)(object)instance != (Object)null) { args.Context.AddString($"LST {instance.CurrentLstDeg:0.0}°"); } if ((Object)(object)mainCamera != (Object)null) { args.Context.AddString($"Looking heading {Astronomy.HeadingDeg(((Component)mainCamera).transform.forward):000}° alt {Astronomy.AltitudeDeg(((Component)mainCamera).transform.forward):0}° far plane {mainCamera.farClipPlane:0}"); } args.Context.AddString("Compass equipped: " + CompassItem.IsEquipped()); } } private static bool s_done; private static void Postfix() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown if (s_done) { return; } s_done = true; object obj = <>c.<>9__1_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { //IL_09ee: Unknown result type (might be due to invalid IL or missing references) //IL_0a04: Unknown result type (might be due to invalid IL or missing references) string text = ((args.Length > 1) ? args[1].ToLowerInvariant() : "info"); if (new HashSet<string> { "sky", "shader", "size", "bright", "force", "matrix", "matrix2", "queue", "test", "test2", "test3", "test4", "test5" }.Contains(text) && !StarNavPlugin.DebugCommands.Value) { args.Context.AddString("Developer command; set DebugCommands=true in the config to enable."); } else if (new HashSet<string> { "lines", "time", "sky", "shader", "size", "bright", "force", "matrix", "matrix2", "queue", "test", "test2", "test3", "test4", "test5" }.Contains(text) && !StarNavPlugin.Enabled.Value) { args.Context.AddString("The star sky is off (StarSky=false in the config)."); } else { switch (text) { case "hud": StarNavPlugin.CompassStrip.Value = !StarNavPlugin.CompassStrip.Value; args.Context.AddString("Compass HUD strip mode: " + (StarNavPlugin.CompassStrip.Value ? "on (wear it in the utility slot)" : "off (use from the hotbar)")); break; case "lines": StarNavPlugin.ShowConstellationLines.Value = !StarNavPlugin.ShowConstellationLines.Value; args.Context.AddString("Constellation lines: " + (StarNavPlugin.ShowConstellationLines.Value ? "on" : "off")); break; case "sky": if ((Object)(object)StarField.Instance != (Object)null) { StarField.Instance.DumpSkyRenderers(); args.Context.AddString("Sky renderers written to BepInEx/LogOutput.log"); } break; case "shader": if ((Object)(object)StarField.Instance != (Object)null && args.Length > 2) { string shader = args.ArgsAll.Substring(args.ArgsAll.IndexOf(args[2], StringComparison.Ordinal)); args.Context.AddString("Star shader now: " + StarField.Instance.SetShader(shader)); } else { args.Context.AddString("usage: starnav shader <Shader/Name> e.g. 'Custom/Particle (Unlit)', 'Legacy Shaders/Particles/Additive', 'Sprites/Default', 'UI/Default'"); } break; case "size": { if ((Object)(object)StarField.Instance != (Object)null && args.Length > 2 && float.TryParse(args[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2)) { StarNavPlugin.StarSize.Value = Mathf.Clamp(result2, 0.3f, 6f); StarField.Instance.RebuildStars(); args.Context.AddString("Star size x" + StarNavPlugin.StarSize.Value); } else { args.Context.AddString("usage: starnav size <0.3-6>"); } break; } case "bright": { if (args.Length > 2 && float.TryParse(args[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { StarNavPlugin.StarBrightness.Value = Mathf.Clamp(result, 0.1f, 6f); args.Context.AddString("Star brightness x" + StarNavPlugin.StarBrightness.Value); } else { args.Context.AddString("usage: starnav bright <0.1-6>"); } break; } case "force": StarNavPlugin.ForceAlwaysVisible.Value = !StarNavPlugin.ForceAlwaysVisible.Value; args.Context.AddString("Force all stars visible: " + (StarNavPlugin.ForceAlwaysVisible.Value ? "ON" : "off")); break; case "matrix2": if ((Object)(object)StarField.Instance != (Object)null) { args.Context.AddString(StarField.Instance.ToggleMatrix2()); } break; case "matrix": if ((Object)(object)StarField.Instance != (Object)null) { args.Context.AddString(StarField.Instance.ToggleMatrix()); } break; case "queue": { if ((Object)(object)StarField.Instance != (Object)null && args.Length > 2 && int.TryParse(args[2], out var result4)) { StarField.Instance.SetQueue(result4); args.Context.AddString("Star render queue " + result4); } else { args.Context.AddString("usage: starnav queue <2500-3500>"); } break; } case "test4": if ((Object)(object)StarField.Instance != (Object)null) { args.Context.AddString(StarField.Instance.ToggleTestSingles()); } break; case "test5": if ((Object)(object)StarField.Instance != (Object)null) { args.Context.AddString(StarField.Instance.ToggleTestRotQuad()); } break; case "test2": if ((Object)(object)StarField.Instance != (Object)null) { args.Context.AddString(StarField.Instance.ToggleTestFans(rotating: true)); } break; case "test3": if ((Object)(object)StarField.Instance != (Object)null) { args.Context.AddString(StarField.Instance.ToggleTestFans(rotating: false)); } break; case "test": if ((Object)(object)StarField.Instance != (Object)null) { StarField.Instance.ToggleTestQuad(); args.Context.AddString("Toggled test quad (look straight up)"); } break; case "tod": if (!((Object)(object)EnvMan.instance == (Object)null)) { string text2 = ((args.Length > 2) ? args[2].ToLowerInvariant() : "off"); float result3; if (text2 == "off" || text2 == "-1") { EnvMan.instance.m_debugTimeOfDay = false; args.Context.AddString("Time of day: back to world clock"); } else if (float.TryParse(text2, NumberStyles.Float, CultureInfo.InvariantCulture, out result3)) { EnvMan.instance.m_debugTimeOfDay = true; EnvMan.instance.m_debugTime = Mathf.Repeat(result3, 1f); args.Context.AddString($"Time of day fixed at {EnvMan.instance.m_debugTime:0.00} (0 = midnight, 0.25 = sunrise, 0.5 = noon, 0.75 = sunset). 'starnav tod off' to release."); } } break; case "time": if ((Object)(object)EnvMan.instance != (Object)null) { args.Context.AddString($"Day {EnvMan.instance.GetDay()} fraction {EnvMan.instance.GetDayFraction():0.000} LST {StarField.ComputeLst():0.0}°"); } break; default: { StarField instance = StarField.Instance; Camera mainCamera = StarField.MainCamera; args.Context.AddString("StarNav 1.0.0 star sky " + (StarNavPlugin.Enabled.Value ? "on" : "off")); args.Context.AddString($"night {StarNavPlugin.SkyState.NightInt:0.00} day {StarNavPlugin.SkyState.DayInt:0.00} fog {StarNavPlugin.SkyState.FogDensity:0.0000} clouds {StarNavPlugin.SkyState.CloudOpacity:0.00} wet {StarNavPlugin.SkyState.Wet} -> visibility {(((Object)(object)instance != (Object)null) ? instance.Visibility : 0f):0.00}"); if ((Object)(object)instance != (Object)null) { args.Context.AddString($"LST {instance.CurrentLstDeg:0.0}°"); } if ((Object)(object)mainCamera != (Object)null) { args.Context.AddString($"Looking heading {Astronomy.HeadingDeg(((Component)mainCamera).transform.forward):000}° alt {Astronomy.AltitudeDeg(((Component)mainCamera).transform.forward):0}° far plane {mainCamera.farClipPlane:0}"); } args.Context.AddString("Compass equipped: " + CompassItem.IsEquipped()); break; } } } }; <>c.<>9__1_0 = val; obj = (object)val; } new ConsoleCommand("starnav", "StarNav: starnav info | hud | tod <0-1|off> | time | lines", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } } [HarmonyPatch(typeof(HotkeyBar), "UpdateIcons")] internal static class HotkeyBar_UpdateIcons_Patch { private static readonly FieldInfo s_elements = AccessTools.Field(typeof(HotkeyBar), "m_elements"); private static FieldInfo s_equiped; private static void Postfix(HotkeyBar __instance, Player player) { if ((Object)(object)player == (Object)null || s_elements == null) { return; } IList list = s_elements.GetValue(__instance) as IList; Inventory inventory = ((Humanoid)player).GetInventory(); if (list == null || inventory == null) { return; } bool flag = (Object)(object)CompassHud.Instance != (Object)null && CompassHud.Instance.IsRaised; for (int i = 0; i < list.Count; i++) { ItemData itemAt = inventory.GetItemAt(i, 0); if (itemAt != null && itemAt.m_shared != null && !(itemAt.m_shared.m_name != "$item_starnav_compass")) { object obj = list[i]; if (s_equiped == null) { s_equiped = AccessTools.Field(obj.GetType(), "m_equiped"); } object? obj2 = s_equiped?.GetValue(obj); GameObject val = (GameObject)((obj2 is GameObject) ? obj2 : null); if ((Object)(object)val != (Object)null && val.activeSelf != flag) { val.SetActive(flag); } } } } } public static class CompassItem { public const string PrefabName = "StarNav_Compass"; public const string TokenName = "$item_starnav_compass"; public const string TokenDesc = "$item_starnav_compass_description"; private const string ClonePrefabName = "Wishbone"; private static GameObject s_container; private static GameObject s_prefab; private static Recipe s_recipe; private static Sprite s_icon; private static readonly MethodInfo s_addWord = AccessTools.Method(typeof(Localization), "AddWord", (Type[])null, (Type[])null); private static readonly MethodInfo s_updateRegisters = AccessTools.Method(typeof(ObjectDB), "UpdateRegisters", (Type[])null, (Type[])null); public static bool Enabled => StarNavPlugin.CompassEnabled.Value; public static GameObject EnsurePrefab(GameObject source) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s_prefab != (Object)null) { return s_prefab; } if ((Object)(object)source == (Object)null) { if ((Object)(object)ObjectDB.instance != (Object)null) { source = ObjectDB.instance.GetItemPrefab("Wishbone"); } if ((Object)(object)source == (Object)null && (Object)(object)ZNetScene.instance != (Object)null) { source = ZNetScene.instance.GetPrefab("Wishbone"); } } if ((Object)(object)source == (Object)null) { StarNavPlugin.Log.LogWarning((object)"Could not find 'Wishbone' to clone the compass from (yet)"); return null; } if ((Object)(object)s_container == (Object)null) { s_container = new GameObject("StarNav_Prefabs"); s_container.SetActive(false); Object.DontDestroyOnLoad((Object)(object)s_container); } GameObject val = Object.Instantiate<GameObject>(source, s_container.transform); ((Object)val).name = "StarNav_Compass"; ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { StarNavPlugin.Log.LogError((object)"Cloned prefab has no ItemDrop"); Object.Destroy((Object)(object)val); return null; } SharedData shared = component.m_itemData.m_shared; shared.m_name = "$item_starnav_compass"; shared.m_description = "$item_starnav_compass_description"; shared.m_itemType = (ItemType)18; shared.m_equipStatusEffect = null; shared.m_setStatusEffect = null; shared.m_maxStackSize = 1; shared.m_maxQuality = 1; shared.m_weight = 0.5f; shared.m_value = 60; shared.m_teleportable = true; shared.m_questItem = false; shared.m_useDurability = false; shared.m_dlc = string.Empty; shared.m_icons = (Sprite[])(object)new Sprite[1] { GetIcon() }; component.m_itemData.m_dropPrefab = val; s_prefab = val; StarNavPlugin.Log.LogInfo((object)"Compass prefab created"); return s_prefab; } public static void RegisterInZNetScene(ZNetScene scene) { if (!Enabled || (Object)(object)scene == (Object)null) { return; } GameObject source = null; foreach (GameObject prefab in scene.m_prefabs) { if ((Object)(object)prefab != (Object)null && ((Object)prefab).name == "Wishbone") { source = prefab; break; } } GameObject val = EnsurePrefab(source); if (!((Object)(object)val == (Object)null) && !scene.m_prefabs.Contains(val)) { scene.m_prefabs.Add(val); } } public static void RegisterInObjectDB(ObjectDB db) { if (!Enabled || (Object)(object)db == (Object)null) { return; } GameObject val = EnsurePrefab(null); if (!((Object)(object)val == (Object)null)) { bool flag = false; if (!db.m_items.Contains(val)) { db.m_items.Add(val); flag = true; } if (flag) { s_updateRegisters?.Invoke(db, null); } if ((Object)(object)s_recipe == (Object)null) { s_recipe = ScriptableObject.CreateInstance<Recipe>(); ((Object)s_recipe).name = "Recipe_StarNav_Compass"; s_recipe.m_item = val.GetComponent<ItemDrop>(); s_recipe.m_amount = 1; s_recipe.m_enabled = true; s_recipe.m_minStationLevel = StarNavPlugin.CompassStationLevel.Value; } s_recipe.m_craftingStation = FindWorkbench() ?? s_recipe.m_craftingStation; s_recipe.m_resources = ParseRequirements(db, StarNavPlugin.CompassRecipe.Value); if (!db.m_recipes.Contains(s_recipe)) { db.m_recipes.Add(s_recipe); } AddLocalization(Localization.instance); } } private static CraftingStation FindWorkbench() { GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab("piece_workbench") : null); if ((Object)(object)val != (Object)null) { return val.GetComponent<CraftingStation>(); } CraftingStation[] array = Resources.FindObjectsOfTypeAll<CraftingStation>(); foreach (CraftingStation val2 in array) { if (((Object)((Component)val2).gameObject).name == "piece_workbench") { return val2; } } return null; } private static Requirement[] ParseRequirements(ObjectDB db, string spec) { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_011e: Expected O, but got Unknown //IL_009b: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown List<Requirement> list = new List<Requirement>(); string[] array = spec.Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Trim().Split(new char[1] { ':' }); if (array2.Length != 0 && array2[0].Length != 0) { int result = 1; if (array2.Length > 1) { int.TryParse(array2[1].Trim(), out result); } GameObject itemPrefab = db.GetItemPrefab(array2[0].Trim()); if ((Object)(object)itemPrefab == (Object)null) { StarNavPlugin.Log.LogWarning((object)("Compass recipe: unknown item '" + array2[0] + "'")); continue; } list.Add(new Requirement { m_resItem = itemPrefab.GetComponent<ItemDrop>(), m_amount = Mathf.Max(1, result), m_recover = true }); } } if (list.Count == 0 && (Object)(object)db.GetItemPrefab("Bronze") != (Object)null) { list.Add(new Requirement { m_resItem = db.GetItemPrefab("Bronze").GetComponent<ItemDrop>(), m_amount = 2, m_recover = true }); } return list.ToArray(); } public static void AddLocalization(Localization loc) { if (s_addWord == null || loc == null) { return; } try { s_addWord.Invoke(loc, new object[2] { "$item_starnav_compass".Substring(1), "Compass" }); s_addWord.Invoke(loc, new object[2] { "$item_starnav_compass_description".Substring(1), "A lodestone needle floating in oil. Worn, it shows your heading at the top of the screen and names the bright stars you look at. Polaris marks true north." }); } catch (Exception ex) { StarNavPlugin.Log.LogWarning((object)("Localization failed: " + ex.Message)); } } public static bool IsEquipped() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return false; } Inventory inventory = ((Humanoid)localPlayer).GetInventory(); if (inventory == null) { return false; } foreach (ItemData allItem in inventory.GetAllItems()) { if (allItem.m_equipped && allItem.m_shared != null && allItem.m_shared.m_name == "$item_starnav_compass") { return true; } } return false; } public static Texture2D LoadPng(string resourceName) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown try { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName); if (stream == null) { return null; } byte[] array = new byte[stream.Length]; int num; for (int i = 0; i < array.Length; i += num) { num = stream.Read(array, i, array.Length - i); if (num <= 0) { break; } } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false) { name = resourceName, filterMode = (FilterMode)2, wrapMode = (TextureWrapMode)1 }; MethodInfo methodInfo = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule")?.GetMethod("LoadImage", new Type[3] { typeof(Texture2D), typeof(byte[]), typeof(bool) }); if (methodInfo != null && (bool)methodInfo.Invoke(null, new object[3] { val, array, false })) { return val; } } catch (Exception ex) { StarNavPlugin.Log.LogWarning((object)("PNG " + resourceName + " failed: " + ex.Message)); } return null; } public static Sprite GetIcon() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s_icon != (Object)null) { return s_icon; } Texture2D val = LoadPng("StarNav.compass_icon.png"); if ((Object)(object)val != (Object)null) { s_icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); ((Object)s_icon).name = "StarNav_CompassIcon"; return s_icon; } return GetProceduralIcon(); } private static Sprite GetProceduralIcon() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false) { name = "StarNav_CompassIcon", filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; Color[] array = (Color[])(object)new Color[4096]; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(31.5f, 31.5f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.78f, 0.62f, 0.28f); Color val4 = default(Color); ((Color)(ref val4))..ctor(0.45f, 0.33f, 0.12f); Color val5 = default(Color); ((Color)(ref val5))..ctor(0.93f, 0.88f, 0.74f); Color val6 = default(Color); ((Color)(ref val6))..ctor(0.15f, 0.12f, 0.1f); Color val7 = default(Color); ((Color)(ref val7))..ctor(0.75f, 0.15f, 0.12f); for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { Vector2 val8 = new Vector2((float)j, (float)i) - val2; float num = ((Vector2)(ref val8)).magnitude / 32f; Color val9 = Color.clear; if (num < 0.98f) { val9 = ((num > 0.8f) ? Color.Lerp(val4, val3, Mathf.Clamp01((0.98f - num) / 0.18f) * 0.6f + 0.4f) : val5); if (num <= 0.8f) { float num2 = Mathf.Atan2(val8.x, val8.y); float num3 = Mathf.Abs(Mathf.Repeat(num2 + (float)Math.PI / 4f, (float)Math.PI / 2f) - (float)Math.PI / 4f); float num4 = Mathf.Abs(Mathf.Repeat(num2 + (float)Math.PI / 8f, (float)Math.PI / 4f) - (float)Math.PI / 8f); float num5 = Mathf.Clamp01((0.75f - num) / 0.75f); if (num3 < 0.11f * num5 * 2.2f && num < 0.75f) { val9 = ((Mathf.Abs(num2) < 0.5f && val8.y > 0f) ? val7 : val6); } else if (num4 < 0.07f * Mathf.Clamp01((0.5f - num) / 0.5f) * 2.2f && num < 0.5f) { val9 = Color.Lerp(val6, val5, 0.45f); } if (num < 0.07f) { val9 = val3; } if (num > 0.72f && num < 0.78f && Mathf.Abs(Mathf.Repeat(num2, (float)Math.PI / 8f) - (float)Math.PI / 16f) > 0.16634955f) { val9 = val6; } } float a = Mathf.Clamp01((0.98f - num) * 64f * 0.5f); val9.a = a; } array[i * 64 + j] = val9; } } val.SetPixels(array); val.Apply(false, false); s_icon = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f); ((Object)s_icon).name = "StarNav_CompassIcon"; return s_icon; } } [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class ZNetScene_Awake_Patch { [HarmonyPriority(700)] private static void Prefix(ZNetScene __instance) { try { CompassItem.RegisterInZNetScene(__instance); } catch (Exception ex) { StarNavPlugin.Log.LogError((object)("Compass ZNetScene registration failed: " + ex)); } } } [HarmonyPatch(typeof(ObjectDB), "Awake")] internal static class ObjectDB_Awake_Patch { private static void Postfix(ObjectDB __instance) { try { CompassItem.RegisterInObjectDB(__instance); } catch (Exception ex) { StarNavPlugin.Log.LogError((object)("Compass ObjectDB registration failed: " + ex)); } } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] internal static class ObjectDB_CopyOtherDB_Patch { private static void Postfix(ObjectDB __instance) { try { CompassItem.RegisterInObjectDB(__instance); } catch (Exception ex) { StarNavPlugin.Log.LogError((object)("Compass ObjectDB(copy) registration failed: " + ex)); } } } [HarmonyPatch(typeof(Localization), "SetupLanguage")] internal static class Localization_SetupLanguage_Patch { private static void Postfix(Localization __instance) { if (CompassItem.Enabled) { CompassItem.AddLocalization(__instance); } } } [HarmonyPatch(typeof(Humanoid), "UseItem")] internal static class Humanoid_UseItem_Patch { private static bool Prefix(Humanoid __instance, ItemData item, bool fromInventoryGui) { if (item == null || item.m_shared == null || item.m_shared.m_name != "$item_starnav_compass") { return true; } if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } if (fromInventoryGui && StarNavPlugin.CompassStrip.Value) { return true; } CompassHud.Instance?.ToggleRaised(); return false; } } public class YggdrasilTweak : MonoBehaviour { private readonly List<Renderer> _renderers = new List<Renderer>(); private readonly Dictionary<Material, Color> _originalColors = new Dictionary<Material, Color>(); private float _nextScan = 1.5f; private int _scans; private StarNavPlugin.YggdrasilMode _applied; private float _appliedDim = -1f; public static YggdrasilTweak Instance { get; private set; } public static void Create() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Instance != (Object)null)) { new GameObject("StarNav_Yggdrasil").AddComponent<YggdrasilTweak>(); } } private void Awake() { Instance = this; } private void OnDestroy() { Apply(StarNavPlugin.YggdrasilMode.Keep, 1f); if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void LateUpdate() { StarNavPlugin.YggdrasilMode value = StarNavPlugin.Yggdrasil.Value; float value2 = StarNavPlugin.YggdrasilDim.Value; if (Time.time >= _nextScan && _scans < 6) { _scans++; _nextScan = Time.time + ((_scans < 3) ? 4f : 20f); if (_renderers.Count > 0) { _scans = 99; } bool flag = false; Renderer[] array = Resources.FindObjectsOfTypeAll<Renderer>(); foreach (Renderer val in array) { if (!((Object)(object)val == (Object)null) && !_renderers.Contains(val)) { Material sharedMaterial = val.sharedMaterial; if (!((Object)(object)sharedMaterial == (Object)null) && !((Object)(object)sharedMaterial.shader == (Object)null) && ((Object)sharedMaterial.shader).name.StartsWith("Custom/Yggdrasil", StringComparison.Ordinal)) { _renderers.Add(val); flag = true; } } } if (flag) { _applied = StarNavPlugin.YggdrasilMode.Keep; _appliedDim = -1f; } } if (value != _applied || (value == StarNavPlugin.YggdrasilMode.Dim && !Mathf.Approximately(value2, _appliedDim))) { Apply(value, value2); _applied = value; _appliedDim = value2; } if (value != StarNavPlugin.YggdrasilMode.Hide) { return; } foreach (Renderer renderer in _renderers) { if ((Object)(object)renderer != (Object)null && (renderer.enabled || !renderer.forceRenderingOff)) { renderer.enabled = false; renderer.forceRenderingOff = true; } } } private void Apply(StarNavPlugin.YggdrasilMode mode, float dim) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) foreach (Renderer renderer in _renderers) { if ((Object)(object)renderer == (Object)null) { continue; } bool flag = mode == StarNavPlugin.YggdrasilMode.Hide; renderer.enabled = !flag; renderer.forceRenderingOff = flag; Material[] materials = renderer.materials; foreach (Material val in materials) { if (!((Object)(object)val == (Object)null) && val.HasProperty("_Color")) { if (!_originalColors.TryGetValue(val, out var value)) { value = val.color; _originalColors[val] = value; } float num = ((mode == StarNavPlugin.YggdrasilMode.Dim) ? dim : 1f); val.color = new Color(value.r * num, value.g * num, value.b * num, value.a); } } } } } public struct StarRecord { public int Hip; public float RaDeg; public float DecDeg; public float Mag; public float BV; public string Name; } public struct ConstellationLine { public string Id; public Vector2[] Points; } public static class StarCatalog { private static List<StarRecord> s_stars; private static List<ConstellationLine> s_lines; private static Thread s_thread; private static readonly object s_lock = new object(); public static IReadOnlyList<StarRecord> Stars { get { EnsureLoaded(); return s_stars; } } public static IReadOnlyList<ConstellationLine> Lines { get { EnsureLoaded(); return s_lines; } } public static void PreloadAsync() { lock (s_lock) { if (s_stars != null || s_thread != null) { return; } s_thread = new Thread((ThreadStart)delegate { try { Load(); } catch (Exception ex) { StarNavPlugin.Log.LogError((object)("Catalog preload failed: " + ex)); } }) { IsBackground = true, Name = "StarNav catalog" }; s_thread.Start(); } } private static void EnsureLoaded() { Thread thread; lock (s_lock) { thread = s_thread; } if (thread != null && thread.IsAlive) { thread.Join(); } if (s_stars == null) { Load(); } } private static void Load() { //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) List<StarRecord> list = new List<StarRecord>(16000); List<ConstellationLine> list2 = new List<ConstellationLine>(160); CultureInfo invariantCulture = CultureInfo.InvariantCulture; try { foreach (string item in ReadResourceLines("StarNav.stars.csv")) { if (item.Length != 0 && item[0] != '#') { string[] array = item.Split(new char[1] { ',' }); if (array.Length >= 5) { list.Add(new StarRecord { Hip = int.Parse(array[0], invariantCulture), RaDeg = float.Parse(array[1], invariantCulture), DecDeg = float.Parse(array[2], invariantCulture), Mag = float.Parse(array[3], invariantCulture), BV = float.Parse(array[4], invariantCulture), Name = ((array.Length > 5) ? array[5].Trim() : string.Empty) }); } } } foreach (string item2 in ReadResourceLines("StarNav.constellations.csv")) { if (item2.Length == 0 || item2[0] == '#') { continue; } int num = item2.IndexOf(';'); if (num >= 0) { string id = item2.Substring(0, num); string[] array2 = item2.Substring(num + 1).Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); Vector2[] array3 = (Vector2[])(object)new Vector2[array2.Length]; for (int i = 0; i < array2.Length; i++) { string[] array4 = array2[i].Split(new char[1] { ',' }); array3[i] = new Vector2(float.Parse(array4[0], invariantCulture), float.Parse(array4[1], invariantCulture)); } list2.Add(new ConstellationLine { Id = id, Points = array3 }); } } StarNavPlugin.Log.LogInfo((object)$"Star catalog loaded: {list.Count} stars, {list2.Count} constellation lines"); } catch (Exception ex) { StarNavPlugin.Log.LogError((object)("Failed to load star catalog: " + ex)); } s_lines = list2; s_stars = list; } private static IEnumerable<string> ReadResourceLines(string name) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); using Stream s = executingAssembly.GetManifestResourceStream(name); if (s == null) { throw new FileNotFoundException("Missing embedded resource " + name); } using StreamReader r = new StreamReader(s); string text; while ((text = r.ReadLine()) != null) { yield return text; } } } public class StarField : MonoBehaviour { private class StarChunk { public Mesh Mesh; public Color[] Colors; public int First; public int Count; public bool Dirty; } private const float BrightLimit = 5f; private const int RenderQueue = 2900; private const int AboveCloudsQueue = 2900; private const int Spokes = 8; private const int VertsPerStar = 17; private const int TrisPerStar = 24; private const float InnerAlpha = 0.9f; private Camera _cam; private Transform _rot; private Material _starMat; private Material _brightMat; private Material _lineMat; private Material _meteorMat; private Texture2D _starTex; private Texture2D _meteorTex; private const int ChunkStars = 3000; private StarChunk[] _brightChunks; private Color[] _brightColors; private StarRecord[] _bright; private Vector3[] _brightDir; private Color[] _brightBase; private float[] _twPhase1; private float[] _twPhase2; private float[] _twSpeed1; private float[] _twSpeed2; private float[] _twAmp; private bool[] _navStar; private StarChunk[] _faintChunks; private Color[] _faintColors; private Vector3[] _faintDir; private Color[] _faintBase; private int _faintCursor; private MeshRenderer _lineRenderer; private Mesh _meteorMesh; private MeshRenderer _meteorRenderer; private float _nextMeteor; private float _meteorT = -1f; private float _meteorDur; private Vector3 _meteorStart; private Vector3 _meteorAxis; private float _meteorArc; private float _meteorWidth; private Color _meteorColor; private float _autoDumpAt = -1f; private Material _skyboxMat; private float _savedStarExposure = float.NaN; private int _poleSign = 1; private float _currentLst; private Vector3 _pole; private static readonly int s_starExposure = Shader.PropertyToID("_StarExposure"); private Camera _mainCam; private int _skyLayer; private GameObject _testQuad; private GameObject _testFans; private readonly List<GameObject> _test4 = new List<GameObject>(); private readonly List<GameObject> _matrix = new List<GameObject>(); public static StarField Instance { get; private set; } public float CurrentLstDeg => _currentLst; public float Visibility { get; private set; } public static Camera MainCamera { get { if (!((Object)(object)Instance != (Object)null) || !((Object)(object)Instance._mainCam != (Object)null)) { return Camera.main; } return Instance._mainCam; } } public Vector3 PoleWorldDirection => _pole; public static void Create(GameCamera gc) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Instance != (Object)null)) { GameObject val = new GameObject("StarNav_Sky"); StarField starField = val.AddComponent<StarField>(); starField._mainCam = ((Component)gc).GetComponent<Camera>() ?? Camera.main; starField._cam = (((Object)(object)gc.m_skyCamera != (Object)null && ((Component)gc.m_skyCamera).gameObject.activeInHierarchy && ((Behaviour)gc.m_skyCamera).enabled) ? gc.m_skyCamera : starField._mainCam); starField._skyLayer = PickLayer(starField._cam); val.layer = starField._skyLayer; StarNavPlugin.Log.LogInfo((object)$"StarNav using camera '{((Object)starField._cam).name}' (far {starField._cam.farClipPlane:0}), layer {starField._skyLayer} ({LayerMask.LayerToName(starField._skyLayer)})"); } } private static int PickLayer(Camera cam) { int num = (((Object)(object)cam != (Object)null) ? cam.cullingMask : (-1)); int num2 = LayerMask.NameToLayer("skybox"); if (num2 >= 0 && (num & (1 << num2)) != 0) { return num2; } for (int num3 = 31; num3 >= 0; num3--) { if ((num & (1 << num3)) != 0) { return num3; } } return 0; } private void Awake() { Instance = this; } private void Start() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown if ((Object)(object)_cam == (Object)null) { _cam = Camera.main; } Build(); Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnCameraPreCull)); _nextMeteor = Time.time + Random.Range(5f, 20f); _autoDumpAt = -1f; } private void OnDestroy() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnCameraPreCull)); RestoreVanillaStars(); if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void Build() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) float value = StarNavPlugin.LatitudeDeg.Value; _pole = Astronomy.PoleDirection(value); Vector3 val = Astronomy.ToHorizon(0f, 0f, value, 0f); Vector3 val2 = Quaternion.AngleAxis(10f, _pole) * val; _poleSign = ((val2.x < 0f) ? 1 : (-1)); _rot = new GameObject("Celestial").transform; _rot.SetParent(((Component)this).transform, false); ((Component)_rot).gameObject.layer = ((Component)this).gameObject.layer; Shader val3 = FindShader(StarNavPlugin.ShaderName.Value); _starTex = Texture2D.whiteTexture; _meteorTex = Texture2D.whiteTexture; _starMat = MakeMaterial(val3, (Texture)(object)_starTex); _brightMat = MakeMaterial(val3, (Texture)(object)_starTex); _brightMat.renderQueue = 2900; _lineMat = MakeMaterial(val3, (Texture)(object)Texture2D.whiteTexture); _meteorMat = MakeMaterial(val3, (Texture)(object)_meteorTex); float value2 = StarNavPlugin.LimitingMagnitude.Value; List<StarRecord> list = new List<StarRecord>(); List<StarRecord> list2 = new List<StarRecord>(); foreach (StarRecord star in StarCatalog.Stars) { if (!(star.Mag > value2)) { if (star.Mag <= 5f) { list.Add(star); } else { list2.Add(star); } } } _bright = list.ToArray(); _brightChunks = BuildLayer("Stars_Bright", list, value, _brightMat, out _brightDir, out _brightBase); _faintChunks = BuildLayer("Stars_Faint", list2, value, _starMat, out _faintDir, out _faintBase); _brightColors = (Color[])((_brightChunks.Length != 0) ? ((Array)_brightChunks[0].Colors) : ((Array)new Color[0])); _faintColors = (Color[])((_faintChunks.Length != 0) ? ((Array)_faintChunks[0].Colors) : ((Array)new Color[0])); int num = _bright.Length; _twPhase1 = new float[num]; _twPhase2 = new float[num]; _twSpeed1 = new float[num]; _twSpeed2 = new float[num]; _twAmp = new float[num]; _navStar = new bool[num]; Random random = new Random(1234); int num2 = 0; for (int i = 0; i < num; i++) { _navStar[i] = _bright[i].Mag <= StarNavPlugin.DayStarMagnitude.Value || _bright[i].Hip == 11767; if (_navStar[i]) { num2++; } _twPhase1[i] = (float)random.NextDouble() * 6.2832f; _twPhase2[i] = (float)random.NextDouble() * 6.2832f; _twSpeed1[i] = 3f + (float)random.NextDouble() * 6f; _twSpeed2[i] = 9f + (float)random.NextDouble() * 14f; double num3 = random.NextDouble(); _twAmp[i] = ((num3 < 0.33) ? 0.15f : ((num3 < 0.85) ? 0.45f : 1f)); } BuildConstellationLines(value); BuildMeteor(); HideVanillaStars(); StarNavPlugin.Log.LogInfo((object)$"Star field built: {list.Count} bright + {list2.Count} faint stars ({num2} always-visible navigation stars), shader '{((Object)val3).name}', pole sign {_poleSign}"); } private StarChunk[] BuildLayer(string name, List<StarRecord> stars, float lat, Material mat, out Vector3[] dirs, out Color[] baseColors) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) int count = stars.Count; dirs = (Vector3[])(object)new Vector3[count]; baseColors = (Color[])(object)new Color[count]; float value = StarNavPlugin.StarSize.Value; for (int i = 0; i < count; i++) { StarRecord starRecord = stars[i]; dirs[i] = Astronomy.ToHorizon(starRecord.RaDeg, starRecord.DecDeg, lat, 0f); float num = Astronomy.MagnitudeToFlux(starRecord.Mag - 1f); Color val = Astronomy.BVToColor(starRecord.BV); val.a = Mathf.Pow(Mathf.Clamp01(num), 0.55f); baseColors[i] = val; } List<StarChunk> list = new List<StarChunk>(); for (int j = 0; j < count; j += 3000) { int num2 = Mathf.Min(3000, count - j); StarChunk starChunk = new StarChunk { First = j, Count = num2 }; starChunk.Mesh = BuildStarMesh(stars, j, num2, dirs, value, out starChunk.Colors); ((Object)starChunk.Mesh).name = name + "_" + list.Count; MakeRenderer(name + "_" + list.Count, _rot, starChunk.Mesh, mat); list.Add(starChunk); } return list.ToArray(); } private static Mesh BuildStarMesh(List<StarRecord> stars, int first, int n, Vector3[] dirs, float sizeMul, out Color[] colors) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: 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_0166: 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_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[n * 17]; Vector2[] array2 = (Vector2[])(object)new Vector2[n * 17]; for (int i = 0; i < array2.Length; i++) { array2[i] = new Vector2(0.5f, 0.5f); } colors = (Color[])(object)new Color[n * 17]; int[] array3 = new int[n * 24 * 3]; for (int j = 0; j < n; j++) { StarRecord starRecord = stars[first + j]; Vector3 val = dirs[first + j]; float num = Mathf.Tan((0.12f + 0.2f * Mathf.Clamp01((7f - starRecord.Mag) / 5f) + 0.2f * Mathf.Clamp01((1.5f - starRecord.Mag) / 3f)) * sizeMul * 0.5f * ((float)Math.PI / 180f)); float num2 = num * 0.55f; Vector3 val2 = Vector3.Cross((Mathf.Abs(val.y) > 0.98f) ? Vector3.forward : Vector3.up, val); Vector3 normalized = ((Vector3)(ref val2)).normalized; val2 = Vector3.Cross(val, normalized); Vector3 normalized2 = ((Vector3)(ref val2)).normalized; int num3 = j * 17; array[num3] = val; for (int k = 0; k < 8; k++) { float num4 = (float)k * ((float)Math.PI / 4f); Vector3 val3 = normalized * Mathf.Cos(num4) + normalized2 * Mathf.Sin(num4); array[num3 + 1 + k] = val + val3 * num2; array[num3 + 1 + 8 + k] = val + val3 * num; } int num5 = j * 24 * 3; for (int l = 0; l < 8; l++) { int num6 = (l + 1) % 8; int num7 = num3; int num8 = num3 + 1 + l; int num9 = num3 + 1 + num6; int num10 = num3 + 1 + 8 + l; int num11 = num3 + 1 + 8 + num6; array3[num5++] = num7; array3[num5++] = num9; array3[num5++] = num8; array3[num5++] = num8; array3[num5++] = num9; array3[num5++] = num10; array3[num5++] = num9; array3[num5++] = num11; array3[num5++] = num10; } for (int m = 0; m < 17; m++) { colors[num3 + m] = Color.clear; } } Mesh val4 = new Mesh { vertices = array, uv = array2, colors = colors, triangles = array3 }; val4.RecalculateBounds(); return val4; } private static void SetStarColor(Color[] arr, int star, Color col) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0053: 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) int num = star * 17; arr[num] = col; Color val = col; val.a *= 0.9f; for (int i = 0; i < 8; i++) { arr[num + 1 + i] = val; } Color val2 = col; val2.a = 0f; for (int j = 0; j < 8; j++) { arr[num + 1 + 8 + j] = val2; } } private void BuildConstellationLines(float lat) { //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: 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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_017d: 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_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0197: 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_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(); List<int> list2 = new List<int>(); float num = Mathf.Tan(0.0010471975f); foreach (ConstellationLine line in StarCatalog.Lines) { for (int i = 0; i + 1 < line.Points.Length; i++) { Vector3 val = Astronomy.ToHorizon(line.Points[i].x, line.Points[i].y, lat, 0f); Vector3 val2 = Astronomy.ToHorizon(line.Points[i + 1].x, line.Points[i + 1].y, lat, 0f); float num2 = Vector3.Angle(val, val2); int num3 = Mathf.Max(1, Mathf.CeilToInt(num2 / 2f)); float num4 = Mathf.Min(0.25f, num2 * 0.08f) / Mathf.Max(num2, 0.01f); Vector3 val3 = Vector3.Slerp(val, val2, num4); Vector3 val4 = ((Vector3)(ref val3)).normalized; for (int j = 1; j <= num3; j++) { float num5 = Mathf.Lerp(num4, 1f - num4, (float)j / (float)num3); val3 = Vector3.Slerp(val, val2, num5); Vector3 normalized = ((Vector3)(ref val3)).normalized; val3 = val4 + normalized; val3 = Vector3.Cross(((Vector3)(ref val3)).normalized, normalized - val4); Vector3 val5 = ((Vector3)(ref val3)).normalized * num; int count = list.Count; list.Add(val4 - val5); list.Add(val4 + val5); list.Add(normalized + val5); list.Add(normalized - val5); list2.Add(count); list2.Add(count + 1); list2.Add(count + 2); list2.Add(count); list2.Add(count + 2); list2.Add(count + 3); val4 = normalized; } } } Mesh val6 = new Mesh { name = "StarNav_Lines" }; val6.SetVertices(list); Color[] array = (Color[])(object)new Color[list.Count]; for (int k = 0; k < array.Length; k++) { array[k] = Color.white; } val6.colors = array; Vector2[] array2 = (Vector2[])(object)new Vector2[list.Count]; for (int l = 0; l < array2.Length; l++) { array2[l] = new Vector2(0.5f, 0.5f); } val6.uv = array2; val6.SetTriangles(list2, 0); val6.bounds = new Bounds(Vector3.zero, Vector3.one * 2.2f); _lineRenderer = MakeRenderer("Constellations", _rot, val6, _lineMat); ((Renderer)_lineRenderer).enabled = StarNavPlugin.ShowConstellationLines.Value; } private void BuildMeteor() { //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_0016: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) _meteorMesh = new Mesh { name = "StarNav_Meteor" }; _meteorMesh.vertices = (Vector3[])(object)new Vector3[4]; _meteorMesh.uv = (Vector2[])(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(1f, 0f) }; _meteorMesh.colors = (Color[])(object)new Color[4] { Color.clear, Color.clear, Color.white, Color.white }; _meteorMesh.triangles = new int[6] { 0, 1, 2, 0, 2, 3 }; _meteorMesh.bounds = new Bounds(Vector3.zero, Vector3.one * 2.2f); _meteorMesh.MarkDynamic(); _meteorRenderer = MakeRenderer("Meteor", ((Component)this).transform, _meteorMesh, _meteorMat); ((Renderer)_meteorRenderer).enabled = false; } private static MeshRenderer MakeRenderer(string name, Transform parent, Mesh mesh, Material mat) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.layer = ((Component)parent).gameObject.layer; val.AddComponent<MeshFilter>().sharedMesh = mesh; MeshRenderer obj = val.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = mat; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; ((Renderer)obj).lightProbeUsage = (LightProbeUsage)0; ((Renderer)obj).reflectionProbeUsage = (ReflectionProbeUsage)0; ((Renderer)obj).motionVectorGenerationMode = (MotionVectorGenerationMode)2; ((Renderer)obj).allowOcclusionWhenDynamic = false; MaterialPropertyBlock val2 = new MaterialPropertyBlock(); if ((Object)(object)mat.mainTexture != (Object)null) { val2.SetTexture("_MainTex", mat.mainTexture); } val2.SetColor("_RendererColor", Color.white); val2.SetVector("_Flip", new Vector4(1f, 1f, 1f, 1f)); val2.SetFloat("_EnableExternalAlpha", 0f); ((Renderer)obj).SetPropertyBlock(val2); return obj; } private static Material MakeMaterial(Shader shader, Texture tex) { //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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0035: Expected O, but got Unknown Material val = new Material(shader) { name = "StarNav_" + ((Object)shader).name, renderQueue = 2900, mainTexture = tex }; ApplyMaterialDefaults(val); return val; } private static void ApplyMaterialDefaults(Material m) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) if (m.HasProperty("_Color")) { m.color = Color.white; } if (m.HasProperty("_TintColor")) { m.SetColor("_TintColor", new Color(0.5f, 0.5f, 0.5f, 0.5f)); } if (m.HasProperty("_FejdFog")) { m.SetFloat("_FejdFog", 0f); } if (m.HasProperty("_SoftParticles")) { m.SetFloat("_SoftParticles", 0f); } if (m.HasProperty("_CameraFadeFactor")) { m.SetFloat("_CameraFadeFactor", 0f); } if (m.HasProperty("_SkyMask")) { m.SetFloat("_SkyMask", 0f); } if (m.HasProperty("_SrcBlend")) { m.SetInt("_SrcBlend", 5); } if (m.HasProperty("_DstBlend")) { m.SetInt("_DstBlend", 1); } if (m.HasProperty("_Cull")) { m.SetInt("_Cull", 0); } if (m.HasProperty("_ZWrite")) { m.SetInt("_ZWrite", 0); } if (m.HasProperty("_RendererColor")) { m.SetColor("_RendererColor", Color.white); } if (m.HasProperty("_Flip")) { m.SetVector("_Flip", new Vector4(1f, 1f, 1f, 1f)); } } public void RebuildStars() { float value = StarNavPlugin.LatitudeDeg.Value; float value2 = StarNavPlugin.LimitingMagnitude.Value; List<StarRecord> list = new List<StarRecord>(); List<StarRecord> list2 = new List<StarRecord>(); foreach (StarRecord star in StarCatalog.Stars) { if (!(star.Mag > value2)) { if (star.Mag <= 5f) { list.Add(star); } else { list2.Add(star); } } } if (list.Count != _bright.Length) { return; } MeshFilter[] componentsInChildren = ((Component)this).GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val in componentsInChildren) { if (((Object)val).name.StartsWith("Stars_", StringComparison.Ordinal)) { Object.Destroy((Object)(object)val.sharedMesh); Object.Destroy((Object)(object)((Component)val).gameObject); } } _brightChunks = BuildLayer("Stars_Bright", list, value, _brightMat, out _brightDir, out _brightBase); _faintChunks = BuildLayer("Stars_Faint", list2, value, _starMat, out _faintDir, out _faintBase); _brightColors = (Color[])((_brightChunks.Length != 0) ? ((Array)_brightChunks[0].Colors) : ((Array)new Color[0])); _faintColors = (Color[])((_faintChunks.Length != 0) ? ((Array)_faintChunks[0].Colors) : ((Array)new Color[0])); _faintCursor = 0; } public void SetQueue(int q) { Material[] array = (Material[])(object)new Material[4] { _starMat, _brightMat, _lineMat, _meteorMat }; foreach (Material val in array) { if ((Object)(object)val != (Object)null) { val.renderQueue = q; } } } public string SetShader(string name) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) Shader val = FindShader(name); Material[] array = (Material[])(object)new Material[4] { _starMat, _brightMat, _lineMat, _meteorMat }; foreach (Material val2 in array) { if (!((Object)(object)val2 == (Object)null)) { int renderQueue = val2.renderQueue; Texture mainTexture = val2.mainTexture; val2.shader = val; val2.mainTexture = mainTexture; ApplyMaterialDefaults(val2); val2.renderQueue = renderQueue; } } Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true); foreach (Renderer val3 in componentsInChildren) { MaterialPropertyBlock val4 = new MaterialPropertyBlock(); val3.GetPropertyBlock(val4); if ((Object)(object)val3.sharedMaterial != (Object)null && (Object)(object)val3.sharedMaterial.mainTexture != (Object)null) { val4.SetTexture("_MainTex", val3.sharedMaterial.mainTexture); } val4.SetColor("_RendererColor", Color.white); val4.SetVector("_Flip", new Vector4(1f, 1f, 1f, 1f)); val3.SetPropertyBlock(val4); } StarNavPlugin.ShaderName.Value = ((Object)val).name; return ((Object)val).name; } private static Shader FindShader(string preferred) { string[] obj = new string[6] { preferred, "Sprites/Default", "Custom/Particle (Unlit)", "Legacy Shaders/Particles/Additive", "Particles/Standard Unlit", "UI/Default" }; Shader[] array = null; string[] array2 = obj; foreach (string text in array2) { if (string.IsNullOrEmpty(text)) { continue; } Shader val = Shader.Find(text); if ((Object)(object)val == (Object)null) { array = array ?? Resources.FindObjectsOfTypeAll<Shader>(); Shader[] array3 = array; foreach (Shader val2 in array3) { if (((Object)val2).name == text) { val = val2; break; } } } if ((Object)(object)val != (Object)null) { if (text != preferred) { StarNavPlugin.Log.LogWarning((object)("Shader '" + preferred + "' not found, using '" + text + "'")); } return val; } } StarNavPlugin.Log.LogError((object)"No usable shader found for stars; falling back to error shader"); return Shader.Find("Hidden/InternalErrorShader"); } private static Texture2D MakeStarTexture(int size) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_00c4: 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) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { name = "StarNav_StarDot", wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; Color[] array = (Color[])(object)new Color[size * size]; float num = (float)(size - 1) * 0.5f; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num2 = Mathf.Sqrt(((float)j - num) * ((float)j - num) + ((float)i - num) * ((float)i - num)) / num; float num3 = Mathf.Exp((0f - num2) * num2 * 9f); float num4 = Mathf.Exp((0f - num2) * num2 * 2.5f) * 0.3f; float num5 = Mathf.Clamp01(num3 + num4) * Mathf.Clamp01((1f - num2) * 6f); array[i * size + j] = new Color(1f, 1f, 1f, num5); } } val.SetPixels(array); val.Apply(false, true); return val; } private static Texture2D MakeMeteorTexture(int w, int h) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(w, h, (TextureFormat)4, false) { name = "StarNav_Meteor", wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; Color[] array = (Color[])(object)new Color[w * h]; for (int i = 0; i < h; i++) { float num = Mathf.Abs(((float)i + 0.5f) / (float)h - 0.5f) * 2f; float num2 = Mathf.Exp((0f - num) * num * 5f); for (int j = 0; j < w; j++) { float num3 = ((float)j + 0.5f) / (float)w; float num4 = Mathf.Pow(num3, 2.2f); float num5 = Mathf.Exp((0f - (1f - num3)) * (1f - num3) * 400f) * 1.5f; float a = Mathf.Clamp01((num4 * 0.9f + num5) * num2); Color val2 = Color.Lerp(new Color(0.65f, 1f, 0.85f), Color.white, num3); val2.a = a; array[i * w + j] = val2; } } val.SetPixels(array); val.Apply(false, true); return val; } private void HideVanillaStars() { if (!StarNavPlugin.HideVanillaStars.Value) { return; } Material val = null; Skybox val2 = (((Object)(object)_cam != (Object)null) ? ((Component)_cam).GetComponent<Skybox>() : null); if ((Object)(object)val2 != (Object)null && (Object)(object)val2.material != (Object)null) { val = val2.material; } if ((Object)(object)val == (Object)null && (Object)(object)_mainCam != (Object)null) { val2 = ((Component)_mainCam).G