Remove some explosion resolves (#13330)
This commit is contained in:
@@ -117,7 +117,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
var gridUid = grid.Owner;
|
var gridUid = grid.Owner;
|
||||||
|
|
||||||
var query = EntityManager.GetEntityQuery<AirtightComponent>();
|
var query = EntityManager.GetEntityQuery<AirtightComponent>();
|
||||||
_explosionSystem.UpdateAirtightMap(gridId, pos, query);
|
_explosionSystem.UpdateAirtightMap(gridId, pos, grid, query);
|
||||||
// TODO make atmos system use query
|
// TODO make atmos system use query
|
||||||
_atmosphereSystem.InvalidateTile(gridUid, pos);
|
_atmosphereSystem.InvalidateTile(gridUid, pos);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,10 +42,10 @@ public sealed partial class ExplosionSystem : EntitySystem
|
|||||||
// indices to this tile-data struct.
|
// indices to this tile-data struct.
|
||||||
private Dictionary<EntityUid, Dictionary<Vector2i, TileData>> _airtightMap = new();
|
private Dictionary<EntityUid, Dictionary<Vector2i, TileData>> _airtightMap = new();
|
||||||
|
|
||||||
public void UpdateAirtightMap(EntityUid gridId, Vector2i tile, EntityQuery<AirtightComponent>? query = null)
|
public void UpdateAirtightMap(EntityUid gridId, Vector2i tile, MapGridComponent? grid = null, EntityQuery<AirtightComponent>? query = null)
|
||||||
{
|
{
|
||||||
if (_mapManager.TryGetGrid(gridId, out var grid))
|
if (Resolve(gridId, ref grid, false))
|
||||||
UpdateAirtightMap(grid, tile, query);
|
UpdateAirtightMap(gridId, grid, tile, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -58,25 +58,26 @@ public sealed partial class ExplosionSystem : EntitySystem
|
|||||||
/// something like a normal and a reinforced windoor on the same tile. But given that this is a pretty rare
|
/// something like a normal and a reinforced windoor on the same tile. But given that this is a pretty rare
|
||||||
/// occurrence, I am fine with this.
|
/// occurrence, I am fine with this.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public void UpdateAirtightMap(MapGridComponent grid, Vector2i tile, EntityQuery<AirtightComponent>? query = null)
|
public void UpdateAirtightMap(EntityUid gridId, MapGridComponent grid, Vector2i tile, EntityQuery<AirtightComponent>? query = null)
|
||||||
{
|
{
|
||||||
var tolerance = new float[_explosionTypes.Count];
|
var tolerance = new float[_explosionTypes.Count];
|
||||||
var blockedDirections = AtmosDirection.Invalid;
|
var blockedDirections = AtmosDirection.Invalid;
|
||||||
|
|
||||||
if (!_airtightMap.ContainsKey(grid.Owner))
|
if (!_airtightMap.ContainsKey(gridId))
|
||||||
_airtightMap[grid.Owner] = new();
|
_airtightMap[gridId] = new();
|
||||||
|
|
||||||
query ??= EntityManager.GetEntityQuery<AirtightComponent>();
|
query ??= EntityManager.GetEntityQuery<AirtightComponent>();
|
||||||
var damageQuery = EntityManager.GetEntityQuery<DamageableComponent>();
|
var damageQuery = EntityManager.GetEntityQuery<DamageableComponent>();
|
||||||
var destructibleQuery = EntityManager.GetEntityQuery<DestructibleComponent>();
|
var destructibleQuery = EntityManager.GetEntityQuery<DestructibleComponent>();
|
||||||
|
var anchoredEnumerator = grid.GetAnchoredEntitiesEnumerator(tile);
|
||||||
|
|
||||||
foreach (var uid in grid.GetAnchoredEntities(tile))
|
while (anchoredEnumerator.MoveNext(out var uid))
|
||||||
{
|
{
|
||||||
if (!query.Value.TryGetComponent(uid, out var airtight) || !airtight.AirBlocked)
|
if (!query.Value.TryGetComponent(uid, out var airtight) || !airtight.AirBlocked)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
blockedDirections |= airtight.AirBlockedDirection;
|
blockedDirections |= airtight.AirBlockedDirection;
|
||||||
var entityTolerances = GetExplosionTolerance(uid, damageQuery, destructibleQuery);
|
var entityTolerances = GetExplosionTolerance(uid.Value, damageQuery, destructibleQuery);
|
||||||
for (var i = 0; i < tolerance.Length; i++)
|
for (var i = 0; i < tolerance.Length; i++)
|
||||||
{
|
{
|
||||||
tolerance[i] = Math.Max(tolerance[i], entityTolerances[i]);
|
tolerance[i] = Math.Max(tolerance[i], entityTolerances[i]);
|
||||||
@@ -84,9 +85,9 @@ public sealed partial class ExplosionSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (blockedDirections != AtmosDirection.Invalid)
|
if (blockedDirections != AtmosDirection.Invalid)
|
||||||
_airtightMap[grid.Owner][tile] = new(tolerance, blockedDirections);
|
_airtightMap[gridId][tile] = new(tolerance, blockedDirections);
|
||||||
else
|
else
|
||||||
_airtightMap[grid.Owner].Remove(tile);
|
_airtightMap[gridId].Remove(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -104,7 +105,7 @@ public sealed partial class ExplosionSystem : EntitySystem
|
|||||||
if (!_mapManager.TryGetGrid(transform.GridUid, out var grid))
|
if (!_mapManager.TryGetGrid(transform.GridUid, out var grid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UpdateAirtightMap(grid, grid.CoordinatesToTile(transform.Coordinates));
|
UpdateAirtightMap(transform.GridUid.Value, grid, grid.CoordinatesToTile(transform.Coordinates));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user