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
This commit is contained in:
Mervill
2024-08-07 19:14:31 -07:00
committed by GitHub
parent 9645f5528b
commit b8d10a3f5e
7 changed files with 226 additions and 127 deletions

View File

@@ -0,0 +1,55 @@
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)),
});
}
}
}