Inline Transform

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 14:20:34 +01:00
parent 69b270017b
commit a5b57c8e10
283 changed files with 742 additions and 709 deletions

View File

@@ -29,13 +29,13 @@ namespace Content.Server.Atmos.EntitySystems
{
if (airtight.FixAirBlockedDirectionInitialize)
{
var rotateEvent = new RotateEvent(airtight.Owner, Angle.Zero, airtight.Owner.Transform.WorldRotation);
var rotateEvent = new RotateEvent(airtight.Owner, Angle.Zero, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(airtight.Owner.Uid).WorldRotation);
OnAirtightRotated(uid, airtight, ref rotateEvent);
}
// Adding this component will immediately anchor the entity, because the atmos system
// requires airtight entities to be anchored for performance.
airtight.Owner.Transform.Anchored = true;
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(airtight.Owner.Uid).Anchored = true;
UpdatePosition(airtight);
}
@@ -54,8 +54,8 @@ namespace Content.Server.Atmos.EntitySystems
private void OnAirtightPositionChanged(EntityUid uid, AirtightComponent airtight, ref AnchorStateChangedEvent args)
{
var gridId = airtight.Owner.Transform.GridID;
var coords = airtight.Owner.Transform.Coordinates;
var gridId = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(airtight.Owner.Uid).GridID;
var coords = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(airtight.Owner.Uid).Coordinates;
var grid = _mapManager.GetGrid(gridId);
var tilePos = grid.TileIndicesFor(coords);
@@ -84,11 +84,11 @@ namespace Content.Server.Atmos.EntitySystems
public void UpdatePosition(AirtightComponent airtight)
{
if (!airtight.Owner.Transform.Anchored || !airtight.Owner.Transform.GridID.IsValid())
if (!IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(airtight.Owner.Uid).Anchored || !IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(airtight.Owner.Uid).GridID.IsValid())
return;
var grid = _mapManager.GetGrid(airtight.Owner.Transform.GridID);
airtight.LastPosition = (airtight.Owner.Transform.GridID, grid.TileIndicesFor(airtight.Owner.Transform.Coordinates));
var grid = _mapManager.GetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(airtight.Owner.Uid).GridID);
airtight.LastPosition = (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(airtight.Owner.Uid).GridID, grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(airtight.Owner.Uid).Coordinates));
InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2, airtight.FixVacuum && !airtight.AirBlocked);
}

View File

@@ -136,16 +136,16 @@ namespace Content.Server.Atmos.EntitySystems
var entity = session.AttachedEntity;
var worldBounds = Box2.CenteredAround(entity.Transform.WorldPosition,
var worldBounds = Box2.CenteredAround(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity.Uid).WorldPosition,
new Vector2(LocalViewRange, LocalViewRange));
foreach (var grid in _mapManager.FindGridsIntersecting(entity.Transform.MapID, worldBounds))
foreach (var grid in _mapManager.FindGridsIntersecting(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity.Uid).MapID, worldBounds))
{
if (!EntityManager.TryGetEntity(grid.GridEntityId, out var gridEnt)) continue;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<GridAtmosphereComponent?>(gridEnt.Uid, out var gam)) continue;
var entityTile = grid.GetTileRef(entity.Transform.Coordinates).GridIndices;
var entityTile = grid.GetTileRef(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity.Uid).Coordinates).GridIndices;
var baseTile = new Vector2i(entityTile.X - (LocalViewRange / 2), entityTile.Y - (LocalViewRange / 2));
var debugOverlayContent = new AtmosDebugOverlayData[LocalViewRange * LocalViewRange];

View File

@@ -1315,7 +1315,7 @@ namespace Content.Server.Atmos.EntitySystems
public bool AddAtmosDevice(AtmosDeviceComponent atmosDevice)
{
var grid = atmosDevice.Owner.Transform.GridID;
var grid = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(atmosDevice.Owner.Uid).GridID;
if (!_mapManager.TryGetGrid(grid, out var mapGrid))
return false;

View File

@@ -75,9 +75,9 @@ namespace Content.Server.Atmos.EntitySystems
{
foreach (var exposed in EntityManager.EntityQuery<AtmosExposedComponent>())
{
var tile = GetTileMixture(exposed.Owner.Transform.Coordinates);
var tile = GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(exposed.Owner.Uid).Coordinates);
if (tile == null) continue;
var updateEvent = new AtmosExposedUpdateEvent(exposed.Owner.Transform.Coordinates, tile);
var updateEvent = new AtmosExposedUpdateEvent(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(exposed.Owner.Uid).Coordinates, tile);
RaiseLocalEvent(exposed.Owner.Uid, ref updateEvent);
}

View File

@@ -197,17 +197,17 @@ namespace Content.Server.Atmos.EntitySystems
// This is the max in any direction that we can get a chunk (e.g. max 2 chunks away of data).
var (maxXDiff, maxYDiff) = ((int) (_updateRange / ChunkSize) + 1, (int) (_updateRange / ChunkSize) + 1);
var worldBounds = Box2.CenteredAround(entity.Transform.WorldPosition,
var worldBounds = Box2.CenteredAround(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity.Uid).WorldPosition,
new Vector2(_updateRange, _updateRange));
foreach (var grid in _mapManager.FindGridsIntersecting(entity.Transform.MapID, worldBounds))
foreach (var grid in _mapManager.FindGridsIntersecting(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity.Uid).MapID, worldBounds))
{
if (!_overlay.TryGetValue(grid.Index, out var chunks))
{
continue;
}
var entityTile = grid.GetTileRef(entity.Transform.Coordinates).GridIndices;
var entityTile = grid.GetTileRef(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity.Uid).Coordinates).GridIndices;
for (var x = -maxXDiff; x <= maxXDiff; x++)
{