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 ValheimPortals v1.0.5
ValheimPortals.dll
Decompiled 6 hours 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.Globalization; using System.IO; 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 Splatform; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.0.0.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 ValheimPortals { public static class Favorites { private const string Key = "ValheimPortals_favorites"; private const int Max = 30; private const float MatchDistance = 1.5f; public static List<Vector3> Load() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(); Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || !localPlayer.m_customData.TryGetValue("ValheimPortals_favorites", out var value) || string.IsNullOrEmpty(value)) { return list; } string[] array = value.Split(new char[1] { ';' }); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { ',' }); if (array2.Length == 3 && float.TryParse(array2[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array2[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array2[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3)) { list.Add(new Vector3(result, result2, result3)); } } return list; } public static bool Contains(List<Vector3> list, Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return IndexOf(list, pos) >= 0; } public static bool Near(Vector3 a, Vector3 b) { //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) return Vector3.Distance(a, b) <= 1.5f; } public static int IndexOf(List<Vector3> list, Vector3 pos) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < list.Count; i++) { if (Near(list[i], pos)) { return i; } } return -1; } public static bool Toggle(Vector3 pos) { //IL_0007: 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) List<Vector3> list = Load(); int num = IndexOf(list, pos); bool num2 = num < 0; if (num2) { list.Add(pos); } else { list.RemoveAt(num); } if (list.Count > 30) { list.RemoveRange(0, list.Count - 30); } Save(list); return num2; } private static void Save(List<Vector3> list) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { localPlayer.m_customData["ValheimPortals_favorites"] = string.Join(";", list.Select((Vector3 v) => string.Format(CultureInfo.InvariantCulture, "{0:0.##},{1:0.##},{2:0.##}", v.x, v.y, v.z))); } } } public class FavoritesPanel : MonoBehaviour { public const int MaxShown = 9; private const float Width = 250f; private const float RowHeight = 28f; private const float Pad = 8f; private const float TitleHeight = 26f; private static readonly Color Bg = new Color(0.07f, 0.05f, 0.04f, 0.88f); private static readonly Color Border = new Color(0.85f, 0.6f, 0.25f, 0.45f); private static readonly Color Title = new Color(1f, 0.75f, 0.35f, 1f); private static readonly Color Dim = new Color(0.75f, 0.7f, 0.62f, 1f); private static FavoritesPanel _instance; private TMP_FontAsset _font; private ZDOID _current = ZDOID.None; public static void Show(List<PortalInfo> favorites, ZDOID current) { //IL_000a: 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_001f: Unknown result type (might be due to invalid IL or missing references) Hide(); _instance = new GameObject("ValheimPortals_Favorites").AddComponent<FavoritesPanel>(); _instance._current = current; _instance.Build(favorites); } public static void Hide() { if ((Object)(object)_instance != (Object)null) { Object.Destroy((Object)(object)((Component)_instance).gameObject); } _instance = null; } private void Build(List<PortalInfo> favorites) { //IL_00ac: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_0140: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) TextInput instance = TextInput.instance; if ((Object)(object)instance != (Object)null) { object value = Traverse.Create((object)instance).Field("m_topic").GetValue(); TMP_Text val = (TMP_Text)((value is TMP_Text) ? value : null); _font = (((Object)(object)val != (Object)null) ? val.font : null); GameObject value2 = Traverse.Create((object)instance).Field("m_panel").GetValue<GameObject>(); if ((Object)(object)value2 != (Object)null) { PortalConfigUI.FindClickSfx(value2.GetComponentInChildren<Button>(true)); } } Canvas obj = ((Component)this).gameObject.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 29000; CanvasScaler obj2 = ((Component)this).gameObject.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); obj2.matchWidthOrHeight = 0.5f; ((Component)this).gameObject.AddComponent<GraphicRaycaster>(); float num = ((favorites.Count == 0) ? 40f : ((float)favorites.Count * 28f)); float num2 = 34f + num + 8f; RectTransform val2 = (RectTransform)new GameObject("Panel", new Type[1] { typeof(RectTransform) }).transform; ((Transform)val2).SetParent(((Component)this).transform, false); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0f, 1f); val2.pivot = val3; Vector2 anchorMin = (val2.anchorMax = val3); val2.anchorMin = anchorMin; val2.anchoredPosition = new Vector2(160f, -112f); val2.sizeDelta = new Vector2(250f, num2); ((Graphic)((Component)val2).gameObject.AddComponent<Image>()).color = Bg; Outline obj3 = ((Component)val2).gameObject.AddComponent<Outline>(); ((Shadow)obj3).effectColor = Border; ((Shadow)obj3).effectDistance = new Vector2(1f, -1f); Box(Label((Transform)(object)val2, Texts.T("fav_title"), 18f, Title, (TextAlignmentOptions)4097).rectTransform, 10f, -8f, 234f, 26f); if (favorites.Count == 0) { TMP_Text obj4 = Label((Transform)(object)val2, Texts.T("fav_empty"), 14f, Dim, (TextAlignmentOptions)257); obj4.fontStyle = (FontStyles)2; obj4.textWrappingMode = (TextWrappingModes)1; Box(obj4.rectTransform, 10f, -34f, 230f, num); } else { for (int i = 0; i < favorites.Count; i++) { AddRow(val2, favorites[i], i + 1, 0f - (34f + (float)i * 28f)); } } } private void AddRow(RectTransform panel, PortalInfo info, int number, float y) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_00a6: 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_00e6: 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_0102: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Expected O, but got Unknown //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: 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_01ee: Expected O, but got Unknown //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)new GameObject("Fav_" + number, new Type[1] { typeof(RectTransform) }).transform; ((Transform)val).SetParent((Transform)(object)panel, false); Box(val, 4f, y, 242f, 28f); Image val2 = ((Component)val).gameObject.AddComponent<Image>(); ((Graphic)val2).color = Color.white; Button obj = ((Component)val).gameObject.AddComponent<Button>(); ((Selectable)obj).targetGraphic = (Graphic)(object)val2; ColorBlock colors = ((Selectable)obj).colors; ((ColorBlock)(ref colors)).normalColor = new Color(1f, 1f, 1f, 0f); ((ColorBlock)(ref colors)).highlightedColor = new Color(1f, 0.8f, 0.4f, 0.18f); ((ColorBlock)(ref colors)).pressedColor = new Color(1f, 0.8f, 0.4f, 0.3f); ((ColorBlock)(ref colors)).selectedColor = ((ColorBlock)(ref colors)).normalColor; ((ColorBlock)(ref colors)).disabledColor = ((ColorBlock)(ref colors)).normalColor; ((ColorBlock)(ref colors)).fadeDuration = 0.05f; ((Selectable)obj).colors = colors; ((Graphic)val2).canvasRenderer.SetColor(((ColorBlock)(ref colors)).normalColor); bool flag = info.Id == _current; ((Selectable)obj).interactable = !flag; ((UnityEvent)obj.onClick).AddListener((UnityAction)delegate { PortalConfigUI.PlayClick(); PortalMap.TravelTo(info); }); Box(Label((Transform)(object)val, number.ToString(), 14f, Dim, (TextAlignmentOptions)514).rectTransform, 2f, 0f, 16f, 28f); RectTransform val3 = (RectTransform)new GameObject("Icon", new Type[1] { typeof(RectTransform) }).transform; ((Transform)val3).SetParent((Transform)(object)val, false); Box(val3, 20f, -3f, 22f, 22f); Image obj2 = ((Component)val3).gameObject.AddComponent<Image>(); obj2.sprite = IconRegistry.Get(info.Icon); Color color = info.GetColor(); if (flag) { color.a = 0.45f; } ((Graphic)obj2).color = color; obj2.preserveAspect = true; ((Graphic)obj2).raycastTarget = false; string text = (flag ? (info.Name + " <size=12><color=#A89880>(" + Texts.T("map_here") + ")</color></size>") : info.Name); TMP_Text obj3 = Label((Transform)(object)val, text, 16f, color, (TextAlignmentOptions)4097); obj3.richText = true; obj3.overflowMode = (TextOverflowModes)1; Box(obj3.rectTransform, 48f, 0f, 190f, 28f); } private TMP_Text Label(Transform parent, string text, float size, Color color, TextAlignmentOptions align) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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) GameObject val = new GameObject("Text", new Type[1] { typeof(RectTransform) }); val.SetActive(false); val.transform.SetParent(parent, false); TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>(); if ((Object)(object)_font != (Object)null) { ((TMP_Text)val2).font = _font; } ((TMP_Text)val2).text = text; ((TMP_Text)val2).fontSize = size; ((Graphic)val2).color = color; ((TMP_Text)val2).alignment = align; ((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0; ((Graphic)val2).raycastTarget = false; val.SetActive(true); return (TMP_Text)(object)val2; } private static void Box(RectTransform rt, float x, float y, float w, float h) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 1f); rt.pivot = val; Vector2 anchorMin = (rt.anchorMax = val); rt.anchorMin = anchorMin; rt.anchoredPosition = new Vector2(x, y); rt.sizeDelta = new Vector2(w, h); } } public static class GroupBridge { private const BindingFlags Static = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private const BindingFlags Inst = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static bool _init; private static FieldInfo _npcParty; private static MethodInfo _npcServerPartyOf; private static MethodInfo _gGroupPlayers; public static bool Available { get { Init(); if (!(_npcParty != null)) { return _gGroupPlayers != null; } return true; } } public static void MyGroup(List<long> ids, List<string> names) { Init(); long myId = PortalPerms.MyId; if (_npcParty?.GetValue(null) is IEnumerable enumerable) { foreach (object item in enumerable) { if (item != null && item.GetType().GetField("Id", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(item) is long num && num != 0L && num != myId) { ids.Add(num); } } } if (!(_gGroupPlayers != null)) { return; } try { string text = (Object.op_Implicit((Object)(object)Player.m_localPlayer) ? Player.m_localPlayer.GetPlayerName() : ""); if (!(_gGroupPlayers.Invoke(null, null) is IEnumerable enumerable2)) { return; } foreach (object item2 in enumerable2) { string text2 = item2?.GetType().GetField("name", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(item2) as string; if (!string.IsNullOrEmpty(text2) && text2 != text) { names.Add(text2); } } } catch { } } public static bool? ServerSameGroup(long a, long b) { Init(); if (_npcServerPartyOf == null || a == 0L || b == 0L) { return null; } try { object obj = _npcServerPartyOf.Invoke(null, new object[1] { a }); if (obj == null) { return false; } return obj.GetType().GetField("members", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj) is List<long> list && list.Contains(b); } catch { return null; } } private static void Init() { if (_init) { return; } _init = true; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { try { Type type = assembly.GetType("ValheimNPCs.Client", throwOnError: false); if (type != null) { _npcParty = type.GetField("Party", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _npcServerPartyOf = assembly.GetType("ValheimNPCs.Server", throwOnError: false)?.GetMethod("PartyOf", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(long) }, null); } Type type2 = assembly.GetType("Groups.API", throwOnError: false); if (type2 != null) { _gGroupPlayers = type2.GetMethod("GroupPlayers", BindingFlags.Static | BindingFlags.Public, null, Type.EmptyTypes, null); } } catch { } } } } public static class GuildBridge { private const BindingFlags Static = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private const BindingFlags Inst = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static bool _init; private static PropertyInfo _npcMyGuild; private static PropertyInfo _npcGuestOnly; private static MethodInfo _npcServerGuildOf; private static FieldInfo _npcServerData; private static MethodInfo _gGetOwnGuild; private static MethodInfo _gGetPlayerGuild; private static MethodInfo _gRefForOwn; private static MethodInfo _gRefFromString; private static string _cachedId = ""; private static string _cachedName = ""; private static float _cachedAt = -10f; public static bool AlliancesAvailable { get { Init(); return _npcMyGuild != null; } } public static string MyGuild() { Refresh(); return _cachedId; } public static string MyGuildName() { Refresh(); return _cachedName; } public static string MyGuildsRef() { Init(); if (_gRefForOwn == null) { return ""; } try { return _gRefForOwn.Invoke(null, null)?.ToString() ?? ""; } catch { return ""; } } public static bool IsInMyGuild(PortalInfo p) { Init(); object obj = NpcClientGuild(); if (obj != null) { if (p.Creator != 0L) { return NpcHasMember(obj, p.Creator); } return false; } object obj2 = GuildsOwnGuild(); if (obj2 != null) { return GuildsHasMember(obj2, p.CreatorRef, p.CreatorName); } return false; } public static bool? ServerSameGuild(PortalInfo p, long playerId, string playerRef) { Init(); if (_npcServerGuildOf != null && ServerNpcHasData()) { string text = NpcServerGuildId(p.Creator); if (text.Length > 0) { return text == NpcServerGuildId(playerId); } } if (_gGetPlayerGuild != null && _gRefFromString != null && p.CreatorRef.Length > 0 && playerRef.Length > 0) { string text2 = GuildsNameOf(p.CreatorRef); return text2.Length > 0 && text2 == GuildsNameOf(playerRef); } return null; } public static bool IsAllyOfMine(string guildId) { Init(); if (string.IsNullOrEmpty(guildId)) { return false; } return Contains(NpcClientGuild(), "allies", guildId); } public static bool? ServerAllied(long creator, long playerId) { Init(); if (_npcServerGuildOf == null || !ServerNpcHasData()) { return null; } try { object obj = _npcServerGuildOf.Invoke(null, new object[1] { creator }); string text = NpcServerGuildId(playerId); return obj != null && text.Length > 0 && Contains(obj, "allies", text); } catch { return null; } } private static bool Contains(object obj, string listField, string value) { if (obj == null || !(obj.GetType().GetField(listField, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj) is IEnumerable enumerable)) { return false; } foreach (object item in enumerable) { if (item as string == value) { return true; } } return false; } private static object NpcClientGuild() { if (_npcMyGuild == null) { return null; } try { if (_npcGuestOnly != null && (bool)_npcGuestOnly.GetValue(null, null)) { return null; } return _npcMyGuild.GetValue(null, null); } catch { return null; } } private static bool ServerNpcHasData() { if (_npcServerData == null) { _npcServerData = _npcServerGuildOf.DeclaringType?.GetField("_data", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); } try { return _npcServerData?.GetValue(null) != null; } catch { return false; } } private static string NpcServerGuildId(long playerId) { if (playerId == 0L) { return ""; } try { return ReadString(_npcServerGuildOf.Invoke(null, new object[1] { playerId }), "id"); } catch { return ""; } } private static bool NpcHasMember(object guild, long playerId) { if (!(guild.GetType().GetField("members", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(guild) is IEnumerable enumerable)) { return false; } foreach (object item in enumerable) { if (item != null && item.GetType().GetField("id", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(item) is long num && num == playerId) { return true; } } return false; } private static object GuildsOwnGuild() { if (_gGetOwnGuild == null) { return null; } try { return _gGetOwnGuild.Invoke(null, null); } catch { return null; } } private static string GuildsNameOf(string playerRef) { try { object obj = _gRefFromString.Invoke(null, new object[1] { playerRef }); return ReadString(_gGetPlayerGuild.Invoke(null, new object[1] { obj }), "Name"); } catch { return ""; } } private static bool GuildsHasMember(object guild, string creatorRef, string creatorName) { if (!(guild.GetType().GetField("Members", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(guild) is IDictionary dictionary)) { return false; } foreach (object key in dictionary.Keys) { if (key != null) { if (creatorRef.Length > 0 && key.ToString() == creatorRef) { return true; } if (creatorRef.Length == 0 && ReadString(key, "name") == creatorName) { return true; } } } return false; } private static void Refresh() { if (Time.time - _cachedAt < 1f) { return; } _cachedAt = Time.time; _cachedId = ""; _cachedName = ""; Init(); object obj = NpcClientGuild(); if (obj != null) { _cachedId = ReadString(obj, "id"); string text = ReadString(obj, "tag"); _cachedName = ((text.Length > 0) ? text : ReadString(obj, "name")); return; } object obj2 = GuildsOwnGuild(); if (obj2 != null) { _cachedId = (_cachedName = ReadString(obj2, "Name")); } } private static string ReadString(object obj, string member) { if (obj == null) { return ""; } Type type = obj.GetType(); FieldInfo field = type.GetField(member, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return (field.GetValue(obj) as string) ?? ""; } return (type.GetProperty(member, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj, null) as string) ?? ""; } private static void Init() { if (_init) { return; } _init = true; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { try { Type type = assembly.GetType("ValheimNPCs.Client", throwOnError: false); if (type != null) { _npcMyGuild = type.GetProperty("MyGuild", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _npcGuestOnly = type.GetProperty("GuestOnly", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _npcServerGuildOf = assembly.GetType("ValheimNPCs.Server", throwOnError: false)?.GetMethod("GuildOf", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(long) }, null); } Type type2 = assembly.GetType("Guilds.API", throwOnError: false); Type type3 = assembly.GetType("Guilds.PlayerReference", throwOnError: false); if (type2 != null && type3 != null) { _gGetOwnGuild = type2.GetMethod("GetOwnGuild", BindingFlags.Static | BindingFlags.Public, null, Type.EmptyTypes, null); _gGetPlayerGuild = type2.GetMethod("GetPlayerGuild", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { type3 }, null); _gRefForOwn = type3.GetMethod("forOwnPlayer", BindingFlags.Static | BindingFlags.Public, null, Type.EmptyTypes, null); _gRefFromString = type3.GetMethod("fromString", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(string) }, null); } } catch { } } } } public static class IconRegistry { public const int MaxIcons = 33; private static readonly string[] ModIcons = new string[19] { "castelo", "bandeira", "cama", "dungeon", "boss", "minerio", "picareta", "cristal", "madeira", "machado", "arvore", "seiva", "farm", "caca", "pesca", "porto", "forja", "mercador", "montanha" }; private static readonly Dictionary<string, Sprite> _cache = new Dictionary<string, Sprite>(); private static MethodInfo _loadImage; private static bool _loadImageMissing; public unsafe static List<string> Keys() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) List<string> list = new List<string>(); if ((Object)(object)Minimap.instance != (Object)null) { foreach (SpriteData icon in Minimap.instance.m_icons) { PinType name = icon.m_name; string text = ((object)(*(PinType*)(&name))/*cast due to .constrained prefix*/).ToString(); if (text.StartsWith("Icon")) { Add(list, "pin:" + text); } } } string[] modIcons = ModIcons; foreach (string text2 in modIcons) { Add(list, "mod:" + text2); } if (list.Count > 33) { list.RemoveRange(33, list.Count - 33); } return list; } private static void Add(List<string> keys, string key) { if (!keys.Contains(key) && (Object)(object)Get(key, fallback: false) != (Object)null) { keys.Add(key); } } public static Sprite Get(string key, bool fallback = true) { if (!string.IsNullOrEmpty(key) && _cache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { return value; } Sprite val = Resolve(key); if ((Object)(object)val != (Object)null) { _cache[key] = val; return val; } if (!fallback || !(key != "pin:Icon4")) { return null; } return Get("pin:Icon4", fallback: false); } private unsafe static Sprite Resolve(string key) { //IL_0092: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(key)) { return null; } int num = key.IndexOf(':'); if (num <= 0) { return null; } string text = key.Substring(0, num); string text2 = key.Substring(num + 1); switch (text) { case "pin": if ((Object)(object)Minimap.instance == (Object)null) { return null; } foreach (SpriteData icon in Minimap.instance.m_icons) { PinType name = icon.m_name; if (((object)(*(PinType*)(&name))/*cast due to .constrained prefix*/).ToString() == text2) { return icon.m_icon; } } return null; case "piece": { GameObject val3 = (Object.op_Implicit((Object)(object)ZNetScene.instance) ? ZNetScene.instance.GetPrefab(text2) : null); Piece val4 = (Object.op_Implicit((Object)(object)val3) ? val3.GetComponent<Piece>() : null); if (!Object.op_Implicit((Object)(object)val4)) { return null; } return val4.m_icon; } case "mod": return LoadEmbedded(text2); case "item": { GameObject val = (Object.op_Implicit((Object)(object)ObjectDB.instance) ? ObjectDB.instance.GetItemPrefab(text2) : null); ItemDrop val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<ItemDrop>() : null); if (!((Object)(object)val2 != (Object)null) || val2.m_itemData == null) { return null; } return val2.m_itemData.GetIcon(); } default: return null; } } private static bool LoadImage(Texture2D tex, byte[] bytes) { if (_loadImage == null) { _loadImage = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule")?.GetMethod("LoadImage", BindingFlags.Static | BindingFlags.Public, null, new Type[2] { typeof(Texture2D), typeof(byte[]) }, null); } if (_loadImage == null) { if (!_loadImageMissing) { Plugin.Log.LogWarning((object)"ImageConversion.LoadImage não encontrado; os ícones próprios não vão aparecer."); } _loadImageMissing = true; return false; } return (bool)_loadImage.Invoke(null, new object[2] { tex, bytes }); } private static Sprite LoadEmbedded(string name) { //IL_004e: 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_0065: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ValheimPortals.Icons." + name + ".png"); if (stream == null) { return null; } byte[] bytes; using (MemoryStream memoryStream = new MemoryStream()) { stream.CopyTo(memoryStream); bytes = memoryStream.ToArray(); } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false) { name = "vp_" + name }; if (!LoadImage(val, bytes)) { return null; } ((Texture)val).wrapMode = (TextureWrapMode)1; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); } } [HarmonyPatch(typeof(Game), "Start")] internal static class Game_Start_Patch { private static void Postfix() { PortalNetwork.Register(); ServerSync.Register(); } } [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class ZNetScene_Awake_Patch { private static void Postfix(ZNetScene __instance) { PortalNetwork.ScanPrefabs(__instance); } } [HarmonyPatch(typeof(TextInput), "IsVisible")] internal static class TextInput_IsVisible_Patch { private static void Postfix(ref bool __result) { if (PortalConfigUI.IsOpen) { __result = true; } } } [HarmonyPatch(typeof(TeleportWorld), "Awake")] internal static class TeleportWorld_Awake_Patch { private static void Postfix(TeleportWorld __instance) { ZNetView nview = ((Component)__instance).GetComponent<ZNetView>(); if (!((Object)(object)nview == (Object)null) && nview.GetZDO() != null) { PortalProtection.Track(__instance); nview.Register<ZPackage>("VP_SetConfig", (Action<long, ZPackage>)delegate(long sender, ZPackage pkg) { PortalConfigUI.RPC_SetConfig(nview, sender, pkg); }); } } } [HarmonyPatch(typeof(Piece), "SetCreator")] internal static class Piece_SetCreator_Patch { private static void Postfix(Piece __instance) { if (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<TeleportWorld>())) { return; } Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && __instance.GetCreator() == localPlayer.GetPlayerID()) { ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner()) { ZDO zDO = component.GetZDO(); zDO.Set("vp_name", PortalInfo.SanitizeName(Texts.T("default_name", localPlayer.GetPlayerName()))); zDO.Set("vp_type", 0); zDO.Set("vp_color", "#FFFFFF"); zDO.Set("vp_icon", "pin:Icon4"); zDO.Set("vp_cname", localPlayer.GetPlayerName()); zDO.Set("vp_cref", GuildBridge.MyGuildsRef()); zDO.Set("vp_guild", GuildBridge.MyGuild()); zDO.Set("vp_gname", GuildBridge.MyGuildName()); } } } } [HarmonyPatch(typeof(TeleportWorld), "Interact")] internal static class TeleportWorld_Interact_Patch { private static bool Prefix(TeleportWorld __instance, bool hold, ref bool __result) { __result = false; if (hold) { return false; } ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return false; } if (!PortalPerms.CanEdit(PortalInfo.FromZDO(component.GetZDO()))) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, Texts.T("only_owner_config"), 0, (Sprite)null, false); } return false; } PortalConfigUI.Open(component); __result = true; return false; } } [HarmonyPatch(typeof(TeleportWorld), "GetHoverText")] internal static class TeleportWorld_GetHoverText_Patch { private static bool Prefix(TeleportWorld __instance, ref string __result) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return true; } PortalInfo portalInfo = PortalInfo.FromZDO(component.GetZDO()); string text = "<color=#" + ColorUtility.ToHtmlStringRGB(portalInfo.GetColor()) + ">" + portalInfo.Name + "</color>\n" + Texts.T("hover_type") + ": " + PortalPerms.TypeLabel(portalInfo.Type) + " " + Texts.T("hover_owner") + ": " + portalInfo.CreatorName; if ((portalInfo.Type == PortalType.Guilda || portalInfo.Type == PortalType.Alianca) && !string.IsNullOrEmpty(portalInfo.GuildName)) { text = text + "\n" + Texts.T("hover_guild") + ": " + portalInfo.GuildName; } if (PortalPerms.CanEdit(portalInfo)) { text = text + "\n[<color=yellow><b>$KEY_Use</b></color>] " + Texts.T("hover_configure"); } __result = Localization.instance.Localize(text); return false; } } [HarmonyPatch(typeof(TeleportWorld), "GetHoverName")] internal static class TeleportWorld_GetHoverName_Patch { private static bool Prefix(TeleportWorld __instance, ref string __result) { ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return true; } __result = PortalInfo.FromZDO(component.GetZDO()).Name; return false; } } [HarmonyPatch(typeof(TeleportWorld), "Teleport", new Type[] { typeof(Player) })] internal static class TeleportWorld_Teleport_Patch { private static bool Prefix(TeleportWorld __instance, Player player) { //IL_0108: 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 false; } if (Time.time < PortalMap.BlockTeleportUntil || ((Character)player).IsTeleporting() || PortalMap.Active) { return false; } ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return false; } if (ServerSync.VersionMismatch) { ((Character)player).Message((MessageType)2, Texts.T("version_mismatch", "1.0.5", ServerSync.ServerVersion), 0, (Sprite)null, false); return false; } PortalInfo portalInfo = PortalInfo.FromZDO(component.GetZDO()); if (!PortalPerms.CanUse(portalInfo, Requester.Local())) { ((Character)player).Message((MessageType)2, portalInfo.Type switch { PortalType.Guilda => Texts.T("deny_guild"), PortalType.Alianca => Texts.T("deny_alliance"), PortalType.Grupo => Texts.T("deny_group"), _ => Texts.T("deny_personal"), }, 0, (Sprite)null, false); return false; } PortalMap.BlockTeleportUntil = Time.time + 1f; PortalNetwork.RequestList(portalInfo.Id); return false; } } [HarmonyPatch] internal static class TeleportWorld_HaveTarget_Patch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(TeleportWorld), "HaveTarget", (Type[])null, (Type[])null); } private static bool Prepare() { return TargetMethod() != null; } private static void Postfix(ref bool __result) { __result = Plugin.PortalEffect.Value; } } [HarmonyPatch] internal static class TeleportWorld_TargetFound_Patch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(TeleportWorld), "TargetFound", (Type[])null, (Type[])null); } private static bool Prepare() { return TargetMethod() != null; } private static void Postfix(ref bool __result) { __result = Plugin.PortalEffect.Value; } } [HarmonyPatch(typeof(Piece), "CanBeRemoved")] internal static class Piece_CanBeRemoved_Patch { private static void Postfix(Piece __instance, ref bool __result) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (!__result) { return; } if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<TeleportWorld>())) { ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid() && !PortalPerms.CanDestroy(PortalInfo.FromZDO(component.GetZDO()))) { __result = false; PortalProtection.Warn(Texts.T("protect_remove_portal")); } } else if (!PortalProtection.LocalCanModify(PortalProtection.FindProtectingPortal(((Component)__instance).transform.position, ((Component)__instance).gameObject))) { __result = false; PortalProtection.Warn(Texts.T("protect_build")); } } } [HarmonyPatch(typeof(WearNTear), "Damage")] internal static class WearNTear_Damage_Patch { private static bool Prefix(WearNTear __instance, HitData hit) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) bool flag = Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<TeleportWorld>()); PortalInfo portalInfo; if (flag) { ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return true; } portalInfo = PortalInfo.FromZDO(component.GetZDO()); } else { portalInfo = PortalProtection.FindProtectingPortal(((Component)__instance).transform.position, ((Component)__instance).gameObject); if (portalInfo == null) { return true; } } Character val = ((hit != null) ? hit.GetAttacker() : null); if (!(val is Player)) { return !ServerSync.BlockNonPlayerDamage; } if ((Object)(object)val != (Object)(object)Player.m_localPlayer) { return true; } if (flag ? PortalPerms.CanDestroy(portalInfo) : PortalProtection.LocalCanModify(portalInfo)) { return true; } PortalProtection.Warn(Texts.T(flag ? "protect_damage_portal" : "protect_build")); return false; } } [HarmonyPatch(typeof(Minimap), "Update")] internal static class Minimap_Update_Patch { private static void Postfix() { PortalMap.OnMinimapUpdate(); } } [HarmonyPatch(typeof(Minimap), "UpdatePins")] internal static class Minimap_UpdatePins_Patch { private static void Postfix() { PortalMap.OnUpdatePins(); } } [HarmonyPatch(typeof(Minimap), "OnMapLeftClick")] internal static class Minimap_OnMapLeftClick_Patch { private static bool Prefix() { return !PortalMap.HandleClick(); } } [HarmonyPatch(typeof(Minimap), "RemovePinUnderPointer")] internal static class Minimap_RemovePinUnderPointer_Patch { private static bool Prefix() { return !PortalMap.HandleRightClick(); } } [BepInPlugin("padilha.valheimportals", "ValheimPortals", "1.0.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string GUID = "padilha.valheimportals"; public const string NAME = "ValheimPortals"; public const string VERSION = "1.0.5"; public static ConfigEntry<PortalType> LegacyPortalType; public static ConfigEntry<float> ExitDistance; public static ConfigEntry<bool> AllowNonTeleportable; public static ConfigEntry<bool> BlockNonPlayerDamage; public static ConfigEntry<bool> PortalEffect; public static ConfigEntry<float> MapCloseDistance; public static ConfigEntry<float> ProtectRadius; public static ConfigEntry<bool> AreaAllowOwner; public static ConfigEntry<bool> GuildCanDestroy; public static ConfigEntry<float> CooldownSeconds; public static ConfigEntry<string> CostItem; public static ConfigEntry<int> CostAmount; public static ConfigEntry<bool> AllowFavorites; public static ManualLogSource Log; private void Awake() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00cf: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_019c: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; ConfigFile val = new ConfigFile(Path.Combine(Paths.ConfigPath, "ValheimPortals", "ValheimPortals.cfg"), true); LegacyPortalType = val.Bind<PortalType>("Geral", "TipoPortaisAntigos", PortalType.Publico, "Tipo dado aos portais que já existiam no mundo antes do mod (sem configuração)."); ExitDistance = val.Bind<float>("Geral", "DistanciaSaida", 2.5f, "Distância à frente do portal de destino onde o jogador aparece."); AllowNonTeleportable = val.Bind<bool>("Geral", "PermitirItensNaoTeleportaveis", false, "Se true, deixa atravessar com minério/metal e outros itens que o vanilla bloqueia."); BlockNonPlayerDamage = val.Bind<bool>("Proteção", "BloquearDanoDeNaoJogadores", true, "Se true, monstros e outras fontes que não são jogadores não danificam portais nem construções na área protegida."); ProtectRadius = val.Bind<float>("Proteção", "RaioAreaProtegida", 6f, "Raio (metros) ao redor de cada portal onde ninguém destrói construções nem mexe no terreno. 0 desliga."); AreaAllowOwner = val.Bind<bool>("Proteção", "DonoPodeMexerNaArea", true, "Se true, o dono do portal pode construir/destruir/cavar na área. ADMs sempre podem."); GuildCanDestroy = val.Bind<bool>("Proteção", "GuildaPodeQuebrar", false, "Se true, membros da guilda do dono também podem remover/danificar o portal e mexer na área dele."); CooldownSeconds = val.Bind<float>("Viagem", "TempoDeEsperaSegundos", 0f, "Tempo de espera (segundos) entre uma viagem e outra. 0 desliga."); CostItem = val.Bind<string>("Viagem", "ItemDeCusto", "", "Prefab do item cobrado por viagem (ex.: Coins). Vazio desliga."); AllowFavorites = val.Bind<bool>("Viagem", "PermitirFavoritos", true, "Se true, os jogadores podem favoritar portais (botão direito no mapa) e usar a lista de favoritos."); CostAmount = val.Bind<int>("Viagem", "QuantidadeDeCusto", 0, "Quantidade do item cobrada por viagem. 0 desliga."); MapCloseDistance = val.Bind<float>("Visual", "DistanciaFecharMapa", 1f, "Quantos metros você anda, a partir de onde o mapa abriu, até ele fechar sozinho. Só vale pra este PC."); PortalEffect = val.Bind<bool>("Visual", "EfeitoPortalAtivo", false, "Se true, mostra o redemoinho/efeito de portal conectado. Desligado deixa o portal sem o efeito (mais leve). Só vale pra este PC."); new Harmony("padilha.valheimportals").PatchAll(); } private void Update() { PortalNetwork.CheckTimeout(); PortalMap.Tick(); ServerSync.Tick(); } } public class PortalConfigUI : MonoBehaviour { [CompilerGenerated] private static class <>O { public static UnityAction <0>__Close; } public const string RpcSetConfig = "VP_SetConfig"; private static PortalConfigUI _instance; private static readonly Color SelectedTint = new Color(1f, 0.85f, 0.45f); private static readonly Color UnselectedTint = new Color(0.55f, 0.55f, 0.55f); private static readonly Color FrameOff = new Color(0f, 0f, 0f, 0.45f); private static readonly Color FrameOn = new Color(1f, 0.8f, 0.3f, 1f); private static readonly Color SoftText = new Color(0.92f, 0.86f, 0.74f, 1f); private static readonly Color DimText = new Color(0.78f, 0.7f, 0.58f, 1f); private ZNetView _nview; private bool _isCreator; private string _myGuild; private string _portalGuild; private float _openedAt; private string _name; private PortalType _type; private Color _color; private string _icon; private bool _syncing; private TMP_Text _topicT; private TMP_InputField _inputT; private Button _buttonT; private Image _bgT; private TMP_InputField _input; private TMP_InputField _hexInput; private TMP_Text _typeDesc; private Image _colorPreview; private Image _previewIcon; private TMP_Text _previewName; private readonly Slider[] _sliders = (Slider[])(object)new Slider[3]; private readonly TMP_Text[] _sliderValues = (TMP_Text[])(object)new TMP_Text[3]; private readonly List<KeyValuePair<PortalType, Button>> _typeButtons = new List<KeyValuePair<PortalType, Button>>(); private readonly List<KeyValuePair<string, Image>> _iconFrames = new List<KeyValuePair<string, Image>>(); private static GameObject _clickSfx; private static bool _sfxSearched; public static bool IsOpen => (Object)(object)_instance != (Object)null; public static void Open(ZNetView nview) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_instance != (Object)null) { Object.Destroy((Object)(object)((Component)_instance).gameObject); } if (!((Object)(object)nview == (Object)null) && nview.IsValid()) { _instance = new GameObject("ValheimPortals_ConfigUI").AddComponent<PortalConfigUI>(); _instance.Init(nview); } } public static void Close() { if ((Object)(object)_instance != (Object)null) { Object.Destroy((Object)(object)((Component)_instance).gameObject); } } private void OnDestroy() { if ((Object)(object)_instance == (Object)(object)this) { _instance = null; } } private void Init(ZNetView nview) { //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) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) _nview = nview; PortalInfo portalInfo = PortalInfo.FromZDO(nview.GetZDO()); _isCreator = portalInfo.Creator != 0L && portalInfo.Creator == PortalPerms.MyId; _myGuild = GuildBridge.MyGuild(); _portalGuild = portalInfo.Guild; _name = portalInfo.Name; _type = portalInfo.Type; _color = portalInfo.GetColor(); _icon = portalInfo.Icon; _openedAt = Time.unscaledTime; EnsureEventSystem(); LoadTemplates(); Build(Texts.T("ui_title")); if ((Object)(object)_input != (Object)null) { _input.text = _name; ((UnityEvent<string>)(object)_input.onValueChanged).AddListener((UnityAction<string>)delegate { RefreshPreview(); }); _input.ActivateInputField(); ((Selectable)_input).Select(); } SetColor(_color, updateHex: true); Refresh(); } private void Update() { if ((Object)(object)_nview == (Object)null || !_nview.IsValid() || (Object)(object)Player.m_localPlayer == (Object)null) { Close(); } else if (!(Time.unscaledTime - _openedAt < 0.3f)) { if (Input.GetKeyDown((KeyCode)27)) { Close(); } else if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271)) { OnOk(); } } } private void LateUpdate() { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } private static void EnsureEventSystem() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown if (!((Object)(object)EventSystem.current != (Object)null)) { Object.DontDestroyOnLoad((Object)new GameObject("ValheimPortals_EventSystem", new Type[2] { typeof(EventSystem), typeof(StandaloneInputModule) })); } } private void LoadTemplates() { TextInput instance = TextInput.instance; if ((Object)(object)instance == (Object)null) { return; } Traverse val = Traverse.Create((object)instance); GameObject value = val.Field("m_panel").GetValue<GameObject>(); ref TMP_Text topicT = ref _topicT; object value2 = val.Field("m_topic").GetValue(); topicT = (TMP_Text)((value2 is TMP_Text) ? value2 : null); ref TMP_InputField inputT = ref _inputT; object value3 = val.Field("m_inputField").GetValue(); inputT = (TMP_InputField)((value3 is TMP_InputField) ? value3 : null); if ((Object)(object)value != (Object)null) { _buttonT = value.GetComponentsInChildren<Button>(true).LastOrDefault(); FindClickSfx(_buttonT); _bgT = (from i in value.GetComponentsInChildren<Image>(true) where (Object)(object)i.sprite != (Object)null select i).OrderByDescending(delegate(Image i) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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) Rect rect = ((Graphic)i).rectTransform.rect; float width = ((Rect)(ref rect)).width; rect = ((Graphic)i).rectTransform.rect; return width * ((Rect)(ref rect)).height; }).FirstOrDefault(); } } private void Build(string title) { //IL_0039: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: 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_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_0302: 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_0357: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0380: 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_03cb: 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_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_0548: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_058a: Unknown result type (might be due to invalid IL or missing references) //IL_059d: Unknown result type (might be due to invalid IL or missing references) //IL_05b7: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05f7: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_061f: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Unknown result type (might be due to invalid IL or missing references) //IL_066c: Unknown result type (might be due to invalid IL or missing references) //IL_070a: Unknown result type (might be due to invalid IL or missing references) //IL_0719: Unknown result type (might be due to invalid IL or missing references) //IL_0745: Unknown result type (might be due to invalid IL or missing references) //IL_076b: Unknown result type (might be due to invalid IL or missing references) //IL_077a: Unknown result type (might be due to invalid IL or missing references) //IL_0789: Unknown result type (might be due to invalid IL or missing references) //IL_07a4: Unknown result type (might be due to invalid IL or missing references) //IL_07b3: Unknown result type (might be due to invalid IL or missing references) //IL_0801: Unknown result type (might be due to invalid IL or missing references) //IL_0810: Unknown result type (might be due to invalid IL or missing references) //IL_0846: Unknown result type (might be due to invalid IL or missing references) //IL_0855: Unknown result type (might be due to invalid IL or missing references) //IL_0891: Unknown result type (might be due to invalid IL or missing references) //IL_08a0: Unknown result type (might be due to invalid IL or missing references) //IL_08ac: Unknown result type (might be due to invalid IL or missing references) //IL_08b6: Expected O, but got Unknown //IL_086a: Unknown result type (might be due to invalid IL or missing references) //IL_086f: Unknown result type (might be due to invalid IL or missing references) //IL_0875: Expected O, but got Unknown //IL_06d9: Unknown result type (might be due to invalid IL or missing references) Canvas obj = ((Component)this).gameObject.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 30000; CanvasScaler obj2 = ((Component)this).gameObject.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); obj2.matchWidthOrHeight = 0.5f; ((Component)this).gameObject.AddComponent<GraphicRaycaster>(); RectTransform obj3 = NewRect("Dim", ((Component)this).transform, Vector2.zero, Vector2.zero); obj3.anchorMin = Vector2.zero; obj3.anchorMax = Vector2.one; obj3.sizeDelta = Vector2.zero; ((Graphic)((Component)obj3).gameObject.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.35f); RectTransform val = NewRect("Panel", ((Component)this).transform, Vector2.zero, new Vector2(720f, 836f)); Image val2 = ((Component)val).gameObject.AddComponent<Image>(); if ((Object)(object)_bgT != (Object)null) { val2.sprite = _bgT.sprite; val2.type = _bgT.type; val2.pixelsPerUnitMultiplier = _bgT.pixelsPerUnitMultiplier; ((Graphic)val2).color = ((Graphic)_bgT).color; } else { ((Graphic)val2).color = new Color(0.22f, 0.15f, 0.1f, 0.97f); } Label((Transform)(object)val, title, 34f, new Vector2(0f, 373f), new Vector2(640f, 46f), (TextAlignmentOptions)514); Separator((Transform)(object)val, 343f); Label((Transform)(object)val, Texts.T("ui_name"), 22f, new Vector2(0f, 313f), new Vector2(640f, 30f), (TextAlignmentOptions)513); _input = CloneInput((Transform)(object)val, "NameInput", new Vector2(0f, 276f), new Vector2(640f, 42f), 22f); if ((Object)(object)_input != (Object)null) { _input.characterLimit = 32; } Label((Transform)(object)val, Texts.T("ui_type"), 22f, new Vector2(0f, 233f), new Vector2(640f, 30f), (TextAlignmentOptions)513); AddTypeButton((Transform)(object)val, PortalType.Pessoal, Texts.T("type_personal"), new Vector2(-258f, 196f)); AddTypeButton((Transform)(object)val, PortalType.Publico, Texts.T("type_public"), new Vector2(-129f, 196f)); AddTypeButton((Transform)(object)val, PortalType.Guilda, GuildAvailable() ? Texts.T("type_guild") : Texts.T("type_guild_none"), new Vector2(0f, 196f)); AddTypeButton((Transform)(object)val, PortalType.Alianca, AllianceAvailable() ? Texts.T("type_alliance") : Texts.T("type_alliance_none"), new Vector2(129f, 196f)); AddTypeButton((Transform)(object)val, PortalType.Grupo, GroupBridge.Available ? Texts.T("type_group") : Texts.T("type_group_none"), new Vector2(258f, 196f)); _typeDesc = Label((Transform)(object)val, "", 17f, new Vector2(0f, 161f), new Vector2(640f, 24f), (TextAlignmentOptions)514); ((Graphic)_typeDesc).color = DimText; _typeDesc.fontStyle = (FontStyles)2; Separator((Transform)(object)val, 140f); Label((Transform)(object)val, Texts.T("ui_color"), 22f, new Vector2(0f, 115f), new Vector2(640f, 30f), (TextAlignmentOptions)513); RectTransform val3 = NewRect("ColorPreviewFrame", (Transform)(object)val, new Vector2(-262f, 68f), new Vector2(96f, 60f)); ((Graphic)((Component)val3).gameObject.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.55f); RectTransform val4 = NewRect("ColorPreview", (Transform)(object)val3, Vector2.zero, new Vector2(86f, 50f)); _colorPreview = ((Component)val4).gameObject.AddComponent<Image>(); ((Graphic)_colorPreview).raycastTarget = false; _hexInput = CloneInput((Transform)(object)val, "HexInput", new Vector2(-262f, 14f), new Vector2(116f, 34f), 18f); if ((Object)(object)_hexInput != (Object)null) { _hexInput.characterLimit = 7; ((UnityEvent<string>)(object)_hexInput.onValueChanged).AddListener((UnityAction<string>)OnHexChanged); } string[] array = new string[3] { "R", "G", "B" }; Color[] array2 = (Color[])(object)new Color[3] { new Color(0.9f, 0.25f, 0.2f), new Color(0.3f, 0.8f, 0.3f), new Color(0.3f, 0.55f, 1f) }; for (int i = 0; i < 3; i++) { float num = 80f - (float)i * 34f; ((Graphic)Label((Transform)(object)val, array[i], 20f, new Vector2(-168f, num), new Vector2(30f, 28f), (TextAlignmentOptions)514)).color = array2[i]; _sliders[i] = MakeSlider((Transform)(object)val, new Vector2(52f, num), 380f, array2[i], delegate { OnSliderChanged(); }); _sliderValues[i] = Label((Transform)(object)val, "0", 18f, new Vector2(282f, num), new Vector2(56f, 28f), (TextAlignmentOptions)516); ((Graphic)_sliderValues[i]).color = SoftText; } Separator((Transform)(object)val, -32f); Label((Transform)(object)val, Texts.T("ui_icon"), 22f, new Vector2(0f, -57f), new Vector2(640f, 30f), (TextAlignmentOptions)513); List<string> list = IconRegistry.Keys(); if (!list.Contains(_icon)) { _icon = "pin:Icon4"; } for (int num2 = 0; num2 < list.Count && num2 < 33; num2++) { int num3 = num2 / 11; int num4 = num2 % 11; AddIconButton((Transform)(object)val, list[num2], new Vector2(-280f + (float)num4 * 56f, -100f - (float)num3 * 56f)); } RectTransform val5 = NewRect("PreviewBar", (Transform)(object)val, new Vector2(0f, -282f), new Vector2(640f, 52f)); ((Graphic)((Component)val5).gameObject.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.4f); ((Graphic)Label((Transform)(object)val5, Texts.T("ui_preview"), 18f, new Vector2(-255f, 0f), new Vector2(110f, 30f), (TextAlignmentOptions)513)).color = DimText; RectTransform val6 = NewRect("PreviewIcon", (Transform)(object)val5, new Vector2(-175f, 0f), new Vector2(38f, 38f)); _previewIcon = ((Component)val6).gameObject.AddComponent<Image>(); _previewIcon.preserveAspect = true; ((Graphic)_previewIcon).raycastTarget = false; _previewName = Label((Transform)(object)val5, "", 20f, new Vector2(65f, 0f), new Vector2(430f, 30f), (TextAlignmentOptions)513); _previewName.richText = true; string text = Texts.T("ui_cancel"); Vector2 pos = new Vector2(-120f, -360f); Vector2 size = new Vector2(200f, 50f); object obj4 = <>O.<0>__Close; if (obj4 == null) { UnityAction val7 = Close; <>O.<0>__Close = val7; obj4 = (object)val7; } MakeButton((Transform)(object)val, text, pos, size, (UnityAction)obj4); MakeButton((Transform)(object)val, Texts.T("ui_ok"), new Vector2(120f, -360f), new Vector2(200f, 50f), new UnityAction(OnOk)); } private bool GuildAvailable() { if (!_isCreator) { return !string.IsNullOrEmpty(_portalGuild); } return !string.IsNullOrEmpty(_myGuild); } private bool AllianceAvailable() { if (GuildAvailable()) { return GuildBridge.AlliancesAvailable; } return false; } private void AddTypeButton(Transform parent, PortalType type, string text, Vector2 pos) { //IL_0017: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown Button val = MakeButton(parent, text, pos, new Vector2(124f, 44f), (UnityAction)delegate { _type = ((type == PortalType.Alianca && _type == PortalType.Alianca) ? PortalType.Guilda : type); Refresh(); }); if (type == PortalType.Guilda && !GuildAvailable() && _type != PortalType.Guilda) { ((Selectable)val).interactable = false; } if (type == PortalType.Alianca && !AllianceAvailable() && _type != PortalType.Alianca) { ((Selectable)val).interactable = false; } if (type == PortalType.Grupo && !GroupBridge.Available && _type != PortalType.Grupo) { ((Selectable)val).interactable = false; } _typeButtons.Add(new KeyValuePair<PortalType, Button>(type, val)); } private void AddIconButton(Transform parent, string key, Vector2 pos) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown RectTransform val = NewRect("Icon", parent, pos, new Vector2(52f, 52f)); Image val2 = ((Component)val).gameObject.AddComponent<Image>(); Image obj = ((Component)NewRect("Sprite", (Transform)(object)val, Vector2.zero, new Vector2(42f, 42f))).gameObject.AddComponent<Image>(); obj.sprite = IconRegistry.Get(key); obj.preserveAspect = true; ((Graphic)obj).raycastTarget = false; Button obj2 = ((Component)val).gameObject.AddComponent<Button>(); ((Selectable)obj2).targetGraphic = (Graphic)(object)val2; ((UnityEvent)obj2.onClick).AddListener((UnityAction)delegate { PlayClick(); _icon = key; Refresh(); }); _iconFrames.Add(new KeyValuePair<string, Image>(key, val2)); } private void SetColor(Color c, bool updateHex) { //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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0032: 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_00b5: Unknown result type (might be due to invalid IL or missing references) c.a = 1f; _color = c; _syncing = true; Color32 val = Color32.op_Implicit(c); byte[] array = new byte[3] { val.r, val.g, val.b }; for (int i = 0; i < 3; i++) { if ((Object)(object)_sliders[i] != (Object)null) { _sliders[i].SetValueWithoutNotify((float)(int)array[i]); } if ((Object)(object)_sliderValues[i] != (Object)null) { _sliderValues[i].text = array[i].ToString(); } } if (updateHex && (Object)(object)_hexInput != (Object)null) { _hexInput.SetTextWithoutNotify("#" + ColorUtility.ToHtmlStringRGB(c)); } _syncing = false; Refresh(); } private void OnSliderChanged() { //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) if (!_syncing) { Color32 val = default(Color32); ((Color32)(ref val))..ctor((byte)_sliders[0].value, (byte)_sliders[1].value, (byte)_sliders[2].value, byte.MaxValue); SetColor(Color32.op_Implicit(val), updateHex: true); } } private void OnHexChanged(string text) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (!_syncing) { string text2 = text.Trim(); if (!text2.StartsWith("#")) { text2 = "#" + text2; } Color c = default(Color); if (text2.Length == 7 && ColorUtility.TryParseHtmlString(text2, ref c)) { SetColor(c, updateHex: false); } } } private void Refresh() { //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<PortalType, Button> typeButton in _typeButtons) { bool flag = typeButton.Key == _type || (typeButton.Key == PortalType.Guilda && _type == PortalType.Alianca); if ((Object)(object)((Selectable)typeButton.Value).targetGraphic != (Object)null) { ((Selectable)typeButton.Value).targetGraphic.color = (flag ? Color.white : UnselectedTint); } TMP_Text componentInChildren = ((Component)typeButton.Value).GetComponentInChildren<TMP_Text>(true); if ((Object)(object)componentInChildren != (Object)null) { ((Graphic)componentInChildren).color = (flag ? SelectedTint : UnselectedTint); } } if ((Object)(object)_typeDesc != (Object)null) { switch (_type) { case PortalType.Pessoal: _typeDesc.text = Texts.T("desc_personal"); break; case PortalType.Publico: _typeDesc.text = Texts.T("desc_public"); break; case PortalType.Guilda: _typeDesc.text = Texts.T("desc_guild"); break; case PortalType.Alianca: _typeDesc.text = Texts.T("desc_alliance"); break; default: _typeDesc.text = Texts.T("desc_group"); break; } } if ((Object)(object)_colorPreview != (Object)null) { ((Graphic)_colorPreview).color = _color; } foreach (KeyValuePair<string, Image> iconFrame in _iconFrames) { ((Graphic)iconFrame.Value).color = ((iconFrame.Key == _icon) ? FrameOn : FrameOff); } RefreshPreview(); } private void RefreshPreview() { //IL_002c: 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) if ((Object)(object)_previewIcon != (Object)null) { _previewIcon.sprite = IconRegistry.Get(_icon); ((Graphic)_previewIcon).color = _color; } if ((Object)(object)_previewName != (Object)null) { string text = PortalInfo.SanitizeName(((Object)(object)_input != (Object)null) ? _input.text : _name); if (text.Length == 0) { text = _name; } _previewName.text = "<color=#" + ColorUtility.ToHtmlStringRGB(_color) + ">" + text + "</color> <color=#A89880>[" + PortalPerms.TypeLabel(_type) + "]</color>"; } } private void OnOk() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00af: 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) string text = PortalInfo.SanitizeName(((Object)(object)_input != (Object)null) ? _input.text : _name); if (text.Length == 0) { text = _name; } if ((_type == PortalType.Guilda || _type == PortalType.Alianca) && !GuildAvailable()) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, Texts.T("ui_need_guild"), 0, (Sprite)null, false); } return; } if ((Object)(object)_nview != (Object)null && _nview.IsValid()) { ZPackage val = new ZPackage(); val.Write(text); val.Write((int)_type); val.Write("#" + ColorUtility.ToHtmlStringRGB(_color)); val.Write(_icon ?? "pin:Icon4"); val.Write(_isCreator ? _myGuild : ""); val.Write(_isCreator ? GuildBridge.MyGuildName() : ""); val.Write(_isCreator ? GuildBridge.MyGuildsRef() : ""); ServerSync.SendConfigRequest(_nview.GetZDO().m_uid, val); } Close(); } public static void RPC_SetConfig(ZNetView nview, long sender, ZPackage pkg) { if (!((Object)(object)nview == (Object)null) && nview.IsValid() && nview.IsOwner() && sender == ServerSync.ServerId()) { ApplyConfig(nview.GetZDO(), pkg); } } public static void ApplyConfig(ZDO zdo, ZPackage pkg) { bool num = pkg.ReadBool(); ZPackage obj = pkg.ReadPackage(); string text = PortalInfo.SanitizeName(obj.ReadString()); int num2 = Mathf.Clamp(obj.ReadInt(), 0, 4); string hex = obj.ReadString(); string text2 = obj.ReadString(); string text3 = obj.ReadString(); string name = obj.ReadString(); string text4 = obj.ReadString(); if (text.Length > 0) { zdo.Set("vp_name", text); } zdo.Set("vp_type", num2); zdo.Set("vp_color", PortalInfo.SanitizeColor(hex)); zdo.Set("vp_icon", (text2.Length <= 64) ? text2 : "pin:Icon4"); if (num) { zdo.Set("vp_guild", text3); zdo.Set("vp_gname", PortalInfo.SanitizeName(name)); if (text4.Length > 0) { zdo.Set("vp_cref", text4); } } } private static RectTransform NewRect(string name, Transform parent, Vector2 pos, Vector2 size) { //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_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_0031: 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_0038: Expected O, but got Unknown //IL_0039: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); RectTransform val2 = (RectTransform)val.transform; Place(val2, pos, size); return val2; } private static void Place(RectTransform rt, Vector2 pos, Vector2 size) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0022: 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_0030: 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_0042: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0.5f); rt.pivot = val; Vector2 anchorMin = (rt.anchorMax = val); rt.anchorMin = anchorMin; rt.anchoredPosition = pos; rt.sizeDelta = size; ((Transform)rt).localScale = Vector3.one; ((Transform)rt).localRotation = Quaternion.identity; } private TMP_Text Label(Transform parent, string text, float size, Vector2 pos, Vector2 sizeDelta, TextAlignmentOptions align) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) TMP_Text val2; if ((Object)(object)_topicT != (Object)null) { GameObject val = Object.Instantiate<GameObject>(((Component)_topicT).gameObject, parent); ((Object)val).name = "Label"; val.SetActive(true); foreach (Transform item in val.transform) { Object.Destroy((Object)(object)((Component)item).gameObject); } StripVanilla(val); val2 = val.GetComponent<TMP_Text>(); } else { val2 = (TMP_Text)(object)((Component)NewRect("Label", parent, pos, sizeDelta)).gameObject.AddComponent<TextMeshProUGUI>(); ((Graphic)val2).color = new Color(1f, 0.75f, 0.35f); } Place((RectTransform)val2.transform, pos, sizeDelta); val2.text = text; val2.enableAutoSizing = false; val2.fontSize = size; val2.alignment = align; ((Graphic)val2).raycastTarget = false; return val2; } private TMP_InputField CloneInput(Transform parent, string name, Vector2 pos, Vector2 size, float fontSize) { //IL_0059: 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_0081: 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) //IL_0096: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0052: Expected O, but got Unknown TMP_InputField val; if ((Object)(object)_inputT != (Object)null) { GameObject obj = Object.Instantiate<GameObject>(((Component)_inputT).gameObject, parent); ((Object)obj).name = name; obj.SetActive(true); StripVanilla(obj); val = obj.GetComponent<TMP_InputField>(); ResetEvents((Component)(object)val); Place((RectTransform)obj.transform, pos, size); } else { RectTransform val2 = NewRect(name, parent, pos, size); ((Graphic)((Component)val2).gameObject.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.5f); RectTransform val3 = NewRect("TextArea", (Transform)(object)val2, Vector2.zero, size - new Vector2(16f, 6f)); ((Component)val3).gameObject.AddComponent<RectMask2D>(); TextMeshProUGUI val4 = ((Component)NewRect("Text", (Transform)(object)val3, Vector2.zero, size - new Vector2(16f, 6f))).gameObject.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val4).alignment = (TextAlignmentOptions)4097; val = ((Component)val2).gameObject.AddComponent<TMP_InputField>(); val.textViewport = val3; val.textComponent = (TMP_Text)(object)val4; } val.lineType = (LineType)0; val.pointSize = fontSize; return val; } private static Slider MakeSlider(Transform parent, Vector2 pos, float width, Color fill, UnityAction<float> onChange) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_00a9: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_0114: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown RectTransform val = NewRect("Slider", parent, pos, new Vector2(width, 14f)); ((Graphic)((Component)val).gameObject.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.55f); RectTransform parent2 = Stretch(NewRect("FillArea", (Transform)(object)val, Vector2.zero, Vector2.zero), 2f, 2f); RectTransform val2 = Stretch(NewRect("Fill", (Transform)(object)parent2, Vector2.zero, Vector2.zero), 0f, 0f); Image obj = ((Component)val2).gameObject.AddComponent<Image>(); ((Graphic)obj).color = fill; ((Graphic)obj).raycastTarget = false; RectTransform parent3 = Stretch(NewRect("HandleArea", (Transform)(object)val, Vector2.zero, Vector2.zero), 6f, 0f); RectTransform val3 = NewRect("Handle", (Transform)(object)parent3, Vector2.zero, Vector2.zero); val3.sizeDelta = new Vector2(12f, 24f); Image val4 = ((Component)val3).gameObject.AddComponent<Image>(); ((Graphic)val4).color = new Color(1f, 0.88f, 0.6f); Slider obj2 = ((Component)val).gameObject.AddComponent<Slider>(); obj2.fillRect = val2; obj2.handleRect = val3; ((Selectable)obj2).targetGraphic = (Graphic)(object)val4; obj2.direction = (Direction)0; obj2.minValue = 0f; obj2.maxValue = 255f; obj2.wholeNumbers = true; ((UnityEvent<float>)(object)obj2.onValueChanged).AddListener(onChange); EventTrigger obj3 = ((Component)val).gameObject.AddComponent<EventTrigger>(); Entry val5 = new Entry { eventID = (EventTriggerType)2 }; ((UnityEvent<BaseEventData>)(object)val5.callback).AddListener((UnityAction<BaseEventData>)delegate { PlayClick(); }); obj3.triggers.Add(val5); return obj2; } private static RectTransform Stretch(RectTransform rt, float padX, float padY) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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) rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; rt.offsetMin = new Vector2(padX, padY); rt.offsetMax = new Vector2(0f - padX, 0f - padY); return rt; } private static void Separator(Transform parent, float y) { //IL_000c: 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_0044: Unknown result type (might be due to invalid IL or missing references) Image obj = ((Component)NewRect("Separator", parent, new Vector2(0f, y), new Vector2(640f, 2f))).gameObject.AddComponent<Image>(); ((Graphic)obj).color = new Color(0.25f, 0.15f, 0.08f, 0.6f); ((Graphic)obj).raycastTarget = false; } private Button MakeButton(Transform parent, string text, Vector2 pos, Vector2 size, UnityAction onClick) { //IL_009c: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown Button val; if ((Object)(object)_buttonT != (Object)null) { GameObject obj = Object.Instantiate<GameObject>(((Component)_buttonT).gameObject, parent); ((Object)obj).name = "Btn_" + text; obj.SetActive(true); StripVanilla(obj); val = obj.GetComponent<Button>(); ResetEvents((Component)(object)val); TMP_Text componentInChildren = obj.GetComponentInChildren<TMP_Text>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.text = text; componentInChildren.enableAutoSizing = true; componentInChildren.fontSizeMin = 12f; } } else { RectTransform val2 = NewRect("Btn_" + text, parent, pos, size); Image val3 = ((Component)val2).gameObject.AddComponent<Image>(); ((Graphic)val3).color = new Color(0.3f, 0.22f, 0.15f, 1f); val = ((Component)val2).gameObject.AddComponent<Button>(); ((Selectable)val).targetGraphic = (Graphic)(object)val3; TextMeshProUGUI obj2 = ((Component)NewRect("Text", (Transform)(object)val2, Vector2.zero, size)).gameObject.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj2).text = text; ((TMP_Text)obj2).fontSize = 20f; ((TMP_Text)obj2).alignment = (TextAlignmentOptions)514; ((Graphic)obj2).raycastTarget = false; } Place((RectTransform)((Component)val).transform, pos, size); ((Selectable)val).interactable = true; ((UnityEvent)val.onClick).AddListener((UnityAction)delegate { if (!(Time.unscaledTime - _openedAt < 0.3f)) { PlayClick(); onClick.Invoke(); } }); return val; } private static void StripVanilla(GameObject go) { MonoBehaviour[] componentsInChildren = go.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !IsPureUI(val)) { Object.DestroyImmediate((Object)(object)val); } } Transform[] componentsInChildren2 = go.GetComponentsInChildren<Transform>(true); foreach (Transform val2 in componentsInChildren2) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2 == (Object)(object)go.transform)) { string text = ((Object)val2).name.ToLowerInvariant(); TMP_Text component = ((Component)val2).GetComponent<TMP_Text>(); bool flag = (Object)(object)component != (Object)null && component.text.Contains("MISSING"); if (text.Contains("hint") || text.Contains("gamepad") || text.Contains("keyboard") || flag) { Object.DestroyImmediate((Object)(object)((Component)val2).gameObject); } } } } private static bool IsPureUI(MonoBehaviour mb) { if (mb is TMP_InputField) { return true; } string text = ((object)mb).GetType().Namespace ?? ""; if (!text.StartsWith("UnityEngine")) { return text.StartsWith("TMPro"); } return true; } internal static void FindClickSfx(Button template) { if ((Object)(object)_clickSfx != (Object)null || _sfxSearched) { return; } _sfxSearched = true; Type type = AccessTools.TypeByName("ButtonSfx"); if (type == null) { return; } Component val = (((Object)(object)template != (Object)null) ? ((Component)template).GetComponent(type) : null); if ((Object)(object)val != (Object)null) { _clickSfx = Traverse.Create((object)val).Field("m_sfxPrefab").GetValue<GameObject>(); } if ((Object)(object)_clickSfx != (Object)null) { return; } Object[] array = Resources.FindObjectsOfTypeAll(type); for (int i = 0; i < array.Length; i++) { _clickSfx = Traverse.Create((object)array[i]).Field("m_sfxPrefab").GetValue<GameObject>(); if ((Object)(object)_clickSfx != (Object)null) { break; } } } internal static void PlayClick() { if ((Object)(object)_clickSfx != (Object)null) { Object.Instantiate<GameObject>(_clickSfx); } } private static void ResetEvents(Component c) { if ((Object)(object)c == (Object)null) { return; } Type type = ((object)c).GetType(); while (type != null && type != typeof(MonoBehaviour)) { FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (typeof(UnityEventBase).IsAssignableFrom(fieldInfo.FieldType) && !fieldInfo.FieldType.IsAbstract) { try { fieldInfo.SetValue(c, Activator.CreateInstance(fieldInfo.FieldType)); } catch { } } } type = type.BaseType; } } } public enum PortalType { Pessoal, Publico, Guilda, Grupo, Alianca } public class PortalInfo { public const string KName = "vp_name"; public const string KType = "vp_type"; public const string KColor = "vp_color"; public const string KIcon = "vp_icon"; public const string KCreatorName = "vp_cname"; public const string KGuild = "vp_guild"; public const string KGuildName = "vp_gname"; public const string KCreatorRef = "vp_cref"; public const string DefaultColor = "#FFFFFF"; public const string DefaultIcon = "pin:Icon4"; public const int MaxNameLength = 32; public ZDOID Id; public Vector3 Pos; public Quaternion Rot; public string Name; public PortalType Type; public string Color; public string Icon; public long Creator; public string CreatorName; public string CreatorRef; public string Guild; public string GuildName; public static PortalInfo FromZDO(ZDO zdo) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) PortalInfo portalInfo = new PortalInfo { Id = zdo.m_uid, Pos = zdo.GetPosition(), Rot = zdo.GetRotation(), Creator = zdo.GetLong(ZDOVars.s_creator, 0L), Color = zdo.GetString("vp_color", "#FFFFFF"), Icon = zdo.GetString("vp_icon", "pin:Icon4"), CreatorName = zdo.GetString("vp_cname", ""), CreatorRef = zdo.GetString("vp_cref", ""), Guild = zdo.GetString("vp_guild", ""), GuildName = zdo.GetString("vp_gname", "") }; int num = zdo.GetInt("vp_type", -1); portalInfo.Type = ((num < 0) ? ServerSync.LegacyType : ((PortalType)num)); string text = zdo.GetString("vp_name", ""); if (string.IsNullOrEmpty(text)) { text = zdo.GetString(ZDOVars.s_tag, ""); } text = SanitizeName(text); portalInfo.Name = ((text.Length > 0) ? text : "Portal"); portalInfo.CreatorName = SanitizeName(portalInfo.CreatorName); if (portalInfo.CreatorName.Length == 0) { portalInfo.CreatorName = Texts.T("unknown"); } portalInfo.GuildName = SanitizeName(portalInfo.GuildName); return portalInfo; } public void Write(ZPackage pkg) { //IL_0002: 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_001a: Unknown result type (might be due to invalid IL or missing references) pkg.Write(Id); pkg.Write(Pos); pkg.Write(Rot); pkg.Write(Name); pkg.Write((int)Type); pkg.Write(Color); pkg.Write(Icon); pkg.Write(Creator); pkg.Write(CreatorName); pkg.Write(CreatorRef); pkg.Write(Guild); pkg.Write(GuildName); } public static PortalInfo Read(ZPackage pkg) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) return new PortalInfo { Id = pkg.ReadZDOID(), Pos = pkg.ReadVector3(), Rot = pkg.ReadQuaternion(), Name = pkg.ReadString(), Type = (PortalType)pkg.ReadInt(), Color = pkg.ReadString(), Icon = pkg.ReadString(), Creator = pkg.ReadLong(), CreatorName = pkg.ReadString(), CreatorRef = pkg.ReadString(), Guild = pkg.ReadString(), GuildName = pkg.ReadString() }; } public Color GetColor() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ParseColor(Color); } public static Color ParseColor(string hex) { //IL_0010: 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) Color result = default(Color); if (!ColorUtility.TryParseHtmlString(hex, ref result)) { return Color.white; } return result; } public static string SanitizeColor(string hex) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) Color val = default(Color); if (!ColorUtility.TryParseHtmlString(hex, ref val)) { return "#FFFFFF"; } return "#" + ColorUtility.ToHtmlStringRGB(val); } public static string SanitizeName(string name) { if (name == null) { return ""; } name = name.Replace("<", "").Replace(">", "").Trim(); if (name.Length > 32) { name = name.Substring(0, 32); } return name; } } public static class PortalMap { private class Entry { public PortalInfo Info; public PinData Pin; public Color Color; public bool Current; } private static readonly List<Entry> _entries = new List<Entry>(); private static readonly List<PortalInfo> _favorites = new List<PortalInfo>(); private static float _openedAt; private static MethodInfo _screenToWorld; public static float BlockTeleportUntil; private static float _teleportStartedAt = -1f; private static float _lastTeleport = -9999f; private static bool _warnedCost; private static Vector3 _openedPos; public static bool Active { get; private set; } public static void Show(ZDOID current, List<PortalInfo> list) { //IL_003b: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) Minimap instance = Minimap.instance; Player localPlayer = Player.m_localPlayer; if ((Object)(object)instance == (Object)null || (Object)(object)localPlayer == (Object)null) { return; } Clear(); instance.SetMapMode((MapMode)2); Traverse.Create((object)instance).Field("m_mapOffset").SetValue((object)Vector3.zero); if (!Minimap.IsOpen()) { ((Character)localPlayer).Message((MessageType)2, Texts.T("map_disabled"), 0, (Sprite)null, false); return; } List<Vector3> list2 = Favorites.Load(); foreach (PortalInfo item in list) { bool current3 = item.Id == current; PinData val = instance.AddPin(item.Pos, (PinType)3, PinLabel(item, current3, ServerSync.AllowFavorites && Favorites.Contains(list2, item.Pos)), false, false, 0L, default(PlatformUserID)); Sprite val2 = IconRegistry.Get(item.Icon); if ((Object)(object)val2 != (Object)null) { val.m_icon = val2; } _entries.Add(new Entry { Info = item, Pin = val, Color = item.GetColor(), Current = current3 }); } if (ServerSync.AllowFavorites) { RefreshFavorites(); } Active = true; _openedAt = Time.time; _openedPos = ((Component)localPlayer).transform.position; if (_entries.Count <= 1) { ((Character)localPlayer).Message((MessageType)2, Texts.T("map_none"), 0, (Sprite)null, false); } else { ((Character)localPlayer).Message((MessageType)2, Texts.T(ServerSync.AllowFavorites ? "map_hint_fav" : "map_hint"), 0, (Sprite)null, false); } } public static void Clear() { if ((Object)(object)Minimap.instance != (Object)null) { foreach (Entry entry in _entries) { if (entry.Pin != null) { Minimap.instance.RemovePin(entry.Pin); } } } _entries.Clear(); _favorites.Clear(); FavoritesPanel.Hide(); Active = false; } private static string PinLabel(PortalInfo info, bool current, bool favorite) { string text = info.Name + " [" + PortalPerms.TypeLabel(info.Type) + "]"; if (favorite) { text = "* " + text; } if (current) { text = text + " - " + Texts.T("map_here"); } return text; } private static void RefreshFavorites() { //IL_000a: Unknown result type (might be due to invalid IL or missing re