Skip to content

Commit

Permalink
more placement manager fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
EmoGarbage404 committed May 30, 2024
1 parent c89c529 commit d1830b2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Robust.Server/Placement/PlacementManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Robust.Shared/GameObjects/EntityManager.Spawn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ public EntityUid[] SpawnEntities(MapCoordinates coordinates, List<string?> 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;
}
Expand Down
7 changes: 5 additions & 2 deletions Robust.Shared/GameObjects/EntityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,13 @@ public virtual EntityUid CreateEntityUninitialized(string? prototypeName, Compon
}

/// <inheritdoc />
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;
}

Expand Down
2 changes: 1 addition & 1 deletion Robust.Shared/GameObjects/IEntityManager.Spawn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ EntityUid[] SpawnEntities(EntityCoordinates coordinates, List<string?> protoName
/// <summary>
/// Spawns an entity and then parents it to the entity that the given entity coordinates are relative to.
/// </summary>
EntityUid SpawnAttachedTo(string? protoName, EntityCoordinates coordinates, ComponentRegistry? overrides = null);
EntityUid SpawnAttachedTo(string? protoName, EntityCoordinates coordinates, ComponentRegistry? overrides = null, Angle rotation = default);

/// <summary>
/// Resolves the given entity coordinates into world coordinates and spawns an entity at that location. The
Expand Down
2 changes: 1 addition & 1 deletion Robust.Shared/GameObjects/IEntityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public partial interface IEntityManager
/// <param name="coordinates">Coordinates to set position and parent of the newly spawned entity to.</param>
/// <param name="overrides"><inheritdoc cref="CreateEntityUninitialized(string?, MapCoordinates , ComponentRegistry?, Angle)"/></param>
/// <returns><inheritdoc cref="CreateEntityUninitialized(string?, MapCoordinates , ComponentRegistry?, Angle)"/></returns>
EntityUid CreateEntityUninitialized(string? prototypeName, EntityCoordinates coordinates, ComponentRegistry? overrides = null);
EntityUid CreateEntityUninitialized(string? prototypeName, EntityCoordinates coordinates, ComponentRegistry? overrides = null, Angle rotation = default);

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

0 comments on commit d1830b2

Please sign in to comment.