Seed extractor construction + upgrading (#11972)

This commit is contained in:
0x6273
2022-10-23 00:26:02 +02:00
committed by GitHub
parent d7bbcb07d4
commit 8718df5622
7 changed files with 81 additions and 11 deletions

View File

@@ -1,4 +1,7 @@
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;
@@ -6,8 +9,34 @@ namespace Content.Server.Botany.Components;
[Access(typeof(SeedExtractorSystem))]
public sealed class SeedExtractorComponent : Component
{
// TODO: Upgradeable machines.
[DataField("minSeeds")] public int MinSeeds = 1;
/// <summary>
/// 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;
}

View File

@@ -1,6 +1,6 @@
using Content.Server.Botany.Components;
using Content.Server.Construction;
using Content.Server.Popups;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Shared.Interaction;
using Content.Shared.Popups;
@@ -20,9 +20,10 @@ public sealed class SeedExtractorSystem : EntitySystem
base.Initialize();
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))
return;
@@ -40,15 +41,21 @@ public sealed class SeedExtractorSystem : EntitySystem
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;
if (random > 1)
if (amount > 1)
seed.Unique = false;
for (var i = 0; i < random; i++)
for (var i = 0; i < amount; i++)
{
_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);
}
}

View File

@@ -66,6 +66,7 @@
- Shovel
- ButchCleaver
- MicrowaveMachineCircuitboard
- SeedExtractorMachineCircuitboard
- type: technology
name: technologies-advanced-surgery

View File

@@ -308,6 +308,24 @@
DefaultPrototype: 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
id: SMESMachineCircuitboard
parent: BaseMachineCircuitboard

View File

@@ -289,6 +289,7 @@
- WallmountSubstationElectronics
- EmitterCircuitboard
- GasRecyclerMachineCircuitboard
- SeedExtractorMachineCircuitboard
- type: MaterialStorage
whitelist:
tags:

View File

@@ -1,7 +1,7 @@
- type: entity
id: SeedExtractor
name: seed extractor
parent: BaseMachinePowered
parent: [ BaseMachinePowered, ConstructibleMachine ]
description: Extracts seeds from produce.
components:
- type: Sprite
@@ -33,3 +33,8 @@
True: { visible: true }
False: { visible: false }
- type: SeedExtractor
- type: Machine
board: SeedExtractorMachineCircuitboard
- type: UpgradePowerDraw
powerDrawMultiplier: 0.75
scaling: Exponential

View File

@@ -413,3 +413,12 @@
materials:
Steel: 100
Glass: 900
- type: latheRecipe
id: SeedExtractorMachineCircuitboard
icon: Objects/Misc/module.rsi/id_mod.png
result: SeedExtractorMachineCircuitboard
completetime: 4
materials:
Steel: 100
Glass: 900