Optimize gas overlays slightly
This commit is contained in:
@@ -9,6 +9,7 @@ using Robust.Client.Graphics;
|
|||||||
using Robust.Client.ResourceManagement;
|
using Robust.Client.ResourceManagement;
|
||||||
using Robust.Client.Utility;
|
using Robust.Client.Utility;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
@@ -143,30 +144,26 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
return _tileData.ContainsKey(gridId);
|
return _tileData.ContainsKey(gridId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public (Texture, Color color)[] GetOverlays(GridId gridIndex, Vector2i indices)
|
public IEnumerable<(Texture, Color)> GetOverlays(GridId gridIndex, Vector2i indices)
|
||||||
{
|
{
|
||||||
if (!_tileData.TryGetValue(gridIndex, out var chunks))
|
if (!_tileData.TryGetValue(gridIndex, out var chunks))
|
||||||
return Array.Empty<(Texture, Color)>();
|
yield break;
|
||||||
|
|
||||||
var chunkIndex = GetGasChunkIndices(indices);
|
var chunkIndex = GetGasChunkIndices(indices);
|
||||||
if (!chunks.TryGetValue(chunkIndex, out var chunk))
|
if (!chunks.TryGetValue(chunkIndex, out var chunk))
|
||||||
return Array.Empty<(Texture, Color)>();
|
yield break;
|
||||||
|
|
||||||
var overlays = chunk.GetData(indices);
|
var overlays = chunk.GetData(indices);
|
||||||
|
|
||||||
if (overlays.Gas == null)
|
if (overlays.Gas == null)
|
||||||
return Array.Empty<(Texture, Color)>();
|
yield break;
|
||||||
|
|
||||||
var fire = overlays.FireState != 0;
|
var fire = overlays.FireState != 0;
|
||||||
var length = overlays.Gas.Length + (fire ? 1 : 0);
|
|
||||||
|
|
||||||
var list = new (Texture, Color)[length];
|
foreach (var gasData in overlays.Gas)
|
||||||
|
|
||||||
for (var i = 0; i < overlays.Gas.Length; i++)
|
|
||||||
{
|
{
|
||||||
var gasData = overlays.Gas[i];
|
|
||||||
var frames = _frames[gasData.Index];
|
var frames = _frames[gasData.Index];
|
||||||
list[i] = (frames[_frameCounter[gasData.Index]], Color.White.WithAlpha(gasData.Opacity));
|
yield return (frames[_frameCounter[gasData.Index]], Color.White.WithAlpha(gasData.Opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fire)
|
if (fire)
|
||||||
@@ -174,10 +171,8 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
var state = overlays.FireState - 1;
|
var state = overlays.FireState - 1;
|
||||||
var frames = _fireFrames[state];
|
var frames = _fireFrames[state];
|
||||||
// TODO ATMOS Set color depending on temperature
|
// TODO ATMOS Set color depending on temperature
|
||||||
list[length - 1] = (frames[_fireFrameCounter[state]], Color.White);
|
yield return (frames[_fireFrameCounter[state]], Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FrameUpdate(float frameTime)
|
public override void FrameUpdate(float frameTime)
|
||||||
|
|||||||
@@ -933,16 +933,4 @@ namespace Content.Server.GameObjects.Components.Atmos
|
|||||||
// TODO ATMOS
|
// TODO ATMOS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct IntermediateTileAtmosphere
|
|
||||||
{
|
|
||||||
public readonly Vector2i Indices;
|
|
||||||
public readonly GasMixture GasMixture;
|
|
||||||
|
|
||||||
public IntermediateTileAtmosphere(Vector2i indices, GasMixture gasMixture)
|
|
||||||
{
|
|
||||||
Indices = indices;
|
|
||||||
GasMixture = gasMixture;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace Content.Shared.GameObjects.EntitySystems.Atmos
|
|||||||
{
|
{
|
||||||
FireState = fireState;
|
FireState = fireState;
|
||||||
FireTemperature = fireTemperature;
|
FireTemperature = fireTemperature;
|
||||||
Gas = gas ?? Array.Empty<GasData>();
|
Gas = gas;
|
||||||
|
|
||||||
Array.Sort(Gas, (a, b) => a.Index.CompareTo(b.Index));
|
Array.Sort(Gas, (a, b) => a.Index.CompareTo(b.Index));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user