Decompiled source of ValheimLikeMaps v1.0.0
ValheimLikeMaps.dll
Decompiled 16 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; 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 System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("pramodexe")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Valheim-style explorable map for Muck: clouds over unexplored land, automatic markers, filters and custom markers.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+f1743ebaa48efa4fee5b201c69037b7337833fef")] [assembly: AssemblyProduct("ValheimLikeMaps")] [assembly: AssemblyTitle("ValheimLikeMaps")] [assembly: AssemblyVersion("1.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; } } } internal static class BiggerMapCounts { [HarmonyPatch(typeof(StructureSpawner), "Start")] [HarmonyPriority(0)] private static class StructurePatch { private static void Prefix(StructureSpawner __instance) { if (Active) { FieldInfo f; switch (((Object)__instance).name) { default: return; case "ShrineGenerator": f = shrine; break; case "HouseGen": f = house; break; case "StructureGen": f = structure; break; } int num = Get(f); if (num > 0) { __instance.nShrines = num; } } } } [HarmonyPatch(typeof(CaveSpawner), "Start")] [HarmonyPriority(0)] private static class CavePatch { private static void Prefix(CaveSpawner __instance) { if (Active) { int num = Get(caveMin); int num2 = Get(caveMax); if (num > 0) { __instance.minCaves = num; } if (num2 > 0) { __instance.maxCaves = Math.Max(num2, __instance.minCaves); } } } } [HarmonyPatch(typeof(CampSpawner), "Start")] [HarmonyPriority(0)] private static class CampPatch { private static void Prefix(CampSpawner __instance) { if (Active) { int num = Get(campMin); int num2 = Get(campMax); if (num > 0) { __instance.minCaves = num; } if (num2 > 0) { __instance.maxCaves = Math.Max(num2, __instance.minCaves); } } } } private static bool? active; private static FieldInfo shrine; private static FieldInfo house; private static FieldInfo structure; private static FieldInfo caveMin; private static FieldInfo caveMax; private static FieldInfo campMin; private static FieldInfo campMax; private static bool Active { get { if (active.HasValue) { return active.Value; } active = false; if (!Chainloader.PluginInfos.ContainsKey("dnmal.biggermap")) { return false; } Type type = AccessTools.TypeByName("BiggerMap.BiggerMapPatch"); if (type == null) { return false; } shrine = AccessTools.Field(type, "_shrineCount"); house = AccessTools.Field(type, "_houseCount"); structure = AccessTools.Field(type, "_structureCount"); caveMin = AccessTools.Field(type, "_caveMin"); caveMax = AccessTools.Field(type, "_caveMax"); campMin = AccessTools.Field(type, "_campMin"); campMax = AccessTools.Field(type, "_campMax"); active = shrine != null && house != null && structure != null && caveMin != null && caveMax != null && campMin != null && campMax != null; return active.Value; } } private static int Get(FieldInfo f) { try { return (f.GetValue(null) is int num) ? num : 0; } catch { return 0; } } } public class BiggerMapLobby { public const string BiggerMapId = "dnmal.biggermap"; public const string BetterBiggerMapsId = "Johnny_Beanzz.BetterBiggerMaps"; private static readonly float[] Sizes = new float[9] { 1f, 1.5f, 2f, 2.5f, 3f, 3.5f, 4f, 4.5f, 5f }; private const int DefaultChunkSize = 241; private const float LobbyBoxHeight = 578f; private static readonly Vector2 LobbyBoxPos = new Vector2(-50f, -50f); private const float LobbyBoxWidth = 350f; private const float LobbyScale = 0.9f; private const float RowH = 30f; private const float LineH = 5f; private const float CellGap = 6f; private const float NoteH = 22f; private bool? hasBiggerMap; private bool failed; private float nextCheck; private GameObject block; private RectTransform blockRt; private GridLayoutGroup sizeGrid; private GridLayoutGroup countGrid; private TMP_InputField sizeInput; private readonly List<KeyValuePair<TextMeshProUGUI, int>> sizeButtons = new List<KeyValuePair<TextMeshProUGUI, int>>(); private float lastWidth = -1f; private string lastSizeText; private bool HasBiggerMap { get { bool? flag = hasBiggerMap; if (!flag.HasValue) { bool? flag2 = (hasBiggerMap = Chainloader.PluginInfos.ContainsKey("dnmal.biggermap")); return flag2.Value; } return flag == true; } } public static int ChunkSizeFor(float multiplier) { return Mathf.RoundToInt(240f * multiplier) + 1; } public void Tick() { //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) if (failed || !HasBiggerMap) { return; } if ((Object)(object)block != (Object)null) { KeepTidy(); } else { if (Time.unscaledTime < nextCheck) { return; } nextCheck = Time.unscaledTime + 0.3f; Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "Menu") { return; } GameObject val = GameObject.Find("Setting_Size"); if (!((Object)(object)val == (Object)null)) { try { Organize(val); ValheimLikeMapsPlugin.LogInfo("Tidied the BiggerMap lobby settings."); } catch (Exception e) { failed = true; ValheimLikeMapsPlugin.Instance?.LogOnce("lobby", e); } } } } private void Organize(GameObject sizeRow) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Expected O, but got Unknown //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Expected O, but got Unknown //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Expected O, but got Unknown //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Expected O, but got Unknown //IL_03fe: 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_05e0: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: Expected O, but got Unknown //IL_061c: Unknown result type (might be due to invalid IL or missing references) //IL_0636: 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_0552: Expected O, but got Unknown //IL_0696: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Expected O, but got Unknown //IL_06f2: Unknown result type (might be due to invalid IL or missing references) //IL_06f7: Unknown result type (might be due to invalid IL or missing references) //IL_0702: Unknown result type (might be due to invalid IL or missing references) //IL_070c: Unknown result type (might be due to invalid IL or missing references) //IL_0717: Unknown result type (might be due to invalid IL or missing references) //IL_0721: Unknown result type (might be due to invalid IL or missing references) //IL_072c: Unknown result type (might be due to invalid IL or missing references) //IL_0736: Unknown result type (might be due to invalid IL or missing references) //IL_0741: Unknown result type (might be due to invalid IL or missing references) //IL_0755: Unknown result type (might be due to invalid IL or missing references) //IL_0788: Unknown result type (might be due to invalid IL or missing references) //IL_078d: Unknown result type (might be due to invalid IL or missing references) //IL_079b: Unknown result type (might be due to invalid IL or missing references) //IL_07a6: Unknown result type (might be due to invalid IL or missing references) //IL_07b1: Unknown result type (might be due to invalid IL or missing references) //IL_07bb: Unknown result type (might be due to invalid IL or missing references) //IL_07c6: Unknown result type (might be due to invalid IL or missing references) //IL_07d0: Unknown result type (might be due to invalid IL or missing references) //IL_07db: Unknown result type (might be due to invalid IL or missing references) //IL_07e5: Unknown result type (might be due to invalid IL or missing references) //IL_07f0: Unknown result type (might be due to invalid IL or missing references) //IL_07fa: Unknown result type (might be due to invalid IL or missing references) //IL_08ab: Unknown result type (might be due to invalid IL or missing references) //IL_091a: Unknown result type (might be due to invalid IL or missing references) //IL_092a: Unknown result type (might be due to invalid IL or missing references) //IL_0957: Unknown result type (might be due to invalid IL or missing references) //IL_0976: Unknown result type (might be due to invalid IL or missing references) //IL_0990: Unknown result type (might be due to invalid IL or missing references) LobbySettings instance = LobbySettings.Instance; if ((Object)(object)instance == (Object)null) { throw new Exception("LobbySettings not found"); } RectTransform val = (RectTransform)((Component)instance).transform; Transform parent = sizeRow.transform.parent; Transform val2 = (((Object)(object)parent.parent != (Object)(object)val) ? parent.parent : null); sizeInput = Field("Setting_Size"); List<KeyValuePair<string, TMP_InputField>> list = new List<KeyValuePair<string, TMP_InputField>> { new KeyValuePair<string, TMP_InputField>("Shrines", Field("Setting_Shrine")), new KeyValuePair<string, TMP_InputField>("Houses", Field("Setting_House")), new KeyValuePair<string, TMP_InputField>("Structures", Field("Setting_Structure")), new KeyValuePair<string, TMP_InputField>("Caves min", Field("Setting_CaveMin")), new KeyValuePair<string, TMP_InputField>("Caves max", Field("Setting_CaveMax")), new KeyValuePair<string, TMP_InputField>("Camps min", Field("Setting_CampMin")), new KeyValuePair<string, TMP_InputField>("Camps max", Field("Setting_CampMax")) }; if ((Object)(object)sizeInput == (Object)null) { throw new Exception("BiggerMap size field not found"); } Transform val3 = parent.Find("Line"); Transform val4 = parent.Find("TextSeed"); GameObject val5 = (((Object)(object)instance.difficultySetting != (Object)null) ? instance.difficultySetting.settingButton : null); if ((Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null) { throw new Exception("Lobby templates not found"); } int siblingIndex = (((Object)(object)val2 != (Object)null) ? val2.GetSiblingIndex() : parent.GetSiblingIndex()); parent.SetParent((Transform)(object)val, false); parent.SetSiblingIndex(siblingIndex); GameObject val6 = new GameObject("ValheimLikeMaps_BiggerMapRows", new Type[1] { typeof(RectTransform) }); val6.transform.SetParent((Transform)(object)val, false); val6.AddComponent<LayoutElement>().ignoreLayout = true; CanvasGroup obj = val6.AddComponent<CanvasGroup>(); obj.alpha = 0f; obj.blocksRaycasts = false; obj.interactable = false; val6.transform.localScale = Vector3.zero; Transform val7 = parent.Find("Setting_Gamemdoe (1)"); int num = (((Object)(object)val7 != (Object)null) ? (val7.GetSiblingIndex() + 1) : parent.childCount); List<Transform> list2 = new List<Transform>(); for (int i = num; i < parent.childCount; i++) { list2.Add(parent.GetChild(i)); } foreach (Transform item in list2) { item.SetParent(val6.transform, false); } if ((Object)(object)val2 != (Object)null) { val2.SetParent(val6.transform, false); } block = new GameObject("ValheimLikeMaps_IslandSettings", new Type[1] { typeof(RectTransform) }); blockRt = (RectTransform)block.transform; ((Transform)blockRt).SetParent(parent, false); VerticalLayoutGroup val8 = block.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val8).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val8).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val8).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)val8).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)val8).spacing = 4f; float height = 0f; int children = 0; if ((Object)(object)val3 != (Object)null) { Add(Object.Instantiate<GameObject>(((Component)val3).gameObject), 5f); } Add(Label(val4, "Island Size", 1f, 30f), 30f); GameObject val9 = new GameObject("IslandSizeButtons", new Type[1] { typeof(RectTransform) }); sizeGrid = val9.AddComponent<GridLayoutGroup>(); sizeGrid.constraint = (Constraint)1; sizeGrid.constraintCount = 5; sizeGrid.spacing = new Vector2(6f, 6f); ((LayoutGroup)sizeGrid).childAlignment = (TextAnchor)1; sizeGrid.cellSize = new Vector2(52f, 30f); int num2 = Mathf.CeilToInt((float)Sizes.Length / 5f); Add(val9, (float)num2 * 30f + (float)(num2 - 1) * 6f); sizeButtons.Clear(); float[] sizes = Sizes; for (int j = 0; j < sizes.Length; j++) { float multiplier = sizes[j]; GameObject obj2 = Object.Instantiate<GameObject>(val5, val9.transform); ((Object)obj2).name = "Size_" + multiplier; TextMeshProUGUI componentInChildren = obj2.GetComponentInChildren<TextMeshProUGUI>(true); if ((Object)(object)componentInChildren != (Object)null) { ((TMP_Text)componentInChildren).text = multiplier.ToString("0.#", CultureInfo.InvariantCulture) + "x"; float fontSize = ((TMP_Text)componentInChildren).fontSize; ((TMP_Text)componentInChildren).enableAutoSizing = true; ((TMP_Text)componentInChildren).fontSizeMin = 10f; ((TMP_Text)componentInChildren).fontSizeMax = Mathf.Min(fontSize, 22f); } int chunk = ChunkSizeFor(multiplier); Button component = obj2.GetComponent<Button>(); if ((Object)(object)component != (Object)null) { ((UnityEvent)component.onClick).AddListener((UnityAction)delegate { SelectSize(chunk); }); } sizeButtons.Add(new KeyValuePair<TextMeshProUGUI, int>(componentInChildren, chunk)); } if ((Object)(object)val3 != (Object)null) { Add(Object.Instantiate<GameObject>(((Component)val3).gameObject), 5f); } Add(Label(val4, "Island Contents", 1f, 30f), 30f); GameObject val10 = new GameObject("IslandCounts", new Type[1] { typeof(RectTransform) }); countGrid = val10.AddComponent<GridLayoutGroup>(); countGrid.constraint = (Constraint)1; countGrid.constraintCount = 2; countGrid.spacing = new Vector2(12f, 4f); countGrid.cellSize = new Vector2(140f, 26f); int num3 = 0; foreach (KeyValuePair<string, TMP_InputField> item2 in list) { if (!((Object)(object)item2.Value == (Object)null)) { num3++; GameObject val11 = new GameObject("Count_" + item2.Key, new Type[1] { typeof(RectTransform) }); val11.transform.SetParent(val10.transform, false); GameObject obj3 = Label(val4, item2.Key, 0.62f, 26f); obj3.transform.SetParent(val11.transform, false); NoLayout(obj3); RectTransform val12 = (RectTransform)obj3.transform; val12.anchorMin = new Vector2(0f, 0f); val12.anchorMax = new Vector2(1f, 1f); val12.pivot = new Vector2(0f, 0.5f); val12.offsetMin = new Vector2(2f, 0f); val12.offsetMax = new Vector2(-60f, 0f); TextMeshProUGUI component2 = obj3.GetComponent<TextMeshProUGUI>(); if ((Object)(object)component2 != (Object)null) { ((TMP_Text)component2).alignment = (TextAlignmentOptions)4097; } RectTransform val13 = (RectTransform)((Component)item2.Value).transform; ((Transform)val13).SetParent(val11.transform, false); NoLayout(((Component)val13).gameObject); val13.anchorMin = new Vector2(1f, 0f); val13.anchorMax = new Vector2(1f, 1f); val13.pivot = new Vector2(1f, 0.5f); val13.sizeDelta = new Vector2(56f, 0f); val13.anchoredPosition = Vector2.zero; item2.Value.pointSize = Mathf.Min(item2.Value.pointSize, 16f); ((Selectable)item2.Value).interactable = true; } } int num4 = Mathf.CeilToInt((float)num3 / 2f); if (num4 > 0) { Add(val10, (float)num4 * 26f + (float)(num4 - 1) * 4f); } else { Object.Destroy((Object)(object)val10); } Add(Label(val4, "Set automatically from the island size. Change them if you like.", 0.5f, 22f, (Color?)new Color(0.75f, 0.75f, 0.75f)), 22f); height += (float)(children - 1) * ((HorizontalOrVerticalLayoutGroup)val8).spacing; LayoutElement obj4 = block.AddComponent<LayoutElement>(); float minHeight = (obj4.preferredHeight = height); obj4.minHeight = minHeight; obj4.flexibleHeight = 0f; blockRt.sizeDelta = new Vector2(blockRt.sizeDelta.x, height); VerticalLayoutGroup component3 = ((Component)parent).GetComponent<VerticalLayoutGroup>(); float num6 = (((Object)(object)component3 != (Object)null) ? ((HorizontalOrVerticalLayoutGroup)component3).spacing : 0f); val.anchoredPosition = LobbyBoxPos; val.sizeDelta = new Vector2(350f, 578f + height + num6); ((Transform)val).localScale = new Vector3(0.9f, 0.9f, 1f); lastWidth = -1f; lastSizeText = null; KeepTidy(); LayoutRebuilder.ForceRebuildLayoutImmediate(val); void Add(GameObject go, float h) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) go.transform.SetParent((Transform)(object)blockRt, false); LayoutElement obj5 = go.GetComponent<LayoutElement>() ?? go.AddComponent<LayoutElement>(); float minHeight2 = (obj5.preferredHeight = h); obj5.minHeight = minHeight2; obj5.flexibleHeight = 0f; ((RectTransform)go.transform).sizeDelta = new Vector2(((RectTransform)go.transform).sizeDelta.x, h); height += h; children++; } static TMP_InputField Field(string row) { GameObject val14 = GameObject.Find(row); if (!((Object)(object)val14 != (Object)null)) { return null; } return val14.GetComponentInChildren<TMP_InputField>(true); } } private static GameObject Label(Transform template, string text, float sizeFactor, float boxHeight, Color? color = null) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Object.Instantiate<GameObject>(((Component)template).gameObject); ((Object)obj).name = "Label_" + text; TextMeshProUGUI component = obj.GetComponent<TextMeshProUGUI>(); if ((Object)(object)component != (Object)null) { float num = Mathf.Max(10f, ((TMP_Text)component).fontSize * sizeFactor); ((TMP_Text)component).text = text; ((TMP_Text)component).enableWordWrapping = false; ((TMP_Text)component).overflowMode = (TextOverflowModes)0; ((TMP_Text)component).enableAutoSizing = true; ((TMP_Text)component).fontSizeMin = 8f; ((TMP_Text)component).fontSizeMax = Mathf.Min(num, boxHeight * 0.85f); ((TMP_Text)component).fontSize = ((TMP_Text)component).fontSizeMax; ((TMP_Text)component).margin = Vector4.zero; if (color.HasValue) { ((Graphic)component).color = color.Value; } } return obj; } private static void NoLayout(GameObject go) { (go.GetComponent<LayoutElement>() ?? go.AddComponent<LayoutElement>()).ignoreLayout = true; } private void SelectSize(int chunk) { if (!((Object)(object)sizeInput == (Object)null)) { sizeInput.text = chunk.ToString(CultureInfo.InvariantCulture); lastSizeText = null; } } private void KeepTidy() { //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_0072: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) float num; if (!((Object)(object)blockRt != (Object)null)) { num = 0f; } else { Rect rect = blockRt.rect; num = ((Rect)(ref rect)).width; } float num2 = num; if (num2 > 20f && Mathf.Abs(num2 - lastWidth) > 0.5f) { lastWidth = num2; if ((Object)(object)sizeGrid != (Object)null) { sizeGrid.cellSize = new Vector2((num2 - 24f) / 5f, 30f); } if ((Object)(object)countGrid != (Object)null) { countGrid.cellSize = new Vector2((num2 - 12f) / 2f, 26f); } } if (!((Object)(object)sizeInput != (Object)null) || !(sizeInput.text != lastSizeText)) { return; } lastSizeText = sizeInput.text; int.TryParse(lastSizeText, out var result); foreach (KeyValuePair<TextMeshProUGUI, int> sizeButton in sizeButtons) { if ((Object)(object)sizeButton.Key != (Object)null) { ((Graphic)sizeButton.Key).color = ((sizeButton.Value == result) ? Color.white : Color.gray); } } } } public class FogLayer { public byte[] explored; private float[] land; private Color32[] cloud; private Color32[] pixels; private Texture2D tex; private GameObject go; private bool dirty = true; private float worldSize; public int Res { get; private set; } = 512; public void Build(Map map) { //IL_007f: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Expected O, but got Unknown //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) worldSize = (float)MapGenerator.mapChunkSize * (float)MapGenerator.worldScale; Res = Mathf.Clamp(Mathf.NextPowerOfTwo(MapGenerator.mapChunkSize * 2), 512, 1024); explored = new byte[Res * Res]; BuildLandMask(); BuildClouds(); pixels = (Color32[])(object)new Color32[Res * Res]; tex = new Texture2D(Res, Res, (TextureFormat)4, false) { filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1, name = "ValheimLikeMapsClouds" }; RebuildAll(); RawImage mapRender = map.mapRender; Transform transform = ((Component)mapRender).transform; go = new GameObject("ValheimLikeMapsClouds", new Type[2] { typeof(RectTransform), typeof(RawImage) }); RawImage component = go.GetComponent<RawImage>(); component.texture = (Texture)(object)tex; component.uvRect = mapRender.uvRect; ((Graphic)component).raycastTarget = false; RectTransform val = (RectTransform)go.transform; bool flag = (Object)(object)transform == (Object)(object)((Component)map.map).transform || map.markerParent.IsChildOf(transform) || (Object)(object)transform.parent == (Object)null; if (flag) { ((Transform)val).SetParent(transform, false); ((Transform)val).SetSiblingIndex(0); val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; val.pivot = new Vector2(0.5f, 0.5f); val.offsetMin = Vector2.zero; val.offsetMax = Vector2.zero; ((Transform)val).localScale = Vector3.one; } else { RectTransform val2 = (RectTransform)transform; ((Transform)val).SetParent(transform.parent, false); ((Transform)val).SetSiblingIndex(transform.GetSiblingIndex() + 1); val.anchorMin = val2.anchorMin; val.anchorMax = val2.anchorMax; val.pivot = val2.pivot; val.sizeDelta = val2.sizeDelta; val.anchoredPosition3D = val2.anchoredPosition3D; ((Transform)val).localScale = ((Transform)val2).localScale; ((Transform)val).localRotation = ((Transform)val2).localRotation; } KeepBelow((Transform)(object)val, map.markerParent); KeepBelow((Transform)(object)val, map.playerMarkerParent); if ((Object)(object)map.playerIcon != (Object)null) { KeepBelow((Transform)(object)val, map.playerIcon); } ValheimLikeMapsPlugin.LogInfo("Clouds placed " + (flag ? "inside" : "next to") + " '" + Path(transform) + "'. Markers: '" + Path(map.markerParent) + "'. Zoom: '" + Path(((Component)map.map).transform) + "'."); } private static void KeepBelow(Transform fog, Transform other) { if ((Object)(object)fog == (Object)null || (Object)(object)other == (Object)null || other.IsChildOf(fog)) { return; } Transform parent = fog.parent; if (!((Object)(object)parent == (Object)null) && other.IsChildOf(parent)) { Transform val = other; while ((Object)(object)val.parent != (Object)(object)parent) { val = val.parent; } if (!((Object)(object)val == (Object)(object)fog) && val.GetSiblingIndex() < fog.GetSiblingIndex()) { fog.SetSiblingIndex(val.GetSiblingIndex()); ValheimLikeMapsPlugin.LogInfo("Moved clouds under '" + ((Object)val).name + "' so its markers stay visible."); } } } private static string Path(Transform t) { string text = (Object.op_Implicit((Object)(object)t) ? ((Object)t).name : "null"); Transform val = (Object.op_Implicit((Object)(object)t) ? t.parent : null); while ((Object)(object)val != (Object)null) { text = ((Object)val).name + "/" + text; val = val.parent; } return text; } public void Destroy() { if (Object.op_Implicit((Object)(object)go)) { Object.Destroy((Object)(object)go); } if (Object.op_Implicit((Object)(object)tex)) { Object.Destroy((Object)(object)tex); } } private void BuildLandMask() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) land = new float[Res * Res]; float[,] heightMap = MapGenerator.Instance.heightMap; int length = heightMap.GetLength(0); Layer[] layers = MapGenerator.Instance.textureData.layers; float num = float.NegativeInfinity; for (int i = 0; i < layers.Length; i++) { if ((int)layers[i].type != 0) { if (i > 0) { num = layers[i].startHeight + 0.1f; } break; } } for (int j = 0; j < Res; j++) { float fi = ((float)j + 0.5f) / (float)Res * (float)length - 0.5f; for (int k = 0; k < Res; k++) { float fj = ((float)k + 0.5f) / (float)Res * (float)length - 0.5f; float num2 = SampleHeight(heightMap, length, fj, fi); land[j * Res + k] = (float.IsNegativeInfinity(num) ? 1f : Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(num - 0.012f, num + 0.012f, num2))); } } } private static float SampleHeight(float[,] hm, int n, float fj, float fi) { fj = Mathf.Clamp(fj, 0f, (float)n - 1.001f); fi = Mathf.Clamp(fi, 0f, (float)n - 1.001f); int num = (int)fj; int num2 = (int)fi; float num3 = fj - (float)num; float num4 = fi - (float)num2; float num5 = hm[num, n - 1 - num2]; float num6 = hm[num + 1, n - 1 - num2]; float num7 = hm[num, n - 2 - num2]; float num8 = hm[num + 1, n - 2 - num2]; return Mathf.Lerp(Mathf.Lerp(num5, num6, num3), Mathf.Lerp(num7, num8, num3), num4); } private void BuildClouds() { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) cloud = (Color32[])(object)new Color32[Res * Res]; Color val = default(Color); ((Color)(ref val))..ctor(0.9f, 0.92f, 0.95f); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.56f, 0.6f, 0.68f); for (int i = 0; i < Res; i++) { for (int j = 0; j < Res; j++) { float num = (float)j / (float)Res; float num2 = (float)i / (float)Res; float num3 = 0f; float num4 = 0.5f; float num5 = 6f; for (int k = 0; k < 4; k++) { num3 += num4 * Mathf.PerlinNoise(37.1f + num * num5, 91.7f + num2 * num5); num4 *= 0.5f; num5 *= 2.1f; } num3 = Mathf.Clamp01((num3 - 0.2f) / 0.65f); cloud[i * Res + j] = Color32.op_Implicit(Color.Lerp(val2, val, num3)); } } } public void RebuildAll() { if (pixels != null) { for (int i = 0; i < pixels.Length; i++) { UpdatePixel(i); } dirty = true; } } private void UpdatePixel(int i) { //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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) Color32 val = cloud[i]; float num = land[i] * (1f - (float)(int)explored[i] / 255f) * 0.98f; val.a = (byte)(num * 255f); pixels[i] = val; } public void ApplyIfDirty() { if (dirty && !((Object)(object)tex == (Object)null)) { dirty = false; tex.SetPixels32(pixels); tex.Apply(false); } } private void WorldToPixel(Vector3 pos, out float px, out float py) { //IL_0001: 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) px = (pos.x / worldSize + 0.5f) * (float)Res; py = (pos.z / worldSize + 0.5f) * (float)Res; } public bool Reveal(Vector3 pos, float radius) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) WorldToPixel(pos, out var px, out var py); float num = radius / worldSize * (float)Res; float num2 = num * 0.72f; int num3 = Mathf.Max(0, Mathf.FloorToInt(px - num)); int num4 = Mathf.Min(Res - 1, Mathf.CeilToInt(px + num)); int num5 = Mathf.Max(0, Mathf.FloorToInt(py - num)); int num6 = Mathf.Min(Res - 1, Mathf.CeilToInt(py + num)); bool flag = false; for (int i = num5; i <= num6; i++) { float num7 = (float)i + 0.5f - py; for (int j = num3; j <= num4; j++) { float num8 = (float)j + 0.5f - px; float num9 = Mathf.Sqrt(num8 * num8 + num7 * num7); if (!(num9 >= num)) { byte b = (byte)(((num9 <= num2) ? 1f : (1f - Mathf.SmoothStep(0f, 1f, (num9 - num2) / (num - num2)))) * 255f); int num10 = i * Res + j; if (b > explored[num10]) { explored[num10] = b; UpdatePixel(num10); flag = true; } } } } if (flag) { dirty = true; } return flag; } public bool IsExplored(Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) WorldToPixel(pos, out var px, out var py); int num = (int)px; int num2 = (int)py; if (num < 0 || num2 < 0 || num >= Res || num2 >= Res) { return true; } return explored[num2 * Res + num] >= 110; } public void LoadExplored(byte[] data) { if (data != null && data.Length == explored.Length) { Buffer.BlockCopy(data, 0, explored, 0, data.Length); RebuildAll(); } } } public class Icon { public Texture tex; public Rect uv = new Rect(0f, 0f, 1f, 1f); public Icon(Texture t) { //IL_0015: 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) tex = t; } public Icon(Texture t, Rect r) { //IL_0015: 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_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) tex = t; uv = r; } public static Icon FromSprite(Sprite s) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s == (Object)null || (Object)(object)s.texture == (Object)null) { return null; } Texture2D texture = s.texture; Rect textureRect = s.textureRect; return new Icon((Texture)(object)texture, new Rect(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height)); } } public enum Shape { Circle, Square, Diamond, Triangle, Star, Plus, Cross, House, Cave, Flag, Ring, Stickman } public static class Icons { private static readonly Dictionary<Shape, Texture2D> shapes = new Dictionary<Shape, Texture2D>(); public static readonly Color[] CustomColors = (Color[])(object)new Color[8] { new Color(1f, 1f, 1f), new Color(1f, 0.32f, 0.3f), new Color(1f, 0.62f, 0.2f), new Color(1f, 0.9f, 0.25f), new Color(0.45f, 0.9f, 0.35f), new Color(0.35f, 0.8f, 1f), new Color(0.55f, 0.5f, 1f), new Color(1f, 0.5f, 0.85f) }; public static Texture2D White { get; private set; } public static void Init() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)White == (Object)null) { White = new Texture2D(1, 1, (TextureFormat)4, false); White.SetPixel(0, 0, Color.white); White.Apply(); Object.DontDestroyOnLoad((Object)(object)White); } } public static Icon Get(Shape s) { if (!shapes.TryGetValue(s, out var value) || (Object)(object)value == (Object)null) { value = Draw(s); shapes[s] = value; } return new Icon((Texture)(object)value); } public static Icon FromItemName(params string[] names) { try { InventoryItem[] array = ItemManager.Instance?.allScriptableItems; if (array == null) { return null; } foreach (string b in names) { InventoryItem[] array2 = array; foreach (InventoryItem val in array2) { if ((Object)(object)val != (Object)null && (Object)(object)val.sprite != (Object)null && string.Equals(val.name, b, StringComparison.OrdinalIgnoreCase)) { return Icon.FromSprite(val.sprite); } } } } catch { } return null; } private static Texture2D Draw(Shape s) { //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false) { filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; Color32[] array = (Color32[])(object)new Color32[4096]; Color val2 = default(Color); ((Color)(ref val2))..ctor(0.08f, 0.08f, 0.1f); float num = 5f / 128f; float num2 = ((s == Shape.Stickman) ? 0.09f : 0.16f); Vector2 p = default(Vector2); for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { ((Vector2)(ref p))..ctor(((float)j + 0.5f) / 64f * 2f - 1f, ((float)i + 0.5f) / 64f * 2f - 1f); float num3 = Sdf(s, p); float a = Mathf.Clamp01(0.5f - num3 / num); float num4 = Mathf.Clamp01(0.5f - (num3 + num2) / num); Color val3 = Color.Lerp(val2, Color.white, num4); val3.a = a; array[i * 64 + j] = Color32.op_Implicit(val3); } } val.SetPixels32(array); val.Apply(); Object.DontDestroyOnLoad((Object)(object)val); return val; } private static float Sdf(Shape s, Vector2 p) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_012e: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: 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_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) switch (s) { case Shape.Circle: return ((Vector2)(ref p)).magnitude - 0.8f; case Shape.Ring: return Mathf.Abs(((Vector2)(ref p)).magnitude - 0.62f) - 0.28f; case Shape.Square: return Box(p, new Vector2(0.62f, 0.62f)) - 0.14f; case Shape.Diamond: return (Mathf.Abs(p.x) + Mathf.Abs(p.y) - 0.95f) * 0.7071f; case Shape.Triangle: return Triangle(new Vector2(p.x, p.y + 0.2f), 0.88f); case Shape.Star: return Star(new Vector2(p.x, p.y + 0.06f), 0.98f, 0.45f); case Shape.Plus: return Mathf.Min(Box(p, new Vector2(0.88f, 0.3f)), Box(p, new Vector2(0.3f, 0.88f))); case Shape.Cross: { Vector2 p2 = new Vector2(p.x + p.y, p.y - p.x) * 0.7071f; return Mathf.Min(Box(p2, new Vector2(0.95f, 0.24f)), Box(p2, new Vector2(0.24f, 0.95f))); } case Shape.House: { float num9 = Box(p - new Vector2(0f, -0.45f), new Vector2(0.6f, 0.45f)); float num10 = Triangle(new Vector2(p.x, (p.y - 0.12f) * 1.7f), 0.95f) / 1.7f; return Mathf.Min(num9, num10); } case Shape.Cave: { Vector2 val2 = p - new Vector2(0f, -0.45f); float num7 = Mathf.Max(((Vector2)(ref val2)).magnitude - 0.95f, 0f - val2.y); float num8 = Mathf.Max(((Vector2)(ref val2)).magnitude - 0.45f, 0f - val2.y - 0.1f); return Mathf.Max(num7, 0f - num8); } case Shape.Stickman: { Vector2 val = p - new Vector2(0f, 0.58f); float num3 = ((Vector2)(ref val)).magnitude - 0.3f; float num4 = Segment(p, new Vector2(0f, 0.3f), new Vector2(0f, -0.28f)) - 0.16f; float num5 = Mathf.Min(Segment(p, new Vector2(0f, 0.12f), new Vector2(-0.5f, -0.12f)), Segment(p, new Vector2(0f, 0.12f), new Vector2(0.5f, -0.12f))) - 0.16f; float num6 = Mathf.Min(Segment(p, new Vector2(0f, -0.28f), new Vector2(-0.4f, -0.9f)), Segment(p, new Vector2(0f, -0.28f), new Vector2(0.4f, -0.9f))) - 0.16f; return Mathf.Min(Mathf.Min(num3, num4), Mathf.Min(num5, num6)); } case Shape.Flag: { float num = Box(p - new Vector2(-0.6f, 0f), new Vector2(0.12f, 0.92f)); float num2 = Box(p - new Vector2(0.05f, 0.42f), new Vector2(0.55f, 0.42f)); return Mathf.Min(num, num2); } default: return ((Vector2)(ref p)).magnitude - 0.8f; } } private static float Segment(Vector2 p, Vector2 a, Vector2 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) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector2 val = p - a; Vector2 val2 = b - a; float num = Mathf.Clamp01(Vector2.Dot(val, val2) / Vector2.Dot(val2, val2)); Vector2 val3 = val - val2 * num; return ((Vector2)(ref val3)).magnitude; } private static float Box(Vector2 p, Vector2 b) { //IL_0002: 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_0014: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(Mathf.Abs(p.x) - b.x, Mathf.Abs(p.y) - b.y); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(Mathf.Max(val.x, 0f), Mathf.Max(val.y, 0f)); return ((Vector2)(ref val2)).magnitude + Mathf.Min(Mathf.Max(val.x, val.y), 0f); } private static float Triangle(Vector2 p, float r) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) p.x = Mathf.Abs(p.x) - r; p.y += r / 1.7320508f; if (p.x + 1.7320508f * p.y > 0f) { p = new Vector2(p.x - 1.7320508f * p.y, -1.7320508f * p.x - p.y) / 2f; } p.x -= Mathf.Clamp(p.x, -2f * r, 0f); return (0f - ((Vector2)(ref p)).magnitude) * Mathf.Sign(p.y); } private static float Star(Vector2 p, float r, float rf) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00ad: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.809017f, -0.58778524f); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f - val.x, val.y); p.x = Mathf.Abs(p.x); p -= 2f * Mathf.Max(Vector2.Dot(val, p), 0f) * val; p -= 2f * Mathf.Max(Vector2.Dot(val2, p), 0f) * val2; p.x = Mathf.Abs(p.x); p.y -= r; Vector2 val3 = rf * new Vector2(0f - val.y, val.x) - new Vector2(0f, 1f); float num = Mathf.Clamp(Vector2.Dot(p, val3) / Vector2.Dot(val3, val3), 0f, r); Vector2 val4 = p - val3 * num; return ((Vector2)(ref val4)).magnitude * Mathf.Sign(p.y * val3.x - p.x * val3.y); } } public class CustomMarker { public Vector3 pos; public string name = ""; public int shape; public int color; public MarkerUi ui; } [BepInPlugin("pramodexe.valheimlikemaps", "ValheimLikeMaps", "1.0.0")] public class ValheimLikeMapsPlugin : BaseUnityPlugin { internal readonly List<CustomMarker> customMarkers = new List<CustomMarker>(); private Tracked hovered; private CustomMarker hoveredCustom; private Vector2 mouseDownPos; private float lastClickTime = -10f; private Vector2 lastClickPos; internal bool popupOpen; internal int popupClosedFrame = -10; private CustomMarker popupEditing; private Vector3 popupWorld; private string popupName = ""; private int popupColor; private Vector2 popupGuiPos; private bool focusName; private Rect panelScreenRect; private Rect popupScreenRect; private Vector2 panelScroll; private const string NameControl = "ValheimLikeMapsMarkerName"; private GUIStyle panelStyle; private GUIStyle headerStyle; private GUIStyle groupStyle; private GUIStyle rowStyle; private GUIStyle smallStyle; private GUIStyle buttonStyle; private GUIStyle tipStyle; private GUIStyle iconButtonStyle; private GUIStyle iconButtonOnStyle; private Texture2D panelBg; private Texture2D tipBg; private Texture2D btnBg; private Texture2D btnOnBg; private const char PresetSeparator = '|'; public const string Version = "1.0.0"; private Harmony harmony; internal const float RevealRadius = 110f; internal ConfigEntry<bool> cfgRemember; internal ConfigEntry<float> cfgIconSize; internal ConfigEntry<bool> cfgShowNames; internal ConfigEntry<bool> cfgPanelOpen; internal ConfigEntry<bool> cfgOptionsOpen; internal ConfigEntry<string>[] cfgPresets; private Map sessionMap; private bool sessionActive; private int sessionSeed; private float sessionStartTime; private float revealTimer; private float resourceScanTimer; private float mobScanTimer; private float saveTimer; private Vector3 lastRevealPos = new Vector3(float.MaxValue, 0f, 0f); private readonly HashSet<string> loggedErrors = new HashSet<string>(); private readonly BiggerMapLobby biggerMapLobby = new BiggerMapLobby(); internal bool saveDirty; public const string GroupPlaces = "Places"; public const string GroupShrines = "Shrines"; public const string GroupLoot = "Loot"; public const string GroupCreatures = "Creatures"; public const string GroupOres = "Ores & rocks"; public const string GroupTrees = "Trees"; public const string GroupMine = "My markers"; internal static readonly string[] GroupOrder = new string[7] { "Places", "Shrines", "Loot", "Creatures", "Ores & rocks", "Trees", "My markers" }; private static readonly string[] TreeOrder = new string[4] { "birch", "fir", "oak", "dark oak" }; private static readonly string[] OreOrder = new string[10] { "rock", "flint", "coal", "copper", "iron", "gold", "mithril", "chunkium", "adamantite", "obamium" }; internal FogLayer fog; internal MarkerLayer markers; internal readonly Dictionary<string, Category> categories = new Dictionary<string, Category>(); internal readonly List<Tracked> tracked = new List<Tracked>(); internal readonly HashSet<Tracked> shownTracked = new HashSet<Tracked>(); private readonly HashSet<int> trackedIds = new HashSet<int>(); private readonly HashSet<int> resourceIdsSeen = new HashSet<int>(); private readonly HashSet<int> chestIdsSeen = new HashSet<int>(); internal readonly HashSet<string> dismissed = new HashSet<string>(); private Category catVillage; private Category catCave; private Category catBossShrine; private Category catBattle; private Category catRevive; private Category catChest; private Category catHutChest; private Category catChief; private Category catAnimal; private Category catBoss; internal Category catCustom; private static readonly FieldRef<LootContainerInteract, bool> lootOpened = SafeRef<LootContainerInteract>("opened"); private static readonly FieldRef<ShrineBoss, bool> bossShrineStarted = SafeRef<ShrineBoss>("started"); private static readonly FieldRef<Boat, bool> gemsDiscovered = SafeRef<Boat>("gemsDiscovered"); private static readonly string[] WoodItems = new string[5] { "Wood", "Birch Wood", "Fir Wood", "Oak Wood", "Dark Oak Wood" }; private static readonly string[] BuiltWords = new string[16] { "anvil", "workbench", "work bench", "fletching", "furnace", "cauldron", "chest", "table", "bed", "door", "wall", "floor", "roof", "stairs", "torch", "fence" }; private readonly Queue<GameObject> pendingObjects = new Queue<GameObject>(); private static readonly float[] FindScanTimes = new float[5] { 0f, 8f, 25f, 60f, 115f }; private int findScanIndex; private int refreshCursor; private float UiScale => Mathf.Clamp((float)Screen.height / 1080f, 0.85f, 2.5f); public static ValheimLikeMapsPlugin Instance { get; private set; } internal static bool BlockGameKeys { get { ValheimLikeMapsPlugin instance = Instance; if ((Object)(object)instance == (Object)null) { return false; } if (!instance.popupOpen) { return Time.frameCount <= instance.popupClosedFrame + 1; } return true; } } private void CreateCustomUi(CustomMarker m) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Clamp(m.color, 0, Icons.CustomColors.Length - 1); m.ui = markers.Create(Icons.Get(Shape.Stickman), Icons.CustomColors[num], cfgShowNames.Value ? m.name : "", 1.1f); } private void RebuildCustomUi(CustomMarker m) { markers.Remove(m.ui); m.ui = null; } internal void RebuildAllCustomUi() { foreach (CustomMarker customMarker in customMarkers) { RebuildCustomUi(customMarker); } } private void OpenPopup(CustomMarker editing, Vector3 world) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) popupOpen = true; popupEditing = editing; popupWorld = editing?.pos ?? world; popupName = ((editing != null) ? editing.name : ""); popupColor = editing?.color ?? 0; Vector2 val = Vector2.op_Implicit(Input.mousePosition); float uiScale = UiScale; popupGuiPos = new Vector2(val.x / uiScale, ((float)Screen.height - val.y) / uiScale); focusName = true; } internal void ClosePopup() { if (popupOpen) { popupOpen = false; popupEditing = null; popupClosedFrame = Time.frameCount; GUIUtility.keyboardControl = 0; } } private void SavePopup() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) string name = (popupName ?? "").Replace('\t', ' ').Replace('\n', ' ').Replace('\r', ' ') .Trim(); if (popupEditing != null) { popupEditing.name = name; popupEditing.color = popupColor; RebuildCustomUi(popupEditing); } else { customMarkers.Add(new CustomMarker { pos = popupWorld, name = name, color = popupColor }); } saveDirty = true; ClosePopup(); } private void DeleteCustom(CustomMarker m) { markers.Remove(m.ui); m.ui = null; customMarkers.Remove(m); if (hoveredCustom == m) { hoveredCustom = null; } saveDirty = true; } private void HandleMapMouse() { //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) //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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_022c: 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_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) hovered = null; hoveredCustom = null; if (popupOpen || IsPointerOverUi()) { return; } Vector2 val = Vector2.op_Implicit(Input.mousePosition); if (!markers.ScreenToWorld(val, out var world)) { return; } float num = markers.PixelsPerMeter(); float num2 = float.MaxValue; foreach (CustomMarker customMarker in customMarkers) { if (customMarker.ui != null && !((Object)(object)customMarker.ui.go == (Object)null) && customMarker.ui.go.activeSelf && !(Flat(customMarker.pos - world) * num > 200f) && markers.HitTest(customMarker.ui, val, out var d) && d < num2) { num2 = d; hoveredCustom = customMarker; } } if (hoveredCustom == null) { foreach (Tracked item in shownTracked) { if (item.ui != null && !(Flat(item.pos - world) * num > 200f) && markers.HitTest(item.ui, val, out var d2) && d2 < num2) { num2 = d2; hovered = item; } } } if (Input.GetMouseButtonDown(0)) { mouseDownPos = val; } if (Input.GetMouseButtonUp(0)) { Vector2 val2 = val - mouseDownPos; if (((Vector2)(ref val2)).magnitude < 6f) { if (hoveredCustom != null) { OpenPopup(hoveredCustom, hoveredCustom.pos); lastClickTime = -10f; } else { if (Time.unscaledTime - lastClickTime < 0.4f) { val2 = val - lastClickPos; if (((Vector2)(ref val2)).magnitude < 12f) { OpenPopup(null, world); lastClickTime = -10f; goto IL_0232; } } lastClickTime = Time.unscaledTime; lastClickPos = val; } } } goto IL_0232; IL_0232: if (!Input.GetMouseButtonDown(1)) { return; } if (hoveredCustom != null) { DeleteCustom(hoveredCustom); } else if (hovered != null) { dismissed.Add(hovered.key); if (hovered.ui != null) { markers.SetShown(hovered.ui, show: false, hovered.pos); } shownTracked.Remove(hovered); hovered = null; saveDirty = true; } } private static float Flat(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) Vector2 val = new Vector2(v.x, v.z); return ((Vector2)(ref val)).magnitude; } internal bool IsPointerOverUi() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) if (!sessionActive || (Object)(object)sessionMap == (Object)null || !sessionMap.active) { return false; } Vector2 val = Vector2.op_Implicit(Input.mousePosition); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(val.x, (float)Screen.height - val.y); if (!((Rect)(ref panelScreenRect)).Contains(val2)) { if (popupOpen) { return ((Rect)(ref popupScreenRect)).Contains(val2); } return false; } return true; } private static Texture2D Solid(Color c) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_001f: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false); val.SetPixel(0, 0, c); val.Apply(); Object.DontDestroyOnLoad((Object)val); return val; } private void EnsureStyles() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_00cd: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown //IL_0156: Expected O, but got Unknown //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_01bf: 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_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Expected O, but got Unknown //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Expected O, but got Unknown //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Expected O, but got Unknown //IL_026f: Expected O, but got Unknown //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Expected O, but got Unknown //IL_02be: Expected O, but got Unknown //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Expected O, but got Unknown if (panelStyle == null || !((Object)(object)panelBg != (Object)null)) { panelBg = Solid(new Color(0.07f, 0.08f, 0.1f, 0.9f)); tipBg = Solid(new Color(0.05f, 0.05f, 0.07f, 0.92f)); btnBg = Solid(new Color(1f, 1f, 1f, 0.08f)); btnOnBg = Solid(new Color(0.35f, 0.65f, 1f, 0.45f)); panelStyle = new GUIStyle(GUI.skin.box) { padding = new RectOffset(10, 10, 8, 8) }; panelStyle.normal.background = panelBg; headerStyle = new GUIStyle(GUI.skin.label) { fontSize = 15, fontStyle = (FontStyle)1, richText = true }; headerStyle.normal.textColor = Color.white; groupStyle = new GUIStyle(GUI.skin.label) { fontSize = 12, fontStyle = (FontStyle)1, margin = new RectOffset(0, 0, 6, 0) }; groupStyle.normal.textColor = new Color(0.55f, 0.78f, 1f); rowStyle = new GUIStyle(GUI.skin.label) { fontSize = 13, richText = true, alignment = (TextAnchor)3 }; rowStyle.normal.textColor = new Color(0.92f, 0.93f, 0.95f); smallStyle = new GUIStyle(GUI.skin.label) { fontSize = 11, richText = true, wordWrap = true }; smallStyle.normal.textColor = new Color(0.68f, 0.7f, 0.75f); buttonStyle = new GUIStyle(GUI.skin.button) { fontSize = 12 }; tipStyle = new GUIStyle(GUI.skin.box) { fontSize = 13, richText = true, alignment = (TextAnchor)3, padding = new RectOffset(8, 8, 4, 4) }; tipStyle.normal.background = tipBg; tipStyle.normal.textColor = Color.white; iconButtonStyle = new GUIStyle(GUI.skin.button) { padding = new RectOffset(3, 3, 3, 3) }; iconButtonStyle.normal.background = btnBg; iconButtonOnStyle = new GUIStyle(iconButtonStyle); iconButtonOnStyle.normal.background = btnOnBg; iconButtonOnStyle.hover.background = btnOnBg; } } private void OnGUI() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_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_0046: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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) if (!sessionActive || (Object)(object)sessionMap == (Object)null || !sessionMap.active) { panelScreenRect = (popupScreenRect = Rect.zero); return; } try { EnsureStyles(); float uiScale = UiScale; Matrix4x4 matrix = GUI.matrix; GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(uiScale, uiScale, 1f)); DrawPanel(uiScale); if (!popupOpen) { DrawTooltip(uiScale); } if (popupOpen) { DrawPopup(uiScale); } else { popupScreenRect = Rect.zero; } GUI.matrix = matrix; } catch (Exception e) { LogOnce("gui", e); } } private static Rect ToScreen(Rect r, float s) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) return new Rect(((Rect)(ref r)).x * s, ((Rect)(ref r)).y * s, ((Rect)(ref r)).width * s, ((Rect)(ref r)).height * s); } private void DrawIcon(Rect r, Icon icon, Color color) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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) if (icon != null && !((Object)(object)icon.tex == (Object)null)) { Color color2 = GUI.color; GUI.color = color; GUI.DrawTextureWithTexCoords(r, icon.tex, icon.uv); GUI.color = color2; } } private List<Category> CategoriesIn(string group) { return (from c in categories.Values where c.@group == @group orderby c.dynamic ? 1 : 0, (!c.dynamic) ? c.order : c.sortKey, c.label select c).ToList(); } private void DrawPanel(float s) { //IL_003d: 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_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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) float num = (float)Screen.width / s; float num2 = (float)Screen.height / s; if (!cfgPanelOpen.Value) { Rect val = default(Rect); ((Rect)(ref val))..ctor(num - 132f, 12f, 120f, 30f); panelScreenRect = ToScreen(val, s); if (GUI.Button(val, "Map filters ▾", buttonStyle)) { cfgPanelOpen.Value = true; } return; } List<KeyValuePair<string, List<Category>>> list = new List<KeyValuePair<string, List<Category>>>(); float num3 = 86f; string[] groupOrder = GroupOrder; foreach (string text in groupOrder) { List<Category> list2 = CategoriesIn(text); if (list2.Count != 0) { list.Add(new KeyValuePair<string, List<Category>>(text, list2)); num3 += 26f + (float)list2.Count * 22f; } } num3 += 30f + (cfgOptionsOpen.Value ? 105f : 0f) + 64f; float num4 = num2 - 24f; Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(num - 250f - 12f, 12f, 250f, Mathf.Min(num3, num4)); panelScreenRect = ToScreen(val2, s); GUI.Box(val2, GUIContent.none, panelStyle); GUILayout.BeginArea(new Rect(((Rect)(ref val2)).x + 10f, ((Rect)(ref val2)).y + 8f, ((Rect)(ref val2)).width - 20f, ((Rect)(ref val2)).height - 16f)); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Map filters", headerStyle, Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); if (GUILayout.Button("▴", buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(26f) })) { cfgPanelOpen.Value = false; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("All", buttonStyle, Array.Empty<GUILayoutOption>())) { SetAll(on: true); } if (GUILayout.Button("None", buttonStyle, Array.Empty<GUILayoutOption>())) { SetAll(on: false); } if (GUILayout.Button("Reset", buttonStyle, Array.Empty<GUILayoutOption>())) { ResetFilters(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); for (int j = 0; j < cfgPresets.Length; j++) { GUI.enabled = !string.IsNullOrEmpty(cfgPresets[j].Value); if (GUILayout.Button($"Preset {j + 1}", buttonStyle, Array.Empty<GUILayoutOption>())) { LoadPreset(j); } GUI.enabled = true; if (GUILayout.Button("Save", buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(44f) })) { SavePreset(j); } if (j < cfgPresets.Length - 1) { GUILayout.Space(6f); } } GUILayout.EndHorizontal(); panelScroll = GUILayout.BeginScrollView(panelScroll, false, false, Array.Empty<GUILayoutOption>()); foreach (KeyValuePair<string, List<Category>> item in list) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(item.Key.ToUpperInvariant(), groupStyle, Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); bool flag = item.Value.All((Category c) => c.enabled.Value); if (GUILayout.Button(flag ? "hide" : "show", smallStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(36f) })) { foreach (Category item2 in item.Value) { item2.enabled.Value = !flag; } } GUILayout.EndHorizontal(); foreach (Category item3 in item.Value) { DrawCategoryRow(item3); } } GUILayout.Space(6f); if (GUILayout.Button(cfgOptionsOpen.Value ? "Options ▴" : "Options ▾", buttonStyle, Array.Empty<GUILayoutOption>())) { cfgOptionsOpen.Value = !cfgOptionsOpen.Value; } if (cfgOptionsOpen.Value) { DrawOptions(); } GUILayout.Space(6f); GUILayout.Label("<b>Double-click</b> the map to add a marker.\n<b>Click</b> your marker to rename or recolour it.\n<b>Right-click</b> a marker to remove it.", smallStyle, Array.Empty<GUILayoutOption>()); GUILayout.EndScrollView(); GUILayout.EndArea(); } private void DrawCategoryRow(Category c) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(20f) }); bool flag = GUILayout.Toggle(c.enabled.Value, GUIContent.none, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(18f) }); Rect rect = GUILayoutUtility.GetRect(18f, 18f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(18f), GUILayout.Height(18f) }); DrawIcon(rect, c.icon, c.enabled.Value ? c.color : (c.color * new Color(1f, 1f, 1f, 0.35f))); GUILayout.Space(4f); string text = ((c.found > 0) ? $" <color=#8a93a3>{c.found}</color>" : ""); if (GUILayout.Button((c.enabled.Value ? c.label : ("<color=#7c8290>" + c.label + "</color>")) + text, rowStyle, Array.Empty<GUILayoutOption>())) { flag = !flag; } GUILayout.EndHorizontal(); if (flag != c.enabled.Value) { c.enabled.Value = flag; } } private void DrawOptions() { GUILayout.Space(4f); bool flag = GUILayout.Toggle(cfgShowNames.Value, " Show names of my markers", Array.Empty<GUILayoutOption>()); if (flag != cfgShowNames.Value) { cfgShowNames.Value = flag; RebuildAllCustomUi(); } GUILayout.Label($"Marker size: {cfgIconSize.Value:0.0}x", smallStyle, Array.Empty<GUILayoutOption>()); float num = GUILayout.HorizontalSlider(cfgIconSize.Value, 0.5f, 3f, Array.Empty<GUILayoutOption>()); if (Mathf.Abs(num - cfgIconSize.Value) > 0.01f) { cfgIconSize.Value = Mathf.Round(num * 10f) / 10f; } GUILayout.Space(4f); GUI.enabled = dismissed.Count > 0; if (GUILayout.Button($"Bring back removed markers ({dismissed.Count})", buttonStyle, Array.Empty<GUILayoutOption>())) { dismissed.Clear(); saveDirty = true; } GUI.enabled = true; } private void SetAll(bool on) { foreach (Category value in categories.Values) { value.enabled.Value = on; } } private void SavePreset(int i) { List<string> list = new List<string>(); foreach (Category value in categories.Values) { if (value.enabled.Value) { list.Add(value.id); } } list.Sort(StringComparer.Ordinal); cfgPresets[i].Value = ((list.Count > 0) ? string.Join('|'.ToString(), list) : "-"); } private void LoadPreset(int i) { string value = cfgPresets[i].Value; if (string.IsNullOrEmpty(value)) { return; } HashSet<string> hashSet = new HashSet<string>(value.Split(new char[1] { '|' })); foreach (Category value2 in categories.Values) { value2.enabled.Value = hashSet.Contains(value2.id); } } private void ResetFilters() { foreach (Category value in categories.Values) { value.enabled.Value = (bool)((ConfigEntryBase)value.enabled).DefaultValue; } } private void DrawTooltip(float s) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) string text = null; Vector3 val = Vector3.zero; if (hoveredCustom != null) { text = (string.IsNullOrEmpty(hoveredCustom.name) ? "<i>My marker</i>" : hoveredCustom.name); val = hoveredCustom.pos; } else if (hovered != null) { text = hovered.label ?? hovered.cat.label; val = hovered.pos; } if (text != null) { if ((Object)(object)PlayerMovement.Instance != (Object)null) { text += $" <color=#8a93a3>{Flat(((Component)PlayerMovement.Instance).transform.position - val):0} m</color>"; } Vector2 val2 = Vector2.op_Implicit(Input.mousePosition); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(val2.x / s + 16f, ((float)Screen.height - val2.y) / s + 10f); Vector2 val4 = tipStyle.CalcSize(new GUIContent(text)); float num = (float)Screen.width / s; if (val3.x + val4.x > num) { val3.x = num - val4.x - 4f; } GUI.Box(new Rect(val3.x, val3.y, val4.x, val4.y), text, tipStyle); } } private void DrawPopup(float s) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Invalid comparison between Unknown and I4 //IL_00e6: 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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Invalid comparison between Unknown and I4 //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Invalid comparison between Unknown and I4 //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Invalid comparison between Unknown and I4 //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Invalid comparison between Unknown and I4 //IL_024b: 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_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) float num = (float)Screen.width / s; float num2 = (float)Screen.height / s; Rect val = default(Rect); ((Rect)(ref val))..ctor(popupGuiPos.x + 14f, popupGuiPos.y - 24f, 300f, 150f); ((Rect)(ref val)).x = Mathf.Clamp(((Rect)(ref val)).x, 4f, num - 300f - 4f); ((Rect)(ref val)).y = Mathf.Clamp(((Rect)(ref val)).y, 4f, num2 - 150f - 4f); popupScreenRect = ToScreen(val, s); Event current = Event.current; if ((int)current.type == 4) { if ((int)current.keyCode == 13 || (int)current.keyCode == 271) { SavePopup(); current.Use(); } else if ((int)current.keyCode == 27) { ClosePopup(); current.Use(); } } GUI.Box(val, GUIContent.none, panelStyle); GUILayout.BeginArea(new Rect(((Rect)(ref val)).x + 10f, ((Rect)(ref val)).y + 8f, ((Rect)(ref val)).width - 20f, ((Rect)(ref val)).height - 16f)); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); Rect rect = GUILayoutUtility.GetRect(24f, 24f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(24f), GUILayout.Height(24f) }); DrawIcon(rect, Icons.Get(Shape.Stickman), Icons.CustomColors[popupColor]); GUILayout.Space(6f); GUILayout.Label((popupEditing != null) ? "Edit marker" : "New marker", headerStyle, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); GUI.SetNextControlName("ValheimLikeMapsMarkerName"); popupName = GUILayout.TextField(popupName ?? "", 40, Array.Empty<GUILayoutOption>()); if (focusName && (int)current.type == 7) { GUI.FocusControl("ValheimLikeMapsMarkerName"); focusName = false; } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); for (int i = 0; i < Icons.CustomColors.Length; i++) { Rect rect2 = GUILayoutUtility.GetRect(30f, 22f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(30f), GUILayout.Height(22f) }); if (GUI.Button(rect2, GUIContent.none, (i == popupColor) ? iconButtonOnStyle : iconButtonStyle)) { popupColor = i; } Color color = GUI.color; GUI.color = Icons.CustomColors[i]; GUI.DrawTexture(new Rect(((Rect)(ref rect2)).x + 5f, ((Rect)(ref rect2)).y + 5f, ((Rect)(ref rect2)).width - 10f, ((Rect)(ref rect2)).height - 10f), (Texture)(object)Icons.White); GUI.color = color; } GUILayout.EndHorizontal(); GUILayout.Space(4f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Save", buttonStyle, Array.Empty<GUILayoutOption>())) { SavePopup(); } if (popupEditing != null && GUILayout.Button("Delete", buttonStyle, Array.Empty<GUILayoutOption>())) { CustomMarker m = popupEditing; ClosePopup(); DeleteCustom(m); } if (GUILayout.Button("Cancel", buttonStyle, Array.Empty<GUILayoutOption>())) { ClosePopup(); } GUILayout.EndHorizontal(); GUILayout.EndArea(); } internal static void LogInfo(string msg) { ValheimLikeMapsPlugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)msg); } } private void Awake() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown Instance = this; cfgRemember = ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "RememberPerSeed", true, "Remember the explored area, your markers and removed markers for each world seed."); cfgIconSize = ((BaseUnityPlugin)this).Config.Bind<float>("Map", "IconSize", 1f, new ConfigDescription("Size of the map markers.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 3f), Array.Empty<object>())); cfgShowNames = ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "ShowMarkerNames", true, "Show the names of your own markers on the map."); cfgPanelOpen = ((BaseUnityPlugin)this).Config.Bind<bool>("Menu", "FilterPanelOpen", true, "Whether the filter panel is expanded."); cfgOptionsOpen = ((BaseUnityPlugin)this).Config.Bind<bool>("Menu", "OptionsOpen", false, "Whether the options section of the filter panel is expanded."); cfgPresets = new ConfigEntry<string>[2]; for (int i = 0; i < cfgPresets.Length; i++) { cfgPresets[i] = ((BaseUnityPlugin)this).Config.Bind<string>("Presets", $"Preset{i + 1}", "", $"Filter preset {i + 1}: the marker types that are shown. Saved from the map's filter menu. Empty = not saved yet."); } harmony = new Harmony("pramodexe.valheimlikemaps"); harmony.PatchAll(Assembly.GetExecutingAssembly()); ((BaseUnityPlugin)this).Logger.LogInfo((object)"ValheimLikeMaps 1.0.0 loaded."); } private void OnDestroy() { EndSession(); Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } private void OnApplicationQuit() { EndSession(); } private void Update() { try { Tick(); } catch (Exception e) { LogOnce("tick", e); } } internal void LogOnce(string where, Exception e) { string item = where + ":" + e.GetType().Name + ":" + e.Message; if (loggedErrors.Add(item)) { ((BaseUnityPlugin)this).Logger.LogError((object)$"[{where}] {e}"); } } private void Tick() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Invalid comparison between Unknown and I4 try { biggerMapLobby.Tick(); } catch (Exception e) { LogOnce("lobby", e); } Map instance = Map.Instance; if (sessionActive && (instance != sessionMap || (Object)(object)instance == (Object)null)) { EndSession(); } if ((Object)(object)instance == (Object)null) { return; } if (!sessionActive) { if ((Object)(object)MapGenerator.Instance == (Object)null || MapGenerator.Instance.heightMap == null || (Object)(object)PlayerMovement.Instance == (Object)null || (int)GameManager.state != 1 || (Object)(object)instance.mapRender == (Object)null || (Object)(object)instance.markerParent == (Object)null) { return; } StartSession(instance); } UpdateSession(); } private void StartSession(Map map) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) sessionMap = map; sessionSeed = GameManager.GetSeed(); sessionStartTime = Time.time; revealTimer = (resourceScanTimer = (mobScanTimer = 0f)); saveTimer = 60f; lastRevealPos = new Vector3(float.MaxValue, 0f, 0f); Icons.Init(); InitCategories(); fog = new FogLayer(); fog.Build(map); markers = new MarkerLayer(); markers.Build(map); tracked.Clear(); trackedIds.Clear(); ResetScanState(); resourceIdsSeen.Clear(); chestIdsSeen.Clear(); dismissed.Clear(); customMarkers.Clear(); if (cfgRemember.Value) { WorldSave.Load(sessionSeed, fog, dismissed, customMarkers); } sessionActive = true; ScanWorld(); ScanMobs(); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Map ready for seed {sessionSeed}, island size {MapGenerator.mapChunkSize}: {pendingObjects.Count} things to look at."); try { ChatBox instance = ChatBox.Instance; if (instance != null) { instance.AppendMessage(-1, $"<color=#8fd3ff>ValheimLikeMaps</color> ready. Open the map with \"{InputManager.map}\". Double-click to add a marker.", ""); } } catch { } } private void EndSession() { if (!sessionActive) { return; } sessionActive = false; ClosePopup(); try { if (cfgRemember.Value && fog != null) { WorldSave.Save(sessionSeed, fog, dismissed, customMarkers); } } catch (Exception e) { LogOnce("save", e); } markers?.Destroy(); fog?.Destroy(); markers = null; fog = null; tracked.Clear(); trackedIds.Clear(); customMarkers.Clear(); sessionMap = null; hovered = null; hoveredCustom = null; } private void UpdateSession() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) float unscaledDeltaTime = Time.unscaledDeltaTime; revealTimer -= unscaledDeltaTime; if (revealTimer <= 0f && (Object)(object)PlayerMovement.Instance != (Object)null) { revealTimer = 0.2f; Vector3 position = ((Component)PlayerMovement.Instance).transform.position; Vector3 val = position - lastRevealPos; if (((Vector3)(ref val)).sqrMagnitude > 4f) { lastRevealPos = position; if (fog.Reveal(position, 110f)) { saveDirty = true; } } } resourceScanTimer -= unscaledDeltaTime; if (resourceScanTimer <= 0f) { resourceScanTimer = ((Time.time - sessionStartTime < 90f) ? 3f : 15f); ScanWorld(); } ProcessPending(3000); mobScanTimer -= unscaledDeltaTime; if (mobScanTimer <= 0f) { mobScanTimer = 1f; ScanMobs(); } if (sessionMap.active) { RefreshStep(8000); markers.UpdateScale(sessionMap, cfgIconSize.Value); fog.ApplyIfDirty(); HandleMapMouse(); } else { if (popupOpen) { ClosePopup(); } hovered = null; hoveredCustom = null; } saveTimer -= unscaledDeltaTime; if (!(saveTimer <= 0f)) { return; } saveTimer = 60f; if (saveDirty && cfgRemember.Value) { saveDirty = false; try { WorldSave.Save(sessionSeed, fog, dismissed, customMarkers); } catch (Exception e) { LogOnce("save", e); } } } internal void OnMapToggled(bool open) { if (!open) { ClosePopup(); } } private static int Rank(string name, string[] order, bool trees) { string text = name.ToLowerInvariant().Trim(); if (trees && text == "wood") { return 0; } int num = order.Length; int num2 = 0; for (int i = 0; i < order.Length; i++) { if (text.Contains(order[i]) && order[i].Length > num2) { num = i; num2 = order[i].Length; } } if (!trees) { return num; } return num + 1; } private static FieldRef<T, bool> SafeRef<T>(string field) { try { return AccessTools.FieldRefAccess<T, bool>(field); } catch { return null; } } private Category Cat(string id, string label, string group, Icon icon, Color color, bool defaultOn, float scale = 1f, bool ignoresClouds = false, bool dynamic = false) { //IL_0051: Unknown result type (might be due to invalid IL or missing referen