Inline Transform
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user