Move HandleSyncPckt to it's own call

This commit is contained in:
Sofia 2020-08-08 04:58:02 +03:00
parent 97a6b74417
commit 48f02df34c

View File

@ -97,12 +97,7 @@ namespace NeonTea.Quakeball.Networking.Instances {
} }
} else if (packet is PlayerSyncPacket) { } else if (packet is PlayerSyncPacket) {
PlayerSyncPacket syncPckt = (PlayerSyncPacket)packet; PlayerSyncPacket syncPckt = (PlayerSyncPacket)packet;
if (Players[conn.uid].Controlled != null) { HandleSyncPckt(conn.uid, syncPckt);
syncPckt.PlayerId = conn.uid;
if (!Players[conn.uid].Controlled.ProcessSyncPacket(syncPckt, false)) {
Players[conn.uid].Unsynced = true;
}
}
} else if (packet is PlayerActionPckt) { } else if (packet is PlayerActionPckt) {
PlayerActionPckt action = (PlayerActionPckt)packet; PlayerActionPckt action = (PlayerActionPckt)packet;
if (Players[conn.uid].Controlled != null) { if (Players[conn.uid].Controlled != null) {
@ -145,6 +140,15 @@ namespace NeonTea.Quakeball.Networking.Instances {
PlayerList.Remove(player); PlayerList.Remove(player);
} }
private void HandleSyncPckt(ulong uid, PlayerSyncPacket pckt) {
if (Players[uid].Controlled != null) {
pckt.PlayerId = uid;
if (!Players[uid].Controlled.ProcessSyncPacket(pckt, false)) {
Players[uid].Unsynced = true;
}
}
}
private void HandleAction(ulong uid, PlayerActionPckt action) { private void HandleAction(ulong uid, PlayerActionPckt action) {
switch (action.Action) { switch (action.Action) {
case PlayerAction.Jump: case PlayerAction.Jump: