ECS Atmos Part 2: Moves a lot of Gas Mixture methods to AtmosphereSystem. (#4218)
This commit is contained in:
committed by
GitHub
parent
e16c23a747
commit
263c9ef974
@@ -1,6 +1,7 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -66,13 +67,13 @@ namespace Content.Server.Atmos.Reactions
|
||||
/// </summary>
|
||||
[DataField("effects")] private List<IGasReactionEffect> _effects = new();
|
||||
|
||||
public ReactionResult React(GasMixture mixture, IGasMixtureHolder holder, GridTileLookupSystem gridLookup)
|
||||
public ReactionResult React(GasMixture mixture, IGasMixtureHolder holder, AtmosphereSystem atmosphereSystem)
|
||||
{
|
||||
var result = ReactionResult.NoReaction;
|
||||
|
||||
foreach (var effect in _effects)
|
||||
{
|
||||
result |= effect.React(mixture, holder, gridLookup);
|
||||
result |= effect.React(mixture, holder, atmosphereSystem);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Coordinates.Helpers;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Shared.Atmos;
|
||||
@@ -13,10 +14,10 @@ namespace Content.Server.Atmos.Reactions
|
||||
[DataDefinition]
|
||||
public class PlasmaFireReaction : IGasReactionEffect
|
||||
{
|
||||
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, GridTileLookupSystem gridTileLookup)
|
||||
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem)
|
||||
{
|
||||
var energyReleased = 0f;
|
||||
var oldHeatCapacity = mixture.HeatCapacity;
|
||||
var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture);
|
||||
var temperature = mixture.Temperature;
|
||||
var location = holder as TileAtmosphere;
|
||||
mixture.ReactionResults[GasReaction.Fire] = 0;
|
||||
@@ -63,7 +64,7 @@ namespace Content.Server.Atmos.Reactions
|
||||
|
||||
if (energyReleased > 0)
|
||||
{
|
||||
var newHeatCapacity = mixture.HeatCapacity;
|
||||
var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture);
|
||||
if (newHeatCapacity > Atmospherics.MinimumHeatCapacity)
|
||||
mixture.Temperature = ((temperature * oldHeatCapacity + energyReleased) / newHeatCapacity);
|
||||
}
|
||||
@@ -75,7 +76,7 @@ namespace Content.Server.Atmos.Reactions
|
||||
{
|
||||
location.HotspotExpose(temperature, mixture.Volume);
|
||||
|
||||
foreach (var entity in location.GridIndices.GetEntitiesInTileFast(location.GridIndex, gridTileLookup))
|
||||
foreach (var entity in location.GridIndices.GetEntitiesInTileFast(location.GridIndex))
|
||||
{
|
||||
foreach (var temperatureExpose in entity.GetAllComponents<ITemperatureExpose>())
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#nullable enable
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Coordinates.Helpers;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Shared.Atmos;
|
||||
@@ -12,10 +13,10 @@ namespace Content.Server.Atmos.Reactions
|
||||
[DataDefinition]
|
||||
public class TritiumFireReaction : IGasReactionEffect
|
||||
{
|
||||
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, GridTileLookupSystem gridTileLookup)
|
||||
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem)
|
||||
{
|
||||
var energyReleased = 0f;
|
||||
var oldHeatCapacity = mixture.HeatCapacity;
|
||||
var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture);
|
||||
var temperature = mixture.Temperature;
|
||||
var location = holder as TileAtmosphere;
|
||||
mixture.ReactionResults[GasReaction.Fire] = 0f;
|
||||
@@ -42,7 +43,7 @@ namespace Content.Server.Atmos.Reactions
|
||||
if (burnedFuel > 0)
|
||||
{
|
||||
energyReleased += (Atmospherics.FireHydrogenEnergyReleased * burnedFuel);
|
||||
|
||||
|
||||
// TODO ATMOS Radiation pulse here!
|
||||
|
||||
// Conservation of mass is important.
|
||||
@@ -53,7 +54,7 @@ namespace Content.Server.Atmos.Reactions
|
||||
|
||||
if (energyReleased > 0)
|
||||
{
|
||||
var newHeatCapacity = mixture.HeatCapacity;
|
||||
var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture);
|
||||
if (newHeatCapacity > Atmospherics.MinimumHeatCapacity)
|
||||
mixture.Temperature = ((temperature * oldHeatCapacity + energyReleased) / newHeatCapacity);
|
||||
}
|
||||
@@ -65,7 +66,7 @@ namespace Content.Server.Atmos.Reactions
|
||||
{
|
||||
location.HotspotExpose(temperature, mixture.Volume);
|
||||
|
||||
foreach (var entity in location.GridIndices.GetEntitiesInTileFast(location.GridIndex, gridTileLookup))
|
||||
foreach (var entity in location.GridIndices.GetEntitiesInTileFast(location.GridIndex))
|
||||
{
|
||||
foreach (var temperatureExpose in entity.GetAllComponents<ITemperatureExpose>())
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#nullable enable
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Fluids.Components;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
@@ -22,7 +23,7 @@ namespace Content.Server.Atmos.Reactions
|
||||
|
||||
[DataField("puddlePrototype")] public string? PuddlePrototype { get; } = "PuddleSmear";
|
||||
|
||||
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, GridTileLookupSystem gridTileLookup)
|
||||
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem)
|
||||
{
|
||||
// If any of the prototypes is invalid, we do nothing.
|
||||
if (string.IsNullOrEmpty(Reagent) || string.IsNullOrEmpty(PuddlePrototype)) return ReactionResult.NoReaction;
|
||||
|
||||
Reference in New Issue
Block a user