Remove transform methods from mapgrid (#12233)
This commit is contained in:
@@ -43,7 +43,7 @@ namespace Content.Client.Atmos.EntitySystems
|
||||
|
||||
var overlayManager = IoCManager.Resolve<IOverlayManager>();
|
||||
if(!overlayManager.HasOverlay<AtmosDebugOverlay>())
|
||||
overlayManager.AddOverlay(new AtmosDebugOverlay());
|
||||
overlayManager.AddOverlay(new AtmosDebugOverlay(this));
|
||||
}
|
||||
|
||||
private void OnGridRemoved(GridRemovalEvent ev)
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Content.Client.Atmos.EntitySystems
|
||||
SubscribeNetworkEvent<GasOverlayUpdateEvent>(HandleGasOverlayUpdate);
|
||||
SubscribeLocalEvent<GridRemovalEvent>(OnGridRemoved);
|
||||
|
||||
_overlay = new GasTileOverlay(this, _resourceCache, ProtoMan, _spriteSys);
|
||||
_overlay = new GasTileOverlay(this, EntityManager, _resourceCache, ProtoMan, _spriteSys);
|
||||
_overlayMan.AddOverlay(_overlay);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,15 +14,16 @@ namespace Content.Client.Atmos.Overlays
|
||||
{
|
||||
private readonly AtmosDebugOverlaySystem _atmosDebugOverlaySystem;
|
||||
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
||||
|
||||
public AtmosDebugOverlay()
|
||||
internal AtmosDebugOverlay(AtmosDebugOverlaySystem system)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
_atmosDebugOverlaySystem = EntitySystem.Get<AtmosDebugOverlaySystem>();
|
||||
_atmosDebugOverlaySystem = system;
|
||||
}
|
||||
|
||||
protected override void Draw(in OverlayDrawArgs args)
|
||||
@@ -41,10 +42,11 @@ namespace Content.Client.Atmos.Overlays
|
||||
|
||||
foreach (var mapGrid in _mapManager.FindGridsIntersecting(mapId, worldBounds))
|
||||
{
|
||||
if (!_atmosDebugOverlaySystem.HasData(mapGrid.GridEntityId))
|
||||
if (!_atmosDebugOverlaySystem.HasData(mapGrid.GridEntityId) ||
|
||||
!_entManager.TryGetComponent<TransformComponent>(mapGrid.GridEntityId, out var xform))
|
||||
continue;
|
||||
|
||||
drawHandle.SetTransform(mapGrid.WorldMatrix);
|
||||
drawHandle.SetTransform(xform.WorldMatrix);
|
||||
|
||||
for (var pass = 0; pass < 2; pass++)
|
||||
{
|
||||
|
||||
@@ -14,9 +14,9 @@ namespace Content.Client.Atmos.Overlays
|
||||
{
|
||||
public sealed class GasTileOverlay : Overlay
|
||||
{
|
||||
private readonly GasTileOverlaySystem _system;
|
||||
private readonly IEntityManager _entManager;
|
||||
private readonly IMapManager _mapManager;
|
||||
|
||||
|
||||
public override OverlaySpace Space => OverlaySpace.WorldSpaceEntities;
|
||||
private readonly ShaderInstance _shader;
|
||||
|
||||
@@ -43,14 +43,14 @@ namespace Content.Client.Atmos.Overlays
|
||||
|
||||
public const int GasOverlayZIndex = (int) Content.Shared.DrawDepth.DrawDepth.Effects; // Under ghosts, above mostly everything else
|
||||
|
||||
public GasTileOverlay(GasTileOverlaySystem system, IResourceCache resourceCache, IPrototypeManager protoMan, SpriteSystem spriteSys)
|
||||
public GasTileOverlay(GasTileOverlaySystem system, IEntityManager entManager, IResourceCache resourceCache, IPrototypeManager protoMan, SpriteSystem spriteSys)
|
||||
{
|
||||
_system = system;
|
||||
_entManager = entManager;
|
||||
_mapManager = IoCManager.Resolve<IMapManager>();
|
||||
_shader = protoMan.Index<ShaderPrototype>("unshaded").Instance();
|
||||
ZIndex = GasOverlayZIndex;
|
||||
|
||||
_gasCount = _system.VisibleGasId.Length;
|
||||
_gasCount = system.VisibleGasId.Length;
|
||||
_timer = new float[_gasCount];
|
||||
_frameDelays = new float[_gasCount][];
|
||||
_frameCounter = new int[_gasCount];
|
||||
@@ -58,7 +58,7 @@ namespace Content.Client.Atmos.Overlays
|
||||
|
||||
for (var i = 0; i < _gasCount; i++)
|
||||
{
|
||||
var gasPrototype = protoMan.Index<GasPrototype>(_system.VisibleGasId[i].ToString());
|
||||
var gasPrototype = protoMan.Index<GasPrototype>(system.VisibleGasId[i].ToString());
|
||||
|
||||
SpriteSpecifier overlay;
|
||||
|
||||
@@ -138,14 +138,17 @@ namespace Content.Client.Atmos.Overlays
|
||||
protected override void Draw(in OverlayDrawArgs args)
|
||||
{
|
||||
var drawHandle = args.WorldHandle;
|
||||
var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
|
||||
|
||||
foreach (var mapGrid in _mapManager.FindGridsIntersecting(args.MapId, args.WorldBounds))
|
||||
{
|
||||
if (!TileData.TryGetValue(mapGrid.GridEntityId, out var gridData))
|
||||
if (!TileData.TryGetValue(mapGrid.GridEntityId, out var gridData) ||
|
||||
!xformQuery.TryGetComponent(mapGrid.GridEntityId, out var gridXform))
|
||||
continue;
|
||||
|
||||
drawHandle.SetTransform(mapGrid.WorldMatrix);
|
||||
var floatBounds = mapGrid.InvWorldMatrix.TransformBox(in args.WorldBounds).Enlarged(mapGrid.TileSize);
|
||||
var (_, _, worldMatrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
|
||||
drawHandle.SetTransform(worldMatrix);
|
||||
var floatBounds = invMatrix.TransformBox(in args.WorldBounds).Enlarged(mapGrid.TileSize);
|
||||
var localBounds = new Box2i(
|
||||
(int) MathF.Floor(floatBounds.Left),
|
||||
(int) MathF.Floor(floatBounds.Bottom),
|
||||
@@ -166,7 +169,7 @@ namespace Content.Client.Atmos.Overlays
|
||||
if (gas.Value.Opacity == null)
|
||||
continue;
|
||||
|
||||
var tilePosition = chunk.Origin + (enumerator.X, enumerator.Y);
|
||||
var tilePosition = chunk.Origin + (enumerator.X, enumerator.Y);
|
||||
if (!localBounds.Contains(tilePosition))
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user