public override async Task CycleUpdateAsync(int deltaMs) { var commands = await _input.GetEntitiesByCommandInfoTypesAsync(typeof(ExitCommandInfo), typeof(AnswerCommandInfo)); foreach (var command in commands) { switch (command.Value) { case ExitCommandInfo _: _input.GetConnectionByEntity(command.Key).Disconnect(); break; case AnswerCommandInfo a: _guess = a.Guess; _inputEntity = command.Key; _gameState = GameState.Answer; var commandEntityContext = command.Key; var componentICareAbout = Components.Single(c => c.ControllingEntity == commandEntityContext); break; default: break; } } switch (_gameState) { case GameState.Question: //await outputHandler.Invoke($"{left} + {right}"); if (_inputEntity != null) { var left = _random.Next(1, 10); var right = _random.Next(1, 10); _answer = left + right; _input.GetConnectionByEntity(_inputEntity).Send($"{left} + {right}"); _gameState = GameState.Answer; } break; case GameState.Answer: if (_guess == _answer) { _guess = -1; //await outputHandler.Invoke("Correct!\n"); _gameState = GameState.Question; _input.GetConnectionByEntity(_inputEntity).Send($"Correct!"); } break; } }
public override async Task CycleUpdateAsync(Func <string, Task> outputHandler) { await ResolveCommandsAsync(await _inputSystem.GetEntitiesByCommandInfoTypesAsync(typeof(TestCommandInfo))); foreach (var comp in Components) { if (comp.State != _prevStates[comp]) { await outputHandler.Invoke($"state is now {comp.State}"); } _prevStates[comp] = comp.State; } }
public override async Task CycleUpdateAsync(int deltaMs) { await ResolveCommandsAsync(await _inputSystem.GetEntitiesByCommandInfoTypesAsync(typeof(TestCommandInfo))); foreach (var comp in Components) { if (comp.State != _prevStates[comp]) { var connection = _inputSystem.GetConnectionByEntity(comp.OwnerEntity); connection.Send($"State is now {comp.State}"); } _prevStates[comp] = comp.State; } }
public override async Task CycleUpdateAsync(Func <string, Task> outputHandler) { await ResolveCommandsAsync(await _inputSystem.GetEntitiesByCommandInfoTypesAsync(typeof(ExploreCommandInfo)), outputHandler); }