Files
ss14-wl/Content.Shared/Temperature/Components/TemperatureDamageComponent.cs
TemporalOroboros 6f38eed9d9 Splits temperature damage processing into its own component (#30515)
* Creates TemperatureDamageThresholdsComponent

* Obsolete TemperatureComponent fields

* Use TemperatureDamageThresholdsComponent
Moves all the uses of the relocated TemperatureComponent fields to use the TDTC versions

* Removes the obsolete TemperatureComponent fields

* Update YAML definitions

* Update doc comments

* Split TemperatureSystem
Creates TemperatureDamageSystem and moves the damage handling from TemperatureSystem

* Cull unused using statements

* Use component-based damage tick scheduling

* Fix temperature damage processing
Check was inverted resulting in things never starting to take temperature damage

* Poke tests

* Add TemperatureDamageThresholds to new prototypes

* Move TemperatureDamageThresholdsComponent to Shared
Parity with TemperatureComponent

* While I'm here
Fixes warning regarding obsolete ProtoId validator attribute

* Fix YAML errors

* Fix merge errors

* Rename TemperatureDamageThresholdsComponent -> TemperatureDamageComponent

* Use ContentHelpers.RoundToLevels for temperature alerts

* Fix YML

* A fuckton of cleanup

* working cleanup

* fix

* misc additions

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
2025-12-24 06:37:11 +00:00

95 lines
3.4 KiB
C#

using Content.Shared.Alert;
using Content.Shared.Damage;
using Content.Shared.FixedPoint;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared.Temperature.Components;
/// <summary>
/// Handles taking damage from being excessively hot/cold.
/// Also handles alerts about being too hot or too cold.
/// </summary>
[RegisterComponent]
public sealed partial class TemperatureDamageComponent : Component
{
/// <summary>
/// The temperature above which the entity will start taking damage from being too hot.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float HeatDamageThreshold = 360f;
/// <summary>
/// The temperature below which the entity will start taking damage from being too cold.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float ColdDamageThreshold = 260f;
/// <summary>
/// Overrides HeatDamageThreshold if the entity's within a parent with the ContainerTemperatureDamageThresholdsComponent component.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float? ParentHeatDamageThreshold;
/// <summary>
/// Overrides ColdDamageThreshold if the entity's within a parent with the ContainerTemperatureDamageThresholdsComponent component.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float? ParentColdDamageThreshold;
/// <summary>
/// The base damage that this entity will take if it's too cold.
/// Will be scaled according to how cold it is.
/// The scaling maxes out at <see cref="DamageCap"/> times this damage per second.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public DamageSpecifier ColdDamage = new();
/// <summary>
/// The base damage that this entity will take per second if it's too hot.
/// Will be scaled according to how hot it is.
/// The scaling maxes out at <see cref="DamageCap"/> times this damage per second.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public DamageSpecifier HeatDamage = new();
/// <summary>
/// Temperature won't do more than this multiple of the base overheating/overcooling damage per seond.
/// </summary>
/// <remarks>
/// Okay it genuinely reaches this basically immediately for a plasma fire.
/// </remarks>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public FixedPoint2 DamageCap = FixedPoint2.New(8);
/// <summary>
/// Used to keep track of when damage starts/stops. Useful for logs.
/// </summary>
[DataField]
public bool TakingDamage;
/// <summary>
/// The id of the alert thrown when the entity is too hot.
/// </summary>
[DataField]
public ProtoId<AlertPrototype> HotAlert = "Hot";
/// <summary>
/// The id of the alert thrown when the entity is too cold.
/// </summary>
[DataField]
public ProtoId<AlertPrototype> ColdAlert = "Cold";
/// <summary>
/// The last time this entity processed temperature damage.
/// </summary>
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan LastUpdate;
/// <summary>
/// The time interval between temperature damage ticks for this entity.
/// </summary>
[DataField]
public TimeSpan UpdateInterval = TimeSpan.FromSeconds(1.0);
}