30 lines
991 B
C#
Raw Normal View History

2020-12-14 16:24:52 +00:00
using QSB.Events;
2020-12-14 16:28:03 +00:00
using QSB.Messaging;
2020-11-03 21:33:48 +00:00
using QSB.Player;
2020-08-09 12:38:35 +01:00
using QSB.Utility;
2020-08-09 12:19:51 +01:00
2020-11-03 17:56:48 +00:00
namespace QSB.DeathSync.Events
2020-08-09 12:19:51 +01:00
{
2020-12-02 21:23:01 +00:00
public class PlayerDeathEvent : QSBEvent<EnumMessage<DeathType>>
{
public override EventType Type => EventType.PlayerDeath;
2020-08-09 12:38:35 +01:00
2020-12-02 21:23:01 +00:00
public override void SetupListener() => GlobalMessenger<DeathType>.AddListener(EventNames.QSBPlayerDeath, Handler);
public override void CloseListener() => GlobalMessenger<DeathType>.RemoveListener(EventNames.QSBPlayerDeath, Handler);
2020-08-15 20:32:58 +01:00
2020-12-02 21:23:01 +00:00
private void Handler(DeathType type) => SendEvent(CreateMessage(type));
2020-08-15 21:52:43 +02:00
2020-12-02 21:23:01 +00:00
private EnumMessage<DeathType> CreateMessage(DeathType type) => new EnumMessage<DeathType>
{
AboutId = LocalPlayerId,
Value = type
};
2020-08-10 18:17:54 +02:00
2020-12-11 22:42:21 +00:00
public override void OnReceiveRemote(bool server, EnumMessage<DeathType> message)
2020-12-02 21:23:01 +00:00
{
var playerName = QSBPlayerManager.GetPlayer(message.AboutId).Name;
var deathMessage = Necronomicon.GetPhrase(message.Value);
DebugLog.ToAll(string.Format(deathMessage, playerName));
}
}
2020-12-03 08:28:05 +00:00
}