Decompiled source of DamageTracker v0.5.14
DamageTracker.dll
Decompiled 11 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Text.Json; using Assets.Scripts; using Assets.Scripts.LevelGeneration; using Assets.Scripts.SkillSystem; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using DRS.UI; using HarmonyLib; using Il2CppInterop.Common; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Reflection; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.EventSystems; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DamageTracker { internal static class History { private static readonly CultureInfo Inv = CultureInfo.InvariantCulture; private static string Dir => Path.Combine(Application.persistentDataPath, "DamageTracker", "runs"); public static void Save(Run r) { try { Directory.CreateDirectory(Dir); File.WriteAllText(Path.Combine(Dir, "run-" + r.Id + ".json"), Write(r)); string[] files = Directory.GetFiles(Dir, "run-*.json"); Array.Sort(files, (IComparer<string>?)StringComparer.Ordinal); for (int i = 0; i < files.Length - Settings.KeepRuns.Value; i++) { File.Delete(files[i]); } } catch (Exception ex) { Plugin.L.LogWarning((object)("Could not save run: " + ex.Message)); } } public static List<Run> LoadAll() { List<Run> list = new List<Run>(); try { if (Directory.Exists(Dir)) { string[] files = Directory.GetFiles(Dir, "run-*.json"); Array.Sort(files, (IComparer<string>?)StringComparer.Ordinal); for (int num = files.Length - 1; num >= 0; num--) { try { list.Add(Read(File.ReadAllText(files[num]))); } catch (Exception ex) { Plugin.L.LogWarning((object)("Skipped " + Path.GetFileName(files[num]) + ": " + ex.Message)); } } } } catch (Exception ex2) { Plugin.L.LogWarning((object)("Could not list runs: " + ex2.Message)); } Run last = Tracker.Last; if (last != null && !list.Exists((Run x) => x.Id == last.Id)) { list.Insert(0, last); } return list; } private static string Write(Run r) { //IL_02d1: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(8192); stringBuilder.Append("{\"v\":1,\"id\":\"").Append(r.Id).Append("\",\"start\":\"") .Append(r.Start.ToString("o", Inv)) .Append('"'); stringBuilder.Append(",\"dur\":").Append(r.Duration.ToString("0.0", Inv)).Append(",\"total\":") .Append(r.Total.ToString("0", Inv)); if (!string.IsNullOrEmpty(r.Mission)) { stringBuilder.Append(",\"mis\":\"").Append(Esc(r.Mission)).Append('"'); } if (!string.IsNullOrEmpty(r.Biome)) { stringBuilder.Append(",\"bio\":\"").Append(Esc(r.Biome)).Append('"'); } if (r.Hazard >= 0) { stringBuilder.Append(",\"hz\":").Append(r.Hazard); } if (r.EnvTotal > 0.0) { stringBuilder.Append(",\"env\":").Append(r.EnvTotal.ToString("0", Inv)); } if (r.Resumed) { stringBuilder.Append(",\"rs\":1"); } if (r.Result >= 0) { stringBuilder.Append(",\"res\":").Append(r.Result); } stringBuilder.Append(",\"threat\":").Append(r.MaxThreat).Append(",\"rolls\":") .Append(r.Rolls) .Append(",\"crits\":") .Append(r.Crits) .Append(",\"supers\":") .Append(r.Supers) .Append(",\"chs\":") .Append(r.ChanceSum.ToString("0.###", Inv)); stringBuilder.Append(",\"stat\":"); Arr(stringBuilder, r.StatusGlobal); stringBuilder.Append(",\"sp\":"); Arr(stringBuilder, r.Spread); stringBuilder.Append(",\"fz\":").Append(r.Frozen.ToString("0", Inv)); if (r.Stats != null) { WriteStats(stringBuilder, r.Stats); } stringBuilder.Append(",\"sources\":["); for (int i = 0; i < r.Sources.Count; i++) { SourceRec sourceRec = r.Sources[i]; if (i > 0) { stringBuilder.Append(','); } stringBuilder.Append("{\"n\":\"").Append(Esc(sourceRec.Name)).Append("\",\"k\":") .Append((int)sourceRec.Kind) .Append(",\"c\":\"#") .Append(ColorUtility.ToHtmlStringRGB(sourceRec.Color)) .Append('"'); stringBuilder.Append(",\"t\":").Append(sourceRec.Total.ToString("0", Inv)).Append(",\"d\":") .Append(sourceRec.Dps.ToString("0.0", Inv)); stringBuilder.Append(",\"h\":").Append(sourceRec.Hits).Append(",\"cr\":") .Append(sourceRec.Crits) .Append(",\"su\":") .Append(sourceRec.Supers); stringBuilder.Append(",\"sk\":").Append(sourceRec.Stacks.ToString("0", Inv)).Append(",\"st\":"); Arr(stringBuilder, sourceRec.Status); stringBuilder.Append(",\"ty\":"); Arr(stringBuilder, sourceRec.Dmg); if (sourceRec.Parts != null && sourceRec.Parts.Count > 0) { stringBuilder.Append(",\"pa\":{"); bool flag = true; foreach (KeyValuePair<string, double> part in sourceRec.Parts) { if (!flag) { stringBuilder.Append(','); } flag = false; stringBuilder.Append('"').Append(Esc(part.Key)).Append("\":") .Append(part.Value.ToString("0", Inv)); } stringBuilder.Append('}'); } stringBuilder.Append(",\"fz\":").Append(sourceRec.Frozen.ToString("0", Inv)).Append('}'); } stringBuilder.Append("],\"samples\":["); for (int j = 0; j < r.Samples.Count; j++) { Sample sample = r.Samples[j]; if (j > 0) { stringBuilder.Append(','); } stringBuilder.Append("{\"t\":").Append(sample.T.ToString("0.0", Inv)).Append(",\"dp\":") .Append(sample.Depth) .Append(",\"th\":") .Append(sample.Threat); if (sample.Hp >= 0f) { stringBuilder.Append(",\"hp\":").Append(sample.Hp.ToString("0.###", Inv)); } if (sample.Gold >= 0) { stringBuilder.Append(",\"g\":").Append(sample.Gold); } if (sample.Nitra >= 0) { stringBuilder.Append(",\"n\":").Append(sample.Nitra); } stringBuilder.Append(",\"c\":"); Arr(stringBuilder, sample.Cum); stringBuilder.Append(",\"s\":"); Arr(stringBuilder, sample.Stat); stringBuilder.Append('}'); } stringBuilder.Append("],\"events\":["); for (int k = 0; k < r.Events.Count; k++) { Ev ev = r.Events[k]; if (k > 0) { stringBuilder.Append(','); } stringBuilder.Append("{\"t\":").Append(ev.T.ToString("0.0", Inv)).Append(",\"k\":\"") .Append(Esc(ev.Kind)) .Append("\",\"x\":\"") .Append(Esc(ev.Text)) .Append("\"}"); } return stringBuilder.Append("]}").ToString(); } private static void WriteStats(StringBuilder sb, RunStats p) { sb.Append(",\"ps\":{\"tk\":").Append(p.Taken.ToString("0", Inv)).Append(",\"hn\":") .Append(p.HitsTaken) .Append(",\"hl\":") .Append(p.Healed.ToString("0", Inv)) .Append(",\"rg\":") .Append(p.Regen.ToString("0", Inv)) .Append(",\"oh\":") .Append(p.Overheal.ToString("0", Inv)) .Append(",\"ar\":") .Append(p.Armor.ToString("0", Inv)) .Append(",\"dg\":") .Append(p.Dodged) .Append(",\"dd\":") .Append(p.DodgedDmg.ToString("0", Inv)) .Append(",\"bh\":") .Append(p.BigHit.ToString("0", Inv)) .Append(",\"bhb\":\"") .Append(Esc(p.BigHitBy)) .Append("\",\"bha\":") .Append(p.BigHitAt.ToString("0.0", Inv)) .Append(",\"bt\":") .Append(p.BigTaken.ToString("0", Inv)) .Append(",\"btb\":\"") .Append(Esc(p.BigTakenBy)) .Append("\",\"bta\":") .Append(p.BigTakenAt.ToString("0.0", Inv)) .Append(",\"lb\":") .Append(p.Lootbugs) .Append(",\"gl\":") .Append(p.Golden) .Append(",\"ex\":") .Append(p.Baited) .Append(",\"exo\":") .Append(p.Exploded) .Append(",\"lo\":") .Append(p.LowHp.ToString("0.###", Inv)) .Append(",\"loa\":") .Append(p.LowHpAt.ToString("0.0", Inv)) .Append(",\"ok\":") .Append(p.Overkill.ToString("0", Inv)) .Append(",\"au\":") .Append(p.Gold.ToString("0", Inv)) .Append(",\"ni\":") .Append(p.Nitra.ToString("0", Inv)) .Append(",\"by\":{"); bool flag = true; foreach (KeyValuePair<string, double> item in p.TakenBy) { if (!flag) { sb.Append(','); } flag = false; sb.Append('"').Append(Esc(item.Key)).Append("\":") .Append(item.Value.ToString("0", Inv)); } sb.Append("},\"bf\":["); for (int i = 0; i < p.Bosses.Count; i++) { BossFight bossFight = p.Bosses[i]; if (i > 0) { sb.Append(','); } sb.Append('[').Append(bossFight.Depth).Append(',') .Append(bossFight.Start.ToString("0.0", Inv)) .Append(',') .Append(bossFight.End.ToString("0.0", Inv)) .Append(']'); } sb.Append("]}"); } private static RunStats ReadStats(JsonElement e) { JsonElement value; RunStats runStats = new RunStats { Taken = D("tk"), HitsTaken = L("hn"), Healed = D("hl"), Regen = D("rg"), Overheal = D("oh"), Armor = D("ar"), Dodged = L("dg"), DodgedDmg = D("dd"), BigHit = D("bh"), BigHitBy = S("bhb"), BigHitAt = (float)D("bha"), BigTaken = D("bt"), BigTakenBy = S("btb"), BigTakenAt = (float)D("bta"), Lootbugs = L("lb"), Golden = L("gl"), Baited = L("ex"), Exploded = L("exo"), Gold = D("au"), Nitra = D("ni"), Overkill = D("ok"), LowHp = (e.TryGetProperty("lo", out value) ? ((float)value.GetDouble()) : 1f), LowHpAt = (float)D("loa") }; if (e.TryGetProperty("by", out var value2)) { foreach (JsonProperty item in value2.EnumerateObject()) { runStats.TakenBy[item.Name] = item.Value.GetDouble(); } } if (e.TryGetProperty("bf", out var value3)) { foreach (JsonElement item2 in value3.EnumerateArray()) { runStats.Bosses.Add(new BossFight { Depth = item2[0].GetInt32(), Start = (float)item2[1].GetDouble(), End = (float)item2[2].GetDouble() }); } } return runStats; double D(string k) { if (!e.TryGetProperty(k, out var value4)) { return 0.0; } return value4.GetDouble(); } long L(string k) { if (!e.TryGetProperty(k, out var value4)) { return 0L; } return value4.GetInt64(); } string S(string k) { if (!e.TryGetProperty(k, out var value4)) { return ""; } return value4.GetString() ?? ""; } } private static void Arr(StringBuilder sb, double[] a) { sb.Append('['); for (int i = 0; i < a.Length; i++) { if (i > 0) { sb.Append(','); } sb.Append(a[i].ToString("0", Inv)); } sb.Append(']'); } private static string Esc(string s) { return (s ?? "").Replace("\\", "\\\\").Replace("\"", "\\\""); } private static Run Read(string json) { //IL_02db: 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_02e3: Unknown result type (might be due to invalid IL or missing references) using JsonDocument jsonDocument = JsonDocument.Parse(json); JsonElement rootElement = jsonDocument.RootElement; Run run = new Run { Id = rootElement.GetProperty("id").GetString(), Start = DateTime.Parse(rootElement.GetProperty("start").GetString(), Inv, DateTimeStyles.RoundtripKind), Duration = (float)rootElement.GetProperty("dur").GetDouble(), Total = rootElement.GetProperty("total").GetDouble(), MaxThreat = rootElement.GetProperty("threat").GetInt32(), Rolls = rootElement.GetProperty("rolls").GetInt64(), Crits = rootElement.GetProperty("crits").GetInt64(), Supers = rootElement.GetProperty("supers").GetInt64() }; if (rootElement.TryGetProperty("chs", out var value)) { run.ChanceSum = value.GetDouble(); } if (rootElement.TryGetProperty("mis", out var value2)) { run.Mission = value2.GetString(); } if (rootElement.TryGetProperty("bio", out var value3)) { run.Biome = value3.GetString(); } if (rootElement.TryGetProperty("hz", out var value4)) { run.Hazard = value4.GetInt32(); } if (rootElement.TryGetProperty("env", out var value5)) { run.EnvTotal = value5.GetDouble(); } run.Resumed = rootElement.TryGetProperty("rs", out var value6) && value6.GetInt32() == 1; if (rootElement.TryGetProperty("res", out var value7)) { run.Result = value7.GetInt32(); } Fill(rootElement.GetProperty("stat"), run.StatusGlobal); if (rootElement.TryGetProperty("sp", out var value8)) { Fill(value8, run.Spread); } run.Frozen = (rootElement.TryGetProperty("fz", out var value9) ? value9.GetDouble() : run.StatusGlobal[6]); if (rootElement.TryGetProperty("ps", out var value10)) { run.Stats = ReadStats(value10); } Color val = default(Color); foreach (JsonElement item in rootElement.GetProperty("sources").EnumerateArray()) { ColorUtility.TryParseHtmlString(item.GetProperty("c").GetString(), ref val); SourceRec sourceRec = new SourceRec { Name = Names.Game(item.GetProperty("n").GetString()), Kind = (Kind)item.GetProperty("k").GetInt32(), Color = val, Type = Names.TypeFromColor(val), Total = item.GetProperty("t").GetDouble(), Dps = item.GetProperty("d").GetDouble(), Hits = item.GetProperty("h").GetInt64(), Crits = item.GetProperty("cr").GetInt64(), Supers = item.GetProperty("su").GetInt64(), Stacks = item.GetProperty("sk").GetDouble() }; Fill(item.GetProperty("st"), sourceRec.Status); if (item.TryGetProperty("ty", out var value11)) { Fill(value11, sourceRec.Dmg); } if (item.TryGetProperty("pa", out var value12)) { sourceRec.Parts = new Dictionary<string, double>(); foreach (JsonProperty item2 in value12.EnumerateObject()) { sourceRec.Parts[Names.Game(item2.Name)] = item2.Value.GetDouble(); } } sourceRec.Frozen = (item.TryGetProperty("fz", out var value13) ? value13.GetDouble() : sourceRec.Status[6]); run.Sources.Add(sourceRec); } foreach (JsonElement item3 in rootElement.GetProperty("samples").EnumerateArray()) { JsonElement property = item3.GetProperty("c"); Sample sample = new Sample { T = (float)item3.GetProperty("t").GetDouble(), Depth = item3.GetProperty("dp").GetInt32(), Threat = item3.GetProperty("th").GetInt32(), Cum = new double[property.GetArrayLength()], Stat = new double[7] }; Fill(property, sample.Cum); if (item3.TryGetProperty("hp", out var value14)) { sample.Hp = (float)value14.GetDouble(); } if (item3.TryGetProperty("g", out var value15)) { sample.Gold = value15.GetInt32(); } if (item3.TryGetProperty("n", out var value16)) { sample.Nitra = value16.GetInt32(); } Fill(item3.GetProperty("s"), sample.Stat); run.Samples.Add(sample); } foreach (JsonElement item4 in rootElement.GetProperty("events").EnumerateArray()) { run.Events.Add(new Ev { T = (float)item4.GetProperty("t").GetDouble(), Kind = item4.GetProperty("k").GetString(), Text = item4.GetProperty("x").GetString() }); } return run; } private static void Fill(JsonElement a, double[] into) { int num = 0; foreach (JsonElement item in a.EnumerateArray()) { if (num >= into.Length) { break; } into[num++] = item.GetDouble(); } } } internal static class Hooks { private static class Real { private sealed class Check { public string Name; public readonly List<IntPtr> Want = new List<IntPtr>(); public readonly HashSet<IntPtr> Ok = new HashSet<IntPtr>(); public readonly HashSet<IntPtr> Bad = new HashSet<IntPtr>(); public long Ignored; } private static class Of<T> where T : Il2CppObjectBase { public static readonly Check C = Make(typeof(T).Name, new Type[1] { typeof(T) }); } private static readonly Dictionary<string, Check> ByKey = new Dictionary<string, Check>(); private static readonly List<Check> All = new List<Check>(); private static Check Make(string name, IEnumerable<Type> types) { Check check = new Check { Name = name }; foreach (Type type in types) { IntPtr intPtr = IntPtr.Zero; try { intPtr = Il2CppClassPointerStore.GetNativeClassPointer(type); } catch (Exception) { } if (intPtr != IntPtr.Zero && !check.Ok.Contains(intPtr)) { check.Want.Add(intPtr); check.Ok.Add(intPtr); } } lock (All) { All.Add(check); return check; } } public static IEnumerable<MethodBase> For(string key, IEnumerable<MethodBase> methods) { List<MethodBase> list = new List<MethodBase>(methods); List<Type> list2 = new List<Type>(); foreach (MethodBase item in list) { if (item.DeclaringType != null && !list2.Contains(item.DeclaringType)) { list2.Add(item.DeclaringType); } } ByKey[key] = Make(key, list2); return list; } public static bool Is<T>(object o) where T : Il2CppObjectBase { return Is(o, Of<T>.C); } public static bool Is(object o, string key) { Check value; return Is(o, ByKey.TryGetValue(key, out value) ? value : null); } private static bool Is(object o, Check c) { if (c == null || c.Want.Count == 0) { return o != null; } Il2CppObjectBase val = (Il2CppObjectBase)((o is Il2CppObjectBase) ? o : null); if (val == null) { return false; } IntPtr intPtr; try { intPtr = Marshal.ReadIntPtr(val.Pointer); } catch (Exception) { return false; } if (c.Ok.Contains(intPtr)) { return true; } if (intPtr != IntPtr.Zero && !c.Bad.Contains(intPtr)) { foreach (IntPtr item in c.Want) { if (IL2CPP.il2cpp_class_is_assignable_from(item, intPtr)) { c.Ok.Add(intPtr); return true; } } c.Bad.Add(intPtr); } if (c.Ignored++ == 0L) { Note("Hook on " + c.Name + " was called for a " + ClassName(intPtr) + ": the game shares that code with other methods. Calls like this are ignored."); } return false; } private static string ClassName(IntPtr k) { try { return (k == IntPtr.Zero) ? "null object" : Marshal.PtrToStringAnsi(IL2CPP.il2cpp_class_get_name(k)); } catch (Exception) { return "other class"; } } public static string Report() { StringBuilder stringBuilder = new StringBuilder(); lock (All) { foreach (Check item in All) { if (item.Ignored > 0) { stringBuilder.Append((stringBuilder.Length > 0) ? ", " : "").Append(item.Name).Append(' ') .Append(item.Ignored); } } } return "Hook calls ignored as not the hooked class (shared code): " + ((stringBuilder.Length > 0) ? stringBuilder.ToString() : "none"); } } private static class NativeCode { private const int MinBytes = 64; private const long MaxDistance = 262144L; private static readonly Dictionary<Type, long> Centers = new Dictionary<Type, long>(); private static readonly Dictionary<IntPtr, string> Claimed = new Dictionary<IntPtr, string>(); private static readonly Dictionary<IntPtr, string> ClaimedBy = new Dictionary<IntPtr, string>(); [DllImport("kernel32.dll")] private static extern IntPtr RtlLookupFunctionEntry(ulong pc, out ulong imageBase, IntPtr history); public static bool Claim(MethodBase m, string owner) { string why; IntPtr intPtr = Code(m, out why); if (intPtr == IntPtr.Zero) { return true; } string text = m.DeclaringType?.Name + "." + m.Name; if (Claimed.TryGetValue(intPtr, out var value)) { string text2 = "Not hooking " + text + " (" + owner + "): the game compiled it into the same function as " + value + ", which is already hooked"; if (ClaimedBy[intPtr] == owner) { Note(text2 + " by the same hook, so it is covered"); } else { Plugin.L.LogWarning((object)(text2 + " by " + ClaimedBy[intPtr])); } return false; } Claimed[intPtr] = text; ClaimedBy[intPtr] = owner; return true; } public static void Report(Harmony h) { List<string> list = new List<string>(); foreach (MethodBase patchedMethod in h.GetPatchedMethods()) { string why; int num = Size(Code(patchedMethod, out why)); if (num >= 0 && num < 64) { list.Add(patchedMethod.DeclaringType?.Name + "." + patchedMethod.Name + " (" + ((num == 0) ? "a few instructions" : (num + " bytes")) + ")"); } } Plugin.L.LogInfo((object)("Hooked methods with code small enough to be shared: " + ((list.Count > 0) ? string.Join(", ", list) : "none"))); } public static bool Hookable(MethodBase m, string owner, bool quiet = false) { string why; IntPtr intPtr = Code(m, out why); if (intPtr == IntPtr.Zero) { if (!m.Name.Contains("b__")) { return true; } if (!quiet) { Note("Not hooking " + owner + "." + m.Name + ": " + why); } return false; } int num = Size(intPtr); if (num < 64) { if (!quiet) { Note("Not hooking " + owner + "." + m.Name + ": " + ((num == 0) ? "its code is a few instructions" : ("its code is " + num + " bytes")) + ", which the game can share with other methods"); } return false; } Type type = ((m.DeclaringType != null && m.DeclaringType.IsNested && m.DeclaringType.Name.Contains("_d__")) ? m.DeclaringType.DeclaringType : m.DeclaringType); long num2 = ((type != null) ? Center(type) : 0); long num3 = ((num2 != 0L) ? Math.Abs(intPtr.ToInt64() - num2) : 0); if (num3 > 262144) { if (!quiet) { Note("Not hooking " + owner + "." + m.Name + ": its code is " + num3 / 1024 + " KB from the rest of " + type.Name + "'s, which is where the game keeps code it shares between classes"); } return false; } return true; } private static long Center(Type t) { if (Centers.TryGetValue(t, out var value)) { return value; } List<long> list = new List<long>(); foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(t)) { if (!declaredMethod.IsSpecialName && !declaredMethod.IsAbstract && !declaredMethod.ContainsGenericParameters) { string why; IntPtr intPtr = Code(declaredMethod, out why); if (intPtr != IntPtr.Zero) { list.Add(intPtr.ToInt64()); } } } list.Sort(); value = ((list.Count >= 3) ? list[list.Count / 2] : 0); Centers[t] = value; return value; } private static IntPtr Code(MethodBase m, out string why) { why = null; try { FieldInfo il2CppMethodInfoPointerFieldForGeneratedMethod = Il2CppInteropUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(m); IntPtr intPtr = ((il2CppMethodInfoPointerFieldForGeneratedMethod != null) ? ((IntPtr)il2CppMethodInfoPointerFieldForGeneratedMethod.GetValue(null)) : IntPtr.Zero); if (intPtr == IntPtr.Zero) { why = "no native method found"; return IntPtr.Zero; } IntPtr intPtr2 = Marshal.ReadIntPtr(intPtr); if (intPtr2 == IntPtr.Zero) { why = "no native code found"; } return intPtr2; } catch (Exception ex) { why = "its code could not be checked (" + ex.GetType().Name + ")"; return IntPtr.Zero; } } private static int Size(IntPtr code) { if (code == IntPtr.Zero) { return -1; } try { ulong imageBase; IntPtr intPtr = RtlLookupFunctionEntry((ulong)code.ToInt64(), out imageBase, IntPtr.Zero); if (intPtr == IntPtr.Zero) { return 0; } uint num = (uint)Marshal.ReadInt32(intPtr); return Marshal.ReadInt32(intPtr, 4) - (int)num; } catch (Exception) { return -1; } } } [HarmonyPatch(typeof(Enemy), "TakeDamage")] private static class EnemyHit { private static void Prefix(Enemy __instance, long __0, EDamageType __2, EDamageSource __4, Entity __5, out bool __state) { //IL_0016: 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) long start = Perf.T(); __state = Real.Is<Enemy>((object)__instance); if (__state) { Tracker.HitStart(__instance, __0, __2, __4, __5); } Perf.Add(Sec.Hit, start); } private static void Finalizer(Enemy __instance, bool __state) { if (__state) { long start = Perf.T(); Tracker.HitEnd(__instance); Perf.Add(Sec.Hit, start); } } } [HarmonyPatch(typeof(Enemy), "Die")] private static class EnemyDie { private static void Prefix(Enemy __instance, long __1) { long start = Perf.T(); if (Real.Is<Enemy>((object)__instance)) { Tracker.Killed(__instance, __1); } Perf.Add(Sec.Hit, start); } } [HarmonyPatch(typeof(Player), "TakeDamage")] private static class PlayerHurt { private static void Prefix(Player __instance, long __0, EDamageType __2, EDamageSource __4, Entity __5, bool __6, out Tracker.PlayerHit __state) { //IL_0017: 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) __state = (Real.Is<Player>((object)__instance) ? Tracker.PlayerHitStart(__instance, __0, __2, __4, __5, __6) : default(Tracker.PlayerHit)); } private static void Postfix(Player __instance, bool __result, Tracker.PlayerHit __state) { if (__state.Ok) { Tracker.PlayerHitEnd(__instance, __state, __result); } } private static void Finalizer(Tracker.PlayerHit __state) { Tracker.PlayerHitDone(__state); } } [HarmonyPatch(typeof(CoreGameEvents), "TriggerPlayerDodge")] private static class PlayerDodge { private static void Postfix() { Tracker.Dodged(); } } [HarmonyPatch(typeof(CoreGameEvents), "TriggerCoreRunEnd")] private static class RunEnd { private static void Postfix(ECoreRunEndCondition __0) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Tracker.RunEnded(__0); } } [HarmonyPatch(typeof(CoreGameEvents), "TriggerCoreRunOutro")] private static class RunOutro { private static void Postfix(ECoreRunEndCondition __0) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Tracker.RunOutro(__0); } } [HarmonyPatch(typeof(UIEndScreen), "Setup")] private static class EndScreen { private static void Postfix(UIEndScreen __instance, ECoreRunEndCondition __0) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (!Real.Is<UIEndScreen>((object)__instance)) { return; } try { Tracker.EndScreenShown(__0, __instance.isWin); } catch (Exception ex) { Tracker.LogOnce("endscreen", "Could not read the end screen: " + ex.Message); } } } [HarmonyPatch(typeof(Player), "Heal")] private static class PlayerHeal { private static void Prefix(Player __instance, out long __state) { __state = (Real.Is<Player>((object)__instance) ? Tracker.HpOf(__instance) : (-1)); } private static void Postfix(Player __instance, long __0, EHealType __1, long __state) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (__state >= 0) { Tracker.Healed(__instance, __state, __0, __1); } } } [HarmonyPatch(typeof(QHandlerCurrencyInterest), "OnDropPodEnter")] private static class Interest { private static void Prefix(QHandlerCurrencyInterest __instance, out Tracker.Purse __state) { __state = default(Tracker.Purse); if (!Real.Is<QHandlerCurrencyInterest>((object)__instance)) { return; } try { __state = Tracker.PurseOf(__instance.wallet); } catch (Exception) { } } private static void Finalizer(QHandlerCurrencyInterest __instance, Tracker.Purse __state) { if (!__state.Ok) { return; } try { Tracker.InterestPaid(__instance.wallet, __state); } catch (Exception) { } } } [HarmonyPatch] private static class EnvExploder { private static IEnumerable<MethodBase> TargetMethods() { return Real.For("EnvExploder", Containing(typeof(ExplosionWeaponHandler), "ActivateWeapon", "Explode", "FriendlyFire")); } private static void Prefix(object __instance, out string __state) { __state = EnterEnv(__instance, "EnvExploder", "Exploders"); } private static void Finalizer(string __state) { Tracker.LeaveEnv(__state); } } [HarmonyPatch] private static class EnvExplosivePlant { private static IEnumerable<MethodBase> TargetMethods() { return Real.For("EnvExplosivePlant", Containing(typeof(ExplosivePlant), "Explode")); } private static void Prefix(object __instance, out string __state) { __state = EnterEnv(__instance, "EnvExplosivePlant", "Explosive Plant"); } private static void Finalizer(string __state) { Tracker.LeaveEnv(__state); } } [HarmonyPatch] private static class EnvExplosiveSpore { private static IEnumerable<MethodBase> TargetMethods() { return Real.For("EnvExplosiveSpore", Containing(typeof(ExplosiveSpore), "Explode")); } private static void Prefix(object __instance, out string __state) { __state = EnterEnv(__instance, "EnvExplosiveSpore", "Explosive Spore"); } private static void Finalizer(string __state) { Tracker.LeaveEnv(__state); } } [HarmonyPatch] private static class EnvFallingIcicle { private static IEnumerable<MethodBase> TargetMethods() { return Real.For("EnvFallingIcicle", Containing(typeof(GlacialStrataFallingIcicle), "OnLand")); } private static void Prefix(object __instance, out string __state) { __state = EnterEnv(__instance, "EnvFallingIcicle", "Falling Icicle"); } private static void Finalizer(string __state) { Tracker.LeaveEnv(__state); } } [HarmonyPatch] private static class EnvDesertTwister { private static IEnumerable<MethodBase> TargetMethods() { return Real.For("EnvDesertTwister", Containing(typeof(DesertTwisterSystem), "TickDamage")); } private static void Prefix(object __instance, out string __state) { __state = EnterEnv(__instance, "EnvDesertTwister", "Desert Twister"); } private static void Finalizer(string __state) { Tracker.LeaveEnv(__state); } } [HarmonyPatch] private static class EnvHotRock { private static IEnumerable<MethodBase> TargetMethods() { return Real.For("EnvHotRock", Containing(typeof(HotRockSystem), "Tick")); } private static void Prefix(object __instance, out string __state) { __state = EnterEnv(__instance, "EnvHotRock", "Hot Rock"); } private static void Finalizer(string __state) { Tracker.LeaveEnv(__state); } } [HarmonyPatch] private static class EnvRedVine { private static IEnumerable<MethodBase> TargetMethods() { return Real.For("EnvRedVine", Containing(typeof(RedVineSystem), "Tick")); } private static void Prefix(object __instance, out string __state) { __state = EnterEnv(__instance, "EnvRedVine", "Red Vine"); } private static void Finalizer(string __state) { Tracker.LeaveEnv(__state); } } private static class Blocks { private static readonly Dictionary<IntPtr, string> NameOf = new Dictionary<IntPtr, string>(); public static List<MethodBase> Targets() { Stopwatch stopwatch = Stopwatch.StartNew(); List<MethodBase> list = new List<MethodBase>(); int num = 0; int num2 = 0; List<string> biomes = BiomePrefixes(); Type[] array; try { array = typeof(MineableBlock).Assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { array = Array.FindAll(ex.Types, (Type x) => x != null); } Type[] array2 = array; foreach (Type type in array2) { if (!type.IsClass || type.ContainsGenericParameters || !typeof(MineableBlock).IsAssignableFrom(type)) { continue; } string name = Name(type.Name, biomes); Remember(NameOf, type, name); num++; foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(type)) { if (Plain(declaredMethod) && !(declaredMethod.Name == "TakeDamage") && !(declaredMethod.Name == "DamageTweening")) { if (NativeCode.Hookable(declaredMethod, type.Name, quiet: true)) { list.Add(declaredMethod); } else { num2++; } } } foreach (MethodInfo item in Coroutines(type, null)) { if (!NativeCode.Hookable(item, type.Name, quiet: true)) { num2++; continue; } Remember(NameOf, item.DeclaringType, name); list.Add(item); } } Plugin.L.LogInfo((object)("Map block hooks: " + list.Count + " methods on " + num + " kinds of block (" + num2 + " left out as code the game may share), found in " + stopwatch.ElapsedMilliseconds + " ms")); return list; } public static string Of(object o) { return NameFrom(NameOf, o); } private static List<string> BiomePrefixes() { List<string> list = new List<string>(); try { Type[] types = typeof(BiomeData).Assembly.GetTypes(); foreach (Type type in types) { if (type.IsSubclassOf(typeof(BiomeData)) && type.Name.StartsWith("BiomeData") && type.Name.Length > 9) { list.Add(type.Name.Substring(9)); } } } catch (Exception) { } list.Sort((string a, string b) => b.Length.CompareTo(a.Length)); return list; } private static string Name(string cls, List<string> biomes) { foreach (string biome in biomes) { if (cls.StartsWith(biome) && cls.Length > biome.Length && Words(cls.Substring(biome.Length)).Contains(" ")) { cls = cls.Substring(biome.Length); break; } } return Words(cls); } } private static class BlockCode { private static void Prefix(object __instance, out string __state) { string text = (Real.Is(__instance, "BlockCode") ? Blocks.Of(__instance) : null); __state = ((text != null) ? Tracker.EnterBlock(text) : Tracker.BlockCtx); } private static void Finalizer(string __state) { Tracker.LeaveBlock(__state); } } private static class Missions { private static readonly Dictionary<IntPtr, string> NameOf = new Dictionary<IntPtr, string>(); private static List<MethodBase> landings; private static List<MethodBase> rest; public static List<MethodBase> Landings() { Search(); return landings; } public static List<MethodBase> Targets() { Search(); return rest; } public static string Of(object o) { return NameFrom(NameOf, o); } private static void Search() { if (landings != null) { return; } landings = new List<MethodBase>(); rest = new List<MethodBase>(); Stopwatch stopwatch = Stopwatch.StartNew(); int num = 0; Type[] array; try { array = typeof(SupplyPod).Assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { array = Array.FindAll(ex.Types, (Type x) => x != null); } List<string> list = new List<string>(); Type[] array2 = array; foreach (Type type in array2) { if (!type.IsClass || type.IsNested || type.ContainsGenericParameters || !typeof(MonoBehaviour).IsAssignableFrom(type)) { continue; } if (type.Name.EndsWith("Pod")) { string name = Words(type.Name); foreach (MethodBase item in Containing(type, "Land")) { Remember(NameOf, item.DeclaringType, name); ((item.Name.Contains("b__") || item.Name == "MoveNext") ? rest : landings).Add(item); } } else { if (!type.Name.StartsWith("Bobby")) { continue; } string name2 = Names.Game(Words(type.Name)); if (!list.Contains("Bobby")) { list.Add("Bobby"); } foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(type)) { if (Plain(declaredMethod)) { if (NativeCode.Hookable(declaredMethod, type.Name, quiet: true)) { Remember(NameOf, type, name2); rest.Add(declaredMethod); } else { num++; } } } foreach (MethodInfo item2 in Coroutines(type, null)) { if (NativeCode.Hookable(item2, type.Name, quiet: true)) { Remember(NameOf, item2.DeclaringType, name2); rest.Add(item2); } else { num++; } } } } array2 = array; foreach (Type type2 in array2) { if (!type2.IsClass || type2.IsNested || !type2.Name.EndsWith("MissionHandler")) { continue; } foreach (string item3 in list) { foreach (MethodInfo item4 in Coroutines(type2, new string[1] { item3 })) { if (NativeCode.Hookable(item4, type2.Name, quiet: true)) { Remember(NameOf, item4.DeclaringType, Names.Game(item3)); rest.Add(item4); } else { num++; } } } } Plugin.L.LogInfo((object)("Mission object hooks: " + landings.Count + " pod landings and " + rest.Count + " other methods (" + num + " left out as code the game may share), found in " + stopwatch.ElapsedMilliseconds + " ms")); } } private static class MissionCode { private static void Prefix(object __instance, out string __state) { string text = (Real.Is(__instance, "MissionCode") ? Missions.Of(__instance) : null); __state = ((text != null) ? Tracker.EnterEnv(text) : Tracker.EnvCtx); } private static void Finalizer(string __state) { Tracker.LeaveEnv(__state); } } private static class PodLanding { private static void Prefix(object __instance, out string __state) { string text = (Real.Is(__instance, "PodLanding") ? Missions.Of(__instance) : null); __state = ((text != null) ? Tracker.EnterEnv(text) : Tracker.EnvCtx); if (text != null) { Tracker.Event("pod", text + " Landed"); } } private static void Finalizer(string __state) { Tracker.LeaveEnv(__state); } } [HarmonyPatch] private static class Explosions { private static IEnumerable<MethodBase> TargetMethods() { return Methods(typeof(ExplosionHandler), "Explode", "ExplodeShrapnel"); } private static void Prefix(ExplosionHandler __instance, WeaponHandler __0, out Tracker.Blast __state) { __state = (Real.Is<ExplosionHandler>((object)__instance) ? Tracker.EnterExplosion(__0) : Tracker.CurrentBlast()); } private static void Finalizer(Tracker.Blast __state) { Tracker.LeaveExplosion(__state); } } [HarmonyPatch(typeof(ExplosionHandler), "DoMiningKillDamage")] private static class MiningExplosion { private static void Prefix(ExplosionHandler __instance, out Tracker.Blast __state) { __state = (Real.Is<ExplosionHandler>((object)__instance) ? Tracker.EnterExplosion(null) : Tracker.CurrentBlast()); } private static void Finalizer(Tracker.Blast __state) { Tracker.LeaveExplosion(__state); } } [HarmonyPatch(typeof(GameController), "UpdateGameState")] private static class State { private static void Postfix(GameController __instance, EGameState __0) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (Real.Is<GameController>((object)__instance)) { Tracker.Gc = __instance; Tracker.OnState(__0); } } } [HarmonyPatch(typeof(CoreStatTracker), "OnPlayerDamageDone")] private static class DamageDone { private static void Prefix(CoreStatTracker __instance, PlayerDamageDoneArgs __0) { long start = Perf.T(); if (Real.Is<CoreStatTracker>((object)__instance)) { Tracker.Damage(__0); } Perf.Add(Sec.Damage, start); } } [HarmonyPatch(typeof(CoreGameEvents), "TriggerSecondaryObjectiveCompleted")] private static class SecondaryDone { private static void Postfix() { Tracker.Event("secondary", "Secondary Objective Completed"); } } [HarmonyPatch] private static class ObjectiveDone { private static IEnumerable<MethodBase> TargetMethods() { return Methods(typeof(LevelObjectiveTracker), "OnObjectiveCompleted"); } private static void Postfix(object __instance) { if (Real.Is<LevelObjectiveTracker>(__instance)) { Tracker.Event("objective", "Main Objective Completed"); } } } [HarmonyPatch(typeof(CoreGameEvents), "TriggerStageBossSpawned")] private static class BossSpawned { private static void Postfix(StageBossSpawnArgs __0) { Tracker.Event("boss", "Boss Spawned"); if (!Real.Is<StageBossSpawnArgs>((object)__0)) { return; } try { Tracker.BossesSpawned(__0); } catch (Exception ex) { Tracker.LogOnce("boss-args", "Could not read the boss spawn: " + ex.Message); } } } [HarmonyPatch(typeof(CoreGameEvents), "TriggerPlayerEnteredDropPod")] private static class PodEntered { private static void Postfix() { Tracker.Event("pod", "Ended the Depth by entering the Drop Pod"); } } [HarmonyPatch(typeof(CoreStatTracker), "OnThreatLevel")] private static class ThreatLevel { private static void Prefix(CoreStatTracker __instance, int __0) { if (Real.Is<CoreStatTracker>((object)__instance)) { Tracker.Threat(__0); } } } [HarmonyPatch(typeof(MinionGrower), "Inject")] private static class GrowerInject { private static void Postfix(MinionGrower __instance, RunSettingsManager __2) { if (Real.Is<MinionGrower>((object)__instance)) { Tracker.Grower = __instance; if (Real.Is<RunSettingsManager>((object)__2)) { Tracker.RunSettings = __2; } } } } [HarmonyPatch(typeof(MinionGrower), "Awake")] private static class GrowerAwake { private static void Postfix(MinionGrower __instance) { if (Real.Is<MinionGrower>((object)__instance)) { Tracker.Grower = __instance; } } } [HarmonyPatch(typeof(CoreStatTracker), "OnCoreRunStarted")] private static class CoreStarted { private static void Postfix(CoreStatTracker __instance) { if (Real.Is<CoreStatTracker>((object)__instance)) { Tracker.EnsureRun(); } } } [HarmonyPatch(typeof(CoreStatTracker), "OnArtifactEquipped")] private static class ArtifactEquipped { private static void Prefix(CoreStatTracker __instance, PlayerArtifactEquippedArgs __0) { if (!Real.Is<CoreStatTracker>((object)__instance)) { return; } H(Tracker.Hk.ArtifactEquipped); try { Tracker.Event("artifact", "Artifact: " + ((ASkillData)__0.ArtifactSkillData).Title); } catch (Exception) { } } } [HarmonyPatch(typeof(RunStateManager), "Inject")] private static class RsmInject { private static void Postfix(RunStateManager __instance) { if (Real.Is<RunStateManager>((object)__instance)) { Tracker.Rsm = __instance; } } } [HarmonyPatch(typeof(RunStateManager), "OnCoreRunStarted")] private static class RsmStarted { private static void Postfix(RunStateManager __instance) { if (Real.Is<RunStateManager>((object)__instance)) { Tracker.Rsm = __instance; } } } [HarmonyPatch(typeof(CombatUtils), "GetIsCrit")] private static class IsCrit { private static void Postfix(bool __result, float __0, double __1, double __2) { long start = Perf.T(); Tracker.Roll(__result, __0, __1, __2); Perf.Add(Sec.Roll, start); } } [HarmonyPatch(typeof(WeaponHandler), "GetTotalDamage")] private static class TotalDamage { private static void Prefix() { Tracker.RollSuper = false; } private static void Postfix(WeaponHandler __instance, bool __0, Enemy __1) { long start = Perf.T(); if (Real.Is<WeaponHandler>((object)__instance)) { Tracker.WeaponRoll(__instance, __0, __1); } Perf.Add(Sec.Roll, start); } } [HarmonyPatch(typeof(WeaponHandler), "Init")] private static class WeaponInit { private static void Postfix(WeaponHandler __instance) { if (Real.Is<WeaponHandler>((object)__instance)) { Tracker.Weapon(__instance); } } } [HarmonyPatch(typeof(WeaponHandler), "OnDestroy")] private static class WeaponDestroy { private static void Prefix(WeaponHandler __instance) { if (Real.Is<WeaponHandler>((object)__instance)) { Tracker.WeaponGone(__instance); } } } [HarmonyPatch(typeof(WeaponHandler), "TrackStatusEffects")] private static class WeaponStatus { private static void Postfix(WeaponHandler __instance, int __0) { long start = Perf.T(); if (Real.Is<WeaponHandler>((object)__instance)) { Tracker.WeaponTracked(__instance, __0); } Perf.Add(Sec.Status, start); } } [HarmonyPatch(typeof(StatusEffectHandler), "Apply", new Type[] { typeof(EStatusEffect), typeof(int) })] private static class StatusApply { private static void Prefix(StatusEffectHandler __instance, out bool __state) { __state = Real.Is<StatusEffectHandler>((object)__instance); if (__state) { Freezes.Enter(__instance); } } private static void Postfix(EStatusEffect __0, int __1, bool __state) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (__state) { long start = Perf.T(); Tracker.StatusApplied(Names.Stat(__0), __1); Perf.Add(Sec.Status, start); } } private static void Finalizer(StatusEffectHandler __instance, bool __state) { if (__state) { Freezes.Leave(__instance, "Apply"); } } } [HarmonyPatch] private static class StatusSpread { private static IEnumerable<MethodBase> TargetMethods() { foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(typeof(StatusEffectHandler))) { if (declaredMethod.Name.Contains("Spread") && Plain(declaredMethod)) { yield return declaredMethod; } } } private static void Prefix(StatusEffectHandler __instance, out bool __state) { __state = Real.Is<StatusEffectHandler>((object)__instance); if (__state) { Tracker.SpreadEnter(); } } private static void Finalizer(bool __state) { if (__state) { Tracker.SpreadLeave(); } } } private static class Freezes { private struct Frame { public IntPtr Enemy; public int Depth; public bool Was; } private static readonly Frame[] Open = new Frame[16]; private static int open; public static void Enter(StatusEffectHandler h) { IntPtr pointer; try { pointer = ((Il2CppObjectBase)h).Pointer; } catch (Exception) { return; } for (int num = open - 1; num >= 0; num--) { if (Open[num].Enemy == pointer) { Open[num].Depth++; return; } } if (open < Open.Length) { bool was = true; try { was = h.IsFrozen; } catch (Exception) { } Open[open++] = new Frame { Enemy = pointer, Depth = 1, Was = was }; } } public static void Leave(StatusEffectHandler h, string path) { IntPtr pointer; try { pointer = ((Il2CppObjectBase)h).Pointer; } catch (Exception) { return; } for (int num = open - 1; num >= 0; num--) { if (!(Open[num].Enemy != pointer)) { if (--Open[num].Depth > 0) { break; } bool was = Open[num].Was; for (int i = num; i < open - 1; i++) { Open[i] = Open[i + 1]; } open--; if (!was) { bool flag = false; try { flag = h.IsFrozen; } catch (Exception) { } if (flag) { Count(path); } } break; } } } public static bool Inside(StatusEffectHandler h) { IntPtr pointer; try { pointer = ((Il2CppObjectBase)h).Pointer; } catch (Exception) { return false; } for (int i = 0; i < open; i++) { if (Open[i].Enemy == pointer) { return true; } } return false; } public static void Count(string path) { if (Tracker.FirstTime("freeze", path)) { Plugin.L.LogInfo((object)("Freeze seen through " + path)); } Tracker.FreezeStarted(); } } [HarmonyPatch(typeof(StatusEffectHandler), "AttemptFreeze")] private static class FreezeAttempt { private static void Prefix(StatusEffectHandler __instance, out bool __state) { __state = Real.Is<StatusEffectHandler>((object)__instance); if (__state) { Freezes.Enter(__instance); } } private static void Finalizer(StatusEffectHandler __instance, bool __state) { if (__state) { Freezes.Leave(__instance, "AttemptFreeze"); } } } [HarmonyPatch(typeof(StatusEffectHandler), "DoFreeze")] private static class FreezeDo { private static void Prefix(StatusEffectHandler __instance, out bool __state) { __state = Real.Is<StatusEffectHandler>((object)__instance); if (__state) { Freezes.Enter(__instance); } } private static void Finalizer(StatusEffectHandler __instance, bool __state) { if (__state) { Freezes.Leave(__instance, "DoFreeze"); } } } [HarmonyPatch] private static class FrozenStarts { private static IEnumerable<MethodBase> TargetMethods() { return Methods(typeof(StatusEffectHandler), "IEFrozen"); } private static void Postfix(StatusEffectHandler __instance) { if (Real.Is<StatusEffectHandler>((object)__instance) && !Freezes.Inside(__instance)) { Freezes.Count("IEFrozen"); } } } [HarmonyPatch] private static class StatusContext { private static IEnumerable<MethodBase> TargetMethods() { return Methods(typeof(WeaponHandler), "ApplyStatusEffects"); } private static void Prefix(WeaponHandler __instance, out StatusFrame __state) { if (!Real.Is<WeaponHandler>((object)__instance)) { __state = Tracker.CurrentStatus(); return; } H(Tracker.Hk.StatusCtx); __state = Tracker.PushStatus(__instance, other: false); } private static void Finalizer(StatusFrame __state) { Tracker.PopStatus(__state); } } [HarmonyPatch] private static class StatusExtraContext { private static IEnumerable<MethodBase> TargetMethods() { return Methods(typeof(WeaponHandler), "ApplyOtherStatusEffects"); } private static void Prefix(WeaponHandler __instance, out StatusFrame __state) { if (!Real.Is<WeaponHandler>((object)__instance)) { __state = Tracker.CurrentStatus(); return; } H(Tracker.Hk.StatusCtx); __state = Tracker.PushStatus(__instance, other: true); } private static void Finalizer(StatusFrame __state) { Tracker.PopStatus(__state); } } [HarmonyPatch(typeof(WeaponHandler), "AddWeaponLevel")] private static class WeaponLevel { private static void Postfix(WeaponHandler __instance) { if (!Real.Is<WeaponHandler>((object)__instance)) { return; } try { Tracker.Event("level", ((ASkillData)__instance.Data).Title + " Level: " + __instance.WeaponLevel); } catch (Exception) { } } } [HarmonyPatch(typeof(WeaponHandler), "AddOverclock")] private static class Overclock { private static void Postfix(WeaponHandler __instance, AOverclockData __0) { if (!Real.Is<WeaponHandler>((object)__instance)) { return; } try { Tracker.Event("overclock", ((ASkillData)__instance.Data).Title + " Overclock: " + OverclockTitle(__0)); } catch (Exception) { } } private static string OverclockTitle(AOverclockData oc) { string text = null; try { text = ((ASkillData)oc).Title; } catch (Exception) { } if (!string.IsNullOrWhiteSpace(text)) { return text.Trim(); } return ((Object)oc).name.Replace('_', ' '); } } [HarmonyPatch(typeof(Player), "EquipBoscoWeapon")] private static class BoscoEquip { private static void Prefix(Player __instance, out bool __state) { __state = Real.Is<Player>((object)__instance); if (__state) { H(Tracker.Hk.BoscoEquip); Tracker.Boscoing = true; } } private static void Finalizer(bool __state) { if (__state) { Tracker.Boscoing = false; } } } [HarmonyPatch(typeof(Player), "EquipBoscoStarterWeapon")] private static class BoscoStarter { private static void Prefix(Player __instance, out bool __state) { __state = Real.Is<Player>((object)__instance); if (__state) { Tracker.Boscoing = true; } } private static void Finalizer(bool __state) { if (__state) { Tracker.Boscoing = false; } } } [HarmonyPatch(typeof(Player), "TryBonk")] private static class Bonk { private static void Prefix(Player __instance, out bool __state) { __state = EnterMelee(__instance, Tracker.Hk.Bonk); } private static void Finalizer(bool __state) { if (__state) { Tracker.Leave(); } } } [HarmonyPatch(typeof(Player), "TryMine")] private static class Mine { private static void Prefix(Player __instance, out bool __state) { __state = EnterMelee(__instance, Tracker.Hk.Mine); } private static void Finalizer(bool __state) { if (__state) { Tracker.Leave(); } } } [HarmonyPatch(typeof(Player), "OnCollisionEnter")] private static class Collision { private static void Prefix(Player __instance, out bool __state) { __state = EnterMelee(__instance, Tracker.Hk.Collision); } private static void Finalizer(bool __state) { if (__state) { Tracker.Leave(); } } } private static class Artifacts { private sealed class Info { public string Name; public int Type = -1; } private static readonly Dictionary<Type, PropertyInfo> DataOf = new Dictionary<Type, PropertyInfo>(); private static readonly Dictionary<Type, PropertyInfo> OwnerOf = new Dictionary<Type, PropertyInfo>(); private static readonly Dictionary<IntPtr, Info> Known = new Dictionary<IntPtr, Info>(); private static readonly Dictionary<Type, PropertyInfo> TypeOf = new Dictionary<Type, PropertyInfo>(); public static List<MethodBase> Targets() { Stopwatch stopwatch = Stopwatch.StartNew(); List<MethodBase> list = new List<MethodBase>(); int num = 0; int num2 = 0; Type[] array; try { array = typeof(AbstractArtifactTrigger).Assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { array = Array.FindAll(ex.Types, (Type x) => x != null); } Type[] array2 = array; foreach (Type type in array2) { if (!type.IsClass || type.IsAbstract || type.ContainsGenericParameters || !type.Name.Contains("Artifact")) { continue; } PropertyInfo propertyInfo = DataProperty(type); if (propertyInfo == null || (!typeof(AbstractArtifactTrigger).IsAssignableFrom(type) && (!typeof(ClassArtifactData).IsAssignableFrom(propertyInfo.PropertyType) || !SetUpOnPlayer(type, propertyInfo.PropertyType)))) { continue; } DataOf[type] = propertyInfo; num++; foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(type)) { if (Plain(declaredMethod)) { if (NativeCode.Hookable(declaredMethod, type.Name, quiet: true)) { list.Add(declaredMethod); } else { num2++; } } } foreach (MethodInfo item in Coroutines(type, null)) { PropertyInfo propertyInfo2 = PropertyOf(item.DeclaringType, "__4__this"); if (!(propertyInfo2 == null)) { if (!NativeCode.Hookable(item, type.Name, quiet: true)) { num2++; continue; } OwnerOf[item.DeclaringType] = propertyInfo2; list.Add(item); } } } Plugin.L.LogInfo((object)("Artifact hooks: " + list.Count + " methods on " + num + " artifacts (" + num2 + " left out as code the game may share), found in " + stopwatch.ElapsedMilliseconds + " ms")); return list; } public static void Forget() { Known.Clear(); } private static bool SetUpOnPlayer(Type t, Type data) { foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(t)) { bool flag = false; bool flag2 = false; ParameterInfo[] parameters = declaredMethod.GetParameters(); foreach (ParameterInfo parameterInfo in parameters) { if (parameterInfo.ParameterType == data) { flag = true; } else if (parameterInfo.ParameterType == typeof(Player)) { flag2 = true; } } if (flag && flag2) { return true; } } return false; } private static PropertyInfo DataProperty(Type t) { PropertyInfo[] properties = t.GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo propertyInfo in properties) { if (propertyInfo.GetIndexParameters().Length == 0 && typeof(ArtifactSkillData).IsAssignableFrom(propertyInfo.PropertyType)) { return propertyInfo; } } return null; } public static bool Enter(object o) { Il2CppObjectBase val = (Il2CppObjectBase)((o is Il2CppObjectBase) ? o : null); if (val == null) { return false; } Type type = o.GetType(); if (OwnerOf.TryGetValue(type, out var value)) { try { object? value2 = value.GetValue(o); val = (Il2CppObjectBase)((value2 is Il2CppObjectBase) ? value2 : null); } catch (Exception) { return false; } if (val == null) { return false; } type = ((object)val).GetType(); } IntPtr pointer; try { pointer = val.Pointer; } catch (Exception) { return false; } if (!Known.TryGetValue(pointer, out var value3)) { value3 = Read(val, type); if (value3.Name == null) { return false; } if (Known.Count > 500) { Known.Clear(); } Known[pointer] = value3; } H(Tracker.Hk.Artifact); Tracker.EnterArtifact(value3.Name, value3.Type); return true; } private static Info Read(Il2CppObjectBase b, Type t) { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) Info info = new Info(); if (!DataOf.TryGetValue(t, out var value)) { return info; } try { object? value2 = value.GetValue(b); ASkillData val = (ASkillData)((value2 is ASkillData) ? value2 : null); if ((Object)(object)val == (Object)null) { return info; } info.Name = (string.IsNullOrEmpty(val.Title) ? t.Name : val.Title); try { Icons.Remember(info.Name, val.Icon); } catch (Exception) { } Type type = ((object)val).GetType(); if (!TypeOf.TryGetValue(type, out var value3)) { value3 = (TypeOf[type] = PropertyOf(type, "DamageType")); } if (value3 != null && value3.PropertyType == typeof(EDamageType)) { info.Type = Names.Dmg((EDamageType)value3.GetValue(val)); } if (Tracker.FirstTime("artifact", info.Name)) { Plugin.L.LogInfo((object)("Artifact " + info.Name + " (" + t.Name + ")" + ((info.Type >= 0) ? (", " + Names.Damage[info.Type]) : ""))); } } catch (Exception) { } return info; } } private static class ArtifactCode { private static void Prefix(object __instance, out bool __state) { __state = Real.Is(__instance, "ArtifactCode") && Artifacts.Enter(__instance); } private static void Finalizer(bool __state) { if (__state) { Tracker.Leave(); } } } [HarmonyPatch] private static class ZoneCreated { private static IEnumerable<MethodBase> TargetMethods() { return Methods(typeof(GroundZone), "Init"); } private static void Postfix(GroundZone __instance) { if (Real.Is<GroundZone>((object)__instance)) { H(Tracker.Hk.ZoneInit); Tracker.OwnZone(__instance); } } } [HarmonyPatch] private static class ZoneTick { private static IEnumerable<MethodBase> TargetMethods() { return Methods(typeof(GroundZone), "Update"); } private static void Prefix(GroundZone __instance, out bool __state) { __state = Real.Is<GroundZone>((object)__instance) && Tracker.EnterZone(__instance); } private static void Finalizer(bool __state) { if (__state) { Tracker.Leave(); } } } [HarmonyPatch] private static class ProjectileFired { private static IEnumerable<MethodBase> TargetMethods() { return Methods(typeof(Projectile), "Shoot"); } private static void Postfix(Projectile __instance) { if (Real.Is<Projectile>((object)__instance)) { H(Tracker.Hk.ProjFired); Tracker.OwnProjectile(__instance); } } } [HarmonyPatch] private static class ProjectileHitting { private static IEnumerable<MethodBase> TargetMethods() { return Methods(typeof(Projectile), "ProjectileHit"); } private static void Prefix(Projectile __instance, out bool __state) { __state = Real.Is<Projectile>((object)__instance); if (__state) { H(Tracker.Hk.ProjHit); Tracker.EnterProjectile(__instance); } } private static void Finalizer(bool __state) { if (__state) { Tracker.Leave(); } } } private static Harmony harmony; private static bool zoneTickOn; private const BindingFlags AnyDeclared = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; public static void Apply(string guid) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown harmony = new Harmony(guid); Type[] nestedTypes = typeof(Hooks).GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic); foreach (Type type in nestedTypes) { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Length != 0 && !(type == typeof(ZoneTick))) { PatchClass(type); } } PatchSearched("Artifact", "ArtifactCode", Artifacts.Targets, typeof(ArtifactCode)); PatchSearched("Map block", "BlockCode", Blocks.Targets, typeof(BlockCode)); PatchSearched("Pod landing", "PodLanding", Missions.Landings, typeof(PodLanding)); PatchSearched("Mission object", "MissionCode", Missions.Targets, typeof(MissionCode)); if (Settings.DebugLog.Value) { NativeCode.Report(harmony); } } public static void EnsureZoneTick() { if (!zoneTickOn) { zoneTickOn = true; PatchClass(typeof(ZoneTick)); Plugin.L.LogInfo((object)"Ground zone tick hook applied"); } } private static void PatchClass(Type t) { List<MethodBase> list; try { list = TargetsOf(t); } catch (Exception ex) { Plugin.L.LogWarning((object)("Hook " + t.Name + " failed: " + ex.Message)); return; } HarmonyMethod val = PatchMethod(t, "Prefix"); HarmonyMethod val2 = PatchMethod(t, "Postfix"); HarmonyMethod val3 = PatchMethod(t, "Finalizer"); foreach (MethodBase item in list) { if (!(item == null) && NativeCode.Claim(item, t.Name)) { try { harmony.Patch(item, val, val2, (HarmonyMethod)null, val3, (HarmonyMethod)null); } catch (Exception ex2) { Plugin.L.LogWarning((object)("Hook " + t.Name + " on " + item.DeclaringType?.Name + "." + item.Name + " failed: " + ex2.Message)); } } } } private static HarmonyMethod PatchMethod(Type t, string name) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown MethodInfo methodInfo = DeclaredMethod(t, name); if (!(methodInfo != null)) { return null; } return new HarmonyMethod(methodInfo); } private static MethodInfo DeclaredMethod(Type t, string name) { MethodInfo[] methods = t.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name == name) { return methodInfo; } } return null; } private static PropertyInfo PropertyOf(Type t, string name) { try { return t.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } catch (AmbiguousMatchException) { return null; } } private static List<MethodBase> TargetsOf(Type t) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown MethodInfo methodInfo = DeclaredMethod(t, "TargetMethods"); if (methodInfo != null) { return new List<MethodBase>((IEnumerable<MethodBase>)methodInfo.Invoke(null, null)); } Type type = null; string text = null; Type[] array = null; object[] customAttributes = t.GetCustomAttributes(typeof(HarmonyPatch), inherit: false); for (int i = 0; i < customAttributes.Length; i++) { HarmonyPatch val = (HarmonyPatch)customAttributes[i]; if ((object)type == null) { type = ((HarmonyAttribute)val).info.declaringType; } if (text == null) { text = ((HarmonyAttribute)val).info.methodName; } if (array == null) { array = ((HarmonyAttribute)val).info.argumentTypes; } } MethodInfo methodInfo2 = ((type != null && text != null) ? AccessTools.Method(type, text, array, (Type[])null) : null); if (methodInfo2 == null) { throw new Exception("target " + type?.Name + "." + text + " not found"); } return new List<MethodBase> { methodInfo2 }; } private static IEnumerable<MethodBase> Methods(Type type, params string[] names) { foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(type)) { if (Array.IndexOf(names, declaredMethod.Name) >= 0) { yield return declaredMethod; } } } private static void H(Tracker.Hk h) { Tracker.Hit(h); } internal static void Note(string msg) { if (Settings.DebugLog.Value) { Plugin.L.LogInfo((object)msg); } } public static string SharedReport() { return Real.Report(); } public static void NewRun() { Artifacts.Forget(); } private static IEnumerable<MethodBase> Containing(Type type, params string[] parts) { List<string> list = new List<string>(); List<MethodBase> list2 = new List<MethodBase>(); foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(type)) { if (Matches(declaredMethod.Name, parts) && Plain(declaredMethod) && NativeCode.Hookable(declaredMethod, type.Name)) { list.Add(declaredMethod.Name); list2.Add(declaredMethod); } } foreach (MethodInfo item in Coroutines(type, parts)) { if (NativeCode.Hookable(item, type.Name + "." + item.DeclaringType.Name)) { list.Add(item.DeclaringType.Name + ".MoveNext"); list2.Add(item); } } if (Settings.DebugLog.Value) { Plugin.L.LogInfo((object)("Map feature hooks on " + type.Name + ": " + ((list.Count > 0) ? string.Join(", ", list) : "none"))); } return list2; } private static bool Plain(MethodInfo m) { if (!m.IsStatic && !m.IsSpecialName && !m.IsAbstract && !m.ContainsGenericParameters && !m.IsConstructor) { return m.ReturnType.Name != "IEnumerator"; } return false; } private static IEnumerable<MethodInfo> Coroutines(Type type, string[] parts) { Type[] nestedTypes = type.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic); foreach (Type type2 in nestedTypes) { if (!type2.ContainsGenericParameters && type2.Name.Contains("_d__") && (parts == null || parts.Length == 0 || Matches(type2.Name, parts))) { MethodInfo methodInfo = DeclaredMethod(type2, "MoveNext"); if (methodInfo != null) { yield return methodInfo; } } } } private static bool Matches(string name, string[] parts) { foreach (string value in parts) { if (name.Contains(value)) { return true; } } return false; } private static string EnterEnv(object o, string key, string name) { if (!Real.Is(o, key)) { return Tracker.EnvCtx; } return Tracker.EnterEnv(name); } private static string Words(string s) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < s.Length; i++) { char c = s[i]; bool flag = char.IsUpper(c); if (i > 0 && flag && (char.IsLower(s[i - 1]) || (i + 1 < s.Length && char.IsLower(s[i + 1]) && char.IsUpper(s[i - 1])))) { stringBuilder.Append(' '); } stringBuilder.Append(c); } return stringBuilder.ToString(); } private static string NameFrom(Dictionary<IntPtr, string> names, object o) { Il2CppObjectBase val = (Il2CppObjectBase)((o is Il2CppObjectBase) ? o : null); if (val == null) { return null; } try { string value; return names.TryGetValue(Marshal.ReadIntPtr(val.Pointer), out value) ? value : null; } catch (Exception) { return null; } } private static void Remember(Dictionary<IntPtr, string> names, Type t, string name) { try { IntPtr nativeClassPointer = Il2CppClassPointerStore.GetNativeClassPointer(t); if (nativeClassPointer != IntPtr.Zero) { names[nativeClassPointer] = name; } } catch (Exception) { } } private static bool EnterMelee(Player p, Tracker.Hk h) { if (!Real.Is<Player>((object)p)) { return false; } long start = Perf.T(); H(h); Tracker.EnterMelee(); Perf.Add(Sec.Melee, start); return true; } private static void PatchSearched(string what, string key, Func<List<MethodBase>> search, Type patch) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown List<MethodBase> list; try { list = new List<MethodBase>(Real.For(key, search())); } catch (Exception ex) { Plugin.L.LogWarning((object)(what + " hooks failed: " + ex.Message)); return; } HarmonyMethod val = new HarmonyMethod(AccessTools.Method(patch, "Prefix", (Type[])null, (Type[])null)); HarmonyMethod val2 = new HarmonyMethod(AccessTools.Method(patch, "Finalizer", (Type[])null, (Type[])null)); int num = 0; foreach (MethodBase item in list) { if (!NativeCode.Claim(item, what + " search")) { continue; } try { harmony.Patch(item, val, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null); } catch (Exception ex2) { if (num++ < 5) { Plugin.L.LogWarning((object)(what + " hook " + item.DeclaringType?.Name + "." + item.Name + " failed: " + ex2.Message)); } } } if (num > 0) { Plugin.L.LogWarning((object)(what + " hooks: " + num + " of " + list.Count + " could not be applied")); } } } internal static class Hud { private struct Row { public string Name; public string Total; public string Dps; public string Pct; public string Crit; public float Fill; public Color Col; public int Type; public double[] Mix; public Icon Chip; public SourceRec Src; } private struct StatRow { public string Name; public string Stacks; public string Rate; public string Pct; public float Fill; public Color Col; public int Type; public double[] Mix; public Icon Chip; public SourceRec Src; } private struct Chip { public Ico Icon; public Color Tint; public string Text; public int Id; } private static readonly Row[] Rows = new Row[24]; private static readonly StatRow[] SRows = new StatRow[12]; private static readonly Chip[] Chips = new Chip[4]; private static readonly List<SourceRec> Sorted = new List<SourceRec>(); private static readonly List<SourceRec> StatList = new List<SourceRec>(); private static readonly TextStyles Styles = new TextStyles(); private static int nRows; private static int nStat; private static int nChips; private static string sub = ""; private static string statSub = ""; private static bool dragging; private static bool hovered; private static bool lockShown; private static Vector2 grab; private static Vector2 dragPos; private static Vector2 lastPos; private static Rect panelRect; private static Rect lockRect; private static float nextBuild; private static Run tipRun; private static Run drawnRun; private static readonly double[] WarmMix = new double[6] { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; private static readonly Vector2[] WarmPts = (Vector2[])(object)new Vector2[3] { new Vector2(-4000f, -4000f), new Vector2(-3900f, -3950f), new Vector2(-3800f, -3990f) }; private static readonly double[] StatTot = new double[7]; private static readonly List<KeyValuePair<string, double>> PartList = new List<KeyValuePair<string, double>>(); public static void OnGUI() { //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_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Invalid comparison between Unknown and I4 EGameState state = Tracker.State; bool flag = (int)state == 5 || (int)state == 4; if (!Settings.Enabled.Value || Tracker.Run == null || ((int)state != 2 && (!flag || !Settings.ShowInShop.Value))) { Release(); return; } bool flag2 = Time.timeScale <= 0f; if (Settings.HideWhenPaused.Value && flag2 && !flag) { Release(); return; } bool flag3 = flag2 || flag; Event current = Event.current; if ((int)current.type != 7) { Mouse(current, flag3); return; } long start = Perf.T(); long num = ((drawnRun != Tracker.Run) ? Stopwatch.GetTimestamp() : 0); if (Time.unscaledTime >= nextBuild) { nextBuild = Time.unscaledTime + 0.25f; Rebuild(); Perf.Add(Sec.Rebuild, start); start = Perf.T(); } Draw(flag3); UiBlock.Set(1, flag3 && (hovered || dragging)); Perf.Add(Sec.HudDraw, start); if (num != 0L) { drawnRun = Tracker.Run; if (Settings.DebugLog.Value) { Plugin.L.LogInfo((object)("First HUD frame of the run took " + ((double)(Stopwatch.GetTimestamp() - num) * Perf.Ms).ToString("0.0") + " ms")); } } } private static void Mouse(Event e, bool idle) { //IL_0011: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Invalid comparison between Unknown and I4 //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Invalid comparison between Unknown and I4 //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //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_00ce: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) if (!idle) { if (dragging) { EndDrag(); } return; } Vector2 mousePosition = e.mousePosition; if ((int)e.type == 0 && e.button == 0) { if (lockShown && ((Rect)(ref lockRect)).Contains(mousePosition)) { Settings.Locked.Value = !Settings.Locked.Value; e.Use(); } else if (!Settings.Locked.Value && ((Rect)(ref panelRect)).Contains(mousePosition)) { float value = Settings.Scale.Value; dragging = true; dragPos = lastPos * value; grab = mousePosition - dragPos; e.Use(); } } else if ((int)e.type == 3 && dragging) { dragPos = mousePosition - grab; e.Use(); } else if ((int)e.type == 1 && dragging) { EndDrag(); e.Use(); } } private static void EndDrag() { dragging = false; float value = Settings.Scale.Value; Settings.AnchorX.Value = Mathf.Clamp01(lastPos.x * value / (float)Mathf.Max(1, Screen.width)); Settings.AnchorY.Value = Mathf.Clamp01(lastPos.y * value / (float)Mathf.Max(1, Screen.height)); } private static void Release() { if (dragging) { EndDrag(); } hovered = (lockShown = false); UiBlock.Set(1, on: false); } public static void Abort() { dragging = false; hovered = (lockShown = false); UiBlock.Set(1, on: false); } public static void Warm() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: 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_0204: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027c: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_0356: 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) long timestamp = Stopwatch.GetTimestamp(); if (Styles.Dirty()) { Styles.Build(); } long timestamp2 = Stopwatch.GetTimestamp(); Rect val = default(Rect); ((Rect)(ref val))..ctor(-4000f, -4000f, 240f, 24f); Gfx.Fill(val, Color.black); Gfx.AmberBar(val, 8f); Gfx.NotchRim(val, 8f, Gfx.Amber); Gfx.TypedBar(val, WarmMix, 0, Color.white, 0.8f); Gfx.Disc(((Rect)(ref val)).center, 4f, Color.white); Texture val2 = Icons.DecoTex(Deco.Fade); if ((Object)(object)val2 != (Object)null) { Gfx.Tex(val, val2, Color.black); } Bracket(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).height); long timestamp3 = Stopwatch.GetTimestamp(); StringBuilder parts = new StringBuilder(); long tp = Stopwatch.GetTimestamp(); try { Styles.Body.Draw(val, new GUIContent("Warm up 0123456789 %.,"), false, false, false, false); } catch (Exception) { } Lap("first plain label"); Styles.Draw(val, "Warm up 0123456789 %.,", Styles.Body, Styles.BodyD); Lap("body"); Styles.Draw(val, "Warm up 0123456789 %.,", Styles.Num, Styles.NumD); Lap("numbers"); Styles.Draw(val, "Warm up 0123456789 %.,", Styles.Head, Styles.HeadD); Lap("header"); Styles.Draw(val, "Warm up 0123456789 %.,", Styles.ColL, Styles.ColLD); Styles.Draw(val, "Warm up 0123456789 %.,", Styles.ColR, Styles.ColRD); Lap("columns"); Styles.Draw(val, "Warm up 0123456789 %.,", Styles.Small, Styles.SmallD); Lap("small"); TextStyles.Lbl(val, "Warm up 0123456789 %.,", Styles.HeadK); TextStyles.Lbl(val, "Warm up 0123456789 %.,", Styles.NumK); Lap("ink"); Txt.Width("Warm up 0123456789 %.,", 0, 14); Txt.Draw(val, "Warm up 0123456789 %.,", 1, 14, Color.white, (TextAnchor)3); Lap("review text"); long timestamp4 = Stopwatch.GetTimestamp(); for (int i = 0; i < 36; i++) { Icons.Draw(val, Icons.Get((Ico)i), Color.white, outline: true); } long timestamp5 = Stopwatch.GetTimestamp(); Gfx.Lines(WarmPts, 3, Color.white, 2f, 4f, 3f); Gfx.Area(WarmPts, 3, -3900f, Color.white); long timestamp6 = Stopwatch.GetTimestamp(); TipData tipData = new TipData(); tipData.Title = "Warm up"; tipData.Sub = "Warm up 0123456789 %.,"; tipData.Note = "Warm up 0123456789 %.,"; tipData.Icon = Icons.Get(Ico.Dps); tipData.Row("1", "Warm Up", Icons.Get(Ico.Dps)); TipBox.Draw(tipData, val, new Rect(-6000f, -6000f, 3000f, 3000f), 1f); long timestamp7 = Stopwatch.GetTimestamp(); if (Settings.DebugLog.Value) { Plugin.L.LogInfo((object)("Warm up took " + ((double)(timestamp7 - timestamp) * Perf.Ms).ToString("0.0") + " ms (styles " + ((double)(timestamp2 - timestamp) * Perf.Ms).ToString("0.0") + ", shapes " + ((double)(timestamp3 - timestamp2) * Perf.Ms).ToString("0.0") + ", text " + ((double)(timestamp4 - timestamp3) * Perf.Ms).ToString("0.0") + ", icons " + ((double)(timestamp5 - timestamp4) * Perf.Ms).ToString("0.0") + ", lines " + ((double)(timestamp6 - timestamp5) * Perf.Ms).ToString("0.0") + ", tooltip " + ((double)(timestamp7 - timestamp6) * Perf.Ms).ToString("0.0") + "); text: " + parts)); } void Lap(string what) { long timestamp8 = Stopwatch.GetTimestamp(); parts.Append((parts.Length > 0) ? ", " : "").Append(what).Append(' ') .Append(((double)(timestamp8 - tp) * Perf.Ms).ToString("0.0")); tp = timestamp8; } } public static Icon ChipIcon(SourceRec s) { if (s.Kind == Kind.Direct) { return Icons.Get(Ico.Melee); } if (s.Kind == Kind.Hazard) { return Icons.Get(Ico.Threat); } if (s.Kind == Kind.Untracked) { return Icons.Get(Ico.Hurt); } return Icons.Type(s.Type) ?? Icons.Get(Ico.Hurt); } public static Color ChipColor(SourceRec s) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (s.Type < 0 || s.Type >= 6) { return new Color(0.55f, 0.62f, 0.65f); } return Names.DamageColor[s.Type]; } public static Icon IconFor(SourceRec s) { Icon icon; if (s.Kind != Kind.Dot) { icon = Icons.ByName(s.Name); if (icon == null) { return ChipIcon(s); } } else { icon = Icons.Type(s.Type); } return icon; } private static void Rebuild() { //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_050a: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0282: 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) if (Styles.Dirty()) { Styles.Build(); } Tracker.Refresh(); Run run = (tipRun = Tracker.Run); Sorted.Clear(); bool flag = Settings.SortBy.Value == "DPS"; double total = run.Total; double num = 0.0; float value = Settings.MinPercent.Value; foreach (SourceRec source in run.Sources) { if (!(source.Total <= 0.0) && (!(total > 0.0) || !(source.Total / total * 100.0 < (double)value))) { double num2 = (flag ? source.Dps : source.Total); int num3 = Sorted.Count; Sorted.Add(source); while (num3 > 0 && (flag ? Sorted[num3 - 1].Dps : Sorted[num3 - 1].Total) < num2) { Sorted[num3] = Sorted[num3 - 1]; num3--; } Sorted[num3] = source; } } nRows = Mathf.Min(Sorted.Count, Mathf.Min(Settings.MaxRows.Value, Rows.Length)); bool flag2 = Settings.BarBasis.Value == "Share of total"; if (nRows > 0) { num = (flag ? Sorted[0].Dps : Sorted[0].Total); } for (int i = 0; i < nRows; i++) { SourceRec sourceRec = Sorted[i]; double num4 = (flag ? sourceRec.Dps : sourceRec.Total); double num5 = ((total > 0.0) ? (sourceRec.Total / total * 100.0) : 0.0); double[] array = Rows[i].Mix ?? new double[6]; Array.Copy(sourceRec.Dmg, array, 6); Rows[i] = new Row { Mix = array, Name = sourceRec.Name, Col = ChipColor(sourceRec), Type = sourceRec.Type, Chip = ChipIcon(sourceRec), Src = sourceRec, Total = Fmt.Num(sourceRec.Total), Dps = Fmt.Num(sourceRec.Dps), Pct = Fmt.Pct(num5), Fill = (flag2 ? ((float)(num5 / 100.0)) : ((num > 0.0) ? ((float)(num4 / num)) : 0f)), Crit = ((sourceRec.Kind == Kind.Weapon && sourceRec.Hits > 0) ? Fmt.Pct((double)sourceRec.Crits * 100.0 / (double)sourceRec.Hits) : "") }; } float num6 = Mathf.Max(1f, Tracker.Clock); sub = "Total: " + Fmt.Num(total) + " · DPS: " + Fmt.Num(total / (double)num6); nChips = 0; if (run.Rolls > 0) { Chips[nChips++] = new Chip { Icon = Ico.Crit, Tint = Color.white, Text = Fmt.Pct((double)run.Crits * 100.0 / (double)run.Rolls), Id = 0 }; Chips[nChips++] = new Chip { Icon = Ico.SuperCrit, Tint = Txt.Value, Text = Fmt.Pct((double)run.Supers * 100.0 / (double)run.Rolls), Id = 1 }; } Chips[nChips++] = new Chip { Icon = Ico.Threat, Tint = new Color(1f, 0.42f, 0.22f), Text = Tracker.CurThreat.ToString(), Id = 2 }; if (Tracker.Depth >= 0) { Chips[nChips++] = new Chip { Icon = Ico.Depth, Tint = Gfx.Amber, Text = "Depth " + (Tracker.Depth + 1), Id = 3 }; } BuildStatus(run); } private static void BuildStatus(Run run) { //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) nStat = 0; if (!Settings.ShowStatus.Value) { return; } List<SourceRec> statList = StatList; statList.Clear(); double num = 0.0; Array.Clear(StatTot, 0, StatTot.Length); foreach (SourceRec source in run.Sources) { if (!(source.Applied <= 0.0)) { num += source.Applied; for (int i = 1; i < 7; i++) { StatTot[i] += source.Status[i]; } } } if (num <= 0.0) { return; } bool flag = Settings.StatusSortBy.Value != "Total"; float value = Settings.StatusMinPercent.Value; foreach (SourceRec source2 in run.Sources) { if (source2.Applied <= 0.0) { continue; } bool flag2 = source2.Applied / num * 100.0 >= (double)value; for (int j = 1; j < 7; j++) { if (flag2) { break; } flag2 = StatTot[j] > 0.0 && source2.Status[j] / StatTot[j] * 100.0 >= (double)value; } if (flag2) { double num2 = (flag ? source2.StackRate : source2.Applied); int num3 = statList.Count; statList.Add(source2); while (num3 > 0 && (flag ? statList[num3 - 1].StackRate : statList[num3 - 1].Applied) < num2) { statList[num3] = statList[num3 - 1]; num3--; } statList[num3] = source2; } } nStat = Mathf.Min(statList.Count, Mathf.Min(Settings.StatusRows.Value, SRows.Length)); double num4 = ((nStat <= 0) ? 0.0 : (flag ? statList[0].StackRate : statList[0].Applied)); bool flag3 = Settings.StatusBarBasis.Value == "Share of total"; float num5 = Mathf.Max(1f, Tracker.Clock); statSub = "Total: " + Fmt.Num(num) + " · APS: " + Fmt.Num(num / (double)num5); for (int k = 0; k < nStat; k++) { SourceRec sourceRec = statList[k]; double[] array = SRows[k].Mix ?? new double[6]; Array.Clear(array, 0, 6); for (int l = 1; l < 7; l++) { int num6 = Names.StatusType[l]; if (num6 >= 0) { array[num6] += sourceRec.Status[l]; } } double num7 = sourceRec.Applied / num * 100.0; double num8 = (flag ? sourceRec.StackRate : sourceRec.Applied); SRows[k] = new StatRow { Name = sourceRec.Name, Stacks = Fmt.Num(sourceRec.Applied), Rate = Fmt.Num(sourceRec.StackRate), Pct = Fmt.Pct(num7), Fill = (flag3 ? ((float)(num7 / 100.0)) : ((num4 > 0.0) ? ((float)(num8 / num4)) : 0f)), Mix = array, Type = sourceRec.Type, Col = ChipColor(sourceRec), Chip = ChipIcon(sourceRec), Src = sourceRec }; } } private static void Draw(bool idle) { //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0164: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_029e: 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_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_0505: Unknown result type (might be due to invalid IL or missing references) //IL_052f: Unknown result type (might be due to invalid IL or missing references) //IL_0548: Unknown result type (might be due to invalid IL or missing references) //IL_057c: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_05bf: Unknown result type (might be due to invalid IL or missing references) //IL_05de: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_05f5: Unknown result type (might be due to invalid IL or missing references) //IL_06b5: Unknown result type (might be due to invalid IL or missing references) //IL_07e1: Unknown result type (might be due to invalid IL or missing references) //IL_07f6: Unknown result type (might be due to invalid IL or missing references) //IL_06ec: Unknown result type (might be due to invalid IL or missing references) //IL_0a28: Unknown result type (might be due to invalid IL or missing references) //IL_0a4b: Unknown result type (might be due to invalid IL or missing references) //IL_0a7c: Unknown result type (might be due to invalid IL or missing references) //IL_0723: Unknown result type (might be due to invalid IL or missing references) //IL_081a: Unknown result type (might be due to invalid IL or missing references) //IL_083d: Unknown result type (might be due to invalid IL or missing references) //IL_0852: Unknown result type (might be due to invalid IL or missing references) //IL_0e38: Unknown result type (might be due to invalid IL or missing references) //IL_079a: Unknown result type (might be due to invalid IL or missing references) //IL_075a: Unknown result type (might be due to invalid IL or missing references) //IL_086b: Unknown result type (might be due to invalid IL or missing references) //IL_0872: Unknown result type (might be due to invalid IL or missing references) //IL_089a: Unknown result type (might be due to invalid IL or missing references) //IL_08a6: Unknown result type (might be due to invalid IL or missing references) //IL_0fa6: Unknown result type (might be due to invalid IL or missing references) //IL_0fbd: Unknown result type (might be due to invalid IL or missing references) //IL_0ea9: Unknown result type (might be due to invalid IL or missing references) //IL_0eac: Unknown result type (might be due to invalid IL or missing references) //IL_0eb8: Unknown result type (might be due to invalid IL or missing references) //IL_08d1: Unknown result type (might be due to invalid IL or missing references) //IL_0ffd: Unknown result type (might be due to invalid IL or missing references) //IL_1015: Unknown result type (might be due to invalid IL or missing references) //IL_0e4c: Unknown result type (might be due to invalid IL or missing references) //IL_0e74: Unknown result type (might be due to invalid IL or missing references) //IL_0909: Unknown result type (might be due to invalid IL or missing references) //IL_0ed9: Unknown result type (might be due to invalid IL or missing references) //IL_0ee3: Unknown result type (might be due to invalid IL or missing references) //IL_0941: Unknown result type (might be due to invalid IL or missing references) //IL_0f0f: Unknown result type (might be due to invalid IL or missing references) //IL_09ba: Unknown result type (might be due to invalid IL or missing references) //IL_0979: Unknown result type (might be due to invalid IL or missing references) //IL_0f57: Unknown result type (might be due to invalid IL or missing references) //IL_09e2: Unknown result type (might be due to invalid IL or missing references) //IL_09e4: Unknown result type (might be due to invalid IL or missing references) //IL_0f8d: Unknown result type (might be due to invalid IL or missing references) //IL_0f08: Unknown result type (might be due to invalid IL or missing references) //IL_0fa2: Unknown result type (might be due to invalid IL or missing references) //IL_0fa4: Unknown result type (might be due to invalid IL or missing references) //IL_0f86: Unknown result type (might be due to invalid IL or missing references) //IL_0b18: Unknown result type (might be due to invalid IL or missing references) //IL_0c0d: Unknown result type (might be due to invalid IL or missing references) //IL_0c22: Unknown result type (might be due to invalid IL or missing references) //IL_0b4f: Unknown result type (might be due to invalid IL or missing references) //IL_0bc6: Unknown result type (might be due to invalid IL or missing references) //IL_0b86: Unknown result type (might be due to invalid IL or missing references) //IL_0c46: Unknown result type (might be due to invalid IL or missing references) //IL_0c69: Unknown result type (might be due to invalid IL or missing references) //IL_0c7e: Unknown result type (might be due to invalid IL or missing references) //IL_0c9c: Unknown result type (might be due to invalid IL or missing references) //IL_0ca3: Unknown result type (might be due to invalid IL or missing references) //IL_0ccb: Unknown result type (might be due to invalid IL or missing references) //IL_0cd7: Unknown result type (might be due to invalid IL or missing references) //IL_0d02: Unknown result type (might be due to invalid IL or missing references) //IL_0d3a: Unknown result type (might be due to invalid IL or missing references) //IL_0db3: Unknown result type (might be due to invalid IL or missing references) //IL_0d72: Unknown result type (might be due to invalid IL or missing references) //IL_0ddb: Unknown result type (mig