Nullable grid Uid (#8798)
This commit is contained in:
@@ -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