diff --git a/Robust.Server/Placement/PlacementManager.cs b/Robust.Server/Placement/PlacementManager.cs index 85e9e709d36..53c837ccbde 100644 --- a/Robust.Server/Placement/PlacementManager.cs +++ b/Robust.Server/Placement/PlacementManager.cs @@ -172,7 +172,7 @@ public void HandlePlacementRequest(MsgPlacement msg) } } - var created = _entityManager.Spawn(entityTemplateName, _xformSystem.ToMapCoordinates(coordinates), rotation: dirRcv.ToAngle()); + var created = _entityManager.SpawnAttachedTo(entityTemplateName, coordinates, rotation: dirRcv.ToAngle()); var placementCreateEvent = new PlacementEntityEvent(created, coordinates, PlacementEventAction.Create, msg.MsgChannel.UserId); _entityManager.EventBus.RaiseEvent(EventSource.Local, placementCreateEvent); diff --git a/Robust.Shared/GameObjects/EntityManager.Spawn.cs b/Robust.Shared/GameObjects/EntityManager.Spawn.cs index ca96a731661..2739308fa9a 100644 --- a/Robust.Shared/GameObjects/EntityManager.Spawn.cs +++ b/Robust.Shared/GameObjects/EntityManager.Spawn.cs @@ -73,12 +73,12 @@ public EntityUid[] SpawnEntities(MapCoordinates coordinates, List proto return ents; } - public virtual EntityUid SpawnAttachedTo(string? protoName, EntityCoordinates coordinates, ComponentRegistry? overrides = null) + public virtual EntityUid SpawnAttachedTo(string? protoName, EntityCoordinates coordinates, ComponentRegistry? overrides = null, Angle rotation = default) { if (!coordinates.IsValid(this)) throw new InvalidOperationException($"Tried to spawn entity {protoName} on invalid coordinates {coordinates}."); - var entity = CreateEntityUninitialized(protoName, coordinates, overrides); + var entity = CreateEntityUninitialized(protoName, coordinates, overrides, rotation); InitializeAndStartEntity(entity, coordinates.GetMapId(this)); return entity; } diff --git a/Robust.Shared/GameObjects/EntityManager.cs b/Robust.Shared/GameObjects/EntityManager.cs index 503c22f6400..3775bec5e59 100644 --- a/Robust.Shared/GameObjects/EntityManager.cs +++ b/Robust.Shared/GameObjects/EntityManager.cs @@ -296,10 +296,13 @@ public virtual EntityUid CreateEntityUninitialized(string? prototypeName, Compon } /// - public virtual EntityUid CreateEntityUninitialized(string? prototypeName, EntityCoordinates coordinates, ComponentRegistry? overrides = null) + public virtual EntityUid CreateEntityUninitialized(string? prototypeName, EntityCoordinates coordinates, ComponentRegistry? overrides = null, Angle rotation = default) { var newEntity = CreateEntity(prototypeName, out _, overrides); - _xforms.SetCoordinates(newEntity, TransformQuery.GetComponent(newEntity), coordinates, unanchor: false); + + var xformComp = TransformQuery.GetComponent(newEntity); + var newRotation = rotation; + _xforms.SetCoordinates(newEntity, xformComp, coordinates, rotation: newRotation, unanchor: false); return newEntity; } diff --git a/Robust.Shared/GameObjects/IEntityManager.Spawn.cs b/Robust.Shared/GameObjects/IEntityManager.Spawn.cs index 29f744366a4..809a24962b0 100644 --- a/Robust.Shared/GameObjects/IEntityManager.Spawn.cs +++ b/Robust.Shared/GameObjects/IEntityManager.Spawn.cs @@ -38,7 +38,7 @@ EntityUid[] SpawnEntities(EntityCoordinates coordinates, List protoName /// /// Spawns an entity and then parents it to the entity that the given entity coordinates are relative to. /// - EntityUid SpawnAttachedTo(string? protoName, EntityCoordinates coordinates, ComponentRegistry? overrides = null); + EntityUid SpawnAttachedTo(string? protoName, EntityCoordinates coordinates, ComponentRegistry? overrides = null, Angle rotation = default); /// /// Resolves the given entity coordinates into world coordinates and spawns an entity at that location. The diff --git a/Robust.Shared/GameObjects/IEntityManager.cs b/Robust.Shared/GameObjects/IEntityManager.cs index e9da826f794..b1dd42bce7b 100644 --- a/Robust.Shared/GameObjects/IEntityManager.cs +++ b/Robust.Shared/GameObjects/IEntityManager.cs @@ -96,7 +96,7 @@ public partial interface IEntityManager /// Coordinates to set position and parent of the newly spawned entity to. /// /// - EntityUid CreateEntityUninitialized(string? prototypeName, EntityCoordinates coordinates, ComponentRegistry? overrides = null); + EntityUid CreateEntityUninitialized(string? prototypeName, EntityCoordinates coordinates, ComponentRegistry? overrides = null, Angle rotation = default); /// /// Creates an uninitialized entity and puts it on the grid or map at the MapCoordinates provided.