Artifact crafting fix (#17454)
* Fix tag steps double counting entities * oauhg
This commit is contained in:
@@ -107,8 +107,8 @@ namespace Content.Server.Construction
|
|||||||
// But I'd rather do this shit than risk having collisions with other containers.
|
// But I'd rather do this shit than risk having collisions with other containers.
|
||||||
Container GetContainer(string name)
|
Container GetContainer(string name)
|
||||||
{
|
{
|
||||||
if (containers.ContainsKey(name))
|
if (containers.TryGetValue(name, out var container1))
|
||||||
return containers[name];
|
return container1;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
@@ -154,6 +154,7 @@ namespace Content.Server.Construction
|
|||||||
var failed = false;
|
var failed = false;
|
||||||
|
|
||||||
var steps = new List<ConstructionGraphStep>();
|
var steps = new List<ConstructionGraphStep>();
|
||||||
|
var used = new HashSet<EntityUid>();
|
||||||
|
|
||||||
foreach (var step in edge.Steps)
|
foreach (var step in edge.Steps)
|
||||||
{
|
{
|
||||||
@@ -169,6 +170,9 @@ namespace Content.Server.Construction
|
|||||||
if (!materialStep.EntityValid(entity, out var stack))
|
if (!materialStep.EntityValid(entity, out var stack))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (used.Contains(entity))
|
||||||
|
continue;
|
||||||
|
|
||||||
// TODO allow taking from several stacks.
|
// TODO allow taking from several stacks.
|
||||||
// Also update crafting steps to check if it works.
|
// Also update crafting steps to check if it works.
|
||||||
var splitStack = _stackSystem.Split(entity, materialStep.Amount, user.ToCoordinates(0, 0), stack);
|
var splitStack = _stackSystem.Split(entity, materialStep.Amount, user.ToCoordinates(0, 0), stack);
|
||||||
@@ -191,11 +195,14 @@ namespace Content.Server.Construction
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ArbitraryInsertConstructionGraphStep arbitraryStep:
|
case ArbitraryInsertConstructionGraphStep arbitraryStep:
|
||||||
foreach (var entity in EnumerateNearby(user))
|
foreach (var entity in new HashSet<EntityUid>(EnumerateNearby(user)))
|
||||||
{
|
{
|
||||||
if (!arbitraryStep.EntityValid(entity, EntityManager, _factory))
|
if (!arbitraryStep.EntityValid(entity, EntityManager, _factory))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (used.Contains(entity))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(arbitraryStep.Store))
|
if (string.IsNullOrEmpty(arbitraryStep.Store))
|
||||||
{
|
{
|
||||||
if (!container.Insert(entity))
|
if (!container.Insert(entity))
|
||||||
@@ -205,6 +212,7 @@ namespace Content.Server.Construction
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
handled = true;
|
handled = true;
|
||||||
|
used.Add(entity);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user