protected override void Start()
        {
            base.Start();

            var state = _defaultState as IAIState;

            if (state.IsNullOrDestroyed() || !_stateMachine.Contains(state))
            {
                state         = _stateMachine.FirstOrDefault();
                _defaultState = state as Component;
            }
            _stateMachine.ChangeState(state);
        }
        protected override void Start()
        {
            base.Start();

            if (_startingCameraStyle is ICameraMovementControllerState)
            {
                if (_stateMachine.Contains(_startingCameraStyle as ICameraMovementControllerState))
                {
                    _stateMachine.ChangeState(_startingCameraStyle as ICameraMovementControllerState);
                }
            }
        }
        private void InitStateMachine()
        {
            IAIState state = null;

            if (_stateMachine != null)
            {
                state = _stateMachine.Current;
                _stateMachine.StateChanged -= this.OnStateChanged;
                _stateMachine = null;
            }

            switch (_stateSource)
            {
            case AIStateMachineSourceMode.SelfSourced:
                _stateMachine = TypedStateMachine <IAIState> .CreateFromComponentSource(this.gameObject);

                break;

            case AIStateMachineSourceMode.ChildSourced:
                _stateMachine = TypedStateMachine <IAIState> .CreateFromParentComponentSource(this.gameObject, false, true);

                break;
            }
            _stateMachine.StateChanged += this.OnStateChanged;
            foreach (var st in _stateMachine)
            {
                st.Init(this);
            }

            if (this.started)
            {
                if (!state.IsNullOrDestroyed() && _stateMachine.Contains(state))
                {
                    _stateMachine.ChangeState(state);
                }
                else
                {
                    _stateMachine.ChangeState((IAIState)null);
                }
            }
        }
Example #4
0
 bool IStateMachine <IAIState> .Contains(IAIState state)
 {
     return(_stateMachine.Contains(state));
 }
 public override bool Contains(Camera cam)
 {
     return _stateMachine.Contains(cam);
 }