Partial atmos refactor (#22521)
* Reduce atmos component queries * Remove method events * Cache airtight data * Make MolesArchived nullable * Fix airtight cache * only get tile def once * Immutable mixtures * firelock queries * misc * misc cleanup * Trim disconnected tiles * Fix merge issues and bugs * Why does the PR keep increasing in scope * debug overlay * Fix bugs * Fix test, remove unused events * Add setmapatmos command * Fix overlays * Add map check * A * Resolve conflicts with #26102 * Remove some obsolete methods
This commit is contained in:
@@ -41,20 +41,6 @@ public partial class AtmosphereSystem
|
||||
_gasTileOverlaySystem.Invalidate(gridUid, tile, comp);
|
||||
}
|
||||
|
||||
public bool NeedsVacuumFixing(MapGridComponent mapGrid, Vector2i indices)
|
||||
{
|
||||
var value = false;
|
||||
|
||||
var enumerator = GetObstructingComponentsEnumerator(mapGrid, indices);
|
||||
|
||||
while (enumerator.MoveNext(out var airtight))
|
||||
{
|
||||
value |= airtight.FixVacuum;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the volume in liters for a number of tiles, on a specific grid.
|
||||
/// </summary>
|
||||
@@ -66,34 +52,44 @@ public partial class AtmosphereSystem
|
||||
return Atmospherics.CellVolume * mapGrid.TileSize * tiles;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all obstructing <see cref="AirtightComponent"/> instances in a specific tile.
|
||||
/// </summary>
|
||||
/// <param name="mapGrid">The grid where to get the tile.</param>
|
||||
/// <param name="tile">The indices of the tile.</param>
|
||||
/// <returns>The enumerator for the airtight components.</returns>
|
||||
public AtmosObstructionEnumerator GetObstructingComponentsEnumerator(MapGridComponent mapGrid, Vector2i tile)
|
||||
{
|
||||
var ancEnumerator = mapGrid.GetAnchoredEntitiesEnumerator(tile);
|
||||
var airQuery = GetEntityQuery<AirtightComponent>();
|
||||
public readonly record struct AirtightData(AtmosDirection BlockedDirections, bool NoAirWhenBlocked,
|
||||
bool FixVacuum);
|
||||
|
||||
var enumerator = new AtmosObstructionEnumerator(ancEnumerator, airQuery);
|
||||
return enumerator;
|
||||
private void UpdateAirtightData(EntityUid uid, GridAtmosphereComponent atmos, MapGridComponent grid, TileAtmosphere tile)
|
||||
{
|
||||
var oldBlocked = tile.AirtightData.BlockedDirections;
|
||||
|
||||
tile.AirtightData = tile.NoGridTile
|
||||
? default
|
||||
: GetAirtightData(uid, grid, tile.GridIndices);
|
||||
|
||||
if (tile.AirtightData.BlockedDirections != oldBlocked && tile.ExcitedGroup != null)
|
||||
ExcitedGroupDispose(atmos, tile.ExcitedGroup);
|
||||
}
|
||||
|
||||
private AtmosDirection GetBlockedDirections(MapGridComponent mapGrid, Vector2i indices)
|
||||
private AirtightData GetAirtightData(EntityUid uid, MapGridComponent grid, Vector2i tile)
|
||||
{
|
||||
var value = AtmosDirection.Invalid;
|
||||
var blockedDirs = AtmosDirection.Invalid;
|
||||
var noAirWhenBlocked = false;
|
||||
var fixVacuum = false;
|
||||
|
||||
var enumerator = GetObstructingComponentsEnumerator(mapGrid, indices);
|
||||
|
||||
while (enumerator.MoveNext(out var airtight))
|
||||
foreach (var ent in _map.GetAnchoredEntities(uid, grid, tile))
|
||||
{
|
||||
if(airtight.AirBlocked)
|
||||
value |= airtight.AirBlockedDirection;
|
||||
if (!_airtightQuery.TryGetComponent(ent, out var airtight))
|
||||
continue;
|
||||
|
||||
if(!airtight.AirBlocked)
|
||||
continue;
|
||||
|
||||
blockedDirs |= airtight.AirBlockedDirection;
|
||||
noAirWhenBlocked |= airtight.NoAirWhenFullyAirBlocked;
|
||||
fixVacuum |= airtight.FixVacuum;
|
||||
|
||||
if (blockedDirs == AtmosDirection.All && noAirWhenBlocked && fixVacuum)
|
||||
break;
|
||||
}
|
||||
|
||||
return value;
|
||||
return new AirtightData(blockedDirs, noAirWhenBlocked, fixVacuum);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user