/// <summary>Starts the MovementAI</summary> /// <returns>Whether already arrived</returns> public bool MoveTo(Vector3 destination, bool findPath = true) { if (!m_owner.IsInWorld) { m_owner.DeleteNow(); return(false); } m_destination = destination; if (IsAtDestination) { return(true); } if (findPath) { Vector3 position = m_owner.Position; position.Z += 5f; m_currentQuery = new PathQuery(position, ref destination, m_owner.ContextHandler, OnPathQueryReply); m_owner.Map.Terrain.FindPath(m_currentQuery); } else if (m_owner.CanMove) { MoveToDestination(); } 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); }