quantum-space-buddies/QSB/Events/PlayerDeathEvent.cs

32 lines
973 B
C#
Raw Normal View History

2020-08-09 12:19:51 +01:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QSB.Messaging;
2020-08-09 12:38:35 +01:00
using QSB.Utility;
2020-08-09 12:19:51 +01:00
namespace QSB.Events
{
class PlayerDeathEvent : QSBEvent<PlayerDeathMessage>
{
public override MessageType Type => MessageType.PlayerDeath;
2020-08-09 12:38:35 +01:00
public override void SetupListener()
{
GlobalMessenger<DeathType>.AddListener("QSBPlayerDeath", type => SendEvent(new PlayerDeathMessage { SenderId = PlayerRegistry.LocalPlayer.NetId, DeathType = type }));
}
public override void OnReceive(PlayerDeathMessage message)
{
var playerName = PlayerRegistry.GetPlayer(message.SenderId).Name;
var deathMessage = Necronomicon.GetPhrase(message.DeathType);
DebugLog.ToAll(string.Format(deathMessage, playerName));
}
public override void OnReceiveLocal(PlayerDeathMessage message)
{
OnReceive(message);
}
2020-08-09 12:19:51 +01:00
}
}