EntityInsertConstructionGraphStep accepts an amount (#46268)

* commit

* self review

* x

* format

---------

Co-authored-by: iaada <iaada@users.noreply.github.com>
Co-authored-by: Pok245 <113675512+Pok27@users.noreply.github.com>
This commit is contained in:
āda 2026-10-02 02:09:40 +00:00 • committed by GitHub
parent 3bce58629d
commit fb9401cf6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 22 additions and 6 deletions

View file

@ -206,6 +206,7 @@ namespace Content.Server.Construction
break;
case ArbitraryInsertConstructionGraphStep arbitraryStep:
var toFind = arbitraryStep.Amount;
foreach (var entity in new HashSet<EntityUid>(EnumerateNearby(user)))
{
if (!arbitraryStep.EntityValid(entity, EntityManager, Factory))
@ -228,8 +229,12 @@ namespace Content.Server.Construction
else if (!_container.Insert(entity, GetContainer(arbitraryStep.Store)))
continue;
handled = true;
used.Add(entity);
toFind--;
if (toFind > 0)
continue;
handled = true;
break;
}

View file

@ -24,7 +24,7 @@ namespace Content.Shared.Construction.Steps
return new ConstructionGuideEntry
{
Localization = "construction-presenter-arbitrary-step",
Arguments = new (string, object)[]{("name", stepName)},
Arguments = [("name", stepName), ("amount", Amount)],
Icon = Icon,
};
}

View file

@ -3,7 +3,17 @@ namespace Content.Shared.Construction.Steps
[ImplicitDataDefinitionForInheritors]
public abstract partial class EntityInsertConstructionGraphStep : ConstructionGraphStep
{
[DataField("store")] public string Store { get; private set; } = string.Empty;
/// <summary>
/// A container ID to store the entity in.
/// </summary>
[DataField]
public string Store { get; private set; } = string.Empty;
/// <summary>
/// How many of the entity is needed.
/// </summary>
[DataField]
public int Amount { get; private set; } = 1;
public abstract bool EntityValid(EntityUid uid, IEntityManager entityManager, IComponentFactory compFactory);
}

View file

@ -13,8 +13,6 @@ namespace Content.Shared.Construction.Steps
[DataField("material", required:true)]
public ProtoId<StackPrototype> MaterialPrototypeId { get; private set; }
[DataField] public int Amount { get; private set; } = 1;
public override void DoExamine(ExaminedEvent examinedEvent)
{
var material = IoCManager.Resolve<IPrototypeManager>().Index(MaterialPrototypeId);

View file

@ -5,5 +5,8 @@ construction-presenter-step-wrapper = {$step-number}. {$text}
construction-presenter-tool-step = Use a {LOC($tool)}.
construction-presenter-material-step = Add {$amount}x {LOC($material)}.
construction-presenter-arbitrary-step = Add {LOC($name)}.
construction-presenter-arbitrary-step = Add {$amount ->
[one] {LOC($name)}.
*[many] {$amount}x {MAKEPLURAL(LOC($name))}.
}
construction-presenter-temperature-step = Heat to {$temperature}.