public void RemoveRequest(IPathRequestQuery requestQuery)
    {
        if (!m_bInitialized)
        {
            UnityEngine.Debug.LogError("PathManagerComponent isn't yet fully intialized. Wait until Start() has been called. Can't call ConsumeRequest.");
            return;
        }

        if (requestQuery == null)
        {
            return;
        }

        PathRequest request = GetPathRequest(requestQuery);

        if (request == null)
        {
            return;
        }

        // Request is no longer "completed"
        m_completedRequests.Remove(request);

        // In case the request is active, remove it.
        m_activeRequests.Remove(request);

        // Return the request back to the pool so that it can be used again.
        m_pathPlannerPool.Return(request.PathPlanner);
        m_requestPool.Enqueue(request);
    }
    private void OnPathRequestSucceeded(IPathRequestQuery request)
    {
        Vector3[] roughPath    = request.GetSolutionPath(m_pathAgent.PathManager.PathTerrain);
        Vector3[] steeringPath = roughPath;

        if (m_usePathSmoothing)
        {
            // Smooth the path
            Vector3[] aLeftPortalEndPts;
            Vector3[] aRightPortalEndPts;
            m_pathAgent.PathManager.PathTerrain.ComputePortalsForPathSmoothing(roughPath, out aLeftPortalEndPts, out aRightPortalEndPts);
            steeringPath = PathSmoother.Smooth(roughPath, request.GetStartPos(), request.GetGoalPos(), aLeftPortalEndPts, aRightPortalEndPts);
        }

        if (sFinded != null)
        {
            sFinded(steeringPath);
        }

        if (m_pathGroup != null)
        {
//			Debug.Log("steeringPath=" + steeringPath.Length);
            m_pathGroup.SetPath(steeringPath, false);
            StartCoroutine(DelayDestory());
        }
        else
        {
            // Begin steering along this path
            m_steeringAgent.SteerAlongPath(steeringPath, m_pathAgent.PathManager.PathTerrain);
        }
    }
    void Awake()
    {
        m_bInitialized = false;
        m_query        = null;

        if (m_pathManager == null)
        {
            GameObject go = GameObject.Find("PathManager");
            if (go != null)
            {
                m_pathManager = go.GetComponent <PathManagerComponent>();
            }
        }

//		if ( m_pathManager == null )
//		{
//			Debug.LogError("PathAgentComponent does not have a PathManagerComponent set. You need to set this up through the Inspector window");
//		}
//		else
//		{
//			m_bInitialized = true;
//		}


        m_bInitialized = true;
    }
Example #4
0
    public void CancelActiveRequest()
    {
        if (m_query == null)
        {
            return;
        }

        m_pathManager.RemoveRequest(m_query);
        m_query = null;
    }
    private PathRequest GetPathRequest(IPathRequestQuery requestQuery)
    {
        PathRequest foundRequest = null;

        System.Diagnostics.Debug.Assert(requestQuery is PathRequest);
        if (requestQuery is PathRequest)
        {
            foundRequest = requestQuery as PathRequest;
        }
        return(foundRequest);
    }
    void Awake()
    {
        m_bInitialized = false;
        m_query        = null;

        /*if ( m_pathManager == null )
         * {
         *      Debug.LogError("PathAgentComponent does not have a PathManagerComponent set. You need to set this up through the Inspector window");
         * }
         * else*/
        {
            m_bInitialized = true;
        }
    }
	void Awake()
	{
		m_bInitialized = false;
		m_query = null;
		
		if ( m_pathManager == null )
		{
			Debug.LogError("PathAgentComponent does not have a PathManagerComponent set. You need to set this up through the Inspector window");
		}
		else
		{
			m_bInitialized = true;
		}
	}
Example #8
0
    public bool RequestPath(PathPlanParams pathPlanParams)
    {
        if (!m_bInitialized)
        {
            return(false);
        }

        m_pathManager.RemoveRequest(m_query);
        m_query = m_pathManager.RequestPathPlan(pathPlanParams, this);
        if (m_query == null)
        {
            return(false);
        }
        return(true);
    }
    void Awake()
    {
        m_pathManager = GameObject.FindObjectOfType(typeof(PathManagerComponent)) as PathManagerComponent;

        m_bInitialized = false;
        m_query        = null;

        if (m_pathManager == null)
        {
            Debug.LogError("PathAgentComponent does not have a PathManagerComponent set. You need to set this up through the Inspector window");
        }
        else
        {
            m_bInitialized = true;
        }
    }
	private void OnPathRequestSucceeded(IPathRequestQuery request)
	{
		Vector3[] roughPath = request.GetSolutionPath(m_pathAgent.PathManager.PathTerrain);
		Vector3[] steeringPath = roughPath;
		
		if ( m_usePathSmoothing )
		{
			// Smooth the path
			Vector3[] aLeftPortalEndPts;
			Vector3[] aRightPortalEndPts;
			m_pathAgent.PathManager.PathTerrain.ComputePortalsForPathSmoothing( roughPath, out aLeftPortalEndPts, out aRightPortalEndPts );
			steeringPath = PathSmoother.Smooth(roughPath, request.GetStartPos(), request.GetGoalPos(), aLeftPortalEndPts, aRightPortalEndPts);
		}
		
		// Begin steering along this path
		m_steeringAgent.SteerAlongPath( steeringPath, m_pathAgent.PathManager.PathTerrain );
	}
Example #11
0
    private void OnPathRequestSucceeded(IPathRequestQuery request)
    {
        Vector3[] roughPath    = request.GetSolutionPath(m_pathAgent.PathManager.PathTerrain);
        Vector3[] steeringPath = roughPath;

        if (m_usePathSmoothing)
        {
            // Smooth the path
            Vector3[] aLeftPortalEndPts;
            Vector3[] aRightPortalEndPts;
            m_pathAgent.PathManager.PathTerrain.ComputePortalsForPathSmoothing(roughPath, out aLeftPortalEndPts, out aRightPortalEndPts);
            steeringPath = PathSmoother.Smooth(roughPath, request.GetStartPos(), request.GetGoalPos(), aLeftPortalEndPts, aRightPortalEndPts);
        }

        // Begin steering along this path
        m_steeringAgent.SteerAlongPath(steeringPath, m_pathAgent.PathManager.PathTerrain);
    }
Example #12
0
    void Awake()
    {
        m_bInitialized = false;
        m_query        = null;

        if (m_pathManager == null)
        {
            GameObject pathGridObject = GameObject.FindGameObjectWithTag("PathManager");
            if (pathGridObject != null)
            {
                m_pathManager = pathGridObject.GetComponent <PathManagerComponent>();
            }
        }

        if (m_pathManager == null)
        {
            Debug.LogError("PathAgentComponent does not have a PathManagerComponent set. You need to set this up through the Inspector window");
        }
        else
        {
            m_bInitialized = true;
        }
    }
 private PathRequest GetPathRequest(IPathRequestQuery requestQuery)
 {
     PathRequest foundRequest = null;
     System.Diagnostics.Debug.Assert(requestQuery is PathRequest);
     if (requestQuery is PathRequest)
     {
         foundRequest = requestQuery as PathRequest;
     }
     return foundRequest;
 }
	public void CancelActiveRequest()
	{
		if ( m_query == null )
		{
			return;
		}
			
		m_pathManager.RemoveRequest(m_query);	
		m_query = null;
	}
Example #15
0
 private void OnPathRequestSucceeded(IPathRequestQuery request)
 {
     Vector3[] roughPath = request.GetSolutionPath(m_pathAgent.PathManager.PathTerrain);
     m_steeringAgent.SteerAlongPath(roughPath, PathTerrain);
 }
	public void OnPathAgentRequestSucceeded(IPathRequestQuery request)
	{
		SendMessageUpwards("OnPathRequestSucceeded", request, SendMessageOptions.DontRequireReceiver);
	}
Example #17
0
 public void OnPathAgentRequestFailed()
 {
     m_query = null;
     SendMessageUpwards("OnPathRequestFailed", SendMessageOptions.DontRequireReceiver);
 }
Example #18
0
 public void OnPathAgentRequestSucceeded(IPathRequestQuery request)
 {
     SendMessageUpwards("OnPathRequestSucceeded", request, SendMessageOptions.DontRequireReceiver);
 }
	public void OnPathAgentRequestFailed()
	{
		m_query = null;
		SendMessageUpwards("OnPathRequestFailed", SendMessageOptions.DontRequireReceiver);
	}
    public void RemoveRequest(IPathRequestQuery requestQuery)
    {
		if ( !m_bInitialized )
		{
			UnityEngine.Debug.LogError("PathManagerComponent isn't yet fully intialized. Wait until Start() has been called. Can't call ConsumeRequest.");
			return;
		}
		
		if ( requestQuery == null )
		{
			return;
		}
		
        PathRequest request = GetPathRequest(requestQuery);
		
		if ( request == null )
		{
			return;
		}

        // Request is no longer "completed"
        m_completedRequests.Remove(request);
		
		// In case the request is active, remove it.
		m_activeRequests.Remove(request);

        // Return the request back to the pool so that it can be used again.
        m_pathPlannerPool.Return(request.PathPlanner);
        m_requestPool.Enqueue(request);
    }
	public bool RequestPath(PathPlanParams pathPlanParams)
	{
		if ( !m_bInitialized )
		{
			return false;
		}
		
	    m_pathManager.RemoveRequest(m_query);
		m_query = m_pathManager.RequestPathPlan(pathPlanParams, this);
		if ( m_query == null )
		{
			return false;
		}
		return true;
	}