Refactors TemperatureComponent and AtmosExposed to ECS (#4927)
Co-authored-by: Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
This commit is contained in:
@@ -1,11 +1,8 @@
|
|||||||
using Content.Server.Atmos.EntitySystems;
|
using Robust.Shared.GameObjects;
|
||||||
using Content.Server.Temperature.Components;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.ViewVariables;
|
|
||||||
|
|
||||||
namespace Content.Server.Atmos.Components
|
namespace Content.Server.Atmos.Components
|
||||||
{
|
{
|
||||||
// TODO: Kill this. With fire.
|
// not if i get there first - Flipp
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents that entity can be exposed to Atmos
|
/// Represents that entity can be exposed to Atmos
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -13,21 +10,5 @@ namespace Content.Server.Atmos.Components
|
|||||||
public class AtmosExposedComponent : Component
|
public class AtmosExposedComponent : Component
|
||||||
{
|
{
|
||||||
public override string Name => "AtmosExposed";
|
public override string Name => "AtmosExposed";
|
||||||
|
|
||||||
[ViewVariables]
|
|
||||||
[ComponentDependency] private readonly TemperatureComponent? _temperatureComponent = null;
|
|
||||||
|
|
||||||
public void Update(GasMixture air, float frameDelta, AtmosphereSystem atmosphereSystem)
|
|
||||||
{
|
|
||||||
// TODO: I'm coming for you next, TemperatureComponent... Fear me for I am death, destroyer of shitcode.
|
|
||||||
if (_temperatureComponent != null)
|
|
||||||
{
|
|
||||||
var temperatureDelta = air.Temperature - _temperatureComponent.CurrentTemperature;
|
|
||||||
var tileHeatCapacity = atmosphereSystem.GetHeatCapacity(air);
|
|
||||||
var heat = temperatureDelta * (tileHeatCapacity * _temperatureComponent.HeatCapacity / (tileHeatCapacity + _temperatureComponent.HeatCapacity));
|
|
||||||
_temperatureComponent.ReceiveHeat(heat);
|
|
||||||
_temperatureComponent.Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
26
Content.Server/Atmos/EntitySystems/AtmosExposedSystem.cs
Normal file
26
Content.Server/Atmos/EntitySystems/AtmosExposedSystem.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using Content.Server.Atmos.Components;
|
||||||
|
using Content.Server.Temperature.Components;
|
||||||
|
using Content.Server.Temperature.Systems;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
|
||||||
|
namespace Content.Server.Atmos.EntitySystems
|
||||||
|
{
|
||||||
|
/* doesn't seem to be a use for this at the moment, so it's disabled
|
||||||
|
public class AtmosExposedSystem : EntitySystem
|
||||||
|
{}
|
||||||
|
*/
|
||||||
|
|
||||||
|
public readonly struct AtmosExposedUpdateEvent
|
||||||
|
{
|
||||||
|
public readonly EntityCoordinates Coordinates;
|
||||||
|
public readonly GasMixture GasMixture;
|
||||||
|
|
||||||
|
public AtmosExposedUpdateEvent(EntityCoordinates coordinates, GasMixture mixture)
|
||||||
|
{
|
||||||
|
Coordinates = coordinates;
|
||||||
|
GasMixture = mixture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
using Content.Server.Atmos.Components;
|
using Content.Server.Atmos.Components;
|
||||||
using Content.Server.NodeContainer.EntitySystems;
|
using Content.Server.NodeContainer.EntitySystems;
|
||||||
|
using Content.Server.Temperature.Components;
|
||||||
|
using Content.Server.Temperature.Systems;
|
||||||
using Content.Shared.Atmos.EntitySystems;
|
using Content.Shared.Atmos.EntitySystems;
|
||||||
using Content.Shared.Maps;
|
using Content.Shared.Maps;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
|
|
||||||
@@ -70,10 +73,10 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
{
|
{
|
||||||
foreach (var exposed in EntityManager.EntityQuery<AtmosExposedComponent>())
|
foreach (var exposed in EntityManager.EntityQuery<AtmosExposedComponent>())
|
||||||
{
|
{
|
||||||
// TODO ATMOS: Kill this with fire.
|
|
||||||
var tile = GetTileMixture(exposed.Owner.Transform.Coordinates);
|
var tile = GetTileMixture(exposed.Owner.Transform.Coordinates);
|
||||||
if (tile == null) continue;
|
if (tile == null) continue;
|
||||||
exposed.Update(tile, _exposedTimer, this);
|
var updateEvent = new AtmosExposedUpdateEvent(exposed.Owner.Transform.Coordinates, tile);
|
||||||
|
RaiseLocalEvent(exposed.Owner.Uid, ref updateEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
_exposedTimer -= ExposedUpdateDelay;
|
_exposedTimer -= ExposedUpdateDelay;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using Content.Server.Atmos.Components;
|
|||||||
using Content.Server.Stunnable;
|
using Content.Server.Stunnable;
|
||||||
using Content.Server.Stunnable.Components;
|
using Content.Server.Stunnable.Components;
|
||||||
using Content.Server.Temperature.Components;
|
using Content.Server.Temperature.Components;
|
||||||
|
using Content.Server.Temperature.Systems;
|
||||||
using Content.Shared.ActionBlocker;
|
using Content.Shared.ActionBlocker;
|
||||||
using Content.Shared.Alert;
|
using Content.Shared.Alert;
|
||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
@@ -27,6 +28,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
||||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||||
[Dependency] private readonly StunSystem _stunSystem = default!;
|
[Dependency] private readonly StunSystem _stunSystem = default!;
|
||||||
|
[Dependency] private readonly TemperatureSystem _temperatureSystem = default!;
|
||||||
|
|
||||||
private const float MinimumFireStacks = -10f;
|
private const float MinimumFireStacks = -10f;
|
||||||
private const float MaximumFireStacks = 20f;
|
private const float MaximumFireStacks = 20f;
|
||||||
@@ -207,14 +209,10 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
|
|
||||||
if (flammable.FireStacks > 0)
|
if (flammable.FireStacks > 0)
|
||||||
{
|
{
|
||||||
if (flammable.Owner.TryGetComponent(out TemperatureComponent? temp))
|
_temperatureSystem.ReceiveHeat(uid, 200 * flammable.FireStacks);
|
||||||
{
|
|
||||||
temp.ReceiveHeat(200 * flammable.FireStacks);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO ATMOS Fire resistance from armor
|
// TODO ATMOS Fire resistance from armor
|
||||||
var damageScale = Math.Min((int) (flammable.FireStacks * 2.5f), 10);
|
var damageScale = Math.Min((int) (flammable.FireStacks * 2.5f), 10);
|
||||||
_damageableSystem.TryChangeDamage(flammable.Owner.Uid, flammable.Damage * damageScale);
|
_damageableSystem.TryChangeDamage(uid, flammable.Damage * damageScale);
|
||||||
|
|
||||||
AdjustFireStacks(uid, -0.1f * (flammable.Resisting ? 10f : 1f), flammable);
|
AdjustFireStacks(uid, -0.1f * (flammable.Resisting ? 10f : 1f), flammable);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using Content.Server.Atmos.EntitySystems;
|
|||||||
using Content.Server.Body.Behavior;
|
using Content.Server.Body.Behavior;
|
||||||
using Content.Server.Body.Circulatory;
|
using Content.Server.Body.Circulatory;
|
||||||
using Content.Server.Temperature.Components;
|
using Content.Server.Temperature.Components;
|
||||||
|
using Content.Server.Temperature.Systems;
|
||||||
using Content.Shared.ActionBlocker;
|
using Content.Shared.ActionBlocker;
|
||||||
using Content.Shared.Alert;
|
using Content.Shared.Alert;
|
||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
@@ -238,20 +239,21 @@ namespace Content.Server.Body.Respiratory
|
|||||||
/// <param name="frameTime"></param>
|
/// <param name="frameTime"></param>
|
||||||
private void ProcessThermalRegulation(float frameTime)
|
private void ProcessThermalRegulation(float frameTime)
|
||||||
{
|
{
|
||||||
|
var temperatureSystem = EntitySystem.Get<TemperatureSystem>();
|
||||||
if (!Owner.TryGetComponent(out TemperatureComponent? temperatureComponent)) return;
|
if (!Owner.TryGetComponent(out TemperatureComponent? temperatureComponent)) return;
|
||||||
temperatureComponent.ReceiveHeat(MetabolismHeat);
|
temperatureSystem.ReceiveHeat(Owner.Uid, MetabolismHeat, temperatureComponent);
|
||||||
temperatureComponent.RemoveHeat(RadiatedHeat);
|
temperatureSystem.RemoveHeat(Owner.Uid, RadiatedHeat, temperatureComponent);
|
||||||
|
|
||||||
// implicit heat regulation
|
// implicit heat regulation
|
||||||
var tempDiff = Math.Abs(temperatureComponent.CurrentTemperature - NormalBodyTemperature);
|
var tempDiff = Math.Abs(temperatureComponent.CurrentTemperature - NormalBodyTemperature);
|
||||||
var targetHeat = tempDiff * temperatureComponent.HeatCapacity;
|
var targetHeat = tempDiff * temperatureComponent.HeatCapacity;
|
||||||
if (temperatureComponent.CurrentTemperature > NormalBodyTemperature)
|
if (temperatureComponent.CurrentTemperature > NormalBodyTemperature)
|
||||||
{
|
{
|
||||||
temperatureComponent.RemoveHeat(Math.Min(targetHeat, ImplicitHeatRegulation));
|
temperatureSystem.RemoveHeat(Owner.Uid, Math.Min(targetHeat, ImplicitHeatRegulation), temperatureComponent);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
temperatureComponent.ReceiveHeat(Math.Min(targetHeat, ImplicitHeatRegulation));
|
temperatureSystem.ReceiveHeat(Owner.Uid, Math.Min(targetHeat, ImplicitHeatRegulation), temperatureComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// recalc difference and target heat
|
// recalc difference and target heat
|
||||||
@@ -287,7 +289,7 @@ namespace Content.Server.Body.Respiratory
|
|||||||
// creadth: sweating does not help in airless environment
|
// creadth: sweating does not help in airless environment
|
||||||
if (EntitySystem.Get<AtmosphereSystem>().GetTileMixture(Owner.Transform.Coordinates) is not {})
|
if (EntitySystem.Get<AtmosphereSystem>().GetTileMixture(Owner.Transform.Coordinates) is not {})
|
||||||
{
|
{
|
||||||
temperatureComponent.RemoveHeat(Math.Min(targetHeat, SweatHeatRegulation));
|
temperatureSystem.RemoveHeat(Owner.Uid, Math.Min(targetHeat, SweatHeatRegulation), temperatureComponent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -299,7 +301,7 @@ namespace Content.Server.Body.Respiratory
|
|||||||
_isShivering = true;
|
_isShivering = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
temperatureComponent.ReceiveHeat(Math.Min(targetHeat, ShiveringHeatRegulation));
|
temperatureSystem.ReceiveHeat(Owner.Uid, Math.Min(targetHeat, ShiveringHeatRegulation), temperatureComponent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
using System;
|
|
||||||
using Content.Server.Alert;
|
|
||||||
using Content.Shared.Alert;
|
|
||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Prototypes;
|
|
||||||
|
|
||||||
namespace Content.Server.Temperature.Components
|
namespace Content.Server.Temperature.Components
|
||||||
{
|
{
|
||||||
@@ -57,82 +52,5 @@ namespace Content.Server.Temperature.Components
|
|||||||
[DataField("heatDamage", required: true)]
|
[DataField("heatDamage", required: true)]
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public DamageSpecifier HeatDamage = default!;
|
public DamageSpecifier HeatDamage = default!;
|
||||||
|
|
||||||
public void Update()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (Owner.TryGetComponent(out ServerAlertsComponent? status))
|
|
||||||
{
|
|
||||||
switch (CurrentTemperature)
|
|
||||||
{
|
|
||||||
// Cold strong.
|
|
||||||
case <= 260:
|
|
||||||
status.ShowAlert(AlertType.Cold, 3);
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Cold mild.
|
|
||||||
case <= 280 and > 260:
|
|
||||||
status.ShowAlert(AlertType.Cold, 2);
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Cold weak.
|
|
||||||
case <= 292 and > 280:
|
|
||||||
status.ShowAlert(AlertType.Cold, 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Safe.
|
|
||||||
case <= 327 and > 292:
|
|
||||||
status.ClearAlertCategory(AlertCategory.Temperature);
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Heat weak.
|
|
||||||
case <= 335 and > 327:
|
|
||||||
status.ShowAlert(AlertType.Hot, 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Heat mild.
|
|
||||||
case <= 345 and > 335:
|
|
||||||
status.ShowAlert(AlertType.Hot, 2);
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Heat strong.
|
|
||||||
case > 345:
|
|
||||||
status.ShowAlert(AlertType.Hot, 3);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Owner.HasComponent<DamageableComponent>()) return;
|
|
||||||
|
|
||||||
if (CurrentTemperature >= _heatDamageThreshold)
|
|
||||||
{
|
|
||||||
int tempDamage = (int) Math.Floor((CurrentTemperature - _heatDamageThreshold) * _tempDamageCoefficient);
|
|
||||||
EntitySystem.Get<DamageableSystem>().TryChangeDamage(Owner.Uid, HeatDamage * tempDamage);
|
|
||||||
}
|
|
||||||
else if (CurrentTemperature <= _coldDamageThreshold)
|
|
||||||
{
|
|
||||||
int tempDamage = (int) Math.Floor((_coldDamageThreshold - CurrentTemperature) * _tempDamageCoefficient);
|
|
||||||
EntitySystem.Get<DamageableSystem>().TryChangeDamage(Owner.Uid, ColdDamage * tempDamage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Forcefully give heat to this component
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="heatAmount"></param>
|
|
||||||
public void ReceiveHeat(float heatAmount)
|
|
||||||
{
|
|
||||||
CurrentTemperature += heatAmount / HeatCapacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Forcefully remove heat from this component
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="heatAmount"></param>
|
|
||||||
public void RemoveHeat(float heatAmount)
|
|
||||||
{
|
|
||||||
CurrentTemperature -= heatAmount / HeatCapacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
140
Content.Server/Temperature/Systems/TemperatureSystem.cs
Normal file
140
Content.Server/Temperature/Systems/TemperatureSystem.cs
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
using System;
|
||||||
|
using Content.Server.Alert;
|
||||||
|
using Content.Server.Atmos.EntitySystems;
|
||||||
|
using Content.Server.Temperature.Components;
|
||||||
|
using Content.Shared.Alert;
|
||||||
|
using Content.Shared.Damage;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
|
||||||
|
namespace Content.Server.Temperature.Systems
|
||||||
|
{
|
||||||
|
public class TemperatureSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
||||||
|
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
SubscribeLocalEvent<TemperatureComponent, OnTemperatureChangeEvent>(ChangeDamage);
|
||||||
|
SubscribeLocalEvent<TemperatureComponent, AtmosExposedUpdateEvent>(OnAtmosExposedUpdate);
|
||||||
|
SubscribeLocalEvent<ServerAlertsComponent, OnTemperatureChangeEvent>(ServerAlert);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ForceChangeTemperature(EntityUid uid, float temp, TemperatureComponent? temperature = null)
|
||||||
|
{
|
||||||
|
if (Resolve(uid, ref temperature))
|
||||||
|
{
|
||||||
|
float lastTemp = temperature.CurrentTemperature;
|
||||||
|
float delta = temperature.CurrentTemperature - temp;
|
||||||
|
temperature.CurrentTemperature = temp;
|
||||||
|
RaiseLocalEvent(uid, new OnTemperatureChangeEvent(temperature.CurrentTemperature, lastTemp, delta));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReceiveHeat(EntityUid uid, float heatAmount, TemperatureComponent? temperature = null)
|
||||||
|
{
|
||||||
|
if (Resolve(uid, ref temperature))
|
||||||
|
{
|
||||||
|
float lastTemp = temperature.CurrentTemperature;
|
||||||
|
temperature.CurrentTemperature += heatAmount / temperature.HeatCapacity;
|
||||||
|
float delta = temperature.CurrentTemperature - lastTemp;
|
||||||
|
|
||||||
|
RaiseLocalEvent(uid, new OnTemperatureChangeEvent(temperature.CurrentTemperature, lastTemp, delta));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveHeat(EntityUid uid, float heatAmount, TemperatureComponent? temperature = null)
|
||||||
|
{
|
||||||
|
if (Resolve(uid, ref temperature))
|
||||||
|
{
|
||||||
|
float lastTemp = temperature.CurrentTemperature;
|
||||||
|
temperature.CurrentTemperature -= heatAmount / temperature.HeatCapacity;
|
||||||
|
float delta = temperature.CurrentTemperature - lastTemp;
|
||||||
|
|
||||||
|
RaiseLocalEvent(uid, new OnTemperatureChangeEvent(temperature.CurrentTemperature, lastTemp, delta));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnAtmosExposedUpdate(EntityUid uid, TemperatureComponent temperature, ref AtmosExposedUpdateEvent args)
|
||||||
|
{
|
||||||
|
var temperatureDelta = args.GasMixture.Temperature - temperature.CurrentTemperature;
|
||||||
|
var tileHeatCapacity = _atmosphereSystem.GetHeatCapacity(args.GasMixture);
|
||||||
|
var heat = temperatureDelta * (tileHeatCapacity * temperature.HeatCapacity / (tileHeatCapacity + temperature.HeatCapacity));
|
||||||
|
ReceiveHeat(uid, heat, temperature);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ServerAlert(EntityUid uid, ServerAlertsComponent status, OnTemperatureChangeEvent args)
|
||||||
|
{
|
||||||
|
switch (args.CurrentTemperature)
|
||||||
|
{
|
||||||
|
// Cold strong.
|
||||||
|
case <= 260:
|
||||||
|
status.ShowAlert(AlertType.Cold, 3);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Cold mild.
|
||||||
|
case <= 280 and > 260:
|
||||||
|
status.ShowAlert(AlertType.Cold, 2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Cold weak.
|
||||||
|
case <= 292 and > 280:
|
||||||
|
status.ShowAlert(AlertType.Cold, 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Safe.
|
||||||
|
case <= 327 and > 292:
|
||||||
|
status.ClearAlertCategory(AlertCategory.Temperature);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Heat weak.
|
||||||
|
case <= 335 and > 327:
|
||||||
|
status.ShowAlert(AlertType.Hot, 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Heat mild.
|
||||||
|
case <= 345 and > 335:
|
||||||
|
status.ShowAlert(AlertType.Hot, 2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Heat strong.
|
||||||
|
case > 345:
|
||||||
|
status.ShowAlert(AlertType.Hot, 3);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeDamage(EntityUid uid, TemperatureComponent temperature, OnTemperatureChangeEvent args)
|
||||||
|
{
|
||||||
|
if (!EntityManager.TryGetComponent<DamageableComponent>(uid, out var damage))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (args.CurrentTemperature >= temperature.HeatDamageThreshold)
|
||||||
|
{
|
||||||
|
int tempDamage = (int) Math.Floor((args.CurrentTemperature - temperature.HeatDamageThreshold) * temperature.TempDamageCoefficient);
|
||||||
|
_damageableSystem.TryChangeDamage(uid, temperature.HeatDamage * tempDamage);
|
||||||
|
}
|
||||||
|
else if (args.CurrentTemperature <= temperature.ColdDamageThreshold)
|
||||||
|
{
|
||||||
|
int tempDamage = (int) Math.Floor((temperature.ColdDamageThreshold - args.CurrentTemperature) * temperature.TempDamageCoefficient);
|
||||||
|
_damageableSystem.TryChangeDamage(uid, temperature.ColdDamage * tempDamage);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OnTemperatureChangeEvent : EntityEventArgs
|
||||||
|
{
|
||||||
|
public float CurrentTemperature { get; }
|
||||||
|
public float LastTemperature { get; }
|
||||||
|
public float TemperatureDelta { get; }
|
||||||
|
|
||||||
|
public OnTemperatureChangeEvent(float current, float last, float delta)
|
||||||
|
{
|
||||||
|
CurrentTemperature = current;
|
||||||
|
LastTemperature = last;
|
||||||
|
TemperatureDelta = delta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user