using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BoneLib; using BoneLib.BoneMenu; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSLZ.Marrow; using Il2CppSLZ.Marrow.Data; using Il2CppTMPro; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using NeonMag; using NeonMag.Ammo; using NeonMag.Config; using NeonMag.Hud; using NeonMag.Menu; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("NeonMag")] [assembly: AssemblyDescription("Cyberpunk holographic ammo readout for every firearm.")] [assembly: AssemblyCompany(null)] [assembly: AssemblyProduct("NeonMag")] [assembly: AssemblyFileVersion("1.2.0")] [assembly: MelonInfo(typeof(NeonMagMod), "NeonMag", "1.2.0", "Rocner", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: MelonColor(255, 0, 235, 255)] [assembly: MelonAuthorColor(255, 255, 40, 155)] [assembly: MelonAdditionalDependencies(new string[] { "BoneLib" })] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyVersion("1.2.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace NeonMag { public sealed class NeonMagMod : MelonMod { private static bool _levelReady; private static float _retry; public override void OnInitializeMelon() { Step("preferences", Prefs.Load); Step("menu", MenuPage.Build); Step("hooks", delegate { Hooking.OnLevelLoaded += OnLevelLoaded; }); Step("unload-hook", delegate { Hooking.OnLevelUnloaded += OnLevelUnloaded; }); ((MelonBase)this).LoggerInstance.Msg("NeonMag ready."); } private void Step(string name, Action action) { try { action(); } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Error("Init step '" + name + "' failed: " + ex); } } private static void OnLevelLoaded(LevelInfo info) { _levelReady = true; _retry = 0f; AmmoReader.Forget(); } private static void OnLevelUnloaded() { _levelReady = false; AmmoReader.Forget(); NeonHud.Destroy(); } public override void OnUpdate() { try { Run(); } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Error("Update failed: " + ex); } } private static void Run() { float deltaTime = Time.deltaTime; if (deltaTime <= 0f) { return; } if (!Prefs.Enabled) { if (NeonHud.Exists) { NeonHud.Feed(found: false, default(AmmoSnapshot)); NeonHud.Tick(deltaTime); } return; } if (!NeonHud.Exists) { _retry -= deltaTime; if (_retry > 0f) { return; } _retry = 0.5f; if (!_levelReady || (Object)(object)Player.Head == (Object)null) { return; } NeonHud.Build(); if (!NeonHud.Exists) { return; } } NeonHud.Feed(AmmoReader.TryResolve(out var snapshot), snapshot); NeonHud.Tick(deltaTime); } public override void OnDeinitializeMelon() { try { Hooking.OnLevelLoaded -= OnLevelLoaded; } catch { } try { Hooking.OnLevelUnloaded -= OnLevelUnloaded; } catch { } try { NeonHud.Destroy(); } catch { } try { NeonTheme.Reset(); } catch { } try { Prefs.Save(); } catch { } } } internal static class BuildInfo { public const string Name = "NeonMag"; public const string Description = "Cyberpunk holographic ammo readout for every firearm."; public const string Author = "Rocner"; public const string Company = null; public const string Version = "1.2.0"; } } namespace NeonMag.Menu { internal static class MenuPage { private static readonly Color Accent = new Color(0f, 0.92f, 1f); public static void Build() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) Page root; try { root = Page.Root.CreatePage("NeonMag", Accent, 0, true); } catch (Exception ex) { Melon.Logger.Error("BoneMenu root page failed: " + ex); return; } Section("display", delegate { BuildDisplaySection(root); }); Section("style", delegate { BuildStylePage(root); }); Section("placement", delegate { BuildPlacementPage(root); }); Section("readouts", delegate { BuildReadoutPage(root); }); } private static void Section(string name, Action build) { try { build(); } catch (Exception ex) { Melon.Logger.Error("BoneMenu section '" + name + "' failed: " + ex); } } private static void BuildDisplaySection(Page root) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) root.CreateBool("Enabled", Accent, Prefs.Enabled, (Action)delegate(bool value) { Prefs.Enabled = value; Prefs.Save(); }); root.CreateFloat("Scale", Accent, Prefs.Scale, 0.05f, 0.35f, 3f, (Action)delegate(float value) { Prefs.Scale = value; Prefs.Save(); }); root.CreateFloat("Opacity", Accent, Prefs.Opacity, 0.05f, 0.15f, 1f, (Action)delegate(float value) { Prefs.Opacity = value; Prefs.Save(); }); } private static void BuildStylePage(Page root) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_00c9: Unknown result type (might be due to invalid IL or missing references) Page obj = root.CreatePage("Style", Accent, 0, true); obj.CreateInt("Palette", Accent, Prefs.Palette, 1, 0, NeonTheme.PaletteCount - 1, (Action)delegate(int value) { Prefs.Palette = value; Prefs.Save(); Melon.Logger.Msg("Palette: " + NeonTheme.PaletteName(value)); }); obj.CreateFunction("Cycle Palette", Accent, (Action)delegate { int index = (Prefs.Palette = (Prefs.Palette + 1) % NeonTheme.PaletteCount); Prefs.Save(); Melon.Logger.Msg("Palette: " + NeonTheme.PaletteName(index)); }); obj.CreateFloat("Glitch Intensity", Accent, Prefs.Glitch, 0.05f, 0f, 1f, (Action)delegate(float value) { Prefs.Glitch = value; Prefs.Save(); }); obj.CreateBool("Scanline Sweep", Accent, Prefs.Sweep, (Action)delegate(bool value) { Prefs.Sweep = value; Prefs.Save(); }); } private static void BuildPlacementPage(Page root) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) Page obj = root.CreatePage("Placement", Accent, 0, true); obj.CreateFloat("Offset X", Accent, Prefs.OffsetX, 0.005f, -0.4f, 0.4f, (Action)delegate(float value) { Prefs.OffsetX = value; Prefs.Save(); }); obj.CreateFloat("Offset Y", Accent, Prefs.OffsetY, 0.005f, -0.4f, 0.4f, (Action)delegate(float value) { Prefs.OffsetY = value; Prefs.Save(); }); obj.CreateFloat("Offset Z", Accent, Prefs.OffsetZ, 0.005f, -0.4f, 0.4f, (Action)delegate(float value) { Prefs.OffsetZ = value; Prefs.Save(); }); obj.CreateBool("Face Player", Accent, Prefs.Billboard, (Action)delegate(bool value) { Prefs.Billboard = value; Prefs.Save(); }); obj.CreateFunction("Reset Offset", Accent, (Action)delegate { Prefs.OffsetX = 0.105f; Prefs.OffsetY = 0.035f; Prefs.OffsetZ = 0f; Prefs.Save(); }); } private static void BuildReadoutPage(Page root) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) Page obj = root.CreatePage("Readouts", Accent, 0, true); obj.CreateBool("Round Segments", Accent, Prefs.Segments, (Action)delegate(bool value) { Prefs.Segments = value; Prefs.Save(); }); obj.CreateBool("Reserve Count", Accent, Prefs.Reserve, (Action)delegate(bool value) { Prefs.Reserve = value; Prefs.Save(); }); obj.CreateBool("Fire Mode", Accent, Prefs.FireMode, (Action)delegate(bool value) { Prefs.FireMode = value; Prefs.Save(); }); obj.CreateBool("Show On Loose Magazines", Accent, Prefs.Magazines, (Action)delegate(bool value) { Prefs.Magazines = value; Prefs.Save(); }); obj.CreateBool("Fade Detail When Idle", Accent, Prefs.AutoFade, (Action)delegate(bool value) { Prefs.AutoFade = value; Prefs.Save(); }); } } } namespace NeonMag.Hud { internal static class Ease { public static float OutCubic(float t) { t = Mathf.Clamp01(t); float num = 1f - t; return 1f - num * num * num; } public static float OutExpo(float t) { t = Mathf.Clamp01(t); if (!(t >= 1f)) { return 1f - Mathf.Pow(2f, -10f * t); } return 1f; } public static float OutBack(float t) { t = Mathf.Clamp01(t); float num = t - 1f; return 1f + 2.70158f * num * num * num + 1.70158f * num * num; } public static float InOutQuad(float t) { t = Mathf.Clamp01(t); if (!(t < 0.5f)) { return 1f - Mathf.Pow(-2f * t + 2f, 2f) * 0.5f; } return 2f * t * t; } public static float Pulse(float time, float rate) { return 0.5f + 0.5f * Mathf.Sin(time * rate * (float)Math.PI * 2f); } public static float Hash(float seed) { float num = Mathf.Sin(seed * 127.1f) * 43758.547f; return num - Mathf.Floor(num); } } internal sealed class NeonPiece { public GameObject Root; public Renderer Renderer; public Material Material; public void SetActive(bool active) { if ((Object)(object)Root != (Object)null && Root.activeSelf != active) { Root.SetActive(active); } } public void Tint(Color color) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) NeonTheme.Tint(Material, color); } public void Place(Vector3 localPosition, Vector2 size) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Root == (Object)null)) { Root.transform.localPosition = localPosition; Root.transform.localScale = new Vector3(size.x, size.y, 1f); } } } internal static class NeonHud { private const float PanelW = 0.156f; private const float PanelH = 0.092f; private const float HeaderY = 0.0345f; private const float NumberY = 0.0055f; private const float MaxY = -0.0015f; private const float BarY = -0.023f; private const float FootY = -0.0372f; private const float ZShadow = 0.011f; private const float ZHalo = 0.008f; private const float ZFill = 0f; private const float ZEdge = -0.0012f; private const float ZBloom = -0.0018f; private const float ZBars = -0.003f; private const float ZRail = -0.0034f; private const float ZTicks = -0.0052f; private const float ZSheen = -0.006f; private const float ZSweep = -0.0066f; private const float ZSecond = -0.0075f; private const float ZMax = -0.009f; private const float ZGhostA = -0.0112f; private const float ZGhostB = -0.0116f; private const float ZCore = -0.0122f; private const float ZBracket = -0.014f; private const float ZTear = -0.0165f; private const float RailW = 0.14f; private const float TickH = 0.0092f; private const float TickGap = 0.0021f; private const int MaxTicks = 40; private static GameObject _root; private static Transform _scaler; private static Transform _warp; private static NeonPiece _shadow; private static NeonPiece _glow; private static NeonPiece _bloom; private static NeonPiece _sheen; private static NeonPiece _fill; private static NeonPiece _edge; private static NeonPiece _headerBar; private static NeonPiece _footBar; private static NeonPiece _rail; private static NeonPiece _sweep; private static NeonPiece _tear; private static readonly List Brackets = new List(); private static readonly List Ticks = new List(); private static readonly float[] TickLit = new float[40]; private static readonly float[] TickFlash = new float[40]; private static Transform _countRoot; private static TextMeshPro _countGhostA; private static TextMeshPro _countGhostB; private static TextMeshPro _countCore; private static TextMeshPro _max; private static TextMeshPro _platform; private static TextMeshPro _fireMode; private static TextMeshPro _reserve; private static TextMeshPro _cartridge; private static readonly List TextMaterials = new List(); private static AmmoSnapshot _current; private static bool _hasSource; private static bool _wantVisible; private static float _alive; private static float _glitch; private static float _kick; private static float _reload; private static float _sweepPhase; private static float _tearSeed; private static float _detail = 1f; private static float _detailHold = 3.5f; private static int _lastCount = -1; private static int _lastMax = -1; public static bool Exists => (Object)(object)_root != (Object)null; public static void Build() { if ((Object)(object)_root != (Object)null) { return; } try { Assemble(); } catch (Exception ex) { Melon.Logger.Error("Readout build failed: " + ex); Destroy(); } } private static void Assemble() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0154: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: 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_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0266: 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_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) _root = new GameObject("NeonMagHud"); Object.DontDestroyOnLoad((Object)(object)_root); GameObject val = new GameObject("Scaler"); val.transform.SetParent(_root.transform, false); _scaler = val.transform; GameObject val2 = new GameObject("Warp"); val2.transform.SetParent(_scaler, false); _warp = val2.transform; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.156f, 0.092f); _shadow = Quad("Shadow", val3, 0.011f, 3994, NeonTextures.Fill(val3)); _shadow.Root.transform.localPosition = new Vector3(0.005f, -0.005f, 0.011f); Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(0.174f, 0.11f); _glow = Quad("Glow", val4, 0.008f, 3996, NeonTextures.Halo(val4, val3)); _fill = Quad("Fill", val3, 0f, 4000, NeonTextures.Fill(val3)); _edge = Quad("Edge", val3, -0.0012f, 4002, NeonTextures.Edge(val3)); Vector2 val5 = default(Vector2); ((Vector2)(ref val5))..ctor(0.163f, 0.099f); _bloom = Quad("Bloom", val5, -0.0018f, 4003, NeonTextures.Halo(val5, val3)); _sheen = Quad("Sheen", val3, -0.006f, 4007, NeonTextures.Sheen(val3)); _headerBar = Quad("HeaderBar", new Vector2(0.146f, 0.0125f), -0.0008f, 4004, NeonTextures.Slab(new Vector2(0.146f, 0.0125f))); _headerBar.Place(new Vector3(0f, 0.0345f, -0.003f), new Vector2(0.146f, 0.0125f)); _footBar = Quad("FootBar", new Vector2(0.146f, 0.01f), -0.0008f, 4004, NeonTextures.Slab(new Vector2(0.146f, 0.01f))); _footBar.Place(new Vector3(0f, -0.0372f, -0.003f), new Vector2(0.146f, 0.01f)); _rail = Quad("Rail", new Vector2(0.14f, 0.0092f), -0.0009f, 4004, NeonTextures.Solid()); _rail.Place(new Vector3(0f, -0.023f, -0.0034f), new Vector2(0.14f, 0.0092f)); _sweep = Quad("Sweep", new Vector2(0.15f, 0.02f), -0.0066f, 4008, NeonTextures.Sweep()); _tear = Quad("Tear", new Vector2(0.156f, 0.006f), -0.0165f, 4014, NeonTextures.Solid()); _tear.SetActive(active: false); BuildBrackets(); BuildTicks(); BuildTexts(); _root.SetActive(false); } private static void BuildBrackets() { //IL_0012: 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) float num = 0.0355f; AddBracket(new Vector3(0.0675f, num, -0.014f), -90f); AddBracket(new Vector3(0f - 0.0675f, 0f - num, -0.014f), 90f); } private static void AddBracket(Vector3 position, float angle) { //IL_000f: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) NeonPiece neonPiece = Quad("Bracket", new Vector2(0.021f, 0.021f), position.z, 4005, NeonTextures.Bracket()); neonPiece.Root.transform.localPosition = position; neonPiece.Root.transform.localRotation = Quaternion.Euler(0f, 0f, angle); Brackets.Add(neonPiece); } private static void BuildTicks() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 40; i++) { NeonPiece neonPiece = Quad("Tick" + i, new Vector2(0.002f, 0.0092f), -0.0052f, 4006, NeonTextures.Tick()); neonPiece.SetActive(active: false); Ticks.Add(neonPiece); } } private static void BuildTexts() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_013e: 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_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_024c: 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) GameObject val = new GameObject("Count"); val.transform.SetParent(_warp, false); val.transform.localPosition = new Vector3(-0.028f, 0.0055f, 0f); _countRoot = val.transform; Vector2 size = default(Vector2); ((Vector2)(ref size))..ctor(0.07f, 0.038f); _countGhostA = Text(_countRoot, "GhostA", size, 0.0365f, (TextAlignmentOptions)516, -0.0112f, 4009); _countGhostB = Text(_countRoot, "GhostB", size, 0.0365f, (TextAlignmentOptions)516, -0.0116f, 4010); _countCore = Text(_countRoot, "Core", size, 0.0365f, (TextAlignmentOptions)516, -0.0122f, 4012); _max = Text(_warp, "Max", new Vector2(0.048f, 0.017f), 0.014f, (TextAlignmentOptions)513, -0.009f, 4012); ((Transform)((TMP_Text)_max).rectTransform).localPosition = new Vector3(0.04f, -0.0015f, -0.009f); _platform = Text(_warp, "Platform", new Vector2(0.061f, 0.013f), 0.0092f, (TextAlignmentOptions)513, -0.0075f, 4012); ((Transform)((TMP_Text)_platform).rectTransform).localPosition = new Vector3(-0.0335f, 0.0345f, -0.0075f); _fireMode = Text(_warp, "FireMode", new Vector2(0.061f, 0.013f), 0.0092f, (TextAlignmentOptions)516, -0.0075f, 4012); ((Transform)((TMP_Text)_fireMode).rectTransform).localPosition = new Vector3(0.0335f, 0.0345f, -0.0075f); _reserve = Text(_warp, "Reserve", new Vector2(0.061f, 0.011f), 0.008f, (TextAlignmentOptions)513, -0.0075f, 4012); ((Transform)((TMP_Text)_reserve).rectTransform).localPosition = new Vector3(-0.0335f, -0.0372f, -0.0075f); _cartridge = Text(_warp, "Cartridge", new Vector2(0.061f, 0.011f), 0.008f, (TextAlignmentOptions)516, -0.0075f, 4012); ((Transform)((TMP_Text)_cartridge).rectTransform).localPosition = new Vector3(0.0335f, -0.0372f, -0.0075f); } private static NeonPiece Quad(string name, Vector2 size, float depth, int queue, Texture2D texture) { //IL_0030: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)val).name = name; val.transform.SetParent(_warp, false); val.transform.localPosition = new Vector3(0f, 0f, depth); val.transform.localRotation = Quaternion.identity; val.transform.localScale = new Vector3(size.x, size.y, 1f); Collider component = val.GetComponent(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } Renderer component2 = val.GetComponent(); Material material = (component2.material = NeonTheme.CreateMaterial(Color.white, texture, queue)); component2.shadowCastingMode = (ShadowCastingMode)0; component2.receiveShadows = false; return new NeonPiece { Root = val, Renderer = component2, Material = material }; } private static TextMeshPro Text(Transform parent, string name, Vector2 size, float worldHeight, TextAlignmentOptions alignment, float depth, int queue) { //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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_00a1: 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) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); TextMeshPro val2 = val.AddComponent(); ((TMP_Text)val2).font = NeonTheme.Font; NeonTheme.Calibrate((TMP_Text)(object)val2); RectTransform rectTransform = ((TMP_Text)val2).rectTransform; ((Transform)rectTransform).localPosition = new Vector3(0f, 0f, depth); ((Transform)rectTransform).localRotation = Quaternion.identity; ((Transform)rectTransform).localScale = Vector3.one; rectTransform.sizeDelta = size; ((TMP_Text)val2).fontSize = NeonTheme.FontSizeFor(worldHeight); ((TMP_Text)val2).alignment = alignment; ((TMP_Text)val2).enableWordWrapping = false; ((TMP_Text)val2).overflowMode = (TextOverflowModes)0; ((TMP_Text)val2).richText = false; ((TMP_Text)val2).margin = new Vector4(0.002f, 0f, 0.002f, 0f); ((TMP_Text)val2).characterSpacing = 4f; ((TMP_Text)val2).text = string.Empty; ((Graphic)val2).color = Color.white; try { Material fontMaterial = ((TMP_Text)val2).fontMaterial; if ((Object)(object)fontMaterial != (Object)null) { TextMaterials.Add(fontMaterial); if (fontMaterial.HasProperty("_ZTestMode")) { fontMaterial.SetFloat("_ZTestMode", 8f); } if (fontMaterial.HasProperty("_ZTest")) { fontMaterial.SetFloat("_ZTest", 8f); } fontMaterial.renderQueue = queue; } } catch { } return val2; } public static void Feed(bool found, AmmoSnapshot snapshot) { if (!found || !Prefs.Enabled) { _wantVisible = false; return; } bool flag = !_hasSource || !_current.SameSource(snapshot); if (flag) { _alive = 0f; _lastCount = -1; _lastMax = -1; _reload = 1f; _detailHold = 3.5f; _detail = 1f; for (int i = 0; i < 40; i++) { TickLit[i] = 0f; TickFlash[i] = 0f; } } if (_lastMax >= 0 && snapshot.Max != _lastMax) { _glitch = 1f; _detailHold = 3.5f; } if (_lastCount >= 0 && snapshot.Count != _lastCount) { _glitch = 1f; _detailHold = 3.5f; _tearSeed = Ease.Hash((float)snapshot.Count * 3.7f + (float)snapshot.Max * 1.3f); if (snapshot.Count < _lastCount) { _kick = 1f; } else if (snapshot.Count - _lastCount > 1) { _reload = 0f; } } _lastCount = snapshot.Count; _lastMax = snapshot.Max; _current = snapshot; _hasSource = true; _wantVisible = true; if (flag) { Snap(); } } private static void Snap() { //IL_002a: 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_004d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_root == (Object)null) && !((Object)(object)_current.Anchor == (Object)null)) { _root.transform.position = TargetPosition(); _root.transform.rotation = TargetRotation(_root.transform.position); } } private static Vector3 TargetPosition() { //IL_000c: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) Transform anchor = _current.Anchor; return anchor.position + anchor.rotation * Prefs.Offset; } private static Quaternion TargetRotation(Vector3 position) { //IL_0044: 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_0050: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (!Prefs.Billboard) { if (!((Object)(object)_current.Anchor != (Object)null)) { return Quaternion.identity; } return _current.Anchor.rotation; } Transform head = Player.Head; if ((Object)(object)head == (Object)null) { return Quaternion.identity; } Vector3 val = position - head.position; if (((Vector3)(ref val)).sqrMagnitude < 1E-06f) { return Quaternion.identity; } return Quaternion.LookRotation(val, Vector3.up); } public static void Tick(float dt) { //IL_017e: 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_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_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_root == (Object)null) { return; } bool flag = _wantVisible && _hasSource && (Object)(object)_current.Anchor != (Object)null; _alive = Mathf.MoveTowards(_alive, flag ? 1f : 0f, dt * (flag ? 4.6f : 7.5f)); if (_alive <= 0.0001f) { if (_root.activeSelf) { _root.SetActive(false); } if (!flag) { _hasSource = false; } return; } if (!_root.activeSelf) { _root.SetActive(true); } _glitch = Mathf.MoveTowards(_glitch, 0f, dt * 3.4f); _kick = Mathf.MoveTowards(_kick, 0f, dt * 3.2f); _reload = Mathf.MoveTowards(_reload, 1f, dt * 2.2f); _sweepPhase = Mathf.Repeat(_sweepPhase + dt * 0.32f, 1f); if (Prefs.AutoFade) { _detailHold = Mathf.Max(0f, _detailHold - dt); _detail = Mathf.MoveTowards(_detail, (_detailHold > 0f) ? 1f : 0f, dt * 1.9f); } else { _detail = Mathf.MoveTowards(_detail, 1f, dt * 3f); } if (flag) { Vector3 val = TargetPosition(); Quaternion val2 = TargetRotation(_root.transform.position); float num = 1f - Mathf.Exp(-16f * dt); float num2 = 1f - Mathf.Exp(-13f * dt); _root.transform.position = Vector3.Lerp(_root.transform.position, val, num); _root.transform.rotation = Quaternion.Slerp(_root.transform.rotation, val2, num2); } ApplyWarp(); ApplyText(); ApplyColors(dt); } private static void ApplyWarp() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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) float scale = Prefs.Scale; _scaler.localScale = new Vector3(scale, scale, scale); float num = Mathf.Max(0.002f, Ease.OutExpo(Mathf.Clamp01(_alive / 0.4f))); float num2 = Mathf.Max(0.002f, Ease.OutBack(Mathf.Clamp01((_alive - 0.22f) / 0.78f))); float num3 = _glitch * _glitch * Prefs.Glitch; float num4 = (Ease.Hash(_tearSeed + Mathf.Floor(Time.time * 34f)) - 0.5f) * 0.01f * num3; _warp.localScale = new Vector3(num, num2, 1f); _warp.localPosition = new Vector3(num4, 0f, 0f); } private static void ApplyText() { //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) bool flag = _current.NoMagazine && !_current.Chambered; ((TMP_Text)_countCore).text = (flag ? "--" : _current.Count.ToString()); ((TMP_Text)_countGhostA).text = ((TMP_Text)_countCore).text; ((TMP_Text)_countGhostB).text = ((TMP_Text)_countCore).text; ((TMP_Text)_max).text = (flag ? "/ --" : ("/ " + _current.Max)); ((TMP_Text)_platform).text = (_current.NoMagazine ? "NO MAG" : _current.Platform); ((TMP_Text)_fireMode).text = (Prefs.FireMode ? (_current.FireMode ?? string.Empty) : string.Empty); ((TMP_Text)_reserve).text = ((_current.Reserve >= 0) ? ("RSV " + _current.Reserve) : string.Empty); ((TMP_Text)_cartridge).text = _current.Cartridge ?? string.Empty; float num = 0.2f * _kick * Mathf.Cos(_kick * 8.4f); _countRoot.localScale = Vector3.one * (1f + num); float num2 = (0.0009f + 0.0032f * _glitch) * Mathf.Lerp(0.3f, 1f, Prefs.Glitch); ((Transform)((TMP_Text)_countGhostA).rectTransform).localPosition = new Vector3(0f - num2, num2 * 0.42f, -0.0112f); ((Transform)((TMP_Text)_countGhostB).rectTransform).localPosition = new Vector3(num2, (0f - num2) * 0.42f, -0.0116f); } private static void ApplyColors(float dt) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_0148: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_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_0203: 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_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0252: 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_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035a: 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_0383: Unknown result type (might be due to invalid IL or missing references) float num = Ease.OutCubic(Mathf.Clamp01(_alive * 1.4f)); float num2 = 0.9f + 0.1f * Ease.Hash(Mathf.Floor(Time.time * 24f) * 1.13f); float num3 = num * Prefs.Opacity * num2; float ratio = _current.Ratio; float num4 = NeonTheme.Severity(_current.Count, ratio); Color val = NeonTheme.StateColor(num4); Color accent = NeonTheme.Accent; float num5 = ((num4 <= 0.0001f) ? 1f : ((num4 < 0.24f) ? 0.6f : 0f)); if (num5 > 0f) { float num6 = Ease.Pulse(Time.time, 2.8f + num5); val = Color.Lerp(val, NeonTheme.Bright, num6 * 0.28f * num5); num3 *= Mathf.Lerp(1f, 0.72f + 0.28f * num6, num5); } float num7 = Mathf.Clamp01(_detail); Fade(_shadow, NeonTheme.Shadow, 1f, num3); Fade(_glow, val, 0.1f, num3); Fade(_bloom, val, 0.17f, num3); Fade(_fill, NeonTheme.Backplate, 1f, num3); Fade(_edge, val, 0.95f, num3); Fade(_headerBar, val, 0.24f, num3 * Mathf.Lerp(0.25f, 1f, num7)); Fade(_footBar, val, 0.15f, num3 * Mathf.Lerp(0.25f, 1f, num7)); Fade(_rail, val, 0.1f, num3); Color color = Color.Lerp(val, NeonTheme.Bright, 0.55f); color.a = num3 * (0.035f + 0.02f * Ease.Pulse(Time.time, 0.13f)); _sheen.Tint(color); for (int i = 0; i < Brackets.Count; i++) { Fade(Brackets[i], accent, 0.85f, num3); } ApplySweep(val, num3); ApplyTear(accent, num3); ApplyTicks(dt, val, num3); Color color2 = Color.Lerp(NeonTheme.Bright, val, 0.25f + 0.45f * num5); color2.a = num3; ((Graphic)_countCore).color = color2; Color color3 = val; color3.a = num3 * (0.55f + 0.35f * _glitch); ((Graphic)_countGhostA).color = color3; Color color4 = accent; color4.a = num3 * (0.5f + 0.4f * _glitch); ((Graphic)_countGhostB).color = color4; Color color5 = val; color5.a = num3 * 0.9f; ((Graphic)_max).color = color5; Color color6 = val; color6.a = num3 * 0.9f * Mathf.Lerp(0.32f, 1f, num7); ((Graphic)_platform).color = color6; Color color7 = Color.Lerp(val, NeonTheme.Bright, 0.15f); color7.a = num3 * 0.72f * Mathf.Lerp(0.32f, 1f, num7); ((Graphic)_reserve).color = color7; ((Graphic)_cartridge).color = color7; Color color8 = accent; color8.a = num3 * 0.88f * Mathf.Lerp(0.32f, 1f, num7); ((Graphic)_fireMode).color = color8; } private static void ApplySweep(Color state, float alpha) { //IL_004d: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) if (!Prefs.Sweep) { _sweep.SetActive(active: false); return; } _sweep.SetActive(active: true); float num = Mathf.Lerp(0.046f, -0.046f, _sweepPhase); _sweep.Root.transform.localPosition = new Vector3(0f, num, -0.0066f); Color color = Color.Lerp(state, NeonTheme.Bright, 0.35f); color.a = alpha * 0.22f * Mathf.Sin(_sweepPhase * (float)Math.PI); _sweep.Tint(color); } private static void ApplyTear(Color accent, float alpha) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_0092: 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_00c2: Unknown result type (might be due to invalid IL or missing references) bool flag = _glitch > 0.12f && Prefs.Glitch > 0.05f; _tear.SetActive(flag); if (flag) { float num = 1f - _glitch; float num2 = Mathf.Lerp(0.046f, -0.046f, num) + (_tearSeed - 0.5f) * 0.02f; float num3 = 0.003f + 0.011f * _glitch; _tear.Place(new Vector3(0f, num2, -0.0165f), new Vector2(0.156f, num3)); Color color = Color.Lerp(accent, NeonTheme.Bright, 0.4f); color.a = alpha * 0.55f * _glitch * Prefs.Glitch; _tear.Tint(color); } } private static void ApplyTicks(float dt, Color state, float alpha) { //IL_00c8: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0167: 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_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_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) if (!Prefs.Segments || (_current.NoMagazine && !_current.Chambered)) { HideTicks(); return; } int num = Mathf.Max(1, _current.Max); int num2 = Mathf.Min(num, 40); float num3 = (0.14f - (float)(num2 - 1) * 0.0021f) / (float)num2; float num4 = -0.07f + num3 * 0.5f; float num5 = (float)num / (float)num2; float num6 = (float)_current.Count / num5 * Ease.OutCubic(_reload); for (int i = 0; i < 40; i++) { NeonPiece neonPiece = Ticks[i]; if (i >= num2) { neonPiece.SetActive(active: false); continue; } neonPiece.SetActive(active: true); neonPiece.Place(new Vector3(num4 + (float)i * (num3 + 0.0021f), -0.023f, -0.0052f), new Vector2(num3, 0.0092f)); float num7 = Mathf.Clamp01(num6 - (float)i); if (num7 < 0.5f && TickLit[i] > 0.5f) { TickFlash[i] = 1f; } TickLit[i] = Mathf.MoveTowards(TickLit[i], num7, dt * ((num7 > TickLit[i]) ? 14f : 7f)); TickFlash[i] = Mathf.MoveTowards(TickFlash[i], 0f, dt * 3.6f); Color val = Color.Lerp(state * 0.6f, state, TickLit[i]); val = Color.Lerp(val, NeonTheme.Bright, TickFlash[i]); val.a = alpha * Mathf.Lerp(0.1f, 1f, TickLit[i]) + alpha * 0.5f * TickFlash[i]; neonPiece.Tint(val); } } private static void HideTicks() { for (int i = 0; i < Ticks.Count; i++) { Ticks[i].SetActive(active: false); } } private static void Fade(NeonPiece piece, Color color, float weight, float alpha) { //IL_0006: 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) if (piece != null) { color.a = color.a * weight * alpha; piece.Tint(color); } } public static void Destroy() { for (int i = 0; i < TextMaterials.Count; i++) { if ((Object)(object)TextMaterials[i] != (Object)null) { Object.Destroy((Object)(object)TextMaterials[i]); } } TextMaterials.Clear(); DestroyPiece(_shadow); DestroyPiece(_glow); DestroyPiece(_bloom); DestroyPiece(_sheen); DestroyPiece(_fill); DestroyPiece(_edge); DestroyPiece(_headerBar); DestroyPiece(_footBar); DestroyPiece(_rail); DestroyPiece(_sweep); DestroyPiece(_tear); for (int j = 0; j < Brackets.Count; j++) { DestroyPiece(Brackets[j]); } for (int k = 0; k < Ticks.Count; k++) { DestroyPiece(Ticks[k]); } Brackets.Clear(); Ticks.Clear(); if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } _root = null; _scaler = null; _warp = null; _hasSource = false; _wantVisible = false; _alive = 0f; _lastCount = -1; _lastMax = -1; _detail = 1f; _detailHold = 3.5f; } private static void DestroyPiece(NeonPiece piece) { if ((Object)(object)piece?.Material != (Object)null) { Object.Destroy((Object)(object)piece.Material); } } } internal static class NeonTextures { private const int LongSide = 256; private const float BorderWorld = 0.0013f; private const float BigChamfer = 0.13f; private const float SmallChamfer = 0.055f; private static readonly Dictionary Cache = new Dictionary(); public static Texture2D Fill(Vector2 worldSize) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Panel(worldSize, "fill"); } public static Texture2D Edge(Vector2 worldSize) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Panel(worldSize, "edge"); } public static Texture2D Glow(Vector2 worldSize) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Panel(worldSize, "glow"); } public static Texture2D Halo(Vector2 outerSize, Vector2 innerSize) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_01af: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(outerSize.x, outerSize.y); if (num <= 0.0001f) { num = 0.01f; } float num2 = 256f / num; int num3 = Mathf.Clamp(Mathf.RoundToInt(outerSize.x * num2), 8, 320); int num4 = Mathf.Clamp(Mathf.RoundToInt(outerSize.y * num2), 8, 320); string key = "halo_" + num3 + "x" + num4; if (Cache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { return value; } Il2CppStructArray val = new Il2CppStructArray((long)(num3 * num4)); float num5 = (float)num3 * 0.5f; float num6 = (float)num4 * 0.5f; float num7 = innerSize.x * 0.5f * num2; float num8 = innerSize.y * 0.5f * num2; float num9 = Mathf.Min(num7, num8) * 2f; float num10 = num9 * 0.13f; float num11 = num9 * 0.055f; float num12 = Mathf.Max(4f, Mathf.Min(num5 - num7, num6 - num8) * 0.85f); for (int i = 0; i < num4; i++) { for (int j = 0; j < num3; j++) { float px = (float)j + 0.5f - num5; float py = (float)i + 0.5f - num6; float num13 = ChamferBox(px, py, num7, num8, num10, num11, num10, num11); float num14 = Mathf.Clamp01(0.5f - num13); float num15 = Mathf.Max(num13, 0f); float num16 = Mathf.Exp((0f - num15 * num15) / (num12 * num12)) * (1f - num14); ((Il2CppArrayBase)(object)val)[i * num3 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(Mathf.Clamp01(num16) * 255f)); } } Texture2D val2 = Commit(val, num3, num4); Cache[key] = val2; return val2; } private static Texture2D Panel(Vector2 worldSize, string mode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(worldSize.x, worldSize.y); if (num <= 0.0001f) { num = 0.01f; } float num2 = 256f / num; int num3 = Mathf.Clamp(Mathf.RoundToInt(worldSize.x * num2), 8, 320); int num4 = Mathf.Clamp(Mathf.RoundToInt(worldSize.y * num2), 8, 320); string key = mode + "_" + num3 + "x" + num4; if (Cache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { return value; } Il2CppStructArray val = new Il2CppStructArray((long)(num3 * num4)); float num5 = (float)num3 * 0.5f; float num6 = (float)num4 * 0.5f; float num7 = Mathf.Min(num3, num4); float num8 = num7 * 0.13f; float num9 = num7 * 0.055f; float num10 = Mathf.Max(1.6f, 0.0013f * num2); float num11 = Mathf.Max(3f, num7 * 0.14f); for (int i = 0; i < num4; i++) { for (int j = 0; j < num3; j++) { float num12 = (float)j + 0.5f - num5; float py = (float)i + 0.5f - num6; float num13 = ChamferBox(num12, py, num5 - 0.5f, num6 - 0.5f, num8, num9, num8, num9); float num14 = Mathf.Clamp01(0.5f - num13); float num15 = Mathf.Clamp01(0.5f - (num13 + num10)); float num16; if (mode == "glow") { num16 = Mathf.Exp((0f - Mathf.Max(num13, 0f)) / num11) * (1f - num14) * 0.9f; } else if (mode == "edge") { float num17 = Mathf.Clamp01(num14 - num15); float num18 = Mathf.Clamp01(0.5f - (num13 + num10 * 3.4f)); float num19 = Mathf.Clamp01(num15 - num18) * 0.22f; float num20 = 0f; float num21 = num4 - 1 - i; if (num21 > num10 * 2f && num21 < num10 * 3.6f) { num20 = num15 * 0.85f; } float num22 = 0f; float num23 = Mathf.Min(j, num3 - 1 - j); float num24 = Mathf.Min(i, num4 - 1 - i); float num25 = num7 * 0.3f; float num26 = num7 * 0.16f; if (num23 > num25 && num23 < num25 + num10 * 1.2f && num24 < num26) { num22 = num15; } if (num24 > num25 * 0.55f && num24 < num25 * 0.55f + num10 * 1.2f && num23 < num26 * 0.7f) { num22 = num15; } num16 = Mathf.Max(num17, Mathf.Max(num20, Mathf.Max(num22 * 0.75f, num19))); } else { float num27 = Mathf.Lerp(0.55f, 1f, ((float)i + 0.5f) / (float)num4); float num28 = (((float)(i % 4) < 1.05f) ? 0.14f : 0f); float num29 = (((float)(j % 24) < 1.05f) ? 0.05f : 0f); float num30 = 1f - 0.25f * Mathf.Abs(num12) / num5; num16 = num15 * (num27 * num30 + num28 + num29); } ((Il2CppArrayBase)(object)val)[i * num3 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(Mathf.Clamp01(num16) * 255f)); } } Texture2D val2 = Commit(val, num3, num4); Cache[key] = val2; return val2; } public static Texture2D Sheen(Vector2 worldSize) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(worldSize.x, worldSize.y); if (num <= 0.0001f) { num = 0.01f; } float num2 = 256f / num; int num3 = Mathf.Clamp(Mathf.RoundToInt(worldSize.x * num2), 8, 320); int num4 = Mathf.Clamp(Mathf.RoundToInt(worldSize.y * num2), 8, 320); string key = "sheen_" + num3 + "x" + num4; if (Cache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { return value; } Il2CppStructArray val = new Il2CppStructArray((long)(num3 * num4)); float num5 = (float)num3 * 0.5f; float num6 = (float)num4 * 0.5f; float num7 = Mathf.Min(num3, num4); float num8 = num7 * 0.13f; float num9 = num7 * 0.055f; float num10 = Mathf.Max(1.6f, 0.0013f * num2); float num11 = num5 + num6; for (int i = 0; i < num4; i++) { for (int j = 0; j < num3; j++) { float num12 = (float)j + 0.5f - num5; float num13 = (float)i + 0.5f - num6; float num14 = ChamferBox(num12, num13, num5 - 0.5f, num6 - 0.5f, num8, num9, num8, num9); float num15 = Mathf.Clamp01(0.5f - (num14 + num10)); float num16 = (num12 * 0.55f + num13 * 1.45f) / num11; float num17 = Mathf.Exp((0f - (num16 + 0.3f) * (num16 + 0.3f)) / 0.075f); float num18 = Mathf.Exp((0f - (num16 - 0.34f) * (num16 - 0.34f)) / 0.006f); float num19 = num15 * (num17 * 0.42f + num18 * 0.55f); ((Il2CppArrayBase)(object)val)[i * num3 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(Mathf.Clamp01(num19) * 255f)); } } Texture2D val2 = Commit(val, num3, num4); Cache[key] = val2; return val2; } public static Texture2D Slab(Vector2 worldSize) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(worldSize.x, worldSize.y); if (num <= 0.0001f) { num = 0.01f; } float num2 = 160f / num; int num3 = Mathf.Clamp(Mathf.RoundToInt(worldSize.x * num2), 6, 224); int num4 = Mathf.Clamp(Mathf.RoundToInt(worldSize.y * num2), 6, 224); string key = "slab_" + num3 + "x" + num4; if (Cache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { return value; } Il2CppStructArray val = new Il2CppStructArray((long)(num3 * num4)); float num5 = (float)num3 * 0.5f; float num6 = (float)num4 * 0.5f; float num7 = (float)Mathf.Min(num3, num4) * 0.42f; for (int i = 0; i < num4; i++) { for (int j = 0; j < num3; j++) { float px = (float)j + 0.5f - num5; float py = (float)i + 0.5f - num6; float num8 = ChamferBox(px, py, num5 - 0.5f, num6 - 0.5f, num7, 0f, num7, 0f); float num9 = Mathf.Clamp01(0.5f - num8); float num10 = Mathf.Lerp(0.7f, 1f, ((float)i + 0.5f) / (float)num4); ((Il2CppArrayBase)(object)val)[i * num3 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(Mathf.Clamp01(num9 * num10) * 255f)); } } Texture2D val2 = Commit(val, num3, num4); Cache[key] = val2; return val2; } public static Texture2D Tick() { //IL_010f: Unknown result type (might be due to invalid IL or missing references) if (Cache.TryGetValue("tick", out var value) && (Object)(object)value != (Object)null) { return value; } Il2CppStructArray val = new Il2CppStructArray(2048L); float num = 16f; float num2 = 32f; for (int i = 0; i < 64; i++) { for (int j = 0; j < 32; j++) { float num3 = ((float)j + 0.5f - num) / num; float num4 = ((float)i + 0.5f - num2) / num2; float num5 = num3 - num4 * 0.38f; float num6 = Band(0.62f - Mathf.Abs(num5), 0.16f) * Band(0.92f - Mathf.Abs(num4), 0.1f); float num7 = Band(0.62f - Mathf.Abs(num5), 0.16f) * Band(0.14f - Mathf.Abs(Mathf.Abs(num4) - 0.84f), 0.06f); float num8 = Mathf.Clamp01(num6 * 0.82f + num7 * 0.6f); ((Il2CppArrayBase)(object)val)[i * 32 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num8 * 255f)); } } Texture2D val2 = Commit(val, 32, 64); Cache["tick"] = val2; return val2; } public static Texture2D Sweep() { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) if (Cache.TryGetValue("sweep", out var value) && (Object)(object)value != (Object)null) { return value; } Il2CppStructArray val = new Il2CppStructArray(8192L); for (int i = 0; i < 32; i++) { for (int j = 0; j < 256; j++) { float num = ((float)i + 0.5f) / 32f * 2f - 1f; float num2 = ((float)j + 0.5f) / 256f; float num3 = Mathf.Exp((0f - num) * num * 9f); float num4 = Band(0.1f - Mathf.Abs(num), 0.08f); float num5 = Mathf.Pow(Mathf.Sin(num2 * (float)Math.PI), 0.45f); float num6 = Mathf.Clamp01((num3 * 0.45f + num4 * 0.8f) * num5); ((Il2CppArrayBase)(object)val)[i * 256 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num6 * 255f)); } } Texture2D val2 = Commit(val, 256, 32); Cache["sweep"] = val2; return val2; } public static Texture2D Bracket() { //IL_00be: Unknown result type (might be due to invalid IL or missing references) if (Cache.TryGetValue("bracket", out var value) && (Object)(object)value != (Object)null) { return value; } Il2CppStructArray val = new Il2CppStructArray(4096L); float num = 32f; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num2 = ((float)j + 0.5f - num) / num; float num3 = ((float)i + 0.5f - num) / num; bool num4 = num2 < -0.81f && num3 > 0.38f; bool flag = num3 > 0.81f && num2 < -0.38f; float num5 = ((num4 || flag) ? 1f : 0f); ((Il2CppArrayBase)(object)val)[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num5 * 255f)); } } Texture2D val2 = Commit(val, 64, 64); Cache["bracket"] = val2; return val2; } public static Texture2D Solid() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (Cache.TryGetValue("solid", out var value) && (Object)(object)value != (Object)null) { return value; } Il2CppStructArray val = new Il2CppStructArray(16L); for (int i = 0; i < 16; i++) { ((Il2CppArrayBase)(object)val)[i] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); } Texture2D val2 = Commit(val, 4, 4); Cache["solid"] = val2; return val2; } private static float ChamferBox(float px, float py, float halfW, float halfH, float topLeft, float topRight, float bottomRight, float bottomLeft) { return Mathf.Max(Mathf.Max(Mathf.Max(Mathf.Max(Mathf.Max(Mathf.Abs(px) - halfW, Mathf.Abs(py) - halfH), Plane(0f - px, py, halfW, halfH, topLeft)), Plane(px, py, halfW, halfH, topRight)), Plane(px, 0f - py, halfW, halfH, bottomRight)), Plane(0f - px, 0f - py, halfW, halfH, bottomLeft)); } private static float Plane(float px, float py, float halfW, float halfH, float chamfer) { if (chamfer <= 0.0001f) { return float.NegativeInfinity; } return (px + py - (halfW + halfH - chamfer)) * 0.70710677f; } private static float Band(float value, float softness) { return Mathf.Clamp01(value / Mathf.Max(0.0001f, softness)); } private static Texture2D Commit(Il2CppStructArray pixels, 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown Texture2D val = new Texture2D(w, h, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; val.SetPixels32(pixels); val.Apply(false, false); return val; } public static void Clear() { foreach (KeyValuePair item in Cache) { if ((Object)(object)item.Value != (Object)null) { Object.Destroy((Object)(object)item.Value); } } Cache.Clear(); } } internal static class NeonTheme { public static readonly Color Backplate = new Color(0.012f, 0.02f, 0.032f, 0.94f); public static readonly Color Shadow = new Color(0f, 0.02f, 0.04f, 0.55f); private static readonly Color[] Primaries = (Color[])(object)new Color[5] { new Color(0f, 0.92f, 1f, 1f), new Color(1f, 0.18f, 0.64f, 1f), new Color(0.55f, 1f, 0.22f, 1f), new Color(0.66f, 0.38f, 1f, 1f), new Color(1f, 0.36f, 0.14f, 1f) }; private static readonly Color[] Accents = (Color[])(object)new Color[5] { new Color(1f, 0.16f, 0.62f, 1f), new Color(0.25f, 0.88f, 1f, 1f), new Color(1f, 0.86f, 0.1f, 1f), new Color(1f, 0.38f, 0.8f, 1f), new Color(1f, 0.86f, 0.22f, 1f) }; private static readonly string[] PaletteNames = new string[5] { "Cyber Cyan", "Hot Magenta", "Toxic Lime", "Synthwave", "Ember" }; public static readonly Color Warn = new Color(1f, 0.72f, 0.1f, 1f); public static readonly Color Critical = new Color(1f, 0.2f, 0.18f, 1f); public static readonly Color Bright = new Color(0.94f, 1f, 1f, 1f); private static Shader _shader; private static TMP_FontAsset _font; private static float _unitsPerFontSize = -1f; private static readonly string[] ShaderCandidates = new string[5] { "Universal Render Pipeline/Unlit", "Unlit/Transparent", "Sprites/Default", "UI/Default", "Hidden/Internal-Colored" }; public static Color Primary => Primaries[Mathf.Clamp(Prefs.Palette, 0, Primaries.Length - 1)]; public static Color Accent => Accents[Mathf.Clamp(Prefs.Palette, 0, Accents.Length - 1)]; public static int PaletteCount => PaletteNames.Length; public static Shader Shader { get { if ((Object)(object)_shader != (Object)null) { return _shader; } for (int i = 0; i < ShaderCandidates.Length; i++) { if (!((Object)(object)_shader == (Object)null)) { break; } _shader = Shader.Find(ShaderCandidates[i]); } if ((Object)(object)_shader == (Object)null) { Melon.Logger.Warning("No usable shader found; readout may be invisible."); } return _shader; } } public static TMP_FontAsset Font { get { if ((Object)(object)_font != (Object)null) { return _font; } try { _font = TMP_Settings.defaultFontAsset; } catch { } if ((Object)(object)_font == (Object)null) { try { Il2CppArrayBase val = Resources.FindObjectsOfTypeAll(); if (val != null && val.Length > 0) { _font = val[0]; } } catch { } } if ((Object)(object)_font == (Object)null) { Melon.Logger.Warning("No TMP font asset found; readout labels will be blank."); } return _font; } } public static string PaletteName(int index) { return PaletteNames[Mathf.Clamp(index, 0, PaletteNames.Length - 1)]; } public static float Severity(int count, float ratio) { return Mathf.Min(ratio, (float)count / 8f); } public static Color StateColor(float severity) { //IL_0008: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (severity < 0.15f) { return Critical; } if (severity < 0.24f) { return Color.Lerp(Critical, Warn, Mathf.InverseLerp(0.15f, 0.24f, severity)); } if (severity < 0.48f) { return Color.Lerp(Warn, Primary, Mathf.InverseLerp(0.24f, 0.48f, severity)); } return Primary; } public static void Calibrate(TMP_Text probe) { //IL_002f: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (_unitsPerFontSize > 0f || (Object)(object)probe == (Object)null) { return; } try { float fontSize = probe.fontSize; probe.fontSize = 1f; Vector2 preferredValues = probe.GetPreferredValues("Ag"); probe.fontSize = fontSize; if (preferredValues.y > 0.0001f) { _unitsPerFontSize = preferredValues.y; } } catch { } } public static float FontSizeFor(float worldHeight) { if (!(_unitsPerFontSize > 0f)) { return worldHeight * 10f; } return worldHeight / _unitsPerFontSize; } public static Material CreateMaterial(Color color, Texture2D texture, int queue) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown Material val = new Material(Shader); Tint(val, color); SetTexture(val, texture); val.SetFloat("_Surface", 1f); val.SetFloat("_Blend", 0f); val.SetFloat("_ZWrite", 0f); val.SetFloat("_Cull", 0f); val.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); val.SetFloat("_ZTest", 8f); val.renderQueue = queue; return val; } public static void SetTexture(Material material, Texture2D texture) { if (!((Object)(object)material == (Object)null) && !((Object)(object)texture == (Object)null)) { if (material.HasProperty("_BaseMap")) { material.SetTexture("_BaseMap", (Texture)(object)texture); } if (material.HasProperty("_MainTex")) { material.SetTexture("_MainTex", (Texture)(object)texture); } } } public static void Tint(Material material, Color color) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)material == (Object)null)) { if (material.HasProperty("_BaseColor")) { material.SetColor("_BaseColor", color); } if (material.HasProperty("_Color")) { material.SetColor("_Color", color); } if (material.HasProperty("_TintColor")) { material.SetColor("_TintColor", color); } } } public static void Reset() { _shader = null; _font = null; _unitsPerFontSize = -1f; NeonTextures.Clear(); } } } namespace NeonMag.Config { internal static class Prefs { private static MelonPreferences_Category _category; private static MelonPreferences_Entry _enabled; private static MelonPreferences_Entry _scale; private static MelonPreferences_Entry _offsetX; private static MelonPreferences_Entry _offsetY; private static MelonPreferences_Entry _offsetZ; private static MelonPreferences_Entry _palette; private static MelonPreferences_Entry _opacity; private static MelonPreferences_Entry _glitch; private static MelonPreferences_Entry _sweep; private static MelonPreferences_Entry _segments; private static MelonPreferences_Entry _reserve; private static MelonPreferences_Entry _fireMode; private static MelonPreferences_Entry _magazines; private static MelonPreferences_Entry _billboard; private static MelonPreferences_Entry _autoFade; public static bool Enabled { get { return _enabled?.Value ?? true; } set { if (_enabled != null) { _enabled.Value = value; } } } public static float Scale { get { return Mathf.Clamp(_scale?.Value ?? 0.62f, 0.35f, 3f); } set { if (_scale != null) { _scale.Value = value; } } } public static Vector3 Offset => new Vector3(_offsetX?.Value ?? 0.105f, _offsetY?.Value ?? 0.035f, _offsetZ?.Value ?? 0f); public static float OffsetX { get { return _offsetX?.Value ?? 0.105f; } set { if (_offsetX != null) { _offsetX.Value = value; } } } public static float OffsetY { get { return _offsetY?.Value ?? 0.035f; } set { if (_offsetY != null) { _offsetY.Value = value; } } } public static float OffsetZ { get { return _offsetZ?.Value ?? 0f; } set { if (_offsetZ != null) { _offsetZ.Value = value; } } } public static int Palette { get { return Mathf.Clamp(_palette?.Value ?? 0, 0, 4); } set { if (_palette != null) { _palette.Value = value; } } } public static float Opacity { get { return Mathf.Clamp(_opacity?.Value ?? 1f, 0.15f, 1f); } set { if (_opacity != null) { _opacity.Value = value; } } } public static float Glitch { get { return Mathf.Clamp01(_glitch?.Value ?? 0.75f); } set { if (_glitch != null) { _glitch.Value = value; } } } public static bool Sweep { get { return _sweep?.Value ?? true; } set { if (_sweep != null) { _sweep.Value = value; } } } public static bool Segments { get { return _segments?.Value ?? true; } set { if (_segments != null) { _segments.Value = value; } } } public static bool Reserve { get { return _reserve?.Value ?? true; } set { if (_reserve != null) { _reserve.Value = value; } } } public static bool FireMode { get { return _fireMode?.Value ?? true; } set { if (_fireMode != null) { _fireMode.Value = value; } } } public static bool Magazines { get { return _magazines?.Value ?? true; } set { if (_magazines != null) { _magazines.Value = value; } } } public static bool Billboard { get { return _billboard?.Value ?? true; } set { if (_billboard != null) { _billboard.Value = value; } } } public static bool AutoFade { get { return _autoFade?.Value ?? true; } set { if (_autoFade != null) { _autoFade.Value = value; } } } public static void Load() { _category = MelonPreferences.CreateCategory("NeonMag"); _enabled = _category.CreateEntry("Enabled", true, "Enabled", (string)null, false, false, (ValueValidator)null, (string)null); _scale = _category.CreateEntry("Scale", 0.62f, "Scale", (string)null, false, false, (ValueValidator)null, (string)null); _offsetX = _category.CreateEntry("OffsetX", 0.105f, "Offset X", (string)null, false, false, (ValueValidator)null, (string)null); _offsetY = _category.CreateEntry("OffsetY", 0.035f, "Offset Y", (string)null, false, false, (ValueValidator)null, (string)null); _offsetZ = _category.CreateEntry("OffsetZ", 0f, "Offset Z", (string)null, false, false, (ValueValidator)null, (string)null); _palette = _category.CreateEntry("Palette", 0, "Palette", (string)null, false, false, (ValueValidator)null, (string)null); _opacity = _category.CreateEntry("Opacity", 1f, "Opacity", (string)null, false, false, (ValueValidator)null, (string)null); _glitch = _category.CreateEntry("Glitch", 0.75f, "Glitch Intensity", (string)null, false, false, (ValueValidator)null, (string)null); _sweep = _category.CreateEntry("Sweep", true, "Scanline Sweep", (string)null, false, false, (ValueValidator)null, (string)null); _segments = _category.CreateEntry("Segments", true, "Round Segments", (string)null, false, false, (ValueValidator)null, (string)null); _reserve = _category.CreateEntry("Reserve", true, "Reserve Count", (string)null, false, false, (ValueValidator)null, (string)null); _fireMode = _category.CreateEntry("FireMode", true, "Fire Mode Readout", (string)null, false, false, (ValueValidator)null, (string)null); _magazines = _category.CreateEntry("Magazines", true, "Show On Loose Magazines", (string)null, false, false, (ValueValidator)null, (string)null); _billboard = _category.CreateEntry("Billboard", true, "Face Player", (string)null, false, false, (ValueValidator)null, (string)null); _autoFade = _category.CreateEntry("AutoFade", true, "Fade Detail When Idle", (string)null, false, false, (ValueValidator)null, (string)null); } public static void Save() { try { MelonPreferences_Category category = _category; if (category != null) { category.SaveToFile(false); } } catch { } } } } namespace NeonMag.Ammo { internal static class AmmoReader { private static readonly GameObject[] CachedHeld = (GameObject[])(object)new GameObject[2]; private static readonly Gun[] CachedGun = (Gun[])(object)new Gun[2]; private static readonly Magazine[] CachedMagazine = (Magazine[])(object)new Magazine[2]; public static bool TryResolve(out AmmoSnapshot snapshot) { snapshot = default(AmmoSnapshot); try { if (!Player.HandsExist) { return false; } if (TryHand(Player.RightHand, 0, ref snapshot)) { return true; } if (TryHand(Player.LeftHand, 1, ref snapshot)) { return true; } } catch { } return false; } public static void Forget() { for (int i = 0; i < CachedHeld.Length; i++) { CachedHeld[i] = null; CachedGun[i] = null; CachedMagazine[i] = null; } } private static bool TryHand(Hand hand, int slot, ref AmmoSnapshot snapshot) { if ((Object)(object)hand == (Object)null) { return false; } GameObject val = null; try { val = Player.GetObjectInHand(hand); } catch { } if ((Object)(object)val == (Object)null) { CachedHeld[slot] = null; CachedGun[slot] = null; CachedMagazine[slot] = null; return false; } if (val != CachedHeld[slot]) { CachedHeld[slot] = val; CachedGun[slot] = Locate(val); CachedMagazine[slot] = (((Object)(object)CachedGun[slot] != (Object)null) ? null : Locate(val)); } Gun val2 = CachedGun[slot]; if ((Object)(object)val2 != (Object)null) { return FromGun(val2, ref snapshot); } if (!Prefs.Magazines) { return false; } Magazine val3 = CachedMagazine[slot]; if ((Object)(object)val3 != (Object)null) { return FromMagazine(val3, ref snapshot); } return false; } private static T Locate(GameObject root) where T : Component { T val = default(T); try { val = root.GetComponentInParent(); } catch { } if ((Object)(object)val != (Object)null) { return val; } try { val = root.GetComponentInChildren(); } catch { } return val; } private static bool FromGun(Gun gun, ref AmmoSnapshot snapshot) { //IL_0184: 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) snapshot.Kind = ReadoutKind.Gun; snapshot.Anchor = Anchor(gun); AmmoSocket val = null; try { val = gun.ammoSocket; } catch { } bool flag = false; try { flag = (Object)(object)val != (Object)null && val.HasMagazine; } catch { } MagazineData val2 = null; try { val2 = gun.internalMagazine; } catch { } MagazineState val3 = null; try { val3 = gun.MagazineState; } catch { } if (val3 == null) { try { val3 = gun._magState; } catch { } } snapshot.NoMagazine = !flag && (Object)(object)val2 == (Object)null; CartridgeData val4 = null; MagazineData val5 = null; int num = 0; if (val3 != null) { try { num = Mathf.Max(0, val3.AmmoCount); } catch { } try { val4 = val3.cartridgeData; } catch { } try { val5 = val3.magazineData; } catch { } } if (snapshot.NoMagazine) { num = 0; } CartridgeData val6 = null; try { val6 = gun.chamberedCartridge; } catch { } snapshot.Chambered = (Object)(object)val6 != (Object)null; snapshot.InMagazine = num; snapshot.Count = num + (snapshot.Chambered ? 1 : 0); if ((Object)(object)val4 == (Object)null) { val4 = val6; } if ((Object)(object)val5 == (Object)null) { val5 = val2; } if ((Object)(object)val5 == (Object)null) { try { val5 = gun.defaultMagazine; } catch { } } snapshot.Max = Rounds(val5, snapshot.Count); if ((Object)(object)val4 == (Object)null) { try { val4 = gun.defaultCartridge; } catch { } } snapshot.Platform = Platform(val5, val); snapshot.Cartridge = CartridgeName(val4); snapshot.Reserve = Reserve(val4); if (Prefs.FireMode) { try { snapshot.FireMode = ShortMode(((object)gun.fireMode/*cast due to .constrained prefix*/).ToString()); } catch { } } return true; } private static bool FromMagazine(Magazine magazine, ref AmmoSnapshot snapshot) { bool flag = false; try { flag = magazine.isMagazineInserted; } catch { } if (flag) { return false; } MagazineState val = null; try { val = magazine.magazineState; } catch { } if (val == null) { return false; } snapshot.Kind = ReadoutKind.Magazine; try { snapshot.Anchor = ((Component)magazine).transform; } catch { } if ((Object)(object)snapshot.Anchor == (Object)null) { return false; } try { snapshot.Count = Mathf.Max(0, val.AmmoCount); } catch { } snapshot.InMagazine = snapshot.Count; MagazineData data = null; try { data = val.magazineData; } catch { } CartridgeData cartridge = null; try { cartridge = val.cartridgeData; } catch { } snapshot.Max = Rounds(data, snapshot.Count); snapshot.Platform = Platform(data, null); snapshot.Cartridge = CartridgeName(cartridge); snapshot.Reserve = Reserve(cartridge); snapshot.FireMode = "MAG"; return true; } private static Transform Anchor(Gun gun) { try { AmmoSocket ammoSocket = gun.ammoSocket; if ((Object)(object)ammoSocket != (Object)null && (Object)(object)((Component)ammoSocket).transform != (Object)null) { return ((Component)ammoSocket).transform; } } catch { } try { return ((Component)gun).transform; } catch { } return null; } private static int Rounds(MagazineData data, int fallback) { int num = 0; if ((Object)(object)data != (Object)null) { try { num = data.rounds; } catch { } } if (num > 0) { return Mathf.Min(num, 999); } return Mathf.Max(1, fallback); } private static string Platform(MagazineData data, AmmoSocket socket) { string value = null; if ((Object)(object)data != (Object)null) { try { value = data.platform; } catch { } } if (string.IsNullOrEmpty(value) && (Object)(object)socket != (Object)null) { try { value = socket.platform; } catch { } } return Clean(value, "STANDARD"); } private static string CartridgeName(CartridgeData cartridge) { if ((Object)(object)cartridge == (Object)null) { return string.Empty; } string value = null; try { value = cartridge.Name; } catch { } if (string.IsNullOrEmpty(value)) { try { value = cartridge._name; } catch { } } return Clean(value, string.Empty); } private static int Reserve(CartridgeData cartridge) { if ((Object)(object)cartridge == (Object)null || !Prefs.Reserve) { return -1; } try { AmmoInventory instance = AmmoInventory.Instance; if ((Object)(object)instance == (Object)null) { return -1; } return Mathf.Max(0, instance.GetCartridgeCount(cartridge)); } catch { } return -1; } private static string ShortMode(string mode) { if (string.IsNullOrEmpty(mode)) { return string.Empty; } mode = mode.ToUpperInvariant(); if (mode.StartsWith("SEMI")) { return "SEMI"; } if (mode.StartsWith("BURST") || mode.Contains("BURST")) { return "BURST"; } if (mode.StartsWith("AUTO") || mode.Contains("AUTOMATIC")) { return "AUTO"; } if (mode.StartsWith("BOLT")) { return "BOLT"; } if (mode.StartsWith("PUMP")) { return "PUMP"; } if (mode.StartsWith("SINGLE")) { return "SINGLE"; } if (mode.Length <= 6) { return mode; } return mode.Substring(0, 6); } private static string Clean(string value, string fallback) { if (string.IsNullOrEmpty(value)) { return fallback; } value = value.Trim().ToUpperInvariant(); if (value.Length > 14) { value = value.Substring(0, 14); } return value; } } internal enum ReadoutKind { None, Gun, Magazine } internal struct AmmoSnapshot { public ReadoutKind Kind; public Transform Anchor; public int Count; public int InMagazine; public int Max; public int Reserve; public bool Chambered; public bool NoMagazine; public string Platform; public string Cartridge; public string FireMode; public float Ratio { get { if (Max <= 0) { return 0f; } return Mathf.Clamp01((float)Count / (float)Max); } } public bool SameSource(AmmoSnapshot other) { if (Kind == other.Kind) { return Anchor == other.Anchor; } return false; } } }