public async Task SendPlayerEventAsync(PlayerEvent playerEvent) { Func <GameEvent, Task> onGameEventAsync; _playerEvents.Enqueue(playerEvent); onGameEventAsync = OnGameEventAsync; if (onGameEventAsync != null) { if (_gameEvents.Count == 0) { // Always send an empty GameEvent as an ACK. await onGameEventAsync(new GameEvent()); } else { while (true) { GameEvent gameEvent; _gameEvents.TryDequeue(out gameEvent); if (gameEvent == null) { break; } await onGameEventAsync(gameEvent); } } } }
public async Task SendPlayerEventAsync(PlayerEvent playerEvent) { Func<GameEvent, Task> onGameEventAsync; _playerEvents.Enqueue(playerEvent); onGameEventAsync = OnGameEventAsync; if (onGameEventAsync != null) { if (_gameEvents.Count == 0) { // Always send an empty GameEvent as an ACK. await onGameEventAsync(new GameEvent()); } else { while (true) { GameEvent gameEvent; _gameEvents.TryDequeue(out gameEvent); if (gameEvent == null) break; await onGameEventAsync(gameEvent); } } } }
public async Task SendPlayerEventAsync(PlayerEvent playerEvent) { if (!_isConnected) { return; } await _stream.WriteObjectAsync(playerEvent); }
private void HandlePlayerEvent(Channel channel, PlayerEvent playerEvent) { if (playerEvent.PositionData != null) { channel.Player.PositionData = playerEvent.PositionData; } if (playerEvent.BlockUpdates != null) { AddBlockUpdates(playerEvent.BlockUpdates); } }
public PlayerEvent CreatePlayerEvent() { var playerEvent = new PlayerEvent(); playerEvent.PositionData = new PositionComponent { Placement = PositionData.Placement, Velocity = PositionData.Velocity, IsFalling = PositionData.IsFalling, InternalPos = PositionData.InternalPos, }; if (_blockUpdates.Count > 0) { playerEvent.BlockUpdates = _blockUpdates; _blockUpdates = new List <BlockUpdateData>(); } return(playerEvent); }
private void HandlePlayerEvent(Channel channel, PlayerEvent playerEvent) { if (playerEvent.PositionData != null) { channel.Player.PositionData = playerEvent.PositionData; } if (playerEvent.BlockUpdates != null) { AddBlockUpdates(playerEvent.BlockUpdates); } }