diff --git a/Robust.Shared/GameObjects/EntityManager.cs b/Robust.Shared/GameObjects/EntityManager.cs index 6aa976d10b9..7f7af060e15 100644 --- a/Robust.Shared/GameObjects/EntityManager.cs +++ b/Robust.Shared/GameObjects/EntityManager.cs @@ -335,7 +335,7 @@ public virtual EntityUid CreateEntityUninitialized(string? prototypeName, MapCoo if (coordinates.MapId == MapId.Nullspace) { transform._parent = EntityUid.Invalid; - transform.Anchored = false; + _xforms.Unanchor(newEntity); return newEntity; } @@ -886,7 +886,7 @@ private protected void LoadEntity(EntityUid entity, IEntityLoadContext? context, public void InitializeAndStartEntity(EntityUid entity, MapId? mapId = null) { - var doMapInit = _mapManager.IsMapInitialized(mapId ?? TransformQuery.GetComponent(entity).MapID); + var doMapInit = _mapSystem.IsInitialized(mapId ?? TransformQuery.GetComponent(entity).MapID); InitializeAndStartEntity(entity, doMapInit); } diff --git a/Robust.Shared/GameObjects/Systems/SharedTransformSystem.Component.cs b/Robust.Shared/GameObjects/Systems/SharedTransformSystem.Component.cs index 1323c693edd..32e2ce84db8 100644 --- a/Robust.Shared/GameObjects/Systems/SharedTransformSystem.Component.cs +++ b/Robust.Shared/GameObjects/Systems/SharedTransformSystem.Component.cs @@ -124,8 +124,13 @@ public bool AnchorEntity(Entity entity, Entity((e, _, _) => Transform(e).Anchored = true); + SubscribeLocalEvent((e, _, _) => + EntityManager.EntitySysManager.GetEntitySystem().AnchorEntity(e)); } } @@ -198,7 +199,7 @@ public void OnAnchored_Parent_SetToGrid() // Act sim.System().ResetCounters(); - sim.Transform(ent1).Anchored = true; + xformSys.AnchorEntity(ent1); Assert.That(sim.Transform(ent1).ParentUid, Is.EqualTo(grid.Owner)); sim.System().AssertMoved(); traversal.Enabled = true; @@ -237,7 +238,7 @@ public void OnAnchored_NonEmptyTile_Anchors() mapSys.SetTile(grid, tileIndices, new Tile(1)); // Act - sim.Transform(ent1).Anchored = true; + xformSys.AnchorEntity(ent1); Assert.That(mapSys.GetAnchoredEntities(grid, tileIndices).First(), Is.EqualTo(ent1)); Assert.That(mapSys.GetTileRef(grid, tileIndices).Tile, Is.Not.EqualTo(Tile.Empty)); @@ -263,12 +264,12 @@ public void Anchored_SetPosition_Nop() mapSys.SetTile(grid, mapSys.TileIndicesFor(grid, coordinates), new Tile(1)); var ent1 = sim.SpawnEntity(null, coordinates); // this raises MoveEvent, subscribe after - sim.Transform(ent1).Anchored = true; + xformSys.AnchorEntity(ent1); sim.System().FailOnMove = true; // Act sim.Transform(ent1).WorldPosition = new Vector2(99, 99); - sim.Transform(ent1).LocalPosition = new Vector2(99, 99); + xformSys.SetLocalPosition(ent1, new Vector2(99, 99)); Assert.That(xformSys.GetMapCoordinates(ent1), Is.EqualTo(coordinates)); sim.System().FailOnMove = false; @@ -309,7 +310,7 @@ public void Anchored_SetParentSame_Nop() var ent1 = entMan.SpawnEntity(null, coords); var tileIndices = mapSys.TileIndicesFor(grid, sim.Transform(ent1).Coordinates); mapSys.SetTile(grid, tileIndices, new Tile(1)); - sim.Transform(ent1).Anchored = true; + xformSys.AnchorEntity(ent1); // Act xformSys.SetParent(ent1, grid.Owner); @@ -428,7 +429,7 @@ public void OnUnanchored_HasPhysicsComp_IsDynamicBody() var tileIndices = mapSys.TileIndicesFor(grid, sim.Transform(ent1).Coordinates); mapSys.SetTile(grid, tileIndices, new Tile(1)); var physComp = entMan.AddComponent(ent1); - sim.Transform(ent1).Anchored = true; + xformSys.AnchorEntity(ent1); // Act xformSys.Unanchor(ent1);