public override void OnThink() { base.OnThink(); if (ControlMaster != null && m_Path != null && m_Path.Count > 0) { Vertex v = m_Path[m_Path.Count - 1]; Mobile m = ControlMaster; if (m.NetState != null) { if (Math.Abs(v.DistanceTo(m.Location) - v.DistanceTo(Location)) > 10) { Frozen = true; } else { Frozen = false; } if (CurrentWayPoint == null) { CurrentWayPoint = new WayPoint(); CurrentWayPoint.MoveToWorld(v.Location, Map); } int dist = v.DistanceTo(Location); if (dist < (v.Teleporter ? 1 : 3) || dist > 100) { m_Path.RemoveAt(m_Path.Count - 1); if (m_Path.Count > 0) { if (CurrentWayPoint == null) { CurrentWayPoint = new WayPoint(); } CurrentWayPoint.MoveToWorld(m_Path[m_Path.Count - 1].Location, Map); } else { Timer.DelayCall <Mobile>(TimeSpan.FromSeconds(3), CommandFollow, m); Say(1076051); // We have reached our destination CommandStop(m); } } } } }
public static Dictionary <int, Vertex> FindShops(string town, Point3D location) { if (town == null || !m_GraphDefinitions.ContainsKey(town)) { return(null); } List <Vertex> vertices = m_GraphDefinitions[town]; Dictionary <int, Vertex> shops = new Dictionary <int, Vertex>(); foreach (Vertex v in vertices) { foreach (int shop in v.Shops) { if (shops.ContainsKey(shop)) { Vertex d = shops[shop]; if (v.DistanceTo(location) < d.DistanceTo(location)) { shops[shop] = v; } } else { shops.Add(shop, v); } } } if (shops.Count > 0) { return(shops); } return(null); }