From 94dd41a26f17fa8ca9a79324bd50578dafdbcddb Mon Sep 17 00:00:00 2001 From: temm1ie <63717386+temm1ie@users.noreply.github.com> Date: Fri, 14 Feb 2025 05:51:08 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B1=D0=B8=D0=BE=D0=B3=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=B0=20(#1364)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProduceMaterialExtractorSystem.cs | 51 ++++++++++++++++--- .../Prototypes/Recipes/Lathes/biogen.yml | 51 ++++++++++++++++++- .../_Sunrise/Recipes/Lathes/Packs/biogen.yml | 6 +++ 3 files changed, 100 insertions(+), 8 deletions(-) diff --git a/Content.Server/Materials/ProduceMaterialExtractorSystem.cs b/Content.Server/Materials/ProduceMaterialExtractorSystem.cs index 5a46930499..33d5c1ac14 100644 --- a/Content.Server/Materials/ProduceMaterialExtractorSystem.cs +++ b/Content.Server/Materials/ProduceMaterialExtractorSystem.cs @@ -4,6 +4,8 @@ using Content.Server.Materials.Components; using Content.Server.Power.EntitySystems; using Content.Shared.Chemistry.EntitySystems; using Content.Shared.Interaction; +using Content.Shared.Storage; +using Content.Shared.Storage.Components; using Robust.Server.Audio; namespace Content.Server.Materials; @@ -28,11 +30,32 @@ public sealed class ProduceMaterialExtractorSystem : EntitySystem if (!this.IsPowered(ent, EntityManager)) return; - if (!TryComp(args.Used, out var produce)) - return; + bool success = false; - if (!_solutionContainer.TryGetSolution(args.Used, produce.SolutionName, out var solution)) - return; + // Handle using bags (mainly plant bags) + if (ExtractFromStorage(ent, args.Used)) + success = true; + + // Handle using produce directly + if (ExtractFromProduce(ent, args.Used)) + success = true; + + // TODO: What if a bag is also a plant? + + if (success) + { + _audio.PlayPvs(ent.Comp.ExtractSound, ent); + args.Handled = true; + } + } + + private bool ExtractFromProduce(Entity ent, EntityUid used) + { + if (!TryComp(used, out var produce)) + return false; + + if (!_solutionContainer.TryGetSolution(used, produce.SolutionName, out var solution)) + return false; // Can produce even have fractional amounts? Does it matter if they do? // Questions man was never meant to answer. @@ -41,8 +64,22 @@ public sealed class ProduceMaterialExtractorSystem : EntitySystem .Sum(r => r.Quantity.Float()); _materialStorage.TryChangeMaterialAmount(ent, ent.Comp.ExtractedMaterial, (int) matAmount); - _audio.PlayPvs(ent.Comp.ExtractSound, ent); - QueueDel(args.Used); - args.Handled = true; + QueueDel(used); + + return true; + } + + private bool ExtractFromStorage(Entity ent, EntityUid used) + { + if (!TryComp(used, out var storage)) + return false; + + bool success = false; + + foreach (var (item, _location) in storage.StoredItems) + if (ExtractFromProduce(ent, item)) + success = true; + + return success; } } diff --git a/Resources/Prototypes/Recipes/Lathes/biogen.yml b/Resources/Prototypes/Recipes/Lathes/biogen.yml index 0579172025..5cc6fbab5f 100644 --- a/Resources/Prototypes/Recipes/Lathes/biogen.yml +++ b/Resources/Prototypes/Recipes/Lathes/biogen.yml @@ -235,5 +235,54 @@ category: Materials completetime: 3 materials: - Biomass: 149 + Biomass: 100 + +- type: latheRecipe + id: BioClothingBeltPlant + result: ClothingBeltPlant + category: Materials + completetime: 5 + materials: + Biomass: 50 + +- type: latheRecipe + id: BioClothingBeltUtility + result: ClothingBeltUtility + category: Materials + completetime: 5 + materials: + Biomass: 50 + +- type: latheRecipe + id: BioClothingBeltMedical + result: ClothingBeltMedical + category: Materials + completetime: 5 + materials: + Biomass: 50 + +- type: latheRecipe + id: BioClothingBeltJanitor + result: ClothingBeltJanitor + category: Materials + completetime: 5 + materials: + Biomass: 50 + +- type: latheRecipe + id: BioClothingBeltStorageWaistbag + result: ClothingBeltStorageWaistbag + category: Materials + completetime: 5 + materials: + Biomass: 50 + +- type: latheRecipe + id: BioClothingBeltChef + result: ClothingBeltChef + category: Materials + completetime: 5 + materials: + Biomass: 50 + # Sunrise-End diff --git a/Resources/Prototypes/_Sunrise/Recipes/Lathes/Packs/biogen.yml b/Resources/Prototypes/_Sunrise/Recipes/Lathes/Packs/biogen.yml index 81369cbba6..cfffbe1d5a 100644 --- a/Resources/Prototypes/_Sunrise/Recipes/Lathes/Packs/biogen.yml +++ b/Resources/Prototypes/_Sunrise/Recipes/Lathes/Packs/biogen.yml @@ -4,3 +4,9 @@ id: BioGenStaticSunrise recipes: - BioGenHandheldSoil + - BioClothingBeltPlant + - BioClothingBeltUtility + - BioClothingBeltMedical + - BioClothingBeltJanitor + - BioClothingBeltStorageWaistbag + - BioClothingBeltChef