Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions Content.Client/Atmos/Consoles/AtmosAlarmEntryContainer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,30 @@ public sealed partial class AtmosAlarmEntryContainer : BoxContainer
[AtmosAlarmType.Danger] = "atmos-alerts-window-danger-state",
};

private Dictionary<Gas, string> _gasShorthands = new Dictionary<Gas, string>()
{
[Gas.Ammonia] = "NH₃",
[Gas.CarbonDioxide] = "CO₂",
[Gas.Frezon] = "F",
[Gas.Nitrogen] = "N₂",
[Gas.NitrousOxide] = "N₂O",
[Gas.Oxygen] = "O₂",
[Gas.Plasma] = "P",
[Gas.Tritium] = "T",
[Gas.WaterVapor] = "H₂O",
[Gas.BZ] = "BZ",
[Gas.Healium] = "F₃BZ",
[Gas.Nitrium] = "N",
[Gas.Pluoxium] = "Pl₂",
[Gas.Hydrogen] = "H₂",
[Gas.HyperNoblium] = "HN₂",
[Gas.ProtoNitrate] = "PN₂",
[Gas.Zauker] = "Z₂",
[Gas.Halon] = "Ha₂",
[Gas.Helium] = "He₂",
[Gas.AntiNoblium] = "AN₂",
};

public AtmosAlarmEntryContainer(NetEntity uid, EntityCoordinates? coordinates)
{
RobustXamlLoader.Load(this);
Expand Down Expand Up @@ -149,11 +173,12 @@ public void UpdateEntry(AtmosAlertsComputerEntry entry, bool isFocus, AtmosAlert
foreach ((var gas, (var mol, var percent, var alert)) in keyValuePairs)
{
FixedPoint2 gasPercent = percent * 100f;
var gasAbbreviation = Atmospherics.GasAbbreviations.GetValueOrDefault(gas, Loc.GetString("gas-unknown-abbreviation"));

var gasShorthand = _gasShorthands.GetValueOrDefault(gas, "X");

var gasLabel = new Label()
{
Text = Loc.GetString("atmos-alerts-window-other-gases-value", ("shorthand", gasAbbreviation), ("value", gasPercent)),
Text = Loc.GetString("atmos-alerts-window-other-gases-value", ("shorthand", gasShorthand), ("value", gasPercent)),
FontOverride = normalFont,
FontColorOverride = GetAlarmStateColor(alert),
HorizontalAlignment = HAlignment.Center,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Client.Stylesheets;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Components;
using Content.Shared.Atmos.EntitySystems;
using Content.Shared.FixedPoint;
using Content.Shared.Temperature;
using Robust.Client.AutoGenerated;
Expand All @@ -19,12 +20,14 @@ public sealed partial class AtmosMonitoringEntryContainer : BoxContainer

private readonly IEntityManager _entManager;
private readonly IResourceCache _cache;
private readonly SharedAtmosphereSystem _atmosphereSystem; // Adventure edit

public AtmosMonitoringEntryContainer(AtmosMonitoringConsoleEntry data)
{
RobustXamlLoader.Load(this);
_entManager = IoCManager.Resolve<IEntityManager>();
_cache = IoCManager.Resolve<IResourceCache>();
_atmosphereSystem = _entManager.System<SharedAtmosphereSystem>(); // Adventure edit

Data = data;

Expand Down Expand Up @@ -132,7 +135,10 @@ public void UpdateEntry(AtmosMonitoringConsoleEntry updatedData, bool isFocus)
var gasPercent = (FixedPoint2)0f;
gasPercent = percent * 100f;

var gasAbbreviation = Atmospherics.GasAbbreviations.GetValueOrDefault(gas, Loc.GetString("gas-unknown-abbreviation"));
var proto = ((int)gas >= 0 && (int)gas < Atmospherics.TotalNumberOfGases) ? _atmosphereSystem.GetGas((int)gas) : null;
var gasAbbreviation = proto?.Abbreviation is { } abbrev
? Loc.GetString(abbrev.Id ?? "gas-unknown-abbreviation")
: Loc.GetString("gas-unknown-abbreviation");

var gasLabel = new Label()
{
Expand Down
31 changes: 23 additions & 8 deletions Content.Client/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ namespace Content.Client.Atmos.EntitySystems
[UsedImplicitly]
internal sealed class AtmosDebugOverlaySystem : SharedAtmosDebugOverlaySystem
{
public readonly Dictionary<EntityUid, AtmosDebugOverlayMessage> TileData = new();
[Dependency] private readonly IOverlayManager _overlayManager = default!;

public readonly Dictionary<EntityUid, AtmosDebugOverlayMessage> TileData = [];

// Configuration set by debug commands and used by AtmosDebugOverlay {
/// <summary>Value source for display</summary>
Expand All @@ -25,6 +27,8 @@ internal sealed class AtmosDebugOverlaySystem : SharedAtmosDebugOverlaySystem
public bool CfgCBM = false;
// }

private AtmosDebugOverlay? _overlay;

public override void Initialize()
{
base.Initialize();
Expand All @@ -34,10 +38,6 @@ public override void Initialize()
SubscribeNetworkEvent<AtmosDebugOverlayDisableMessage>(HandleAtmosDebugOverlayDisableMessage);

SubscribeLocalEvent<GridRemovalEvent>(OnGridRemoved);

var overlayManager = IoCManager.Resolve<IOverlayManager>();
if(!overlayManager.HasOverlay<AtmosDebugOverlay>())
overlayManager.AddOverlay(new AtmosDebugOverlay(this));
}

private void OnGridRemoved(GridRemovalEvent ev)
Expand All @@ -51,19 +51,25 @@ private void OnGridRemoved(GridRemovalEvent ev)
private void HandleAtmosDebugOverlayMessage(AtmosDebugOverlayMessage message)
{
TileData[GetEntity(message.GridId)] = message;

if (_overlay is not null)
return;

_overlay = new AtmosDebugOverlay(this);
_overlayManager.AddOverlay(_overlay);
}

private void HandleAtmosDebugOverlayDisableMessage(AtmosDebugOverlayDisableMessage ev)
{
TileData.Clear();
RemoveOverlay();
}

public override void Shutdown()
{
base.Shutdown();
var overlayManager = IoCManager.Resolve<IOverlayManager>();
if (overlayManager.HasOverlay<AtmosDebugOverlay>())
overlayManager.RemoveOverlay<AtmosDebugOverlay>();

RemoveOverlay();
}

public void Reset(RoundRestartCleanupEvent ev)
Expand All @@ -75,6 +81,15 @@ public bool HasData(EntityUid gridId)
{
return TileData.ContainsKey(gridId);
}

private void RemoveOverlay()
{
if (_overlay is null)
return;

_overlayManager.RemoveOverlay(_overlay);
_overlay = null;
}
}

internal enum AtmosDebugOverlayMode : byte
Expand Down
17 changes: 17 additions & 0 deletions Content.Client/Atmos/EntitySystems/AtmosphereSystem.CVars.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Content.Shared.CCVar;
using Robust.Shared.Configuration;

namespace Content.Client.Atmos.EntitySystems;

public sealed partial class AtmosphereSystem
{
[Dependency] private readonly IConfigurationManager _cfg = default!;

private void InitializeCVars()
{
_cfg.OnValueChanged(
CCVars.AtmosHeatScale,
v => HeatScale = MathF.Max(0.000001f, v),
invokeImmediately: true);
}
}
58 changes: 58 additions & 0 deletions Content.Client/Atmos/EntitySystems/AtmosphereSystem.Gases.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System.Runtime.CompilerServices;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Reactions;

namespace Content.Client.Atmos.EntitySystems;

public sealed partial class AtmosphereSystem
{
/*
Partial class for operations involving GasMixtures.

Any method that is overridden here is usually because the server-sided implementation contains
code that would escape sandbox. As such these methods are overridden here with a safe
implementation.
*/

/// <inheritdoc/>
/// <remarks>No-op on client as reactions aren't entirely in shared.
/// Don't call it. Smile.</remarks>
public override ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder)
{
return ReactionResult.NoReaction;
}

public override bool IsMixtureFuel(GasMixture mixture, float epsilon = Atmospherics.GasMinMoles)
{
var tmp = new float[Atmospherics.AdjustedNumberOfGases];
NumericsHelpers.Multiply(mixture.Moles, GasFuelMask, tmp);
return NumericsHelpers.HorizontalAdd(tmp) > epsilon;
}

public override bool IsMixtureOxidizer(GasMixture mixture, float epsilon = Atmospherics.GasMinMoles)
{
var tmp = new float[Atmospherics.AdjustedNumberOfGases];
NumericsHelpers.Multiply(mixture.Moles, GasOxidizerMask, tmp);
return NumericsHelpers.HorizontalAdd(tmp) > epsilon;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected override float GetHeatCapacityCalculation(float[] moles, bool space)
{
// Little hack to make space gas mixtures have heat capacity, therefore allowing them to cool down rooms.
if (space && MathHelper.CloseTo(NumericsHelpers.HorizontalAdd(moles), 0f))
{
return Atmospherics.SpaceHeatCapacity;
}

// explicit stackalloc call is banned on client tragically.
// the JIT does not stackalloc this during runtime,
// though this isnt the hottest code path so it should be fine
// the gc can eat a little as a treat
var tmp = new float[moles.Length];
NumericsHelpers.Multiply(moles, GasSpecificHeats, tmp);
// Adjust heat capacity by speedup, because this is primarily what
// determines how quickly gases heat up/cool.
return MathF.Max(NumericsHelpers.HorizontalAdd(tmp), Atmospherics.MinimumHeatCapacity);
}
}
3 changes: 2 additions & 1 deletion Content.Client/Atmos/EntitySystems/AtmosphereSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@

namespace Content.Client.Atmos.EntitySystems;

public sealed class AtmosphereSystem : SharedAtmosphereSystem
public sealed partial class AtmosphereSystem : SharedAtmosphereSystem // Adventure edit
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MapAtmosphereComponent, ComponentHandleState>(OnMapHandleState);
InitializeCVars(); // Adventure edit
}

private void OnMapHandleState(EntityUid uid, MapAtmosphereComponent component, ref ComponentHandleState args)
Expand Down
30 changes: 30 additions & 0 deletions Content.Client/Atmos/EntitySystems/GasTileFireOverlaySystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Content.Client.Atmos.Overlays;
using JetBrains.Annotations;
using Robust.Client.Graphics;

namespace Content.Client.Atmos.EntitySystems;

/// <summary>
/// System responsible for rendering atmos fire animations using <see cref="GasTileFireOverlay"/>.
/// </summary>
[UsedImplicitly]
public sealed class GasTileFireOverlaySystem : EntitySystem
{
[Dependency] private readonly IOverlayManager _overlayMan = default!;

private GasTileFireOverlay _fireOverlay = default!;

public override void Initialize()
{
base.Initialize();

_fireOverlay = new GasTileFireOverlay();
_overlayMan.AddOverlay(_fireOverlay);
}

public override void Shutdown()
{
base.Shutdown();
_overlayMan.RemoveOverlay<GasTileFireOverlay>();
}
}
Loading
Loading