Machine upgrading framework [NO CONTENT YET] (#11528)
* upgrading parts baseline * don't hardcode prototypes * 0xsomethingsomething review i sorry i forgot your name
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
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
|
||||
{
|
||||
@@ -55,7 +57,7 @@ namespace Content.Server.Atmos.Piping.Unary.Components
|
||||
/// </summary>
|
||||
[DataField("baseMinTemperature")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float BaseMinTemperature = 96.625f; // Selected so that tier-1 parts can reach 73.15k
|
||||
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 laser quality. Usually the quality will be at
|
||||
@@ -78,5 +80,17 @@ namespace Content.Server.Atmos.Piping.Unary.Components
|
||||
[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 = "Laser";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
[UsedImplicitly]
|
||||
public sealed class GasThermoMachineSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!;
|
||||
|
||||
@@ -33,14 +34,12 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
|
||||
private void OnThermoMachineUpdated(EntityUid uid, GasThermoMachineComponent thermoMachine, AtmosDeviceUpdateEvent args)
|
||||
{
|
||||
var appearance = EntityManager.GetComponentOrNull<AppearanceComponent>(thermoMachine.Owner);
|
||||
|
||||
if (!thermoMachine.Enabled
|
||||
|| !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer)
|
||||
|| !nodeContainer.TryGetNode(thermoMachine.InletName, out PipeNode? inlet))
|
||||
{
|
||||
DirtyUI(uid, thermoMachine);
|
||||
appearance?.SetData(ThermoMachineVisuals.Enabled, false);
|
||||
_appearance.SetData(uid, ThermoMachineVisuals.Enabled, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,7 +48,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
|
||||
if (!MathHelper.CloseTo(combinedHeatCapacity, 0, 0.001f))
|
||||
{
|
||||
appearance?.SetData(ThermoMachineVisuals.Enabled, true);
|
||||
_appearance.SetData(uid, ThermoMachineVisuals.Enabled, true);
|
||||
var combinedEnergy = thermoMachine.HeatCapacity * thermoMachine.TargetTemperature + airHeatCapacity * inlet.Air.Temperature;
|
||||
inlet.Air.Temperature = combinedEnergy / combinedHeatCapacity;
|
||||
}
|
||||
@@ -59,38 +58,15 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
|
||||
private void OnThermoMachineLeaveAtmosphere(EntityUid uid, GasThermoMachineComponent component, AtmosDeviceDisabledEvent args)
|
||||
{
|
||||
if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
|
||||
{
|
||||
appearance.SetData(ThermoMachineVisuals.Enabled, false);
|
||||
}
|
||||
_appearance.SetData(uid, ThermoMachineVisuals.Enabled, false);
|
||||
|
||||
DirtyUI(uid, component);
|
||||
}
|
||||
|
||||
private void OnGasThermoRefreshParts(EntityUid uid, GasThermoMachineComponent component, RefreshPartsEvent args)
|
||||
{
|
||||
// Here we evaluate the average quality of relevant machine parts.
|
||||
var nLasers = 0;
|
||||
var nBins= 0;
|
||||
var matterBinRating = 0;
|
||||
var laserRating = 0;
|
||||
|
||||
foreach (var part in args.Parts)
|
||||
{
|
||||
switch (part.PartType)
|
||||
{
|
||||
case MachinePart.MatterBin:
|
||||
nBins += 1;
|
||||
matterBinRating += part.Rating;
|
||||
break;
|
||||
case MachinePart.Laser:
|
||||
nLasers += 1;
|
||||
laserRating += part.Rating;
|
||||
break;
|
||||
}
|
||||
}
|
||||
laserRating /= nLasers;
|
||||
matterBinRating /= nBins;
|
||||
var matterBinRating = args.PartRatings[component.MachinePartHeatCapacity];
|
||||
var laserRating = args.PartRatings[component.MachinePartTemperature];
|
||||
|
||||
component.HeatCapacity = 5000 * MathF.Pow(matterBinRating, 2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user