OneNightDuel/PacketLib/GameEvent.cs

45 lines
2.4 KiB
C#
Raw Permalink Normal View History

using System.Diagnostics.CodeAnalysis;
using GlobalClassLib;
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 id) => new(){Id = 2, Args = [pid, id] };
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 TOGGLE_DOOR_REMOTE(int pid, (int, int) doorId, bool state) => new(){Id = 5, Args = [pid, doorId.Item1, doorId.Item2, state ? 1 : 0]};
public static GameEvent ENEMY_SPAWN(EnemyType enemyTypeId, int enemyId, int difficulty, int camId) => new(){ Id = 6, Args = [(int)enemyTypeId, enemyId, difficulty, camId] };
public static GameEvent ENEMY_MOVEMENT(int enemyId, int camId) => new(){Id = 7, Args = [enemyId, camId]};
public static GameEvent ENEMY_ATTACK(int enemyId, int pid) => new(){ Id = 8, Args =[enemyId, pid] };
public static GameEvent ENEMY_RESET(int enemyId, int camId) => new(){Id = 9, Args = [enemyId, camId]};
public static GameEvent SPOT_SET_ACTIVE(int enemyId, bool state) => new(){ Id = 10, Args = [enemyId, state ? 1 : 0] };
public static GameEvent PLAYER_WIN(int pid) => new(){Id = 11, Args = [pid]};
public static GameEvent GAME_START() => new(){Id = 12};
public static GameEvent POWER_TICK(int pid, int power) => new(){Id = 13, Args = [pid, power]};
public static GameEvent POWER_OUT(int pid) => new(){Id = 14, Args = [pid]};
public static GameEvent TOGGLE_LIGHT(int pid, int camId, bool state) => new(){Id = 15, Args = [pid, camId, state ? 1 : 0]};
public static GameEvent NEKO_ANGERED(int pid, int enemyId) => new(){Id = 16, Args = [pid, enemyId]};
public static GameEvent VENT_USED() => new(){Id = 17};
public static GameEvent NEXT_PHASE() => new(){Id = 18};
public int Id{ get; set; }
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();
}
}