quakeball/Assets/Scripts/Networking/Packets/PlayerUpdatePckt.cs

61 lines
1.7 KiB
C#

using UnityEngine;
using NeonTea.Quakeball.TeaNet.Packets;
namespace NeonTea.Quakeball.Networking.Packets {
public class PlayerUpdatePckt : Packet {
public ulong PlayerId;
public Vector3 MoveDirection;
public byte MoveStyle;
public float Pitch;
public float Yaw;
public PlayerUpdatePckt() { }
public PlayerUpdatePckt(Vector3 moveDirection, byte moveStyle, float pitch, float yaw, ulong id = 0) {
MoveDirection = moveDirection;
MoveStyle = moveStyle;
Pitch = pitch;
Yaw = yaw;
PlayerId = id;
}
public override void Read(ByteBuffer buffer) {
PlayerId = buffer.ReadULong();
float x = buffer.ReadFloat();
float y = buffer.ReadFloat();
float z = buffer.ReadFloat();
MoveDirection = new Vector3(x, y, z);
MoveStyle = buffer.Read();
Pitch = buffer.ReadFloat();
Yaw = buffer.ReadFloat();
}
public override void Write(ByteBuffer buffer) {
buffer.Write(PlayerId);
buffer.Write(MoveDirection.x);
buffer.Write(MoveDirection.y);
buffer.Write(MoveDirection.z);
buffer.Write(MoveStyle);
buffer.Write(Pitch);
buffer.Write(Yaw);
}
}
public class PlayerJumpPckt : Packet {
public ulong PlayerId;
public PlayerJumpPckt() { }
public PlayerJumpPckt(ulong id) { PlayerId = id; }
public override void Read(ByteBuffer buffer) {
PlayerId = buffer.ReadULong();
}
public override void Write(ByteBuffer buffer) {
buffer.Write(PlayerId);
}
}
}