using 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 BetterDisplay; using FishNet.Connection; using FishNet.Object; using HarmonyLib; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(BetterDisplayMod), "更好的显示", "0.4.3", "YourName", null)] [assembly: MelonColor(255, 43, 214, 255)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("BetterDisplay")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.4.3.0")] [assembly: AssemblyInformationalVersion("0.4.3")] [assembly: AssemblyProduct("BetterDisplay")] [assembly: AssemblyTitle("BetterDisplay")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.4.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BetterDisplay { [HarmonyPatch(typeof(Weapon), "Shoot")] internal static class WeaponShootCenterAimPatch { private sealed class AimState { internal readonly Transform FirePoint; internal readonly Quaternion OriginalRotation; internal AimState(Transform firePoint, Quaternion originalRotation) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) FirePoint = firePoint; OriginalRotation = originalRotation; } } private const float AimDistance = 10000f; [HarmonyPrefix] private static void Prefix(Weapon __instance, ref AimState __state) { //IL_0081: 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) if (!BetterDisplayConfig.BallisticCorrectionEnabled || (Object)(object)__instance == (Object)null) { return; } Player holder = ((Item)__instance).Holder; if (!((Object)(object)holder == (Object)null) && !(((NetworkBehaviour)holder).Owner == (NetworkConnection)null) && ((NetworkBehaviour)holder).Owner.IsLocalClient) { Camera curCam = holder.CurCam; Attachments attachments = __instance.Attachments; Transform val = (((Object)(object)attachments != (Object)null) ? attachments.FirePoint : null); if (!((Object)(object)curCam == (Object)null) && !((Object)(object)val == (Object)null) && TryGetCenterAimDirection(holder, curCam, val, out var direction)) { __state = new AimState(val, val.rotation); val.forward = direction; } } } [HarmonyPostfix] private static void Postfix(AimState __state) { Restore(__state); } [HarmonyFinalizer] private static Exception Finalizer(Exception __exception, AimState __state) { Restore(__state); return __exception; } private static void Restore(AimState state) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (state != null && !((Object)(object)state.FirePoint == (Object)null)) { state.FirePoint.rotation = state.OriginalRotation; } } private static bool TryGetCenterAimDirection(Player holder, Camera camera, Transform firePoint, out Vector3 direction) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0083: 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_00d5: 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) //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_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_00c2: 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) direction = Vector3.zero; if ((Object)(object)holder == (Object)null || (Object)(object)camera == (Object)null || (Object)(object)firePoint == (Object)null) { return false; } Ray val = camera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f)); Vector3 val2 = ((Ray)(ref val)).origin + ((Ray)(ref val)).direction * 10000f; int aimLayerMask = GetAimLayerMask(); RaycastHit[] array = Physics.RaycastAll(val, 10000f, aimLayerMask); float num = float.MaxValue; for (int i = 0; i < array.Length; i++) { RaycastHit val3 = array[i]; Transform transform = ((RaycastHit)(ref val3)).transform; if (!((Object)(object)transform == (Object)null) && !transform.IsChildOf(((Component)holder).transform) && ((RaycastHit)(ref val3)).distance < num) { num = ((RaycastHit)(ref val3)).distance; val2 = ((RaycastHit)(ref val3)).point; } } Vector3 val4 = val2 - firePoint.position; if (((Vector3)(ref val4)).sqrMagnitude < 0.0001f) { return false; } direction = ((Vector3)(ref val4)).normalized; return true; } private static int GetAimLayerMask() { //IL_0000: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) return LayerMask.op_Implicit(GameInfo.LevelLayer) | LayerMask.op_Implicit(GameInfo.PlayerLayer) | LayerMask.op_Implicit(GameInfo.ItemLayer) | LayerMask.op_Implicit(GameInfo.NpcLayer); } } internal static class BetterDisplayBossIndicator { private const float HorizontalEdgeOffset = 72f; private const float TopEdgeOffset = 72f; private const float BottomSafeOffset = 165f; private const float MinimumBossDistance = 5f; private const float MaximumBossDistance = 250f; private const float MinimumIconSize = 40f; private const float MaximumIconSize = 82f; private static readonly FieldInfo PlayerUiInstanceField = AccessTools.Field(typeof(PlayerUI), "_instance"); private static GameObject _root; private static RectTransform _rootRect; private static RectTransform _indicatorRect; private static Image _indicatorImage; private static Transform _hudParent; private static Creature _lastBoss; private static Renderer[] _bossRenderers; private static Sprite _fallbackSprite; private static Texture2D _fallbackTexture; internal static void Update() { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: 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_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0293: 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) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer == (Object)null) { Hide(); return; } if ((Object)(object)GetPlayerUi() == (Object)null || (Object)(object)PlayerUI.FXCanvasTrans == (Object)null || PlayerUI.UIDisabled) { Hide(); return; } Creature activeBoss = GetActiveBoss(); Camera curCam = localPlayer.CurCam; if ((Object)(object)activeBoss == (Object)null || (Object)(object)curCam == (Object)null) { Hide(); return; } Transform fXCanvasTrans = PlayerUI.FXCanvasTrans; if ((Object)(object)_root == (Object)null || (Object)(object)_hudParent != (Object)(object)fXCanvasTrans) { Recreate(fXCanvasTrans); } if ((Object)(object)_indicatorImage == (Object)null || (Object)(object)_indicatorRect == (Object)null || (Object)(object)_rootRect == (Object)null) { return; } if ((Object)(object)_lastBoss != (Object)(object)activeBoss) { _lastBoss = activeBoss; _bossRenderers = ((Component)activeBoss).GetComponentsInChildren(true); } Vector3 bossVisualPosition = GetBossVisualPosition(activeBoss); Vector3 val = curCam.WorldToViewportPoint(bossVisualPosition); bool flag = val.z <= 0f; if (!flag && IsInsideViewport(val)) { Hide(); return; } Rect rect = _rootRect.rect; Vector2 center = ((Rect)(ref rect)).center; Vector2 direction; Vector2 anchoredPosition = default(Vector2); if (flag) { float rearHorizontal = GetRearHorizontal(curCam, bossVisualPosition); float num = ((Rect)(ref rect)).xMin + 72f; float num2 = ((Rect)(ref rect)).xMax - 72f; float num3 = center.x + rearHorizontal * (num2 - center.x); Vector2 val2 = new Vector2(rearHorizontal * 0.65f, -1f); direction = ((Vector2)(ref val2)).normalized; ((Vector2)(ref anchoredPosition))..ctor(Mathf.Clamp(num3, num, num2), ((Rect)(ref rect)).yMin + 165f); } else { direction = new Vector2(((Rect)(ref rect)).xMin + val.x * ((Rect)(ref rect)).width, ((Rect)(ref rect)).yMin + val.y * ((Rect)(ref rect)).height) - center; if (((Vector2)(ref direction)).sqrMagnitude < 0.0001f) { Hide(); return; } anchoredPosition = ProjectToSafeEdge(center, direction, rect); } float num4 = Vector3.Distance(((Component)curCam).transform.position, bossVisualPosition); float num5 = Mathf.InverseLerp(250f, 5f, num4); float num6 = Mathf.Lerp(40f, 82f, num5); _indicatorRect.anchorMin = new Vector2(0.5f, 0.5f); _indicatorRect.anchorMax = new Vector2(0.5f, 0.5f); _indicatorRect.pivot = new Vector2(0.5f, 0.5f); _indicatorRect.anchoredPosition = anchoredPosition; _indicatorRect.sizeDelta = new Vector2(num6, num6); ((Transform)_indicatorRect).localRotation = Quaternion.Euler(0f, 0f, DirectionToRotation(direction)); ((Graphic)_indicatorImage).color = new Color(1f, 0.035f, 0.035f, 1f); ((Component)_indicatorImage).gameObject.SetActive(true); } internal static void Close() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } if ((Object)(object)_fallbackSprite != (Object)null) { Object.Destroy((Object)(object)_fallbackSprite); } if ((Object)(object)_fallbackTexture != (Object)null) { Object.Destroy((Object)(object)_fallbackTexture); } _root = null; _rootRect = null; _indicatorRect = null; _indicatorImage = null; _hudParent = null; _lastBoss = null; _bossRenderers = null; _fallbackSprite = null; _fallbackTexture = null; } private static PlayerUI GetPlayerUi() { if (PlayerUiInstanceField == null) { return null; } object? value = PlayerUiInstanceField.GetValue(null); return (PlayerUI)((value is PlayerUI) ? value : null); } private static Creature GetActiveBoss() { Creature boss = BossManager.Boss; if (!((Object)(object)boss == (Object)null) && !boss.IsDead) { return boss; } return null; } private static Vector3 GetBossVisualPosition(Creature boss) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (_bossRenderers == null || _bossRenderers.Length == 0) { return ((Component)boss).transform.position; } Bounds val = default(Bounds); bool flag = false; for (int i = 0; i < _bossRenderers.Length; i++) { Renderer val2 = _bossRenderers[i]; if (!((Object)(object)val2 == (Object)null)) { if (!flag) { val = val2.bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(val2.bounds); } } } if (!flag) { return ((Component)boss).transform.position; } return ((Bounds)(ref val)).center; } private static bool IsInsideViewport(Vector3 viewport) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0027: Unknown result type (might be due to invalid IL or missing references) if (viewport.x >= 0f && viewport.x <= 1f && viewport.y >= 0f) { return viewport.y <= 1f; } return false; } private static float GetRearHorizontal(Camera camera, Vector3 bossPosition) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)camera).transform.InverseTransformDirection(bossPosition - ((Component)camera).transform.position); float num = Mathf.Max(0f - val.z, 0.001f); return Mathf.Clamp(Mathf.Atan2(val.x, num) / ((float)Math.PI / 2f), -1f, 1f); } private static Vector2 ProjectToSafeEdge(Vector2 center, Vector2 direction, Rect rootBounds) { //IL_003f: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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) float num = ((Rect)(ref rootBounds)).xMin + 72f; float num2 = ((Rect)(ref rootBounds)).xMax - 72f; float num3 = ((Rect)(ref rootBounds)).yMin + 165f; float num4 = ((Rect)(ref rootBounds)).yMax - 72f; float num5 = float.MaxValue; if (direction.x > 0f) { num5 = Mathf.Min(num5, (num2 - center.x) / direction.x); } else if (direction.x < 0f) { num5 = Mathf.Min(num5, (num - center.x) / direction.x); } if (direction.y > 0f) { num5 = Mathf.Min(num5, (num4 - center.y) / direction.y); } else if (direction.y < 0f) { num5 = Mathf.Min(num5, (num3 - center.y) / direction.y); } if (num5 == float.MaxValue || num5 < 0f) { return center; } return center + direction * num5; } private static float DirectionToRotation(Vector2 direction) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return Mathf.Atan2(direction.y, direction.x) * 57.29578f - 90f; } private static void Recreate(Transform hudParent) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_008e: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } _hudParent = hudParent; _root = new GameObject("BetterDisplayBossIndicator", new Type[1] { typeof(RectTransform) }); _root.transform.SetParent(hudParent, false); _rootRect = _root.GetComponent(); SetFullStretch(_rootRect); GameObject val = new GameObject("BossDirectionMarker", new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(_root.transform, false); _indicatorRect = val.GetComponent(); _indicatorRect.sizeDelta = new Vector2(40f, 40f); _indicatorImage = val.GetComponent(); _indicatorImage.sprite = GetFallbackSprite(); ((Graphic)_indicatorImage).color = new Color(1f, 0.035f, 0.035f, 1f); _indicatorImage.type = (Type)0; _indicatorImage.preserveAspect = true; ((Graphic)_indicatorImage).raycastTarget = false; Outline obj = val.AddComponent(); ((Shadow)obj).effectColor = new Color(0.02f, 0f, 0f, 0.95f); ((Shadow)obj).effectDistance = new Vector2(2f, 2f); ((Shadow)obj).useGraphicAlpha = true; val.SetActive(false); } private static Sprite GetFallbackSprite() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_fallbackSprite != (Object)null) { return _fallbackSprite; } _fallbackTexture = new Texture2D(64, 64, (TextureFormat)4, false); ((Object)_fallbackTexture).name = "BetterDisplayBossDropTexture"; ((Texture)_fallbackTexture).wrapMode = (TextureWrapMode)1; ((Texture)_fallbackTexture).filterMode = (FilterMode)1; Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num = ((float)j + 0.5f) / 64f * 2f - 1f; float num2 = ((float)i + 0.5f) / 64f * 2f - 1f; bool flag = num * num + (num2 + 0.22f) * (num2 + 0.22f) <= 0.33639997f; bool flag2 = num2 >= -0.1f && num2 <= 0.92f && Mathf.Abs(num) <= 0.58f * (1f - Mathf.InverseLerp(-0.1f, 0.92f, num2)); array[i * 64 + j] = ((flag || flag2) ? new Color32(byte.MaxValue, (byte)9, (byte)9, byte.MaxValue) : new Color32((byte)0, (byte)0, (byte)0, (byte)0)); } } _fallbackTexture.SetPixels32(array); _fallbackTexture.Apply(false, false); _fallbackSprite = Sprite.Create(_fallbackTexture, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 64f); ((Object)_fallbackSprite).name = "BetterDisplayBossDrop"; return _fallbackSprite; } private static void Hide() { if ((Object)(object)_indicatorImage != (Object)null) { ((Component)_indicatorImage).gameObject.SetActive(false); } } private static void SetFullStretch(RectTransform rect) { //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) rect.anchorMin = Vector2.zero; rect.anchorMax = Vector2.one; rect.pivot = new Vector2(0.5f, 0.5f); rect.offsetMin = Vector2.zero; rect.offsetMax = Vector2.zero; } } internal static class BetterDisplayGunStabilizer { private static readonly FieldInfo LookRotField = AccessTools.Field(typeof(PlayerToolMovement), "_lookRot"); private static readonly FieldInfo ToolSwayTargetField = AccessTools.Field(typeof(PlayerToolMovement), "_toolSwayTarget"); internal static bool IsLocalWeapon(PlayerToolMovement movement) { if ((Object)(object)movement == (Object)null) { return false; } Tool currentTool = movement.CurrentTool; Weapon val = (((Object)(object)currentTool != (Object)null) ? ((Item)currentTool).Weapon : null); Player val2 = (((Object)(object)val != (Object)null) ? ((Item)val).Holder : null); if ((Object)(object)val2 != (Object)null && ((NetworkBehaviour)val2).Owner != (NetworkConnection)null) { return ((NetworkBehaviour)val2).Owner.IsLocalClient; } return false; } internal static void ClearLookAround(PlayerToolMovement movement) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)movement == (Object)null) { return; } if (LookRotField != null) { LookRotField.SetValue(movement, Vector3.zero); } if (!(ToolSwayTargetField == null)) { object? value = ToolSwayTargetField.GetValue(movement); Transform val = (Transform)((value is Transform) ? value : null); if ((Object)(object)val != (Object)null && (Object)(object)val.parent != (Object)null) { val.parent.localEulerAngles = Vector3.zero; } } } } [HarmonyPatch(typeof(PlayerToolMovement), "LookAround")] internal static class PlayerToolMovementLookAroundPatch { [HarmonyPrefix] private static bool Prefix(PlayerToolMovement __instance) { if (!BetterDisplayConfig.BallisticCorrectionEnabled || !BetterDisplayGunStabilizer.IsLocalWeapon(__instance)) { return true; } BetterDisplayGunStabilizer.ClearLookAround(__instance); return false; } } [HarmonyPatch(typeof(PlayerToolMovement), "SetTool")] internal static class PlayerToolMovementSetToolPatch { [HarmonyPostfix] private static void Postfix(PlayerToolMovement __instance) { if (BetterDisplayConfig.BallisticCorrectionEnabled && BetterDisplayGunStabilizer.IsLocalWeapon(__instance)) { BetterDisplayGunStabilizer.ClearLookAround(__instance); } } } internal static class BetterDisplayHud { private static readonly FieldInfo PlayerUiInstanceField = AccessTools.Field(typeof(PlayerUI), "_instance"); private static readonly FieldInfo WeaponUiField = AccessTools.Field(typeof(PlayerUI), "weaponUI"); private static readonly FieldInfo SniperUiVisibleField = AccessTools.Field(typeof(WeaponUI), "_isShowingSniperUI"); private static readonly FieldInfo VitalsUiField = AccessTools.Field(typeof(PlayerUI), "_vitalsUI"); private static readonly FieldInfo HealthImageField = AccessTools.Field(typeof(VitalsUI), "_healthImage"); private static readonly FieldInfo FullnessImageField = AccessTools.Field(typeof(VitalsUI), "_fullnessImage"); private static readonly FieldInfo MaxHealthField = AccessTools.Field(typeof(PlayerVitals), "_maxHealth"); private static readonly FieldInfo MaxFullnessField = AccessTools.Field(typeof(PlayerVitals), "_maxFullness"); private static PlayerUI _playerUi; private static Transform _hudParent; private static GameObject _root; private static GameObject _crosshair; private static TextMeshProUGUI _foodText; private static TextMeshProUGUI _ammoText; private static TextMeshProUGUI _healthValueText; private static TextMeshProUGUI _fullnessValueText; internal static void Update() { Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer == (Object)null) { HideHud(); return; } PlayerUI playerUi = GetPlayerUi(); if ((Object)(object)playerUi == (Object)null || (Object)(object)PlayerUI.FXCanvasTrans == (Object)null) { HideHud(); return; } Transform fXCanvasTrans = PlayerUI.FXCanvasTrans; if ((Object)(object)_root == (Object)null || (Object)(object)_hudParent != (Object)(object)fXCanvasTrans || (Object)(object)_playerUi != (Object)(object)playerUi) { RecreateHud(playerUi, fXCanvasTrans); } if ((Object)(object)_root == (Object)null) { return; } Item val = (((Object)(object)localPlayer.Holding != (Object)null) ? localPlayer.Holding.HeldItem : null); Weapon val2 = (((Object)(object)val != (Object)null) ? val.Weapon : null); Creature val3 = (((Object)(object)val != (Object)null) ? val.Creature : null); bool flag = !PlayerUI.UIDisabled; bool flag2 = (Object)(object)val2 != (Object)null; bool flag3 = IsSniperUiVisible(playerUi); bool active = flag && flag2 && !flag3; _crosshair.SetActive(active); bool flag4 = flag && BetterDisplayConfig.AmmoDisplayEnabled && flag2 && (Object)(object)val2.Attachments != (Object)null; if (flag4) { int ammoPerMag = val2.Attachments.AmmoPerMag; flag4 = ammoPerMag > 0; if (flag4) { ((TMP_Text)_ammoText).text = $"{val2.Ammo}/{ammoPerMag}"; } } ((Component)_ammoText).gameObject.SetActive(flag4); bool flag5 = flag && BetterDisplayConfig.FoodInfoEnabled && (Object)(object)val3 != (Object)null && (val3.HpToRestore != 0 || val3.FullnessToRestore != 0); if (flag5) { int effectiveFoodValue = GetEffectiveFoodValue(val3.HpToRestore, val); int effectiveFoodValue2 = GetEffectiveFoodValue(val3.FullnessToRestore, val); ((TMP_Text)_foodText).text = $"生命 {FormatSigned(effectiveFoodValue)} 饥饿 {FormatSigned(effectiveFoodValue2)}"; } ((Component)_foodText).gameObject.SetActive(flag5); UpdateVitals(playerUi, localPlayer, flag && BetterDisplayConfig.VitalsDisplayEnabled); } internal static void Close() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } HideHud(); _root = null; _crosshair = null; _foodText = null; _ammoText = null; _healthValueText = null; _fullnessValueText = null; _hudParent = null; _playerUi = null; } private static PlayerUI GetPlayerUi() { if (PlayerUiInstanceField != null) { object? value = PlayerUiInstanceField.GetValue(null); return (PlayerUI)((value is PlayerUI) ? value : null); } return null; } private static bool IsSniperUiVisible(PlayerUI playerUi) { if (WeaponUiField == null || SniperUiVisibleField == null) { return false; } object? value = WeaponUiField.GetValue(playerUi); WeaponUI val = (WeaponUI)((value is WeaponUI) ? value : null); if ((Object)(object)val != (Object)null) { return (bool)SniperUiVisibleField.GetValue(val); } return false; } private static void RecreateHud(PlayerUI playerUi, Transform hudParent) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_009c: 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) if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } _playerUi = playerUi; _hudParent = hudParent; _root = new GameObject("BetterDisplayHud", new Type[1] { typeof(RectTransform) }); _root.transform.SetParent(hudParent, false); SetFullStretch(_root.GetComponent()); _crosshair = CreateCrosshair(_root.transform); _foodText = CreateStatusText(_root.transform, "FoodRestoreText", 330f, 40f, new Vector2(-50f, 112f), 20f, (TextAlignmentOptions)1028); _ammoText = CreateStatusText(_root.transform, "AmmoText", 245f, 48f, new Vector2(-50f, 62f), 27f, (TextAlignmentOptions)1028); _healthValueText = CreateVitalValueText(_root.transform, "HealthValueText"); _fullnessValueText = CreateVitalValueText(_root.transform, "FullnessValueText"); ((Component)_foodText).gameObject.SetActive(false); ((Component)_ammoText).gameObject.SetActive(false); ((Component)_healthValueText).gameObject.SetActive(false); ((Component)_fullnessValueText).gameObject.SetActive(false); } private static void UpdateVitals(PlayerUI playerUi, Player localPlayer, bool uiVisible) { //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) if (!uiVisible || (Object)(object)playerUi == (Object)null || (Object)(object)localPlayer.Vitals == (Object)null || VitalsUiField == null) { ((Component)_healthValueText).gameObject.SetActive(false); ((Component)_fullnessValueText).gameObject.SetActive(false); return; } object? value = VitalsUiField.GetValue(playerUi); VitalsUI val = (VitalsUI)((value is VitalsUI) ? value : null); Image val2 = (Image)((HealthImageField != null && (Object)(object)val != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); Image val3 = (Image)((FullnessImageField != null && (Object)(object)val != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); int privateInt = GetPrivateInt(MaxHealthField, localPlayer.Vitals); int privateInt2 = GetPrivateInt(MaxFullnessField, localPlayer.Vitals); ((TMP_Text)_healthValueText).text = FormatVitalValue(localPlayer.Vitals.Health, privateInt); ((TMP_Text)_fullnessValueText).text = FormatVitalValue(localPlayer.Vitals.Fullness, privateInt2); bool flag = (Object)(object)val2 != (Object)null && PlaceValueUnderIcon(_healthValueText, val2); bool flag2 = (Object)(object)val3 != (Object)null && PlaceValueUnderIcon(_fullnessValueText, val3); if (flag && flag2) { RectTransform component = ((Component)_healthValueText).GetComponent(); RectTransform component2 = ((Component)_fullnessValueText).GetComponent(); Vector2 anchoredPosition = component2.anchoredPosition; anchoredPosition.y = component.anchoredPosition.y; component2.anchoredPosition = anchoredPosition; } ((Component)_healthValueText).gameObject.SetActive(flag); ((Component)_fullnessValueText).gameObject.SetActive(flag2); } private static string FormatVitalValue(int current, int maximum) { if (maximum <= 0) { return current.ToString(); } return $"{current}/{maximum}"; } private static int GetPrivateInt(FieldInfo field, object instance) { if (field == null || instance == null) { return 0; } return (int)field.GetValue(instance); } private static TextMeshProUGUI CreateVitalValueText(Transform parent, string name) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 1f); component.sizeDelta = new Vector2(120f, 30f); TextMeshProUGUI component2 = val.GetComponent(); TMP_FontAsset gameFont = GetGameFont(); if ((Object)(object)gameFont != (Object)null) { ((TMP_Text)component2).font = gameFont; } ((TMP_Text)component2).fontSize = 17f; ((Graphic)component2).color = Color.white; ((TMP_Text)component2).alignment = (TextAlignmentOptions)514; ((TMP_Text)component2).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)component2).overflowMode = (TextOverflowModes)1; ((TMP_Text)component2).enableAutoSizing = false; ((Graphic)component2).raycastTarget = false; ((TMP_Text)component2).outlineWidth = 0.24f; ((TMP_Text)component2).outlineColor = Color32.op_Implicit(new Color(0f, 0f, 0f, 0.95f)); return component2; } private static bool PlaceValueUnderIcon(TextMeshProUGUI text, Image icon) { //IL_0072: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00dd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)text == (Object)null || (Object)(object)icon == (Object)null || (Object)(object)_root == (Object)null) { return false; } RectTransform component = ((Component)icon).GetComponent(); RectTransform component2 = _root.GetComponent(); Canvas val = (((Object)(object)_hudParent != (Object)null) ? ((Component)_hudParent).GetComponentInParent() : null); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { return false; } Vector3[] array = (Vector3[])(object)new Vector3[4]; component.GetWorldCorners(array); Vector3 val2 = (array[0] + array[3]) * 0.5f; Camera val3 = (((Object)(object)val != (Object)null && (int)val.renderMode != 0) ? val.worldCamera : null); Vector2 val4 = RectTransformUtility.WorldToScreenPoint(val3, val2); Vector2 val5 = default(Vector2); if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(component2, val4, val3, ref val5)) { return false; } ((Component)text).GetComponent().anchoredPosition = val5 + new Vector2(0f, -5f); return true; } private static GameObject CreateCrosshair(Transform parent) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown GameObject val = new GameObject("Crosshair", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); SetFullStretch(val.GetComponent()); CreateCrosshairLine(val.transform, "Horizontal", new Vector2(26f, 1.8f)); CreateCrosshairLine(val.transform, "Vertical", new Vector2(1.8f, 26f)); CreateCrosshairLine(val.transform, "Center", new Vector2(3.2f, 3.2f)); return val; } private static void CreateCrosshairLine(Transform parent, string name, Vector2 size) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); component.anchoredPosition = Vector2.zero; component.sizeDelta = size; Image component2 = val.GetComponent(); ((Graphic)component2).color = new Color(1f, 1f, 1f, 0.96f); ((Graphic)component2).raycastTarget = false; Outline obj = val.AddComponent(); ((Shadow)obj).effectColor = new Color(0f, 0f, 0f, 0.9f); ((Shadow)obj).effectDistance = new Vector2(0.85f, 0.85f); ((Shadow)obj).useGraphicAlpha = true; } private static TextMeshProUGUI CreateStatusText(Transform parent, string name, float width, float height, Vector2 position, float fontSize, TextAlignmentOptions alignment) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent(); component.anchorMin = new Vector2(1f, 0f); component.anchorMax = new Vector2(1f, 0f); component.pivot = new Vector2(1f, 0f); component.anchoredPosition = position; component.sizeDelta = new Vector2(width, height); TextMeshProUGUI component2 = val.GetComponent(); TMP_FontAsset gameFont = GetGameFont(); if ((Object)(object)gameFont != (Object)null) { ((TMP_Text)component2).font = gameFont; } ((TMP_Text)component2).fontSize = fontSize; ((Graphic)component2).color = Color.white; ((TMP_Text)component2).alignment = alignment; ((TMP_Text)component2).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)component2).overflowMode = (TextOverflowModes)1; ((TMP_Text)component2).enableAutoSizing = false; ((TMP_Text)component2).richText = true; ((Graphic)component2).raycastTarget = false; ((TMP_Text)component2).outlineWidth = 0.22f; ((TMP_Text)component2).outlineColor = Color32.op_Implicit(new Color(0f, 0f, 0f, 0.95f)); return component2; } private static TMP_FontAsset GetGameFont() { if ((Object)(object)PlayerUI.CanvasTextPrefab != (Object)null) { return ((TMP_Text)PlayerUI.CanvasTextPrefab).font; } TextMeshProUGUI val = Object.FindAnyObjectByType(); if (!((Object)(object)val != (Object)null)) { return null; } return ((TMP_Text)val).font; } private static string FormatSigned(int value) { if (value < 0) { return value.ToString(); } return "+" + value; } private static int GetEffectiveFoodValue(int baseValue, Item foodItem) { if ((Object)(object)foodItem == (Object)null || GameInfo.CooknessEatCurve == null) { return baseValue; } float num = GameInfo.CooknessEatCurve.Evaluate(foodItem.Cookness); return (int)((float)baseValue * num); } private static void HideHud() { if ((Object)(object)_crosshair != (Object)null) { _crosshair.SetActive(false); } if ((Object)(object)_foodText != (Object)null) { ((Component)_foodText).gameObject.SetActive(false); } if ((Object)(object)_ammoText != (Object)null) { ((Component)_ammoText).gameObject.SetActive(false); } if ((Object)(object)_healthValueText != (Object)null) { ((Component)_healthValueText).gameObject.SetActive(false); } if ((Object)(object)_fullnessValueText != (Object)null) { ((Component)_fullnessValueText).gameObject.SetActive(false); } } private static void SetFullStretch(RectTransform rect) { //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) rect.anchorMin = Vector2.zero; rect.anchorMax = Vector2.one; rect.pivot = new Vector2(0.5f, 0.5f); rect.offsetMin = Vector2.zero; rect.offsetMax = Vector2.zero; } } internal static class BetterDisplayMenu { [HarmonyPatch(typeof(ButtonManager), "SetupUI")] internal static class ButtonManagerSetupUiPatch { [HarmonyPostfix] private static void Postfix(ButtonManager __instance) { AttachToSettings(__instance); } } private sealed class CategoryView { internal readonly MarkerCategory Category; internal readonly List Swatches = new List(); internal CategoryView(MarkerCategory category) { Category = category; } } private sealed class SwatchView { internal readonly ColorPreset Preset; internal readonly Outline Selection; internal SwatchView(ColorPreset preset, Outline selection) { Preset = preset; Selection = selection; } } private sealed class ColorPreset { internal readonly string Name; internal readonly Color Color; internal readonly bool UseOriginal; internal ColorPreset(string name, Color color, bool useOriginal) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Name = name; Color = color; UseOriginal = useOriginal; } } [CompilerGenerated] private static class <>O { public static UnityAction <0>__Open; public static UnityAction <1>__ToggleEnabled; public static UnityAction <2>__TogglePulse; public static UnityAction <3>__ToggleBallisticCorrection; public static UnityAction <4>__ToggleAmmoDisplay; public static UnityAction <5>__ToggleFoodInfo; public static UnityAction <6>__ToggleVitalsDisplay; public static UnityAction <7>__ResetAllColors; public static UnityAction <8>__Close; } private const float PanelWidth = 970f; private const float PanelHeight = 585f; private static readonly FieldInfo ItemDotsToggleField = AccessTools.Field(typeof(ButtonManager), "_itemDotsToggle"); private static readonly Color BorderColor = new Color(0.94f, 0.95f, 0.98f, 0.92f); private static readonly Color PanelColor = new Color(0.035f, 0.055f, 0.095f, 0.95f); private static readonly Color RowColor = new Color(0.08f, 0.11f, 0.17f, 0.58f); private static readonly Color ButtonColor = new Color(0.1f, 0.14f, 0.21f, 0.9f); private static readonly Color TextColor = new Color(0.94f, 0.95f, 0.98f, 1f); private static readonly Color MutedTextColor = new Color(0.72f, 0.76f, 0.83f, 1f); private static readonly Color SelectedColor = new Color(1f, 0.79f, 0.27f, 1f); private static readonly ColorPreset[] Presets = new ColorPreset[7] { new ColorPreset("原版", new Color(0.56f, 0.6f, 0.67f, 1f), useOriginal: true), new ColorPreset("红色", new Color(1f, 0.302f, 0.302f, 1f), useOriginal: false), new ColorPreset("青蓝", new Color(0.302f, 0.733f, 1f, 1f), useOriginal: false), new ColorPreset("亮黄", new Color(1f, 0.831f, 0.278f, 1f), useOriginal: false), new ColorPreset("洋红", new Color(1f, 0.1686f, 0.8392f, 1f), useOriginal: false), new ColorPreset("绿色", new Color(0.404f, 0.902f, 0.404f, 1f), useOriginal: false), new ColorPreset("白色", Color.white, useOriginal: false) }; private static readonly List CategoryViews = new List(); private static Canvas _canvas; private static Button _openButton; private static GameObject _panel; private static TextMeshProUGUI _enabledLabel; private static TextMeshProUGUI _pulseLabel; private static TextMeshProUGUI _ballisticCorrectionLabel; private static TextMeshProUGUI _ammoDisplayLabel; private static TextMeshProUGUI _foodInfoLabel; private static TextMeshProUGUI _vitalsDisplayLabel; private static TMP_FontAsset _font; internal static void AttachToSettings(ButtonManager manager) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown if ((Object)(object)manager == (Object)null) { return; } object? value = ItemDotsToggleField.GetValue(manager); Toggle val = (Toggle)((value is Toggle) ? value : null); if ((Object)(object)val == (Object)null) { return; } Canvas componentInParent = ((Component)val).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { return; } SwitchCanvas(componentInParent); EnsurePanel(componentInParent); if ((Object)(object)_openButton == (Object)null) { Transform obj = FindButtonParent(((Component)val).transform); _openButton = CreateVanillaButton(obj, "BetterDisplayOpenButton", "更好的显示", 190f, 42f, 17f); ButtonClickedEvent onClick = _openButton.onClick; object obj2 = <>O.<0>__Open; if (obj2 == null) { UnityAction val2 = Open; <>O.<0>__Open = val2; obj2 = (object)val2; } ((UnityEvent)onClick).AddListener((UnityAction)obj2); if ((Object)(object)((Component)obj).GetComponent() == (Object)null) { PositionBesideToggle(((Component)_openButton).GetComponent(), val); } } } internal static void Update() { if (Keyboard.current != null && ((ButtonControl)Keyboard.current.f8Key).wasPressedThisFrame) { Toggle(); } } internal static void Open() { if ((Object)(object)_panel == (Object)null) { ButtonManager val = Object.FindAnyObjectByType(); if ((Object)(object)val != (Object)null) { AttachToSettings(val); } } if ((Object)(object)_panel == (Object)null) { Canvas val2 = Object.FindAnyObjectByType(); if ((Object)(object)val2 != (Object)null) { SwitchCanvas(val2); EnsurePanel(val2); } } if (!((Object)(object)_panel == (Object)null)) { _panel.SetActive(true); _panel.transform.SetAsLastSibling(); Refresh(); } } internal static void Close() { if ((Object)(object)_panel != (Object)null) { _panel.SetActive(false); } } private static void Toggle() { if ((Object)(object)_panel != (Object)null && _panel.activeSelf) { Close(); } else { Open(); } } private static void SwitchCanvas(Canvas canvas) { if ((Object)(object)_canvas != (Object)null && (Object)(object)_canvas != (Object)(object)canvas) { ResetForNewCanvas(); } _canvas = canvas; } private static void ResetForNewCanvas() { Close(); _openButton = null; _panel = null; _canvas = null; _font = null; CategoryViews.Clear(); _enabledLabel = null; _pulseLabel = null; _ballisticCorrectionLabel = null; _ammoDisplayLabel = null; _foodInfoLabel = null; _vitalsDisplayLabel = null; } private static void EnsurePanel(Canvas canvas) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_011f: 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_013e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_panel != (Object)null)) { CategoryViews.Clear(); _enabledLabel = null; _pulseLabel = null; _ballisticCorrectionLabel = null; _ammoDisplayLabel = null; _foodInfoLabel = null; _vitalsDisplayLabel = null; FindFont(canvas); _panel = new GameObject("BetterDisplaySettingsPanel", new Type[2] { typeof(RectTransform), typeof(Image) }); _panel.transform.SetParent(((Component)canvas).transform, false); SetFullStretch(_panel.GetComponent()); Image component = _panel.GetComponent(); ((Graphic)component).color = new Color(0f, 0f, 0f, 0.52f); ((Graphic)component).raycastTarget = true; GameObject obj = CreateUiObject(_panel.transform, "Content"); RectTransform component2 = obj.GetComponent(); component2.anchorMin = new Vector2(0.5f, 0.5f); component2.anchorMax = new Vector2(0.5f, 0.5f); component2.pivot = new Vector2(0.5f, 0.5f); component2.anchoredPosition = Vector2.zero; component2.sizeDelta = new Vector2(970f, 585f); AddBackground(obj, PanelColor, addBorder: true); CreateHeader(obj.transform, 242f); CreateHint(obj.transform, 196f); CreateDivider(obj.transform, 174f); CreateGlobalSettings(obj.transform, 136f); CreateInfoSettings(obj.transform, 84f); CreateCategoryRow(obj.transform, MarkerCategory.Enemy, "敌对生物", "活着的生物", 12f); CreateCategoryRow(obj.transform, MarkerCategory.Player, "玩家标记", "死亡玩家的物品", -77f); CreateCategoryRow(obj.transform, MarkerCategory.Pickup, "可拾取物品", "普通物品与死亡生物", -166f); CreateFooter(obj.transform, -244f); _panel.SetActive(false); } } private static void CreateHeader(Transform parent, float y) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)CreateText(CreatePositionedBlock(parent, "Header", 914f, 54f, y).transform, "Title", "更好的显示", 30f, TextColor, (TextAlignmentOptions)514)).fontStyle = (FontStyles)0; } private static void CreateHint(Transform parent, float y) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = CreateText(CreatePositionedBlock(parent, "Hint", 914f, 28f, y).transform, "HintText", "选择颜色以覆盖原版;选择“原版”可还原该类别。按 F8 可打开或关闭本菜单。", 15f, MutedTextColor, (TextAlignmentOptions)514); ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)obj).overflowMode = (TextOverflowModes)1; } private static void CreateDivider(Transform parent, float y) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) Image obj = CreatePositionedBlock(parent, "Divider", 914f, 1f, y).AddComponent(); ((Graphic)obj).color = new Color(BorderColor.r, BorderColor.g, BorderColor.b, 0.52f); ((Graphic)obj).raycastTarget = false; } private static void CreateGlobalSettings(Transform parent, float y) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown GameObject obj = CreatePositionedBlock(parent, "GlobalSettings", 914f, 48f, y); CreateTextAt(obj.transform, "GlobalLabel", "显示效果", 20f, TextColor, (TextAlignmentOptions)4097, new Vector2(0f, 0.5f), new Vector2(250f, 38f), new Vector2(12f, 0f)); Button obj2 = CreateVanillaButton(obj.transform, "EnabledButton", string.Empty, 170f, 38f, 16f); SetAt(((Component)obj2).GetComponent(), new Vector2(-90f, 0f)); _enabledLabel = GetButtonLabel(obj2); ButtonClickedEvent onClick = obj2.onClick; object obj3 = <>O.<1>__ToggleEnabled; if (obj3 == null) { UnityAction val = ToggleEnabled; <>O.<1>__ToggleEnabled = val; obj3 = (object)val; } ((UnityEvent)onClick).AddListener((UnityAction)obj3); Button obj4 = CreateVanillaButton(obj.transform, "PulseButton", string.Empty, 170f, 38f, 16f); SetAt(((Component)obj4).GetComponent(), new Vector2(95f, 0f)); _pulseLabel = GetButtonLabel(obj4); ButtonClickedEvent onClick2 = obj4.onClick; object obj5 = <>O.<2>__TogglePulse; if (obj5 == null) { UnityAction val2 = TogglePulse; <>O.<2>__TogglePulse = val2; obj5 = (object)val2; } ((UnityEvent)onClick2).AddListener((UnityAction)obj5); Button obj6 = CreateVanillaButton(obj.transform, "CenterAimButton", string.Empty, 170f, 38f, 16f); SetAt(((Component)obj6).GetComponent(), new Vector2(280f, 0f)); _ballisticCorrectionLabel = GetButtonLabel(obj6); ButtonClickedEvent onClick3 = obj6.onClick; object obj7 = <>O.<3>__ToggleBallisticCorrection; if (obj7 == null) { UnityAction val3 = ToggleBallisticCorrection; <>O.<3>__ToggleBallisticCorrection = val3; obj7 = (object)val3; } ((UnityEvent)onClick3).AddListener((UnityAction)obj7); } private static void CreateInfoSettings(Transform parent, float y) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown GameObject obj = CreatePositionedBlock(parent, "InfoSettings", 914f, 48f, y); CreateTextAt(obj.transform, "InfoLabel", "附加显示", 20f, TextColor, (TextAlignmentOptions)4097, new Vector2(0f, 0.5f), new Vector2(250f, 38f), new Vector2(12f, 0f)); Button obj2 = CreateVanillaButton(obj.transform, "AmmoDisplayButton", string.Empty, 170f, 38f, 16f); SetAt(((Component)obj2).GetComponent(), new Vector2(-90f, 0f)); _ammoDisplayLabel = GetButtonLabel(obj2); ButtonClickedEvent onClick = obj2.onClick; object obj3 = <>O.<4>__ToggleAmmoDisplay; if (obj3 == null) { UnityAction val = ToggleAmmoDisplay; <>O.<4>__ToggleAmmoDisplay = val; obj3 = (object)val; } ((UnityEvent)onClick).AddListener((UnityAction)obj3); Button obj4 = CreateVanillaButton(obj.transform, "FoodInfoButton", string.Empty, 170f, 38f, 16f); SetAt(((Component)obj4).GetComponent(), new Vector2(95f, 0f)); _foodInfoLabel = GetButtonLabel(obj4); ButtonClickedEvent onClick2 = obj4.onClick; object obj5 = <>O.<5>__ToggleFoodInfo; if (obj5 == null) { UnityAction val2 = ToggleFoodInfo; <>O.<5>__ToggleFoodInfo = val2; obj5 = (object)val2; } ((UnityEvent)onClick2).AddListener((UnityAction)obj5); Button obj6 = CreateVanillaButton(obj.transform, "VitalsDisplayButton", string.Empty, 170f, 38f, 16f); SetAt(((Component)obj6).GetComponent(), new Vector2(280f, 0f)); _vitalsDisplayLabel = GetButtonLabel(obj6); ButtonClickedEvent onClick3 = obj6.onClick; object obj7 = <>O.<6>__ToggleVitalsDisplay; if (obj7 == null) { UnityAction val3 = ToggleVitalsDisplay; <>O.<6>__ToggleVitalsDisplay = val3; obj7 = (object)val3; } ((UnityEvent)onClick3).AddListener((UnityAction)obj7); } private static void CreateCategoryRow(Transform parent, MarkerCategory category, string title, string subtitle, float y) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_00a2: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Expected O, but got Unknown GameObject obj = CreatePositionedBlock(parent, title + "Row", 914f, 80f, y); AddBackground(obj, RowColor, addBorder: false); ((TMP_Text)CreateTextAt(obj.transform, "CategoryTitle", title, 19f, TextColor, (TextAlignmentOptions)4097, new Vector2(0f, 0.5f), new Vector2(185f, 28f), new Vector2(16f, 13f))).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)CreateTextAt(obj.transform, "CategorySubtitle", subtitle, 14f, MutedTextColor, (TextAlignmentOptions)4097, new Vector2(0f, 0.5f), new Vector2(185f, 22f), new Vector2(16f, -15f))).textWrappingMode = (TextWrappingModes)0; GameObject val = CreateUiObject(obj.transform, "Swatches"); RectTransform component = val.GetComponent(); component.anchorMin = new Vector2(0f, 0f); component.anchorMax = new Vector2(1f, 1f); component.offsetMin = new Vector2(212f, 14f); component.offsetMax = new Vector2(-12f, -14f); HorizontalLayoutGroup obj2 = val.AddComponent(); ((HorizontalOrVerticalLayoutGroup)obj2).spacing = 8f; ((LayoutGroup)obj2).childAlignment = (TextAnchor)3; ((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false; CategoryView categoryView = new CategoryView(category); CategoryViews.Add(categoryView); for (int i = 0; i < Presets.Length; i++) { ColorPreset colorPreset = Presets[i]; Button obj3 = CreateColorButton(val.transform, title + "_" + colorPreset.Name, colorPreset, 91f); Outline val2 = ((Component)obj3).gameObject.AddComponent(); ((Shadow)val2).effectColor = SelectedColor; ((Shadow)val2).effectDistance = new Vector2(2.2f, 2.2f); ((Shadow)val2).useGraphicAlpha = false; ((Behaviour)val2).enabled = false; ColorPreset capturedPreset = colorPreset; MarkerCategory capturedCategory = category; ((UnityEvent)obj3.onClick).AddListener((UnityAction)delegate { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (capturedPreset.UseOriginal) { BetterDisplayConfig.ResetColor(capturedCategory); } else { BetterDisplayConfig.SetCustomColor(capturedCategory, capturedPreset.Color); } Refresh(); }); categoryView.Swatches.Add(new SwatchView(colorPreset, val2)); } } private static void CreateFooter(Transform parent, float y) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_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_0074: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown GameObject obj = CreatePositionedBlock(parent, "Footer", 914f, 46f, y); Button obj2 = CreateVanillaButton(obj.transform, "ResetButton", "恢复全部原版颜色", 240f, 40f, 16f); SetAt(((Component)obj2).GetComponent(), new Vector2(-134f, 0f)); ButtonClickedEvent onClick = obj2.onClick; object obj3 = <>O.<7>__ResetAllColors; if (obj3 == null) { UnityAction val = ResetAllColors; <>O.<7>__ResetAllColors = val; obj3 = (object)val; } ((UnityEvent)onClick).AddListener((UnityAction)obj3); Button obj4 = CreateVanillaButton(obj.transform, "CloseButton", "关闭", 150f, 40f, 16f); SetAt(((Component)obj4).GetComponent(), new Vector2(76f, 0f)); ButtonClickedEvent onClick2 = obj4.onClick; object obj5 = <>O.<8>__Close; if (obj5 == null) { UnityAction val2 = Close; <>O.<8>__Close = val2; obj5 = (object)val2; } ((UnityEvent)onClick2).AddListener((UnityAction)obj5); } private static GameObject CreatePositionedBlock(Transform parent, string name, float width, float height, float y) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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) GameObject obj = CreateUiObject(parent, name); RectTransform component = obj.GetComponent(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); component.anchoredPosition = new Vector2(0f, y); component.sizeDelta = new Vector2(width, height); return obj; } private static Button CreateVanillaButton(Transform parent, string name, string text, float width, float height, float fontSize) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) GameObject val = CreateUiObject(parent, name); val.GetComponent().sizeDelta = new Vector2(width, height); LayoutElement obj = val.AddComponent(); obj.preferredWidth = width; obj.minWidth = width; obj.preferredHeight = height; obj.minHeight = height; Image targetGraphic = AddBackground(val, ButtonColor, addBorder: true); Button obj2 = val.AddComponent