Files
tbd-station-14/Content.Shared/Atmos/EntitySystems/SharedGasMinerSystem.cs
Mervill b8d10a3f5e Add verbose (client predicted!) examine text to Gas Miners (#30480)
* add verbose examine text to gas miners so their behaviour can be understood

* no need for these to be properties

* use an enum instead of two booleans for the miner state

* require the gas miner to be anchored in order to not be disabled

* xmldoc

* pr feedback

* file-scope namespace

* it's to late to hide my transgressions in a rebase

* turns out the normal examine distance is totally fine for this
2024-08-08 12:14:31 +10:00

56 lines
2.1 KiB
C#

using Content.Shared.Atmos.Components;
using Content.Shared.Examine;
using Content.Shared.Temperature;
namespace Content.Shared.Atmos.EntitySystems;
public abstract class SharedGasMinerSystem : EntitySystem
{
[Dependency] private readonly SharedAtmosphereSystem _sharedAtmosphereSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<GasMinerComponent, ExaminedEvent>(OnExamine);
}
private void OnExamine(Entity<GasMinerComponent> ent, ref ExaminedEvent args)
{
var component = ent.Comp;
using (args.PushGroup(nameof(GasMinerComponent)))
{
args.PushMarkup(Loc.GetString("gas-miner-mines-text",
("gas", Loc.GetString(_sharedAtmosphereSystem.GetGas(component.SpawnGas).Name))));
args.PushText(Loc.GetString("gas-miner-amount-text",
("moles", $"{component.SpawnAmount:0.#}")));
args.PushText(Loc.GetString("gas-miner-temperature-text",
("tempK", $"{component.SpawnTemperature:0.#}"),
("tempC", $"{TemperatureHelpers.KelvinToCelsius(component.SpawnTemperature):0.#}")));
if (component.MaxExternalAmount < float.PositiveInfinity)
{
args.PushText(Loc.GetString("gas-miner-moles-cutoff-text",
("moles", $"{component.MaxExternalAmount:0.#}")));
}
if (component.MaxExternalPressure < float.PositiveInfinity)
{
args.PushText(Loc.GetString("gas-miner-pressure-cutoff-text",
("pressure", $"{component.MaxExternalPressure:0.#}")));
}
args.AddMarkup(component.MinerState switch
{
GasMinerState.Disabled => Loc.GetString("gas-miner-state-disabled-text"),
GasMinerState.Idle => Loc.GetString("gas-miner-state-idle-text"),
GasMinerState.Working => Loc.GetString("gas-miner-state-working-text"),
// C# pattern matching is not exhaustive for enums
_ => throw new IndexOutOfRangeException(nameof(component.MinerState)),
});
}
}
}