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 HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSLZ.Marrow; using Il2CppSystem.Collections.Generic; using Il2CppTMPro; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using Overheat; using Overheat.Config; using Overheat.Fx; using Overheat.Heat; using Overheat.Hud; using Overheat.Menu; using Overheat.Patches; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Overheat")] [assembly: AssemblyDescription("Guns heat up, smoke, and stop firing until they cool down.")] [assembly: AssemblyCompany(null)] [assembly: AssemblyProduct("Overheat")] [assembly: AssemblyFileVersion("1.1.0")] [assembly: MelonInfo(typeof(OverheatMod), "Overheat", "1.1.0", "Rocner", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: MelonColor(255, 255, 110, 30)] [assembly: MelonAuthorColor(255, 120, 200, 255)] [assembly: MelonAdditionalDependencies(new string[] { "BoneLib" })] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyVersion("1.1.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 Overheat { public sealed class OverheatMod : MelonMod { private static bool _levelReady; private static float _retry; public override void OnInitializeMelon() { Step("preferences", Prefs.Load); Step("patches", delegate { GunPatches.Apply(((MelonBase)this).HarmonyInstance); }); Step("menu", MenuPage.Build); Step("level loaded hook", delegate { Hooking.OnLevelLoaded += OnLevelLoaded; }); Step("level unloaded hook", delegate { Hooking.OnLevelUnloaded += OnLevelUnloaded; }); ((MelonBase)this).LoggerInstance.Msg("Overheat ready. Don't hold the trigger."); } 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) { HeatSystem.Clear(); _levelReady = true; _retry = 0f; } private static void OnLevelUnloaded() { _levelReady = false; HeatSystem.Clear(); HeatHud.Destroy(); } public override void OnUpdate() { try { Run(Time.deltaTime); } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Error("Update failed: " + ex); } } private void Run(float dt) { if (dt <= 0f || !_levelReady) { return; } HeatSystem.Tick(dt); if (!Prefs.ShowHud && !Prefs.ShowHeatBar) { if (HeatHud.Exists) { HeatHud.Destroy(); } return; } if (!HeatHud.Exists) { _retry -= dt; if (_retry > 0f) { return; } _retry = 0.5f; if ((Object)(object)Player.Head == (Object)null) { return; } HeatHud.Build(); if (!HeatHud.Exists) { return; } } bool overheated = Prefs.ShowHud && HeatSystem.PlayerOverheated; HeatHud.Tick(dt, HeatSystem.PlayerHeat, overheated); } public override void OnDeinitializeMelon() { try { Hooking.OnLevelLoaded -= OnLevelLoaded; } catch { } try { Hooking.OnLevelUnloaded -= OnLevelUnloaded; } catch { } try { HeatSystem.Clear(); } catch { } try { HeatHud.Destroy(); } catch { } try { Smoke.DisposeShared(); } catch { } try { BarrelGlow.DisposeShared(); } catch { } try { Prefs.Save(); } catch { } } } internal static class BuildInfo { public const string Name = "Overheat"; public const string Description = "Guns heat up, smoke, and stop firing until they cool down."; public const string Author = "Rocner"; public const string Company = null; public const string Version = "1.1.0"; } } namespace Overheat.Patches { internal static class GunPatches { public static bool BlockPatched { get; private set; } public static bool CountPatched { get; private set; } public static void Apply(Harmony harmony) { if (harmony == null) { return; } BlockPatched = Patch(harmony, "Fire", "FirePrefix", prefix: true); CountPatched = Patch(harmony, "OnFire", "CountPostfix", prefix: false); if (!CountPatched) { CountPatched = Patch(harmony, "Fire", "CountPostfix", prefix: false); if (CountPatched) { Melon.Logger.Msg("Counting shots on Gun.Fire (OnFire was unavailable)."); } } if (!CountPatched) { Melon.Logger.Error("Could not hook gun firing; nothing will heat up."); } else if (!BlockPatched) { Melon.Logger.Warning("Guns will heat and smoke, but cannot be locked out."); } } private static bool Patch(Harmony harmony, string method, string patchName, bool prefix) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown try { MethodInfo methodInfo = AccessTools.Method(typeof(Gun), method, (Type[])null, (Type[])null); if (methodInfo == null) { Melon.Logger.Warning("Gun." + method + " not found."); return false; } HarmonyMethod val = new HarmonyMethod(AccessTools.Method(typeof(GunPatches), patchName, (Type[])null, (Type[])null)); if (prefix) { harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } Melon.Logger.Msg("Hooked Gun." + method + "."); return true; } catch (Exception ex) { Melon.Logger.Error("Patching Gun." + method + " failed: " + ex); return false; } } private static bool FirePrefix(Gun __instance) { try { if (!Prefs.Enabled) { return true; } return !HeatSystem.Blocked(__instance); } catch { return true; } } private static void CountPostfix(Gun __instance) { try { if (Prefs.Enabled && !HeatSystem.Blocked(__instance)) { HeatSystem.OnShot(__instance); } } catch { } } } } namespace Overheat.Menu { internal static class MenuPage { private static readonly Color Accent = new Color(1f, 0.45f, 0.12f); 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("Overheat", Accent, 0, true); } catch (Exception ex) { Melon.Logger.Error("BoneMenu root page failed: " + ex); return; } Section("main", delegate { BuildMain(root); }); Section("heat", delegate { BuildHeat(root); }); Section("smoke", delegate { BuildSmoke(root); }); Section("warning", delegate { BuildWarning(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 BuildMain(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(); if (!value) { HeatSystem.CoolEverything(); } }); root.CreateFloat("Shots To Overheat", Accent, Prefs.ShotsToOverheat, 1f, 3f, 300f, (Action)delegate(float value) { Prefs.ShotsToOverheat = value; Prefs.Save(); }); root.CreateFunction("Cool Everything Now", Accent, (Action)HeatSystem.CoolEverything); } private static void BuildHeat(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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) Page obj = root.CreatePage("Heat", Accent, 0, true); obj.CreateFloat("Cool Per Second", Accent, Prefs.CoolPerSecond, 0.02f, 0.01f, 3f, (Action)delegate(float value) { Prefs.CoolPerSecond = value; Prefs.Save(); }); obj.CreateFloat("Resume At Heat", Accent, Prefs.ResumeAt, 0.05f, 0f, 0.95f, (Action)delegate(float value) { Prefs.ResumeAt = value; Prefs.Save(); }); obj.CreateBool("Scale By Fire Rate", Accent, Prefs.ScaleByFireRate, (Action)delegate(bool value) { Prefs.ScaleByFireRate = value; Prefs.Save(); }); obj.CreateBool("Affect NPC Guns", Accent, Prefs.AffectNpcGuns, (Action)delegate(bool value) { Prefs.AffectNpcGuns = value; Prefs.Save(); if (!value) { HeatSystem.CoolEverything(); } }); obj.CreateBool("Log Events", Accent, Prefs.LogEvents, (Action)delegate(bool value) { Prefs.LogEvents = value; Prefs.Save(); }); } private static void BuildSmoke(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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) Page obj = root.CreatePage("Smoke", Accent, 0, true); obj.CreateBool("Smoke", Accent, Prefs.Smoke, (Action)delegate(bool value) { Prefs.Smoke = value; Prefs.Save(); }); obj.CreateFloat("Smoke Starts At", Accent, Prefs.SmokeThreshold, 0.05f, 0f, 1f, (Action)delegate(float value) { Prefs.SmokeThreshold = value; Prefs.Save(); }); obj.CreateFloat("Smoke Amount", Accent, Prefs.SmokeAmount, 0.1f, 0.1f, 4f, (Action)delegate(float value) { Prefs.SmokeAmount = value; Prefs.Save(); }); obj.CreateBool("Barrel Glow", Accent, Prefs.Glow, (Action)delegate(bool value) { Prefs.Glow = value; Prefs.Save(); }); obj.CreateFloat("Glow Starts At", Accent, Prefs.GlowStartsAt, 0.05f, 0f, 1f, (Action)delegate(float value) { Prefs.GlowStartsAt = value; Prefs.Save(); }); obj.CreateFloat("Glow Size", Accent, Prefs.GlowSize, 0.1f, 0.2f, 4f, (Action)delegate(float value) { Prefs.GlowSize = value; Prefs.Save(); }); obj.CreateBool("Glow Casts Light", Accent, Prefs.GlowLight, (Action)delegate(bool value) { Prefs.GlowLight = value; Prefs.Save(); HeatSystem.RebuildEffects(); }); } private static void BuildWarning(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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) Page obj = root.CreatePage("Warning", Accent, 0, true); obj.CreateBool("Show Warning", Accent, Prefs.ShowHud, (Action)delegate(bool value) { Prefs.ShowHud = value; Prefs.Save(); }); obj.CreateBool("Show Heat Bar", Accent, Prefs.ShowHeatBar, (Action)delegate(bool value) { Prefs.ShowHeatBar = value; Prefs.Save(); }); obj.CreateFloat("Bar Appears At", Accent, Prefs.BarThreshold, 0.05f, 0f, 1f, (Action)delegate(float value) { Prefs.BarThreshold = value; Prefs.Save(); }); obj.CreateFloat("Flash Rate", Accent, Prefs.FlashHz, 0.25f, 0.25f, 6f, (Action)delegate(float value) { Prefs.FlashHz = value; Prefs.Save(); }); obj.CreateFloat("Scale", Accent, Prefs.HudScale, 0.05f, 0.3f, 3f, (Action)delegate(float value) { Prefs.HudScale = value; Prefs.Save(); }); obj.CreateFloat("Distance", Accent, Prefs.HudDistance, 0.05f, 0.25f, 2f, (Action)delegate(float value) { Prefs.HudDistance = value; Prefs.Save(); }); obj.CreateFloat("Height", Accent, Prefs.HudHeight, 0.02f, -1f, 1f, (Action)delegate(float value) { Prefs.HudHeight = value; Prefs.Save(); }); } } } namespace Overheat.Hud { internal static class HeatHud { private const float PanelW = 0.24f; private const float PanelH = 0.078f; private const float BarW = 0.15f; private const float BarH = 0.01f; private static readonly Color HotRed = new Color(1f, 0.16f, 0.1f, 1f); private static readonly Color DimRed = new Color(0.42f, 0.05f, 0.03f, 1f); private static readonly Color Backplate = new Color(0.1f, 0.01f, 0.01f, 0.86f); private static readonly Color BarCool = new Color(1f, 0.72f, 0.2f, 1f); private static readonly List Materials = new List(); private static GameObject _root; private static Transform _scaler; private static GameObject _panel; private static GameObject _barGroup; private static Material _plateMaterial; private static Material _barBackMaterial; private static Material _barFillMaterial; private static GameObject _barFill; private static TextMeshPro _title; private static TextMeshPro _sub; private static Texture2D _plateTexture; private static Texture2D _solidTexture; private static float _pulse; private static float _unitsPerFontSize = -1f; private static TMP_FontAsset _font; public static bool Exists => (Object)(object)_root != (Object)null; public static void Build() { //IL_0018: 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_0040: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_00b1: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Expected O, but got Unknown //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_root != (Object)null)) { _plateTexture = Plate(new Vector2(0.24f, 0.078f)); _solidTexture = Solid(); _root = new GameObject("OverheatHud"); Object.DontDestroyOnLoad((Object)(object)_root); GameObject val = new GameObject("Scaler"); val.transform.SetParent(_root.transform, false); _scaler = val.transform; _panel = new GameObject("Panel"); _panel.transform.SetParent(_scaler, false); ((Component)Quad("Plate", _panel.transform, new Vector2(0.24f, 0.078f), 0f, 4000, _plateTexture, out _plateMaterial)).transform.localPosition = Vector3.zero; _title = Text("Title", _panel.transform, new Vector2(0.23f, 0.04f), 0.029f, (TextAlignmentOptions)514, new Vector3(0f, 0.0135f, -0.0024f)); _sub = Text("Sub", _panel.transform, new Vector2(0.23f, 0.02f), 0.0125f, (TextAlignmentOptions)514, new Vector3(0f, -0.0175f, -0.0024f)); ((TMP_Text)_title).text = "OVERHEAT!!"; ((TMP_Text)_sub).text = "chill out"; _barGroup = new GameObject("Bar"); _barGroup.transform.SetParent(_scaler, false); ((Component)Quad("BarBack", _barGroup.transform, new Vector2(0.15f, 0.01f), 0f, 4002, _solidTexture, out _barBackMaterial)).transform.localPosition = Vector3.zero; _barFill = ((Component)Quad("BarFill", _barGroup.transform, new Vector2(0.15f, 0.01f), -0.0008f, 4004, _solidTexture, out _barFillMaterial)).gameObject; _panel.SetActive(false); _barGroup.SetActive(false); _root.SetActive(false); } } public static void Tick(float dt, float heat, bool overheated) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_root == (Object)null) { return; } bool flag = Prefs.ShowHeatBar && heat >= Prefs.BarThreshold && !overheated; bool flag2 = overheated; if (!flag && !flag2) { if (_root.activeSelf) { _root.SetActive(false); } _pulse = 0f; return; } Transform head = Player.Head; if (!((Object)(object)head == (Object)null)) { if (!_root.activeSelf) { _root.SetActive(true); } Vector3 val = head.forward; val.y = 0f; val = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val)).normalized : Vector3.forward); _root.transform.position = head.position + val * Prefs.HudDistance + Vector3.up * Prefs.HudHeight; _root.transform.rotation = Quaternion.LookRotation(val, Vector3.up); float hudScale = Prefs.HudScale; _scaler.localScale = new Vector3(hudScale, hudScale, hudScale); if (_panel.activeSelf != flag2) { _panel.SetActive(flag2); } if (_barGroup.activeSelf != flag) { _barGroup.SetActive(flag); } _barGroup.transform.localPosition = new Vector3(0f, -0.055f, 0f); if (flag2) { TickPanel(dt); } if (flag) { TickBar(heat); } } } private static void TickPanel(float dt) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) _pulse += dt * Prefs.FlashHz * (float)Math.PI * 2f; float num = 0.5f + 0.5f * Mathf.Sin(_pulse); Color color = Color.Lerp(DimRed, HotRed, num); Tint(_plateMaterial, new Color(Backplate.r + num * 0.16f, Backplate.g, Backplate.b, Backplate.a)); if ((Object)(object)_title != (Object)null) { ((Graphic)_title).color = color; } if ((Object)(object)_sub != (Object)null) { ((Graphic)_sub).color = new Color(1f, 0.8f, 0.74f, 0.55f + num * 0.4f); } } private static void TickBar(float heat) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0048: 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_00a7: Unknown result type (might be due to invalid IL or missing references) Color color = Color.Lerp(BarCool, HotRed, Mathf.InverseLerp(0.45f, 1f, heat)); Tint(_barBackMaterial, new Color(0f, 0f, 0f, 0.55f)); Tint(_barFillMaterial, color); float num = Mathf.Clamp01(heat); float num2 = Mathf.Max(0.0006f, 0.15f * num); _barFill.transform.localPosition = new Vector3(-0.075f + num2 * 0.5f, 0f, -0.0008f); _barFill.transform.localScale = new Vector3(num2, 0.01f, 1f); } public static void Destroy() { for (int i = 0; i < Materials.Count; i++) { if ((Object)(object)Materials[i] != (Object)null) { Object.Destroy((Object)(object)Materials[i]); } } Materials.Clear(); if ((Object)(object)_plateTexture != (Object)null) { Object.Destroy((Object)(object)_plateTexture); } if ((Object)(object)_solidTexture != (Object)null) { Object.Destroy((Object)(object)_solidTexture); } if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } _root = null; _scaler = null; _panel = null; _barGroup = null; _barFill = null; _title = null; _sub = null; _plateMaterial = null; _barBackMaterial = null; _barFillMaterial = null; _plateTexture = null; _solidTexture = null; _pulse = 0f; } private static Renderer Quad(string name, Transform parent, Vector2 size, float depth, int queue, Texture2D texture, out Material material) { //IL_002b: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)obj).name = name; obj.transform.SetParent(parent, false); obj.transform.localPosition = new Vector3(0f, 0f, depth); obj.transform.localScale = new Vector3(size.x, size.y, 1f); Collider component = obj.GetComponent(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } Renderer component2 = obj.GetComponent(); material = CreateMaterial(texture, queue); component2.material = material; component2.shadowCastingMode = (ShadowCastingMode)0; component2.receiveShadows = false; Materials.Add(material); return component2; } private static Material CreateMaterial(Texture2D texture, int queue) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown Shader val = null; string[] array = new string[4] { "Universal Render Pipeline/Unlit", "Unlit/Transparent", "Sprites/Default", "UI/Default" }; for (int i = 0; i < array.Length; i++) { if (!((Object)(object)val == (Object)null)) { break; } val = Shader.Find(array[i]); } Material val2 = new Material(val); if ((Object)(object)texture != (Object)null) { if (val2.HasProperty("_BaseMap")) { val2.SetTexture("_BaseMap", (Texture)(object)texture); } if (val2.HasProperty("_MainTex")) { val2.SetTexture("_MainTex", (Texture)(object)texture); } } val2.SetFloat("_Surface", 1f); val2.SetFloat("_Blend", 0f); val2.SetFloat("_ZWrite", 0f); val2.SetFloat("_Cull", 0f); val2.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); val2.SetFloat("_ZTest", 8f); val2.renderQueue = queue; return val2; } private static TextMeshPro Text(string name, Transform parent, Vector2 size, float worldHeight, TextAlignmentOptions alignment, Vector3 position) { //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_003c: 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_0056: 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_FontAsset val3 = Font(); if ((Object)(object)val3 != (Object)null) { ((TMP_Text)val2).font = val3; } Calibrate((TMP_Text)(object)val2); RectTransform rectTransform = ((TMP_Text)val2).rectTransform; ((Transform)rectTransform).localPosition = position; rectTransform.sizeDelta = size; ((TMP_Text)val2).fontSize = FontSizeFor(worldHeight); ((TMP_Text)val2).alignment = alignment; ((TMP_Text)val2).enableWordWrapping = false; ((TMP_Text)val2).richText = false; ((TMP_Text)val2).characterSpacing = 4f; ((TMP_Text)val2).text = string.Empty; try { Material fontMaterial = ((TMP_Text)val2).fontMaterial; if ((Object)(object)fontMaterial != (Object)null) { Materials.Add(fontMaterial); if (fontMaterial.HasProperty("_ZTestMode")) { fontMaterial.SetFloat("_ZTestMode", 8f); } if (fontMaterial.HasProperty("_ZTest")) { fontMaterial.SetFloat("_ZTest", 8f); } fontMaterial.renderQueue = 4010; } } catch { } return val2; } private static TMP_FontAsset Font() { 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; the warning text will be blank."); } return _font; } private 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 { } } private static float FontSizeFor(float worldHeight) { if (!(_unitsPerFontSize > 0f)) { return worldHeight * 10f; } return worldHeight / _unitsPerFontSize; } private 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) if (!((Object)(object)material == (Object)null)) { if (material.HasProperty("_BaseColor")) { material.SetColor("_BaseColor", color); } if (material.HasProperty("_Color")) { material.SetColor("_Color", color); } } } private static Texture2D Plate(Vector2 size) { //IL_0005: 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_0018: 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_016a: Unknown result type (might be due to invalid IL or missing references) float num = 256f / Mathf.Max(size.x, size.y); int num2 = Mathf.Clamp(Mathf.RoundToInt(size.x * num), 8, 320); int num3 = Mathf.Clamp(Mathf.RoundToInt(size.y * num), 8, 320); Il2CppStructArray val = new Il2CppStructArray((long)(num2 * num3)); float num4 = (float)num2 * 0.5f; float num5 = (float)num3 * 0.5f; float num6 = (float)Mathf.Min(num2, num3) * 0.18f; float num7 = 3f; for (int i = 0; i < num3; i++) { for (int j = 0; j < num2; j++) { float num8 = Mathf.Abs((float)j + 0.5f - num4) - (num4 - 0.5f) + num6; float num9 = Mathf.Abs((float)i + 0.5f - num5) - (num5 - 0.5f) + num6; float num10 = Mathf.Max(num8, 0f); float num11 = Mathf.Max(num9, 0f); float num12 = Mathf.Min(Mathf.Max(num8, num9), 0f) + Mathf.Sqrt(num10 * num10 + num11 * num11) - num6; float num13 = Mathf.Clamp01(0.5f - num12); float num14 = Mathf.Clamp01(0.5f - (num12 + num7)); float num15 = Mathf.Clamp01(Mathf.Clamp01(num13 - num14) * 1f + num14 * 0.86f); ((Il2CppArrayBase)(object)val)[i * num2 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num15 * 255f)); } } return Commit(val, num2, num3); } private static Texture2D Solid() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) 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); } return Commit(val, 4, 4); } 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; } } } namespace Overheat.Heat { internal static class GunUtil { public static bool HeldByPlayer(Gun gun) { if ((Object)(object)gun == (Object)null) { return false; } try { RigManager rigManager = Player.RigManager; if ((Object)(object)rigManager == (Object)null) { return false; } if (HandsInclude(gun.triggerGrip, rigManager)) { return true; } Il2CppReferenceArray otherGrips = gun.otherGrips; if (otherGrips != null) { for (int i = 0; i < ((Il2CppArrayBase)(object)otherGrips).Length; i++) { if (HandsInclude(((Il2CppArrayBase)(object)otherGrips)[i], rigManager)) { return true; } } } } catch { } return false; } private static bool HandsInclude(Grip grip, RigManager player) { if ((Object)(object)grip == (Object)null) { return false; } List attachedHands = grip.attachedHands; if (attachedHands == null || attachedHands.Count == 0) { return false; } for (int i = 0; i < attachedHands.Count; i++) { Hand val = attachedHands[i]; if (!((Object)(object)val == (Object)null)) { RigManager manager = val.manager; if ((Object)(object)manager != (Object)null && ((Il2CppObjectBase)manager).Pointer == ((Il2CppObjectBase)player).Pointer) { return true; } } } return false; } public static bool Alive(Gun gun) { try { return (Object)(object)gun != (Object)null && (Object)(object)((Component)gun).gameObject != (Object)null; } catch { return false; } } public static bool Awake(Gun gun) { try { return (Object)(object)gun != (Object)null && (Object)(object)((Component)gun).gameObject != (Object)null && ((Component)gun).gameObject.activeInHierarchy; } catch { return false; } } public static Transform Muzzle(Gun gun) { try { Transform firePointTransform = gun.firePointTransform; if ((Object)(object)firePointTransform != (Object)null) { return firePointTransform; } return ((Component)gun).transform; } catch { return null; } } public static float RoundsPerSecond(Gun gun) { try { float roundsPerMinute = gun.roundsPerMinute; if (roundsPerMinute > 1f) { return Mathf.Clamp(roundsPerMinute / 60f, 0.5f, 60f); } } catch { } return 10f; } } internal sealed class GunState { public Gun Gun; public float Heat; public bool Overheated; public float LastSeen; public Smoke Smoke; public BarrelGlow Glow; } internal static class HeatSystem { private const float ReferenceRps = 10f; private const float EvictAfter = 25f; private const float MaxSmokeRate = 55f; private const float HeatCeiling = 1.25f; private static readonly Dictionary States = new Dictionary(); private static readonly List Doomed = new List(); private static bool _loggedFirstShot; public static float PlayerHeat { get; private set; } public static bool PlayerOverheated { get; private set; } public static int TrackedGuns => States.Count; public static bool Blocked(Gun gun) { if (!Prefs.Enabled || (Object)(object)gun == (Object)null) { return false; } return Find(gun)?.Overheated ?? false; } public static void OnShot(Gun gun) { if (!Prefs.Enabled || (Object)(object)gun == (Object)null) { return; } GunState gunState = Obtain(gun); if (gunState == null) { return; } if (!_loggedFirstShot) { _loggedFirstShot = true; Melon.Logger.Msg($"Counting shots: {Name(gun)} at {GunUtil.RoundsPerSecond(gun) * 60f:0} RPM, {1f / HeatPerShot(gun):0.0} rounds to overheat."); } gunState.Heat = Mathf.Min(1.25f, gunState.Heat + HeatPerShot(gun)); gunState.LastSeen = Time.time; if (!gunState.Overheated && !(gunState.Heat < 1f)) { gunState.Overheated = true; if (Prefs.LogEvents) { Melon.Logger.Msg(Name(gun) + " overheated."); } } } public static void Tick(float dt) { //IL_002b: 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_013c: Unknown result type (might be due to invalid IL or missing references) PlayerHeat = 0f; PlayerOverheated = false; if (States.Count == 0) { return; } float num = Prefs.CoolPerSecond * dt; float time = Time.time; Vector3 viewer = Viewer(); Doomed.Clear(); foreach (KeyValuePair state in States) { GunState value = state.Value; if (!GunUtil.Alive(value.Gun)) { Doomed.Add(state.Key); continue; } if (!GunUtil.Awake(value.Gun)) { value.Heat = 0f; value.Overheated = false; ClearEffects(value); if (time - value.LastSeen > 25f) { Doomed.Add(state.Key); } continue; } value.Heat = Mathf.Max(0f, value.Heat - num); if (value.Overheated && value.Heat <= Prefs.ResumeAt) { value.Overheated = false; if (Prefs.LogEvents) { Melon.Logger.Msg(Name(value.Gun) + " cooled down."); } } UpdateSmoke(value); UpdateGlow(value, viewer); if (GunUtil.HeldByPlayer(value.Gun)) { value.LastSeen = time; if (value.Heat > PlayerHeat) { PlayerHeat = value.Heat; } if (value.Overheated) { PlayerOverheated = true; } } if (value.Heat <= 0f && time - value.LastSeen > 25f && (value.Smoke == null || value.Smoke.Finished())) { Doomed.Add(state.Key); } } for (int i = 0; i < Doomed.Count; i++) { if (States.TryGetValue(Doomed[i], out var value2)) { ClearEffects(value2); } States.Remove(Doomed[i]); } Doomed.Clear(); } public static void Clear() { foreach (KeyValuePair state in States) { ClearEffects(state.Value); } States.Clear(); Doomed.Clear(); PlayerHeat = 0f; PlayerOverheated = false; } public static void RebuildEffects() { foreach (KeyValuePair state in States) { ClearEffects(state.Value); } } public static void CoolEverything() { foreach (KeyValuePair state in States) { state.Value.Heat = 0f; state.Value.Overheated = false; ClearEffects(state.Value); } PlayerHeat = 0f; PlayerOverheated = false; } private static float HeatPerShot(Gun gun) { float num = 1f / Prefs.ShotsToOverheat; if (!Prefs.ScaleByFireRate) { return num; } float num2 = GunUtil.RoundsPerSecond(gun); return num * Mathf.Sqrt(10f / num2); } private static void UpdateSmoke(GunState state) { if (!Prefs.Smoke) { StopSmoke(state); return; } float num = Mathf.InverseLerp(Prefs.SmokeThreshold, 1f, state.Heat); if (num <= 0f) { if (state.Smoke != null) { state.Smoke.SetRate(0f); if (state.Smoke.Finished()) { StopSmoke(state); } } return; } if (state.Smoke == null || !state.Smoke.Alive) { Transform val = GunUtil.Muzzle(state.Gun); if ((Object)(object)val == (Object)null) { return; } state.Smoke = Smoke.Attach(val); if (state.Smoke == null) { return; } } state.Smoke.SetRate(num * 55f * Prefs.SmokeAmount); } private static void UpdateGlow(GunState state, Vector3 viewer) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (!Prefs.Glow) { StopGlow(state); return; } if (state.Glow == null || !state.Glow.Alive) { if (state.Heat <= Prefs.GlowStartsAt) { return; } Transform val = GunUtil.Muzzle(state.Gun); if ((Object)(object)val == (Object)null) { return; } state.Glow = BarrelGlow.Attach(val); if (state.Glow == null) { return; } } state.Glow.Set(state.Heat, viewer); } private static Vector3 Viewer() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_001c: Unknown result type (might be due to invalid IL or missing references) try { Transform head = Player.Head; return ((Object)(object)head != (Object)null) ? head.position : Vector3.zero; } catch { return Vector3.zero; } } private static void StopSmoke(GunState state) { if (state.Smoke != null) { state.Smoke.Destroy(); state.Smoke = null; } } private static void StopGlow(GunState state) { if (state.Glow != null) { state.Glow.Destroy(); state.Glow = null; } } private static void ClearEffects(GunState state) { StopSmoke(state); StopGlow(state); } private static GunState Find(Gun gun) { try { GunState value; return States.TryGetValue(((Object)gun).GetInstanceID(), out value) ? value : null; } catch { return null; } } private static GunState Obtain(Gun gun) { try { int instanceID = ((Object)gun).GetInstanceID(); if (States.TryGetValue(instanceID, out var value)) { value.Gun = gun; return value; } if (!Prefs.AffectNpcGuns && !GunUtil.HeldByPlayer(gun)) { return null; } GunState gunState = new GunState { Gun = gun, LastSeen = Time.time }; States[instanceID] = gunState; return gunState; } catch { return null; } } private static string Name(Gun gun) { try { return ((Object)(object)gun != (Object)null && (Object)(object)((Component)gun).gameObject != (Object)null) ? ((Object)((Component)gun).gameObject).name : "gun"; } catch { return "gun"; } } } } namespace Overheat.Fx { internal sealed class BarrelGlow { private static Shader _shader; private static Texture2D _sprite; private static bool _failed; private GameObject _root; private Transform _card; private Renderer _renderer; private Material _material; private Light _light; public bool Alive => (Object)(object)_root != (Object)null; public static BarrelGlow Attach(Transform muzzle) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)muzzle == (Object)null || !Prepare()) { return null; } try { BarrelGlow barrelGlow = new BarrelGlow(); barrelGlow._root = new GameObject("OverheatGlow"); barrelGlow._root.transform.SetParent(muzzle, false); barrelGlow._root.transform.localPosition = Vector3.zero; barrelGlow._root.transform.localRotation = Quaternion.identity; GameObject val = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)val).name = "Card"; val.transform.SetParent(barrelGlow._root.transform, false); val.transform.localPosition = Vector3.zero; Collider component = val.GetComponent(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } barrelGlow._card = val.transform; barrelGlow._renderer = val.GetComponent(); barrelGlow._material = BuildMaterial(); barrelGlow._renderer.material = barrelGlow._material; barrelGlow._renderer.shadowCastingMode = (ShadowCastingMode)0; barrelGlow._renderer.receiveShadows = false; barrelGlow._renderer.lightProbeUsage = (LightProbeUsage)0; barrelGlow._renderer.reflectionProbeUsage = (ReflectionProbeUsage)0; if (Prefs.GlowLight) { barrelGlow._light = BuildLight(barrelGlow._root); } barrelGlow.Hide(); return barrelGlow; } catch (Exception ex) { Melon.Logger.Error("Creating the barrel glow failed: " + ex); return null; } } public void Set(float heat, Vector3 viewer) { //IL_002b: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_0170: 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_0188: Unknown result type (might be due to invalid IL or missing references) if (!Alive) { return; } float num = Mathf.InverseLerp(Prefs.GlowStartsAt, 1f, heat); if (num <= 0f) { Hide(); return; } try { Color val = HeatColour(num); float num2 = 1f + 0.05f * Mathf.Sin(Time.time * 9.3f); float num3 = Mathf.Lerp(0.02f, 0.054f, num) * Prefs.GlowSize * num2; if (!_renderer.enabled) { _renderer.enabled = true; } _card.localScale = new Vector3(num3, num3, 1f); Vector3 val2 = _card.position - viewer; if (((Vector3)(ref val2)).sqrMagnitude > 1E-06f) { _card.rotation = Quaternion.LookRotation(((Vector3)(ref val2)).normalized, Vector3.up); } if (_material.HasProperty("_BaseColor")) { _material.SetColor("_BaseColor", val); } if (_material.HasProperty("_Color")) { _material.SetColor("_Color", val); } if (_material.HasProperty("_EmissionColor")) { _material.SetColor("_EmissionColor", val); } if ((Object)(object)_light != (Object)null) { if (!((Behaviour)_light).enabled) { ((Behaviour)_light).enabled = true; } _light.color = new Color(val.r, val.g * 0.85f, val.b * 0.7f); _light.intensity = Mathf.Lerp(0.12f, 1.45f, num) * num2; _light.range = Mathf.Lerp(0.22f, 0.9f, num); } } catch { } } public void Destroy() { try { if ((Object)(object)_material != (Object)null) { Object.Destroy((Object)(object)_material); } if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } } catch { } _root = null; _card = null; _renderer = null; _material = null; _light = null; } public static void DisposeShared() { try { if ((Object)(object)_sprite != (Object)null) { Object.Destroy((Object)(object)_sprite); } } catch { } _sprite = null; _shader = null; _failed = false; } private void Hide() { try { if ((Object)(object)_renderer != (Object)null && _renderer.enabled) { _renderer.enabled = false; } if ((Object)(object)_light != (Object)null && ((Behaviour)_light).enabled) { ((Behaviour)_light).enabled = false; } } catch { } } private static Color HeatColour(float t) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0037: Unknown result type (might be due to invalid IL or missing references) if (t < 0.5f) { return Color.Lerp(new Color(0.38f, 0.02f, 0f), new Color(1f, 0.13f, 0.02f), t / 0.5f); } return Color.Lerp(new Color(1f, 0.13f, 0.02f), new Color(1f, 0.54f, 0.17f), (t - 0.5f) / 0.5f); } private static Light BuildLight(GameObject root) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) try { Light val = root.AddComponent(); val.type = (LightType)2; val.range = 0.4f; val.intensity = 0.2f; val.color = new Color(1f, 0.3f, 0.08f); val.bounceIntensity = 0f; try { val.shadows = (LightShadows)0; } catch { } return val; } catch { return null; } } private static Material BuildMaterial() { //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_0013: Expected O, but got Unknown Material val = new Material(_shader) { hideFlags = (HideFlags)61 }; if (val.HasProperty("_BaseMap")) { val.SetTexture("_BaseMap", (Texture)(object)_sprite); } if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", (Texture)(object)_sprite); } val.SetFloat("_Surface", 1f); val.SetFloat("_Blend", 2f); val.SetFloat("_ZWrite", 0f); val.SetFloat("_Cull", 0f); if (val.HasProperty("_SrcBlend")) { val.SetFloat("_SrcBlend", 1f); } if (val.HasProperty("_DstBlend")) { val.SetFloat("_DstBlend", 1f); } val.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); val.EnableKeyword("_ALPHAPREMULTIPLY_ON"); val.EnableKeyword("_EMISSION"); val.renderQueue = 3200; return val; } private static bool Prepare() { if (_failed) { return false; } if ((Object)(object)_shader != (Object)null && (Object)(object)_sprite != (Object)null) { return true; } try { string[] array = new string[6] { "Universal Render Pipeline/Particles/Unlit", "Universal Render Pipeline/Unlit", "Particles/Standard Unlit", "Legacy Shaders/Particles/Additive", "Sprites/Default", "UI/Default" }; for (int i = 0; i < array.Length; i++) { if (!((Object)(object)_shader == (Object)null)) { break; } _shader = Shader.Find(array[i]); } if ((Object)(object)_shader == (Object)null) { _failed = true; Melon.Logger.Error("No usable shader for the barrel glow."); return false; } _sprite = Ember(); return true; } catch (Exception ex) { _failed = true; Melon.Logger.Error("Preparing the barrel glow failed: " + ex); return false; } } private static Texture2D Ember() { //IL_00cc: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) 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; float num4 = Mathf.Clamp01(Mathf.Sqrt(num2 * num2 + num3 * num3)); float num5 = Mathf.Pow(1f - num4, 2.4f); float num6 = Mathf.Clamp01(1f - num4 * 3.4f) * 0.55f; byte b = (byte)(Mathf.Clamp01(num5 + num6) * 255f); ((Il2CppArrayBase)(object)val)[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b); } } Texture2D val2 = new Texture2D(64, 64, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; val2.SetPixels32(val); val2.Apply(false, false); return val2; } } internal sealed class Smoke { private static Material _shared; private static Texture2D _sprite; private static bool _materialFailed; private GameObject _root; private ParticleSystem _system; public bool Alive { get { if ((Object)(object)_root != (Object)null) { return (Object)(object)_system != (Object)null; } return false; } } public static Smoke Attach(Transform muzzle) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0050: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_011c: 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_012b: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Expected O, but got Unknown //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Expected O, but got Unknown //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Expected O, but got Unknown //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Expected O, but got Unknown if ((Object)(object)muzzle == (Object)null) { return null; } Material val = SharedMaterial(); if ((Object)(object)val == (Object)null) { return null; } try { Smoke smoke = new Smoke(); smoke._root = new GameObject("OverheatSmoke"); smoke._root.transform.SetParent(muzzle, false); smoke._root.transform.localPosition = Vector3.zero; smoke._root.transform.localRotation = Quaternion.identity; ParticleSystem val2 = (smoke._system = smoke._root.AddComponent()); MainModule main = val2.main; main.loop = true; main.playOnAwake = false; main.duration = 4f; main.maxParticles = 140; main.simulationSpace = (ParticleSystemSimulationSpace)1; main.startLifetime = new MinMaxCurve(1.1f, 2f); main.startSpeed = new MinMaxCurve(0.16f, 0.4f); main.startSize = new MinMaxCurve(0.018f, 0.042f); main.startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f); main.startColor = new MinMaxGradient(new Color(0.78f, 0.78f, 0.8f, 0.38f)); main.gravityModifier = new MinMaxCurve(-0.025f); EmissionModule emission = val2.emission; emission.enabled = true; emission.rateOverTime = new MinMaxCurve(0f); ShapeModule shape = val2.shape; shape.shapeType = (ParticleSystemShapeType)4; shape.angle = 11f; shape.radius = 0.004f; SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime; sizeOverLifetime.enabled = true; sizeOverLifetime.size = new MinMaxCurve(1f, AnimationCurve.EaseInOut(0f, 0.35f, 1f, 1f)); ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime; colorOverLifetime.enabled = true; colorOverLifetime.color = new MinMaxGradient(FadeGradient()); RotationOverLifetimeModule rotationOverLifetime = val2.rotationOverLifetime; rotationOverLifetime.enabled = true; rotationOverLifetime.z = new MinMaxCurve(-0.45f, 0.45f); NoiseModule noise = val2.noise; noise.enabled = true; noise.quality = (ParticleSystemNoiseQuality)1; noise.strength = new MinMaxCurve(0.055f); noise.frequency = 0.45f; noise.damping = true; noise.scrollSpeed = new MinMaxCurve(0.22f); ParticleSystemRenderer val3 = smoke._root.GetComponent(); if ((Object)(object)val3 == (Object)null) { val3 = smoke._root.AddComponent(); } val3.renderMode = (ParticleSystemRenderMode)0; ((Renderer)val3).sharedMaterial = val; val3.sortMode = (ParticleSystemSortMode)1; ((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val3).receiveShadows = false; ((Renderer)val3).lightProbeUsage = (LightProbeUsage)0; ((Renderer)val3).reflectionProbeUsage = (ReflectionProbeUsage)0; val2.Play(); return smoke; } catch (Exception ex) { Melon.Logger.Error("Creating the smoke emitter failed: " + ex); return null; } } public void SetRate(float rate) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if (!Alive) { return; } try { _system.emission.rateOverTime = new MinMaxCurve(Mathf.Max(0f, rate)); if (rate > 0f && !_system.isPlaying) { _system.Play(); } } catch { } } public bool Finished() { if (!Alive) { return true; } try { return _system.particleCount <= 0; } catch { return true; } } public void Destroy() { try { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } } catch { } _root = null; _system = null; } public static void DisposeShared() { try { if ((Object)(object)_shared != (Object)null) { Object.Destroy((Object)(object)_shared); } if ((Object)(object)_sprite != (Object)null) { Object.Destroy((Object)(object)_sprite); } } catch { } _shared = null; _sprite = null; _materialFailed = false; } private static Gradient FadeGradient() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_004d: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown Gradient val = new Gradient(); val.SetKeys(new Il2CppStructArray(2L) { [0] = new GradientColorKey(new Color(0.9f, 0.9f, 0.92f), 0f), [1] = new GradientColorKey(new Color(0.48f, 0.48f, 0.51f), 1f) }, new Il2CppStructArray(3L) { [0] = new GradientAlphaKey(0f, 0f), [1] = new GradientAlphaKey(1f, 0.16f), [2] = new GradientAlphaKey(0f, 1f) }); return val; } private static Material SharedMaterial() { //IL_00a7: 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_00b5: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_shared != (Object)null) { return _shared; } if (_materialFailed) { return null; } try { Shader val = null; string[] array = new string[6] { "Universal Render Pipeline/Particles/Unlit", "Universal Render Pipeline/Unlit", "Particles/Standard Unlit", "Legacy Shaders/Particles/Alpha Blended", "Sprites/Default", "UI/Default" }; for (int i = 0; i < array.Length; i++) { if (!((Object)(object)val == (Object)null)) { break; } val = Shader.Find(array[i]); } if ((Object)(object)val == (Object)null) { _materialFailed = true; Melon.Logger.Error("No usable particle shader found; smoke disabled."); return null; } _sprite = Puff(); Material val2 = new Material(val) { hideFlags = (HideFlags)61 }; if (val2.HasProperty("_BaseMap")) { val2.SetTexture("_BaseMap", (Texture)(object)_sprite); } if (val2.HasProperty("_MainTex")) { val2.SetTexture("_MainTex", (Texture)(object)_sprite); } if (val2.HasProperty("_BaseColor")) { val2.SetColor("_BaseColor", Color.white); } if (val2.HasProperty("_Color")) { val2.SetColor("_Color", Color.white); } val2.SetFloat("_Surface", 1f); val2.SetFloat("_Blend", 0f); val2.SetFloat("_ZWrite", 0f); val2.SetFloat("_Cull", 0f); val2.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); val2.renderQueue = 3100; _shared = val2; return _shared; } catch (Exception ex) { _materialFailed = true; Melon.Logger.Error("Creating the smoke material failed: " + ex); return null; } } private static Texture2D Puff() { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00ca: 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_00da: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) 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; float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3); float num5 = Mathf.Clamp01(1f - num4); num5 = num5 * num5 * (3f - 2f * num5); ((Il2CppArrayBase)(object)val)[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num5 * 255f)); } } Texture2D val2 = new Texture2D(64, 64, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; val2.SetPixels32(val); val2.Apply(false, false); return val2; } } } namespace Overheat.Config { internal static class Prefs { private static MelonPreferences_Category _category; private static MelonPreferences_Entry _enabled; private static MelonPreferences_Entry _shotsToOverheat; private static MelonPreferences_Entry _coolPerSecond; private static MelonPreferences_Entry _resumeAt; private static MelonPreferences_Entry _scaleByFireRate; private static MelonPreferences_Entry _smoke; private static MelonPreferences_Entry _smokeThreshold; private static MelonPreferences_Entry _smokeAmount; private static MelonPreferences_Entry _glow; private static MelonPreferences_Entry _glowStartsAt; private static MelonPreferences_Entry _glowSize; private static MelonPreferences_Entry _glowLight; private static MelonPreferences_Entry _showHud; private static MelonPreferences_Entry _showHeatBar; private static MelonPreferences_Entry _barThreshold; private static MelonPreferences_Entry _hudScale; private static MelonPreferences_Entry _hudDistance; private static MelonPreferences_Entry _hudHeight; private static MelonPreferences_Entry _flashHz; private static MelonPreferences_Entry _affectNpcGuns; private static MelonPreferences_Entry _logEvents; public static bool Enabled { get { return _enabled?.Value ?? true; } set { if (_enabled != null) { _enabled.Value = value; } } } public static float ShotsToOverheat { get { return Mathf.Clamp(_shotsToOverheat?.Value ?? 35f, 3f, 300f); } set { if (_shotsToOverheat != null) { _shotsToOverheat.Value = value; } } } public static float CoolPerSecond { get { return Mathf.Clamp(_coolPerSecond?.Value ?? 0.22f, 0.01f, 3f); } set { if (_coolPerSecond != null) { _coolPerSecond.Value = value; } } } public static float ResumeAt { get { return Mathf.Clamp(_resumeAt?.Value ?? 0.35f, 0f, 0.95f); } set { if (_resumeAt != null) { _resumeAt.Value = value; } } } public static bool ScaleByFireRate { get { return _scaleByFireRate?.Value ?? true; } set { if (_scaleByFireRate != null) { _scaleByFireRate.Value = value; } } } public static bool Smoke { get { return _smoke?.Value ?? true; } set { if (_smoke != null) { _smoke.Value = value; } } } public static float SmokeThreshold { get { return Mathf.Clamp01(_smokeThreshold?.Value ?? 0.3f); } set { if (_smokeThreshold != null) { _smokeThreshold.Value = value; } } } public static float SmokeAmount { get { return Mathf.Clamp(_smokeAmount?.Value ?? 1f, 0.1f, 4f); } set { if (_smokeAmount != null) { _smokeAmount.Value = value; } } } public static bool Glow { get { return _glow?.Value ?? true; } set { if (_glow != null) { _glow.Value = value; } } } public static float GlowStartsAt { get { return Mathf.Clamp01(_glowStartsAt?.Value ?? 0.45f); } set { if (_glowStartsAt != null) { _glowStartsAt.Value = value; } } } public static float GlowSize { get { return Mathf.Clamp(_glowSize?.Value ?? 1f, 0.2f, 4f); } set { if (_glowSize != null) { _glowSize.Value = value; } } } public static bool GlowLight { get { return _glowLight?.Value ?? true; } set { if (_glowLight != null) { _glowLight.Value = value; } } } public static bool ShowHud { get { return _showHud?.Value ?? true; } set { if (_showHud != null) { _showHud.Value = value; } } } public static bool ShowHeatBar { get { return _showHeatBar?.Value ?? true; } set { if (_showHeatBar != null) { _showHeatBar.Value = value; } } } public static float BarThreshold { get { return Mathf.Clamp01(_barThreshold?.Value ?? 0.35f); } set { if (_barThreshold != null) { _barThreshold.Value = value; } } } public static float HudScale { get { return Mathf.Clamp(_hudScale?.Value ?? 1f, 0.3f, 3f); } set { if (_hudScale != null) { _hudScale.Value = value; } } } public static float HudDistance { get { return Mathf.Clamp(_hudDistance?.Value ?? 0.55f, 0.25f, 2f); } set { if (_hudDistance != null) { _hudDistance.Value = value; } } } public static float HudHeight { get { return Mathf.Clamp(_hudHeight?.Value ?? (-0.12f), -1f, 1f); } set { if (_hudHeight != null) { _hudHeight.Value = value; } } } public static float FlashHz { get { return Mathf.Clamp(_flashHz?.Value ?? 2.5f, 0.2f, 6f); } set { if (_flashHz != null) { _flashHz.Value = value; } } } public static bool AffectNpcGuns { get { return _affectNpcGuns?.Value ?? false; } set { if (_affectNpcGuns != null) { _affectNpcGuns.Value = value; } } } public static bool LogEvents { get { return _logEvents?.Value ?? false; } set { if (_logEvents != null) { _logEvents.Value = value; } } } public static void Load() { _category = MelonPreferences.CreateCategory("Overheat"); _enabled = _category.CreateEntry("Enabled", true, "Enabled", (string)null, false, false, (ValueValidator)null, (string)null); _shotsToOverheat = _category.CreateEntry("ShotsToOverheat", 35f, "Shots To Overheat", (string)null, false, false, (ValueValidator)null, (string)null); _coolPerSecond = _category.CreateEntry("CoolPerSecond", 0.22f, "Cool Per Second", (string)null, false, false, (ValueValidator)null, (string)null); _resumeAt = _category.CreateEntry("ResumeAt", 0.35f, "Resume At Heat", (string)null, false, false, (ValueValidator)null, (string)null); _scaleByFireRate = _category.CreateEntry("ScaleByFireRate", true, "Scale By Fire Rate", (string)null, false, false, (ValueValidator)null, (string)null); _smoke = _category.CreateEntry("Smoke", true, "Smoke", (string)null, false, false, (ValueValidator)null, (string)null); _smokeThreshold = _category.CreateEntry("SmokeThreshold", 0.3f, "Smoke Starts At", (string)null, false, false, (ValueValidator)null, (string)null); _smokeAmount = _category.CreateEntry("SmokeAmount", 1f, "Smoke Amount", (string)null, false, false, (ValueValidator)null, (string)null); _glow = _category.CreateEntry("Glow", true, "Barrel Glow", (string)null, false, false, (ValueValidator)null, (string)null); _glowStartsAt = _category.CreateEntry("GlowStartsAt", 0.45f, "Glow Starts At", (string)null, false, false, (ValueValidator)null, (string)null); _glowSize = _category.CreateEntry("GlowSize", 1f, "Glow Size", (string)null, false, false, (ValueValidator)null, (string)null); _glowLight = _category.CreateEntry("GlowLight", true, "Glow Casts Light", (string)null, false, false, (ValueValidator)null, (string)null); _showHud = _category.CreateEntry("ShowHud", true, "Show Warning", (string)null, false, false, (ValueValidator)null, (string)null); _showHeatBar = _category.CreateEntry("ShowHeatBar", true, "Show Heat Bar", (string)null, false, false, (ValueValidator)null, (string)null); _barThreshold = _category.CreateEntry("BarThreshold", 0.35f, "Bar Appears At", (string)null, false, false, (ValueValidator)null, (string)null); _hudScale = _category.CreateEntry("HudScale", 1f, "HUD Scale", (string)null, false, false, (ValueValidator)null, (string)null); _hudDistance = _category.CreateEntry("HudDistance", 0.55f, "HUD Distance", (string)null, false, false, (ValueValidator)null, (string)null); _hudHeight = _category.CreateEntry("HudHeight", -0.12f, "HUD Height", (string)null, false, false, (ValueValidator)null, (string)null); _flashHz = _category.CreateEntry("FlashHz", 2.5f, "Flash Rate (Hz)", (string)null, false, false, (ValueValidator)null, (string)null); _affectNpcGuns = _category.CreateEntry("AffectNpcGuns", false, "Affect NPC Guns", (string)null, false, false, (ValueValidator)null, (string)null); _logEvents = _category.CreateEntry("LogEvents", false, "Log Events", (string)null, false, false, (ValueValidator)null, (string)null); } public static void Save() { try { MelonPreferences_Category category = _category; if (category != null) { category.SaveToFile(false); } } catch { } } } }