using Content.Shared.Atmos; using Content.Shared.Atmos.EntitySystems; using Robust.Shared.Serialization; namespace Content.Shared.Temperature.HeatContainer; /// /// A general-purpose container for heat energy. /// Any object that contains, stores, or transfers heat should use a /// instead of implementing its own system. /// This allows for consistent heat transfer mechanics across different objects and systems. /// [Serializable, NetSerializable, DataDefinition] [Access(typeof(HeatContainerHelpers), typeof(SharedAtmosphereSystem))] public partial struct HeatContainer : IRobustCloneable { /// /// The heat capacity of this container in Joules per Kelvin. /// This determines how much energy is required to change the temperature of the container. /// Higher values mean the container can absorb or release more heat energy /// without a significant change in temperature. /// [DataField] public float HeatCapacity = 4000f; // about 1kg of water /// /// The current temperature of the container in Kelvin. /// [DataField] public float Temperature = Atmospherics.T20C; // room temperature /// /// The current temperature of the container in Celsius. /// Ideal if you just need to read the temperature for UI. /// Do not perform computations in Celsius/set this value, use Kelvin instead. /// [ViewVariables] public float TemperatureC => TemperatureHelpers.KelvinToCelsius(Temperature); /// /// The current thermal energy of the container in Joules. /// [ViewVariables] public float InternalEnergy => Temperature * HeatCapacity; public HeatContainer(float heatCapacity, float temperature) { HeatCapacity = heatCapacity; Temperature = temperature; } /// /// Copy constructor for implementing ICloneable. /// /// The HeatContainer to copy. private HeatContainer(HeatContainer c) { HeatCapacity = c.HeatCapacity; Temperature = c.Temperature; } public HeatContainer Clone() { return new HeatContainer(this); } }