Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of PortalSelector v1.0.1
plugins/PortalSelector.dll
Decompiled a week ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("PortalSelector")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+e7c8c6e1936757ff04de0f8462655ec37ee47391")] [assembly: AssemblyProduct("PortalSelector")] [assembly: AssemblyTitle("PortalSelector")] [assembly: AssemblyVersion("1.0.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 PortalSelector { internal static class GameMapView { private static GameObject _root; private static Component _image; private static PropertyInfo _uvRect; private static RectTransform _rect; private static Material _material; public static bool Active { get { if ((Object)(object)_root != (Object)null) { return (Object)(object)_image != (Object)null; } return false; } } public static bool Show() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //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_00ca: 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_00da: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown Hide(); Component largeMapImage = MinimapData.LargeMapImage; if ((Object)(object)largeMapImage == (Object)null) { return false; } object value = Traverse.Create((object)largeMapImage).Property("texture", (object[])null).GetValue(); Texture val = (Texture)((value is Texture) ? value : null); object value2 = Traverse.Create((object)largeMapImage).Property("material", (object[])null).GetValue(); Material val2 = (Material)((value2 is Material) ? value2 : null); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { return false; } try { _root = new GameObject("PortalSelector_GameMap"); Object.DontDestroyOnLoad((Object)(object)_root); Canvas obj = _root.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 1000; GameObject val3 = new GameObject("Map", new Type[1] { typeof(RectTransform) }); val3.transform.SetParent(_root.transform, false); _rect = (RectTransform)val3.transform; _rect.anchorMin = Vector2.zero; _rect.anchorMax = Vector2.zero; _rect.pivot = Vector2.zero; _material = new Material(val2); Type type = ((object)largeMapImage).GetType(); _image = val3.AddComponent(type); Traverse obj2 = Traverse.Create((object)_image); obj2.Property("texture", (object[])null).SetValue((object)val); obj2.Property("material", (object[])null).SetValue((object)_material); obj2.Property("raycastTarget", (object[])null).SetValue((object)false); _uvRect = AccessTools.Property(type, "uvRect"); if (_uvRect == null) { throw new MissingMemberException(type.Name, "uvRect"); } _root.SetActive(false); return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not clone the game map, using the fallback map: " + ex.Message)); Hide(); return false; } } public static void Place(Rect screenRect, Rect uv) { //IL_0022: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if (Active) { _rect.anchoredPosition = new Vector2(((Rect)(ref screenRect)).x, (float)Screen.height - ((Rect)(ref screenRect)).yMax); _rect.sizeDelta = new Vector2(((Rect)(ref screenRect)).width, ((Rect)(ref screenRect)).height); _uvRect.SetValue(_image, uv, null); SetFloat("_zoom", ((Rect)(ref uv)).width); SetFloat("_pixelSize", 200f / Mathf.Max(0.0001f, ((Rect)(ref uv)).width)); if (_material.HasProperty("_mapCenter")) { _material.SetVector("_mapCenter", Vector4.op_Implicit(MinimapData.UVToWorld(((Rect)(ref uv)).center))); } if (!_root.activeSelf) { _root.SetActive(true); } } } public static void Hide() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } if ((Object)(object)_material != (Object)null) { Object.Destroy((Object)(object)_material); } _root = null; _image = null; _uvRect = null; _rect = null; _material = null; } private static void SetFloat(string name, float value) { if (_material.HasProperty(name)) { _material.SetFloat(name, value); } } } internal enum UiLanguage { Auto, English, Korean } internal static class Lang { private static readonly Dictionary<string, string[]> Table = new Dictionary<string, string[]> { ["title_main"] = new string[2] { "Main Portal", "메인 포탈" }, ["title_select"] = new string[2] { "Portal Selector", "포탈 선택" }, ["main_portal"] = new string[2] { "Main portal", "메인 포탈" }, ["main_short"] = new string[2] { "Main", "메인" }, ["main_tag"] = new string[2] { "[Main] ", "[메인] " }, ["current_portal"] = new string[2] { "This portal", "현재 포탈" }, ["current_main"] = new string[2] { "Main portal (here)", "메인 포탈 (현재)" }, ["search"] = new string[2] { "Search tags…", "태그 검색…" }, ["search_count"] = new string[2] { "Search tags… ({0})", "태그 검색… ({0}개)" }, ["refresh"] = new string[2] { "Refresh", "새로고침" }, ["map_help"] = new string[2] { "Wheel: zoom · Drag: pan · Click a portal: select", "휠: 확대/축소 · 드래그: 이동 · 포탈 클릭: 선택" }, ["no_response"] = new string[2] { "The server is not responding.\nMake sure this mod is installed on the server too.", "서버가 응답하지 않습니다.\n서버에도 이 모드가 설치되어 있는지 확인하세요." }, ["loading"] = new string[2] { "Loading portals…", "포탈 목록을 불러오는 중…" }, ["no_portals"] = new string[2] { "No tagged portals yet.", "태그가 있는 포탈이 없습니다." }, ["no_results"] = new string[2] { "No matching portals.", "검색 결과가 없습니다." }, ["no_map"] = new string[2] { "Map texture is not available.", "지도 텍스처를 가져올 수 없습니다." }, ["linked_label"] = new string[2] { "Linked to", "현재 연결" }, ["none"] = new string[2] { "none", "없음" }, ["selected_label"] = new string[2] { "Selected", "선택" }, ["select_hint"] = new string[2] { "Pick a portal from the list or the map", "목록이나 지도에서 포탈을 고르세요" }, ["btn_connect"] = new string[2] { "Connect", "연결" }, ["btn_disconnect"] = new string[2] { "Disconnect", "연결 해제" }, ["btn_set_main"] = new string[2] { "Set as main", "메인 지정" }, ["btn_unset_main"] = new string[2] { "Unset main", "메인 해제" }, ["btn_tag"] = new string[2] { "Edit tag", "태그 입력" }, ["btn_close"] = new string[2] { "Close", "닫기" }, ["msg_connected"] = new string[2] { "Connected to '{0}'", "'{0}' 포탈과 연결되었습니다" }, ["msg_disconnected"] = new string[2] { "Portal link removed", "포탈 연결을 해제했습니다" }, ["msg_main_set"] = new string[2] { "This is now the main portal. Every tagged portal leads here.", "이 포탈을 메인 포탈로 지정했습니다. 이제 태그 포탈에 들어가면 여기로 옵니다" }, ["msg_main_unset"] = new string[2] { "Main portal unset", "메인 포탈 지정을 해제했습니다" }, ["hover_selector"] = new string[2] { "Portal selector", "포탈 선택창" }, ["hover_to_main"] = new string[2] { "→ Main portal ({0})", "→ 메인 포탈 ({0})" }, ["legend_selected"] = new string[2] { "Selected", "선택" }, ["legend_linked"] = new string[2] { "Linked", "연결됨" }, ["legend_me"] = new string[2] { "You", "나" }, ["portal_wood"] = new string[2] { "Wood portal", "나무 포탈" }, ["portal_stone"] = new string[2] { "Stone portal", "돌 포탈" }, ["portal_ancient"] = new string[2] { "Ancient portal", "고대 포탈" } }; private static bool _korean; private static float _nextCheck = -1f; public static bool IsKorean { get { if (Time.unscaledTime >= _nextCheck) { _nextCheck = Time.unscaledTime + 3f; _korean = ResolveKorean(); } return _korean; } } public static string T(string key, params object[] args) { if (!Table.TryGetValue(key, out var value)) { return key; } string text = value[IsKorean ? 1u : 0u]; if (args.Length != 0) { return string.Format(text, args); } return text; } private static bool ResolveKorean() { switch (Plugin.Language.Value) { case UiLanguage.Korean: return true; case UiLanguage.English: return false; default: if (Localization.instance == null) { return false; } return Traverse.Create((object)Localization.instance).Method("GetSelectedLanguage", Array.Empty<object>()).GetValue() as string == "Korean"; } } } internal static class MinimapData { private const int FogResolution = 512; private static readonly Color FogColor = new Color(0.36f, 0.33f, 0.28f, 0.93f); private static readonly Color32 Clear = new Color32((byte)0, (byte)0, (byte)0, (byte)0); private static Texture2D _fog; private static Color32[] _fogPixels; private static int _textureSize = 2048; private static float _pixelSize = 12f; public static Texture MapTexture { get; private set; } public static Texture FogTexture { get; private set; } public static Component LargeMapImage { get; private set; } public static Sprite PlayerMarker { get; private set; } public static void Refresh() { MapTexture = null; FogTexture = null; LargeMapImage = null; PlayerMarker = null; Minimap instance = Minimap.instance; if (!((Object)(object)instance == (Object)null)) { Traverse val = Traverse.Create((object)instance); int value = val.Field("m_textureSize").GetValue<int>(); float value2 = val.Field("m_pixelSize").GetValue<float>(); if (value > 0) { _textureSize = value; } if (value2 > 0f) { _pixelSize = value2; } object value3 = val.Field("m_mapImageLarge").GetValue(); LargeMapImage = (Component)((value3 is Component) ? value3 : null); object value4 = val.Field("m_mapTexture").GetValue(); MapTexture = (Texture)((value4 is Texture) ? value4 : null); if ((Object)(object)MapTexture == (Object)null && (Object)(object)LargeMapImage != (Object)null) { object value5 = Traverse.Create((object)LargeMapImage).Property("texture", (object[])null).GetValue(); MapTexture = (Texture)((value5 is Texture) ? value5 : null); } object value6 = val.Field("m_largeMarker").GetValue(); Component val2 = (Component)((value6 is Component) ? value6 : null); Component val3 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent("Image") : null); PlayerMarker = (Sprite)(((Object)(object)val3 != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); if (Plugin.HideUnexploredMap.Value) { BuildFog(val); } } } public static Vector2 WorldToUV(Vector3 world) { //IL_000d: 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_0037: Unknown result type (might be due to invalid IL or missing references) float num = (float)_textureSize / 2f; return new Vector2((world.x / _pixelSize + num) / (float)_textureSize, (world.z / _pixelSize + num) / (float)_textureSize); } public static Vector3 UVToWorld(Vector2 uv) { //IL_000d: 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) float num = (float)_textureSize / 2f; return new Vector3((uv.x * (float)_textureSize - num) * _pixelSize, 0f, (uv.y * (float)_textureSize - num) * _pixelSize); } private static Color32 Cloud(int x, int y, int size) { //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) float num = (float)x / (float)size; float num2 = (float)y / (float)size; float num3 = Mathf.PerlinNoise(num * 9f, num2 * 9f) * 0.65f + Mathf.PerlinNoise(num * 31f + 7f, num2 * 31f + 3f) * 0.35f; float num4 = 0.78f + num3 * 0.4f; return Color32.op_Implicit(new Color(FogColor.r * num4, FogColor.g * num4, FogColor.b * num4, FogColor.a)); } private static Func<int, bool> ExploredReader(object value, int requiredLength) { BitArray bitArray = value as BitArray; if (bitArray == null) { bool[] array = value as bool[]; if (array != null && array.Length >= requiredLength) { return (int i) => array[i]; } } else if (bitArray.Length >= requiredLength) { return (int i) => bitArray[i]; } return null; } private static void BuildFog(Traverse minimap) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_00f1: 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_00f6: Unknown result type (might be due to invalid IL or missing references) int textureSize = _textureSize; Func<int, bool> func = ExploredReader(minimap.Field("m_explored").GetValue(), textureSize * textureSize); Func<int, bool> func2 = ExploredReader(minimap.Field("m_exploredOthers").GetValue(), textureSize * textureSize); if (func == null) { return; } int num = Mathf.Max(1, textureSize / 512); int num2 = textureSize / num; if ((Object)(object)_fog == (Object)null || ((Texture)_fog).width != num2) { _fog = new Texture2D(num2, num2, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; _fogPixels = (Color32[])(object)new Color32[num2 * num2]; } for (int i = 0; i < num2; i++) { int num3 = i * num * textureSize; int num4 = i * num2; for (int j = 0; j < num2; j++) { int arg = num3 + j * num; bool flag = func(arg) || (func2?.Invoke(arg) ?? false); _fogPixels[num4 + j] = (flag ? Clear : Cloud(j, i, num2)); } } _fog.SetPixels32(_fogPixels); _fog.Apply(false); FogTexture = (Texture)(object)_fog; } } [BepInPlugin("lazly.valheim.portalselector", "PortalSelector", "1.0.1")] public class Plugin : BaseUnityPlugin { public const string ModGuid = "lazly.valheim.portalselector"; public const string ModName = "PortalSelector"; public const string ModVersion = "1.0.1"; internal static ManualLogSource Log; internal static ConfigEntry<string> PortalPrefabs; internal static ConfigEntry<bool> RespectTeleportRestrictions; internal static ConfigEntry<ReturnToMainMode> ReturnToMain; internal static ConfigEntry<bool> HideUnexploredMap; internal static ConfigEntry<bool> ShowMapLabels; internal static ConfigEntry<bool> UseGameFont; internal static ConfigEntry<UiLanguage> Language; internal static ConfigEntry<bool> UseGameMap; private Harmony _harmony; private void Awake() { //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_011f: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; PortalPrefabs = ((BaseUnityPlugin)this).Config.Bind<string>("General", "PortalPrefabs", "portal_wood,portal_stone,portal", "Portal prefab names included in the list (comma separated). Add portals from other mods here. The server's value is used."); ReturnToMain = ((BaseUnityPlugin)this).Config.Bind<ReturnToMainMode>("General", "ReturnToMain", ReturnToMainMode.Always, "Where tagged portals lead. Always = every tagged portal goes to the main portal, UnpairedOnly = only tagged portals without a vanilla pair, Off = vanilla behaviour. Each player's own setting is used."); RespectTeleportRestrictions = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "RespectTeleportRestrictions", true, "Block teleporting with non-teleportable items (ores etc.) like vanilla."); HideUnexploredMap = ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "HideUnexploredMap", true, "When the fallback map is used, cover unexplored areas with fog (the game map already has its own fog)."); ShowMapLabels = ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "ShowMapLabels", true, "Show portal tag names on the map."); UseGameMap = ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "UseGameMap", true, "Show the game's own large map (M key map) in the window. Set to false if the map is missing or misaligned."); Language = ((BaseUnityPlugin)this).Config.Bind<UiLanguage>("UI", "Language", UiLanguage.Auto, "UI language. Auto = Korean when the game language is Korean, otherwise English."); UseGameFont = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "UseGameFont", true, "Use Valheim fonts (Averia Serif, Norse) in the window. Set to false if text looks broken."); GameObject val = new GameObject("PortalSelector_UI"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<PortalSelectorUI>(); _harmony = new Harmony("lazly.valheim.portalselector"); _harmony.PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)"PortalSelector 1.0.1 loaded"); } } internal struct PortalInfo { public ZDOID Id; public string Tag; public string Prefab; public Vector3 Position; public Quaternion Rotation; public bool IsMain; } internal struct PortalLink { public string Tag; public Vector3 Position; public Quaternion Rotation; } internal enum ReturnToMainMode { Always, UnpairedOnly, Off } internal static class PortalNetwork { private const string RpcRequestList = "PortalSelector_RequestList"; private const string RpcPortalList = "PortalSelector_PortalList"; private const string RpcRequestMain = "PortalSelector_RequestMain"; private const string RpcAnnounceMain = "PortalSelector_AnnounceMain"; private const string RpcMainInfo = "PortalSelector_MainInfo"; private const string RpcSetLink = "PortalSelector_SetLink"; private const string RpcSetMainStamp = "PortalSelector_SetMainStamp"; private static readonly int KeyTag = ZDOVars.s_tag; private const string KeyLinkTag = "PortalSelector_LinkTag"; private const string KeyLinkPos = "PortalSelector_LinkPos"; private const string KeyLinkRot = "PortalSelector_LinkRot"; private const string KeyMainStamp = "PortalSelector_MainStamp"; private const float ServerMainCacheSeconds = 30f; private const float ClientMainRefreshSeconds = 20f; private static bool _mainKnown; private static PortalInfo? _serverMain; private static float _serverMainTime = -1000f; private static float _nextMainRequest; private static bool _hadPlayer; private static readonly List<ZDO> TempZdos = new List<ZDO>(); private const string MainLinkMarker = "\u0001main"; private const string LegacyMainLinkText = "메인 포탈"; public static PortalInfo? MainPortal { get; private set; } public static event Action<List<PortalInfo>> PortalListReceived; public static void RegisterGlobalRpcs() { ZRoutedRpc.instance.Register<ZPackage>("PortalSelector_RequestList", (Action<long, ZPackage>)OnRequestList); ZRoutedRpc.instance.Register<ZPackage>("PortalSelector_PortalList", (Action<long, ZPackage>)OnPortalList); ZRoutedRpc.instance.Register<ZPackage>("PortalSelector_RequestMain", (Action<long, ZPackage>)OnRequestMain); ZRoutedRpc.instance.Register<ZPackage>("PortalSelector_AnnounceMain", (Action<long, ZPackage>)OnAnnounceMain); ZRoutedRpc.instance.Register<ZPackage>("PortalSelector_MainInfo", (Action<long, ZPackage>)OnMainInfo); MainPortal = null; _mainKnown = false; _serverMain = null; _serverMainTime = -1000f; _hadPlayer = false; Plugin.Log.LogInfo((object)"Portal RPCs registered"); } public static void RegisterPortalRpcs(ZNetView nview) { nview.Register<ZPackage>("PortalSelector_SetLink", (Action<long, ZPackage>)delegate(long sender, ZPackage pkg) { OnSetLink(nview, pkg); }); nview.Register<long>("PortalSelector_SetMainStamp", (Action<long, long>)delegate(long sender, long stamp) { OnSetMainStamp(nview, stamp); }); } public static void Tick() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown if (!((Object)(object)Player.m_localPlayer != (Object)null) || ZRoutedRpc.instance == null) { _hadPlayer = false; } else if (!_hadPlayer || Time.unscaledTime >= _nextMainRequest) { _hadPlayer = true; _nextMainRequest = Time.unscaledTime + 20f; ZRoutedRpc.instance.InvokeRoutedRPC(0L, "PortalSelector_RequestMain", new object[1] { (object)new ZPackage() }); } } public static void RequestPortalList() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.InvokeRoutedRPC(0L, "PortalSelector_RequestList", new object[1] { (object)new ZPackage() }); } } private static void OnRequestList(long sender, ZPackage _) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown if (!IsServer()) { return; } List<PortalInfo> list = ScanPortals(); ZPackage val = new ZPackage(); val.Write(list.Count); foreach (PortalInfo item in list) { WritePortal(val, item); } Plugin.Log.LogInfo((object)$"Portal list requested by {sender} -> sending {list.Count} portals"); ZRoutedRpc.instance.InvokeRoutedRPC(sender, "PortalSelector_PortalList", new object[1] { val }); } private static void OnPortalList(long sender, ZPackage pkg) { List<PortalInfo> list = new List<PortalInfo>(); int num = pkg.ReadInt(); PortalInfo? clientMain = null; for (int i = 0; i < num; i++) { PortalInfo portalInfo = ReadPortal(pkg); list.Add(portalInfo); if (portalInfo.IsMain) { clientMain = portalInfo; } } SetClientMain(clientMain); Plugin.Log.LogInfo((object)string.Format("Portal list received: {0}, main: {1}", list.Count, clientMain.HasValue ? DisplayTag(clientMain.Value.Tag) : "none")); PortalNetwork.PortalListReceived?.Invoke(list); } private static List<PortalInfo> ScanPortals() { //IL_008c: 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_0105: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012e: 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) List<PortalInfo> list = new List<PortalInfo>(); HashSet<ZDOID> hashSet = new HashSet<ZDOID>(); int num = -1; long num2 = 0L; string[] array = Plugin.PortalPrefabs.Value.Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length == 0) { continue; } TempZdos.Clear(); int num3 = 0; while (!ZDOMan.instance.GetAllZDOsWithPrefabIterative(text, TempZdos, ref num3)) { } foreach (ZDO tempZdo in TempZdos) { if (hashSet.Add(tempZdo.m_uid)) { string text2 = tempZdo.GetString(KeyTag, ""); long num4 = tempZdo.GetLong("PortalSelector_MainStamp", 0L); if (num4 != 0L && Math.Abs(num4) > num2) { num2 = Math.Abs(num4); num = ((num4 > 0) ? list.Count : (-1)); } if (!string.IsNullOrEmpty(text2) || num4 > 0) { list.Add(new PortalInfo { Id = tempZdo.m_uid, Tag = text2, Prefab = text, Position = tempZdo.GetPosition(), Rotation = tempZdo.GetRotation() }); } } } } TempZdos.Clear(); PortalInfo? serverMain = null; if (num >= 0) { PortalInfo value = list[num]; value.IsMain = true; list[num] = value; serverMain = value; } list.RemoveAll((PortalInfo p) => !p.IsMain && string.IsNullOrEmpty(p.Tag)); _serverMain = serverMain; _serverMainTime = Time.realtimeSinceStartup; return list; } private static void OnRequestMain(long sender, ZPackage _) { if (IsServer()) { if (Time.realtimeSinceStartup - _serverMainTime > 30f) { ScanPortals(); } ZRoutedRpc.instance.InvokeRoutedRPC(sender, "PortalSelector_MainInfo", new object[1] { MainPackage(_serverMain) }); } } private static void OnAnnounceMain(long sender, ZPackage pkg) { //IL_0044: 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_0090: Unknown result type (might be due to invalid IL or missing references) if (IsServer()) { bool flag = pkg.ReadBool(); PortalInfo value = ReadPortal(pkg); if (flag) { value.IsMain = true; _serverMain = value; } else if (_serverMain.HasValue && _serverMain.Value.Id == value.Id) { _serverMain = null; } _serverMainTime = Time.realtimeSinceStartup; Plugin.Log.LogInfo((object)string.Format("Main portal {0}: {1} ({2})", flag ? "set" : "unset", DisplayTag(value.Tag), value.Position)); ZRoutedRpc.instance.InvokeRoutedRPC(0L, "PortalSelector_MainInfo", new object[1] { MainPackage(_serverMain) }); } } private static void OnMainInfo(long sender, ZPackage pkg) { SetClientMain(pkg.ReadBool() ? new PortalInfo?(ReadPortal(pkg)) : ((PortalInfo?)null)); } private static void SetClientMain(PortalInfo? main) { //IL_0033: 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_0094: Unknown result type (might be due to invalid IL or missing references) bool num = !_mainKnown || MainPortal.HasValue != main.HasValue || (main.HasValue && MainPortal.Value.Id != main.Value.Id); MainPortal = main; _mainKnown = true; if (num) { Plugin.Log.LogInfo((object)("Main portal: " + (main.HasValue ? $"{DisplayTag(main.Value.Tag)} ({main.Value.Position})" : "none"))); } } public static void SetMain(TeleportWorld portal, bool makeMain) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) ZNetView component = ((Component)portal).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { ZDO zDO = component.GetZDO(); long ticks = DateTime.UtcNow.Ticks; component.InvokeRPC("PortalSelector_SetMainStamp", new object[1] { makeMain ? ticks : (-ticks) }); if (makeMain && MainPortal.HasValue && MainPortal.Value.Id != zDO.m_uid) { ClearStampIfLoaded(MainPortal.Value.Id, ticks); } PortalInfo portalInfo = FromPortal(portal, zDO, makeMain); ZPackage val = new ZPackage(); val.Write(makeMain); WritePortal(val, portalInfo); ZRoutedRpc.instance.InvokeRoutedRPC(0L, "PortalSelector_AnnounceMain", new object[1] { val }); if (makeMain) { SetClientMain(portalInfo); } else if (MainPortal.HasValue && MainPortal.Value.Id == zDO.m_uid) { SetClientMain(null); } } } private static void ClearStampIfLoaded(ZDOID id, long now) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) ZDO zDO = ZDOMan.instance.GetZDO(id); ZNetView val = ((zDO != null && (Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.FindInstance(zDO) : null); if ((Object)(object)val != (Object)null && val.IsValid()) { val.InvokeRPC("PortalSelector_SetMainStamp", new object[1] { -(now - 1) }); } } private static void OnSetMainStamp(ZNetView nview, long stamp) { if (!((Object)(object)nview == (Object)null) && nview.IsValid() && nview.IsOwner()) { nview.GetZDO().Set("PortalSelector_MainStamp", stamp); } } public static bool IsMain(TeleportWorld portal) { //IL_002f: 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) ZDO zdo = GetZdo(portal); if (zdo == null) { return false; } if (_mainKnown) { if (MainPortal.HasValue) { return MainPortal.Value.Id == zdo.m_uid; } return false; } return zdo.GetLong("PortalSelector_MainStamp", 0L) > 0; } public static bool IsSelectorPortal(TeleportWorld portal) { if (!IsMain(portal)) { return IsUntagged(portal); } return true; } public static bool TryGetMainRoute(TeleportWorld portal, out PortalInfo main) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) main = default(PortalInfo); if (Plugin.ReturnToMain.Value == ReturnToMainMode.Off || !MainPortal.HasValue) { return false; } ZDO zdo = GetZdo(portal); if (zdo == null || string.IsNullOrEmpty(zdo.GetString(KeyTag, "")) || IsMain(portal)) { return false; } if (Plugin.ReturnToMain.Value == ReturnToMainMode.UnpairedOnly && zdo.GetConnectionZDOID((ConnectionType)1) != ZDOID.None) { return false; } main = MainPortal.Value; return true; } public static string GetTag(TeleportWorld portal) { ZDO zdo = GetZdo(portal); if (zdo != null) { return zdo.GetString(KeyTag, ""); } return null; } public static bool IsUntagged(TeleportWorld portal) { ZDO zdo = GetZdo(portal); if (zdo != null) { return string.IsNullOrEmpty(zdo.GetString(KeyTag, "")); } return false; } public static bool TryGetLink(TeleportWorld portal, out PortalLink link) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) link = default(PortalLink); ZDO zdo = GetZdo(portal); if (zdo == null) { return false; } string text = zdo.GetString("PortalSelector_LinkTag", ""); if (string.IsNullOrEmpty(text)) { return false; } link = new PortalLink { Tag = text, Position = zdo.GetVec3("PortalSelector_LinkPos", Vector3.zero), Rotation = zdo.GetQuaternion("PortalSelector_LinkRot", Quaternion.identity) }; return true; } public static void SetLink(TeleportWorld portal, PortalInfo? target) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_005e: 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_0080: 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) ZNetView component = ((Component)portal).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { ZPackage val = new ZPackage(); val.Write(target.HasValue ? LinkTag(target.Value.Tag) : ""); val.Write(target.HasValue ? target.Value.Position : Vector3.zero); val.Write(target.HasValue ? target.Value.Rotation : Quaternion.identity); component.InvokeRPC("PortalSelector_SetLink", new object[1] { val }); } } private static void OnSetLink(ZNetView nview, ZPackage pkg) { //IL_0038: 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) if (!((Object)(object)nview == (Object)null) && nview.IsValid() && nview.IsOwner()) { ZDO zDO = nview.GetZDO(); zDO.Set("PortalSelector_LinkTag", pkg.ReadString()); zDO.Set("PortalSelector_LinkPos", pkg.ReadVector3()); zDO.Set("PortalSelector_LinkRot", pkg.ReadQuaternion()); } } public static string DisplayTag(string tag) { if (!string.IsNullOrEmpty(tag) && !(tag == "\u0001main") && !(tag == "메인 포탈")) { return tag; } return Lang.T("main_portal"); } public static string LinkTag(string tag) { if (!string.IsNullOrEmpty(tag) && !(tag == "메인 포탈")) { return tag; } return "\u0001main"; } private static bool IsServer() { if ((Object)(object)ZNet.instance != (Object)null) { return ZNet.instance.IsServer(); } return false; } private static PortalInfo FromPortal(TeleportWorld portal, ZDO zdo, bool isMain) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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) return new PortalInfo { Id = zdo.m_uid, Tag = zdo.GetString(KeyTag, ""), Prefab = ((Object)((Component)portal).gameObject).name.Replace("(Clone)", "").Trim(), Position = zdo.GetPosition(), Rotation = zdo.GetRotation(), IsMain = isMain }; } private static ZPackage MainPackage(PortalInfo? main) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown ZPackage val = new ZPackage(); val.Write(main.HasValue); if (main.HasValue) { WritePortal(val, main.Value); } return val; } private static void WritePortal(ZPackage pkg, PortalInfo p) { //IL_0002: 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_0044: Unknown result type (might be due to invalid IL or missing references) pkg.Write(p.Id); pkg.Write(p.Tag ?? ""); pkg.Write(p.Prefab ?? ""); pkg.Write(p.Position); pkg.Write(p.Rotation); pkg.Write(p.IsMain); } private static PortalInfo ReadPortal(ZPackage pkg) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_003f: 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) return new PortalInfo { Id = pkg.ReadZDOID(), Tag = pkg.ReadString(), Prefab = pkg.ReadString(), Position = pkg.ReadVector3(), Rotation = pkg.ReadQuaternion(), IsMain = pkg.ReadBool() }; } private static ZDO GetZdo(TeleportWorld portal) { if ((Object)(object)portal == (Object)null) { return null; } ZNetView component = ((Component)portal).GetComponent<ZNetView>(); if (!((Object)(object)component != (Object)null) || !component.IsValid()) { return null; } return component.GetZDO(); } } [HarmonyPatch(typeof(Game), "Start")] internal static class GameStartPatch { private static void Postfix() { PortalNetwork.RegisterGlobalRpcs(); } } [HarmonyPatch(typeof(TeleportWorld), "Awake")] internal static class PortalAwakePatch { private static void Postfix(TeleportWorld __instance) { ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if ((Object)(object)component != (Object)null && component.GetZDO() != null) { PortalNetwork.RegisterPortalRpcs(component); } } } [HarmonyPatch(typeof(TeleportWorld), "Interact")] internal static class PortalInteractPatch { private static bool Prefix(TeleportWorld __instance, Humanoid human, bool hold, bool alt, ref bool __result) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) Player val = (Player)(object)((human is Player) ? human : null); if (val == null || (Object)(object)val != (Object)(object)Player.m_localPlayer) { return true; } bool flag = PortalNetwork.IsMain(__instance); Plugin.Log.LogInfo((object)$"Portal interact: tag='{PortalNetwork.GetTag(__instance)}' main={flag} hold={hold} alt={alt}"); if (hold || alt) { return true; } if (!flag && !PortalNetwork.IsUntagged(__instance)) { return true; } if (!PrivateArea.CheckAccess(((Component)__instance).transform.position, 0f, true, false)) { Plugin.Log.LogInfo((object)"No ward access, not opening the portal selector"); __result = true; return false; } PortalSelectorUI.Open(__instance); __result = true; return false; } } [HarmonyPatch(typeof(TeleportWorld), "GetHoverText")] internal static class PortalHoverTextPatch { private const string MainColor = "#ffcc5c"; private static void Postfix(TeleportWorld __instance, ref string __result) { bool flag = PortalNetwork.IsMain(__instance); PortalInfo main; if (flag || PortalNetwork.IsUntagged(__instance)) { string tag = PortalNetwork.GetTag(__instance); string text = (flag ? ("<color=#ffcc5c>" + Lang.T("main_portal") + "</color>" + (string.IsNullOrEmpty(tag) ? "" : (" \"" + PortalSelectorUI.SafeText(tag) + "\""))) : Localization.instance.Localize("$piece_portal")); PortalLink link; string text2 = (PortalNetwork.TryGetLink(__instance, out link) ? ("<color=#7fe0ff>→ " + PortalSelectorUI.SafeText(PortalNetwork.DisplayTag(link.Tag)) + "</color>") : Localization.instance.Localize("$piece_portal_unconnected")); __result = text + " [" + text2 + "]\n" + Localization.instance.Localize("[<color=yellow><b>$KEY_Use</b></color>] ") + Lang.T("hover_selector") + "\n" + Localization.instance.Localize("[<color=yellow><b>$KEY_AltPlace + $KEY_Use</b></color>] $piece_portal_settag"); } else if (PortalNetwork.TryGetMainRoute(__instance, out main)) { __result = __result + "\n<color=#ffcc5c>" + Lang.T("hover_to_main", PortalSelectorUI.SafeText(PortalNetwork.DisplayTag(main.Tag))) + "</color>"; } } } [HarmonyPatch(typeof(TeleportWorld), "Teleport")] internal static class PortalTeleportPatch { private static bool Prefix(TeleportWorld __instance, Player player) { //IL_004a: 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_0052: 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_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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || (Object)(object)player != (Object)(object)Player.m_localPlayer) { return true; } Vector3 position; Quaternion rotation; if (PortalNetwork.IsSelectorPortal(__instance)) { if (!PortalNetwork.TryGetLink(__instance, out var link)) { return true; } position = link.Position; rotation = link.Rotation; } else { if (!PortalNetwork.TryGetMainRoute(__instance, out var main)) { return true; } position = main.Position; rotation = main.Rotation; } if (Plugin.RespectTeleportRestrictions.Value && !CanTeleport(__instance, player)) { ((Character)player).Message((MessageType)2, "$msg_noteleport", 0, (Sprite)null, false); return false; } float num = Traverse.Create((object)__instance).Field("m_exitDistance").GetValue<float>(); if (num <= 0f) { num = 1f; } Vector3 val = position + rotation * Vector3.forward * num + Vector3.up; ((Character)player).TeleportTo(val, rotation, true); return false; } private static bool CanTeleport(TeleportWorld portal, Player player) { Traverse val = Traverse.Create((object)portal).Field("m_allowAllItems"); bool flag = val.FieldExists() && val.GetValue<bool>(); if (((Humanoid)player).IsTeleportable(flag)) { return true; } if ((Object)(object)ZoneSystem.instance != (Object)null) { return ZoneSystem.instance.GetGlobalKey("TeleportAll"); } return false; } } [HarmonyPatch] internal static class PortalTargetFoundPatch { private static IEnumerable<MethodBase> TargetMethods() { return (from m in AccessTools.GetDeclaredMethods(typeof(TeleportWorld)) where (m.Name == "TargetFound" || m.Name == "HaveTarget") && m.ReturnType == typeof(bool) && m.GetParameters().Length == 0 select m).Cast<MethodBase>(); } private static bool Prepare() { return TargetMethods().Any(); } private static void Postfix(TeleportWorld __instance, ref bool __result) { if (!__result) { __result = (PortalNetwork.IsSelectorPortal(__instance) ? PortalNetwork.TryGetLink(__instance, out var _) : PortalNetwork.TryGetMainRoute(__instance, out var _)); } } } [HarmonyPatch] internal static class BlockTakeInputPatch { private static IEnumerable<MethodBase> TargetMethods() { return (from m in ((IEnumerable<Type>)new Type[2] { typeof(PlayerController), typeof(Player) }).SelectMany((Func<Type, IEnumerable<MethodInfo>>)AccessTools.GetDeclaredMethods) where m.Name == "TakeInput" && m.ReturnType == typeof(bool) select m).Cast<MethodBase>(); } private static bool Prepare() { return TargetMethods().Any(); } private static void Postfix(ref bool __result) { if (PortalSelectorUI.IsOpen) { __result = false; } } } [HarmonyPatch] internal static class BlockGuiUpdatePatch { private static IEnumerable<MethodBase> TargetMethods() { return (from t in new Type[3] { typeof(Menu), typeof(InventoryGui), typeof(Minimap) } select AccessTools.DeclaredMethod(t, "Update", (Type[])null, (Type[])null) into m where m != null select m).Cast<MethodBase>(); } private static bool Prepare() { return TargetMethods().Any(); } private static bool Prefix() { return !PortalSelectorUI.IsOpen; } } [HarmonyPatch] internal static class MouseCapturePatch { private static IEnumerable<MethodBase> TargetMethods() { return (from m in AccessTools.GetDeclaredMethods(typeof(GameCamera)) where m.Name == "UpdateMouseCapture" select m).Cast<MethodBase>(); } private static bool Prepare() { return TargetMethods().Any(); } private static void Postfix() { if (PortalSelectorUI.IsOpen) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } } internal class PortalSelectorUI : MonoBehaviour { private const int WindowId = 5264204; private const float MaxUseDistance = 8f; private const float ListWidth = 320f; private const float ItemHeight = 36f; private const float BottomHeight = 64f; private const float MinZoom = 1f; private const float MaxZoom = 48f; private const float MarkerHitRadius = 14f; private const float RequestTimeout = 5f; private const string SearchControl = "PortalSelector_Search"; private TeleportWorld _portal; private readonly List<PortalInfo> _portals = new List<PortalInfo>(); private readonly List<string> _labels = new List<string>(); private readonly List<int> _visible = new List<int>(); private bool _loading; private float _requestTime; private int _selected = -1; private string _filter = ""; private Vector2 _listScroll; private Rect _windowRect; private Vector2 _mapCenter = new Vector2(0.5f, 0.5f); private float _zoom = 4f; private bool _dragging; private bool _loggedFirstDraw; private const float WindowPad = 20f; private const float MapFrameWidth = 9f; private const float MapButtonSize = 32f; private const float PortalIconSize = 22f; private const float ZoomStep = 1.5f; private static readonly Color MapTint = new Color(0.93f, 0.87f, 0.74f); private static readonly Color CurrentColor = new Color(0.95f, 0.93f, 0.88f); private static readonly Color MainColor = new Color(1f, 0.55f, 0.25f); private readonly List<Rect> _mapControls = new List<Rect>(); private Vector2 _viewCenter = new Vector2(0.5f, 0.5f); private float _viewZoom = 4f; internal static PortalSelectorUI Instance { get; private set; } internal static bool IsOpen { get { if ((Object)(object)Instance != (Object)null) { return (Object)(object)Instance._portal != (Object)null; } return false; } } private void Awake() { Instance = this; PortalNetwork.PortalListReceived += OnPortalListReceived; } private void OnDestroy() { PortalNetwork.PortalListReceived -= OnPortalListReceived; GameMapView.Hide(); if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } public static void Open(TeleportWorld portal) { if ((Object)(object)Instance != (Object)null) { Instance.OpenInternal(portal); } } private void OpenInternal(TeleportWorld portal) { //IL_003b: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) _portal = portal; _portals.Clear(); _labels.Clear(); _visible.Clear(); _selected = -1; _filter = ""; _listScroll = Vector2.zero; _dragging = false; _loading = true; _requestTime = Time.unscaledTime; float num = Mathf.Min(1200f, (float)Screen.width - 40f); float num2 = Mathf.Min(760f, (float)Screen.height - 40f); _windowRect = new Rect(((float)Screen.width - num) / 2f, ((float)Screen.height - num2) / 2f, num, num2); MinimapData.Refresh(); _mapCenter = MinimapData.WorldToUV(((Component)portal).transform.position); _zoom = 4f; _viewCenter = _mapCenter; _viewZoom = _zoom; bool flag = Plugin.UseGameMap.Value && GameMapView.Show(); Plugin.Log.LogInfo((object)($"Open portal selector: screen {Screen.width}x{Screen.height}, window {_windowRect}, " + "game map clone " + (flag ? "ok" : "off/failed") + ", map texture " + (((Object)(object)MinimapData.MapTexture != (Object)null) ? "yes" : "no"))); _loggedFirstDraw = false; PortalNetwork.RequestPortalList(); } public void Close() { if ((Object)(object)_portal != (Object)null) { Plugin.Log.LogInfo((object)"Close portal selector"); } _portal = null; _dragging = false; GameMapView.Hide(); } private void Update() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) PortalNetwork.Tick(); if (IsOpen) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || Vector3.Distance(((Component)localPlayer).transform.position, ((Component)_portal).transform.position) > 8f) { Close(); } } } private void LateUpdate() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0051: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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) if (IsOpen) { ComputeLayout(((Rect)(ref _windowRect)).width, ((Rect)(ref _windowRect)).height, out var _, out var mapRect); Rect val = MapInner(mapRect); float aspect = ((Rect)(ref val)).width / Mathf.Max(1f, ((Rect)(ref val)).height); ClampView(aspect); _viewCenter = _mapCenter; _viewZoom = _zoom; if (GameMapView.Active) { GameMapView.Place(new Rect(((Rect)(ref _windowRect)).x + ((Rect)(ref val)).x, ((Rect)(ref _windowRect)).y + ((Rect)(ref val)).y, ((Rect)(ref val)).width, ((Rect)(ref val)).height), ViewUV(_viewCenter, _viewZoom, aspect)); } } } private void OnPortalListReceived(List<PortalInfo> portals) { //IL_0037: 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_0044: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) if (!IsOpen) { return; } _loading = false; _portals.Clear(); ZNetView component = ((Component)_portal).GetComponent<ZNetView>(); ZDOID val = (((Object)(object)component != (Object)null && component.IsValid()) ? component.GetZDO().m_uid : ZDOID.None); foreach (PortalInfo portal in portals) { if (portal.Id != val) { _portals.Add(portal); } } _portals.Sort(delegate(PortalInfo a, PortalInfo b) { int num7 = string.Compare(a.Tag, b.Tag, StringComparison.OrdinalIgnoreCase); return (num7 == 0) ? DistanceTo(a).CompareTo(DistanceTo(b)) : num7; }); _labels.Clear(); for (int num = 0; num < _portals.Count; num++) { int num2 = 0; int num3 = 0; for (int num4 = 0; num4 < _portals.Count; num4++) { if (!(_portals[num4].Tag != _portals[num].Tag)) { num3++; if (num4 <= num) { num2++; } } } string text = SafeText(PortalNetwork.DisplayTag(_portals[num].Tag)); if (num3 > 1) { text = text + " #" + num2; } _labels.Add((_portals[num].IsMain && !string.IsNullOrEmpty(_portals[num].Tag)) ? (Lang.T("main_tag") + text) : text); } _selected = -1; if (PortalNetwork.TryGetLink(_portal, out var link)) { float num5 = float.MaxValue; for (int num6 = 0; num6 < _portals.Count; num6++) { if (!(PortalNetwork.LinkTag(_portals[num6].Tag) != PortalNetwork.LinkTag(link.Tag))) { Vector3 val2 = _portals[num6].Position - link.Position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num5) { num5 = sqrMagnitude; _selected = num6; } } } } RebuildVisible(); } private void RebuildVisible() { _visible.Clear(); string text = _filter.Trim(); for (int i = 0; i < _portals.Count; i++) { if (text.Length == 0 || _portals[i].Tag.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0) { _visible.Add(i); } } } private void OnGUI() { if (!IsOpen) { return; } try { DrawGui(); } catch (Exception ex) { Plugin.Log.LogError((object)("Error while drawing the portal selector, closing it: " + ex)); Close(); } } private void DrawGui() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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) //IL_00f6: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Invalid comparison between Unknown and I4 if (!_loggedFirstDraw && (int)Event.current.type == 7) { _loggedFirstDraw = true; Plugin.Log.LogInfo((object)"Portal selector first draw"); } Event current = Event.current; if ((int)current.type == 4 && (int)current.keyCode == 27) { current.Use(); Close(); return; } ValheimStyle.Ensure(); GUI.skin = ValheimStyle.Skin; GUI.depth = -1000; ValheimStyle.DrawTextureExcept(new Rect(((Rect)(ref _windowRect)).x - 28f, ((Rect)(ref _windowRect)).y - 28f + 8f, ((Rect)(ref _windowRect)).width + 56f, ((Rect)(ref _windowRect)).height + 56f), ScreenMapHole(), (Texture)(object)ValheimStyle.Shadow, tiled: false); _windowRect = GUI.Window(5264204, _windowRect, new WindowFunction(DrawWindow), GUIContent.none, ValheimStyle.Skin.window); } private void DrawWindow(int id) { //IL_002f: 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_0043: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_022a: 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_025f: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) float width = ((Rect)(ref _windowRect)).width; float height = ((Rect)(ref _windowRect)).height; ComputeLayout(width, height, out var listRect, out var mapRect); ValheimStyle.DrawPanel(new Rect(0f, 0f, width, height), GameMapView.Active ? MapInner(mapRect) : Rect.zero); string text = (PortalNetwork.IsMain(_portal) ? Lang.T("title_main") : Lang.T("title_select")); ValheimStyle.ShadowLabel(new Rect(0f, 10f, width, 38f), text, ValheimStyle.Title, ValheimStyle.Gold); ValheimStyle.DrawDivider(40f, 52f, width - 80f); if (GUI.Button(new Rect(width - 20f - 34f, 14f, 34f, 32f), "X", ValheimStyle.CloseButton)) { Close(); return; } float num = 66f; Rect val = default(Rect); ((Rect)(ref val))..ctor(20f, num, 320f, 34f); GUI.SetNextControlName("PortalSelector_Search"); string text2 = GUI.TextField(val, _filter, 32); if (text2 != _filter) { _filter = text2; RebuildVisible(); } if (_filter.Length == 0 && GUI.GetNameOfFocusedControl() != "PortalSelector_Search") { string text3 = (_loading ? Lang.T("search") : Lang.T("search_count", _portals.Count)); GUI.Label(val, text3, ValheimStyle.Placeholder); } Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(width - 20f - 120f, num, 120f, 34f); if (GUI.Button(val2, Lang.T("refresh"))) { _loading = true; _requestTime = Time.unscaledTime; PortalNetwork.RequestPortalList(); } GUI.Label(new Rect(((Rect)(ref val)).xMax + 16f, num, ((Rect)(ref val2)).x - ((Rect)(ref val)).xMax - 28f, 34f), Lang.T("map_help"), ValheimStyle.Small); float num2 = height - 20f - 64f; DrawList(listRect); DrawMap(mapRect); if (IsOpen) { ValheimStyle.DrawDivider(20f, num2 - 7f, width - 40f); DrawBottom(new Rect(20f, num2, width - 40f, 64f)); } } private static void ComputeLayout(float w, float h, out Rect listRect, out Rect mapRect) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) float num = h - 20f - 64f - 14f - 112f; listRect = new Rect(20f, 112f, 320f, num); mapRect = new Rect(((Rect)(ref listRect)).xMax + 14f, 112f, w - 20f - ((Rect)(ref listRect)).xMax - 14f, num); } private Rect ScreenMapHole() { //IL_002c: 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_0032: 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_0007: Unknown result type (might be due to invalid IL or missing references) if (!GameMapView.Active) { return Rect.zero; } ComputeLayout(((Rect)(ref _windowRect)).width, ((Rect)(ref _windowRect)).height, out var _, out var mapRect); Rect val = MapInner(mapRect); return new Rect(((Rect)(ref _windowRect)).x + ((Rect)(ref val)).x, ((Rect)(ref _windowRect)).y + ((Rect)(ref val)).y, ((Rect)(ref val)).width, ((Rect)(ref val)).height); } private void DrawList(Rect rect) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) GUI.Box(rect, GUIContent.none, ValheimStyle.Inset); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref rect)).x + 2f, ((Rect)(ref rect)).y + 2f, ((Rect)(ref rect)).width - 4f, ((Rect)(ref rect)).height - 4f); if (_loading) { string text = ((Time.unscaledTime - _requestTime > 5f) ? Lang.T("no_response") : Lang.T("loading")); GUI.Label(new Rect(((Rect)(ref val)).x + 14f, ((Rect)(ref val)).y + 14f, ((Rect)(ref val)).width - 28f, 60f), text, ValheimStyle.LabelDim); return; } if (_visible.Count == 0) { string text2 = ((_portals.Count == 0) ? Lang.T("no_portals") : Lang.T("no_results")); GUI.Label(new Rect(((Rect)(ref val)).x + 14f, ((Rect)(ref val)).y + 14f, ((Rect)(ref val)).width - 28f, 40f), text2, ValheimStyle.LabelDim); return; } Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(0f, 0f, ((Rect)(ref val)).width - 14f, (float)_visible.Count * 36f); _listScroll = GUI.BeginScrollView(val, _listScroll, val2); int num = Mathf.Max(0, (int)(_listScroll.y / 36f)); int num2 = Mathf.Min(_visible.Count - 1, (int)((_listScroll.y + ((Rect)(ref val)).height) / 36f) + 1); Rect val3 = default(Rect); for (int i = num; i <= num2; i++) { int num3 = _visible[i]; bool flag = num3 == _selected; ((Rect)(ref val3))..ctor(0f, (float)i * 36f, ((Rect)(ref val2)).width, 35f); if (GUI.Button(val3, GUIContent.none, flag ? ValheimStyle.ListItemSelected : ValheimStyle.ListItem)) { _selected = num3; _mapCenter = MinimapData.WorldToUV(_portals[num3].Position); _zoom = Mathf.Max(_zoom, 6f); } GUI.Label(new Rect(((Rect)(ref val3)).x + 14f, ((Rect)(ref val3)).y, ((Rect)(ref val3)).width - 90f, ((Rect)(ref val3)).height), _labels[num3], flag ? ValheimStyle.ListTagSelected : ValheimStyle.ListTag); GUI.Label(new Rect(((Rect)(ref val3)).xMax - 80f, ((Rect)(ref val3)).y, 70f, ((Rect)(ref val3)).height), FormatDistance(DistanceTo(_portals[num3])), ValheimStyle.ListDistance); if (i < _visible.Count - 1) { Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, 0.06f); GUI.DrawTexture(new Rect(((Rect)(ref val3)).x + 10f, ((Rect)(ref val3)).yMax, ((Rect)(ref val3)).width - 20f, 1f), (Texture)(object)Texture2D.whiteTexture); GUI.color = color; } } GUI.EndScrollView(); } private void DrawBottom(Rect rect) { //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Unknown result type (might be due to invalid IL or missing references) PortalLink link; bool flag = PortalNetwork.TryGetLink(_portal, out link); bool flag2 = _selected >= 0 && _selected < _portals.Count; bool flag3 = PortalNetwork.IsMain(_portal); string text = (flag3 ? ("<color=#ffcc5c><b>" + Lang.T("main_portal") + "</b></color> · ") : "") + (flag ? ("<color=#a19480>" + Lang.T("linked_label") + "</color> <color=#73d9ff><b>" + SafeText(PortalNetwork.DisplayTag(link.Tag)) + "</b></color>") : ("<color=#a19480>" + Lang.T("linked_label") + "</color> <color=#a19480>" + Lang.T("none") + "</color>")); string text2 = (flag2 ? ("<color=#a19480>" + Lang.T("selected_label") + "</color> <color=#ffcc5c><b>" + _labels[_selected] + "</b></color> <color=#a19480>" + FormatDistance(DistanceTo(_portals[_selected])) + $" · X {_portals[_selected].Position.x:0}, Z {_portals[_selected].Position.z:0}</color>") : ("<color=#a19480>" + Lang.T("selected_label") + "</color> <color=#a19480>" + Lang.T("select_hint") + "</color>")); float num = ((Rect)(ref rect)).width - 592f - 16f; GUI.Label(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + 4f, num, 28f), text, ValheimStyle.Label); GUI.Label(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + 34f, num, 28f), text2, ValheimStyle.Label); float num2 = ((Rect)(ref rect)).y + (((Rect)(ref rect)).height - 44f) / 2f; float num3 = ((Rect)(ref rect)).xMax - 560f - 32f; GUI.enabled = flag2; if (GUI.Button(new Rect(num3, num2, 112f, 44f), Lang.T("btn_connect"), ValheimStyle.PrimaryButton)) { PortalInfo value = _portals[_selected]; PortalNetwork.SetLink(_portal, value); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, Lang.T("msg_connected", SafeText(PortalNetwork.DisplayTag(value.Tag))), 0, (Sprite)null, false); } Close(); GUI.enabled = true; return; } GUI.enabled = flag; if (GUI.Button(new Rect(num3 + 120f, num2, 112f, 44f), Lang.T("btn_disconnect"))) { PortalNetwork.SetLink(_portal, null); Player localPlayer2 = Player.m_localPlayer; if (localPlayer2 != null) { ((Character)localPlayer2).Message((MessageType)2, Lang.T("msg_disconnected"), 0, (Sprite)null, false); } } GUI.enabled = true; if (GUI.Button(new Rect(num3 + 240f, num2, 112f, 44f), flag3 ? Lang.T("btn_unset_main") : Lang.T("btn_set_main"))) { PortalNetwork.SetMain(_portal, !flag3); Player localPlayer3 = Player.m_localPlayer; if (localPlayer3 != null) { ((Character)localPlayer3).Message((MessageType)2, flag3 ? Lang.T("msg_main_unset") : Lang.T("msg_main_set"), 0, (Sprite)null, false); } } if (GUI.Button(new Rect(num3 + 360f, num2, 112f, 44f), Lang.T("btn_tag"))) { TeleportWorld portal = _portal; Close(); TextInput.instance.RequestText((TextReceiver)(object)portal, "$piece_portal_tag", 10); } else if (GUI.Button(new Rect(num3 + 480f, num2, 112f, 44f), Lang.T("btn_close"))) { Close(); } } private static float DistanceTo(PortalInfo p) { //IL_0015: 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) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { return Vector3.Distance(((Component)localPlayer).transform.position, p.Position); } return 0f; } private static string FormatDistance(float meters) { if (!(meters >= 1000f)) { return meters.ToString("0") + "m"; } return (meters / 1000f).ToString("0.0") + "km"; } internal static string SafeText(string text) { if (!string.IsNullOrEmpty(text)) { return text.Replace("<", "‹").Replace(">", "›"); } return ""; } private static Rect MapInner(Rect mapRect) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) return new Rect(((Rect)(ref mapRect)).x + 9f, ((Rect)(ref mapRect)).y + 9f, ((Rect)(ref mapRect)).width - 18f, ((Rect)(ref mapRect)).height - 18f); } private void DrawMap(Rect rect) { //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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: 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_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: 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_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) Rect val = MapInner(rect); GUI.BeginGroup(val); Rect local = default(Rect); ((Rect)(ref local))..ctor(0f, 0f, ((Rect)(ref val)).width, ((Rect)(ref val)).height); float aspect = ((Rect)(ref local)).width / Mathf.Max(1f, ((Rect)(ref local)).height); float num = ((Rect)(ref local)).width - 12f - 48f; Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(num, 12f, 48f, 48f); float num2 = num + 8f; Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(num2, ((Rect)(ref val2)).yMax + 10f, 32f, 32f); Rect val4 = default(Rect); ((Rect)(ref val4))..ctor(num2, ((Rect)(ref val3)).yMax + 4f, 32f, 32f); Rect val5 = default(Rect); ((Rect)(ref val5))..ctor(num2, ((Rect)(ref val4)).yMax + 12f, 32f, 32f); _mapControls.Clear(); _mapControls.Add(val2); _mapControls.Add(val3); _mapControls.Add(val4); _mapControls.Add(val5); HandleMapInput(local, aspect); ClampView(aspect); Rect uv = ViewUV(_viewCenter, _viewZoom, aspect); if (!GameMapView.Active) { DrawMapImage(local, uv); } PortalLink link; bool flag = PortalNetwork.TryGetLink(_portal, out link); bool flag2 = _selected >= 0 && _selected < _portals.Count; Vector2 a = WorldToLocal(local, uv, ((Component)_portal).transform.position); if (flag && (!flag2 || !IsLinkTarget(_portals[_selected], link))) { DrawDottedLine(a, WorldToLocal(local, uv, link.Position), ValheimStyle.Linked, 0.55f, 0f); } if (flag2) { DrawDottedLine(a, WorldToLocal(local, uv, _portals[_selected].Position), ValheimStyle.Selected, 0.95f, Time.unscaledTime * 14f); } int num3 = CurrentHover(local, uv); bool value = Plugin.ShowMapLabels.Value; foreach (int item in _visible) { if (item != _selected) { bool flag3 = flag && IsLinkTarget(_portals[item], link); bool isMain = _portals[item].IsMain; bool flag4 = value && (_zoom >= 3f || flag3 || isMain || item == num3); Color? val6 = (flag3 ? new Color?(ValheimStyle.Linked) : (isMain ? new Color?(MainColor) : ((Color?)null))); DrawPortalPin(local, uv, _portals[item].Position, (item == num3) ? 1.2f : 1f, val6, pulse: false, flag4 ? _labels[item] : null, (Color)(((??)val6) ?? Color.white)); } } DrawPortalPin(local, uv, ((Component)_portal).transform.position, 0.9f, CurrentColor, pulse: false, PortalNetwork.IsMain(_portal) ? Lang.T("current_main") : Lang.T("current_portal"), CurrentColor); if (flag2) { DrawPortalPin(local, uv, _portals[_selected].Position, (_selected == num3) ? 1.35f : 1.25f, ValheimStyle.Selected, pulse: true, _labels[_selected], ValheimStyle.Selected); } if ((Object)(object)Player.m_localPlayer != (Object)null) { DrawPlayerArrow(local, uv, ((Component)Player.m_localPlayer).transform); } DrawCompass(val2); DrawMapButtons(local, aspect, val3, val4, val5); DrawLegend(local); DrawCursorCoordinates(local, uv); if (num3 >= 0) { DrawTooltip(local, num3); } GUI.EndGroup(); GUI.Box(rect, GUIContent.none, ValheimStyle.MapFrame); ValheimStyle.DrawCorners(rect, 14f, -3f); } private void DrawMapImage(Rect local, Rect uv) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0066: 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) Color color = GUI.color; GUI.color = new Color(0.1f, 0.08f, 0.06f); GUI.DrawTexture(local, (Texture)(object)Texture2D.whiteTexture); GUI.color = color; if ((Object)(object)MinimapData.MapTexture != (Object)null) { GUI.color = MapTint; GUI.DrawTextureWithTexCoords(local, MinimapData.MapTexture, uv); GUI.color = color; if ((Object)(object)MinimapData.FogTexture != (Object)null) { GUI.DrawTextureWithTexCoords(local, MinimapData.FogTexture, uv); } Texture2D paper = ValheimStyle.Paper; GUI.DrawTextureWithTexCoords(local, (Texture)(object)paper, new Rect(0f, 0f, ((Rect)(ref local)).width / (float)((Texture)paper).width, ((Rect)(ref local)).height / (float)((Texture)paper).height)); } else { GUI.Label(new Rect(20f, 20f, ((Rect)(ref local)).width - 40f, 30f), Lang.T("no_map"), ValheimStyle.LabelDim); } GUI.DrawTexture(local, (Texture)(object)ValheimStyle.Vignette, (ScaleMode)0); } private void DrawPortalPin(Rect local, Rect uv, Vector3 world, float scale, Color? accent, bool pulse, string label, Color labelColor) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0024: 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_003f: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00dd: 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) //IL_00e9: 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) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) Vector2 val = WorldToLocal(local, uv, world); float num = 22f * scale; float num2 = num + 24f; if (!(val.x < 0f - num2) && !(val.y < 0f - num2) && !(val.x > ((Rect)(ref local)).width + num2) && !(val.y > ((Rect)(ref local)).height + num2)) { Color color = GUI.color; if (accent.HasValue) { Color value = accent.Value; float num3 = (pulse ? (Mathf.Sin(Time.unscaledTime * 4f) * 0.5f + 0.5f) : 0f); GUI.color = new Color(value.r, value.g, value.b, 0.45f + num3 * 0.2f); GUI.DrawTexture(Centered(val, num * 2.4f + num3 * 6f), (Texture)(object)ValheimStyle.Glow); GUI.color = new Color(value.r, value.g, value.b, 0.95f); GUI.DrawTexture(Centered(val, num + 10f + num3 * 3f), (Texture)(object)ValheimStyle.Ring); } GUI.color = new Color(0f, 0f, 0f, 0.6f); GUI.DrawTexture(Centered(val + new Vector2(1.5f, 2.5f), num + 2f), (Texture)(object)ValheimStyle.Glow); GUI.color = Color.white; if (!ValheimStyle.DrawSprite(Centered(val, num), ValheimStyle.PortalIcon)) { GUI.color = Color.black; GUI.DrawTexture(Centered(val, num * 0.7f), (Texture)(object)ValheimStyle.Disc); GUI.color = (Color)(((??)accent) ?? new Color(0.72f, 0.5f, 1f)); GUI.DrawTexture(Centered(val, num * 0.55f), (Texture)(object)ValheimStyle.Disc); } GUI.color = color; if (!string.IsNullOrEmpty(label)) { ValheimStyle.OutlineLabel(new Rect(val.x + num / 2f + 7f, val.y - 11f, 260f, 22f), label, ValheimStyle.MapLabel, labelColor); } } } private static void DrawPlayerArrow(Rect local, Rect uv, Transform player) { //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_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0026: 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_0032: 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_0049: Unknown result type (might be due to invalid IL or missing references) Vector2 val = WorldToLocal(local, uv, player.position); Matrix4x4 matrix = GUI.matrix; Quaternion rotation = player.rotation; GUIUtility.RotateAroundPivot(((Quaternion)(ref rotation)).eulerAngles.y, val); if (!ValheimStyle.DrawSprite(Centered(val, 26f), MinimapData.PlayerMarker)) { GUI.DrawTexture(Centered(val, 22f), (Texture)(object)ValheimStyle.Arrow); } GUI.matrix = matrix; } private static void DrawDottedLine(Vector2 a, Vector2 b, Color color, float alpha, float phase) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_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) //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_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_0064: 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_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_0097: 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: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) Vector2 val = b - a; float magnitude = ((Vector2)(ref val)).magnitude; if (!(magnitude < 22f)) { Vector2 val2 = val / magnitude; Color color2 = GUI.color; for (float num = 16f + Mathf.Repeat(phase, 11f); num < magnitude - 16f; num += 11f) { Vector2 val3 = a + val2 * num; GUI.color = new Color(0f, 0f, 0f, 0.6f * alpha); GUI.DrawTexture(Centered(val3 + new Vector2(1f, 1.5f), 6f), (Texture)(object)ValheimStyle.Disc); GUI.color = new Color(color.r, color.g, color.b, alpha); GUI.DrawTexture(Centered(val3, 5f), (Texture)(object)ValheimStyle.Disc); } GUI.color = color2; } } private static void DrawCompass(Rect r) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00b0: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) Color color = GUI.color; GUI.color = new Color(0f, 0f, 0f, 0.5f); GUI.DrawTexture(new Rect(((Rect)(ref r)).x - 6f, ((Rect)(ref r)).y - 4f, ((Rect)(ref r)).width + 12f, ((Rect)(ref r)).height + 12f), (Texture)(object)ValheimStyle.Glow); GUI.color = new Color(0.12f, 0.09f, 0.06f, 0.92f); GUI.DrawTexture(r, (Texture)(object)ValheimStyle.Disc); GUI.color = ValheimStyle.GoldDim; GUI.DrawTexture(r, (Texture)(object)ValheimStyle.Ring); GUI.color = ValheimStyle.Gold; GUI.DrawTexture(new Rect(((Rect)(ref r)).center.x - 5f, ((Rect)(ref r)).y + 3f, 10f, 10f), (Texture)(object)ValheimStyle.Arrow); GUI.color = color; ValheimStyle.OutlineLabel(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + 8f, ((Rect)(ref r)).width, ((Rect)(ref r)).height - 6f), "N", ValheimStyle.CompassLetter, ValheimStyle.Gold); } private void DrawMapButtons(Rect local, float aspect, Rect zoomIn, Rect zoomOut, Rect center) { //IL_0000: 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_0013: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0082: Unknown result type (might be due to invalid IL or missing references) if (GUI.Button(zoomIn, "+", ValheimStyle.MapButton)) { ZoomAt(local, aspect, ((Rect)(ref local)).center, 1.5f); } if (GUI.Button(zoomOut, "-", ValheimStyle.MapButton)) { ZoomAt(local, aspect, ((Rect)(ref local)).center, 2f / 3f); } if (GUI.Button(center, GUIContent.none, ValheimStyle.MapButton) && (Object)(object)Player.m_localPlayer != (Object)null) { _mapCenter = MinimapData.WorldToUV(((Component)Player.m_localPlayer).transform.position); } GUI.DrawTexture(new Rect(((Rect)(ref center)).x + 8f, ((Rect)(ref center)).y + 7f, ((Rect)(ref center)).width - 16f, ((Rect)(ref center)).height - 16f), (Texture)(object)ValheimStyle.Arrow); } private void DrawLegend(Rect local) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) float num = 20f; string[] array = new string[4] { Lang.T("legend_selected"), Lang.T("legend_linked"), Lang.T("main_short"), Lang.T("current_portal") }; Color[] array2 = (Color[])(object)new Color[4] { ValheimStyle.Selected, ValheimStyle.Linked, MainColor, CurrentColor }; Vector2[] array3 = (Vector2[])(object)new Vector2[array.Length]; for (int i = 0; i < array.Length; i++) { array3[i] = ValheimStyle.LegendText.CalcSize(new GUIContent(array[i])); num += 18f + array3[i].x + 14f; } num += 30f; Rect val = default(Rect); ((Rect)(ref val))..ctor(12f, ((Rect)(ref local)).height - 28f - 12f, num, 28f); GUI.Box(val, GUIContent.none, ValheimStyle.Plaque); Color color = GUI.color; float num2 = ((Rect)(ref val)).x + 10f; for (int j = 0; j < array.Length; j++) { Color val2 = array2[j]; GUI.color = new Color(val2.r, val2.g, val2.b, 0.5f); GUI.DrawTexture(new Rect(num2 - 3f, ((Rect)(ref val)).y + 5f, 18f, 18f), (Texture)(object)ValheimStyle.Glow); GUI.color = val2; GUI.DrawTexture(new Rect(num2, ((Rect)(ref val)).y + 8f, 12f, 12f), (Texture)(object)ValheimStyle.Ring); GUI.color = color; GUI.Label(new Rect(num2 + 17f, ((Rect)(ref val)).y, array3[j].x + 4f, 28f), array[j], ValheimStyle.LegendText); num2 += 18f + array3[j].x + 14f; } GUI.DrawTexture(new Rect(num2, ((Rect)(ref val)).y + 6f, 16f, 16f), (Texture)(object)ValheimStyle.Arrow); GUI.Label(new Rect(num2 + 18f, ((Rect)(ref val)).y, 30f, 28f), Lang.T("legend_me"), ValheimStyle.LegendText); } private void DrawCursorCoordinates(Rect local, Rect uv) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_0055: Expected O, but got Unknown //IL_0050: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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) Vector2 mousePosition = Event.current.mousePosition; if (((Rect)(ref local)).Conta