Veilheim/Map/PortalsOnMap.cs
/// <summary>
///     Add and remove pins in internal list based on a list of portals
/// </summary>
/// <param name="portals"></param>
Add and remove pins in internal list based on a list of portals
Add and remove pins in internal list based on a list of portals
public static void UpdatePins(PortalList portals)
        {
            Logger.LogInfo("Updating pins of portals on minimap");
            lock (portalPins)
            {
                foreach (var portal in portals.FindAll(x => x.m_con))
                {
                    var foundPin = portalPins.FirstOrDefault(x => x.m_pos == portal.m_pos);
                    if (foundPin != null)
                    {
                        if (foundPin.m_name != portal.m_tag)
                        {
                            portalPins.Remove(foundPin);
                            portalPins.Add(CreatePinData(portal.m_pos, Minimap.PinType.Icon4, portal.m_tag, false, false));
                        }
                    }
                    else
                    {
                        portalPins.Add(CreatePinData(portal.m_pos, Minimap.PinType.Icon4, portal.m_tag, false, false));
                    }
                }
                foreach (var portal in portals.FindAll(x => !x.m_con))
                {
                    var foundPin = portalPins.FirstOrDefault(x => x.m_pos == portal.m_pos);
                    if (foundPin != null)
                    {
                        if (foundPin.m_name != portal.m_tag)
                        {
                            portalPins.Remove(foundPin);
                            portalPins.Add(CreatePinData(portal.m_pos, Minimap.PinType.Icon4, portal.m_tag, false, false));
                        }
                    }
                    else
                    {
                        portalPins.Add(CreatePinData(portal.m_pos, Minimap.PinType.Icon4, portal.m_tag, false, false));
                    }
                }
                foreach (var kv in portalPins.ToList())
                {
                    if (portals.All(x => x.m_pos != kv.m_pos))
                    {
                        portalPins.Remove(kv);
                    }
                }
            }
            Logger.LogInfo("Portal pins updated succesfully");
        }
public static void UpdatePins ( PortalList portals ) { Logger . LogInfo ( " " ) ; lock ( portalPins ) { foreach ( var portal in portals . FindAll ( x => x . m_con ) ) { var foundPin = portalPins . FirstOrDefault ( x => x . m_pos == portal . m_pos ) ; if ( foundPin != null ) { if ( foundPin . m_name != portal . m_tag ) { portalPins . Remove ( foundPin ) ; portalPins . Add ( CreatePinData ( portal . m_pos , Minimap . PinType . Icon4 , portal . m_tag , false , false ) ) ; } } else { portalPins . Add ( CreatePinData ( portal . m_pos , Minimap . PinType . Icon4 , portal . m_tag , false , false ) ) ; } } foreach ( var portal in portals . FindAll ( x => ! x . m_con ) ) { var foundPin = portalPins . FirstOrDefault ( x => x . m_pos == portal . m_pos ) ; if ( foundPin != null ) { if ( foundPin . m_name != portal . m_tag ) { portalPins . Remove ( foundPin ) ; portalPins . Add ( CreatePinData ( portal . m_pos , Minimap . PinType . Icon4 , portal . m_tag , false , false ) ) ; } } else { portalPins . Add ( CreatePinData ( portal . m_pos , Minimap . PinType . Icon4 , portal . m_tag , false , false ) ) ; } } foreach ( var kv in portalPins . ToList ( ) ) { if ( portals . All ( x => x . m_pos != kv . m_pos ) ) { portalPins . Remove ( kv ) ; } } } Logger . LogInfo ( " " ) ; }
Add and remove pins in internal list based on a list of portals
Add and remove pins in internal list based on a list of portals
// prevent MT crashing // Add connected portals (separated connected and unconnected, maybe show another icon?) // Was pin already added? // Did the pin's name change? // Remove pin at location and readd with new name // Add new pin // Add unconnected portals (maybe show another icon / text?) // Was pin already added? // Did the pin's name change? // Remove pin at location and readd with new name // Add new pin // Remove destroyed portals from map // doesn't really react on portal destruction, only works if after a portal was destroyed, someone set the name on another portal
portals
PortalList
None