Biogenerator (#30694)

* biogenerator

* ack

* test success!

* fix tests

* increase price of reagents
This commit is contained in:
Nemanja
2024-09-08 01:34:22 -04:00
committed by GitHub
parent 6fcb5cf148
commit efe54e011e
9 changed files with 422 additions and 0 deletions

View File

@@ -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");
}

View File

@@ -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;
}
}

View File

@@ -1,2 +1,4 @@
lathe-component-upgrade-speed = speed lathe-component-upgrade-speed = speed
lathe-component-upgrade-material-use = material use lathe-component-upgrade-material-use = material use
lathe-component-output-slot-beaker-name = Beaker slot

View File

@@ -6,3 +6,7 @@ lathe-category-parts = Parts
lathe-category-robotics = Robotics lathe-category-robotics = Robotics
lathe-category-tools = Tools lathe-category-tools = Tools
lathe-category-weapons = Weapons lathe-category-weapons = Weapons
lathe-category-food = Food
lathe-category-chemicals = Chemicals
lathe-category-materials = Materials

View File

@@ -193,6 +193,23 @@
stackRequirements: stackRequirements:
Plasma: 5 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 - type: entity
id: UniformPrinterMachineCircuitboard id: UniformPrinterMachineCircuitboard
parent: BaseMachineCircuitboard parent: BaseMachineCircuitboard

View File

@@ -430,6 +430,7 @@
- ProtolatheMachineCircuitboard - ProtolatheMachineCircuitboard
- AutolatheMachineCircuitboard - AutolatheMachineCircuitboard
- CircuitImprinterMachineCircuitboard - CircuitImprinterMachineCircuitboard
- BiogeneratorMachineCircuitboard
- OreProcessorMachineCircuitboard - OreProcessorMachineCircuitboard
- ElectrolysisUnitMachineCircuitboard - ElectrolysisUnitMachineCircuitboard
- CentrifugeMachineCircuitboard - CentrifugeMachineCircuitboard
@@ -1150,6 +1151,70 @@
- RawMaterial - RawMaterial
- Ingot - 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 - type: entity
parent: BaseLathe parent: BaseLathe
id: OreProcessor id: OreProcessor

View File

@@ -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

View File

@@ -29,3 +29,17 @@
- type: latheCategory - type: latheCategory
id: Weapons id: Weapons
name: lathe-category-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

View File

@@ -309,6 +309,15 @@
Steel: 100 Steel: 100
Glass: 500 Glass: 500
- type: latheRecipe
id: BiogeneratorMachineCircuitboard
result: BiogeneratorMachineCircuitboard
category: Circuitry
completetime: 4
materials:
Steel: 100
Glass: 500
- type: latheRecipe - type: latheRecipe
id: VaccinatorMachineCircuitboard id: VaccinatorMachineCircuitboard
result: VaccinatorMachineCircuitboard result: VaccinatorMachineCircuitboard