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

@@ -39,7 +39,7 @@ namespace Content.Server.Atmos.Commands
return;
}
gridId = player.AttachedEntity.Transform.GridID;
gridId = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(player.AttachedEntity.Uid).GridID;
if (gridId == GridId.Invalid)
{
@@ -65,7 +65,7 @@ namespace Content.Server.Atmos.Commands
return;
}
gridId = player.AttachedEntity.Transform.GridID;
gridId = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(player.AttachedEntity.Uid).GridID;
if (gridId == GridId.Invalid)
{

View File

@@ -123,7 +123,7 @@ namespace Content.Server.Atmos.Components
{
// Already get the pressure before Dirty(), because we can't get the EntitySystem in that thread or smth
var pressure = 0f;
var tile = EntitySystem.Get<AtmosphereSystem>().GetTileMixture(Owner.Transform.Coordinates);
var tile = EntitySystem.Get<AtmosphereSystem>().GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates);
if (tile != null)
{
pressure = tile.Pressure;
@@ -171,7 +171,7 @@ namespace Content.Server.Atmos.Components
}
}
var pos = Owner.Transform.Coordinates;
var pos = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates;
if (!_checkPlayer && _position.HasValue)
{
// Check if position is out of range => don't update

View File

@@ -279,11 +279,11 @@ namespace Content.Server.Atmos.Components
{
if (_integrity <= 0)
{
var environment = atmosphereSystem.GetTileMixture(Owner.Transform.Coordinates, true);
var environment = atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates, true);
if(environment != null)
atmosphereSystem.Merge(environment, Air);
SoundSystem.Play(Filter.Pvs(Owner), _ruptureSound.GetSound(), Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.125f));
SoundSystem.Play(Filter.Pvs(Owner), _ruptureSound.GetSound(), IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates, AudioHelpers.WithVariation(0.125f));
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(Owner.Uid);
return;
@@ -297,7 +297,7 @@ namespace Content.Server.Atmos.Components
{
if (_integrity <= 0)
{
var environment = atmosphereSystem.GetTileMixture(Owner.Transform.Coordinates, true);
var environment = atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates, true);
if (environment == null)
return;

View File

@@ -47,7 +47,7 @@ namespace Content.Server.Atmos.Components
// TODO ATMOS stuns?
var transform = physics.Owner.Transform;
var transform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(physics.Owner.Uid);
var maxForce = MathF.Sqrt(pressureDifference) * 2.25f;
var moveProb = 100f;

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++)
{

View File

@@ -45,7 +45,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
return;
}
var environment = _atmosphereSystem.GetTileMixture(vent.Owner.Transform.Coordinates, true);
var environment = _atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(vent.Owner.Uid).Coordinates, true);
// We're in an air-blocked tile... Do nothing.
if (environment == null)

View File

@@ -38,7 +38,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
private void OnExamined(EntityUid uid, GasPressurePumpComponent pump, ExaminedEvent args)
{
if (!pump.Owner.Transform.Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
if (!IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(pump.Owner.Uid).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
return;
if (Loc.TryGetString("gas-pressure-pump-system-examined", out var str,
@@ -95,7 +95,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User.Uid, out ActorComponent? actor))
return;
if (component.Owner.Transform.Anchored)
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(component.Owner.Uid).Anchored)
{
_userInterfaceSystem.TryOpen(uid, GasPressurePumpUiKey.Key, actor.PlayerSession);
DirtyUI(uid, component);

View File

@@ -11,6 +11,7 @@ using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Player;
@@ -30,7 +31,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
private void OnExamined(EntityUid uid, GasValveComponent valve, ExaminedEvent args)
{
if (!valve.Owner.Transform.Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
if (!IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(valve.Owner.Uid).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
return;
if (Loc.TryGetString("gas-valve-system-examined", out var str,

View File

@@ -39,7 +39,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
private void OnExamined(EntityUid uid, GasVolumePumpComponent pump, ExaminedEvent args)
{
if (!pump.Owner.Transform.Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
if (!IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(pump.Owner.Uid).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
return;
if (Loc.TryGetString("gas-volume-pump-system-examined", out var str,
@@ -83,7 +83,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
// Some of the gas from the mixture leaks when overclocked.
if (pump.Overclocked)
{
var tile = _atmosphereSystem.GetTileMixture(pump.Owner.Transform.Coordinates, true);
var tile = _atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(pump.Owner.Uid).Coordinates, true);
if (tile != null)
{
@@ -100,7 +100,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User.Uid, out ActorComponent? actor))
return;
if (component.Owner.Transform.Anchored)
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(component.Owner.Uid).Anchored)
{
_userInterfaceSystem.TryOpen(uid, GasVolumePumpUiKey.Key, actor.PlayerSession);
DirtyUI(uid, component);

View File

@@ -32,7 +32,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
private bool CanJoinAtmosphere(AtmosDeviceComponent component)
{
return !component.RequireAnchored || component.Owner.Transform.Anchored;
return !component.RequireAnchored || IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(component.Owner.Uid).Anchored;
}
public void JoinAtmosphere(AtmosDeviceComponent component)
@@ -104,7 +104,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
if (!component.RequireAnchored)
return;
if(component.Owner.Transform.Anchored)
if(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(component.Owner.Uid).Anchored)
JoinAtmosphere(component);
else
LeaveAtmosphere(component);

View File

@@ -31,7 +31,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
if (!component.Enabled || !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodes))
return;
if (_atmosphereSystem.GetTileMixture(component.Owner.Transform.Coordinates) is not {} environment)
if (_atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(component.Owner.Uid).Coordinates) is not {} environment)
return;
foreach (var node in nodes.Nodes.Values)
@@ -52,7 +52,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
if (!component.Enabled || !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodes))
return;
if (_atmosphereSystem.GetTileMixture(component.Owner.Transform.Coordinates, true) is not {} environment)
if (_atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(component.Owner.Uid).Coordinates, true) is not {} environment)
environment = GasMixture.SpaceGas;
var lost = 0f;

View File

@@ -37,10 +37,10 @@ namespace Content.Server.Atmos.Piping.Other.EntitySystems
private bool CheckMinerOperation(GasMinerComponent miner, [NotNullWhen(true)] out GasMixture? environment)
{
environment = _atmosphereSystem.GetTileMixture(miner.Owner.Transform.Coordinates, true);
environment = _atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(miner.Owner.Uid).Coordinates, true);
// Space.
if (_atmosphereSystem.IsTileSpace(miner.Owner.Transform.Coordinates))
if (_atmosphereSystem.IsTileSpace(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(miner.Owner.Uid).Coordinates))
{
miner.Broken = true;
return false;

View File

@@ -84,7 +84,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User.Uid, out ActorComponent? actor))
return;
if (component.Owner.Transform.Anchored)
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(component.Owner.Uid).Anchored)
{
_userInterfaceSystem.TryOpen(uid, GasFilterUiKey.Key, actor.PlayerSession);
DirtyUI(uid, component);

View File

@@ -109,7 +109,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User.Uid, out ActorComponent? actor))
return;
if (component.Owner.Transform.Anchored)
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(component.Owner.Uid).Anchored)
{
_userInterfaceSystem.TryOpen(uid, GasMixerUiKey.Key, actor.PlayerSession);
DirtyUI(uid, component);

View File

@@ -211,7 +211,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
}
else
{
var environment = _atmosphereSystem.GetTileMixture(canister.Owner.Transform.Coordinates, true);
var environment = _atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(canister.Owner.Uid).Coordinates, true);
_atmosphereSystem.ReleaseGasTo(canister.Air, environment, canister.ReleasePressure);
}
}

View File

@@ -35,7 +35,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
if (!nodeContainer.TryGetNode(injector.InletName, out PipeNode? inlet))
return;
var environment = _atmosphereSystem.GetTileMixture(injector.Owner.Transform.Coordinates, true);
var environment = _atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(injector.Owner.Uid).Coordinates, true);
if (environment == null)
return;

View File

@@ -25,7 +25,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
private void OnPassiveVentUpdated(EntityUid uid, GasPassiveVentComponent vent, AtmosDeviceUpdateEvent args)
{
var environment = _atmosphereSystem.GetTileMixture(vent.Owner.Transform.Coordinates, true);
var environment = _atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(vent.Owner.Uid).Coordinates, true);
if (environment == null)
return;

View File

@@ -43,7 +43,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
return;
}
var environment = _atmosphereSystem.GetTileMixture(vent.Owner.Transform.Coordinates, true);
var environment = _atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(vent.Owner.Uid).Coordinates, true);
// We're in an air-blocked tile... Do nothing.
if (environment == null)

View File

@@ -44,14 +44,14 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
return;
}
var environment = _atmosphereSystem.GetTileMixture(scrubber.Owner.Transform.Coordinates, true);
var environment = _atmosphereSystem.GetTileMixture(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(scrubber.Owner.Uid).Coordinates, true);
Scrub(_atmosphereSystem, scrubber, appearance, environment, outlet);
if (!scrubber.WideNet) return;
// Scrub adjacent tiles too.
foreach (var adjacent in _atmosphereSystem.GetAdjacentTileMixtures(scrubber.Owner.Transform.Coordinates, false, true))
foreach (var adjacent in _atmosphereSystem.GetAdjacentTileMixtures(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(scrubber.Owner.Uid).Coordinates, false, true))
{
Scrub(_atmosphereSystem, scrubber, null, adjacent, outlet);
}