Nullable grid Uid (#8798)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user