Death errors workaround, and allow more death types (#79)

* Fix network animator errors when nothing to animate

Clsoes #75

* Broadcast death after all the death logic has been dealt with

for #77

* Remove black hole from death type whitelist
This commit is contained in:
Ricardo Lopes 2020-03-14 21:20:25 +01:00 committed by GitHub
parent 361da9cbbb
commit 34f75c672f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,12 @@ namespace QSB.TimeSync
{
private static RespawnOnDeath _instance;
private static readonly DeathType[] _allowedDeathTypes = {
DeathType.BigBang,
DeathType.Supernova,
DeathType.TimeLoop
};
private SpawnPoint _shipSpawnPoint;
private SpawnPoint _playerSpawnPoint;
private OWRigidbody _shipBody;
@ -21,13 +27,13 @@ namespace QSB.TimeSync
private HatchController _hatchController;
private ShipCockpitController _cockpitController;
private PlayerSpacesuit _spaceSuit;
private MessageHandler<DeathMessage> _deathHandler;
private void Awake()
{
_instance = this;
QSB.Helper.HarmonyHelper.AddPrefix<DeathManager>("KillPlayer", typeof(Patches), nameof(Patches.PreFinishDeathSequence));
QSB.Helper.HarmonyHelper.AddPostfix<DeathManager>("KillPlayer", typeof(Patches), nameof(Patches.BroadcastDeath));
QSB.Helper.Events.Subscribe<PlayerResources>(OWML.Common.Events.AfterStart);
QSB.Helper.Events.OnEvent += OnEvent;
}
@ -145,9 +151,7 @@ namespace QSB.TimeSync
{
public static bool PreFinishDeathSequence(DeathType deathType)
{
BroadcastDeath(deathType);
if (deathType == DeathType.Supernova)
if (_allowedDeathTypes.Contains(deathType))
{
// Allow real death
return true;
@ -160,7 +164,7 @@ namespace QSB.TimeSync
return false;
}
private static void BroadcastDeath(DeathType deathType)
public static void BroadcastDeath(DeathType deathType)
{
var message = new DeathMessage
{