diff --git a/Content.Client/Chat/UI/SpeechBubble.cs b/Content.Client/Chat/UI/SpeechBubble.cs index 68c937a788..adb61d10e6 100644 --- a/Content.Client/Chat/UI/SpeechBubble.cs +++ b/Content.Client/Chat/UI/SpeechBubble.cs @@ -16,6 +16,7 @@ namespace Content.Client.Chat.UI [Dependency] private readonly IEyeManager _eyeManager = default!; [Dependency] private readonly IEntityManager _entityManager = default!; [Dependency] protected readonly IConfigurationManager ConfigManager = default!; + private readonly SharedTransformSystem _transformSystem; public enum SpeechType : byte { @@ -83,6 +84,7 @@ namespace Content.Client.Chat.UI { IoCManager.InjectDependencies(this); _senderEntity = senderEntity; + _transformSystem = _entityManager.System(); // Use text clipping so new messages don't overlap old ones being pushed up. RectClipContent = true; @@ -140,7 +142,7 @@ namespace Content.Client.Chat.UI } var offset = (-_eyeManager.CurrentEye.Rotation).ToWorldVec() * -EntityVerticalOffset; - var worldPos = xform.WorldPosition + offset; + var worldPos = _transformSystem.GetWorldPosition(xform) + offset; var lowerCenter = _eyeManager.WorldToScreen(worldPos) / UIScale; var screenPos = lowerCenter - new Vector2(ContentSize.X / 2, ContentSize.Y + _verticalOffsetAchieved); diff --git a/Content.Client/Explosion/ExplosionOverlay.cs b/Content.Client/Explosion/ExplosionOverlay.cs index 653f63e0f9..a005d0317b 100644 --- a/Content.Client/Explosion/ExplosionOverlay.cs +++ b/Content.Client/Explosion/ExplosionOverlay.cs @@ -16,6 +16,7 @@ public sealed class ExplosionOverlay : Overlay [Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly IEntityManager _entMan = default!; [Dependency] private readonly IPrototypeManager _proto = default!; + private readonly SharedTransformSystem _transformSystem; private SharedAppearanceSystem _appearance; public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV; @@ -26,6 +27,7 @@ public sealed class ExplosionOverlay : Overlay { IoCManager.InjectDependencies(this); _shader = _proto.Index("unshaded").Instance(); + _transformSystem = _entMan.System(); _appearance = appearanceSystem; } @@ -68,7 +70,7 @@ public sealed class ExplosionOverlay : Overlay continue; var xform = xforms.GetComponent(gridId); - var (_, _, worldMatrix, invWorldMatrix) = xform.GetWorldPositionRotationMatrixWithInv(xforms); + var (_, _, worldMatrix, invWorldMatrix) = _transformSystem.GetWorldPositionRotationMatrixWithInv(xform, xforms); gridBounds = invWorldMatrix.TransformBox(worldBounds).Enlarged(grid.TileSize * 2); drawHandle.SetTransform(worldMatrix); diff --git a/Content.Client/Fluids/PuddleOverlay.cs b/Content.Client/Fluids/PuddleOverlay.cs index a8c1d35510..caa5a92580 100644 --- a/Content.Client/Fluids/PuddleOverlay.cs +++ b/Content.Client/Fluids/PuddleOverlay.cs @@ -14,6 +14,7 @@ public sealed class PuddleOverlay : Overlay [Dependency] private readonly IEntityManager _entityManager = default!; [Dependency] private readonly IEntitySystemManager _entitySystemManager = default!; private readonly PuddleDebugOverlaySystem _debugOverlaySystem; + private readonly SharedTransformSystem _transformSystem; private readonly Color _heavyPuddle = new(0, 255, 255, 50); private readonly Color _mediumPuddle = new(0, 150, 255, 50); @@ -29,6 +30,7 @@ public sealed class PuddleOverlay : Overlay _debugOverlaySystem = _entitySystemManager.GetEntitySystem(); var cache = IoCManager.Resolve(); _font = new VectorFont(cache.GetResource("/Fonts/NotoSans/NotoSans-Regular.ttf"), 8); + _transformSystem = _entityManager.System(); } protected override void Draw(in OverlayDrawArgs args) @@ -56,7 +58,7 @@ public sealed class PuddleOverlay : Overlay continue; var gridXform = xformQuery.GetComponent(gridId); - var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(xformQuery); + var (_, _, worldMatrix, invWorldMatrix) = _transformSystem.GetWorldPositionRotationMatrixWithInv(gridXform, xformQuery); gridBounds = invWorldMatrix.TransformBox(args.WorldBounds).Enlarged(mapGrid.TileSize * 2); drawHandle.SetTransform(worldMatrix); @@ -89,7 +91,7 @@ public sealed class PuddleOverlay : Overlay continue; var gridXform = xformQuery.GetComponent(gridId); - var (_, _, matrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(xformQuery); + var (_, _, matrix, invMatrix) = _transformSystem.GetWorldPositionRotationMatrixWithInv(gridXform, xformQuery); var gridBounds = invMatrix.TransformBox(args.WorldBounds).Enlarged(mapGrid.TileSize * 2); foreach (var debugOverlayData in _debugOverlaySystem.GetData(gridId)) diff --git a/Content.Client/Interaction/DragDropSystem.cs b/Content.Client/Interaction/DragDropSystem.cs index d249766bbc..aab6a62776 100644 --- a/Content.Client/Interaction/DragDropSystem.cs +++ b/Content.Client/Interaction/DragDropSystem.cs @@ -42,6 +42,7 @@ public sealed class DragDropSystem : SharedDragDropSystem [Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly SharedPopupSystem _popup = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; // how often to recheck possible targets (prevents calling expensive // check logic each update) @@ -551,7 +552,7 @@ public sealed class DragDropSystem : SharedDragDropSystem if (Exists(_dragShadow)) { var mousePos = _eyeManager.PixelToMap(_inputManager.MouseScreenPosition); - Transform(_dragShadow.Value).WorldPosition = mousePos.Position; + _transformSystem.SetWorldPosition(_dragShadow.Value, mousePos.Position); } } } diff --git a/Content.Client/Maps/GridDraggingSystem.cs b/Content.Client/Maps/GridDraggingSystem.cs index 5e9250f0ce..5bbf5ff500 100644 --- a/Content.Client/Maps/GridDraggingSystem.cs +++ b/Content.Client/Maps/GridDraggingSystem.cs @@ -18,6 +18,7 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem [Dependency] private readonly IInputManager _inputManager = default!; [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly InputSystem _inputSystem = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; public bool Enabled { get; set; } @@ -62,11 +63,11 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem if (_dragging == null) return; if (_lastMousePosition != null && TryComp(_dragging.Value, out TransformComponent? xform) && - TryComp(_dragging.Value, out var body) && + TryComp(_dragging.Value, out _) && xform.MapID == _lastMousePosition.Value.MapId) { var tickTime = _gameTiming.TickPeriod; - var distance = _lastMousePosition.Value.Position - xform.WorldPosition; + var distance = _lastMousePosition.Value.Position - _transformSystem.GetWorldPosition(xform); RaiseNetworkEvent(new GridDragVelocityRequest() { Grid = GetNetEntity(_dragging.Value), diff --git a/Content.Client/NPC/HTN/HTNOverlay.cs b/Content.Client/NPC/HTN/HTNOverlay.cs index ad173f3b29..2cb02f1086 100644 --- a/Content.Client/NPC/HTN/HTNOverlay.cs +++ b/Content.Client/NPC/HTN/HTNOverlay.cs @@ -9,6 +9,7 @@ public sealed class HTNOverlay : Overlay { private readonly IEntityManager _entManager = default!; private readonly Font _font = default!; + private readonly SharedTransformSystem _transformSystem; public override OverlaySpace Space => OverlaySpace.ScreenSpace; @@ -16,6 +17,7 @@ public sealed class HTNOverlay : Overlay { _entManager = entManager; _font = new VectorFont(resourceCache.GetResource("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10); + _transformSystem = _entManager.System(); } protected override void Draw(in OverlayDrawArgs args) @@ -30,7 +32,7 @@ public sealed class HTNOverlay : Overlay if (string.IsNullOrEmpty(comp.DebugText) || xform.MapID != args.MapId) continue; - var worldPos = xform.WorldPosition; + var worldPos = _transformSystem.GetWorldPosition(xform); if (!args.WorldAABB.Contains(worldPos)) continue; diff --git a/Content.Client/NPC/NPCSteeringSystem.cs b/Content.Client/NPC/NPCSteeringSystem.cs index bb2145bce0..eda3d74cf7 100644 --- a/Content.Client/NPC/NPCSteeringSystem.cs +++ b/Content.Client/NPC/NPCSteeringSystem.cs @@ -81,10 +81,12 @@ public sealed class NPCSteeringOverlay : Overlay public override OverlaySpace Space => OverlaySpace.WorldSpace; private readonly IEntityManager _entManager; + private readonly SharedTransformSystem _transformSystem; public NPCSteeringOverlay(IEntityManager entManager) { _entManager = entManager; + _transformSystem = _entManager.System(); } protected override void Draw(in OverlayDrawArgs args) @@ -96,7 +98,7 @@ public sealed class NPCSteeringOverlay : Overlay continue; } - var (worldPos, worldRot) = xform.GetWorldPositionRotation(); + var (worldPos, worldRot) = _transformSystem.GetWorldPositionRotation(xform); if (!args.WorldAABB.Contains(worldPos)) continue; diff --git a/Content.Client/NetworkConfigurator/NetworkConfiguratorLinkOverlay.cs b/Content.Client/NetworkConfigurator/NetworkConfiguratorLinkOverlay.cs index 4fcdada868..19da5aa959 100644 --- a/Content.Client/NetworkConfigurator/NetworkConfiguratorLinkOverlay.cs +++ b/Content.Client/NetworkConfigurator/NetworkConfiguratorLinkOverlay.cs @@ -12,6 +12,7 @@ public sealed class NetworkConfiguratorLinkOverlay : Overlay [Dependency] private readonly IEntityManager _entityManager = default!; [Dependency] private readonly IRobustRandom _random = default!; private readonly DeviceListSystem _deviceListSystem; + private readonly SharedTransformSystem _transformSystem; public Dictionary Colors = new(); public EntityUid? Action; @@ -23,6 +24,7 @@ public sealed class NetworkConfiguratorLinkOverlay : Overlay IoCManager.InjectDependencies(this); _deviceListSystem = _entityManager.System(); + _transformSystem = _entityManager.System(); } protected override void Draw(in OverlayDrawArgs args) @@ -66,7 +68,7 @@ public sealed class NetworkConfiguratorLinkOverlay : Overlay continue; } - args.WorldHandle.DrawLine(sourceTransform.WorldPosition, linkTransform.WorldPosition, Colors[uid]); + args.WorldHandle.DrawLine(_transformSystem.GetWorldPosition(sourceTransform), _transformSystem.GetWorldPosition(linkTransform), Colors[uid]); } } } diff --git a/Content.Client/NodeContainer/NodeVisualizationOverlay.cs b/Content.Client/NodeContainer/NodeVisualizationOverlay.cs index 4e8a4a10ca..b0bdf8ed87 100644 --- a/Content.Client/NodeContainer/NodeVisualizationOverlay.cs +++ b/Content.Client/NodeContainer/NodeVisualizationOverlay.cs @@ -20,6 +20,7 @@ namespace Content.Client.NodeContainer private readonly IMapManager _mapManager; private readonly IInputManager _inputManager; private readonly IEntityManager _entityManager; + private readonly SharedTransformSystem _transformSystem; private readonly Dictionary<(int, int), NodeRenderData> _nodeIndex = new(); private readonly Dictionary>> _gridIndex = new (); @@ -46,6 +47,7 @@ namespace Content.Client.NodeContainer _mapManager = mapManager; _inputManager = inputManager; _entityManager = entityManager; + _transformSystem = _entityManager.System(); _font = cache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 12); } @@ -146,7 +148,7 @@ namespace Content.Client.NodeContainer foreach (var (gridId, gridDict) in _gridIndex) { var grid = _entityManager.GetComponent(gridId); - var (_, _, worldMatrix, invMatrix) = _entityManager.GetComponent(gridId).GetWorldPositionRotationMatrixWithInv(); + var (_, _, worldMatrix, invMatrix) = _transformSystem.GetWorldPositionRotationMatrixWithInv(gridId); var lCursorBox = invMatrix.TransformBox(cursorBox); foreach (var (pos, list) in gridDict) diff --git a/Content.Client/Outline/TargetOutlineSystem.cs b/Content.Client/Outline/TargetOutlineSystem.cs index df57578b1f..c69987fe77 100644 --- a/Content.Client/Outline/TargetOutlineSystem.cs +++ b/Content.Client/Outline/TargetOutlineSystem.cs @@ -23,6 +23,7 @@ public sealed class TargetOutlineSystem : EntitySystem [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!; [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; private bool _enabled = false; @@ -165,8 +166,8 @@ public sealed class TargetOutlineSystem : EntitySystem valid = _interactionSystem.InRangeUnobstructed(player, entity, Range); else if (Range >= 0) { - var origin = Transform(player).WorldPosition; - var target = Transform(entity).WorldPosition; + var origin = _transformSystem.GetWorldPosition(player); + var target = _transformSystem.GetWorldPosition(entity); valid = (origin - target).LengthSquared() <= Range; } diff --git a/Content.Client/Stealth/StealthSystem.cs b/Content.Client/Stealth/StealthSystem.cs index 0b94e41f6b..adb25e1ef6 100644 --- a/Content.Client/Stealth/StealthSystem.cs +++ b/Content.Client/Stealth/StealthSystem.cs @@ -11,6 +11,7 @@ namespace Content.Client.Stealth; public sealed class StealthSystem : SharedStealthSystem { [Dependency] private readonly IPrototypeManager _protoMan = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; private ShaderInstance _shader = default!; @@ -81,7 +82,7 @@ public sealed class StealthSystem : SharedStealthSystem if (!parent.IsValid()) return; // should never happen, but lets not kill the client. var parentXform = Transform(parent); - var reference = args.Viewport.WorldToLocal(parentXform.WorldPosition); + var reference = args.Viewport.WorldToLocal(_transformSystem.GetWorldPosition(parentXform)); reference.X = -reference.X; var visibility = GetVisibility(uid, component); diff --git a/Content.Client/Tabletop/TabletopSystem.cs b/Content.Client/Tabletop/TabletopSystem.cs index 0b55a1839c..034d3e4f02 100644 --- a/Content.Client/Tabletop/TabletopSystem.cs +++ b/Content.Client/Tabletop/TabletopSystem.cs @@ -27,6 +27,7 @@ namespace Content.Client.Tabletop [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly AppearanceSystem _appearance = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; // Time in seconds to wait until sending the location of a dragged entity to the server again private const float Delay = 1f / 10; // 10 Hz @@ -100,7 +101,7 @@ namespace Content.Client.Tabletop if (clampedCoords.Equals(MapCoordinates.Nullspace)) return; // Move the entity locally every update - EntityManager.GetComponent(_draggedEntity.Value).WorldPosition = clampedCoords.Position; + _transformSystem.SetWorldPosition(_draggedEntity.Value, clampedCoords.Position); // Increment total time passed _timePassed += frameTime; diff --git a/Content.Client/UserInterface/Systems/Viewport/ViewportUIController.cs b/Content.Client/UserInterface/Systems/Viewport/ViewportUIController.cs index 59747b1b0f..613f71e79b 100644 --- a/Content.Client/UserInterface/Systems/Viewport/ViewportUIController.cs +++ b/Content.Client/UserInterface/Systems/Viewport/ViewportUIController.cs @@ -15,7 +15,6 @@ public sealed class ViewportUIController : UIController [Dependency] private readonly IPlayerManager _playerMan = default!; [Dependency] private readonly IEntityManager _entMan = default!; [Dependency] private readonly IConfigurationManager _configurationManager = default!; - public static readonly Vector2i ViewportSize = (EyeManager.PixelsPerMeter * 21, EyeManager.PixelsPerMeter * 15); public const int ViewportHeight = 15; private MainViewport? Viewport => UIManager.ActiveScreen?.GetWidget(); diff --git a/Content.Client/Weapons/Melee/MeleeWeaponSystem.Effects.cs b/Content.Client/Weapons/Melee/MeleeWeaponSystem.Effects.cs index 3e1a4b1906..540d76c129 100644 --- a/Content.Client/Weapons/Melee/MeleeWeaponSystem.Effects.cs +++ b/Content.Client/Weapons/Melee/MeleeWeaponSystem.Effects.cs @@ -213,7 +213,7 @@ public sealed partial class MeleeWeaponSystem private void UpdateEffects() { var query = EntityQueryEnumerator(); - while (query.MoveNext(out var arcComponent, out var xform)) + while (query.MoveNext(out var uid, out var arcComponent, out var xform)) { if (arcComponent.User == null) continue; @@ -226,7 +226,7 @@ public sealed partial class MeleeWeaponSystem targetPos += entRotation.RotateVec(arcComponent.Offset); } - TransformSystem.SetWorldPosition(xform, targetPos); + TransformSystem.SetWorldPosition(uid, targetPos); } } } diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs index 2e41e45d3f..b96dd0ac48 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs @@ -237,7 +237,7 @@ namespace Content.Server.Atmos.EntitySystems // TODO: Technically these directions won't be correct but uhh I'm just here for optimisations buddy not to fix my old bugs. if (throwTarget != EntityCoordinates.Invalid) { - var pos = ((throwTarget.ToMap(EntityManager, _transformSystem).Position - xform.WorldPosition).Normalized() + dirVec).Normalized(); + var pos = ((_transformSystem.ToMapCoordinates(throwTarget).Position - _transformSystem.GetWorldPosition(xform)).Normalized() + dirVec).Normalized(); _physics.ApplyLinearImpulse(uid, pos * moveForce, body: physics); } else diff --git a/Content.Server/Chemistry/EntitySystems/VaporSystem.cs b/Content.Server/Chemistry/EntitySystems/VaporSystem.cs index 8e12670ca6..dbb8572299 100644 --- a/Content.Server/Chemistry/EntitySystems/VaporSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/VaporSystem.cs @@ -28,6 +28,7 @@ namespace Content.Server.Chemistry.EntitySystems [Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!; [Dependency] private readonly ThrowingSystem _throwing = default!; [Dependency] private readonly ReactiveSystem _reactive = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; private const float ReactTime = 0.125f; @@ -69,7 +70,7 @@ namespace Content.Server.Chemistry.EntitySystems _throwing.TryThrow(vapor, dir, speed, user: user); - var distance = (target.Position - vaporXform.WorldPosition).Length(); + var distance = (target.Position - _transformSystem.GetWorldPosition(vaporXform)).Length(); var time = (distance / physics.LinearVelocity.Length()); despawn.Lifetime = MathF.Min(aliveTime, time); } diff --git a/Content.Server/Commands/CommandUtils.cs b/Content.Server/Commands/CommandUtils.cs index 172f3324e3..30ea41b7c9 100644 --- a/Content.Server/Commands/CommandUtils.cs +++ b/Content.Server/Commands/CommandUtils.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using Robust.Server.Player; using Robust.Shared.Console; @@ -55,13 +55,15 @@ namespace Content.Server.Commands { var entMan = IoCManager.Resolve(); var transform = entMan.GetComponent(ent); + var transformSystem = entMan.System(); + var worldPosition = transformSystem.GetWorldPosition(transform); // gross, is there a better way to do this? ruleString = ruleString.Replace("$ID", ent.ToString()); ruleString = ruleString.Replace("$WX", - transform.WorldPosition.X.ToString(CultureInfo.InvariantCulture)); + worldPosition.X.ToString(CultureInfo.InvariantCulture)); ruleString = ruleString.Replace("$WY", - transform.WorldPosition.Y.ToString(CultureInfo.InvariantCulture)); + worldPosition.Y.ToString(CultureInfo.InvariantCulture)); ruleString = ruleString.Replace("$LX", transform.LocalPosition.X.ToString(CultureInfo.InvariantCulture)); ruleString = ruleString.Replace("$LY", @@ -73,12 +75,13 @@ namespace Content.Server.Commands if (player.AttachedEntity is {Valid: true} p) { var pTransform = entMan.GetComponent(p); + var pWorldPosition = transformSystem.GetWorldPosition(pTransform); ruleString = ruleString.Replace("$PID", ent.ToString()); ruleString = ruleString.Replace("$PWX", - pTransform.WorldPosition.X.ToString(CultureInfo.InvariantCulture)); + pWorldPosition.X.ToString(CultureInfo.InvariantCulture)); ruleString = ruleString.Replace("$PWY", - pTransform.WorldPosition.Y.ToString(CultureInfo.InvariantCulture)); + pWorldPosition.Y.ToString(CultureInfo.InvariantCulture)); ruleString = ruleString.Replace("$PLX", pTransform.LocalPosition.X.ToString(CultureInfo.InvariantCulture)); ruleString = ruleString.Replace("$PLY", diff --git a/Content.Server/DeviceNetwork/Systems/WirelessNetworkSystem.cs b/Content.Server/DeviceNetwork/Systems/WirelessNetworkSystem.cs index b27ef52eca..1741afd4ce 100644 --- a/Content.Server/DeviceNetwork/Systems/WirelessNetworkSystem.cs +++ b/Content.Server/DeviceNetwork/Systems/WirelessNetworkSystem.cs @@ -6,6 +6,8 @@ namespace Content.Server.DeviceNetwork.Systems [UsedImplicitly] public sealed class WirelessNetworkSystem : EntitySystem { + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; + public override void Initialize() { base.Initialize(); @@ -25,7 +27,7 @@ namespace Content.Server.DeviceNetwork.Systems return; if (xform.MapID != args.SenderTransform.MapID - || (ownPosition - xform.WorldPosition).Length() > sendingComponent.Range) + || (ownPosition - _transformSystem.GetWorldPosition(xform)).Length() > sendingComponent.Range) { args.Cancel(); } diff --git a/Content.Server/Dragon/DragonSystem.cs b/Content.Server/Dragon/DragonSystem.cs index 29875c60ca..42610a0323 100644 --- a/Content.Server/Dragon/DragonSystem.cs +++ b/Content.Server/Dragon/DragonSystem.cs @@ -156,7 +156,7 @@ public sealed partial class DragonSystem : EntitySystem } // cant put a rift on solars - foreach (var tile in grid.GetTilesIntersecting(new Circle(xform.WorldPosition, RiftTileRadius), false)) + foreach (var tile in grid.GetTilesIntersecting(new Circle(_transform.GetWorldPosition(xform), RiftTileRadius), false)) { if (!tile.IsSpace(_tileDef)) continue; diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs index d88945bc19..75bb606441 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs @@ -105,7 +105,7 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem var xforms = EntityManager.GetEntityQuery(); var xform = xforms.GetComponent(gridToTransform); - var (_, gridWorldRotation, gridWorldMatrix, invGridWorldMatrid) = xform.GetWorldPositionRotationMatrixWithInv(xforms); + var (_, gridWorldRotation, gridWorldMatrix, invGridWorldMatrid) = _transformSystem.GetWorldPositionRotationMatrixWithInv(xform, xforms); var localEpicentre = (Vector2i) Vector2.Transform(epicentre.Position, invGridWorldMatrid); var matrix = offsetMatrix * gridWorldMatrix * targetMatrix; diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs index 1eeed949cc..6de516ec0f 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs @@ -406,7 +406,7 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem if (player.AttachedEntity is not EntityUid uid) continue; - var playerPos = Transform(player.AttachedEntity!.Value).WorldPosition; + var playerPos = _transformSystem.GetWorldPosition(player.AttachedEntity!.Value); var delta = epicenter.Position - playerPos; if (delta.EqualsApprox(Vector2.Zero)) diff --git a/Content.Server/Hands/Systems/HandsSystem.cs b/Content.Server/Hands/Systems/HandsSystem.cs index 12c2a396de..903fd1ff3f 100644 --- a/Content.Server/Hands/Systems/HandsSystem.cs +++ b/Content.Server/Hands/Systems/HandsSystem.cs @@ -201,7 +201,7 @@ namespace Content.Server.Hands.Systems throwEnt = splitStack.Value; } - var direction = coordinates.ToMapPos(EntityManager, _transformSystem) - Transform(player).WorldPosition; + var direction = _transformSystem.ToMapCoordinates(coordinates).Position - _transformSystem.GetWorldPosition(player); if (direction == Vector2.Zero) return true; diff --git a/Content.Server/Maps/GridDraggingSystem.cs b/Content.Server/Maps/GridDraggingSystem.cs index 76b2e29dea..cf71e012f4 100644 --- a/Content.Server/Maps/GridDraggingSystem.cs +++ b/Content.Server/Maps/GridDraggingSystem.cs @@ -12,6 +12,7 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem { [Dependency] private readonly IConGroupController _admin = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; private readonly HashSet _draggers = new(); @@ -76,8 +77,6 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem return; } - var gridXform = Transform(grid); - - gridXform.WorldPosition = msg.WorldPosition; + _transformSystem.SetWorldPosition(grid, msg.WorldPosition); } } diff --git a/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs b/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs index c5c44056b9..aa28a8063c 100644 --- a/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs +++ b/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using Content.Server.Interaction; using Content.Server.Mech.Equipment.Components; using Content.Server.Mech.Systems; @@ -85,7 +85,7 @@ public sealed class MechGrabberSystem : EntitySystem var (mechPos, mechRot) = _transform.GetWorldPositionRotation(mechxform); var offset = mechPos + mechRot.RotateVec(component.DepositOffset); - _transform.SetWorldPositionRotation(xform, offset, Angle.Zero); + _transform.SetWorldPositionRotation(toRemove, offset, Angle.Zero); _mech.UpdateUserInterface(mech); } diff --git a/Content.Server/Movement/StressTestMovementSystem.cs b/Content.Server/Movement/StressTestMovementSystem.cs index 81ea6840e3..51916204da 100644 --- a/Content.Server/Movement/StressTestMovementSystem.cs +++ b/Content.Server/Movement/StressTestMovementSystem.cs @@ -39,7 +39,7 @@ public sealed class StressTestMovementSystem : EntitySystem var x = MathF.Sin(stressTest.Progress * MathHelper.TwoPi); var y = MathF.Cos(stressTest.Progress * MathHelper.TwoPi); - _transform.SetWorldPosition(transform, stressTest.Origin + new Vector2(x, y) * 5); + _transform.SetWorldPosition((uid, transform), stressTest.Origin + new Vector2(x, y) * 5); } } } diff --git a/Content.Server/Pointing/EntitySystems/RoguePointingSystem.cs b/Content.Server/Pointing/EntitySystems/RoguePointingSystem.cs index be3ceb3b08..bdd652f38f 100644 --- a/Content.Server/Pointing/EntitySystems/RoguePointingSystem.cs +++ b/Content.Server/Pointing/EntitySystems/RoguePointingSystem.cs @@ -12,6 +12,7 @@ namespace Content.Server.Pointing.EntitySystems [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly ExplosionSystem _explosion = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; private EntityUid? RandomNearbyPlayer(EntityUid uid, RoguePointingArrowComponent? component = null, TransformComponent? transform = null) { @@ -66,27 +67,28 @@ namespace Content.Server.Pointing.EntitySystems } component.TurningDelay -= frameTime; + var (transformPos, transformRot) = _transformSystem.GetWorldPositionRotation(transform); if (component.TurningDelay > 0) { - var difference = Comp(chasing).WorldPosition - transform.WorldPosition; + var difference = _transformSystem.GetWorldPosition(chasing) - transformPos; var angle = difference.ToAngle(); var adjusted = angle.Degrees + 90; var newAngle = Angle.FromDegrees(adjusted); - transform.WorldRotation = newAngle; + _transformSystem.SetWorldRotation(transform, newAngle); UpdateAppearance(uid, component, transform); continue; } - transform.WorldRotation += Angle.FromDegrees(20); + _transformSystem.SetWorldRotation(transform, transformRot + Angle.FromDegrees(20)); UpdateAppearance(uid, component, transform); - var toChased = Comp(chasing).WorldPosition - transform.WorldPosition; + var toChased = _transformSystem.GetWorldPosition(chasing) - transformPos; - transform.WorldPosition += toChased * frameTime * component.ChasingSpeed; + _transformSystem.SetWorldPosition((uid, transform), transformPos + (toChased * frameTime * component.ChasingSpeed)); component.ChasingTime -= frameTime; diff --git a/Content.Server/Respawn/SpecialRespawnSystem.cs b/Content.Server/Respawn/SpecialRespawnSystem.cs index bdaa4a40bc..cbda98f263 100644 --- a/Content.Server/Respawn/SpecialRespawnSystem.cs +++ b/Content.Server/Respawn/SpecialRespawnSystem.cs @@ -1,4 +1,4 @@ -using Content.Server.Administration.Logs; +using Content.Server.Administration.Logs; using Content.Server.Atmos.EntitySystems; using Content.Server.Chat.Managers; using Content.Server.GameTicking; @@ -157,7 +157,7 @@ public sealed class SpecialRespawnSystem : SharedSpecialRespawnSystem var tile = tileRef.GridIndices; var found = false; - var (gridPos, _, gridMatrix) = xform.GetWorldPositionRotationMatrix(); + var (gridPos, _, gridMatrix) = _transform.GetWorldPositionRotationMatrix(xform); var gridBounds = gridMatrix.TransformBox(grid.LocalAABB); //Obviously don't put anything ridiculous in here diff --git a/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs b/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs index c889d59f15..f972865509 100644 --- a/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs +++ b/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs @@ -42,6 +42,7 @@ public sealed partial class RevenantSystem [Dependency] private readonly GhostSystem _ghost = default!; [Dependency] private readonly TileSystem _tile = default!; [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; private void InitializeAbilities() { @@ -227,7 +228,7 @@ public sealed partial class RevenantSystem var xform = Transform(uid); if (!TryComp(xform.GridUid, out var map)) return; - var tiles = map.GetTilesIntersecting(Box2.CenteredAround(xform.WorldPosition, + var tiles = map.GetTilesIntersecting(Box2.CenteredAround(_transformSystem.GetWorldPosition(xform), new Vector2(component.DefileRadius * 2, component.DefileRadius))).ToArray(); _random.Shuffle(tiles); diff --git a/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs b/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs index e575b0403b..f02c2bfd0d 100644 --- a/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs +++ b/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs @@ -22,6 +22,7 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem [Dependency] private readonly PhysicsSystem _physics = default!; [Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly SharedPointLightSystem _light = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; [Dependency] private readonly TagSystem _tags = default!; public override void Initialize() @@ -234,7 +235,7 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem if (!gen1XForm.Anchored) return false; - var genWorldPosRot = gen1XForm.GetWorldPositionRotation(); + var genWorldPosRot = _transformSystem.GetWorldPositionRotation(gen1XForm); var dirRad = dir.ToAngle() + genWorldPosRot.WorldRotation; //needs to be like this for the raycast to work properly var ray = new CollisionRay(genWorldPosRot.WorldPosition, dirRad.ToVec(), component.CollisionMask); diff --git a/Content.Server/Singularity/EntitySystems/ContainmentFieldSystem.cs b/Content.Server/Singularity/EntitySystems/ContainmentFieldSystem.cs index 0af4954519..d3a32f5006 100644 --- a/Content.Server/Singularity/EntitySystems/ContainmentFieldSystem.cs +++ b/Content.Server/Singularity/EntitySystems/ContainmentFieldSystem.cs @@ -1,4 +1,4 @@ -using Content.Server.Popups; +using Content.Server.Popups; using Content.Server.Shuttles.Components; using Content.Server.Singularity.Events; using Content.Shared.Popups; @@ -13,6 +13,7 @@ public sealed class ContainmentFieldSystem : EntitySystem { [Dependency] private readonly ThrowingSystem _throwing = default!; [Dependency] private readonly PopupSystem _popupSystem = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; public override void Initialize() { @@ -34,8 +35,8 @@ public sealed class ContainmentFieldSystem : EntitySystem if (TryComp(otherBody, out var physics) && physics.Mass <= component.MaxMass && physics.Hard) { - var fieldDir = Transform(uid).WorldPosition; - var playerDir = Transform(otherBody).WorldPosition; + var fieldDir = _transformSystem.GetWorldPosition(uid); + var playerDir = _transformSystem.GetWorldPosition(otherBody); _throwing.TryThrow(otherBody, playerDir-fieldDir, baseThrowSpeed: component.ThrowForce); } diff --git a/Content.Server/Solar/EntitySystems/PowerSolarSystem.cs b/Content.Server/Solar/EntitySystems/PowerSolarSystem.cs index 6a8fc68d97..4f1cdb0eb0 100644 --- a/Content.Server/Solar/EntitySystems/PowerSolarSystem.cs +++ b/Content.Server/Solar/EntitySystems/PowerSolarSystem.cs @@ -18,6 +18,7 @@ namespace Content.Server.Solar.EntitySystems { [Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly SharedPhysicsSystem _physicsSystem = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; /// /// Maximum panel angular velocity range - used to stop people rotating panels fast enough that the lag prevention becomes noticable @@ -112,7 +113,7 @@ namespace Content.Server.Solar.EntitySystems while (query.MoveNext(out var uid, out var panel, out var xform)) { TotalPanelPower += panel.MaxSupply * panel.Coverage; - xform.WorldRotation = TargetPanelRotation; + _transformSystem.SetWorldRotation(xform, TargetPanelRotation); _updateQueue.Enqueue((uid, panel)); } } @@ -135,7 +136,7 @@ namespace Content.Server.Solar.EntitySystems // directly downwards (abs(theta) = pi) = coverage -1 // as TowardsSun + = CCW, // panelRelativeToSun should - = CW - var panelRelativeToSun = xform.WorldRotation - TowardsSun; + var panelRelativeToSun = _transformSystem.GetWorldRotation(xform) - TowardsSun; // essentially, given cos = X & sin = Y & Y is 'downwards', // then for the first 90 degrees of rotation in either direction, // this plots the lower-right quadrant of a circle. @@ -153,7 +154,7 @@ namespace Content.Server.Solar.EntitySystems if (coverage > 0) { // Determine if the solar panel is occluded, and zero out coverage if so. - var ray = new CollisionRay(xform.WorldPosition, TowardsSun.ToWorldVec(), (int) CollisionGroup.Opaque); + var ray = new CollisionRay(_transformSystem.GetWorldPosition(xform), TowardsSun.ToWorldVec(), (int) CollisionGroup.Opaque); var rayCastResults = _physicsSystem.IntersectRayWithPredicate( xform.MapID, ray, diff --git a/Content.Server/Worldgen/Systems/BaseWorldSystem.cs b/Content.Server/Worldgen/Systems/BaseWorldSystem.cs index 78326651c9..7a9e74375c 100644 --- a/Content.Server/Worldgen/Systems/BaseWorldSystem.cs +++ b/Content.Server/Worldgen/Systems/BaseWorldSystem.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using Content.Server.Worldgen.Components; using JetBrains.Annotations; @@ -12,6 +12,7 @@ namespace Content.Server.Worldgen.Systems; public abstract class BaseWorldSystem : EntitySystem { [Dependency] private readonly WorldControllerSystem _worldController = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; /// /// Gets a chunk's coordinates in chunk space as an integer value. @@ -25,7 +26,7 @@ public abstract class BaseWorldSystem : EntitySystem if (!Resolve(ent, ref xform)) throw new Exception("Failed to resolve transform, somehow."); - return WorldGen.WorldToChunkCoords(xform.WorldPosition).Floored(); + return WorldGen.WorldToChunkCoords(_transformSystem.GetWorldPosition(xform)).Floored(); } /// @@ -40,7 +41,7 @@ public abstract class BaseWorldSystem : EntitySystem if (!Resolve(ent, ref xform)) throw new Exception("Failed to resolve transform, somehow."); - return WorldGen.WorldToChunkCoords(xform.WorldPosition); + return WorldGen.WorldToChunkCoords(_transformSystem.GetWorldPosition(xform)); } /// diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ThrowArtifactSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ThrowArtifactSystem.cs index 8708e0ff4e..0591222996 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ThrowArtifactSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ThrowArtifactSystem.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; using Content.Server.Xenoarchaeology.XenoArtifacts.Events; using Content.Shared.Maps; @@ -31,7 +31,7 @@ public sealed class ThrowArtifactSystem : EntitySystem if (TryComp(xform.GridUid, out var grid)) { var tiles = grid.GetTilesIntersecting( - Box2.CenteredAround(xform.WorldPosition, new Vector2(component.Range * 2, component.Range))); + Box2.CenteredAround(_transform.GetWorldPosition(xform), new Vector2(component.Range * 2, component.Range))); foreach (var tile in tiles) { diff --git a/Content.Shared/Construction/Conditions/WallmountCondition.cs b/Content.Shared/Construction/Conditions/WallmountCondition.cs index fe4336e6fc..f1d056165e 100644 --- a/Content.Shared/Construction/Conditions/WallmountCondition.cs +++ b/Content.Shared/Construction/Conditions/WallmountCondition.cs @@ -20,13 +20,13 @@ namespace Content.Shared.Construction.Conditions // get blueprint and user position var transformSystem = entManager.System(); - var userWorldPosition = entManager.GetComponent(user).WorldPosition; + var userWorldPosition = transformSystem.GetWorldPosition(user); var objWorldPosition = location.ToMap(entManager, transformSystem).Position; // find direction from user to blueprint var userToObject = (objWorldPosition - userWorldPosition); // get direction of the grid being placed on as an offset. - var gridRotation = entManager.GetComponent(location.EntityId).WorldRotation; + var gridRotation = transformSystem.GetWorldRotation(location.EntityId); var directionWithOffset = gridRotation.RotateVec(direction.ToVec()); // dot product will be positive if user direction and blueprint are co-directed diff --git a/Content.Shared/Tiles/FloorTileSystem.cs b/Content.Shared/Tiles/FloorTileSystem.cs index 97ed908ed3..f031292f23 100644 --- a/Content.Shared/Tiles/FloorTileSystem.cs +++ b/Content.Shared/Tiles/FloorTileSystem.cs @@ -156,7 +156,7 @@ public sealed class FloorTileSystem : EntitySystem var grid = _mapManager.CreateGridEntity(locationMap.MapId); var gridXform = Transform(grid); - _transform.SetWorldPosition(gridXform, locationMap.Position); + _transform.SetWorldPosition((grid, gridXform), locationMap.Position); location = new EntityCoordinates(grid, Vector2.Zero); PlaceAt(args.User, grid, grid.Comp, location, _tileDefinitionManager[component.OutputTiles[0]].TileId, component.PlaceTileSound, grid.Comp.TileSize / 2f); return;