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