make lube speed up lathes (#25515)
* add LatheGetSpeedEvent * add LatheLube system * make typical lathes accept lube * spill * :trollface: * rework to generic ReagentSpeedSystem * hyperlathe ops --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -14,6 +14,7 @@ using Content.Shared.Database;
|
|||||||
using Content.Shared.Emag.Components;
|
using Content.Shared.Emag.Components;
|
||||||
using Content.Shared.Lathe;
|
using Content.Shared.Lathe;
|
||||||
using Content.Shared.Materials;
|
using Content.Shared.Materials;
|
||||||
|
using Content.Shared.ReagentSpeed;
|
||||||
using Content.Shared.Research.Components;
|
using Content.Shared.Research.Components;
|
||||||
using Content.Shared.Research.Prototypes;
|
using Content.Shared.Research.Prototypes;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
@@ -35,6 +36,7 @@ namespace Content.Server.Lathe
|
|||||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||||
[Dependency] private readonly UserInterfaceSystem _uiSys = default!;
|
[Dependency] private readonly UserInterfaceSystem _uiSys = default!;
|
||||||
[Dependency] private readonly MaterialStorageSystem _materialStorage = default!;
|
[Dependency] private readonly MaterialStorageSystem _materialStorage = default!;
|
||||||
|
[Dependency] private readonly ReagentSpeedSystem _reagentSpeed = default!;
|
||||||
[Dependency] private readonly StackSystem _stack = default!;
|
[Dependency] private readonly StackSystem _stack = default!;
|
||||||
[Dependency] private readonly TransformSystem _transform = default!;
|
[Dependency] private readonly TransformSystem _transform = default!;
|
||||||
|
|
||||||
@@ -186,9 +188,11 @@ namespace Content.Server.Lathe
|
|||||||
var recipe = component.Queue.First();
|
var recipe = component.Queue.First();
|
||||||
component.Queue.RemoveAt(0);
|
component.Queue.RemoveAt(0);
|
||||||
|
|
||||||
|
var time = _reagentSpeed.ApplySpeed(uid, recipe.CompleteTime);
|
||||||
|
|
||||||
var lathe = EnsureComp<LatheProducingComponent>(uid);
|
var lathe = EnsureComp<LatheProducingComponent>(uid);
|
||||||
lathe.StartTime = _timing.CurTime;
|
lathe.StartTime = _timing.CurTime;
|
||||||
lathe.ProductionLength = recipe.CompleteTime * component.TimeMultiplier;
|
lathe.ProductionLength = time * component.TimeMultiplier;
|
||||||
component.CurrentRecipe = recipe;
|
component.CurrentRecipe = recipe;
|
||||||
|
|
||||||
var ev = new LatheStartPrintingEvent(recipe);
|
var ev = new LatheStartPrintingEvent(recipe);
|
||||||
|
|||||||
34
Content.Shared/ReagentSpeed/ReagentSpeedComponent.cs
Normal file
34
Content.Shared/ReagentSpeed/ReagentSpeedComponent.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
33
Content.Shared/ReagentSpeed/ReagentSpeedSystem.cs
Normal file
33
Content.Shared/ReagentSpeed/ReagentSpeedSystem.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,9 +50,44 @@
|
|||||||
- type: ResearchClient
|
- type: ResearchClient
|
||||||
- type: TechnologyDatabase
|
- type: TechnologyDatabase
|
||||||
|
|
||||||
|
# a lathe that can be sped up with space lube / slowed down with glue
|
||||||
|
- type: entity
|
||||||
|
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
|
- type: entity
|
||||||
id: Autolathe
|
id: Autolathe
|
||||||
parent: BaseLathe
|
parent: BaseLatheLube
|
||||||
name: autolathe
|
name: autolathe
|
||||||
description: It produces items using metal and glass.
|
description: It produces items using metal and glass.
|
||||||
components:
|
components:
|
||||||
@@ -215,22 +250,18 @@
|
|||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: AutolatheHyperConvection
|
id: AutolatheHyperConvection
|
||||||
parent: Autolathe
|
parent: [Autolathe, BaseHyperlathe]
|
||||||
name: hyper convection autolathe
|
name: hyper convection autolathe
|
||||||
description: A highly-experimental autolathe that harnesses the power of extreme heat to slowly create objects more cost-effectively.
|
description: A highly-experimental autolathe that harnesses the power of extreme heat to slowly create objects more cost-effectively.
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Structures/Machines/autolathe_hypercon.rsi
|
sprite: Structures/Machines/autolathe_hypercon.rsi
|
||||||
- type: Lathe
|
|
||||||
materialUseMultiplier: 0.5
|
|
||||||
timeMultiplier: 1.5
|
|
||||||
- type: LatheHeatProducing
|
|
||||||
- type: Machine
|
- type: Machine
|
||||||
board: AutolatheHyperConvectionMachineCircuitboard
|
board: AutolatheHyperConvectionMachineCircuitboard
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: Protolathe
|
id: Protolathe
|
||||||
parent: BaseLathe
|
parent: BaseLatheLube
|
||||||
name: protolathe
|
name: protolathe
|
||||||
description: Converts raw materials into useful objects.
|
description: Converts raw materials into useful objects.
|
||||||
components:
|
components:
|
||||||
@@ -334,22 +365,18 @@
|
|||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: ProtolatheHyperConvection
|
id: ProtolatheHyperConvection
|
||||||
parent: Protolathe
|
parent: [Protolathe, BaseHyperlathe]
|
||||||
name: hyper convection protolathe
|
name: hyper convection protolathe
|
||||||
description: A highly-experimental protolathe that harnesses the power of extreme heat to slowly create objects more cost-effectively.
|
description: A highly-experimental protolathe that harnesses the power of extreme heat to slowly create objects more cost-effectively.
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Structures/Machines/protolathe_hypercon.rsi
|
sprite: Structures/Machines/protolathe_hypercon.rsi
|
||||||
- type: Lathe
|
|
||||||
materialUseMultiplier: 0.5
|
|
||||||
timeMultiplier: 1.5
|
|
||||||
- type: LatheHeatProducing
|
|
||||||
- type: Machine
|
- type: Machine
|
||||||
board: ProtolatheHyperConvectionMachineCircuitboard
|
board: ProtolatheHyperConvectionMachineCircuitboard
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: CircuitImprinter
|
id: CircuitImprinter
|
||||||
parent: BaseLathe
|
parent: BaseLatheLube
|
||||||
name: circuit imprinter
|
name: circuit imprinter
|
||||||
description: Prints circuit boards for machines.
|
description: Prints circuit boards for machines.
|
||||||
components:
|
components:
|
||||||
@@ -485,7 +512,7 @@
|
|||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: ExosuitFabricator
|
id: ExosuitFabricator
|
||||||
parent: BaseLathe
|
parent: BaseLatheLube
|
||||||
name: exosuit fabricator
|
name: exosuit fabricator
|
||||||
description: Creates parts for robotics and other mechanical needs
|
description: Creates parts for robotics and other mechanical needs
|
||||||
components:
|
components:
|
||||||
@@ -643,7 +670,7 @@
|
|||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: SecurityTechFab
|
id: SecurityTechFab
|
||||||
parent: BaseLathe
|
parent: BaseLatheLube
|
||||||
name: security techfab
|
name: security techfab
|
||||||
description: Prints equipment for use by security crew.
|
description: Prints equipment for use by security crew.
|
||||||
components:
|
components:
|
||||||
@@ -764,7 +791,7 @@
|
|||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: AmmoTechFab
|
id: AmmoTechFab
|
||||||
parent: BaseLathe
|
parent: BaseLatheLube
|
||||||
name: ammo techfab
|
name: ammo techfab
|
||||||
description: Prints the bare minimum of bullets that any budget military or armory could need. Nothing fancy.
|
description: Prints the bare minimum of bullets that any budget military or armory could need. Nothing fancy.
|
||||||
components:
|
components:
|
||||||
@@ -815,7 +842,7 @@
|
|||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: MedicalTechFab
|
id: MedicalTechFab
|
||||||
parent: BaseLathe
|
parent: BaseLatheLube
|
||||||
name: medical techfab
|
name: medical techfab
|
||||||
description: Prints equipment for use by the medbay.
|
description: Prints equipment for use by the medbay.
|
||||||
components:
|
components:
|
||||||
|
|||||||
Reference in New Issue
Block a user