From c21920df6c4d12d51084694f0fef3d7d89bab2a5 Mon Sep 17 00:00:00 2001 From: F77F <66768086+F77F@users.noreply.github.com> Date: Sun, 25 Oct 2020 06:08:22 -0500 Subject: [PATCH] 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 --- .../Components/Observer/GhostComponent.cs | 19 ++++++++++++++++++- .../Entities/Mobs/Player/observer.yml | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/Components/Observer/GhostComponent.cs b/Content.Server/GameObjects/Components/Observer/GhostComponent.cs index 43d22038f7..1a36f8fd8c 100644 --- a/Content.Server/GameObjects/Components/Observer/GhostComponent.cs +++ b/Content.Server/GameObjects/Components/Observer/GhostComponent.cs @@ -15,15 +15,22 @@ using Robust.Shared.Interfaces.Network; using Robust.Shared.IoC; using Robust.Shared.Players; 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 namespace Content.Server.GameObjects.Components.Observer { [RegisterComponent] - public class GhostComponent : SharedGhostComponent + public class GhostComponent : SharedGhostComponent, IExamine { private bool _canReturnToBody = true; + private TimeSpan _timeOfDeath = TimeSpan.Zero; [Dependency] private readonly IPlayerManager _playerManager = default!; + [Dependency] private readonly IGameTiming _gameTimer = default!; [ViewVariables(VVAccess.ReadWrite)] public bool CanReturnToBody { @@ -40,6 +47,7 @@ namespace Content.Server.GameObjects.Components.Observer base.Initialize(); Owner.EnsureComponent().Layer = (int) VisibilityFlags.Ghost; + _timeOfDeath = _gameTimer.RealTime; } public override ComponentState GetComponentState() => new GhostComponentState(CanReturnToBody); @@ -139,6 +147,15 @@ namespace Content.Server.GameObjects.Components.Observer return comp.EntityQuery().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 GhostReturnMessage(Mind sender) diff --git a/Resources/Prototypes/Entities/Mobs/Player/observer.yml b/Resources/Prototypes/Entities/Mobs/Player/observer.yml index 5ead82503c..7b29a537a2 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/observer.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/observer.yml @@ -6,6 +6,8 @@ description: Boo! components: - type: Mind + - type: Clickable + - type: InteractionOutline - type: Physics anchored: false mass: 5