Fix decal draw-order (#22953)
* Fix decal draw-order Using the new overlayspace ensures they don't draw above grids above them. * a
This commit is contained in:
@@ -2,18 +2,17 @@ using Content.Shared.Decals;
|
|||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
using Robust.Shared.Enums;
|
using Robust.Shared.Enums;
|
||||||
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Client.Decals.Overlays
|
namespace Content.Client.Decals.Overlays
|
||||||
{
|
{
|
||||||
public sealed class DecalOverlay : Overlay
|
public sealed class DecalOverlay : GridOverlay
|
||||||
{
|
{
|
||||||
private readonly SpriteSystem _sprites;
|
private readonly SpriteSystem _sprites;
|
||||||
private readonly IEntityManager _entManager;
|
private readonly IEntityManager _entManager;
|
||||||
private readonly IPrototypeManager _prototypeManager;
|
private readonly IPrototypeManager _prototypeManager;
|
||||||
|
|
||||||
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowEntities;
|
|
||||||
|
|
||||||
private readonly Dictionary<string, (Texture Texture, bool SnapCardinals)> _cachedTextures = new(64);
|
private readonly Dictionary<string, (Texture Texture, bool SnapCardinals)> _cachedTextures = new(64);
|
||||||
|
|
||||||
public DecalOverlay(
|
public DecalOverlay(
|
||||||
@@ -28,22 +27,29 @@ namespace Content.Client.Decals.Overlays
|
|||||||
|
|
||||||
protected override void Draw(in OverlayDrawArgs args)
|
protected override void Draw(in OverlayDrawArgs args)
|
||||||
{
|
{
|
||||||
|
if (args.MapId == MapId.Nullspace)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var grid = Grid;
|
||||||
|
|
||||||
|
if (!_entManager.TryGetComponent(grid, out DecalGridComponent? decalGrid) ||
|
||||||
|
!_entManager.TryGetComponent(grid, out TransformComponent? xform))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xform.MapID != args.MapId)
|
||||||
|
return;
|
||||||
|
|
||||||
// Shouldn't need to clear cached textures unless the prototypes get reloaded.
|
// Shouldn't need to clear cached textures unless the prototypes get reloaded.
|
||||||
var handle = args.WorldHandle;
|
var handle = args.WorldHandle;
|
||||||
var xformSystem = _entManager.System<TransformSystem>();
|
var xformSystem = _entManager.System<TransformSystem>();
|
||||||
var eyeAngle = args.Viewport.Eye?.Rotation ?? Angle.Zero;
|
var eyeAngle = args.Viewport.Eye?.Rotation ?? Angle.Zero;
|
||||||
|
|
||||||
var gridQuery = _entManager.AllEntityQueryEnumerator<DecalGridComponent, TransformComponent>();
|
|
||||||
|
|
||||||
while (gridQuery.MoveNext(out var decalGrid, out var xform))
|
|
||||||
{
|
|
||||||
if (xform.MapID != args.MapId)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var zIndexDictionary = decalGrid.DecalRenderIndex;
|
var zIndexDictionary = decalGrid.DecalRenderIndex;
|
||||||
|
|
||||||
if (zIndexDictionary.Count == 0)
|
if (zIndexDictionary.Count == 0)
|
||||||
continue;
|
return;
|
||||||
|
|
||||||
var (_, worldRot, worldMatrix) = xformSystem.GetWorldPositionRotationMatrix(xform);
|
var (_, worldRot, worldMatrix) = xformSystem.GetWorldPositionRotationMatrix(xform);
|
||||||
|
|
||||||
@@ -75,7 +81,6 @@ namespace Content.Client.Decals.Overlays
|
|||||||
handle.DrawTexture(cache.Texture, decal.Coordinates, angle, decal.Color);
|
handle.DrawTexture(cache.Texture, decal.Coordinates, angle, decal.Color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
handle.SetTransform(Matrix3.Identity);
|
handle.SetTransform(Matrix3.Identity);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user