Cleanup remaining warnings in ExplosionSystem (#37764)
* Change ExplosionGridTileFlood.Grid to Entity<T> * Change ExplosionData.Lookup to Entity<T> * ExplodeSpace * ExplosionData.MapGrid * _currentGrid * _tileUpdateDict * 1 warning in Process * IsEdge
This commit is contained in:
@@ -11,7 +11,7 @@ namespace Content.Server.Explosion.EntitySystems;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class ExplosionGridTileFlood : ExplosionTileFlood
|
public sealed class ExplosionGridTileFlood : ExplosionTileFlood
|
||||||
{
|
{
|
||||||
public MapGridComponent Grid;
|
public Entity<MapGridComponent> Grid;
|
||||||
private bool _needToTransform = false;
|
private bool _needToTransform = false;
|
||||||
|
|
||||||
private Matrix3x2 _matrix = Matrix3x2.Identity;
|
private Matrix3x2 _matrix = Matrix3x2.Identity;
|
||||||
@@ -37,7 +37,7 @@ public sealed class ExplosionGridTileFlood : ExplosionTileFlood
|
|||||||
private Dictionary<Vector2i, NeighborFlag> _edgeTiles;
|
private Dictionary<Vector2i, NeighborFlag> _edgeTiles;
|
||||||
|
|
||||||
public ExplosionGridTileFlood(
|
public ExplosionGridTileFlood(
|
||||||
MapGridComponent grid,
|
Entity<MapGridComponent> grid,
|
||||||
Dictionary<Vector2i, TileData> airtightMap,
|
Dictionary<Vector2i, TileData> airtightMap,
|
||||||
float maxIntensity,
|
float maxIntensity,
|
||||||
float intensityStepSize,
|
float intensityStepSize,
|
||||||
@@ -73,7 +73,7 @@ public sealed class ExplosionGridTileFlood : ExplosionTileFlood
|
|||||||
|
|
||||||
var transformSystem = entityManager.System<SharedTransformSystem>();
|
var transformSystem = entityManager.System<SharedTransformSystem>();
|
||||||
var transform = entityManager.GetComponent<TransformComponent>(Grid.Owner);
|
var transform = entityManager.GetComponent<TransformComponent>(Grid.Owner);
|
||||||
var size = (float)Grid.TileSize;
|
var size = (float)Grid.Comp.TileSize;
|
||||||
|
|
||||||
_matrix.M31 = size / 2;
|
_matrix.M31 = size / 2;
|
||||||
_matrix.M32 = size / 2;
|
_matrix.M32 = size / 2;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public sealed partial class ExplosionSystem
|
|||||||
|
|
||||||
foreach (var tileRef in _map.GetAllTiles(ev.EntityUid, grid))
|
foreach (var tileRef in _map.GetAllTiles(ev.EntityUid, grid))
|
||||||
{
|
{
|
||||||
if (IsEdge(grid, tileRef.GridIndices, out var dir))
|
if (IsEdge((ev.EntityUid, grid), tileRef.GridIndices, out var dir))
|
||||||
edges.Add(tileRef.GridIndices, dir);
|
edges.Add(tileRef.GridIndices, dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -290,7 +290,7 @@ public sealed partial class ExplosionSystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
// finally check if the new tile is itself an edge tile
|
// finally check if the new tile is itself an edge tile
|
||||||
if (IsEdge(grid, change.GridIndices, out var spaceDir))
|
if (IsEdge((ev.Entity, grid), change.GridIndices, out var spaceDir))
|
||||||
edges.Add(change.GridIndices, spaceDir);
|
edges.Add(change.GridIndices, spaceDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -302,12 +302,12 @@ public sealed partial class ExplosionSystem
|
|||||||
/// Optionally ignore a specific Vector2i. Used by <see cref="OnTileChanged"/> when we already know that a
|
/// Optionally ignore a specific Vector2i. Used by <see cref="OnTileChanged"/> when we already know that a
|
||||||
/// given tile is not space. This avoids unnecessary TryGetTileRef calls.
|
/// given tile is not space. This avoids unnecessary TryGetTileRef calls.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
private bool IsEdge(MapGridComponent grid, Vector2i index, out NeighborFlag spaceDirections)
|
private bool IsEdge(Entity<MapGridComponent> grid, Vector2i index, out NeighborFlag spaceDirections)
|
||||||
{
|
{
|
||||||
spaceDirections = NeighborFlag.Invalid;
|
spaceDirections = NeighborFlag.Invalid;
|
||||||
for (var i = 0; i < NeighbourVectors.Length; i++)
|
for (var i = 0; i < NeighbourVectors.Length; i++)
|
||||||
{
|
{
|
||||||
if (!grid.TryGetTileRef(index + NeighbourVectors[i], out var neighborTile) || neighborTile.Tile.IsEmpty)
|
if (!_mapSystem.TryGetTileRef(grid, grid.Comp, index + NeighbourVectors[i], out var neighborTile) || neighborTile.Tile.IsEmpty)
|
||||||
spaceDirections |= (NeighborFlag) (1 << i);
|
spaceDirections |= (NeighborFlag) (1 << i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ public sealed partial class ExplosionSystem
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Same as <see cref="ExplodeTile"/>, but for SPAAAAAAACE.
|
/// Same as <see cref="ExplodeTile"/>, but for SPAAAAAAACE.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal void ExplodeSpace(BroadphaseComponent lookup,
|
internal void ExplodeSpace(Entity<BroadphaseComponent> lookup,
|
||||||
Matrix3x2 spaceMatrix,
|
Matrix3x2 spaceMatrix,
|
||||||
Matrix3x2 invSpaceMatrix,
|
Matrix3x2 invSpaceMatrix,
|
||||||
Vector2i tile,
|
Vector2i tile,
|
||||||
@@ -318,10 +318,10 @@ public sealed partial class ExplosionSystem
|
|||||||
var state = (list, processed, invSpaceMatrix, lookup.Owner, EntityManager.TransformQuery, gridBox, _transformSystem);
|
var state = (list, processed, invSpaceMatrix, lookup.Owner, EntityManager.TransformQuery, gridBox, _transformSystem);
|
||||||
|
|
||||||
// get entities:
|
// get entities:
|
||||||
lookup.DynamicTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
|
lookup.Comp.DynamicTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
|
||||||
lookup.StaticTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
|
lookup.Comp.StaticTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
|
||||||
lookup.SundriesTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
|
lookup.Comp.SundriesTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
|
||||||
lookup.StaticSundriesTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
|
lookup.Comp.StaticSundriesTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
|
||||||
|
|
||||||
foreach (var (uid, xform) in state.Item1)
|
foreach (var (uid, xform) in state.Item1)
|
||||||
{
|
{
|
||||||
@@ -335,8 +335,8 @@ public sealed partial class ExplosionSystem
|
|||||||
// Also, throw any entities that were spawned as shrapnel. Compared to entity spawning & destruction, this extra
|
// Also, throw any entities that were spawned as shrapnel. Compared to entity spawning & destruction, this extra
|
||||||
// lookup is relatively minor computational cost, and throwing is disabled for nukes anyways.
|
// lookup is relatively minor computational cost, and throwing is disabled for nukes anyways.
|
||||||
list.Clear();
|
list.Clear();
|
||||||
lookup.DynamicTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
|
lookup.Comp.DynamicTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
|
||||||
lookup.SundriesTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
|
lookup.Comp.SundriesTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
|
||||||
|
|
||||||
foreach (var (uid, xform) in list)
|
foreach (var (uid, xform) in list)
|
||||||
{
|
{
|
||||||
@@ -569,12 +569,12 @@ sealed class Explosion
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Lookup component for this grid (or space/map).
|
/// Lookup component for this grid (or space/map).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BroadphaseComponent Lookup;
|
public Entity<BroadphaseComponent> Lookup;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The actual grid that this corresponds to. If null, this implies space.
|
/// The actual grid that this corresponds to. If null, this implies space.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MapGridComponent? MapGrid;
|
public Entity<MapGridComponent>? MapGrid;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly List<ExplosionData> _explosionData = new();
|
private readonly List<ExplosionData> _explosionData = new();
|
||||||
@@ -625,8 +625,8 @@ sealed class Explosion
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
private DamageSpecifier? _expectedDamage;
|
private DamageSpecifier? _expectedDamage;
|
||||||
#endif
|
#endif
|
||||||
private BroadphaseComponent _currentLookup = default!;
|
private Entity<BroadphaseComponent> _currentLookup = default!;
|
||||||
private MapGridComponent? _currentGrid;
|
private Entity<MapGridComponent>? _currentGrid;
|
||||||
private float _currentIntensity;
|
private float _currentIntensity;
|
||||||
private float _currentThrowForce;
|
private float _currentThrowForce;
|
||||||
private List<Vector2i>.Enumerator _currentEnumerator;
|
private List<Vector2i>.Enumerator _currentEnumerator;
|
||||||
@@ -636,7 +636,7 @@ sealed class Explosion
|
|||||||
/// The set of tiles that need to be updated when the explosion has finished processing. Used to avoid having
|
/// The set of tiles that need to be updated when the explosion has finished processing. Used to avoid having
|
||||||
/// the explosion trigger chunk regeneration & shuttle-system processing every tick.
|
/// the explosion trigger chunk regeneration & shuttle-system processing every tick.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly Dictionary<MapGridComponent, List<(Vector2i, Tile)>> _tileUpdateDict = new();
|
private readonly Dictionary<Entity<MapGridComponent>, List<(Vector2i, Tile)>> _tileUpdateDict = new();
|
||||||
|
|
||||||
// Entity Queries
|
// Entity Queries
|
||||||
private readonly EntityQuery<TransformComponent> _xformQuery;
|
private readonly EntityQuery<TransformComponent> _xformQuery;
|
||||||
@@ -720,7 +720,7 @@ sealed class Explosion
|
|||||||
_explosionData.Add(new()
|
_explosionData.Add(new()
|
||||||
{
|
{
|
||||||
TileLists = spaceData.TileLists,
|
TileLists = spaceData.TileLists,
|
||||||
Lookup = entMan.GetComponent<BroadphaseComponent>(mapUid),
|
Lookup = (mapUid, entMan.GetComponent<BroadphaseComponent>(mapUid)),
|
||||||
MapGrid = null
|
MapGrid = null
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -733,7 +733,7 @@ sealed class Explosion
|
|||||||
_explosionData.Add(new ExplosionData
|
_explosionData.Add(new ExplosionData
|
||||||
{
|
{
|
||||||
TileLists = grid.TileLists,
|
TileLists = grid.TileLists,
|
||||||
Lookup = entMan.GetComponent<BroadphaseComponent>(grid.Grid.Owner),
|
Lookup = (grid.Grid, entMan.GetComponent<BroadphaseComponent>(grid.Grid)),
|
||||||
MapGrid = grid.Grid,
|
MapGrid = grid.Grid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -784,7 +784,7 @@ sealed class Explosion
|
|||||||
_currentDataIndex++;
|
_currentDataIndex++;
|
||||||
|
|
||||||
// sanity checks, in case something changed while the explosion was being processed over several ticks.
|
// sanity checks, in case something changed while the explosion was being processed over several ticks.
|
||||||
if (_currentLookup.Deleted || _currentGrid != null && !_entMan.EntityExists(_currentGrid.Owner))
|
if (_currentLookup.Comp.Deleted || _currentGrid != null && !_entMan.EntityExists(_currentGrid.Value))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -839,20 +839,20 @@ sealed class Explosion
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Is the current tile on a grid (instead of in space)?
|
// Is the current tile on a grid (instead of in space)?
|
||||||
if (_currentGrid != null &&
|
if (_currentGrid is { } currentGrid &&
|
||||||
_currentGrid.TryGetTileRef(_currentEnumerator.Current, out var tileRef) &&
|
_mapSystem.TryGetTileRef(currentGrid, currentGrid.Comp, _currentEnumerator.Current, out var tileRef) &&
|
||||||
!tileRef.Tile.IsEmpty)
|
!tileRef.Tile.IsEmpty)
|
||||||
{
|
{
|
||||||
if (!_tileUpdateDict.TryGetValue(_currentGrid, out var tileUpdateList))
|
if (!_tileUpdateDict.TryGetValue(currentGrid, out var tileUpdateList))
|
||||||
{
|
{
|
||||||
tileUpdateList = new();
|
tileUpdateList = new();
|
||||||
_tileUpdateDict[_currentGrid] = tileUpdateList;
|
_tileUpdateDict[currentGrid] = tileUpdateList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// damage entities on the tile. Also figures out whether there are any solid entities blocking the floor
|
// damage entities on the tile. Also figures out whether there are any solid entities blocking the floor
|
||||||
// from being destroyed.
|
// from being destroyed.
|
||||||
var canDamageFloor = _system.ExplodeTile(_currentLookup,
|
var canDamageFloor = _system.ExplodeTile(_currentLookup,
|
||||||
(_currentGrid.Owner, _currentGrid),
|
currentGrid,
|
||||||
_currentEnumerator.Current,
|
_currentEnumerator.Current,
|
||||||
_currentThrowForce,
|
_currentThrowForce,
|
||||||
_currentDamage,
|
_currentDamage,
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public sealed partial class ExplosionSystem
|
|||||||
airtightMap = new();
|
airtightMap = new();
|
||||||
|
|
||||||
var initialGridData = new ExplosionGridTileFlood(
|
var initialGridData = new ExplosionGridTileFlood(
|
||||||
Comp<MapGridComponent>(epicentreGrid.Value),
|
(epicentreGrid.Value, Comp<MapGridComponent>(epicentreGrid.Value)),
|
||||||
airtightMap,
|
airtightMap,
|
||||||
maxIntensity,
|
maxIntensity,
|
||||||
stepSize,
|
stepSize,
|
||||||
@@ -196,7 +196,7 @@ public sealed partial class ExplosionSystem
|
|||||||
airtightMap = new();
|
airtightMap = new();
|
||||||
|
|
||||||
data = new ExplosionGridTileFlood(
|
data = new ExplosionGridTileFlood(
|
||||||
Comp<MapGridComponent>(grid),
|
(grid, Comp<MapGridComponent>(grid)),
|
||||||
airtightMap,
|
airtightMap,
|
||||||
maxIntensity,
|
maxIntensity,
|
||||||
stepSize,
|
stepSize,
|
||||||
|
|||||||
Reference in New Issue
Block a user