Add internal temperatures for cooking meats (#20659)

This commit is contained in:
deltanedas
2023-10-20 21:21:49 +01:00
committed by GitHub
parent 3a561ed993
commit 68aa295a38
6 changed files with 158 additions and 22 deletions

View File

@@ -0,0 +1,48 @@
using Content.Server.Temperature.Systems;
namespace Content.Server.Temperature.Components;
/// <summary>
/// Entity has an internal temperature which conducts heat from its surface.
/// Requires <see cref="TemperatureComponent"/> to function.
/// </summary>
/// <remarks>
/// Currently this is only used for cooking but animal metabolism could use it too.
/// Too hot? Suffering heatstroke, start sweating to cool off and increase thirst.
/// Too cold? Suffering hypothermia, start shivering to warm up and increase hunger.
/// </remarks>
[RegisterComponent, Access(typeof(TemperatureSystem))]
public sealed partial class InternalTemperatureComponent : Component
{
/// <summary>
/// Internal temperature which is modified by surface temperature.
/// This gets set to <see cref="TemperatureComponent.CurrentTemperature"/> on mapinit.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float Temperature;
/// <summary>
/// Thermal conductivity of the material in W/m/K.
/// Higher conductivity means its insides will heat up faster.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float Conductivity = 0.5f;
/// <summary>
/// Average thickness between the surface and the inside.
/// For meats and such this is constant.
/// Thicker materials take longer for heat to dissipate.
/// </summary>
[DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
public float Thickness;
/// <summary>
/// Surface area in m^2 for the purpose of conducting surface temperature to the inside.
/// Larger surface area means it takes longer to heat up/cool down
/// </summary>
/// <remarks>
/// For meats etc this should just be the area of the cooked surface not the whole thing as it's only getting heat from one side usually.
/// </remarks>
[DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
public float Area;
}

View File

@@ -1,8 +1,7 @@
using Content.Server.Temperature.Systems;
using Content.Shared.Atmos;
using Content.Shared.Damage;
using Content.Shared.FixedPoint;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
namespace Content.Server.Temperature.Components;
@@ -14,6 +13,9 @@ namespace Content.Server.Temperature.Components;
[RegisterComponent]
public sealed partial class TemperatureComponent : Component
{
/// <summary>
/// Surface temperature which is modified by the environment.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float CurrentTemperature = Atmospherics.T20C;
@@ -47,16 +49,12 @@ public sealed partial class TemperatureComponent : Component
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float AtmosTemperatureTransferEfficiency = 0.1f;
[ViewVariables] public float HeatCapacity
[Obsolete("Use system method")]
public float HeatCapacity
{
get
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<PhysicsComponent>(Owner, out var physics) && physics.FixturesMass != 0)
{
return SpecificHeat * physics.FixturesMass;
}
return Atmospherics.MinimumHeatCapacity;
return IoCManager.Resolve<IEntityManager>().System<TemperatureSystem>().GetHeatCapacity(Owner, this);
}
}