]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Biogenerator (#30694)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Sun, 8 Sep 2024 05:34:22 +0000 (01:34 -0400)
committerGitHub <noreply@github.com>
Sun, 8 Sep 2024 05:34:22 +0000 (23:34 -0600)
* biogenerator

* ack

* test success!

* fix tests

* increase price of reagents

Content.Server/Materials/Components/ProduceMaterialExtractorComponent.cs [new file with mode: 0644]
Content.Server/Materials/ProduceMaterialExtractorSystem.cs [new file with mode: 0644]
Resources/Locale/en-US/lathe/components/lathe-component.ftl
Resources/Locale/en-US/lathe/lathe-categories.ftl
Resources/Prototypes/Entities/Objects/Devices/Circuitboards/Machine/production.yml
Resources/Prototypes/Entities/Structures/Machines/lathe.yml
Resources/Prototypes/Recipes/Lathes/biogen.yml [new file with mode: 0644]
Resources/Prototypes/Recipes/Lathes/categories.yml
Resources/Prototypes/Recipes/Lathes/electronics.yml

diff --git a/Content.Server/Materials/Components/ProduceMaterialExtractorComponent.cs b/Content.Server/Materials/Components/ProduceMaterialExtractorComponent.cs
new file mode 100644 (file)
index 0000000..acf560b
--- /dev/null
@@ -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;
+
+/// <summary>
+/// This is used for a machine that turns produce into a specified material.
+/// </summary>
+[RegisterComponent, Access(typeof(ProduceMaterialExtractorSystem))]
+public sealed partial class ProduceMaterialExtractorComponent : Component
+{
+    /// <summary>
+    /// The material that produce is converted into
+    /// </summary>
+    [DataField]
+    public ProtoId<MaterialPrototype> ExtractedMaterial = "Biomass";
+
+    /// <summary>
+    /// List of reagents that determines how much material is yielded from a produce.
+    /// </summary>
+    [DataField]
+    public List<ProtoId<ReagentPrototype>> 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 (file)
index 0000000..5a46930
--- /dev/null
@@ -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!;
+
+    /// <inheritdoc/>
+    public override void Initialize()
+    {
+        SubscribeLocalEvent<ProduceMaterialExtractorComponent, AfterInteractUsingEvent>(OnInteractUsing);
+    }
+
+    private void OnInteractUsing(Entity<ProduceMaterialExtractorComponent> ent, ref AfterInteractUsingEvent args)
+    {
+        if (args.Handled)
+            return;
+
+        if (!this.IsPowered(ent, EntityManager))
+            return;
+
+        if (!TryComp<ProduceComponent>(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;
+    }
+}
index 3f70bff642802cadf544d556dfd5f1016547d69c..2e6d10234fd5a605375e627d3d46d93f45f2c9df 100644 (file)
@@ -1,2 +1,4 @@
 lathe-component-upgrade-speed = speed
 lathe-component-upgrade-material-use = material use
+
+lathe-component-output-slot-beaker-name = Beaker slot
index a7261c2b511267cd643dee9e3ed26fd627dbcee3..7a4c20918cf3a0779fcec87c561939296795b9da 100644 (file)
@@ -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
index 085ace797bbfdfc9683eb532d202021ac7968422..8e0860c181c292b16efc8eec93e6ef4725345a1d 100644 (file)
     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
index 1bd5bc74a922f834ba4cbcca9ae7819a471386ee..7a321594998e5642a932313f53b3e29379bfc936 100644 (file)
     - ProtolatheMachineCircuitboard
     - AutolatheMachineCircuitboard
     - CircuitImprinterMachineCircuitboard
+    - BiogeneratorMachineCircuitboard
     - OreProcessorMachineCircuitboard
     - ElectrolysisUnitMachineCircuitboard
     - CentrifugeMachineCircuitboard
         - 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 (file)
index 0000000..4f8887a
--- /dev/null
@@ -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
+
+
+
index 8faa67af1b3e8d02304b5dbe50afb3588f4c82e4..0d26305b75f71b0524da22e3d37a95c7efcf09a0 100644 (file)
 - 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
index 6b4653d43ad6b821e65c06d9989250f56a40e3dd..e0b95a23d76a056461f288e5dfd5bb8d7ee06b9c 100644 (file)
      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