예제 #1
0
 internal void ExecuteAction(ActionToken action, object data)
 {
     if (actionHandlerDic.TryGetValue(action, out StateActionHandler handler))
     {
         handler(action, data);
     }
 }
예제 #2
0
 protected void UnregisterAction(ActionToken action)
 {
     if (action == null)
     {
         throw new ArgumentNullException("StateBase::UnregisterAction->action is null");
     }
     if (actionHandlerDic.ContainsKey(action))
     {
         actionHandlerDic.Remove(action);
     }
 }
예제 #3
0
        public void PerformAction(ActionToken action, object data)
        {
            if (action == null)
            {
                throw new ArgumentNullException("StateMachine::PreformAction->actoin is null");
            }

            if (CurrentState == null)
            {
                throw new InvalidOperationException("StateMachine::PreformAction->CurrentState is null");
            }

            CurrentState.ExecuteAction(action, data);
        }
예제 #4
0
        protected void RegisterAction(ActionToken action, StateActionHandler actionHandler)
        {
            if (action == null)
            {
                throw new ArgumentNullException("StateBase::RegisterAction->action is null");
            }

            if (actionHandler == null)
            {
                throw new ArgumentNullException("StateBase::RegisterAction->actionHandler is null");
            }

            if (actionHandlerDic.ContainsKey(action))
            {
                throw new InvalidOperationException($"Action has been registered.action = {action}.");
            }
            actionHandlerDic.Add(action, actionHandler);
        }
예제 #5
0
 public void PerformAction(ActionToken action)
 {
     PerformAction(action, null);
 }