Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BuminDeathRecap v1.2.0
plugins/BuminDeathRecap.dll
Decompiled 5 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.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace BuminDeathRecap; [HarmonyPatch(typeof(Character), "ApplyDamage")] internal static class ApplyDamagePatch { internal sealed class State { public float Hp; public float[] Before; public float Shield; } [HarmonyPriority(800)] private static void Prefix(Character __instance, HitData hit, out State __state) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) __state = null; try { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && hit != null && !__instance.IsDead()) { __state = new State(); __state.Hp = __instance.GetHealth(); __state.Before = Dmg.Vec(hit.m_damage); __state.Shield = Shield.AbsorbedNow(); } } catch (Exception e) { Plugin.LogOnce("ApplyDamage prefix", e); } } [HarmonyPriority(0)] private static void Postfix(Character __instance, HitData hit, State __state) { if (__state == null) { return; } try { float num = __state.Hp - Mathf.Max(0f, __instance.GetHealth()); float shield = Mathf.Max(0f, Shield.AbsorbedNow() - __state.Shield); Recorder.OnApplied(hit, Mathf.Max(0f, num), __state.Before, shield); } catch (Exception e) { Plugin.LogOnce("ApplyDamage postfix", e); } } } internal sealed class AttackGroup { public string Attack; public int Count; public bool Killing; public float[] D = new float[9]; public float Biggest; public float Shield; public float Mit; public float Total => Dmg.Sum(D); internal static List<AttackGroup> Of(DeathRec r, int a) { List<AttackGroup> list = new List<AttackGroup>(); HitRec last = r.Last; foreach (HitRec hit in r.Hits) { if (hit.A != a) { continue; } AttackGroup attackGroup = null; foreach (AttackGroup item in list) { if (item.Attack == hit.Attack) { attackGroup = item; break; } } if (attackGroup == null) { attackGroup = new AttackGroup(); attackGroup.Attack = hit.Attack; list.Add(attackGroup); } attackGroup.Count++; attackGroup.Shield += hit.Shield; attackGroup.Mit += hit.MitTotal; for (int i = 0; i < 9; i++) { attackGroup.D[i] += hit.D[i]; } if (hit.Total > attackGroup.Biggest) { attackGroup.Biggest = hit.Total; } if (hit == last) { attackGroup.Killing = true; } } foreach (HitRec mit in r.Mits) { if (mit.A != a) { continue; } foreach (AttackGroup item2 in list) { if (item2.Attack == mit.Attack) { item2.Mit += mit.MitTotal; break; } } } list.Sort((AttackGroup x, AttackGroup y) => (y.Total + y.Shield * 0.001f).CompareTo(x.Total + x.Shield * 0.001f)); return list; } public string Chip() { string text = Attack; if (Count > 1) { text = text + " ×" + Count; } if (Total < 0.5f && Shield >= 0.5f) { return text + " · " + Text.F("shieldShort", Text.Num(Shield)); } return text + " · " + Text.Num(Total) + " " + Text.G("type" + Dmg.Top(D)); } public string Breakdown() { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < 9; i++) { if (!(D[i] < 0.5f)) { if (stringBuilder.Length > 0) { stringBuilder.Append('\n'); } stringBuilder.Append(Text.G("type" + i)).Append(": ").Append(Text.Num(D[i])); } } if (Shield >= 0.5f) { if (stringBuilder.Length > 0) { stringBuilder.Append('\n'); } stringBuilder.Append("<color=").Append("#6FB7FF").Append('>') .Append(Text.F("shieldAte", Text.Num(Shield))) .Append("</color>"); } if (Mit >= 0.5f) { if (stringBuilder.Length > 0) { stringBuilder.Append('\n'); } stringBuilder.Append("<color=").Append("#B8B2A7").Append('>') .Append(Text.F("mitShort", Text.Num(Mit))) .Append("</color>"); } return stringBuilder.ToString(); } } internal sealed class AttackerRec { public string Key = ""; public string Name = ""; public int Stars; public int Kind; public string IconItem = ""; public string Glyph = ""; public int Count = 1; } internal sealed class BuffRec { public int Hash; public string Name = ""; public string Tip = ""; } [HarmonyPatch(typeof(TextsDialog), "UpdateTextsList")] internal static class CompendiumPatch { private static readonly FieldInfo Texts = AccessTools.Field(typeof(TextsDialog), "m_texts"); private static void Postfix(TextsDialog __instance) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown try { if (Plugin.Compendium.Value && !(Texts == null) && Texts.GetValue(__instance) is List<TextInfo> list) { list.Insert(Mathf.Min(1, list.Count), new TextInfo(Text.G("compTitle"), Store.Report())); } } catch (Exception e) { Plugin.LogOnce("Compendium", e); } } } internal sealed class ConfigurationManagerAttributes { public int? Order; } [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] internal static class CursorPatch { private static void Postfix() { if (DeathUi.WantsCursor) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } } [HarmonyPatch(typeof(Player), "OnDeath")] internal static class DeathPatch { [HarmonyPriority(800)] private static void Prefix(Player __instance) { try { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { DeathRec deathRec = Recorder.Finish(__instance); Store.Add(deathRec); Plugin.Log.LogInfo((object)("Death recorded: " + deathRec.Hits.Count + " hits, " + Text.Num(deathRec.Total) + " damage, " + Text.Num(deathRec.ShieldTotal) + " absorbed by the rune shield, " + Text.Num(deathRec.MitTotal) + " mitigated (" + deathRec.Stopped + " hits stopped), killer " + ((deathRec.Killer != null) ? deathRec.Killer.Key : "none") + ", last attack " + ((deathRec.Last != null) ? deathRec.Last.Attack : "-"))); if (Plugin.ChatLine.Value && (Object)(object)Chat.instance != (Object)null) { ((Terminal)Chat.instance).AddString("<color=#D0584A>" + Text.F("chat", deathRec.Headline(), Text.Num(deathRec.Total), Text.Sec(deathRec.Duration), deathRec.KillingBlow()) + "</color>"); } DeathUi.OnDeath(deathRec); } } catch (Exception e) { Plugin.LogOnce("OnDeath", e); } } } internal sealed class DeathRec { public DateTime When; public string Biome = ""; public int Streak = 1; public float MaxHp; public readonly List<AttackerRec> Attackers = new List<AttackerRec>(); public readonly List<HitRec> Hits = new List<HitRec>(); public readonly List<BuffRec> Buffs = new List<BuffRec>(); public readonly List<HitRec> Mits = new List<HitRec>(); public bool HasMit { get { if (Mits.Count > 0) { return true; } foreach (HitRec hit in Hits) { if (hit.HasMit) { return true; } } return false; } } public float MitTotal => Dmg.Sum(MitCats()); public int Stopped => Mits.Count; public float Total { get { float num = 0f; foreach (HitRec hit in Hits) { num += hit.Total; } return num; } } public float ShieldTotal { get { float num = 0f; foreach (HitRec hit in Hits) { num += hit.Shield; } return num; } } public float Duration { get { if (Hits.Count != 0) { return Mathf.Max(0.1f, 0f - Hits[0].T); } return 0f; } } public HitRec Last { get { if (Hits.Count != 0) { return Hits[Hits.Count - 1]; } return null; } } public AttackerRec Killer { get { HitRec last = Last; if (last != null && last.A >= 0 && last.A < Attackers.Count) { return Attackers[last.A]; } return null; } } public float[] MitCats() { float[] array = new float[7]; for (int i = 0; i < 2; i++) { foreach (HitRec item in (i == 0) ? Hits : Mits) { for (int j = 0; j < 9; j++) { array[Dmg.CatOf(j)] += item.M[j]; } } } return array; } public float[] MitSources() { float[] array = new float[5]; for (int i = 0; i < 2; i++) { foreach (HitRec item in (i == 0) ? Hits : Mits) { for (int j = 0; j < 5; j++) { array[j] += item.Ms[j]; } } } return array; } public float AttackerMit(int a) { float num = 0f; for (int i = 0; i < 2; i++) { foreach (HitRec item in (i == 0) ? Hits : Mits) { if (item.A == a) { num += item.MitTotal; } } } return num; } public float[] Cats() { float[] array = new float[7]; foreach (HitRec hit in Hits) { for (int i = 0; i < 9; i++) { array[Dmg.CatOf(i)] += hit.D[i]; } } return array; } public float[] Slots() { float[] array = new float[9]; foreach (HitRec hit in Hits) { for (int i = 0; i < 9; i++) { array[i] += hit.D[i]; } } return array; } public float AttackerTotal(int a) { float num = 0f; foreach (HitRec hit in Hits) { if (hit.A == a) { num += hit.Total; } } return num; } public float AttackerShield(int a) { float num = 0f; foreach (HitRec hit in Hits) { if (hit.A == a) { num += hit.Shield; } } return num; } public string TakenLine() { string text = Text.F("taken", Text.Num(Total), Text.Sec(Duration)); if (ShieldTotal >= 0.5f) { text = text + " · <color=#6FB7FF>" + Text.F("shieldTotal", Text.Num(ShieldTotal)) + "</color>"; } return text; } public string Headline() { string text = Text.BiomeIn(Biome); AttackerRec killer = Killer; if (killer == null) { return Text.F("killedNone", text); } if (killer.Kind == 2) { return Text.F("killedEnv", text, killer.Name); } return Text.F("killedBy", text, Text.Starred(killer.Name, killer.Stars)); } public string KillingBlow() { HitRec last = Last; if (last == null) { return "-"; } int num = Dmg.Top(last.D); string text = last.Attack + " " + Text.Num(last.Total) + " " + Text.G("type" + num); if (last.Shield >= 0.5f) { text = text + " (" + Text.F("shieldAte", Text.Num(last.Shield)) + ")"; } return text; } } internal static class DeathUi { private sealed class Zone { public RectTransform Rt; public string Tip; public Func<string> TipFn; public bool Ring; public int Seg = -1; } private const float FadeTime = 0.18f; private const float RefHeight = 1080f; private static GameObject _root; private static RectTransform _rootRt; private static Canvas _canvas; private static CanvasScaler _scaler; private static GameObject _vignette; private static GameObject _screen; private static GameObject _panel; private static GameObject _tip; private static RectTransform _tipRt; private static TextMeshProUGUI _tipText; private static TextMeshProUGUI _respawnText; private static readonly List<Zone> Zones = new List<Zone>(); private static readonly List<float> RingStart = new List<float>(); private static readonly List<string> RingTips = new List<string>(); private static readonly List<Image> RingSegs = new List<Image>(); private static readonly List<Color> RingCols = new List<Color>(); private static int _ringHot = -2; private static DeathRec _panelRec; private static CanvasGroup _panelFade; private static float _panelAt; private static CanvasGroup _screenFade; private static float _screenAt; private static bool _dead; private static bool _screenShown; private static float _deadAt; private static DeathRec _death; internal static bool Holding; internal static bool Released; private static readonly MethodInfo RequestRespawn = AccessTools.Method(typeof(Game), "RequestRespawn", (Type[])null, (Type[])null); private static readonly Color[] Palette = (Color[])(object)new Color[6] { new Color(0.86f, 0.69f, 0.38f), new Color(0.8f, 0.29f, 0.24f), new Color(0.38f, 0.68f, 0.63f), new Color(0.6f, 0.47f, 0.8f), new Color(0.91f, 0.54f, 0.26f), new Color(0.46f, 0.63f, 0.88f) }; private static readonly HashSet<int> DebuffHashes = MakeDebuffHashes(); private static readonly string[] DebuffWords = new string[14] { "debuff", "curse", "bleed", "poison", "burn", "frost", "chill", "freez", "shock", "weak", "stun", "blight", "slime", "harpoon" }; internal static bool IsDead => _dead; internal static bool PanelOpen => (Object)(object)_panel != (Object)null; internal static bool WantsCursor { get { if (((Object)(object)_screen != (Object)null || (Object)(object)_panel != (Object)null) && (Object)(object)_canvas != (Object)null) { return ((Behaviour)_canvas).enabled; } return false; } } internal static void OnDeath(DeathRec r) { _death = r; _dead = true; _deadAt = Time.time; _screenShown = false; Holding = false; Released = false; ClosePanel(); } internal static void Tick() { //IL_0099: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Game.instance == (Object)null || (Object)(object)ZNet.instance == (Object)null) { if (_dead || (Object)(object)_panel != (Object)null || (Object)(object)_screen != (Object)null) { Reset(); } return; } if ((Object)(object)_root != (Object)null) { _scaler.scaleFactor = Mathf.Max(0.3f, (float)Screen.height / 1080f * Plugin.PanelSize.Value); bool flag = false; try { flag = Menu.IsVisible(); } catch { } ((Behaviour)_canvas).enabled = !flag; } if (KeyDown(Plugin.ReopenKey.Value) && !Typing()) { if ((Object)(object)_panel != (Object)null) { ClosePanel(); } else { DeathRec deathRec = ((_dead && _death != null) ? _death : Store.Latest); if (deathRec != null) { OpenPanel(deathRec); } else if ((Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)2, Text.G("noData"), 0, (Sprite)null, false); } } } if (_dead) { float num = Time.time - _deadAt; if (!_screenShown && num >= Plugin.ScreenDelay.Value) { _screenShown = true; try { ShowDeathScreen(); if (Plugin.OpenOnDeath.Value && _death != null) { OpenPanel(_death); } } catch (Exception e) { Plugin.LogOnce("Death screen", e); } } if (_screenShown) { UpdateRespawnLabel(num); } if (Holding && (((Object)(object)_screen == (Object)null && num > Plugin.ScreenDelay.Value + 3f) || (Plugin.AutoRespawn.Value > 0f && num >= Plugin.AutoRespawn.Value))) { Respawn(); } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && !((Character)localPlayer).IsDead() && num > 1f) { EndDeath(); } } Fade(_panelFade, _panelAt, _panel); Fade(_screenFade, _screenAt, null); if ((Object)(object)_root != (Object)null && ((Behaviour)_canvas).enabled && ((Object)(object)_panel != (Object)null || (Object)(object)_screen != (Object)null)) { UpdateHover(); } else if ((Object)(object)_tip != (Object)null && _tip.activeSelf) { _tip.SetActive(false); } } private static void Fade(CanvasGroup g, float at, GameObject grow) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)g == (Object)null) && !(g.alpha >= 1f)) { float num = (g.alpha = Mathf.Clamp01((Time.unscaledTime - at) / 0.18f)); if ((Object)(object)grow != (Object)null) { float num3 = Mathf.Lerp(0.96f, 1f, 1f - (1f - num) * (1f - num)); grow.transform.localScale = new Vector3(num3, num3, 1f); } } } private static CanvasGroup AddFade(GameObject go) { CanvasGroup val = go.AddComponent<CanvasGroup>(); val.alpha = 0f; return val; } private static bool KeyDown(KeyboardShortcut k) { //IL_0002: 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_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_002f: Unknown result type (might be due to invalid IL or missing references) if ((int)((KeyboardShortcut)(ref k)).MainKey == 0 || !Input.GetKeyDown(((KeyboardShortcut)(ref k)).MainKey)) { return false; } foreach (KeyCode modifier in ((KeyboardShortcut)(ref k)).Modifiers) { if (!Input.GetKey(modifier)) { return false; } } return true; } private static bool Typing() { try { return ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) || Console.IsVisible() || TextInput.IsVisible(); } catch { return false; } } private static void UpdateRespawnLabel(float t) { if (!((Object)(object)_respawnText == (Object)null)) { float num = -1f; if (!Plugin.HoldRespawn.Value) { num = 10f - t; } else if (Plugin.AutoRespawn.Value > 0f) { num = Plugin.AutoRespawn.Value - t; } ((TMP_Text)_respawnText).text = ((num > 0f) ? Text.F("respawnIn", Mathf.CeilToInt(num)) : Text.G("respawn")); } } private static void Respawn() { if (!_dead) { return; } Released = true; Holding = false; HideDeathScreen(); ClosePanel(); try { if ((Object)(object)Game.instance != (Object)null && RequestRespawn != null) { RequestRespawn.Invoke(Game.instance, new object[2] { 0f, true }); } } catch (Exception e) { Plugin.LogOnce("Respawn", e); } } private static void EndDeath() { _dead = false; Holding = false; Released = false; HideDeathScreen(); ClosePanel(); } private static void Reset() { EndDeath(); if ((Object)(object)_tip != (Object)null) { _tip.SetActive(false); } } internal static void ClosePanel() { if ((Object)(object)_panel != (Object)null) { Object.Destroy((Object)(object)_panel); } _panel = null; _panelFade = null; RingSegs.Clear(); RingCols.Clear(); _ringHot = -2; } private static void ToggleSummary() { if ((Object)(object)_panel != (Object)null) { ClosePanel(); } else if (_death != null) { OpenPanel(_death); } } private static void HideDeathScreen() { if ((Object)(object)_screen != (Object)null) { Object.Destroy((Object)(object)_screen); } if ((Object)(object)_vignette != (Object)null) { Object.Destroy((Object)(object)_vignette); } _screen = null; _vignette = null; _respawnText = null; _screenFade = null; } private static void EnsureRoot() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_00f1: 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_00f7: 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_0100: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_root != (Object)null)) { _root = new GameObject("BuminDeathRecap UI", new Type[1] { typeof(RectTransform) }); Object.DontDestroyOnLoad((Object)(object)_root); _root.layer = 5; _canvas = _root.AddComponent<Canvas>(); _canvas.renderMode = (RenderMode)0; _canvas.sortingOrder = 1000; _scaler = _root.AddComponent<CanvasScaler>(); _scaler.uiScaleMode = (ScaleMode)0; _scaler.scaleFactor = Mathf.Max(0.3f, (float)Screen.height / 1080f * Plugin.PanelSize.Value); _root.AddComponent<GraphicRaycaster>(); _rootRt = (RectTransform)_root.transform; RectTransform val = Rt("Tooltip", (Transform)(object)_rootRt); Vector2 val2 = (val.anchorMax = new Vector2(0.5f, 0.5f)); Vector2 anchorMin = val2; val.anchorMin = anchorMin; val.pivot = new Vector2(0f, 1f); Image val4 = ((Component)val).gameObject.AddComponent<Image>(); val4.sprite = Theme.Part("Window"); val4.type = (Type)1; ((Graphic)val4).raycastTarget = false; _tipText = Txt((Transform)(object)val, "", "Body", 15f, Theme.Col("Text"), (TextAlignmentOptions)257, 10f, 8f, 300f, 20f); ((TMP_Text)_tipText).textWrappingMode = (TextWrappingModes)1; ((TMP_Text)_tipText).overflowMode = (TextOverflowModes)0; _tipRt = val; _tip = ((Component)val).gameObject; _tip.SetActive(false); } } private static RectTransform Rt(string name, Transform parent) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.layer = 5; RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent(parent, false); return val2; } private static RectTransform At(RectTransform rt, float x, float y, float w, float h) { //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) //IL_0011: 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_0018: 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_002b: 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_0047: Unknown result type (might be due to invalid IL or missing references) Vector2 val = (rt.anchorMax = new Vector2(0f, 1f)); Vector2 anchorMin = val; rt.anchorMin = anchorMin; rt.pivot = new Vector2(0f, 1f); rt.anchoredPosition = new Vector2(x, 0f - y); rt.sizeDelta = new Vector2(w, h); return rt; } private static RectTransform Stretch(RectTransform rt) { //IL_0001: 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_0021: 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_0037: Unknown result type (might be due to invalid IL or missing references) rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; rt.pivot = new Vector2(0.5f, 0.5f); rt.offsetMin = Vector2.zero; rt.offsetMax = Vector2.zero; return rt; } private static Image Img(Transform parent, string name, Sprite s, Color c, float x, float y, float w, float h) { //IL_0029: 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) RectTransform val = At(Rt(name, parent), x, y, w, h); Image val2 = ((Component)val).gameObject.AddComponent<Image>(); val2.sprite = s; ((Graphic)val2).color = c; val2.type = (Type)(((Object)(object)s != (Object)null && s.border != Vector4.zero) ? 1 : 0); ((Graphic)val2).raycastTarget = false; return val2; } private static Image Pic(Transform parent, Sprite s, Color c, float x, float y, float w, float h) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s == (Object)null) { return null; } Image val = Img(parent, "Icon", s, c, x, y, w, h); val.type = (Type)0; val.preserveAspect = true; return val; } private static TextMeshProUGUI Txt(Transform parent, string s, string font, float size, Color c, TextAlignmentOptions al, float x, float y, float w, float h) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) RectTransform val = At(Rt("Text", parent), x, y, w, h); TextMeshProUGUI val2 = ((Component)val).gameObject.AddComponent<TextMeshProUGUI>(); TMP_FontAsset val3 = Theme.Font(font); if ((Object)(object)val3 != (Object)null) { ((TMP_Text)val2).font = val3; } ((TMP_Text)val2).fontSize = size; ((Graphic)val2).color = c; ((TMP_Text)val2).alignment = al; ((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)val2).overflowMode = (TextOverflowModes)1; ((Graphic)val2).raycastTarget = false; ((TMP_Text)val2).richText = true; ((TMP_Text)val2).text = s; return val2; } private static TextMeshProUGUI Btn(Transform parent, float x, float y, float w, float h, bool primary, string label, string glyph, UnityAction click, string tip, Func<string> tipFn = null) { //IL_001b: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00b3: 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_01ce: 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) //IL_0199: 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) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) Image val = Img(parent, "Button", Theme.Part(primary ? "Primary" : "Button"), Color.white, x, y, w, h); ((Graphic)val).raycastTarget = true; Button val2 = ((Component)val).gameObject.AddComponent<Button>(); ((Selectable)val2).targetGraphic = (Graphic)(object)val; ((Selectable)val2).transition = (Transition)2; SpriteState spriteState = default(SpriteState); Sprite val3 = (((SpriteState)(ref spriteState)).highlightedSprite = Theme.Part(primary ? "PrimaryHover" : "ButtonHover")); Sprite pressedSprite = val3; ((SpriteState)(ref spriteState)).pressedSprite = pressedSprite; ((Selectable)val2).spriteState = spriteState; Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)val2).navigation = navigation; ((UnityEvent)val2.onClick).AddListener(click); Color c = (primary ? Theme.Col("OnPrimary") : Theme.Col("Text")); Sprite val5 = Theme.Icon(glyph); TextMeshProUGUI result = null; if (string.IsNullOrEmpty(label)) { if ((Object)(object)val5 != (Object)null) { Pic(((Component)val).transform, val5, c, w * 0.22f, h * 0.22f, w * 0.56f, h * 0.56f); } else { result = Txt(((Component)val).transform, "×", "Strong", h * 0.7f, c, (TextAlignmentOptions)514, 0f, 0f, w, h); } } else if ((Object)(object)val5 != (Object)null) { Pic(((Component)val).transform, val5, c, 14f, (h - 22f) * 0.5f, 22f, 22f); result = Txt(((Component)val).transform, label, "Strong", 18f, c, (TextAlignmentOptions)514, 40f, 0f, w - 50f, h); } else { result = Txt(((Component)val).transform, label, "Strong", 18f, c, (TextAlignmentOptions)514, 6f, 0f, w - 12f, h); } if (tipFn != null) { AddZone(((Graphic)val).rectTransform, null, ring: false); Zones[Zones.Count - 1].TipFn = tipFn; } else if (!string.IsNullOrEmpty(tip)) { AddZone(((Graphic)val).rectTransform, tip, ring: false); } return result; } private static RectTransform Section(Transform p, string title, float x, float y, float w, float h) { //IL_0010: 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_0073: Unknown result type (might be due to invalid IL or missing references) Image val = Img(p, "Section", Theme.Part("Inner"), Color.white, x, y, w, h); Txt(((Component)val).transform, title, "Strong", 17f, Theme.Col("Accent"), (TextAlignmentOptions)4097, 16f, 8f, w - 32f, 24f); Img(((Component)val).transform, "Line", Theme.Part("Separator"), Color.white, 12f, 37f, w - 24f, 1.5f); return ((Graphic)val).rectTransform; } private static void AddZone(RectTransform rt, string tip, bool ring) { Zone zone = new Zone(); zone.Rt = rt; zone.Tip = tip; zone.Ring = ring; Zones.Add(zone); } private static string Hex(Color c) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return "#" + ColorUtility.ToHtmlStringRGB(c); } private static Color AttackerColor(DeathRec r, int a) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (r.Attackers[a].Kind == 2) { return new Color(0.58f, 0.56f, 0.54f); } return Palette[a % Palette.Length]; } private static Sprite ItemIcon(string prefab) { if (string.IsNullOrEmpty(prefab) || (Object)(object)ObjectDB.instance == (Object)null) { return null; } try { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(prefab); ItemDrop val = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null); return ((Object)(object)val != (Object)null) ? val.m_itemData.GetIcon() : null; } catch { return null; } } private static Sprite EffectIcon(int hash) { if ((Object)(object)ObjectDB.instance == (Object)null) { return null; } try { StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect(hash); return ((Object)(object)statusEffect != (Object)null) ? statusEffect.m_icon : null; } catch { return null; } } private static void ShowDeathScreen() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_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_008d: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00b3: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Expected O, but got Unknown //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Expected O, but got Unknown EnsureRoot(); HideDeathScreen(); Color c = Theme.Col("Text"); Color c2 = Theme.Col("Bad"); if (Plugin.RedEdges.Value) { RectTransform val = Stretch(Rt("RedEdges", (Transform)(object)_rootRt)); Image val2 = ((Component)val).gameObject.AddComponent<Image>(); val2.sprite = Theme.Vignette; ((Graphic)val2).raycastTarget = false; ((Transform)val).SetAsFirstSibling(); _vignette = ((Component)val).gameObject; } RectTransform val3 = Rt("DeathScreen", (Transform)(object)_rootRt); Vector2 val4 = (val3.anchorMax = new Vector2(0.5f, 0f)); Vector2 anchorMin = val4; val3.anchorMin = anchorMin; val3.pivot = new Vector2(0.5f, 0f); val3.anchoredPosition = new Vector2(0f, 56f); val3.sizeDelta = new Vector2(660f, 158f); Image val6 = ((Component)val3).gameObject.AddComponent<Image>(); val6.sprite = Theme.Part("Window"); val6.type = (Type)1; ((Graphic)val6).raycastTarget = true; _screen = ((Component)val3).gameObject; Txt((Transform)(object)val3, Text.G("youDied"), "Title", 44f, c2, (TextAlignmentOptions)514, 20f, 8f, 620f, 54f); Txt((Transform)(object)val3, (_death != null) ? _death.Headline() : "", "Body", 18f, c, (TextAlignmentOptions)514, 20f, 62f, 620f, 26f); float num = 99f; Btn((Transform)(object)val3, num, 100f, 160f, 44f, primary: false, Text.Tr ? "ÖZET" : "SUMMARY", "chart-bar", new UnityAction(ToggleSummary), null, () => Text.G(((Object)(object)_panel != (Object)null) ? "hideSummary" : "showSummary")); _respawnText = Btn((Transform)(object)val3, num + 160f + 12f, 100f, 290f, 44f, primary: true, Text.G("respawn"), null, new UnityAction(Respawn), null); _screenFade = AddFade(_screen); _screenAt = Time.unscaledTime; _tip.transform.SetAsLastSibling(); } private static void OpenPanel(DeathRec r) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_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_0025: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) EnsureRoot(); ClosePanel(); Color c = Theme.Col("Text"); Color c2 = Theme.Col("Accent"); Color c3 = Theme.Col("Bad"); Color c4 = Theme.Col("Warn"); RectTransform val = Rt("DeathSummary", (Transform)(object)_rootRt); Vector2 val2 = (val.anchorMax = new Vector2(0.5f, 0.5f)); Vector2 anchorMin = val2; val.anchorMin = anchorMin; val.pivot = new Vector2(0.5f, 0.5f); val.sizeDelta = new Vector2(960f, 660f); val.anchoredPosition = new Vector2(0f, ((Object)(object)_screen != (Object)null) ? 80f : 0f); Image val4 = ((Component)val).gameObject.AddComponent<Image>(); val4.sprite = Theme.Part("Window"); val4.type = (Type)1; ((Graphic)val4).raycastTarget = true; _panel = ((Component)val).gameObject; _panelRec = r; _panelFade = AddFade(_panel); _panelAt = Time.unscaledTime; Txt((Transform)(object)val, Text.G("title"), "Title", 30f, c2, (TextAlignmentOptions)514, 70f, 12f, 820f, 40f); Btn((Transform)(object)val, 908f, 12f, 38f, 38f, primary: false, "", "x", new UnityAction(ClosePanel), Text.G("close")); Img((Transform)(object)val, "Line", Theme.Part("Separator"), Color.white, 24f, 58f, 912f, 1.5f); Txt((Transform)(object)val, r.TakenLine(), "Strong", 20f, c, (TextAlignmentOptions)514, 24f, 66f, 912f, 26f); string text = r.Headline(); if (Plugin.Streak.Value && r.Streak > 1) { string text2 = text; text = text2 + " <color=" + Hex(c4) + ">· " + Text.F("streak", r.Streak) + "</color>"; } Txt((Transform)(object)val, text, "Body", 18f, c3, (TextAlignmentOptions)514, 24f, 94f, 912f, 26f); float num = 508f; DamageBox(val, r, 20f, 132f, 450f, num); float num2 = 486f; float w = 960f - num2 - 20f; AttackerBox(val, r, num2, 132f, w, num - 100f); BuffBox(val, r, num2, 132f + num - 90f, w, 90f); _tip.transform.SetAsLastSibling(); } private static void ToggleAttacks() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) Plugin.ShowAttacks.Value = !Plugin.ShowAttacks.Value; DeathRec panelRec = _panelRec; if (panelRec != null && (Object)(object)_panel != (Object)null) { OpenPanel(panelRec); if ((Object)(object)_panelFade != (Object)null) { _panelFade.alpha = 1f; _panel.transform.localScale = Vector3.one; } } } private static void DamageBox(RectTransform p, DeathRec r, float x, float y, float w, float h) { //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: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: 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_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) RectTransform parent = Section((Transform)(object)p, Text.G("damageTaken"), x, y, w, h); Color val = Theme.Col("Text"); Color val2 = Theme.Col("Muted"); float[] array = r.Cats(); float num = Mathf.Max(1f, r.Total); bool hasMit = r.HasMit; float[] array2 = r.MitCats(); float num2 = num; if (hasMit) { num2 = 1f; for (int i = 0; i < 7; i++) { num2 = Mathf.Max(num2, array[i] + array2[i]); } float mitTotal = r.MitTotal; if (mitTotal >= 0.5f) { string text = Text.G("mitigated") + " " + Text.Num(mitTotal) + " <color=" + Hex(val2) + ">" + Text.Pct(mitTotal / (mitTotal + r.Total)) + "</color>"; TextMeshProUGUI val3 = Txt((Transform)(object)parent, text, "Body", 15f, val, (TextAlignmentOptions)4100, w * 0.42f, 9f, w * 0.58f - 16f, 22f); float num3 = Mathf.Min(((TMP_Text)val3).GetPreferredValues(text).x, w * 0.58f - 16f); float num4 = w - 16f - num3 - 22f; Img((Transform)(object)parent, "MitSwatch", Theme.Round, new Color(val2.r, val2.g, val2.b, 0.2f), num4, 15f, 16f, 10f); Image val4 = Img((Transform)(object)parent, "MitSwatchHatch", Theme.Hatch, new Color(val2.r, val2.g, val2.b, 0.8f), num4, 15f, 16f, 10f); val4.type = (Type)2; RectTransform rt = At(Rt("MitHover", (Transform)(object)parent), num4 - 4f, 6f, w - num4 - 12f, 28f); AddZone(rt, MitTip(r), ring: false); } } float num5 = (h - 46f) / 7f; float num6 = w - 24f; for (int j = 0; j < 7; j++) { bool flag = array[j] >= 0.5f; bool flag2 = hasMit && array2[j] >= 0.5f; Color val5 = Dmg.CatColor[j]; Color c = (Color)((flag || flag2) ? val5 : new Color(val5.r, val5.g, val5.b, 0.35f)); RectTransform val6 = At(Rt("Row", (Transform)(object)parent), 12f, 44f + (float)j * num5, num6, num5 - 4f); Image val7 = Img((Transform)(object)val6, "IconBox", Theme.Part("Card"), Color.white, 0f, 2f, 48f, 48f); Pic(((Component)val7).transform, Theme.Icon(Dmg.CatGlyph[j]), c, 9f, 9f, 30f, 30f); Txt((Transform)(object)val6, Text.Num(array[j]) + " " + Text.G("cat" + j), "Strong", 18f, flag ? val : val2, (TextAlignmentOptions)4097, 60f, 2f, num6 - 140f, 24f); if (flag) { Txt((Transform)(object)val6, Text.Pct(array[j] / num), "Body", 15f, val2, (TextAlignmentOptions)4100, num6 - 80f, 3f, 76f, 22f); } float num7 = num6 - 64f; Img((Transform)(object)val6, "Track", Theme.Part("Track"), Color.white, 60f, 32f, num7, 12f); float num8 = num7 - 2f; float num9 = 0f; if (flag) { num9 = Mathf.Min(num8, Mathf.Max(6f, num8 * array[j] / num2)); Img((Transform)(object)val6, "Fill", Theme.Round, val5, 61f, 33f, num9, 10f); } if (flag2) { float num10 = Mathf.Min(num8 - num9, Mathf.Max(4f, num8 * array2[j] / num2)); if (num10 > 1f) { Img((Transform)(object)val6, "MitigatedBack", Theme.Round, new Color(val5.r, val5.g, val5.b, 0.16f), 61f + num9, 33f, num10, 10f); Image val8 = Img((Transform)(object)val6, "Mitigated", Theme.Hatch, new Color(val5.r, val5.g, val5.b, 0.75f), 61f + num9, 33f, num10, 10f); val8.type = (Type)2; } } AddZone(val6, CategoryTip(r, j), ring: false); } } private static string MitTip(DeathRec r) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); float mitTotal = r.MitTotal; stringBuilder.Append("<color=").Append(Hex(Theme.Col("Accent"))).Append('>') .Append(Text.G("mitTitle")) .Append("</color>\n") .Append(Text.G("mitigated")) .Append(": ") .Append(Text.Num(mitTotal)) .Append(" (") .Append(Text.Pct(mitTotal / Mathf.Max(1f, mitTotal + r.Total))) .Append(')'); float[] array = r.MitSources(); for (int i = 0; i < 5; i++) { if (array[i] >= 0.5f) { stringBuilder.Append("\n<color=").Append("#B8B2A7").Append('>') .Append(Text.G("mitSrc" + i)) .Append(": ") .Append(Text.Num(array[i])) .Append("</color>"); } } if (r.Stopped > 0) { stringBuilder.Append('\n').Append(Text.G("mitStopped")).Append(": ") .Append(r.Stopped); } return stringBuilder.ToString(); } private static string CategoryTip(DeathRec r, int c) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("<color=").Append(Hex(Dmg.CatColor[c])).Append('>') .Append(Text.G("cat" + c)) .Append("</color>"); float num = r.Cats()[c]; stringBuilder.Append('\n').Append(Text.G("takenRow")).Append(": ") .Append(Text.Num(num)) .Append(" (") .Append(Text.Pct(num / Mathf.Max(1f, r.Total))) .Append(')'); if (r.HasMit) { float num2 = r.MitCats()[c]; stringBuilder.Append("\n<color=").Append("#B8B2A7").Append('>') .Append(Text.G("mitigated")) .Append(": ") .Append(Text.Num(num2)) .Append(" (") .Append(Text.Pct((num + num2 >= 0.5f) ? (num2 / (num + num2)) : 0f)) .Append(")</color>"); } else { stringBuilder.Append("\n<color=").Append(Hex(Theme.Col("Muted"))).Append('>') .Append(Text.G("mitNone")) .Append("</color>"); } float[] array = r.Slots(); for (int i = 0; i < 9; i++) { if (Dmg.CatOf(i) == c && !(array[i] < 0.5f)) { stringBuilder.Append('\n').Append(Text.G("type" + i)).Append(": ") .Append(Text.Num(array[i])); } } for (int j = 0; j < r.Attackers.Count; j++) { float num3 = 0f; foreach (HitRec hit in r.Hits) { if (hit.A != j) { continue; } for (int k = 0; k < 9; k++) { if (Dmg.CatOf(k) == c) { num3 += hit.D[k]; } } } if (!(num3 < 0.5f)) { stringBuilder.Append("\n<color=").Append(Hex(Theme.Col("Muted"))).Append(">") .Append(Text.Starred(r.Attackers[j].Name, r.Attackers[j].Stars)) .Append(": ") .Append(Text.Num(num3)) .Append("</color>"); } } return stringBuilder.ToString(); } private static void AttackerBox(RectTransform p, DeathRec r, float x, float y, float w, float h) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_05c7: Unknown result type (might be due to invalid IL or missing references) //IL_0756: Unknown result type (might be due to invalid IL or missing references) //IL_07be: Unknown result type (might be due to invalid IL or missing references) //IL_0793: Unknown result type (might be due to invalid IL or missing references) //IL_0ca8: Unknown result type (might be due to invalid IL or missing references) //IL_085a: Unknown result type (might be due to invalid IL or missing references) //IL_0857: Unknown result type (might be due to invalid IL or missing references) //IL_0885: Unknown result type (might be due to invalid IL or missing references) //IL_099e: Unknown result type (might be due to invalid IL or missing references) //IL_08b1: Unknown result type (might be due to invalid IL or missing references) //IL_092e: Unknown result type (might be due to invalid IL or missing references) //IL_0a0e: Unknown result type (might be due to invalid IL or missing references) //IL_0a41: Unknown result type (might be due to invalid IL or missing references) //IL_0a66: Unknown result type (might be due to invalid IL or missing references) //IL_0aea: Unknown result type (might be due to invalid IL or missing references) //IL_0b02: Unknown result type (might be due to invalid IL or missing references) //IL_0ab7: Unknown result type (might be due to invalid IL or missing references) //IL_0b20: Unknown result type (might be due to invalid IL or missing references) //IL_0b7f: Unknown result type (might be due to invalid IL or missing references) //IL_0b7c: Unknown result type (might be due to invalid IL or missing references) RectTransform parent = Section((Transform)(object)p, Text.G("attackers"), x, y, w, h); Color val = Theme.Col("Text"); Color c = Theme.Col("Muted"); Color val2 = Theme.Col("Accent"); Color val3 = Theme.Col("Bad"); float num = Mathf.Max(1f, r.Total); string text = Hex(c); bool value = Plugin.ShowAttacks.Value; string text2 = (value ? "eye" : "eye-slash"); if ((Object)(object)Theme.Icon(text2) == (Object)null) { text2 = (((Object)(object)Theme.Icon("eye") != (Object)null) ? "eye" : null); } Btn((Transform)(object)parent, w - 44f, 5f, 30f, 30f, primary: false, (text2 != null) ? "" : (value ? "-" : "+"), text2, new UnityAction(ToggleAttacks), Text.G(value ? "hideAttacks" : "showAttacks")); float num2 = (value ? 56f : 32f); RectTransform val4 = At(Rt("Ring", (Transform)(object)parent), 18f, 50f, 126f, 126f); Image val5 = ((Component)Stretch(Rt("Back", (Transform)(object)val4))).gameObject.AddComponent<Image>(); val5.sprite = Theme.Ring; ((Graphic)val5).color = new Color(0f, 0f, 0f, 0.45f); ((Graphic)val5).raycastTarget = false; RingStart.Clear(); RingTips.Clear(); float num3 = 0f; for (int i = 0; i < r.Attackers.Count; i++) { float num4 = r.AttackerTotal(i) / num; RectTransform val6 = Stretch(Rt("Segment", (Transform)(object)val4)); Image val7 = ((Component)val6).gameObject.AddComponent<Image>(); val7.sprite = Theme.Ring; ((Graphic)val7).color = AttackerColor(r, i); val7.type = (Type)3; val7.fillMethod = (FillMethod)4; val7.fillOrigin = 2; val7.fillClockwise = true; val7.fillAmount = Mathf.Max(0f, num4 - ((r.Attackers.Count > 1) ? 0.006f : 0f)); ((Graphic)val7).raycastTarget = false; ((Transform)val6).localEulerAngles = new Vector3(0f, 0f, (0f - num3) * 360f); RingSegs.Add(val7); RingCols.Add(((Graphic)val7).color); RingStart.Add(num3); RingTips.Add(AttackerTip(r, i, num4)); num3 += num4; } Txt((Transform)(object)val4, Text.Num(r.Total), "Title", 22f, val, (TextAlignmentOptions)514, 0f, 0f, 126f, 126f); AddZone(val4, null, ring: true); float num5 = 0f; foreach (HitRec hit in r.Hits) { if (hit.Total > num5) { num5 = hit.Total; } } List<string> list = new List<string>(); list.Add("<color=" + text + ">" + Text.G("hits") + ":</color> " + r.Hits.Count); list.Add("<color=" + text + ">" + Text.G("biggest") + ":</color> " + Text.Num(num5)); list.Add("<color=" + text + ">" + Text.G("time") + ":</color> " + Text.Sec(r.Duration) + " " + Text.G("sec")); list.Add("<color=" + text + ">" + Text.G("attackerCount") + ":</color> " + r.Attackers.Count); List<string> list2 = list; if (r.ShieldTotal >= 0.5f) { list2.Add("<color=" + text + ">" + Text.G("shieldLabel") + ":</color> <color=#6FB7FF>" + Text.Num(r.ShieldTotal) + "</color>"); } float num6 = ((list2.Count > 4) ? 25f : 29f); for (int j = 0; j < list2.Count; j++) { Txt((Transform)(object)parent, list2[j], "Body", 17f, val, (TextAlignmentOptions)4097, 164f, 56f + (float)j * num6, w - 178f, 26f); } List<int> list3 = new List<int>(); for (int k = 0; k < r.Attackers.Count; k++) { list3.Add(k); } list3.Sort((int a1, int a2) => r.AttackerTotal(a2).CompareTo(r.AttackerTotal(a1))); int num7 = ((r.Last != null) ? r.Last.A : (-1)); int num8 = Mathf.Max(1, (int)((h - 190f - 6f) / num2)); int num9 = ((list3.Count > num8) ? (num8 - 1) : list3.Count); for (int num10 = 0; num10 < num9; num10++) { int num11 = list3[num10]; AttackerRec attackerRec = r.Attackers[num11]; float num12 = 190f + (float)num10 * num2; float num13 = r.AttackerTotal(num11); RectTransform rt = At(Rt("Hover", (Transform)(object)parent), 12f, num12, w - 24f, 26f); AddZone(rt, AttackerTip(r, num11, num13 / num), ring: false); Zones[Zones.Count - 1].Seg = num11; Img((Transform)(object)parent, "Dot", Theme.Round, AttackerColor(r, num11), 16f, num12 + 8f, 10f, 10f); Sprite val8 = ItemIcon(attackerRec.IconItem); if ((Object)(object)val8 != (Object)null) { Pic((Transform)(object)parent, val8, Color.white, 32f, num12, 26f, 26f); } else { Pic((Transform)(object)parent, Theme.Icon(attackerRec.Glyph), val, 34f, num12 + 2f, 22f, 22f); } Sprite val9 = Theme.Icon("star"); string text3 = (((Object)(object)val9 == (Object)null) ? Text.Starred(attackerRec.Name, attackerRec.Stars) : attackerRec.Name); if (attackerRec.Count > 1) { text3 = text3 + " ×" + attackerRec.Count; } float num14 = w - 64f - 150f; TextMeshProUGUI val10 = Txt((Transform)(object)parent, text3, "Strong", 17f, (num11 == num7) ? val3 : val, (TextAlignmentOptions)4097, 64f, num12 + 1f, num14, 24f); float num15 = 64f + Mathf.Min(((TMP_Text)val10).GetPreferredValues(text3).x, num14) + 5f; if ((Object)(object)val9 != (Object)null) { for (int num16 = 0; num16 < Mathf.Min(attackerRec.Stars, 5); num16++) { Pic((Transform)(object)parent, val9, val2, num15 + (float)num16 * 14f, num12 + 6f, 13f, 13f); } } if (num11 == num7) { float x2 = num15 + (((Object)(object)val9 != (Object)null) ? ((float)Mathf.Min(attackerRec.Stars, 5) * 14f + 4f) : 0f); Pic((Transform)(object)parent, Theme.Icon("skull"), val3, x2, num12 + 4f, 17f, 17f); } Txt((Transform)(object)parent, Text.Num(num13) + " <color=" + text + ">" + Text.Pct(num13 / num) + "</color>", "Strong", 17f, val, (TextAlignmentOptions)4100, w - 164f, num12 + 1f, 150f, 24f); if (!value) { continue; } List<AttackGroup> list4 = AttackGroup.Of(r, num11); float num17 = 64f; for (int num18 = 0; num18 < list4.Count; num18++) { AttackGroup attackGroup = list4[num18]; string text4 = attackGroup.Chip(); Image val11 = Img((Transform)(object)parent, "Chip", Theme.Part("Chip"), Color.white, num17, num12 + 29f, 100f, 23f); TextMeshProUGUI val12 = Txt(((Component)val11).transform, text4, "Body", 14f, val, (TextAlignmentOptions)514, 0f, 0f, 100f, 23f); float num19 = ((TMP_Text)val12).GetPreferredValues(text4).x + 20f; if (num17 + num19 > w - 14f) { Object.Destroy((Object)(object)((Component)val11).gameObject); Txt((Transform)(object)parent, "+" + (list4.Count - num18), "Body", 14f, c, (TextAlignmentOptions)4097, num17, num12 + 29f, 40f, 23f); break; } ((Graphic)val11).rectTransform.sizeDelta = new Vector2(num19, 23f); ((TMP_Text)val12).rectTransform.sizeDelta = new Vector2(num19, 23f); if (attackGroup.Killing) { Image val13 = Img((Transform)(object)parent, "KillingBlow", Theme.Round, val3, num17 - 2f, num12 + 27f, num19 + 4f, 27f); ((Component)val13).transform.SetSiblingIndex(((Component)val11).transform.GetSiblingIndex()); } string tip = "<color=" + Hex(attackGroup.Killing ? val3 : val2) + ">" + attackGroup.Attack + (attackGroup.Killing ? (" — " + Text.G("killingBlow")) : "") + "</color>\n" + Text.F("hitsN", attackGroup.Count) + " · " + Text.Num(attackGroup.Total) + "\n" + attackGroup.Breakdown(); AddZone(((Graphic)val11).rectTransform, tip, ring: false); num17 += num19 + 6f; } } if (num9 < list3.Count) { Txt((Transform)(object)parent, Text.F("more", list3.Count - num9), "Body", 15f, c, (TextAlignmentOptions)4097, 64f, 190f + (float)num9 * num2 + 4f, w - 80f, 24f); } } private static string AttackerTip(DeathRec r, int a, float share) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) AttackerRec attackerRec = r.Attackers[a]; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("<color=").Append(Hex(AttackerColor(r, a))).Append('>') .Append(Text.Starred(attackerRec.Name, attackerRec.Stars)); if (attackerRec.Count > 1) { stringBuilder.Append(" ×").Append(attackerRec.Count); } stringBuilder.Append("</color>\n").Append(Text.Num(r.AttackerTotal(a))).Append(" (") .Append(Text.Pct(share)) .Append(')'); float[] array = new float[9]; int num = 0; foreach (HitRec hit in r.Hits) { if (hit.A == a) { num++; for (int i = 0; i < 9; i++) { array[i] += hit.D[i]; } } } stringBuilder.Append(" · ").Append(Text.F("hitsN", num)); float num2 = r.AttackerShield(a); if (num2 >= 0.5f) { stringBuilder.Append("\n<color=").Append("#6FB7FF").Append('>') .Append(Text.F("shieldAte", Text.Num(num2))) .Append("</color>"); } float num3 = r.AttackerMit(a); if (num3 >= 0.5f) { stringBuilder.Append("\n<color=").Append("#B8B2A7").Append('>') .Append(Text.F("mitShort", Text.Num(num3))) .Append("</color>"); } for (int j = 0; j < 9; j++) { if (array[j] >= 0.5f) { stringBuilder.Append('\n').Append(Text.G("type" + j)).Append(": ") .Append(Text.Num(array[j])); } } return stringBuilder.ToString(); } private static void BuffBox(RectTransform p, DeathRec r, float x, float y, float w, float h) { List<BuffRec> list = new List<BuffRec>(); List<BuffRec> list2 = new List<BuffRec>(); foreach (BuffRec buff in r.Buffs) { (IsDebuff(buff) ? list : list2).Add(buff); } float num = (w - 8f) * 0.5f; EffectBox(p, Text.G("debuffs"), Text.G("noDebuffs"), list, debuff: true, x, y, num, h); EffectBox(p, Text.G("goodBuffs"), Text.G("noGoodBuffs"), list2, debuff: false, x + num + 8f, y, num, h); } private static void EffectBox(RectTransform p, string title, string none, List<BuffRec> list, bool debuff, float x, float y, float w, float h) { //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_0053: 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_006f: 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_00e2: 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_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) RectTransform parent = Section((Transform)(object)p, title, x, y, w, h); Color c = Theme.Col("Muted"); if (list.Count == 0) { Txt((Transform)(object)parent, none, "Body", 15f, c, (TextAlignmentOptions)4097, 16f, 48f, w - 32f, 26f); return; } string text = Hex(c); string text2 = Hex(debuff ? Theme.Col("Bad") : Theme.Col("Accent")); int num = Mathf.Max(1, (int)((w - 24f + 6f) / 44f)); int num2 = ((list.Count > num) ? (num - 1) : list.Count); for (int i = 0; i < num2; i++) { float x2 = 14f + (float)i * 44f; BuffRec buffRec = list[i]; Image val = Img((Transform)(object)parent, "Buff", Theme.Part("Card"), Color.white, x2, 44f, 38f, 38f); if (debuff) { Img(((Component)val).transform, "DebuffMark", Theme.Round, new Color(0.85f, 0.25f, 0.2f, 0.85f), 5f, 33f, 28f, 3f); } Sprite val2 = EffectIcon(buffRec.Hash); if ((Object)(object)val2 != (Object)null) { Pic(((Component)val).transform, val2, Color.white, 4f, 4f, 30f, 30f); } else { Pic(((Component)val).transform, Theme.Icon(debuff ? "warning" : "sparkle"), debuff ? Theme.Col("Bad") : Theme.Col("Accent"), 8f, 8f, 22f, 22f); } string text3 = "<color=" + text2 + ">" + buffRec.Name + "</color>"; if (!string.IsNullOrEmpty(buffRec.Tip)) { string text4 = text3; text3 = text4 + "\n<color=" + text + ">" + buffRec.Tip + "</color>"; } AddZone(((Graphic)val).rectTransform, text3, ring: false); } if (num2 >= list.Count) { return; } float x3 = 14f + (float)num2 * 44f; Image val3 = Img((Transform)(object)parent, "More", Theme.Part("Card"), Color.white, x3, 44f, 38f, 38f); Txt(((Component)val3).transform, "+" + (list.Count - num2), "Strong", 16f, Theme.Col("Text"), (TextAlignmentOptions)514, 0f, 0f, 38f, 38f); StringBuilder stringBuilder = new StringBuilder(); for (int j = num2; j < list.Count; j++) { if (stringBuilder.Length > 0) { stringBuilder.Append('\n'); } stringBuilder.Append("<color=").Append(text2).Append('>') .Append(list[j].Name) .Append("</color>"); } AddZone(((Graphic)val3).rectTransform, stringBuilder.ToString(), ring: false); } private static HashSet<int> MakeDebuffHashes() { HashSet<int> hashSet = new HashSet<int>(); string[] array = new string[15] { "Encumbered", "Wet", "Cold", "Freezing", "Burning", "Frost", "Lightning", "Poison", "Smoked", "Spirit", "Tared", "Harpooned", "Puke", "Immobilized", "Slimed" }; string[] array2 = array; foreach (string text in array2) { hashSet.Add(StringExtensionMethods.GetStableHashCode(text)); } return hashSet; } private static bool IsDebuff(BuffRec b) { if (DebuffHashes.Contains(b.Hash)) { return true; } try { StatusEffect val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetStatusEffect(b.Hash) : null); if ((Object)(object)val != (Object)null) { switch (((object)val).GetType().Name) { case "SE_Burning": case "SE_Poison": case "SE_Frost": case "SE_Harpooned": case "SE_Puke": case "SE_Smoke": case "SE_Wet": return true; default: { string text = ((Object)val).name.ToLowerInvariant(); string[] debuffWords = DebuffWords; string[] array = debuffWords; foreach (string value in array) { if (text.Contains(value)) { return !text.Contains("resist") && !text.Contains("immun"); } } break; } } } } catch { } return false; } private static void UpdateHover() { //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_000a: 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_0067: 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) Vector2 val = Vector2.op_Implicit(Input.mousePosition); string text = null; int seg = -1; for (int num = Zones.Count - 1; num >= 0; num--) { Zone zone = Zones[num]; if ((Object)(object)zone.Rt == (Object)null) { Zones.RemoveAt(num); } else if (((Component)zone.Rt).gameObject.activeInHierarchy && RectTransformUtility.RectangleContainsScreenPoint(zone.Rt, val, (Camera)null)) { if (zone.Ring) { int num2 = RingIndex(zone.Rt, val); if (num2 >= 0 && num2 < RingTips.Count) { text = RingTips[num2]; seg = num2; } } else { text = ((zone.TipFn != null) ? zone.TipFn() : zone.Tip); seg = zone.Seg; } if (text != null) { break; } } } HighlightRing(seg); ShowTip(text, val); } private static void HighlightRing(int seg) { //IL_0034: 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_0085: 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_00b0: Unknown result type (might be due to invalid IL or missing references) if (seg == _ringHot) { return; } _ringHot = seg; for (int i = 0; i < RingSegs.Count; i++) { Image val = RingSegs[i]; if (!((Object)(object)val == (Object)null)) { Color val2 = RingCols[i]; bool flag = seg < 0 || i == seg; ((Graphic)val).color = (Color)(flag ? val2 : new Color(val2.r * 0.55f, val2.g * 0.55f, val2.b * 0.55f, val2.a * 0.6f)); float num = ((seg >= 0 && i == seg) ? 1.06f : 1f); ((Transform)((Graphic)val).rectTransform).localScale = new Vector3(num, num, 1f); } } } private static int RingIndex(RectTransform rt, Vector2 mouse) { //IL_0001: 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_0015: 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_0023: 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) Vector2 val = default(Vector2); if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(rt, mouse, (Camera)null, ref val)) { return -1; } Vector2 val2 = val; Rect rect = rt.rect; Vector2 val3 = val2 - ((Rect)(ref rect)).center; float magnitude = ((Vector2)(ref val3)).magnitude; Rect rect2 = rt.rect; float num = magnitude / (((Rect)(ref rect2)).width * 0.5f); if (num < 0.5888f || num > 1.04f) { return -1; } float num2 = Mathf.Atan2(val3.x, val3.y) * 57.29578f; if (num2 < 0f) { num2 += 360f; } float num3 = num2 / 360f; for (int num4 = RingStart.Count - 1; num4 >= 0; num4--) { if (num3 >= RingStart[num4]) { return num4; } } return -1; } private static void ShowTip(string tip, Vector2 mouse) { //IL_0077: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_00fb: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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) if ((Object)(object)_tip == (Object)null) { return; } if (string.IsNullOrEmpty(tip)) { if (_tip.activeSelf) { _tip.SetActive(false); } return; } if (!_tip.activeSelf) { _tip.SetActive(true); } if (((TMP_Text)_tipText).text != tip) { ((TMP_Text)_tipText).text = tip; } float num = Mathf.Min(300f, ((TMP_Text)_tipText).GetPreferredValues(tip, 300f, 0f).x + 2f); Vector2 preferredValues = ((TMP_Text)_tipText).GetPreferredValues(tip, num, 0f); ((TMP_Text)_tipText).rectTransform.sizeDelta = new Vector2(num, preferredValues.y); float num2 = num + 20f; float num3 = preferredValues.y + 16f; _tipRt.sizeDelta = new Vector2(num2, num3); Vector2 val = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle(_rootRt, mouse, (Camera)null, ref val); Rect rect = _rootRt.rect; Vector2 anchoredPosition = val + new Vector2(18f, -18f); if (anchoredPosition.x + num2 > ((Rect)(ref rect)).xMax) { anchoredPosition.x = val.x - 18f - num2; } if (anchoredPosition.y - num3 < ((Rect)(ref rect)).yMin) { anchoredPosition.y = val.y + 18f + num3; } _tipRt.anchoredPosition = anchoredPosition; } } internal static class Dmg { internal const int Slots = 9; internal const int Cats = 7; internal static readonly string[] CatGlyph = new string[7] { "hand-fist", "flame", "snowflake", "lightning", "drop", "ghost", "skull" }; internal static readonly Color[] CatColor = (Color[])(object)new Color[7] { new Color(0.8f, 0.74f, 0.62f), new Color(0.96f, 0.47f, 0.18f), new Color(0.48f, 0.78f, 0.98f), new Color(0.98f, 0.86f, 0.34f), new Color(0.5f, 0.82f, 0.32f), new Color(0.7f, 0.92f, 0.86f), new Color(0.7f, 0.56f, 0.56f) }; internal static int CatOf(int slot) { switch (slot) { case 1: case 2: case 3: return 0; case 4: return 1; case 5: return 2; case 6: return 3; case 7: return 4; case 8: return 5; default: return 6; } } internal static float[] Vec(DamageTypes d) { return new float[9] { d.m_damage, d.m_blunt, d.m_slash, d.m_pierce, d.m_fire, d.m_frost, d.m_lightning, d.m_poison, d.m_spirit }; } internal static float Sum(float[] v) { float num = 0f; for (int i = 0; i < v.Length; i++) { if (v[i] > 0f) { num += v[i]; } } return num; } internal static int Top(float[] v) { int num = 0; for (int i = 1; i < v.Length; i++) { if (v[i] > v[num]) { num = i; } } return num; } } [HarmonyPatch(typeof(Menu), "Update")] internal static class EscPatch { private static bool Prefix() { if (DeathUi.PanelOpen && Input.GetKeyDown((KeyCode)27)) { DeathUi.ClosePanel(); return false; } return true; } } internal sealed class HitRec { public int A; public string Attack = ""; public float T; public float[] D = new float[9]; public float Shield; public float[] M = new float[9]; public float[] Ms = new float[5]; public bool HasMit; public float Total => Dmg.Sum(D); public float MitTotal => Dmg.Sum(M); } [HarmonyPatch(typeof(Game), "_RequestRespawn")] internal static class HoldRespawnPatch { private static readonly FieldInfo AfterDeath = AccessTools.Field(typeof(Game), "m_respawnAfterDeath"); private static bool Prefix(Game __instance) { try { if (!Plugin.HoldRespawn.Value || !DeathUi.IsDead || DeathUi.Released || AfterDeath == null) { return true; } object value = AfterDeath.GetValue(__instance); if (!(value is bool) || !(bool)value) { return true; } if (!DeathUi.Holding) { Plugin.Log.LogInfo((object)"Respawn waits for the Respawn button"); } DeathUi.Holding = true; return false; } catch { return true; } } } [HarmonyPatch(typeof(PlayerController), "TakeInput")] internal static class InputPatch { private static void Postfix(ref bool __result) { if (__result && DeathUi.PanelOpen && !DeathUi.IsDead) { __result = false; } } } internal sealed class LiveHit { public float Time; public Src Src; public float[] D = new float[9]; public float Shield; public float[] M = new float[9]; public float[] Ms = new float[5]; public bool MitOnly; } internal static class Mit { internal const int Sources = 5; internal const int Block = 0; internal const int Resist = 1; internal const int Armor = 2; internal const int Effects = 3; internal const int Other = 4; } [HarmonyPatch(typeof(HitData), "BlockDamage")] internal static class MitBlockPatch { [HarmonyPriority(800)] private static void Prefix(HitData __instance, out float[] __state) { __state = Recorder.MitStart(__instance); } [HarmonyPriority(0)] private static void Postfix(HitData __instance, float[] __state) { Recorder.MitEnd(__instance, __state, 0); } } [HarmonyPatch(typeof(HitData), "ApplyResistance")] internal static class MitResistPatch { [HarmonyPriority(800)] private static void Prefix(HitData __instance, out float[] __state) { __state = Recorder.MitStart(__instance); } [HarmonyPriority(0)] private static void Postfix(HitData __instance, float[] __state) { Recorder.MitEnd(__instance, __state, 1); } } [HarmonyPatch(typeof(HitData), "ApplyArmor")] internal static class MitArmorPatch { [HarmonyPriority(800)] private static void Prefix(HitData __instance, out float[] __state) { __state = Recorder.MitStart(__instance); } [HarmonyPriority(0)] private static void Postfix(HitData __instance, float[] __state) { Recorder.MitEnd(__instance, __state, 2); } } [HarmonyPatch(typeof(SEMan), "OnDamaged")] internal static class MitEffectsPatch { [HarmonyPriority(800)] private static void Prefix(HitData hit, out float[] __state) { __state = Recorder.MitStart(hit); } [HarmonyPriority(0)] private static void Postfix(HitData hit, float[] __state) { Recorder.MitEnd(hit, __state, 3); } } internal enum PanelLanguage { Auto, Turkish, English } [BepInPlugin("bumin.deathrecap", "BuminDeathRecap", "1.2.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "bumin.deathrecap"; public const string Version = "1.2.0"; internal static ManualLogSource Log; internal static ConfigEntry<PanelLanguage> Language; internal static ConfigEntry<RecapWindow> Window; internal static ConfigEntry<float> WindowSeconds; internal static ConfigEntry<bool> HoldRespawn; internal static ConfigEntry<float> AutoRespawn; internal static ConfigEntry<bool> OpenOnDeath; internal static ConfigEntry<float> ScreenDelay; internal static ConfigEntry<bool> RedEdges; internal static ConfigEntry<KeyboardShortcut> ReopenKey; internal static ConfigEntry<float> PanelSize; internal static ConfigEntry<bool> UseSeneaL; internal static ConfigEntry<bool> ShowAttacks; internal static ConfigEntry<bool> ChatLine; internal static ConfigEntry<bool> Compendium; internal static ConfigEntry<int> DeathsKept; internal static ConfigEntry<bool> Streak; internal static ConfigEntry<float> StreakMinutes; private int _order = 1000; private static readonly HashSet<string> Logged = new HashSet<string>(); private ConfigEntry<T> Bind<T>(string section, string key, T value, string text, AcceptableValueBase range) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes(); configurationManagerAttributes.Order = _order--; return ((BaseUnityPlugin)this).Config.Bind<T>(section, key, value, new ConfigDescription(text, range, new object[1] { configurationManagerAttributes })); } private void Awake() { //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Language = Bind("1 - General", "Language", PanelLanguage.Auto, "Language of the death screen. Auto follows the game language (Turkish or English).", null); Window = Bind("1 - General", "Recap window", RecapWindow.SinceFullHealth, "Which hits the summary counts: every hit since you were last at full health, or only the last seconds.", null); WindowSeconds = Bind("1 - General", "Window seconds", 20f, "Length of the window for LastSeconds. Hits older than 3 minutes are always dropped.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 120f)); HoldRespawn = Bind("2 - Death screen", "Wait for respawn click", value: true, "After death you stay down until you click Respawn, so you can read the summary. Off: the game respawns you after 10 seconds as usual.", null); AutoRespawn = Bind("2 - Death screen", "Auto respawn after seconds", 0f, "While waiting for the click, respawn by itself after this many seconds. 0 = never.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 600f)); OpenOnDeath = Bind("2 - Death screen", "Open summary on death", value: true, "Open the death summary together with the death screen. Off: open it with the summary button.", null); ScreenDelay = Bind("2 - Death screen", "Death screen delay", 1.5f, "Seconds between the killing blow and the death screen.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f)); RedEdges = Bind("2 - Death screen", "Red screen edges", value: true, "Darken the screen edges in red while you are dead.", null); ReopenKey = Bind<KeyboardShortcut>("3 - Summary", "Reopen key", new KeyboardShortcut((KeyCode)289, (KeyCode[])(object)new KeyCode[0]), "Opens or closes the summary of your last death.", null); PanelSize = Bind("3 - Summary", "Panel size", 1f, "Size of the death screen and the summary.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.6f, 1.6f)); UseSeneaL = Bind("3 - Summary", "Use SeneaL UI look", value: true, "Draw the panels with SeneaL UI's theme when SeneaL UI is installed.", null); ShowAttacks = Bind("3 - Summary", "Show attacks under attackers", value: true, "Show each attacker's attacks under its name. The eye button in the Attackers box switches this too; off fits more attackers.", null); ChatLine = Bind("4 - Extras", "Chat line", value: true, "Write a one-line death summary into your own chat window (only you see it).", null); Compendium = Bind("4 - Extras", "Compendium entry", value: true, "Add a Death records page to the compendium with your last deaths.", null); DeathsKept = Bind("4 - Extras", "Deaths kept", 5, "How many deaths are kept for the compendium and the reopen key.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20)); Streak = Bind("4 - Extras", "Death streak counter", value: true, "Show how many times in a row you died.", null); StreakMinutes = Bind("4 - Extras", "Streak minutes", 10f, "Deaths closer together than this many minutes count as one streak.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 120f)); new Harmony("bumin.deathrecap").PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)"BuminDeathRecap 1.2.0 is ready"); } private void Update() { try { Recorder.Tick(); DeathUi.Tick(); } catch (Exception e) { LogOnce("Update", e); } } internal static void LogOnce(string where, Exception e) { if (Logged.Add(where + e.GetType().Name)) { Log.LogWarning((object)(where + ": " + e)); } } } internal enum RecapWindow { SinceFullHealth, LastSeconds } internal static class Recorder { private const float MaxAge = 180f; private static readonly List<LiveHit> Hits = new List<LiveHit>(); private static float _lastFull = -1f; private static HitData _rawHit; private static Src _rawSrc; private static Src _poisonSrc; private static Src _fireSrc; private static float _poisonAt; private static float _fireAt; private static readonly float[] _mit = new float[9]; private static readonly float[] _mitSrc = new float[5]; private static readonly FieldInfo CurrentAttack = AccessTools.Field(typeof(Humanoid), "m_currentAttack"); private static readonly FieldInfo PreviousAttack = AccessTools.Field(typeof(Humanoid), "m_previousAttack"); private static readonly FieldInfo AttackWeapon = AccessTools.Field(typeof(Attack), "m_weapon"); private static readonly FieldInfo VisRight = AccessTools.Field(typeof(VisEquipment), "m_rightItem"); private static readonly FieldInfo VisLeft = AccessTools.Field(typeof(VisEquipment), "m_leftItem"); private static readonly string[][] Keywords = new string[32][] { new string[2] { "bite", "atk_bite" }, new string[2] { "claw", "atk_claw" }, new string[2] { "scratch", "atk_claw" }, new string[2] { "swipe", "atk_claw" }, new string[2] { "tail", "atk_tail" }, new string[2] { "stomp", "atk_stomp" }, new string[2] { "kick", "atk_stomp" }, new string[2] { "slam", "atk_slam" }, new string[2] { "smash", "atk_slam" }, new string[2] { "punch", "atk_punch" }, new string[2] { "fist", "atk_punch" }, new string[2] { "unarmed", "atk_punch" }, new string[2] { "headbutt", "atk_charge" }, new string[2] { "charge", "atk_charge" }, new string[2] { "horn", "atk_charge" }, new string[2] { "gore", "atk_charge" }, new string[2] { "spit", "atk_spit" }, new string[2] { "breath", "atk_breath" }, new string[2] { "throw", "atk_throw" }, new string[2] { "rock", "atk_throw" }, new string[2] { "spell", "atk_spell" }, new string[2] { "fireball", "atk_spell" }, new string[2] { "nova", "atk_spell" }, new string[2] { "magic", "atk_spell" }, new string[2] { "explo", "atk_explosion" }, new string[2] { "aoe", "atk_explosion" }, new string[2] { "sting", "atk_sting" }, new string[2] { "grab", "atk_grab" }, new string[2] { "tentacle", "atk_tentacle" }, new string[2] { "shoot", "atk_shot" }, new string[2] { "sweep", "atk_sweep" }, new string[2] { "peck", "atk_peck" } }; internal static void Tick() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && !((Character)localPlayer).IsDead() && ((Character)localPlayer).GetHealth() >= ((Character)localPlayer).GetMaxHealth() - 0.5f && Shield.Full()) { _lastFull = Time.time; } } internal static void OnRawHit(HitData hit) { if (hit == null) { return; } _rawHit = hit; Array.Clear(_mit, 0, _mit.Length); Array.Clear(_mitSrc, 0, _mitSrc.Length); _rawSrc = Resolve(hit); if (_rawSrc.Kind != 2) { if (hit.m_damage.m_poison > 0f) { _poisonSrc = _rawSrc; _poisonAt = Time.time; } if (hit.m_damage.m_fire > 0f) { _fireSrc = _rawSrc; _fireAt = Time.time; } } } internal static float[] MitStart(HitData hit) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (hit == null || hit != _rawHit) { return null; } return Dmg.Vec(hit.m_damage); } internal static void MitEnd(HitData hit, float[] before, int source) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (before == null || hit == null || hit != _rawHit) { return; } float[] array = Dmg.Vec(hit.m_damage); for (int i = 0; i < 9; i++) { float num = before[i] - array[i]; if (num > 0f) { _mit[i] += num; _mitSrc[source] += num; } } } internal static void OnApplied(HitData hit, float lost, float[] before, float shield) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Invalid comparison between Unknown and I4 //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Invalid comparison between Unknown and I4 //IL_022c: Unknown result type (might be due to invalid IL or missing references) bool flag = hit == _rawHit && _rawSrc != null; float[] array = new float[9]; float[] array2 = new float[5]; if (flag) { Array.Copy(_mit, array, 9); Array.Copy(_mitSrc, array2, 5); } float[] array3 = Dmg.Vec(hit.m_damage); float[] array4 = new float[9]; float num = 0f; for (int i = 0; i < 9; i++) { array4[i] = Mathf.Max(0f, before[i] - array3[i]); num += array4[i]; } float num2 = Dmg.Sum(before) - Dmg.Sum(array3) - shield; if (num2 > 0.05f && num > 0f) { for (int j = 0; j < 9; j++) { array[j] += array4[j] * num2 / num; } array2[4] += num2; } bool flag2 = lost <= 0.05f && shield <= 0.05f; if (flag2 && Dmg.Sum(array) < 0.5f) { return; } Src src = (flag ? _rawSrc : Resolve(hit)); _rawHit = null; _rawSrc = null; if (src.Kind == 2) { if ((int)hit.m_hitType == 7 && _poisonSrc != null && Time.time - _poisonAt < 60f) { src = _poisonSrc.With(Text.G("poisonTick")); } else if ((int)hit.m_hitType == 5 && _fireSrc != null && Time.time - _fireAt < 30f) { src = _fireSrc.With(Text.G("burnTick")); } } float[] array5 = array3; float num3 = Dmg.Sum(array5); if (num3 <= 0f) { array5 = before; num3 = Dmg.Sum(array5); } LiveHit liveHit = new LiveHit(); liveHit.Time = Time.time; liveHit.Src = src; liveHit.Shield = shield; liveHit.M = array; liveHit.Ms = array2; liveHit.MitOnly = flag2; if (num3 <= 0f) { liveHit.D[SlotOf(hit.m_hitType)] = lost; } else { for (int k = 0; k < 9; k++) { if (array5[k] > 0f) { liveHit.D[k] = lost * array5[k] / num3; } } } Hits.Add(liveHit); float num4 = Time.time - 180f; while (Hits.Count > 0 && (Hits[0].Time < num4 || Hits.Count > 400)) { Hits.RemoveAt(0); } } private static int SlotOf(HitType t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: 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_0016: Expected I4, but got Unknown //IL_0016: 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_002b: Expected I4, but got Unknown switch (t - 5) { default: switch (t - 20) { case 0: case 1: case 2: break; default: return 0; } goto case 0; case 0: return 4; case 1: return 5; case 2: return 7; } } internal static DeathRec Finish(Player p) { //IL_011b: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; float num = ((Plugin.Window.Value != RecapWindow.LastSeconds) ? ((_lastFull >= 0f) ? Mathf.Max(_lastFull, time - 180f) : (time - 180f)) : (time - Plugin.WindowSeconds.Value)); List<LiveHit> list = new List<LiveHit>(); List<LiveHit> list2 = new List<LiveHit>(); foreach (LiveHit hit in Hits) { if (hit.Time >= num - 0.01f) { (hit.MitOnly ? list2 : list).Add(hit); } } if (list.Count == 0) { for (int num2 = Hits.Count - 1; num2 >= 0; num2--) { if (!Hits[num2].MitOnly) { list.Add(Hits[num2]); break; } } } DeathRec deathRec = new DeathRec(); deathRec.When = DateTime.Now; deathRec.MaxHp = ((Character)p).GetMaxHealth(); deathRec.Biome = BiomeOf(((Component)p).transform.position); Dictionary<string, HashSet<string>> dictionary = new Dictionary<string, HashSet<string>>(); foreach (LiveHit item in list) { int num3 = -1; for (int i = 0; i < deathRec.Attackers.Count; i++) { if (deathRec.Attackers[i].Key == item.Src.Key) { num3 = i; break; } } if (num3 < 0) { AttackerRec attackerRec = new AttackerRec(); attackerRec.Key = item.Src.Key; attackerRec.Name = item.Src.Name; attackerRec.Stars = item.Src.Stars; attackerRec.Kind = item.Src.Kind; attackerRec.IconItem = item.Src.IconItem; attackerRec.Glyph = item.Src.Glyph; deathRec.Attackers.Add(attackerRec); num3 = deathRec.Attackers.Count - 1; dictionary[attackerRec.Key] = new HashSet<string>(); } if (!string.IsNullOrEmpty(item.Src.Zdo)) { dictionary[item.Src.Key].Add(item.Src.Zdo); } HitRec hitRec = new HitRec(); hitRec.A = num3; hitRec.Attack = item.Src.Attack; hitRec.T = item.Time - time; hitRec.Shield = item.Shield; Array.Copy(item.D, hitRec.D, 9); Array.Copy(item.M, hitRec.M, 9); Array.Copy(item.Ms, hitRec.Ms, 5); hitRec.HasMit = true; deathRec.Hits.Add(hitRec); } foreach (LiveHit item2 in list2) { HitRec hitRec2 = new HitRec(); hitRec2.A = -1; for (int j = 0; j < deathRec.Attackers.Count; j++) { if (deathRec.Attackers[j].Key == item2.Src.Key) { hitRec2.A = j; break; } } hitRec2.Attack = item2.Src.Attack; hitRec2.T = item2.Time - time; Array.Copy(item2.M, hitRec2.M, 9); Array.Copy(item2.Ms, hitRec2.Ms, 5); hitRec2.HasMit = true; deathRec.Mits.Add(hitRec2); } foreach (AttackerRec attacker in deathRec.Attackers) { attacker.Count = Mathf.Max(1, dictionary[attacker.Key].Count); } try { foreach (StatusEffect statusEffect in ((Character)p).GetSEMan().GetStatusEffects()) { if (!((Object)(object)statusEffect == (Object)null) && !((Object)(object)statusEffect.m_icon == (Object)null)) { BuffRec buffRec = new BuffRec(); buffRec.Hash = statusEffect.NameHash(); buffRec.Name = Localization.instance.Localize(statusEffect.m_name); string text = ""; try { text = Localization.instance.Localize(statusEffect.GetTooltipString()); } catch { } buffRec.Tip = text ?? ""; deathRec.Buffs.Add(buffRec); } } } catch (Exception e) { Plugin.LogOnce("Buffs", e); } DeathRec latest = Store.Latest; if (latest != null && (deathRec.When - latest.When).TotalMinutes <= (double)Plugin.StreakMinutes.Value) { deathRec.Streak = latest.Streak + 1; } Hits.Clear(); _poisonSrc = null; _fireSrc = null; _lastFull = -1f; return deathRec; } private static string BiomeOf(Vector3 pos) { //IL_0014: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (pos.y > 3000f) { return "Dungeon"; } try { Biome val = Heightmap.FindBiome(pos); if ((int)val == 0 && WorldGenerator.instance != null) { val = WorldGenerator.instance.GetBiome(pos); } return ((object)val).ToString(); } catch { return ""; } } private static Src Resolve(HitData hit) { //IL_0141: 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) Character val = null; try { val = hit.GetAttacker(); } catch { } if ((Object)(object)val != (Object)null) { return FromCharacter(val, ((Component)val).gameObject, hit); } if (!((ZDOID)(ref hit.m_attacker)).IsNone()) { try { ZDO zDO = ZDOMan.instance.GetZDO(hit.m_attacker); GameObject val2 = ((zDO != null && (Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(zDO.GetPrefab()) : null); Character val3 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<Character>() : null); if ((Object)(object)val3 != (Object)null) { Src src = FromCharacter(val3, val2, hit); src.Stars = Mathf.Max(0, zDO.GetInt(ZDOVars.s_level, 1) - 1); src.Key = "c:" + ((Object)val2).name + ":" + src.Stars; src.Zdo = ((object)Unsafe.As<ZDOID, ZDOID>(ref hit.m_attacker)/*cast due to .constrained prefix*/).ToString(); return src; } } catch { } Src src2 = World((HitType)0); src2.Name = Text.G("unknown"); src2.Attack = Text.G("atk"); return src2; } return World(hit.m_hitType); } private static Src World(HitType t) { //IL_0013: 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_0056: Unknown result type (might be due to invalid IL or missing references) Src src = new Src(); src.Kind = 2; src.Key = "w:" + t; string obj = Text.G("env_" + t) ?? Text.G("unknown"); string attack = obj; src.Name = obj; src.Attack = attack; src.Glyph = GlyphOf(t); return src; } private static string GlyphOf(HitType t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: 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_0062: Expected I4, but got Unknown switch (t - 3) { case 0: case 8: return "arrow-fat-down"; case 1: case 5: case 18: return "waves"; case 2: case 17: case 19: case 20: return "flame"; case 3: return "snowflake"; case 4: return "drop"; case 6: return "wind"; case 10: return "tree"; case 14: return "boat"; case 13: case 16: return "crosshair"; case 11: return "user"; case 9: case 12: case 15: case 21: return "hammer"; default: return "skull"; } } private static Src FromCharacter(Character c, GameObject go, HitData hit) { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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) Src src = new Src(); string prefabName = Utils.GetPrefabName(go); bool flag = c.IsPlayer(); src.Kind = (flag ? 1 : 0); try { src.Name = c.GetHoverName(); } catch { } if (string.IsNullOrEmpty(src.Name)) { src.Name = Localization.instance.Localize(c.m_name); } if ((Object)(object)c == (Object)(object)Player.m_localPlayer) { src.Name = Text.G("self"); } try { src.Stars = Mathf.Max(0, c.GetLevel() - 1); } catch { } src.Key = (flag ? ("p:" + src.Name) : ("c:" + prefabName + ":" + src.Stars)); try { if (c.GetZDOID() != ZDOID.None) { src.Zdo = ((object)c.GetZDOID()/*cast due to .constrained prefix*/).ToString(); } } catch { } src.Glyph = (flag ? "user" : "paw-print"); if (!flag) { src.IconItem = TrophyOf(go); } GameObject val = BestWeapon(c, go, hit, flag); if ((Object)(object)val != (Object)null) { ItemDrop component = val.GetComponent<ItemDrop>(); src.Attack = AttackName(val, component, flag); if (flag || string.IsNullOrEmpty(src.IconItem)) { src.IconItem = (HasIcon(component) ? ((Object)val).name : src.IconItem); } } else { src.Attack = Text.G(flag ? "unarmed" : "atk"); } return src; } private static bool HasIcon(ItemDrop d) { if ((Object)(object)d != (Object)null && d.m_itemData != null && d.m_itemData.m_shared != null && d.m_itemData.m_shared.m_icons != null && d.m_itemData.m_shared.m_icons.Length > 0) { return (Object)(object)d.m_itemData.m_shared.m_icons[0] != (Object)null; } return false; } private static string TrophyOf(GameObject go) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Invalid comparison between Unknown and I4 try { CharacterDrop component = go.GetComponent<CharacterDrop>(); if ((Object)(object)component == (Object)null || component.m_drops == null) { return ""; } foreach (Drop drop in component.m_drops) { if (drop != null && !((Object)(object)drop.m_prefab == (Object)null)) { ItemDrop component2 = drop.m_prefab.GetComponent<ItemDrop>(); if ((Object)(object)component2 != (Object)null && (int)component2.m_itemData.m_shared.m_itemType == 13) { return ((Object)drop.m_prefab).name; } } } } catch { } return ""; } private static GameObject BestWeapon(Character c, GameObject go, HitData hit, bool player) { //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) List<GameObject> list = new List<GameObject>(); GameObject val = null; try { Humanoid val2 = (Humanoid)(object)((c is Humanoid) ? c : null); if ((Object)(object)val2 != (Object)null) { val = WeaponOf((Attack)((CurrentAttack != null) ? /*isinst with value type is only supported in some contexts*/: null)); if ((Object)(object)val == (Object)null) { val = WeaponOf((Attack)((PreviousAttack != null) ? /*isinst with value type is only supported in some contexts*/: null)); } if ((Object)(object)val != (Object)null) { list.Add(val); } if (val2.m_defaultItems != null) { list.AddRange(val2.m_defaultItems); } if (val2.m_randomWeapon != null) { list.AddRange(val2.m_randomWeapon); } if (val2.m_randomSets != null) { ItemSet[] randomSets = val2.m_randomSets; ItemSet[] array = randomSets; foreach (ItemSet val3 in array) { if (val3 != null && val3.m_items != null) { list.AddRange(val3.m_items); } } } if (val2.m_randomItems != null) { RandomItem[] randomItems = val2.m_randomItems; RandomItem[] array2 = randomItems; foreach (RandomItem val4 in array2) { if (val4 != null) { list.Add(val4.m_prefab); } } } } VisEquipment component = go.GetComponent<VisEquipment>(); if ((Object)(object)component != (Object)null && (Object)(object)ObjectDB.instance != (Object)null) { FieldInfo[] array3 = new FieldInfo[2] { VisRight, VisLeft }; FieldInfo[] array4 = array3; foreach (FieldInfo fieldInfo in array4) { if (fieldInfo == null) { continue; } object value = fieldInfo.GetValue(component); if (value is int && (int)value != 0) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab((int)value); if ((Object)(object)itemPrefab != (Object)null) { list.Add(itemPrefab); } } } } } catch (Exception e) { Plugin.LogOnce("Weapons", e); } float[] a = Dmg.Vec(hit.m_damage); GameObject result = null; float num = 0.25f; foreach (GameObject item in list) { if ((Object)(object)item == (Object)null) { continue; } ItemDrop component2 = item.GetComponent<ItemDrop>(); if ((Object)(object)component2 == (Object)null || component2.m_itemData == null || component2.m_itemData.m_shared == null) { continue; } SharedData shared = component2.m_itemData.m_shared; float[] array5 = Dmg.Vec(shared.m_damages); bool flag = (Object)(object)item == (Object)(object)val; if (!(Dmg.Sum(array5) <= 0f) || flag) { float num2 = Cos(a, array5); if ((int)hit.m_skill != 0 && shared.m_skillType == hit.m_skill) { num2 += 0.4f; } if (hit.m_statusEffectHash != 0 && (Object)(object)shared.m_attackStatusEffect != (Object)null && shared.m_attackStatusEffect.NameHash() == hit.m_statusEffectHash) { num2 += 0.6f; } if (flag) { num2 += 0.3f; } if (num2 > num) { num = num2; result = item; } } } return result; } private static GameObject WeaponOf(Attack at) { ItemData val = (ItemData)((at != null && AttackWeapon != null) ? /*isinst with value type is only supported in some contexts*/: null); if (val == null) { return null; } if ((Object)(object)val.m_dropPrefab != (Object)null) { return val.m_dropPrefab; } if (!((Object)(object)ObjectDB.instance != (Object)null)) { return null; } return ObjectDB.instance.GetItemPrefab(val.m_shared); } private static float Cos(float[] a, float[] b) { float num = 0f; float num2 = 0f; float num3 = 0f; for (int i = 0; i < a.Length; i++) { float num4 = Mathf.Max(0f, a[i]); float num5 = Mathf.Max(0f, b[i]); num += num4 * num5; num2 += num4 * num4; num3 += num5 * num5; } if (num2 <= 0f || num3 <= 0f) { return 0f; } return num / Mathf.Sqrt(num2 * num3); } private static string AttackName(GameObject prefab, ItemDrop d, bool player) { if (!player) { string text = ((Object)prefab).name.ToLowerInvariant(); string[][] keywords = Keywords; string[][] array = keywords; foreach (string[] array2 in array) { if (text.Contains(array2[0])) { return Text.G(array2[1]); } } } if ((Object)(objec