public NavMeshInstance(NavMesh mesh, int startNode, bool reverse, int timeOut) { m_navMesh = mesh; m_currentNode = new Node(startNode); m_startNode = startNode; m_reverse = reverse; timeOut = Math.Max(0, timeOut); m_timeOut = timeOut; }
/// <summary> /// Sets up where the bot should be walking /// </summary> /// <param name="Bot">ID of the bot</param> /// <param name="Positions">List of positions the bot will move to</param> /// <param name="mode">List of what the bot should be doing inbetween the positions</param> public void SetBotMap(UUID Bot, List<Vector3> Positions, List<TravelMode> mode) { IRexBot bot; //Find the bot if (m_bots.TryGetValue(Bot, out bot)) { NavMesh mesh = new NavMesh(); int i = 0; foreach (Vector3 position in Positions) { //Add the position first mesh.AddNode(position); //Add the edge so that we know in which order the positions are and what to do between them if (i + 1 == Positions.Count) mesh.AddEdge(i, 0, mode[i]); else mesh.AddEdge(i, i + 1, mode[i]); i++; } if (true) { } //Tell the bot about it bot.SetPath(mesh, 0, false, 100000); } }
void OnFrame() { //This is our main updating loop // We use this to deal with moving the av to the next location that it needs to go to if (IsFollowing) { // FOLLOW an avatar - this is looking for an avatar UUID so wont follow a prim here - yet if (FollowSP == null) { m_Sp.Scene.TryGetAvatarByName(FollowName, out FollowSP); } //If its still null, the person doesn't exist, cancel the follow and return if (FollowSP == null) { IsFollowing = false; m_log.Warn("Could not find avatar " + FollowName); } else { //Only check so many times CurrentFollowTimeBeforeUpdate++; if (CurrentFollowTimeBeforeUpdate == FollowTimeBeforeUpdate) { NavMesh mesh = new NavMesh(); mesh.AddEdge(0, 1, ShouldFly ? Aurora.Framework.TravelMode.Fly : Aurora.Framework.TravelMode.Walk); mesh.AddNode(m_Sp.AbsolutePosition); //Give it the current pos so that it will know where to start mesh.AddEdge(1, 2, ShouldFly ? Aurora.Framework.TravelMode.Fly : Aurora.Framework.TravelMode.Walk); mesh.AddNode(FollowSP.AbsolutePosition); //Give it the new point so that it will head toward it SetPath(mesh, 0, false, 10000); //Set and go //Reset the time CurrentFollowTimeBeforeUpdate = -1; } } } else if (IsOnAPath) { lock(WayPoints) { if (WayPoints[CurrentWayPoint].ApproxEquals(m_Sp.AbsolutePosition, 1)) //Are we about to the new position? { //We need to update the waypoint then and send the av to a new location CurrentWayPoint++; if (WayPoints.Count >= CurrentWayPoint) { //We are at the last point, end the path checking IsOnAPath = false; return; } NavMesh mesh = new NavMesh(); //Build the next mesh to tell the bot where to go mesh.AddEdge(0, 1, ShouldFly ? Aurora.Framework.TravelMode.Fly : Aurora.Framework.TravelMode.Walk); mesh.AddNode(m_Sp.AbsolutePosition); //Give it the current pos so that it will know where to start mesh.AddEdge(1, 2, ShouldFly ? Aurora.Framework.TravelMode.Fly : Aurora.Framework.TravelMode.Walk); mesh.AddNode(WayPoints[CurrentWayPoint]); //Give it the new point so that it will head toward it SetPath(mesh, 0, false, 10000); //Set and go } } } }