Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of AutoWaypoints v1.0.4
AutoWaypoints.dll
Decompiled 9 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Managers; using Microsoft.CodeAnalysis; using Splatform; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AutoWaypoints { [BepInPlugin("com.michal.valheim.autowaypoints", "Auto Waypoints", "1.0.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class AutoWaypointsPlugin : BaseUnityPlugin { [Serializable] private class CharacterSettingsFile { public List<string> Keys = new List<string>(); public List<bool> Values = new List<bool>(); } [HarmonyPatch(typeof(Minimap), "UpdateLocationPins")] private static class Minimap_UpdateLocationPins_Patch { private static void Postfix() { Instance?.RefreshLocationIconNames(); } } [HarmonyPatch(typeof(Minimap), "UpdatePins")] private static class Minimap_UpdatePins_LocationPatch { private static void Postfix(List<PinData> ___m_pins) { Instance?.ApplyLocationIcons(___m_pins); } } [HarmonyPatch(typeof(LocationProxy), "Awake")] private static class LocationProxy_Awake_Patch { private static void Postfix(LocationProxy __instance) { LoadedLocationProxies.Add(__instance); } } [HarmonyPatch(typeof(LocationProxy), "OnDestroy")] private static class LocationProxy_OnDestroy_Patch { private static void Postfix(LocationProxy __instance) { LoadedLocationProxies.Remove(__instance); } } private class RuinCluster { public Vector3 Center; public float MinY = float.PositiveInfinity; public float MaxY = float.NegativeInfinity; public int StoneCount; public int WoodCount; public readonly HashSet<GameObject> Pieces = new HashSet<GameObject>(); public PinData Pin; public ResourceCategory Category; } private class ResourceCategory { public string Key; public string DisplayName; public HashSet<string> ExactNames; public string Prefix; public HashSet<string> OreDropItemNames; public HashSet<string> OreNameTokens; public PinType PinType; public ConfigEntry<bool> Enabled; public ConfigEntry<bool> ShowName; public string MenuGroup; public bool? PlayerBuilt; public string IconPiecePrefab; public string[] LegacyPinNames; public HashSet<string> LocationPrefabs; public Dictionary<string, Sprite> VariantIcons; public HashSet<string> OrePrefabNames; public string IconItemNameOverride; public string[] IconItemNameCandidates; public string IconWorldPrefab; public bool RemoveOnPicked = true; public float? MaxVerticalDeltaOverride; public Sprite CustomIcon; public bool Matches(string name) { if (ExactNames != null && ExactNames.Contains(name)) { return true; } if (Prefix != null && name.StartsWith(Prefix, StringComparison.Ordinal)) { return true; } return false; } } private class TrackedResource { public GameObject Obj; public PinData Pin; public Pickable PickableComp; public ResourceCategory Category; public bool ReplacedWhenDamaged; } [HarmonyPatch(typeof(Minimap), "Awake")] private static class Minimap_Awake_Patch { private static void Postfix(Minimap __instance) { Instance?.CreateSettingsButton(__instance); } } [HarmonyPatch(typeof(Minimap), "Update")] private static class Minimap_Update_EscapePatch { private static bool Prefix() { if ((Object)(object)Instance == (Object)null || (Object)(object)Instance._settingsPanel == (Object)null || !Instance._settingsPanel.activeSelf) { return true; } if (!Input.GetKeyDown((KeyCode)27)) { return true; } Instance.ToggleSettingsMenu(); return false; } } [Serializable] private class PortalRegistryFile { public List<Vector3> Positions = new List<Vector3>(); } [HarmonyPatch(typeof(Minimap), "CreateMapNamePin")] private static class Minimap_CreateMapNamePin_LabelPatch { private static void Postfix(PinData namePin) { Instance?.ApplyLabelVisibility(namePin); } } private enum GoneReason { None, ResourceGone, PinMissing } private class HiddenPinRecord { public string CategoryKey; public float X; public float Y; public float Z; public string DisplayName; public int PinType; public bool Save; } [Serializable] private class HiddenPinsFile { public List<string> CategoryKeys = new List<string>(); public List<Vector3> Positions = new List<Vector3>(); public List<string> DisplayNames = new List<string>(); public List<int> PinTypes = new List<int>(); public List<bool> Saves = new List<bool>(); public bool IsConsistent { get { if (CategoryKeys != null && Positions != null && DisplayNames != null && PinTypes != null && Saves != null && Positions.Count == CategoryKeys.Count && DisplayNames.Count == CategoryKeys.Count && PinTypes.Count == CategoryKeys.Count) { return Saves.Count == CategoryKeys.Count; } return false; } } } [HarmonyPatch(typeof(Minimap), "UpdatePins")] private static class Minimap_UpdatePins_NativeBossPatch { private static void Postfix(List<PinData> ___m_pins) { Instance?.ApplyNativeBossPinVisibility(___m_pins); } } [Serializable] private class DiscoveredFile { public List<string> Keys = new List<string>(); } [HarmonyPatch(typeof(Minimap), "AddPin")] private static class Minimap_AddPin_DiscoveryPatch { private static void Postfix(Minimap __instance, PinData __result) { if (!((Object)(object)Instance == (Object)null) && __result != null) { object value = MapHasGeneratedField.GetValue(__instance); bool flag = default(bool); int num; if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } bool flag2 = (byte)((uint)num & (flag ? 1u : 0u)) != 0; ResourceCategory category = Instance.CategoryForPin(__result); Instance.MarkDiscovered(category, flag2); if (flag2) { Instance.HideIfCategoryHidden(category); } if (flag2 && IsNativeBossPin(__result, category)) { Instance.ApplyNativeBossIcon(__result); } } } } private readonly Dictionary<string, ConfigEntry<bool>> _characterEntries = new Dictionary<string, ConfigEntry<bool>>(); private readonly List<(Toggle Toggle, ConfigEntry<bool> Config)> _menuToggles = new List<(Toggle, ConfigEntry<bool>)>(); private string _characterSettingsPath; private bool _applyingCharacterSettings; private bool _characterSettingsDirty; private ConfigEntry<bool> _replaceLocationIcons; private const float LocationPinMatchRadius = 30f; private static readonly FieldInfo LocationPinsField = AccessTools.Field(typeof(Minimap), "m_locationPins"); private readonly Dictionary<Vector3, string> _locationIconNames = new Dictionary<Vector3, string>(); private readonly Dictionary<ResourceCategory, Sprite> _modLocationIcons = new Dictionary<ResourceCategory, Sprite>(); private readonly Dictionary<ResourceCategory, Sprite> _gameLocationIcons = new Dictionary<ResourceCategory, Sprite>(); private Minimap _gameLocationIconsSource; private const float LocationDiscoverRadius = 40f; private static readonly HashSet<LocationProxy> LoadedLocationProxies = new HashSet<LocationProxy>(); public const string PluginGUID = "com.michal.valheim.autowaypoints"; public const string PluginName = "Auto Waypoints"; public const string PluginVersion = "1.0.4"; private const float ScanInterval = 1.5f; private const float MaxVerticalDelta = 3f; private const float MinPinSpacing = 8f; private static readonly FieldInfo PinsField = AccessTools.Field(typeof(Minimap), "m_pins"); private static readonly FieldInfo LocationsByHashField = AccessTools.Field(typeof(ZoneSystem), "m_locationsByHash"); private static readonly FieldInfo MapHasGeneratedField = AccessTools.Field(typeof(Minimap), "m_hasGenerated"); private static readonly (string LocationName, string DisplayName, PinType PinType, string IconKey, string TrophyItemName)[] DungeonLocationDefs = new(string, string, PinType, string, string)[42] { ("BearCave", "Bear Cave", (PinType)2, null, "TrophyBjorn"), ("TrollCave", "Troll Cave", (PinType)2, null, "TrophyFrostTroll"), ("TrollCave01", "Troll Cave", (PinType)2, null, "TrophyFrostTroll"), ("TrollCave02", "Troll Cave", (PinType)2, null, "TrophyFrostTroll"), ("Crypt1", "Burial Chambers", (PinType)6, "DungeonCrypt", null), ("Crypt2", "Burial Chambers", (PinType)6, "DungeonCrypt", null), ("Crypt3", "Burial Chambers", (PinType)6, "DungeonCrypt", null), ("Crypt4", "Burial Chambers", (PinType)6, "DungeonCrypt", null), ("SunkenCrypt1", "Sunken Crypt", (PinType)6, "DungeonCrypt", null), ("SunkenCrypt2", "Sunken Crypt", (PinType)6, "DungeonCrypt", null), ("SunkenCrypt3", "Sunken Crypt", (PinType)6, "DungeonCrypt", null), ("SunkenCrypt4", "Sunken Crypt", (PinType)6, "DungeonCrypt", null), ("MountainCave01", "Frost Cave", (PinType)2, "DungeonFrostCave", null), ("MountainCave02", "Frost Cave", (PinType)2, "DungeonFrostCave", null), ("MountainCave03", "Frost Cave", (PinType)2, "DungeonFrostCave", null), ("MountainCave04", "Frost Cave", (PinType)2, "DungeonFrostCave", null), ("GoblinCamp1", "Fuling Camp", (PinType)3, null, "TrophyGoblin"), ("GoblinCamp2", "Fuling Camp", (PinType)3, null, "TrophyGoblin"), ("GoblinCamp3", "Fuling Camp", (PinType)3, null, "TrophyGoblin"), ("GoblinCamp4", "Fuling Camp", (PinType)3, null, "TrophyGoblin"), ("GoblinCamp2_1", "Fuling Camp", (PinType)3, null, "TrophyGoblin"), ("FireHole", "Surtling", (PinType)3, null, "TrophySurtling"), ("Mistlands_DvergrTownEntrance1", "Infested Mine", (PinType)3, "DungeonInfestedMine", null), ("Mistlands_DvergrTownEntrance2", "Infested Mine", (PinType)3, "DungeonInfestedMine", null), ("MorgenHole1", "Winding Tunnels", (PinType)2, "DungeonWindingTunnels", null), ("MorgenHole2", "Winding Tunnels", (PinType)2, "DungeonWindingTunnels", null), ("MorgenHole3", "Winding Tunnels", (PinType)2, "DungeonWindingTunnels", null), ("MorkBorg", "Morkhalla", (PinType)2, "DungeonMorkhalla", null), ("Hildir_crypt", "Smouldering Tomb", (PinType)6, "DungeonSmoulderingTomb", null), ("Hildir_cave", "Howling Cavern", (PinType)2, "DungeonHowlingCavern", null), ("Hildir_plainsfortress", "Sealed Tower", (PinType)3, "DungeonSealedTower", null), ("Eikthyrnir", "Eikthyr's Altar", (PinType)9, null, "TrophyEikthyr"), ("GDKing", "Elder's Altar", (PinType)9, null, "TrophyTheElder"), ("Bonemass", "Bonemass' Altar", (PinType)9, null, "TrophyBonemass"), ("Dragonqueen", "Moder's Altar", (PinType)9, null, "TrophyDragonQueen"), ("GoblinKing", "Yagluth's Altar", (PinType)9, null, "TrophyGoblinKing"), ("Mistlands_DvergrBossEntrance1", "Infested Citadel", (PinType)9, "DungeonInfestedCitadel", null), ("FaderLocation", "Fader's Altar", (PinType)9, "DungeonFadersAltar", null), ("DN_Bossroom", "Deep North Boss", (PinType)9, "DungeonDeepNorthBoss", null), ("Vendor_BlackForest", "Trader", (PinType)3, null, "Coins"), ("Hildir_camp", "Hildir's Camp", (PinType)3, "DungeonHildirsCamp", null), ("BogWitch_Camp", "Bog Witch Camp", (PinType)3, "DungeonBogWitchCamp", null) }; private static readonly HashSet<string> TraderLocations = new HashSet<string> { "Vendor_BlackForest", "Hildir_camp", "BogWitch_Camp" }; private static readonly Dictionary<string, string> DungeonKeyOverrides = new Dictionary<string, string> { { "Burial Chambers", "DungeonCrypt" } }; private static readonly Dictionary<string, string[]> DungeonLegacyPinNames = new Dictionary<string, string[]> { { "Burial Chambers", new string[1] { "Crypt" } } }; private static readonly Dictionary<int, (string DisplayName, PinType PinType, string IconKey, string TrophyItemName)> DungeonLocationByHash = DungeonLocationDefs.ToDictionary(((string LocationName, string DisplayName, PinType PinType, string IconKey, string TrophyItemName) d) => StringExtensionMethods.GetStableHashCode(d.LocationName), ((string LocationName, string DisplayName, PinType PinType, string IconKey, string TrophyItemName) d) => (DisplayName: d.DisplayName, PinType: d.PinType, IconKey: d.IconKey, TrophyItemName: d.TrophyItemName)); private readonly Dictionary<string, Sprite> _dungeonIcons = new Dictionary<string, Sprite>(); internal static ManualLogSource Log; private ConfigEntry<bool> _showAutoPins; private ConfigEntry<bool> _showPinLabels; private ConfigEntry<bool> _replaceBossAltars; private readonly Dictionary<string, ResourceCategory> _categoryByPinName = new Dictionary<string, ResourceCategory>(); private ConfigEntry<bool> _debugLogNearby; private ConfigEntry<float> _scanRadius; private ConfigEntry<bool> _shipsEnabled; private ConfigEntry<bool> _shipsDockedEnabled; private readonly ResourceCategory _shipLiveCategory = new ResourceCategory { Key = "ShipLive", DisplayName = "Live pin" }; private readonly ResourceCategory _shipDockedCategory = new ResourceCategory { Key = "ShipDocked", DisplayName = "Docked" }; private ConfigEntry<bool> _portalsEnabled; private readonly ResourceCategory _portalCategory = new ResourceCategory { Key = "Portal", DisplayName = "Portal" }; private readonly Dictionary<string, ResourceCategory> _dungeonCategoriesByName = new Dictionary<string, ResourceCategory>(); private ResourceCategory _looseRuinsCategory; private ResourceCategory _looseTowerCategory; private ResourceCategory _looseWoodCategory; private readonly List<ResourceCategory> _categories = new List<ResourceCategory>(); private static readonly HashSet<string> RuinPieceNames = new HashSet<string> { "stone_wall_2x1", "stone_wall_1x1", "stone_floor_2x2", "stone_stair", "wood_floor", "wood_floor_1x1", "wood_stepladder" }; private const float RuinClusterRadius = 20f; private const int RuinClusterMinPieces = 3; private const float TowerHeightSpan = 6f; private readonly List<RuinCluster> _ruinClusters = new List<RuinCluster>(); private float _scanTimer; private bool _globalIconPassDone; private string _session; private const float ShipUpdateInterval = 0.3f; private float _shipUpdateTimer; private readonly Dictionary<Ship, PinData> _shipPins = new Dictionary<Ship, PinData>(); private readonly Dictionary<GameObject, TrackedResource> _tracked = new Dictionary<GameObject, TrackedResource>(); private GameObject _settingsPanel; internal static AutoWaypointsPlugin Instance; private Harmony _harmony; private const string UnnamedPortalPinName = "Portal"; private const string LegacyPortalPrefix = "Portal: "; private const float PortalPinMatchRadius = 1f; private readonly List<Vector3> _portalPinPositions = new List<Vector3>(); private string _portalRegistryWorld; private static readonly (string Key, string DisplayName, string[] Names, PinType PinType)[] StructureDefinitions = new(string, string, string[], PinType)[53] { ("StructRuins", "Ruins", new string[8] { "StoneHouse3", "StoneHouse4", "Ruin1", "Ruin2", "Ruin3", "StoneHouse1_heath", "StoneHouse2_heath", "StoneHouse5_heath" }, (PinType)2), ("StructLogCabin", "Log Cabin", new string[3] { "AbandonedLogCabin02", "AbandonedLogCabin03", "AbandonedLogCabin04" }, (PinType)2), ("StructWoodHouse", "Wood House", new string[13] { "WoodHouse1", "WoodHouse2", "WoodHouse3", "WoodHouse4", "WoodHouse5", "WoodHouse6", "WoodHouse7", "WoodHouse8", "WoodHouse9", "WoodHouse10", "WoodHouse11", "WoodHouse12", "WoodHouse13" }, (PinType)2), ("StructDraugrVillage", "Draugr Village", new string[2] { "WoodVillage1", "WoodVillage2" }, (PinType)2), ("StructAbandonedFarm", "Abandoned Farm", new string[1] { "WoodFarm1" }, (PinType)2), ("StructSwampHut", "Swamp Hut", new string[8] { "SwampHut1", "SwampHut2", "SwampHut3", "SwampHut4", "SwampHut5", "SwampHut1_1", "SwampHut2_1", "SwampHut3_1" }, (PinType)2), ("StructSwampTower", "Stone Tower Ruins", new string[12] { "StoneTowerRuins05_leet", "StoneTowerRuins07", "StoneTowerRuins08_sunk", "StoneTowerRuins10_sunk", "StoneTowerRuins03", "StoneTowerRuins04", "StoneTowerRuins05", "StoneTowerRuins07_sunk", "StoneTowerRuins08", "StoneTowerRuins09", "StoneTowerRuins09_sunk", "StoneTowerRuins10" }, (PinType)2), ("StructHarbour", "Harbour", new string[1] { "Mistlands_Harbour1" }, (PinType)2), ("StructViaduct", "Viaduct", new string[2] { "Mistlands_Viaduct1", "Mistlands_Viaduct2" }, (PinType)2), ("StructShipwreck", "Shipwreck", new string[6] { "ShipWreck01", "ShipWreck02", "ShipWreck03", "ShipWreck04", "ShipWreck01_DN", "ShipWreck02_DN" }, (PinType)2), ("StructStoneCircle", "Stone Circle", new string[6] { "StoneHenge3", "StoneHenge5", "StoneHenge1", "StoneHenge2", "StoneHenge4", "StoneHenge6" }, (PinType)6), ("StructWell", "Well", new string[1] { "MountainWell1" }, (PinType)6), ("StructDolmen", "Dolmen", new string[3] { "Dolmen01", "Dolmen02", "Dolmen03" }, (PinType)6), ("StructRunestone", "Runestone", new string[12] { "Runestone_Greydwarfs", "Runestone_Draugr", "DrakeLorestone", "Runestone_Boars", "Runestone_BlackForest", "Runestone_Mistlands", "Runestone_Meadows", "Runestone_Swamps", "Runestone_Mountains", "Runestone_Plains", "Runestone_Ashlands", "Runestone_DeepNorth" }, (PinType)6), ("StructStatues", "Statues", new string[4] { "Mistlands_Statue1", "Mistlands_Statue2", "Mistlands_StatueGroup1", "Mistlands_RockSpire1" }, (PinType)6), ("StructGiantRemains", "Giant Remains", new string[2] { "Mistlands_Giant1", "Mistlands_Giant2" }, (PinType)3), ("StructGiantArmor", "Giant Armor", new string[7] { "Mistlands_Swords1", "Mistlands_Swords2", "Mistlands_Swords3", "giant_helmet1", "giant_helmet2", "giant_sword1", "giant_sword2" }, (PinType)3), ("StructDvergrTower", "Dvergr Tower", new string[7] { "Mistlands_GuardTower1_ruined_new2", "Mistlands_GuardTower3_new", "Mistlands_GuardTower3_ruined_new", "Mistlands_GuardTower1_new", "Mistlands_GuardTower2_new", "Mistlands_GuardTower1_ruined_new", "Mistlands_Lighthouse1_new" }, (PinType)0), ("StructDvergrExcavation", "Dvergr Excavation", new string[3] { "Mistlands_Excavation1", "Mistlands_Excavation2", "Mistlands_Excavation3" }, (PinType)0), ("StructRoadPost", "Road Post", new string[1] { "Mistlands_RoadPost1" }, (PinType)0), ("StructInfestedTree", "Infested Tree", new string[1] { "InfestedTree01" }, (PinType)1), ("StructSacrificialStones", "Sacrificial Stones", new string[1] { "StartTemple" }, (PinType)6), ("StructCombatRuin", "Combat Ruin", new string[1] { "CombatRuin01" }, (PinType)2), ("StructStoneShip", "Stone Ship", new string[3] { "ShipSetting01", "ShipSetting02", "ShipSetting03" }, (PinType)6), ("StructGreydwarfCamp", "Greydwarf Camp", new string[1] { "Greydwarf_camp1" }, (PinType)3), ("StructBigRockClearing", "Big Rock Clearing", new string[1] { "BigRockClearing" }, (PinType)6), ("StructDraugrGrave", "Draugr Grave", new string[1] { "Grave1" }, (PinType)3), ("StructSwampRuin", "Swamp Ruin", new string[2] { "SwampRuin1", "SwampRuin2" }, (PinType)2), ("StructSwampWell", "Swamp Well", new string[1] { "SwampWell1" }, (PinType)6), ("StructDragonNest", "Dragon Nest", new string[1] { "DrakeNest01" }, (PinType)3), ("StructMountainGrave", "Mountain Grave", new string[1] { "MountainGrave01" }, (PinType)6), ("StructWaymarker", "Waymarker", new string[2] { "Waymarker01", "Waymarker02" }, (PinType)6), ("StructAncientUpgradeStation", "Ancient Upgrade Station", new string[1] { "AncientUpgradeStation" }, (PinType)6), ("StructFulingTower", "Fuling Tower", new string[2] { "StoneTower1", "StoneTower3" }, (PinType)3), ("StructFulingHut", "Fuling Hut", new string[3] { "GoblinHut01", "GoblinHut02", "GoblinHut03" }, (PinType)3), ("StructTarPit", "Tar Pit", new string[6] { "TarPit1", "TarPit2", "TarPit3", "TarPit1_1", "TarPit2_1", "TarPit3_1" }, (PinType)3), ("StructCharredFortress", "Charred Fortress", new string[1] { "CharredFortress" }, (PinType)3), ("StructFortressRuins", "Fortress Ruins", new string[1] { "FortressRuins" }, (PinType)2), ("StructAshlandRuins", "Ashland Ruins", new string[1] { "AshlandRuins" }, (PinType)2), ("StructCharredRuins", "Charred Ruins", new string[4] { "CharredRuins1", "CharredRuins2", "CharredRuins3", "CharredRuins4" }, (PinType)2), ("StructCharredTowerRuins", "Charred Tower Ruins", new string[3] { "CharredTowerRuins1", "CharredTowerRuins2", "CharredTowerRuins3" }, (PinType)2), ("StructDvergrTowerRuins", "Dvergr Tower Ruins", new string[1] { "CharredTowerRuins1_dvergr" }, (PinType)2), ("StructPlaceOfMystery", "Place of Mystery", new string[3] { "PlaceofMystery1", "PlaceofMystery2", "PlaceofMystery3" }, (PinType)6), ("StructCharredStones", "Charred Stones", new string[1] { "CharredStone_Spawner" }, (PinType)3), ("StructSulfurArch", "Sulfur Arch", new string[1] { "SulfurArch" }, (PinType)6), ("StructVoltureNest", "Volture Nest", new string[1] { "VoltureNest" }, (PinType)3), ("StructNorthVillage", "North Village", new string[1] { "NorthVillage" }, (PinType)2), ("StructFrozenShip", "Frozen Ship", new string[3] { "FrozenShip01_DN", "FrozenShip02_DN", "FrozenShip03_DN" }, (PinType)2), ("StructLumberCamp", "Lumber Camp", new string[1] { "LumberCamp" }, (PinType)2), ("StructNorthernHut", "Northern Hut", new string[1] { "DN_hut01" }, (PinType)2), ("StructPetrifiedGammeltroll", "Petrified Gammeltroll", new string[2] { "DN_gammeltrollFrac01", "DN_gammeltrollFrac02" }, (PinType)3), ("StructIcePond", "Ice Pond", new string[1] { "IcePond1" }, (PinType)6), ("StructNorthMemorial", "North Memorial", new string[1] { "NorthMemorialPlace" }, (PinType)6) }; private readonly Dictionary<int, ResourceCategory> _structureByLocationHash = new Dictionary<int, ResourceCategory>(); private readonly Dictionary<int, string> _locationNameByHash = new Dictionary<int, string>(); private const string LegacyFarmVillageKey = "StructFarmVillage"; private const string LegacyFarmVillageName = "Farm Village"; private static Sprite _genericShipIcon; private Collider[] _scanBuffer = (Collider[])(object)new Collider[256]; private const int HitsPerFrame = 40; private int _pendingHitCount; private int _pendingHitIndex; private Vector3 _pendingPlayerPos; private HashSet<GameObject> _pendingSeenRoots; private List<string> _pendingDiagNames; private const float LocationPinAdoptRadius = 50f; private static readonly Dictionary<Theme, string> LocationByTheme = new Dictionary<Theme, string> { { (Theme)16, "GoblinCamp2" }, { (Theme)32, "WoodVillage1" }, { (Theme)64, "WoodFarm1" }, { (Theme)65536, "NorthVillage" }, { (Theme)8192, "FortressRuins" }, { (Theme)4096, "AshlandRuins" }, { (Theme)2048, "Hildir_plainsfortress" } }; private static readonly HashSet<string> DungeonDisplayNames = new HashSet<string>(DungeonLocationDefs.Select(((string LocationName, string DisplayName, PinType PinType, string IconKey, string TrophyItemName) d) => d.DisplayName).Concat(DungeonLegacyPinNames.Values.SelectMany((string[] n) => n))); private static readonly Dictionary<GameObject, (MineRock Rock, MineRock5 Rock5)> OreTemplateCache = new Dictionary<GameObject, (MineRock, MineRock5)>(); private readonly Dictionary<string, List<HiddenPinRecord>> _hiddenPins = new Dictionary<string, List<HiddenPinRecord>>(); private bool _hiddenPinsLoaded; private static string _saveDir; private string _hiddenPinsPath; private const string BossAltarsGroup = "Boss Altars"; private const float NativeBossPinMatchRadius = 30f; private static readonly Dictionary<string, string> NativeBossPinNames = new Dictionary<string, string> { { "$enemy_eikthyr", "Eikthyrnir" }, { "$enemy_gdking", "GDKing" }, { "$enemy_bonemass", "Bonemass" }, { "$enemy_dragon", "Dragonqueen" }, { "$enemy_goblinking", "GoblinKing" } }; private const float NativeBossLocationRadius = 50f; private static readonly FieldInfo LocationInstancesField = AccessTools.Field(typeof(ZoneSystem), "m_locationInstances"); private List<(Vector3 Pos, string LocationName)> _bossLocations; private readonly HashSet<string> _reportedUnknownBossPins = new HashSet<string>(); private const float LegacySplitRadius = 50f; private List<(Vector3 Pos, string PrefabName)> _allLocations; private ZoneSystem _allLocationsSource; private static readonly MethodInfo MinimapGetSpriteMethod = AccessTools.Method(typeof(Minimap), "GetSprite", (Type[])null, (Type[])null); private static readonly FieldInfo PinUpdateRequiredField = AccessTools.Field(typeof(Minimap), "m_pinUpdateRequired"); private readonly HashSet<ResourceCategory> _pendingHide = new HashSet<ResourceCategory>(); private bool _hiddenPinsSaveDirty; private readonly HashSet<string> _discoveredKeys = new HashSet<string>(); private string _discoveryWorld; private string _discoveryPath; private bool _discoverySaveDirty; private bool _categoryListDirty = true; private readonly HashSet<ResourceCategory> _pendingGroupInheritance = new HashSet<ResourceCategory>(); private const float MenuPanelWidth = 460f; private const float MenuPanelHeight = 590f; private const float MenuRowHeight = 26f; private Transform _categoryListContent; private readonly HashSet<string> _expandedGroups = new HashSet<string>(); private static readonly HashSet<string> OreKeys = new HashSet<string> { "Copper", "Silver", "Tin", "Iron", "Obsidian", "Meteorite", "FlametalDeposit" }; private static readonly HashSet<string> BerryKeys = new HashSet<string> { "Blueberry", "Cloudberry", "Raspberry", "Lingonberry", "Vineberry" }; private static readonly HashSet<string> HerbKeys = new HashSet<string> { "Thistle", "Dandelion", "Fiddlehead" }; private const float ListWidth = 420f; private const float ListHandleSize = 10f; private const float ListHandleDistance = 2f; private const float ListRowWidth = 406f; private const float ToggleSize = 20f; private const float PinColumnLeft = 6f; private const float LabelColumnRightOffset = 24f; private const float RowTextRight = 354f; private const float SliderHandleSize = 14f; private static string SaveDir => _saveDir ?? (_saveDir = Directory.CreateDirectory(Path.Combine(Paths.ConfigPath, "AutoWaypoints")).FullName); private static string LegacySaveDir => Path.GetDirectoryName(typeof(AutoWaypointsPlugin).Assembly.Location); private IEnumerable<ResourceCategory> MenuCategories => new ResourceCategory[3] { _portalCategory, _shipLiveCategory, _shipDockedCategory }.Concat(_categories); private static string EntryKey(ConfigEntryBase entry) { return entry.Definition.Section + "/" + entry.Definition.Key; } private void SetUpCharacterSettings() { foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in ((BaseUnityPlugin)this).Config) { ConfigEntryBase value = item.Value; if (!(value is ConfigEntry<bool> value2)) { continue; } string section = value.Definition.Section; string key = value.Definition.Key; if (!(section == "Categories") && !(section == "Labels")) { switch (key) { case "ShowAutoPins": case "ReplaceBossAltars": case "ReplaceLocationIcons": break; default: continue; } } _characterEntries[EntryKey(value)] = value2; } ((BaseUnityPlugin)this).Config.Save(); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; ((BaseUnityPlugin)this).Config.SettingChanged += delegate(object _, SettingChangedEventArgs e) { if (!_applyingCharacterSettings && _characterEntries.ContainsKey(EntryKey(e.ChangedSetting))) { _characterSettingsDirty = true; } }; } private void LoadCharacterSettings(string character) { _characterSettingsPath = Path.Combine(SaveDir, "settings_" + SafeFileName(character) + ".json"); _applyingCharacterSettings = true; try { if (File.Exists(_characterSettingsPath)) { CharacterSettingsFile characterSettingsFile = JsonUtility.FromJson<CharacterSettingsFile>(File.ReadAllText(_characterSettingsPath)); if (characterSettingsFile?.Keys != null && characterSettingsFile.Values != null && characterSettingsFile.Keys.Count == characterSettingsFile.Values.Count) { for (int i = 0; i < characterSettingsFile.Keys.Count; i++) { if (_characterEntries.TryGetValue(characterSettingsFile.Keys[i], out var value)) { value.Value = characterSettingsFile.Values[i]; } } } else { Log.LogWarning((object)("Plik ustawien postaci " + _characterSettingsPath + " jest uszkodzony - uzywam ustawien startowych.")); ((BaseUnityPlugin)this).Config.Reload(); } } else { ((BaseUnityPlugin)this).Config.Reload(); _characterSettingsDirty = true; } } catch (Exception arg) { Log.LogWarning((object)$"Nie udalo sie wczytac ustawien postaci ({_characterSettingsPath}): {arg}"); } finally { _applyingCharacterSettings = false; } foreach (var (val, val2) in _menuToggles) { if ((Object)(object)val != (Object)null) { val.SetIsOnWithoutNotify(val2.Value); } } _categoryListDirty = true; ApplyLabelVisibilityToAllPins(); } private void SaveCharacterSettingsIfDirty() { if (!_characterSettingsDirty || _characterSettingsPath == null) { return; } _characterSettingsDirty = false; try { CharacterSettingsFile characterSettingsFile = new CharacterSettingsFile(); foreach (KeyValuePair<string, ConfigEntry<bool>> characterEntry in _characterEntries) { characterSettingsFile.Keys.Add(characterEntry.Key); characterSettingsFile.Values.Add(characterEntry.Value.Value); } string text = JsonUtility.ToJson((object)characterSettingsFile); CharacterSettingsFile characterSettingsFile2 = JsonUtility.FromJson<CharacterSettingsFile>(text); if (characterSettingsFile2?.Keys == null || characterSettingsFile2.Keys.Count != characterSettingsFile.Keys.Count || characterSettingsFile2.Values.Count != characterSettingsFile.Values.Count) { Log.LogError((object)("Zapis ustawien postaci: serializacja zgubila dane ('" + text + "') - NIE nadpisuje pliku.")); } else { WriteFileAtomically(_characterSettingsPath, text); } } catch (Exception arg) { Log.LogWarning((object)$"Nie udalo sie zapisac ustawien postaci: {arg}"); } } private void BindLocationIconsConfig() { _replaceLocationIcons = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ReplaceLocationIcons", false, "On: the game's own map icons for traders (Haldor, Hildir, Bog Witch) and the sacrificial stones at the start use this mod's icons. Off: they keep the game's icons, and this mod's pins for those places use the game's icons too. Either way the game's icon steps aside where this mod already has a named pin."); _replaceLocationIcons.SettingChanged += delegate { RequestPinUpdate(); }; } private void RefreshLocationIconNames() { if (!((Object)(object)ZoneSystem.instance == (Object)null)) { _locationIconNames.Clear(); ZoneSystem.instance.GetLocationIcons(_locationIconNames); } } private ResourceCategory LocationIconCategory(string locationName) { int stableHashCode = StringExtensionMethods.GetStableHashCode(locationName); ResourceCategory value = null; if (DungeonLocationByHash.TryGetValue(stableHashCode, out (string, PinType, string, string) value2)) { _dungeonCategoriesByName.TryGetValue(value2.Item1, out value); } else { _structureByLocationHash.TryGetValue(stableHashCode, out value); } if (value == null || !(value.MenuGroup != "Boss Altars")) { return null; } return value; } private Sprite ModLocationIcon(ResourceCategory category) { if (_modLocationIcons.TryGetValue(category, out var value) && (Object)(object)value != (Object)null) { return value; } value = category.CustomIcon; if ((Object)(object)value == (Object)null) { (string, string, PinType, string, string) tuple = DungeonLocationDefs.FirstOrDefault(((string LocationName, string DisplayName, PinType PinType, string IconKey, string TrophyItemName) d) => d.DisplayName == category.DisplayName); if (tuple.Item2 != null) { value = ResolveDungeonIcon(tuple.Item4, tuple.Item5); } } _modLocationIcons[category] = value; return value; } private Sprite GameLocationIcon(ResourceCategory category) { if ((Object)(object)_gameLocationIconsSource != (Object)(object)Minimap.instance) { _gameLocationIconsSource = Minimap.instance; _gameLocationIcons.Clear(); } if (_gameLocationIcons.TryGetValue(category, out var value)) { return value; } value = null; if (category.LocationPrefabs != null && category.MenuGroup != "Boss Altars" && (Object)(object)Minimap.instance != (Object)null) { value = (from l in Minimap.instance.m_locationIcons where category.LocationPrefabs.Contains(l.m_name) select l.m_icon).FirstOrDefault(); } _gameLocationIcons[category] = value; return value; } private Sprite LocationIconFor(ResourceCategory category) { Sprite val = GameLocationIcon(category); if (!_replaceLocationIcons.Value && !((Object)(object)val == (Object)null)) { return val; } return ModLocationIcon(category); } private void ApplyLocationIcons(List<PinData> pins) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Minimap.instance == (Object)null || _replaceLocationIcons == null) { return; } foreach (PinData pin in pins) { ResourceCategory resourceCategory = CategoryForPin(pin); if (resourceCategory != null && (Object)(object)GameLocationIcon(resourceCategory) != (Object)null) { SetPinIcon(pin, LocationIconFor(resourceCategory)); } } if (!(LocationPinsField?.GetValue(Minimap.instance) is Dictionary<Vector3, PinData> dictionary)) { return; } foreach (KeyValuePair<Vector3, PinData> item in dictionary) { if (!_locationIconNames.TryGetValue(item.Key, out var value)) { continue; } ResourceCategory category = LocationIconCategory(value); if (category != null) { PinData native = item.Value; bool flag = pins.Any((PinData p) => p != native && CategoryForPin(p) == category && Utils.DistanceXZ(p.m_pos, native.m_pos) < 30f); SetHiddenByAlpha(((Object)(object)native.m_uiElement != (Object)null) ? ((Component)native.m_uiElement).gameObject : null, flag || !IsCategoryVisible(category)); SetPinIcon(native, LocationIconFor(category)); } } } private static void SetPinIcon(PinData pin, Sprite icon) { if (!((Object)(object)icon == (Object)null) && !((Object)(object)pin.m_icon == (Object)(object)icon)) { pin.m_icon = icon; if ((Object)(object)pin.m_iconElement != (Object)null) { pin.m_iconElement.sprite = icon; } } } private void ScanNearbyLocations(Vector3 playerPos) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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) float num = Mathf.Max(_scanRadius.Value, 40f); foreach (LocationProxy item in LoadedLocationProxies.ToList()) { if ((Object)(object)item == (Object)null) { LoadedLocationProxies.Remove(item); continue; } GameObject gameObject = ((Component)item).gameObject; if (!_tracked.ContainsKey(gameObject) && !(Utils.DistanceXZ(gameObject.transform.position, playerPos) > num)) { ZNetView component = gameObject.GetComponent<ZNetView>(); ZDO val = ((component != null) ? component.GetZDO() : null); int num2 = ((val != null) ? val.GetInt(ZDOVars.s_location, 0) : 0); if (num2 != 0) { TrackLocation(gameObject, num2, playerPos, 8f); } } } } private void Awake() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Game.isModded = true; Instance = this; BuildConfig(); SetUpCharacterSettings(); GUIManager.OnCustomGUIAvailable += BuildSettingsMenu; _harmony = new Harmony("com.michal.valheim.autowaypoints"); _harmony.PatchAll(typeof(AutoWaypointsPlugin).Assembly); } private void CreateSettingsButton(Minimap mm) { //IL_0053: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown if (GUIManager.Instance != null && !((Object)(object)mm.m_largeRoot == (Object)null) && !((Object)(object)mm.m_largeRoot.transform.Find("AutoWaypointsSettingsButton") != (Object)null)) { GameObject obj = GUIManager.Instance.CreateButton("Waypoint Settings", mm.m_largeRoot.transform, new Vector2(1f, 0f), new Vector2(1f, 0f), new Vector2(-150f, -30f), 180f, 30f); ((Object)obj).name = "AutoWaypointsSettingsButton"; ((UnityEvent)obj.GetComponent<Button>().onClick).AddListener(new UnityAction(ToggleSettingsMenu)); } } private void BuildConfig() { //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_05b4: Unknown result type (might be due to invalid IL or missing references) //IL_05bb: Invalid comparison between Unknown and I4 //IL_0be2: Unknown result type (might be due to invalid IL or missing references) //IL_0be7: Unknown result type (might be due to invalid IL or missing references) //IL_0c10: Unknown result type (might be due to invalid IL or missing references) _showAutoPins = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowAutoPins", true, "Master switch. When off, all pins this mod added are removed from the map and no new ones are added - only the game's own pins remain."); _debugLogNearby = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DebugLogNearby", false, "Temporary debug aid: logs every distinct object name found in scan range each scan tick. Noisy - turn off once category prefab names are confirmed working."); _scanRadius = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ScanRadius", 25f, "How far (meters) to scan around the player. WARNING: large values (100+) can hit FPS since Physics.OverlapSphere gets expensive - only raise this temporarily for diagnostics, then set back down."); _showAutoPins.SettingChanged += delegate { RefreshAllVisibility(); }; _showPinLabels = ((BaseUnityPlugin)this).Config.Bind<bool>("Labels", "ShowPinLabels", true, "Master switch for the name labels under this mod's pins on the large map. Pins themselves stay visible."); _showPinLabels.SettingChanged += delegate { ApplyLabelVisibilityToAllPins(); }; _replaceBossAltars = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ReplaceBossAltars", false, "On: boss pins - both this mod's altar pins and the game's own boss pins from Vegvisir runestones - use this mod's icons (trophies/altar renders). Off: all of them use the game's standard boss icon. Either way the mod's altar pin steps aside where the game already has a pin for that boss."); _replaceBossAltars.SettingChanged += delegate { if (!_applyingCharacterSettings) { foreach (ResourceCategory item5 in _categories.Where((ResourceCategory c) => c.MenuGroup == "Boss Altars")) { SetCategoryVisibility(item5, IsCategoryVisible(item5)); } ReapplyAllKnownPinIcons(); RequestPinUpdate(); } }; BindLocationIconsConfig(); AddOreCategory("Copper", "Copper Ore", "CopperOre", "$piece_deposit_copper"); AddOreCategory("Silver", "Silver Ore", "SilverOre", "$piece_deposit_silver"); AddOreCategory("Tin", "Tin Ore", "TinOre", "$piece_deposit_tin", "MineRock_Tin"); AddOreCategory("Iron", "Iron Deposit", "IronOre", "$piece_deposit_iron"); AddOreCategory("Obsidian", "Obsidian", "Obsidian", "$piece_deposit_obsidian"); AddOreCategory("Meteorite", "Meteorite", "FlametalOreNew", "$item_flametalore", null, "MineRock_Meteorite", new string[1] { "MineRock_Meteorite" }); AddOreCategory("FlametalDeposit", "Flametal Deposit", "FlametalOreNew", "$item_flametalore", null, null, new string[1] { "LeviathanLava" }); string[] exactNames = new string[1] { "BlueberryBush" }; string[] iconItemNameCandidates = new string[2] { "Blueberry", "Blueberries" }; AddCategory("Blueberry", "Blueberries", exactNames, null, (PinType)1, null, removeOnPicked: false, null, iconItemNameCandidates); AddCategory("Cloudberry", "Cloudberries", new string[1] { "CloudberryBush" }, null, (PinType)1, "Cloudberry", removeOnPicked: false); AddCategory("Raspberry", "Raspberries", new string[1] { "RaspberryBush" }, null, (PinType)1, "Raspberry", removeOnPicked: false); AddCategory("Lingonberry", "Lingonberries", new string[1] { "LingonberryBush" }, null, (PinType)1, "Lingonberry", removeOnPicked: false); AddCategory("Vineberry", "Vineberries", new string[2] { "VineGreen", "VineAsh" }, null, (PinType)1, "Vineberry", removeOnPicked: false); string[] exactNames2 = new string[1] { "Pickable_Mushroom" }; iconItemNameCandidates = new string[1] { "Mushroom" }; AddCategory("MushroomCommon", "Mushroom", exactNames2, null, (PinType)1, null, removeOnPicked: true, null, iconItemNameCandidates); string[] exactNames3 = new string[1] { "Pickable_Mushroom_blue" }; iconItemNameCandidates = new string[3] { "MushroomBlue", "Mushroom_blue", "BlueMushroom" }; AddCategory("MushroomBlue", "Blue Mushroom", exactNames3, null, (PinType)1, null, removeOnPicked: true, null, iconItemNameCandidates); string[] exactNames4 = new string[1] { "Pickable_Mushroom_yellow" }; iconItemNameCandidates = new string[3] { "MushroomYellow", "Mushroom_yellow", "YellowMushroom" }; AddCategory("MushroomYellow", "Yellow Mushroom", exactNames4, null, (PinType)1, null, removeOnPicked: true, null, iconItemNameCandidates); string[] exactNames5 = new string[1] { "Pickable_Mushroom_JotunPuffs" }; iconItemNameCandidates = new string[2] { "JotunPuffs", "MushroomJotunPuffs" }; AddCategory("MushroomJotunPuffs", "Jotun Puffs", exactNames5, null, (PinType)1, null, removeOnPicked: true, null, iconItemNameCandidates); string[] exactNames6 = new string[1] { "Pickable_Mushroom_Magecap" }; iconItemNameCandidates = new string[2] { "Magecap", "MushroomMagecap" }; AddCategory("MushroomMagecap", "Magecap", exactNames6, null, (PinType)1, null, removeOnPicked: true, null, iconItemNameCandidates); AddCategory("MushroomSmokePuff", "Smoke Puff", new string[1] { "Pickable_SmokePuff" }, null, (PinType)1, "MushroomSmokePuff"); bool defaultEnabled = TakeLegacySetting("Categories", "Dungeon"); bool defaultShowName = TakeLegacySetting("Labels", "Dungeon"); foreach (string displayName in DungeonLocationDefs.Select(((string LocationName, string DisplayName, PinType PinType, string IconKey, string TrophyItemName) d) => d.DisplayName).Distinct()) { (string, string, PinType, string, string) tuple = DungeonLocationDefs.First(((string LocationName, string DisplayName, PinType PinType, string IconKey, string TrophyItemName) d) => d.DisplayName == displayName); if (!DungeonKeyOverrides.TryGetValue(displayName, out var value)) { value = "Dungeon" + new string(displayName.Where(char.IsLetterOrDigit).ToArray()); } ResourceCategory resourceCategory = AddCategory(value, displayName, null, null, tuple.Item3, null, removeOnPicked: true, 60f, null, defaultEnabled, defaultShowName); resourceCategory.MenuGroup = (((int)tuple.Item3 == 9) ? "Boss Altars" : (TraderLocations.Contains(tuple.Item1) ? "Other" : "Dungeons")); resourceCategory.LocationPrefabs = new HashSet<string>(from d in DungeonLocationDefs where d.DisplayName == displayName select d.LocationName); if (DungeonLegacyPinNames.TryGetValue(displayName, out var value2)) { resourceCategory.LegacyPinNames = value2; } _dungeonCategoriesByName[displayName] = resourceCategory; } AddCategory("CropCarrot", "Carrot", new string[1] { "Pickable_Carrot" }, null, (PinType)1, "Carrot"); AddCategory("CropTurnip", "Turnip", new string[1] { "Pickable_Turnip" }, null, (PinType)1, "Turnip"); AddCategory("CropOnion", "Onion", new string[1] { "Pickable_Onion" }, null, (PinType)1, "Onion"); AddCategory("CropKale", "Kale", new string[1] { "Pickable_Kale" }, null, (PinType)1, "Kale"); AddCategory("CropPoteitr", "Poteitr", new string[1] { "Pickable_Poteitr" }, null, (PinType)1, "Poteitr"); ResourceCategory resourceCategory2 = AddCategory("Beehive", "Beehive", new string[1] { "piece_beehive" }, null, (PinType)1); resourceCategory2.PlayerBuilt = true; resourceCategory2.IconPiecePrefab = "piece_beehive"; ResourceCategory resourceCategory3 = AddCategory("BeehiveWild", "Wild Beehive", new string[2] { "Beehive", "piece_beehive" }, null, (PinType)1, null, removeOnPicked: true, 12f); resourceCategory3.PlayerBuilt = false; resourceCategory3.CustomIcon = LoadEmbeddedIcon("BeehiveWild"); resourceCategory3.LegacyPinNames = new string[1] { "Beehive" }; AddCategory("DragonEgg", "Dragon Egg", new string[1] { "Pickable_DragonEgg" }, null, (PinType)3, "DragonEgg"); AddCategory("Thistle", "Thistle", new string[1] { "Pickable_Thistle" }, null, (PinType)1, "Thistle"); AddCategory("Dandelion", "Dandelion", new string[1] { "Pickable_Dandelion" }, null, (PinType)1, "Dandelion"); AddCategory("Fiddlehead", "Fiddlehead", new string[1] { "Pickable_Fiddlehead" }, null, (PinType)1, "Fiddleheadfern"); AddCategory("SeedCarrot", "Carrot Seeds", new string[1] { "Pickable_SeedCarrot" }, null, (PinType)1, "CarrotSeeds"); AddCategory("SeedTurnip", "Turnip Seeds", new string[1] { "Pickable_SeedTurnip" }, null, (PinType)1, "TurnipSeeds"); AddCategory("SeedOnion", "Onion Seeds", new string[1] { "Pickable_SeedOnion" }, null, (PinType)1, "OnionSeeds"); AddCategory("SeedKale", "Kale Seeds", new string[1] { "Pickable_SeedKale" }, null, (PinType)1, "KaleSeeds"); AddCategory("CropBarley", "Wild Barley", new string[1] { "Pickable_Barley_Wild" }, null, (PinType)1, "Barley").LegacyPinNames = new string[1] { "Barley" }; AddCategory("CropFlax", "Wild Flax", new string[1] { "Pickable_Flax_Wild" }, null, (PinType)1, "Flax").LegacyPinNames = new string[1] { "Flax" }; _shipsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Categories", "Ships", true, "Show a live pin for ships currently being sailed (by anyone). The pin follows the ship while sailed."); _shipLiveCategory.Enabled = _shipsEnabled; _shipLiveCategory.ShowName = BindLabel("Ships", "live ship"); _shipsDockedEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Categories", "ShipsDocked", true, "When a ship's live pin loses its crew, keep a saved pin marking where it was left instead of removing it."); _shipDockedCategory.Enabled = _shipsDockedEnabled; _shipDockedCategory.ShowName = BindLabel("ShipsDocked", "docked ship"); _shipsDockedEnabled.SettingChanged += delegate { SetCategoryVisibility(_shipDockedCategory, IsCategoryVisible(_shipDockedCategory)); }; _portalsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Categories", "Portals", true, "Auto-pin portals, labelled with their connection tag (the name you set on the portal)."); _portalCategory.Enabled = _portalsEnabled; _portalCategory.ShowName = BindLabel("Portals", "portal"); _portalsEnabled.SettingChanged += delegate { SetCategoryVisibility(_portalCategory, IsCategoryVisible(_portalCategory)); }; bool flag = TakeLegacySetting("Categories", "StructFarmVillage"); bool flag2 = TakeLegacySetting("Labels", "StructFarmVillage"); TakeLegacySetting("Categories", "StructInfestedMine"); TakeLegacySetting("Labels", "StructInfestedMine"); (string, string, string[], PinType)[] structureDefinitions = StructureDefinitions; for (int num = 0; num < structureDefinitions.Length; num++) { (string, string, string[], PinType) tuple2 = structureDefinitions[num]; string item = tuple2.Item1; string item2 = tuple2.Item2; string[] item3 = tuple2.Item3; PinType item4 = tuple2.Item4; bool flag3 = item == "StructDraugrVillage" || item == "StructAbandonedFarm"; ResourceCategory resourceCategory4 = AddCategory(item, item2, item3, null, item4, null, removeOnPicked: true, 60f, null, !flag3 || flag, !flag3 || flag2); if (flag3) { resourceCategory4.LegacyPinNames = new string[1] { "Farm Village" }; } resourceCategory4.LocationPrefabs = new HashSet<string>(item3); iconItemNameCandidates = item3; foreach (string text in iconItemNameCandidates) { _structureByLocationHash[StringExtensionMethods.GetStableHashCode(text)] = resourceCategory4; _locationNameByHash[StringExtensionMethods.GetStableHashCode(text)] = text; Sprite val = LoadEmbeddedIcon(item + "__" + text); if ((Object)(object)val != (Object)null) { ResourceCategory resourceCategory5 = resourceCategory4; (resourceCategory5.VariantIcons ?? (resourceCategory5.VariantIcons = new Dictionary<string, Sprite>()))[text] = val; } } resourceCategory4.CustomIcon = LoadEmbeddedIcon(item); if (item == "StructRuins") { _looseRuinsCategory = resourceCategory4; } if (item == "StructSwampTower") { _looseTowerCategory = resourceCategory4; } if (item == "StructWoodHouse") { _looseWoodCategory = resourceCategory4; } } foreach (string item6 in (from d in DungeonLocationDefs select d.IconKey into k where k != null select k).Distinct()) { _dungeonIcons[item6] = LoadEmbeddedIcon(item6); } foreach (ResourceCategory category in _categories) { _categoryByPinName[category.DisplayName] = category; } _categoryByPinName["Ship"] = _shipLiveCategory; _categoryByPinName["Ship (docked)"] = _shipDockedCategory; } private bool TakeLegacySetting(string section, string key) { ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>(section, key, true, "Legacy setting, replaced by per-type entries."); bool value = val.Value; ((BaseUnityPlugin)this).Config.Remove(((ConfigEntryBase)val).Definition); return value; } private ConfigEntry<bool> BindLabel(string key, string displayName, bool defaultValue = true) { ConfigEntry<bool> obj = ((BaseUnityPlugin)this).Config.Bind<bool>("Labels", key, defaultValue, "Show the name label of " + displayName + " pins on the large map."); obj.SettingChanged += delegate { ApplyLabelVisibilityToAllPins(); }; return obj; } private ResourceCategory CategoryForPin(PinData pin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) if ((int)pin.m_type == 0 && IsRegisteredPortal(pin.m_pos)) { return _portalCategory; } return CategoryForName(pin.m_name); } private ResourceCategory CategoryForName(string pinName) { if (pinName == null) { return null; } if (_categoryByPinName.TryGetValue(pinName, out var value)) { return value; } if (IsLegacyPortalName(pinName)) { return _portalCategory; } return null; } private static string PortalPinName(string tag) { if (!string.IsNullOrEmpty(tag)) { return tag; } return "Portal"; } private static bool IsLegacyPortalName(string name) { if (!(name == "Portal")) { return name?.StartsWith("Portal: ", StringComparison.Ordinal) ?? false; } return true; } private bool EnsurePortalRegistryLoaded() { ZNet instance = ZNet.instance; string text = ((instance != null) ? instance.GetWorldName() : null); if (string.IsNullOrEmpty(text)) { return false; } if (text == _portalRegistryWorld) { return true; } _portalRegistryWorld = text; _portalPinPositions.Clear(); string text2 = WorldFilePath("portals", text); if (!File.Exists(text2)) { return true; } try { PortalRegistryFile portalRegistryFile = JsonUtility.FromJson<PortalRegistryFile>(File.ReadAllText(text2)); if (portalRegistryFile?.Positions != null) { _portalPinPositions.AddRange(portalRegistryFile.Positions); } } catch (Exception arg) { Log.LogWarning((object)$"Nie udalo sie wczytac rejestru portali ({text2}): {arg}"); } return true; } private void SavePortalRegistry() { try { PortalRegistryFile portalRegistryFile = new PortalRegistryFile { Positions = _portalPinPositions.ToList() }; string text = JsonUtility.ToJson((object)portalRegistryFile); PortalRegistryFile portalRegistryFile2 = JsonUtility.FromJson<PortalRegistryFile>(text); if (portalRegistryFile2?.Positions == null || portalRegistryFile2.Positions.Count != portalRegistryFile.Positions.Count) { Log.LogError((object)("Zapis rejestru portali: serializacja zgubila dane ('" + text + "') - NIE nadpisuje pliku.")); } else { WriteFileAtomically(WorldFilePath("portals", _portalRegistryWorld), text); } } catch (Exception arg) { Log.LogWarning((object)$"Nie udalo sie zapisac rejestru portali: {arg}"); } } private bool IsRegisteredPortal(Vector3 pos) { //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) if (EnsurePortalRegistryLoaded()) { return _portalPinPositions.Any((Vector3 p) => Utils.DistanceXZ(p, pos) < 1f); } return false; } private void RegisterPortalPin(Vector3 pos) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (EnsurePortalRegistryLoaded() && !IsRegisteredPortal(pos)) { _portalPinPositions.Add(pos); SavePortalRegistry(); } } private void UnregisterPortalPin(Vector3 pos) { //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) if (EnsurePortalRegistryLoaded() && _portalPinPositions.RemoveAll((Vector3 p) => Utils.DistanceXZ(p, pos) < 1f) > 0) { SavePortalRegistry(); } } private void ApplyLabelVisibility(PinData pin) { PinNameData namePinData = pin.m_NamePinData; GameObject val = ((namePinData != null) ? namePinData.PinNameGameObject : null); if (!((Object)(object)val == (Object)null)) { SetHiddenByAlpha(val, ShouldHideLabel(pin)); } } private bool ShouldHideLabel(PinData pin) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 ResourceCategory resourceCategory = CategoryForPin(pin); if (resourceCategory == null && (int)pin.m_type == 9) { resourceCategory = NativeBossCategory(pin); } if (resourceCategory != null && (!_showPinLabels.Value || !resourceCategory.ShowName.Value)) { return true; } if ((int)pin.m_type == 9 && (Object)(object)Minimap.instance != (Object)null && PinsField.GetValue(Minimap.instance) is List<PinData> pins) { if (!IsBossPinYielding(pin, pins)) { return IsNativeBossPinHiddenByCategory(pin); } return true; } return false; } public bool IsPinLabelVisible(PinData pin) { if (pin != null) { return !ShouldHideLabel(pin); } return false; } private static void SetHiddenByAlpha(GameObject go, bool hide) { if ((Object)(object)go == (Object)null) { return; } CanvasGroup val = go.GetComponent<CanvasGroup>(); if ((Object)(object)val == (Object)null) { if (!hide) { return; } val = go.AddComponent<CanvasGroup>(); val.blocksRaycasts = false; } val.alpha = (hide ? 0f : 1f); } private void ApplyLabelVisibilityToAllPins() { if ((Object)(object)Minimap.instance == (Object)null || !(PinsField.GetValue(Minimap.instance) is List<PinData> list)) { return; } foreach (PinData item in list) { ApplyLabelVisibility(item); } } private Sprite StructureIcon(ResourceCategory category, Vector3 pos, GameObject root = null) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (category.VariantIcons != null) { string value = null; object obj; if (!((Object)(object)root != (Object)null)) { obj = null; } else { LocationProxy component = root.GetComponent<LocationProxy>(); if (component == null) { obj = null; } else { ZNetView component2 = ((Component)component).GetComponent<ZNetView>(); obj = ((component2 != null) ? component2.GetZDO() : null); } } ZDO val = (ZDO)obj; if (val != null) { _locationNameByHash.TryGetValue(val.GetInt(ZDOVars.s_location, 0), out value); } if (value == null) { value = LocationNameAt(pos, category.LocationPrefabs); } if (value != null && category.VariantIcons.TryGetValue(value, out var value2)) { return value2; } } return category.CustomIcon; } private ResourceCategory AddCategory(string key, string displayName, string[] exactNames, string prefix, PinType pinType, string iconItemNameOverride = null, bool removeOnPicked = true, float? maxVerticalDeltaOverride = null, string[] iconItemNameCandidates = null, bool defaultEnabled = true, bool defaultShowName = true) { //IL_0060: 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) ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>("Categories", key, defaultEnabled, "Auto-pin " + displayName + "."); ResourceCategory category = new ResourceCategory { Key = key, DisplayName = displayName, ExactNames = ((exactNames != null) ? new HashSet<string>(exactNames) : null), Prefix = prefix, PinType = pinType, Enabled = val, ShowName = BindLabel(key, displayName, defaultShowName), IconItemNameOverride = iconItemNameOverride, IconItemNameCandidates = iconItemNameCandidates, RemoveOnPicked = removeOnPicked, MaxVerticalDeltaOverride = maxVerticalDeltaOverride }; val.SettingChanged += delegate { SetCategoryVisibility(category, IsCategoryVisible(category)); }; _categories.Add(category); return category; } private void AddOreCategory(string key, string displayName, string dropItemName, string nameToken, string worldObjectName = null, string iconWorldPrefab = null, string[] orePrefabs = null) { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>("Categories", key, true, "Auto-pin " + displayName + "."); ResourceCategory category = new ResourceCategory { Key = key, DisplayName = displayName, OreDropItemNames = new HashSet<string> { dropItemName }, OreNameTokens = new HashSet<string> { nameToken }, ExactNames = ((worldObjectName != null) ? new HashSet<string> { worldObjectName } : null), IconItemNameOverride = dropItemName, IconWorldPrefab = iconWorldPrefab, OrePrefabNames = ((orePrefabs != null) ? new HashSet<string>(orePrefabs) : null), PinType = (PinType)3, Enabled = val, ShowName = BindLabel(key, displayName) }; val.SettingChanged += delegate { SetCategoryVisibility(category, IsCategoryVisible(category)); }; _categories.Add(category); } private static Sprite LoadEmbeddedIcon(string key) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) string suffix = ".Icons." + key + ".png"; Assembly executingAssembly = Assembly.GetExecutingAssembly(); string text = executingAssembly.GetManifestResourceNames().FirstOrDefault((string n) => n.EndsWith(suffix, StringComparison.Ordinal)); if (text == null) { return null; } using Stream stream = executingAssembly.GetManifestResourceStream(text); if (stream == null) { return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, memoryStream.ToArray())) { return null; } return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } private Sprite ResolveDungeonIcon(string iconKey, string trophyItemName) { if (iconKey != null && _dungeonIcons.TryGetValue(iconKey, out var value) && (Object)(object)value != (Object)null) { return value; } if (trophyItemName != null && (Object)(object)ObjectDB.instance != (Object)null) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(trophyItemName); ItemDrop obj = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null); if (obj == null) { return null; } ItemData itemData = obj.m_itemData; if (itemData == null) { return null; } return itemData.GetIcon(); } return null; } private static Sprite ResolvePortalIcon() { GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab("portal_wood") : null); if (!((Object)(object)val != (Object)null)) { return null; } return val.GetComponent<Piece>()?.m_icon; } private static Sprite ResolveGenericShipIcon() { if ((Object)(object)_genericShipIcon != (Object)null || (Object)(object)ZNetScene.instance == (Object)null) { return _genericShipIcon; } List<GameObject> source = ZNetScene.instance.m_prefabs.Where((GameObject p) => (Object)(object)p != (Object)null && (Object)(object)p.GetComponent<Ship>() != (Object)null).ToList(); GameObject val = ((IEnumerable<GameObject>)source).FirstOrDefault((Func<GameObject, bool>)((GameObject p) => ((Object)p).name == "Karve")) ?? source.FirstOrDefault(); _genericShipIcon = ((!((Object)(object)val != (Object)null)) ? null : val.GetComponent<Piece>()?.m_icon); return _genericShipIcon; } private static bool IsShipPinName(string name) { if (!(name == "Ship")) { return name == "Ship (docked)"; } return true; } private void Update() { try { RunUpdate(); } catch (Exception arg) { Log.LogError((object)$"Auto Waypoints error (will retry next tick): {arg}"); } } private void RunUpdate() { if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)Minimap.instance == (Object)null || (Object)(object)ObjectDB.instance == (Object)null) { return; } object value = MapHasGeneratedField.GetValue(Minimap.instance); if (value is bool && !(bool)value) { return; } ZNet instance = ZNet.instance; string text = ((instance != null) ? instance.GetWorldName() : null) + "\n" + CurrentCharacter(); if (text != _session) { SaveHiddenPinsIfDirty(); SaveCharacterSettingsIfDirty(); string text2 = CurrentCharacter(); if (string.IsNullOrEmpty(text2)) { return; } _session = text; LoadCharacterSettings(text2); _hiddenPinsLoaded = false; _globalIconPassDone = false; } if (!_globalIconPassDone) { ReapplyAllKnownPinIcons(); _globalIconPassDone = true; } if (!_hiddenPinsLoaded) { TryLoadHiddenPins(); RefreshAllVisibility(); } SaveDiscoveredIfDirty(); SaveHiddenPinsIfDirty(); SaveCharacterSettingsIfDirty(); ApplyPendingGroupInheritance(); ApplyPendingHides(); _shipUpdateTimer += Time.deltaTime; if (_shipUpdateTimer >= 0.3f) { _shipUpdateTimer = 0f; UpdateShipPins(); } if (_pendingHitCount > 0 && _pendingHitIndex < _pendingHitCount) { ProcessPendingScanBatch(); return; } _scanTimer += Time.deltaTime; if (!(_scanTimer < 1.5f)) { _scanTimer = 0f; PruneTracked(); ScanNearby(); } } private void ScanNearby() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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) //IL_0016: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_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_005b: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)Player.m_localPlayer).transform.position; Vector3 val = position + Vector3.up; ScanNearbyLocations(position); int num = Physics.OverlapSphereNonAlloc(val, _scanRadius.Value, _scanBuffer); if (num >= _scanBuffer.Length) { Array.Resize(ref _scanBuffer, _scanBuffer.Length * 2); num = Physics.OverlapSphereNonAlloc(val, _scanRadius.Value, _scanBuffer); } _pendingPlayerPos = position; _pendingHitCount = num; _pendingHitIndex = 0; _pendingSeenRoots = new HashSet<GameObject>(); _pendingDiagNames = (_debugLogNearby.Value ? new List<string>() : null); } private void ProcessPendingScanBatch() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Min(_pendingHitIndex + 40, _pendingHitCount); for (int i = _pendingHitIndex; i < num; i++) { ProcessScanHit(_scanBuffer[i], _pendingPlayerPos, _pendingSeenRoots, _pendingDiagNames); } _pendingHitIndex = num; if (_pendingHitIndex >= _pendingHitCount) { if (_debugLogNearby.Value && _pendingDiagNames != null) { Log.LogInfo((object)string.Format("[DIAG] obiekty w zasiegu skanu ({0}): {1}", _pendingDiagNames.Count, string.Join(", ", _pendingDiagNames.Distinct()))); } _pendingHitCount = 0; _pendingSeenRoots = null; _pendingDiagNames = null; } } private void ProcessScanHit(Collider hit, Vector3 playerPos, HashSet<GameObject> seenRoots, List<string> diagNames) { //IL_018c: 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_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_083f: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_0662: Unknown result type (might be due to invalid IL or missing references) //IL_067a: Unknown result type (might be due to invalid IL or missing references) //IL_06cc: Unknown result type (might be due to invalid IL or missing references) //IL_05af: Unknown result type (might be due to invalid IL or missing references) //IL_08e9: Unknown result type (might be due to invalid IL or missing references) //IL_08f3: Unknown result type (might be due to invalid IL or missing references) //IL_087c: 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_095d: Unknown result type (might be due to invalid IL or missing references) //IL_09a0: Unknown result type (might be due to invalid IL or missing references) //IL_09aa: Unknown result type (might be due to invalid IL or missing references) //IL_09d6: Unknown result type (might be due to invalid IL or missing references) //IL_081f: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_0a0e: Unknown result type (might be due to invalid IL or missing references) //IL_0806: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)hit == (Object)null) { return; } MineRock mineRock = ((Component)hit).GetComponentInParent<MineRock>(); MineRock5 mineRock2 = ((Component)hit).GetComponentInParent<MineRock5>(); Destructible val = null; if ((Object)(object)mineRock == (Object)null && (Object)(object)mineRock2 == (Object)null) { Destructible componentInParent = ((Component)hit).GetComponentInParent<Destructible>(); if ((Object)(object)componentInParent != (Object)null && TryGetOreTemplate(componentInParent, out mineRock, out mineRock2)) { val = componentInParent; } } if ((Object)(object)mineRock != (Object)null || (Object)(object)mineRock2 != (Object)null) { GameObject val2 = (((Object)(object)val != (Object)null) ? ((Component)val).gameObject : (((Object)(object)mineRock != (Object)null) ? ((Component)mineRock).gameObject : ((Component)mineRock2).gameObject)); if (_tracked.ContainsKey(val2)) { if (_debugLogNearby.Value && seenRoots.Add(val2)) { Log.LogInfo((object)$"[DIAG-ORE] '{((Object)val2).name}' juz sledzona, pin '{_tracked[val2].Pin?.m_name}' @ {_tracked[val2].Pin?.m_pos}, na mapie={(PinsField.GetValue(Minimap.instance) as List<PinData>)?.Contains(_tracked[val2].Pin)}"); } return; } Bounds bounds = hit.bounds; float num = Mathf.Max(new float[3] { 0f, ((Bounds)(ref bounds)).min.y - playerPos.y, playerPos.y - ((Bounds)(ref bounds)).max.y }); if (num > 3f) { if (_debugLogNearby.Value) { Log.LogInfo((object)$"[DIAG-ORE] '{((Object)val2).name}' kawalek '{((Object)hit).name}' odrzucony w pionie: gracz y={playerPos.y:0.0}, kawalek y={((Bounds)(ref bounds)).min.y:0.0}..{((Bounds)(ref bounds)).max.y:0.0}, roznica={num:0.0}m"); } } else { if (!seenRoots.Add(val2)) { return; } DropTable table = (((Object)(object)mineRock != (Object)null) ? mineRock.m_dropItems : mineRock2.m_dropItems); string nameToken = (((Object)(object)mineRock != (Object)null) ? mineRock.m_name : mineRock2.m_name); string dropItemName = ResolveDropItemName(table); if (_debugLogNearby.Value) { Log.LogInfo((object)string.Format("[DIAG-ORE] {0} m_name='{1}' dropItem='{2}' pos={3}", ((Object)(object)mineRock != (Object)null) ? "MineRock" : "MineRock5", nameToken, dropItemName, val2.transform.position)); } string orePrefab = ((Object)val2).name.Replace("(Clone)", string.Empty).Trim(); ResourceCategory resourceCategory = _categories.FirstOrDefault((ResourceCategory c) => c.OrePrefabNames != null && c.OrePrefabNames.Contains(orePrefab)) ?? _categories.FirstOrDefault((ResourceCategory c) => c.OrePrefabNames == null && ((c.OreNameTokens != null && nameToken != null && c.OreNameTokens.Contains(nameToken)) || (c.OreDropItemNames != null && dropItemName != null && dropItemName != "Stone" && c.OreDropItemNames.Contains(dropItemName)))); if (resourceCategory == null) { if (_debugLogNearby.Value) { Log.LogInfo((object)("[DIAG-ORE] '" + ((Object)val2).name + "' nie pasuje do zadnej kategorii (m_name='" + nameToken + "', drop='" + dropItemName + "')")); } return; } PinData existingOrePin = FindNearbyPin(resourceCategory, val2.transform.position); if (existingOrePin != null) { if (_debugLogNearby.Value) { Log.LogInfo((object)$"[DIAG-ORE] '{((Object)val2).name}' przejmuje istniejacy pin '{existingOrePin.m_name}' @ {existingOrePin.m_pos} (zyla @ {val2.transform.position})"); } if (!_tracked.Values.Any((TrackedResource t) => t.Pin == existingOrePin)) { _tracked[val2] = new TrackedResource { Obj = val2, Pin = existingOrePin, PickableComp = null, Category = resourceCategory, ReplacedWhenDamaged = ((Object)(object)val != (Object)null) }; } ReapplyIcon(existingOrePin, resourceCategory, val2, null, dropItemName); } else { AddResourcePin(val2, resourceCategory, dropItemName, null); if ((Object)(object)val != (Object)null && _tracked.TryGetValue(val2, out var value)) { value.ReplacedWhenDamaged = true; } } } return; } TeleportWorld componentInParent2 = ((Component)hit).GetComponentInParent<TeleportWorld>(); if ((Object)(object)componentInParent2 != (Object)null) { GameObject gameObject = ((Component)componentInParent2).gameObject; if (!seenRoots.Add(gameObject) || _tracked.ContainsKey(gameObject) || Mathf.Abs(gameObject.transform.position.y - playerPos.y) > 3f) { return; } string text = PortalPinName(componentInParent2.GetText()); Sprite val3 = ResolvePortalIcon(); PinData existingPortalPin = FindNearbyPortalPin(gameObject.transform.position); if (existingPortalPin != null) { RegisterPortalPin(existingPortalPin.m_pos); RenamePin(existingPortalPin, text); if ((Object)(object)val3 != (Object)null) { existingPortalPin.m_icon = val3; if ((Object)(object)existingPortalPin.m_iconElement != (Object)null) { existingPortalPin.m_iconElement.sprite = val3; } } if (!_tracked.Values.Any((TrackedResource t) => t.Pin == existingPortalPin)) { _tracked[gameObject] = new TrackedResource { Obj = gameObject, Pin = existingPortalPin, Category = _portalCategory }; } } else { RegisterPortalPin(gameObject.transform.position); PinData pin = CreatePinForFind(_portalCategory, gameObject.transform.position, (PinType)0, text, val3); _tracked[gameObject] = new TrackedResource { Obj = gameObject, Pin = pin, Category = _portalCategory }; Log.LogInfo((object)string.Format("Auto-pin dodany: {0} @ {1} (ikona: {2})", text, gameObject.transform.position, ((Object)(object)val3 != (Object)null) ? "OK" : "brak")); } return; } LocationProxy componentInParent3 = ((Component)hit).GetComponentInParent<LocationProxy>(); if ((Object)(object)componentInParent3 != (Object)null) { GameObject gameObject2 = ((Component)componentInParent3).gameObject; if (!seenRoots.Add(gameObject2) || _tracked.ContainsKey(gameObject2)) { return; } ZNetView component = gameObject2.GetComponent<ZNetView>(); ZDO val4 = (((Object)(object)component != (Object)null) ? component.GetZDO() : null); int num2 = ((val4 != null) ? val4.GetInt(ZDOVars.s_location, 0) : 0); if (_debugLogNearby.Value) { string arg = "?"; Dictionary<int, ZoneLocation> dictionary = (((Object)(object)ZoneSystem.instance != (Object)null) ? (LocationsByHashField.GetValue(ZoneSystem.instance) as Dictionary<int, ZoneLocation>) : null); if (dictionary != null && dictionary.TryGetValue(num2, out var value2)) { arg = "m_name='" + value2.m_name + "' m_prefabName='" + value2.m_prefabName + "'"; } Log.LogInfo((object)$"[DIAG-DUNGEON] LocationProxy locationHash={num2} resolved=[{arg}] pos={gameObject2.transform.position}"); } TrackLocation(gameObject2, num2, playerPos, 8f); return; } DungeonGenerator componentInParent4 = ((Component)hit).GetComponentInParent<DungeonGenerator>(); if ((Object)(object)componentInParent4 != (Object)null) { string text2 = LocationForTheme(componentInParent4.m_themes); if (text2 != null) { GameObject gameObject3 = ((Component)componentInParent4).gameObject; if (seenRoots.Add(gameObject3) && !_tracked.ContainsKey(gameObject3)) { TrackLocation(gameObject3, StringExtensionMethods.GetStableHashCode(text2), playerPos, 50f); } return; } } GameObject root = ((Component)((Component)hit).transform.root).gameObject; if (!seenRoots.Add(root)) { return; } string name = ((Object)root).name.Replace("(Clone)", string.Empty); if (_debugLogNearby.Value && diagNames != null) { float num3 = Mathf.Abs(root.transform.position.y - playerPos.y); diagNames.Add((num3 <= 3f) ? name : $"{name} [dy={num3:0.0}, poza zasiegiem pionowym]"); } if (_tracked.ContainsKey(root)) { return; } if (RuinPieceNames.Contains(name)) { HandleRuinPieceSighting(root, playerPos); return; } ResourceCategory resourceCategory2 = _categories.FirstOrDefault((ResourceCategory c) => c.Matches(name) && MatchesBuilder(c, root)); if (resourceCategory2 == null) { return; } float num4 = resourceCategory2.MaxVerticalDeltaOverride ?? 3f; if (Mathf.Abs(root.transform.position.y - playerPos.y) > num4) { return; } Pickable componentInChildren = root.GetComponentInChildren<Pickable>(); PinData existingPin = FindNearbyPin(resourceCategory2, root.transform.position); if (existingPin == null && resourceCategory2.LegacyPinNames != null) { existingPin = FindNearbyPinNamed(resourceCategory2.LegacyPinNames, root.transform.position); if (existingPin != null) { existingPin.m_name = resourceCategory2.DisplayName; OnPinRenamed(existingPin); } } if (existingPin != null) { if (!_tracked.Values.Any((TrackedResource t) => t.Pin == existingPin)) { _tracked[root] = new TrackedResource { Obj = root, Pin = existingPin, PickableComp = componentInChildren, Category = resourceCategory2 }; } ReapplyIcon(existingPin, resourceCategory2, root, componentInChildren, name); } else { AddResourcePin(root, resourceCategory2, name, componentInChildren); } } private void UpdateShipPins() { //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0222: 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_018e: 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) if (!_showAutoPins.Value || !_shipsEnabled.Value) { if (_shipPins.Count <= 0) { return; } foreach (PinData value2 in _shipPins.Values) { Minimap.instance.RemovePin(value2); } _shipPins.Clear(); return; } List<PinData> list = PinsField.GetValue(Minimap.instance) as List<PinData>; HashSet<Ship> active = new HashSet<Ship>(); foreach (IMonoUpdater instance in Ship.Instances) { Ship ship = (Ship)(object)((instance is Ship) ? instance : null); if (ship == null || !ship.HasPlayerOnboard()) { continue; } active.Add(ship); if (_shipPins.TryGetValue(ship, out var value)) { value.m_pos = ((Component)ship).transform.position; continue; } Sprite val = ((Component)ship).GetComponent<Piece>()?.m_icon; PinData val2 = list?.FirstOrDefault((Func<PinData, bool>)((PinData p) => p.m_name != null && p.m_name.StartsWith("Ship", StringComparison.Ordinal) && Vector3.Distance(p.m_pos, ((Component)ship).transform.position) < 8f)); if (val2 != null) { val2.m_name = "Ship"; val2.m_save = false; OnPinRenamed(val2); val2.m_pos = ((Component)ship).transform.position; if ((Object)(object)val != (Object)null) { val2.m_icon = val; if ((Object)(object)val2.m_iconElement != (Object)null) { val2.m_iconElement.sprite = val; } } _shipPins[ship] = val2; } else { RemoveHiddenRecordsNear(_shipDockedCategory, ((Component)ship).transform.position, 8f); PinData val3 = Minimap.instance.AddPin(((Component)ship).transform.position, (PinType)0, "Ship", false, false, 0L, default(PlatformUserID)); if ((Object)(object)val != (Object)null) { val3.m_icon = val; } _shipPins[ship] = val3; } } foreach (Ship item in _shipPins.Keys.Where((Ship s) => (Object)(object)s == (Object)null || !active.Contains(s)).ToList()) { PinData val4 = _shipPins[item]; _shipPins.Remove(item); if (val4 != null) { val4.m_name = "Ship (docked)"; val4.m_save = true; OnPinRenamed(val4); } } if (list == null) { return; } foreach (IMonoUpdater instance2 in Ship.Instances) { Ship ship2 = (Ship)(object)((instance2 is Ship) ? instance2 : null); if (ship2 == null || active.Contains(ship2)) { continue; } Sprite val5 = ((Component)ship2).GetComponent<Piece>()?.m_icon; if ((Object)(object)val5 == (Object)null) { continue; } PinData val6 = ((IEnumerable<PinData>)list).FirstOrDefault((Func<PinData, bool>)((PinData p) => p.m_name == "Ship (docked)" && Vector3.Distance(p.m_pos, ((Component)ship2).transform.position) < 8f)); if (val6 != null && !((Object)(object)val6.m_icon == (Object)(object)val5)) { val6.m_icon = val5; if ((Object)(object)val6.m_iconElement != (Object)null) { val6.m_iconElement.sprite = val5; } } } } private void ReapplyAllKnownPinIcons() { //IL_004f: 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_0236: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) if (!(PinsField.GetValue(Minimap.instance) is List<PinData> list) || (Object)(object)ObjectDB.instance == (Object)null) { return; } ResolvePieceIcons(); List<PinData> list2 = new List<PinData>(); foreach (PinData item in list) { ResourceCategory resourceCategory = ResolveSplitLegacy(item.m_name, item.m_pos); if (resourceCategory != null) { RenamePin(item, resourceCategory.DisplayName); list2.Add(item); } } int num = 0; Dictionary<string, int> dictionary = new Dictionary<string, int>(); foreach (PinData pin in list) { if (CategoryForPin(pin) == _portalCategory) { if (pin.m_name.StartsWith("Portal: ", StringComparison.Ordinal)) { RenamePin(pin, pin.m_name.Substring("Portal: ".Length)); } RegisterPortalPin(pin.m_pos); Sprite val = ResolvePortalIcon(); if ((Object)(object)val != (Object)null) { pin.m_icon = val; if ((Object)(object)pin.m_iconElement != (Object)null) { pin.m_iconElement.sprite = val; } num++; } continue; } if (IsNativeBossPin(pin, CategoryForPin(pin))) { if (ApplyNativeBossIcon(pin)) { num++; } continue; } if (IsShipPinName(pin.m_name)) { Sprite val2 = ResolveGenericShipIcon(); if ((Object)(object)val2 != (Object)null) { pin.m_icon = val2; if ((Object)(object)pin.m_iconElement != (Object)null) { pin.m_iconElement.sprite = val2; } num++; } continue; } (string, string, PinType, string, string) tuple = DungeonLocationDefs.FirstOrDefault(((string LocationName, string DisplayName, PinType PinType, string IconKey, string TrophyItemName) d) => d.DisplayName == pin.m_name && (d.IconKey != null || d.TrophyItemName != null)); if (tuple.Item2 != null) { Sprite val3 = ResolveDungeonPinIcon(tuple.Item3, tuple.Item4, tuple.Item5); if ((Object)(object)val3 != (Object)null) { pin.m_icon = val3; if ((Object)(object)pin.m_iconElement != (Object)null) { pin.m_iconElement.sprite = val3; } num++; } continue; } ResourceCategory resourceCategory2 = _categories.FirstOrDefault((ResourceCategory c) => c.DisplayName == pin.m_name && (c.IconItemNameOverride != null || c.IconItemNameCandidates != null || (Object)(object)c.CustomIcon != (Object)null)); if (resourceCategory2 == null) { continue; } if ((Object)(object)resourceCategory2.CustomIcon != (Object)null) { Sprite val4 = StructureIcon(resourceCategory2, pin.m_pos); pin.m_icon = val4; if ((Object)(object)pin.m_iconElement != (Object)null) { pin.m_iconElement.sprite = val4; } num++; continue; } string[] obj = resourceCategory2.IconItemNameCandidates ?? new string[1] { resourceCategory2.IconItemNameOverride }; Sprite val5 = null; string[] array = obj; foreach (string text in array) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text); ItemDrop obj2 = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null); object obj3; if (obj2 == null) { obj3 = null; } else { ItemData itemData = obj2.m_itemData; obj3 = ((itemData != null) ? itemData.GetIcon() : null); } val5 = (Sprite)obj3; if ((Object)(object)val5 != (Object)null) { break; } } if ((Object)(object)val5 == (Object)null && resourceCategory2.IconWorldPrefab != null) { val5 = IconFromWorldPrefab(resourceCategory2.IconWorldPrefab); } if ((Object)(object)val5 == (Object)null) { dictionary.TryGetValue(resourceCategory2.DisplayName, out var value); dictionary[resourceCategory2.DisplayName] = value + 1; continue; } pin.m_icon = val5; if ((Object)(object)pin.m_iconElement != (Object)null) { pin.m_iconElement.sprite = val5; } num++; } foreach (PinData item2 in list2) { OnPinRenamed(item2); } if (list2.Count > 0) { Log.LogInfo((object)$"Przypisano {list2.Count} dawnych pinow do nowych kategorii (po lokacji gry)."); } Log.LogInfo((object)$"Globalny przebieg ikonek pinow: naprawiono {num} z {list.Count}."); foreach (KeyValuePair<string, int> item3 in dictionary) { Log.LogWarning((object)$"Globalny przebieg ikonek: '{item3.Key}' nie naprawiono ({item3.Value}x) - brak ikony przedmiotu w ObjectDB i w lupach obiektu."); } } private static bool MatchesBuilder(ResourceCategory category, GameObject root) { if (!category.PlayerBuilt.HasValue) { return true; } Piece val = root.GetComponentInParent<Piece>() ?? root.GetComponentInChildren<Piece>(); return ((Object)(object)val != (Object)null && val.GetCreator() != 0) == category.PlayerBuilt.Value; } private static PinData FindNearbyPinNamed(string[] names, Vector3 pos, float radius = 8f) { //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) return (PinsField.GetValue(Minimap.instance) as List<PinData>)?.FirstOrDefault((Func<PinData, bool>)((PinData p) => names.Contains(p.m_name) && Vector3.Distance(p.m_pos, pos) < radius)); } private void ResolvePieceIcons() { if ((Object)(object)ZNetScene.instance == (Object)null) { return; } foreach (ResourceCategory item in _categories.Where((ResourceCategory c) => c.IconPiecePrefab != null && (Object)(object)c.CustomIcon == (Object)null)) { GameObject prefab = ZNetScene.instance.GetPrefab(item.IconPiecePrefab); item.CustomIcon = ((prefab != null) ? prefab.GetComponent<Piece>()?.m_icon : null); } } private static PinData FindNearbyPin(ResourceCategory category, Vector3 pos, float radius = 8f) { //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) return (PinsField.GetValue(Minimap.instance) as List<PinData>)?.FirstOrDefault((Func<PinData, bool>)((PinData p) => p.m_name == category.DisplayName && Vector3.Distance(p.m_pos, pos) < radius)); } private static string LocationForTheme(Theme themes) { //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) return (from kv in LocationByTheme where (themes & kv.Key) > 0 select kv.Value).FirstOrDefault(); } private void TrackLocation(GameObject obj, int locationHash, Vector3 playerPos, float adoptRadius) { //IL_0012: 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) ResourceCategory value2; if (DungeonLocationByHash.TryGetValue(locationHash, out (string, PinType, string, string) value)) { TrackDungeonLocation(obj, value, playerPos, adoptRadius); } else if (_structureByLocationHash.TryGetValue(locationHash, out value2)) { TrackStructureLocation(obj, value2, playerPos); } } private void TrackDungeonLocation(GameObject locObj, (string DisplayName, PinType PinType, string IconKey, string TrophyItemName) dungeonInfo, Vector3 playerPos, float adoptRadius) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_019e: Unknown result type (might be due to invalid IL or missing references) ResourceCategory resourceCategory = _dungeonCategoriesByName[dungeonInfo.DisplayName]; if (Mathf.Abs(locObj.transform.position.y - playerPos.y) > (resourceCategory.MaxVerticalDeltaOverride ?? 3f)) { return; } Sprite val = ResolveDungeonPinIcon(dungeonInfo.PinType, dungeonInfo.IconKey, dungeonInfo.TrophyItemName); PinData existingDungeonPin = FindNearbyDungeonPin(locObj.transform.position, adoptRadius, dungeonInfo.DisplayName); if (existingDungeonPin != null) { if (existingDungeonPin.m_name != dungeonInfo.DisplayName) { existingDungeonPin.m_name = dungeonInfo.DisplayName; OnPinRenamed(existingDungeonPin); } if ((Object)(object)val != (Object)null) { existingDungeonPin.m_icon = val; if ((Object)(object)existingDungeonPin.m_iconElement != (Object)null) { existingDungeonPin.m_iconElement.sprite = val; } } if (!_tracked.Values.Any((TrackedResource t) => t.Pin == existingDungeonPin)) { _tracked[locObj] = new TrackedResource { Obj = locObj, Pin = existingDungeonPin, Category = resourceCategory }; } } else { PinData pin = CreatePinForFind(resourceCategory, locObj.transform.position, dungeonInfo.PinType, dungeonInfo.DisplayName, val); _tracked[locObj] = new TrackedResource { Obj = locObj, Pin = pin, Category = resourceCategory }; Log.LogInfo((object)$"Auto-pin dodany: {dungeonInfo.DisplayName} @ {locObj.transform.position}"); } } private void TrackStructureLocation(GameObject locObj, ResourceCategory category, Vector3 playerPos) { //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) //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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) Vector3 position = locObj.transform.position; if (Mathf.Abs(position.y - playerPos.y) > (category.MaxVerticalDeltaOverride ?? 3f)) { return; } PinData existingPin = FindNearbyPin(category, position, 50f); if (existingPin == null && category.LegacyPinNames != null) { existingPin = FindNearbyPinNamed(category.LegacyPinNames, position, 50f); if (existingPin != null) { existingPin.m_name = category.DisplayName; OnPinRenamed(existingPin); } } if (existingPin != null) { if (!_tracked.Values.Any((TrackedResource t) => t.Pin == existingPin)) { _tracked[locObj] = new TrackedResource { Obj = locObj, Pin = existingPin, Category = category }; } ReapplyIcon(existingPin, category, locObj, null, category.DisplayName); } else { AddResourcePin(locObj, category, category.DisplayName, null); } } private PinData FindNearbyPortalPin(Vector3 pos) { //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) return (PinsField.GetValue(Minimap.instance) as List<PinData>)?.FirstOrDefault((Func<PinData, bool>)((PinData p) => CategoryForPin(p) == _portalCategory && Vector3.Distance(p.m_pos, pos) < 8f)); } private PinData FindNearbyDungeonPin(Vector3 pos, float radius, string displayName) { //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) List<PinData> obj = PinsField.GetValue(Minimap.instance) as List<PinData>; HashSet<string> hashSet = new HashSet<string> { displayName }; if (DungeonLegacyPinNames.TryGetValue(displayName, out var value)) { hashSet.UnionWith(value); } HashSet<string> allowed = ((radius <= 8f) ? DungeonDisplayNames : hashSet); return obj?.FirstOrDefault((Func<PinData, bool>)((PinData p) => p.m_name != null && allowed.Contains(p.m_name) && Vector3.Distance(p.m_pos, pos) < radius)); } private static string ResolveDropItemName(DropTable table) { //IL_0042: 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) DropData? val = table?.m_drops?.FirstOrDefault((Func<DropData, bool>)((DropData d) => (Object)(object)d.m_item != (Object)null && ((Object)d.m_item).name != "Stone")); if (!val.HasValue) { return null; } GameObject item = val.GetValueOrDefault().m_item; if (item == null) { return null; } return ((Object)item).name?.Replace("(Clone)", string.Empty); } private void ReapplyIcon(PinData pin, ResourceCategory category, GameObject root, Pickable pickable, string matchedName) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)category.CustomIcon != (Object)null) { Sprite sprite = (pin.m_icon = StructureIcon(category, pin.m_pos, root)); if ((Object)(object)pin.m_iconElement != (Object)null) { pin.m_iconElement.sprite = sprite; } return; } string diag; Sprite val = ResolveIcon(root, pickable, category.IconItemNameOverride ?? matchedName, out diag); if (_debugLogNearby.Value) { Log.LogInfo((object)("[DIAG-ICON] ReapplyIcon '" + category.DisplayName + "': icon=" + (((Object)(object)val != (Object)null) ? "OK" : "NULL") + " (" + diag + "), m_iconElement=" + (((Object)(object)pin.m_iconElement != (Object)null) ? "istnieje" : "NULL") + ", pin.m_icon przed=" + (((Object)(object)pin.m_icon != (Object)null) ? ((Object)pin.m_icon).name : "null"))); } if (!((Object)(object)val == (Object)null)) { pin.m_icon = val; if ((Object)(object)pin.m_iconElement != (Object)null) { pin.m_iconElement.sprite = val; } } } private static bool TryGetOreTemplate(Destructible destructible, out MineRock mineRock, out MineRock5 mineRock5) { mineRock = null; mineRock5 = null; GameObject[] array = (GameObject[])(object)new GameObject[2] { destructible.m_spawnWhenDamaged, destructible.m_spawnWhenDestroyed }; foreach (GameObject val in array) { if (!((Object)(object)val == (Object)null)) { if (!OreTemplateCache.TryGetValue(val, out (MineRock, MineRock5) value)) { value = (val.GetComponentInChildren<MineRock>(true), val.GetComponentInChildren<MineRock5>(true)); OreTemplateCache[val] = value; } if ((Object)(object)value.Item1 != (Object)null || (Object)(object)value.Item2 != (Object)null) { (mineRock, mineRock5) = value; return true; } } } return false; } private void AddResourcePin(GameObject root, ResourceCategory category, string matchedName, Pickable pickable) { //IL_0019: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) Sprite val = (((Object)(object)category.CustomIcon != (Object)null) ? StructureIcon(category, root.transform.position, root) : null); string diag = "wlasna ikona (renderowana z pliku gry)"; if ((Object)(object)val == (Object)null) { val = ResolveIcon(root, pickable, category.IconItemNameOverride ?? matchedName, out diag); } PinData pin = CreatePinForFind(category, root.transform.position, category.PinType, category.DisplayName, val); _tracked[root] = new TrackedResource { Obj = root, Pin = pin, PickableComp = pickable, Category = category }; Log.LogInfo((object)$"Auto-pin dodany: {category.DisplayName} @ {root.transform.position} (ikona: {diag})"); } private static Sprite ResolveIcon(GameObject root, Pickable pickable, string matchedName, out string diag) { if ((Object)(object)pickable != (Object)null) { if ((Object)(object)pickable.m_itemPrefab != (Object)null) { ItemDrop component = pickable.m_itemPrefab.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null) { Sprite icon = component.m_itemData.GetIcon(); diag = (((Object)(object)icon != (Object)null) ? ("Pickable.m_itemPrefab=" + ((Object)pickable.m_itemPrefab).name + " OK") : ("Pickable.m_itemPrefab=" + ((Object)pickable.m_itemPrefab).name + " ale GetIcon()==null")); if ((Object)(object)icon != (Object)nu