private void OnChainDone(bool success) { _chain = null; if (success) { _container.CurrentState = _container.NextState; } else { Debug.LogError($"GameFlowService :: OnChainDone : Can't process state {_container.NextState}"); } }
static void Main(string[] args) { using (var node = new Node(new Uri("http://localhost:9000/in"))) { node.Start(); var simpleTracker = EventTracker <SimpleEventTrackerFactory> .Create(); var store = new EventTrackerStore(); store.Add(simpleTracker, node); var fileSystemSensor = FileSystemSensor.CreateWithPathAndType("C:\\work", "FileSensorMessage"); var processorLoadingSensor = ProcessorLoadingSensor.CreateWithType("ProcessorMessage"); var fileSystemTrack = fileSystemSensor.Token(); var processorLoadingTrack = processorLoadingSensor.Token(); var fileSystemChain = new SimpleChain(); fileSystemChain.Add(fileSystemTrack).Add(fileSystemTrack).Add(fileSystemTrack); fileSystemChain.ReadyBlock = () => Console.WriteLine("FileSystemChain Ready!"); var processorLoadingChain = new SimpleChain(); processorLoadingChain.Add(processorLoadingTrack).Add(processorLoadingTrack); processorLoadingChain.ReadyBlock = () => Console.WriteLine("ProcessorLoadingChain Ready!"); var multiChain = new SimpleChain(); multiChain.Add(processorLoadingTrack).Add(fileSystemTrack).Add(processorLoadingTrack); multiChain.ReadyBlock = () => Console.WriteLine("MultiChain Ready!"); simpleTracker.AddChain(fileSystemChain); simpleTracker.AddChain(processorLoadingChain); simpleTracker.AddChain(multiChain); fileSystemSensor.Start(); processorLoadingSensor.Start(); Console.ReadLine(); } }
public void ChangeState() { if (_chain != null) { return; } if (_container.NextState == _container.CurrentState) { return; } _stateExitFactories.TryGetValue(_container.CurrentState, out var exitCurrent); _statePrepareFactories.TryGetValue(_container.NextState, out var prepareNext); _stateEnterFactories.TryGetValue(_container.NextState, out var enterNext); _chain = new SimpleChain(); _chain.Add(new StateProcessor(exitCurrent)); _chain.Add(new StateProcessor(prepareNext)); _chain.Add(new StateProcessor(enterNext)); _chain.Done += OnChainDone; _chain.Process(); }