}
}
- // We set the graph and node accordingly.
- ChangeGraph(newUid, userUid, construction.Graph, construction.Node, false, newConstruction);
+ // If the new entity has the *same* construction graph, stay on the same node.
+ // If not, we effectively restart the construction graph, so the new entity can be completed.
+ if (construction.Graph == newConstruction.Graph)
+ {
+ ChangeNode(newUid, userUid, construction.Node, false, newConstruction);
- if (construction.TargetNode is {} targetNode)
- SetPathfindingTarget(newUid, targetNode, newConstruction);
+ // Retain the target node if an entity change happens in response to deconstruction;
+ // in that case, we must continue to move towards the start node.
+ if (construction.TargetNode is {} targetNode)
+ SetPathfindingTarget(newUid, targetNode, newConstruction);
+ }
// Transfer all pending interaction events too.
while (construction.InteractionQueue.TryDequeue(out var ev))