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:
@@ -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");
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user