Fix for death timer resetting after returning to body. (#5174)
This commit is contained in:
parent
1b01247c5f
commit
81dc92ce9b
|
|
@ -4,12 +4,14 @@ using Content.Shared.MobState.Components;
|
|||
using Content.Shared.Movement.EntitySystems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.Body
|
||||
{
|
||||
public sealed class BodySystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly GameTicker _ticker = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
|
|
@ -24,6 +26,11 @@ namespace Content.Server.Body
|
|||
EntityManager.TryGetComponent<MindComponent>(uid, out var mind) &&
|
||||
mind.HasMind)
|
||||
{
|
||||
if (!mind.Mind!.TimeOfDeath.HasValue)
|
||||
{
|
||||
mind.Mind.TimeOfDeath = _gameTiming.RealTime;
|
||||
}
|
||||
|
||||
_ticker.OnGhostAttempt(mind.Mind!, true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,12 @@ namespace Content.Server.GameTicking.Presets
|
|||
ghost.Name = mind.Session.Name;
|
||||
|
||||
var ghostComponent = ghost.GetComponent<GhostComponent>();
|
||||
|
||||
if (mind.TimeOfDeath.HasValue)
|
||||
{
|
||||
ghostComponent.TimeOfDeath = mind.TimeOfDeath!.Value;
|
||||
}
|
||||
|
||||
EntitySystem.Get<SharedGhostSystem>().SetCanReturnToBody(ghostComponent, canReturn);
|
||||
|
||||
if (canReturn)
|
||||
|
|
|
|||
|
|
@ -63,6 +63,12 @@ namespace Content.Server.Mind
|
|||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public string? CharacterName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time of death for this Mind.
|
||||
/// Can be null - will be null if the Mind is not considered "dead".
|
||||
/// </summary>
|
||||
[ViewVariables] public TimeSpan? TimeOfDeath { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// The component currently owned by this mind.
|
||||
/// Can be null.
|
||||
|
|
@ -116,6 +122,7 @@ namespace Content.Server.Mind
|
|||
/// </summary>
|
||||
[ViewVariables]
|
||||
public bool CharacterDeadIC => CharacterDeadPhysically;
|
||||
|
||||
/// <summary>
|
||||
/// True if the OwnedEntity of this mind is physically dead.
|
||||
/// This specific definition, as opposed to CharacterDeadIC, is used to determine if ghosting should allow return.
|
||||
|
|
|
|||
Loading…
Reference in New Issue