Gas overlay chunking (#1678)

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2020-08-18 00:12:21 +10:00
committed by GitHub
parent 0e6f55a23d
commit f54ba4b6d5
16 changed files with 786 additions and 306 deletions

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Shared.Atmos
{
@@ -14,10 +15,18 @@ namespace Content.Shared.Atmos
var protoMan = IoCManager.Resolve<IPrototypeManager>();
GasPrototypes = new GasPrototype[TotalNumberOfGases];
GasOverlays = new SpriteSpecifier[TotalNumberOfGases];
for (var i = 0; i < TotalNumberOfGases; i++)
{
GasPrototypes[i] = protoMan.Index<GasPrototype>(i.ToString());
var gasPrototype = protoMan.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);
}
}
@@ -27,6 +36,10 @@ namespace Content.Shared.Atmos
public static GasPrototype GetGas(Gas gasId) => GasPrototypes[(int) gasId];
public static IEnumerable<GasPrototype> Gases => GasPrototypes;
private static readonly SpriteSpecifier[] GasOverlays;
public static SpriteSpecifier GetOverlay(int overlayId) => GasOverlays[overlayId];
#region ATMOS
/// <summary>
/// The universal gas constant, in kPa*L/(K*mol)
@@ -166,7 +179,7 @@ namespace Content.Shared.Atmos
/// <summary>
/// Total number of gases. Increase this if you want to add more!
/// </summary>
public const int TotalNumberOfGases = 6;
public const byte TotalNumberOfGases = 6;
/// <summary>
/// Amount of heat released per mole of burnt hydrogen or tritium (hydrogen isotope)

View File

@@ -45,23 +45,6 @@ namespace Content.Shared.Atmos
/// </summary>
public string GasOverlaySprite { get; set; }
/// <summary>
/// Sprite specifier for the gas overlay.
/// </summary>
public SpriteSpecifier GasOverlay
{
get
{
if(string.IsNullOrEmpty(GasOverlaySprite) && !string.IsNullOrEmpty(GasOverlayTexture))
return new SpriteSpecifier.Texture(new ResourcePath(GasOverlayTexture));
if(!string.IsNullOrEmpty(GasOverlaySprite) && !string.IsNullOrEmpty(GasOverlayState))
return new SpriteSpecifier.Rsi(new ResourcePath(GasOverlaySprite), GasOverlayState);
return null;
}
}
/// <summary>
/// Path to the tile overlay used when this gas appears visible.
/// </summary>