Files
tbd-station-14/Content.Server/GameObjects/Components/Atmos/AtmosExposedComponent.cs
Paul Ritter 844e4f6e50 The power of componentdependencies (#2211)
* stuff

* bucklemeup

* powerreceiver

* things

* Update RobustToolbox

* Fix nullability errors

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
2020-10-13 21:51:54 +02:00

47 lines
1.6 KiB
C#

#nullable enable
using Content.Server.Atmos;
using Content.Server.GameObjects.Components.Temperature;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.ComponentDependencies;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Atmos
{
/// <summary>
/// Represents that entity can be exposed to Atmos
/// </summary>
[RegisterComponent]
public class AtmosExposedComponent
: Component
{
public override string Name => "AtmosExposed";
[ViewVariables]
[ComponentDependency] private readonly TemperatureComponent? _temperatureComponent = null;
[ViewVariables]
[ComponentDependency] private readonly BarotraumaComponent? _barotraumaComponent = null;
[ViewVariables]
[ComponentDependency] private readonly FlammableComponent? _flammableComponent = null;
public void Update(TileAtmosphere tile, float frameDelta)
{
if (_temperatureComponent != null)
{
if (tile.Air != null)
{
var temperatureDelta = tile.Air.Temperature - _temperatureComponent.CurrentTemperature;
var heat = temperatureDelta * (tile.Air.HeatCapacity * _temperatureComponent.HeatCapacity / (tile.Air.HeatCapacity + _temperatureComponent.HeatCapacity));
_temperatureComponent.ReceiveHeat(heat);
}
_temperatureComponent.Update();
}
_barotraumaComponent?.Update(tile.Air?.Pressure ?? 0);
_flammableComponent?.Update(tile);
}
}
}