35 lines
1.0 KiB
C#
Raw Normal View History

2020-08-21 14:04:13 +01:00
using QSB.Events;
using System.Linq;
2020-08-13 21:46:16 +02:00
namespace QSB.DeathSync
{
public static class DeathPatches
{
public static bool PreFinishDeathSequence(DeathType deathType)
{
if (RespawnOnDeath.Instance.AllowedDeathTypes.Contains(deathType))
{
// Allow real death
return true;
}
RespawnOnDeath.Instance.ResetShip();
RespawnOnDeath.Instance.ResetPlayer();
// Prevent original death method from running.
return false;
}
public static void BroadcastDeath(DeathType deathType)
{
GlobalMessenger<DeathType>.FireEvent(EventNames.QSBPlayerDeath, deathType);
}
2020-08-23 15:51:45 +02:00
2020-08-23 15:54:00 +02:00
public static void DoPatches()
2020-08-23 15:51:45 +02:00
{
QSB.Helper.HarmonyHelper.AddPrefix<DeathManager>("KillPlayer", typeof(DeathPatches), nameof(PreFinishDeathSequence));
QSB.Helper.HarmonyHelper.AddPostfix<DeathManager>("KillPlayer", typeof(DeathPatches), nameof(BroadcastDeath));
}
2020-08-13 21:46:16 +02:00
}
}