Files
tbd-station-14/Content.Shared/GameObjects/EntitySystems/Atmos/SharedAtmosphereSystem.cs
Víctor Aguilera Puerto b18ee3ec49 SIMD-accelerated gas mixtures. (SIMD atmos) (#2479)
* SIMD atmos

* Moles will always be a multiple of four.

* Component dependencies for grid atmos.

* Let's optimize allocations while we're at it!

* Inline this

* A bunch of atmos optimizations

* Fix crimes against atmos

* Microsoft moment

* Remove nuget.config

* do not reference Robust.UnitTests in Content.Benchmarks as it's unneeded.

* Revert "Remove nuget.config"

This reverts commit 872604ae6a51365af4075bb23687bd005befd8ac.

* Gas overlay optimization and fixes

* Lattice is now spess

* minor atmos tweaks
2020-11-25 10:48:49 +01:00

44 lines
1.7 KiB
C#

using System.Collections.Generic;
using Content.Shared.Atmos;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Shared.GameObjects.EntitySystems.Atmos
{
public class SharedAtmosphereSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
protected readonly GasPrototype[] GasPrototypes = new GasPrototype[Atmospherics.TotalNumberOfGases];
private readonly SpriteSpecifier[] _gasOverlays = new SpriteSpecifier[Atmospherics.TotalNumberOfGases];
public override void Initialize()
{
base.Initialize();
for (var i = 0; i < Atmospherics.TotalNumberOfGases; i++)
{
var gasPrototype = _prototypeManager.Index<GasPrototype>(i.ToString());
GasPrototypes[i] = gasPrototype;
if(string.IsNullOrEmpty(gasPrototype.GasOverlaySprite) && !string.IsNullOrEmpty(gasPrototype.GasOverlayTexture))
_gasOverlays[i] = new SpriteSpecifier.Texture(new ResourcePath(gasPrototype.GasOverlayTexture));
if(!string.IsNullOrEmpty(gasPrototype.GasOverlaySprite) && !string.IsNullOrEmpty(gasPrototype.GasOverlayState))
_gasOverlays[i] = new SpriteSpecifier.Rsi(new ResourcePath(gasPrototype.GasOverlaySprite), gasPrototype.GasOverlayState);
}
}
public GasPrototype GetGas(int gasId) => GasPrototypes[gasId];
public GasPrototype GetGas(Gas gasId) => GasPrototypes[(int) gasId];
public IEnumerable<GasPrototype> Gases => GasPrototypes;
public SpriteSpecifier GetOverlay(int overlayId) => _gasOverlays[overlayId];
}
}