public static byte[] Whoami(CommandParameter parameter) { string playername = Encoding.UTF8.GetString(parameter.Data); var player = new Player(); updateHub.Push(new EntityNotification() { Entity = player, Type = EntityNotification.ActionType.Add }, DefaultChannels.Simulation); var remotePlayer = new RemoteEntity(player); remotePlayer.Components.AddComponent(new PositionComponent { Position = new Coordinate(0, new Index3(0, 0, 78), new Vector3(0, 0, 0)) }); remotePlayer.Components.AddComponent(new RenderComponent { Name = "Wauzi", ModelName = "dog", TextureName = "texdog", BaseZRotation = -90 }, true); remotePlayer.Components.AddComponent(new BodyComponent() { Mass = 50f, Height = 2f, Radius = 1.5f }); Console.WriteLine(playername); updateHub.Push(new EntityNotification() { Entity = remotePlayer, Type = EntityNotification.ActionType.Add }, DefaultChannels.Network); return(Serializer.Serialize(player, Program.ServerHandler.SimulationManager.DefinitionManager)); }
public static byte[] EntityNotification(CommandParameter parameter) { var entityNotification = Serializer.Deserialize <EntityNotification>(parameter.Data, null); entityNotification.SenderId = parameter.ClientId; updateHub.Push(entityNotification, DefaultChannels.Simulation); updateHub.Push(entityNotification, DefaultChannels.Network); return(null); }
public void OnNext(Package package) { switch (package.Command) { case (ushort)OfficialCommand.EntityNotification: var entityNotification = Serializer.Deserialize <EntityNotification>(package.Payload, definitionManager); updateHub.Push(entityNotification, DefaultChannels.Simulation); break; case (ushort)OfficialCommand.ChunkNotification: var chunkNotification = Serializer.Deserialize <ChunkNotification>(package.Payload, definitionManager); updateHub.Push(chunkNotification, DefaultChannels.Chunk); break; default: break; } }
public Task OnNext(Package package) { switch (package.OfficialCommand) { case OfficialCommand.EntityNotification: var entityNotification = Serializer.DeserializePoolElement(entityNotificationPool, package.Payload); updateHub.Push(entityNotification, DefaultChannels.Simulation); entityNotification.Release(); break; case OfficialCommand.ChunkNotification: var notificationType = (BlockNotificationType)package.Payload[0]; Notification chunkNotification; switch (notificationType) { case BlockNotificationType.BlockChanged: chunkNotification = Serializer.DeserializePoolElement(blockChangedNotificationPool, package.Payload); break; case BlockNotificationType.BlocksChanged: chunkNotification = Serializer.DeserializePoolElement(blocksChangedNotificationPool, package.Payload); break; default: throw new NotSupportedException($"This Type is not supported: {notificationType}"); } updateHub.Push(chunkNotification, DefaultChannels.Chunk); chunkNotification.Release(); break; default: break; } return(Task.CompletedTask); }