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:
F77F
2020-10-25 06:08:22 -05:00
committed by GitHub
parent 45ace1d345
commit c21920df6c
2 changed files with 20 additions and 1 deletions

View File

@@ -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<VisibilityComponent>().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<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 GhostReturnMessage(Mind sender)

View File

@@ -6,6 +6,8 @@
description: Boo!
components:
- type: Mind
- type: Clickable
- type: InteractionOutline
- type: Physics
anchored: false
mass: 5