private void Apply(EnterGameCommand command, GameTime gameTime) { _grid.Enter(command.Entity, command.Coordinates); command.Entity.SetCoordinates(command.Coordinates, gameTime); command.Entity.Appears(); _pipeline.Subscribe(command.Entity); }
protected override void OnReceived(byte[] body) { ByteArrayArrayStream stream = new ByteArrayArrayStream(body); ByteArrayStreamReader reader = new ByteArrayStreamReader(stream); try { if (Adler32.Generate(body, 4) == reader.ReadUInt()) { if (Keys == null) { Rsa.DecryptAndReplace(body, 21); } Command command = null; switch (reader.ReadByte()) { case 0x01: { var packet = server.PacketsFactory.Create <EnterGameIncomingPacket>(reader); command = new EnterGameCommand(this, packet); } break; } if (command != null) { server.QueueForExecution(command); } } } catch (Exception ex) { server.Logger.WriteLine(ex.ToString()); } base.OnReceived(body); }
private void Apply(EnterGameCommand command, GameTime gameTime) { _grid.Exit(command.Entity); command.Entity.ClearPosition(); _pipeline.Unsubscribe(command.Entity); }
private void InitializeEntity(Entity entity, Coordinates to, GameTime gameTime) { var command = new EnterGameCommand(entity, to); _doCommandsHandler.Apply(command, gameTime); }