Seed extractor construction + upgrading (#11972)
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
using Content.Server.Botany.Systems;
|
using Content.Server.Botany.Systems;
|
||||||
|
using Content.Server.Construction;
|
||||||
|
using Content.Shared.Construction.Prototypes;
|
||||||
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||||
|
|
||||||
namespace Content.Server.Botany.Components;
|
namespace Content.Server.Botany.Components;
|
||||||
|
|
||||||
@@ -6,8 +9,34 @@ namespace Content.Server.Botany.Components;
|
|||||||
[Access(typeof(SeedExtractorSystem))]
|
[Access(typeof(SeedExtractorSystem))]
|
||||||
public sealed class SeedExtractorComponent : Component
|
public sealed class SeedExtractorComponent : Component
|
||||||
{
|
{
|
||||||
// TODO: Upgradeable machines.
|
/// <summary>
|
||||||
[DataField("minSeeds")] public int MinSeeds = 1;
|
/// The minimum amount of seed packets dropped with no machine upgrades.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("baseMinSeeds"), ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public int BaseMinSeeds = 1;
|
||||||
|
|
||||||
[DataField("maxSeeds")] public int MaxSeeds = 4;
|
/// <summary>
|
||||||
|
/// The maximum amount of seed packets dropped with no machine upgrades.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("baseMaxSeeds"), ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public int BaseMaxSeeds = 3;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Modifier to the amount of seeds outputted, set on <see cref="RefreshPartsEvent"/>.
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public float SeedAmountMultiplier;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Machine part whose rating modifies the amount of seed packets dropped.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("machinePartYieldAmount", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
|
||||||
|
public string MachinePartSeedAmount = "Manipulator";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How much the machine part quality affects the amount of seeds outputted.
|
||||||
|
/// Going up a tier will multiply the seed output by this amount.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("partRatingSeedAmountMultiplier"), ViewVariables]
|
||||||
|
public float PartRatingSeedAmountMultiplier = 1.5f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Content.Server.Botany.Components;
|
using Content.Server.Botany.Components;
|
||||||
|
using Content.Server.Construction;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Server.Power.Components;
|
|
||||||
using Content.Server.Power.EntitySystems;
|
using Content.Server.Power.EntitySystems;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
@@ -20,9 +20,10 @@ public sealed class SeedExtractorSystem : EntitySystem
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<SeedExtractorComponent, InteractUsingEvent>(OnInteractUsing);
|
SubscribeLocalEvent<SeedExtractorComponent, InteractUsingEvent>(OnInteractUsing);
|
||||||
|
SubscribeLocalEvent<SeedExtractorComponent, RefreshPartsEvent>(OnRefreshParts);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnInteractUsing(EntityUid uid, SeedExtractorComponent component, InteractUsingEvent args)
|
private void OnInteractUsing(EntityUid uid, SeedExtractorComponent seedExtractor, InteractUsingEvent args)
|
||||||
{
|
{
|
||||||
if (!this.IsPowered(uid, EntityManager))
|
if (!this.IsPowered(uid, EntityManager))
|
||||||
return;
|
return;
|
||||||
@@ -40,15 +41,21 @@ public sealed class SeedExtractorSystem : EntitySystem
|
|||||||
|
|
||||||
QueueDel(args.Used);
|
QueueDel(args.Used);
|
||||||
|
|
||||||
var random = _random.Next(component.MinSeeds, component.MaxSeeds);
|
var amount = (int) _random.NextFloat(seedExtractor.BaseMinSeeds, seedExtractor.BaseMaxSeeds + 1) * seedExtractor.SeedAmountMultiplier;
|
||||||
var coords = Transform(uid).Coordinates;
|
var coords = Transform(uid).Coordinates;
|
||||||
|
|
||||||
if (random > 1)
|
if (amount > 1)
|
||||||
seed.Unique = false;
|
seed.Unique = false;
|
||||||
|
|
||||||
for (var i = 0; i < random; i++)
|
for (var i = 0; i < amount; i++)
|
||||||
{
|
{
|
||||||
_botanySystem.SpawnSeedPacket(seed, coords);
|
_botanySystem.SpawnSeedPacket(seed, coords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnRefreshParts(EntityUid uid, SeedExtractorComponent seedExtractor, RefreshPartsEvent args)
|
||||||
|
{
|
||||||
|
var manipulatorQuality = args.PartRatings[seedExtractor.MachinePartSeedAmount];
|
||||||
|
seedExtractor.SeedAmountMultiplier = MathF.Pow(seedExtractor.PartRatingSeedAmountMultiplier, manipulatorQuality - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,7 @@
|
|||||||
- Shovel
|
- Shovel
|
||||||
- ButchCleaver
|
- ButchCleaver
|
||||||
- MicrowaveMachineCircuitboard
|
- MicrowaveMachineCircuitboard
|
||||||
|
- SeedExtractorMachineCircuitboard
|
||||||
|
|
||||||
- type: technology
|
- type: technology
|
||||||
name: technologies-advanced-surgery
|
name: technologies-advanced-surgery
|
||||||
|
|||||||
@@ -308,6 +308,24 @@
|
|||||||
DefaultPrototype: Beaker
|
DefaultPrototype: Beaker
|
||||||
ExamineName: Glass Beaker
|
ExamineName: Glass Beaker
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
id: SeedExtractorMachineCircuitboard
|
||||||
|
parent: BaseMachineCircuitboard
|
||||||
|
name: seed extractor machine board
|
||||||
|
description: A machine printed circuit board for a seed extractor
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
state: service
|
||||||
|
- type: MachineBoard
|
||||||
|
prototype: SeedExtractor
|
||||||
|
requirements:
|
||||||
|
Manipulator: 2
|
||||||
|
Capacitor: 1
|
||||||
|
materialRequirements:
|
||||||
|
# replacing the console screen
|
||||||
|
Glass: 1
|
||||||
|
Cable: 2
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: SMESMachineCircuitboard
|
id: SMESMachineCircuitboard
|
||||||
parent: BaseMachineCircuitboard
|
parent: BaseMachineCircuitboard
|
||||||
|
|||||||
@@ -289,6 +289,7 @@
|
|||||||
- WallmountSubstationElectronics
|
- WallmountSubstationElectronics
|
||||||
- EmitterCircuitboard
|
- EmitterCircuitboard
|
||||||
- GasRecyclerMachineCircuitboard
|
- GasRecyclerMachineCircuitboard
|
||||||
|
- SeedExtractorMachineCircuitboard
|
||||||
- type: MaterialStorage
|
- type: MaterialStorage
|
||||||
whitelist:
|
whitelist:
|
||||||
tags:
|
tags:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
- type: entity
|
- type: entity
|
||||||
id: SeedExtractor
|
id: SeedExtractor
|
||||||
name: seed extractor
|
name: seed extractor
|
||||||
parent: BaseMachinePowered
|
parent: [ BaseMachinePowered, ConstructibleMachine ]
|
||||||
description: Extracts seeds from produce.
|
description: Extracts seeds from produce.
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
@@ -33,3 +33,8 @@
|
|||||||
True: { visible: true }
|
True: { visible: true }
|
||||||
False: { visible: false }
|
False: { visible: false }
|
||||||
- type: SeedExtractor
|
- type: SeedExtractor
|
||||||
|
- type: Machine
|
||||||
|
board: SeedExtractorMachineCircuitboard
|
||||||
|
- type: UpgradePowerDraw
|
||||||
|
powerDrawMultiplier: 0.75
|
||||||
|
scaling: Exponential
|
||||||
|
|||||||
@@ -404,7 +404,7 @@
|
|||||||
materials:
|
materials:
|
||||||
Steel: 100
|
Steel: 100
|
||||||
Glass: 900
|
Glass: 900
|
||||||
|
|
||||||
- type: latheRecipe
|
- type: latheRecipe
|
||||||
id: GasRecyclerMachineCircuitboard
|
id: GasRecyclerMachineCircuitboard
|
||||||
icon: Objects/Misc/module.rsi/id_mod.png
|
icon: Objects/Misc/module.rsi/id_mod.png
|
||||||
@@ -412,4 +412,13 @@
|
|||||||
completetime: 4
|
completetime: 4
|
||||||
materials:
|
materials:
|
||||||
Steel: 100
|
Steel: 100
|
||||||
Glass: 900
|
Glass: 900
|
||||||
|
|
||||||
|
- type: latheRecipe
|
||||||
|
id: SeedExtractorMachineCircuitboard
|
||||||
|
icon: Objects/Misc/module.rsi/id_mod.png
|
||||||
|
result: SeedExtractorMachineCircuitboard
|
||||||
|
completetime: 4
|
||||||
|
materials:
|
||||||
|
Steel: 100
|
||||||
|
Glass: 900
|
||||||
|
|||||||
Reference in New Issue
Block a user