diff --git a/Content.Server/Materials/Components/ProduceMaterialExtractorComponent.cs b/Content.Server/Materials/Components/ProduceMaterialExtractorComponent.cs new file mode 100644 index 0000000000..acf560b819 --- /dev/null +++ b/Content.Server/Materials/Components/ProduceMaterialExtractorComponent.cs @@ -0,0 +1,31 @@ +using Content.Shared.Chemistry.Reagent; +using Content.Shared.Materials; +using Robust.Shared.Audio; +using Robust.Shared.Prototypes; + +namespace Content.Server.Materials.Components; + +/// +/// This is used for a machine that turns produce into a specified material. +/// +[RegisterComponent, Access(typeof(ProduceMaterialExtractorSystem))] +public sealed partial class ProduceMaterialExtractorComponent : Component +{ + /// + /// The material that produce is converted into + /// + [DataField] + public ProtoId ExtractedMaterial = "Biomass"; + + /// + /// List of reagents that determines how much material is yielded from a produce. + /// + [DataField] + public List> ExtractionReagents = new() + { + "Nutriment" + }; + + [DataField] + public SoundSpecifier? ExtractSound = new SoundPathSpecifier("/Audio/Effects/waterswirl.ogg"); +} diff --git a/Content.Server/Materials/ProduceMaterialExtractorSystem.cs b/Content.Server/Materials/ProduceMaterialExtractorSystem.cs new file mode 100644 index 0000000000..5a46930499 --- /dev/null +++ b/Content.Server/Materials/ProduceMaterialExtractorSystem.cs @@ -0,0 +1,48 @@ +using System.Linq; +using Content.Server.Botany.Components; +using Content.Server.Materials.Components; +using Content.Server.Power.EntitySystems; +using Content.Shared.Chemistry.EntitySystems; +using Content.Shared.Interaction; +using Robust.Server.Audio; + +namespace Content.Server.Materials; + +public sealed class ProduceMaterialExtractorSystem : EntitySystem +{ + [Dependency] private readonly AudioSystem _audio = default!; + [Dependency] private readonly MaterialStorageSystem _materialStorage = default!; + [Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!; + + /// + public override void Initialize() + { + SubscribeLocalEvent(OnInteractUsing); + } + + private void OnInteractUsing(Entity ent, ref AfterInteractUsingEvent args) + { + if (args.Handled) + return; + + if (!this.IsPowered(ent, EntityManager)) + return; + + if (!TryComp(args.Used, out var produce)) + return; + + if (!_solutionContainer.TryGetSolution(args.Used, produce.SolutionName, out var solution)) + return; + + // Can produce even have fractional amounts? Does it matter if they do? + // Questions man was never meant to answer. + var matAmount = solution.Value.Comp.Solution.Contents + .Where(r => ent.Comp.ExtractionReagents.Contains(r.Reagent.Prototype)) + .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; + } +} diff --git a/Resources/Locale/en-US/lathe/components/lathe-component.ftl b/Resources/Locale/en-US/lathe/components/lathe-component.ftl index 3f70bff642..2e6d10234f 100644 --- a/Resources/Locale/en-US/lathe/components/lathe-component.ftl +++ b/Resources/Locale/en-US/lathe/components/lathe-component.ftl @@ -1,2 +1,4 @@ lathe-component-upgrade-speed = speed lathe-component-upgrade-material-use = material use + +lathe-component-output-slot-beaker-name = Beaker slot diff --git a/Resources/Locale/en-US/lathe/lathe-categories.ftl b/Resources/Locale/en-US/lathe/lathe-categories.ftl index a7261c2b51..7a4c20918c 100644 --- a/Resources/Locale/en-US/lathe/lathe-categories.ftl +++ b/Resources/Locale/en-US/lathe/lathe-categories.ftl @@ -6,3 +6,7 @@ lathe-category-parts = Parts lathe-category-robotics = Robotics lathe-category-tools = Tools lathe-category-weapons = Weapons + +lathe-category-food = Food +lathe-category-chemicals = Chemicals +lathe-category-materials = Materials diff --git a/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml b/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml index 085ace797b..8e0860c181 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml @@ -193,6 +193,23 @@ stackRequirements: Plasma: 5 +- type: entity + id: BiogeneratorMachineCircuitboard + parent: BaseMachineCircuitboard + name: biogenerator machine board + description: A machine printed circuit board for a biogenerator. + components: + - type: Sprite + state: service + - type: MachineBoard + prototype: Biogenerator + stackRequirements: + MatterBin: 2 + tagRequirements: + GlassBeaker: + amount: 1 + defaultPrototype: Beaker + - type: entity id: UniformPrinterMachineCircuitboard parent: BaseMachineCircuitboard diff --git a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml index 1bd5bc74a9..7a32159499 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml @@ -430,6 +430,7 @@ - ProtolatheMachineCircuitboard - AutolatheMachineCircuitboard - CircuitImprinterMachineCircuitboard + - BiogeneratorMachineCircuitboard - OreProcessorMachineCircuitboard - ElectrolysisUnitMachineCircuitboard - CentrifugeMachineCircuitboard @@ -1150,6 +1151,70 @@ - RawMaterial - Ingot +- type: entity + id: Biogenerator + parent: BaseLathe + name: biogenerator + description: Converts plants into biomass, which can be used to construct useful items. + components: + - type: Sprite + sprite: Structures/Machines/biofabricator.rsi + snapCardinals: true + layers: + - state: icon + map: ["enum.LatheVisualLayers.IsRunning"] + - state: unlit + shader: unshaded + map: ["enum.PowerDeviceVisualLayers.Powered"] + - state: inserting + map: ["enum.MaterialStorageVisualLayers.Inserting"] + - state: panel + map: ["enum.WiresVisualLayers.MaintenancePanel"] + - type: Machine + board: BiogeneratorMachineCircuitboard + - type: MaterialStorage + insertOnInteract: false + canEjectStoredMaterials: false + - type: ProduceMaterialExtractor + - type: ItemSlots + slots: + beaker_slot: + name: lathe-component-output-slot-beaker-name + whitelist: + components: + - FitsInDispenser + - type: ContainerContainer + containers: + machine_board: !type:Container + machine_parts: !type:Container + beaker_slot: !type:ContainerSlot + - type: Lathe + reagentOutputSlotId: beaker_slot + idleState: icon + runningState: building + staticRecipes: + - BioGenMilk + - BioGenMilkSoy + - BioGenEthanol + - BioGenCream + - BioGenBlackpepper + - BioGenEnzyme + - BioGenFlour + - BioGenSugar + - BioGenMonkeyCube + - BioGenKoboldCube + - BioGenMaterialCloth1 + - BioGenMaterialCardboard1 + - BioGenPaper + - BioGenPaperRolling1 + - BioGenCandle + - BioGenPlantBGone + - BioGenWeedKiller + - BioGenPestKiller + - BioGenLeft4Zed + - BioGenEZNutrient + - BioGenRobustHarvest + - type: entity parent: BaseLathe id: OreProcessor diff --git a/Resources/Prototypes/Recipes/Lathes/biogen.yml b/Resources/Prototypes/Recipes/Lathes/biogen.yml new file mode 100644 index 0000000000..4f8887a130 --- /dev/null +++ b/Resources/Prototypes/Recipes/Lathes/biogen.yml @@ -0,0 +1,232 @@ +- type: latheRecipe + id: BioGenMonkeyCube + result: MonkeyCube + category: Food + completetime: 3 + materials: + Biomass: 70 + +- type: latheRecipe + id: BioGenKoboldCube + result: KoboldCube + category: Food + completetime: 3 + materials: + Biomass: 70 + +- type: latheRecipe + id: BioGenMaterialCloth1 + result: MaterialCloth1 + category: Materials + icon: + sprite: Objects/Materials/materials.rsi + state: cloth + completetime: 1 + materials: + Biomass: 10 + +- type: latheRecipe + id: BioGenMaterialCardboard1 + result: MaterialCardboard1 + category: Materials + icon: + sprite: Objects/Materials/materials.rsi + state: cardboard + completetime: 1 + materials: + Biomass: 5 + +- type: latheRecipe + id: BioGenPaper + result: Paper + category: Materials + completetime: 1 + materials: + Biomass: 2 + +- type: latheRecipe + id: BioGenPaperRolling1 + result: PaperRolling1 + category: Materials + completetime: 1 + materials: + Biomass: 1 + +- type: latheRecipe + id: BioGenCandle + result: Candle + category: Materials + completetime: 3 + materials: + Biomass: 3 + +- type: latheRecipe + id: BioGenPlantBGone + resultReagents: + PlantBGone: 10 + category: Chemicals + icon: + sprite: Objects/Tools/Hydroponics/sprays.rsi + state: plantbgone + completetime: 1 + materials: + Biomass: 12 + +- type: latheRecipe + id: BioGenWeedKiller + resultReagents: + WeedKiller: 10 + category: Chemicals + icon: + sprite: Objects/Tools/Hydroponics/sprays.rsi + state: weedspray + completetime: 1 + materials: + Biomass: 8 + +- type: latheRecipe + id: BioGenPestKiller + resultReagents: + PestKiller: 10 + category: Chemicals + icon: + sprite: Objects/Tools/Hydroponics/sprays.rsi + state: weedspray + completetime: 1 + materials: + Biomass: 12 + +- type: latheRecipe + id: BioGenLeft4Zed + resultReagents: + Left4Zed: 10 + category: Chemicals + icon: + sprite: Objects/Specific/Chemistry/bottle.rsi + state: bottle-1 + completetime: 1 + materials: + Biomass: 12 + +- type: latheRecipe + id: BioGenEZNutrient + resultReagents: + EZNutrient: 10 + category: Chemicals + icon: + sprite: Objects/Specific/Chemistry/bottle.rsi + state: bottle-1 + completetime: 1 + materials: + Biomass: 15 + +- type: latheRecipe + id: BioGenRobustHarvest + resultReagents: + RobustHarvest: 10 + category: Chemicals + icon: + sprite: Objects/Specific/Chemistry/bottle.rsi + state: bottle-1 + completetime: 1 + materials: + Biomass: 15 + +- type: latheRecipe + id: BioGenMilk + resultReagents: + Milk: 10 + category: Food + icon: + sprite: Objects/Consumable/Drinks/milk.rsi + state: icon + completetime: 1 + materials: + Biomass: 12 + +- type: latheRecipe + id: BioGenMilkSoy + resultReagents: + MilkSoy: 10 + category: Food + icon: + sprite: Objects/Consumable/Drinks/soymilk.rsi + state: icon + completetime: 1 + materials: + Biomass: 12 + +- type: latheRecipe + id: BioGenEthanol + resultReagents: + Ethanol: 10 + category: Food + icon: + sprite: Objects/Consumable/Drinks/glass_clear.rsi + state: icon + completetime: 1 + materials: + Biomass: 18 + +- type: latheRecipe + id: BioGenCream + resultReagents: + Cream: 10 + category: Food + icon: + sprite: Objects/Consumable/Drinks/cream.rsi + state: icon + completetime: 1 + materials: + Biomass: 18 + +- type: latheRecipe + id: BioGenBlackpepper + resultReagents: + Blackpepper: 10 + category: Food + icon: + sprite: Objects/Consumable/Food/condiments.rsi + state: packet-pepper + completetime: 1 + materials: + Biomass: 18 + +- type: latheRecipe + id: BioGenEnzyme + resultReagents: + Enzyme: 10 + category: Food + icon: + sprite: Objects/Consumable/Food/condiments.rsi + state: bottle-empty + completetime: 1 + materials: + Biomass: 18 + +- type: latheRecipe + id: BioGenFlour + resultReagents: + Flour: 10 + category: Food + icon: + sprite: Objects/Consumable/Food/ingredients.rsi + state: flour-big + completetime: 1 + materials: + Biomass: 18 + +- type: latheRecipe + id: BioGenSugar + resultReagents: + Sugar: 10 + category: Food + icon: + sprite: Objects/Consumable/Food/ingredients.rsi + state: sugar-big + completetime: 1 + materials: + Biomass: 18 + + + diff --git a/Resources/Prototypes/Recipes/Lathes/categories.yml b/Resources/Prototypes/Recipes/Lathes/categories.yml index 8faa67af1b..0d26305b75 100644 --- a/Resources/Prototypes/Recipes/Lathes/categories.yml +++ b/Resources/Prototypes/Recipes/Lathes/categories.yml @@ -29,3 +29,17 @@ - type: latheCategory id: Weapons name: lathe-category-weapons + +# Biogen + +- type: latheCategory + id: Food + name: lathe-category-food + +- type: latheCategory + id: Chemicals + name: lathe-category-chemicals + +- type: latheCategory + id: Materials + name: lathe-category-materials diff --git a/Resources/Prototypes/Recipes/Lathes/electronics.yml b/Resources/Prototypes/Recipes/Lathes/electronics.yml index 6b4653d43a..e0b95a23d7 100644 --- a/Resources/Prototypes/Recipes/Lathes/electronics.yml +++ b/Resources/Prototypes/Recipes/Lathes/electronics.yml @@ -309,6 +309,15 @@ Steel: 100 Glass: 500 +- type: latheRecipe + id: BiogeneratorMachineCircuitboard + result: BiogeneratorMachineCircuitboard + category: Circuitry + completetime: 4 + materials: + Steel: 100 + Glass: 500 + - type: latheRecipe id: VaccinatorMachineCircuitboard result: VaccinatorMachineCircuitboard