32 lines
No EOL
1.1 KiB
C#
32 lines
No EOL
1.1 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using LiteNetLib.Utils;
|
|
|
|
namespace PacketLib;
|
|
|
|
#nullable disable
|
|
public struct GameEvent : INetSerializable{
|
|
public static GameEvent PLAYER_JOIN(int pid) => new(){ID = 0, Args = [pid] };
|
|
public static GameEvent PLAYER_LEAVE(int pid) => new(){ID = 1, Args = [pid] };
|
|
public static GameEvent SWITCH_CAM(int pid, int camId) => new(){ID = 2, Args = [pid, camId] };
|
|
public static GameEvent TOGGLE_MONITOR(int pid, bool state) => new(){ID = 3, Args = [pid, state ? 1 : 0]};
|
|
public static GameEvent TOGGLE_DOOR_OFFICE(int pid, int doorId, bool state) => new(){ID = 4, Args = [pid, doorId, state ? 1 : 0]};
|
|
|
|
|
|
|
|
public static GameEvent ENEMY_MOVEMENT(int enemyId, int camId) => new(){ID = -1, Args = [enemyId, camId]};
|
|
|
|
public int ID{ get; set; }
|
|
public bool Hideable => ID < 0;
|
|
public int[] Args{ get; private set; }
|
|
|
|
public void Serialize(NetDataWriter writer) {
|
|
writer.Put(ID);
|
|
writer.PutArray(Args);
|
|
}
|
|
|
|
public void Deserialize(NetDataReader reader) {
|
|
ID = reader.GetInt();
|
|
Args = reader.GetIntArray();
|
|
}
|
|
|
|
} |