Example #1
0
    public void Update(FSM fsm)
    {
        AIActionProximityBase action = null;

        if (_agent.CurrentActions.Count > 0)
        {
            action = _agent.CurrentActions.Peek() as AIActionProximityBase;
        }
        if (action == null || !_nav.Valid() || action.destination == Vector3.zero)
        {
            fsm.PopState(); // move
            fsm.PopState(); // perform
            fsm.PushState(_agent.IdleState);
            return;
        }
        if (_nav.RemainingDistance() <= SuccessDistance)
        {
            action.isInRange = true;
            fsm.PopState();
            return;
        }
        _rethinkTime += Time.deltaTime;
        if (_rethinkTime > RethinkDelay)
        {
            _rethinkTime -= RethinkDelay;
            Rethink();
        }

        /*   // get the agent to move itself
         * if (dataProvider.moveAgent(action))
         * {
         *    fsm.popState();
         * } */
    }