Fires burn bright (#6516)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
hubismal
2022-02-08 04:43:33 -06:00
committed by GitHub
parent 11f650a459
commit 1c6df07086
4 changed files with 100 additions and 20 deletions

View File

@@ -0,0 +1,57 @@
using Content.Client.Atmos.EntitySystems;
using Robust.Client.Graphics;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using Robust.Shared.Map;
namespace Content.Client.Atmos.Overlays
{
public sealed class FireTileOverlay : Overlay
{
private readonly GasTileOverlaySystem _gasTileOverlaySystem;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV;
private readonly ShaderInstance _shader;
public FireTileOverlay()
{
IoCManager.InjectDependencies(this);
_gasTileOverlaySystem = EntitySystem.Get<GasTileOverlaySystem>();
_shader = _prototypeManager.Index<ShaderPrototype>("unshaded").Instance().Duplicate();
ZIndex = GasTileOverlaySystem.GasOverlayZIndex + 1;
}
protected override void Draw(in OverlayDrawArgs args)
{
var drawHandle = args.WorldHandle;
var mapId = args.Viewport.Eye!.Position.MapId;
var worldBounds = args.WorldBounds;
drawHandle.UseShader(_shader);
foreach (var mapGrid in _mapManager.FindGridsIntersecting(mapId, worldBounds))
{
if (!_gasTileOverlaySystem.HasData(mapGrid.Index))
continue;
drawHandle.SetTransform(mapGrid.WorldMatrix);
foreach (var tile in mapGrid.GetTilesIntersecting(worldBounds))
{
var enumerator = _gasTileOverlaySystem.GetFireOverlays(mapGrid.Index, tile.GridIndices);
while (enumerator.MoveNext(out var tuple))
{
drawHandle.DrawTexture(tuple.Texture, new Vector2(tile.X, tile.Y), tuple.Color);
}
}
}
drawHandle.SetTransform(Matrix3.Identity);
}
}
}

View File

@@ -8,7 +8,7 @@ using Robust.Shared.Maths;
namespace Content.Client.Atmos.Overlays
{
public class GasTileOverlay : Overlay
public sealed class GasTileOverlay : Overlay
{
private readonly GasTileOverlaySystem _gasTileOverlaySystem;
@@ -21,6 +21,7 @@ namespace Content.Client.Atmos.Overlays
IoCManager.InjectDependencies(this);
_gasTileOverlaySystem = EntitySystem.Get<GasTileOverlaySystem>();
ZIndex = GasTileOverlaySystem.GasOverlayZIndex;
}
protected override void Draw(in OverlayDrawArgs args)
@@ -46,8 +47,6 @@ namespace Content.Client.Atmos.Overlays
}
}
}
drawHandle.SetTransform(Matrix3.Identity);
}
}
}