quantum-space-buddies/QSB/Events/PlayerDeathEvent.cs
2020-08-10 18:17:54 +02:00

29 lines
886 B
C#

using QSB.Messaging;
using QSB.Utility;
namespace QSB.Events
{
public class PlayerDeathEvent : QSBEvent<PlayerDeathMessage>
{
public override MessageType Type => MessageType.PlayerDeath;
public override void SetupListener()
{
GlobalMessenger<DeathType>.AddListener("QSBPlayerDeath", type => SendEvent(CreateMessage(type)));
}
private PlayerDeathMessage CreateMessage(DeathType type) => new PlayerDeathMessage
{
SenderId = LocalPlayerId,
DeathType = type
};
public override void OnReceiveRemote(PlayerDeathMessage message)
{
var playerName = PlayerRegistry.GetPlayer(message.SenderId).Name;
var deathMessage = Necronomicon.GetPhrase(message.DeathType);
DebugLog.ToAll(string.Format(deathMessage, playerName));
}
}
}