Adds a new AtmosphereSystem.GetTileMixture() override (#21804)

This commit is contained in:
Leon Friedrich
2023-11-28 18:03:44 -05:00
committed by GitHub
parent c60205fa28
commit 918d8c2b34
14 changed files with 25 additions and 33 deletions

View File

@@ -65,7 +65,7 @@ public sealed class GasProducerAnomalySystem : EntitySystem
if (tilerefs.Length == 0) if (tilerefs.Length == 0)
return; return;
var mixture = _atmosphere.GetTileMixture(xform.GridUid, xform.MapUid, _xform.GetGridOrMapTilePosition(uid, xform), true); var mixture = _atmosphere.GetTileMixture((uid, xform), grid, true);
if (mixture != null) if (mixture != null)
{ {
mixture.AdjustMoles(gas, mols); mixture.AdjustMoles(gas, mols);

View File

@@ -22,7 +22,7 @@ public sealed class TempAffectingAnomalySystem : EntitySystem
{ {
var grid = xform.GridUid; var grid = xform.GridUid;
var map = xform.MapUid; var map = xform.MapUid;
var indices = _xform.GetGridOrMapTilePosition(ent, xform); var indices = _xform.GetGridTilePositionOrDefault((ent, xform));
var mixture = _atmosphere.GetTileMixture(grid, map, indices, true); var mixture = _atmosphere.GetTileMixture(grid, map, indices, true);
if (mixture is { }) if (mixture is { })

View File

@@ -127,9 +127,18 @@ public partial class AtmosphereSystem
return ev.Mixtures; return ev.Mixtures;
} }
public GasMixture? GetTileMixture(EntityUid? gridUid, EntityUid? mapUid, Vector2i tile, bool excite = false) public GasMixture? GetTileMixture (Entity<TransformComponent?> entity, MapGridComponent? grid = null, bool excite = false)
{ {
var ev = new GetTileMixtureMethodEvent(gridUid, mapUid, tile, excite); if (!Resolve(entity.Owner, ref entity.Comp))
return null;
var indices = _transformSystem.GetGridTilePositionOrDefault(entity);
return GetTileMixture(entity.Comp.GridUid, entity.Comp.MapUid, indices, excite);
}
public GasMixture? GetTileMixture(EntityUid? gridUid, EntityUid? mapUid, Vector2i gridTile, bool excite = false)
{
var ev = new GetTileMixtureMethodEvent(gridUid, mapUid, gridTile, excite);
// If we've been passed a grid, try to let it handle it. // If we've been passed a grid, try to let it handle it.
if(gridUid.HasValue) if(gridUid.HasValue)

View File

@@ -118,9 +118,7 @@ public sealed class RottingSystem : EntitySystem
return; return;
var molsToDump = perishable.MolsPerSecondPerUnitMass * physics.FixturesMass * (float) component.TotalRotTime.TotalSeconds; var molsToDump = perishable.MolsPerSecondPerUnitMass * physics.FixturesMass * (float) component.TotalRotTime.TotalSeconds;
var transform = Transform(uid); var tileMix = _atmosphere.GetTileMixture(uid, excite: true);
var indices = _transform.GetGridOrMapTilePosition(uid, transform);
var tileMix = _atmosphere.GetTileMixture(transform.GridUid, transform.MapUid, indices, true);
tileMix?.AdjustMoles(Gas.Miasma, molsToDump); tileMix?.AdjustMoles(Gas.Miasma, molsToDump);
} }
@@ -214,8 +212,7 @@ public sealed class RottingSystem : EntitySystem
// We need a way to get the mass of the mob alone without armor etc in the future // We need a way to get the mass of the mob alone without armor etc in the future
// or just remove the mass mechanics altogether because they aren't good. // or just remove the mass mechanics altogether because they aren't good.
var molRate = perishable.MolsPerSecondPerUnitMass * (float) rotting.RotUpdateRate.TotalSeconds; var molRate = perishable.MolsPerSecondPerUnitMass * (float) rotting.RotUpdateRate.TotalSeconds;
var indices = _transform.GetGridOrMapTilePosition(uid); var tileMix = _atmosphere.GetTileMixture(uid, excite: true);
var tileMix = _atmosphere.GetTileMixture(xform.GridUid, null, indices, true);
tileMix?.AdjustMoles(Gas.Miasma, molRate * physics.FixturesMass); tileMix?.AdjustMoles(Gas.Miasma, molRate * physics.FixturesMass);
} }
} }

View File

@@ -110,9 +110,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
// Some of the gas from the mixture leaks when overclocked. // Some of the gas from the mixture leaks when overclocked.
if (pump.Overclocked) if (pump.Overclocked)
{ {
var transform = Transform(uid); var tile = _atmosphereSystem.GetTileMixture(uid, excite: true);
var indices = _transformSystem.GetGridOrMapTilePosition(uid, transform);
var tile = _atmosphereSystem.GetTileMixture(transform.GridUid, null, indices, true);
if (tile != null) if (tile != null)
{ {

View File

@@ -67,8 +67,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
if (xform.GridUid == null) if (xform.GridUid == null)
return; return;
var position = _transformSystem.GetGridOrMapTilePosition(uid, xform); var position = _transformSystem.GetGridTilePositionOrDefault((uid,xform));
var environment = _atmosphereSystem.GetTileMixture(xform.GridUid, xform.MapUid, position, true); var environment = _atmosphereSystem.GetTileMixture(xform.GridUid, xform.MapUid, position, true);
Scrub(timeDelta, scrubber, environment, outlet); Scrub(timeDelta, scrubber, environment, outlet);

View File

@@ -79,8 +79,7 @@ namespace Content.Server.Atmos.Portable
if (xform.GridUid == null) if (xform.GridUid == null)
return; return;
var position = _transformSystem.GetGridOrMapTilePosition(uid, xform); var position = _transformSystem.GetGridTilePositionOrDefault((uid,xform));
var environment = _atmosphereSystem.GetTileMixture(xform.GridUid, xform.MapUid, position, true); var environment = _atmosphereSystem.GetTileMixture(xform.GridUid, xform.MapUid, position, true);
var running = Scrub(timeDelta, component, environment); var running = Scrub(timeDelta, component, environment);

View File

@@ -339,8 +339,7 @@ namespace Content.Server.Cloning
clonePod.CloningProgress = 0f; clonePod.CloningProgress = 0f;
UpdateStatus(uid, CloningPodStatus.Idle, clonePod); UpdateStatus(uid, CloningPodStatus.Idle, clonePod);
var transform = Transform(uid); var transform = Transform(uid);
var indices = _transformSystem.GetGridOrMapTilePosition(uid); var indices = _transformSystem.GetGridTilePositionOrDefault((uid, transform));
var tileMix = _atmosphereSystem.GetTileMixture(transform.GridUid, null, indices, true); var tileMix = _atmosphereSystem.GetTileMixture(transform.GridUid, null, indices, true);
if (HasComp<EmaggedComponent>(uid)) if (HasComp<EmaggedComponent>(uid))

View File

@@ -576,7 +576,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
private void HandleAir(EntityUid uid, DisposalUnitComponent component, TransformComponent xform) private void HandleAir(EntityUid uid, DisposalUnitComponent component, TransformComponent xform)
{ {
var air = component.Air; var air = component.Air;
var indices = _transformSystem.GetGridOrMapTilePosition(uid, xform); var indices = _transformSystem.GetGridTilePositionOrDefault((uid, xform));
if (_atmosSystem.GetTileMixture(xform.GridUid, xform.MapUid, indices, true) is { Temperature: > 0f } environment) if (_atmosSystem.GetTileMixture(xform.GridUid, xform.MapUid, indices, true) is { Temperature: > 0f } environment)
{ {

View File

@@ -88,10 +88,7 @@ namespace Content.Server.RatKing
_hunger.ModifyHunger(uid, -component.HungerPerDomainUse, hunger); _hunger.ModifyHunger(uid, -component.HungerPerDomainUse, hunger);
_popup.PopupEntity(Loc.GetString("rat-king-domain-popup"), uid); _popup.PopupEntity(Loc.GetString("rat-king-domain-popup"), uid);
var tileMix = _atmos.GetTileMixture(uid, excite: true);
var transform = Transform(uid);
var indices = _xform.GetGridOrMapTilePosition(uid, transform);
var tileMix = _atmos.GetTileMixture(transform.GridUid, transform.MapUid, indices, true);
tileMix?.AdjustMoles(Gas.Miasma, component.MolesMiasmaPerDomain); tileMix?.AdjustMoles(Gas.Miasma, component.MolesMiasmaPerDomain);
} }

View File

@@ -149,8 +149,7 @@ public sealed class TemperatureSystem : EntitySystem
if (transform.MapUid == null) if (transform.MapUid == null)
return; return;
var position = _transform.GetGridOrMapTilePosition(uid, transform); var position = _transform.GetGridTilePositionOrDefault((uid, transform));
var temperatureDelta = args.GasMixture.Temperature - temperature.CurrentTemperature; var temperatureDelta = args.GasMixture.Temperature - temperature.CurrentTemperature;
var tileHeatCapacity = var tileHeatCapacity =
_atmosphere.GetTileHeatCapacity(transform.GridUid, transform.MapUid.Value, position); _atmosphere.GetTileHeatCapacity(transform.GridUid, transform.MapUid.Value, position);

View File

@@ -37,9 +37,7 @@ public sealed class ArtifactGasTriggerSystem : EntitySystem
if (trigger.ActivationGas == null) if (trigger.ActivationGas == null)
continue; continue;
var environment = _atmosphereSystem.GetTileMixture(transform.GridUid, transform.MapUid, var environment = _atmosphereSystem.GetTileMixture((uid, transform));
_transformSystem.GetGridOrMapTilePosition(uid, transform));
if (environment == null) if (environment == null)
continue; continue;

View File

@@ -28,8 +28,7 @@ public sealed class ArtifactHeatTriggerSystem : EntitySystem
var query = EntityQueryEnumerator<ArtifactHeatTriggerComponent, TransformComponent, ArtifactComponent>(); var query = EntityQueryEnumerator<ArtifactHeatTriggerComponent, TransformComponent, ArtifactComponent>();
while (query.MoveNext(out var uid, out var trigger, out var transform, out var artifact)) while (query.MoveNext(out var uid, out var trigger, out var transform, out var artifact))
{ {
var environment = _atmosphereSystem.GetTileMixture(transform.GridUid, transform.MapUid, var environment = _atmosphereSystem.GetTileMixture((uid, transform));
_transformSystem.GetGridOrMapTilePosition(uid, transform));
if (environment == null) if (environment == null)
continue; continue;

View File

@@ -21,9 +21,7 @@ public sealed class ArtifactPressureTriggerSystem : EntitySystem
var query = EntityQueryEnumerator<ArtifactPressureTriggerComponent, ArtifactComponent, TransformComponent>(); var query = EntityQueryEnumerator<ArtifactPressureTriggerComponent, ArtifactComponent, TransformComponent>();
while (query.MoveNext(out var uid, out var trigger, out var artifact, out var transform)) while (query.MoveNext(out var uid, out var trigger, out var artifact, out var transform))
{ {
var environment = _atmosphereSystem.GetTileMixture(transform.GridUid, transform.MapUid, var environment = _atmosphereSystem.GetTileMixture((uid, transform));
_transformSystem.GetGridOrMapTilePosition(uid, transform));
if (environment == null) if (environment == null)
continue; continue;