Skip to content

Commit 783d529

Browse files
more placement manager fixes (#5186)
* more placement manager fixes * Update Robust.Shared/GameObjects/EntityManager.cs Co-authored-by: ShadowCommander <[email protected]> --------- Co-authored-by: ShadowCommander <[email protected]>
1 parent 895bfb8 commit 783d529

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

Robust.Server/Placement/PlacementManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public void HandlePlacementRequest(MsgPlacement msg)
172172
}
173173
}
174174

175-
var created = _entityManager.Spawn(entityTemplateName, _xformSystem.ToMapCoordinates(coordinates), rotation: dirRcv.ToAngle());
175+
var created = _entityManager.SpawnAttachedTo(entityTemplateName, coordinates, rotation: dirRcv.ToAngle());
176176

177177
var placementCreateEvent = new PlacementEntityEvent(created, coordinates, PlacementEventAction.Create, msg.MsgChannel.UserId);
178178
_entityManager.EventBus.RaiseEvent(EventSource.Local, placementCreateEvent);

Robust.Shared/GameObjects/EntityManager.Spawn.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ public EntityUid[] SpawnEntities(MapCoordinates coordinates, List<string?> proto
7373
return ents;
7474
}
7575

76-
public virtual EntityUid SpawnAttachedTo(string? protoName, EntityCoordinates coordinates, ComponentRegistry? overrides = null)
76+
public virtual EntityUid SpawnAttachedTo(string? protoName, EntityCoordinates coordinates, ComponentRegistry? overrides = null, Angle rotation = default)
7777
{
7878
if (!coordinates.IsValid(this))
7979
throw new InvalidOperationException($"Tried to spawn entity {protoName} on invalid coordinates {coordinates}.");
8080

81-
var entity = CreateEntityUninitialized(protoName, coordinates, overrides);
81+
var entity = CreateEntityUninitialized(protoName, coordinates, overrides, rotation);
8282
InitializeAndStartEntity(entity, coordinates.GetMapId(this));
8383
return entity;
8484
}

Robust.Shared/GameObjects/EntityManager.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,12 @@ public virtual EntityUid CreateEntityUninitialized(string? prototypeName, Compon
296296
}
297297

298298
/// <inheritdoc />
299-
public virtual EntityUid CreateEntityUninitialized(string? prototypeName, EntityCoordinates coordinates, ComponentRegistry? overrides = null)
299+
public virtual EntityUid CreateEntityUninitialized(string? prototypeName, EntityCoordinates coordinates, ComponentRegistry? overrides = null, Angle rotation = default)
300300
{
301301
var newEntity = CreateEntity(prototypeName, out _, overrides);
302-
_xforms.SetCoordinates(newEntity, TransformQuery.GetComponent(newEntity), coordinates, unanchor: false);
302+
303+
var xformComp = TransformQuery.GetComponent(newEntity);
304+
_xforms.SetCoordinates(newEntity, xformComp, coordinates, rotation: rotation, unanchor: false);
303305
return newEntity;
304306
}
305307

Robust.Shared/GameObjects/IEntityManager.Spawn.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ EntityUid[] SpawnEntities(EntityCoordinates coordinates, List<string?> protoName
3838
/// <summary>
3939
/// Spawns an entity and then parents it to the entity that the given entity coordinates are relative to.
4040
/// </summary>
41-
EntityUid SpawnAttachedTo(string? protoName, EntityCoordinates coordinates, ComponentRegistry? overrides = null);
41+
EntityUid SpawnAttachedTo(string? protoName, EntityCoordinates coordinates, ComponentRegistry? overrides = null, Angle rotation = default);
4242

4343
/// <summary>
4444
/// Resolves the given entity coordinates into world coordinates and spawns an entity at that location. The

Robust.Shared/GameObjects/IEntityManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public partial interface IEntityManager
9696
/// <param name="coordinates">Coordinates to set position and parent of the newly spawned entity to.</param>
9797
/// <param name="overrides"><inheritdoc cref="CreateEntityUninitialized(string?, MapCoordinates , ComponentRegistry?, Angle)"/></param>
9898
/// <returns><inheritdoc cref="CreateEntityUninitialized(string?, MapCoordinates , ComponentRegistry?, Angle)"/></returns>
99-
EntityUid CreateEntityUninitialized(string? prototypeName, EntityCoordinates coordinates, ComponentRegistry? overrides = null);
99+
EntityUid CreateEntityUninitialized(string? prototypeName, EntityCoordinates coordinates, ComponentRegistry? overrides = null, Angle rotation = default);
100100

101101
/// <summary>
102102
/// Creates an uninitialized entity and puts it on the grid or map at the MapCoordinates provided.

0 commit comments

Comments
 (0)