Fix MapCoordinate spawns using grid-relative rotation

This was an undocumented breaking change introduced by https://github.com/space-wizards/RobustToolbox/pull/5915. The behavior does not make much sense: you're specifying coordinates relative to the map, so the rotation should be relative to the map too.
This commit is contained in:
PJB3005
2026-01-26 19:20:12 +01:00
parent 0b93a1b7e2
commit 3bec89aaa5
3 changed files with 4 additions and 3 deletions

View File

@@ -35,7 +35,7 @@ END TEMPLATE-->
### Breaking changes
*None yet*
* Reversed an undocumented breaking change from `v267.3.0`: entity spawning with a `MapCoordinates` now takes the rotation as relative to the map again instead of relative to the grid the entity was attached to.
### New features

View File

@@ -366,7 +366,8 @@ namespace Robust.Shared.GameObjects
&& meta.EntityLifeStage < EntityLifeStage.Terminating)
{
coords = new EntityCoordinates(gridUid, _mapSystem.WorldToLocal(gridUid, grid, coordinates.Position));
_xforms.SetCoordinates(newEntity, transform, coords, rotation, unanchor: false);
var relativeRotation = rotation - _xforms.GetWorldRotation(gridUid);
_xforms.SetCoordinates(newEntity, transform, coords, relativeRotation, unanchor: false);
}
else
{

View File

@@ -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">Local rotation to set the newly spawned entity to.</param>
/// <param name="rotation">World 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>