Hellfire Thermomachines (#23543)

* hellfire thermomachines

* slight nerf? idk

* ilya review

* Improve clarity

* Update Content.Server/Atmos/Piping/Unary/EntitySystems/GasThermoMachineSystem.cs

Co-authored-by: Kevin Zheng <kevinz5000@gmail.com>

---------

Co-authored-by: Kevin Zheng <kevinz5000@gmail.com>
This commit is contained in:
Nemanja
2024-01-07 08:55:22 -05:00
committed by GitHub
parent bc07cbc97c
commit a78e9a854e
17 changed files with 168 additions and 111 deletions

View File

@@ -17,7 +17,7 @@ public sealed partial class GasThermomachineWindow : DefaultWindow
RobustXamlLoader.Load(this); RobustXamlLoader.Load(this);
SpinboxHBox.AddChild( SpinboxHBox.AddChild(
TemperatureSpinbox = new FloatSpinBox(.1f, 2) { MaxWidth = 150, HorizontalExpand = true } TemperatureSpinbox = new FloatSpinBox(.1f, 2) { MinWidth = 150, HorizontalExpand = true }
); );
} }

View File

@@ -1,7 +1,4 @@
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.Atmos.Piping.Unary.Components;
using Content.Shared.Construction.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Atmos.Piping.Unary.Components namespace Content.Server.Atmos.Piping.Unary.Components
{ {
@@ -15,24 +12,16 @@ namespace Content.Server.Atmos.Piping.Unary.Components
/// Current electrical power consumption, in watts. Increasing power increases the ability of the /// Current electrical power consumption, in watts. Increasing power increases the ability of the
/// thermomachine to heat or cool air. /// thermomachine to heat or cool air.
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite)] [DataField, ViewVariables(VVAccess.ReadWrite)]
public float HeatCapacity = 10000; public float HeatCapacity = 5000;
/// <summary> [DataField, ViewVariables(VVAccess.ReadWrite)]
/// Base heat capacity of the device. Actual heat capacity is calculated by taking this number and doubling
/// it for every matter bin quality tier above one.
/// </summary>
[DataField("baseHeatCapacity")]
public float BaseHeatCapacity = 5000;
[DataField("targetTemperature")]
[ViewVariables(VVAccess.ReadWrite)]
public float TargetTemperature = Atmospherics.T20C; public float TargetTemperature = Atmospherics.T20C;
/// <summary> /// <summary>
/// Tolerance for temperature setpoint hysteresis. /// Tolerance for temperature setpoint hysteresis.
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadOnly)] [DataField, ViewVariables(VVAccess.ReadOnly)]
public float TemperatureTolerance = 2f; public float TemperatureTolerance = 2f;
/// <summary> /// <summary>
@@ -40,7 +29,7 @@ namespace Content.Server.Atmos.Piping.Unary.Components
/// If true, add Sign(Cp)*TemperatureTolerance to the temperature setpoint. /// If true, add Sign(Cp)*TemperatureTolerance to the temperature setpoint.
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadOnly)] [ViewVariables(VVAccess.ReadOnly)]
public bool HysteresisState = false; public bool HysteresisState;
/// <summary> /// <summary>
/// Coefficient of performance. Output power / input power. /// Coefficient of performance. Output power / input power.
@@ -51,68 +40,29 @@ namespace Content.Server.Atmos.Piping.Unary.Components
public float Cp = 0.9f; // output power / input power, positive is heat public float Cp = 0.9f; // output power / input power, positive is heat
/// <summary> /// <summary>
/// Current minimum temperature, calculated from <see cref="InitialMinTemperature"/> and <see /// Current minimum temperature
/// cref="MinTemperatureDelta"/>.
/// Ignored if heater. /// Ignored if heater.
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite)] [DataField, ViewVariables(VVAccess.ReadWrite)]
public float MinTemperature; public float MinTemperature = 73.15f;
/// <summary> /// <summary>
/// Current maximum temperature, calculated from <see cref="InitialMaxTemperature"/> and <see /// Current maximum temperature
/// cref="MaxTemperatureDelta"/>.
/// Ignored if freezer. /// Ignored if freezer.
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite)] [DataField, ViewVariables(VVAccess.ReadWrite)]
public float MaxTemperature; public float MaxTemperature = 593.15f;
/// <summary>
/// Minimum temperature the device can reach with a 0 total capacitor quality. Usually the quality will be at
/// least 1.
/// </summary>
[DataField("baseMinTemperature")]
[ViewVariables(VVAccess.ReadWrite)]
public float BaseMinTemperature = 96.625f; // Selected so that tier-1 parts can reach 73.15k
/// <summary>
/// Maximum temperature the device can reach with a 0 total capacitor quality. Usually the quality will be at
/// least 1.
/// </summary>
[DataField("baseMaxTemperature")]
[ViewVariables(VVAccess.ReadWrite)]
public float BaseMaxTemperature = Atmospherics.T20C;
/// <summary>
/// Decrease in minimum temperature, per unit machine part quality.
/// </summary>
[DataField("minTemperatureDelta")]
[ViewVariables(VVAccess.ReadWrite)]
public float MinTemperatureDelta = 23.475f; // selected so that tier-4 parts can reach TCMB
/// <summary>
/// Change in maximum temperature, per unit machine part quality.
/// </summary>
[DataField("maxTemperatureDelta")]
[ViewVariables(VVAccess.ReadWrite)]
public float MaxTemperatureDelta = 300;
/// <summary>
/// The machine part that affects the heat capacity.
/// </summary>
[DataField("machinePartHeatCapacity", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
public string MachinePartHeatCapacity = "MatterBin";
/// <summary>
/// The machine part that affects the temperature range.
/// </summary>
[DataField("machinePartTemperature", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
public string MachinePartTemperature = "Capacitor";
/// <summary> /// <summary>
/// Last amount of energy added/removed from the attached pipe network /// Last amount of energy added/removed from the attached pipe network
/// </summary> /// </summary>
[DataField("lastEnergyDelta")] [DataField, ViewVariables(VVAccess.ReadWrite)]
[ViewVariables(VVAccess.ReadWrite)]
public float LastEnergyDelta; public float LastEnergyDelta;
/// <summary>
/// An percentage of the energy change that is leaked into the surrounding environment rather than the inlet pipe.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float EnergyLeakPercentage;
} }
} }

View File

@@ -2,7 +2,6 @@ using Content.Server.Atmos.EntitySystems;
using Content.Server.Atmos.Monitor.Systems; using Content.Server.Atmos.Monitor.Systems;
using Content.Server.Atmos.Piping.Components; using Content.Server.Atmos.Piping.Components;
using Content.Server.Atmos.Piping.Unary.Components; using Content.Server.Atmos.Piping.Unary.Components;
using Content.Server.Construction;
using Content.Server.DeviceNetwork; using Content.Server.DeviceNetwork;
using Content.Server.DeviceNetwork.Components; using Content.Server.DeviceNetwork.Components;
using Content.Server.DeviceNetwork.Systems; using Content.Server.DeviceNetwork.Systems;
@@ -15,6 +14,7 @@ using Content.Shared.Atmos.Piping.Unary.Components;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Content.Server.Power.EntitySystems; using Content.Server.Power.EntitySystems;
using Content.Server.UserInterface;
using Content.Shared.Examine; using Content.Shared.Examine;
namespace Content.Server.Atmos.Piping.Unary.EntitySystems namespace Content.Server.Atmos.Piping.Unary.EntitySystems
@@ -28,17 +28,15 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
[Dependency] private readonly NodeContainerSystem _nodeContainer = default!; [Dependency] private readonly NodeContainerSystem _nodeContainer = default!;
[Dependency] private readonly DeviceNetworkSystem _deviceNetwork = default!; [Dependency] private readonly DeviceNetworkSystem _deviceNetwork = default!;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<GasThermoMachineComponent, AtmosDeviceUpdateEvent>(OnThermoMachineUpdated); SubscribeLocalEvent<GasThermoMachineComponent, AtmosDeviceUpdateEvent>(OnThermoMachineUpdated);
SubscribeLocalEvent<GasThermoMachineComponent, RefreshPartsEvent>(OnGasThermoRefreshParts);
SubscribeLocalEvent<GasThermoMachineComponent, UpgradeExamineEvent>(OnGasThermoUpgradeExamine);
SubscribeLocalEvent<GasThermoMachineComponent, ExaminedEvent>(OnExamined); SubscribeLocalEvent<GasThermoMachineComponent, ExaminedEvent>(OnExamined);
// UI events // UI events
SubscribeLocalEvent<GasThermoMachineComponent, BeforeActivatableUIOpenEvent>(OnBeforeOpened);
SubscribeLocalEvent<GasThermoMachineComponent, GasThermomachineToggleMessage>(OnToggleMessage); SubscribeLocalEvent<GasThermoMachineComponent, GasThermomachineToggleMessage>(OnToggleMessage);
SubscribeLocalEvent<GasThermoMachineComponent, GasThermomachineChangeTemperatureMessage>(OnChangeTemperature); SubscribeLocalEvent<GasThermoMachineComponent, GasThermomachineChangeTemperatureMessage>(OnChangeTemperature);
@@ -46,6 +44,11 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
SubscribeLocalEvent<GasThermoMachineComponent, DeviceNetworkPacketEvent>(OnPacketRecv); SubscribeLocalEvent<GasThermoMachineComponent, DeviceNetworkPacketEvent>(OnPacketRecv);
} }
private void OnBeforeOpened(Entity<GasThermoMachineComponent> ent, ref BeforeActivatableUIOpenEvent args)
{
DirtyUI(ent, ent.Comp);
}
private void OnThermoMachineUpdated(EntityUid uid, GasThermoMachineComponent thermoMachine, ref AtmosDeviceUpdateEvent args) private void OnThermoMachineUpdated(EntityUid uid, GasThermoMachineComponent thermoMachine, ref AtmosDeviceUpdateEvent args)
{ {
if (!(_power.IsPowered(uid) && TryComp<ApcPowerReceiverComponent>(uid, out var receiver)) if (!(_power.IsPowered(uid) && TryComp<ApcPowerReceiverComponent>(uid, out var receiver))
@@ -90,7 +93,13 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
thermoMachine.HysteresisState = false; // turn off thermoMachine.HysteresisState = false; // turn off
} }
float dQActual = dQ * scale; float dQActual = dQ * scale;
_atmosphereSystem.AddHeat(inlet.Air, dQActual); float dQLeak = dQActual * thermoMachine.EnergyLeakPercentage;
float dQPipe = dQActual - dQLeak;
_atmosphereSystem.AddHeat(inlet.Air, dQPipe);
if (_atmosphereSystem.GetContainingMixture(uid) is { } containingMixture)
_atmosphereSystem.AddHeat(containingMixture, dQLeak);
receiver.Load = thermoMachine.HeatCapacity;// * scale; // we're not ready for dynamic load yet, see note above receiver.Load = thermoMachine.HeatCapacity;// * scale; // we're not ready for dynamic load yet, see note above
} }
@@ -99,41 +108,6 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
return comp.Cp >= 0; return comp.Cp >= 0;
} }
private void OnGasThermoRefreshParts(EntityUid uid, GasThermoMachineComponent thermoMachine, RefreshPartsEvent args)
{
var heatCapacityPartRating = args.PartRatings[thermoMachine.MachinePartHeatCapacity];
thermoMachine.HeatCapacity = thermoMachine.BaseHeatCapacity * MathF.Pow(heatCapacityPartRating, 2);
var temperatureRangePartRating = args.PartRatings[thermoMachine.MachinePartTemperature];
if (IsHeater(thermoMachine))
{
// 593.15K with stock parts.
thermoMachine.MaxTemperature = thermoMachine.BaseMaxTemperature + thermoMachine.MaxTemperatureDelta * temperatureRangePartRating;
thermoMachine.MinTemperature = Atmospherics.T20C;
}
else {
// 73.15K with stock parts.
thermoMachine.MinTemperature = MathF.Max(
thermoMachine.BaseMinTemperature - thermoMachine.MinTemperatureDelta * temperatureRangePartRating, Atmospherics.TCMB);
thermoMachine.MaxTemperature = Atmospherics.T20C;
}
DirtyUI(uid, thermoMachine);
}
private void OnGasThermoUpgradeExamine(EntityUid uid, GasThermoMachineComponent thermoMachine, UpgradeExamineEvent args)
{
if (IsHeater(thermoMachine))
{
args.AddPercentageUpgrade("gas-thermo-component-upgrade-heating", thermoMachine.MaxTemperature / (thermoMachine.BaseMaxTemperature + thermoMachine.MaxTemperatureDelta));
}
else
{
args.AddPercentageUpgrade("gas-thermo-component-upgrade-cooling", thermoMachine.MinTemperature / (thermoMachine.BaseMinTemperature - thermoMachine.MinTemperatureDelta));
}
args.AddPercentageUpgrade("gas-thermo-component-upgrade-heat-capacity", thermoMachine.HeatCapacity / thermoMachine.BaseHeatCapacity);
}
private void OnToggleMessage(EntityUid uid, GasThermoMachineComponent thermoMachine, GasThermomachineToggleMessage args) private void OnToggleMessage(EntityUid uid, GasThermoMachineComponent thermoMachine, GasThermomachineToggleMessage args)
{ {
_power.TogglePower(uid); _power.TogglePower(uid);

View File

@@ -394,6 +394,46 @@
deconstructionTarget: null deconstructionTarget: null
node: heater node: heater
- type: entity
parent: BaseMachineCircuitboard
id: HellfireFreezerMachineCircuitBoard
name: hellfire freezer machine board
description: Looks like you could use a screwdriver to change the board type.
components:
- type: Sprite
state: engineering
- type: MachineBoard
prototype: GasThermoMachineHellfireFreezer
requirements:
MatterBin: 2
Capacitor: 2
materialRequirements:
Plasma: 1
- type: Construction
deconstructionTarget: null
graph: ThermomachineBoard
node: hellfirefreezer
- type: entity
parent: BaseMachineCircuitboard
id: HellfireHeaterMachineCircuitBoard
name: hellfire heater machine board
description: Looks like you could use a screwdriver to change the board type.
components:
- type: Sprite
state: engineering
- type: MachineBoard
prototype: GasThermoMachineHellfireHeater
requirements:
MatterBin: 2
Capacitor: 2
materialRequirements:
Plasma: 1
- type: Construction
graph: ThermomachineBoard
deconstructionTarget: null
node: hellfireheater
- type: entity - type: entity
id: CondenserMachineCircuitBoard id: CondenserMachineCircuitBoard
parent: BaseMachineCircuitboard parent: BaseMachineCircuitboard

View File

@@ -366,6 +366,7 @@
- FloorBlueCircuit - FloorBlueCircuit
dynamicRecipes: dynamicRecipes:
- ThermomachineFreezerMachineCircuitBoard - ThermomachineFreezerMachineCircuitBoard
- HellfireFreezerMachineCircuitBoard
- PortableScrubberMachineCircuitBoard - PortableScrubberMachineCircuitBoard
- CloningPodMachineCircuitboard - CloningPodMachineCircuitboard
- MedicalScannerMachineCircuitboard - MedicalScannerMachineCircuitboard

View File

@@ -356,6 +356,36 @@
- type: ApcPowerReceiver - type: ApcPowerReceiver
powerDisabled: false powerDisabled: false
- type: entity
parent: GasThermoMachineFreezer
id: GasThermoMachineHellfireFreezer
name: hellfire freezer
description: An advanced machine that cools gas in connected pipes. Has the side effect of chilling the surrounding area. Cold as Hell!
components:
- type: Sprite
sprite: Structures/Piping/Atmospherics/hellfirethermomachine.rsi
- type: GasThermoMachine
minTemperature: 23.15
heatCapacity: 40000
energyLeakPercentage: 0.15
- type: Machine
board: HellfireFreezerMachineCircuitBoard
- type: entity
parent: GasThermoMachineHeater
id: GasThermoMachineHellfireHeater
name: hellfire heater
description: An advanced machine that heats gas in connected pipes. Has the side effect of leaking heat into the surrounding area. Hot as Hell!
components:
- type: Sprite
sprite: Structures/Piping/Atmospherics/hellfirethermomachine.rsi
- type: GasThermoMachine
maxTemperature: 1193.15
heatCapacity: 40000
energyLeakPercentage: 0.15
- type: Machine
board: HellfireHeaterMachineCircuitBoard
- type: entity - type: entity
parent: [ BaseMachinePowered, ConstructibleMachine ] parent: [ BaseMachinePowered, ConstructibleMachine ]
id: BaseGasCondenser id: BaseGasCondenser

View File

@@ -16,3 +16,17 @@
steps: steps:
- tool: Screwing - tool: Screwing
doAfter: 2 doAfter: 2
- node: hellfirefreezer
entity: HellfireFreezerMachineCircuitBoard
edges:
- to: hellfireheater
steps:
- tool: Screwing
doAfter: 2
- node: hellfireheater
entity: HellfireHeaterMachineCircuitBoard
edges:
- to: hellfirefreezer
steps:
- tool: Screwing
doAfter: 2

View File

@@ -104,6 +104,15 @@
Glass: 900 Glass: 900
Gold: 50 Gold: 50
- type: latheRecipe
id: HellfireFreezerMachineCircuitBoard
result: HellfireFreezerMachineCircuitBoard
completetime: 4
materials:
Steel: 150
Glass: 900
Gold: 50
- type: latheRecipe - type: latheRecipe
id: CondenserMachineCircuitBoard id: CondenserMachineCircuitBoard
result: CondenserMachineCircuitBoard result: CondenserMachineCircuitBoard

View File

@@ -157,10 +157,11 @@
state: icon state: icon
discipline: Industrial discipline: Industrial
tier: 2 tier: 2
cost: 5000 cost: 7500
recipeUnlocks: recipeUnlocks:
- HolofanProjector - HellfireFreezerMachineCircuitBoard
- PortableScrubberMachineCircuitBoard - PortableScrubberMachineCircuitBoard
- HolofanProjector
- type: technology - type: technology
id: AdvancedToolsTechnology id: AdvancedToolsTechnology

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

View File

@@ -0,0 +1,38 @@
{
"version":1,
"size":{"x":32,"y":32},
"copyright":"Base sprites taken from tgstation, split to display on two layers (machinebody/panel) by Menshin, and recolored and edited by EmoGarbage404 (github)",
"license":"CC-BY-SA-3.0",
"states":[
{
"name":"freezerOff",
"directions":1
},
{
"name":"freezerPanelOpen",
"directions":1
},
{
"name":"freezerOn",
"directions":1,
"delays":[ [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] ]
},
{
"name":"heaterOff",
"directions":1
},
{
"name":"heaterPanelOpen",
"directions":1
},
{
"name":"heaterOn",
"directions":1,
"delays":[ [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] ]
},
{
"name":"pipe",
"directions":4
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B