ECS Atmos Part 3: Removes AtmosHelpers, add many methods to AtmosphereSystem. (#4285)
* ECS Atmos Part 3: Removes AtmosHelpers, add many methods to AtmosphereSystem * Adds API for adding/removing active tiles. * Adds API for FixVacuum. * Adds API for UpdateAdjacent. * Adds API for IsTileAirBlocked. * Re-organize hotspot code * Adds API for IsTileSpace. * RemoveGasCommand uses AtmosphereSystem * AddGasCommand uses AtmosphereSystem. * SetTemperatureCommand uses AtmosphereSystem. * Adds API for IsSimulatedGrid. * GasLeak uses AtmosphereSystem. * Makes Spark method in GasLeak ALSO use AtmosphereSystem. * GasPassiveVentSystem uses AtmosphereSystem. * GasMinerSystem uses AtmosphereSystem. * GasOutletInjectorSystem uses AtmosphereSystem. * GasVentPumpSystem uses AtmosphereSystem. * GasDualPortVentPumpSystem uses AtmosphereSystem. * GasVolumePumpSystem uses AtmosphereSystem. * GasAnalyzerComponent uses AtmosphereSystem. * Add API for GetAdjacentTileMixtures. * GasVentScrubberSystem uses AtmosphereSystem. * AirtightComponent uses AtmosphereSystem. * GasLeaks's TryFindRandomTile uses AtmosphereSystem. * Adds API for GetAdjacentTiles. * FirelockComponent's IsHoldingFire uses AtmosphereSystem. * Adds API for GetAllTileMixtures. * DeleteGasCommand uses AtmosphereSystem. * FixGridAtmos uses AtmosphereSystem. * FillGasCommand uses AtmosphereSystem. * SetAtmosTemperatureCommand uses AtmosphereSystem.
This commit is contained in:
committed by
GitHub
parent
10ced26b0d
commit
c8ba345cdc
@@ -1,61 +0,0 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Server.Atmos
|
||||
{
|
||||
public static class AtmosHelpers
|
||||
{
|
||||
public static TileAtmosphere? GetTileAtmosphere(this EntityCoordinates coordinates)
|
||||
{
|
||||
return EntitySystem.Get<AtmosphereSystem>().GetGridAtmosphere(coordinates).GetTile(coordinates);
|
||||
}
|
||||
|
||||
public static GasMixture? GetTileAir(this EntityCoordinates coordinates, IEntityManager? entityManager = null)
|
||||
{
|
||||
return coordinates.GetTileAtmosphere()?.Air;
|
||||
}
|
||||
|
||||
public static bool TryGetTileAtmosphere(this EntityCoordinates coordinates, [NotNullWhen(true)] out TileAtmosphere? atmosphere)
|
||||
{
|
||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
||||
return !Equals(atmosphere = coordinates.GetTileAtmosphere(), default);
|
||||
}
|
||||
|
||||
public static bool TryGetTileAir(this EntityCoordinates coordinates, [NotNullWhen(true)] out GasMixture? air, IEntityManager? entityManager = null)
|
||||
{
|
||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
||||
return !Equals(air = coordinates.GetTileAir(entityManager), default);
|
||||
}
|
||||
|
||||
public static bool IsTileAirProbablySafe(this EntityCoordinates coordinates)
|
||||
{
|
||||
// Note that oxygen mix isn't checked, but survival boxes make that not necessary.
|
||||
var air = coordinates.GetTileAir();
|
||||
if (air == null)
|
||||
return false;
|
||||
if (air.Pressure <= Atmospherics.WarningLowPressure)
|
||||
return false;
|
||||
if (air.Pressure >= Atmospherics.WarningHighPressure)
|
||||
return false;
|
||||
if (air.Temperature <= 260)
|
||||
return false;
|
||||
if (air.Temperature >= 360)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool InvalidateTileAir(this EntityCoordinates coordinates)
|
||||
{
|
||||
if (!coordinates.TryGetTileAtmosphere(out var tileAtmos))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
tileAtmos.Invalidate();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@ namespace Content.Server.Atmos.Components
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
private (GridId, Vector2i) _lastPosition;
|
||||
private AtmosphereSystem _atmosphereSystem = default!;
|
||||
|
||||
public override string Name => "Airtight";
|
||||
|
||||
@@ -76,8 +75,6 @@ namespace Content.Server.Atmos.Components
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
if (_fixAirBlockedDirectionInitialize)
|
||||
RotateEvent(new RotateEvent(Owner, Angle.Zero, Owner.Transform.WorldRotation));
|
||||
|
||||
@@ -132,7 +129,7 @@ namespace Content.Server.Atmos.Components
|
||||
|
||||
if (_fixVacuum)
|
||||
{
|
||||
_atmosphereSystem.GetGridAtmosphere(_lastPosition.Item1)?.FixVacuum(_lastPosition.Item2);
|
||||
EntitySystem.Get<AtmosphereSystem>().FixVacuum(_lastPosition.Item1, _lastPosition.Item2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,10 +161,9 @@ namespace Content.Server.Atmos.Components
|
||||
if (!gridId.IsValid())
|
||||
return;
|
||||
|
||||
var gridAtmos = _atmosphereSystem.GetGridAtmosphere(gridId);
|
||||
|
||||
gridAtmos?.UpdateAdjacentBits(pos);
|
||||
gridAtmos?.Invalidate(pos);
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
atmosphereSystem.UpdateAdjacent(gridId, pos);
|
||||
atmosphereSystem.InvalidateTile(gridId, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,15 +74,12 @@ namespace Content.Server.Atmos.Components
|
||||
{
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
var gridAtmosphere = atmosphereSystem.GetGridAtmosphere(Owner.Transform.Coordinates);
|
||||
|
||||
var minMoles = float.MaxValue;
|
||||
var maxMoles = 0f;
|
||||
|
||||
foreach (var (_, adjacent) in gridAtmosphere.GetAdjacentTiles(Owner.Transform.Coordinates))
|
||||
foreach (var adjacent in atmosphereSystem.GetAdjacentTileMixtures(Owner.Transform.Coordinates))
|
||||
{
|
||||
// includeAirBlocked remains false, and therefore Air must be present
|
||||
var moles = adjacent.Air!.TotalMoles;
|
||||
var moles = adjacent.TotalMoles;
|
||||
if (moles < minMoles)
|
||||
minMoles = moles;
|
||||
if (moles > maxMoles)
|
||||
@@ -96,17 +93,18 @@ namespace Content.Server.Atmos.Components
|
||||
{
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
if (!Owner.Transform.Coordinates.TryGetTileAtmosphere(out var tileAtmos))
|
||||
if (!atmosphereSystem.TryGetGridAndTile(Owner.Transform.Coordinates, out var tuple))
|
||||
return false;
|
||||
|
||||
if (tileAtmos.Hotspot.Valid)
|
||||
if (atmosphereSystem.GetTileMixture(tuple.Value.Grid, tuple.Value.Tile) == null)
|
||||
return false;
|
||||
|
||||
if (atmosphereSystem.IsHotspotActive(tuple.Value.Grid, tuple.Value.Tile))
|
||||
return true;
|
||||
|
||||
var gridAtmosphere = atmosphereSystem.GetGridAtmosphere(Owner.Transform.Coordinates);
|
||||
|
||||
foreach (var (_, adjacent) in gridAtmosphere.GetAdjacentTiles(tileAtmos.GridIndices))
|
||||
foreach (var adjacent in atmosphereSystem.GetAdjacentTiles(Owner.Transform.Coordinates))
|
||||
{
|
||||
if (adjacent.Hotspot.Valid)
|
||||
if (atmosphereSystem.IsHotspotActive(tuple.Value.Grid, adjacent))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,8 +123,7 @@ namespace Content.Server.Atmos.Components
|
||||
{
|
||||
// Already get the pressure before Dirty(), because we can't get the EntitySystem in that thread or smth
|
||||
var pressure = 0f;
|
||||
var gam = EntitySystem.Get<AtmosphereSystem>().GetGridAtmosphere(Owner.Transform.Coordinates);
|
||||
var tile = gam?.GetTile(Owner.Transform.Coordinates)?.Air;
|
||||
var tile = EntitySystem.Get<AtmosphereSystem>().GetTileMixture(Owner.Transform.Coordinates);
|
||||
if (tile != null)
|
||||
{
|
||||
pressure = tile.Pressure;
|
||||
@@ -182,9 +181,8 @@ namespace Content.Server.Atmos.Components
|
||||
pos = _position.Value;
|
||||
}
|
||||
|
||||
var atmosSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
var gam = atmosSystem.GetGridAtmosphere(pos);
|
||||
var tile = gam.GetTile(pos)?.Air;
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
var tile = atmosphereSystem.GetTileMixture(pos);
|
||||
if (tile == null)
|
||||
{
|
||||
error = "No Atmosphere!";
|
||||
@@ -201,7 +199,7 @@ namespace Content.Server.Atmos.Components
|
||||
|
||||
for (var i = 0; i < Atmospherics.TotalNumberOfGases; i++)
|
||||
{
|
||||
var gas = atmosSystem.GetGas(i);
|
||||
var gas = atmosphereSystem.GetGas(i);
|
||||
|
||||
if (tile.Moles[i] <= Atmospherics.GasMinMoles) continue;
|
||||
|
||||
|
||||
@@ -278,8 +278,9 @@ namespace Content.Server.Atmos.Components
|
||||
{
|
||||
if (_integrity <= 0)
|
||||
{
|
||||
var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere();
|
||||
tileAtmos?.AssumeAir(Air);
|
||||
var environment = atmosphereSystem.GetTileMixture(Owner.Transform.Coordinates, true);
|
||||
if(environment != null)
|
||||
atmosphereSystem.Merge(environment, Air);
|
||||
|
||||
SoundSystem.Play(Filter.Pvs(Owner), "Audio/Effects/spray.ogg", Owner.Transform.Coordinates,
|
||||
AudioHelpers.WithVariation(0.125f));
|
||||
@@ -296,12 +297,12 @@ namespace Content.Server.Atmos.Components
|
||||
{
|
||||
if (_integrity <= 0)
|
||||
{
|
||||
var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere();
|
||||
if (tileAtmos == null)
|
||||
var environment = atmosphereSystem.GetTileMixture(Owner.Transform.Coordinates, true);
|
||||
if (environment == null)
|
||||
return;
|
||||
|
||||
var leakedGas = Air.RemoveRatio(0.25f);
|
||||
tileAtmos.AssumeAir(leakedGas);
|
||||
atmosphereSystem.Merge(environment, leakedGas);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
1000
Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs
Normal file
1000
Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,17 +1,12 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.NodeContainer.EntitySystems;
|
||||
using Content.Shared.Atmos.EntitySystems;
|
||||
using Content.Shared.Maps;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.Atmos.EntitySystems
|
||||
{
|
||||
@@ -20,16 +15,11 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _protoMan = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IPauseManager _pauseManager = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
|
||||
private GridTileLookupSystem? _gridTileLookup = null;
|
||||
|
||||
private const float ExposedUpdateDelay = 1f;
|
||||
private float _exposedTimer = 0f;
|
||||
|
||||
public GridTileLookupSystem GridTileLookupSystem => _gridTileLookup ??= Get<GridTileLookupSystem>();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -81,73 +71,6 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
map.AddComponent<SpaceGridAtmosphereComponent>();
|
||||
}
|
||||
|
||||
#region Helper Methods
|
||||
public IGridAtmosphereComponent? GetGridAtmosphere(GridId gridId)
|
||||
{
|
||||
if (!gridId.IsValid())
|
||||
return null;
|
||||
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid))
|
||||
return null;
|
||||
|
||||
return ComponentManager.TryGetComponent(grid.GridEntityId, out IGridAtmosphereComponent? gridAtmosphere)
|
||||
? gridAtmosphere : null;
|
||||
}
|
||||
|
||||
public IGridAtmosphereComponent GetGridAtmosphere(EntityCoordinates coordinates)
|
||||
{
|
||||
return GetGridAtmosphere(coordinates.ToMap(EntityManager));
|
||||
}
|
||||
|
||||
public IGridAtmosphereComponent GetGridAtmosphere(MapCoordinates coordinates)
|
||||
{
|
||||
if (coordinates.MapId == MapId.Nullspace)
|
||||
{
|
||||
throw new ArgumentException($"Coordinates cannot be in nullspace!", nameof(coordinates));
|
||||
}
|
||||
|
||||
if (_mapManager.TryFindGridAt(coordinates, out var grid))
|
||||
{
|
||||
if (ComponentManager.TryGetComponent(grid.GridEntityId, out IGridAtmosphereComponent? atmos))
|
||||
{
|
||||
return atmos;
|
||||
}
|
||||
}
|
||||
|
||||
return _mapManager.GetMapEntity(coordinates.MapId).GetComponent<IGridAtmosphereComponent>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unlike <see cref="GetGridAtmosphere"/>, this doesn't return space grid when not found.
|
||||
/// </summary>
|
||||
public bool TryGetSimulatedGridAtmosphere(MapCoordinates coordinates, [NotNullWhen(true)] out IGridAtmosphereComponent? atmosphere)
|
||||
{
|
||||
if (coordinates.MapId == MapId.Nullspace)
|
||||
{
|
||||
atmosphere = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_mapManager.TryFindGridAt(coordinates, out var mapGrid)
|
||||
&& ComponentManager.TryGetComponent(mapGrid.GridEntityId, out IGridAtmosphereComponent? atmosGrid)
|
||||
&& atmosGrid.Simulated)
|
||||
{
|
||||
atmosphere = atmosGrid;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_mapManager.GetMapEntity(coordinates.MapId).TryGetComponent(out IGridAtmosphereComponent? atmosMap)
|
||||
&& atmosMap.Simulated)
|
||||
{
|
||||
atmosphere = atmosMap;
|
||||
return true;
|
||||
}
|
||||
|
||||
atmosphere = null;
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
@@ -158,9 +81,11 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
|
||||
if (_exposedTimer >= ExposedUpdateDelay)
|
||||
{
|
||||
foreach (var exposed in EntityManager.ComponentManager.EntityQuery<AtmosExposedComponent>(true))
|
||||
foreach (var exposed in EntityManager.ComponentManager.EntityQuery<AtmosExposedComponent>())
|
||||
{
|
||||
var tile = exposed.Owner.Transform.Coordinates.GetTileAtmosphere();
|
||||
// TODO ATMOS: Kill this with fire.
|
||||
var atmos = GetGridAtmosphere(exposed.Owner.Transform.Coordinates);
|
||||
var tile = atmos.GetTile(exposed.Owner.Transform.Coordinates);
|
||||
if (tile == null) continue;
|
||||
exposed.Update(tile, _exposedTimer, this);
|
||||
}
|
||||
|
||||
@@ -46,10 +46,11 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
||||
|| !nodeContainer.TryGetNode(vent.OutletName, out PipeNode? outlet))
|
||||
return;
|
||||
|
||||
var environment = args.Atmosphere.GetTile(vent.Owner.Transform.Coordinates)!;
|
||||
var atmosphereSystem = Get<AtmosphereSystem>();
|
||||
var environment = atmosphereSystem.GetTileMixture(vent.Owner.Transform.Coordinates, true);
|
||||
|
||||
// We're in an air-blocked tile... Do nothing.
|
||||
if (environment.Air == null)
|
||||
if (environment == null)
|
||||
return;
|
||||
|
||||
if (vent.PumpDirection == VentPumpDirection.Releasing)
|
||||
@@ -58,38 +59,37 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
||||
var pressureDelta = 10000f;
|
||||
|
||||
if ((vent.PressureChecks & DualPortVentPressureBound.ExternalBound) != 0)
|
||||
pressureDelta = MathF.Min(pressureDelta, (vent.ExternalPressureBound - environment.Air.Pressure));
|
||||
pressureDelta = MathF.Min(pressureDelta, (vent.ExternalPressureBound - environment.Pressure));
|
||||
|
||||
if ((vent.PressureChecks & DualPortVentPressureBound.InputMinimum) != 0)
|
||||
pressureDelta = MathF.Min(pressureDelta, (inlet.Air.Pressure - vent.InputPressureMin));
|
||||
|
||||
if (pressureDelta > 0 && inlet.Air.Temperature > 0)
|
||||
{
|
||||
var transferMoles = pressureDelta * environment.Air.Volume / inlet.Air.Temperature * Atmospherics.R;
|
||||
var transferMoles = pressureDelta * environment.Volume / inlet.Air.Temperature * Atmospherics.R;
|
||||
var removed = inlet.Air.Remove(transferMoles);
|
||||
environment.AssumeAir(removed);
|
||||
atmosphereSystem.Merge(environment, removed);
|
||||
}
|
||||
}
|
||||
else if (vent.PumpDirection == VentPumpDirection.Siphoning && environment.Air.Pressure > 0f)
|
||||
else if (vent.PumpDirection == VentPumpDirection.Siphoning && environment.Pressure > 0f)
|
||||
{
|
||||
appearance?.SetData(VentPumpVisuals.State, VentPumpState.In);
|
||||
var ourMultiplier = outlet.Air.Volume / environment.Air.Temperature * Atmospherics.R;
|
||||
var ourMultiplier = outlet.Air.Volume / environment.Temperature * Atmospherics.R;
|
||||
var molesDelta = 10000 * ourMultiplier;
|
||||
|
||||
if ((vent.PressureChecks & DualPortVentPressureBound.ExternalBound) != 0)
|
||||
molesDelta =
|
||||
MathF.Min(molesDelta,
|
||||
(environment.Air.Pressure - vent.OutputPressureMax) * environment.Air.Volume / (environment.Air.Temperature * Atmospherics.R));
|
||||
(environment.Pressure - vent.OutputPressureMax) * environment.Volume / (environment.Temperature * Atmospherics.R));
|
||||
|
||||
if ((vent.PressureChecks &DualPortVentPressureBound.InputMinimum) != 0)
|
||||
molesDelta = MathF.Min(molesDelta, (vent.InputPressureMin - outlet.Air.Pressure) * ourMultiplier);
|
||||
|
||||
if (molesDelta > 0)
|
||||
{
|
||||
var removed = environment.Air.Remove(molesDelta);
|
||||
var removed = environment.Remove(molesDelta);
|
||||
|
||||
Get<AtmosphereSystem>().Merge(outlet.Air, removed);
|
||||
environment.Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Atmos.Piping.Binary.Components;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.NodeContainer;
|
||||
@@ -55,12 +56,13 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
||||
// Some of the gas from the mixture leaks when overclocked.
|
||||
if (pump.Overclocked)
|
||||
{
|
||||
var tile = args.Atmosphere.GetTile(pump.Owner.Transform.Coordinates);
|
||||
var atmosphereSystem = Get<AtmosphereSystem>();
|
||||
var tile = atmosphereSystem.GetTileMixture(pump.Owner.Transform.Coordinates, true);
|
||||
|
||||
if (tile != null)
|
||||
{
|
||||
var leaked = removed.RemoveRatio(pump.LeakRatio);
|
||||
tile.AssumeAir(leaked);
|
||||
atmosphereSystem.Merge(tile, leaked);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Buffers;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.Construction.Components;
|
||||
@@ -25,7 +26,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
|
||||
if (!component.Enabled || !ComponentManager.TryGetComponent(uid, out NodeContainerComponent? nodes))
|
||||
return;
|
||||
|
||||
if (!component.Owner.Transform.Coordinates.TryGetTileAir(out var environment, EntityManager))
|
||||
if (Get<AtmosphereSystem>().GetTileMixture(component.Owner.Transform.Coordinates) is not {} environment)
|
||||
return;
|
||||
|
||||
foreach (var node in nodes.Nodes.Values)
|
||||
@@ -46,12 +47,10 @@ namespace Content.Server.Atmos.Piping.EntitySystems
|
||||
if (!component.Enabled || !ComponentManager.TryGetComponent(uid, out NodeContainerComponent? nodes))
|
||||
return;
|
||||
|
||||
if (!component.Owner.Transform.Coordinates.TryGetTileAtmosphere(out var environment))
|
||||
environment = null;
|
||||
var atmosphereSystem = Get<AtmosphereSystem>();
|
||||
|
||||
var environmentPressure = environment?.Air?.Pressure ?? 0f;
|
||||
var environmentVolume = environment?.Air?.Volume ?? Atmospherics.CellVolume;
|
||||
var environmentTemperature = environment?.Air?.Volume ?? Atmospherics.TCMB;
|
||||
if (atmosphereSystem.GetTileMixture(component.Owner.Transform.Coordinates, true) is not {} environment)
|
||||
environment = GasMixture.SpaceGas;
|
||||
|
||||
var lost = 0f;
|
||||
var timesLost = 0;
|
||||
@@ -60,16 +59,14 @@ namespace Content.Server.Atmos.Piping.EntitySystems
|
||||
{
|
||||
if (node is not PipeNode pipe) continue;
|
||||
|
||||
var difference = pipe.Air.Pressure - environmentPressure;
|
||||
lost += difference * environmentVolume / (environmentTemperature * Atmospherics.R);
|
||||
var difference = pipe.Air.Pressure - environment.Pressure;
|
||||
lost += difference * environment.Volume / (environment.Temperature * Atmospherics.R);
|
||||
timesLost++;
|
||||
}
|
||||
|
||||
var sharedLoss = lost / timesLost;
|
||||
var buffer = new GasMixture();
|
||||
|
||||
var atmosphereSystem = Get<AtmosphereSystem>();
|
||||
|
||||
foreach (var node in nodes.Nodes.Values)
|
||||
{
|
||||
if (node is not PipeNode pipe) continue;
|
||||
@@ -77,7 +74,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
|
||||
atmosphereSystem.Merge(buffer, pipe.Air.Remove(sharedLoss));
|
||||
}
|
||||
|
||||
environment?.AssumeAir(buffer);
|
||||
atmosphereSystem.Merge(environment, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.Atmos.Piping.Other.Components;
|
||||
using Content.Shared.Atmos;
|
||||
@@ -20,7 +21,9 @@ namespace Content.Server.Atmos.Piping.Other.EntitySystems
|
||||
|
||||
private void OnMinerUpdated(EntityUid uid, GasMinerComponent miner, AtmosDeviceUpdateEvent args)
|
||||
{
|
||||
if (!CheckMinerOperation(args.Atmosphere, miner, out var tile) || !miner.Enabled || !miner.SpawnGas.HasValue || miner.SpawnAmount <= 0f)
|
||||
var atmosphereSystem = Get<AtmosphereSystem>();
|
||||
|
||||
if (!CheckMinerOperation(atmosphereSystem, miner, out var environment) || !miner.Enabled || !miner.SpawnGas.HasValue || miner.SpawnAmount <= 0f)
|
||||
return;
|
||||
|
||||
// Time to mine some gas.
|
||||
@@ -28,22 +31,22 @@ namespace Content.Server.Atmos.Piping.Other.EntitySystems
|
||||
var merger = new GasMixture(1) { Temperature = miner.SpawnTemperature };
|
||||
merger.SetMoles(miner.SpawnGas.Value, miner.SpawnAmount);
|
||||
|
||||
tile.AssumeAir(merger);
|
||||
atmosphereSystem.Merge(environment, merger);
|
||||
}
|
||||
|
||||
private bool CheckMinerOperation(IGridAtmosphereComponent atmosphere, GasMinerComponent miner, [NotNullWhen(true)] out TileAtmosphere? tile)
|
||||
private bool CheckMinerOperation(AtmosphereSystem atmosphereSystem, GasMinerComponent miner, [NotNullWhen(true)] out GasMixture? environment)
|
||||
{
|
||||
tile = atmosphere.GetTile(miner.Owner.Transform.Coordinates)!;
|
||||
environment = atmosphereSystem.GetTileMixture(miner.Owner.Transform.Coordinates, true);
|
||||
|
||||
// Space.
|
||||
if (atmosphere.IsSpace(tile.GridIndices))
|
||||
if (atmosphereSystem.IsTileSpace(miner.Owner.Transform.Coordinates))
|
||||
{
|
||||
miner.Broken = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Airblocked location.
|
||||
if (tile.Air == null)
|
||||
// Air-blocked location.
|
||||
if (environment == null)
|
||||
{
|
||||
miner.Broken = true;
|
||||
return false;
|
||||
@@ -51,14 +54,14 @@ namespace Content.Server.Atmos.Piping.Other.EntitySystems
|
||||
|
||||
// External pressure above threshold.
|
||||
if (!float.IsInfinity(miner.MaxExternalPressure) &&
|
||||
tile.Air.Pressure > miner.MaxExternalPressure - miner.SpawnAmount * miner.SpawnTemperature * Atmospherics.R / tile.Air.Volume)
|
||||
environment.Pressure > miner.MaxExternalPressure - miner.SpawnAmount * miner.SpawnTemperature * Atmospherics.R / environment.Volume)
|
||||
{
|
||||
miner.Broken = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// External gas amount above threshold.
|
||||
if (!float.IsInfinity(miner.MaxExternalAmount) && tile.Air.TotalMoles > miner.MaxExternalAmount)
|
||||
if (!float.IsInfinity(miner.MaxExternalAmount) && environment.TotalMoles > miner.MaxExternalAmount)
|
||||
{
|
||||
miner.Broken = true;
|
||||
return false;
|
||||
|
||||
@@ -165,9 +165,8 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
}
|
||||
else
|
||||
{
|
||||
var tileAtmosphere = canister.Owner.Transform.Coordinates.GetTileAtmosphere();
|
||||
atmosphereSystem.ReleaseGasTo(canister.Air, tileAtmosphere?.Air, canister.ReleasePressure);
|
||||
tileAtmosphere?.Invalidate();
|
||||
var environment = atmosphereSystem.GetTileMixture(canister.Owner.Transform.Coordinates, true);
|
||||
atmosphereSystem.ReleaseGasTo(canister.Air, environment, canister.ReleasePressure);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.Atmos.Piping.Unary.Components;
|
||||
using Content.Server.NodeContainer;
|
||||
@@ -31,9 +32,10 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
if (!nodeContainer.TryGetNode(injector.InletName, out PipeNode? inlet))
|
||||
return;
|
||||
|
||||
var environment = args.Atmosphere.GetTile(injector.Owner.Transform.Coordinates)!;
|
||||
var atmosphereSystem = Get<AtmosphereSystem>();
|
||||
var environment = atmosphereSystem.GetTileMixture(injector.Owner.Transform.Coordinates, true);
|
||||
|
||||
if (environment.Air == null)
|
||||
if (environment == null)
|
||||
return;
|
||||
|
||||
if (inlet.Air.Temperature > 0)
|
||||
@@ -42,8 +44,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
|
||||
var removed = inlet.Air.Remove(transferMoles);
|
||||
|
||||
environment.AssumeAir(removed);
|
||||
environment.Invalidate();
|
||||
atmosphereSystem.Merge(environment, removed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.Atmos.Piping.Unary.Components;
|
||||
using Content.Server.NodeContainer;
|
||||
@@ -21,9 +22,10 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
|
||||
private void OnPassiveVentUpdated(EntityUid uid, GasPassiveVentComponent vent, AtmosDeviceUpdateEvent args)
|
||||
{
|
||||
var environment = args.Atmosphere.GetTile(vent.Owner.Transform.Coordinates)!;
|
||||
var atmosphereSystem = Get<AtmosphereSystem>();
|
||||
var environment = atmosphereSystem.GetTileMixture(vent.Owner.Transform.Coordinates, true);
|
||||
|
||||
if (environment.Air == null)
|
||||
if (environment == null)
|
||||
return;
|
||||
|
||||
if (!ComponentManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer))
|
||||
@@ -32,27 +34,26 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
if (!nodeContainer.TryGetNode(vent.InletName, out PipeNode? inlet))
|
||||
return;
|
||||
|
||||
var environmentPressure = environment.Air.Pressure;
|
||||
var environmentPressure = environment.Pressure;
|
||||
var pressureDelta = MathF.Abs(environmentPressure - inlet.Air.Pressure);
|
||||
|
||||
if ((environment.Air.Temperature > 0 || inlet.Air.Temperature > 0) && pressureDelta > 0.5f)
|
||||
if ((environment.Temperature > 0 || inlet.Air.Temperature > 0) && pressureDelta > 0.5f)
|
||||
{
|
||||
if (environmentPressure < inlet.Air.Pressure)
|
||||
{
|
||||
var airTemperature = environment.Temperature > 0 ? environment.Temperature : inlet.Air.Temperature;
|
||||
var transferMoles = pressureDelta * environment.Air.Volume / (airTemperature * Atmospherics.R);
|
||||
var transferMoles = pressureDelta * environment.Volume / (airTemperature * Atmospherics.R);
|
||||
var removed = inlet.Air.Remove(transferMoles);
|
||||
environment.AssumeAir(removed);
|
||||
atmosphereSystem.Merge(environment, removed);
|
||||
}
|
||||
else
|
||||
{
|
||||
var airTemperature = inlet.Air.Temperature > 0 ? inlet.Air.Temperature : environment.Temperature;
|
||||
var outputVolume = inlet.Air.Volume;
|
||||
var transferMoles = (pressureDelta * outputVolume) / (airTemperature * Atmospherics.R);
|
||||
transferMoles = MathF.Min(transferMoles, environment.Air.TotalMoles * inlet.Air.Volume / environment.Air.Volume);
|
||||
var removed = environment.Air.Remove(transferMoles);
|
||||
transferMoles = MathF.Min(transferMoles, environment.TotalMoles * inlet.Air.Volume / environment.Volume);
|
||||
var removed = environment.Remove(transferMoles);
|
||||
inlet.AssumeAir(removed);
|
||||
environment.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.Atmos.Piping.Unary.Components;
|
||||
using Content.Server.NodeContainer;
|
||||
@@ -43,10 +44,11 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
if (!nodeContainer.TryGetNode(vent.InletName, out PipeNode? pipe))
|
||||
return;
|
||||
|
||||
var environment = args.Atmosphere.GetTile(vent.Owner.Transform.Coordinates)!;
|
||||
var atmosphereSystem = Get<AtmosphereSystem>();
|
||||
var environment = atmosphereSystem.GetTileMixture(vent.Owner.Transform.Coordinates, true);
|
||||
|
||||
// We're in an air-blocked tile... Do nothing.
|
||||
if (environment.Air == null)
|
||||
if (environment == null)
|
||||
return;
|
||||
|
||||
if (vent.PumpDirection == VentPumpDirection.Releasing)
|
||||
@@ -55,37 +57,36 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
var pressureDelta = 10000f;
|
||||
|
||||
if ((vent.PressureChecks & VentPressureBound.ExternalBound) != 0)
|
||||
pressureDelta = MathF.Min(pressureDelta, vent.ExternalPressureBound - environment.Air.Pressure);
|
||||
pressureDelta = MathF.Min(pressureDelta, vent.ExternalPressureBound - environment.Pressure);
|
||||
|
||||
if ((vent.PressureChecks & VentPressureBound.InternalBound) != 0)
|
||||
pressureDelta = MathF.Min(pressureDelta, pipe.Air.Pressure - vent.InternalPressureBound);
|
||||
|
||||
if (pressureDelta > 0 && pipe.Air.Temperature > 0)
|
||||
{
|
||||
var transferMoles = pressureDelta * environment.Air.Volume / (pipe.Air.Temperature * Atmospherics.R);
|
||||
var transferMoles = pressureDelta * environment.Volume / (pipe.Air.Temperature * Atmospherics.R);
|
||||
|
||||
environment.AssumeAir(pipe.Air.Remove(transferMoles));
|
||||
atmosphereSystem.Merge(environment, pipe.Air.Remove(transferMoles));
|
||||
}
|
||||
}
|
||||
else if (vent.PumpDirection == VentPumpDirection.Siphoning && environment.Air.Pressure > 0)
|
||||
else if (vent.PumpDirection == VentPumpDirection.Siphoning && environment.Pressure > 0)
|
||||
{
|
||||
appearance?.SetData(VentPumpVisuals.State, VentPumpState.In);
|
||||
var ourMultiplier = pipe.Air.Volume / (environment.Air.Temperature * Atmospherics.R);
|
||||
var ourMultiplier = pipe.Air.Volume / (environment.Temperature * Atmospherics.R);
|
||||
var molesDelta = 10000f * ourMultiplier;
|
||||
|
||||
if ((vent.PressureChecks & VentPressureBound.ExternalBound) != 0)
|
||||
molesDelta = MathF.Min(molesDelta,
|
||||
(environment.Air.Pressure - vent.ExternalPressureBound) * environment.Air.Volume /
|
||||
(environment.Air.Temperature * Atmospherics.R));
|
||||
(environment.Pressure - vent.ExternalPressureBound) * environment.Volume /
|
||||
(environment.Temperature * Atmospherics.R));
|
||||
|
||||
if ((vent.PressureChecks & VentPressureBound.InternalBound) != 0)
|
||||
molesDelta = MathF.Min(molesDelta, (vent.InternalPressureBound - pipe.Air.Pressure) * ourMultiplier);
|
||||
|
||||
if (molesDelta > 0)
|
||||
{
|
||||
var removed = environment.Air.Remove(molesDelta);
|
||||
var removed = environment.Remove(molesDelta);
|
||||
pipe.AssumeAir(removed);
|
||||
environment.Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,17 +45,17 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
if (!nodeContainer.TryGetNode(scrubber.OutletName, out PipeNode? outlet))
|
||||
return;
|
||||
|
||||
var environment = args.Atmosphere.GetTile(scrubber.Owner.Transform.Coordinates)!;
|
||||
var atmosphereSystem = Get<AtmosphereSystem>();
|
||||
var environment = atmosphereSystem.GetTileMixture(scrubber.Owner.Transform.Coordinates, true);
|
||||
|
||||
Scrub(scrubber, appearance, environment, outlet);
|
||||
Scrub(atmosphereSystem, scrubber, appearance, environment, outlet);
|
||||
|
||||
if (!scrubber.WideNet) return;
|
||||
|
||||
// Scrub adjacent tiles too.
|
||||
foreach (var adjacent in environment.AdjacentTiles)
|
||||
foreach (var adjacent in atmosphereSystem.GetAdjacentTileMixtures(scrubber.Owner.Transform.Coordinates, false, true))
|
||||
{
|
||||
// Pass null appearance, we don't need to set it there.
|
||||
Scrub(scrubber, null, adjacent, outlet);
|
||||
Scrub(atmosphereSystem, scrubber, null, adjacent, outlet);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,10 +67,10 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
}
|
||||
}
|
||||
|
||||
private void Scrub(GasVentScrubberComponent scrubber, AppearanceComponent? appearance, TileAtmosphere? tile, PipeNode outlet)
|
||||
private void Scrub(AtmosphereSystem atmosphereSystem, GasVentScrubberComponent scrubber, AppearanceComponent? appearance, GasMixture? tile, PipeNode outlet)
|
||||
{
|
||||
// Cannot scrub if tile is null or air-blocked.
|
||||
if (tile?.Air == null)
|
||||
if (tile == null)
|
||||
return;
|
||||
|
||||
// Cannot scrub if pressure too high.
|
||||
@@ -80,30 +80,28 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
if (scrubber.PumpDirection == ScrubberPumpDirection.Scrubbing)
|
||||
{
|
||||
appearance?.SetData(ScrubberVisuals.State, scrubber.WideNet ? ScrubberState.WideScrub : ScrubberState.Scrub);
|
||||
var transferMoles = MathF.Min(1f, (scrubber.VolumeRate / tile.Air.Volume) * tile.Air.TotalMoles);
|
||||
var transferMoles = MathF.Min(1f, (scrubber.VolumeRate / tile.Volume) * tile.TotalMoles);
|
||||
|
||||
// Take a gas sample.
|
||||
var removed = tile.Air.Remove(transferMoles);
|
||||
var removed = tile.Remove(transferMoles);
|
||||
|
||||
// Nothing left to remove from the tile.
|
||||
if (MathHelper.CloseTo(removed.TotalMoles, 0f))
|
||||
return;
|
||||
|
||||
// TODO: Entity system dependency
|
||||
Get<AtmosphereSystem>().ScrubInto(removed, outlet.Air, scrubber.FilterGases);
|
||||
atmosphereSystem.ScrubInto(removed, outlet.Air, scrubber.FilterGases);
|
||||
|
||||
// Remix the gases.
|
||||
tile.AssumeAir(removed);
|
||||
atmosphereSystem.Merge(tile, removed);
|
||||
}
|
||||
else if (scrubber.PumpDirection == ScrubberPumpDirection.Siphoning)
|
||||
{
|
||||
appearance?.SetData(ScrubberVisuals.State, ScrubberState.Siphon);
|
||||
var transferMoles = tile.Air.TotalMoles * (scrubber.VolumeRate / tile.Air.Volume);
|
||||
var transferMoles = tile.TotalMoles * (scrubber.VolumeRate / tile.Volume);
|
||||
|
||||
var removed = tile.Air.Remove(transferMoles);
|
||||
var removed = tile.Remove(transferMoles);
|
||||
|
||||
outlet.AssumeAir(removed);
|
||||
tile.Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace Content.Server.Body.Behavior
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Owner.Transform.Coordinates.TryGetTileAir(out var tileAir))
|
||||
if (EntitySystem.Get<AtmosphereSystem>().GetTileMixture(Owner.Transform.Coordinates, true) is not {} tileAir)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ namespace Content.Server.Body.Behavior
|
||||
|
||||
public void Exhale(float frameTime)
|
||||
{
|
||||
if (!Owner.Transform.Coordinates.TryGetTileAir(out var tileAir))
|
||||
if (EntitySystem.Get<AtmosphereSystem>().GetTileMixture(Owner.Transform.Coordinates, true) is not {} tileAir)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Server.Fluids.Components;
|
||||
using Content.Server.Hands.Components;
|
||||
@@ -247,8 +248,7 @@ namespace Content.Server.Botany.Components
|
||||
_updateSpriteAfterUpdate = true;
|
||||
}
|
||||
|
||||
var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere();
|
||||
var environment = tileAtmos?.Air ?? GasMixture.SpaceGas;
|
||||
var environment = EntitySystem.Get<AtmosphereSystem>().GetTileMixture(Owner.Transform.Coordinates, true)?? GasMixture.SpaceGas;
|
||||
|
||||
if (Seed.ConsumeGasses.Count > 0)
|
||||
{
|
||||
|
||||
@@ -21,16 +21,23 @@ namespace Content.Server.Chemistry.TileReactions
|
||||
|
||||
public ReagentUnit TileReact(TileRef tile, ReagentPrototype reagent, ReagentUnit reactVolume)
|
||||
{
|
||||
if (reactVolume <= ReagentUnit.Zero || tile.Tile.IsEmpty) return ReagentUnit.Zero;
|
||||
var tileAtmos = tile.GridPosition().GetTileAtmosphere();
|
||||
if (tileAtmos == null || !tileAtmos.Hotspot.Valid || tileAtmos.Air == null) return ReagentUnit.Zero;
|
||||
tileAtmos.Air.Temperature =
|
||||
MathF.Max(MathF.Min(tileAtmos.Air.Temperature - (_coolingTemperature * 1000f),
|
||||
tileAtmos.Air.Temperature / _coolingTemperature),
|
||||
Atmospherics.TCMB);
|
||||
EntitySystem.Get<AtmosphereSystem>().React(tileAtmos.Air, tileAtmos);
|
||||
tileAtmos.Hotspot = new Hotspot();
|
||||
tileAtmos.UpdateVisuals();
|
||||
if (reactVolume <= ReagentUnit.Zero || tile.Tile.IsEmpty)
|
||||
return ReagentUnit.Zero;
|
||||
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
var environment = atmosphereSystem.GetTileMixture(tile.GridIndex, tile.GridIndices, true);
|
||||
|
||||
if (environment == null || !atmosphereSystem.IsHotspotActive(tile.GridIndex, tile.GridIndices))
|
||||
return ReagentUnit.Zero;
|
||||
|
||||
environment.Temperature =
|
||||
MathF.Max(MathF.Min(environment.Temperature - (_coolingTemperature * 1000f),
|
||||
environment.Temperature / _coolingTemperature), Atmospherics.TCMB);
|
||||
|
||||
atmosphereSystem.React(tile.GridIndex, tile.GridIndices);
|
||||
atmosphereSystem.HotspotExtinguish(tile.GridIndex, tile.GridIndices);
|
||||
|
||||
return ReagentUnit.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,18 @@ namespace Content.Server.Chemistry.TileReactions
|
||||
|
||||
public ReagentUnit TileReact(TileRef tile, ReagentPrototype reagent, ReagentUnit reactVolume)
|
||||
{
|
||||
if (reactVolume <= ReagentUnit.Zero || tile.Tile.IsEmpty) return ReagentUnit.Zero;
|
||||
var tileAtmos = tile.GridPosition().GetTileAtmosphere();
|
||||
if (tileAtmos?.Air == null || !tileAtmos.Hotspot.Valid) return ReagentUnit.Zero;
|
||||
tileAtmos.Air.Temperature *= MathF.Max(_temperatureMultiplier * reactVolume.Float(), 1f);
|
||||
EntitySystem.Get<AtmosphereSystem>().React(tileAtmos.Air, tileAtmos);
|
||||
if (reactVolume <= ReagentUnit.Zero || tile.Tile.IsEmpty)
|
||||
return ReagentUnit.Zero;
|
||||
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
var environment = atmosphereSystem.GetTileMixture(tile.GridIndex, tile.GridIndices, true);
|
||||
if (environment == null || !atmosphereSystem.IsHotspotActive(tile.GridIndex, tile.GridIndices))
|
||||
return ReagentUnit.Zero;
|
||||
|
||||
environment.Temperature *= MathF.Max(_temperatureMultiplier * reactVolume.Float(), 1f);
|
||||
atmosphereSystem.React(tile.GridIndex, tile.GridIndices);
|
||||
|
||||
return reactVolume;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.Console;
|
||||
@@ -28,46 +29,17 @@ namespace Content.Server.Commands.Atmos
|
||||
|
||||
var gridId = new GridId(id);
|
||||
|
||||
var mapMan = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
|
||||
{
|
||||
shell.WriteLine("Invalid grid ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid))
|
||||
{
|
||||
shell.WriteLine("Failed to get grid entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!grid.HasComponent<GridAtmosphereComponent>())
|
||||
{
|
||||
shell.WriteLine("Grid doesn't have an atmosphere.");
|
||||
return;
|
||||
}
|
||||
|
||||
var gam = grid.GetComponent<GridAtmosphereComponent>();
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
var indices = new Vector2i(x, y);
|
||||
var tile = gam.GetTile(indices);
|
||||
var tile = atmosphereSystem.GetTileMixture(gridId, indices, true);
|
||||
|
||||
if (tile == null)
|
||||
{
|
||||
shell.WriteLine("Invalid coordinates.");
|
||||
shell.WriteLine("Invalid coordinates or tile.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (tile.Air == null)
|
||||
{
|
||||
shell.WriteLine("Can't add gas to that tile.");
|
||||
return;
|
||||
}
|
||||
|
||||
tile.Air.AdjustMoles(gasId, moles);
|
||||
tile.Invalidate();
|
||||
tile.AdjustMoles(gasId, moles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Server.Player;
|
||||
@@ -127,55 +128,39 @@ namespace Content.Server.Commands.Atmos
|
||||
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (!mapManager.TryGetGrid(gridId, out var grid))
|
||||
if (!mapManager.TryGetGrid(gridId, out _))
|
||||
{
|
||||
shell.WriteLine($"No grid exists with id {gridId}");
|
||||
return;
|
||||
}
|
||||
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity))
|
||||
{
|
||||
shell.WriteLine($"Grid {gridId} has no entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gridEntity.TryGetComponent(out GridAtmosphereComponent? atmosphere))
|
||||
{
|
||||
shell.WriteLine($"Grid {gridId} has no {nameof(GridAtmosphereComponent)}");
|
||||
return;
|
||||
}
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
var tiles = 0;
|
||||
var moles = 0f;
|
||||
|
||||
if (gas == null)
|
||||
{
|
||||
foreach (var tile in atmosphere)
|
||||
foreach (var tile in atmosphereSystem.GetAllTileMixtures(gridId, true))
|
||||
{
|
||||
if (tile.Air == null || tile.Air.Immutable) continue;
|
||||
if (tile.Immutable) continue;
|
||||
|
||||
tiles++;
|
||||
moles += tile.Air.TotalMoles;
|
||||
moles += tile.TotalMoles;
|
||||
|
||||
tile.Air.Clear();
|
||||
|
||||
tile.Invalidate();
|
||||
tile.Clear();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var tile in atmosphere)
|
||||
foreach (var tile in atmosphereSystem.GetAllTileMixtures(gridId, true))
|
||||
{
|
||||
if (tile.Air == null || tile.Air.Immutable) continue;
|
||||
if (tile.Immutable) continue;
|
||||
|
||||
tiles++;
|
||||
moles += tile.Air.TotalMoles;
|
||||
moles += tile.TotalMoles;
|
||||
|
||||
tile.Air.SetMoles(gas.Value, 0);
|
||||
|
||||
tile.Invalidate();
|
||||
tile.SetMoles(gas.Value, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.Console;
|
||||
@@ -27,32 +28,17 @@ namespace Content.Server.Commands.Atmos
|
||||
|
||||
var mapMan = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
|
||||
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out _))
|
||||
{
|
||||
shell.WriteLine("Invalid grid ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid))
|
||||
foreach (var tile in atmosphereSystem.GetAllTileMixtures(gridId, true))
|
||||
{
|
||||
shell.WriteLine("Failed to get grid entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!grid.HasComponent<IGridAtmosphereComponent>())
|
||||
{
|
||||
shell.WriteLine("Grid doesn't have an atmosphere.");
|
||||
return;
|
||||
}
|
||||
|
||||
var gam = grid.GetComponent<IGridAtmosphereComponent>();
|
||||
|
||||
foreach (var tile in gam)
|
||||
{
|
||||
tile.Air?.AdjustMoles(gasId, moles);
|
||||
tile.Invalidate();
|
||||
tile.AdjustMoles(gasId, moles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.Console;
|
||||
@@ -25,7 +26,7 @@ namespace Content.Server.Commands.Atmos
|
||||
}
|
||||
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
var mixture = new GasMixture(Atmospherics.CellVolume) { Temperature = Atmospherics.T20C };
|
||||
mixture.AdjustMoles(Gas.Oxygen, Atmospherics.OxygenMolesStandard);
|
||||
@@ -40,32 +41,19 @@ namespace Content.Server.Commands.Atmos
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!mapManager.TryGetGrid(new GridId(i), out var grid))
|
||||
var gridId = new GridId(i);
|
||||
|
||||
if (!mapManager.TryGetGrid(gridId, out _))
|
||||
{
|
||||
shell.WriteError($"Grid \"{i}\" doesn't exist.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!entityManager.TryGetEntity(grid.GridEntityId, out var entity))
|
||||
foreach (var tile in atmosphereSystem.GetAllTileMixtures(gridId, true))
|
||||
{
|
||||
shell.WriteError($"Grid entity for grid \"{i}\" doesn't exist.");
|
||||
continue;
|
||||
}
|
||||
|
||||
var gridAtmosphere = new GridAtmosphereComponent() {Owner = entity};
|
||||
|
||||
// Inject dependencies manually or a NRE will eat your face.
|
||||
IoCManager.InjectDependencies(gridAtmosphere);
|
||||
|
||||
entityManager.ComponentManager.AddComponent(entity, gridAtmosphere, true);
|
||||
|
||||
gridAtmosphere.RepopulateTiles();
|
||||
|
||||
foreach (var tile in gridAtmosphere)
|
||||
{
|
||||
tile.Air = (GasMixture) mixture.Clone();
|
||||
tile.Air.Volume = gridAtmosphere.GetVolumeForCells(1);
|
||||
tile.Invalidate();
|
||||
tile.Clear();
|
||||
atmosphereSystem.Merge(tile, mixture);
|
||||
tile.Temperature = mixture.Temperature;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -27,50 +28,20 @@ namespace Content.Server.Commands.Atmos
|
||||
|
||||
var gridId = new GridId(id);
|
||||
|
||||
var mapMan = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
|
||||
{
|
||||
shell.WriteLine("Invalid grid ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid))
|
||||
{
|
||||
shell.WriteLine("Failed to get grid entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!grid.HasComponent<GridAtmosphereComponent>())
|
||||
{
|
||||
shell.WriteLine("Grid doesn't have an atmosphere.");
|
||||
return;
|
||||
}
|
||||
|
||||
var gam = grid.GetComponent<GridAtmosphereComponent>();
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
var indices = new Vector2i(x, y);
|
||||
var tile = gam.GetTile(indices);
|
||||
var tile = atmosphereSystem.GetTileMixture(gridId, indices, true);
|
||||
|
||||
if (tile == null)
|
||||
{
|
||||
shell.WriteLine("Invalid coordinates.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (tile.Air == null)
|
||||
{
|
||||
shell.WriteLine("Can't remove gas from that tile.");
|
||||
shell.WriteLine("Invalid coordinates or tile.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ratio)
|
||||
tile.Air.RemoveRatio(amount);
|
||||
tile.RemoveRatio(amount);
|
||||
else
|
||||
tile.Air.Remove(amount);
|
||||
|
||||
tile.Invalidate();
|
||||
tile.Remove(amount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.Console;
|
||||
@@ -38,32 +39,13 @@ namespace Content.Server.Commands.Atmos
|
||||
return;
|
||||
}
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid))
|
||||
{
|
||||
shell.WriteLine("Failed to get grid entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!grid.HasComponent<GridAtmosphereComponent>())
|
||||
{
|
||||
shell.WriteLine("Grid doesn't have an atmosphere.");
|
||||
return;
|
||||
}
|
||||
|
||||
var gam = grid.GetComponent<GridAtmosphereComponent>();
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
var tiles = 0;
|
||||
foreach (var tile in gam)
|
||||
foreach (var tile in atmosphereSystem.GetAllTileMixtures(gridId, true))
|
||||
{
|
||||
if (tile.Air == null)
|
||||
continue;
|
||||
|
||||
tiles++;
|
||||
|
||||
tile.Air.Temperature = temperature;
|
||||
tile.Invalidate();
|
||||
tile.Temperature = temperature;
|
||||
}
|
||||
|
||||
shell.WriteLine($"Changed the temperature of {tiles} tiles.");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.Console;
|
||||
@@ -27,52 +28,23 @@ namespace Content.Server.Commands.Atmos
|
||||
|
||||
var gridId = new GridId(id);
|
||||
|
||||
var mapMan = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (temperature < Atmospherics.TCMB)
|
||||
{
|
||||
shell.WriteLine("Invalid temperature.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
|
||||
{
|
||||
shell.WriteLine("Invalid grid ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid))
|
||||
{
|
||||
shell.WriteLine("Failed to get grid entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!grid.HasComponent<GridAtmosphereComponent>())
|
||||
{
|
||||
shell.WriteLine("Grid doesn't have an atmosphere.");
|
||||
return;
|
||||
}
|
||||
|
||||
var gam = grid.GetComponent<GridAtmosphereComponent>();
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
var indices = new Vector2i(x, y);
|
||||
var tile = gam.GetTile(indices);
|
||||
var tile = atmosphereSystem.GetTileMixture(gridId, indices, true);
|
||||
|
||||
if (tile == null)
|
||||
{
|
||||
shell.WriteLine("Invalid coordinates.");
|
||||
shell.WriteLine("Invalid coordinates or tile.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (tile.Air == null)
|
||||
{
|
||||
shell.WriteLine("Can't change that tile's temperature.");
|
||||
return;
|
||||
}
|
||||
|
||||
tile.Air.Temperature = temperature;
|
||||
tile.Invalidate();
|
||||
tile.Temperature = temperature;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Disposal.Tube.Components;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Server.Items;
|
||||
@@ -135,10 +136,11 @@ namespace Content.Server.Disposal.Unit.Components
|
||||
}
|
||||
}
|
||||
|
||||
if (Owner.Transform.Coordinates.TryGetTileAtmosphere(out var tileAtmos) &&
|
||||
tileAtmos.Air != null)
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
if (atmosphereSystem.GetTileMixture(Owner.Transform.Coordinates, true) is {} environment)
|
||||
{
|
||||
tileAtmos.AssumeAir(Air);
|
||||
atmosphereSystem.Merge(environment, Air);
|
||||
Air.Clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -274,19 +274,13 @@ namespace Content.Server.Disposal.Unit.Components
|
||||
|
||||
var entryComponent = Owner.EntityManager.ComponentManager.GetComponent<DisposalEntryComponent>(entry);
|
||||
|
||||
if (Owner.Transform.Coordinates.TryGetTileAtmosphere(out var tileAtmos) &&
|
||||
tileAtmos.Air != null &&
|
||||
tileAtmos.Air.Temperature > 0)
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
if (atmosphereSystem.GetTileMixture(Owner.Transform.Coordinates, true) is {Temperature: > 0} environment)
|
||||
{
|
||||
var tileAir = tileAtmos.Air;
|
||||
var transferMoles = 0.1f * (0.05f * Atmospherics.OneAtmosphere * 1.01f - Air.Pressure) * Air.Volume / (tileAir.Temperature * Atmospherics.R);
|
||||
var transferMoles = 0.1f * (0.05f * Atmospherics.OneAtmosphere * 1.01f - Air.Pressure) * Air.Volume / (environment.Temperature * Atmospherics.R);
|
||||
|
||||
Air = tileAir.Remove(transferMoles);
|
||||
|
||||
var atmosSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
atmosSystem
|
||||
.GetGridAtmosphere(Owner.Transform.Coordinates)?
|
||||
.Invalidate(tileAtmos.GridIndices);
|
||||
Air = environment.Remove(transferMoles);
|
||||
}
|
||||
|
||||
entryComponent.TryInsert(this);
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.GameTicking.Rules;
|
||||
using Content.Server.Hands.Components;
|
||||
@@ -162,10 +163,12 @@ namespace Content.Server.GameTicking.Presets
|
||||
_robustRandom.Shuffle(ents);
|
||||
var foundATarget = false;
|
||||
bestTarget = EntityCoordinates.Invalid;
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
foreach (var entity in ents)
|
||||
{
|
||||
if (!entity.Transform.Coordinates.IsTileAirProbablySafe())
|
||||
if (!atmosphereSystem.IsTileMixtureProbablySafe(entity.Transform.Coordinates))
|
||||
continue;
|
||||
|
||||
var distanceFromNearest = float.PositiveInfinity;
|
||||
foreach (var existing in existingPlayerPoints)
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.Alert;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Body.Behavior;
|
||||
using Content.Server.Body.Circulatory;
|
||||
using Content.Server.Temperature.Components;
|
||||
@@ -282,7 +283,7 @@ namespace Content.Server.Metabolism
|
||||
}
|
||||
|
||||
// creadth: sweating does not help in airless environment
|
||||
if (Owner.Transform.Coordinates.TryGetTileAir(out _, Owner.EntityManager))
|
||||
if (EntitySystem.Get<AtmosphereSystem>().GetTileMixture(Owner.Transform.Coordinates) is not {})
|
||||
{
|
||||
temperatureComponent.RemoveHeat(Math.Min(targetHeat, SweatHeatRegulation));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.Audio;
|
||||
@@ -113,19 +114,20 @@ namespace Content.Server.StationEvents.Events
|
||||
if (_timeUntilLeak > 0f) return;
|
||||
_timeUntilLeak += LeakCooldown;
|
||||
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
if (!_foundTile ||
|
||||
_targetGrid == null ||
|
||||
_targetGrid.Deleted ||
|
||||
!_targetGrid.TryGetComponent(out GridAtmosphereComponent? gridAtmos))
|
||||
!atmosphereSystem.IsSimulatedGrid(_targetGrid.Transform.GridID))
|
||||
{
|
||||
Running = false;
|
||||
return;
|
||||
}
|
||||
|
||||
var atmos = gridAtmos.GetTile(_targetTile);
|
||||
var environment = atmosphereSystem.GetTileMixture(_targetGrid.Transform.GridID, _targetTile, true);
|
||||
|
||||
atmos?.Air?.AdjustMoles(_leakGas, LeakCooldown * _molesPerSecond);
|
||||
atmos?.Invalidate();
|
||||
environment?.AdjustMoles(_leakGas, LeakCooldown * _molesPerSecond);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
@@ -144,21 +146,21 @@ namespace Content.Server.StationEvents.Events
|
||||
|
||||
private void Spark()
|
||||
{
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
var robustRandom = IoCManager.Resolve<IRobustRandom>();
|
||||
if (robustRandom.NextFloat() <= SparkChance)
|
||||
{
|
||||
if (!_foundTile ||
|
||||
_targetGrid == null ||
|
||||
_targetGrid.Deleted ||
|
||||
!_targetGrid.TryGetComponent(out GridAtmosphereComponent? gridAtmos))
|
||||
!atmosphereSystem.IsSimulatedGrid(_targetGrid.Transform.GridID))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var atmos = gridAtmos.GetTile(_targetTile);
|
||||
// Don't want it to be so obnoxious as to instantly murder anyone in the area but enough that
|
||||
// it COULD start potentially start a bigger fire.
|
||||
atmos?.HotspotExpose(700f, 50f, true);
|
||||
atmosphereSystem.HotspotExpose(_targetGrid.Transform.GridID, _targetTile, 700f, 50f, true);
|
||||
SoundSystem.Play(Filter.Pvs(_targetCoords), "/Audio/Effects/sparks4.ogg", _targetCoords);
|
||||
}
|
||||
}
|
||||
@@ -171,7 +173,7 @@ namespace Content.Server.StationEvents.Events
|
||||
if (!IoCManager.Resolve<IMapManager>().TryGetGrid(defaultGridId, out var grid) ||
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetEntity(grid.GridEntityId, out _targetGrid)) return false;
|
||||
|
||||
_targetGrid.EnsureComponent(out GridAtmosphereComponent gridAtmos);
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
robustRandom ??= IoCManager.Resolve<IRobustRandom>();
|
||||
var found = false;
|
||||
var gridBounds = grid.WorldBounds;
|
||||
@@ -183,7 +185,7 @@ namespace Content.Server.StationEvents.Events
|
||||
var randomY = robustRandom.Next((int) gridBounds.Bottom, (int) gridBounds.Top);
|
||||
|
||||
tile = new Vector2i(randomX - (int) gridPos.X, randomY - (int) gridPos.Y);
|
||||
if (gridAtmos.IsSpace(tile) || gridAtmos.IsAirBlocked(tile)) continue;
|
||||
if (atmosphereSystem.IsTileSpace(defaultGridId, tile) || atmosphereSystem.IsTileAirBlocked(defaultGridId, tile)) continue;
|
||||
found = true;
|
||||
_targetCoords = grid.GridTileToLocal(tile);
|
||||
break;
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Act;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Server.Explosion;
|
||||
@@ -212,8 +213,7 @@ namespace Content.Server.Tools.Components
|
||||
PlaySoundCollection("WelderOn", -5);
|
||||
_welderSystem.Subscribe(this);
|
||||
|
||||
Owner.Transform.Coordinates
|
||||
.GetTileAtmosphere()?.HotspotExpose(700f, 50f, true);
|
||||
EntitySystem.Get<AtmosphereSystem>().HotspotExpose(Owner.Transform.Coordinates, 700, 50, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -256,8 +256,7 @@ namespace Content.Server.Tools.Components
|
||||
|
||||
_solutionComponent?.TryRemoveReagent("WeldingFuel", ReagentUnit.New(FuelLossRate * frameTime));
|
||||
|
||||
Owner.Transform.Coordinates
|
||||
.GetTileAtmosphere()?.HotspotExpose(700f, 50f, true);
|
||||
EntitySystem.Get<AtmosphereSystem>().HotspotExpose(Owner.Transform.Coordinates, 700, 50, true);
|
||||
|
||||
if (Fuel == 0)
|
||||
ToggleWelderStatus();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.CombatMode;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Interaction.Components;
|
||||
@@ -182,9 +183,9 @@ namespace Content.Server.Weapon.Ranged
|
||||
return;
|
||||
}
|
||||
|
||||
if (_canHotspot && user.Transform.Coordinates.TryGetTileAtmosphere(out var tile))
|
||||
if (_canHotspot)
|
||||
{
|
||||
tile.HotspotExpose(700, 50);
|
||||
EntitySystem.Get<AtmosphereSystem>().HotspotExpose(user.Transform.Coordinates, 700, 50);
|
||||
}
|
||||
FireHandler?.Invoke(user, targetPos);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user