private static void OnFoundPath(PathQuery query) { var chr = (Character)query.ContextHandler; var figurines = TerrainVisualizations.ClearVis(chr); // spawn figurines along the path if (query.Path == null) { chr.SendSystemMessage("Could not find path"); return; } var last = new NavFigurine(chr.Map, query.From); foreach (var vert in query.Path) { var fig = new NavFigurine(chr.Map, vert); var v = vert; last.SetOrientationTowards(ref v); last.ChannelObject = fig; figurines.Add(fig); last = fig; } }
protected void OnPathQueryReply(PathQuery query) { if (query != m_currentQuery) { // deprecated query return; } m_currentQuery = null; FollowPath(query.Path); }
/// <summary> /// Starts the MovementAI /// </summary> /// <returns>Whether already arrived</returns> public bool MoveToPoints(List<Vector3> points) { if (!m_owner.IsInWorld) { // something's wrong here m_owner.DeleteNow(); return false; } m_destination = points[points.Count - 1]; if (IsAtDestination) { return true; } // TODO: Consider flying units & liquid levels var pos = m_owner.Position; pos.Z += 5; m_currentQuery = new PathQuery(pos, ref m_destination, m_owner.ContextHandler, OnPathQueryReply); m_currentQuery.Path.Reset(points.Count); foreach (var point in points) { m_currentQuery.Path.Add(point); } m_currentQuery.Reply(); //m_owner.Map.Terrain.FindPath(m_currentQuery); // cannot move return false; }
/// <summary> /// Starts the MovementAI /// </summary> /// <returns>Whether already arrived</returns> public bool MoveTo(Vector3 destination, bool findPath = true) { if (!m_owner.IsInWorld) { // something's wrong here m_owner.DeleteNow(); return false; } m_destination = destination; if (IsAtDestination) { return true; } if (findPath) { // TODO: Consider flying units & liquid levels var pos = m_owner.Position; pos.Z += 5; m_currentQuery = new PathQuery(pos, ref destination, m_owner.ContextHandler, OnPathQueryReply); m_owner.Map.Terrain.FindPath(m_currentQuery); } else if (m_owner.CanMove) { // start moving MoveToDestination(); } // cannot move return false; }
protected void OnPathQueryReply(PathQuery query) { if (query != m_currentQuery) { // deprecated query return; } m_currentQuery = null; // TODO: Support paths MoveToDestination(); }
/// <summary> /// Starts the MovementAI /// </summary> /// <returns>Whether already arrived</returns> public bool MoveTo(Vector3 destination, bool findPath) { m_destination = destination; if (IsAtDestination) { return true; } if (findPath) { m_currentQuery = new PathQuery(m_owner.Position, ref destination, m_owner.ContextHandler, OnPathQueryReply); m_owner.Map.QueryDirectPath(m_currentQuery); } else if (m_owner.CanMove) { // start moving MoveToDestination(); } // cannot move return false; }
public void FindPath(PathQuery query) { query.Path.Reset(1); query.Path.Add(query.To); query.Reply(); }
public void QueryDirectPath(PathQuery query) { query.Reply(new Path(query.To)); }
public void QueryDirectPath(PathQuery query) { var wayPoints = WorldMap.GetDirectPath(id, query.From, query.To); query.Reply(new Path(wayPoints)); }
public void FindPath(PathQuery query) { FindPath(query.From, query.To, query.Path); query.Reply(); }
protected void OnPathQueryReply(PathQuery query) { if (query != m_currentQuery) { // deprecated query return; } m_currentQuery = null; if (query.Path != null) { _currentPath = query.Path; m_destination = _currentPath.Next(); } MoveToDestination(); }