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

48 lines
1.3 KiB
C#

using UnityEngine;
using NeonTea.Quakeball.TeaNet.Packets;
namespace NeonTea.Quakeball.Networking.Packets {
public class SpawnPckt : Packet {
public ulong PlayerId;
public Vector3 Location;
public bool IsInitial;
public SpawnPckt(Vector3 location, ulong id = 0, bool isinitial = true) {
PlayerId = id;
Location = location;
IsInitial = isinitial;
}
public override void Read(ByteBuffer buffer) {
float x = buffer.ReadFloat();
float y = buffer.ReadFloat();
float z = buffer.ReadFloat();
Location = new Vector3(x, y, z);
PlayerId = buffer.ReadULong();
IsInitial = buffer.ReadBool();
}
public override void Write(ByteBuffer buffer) {
buffer.Write(Location.x);
buffer.Write(Location.y);
buffer.Write(Location.z);
buffer.Write(PlayerId);
buffer.Write(IsInitial);
}
}
public class SelfIdentPckt : Packet {
public ulong PlayerId;
public override void Read(ByteBuffer buffer) {
PlayerId = buffer.ReadULong();
}
public override void Write(ByteBuffer buffer) {
buffer.Write(PlayerId);
}
}
}