mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Always align newly created entities with the grid (#5915)
* align spawns with grids * :godmode: * Fix comment * fix * release notes
This commit is contained in:
@@ -46,6 +46,7 @@ END TEMPLATE-->
|
||||
### Bugfixes
|
||||
|
||||
* Fixed yaml hot reloading throwing invalid path exceptions.
|
||||
* The `EntityManager.CreateEntityUninitialized` overload that uses MapCoordinates now actually attaches entities to a grid if one is present at those coordinates, as was stated in it's documentation.
|
||||
|
||||
### Other
|
||||
|
||||
|
||||
@@ -352,7 +352,9 @@ namespace Robust.Shared.GameObjects
|
||||
throw new ArgumentException($"Attempted to spawn entity on an invalid map. Coordinates: {coordinates}");
|
||||
|
||||
EntityCoordinates coords;
|
||||
if (transform.Anchored && _mapManager.TryFindGridAt(coordinates, out var gridUid, out var grid))
|
||||
if (_mapManager.TryFindGridAt(coordinates, out var gridUid, out var grid)
|
||||
&& MetaQuery.TryGetComponentInternal(gridUid, out var meta)
|
||||
&& meta.EntityLifeStage < EntityLifeStage.Terminating)
|
||||
{
|
||||
coords = new EntityCoordinates(gridUid, _mapSystem.WorldToLocal(gridUid, grid, coordinates.Position));
|
||||
_xforms.SetCoordinates(newEntity, transform, coords, rotation, unanchor: false);
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <param name="prototypeName">Name of the <see cref="EntityPrototype"/> to spawn.</param>
|
||||
/// <param name="coordinates">Coordinates to place the newly spawned entity.</param>
|
||||
/// <param name="overrides">Overrides to add or remove components that differ from the prototype.</param>
|
||||
/// <param name="rotation">Map rotation to set the newly spawned entity to.</param>
|
||||
/// <param name="rotation">Local rotation to set the newly spawned entity to.</param>
|
||||
/// <returns>A new uninitialized entity.</returns>
|
||||
/// <remarks>If there is a grid at the <paramref name="coordinates"/>, the entity will be parented to the grid.
|
||||
/// Otherwise, it will be parented to the map.</remarks>
|
||||
|
||||
@@ -196,10 +196,8 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
var ent1 = sim.SpawnEntity(null, coordinates); // this raises MoveEvent, subscribe after
|
||||
|
||||
// Act
|
||||
sim.System<MoveEventTestSystem>().ResetCounters();
|
||||
sim.Transform(ent1).Anchored = true;
|
||||
xformSys.AnchorEntity(ent1);
|
||||
Assert.That(sim.Transform(ent1).ParentUid, Is.EqualTo(grid.Owner));
|
||||
sim.System<MoveEventTestSystem>().AssertMoved();
|
||||
traversal.Enabled = true;
|
||||
}
|
||||
|
||||
@@ -497,7 +495,7 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
// Act
|
||||
sim.System<MoveEventTestSystem>().FailOnMove = true;
|
||||
xformSys.Unanchor(ent1);
|
||||
Assert.That(sim.Transform(ent1).ParentUid, Is.EqualTo(mapSys.GetMap(coordinates.MapId)));
|
||||
Assert.That(sim.Transform(ent1).ParentUid, Is.EqualTo(grid.Owner));
|
||||
sim.System<MoveEventTestSystem>().FailOnMove = false;
|
||||
traversal.Enabled = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user