using NeonTea.Quakeball.TeaNet.Packets; namespace NeonTea.Quakeball.Networking.Packets { public class PlayerActionPckt : Packet { public ulong PlayerId; public PlayerAction Action; public Serializable Serializable; public PlayerActionPckt() { } public PlayerActionPckt(PlayerAction action, ulong id = 0) { Action = action; PlayerId = id; } public override void Read(ByteBuffer buffer) { PlayerId = buffer.ReadULong(); switch (buffer.Read()) { case 0: Action = PlayerAction.Jump; break; case 1: Action = PlayerAction.Shoot; ShootData data = new ShootData(); data.Read(buffer); Serializable = data; break; } } public override void Write(ByteBuffer buffer) { buffer.Write(PlayerId); buffer.Write((byte)Action); if (Action == PlayerAction.Shoot) { buffer.Write(Serializable); } } } public enum PlayerAction { Null = byte.MaxValue, Jump = 0, Shoot = 1, } public class ShootData : Serializable { public void Read(ByteBuffer buffer) { } public void Write(ByteBuffer buffer) { } } }