private StateCommand ChangeState(Type type, object[] args) { StateCommand prevState = _state; _state = null; if (prevState != null) { prevState.Terminate(); StopAllCommands(); } _state = CreateState(type, args); #if UNITY_EDITOR _stateHistory.Add(type.Name); StateHistory = _stateHistory.ToArray(); #endif _state.AsyncToken.AddResponder(new Responder <StateCommand>(OnStateFinished, OnStateFinished)); if (Changed != null) { Changed(this); } return(_state); }
private void OnStateFinished(StateCommand state) { if (state == _state) { _state = null; StopAllCommands(); _container.Next(state); } }
private void OnDownloadFault(StateCommand command) { DownloadManagerCommand downloadManagerCommand = (DownloadManagerCommand)command; _downloadQueue.Remove(downloadManagerCommand.File.Path); if (Fault != null) { Fault(downloadManagerCommand.File); } }
private void OnDownloadFinished(StateCommand command) { DownloadManagerCommand downloadManagerCommand = (DownloadManagerCommand)command; _downloadQueue.Remove(downloadManagerCommand.File.Path); if (Complete != null) { Complete(downloadManagerCommand.File); } }
public StateCommand Execute(Type type, params object[] args) { StateCommand command = (StateCommand)MonoCommand.ExecuteOn(type, _container.GameObject, args); _commands.Add(command); command.AsyncToken.AddResponder(new Responder <StateCommand>(delegate(StateCommand result) { _commands.Remove(result); })); return(command); }
public void Next(StateCommand prevState) { NextStatePair pair = null; if (prevState != null) { pair = _stateFlow.Find(delegate(NextStatePair nextStatePair) { return(nextStatePair.Target == prevState.GetType()); }); } if (pair != null) { if (prevState.FinishedWithSuccess) { _stateMachine.ApplyState(pair.Success, _container); } else { _stateMachine.ApplyState(pair.Fail, _container); } } }
public void Next(StateCommand previousState) { }