From fee5ae05bc552a9d21578285def7b75418df5718 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Thu, 13 Aug 2020 13:51:57 +0200 Subject: [PATCH] Add more atmos helpers (#1661) --- Content.Server/Atmos/AtmosHelpers.cs | 37 +++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/Content.Server/Atmos/AtmosHelpers.cs b/Content.Server/Atmos/AtmosHelpers.cs index 4a4eb37d0c..5561b70639 100644 --- a/Content.Server/Atmos/AtmosHelpers.cs +++ b/Content.Server/Atmos/AtmosHelpers.cs @@ -1,9 +1,9 @@ -using Content.Server.GameObjects.EntitySystems; +#nullable enable +using System.Diagnostics.CodeAnalysis; +using Content.Server.GameObjects.EntitySystems; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Map; -#nullable enable - namespace Content.Server.Atmos { public static class AtmosHelpers @@ -15,11 +15,42 @@ namespace Content.Server.Atmos return gridAtmos?.GetTile(coordinates); } + public static GasMixture? GetTileAir(this GridCoordinates coordinates) + { + return coordinates.GetTileAtmosphere()?.Air; + } + + public static bool TryGetTileAtmosphere(this GridCoordinates coordinates, [NotNullWhen(true)] out TileAtmosphere atmosphere) + { + return (atmosphere = coordinates.GetTileAtmosphere()!) != default; + } + + public static bool TryGetTileAir(this GridCoordinates coordinates, [NotNullWhen(true)] out GasMixture air) + { + return !(air = coordinates.GetTileAir()!).Equals(default); + } + public static TileAtmosphere? GetTileAtmosphere(this MapIndices indices, GridId gridId) { var gridAtmos = EntitySystem.Get().GetGridAtmosphere(gridId); return gridAtmos?.GetTile(indices); } + + public static GasMixture? GetTileAir(this MapIndices indices, GridId gridId) + { + return indices.GetTileAtmosphere(gridId)?.Air; + } + + public static bool TryGetTileAtmosphere(this MapIndices indices, GridId gridId, + [NotNullWhen(true)] out TileAtmosphere atmosphere) + { + return (atmosphere = indices.GetTileAtmosphere(gridId)!) != default; + } + + public static bool TryGetTileAir(this MapIndices indices, GridId gridId, [NotNullWhen(true)] out GasMixture air) + { + return !(air = indices.GetTileAir(gridId)!).Equals(default); + } } }