Decompiled source of Arsenal v1.0.3
Arsenal.dll
Decompiled 3 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using InControl; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using WeaponFramework; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCompany("Arsenal")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+525106222f2f65c442b671b8edae6c51a20d61f9")] [assembly: AssemblyProduct("Arsenal")] [assembly: AssemblyTitle("Arsenal")] [assembly: AssemblyVersion("1.0.0.0")] namespace Arsenal; [HarmonyPatch] internal static class Bench { private sealed class Row { public int Pickups; public int Kills; public int Hits; public float Damage; } internal static readonly bool On = Environment.GetEnvironmentVariable("ARSENAL_BENCH") == "1"; private static readonly Dictionary<string, Row> rows = new Dictionary<string, Row>(); private static readonly Dictionary<Controller, KeyValuePair<string, float>> lastHit = new Dictionary<Controller, KeyValuePair<string, float>>(); private static float writeAt; private static int deaths; private static Row Get(string id) { if (!rows.TryGetValue(id, out var value)) { value = (rows[id] = new Row()); } return value; } private static string HeldId(Controller c) { WeaponInfo val = WeaponRegistry.Held(c); if (val == null) { return "(hands)"; } return val.Id; } [HarmonyPrefix] [HarmonyPatch(typeof(HealthHandler), "TakeDamage", new Type[] { typeof(float), typeof(Controller), typeof(DamageType), typeof(bool), typeof(Vector3), typeof(Vector3) })] private static void BeforeDamage(HealthHandler __instance, out float __state) { __state = (On ? __instance.health : 0f); } [HarmonyPostfix] [HarmonyPatch(typeof(HealthHandler), "TakeDamage", new Type[] { typeof(float), typeof(Controller), typeof(DamageType), typeof(bool), typeof(Vector3), typeof(Vector3) })] private static void AfterDamage(HealthHandler __instance, Controller damager, float __state) { if (!On || (Object)(object)damager == (Object)null) { return; } Controller component = ((Component)((Component)__instance).transform.root).GetComponent<Controller>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component == (Object)(object)damager)) { float num = Mathf.Max(0f, __state - Mathf.Max(0f, __instance.health)); if (!(num <= 0f)) { string text = HeldId(damager); Row row = Get(text); row.Damage += num; row.Hits++; lastHit[component] = new KeyValuePair<string, float>(text, Time.time); MaybeWrite(); } } } [HarmonyPrefix] [HarmonyPatch(typeof(GameManager), "KillPlayer")] private static void Killed(Controller playerToKill) { if (On && !((Object)(object)playerToKill == (Object)null)) { deaths++; if (lastHit.TryGetValue(playerToKill, out var value) && Time.time - value.Value < 6f) { Get(value.Key).Kills++; } else { Get("(nobody / fell)").Kills++; } lastHit.Remove(playerToKill); MaybeWrite(); } } [HarmonyPostfix] [HarmonyPatch(typeof(Fighting), "PickUpWeapon")] private static void PickedUp(Fighting __instance, GameObject go) { if (On && !((Object)(object)go == (Object)null)) { Get(HeldId(((Component)__instance).GetComponent<Controller>())).Pickups++; } } private static void MaybeWrite() { if (Time.unscaledTime < writeAt) { return; } writeAt = Time.unscaledTime + 30f; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(DateTime.Now.ToString("HH:mm:ss") + " deaths " + deaths); stringBuilder.AppendLine(string.Format("{0,-28} {1,7} {2,6} {3,8} {4,8} {5,8}", "weapon", "pickups", "kills", "k/pick", "dmg", "dmg/pick")); foreach (KeyValuePair<string, Row> item in rows.OrderByDescending((KeyValuePair<string, Row> k) => (k.Value.Pickups <= 0) ? 0f : ((float)k.Value.Kills / (float)k.Value.Pickups))) { Row value = item.Value; stringBuilder.AppendLine($"{item.Key,-28} {value.Pickups,7} {value.Kills,6} {((value.Pickups > 0) ? ((float)value.Kills / (float)value.Pickups) : 0f),8:0.00} {value.Damage,8:0} {((value.Pickups > 0) ? (value.Damage / (float)value.Pickups) : 0f),8:0}"); } try { File.WriteAllText(Path.Combine(Paths.BepInExRootPath, "Arsenal-bench.txt"), stringBuilder.ToString()); } catch (Exception) { } } } internal sealed class BounceBench : MonoBehaviour { private sealed class Probe { private readonly GameObject go; private readonly Rigidbody rb; private float lastVy; private float impactY = float.NaN; private float peak = float.NegativeInfinity; private int bounces; private float lateSpeed; private float lateSpin; private float lateN; private Vector3 lateFrom; private bool lateStarted; public string Material = "-"; public Probe(GameObject prefab, Vector3 at, Vector3 v) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) go = Object.Instantiate<GameObject>(prefab, at, Quaternion.identity); rb = go.GetComponent<Rigidbody>(); if ((Object)(object)rb != (Object)null) { rb.velocity = v; if (((Vector3)(ref v)).sqrMagnitude > 0f) { rb.angularVelocity = new Vector3(6f, 0f, 0f); } } } public void Step(float end) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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_0146: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rb == (Object)null) { return; } if (Material == "-") { Collider[] componentsInChildren = go.GetComponentsInChildren<Collider>(); foreach (Collider val in componentsInChildren) { if (!val.isTrigger) { Material = (((Object)(object)val.sharedMaterial != (Object)null) ? (((Object)val.sharedMaterial).name + " " + val.sharedMaterial.bounciness.ToString("0.00")) : "none"); break; } } } float y = rb.velocity.y; float y2 = rb.position.y; if (lastVy < -1f && y > 1f) { bounces++; if (float.IsNaN(impactY)) { impactY = y2; } } if (!float.IsNaN(impactY)) { peak = Mathf.Max(peak, y2 - impactY); } lastVy = y; if (Time.time > end - 1f) { if (!lateStarted) { lateStarted = true; lateFrom = rb.position; } float num = lateSpeed; Vector3 val2 = rb.velocity; lateSpeed = num + ((Vector3)(ref val2)).magnitude; float num2 = lateSpin; val2 = rb.angularVelocity; lateSpin = num2 + ((Vector3)(ref val2)).magnitude; lateN += 1f; } } public override string ToString() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rb == (Object)null) { return "no body"; } float num = (lateStarted ? Mathf.Abs(rb.position.z - lateFrom.z) : 0f); return "bounces " + bounces + " rebound " + (float.IsNegativeInfinity(peak) ? 0f : peak).ToString("0.00") + " end speed " + ((lateN > 0f) ? (lateSpeed / lateN) : 0f).ToString("0.00") + " spin " + ((lateN > 0f) ? (lateSpin / lateN) : 0f).ToString("0.0") + " slide " + num.ToString("0.00") + " at y " + (rb.position.y - -9.05f).ToString("0.00"); } public void Done() { if ((Object)(object)go != (Object)null) { Object.Destroy((Object)(object)go); } } } private const float Floor = -9.05f; private const float Trial = 3.5f; private float checkAt; private bool running; public static void Install() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown if (!(Environment.GetEnvironmentVariable("ARSENAL_BENCH") != "1")) { GameObject val = new GameObject("Arsenal BounceBench"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<BounceBench>(); } } private void Update() { if (!running && !(Time.unscaledTime < checkAt)) { checkAt = Time.unscaledTime + 0.3f; string path = Path.Combine(Paths.BepInExRootPath, "Arsenal-bounce.txt"); if (File.Exists(path)) { string arg = File.ReadAllText(path).Trim(); File.Delete(path); ((MonoBehaviour)this).StartCoroutine(Run(arg)); } } } private IEnumerator Run(string arg) { running = true; Controller val = Object.FindObjectOfType<Controller>(); Weapons list = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponentInChildren<Weapons>(true) : null); if ((Object)(object)list == (Object)null) { Plugin.Log.LogWarning((object)"Bounce: no player"); running = false; yield break; } List<int> list2 = new List<int>(); if (arg == "all") { for (int i = 0; i < ((Component)list).transform.childCount; i++) { list2.Add(i); } } else { string[] array = arg.Split(new char[1] { ' ' }); for (int j = 0; j < array.Length; j++) { if (int.TryParse(array[j], out var result)) { list2.Add(result); } } } foreach (int i2 in list2) { if (i2 >= ((Component)list).transform.childCount) { continue; } Weapon component = ((Component)((Component)list).transform.GetChild(i2)).GetComponent<Weapon>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.weaponDrop == (Object)null)) { WeaponInfo byIndex = WeaponRegistry.GetByIndex(i2); string name = ((byIndex != null) ? byIndex.Name : ((Object)component).name); Probe drop = new Probe(component.weaponDrop, new Vector3(0f, -2.0500002f, -14f), Vector3.zero); Probe thrown = new Probe(component.weaponDrop, new Vector3(0f, -3.0500002f, -8f), new Vector3(0f, -12f, 32.8f)); float end = Time.time + 3.5f; while (Time.time < end) { yield return (object)new WaitForFixedUpdate(); drop.Step(end); thrown.Step(end); } Plugin.Log.LogInfo((object)("Bounce: #" + i2 + " " + name + " | mat " + drop.Material + " | drop " + drop?.ToString() + " | throw " + thrown)); drop.Done(); thrown.Done(); yield return null; } } Plugin.Log.LogInfo((object)"Bounce: done"); running = false; } } internal static class Extrude { public const float Depth = 0.0625f; private static readonly Dictionary<string, Mesh> meshes = new Dictionary<string, Mesh>(); public static readonly Dictionary<Texture2D, Texture2D> ShapeOf = new Dictionary<Texture2D, Texture2D>(); private static Shader standard; public static Mesh MeshFor(Texture2D tex, float turn = 0f) { if ((Object)(object)tex != (Object)null && ShapeOf.TryGetValue(tex, out var value)) { tex = value; } if ((Object)(object)tex == (Object)null) { return null; } string key = ((Object)tex).GetInstanceID() + "|" + Mathf.RoundToInt(turn); if (meshes.TryGetValue(key, out var value2) && (Object)(object)value2 != (Object)null) { return value2; } value2 = Build(tex, turn); meshes[key] = value2; return value2; } public static Material MaterialFor(Texture2D tex) { //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_0032: Expected O, but got Unknown //IL_0033: 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) if ((Object)(object)standard == (Object)null) { standard = Shader.Find("Standard"); } Material val = new Material(standard) { name = "Arsenal picture" }; val.color = Color.black; if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0f); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0f); } val.EnableKeyword("_EMISSION"); val.SetColor("_EmissionColor", Color.white); SetPicture(val, tex); return val; } public static void SetPicture(Material m, Texture2D tex) { if (!((Object)(object)m == (Object)null)) { m.SetTexture("_EmissionMap", (Texture)(object)tex); m.mainTexture = (Texture)(object)tex; } } private static Mesh Build(Texture2D tex, float turn) { //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Expected O, but got Unknown //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020c: 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_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0263: 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_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: 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_03de: Unknown result type (might be due to invalid IL or missing references) int num = ((((Texture)tex).width <= 64) ? ((Texture)tex).width : 32); int num2 = num; int num3 = Mathf.Max(1, Mathf.RoundToInt((float)(num * ((Texture)tex).height) / (float)((Texture)tex).width)); if (((Texture)tex).width <= 64) { num3 = ((Texture)tex).height; } Color[] pixels = tex.GetPixels(); bool[,] array = new bool[num2, num3]; for (int i = 0; i < num3; i++) { for (int j = 0; j < num2; j++) { int num4 = j * ((Texture)tex).width / num2; int num5 = Mathf.Max(num4 + 1, (j + 1) * ((Texture)tex).width / num2); int num6 = i * ((Texture)tex).height / num3; int num7 = Mathf.Max(num6 + 1, (i + 1) * ((Texture)tex).height / num3); int num8 = 0; int num9 = 0; for (int k = num6; k < num7; k++) { for (int l = num4; l < num5; l++) { num8++; if (pixels[k * ((Texture)tex).width + l].a > 0.5f) { num9++; } } } array[j, i] = num9 * 2 > num8; } } List<Vector3> list = new List<Vector3>(); List<Vector2> list2 = new List<Vector2>(); List<int> list3 = new List<int>(); float num10 = 1f / 32f; Vector2 mid = default(Vector2); for (int m = 0; m < num3; m++) { for (int n = 0; n < num2; n++) { if (array[n, m]) { float num11 = (float)n / (float)num2; float num12 = (float)(n + 1) / (float)num2; float num13 = (float)m / (float)num3; float num14 = (float)(m + 1) / (float)num3; float num15 = num11 - 0.5f; float num16 = num12 - 0.5f; float num17 = num13 - 0.5f; float num18 = num14 - 0.5f; ((Vector2)(ref mid))..ctor((num11 + num12) * 0.5f, (num13 + num14) * 0.5f); Quad(list, list2, list3, new Vector3(num15, num17, 0f - num10), new Vector3(num15, num18, 0f - num10), new Vector3(num16, num18, 0f - num10), new Vector3(num16, num17, 0f - num10), new Vector2(num11, num13), new Vector2(num11, num14), new Vector2(num12, num14), new Vector2(num12, num13), Vector3.back); Quad(list, list2, list3, new Vector3(num15, num17, num10), new Vector3(num15, num18, num10), new Vector3(num16, num18, num10), new Vector3(num16, num17, num10), new Vector2(num11, num13), new Vector2(num11, num14), new Vector2(num12, num14), new Vector2(num12, num13), Vector3.forward); if (n == 0 || !array[n - 1, m]) { Wall(list, list2, list3, new Vector3(num15, num17, 0f - num10), new Vector3(num15, num18, 0f - num10), new Vector3(num15, num18, num10), new Vector3(num15, num17, num10), mid, Vector3.left); } if (n == num2 - 1 || !array[n + 1, m]) { Wall(list, list2, list3, new Vector3(num16, num17, 0f - num10), new Vector3(num16, num18, 0f - num10), new Vector3(num16, num18, num10), new Vector3(num16, num17, num10), mid, Vector3.right); } if (m == 0 || !array[n, m - 1]) { Wall(list, list2, list3, new Vector3(num15, num17, 0f - num10), new Vector3(num16, num17, 0f - num10), new Vector3(num16, num17, num10), new Vector3(num15, num17, num10), mid, Vector3.down); } if (m == num3 - 1 || !array[n, m + 1]) { Wall(list, list2, list3, new Vector3(num15, num18, 0f - num10), new Vector3(num16, num18, 0f - num10), new Vector3(num16, num18, num10), new Vector3(num15, num18, num10), mid, Vector3.up); } } } } Mesh val = new Mesh { name = "Arsenal picture " + ((Object)tex).name }; if (turn != 0f) { Quaternion val2 = Quaternion.AngleAxis(turn, Vector3.forward); for (int num19 = 0; num19 < list.Count; num19++) { list[num19] = val2 * list[num19]; } } val.SetVertices(list); val.SetUVs(0, list2); val.SetTriangles(list3, 0); val.RecalculateNormals(); val.RecalculateBounds(); return val; } private static void Wall(List<Vector3> v, List<Vector2> uv, List<int> tri, Vector3 a, Vector3 b, Vector3 c, Vector3 e, Vector2 mid, Vector3 n) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0010: 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) Quad(v, uv, tri, a, b, c, e, mid, mid, mid, mid, n); } private static void Quad(List<Vector3> v, List<Vector2> uv, List<int> tri, Vector3 a, Vector3 b, Vector3 c, Vector3 e, Vector2 ua, Vector2 ub, Vector2 uc, Vector2 ue, Vector3 n) { //IL_0008: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) int count = v.Count; v.Add(a); v.Add(b); v.Add(c); v.Add(e); uv.Add(ua); uv.Add(ub); uv.Add(uc); uv.Add(ue); if (!(Vector3.Dot(Vector3.Cross(b - a, c - a), n) < 0f)) { tri.Add(count); tri.Add(count + 1); tri.Add(count + 2); tri.Add(count); tri.Add(count + 2); tri.Add(count + 3); } else { tri.Add(count); tri.Add(count + 2); tri.Add(count + 1); tri.Add(count); tri.Add(count + 3); tri.Add(count + 2); } } } internal static class Hold { public const float LightMass = 2.5f; public const float LighterMass = 1.25f; public static void Light(Weapon w) { SetMass(w, 2.5f); } public static void Lighter(Weapon w) { SetMass(w, 1.25f); } private static void SetMass(Weapon w, float mass) { Rigidbody val = (((Object)(object)w != (Object)null) ? ((Component)w).GetComponent<Rigidbody>() : null); if ((Object)(object)val != (Object)null) { val.mass = mass; } } } internal sealed class HoldProbe : MonoBehaviour { private static readonly bool On = Environment.GetEnvironmentVariable("ARSENAL_BENCH") == "1"; private static readonly FieldRef<Fighting, Rigidbody> RightHand = AccessTools.FieldRefAccess<Fighting, Rigidbody>("rightHand"); private static readonly FieldRef<Fighting, Rigidbody> WeaponBody = AccessTools.FieldRefAccess<Fighting, Rigidbody>("weaponBody"); private static readonly FieldRef<Fighting, Transform> AimPosition = AccessTools.FieldRefAccess<Fighting, Transform>("aimPosition"); private Weapon current; private float since; private int n; private float gapSum; private float gapMax; private float leanSum; private float lagSum; private float lagMax; private float speedSum; private float errSum; private float errSq; private float spinSum; private float lastErr; private Vector3 hipStart; private float checkAt; public static void Install() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (On) { GameObject val = new GameObject("Arsenal HoldProbe"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<HoldProbe>(); } } private void Update() { if (Time.unscaledTime < checkAt) { return; } checkAt = Time.unscaledTime + 0.5f; string path = Path.Combine(Paths.BepInExRootPath, "Arsenal-steady.txt"); try { Steady.DampNow = ((File.Exists(path) && float.TryParse(File.ReadAllText(path).Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) ? result : 0.45f); } catch (Exception) { } } private static float Angle(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return Mathf.Atan2(v.y, v.z) * 57.29578f; } private void FixedUpdate() { //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0206: 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_0224: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: 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) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_034d: 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_035d: Unknown result type (might be due to invalid IL or missing references) Controller val = null; foreach (Controller item in Players.All) { if ((Object)(object)item != (Object)null && item.playerID == 0) { val = item; break; } } if ((Object)(object)val == (Object)null || Players.IsDead(val)) { return; } Fighting component = ((Component)val).GetComponent<Fighting>(); if ((Object)(object)component == (Object)null) { return; } if ((Object)(object)component.weapon != (Object)(object)current) { current = component.weapon; since = 0f; n = 0; gapSum = (gapMax = (leanSum = (lagSum = (lagMax = (speedSum = (errSum = (errSq = (spinSum = 0f)))))))); } else { if ((Object)(object)current == (Object)null) { return; } since += Time.fixedDeltaTime; if (since < 1.5f) { return; } Rigidbody val3 = RightHand.Invoke(component); Rigidbody val4 = WeaponBody.Invoke(component); Rigidbody val5 = Players.Hip(val); Rigidbody val6 = Players.Torso(val); Transform val7 = AimPosition.Invoke(component); if ((Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null || (Object)(object)val6 == (Object)null || (Object)(object)val7 == (Object)null) { return; } if (n == 0) { hipStart = val5.position; } Transform val8 = ((((Component)current).transform.childCount > 0) ? ((Component)current).transform.GetChild(0) : ((Component)current).transform); float num = Vector3.Distance(val3.position, val8.position); float num2 = Vector3.Angle(((Component)val4).transform.forward, val7.forward); float num3 = Mathf.DeltaAngle(Angle(val7.forward), Angle(((Component)val4).transform.forward)); gapSum += num; gapMax = Mathf.Max(gapMax, num); lagSum += num2; lagMax = Mathf.Max(lagMax, num2); errSum += num3; errSq += num3 * num3; if (n > 0) { spinSum += Mathf.Abs(num3 - lastErr) / Time.fixedDeltaTime; } lastErr = num3; leanSum += Vector3.Angle(((Component)val6).transform.up, Vector3.up); float num4 = speedSum; Vector2 val9 = new Vector2(val5.velocity.y, val5.velocity.z); speedSum = num4 + ((Vector2)(ref val9)).magnitude; n++; if (!(since < 4.5f)) { WeaponInfo val10 = WeaponRegistry.Of(current); Vector3 val11 = val5.position - hipStart; val11.x = 0f; float num5 = errSum / (float)n; float num6 = Mathf.Sqrt(Mathf.Max(0f, errSq / (float)n - num5 * num5)); string text = string.Format("{0,-24} gap {1,5:0.00} (max {2,4:0.00}) drift {3,5:0.00} speed {4,5:0.00} lean {5,5:0.0} lag {6,5:0.0} (max {7,5:0.0}) wob {9,5:0.00} spin {10,6:0.0} mass {8:0.#}", (val10 != null) ? val10.Id : ((Object)current).name, gapSum / (float)n, gapMax, ((Vector3)(ref val11)).magnitude, speedSum / (float)n, leanSum / (float)n, lagSum / (float)n, lagMax, val4.mass, num6, spinSum / (float)Mathf.Max(1, n - 1)); try { File.AppendAllText(Path.Combine(Paths.BepInExRootPath, "Arsenal-hold.txt"), text + "\n"); } catch (Exception) { } since = -1000f; } } } } [HarmonyPatch(typeof(Fighting), "SetWeapon")] internal static class AmmoLog { private static readonly bool On = Environment.GetEnvironmentVariable("ARSENAL_BENCH") == "1"; private static readonly FieldRef<Fighting, int> Left = AccessTools.FieldRefAccess<Fighting, int>("bulletsLeft"); private static void Postfix(Fighting __instance) { if (On && !((Object)(object)__instance.weapon == (Object)null)) { WeaponInfo val = WeaponRegistry.Of(__instance.weapon); Controller component = ((Component)__instance).GetComponent<Controller>(); Plugin.Log.LogInfo((object)("Equip: P" + (((Object)(object)component != (Object)null) ? (component.playerID + 1) : 0) + " " + ((val != null) ? val.Id : ((Object)__instance.weapon).name) + " ammo " + Left.Invoke(__instance))); } } } internal sealed class PreviewHook : MonoBehaviour { private float checkAt; public static void Install() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown if (!(Environment.GetEnvironmentVariable("ARSENAL_BENCH") != "1")) { GameObject val = new GameObject("Arsenal PreviewHook"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<PreviewHook>(); } } private void Update() { if (Time.unscaledTime < checkAt) { return; } checkAt = Time.unscaledTime + 0.3f; string path = Path.Combine(Paths.BepInExRootPath, "Arsenal-preview.txt"); if (File.Exists(path)) { string[] array = File.ReadAllText(path).Trim().Split(new char[1] { '|' }); File.Delete(path); if (array.Length >= 2) { ((MonoBehaviour)this).StartCoroutine(Open(array[0].Trim(), array[1].Trim())); } } } private IEnumerator Open(string category, string weapon) { PauseManager pm = Object.FindObjectOfType<PauseManager>(); if ((Object)(object)pm == (Object)null) { Plugin.Log.LogWarning((object)"Preview: no PauseManager"); yield break; } if (!PauseManager.isPaused) { pm.Pause(); } yield return null; pm.OpenWeaponSelect(); yield return (object)new WaitForSecondsRealtime(0.6f); Type type = typeof(Plugin).Assembly.GetType("WeaponFramework.WeaponPage"); object page = type?.GetField("Instance", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null); if (page == null) { Plugin.Log.LogWarning((object)"Preview: no weapon page"); yield break; } Type two = type.BaseType; IList cats = (IList)two.GetField("cats", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).GetValue(page); MethodInfo method = two.GetMethod("CategoryName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); MethodInfo method2 = two.GetMethod("Show", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); int ci = -1; for (int i = 0; i < cats.Count; i++) { int num = (int)cats[i].GetType().GetField("Index").GetValue(cats[i]); if (string.Equals((string)method.Invoke(page, new object[1] { num }), category, StringComparison.OrdinalIgnoreCase)) { ci = i; break; } } if (ci < 0) { Plugin.Log.LogWarning((object)("Preview: no category " + category)); yield break; } Type type2 = Type.GetType("UnityEngine.EventSystems.EventSystem, UnityEngine.UI"); object cur = type2.GetProperty("current").GetValue(null, null); MethodInfo select = type2.GetMethod("SetSelectedGameObject", new Type[1] { typeof(GameObject) }); select.Invoke(cur, new object[1] { cats[ci].GetType().GetField("Go").GetValue(cats[ci]) }); method2.Invoke(page, new object[2] { ci, false }); yield return (object)new WaitForSecondsRealtime(0.3f); List<string> list = new List<string>(); IList obj = (IList)two.GetField("rows", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).GetValue(page); MethodInfo method3 = two.GetMethod("Describe", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); int num2 = (int)cats[ci].GetType().GetField("Index").GetValue(cats[ci]); foreach (object item in obj) { int num3 = (int)item.GetType().GetField("Index").GetValue(item); object[] array = new object[4] { num2, num3, null, null }; method3.Invoke(page, array); list.Add((string)array[2]); string text = ((string)array[2]) ?? ""; int num4 = text.IndexOf('<'); if (num4 >= 0) { text = text.Substring(0, num4); } if (string.Equals(text.Trim(), weapon, StringComparison.OrdinalIgnoreCase)) { select.Invoke(cur, new object[1] { item.GetType().GetField("Go").GetValue(item) }); Plugin.Log.LogInfo((object)("Preview: showing " + category + " / " + weapon)); yield break; } } Plugin.Log.LogWarning((object)("Preview: no " + weapon + " in " + category + " (" + string.Join(", ", list.ToArray()) + ")")); } } internal static class Mc { public const float BowSize = 1.05f; public const float BowAngle = 135f; public static readonly Vector2 BowGrip = new Vector2(-0.22f, 0.22f); public const float ArrowSize = 1.2f; public const float ArrowAngle = 45f; public static readonly Vector2 ArrowTip = new Vector2(0.375f, 0.375f); private static readonly string[] bowNames = new string[4] { "bow", "bow_pulling_0", "bow_pulling_1", "bow_pulling_2" }; private static Texture2D[] bow; private static bool bowChecked; private static readonly Dictionary<string, Texture2D[]> strips = new Dictionary<string, Texture2D[]>(); private static readonly Dictionary<Texture2D, Texture2D[]> glinted = new Dictionary<Texture2D, Texture2D[]>(); public const int GlintFrames = 32; public const float GlintPeriod = 2.6f; private const float Glint = 0.6f; private static GameObject arrowPrefab; private static GameObject arrowFrom; public const int BowIndex = 13; public static Texture2D[] Bow { get { if (bowChecked) { return bow; } bowChecked = true; Texture2D[] array = (Texture2D[])(object)new Texture2D[4]; for (int i = 0; i < 4; i++) { if ((Object)(object)(array[i] = Private.Sprite(bowNames[i])) == (Object)null) { return bow = null; } } return bow = array; } } public static Texture2D Arrow => Private.Sprite("arrow"); public static FlatSprite Flat(Transform parent, Texture2D tex, float size, float angle, Vector2 grip, Vector3 anchorLocal, bool followForward) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) GameObject val = Solid(parent, tex, "Arsenal flat picture", 0f - angle); FlatSprite flatSprite = val.AddComponent<FlatSprite>(); flatSprite.Anchor = parent; flatSprite.AnchorLocal = anchorLocal; flatSprite.Size = size; flatSprite.Angle = angle; flatSprite.Grip = grip; flatSprite.FollowForward = followForward; flatSprite.Material = ((Renderer)val.GetComponent<MeshRenderer>()).sharedMaterial; flatSprite.LateUpdate(); return flatSprite; } public static GameObject Solid(Transform parent, Texture2D tex, string name, float turn = 0f) { //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_0017: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown GameObject val = new GameObject(name) { layer = ((Component)parent).gameObject.layer }; val.transform.SetParent(parent, false); val.AddComponent<MeshFilter>().sharedMesh = Extrude.MeshFor(tex, turn); MeshRenderer obj = val.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = Extrude.MaterialFor(tex); ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; return val; } public static GameObject Quad(Transform parent, Texture2D tex, string name) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)obj).name = name; Object.Destroy((Object)(object)obj.GetComponent<Collider>()); obj.layer = ((Component)parent).gameObject.layer; obj.transform.SetParent(parent, false); MeshRenderer component = obj.GetComponent<MeshRenderer>(); Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Transparent"); ((Renderer)component).sharedMaterial = new Material(val) { mainTexture = (Texture)(object)tex }; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; return obj; } public static void HideModel(Transform root) { Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!(val is ParticleSystemRenderer) && !(val is TrailRenderer) && !((Object)(object)((Component)val).GetComponent<FlatSprite>() != (Object)null) && !((Object)(object)((Component)val).GetComponent<Flipbook>() != (Object)null)) { val.enabled = false; } } SetLinePositions[] componentsInChildren2 = ((Component)root).GetComponentsInChildren<SetLinePositions>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { ((Behaviour)componentsInChildren2[i]).enabled = false; } } public static Transform HandPosition(Transform weapon) { Transform val = weapon.Find("handPosition"); if ((Object)(object)val == (Object)null && weapon.childCount > 0) { val = weapon.GetChild(0); } return val; } public static Texture2D[] Fire(string name) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown if (strips.TryGetValue(name, out var value)) { return value; } value = null; Texture2D val = Private.Sprite(name); if ((Object)(object)val != (Object)null && ((Texture)val).width > 0 && ((Texture)val).height >= ((Texture)val).width * 2) { int width = ((Texture)val).width; int num = ((Texture)val).height / width; value = (Texture2D[])(object)new Texture2D[num]; for (int i = 0; i < num; i++) { int num2 = (i + num / 2) % num; Texture2D val2 = new Texture2D(width, width, (TextureFormat)4, false) { filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)1 }; val2.SetPixels(val.GetPixels(0, ((Texture)val).height - width * (num2 + 1), width, width)); val2.Apply(false, false); value[i] = val2; } } strips[name] = value; return value; } public static Flipbook FireOn(Transform follow, Vector3 offset, float size, string strip) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) Texture2D[] array = Fire(strip); if (array == null || (Object)(object)follow == (Object)null) { return null; } GameObject val = Quad(follow, array[0], "Arsenal fire"); val.transform.localScale = Vector3.one * size / Mathf.Max(0.01f, Mathf.Abs(follow.lossyScale.x)); Flipbook flipbook = val.AddComponent<Flipbook>(); flipbook.Frames = array; flipbook.Follow = follow; flipbook.Offset = offset; flipbook.Fps = 20f; flipbook.Material = ((Renderer)val.GetComponent<MeshRenderer>()).sharedMaterial; return flipbook; } public static Texture2D[] Glinted(Texture2D src) { //IL_0059: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: 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_01fc: 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_0224: 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_0259: 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_028e: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)src == (Object)null) { return null; } if (glinted.TryGetValue(src, out var value)) { return value; } value = null; Texture2D val = Private.Sprite("enchanted_glint_item"); if ((Object)(object)val != (Object)null) { int num = Mathf.Max(1, 64 / ((Texture)src).width); Color[] pixels = src.GetPixels(); value = (Texture2D[])(object)new Texture2D[32]; Vector2 val2 = Dir(-50f); Vector2 val3 = Dir(10f); for (int i = 0; i < 32; i++) { float num2 = (float)i / 32f; Color[] array = (Color[])(object)new Color[4096]; for (int j = 0; j < 64; j++) { for (int k = 0; k < 64; k++) { int num3 = Mathf.Min(((Texture)src).width - 1, k / num); int num4 = Mathf.Min(((Texture)src).height - 1, j / num); Color val4 = pixels[num4 * ((Texture)src).width + num3]; if (val4.a <= 0.01f) { array[j * 64 + k] = new Color(0f, 0f, 0f, 0f); continue; } float num5 = (float)k / 64f; float num6 = (float)j / 64f; float num7 = (num5 * val2.x - num6 * val2.y) * 0.5f + num2; float num8 = (num5 * val2.y + num6 * val2.x) * 0.5f; float num9 = (num5 * val3.x - num6 * val3.y) * 0.5f - num2; float num10 = (num5 * val3.y + num6 * val3.x) * 0.5f; Color val5 = val.GetPixelBilinear(Mathf.Repeat(num7, 1f), Mathf.Repeat(num8, 1f)) + val.GetPixelBilinear(Mathf.Repeat(num9, 1f), Mathf.Repeat(num10, 1f)); float num11 = 0.3f * val4.r + 0.59f * val4.g + 0.11f * val4.b; val4.r = Mathf.Min(1f, val4.r * 0.45f + 0.405f * num11 + val5.r * 0.6f); val4.g = Mathf.Min(1f, val4.g * 0.45f + 0.225f * num11 + val5.g * 0.6f); val4.b = Mathf.Min(1f, val4.b * 0.45f + 0.675f * num11 + val5.b * 0.6f); array[j * 64 + k] = val4; } } Texture2D val6 = new Texture2D(64, 64, (TextureFormat)4, false) { filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)1 }; val6.SetPixels(array); val6.Apply(false, false); value[i] = val6; Extrude.ShapeOf[val6] = src; } } glinted[src] = value; return value; } private static Vector2 Dir(float deg) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) float num = deg * ((float)Math.PI / 180f); return new Vector2(Mathf.Cos(num), Mathf.Sin(num)); } public static GameObject SkinnedArrow(GameObject projectile) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)projectile == (Object)null || (Object)(object)Arrow == (Object)null) { return projectile; } if ((Object)(object)arrowPrefab != (Object)null && (Object)(object)arrowFrom == (Object)(object)projectile) { return arrowPrefab; } GameObject val = new GameObject("Arsenal pixel arrows"); val.SetActive(false); Object.DontDestroyOnLoad((Object)(object)val); GameObject obj = Object.Instantiate<GameObject>(projectile, val.transform, false); ((Object)obj).name = ((Object)projectile).name; HideModel(obj.transform); Flat(obj.transform, Arrow, 1.2f, 45f, ArrowTip, new Vector3(0f, 0f, 0.16f), followForward: true); ProjectileCollision component = obj.GetComponent<ProjectileCollision>(); AudioClip[] array = Sounds("bow_hit"); if ((Object)(object)component != (Object)null && array != null) { component.clips = array; } StickyObject component2 = obj.GetComponent<StickyObject>(); if ((Object)(object)component2 != (Object)null) { component2.offset = -0.15f; } arrowPrefab = obj; arrowFrom = projectile; return obj; } public static AudioClip[] Sounds(string name) { List<AudioClip> list = new List<AudioClip>(); AudioClip val = Private.Sound(name, null); if ((Object)(object)val != (Object)null) { list.Add(val); } int num = 2; while ((Object)(object)val != (Object)null && num < 10) { val = Private.Sound(name + "_" + num, null); if ((Object)(object)val != (Object)null) { list.Add(val); } num++; } if (list.Count <= 0) { return null; } return list.ToArray(); } public static void DressHeldBow(Weapon w) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (Bow != null && !((Object)(object)((Component)w).GetComponent<BowSprite>() != (Object)null)) { Transform val = HandPosition(((Component)w).transform); HideModel(((Component)w).transform); FlatSprite flat = Flat(((Component)w).transform, Bow[0], 1.05f, 135f, BowGrip, ((Object)(object)val != (Object)null) ? val.localPosition : Vector3.zero, followForward: true); BowSprite bowSprite = ((Component)w).gameObject.AddComponent<BowSprite>(); bowSprite.Weapon = w; bowSprite.Flat = flat; AudioClip[] array = Sounds("bow_shoot"); if (array != null) { w.clips = array; } bowSprite.DrawSound = Private.Sound("bow_draw", null); Plugin.Log.LogInfo((object)("Pixel bow look on " + ((Object)w).name + " (" + ((Object)((Component)w).transform.root).name + ").")); } } public static void DressPickupBow(GameObject p, bool enchanted) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (Bow != null && !((Object)(object)p.GetComponentInChildren<FlatSprite>(true) != (Object)null)) { HideModel(p.transform); FlatSprite flat = Flat(p.transform, Bow[0], 1.05f, 135f, Vector2.zero, Vector3.zero, followForward: false); if (enchanted) { BowSprite bowSprite = p.AddComponent<BowSprite>(); bowSprite.Flat = flat; bowSprite.Glint = true; } } } public static Texture2D[][] Frames(Texture2D[] pics, bool glint) { Texture2D[][] array = new Texture2D[pics.Length][]; for (int i = 0; i < pics.Length; i++) { Texture2D[] array2 = (glint ? Glinted(pics[i]) : null); array[i] = (Texture2D[])(((object)array2) ?? ((object)new Texture2D[1] { pics[i] })); } return array; } } internal sealed class FlatSprite : MonoBehaviour { public Transform Anchor; public Vector3 AnchorLocal; public float Size = 1f; public float Angle; public Vector2 Grip; public bool FollowForward = true; public float Depth = -0.06f; public Material Material; private float roll; private bool ownMaterial; public void Show(Texture2D t) { if (!((Object)(object)Material == (Object)null) && !((Object)(object)Material.mainTexture == (Object)(object)t)) { Extrude.SetPicture(Material, t); MeshFilter component = ((Component)this).GetComponent<MeshFilter>(); if ((Object)(object)component != (Object)null) { component.sharedMesh = Extrude.MeshFor(t, 0f - Angle); } } } private void Awake() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown MeshRenderer component = ((Component)this).GetComponent<MeshRenderer>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)((Renderer)component).sharedMaterial == (Object)null)) { Material = new Material(((Renderer)component).sharedMaterial); ((Renderer)component).sharedMaterial = Material; ownMaterial = true; } } private void OnDestroy() { if (ownMaterial && (Object)(object)Material != (Object)null) { Object.Destroy((Object)(object)Material); } } public void LateUpdate() { //IL_0015: 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_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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_012e: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: 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) if (!((Object)(object)Anchor == (Object)null)) { Vector3 forward = Anchor.forward; Vector3 up = Anchor.up; float num = forward.y * forward.y + forward.z * forward.z; float num2 = up.y * up.y + up.z * up.z; float num3 = ((FollowForward && num > 0.04f) ? (Mathf.Atan2(forward.y, 0f - forward.z) * 57.29578f) : ((num2 > 0.04f) ? (Mathf.Atan2(up.y, 0f - up.z) * 57.29578f - 90f) : ((!(num > 0.04f)) ? (roll + Angle) : (Mathf.Atan2(forward.y, 0f - forward.z) * 57.29578f)))); roll = num3 - Angle; Quaternion val = Quaternion.AngleAxis(num3, Vector3.right) * Quaternion.LookRotation(Vector3.right, Vector3.up); Vector3 val2 = Anchor.TransformPoint(AnchorLocal); Vector3 position = val2 - val * (Quaternion.AngleAxis(0f - Angle, Vector3.forward) * new Vector3(Grip.x * Size, Grip.y * Size, 0f)); position.x = val2.x + Depth; ((Component)this).transform.position = position; ((Component)this).transform.rotation = val; Transform parent = ((Component)this).transform.parent; float num4 = (((Object)(object)parent != (Object)null) ? Mathf.Max(0.0001f, Mathf.Abs(parent.lossyScale.x)) : 1f); ((Component)this).transform.localScale = Vector3.one * (Size / num4); } } } internal sealed class Flipbook : MonoBehaviour { public Texture2D[] Frames; public Transform Follow; public Vector3 Offset; public float Fps = 20f; public Material Material; private float start = -1f; private void OnDestroy() { if ((Object)(object)Material != (Object)null) { Object.Destroy((Object)(object)Material); } } private void LateUpdate() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (Frames != null && Frames.Length != 0) { if (start < 0f) { start = Time.time - Random.value; } Material.mainTexture = (Texture)(object)Frames[(int)((Time.time - start) * Fps) % Frames.Length]; if ((Object)(object)Follow != (Object)null) { ((Component)this).transform.position = Follow.position + Offset; } ((Component)this).transform.rotation = Quaternion.LookRotation(Vector3.right, Vector3.up); } } } internal sealed class BowSprite : MonoBehaviour { public Weapon Weapon; public FlatSprite Flat; public bool Glint; public AudioClip DrawSound; private Texture2D[][] frames; private float shown; private bool drawing; private void Update() { if (frames == null && Mc.Bow != null) { frames = Mc.Frames(Mc.Bow, Glint); } Texture2D[][] array = frames; if ((Object)(object)Flat == (Object)null || array == null) { return; } float num = (((Object)(object)Weapon != (Object)null && Weapon.maxChargeTime > 0f) ? Mathf.Clamp01(Weapon.currentCharge / Weapon.maxChargeTime) : 0f); shown = ((num > shown) ? Mathf.MoveTowards(shown, num, Time.deltaTime * 5f) : num); int num2 = ((!(shown < 0.04f)) ? ((shown < 0.45f) ? 1 : ((shown < 0.85f) ? 2 : 3)) : 0); Texture2D[] array2 = array[Mathf.Min(num2, array.Length - 1)]; Flat.Show((array2.Length == 1) ? array2[0] : array2[(int)(Time.time / 2.6f * (float)array2.Length) % array2.Length]); if (num2 > 0 && !drawing) { drawing = true; if ((Object)(object)DrawSound != (Object)null) { Controller component = ((Component)((Component)this).transform.root).GetComponent<Controller>(); if ((Object)(object)component != (Object)null) { Sounds.Play(component, DrawSound, 0.45f); } } } else if (num2 == 0) { drawing = false; } } } [HarmonyPatch(typeof(Fighting), "PickUpWeapon")] internal static class McPickupPop { private static void Postfix(Fighting __instance, int i, GameObject go) { if (!((Object)(object)go == (Object)null) && !MatchmakingHandler.IsNetworkMatch && Looks(i)) { AudioClip val = Private.Sound("mc_pop", null); Controller component = ((Component)__instance).GetComponent<Controller>(); if ((Object)(object)val != (Object)null && (Object)(object)component != (Object)null) { Sounds.Play(component, val, 0.8f); } } } internal static bool Looks(int index) { switch (index) { case 13: return Mc.Bow != null; case 8: return (Object)(object)McShield.Texture != (Object)null; default: { WeaponInfo byIndex = WeaponRegistry.GetByIndex(index); if (byIndex == null) { return false; } return byIndex.Id switch { "arsenal.warppearl" => (Object)(object)Private.Sprite("warp_pearl") != (Object)null, "arsenal.tiersword" => true, "arsenal.enchantedbow" => Mc.Bow != null, "arsenal.apple" => (Object)(object)Private.Sprite("apple") != (Object)null, "arsenal.cookie" => (Object)(object)Private.Sprite("cookie") != (Object)null, _ => false, }; } } } } [HarmonyPatch] internal static class McBowPreview { private static MethodBase TargetMethod() { if (!Chainloader.PluginInfos.TryGetValue("stickfight.menuoverhaul", out var value) || (Object)(object)value.Instance == (Object)null) { return null; } Type type = ((object)value.Instance).GetType().Assembly.GetType("MenuOverhaul.TwoPanePage"); if ((object)type == null) { return null; } return AccessTools.Method(type, "ShowModel", (Type[])null, (Type[])null); } private static bool Prepare() { return (object)TargetMethod() != null; } private static bool IsShield(GameObject source) { Weapon component = source.GetComponent<Weapon>(); if ((Object)(object)component == (Object)null) { return false; } WeaponInfo val = WeaponRegistry.Of(component); if (val == null) { return ((Object)source).name == "8 Shield"; } return val.Index == 8; } private static void Prefix(GameObject source) { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)source != (Object)null) { FlatSprite[] componentsInChildren = source.GetComponentsInChildren<FlatSprite>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].LateUpdate(); } } if ((Object)(object)source != (Object)null) { McPreviewFlat.Pose(source); } if ((Object)(object)source != (Object)null && PortalBullets.Bench) { Renderer[] componentsInChildren2 = source.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren2) { if (val.enabled && (val is MeshRenderer || val is SpriteRenderer)) { ManualLogSource log = Plugin.Log; string[] obj = new string[9] { "Preview part ", ((Object)val).name, " (", ((object)val).GetType().Name, ") bounds ", null, null, null, null }; Bounds bounds = val.bounds; obj[5] = ((object)((Bounds)(ref bounds)).size/*cast due to .constrained prefix*/).ToString(); obj[6] = " at "; Transform transform = source.transform; bounds = val.bounds; obj[7] = ((object)transform.InverseTransformPoint(((Bounds)(ref bounds)).center)/*cast due to .constrained prefix*/).ToString(); obj[8] = (((Component)val).gameObject.activeInHierarchy ? "" : " inactive"); log.LogInfo((object)string.Concat(obj)); } } } if ((Object)(object)source != (Object)null && (Object)(object)McShield.Texture != (Object)null && (Object)(object)source.GetComponent<McShieldLook>() == (Object)null && IsShield(source)) { try { McShield.Dress(source, held: true); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Pixel shield preview look failed: " + ex.Message)); } } if ((Object)(object)source == (Object)null || Mc.Bow == null || (Object)(object)source.GetComponent<BowSprite>() != (Object)null) { return; } Weapon component = source.GetComponent<Weapon>(); if ((Object)(object)component == (Object)null || (Object)(object)source.GetComponentInChildren<BowHandler>(true) == (Object)null) { return; } WeaponInfo val2 = WeaponRegistry.Of(component); if (val2 != null && val2.Index != 13) { return; } try { Mc.DressHeldBow(component); } catch (Exception ex2) { Plugin.Log.LogWarning((object)("Pixel bow preview look failed: " + ex2.Message)); } } } [HarmonyPatch] internal static class McBowSkin { [HarmonyPostfix] [HarmonyPatch(typeof(Weapon), "OnEnable")] private static void Held(Weapon __instance) { if (Mc.Bow == null || (Object)(object)((Component)__instance).GetComponent<BowSprite>() != (Object)null) { return; } Transform parent = ((Component)__instance).transform.parent; if ((Object)(object)parent == (Object)null || (Object)(object)((Component)parent).GetComponent<Weapons>() == (Object)null || ((Component)__instance).transform.GetSiblingIndex() != 13) { return; } try { Mc.DressHeldBow(__instance); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Pixel bow look failed: " + ex)); } } [HarmonyPostfix] [HarmonyPatch(typeof(WeaponPickUp), "Start")] private static void Pickup(WeaponPickUp __instance) { if (Mc.Bow == null || __instance.id != 13) { return; } try { Mc.DressPickupBow(((Component)__instance).gameObject, enchanted: false); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Pixel bow pickup look failed: " + ex)); } } [HarmonyPrefix] [HarmonyPatch(typeof(Weapon), "ActuallyShoot")] private static void BeforeShoot(Weapon __instance, out GameObject __state) { __state = null; if (!MatchmakingHandler.IsNetworkMatch && !((Object)(object)((Component)__instance).GetComponent<BowSprite>() == (Object)null) && !((Object)(object)((Component)__instance).GetComponent<WeaponBehaviour>() != (Object)null)) { GameObject val = Mc.SkinnedArrow(__instance.projectile); if (!((Object)(object)val == (Object)(object)__instance.projectile)) { __state = __instance.projectile; __instance.projectile = val; } } } [HarmonyFinalizer] [HarmonyPatch(typeof(Weapon), "ActuallyShoot")] private static Exception AfterShoot(Weapon __instance, GameObject __state, Exception __exception) { if ((Object)(object)__state != (Object)null) { __instance.projectile = __state; } return __exception; } } [HarmonyPatch] internal static class McPreviewFlat { private static Type viewType; private static FieldInfo sourceOf; private static FieldInfo spinOf; private static readonly Dictionary<GameObject, bool> pictured = new Dictionary<GameObject, bool>(); private static MethodBase TargetMethod() { if (!Chainloader.PluginInfos.TryGetValue("stickfight.menuoverhaul", out var value) || (Object)(object)value.Instance == (Object)null) { return null; } viewType = ((object)value.Instance).GetType().Assembly.GetType("MenuOverhaul.ModelView"); if ((object)viewType == null) { return null; } sourceOf = AccessTools.Field(viewType, "source"); spinOf = AccessTools.Field(viewType, "spin"); if ((object)sourceOf == null || (object)spinOf == null) { return null; } return AccessTools.Method(viewType, "LateUpdate", (Type[])null, (Type[])null); } private static bool Prepare() { return (object)TargetMethod() != null; } private static void Postfix(object __instance) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) object? value = sourceOf.GetValue(__instance); GameObject val = (GameObject)((value is GameObject) ? value : null); object? value2 = spinOf.GetValue(__instance); Transform val2 = (Transform)((value2 is Transform) ? value2 : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null) && Pictured(val)) { val2.localRotation = Quaternion.identity; } } private static bool Pictured(GameObject src) { if (pictured.TryGetValue(src, out var value)) { return value; } value = (Object)(object)src.GetComponentInChildren<FlatSprite>(true) != (Object)null || (Object)(object)src.GetComponentInChildren<FaceCamera>(true) != (Object)null || (Object)(object)src.GetComponentInChildren<WarpPearl.PearlFace>(true) != (Object)null; pictured[src] = value; return value; } internal static void Pose(GameObject source) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) FaceCamera[] componentsInChildren = source.GetComponentsInChildren<FaceCamera>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).transform.rotation = source.transform.rotation * Quaternion.LookRotation(Vector3.right, Vector3.up); } WarpPearl.PearlFace[] componentsInChildren2 = source.GetComponentsInChildren<WarpPearl.PearlFace>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { ((Component)componentsInChildren2[i]).transform.rotation = source.transform.rotation; } } } internal static class McShield { private sealed class Builder { private readonly List<Vector3> v = new List<Vector3>(); private readonly List<Vector2> uv = new List<Vector2>(); private readonly List<int> tri = new List<int>(); public void Box(Vector3 min, Vector3 size, int u, int vv) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) float x = size.x; float y = size.y; float z = size.z; Vector3 val = min + size * 0.5f; Face(val + new Vector3(0f, 0f, z / 2f), Vector3.left, Vector3.up, x, y, (float)u + z, (float)vv + z); Face(val - new Vector3(0f, 0f, z / 2f), Vector3.right, Vector3.up, x, y, (float)u + 2f * z + x, (float)vv + z); Face(val + new Vector3(x / 2f, 0f, 0f), Vector3.forward, Vector3.up, z, y, u, (float)vv + z); Face(val - new Vector3(x / 2f, 0f, 0f), Vector3.back, Vector3.up, z, y, (float)u + z + x, (float)vv + z); Face(val + new Vector3(0f, y / 2f, 0f), Vector3.left, Vector3.back, x, z, (float)u + z, vv); Face(val - new Vector3(0f, y / 2f, 0f), Vector3.left, Vector3.forward, x, z, (float)u + z + x, vv); } private void Face(Vector3 c, Vector3 right, Vector3 up, float fw, float fh, float tu, float tv) { //IL_000c: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) int count = v.Count; Vector3 val = right * fw / 2f; Vector3 val2 = up * fh / 2f; v.Add((c - val - val2) * 0.08681818f); v.Add((c + val - val2) * 0.08681818f); v.Add((c + val + val2) * 0.08681818f); v.Add((c - val + val2) * 0.08681818f); float num = tu / 64f; float num2 = (tu + fw) / 64f; float num3 = 1f - (tv + fh) / 64f; float num4 = 1f - tv / 64f; uv.Add(new Vector2(num, num3)); uv.Add(new Vector2(num2, num3)); uv.Add(new Vector2(num2, num4)); uv.Add(new Vector2(num, num4)); tri.Add(count); tri.Add(count + 3); tri.Add(count + 2); tri.Add(count); tri.Add(count + 2); tri.Add(count + 1); } public Mesh Done(string name) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown Mesh val = new Mesh { name = name }; val.SetVertices(v); val.SetUVs(0, uv); val.SetTriangles(tri, 0); val.RecalculateNormals(); val.RecalculateBounds(); return val; } } public const int Index = 8; public const float Tilt = 55f; private const float Px = 0.08681818f; private const float Front = 3.2f; public static float Glow = 0.72f; private static Mesh mesh; private static Material material; private static AudioClip[] blocks; private static AudioClip silent; public static Texture2D Texture => Private.Sprite("shield"); public static AudioClip[] Blocks => blocks ?? (blocks = Mc.Sounds("shield_block")); public static AudioClip Silent => silent ?? (silent = AudioClip.Create("Arsenal silence", 64, 1, 44100, false)); private static Mesh Mesh { get { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)mesh != (Object)null) { return mesh; } Builder builder = new Builder(); builder.Box(new Vector3(-6f, -11f, 2.2f), new Vector3(12f, 22f, 1f), 0, 0); builder.Box(new Vector3(-1f, -3f, -3.8f), new Vector3(2f, 6f, 6f), 26, 0); mesh = builder.Done("Arsenal pixel shield"); return mesh; } } public static void Dress(GameObject root, bool held) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) Texture2D texture = Texture; if ((Object)(object)texture == (Object)null || (Object)(object)root.GetComponent<McShieldLook>() != (Object)null) { return; } MeshRenderer[] componentsInChildren = root.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val in componentsInChildren) { if (((Object)val).name.StartsWith("collider")) { ((Renderer)val).enabled = false; } } GameObject val2 = new GameObject("Arsenal pixel shield"); val2.layer = root.layer; val2.transform.SetParent(root.transform, false); val2.AddComponent<MeshFilter>().sharedMesh = Mesh; MeshRenderer obj = val2.AddComponent<MeshRenderer>(); if ((Object)(object)material == (Object)null) { material = Extrude.MaterialFor(texture); material.SetColor("_EmissionColor", Color.white * Glow); } ((Renderer)obj).sharedMaterial = material; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; McShieldLook mcShieldLook = root.AddComponent<McShieldLook>(); mcShieldLook.Slab = val2.transform; mcShieldLook.Held = held; } } internal sealed class McShieldLook : MonoBehaviour { public Transform Slab; public bool Held; public float LastBlock = -1f; private Controller holder; private void LateUpdate() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if (!Held || (Object)(object)Slab == (Object)null) { return; } if ((Object)(object)holder == (Object)null) { holder = ((Component)((Component)this).transform.root).GetComponent<Controller>(); } if ((Object)(object)holder == (Object)null) { return; } Vector3 forward = ((Component)this).transform.forward; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, forward.y, forward.z); if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f)) { ((Vector3)(ref val)).Normalize(); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0f, 0f - val.z, val.y); if (Vector3.Dot(val2, ((Component)this).transform.up) < 0f) { val2 = -val2; } float num = 0.9599311f; Slab.rotation = Quaternion.LookRotation(val * Mathf.Cos(num) + Vector3.left * Mathf.Sin(num), val2); Slab.position = ((Component)this).transform.position; float num2 = Mathf.Max(0.0001f, Mathf.Abs(((Component)this).transform.lossyScale.x)); Slab.localScale = Vector3.one / num2; } } } [HarmonyPatch] internal static class McShieldSkin { private static McShieldLook pending; [HarmonyPostfix] [HarmonyPatch(typeof(Weapon), "OnEnable")] private static void Held(Weapon __instance) { if ((Object)(object)McShield.Texture == (Object)null || (Object)(object)((Component)__instance).GetComponent<McShieldLook>() != (Object)null) { return; } Transform parent = ((Component)__instance).transform.parent; if ((Object)(object)parent == (Object)null || (Object)(object)((Component)parent).GetComponent<Weapons>() == (Object)null || ((Component)__instance).transform.GetSiblingIndex() != 8) { return; } try { McShield.Dress(((Component)__instance).gameObject, held: true); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Pixel shield look failed: " + ex)); } } [HarmonyPostfix] [HarmonyPatch(typeof(WeaponPickUp), "Start")] private static void Pickup(WeaponPickUp __instance) { if (__instance.id != 8 || (Object)(object)McShield.Texture == (Object)null) { return; } try { McShield.Dress(((Component)__instance).gameObject, held: false); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Pixel shield pickup look failed: " + ex)); } } [HarmonyPrefix] [HarmonyPatch(typeof(ProjectileCollision), "HitObject")] private static void BeforeHit(ProjectileCollision __instance, RaycastHit hit, out object[] __state) { __state = null; pending = null; if ((Object)(object)((RaycastHit)(ref hit)).collider == (Object)null || MatchmakingHandler.IsNetworkMatch) { return; } McShieldLook componentInParent = ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<McShieldLook>(); AudioClip[] array = (((Object)(object)componentInParent != (Object)null) ? McShield.Blocks : null); if (array != null) { bool flag = Time.time - componentInParent.LastBlock > 0.08f; componentInParent.LastBlock = Time.time; __state = new object[2] { __instance.clips, __instance.clips2 }; __instance.clips = (AudioClip[])(flag ? ((Array)array) : ((Array)new AudioClip[1] { McShield.Silent })); __instance.clips2 = (AudioClip[])(object)new AudioClip[0]; if (flag) { pending = componentInParent; } } } [HarmonyPrefix] [HarmonyPatch(typeof(ProjectileCollision), "PlayParticles")] private static void Played() { pending = null; } [HarmonyFinalizer] [HarmonyPatch(typeof(ProjectileCollision), "HitObject")] private static Exception AfterHit(ProjectileCollision __instance, object[] __state, Exception __exception) { if (__state == null) { return __exception; } __instance.clips = (AudioClip[])__state[0]; __instance.clips2 = (AudioClip[])__state[1]; McShieldLook mcShieldLook = pending; pending = null; if (PortalBullets.Bench) { Plugin.Log.LogInfo((object)("Shield block sound on " + ((Object)__instance).name + (((Object)(object)mcShieldLook != (Object)null) ? " (played here)" : " (the game played it)"))); } if ((Object)(object)mcShieldLook != (Object)null) { AudioClip[] blocks = McShield.Blocks; AudioClip val = blocks[Random.Range(0, blocks.Length)]; Controller component = ((Component)((Component)mcShieldLook).transform.root).GetComponent<Controller>(); if ((Object)(object)component != (Object)null) { Sounds.Play(component, val, 1f); } else { AudioSource componentInChildren = ((Component)((Component)__instance).transform.root).GetComponentInChildren<AudioSource>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.PlayOneShot(val, 1f); } } } return __exception; } } internal sealed class McSteady : MonoBehaviour { [HarmonyPatch(typeof(WeaponPickUp), "Start")] private static class OnPickups { private static void Postfix(WeaponPickUp __instance) { if (!MatchmakingHandler.IsNetworkMatch && !((Object)(object)((Component)__instance).GetComponent<McSteady>() != (Object)null) && McPickupPop.Looks(__instance.id)) { ((Component)__instance).gameObject.AddComponent<McSteady>(); } } } private Rigidbody rb; private void Awake() { rb = ((Component)this).GetComponent<Rigidbody>(); } private void FixedUpdate() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rb == (Object)null) && !rb.isKinematic) { Vector3 velocity = rb.velocity; if (!(Mathf.Abs(velocity.y) > 3f) && !(Mathf.Abs(velocity.z) > 2f) && Physics.Raycast(((Component)this).transform.position, Vector3.down, 1.3f, -1, (QueryTriggerInteraction)1)) { velocity.y *= 0.5f; rb.velocity = velocity; } } } } [HarmonyPatch(typeof(WeaponPickUp), "Start")] internal static class PickupPhysics { private static void Postfix(WeaponPickUp __instance) { WeaponInfo byIndex = WeaponRegistry.GetByIndex(__instance.id); if (byIndex == null || byIndex.Id == null || !byIndex.Id.StartsWith("arsenal.")) { return; } Collider[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Collider>(true); foreach (Collider val in componentsInChildren) { if ((Object)(object)val.sharedMaterial != (Object)null && val.sharedMaterial.bounciness > 0.2f) { val.sharedMaterial = null; } } } } [BepInPlugin("stickfight.arsenal", "Arsenal", "1.0.3")] [BepInDependency("stickfight.weaponframework", "1.0.7")] public class Plugin : BaseUnityPlugin { public const string Guid = "stickfight.arsenal"; public const string Name = "Arsenal"; public const string Version = "1.0.3"; internal static ManualLogSource Log; private void Start() { PortalStorm.Register(); if (Environment.GetEnvironmentVariable("ARSENAL_BENCH") == "1") { string[] array = new string[8] { "Unlit/Transparent Cutout", "Unlit/Texture", "Unlit/Transparent", "Legacy Shaders/Transparent/Cutout/Diffuse", "Sprites/Default", "UI/Default", "Standard", "Particles/Alpha Blended" }; foreach (string text in array) { Log.LogInfo((object)("Shader " + text + ": " + ((Object)(object)Shader.Find(text) != (Object)null))); } } } private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony("stickfight.arsenal").PatchAll(typeof(Plugin).Assembly); Snd.Make(); HoldProbe.Install(); PreviewHook.Install(); BounceBench.Install(); Food.AddCategory(); Add(BaseballBat.Define); Add(FryingPan.Define); Add(Railgun.Define); Add(Marksman.Define); Add(Harpoon.Define); Add(Tesla.Define); Add(StickyBomb.Define); Add(LandMine.Define); Add(GrapplingHook.Define); Add(Boomerang.Define); Add(SwapGun.Define); Add(WarpPearl.Define); Add(PortalGun.Define); Add(BoxGun.Define); Add(HandCannon.Define); Add(EnchantedBow.Define); Add(DoubleBarrel.Define); Add(AirCannon.Define); Add(Chainsaw.Define); Add(Hammer.Define); Add(BoxingGlove.Define); Add(Taser.Define); Add(BubbleGun.Define); Add(Turret.Define); Add(FlareGun.Define); Add(DartPistol.Define); Add(FlakCannon.Define); Add(NailGun.Define); Add(ClusterGrenade.Define); Add(Mortar.Define); Add(BouncyBomb.Define); Add(Scythe.Define); Add(GravityGun.Define); Add(MagnetGun.Define); Add(Flail.Define); Add(BurstPistol.Define); Add(LeverAction.Define); Add(ScatterBouncer.Define); Add(WaterCannon.Define); Add(GatlingLaser.Define); Add(GuidedRocket.Define); Add(Jetpack.Define); Add(SpringPad.Define); Add(BearTrap.Define); Add(WallBuilder.Define); Add(ThrowingKnives.Define); Add(OrbitalLaser.Define); Add(ThorsHammer.Define); Add(MeteorStaff.Define); Add(MagmaGrenade.Define); Add(SnakeNest.Define); if (McSword.Available) { Add(McSword.Define); } if (Shout.Available) { Add(Shout.Define); } if (ArmBlades.Available) { Add(ArmBlades.Define); } if (LockPistol.Available) { Add(LockPistol.Define); } try { foreach (WeaponDefinition item in Food.Define()) { WeaponRegistry.Add(item); } } catch (Exception ex) { Log.LogError((object)("Couldn't add the food: " + ex)); } WeaponRegistry.Ready += delegate { WeaponInfo val = WeaponRegistry.Get("arsenal.enchantedbow"); WeaponInfo val2 = WeaponRegistry.Get("arsenal.tiersword"); WeaponInfo val3 = WeaponRegistry.Get("arsenal.portalgun"); if (Environment.GetEnvironmentVariable("ARSENAL_BENCH") == "1") { StringBuilder stringBuilder = new StringBuilder(); foreach (WeaponInfo item2 in WeaponRegistry.All) { stringBuilder.Append(item2.Index).Append(' ').Append(item2.Id) .AppendLine(); } File.WriteAllText(Path.Combine(Paths.BepInExRootPath, "Arsenal-index.txt"), stringBuilder.ToString()); } Log.LogInfo((object)("Enchanted Bow is weapon #" + ((val != null) ? val.Index : (-1)) + ((val2 != null) ? (", Tier Sword #" + val2.Index) : "") + ((val3 != null) ? (", Portal Gun #" + val3.Index) : "") + ".")); }; Log.LogInfo((object)"Arsenal 1.0.3 loaded."); } private static void Add(Func<WeaponDefinition> define) { try { WeaponRegistry.Add(PickupGlint.Rare(define())); } catch (Exception ex) { Log.LogError((object)("Couldn't add a weapon: " + ex)); } } } [HarmonyPatch] internal static class PreviewLaser { private static MethodBase TargetMethod() { if (!Chainloader.PluginInfos.TryGetValue("stickfight.menuoverhaul", out var value) || (Object)(object)value.Instance == (Object)null) { return null; } Type type = ((object)value.Instance).GetType().Assembly.GetType("MenuOverhaul.TwoPanePage"); if ((object)type == null) { return null; } return AccessTools.Method(type, "ShowModel", (Type[])null, (Type[])null); } private static bool Prepare() { return (object)TargetMethod() != null; } private static void Prefix(GameObject source, out GameObject __state) { __state = null; Transform val = (((Object)(object)source != (Object)null) ? source.transform.Find("LaserSight") : null); if (!((Object)(object)val == (Object)null) && ((Component)val).gameObject.activeSelf) { ((Component)val).gameObject.SetActive(false); __state = ((Component)val).gameObject; } } private static void Postfix(GameObject __state) { if ((Object)(object)__state != (Object)null) { __state.SetActive(true); } } } internal static class Private { private static readonly Dictionary<string, Texture2D> textures = new Dictionary<string, Texture2D>(); private static readonly Dictionary<string, AudioClip> clips = new Dictionary<string, AudioClip>(); private static Dictionary<string, string> names; private static string Root => Path.Combine(Paths.ConfigPath, (Environment.GetEnvironmentVariable("ARSENAL_NOPRIVATE") == "1") ? "Arsenal-none" : "Arsenal"); public static Texture2D Sprite(string name) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown if (textures.TryGetValue(name, out var value)) { return value; } value = null; try { string path = Path.Combine(Path.Combine(Root, "Sprites"), name + ".png"); if (File.Exists(path)) { value = new Texture2D(2, 2, (TextureFormat)4, true); if (!value.LoadImage(File.ReadAllBytes(path))) { value = null; } else { ((Texture)value).wrapMode = (TextureWrapMode)1; bool flag = ((Texture)value).width <= 64 && ((Texture)value).height <= 64; ((Texture)value).filterMode = (FilterMode)((!flag) ? 2 : 0); if (!flag) { ((Texture)value).anisoLevel = 4; } value.Apply(!flag); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Couldn't load the picture for " + name + ": " + ex.Message)); value = null; } textures[name] = value; return value; } public static AudioClip Sound(string name, AudioClip fallback) { if (!clips.TryGetValue(name, out var value)) { value = null; try { string path = Path.Combine(Path.Combine(Root, "Sounds"), name + ".wav"); if (File.Exists(path)) { value = Recorded.FromBytes(File.ReadAllBytes(path), name); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Couldn't load the sound " + name + ": " + ex.Message)); value = null; } clips[name] = value; } return value ?? fallback; } public static string Name(string key, string fallback) { if (names == null) { names = new Dictionary<string, string>(); try { string path = Path.Combine(Root, "names.txt"); if (File.Exists(path)) { string[] array = File.ReadAllLines(path); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); int num = text.IndexOf('='); if (text.Length != 0 && text[0] != '#' && num > 0) { names[text.Substring(0, num).Trim()] = text.Substring(num + 1).Trim(); } } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Couldn't read names.txt: " + ex.Message)); } } if (!names.TryGetValue(key, out var value) || value.Length <= 0) { return fallback; } return value; } public static GameObject Billboard(Transform parent, Texture2D tex, float height, Vector3 localOffset) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Mc.Solid(parent, tex, "Arsenal picture"); obj.transform.localPosition = localOffset; obj.transform.localScale = new Vector3(height * (float)((Texture)tex).width / (float)Mathf.Max(1, ((Texture)tex).height), height, height); obj.AddComponent<FaceCamera>(); return obj; } } internal sealed class FaceCamera : MonoBehaviour { private void LateUpdate() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.rotation = Quaternion.LookRotation(Vector3.right, Vector3.up); } } internal static class RareFx { public static void Sparks(Vector3 at, Color color, int count, float reach, float life = 0.25f, Vector3? bias = null) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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) //