private static void AddPortalPins(Minimap __instance) { foreach (Portal portal in MinimapManager.Instance.GetPinsToShow()) { if (portal.MapPin != null && !_miniMap.HaveSimilarPin(portal.MapPin.m_pos, portal.MapPin.m_type, portal.MapPin.m_name, portal.MapPin.m_save)) { _miniMap.RemovePin(portal.Position); portal.MapPin = null; } if (portal.MapPin == null) { portal.MapPin = __instance.AddPin(portal.Position, PinType, portal.Tag, true, false); PortalPinAdded?.Invoke(null, portal.MapPin); } if (portal.MapPin != null) { portal.MapPin.m_name = portal.Tag; } if (portal.MapPin.m_uiElement != null && MinimapManager.Instance.UseColorCoding) { Image icon = portal.MapPin.m_uiElement.GetComponent <Image>(); icon.color = portal.AssignedColor; } } }
public static void AddPin(ref Minimap __instance) { Minimap.PinType pintype = iconSelected.value == 4 ? Minimap.PinType.Icon4 : (Minimap.PinType)iconSelected.value; Minimap.PinData addedPin = __instance.AddPin(pinPos, pintype, pinName.text, true, false); if (Configuration.Current.Map.shareablePins && sharePin.isOn && !Configuration.Current.Map.shareAllPins) { VPlusMapPinSync.SendMapPinToServer(addedPin); } pinEditorPanel.SetActive(false); __instance.m_wasFocused = false; }
static void GenerateTestData(bool[] m_explored, Minimap _instance, Texture2D m_fogTexture, List <Minimap.PinData> m_pins) { Utils.Log("Generating test data..."); var ySize = _instance.m_textureSize; if (!explored) { var exploredChunkCounter = 0; Utils.Log($"Discover whole map"); if (_instance == null) { Utils.Log("_instance is null"); return; } if (m_explored == null) { Utils.Log("m_explored is null"); return; } for (var i = 0; i < m_explored.Length; i++) { if (_instance.Explore(i % ySize, i / ySize)) { exploredChunkCounter++; } } if (exploredChunkCounter > 0) { m_fogTexture.Apply(); } explored = true; } var vals = Enum.GetValues(typeof(Minimap.PinType)); for (int i = 0; i < 100; i++) { var randSpotX = Random.Range(0, ySize); var randSpotY = Random.Range(0, ySize); var randPos = new Vector3(randSpotX, 0f, randSpotY); var randPinType = Random.Range(0, 5); _instance.AddPin(randPos, (Minimap.PinType)vals.GetValue(randPinType), "randompin" + i, true, Random.Range(0, 1) == 0); } }
public static void MergePinData(List <Minimap.PinData> pinsIn, List <Minimap.PinData> existingPins, Minimap minimap) { if (pinsIn == null || pinsIn.Count == 0) { return; } foreach (var p in pinsIn) { if (!HaveSimilarPin(existingPins, p)) { minimap.AddPin(p.m_pos, p.m_type, p.m_name, p.m_save, p.m_checked); } } }
private static bool CheckPin(Minimap __instance, Player player, ZDO zdo, int hashCode, string pinName) { if (zdo.m_prefab != hashCode) { return(false); } Minimap.PinData customPin; bool pinWasFound = customPins.TryGetValue(zdo, out customPin); // turn off associated pin if player controlled ship is in that position Ship controlledShip = player.GetControlledShip(); if (controlledShip && Vector3.Distance(controlledShip.transform.position, zdo.m_position) < 0.01f) { if (pinWasFound) { __instance.RemovePin(customPin); customPins.Remove(zdo); } return(true); } if (!pinWasFound) { customPin = __instance.AddPin(zdo.m_position, Minimap.PinType.Death, pinName, false, false); Sprite sprite; if (icons.TryGetValue(hashCode, out sprite)) { customPin.m_icon = sprite; } customPin.m_doubleSize = true; customPins.Add(zdo, customPin); } else { customPin.m_pos = zdo.m_position; } return(true); }
public static void Postfix(Minimap __instance) { //Skip this entirely if disabled in the config. if (showMinimapIcons.Value) { //Populate the list of current HUD characters. List <Character> guysList = new List <Character>(); foreach (EnemyHud.HudData hud in EnemyHud.instance.m_huds.Values) { if (hud.m_character != null && hud.m_hoverTimer < EnemyHud.instance.m_hoverShowDuration) { guysList.Add(hud.m_character); } } //Add minimap pins if they haven't been added already. foreach (Character character in guysList) { if (character is Player) { continue; } bool flag = false; foreach (Minimap.PinData pin in __instance.m_pins) { if (pin.m_name.Equals("CS__" + character.GetZDOID().ToString())) { flag = true; break; } } if (!flag) { __instance.AddPin(character.GetCenterPoint(), Minimap.PinType.RandomEvent, "CS__" + character.GetZDOID().ToString(), false, false); } } //Remove minimap pins which are not needed anymore. List <Minimap.PinData> removePins = new List <Minimap.PinData>(); foreach (Minimap.PinData pin in __instance.m_pins) { if (pin.m_type == Minimap.PinType.RandomEvent && pin.m_name.Contains("CS__")) { bool flag = false; foreach (Character character in guysList) { if (pin.m_name.Equals("CS__" + character.GetZDOID().ToString())) { pin.m_pos.x = character.GetCenterPoint().x; pin.m_pos.y = character.GetCenterPoint().y; pin.m_pos.z = character.GetCenterPoint().z; flag = true; break; } } if (!flag) { removePins.Add(pin); } } } foreach (Minimap.PinData pin in removePins) { __instance.RemovePin(pin); Debug.Log("removing pin for " + pin.m_name); } } }
public static void MergeSharedMapPinData(List <Minimap.PinData> sharedMapPins, List <Minimap.PinData> playerPins, Minimap minimap, Dictionary <string, PlayerSyncData> playerSyncDatas, Dictionary <string, ExtendedPinData> extendedPinDatas) { if (sharedMapPins == null || playerSyncDatas == null || extendedPinDatas == null) { return; } Utils.Log("mergeSharedMapPinData executing."); //Build some hashes var sharedMapPinsDict = new Dictionary <string, Minimap.PinData>(); var playerPinsDict = new Dictionary <string, Minimap.PinData>(); sharedMapPins.ForEach(p => { sharedMapPinsDict[GetPinKey(p)] = p; }); playerPins.ForEach(p => { playerPinsDict[GetPinKey(p)] = p; }); Utils.Log("Hashes built."); //Get last player sync date var lastSyncDate = DateTime.MinValue; if (playerSyncDatas.ContainsKey(Player.m_localPlayer.GetPlayerName())) { lastSyncDate = playerSyncDatas[Player.m_localPlayer.GetPlayerName()].SyncDate; Utils.Log($"Last player sync: {lastSyncDate}"); } else { Utils.Log($"No last player sync for {Player.m_localPlayer.GetPlayerName()}"); } //Delete any pins from incoming data player has removed since last sync - from the shared map pins dict and list DeleteRemovedPinsFromSharedMap(lastSyncDate, sharedMapPins, sharedMapPinsDict, playerPinsDict, extendedPinDatas); DeleteRemovedPinsFromPlayer(playerPinsDict, extendedPinDatas, minimap); //If the player is sharing their own pins, add them to the shared and extended pin data if (Settings.MapSettings.SendPinShares.Value) { playerPins.ForEach(p => { var pKey = GetPinKey(p); sharedMapPinsDict[pKey] = p; extendedPinDatas[pKey] = new ExtendedPinData(pKey, DateTime.Now, false); }); } //add any pins to the map from incoming data that the player is missing foreach (var pin in sharedMapPinsDict) { var pVal = pin.Value; if (!playerPinsDict.ContainsKey(pin.Key)) { minimap.AddPin(pVal.m_pos, pVal.m_type, pVal.m_name, pVal.m_save, pVal.m_checked); } } }
public static void UpdateDynamicPins_Postfix(Minimap __instance) { var player = Player.m_localPlayer; if (player == null) { return; } var adventureSaveData = player.GetAdventureSaveData(); if (adventureSaveData == null) { return; } var unfoundTreasureChests = adventureSaveData.GetUnfoundTreasureChests(); var oldPins = TreasureMapPins.Where(pinEntry => !unfoundTreasureChests.Exists(x => x.Interval == pinEntry.Key.Item1 && x.Biome == pinEntry.Key.Item2)).ToList(); foreach (var pinEntry in oldPins) { __instance.RemovePin(pinEntry.Value.Pin); __instance.RemovePin(pinEntry.Value.Area); if (pinEntry.Value.DebugPin != null) { __instance.RemovePin(pinEntry.Value.DebugPin); } TreasureMapPins.Remove(pinEntry.Key); } foreach (var chestInfo in unfoundTreasureChests) { var key = new Tuple <int, Heightmap.Biome>(chestInfo.Interval, chestInfo.Biome); if (!TreasureMapPins.ContainsKey(key)) { var position = chestInfo.Position + chestInfo.MinimapCircleOffset; var area = __instance.AddPin(position, Minimap.PinType.EventArea, string.Empty, false, false); area.m_worldSize = AdventureDataManager.Config.TreasureMap.MinimapAreaRadius * AreaScale; var label = Localization.instance.Localize("$mod_epicloot_treasurechest_minimappin", Localization.instance.Localize($"$biome_{chestInfo.Biome.ToString().ToLowerInvariant()}"), (chestInfo.Interval + 1).ToString()); var pin = __instance.AddPin(position, EpicLoot.TreasureMapPinType, label, false, false); if (DebugMode) { var debugPin = __instance.AddPin(chestInfo.Position, Minimap.PinType.Icon3, $"{chestInfo.Position.x:0.0}, {chestInfo.Position.z:0.0}", false, false); TreasureMapPins.Add(key, new AreaPinInfo() { Pin = pin, Area = area, DebugPin = debugPin }); } else { TreasureMapPins.Add(key, new AreaPinInfo() { Pin = pin, Area = area }); } } } var currentBounties = adventureSaveData.GetInProgressBounties(); var oldBountyPins = BountyPins.Where(pinEntry => !currentBounties.Exists(x => x.ID == pinEntry.Key)).ToList(); foreach (var pinEntry in oldBountyPins) { __instance.RemovePin(pinEntry.Value.Pin); __instance.RemovePin(pinEntry.Value.Area); BountyPins.Remove(pinEntry.Key); } foreach (var bounty in currentBounties) { var key = bounty.ID; if (!BountyPins.ContainsKey(key)) { var position = bounty.Position + bounty.MinimapCircleOffset; var area = __instance.AddPin(position, Minimap.PinType.EventArea, string.Empty, false, false); area.m_worldSize = AdventureDataManager.Config.TreasureMap.MinimapAreaRadius * AreaScale; var label = Localization.instance.Localize("$mod_epicloot_bounties_minimappin", AdventureDataManager.GetBountyName(bounty)); var pin = __instance.AddPin(position, EpicLoot.BountyPinType, label, false, false); if (DebugMode) { var debugPin = __instance.AddPin(bounty.Position, Minimap.PinType.Icon3, $"{bounty.Position.x:0.0}, {bounty.Position.z:0.0}", false, false); BountyPins.Add(key, new AreaPinInfo() { Pin = pin, Area = area, DebugPin = debugPin }); } else { BountyPins.Add(key, new AreaPinInfo() { Pin = pin, Area = area }); } } } }
private static bool Minimap_UpdateProfilePins(Minimap __instance, ref Minimap.PinData ___m_deathPin) { PlayerProfile prof = Game.instance.GetPlayerProfile(); if (prof.HaveDeathPoint() && ___m_deathPin == null) { var text = string.Empty; if (Settings.MoreDetailsOnDeathMarkers.Value) { text = prof.GetName() + "\n" + DateTime.Now.ToString("hh:mm"); } var newpin = __instance.AddPin(prof.GetDeathPoint(), Minimap.PinType.Death, text, true, false); ___m_deathPin = newpin; if (Settings.ShareDeathMarkers.Value) { Plugin.SendPin(newpin, text); } } bool done = false; if (Settings.ShowCarts.Value) { if (cartZDOs == null) { cartZDOs = new List <ZDO>(); } var cartIndex = index; while (!done && cartIndex - index < sectorsPerFrame) { done = done || ZDOMan.instance.GetAllZDOsWithPrefabIterative(CartPrefab, cartZDOs, ref cartIndex); } cartZDOs = cartZDOs .Distinct() .Where(x => x.GetPosition().y > ZoneSystem.instance.m_waterLevel - 40f) .ToList(); if (cartPins == null) { cartPins = new List <Minimap.PinData>(); } if (cartPins.Count != cartZDOs.Count) { foreach (var pin in cartPins) { Minimap.instance.RemovePin(pin); } cartPins.Clear(); for (int i = 0; i < cartZDOs.Count; i++) { var pos = cartZDOs[i].GetPosition(); var newPin = Minimap.instance.AddPin(pos, Minimap.PinType.Icon1, string.Empty, false, false); newPin.m_icon = Assets.cartSprite; cartPins.Add(newPin); } } for (int i = 0; i < cartZDOs.Count; i++) { cartPins[i].m_pos = cartZDOs[i].GetPosition(); } } if (Settings.ShowBoats.Value) { if (raftZDOs == null) { raftZDOs = new List <ZDO>(); } if (karveZDOs == null) { karveZDOs = new List <ZDO>(); } if (longboatZDOs == null) { longboatZDOs = new List <ZDO>(); } raftZDOs.RemoveAll(x => x == null || !x.IsValid()); karveZDOs.RemoveAll(x => x == null || !x.IsValid()); longboatZDOs.RemoveAll(x => x == null || !x.IsValid()); var raftIndex = index; var karveIndex = index; var longIndex = index; while (!done && raftIndex - index < sectorsPerFrame) { done = done || ZDOMan.instance.GetAllZDOsWithPrefabIterative(RaftPrefabName, raftZDOs, ref raftIndex); ZDOMan.instance.GetAllZDOsWithPrefabIterative(KarvePrefabName, karveZDOs, ref karveIndex); ZDOMan.instance.GetAllZDOsWithPrefabIterative(LongboatPrefabName, longboatZDOs, ref longIndex); } raftZDOs = raftZDOs.Distinct().ToList(); karveZDOs = karveZDOs.Distinct().ToList(); longboatZDOs = longboatZDOs.Distinct().ToList(); var boatZDOs = raftZDOs.Select(x => new Tuple <ZDO, string>(x, Localization.instance.Localize("$ship_raft"))) .Concat(karveZDOs.Select(x => new Tuple <ZDO, string>(x, Localization.instance.Localize("$ship_karve")))) .Concat(longboatZDOs.Select(x => new Tuple <ZDO, string>(x, Localization.instance.Localize("$ship_longship")))) .Where(x => x.Item1.GetPosition().y > ZoneSystem.instance.m_waterLevel - 40f) // Attempt to remove/hide items below the map .ToList() ; if (boatPins == null) { boatPins = new List <Minimap.PinData>(); } if (boatPins.Count != boatZDOs.Count) { foreach (var pin in boatPins) { Minimap.instance.RemovePin(pin); } boatPins.Clear(); for (int i = 0; i < boatZDOs.Count; i++) { var pos = boatZDOs[i].Item1.GetPosition(); var newPin = Minimap.instance.AddPin(pos, Minimap.PinType.Icon1, boatZDOs[i].Item2, false, false); newPin.m_icon = Assets.boatSprite; boatPins.Add(newPin); } } for (int i = 0; i < boatZDOs.Count; i++) { boatPins[i].m_pos = boatZDOs[i].Item1.GetPosition(); boatPins[i].m_name = boatZDOs[i].Item2; } } if (done) { index = 0; } else { index += sectorsPerFrame; } return(true); }