From fb9401cf6a1bb01d6fa6fc2ebf2b53678ae5cbd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=81da?= Date: Fri, 2 Oct 2026 02:09:40 +0000 Subject: [PATCH] EntityInsertConstructionGraphStep accepts an amount (#46268) * commit * self review * x * format --------- Co-authored-by: iaada Co-authored-by: Pok245 <113675512+Pok27@users.noreply.github.com> --- .../Construction/ConstructionSystem.Initial.cs | 7 ++++++- .../Steps/ArbitraryInsertConstructionGraphStep.cs | 2 +- .../Steps/EntityInsertConstructionGraphStep.cs | 12 +++++++++++- .../Steps/MaterialConstructionGraphStep.cs | 2 -- .../construction/ui/construction-menu-presenter.ftl | 5 ++++- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Content.Server/Construction/ConstructionSystem.Initial.cs b/Content.Server/Construction/ConstructionSystem.Initial.cs index a6d6739e99..50b8046736 100644 --- a/Content.Server/Construction/ConstructionSystem.Initial.cs +++ b/Content.Server/Construction/ConstructionSystem.Initial.cs @@ -206,6 +206,7 @@ namespace Content.Server.Construction break; case ArbitraryInsertConstructionGraphStep arbitraryStep: + var toFind = arbitraryStep.Amount; foreach (var entity in new HashSet(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; } diff --git a/Content.Shared/Construction/Steps/ArbitraryInsertConstructionGraphStep.cs b/Content.Shared/Construction/Steps/ArbitraryInsertConstructionGraphStep.cs index 27a5473a87..fa7744ced4 100644 --- a/Content.Shared/Construction/Steps/ArbitraryInsertConstructionGraphStep.cs +++ b/Content.Shared/Construction/Steps/ArbitraryInsertConstructionGraphStep.cs @@ -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, }; } diff --git a/Content.Shared/Construction/Steps/EntityInsertConstructionGraphStep.cs b/Content.Shared/Construction/Steps/EntityInsertConstructionGraphStep.cs index b609223c29..21338b773d 100644 --- a/Content.Shared/Construction/Steps/EntityInsertConstructionGraphStep.cs +++ b/Content.Shared/Construction/Steps/EntityInsertConstructionGraphStep.cs @@ -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; + /// + /// A container ID to store the entity in. + /// + [DataField] + public string Store { get; private set; } = string.Empty; + + /// + /// How many of the entity is needed. + /// + [DataField] + public int Amount { get; private set; } = 1; public abstract bool EntityValid(EntityUid uid, IEntityManager entityManager, IComponentFactory compFactory); } diff --git a/Content.Shared/Construction/Steps/MaterialConstructionGraphStep.cs b/Content.Shared/Construction/Steps/MaterialConstructionGraphStep.cs index b1ae9cbdf7..8a9d7fa080 100644 --- a/Content.Shared/Construction/Steps/MaterialConstructionGraphStep.cs +++ b/Content.Shared/Construction/Steps/MaterialConstructionGraphStep.cs @@ -13,8 +13,6 @@ namespace Content.Shared.Construction.Steps [DataField("material", required:true)] public ProtoId MaterialPrototypeId { get; private set; } - [DataField] public int Amount { get; private set; } = 1; - public override void DoExamine(ExaminedEvent examinedEvent) { var material = IoCManager.Resolve().Index(MaterialPrototypeId); diff --git a/Resources/Locale/en-US/construction/ui/construction-menu-presenter.ftl b/Resources/Locale/en-US/construction/ui/construction-menu-presenter.ftl index 7961461dd9..da89897997 100644 --- a/Resources/Locale/en-US/construction/ui/construction-menu-presenter.ftl +++ b/Resources/Locale/en-US/construction/ui/construction-menu-presenter.ftl @@ -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}.