mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-04 02:47:22 +00:00
41 lines
920 B
C#
41 lines
920 B
C#
|
using QSB.ClientServerStateSync;
|
|||
|
using QSB.Messaging;
|
|||
|
using QSB.Player;
|
|||
|
using QuantumUNET.Transport;
|
|||
|
|
|||
|
namespace QSB.RespawnSync.Events
|
|||
|
{
|
|||
|
internal class PlayerRespawnMessage : QSBMessage
|
|||
|
{
|
|||
|
private uint PlayerId;
|
|||
|
|
|||
|
public PlayerRespawnMessage(uint playerId) => PlayerId = playerId;
|
|||
|
|
|||
|
public PlayerRespawnMessage() { }
|
|||
|
|
|||
|
public override void Serialize(QNetworkWriter writer)
|
|||
|
{
|
|||
|
base.Serialize(writer);
|
|||
|
writer.Write(PlayerId);
|
|||
|
}
|
|||
|
|
|||
|
public override void Deserialize(QNetworkReader reader)
|
|||
|
{
|
|||
|
base.Deserialize(reader);
|
|||
|
PlayerId = reader.ReadUInt32();
|
|||
|
}
|
|||
|
|
|||
|
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));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|