Funkční komunikace mezi jedním clientem a serverem
This commit is contained in:
commit
3f235f6e04
44 changed files with 1030 additions and 0 deletions
29
PacketLib/GameEvent.cs
Normal file
29
PacketLib/GameEvent.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
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 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();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue