Gas tile overlay state handling changes (#12691)

This commit is contained in:
Leon Friedrich
2022-12-19 08:25:27 +13:00
committed by GitHub
parent 195bf86fe2
commit 2759ef009e
11 changed files with 268 additions and 108 deletions

View File

@@ -1,5 +1,6 @@
using Content.Client.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Components;
using Content.Shared.Atmos.Prototypes;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
@@ -20,8 +21,6 @@ namespace Content.Client.Atmos.Overlays
public override OverlaySpace Space => OverlaySpace.WorldSpaceEntities;
private readonly ShaderInstance _shader;
public readonly Dictionary<EntityUid, Dictionary<Vector2i, GasOverlayChunk>> TileData = new();
// Gas overlays
private readonly float[] _timer;
private readonly float[][] _frameDelays;
@@ -139,12 +138,15 @@ namespace Content.Client.Atmos.Overlays
{
var drawHandle = args.WorldHandle;
var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
var overlayQuery = _entManager.GetEntityQuery<GasTileOverlayComponent>();
foreach (var mapGrid in _mapManager.FindGridsIntersecting(args.MapId, args.WorldBounds))
{
if (!TileData.TryGetValue(mapGrid.Owner, out var gridData) ||
if (!overlayQuery.TryGetComponent(mapGrid.Owner, out var comp) ||
!xformQuery.TryGetComponent(mapGrid.Owner, out var gridXform))
{
continue;
}
var (_, _, worldMatrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
drawHandle.SetTransform(worldMatrix);
@@ -160,7 +162,7 @@ namespace Content.Client.Atmos.Overlays
// by chunk, even though its currently slower.
drawHandle.UseShader(null);
foreach (var chunk in gridData.Values)
foreach (var chunk in comp.Chunks.Values)
{
var enumerator = new GasChunkEnumerator(chunk);
@@ -184,7 +186,7 @@ namespace Content.Client.Atmos.Overlays
// And again for fire, with the unshaded shader
drawHandle.UseShader(_shader);
foreach (var chunk in gridData.Values)
foreach (var chunk in comp.Chunks.Values)
{
var enumerator = new GasChunkEnumerator(chunk);