Cleanup AnchorableSystem (#37753)
* The easy part * Overload and obsolete * Internal cleanup * Update all references to new overload
This commit is contained in:
@@ -29,7 +29,7 @@ public sealed partial class DungeonJob
|
||||
if (dungeon.Entrances.Contains(neighbor))
|
||||
continue;
|
||||
|
||||
if (!_anchorable.TileFree(_grid, neighbor, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
if (!_anchorable.TileFree((_gridUid, _grid), neighbor, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
continue;
|
||||
|
||||
tiles.Add((neighbor, _tile.GetVariantTile((ContentTileDefinition) tileDef, random)));
|
||||
@@ -40,7 +40,7 @@ public sealed partial class DungeonJob
|
||||
if (dungeon.RoomTiles.Contains(index))
|
||||
continue;
|
||||
|
||||
if (!_anchorable.TileFree(_grid, index, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
if (!_anchorable.TileFree((_gridUid, _grid), index, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
continue;
|
||||
|
||||
tiles.Add((index, _tile.GetVariantTile((ContentTileDefinition)tileDef, random)));
|
||||
@@ -53,7 +53,7 @@ public sealed partial class DungeonJob
|
||||
{
|
||||
var index = tiles[i];
|
||||
|
||||
if (!_anchorable.TileFree(_grid, index.Index, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
if (!_anchorable.TileFree((_gridUid, _grid), index.Index, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
continue;
|
||||
|
||||
// If no cardinal neighbors in dungeon then we're a corner.
|
||||
|
||||
@@ -19,7 +19,7 @@ public sealed partial class DungeonJob
|
||||
if (reservedTiles.Contains(tile))
|
||||
continue;
|
||||
|
||||
var blocked = _anchorable.TileFree(_grid, tile, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask);
|
||||
var blocked = _anchorable.TileFree((_gridUid, _grid), tile, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask);
|
||||
|
||||
if (blocked)
|
||||
continue;
|
||||
|
||||
@@ -56,13 +56,13 @@ public sealed partial class DungeonJob
|
||||
}
|
||||
|
||||
// Check if exterior spot free.
|
||||
if (!_anchorable.TileFree(_grid, tile, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
if (!_anchorable.TileFree((_gridUid, _grid), tile, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if interior spot free (no guarantees on exterior but ClearDoor should handle it)
|
||||
if (!_anchorable.TileFree(_grid, dirVec, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
if (!_anchorable.TileFree((_gridUid, _grid), dirVec, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public sealed partial class DungeonJob
|
||||
if (reservedTiles.Contains(tile))
|
||||
continue;
|
||||
|
||||
if (!_anchorable.TileFree(_grid,
|
||||
if (!_anchorable.TileFree((_gridUid, _grid),
|
||||
tile,
|
||||
(int) CollisionGroup.MachineLayer,
|
||||
(int) CollisionGroup.MachineLayer))
|
||||
|
||||
@@ -49,7 +49,7 @@ public sealed partial class DungeonJob
|
||||
break;
|
||||
|
||||
// Room tile / already used.
|
||||
if (!_anchorable.TileFree(_grid, tile, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask) ||
|
||||
if (!_anchorable.TileFree((_gridUid, _grid), tile, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask) ||
|
||||
takenTiles.Contains(tile))
|
||||
{
|
||||
continue;
|
||||
@@ -69,7 +69,7 @@ public sealed partial class DungeonJob
|
||||
|
||||
if (!allExterior.Contains(neighbor) ||
|
||||
takenTiles.Contains(neighbor) ||
|
||||
!_anchorable.TileFree(_grid, neighbor, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
!_anchorable.TileFree((_gridUid, _grid), neighbor, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
{
|
||||
isValid = false;
|
||||
break;
|
||||
@@ -84,7 +84,7 @@ public sealed partial class DungeonJob
|
||||
|
||||
if (allExterior.Contains(perpTile) ||
|
||||
takenTiles.Contains(neighbor) ||
|
||||
!_anchorable.TileFree(_grid, perpTile, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
!_anchorable.TileFree((_gridUid, _grid), perpTile, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
{
|
||||
isValid = false;
|
||||
break;
|
||||
|
||||
@@ -24,7 +24,7 @@ public sealed partial class DungeonJob
|
||||
if (fill.AllowedTiles != null && !fill.AllowedTiles.Contains(tileDef.ID))
|
||||
continue;
|
||||
|
||||
if (!_anchorable.TileFree(_grid, tile, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
if (!_anchorable.TileFree((_gridUid, _grid), tile, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
continue;
|
||||
|
||||
var gridPos = _maps.GridTileToLocal(_gridUid, _grid, tile);
|
||||
|
||||
@@ -69,7 +69,7 @@ public sealed partial class DungeonJob
|
||||
if (reservedTiles.Contains(windowTile))
|
||||
continue;
|
||||
|
||||
if (!_anchorable.TileFree(_grid, windowTile, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
if (!_anchorable.TileFree((_gridUid, _grid), windowTile, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
continue;
|
||||
|
||||
validTiles.Add(windowTile);
|
||||
|
||||
@@ -20,7 +20,7 @@ public sealed partial class DungeonJob
|
||||
// N-wide junctions
|
||||
foreach (var tile in dungeon.CorridorTiles)
|
||||
{
|
||||
if (!_anchorable.TileFree(_grid, tile, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
if (!_anchorable.TileFree((_gridUid, _grid), tile, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
continue;
|
||||
|
||||
// Check each direction:
|
||||
@@ -57,7 +57,7 @@ public sealed partial class DungeonJob
|
||||
}
|
||||
|
||||
// If we're not at the end tile then check it + perpendicular are free.
|
||||
if (!_anchorable.TileFree(_grid, neighbor, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
if (!_anchorable.TileFree((_gridUid, _grid), neighbor, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
{
|
||||
isValid = false;
|
||||
break;
|
||||
@@ -66,13 +66,13 @@ public sealed partial class DungeonJob
|
||||
var perp1 = tile + neighborVec * j + ((Direction) ((i * 2 + 2) % 8)).ToIntVec();
|
||||
var perp2 = tile + neighborVec * j + ((Direction) ((i * 2 + 6) % 8)).ToIntVec();
|
||||
|
||||
if (!_anchorable.TileFree(_grid, perp1, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
if (!_anchorable.TileFree((_gridUid, _grid), perp1, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
{
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!_anchorable.TileFree(_grid, perp2, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
if (!_anchorable.TileFree((_gridUid, _grid), perp2, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
{
|
||||
isValid = false;
|
||||
break;
|
||||
@@ -94,7 +94,7 @@ public sealed partial class DungeonJob
|
||||
var cornerVec = cornerDir.ToIntVec();
|
||||
var cornerNeighbor = tile + neighborVec * j + cornerVec;
|
||||
|
||||
if (_anchorable.TileFree(_grid, cornerNeighbor, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
if (_anchorable.TileFree((_gridUid, _grid), cornerNeighbor, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
{
|
||||
freeCount++;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public sealed partial class DungeonJob
|
||||
if (dungeon.RoomTiles.Contains(neighbor))
|
||||
continue;
|
||||
|
||||
if (!_anchorable.TileFree(_grid, neighbor, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
if (!_anchorable.TileFree((_gridUid, _grid), neighbor, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
continue;
|
||||
|
||||
roomEdges.Add(neighbor);
|
||||
@@ -103,7 +103,7 @@ public sealed partial class DungeonJob
|
||||
{
|
||||
var node = nodeDistances[i].Node;
|
||||
var gridPos = _maps.GridTileToLocal(_gridUid, _grid, node);
|
||||
if (!_anchorable.TileFree(_grid, node, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
if (!_anchorable.TileFree((_gridUid, _grid), node, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
continue;
|
||||
|
||||
width--;
|
||||
|
||||
@@ -35,7 +35,7 @@ public sealed partial class DungeonJob
|
||||
{
|
||||
var tile = availableTiles.RemoveSwap(random.Next(availableTiles.Count));
|
||||
|
||||
if (!_anchorable.TileFree(_grid, tile, (int) CollisionGroup.MachineLayer,
|
||||
if (!_anchorable.TileFree((_gridUid, _grid), tile, (int) CollisionGroup.MachineLayer,
|
||||
(int) CollisionGroup.MachineLayer))
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -23,7 +23,7 @@ public sealed partial class DungeonJob
|
||||
foreach (var neighbor in allExterior)
|
||||
{
|
||||
// Occupado
|
||||
if (dungeon.RoomTiles.Contains(neighbor) || checkedTiles.Contains(neighbor) || !_anchorable.TileFree(_grid, neighbor, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
if (dungeon.RoomTiles.Contains(neighbor) || checkedTiles.Contains(neighbor) || !_anchorable.TileFree((_gridUid, _grid), neighbor, DungeonSystem.CollisionLayer, DungeonSystem.CollisionMask))
|
||||
continue;
|
||||
|
||||
if (!random.Prob(gen.Prob) || !checkedTiles.Add(neighbor))
|
||||
|
||||
@@ -9,7 +9,6 @@ using Content.Shared.Interaction;
|
||||
using Content.Shared.Movement.Pulling.Components;
|
||||
using Content.Shared.Movement.Pulling.Systems;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Tools;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
@@ -28,9 +27,10 @@ public sealed partial class AnchorableSystem : EntitySystem
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly PullingSystem _pulling = default!;
|
||||
[Dependency] private readonly SharedMapSystem _map = default!;
|
||||
[Dependency] private readonly SharedToolSystem _tool = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
|
||||
[Dependency] private readonly TagSystem _tagSystem = default!;
|
||||
[Dependency] private readonly TagSystem _tagSystem = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
|
||||
private EntityQuery<PhysicsComponent> _physicsQuery;
|
||||
@@ -268,9 +268,9 @@ public sealed partial class AnchorableSystem : EntitySystem
|
||||
|
||||
// Need to cast the event or it will be raised as BaseAnchoredAttemptEvent.
|
||||
if (anchoring)
|
||||
RaiseLocalEvent(uid, (AnchorAttemptEvent) attempt);
|
||||
RaiseLocalEvent(uid, (AnchorAttemptEvent)attempt);
|
||||
else
|
||||
RaiseLocalEvent(uid, (UnanchorAttemptEvent) attempt);
|
||||
RaiseLocalEvent(uid, (UnanchorAttemptEvent)attempt);
|
||||
|
||||
anchorable.Delay += attempt.Delay;
|
||||
|
||||
@@ -288,17 +288,17 @@ public sealed partial class AnchorableSystem : EntitySystem
|
||||
if (!TryComp<MapGridComponent>(gridUid, out var grid))
|
||||
return false;
|
||||
|
||||
var tileIndices = grid.TileIndicesFor(coordinates);
|
||||
return TileFree(grid, tileIndices, anchorBody.CollisionLayer, anchorBody.CollisionMask);
|
||||
var tileIndices = _map.TileIndicesFor((gridUid.Value, grid), coordinates);
|
||||
return TileFree((gridUid.Value, grid), tileIndices, anchorBody.CollisionLayer, anchorBody.CollisionMask);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if no hard anchored entities match the collision layer or mask specified.
|
||||
/// </summary>
|
||||
/// <param name="grid"></param>
|
||||
public bool TileFree(MapGridComponent grid, Vector2i gridIndices, int collisionLayer = 0, int collisionMask = 0)
|
||||
public bool TileFree(Entity<MapGridComponent> grid, Vector2i gridIndices, int collisionLayer = 0, int collisionMask = 0)
|
||||
{
|
||||
var enumerator = grid.GetAnchoredEntitiesEnumerator(gridIndices);
|
||||
var enumerator = _map.GetAnchoredEntitiesEnumerator(grid, grid.Comp, gridIndices);
|
||||
|
||||
while (enumerator.MoveNext(out var ent))
|
||||
{
|
||||
@@ -319,6 +319,12 @@ public sealed partial class AnchorableSystem : EntitySystem
|
||||
return true;
|
||||
}
|
||||
|
||||
[Obsolete("Use the Entity<MapGridComponent> version")]
|
||||
public bool TileFree(MapGridComponent grid, Vector2i gridIndices, int collisionLayer = 0, int collisionMask = 0)
|
||||
{
|
||||
return TileFree((grid.Owner, grid), gridIndices, collisionLayer, collisionMask);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if any unstackables are also on the corresponding tile.
|
||||
/// </summary>
|
||||
@@ -337,7 +343,7 @@ public sealed partial class AnchorableSystem : EntitySystem
|
||||
if (!TryComp<MapGridComponent>(gridUid, out var grid))
|
||||
return false;
|
||||
|
||||
var enumerator = grid.GetAnchoredEntitiesEnumerator(grid.LocalToTile(location));
|
||||
var enumerator = _map.GetAnchoredEntitiesEnumerator(gridUid.Value, grid, _map.LocalToTile(gridUid.Value, grid, location));
|
||||
|
||||
while (enumerator.MoveNext(out var entity))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user