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,14 +1,9 @@
|
||||
using System;
|
||||
using Content.Server.Alert;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Damage;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Temperature.Components
|
||||
{
|
||||
@@ -57,82 +52,5 @@ namespace Content.Server.Temperature.Components
|
||||
[DataField("heatDamage", required: true)]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user