Salvage magnet shows cooldown time on Examine (revived) (#14007)

* Added salvage magnet cooldown time on Examine

* weh

* Style issues

* mirrorcult feedback

---------

Co-authored-by: dmnct <asp1@tuta.io>
Co-authored-by: deltanedas <user@zenith>
This commit is contained in:
deltanedas
2023-03-03 16:25:42 +00:00
committed by GitHub
parent 1d0e5cca3a
commit ff6527f2a4
2 changed files with 18 additions and 11 deletions

View File

@@ -141,8 +141,22 @@ namespace Content.Server.Salvage
private void OnExamined(EntityUid uid, SalvageMagnetComponent component, ExaminedEvent args)
{
var gotGrid = false;
var remainingTime = TimeSpan.Zero;
if (!args.IsInDetailsRange)
return;
if (Transform(uid).GridUid is EntityUid gridId &&
_salvageGridStates.TryGetValue(gridId, out var salvageGridState))
{
remainingTime = component.MagnetState.Until - salvageGridState.CurrentTime;
gotGrid = true;
}
else
{
Logger.WarningS("salvage", "Failed to load salvage grid state, can't display remaining time");
}
switch (component.MagnetState.StateType)
{
case MagnetStateType.Inactive:
@@ -155,19 +169,12 @@ namespace Content.Server.Salvage
args.PushMarkup(Loc.GetString("salvage-system-magnet-examined-releasing"));
break;
case MagnetStateType.CoolingDown:
args.PushMarkup(Loc.GetString("salvage-system-magnet-examined-cooling-down"));
if (gotGrid)
args.PushMarkup(Loc.GetString("salvage-system-magnet-examined-cooling-down", ("timeLeft", Math.Ceiling(remainingTime.TotalSeconds))));
break;
case MagnetStateType.Holding:
var magnetTransform = EntityManager.GetComponent<TransformComponent>(component.Owner);
if (magnetTransform.GridUid is EntityUid gridId && _salvageGridStates.TryGetValue(gridId, out var salvageGridState))
{
var remainingTime = component.MagnetState.Until - salvageGridState.CurrentTime;
if (gotGrid)
args.PushMarkup(Loc.GetString("salvage-system-magnet-examined-active", ("timeLeft", Math.Ceiling(remainingTime.TotalSeconds))));
}
else
{
Logger.WarningS("salvage", "Failed to load salvage grid state, can't display remaining time");
}
break;
default:
throw new NotImplementedException("Unexpected magnet state type");

View File

@@ -18,4 +18,4 @@ salvage-system-magnet-examined-active = The salvage magnet is holding salvage in
*[other] { $timeLeft } seconds.
}
salvage-system-magnet-examined-releasing = The salvage magnet is releasing the salvage.
salvage-system-magnet-examined-cooling-down = The salvage magnet is cooling down.
salvage-system-magnet-examined-cooling-down = The salvage magnet is cooling down. It will be ready in: {$timeLeft} seconds.