From 1416942beacecf878a05402a559f1d71452b9ac0 Mon Sep 17 00:00:00 2001 From: Visne <39844191+Visne@users.noreply.github.com> Date: Wed, 30 Aug 2023 04:05:19 +0200 Subject: [PATCH] Remove most usages of obsolete TransformComponent methods (#19571) --- .../SpawnExplosion/ExplosionDebugOverlay.cs | 7 +++- .../Atmos/Overlays/AtmosDebugOverlay.cs | 4 +- .../Atmos/Overlays/GasTileOverlay.cs | 6 ++- Content.Client/Audio/AmbientSoundSystem.cs | 7 ++-- .../CardboardBox/CardboardBoxSystem.cs | 3 +- Content.Client/Chat/UI/SpeechBubble.cs | 36 ++++++++++++++---- .../Decals/Overlays/DecalOverlay.cs | 4 +- Content.Client/DragDrop/DragDropSystem.cs | 7 ++-- Content.Client/Explosion/ExplosionOverlay.cs | 4 +- Content.Client/Fluids/PuddleOverlay.cs | 6 ++- .../HealthOverlay/HealthOverlaySystem.cs | 3 +- Content.Client/Maps/GridDraggingSystem.cs | 12 +++--- .../CrewMonitoringWindow.xaml.cs | 4 +- Content.Client/NPC/HTN/HTNOverlay.cs | 8 ++-- Content.Client/NPC/NPCSteeringSystem.cs | 4 +- Content.Client/NPC/PathfindingSystem.cs | 21 +++++----- .../NetworkConfiguratorLinkOverlay.cs | 4 +- .../NodeContainer/NodeVisualizationOverlay.cs | 4 +- Content.Client/Outline/TargetOutlineSystem.cs | 5 ++- Content.Client/Pinpointer/NavMapSystem.cs | 4 +- Content.Client/Pinpointer/UI/NavMapControl.cs | 6 ++- .../ReplaySpectatorSystem.Position.cs | 3 +- .../Systems/ShuttleSystem.EmergencyConsole.cs | 9 +++-- Content.Client/Shuttles/UI/DockingControl.cs | 13 +++++-- .../Shuttles/UI/ShuttleConsoleWindow.xaml.cs | 4 +- Content.Client/Stealth/StealthSystem.cs | 3 +- Content.Client/Tabletop/TabletopSystem.cs | 24 +++++++----- .../Systems/Chat/ChatUIController.cs | 4 +- .../Systems/Viewport/ViewportUIController.cs | 7 +++- .../Administration/Commands/AGhost.cs | 2 +- .../Administration/Commands/WarpCommand.cs | 7 ++-- .../Systems/AdminVerbSystem.Smites.cs | 5 ++- .../EntitySystems/AtmosDebugOverlaySystem.cs | 3 +- .../AtmosphereSystem.HighPressureDelta.cs | 6 ++- Content.Server/Bible/BibleSystem.cs | 3 +- Content.Server/Body/Systems/BodySystem.cs | 5 ++- .../EntitySystems/RehydratableSystem.cs | 3 +- .../Chemistry/EntitySystems/VaporSystem.cs | 3 +- Content.Server/Climbing/ClimbSystem.cs | 5 ++- Content.Server/Commands/CommandUtils.cs | 38 ------------------- .../Construction/Completions/SnapToGrid.cs | 2 +- .../Construction/ConstructionSystem.Graph.cs | 2 +- .../ConstructionSystem.Initial.cs | 3 +- .../Systems/WirelessNetworkSystem.cs | 4 +- Content.Server/Dragon/DragonSystem.cs | 3 +- .../EntitySystems/ExplosionGridTileFlood.cs | 7 ++-- .../EntitySystems/ExplosionSystem.GridMap.cs | 7 ++-- .../EntitySystems/ExplosionSystem.TileFill.cs | 4 +- .../EntitySystems/ExplosionSystem.cs | 2 +- .../PuddleDebugDebugOverlaySystem.cs | 3 +- .../GameTicking/GameTicker.Spawning.cs | 2 +- Content.Server/Ghost/GhostSystem.cs | 12 +++--- Content.Server/Hands/Systems/HandsSystem.cs | 3 +- .../ImmovableRod/ImmovableRodSystem.cs | 5 ++- Content.Server/Lightning/LightningSystem.cs | 3 +- Content.Server/Magic/MagicSystem.cs | 5 ++- Content.Server/Maps/GridDraggingSystem.cs | 10 +++-- .../EntitySystems/MechGrabberSystem.cs | 2 +- .../Pathfinding/PathfindingSystem.Distance.cs | 2 +- .../NPC/Pathfinding/PathfindingSystem.Grid.cs | 3 +- .../NPC/Pathfinding/PathfindingSystem.cs | 3 +- .../EntitySystems/RoguePointingSystem.cs | 11 +++--- .../Polymorph/Systems/PolymorphSystem.cs | 6 +-- .../Respawn/SpecialRespawnSystem.cs | 3 +- .../EntitySystems/RevenantSystem.Abilities.cs | 3 +- Content.Server/Salvage/SalvageRulerCommand.cs | 2 +- .../Systems/EmergencyShuttleSystem.cs | 3 +- .../Systems/ShuttleSystem.FasterThanLight.cs | 17 +++++---- .../Systems/ShuttleSystem.GridFill.cs | 2 +- .../Shuttles/Systems/ShuttleSystem.Impact.cs | 4 +- .../ContainmentFieldGeneratorSystem.cs | 5 ++- .../EntitySystems/ContainmentFieldSystem.cs | 11 +++--- .../Solar/EntitySystems/PowerSolarSystem.cs | 7 ++-- .../Standing/StandingStateSystem.cs | 3 +- .../Worldgen/Systems/BaseWorldSystem.cs | 5 ++- .../Effects/Systems/ThrowArtifactSystem.cs | 3 +- .../Body/Systems/SharedBodySystem.Organs.cs | 4 +- .../Body/Systems/SharedBodySystem.Parts.cs | 4 +- .../Body/Systems/SharedBodySystem.cs | 1 + .../Buckle/SharedBuckleSystem.Buckle.cs | 2 +- Content.Shared/Buckle/SharedBuckleSystem.cs | 2 +- .../Conditions/WallmountCondition.cs | 5 ++- .../Containers/ContainerFillSystem.cs | 3 +- .../EntitySystems/SharedHandsSystem.Drop.cs | 8 +++- .../Interaction/RotateToFaceSystem.cs | 4 +- .../Interaction/SharedInteractionSystem.cs | 4 +- .../Inventory/InventorySystem.Equip.cs | 3 +- Content.Shared/Maps/TurfHelpers.cs | 2 +- .../Controllers/SharedConveyorController.cs | 3 +- .../Placeable/PlaceableSurfaceSystem.cs | 5 ++- .../Random/Helpers/SharedEntityExtensions.cs | 5 ++- 91 files changed, 312 insertions(+), 221 deletions(-) diff --git a/Content.Client/Administration/UI/SpawnExplosion/ExplosionDebugOverlay.cs b/Content.Client/Administration/UI/SpawnExplosion/ExplosionDebugOverlay.cs index e175f39661..7f34d91069 100644 --- a/Content.Client/Administration/UI/SpawnExplosion/ExplosionDebugOverlay.cs +++ b/Content.Client/Administration/UI/SpawnExplosion/ExplosionDebugOverlay.cs @@ -14,6 +14,7 @@ public sealed class ExplosionDebugOverlay : Overlay [Dependency] private readonly IEntityManager _entityManager = default!; [Dependency] private readonly IEyeManager _eyeManager = default!; [Dependency] private readonly IMapManager _mapManager = default!; + private readonly SharedTransformSystem _transform; public Dictionary>? SpaceTiles; public Dictionary>> Tiles = new(); @@ -35,6 +36,8 @@ public sealed class ExplosionDebugOverlay : Overlay var cache = IoCManager.Resolve(); _font = new VectorFont(cache.GetResource("/Fonts/NotoSans/NotoSans-Regular.ttf"), 8); + + _transform = _entityManager.System(); } protected override void Draw(in OverlayDrawArgs args) @@ -68,7 +71,7 @@ public sealed class ExplosionDebugOverlay : Overlay continue; var gridXform = xformQuery.GetComponent(grid.Owner); - var (_, _, matrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(xformQuery); + var (_, _, matrix, invMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform, xformQuery); gridBounds = invMatrix.TransformBox(args.WorldBounds).Enlarged(grid.TileSize * 2); DrawText(handle, gridBounds, matrix, tileSets, grid.TileSize); } @@ -136,7 +139,7 @@ public sealed class ExplosionDebugOverlay : Overlay continue; var gridXform = xformQuery.GetComponent(grid.Owner); - var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(xformQuery); + var (_, _, worldMatrix, invWorldMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform, xformQuery); gridBounds = invWorldMatrix.TransformBox(args.WorldBounds).Enlarged(grid.TileSize * 2); handle.SetTransform(worldMatrix); DrawTiles(handle, gridBounds, tileSets, SpaceTileSize); diff --git a/Content.Client/Atmos/Overlays/AtmosDebugOverlay.cs b/Content.Client/Atmos/Overlays/AtmosDebugOverlay.cs index 6d1752a8c9..f922fce3a0 100644 --- a/Content.Client/Atmos/Overlays/AtmosDebugOverlay.cs +++ b/Content.Client/Atmos/Overlays/AtmosDebugOverlay.cs @@ -17,6 +17,7 @@ namespace Content.Client.Atmos.Overlays [Dependency] private readonly IEntityManager _entManager = default!; [Dependency] private readonly IMapManager _mapManager = default!; + private readonly SharedTransformSystem _transform; public override OverlaySpace Space => OverlaySpace.WorldSpace; @@ -25,6 +26,7 @@ namespace Content.Client.Atmos.Overlays IoCManager.InjectDependencies(this); _atmosDebugOverlaySystem = system; + _transform = _entManager.System(); } protected override void Draw(in OverlayDrawArgs args) @@ -47,7 +49,7 @@ namespace Content.Client.Atmos.Overlays !_entManager.TryGetComponent(mapGrid.Owner, out var xform)) continue; - drawHandle.SetTransform(xform.WorldMatrix); + drawHandle.SetTransform(_transform.GetWorldMatrix(xform)); for (var pass = 0; pass < 2; pass++) { diff --git a/Content.Client/Atmos/Overlays/GasTileOverlay.cs b/Content.Client/Atmos/Overlays/GasTileOverlay.cs index d3e6dbc8de..f777830bd8 100644 --- a/Content.Client/Atmos/Overlays/GasTileOverlay.cs +++ b/Content.Client/Atmos/Overlays/GasTileOverlay.cs @@ -19,6 +19,7 @@ namespace Content.Client.Atmos.Overlays public sealed class GasTileOverlay : Overlay { private readonly IEntityManager _entManager; + private readonly SharedTransformSystem _transform; private readonly IMapManager _mapManager; public override OverlaySpace Space => OverlaySpace.WorldSpaceEntities; @@ -48,6 +49,7 @@ namespace Content.Client.Atmos.Overlays public GasTileOverlay(GasTileOverlaySystem system, IEntityManager entManager, IResourceCache resourceCache, IPrototypeManager protoMan, SpriteSystem spriteSys) { _entManager = entManager; + _transform = entManager.System(); _mapManager = IoCManager.Resolve(); _shader = protoMan.Index("unshaded").Instance(); ZIndex = GasOverlayZIndex; @@ -182,7 +184,7 @@ namespace Content.Client.Atmos.Overlays // TODO: WorldBounds callback. _mapManager.FindGridsIntersecting(args.MapId, args.WorldAABB, ref gridState, - static (EntityUid uid, MapGridComponent grid, + (EntityUid uid, MapGridComponent grid, ref (Box2Rotated WorldBounds, DrawingHandleWorld drawHandle, int gasCount, @@ -200,7 +202,7 @@ namespace Content.Client.Atmos.Overlays return true; } - var (_, _, worldMatrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(); + var (_, _, worldMatrix, invMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform); state.drawHandle.SetTransform(worldMatrix); var floatBounds = invMatrix.TransformBox(in state.WorldBounds).Enlarged(grid.TileSize); var localBounds = new Box2i( diff --git a/Content.Client/Audio/AmbientSoundSystem.cs b/Content.Client/Audio/AmbientSoundSystem.cs index 8fe331119a..460a5294e4 100644 --- a/Content.Client/Audio/AmbientSoundSystem.cs +++ b/Content.Client/Audio/AmbientSoundSystem.cs @@ -29,6 +29,7 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem [Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IRobustRandom _random = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; protected override void QueueUpdate(EntityUid uid, AmbientSoundComponent ambience) => _treeSys.QueueTreeUpdate(uid, ambience); @@ -201,7 +202,7 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem } } - private static bool Callback( + private bool Callback( ref QueryState state, in ComponentTreeEntry value) { @@ -211,7 +212,7 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem var delta = xform.ParentUid == state.Player.ParentUid ? xform.LocalPosition - state.Player.LocalPosition - : xform.WorldPosition - state.MapPos; + : _transform.GetWorldPosition(xform) - state.MapPos; var range = delta.Length(); if (range >= ambientComp.Range) @@ -253,7 +254,7 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem { var distance = (xform.ParentUid == playerXform.ParentUid) ? xform.LocalPosition - playerXform.LocalPosition - : xform.WorldPosition - mapPos.Position; + : _transform.GetWorldPosition(xform) - mapPos.Position; if (distance.LengthSquared() < comp.Range * comp.Range) continue; diff --git a/Content.Client/CardboardBox/CardboardBoxSystem.cs b/Content.Client/CardboardBox/CardboardBoxSystem.cs index a4a273eaca..39b0069d04 100644 --- a/Content.Client/CardboardBox/CardboardBoxSystem.cs +++ b/Content.Client/CardboardBox/CardboardBoxSystem.cs @@ -10,6 +10,7 @@ namespace Content.Client.CardboardBox; public sealed class CardboardBoxSystem : SharedCardboardBoxSystem { [Dependency] private readonly EntityLookupSystem _entityLookup = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public override void Initialize() { @@ -55,7 +56,7 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem continue; sprite.Offset = new Vector2(0, 1); - entTransform.AttachParent(mob); + _transform.SetParent(ent, entTransform, mob); } } } diff --git a/Content.Client/Chat/UI/SpeechBubble.cs b/Content.Client/Chat/UI/SpeechBubble.cs index b6b336f1dc..33fedb95ac 100644 --- a/Content.Client/Chat/UI/SpeechBubble.cs +++ b/Content.Client/Chat/UI/SpeechBubble.cs @@ -36,6 +36,7 @@ namespace Content.Client.Chat.UI private readonly EntityUid _senderEntity; private readonly IChatManager _chatManager; private readonly IEntityManager _entityManager; + private readonly SharedTransformSystem _transform; private float _timeLeft = TotalTime; @@ -47,30 +48,43 @@ namespace Content.Client.Chat.UI // man down public event Action? OnDied; - public static SpeechBubble CreateSpeechBubble(SpeechType type, string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager) + public static SpeechBubble CreateSpeechBubble(SpeechType type, + string text, + EntityUid senderEntity, + IEyeManager eyeManager, + IChatManager chatManager, + IEntityManager entityManager, + SharedTransformSystem transform) { switch (type) { case SpeechType.Emote: - return new TextSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager, "emoteBox"); + return new TextSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager, transform, "emoteBox"); case SpeechType.Say: - return new TextSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager, "sayBox"); + return new TextSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager, transform, "sayBox"); case SpeechType.Whisper: - return new TextSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager, "whisperBox"); + return new TextSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager, transform, "whisperBox"); default: throw new ArgumentOutOfRangeException(); } } - public SpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager, string speechStyleClass) + public SpeechBubble(string text, + EntityUid senderEntity, + IEyeManager eyeManager, + IChatManager chatManager, + IEntityManager entityManager, + SharedTransformSystem transform, + string speechStyleClass) { _chatManager = chatManager; _senderEntity = senderEntity; _eyeManager = eyeManager; _entityManager = entityManager; + _transform = transform; // Use text clipping so new messages don't overlap old ones being pushed up. RectClipContent = true; @@ -128,7 +142,7 @@ namespace Content.Client.Chat.UI } var offset = (-_eyeManager.CurrentEye.Rotation).ToWorldVec() * -EntityVerticalOffset; - var worldPos = xform.WorldPosition + offset; + var worldPos = _transform.GetWorldPosition(xform) + offset; var lowerCenter = _eyeManager.WorldToScreen(worldPos) / UIScale; var screenPos = lowerCenter - new Vector2(ContentSize.X / 2, ContentSize.Y + _verticalOffsetAchieved); @@ -164,8 +178,14 @@ namespace Content.Client.Chat.UI public sealed class TextSpeechBubble : SpeechBubble { - public TextSpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager, string speechStyleClass) - : base(text, senderEntity, eyeManager, chatManager, entityManager, speechStyleClass) + public TextSpeechBubble(string text, + EntityUid senderEntity, + IEyeManager eyeManager, + IChatManager chatManager, + IEntityManager entityManager, + SharedTransformSystem transform, + string speechStyleClass) + : base(text, senderEntity, eyeManager, chatManager, entityManager, transform, speechStyleClass) { } diff --git a/Content.Client/Decals/Overlays/DecalOverlay.cs b/Content.Client/Decals/Overlays/DecalOverlay.cs index c37a0e3aea..5d8a34a7bc 100644 --- a/Content.Client/Decals/Overlays/DecalOverlay.cs +++ b/Content.Client/Decals/Overlays/DecalOverlay.cs @@ -11,6 +11,7 @@ namespace Content.Client.Decals.Overlays private readonly SpriteSystem _sprites; private readonly IEntityManager _entManager; private readonly IPrototypeManager _prototypeManager; + private readonly SharedTransformSystem _transform; public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowEntities; @@ -24,6 +25,7 @@ namespace Content.Client.Decals.Overlays _sprites = sprites; _entManager = entManager; _prototypeManager = prototypeManager; + _transform = _entManager.System(); } protected override void Draw(in OverlayDrawArgs args) @@ -44,7 +46,7 @@ namespace Content.Client.Decals.Overlays if (xform.MapID != args.MapId) continue; - var (_, worldRot, worldMatrix) = xform.GetWorldPositionRotationMatrix(xformQuery); + var (_, worldRot, worldMatrix) = _transform.GetWorldPositionRotationMatrix(xform, xformQuery); handle.SetTransform(worldMatrix); diff --git a/Content.Client/DragDrop/DragDropSystem.cs b/Content.Client/DragDrop/DragDropSystem.cs index 84bc63a3b6..2eddd287d5 100644 --- a/Content.Client/DragDrop/DragDropSystem.cs +++ b/Content.Client/DragDrop/DragDropSystem.cs @@ -44,6 +44,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 _transform = default!; private ISawmill _sawmill = default!; @@ -253,9 +254,7 @@ public sealed class DragDropSystem : SharedDragDropSystem // keep it on top of everything dragSprite.DrawDepth = (int) DrawDepth.Overlays; if (!dragSprite.NoRotation) - { - Transform(_dragShadow.Value).WorldRotation = Transform(_draggedEntity.Value).WorldRotation; - } + _transform.SetWorldRotation(_dragShadow.Value, _transform.GetWorldRotation(_draggedEntity.Value)); // drag initiated return; @@ -536,7 +535,7 @@ public sealed class DragDropSystem : SharedDragDropSystem if (Exists(_dragShadow)) { var mousePos = _eyeManager.PixelToMap(_inputManager.MouseScreenPosition); - Transform(_dragShadow.Value).WorldPosition = mousePos.Position; + _transform.SetWorldPosition(_dragShadow.Value, mousePos.Position); } } } diff --git a/Content.Client/Explosion/ExplosionOverlay.cs b/Content.Client/Explosion/ExplosionOverlay.cs index 17df782887..3592e8bff3 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 IMapManager _mapManager = default!; [Dependency] private readonly IEntityManager _entMan = default!; [Dependency] private readonly IPrototypeManager _proto = default!; + private readonly SharedTransformSystem _transform; public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV; @@ -25,6 +26,7 @@ public sealed class ExplosionOverlay : Overlay { IoCManager.InjectDependencies(this); _shader = _proto.Index("unshaded").Instance(); + _transform = _entMan.System(); } protected override void Draw(in OverlayDrawArgs args) @@ -67,7 +69,7 @@ public sealed class ExplosionOverlay : Overlay continue; var xform = xforms.GetComponent(grid.Owner); - var (_, _, worldMatrix, invWorldMatrix) = xform.GetWorldPositionRotationMatrixWithInv(xforms); + var (_, _, worldMatrix, invWorldMatrix) = _transform.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 f2f5ca1b9a..ffc4015d35 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 _transform; private readonly Color _heavyPuddle = new(0, 255, 255, 50); private readonly Color _mediumPuddle = new(0, 150, 255, 50); @@ -27,6 +28,7 @@ public sealed class PuddleOverlay : Overlay { IoCManager.InjectDependencies(this); _debugOverlaySystem = _entitySystemManager.GetEntitySystem(); + _transform = _entitySystemManager.GetEntitySystem(); var cache = IoCManager.Resolve(); _font = new VectorFont(cache.GetResource("/Fonts/NotoSans/NotoSans-Regular.ttf"), 8); } @@ -56,7 +58,7 @@ public sealed class PuddleOverlay : Overlay continue; var gridXform = xformQuery.GetComponent(gridId); - var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(xformQuery); + var (_, _, worldMatrix, invWorldMatrix) = _transform.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) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform, xformQuery); var gridBounds = invMatrix.TransformBox(args.WorldBounds).Enlarged(mapGrid.TileSize * 2); foreach (var debugOverlayData in _debugOverlaySystem.GetData(mapGrid.Owner)) diff --git a/Content.Client/HealthOverlay/HealthOverlaySystem.cs b/Content.Client/HealthOverlay/HealthOverlaySystem.cs index 9e1b39aed2..b9c7cfe180 100644 --- a/Content.Client/HealthOverlay/HealthOverlaySystem.cs +++ b/Content.Client/HealthOverlay/HealthOverlaySystem.cs @@ -16,6 +16,7 @@ namespace Content.Client.HealthOverlay { [Dependency] private readonly IEyeManager _eyeManager = default!; [Dependency] private readonly IEntityManager _entities = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; private readonly Dictionary _guis = new(); private EntityUid? _attachedEntity; @@ -85,7 +86,7 @@ namespace Content.Client.HealthOverlay var entity = mobState.Owner; if (_entities.GetComponent(ent).MapID != _entities.GetComponent(entity).MapID || - !viewBox.Contains(_entities.GetComponent(entity).WorldPosition)) + !viewBox.Contains(_transform.GetWorldPosition(entity))) { if (_guis.TryGetValue(entity, out var oldGui)) { diff --git a/Content.Client/Maps/GridDraggingSystem.cs b/Content.Client/Maps/GridDraggingSystem.cs index dcf74557ee..7849b6fa3b 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 _transform = default!; public bool Enabled { get; set; } @@ -66,7 +67,7 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem xform.MapID == _lastMousePosition.Value.MapId) { var tickTime = _gameTiming.TickPeriod; - var distance = _lastMousePosition.Value.Position - xform.WorldPosition; + var distance = _lastMousePosition.Value.Position - _transform.GetWorldPosition(xform); RaiseNetworkEvent(new GridDragVelocityRequest() { Grid = _dragging.Value, @@ -101,7 +102,7 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem if (!_mapManager.TryFindGridAt(mousePos, out var gridUid, out var grid)) return; - StartDragging(gridUid, Transform(gridUid).InvWorldMatrix.Transform(mousePos.Position)); + StartDragging(gridUid, _transform.GetInvWorldMatrix(gridUid).Transform(mousePos.Position)); } if (!TryComp(_dragging, out var xform)) @@ -116,11 +117,12 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem return; } - var localToWorld = xform.WorldMatrix.Transform(_localPosition); + var localToWorld = _transform.GetWorldMatrix(xform).Transform(_localPosition); - if (localToWorld.EqualsApprox(mousePos.Position, 0.01f)) return; + if (localToWorld.EqualsApprox(mousePos.Position, 0.01f)) + return; - var requestedGridOrigin = mousePos.Position - xform.WorldRotation.RotateVec(_localPosition); + var requestedGridOrigin = mousePos.Position - _transform.GetWorldRotation(xform).RotateVec(_localPosition); _lastMousePosition = new MapCoordinates(requestedGridOrigin, mousePos.MapId); RaiseNetworkEvent(new GridDragRequestPosition() diff --git a/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs b/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs index 40da258a4b..56518ebafc 100644 --- a/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs +++ b/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs @@ -21,6 +21,7 @@ namespace Content.Client.Medical.CrewMonitoring private List<(DirectionIcon Icon, Vector2 Position)> _directionIcons = new(); private readonly IEntityManager _entManager; private readonly IEyeManager _eye; + private readonly SharedTransformSystem _transform; private EntityUid? _stationUid; private CrewMonitoringButton? _trackedButton; @@ -31,6 +32,7 @@ namespace Content.Client.Medical.CrewMonitoring RobustXamlLoader.Load(this); _eye = IoCManager.Resolve(); _entManager = IoCManager.Resolve(); + _transform = _entManager.System(); _stationUid = mapUid; if (_entManager.TryGetComponent(mapUid, out var xform)) @@ -193,7 +195,7 @@ namespace Content.Client.Medical.CrewMonitoring // Apply the offset relative to the eye. // For a station at 45 degrees rotation, the current eye rotation is -45 degrees. // TODO: This feels sketchy. Is there something underlying wrong with eye rotation? - offsetAngle = -(_eye.CurrentEye.Rotation + xform.WorldRotation); + offsetAngle = -(_eye.CurrentEye.Rotation + _transform.GetWorldRotation(xform)); } foreach (var (icon, pos) in _directionIcons) diff --git a/Content.Client/NPC/HTN/HTNOverlay.cs b/Content.Client/NPC/HTN/HTNOverlay.cs index ad173f3b29..56bd4b1b53 100644 --- a/Content.Client/NPC/HTN/HTNOverlay.cs +++ b/Content.Client/NPC/HTN/HTNOverlay.cs @@ -7,14 +7,16 @@ namespace Content.Client.NPC.HTN; public sealed class HTNOverlay : Overlay { - private readonly IEntityManager _entManager = default!; - private readonly Font _font = default!; + private readonly IEntityManager _entManager; + private readonly SharedTransformSystem _transform; + private readonly Font _font; public override OverlaySpace Space => OverlaySpace.ScreenSpace; public HTNOverlay(IEntityManager entManager, IResourceCache resourceCache) { _entManager = entManager; + _transform = entManager.System(); _font = new VectorFont(resourceCache.GetResource("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10); } @@ -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 = _transform.GetWorldPosition(xform); if (!args.WorldAABB.Contains(worldPos)) continue; diff --git a/Content.Client/NPC/NPCSteeringSystem.cs b/Content.Client/NPC/NPCSteeringSystem.cs index c647c026c1..f270421915 100644 --- a/Content.Client/NPC/NPCSteeringSystem.cs +++ b/Content.Client/NPC/NPCSteeringSystem.cs @@ -78,10 +78,12 @@ public sealed class NPCSteeringOverlay : Overlay public override OverlaySpace Space => OverlaySpace.WorldSpace; private readonly IEntityManager _entManager; + private readonly SharedTransformSystem _transform; public NPCSteeringOverlay(IEntityManager entManager) { _entManager = entManager; + _transform = entManager.System(); } protected override void Draw(in OverlayDrawArgs args) @@ -93,7 +95,7 @@ public sealed class NPCSteeringOverlay : Overlay continue; } - var (worldPos, worldRot) = xform.GetWorldPositionRotation(); + var worldPos = _transform.GetWorldPosition(xform); if (!args.WorldAABB.Contains(worldPos)) continue; diff --git a/Content.Client/NPC/PathfindingSystem.cs b/Content.Client/NPC/PathfindingSystem.cs index ea50725b4f..c907cd007f 100644 --- a/Content.Client/NPC/PathfindingSystem.cs +++ b/Content.Client/NPC/PathfindingSystem.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Numerics; using System.Text; using Content.Shared.NPC; +using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Client.Input; using Robust.Client.ResourceManagement; @@ -20,6 +21,7 @@ namespace Content.Client.NPC [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IResourceCache _cache = default!; [Dependency] private readonly NPCSteeringSystem _steering = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public PathfindingDebugMode Modes { @@ -136,6 +138,7 @@ namespace Content.Client.NPC private readonly IInputManager _inputManager; private readonly IMapManager _mapManager; private readonly PathfindingSystem _system; + private readonly SharedTransformSystem _transform; public override OverlaySpace Space => OverlaySpace.ScreenSpace | OverlaySpace.WorldSpace; @@ -154,6 +157,7 @@ namespace Content.Client.NPC _inputManager = inputManager; _mapManager = mapManager; _system = system; + _transform = entManager.System(); _font = new VectorFont(cache.GetResource("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10); } @@ -187,7 +191,7 @@ namespace Content.Client.NPC if (found || !_system.Breadcrumbs.TryGetValue(grid.Owner, out var crumbs) || !xformQuery.TryGetComponent(grid.Owner, out var gridXform)) continue; - var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(); + var (_, _, worldMatrix, invWorldMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform); var localAABB = invWorldMatrix.TransformBox(aabb.Enlarged(float.Epsilon - SharedPathfindingSystem.ChunkSize)); foreach (var chunk in crumbs) @@ -271,9 +275,8 @@ namespace Content.Client.NPC return; } - var invGridMatrix = gridXform.InvWorldMatrix; + var invGridMatrix = _transform.GetInvWorldMatrix(gridXform); DebugPathPoly? nearest = null; - var nearestDistance = float.MaxValue; foreach (var poly in tile) { @@ -339,7 +342,7 @@ namespace Content.Client.NPC continue; } - var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(); + var (_, _, worldMatrix, invWorldMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform); worldHandle.SetTransform(worldMatrix); var localAABB = invWorldMatrix.TransformBox(aabb); @@ -394,7 +397,7 @@ namespace Content.Client.NPC !xformQuery.TryGetComponent(grid.Owner, out var gridXform)) continue; - var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(); + var (_, _, worldMatrix, invWorldMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform); worldHandle.SetTransform(worldMatrix); var localAABB = invWorldMatrix.TransformBox(aabb); @@ -428,7 +431,7 @@ namespace Content.Client.NPC !xformQuery.TryGetComponent(grid.Owner, out var gridXform)) continue; - var (_, _, worldMatrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(); + var (_, _, worldMatrix, invMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform); worldHandle.SetTransform(worldMatrix); var localAABB = invMatrix.TransformBox(aabb); @@ -482,7 +485,7 @@ namespace Content.Client.NPC !xformQuery.TryGetComponent(grid.Owner, out var gridXform)) continue; - var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(); + var (_, _, worldMatrix, invWorldMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform); worldHandle.SetTransform(worldMatrix); var localAABB = invWorldMatrix.TransformBox(args.WorldBounds); @@ -509,7 +512,7 @@ namespace Content.Client.NPC if (!_entManager.TryGetComponent(node.GraphUid, out var graphXform)) continue; - worldHandle.SetTransform(graphXform.WorldMatrix); + worldHandle.SetTransform(_transform.GetWorldMatrix(graphXform)); worldHandle.DrawRect(node.Box, Color.Orange.WithAlpha(0.10f)); } } @@ -531,7 +534,7 @@ namespace Content.Client.NPC continue; matrix = node.GraphUid; - worldHandle.SetTransform(graphXform.WorldMatrix); + worldHandle.SetTransform(_transform.GetWorldMatrix(graphXform)); } worldHandle.DrawRect(node.Box, new Color(0f, cost / highestGScore, 1f - (cost / highestGScore), 0.10f)); diff --git a/Content.Client/NetworkConfigurator/NetworkConfiguratorLinkOverlay.cs b/Content.Client/NetworkConfigurator/NetworkConfiguratorLinkOverlay.cs index d61bb469b3..66b01eab59 100644 --- a/Content.Client/NetworkConfigurator/NetworkConfiguratorLinkOverlay.cs +++ b/Content.Client/NetworkConfigurator/NetworkConfiguratorLinkOverlay.cs @@ -13,6 +13,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 _transform; private Dictionary _colors = new(); @@ -23,6 +24,7 @@ public sealed class NetworkConfiguratorLinkOverlay : Overlay IoCManager.InjectDependencies(this); _deviceListSystem = _entityManager.System(); + _transform = _entityManager.System(); } public void ClearEntity(EntityUid uid) @@ -70,7 +72,7 @@ public sealed class NetworkConfiguratorLinkOverlay : Overlay continue; } - args.WorldHandle.DrawLine(sourceTransform.WorldPosition, linkTransform.WorldPosition, _colors[tracker.Owner]); + args.WorldHandle.DrawLine(_transform.GetWorldPosition(sourceTransform), _transform.GetWorldPosition(linkTransform), _colors[tracker.Owner]); } } } diff --git a/Content.Client/NodeContainer/NodeVisualizationOverlay.cs b/Content.Client/NodeContainer/NodeVisualizationOverlay.cs index 43e3c12a72..82c785a4f2 100644 --- a/Content.Client/NodeContainer/NodeVisualizationOverlay.cs +++ b/Content.Client/NodeContainer/NodeVisualizationOverlay.cs @@ -19,6 +19,7 @@ namespace Content.Client.NodeContainer private readonly IMapManager _mapManager; private readonly IInputManager _inputManager; private readonly IEntityManager _entityManager; + private readonly SharedTransformSystem _transform; private readonly Dictionary<(int, int), NodeRenderData> _nodeIndex = new(); private readonly Dictionary>> _gridIndex = new (); @@ -44,6 +45,7 @@ namespace Content.Client.NodeContainer _mapManager = mapManager; _inputManager = inputManager; _entityManager = entityManager; + _transform = entityManager.System(); _font = cache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 12); } @@ -141,7 +143,7 @@ namespace Content.Client.NodeContainer foreach (var (gridId, gridDict) in _gridIndex) { var grid = _mapManager.GetGrid(gridId); - var (_, _, worldMatrix, invMatrix) = _entityManager.GetComponent(grid.Owner).GetWorldPositionRotationMatrixWithInv(); + var (_, _, worldMatrix, invMatrix) = _transform.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 1c396585b3..7127589f34 100644 --- a/Content.Client/Outline/TargetOutlineSystem.cs +++ b/Content.Client/Outline/TargetOutlineSystem.cs @@ -22,6 +22,7 @@ public sealed class TargetOutlineSystem : EntitySystem [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; private bool _enabled = false; @@ -164,8 +165,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 = _transform.GetWorldPosition(player); + var target = _transform.GetWorldPosition(entity); valid = (origin - target).LengthSquared() <= Range; } diff --git a/Content.Client/Pinpointer/NavMapSystem.cs b/Content.Client/Pinpointer/NavMapSystem.cs index 6556aeaf99..f59b669e50 100644 --- a/Content.Client/Pinpointer/NavMapSystem.cs +++ b/Content.Client/Pinpointer/NavMapSystem.cs @@ -35,6 +35,7 @@ public sealed class NavMapSystem : SharedNavMapSystem public sealed class NavMapOverlay : Overlay { private readonly IEntityManager _entManager; + private readonly SharedTransformSystem _transform; private readonly IMapManager _mapManager; public override OverlaySpace Space => OverlaySpace.WorldSpace; @@ -42,6 +43,7 @@ public sealed class NavMapOverlay : Overlay public NavMapOverlay(IEntityManager entManager, IMapManager mapManager) { _entManager = entManager; + _transform = entManager.System(); _mapManager = mapManager; } @@ -57,7 +59,7 @@ public sealed class NavMapOverlay : Overlay continue; // TODO: Faster helper method - var (_, _, matrix, invMatrix) = xform.GetWorldPositionRotationMatrixWithInv(); + var (_, _, matrix, invMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(xform); var localAABB = invMatrix.TransformBox(args.WorldBounds); Matrix3.Multiply(in scale, in matrix, out var matty); diff --git a/Content.Client/Pinpointer/UI/NavMapControl.cs b/Content.Client/Pinpointer/UI/NavMapControl.cs index bd61587e8b..b6f6ca15a9 100644 --- a/Content.Client/Pinpointer/UI/NavMapControl.cs +++ b/Content.Client/Pinpointer/UI/NavMapControl.cs @@ -20,6 +20,7 @@ namespace Content.Client.Pinpointer.UI; public sealed class NavMapControl : MapGridControl { [Dependency] private readonly IEntityManager _entManager = default!; + private readonly SharedTransformSystem _transform; public EntityUid? MapUid; @@ -52,6 +53,9 @@ public sealed class NavMapControl : MapGridControl public NavMapControl() : base(8f, 128f, 48f) { IoCManager.InjectDependencies(this); + + _transform = _entManager.System(); + RectClipContent = true; HorizontalExpand = true; VerticalExpand = true; @@ -326,7 +330,7 @@ public sealed class NavMapControl : MapGridControl if (mapPos.MapId != MapId.Nullspace) { - var position = xform.InvWorldMatrix.Transform(mapPos.Position) - offset; + var position = _transform.GetInvWorldMatrix(xform).Transform(mapPos.Position) - offset; position = Scale(new Vector2(position.X, -position.Y)); handle.DrawCircle(position, MinimapScale / 2f, value.Color); diff --git a/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Position.cs b/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Position.cs index 04fd35da11..f1359eae67 100644 --- a/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Position.cs +++ b/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Position.cs @@ -56,7 +56,8 @@ public sealed partial class ReplaySpectatorSystem return data; data.Local = (xform.Coordinates, xform.LocalRotation); - data.World = (new(xform.MapUid.Value, xform.WorldPosition), xform.WorldRotation); + var (pos, rot) = _transform.GetWorldPositionRotation(xform); + data.World = (new(xform.MapUid.Value, pos), rot); if (TryComp(player, out InputMoverComponent? mover)) data.Eye = (mover.RelativeEntity, mover.TargetRelativeRotation); diff --git a/Content.Client/Shuttles/Systems/ShuttleSystem.EmergencyConsole.cs b/Content.Client/Shuttles/Systems/ShuttleSystem.EmergencyConsole.cs index db3f8f5b58..5f208b6658 100644 --- a/Content.Client/Shuttles/Systems/ShuttleSystem.EmergencyConsole.cs +++ b/Content.Client/Shuttles/Systems/ShuttleSystem.EmergencyConsole.cs @@ -57,7 +57,8 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem /// public sealed class EmergencyShuttleOverlay : Overlay { - private IEntityManager _entManager; + private readonly IEntityManager _entManager; + private readonly SharedTransformSystem _transform; public override OverlaySpace Space => OverlaySpace.WorldSpace; @@ -67,13 +68,15 @@ public sealed class EmergencyShuttleOverlay : Overlay public EmergencyShuttleOverlay(IEntityManager entManager) { _entManager = entManager; + _transform = entManager.System(); } protected override void Draw(in OverlayDrawArgs args) { - if (Position == null || !_entManager.TryGetComponent(StationUid, out var xform)) return; + if (Position == null || !_entManager.TryGetComponent(StationUid, out var xform)) + return; - args.WorldHandle.SetTransform(xform.WorldMatrix); + args.WorldHandle.SetTransform(_transform.GetWorldMatrix(xform)); args.WorldHandle.DrawRect(Position.Value, Color.Red.WithAlpha(100)); args.WorldHandle.SetTransform(Matrix3.Identity); } diff --git a/Content.Client/Shuttles/UI/DockingControl.cs b/Content.Client/Shuttles/UI/DockingControl.cs index 93c72921bb..32c740fd94 100644 --- a/Content.Client/Shuttles/UI/DockingControl.cs +++ b/Content.Client/Shuttles/UI/DockingControl.cs @@ -16,6 +16,7 @@ namespace Content.Client.Shuttles.UI; public class DockingControl : Control { private readonly IEntityManager _entManager; + private readonly SharedTransformSystem _transform; private readonly IMapManager _mapManager; private float _range = 8f; @@ -46,6 +47,7 @@ public class DockingControl : Control public DockingControl() { _entManager = IoCManager.Resolve(); + _transform = _entManager.System(); _mapManager = IoCManager.Resolve(); _rangeSquared = _range * _range; MinSize = new Vector2(SizeFull, SizeFull); @@ -78,7 +80,10 @@ public class DockingControl : Control if (Coordinates == null || Angle == null || - !_entManager.TryGetComponent(GridEntity, out var gridXform)) return; + !_entManager.TryGetComponent(GridEntity, out var gridXform)) + { + return; + } var rotation = Matrix3.CreateRotation(-Angle.Value + Math.PI); var matrix = Matrix3.CreateTranslation(-Coordinates.Value.Position); @@ -140,8 +145,8 @@ public class DockingControl : Control ScalePosition(rotation.Transform(new Vector2(0.5f, -0.5f)))), Color.Green); // Draw nearby grids - var worldPos = gridXform.WorldMatrix.Transform(Coordinates.Value.Position); - var gridInvMatrix = gridXform.InvWorldMatrix; + var worldPos = _transform.GetWorldMatrix(gridXform).Transform(Coordinates.Value.Position); + var gridInvMatrix = _transform.GetInvWorldMatrix(gridXform); Matrix3.Multiply(in gridInvMatrix, in matrix, out var invMatrix); // TODO: Getting some overdraw so need to fix that. @@ -157,7 +162,7 @@ public class DockingControl : Control if (!_entManager.TryGetComponent(grid.Owner, out var gridFixtures)) continue; - var gridMatrix = xformQuery.GetComponent(grid.Owner).WorldMatrix; + var gridMatrix = _transform.GetWorldMatrix(grid.Owner); Matrix3.Multiply(in gridMatrix, in invMatrix, out var matty); diff --git a/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml.cs b/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml.cs index 61f861bbc7..049d27a906 100644 --- a/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml.cs +++ b/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml.cs @@ -21,6 +21,7 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow, { private readonly IEntityManager _entManager; private readonly IGameTiming _timing; + private readonly SharedTransformSystem _transform; private EntityUid? _shuttleUid; @@ -51,6 +52,7 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow, RobustXamlLoader.Load(this); _entManager = IoCManager.Resolve(); _timing = IoCManager.Resolve(); + _transform = _entManager.System(); WorldRangeChange(RadarScreen.WorldRange); RadarScreen.WorldRangeChanged += WorldRangeChange; @@ -323,7 +325,7 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow, FTLTimer.Text = GetFTLText(); - var (_, worldRot, worldMatrix) = gridXform.GetWorldPositionRotationMatrix(); + var (_, worldRot, worldMatrix) = _transform.GetWorldPositionRotationMatrix(gridXform); var worldPos = worldMatrix.Transform(gridBody.LocalCenter); // Get the positive reduced angle. diff --git a/Content.Client/Stealth/StealthSystem.cs b/Content.Client/Stealth/StealthSystem.cs index b60ffc2a40..128283ca4c 100644 --- a/Content.Client/Stealth/StealthSystem.cs +++ b/Content.Client/Stealth/StealthSystem.cs @@ -10,6 +10,7 @@ namespace Content.Client.Stealth; public sealed class StealthSystem : SharedStealthSystem { [Dependency] private readonly IPrototypeManager _protoMan = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; private ShaderInstance _shader = default!; @@ -79,7 +80,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(_transform.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 ee0f9646c5..2a2ff29141 100644 --- a/Content.Client/Tabletop/TabletopSystem.cs +++ b/Content.Client/Tabletop/TabletopSystem.cs @@ -28,6 +28,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 _transform = 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 @@ -76,7 +77,8 @@ namespace Content.Client.Tabletop } // If no entity is being dragged or no viewport is clicked, return - if (_draggedEntity == null || _viewport == null) return; + if (_draggedEntity == null || _viewport == null) + return; if (!CanDrag(playerEntity, _draggedEntity.Value, out var draggableComponent)) { @@ -98,10 +100,11 @@ namespace Content.Client.Tabletop // Clamp coordinates to viewport var clampedCoords = ClampPositionToViewport(coords, _viewport); - if (clampedCoords.Equals(MapCoordinates.Nullspace)) return; + if (clampedCoords.Equals(MapCoordinates.Nullspace)) + return; // Move the entity locally every update - EntityManager.GetComponent(_draggedEntity.Value).WorldPosition = clampedCoords.Position; + _transform.SetWorldPosition(_draggedEntity.Value, clampedCoords.Position); // Increment total time passed _timePassed += frameTime; @@ -182,10 +185,11 @@ namespace Content.Client.Tabletop { if (_draggedEntity != null && _table != null) { - var ev = new TabletopRequestTakeOut(); - ev.Entity = _draggedEntity.Value; - ev.TableUid = _table.Value; - RaiseNetworkEvent(ev); + RaiseNetworkEvent(new TabletopRequestTakeOut + { + Entity = _draggedEntity.Value, + TableUid = _table.Value, + }); } return false; } @@ -278,10 +282,12 @@ namespace Content.Client.Tabletop /// Coordinates clamped to the viewport. private static MapCoordinates ClampPositionToViewport(MapCoordinates coordinates, ScalingViewport viewport) { - if (coordinates == MapCoordinates.Nullspace) return MapCoordinates.Nullspace; + if (coordinates == MapCoordinates.Nullspace) + return MapCoordinates.Nullspace; var eye = viewport.Eye; - if (eye == null) return MapCoordinates.Nullspace; + if (eye == null) + return MapCoordinates.Nullspace; var size = (Vector2) viewport.ViewportSize / EyeManager.PixelsPerMeter; // Convert to tiles instead of pixels var eyePosition = eye.Position.Position; diff --git a/Content.Client/UserInterface/Systems/Chat/ChatUIController.cs b/Content.Client/UserInterface/Systems/Chat/ChatUIController.cs index 50431a7c57..d29678266d 100644 --- a/Content.Client/UserInterface/Systems/Chat/ChatUIController.cs +++ b/Content.Client/UserInterface/Systems/Chat/ChatUIController.cs @@ -19,6 +19,7 @@ using Content.Shared.Chat; using Content.Shared.Examine; using Content.Shared.Input; using Content.Shared.Radio; +using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Client.Input; using Robust.Client.Player; @@ -55,6 +56,7 @@ public sealed class ChatUIController : UIController [UISystemDependency] private readonly GhostSystem? _ghost = default; [UISystemDependency] private readonly TypingIndicatorSystem? _typingIndicator = default; [UISystemDependency] private readonly ChatSystem? _chatSys = default; + [UISystemDependency] private readonly TransformSystem _transform = default!; private ISawmill _sawmill = default!; @@ -408,7 +410,7 @@ public sealed class ChatUIController : UIController private void CreateSpeechBubble(EntityUid entity, SpeechBubbleData speechData) { var bubble = - SpeechBubble.CreateSpeechBubble(speechData.Type, speechData.Message, entity, _eye, _manager, _entities); + SpeechBubble.CreateSpeechBubble(speechData.Type, speechData.Message, entity, _eye, _manager, _entities, _transform); bubble.OnDied += SpeechBubbleDied; diff --git a/Content.Client/UserInterface/Systems/Viewport/ViewportUIController.cs b/Content.Client/UserInterface/Systems/Viewport/ViewportUIController.cs index d16b61317d..d6d9ef84d1 100644 --- a/Content.Client/UserInterface/Systems/Viewport/ViewportUIController.cs +++ b/Content.Client/UserInterface/Systems/Viewport/ViewportUIController.cs @@ -4,6 +4,7 @@ using Content.Shared.CCVar; using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Client.Player; +using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controllers; using Robust.Shared.Configuration; using Robust.Shared.Timing; @@ -16,6 +17,7 @@ public sealed class ViewportUIController : UIController [Dependency] private readonly IPlayerManager _playerMan = default!; [Dependency] private readonly IEntityManager _entMan = default!; [Dependency] private readonly IConfigurationManager _configurationManager = default!; + [UISystemDependency] private readonly TransformSystem _transform = default!; public static readonly Vector2i ViewportSize = (EyeManager.PixelsPerMeter * 21, EyeManager.PixelsPerMeter * 15); public const int ViewportHeight = 15; @@ -87,9 +89,10 @@ public sealed class ViewportUIController : UIController _entMan.TryGetComponent(ent, out EyeComponent? eye); - if (eye?.Eye == _eyeManager.CurrentEye - && _entMan.GetComponent(ent.Value).WorldPosition == default) + if (eye?.Eye == _eyeManager.CurrentEye && _transform.GetWorldPosition(ent.Value) == default) + { return; // nothing to worry about, the player is just in null space... actually that is probably a problem? + } // Currently, this shouldn't happen. This likely happened because the main eye was set to null. When this // does happen it can create hard to troubleshoot bugs, so lets print some helpful warnings: diff --git a/Content.Server/Administration/Commands/AGhost.cs b/Content.Server/Administration/Commands/AGhost.cs index 56d9087fa2..21ae9f246a 100644 --- a/Content.Server/Administration/Commands/AGhost.cs +++ b/Content.Server/Administration/Commands/AGhost.cs @@ -48,7 +48,7 @@ namespace Content.Server.Administration.Commands ? _entities.GetComponent(player.AttachedEntity.Value).Coordinates : EntitySystem.Get().GetObserverSpawnPoint(); var ghost = _entities.SpawnEntity("AdminObserver", coordinates); - _entities.GetComponent(ghost).AttachToGridOrMap(); + _entities.System().AttachToGridOrMap(ghost); if (canReturn) { diff --git a/Content.Server/Administration/Commands/WarpCommand.cs b/Content.Server/Administration/Commands/WarpCommand.cs index 5c61208b5b..7b577f59ef 100644 --- a/Content.Server/Administration/Commands/WarpCommand.cs +++ b/Content.Server/Administration/Commands/WarpCommand.cs @@ -4,6 +4,7 @@ using Content.Server.Warps; using Content.Shared.Administration; using Content.Shared.Follower; using Content.Shared.Ghost; +using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Enums; @@ -121,9 +122,9 @@ namespace Content.Server.Administration.Commands return; } - var xform = _entManager.GetComponent(playerEntity); - xform.Coordinates = coords; - xform.AttachToGridOrMap(); + var transform = _entManager.System(); + transform.SetCoordinates(playerEntity, coords); + transform.AttachToGridOrMap(playerEntity); if (_entManager.TryGetComponent(playerEntity, out PhysicsComponent? physics)) { _entManager.System().SetLinearVelocity(playerEntity, Vector2.Zero, body: physics); diff --git a/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs b/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs index 45c754eba4..4ebec61ee3 100644 --- a/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs +++ b/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs @@ -76,6 +76,7 @@ public sealed partial class AdminVerbSystem [Dependency] private readonly VomitSystem _vomitSystem = default!; [Dependency] private readonly WeldableSystem _weldableSystem = default!; [Dependency] private readonly SharedContentEyeSystem _eyeSystem = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; // All smite verbs have names so invokeverb works. private void AddSmiteVerbs(GetVerbsEvent args) @@ -130,8 +131,8 @@ public sealed partial class AdminVerbSystem Filter.PvsExcept(args.Target), true, PopupType.MediumCaution); var board = Spawn("ChessBoard", xform.Coordinates); var session = _tabletopSystem.EnsureSession(Comp(board)); - xform.Coordinates = EntityCoordinates.FromMap(_mapManager, session.Position); - xform.WorldRotation = Angle.Zero; + _transform.SetCoordinates(args.Target, EntityCoordinates.FromMap(_mapManager, session.Position)); + _transform.SetWorldRotation(xform, Angle.Zero); }, Impact = LogImpact.Extreme, Message = Loc.GetString("admin-smite-chess-dimension-description") diff --git a/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs b/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs index 7d00634e4a..3833d05c76 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs @@ -18,6 +18,7 @@ namespace Content.Server.Atmos.EntitySystems [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IConfigurationManager _configManager = default!; [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; /// /// Players allowed to see the atmos debug overlay. @@ -134,7 +135,7 @@ namespace Content.Server.Atmos.EntitySystems var mapIsSpace = _atmosphereSystem.IsTileSpace(null, mapUid, Vector2i.Zero); - var worldBounds = Box2.CenteredAround(transform.WorldPosition, + var worldBounds = Box2.CenteredAround(_transform.GetWorldPosition(transform), new Vector2(LocalViewRange, LocalViewRange)); foreach (var grid in _mapManager.FindGridsIntersecting(transform.MapID, worldBounds)) diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs index a06bf3504c..39493e99a1 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs @@ -15,6 +15,8 @@ namespace Content.Server.Atmos.EntitySystems { public sealed partial class AtmosphereSystem { + [Dependency] private readonly SharedTransformSystem _transform = default!; + private const int SpaceWindSoundCooldownCycles = 75; private int _spaceWindSoundCooldown = 0; @@ -118,7 +120,7 @@ namespace Content.Server.Atmos.EntitySystems return; // Used by ExperiencePressureDifference to correct push/throw directions from tile-relative to physics world. - var gridWorldRotation = xforms.GetComponent(gridAtmosphere.Owner).WorldRotation; + var gridWorldRotation = _transform.GetWorldRotation(gridAtmosphere.Owner); // If we're using monstermos, smooth out the yeet direction to follow the flow if (MonstermosEqualization) @@ -234,7 +236,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).Position - xform.WorldPosition).Normalized() + dirVec).Normalized(); + var pos = ((throwTarget.ToMap(EntityManager).Position - _transform.GetWorldPosition(xform)).Normalized() + dirVec).Normalized(); _physics.ApplyLinearImpulse(uid, pos * moveForce, body: physics); } else diff --git a/Content.Server/Bible/BibleSystem.cs b/Content.Server/Bible/BibleSystem.cs index 8186db5a49..f06bcdb7be 100644 --- a/Content.Server/Bible/BibleSystem.cs +++ b/Content.Server/Bible/BibleSystem.cs @@ -29,6 +29,7 @@ namespace Content.Server.Bible [Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly SharedActionsSystem _actionsSystem = default!; [Dependency] private readonly UseDelaySystem _delay = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public override void Initialize() { @@ -235,7 +236,7 @@ namespace Content.Server.Bible if (HasComp(familiar)) { _popupSystem.PopupEntity(Loc.GetString("bible-summon-requested"), user, PopupType.Medium); - Transform(familiar).AttachParent(component.Owner); + _transform.SetParent(familiar, component.Owner); } component.AlreadySummoned = true; _actionsSystem.RemoveAction(user, component.SummonAction); diff --git a/Content.Server/Body/Systems/BodySystem.cs b/Content.Server/Body/Systems/BodySystem.cs index 1ed9cf71c0..b51dfd46b7 100644 --- a/Content.Server/Body/Systems/BodySystem.cs +++ b/Content.Server/Body/Systems/BodySystem.cs @@ -29,6 +29,7 @@ public sealed class BodySystem : SharedBodySystem [Dependency] private readonly MobStateSystem _mobState = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly MindSystem _mindSystem = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public override void Initialize() { @@ -126,7 +127,7 @@ public sealed class BodySystem : SharedBodySystem return; // Don't microwave animals, kids - Transform(uid).AttachToGridOrMap(); + _transform.AttachToGridOrMap(uid); GibBody(uid, false, component); args.Handled = true; @@ -208,7 +209,7 @@ public sealed class BodySystem : SharedBodySystem else { cont.Remove(ent, EntityManager, force: true); - Transform(ent).Coordinates = coordinates; + _transform.SetCoordinates(ent, coordinates); ent.RandomOffset(0.25f); } } diff --git a/Content.Server/Chemistry/EntitySystems/RehydratableSystem.cs b/Content.Server/Chemistry/EntitySystems/RehydratableSystem.cs index 3dd1c6ae58..ce0032e741 100644 --- a/Content.Server/Chemistry/EntitySystems/RehydratableSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/RehydratableSystem.cs @@ -10,6 +10,7 @@ public sealed class RehydratableSystem : EntitySystem [Dependency] private readonly SharedPopupSystem _popups = default!; [Dependency] private readonly SolutionContainerSystem _solutions = default!; [Dependency] private readonly IRobustRandom _random = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public override void Initialize() { @@ -36,7 +37,7 @@ public sealed class RehydratableSystem : EntitySystem var target = Spawn(randomMob, Transform(uid).Coordinates); - Transform(target).AttachToGridOrMap(); + _transform.AttachToGridOrMap(target); var ev = new GotRehydratedEvent(target); RaiseLocalEvent(uid, ref ev); diff --git a/Content.Server/Chemistry/EntitySystems/VaporSystem.cs b/Content.Server/Chemistry/EntitySystems/VaporSystem.cs index 92ba44b2c6..7a51ab68de 100644 --- a/Content.Server/Chemistry/EntitySystems/VaporSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/VaporSystem.cs @@ -27,6 +27,7 @@ namespace Content.Server.Chemistry.EntitySystems [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!; [Dependency] private readonly ThrowingSystem _throwing = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; private const float ReactTime = 0.125f; @@ -69,7 +70,7 @@ namespace Content.Server.Chemistry.EntitySystems _throwing.TryThrow(vapor.Owner, dir, speed, user: user, pushbackRatio: ThrowingSystem.PushbackDefault * 10f); - var distance = (target.Position - vaporXform.WorldPosition).Length(); + var distance = (target.Position - _transform.GetWorldPosition(vaporXform)).Length(); var time = (distance / physics.LinearVelocity.Length()); despawn.Lifetime = MathF.Min(aliveTime, time); } diff --git a/Content.Server/Climbing/ClimbSystem.cs b/Content.Server/Climbing/ClimbSystem.cs index 539463eed4..b9c9fd8772 100644 --- a/Content.Server/Climbing/ClimbSystem.cs +++ b/Content.Server/Climbing/ClimbSystem.cs @@ -45,6 +45,7 @@ public sealed class ClimbSystem : SharedClimbSystem [Dependency] private readonly InteractionSystem _interactionSystem = default!; [Dependency] private readonly StunSystem _stunSystem = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; private const string ClimbingFixtureName = "climb"; private const int ClimbingCollisionGroup = (int) (CollisionGroup.TableLayer | CollisionGroup.LowImpassable); @@ -394,8 +395,8 @@ public sealed class ClimbSystem : SharedClimbSystem if (!Resolve(uid, ref physics, ref climbing, false)) return; - var from = Transform(uid).WorldPosition; - var to = Transform(target).WorldPosition; + var from = _transform.GetWorldPosition(uid); + var to = _transform.GetWorldPosition(target); var (x, y) = (to - from).Normalized(); if (MathF.Abs(x) < 0.6f) // user climbed mostly vertically so lets make it a clean straight line diff --git a/Content.Server/Commands/CommandUtils.cs b/Content.Server/Commands/CommandUtils.cs index 11adaec9a2..0eb69985e9 100644 --- a/Content.Server/Commands/CommandUtils.cs +++ b/Content.Server/Commands/CommandUtils.cs @@ -1,5 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using System.Globalization; using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Network; @@ -49,42 +48,5 @@ namespace Content.Server.Commands attachedEntity = session.AttachedEntity.Value; return true; } - - public static string SubstituteEntityDetails(IConsoleShell shell, EntityUid ent, string ruleString) - { - var entMan = IoCManager.Resolve(); - var transform = entMan.GetComponent(ent); - - // 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)); - ruleString = ruleString.Replace("$WY", - transform.WorldPosition.Y.ToString(CultureInfo.InvariantCulture)); - ruleString = ruleString.Replace("$LX", - transform.LocalPosition.X.ToString(CultureInfo.InvariantCulture)); - ruleString = ruleString.Replace("$LY", - transform.LocalPosition.Y.ToString(CultureInfo.InvariantCulture)); - ruleString = ruleString.Replace("$NAME", entMan.GetComponent(ent).EntityName); - - if (shell.Player is IPlayerSession player) - { - if (player.AttachedEntity is {Valid: true} p) - { - var pTransform = entMan.GetComponent(p); - - ruleString = ruleString.Replace("$PID", ent.ToString()); - ruleString = ruleString.Replace("$PWX", - pTransform.WorldPosition.X.ToString(CultureInfo.InvariantCulture)); - ruleString = ruleString.Replace("$PWY", - pTransform.WorldPosition.Y.ToString(CultureInfo.InvariantCulture)); - ruleString = ruleString.Replace("$PLX", - pTransform.LocalPosition.X.ToString(CultureInfo.InvariantCulture)); - ruleString = ruleString.Replace("$PLY", - pTransform.LocalPosition.Y.ToString(CultureInfo.InvariantCulture)); - } - } - return ruleString; - } } } diff --git a/Content.Server/Construction/Completions/SnapToGrid.cs b/Content.Server/Construction/Completions/SnapToGrid.cs index 47941108f5..2f51df884b 100644 --- a/Content.Server/Construction/Completions/SnapToGrid.cs +++ b/Content.Server/Construction/Completions/SnapToGrid.cs @@ -15,7 +15,7 @@ namespace Content.Server.Construction.Completions var transform = entityManager.GetComponent(uid); if (!transform.Anchored) - transform.Coordinates = transform.Coordinates.SnapToGrid(entityManager); + entityManager.System().SetCoordinates(uid, transform, transform.Coordinates.SnapToGrid(entityManager)); if (SouthRotation) { diff --git a/Content.Server/Construction/ConstructionSystem.Graph.cs b/Content.Server/Construction/ConstructionSystem.Graph.cs index 43b7b009a5..e9f3e3cbea 100644 --- a/Content.Server/Construction/ConstructionSystem.Graph.cs +++ b/Content.Server/Construction/ConstructionSystem.Graph.cs @@ -341,7 +341,7 @@ namespace Content.Server.Construction // Transform transferring. var newTransform = Transform(newUid); - newTransform.AttachToGridOrMap(); // in case in hands or a container + _transform.AttachToGridOrMap(newUid, newTransform); // in case in hands or a container newTransform.LocalRotation = transform.LocalRotation; newTransform.Anchored = transform.Anchored; diff --git a/Content.Server/Construction/ConstructionSystem.Initial.cs b/Content.Server/Construction/ConstructionSystem.Initial.cs index 2284ade6bd..a2191a0395 100644 --- a/Content.Server/Construction/ConstructionSystem.Initial.cs +++ b/Content.Server/Construction/ConstructionSystem.Initial.cs @@ -31,6 +31,7 @@ namespace Content.Server.Construction [Dependency] private readonly SharedHandsSystem _handsSystem = default!; [Dependency] private readonly EntityLookupSystem _lookupSystem = default!; [Dependency] private readonly StorageSystem _storageSystem = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; // --- WARNING! LEGACY CODE AHEAD! --- // This entire file contains the legacy code for initial construction. @@ -515,7 +516,7 @@ namespace Content.Server.Construction var xform = Transform(structure); var wasAnchored = xform.Anchored; xform.Anchored = false; - xform.Coordinates = ev.Location; + _transform.SetCoordinates(structure, xform, ev.Location); xform.LocalRotation = constructionPrototype.CanRotate ? ev.Angle : Angle.Zero; xform.Anchored = wasAnchored; diff --git a/Content.Server/DeviceNetwork/Systems/WirelessNetworkSystem.cs b/Content.Server/DeviceNetwork/Systems/WirelessNetworkSystem.cs index b27ef52eca..ae8da22b18 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 _transform = 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 - _transform.GetWorldPosition(xform)).Length() > sendingComponent.Range) { args.Cancel(); } diff --git a/Content.Server/Dragon/DragonSystem.cs b/Content.Server/Dragon/DragonSystem.cs index 82aa10b037..219527560a 100644 --- a/Content.Server/Dragon/DragonSystem.cs +++ b/Content.Server/Dragon/DragonSystem.cs @@ -38,6 +38,7 @@ public sealed partial class DragonSystem : EntitySystem [Dependency] private readonly MovementSpeedModifierSystem _movement = default!; [Dependency] private readonly SharedAudioSystem _audioSystem = default!; [Dependency] private readonly NPCSystem _npc = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; /// /// Minimum distance between 2 rifts allowed. @@ -251,7 +252,7 @@ public sealed partial class DragonSystem : EntitySystem } } - 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/ExplosionGridTileFlood.cs b/Content.Server/Explosion/EntitySystems/ExplosionGridTileFlood.cs index 8d2a699de2..585475dd83 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionGridTileFlood.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionGridTileFlood.cs @@ -69,13 +69,14 @@ public sealed class ExplosionGridTileFlood : ExplosionTileFlood return; _needToTransform = true; - var transform = IoCManager.Resolve().GetComponent(Grid.Owner); + var transform = IoCManager.Resolve().GetEntitySystem(); var size = (float) Grid.TileSize; _matrix.R0C2 = size / 2; _matrix.R1C2 = size / 2; - _matrix *= transform.WorldMatrix * Matrix3.Invert(spaceMatrix); - var relativeAngle = transform.WorldRotation - spaceAngle; + var (_, rot, mat) = transform.GetWorldPositionRotationMatrix(Grid.Owner); + _matrix *= mat * Matrix3.Invert(spaceMatrix); + var relativeAngle = rot - spaceAngle; _offset = relativeAngle.RotateVec(new Vector2(size / 4, size / 4)); } diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs index 79985d233b..7a3e6d0a65 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs @@ -61,8 +61,9 @@ public sealed partial class ExplosionSystem : EntitySystem { var targetGrid = _mapManager.GetGrid(referenceGrid.Value); var xform = Transform(targetGrid.Owner); - targetAngle = xform.WorldRotation; - targetMatrix = xform.InvWorldMatrix; + var (_, rot, invMat) = _transformSystem.GetWorldPositionRotationInvMatrix(xform); + targetAngle = rot; + targetMatrix = invMat; tileSize = targetGrid.TileSize; } @@ -95,7 +96,7 @@ public sealed partial class ExplosionSystem : EntitySystem var xforms = EntityManager.GetEntityQuery(); var xform = xforms.GetComponent(grid.Owner); - var (_, gridWorldRotation, gridWorldMatrix, invGridWorldMatrid) = xform.GetWorldPositionRotationMatrixWithInv(xforms); + var (_, gridWorldRotation, gridWorldMatrix, invGridWorldMatrid) = _transformSystem.GetWorldPositionRotationMatrixWithInv(xform, xforms); var localEpicentre = (Vector2i) invGridWorldMatrid.Transform(epicentre.Position); var matrix = offsetMatrix * gridWorldMatrix * targetMatrix; diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.TileFill.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.TileFill.cs index fc16c9daa4..e797520ac0 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.TileFill.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.TileFill.cs @@ -87,8 +87,8 @@ public sealed partial class ExplosionSystem : EntitySystem if (referenceGrid != null) { var xform = Transform(_mapManager.GetGrid(referenceGrid.Value).Owner); - spaceMatrix = xform.WorldMatrix; - spaceAngle = xform.WorldRotation; + spaceMatrix = _transformSystem.GetWorldMatrix(xform); + spaceAngle = _transformSystem.GetWorldRotation(xform); } // is the explosion starting on a grid? diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs index d042b65449..a701b27aa2 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs @@ -340,7 +340,7 @@ public sealed partial class ExplosionSystem : EntitySystem 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/Fluids/EntitySystems/PuddleDebugDebugOverlaySystem.cs b/Content.Server/Fluids/EntitySystems/PuddleDebugDebugOverlaySystem.cs index b09d74c4d0..350f805a1b 100644 --- a/Content.Server/Fluids/EntitySystems/PuddleDebugDebugOverlaySystem.cs +++ b/Content.Server/Fluids/EntitySystems/PuddleDebugDebugOverlaySystem.cs @@ -13,6 +13,7 @@ public sealed class PuddleDebugDebugOverlaySystem : SharedPuddleDebugOverlaySyst [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly PuddleSystem _puddle = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; private readonly HashSet _playerObservers = new(); @@ -55,7 +56,7 @@ public sealed class PuddleDebugDebugOverlaySystem : SharedPuddleDebugOverlaySyst var transform = EntityManager.GetComponent(entity); - var worldBounds = Box2.CenteredAround(transform.WorldPosition, + var worldBounds = Box2.CenteredAround(_transform.GetWorldPosition(transform), new Vector2(LocalViewRange, LocalViewRange)); diff --git a/Content.Server/GameTicking/GameTicker.Spawning.cs b/Content.Server/GameTicking/GameTicker.Spawning.cs index ee1dfc598a..8dca5c20bc 100644 --- a/Content.Server/GameTicking/GameTicker.Spawning.cs +++ b/Content.Server/GameTicking/GameTicker.Spawning.cs @@ -368,7 +368,7 @@ namespace Content.Server.GameTicking var gridXform = Transform(gridUid); return new EntityCoordinates(gridUid, - gridXform.InvWorldMatrix.Transform(toMap.Position)); + _transform.GetInvWorldMatrix(gridXform).Transform(toMap.Position)); } return spawn; diff --git a/Content.Server/Ghost/GhostSystem.cs b/Content.Server/Ghost/GhostSystem.cs index f66ec36b5f..0ee7592608 100644 --- a/Content.Server/Ghost/GhostSystem.cs +++ b/Content.Server/Ghost/GhostSystem.cs @@ -39,6 +39,7 @@ namespace Content.Server.Ghost [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly MindSystem _minds = default!; [Dependency] private readonly JobSystem _jobs = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public override void Initialize() { @@ -205,8 +206,8 @@ namespace Content.Server.Ghost private void OnGhostWarpToTargetRequest(GhostWarpToTargetRequestEvent msg, EntitySessionEventArgs args) { - if (args.SenderSession.AttachedEntity is not {Valid: true} attached || - !EntityManager.TryGetComponent(attached, out GhostComponent? ghost)) + if (args.SenderSession.AttachedEntity is not { Valid: true } attached || + !EntityManager.HasComponent(attached)) { Logger.Warning($"User {args.SenderSession.Name} tried to warp to {msg.Target} without being a ghost."); return; @@ -221,13 +222,12 @@ namespace Content.Server.Ghost if (TryComp(msg.Target, out WarpPointComponent? warp) && warp.Follow || HasComp(msg.Target)) { - _followerSystem.StartFollowingEntity(ghost.Owner, msg.Target); + _followerSystem.StartFollowingEntity(attached, msg.Target); return; } - var xform = Transform(ghost.Owner); - xform.Coordinates = Transform(msg.Target).Coordinates; - xform.AttachToGridOrMap(); + _transform.SetCoordinates(attached, Transform(msg.Target).Coordinates); + _transform.AttachToGridOrMap(attached); if (TryComp(attached, out PhysicsComponent? physics)) _physics.SetLinearVelocity(attached, Vector2.Zero, body: physics); } diff --git a/Content.Server/Hands/Systems/HandsSystem.cs b/Content.Server/Hands/Systems/HandsSystem.cs index 9a72d31207..ec7743f2ae 100644 --- a/Content.Server/Hands/Systems/HandsSystem.cs +++ b/Content.Server/Hands/Systems/HandsSystem.cs @@ -45,6 +45,7 @@ namespace Content.Server.Hands.Systems [Dependency] private readonly StorageSystem _storageSystem = default!; [Dependency] private readonly ISharedPlayerManager _player = default!; [Dependency] private readonly IConfigurationManager _configuration = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public override void Initialize() { @@ -201,7 +202,7 @@ namespace Content.Server.Hands.Systems throwEnt = splitStack.Value; } - var direction = coords.ToMapPos(EntityManager) - Transform(player).WorldPosition; + var direction = coords.ToMapPos(EntityManager) - _transform.GetWorldPosition(player); if (direction == Vector2.Zero) return true; diff --git a/Content.Server/ImmovableRod/ImmovableRodSystem.cs b/Content.Server/ImmovableRod/ImmovableRodSystem.cs index 99c949ebce..f809de0ad0 100644 --- a/Content.Server/ImmovableRod/ImmovableRodSystem.cs +++ b/Content.Server/ImmovableRod/ImmovableRodSystem.cs @@ -20,6 +20,7 @@ public sealed class ImmovableRodSystem : EntitySystem [Dependency] private readonly PopupSystem _popup = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public override void Update(float frameTime) { @@ -62,11 +63,11 @@ public sealed class ImmovableRodSystem : EntitySystem var vel = component.DirectionOverride.Degrees switch { 0f => _random.NextVector2(component.MinSpeed, component.MaxSpeed), - _ => xform.WorldRotation.RotateVec(component.DirectionOverride.ToVec()) * _random.NextFloat(component.MinSpeed, component.MaxSpeed) + _ => _transform.GetWorldRotation(xform).RotateVec(component.DirectionOverride.ToVec()) * _random.NextFloat(component.MinSpeed, component.MaxSpeed), }; _physics.ApplyLinearImpulse(uid, vel, body: phys); - xform.LocalRotation = (vel - xform.WorldPosition).ToWorldAngle() + MathHelper.PiOver2; + xform.LocalRotation = (vel - _transform.GetWorldPosition(xform)).ToWorldAngle() + MathHelper.PiOver2; } } diff --git a/Content.Server/Lightning/LightningSystem.cs b/Content.Server/Lightning/LightningSystem.cs index 8d82275b0a..5e842b8969 100644 --- a/Content.Server/Lightning/LightningSystem.cs +++ b/Content.Server/Lightning/LightningSystem.cs @@ -16,6 +16,7 @@ public sealed class LightningSystem : SharedLightningSystem [Dependency] private readonly PhysicsSystem _physics = default!; [Dependency] private readonly BeamSystem _beam = default!; [Dependency] private readonly IRobustRandom _random = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public override void Initialize() { @@ -97,7 +98,7 @@ public sealed class LightningSystem : SharedLightningSystem for (int i = 0; i < directions; i++) { var direction = (Direction) i; - var (targetPos, targetRot) = targetXForm.GetWorldPositionRotation(xformQuery); + var (targetPos, targetRot) = _transform.GetWorldPositionRotation(targetXForm, xformQuery); var dirRad = direction.ToAngle() + targetRot; var ray = new CollisionRay(targetPos, dirRad.ToVec(), component.CollisionMask); var rayCastResults = _physics.IntersectRay(targetXForm.MapID, ray, component.MaxLength, target, false).ToList(); diff --git a/Content.Server/Magic/MagicSystem.cs b/Content.Server/Magic/MagicSystem.cs index e75bae0249..61c094de60 100644 --- a/Content.Server/Magic/MagicSystem.cs +++ b/Content.Server/Magic/MagicSystem.cs @@ -274,10 +274,11 @@ public sealed class MagicSystem : EntitySystem var transform = Transform(args.Performer); - if (transform.MapID != args.Target.GetMapId(EntityManager)) return; + if (transform.MapID != args.Target.GetMapId(EntityManager)) + return; _transformSystem.SetCoordinates(args.Performer, args.Target); - transform.AttachToGridOrMap(); + _transformSystem.AttachToGridOrMap(args.Performer, transform); _audio.PlayPvs(args.BlinkSound, args.Performer, AudioParams.Default.WithVolume(args.BlinkVolume)); Speak(args); args.Handled = true; diff --git a/Content.Server/Maps/GridDraggingSystem.cs b/Content.Server/Maps/GridDraggingSystem.cs index eef3e56849..b24250b0df 100644 --- a/Content.Server/Maps/GridDraggingSystem.cs +++ b/Content.Server/Maps/GridDraggingSystem.cs @@ -13,6 +13,7 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem { [Dependency] private readonly IConGroupController _admin = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; private readonly HashSet _draggers = new(); @@ -65,10 +66,11 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem if (args.SenderSession is not IPlayerSession playerSession || !_admin.CanCommand(playerSession, CommandName) || !Exists(msg.Grid) || - Deleted(msg.Grid)) return; + Deleted(msg.Grid)) + { + return; + } - var gridXform = Transform(msg.Grid); - - gridXform.WorldPosition = msg.WorldPosition; + _transform.SetWorldPosition(msg.Grid, msg.WorldPosition); } } diff --git a/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs b/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs index 84f60573b1..e674fe3241 100644 --- a/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs +++ b/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs @@ -77,7 +77,7 @@ public sealed class MechGrabberSystem : EntitySystem component.ItemContainer.Remove(toRemove); var mechxform = Transform(mech); var xform = Transform(toRemove); - xform.AttachToGridOrMap(); + _transform.AttachToGridOrMap(toRemove, xform); var offset = _transform.GetWorldPosition(mechxform) + _transform.GetWorldRotation(mechxform).RotateVec(component.DepositOffset); _transform.SetWorldPosition(xform, offset); diff --git a/Content.Server/NPC/Pathfinding/PathfindingSystem.Distance.cs b/Content.Server/NPC/Pathfinding/PathfindingSystem.Distance.cs index 95d5c9c465..fb650ec2cd 100644 --- a/Content.Server/NPC/Pathfinding/PathfindingSystem.Distance.cs +++ b/Content.Server/NPC/Pathfinding/PathfindingSystem.Distance.cs @@ -36,7 +36,7 @@ public sealed partial class PathfindingSystem return Vector2.Zero; } - endPos = startXform.InvWorldMatrix.Transform(endXform.WorldMatrix.Transform(endPos)); + endPos = _transform.GetInvWorldMatrix(startXform).Transform(_transform.GetWorldMatrix(endXform).Transform(endPos)); } // TODO: Numerics when we changeover. diff --git a/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs b/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs index ca970815b6..6f3ed428c4 100644 --- a/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs +++ b/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs @@ -410,8 +410,7 @@ public sealed partial class PathfindingSystem private Vector2i GetOrigin(EntityCoordinates coordinates, EntityUid gridUid) { - var gridXform = Transform(gridUid); - var localPos = gridXform.InvWorldMatrix.Transform(coordinates.ToMapPos(EntityManager)); + var localPos = _transform.GetInvWorldMatrix(gridUid).Transform(coordinates.ToMapPos(EntityManager)); return new Vector2i((int) Math.Floor(localPos.X / ChunkSize), (int) Math.Floor(localPos.Y / ChunkSize)); } diff --git a/Content.Server/NPC/Pathfinding/PathfindingSystem.cs b/Content.Server/NPC/Pathfinding/PathfindingSystem.cs index 06ff9faa69..528a458296 100644 --- a/Content.Server/NPC/Pathfinding/PathfindingSystem.cs +++ b/Content.Server/NPC/Pathfinding/PathfindingSystem.cs @@ -47,6 +47,7 @@ namespace Content.Server.NPC.Pathfinding [Dependency] private readonly FixtureSystem _fixtures = default!; [Dependency] private readonly NPCSystem _npc = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; private readonly Dictionary _subscribedSessions = new(); @@ -382,7 +383,7 @@ namespace Content.Server.NPC.Pathfinding return null; } - var localPos = xform.InvWorldMatrix.Transform(coordinates.ToMapPos(EntityManager)); + var localPos = _transform.GetInvWorldMatrix(xform).Transform(coordinates.ToMapPos(EntityManager)); var origin = GetOrigin(localPos); if (!TryGetChunk(origin, comp, out var chunk)) diff --git a/Content.Server/Pointing/EntitySystems/RoguePointingSystem.cs b/Content.Server/Pointing/EntitySystems/RoguePointingSystem.cs index 160dc80fc3..5703883bd6 100644 --- a/Content.Server/Pointing/EntitySystems/RoguePointingSystem.cs +++ b/Content.Server/Pointing/EntitySystems/RoguePointingSystem.cs @@ -16,6 +16,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 _transform = default!; private EntityUid? RandomNearbyPlayer(EntityUid uid, RoguePointingArrowComponent? component = null, TransformComponent? transform = null) { @@ -68,24 +69,24 @@ namespace Content.Server.Pointing.EntitySystems if (component.TurningDelay > 0) { - var difference = EntityManager.GetComponent(chasing).WorldPosition - transform.WorldPosition; + var difference = _transform.GetWorldPosition(chasing) - _transform.GetWorldPosition(transform); var angle = difference.ToAngle(); var adjusted = angle.Degrees + 90; var newAngle = Angle.FromDegrees(adjusted); - transform.WorldRotation = newAngle; + _transform.SetWorldRotation(transform, newAngle); UpdateAppearance(uid, component, transform); continue; } - transform.WorldRotation += Angle.FromDegrees(20); + _transform.SetWorldRotation(transform, _transform.GetWorldRotation(transform) + Angle.FromDegrees(20)); UpdateAppearance(uid, component, transform); - var toChased = EntityManager.GetComponent(chasing).WorldPosition - transform.WorldPosition; + var toChased = _transform.GetWorldPosition(chasing) - _transform.GetWorldPosition(transform); - transform.WorldPosition += toChased * frameTime * component.ChasingSpeed; + _transform.SetWorldPosition(transform, _transform.GetWorldPosition(transform) + toChased * frameTime * component.ChasingSpeed); component.ChasingTime -= frameTime; diff --git a/Content.Server/Polymorph/Systems/PolymorphSystem.cs b/Content.Server/Polymorph/Systems/PolymorphSystem.cs index fce8b694f7..fae5ce67d2 100644 --- a/Content.Server/Polymorph/Systems/PolymorphSystem.cs +++ b/Content.Server/Polymorph/Systems/PolymorphSystem.cs @@ -266,8 +266,8 @@ namespace Content.Server.Polymorph.Systems var parentXform = Transform(parent); _transform.SetParent(parent, parentXform, uidXform.ParentUid); - parentXform.Coordinates = uidXform.Coordinates; - parentXform.LocalRotation = uidXform.LocalRotation; + _transform.SetCoordinates(parent, parentXform, uidXform.Coordinates); + _transform.SetLocalRotation(parentXform, uidXform.LocalRotation); if (proto.TransferDamage && TryComp(parent, out var damageParent) && @@ -306,7 +306,7 @@ namespace Content.Server.Polymorph.Systems _mindSystem.TransferTo(mindId, parent, mind: mind); // if an item polymorph was picked up, put it back down after reverting - Transform(parent).AttachToGridOrMap(); + _transform.AttachToGridOrMap(parent); _popup.PopupEntity(Loc.GetString("polymorph-revert-popup-generic", ("parent", Identity.Entity(uid, EntityManager)), diff --git a/Content.Server/Respawn/SpecialRespawnSystem.cs b/Content.Server/Respawn/SpecialRespawnSystem.cs index 51c092be18..6176af5210 100644 --- a/Content.Server/Respawn/SpecialRespawnSystem.cs +++ b/Content.Server/Respawn/SpecialRespawnSystem.cs @@ -22,6 +22,7 @@ public sealed class SpecialRespawnSystem : SharedSpecialRespawnSystem [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly TurfSystem _turf = default!; [Dependency] private readonly IChatManager _chat = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public override void Initialize() { @@ -156,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 66a7076569..355f50f4d7 100644 --- a/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs +++ b/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs @@ -40,6 +40,7 @@ public sealed partial class RevenantSystem [Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!; [Dependency] private readonly GhostSystem _ghost = default!; [Dependency] private readonly TileSystem _tile = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; private void InitializeAbilities() { @@ -214,7 +215,7 @@ public sealed partial class RevenantSystem var xform = Transform(uid); if (!_mapManager.TryGetGrid(xform.GridUid, out var map)) return; - var tiles = map.GetTilesIntersecting(Box2.CenteredAround(xform.WorldPosition, + var tiles = map.GetTilesIntersecting(Box2.CenteredAround(_transform.GetWorldPosition(xform), new Vector2(component.DefileRadius * 2, component.DefileRadius))).ToArray(); _random.Shuffle(tiles); diff --git a/Content.Server/Salvage/SalvageRulerCommand.cs b/Content.Server/Salvage/SalvageRulerCommand.cs index 9dcf7fc36e..eeaf9c7b4b 100644 --- a/Content.Server/Salvage/SalvageRulerCommand.cs +++ b/Content.Server/Salvage/SalvageRulerCommand.cs @@ -50,7 +50,7 @@ sealed class SalvageRulerCommand : IConsoleCommand var first = true; foreach (var mapGrid in _maps.GetAllMapGrids(entityTransform.MapID)) { - var aabb = _entities.GetComponent(mapGrid.Owner).WorldMatrix.TransformBox(mapGrid.LocalAABB); + var aabb = _entities.System().GetWorldMatrix(mapGrid.Owner).TransformBox(mapGrid.LocalAABB); if (first) { total = aabb; diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs index a6bdc043a9..072edfe47f 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs @@ -54,6 +54,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem [Dependency] private readonly ShuttleSystem _shuttle = default!; [Dependency] private readonly StationSystem _station = default!; [Dependency] private readonly UserInterfaceSystem _uiSystem = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; private ISawmill _sawmill = default!; @@ -415,6 +416,6 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem if (!Resolve(shuttle, ref grid, ref shuttleXform)) return false; - return shuttleXform.WorldMatrix.TransformBox(grid.LocalAABB).Contains(xform.WorldPosition); + return _transform.GetWorldMatrix(shuttleXform).TransformBox(grid.LocalAABB).Contains(_transform.GetWorldPosition(xform)); } } diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs index e9b4283599..03037ed8d3 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs @@ -250,8 +250,8 @@ public sealed partial class ShuttleSystem var fromRotation = _transform.GetWorldRotation(xform); var width = Comp(uid).LocalAABB.Width; - xform.Coordinates = new EntityCoordinates(_mapManager.GetMapEntityId(_hyperSpaceMap!.Value), new Vector2(_index + width / 2f, 0f)); - xform.LocalRotation = Angle.Zero; + _transform.SetCoordinates(uid, xform, new EntityCoordinates(_mapManager.GetMapEntityId(_hyperSpaceMap!.Value), new Vector2(_index + width / 2f, 0f))); + _transform.SetLocalRotation(xform, Angle.Zero); _index += width + Buffer; comp.Accumulator += comp.TravelTime - DefaultArrivalTime; @@ -336,7 +336,7 @@ public sealed partial class ShuttleSystem } else { - xform.Coordinates = comp.TargetCoordinates; + _transform.SetCoordinates(uid, xform, comp.TargetCoordinates); mapId = comp.TargetCoordinates.GetMapId(EntityManager); } @@ -506,7 +506,7 @@ public sealed partial class ShuttleSystem if (config != null) { - FTLDock(config, shuttleXform); + FTLDock(config, shuttleUid, shuttleXform); return true; } @@ -517,10 +517,13 @@ public sealed partial class ShuttleSystem /// /// Forces an FTL dock. /// - public void FTLDock(DockingConfig config, TransformComponent shuttleXform) + public void FTLDock(DockingConfig config, EntityUid uid, TransformComponent? shuttleXform = null) { + if (!Resolve(uid, ref shuttleXform)) + return; + // Set position - shuttleXform.Coordinates = config.Coordinates; + _transform.SetCoordinates(uid, shuttleXform, config.Coordinates); _transform.SetWorldRotation(shuttleXform, config.Angle); // Connect everything @@ -629,7 +632,7 @@ public sealed partial class ShuttleSystem spawnPos = _transform.GetWorldPosition(targetXform, xformQuery); } - xform.Coordinates = new EntityCoordinates(targetXform.MapUid.Value, spawnPos); + _transform.SetCoordinates(shuttleUid, xform, new EntityCoordinates(targetXform.MapUid.Value, spawnPos)); if (!HasComp(targetXform.GridUid)) { diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs index 4d53647c9e..6fa1573b86 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.GridFill.cs @@ -115,7 +115,7 @@ public sealed partial class ShuttleSystem if (config != null) { - FTLDock(config, shuttleXform); + FTLDock(config, ent[0], shuttleXform); if (TryComp(xform.GridUid, out var stationMember)) { diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.Impact.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.Impact.cs index 73dc4b208c..53dcb8a80e 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.Impact.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.Impact.cs @@ -38,8 +38,8 @@ public sealed partial class ShuttleSystem var otherXform = Transform(args.OtherEntity); - var ourPoint = ourXform.InvWorldMatrix.Transform(args.WorldPoint); - var otherPoint = otherXform.InvWorldMatrix.Transform(args.WorldPoint); + var ourPoint = _transform.GetInvWorldMatrix(ourXform).Transform(args.WorldPoint); + var otherPoint = _transform.GetInvWorldMatrix(otherXform).Transform(args.WorldPoint); var ourVelocity = _physics.GetLinearVelocity(uid, ourPoint, ourBody, ourXform); var otherVelocity = _physics.GetLinearVelocity(args.OtherEntity, otherPoint, otherBody, otherXform); diff --git a/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs b/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs index ac21342376..f83370d557 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 PopupSystem _popupSystem = default!; [Dependency] private readonly PhysicsSystem _physics = default!; [Dependency] private readonly AppearanceSystem _visualizer = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public override void Initialize() { @@ -228,7 +229,7 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem if (!gen1XForm.Anchored) return false; - var genWorldPosRot = gen1XForm.GetWorldPositionRotation(); + var genWorldPosRot = _transform.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); @@ -304,7 +305,7 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem var newField = Spawn(firstGenComp.CreatedField, currentCoords); var fieldXForm = Transform(newField); - fieldXForm.AttachParent(firstGenComp.Owner); + _transform.SetParent(newField, fieldXForm, firstGenComp.Owner); if (dirVec.GetDir() == Direction.East || dirVec.GetDir() == Direction.West) { var angle = fieldXForm.LocalPosition.ToAngle(); diff --git a/Content.Server/Singularity/EntitySystems/ContainmentFieldSystem.cs b/Content.Server/Singularity/EntitySystems/ContainmentFieldSystem.cs index 70cc992dc3..2985e5709e 100644 --- a/Content.Server/Singularity/EntitySystems/ContainmentFieldSystem.cs +++ b/Content.Server/Singularity/EntitySystems/ContainmentFieldSystem.cs @@ -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 _transform = default!; public override void Initialize() { @@ -26,16 +27,16 @@ public sealed class ContainmentFieldSystem : EntitySystem { var otherBody = args.OtherEntity; - if (TryComp(otherBody, out var garbage)) + if (HasComp(otherBody)) { - _popupSystem.PopupEntity(Loc.GetString("comp-field-vaporized", ("entity", otherBody)), component.Owner, PopupType.LargeCaution); - QueueDel(garbage.Owner); + _popupSystem.PopupEntity(Loc.GetString("comp-field-vaporized", ("entity", otherBody)), uid, PopupType.LargeCaution); + QueueDel(otherBody); } if (TryComp(otherBody, out var physics) && physics.Mass <= component.MaxMass && physics.Hard) { - var fieldDir = Transform(component.Owner).WorldPosition; - var playerDir = Transform(otherBody).WorldPosition; + var fieldDir = _transform.GetWorldPosition(uid); + var playerDir = _transform.GetWorldPosition(otherBody); _throwing.TryThrow(otherBody, playerDir-fieldDir, strength: component.ThrowForce); } diff --git a/Content.Server/Solar/EntitySystems/PowerSolarSystem.cs b/Content.Server/Solar/EntitySystems/PowerSolarSystem.cs index 74f88bc0d1..dee3ac2096 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 _transform = default!; /// /// Maximum panel angular velocity range - used to stop people rotating panels fast enough that the lag prevention becomes noticable @@ -111,7 +112,7 @@ namespace Content.Server.Solar.EntitySystems foreach (var (panel, xform) in EntityManager.EntityQuery()) { TotalPanelPower += panel.MaxSupply * panel.Coverage; - xform.WorldRotation = TargetPanelRotation; + _transform.SetWorldRotation(xform, TargetPanelRotation); _updateQueue.Enqueue(panel); } } @@ -134,7 +135,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 = _transform.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. @@ -152,7 +153,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(_transform.GetWorldPosition(xform), TowardsSun.ToWorldVec(), (int) CollisionGroup.Opaque); var rayCastResults = _physicsSystem.IntersectRayWithPredicate( xform.MapID, ray, diff --git a/Content.Server/Standing/StandingStateSystem.cs b/Content.Server/Standing/StandingStateSystem.cs index e2b6495844..c1a08c829f 100644 --- a/Content.Server/Standing/StandingStateSystem.cs +++ b/Content.Server/Standing/StandingStateSystem.cs @@ -13,6 +13,7 @@ public sealed class StandingStateSystem : EntitySystem [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly SharedHandsSystem _handsSystem = default!; [Dependency] private readonly ThrowingSystem _throwingSystem = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; private void FallOver(EntityUid uid, StandingStateComponent component, DropHandItemsEvent args) { @@ -25,7 +26,7 @@ public sealed class StandingStateSystem : EntitySystem if (!TryComp(uid, out HandsComponent? handsComp)) return; - var worldRotation = EntityManager.GetComponent(uid).WorldRotation.ToVec(); + var worldRotation = _transform.GetWorldRotation(uid).ToVec(); foreach (var hand in handsComp.Hands.Values) { if (hand.HeldEntity is not EntityUid held) diff --git a/Content.Server/Worldgen/Systems/BaseWorldSystem.cs b/Content.Server/Worldgen/Systems/BaseWorldSystem.cs index 78326651c9..9f308372fd 100644 --- a/Content.Server/Worldgen/Systems/BaseWorldSystem.cs +++ b/Content.Server/Worldgen/Systems/BaseWorldSystem.cs @@ -12,6 +12,7 @@ namespace Content.Server.Worldgen.Systems; public abstract class BaseWorldSystem : EntitySystem { [Dependency] private readonly WorldControllerSystem _worldController = default!; + [Dependency] private readonly SharedTransformSystem _transform = 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(_transform.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(_transform.GetWorldPosition(xform)); } /// diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ThrowArtifactSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ThrowArtifactSystem.cs index 55159feebb..0034cc7dcb 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ThrowArtifactSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ThrowArtifactSystem.cs @@ -16,6 +16,7 @@ public sealed class ThrowArtifactSystem : EntitySystem [Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly ThrowingSystem _throwing = default!; [Dependency] private readonly TileSystem _tile = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; /// public override void Initialize() @@ -29,7 +30,7 @@ public sealed class ThrowArtifactSystem : EntitySystem if (_map.TryGetGrid(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/Body/Systems/SharedBodySystem.Organs.cs b/Content.Shared/Body/Systems/SharedBodySystem.Organs.cs index dbfadc6a0f..eff1012c82 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Organs.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Organs.cs @@ -140,7 +140,7 @@ public partial class SharedBodySystem container.Remove(organId.Value); if (TryComp(organId, out TransformComponent? transform)) - transform.AttachToGridOrMap(); + _transform.AttachToGridOrMap(organId.Value, transform); organ.Owner.RandomOffset(0.25f); @@ -165,7 +165,7 @@ public partial class SharedBodySystem return false; if (TryComp(organId.Value, out TransformComponent? transform)) - transform.Coordinates = dropAt; + _transform.SetCoordinates(organId.Value, transform, dropAt); return true; } diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs b/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs index 8c55fe9cdd..bfd9636eff 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs @@ -249,7 +249,7 @@ public partial class SharedBodySystem container.Remove(partId.Value); if (TryComp(partId, out TransformComponent? transform)) - transform.AttachToGridOrMap(); + _transform.AttachToGridOrMap(partId.Value, transform); part.Owner.RandomOffset(0.25f); @@ -331,7 +331,7 @@ public partial class SharedBodySystem return false; if (TryComp(partId.Value, out TransformComponent? transform)) - transform.Coordinates = dropAt; + _transform.SetCoordinates(partId.Value, transform, dropAt); return true; } diff --git a/Content.Shared/Body/Systems/SharedBodySystem.cs b/Content.Shared/Body/Systems/SharedBodySystem.cs index 4d195e0a50..11d728dfbf 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.cs @@ -16,6 +16,7 @@ public abstract partial class SharedBodySystem : EntitySystem [Dependency] protected readonly DamageableSystem Damageable = default!; [Dependency] protected readonly StandingStateSystem Standing = default!; [Dependency] protected readonly MovementSpeedModifierSystem Movement = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public override void Initialize() { diff --git a/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs b/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs index 13a00dd5a1..ee0e54051a 100644 --- a/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs +++ b/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs @@ -465,7 +465,7 @@ public abstract partial class SharedBuckleSystem _transformSystem.SetWorldRotation(buckleXform, oldBuckledToWorldRot); if (strapComp.UnbuckleOffset != Vector2.Zero) - buckleXform.Coordinates = oldBuckledXform.Coordinates.Offset(strapComp.UnbuckleOffset); + _transformSystem.SetCoordinates(buckleUid, buckleXform, oldBuckledXform.Coordinates.Offset(strapComp.UnbuckleOffset)); } if (TryComp(buckleUid, out AppearanceComponent? appearance)) diff --git a/Content.Shared/Buckle/SharedBuckleSystem.cs b/Content.Shared/Buckle/SharedBuckleSystem.cs index bbe171b8c3..3440c2bd65 100644 --- a/Content.Shared/Buckle/SharedBuckleSystem.cs +++ b/Content.Shared/Buckle/SharedBuckleSystem.cs @@ -65,7 +65,7 @@ public abstract partial class SharedBuckleSystem : EntitySystem var buckleTransform = Transform(buckleUid); - buckleTransform.Coordinates = new EntityCoordinates(strapUid, strapComp.BuckleOffset); + _transformSystem.SetCoordinates(buckleUid, buckleTransform, new EntityCoordinates(strapUid, strapComp.BuckleOffset)); // Buckle subscribes to move for so this might fail. // TODO: Make buckle not do that. diff --git a/Content.Shared/Construction/Conditions/WallmountCondition.cs b/Content.Shared/Construction/Conditions/WallmountCondition.cs index bf3016d497..307dbf5e4c 100644 --- a/Content.Shared/Construction/Conditions/WallmountCondition.cs +++ b/Content.Shared/Construction/Conditions/WallmountCondition.cs @@ -17,15 +17,16 @@ namespace Content.Shared.Construction.Conditions public bool Condition(EntityUid user, EntityCoordinates location, Direction direction) { var entManager = IoCManager.Resolve(); + var transform = entManager.System(); // get blueprint and user position - var userWorldPosition = entManager.GetComponent(user).WorldPosition; + var userWorldPosition = transform.GetWorldPosition(user); var objWorldPosition = location.ToMap(entManager).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 = transform.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/Containers/ContainerFillSystem.cs b/Content.Shared/Containers/ContainerFillSystem.cs index 81b9782dcd..6ed86aa6ca 100644 --- a/Content.Shared/Containers/ContainerFillSystem.cs +++ b/Content.Shared/Containers/ContainerFillSystem.cs @@ -7,6 +7,7 @@ namespace Content.Shared.Containers; public sealed class ContainerFillSystem : EntitySystem { [Dependency] private readonly SharedContainerSystem _containerSystem = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public override void Initialize() { @@ -39,7 +40,7 @@ public sealed class ContainerFillSystem : EntitySystem if (!container.Insert(ent, EntityManager, null, xform)) { Log.Error($"Entity {ToPrettyString(uid)} with a {nameof(ContainerFillComponent)} failed to insert an entity: {ToPrettyString(ent)}."); - Transform(ent).AttachToGridOrMap(); + _transform.AttachToGridOrMap(ent); break; } } diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs index 87edd47282..494956ef12 100644 --- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs +++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs @@ -8,6 +8,8 @@ namespace Content.Shared.Hands.EntitySystems; public abstract partial class SharedHandsSystem : EntitySystem { + [Dependency] private readonly SharedTransformSystem _transform = default!; + private void InitializeDrop() { SubscribeLocalEvent(HandleEntityRemoved); @@ -98,12 +100,14 @@ public abstract partial class SharedHandsSystem : EntitySystem if (!isInContainer || !_containerSystem.TryGetContainingContainer(userXform.ParentUid, uid, out var container, skipExistCheck: true) || !container.Insert(entity, EntityManager, itemXform)) - itemXform.AttachToGridOrMap(); + { + _transform.AttachToGridOrMap(entity, itemXform); + } return true; } var target = targetDropLocation.Value.ToMap(EntityManager); - itemXform.WorldPosition = GetFinalDropCoordinates(uid, userXform.MapPosition, target); + _transform.SetWorldPosition(itemXform, GetFinalDropCoordinates(uid, userXform.MapPosition, target)); return true; } diff --git a/Content.Shared/Interaction/RotateToFaceSystem.cs b/Content.Shared/Interaction/RotateToFaceSystem.cs index d5fa01a71b..6ff74d32f0 100644 --- a/Content.Shared/Interaction/RotateToFaceSystem.cs +++ b/Content.Shared/Interaction/RotateToFaceSystem.cs @@ -85,7 +85,7 @@ namespace Content.Shared.Interaction if (!Resolve(user, ref xform)) return false; - xform.WorldRotation = diffAngle; + _transform.SetWorldRotation(xform, diffAngle); return true; } @@ -101,7 +101,7 @@ namespace Content.Shared.Interaction // (Since the user being buckled to it holds it down with their weight.) // This is logically equivalent to RotateWhileAnchored. // Barstools and office chairs have independent wheels, while regular chairs don't. - Transform(rotatable.Owner).WorldRotation = diffAngle; + _transform.SetWorldRotation(suid.Value, diffAngle); return true; } } diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index f00d9c8c38..f4c3491e77 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -593,7 +593,7 @@ namespace Content.Shared.Interaction fixtureB.FixtureCount > 0 && TryComp(origin, out var xformA)) { - var (worldPosA, worldRotA) = xformA.GetWorldPositionRotation(); + var (worldPosA, worldRotA) = _transform.GetWorldPositionRotation(xformA); var xfA = new Transform(worldPosA, worldRotA); var parentRotB = _transform.GetWorldRotation(otherCoordinates.EntityId); var xfB = new Transform(targetPos.Position, parentRotB + otherAngle); @@ -659,7 +659,7 @@ namespace Content.Shared.Interaction Ignored? predicate = null) { var transform = Transform(target); - var (position, rotation) = transform.GetWorldPositionRotation(); + var (position, rotation) = _transform.GetWorldPositionRotation(transform); var mapPos = new MapCoordinates(position, transform.MapID); var combinedPredicate = GetPredicate(origin, target, mapPos, rotation, collisionMask, predicate); diff --git a/Content.Shared/Inventory/InventorySystem.Equip.cs b/Content.Shared/Inventory/InventorySystem.Equip.cs index 25dcf56921..9ebcba6d1f 100644 --- a/Content.Shared/Inventory/InventorySystem.Equip.cs +++ b/Content.Shared/Inventory/InventorySystem.Equip.cs @@ -27,6 +27,7 @@ public abstract partial class InventorySystem [Dependency] private readonly SharedHandsSystem _handsSystem = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly INetManager _netMan = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; private void InitializeEquip() { @@ -385,7 +386,7 @@ public abstract partial class InventorySystem } } - Transform(removedItem.Value).Coordinates = Transform(target).Coordinates; + _transform.SetCoordinates(removedItem.Value, Transform(target).Coordinates); if (!silent && Resolve(removedItem.Value, ref clothing, false) && clothing.UnequipSound != null && _gameTiming.IsFirstTimePredicted) { diff --git a/Content.Shared/Maps/TurfHelpers.cs b/Content.Shared/Maps/TurfHelpers.cs index 6b9d7dbbf9..7c4cc20df8 100644 --- a/Content.Shared/Maps/TurfHelpers.cs +++ b/Content.Shared/Maps/TurfHelpers.cs @@ -175,7 +175,7 @@ namespace Content.Shared.Maps if (map.TryGetGrid(turf.GridUid, out var tileGrid)) { - var gridRot = entManager.GetComponent(tileGrid.Owner).WorldRotation; + var gridRot = entManager.System().GetWorldRotation(tileGrid.Owner); // This is scaled to 90 % so it doesn't encompass walls on other tiles. var tileBox = Box2.UnitCentered.Scale(0.9f); diff --git a/Content.Shared/Physics/Controllers/SharedConveyorController.cs b/Content.Shared/Physics/Controllers/SharedConveyorController.cs index 1ba66aa1a3..f22aadc9ad 100644 --- a/Content.Shared/Physics/Controllers/SharedConveyorController.cs +++ b/Content.Shared/Physics/Controllers/SharedConveyorController.cs @@ -18,6 +18,7 @@ public abstract class SharedConveyorController : VirtualController [Dependency] protected readonly EntityLookupSystem Lookup = default!; [Dependency] protected readonly SharedPhysicsSystem Physics = default!; [Dependency] private readonly SharedGravitySystem _gravity = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; protected const string ConveyorFixture = "conveyor"; @@ -116,7 +117,7 @@ public abstract class SharedConveyorController : VirtualController var itemRelative = conveyorPos - localPos; localPos += Convey(direction, speed, frameTime, itemRelative); - transform.LocalPosition = localPos; + _transform.SetLocalPosition(transform, localPos); // Force it awake for collisionwake reasons. Physics.SetAwake(entity, body, true); diff --git a/Content.Shared/Placeable/PlaceableSurfaceSystem.cs b/Content.Shared/Placeable/PlaceableSurfaceSystem.cs index 7464c8890c..88a46475ef 100644 --- a/Content.Shared/Placeable/PlaceableSurfaceSystem.cs +++ b/Content.Shared/Placeable/PlaceableSurfaceSystem.cs @@ -9,6 +9,7 @@ namespace Content.Shared.Placeable public sealed class PlaceableSurfaceSystem : EntitySystem { [Dependency] private readonly SharedHandsSystem _handsSystem = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public override void Initialize() { @@ -68,9 +69,9 @@ namespace Content.Shared.Placeable return; if (surface.PlaceCentered) - Transform(args.Used).LocalPosition = Transform(uid).LocalPosition + surface.PositionOffset; + _transform.SetLocalPosition(args.Used, Transform(uid).LocalPosition + surface.PositionOffset); else - Transform(args.Used).Coordinates = args.ClickLocation; + _transform.SetCoordinates(args.Used, args.ClickLocation); args.Handled = true; } diff --git a/Content.Shared/Random/Helpers/SharedEntityExtensions.cs b/Content.Shared/Random/Helpers/SharedEntityExtensions.cs index 5b12ffb94d..1ca52693ed 100644 --- a/Content.Shared/Random/Helpers/SharedEntityExtensions.cs +++ b/Content.Shared/Random/Helpers/SharedEntityExtensions.cs @@ -17,7 +17,10 @@ namespace Content.Shared.Random.Helpers var randomY = random.NextFloat() * (maxY - minY) + minY; var offset = new Vector2(randomX, randomY); - IoCManager.Resolve().GetComponent(entity).LocalPosition += offset; + var entMan = IoCManager.Resolve(); + var comp = entMan.GetComponent(entity); + var transform = entMan.System(); + transform.SetLocalPosition(comp, comp.LocalPosition + offset); } public static void RandomOffset(this EntityUid entity, float min, float max)