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

31 lines
908 B
C#
Raw Normal View History

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