public async void OnNewInputConnectionAsync(object sender, NewConnectionArgs e) { var newEntity = await Game.CreateEntityAsync(); NewInputEntityCreated?.Invoke(this, new SharperEntityEventArgs(newEntity)); await RegisterComponentAsync(new SharperInputComponent(newEntity, e.Connection)); }
public async Task AssignNewCommandAsync(IUniverseCommandInfo commandInfo, IUniverseCommandSource bindingSource) { var inputComponent = Components.FirstOrDefault(x => x.BindingSource.SourceIsSameAsBindingSource(bindingSource)); if (inputComponent == null) { var newEntity = await Game.CreateEntityAsync(); NewInputEntityCreated?.Invoke(this, new SharperEntityEventArgs(newEntity)); await RegisterComponentAsync(newEntity, bindingSource); inputComponent = Components.First(x => x.BindingSource.SourceIsSameAsBindingSource(bindingSource)); } inputComponent.CurrentCommand = commandInfo; }