Skip to content

Commit 22e1a50

Browse files
[BOUNTY] ssd timer (Goob-Station#6441)
* Create ssdindicator.ftl * Update SSDIndicatorSystem.cs * Update ssdindicator.ftl * revert * Create SSDTimerSystem.cs * Apply suggestion from @NotActuallyMarty --------- Co-authored-by: NotActuallyMarty <27968892+NotActuallyMarty@users.noreply.github.com>
1 parent e3e011b commit 22e1a50

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using Content.Shared.Examine;
2+
using Content.Shared.CCVar;
3+
using Content.Shared.SSDIndicator;
4+
using Robust.Shared.Timing;
5+
using Robust.Shared.Configuration;
6+
7+
namespace Content.Goobstation.Shared.SSDTimer;
8+
9+
public sealed class SSDTimerSystem : EntitySystem
10+
{
11+
[Dependency] private readonly IConfigurationManager _cfg = default!;
12+
[Dependency] private readonly IGameTiming _timing = default!;
13+
14+
private float _icSsdSleepTime;
15+
16+
public override void Initialize()
17+
{
18+
base.Initialize();
19+
20+
SubscribeLocalEvent<SSDIndicatorComponent, ExaminedEvent>(OnExamined);
21+
22+
_cfg.OnValueChanged(CCVars.ICSSDSleepTime, obj => _icSsdSleepTime = obj, true);
23+
24+
}
25+
26+
private void OnExamined(EntityUid uid, SSDIndicatorComponent component, ExaminedEvent args)
27+
{
28+
if (!args.IsInDetailsRange || !component.IsSSD)
29+
return;
30+
31+
var timeFellAsleep = component.FallAsleepTime - TimeSpan.FromSeconds(_icSsdSleepTime);
32+
var time = _timing.CurTime - timeFellAsleep;
33+
args.PushMarkup(Loc.GetString("comp-ssd-person-examined", ("ent", uid), ("time", (int) time.TotalMinutes)));
34+
}
35+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
comp-ssd-person-examined = [color=yellow]{ CAPITALIZE(SUBJECT($ent)) } has been asleep for { $time ->
2+
[one] { $time } minute
3+
*[other] { $time } minutes
4+
}.[/color]

0 commit comments

Comments
 (0)