Move board spawning out of DoorSystem (#11772)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Content.Server.Construction.Components;
|
||||
using Content.Server.Containers;
|
||||
using Content.Shared.Construction;
|
||||
using Content.Shared.Construction.Prototypes;
|
||||
using Content.Shared.Construction.Steps;
|
||||
@@ -281,20 +282,33 @@ namespace Content.Server.Construction
|
||||
Resolve(uid, ref containerManager, false);
|
||||
|
||||
// We create the new entity.
|
||||
var newUid = EntityManager.SpawnEntity(newEntity, transform.Coordinates);
|
||||
var newUid = EntityManager.CreateEntityUninitialized(newEntity, transform.Coordinates);
|
||||
|
||||
// Construction transferring.
|
||||
var newConstruction = EntityManager.EnsureComponent<ConstructionComponent>(newUid);
|
||||
|
||||
// We set the graph and node accordingly... Then we append our containers to theirs.
|
||||
// Transfer all construction-owned containers.
|
||||
newConstruction.Containers.UnionWith(construction.Containers);
|
||||
|
||||
// Prevent MapInitEvent spawned entities from spawning into the containers.
|
||||
// Containers created by ChangeNode() actions do not exist until after this function is complete,
|
||||
// but this should be fine, as long as the target entity properly declared its managed containers.
|
||||
if (TryComp(newUid, out ContainerFillComponent? containerFill) && containerFill.IgnoreConstructionSpawn)
|
||||
{
|
||||
foreach (var id in newConstruction.Containers)
|
||||
{
|
||||
containerFill.Containers.Remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
EntityManager.InitializeAndStartEntity(newUid);
|
||||
|
||||
// We set the graph and node accordingly.
|
||||
ChangeGraph(newUid, userUid, construction.Graph, construction.Node, false, newConstruction);
|
||||
|
||||
if (construction.TargetNode is {} targetNode)
|
||||
SetPathfindingTarget(newUid, targetNode, newConstruction);
|
||||
|
||||
// Transfer all construction-owned containers.
|
||||
newConstruction.Containers.UnionWith(construction.Containers);
|
||||
|
||||
// Transfer all pending interaction events too.
|
||||
while (construction.InteractionQueue.TryDequeue(out var ev))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user