Refactors TemperatureComponent and AtmosExposed to ECS (#4927)

Co-authored-by: Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
This commit is contained in:
Flipp Syder
2021-10-29 01:18:43 -07:00
committed by GitHub
parent 68e5a204e3
commit c7c651e3de
7 changed files with 185 additions and 117 deletions

View 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;
}
}
}

View File

@@ -1,8 +1,11 @@
using Content.Server.Atmos.Components;
using Content.Server.NodeContainer.EntitySystems;
using Content.Server.Temperature.Components;
using Content.Server.Temperature.Systems;
using Content.Shared.Atmos.EntitySystems;
using Content.Shared.Maps;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
@@ -70,10 +73,10 @@ namespace Content.Server.Atmos.EntitySystems
{
foreach (var exposed in EntityManager.EntityQuery<AtmosExposedComponent>())
{
// TODO ATMOS: Kill this with fire.
var tile = GetTileMixture(exposed.Owner.Transform.Coordinates);
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;

View File

@@ -4,6 +4,7 @@ using Content.Server.Atmos.Components;
using Content.Server.Stunnable;
using Content.Server.Stunnable.Components;
using Content.Server.Temperature.Components;
using Content.Server.Temperature.Systems;
using Content.Shared.ActionBlocker;
using Content.Shared.Alert;
using Content.Shared.Atmos;
@@ -27,6 +28,7 @@ namespace Content.Server.Atmos.EntitySystems
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly StunSystem _stunSystem = default!;
[Dependency] private readonly TemperatureSystem _temperatureSystem = default!;
private const float MinimumFireStacks = -10f;
private const float MaximumFireStacks = 20f;
@@ -207,14 +209,10 @@ namespace Content.Server.Atmos.EntitySystems
if (flammable.FireStacks > 0)
{
if (flammable.Owner.TryGetComponent(out TemperatureComponent? temp))
{
temp.ReceiveHeat(200 * flammable.FireStacks);
}
_temperatureSystem.ReceiveHeat(uid, 200 * flammable.FireStacks);
// TODO ATMOS Fire resistance from armor
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);
}