mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-03-12 22:14:37 +00:00
Merge pull request #428 from misternebula/fix-deaths
Fix death events being called too many times
This commit is contained in:
commit
b918b62663
@ -30,6 +30,11 @@ namespace QSB.DeathSync.Events
|
||||
switch (message.EnumValue)
|
||||
{
|
||||
case EndLoopReason.AllPlayersDead:
|
||||
if (ServerStateManager.Instance.GetServerState() == ServerState.WaitingForAllPlayersToDie)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
QSBPatchManager.DoUnpatchType(QSBPatchTypes.RespawnTime);
|
||||
|
||||
Locator.GetDeathManager().KillPlayer(DeathType.TimeLoop);
|
||||
|
@ -10,155 +10,155 @@ namespace QSB.DeathSync
|
||||
{
|
||||
DeathType.Default,
|
||||
new[] // Running out of health
|
||||
{
|
||||
"{0} died",
|
||||
"{0} was killed"
|
||||
}
|
||||
{
|
||||
"{0} died",
|
||||
"{0} was killed"
|
||||
}
|
||||
},
|
||||
{
|
||||
DeathType.Impact,
|
||||
new[] // Hitting the ground/wall/object
|
||||
{
|
||||
"{0} forgot to use retro-rockets",
|
||||
"{0} bonked into the ground too hard",
|
||||
"{0} hit the ground too hard",
|
||||
"{0} went splat",
|
||||
"{0} died",
|
||||
"{0} was killed",
|
||||
"{0} died due to impact",
|
||||
"{0} impacted the ground too hard"
|
||||
}
|
||||
{
|
||||
"{0} forgot to use retro-rockets",
|
||||
"{0} bonked into the ground too hard",
|
||||
"{0} hit the ground too hard",
|
||||
"{0} went splat",
|
||||
"{0} died",
|
||||
"{0} was killed",
|
||||
"{0} died due to impact",
|
||||
"{0} impacted the ground too hard"
|
||||
}
|
||||
},
|
||||
{
|
||||
DeathType.Asphyxiation,
|
||||
new[] // Running out of oxygen
|
||||
{
|
||||
"{0} forgot to breathe",
|
||||
"{0} asphyxiated",
|
||||
"{0} died due to asphyxiation",
|
||||
"{0} forgot how to breathe",
|
||||
"{0} forgot to check their oxygen",
|
||||
"{0} ran out of air",
|
||||
"{0} ran out of oxygen",
|
||||
"{0} didn't need air anyway"
|
||||
}
|
||||
{
|
||||
"{0} forgot to breathe",
|
||||
"{0} asphyxiated",
|
||||
"{0} died due to asphyxiation",
|
||||
"{0} forgot how to breathe",
|
||||
"{0} forgot to check their oxygen",
|
||||
"{0} ran out of air",
|
||||
"{0} ran out of oxygen",
|
||||
"{0} didn't need air anyway"
|
||||
}
|
||||
},
|
||||
{
|
||||
DeathType.Energy,
|
||||
new[] // Electricity, sun, etc.
|
||||
{
|
||||
"{0} was cooked",
|
||||
"{0} died",
|
||||
"{0} was killed"
|
||||
}
|
||||
{
|
||||
"{0} was cooked",
|
||||
"{0} died",
|
||||
"{0} was killed"
|
||||
}
|
||||
},
|
||||
{
|
||||
DeathType.Supernova,
|
||||
new[] // Supernova
|
||||
{
|
||||
"{0} ran out of time",
|
||||
"{0} burnt up",
|
||||
"{0} got vaporized",
|
||||
"{0} lost track of time",
|
||||
"{0} got front row seats to the supernova",
|
||||
"{0} heard the music",
|
||||
"{0} watched the sun go kaboom",
|
||||
"{0} became cosmic marshmallow",
|
||||
"{0} photosynthesized too much",
|
||||
"{0} died due to the supernova"
|
||||
}
|
||||
{
|
||||
"{0} ran out of time",
|
||||
"{0} burnt up",
|
||||
"{0} got vaporized",
|
||||
"{0} lost track of time",
|
||||
"{0} got front row seats to the supernova",
|
||||
"{0} heard the music",
|
||||
"{0} watched the sun go kaboom",
|
||||
"{0} became cosmic marshmallow",
|
||||
"{0} photosynthesized too much",
|
||||
"{0} died due to the supernova"
|
||||
}
|
||||
},
|
||||
{
|
||||
DeathType.Digestion,
|
||||
new[] // Anglerfish
|
||||
{
|
||||
"{0} was eaten",
|
||||
"{0} found a fish",
|
||||
"{0} encountered an evil creature",
|
||||
"{0} messed with the wrong fish",
|
||||
"{0} was digested",
|
||||
"{0} died due to digestion"
|
||||
}
|
||||
{
|
||||
"{0} was eaten",
|
||||
"{0} found a fish",
|
||||
"{0} encountered an evil creature",
|
||||
"{0} messed with the wrong fish",
|
||||
"{0} was digested",
|
||||
"{0} died due to digestion"
|
||||
}
|
||||
},
|
||||
{
|
||||
DeathType.BigBang,
|
||||
new[] // End of the game
|
||||
{
|
||||
// TODO : maybe don't show these?
|
||||
"{0} sacrificed themself for the universe",
|
||||
"{0} knows the true meaning of sacrifice",
|
||||
"{0} won at the cost of their life"
|
||||
}
|
||||
{
|
||||
// TODO : maybe don't show these?
|
||||
"{0} sacrificed themself for the universe",
|
||||
"{0} knows the true meaning of sacrifice",
|
||||
"{0} won at the cost of their life"
|
||||
}
|
||||
},
|
||||
{
|
||||
DeathType.Crushed,
|
||||
new[] // Crushed in sand
|
||||
{
|
||||
"{0} went through the tunnel too slow",
|
||||
"{0} didn't make it out in time",
|
||||
"{0} was squished",
|
||||
"{0} was crushed",
|
||||
"{0} was buried",
|
||||
"{0} went swimming in the sand",
|
||||
"{0} underestimated the danger of sand",
|
||||
"{0} died due to being crushed"
|
||||
}
|
||||
{
|
||||
"{0} went through the tunnel too slow",
|
||||
"{0} didn't make it out in time",
|
||||
"{0} was squished",
|
||||
"{0} was crushed",
|
||||
"{0} was buried",
|
||||
"{0} went swimming in the sand",
|
||||
"{0} underestimated the danger of sand",
|
||||
"{0} died due to being crushed"
|
||||
}
|
||||
},
|
||||
{
|
||||
DeathType.TimeLoop,
|
||||
new[] // Escaping the supernova
|
||||
{
|
||||
"{0} ran out of time",
|
||||
"{0} lost track of time",
|
||||
"{0} watched the sun go kaboom"
|
||||
}
|
||||
{
|
||||
"{0} ran out of time",
|
||||
"{0} lost track of time",
|
||||
"{0} watched the sun go kaboom"
|
||||
}
|
||||
},
|
||||
{
|
||||
DeathType.Lava,
|
||||
new[] // Lava
|
||||
{
|
||||
"{0} died in lava",
|
||||
"{0} was melted",
|
||||
"{0} tried to swim in lava",
|
||||
"{0} didn't know what the glowy orange liquid was",
|
||||
"{0} fell into lava",
|
||||
"{0} became one with the glowing gooey rock",
|
||||
"{0} died due to lava",
|
||||
"{0} got burnt in the lava"
|
||||
}
|
||||
{
|
||||
"{0} died in lava",
|
||||
"{0} was melted",
|
||||
"{0} tried to swim in lava",
|
||||
"{0} didn't know what the glowy orange liquid was",
|
||||
"{0} fell into lava",
|
||||
"{0} became one with the glowing gooey rock",
|
||||
"{0} died due to lava",
|
||||
"{0} got burnt in the lava"
|
||||
}
|
||||
},
|
||||
{
|
||||
DeathType.BlackHole,
|
||||
new[] // ATP core black hole
|
||||
{
|
||||
"{0} should visit the Ash Twin Project again",
|
||||
"{0} waited inside the Ash Twin Project",
|
||||
"{0} chased their memories"
|
||||
}
|
||||
{
|
||||
"{0} should visit the Ash Twin Project again",
|
||||
"{0} waited inside the Ash Twin Project",
|
||||
"{0} chased their memories"
|
||||
}
|
||||
},
|
||||
{
|
||||
DeathType.DreamExplosion,
|
||||
new[] // using the prototype
|
||||
{
|
||||
"{0} exploded",
|
||||
"{0} was an early adopter",
|
||||
"{0} went kaboom",
|
||||
"{0} was fried",
|
||||
"{0} died due to explosion",
|
||||
"{0} used the wrong artifact"
|
||||
}
|
||||
{
|
||||
"{0} exploded",
|
||||
"{0} was an early adopter",
|
||||
"{0} went kaboom",
|
||||
"{0} was fried",
|
||||
"{0} died due to explosion",
|
||||
"{0} used the wrong artifact"
|
||||
}
|
||||
},
|
||||
{
|
||||
DeathType.CrushedByElevator,
|
||||
new[] // elevator-induced pancakeness
|
||||
{
|
||||
"{0} was crushed",
|
||||
"{0} was squished",
|
||||
"{0} was crushed by an elevator",
|
||||
"{0} stood under an elevator",
|
||||
"{0} became a flat-hearther",
|
||||
"{0} was squished by an elevator"
|
||||
}
|
||||
{
|
||||
"{0} was crushed",
|
||||
"{0} was squished",
|
||||
"{0} was crushed by an elevator",
|
||||
"{0} stood under an elevator",
|
||||
"{0} became a flat-hearther",
|
||||
"{0} was squished by an elevator"
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -53,13 +53,6 @@ namespace QSB.DeathSync.Patches
|
||||
{
|
||||
Locator.GetDeathManager().SetImpactDeathSpeed(impact.speed);
|
||||
Locator.GetDeathManager().KillPlayer(DeathType.Impact);
|
||||
DebugLog.DebugWrite(string.Concat(new object[]
|
||||
{
|
||||
"Player killed from impact with ",
|
||||
impact.otherCollider,
|
||||
" attached to ",
|
||||
impact.otherCollider.attachedRigidbody.gameObject.name
|
||||
}));
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -108,7 +101,6 @@ namespace QSB.DeathSync.Patches
|
||||
if (distanceFromShip > 8f)
|
||||
{
|
||||
____body.SetPosition(shipCenter);
|
||||
DebugLog.DebugWrite("MOVE PLAYER BACK TO SHIP CENTER");
|
||||
}
|
||||
|
||||
if (!____dead)
|
||||
@ -118,17 +110,6 @@ namespace QSB.DeathSync.Patches
|
||||
{
|
||||
____impactSpeed = a.magnitude;
|
||||
____body.AddVelocityChange(-a);
|
||||
DebugLog.DebugWrite("Would have killed player...");
|
||||
//____dieNextUpdate = true;
|
||||
DebugLog.DebugWrite(string.Concat(new object[]
|
||||
{
|
||||
"HIGH SPEED IMPACT: ",
|
||||
__instance.name,
|
||||
" hit the Ship at ",
|
||||
____impactSpeed,
|
||||
"m/s Dist from ship: ",
|
||||
distanceFromShip
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,17 +146,6 @@ namespace QSB.DeathSync.Patches
|
||||
____dieNextUpdate = true;
|
||||
}
|
||||
|
||||
DebugLog.DebugWrite(string.Concat(new object[]
|
||||
{
|
||||
"HIGH SPEED IMPACT: ",
|
||||
__instance.name,
|
||||
" hit ",
|
||||
____raycastHits[i].rigidbody.name,
|
||||
" at ",
|
||||
____impactSpeed,
|
||||
"m/s RF: ",
|
||||
passiveReferenceFrame.GetOWRigidBody().name
|
||||
}));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -201,7 +171,18 @@ namespace QSB.DeathSync.Patches
|
||||
return true;
|
||||
}
|
||||
|
||||
QSBPlayerManager.LocalPlayer.IsDead = true;
|
||||
if (QSBPlayerManager.LocalPlayer.IsDead)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var deadPlayersCount = QSBPlayerManager.PlayerList.Count(x => x.IsDead);
|
||||
|
||||
if (deadPlayersCount == QSBPlayerManager.PlayerList.Count - 1)
|
||||
{
|
||||
QSBEventManager.FireEvent(EventNames.QSBEndLoop, EndLoopReason.AllPlayersDead);
|
||||
return true;
|
||||
}
|
||||
|
||||
RespawnOnDeath.Instance.ResetPlayer();
|
||||
return false;
|
||||
@ -209,7 +190,14 @@ namespace QSB.DeathSync.Patches
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(DeathManager), nameof(DeathManager.KillPlayer))]
|
||||
public static void DeathManager_KillPlayer_Postfix(DeathType deathType) => QSBEventManager.FireEvent(EventNames.QSBPlayerDeath, deathType);
|
||||
public static void DeathManager_KillPlayer_Postfix(DeathType deathType)
|
||||
{
|
||||
if (!QSBPlayerManager.LocalPlayer.IsDead)
|
||||
{
|
||||
QSBPlayerManager.LocalPlayer.IsDead = true;
|
||||
QSBEventManager.FireEvent(EventNames.QSBPlayerDeath, deathType);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(ShipDamageController), nameof(ShipDamageController.Awake))]
|
||||
|
@ -1,5 +1,4 @@
|
||||
using OWML.Common;
|
||||
using OWML.Utils;
|
||||
using QSB.Events;
|
||||
using QSB.Player;
|
||||
using QSB.Player.TransformSync;
|
||||
@ -41,6 +40,7 @@ namespace QSB.DeathSync
|
||||
|
||||
public void Init()
|
||||
{
|
||||
DebugLog.DebugWrite($"INIT");
|
||||
var playerTransform = Locator.GetPlayerTransform();
|
||||
_playerResources = playerTransform.GetComponent<PlayerResources>();
|
||||
_spaceSuit = Locator.GetPlayerSuit();
|
||||
@ -59,14 +59,6 @@ namespace QSB.DeathSync
|
||||
Init();
|
||||
}
|
||||
|
||||
var deadPlayersCount = QSBPlayerManager.PlayerList.Count(x => x.IsDead);
|
||||
|
||||
if (deadPlayersCount == QSBPlayerManager.PlayerList.Count)
|
||||
{
|
||||
QSBEventManager.FireEvent(EventNames.QSBEndLoop, EndLoopReason.AllPlayersDead);
|
||||
return;
|
||||
}
|
||||
|
||||
RespawnManager.Instance.TriggerRespawnMap();
|
||||
|
||||
var inSpace = PlayerTransformSync.LocalInstance.SectorSync.SectorList.Count == 0;
|
||||
@ -94,31 +86,19 @@ namespace QSB.DeathSync
|
||||
_playerSpawnPoint.AddObjectToTriggerVolumes(_fluidDetector.gameObject);
|
||||
_playerSpawnPoint.OnSpawnPlayer();
|
||||
|
||||
_playerResources.SetValue("_isSuffocating", false);
|
||||
_playerResources._isSuffocating = false;
|
||||
_playerResources.DebugRefillResources();
|
||||
_spaceSuit.RemoveSuit(true);
|
||||
|
||||
foreach (var pickupVolume in _suitPickupVolumes)
|
||||
{
|
||||
var containsSuit = pickupVolume.GetValue<bool>("_containsSuit");
|
||||
var allowReturn = pickupVolume.GetValue<bool>("_allowSuitReturn");
|
||||
|
||||
if (!containsSuit && allowReturn)
|
||||
if (!pickupVolume._containsSuit && pickupVolume._allowSuitReturn)
|
||||
{
|
||||
|
||||
var interactVolume = pickupVolume.GetValue<MultipleInteractionVolume>("_interactVolume");
|
||||
var pickupSuitIndex = pickupVolume.GetValue<int>("_pickupSuitCommandIndex");
|
||||
|
||||
pickupVolume.SetValue("_containsSuit", true);
|
||||
interactVolume.ChangePrompt(UITextType.SuitUpPrompt, pickupSuitIndex);
|
||||
|
||||
var suitGeometry = pickupVolume.GetValue<GameObject>("_suitGeometry");
|
||||
var suitCollider = pickupVolume.GetValue<OWCollider>("_suitOWCollider");
|
||||
var toolGeometries = pickupVolume.GetValue<GameObject[]>("_toolGeometry");
|
||||
|
||||
suitGeometry.SetActive(true);
|
||||
suitCollider.SetActivation(true);
|
||||
foreach (var geo in toolGeometries)
|
||||
pickupVolume._containsSuit = true;
|
||||
pickupVolume._interactVolume.ChangePrompt(UITextType.SuitUpPrompt, pickupVolume._pickupSuitCommandIndex);
|
||||
pickupVolume._suitGeometry.SetActive(true);
|
||||
pickupVolume._suitOWCollider.SetActivation(true);
|
||||
foreach (var geo in pickupVolume._toolGeometry)
|
||||
{
|
||||
geo.SetActive(true);
|
||||
}
|
||||
@ -128,7 +108,7 @@ namespace QSB.DeathSync
|
||||
|
||||
private SpawnPoint GetSpawnPoint()
|
||||
{
|
||||
var spawnList = _playerSpawner.GetValue<SpawnPoint[]>("_spawnList");
|
||||
var spawnList = _playerSpawner._spawnList;
|
||||
if (spawnList == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - _spawnList was null for player spawner!", MessageType.Warning);
|
||||
|
@ -1,4 +1,4 @@
|
||||
using OWML.Utils;
|
||||
using QSB.DeathSync;
|
||||
using QSB.Events;
|
||||
using QSB.Patches;
|
||||
using QSB.Player;
|
||||
@ -105,7 +105,6 @@ namespace QSB.RespawnSync
|
||||
multiInteract._interactRange = 1.5f;
|
||||
|
||||
_qsbRecoveryPoint.AddComponent<ShipRecoveryPoint>();
|
||||
|
||||
_qsbRecoveryPoint.AddComponent<RespawnHUDMarker>();
|
||||
}
|
||||
|
||||
@ -126,7 +125,7 @@ namespace QSB.RespawnSync
|
||||
var playerSpawner = FindObjectOfType<PlayerSpawner>();
|
||||
playerSpawner.DebugWarp(playerSpawner.GetSpawnPoint(SpawnLocation.Ship));
|
||||
|
||||
mapController.GetType().GetAnyMethod("ExitMapView").Invoke(mapController, null);
|
||||
mapController.ExitMapView();
|
||||
|
||||
var cameraEffectController = Locator.GetPlayerCamera().GetComponent<PlayerCameraEffectController>();
|
||||
cameraEffectController.OpenEyes(1f, false);
|
||||
@ -134,20 +133,25 @@ namespace QSB.RespawnSync
|
||||
|
||||
public void OnPlayerDeath(PlayerInfo player)
|
||||
{
|
||||
DebugLog.DebugWrite($"ON PLAYER DEATH");
|
||||
|
||||
if (_playersPendingRespawn.Contains(player))
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - Received death message for player who is already in _playersPendingRespawn!", OWML.Common.MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
DebugLog.DebugWrite($"set player to be dead");
|
||||
player.IsDead = true;
|
||||
|
||||
_playersPendingRespawn.Add(player);
|
||||
UpdateRespawnNotification();
|
||||
|
||||
var deadPlayersCount = QSBPlayerManager.PlayerList.Count(x => x.IsDead);
|
||||
|
||||
if (deadPlayersCount == QSBPlayerManager.PlayerList.Count)
|
||||
{
|
||||
QSBEventManager.FireEvent(EventNames.QSBEndLoop, EndLoopReason.AllPlayersDead);
|
||||
return;
|
||||
}
|
||||
|
||||
QSBPlayerManager.ChangePlayerVisibility(player.PlayerId, false);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user