Decompiled source of HoldfastExtras v1.0.4
plugins/HoldfastExtras/HoldfastExtras.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Configuration; using DarkTonic.MasterAudio; using HarmonyLib; using HoldfastDiscordStatus; using HoldfastGame; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Networking; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("HoldfastExtras")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("HoldfastExtras")] [assembly: AssemblyTitle("HoldfastExtras")] [assembly: AssemblyVersion("1.0.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 HoldfastExtras { public class FxSim { private struct Flake { public Vector2 p; public float z; public float phase; public float freq; public float rot; public float spin; public int sprite; } private enum Kind { Peony, Willow, Ring, Crossette, Crackle } private class Shell { public Vector2 p; public Vector2 v; public float trail; public Kind kind; public Color col; } private struct Spark { public Vector2 p; public Vector2 v; public float life; public float max; public float drag; public float grav; public float size; public float trail; public float phase; public Color col; public bool willow; public bool crackle; public bool split; public bool ember; public Vector2[] hist; public int hn; public float ht; } private struct Ember { public Vector2 p; public Vector2 v; public float life; public float max; public float size; public float seed; } public readonly List<FxQuad> alphaQuads = new List<FxQuad>(1024); public readonly List<FxQuad> glowQuads = new List<FxQuad>(4096); private readonly Random rng = new Random(); private float W; private float H; private float k; private bool init; private readonly List<Flake> flakes = new List<Flake>(); private readonly List<Vector4> bokeh = new List<Vector4>(); private readonly List<Shell> shells = new List<Shell>(); private readonly List<Spark> sparks = new List<Spark>(2048); private readonly List<Vector4> flashes = new List<Vector4>(); private readonly List<Color> flashCols = new List<Color>(); private float launchTimer; private const int TrailLen = 9; private static readonly Color[] NewYear = (Color[])(object)new Color[6] { new Color(1f, 0.78f, 0.36f), new Color(0.95f, 0.96f, 1f), new Color(1f, 0.28f, 0.3f), new Color(0.35f, 1f, 0.6f), new Color(0.38f, 0.62f, 1f), new Color(0.78f, 0.48f, 1f) }; private static readonly Color[] July = (Color[])(object)new Color[3] { new Color(1f, 0.18f, 0.2f), new Color(1f, 1f, 1f), new Color(0.3f, 0.45f, 1f) }; private readonly List<Ember> embers = new List<Ember>(); private float R() { return (float)rng.NextDouble(); } private float R(float a, float b) { return a + (b - a) * (float)rng.NextDouble(); } public void Reset() { flakes.Clear(); sparks.Clear(); shells.Clear(); embers.Clear(); flashes.Clear(); bokeh.Clear(); init = false; launchTimer = 0.4f; } public void Step(string season, float dt, float t, float w, float h, float amount) { alphaQuads.Clear(); glowQuads.Clear(); if (season != null) { if (w != W || h != H) { W = w; H = h; k = h / 1080f; init = false; } if (season == "Winter snow") { Snow(dt, t, amount); } else if (season == "Halloween embers") { Embers(dt, t, amount); } else { Fireworks(dt, t, amount, season == "4th of July fireworks"); } init = true; } } private static Vector2 Dir(Vector2 v) { //IL_0016: 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_0010: Unknown result type (might be due to invalid IL or missing references) float magnitude = ((Vector2)(ref v)).magnitude; if (!(magnitude > 0.0001f)) { return Vector2.right; } return v / magnitude; } private void Quad(List<FxQuad> l, Vector2 p, float wdt, float hgt, Vector2 dir, Color c, int sprite) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) l.Add(new FxQuad { pos = p, size = new Vector2(wdt, hgt), dir = dir, color = c, sprite = sprite }); } private static Vector2 Rot(float a) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) return new Vector2(Mathf.Cos(a), Mathf.Sin(a)); } private Flake NewFlake(bool anywhere) { //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) float z = Mathf.Pow(R(), 1.7f); return new Flake { p = new Vector2(R(-0.05f, 1.05f) * W, anywhere ? (R() * H) : (H + R(10f, 60f) * k)), z = z, phase = R(0f, 6.283f), freq = R(0.6f, 1.4f), rot = R(0f, 6.283f), spin = R(-1.2f, 1.2f), sprite = ((R() < 0.5f) ? 2 : 4) }; } private void Snow(float dt, float t, float amount) { //IL_0098: 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_024f: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_034e: 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_0573: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_0594: Unknown result type (might be due to invalid IL or missing references) //IL_059b: Unknown result type (might be due to invalid IL or missing references) //IL_05a2: Unknown result type (might be due to invalid IL or missing references) //IL_05bb: Unknown result type (might be due to invalid IL or missing references) //IL_051f: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.RoundToInt(650f * amount); if (!init) { flakes.Clear(); for (int i = 0; i < num; i++) { flakes.Add(NewFlake(anywhere: true)); } bokeh.Clear(); for (int j = 0; j < 4; j++) { bokeh.Add(new Vector4(R() * W, R() * H, R(50f, 90f) * this.k, R(0f, 6.283f))); } } while (flakes.Count < num) { flakes.Add(NewFlake(anywhere: false)); } while (flakes.Count > num) { flakes.RemoveAt(flakes.Count - 1); } float num2 = (Mathf.PerlinNoise(t * 0.06f, 0.37f) - 0.5f) * 140f * this.k; float num3 = Mathf.Pow(Mathf.Max(0f, Mathf.Sin(t * 0.21f) * Mathf.Sin(t * 0.13f + 1f)), 3f) * 90f * this.k; num2 += num3; for (int k = 0; k < flakes.Count; k++) { Flake value = flakes[k]; float num4 = Mathf.Lerp(28f, 135f, value.z) * this.k; float num5 = Mathf.Sin(value.phase + t * value.freq) * Mathf.Lerp(8f, 26f, value.z) * this.k; value.p.x += (num2 * Mathf.Lerp(0.35f, 1f, value.z) + num5 * value.freq) * dt; value.p.y -= num4 * dt; value.rot += value.spin * dt; if (value.p.y < -30f * this.k) { value = NewFlake(anywhere: false); } if (value.p.x < -40f * this.k) { value.p.x += W + 80f * this.k; } else if (value.p.x > W + 40f * this.k) { value.p.x -= W + 80f * this.k; } flakes[k] = value; float num6 = Mathf.Lerp(0.5f, 1f, value.z); num6 *= Mathf.Clamp01((H + 30f * this.k - value.p.y) / (60f * this.k)); Color c = Color.Lerp(new Color(0.8f, 0.86f, 0.97f), Color.white, value.z); c.a = num6; float num7 = ((value.z > 0.78f) ? (Mathf.Lerp(16f, 34f, (value.z - 0.78f) / 0.22f) * this.k) : (Mathf.Lerp(3.5f, 9f, value.z / 0.78f) * this.k)); Quad(alphaQuads, value.p + new Vector2(0.6f, -0.8f) * this.k, num7 * 2.1f, num7 * 2.1f, Vector2.right, new Color(0.05f, 0.07f, 0.1f, 0.16f * num6), 0); if (value.z > 0.78f) { Quad(alphaQuads, value.p, num7, num7, Rot(value.rot), c, value.sprite); } else { Quad(alphaQuads, value.p, num7, num7, Vector2.right, c, 1); } } for (int l = 0; l < bokeh.Count; l++) { Vector4 val = bokeh[l]; val.y -= 170f * this.k * dt; val.x += (num2 * 1.3f + Mathf.Sin(t * 0.7f + val.w) * 30f * this.k) * dt; if (val.y < 0f - val.z) { ((Vector4)(ref val))..ctor(R() * W, H + val.z + R(0f, 300f) * this.k, R(50f, 90f) * this.k, R(0f, 6.283f)); } bokeh[l] = val; Quad(alphaQuads, new Vector2(val.x, val.y), val.z, val.z, Vector2.right, new Color(1f, 1f, 1f, 0.1f), 0); } } private void Launch(bool july) { //IL_00b0: 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_00e6: 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) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) float num = 380f * k; float num2 = R(0.52f, 0.86f) * H; Color[] array = (july ? July : NewYear); float num3 = R(); Kind kind = ((!(num3 < 0.42f)) ? ((num3 < 0.62f) ? Kind.Willow : ((num3 < 0.78f) ? Kind.Ring : ((num3 < 0.9f) ? Kind.Crossette : Kind.Crackle))) : Kind.Peony); Color col = (Color)(kind switch { Kind.Crackle => new Color(1f, 0.92f, 0.7f), Kind.Willow => new Color(1f, 0.72f, 0.32f), _ => array[rng.Next(array.Length)], }); shells.Add(new Shell { p = new Vector2(R(0.12f, 0.88f) * W, -20f * k), v = new Vector2(R(-40f, 40f) * k, Mathf.Sqrt(2f * num * num2)), kind = kind, col = col }); } private void Burst(Shell s) { //IL_004e: 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_00d5: 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_00f4: 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_011a: 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) //IL_0122: 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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: 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_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) float num = R(380f, 480f) * this.k; flashes.Add(new Vector4(s.p.x, s.p.y, 0f, (s.kind == Kind.Willow) ? 0.5f : 0.8f)); flashCols.Add(s.col); switch (s.kind) { case Kind.Ring: { int num2 = 64; float num3 = R(0.25f, 1f); float num4 = R(0f, 6.283f); Vector2 val = default(Vector2); for (int j = 0; j < num2; j++) { float num5 = (float)j / (float)num2 * 6.283f; ((Vector2)(ref val))..ctor(Mathf.Cos(num5), Mathf.Sin(num5) * num3); ((Vector2)(ref val))..ctor(val.x * Mathf.Cos(num4) - val.y * Mathf.Sin(num4), val.x * Mathf.Sin(num4) + val.y * Mathf.Cos(num4)); AddSpark(s.p, val * num * R(0.97f, 1.03f), s.col, R(1.5f, 1.9f), 1.3f, 70f, 1f, willow: false, crackle: false, split: false); } for (int k = 0; k < 18; k++) { AddSpark(s.p, Sphere() * num * 0.35f, Color.white, R(0.9f, 1.2f), 2f, 60f, 0.8f, willow: false, crackle: false, split: false); } break; } case Kind.Crossette: { int num2 = 12; for (int l = 0; l < num2; l++) { AddSpark(s.p, Rot((float)l / (float)num2 * 6.283f + R(0f, 0.2f)) * num * 0.8f, s.col, 0.75f, 1.2f, 80f, 1.3f, willow: false, crackle: false, split: true); } break; } default: { bool flag = s.kind == Kind.Willow; bool crackle = s.kind == Kind.Crackle; int num2 = (flag ? 80 : 100); for (int i = 0; i < num2; i++) { AddSpark(s.p, Sphere() * num * R(0.9f, 1.05f) * (flag ? 0.85f : 1f), s.col, flag ? R(2.8f, 3.6f) : R(1.5f, 2.2f), flag ? 1.9f : 1.35f, flag ? 30f : 70f, flag ? 0.9f : 1f, flag, crackle, split: false); } break; } } } private Vector2 Sphere() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) float num = R(-1f, 1f); float num2 = R(0f, 6.283f); float num3 = Mathf.Sqrt(1f - num * num); return new Vector2(num3 * Mathf.Cos(num2), num3 * Mathf.Sin(num2)); } private void AddSpark(Vector2 p, Vector2 v, Color c, float life, float drag, float grav, float size, bool willow, bool crackle, bool split) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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) if (sparks.Count <= 2600) { sparks.Add(new Spark { p = p, v = v, col = c, life = 0f, max = life, drag = drag, grav = grav * k, size = size, willow = willow, crackle = crackle, split = split, phase = R(0f, 6.283f), hist = (Vector2[])(object)new Vector2[9] }); } } private void Fireworks(float dt, float t, float amount, bool july) { //IL_009b: 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_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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_0131: 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) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_08d5: Unknown result type (might be due to invalid IL or missing references) //IL_08da: Unknown result type (might be due to invalid IL or missing references) //IL_08f0: Unknown result type (might be due to invalid IL or missing references) //IL_08f7: Unknown result type (might be due to invalid IL or missing references) //IL_08fe: Unknown result type (might be due to invalid IL or missing references) //IL_0914: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_04a5: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_0941: Unknown result type (might be due to invalid IL or missing references) //IL_094e: Unknown result type (might be due to invalid IL or missing references) //IL_0958: Unknown result type (might be due to invalid IL or missing references) //IL_095d: Unknown result type (might be due to invalid IL or missing references) //IL_0975: Unknown result type (might be due to invalid IL or missing references) //IL_097c: Unknown result type (might be due to invalid IL or missing references) //IL_0983: Unknown result type (might be due to invalid IL or missing references) //IL_09a0: Unknown result type (might be due to invalid IL or missing references) //IL_09a5: Unknown result type (might be due to invalid IL or missing references) //IL_09ad: Unknown result type (might be due to invalid IL or missing references) //IL_09af: Unknown result type (might be due to invalid IL or missing references) //IL_09b3: Unknown result type (might be due to invalid IL or missing references) //IL_09c0: Unknown result type (might be due to invalid IL or missing references) //IL_09e0: Unknown result type (might be due to invalid IL or missing references) //IL_09e7: Unknown result type (might be due to invalid IL or missing references) //IL_09ee: Unknown result type (might be due to invalid IL or missing references) //IL_0a0b: Unknown result type (might be due to invalid IL or missing references) //IL_0a10: Unknown result type (might be due to invalid IL or missing references) //IL_0a28: Unknown result type (might be due to invalid IL or missing references) //IL_0a2f: Unknown result type (might be due to invalid IL or missing references) //IL_0a36: Unknown result type (might be due to invalid IL or missing references) //IL_0a53: Unknown result type (might be due to invalid IL or missing references) //IL_0a58: Unknown result type (might be due to invalid IL or missing references) //IL_063f: Unknown result type (might be due to invalid IL or missing references) //IL_0646: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Unknown result type (might be due to invalid IL or missing references) //IL_0662: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034a: 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_0358: Unknown result type (might be due to invalid IL or missing references) //IL_066d: Unknown result type (might be due to invalid IL or missing references) //IL_0671: Unknown result type (might be due to invalid IL or missing references) //IL_0685: Unknown result type (might be due to invalid IL or missing references) //IL_068a: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Unknown result type (might be due to invalid IL or missing references) //IL_06a2: Unknown result type (might be due to invalid IL or missing references) //IL_0739: Unknown result type (might be due to invalid IL or missing references) //IL_073e: Unknown result type (might be due to invalid IL or missing references) //IL_06e8: Unknown result type (might be due to invalid IL or missing references) //IL_06f1: Unknown result type (might be due to invalid IL or missing references) //IL_06f6: Unknown result type (might be due to invalid IL or missing references) //IL_070c: Unknown result type (might be due to invalid IL or missing references) //IL_0711: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_0580: Unknown result type (might be due to invalid IL or missing references) //IL_059a: Unknown result type (might be due to invalid IL or missing references) //IL_059f: Unknown result type (might be due to invalid IL or missing references) //IL_0751: Unknown result type (might be due to invalid IL or missing references) //IL_0756: Unknown result type (might be due to invalid IL or missing references) //IL_0758: Unknown result type (might be due to invalid IL or missing references) //IL_075a: Unknown result type (might be due to invalid IL or missing references) //IL_075c: Unknown result type (might be due to invalid IL or missing references) //IL_0761: Unknown result type (might be due to invalid IL or missing references) //IL_078e: Unknown result type (might be due to invalid IL or missing references) //IL_0790: Unknown result type (might be due to invalid IL or missing references) //IL_0826: Unknown result type (might be due to invalid IL or missing references) //IL_083b: Unknown result type (might be due to invalid IL or missing references) //IL_0840: Unknown result type (might be due to invalid IL or missing references) //IL_0848: Unknown result type (might be due to invalid IL or missing references) //IL_084a: Unknown result type (might be due to invalid IL or missing references) //IL_0865: Unknown result type (might be due to invalid IL or missing references) //IL_0892: Unknown result type (might be due to invalid IL or missing references) //IL_0897: Unknown result type (might be due to invalid IL or missing references) //IL_0805: Unknown result type (might be due to invalid IL or missing references) //IL_0807: Unknown result type (might be due to invalid IL or missing references) //IL_07c8: Unknown result type (might be due to invalid IL or missing references) //IL_07ca: Unknown result type (might be due to invalid IL or missing references) //IL_07cc: Unknown result type (might be due to invalid IL or missing references) //IL_07d6: Unknown result type (might be due to invalid IL or missing references) //IL_07f4: Unknown result type (might be due to invalid IL or missing references) //IL_07f8: Unknown result type (might be due to invalid IL or missing references) //IL_07fd: Unknown result type (might be due to invalid IL or missing references) launchTimer -= dt; if (launchTimer <= 0f) { Launch(july); if (R() < 0.25f) { Launch(july); } launchTimer = R(0.7f, 1.8f) / Mathf.Max(0.25f, amount); } float num = 380f * k; for (int num2 = shells.Count - 1; num2 >= 0; num2--) { Shell shell = shells[num2]; shell.v.y -= num * dt; shell.p += shell.v * dt; shell.trail -= dt; if (shell.trail <= 0f) { shell.trail = 0.018f; sparks.Add(new Spark { p = shell.p - shell.v * 0.01f, v = new Vector2(R(-12f, 12f), R(-30f, -5f)) * k, col = new Color(1f, 0.7f, 0.35f), max = R(0.35f, 0.6f), drag = 2f, grav = 40f * k, size = 0.45f, ember = true }); } Vector2 dir = Dir(shell.v); Quad(glowQuads, shell.p, 30f * k, 5f * k, dir, new Color(1f, 0.85f, 0.6f, 0.95f), 3); Quad(glowQuads, shell.p, 22f * k, 22f * k, Vector2.right, new Color(1f, 0.7f, 0.4f, 0.35f), 0); if (shell.v.y <= 25f * k) { Burst(shell); shells.RemoveAt(num2); } } List<Spark> list = new List<Spark>(); for (int num3 = sparks.Count - 1; num3 >= 0; num3--) { Spark value = sparks[num3]; value.life += dt; if (value.life >= value.max) { if (value.split) { for (int i = 0; i < 4; i++) { list.Add(new Spark { p = value.p, v = Rot((float)i * 1.5708f + 0.785f + R(-0.1f, 0.1f)) * 220f * k + value.v * 0.3f, col = value.col, max = R(0.8f, 1.1f), drag = 1.6f, grav = 70f * k, size = 0.9f, hist = (Vector2[])(object)new Vector2[9] }); } } sparks.RemoveAt(num3); } else { ref Vector2 v = ref value.v; v *= Mathf.Exp((0f - value.drag) * dt); value.v.y -= value.grav * dt; ref Vector2 p = ref value.p; p += value.v * dt; if (value.willow) { value.trail -= dt; if (value.trail <= 0f) { value.trail = 0.05f; list.Add(new Spark { p = value.p, v = new Vector2(R(-6f, 6f), R(-20f, -8f)) * k, col = new Color(1f, 0.62f, 0.25f), max = R(0.7f, 1.1f), drag = 1f, grav = 25f * k, size = 0.4f, ember = true }); } } if (value.hist != null) { value.ht -= dt; if (value.ht <= 0f) { value.ht = 0.028f; for (int num4 = value.hist.Length - 1; num4 > 0; num4--) { value.hist[num4] = value.hist[num4 - 1]; } value.hist[0] = value.p; if (value.hn < value.hist.Length) { value.hn++; } } } sparks[num3] = value; float num5 = value.life / value.max; float num6 = 1f - Mathf.SmoothStep(0.55f, 1f, num5); if (value.crackle && num5 > 0.55f) { num6 *= ((Mathf.Sin(value.life * 55f + value.phase) > 0.2f) ? 1f : 0.12f); } Color val = Color.Lerp(Color.white, value.col, Mathf.Clamp01(value.life / 0.16f)); if (num5 > 0.6f) { val = Color.Lerp(val, value.col * new Color(1f, 0.6f, 0.4f), (num5 - 0.6f) / 0.4f); } val.a = num6; _ = ((Vector2)(ref value.v)).magnitude; if (value.ember) { float num7 = 3.2f * k * value.size * 2f; Quad(glowQuads, value.p, num7, num7, Vector2.right, val * new Color(1f, 1f, 1f, 0.8f), 1); } else { float num8 = 5.5f * k * value.size; Vector2 val2 = value.p; for (int j = 0; j < value.hn; j++) { Vector2 val3 = value.hist[j]; Vector2 val4 = val2 - val3; float magnitude = ((Vector2)(ref val4)).magnitude; float num9 = 1f - ((float)j + 1f) / ((float)value.hist.Length + 1f); Color c = val; c.a *= num9 * num9 * (value.willow ? 0.9f : 0.75f); if (magnitude > 0.5f) { Quad(glowQuads, (val2 + val3) * 0.5f, magnitude + num8 * num9, num8 * (0.35f + 0.65f * num9), val4 / magnitude, c, 1); } val2 = val3; } Quad(glowQuads, value.p, num8 * 1.5f, num8 * 1.5f, Vector2.right, val, 1); Color c2 = val; c2.a *= 0.28f; Quad(glowQuads, value.p, 30f * k * value.size, 30f * k * value.size, Vector2.right, c2, 0); } } } sparks.AddRange(list); for (int num10 = flashes.Count - 1; num10 >= 0; num10--) { Vector4 val5 = flashes[num10]; val5.z += dt; flashes[num10] = val5; float num11 = val5.w * Mathf.Exp((0f - val5.z) * 9f); if (val5.z > 2.2f) { flashes.RemoveAt(num10); flashCols.RemoveAt(num10); } else { Color val6 = Color.Lerp(Color.white, flashCols[num10], 0.5f); val6.a = num11 * 0.6f; Quad(glowQuads, new Vector2(val5.x, val5.y), 340f * k, 340f * k, Vector2.right, val6, 0); Color c3 = val6; c3.a = val5.w * 0.16f * Mathf.Exp((0f - val5.z) * 1.6f); Quad(glowQuads, new Vector2(val5.x, val5.y), 900f * k, 900f * k, Vector2.right, c3, 0); val6.a = num11; Quad(glowQuads, new Vector2(val5.x, val5.y), 60f * k, 60f * k, Vector2.right, val6, 5); } } } private Ember NewEmber(bool anywhere) { //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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) return new Ember { p = new Vector2(R() * W, anywhere ? (R() * H * 0.9f) : (R(-30f, -5f) * k)), v = new Vector2(R(-10f, 10f), R(35f, 95f)) * k, life = (anywhere ? R(0f, 4f) : 0f), max = R(5f, 9f), size = R(0.7f, 1.4f), seed = R(0f, 100f) }; } private void Embers(float dt, float t, float amount) { //IL_009e: 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_00d6: 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_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.RoundToInt(190f * amount); if (!init) { embers.Clear(); for (int i = 0; i < num; i++) { embers.Add(NewEmber(anywhere: true)); } } while (embers.Count < num) { embers.Add(NewEmber(anywhere: false)); } float num2 = 0.8f + 0.2f * Mathf.PerlinNoise(t * 0.4f, 3.1f); Quad(glowQuads, new Vector2(W * 0.5f, (0f - H) * 0.12f), W * 1.5f, H * 0.55f, Vector2.right, new Color(1f, 0.32f, 0.06f, 0.2f * num2), 0); for (int num3 = embers.Count - 1; num3 >= 0; num3--) { Ember value = embers[num3]; value.life += dt; if (value.life >= value.max || value.p.y > H + 20f * k) { if (embers.Count > num) { embers.RemoveAt(num3); } else { embers[num3] = NewEmber(anywhere: false); } } else { float num4 = Mathf.PerlinNoise(value.p.x * 0.004f / k + value.seed, t * 0.25f) - 0.5f; float num5 = Mathf.PerlinNoise(value.seed, value.p.y * 0.004f / k + t * 0.2f) - 0.5f; value.v.x += num4 * 220f * k * dt; value.v.y += num5 * 70f * k * dt; value.v.x *= Mathf.Exp(-0.8f * dt); value.v.y = Mathf.Lerp(value.v.y, 65f * k, 0.3f * dt); ref Vector2 p = ref value.p; p += value.v * dt; embers[num3] = value; float num6 = value.life / value.max; Color val = ((num6 < 0.35f) ? Color.Lerp(new Color(1f, 0.93f, 0.62f), new Color(1f, 0.55f, 0.12f), num6 / 0.35f) : Color.Lerp(new Color(1f, 0.55f, 0.12f), new Color(0.75f, 0.12f, 0.03f), (num6 - 0.35f) / 0.65f)); float num7 = 0.65f + 0.35f * Mathf.PerlinNoise(t * 7f, value.seed); val.a = Mathf.Clamp01(value.life / 0.5f) * (1f - Mathf.SmoothStep(0.6f, 1f, num6)) * num7; float magnitude = ((Vector2)(ref value.v)).magnitude; float wdt = (5f + magnitude * 0.05f / k) * k * value.size; Quad(glowQuads, value.p, wdt, 6f * k * value.size, Dir(value.v), val, 3); Color c = val; c.a *= 0.5f; Quad(glowQuads, value.p, 30f * k * value.size, 26f * k * value.size, Vector2.right, c, 0); } } } } [BepInPlugin("com.llstarlessll.holdfastextras", "Holdfast Extras", "1.0.4")] public class Extras : BaseUnityPlugin { private struct WP { public Vector3 p; public Vector3 v; public float life; public float max; public float size; public float rot; public float spin; public float grow; public float phase; public float drag; public float grav; public float flip; public float flipRate; public Color c; public int sprite; public bool glow; public bool stretch; public bool coin; public bool flutter; public bool crackle; public Vector3 ringCenter; public float ringR; public float ringAng; public float ringSpeed; public Vector3 ringVel; public float burstT; public bool rocket; public float trail; public Color burstCol; public float floatAfter; } private AudioSource sfxSource; private readonly Dictionary<string, AudioClip> clips = new Dictionary<string, AudioClip>(); private bool wasAlive; private static readonly string[] SoundNames = new string[8] { "kill_tick", "hs_wig", "hs_jackpot", "hs_firework_launch", "hs_firework_burst", "hs_champagne", "hs_laurel", "death_thud" }; internal static readonly string[] MusicModes = new string[4] { "Game music", "Marches", "My music", "Marches + my music" }; internal static readonly string[] MusicEras = new string[5] { "Everything", "Napoleonic", "WW1 (both sides)", "WW1 Entente & USA", "WW1 Central Powers" }; internal static readonly string[] MusicExt = new string[5] { ".ogg", ".mp3", ".wav", ".mp4", ".m4a" }; private const string GameMusicBus = "Menu Music"; private AudioSource musicSource2; internal readonly List<string> tracks = new List<string>(); internal int myTrackCount; internal int skippedTracks; internal string nowPlaying; private int trackIndex = -1; private bool loadingTrack; private bool gameBusMuted; private bool wantMusic; private float fade; private float trackStartedAt = -10f; private AudioClip currentClip; private readonly HashSet<string> badFiles = new HashSet<string>(); private readonly Random rng = new Random(); private const float CrossFade = 4f; private AudioSource musicSourceA; private AudioSource musicSourceB; private AudioSource oldSource; private AudioClip oldClip; private float oldGain; private float newGain = 1f; private readonly List<string> bag = new List<string>(); private MasterAudio masterAudio; private float nextAudioLookup; private float lastPos; public const string Guid = "com.llstarlessll.holdfastextras"; public const string Name = "Holdfast Extras"; public const string Version = "1.0.4"; internal static Extras I; internal string PluginDir; internal string UserDir; internal ConfigEntry<KeyboardShortcut> keyMenu; internal ConfigEntry<KeyboardShortcut> keyShotMode; internal ConfigEntry<KeyboardShortcut> keyCapture; internal ConfigEntry<bool> headshotFx; internal ConfigEntry<bool> killOn; internal ConfigEntry<bool> killTick; internal ConfigEntry<bool> killDing; internal ConfigEntry<bool> deathThud; internal ConfigEntry<float> killVol; internal ConfigEntry<string> musicSource; internal ConfigEntry<string> musicEra; internal ConfigEntry<bool> musicShuffle; internal ConfigEntry<float> musicVol; internal ConfigEntry<bool> seasonOn; internal ConfigEntry<bool> seasonMenu; internal ConfigEntry<bool> seasonScoreboard; internal ConfigEntry<bool> seasonBackdrop; internal ConfigEntry<string> seasonForce; internal ConfigEntry<float> seasonDensity; internal ConfigEntry<int> shotScale; internal ConfigEntry<bool> shotCleanCapture; internal ConfigEntry<bool> shotHideInMode; private float lastWarn; private string toast; private float toastUntil; internal static readonly string[] SeasonNames = new string[5] { "Automatic (by date)", "Winter snow", "New Year fireworks", "4th of July fireworks", "Halloween embers" }; internal const string FxCanvasName = "HoldfastExtras Season FX"; private GameObject fxRoot; private FxGraphic fxAlpha; private FxGraphic fxGlow; private float fxFade; private string fxSeason; private float fxTime; private readonly FxSim sim = new FxSim(); private RawImage backdrop; private Texture art; private float nextArtSearch; private int artSearches; private readonly Dictionary<string, Texture2D> gradients = new Dictionary<string, Texture2D>(); private static readonly string[] ArtNames = new string[3] { "hui-event-sch-event-image-1", "hui-event-sch-event-image-2", "hui-event-sch-event-image-3" }; internal bool shotMode; private readonly List<Canvas> hiddenCanvases = new List<Canvas>(); private float nextCanvasScan; private bool capturing; internal bool menuOpen; private bool hideOverlayForCapture; private bool savedUnlock; private int tab; internal ConfigEntry<KeyboardShortcut> listening; private static readonly string[] Tabs = new string[6] { "SOUNDS", "MUSIC", "SEASONS", "SCREENSHOTS", "DISCORD", "KEYS" }; private static readonly Color Gold = Color32.op_Implicit(new Color32((byte)201, (byte)162, (byte)74, byte.MaxValue)); private static readonly Color GoldDim = Color32.op_Implicit(new Color32((byte)125, (byte)102, (byte)51, byte.MaxValue)); private static readonly Color Ink = Color32.op_Implicit(new Color32((byte)233, (byte)223, (byte)198, byte.MaxValue)); private static readonly Color Muted = Color32.op_Implicit(new Color32((byte)156, (byte)147, (byte)128, byte.MaxValue)); private static readonly Color Panel = Color32.op_Implicit(new Color32((byte)20, (byte)19, (byte)16, (byte)242)); private static readonly Color Row = Color32.op_Implicit(new Color32((byte)34, (byte)32, (byte)27, byte.MaxValue)); private static readonly Color RowHot = Color32.op_Implicit(new Color32((byte)46, (byte)42, (byte)34, byte.MaxValue)); private Texture2D texPanel; private Texture2D texRow; private Texture2D texRowHot; private Texture2D texGold; private Texture2D texGoldDim; private Texture2D texBlack; private GUIStyle sTitle; private GUIStyle sSub; private GUIStyle sLabel; private GUIStyle sMuted; private GUIStyle sTab; private GUIStyle sTabOn; private GUIStyle sBtn; private GUIStyle sValue; private GUIStyle sToast; private GUIStyle sSmallBtn; private float uiScale = 1f; internal float hsAt = -10f; private GUIStyle sHs; private Rect body; private float y; internal static readonly string[] HeadshotStyles = new string[7] { "Powdered wig", "Jackpot", "Firework", "Champagne", "Laurel crown", "Random", "None" }; private static readonly string[] HeadshotSoundFor = new string[5] { "hs_wig", "hs_jackpot", "hs_firework_launch", "hs_champagne", "hs_laurel" }; internal ConfigEntry<string> headshotStyle; private const float FxFadeStart = 35f; private const float FxFadeEnd = 70f; private const float SoundMaxDistance = 80f; private const float FxScale = 1.7f; private readonly List<WP> wparts = new List<WP>(512); private readonly Random wr = new Random(); private GameObject wRoot; private FxGraphic wAlpha; private FxGraphic wGlow; private readonly List<AudioSource> wAudio = new List<AudioSource>(); private static readonly Color[] RocketCols = (Color[])(object)new Color[6] { new Color(1f, 0.3f, 0.3f), new Color(1f, 0.85f, 0.4f), new Color(0.45f, 0.7f, 1f), new Color(0.5f, 1f, 0.6f), new Color(0.85f, 0.5f, 1f), Color.white }; internal string MyMusicDir => Path.Combine(UserDir, "MyMusic"); private static float GameMenuVolume { get { try { return Mathf.Clamp01(GameOptionsCollectionManager.Instance.GameOptions.AudioOptions.backgroundMusicVolume); } catch { return 0.3f; } } } private MasterAudio GameAudio { get { if ((Object)(object)masterAudio == (Object)null && Time.unscaledTime >= nextAudioLookup) { nextAudioLookup = Time.unscaledTime + 1f; try { masterAudio = Object.FindObjectOfType<MasterAudio>(); } catch { masterAudio = null; } if ((Object)(object)masterAudio != (Object)null) { gameBusMuted = false; } } return masterAudio; } } private bool MenuReady { get { //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) if ((Object)(object)GameAudio != (Object)null) { return true; } try { Scene sceneByName = SceneManager.GetSceneByName("MainMenuScene"); return ((Scene)(ref sceneByName)).isLoaded; } catch { return false; } } } internal static bool InBattle { get { try { ClientHoldfastGameStateManager instance = ClientHoldfastGameStateManager.Instance; return instance != null && ConnectionManager.Connected && instance.LevelRunning && (Object)(object)instance.CurrentLoadedMap != (Object)null && !instance.InMapLoadingProcess; } catch { return false; } } } internal static bool Loading { get { try { ClientHoldfastGameStateManager instance = ClientHoldfastGameStateManager.Instance; return instance != null && instance.InMapLoadingProcess; } catch { return false; } } } internal static bool InMenu { get { if (Loading) { return false; } try { return !ConnectionManager.Connected; } catch { return !InBattle; } } } internal string ActiveSeason { get { string value = seasonForce.Value; if (value != SeasonNames[0]) { return value; } DateTime now = DateTime.Now; if ((now.Month == 12 && now.Day == 31) || (now.Month == 1 && now.Day == 1)) { return "New Year fireworks"; } if (now.Month == 7 && now.Day == 4) { return "4th of July fireworks"; } if (now.Month == 10 && now.Day >= 24) { return "Halloween embers"; } if (now.Month == 12 || (now.Month == 1 && now.Day <= 6)) { return "Winter snow"; } return null; } } private static bool ScoreboardOpen { get { try { ClientComponentReferenceManager clientInstance = ClientComponentReferenceManager.ClientInstance; return (Object)(object)clientInstance != (Object)null && (Object)(object)clientInstance.scoreboardManager != (Object)null && clientInstance.scoreboardManager.Showing; } catch { return false; } } } private bool SeasonWanted { get { if (!seasonOn.Value || ActiveSeason == null || Loading) { return false; } if (shotMode && shotHideInMode.Value) { return false; } if (InMenu) { return seasonMenu.Value; } if (InBattle) { if (seasonScoreboard.Value) { return ScoreboardOpen; } return false; } return false; } } internal string ShotDir { get { string text = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); if (string.IsNullOrEmpty(text)) { text = Path.Combine(Paths.GameRootPath, "Screenshots"); } return Path.Combine(text, "Holdfast Extras"); } } private static Camera Cam { get { Camera main = Camera.main; if (!((Object)(object)main != (Object)null) || !((Behaviour)main).isActiveAndEnabled) { return null; } return main; } } private void BuildAudio() { sfxSource = MakeSource("HoldfastExtras SFX"); musicSource2 = MakeSource("HoldfastExtras Music"); musicSource2.loop = false; } private AudioSource MakeSource(string n) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_000c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(n); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; AudioSource obj = val.AddComponent<AudioSource>(); obj.playOnAwake = false; obj.spatialBlend = 0f; obj.ignoreListenerPause = true; obj.priority = 16; obj.bypassReverbZones = true; return obj; } private void LoadSounds() { clips.Clear(); string[] soundNames = SoundNames; foreach (string n in soundNames) { string text = FindSound(Path.Combine(UserDir, "MySounds"), n) ?? FindSound(Path.Combine(PluginDir, "sounds"), n) ?? FindAnywhere(n); if (text == null) { continue; } ((MonoBehaviour)this).StartCoroutine(LoadClip(text, stream: false, delegate(AudioClip c) { if ((Object)(object)c != (Object)null) { ((Object)c).name = n; clips[n] = c; } })); } } private string FindAnywhere(string n) { try { string[] array = new string[3] { ".ogg", ".wav", ".mp3" }; foreach (string text in array) { string[] files = Directory.GetFiles(PluginDir, n + text, SearchOption.AllDirectories); if (files.Length != 0) { return files[0]; } } } catch { } return null; } private static string FindSound(string dir, string n) { string[] array = new string[3] { ".ogg", ".wav", ".mp3" }; foreach (string text in array) { string text2 = Path.Combine(dir, n + text); if (File.Exists(text2)) { return text2; } } return null; } internal static AudioType TypeFor(string path) { switch (Path.GetExtension(path).ToLowerInvariant()) { case ".ogg": return (AudioType)14; case ".wav": return (AudioType)20; case ".mp3": return (AudioType)13; case ".mp4": case ".m4a": case ".aac": return (AudioType)1; default: return (AudioType)0; } } internal IEnumerator LoadClip(string path, bool stream, Action<AudioClip> done) { AudioClip clip = null; UnityWebRequest req = null; try { req = UnityWebRequestMultimedia.GetAudioClip(new Uri(path).AbsoluteUri, TypeFor(path)); DownloadHandlerAudioClip val = (DownloadHandlerAudioClip)req.downloadHandler; val.streamAudio = stream; val.compressed = !stream; } catch (Exception e) { Warn("load " + Path.GetFileName(path), e); } if (req == null) { done(null); yield break; } yield return req.SendWebRequest(); try { if (string.IsNullOrEmpty(req.error)) { clip = DownloadHandlerAudioClip.GetContent(req); if ((Object)(object)clip != (Object)null && !stream && (int)clip.loadState == 0) { clip.LoadAudioData(); } } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not load " + Path.GetFileName(path) + ": " + req.error)); } } catch (Exception e2) { Warn("load " + Path.GetFileName(path), e2); clip = null; } finally { req.Dispose(); } done(clip); } private void PlaySfx(string n) { if (clips.TryGetValue(n, out var value) && (Object)(object)value != (Object)null) { sfxSource.PlayOneShot(value, killVol.Value); } } private void TickRound() { try { ClientComponentReferenceManager clientInstance = ClientComponentReferenceManager.ClientInstance; ClientRoundPlayerOwner val = (((Object)(object)clientInstance != (Object)null && (Object)(object)clientInstance.clientRoundPlayerManager != (Object)null) ? clientInstance.clientRoundPlayerManager.LocalPlayer : null); bool flag = val != null && (Object)(object)((RoundPlayer)val).PlayerBase != (Object)null && ((RoundPlayer)val).PlayerBase.SpawnedAndAlive; if (wasAlive && !flag && InBattle && killOn.Value && deathThud.Value) { PlaySfx("death_thud"); } wasAlive = flag; } catch { } } private static void ScorePostfix(ClientRoundPlayer killer, ClientRoundPlayer victim, ScorableAction scorableAction) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)I == (Object)null || !I.killOn.Value || killer == null || killer == victim) { return; } PlayerKilledPlayerScorableAction val = (PlayerKilledPlayerScorableAction)(object)((scorableAction is PlayerKilledPlayerScorableAction) ? scorableAction : null); if (val == null || val.TeamKill) { return; } ClientComponentReferenceManager clientInstance = ClientComponentReferenceManager.ClientInstance; ClientRoundPlayerOwner val2 = (((Object)(object)clientInstance != (Object)null && (Object)(object)clientInstance.clientRoundPlayerManager != (Object)null) ? clientInstance.clientRoundPlayerManager.LocalPlayer : null); if (val2 != null && (object)killer == val2 && (((RoundPlayer)killer).PlayerStartData == null || victim == null || ((RoundPlayer)victim).PlayerStartData == null || ((RoundPlayer)killer).PlayerStartData.Faction != ((RoundPlayer)victim).PlayerStartData.Faction)) { I.OnMyKill(val); if (val.Headshot) { I.HeadshotAt(victim); } } } catch (Exception e) { if ((Object)(object)I != (Object)null) { I.Warn("kill", e); } } } private void OnMyKill(PlayerKilledPlayerScorableAction a) { if (a.Headshot && headshotFx.Value) { hsAt = Time.unscaledTime; } else if (killTick.Value) { PlaySfx("kill_tick"); } } internal void TestKillSound(int i) { switch (i) { case 0: PlaySfx("kill_tick"); break; case 1: TestHeadshot(); break; } } internal void ScanMusic() { tracks.Clear(); myTrackCount = 0; string value = musicSource.Value; if (value == "Marches" || value == "Marches + my music") { string value2 = musicEra.Value; bool num = value2 == "Everything" || Array.IndexOf(MusicEras, value2) < 0; List<string> source = BundledTracks(); if (num || value2 == "Napoleonic") { tracks.AddRange(source.Where((string f) => Path.GetFileName(f).StartsWith("Napoleonic - "))); } if (num || value2 == "WW1 (both sides)" || value2 == "WW1 Entente & USA") { tracks.AddRange(source.Where((string f) => Path.GetFileName(f).StartsWith("WW1 Entente - "))); } if (num || value2 == "WW1 (both sides)" || value2 == "WW1 Central Powers") { tracks.AddRange(source.Where((string f) => Path.GetFileName(f).StartsWith("WW1 Central - "))); } if (tracks.Count == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("No bundled menu music found under " + PluginDir)); } } if (value == "My music" || value == "Marches + my music") { List<string> list = Files(MyMusicDir); myTrackCount = list.Count; tracks.AddRange(list); } tracks.RemoveAll((string t) => badFiles.Contains(t)); bag.RemoveAll((string p) => !tracks.Contains(p)); skippedTracks = badFiles.Count; trackIndex = -1; } private List<string> BundledTracks() { try { return Directory.GetFiles(PluginDir, "*.ogg", SearchOption.AllDirectories).Where(delegate(string f) { string fileName = Path.GetFileName(f); return fileName.StartsWith("Napoleonic - ") || fileName.StartsWith("WW1 Entente - ") || fileName.StartsWith("WW1 Central - "); }).OrderBy<string, string>((string f) => Path.GetFileName(f), StringComparer.OrdinalIgnoreCase) .ToList(); } catch { return new List<string>(); } } private static List<string> Files(string dir) { try { if (!Directory.Exists(dir)) { return new List<string>(); } return (from f in Directory.GetFiles(dir) where MusicExt.Contains(Path.GetExtension(f).ToLowerInvariant()) select f).OrderBy<string, string>((string f) => f, StringComparer.OrdinalIgnoreCase).ToList(); } catch { return new List<string>(); } } private void TickMusic() { //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Invalid comparison between Unknown and I4 wantMusic = musicSource.Value != "Game music" && InMenu && MenuReady && tracks.Count > 0 && GameMenuVolume > 0f && musicVol.Value > 0f; fade = Mathf.MoveTowards(fade, wantMusic ? 1f : 0f, Time.unscaledDeltaTime / (wantMusic ? 2f : 0.8f)); float num = fade * musicVol.Value * GameMenuVolume * 2f; newGain = Mathf.MoveTowards(newGain, 1f, Time.unscaledDeltaTime / 4f); musicSource2.volume = num * Mathf.Sin(newGain * (float)Math.PI / 2f); if ((Object)(object)oldSource != (Object)null) { oldGain = Mathf.MoveTowards(oldGain, 0f, Time.unscaledDeltaTime / 4f); oldSource.volume = num * Mathf.Sin(oldGain * (float)Math.PI / 2f); if (oldGain <= 0f || !oldSource.isPlaying) { oldSource.Stop(); oldSource.clip = null; if ((Object)(object)oldClip != (Object)null) { Object.Destroy((Object)(object)oldClip); } oldClip = null; oldSource = null; } } if (wantMusic) { MuteGameMusic(musicSource2.isPlaying || ((Object)(object)oldSource != (Object)null && oldSource.isPlaying)); if (loadingTrack) { return; } AudioClip clip = musicSource2.clip; bool flag = Time.unscaledTime - trackStartedAt < 2f; if (musicSource2.isPlaying) { lastPos = musicSource2.time; } bool flag2 = !musicSource2.isPlaying && !flag && ((Object)(object)clip == (Object)null || (int)clip.loadState != 1); if (flag2 && (Object)(object)clip != (Object)null && lastPos > 0f && lastPos < clip.length - 4f - 1f && Time.unscaledTime - trackStartedAt < clip.length + 30f) { musicSource2.Play(); musicSource2.time = Mathf.Min(lastPos, clip.length - 0.1f); return; } bool flag3 = musicSource2.isPlaying && (Object)(object)clip != (Object)null && clip.length > 12f && musicSource2.time >= clip.length - 4f; if ((Object)(object)clip == (Object)null || flag2 || flag3) { NextTrack(1); } } else if (fade <= 0f) { if (musicSource2.isPlaying) { musicSource2.Stop(); } if ((Object)(object)oldSource != (Object)null) { oldSource.Stop(); oldSource = null; } MuteGameMusic(mute: false); } } private int PickNext(int dir) { if (musicShuffle.Value && tracks.Count > 1 && dir > 0) { if (bag.Count == 0) { for (int i = 0; i < tracks.Count; i++) { if (i != trackIndex) { bag.Add(tracks[i]); } } } int index = rng.Next(bag.Count); string item = bag[index]; bag.RemoveAt(index); int num = tracks.IndexOf(item); if (num >= 0) { return num; } } if (trackIndex >= 0) { return (int)Mathf.Repeat((float)(trackIndex + dir), (float)tracks.Count); } return 0; } private void MuteGameMusic(bool mute) { if (mute == gameBusMuted) { return; } try { if (!((Object)(object)GameAudio == (Object)null)) { if (mute) { MasterAudio.MuteBus("Menu Music"); } else { MasterAudio.UnmuteBus("Menu Music", true); } gameBusMuted = mute; } } catch (Exception e) { Warn("menu music bus", e); gameBusMuted = mute; } } internal void NextTrack(int dir) { if (tracks.Count == 0 || loadingTrack) { return; } int index = (trackIndex = Mathf.Clamp(PickNext(dir), 0, tracks.Count - 1)); string path = tracks[index]; loadingTrack = true; ((MonoBehaviour)this).StartCoroutine(LoadClip(path, stream: false, delegate(AudioClip clip) { loadingTrack = false; if ((Object)(object)clip == (Object)null) { badFiles.Add(path); ((BaseUnityPlugin)this).Logger.LogWarning((object)("Skipped " + Path.GetFileName(path) + " (Holdfast can't read that file type; convert it to .mp3 or .ogg).")); ScanMusic(); } else { if ((Object)(object)musicSourceB == (Object)null) { musicSourceB = MakeSource("HoldfastExtras Music B"); musicSourceB.loop = false; } if ((Object)(object)oldSource != (Object)null) { oldSource.Stop(); oldSource.clip = null; if ((Object)(object)oldClip != (Object)null) { Object.Destroy((Object)(object)oldClip); } } if (musicSource2.isPlaying) { oldSource = musicSource2; oldClip = currentClip; oldGain = 1f; newGain = 0f; } else { musicSource2.clip = null; if ((Object)(object)currentClip != (Object)null) { Object.Destroy((Object)(object)currentClip); } newGain = 1f; } if ((Object)(object)musicSourceA == (Object)null) { musicSourceA = musicSource2; } if ((Object)(object)oldSource != (Object)null) { musicSource2 = (((Object)(object)oldSource == (Object)(object)musicSourceA) ? musicSourceB : musicSourceA); } currentClip = clip; musicSource2.clip = clip; musicSource2.Play(); trackStartedAt = Time.unscaledTime; lastPos = 0f; nowPlaying = Pretty(path); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Menu music: " + nowPlaying + " (" + clip.length.ToString("0") + " s, volume " + musicSource2.volume.ToString("0.00") + ")")); } })); } internal static string Pretty(string path) { string text = Path.GetFileNameWithoutExtension(path); string[] array = new string[3] { "Napoleonic - ", "WW1 Entente - ", "WW1 Central - " }; foreach (string text2 in array) { if (text.StartsWith(text2)) { text = text.Substring(text2.Length); } } if (text.Length > 5 && char.IsDigit(text[0]) && char.IsDigit(text[1]) && text.Substring(2, 3) == " - ") { text = text.Substring(5); } return text; } internal void RestartMusic() { StopMusic(); ScanMusic(); } private void StopMusic() { try { musicSource2.Stop(); if ((Object)(object)oldSource != (Object)null) { oldSource.Stop(); } oldSource = null; } catch { } nowPlaying = null; MuteGameMusic(mute: false); } internal void OpenMusicFolder() { try { Directory.CreateDirectory(MyMusicDir); Process.Start(MyMusicDir); } catch (Exception e) { Warn("open folder", e); } } private void Awake() { //IL_0084: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Expected O, but got Unknown //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Expected O, but got Unknown //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Expected O, but got Unknown //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Expected O, but got Unknown //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Expected O, but got Unknown //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Expected O, but got Unknown //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Expected O, but got Unknown //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Expected O, but got Unknown //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_050c: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Expected O, but got Unknown I = this; ((MonoBehaviour)this).useGUILayout = false; PluginDir = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); UserDir = Path.Combine(Paths.ConfigPath, "HoldfastExtras"); try { Directory.CreateDirectory(Path.Combine(UserDir, "MyMusic")); Directory.CreateDirectory(Path.Combine(UserDir, "MySounds")); } catch { } keyMenu = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "Open menu", new KeyboardShortcut((KeyCode)289, Array.Empty<KeyCode>()), "Opens the Holdfast Extras menu."); keyShotMode = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "Screenshot mode", new KeyboardShortcut((KeyCode)291, Array.Empty<KeyCode>()), "Hides the whole HUD until you press it again."); keyCapture = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "Take screenshot", new KeyboardShortcut((KeyCode)290, Array.Empty<KeyCode>()), "Saves a screenshot to Pictures\\Holdfast Extras."); killOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Kill Sounds", "Enabled", true, "Master switch for kill sounds and headshot effect sounds."); killTick = ((BaseUnityPlugin)this).Config.Bind<bool>("Kill Sounds", "Kill confirm tick", true, "A short wood-block tick when you get a kill."); killDing = ((BaseUnityPlugin)this).Config.Bind<bool>("Kill Sounds", "Headshot ding", true, "Play the headshot effect's own sound (3D: quieter the further away)."); headshotFx = ((BaseUnityPlugin)this).Config.Bind<bool>("Kill Sounds", "Headshot marker", true, "A gold hit-marker and HEADSHOT pop at your crosshair on headshot kills."); headshotStyle = ((BaseUnityPlugin)this).Config.Bind<string>("Kill Sounds", "Headshot effect", "Random", new ConfigDescription("What bursts out of the head on your headshot kills (each has its own sound).", (AcceptableValueBase)(object)new AcceptableValueList<string>(HeadshotStyles), Array.Empty<object>())); deathThud = ((BaseUnityPlugin)this).Config.Bind<bool>("Kill Sounds", "Death thud", false, "A soft drum thud when you die."); killVol = ((BaseUnityPlugin)this).Config.Bind<float>("Kill Sounds", "Sound volume", 0.6f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); musicSource = ((BaseUnityPlugin)this).Config.Bind<string>("Menu Music", "Play", "Marches + my music", new ConfigDescription("What plays in the main menu.", (AcceptableValueBase)(object)new AcceptableValueList<string>(MusicModes), Array.Empty<object>())); musicEra = ((BaseUnityPlugin)this).Config.Bind<string>("Menu Music", "Bundled music", "Everything", new ConfigDescription("Which of the bundled sets to play.", (AcceptableValueBase)(object)new AcceptableValueList<string>(MusicEras), Array.Empty<object>())); musicShuffle = ((BaseUnityPlugin)this).Config.Bind<bool>("Menu Music", "Shuffle", true, ""); musicVol = ((BaseUnityPlugin)this).Config.Bind<float>("Menu Music", "Volume", 0.6f, new ConfigDescription("Multiplied by the game's own menu music volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); seasonOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Seasons", "Enabled", true, "Snow in winter, fireworks at New Year and the 4th of July, embers at Halloween."); seasonMenu = ((BaseUnityPlugin)this).Config.Bind<bool>("Seasons", "Main menu background", true, "Season effects in the main menu, behind Holdfast's own buttons and panels."); seasonBackdrop = ((BaseUnityPlugin)this).Config.Bind<bool>("Seasons", "Themed menu background", true, "Recolours the main menu background to match the season (Holdfast's own menu art, from your game files)."); seasonScoreboard = ((BaseUnityPlugin)this).Config.Bind<bool>("Seasons", "Behind the scoreboard", true, "Season effects behind the scoreboard while you hold it open in a battle. Never shown during normal play."); seasonForce = ((BaseUnityPlugin)this).Config.Bind<string>("Seasons", "Season", "Automatic (by date)", new ConfigDescription("Pick one to preview it any time of year.", (AcceptableValueBase)(object)new AcceptableValueList<string>(SeasonNames), Array.Empty<object>())); seasonDensity = ((BaseUnityPlugin)this).Config.Bind<float>("Seasons", "Amount", 0.6f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>())); shotScale = ((BaseUnityPlugin)this).Config.Bind<int>("Screenshots", "Resolution multiplier", 1, new ConfigDescription("2 = double resolution (bigger files).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 4), Array.Empty<object>())); shotCleanCapture = ((BaseUnityPlugin)this).Config.Bind<bool>("Screenshots", "Hide HUD in screenshots", true, "Takes the picture without the HUD even when screenshot mode is off."); shotHideInMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Screenshots", "Hide season effects in screenshot mode", false, ""); BuildAudio(); try { new Harmony("com.llstarlessll.holdfastextras").Patch((MethodBase)AccessTools.Method(typeof(ScoreLogUI), "DisplayScore", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Extras), "ScorePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not hook the score log, kill sounds are off: " + ex.Message)); } LoadSounds(); ScanMusic(); Toast("Holdfast Extras: press " + ((object)keyMenu.Value/*cast due to .constrained prefix*/).ToString() + " for the menu", 6f); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Holdfast Extras 1.0.4 loaded. Press " + ((object)keyMenu.Value/*cast due to .constrained prefix*/).ToString() + " for the menu.")); } internal static bool Typing() { try { EventSystem current = EventSystem.current; GameObject val = (((Object)(object)current != (Object)null) ? current.currentSelectedGameObject : null); return (Object)(object)val != (Object)null && ((Object)(object)val.GetComponent<InputField>() != (Object)null || (Object)(object)val.GetComponent<TMP_InputField>() != (Object)null); } catch { return false; } } private static bool Pressed(ConfigEntry<KeyboardShortcut> k) { //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_0009: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = k.Value; if ((int)((KeyboardShortcut)(ref value)).MainKey != 0) { return ((KeyboardShortcut)(ref value)).IsDown(); } return false; } private void Update() { try { if (listening == null && !Typing()) { if (Pressed(keyMenu)) { SetMenu(!menuOpen); } else if (Pressed(keyShotMode)) { SetShotMode(!shotMode); } else if (Pressed(keyCapture)) { Capture(); } } if (menuOpen && Input.GetKeyDown((KeyCode)27) && listening == null) { SetMenu(open: false); } if (shotMode && Input.GetKeyDown((KeyCode)27)) { SetShotMode(on: false); } if (menuOpen) { KeepMouseFree(); } TickRound(); TickMusic(); TickSeasons(Time.unscaledDeltaTime); TickShotMode(); TickWorldFx(Time.unscaledDeltaTime); } catch (Exception e) { Warn("update", e); } } private void OnDestroy() { try { SetShotMode(on: false); SetMenu(open: false); StopMusic(); } catch { } } internal void Warn(string where, Exception e) { if (!(Time.unscaledTime - lastWarn < 5f)) { lastWarn = Time.unscaledTime; ((BaseUnityPlugin)this).Logger.LogWarning((object)(where + ": " + e.Message)); } } internal void Toast(string text, float seconds = 2.5f) { toast = text; toastUntil = Time.unscaledTime + seconds; } private void EnsureFx() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)fxRoot != (Object)null)) { fxRoot = new GameObject("HoldfastExtras Season FX"); Object.DontDestroyOnLoad((Object)(object)fxRoot); Canvas obj = fxRoot.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = -500; obj.pixelPerfect = false; Texture2D atlas = FxArt.Build(); GameObject val = new GameObject("Backdrop"); val.transform.SetParent(fxRoot.transform, false); backdrop = val.AddComponent<RawImage>(); ((Graphic)backdrop).raycastTarget = false; RectTransform rectTransform = ((Graphic)backdrop).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; fxAlpha = MakeLayer("Snow", atlas, null); fxGlow = MakeLayer("Glow", atlas, FxArt.AdditiveMaterial()); } } private FxGraphic MakeLayer(string n, Texture2D atlas, Material mat) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(n); val.transform.SetParent(fxRoot.transform, false); FxGraphic fxGraphic = val.AddComponent<FxGraphic>(); fxGraphic.atlas = atlas; ((Graphic)fxGraphic).raycastTarget = false; if ((Object)(object)mat != (Object)null) { ((Graphic)fxGraphic).material = mat; } RectTransform rectTransform = ((Graphic)fxGraphic).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.pivot = Vector2.zero; rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; return fxGraphic; } private void TickSeasons(float dt) { bool seasonWanted = SeasonWanted; fxFade = Mathf.MoveTowards(fxFade, seasonWanted ? 1f : 0f, dt / (seasonWanted ? 0.6f : 0.35f)); if (fxFade <= 0f) { if ((Object)(object)fxRoot != (Object)null && fxRoot.activeSelf) { fxRoot.SetActive(false); } return; } EnsureFx(); if (!fxRoot.activeSelf) { fxRoot.SetActive(true); } string text = ActiveSeason ?? fxSeason; if (text != fxSeason) { fxSeason = text; sim.Reset(); } dt = Mathf.Min(dt, 0.05f); fxTime += dt; sim.Step(text, dt, fxTime, Screen.width, Screen.height, seasonDensity.Value); UpdateBackdrop(text); fxAlpha.quads = sim.alphaQuads; fxAlpha.fade = fxFade; ((Graphic)fxAlpha).SetVerticesDirty(); fxGlow.quads = sim.glowQuads; fxGlow.fade = fxFade; ((Graphic)fxGlow).SetVerticesDirty(); } private void UpdateBackdrop(string season) { //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: 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_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)backdrop == (Object)null) { return; } bool flag = InMenu && seasonBackdrop.Value && season != null; ((Behaviour)backdrop).enabled = flag; if (!flag) { return; } if ((Object)(object)art == (Object)null && artSearches < 4 && Time.unscaledTime >= nextArtSearch) { nextArtSearch = Time.unscaledTime + 5f; artSearches++; try { Texture2D[] array = Resources.FindObjectsOfTypeAll<Texture2D>(); foreach (Texture2D val in array) { if ((Object)(object)val != (Object)null && Array.IndexOf(ArtNames, ((Object)val).name) >= 0 && ((Texture)val).width >= 1024) { art = (Texture)(object)val; break; } } } catch { } } Color white = default(Color); Color top = default(Color); Color bottom = default(Color); if (!(season == "Winter snow")) { if (season == "Halloween embers") { ((Color)(ref white))..ctor(0.5f, 0.27f, 0.17f); ((Color)(ref top))..ctor(0.18f, 0.08f, 0.05f); ((Color)(ref bottom))..ctor(0.05f, 0.02f, 0.02f); } else { ((Color)(ref white))..ctor(0.26f, 0.29f, 0.42f); ((Color)(ref top))..ctor(0.03f, 0.04f, 0.09f); ((Color)(ref bottom))..ctor(0.1f, 0.12f, 0.2f); } } else { ((Color)(ref white))..ctor(0.62f, 0.72f, 0.88f); ((Color)(ref top))..ctor(0.55f, 0.66f, 0.8f); ((Color)(ref bottom))..ctor(0.2f, 0.24f, 0.3f); } Texture val2 = art; if ((Object)(object)val2 == (Object)null) { if (!gradients.TryGetValue(season, out var value)) { value = Gradient(top, bottom); gradients[season] = value; } val2 = (Texture)(object)value; white = Color.white; } backdrop.texture = val2; Color color = white; color.a = fxFade; ((Graphic)backdrop).color = color; float num = (float)Screen.width / (float)Mathf.Max(1, Screen.height); float num2 = (float)val2.width / (float)Mathf.Max(1, val2.height); backdrop.uvRect = ((num > num2) ? new Rect(0f, (1f - num2 / num) / 2f, 1f, num2 / num) : new Rect((1f - num / num2) / 2f, 0f, num / num2, 1f)); } private static Texture2D Gradient(Color top, Color bottom) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_003f: 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_0052: 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_0059: 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_0077: 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) Texture2D val = new Texture2D(64, 128, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; for (int i = 0; i < 128; i++) { for (int j = 0; j < 64; j++) { float num = (float)i / 127f; float num2 = (float)j / 63f - 0.5f; Color val2 = Color.Lerp(bottom, top, num * num * (3f - 2f * num)); val2 *= 1f - 0.35f * num2 * num2 * 4f; val2.a = 1f; val.SetPixel(j, i, val2); } } val.Apply(); return val; } internal void SetShotMode(bool on) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (on != shotMode) { shotMode = on; if (on) { SetMenu(open: false); HideHud(); Toast("Screenshot mode - press " + ((object)keyShotMode.Value/*cast due to .constrained prefix*/).ToString() + " to bring the HUD back", 2f); } else { ShowHud(); } } } private void HideHud() { try { Canvas[] array = Object.FindObjectsOfType<Canvas>(); foreach (Canvas val in array) { if (!((Object)(object)val == (Object)null) && ((Behaviour)val).enabled && val.isRootCanvas && !(((Object)((Component)val).gameObject).name == "HoldfastExtras Season FX")) { ((Behaviour)val).enabled = false; hiddenCanvases.Add(val); } } } catch (Exception e) { Warn("hide hud", e); } } private void ShowHud() { foreach (Canvas hiddenCanvase in hiddenCanvases) { try { if ((Object)(object)hiddenCanvase != (Object)null) { ((Behaviour)hiddenCanvase).enabled = true; } } catch { } } hiddenCanvases.Clear(); } private void TickShotMode() { if (shotMode) { if (Loading) { SetShotMode(on: false); } else if (Time.unscaledTime >= nextCanvasScan) { nextCanvasScan = Time.unscaledTime + 0.5f; HideHud(); } } } internal void Capture() { if (!capturing) { ((MonoBehaviour)this).StartCoroutine(CaptureRoutine()); } } private IEnumerator CaptureRoutine() { capturing = true; bool hideNow = !shotMode && shotCleanCapture.Value; if (menuOpen) { SetMenu(open: false); } if (hideNow) { HideHud(); } hideOverlayForCapture = true; yield return null; string file; try { Directory.CreateDirectory(ShotDir); file = Path.Combine(ShotDir, "Holdfast " + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + ".png"); ScreenCapture.CaptureScreenshot(file, Mathf.Clamp(shotScale.Value, 1, 4)); } catch (Exception e) { Warn("screenshot", e); file = null; } yield return null; yield return null; hideOverlayForCapture = false; if (hideNow) { ShowHud(); } capturing = false; if (file != null) { Toast("Saved " + Path.GetFileName(file) + " (Pictures\\Holdfast Extras)"); } } internal void OpenShotFolder() { try { Directory.CreateDirectory(ShotDir); Process.Start(ShotDir); } catch (Exception e) { Warn("open folder", e); } } internal void SetMenu(bool open) { if (open == menuOpen) { return; } menuOpen = open; listening = null; ClientGlobalVariables val = GlobalVars(); if (open) { if ((Object)(object)val != (Object)null) { savedUnlock = val.ShouldUnlockMouse; } return; } if ((Object)(object)val != (Object)null) { val.ShouldUnlockMouse = savedUnlock; } try { ((BaseUnityPlugin)this).Config.Save(); } catch { } } private static ClientGlobalVariables GlobalVars() { try { ClientComponentReferenceManager clientInstance = ClientComponentReferenceManager.ClientInstance; return ((Object)(object)clientInstance != (Object)null) ? clientInstance.clientGlobalVariables : null; } catch { return null; } } private void KeepMouseFree() { ClientGlobalVariables val = GlobalVars(); if ((Object)(object)val != (Object)null) { val.ShouldUnlockMouse = true; } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } private static Texture2D Tex(Color c) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1) { hideFlags = (HideFlags)61 }; val.SetPixel(0, 0, c); val.Apply(); return val; } private void BuildStyles() { //IL_000a: 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_002a: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00ab: 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_00cd: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_0110: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Expected O, but got Unknown //IL_0178: 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_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_01b0: 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) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Expected O, but got Unknown //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Expected O, but got Unknown //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Expected O, but got Unknown //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Expected O, but got Unknown if (sTitle == null) { texPanel = Tex(Panel); texRow = Tex(Row); texRowHot = Tex(RowHot); texGold = Tex(Gold); texGoldDim = Tex(GoldDim); texBlack = Tex(new Color(0f, 0f, 0f, 0.55f)); sTitle = new GUIStyle(GUI.skin.label) { fontStyle = (FontStyle)1, alignment = (TextAnchor)3 }; sTitle.normal.textColor = Gold; sSub = new GUIStyle(sTitle) { fontStyle = (FontStyle)1 }; sSub.normal.textColor = Gold; sLabel = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)3, wordWrap = false }; sLabel.normal.textColor = Ink; sMuted = new GUIStyle(sLabel) { wordWrap = true, alignment = (TextAnchor)0 }; sMuted.normal.textColor = Muted; sValue = new GUIStyle(sLabel) { alignment = (TextAnchor)4, fontStyle = (FontStyle)1 }; sValue.normal.textColor = Ink; sTab = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontStyle = (FontStyle)1 }; sTab.normal.textColor = Muted; sTab.hover.textColor = Ink; sTabOn = new GUIStyle(sTab); sTabOn.normal.textColor = Gold; sTabOn.hover.textColor = Gold; sBtn = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontStyle = (FontStyle)1 }; sBtn.normal.background = texGoldDim; sBtn.normal.textColor = Ink; sBtn.hover.background = texGold; sBtn.hover.textColor = Color32.op_Implicit(new Color32((byte)20, (byte)19, (byte)16, byte.MaxValue)); sBtn.active.background = texGold; sBtn.active.textColor = Color32.op_Implicit(new Color32((byte)20, (byte)19, (byte)16, byte.MaxValue)); sSmallBtn = new GUIStyle(sBtn); sToast = new GUIStyle(sLabel) { alignment = (TextAnchor)4, fontStyle = (FontStyle)1 }; } } private void ScaleStyles() { sTitle.fontSize = f(22f); sSub.fontSize = f(14f); sLabel.fontSize = f(14f); sMuted.fontSize = f(12f); sValue.fontSize = f(13f); sTab.fontSize = f(12f); sTabOn.fontSize = f(12f); sBtn.fontSize = f(13f); sSmallBtn.fontSize = f(12f); sToast.fontSize = f(15f); int f(float px) { return Mathf.RoundToInt(px * uiScale); } } private void OnGUI() { try { GUI.depth = -1000; if (hideOverlayForCapture) { return; } bool flag = headshotFx.Value && Time.unscaledTime - hsAt < 0.9f; if (toast != null || menuOpen || flag) { BuildStyles(); uiScale = Mathf.Clamp((float)Screen.height / 1080f, 0.8f, 2f); ScaleStyles(); if (flag && Time.unscaledTime - hsAt < 0.9f) { DrawHeadshot(Time.unscaledTime - hsAt); } if (toast != null) { DrawToast(); } if (menuOpen) { DrawMenu(); } } } catch (Exception e) { Warn("ui", e); } } private void DrawHeadshot(float t) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_0021: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: 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_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) if ((int)Event.current.type == 7) { if (sHs == null) { sHs = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontStyle = (FontStyle)1 }; } float num = ((t < 0.08f) ? Mathf.Lerp(1.45f, 1f, t / 0.08f) : 1f); float num2 = ((t < 0.35f) ? 1f : Mathf.Clamp01(1f - (t - 0.35f) / 0.4f)); float num3 = ((t < 0.5f) ? 1f : Mathf.Clamp01(1f - (t - 0.5f) / 0.4f)); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor((float)Screen.width / 2f, (float)Screen.height / 2f); float num4 = uiScale * num; float num5 = 7f * num4; float num6 = 11f * num4; float num7 = Mathf.Max(2f, 2.6f * num4); Matrix4x4 matrix = GUI.matrix; Color color = GUI.color; for (int i = 0; i < 4; i++) { float num8 = 45f + 90f * (float)i; GUI.matrix = matrix; GUIUtility.RotateAroundPivot(num8, val); GUI.color = new Color(0f, 0f, 0f, 0.55f * num2); GUI.DrawTexture(new Rect(val.x + num5 - 1f, val.y - num7 / 2f - 1f, num6 + 2f, num7 + 2f), (Texture)(object)Texture2D.whiteTexture); GUI.color = new Color(1f, 0.86f, 0.45f, num2); GUI.DrawTexture(new Rect(val.x + num5, val.y - num7 / 2f, num6, num7), (Texture)(object)Texture2D.whiteTexture); } GUI.matrix = matrix; sHs.fontSize = Mathf.RoundToInt(15f * uiScale); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(val.x - 120f * uiScale, val.y + 26f * uiScale + (1f - num3) * 6f * uiScale, 240f * uiScale, 24f * uiScale); sHs.normal.textColor = new Color(0f, 0f, 0f, 0.6f * num3); GUI.Label(new Rect(((Rect)(ref val2)).x + 1f, ((Rect)(ref val2)).y + 1f, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height), "HEADSHOT", sHs); sHs.normal.textColor = new Color(1f, 0.86f, 0.45f, num3); GUI.Label(val2, "HEADSHOT", sHs); GUI.color = color; } } private void DrawToast() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if (Time.unscaledTime > toastUntil) { toast = null; return; } float num = sToast.CalcSize(new GUIContent(toast)).x + 40f * uiScale; float num2 = 36f * uiScale; Rect val = default(Rect); ((Rect)(ref val))..ctor(((float)Screen.width - num) / 2f, 24f * uiScale, num, num2); GUI.DrawTexture(val, (Texture)(object)texPanel); GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).yMax - 2f * uiScale, ((Rect)(ref val)).width, 2f * uiScale), (Texture)(object)texGold); sToast.normal.textColor = Ink; GUI.Label(val, toast, sToast); } private float U(float v) { return v * uiScale; } private Rect NextRow(float h) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) Rect result = new Rect(((Rect)(ref body)).x, y, ((Rect)(ref body)).width, U(h)); y += U(h) + U(4f); return result; } private void Section(string text) { //IL_0046: Unknown result type (might be due to invalid I