Space now has an immutable, cold atmosphere.

This commit is contained in:
Víctor Aguilera Puerto
2020-09-19 15:02:30 +02:00
parent 2eb5780303
commit cb43970188
5 changed files with 92 additions and 38 deletions

View File

@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using Content.Server.Atmos;
using Content.Server.Atmos.Reactions;
using Content.Server.GameObjects.Components.Atmos;
using Content.Shared.GameObjects.EntitySystems.Atmos;
using JetBrains.Annotations;
using Robust.Server.Interfaces.Timing;
@@ -27,6 +28,8 @@ namespace Content.Server.GameObjects.EntitySystems
private GasReactionPrototype[] _gasReactions = Array.Empty<GasReactionPrototype>();
private SpaceGridAtmosphereComponent _spaceAtmos = default!;
/// <summary>
/// List of gas reactions ordered by priority.
/// </summary>
@@ -44,17 +47,25 @@ namespace Content.Server.GameObjects.EntitySystems
_gasReactions = _protoMan.EnumeratePrototypes<GasReactionPrototype>().ToArray();
Array.Sort(_gasReactions, (a, b) => b.Priority.CompareTo(a.Priority));
_spaceAtmos = new SpaceGridAtmosphereComponent();
_spaceAtmos.Initialize();
IoCManager.InjectDependencies(_spaceAtmos);
_mapManager.TileChanged += OnTileChanged;
}
public IGridAtmosphereComponent? GetGridAtmosphere(GridId gridId)
{
// TODO Return space grid atmosphere for invalid grids or grids with no atmos
if (!gridId.IsValid())
{
return _spaceAtmos;
}
var grid = _mapManager.GetGrid(gridId);
if (!EntityManager.TryGetEntity(grid.GridEntityId, out var gridEnt)) return null;
if (!EntityManager.TryGetEntity(grid.GridEntityId, out var gridEnt)) return _spaceAtmos;
return gridEnt.TryGetComponent(out IGridAtmosphereComponent? atmos) ? atmos : null;
return gridEnt.TryGetComponent(out IGridAtmosphereComponent? atmos) ? atmos : _spaceAtmos;
}
public override void Update(float frameTime)