using Content.Shared.Emag.Components;
using Content.Shared.Lathe;
using Content.Shared.Materials;
+using Content.Shared.ReagentSpeed;
using Content.Shared.Research.Components;
using Content.Shared.Research.Prototypes;
using JetBrains.Annotations;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly UserInterfaceSystem _uiSys = default!;
[Dependency] private readonly MaterialStorageSystem _materialStorage = default!;
+ [Dependency] private readonly ReagentSpeedSystem _reagentSpeed = default!;
[Dependency] private readonly StackSystem _stack = default!;
[Dependency] private readonly TransformSystem _transform = default!;
var recipe = component.Queue.First();
component.Queue.RemoveAt(0);
+ var time = _reagentSpeed.ApplySpeed(uid, recipe.CompleteTime);
+
var lathe = EnsureComp<LatheProducingComponent>(uid);
lathe.StartTime = _timing.CurTime;
- lathe.ProductionLength = recipe.CompleteTime * component.TimeMultiplier;
+ lathe.ProductionLength = time * component.TimeMultiplier;
component.CurrentRecipe = recipe;
var ev = new LatheStartPrintingEvent(recipe);
--- /dev/null
+using Content.Shared.Chemistry.Reagent;
+using Content.Shared.FixedPoint;
+using Robust.Shared.Prototypes;
+
+namespace Content.Shared.ReagentSpeed;
+
+/// <summary>
+/// Makes a device work faster by consuming reagents on each use.
+/// Other systems must use <see cref="ReagentSpeedSystem.ApplySpeed"/> for this to do anything.
+/// </summary>
+[RegisterComponent, Access(typeof(ReagentSpeedSystem))]
+public sealed partial class ReagentSpeedComponent : Component
+{
+ /// <summary>
+ /// Solution that will be checked.
+ /// Anything that isn't in <c>Modifiers</c> is left alone.
+ /// </summary>
+ [DataField(required: true)]
+ public string Solution = string.Empty;
+
+ /// <summary>
+ /// How much reagent from the solution to use up for each use.
+ /// This is per-modifier-reagent and not shared between them.
+ /// </summary>
+ [DataField]
+ public FixedPoint2 Cost = 5;
+
+ /// <summary>
+ /// Reagents and how much they modify speed at full purity.
+ /// Small number means faster large number means slower.
+ /// </summary>
+ [DataField(required: true)]
+ public Dictionary<ProtoId<ReagentPrototype>, float> Modifiers = new();
+}
--- /dev/null
+using Content.Shared.Chemistry.EntitySystems;
+
+namespace Content.Shared.ReagentSpeed;
+
+public sealed class ReagentSpeedSystem : EntitySystem
+{
+ [Dependency] private readonly SharedSolutionContainerSystem _solution = default!;
+
+ /// <summary>
+ /// Consumes reagents and modifies the duration.
+ /// This can be production time firing delay etc.
+ /// </summary>
+ public TimeSpan ApplySpeed(Entity<ReagentSpeedComponent?> ent, TimeSpan time)
+ {
+ if (!Resolve(ent, ref ent.Comp, false))
+ return time;
+
+ if (!_solution.TryGetSolution(ent.Owner, ent.Comp.Solution, out _, out var solution))
+ return time;
+
+ foreach (var (reagent, fullModifier) in ent.Comp.Modifiers)
+ {
+ var used = solution.RemoveReagent(reagent, ent.Comp.Cost);
+ var efficiency = (used / ent.Comp.Cost).Float();
+ // scale the speed modifier so microdosing has less effect
+ var reduction = (1f - fullModifier) * efficiency;
+ var modifier = 1f - reduction;
+ time *= modifier;
+ }
+
+ return time;
+ }
+}
- type: ResearchClient
- type: TechnologyDatabase
+# a lathe that can be sped up with space lube / slowed down with glue
- type: entity
- id: Autolathe
+ abstract: true
parent: BaseLathe
+ id: BaseLatheLube
+ components:
+ - type: ReagentSpeed
+ solution: lube
+ modifiers:
+ SpaceLube: 0.25
+ SpaceGlue: 5
+ - type: SolutionContainerManager
+ solutions:
+ lube:
+ maxVol: 250
+ - type: Spillable
+ solution: lube
+ - type: RefillableSolution
+ solution: lube
+ - type: ExaminableSolution
+ solution: lube
+
+- type: entity
+ abstract: true
+ id: BaseHyperlathe
+ components:
+ - type: Lathe
+ materialUseMultiplier: 0.5
+ timeMultiplier: 1.5
+ - type: LatheHeatProducing
+ - type: ReagentSpeed
+ modifiers:
+ SpaceLube: 0.8 # being faster means less heat so lube needs to be nerfed
+ SpaceGlue: 5 # no change from normal lathe, overheat!!!
+
+- type: entity
+ id: Autolathe
+ parent: BaseLatheLube
name: autolathe
description: It produces items using metal and glass.
components:
- type: entity
id: AutolatheHyperConvection
- parent: Autolathe
+ parent: [Autolathe, BaseHyperlathe]
name: hyper convection autolathe
description: A highly-experimental autolathe that harnesses the power of extreme heat to slowly create objects more cost-effectively.
components:
- type: Sprite
sprite: Structures/Machines/autolathe_hypercon.rsi
- - type: Lathe
- materialUseMultiplier: 0.5
- timeMultiplier: 1.5
- - type: LatheHeatProducing
- type: Machine
board: AutolatheHyperConvectionMachineCircuitboard
- type: entity
id: Protolathe
- parent: BaseLathe
+ parent: BaseLatheLube
name: protolathe
description: Converts raw materials into useful objects.
components:
- type: entity
id: ProtolatheHyperConvection
- parent: Protolathe
+ parent: [Protolathe, BaseHyperlathe]
name: hyper convection protolathe
description: A highly-experimental protolathe that harnesses the power of extreme heat to slowly create objects more cost-effectively.
components:
- type: Sprite
sprite: Structures/Machines/protolathe_hypercon.rsi
- - type: Lathe
- materialUseMultiplier: 0.5
- timeMultiplier: 1.5
- - type: LatheHeatProducing
- type: Machine
board: ProtolatheHyperConvectionMachineCircuitboard
- type: entity
id: CircuitImprinter
- parent: BaseLathe
+ parent: BaseLatheLube
name: circuit imprinter
description: Prints circuit boards for machines.
components:
- type: entity
id: ExosuitFabricator
- parent: BaseLathe
+ parent: BaseLatheLube
name: exosuit fabricator
description: Creates parts for robotics and other mechanical needs
components:
- type: entity
id: SecurityTechFab
- parent: BaseLathe
+ parent: BaseLatheLube
name: security techfab
description: Prints equipment for use by security crew.
components:
- type: entity
id: AmmoTechFab
- parent: BaseLathe
+ parent: BaseLatheLube
name: ammo techfab
description: Prints the bare minimum of bullets that any budget military or armory could need. Nothing fancy.
components:
- type: entity
id: MedicalTechFab
- parent: BaseLathe
+ parent: BaseLatheLube
name: medical techfab
description: Prints equipment for use by the medbay.
components: