Beispiel #1
0
		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;
			}
		}
Beispiel #2
0
		protected void OnPathQueryReply(PathQuery query)
		{
			if (query != m_currentQuery)
			{
				// deprecated query
				return;
			}
			m_currentQuery = null;

		    FollowPath(query.Path);
		}
Beispiel #3
0
		/// <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;
		}
Beispiel #4
0
		/// <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;
		}
Beispiel #5
0
		protected void OnPathQueryReply(PathQuery query)
		{
			if (query != m_currentQuery)
			{
				// deprecated query
				return;
			}
			m_currentQuery = null;

			// TODO: Support paths
			MoveToDestination();
		}
Beispiel #6
0
		/// <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));
		}
Beispiel #9
0
 public void QueryDirectPath(PathQuery query)
 {
     var wayPoints = WorldMap.GetDirectPath(id, query.From, query.To);
     query.Reply(new Path(wayPoints));
 }
Beispiel #10
0
 public void FindPath(PathQuery query)
 {
     FindPath(query.From, query.To, query.Path);
     query.Reply();
 }
Beispiel #11
0
		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();
		}