Exemplo n.º 1
0
            public virtual int Update()
            {
                GlobalState?.Execute(owner);
                int?result = State?.Execute(owner);

                return(result.GetValueOrDefault(0));
            }
Exemplo n.º 2
0
 public void Update()
 {
     if (GlobalState != null)
     {
         GlobalState.Execute(Owner);
     }
     if (CurrentState != null)
     {
         CurrentState.Execute(Owner);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Call this to update the FSM.
        /// </summary>
        public void Update()
        {
            // if a global state exists, call its execute method, else do nothing
            if (GlobalState != null)
            {
                GlobalState.Execute(Owner);
            }

            // same for the current state
            if (CurrentState != null)
            {
                CurrentState.Execute(Owner);
            }
        }
Exemplo n.º 4
0
        /// <summary>Update states in state machine</summary>
        public void Update()
        {
            //if state machine is not active, then skip
            if (!_running)
            {
                // Initialize and start state machine
                // If global state assigned by external thread
                if (InitState != null)
                {
                    SetGlobalState(InitState);
                    InitState = null;

                    _running = true;
                }
                else
                {
                    return;
                }
            }

            //update the global state (if it exists and has not already exited or finished)
            if (GlobalState != null)
            {
                if (GlobalState.Started)
                {
                    GlobalState.Execute(Entity);
                }
                else if (GlobalState.Completed)
                {
                    // Global state doesn't have track
                    // So if it completed stop state machine as well
                    _running = false;
                }
            }

            //update the current state (if it exists and has not already exited or finished)
            if (CurrentState != null)
            {
                if (CurrentState.Started)
                {
                    CurrentState.Execute(Entity);
                }
                else if (CurrentState.Completed)
                {
                    // if current state has track of previous state
                    // than auto-revert, otherwise set it null
                    if (CurrentState.PreviousState != null)
                    {
                        RevertToPreviousState();
                    }
                    else
                    {
                        CurrentState = null;
                        OnStateChangedUnknown();
                    }
                }
            }

            //update last updated variable
            LastUpdated = DateTime.Now;
        }
Exemplo n.º 5
0
 /// <summary>
 /// Call to update the state machine.
 /// Calls the execute functions for the global and/or current states
 /// </summary>
 public void Update()
 {
     GlobalState?.Execute(_owner);
     CurrentState?.Execute(_owner);
 }
Exemplo n.º 6
0
 public virtual void Update()
 {
     GlobalState?.Execute(owner);
     State?.Execute(owner);
 }