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>();
|
var overlayManager = IoCManager.Resolve<IOverlayManager>();
|
||||||
if(!overlayManager.HasOverlay<AtmosDebugOverlay>())
|
if(!overlayManager.HasOverlay<AtmosDebugOverlay>())
|
||||||
overlayManager.AddOverlay(new AtmosDebugOverlay());
|
overlayManager.AddOverlay(new AtmosDebugOverlay(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGridRemoved(GridRemovalEvent ev)
|
private void OnGridRemoved(GridRemovalEvent ev)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace Content.Client.Atmos.EntitySystems
|
|||||||
SubscribeNetworkEvent<GasOverlayUpdateEvent>(HandleGasOverlayUpdate);
|
SubscribeNetworkEvent<GasOverlayUpdateEvent>(HandleGasOverlayUpdate);
|
||||||
SubscribeLocalEvent<GridRemovalEvent>(OnGridRemoved);
|
SubscribeLocalEvent<GridRemovalEvent>(OnGridRemoved);
|
||||||
|
|
||||||
_overlay = new GasTileOverlay(this, _resourceCache, ProtoMan, _spriteSys);
|
_overlay = new GasTileOverlay(this, EntityManager, _resourceCache, ProtoMan, _spriteSys);
|
||||||
_overlayMan.AddOverlay(_overlay);
|
_overlayMan.AddOverlay(_overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,15 +14,16 @@ namespace Content.Client.Atmos.Overlays
|
|||||||
{
|
{
|
||||||
private readonly AtmosDebugOverlaySystem _atmosDebugOverlaySystem;
|
private readonly AtmosDebugOverlaySystem _atmosDebugOverlaySystem;
|
||||||
|
|
||||||
|
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||||
|
|
||||||
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
||||||
|
|
||||||
public AtmosDebugOverlay()
|
internal AtmosDebugOverlay(AtmosDebugOverlaySystem system)
|
||||||
{
|
{
|
||||||
IoCManager.InjectDependencies(this);
|
IoCManager.InjectDependencies(this);
|
||||||
|
|
||||||
_atmosDebugOverlaySystem = EntitySystem.Get<AtmosDebugOverlaySystem>();
|
_atmosDebugOverlaySystem = system;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Draw(in OverlayDrawArgs args)
|
protected override void Draw(in OverlayDrawArgs args)
|
||||||
@@ -41,10 +42,11 @@ namespace Content.Client.Atmos.Overlays
|
|||||||
|
|
||||||
foreach (var mapGrid in _mapManager.FindGridsIntersecting(mapId, worldBounds))
|
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;
|
continue;
|
||||||
|
|
||||||
drawHandle.SetTransform(mapGrid.WorldMatrix);
|
drawHandle.SetTransform(xform.WorldMatrix);
|
||||||
|
|
||||||
for (var pass = 0; pass < 2; pass++)
|
for (var pass = 0; pass < 2; pass++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace Content.Client.Atmos.Overlays
|
|||||||
{
|
{
|
||||||
public sealed class GasTileOverlay : Overlay
|
public sealed class GasTileOverlay : Overlay
|
||||||
{
|
{
|
||||||
private readonly GasTileOverlaySystem _system;
|
private readonly IEntityManager _entManager;
|
||||||
private readonly IMapManager _mapManager;
|
private readonly IMapManager _mapManager;
|
||||||
|
|
||||||
public override OverlaySpace Space => OverlaySpace.WorldSpaceEntities;
|
public override OverlaySpace Space => OverlaySpace.WorldSpaceEntities;
|
||||||
@@ -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 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>();
|
_mapManager = IoCManager.Resolve<IMapManager>();
|
||||||
_shader = protoMan.Index<ShaderPrototype>("unshaded").Instance();
|
_shader = protoMan.Index<ShaderPrototype>("unshaded").Instance();
|
||||||
ZIndex = GasOverlayZIndex;
|
ZIndex = GasOverlayZIndex;
|
||||||
|
|
||||||
_gasCount = _system.VisibleGasId.Length;
|
_gasCount = system.VisibleGasId.Length;
|
||||||
_timer = new float[_gasCount];
|
_timer = new float[_gasCount];
|
||||||
_frameDelays = new float[_gasCount][];
|
_frameDelays = new float[_gasCount][];
|
||||||
_frameCounter = new int[_gasCount];
|
_frameCounter = new int[_gasCount];
|
||||||
@@ -58,7 +58,7 @@ namespace Content.Client.Atmos.Overlays
|
|||||||
|
|
||||||
for (var i = 0; i < _gasCount; i++)
|
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;
|
SpriteSpecifier overlay;
|
||||||
|
|
||||||
@@ -138,14 +138,17 @@ namespace Content.Client.Atmos.Overlays
|
|||||||
protected override void Draw(in OverlayDrawArgs args)
|
protected override void Draw(in OverlayDrawArgs args)
|
||||||
{
|
{
|
||||||
var drawHandle = args.WorldHandle;
|
var drawHandle = args.WorldHandle;
|
||||||
|
var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
|
||||||
|
|
||||||
foreach (var mapGrid in _mapManager.FindGridsIntersecting(args.MapId, args.WorldBounds))
|
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;
|
continue;
|
||||||
|
|
||||||
drawHandle.SetTransform(mapGrid.WorldMatrix);
|
var (_, _, worldMatrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
|
||||||
var floatBounds = mapGrid.InvWorldMatrix.TransformBox(in args.WorldBounds).Enlarged(mapGrid.TileSize);
|
drawHandle.SetTransform(worldMatrix);
|
||||||
|
var floatBounds = invMatrix.TransformBox(in args.WorldBounds).Enlarged(mapGrid.TileSize);
|
||||||
var localBounds = new Box2i(
|
var localBounds = new Box2i(
|
||||||
(int) MathF.Floor(floatBounds.Left),
|
(int) MathF.Floor(floatBounds.Left),
|
||||||
(int) MathF.Floor(floatBounds.Bottom),
|
(int) MathF.Floor(floatBounds.Bottom),
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ namespace Content.Client.NPC
|
|||||||
var mousePos = _inputManager.MouseScreenPosition;
|
var mousePos = _inputManager.MouseScreenPosition;
|
||||||
var mouseWorldPos = _eyeManager.ScreenToMap(mousePos);
|
var mouseWorldPos = _eyeManager.ScreenToMap(mousePos);
|
||||||
var aabb = new Box2(mouseWorldPos.Position - SharedPathfindingSystem.ChunkSize, mouseWorldPos.Position + SharedPathfindingSystem.ChunkSize);
|
var aabb = new Box2(mouseWorldPos.Position - SharedPathfindingSystem.ChunkSize, mouseWorldPos.Position + SharedPathfindingSystem.ChunkSize);
|
||||||
|
var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
|
||||||
|
|
||||||
if ((_system.Modes & PathfindingDebugMode.Crumb) != 0x0 &&
|
if ((_system.Modes & PathfindingDebugMode.Crumb) != 0x0 &&
|
||||||
mouseWorldPos.MapId == args.MapId)
|
mouseWorldPos.MapId == args.MapId)
|
||||||
@@ -172,11 +173,11 @@ namespace Content.Client.NPC
|
|||||||
|
|
||||||
foreach (var grid in _mapManager.FindGridsIntersecting(mouseWorldPos.MapId, aabb))
|
foreach (var grid in _mapManager.FindGridsIntersecting(mouseWorldPos.MapId, aabb))
|
||||||
{
|
{
|
||||||
if (found || !_system.Breadcrumbs.TryGetValue(grid.GridEntityId, out var crumbs))
|
if (found || !_system.Breadcrumbs.TryGetValue(grid.GridEntityId, out var crumbs) || !xformQuery.TryGetComponent(grid.GridEntityId, out var gridXform))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var localAABB = grid.InvWorldMatrix.TransformBox(aabb.Enlarged(float.Epsilon - SharedPathfindingSystem.ChunkSize));
|
var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
|
||||||
var worldMatrix = grid.WorldMatrix;
|
var localAABB = invWorldMatrix.TransformBox(aabb.Enlarged(float.Epsilon - SharedPathfindingSystem.ChunkSize));
|
||||||
|
|
||||||
foreach (var chunk in crumbs)
|
foreach (var chunk in crumbs)
|
||||||
{
|
{
|
||||||
@@ -242,7 +243,7 @@ namespace Content.Client.NPC
|
|||||||
if ((_system.Modes & PathfindingDebugMode.Poly) != 0x0 &&
|
if ((_system.Modes & PathfindingDebugMode.Poly) != 0x0 &&
|
||||||
mouseWorldPos.MapId == args.MapId)
|
mouseWorldPos.MapId == args.MapId)
|
||||||
{
|
{
|
||||||
if (!_mapManager.TryFindGridAt(mouseWorldPos, out var grid))
|
if (!_mapManager.TryFindGridAt(mouseWorldPos, out var grid) || !xformQuery.TryGetComponent(grid.GridEntityId, out var gridXform))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var found = false;
|
var found = false;
|
||||||
@@ -261,7 +262,7 @@ namespace Content.Client.NPC
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var invGridMatrix = grid.InvWorldMatrix;
|
var invGridMatrix = gridXform.InvWorldMatrix;
|
||||||
DebugPathPoly? nearest = null;
|
DebugPathPoly? nearest = null;
|
||||||
var nearestDistance = float.MaxValue;
|
var nearestDistance = float.MaxValue;
|
||||||
|
|
||||||
@@ -316,17 +317,20 @@ namespace Content.Client.NPC
|
|||||||
var mousePos = _inputManager.MouseScreenPosition;
|
var mousePos = _inputManager.MouseScreenPosition;
|
||||||
var mouseWorldPos = _eyeManager.ScreenToMap(mousePos);
|
var mouseWorldPos = _eyeManager.ScreenToMap(mousePos);
|
||||||
var aabb = new Box2(mouseWorldPos.Position - Vector2.One / 4f, mouseWorldPos.Position + Vector2.One / 4f);
|
var aabb = new Box2(mouseWorldPos.Position - Vector2.One / 4f, mouseWorldPos.Position + Vector2.One / 4f);
|
||||||
|
var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
|
||||||
|
|
||||||
if ((_system.Modes & PathfindingDebugMode.Breadcrumbs) != 0x0 &&
|
if ((_system.Modes & PathfindingDebugMode.Breadcrumbs) != 0x0 &&
|
||||||
mouseWorldPos.MapId == args.MapId)
|
mouseWorldPos.MapId == args.MapId)
|
||||||
{
|
{
|
||||||
foreach (var grid in _mapManager.FindGridsIntersecting(mouseWorldPos.MapId, aabb))
|
foreach (var grid in _mapManager.FindGridsIntersecting(mouseWorldPos.MapId, aabb))
|
||||||
{
|
{
|
||||||
if (!_system.Breadcrumbs.TryGetValue(grid.GridEntityId, out var crumbs))
|
if (!_system.Breadcrumbs.TryGetValue(grid.GridEntityId, out var crumbs) ||
|
||||||
|
!xformQuery.TryGetComponent(grid.GridEntityId, out var gridXform))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
worldHandle.SetTransform(grid.WorldMatrix);
|
var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
|
||||||
var localAABB = grid.InvWorldMatrix.TransformBox(aabb);
|
worldHandle.SetTransform(worldMatrix);
|
||||||
|
var localAABB = invWorldMatrix.TransformBox(aabb);
|
||||||
|
|
||||||
foreach (var chunk in crumbs)
|
foreach (var chunk in crumbs)
|
||||||
{
|
{
|
||||||
@@ -374,11 +378,13 @@ namespace Content.Client.NPC
|
|||||||
{
|
{
|
||||||
foreach (var grid in _mapManager.FindGridsIntersecting(args.MapId, aabb))
|
foreach (var grid in _mapManager.FindGridsIntersecting(args.MapId, aabb))
|
||||||
{
|
{
|
||||||
if (!_system.Polys.TryGetValue(grid.GridEntityId, out var data))
|
if (!_system.Polys.TryGetValue(grid.GridEntityId, out var data) ||
|
||||||
|
!xformQuery.TryGetComponent(grid.GridEntityId, out var gridXform))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
worldHandle.SetTransform(grid.WorldMatrix);
|
var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
|
||||||
var localAABB = grid.InvWorldMatrix.TransformBox(aabb);
|
worldHandle.SetTransform(worldMatrix);
|
||||||
|
var localAABB = invWorldMatrix.TransformBox(aabb);
|
||||||
|
|
||||||
foreach (var chunk in data)
|
foreach (var chunk in data)
|
||||||
{
|
{
|
||||||
@@ -407,7 +413,7 @@ namespace Content.Client.NPC
|
|||||||
foreach (var grid in _mapManager.FindGridsIntersecting(args.MapId, aabb))
|
foreach (var grid in _mapManager.FindGridsIntersecting(args.MapId, aabb))
|
||||||
{
|
{
|
||||||
if (!_system.Polys.TryGetValue(grid.GridEntityId, out var data) ||
|
if (!_system.Polys.TryGetValue(grid.GridEntityId, out var data) ||
|
||||||
!_entManager.TryGetComponent<TransformComponent>(grid.GridEntityId, out var gridXform))
|
!xformQuery.TryGetComponent(grid.GridEntityId, out var gridXform))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var (_, _, worldMatrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
|
var (_, _, worldMatrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
|
||||||
@@ -460,11 +466,13 @@ namespace Content.Client.NPC
|
|||||||
{
|
{
|
||||||
foreach (var grid in _mapManager.FindGridsIntersecting(args.MapId, args.WorldBounds))
|
foreach (var grid in _mapManager.FindGridsIntersecting(args.MapId, args.WorldBounds))
|
||||||
{
|
{
|
||||||
if (!_system.Breadcrumbs.TryGetValue(grid.GridEntityId, out var crumbs))
|
if (!_system.Breadcrumbs.TryGetValue(grid.GridEntityId, out var crumbs) ||
|
||||||
|
!xformQuery.TryGetComponent(grid.GridEntityId, out var gridXform))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
worldHandle.SetTransform(grid.WorldMatrix);
|
var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
|
||||||
var localAABB = grid.InvWorldMatrix.TransformBox(args.WorldBounds);
|
worldHandle.SetTransform(worldMatrix);
|
||||||
|
var localAABB = invWorldMatrix.TransformBox(args.WorldBounds);
|
||||||
|
|
||||||
foreach (var chunk in crumbs)
|
foreach (var chunk in crumbs)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -140,7 +140,9 @@ namespace Content.Client.NodeContainer
|
|||||||
foreach (var (gridId, gridDict) in _gridIndex)
|
foreach (var (gridId, gridDict) in _gridIndex)
|
||||||
{
|
{
|
||||||
var grid = _mapManager.GetGrid(gridId);
|
var grid = _mapManager.GetGrid(gridId);
|
||||||
var lCursorBox = grid.InvWorldMatrix.TransformBox(cursorBox);
|
var (_, _, worldMatrix, invMatrix) = _entityManager.GetComponent<TransformComponent>(grid.GridEntityId).GetWorldPositionRotationMatrixWithInv();
|
||||||
|
|
||||||
|
var lCursorBox = invMatrix.TransformBox(cursorBox);
|
||||||
foreach (var (pos, list) in gridDict)
|
foreach (var (pos, list) in gridDict)
|
||||||
{
|
{
|
||||||
var centerPos = (Vector2) pos + grid.TileSize / 2f;
|
var centerPos = (Vector2) pos + grid.TileSize / 2f;
|
||||||
@@ -159,7 +161,7 @@ namespace Content.Client.NodeContainer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handle.SetTransform(grid.WorldMatrix);
|
handle.SetTransform(worldMatrix);
|
||||||
|
|
||||||
foreach (var nodeRenderData in _nodeIndex.Values)
|
foreach (var nodeRenderData in _nodeIndex.Values)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -136,16 +136,19 @@ public class DockingControl : Control
|
|||||||
Matrix3.Multiply(in gridInvMatrix, in matrix, out var invMatrix);
|
Matrix3.Multiply(in gridInvMatrix, in matrix, out var invMatrix);
|
||||||
|
|
||||||
// TODO: Getting some overdraw so need to fix that.
|
// TODO: Getting some overdraw so need to fix that.
|
||||||
|
var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
|
||||||
|
|
||||||
foreach (var grid in _mapManager.FindGridsIntersecting(gridXform.MapID,
|
foreach (var grid in _mapManager.FindGridsIntersecting(gridXform.MapID,
|
||||||
new Box2(worldPos - _range, worldPos + _range)))
|
new Box2(worldPos - _range, worldPos + _range)))
|
||||||
{
|
{
|
||||||
if (grid.GridEntityId == GridEntity) continue;
|
if (grid.GridEntityId == GridEntity)
|
||||||
|
continue;
|
||||||
|
|
||||||
// Draw the fixtures before drawing any docks in range.
|
// Draw the fixtures before drawing any docks in range.
|
||||||
if (!_entManager.TryGetComponent<FixturesComponent>(grid.GridEntityId, out var gridFixtures)) continue;
|
if (!_entManager.TryGetComponent<FixturesComponent>(grid.GridEntityId, out var gridFixtures))
|
||||||
|
continue;
|
||||||
|
|
||||||
var gridMatrix = grid.WorldMatrix;
|
var gridMatrix = xformQuery.GetComponent(grid.GridEntityId).WorldMatrix;
|
||||||
|
|
||||||
Matrix3.Multiply(in gridMatrix, in invMatrix, out var matty);
|
Matrix3.Multiply(in gridMatrix, in invMatrix, out var matty);
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ namespace Content.IntegrationTests.Tests.Fluids
|
|||||||
// Check that the map and grid are paused
|
// Check that the map and grid are paused
|
||||||
await server.WaitAssertion(() =>
|
await server.WaitAssertion(() =>
|
||||||
{
|
{
|
||||||
Assert.True(sMapManager.IsGridPaused(sGridId));
|
Assert.True(metaSystem.EntityPaused(sGridId));
|
||||||
Assert.True(sMapManager.IsMapPaused(sMapId));
|
Assert.True(sMapManager.IsMapPaused(sMapId));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ namespace Content.IntegrationTests.Tests.Fluids
|
|||||||
evaporation = entityManager.GetComponent<EvaporationComponent>(puddle.Owner);
|
evaporation = entityManager.GetComponent<EvaporationComponent>(puddle.Owner);
|
||||||
metaSystem.SetEntityPaused(puddle.Owner, true, meta); // See https://github.com/space-wizards/RobustToolbox/issues/1445
|
metaSystem.SetEntityPaused(puddle.Owner, true, meta); // See https://github.com/space-wizards/RobustToolbox/issues/1445
|
||||||
|
|
||||||
Assert.True(meta.EntityPaused);
|
Assert.True(metaSystem.EntityPaused(puddle.Owner, meta));
|
||||||
|
|
||||||
// Check that the puddle is going to evaporate
|
// Check that the puddle is going to evaporate
|
||||||
Assert.Positive(evaporation.EvaporateTime);
|
Assert.Positive(evaporation.EvaporateTime);
|
||||||
@@ -174,7 +174,7 @@ namespace Content.IntegrationTests.Tests.Fluids
|
|||||||
await server.WaitAssertion(() =>
|
await server.WaitAssertion(() =>
|
||||||
{
|
{
|
||||||
Assert.False(sMapManager.IsMapPaused(sMapId));
|
Assert.False(sMapManager.IsMapPaused(sMapId));
|
||||||
Assert.False(sMapManager.IsGridPaused(sGridId));
|
Assert.False(metaSystem.EntityPaused(sGridId));
|
||||||
Assert.False(meta.EntityPaused);
|
Assert.False(meta.EntityPaused);
|
||||||
|
|
||||||
// Check that the puddle still exists
|
// Check that the puddle still exists
|
||||||
|
|||||||
@@ -59,18 +59,26 @@ namespace Content.IntegrationTests.Tests
|
|||||||
await server.WaitAssertion(() =>
|
await server.WaitAssertion(() =>
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
if (!mapManager.TryFindGridAt(new MapId(10), new Vector2(10, 10), out var mapGrid))
|
if (!mapManager.TryFindGridAt(new MapId(10), new Vector2(10, 10), out var mapGrid) ||
|
||||||
|
!sEntities.TryGetComponent<TransformComponent>(mapGrid.GridEntityId, out var gridXform))
|
||||||
|
{
|
||||||
Assert.Fail();
|
Assert.Fail();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Assert.That(mapGrid.WorldPosition, Is.EqualTo(new Vector2(10, 10)));
|
Assert.That(gridXform.WorldPosition, Is.EqualTo(new Vector2(10, 10)));
|
||||||
|
|
||||||
Assert.That(mapGrid.GetTileRef(new Vector2i(0, 0)).Tile, Is.EqualTo(new Tile(1, (TileRenderFlag)1, 255)));
|
Assert.That(mapGrid.GetTileRef(new Vector2i(0, 0)).Tile, Is.EqualTo(new Tile(1, (TileRenderFlag)1, 255)));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
if (!mapManager.TryFindGridAt(new MapId(10), new Vector2(-8, -8), out var mapGrid))
|
if (!mapManager.TryFindGridAt(new MapId(10), new Vector2(-8, -8), out var mapGrid) ||
|
||||||
|
!sEntities.TryGetComponent<TransformComponent>(mapGrid.GridEntityId, out var gridXform))
|
||||||
|
{
|
||||||
Assert.Fail();
|
Assert.Fail();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Assert.That(mapGrid.WorldPosition, Is.EqualTo(new Vector2(-8, -8)));
|
Assert.That(gridXform.WorldPosition, Is.EqualTo(new Vector2(-8, -8)));
|
||||||
Assert.That(mapGrid.GetTileRef(new Vector2i(0, 0)).Tile, Is.EqualTo(new Tile(2, (TileRenderFlag)1, 254)));
|
Assert.That(mapGrid.GetTileRef(new Vector2i(0, 0)).Tile, Is.EqualTo(new Tile(2, (TileRenderFlag)1, 254)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using Content.IntegrationTests;
|
|||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
@@ -59,6 +60,7 @@ namespace Content.MapRenderer.Painters
|
|||||||
var tilePainter = new TilePainter(client, server);
|
var tilePainter = new TilePainter(client, server);
|
||||||
var entityPainter = new GridPainter(client, server);
|
var entityPainter = new GridPainter(client, server);
|
||||||
IMapGrid[] grids = null!;
|
IMapGrid[] grids = null!;
|
||||||
|
var xformQuery = sEntityManager.GetEntityQuery<TransformComponent>();
|
||||||
|
|
||||||
await server.WaitPost(() =>
|
await server.WaitPost(() =>
|
||||||
{
|
{
|
||||||
@@ -74,7 +76,8 @@ namespace Content.MapRenderer.Painters
|
|||||||
|
|
||||||
foreach (var grid in grids)
|
foreach (var grid in grids)
|
||||||
{
|
{
|
||||||
grid.WorldRotation = Angle.Zero;
|
var gridXform = xformQuery.GetComponent(grid.GridEntityId);
|
||||||
|
gridXform.WorldRotation = Angle.Zero;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -116,7 +119,7 @@ namespace Content.MapRenderer.Painters
|
|||||||
var renderedImage = new RenderedGridImage<Rgba32>(gridCanvas)
|
var renderedImage = new RenderedGridImage<Rgba32>(gridCanvas)
|
||||||
{
|
{
|
||||||
GridUid = grid.GridEntityId,
|
GridUid = grid.GridEntityId,
|
||||||
Offset = grid.WorldPosition
|
Offset = xformQuery.GetComponent(grid.GridEntityId).WorldPosition
|
||||||
};
|
};
|
||||||
|
|
||||||
yield return renderedImage;
|
yield return renderedImage;
|
||||||
|
|||||||
@@ -122,11 +122,18 @@ public sealed partial class AtmosphereSystem
|
|||||||
if (shell.Player is { AttachedEntity: { } playerEnt })
|
if (shell.Player is { AttachedEntity: { } playerEnt })
|
||||||
playerMap = Transform(playerEnt).MapID;
|
playerMap = Transform(playerEnt).MapID;
|
||||||
|
|
||||||
var options = _mapManager.GetAllGrids()
|
var options = new List<CompletionOption>();
|
||||||
.OrderByDescending(e => playerMap != null && e.ParentMapId == playerMap)
|
|
||||||
.ThenBy(e => (int) e.ParentMapId)
|
if (playerMap == null)
|
||||||
.ThenBy(e => (int) e.GridEntityId)
|
return CompletionResult.FromOptions(options);
|
||||||
.Select(e => new CompletionOption(e.GridEntityId.ToString(), $"{MetaData(e.GridEntityId).EntityName} - Map {e.ParentMapId}"));
|
|
||||||
|
foreach (var grid in _mapManager.GetAllMapGrids(playerMap.Value).OrderBy(o => o.GridEntityId))
|
||||||
|
{
|
||||||
|
if (!TryComp<TransformComponent>(grid.GridEntityId, out var gridXform))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
options.Add(new CompletionOption(grid.GridEntityId.ToString(), $"{MetaData(grid.GridEntityId).EntityName} - Map {gridXform.MapID}"));
|
||||||
|
}
|
||||||
|
|
||||||
return CompletionResult.FromOptions(options);
|
return CompletionResult.FromOptions(options);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
var mapGrid = mapGridComp.Grid;
|
var mapGrid = mapGridComp.Grid;
|
||||||
var mapUid = _mapManager.GetMapEntityIdOrThrow(mapGridComp.Grid.ParentMapId);
|
var mapUid = _mapManager.GetMapEntityIdOrThrow(Transform(mapGridComp.Owner).MapID);
|
||||||
|
|
||||||
var volume = GetVolumeForTiles(mapGrid, 1);
|
var volume = GetVolumeForTiles(mapGrid, 1);
|
||||||
|
|
||||||
|
|||||||
@@ -387,10 +387,12 @@ public sealed partial class CargoSystem
|
|||||||
var center = new Vector2();
|
var center = new Vector2();
|
||||||
var minRadius = 0f;
|
var minRadius = 0f;
|
||||||
Box2? aabb = null;
|
Box2? aabb = null;
|
||||||
|
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||||
|
|
||||||
foreach (var grid in _mapManager.GetAllMapGrids(xform.MapID))
|
foreach (var grid in _mapManager.GetAllMapGrids(xform.MapID))
|
||||||
{
|
{
|
||||||
aabb = aabb?.Union(grid.WorldAABB) ?? grid.WorldAABB;
|
var worldAABB = xformQuery.GetComponent(grid.GridEntityId).WorldMatrix.TransformBox(grid.LocalAABB);
|
||||||
|
aabb = aabb?.Union(worldAABB) ?? worldAABB;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aabb != null)
|
if (aabb != null)
|
||||||
|
|||||||
@@ -331,8 +331,10 @@ namespace Content.Server.GameTicking
|
|||||||
|
|
||||||
if (_mapManager.TryFindGridAt(toMap, out var foundGrid))
|
if (_mapManager.TryFindGridAt(toMap, out var foundGrid))
|
||||||
{
|
{
|
||||||
|
var gridXform = Transform(foundGrid.GridEntityId);
|
||||||
|
|
||||||
return new EntityCoordinates(foundGrid.GridEntityId,
|
return new EntityCoordinates(foundGrid.GridEntityId,
|
||||||
foundGrid.InvWorldMatrix.Transform(toMap.Position));
|
gridXform.InvWorldMatrix.Transform(toMap.Position));
|
||||||
}
|
}
|
||||||
|
|
||||||
return spawn;
|
return spawn;
|
||||||
|
|||||||
@@ -149,9 +149,11 @@ public sealed class PiratesRuleSystem : GameRuleSystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
var map = "/Maps/pirate.yml";
|
var map = "/Maps/pirate.yml";
|
||||||
|
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||||
|
|
||||||
var aabbs = _stationSystem.Stations.SelectMany(x =>
|
var aabbs = _stationSystem.Stations.SelectMany(x =>
|
||||||
Comp<StationDataComponent>(x).Grids.Select(x => _mapManager.GetGridComp(x).Grid.WorldAABB)).ToArray();
|
Comp<StationDataComponent>(x).Grids.Select(x => xformQuery.GetComponent(x).WorldMatrix.TransformBox(_mapManager.GetGridComp(x).Grid.LocalAABB))).ToArray();
|
||||||
|
|
||||||
var aabb = aabbs[0];
|
var aabb = aabbs[0];
|
||||||
|
|
||||||
for (var i = 1; i < aabbs.Length; i++)
|
for (var i = 1; i < aabbs.Length; i++)
|
||||||
|
|||||||
@@ -32,10 +32,13 @@ namespace Content.Server.Objectives.Conditions
|
|||||||
|
|
||||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||||
|
|
||||||
if (!entMan.TryGetComponent<IMapGridComponent>(shuttle, out var shuttleGrid))
|
if (!entMan.TryGetComponent<IMapGridComponent>(shuttle, out var shuttleGrid) ||
|
||||||
|
!entMan.TryGetComponent<TransformComponent>(shuttle, out var shuttleXform))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return shuttleGrid.Grid.WorldAABB.Contains(agentXform.WorldPosition);
|
return shuttleXform.WorldMatrix.TransformBox(shuttleGrid.Grid.LocalAABB).Contains(agentXform.WorldPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float Progress
|
public float Progress
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ sealed class SalvageRulerCommand : IConsoleCommand
|
|||||||
var first = true;
|
var first = true;
|
||||||
foreach (var mapGrid in _maps.GetAllMapGrids(entityTransform.MapID))
|
foreach (var mapGrid in _maps.GetAllMapGrids(entityTransform.MapID))
|
||||||
{
|
{
|
||||||
var aabb = mapGrid.WorldAABB;
|
var aabb = _entities.GetComponent<TransformComponent>(mapGrid.GridEntityId).WorldMatrix.TransformBox(mapGrid.LocalAABB);
|
||||||
if (first)
|
if (first)
|
||||||
{
|
{
|
||||||
total = aabb;
|
total = aabb;
|
||||||
|
|||||||
@@ -227,9 +227,10 @@ namespace Content.Server.Salvage
|
|||||||
angle = Angle.Zero;
|
angle = Angle.Zero;
|
||||||
var tsc = Transform(component.Owner);
|
var tsc = Transform(component.Owner);
|
||||||
coords = new EntityCoordinates(component.Owner, component.Offset).ToMap(EntityManager);
|
coords = new EntityCoordinates(component.Owner, component.Offset).ToMap(EntityManager);
|
||||||
if (_mapManager.TryGetGrid(tsc.GridUid, out var magnetGrid))
|
|
||||||
|
if (_mapManager.TryGetGrid(tsc.GridUid, out var magnetGrid) && TryComp<TransformComponent>(magnetGrid.GridEntityId, out var gridXform))
|
||||||
{
|
{
|
||||||
angle = magnetGrid.WorldRotation;
|
angle = gridXform.WorldRotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +373,7 @@ namespace Content.Server.Salvage
|
|||||||
var gridId = gridIdAndState.Key;
|
var gridId = gridIdAndState.Key;
|
||||||
// Not handling the case where the salvage we spawned got paused
|
// Not handling the case where the salvage we spawned got paused
|
||||||
// They both need to be paused, or it doesn't make sense
|
// They both need to be paused, or it doesn't make sense
|
||||||
if (_mapManager.IsGridPaused(gridId)) continue;
|
if (MetaData(gridId).EntityPaused) continue;
|
||||||
state.CurrentTime += secondsPassed;
|
state.CurrentTime += secondsPassed;
|
||||||
|
|
||||||
var deleteQueue = new RemQueue<SalvageMagnetComponent>();
|
var deleteQueue = new RemQueue<SalvageMagnetComponent>();
|
||||||
|
|||||||
@@ -90,17 +90,19 @@ namespace Content.Server.Shuttles.Systems
|
|||||||
var enlargedAABB = aabb.Value.Enlarged(DockingRadius * 1.5f);
|
var enlargedAABB = aabb.Value.Enlarged(DockingRadius * 1.5f);
|
||||||
|
|
||||||
// Get any docking ports in range on other grids.
|
// Get any docking ports in range on other grids.
|
||||||
_mapManager.FindGridsIntersectingEnumerator(dockingXform.MapID, enlargedAABB, out var enumerator);
|
foreach (var otherGrid in _mapManager.FindGridsIntersecting(dockingXform.MapID, enlargedAABB))
|
||||||
|
|
||||||
while (enumerator.MoveNext(out var otherGrid))
|
|
||||||
{
|
{
|
||||||
if (otherGrid.GridEntityId == dockingXform.GridUid) continue;
|
if (otherGrid.GridEntityId == dockingXform.GridUid)
|
||||||
|
continue;
|
||||||
|
|
||||||
foreach (var ent in otherGrid.GetAnchoredEntities(enlargedAABB))
|
foreach (var ent in otherGrid.GetAnchoredEntities(enlargedAABB))
|
||||||
{
|
{
|
||||||
if (!TryComp(ent, out DockingComponent? otherDocking) ||
|
if (!TryComp(ent, out DockingComponent? otherDocking) ||
|
||||||
!otherDocking.Enabled ||
|
!otherDocking.Enabled ||
|
||||||
!TryComp(ent, out PhysicsComponent? otherBody)) continue;
|
!TryComp(ent, out PhysicsComponent? otherBody))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var otherTransform = otherBody.GetTransform();
|
var otherTransform = otherBody.GetTransform();
|
||||||
var otherDockingFixture = _fixtureSystem.GetFixtureOrNull(otherBody, DockingFixture);
|
var otherDockingFixture = _fixtureSystem.GetFixtureOrNull(otherBody, DockingFixture);
|
||||||
|
|||||||
@@ -90,9 +90,12 @@ public sealed partial class ShuttleSystem
|
|||||||
reason = null;
|
reason = null;
|
||||||
|
|
||||||
if (!TryComp<IMapGridComponent>(uid, out var grid) ||
|
if (!TryComp<IMapGridComponent>(uid, out var grid) ||
|
||||||
!Resolve(uid.Value, ref xform)) return true;
|
!Resolve(uid.Value, ref xform))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
var bounds = grid.Grid.WorldAABB.Enlarged(ShuttleFTLRange);
|
var bounds = xform.WorldMatrix.TransformBox(grid.Grid.LocalAABB).Enlarged(ShuttleFTLRange);
|
||||||
var bodyQuery = GetEntityQuery<PhysicsComponent>();
|
var bodyQuery = GetEntityQuery<PhysicsComponent>();
|
||||||
|
|
||||||
foreach (var other in _mapManager.FindGridsIntersecting(xform.MapID, bounds))
|
foreach (var other in _mapManager.FindGridsIntersecting(xform.MapID, bounds))
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ public sealed class StationSystem : EntitySystem
|
|||||||
bounds.Add(bound);
|
bounds.Add(bound);
|
||||||
if (!mapIds.Contains(mapId))
|
if (!mapIds.Contains(mapId))
|
||||||
{
|
{
|
||||||
mapIds.Add(grid.ParentMapId);
|
mapIds.Add(xform.MapID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,9 +68,13 @@ namespace Content.Server.StationEvents.Events
|
|||||||
Box2? playableArea = null;
|
Box2? playableArea = null;
|
||||||
var mapId = GameTicker.DefaultMap;
|
var mapId = GameTicker.DefaultMap;
|
||||||
|
|
||||||
foreach (var grid in MapManager.GetAllGrids())
|
foreach (var grid in MapManager.GetAllMapGrids(mapId))
|
||||||
{
|
{
|
||||||
if (grid.ParentMapId != mapId || !EntityManager.TryGetComponent(grid.GridEntityId, out PhysicsComponent? gridBody)) continue;
|
if (!TryComp<PhysicsComponent>(grid.GridEntityId, out var gridBody))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var aabb = gridBody.GetWorldAABB();
|
var aabb = gridBody.GetWorldAABB();
|
||||||
playableArea = playableArea?.Union(aabb) ?? aabb;
|
playableArea = playableArea?.Union(aabb) ?? aabb;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace Content.Server.StationEvents.Events
|
|||||||
[Dependency] protected readonly IAdminLogManager AdminLogManager = default!;
|
[Dependency] protected readonly IAdminLogManager AdminLogManager = default!;
|
||||||
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
|
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
|
||||||
[Dependency] protected readonly IMapManager MapManager = default!;
|
[Dependency] protected readonly IMapManager MapManager = default!;
|
||||||
|
[Dependency] private readonly AtmosphereSystem _atmosphere = default!;
|
||||||
[Dependency] protected readonly ChatSystem ChatSystem = default!;
|
[Dependency] protected readonly ChatSystem ChatSystem = default!;
|
||||||
[Dependency] protected readonly StationSystem StationSystem = default!;
|
[Dependency] protected readonly StationSystem StationSystem = default!;
|
||||||
|
|
||||||
@@ -146,12 +147,12 @@ namespace Content.Server.StationEvents.Events
|
|||||||
|
|
||||||
if (!TryComp<IMapGridComponent>(targetGrid, out var gridComp))
|
if (!TryComp<IMapGridComponent>(targetGrid, out var gridComp))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var grid = gridComp.Grid;
|
var grid = gridComp.Grid;
|
||||||
|
|
||||||
var atmosphereSystem = Get<AtmosphereSystem>();
|
|
||||||
var found = false;
|
var found = false;
|
||||||
var gridBounds = grid.WorldAABB;
|
var (gridPos, _, gridMatrix) = Transform(targetGrid).GetWorldPositionRotationMatrix();
|
||||||
var gridPos = grid.WorldPosition;
|
var gridBounds = gridMatrix.TransformBox(grid.LocalAABB);
|
||||||
|
|
||||||
for (var i = 0; i < 10; i++)
|
for (var i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
@@ -159,8 +160,13 @@ namespace Content.Server.StationEvents.Events
|
|||||||
var randomY = RobustRandom.Next((int) gridBounds.Bottom, (int) gridBounds.Top);
|
var randomY = RobustRandom.Next((int) gridBounds.Bottom, (int) gridBounds.Top);
|
||||||
|
|
||||||
tile = new Vector2i(randomX - (int) gridPos.X, randomY - (int) gridPos.Y);
|
tile = new Vector2i(randomX - (int) gridPos.X, randomY - (int) gridPos.Y);
|
||||||
if (atmosphereSystem.IsTileSpace(grid.GridEntityId, Transform(targetGrid).MapUid, tile, mapGridComp:gridComp)
|
if (_atmosphere.IsTileSpace(grid.GridEntityId, Transform(targetGrid).MapUid, tile,
|
||||||
|| atmosphereSystem.IsTileAirBlocked(grid.GridEntityId, tile, mapGridComp:gridComp)) continue;
|
mapGridComp: gridComp)
|
||||||
|
|| _atmosphere.IsTileAirBlocked(grid.GridEntityId, tile, mapGridComp: gridComp))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
targetCoords = grid.GridTileToLocal(tile);
|
targetCoords = grid.GridTileToLocal(tile);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ namespace Content.Server.Tiles
|
|||||||
else if (HasBaseTurf(currentTileDefinition, ContentTileDefinition.SpaceID))
|
else if (HasBaseTurf(currentTileDefinition, ContentTileDefinition.SpaceID))
|
||||||
{
|
{
|
||||||
mapGrid = _mapManager.CreateGrid(locationMap.MapId);
|
mapGrid = _mapManager.CreateGrid(locationMap.MapId);
|
||||||
mapGrid.WorldPosition = locationMap.Position;
|
var gridXform = Transform(mapGrid.GridEntityId);
|
||||||
|
gridXform.WorldPosition = locationMap.Position;
|
||||||
location = new EntityCoordinates(mapGrid.GridEntityId, Vector2.Zero);
|
location = new EntityCoordinates(mapGrid.GridEntityId, Vector2.Zero);
|
||||||
PlaceAt(mapGrid, location, _tileDefinitionManager[component.OutputTiles[0]].TileId, component.PlaceTileSound, mapGrid.TileSize / 2f);
|
PlaceAt(mapGrid, location, _tileDefinitionManager[component.OutputTiles[0]].TileId, component.PlaceTileSound, mapGrid.TileSize / 2f);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -250,19 +250,23 @@ namespace Content.Shared.Maps
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a box the size of a tile, at the same position in the world as the tile.
|
/// Creates a box the size of a tile, at the same position in the world as the tile.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Obsolete]
|
||||||
private static bool GetWorldTileBox(TileRef turf, out Box2Rotated res)
|
private static bool GetWorldTileBox(TileRef turf, out Box2Rotated res)
|
||||||
{
|
{
|
||||||
|
var entManager = IoCManager.Resolve<IEntityManager>();
|
||||||
var map = IoCManager.Resolve<IMapManager>();
|
var map = IoCManager.Resolve<IMapManager>();
|
||||||
|
|
||||||
if (map.TryGetGrid(turf.GridUid, out var tileGrid))
|
if (map.TryGetGrid(turf.GridUid, out var tileGrid))
|
||||||
{
|
{
|
||||||
|
var gridRot = entManager.GetComponent<TransformComponent>(tileGrid.GridEntityId).WorldRotation;
|
||||||
|
|
||||||
// This is scaled to 90 % so it doesn't encompass walls on other tiles.
|
// This is scaled to 90 % so it doesn't encompass walls on other tiles.
|
||||||
var tileBox = Box2.UnitCentered.Scale(0.9f);
|
var tileBox = Box2.UnitCentered.Scale(0.9f);
|
||||||
tileBox = tileBox.Scale(tileGrid.TileSize);
|
tileBox = tileBox.Scale(tileGrid.TileSize);
|
||||||
var worldPos = tileGrid.GridTileToWorldPos(turf.GridIndices);
|
var worldPos = tileGrid.GridTileToWorldPos(turf.GridIndices);
|
||||||
tileBox = tileBox.Translated(worldPos);
|
tileBox = tileBox.Translated(worldPos);
|
||||||
// Now tileBox needs to be rotated to match grid rotation
|
// Now tileBox needs to be rotated to match grid rotation
|
||||||
res = new Box2Rotated(tileBox, tileGrid.WorldRotation, worldPos);
|
res = new Box2Rotated(tileBox, gridRot, worldPos);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user