Remove Explicit GridId References (#8315)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -140,10 +140,10 @@ namespace Content.Shared.AI
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ReachableChunkRegionsDebugMessage : EntityEventArgs
|
||||
{
|
||||
public GridId GridId { get; }
|
||||
public EntityUid GridId { get; }
|
||||
public Dictionary<int, Dictionary<int, List<Vector2>>> Regions { get; }
|
||||
|
||||
public ReachableChunkRegionsDebugMessage(GridId gridId, Dictionary<int, Dictionary<int, List<Vector2>>> regions)
|
||||
public ReachableChunkRegionsDebugMessage(EntityUid gridId, Dictionary<int, Dictionary<int, List<Vector2>>> regions)
|
||||
{
|
||||
GridId = gridId;
|
||||
Regions = regions;
|
||||
@@ -153,11 +153,11 @@ namespace Content.Shared.AI
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ReachableCacheDebugMessage : EntityEventArgs
|
||||
{
|
||||
public GridId GridId { get; }
|
||||
public EntityUid GridId { get; }
|
||||
public Dictionary<int, List<Vector2>> Regions { get; }
|
||||
public bool Cached { get; }
|
||||
|
||||
public ReachableCacheDebugMessage(GridId gridId, Dictionary<int, List<Vector2>> regions, bool cached)
|
||||
public ReachableCacheDebugMessage(EntityUid gridId, Dictionary<int, List<Vector2>> regions, bool cached)
|
||||
{
|
||||
GridId = gridId;
|
||||
Regions = regions;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Atmos.EntitySystems
|
||||
@@ -37,13 +37,13 @@ namespace Content.Shared.Atmos.EntitySystems
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AtmosDebugOverlayMessage : EntityEventArgs
|
||||
{
|
||||
public GridId GridId { get; }
|
||||
public EntityUid GridId { get; }
|
||||
|
||||
public Vector2i BaseIdx { get; }
|
||||
// LocalViewRange*LocalViewRange
|
||||
public AtmosDebugOverlayData[] OverlayData { get; }
|
||||
|
||||
public AtmosDebugOverlayMessage(GridId gridIndices, Vector2i baseIdx, AtmosDebugOverlayData[] overlayData)
|
||||
public AtmosDebugOverlayMessage(EntityUid gridIndices, Vector2i baseIdx, AtmosDebugOverlayData[] overlayData)
|
||||
{
|
||||
GridId = gridIndices;
|
||||
BaseIdx = baseIdx;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Atmos.EntitySystems
|
||||
@@ -84,11 +84,11 @@ namespace Content.Shared.Atmos.EntitySystems
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class GasOverlayMessage : EntityEventArgs
|
||||
{
|
||||
public GridId GridId { get; }
|
||||
public EntityUid GridId { get; }
|
||||
|
||||
public List<(Vector2i, GasOverlayData)> OverlayData { get; }
|
||||
|
||||
public GasOverlayMessage(GridId gridIndices, List<(Vector2i,GasOverlayData)> overlayData)
|
||||
public GasOverlayMessage(EntityUid gridIndices, List<(Vector2i,GasOverlayData)> overlayData)
|
||||
{
|
||||
GridId = gridIndices;
|
||||
OverlayData = overlayData;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Content.Shared.Atmos
|
||||
/// <summary>
|
||||
/// Grid for this chunk
|
||||
/// </summary>
|
||||
public GridId GridIndices { get; }
|
||||
public EntityUid GridIndices { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Origin of this chunk
|
||||
@@ -21,7 +21,7 @@ namespace Content.Shared.Atmos
|
||||
|
||||
public GameTick LastUpdate { get; private set; }
|
||||
|
||||
public GasOverlayChunk(GridId gridIndices, Vector2i vector2i)
|
||||
public GasOverlayChunk(EntityUid gridIndices, Vector2i vector2i)
|
||||
{
|
||||
GridIndices = gridIndices;
|
||||
Vector2i = vector2i;
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Content.Shared.Decals
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class DecalChunkUpdateEvent : EntityEventArgs
|
||||
{
|
||||
public Dictionary<GridId, Dictionary<Vector2i, Dictionary<uint, Decal>>> Data = new();
|
||||
public Dictionary<GridId, HashSet<Vector2i>> RemovedChunks = new();
|
||||
public Dictionary<EntityUid, Dictionary<Vector2i, Dictionary<uint, Decal>>> Data = new();
|
||||
public Dictionary<EntityUid, HashSet<Vector2i>> RemovedChunks = new();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Content.Shared.Decals
|
||||
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
||||
[Dependency] protected readonly IMapManager MapManager = default!;
|
||||
|
||||
protected readonly Dictionary<GridId, Dictionary<uint, Vector2i>> ChunkIndex = new();
|
||||
protected readonly Dictionary<EntityUid, Dictionary<uint, Vector2i>> ChunkIndex = new();
|
||||
|
||||
public const int ChunkSize = 32;
|
||||
public static Vector2i GetChunkIndices(Vector2 coordinates) => new ((int) Math.Floor(coordinates.X / ChunkSize), (int) Math.Floor(coordinates.Y / ChunkSize));
|
||||
@@ -54,14 +54,11 @@ namespace Content.Shared.Decals
|
||||
|
||||
protected DecalGridComponent.DecalGridChunkCollection DecalGridChunkCollection(EntityUid gridEuid) =>
|
||||
Comp<DecalGridComponent>(gridEuid).ChunkCollection;
|
||||
protected DecalGridComponent.DecalGridChunkCollection DecalGridChunkCollection(GridId gridId) =>
|
||||
Comp<DecalGridComponent>(MapManager.GetGridEuid(gridId)).ChunkCollection;
|
||||
protected Dictionary<Vector2i, Dictionary<uint, Decal>> ChunkCollection(EntityUid gridEuid) => DecalGridChunkCollection(gridEuid).ChunkCollection;
|
||||
protected Dictionary<Vector2i, Dictionary<uint, Decal>> ChunkCollection(GridId gridId) => DecalGridChunkCollection(gridId).ChunkCollection;
|
||||
|
||||
protected virtual void DirtyChunk(GridId id, Vector2i chunkIndices) {}
|
||||
protected virtual void DirtyChunk(EntityUid id, Vector2i chunkIndices) {}
|
||||
|
||||
protected bool RemoveDecalInternal(GridId gridId, uint uid)
|
||||
protected bool RemoveDecalInternal(EntityUid gridId, uint uid)
|
||||
{
|
||||
if (!RemoveDecalHook(gridId, uid)) return false;
|
||||
|
||||
@@ -84,7 +81,7 @@ namespace Content.Shared.Decals
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual bool RemoveDecalHook(GridId gridId, uint uid) => true;
|
||||
protected virtual bool RemoveDecalHook(EntityUid gridId, uint uid) => true;
|
||||
|
||||
protected (Box2 view, MapId mapId) CalcViewBounds(in EntityUid euid, TransformComponent xform)
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ public sealed class ExplosionEvent : EntityEventArgs
|
||||
public MapCoordinates Epicenter;
|
||||
|
||||
public Dictionary<int, List<Vector2i>>? SpaceTiles;
|
||||
public Dictionary<GridId, Dictionary<int, List<Vector2i>>> Tiles;
|
||||
public Dictionary<EntityUid, Dictionary<int, List<Vector2i>>> Tiles;
|
||||
|
||||
public List<float> Intensity;
|
||||
|
||||
@@ -53,7 +53,7 @@ public sealed class ExplosionEvent : EntityEventArgs
|
||||
string typeID,
|
||||
List<float> intensity,
|
||||
Dictionary<int, List<Vector2i>>? spaceTiles,
|
||||
Dictionary<GridId, Dictionary<int, List<Vector2i>>> tiles,
|
||||
Dictionary<EntityUid, Dictionary<int, List<Vector2i>>> tiles,
|
||||
Matrix3 spaceMatrix,
|
||||
ushort spaceTileSize)
|
||||
{
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace Content.Shared.Friction
|
||||
|
||||
// TODO: Make IsWeightless event-based; we already have grid traversals tracked so just raise events
|
||||
if (body.Owner.IsWeightless(body, coords, _mapManager) ||
|
||||
!_mapManager.TryGetGrid(xform.GridID, out var grid))
|
||||
!_mapManager.TryGetGrid(xform.GridEntityId, out var grid))
|
||||
return 0.0f;
|
||||
|
||||
if (!coords.IsValid(EntityManager)) return 0.0f;
|
||||
|
||||
@@ -4,13 +4,13 @@ namespace Content.Shared.Gravity
|
||||
{
|
||||
public sealed class GravityChangedMessage : EntityEventArgs
|
||||
{
|
||||
public GravityChangedMessage(GridId changedGridIndex, bool newGravityState)
|
||||
public GravityChangedMessage(EntityUid changedGridIndex, bool newGravityState)
|
||||
{
|
||||
HasGravity = newGravityState;
|
||||
ChangedGridIndex = changedGridIndex;
|
||||
}
|
||||
|
||||
public GridId ChangedGridIndex { get; }
|
||||
public EntityUid ChangedGridIndex { get; }
|
||||
|
||||
public bool HasGravity { get; }
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Content.Shared.Maps
|
||||
/// <summary>
|
||||
/// Attempts to get the turf at map indices with grid id or null if no such turf is found.
|
||||
/// </summary>
|
||||
public static TileRef GetTileRef(this Vector2i vector2i, GridId gridId, IMapManager? mapManager = null)
|
||||
public static TileRef GetTileRef(this Vector2i vector2i, EntityUid gridId, IMapManager? mapManager = null)
|
||||
{
|
||||
if (!gridId.IsValid())
|
||||
return default;
|
||||
@@ -41,7 +41,7 @@ namespace Content.Shared.Maps
|
||||
|
||||
mapManager ??= IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (!mapManager.TryGetGrid(coordinates.GetGridId(entityManager), out var grid))
|
||||
if (!mapManager.TryGetGrid(coordinates.GetGridEntityId(entityManager), out var grid))
|
||||
return null;
|
||||
|
||||
|
||||
@@ -95,10 +95,10 @@ namespace Content.Shared.Maps
|
||||
entityManager ??= IoCManager.Resolve<IEntityManager>();
|
||||
mapManager ??= IoCManager.Resolve<IMapManager>();
|
||||
|
||||
return coordinates.ToVector2i(entityManager, mapManager).PryTile(coordinates.GetGridId(entityManager));
|
||||
return coordinates.ToVector2i(entityManager, mapManager).PryTile(coordinates.GetGridEntityId(entityManager));
|
||||
}
|
||||
|
||||
public static bool PryTile(this Vector2i indices, GridId gridId,
|
||||
public static bool PryTile(this Vector2i indices, EntityUid gridId,
|
||||
IMapManager? mapManager = null, ITileDefinitionManager? tileDefinitionManager = null, IEntityManager? entityManager = null)
|
||||
{
|
||||
mapManager ??= IoCManager.Resolve<IMapManager>();
|
||||
@@ -128,7 +128,7 @@ namespace Content.Shared.Maps
|
||||
|
||||
if (!tileDef.CanCrowbar) return false;
|
||||
|
||||
var mapGrid = mapManager.GetGrid(tileRef.GridIndex);
|
||||
var mapGrid = mapManager.GetGrid(tileRef.GridUid);
|
||||
|
||||
var plating = tileDefinitionManager[tileDef.BaseTurfs[^1]];
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Content.Shared.Maps
|
||||
var (x, y) = ((mapGrid.TileSize - 2 * margin) * robustRandom.NextFloat() + margin, (mapGrid.TileSize - 2 * margin) * robustRandom.NextFloat() + margin);
|
||||
|
||||
//Actually spawn the relevant tile item at the right position and give it some random offset.
|
||||
var tileItem = entityManager.SpawnEntity(tileDef.ItemDropPrototypeName, indices.ToEntityCoordinates(tileRef.GridIndex, mapManager).Offset(new Vector2(x, y)));
|
||||
var tileItem = entityManager.SpawnEntity(tileDef.ItemDropPrototypeName, indices.ToEntityCoordinates(tileRef.GridUid, mapManager).Offset(new Vector2(x, y)));
|
||||
entityManager.GetComponent<TransformComponent>(tileItem).LocalRotation = robustRandom.NextDouble() * Math.Tau;
|
||||
|
||||
return true;
|
||||
@@ -156,7 +156,7 @@ namespace Content.Shared.Maps
|
||||
if (!GetWorldTileBox(turf, out var worldBox))
|
||||
return Enumerable.Empty<EntityUid>();
|
||||
|
||||
return lookupSystem.GetEntitiesIntersecting(turf.GridIndex, worldBox, flags);
|
||||
return lookupSystem.GetEntitiesIntersecting(turf.GridUid, worldBox, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -175,7 +175,7 @@ namespace Content.Shared.Maps
|
||||
/// <summary>
|
||||
/// Helper that returns all entities in a turf.
|
||||
/// </summary>
|
||||
public static IEnumerable<EntityUid> GetEntitiesInTile(this Vector2i indices, GridId gridId, LookupFlags flags = LookupFlags.Anchored, EntityLookupSystem? lookupSystem = null)
|
||||
public static IEnumerable<EntityUid> GetEntitiesInTile(this Vector2i indices, EntityUid gridId, LookupFlags flags = LookupFlags.Anchored, EntityLookupSystem? lookupSystem = null)
|
||||
{
|
||||
return GetEntitiesInTile(indices.GetTileRef(gridId), flags, lookupSystem);
|
||||
}
|
||||
@@ -196,7 +196,7 @@ namespace Content.Shared.Maps
|
||||
return false;
|
||||
|
||||
var entManager = IoCManager.Resolve<IEntityManager>();
|
||||
var query = physics.GetEntitiesIntersecting(turf.GridIndex, worldBox);
|
||||
var query = physics.GetEntitiesIntersecting(turf.GridUid, worldBox);
|
||||
|
||||
foreach (var ent in query)
|
||||
{
|
||||
@@ -218,7 +218,7 @@ namespace Content.Shared.Maps
|
||||
{
|
||||
mapManager ??= IoCManager.Resolve<IMapManager>();
|
||||
|
||||
return turf.GridIndices.ToEntityCoordinates(turf.GridIndex, mapManager);
|
||||
return turf.GridIndices.ToEntityCoordinates(turf.GridUid, mapManager);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -228,7 +228,7 @@ namespace Content.Shared.Maps
|
||||
{
|
||||
var map = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (map.TryGetGrid(turf.GridIndex, out var tileGrid))
|
||||
if (map.TryGetGrid(turf.GridUid, out var tileGrid))
|
||||
{
|
||||
// This is scaled to 90 % so it doesn't encompass walls on other tiles.
|
||||
var tileBox = Box2.UnitCentered.Scale(0.9f);
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Content.Shared.Movement.Components
|
||||
return ignoreGravityComponent.Weightless;
|
||||
|
||||
var transform = entityManager.GetComponent<TransformComponent>(entity);
|
||||
var gridId = transform.GridID;
|
||||
var gridId = transform.GridEntityId;
|
||||
|
||||
if (!gridId.IsValid())
|
||||
{
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Content.Shared.Movement
|
||||
|
||||
protected Angle GetParentGridAngle(TransformComponent xform, IMoverComponent mover)
|
||||
{
|
||||
if (xform.GridID == GridId.Invalid || !_mapManager.TryGetGrid(xform.GridID, out var grid))
|
||||
if (xform.GridEntityId == EntityUid.Invalid || !_mapManager.TryGetGrid(xform.GridEntityId, out var grid))
|
||||
return mover.LastGridAngle;
|
||||
|
||||
return grid.WorldRotation;
|
||||
@@ -90,11 +90,11 @@ namespace Content.Shared.Movement
|
||||
|
||||
var worldTotal = _relativeMovement ? parentRotation.RotateVec(total) : total;
|
||||
|
||||
if (transform.GridID != GridId.Invalid)
|
||||
if (transform.GridEntityId == EntityUid.Invalid)
|
||||
mover.LastGridAngle = parentRotation;
|
||||
|
||||
if (worldTotal != Vector2.Zero)
|
||||
transform.LocalRotation = transform.GridID != GridId.Invalid
|
||||
transform.LocalRotation = transform.GridEntityId == EntityUid.Invalid
|
||||
? total.ToWorldAngle()
|
||||
: worldTotal.ToWorldAngle();
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace Content.Shared.Movement
|
||||
|
||||
if (!touching)
|
||||
{
|
||||
if (xform.GridID != GridId.Invalid)
|
||||
if (xform.GridEntityId != EntityUid.Invalid)
|
||||
mover.LastGridAngle = GetParentGridAngle(xform, mover);
|
||||
|
||||
xform.WorldRotation = physicsComponent.LinearVelocity.GetDir().ToAngle();
|
||||
@@ -152,14 +152,14 @@ namespace Content.Shared.Movement
|
||||
if (weightless)
|
||||
worldTotal *= mobMover.WeightlessStrength;
|
||||
|
||||
if (xform.GridID != GridId.Invalid)
|
||||
if (xform.GridEntityId != EntityUid.Invalid)
|
||||
mover.LastGridAngle = parentRotation;
|
||||
|
||||
if (worldTotal != Vector2.Zero)
|
||||
{
|
||||
// This should have its event run during island solver soooo
|
||||
xform.DeferUpdates = true;
|
||||
xform.LocalRotation = xform.GridID != GridId.Invalid
|
||||
xform.LocalRotation = xform.GridEntityId != EntityUid.Invalid
|
||||
? total.ToWorldAngle()
|
||||
: worldTotal.ToWorldAngle();
|
||||
xform.DeferUpdates = false;
|
||||
@@ -231,7 +231,7 @@ namespace Content.Shared.Movement
|
||||
if (!CanSound() || !_tags.HasTag(mover.Owner, "FootstepSound")) return false;
|
||||
|
||||
var coordinates = xform.Coordinates;
|
||||
var gridId = coordinates.GetGridId(EntityManager);
|
||||
var gridId = coordinates.GetGridEntityId(EntityManager);
|
||||
var distanceNeeded = mover.Sprinting ? StepSoundMoveDistanceRunning : StepSoundMoveDistanceWalking;
|
||||
|
||||
// Handle footsteps.
|
||||
@@ -254,7 +254,7 @@ namespace Content.Shared.Movement
|
||||
return false;
|
||||
}
|
||||
|
||||
DebugTools.Assert(gridId != GridId.Invalid);
|
||||
DebugTools.Assert(gridId != EntityUid.Invalid);
|
||||
mobMover.LastPosition = coordinates;
|
||||
|
||||
if (mobMover.StepSoundDistance < distanceNeeded) return false;
|
||||
@@ -272,7 +272,7 @@ namespace Content.Shared.Movement
|
||||
return TryGetFootstepSound(gridId, coordinates, out variation, out sound);
|
||||
}
|
||||
|
||||
private bool TryGetFootstepSound(GridId gridId, EntityCoordinates coordinates, out float variation, [NotNullWhen(true)] out string? sound)
|
||||
private bool TryGetFootstepSound(EntityUid gridId, EntityCoordinates coordinates, out float variation, [NotNullWhen(true)] out string? sound)
|
||||
{
|
||||
variation = 0f;
|
||||
sound = null;
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Content.Shared.SubFloor
|
||||
if (args.NewTile.Tile.IsEmpty)
|
||||
return; // Anything that was here will be unanchored anyways.
|
||||
|
||||
UpdateTile(MapManager.GetGrid(args.NewTile.GridIndex), args.NewTile.GridIndices);
|
||||
UpdateTile(MapManager.GetGrid(args.NewTile.GridUid), args.NewTile.GridIndices);
|
||||
}
|
||||
|
||||
private void OnGridChanged(GridModifiedEvent args)
|
||||
@@ -98,7 +98,7 @@ namespace Content.Shared.SubFloor
|
||||
if (!Resolve(uid, ref component, ref xform))
|
||||
return;
|
||||
|
||||
if (xform.Anchored && MapManager.TryGetGrid(xform.GridID, out var grid))
|
||||
if (xform.Anchored && MapManager.TryGetGrid(xform.GridEntityId, out var grid))
|
||||
component.IsUnderCover = HasFloorCover(grid, grid.TileIndicesFor(xform.Coordinates));
|
||||
else
|
||||
component.IsUnderCover = false;
|
||||
|
||||
@@ -208,7 +208,7 @@ public sealed class TrayScannerSystem : EntitySystem
|
||||
|
||||
// For now, limiting to the scanner's own grid. We could do a grid-lookup, but then what do we do if one grid
|
||||
// flies away, while the scanner's local-position remains unchanged?
|
||||
if (_mapManager.TryGetGrid(transform.GridID, out var grid))
|
||||
if (_mapManager.TryGetGrid(transform.GridEntityId, out var grid))
|
||||
{
|
||||
foreach (var entity in grid.GetAnchoredEntities(worldBox))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user