Nullable grid Uid (#8798)
This commit is contained in:
@@ -294,7 +294,7 @@ namespace Content.Client.AI
|
||||
private void DrawCachedRegions(DrawingHandleScreen screenHandle, Box2 viewport)
|
||||
{
|
||||
var transform = _entities.GetComponentOrNull<TransformComponent>(_playerManager.LocalPlayer?.ControlledEntity);
|
||||
if (transform == null || !CachedRegions.TryGetValue(transform.GridEntityId, out var entityRegions))
|
||||
if (transform == null || transform.GridUid == null || !CachedRegions.TryGetValue(transform.GridUid.Value, out var entityRegions))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -312,7 +312,7 @@ namespace Content.Client.AI
|
||||
screenTile.X + 15.0f,
|
||||
screenTile.Y + 15.0f);
|
||||
|
||||
screenHandle.DrawRect(box, _cachedRegionColors[transform.GridEntityId][region]);
|
||||
screenHandle.DrawRect(box, _cachedRegionColors[transform.GridUid.Value][region]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -344,7 +344,8 @@ namespace Content.Client.AI
|
||||
{
|
||||
var attachedEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (!_entities.TryGetComponent(attachedEntity, out TransformComponent? transform) ||
|
||||
!Regions.TryGetValue(transform.GridEntityId, out var entityRegions))
|
||||
transform.GridUid == null ||
|
||||
!Regions.TryGetValue(transform.GridUid.Value, out var entityRegions))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -364,7 +365,7 @@ namespace Content.Client.AI
|
||||
screenTile.X + 15.0f,
|
||||
screenTile.Y + 15.0f);
|
||||
|
||||
screenHandle.DrawRect(box, _regionColors[_entities.GetComponent<TransformComponent>(attachedEntity.Value).GridEntityId][chunk][region]);
|
||||
screenHandle.DrawRect(box, _regionColors[transform.GridUid.Value][chunk][region]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
|
||||
foreach (var grid in _data)
|
||||
{
|
||||
var player = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(player)?.GridEntityId;
|
||||
var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(player)?.GridUid;
|
||||
GridOptions.AddItem($"{grid.GridEntityId} {(playerGrid == grid.GridEntityId ? " (Current)" : "")}");
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
|
||||
foreach (var grid in _gridData)
|
||||
{
|
||||
var player = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(player)?.GridEntityId;
|
||||
var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(player)?.GridUid;
|
||||
GridOptions.AddItem($"{grid.GridEntityId} {(playerGrid == grid.GridEntityId ? " (Current)" : "")}");
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
|
||||
foreach (var grid in _gridData)
|
||||
{
|
||||
var player = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(player)?.GridEntityId;
|
||||
var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(player)?.GridUid;
|
||||
GridOptions.AddItem($"{grid.GridEntityId} {(playerGrid == grid.GridEntityId ? " (Current)" : "")}");
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
|
||||
foreach (var grid in _data)
|
||||
{
|
||||
var player = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(player)?.GridEntityId;
|
||||
var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(player)?.GridUid;
|
||||
GridOptions.AddItem($"{grid.GridEntityId} {(playerGrid == grid.GridEntityId ? " (Current)" : "")}");
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace Content.Client.Audio
|
||||
{
|
||||
if(_playMan.LocalPlayer is null || _playMan.LocalPlayer.ControlledEntity != message.Entity) return;
|
||||
if (!TryComp<TransformComponent>(message.Entity, out var xform) ||
|
||||
!_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) return;
|
||||
!_mapManager.TryGetGrid(xform.GridUid, out var grid)) return;
|
||||
|
||||
var tileDef = (ContentTileDefinition) _tileDefMan[grid.GetTileRef(xform.Coordinates).Tile.TypeId];
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ public sealed class EyeLerpingSystem : EntitySystem
|
||||
if (!TryComp(uid, out TransformComponent? transform)
|
||||
|| !TryComp(uid, out EyeComponent? eye)
|
||||
|| eye.Eye == null
|
||||
|| !_mapManager.TryGetGrid(transform.GridEntityId, out var grid))
|
||||
|| !_mapManager.TryGetGrid(transform.GridUid, out var grid))
|
||||
{
|
||||
_toRemove.Add(uid);
|
||||
return;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Content.Client.IconSmoothing
|
||||
[RegisterComponent]
|
||||
public sealed class IconSmoothComponent : Component
|
||||
{
|
||||
public (EntityUid, Vector2i)? LastPosition;
|
||||
public (EntityUid?, Vector2i)? LastPosition;
|
||||
|
||||
/// <summary>
|
||||
/// We will smooth with other objects with the same key.
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace Content.Client.IconSmoothing
|
||||
var xform = Transform(uid);
|
||||
if (xform.Anchored)
|
||||
{
|
||||
component.LastPosition = _mapManager.TryGetGrid(xform.GridEntityId, out var grid)
|
||||
? (xform.GridEntityId, grid.TileIndicesFor(xform.Coordinates))
|
||||
: (EntityUid.Invalid, new Vector2i(0, 0));
|
||||
component.LastPosition = _mapManager.TryGetGrid(xform.GridUid, out var grid)
|
||||
? (xform.GridUid.Value, grid.TileIndicesFor(xform.Coordinates))
|
||||
: (null, new Vector2i(0, 0));
|
||||
|
||||
DirtyNeighbours(uid, component);
|
||||
}
|
||||
@@ -111,7 +111,7 @@ namespace Content.Client.IconSmoothing
|
||||
|
||||
Vector2i pos;
|
||||
|
||||
if (transform.Anchored && _mapManager.TryGetGrid(transform.GridEntityId, out var grid))
|
||||
if (transform.Anchored && _mapManager.TryGetGrid(transform.GridUid, out var grid))
|
||||
{
|
||||
pos = grid.CoordinatesToTile(transform.Coordinates);
|
||||
}
|
||||
@@ -191,9 +191,9 @@ namespace Content.Client.IconSmoothing
|
||||
|
||||
if (xform.Anchored)
|
||||
{
|
||||
if (!_mapManager.TryGetGrid(xform.GridEntityId, out grid))
|
||||
if (!_mapManager.TryGetGrid(xform.GridUid, out grid))
|
||||
{
|
||||
Logger.Error($"Failed to calculate IconSmoothComponent sprite in {uid} because grid {xform.GridEntityId} was missing.");
|
||||
Logger.Error($"Failed to calculate IconSmoothComponent sprite in {uid} because grid {xform.GridUid} was missing.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,9 +76,10 @@ namespace Content.Client.NodeContainer
|
||||
var node = _system.NodeLookup[(groupId, nodeId)];
|
||||
|
||||
|
||||
var gridId = _entityManager.GetComponent<TransformComponent>(node.Entity).GridEntityId;
|
||||
var grid = _mapManager.GetGrid(gridId);
|
||||
var gridTile = grid.TileIndicesFor(_entityManager.GetComponent<TransformComponent>(node.Entity).Coordinates);
|
||||
var xform = _entityManager.GetComponent<TransformComponent>(node.Entity);
|
||||
if (!_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
return;
|
||||
var gridTile = grid.TileIndicesFor(xform.Coordinates);
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.Append($"entity: {node.Entity}\n");
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Content.Client.Physics.Controllers
|
||||
return;
|
||||
}
|
||||
|
||||
if (xform.GridEntityId != EntityUid.Invalid)
|
||||
if (xform.GridUid != null)
|
||||
mover.LastGridAngle = GetParentGridAngle(xform, mover);
|
||||
|
||||
// Essentially we only want to set our mob to predicted so every other entity we just interpolate
|
||||
|
||||
@@ -150,15 +150,15 @@ public sealed class RadarControl : Control
|
||||
Matrix3 matrix;
|
||||
|
||||
// Draw our grid in detail
|
||||
var ourGridId = xform.GridID;
|
||||
if (ourGridId != GridId.Invalid)
|
||||
var ourGridId = xform.GridUid;
|
||||
if (ourGridId != null)
|
||||
{
|
||||
matrix = xform.InvWorldMatrix;
|
||||
var ourGridFixtures = fixturesQuery.GetComponent(ourGridId);
|
||||
var ourGridFixtures = fixturesQuery.GetComponent(ourGridId.Value);
|
||||
// Draw our grid; use non-filled boxes so it doesn't look awful.
|
||||
DrawGrid(handle, offsetMatrix, ourGridFixtures, Color.Yellow);
|
||||
|
||||
DrawDocks(handle, xform.GridEntityId, offsetMatrix);
|
||||
DrawDocks(handle, ourGridId.Value, offsetMatrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -110,13 +110,14 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
|
||||
DockPorts.DisposeAllChildren();
|
||||
DockingScreen.Docks = _docks;
|
||||
|
||||
if (!_entManager.TryGetComponent<TransformComponent>(_entity, out var xform))
|
||||
if (!_entManager.TryGetComponent<TransformComponent>(_entity, out var xform)
|
||||
|| !xform.GridUid.HasValue)
|
||||
{
|
||||
// TODO: Show Placeholder
|
||||
return;
|
||||
}
|
||||
|
||||
if (_docks.TryGetValue(xform.GridEntityId, out var gridDocks))
|
||||
if (_docks.TryGetValue(xform.GridUid.Value, out var gridDocks))
|
||||
{
|
||||
var index = 1;
|
||||
|
||||
@@ -194,7 +195,7 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
|
||||
DockingScreen.Visible = true;
|
||||
DockingScreen.ViewedDock = ent;
|
||||
StartAutodockPressed?.Invoke(ent);
|
||||
DockingScreen.GridEntity = xform?.GridEntityId;
|
||||
DockingScreen.GridEntity = xform?.GridUid;
|
||||
_selectedDock = obj.Button;
|
||||
}
|
||||
}
|
||||
@@ -215,8 +216,8 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
|
||||
base.Draw(handle);
|
||||
|
||||
if (!_entManager.TryGetComponent<TransformComponent>(_entity, out var entXform) ||
|
||||
!_entManager.TryGetComponent<PhysicsComponent>(entXform.GridEntityId, out var gridBody) ||
|
||||
!_entManager.TryGetComponent<TransformComponent>(entXform.GridEntityId, out var gridXform))
|
||||
!_entManager.TryGetComponent<PhysicsComponent>(entXform.GridUid, out var gridBody) ||
|
||||
!_entManager.TryGetComponent<TransformComponent>(entXform.GridUid, out var gridXform))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Content.IntegrationTests.Tests
|
||||
{
|
||||
// TODO: Properly find the "main" station grid.
|
||||
var grid0 = mapManager.GetAllGrids().First();
|
||||
mapLoader.SaveBlueprint(grid0.GridEntityId, "save load save 1.yml");
|
||||
mapLoader.SaveBlueprint(grid0.Index, "save load save 1.yml");
|
||||
var mapId = mapManager.CreateMap();
|
||||
var grid = mapLoader.LoadBlueprint(mapId, "save load save 1.yml").gridId;
|
||||
mapLoader.SaveBlueprint(grid!.Value, "save load save 2.yml");
|
||||
|
||||
@@ -90,14 +90,14 @@ namespace Content.MapRenderer.Painters
|
||||
}
|
||||
|
||||
var transform = _sEntityManager.GetComponent<TransformComponent>(entity);
|
||||
if (_cMapManager.TryGetGrid(transform.GridEntityId, out var grid))
|
||||
if (_cMapManager.TryGetGrid(transform.GridUid, out var grid))
|
||||
{
|
||||
var position = transform.LocalPosition;
|
||||
|
||||
var (x, y) = TransformLocalPosition(position, grid);
|
||||
var data = new EntityData(sprite, x, y);
|
||||
|
||||
components.GetOrAdd(transform.GridEntityId, _ => new List<EntityData>()).Add(data);
|
||||
components.GetOrAdd(transform.GridUid.Value, _ => new List<EntityData>()).Add(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
{
|
||||
var targetTransform = _entMan.GetComponent<TransformComponent>(_useTarget);
|
||||
|
||||
if (targetTransform.GridEntityId != _entMan.GetComponent<TransformComponent>(_owner).GridEntityId)
|
||||
if (targetTransform.GridUid != _entMan.GetComponent<TransformComponent>(_owner).GridUid)
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
@@ -168,10 +168,10 @@ namespace Content.Server.AI.Pathfinding.Accessible
|
||||
{
|
||||
var xform = EntityManager.GetComponent<TransformComponent>(target);
|
||||
// TODO: Handle this gracefully instead of just failing.
|
||||
if (!xform.GridEntityId.IsValid())
|
||||
if (xform.GridUid == null)
|
||||
return false;
|
||||
|
||||
var targetTile = _mapManager.GetGrid(xform.GridEntityId).GetTileRef(xform.Coordinates);
|
||||
var targetTile = _mapManager.GetGrid(xform.GridUid.Value).GetTileRef(xform.Coordinates);
|
||||
var targetNode = _pathfindingSystem.GetNode(targetTile);
|
||||
|
||||
var collisionMask = 0;
|
||||
@@ -206,10 +206,10 @@ namespace Content.Server.AI.Pathfinding.Accessible
|
||||
{
|
||||
var xform = EntityManager.GetComponent<TransformComponent>(entity);
|
||||
|
||||
if (xform.GridEntityId != targetNode.TileRef.GridUid)
|
||||
if (xform.GridUid != targetNode.TileRef.GridUid || xform.GridUid == null)
|
||||
return false;
|
||||
|
||||
var entityTile = _mapManager.GetGrid(xform.GridEntityId).GetTileRef(xform.Coordinates);
|
||||
var entityTile = _mapManager.GetGrid(xform.GridUid.Value).GetTileRef(xform.Coordinates);
|
||||
var entityNode = _pathfindingSystem.GetNode(entityTile);
|
||||
var entityRegion = GetRegion(entityNode);
|
||||
var targetRegion = GetRegion(targetNode);
|
||||
@@ -421,12 +421,12 @@ namespace Content.Server.AI.Pathfinding.Accessible
|
||||
{
|
||||
var xform = EntityManager.GetComponent<TransformComponent>(entity);
|
||||
|
||||
if (!xform.GridEntityId.IsValid())
|
||||
if (xform.GridUid == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var entityTile = _mapManager.GetGrid(xform.GridEntityId).GetTileRef(xform.Coordinates);
|
||||
var entityTile = _mapManager.GetGrid(xform.GridUid.Value).GetTileRef(xform.Coordinates);
|
||||
var entityNode = _pathfindingSystem.GetNode(entityTile);
|
||||
return GetRegion(entityNode);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public sealed partial class PathfindingSystem
|
||||
|
||||
private bool IsRelevant(TransformComponent xform, PhysicsComponent physics)
|
||||
{
|
||||
return xform.GridEntityId != EntityUid.Invalid && (TrackedCollisionLayers & physics.CollisionLayer) != 0;
|
||||
return xform.GridUid != null && (TrackedCollisionLayers & physics.CollisionLayer) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -143,7 +143,7 @@ public sealed partial class PathfindingSystem
|
||||
!Resolve(entity, ref physics, false)) return;
|
||||
|
||||
if (!IsRelevant(xform, physics) ||
|
||||
!_mapManager.TryGetGrid(xform.GridEntityId, out var grid))
|
||||
!_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ public sealed partial class PathfindingSystem
|
||||
private void OnEntityRemove(EntityUid entity, TransformComponent? xform = null)
|
||||
{
|
||||
if (!Resolve(entity, ref xform, false) ||
|
||||
!_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) return;
|
||||
!_mapManager.TryGetGrid(xform.GridUid, out var grid)) return;
|
||||
|
||||
var node = GetNode(grid.GetTileRef(xform.Coordinates));
|
||||
node.RemoveEntity(entity);
|
||||
@@ -166,7 +166,7 @@ public sealed partial class PathfindingSystem
|
||||
|
||||
private void OnEntityRemove(EntityUid entity, EntityCoordinates coordinates)
|
||||
{
|
||||
var gridId = coordinates.GetGridEntityId(EntityManager);
|
||||
var gridId = coordinates.GetGridUid(EntityManager);
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid)) return;
|
||||
|
||||
var node = GetNode(grid.GetTileRef(coordinates));
|
||||
@@ -175,13 +175,13 @@ public sealed partial class PathfindingSystem
|
||||
|
||||
private PathfindingNode? GetNode(TransformComponent xform)
|
||||
{
|
||||
if (!_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) return null;
|
||||
if (!_mapManager.TryGetGrid(xform.GridUid, out var grid)) return null;
|
||||
return GetNode(grid.GetTileRef(xform.Coordinates));
|
||||
}
|
||||
|
||||
private PathfindingNode? GetNode(EntityCoordinates coordinates)
|
||||
{
|
||||
if (!_mapManager.TryGetGrid(coordinates.GetGridEntityId(EntityManager), out var grid)) return null;
|
||||
if (!_mapManager.TryGetGrid(coordinates.GetGridUid(EntityManager), out var grid)) return null;
|
||||
return GetNode(grid.GetTileRef(coordinates));
|
||||
}
|
||||
|
||||
@@ -215,8 +215,10 @@ public sealed partial class PathfindingSystem
|
||||
// Also look at increasing tile cost the more physics entities are on it
|
||||
public bool CanTraverse(EntityUid entity, EntityCoordinates coordinates)
|
||||
{
|
||||
var gridId = coordinates.GetGridEntityId(EntityManager);
|
||||
var tile = _mapManager.GetGrid(gridId).GetTileRef(coordinates);
|
||||
var gridId = coordinates.GetGridUid(EntityManager);
|
||||
if (gridId == null)
|
||||
return false;
|
||||
var tile = _mapManager.GetGrid(gridId.Value).GetTileRef(coordinates);
|
||||
var node = GetNode(tile);
|
||||
return CanTraverse(entity, node);
|
||||
}
|
||||
|
||||
@@ -242,7 +242,8 @@ namespace Content.Server.AI.Steering
|
||||
if (Deleted(entity) ||
|
||||
!EntityManager.TryGetComponent(entity, out AiControllerComponent? controller) ||
|
||||
!controller.CanMove ||
|
||||
!EntityManager.GetComponent<TransformComponent>(entity).GridEntityId.IsValid())
|
||||
!TryComp(entity, out TransformComponent? xform) ||
|
||||
xform.GridUid == null)
|
||||
{
|
||||
return SteeringStatus.NoPath;
|
||||
}
|
||||
@@ -255,7 +256,7 @@ namespace Content.Server.AI.Steering
|
||||
return SteeringStatus.NoPath;
|
||||
}
|
||||
|
||||
if (_mapManager.IsGridPaused(EntityManager.GetComponent<TransformComponent>(entity).GridEntityId))
|
||||
if (_mapManager.IsGridPaused(xform.GridUid.Value))
|
||||
{
|
||||
controller.VelocityDir = Vector2.Zero;
|
||||
return SteeringStatus.Pending;
|
||||
@@ -263,14 +264,14 @@ namespace Content.Server.AI.Steering
|
||||
|
||||
// Validation
|
||||
// Check if we can even arrive -> Currently only samegrid movement supported
|
||||
if (EntityManager.GetComponent<TransformComponent>(entity).GridEntityId != steeringRequest.TargetGrid.GetGridEntityId(EntityManager))
|
||||
if (xform.GridUid != steeringRequest.TargetGrid.GetGridUid(EntityManager))
|
||||
{
|
||||
controller.VelocityDir = Vector2.Zero;
|
||||
return SteeringStatus.NoPath;
|
||||
}
|
||||
|
||||
// Check if we have arrived
|
||||
var targetDistance = (EntityManager.GetComponent<TransformComponent>(entity).MapPosition.Position - steeringRequest.TargetMap.Position).Length;
|
||||
var targetDistance = (xform.MapPosition.Position - steeringRequest.TargetMap.Position).Length;
|
||||
steeringRequest.TimeUntilInteractionCheck -= frameTime;
|
||||
|
||||
if (targetDistance <= steeringRequest.ArrivalDistance && steeringRequest.TimeUntilInteractionCheck <= 0.0f)
|
||||
@@ -407,9 +408,13 @@ namespace Content.Server.AI.Steering
|
||||
return;
|
||||
}
|
||||
|
||||
var xform = EntityManager.GetComponent<TransformComponent>(entity);
|
||||
if (xform.GridUid == null)
|
||||
return;
|
||||
|
||||
var cancelToken = new CancellationTokenSource();
|
||||
var gridManager = _mapManager.GetGrid(EntityManager.GetComponent<TransformComponent>(entity).GridEntityId);
|
||||
var startTile = gridManager.GetTileRef(EntityManager.GetComponent<TransformComponent>(entity).Coordinates);
|
||||
var gridManager = _mapManager.GetGrid(xform.GridUid.Value);
|
||||
var startTile = gridManager.GetTileRef(xform.Coordinates);
|
||||
var endTile = gridManager.GetTileRef(steeringRequest.TargetGrid);
|
||||
var collisionMask = 0;
|
||||
if (EntityManager.TryGetComponent(entity, out IPhysBody? physics))
|
||||
@@ -439,7 +444,10 @@ namespace Content.Server.AI.Steering
|
||||
{
|
||||
_pathfindingRequests.Remove(entity);
|
||||
|
||||
var entityTile = _mapManager.GetGrid(EntityManager.GetComponent<TransformComponent>(entity).GridEntityId).GetTileRef(EntityManager.GetComponent<TransformComponent>(entity).Coordinates);
|
||||
var xform = EntityManager.GetComponent<TransformComponent>(entity);
|
||||
if (xform.GridUid == null)
|
||||
return;
|
||||
var entityTile = _mapManager.GetGrid(xform.GridUid.Value).GetTileRef(xform.Coordinates);
|
||||
var tile = path.Dequeue();
|
||||
var closestDistance = PathfindingHelpers.OctileDistance(entityTile, tile);
|
||||
|
||||
@@ -508,7 +516,12 @@ namespace Content.Server.AI.Steering
|
||||
{
|
||||
if (_paths[entity].Count == 0) return;
|
||||
var nextTile = dequeue ? _paths[entity].Dequeue() : _paths[entity].Peek();
|
||||
var nextGrid = _mapManager.GetGrid(EntityManager.GetComponent<TransformComponent>(entity).GridEntityId).GridTileToLocal(nextTile.GridIndices);
|
||||
|
||||
var xform = EntityManager.GetComponent<TransformComponent>(entity);
|
||||
if (xform.GridUid == null)
|
||||
return;
|
||||
|
||||
var nextGrid = _mapManager.GetGrid(xform.GridUid.Value).GridTileToLocal(nextTile.GridIndices);
|
||||
_nextGrid[entity] = nextGrid;
|
||||
}
|
||||
|
||||
@@ -630,8 +643,13 @@ namespace Content.Server.AI.Steering
|
||||
var avoidanceVector = Vector2.Zero;
|
||||
var checkTiles = new HashSet<TileRef>();
|
||||
var avoidTiles = new HashSet<TileRef>();
|
||||
var entityGridCoords = EntityManager.GetComponent<TransformComponent>(entity).Coordinates;
|
||||
var grid = _mapManager.GetGrid(EntityManager.GetComponent<TransformComponent>(entity).GridEntityId);
|
||||
|
||||
var xform = EntityManager.GetComponent<TransformComponent>(entity);
|
||||
if (xform.GridUid == null)
|
||||
return default;
|
||||
|
||||
var entityGridCoords = xform.Coordinates;
|
||||
var grid = _mapManager.GetGrid(xform.GridUid.Value);
|
||||
var currentTile = grid.GetTileRef(entityGridCoords);
|
||||
var halfwayTile = grid.GetTileRef(entityGridCoords.Offset(direction / 2));
|
||||
var nextTile = grid.GetTileRef(entityGridCoords.Offset(direction));
|
||||
|
||||
@@ -51,10 +51,12 @@ namespace Content.Server.AI.Utility.Actions.Idle
|
||||
};
|
||||
}
|
||||
|
||||
private EntityCoordinates FindRandomGrid(IRobustRandom robustRandom)
|
||||
private EntityCoordinates FindRandomGrid(IRobustRandom robustRandom, IEntityManager? entMan = null)
|
||||
{
|
||||
IoCManager.Resolve(ref entMan);
|
||||
|
||||
// Very inefficient (should weight each region by its node count) but better than the old system
|
||||
var reachableSystem = EntitySystem.Get<AiReachableSystem>();
|
||||
var reachableSystem = entMan.EntitySysManager.GetEntitySystem<AiReachableSystem>();
|
||||
var reachableArgs = ReachableArgs.GetArgs(Owner);
|
||||
var entityRegion = reachableSystem.GetRegion(Owner);
|
||||
var reachableRegions = reachableSystem.GetReachableRegions(reachableArgs, entityRegion);
|
||||
@@ -76,9 +78,11 @@ namespace Content.Server.AI.Utility.Actions.Idle
|
||||
}
|
||||
|
||||
var targetNode = robustRandom.Pick(reachableNodes);
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
var grid = mapManager.GetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).GridEntityId);
|
||||
var targetGrid = grid.GridTileToLocal(targetNode.TileRef.GridIndices);
|
||||
|
||||
if (!entMan.TryGetComponent(entMan.GetComponent<TransformComponent>(Owner).GridUid, out IMapGridComponent? grid))
|
||||
return default;
|
||||
|
||||
var targetGrid = grid.Grid.GridTileToLocal(targetNode.TileRef.GridIndices);
|
||||
|
||||
return targetGrid;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Content.Server.AI.Utility.Considerations.Movement
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (context.GetState<TargetEntityState>().GetValue() is not {Valid: true} target || entities.Deleted(target) ||
|
||||
entities.GetComponent<TransformComponent>(target).GridEntityId != entities.GetComponent<TransformComponent>(self).GridEntityId)
|
||||
entities.GetComponent<TransformComponent>(target).GridUid != entities.GetComponent<TransformComponent>(self).GridUid)
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Content.Server.AI.Utils
|
||||
{
|
||||
var transform = entityManager.GetComponent<TransformComponent>(entity);
|
||||
|
||||
if (transform.Coordinates.GetGridEntityId(entityManager) != grid.GetGridEntityId(entityManager))
|
||||
if (transform.Coordinates.GetGridUid(entityManager) != grid.GetGridUid(entityManager))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Content.Server.AME
|
||||
if (!_toolSystem.HasQuality(args.Used, component.QualityNeeded))
|
||||
return;
|
||||
|
||||
if (!_mapManager.TryGetGrid(args.ClickLocation.GetGridEntityId(EntityManager), out var mapGrid))
|
||||
if (!_mapManager.TryGetGrid(args.ClickLocation.GetGridUid(EntityManager), out var mapGrid))
|
||||
return; // No AME in space.
|
||||
|
||||
var snapPos = mapGrid.TileIndicesFor(args.ClickLocation);
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Content.Server.Administration.Commands
|
||||
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
var currentMap = entMan.GetComponent<TransformComponent>(playerEntity).MapID;
|
||||
var currentGrid = entMan.GetComponent<TransformComponent>(playerEntity).GridEntityId;
|
||||
var currentGrid = entMan.GetComponent<TransformComponent>(playerEntity).GridUid;
|
||||
|
||||
var found = entMan.EntityQuery<WarpPointComponent>(true)
|
||||
.Where(p => p.Location == location)
|
||||
@@ -62,8 +62,8 @@ namespace Content.Server.Administration.Commands
|
||||
// Sort so that warp points on the same grid/map are first.
|
||||
// So if you have two maps loaded with the same warp points,
|
||||
// it will prefer the warp points on the map you're currently on.
|
||||
var aGrid = a.GetGridEntityId(entMan);
|
||||
var bGrid = b.GetGridEntityId(entMan);
|
||||
var aGrid = a.GetGridUid(entMan);
|
||||
var bGrid = b.GetGridUid(entMan);
|
||||
|
||||
if (aGrid == bGrid)
|
||||
{
|
||||
@@ -102,7 +102,7 @@ namespace Content.Server.Administration.Commands
|
||||
}))
|
||||
.FirstOrDefault();
|
||||
|
||||
var entityUid = found.GetGridEntityId(entMan);
|
||||
var entityUid = found.GetGridUid(entMan);
|
||||
if (entityUid != EntityUid.Invalid)
|
||||
{
|
||||
entMan.GetComponent<TransformComponent>(playerEntity).Coordinates = found;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Content.Server.Atmos.Commands
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
EntityUid gridId;
|
||||
EntityUid? gridId;
|
||||
Gas? gas = null;
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
@@ -39,9 +39,9 @@ namespace Content.Server.Atmos.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = entMan.GetComponent<TransformComponent>(playerEntity).GridEntityId;
|
||||
gridId = entMan.GetComponent<TransformComponent>(playerEntity).GridUid;
|
||||
|
||||
if (gridId == EntityUid.Invalid)
|
||||
if (gridId == null)
|
||||
{
|
||||
shell.WriteLine("You aren't on a grid to delete gas from.");
|
||||
return;
|
||||
@@ -66,9 +66,9 @@ namespace Content.Server.Atmos.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = entMan.GetComponent<TransformComponent>(playerEntity).GridEntityId;
|
||||
gridId = entMan.GetComponent<TransformComponent>(playerEntity).GridUid;
|
||||
|
||||
if (gridId == EntityUid.Invalid)
|
||||
if (gridId == null)
|
||||
{
|
||||
shell.WriteLine("You aren't on a grid to delete gas from.");
|
||||
return;
|
||||
@@ -98,7 +98,7 @@ namespace Content.Server.Atmos.Commands
|
||||
|
||||
gridId = first;
|
||||
|
||||
if (gridId == EntityUid.Invalid)
|
||||
if (gridId.Value.IsValid())
|
||||
{
|
||||
shell.WriteLine($"{gridId} is not a valid grid id.");
|
||||
return;
|
||||
@@ -134,7 +134,7 @@ namespace Content.Server.Atmos.Commands
|
||||
|
||||
if (gas == null)
|
||||
{
|
||||
foreach (var tile in atmosphereSystem.GetAllTileMixtures(gridId, true))
|
||||
foreach (var tile in atmosphereSystem.GetAllTileMixtures(gridId.Value, true))
|
||||
{
|
||||
if (tile.Immutable) continue;
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace Content.Server.Atmos.Commands
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var tile in atmosphereSystem.GetAllTileMixtures(gridId, true))
|
||||
foreach (var tile in atmosphereSystem.GetAllTileMixtures(gridId.Value, true))
|
||||
{
|
||||
if (tile.Immutable) continue;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
var xform = Transform(uid);
|
||||
|
||||
// If the grid is deleting no point updating atmos.
|
||||
if (_mapManager.TryGetGrid(xform.GridEntityId, out var grid))
|
||||
if (_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
{
|
||||
if (MetaData(grid.GridEntityId).EntityLifeStage > EntityLifeStage.MapInitialized) return;
|
||||
}
|
||||
@@ -56,15 +56,17 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
{
|
||||
var xform = Transform(uid);
|
||||
|
||||
var gridId = xform.GridEntityId;
|
||||
if (!TryComp(xform.GridUid, out IMapGridComponent? grid))
|
||||
return;
|
||||
|
||||
var gridId = xform.GridUid;
|
||||
var coords = xform.Coordinates;
|
||||
|
||||
var grid = _mapManager.GetGrid(gridId);
|
||||
var tilePos = grid.TileIndicesFor(coords);
|
||||
var tilePos = grid.Grid.TileIndicesFor(coords);
|
||||
|
||||
// Update and invalidate new position.
|
||||
airtight.LastPosition = (gridId, tilePos);
|
||||
InvalidatePosition(gridId, tilePos);
|
||||
airtight.LastPosition = (gridId.Value, tilePos);
|
||||
InvalidatePosition(gridId.Value, tilePos);
|
||||
}
|
||||
|
||||
private void OnAirtightReAnchor(EntityUid uid, AirtightComponent airtight, ref ReAnchorEvent args)
|
||||
@@ -100,11 +102,10 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
{
|
||||
if (!Resolve(airtight.Owner, ref xform)) return;
|
||||
|
||||
if (!xform.Anchored || !xform.GridEntityId.IsValid())
|
||||
if (!xform.Anchored || !_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
return;
|
||||
|
||||
var grid = _mapManager.GetGrid(xform.GridEntityId);
|
||||
airtight.LastPosition = (xform.GridEntityId, grid.TileIndicesFor(xform.Coordinates));
|
||||
airtight.LastPosition = (xform.GridUid.Value, grid.TileIndicesFor(xform.Coordinates));
|
||||
InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2, airtight.FixVacuum && !airtight.AirBlocked);
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
/// </summary>
|
||||
/// <param name="grid">Grid to be checked.</param>
|
||||
/// <returns>Whether the grid has a simulated atmosphere.</returns>
|
||||
public bool IsSimulatedGrid(EntityUid grid)
|
||||
public bool IsSimulatedGrid(EntityUid? grid)
|
||||
{
|
||||
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
|
||||
return false;
|
||||
@@ -1376,7 +1376,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
|
||||
public bool AddAtmosDevice(AtmosDeviceComponent atmosDevice)
|
||||
{
|
||||
var grid = Comp<TransformComponent>(atmosDevice.Owner).GridEntityId;
|
||||
var grid = Comp<TransformComponent>(atmosDevice.Owner).GridUid;
|
||||
|
||||
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
|
||||
return false;
|
||||
@@ -1578,7 +1578,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
return false;
|
||||
}
|
||||
|
||||
var gridId = coordinates.GetGridEntityId(EntityManager);
|
||||
var gridId = coordinates.GetGridUid(EntityManager);
|
||||
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid))
|
||||
{
|
||||
@@ -1586,7 +1586,7 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
return false;
|
||||
}
|
||||
|
||||
tuple = (gridId, grid.TileIndicesFor(coordinates));
|
||||
tuple = (gridId.Value, grid.TileIndicesFor(coordinates));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -161,7 +161,6 @@ namespace Content.Server.Atmos.EntitySystems
|
||||
xforms.GetComponent(entity),
|
||||
body);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public sealed class AtmosPipeAppearanceSystem : EntitySystem
|
||||
if (!Resolve(uid, ref appearance, ref container, ref xform, false))
|
||||
return;
|
||||
|
||||
if (!_mapManager.TryGetGrid(xform.GridEntityId, out var grid))
|
||||
if (!_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
return;
|
||||
|
||||
// get connected entities
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
return;
|
||||
|
||||
// If we can't find any ports, cancel the anchoring.
|
||||
if(!FindGasPortIn(transform.GridEntityId, transform.Coordinates, out _))
|
||||
if(!FindGasPortIn(transform.GridUid, transform.Coordinates, out _))
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
@@ -50,15 +50,13 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
}
|
||||
}
|
||||
|
||||
private bool FindGasPortIn(EntityUid gridId, EntityCoordinates coordinates, [NotNullWhen(true)] out GasPortComponent? port)
|
||||
private bool FindGasPortIn(EntityUid? gridId, EntityCoordinates coordinates, [NotNullWhen(true)] out GasPortComponent? port)
|
||||
{
|
||||
port = null;
|
||||
|
||||
if (!gridId.IsValid())
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid))
|
||||
return false;
|
||||
|
||||
var grid = _mapManager.GetGrid(gridId);
|
||||
|
||||
foreach (var entityUid in grid.GetLocal(coordinates))
|
||||
{
|
||||
if (EntityManager.TryGetComponent<GasPortComponent>(entityUid, out port))
|
||||
|
||||
@@ -69,7 +69,11 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
var xform = _entities.GetComponent<TransformComponent>(Owner);
|
||||
var solSys = _systems.GetEntitySystem<SolutionContainerSystem>();
|
||||
var grid = MapManager.GetGrid(xform.GridEntityId);
|
||||
|
||||
if (!_entities.TryGetComponent(xform.GridUid, out IMapGridComponent? gridComp))
|
||||
return;
|
||||
|
||||
var grid = gridComp.Grid;
|
||||
var origin = grid.TileIndicesFor(xform.Coordinates);
|
||||
|
||||
DebugTools.Assert(xform.Anchored, "Area effect entity prototypes must be anchored.");
|
||||
@@ -141,14 +145,17 @@ namespace Content.Server.Chemistry.Components
|
||||
/// with the other area effects from the inception.</param>
|
||||
public void React(float averageExposures)
|
||||
{
|
||||
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
|
||||
|
||||
if (!_entities.EntitySysManager.GetEntitySystem<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
|
||||
return;
|
||||
|
||||
var chemistry = EntitySystem.Get<ReactiveSystem>();
|
||||
var xform = _entities.GetComponent<TransformComponent>(Owner);
|
||||
var mapGrid = MapManager.GetGrid(xform.GridEntityId);
|
||||
if (!MapManager.TryGetGrid(xform.GridUid, out var mapGrid))
|
||||
return;
|
||||
|
||||
var tile = mapGrid.GetTileRef(xform.Coordinates.ToVector2i(_entities, MapManager));
|
||||
var lookup = EntitySystem.Get<EntityLookupSystem>();
|
||||
var chemistry = _entities.EntitySysManager.GetEntitySystem<ReactiveSystem>();
|
||||
var lookup = _entities.EntitySysManager.GetEntitySystem<EntityLookupSystem>();
|
||||
|
||||
var solutionFraction = 1 / Math.Floor(averageExposures);
|
||||
|
||||
|
||||
@@ -90,16 +90,17 @@ namespace Content.Server.Chemistry.EntitySystems
|
||||
return;
|
||||
|
||||
var entity = vapor.Owner;
|
||||
var xform = Transform(entity);
|
||||
|
||||
vapor.Timer += frameTime;
|
||||
vapor.ReactTimer += frameTime;
|
||||
|
||||
if (vapor.ReactTimer >= ReactTime && EntityManager.GetComponent<TransformComponent>(vapor.Owner).GridEntityId.IsValid())
|
||||
if (vapor.ReactTimer >= ReactTime && TryComp(xform.GridUid, out IMapGridComponent? gridComp))
|
||||
{
|
||||
vapor.ReactTimer = 0;
|
||||
var mapGrid = _mapManager.GetGrid(EntityManager.GetComponent<TransformComponent>(entity).GridEntityId);
|
||||
|
||||
var tile = mapGrid.GetTileRef(EntityManager.GetComponent<TransformComponent>(entity).Coordinates.ToVector2i(EntityManager, _mapManager));
|
||||
|
||||
var tile = gridComp.Grid.GetTileRef(xform.Coordinates.ToVector2i(EntityManager, _mapManager));
|
||||
foreach (var reagentQuantity in contents.Contents.ToArray())
|
||||
{
|
||||
if (reagentQuantity.Quantity == FixedPoint2.Zero) continue;
|
||||
@@ -111,7 +112,7 @@ namespace Content.Server.Chemistry.EntitySystems
|
||||
|
||||
// Check if we've reached our target.
|
||||
if (!vapor.Reached &&
|
||||
vapor.Target.TryDistance(EntityManager, EntityManager.GetComponent<TransformComponent>(entity).Coordinates, out var distance) &&
|
||||
vapor.Target.TryDistance(EntityManager, xform.Coordinates, out var distance) &&
|
||||
distance <= 0.5f)
|
||||
{
|
||||
vapor.Reached = true;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Content.Server.Construction.Commands
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
EntityUid gridId;
|
||||
EntityUid? gridId;
|
||||
var xformQuery = entityManager.GetEntityQuery<TransformComponent>();
|
||||
|
||||
switch (args.Length)
|
||||
@@ -33,7 +33,7 @@ namespace Content.Server.Construction.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = xformQuery.GetComponent(playerEntity).GridEntityId;
|
||||
gridId = xformQuery.GetComponent(playerEntity).GridUid;
|
||||
break;
|
||||
case 1:
|
||||
if (!EntityUid.TryParse(args[0], out var id))
|
||||
|
||||
@@ -21,7 +21,7 @@ sealed class TileReplaceCommand : IConsoleCommand
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
EntityUid gridId;
|
||||
EntityUid? gridId;
|
||||
string tileIdA = "";
|
||||
string tileIdB = "";
|
||||
|
||||
@@ -34,7 +34,7 @@ sealed class TileReplaceCommand : IConsoleCommand
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = entityManager.GetComponent<TransformComponent>(playerEntity).GridEntityId;
|
||||
gridId = entityManager.GetComponent<TransformComponent>(playerEntity).GridUid;
|
||||
tileIdA = args[0];
|
||||
tileIdB = args[1];
|
||||
break;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Content.Server.Construction.Commands
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
EntityUid gridId;
|
||||
EntityUid? gridId;
|
||||
|
||||
switch (args.Length)
|
||||
{
|
||||
@@ -35,7 +35,7 @@ namespace Content.Server.Construction.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = entityManager.GetComponent<TransformComponent>(playerEntity).GridEntityId;
|
||||
gridId = entityManager.GetComponent<TransformComponent>(playerEntity).GridUid;
|
||||
break;
|
||||
case 1:
|
||||
if (!EntityUid.TryParse(args[0], out var id))
|
||||
|
||||
@@ -43,8 +43,11 @@ namespace Content.Server.Construction.Conditions
|
||||
var type = IoCManager.Resolve<IComponentFactory>().GetRegistration(Component).Type;
|
||||
|
||||
var transform = entityManager.GetComponent<TransformComponent>(uid);
|
||||
if (transform.GridUid == null)
|
||||
return false;
|
||||
|
||||
var indices = transform.Coordinates.ToVector2i(entityManager, IoCManager.Resolve<IMapManager>());
|
||||
var entities = indices.GetEntitiesInTile(transform.GridEntityId, LookupFlags.Approximate | LookupFlags.Anchored, EntitySystem.Get<EntityLookupSystem>());
|
||||
var entities = indices.GetEntitiesInTile(transform.GridUid.Value, LookupFlags.Approximate | LookupFlags.Anchored, EntitySystem.Get<EntityLookupSystem>());
|
||||
|
||||
foreach (var ent in entities)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Content.Server.Coordinates.Helpers
|
||||
{
|
||||
IoCManager.Resolve(ref entMan, ref mapManager);
|
||||
|
||||
var gridId = coordinates.GetGridEntityId(entMan);
|
||||
var gridId = coordinates.GetGridId(entMan);
|
||||
|
||||
var tileSize = 1f;
|
||||
|
||||
|
||||
@@ -168,16 +168,16 @@ namespace Content.Server.Decals
|
||||
if (!ev.Coordinates.IsValid(EntityManager))
|
||||
return;
|
||||
|
||||
var gridId = ev.Coordinates.GetGridEntityId(EntityManager);
|
||||
var gridId = ev.Coordinates.GetGridUid(EntityManager);
|
||||
|
||||
if (!gridId.IsValid())
|
||||
if (gridId == null)
|
||||
return;
|
||||
|
||||
// remove all decals on the same tile
|
||||
foreach (var (uid, decal) in GetDecalsInRange(gridId, ev.Coordinates.Position))
|
||||
foreach (var (uid, decal) in GetDecalsInRange(gridId.Value, ev.Coordinates.Position))
|
||||
{
|
||||
var chunkIndices = GetChunkIndices(decal.Coordinates);
|
||||
RemoveDecal(gridId, uid);
|
||||
RemoveDecal(gridId.Value, uid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,21 +205,21 @@ namespace Content.Server.Decals
|
||||
if (!PrototypeManager.HasIndex<DecalPrototype>(decal.Id))
|
||||
return false;
|
||||
|
||||
var gridId = coordinates.GetGridEntityId(EntityManager);
|
||||
var gridId = coordinates.GetGridUid(EntityManager);
|
||||
if (!MapManager.TryGetGrid(gridId, out var grid))
|
||||
return false;
|
||||
|
||||
if (grid.GetTileRef(coordinates).IsSpace(_tileDefMan))
|
||||
return false;
|
||||
|
||||
var chunkCollection = DecalGridChunkCollection(gridId);
|
||||
var chunkCollection = DecalGridChunkCollection(gridId.Value);
|
||||
uid = chunkCollection.NextUid++;
|
||||
var chunkIndices = GetChunkIndices(decal.Coordinates);
|
||||
if(!chunkCollection.ChunkCollection.ContainsKey(chunkIndices))
|
||||
chunkCollection.ChunkCollection[chunkIndices] = new();
|
||||
chunkCollection.ChunkCollection[chunkIndices][uid.Value] = decal;
|
||||
ChunkIndex[gridId][uid.Value] = chunkIndices;
|
||||
DirtyChunk(gridId, chunkIndices);
|
||||
ChunkIndex[gridId.Value][uid.Value] = chunkIndices;
|
||||
DirtyChunk(gridId.Value, chunkIndices);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -250,7 +250,11 @@ namespace Content.Server.Decals
|
||||
|
||||
public bool SetDecalPosition(EntityUid gridId, uint uid, EntityCoordinates coordinates)
|
||||
{
|
||||
return SetDecalPosition(gridId, uid, coordinates.GetGridEntityId(EntityManager), coordinates.Position);
|
||||
var newGridId = coordinates.GetGridUid(EntityManager);
|
||||
if (newGridId == null)
|
||||
return false;
|
||||
|
||||
return SetDecalPosition(gridId, uid, newGridId.Value, coordinates.Position);
|
||||
}
|
||||
|
||||
public bool SetDecalPosition(EntityUid gridId, uint uid, EntityUid newGridId, Vector2 position)
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Content.Server.DeviceNetwork.Systems
|
||||
/// </summary>
|
||||
private void OnBeforePacketSent(EntityUid uid, WiredNetworkComponent component, BeforePacketSentEvent args)
|
||||
{
|
||||
if (EntityManager.GetComponent<TransformComponent>(uid).GridEntityId != args.SenderTransform.GridEntityId)
|
||||
if (EntityManager.GetComponent<TransformComponent>(uid).GridUid != args.SenderTransform.GridUid)
|
||||
{
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
@@ -125,8 +125,11 @@ namespace Content.Server.Disposal.Tube
|
||||
return null;
|
||||
var oppositeDirection = nextDirection.GetOpposite();
|
||||
|
||||
var grid = _mapManager.GetGrid(EntityManager.GetComponent<TransformComponent>(targetTube.Owner).GridEntityId);
|
||||
var position = EntityManager.GetComponent<TransformComponent>(targetTube.Owner).Coordinates;
|
||||
var xform = Transform(targetTube.Owner);
|
||||
if (!_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
return null;
|
||||
|
||||
var position = xform.Coordinates;
|
||||
foreach (var entity in grid.GetInDir(position, nextDirection))
|
||||
{
|
||||
if (!EntityManager.TryGetComponent(entity, out IDisposalTubeComponent? tube))
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
// *This is on purpose.*
|
||||
|
||||
DisposalUnitComponent? duc = null;
|
||||
if (_mapManager.TryGetGrid(holderTransform.GridEntityId, out var grid))
|
||||
if (_mapManager.TryGetGrid(holderTransform.GridUid, out var grid))
|
||||
{
|
||||
foreach (var contentUid in grid.GetLocal(holderTransform.Coordinates))
|
||||
{
|
||||
|
||||
@@ -477,9 +477,12 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
return false;
|
||||
}
|
||||
|
||||
var grid = _mapManager.GetGrid(EntityManager.GetComponent<TransformComponent>(component.Owner).GridEntityId);
|
||||
var coords = EntityManager.GetComponent<TransformComponent>(component.Owner).Coordinates;
|
||||
var entry = grid.GetLocal(coords)
|
||||
var xform = Transform(component.Owner);
|
||||
if (!TryComp(xform.GridUid, out IMapGridComponent? grid))
|
||||
return false;
|
||||
|
||||
var coords = xform.Coordinates;
|
||||
var entry = grid.Grid.GetLocal(coords)
|
||||
.FirstOrDefault(entity => EntityManager.HasComponent<DisposalEntryComponent>(entity));
|
||||
|
||||
if (entry == default)
|
||||
@@ -490,7 +493,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
var air = component.Air;
|
||||
var entryComponent = EntityManager.GetComponent<DisposalEntryComponent>(entry);
|
||||
|
||||
if (_atmosSystem.GetTileMixture(EntityManager.GetComponent<TransformComponent>(component.Owner).Coordinates, true) is {Temperature: > 0} environment)
|
||||
if (_atmosSystem.GetTileMixture(xform.Coordinates, true) is {Temperature: > 0} environment)
|
||||
{
|
||||
var transferMoles = 0.1f * (0.25f * Atmospherics.OneAtmosphere * 1.01f - air.Pressure) * air.Volume / (environment.Temperature * Atmospherics.R);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Content.Server.Engineering.EntitySystems
|
||||
return;
|
||||
if (string.IsNullOrEmpty(component.Prototype))
|
||||
return;
|
||||
if (!_mapManager.TryGetGrid(args.ClickLocation.GetGridEntityId(EntityManager), out var grid))
|
||||
if (!_mapManager.TryGetGrid(args.ClickLocation.GetGridUid(EntityManager), out var grid))
|
||||
return;
|
||||
if (!grid.TryGetTileRef(args.ClickLocation, out var tileRef))
|
||||
return;
|
||||
|
||||
@@ -100,7 +100,7 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
if (!EntityManager.TryGetComponent(uid, out TransformComponent? transform) || !transform.Anchored)
|
||||
return;
|
||||
|
||||
if (!_mapManager.TryGetGrid(transform.GridEntityId, out var grid))
|
||||
if (!_mapManager.TryGetGrid(transform.GridUid, out var grid))
|
||||
return;
|
||||
|
||||
UpdateAirtightMap(grid, grid.CoordinatesToTile(transform.Coordinates));
|
||||
|
||||
@@ -103,7 +103,7 @@ public sealed class FluidSpreaderSystem : EntitySystem
|
||||
var prototypeName = metadataOriginal.EntityPrototype!.ID;
|
||||
var visitedTiles = new HashSet<Vector2i>();
|
||||
|
||||
if (!_mapManager.TryGetGrid(transformOrig.GridEntityId, out var mapGrid))
|
||||
if (!_mapManager.TryGetGrid(transformOrig.GridUid, out var mapGrid))
|
||||
return;
|
||||
|
||||
// skip origin puddle
|
||||
|
||||
@@ -76,7 +76,7 @@ public sealed class MoppingSystem : EntitySystem
|
||||
|
||||
private void ReleaseToFloor(EntityCoordinates clickLocation, AbsorbentComponent absorbent, Solution? absorbedSolution)
|
||||
{
|
||||
if ((_mapManager.TryGetGrid(clickLocation.GetGridEntityId(EntityManager), out var mapGrid)) // needs valid grid
|
||||
if ((_mapManager.TryGetGrid(clickLocation.GetGridUid(EntityManager), out var mapGrid)) // needs valid grid
|
||||
&& absorbedSolution is not null) // needs a solution to place on the tile
|
||||
{
|
||||
TileRef tile = mapGrid.GetTileRef(clickLocation);
|
||||
|
||||
@@ -132,7 +132,7 @@ public sealed class SpillableSystem : EntitySystem
|
||||
if (solution.TotalVolume == 0) return null;
|
||||
|
||||
|
||||
if (!_mapManager.TryGetGrid(coordinates.GetGridEntityId(EntityManager), out var mapGrid))
|
||||
if (!_mapManager.TryGetGrid(coordinates.GetGridUid(EntityManager), out var mapGrid))
|
||||
return null; // Let's not spill to space.
|
||||
|
||||
return SpillAt(mapGrid.GetTileRef(coordinates), solution, prototype, overflow, sound,
|
||||
|
||||
@@ -59,7 +59,7 @@ public sealed class SpraySystem : EntitySystem
|
||||
|
||||
var playerPos = Transform(args.User).Coordinates;
|
||||
|
||||
if (args.ClickLocation.GetGridEntityId(EntityManager) != playerPos.GetGridEntityId(EntityManager))
|
||||
if (args.ClickLocation.GetGridUid(EntityManager) != playerPos.GetGridUid(EntityManager))
|
||||
return;
|
||||
|
||||
var direction = (args.ClickLocation.Position - playerPos.Position).Normalized;
|
||||
|
||||
@@ -187,12 +187,11 @@ namespace Content.Server.Gravity.EntitySystems
|
||||
|
||||
private void UpdateGravityActive(GravityGeneratorComponent grav, bool shake)
|
||||
{
|
||||
var gridId = EntityManager.GetComponent<TransformComponent>(grav.Owner).GridEntityId;
|
||||
if (gridId == EntityUid.Invalid)
|
||||
var gridId = EntityManager.GetComponent<TransformComponent>(grav.Owner).GridUid;
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid))
|
||||
return;
|
||||
|
||||
var grid = _mapManager.GetGrid(gridId);
|
||||
var gravity = EntityManager.GetComponent<GravityComponent>(grid.GridEntityId);
|
||||
var gravity = EntityManager.GetComponent<GravityComponent>(gridId.Value);
|
||||
|
||||
if (grav.GravityActive)
|
||||
_gravitySystem.EnableGravity(gravity);
|
||||
@@ -200,7 +199,7 @@ namespace Content.Server.Gravity.EntitySystems
|
||||
_gravitySystem.DisableGravity(gravity);
|
||||
|
||||
if (shake)
|
||||
_gravityShakeSystem.ShakeGrid(gridId, gravity);
|
||||
_gravityShakeSystem.ShakeGrid(gridId.Value, gravity);
|
||||
}
|
||||
|
||||
private void OnInteractHand(EntityUid uid, GravityGeneratorComponent component, InteractHandEvent args)
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Content.Server.Gravity.EntitySystems
|
||||
foreach (var player in _playerManager.Sessions)
|
||||
{
|
||||
if (player.AttachedEntity is not {Valid: true} attached
|
||||
|| EntityManager.GetComponent<TransformComponent>(attached).GridEntityId != gridId
|
||||
|| EntityManager.GetComponent<TransformComponent>(attached).GridUid != gridId
|
||||
|| !EntityManager.HasComponent<CameraRecoilComponent>(attached))
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -16,22 +16,26 @@ namespace Content.Server.Gravity.EntitySystems
|
||||
private void HandleGravityInitialize(EntityUid uid, GravityComponent component, ComponentInit args)
|
||||
{
|
||||
// Incase there's already a generator on the grid we'll just set it now.
|
||||
var gridId = EntityManager.GetComponent<TransformComponent>(component.Owner).GridEntityId;
|
||||
var gridId = Transform(component.Owner).GridUid;
|
||||
|
||||
if (gridId == null)
|
||||
return;
|
||||
|
||||
GravityChangedMessage message;
|
||||
|
||||
foreach (var generator in EntityManager.EntityQuery<GravityGeneratorComponent>())
|
||||
{
|
||||
if (EntityManager.GetComponent<TransformComponent>(generator.Owner).GridEntityId == gridId && generator.GravityActive)
|
||||
if (Transform(generator.Owner).GridUid == gridId && generator.GravityActive)
|
||||
{
|
||||
component.Enabled = true;
|
||||
message = new GravityChangedMessage(gridId, true);
|
||||
message = new GravityChangedMessage(gridId.Value, true);
|
||||
RaiseLocalEvent(message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
component.Enabled = false;
|
||||
message = new GravityChangedMessage(gridId, false);
|
||||
message = new GravityChangedMessage(gridId.Value, false);
|
||||
RaiseLocalEvent(message);
|
||||
}
|
||||
|
||||
@@ -43,10 +47,13 @@ namespace Content.Server.Gravity.EntitySystems
|
||||
public void EnableGravity(GravityComponent comp)
|
||||
{
|
||||
if (comp.Enabled) return;
|
||||
comp.Enabled = true;
|
||||
|
||||
var gridId = EntityManager.GetComponent<TransformComponent>(comp.Owner).GridEntityId;
|
||||
var message = new GravityChangedMessage(gridId, true);
|
||||
var gridId = Transform(comp.Owner).GridUid;
|
||||
if (gridId == null)
|
||||
return;
|
||||
|
||||
comp.Enabled = true;
|
||||
var message = new GravityChangedMessage(gridId.Value, true);
|
||||
RaiseLocalEvent(message);
|
||||
}
|
||||
|
||||
@@ -55,8 +62,11 @@ namespace Content.Server.Gravity.EntitySystems
|
||||
if (!comp.Enabled) return;
|
||||
comp.Enabled = false;
|
||||
|
||||
var gridId = EntityManager.GetComponent<TransformComponent>(comp.Owner).GridEntityId;
|
||||
var message = new GravityChangedMessage(gridId, false);
|
||||
var gridId = Transform(comp.Owner).GridUid;
|
||||
if (gridId == null)
|
||||
return;
|
||||
|
||||
var message = new GravityChangedMessage(gridId.Value, false);
|
||||
RaiseLocalEvent(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,11 +34,11 @@ namespace Content.Server.Gravity.EntitySystems
|
||||
public void AddAlert(AlertsComponent status)
|
||||
{
|
||||
var xform = Transform(status.Owner);
|
||||
var alerts = _alerts.GetOrNew(xform.GridEntityId);
|
||||
var alerts = _alerts.GetOrNew(xform.GridID);
|
||||
|
||||
alerts.Add(status);
|
||||
|
||||
if (_mapManager.TryGetGrid(xform.GridEntityId, out var grid))
|
||||
if (_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
{
|
||||
if (EntityManager.GetComponent<GravityComponent>(grid.GridEntityId).Enabled)
|
||||
{
|
||||
@@ -53,7 +53,7 @@ namespace Content.Server.Gravity.EntitySystems
|
||||
|
||||
public void RemoveAlert(AlertsComponent status)
|
||||
{
|
||||
var grid = EntityManager.GetComponent<TransformComponent>(status.Owner).GridEntityId;
|
||||
var grid = EntityManager.GetComponent<TransformComponent>(status.Owner).GridID;
|
||||
if (!_alerts.TryGetValue(grid, out var statuses))
|
||||
{
|
||||
return;
|
||||
@@ -109,7 +109,10 @@ namespace Content.Server.Gravity.EntitySystems
|
||||
}
|
||||
}
|
||||
|
||||
var newGrid = ev.Transform.GridEntityId;
|
||||
if (ev.Transform.MapID == MapId.Nullspace)
|
||||
return;
|
||||
|
||||
var newGrid = ev.Transform.GridID;
|
||||
var newStatuses = _alerts.GetOrNew(newGrid);
|
||||
|
||||
newStatuses.Add(status);
|
||||
|
||||
@@ -47,9 +47,13 @@ namespace Content.Server.Interaction
|
||||
}
|
||||
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
var playerGrid = _entities.GetComponent<TransformComponent>(attached).GridEntityId;
|
||||
var mapGrid = mapManager.GetGrid(playerGrid);
|
||||
var playerPosition = _entities.GetComponent<TransformComponent>(attached).Coordinates;
|
||||
var xform = _entities.GetComponent<TransformComponent>(attached);
|
||||
var playerGrid = xform.GridUid;
|
||||
|
||||
if (!mapManager.TryGetGrid(playerGrid, out var mapGrid))
|
||||
return;
|
||||
|
||||
var playerPosition = xform.Coordinates;
|
||||
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
|
||||
|
||||
for (var i = -radius; i <= radius; i++)
|
||||
|
||||
@@ -44,7 +44,7 @@ public sealed class SpreaderSystem : EntitySystem
|
||||
if (!EntityManager.TryGetComponent<TransformComponent>(blocker, out var transform))
|
||||
return; // how did we get here?
|
||||
|
||||
if (!_mapManager.TryGetGrid(transform.GridEntityId, out var grid)) return;
|
||||
if (!_mapManager.TryGetGrid(transform.GridUid, out var grid)) return;
|
||||
|
||||
for (var i = 0; i < Atmospherics.Directions; i++)
|
||||
{
|
||||
@@ -89,7 +89,7 @@ public sealed class SpreaderSystem : EntitySystem
|
||||
|
||||
if (spreader.Enabled == false) return false;
|
||||
|
||||
if (!_mapManager.TryGetGrid(transform.GridEntityId, out var grid)) return false;
|
||||
if (!_mapManager.TryGetGrid(transform.GridUid, out var grid)) return false;
|
||||
|
||||
var didGrow = false;
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace Content.Server.Medical.CrewMonitoring
|
||||
// should work well enough?
|
||||
if (TryComp(uid, out IMoverComponent? mover))
|
||||
worldRot = mover.LastGridAngle;
|
||||
else if (_mapManager.TryGetGrid(xform.GridEntityId, out var grid))
|
||||
else if (_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
worldRot = grid.WorldRotation;
|
||||
|
||||
// update all sensors info
|
||||
|
||||
@@ -90,7 +90,7 @@ public sealed class MindSystem : EntitySystem
|
||||
return;
|
||||
|
||||
// Async this so that we don't throw if the grid we're on is being deleted.
|
||||
var gridId = spawnPosition.GetGridEntityId(EntityManager);
|
||||
var gridId = spawnPosition.GetGridUid(EntityManager);
|
||||
if (!spawnPosition.IsValid(EntityManager) || gridId == EntityUid.Invalid || !_mapManager.GridExists(gridId))
|
||||
{
|
||||
spawnPosition = _gameTicker.GetObserverSpawnPoint();
|
||||
|
||||
@@ -286,7 +286,7 @@ namespace Content.Server.NodeContainer.EntitySystems
|
||||
private BaseNodeGroup InitGroup(Node node, List<Node> groupNodes)
|
||||
{
|
||||
var newGroup = (BaseNodeGroup) _nodeGroupFactory.MakeNodeGroup(node.NodeGroupID);
|
||||
newGroup.Initialize(node);
|
||||
newGroup.Initialize(node, EntityManager);
|
||||
newGroup.NetId = _groupNetIdCounter++;
|
||||
|
||||
var netIdCounter = 0;
|
||||
@@ -335,7 +335,7 @@ namespace Content.Server.NodeContainer.EntitySystems
|
||||
private IEnumerable<Node> GetCompatibleNodes(Node node, EntityQuery<TransformComponent> xformQuery, EntityQuery<NodeContainerComponent> nodeQuery)
|
||||
{
|
||||
var xform = xformQuery.GetComponent(node.Owner);
|
||||
_mapManager.TryGetGrid(xform.GridEntityId, out var grid);
|
||||
_mapManager.TryGetGrid(xform.GridUid, out var grid);
|
||||
|
||||
if (!node.Connectable(EntityManager, xform))
|
||||
yield break;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using Content.Server.NodeContainer.Nodes;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.NodeContainer.NodeGroups
|
||||
{
|
||||
@@ -19,7 +20,7 @@ namespace Content.Server.NodeContainer.NodeGroups
|
||||
|
||||
void Create(NodeGroupID groupId);
|
||||
|
||||
void Initialize(Node sourceNode);
|
||||
void Initialize(Node sourceNode, IEntityManager? entMan = null);
|
||||
|
||||
void RemoveNode(Node node);
|
||||
|
||||
@@ -72,10 +73,14 @@ namespace Content.Server.NodeContainer.NodeGroups
|
||||
GroupId = groupId;
|
||||
}
|
||||
|
||||
public virtual void Initialize(Node sourceNode)
|
||||
public virtual void Initialize(Node sourceNode, IEntityManager? entMan = null)
|
||||
{
|
||||
// TODO: Can we get rid of this GridId?
|
||||
GridId = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(sourceNode.Owner).GridEntityId;
|
||||
IoCManager.Resolve(ref entMan);
|
||||
|
||||
var xform = entMan.GetComponent<TransformComponent>(sourceNode.Owner);
|
||||
DebugTools.AssertNotNull(xform.GridUid);
|
||||
GridId = xform.GridUid!.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace Content.Server.NodeContainer.NodeGroups
|
||||
|
||||
public EntityUid Grid => GridId;
|
||||
|
||||
public override void Initialize(Node sourceNode)
|
||||
public override void Initialize(Node sourceNode, IEntityManager? entMan = null)
|
||||
{
|
||||
base.Initialize(sourceNode);
|
||||
base.Initialize(sourceNode, entMan);
|
||||
|
||||
_atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
_atmosphereSystem.AddPipeNet(this);
|
||||
|
||||
@@ -329,7 +329,7 @@ namespace Content.Server.ParticleAccelerator.Components
|
||||
// Find fuel chamber first by scanning cardinals.
|
||||
if (_entMan.GetComponent<TransformComponent>(Owner).Anchored)
|
||||
{
|
||||
var grid = _mapManager.GetGrid(_entMan.GetComponent<TransformComponent>(Owner).GridEntityId);
|
||||
var grid = _mapManager.GetGrid(_entMan.GetComponent<TransformComponent>(Owner).GridUid!.Value);
|
||||
var coords = _entMan.GetComponent<TransformComponent>(Owner).Coordinates;
|
||||
foreach (var maybeFuel in grid.GetCardinalNeighborCells(coords))
|
||||
{
|
||||
@@ -403,8 +403,14 @@ namespace Content.Server.ParticleAccelerator.Components
|
||||
private bool ScanPart<T>(Vector2i offset, [NotNullWhen(true)] out T? part)
|
||||
where T : ParticleAcceleratorPartComponent
|
||||
{
|
||||
var grid = _mapManager.GetGrid(_entMan.GetComponent<TransformComponent>(Owner).GridEntityId);
|
||||
var coords = _entMan.GetComponent<TransformComponent>(Owner).Coordinates;
|
||||
var xform = _entMan.GetComponent<TransformComponent>(Owner);
|
||||
if (!_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
{
|
||||
part = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
var coords = xform.Coordinates;
|
||||
foreach (var ent in grid.GetOffset(coords, offset))
|
||||
{
|
||||
if (_entMan.TryGetComponent(ent, out part) && !part.Deleted)
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Content.Server.Physics.Controllers
|
||||
|
||||
public IEnumerable<(EntityUid, TransformComponent)> GetEntitiesToMove(ConveyorComponent comp, TransformComponent xform)
|
||||
{
|
||||
if (!_mapManager.TryGetGrid(xform.GridEntityId, out var grid) ||
|
||||
if (!_mapManager.TryGetGrid(xform.GridUid, out var grid) ||
|
||||
!grid.TryGetTileRef(xform.Coordinates, out var tile)) yield break;
|
||||
|
||||
var tileAABB = _lookup.GetLocalBounds(tile, grid.TileSize).Enlarged(0.01f);
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Content.Server.Physics.Controllers
|
||||
if (pilot.Console == null) continue;
|
||||
_excludedMobs.Add(mover.Owner);
|
||||
|
||||
var gridId = xform.GridEntityId;
|
||||
var gridId = xform.GridUid;
|
||||
// This tries to see if the grid is a shuttle
|
||||
if (!_mapManager.TryGetGrid(gridId, out var grid) ||
|
||||
!EntityManager.TryGetComponent(grid.GridEntityId, out ShuttleComponent? shuttleComponent)) continue;
|
||||
|
||||
@@ -19,7 +19,7 @@ public sealed partial class CableSystem
|
||||
|
||||
if (component.CablePrototypeId == null) return;
|
||||
|
||||
if(!_mapManager.TryGetGrid(args.ClickLocation.GetGridEntityId(EntityManager), out var grid))
|
||||
if(!_mapManager.TryGetGrid(args.ClickLocation.GetGridUid(EntityManager), out var grid))
|
||||
return;
|
||||
|
||||
var snapPos = grid.TileIndicesFor(args.ClickLocation);
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Content.Server.Power.EntitySystems
|
||||
return;
|
||||
|
||||
var transform = Transform(uid);
|
||||
if (!_mapManager.TryGetGrid(transform.GridEntityId, out var grid))
|
||||
if (!_mapManager.TryGetGrid(transform.GridUid, out var grid))
|
||||
return;
|
||||
|
||||
var mask = WireVisDirFlags.None;
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Content.Server.Power.EntitySystems
|
||||
var xform = Transform(uid);
|
||||
|
||||
// If grid deleting no need to update power.
|
||||
if (_mapManager.TryGetGrid(xform.GridEntityId, out var grid))
|
||||
if (_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
{
|
||||
if (MetaData(grid.GridEntityId).EntityLifeStage > EntityLifeStage.MapInitialized) return;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ namespace Content.Server.Power.EntitySystems
|
||||
var xform = Transform(owner);
|
||||
var coordinates = xform.Coordinates;
|
||||
|
||||
if (!_mapManager.TryGetGrid(xform.GridEntityId, out var grid))
|
||||
if (!_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
yield break;
|
||||
|
||||
var nearbyEntities = grid.GetCellsInSquareArea(coordinates, (int) Math.Ceiling(range / grid.TileSize));
|
||||
@@ -238,7 +238,7 @@ namespace Content.Server.Power.EntitySystems
|
||||
|
||||
private bool TryFindAvailableProvider(EntityUid owner, float range, [NotNullWhen(true)] out ExtensionCableProviderComponent? foundProvider, TransformComponent? xform = null)
|
||||
{
|
||||
if (!Resolve(owner, ref xform) || !_mapManager.TryGetGrid(xform.GridEntityId, out var grid))
|
||||
if (!Resolve(owner, ref xform) || !_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
{
|
||||
foundProvider = null;
|
||||
return false;
|
||||
|
||||
@@ -46,9 +46,9 @@ namespace Content.Server.Power.NodeGroups
|
||||
[ViewVariables]
|
||||
public PowerState.Network NetworkNode { get; } = new();
|
||||
|
||||
public override void Initialize(Node sourceNode)
|
||||
public override void Initialize(Node sourceNode, IEntityManager? entMan = null)
|
||||
{
|
||||
base.Initialize(sourceNode);
|
||||
base.Initialize(sourceNode, entMan);
|
||||
|
||||
_powerNetSystem.InitApcNet(this);
|
||||
}
|
||||
|
||||
@@ -37,9 +37,9 @@ namespace Content.Server.Power.NodeGroups
|
||||
[ViewVariables]
|
||||
public PowerState.Network NetworkNode { get; } = new();
|
||||
|
||||
public override void Initialize(Node sourceNode)
|
||||
public override void Initialize(Node sourceNode, IEntityManager? entMan = null)
|
||||
{
|
||||
base.Initialize(sourceNode);
|
||||
base.Initialize(sourceNode, entMan);
|
||||
|
||||
_powerNetSystem.InitPowerNet(this);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Content.Server.Shuttles.Systems
|
||||
|
||||
// Assume the docking port itself (and its body) is valid
|
||||
|
||||
if (!_mapManager.TryGetGrid(dockingXform.GridEntityId, out var grid) ||
|
||||
if (!_mapManager.TryGetGrid(dockingXform.GridUid, out var grid) ||
|
||||
!HasComp<ShuttleComponent>(grid.GridEntityId)) return null;
|
||||
|
||||
var transform = body.GetTransform();
|
||||
@@ -93,7 +93,7 @@ namespace Content.Server.Shuttles.Systems
|
||||
|
||||
while (enumerator.MoveNext(out var otherGrid))
|
||||
{
|
||||
if (otherGrid.GridEntityId == dockingXform.GridEntityId) continue;
|
||||
if (otherGrid.GridEntityId == dockingXform.GridUid) continue;
|
||||
|
||||
foreach (var ent in otherGrid.GetAnchoredEntities(enlargedAABB))
|
||||
{
|
||||
@@ -164,16 +164,18 @@ namespace Content.Server.Shuttles.Systems
|
||||
dockA.DockJoint = null;
|
||||
dockA.DockedWith = null;
|
||||
|
||||
// If these grids are ever invalid then need to look at fixing ordering for unanchored events elsewhere.
|
||||
var gridAUid = _mapManager.GetGrid(EntityManager.GetComponent<TransformComponent>(dockA.Owner).GridEntityId).GridEntityId;
|
||||
var gridBUid = _mapManager.GetGrid(EntityManager.GetComponent<TransformComponent>(dockB.Owner).GridEntityId).GridEntityId;
|
||||
// If these grids are ever null then need to look at fixing ordering for unanchored events elsewhere.
|
||||
var gridAUid = EntityManager.GetComponent<TransformComponent>(dockA.Owner).GridUid;
|
||||
var gridBUid = EntityManager.GetComponent<TransformComponent>(dockB.Owner).GridUid;
|
||||
DebugTools.Assert(gridAUid != null);
|
||||
DebugTools.Assert(gridBUid != null);
|
||||
|
||||
var msg = new UndockEvent
|
||||
{
|
||||
DockA = dockA,
|
||||
DockB = dockB,
|
||||
GridAUid = gridAUid,
|
||||
GridBUid = gridBUid,
|
||||
GridAUid = gridAUid!.Value,
|
||||
GridBUid = gridBUid!.Value,
|
||||
};
|
||||
|
||||
EntityManager.EventBus.RaiseLocalEvent(dockA.Owner, msg, false);
|
||||
@@ -305,8 +307,10 @@ namespace Content.Server.Shuttles.Systems
|
||||
var dockAXform = EntityManager.GetComponent<TransformComponent>(dockA.Owner);
|
||||
var dockBXform = EntityManager.GetComponent<TransformComponent>(dockB.Owner);
|
||||
|
||||
var gridA = _mapManager.GetGrid(dockAXform.GridEntityId).GridEntityId;
|
||||
var gridB = _mapManager.GetGrid(dockBXform.GridEntityId).GridEntityId;
|
||||
DebugTools.Assert(dockAXform.GridUid != null);
|
||||
DebugTools.Assert(dockBXform.GridUid != null);
|
||||
var gridA = dockAXform.GridUid!.Value;
|
||||
var gridB = dockBXform.GridUid!.Value;
|
||||
|
||||
SharedJointSystem.LinearStiffness(
|
||||
2f,
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace Content.Server.Shuttles.Systems
|
||||
pilot.Console is not ShuttleConsoleComponent console) return;
|
||||
|
||||
if (!console.SubscribedPilots.Contains(pilot) ||
|
||||
!TryComp<ShuttleComponent>(xform.GridEntityId, out var shuttle)) return;
|
||||
!TryComp<ShuttleComponent>(xform.GridUid, out var shuttle)) return;
|
||||
|
||||
SetShuttleMode(args.Mode, console, shuttle);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public sealed class SpaceGarbageSystem : EntitySystem
|
||||
var ourXform = Transform(args.OurFixture.Body.Owner);
|
||||
var otherXform = Transform(args.OtherFixture.Body.Owner);
|
||||
|
||||
if (ourXform.GridEntityId == otherXform.GridEntityId ||
|
||||
if (ourXform.GridUid == otherXform.GridUid ||
|
||||
args.OtherFixture.Body.BodyType != BodyType.Static) return;
|
||||
|
||||
QueueDel(uid);
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace Content.Server.Shuttles.Systems
|
||||
|
||||
if (new Vector2i((int) direction.X, (int) direction.Y) != new Vector2i(x, y)) continue;
|
||||
|
||||
DisableThruster(ent.Value, thruster, xform.GridEntityId);
|
||||
DisableThruster(ent.Value, thruster, xform.GridUid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ namespace Content.Server.Shuttles.Systems
|
||||
if (!component.Enabled ||
|
||||
component.Type != ThrusterType.Linear ||
|
||||
!EntityManager.TryGetComponent(uid, out TransformComponent? xform) ||
|
||||
!_mapManager.TryGetGrid(xform.GridEntityId, out var grid) ||
|
||||
!_mapManager.TryGetGrid(xform.GridUid, out var grid) ||
|
||||
!EntityManager.TryGetComponent(grid.GridEntityId, out ShuttleComponent? shuttleComponent))
|
||||
{
|
||||
return;
|
||||
@@ -243,7 +243,7 @@ namespace Content.Server.Shuttles.Systems
|
||||
{
|
||||
if (component.IsOn ||
|
||||
!Resolve(uid, ref xform) ||
|
||||
!_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) return;
|
||||
!_mapManager.TryGetGrid(xform.GridUid, out var grid)) return;
|
||||
|
||||
component.IsOn = true;
|
||||
|
||||
@@ -304,13 +304,13 @@ namespace Content.Server.Shuttles.Systems
|
||||
public void DisableThruster(EntityUid uid, ThrusterComponent component, TransformComponent? xform = null, Angle? angle = null)
|
||||
{
|
||||
if (!Resolve(uid, ref xform)) return;
|
||||
DisableThruster(uid, component, xform.GridEntityId, xform);
|
||||
DisableThruster(uid, component, xform.GridUid, xform);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to disable the thruster.
|
||||
/// </summary>
|
||||
public void DisableThruster(EntityUid uid, ThrusterComponent component, EntityUid gridId, TransformComponent? xform = null, Angle? angle = null)
|
||||
public void DisableThruster(EntityUid uid, ThrusterComponent component, EntityUid? gridId, TransformComponent? xform = null, Angle? angle = null)
|
||||
{
|
||||
if (!component.IsOn ||
|
||||
!Resolve(uid, ref xform) ||
|
||||
@@ -382,8 +382,11 @@ namespace Content.Server.Shuttles.Systems
|
||||
|
||||
private bool NozzleExposed(TransformComponent xform)
|
||||
{
|
||||
if (xform.GridUid == null)
|
||||
return true;
|
||||
|
||||
var (x, y) = xform.LocalPosition + xform.LocalRotation.Opposite().ToWorldVec();
|
||||
var tile = _mapManager.GetGrid(xform.GridEntityId).GetTileRef(new Vector2i((int) Math.Floor(x), (int) Math.Floor(y)));
|
||||
var tile = _mapManager.GetGrid(xform.GridUid.Value).GetTileRef(new Vector2i((int) Math.Floor(x), (int) Math.Floor(y)));
|
||||
|
||||
return tile.Tile.IsSpace();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Content.Server.Sound
|
||||
private void HandleEmitSoundOnLand(EntityUid eUI, BaseEmitSoundComponent component, LandEvent arg)
|
||||
{
|
||||
if (!TryComp<TransformComponent>(eUI, out var xform) ||
|
||||
!_mapManager.TryGetGrid(xform.GridEntityId, out var grid)) return;
|
||||
!_mapManager.TryGetGrid(xform.GridUid, out var grid)) return;
|
||||
|
||||
var tile = grid.GetTileRef(xform.Coordinates);
|
||||
|
||||
|
||||
@@ -317,13 +317,13 @@ public sealed class StationSystem : EntitySystem
|
||||
return CompOrNull<StationMemberComponent>(entity)?.Station;
|
||||
}
|
||||
|
||||
if (xform.GridEntityId == EntityUid.Invalid)
|
||||
if (xform.GridUid == EntityUid.Invalid)
|
||||
{
|
||||
Logger.Debug("A");
|
||||
return null;
|
||||
}
|
||||
|
||||
return CompOrNull<StationMemberComponent>(xform.GridEntityId)?.Station;
|
||||
return CompOrNull<StationMemberComponent>(xform.GridUid)?.Station;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,18 +114,18 @@ namespace Content.Server.StationEvents.Events
|
||||
if (_timeUntilLeak > 0f) return;
|
||||
_timeUntilLeak += LeakCooldown;
|
||||
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
|
||||
var atmosphereSystem = _entityManager.EntitySysManager.GetEntitySystem<AtmosphereSystem>();
|
||||
|
||||
if (!_foundTile ||
|
||||
_targetGrid == default ||
|
||||
_entityManager.Deleted(_targetGrid) ||
|
||||
!atmosphereSystem.IsSimulatedGrid(_entityManager.GetComponent<TransformComponent>(_targetGrid).GridEntityId))
|
||||
!atmosphereSystem.IsSimulatedGrid(_targetGrid))
|
||||
{
|
||||
Running = false;
|
||||
return;
|
||||
}
|
||||
|
||||
var environment = atmosphereSystem.GetTileMixture(_entityManager.GetComponent<TransformComponent>(_targetGrid).GridEntityId, _targetTile, true);
|
||||
var environment = atmosphereSystem.GetTileMixture(_targetGrid, _targetTile, true);
|
||||
|
||||
environment?.AdjustMoles(_leakGas, LeakCooldown * _molesPerSecond);
|
||||
}
|
||||
@@ -152,14 +152,14 @@ namespace Content.Server.StationEvents.Events
|
||||
if (!_foundTile ||
|
||||
_targetGrid == default ||
|
||||
(!_entityManager.EntityExists(_targetGrid) ? EntityLifeStage.Deleted : _entityManager.GetComponent<MetaDataComponent>(_targetGrid).EntityLifeStage) >= EntityLifeStage.Deleted ||
|
||||
!atmosphereSystem.IsSimulatedGrid(_entityManager.GetComponent<TransformComponent>(_targetGrid).GridEntityId))
|
||||
!atmosphereSystem.IsSimulatedGrid(_targetGrid))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't want it to be so obnoxious as to instantly murder anyone in the area but enough that
|
||||
// it COULD start potentially start a bigger fire.
|
||||
atmosphereSystem.HotspotExpose(_entityManager.GetComponent<TransformComponent>(_targetGrid).GridID, _targetTile, 700f, 50f, true);
|
||||
atmosphereSystem.HotspotExpose(_targetGrid, _targetTile, 700f, 50f, true);
|
||||
SoundSystem.Play("/Audio/Effects/sparks4.ogg", Filter.Pvs(_targetCoords), _targetCoords);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public sealed class SubFloorHideSystem : SharedSubFloorHideSystem
|
||||
// No teleporting entities through floor tiles when anchoring them.
|
||||
var xform = Transform(uid);
|
||||
|
||||
if (MapManager.TryGetGrid(xform.GridEntityId, out var grid)
|
||||
if (MapManager.TryGetGrid(xform.GridUid, out var grid)
|
||||
&& HasFloorCover(grid, grid.TileIndicesFor(xform.Coordinates)))
|
||||
{
|
||||
args.Cancel();
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Shared.Interaction;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Tools;
|
||||
|
||||
@@ -26,7 +27,14 @@ public sealed partial class ToolSystem
|
||||
private void OnTilePryComplete(EntityUid uid, TilePryingComponent component, TilePryingCompleteEvent args)
|
||||
{
|
||||
component.CancelToken = null;
|
||||
args.Coordinates.PryTile(EntityManager, _mapManager);
|
||||
var gridUid = args.Coordinates.GetGridUid(EntityManager);
|
||||
if (!_mapManager.TryGetGrid(gridUid, out var grid))
|
||||
{
|
||||
Logger.Error("Attempted to pry from a non-existent grid?");
|
||||
return;
|
||||
}
|
||||
|
||||
grid.GetTileRef(args.Coordinates).PryTile(_mapManager, _tileDefinitionManager, EntityManager);
|
||||
}
|
||||
|
||||
private void OnTilePryingAfterInteract(EntityUid uid, TilePryingComponent component, AfterInteractEvent args)
|
||||
@@ -47,7 +55,7 @@ public sealed partial class ToolSystem
|
||||
if (!TryComp<ToolComponent?>(component.Owner, out var tool) && component.ToolComponentNeeded)
|
||||
return false;
|
||||
|
||||
if (!_mapManager.TryGetGrid(clickLocation.GetGridEntityId(EntityManager), out var mapGrid))
|
||||
if (!_mapManager.TryGetGrid(clickLocation.GetGridUid(EntityManager), out var mapGrid))
|
||||
return false;
|
||||
|
||||
var tile = mapGrid.GetTileRef(clickLocation);
|
||||
|
||||
@@ -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.GridEntityId, out var grid))
|
||||
!_mapManager.TryGetGrid(xform.GridUid, out var grid))
|
||||
return 0.0f;
|
||||
|
||||
if (!coords.IsValid(EntityManager)) return 0.0f;
|
||||
|
||||
@@ -14,9 +14,6 @@ namespace Content.Shared.Maps
|
||||
/// </summary>
|
||||
public static TileRef GetTileRef(this Vector2i vector2i, EntityUid gridId, IMapManager? mapManager = null)
|
||||
{
|
||||
if (!gridId.IsValid())
|
||||
return default;
|
||||
|
||||
mapManager ??= IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (!mapManager.TryGetGrid(gridId, out var grid))
|
||||
@@ -41,7 +38,7 @@ namespace Content.Shared.Maps
|
||||
|
||||
mapManager ??= IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (!mapManager.TryGetGrid(coordinates.GetGridEntityId(entityManager), out var grid))
|
||||
if (!mapManager.TryGetGrid(coordinates.GetGridUid(entityManager), out var grid))
|
||||
return null;
|
||||
|
||||
|
||||
@@ -89,15 +86,6 @@ namespace Content.Shared.Maps
|
||||
return tile.Tile.IsSpace(tileDefinitionManager);
|
||||
}
|
||||
|
||||
public static bool PryTile(this EntityCoordinates coordinates, IEntityManager? entityManager = null,
|
||||
IMapManager? mapManager = null)
|
||||
{
|
||||
entityManager ??= IoCManager.Resolve<IEntityManager>();
|
||||
mapManager ??= IoCManager.Resolve<IMapManager>();
|
||||
|
||||
return coordinates.ToVector2i(entityManager, mapManager).PryTile(coordinates.GetGridEntityId(entityManager));
|
||||
}
|
||||
|
||||
public static bool PryTile(this Vector2i indices, EntityUid gridId,
|
||||
IMapManager? mapManager = null, ITileDefinitionManager? tileDefinitionManager = null, IEntityManager? entityManager = null)
|
||||
{
|
||||
|
||||
@@ -45,9 +45,9 @@ namespace Content.Shared.Movement.Components
|
||||
return ignoreGravityComponent.Weightless;
|
||||
|
||||
var transform = entityManager.GetComponent<TransformComponent>(entity);
|
||||
var gridId = transform.GridEntityId;
|
||||
var gridId = transform.GridUid;
|
||||
|
||||
if (!gridId.IsValid())
|
||||
if (gridId == null)
|
||||
{
|
||||
// Not on a grid = no gravity for now.
|
||||
// In the future, may want to allow maps to override to always have gravity instead.
|
||||
@@ -55,7 +55,7 @@ namespace Content.Shared.Movement.Components
|
||||
}
|
||||
|
||||
mapManager ??= IoCManager.Resolve<IMapManager>();
|
||||
var grid = mapManager.GetGrid(gridId);
|
||||
var grid = mapManager.GetGrid(gridId.Value);
|
||||
var invSys = EntitySystem.Get<InventorySystem>();
|
||||
|
||||
if (invSys.TryGetSlotEntity(entity, "shoes", out var ent))
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Content.Shared.Movement
|
||||
|
||||
protected Angle GetParentGridAngle(TransformComponent xform, IMoverComponent mover)
|
||||
{
|
||||
if (xform.GridEntityId == EntityUid.Invalid || !_mapManager.TryGetGrid(xform.GridEntityId, out var grid))
|
||||
if (!_mapManager.TryGetGrid(xform.GridUid, 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.GridEntityId != EntityUid.Invalid)
|
||||
if (transform.GridUid != null)
|
||||
mover.LastGridAngle = parentRotation;
|
||||
|
||||
if (worldTotal != Vector2.Zero)
|
||||
transform.LocalRotation = transform.GridEntityId != EntityUid.Invalid
|
||||
transform.LocalRotation = transform.GridUid != null
|
||||
? total.ToWorldAngle()
|
||||
: worldTotal.ToWorldAngle();
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace Content.Shared.Movement
|
||||
|
||||
if (!touching)
|
||||
{
|
||||
if (xform.GridEntityId != EntityUid.Invalid)
|
||||
if (xform.GridUid != 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.GridEntityId != EntityUid.Invalid)
|
||||
if (xform.GridUid != 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.GridEntityId != EntityUid.Invalid
|
||||
xform.LocalRotation = xform.GridUid != EntityUid.Invalid
|
||||
? total.ToWorldAngle()
|
||||
: worldTotal.ToWorldAngle();
|
||||
xform.DeferUpdates = false;
|
||||
@@ -229,7 +229,7 @@ namespace Content.Shared.Movement
|
||||
if (!CanSound() || !_tags.HasTag(mover.Owner, "FootstepSound")) return false;
|
||||
|
||||
var coordinates = xform.Coordinates;
|
||||
var gridId = coordinates.GetGridEntityId(EntityManager);
|
||||
var gridId = coordinates.GetGridUid(EntityManager);
|
||||
var distanceNeeded = mover.Sprinting ? StepSoundMoveDistanceRunning : StepSoundMoveDistanceWalking;
|
||||
|
||||
// Handle footsteps.
|
||||
@@ -252,7 +252,7 @@ namespace Content.Shared.Movement
|
||||
return false;
|
||||
}
|
||||
|
||||
DebugTools.Assert(gridId != EntityUid.Invalid);
|
||||
DebugTools.Assert(gridId != null);
|
||||
mobMover.LastPosition = coordinates;
|
||||
|
||||
if (mobMover.StepSoundDistance < distanceNeeded) return false;
|
||||
@@ -267,7 +267,7 @@ namespace Content.Shared.Movement
|
||||
return true;
|
||||
}
|
||||
|
||||
return TryGetFootstepSound(gridId, coordinates, out variation, out sound);
|
||||
return TryGetFootstepSound(gridId!.Value, coordinates, out variation, out sound);
|
||||
}
|
||||
|
||||
private bool TryGetFootstepSound(EntityUid gridId, EntityCoordinates coordinates, out float variation, [NotNullWhen(true)] out string? sound)
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Content.Shared.SubFloor
|
||||
if (!Resolve(uid, ref component, ref xform))
|
||||
return;
|
||||
|
||||
if (xform.Anchored && MapManager.TryGetGrid(xform.GridEntityId, out var grid))
|
||||
if (xform.Anchored && MapManager.TryGetGrid(xform.GridUid, 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.GridEntityId, out var grid))
|
||||
if (_mapManager.TryGetGrid(transform.GridUid, out var grid))
|
||||
{
|
||||
foreach (var entity in grid.GetAnchoredEntities(worldBox))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user