Add examine tooltip to ghosts. (#2382)
* Add examine tooltip to ghosts. * remove ghost name in examine tmsg. reformat time since death Co-authored-by: scuffedjays <yetanotherscuffed@gmail.com>
This commit is contained in:
@@ -15,15 +15,22 @@ using Robust.Shared.Interfaces.Network;
|
|||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Players;
|
using Robust.Shared.Players;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
using Robust.Shared.Localization;
|
||||||
|
using Robust.Shared.Interfaces.Timing;
|
||||||
|
using System;
|
||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
namespace Content.Server.GameObjects.Components.Observer
|
namespace Content.Server.GameObjects.Components.Observer
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class GhostComponent : SharedGhostComponent
|
public class GhostComponent : SharedGhostComponent, IExamine
|
||||||
{
|
{
|
||||||
private bool _canReturnToBody = true;
|
private bool _canReturnToBody = true;
|
||||||
|
private TimeSpan _timeOfDeath = TimeSpan.Zero;
|
||||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||||
|
[Dependency] private readonly IGameTiming _gameTimer = default!;
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public bool CanReturnToBody
|
public bool CanReturnToBody
|
||||||
{
|
{
|
||||||
@@ -40,6 +47,7 @@ namespace Content.Server.GameObjects.Components.Observer
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
Owner.EnsureComponent<VisibilityComponent>().Layer = (int) VisibilityFlags.Ghost;
|
Owner.EnsureComponent<VisibilityComponent>().Layer = (int) VisibilityFlags.Ghost;
|
||||||
|
_timeOfDeath = _gameTimer.RealTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ComponentState GetComponentState() => new GhostComponentState(CanReturnToBody);
|
public override ComponentState GetComponentState() => new GhostComponentState(CanReturnToBody);
|
||||||
@@ -139,6 +147,15 @@ namespace Content.Server.GameObjects.Components.Observer
|
|||||||
return comp.EntityQuery<WarpPointComponent>().ToList();
|
return comp.EntityQuery<WarpPointComponent>().ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Examine(FormattedMessage message, bool inDetailsRange)
|
||||||
|
{
|
||||||
|
var timeSinceDeath = _gameTimer.RealTime.Subtract(_timeOfDeath);
|
||||||
|
//If we've been dead for longer than 1 minute use minutes, otherwise use seconds. Ignore the improper plurals.
|
||||||
|
var deathTimeInfo = timeSinceDeath.Minutes > 0 ? Loc.GetString($"{timeSinceDeath.Minutes} minutes ago") : Loc.GetString($"{timeSinceDeath.Seconds} seconds ago");
|
||||||
|
|
||||||
|
message.AddMarkup(Loc.GetString("Died [color=yellow]{0}[/color].", deathTimeInfo));
|
||||||
|
}
|
||||||
|
|
||||||
public class GhostReturnMessage : EntitySystemMessage
|
public class GhostReturnMessage : EntitySystemMessage
|
||||||
{
|
{
|
||||||
public GhostReturnMessage(Mind sender)
|
public GhostReturnMessage(Mind sender)
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
description: Boo!
|
description: Boo!
|
||||||
components:
|
components:
|
||||||
- type: Mind
|
- type: Mind
|
||||||
|
- type: Clickable
|
||||||
|
- type: InteractionOutline
|
||||||
- type: Physics
|
- type: Physics
|
||||||
anchored: false
|
anchored: false
|
||||||
mass: 5
|
mass: 5
|
||||||
|
|||||||
Reference in New Issue
Block a user