2022-01-14 07:38:45 +00:00
|
|
|
|
using Mirror;
|
|
|
|
|
using QSB.ClientServerStateSync;
|
2021-12-23 06:09:00 +00:00
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
using QSB.Player;
|
|
|
|
|
|
2021-12-23 21:57:33 +00:00
|
|
|
|
namespace QSB.RespawnSync.Messages
|
2021-12-23 06:09:00 +00:00
|
|
|
|
{
|
|
|
|
|
internal class PlayerRespawnMessage : QSBMessage
|
|
|
|
|
{
|
|
|
|
|
private uint PlayerId;
|
|
|
|
|
|
|
|
|
|
public PlayerRespawnMessage(uint playerId) => PlayerId = playerId;
|
|
|
|
|
|
2022-01-14 07:38:45 +00:00
|
|
|
|
public override void Serialize(NetworkWriter writer)
|
2021-12-23 06:09:00 +00:00
|
|
|
|
{
|
|
|
|
|
base.Serialize(writer);
|
|
|
|
|
writer.Write(PlayerId);
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-14 07:38:45 +00:00
|
|
|
|
public override void Deserialize(NetworkReader reader)
|
2021-12-23 06:09:00 +00:00
|
|
|
|
{
|
|
|
|
|
base.Deserialize(reader);
|
2022-01-14 07:38:45 +00:00
|
|
|
|
PlayerId = reader.Read<uint>();
|
2021-12-23 06:09:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveLocal() => OnReceiveRemote();
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
|
|
|
|
if (PlayerId == QSBPlayerManager.LocalPlayerId)
|
|
|
|
|
{
|
|
|
|
|
RespawnManager.Instance.Respawn();
|
|
|
|
|
ClientStateManager.Instance.OnRespawn();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RespawnManager.Instance.OnPlayerRespawn(QSBPlayerManager.GetPlayer(PlayerId));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|