/// <summary> /// Resets the agent's current drive path /// </summary> private void ResetPath() { m_acoConnectionPath = null; m_currentTargetACOConn = null; m_currentTargetACOConnIndex = 0; m_currentACOConnRouteIndex = 0; m_startToACOPath = null; m_startToACONavInfo = null; m_acoToStartPath = null; m_acoToStartNavInfo = null; m_totalDuration = 0f; }
/// <summary> /// Drives the along a certain connection path /// </summary> /// <param name="startToACOAStarPath">A* path from the agent start to the ACO path</param> /// <param name="acoConnections">The ACO connections path that goal around all goals</param> /// <param name="acoToStartAStarPath">A* path from the final ACO node back to the agent's start path</param> public void SetMovePath(List <Connection> startToACOAStarPath, List <ACOConnection> acoConnections, List <Connection> acoToStartAStarPath) { if (acoConnections == null || acoConnections != null && acoConnections.Count <= 0) { Debug.LogError("Unable to drive along connection path. acoConnections invalid"); return; } /// Set navigation paths for this agent. Contains three paths: /// Agent start to the initial ACO start node /// The Total ACO path /// Final ACO node to the initial Agent start node m_acoConnectionPath = acoConnections; m_startToACOPath = startToACOAStarPath; m_acoToStartPath = acoToStartAStarPath; /// Set Move states to go from Start to the ACO start m_currentDrivePathTarget = NavigationTarget.StartToACO; /// Set movement vars to default values m_currentTargetACOConnIndex = 0; m_currentACOConnRouteIndex = 0; m_currentTargetACOConn = m_acoConnectionPath[m_currentTargetACOConnIndex]; /// Set NavigateInfo for each A* path m_startToACONavInfo = new NavigateToInfo { TargetNode = m_startToACOPath.FirstOrDefault().ToNode, TargetIndex = 0 }; m_acoToStartNavInfo = new NavigateToInfo { TargetNode = m_acoToStartPath.FirstOrDefault().ToNode, TargetIndex = 0, }; /// Set start position for agent this.transform.position = startToACOAStarPath.FirstOrDefault().FromNode.transform.position; Debug.Log($"Agent '{this.name}' path set! Start to ACO '{m_startToACOPath.Count}' Waypoints, ACO Total '{m_acoConnectionPath.Count}' waypoints, ACO to Start '{m_acoToStartPath.Count}' waypoints"); m_ui.SetStatusText($"New Path: Moving to '{m_acoConnectionPath[m_acoConnectionPath.Count - 1].ToNode.name}'"); }