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 SmartTerminal v1.0.4
BepInEx\plugins\SmartTerminal\SmartTerminal.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("SmartTerminal")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.4.0")] [assembly: AssemblyInformationalVersion("1.0.4+e25a98004953e72531981b96bd3723c0e72f21f2")] [assembly: AssemblyProduct("SmartTerminal")] [assembly: AssemblyTitle("SmartTerminal")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.4.0")] [module: UnverifiableCode] namespace SmartTerminal { public static class DamageTracker { private struct DamageRecord { public readonly float Time; public readonly float Amount; public DamageRecord(float time, float amount) { Time = time; Amount = amount; } } private static readonly List<DamageRecord> Dealt = new List<DamageRecord>(64); private static readonly List<DamageRecord> Taken = new List<DamageRecord>(64); private static bool _patched; public static float DpsDealt => Query(Dealt); public static float DpsTaken => Query(Taken); public static void TryPatch(Harmony harmony) { if (_patched) { return; } try { harmony.PatchAll(typeof(DamageTracker)); _patched = true; SmartTerminalPlugin.Log.LogInfo((object)"伤害统计与击退浮字补丁已应用"); } catch (Exception ex) { SmartTerminalPlugin.Log.LogWarning((object)("伤害统计补丁失败: " + ex.Message)); } } [HarmonyPatch(typeof(Character), "RPC_Damage")] [HarmonyPostfix] private static void RpcDamage_Postfix(Character __instance, HitData hit) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } float totalDamage = ((DamageTypes)(ref hit.m_damage)).GetTotalDamage(); float time = Time.time; if ((Object)(object)hit.GetAttacker() == (Object)(object)localPlayer) { if (totalDamage > 0f) { Dealt.Add(new DamageRecord(time, totalDamage)); ShowKnockbackText(__instance, hit, L10n.T("knockback")); } } else if ((Object)(object)__instance == (Object)(object)localPlayer && totalDamage > 0f) { Taken.Add(new DamageRecord(time, totalDamage)); ShowKnockbackText(__instance, hit, L10n.T("knockback")); } } [HarmonyPatch(typeof(Humanoid), "BlockAttack")] [HarmonyPostfix] private static void BlockAttack_Postfix(Humanoid __instance, HitData hit, Character attacker, bool __result) { if (!__result) { return; } Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { ItemData currentBlocker = __instance.GetCurrentBlocker(); bool flag = currentBlocker != null && currentBlocker.m_shared.m_timedBlockBonus > 1f && __instance.m_blockTimer != -1f && __instance.m_blockTimer < 0.25f; if ((Object)(object)__instance == (Object)(object)localPlayer) { ShowKnockbackText((Character)(object)__instance, hit, flag ? L10n.T("knockbackParry") : L10n.T("knockbackBlock")); } else if ((Object)(object)attacker == (Object)(object)localPlayer) { ShowKnockbackText((Character)(object)__instance, hit, L10n.T("knockbackBlocked")); } } } private static void ShowKnockbackText(Character target, HitData hit, string prefix) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) if ((SmartTerminalPlugin.ShowKnockback != null && !SmartTerminalPlugin.ShowKnockback.Value) || hit.m_pushForce <= 0f) { return; } try { DamageText instance = DamageText.instance; Camera mainCamera = Utils.GetMainCamera(); if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.m_worldTextBase == (Object)null) && !((Object)(object)mainCamera == (Object)null)) { Vector3 val = hit.m_point + Vector3.up * 1.1f; float num = Vector3.Distance(((Component)mainCamera).transform.position, val); if (!(num > instance.m_maxTextDistance)) { instance.AddInworldText((TextType)0, val, num, $"{prefix} {hit.m_pushForce:0.#}", false); ((Graphic)instance.m_worldTexts[instance.m_worldTexts.Count - 1].m_textField).color = new Color(0.42f, 0.72f, 1f, 1f); } } } catch (Exception ex) { SmartTerminalPlugin.Log.LogWarning((object)("击退浮字异常: " + ex.Message)); } } private static float Query(List<DamageRecord> records) { float num = SmartTerminalPlugin.DamageWindow?.Value ?? 5f; float num2 = Time.time - num; float num3 = 0f; for (int num4 = records.Count - 1; num4 >= 0; num4--) { if (records[num4].Time < num2) { records.RemoveRange(0, num4 + 1); break; } num3 += records[num4].Amount; } return num3 / num; } } public static class DataCollector { private const float SeaLevel = 30f; public static string BuildReport() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(256); Player localPlayer = Player.m_localPlayer; EnvMan instance = EnvMan.instance; if (Show(SmartTerminalPlugin.ShowAltitude)) { float num = (((Object)(object)localPlayer != (Object)null) ? ((Component)localPlayer).transform.position.y : 0f); stringBuilder.Append(L10n.T("altitude")).Append(": ").Append(num.ToString("F1")) .Append("m") .Append(" (") .Append(L10n.T("waterAbove")) .Append(" ") .Append((num - 30f).ToString("F1")) .AppendLine("m)"); } if (Show(SmartTerminalPlugin.ShowTime) && (Object)(object)instance != (Object)null) { int currentDay = instance.GetCurrentDay(); float num2 = instance.GetDayFraction() * 24f; int num3 = Mathf.FloorToInt(num2); int num4 = Mathf.FloorToInt((num2 - (float)num3) * 60f); stringBuilder.Append(L10n.T("time")).Append(": ").Append(L10n.F("timeFormat", currentDay)) .Append(" ") .Append(num3.ToString("00")) .Append(":") .Append(num4.ToString("00")) .AppendLine(); } else if (Show(SmartTerminalPlugin.ShowTime)) { stringBuilder.Append(L10n.T("time")).AppendLine(": —"); } if (Show(SmartTerminalPlugin.ShowWeather)) { stringBuilder.Append(L10n.T("weather")).Append(": ").AppendLine(((Object)(object)localPlayer != (Object)null && (Object)(object)instance != (Object)null) ? TranslateWeather(instance.GetCurrentEnvironment()?.m_name) : "—"); } if (Show(SmartTerminalPlugin.ShowDamageDealt)) { stringBuilder.Append(L10n.T("dpsDealt")).Append(": ").Append(DamageTracker.DpsDealt.ToString("F1")) .AppendLine(L10n.T("perSec")); } if (Show(SmartTerminalPlugin.ShowDamageTaken)) { stringBuilder.Append(L10n.T("dpsTaken")).Append(": ").Append(DamageTracker.DpsTaken.ToString("F1")) .AppendLine(L10n.T("perSec")); } if (Show(SmartTerminalPlugin.ShowRecovery)) { stringBuilder.Append(L10n.T("stamina")).Append(": ").AppendLine(((Object)(object)localPlayer != (Object)null) ? GetStaminaState(localPlayer) : "—"); stringBuilder.Append(L10n.T("health")).Append(": ").AppendLine(((Object)(object)localPlayer != (Object)null) ? GetHealthRegen(localPlayer) : "—"); } if (Show(SmartTerminalPlugin.ShowBlock)) { stringBuilder.Append(L10n.T("block")).Append(": ").AppendLine(((Object)(object)localPlayer != (Object)null) ? GetBlockSummary(localPlayer) : "—"); } return stringBuilder.ToString().TrimEnd(Array.Empty<char>()); } private static bool Show(ConfigEntry<bool> entry) { return entry?.Value ?? true; } private static string GetStaminaState(Player player) { bool flag = player.GetStamina() >= ((Character)player).GetMaxStamina() - 0.01f; bool flag2 = player.m_staminaRegenTimer > 0f || ((Character)player).InAttack() || ((Character)player).InDodge() || (((Character)player).IsSwimming() && !((Character)player).IsOnGround()) || ((Character)player).m_wallRunning; float num = 1f; ((Character)player).m_seman.ModifyStaminaRegen(ref num); if (((Character)player).IsBlocking()) { num *= 0.8f; } StringBuilder reasons = BuildStaminaReasons(player); if (!flag && !flag2 && ((Character)player).IsEncumbered()) { return AppendReasons(L10n.T("staminaStoppedEncumbered"), reasons); } return AppendReasons(L10n.T(flag ? "staminaFull" : (flag2 ? "staminaDelay" : ((num >= 0.95f) ? "staminaNormal" : ((num >= 0.75f) ? "staminaSlow" : ((num >= 0.5f) ? "staminaVerySlow" : ((num >= 0.25f) ? "staminaExtremelySlow" : "staminaStalled")))))), reasons); } private static StringBuilder BuildStaminaReasons(Player player) { StringBuilder stringBuilder = new StringBuilder(); if (((Character)player).IsBlocking()) { stringBuilder.Append(" ").Append(L10n.T("blockingNote")).Append("×0.8"); } foreach (StatusEffect statusEffect in ((Character)player).m_seman.m_statusEffects) { SE_Stats val = (SE_Stats)(object)((statusEffect is SE_Stats) ? statusEffect : null); if (val != null && Mathf.Abs(val.m_staminaRegenMultiplier - 1f) > 0.01f) { stringBuilder.Append(" ").Append(Localization.instance.Localize(((StatusEffect)val).m_name)).Append("×") .Append(val.m_staminaRegenMultiplier.ToString("0.##")); } } return stringBuilder; } private static string AppendReasons(string text, StringBuilder reasons) { if (reasons.Length == 0) { return text; } string text2 = reasons.ToString().TrimStart(Array.Empty<char>()); if (text.Length + text2.Length > 16) { return text + "\n " + text2; } return text + " " + text2; } private static string GetHealthRegen(Player player) { float num = 0f; float num2 = float.MaxValue; foreach (Food food in player.m_foods) { num += food.m_item.m_shared.m_foodRegen; if (food.m_time < num2) { num2 = food.m_time; } } if (num <= 0f) { return L10n.T("healthNoFood"); } float num3 = 1f; ((Character)player).m_seman.ModifyHealthRegen(ref num3); num *= num3; StringBuilder stringBuilder = new StringBuilder(); if (Mathf.Abs(num3 - 1f) > 0.01f) { foreach (StatusEffect statusEffect in ((Character)player).m_seman.m_statusEffects) { SE_Stats val = (SE_Stats)(object)((statusEffect is SE_Stats) ? statusEffect : null); if (val != null && Mathf.Abs(val.m_healthRegenMultiplier - 1f) > 0.01f) { stringBuilder.Append(" ").Append(Localization.instance.Localize(((StatusEffect)val).m_name)).Append("×") .Append(val.m_healthRegenMultiplier.ToString("0.##")); } } } return AppendReasons((num2 < 30f) ? string.Format("+{0:0.#}{1} ·{2}", num, L10n.T("perTick"), L10n.F("foodExpires", num2.ToString("0.#"))) : string.Format("+{0:0.#}{1}{2}", num, L10n.T("perTick"), L10n.T("tickNote")), stringBuilder); } private static string GetBlockSummary(Player player) { ItemData currentBlocker = ((Humanoid)player).GetCurrentBlocker(); if (currentBlocker == null) { return L10n.T("unarmed"); } float skillFactor = ((Character)player).GetSkillFactor((SkillType)6); float blockPower = currentBlocker.GetBlockPower(skillFactor); string text = Localization.instance.Localize(currentBlocker.m_shared.m_name) + ((currentBlocker.m_quality > 1) ? $" Lv{currentBlocker.m_quality}" : ""); float timedBlockBonus = currentBlocker.m_shared.m_timedBlockBonus; if (timedBlockBonus > 1f) { float num = blockPower * timedBlockBonus; ((Character)player).m_seman.ModifyTimedBlockBonus(ref num); return string.Format("{0} · {1} {2:0.#} · {3} {4:0.#}", text, L10n.T("block"), blockPower, L10n.T("parry"), num); } return string.Format("{0} · {1} {2:0.#}", text, L10n.T("block"), blockPower); } private static string TranslateWeather(string environment) { if (string.IsNullOrEmpty(environment)) { return "—"; } if (!L10n.IsChinese) { return environment; } return environment switch { "Clear" => "晴朗", "Misty" => "薄雾", "Darklands_dark" => "黑暗", "Heath clear" => "晴空", "DeepForest Mist" => "密林浓雾", "GDKing" => "雨", "Rain" => "雨", "LightRain" => "小雨", "ThunderStorm" => "雷暴", "Eikthyr" => "沉寂", "GoblinKing" => "薄雾", "nofogts" => "雾散", "SwampRain" => "沼泽雨", "Bonemass" => "浓雾", _ => environment, }; } } public class HudPanel : MonoBehaviour { private const float MapSpacing = 12f; private const float PanelWidth = 280f; private const float HeightAnimDuration = 0.5f; private const float PaddingH = 14f; private const float PaddingV = 10f; private RectTransform _root; private TextMeshProUGUI _textTop; private RectTransform _bottomClip; private TextMeshProUGUI _textBottom; private bool _building; private float _lastRefresh; private string _cachedText = ""; private float _animTime; private float _clipFrom; private float _clipTo; private float _offsetFrom; private float _bottomH; private bool _heightInitialized; private static readonly Color TitleColor = new Color(0.87f, 0.74f, 0.5f); private static readonly Color ContentColor = new Color(0.93f, 0.89f, 0.8f); private void Update() { EnsurePanel(); if ((Object)(object)_root == (Object)null) { return; } Player localPlayer = Player.m_localPlayer; bool flag = (Object)(object)localPlayer != (Object)null && !((Character)localPlayer).InPlaceMode(); if (((Component)_root).gameObject.activeSelf != flag) { ((Component)_root).gameObject.SetActive(flag); } if (flag) { AlignToMinimap(); if (Time.unscaledTime - _lastRefresh >= SmartTerminalPlugin.RefreshInterval.Value) { _lastRefresh = Time.unscaledTime; ApplyText(DataCollector.BuildReport()); } AdvanceAnimation(); } } private void ApplyText(string newText) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) SplitLines(_cachedText, newText, out var prefix, out var middle, out var suffix, out var oldTail); int num = ((_cachedText != null && _cachedText.Length > 0) ? _cachedText.Split(new char[1] { '\n' }).Length : 0); int num2 = ((newText != null && newText.Length > 0) ? newText.Split(new char[1] { '\n' }).Length : 0); string text = "<color=#" + ColorUtility.ToHtmlStringRGB(TitleColor) + ">" + L10n.T("title") + "</color>"; if (!_heightInitialized) { ((TMP_Text)_textTop).text = ((newText.Length > 0) ? (text + "\n" + newText) : text); ((TMP_Text)_textBottom).text = ""; _clipFrom = (_clipTo = 0f); _offsetFrom = 0f; _animTime = 0.5f; _heightInitialized = true; _bottomH = 0f; _cachedText = newText; return; } ((TMP_Text)_textTop).text = ((prefix.Length > 0) ? (text + "\n" + prefix) : text); string text2 = ((middle.Length > 0 && suffix.Length > 0) ? (middle + "\n" + suffix) : ((middle.Length > 0) ? middle : suffix)); float num3 = 0f; if (suffix.Length > 0) { ((TMP_Text)_textBottom).text = suffix; num3 = ((TMP_Text)_textBottom).preferredHeight; } ((TMP_Text)_textBottom).text = text2; float preferredHeight = ((TMP_Text)_textBottom).preferredHeight; float num4 = preferredHeight - num3; if (num2 > num && num4 > 0.1f) { _clipFrom = num3; _clipTo = preferredHeight; _offsetFrom = num4; _animTime = 0f; } else if (num2 < num) { float num5 = 0f; if (oldTail.Length > 0) { ((TMP_Text)_textBottom).text = oldTail; num5 = ((TMP_Text)_textBottom).preferredHeight; ((TMP_Text)_textBottom).text = text2; } _clipFrom = num5; _clipTo = preferredHeight; _offsetFrom = 0f - Mathf.Max(0f, num5 - preferredHeight); _animTime = 0f; } else { _clipFrom = (_clipTo = preferredHeight); _offsetFrom = 0f; _animTime = 0.5f; } _bottomH = preferredHeight; _cachedText = newText; } private void AdvanceAnimation() { //IL_007c: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) _animTime += Time.deltaTime; float num = Mathf.Clamp01(_animTime / 0.5f); float num2 = 1f - num; num = 1f - num2 * num2 * num2; float num3 = Mathf.Lerp(_clipFrom, _clipTo, num); float num4 = Mathf.Lerp(_offsetFrom, 0f, num); float preferredHeight = ((TMP_Text)_textTop).preferredHeight; ((TMP_Text)_textTop).rectTransform.sizeDelta = new Vector2(-28f, preferredHeight); _bottomClip.anchoredPosition = new Vector2(0f, -10f - preferredHeight); _bottomClip.SetSizeWithCurrentAnchors((Axis)1, num3); RectTransform rectTransform = ((TMP_Text)_textBottom).rectTransform; rectTransform.sizeDelta = new Vector2(0f, _bottomH); rectTransform.anchoredPosition = new Vector2(0f, num4); _root.SetSizeWithCurrentAnchors((Axis)1, preferredHeight + num3 + 20f); } private static void SplitLines(string oldText, string newText, out string prefix, out string middle, out string suffix, out string oldTail) { string[] array = ((oldText != null) ? oldText.Split(new char[1] { '\n' }) : new string[0]); string[] array2 = ((newText != null) ? newText.Split(new char[1] { '\n' }) : new string[0]); int i; for (i = 0; i < array.Length && i < array2.Length && LineKey(array[i]) == LineKey(array2[i]); i++) { } int j; for (j = 0; j < array.Length - i && j < array2.Length - i && LineKey(array[array.Length - 1 - j]) == LineKey(array2[array2.Length - 1 - j]); j++) { } prefix = JoinLines(array2, 0, i); middle = JoinLines(array2, i, array2.Length - i - j); suffix = JoinLines(array2, array2.Length - j, j); oldTail = JoinLines(array, i, array.Length - i); } private static string LineKey(string line) { int num = line.IndexOf(':'); return ((num >= 0) ? line.Substring(0, num) : line).Trim(); } private static string JoinLines(string[] lines, int index, int count) { if (count <= 0) { return ""; } return string.Join("\n", lines, index, count); } private void AlignToMinimap() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) RawImage val = (((Object)(object)Minimap.instance != (Object)null) ? Minimap.instance.m_mapImageSmall : null); if (!((Object)(object)val == (Object)null)) { Vector3[] array = (Vector3[])(object)new Vector3[4]; ((Graphic)val).rectTransform.GetWorldCorners(array); int value = SmartTerminalPlugin.HudOffsetY.Value; int value2 = SmartTerminalPlugin.HudOffsetX.Value; ((Transform)_root).position = new Vector3(array[3].x + (float)value2, array[3].y - 12f - (float)value, 0f); } } private void OnDestroy() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)((Component)_root).gameObject); } } private void EnsurePanel() { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_00e6: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Expected O, but got Unknown //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Expected O, but got Unknown //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_root != (Object)null || _building) { return; } Hud instance = Hud.instance; RawImage val = (((Object)(object)Minimap.instance != (Object)null) ? Minimap.instance.m_mapImageSmall : null); TMP_FontAsset val2 = (((Object)(object)instance != (Object)null && (Object)(object)instance.m_healthText != (Object)null) ? instance.m_healthText.font : null); if ((Object)(object)instance == (Object)null || (Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { return; } _building = true; try { GameObject val3 = new GameObject("SmartTerminalPanel", new Type[1] { typeof(RectTransform) }); _root = val3.GetComponent<RectTransform>(); ((Transform)_root).SetParent(((Component)((Graphic)val).canvas).transform, false); ((Transform)_root).SetAsFirstSibling(); RectTransform root = _root; Vector2 anchorMin = (_root.anchorMax = Vector2.zero); root.anchorMin = anchorMin; _root.pivot = new Vector2(1f, 1f); _root.sizeDelta = new Vector2(280f, 64f); ((Transform)_root).localScale = Vector3.one; Image obj = val3.AddComponent<Image>(); obj.sprite = MakePanelSprite(); obj.type = (Type)1; ((Graphic)obj).raycastTarget = false; GameObject val4 = new GameObject("TextTop", new Type[1] { typeof(RectTransform) }); RectTransform component = val4.GetComponent<RectTransform>(); ((Transform)component).SetParent((Transform)(object)_root, false); component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(0.5f, 1f); component.anchoredPosition = new Vector2(0f, -10f); _textTop = val4.AddComponent<TextMeshProUGUI>(); ConfigureText(_textTop, val2); GameObject val5 = new GameObject("BottomClip", new Type[1] { typeof(RectTransform) }); _bottomClip = val5.GetComponent<RectTransform>(); ((Transform)_bottomClip).SetParent((Transform)(object)_root, false); _bottomClip.anchorMin = new Vector2(0f, 1f); _bottomClip.anchorMax = new Vector2(1f, 1f); _bottomClip.pivot = new Vector2(0.5f, 1f); _bottomClip.sizeDelta = new Vector2(-28f, 0f); val5.AddComponent<RectMask2D>(); GameObject val6 = new GameObject("TextBottom", new Type[1] { typeof(RectTransform) }); RectTransform component2 = val6.GetComponent<RectTransform>(); ((Transform)component2).SetParent((Transform)(object)_bottomClip, false); component2.anchorMin = new Vector2(0f, 1f); component2.anchorMax = new Vector2(1f, 1f); component2.pivot = new Vector2(0.5f, 1f); _textBottom = val6.AddComponent<TextMeshProUGUI>(); ConfigureText(_textBottom, val2); SmartTerminalPlugin.Log.LogInfo((object)"HUD 面板已创建(uGUI,推挤动画)"); } finally { _building = false; } } private static void ConfigureText(TextMeshProUGUI text, TMP_FontAsset font) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)text).font = font; ((TMP_Text)text).fontSize = 16f; ((Graphic)text).color = ContentColor; ((TMP_Text)text).alignment = (TextAlignmentOptions)257; ((TMP_Text)text).enableWordWrapping = true; ((Graphic)text).raycastTarget = false; ((TMP_Text)text).overflowMode = (TextOverflowModes)0; } private static Sprite MakePanelSprite() { //IL_000c: 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_001a: Expected O, but got Unknown //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_0164: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false) { hideFlags = (HideFlags)52 }; Color[] array = (Color[])(object)new Color[16384]; Color val2 = default(Color); ((Color)(ref val2))..ctor(0.07f, 0.055f, 0.04f, 0.8f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.53f, 0.44f, 0.31f, 0.94f); Color val4 = default(Color); for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { float num = Mathf.Min((float)j + 0.5f, (float)(128 - j) - 0.5f); float num2 = Mathf.Min((float)i + 0.5f, (float)(128 - i) - 0.5f); float num5; if (num < 28f && num2 < 28f) { float num3 = 28f - num; float num4 = 28f - num2; num5 = 28f - Mathf.Sqrt(num3 * num3 + num4 * num4); } else { num5 = Mathf.Min(num, num2); } if (num5 < 0f) { float num6 = Mathf.Clamp01((num5 + 2f) / 2f); ((Color)(ref val4))..ctor(val3.r, val3.g, val3.b, val3.a * num6); } else { float num7 = Mathf.Clamp01((num5 - 4f) / 2f); val4 = Color.Lerp(val3, val2, num7); } array[i * 128 + j] = val4; } } val.SetPixels(array); val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(36f, 36f, 36f, 36f)); } } internal static class L10n { private static bool? _isChinese; private static readonly Dictionary<string, string> Zh = new Dictionary<string, string> { ["title"] = "智能终端", ["altitude"] = "海拔", ["time"] = "时间", ["timeFormat"] = "第 {0} 天", ["weather"] = "天气", ["dpsDealt"] = "输出", ["dpsTaken"] = "承伤", ["stamina"] = "体力恢复", ["health"] = "生命回复", ["block"] = "格挡", ["parry"] = "招架", ["waterAbove"] = "水上", ["perSec"] = " /s", ["perTick"] = "/tick", ["tickNote"] = "(10s)", ["waiting"] = "正在等待玩家进入世界…", ["staminaFull"] = "已满", ["staminaStoppedEncumbered"] = "停止(超重)", ["staminaDelay"] = "恢复延迟中", ["staminaNormal"] = "正常", ["staminaSlow"] = "较慢", ["staminaVerySlow"] = "很慢", ["staminaExtremelySlow"] = "极慢", ["staminaStalled"] = "停滞", ["blockingNote"] = "格挡", ["healthNoFood"] = "无进食回复", ["foodExpires"] = " {0}s 后食物耗尽", ["unarmed"] = "徒手", ["knockback"] = "击退", ["knockbackBlock"] = "格挡击退", ["knockbackParry"] = "招架击退", ["knockbackBlocked"] = "被格挡" }; private static readonly Dictionary<string, string> En = new Dictionary<string, string> { ["title"] = "Smart Terminal", ["altitude"] = "Altitude", ["time"] = "Time", ["timeFormat"] = "Day {0}", ["weather"] = "Weather", ["dpsDealt"] = "DMG dealt", ["dpsTaken"] = "DMG taken", ["stamina"] = "Stamina regen", ["health"] = "Health regen", ["block"] = "Block", ["parry"] = "Parry", ["waterAbove"] = "above water", ["perSec"] = " /s", ["perTick"] = "/tick", ["tickNote"] = " (10s)", ["waiting"] = "Waiting for player to enter world...", ["staminaFull"] = "Full", ["staminaStoppedEncumbered"] = "Stopped (encumbered)", ["staminaDelay"] = "Regen delay", ["staminaNormal"] = "Normal", ["staminaSlow"] = "Slow", ["staminaVerySlow"] = "Very slow", ["staminaExtremelySlow"] = "Barely", ["staminaStalled"] = "Stalled", ["blockingNote"] = "Block", ["healthNoFood"] = "No food regen", ["foodExpires"] = " food ends in {0}s", ["unarmed"] = "Unarmed", ["knockback"] = "Knockback", ["knockbackBlock"] = "Block knockback", ["knockbackParry"] = "Parry knockback", ["knockbackBlocked"] = "Blocked" }; public static bool IsChinese { get { if (_isChinese.HasValue) { return _isChinese.Value; } try { string text = ((Localization.instance != null) ? Localization.instance.GetSelectedLanguage() : null); _isChinese = text != null && (text.StartsWith("Chinese") || text.ToLowerInvariant().StartsWith("zh")); } catch { _isChinese = true; } return _isChinese.Value; } } public static string T(string key) { if (!(IsChinese ? Zh : En).TryGetValue(key, out var value)) { return key; } return value; } public static string F(string key, object arg) { return string.Format(T(key), arg); } } [BepInPlugin("com.brainaxe.smartterminal", "SmartTerminal", "1.0.4")] public class SmartTerminalPlugin : BaseUnityPlugin { public const string PluginGuid = "com.brainaxe.smartterminal"; public const string PluginName = "SmartTerminal"; public const string PluginVersion = "1.0.4"; internal static ManualLogSource Log; internal static ConfigEntry<int> HudOffsetX; internal static ConfigEntry<int> HudOffsetY; internal static ConfigEntry<float> HudScale; internal static ConfigEntry<float> RefreshInterval; internal static ConfigEntry<float> DamageWindow; internal static ConfigEntry<bool> ShowAltitude; internal static ConfigEntry<bool> ShowTime; internal static ConfigEntry<bool> ShowWeather; internal static ConfigEntry<bool> ShowDamageDealt; internal static ConfigEntry<bool> ShowDamageTaken; internal static ConfigEntry<bool> ShowRecovery; internal static ConfigEntry<bool> ShowBlock; internal static ConfigEntry<bool> ShowKnockback; private Harmony _harmony; private HudPanel _hud; private void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; BindConfigs(); _harmony = new Harmony("com.brainaxe.smartterminal"); DamageTracker.TryPatch(_harmony); _hud = ((Component)this).gameObject.AddComponent<HudPanel>(); Log.LogInfo((object)"智能终端 v1.0.4 已加载"); } private void BindConfigs() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown HudOffsetX = ((BaseUnityPlugin)this).Config.Bind<int>("0. 通用", "横向偏移", 0, new ConfigDescription("面板相对小地图下方锚点的横向偏移(像素,面板右边缘与小地图右边缘对齐)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-2000, 2000), Array.Empty<object>())); HudOffsetY = ((BaseUnityPlugin)this).Config.Bind<int>("0. 通用", "纵向偏移", 0, new ConfigDescription("面板相对小地图下方锚点的纵向偏移(像素)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-2000, 2000), Array.Empty<object>())); HudScale = ((BaseUnityPlugin)this).Config.Bind<float>("0. 通用", "额外缩放", 1f, new ConfigDescription("在跟随游戏 UI 缩放的基础上的额外倍率(0.5~2.0)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>())); RefreshInterval = ((BaseUnityPlugin)this).Config.Bind<float>("0. 通用", "刷新间隔", 0.25f, new ConfigDescription("数据刷新间隔秒数(0.1~2)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 2f), Array.Empty<object>())); DamageWindow = ((BaseUnityPlugin)this).Config.Bind<float>("0. 通用", "伤害统计窗口", 5f, new ConfigDescription("计算每秒伤害时回看的滑动窗口秒数(1~30)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 30f), Array.Empty<object>())); ShowAltitude = ((BaseUnityPlugin)this).Config.Bind<bool>("1. 显示内容", "显示海拔", true, (ConfigDescription)null); ShowTime = ((BaseUnityPlugin)this).Config.Bind<bool>("1. 显示内容", "显示时间", true, (ConfigDescription)null); ShowWeather = ((BaseUnityPlugin)this).Config.Bind<bool>("1. 显示内容", "显示天气", true, (ConfigDescription)null); ShowDamageDealt = ((BaseUnityPlugin)this).Config.Bind<bool>("1. 显示内容", "显示输出伤害", true, "每秒造成伤害(滑动窗口平均值)"); ShowDamageTaken = ((BaseUnityPlugin)this).Config.Bind<bool>("1. 显示内容", "显示承受伤害", true, "每秒承受伤害(滑动窗口平均值)"); ShowRecovery = ((BaseUnityPlugin)this).Config.Bind<bool>("1. 显示内容", "显示恢复状态", true, "体力恢复状态(正常/较慢/很慢等,含环境 debuff)与生命每 tick 回复量"); ShowBlock = ((BaseUnityPlugin)this).Config.Bind<bool>("1. 显示内容", "显示格挡数据", true, "当前格挡物的格挡力与招架计算值(含技能系数,随装备实时变化)"); ShowKnockback = ((BaseUnityPlugin)this).Config.Bind<bool>("1. 显示内容", "显示击退浮字", true, "造成/承受伤害或格挡时,以伤害数字样式显示击退值(蓝色)"); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }