using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.TextCore;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SimpleTeleport")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+6e3c39eb79947214ebbc1dfe4dcf72f2f0afe807")]
[assembly: AssemblyProduct("SimpleTeleport")]
[assembly: AssemblyTitle("SimpleTeleport")]
[assembly: AssemblyVersion("1.1.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace SimpleTeleport
{
[BepInPlugin("khalil.SimpleTeleport", "Simple Teleport", "1.1.1")]
public sealed class SimpleTeleportPlugin : BaseUnityPlugin
{
internal const string PluginGuid = "khalil.SimpleTeleport";
internal const string PluginName = "Simple Teleport";
internal const string PluginVersion = "1.1.1";
private void Awake()
{
//IL_001b: 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)
STLog.Init(((BaseUnityPlugin)this).Logger);
STConfig.Bind(((BaseUnityPlugin)this).Config);
GameObject val = new GameObject("SimpleTeleportHost");
val.transform.SetParent(((Component)this).transform, false);
val.AddComponent<STBootstrap>();
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
STLog.Info("Simple Teleport v1.1.1 loaded.");
}
}
internal sealed class STBootstrap : MonoBehaviour
{
private STPanel _panel;
private void Start()
{
((MonoBehaviour)this).StartCoroutine(WatchGame());
}
private IEnumerator WatchGame()
{
while (true)
{
bool flag = (Object)(object)GUIManager.instance != (Object)null && (Object)(object)Character.localCharacter != (Object)null;
if ((Object)(object)_panel == (Object)null)
{
if (flag)
{
_panel = ((Component)this).gameObject.AddComponent<STPanel>();
STLog.Info("传送面板已就绪,按 " + ((object)STConfig.ToggleKey.Value/*cast due to .constrained prefix*/).ToString() + " 打开。");
}
}
else if ((Object)(object)GUIManager.instance == (Object)null)
{
Object.Destroy((Object)(object)_panel);
_panel = null;
}
yield return (object)new WaitForSecondsRealtime(0.5f);
}
}
}
internal static class STConfig
{
internal static ConfigEntry<KeyCode> ToggleKey;
internal static ConfigEntry<float> CooldownSeconds;
internal static ConfigEntry<float> ArrivalOffset;
internal static ConfigEntry<float> PanelScale;
internal static ConfigEntry<bool> UseMetricDistance;
internal static ConfigEntry<bool> CloseAfterTeleport;
internal static void Bind(ConfigFile config)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Expected O, but got Unknown
ToggleKey = config.Bind<KeyCode>("General", "ToggleKey", (KeyCode)116, "打开/关闭传送面板的按键。");
CooldownSeconds = config.Bind<float>("General", "CooldownSeconds", 1.5f, new ConfigDescription("两次传送之间的最小间隔(秒),防止连点导致布娃娃物理异常。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>()));
ArrivalOffset = config.Bind<float>("General", "ArrivalOffset", 1.6f, new ConfigDescription("落点与目标玩家的水平距离(米)。数值太小会与目标重叠并互相弹开。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 6f), Array.Empty<object>()));
CloseAfterTeleport = config.Bind<bool>("General", "CloseAfterTeleport", true, "传送后自动关闭面板。");
PanelScale = config.Bind<float>("UI", "PanelScale", 1f, new ConfigDescription("面板整体缩放。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.6f, 2f), Array.Empty<object>()));
UseMetricDistance = config.Bind<bool>("UI", "UseMetricDistance", true, "true 在距离后面加 m,false 只显示裸数值。PEAK 中 1 单位约等于 1 米。");
}
}
internal static class STInput
{
private static bool _legacyBroken;
private static readonly Dictionary<KeyCode, Key> SpecialMap = new Dictionary<KeyCode, Key>
{
{
(KeyCode)48,
(Key)50
},
{
(KeyCode)49,
(Key)41
},
{
(KeyCode)50,
(Key)42
},
{
(KeyCode)51,
(Key)43
},
{
(KeyCode)52,
(Key)44
},
{
(KeyCode)53,
(Key)45
},
{
(KeyCode)54,
(Key)46
},
{
(KeyCode)55,
(Key)47
},
{
(KeyCode)56,
(Key)48
},
{
(KeyCode)57,
(Key)49
},
{
(KeyCode)13,
(Key)2
},
{
(KeyCode)96,
(Key)4
},
{
(KeyCode)316,
(Key)74
},
{
(KeyCode)317,
(Key)74
},
{
(KeyCode)319,
(Key)59
},
{
(KeyCode)306,
(Key)55
},
{
(KeyCode)305,
(Key)56
},
{
(KeyCode)310,
(Key)57
},
{
(KeyCode)309,
(Key)58
},
{
(KeyCode)300,
(Key)73
},
{
(KeyCode)256,
(Key)84
},
{
(KeyCode)257,
(Key)85
},
{
(KeyCode)258,
(Key)86
},
{
(KeyCode)259,
(Key)87
},
{
(KeyCode)260,
(Key)88
},
{
(KeyCode)261,
(Key)89
},
{
(KeyCode)262,
(Key)90
},
{
(KeyCode)263,
(Key)91
},
{
(KeyCode)264,
(Key)92
},
{
(KeyCode)265,
(Key)93
},
{
(KeyCode)266,
(Key)82
},
{
(KeyCode)267,
(Key)78
},
{
(KeyCode)268,
(Key)79
},
{
(KeyCode)269,
(Key)81
},
{
(KeyCode)270,
(Key)80
},
{
(KeyCode)271,
(Key)77
},
{
(KeyCode)272,
(Key)83
}
};
private static readonly Dictionary<KeyCode, Key> ResolvedCache = new Dictionary<KeyCode, Key>();
internal static Vector2 MousePosition
{
get
{
//IL_0015: 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)
Mouse current = Mouse.current;
if (current != null)
{
return ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue();
}
return LegacyMousePosition();
}
}
internal static bool LeftClickThisFrame
{
get
{
Mouse current = Mouse.current;
if (current != null)
{
return current.leftButton.wasPressedThisFrame;
}
return LegacyKeyDown((KeyCode)323);
}
}
internal static bool LeftButtonHeld
{
get
{
Mouse current = Mouse.current;
if (current != null)
{
return current.leftButton.isPressed;
}
return LegacyKeyHeld((KeyCode)323);
}
}
internal static bool WasPressedThisFrame(KeyCode code)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: 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_0014: Unknown result type (might be due to invalid IL or missing references)
Key val = Resolve(code);
if ((int)val != 0)
{
Keyboard current = Keyboard.current;
if (current != null)
{
try
{
KeyControl val2 = current[val];
if (val2 != null)
{
return ((ButtonControl)val2).wasPressedThisFrame;
}
}
catch (ArgumentOutOfRangeException)
{
ResolvedCache[code] = (Key)0;
}
}
}
return LegacyKeyDown(code);
}
internal static int ScrollNotch()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
Mouse current = Mouse.current;
if (current != null)
{
float y = ((InputControl<Vector2>)(object)current.scroll).ReadValue().y;
if (Mathf.Abs(y) > 0.01f)
{
if (!(y > 0f))
{
return -1;
}
return 1;
}
return 0;
}
float num = LegacyScroll();
if (Mathf.Abs(num) > 0.01f)
{
if (!(num > 0f))
{
return -1;
}
return 1;
}
return 0;
}
private unsafe static Key Resolve(KeyCode code)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: 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_0055: 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)
if (ResolvedCache.TryGetValue(code, out var value))
{
return value;
}
Key val = (Key)0;
Key result;
if (SpecialMap.TryGetValue(code, out var value2))
{
val = value2;
}
else if (Enum.TryParse<Key>(((object)(*(KeyCode*)(&code))/*cast due to .constrained prefix*/).ToString(), ignoreCase: false, out result) && Enum.IsDefined(typeof(Key), result))
{
val = result;
}
if ((int)val != 0 && char.IsDigit(((object)(*(KeyCode*)(&code))/*cast due to .constrained prefix*/).ToString()[0]))
{
val = (Key)0;
}
ResolvedCache[code] = val;
return val;
}
private static bool LegacyKeyDown(KeyCode code)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
if (_legacyBroken)
{
return false;
}
try
{
return Input.GetKeyDown(code);
}
catch (Exception)
{
_legacyBroken = true;
STLog.Warn("旧版 Input 不可用,已停用退回路径。");
return false;
}
}
private static bool LegacyKeyHeld(KeyCode code)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
if (_legacyBroken)
{
return false;
}
try
{
return Input.GetKey(code);
}
catch (Exception)
{
_legacyBroken = true;
return false;
}
}
private static float LegacyScroll()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
if (_legacyBroken)
{
return 0f;
}
try
{
return Input.mouseScrollDelta.y;
}
catch (Exception)
{
_legacyBroken = true;
return 0f;
}
}
private static Vector2 LegacyMousePosition()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: 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_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (_legacyBroken)
{
return Vector2.zero;
}
try
{
return Vector2.op_Implicit(Input.mousePosition);
}
catch (Exception)
{
_legacyBroken = true;
return Vector2.zero;
}
}
}
internal static class STLog
{
private static ManualLogSource _log;
internal static void Init(ManualLogSource log)
{
_log = log;
}
internal static void Info(string message)
{
ManualLogSource log = _log;
if (log != null)
{
log.LogInfo((object)message);
}
}
internal static void Warn(string message)
{
ManualLogSource log = _log;
if (log != null)
{
log.LogWarning((object)message);
}
}
internal static void Error(string message)
{
ManualLogSource log = _log;
if (log != null)
{
log.LogError((object)message);
}
}
}
[DefaultExecutionOrder(-200)]
internal sealed class STPanel : MonoBehaviour
{
private sealed class CardView
{
internal GameObject Root;
internal RectTransform RootRect;
internal Image Background;
internal TextMeshProUGUI NameText;
internal TextMeshProUGUI InfoText;
internal Image GoButton;
internal TextMeshProUGUI GoLabel;
internal RectTransform GoRect;
internal Image BringButton;
internal TextMeshProUGUI BringLabel;
internal RectTransform BringRect;
}
private const int VisibleCards = 6;
private const float PanelWidth = 528f;
private const float PanelPadding = 16f;
private const float CardSpacing = 7f;
private const float TitleFontSize = 29f;
private const float HintFontSize = 17f;
private const float CountFontSize = 18f;
private const float NameFontSize = 25f;
private const float InfoFontSize = 18f;
private const float ButtonFontSize = 17f;
private const float StatusFontSize = 17f;
private const float ScrollHintFontSize = 17f;
private const float ButtonWidth = 108f;
private const float ButtonGap = 7f;
private const float ButtonColumnWidth = 120f;
private const float ScrollBarWidth = 10f;
private static readonly Vector4 ScrollGrabPadding = new Vector4(0f, -6f, -3f, -6f);
private const float ScrollThumbMinHeight = 28f;
private const float CountWidth = 190f;
private static readonly Color PanelColor = new Color(0.055f, 0.065f, 0.085f, 0.9f);
private static readonly Color SeparatorColor = new Color(1f, 1f, 1f, 0.1f);
private static readonly Color CardColor = new Color(1f, 1f, 1f, 0.055f);
private static readonly Color CardHoverColor = new Color(1f, 1f, 1f, 0.12f);
private static readonly Color TitleColor = new Color(0.96f, 0.97f, 1f, 1f);
private static readonly Color SubtleColor = new Color(0.68f, 0.73f, 0.8f, 1f);
private static readonly Color GoColor = new Color(0.16f, 0.44f, 0.72f, 0.95f);
private static readonly Color GoHoverColor = new Color(0.26f, 0.6f, 0.92f, 1f);
private static readonly Color BringColor = new Color(0.62f, 0.38f, 0.12f, 0.95f);
private static readonly Color BringHoverColor = new Color(0.84f, 0.52f, 0.17f, 1f);
private static readonly Color ButtonBlockedColor = new Color(0.26f, 0.28f, 0.32f, 0.8f);
private static readonly Color ScrollTrackColor = new Color(1f, 1f, 1f, 0.07f);
private static readonly Color ScrollThumbColor = new Color(0.62f, 0.72f, 0.86f, 0.55f);
private static readonly Color ScrollThumbHoverColor = new Color(0.78f, 0.86f, 1f, 0.78f);
private static readonly Color ScrollThumbDragColor = new Color(0.36f, 0.66f, 1f, 0.95f);
private static readonly Color ScrollHintColor = new Color(1f, 0.78f, 0.36f, 1f);
private float _titleRow;
private float _hintRow;
private float _nameRow;
private float _infoRow;
private float _buttonRow;
private float _statusRow;
private float _scrollHintRow;
private float _headerHeight;
private float _cardHeight;
private float _footerHeight;
private float _footerHeightScrolling;
private int _nameCharBudget;
private GameObject _canvasObject;
private RectTransform _canvasRect;
private RectTransform _panelRect;
private TextMeshProUGUI _titleText;
private TextMeshProUGUI _countText;
private TextMeshProUGUI _hintText;
private TextMeshProUGUI _statusText;
private TextMeshProUGUI _emptyText;
private TextMeshProUGUI _scrollHintText;
private Image _scrollTrack;
private RectTransform _scrollTrackRect;
private Image _scrollThumb;
private RectTransform _scrollThumbRect;
private float _trackHeight;
private bool _draggingThumb;
private float _dragGrabOffset;
private float _dragThumbTop;
private readonly List<CardView> _cards = new List<CardView>();
private readonly List<Character> _targets = new List<Character>();
private Comparison<Character> _byName;
private float _appliedPanelHeight = -1f;
private float _appliedPanelScale = -1f;
private int _appliedScrollIndex = -1;
private int _appliedScrollTotal = -1;
private GameObject _proxyHolder;
private MenuWindow _inputProxy;
private bool _open;
private int _scrollIndex;
private string _statusMessage;
private float _statusUntil;
private int MaxScrollIndex => Mathf.Max(0, _targets.Count - 6);
private bool NeedsScrolling => _targets.Count > 6;
private void Awake()
{
_byName = CompareByName;
MeasureLayout();
BuildHierarchy();
BuildInputProxy();
_canvasObject.SetActive(false);
}
private void OnDisable()
{
Close();
}
private void OnDestroy()
{
DetachProxy();
if ((Object)(object)_proxyHolder != (Object)null)
{
Object.Destroy((Object)(object)_proxyHolder);
_proxyHolder = null;
}
if ((Object)(object)_canvasObject != (Object)null)
{
Object.Destroy((Object)(object)_canvasObject);
_canvasObject = null;
}
}
private void Update()
{
Character localCharacter = Character.localCharacter;
if (_open && !StillValid(localCharacter))
{
Close();
return;
}
try
{
if (_open)
{
SuppressStaleGameplayInput(localCharacter);
}
HandleToggleKey(localCharacter);
if (_open)
{
RefreshTargets(localCharacter);
HandleScroll();
HandleThumbDrag();
Redraw(localCharacter);
HandleClicks(localCharacter);
}
}
catch (Exception ex)
{
STLog.Error("面板更新出错,已关闭面板:" + ex);
Close();
}
}
private void LateUpdate()
{
if (!_open)
{
return;
}
try
{
SuppressStaleGameplayInput(Character.localCharacter);
}
catch (Exception ex)
{
STLog.Error("清理输入出错,已关闭面板:" + ex);
Close();
}
}
private void MeasureLayout()
{
_titleRow = STUI.RowHeightFor(29f);
_hintRow = STUI.RowHeightFor(17f);
_nameRow = STUI.RowHeightFor(25f);
_infoRow = STUI.RowHeightFor(18f);
_buttonRow = STUI.RowHeightFor(17f);
_statusRow = STUI.RowHeightFor(17f);
_scrollHintRow = STUI.RowHeightFor(17f);
_headerHeight = 10f + _titleRow + 3f + _hintRow + 12f;
float num = 10f + _nameRow + 3f + _infoRow + 10f;
float num2 = 10f + _buttonRow * 2f + 7f + 10f;
_cardHeight = Mathf.Max(num, num2);
_footerHeight = 8f + _statusRow + 6f;
_footerHeightScrolling = 8f + _scrollHintRow + 4f + _statusRow + 6f;
float num3 = 346f;
_nameCharBudget = Mathf.Max(6, Mathf.FloorToInt(num3 / 15.5f));
}
private bool StillValid(Character local)
{
if ((Object)(object)local == (Object)null || (Object)(object)GUIManager.instance == (Object)null || LoadingScreenHandler.loading)
{
return false;
}
if (!TeleportService.IsPositionReady(local))
{
return false;
}
if (GUIManager.InPauseMenu)
{
return false;
}
if ((Object)(object)_inputProxy == (Object)null || !MenuWindow.AllActiveWindows.Contains(_inputProxy))
{
return false;
}
return true;
}
private void HandleToggleKey(Character local)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
if (STInput.WasPressedThisFrame(STConfig.ToggleKey.Value))
{
if (_open)
{
Close();
}
else if (!((Object)(object)local == (Object)null) && !((Object)(object)GUIManager.instance == (Object)null) && !LoadingScreenHandler.loading && TeleportService.IsPositionReady(local) && !GUIManager.InPauseMenu && !GUIManager.instance.wheelActive && !GUIManager.instance.windowBlockingInput)
{
Open();
}
}
}
private void Open()
{
if (!_open)
{
AttachProxy();
GUIManager instance = GUIManager.instance;
if ((Object)(object)instance != (Object)null)
{
instance.UpdateWindowStatus();
}
_open = true;
_scrollIndex = 0;
_statusMessage = null;
_statusUntil = 0f;
_appliedPanelHeight = -1f;
_appliedPanelScale = -1f;
_appliedScrollIndex = -1;
_appliedScrollTotal = -1;
_canvasObject.SetActive(true);
}
}
internal void Close()
{
if (_open)
{
_open = false;
_draggingThumb = false;
DetachProxy();
_targets.Clear();
if ((Object)(object)_canvasObject != (Object)null)
{
_canvasObject.SetActive(false);
}
}
}
private static void SuppressStaleGameplayInput(Character local)
{
CharacterInput val = local?.input;
if (!((Object)(object)val == (Object)null))
{
val.scrollInput = 0f;
val.scrollForwardWasPressed = false;
val.scrollBackwardWasPressed = false;
val.scrollForwardIsPressed = false;
val.scrollBackwardIsPressed = false;
val.pingWasPressed = false;
val.selectBackpackWasPressed = false;
val.selectSlotForwardWasPressed = false;
val.selectSlotBackwardWasPressed = false;
val.unselectSlotWasPressed = false;
val.spectateLeftWasPressed = false;
val.spectateRightWasPressed = false;
val.sprintToggleIsPressed = false;
InputAction push_to_talk = CharacterInput.push_to_talk;
if (push_to_talk != null)
{
val.pushToTalkPressed = push_to_talk.IsPressed();
}
}
}
private void RefreshTargets(Character local)
{
_targets.Clear();
List<Character> allCharacters = Character.AllCharacters;
for (int i = 0; i < allCharacters.Count; i++)
{
Character val = allCharacters[i];
if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)local) && val.IsPlayerControlled && !((Object)(object)((MonoBehaviourPun)val).photonView == (Object)null) && ((MonoBehaviourPun)val).photonView.Owner != null && TeleportService.IsPositionReady(val))
{
_targets.Add(val);
}
}
_targets.Sort(_byName);
_scrollIndex = Mathf.Clamp(_scrollIndex, 0, MaxScrollIndex);
}
private static int CompareByName(Character a, Character b)
{
int num = string.Compare(DisplayName(a), DisplayName(b), StringComparison.OrdinalIgnoreCase);
if (num != 0)
{
return num;
}
return ActorNumberOf(a).CompareTo(ActorNumberOf(b));
}
private static int ActorNumberOf(Character character)
{
PhotonView photonView = ((MonoBehaviourPun)character).photonView;
Player val = ((photonView != null) ? photonView.Owner : null);
if (val == null)
{
return int.MaxValue;
}
return val.ActorNumber;
}
private void HandleScroll()
{
if (!_draggingThumb)
{
int num = STInput.ScrollNotch();
if (num != 0)
{
_scrollIndex = Mathf.Clamp(_scrollIndex - num, 0, MaxScrollIndex);
}
}
}
private void HandleThumbDrag()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: 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_009d: Unknown result type (might be due to invalid IL or missing references)
if (!NeedsScrolling)
{
_draggingThumb = false;
return;
}
if (_draggingThumb && !STInput.LeftButtonHeld)
{
_draggingThumb = false;
return;
}
Vector2 mousePosition = STInput.MousePosition;
if (!_draggingThumb && STInput.LeftClickThisFrame && STInput.LeftButtonHeld)
{
float distanceFromTop2;
if (RectTransformUtility.RectangleContainsScreenPoint(_scrollThumbRect, mousePosition, (Camera)null, ScrollGrabPadding))
{
if (TryGetTrackLocalY(mousePosition, out var distanceFromTop))
{
_draggingThumb = true;
_dragThumbTop = CurrentThumbTop();
_dragGrabOffset = distanceFromTop - _dragThumbTop;
}
}
else if (RectTransformUtility.RectangleContainsScreenPoint(_scrollTrackRect, mousePosition) && TryGetTrackLocalY(mousePosition, out distanceFromTop2))
{
float num = CurrentThumbHeight();
_dragGrabOffset = num * 0.5f;
_dragThumbTop = distanceFromTop2 - _dragGrabOffset;
SetScrollFromThumbTop(_dragThumbTop, num);
_draggingThumb = true;
}
}
if (_draggingThumb && TryGetTrackLocalY(mousePosition, out var distanceFromTop3))
{
_dragThumbTop = distanceFromTop3 - _dragGrabOffset;
SetScrollFromThumbTop(_dragThumbTop, CurrentThumbHeight());
}
}
private bool TryGetTrackLocalY(Vector2 screenPoint, out float distanceFromTop)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
distanceFromTop = 0f;
Vector2 val = default(Vector2);
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(_scrollTrackRect, screenPoint, (Camera)null, ref val))
{
return false;
}
distanceFromTop = 0f - val.y;
return true;
}
private float CurrentThumbHeight()
{
int num = Mathf.Max(1, _targets.Count);
float num2 = 6f / (float)num;
return Mathf.Clamp(_trackHeight * num2, 28f, _trackHeight);
}
private float CurrentThumbTop()
{
float num = Mathf.Max(0f, _trackHeight - CurrentThumbHeight());
float num2 = ((MaxScrollIndex > 0) ? ((float)_scrollIndex / (float)MaxScrollIndex) : 0f);
return num * num2;
}
private void SetScrollFromThumbTop(float thumbTop, float thumbHeight)
{
float num = Mathf.Max(0f, _trackHeight - thumbHeight);
if (num <= 0.01f)
{
_scrollIndex = 0;
return;
}
float num2 = Mathf.Clamp01(thumbTop / num);
_scrollIndex = Mathf.Clamp(Mathf.RoundToInt(num2 * (float)MaxScrollIndex), 0, MaxScrollIndex);
}
private void Redraw(Character local)
{
//IL_00fb: 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_029e: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
bool value = STConfig.UseMetricDistance.Value;
int num = Mathf.Min(6, _targets.Count);
bool needsScrolling = NeedsScrolling;
ApplyPanelTransform(num);
SetText(_titleText, STStrings.Title);
SetText(_hintText, STStrings.Hint);
if (_targets.Count == 0)
{
SetText(_countText, string.Empty);
}
else if (needsScrolling)
{
SetText(_countText, STStrings.Count(_scrollIndex + 1, _scrollIndex + num, _targets.Count));
}
else
{
SetText(_countText, STStrings.Total(_targets.Count));
}
bool flag = _targets.Count == 0;
if (((Component)_emptyText).gameObject.activeSelf != flag)
{
((Component)_emptyText).gameObject.SetActive(flag);
}
if (flag)
{
SetText(_emptyText, STStrings.Empty);
}
Vector2 mousePosition = STInput.MousePosition;
for (int i = 0; i < _cards.Count; i++)
{
CardView cardView = _cards[i];
int num2 = _scrollIndex + i;
if (i >= num || num2 >= _targets.Count)
{
if (cardView.Root.activeSelf)
{
cardView.Root.SetActive(false);
}
continue;
}
Character val = _targets[num2];
if (!cardView.Root.activeSelf)
{
cardView.Root.SetActive(true);
}
bool flag2 = RectTransformUtility.RectangleContainsScreenPoint(cardView.RootRect, mousePosition);
((Graphic)cardView.Background).color = (flag2 ? CardHoverColor : CardColor);
SetText(cardView.NameText, STUI.Truncate(DisplayName(val), _nameCharBudget));
SetText(cardView.InfoText, BuildInfoLine(local, val, value));
string reason;
bool flag3 = TeleportService.CanTeleportNow(local, val, out reason);
bool flag4 = TeleportService.CanTeleportNow(val, local, out reason);
((Graphic)cardView.GoButton).color = ((!flag3) ? ButtonBlockedColor : (RectTransformUtility.RectangleContainsScreenPoint(cardView.GoRect, mousePosition) ? GoHoverColor : GoColor));
((Graphic)cardView.BringButton).color = ((!flag4) ? ButtonBlockedColor : (RectTransformUtility.RectangleContainsScreenPoint(cardView.BringRect, mousePosition) ? BringHoverColor : BringColor));
SetText(cardView.GoLabel, STStrings.GoToLabel);
SetText(cardView.BringLabel, STStrings.BringLabel);
}
RedrawScrollBar(needsScrolling, mousePosition);
RedrawScrollHint(needsScrolling);
RedrawStatus();
}
private void RedrawScrollHint(bool scrolling)
{
if (((Component)_scrollHintText).gameObject.activeSelf != scrolling)
{
((Component)_scrollHintText).gameObject.SetActive(scrolling);
}
if (scrolling)
{
SetText(_scrollHintText, STStrings.ScrollHint);
}
}
private static void SetText(TextMeshProUGUI target, string value)
{
if (!string.Equals(((TMP_Text)target).text, value))
{
((TMP_Text)target).text = value;
}
}
private void ApplyPanelTransform(int visible)
{
//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_008c: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
float num = MeasureHeight(visible);
float num2 = Mathf.Clamp(STConfig.PanelScale.Value, 0.6f, 2f);
float num3;
if (!((Object)(object)_canvasRect != (Object)null))
{
num3 = 0f;
}
else
{
Rect rect = _canvasRect.rect;
num3 = ((Rect)(ref rect)).height;
}
float num4 = num3;
if (num4 > 1f && num > 1f)
{
num2 = Mathf.Min(num2, num4 * 0.98f / num);
}
if (!Mathf.Approximately(num, _appliedPanelHeight))
{
_appliedPanelHeight = num;
_panelRect.sizeDelta = new Vector2(528f, num);
}
if (!Mathf.Approximately(num2, _appliedPanelScale))
{
_appliedPanelScale = num2;
((Transform)_panelRect).localScale = Vector3.one * num2;
}
}
private void RedrawScrollBar(bool scrolling, Vector2 mouse)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
if (((Component)_scrollTrack).gameObject.activeSelf != scrolling)
{
((Component)_scrollTrack).gameObject.SetActive(scrolling);
}
if (!scrolling)
{
return;
}
Color color = ((!_draggingThumb) ? (RectTransformUtility.RectangleContainsScreenPoint(_scrollThumbRect, mouse, (Camera)null, ScrollGrabPadding) ? ScrollThumbHoverColor : ScrollThumbColor) : ScrollThumbDragColor);
((Graphic)_scrollThumb).color = color;
float num = CurrentThumbHeight();
if (_draggingThumb)
{
float num2 = Mathf.Max(0f, _trackHeight - num);
float top = Mathf.Clamp(_dragThumbTop, 0f, num2);
LayoutThumb(top, num);
_appliedScrollIndex = -1;
_appliedScrollTotal = -1;
return;
}
int count = _targets.Count;
if (_appliedScrollIndex != _scrollIndex || _appliedScrollTotal != count)
{
_appliedScrollIndex = _scrollIndex;
_appliedScrollTotal = count;
LayoutThumb(CurrentThumbTop(), num);
}
}
private void RedrawStatus()
{
if (!string.IsNullOrEmpty(_statusMessage) && Time.unscaledTime < _statusUntil)
{
SetText(_statusText, _statusMessage);
return;
}
float cooldownRemaining = TeleportService.CooldownRemaining;
SetText(_statusText, (cooldownRemaining > 0.05f) ? STStrings.Cooldown(cooldownRemaining) : string.Empty);
}
private static string DisplayName(Character target)
{
if (!string.IsNullOrWhiteSpace(target.characterName))
{
return target.characterName;
}
PhotonView photonView = ((MonoBehaviourPun)target).photonView;
object obj;
if (photonView == null)
{
obj = null;
}
else
{
Player owner = photonView.Owner;
obj = ((owner != null) ? owner.NickName : null);
}
string text = (string)obj;
if (!string.IsNullOrWhiteSpace(text))
{
return text;
}
return "???";
}
private static string BuildInfoLine(Character local, Character target, bool metric)
{
//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)
string text = DescribeState(target);
if (!TeleportService.TryGetAnchorPosition(target, out var position) || ((Object)(object)target.data != (Object)null && target.data.dead))
{
return text ?? STStrings.StateDead;
}
string text2 = STStrings.Distance(Vector3.Distance(TeleportService.AnchorPosition(local), position), metric);
if (!string.IsNullOrEmpty(text))
{
text2 = text2 + " " + text;
}
return text2;
}
private void HandleClicks(Character local)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: 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)
if (!STInput.LeftClickThisFrame || _draggingThumb)
{
return;
}
Vector2 mousePosition = STInput.MousePosition;
int num = Mathf.Min(6, _targets.Count);
for (int i = 0; i < num && i < _cards.Count; i++)
{
int num2 = _scrollIndex + i;
if (num2 < _targets.Count)
{
CardView cardView = _cards[i];
Character target = _targets[num2];
if (RectTransformUtility.RectangleContainsScreenPoint(cardView.GoRect, mousePosition))
{
Execute(local, target, bringThem: false);
break;
}
if (RectTransformUtility.RectangleContainsScreenPoint(cardView.BringRect, mousePosition))
{
Execute(local, target, bringThem: true);
break;
}
continue;
}
break;
}
}
private void Execute(Character local, Character target, bool bringThem)
{
Character mover = (bringThem ? target : local);
Character anchor = (bringThem ? local : target);
if (!TeleportService.Teleport(mover, anchor, out var message))
{
SetStatus(message);
return;
}
string target2 = DisplayName(target);
SetStatus(bringThem ? STStrings.SentBring(target2) : STStrings.SentGoTo(target2));
if (STConfig.CloseAfterTeleport.Value)
{
Close();
}
}
private void SetStatus(string message)
{
_statusMessage = message;
_statusUntil = Time.unscaledTime + 2.5f;
}
private static string DescribeState(Character target)
{
if ((Object)(object)target.data == (Object)null)
{
return null;
}
if (target.data.dead)
{
return STStrings.StateDead;
}
if (target.warping)
{
return STStrings.StateWarping;
}
if (target.data.fullyPassedOut)
{
return STStrings.StateDown;
}
return null;
}
private float MeasureHeight(int visibleCards)
{
float num = ((visibleCards <= 0) ? _cardHeight : ((float)visibleCards * _cardHeight + (float)(visibleCards - 1) * 7f));
return _headerHeight + num + (NeedsScrolling ? _footerHeightScrolling : _footerHeight);
}
private float CardTop(int slot)
{
return _headerHeight + (float)slot * (_cardHeight + 7f);
}
private void BuildHierarchy()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
//IL_0076: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: 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_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_0370: Unknown result type (might be due to invalid IL or missing references)
_canvasObject = new GameObject("SimpleTeleportCanvas");
_canvasObject.transform.SetParent(((Component)this).transform, false);
Canvas obj = _canvasObject.AddComponent<Canvas>();
obj.renderMode = (RenderMode)0;
obj.sortingOrder = 520;
_canvasRect = (RectTransform)_canvasObject.transform;
CanvasScaler obj2 = _canvasObject.AddComponent<CanvasScaler>();
obj2.uiScaleMode = (ScaleMode)1;
obj2.referenceResolution = new Vector2(1920f, 1080f);
obj2.screenMatchMode = (ScreenMatchMode)0;
obj2.matchWidthOrHeight = 0.5f;
Image val = STUI.CreatePanel("Panel", _canvasObject.transform, PanelColor);
_panelRect = STUI.Rect(((Component)val).gameObject);
_panelRect.anchorMin = new Vector2(0.5f, 0.5f);
_panelRect.anchorMax = new Vector2(0.5f, 0.5f);
_panelRect.pivot = new Vector2(0.5f, 0.5f);
_panelRect.anchoredPosition = Vector2.zero;
_panelRect.sizeDelta = new Vector2(528f, MeasureHeight(6));
_titleText = STUI.CreateText("Title", ((Component)val).transform, 29f, (TextAlignmentOptions)514, TitleColor);
STUI.SetStretchRow(STUI.Rect(((Component)_titleText).gameObject), 16f, 16f, 10f, _titleRow);
_countText = STUI.CreateText("Count", ((Component)val).transform, 18f, (TextAlignmentOptions)516, SubtleColor);
STUI.SetTopRight(STUI.Rect(((Component)_countText).gameObject), 18f, 12f, 190f, STUI.RowHeightFor(18f));
_hintText = STUI.CreateText("Hint", ((Component)val).transform, 17f, (TextAlignmentOptions)514, SubtleColor);
STUI.SetStretchRow(STUI.Rect(((Component)_hintText).gameObject), 16f, 16f, 10f + _titleRow + 3f, _hintRow);
STUI.SetStretchRow(STUI.Rect(((Component)STUI.CreatePanel("Separator", ((Component)val).transform, SeparatorColor)).gameObject), 16f, 16f, _headerHeight - 6f, 1f);
_emptyText = STUI.CreateText("Empty", ((Component)val).transform, 21f, (TextAlignmentOptions)514, SubtleColor);
STUI.SetStretchRow(STUI.Rect(((Component)_emptyText).gameObject), 16f, 16f, _headerHeight + 18f, STUI.RowHeightFor(21f));
for (int i = 0; i < 6; i++)
{
_cards.Add(BuildCard(((Component)val).transform, i));
}
BuildScrollBar(((Component)val).transform);
_scrollHintText = STUI.CreateText("ScrollHint", ((Component)val).transform, 17f, (TextAlignmentOptions)514, ScrollHintColor);
STUI.SetBottomRow(STUI.Rect(((Component)_scrollHintText).gameObject), 18f, 18f, 6f + _statusRow + 4f, _scrollHintRow);
_statusText = STUI.CreateText("Status", ((Component)val).transform, 17f, (TextAlignmentOptions)513, SubtleColor);
STUI.SetBottomRow(STUI.Rect(((Component)_statusText).gameObject), 18f, 18f, 6f, _statusRow);
}
private void BuildScrollBar(Transform parent)
{
//IL_001f: 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)
_trackHeight = 6f * _cardHeight + 35f;
_scrollTrack = STUI.CreatePanel("ScrollTrack", parent, ScrollTrackColor);
_scrollTrackRect = STUI.Rect(((Component)_scrollTrack).gameObject);
STUI.SetTopRight(_scrollTrackRect, 3f, _headerHeight, 10f, _trackHeight);
_scrollThumb = STUI.CreatePanel("ScrollThumb", ((Component)_scrollTrack).transform, ScrollThumbColor);
_scrollThumbRect = STUI.Rect(((Component)_scrollThumb).gameObject);
LayoutThumb(0f, _trackHeight);
}
private void LayoutThumb(float top, float height)
{
//IL_0010: 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_0044: 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_0074: Unknown result type (might be due to invalid IL or missing references)
_scrollThumbRect.anchorMin = new Vector2(0f, 1f);
_scrollThumbRect.anchorMax = new Vector2(1f, 1f);
_scrollThumbRect.pivot = new Vector2(0.5f, 1f);
_scrollThumbRect.offsetMin = new Vector2(0f, 0f - (top + height));
_scrollThumbRect.offsetMax = new Vector2(0f, 0f - top);
}
private CardView BuildCard(Transform parent, int slot)
{
//IL_0012: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: 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_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
Image val = STUI.CreatePanel("Card" + slot, parent, CardColor);
RectTransform val2 = STUI.Rect(((Component)val).gameObject);
STUI.SetStretchRow(val2, 16f, 16f, CardTop(slot), _cardHeight);
float width = 346f;
TextMeshProUGUI val3 = STUI.CreateText("Name", ((Component)val).transform, 25f, (TextAlignmentOptions)513, Color.white);
STUI.SetTopLeft(STUI.Rect(((Component)val3).gameObject), 14f, 10f, width, _nameRow);
TextMeshProUGUI val4 = STUI.CreateText("Info", ((Component)val).transform, 18f, (TextAlignmentOptions)513, SubtleColor);
STUI.SetTopLeft(STUI.Rect(((Component)val4).gameObject), 14f, 10f + _nameRow + 3f, width, _infoRow);
Image val5 = STUI.CreatePanel("GoButton", ((Component)val).transform, GoColor);
RectTransform val6 = STUI.Rect(((Component)val5).gameObject);
STUI.SetTopRight(val6, 12f, 10f, 108f, _buttonRow);
TextMeshProUGUI val7 = STUI.CreateText("GoLabel", ((Component)val5).transform, 17f, (TextAlignmentOptions)514, Color.white);
STUI.Stretch(STUI.Rect(((Component)val7).gameObject));
Image val8 = STUI.CreatePanel("BringButton", ((Component)val).transform, BringColor);
RectTransform val9 = STUI.Rect(((Component)val8).gameObject);
STUI.SetTopRight(val9, 12f, 10f + _buttonRow + 7f, 108f, _buttonRow);
TextMeshProUGUI val10 = STUI.CreateText("BringLabel", ((Component)val8).transform, 17f, (TextAlignmentOptions)514, Color.white);
STUI.Stretch(STUI.Rect(((Component)val10).gameObject));
return new CardView
{
Root = ((Component)val).gameObject,
RootRect = val2,
Background = val,
NameText = val3,
InfoText = val4,
GoButton = val5,
GoLabel = val7,
GoRect = val6,
BringButton = val8,
BringLabel = val10,
BringRect = val9
};
}
private void BuildInputProxy()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
_proxyHolder = new GameObject("SimpleTeleportInputProxy");
_proxyHolder.transform.SetParent(((Component)this).transform, false);
_proxyHolder.SetActive(false);
_inputProxy = _proxyHolder.AddComponent<MenuWindow>();
}
private void AttachProxy()
{
if ((Object)(object)_inputProxy == (Object)null)
{
BuildInputProxy();
}
if ((Object)(object)_inputProxy != (Object)null && !MenuWindow.AllActiveWindows.Contains(_inputProxy))
{
MenuWindow.AllActiveWindows.Add(_inputProxy);
}
}
private void DetachProxy()
{
List<MenuWindow> allActiveWindows = MenuWindow.AllActiveWindows;
if ((Object)(object)_inputProxy != (Object)null)
{
allActiveWindows.Remove(_inputProxy);
}
for (int i = 0; i < allActiveWindows.Count; i++)
{
if ((Object)(object)allActiveWindows[i] == (Object)null)
{
STLog.Warn("MenuWindow.AllActiveWindows 里存在已销毁的窗口,游戏 HUD 更新可能会出错(不是本模组的占位)。");
break;
}
}
}
}
internal static class STStrings
{
private static bool IsChinese
{
get
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
Language cURRENT_LANGUAGE = LocalizedText.CURRENT_LANGUAGE;
if ((int)cURRENT_LANGUAGE != 9)
{
return (int)cURRENT_LANGUAGE == 10;
}
return true;
}
}
private static bool IsTraditional => (int)LocalizedText.CURRENT_LANGUAGE == 10;
internal static string Title => Pick("传送面板", "傳送面板", "Teleport");
internal static string Hint => Pick("按 T 关闭", "按 T 關閉", "Press T to close");
internal static string ScrollHint => Pick("滚动鼠标滚轮或拖动右侧滑块查看更多玩家", "滾動滑鼠滾輪或拖動右側滑塊查看更多玩家", "Scroll or drag the bar to see more players");
internal static string GoToLabel => Pick("我过去", "我過去", "Go To");
internal static string BringLabel => Pick("拉过来", "拉過來", "Bring");
internal static string Empty => Pick("房间里没有其他玩家", "房間裡沒有其他玩家", "No other players in the room");
internal static string StateDead => Pick("[已死亡]", "[已死亡]", "[Dead]");
internal static string StateDown => Pick("[昏迷]", "[昏迷]", "[Down]");
internal static string StateWarping => Pick("[传送中]", "[傳送中]", "[Warping]");
internal static string Busy => Pick("上一次传送还没结束", "上一次傳送還沒結束", "Previous warp still running");
internal static string SelfDead => Pick("你已死亡,无法移动", "你已死亡,無法移動", "You are dead");
internal static string MoverDead => Pick("对方已死亡,无法移动", "對方已死亡,無法移動", "Target is dead");
internal static string AnchorUnknown => Pick("找不到对方的有效位置", "找不到對方的有效位置", "No valid position for target");
internal static string Unavailable => Pick("当前无法传送", "當前無法傳送", "Teleport unavailable right now");
private static string Pick(string simplified, string traditional, string english)
{
if (!IsChinese)
{
return english;
}
if (!IsTraditional)
{
return simplified;
}
return traditional;
}
internal static string Count(int shownFrom, int shownTo, int total)
{
if (total <= 0)
{
return string.Empty;
}
string text = string.Format(CultureInfo.InvariantCulture, "{0}-{1} / {2}", shownFrom, shownTo, total);
return Pick("玩家 " + text, "玩家 " + text, "Players " + text);
}
internal static string Total(int total)
{
return Pick("玩家 " + total, "玩家 " + total, "Players " + total);
}
internal static string Distance(float meters, bool metric)
{
string text = meters.ToString((meters < 100f) ? "0.0" : "0", CultureInfo.InvariantCulture);
return Pick("距离 ", "距離 ", "Dist ") + (metric ? (text + "m") : text);
}
internal static string Cooldown(float remaining)
{
string text = remaining.ToString("0.0", CultureInfo.InvariantCulture);
return Pick("冷却中 " + text + "s", "冷卻中 " + text + "s", "Cooldown " + text + "s");
}
internal static string SentGoTo(string target)
{
return Pick("已传送到 " + target, "已傳送到 " + target, "Teleported to " + target);
}
internal static string SentBring(string target)
{
return Pick("已把 " + target + " 拉过来", "已把 " + target + " 拉過來", "Pulled " + target + " to you");
}
}
internal static class STUI
{
private static TMP_FontAsset _font;
private static bool _loggedFont;
private static int _uiLayer = -1;
internal const float HalfCharWidthRatio = 0.62f;
internal static TMP_FontAsset ResolveFont()
{
if ((Object)(object)_font != (Object)null)
{
return _font;
}
GUIManager instance = GUIManager.instance;
if ((Object)(object)instance != (Object)null)
{
_font = FontFrom(instance.interactNameText) ?? FontFrom(instance.interactPromptText) ?? FontFrom(instance.itemPromptMain) ?? FontFrom(instance.spectatingNameText);
}
if ((Object)(object)_font == (Object)null)
{
TextMeshProUGUI[] array = Object.FindObjectsByType<TextMeshProUGUI>((FindObjectsSortMode)0);
for (int i = 0; i < array.Length; i++)
{
if ((Object)(object)array[i] != (Object)null && (Object)(object)((TMP_Text)array[i]).font != (Object)null)
{
_font = ((TMP_Text)array[i]).font;
break;
}
}
}
if ((Object)(object)_font == (Object)null)
{
_font = TMP_Settings.defaultFontAsset;
}
if ((Object)(object)_font == (Object)null)
{
STLog.Warn("没有找到可用的 TMP 字体,面板文字可能不显示。");
}
else if (!_loggedFont)
{
_loggedFont = true;
STLog.Info($"UI 字体: {((Object)_font).name} (含 fallback 的最大 lineHeight/pointSize = {MaxLineHeightRatio(_font):0.00})");
}
return _font;
}
private static float MaxLineHeightRatio(TMP_FontAsset font)
{
float num = RatioOf(font);
if ((Object)(object)font != (Object)null && font.fallbackFontAssetTable != null)
{
for (int i = 0; i < font.fallbackFontAssetTable.Count; i++)
{
TMP_FontAsset val = font.fallbackFontAssetTable[i];
if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)font)
{
num = Mathf.Max(num, RatioOf(val));
}
}
}
return num;
}
private static float RatioOf(TMP_FontAsset font)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: 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)
if (!((Object)(object)font == (Object)null))
{
FaceInfo faceInfo = ((TMP_Asset)font).faceInfo;
if (!(((FaceInfo)(ref faceInfo)).pointSize <= 0f))
{
faceInfo = ((TMP_Asset)font).faceInfo;
float lineHeight = ((FaceInfo)(ref faceInfo)).lineHeight;
faceInfo = ((TMP_Asset)font).faceInfo;
return lineHeight / ((FaceInfo)(ref faceInfo)).pointSize;
}
}
return 1.6f;
}
internal static float RowHeightFor(float fontSize)
{
float num = Mathf.Clamp(MaxLineHeightRatio(ResolveFont()), 1.2f, 2.2f);
return Mathf.Ceil(fontSize * num) + 4f;
}
private static TMP_FontAsset FontFrom(TextMeshProUGUI text)
{
if (!((Object)(object)text != (Object)null))
{
return null;
}
return ((TMP_Text)text).font;
}
internal static RectTransform Rect(GameObject go)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
return (RectTransform)go.transform;
}
private static GameObject NewUIObject(string name, Transform parent)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: 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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
if (_uiLayer < 0)
{
int num = LayerMask.NameToLayer("UI");
_uiLayer = ((num >= 0) ? num : 5);
}
val.layer = _uiLayer;
val.transform.SetParent(parent, false);
RectTransform val2 = (RectTransform)val.transform;
((Transform)val2).localScale = Vector3.one;
((Transform)val2).localRotation = Quaternion.identity;
val2.anchoredPosition3D = Vector3.zero;
return val;
}
internal static Image CreatePanel(string name, Transform parent, Color color)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
Image obj = NewUIObject(name, parent).AddComponent<Image>();
((Graphic)obj).color = color;
((Graphic)obj).raycastTarget = false;
return obj;
}
internal static TextMeshProUGUI CreateText(string name, Transform parent, float fontSize, TextAlignmentOptions alignment, Color color)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
TextMeshProUGUI val = NewUIObject(name, parent).AddComponent<TextMeshProUGUI>();
TMP_FontAsset val2 = ResolveFont();
if ((Object)(object)val2 != (Object)null)
{
((TMP_Text)val).font = val2;
}
((TMP_Text)val).fontSize = fontSize;
((TMP_Text)val).enableAutoSizing = false;
((TMP_Text)val).alignment = alignment;
((Graphic)val).color = color;
((TMP_Text)val).richText = false;
((Graphic)val).raycastTarget = false;
((TMP_Text)val).margin = Vector4.zero;
((TMP_Text)val).textWrappingMode = (TextWrappingModes)0;
((TMP_Text)val).overflowMode = (TextOverflowModes)0;
return val;
}
internal static string Truncate(string value, int maxWidthInHalfChars)
{
if (string.IsNullOrEmpty(value))
{
return value;
}
int num = 0;
int num2 = -1;
bool flag = false;
TextElementEnumerator textElementEnumerator = StringInfo.GetTextElementEnumerator(value);
while (textElementEnumerator.MoveNext())
{
string element = (string)textElementEnumerator.Current;
int elementIndex = textElementEnumerator.ElementIndex;
num += ElementWidth(element);
if (num > maxWidthInHalfChars)
{
num2 = elementIndex;
break;
}
if (!flag)
{
flag = ContainsBidiOverride(element);
}
}
if (num2 < 0)
{
return value;
}
string text = value.Substring(0, num2) + "..";
if (!flag)
{
return text;
}
return text + "\u202c";
}
private static int ElementWidth(string element)
{
for (int i = 0; i < element.Length; i++)
{
if (IsWide(element[i]))
{
return 2;
}
}
if (element.Length >= 2 && char.IsHighSurrogate(element[0]))
{
return 2;
}
return 1;
}
private static bool ContainsBidiOverride(string element)
{
foreach (char c in element)
{
if ((c >= '\u202a' && c <= '\u202e') || (c >= '\u2066' && c <= '\u2069'))
{
return true;
}
}
return false;
}
private static bool IsWide(char c)
{
if (c < 'ᄀ')
{
return false;
}
if ((c >= '\u200b' && c <= '\u200f') || (c >= '\u202a' && c <= '\u202e') || (c >= '\u2066' && c <= '\u2069'))
{
return false;
}
if ((c < 'ᄀ' || c > 'ᅟ') && (c < '⺀' || c > '〾') && (c < 'ぁ' || c > '㏿') && (c < '㐀' || c > '䶿') && (c < '一' || c > '鿿') && (c < 'ꀀ' || c > '\ua4cf') && (c < '가' || c > '힣') && (c < '豈' || c > '\ufaff') && (c < '︰' || c > '\ufe6f') && (c < '\uff00' || c > '⦆'))
{
if (c >= '¢')
{
return c <= '₩';
}
return false;
}
return true;
}
internal static void Stretch(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 void SetTopLeft(RectTransform rect, float x, float y, float width, float height)
{
//IL_000b: 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)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
rect.anchorMin = new Vector2(0f, 1f);
rect.anchorMax = new Vector2(0f, 1f);
rect.pivot = new Vector2(0f, 1f);
rect.sizeDelta = new Vector2(width, height);
rect.anchoredPosition = new Vector2(x, 0f - y);
}
internal static void SetTopRight(RectTransform rect, float xFromRight, float y, float width, float height)
{
//IL_000b: 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)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
rect.anchorMin = new Vector2(1f, 1f);
rect.anchorMax = new Vector2(1f, 1f);
rect.pivot = new Vector2(1f, 1f);
rect.sizeDelta = new Vector2(width, height);
rect.anchoredPosition = new Vector2(0f - xFromRight, 0f - y);
}
internal static void SetStretchRow(RectTransform rect, float padLeft, float padRight, float y, float height)
{
//IL_000b: 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)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
rect.anchorMin = new Vector2(0f, 1f);
rect.anchorMax = new Vector2(1f, 1f);
rect.pivot = new Vector2(0.5f, 1f);
rect.offsetMin = new Vector2(padLeft, 0f - y - height);
rect.offsetMax = new Vector2(0f - padRight, 0f - y);
}
internal static void SetBottomRow(RectTransform rect, float padLeft, float padRight, float y, float height)
{
//IL_000b: 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)
//IL_0035: 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_0053: Unknown result type (might be due to invalid IL or missing references)
rect.anchorMin = new Vector2(0f, 0f);
rect.anchorMax = new Vector2(1f, 0f);
rect.pivot = new Vector2(0.5f, 0f);
rect.offsetMin = new Vector2(padLeft, y);
rect.offsetMax = new Vector2(0f - padRight, y + height);
}
}
internal static class TeleportService
{
private const int RingSamples = 8;
private const float ClearanceRadius = 0.35f;
private const float GroundProbeDistance = 4f;
private const float DeathVoidHeight = 3000f;
private static float _lastTeleportTime = -999f;
internal static float CooldownRemaining
{
get
{
float num = _lastTeleportTime + STConfig.CooldownSeconds.Value - Time.unscaledTime;
if (!(num > 0f))
{
return 0f;
}
return num;
}
}
internal static bool IsPositionReady(Character character)
{
if ((Object)(object)character == (Object)null || character.refs == null)
{
return false;
}
CharacterRagdoll ragdoll = character.refs.ragdoll;
if ((Object)(object)ragdoll == (Object)null || ragdoll.partDict == null)
{
return false;
}
return ragdoll.partDict.ContainsKey((BodypartType)2);
}
internal static Vector3 AnchorPosition(Character character)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return character.GetSpectatePosition();
}
internal static bool CanTeleportNow(Character mover, Character anchor, out string reason)
{
reason = null;
if ((Object)(object)mover == (Object)null || (Object)(object)anchor == (Object)null || (Object)(object)mover == (Object)(object)anchor)
{
reason = STStrings.Unavailable;
return false;
}
if (!PhotonNetwork.InRoom)
{
reason = STStrings.Unavailable;
return false;
}
PhotonView photonView = ((MonoBehaviourPun)mover).photonView;
if ((Object)(object)photonView == (Object)null || photonView.ViewID < 1)
{
reason = STStrings.Unavailable;
return false;
}
if ((Object)(object)mover.data != (Object)null && mover.data.dead)
{
reason = (mover.IsLocal ? STStrings.SelfDead : STStrings.MoverDead);
return false;
}
if (!TryGetAnchorPosition(anchor, out var _))
{
reason = STStrings.AnchorUnknown;
return false;
}
if (mover.warping || anchor.warping)
{
reason = STStrings.Busy;
return false;
}
float cooldownRemaining = CooldownRemaining;
if (cooldownRemaining > 0f)
{
reason = STStrings.Cooldown(cooldownRemaining);
return false;
}
return true;
}
internal static bool Teleport(Character mover, Character anchor, out string message)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
if (!CanTeleportNow(mover, anchor, out message))
{
return false;
}
if (!TryGetAnchorPosition(anchor, out var position))
{
message = STStrings.AnchorUnknown;
return false;
}
Vector3 val = ResolveArrivalPoint(mover, anchor, position);
((MonoBehaviourPun)mover).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { val, true });
_lastTeleportTime = Time.unscaledTime;
STLog.Info($"Warp {mover.characterName} -> {val} (anchor {anchor.characterName})");
message = null;
return true;
}
internal static bool TryGetAnchorPosition(Character anchor, out Vector3 position)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
position = Vector3.zero;
if (!IsPositionReady(anchor))
{
return false;
}
position = AnchorPosition(anchor);
if ((Object)(object)anchor.data != (Object)null && anchor.data.dead && (((Vector3)(ref position)).sqrMagnitude < 1f || position.y > 3000f))
{
return false;
}
return true;
}
private static Vector3 ResolveArrivalPoint(Character mover, Character anchor, Vector3 anchorPosition)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_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_002e: 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_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: 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)
float value = STConfig.ArrivalOffset.Value;
Vector3 val = PreferredDirection(mover, anchor, anchorPosition);
float num = 45f;
for (int i = 0; i < 2; i++)
{
bool flag = i == 0;
for (int j = 0; j < 8; j++)
{
Vector3 val2 = Quaternion.AngleAxis(num * (float)j, Vector3.up) * val;
Vector3 val3 = anchorPosition + val2 * value;
if (IsClear(anchorPosition, val3) && (!flag || HasGroundBelow(val3)))
{
return val3;
}
}
}
return anchorPosition + Vector3.up * 0.25f;
}
private static Vector3 PreferredDirection(Character mover, Character anchor, Vector3 anchorPosition)
{
//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_0007: 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_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = AnchorPosition(mover) - anchorPosition;
val.y = 0f;
if (((Vector3)(ref val)).sqrMagnitude > 0.0001f)
{
return ((Vector3)(ref val)).normalized;
}
if ((Object)(object)anchor.data != (Object)null)
{
Vector3 lookDirection = anchor.data.lookDirection;
lookDirection.y = 0f;
if (((Vector3)(ref lookDirection)).sqrMagnitude > 0.0001f)
{
return ((Vector3)(ref lookDirection)).normalized;
}
}
return Vector3.forward;
}
private static bool IsClear(Vector3 anchorPosition, Vector3 candidate)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: 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)
LayerMask terrainMapMask = HelperFunctions.terrainMapMask;
if (Physics.CheckSphere(candidate, 0.35f, LayerMask.op_Implicit(terrainMapMask), (QueryTriggerInteraction)1))
{
return false;
}
Vector3 val = candidate - anchorPosition;
float magnitude = ((Vector3)(ref val)).magnitude;
if (magnitude < 0.01f)
{
return false;
}
return !Physics.Raycast(anchorPosition, val / magnitude, magnitude, LayerMask.op_Implicit(terrainMapMask), (QueryTriggerInteraction)1);
}
private static bool HasGroundBelow(Vector3 candidate)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
return Physics.Raycast(candidate, Vector3.down, 4f, LayerMask.op_Implicit(HelperFunctions.terrainMapMask), (QueryTriggerInteraction)1);
}
}
}