46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using LiteNetLib;
|
|
using LiteNetLib.Utils;
|
|
|
|
namespace PacketLib;
|
|
|
|
public struct PlayerState : INetSerializable { // TODO: make a constructor
|
|
public int pid;
|
|
public int camera;
|
|
public bool monitorUp;
|
|
|
|
public int officeTileId;
|
|
public bool[] doorStates;
|
|
public int[] neighbouringTiles; // the indexes should correspond in both arrays
|
|
|
|
public int power;
|
|
public bool poweredOut;
|
|
|
|
public void Serialize(NetDataWriter writer) {
|
|
writer.Put(pid);
|
|
writer.Put(camera);
|
|
writer.Put(monitorUp);
|
|
writer.PutArray(doorStates);
|
|
writer.Put(officeTileId);
|
|
writer.PutArray(neighbouringTiles);
|
|
writer.Put(power);
|
|
writer.Put(poweredOut);
|
|
}
|
|
|
|
public void Deserialize(NetDataReader reader) {
|
|
pid = reader.GetInt();
|
|
camera = reader.GetInt();
|
|
monitorUp = reader.GetBool();
|
|
doorStates = reader.GetBoolArray();
|
|
officeTileId = reader.GetInt();
|
|
neighbouringTiles = reader.GetIntArray();
|
|
power = reader.GetInt();
|
|
poweredOut = reader.GetBool();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|