From f4cb02fb0ca385c858569c07c51afb0d24ade949 Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Wed, 20 Mar 2024 21:59:56 -0400 Subject: [PATCH] Code cleanup: Purge calls to obsolete EntityCoordinates methods (#26292) * Purge calls to obsolete EntityCoordinates methods * Pizza defruited; rerun those tests! --- Content.Client/Construction/ConstructionSystem.cs | 3 ++- .../ContextMenu/UI/EntityMenuUIController.cs | 2 +- Content.Client/Gameplay/GameplayStateBase.cs | 2 +- Content.Client/NPC/PathfindingSystem.cs | 10 +++++++--- Content.Client/Popups/PopupOverlay.cs | 6 ++++-- Content.Client/Popups/PopupSystem.cs | 2 ++ .../Radiation/Overlays/RadiationPulseOverlay.cs | 5 ++++- Content.Client/Sandbox/SandboxSystem.cs | 3 ++- .../AtmosphereSystem.HighPressureDelta.cs | 2 +- Content.Server/Chemistry/EntitySystems/VaporSystem.cs | 4 ++-- .../Construction/Conditions/ComponentInTile.cs | 3 ++- .../Construction/ConstructionSystem.Initial.cs | 7 ++----- Content.Server/Dragon/DragonSystem.cs | 3 ++- .../Explosion/EntitySystems/ExplosionSystem.cs | 2 +- Content.Server/GameTicking/GameTicker.Spawning.cs | 2 +- Content.Server/Guardian/GuardianSystem.cs | 3 ++- Content.Server/Hands/Systems/HandsSystem.cs | 3 ++- Content.Server/Implants/SubdermalImplantSystem.cs | 2 +- Content.Server/Magic/MagicSystem.cs | 2 +- .../Preconditions/CoordinatesInRangePrecondition.cs | 2 +- .../CoordinatesNotInRangePrecondition.cs | 2 +- .../HTN/Preconditions/TargetInRangePrecondition.cs | 2 +- Content.Server/NPC/Pathfinding/PathfindingSystem.cs | 2 +- .../Pointing/EntitySystems/PointingSystem.cs | 7 ++++--- Content.Server/Respawn/SpecialRespawnSystem.cs | 5 +++-- .../Singularity/EntitySystems/GravityWellSystem.cs | 8 ++++---- .../EntitySystems/SingularityAttractorSystem.cs | 11 +++-------- .../Storage/EntitySystems/BluespaceLockerSystem.cs | 3 ++- .../Systems/Carvers/NoiseRangeCarverSystem.cs | 3 ++- .../Construction/Conditions/WallmountCondition.cs | 3 ++- Content.Shared/Examine/ExamineSystemShared.cs | 2 +- .../Hands/EntitySystems/SharedHandsSystem.Pickup.cs | 2 +- Content.Shared/Interaction/SharedInteractionSystem.cs | 6 +++--- Content.Shared/Spawning/EntitySystemExtensions.cs | 2 +- 34 files changed, 70 insertions(+), 56 deletions(-) diff --git a/Content.Client/Construction/ConstructionSystem.cs b/Content.Client/Construction/ConstructionSystem.cs index ae1724c3bf63c5..66000a8457dc2a 100644 --- a/Content.Client/Construction/ConstructionSystem.cs +++ b/Content.Client/Construction/ConstructionSystem.cs @@ -27,6 +27,7 @@ public sealed class ConstructionSystem : SharedConstructionSystem [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; [Dependency] private readonly PopupSystem _popupSystem = default!; private readonly Dictionary _ghosts = new(); @@ -195,7 +196,7 @@ public bool TrySpawnGhost( return false; // This InRangeUnobstructed should probably be replaced with "is there something blocking us in that tile?" - var predicate = GetPredicate(prototype.CanBuildInImpassable, loc.ToMap(EntityManager)); + var predicate = GetPredicate(prototype.CanBuildInImpassable, loc.ToMap(EntityManager, _transformSystem)); if (!_interactionSystem.InRangeUnobstructed(user, loc, 20f, predicate: predicate)) return false; diff --git a/Content.Client/ContextMenu/UI/EntityMenuUIController.cs b/Content.Client/ContextMenu/UI/EntityMenuUIController.cs index ae1b3ec3bf005b..a60619baa357d2 100644 --- a/Content.Client/ContextMenu/UI/EntityMenuUIController.cs +++ b/Content.Client/ContextMenu/UI/EntityMenuUIController.cs @@ -170,7 +170,7 @@ private bool HandleOpenEntityMenu(in PointerInputCmdHandler.PointerInputCmdArgs if (_combatMode.IsInCombatMode(args.Session?.AttachedEntity)) return false; - var coords = args.Coordinates.ToMap(_entityManager); + var coords = args.Coordinates.ToMap(_entityManager, _xform); if (_verbSystem.TryGetEntityMenuEntities(coords, out var entities)) OpenRootMenu(entities); diff --git a/Content.Client/Gameplay/GameplayStateBase.cs b/Content.Client/Gameplay/GameplayStateBase.cs index bdbd69d108636d..6236cd8e958378 100644 --- a/Content.Client/Gameplay/GameplayStateBase.cs +++ b/Content.Client/Gameplay/GameplayStateBase.cs @@ -104,7 +104,7 @@ private bool HandleInspect(ICommonSession? session, EntityCoordinates coords, En public IEnumerable GetClickableEntities(EntityCoordinates coordinates) { - return GetClickableEntities(coordinates.ToMap(_entityManager)); + return GetClickableEntities(coordinates.ToMap(_entityManager, _entitySystemManager.GetEntitySystem())); } public IEnumerable GetClickableEntities(MapCoordinates coordinates) diff --git a/Content.Client/NPC/PathfindingSystem.cs b/Content.Client/NPC/PathfindingSystem.cs index 548edd601ce871..7bf3df1f0b9721 100644 --- a/Content.Client/NPC/PathfindingSystem.cs +++ b/Content.Client/NPC/PathfindingSystem.cs @@ -23,6 +23,7 @@ public sealed class PathfindingSystem : SharedPathfindingSystem [Dependency] private readonly IResourceCache _cache = default!; [Dependency] private readonly NPCSteeringSystem _steering = default!; [Dependency] private readonly MapSystem _mapSystem = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; public PathfindingDebugMode Modes { @@ -39,7 +40,7 @@ public PathfindingDebugMode Modes } else if (!overlayManager.HasOverlay()) { - overlayManager.AddOverlay(new PathfindingOverlay(EntityManager, _eyeManager, _inputManager, _mapManager, _cache, this, _mapSystem)); + overlayManager.AddOverlay(new PathfindingOverlay(EntityManager, _eyeManager, _inputManager, _mapManager, _cache, this, _mapSystem, _transformSystem)); } if ((value & PathfindingDebugMode.Steering) != 0x0) @@ -140,6 +141,7 @@ public sealed class PathfindingOverlay : Overlay private readonly IMapManager _mapManager; private readonly PathfindingSystem _system; private readonly MapSystem _mapSystem; + private readonly SharedTransformSystem _transformSystem; public override OverlaySpace Space => OverlaySpace.ScreenSpace | OverlaySpace.WorldSpace; @@ -153,7 +155,8 @@ public PathfindingOverlay( IMapManager mapManager, IResourceCache cache, PathfindingSystem system, - MapSystem mapSystem) + MapSystem mapSystem, + SharedTransformSystem transformSystem) { _entManager = entManager; _eyeManager = eyeManager; @@ -161,6 +164,7 @@ public PathfindingOverlay( _mapManager = mapManager; _system = system; _mapSystem = mapSystem; + _transformSystem = transformSystem; _font = new VectorFont(cache.GetResource("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10); } @@ -480,7 +484,7 @@ private void DrawWorld(OverlayDrawArgs args, DrawingHandleWorld worldHandle) if (neighborPoly.NetEntity != poly.GraphUid) { color = Color.Green; - var neighborMap = _entManager.GetCoordinates(neighborPoly).ToMap(_entManager); + var neighborMap = _entManager.GetCoordinates(neighborPoly).ToMap(_entManager, _transformSystem); if (neighborMap.MapId != args.MapId) continue; diff --git a/Content.Client/Popups/PopupOverlay.cs b/Content.Client/Popups/PopupOverlay.cs index 3bfa7278734a37..fb6bb3bf565e2d 100644 --- a/Content.Client/Popups/PopupOverlay.cs +++ b/Content.Client/Popups/PopupOverlay.cs @@ -22,7 +22,7 @@ public sealed class PopupOverlay : Overlay private readonly PopupSystem _popup; private readonly PopupUIController _controller; private readonly ExamineSystemShared _examine; - + private readonly SharedTransformSystem _transform; private readonly ShaderInstance _shader; public override OverlaySpace Space => OverlaySpace.ScreenSpace; @@ -35,6 +35,7 @@ public PopupOverlay( IUserInterfaceManager uiManager, PopupUIController controller, ExamineSystemShared examine, + SharedTransformSystem transform, PopupSystem popup) { _configManager = configManager; @@ -42,6 +43,7 @@ public PopupOverlay( _playerMgr = playerMgr; _uiManager = uiManager; _examine = examine; + _transform = transform; _popup = popup; _controller = controller; @@ -76,7 +78,7 @@ private void DrawWorld(DrawingHandleScreen worldHandle, OverlayDrawArgs args, fl foreach (var popup in _popup.WorldLabels) { - var mapPos = popup.InitialPos.ToMap(_entManager); + var mapPos = popup.InitialPos.ToMap(_entManager, _transform); if (mapPos.MapId != args.MapId) continue; diff --git a/Content.Client/Popups/PopupSystem.cs b/Content.Client/Popups/PopupSystem.cs index 46c1e0cdf62bc9..479fb02906c46b 100644 --- a/Content.Client/Popups/PopupSystem.cs +++ b/Content.Client/Popups/PopupSystem.cs @@ -28,6 +28,7 @@ public sealed class PopupSystem : SharedPopupSystem [Dependency] private readonly IUserInterfaceManager _uiManager = default!; [Dependency] private readonly IReplayRecordingManager _replayRecording = default!; [Dependency] private readonly ExamineSystemShared _examine = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public IReadOnlyList WorldLabels => _aliveWorldLabels; public IReadOnlyList CursorLabels => _aliveCursorLabels; @@ -54,6 +55,7 @@ public override void Initialize() _uiManager, _uiManager.GetUIController(), _examine, + _transform, this)); } diff --git a/Content.Client/Radiation/Overlays/RadiationPulseOverlay.cs b/Content.Client/Radiation/Overlays/RadiationPulseOverlay.cs index adc535b2684b4f..9012767ef3f387 100644 --- a/Content.Client/Radiation/Overlays/RadiationPulseOverlay.cs +++ b/Content.Client/Radiation/Overlays/RadiationPulseOverlay.cs @@ -121,7 +121,10 @@ private void RadiationQuery(IEye? currentEye) private bool PulseQualifies(EntityUid pulseEntity, MapCoordinates currentEyeLoc) { - return _entityManager.GetComponent(pulseEntity).MapID == currentEyeLoc.MapId && _entityManager.GetComponent(pulseEntity).Coordinates.InRange(_entityManager, EntityCoordinates.FromMap(_entityManager, _entityManager.GetComponent(pulseEntity).ParentUid, currentEyeLoc), MaxDist); + var transformComponent = _entityManager.GetComponent(pulseEntity); + var transformSystem = _entityManager.System(); + return transformComponent.MapID == currentEyeLoc.MapId + && transformComponent.Coordinates.InRange(_entityManager, transformSystem, EntityCoordinates.FromMap(transformComponent.ParentUid, currentEyeLoc, transformSystem, _entityManager), MaxDist); } private sealed record RadiationShaderInstance(MapCoordinates CurrentMapCoords, float Range, TimeSpan Start, float Duration) diff --git a/Content.Client/Sandbox/SandboxSystem.cs b/Content.Client/Sandbox/SandboxSystem.cs index d16751e3715d2b..6a1129bb75d97e 100644 --- a/Content.Client/Sandbox/SandboxSystem.cs +++ b/Content.Client/Sandbox/SandboxSystem.cs @@ -16,6 +16,7 @@ public sealed class SandboxSystem : SharedSandboxSystem [Dependency] private readonly IMapManager _map = default!; [Dependency] private readonly IPlacementManager _placement = default!; [Dependency] private readonly ContentEyeSystem _contentEye = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; private bool _sandboxEnabled; public bool SandboxAllowed { get; private set; } @@ -108,7 +109,7 @@ public bool Copy(ICommonSession? session, EntityCoordinates coords, EntityUid ui } // Try copy tile. - if (!_map.TryFindGridAt(coords.ToMap(EntityManager), out _, out var grid) || !grid.TryGetTileRef(coords, out var tileRef)) + if (!_map.TryFindGridAt(coords.ToMap(EntityManager, _transform), out _, out var grid) || !grid.TryGetTileRef(coords, out var tileRef)) return false; if (_placement.Eraser) diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs index 53035e1ed3c555..4d25292a667968 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs @@ -238,7 +238,7 @@ public void ExperiencePressureDifference( // 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, _transformSystem).Position - xform.WorldPosition).Normalized() + dirVec).Normalized(); _physics.ApplyLinearImpulse(uid, pos * moveForce, body: physics); } else diff --git a/Content.Server/Chemistry/EntitySystems/VaporSystem.cs b/Content.Server/Chemistry/EntitySystems/VaporSystem.cs index d945c1f818b722..e174d39fc6f92a 100644 --- a/Content.Server/Chemistry/EntitySystems/VaporSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/VaporSystem.cs @@ -22,8 +22,8 @@ namespace Content.Server.Chemistry.EntitySystems [UsedImplicitly] internal sealed class VaporSystem : EntitySystem { - [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IPrototypeManager _protoManager = default!; + [Dependency] private readonly SharedMapSystem _map = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!; [Dependency] private readonly ThrowingSystem _throwing = default!; @@ -115,7 +115,7 @@ private void Update(float frameTime, Entity ent, Entity()); + var transformSys = entityManager.System(); + var indices = transform.Coordinates.ToVector2i(entityManager, IoCManager.Resolve(), transformSys); var lookup = entityManager.EntitySysManager.GetEntitySystem(); var entities = indices.GetEntitiesInTile(transform.GridUid.Value, LookupFlags.Approximate | LookupFlags.Static, lookup); diff --git a/Content.Server/Construction/ConstructionSystem.Initial.cs b/Content.Server/Construction/ConstructionSystem.Initial.cs index 298036650013f3..ede8d3064faa38 100644 --- a/Content.Server/Construction/ConstructionSystem.Initial.cs +++ b/Content.Server/Construction/ConstructionSystem.Initial.cs @@ -2,7 +2,6 @@ using System.Linq; using System.Threading.Tasks; using Content.Server.Construction.Components; -using Content.Server.Storage.EntitySystems; using Content.Shared.ActionBlocker; using Content.Shared.Construction; using Content.Shared.Construction.Prototypes; @@ -15,7 +14,6 @@ using Content.Shared.Interaction; using Content.Shared.Inventory; using Content.Shared.Storage; -using Content.Shared.Tag; using Robust.Shared.Containers; using Robust.Shared.Player; using Robust.Shared.Timing; @@ -30,8 +28,7 @@ public sealed partial class ConstructionSystem [Dependency] private readonly ActionBlockerSystem _actionBlocker = default!; [Dependency] private readonly SharedHandsSystem _handsSystem = default!; [Dependency] private readonly EntityLookupSystem _lookupSystem = default!; - [Dependency] private readonly StorageSystem _storageSystem = default!; - [Dependency] private readonly TagSystem _tagSystem = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; // --- WARNING! LEGACY CODE AHEAD! --- // This entire file contains the legacy code for initial construction. @@ -465,7 +462,7 @@ void Cleanup() return; } - var mapPos = location.ToMap(EntityManager); + var mapPos = location.ToMap(EntityManager, _transformSystem); var predicate = GetPredicate(constructionPrototype.CanBuildInImpassable, mapPos); if (!_interactionSystem.InRangeUnobstructed(user, mapPos, predicate: predicate)) diff --git a/Content.Server/Dragon/DragonSystem.cs b/Content.Server/Dragon/DragonSystem.cs index 36df6fb6f29c76..326510715f0464 100644 --- a/Content.Server/Dragon/DragonSystem.cs +++ b/Content.Server/Dragon/DragonSystem.cs @@ -31,6 +31,7 @@ public sealed partial class DragonSystem : EntitySystem [Dependency] private readonly RoleSystem _role = default!; [Dependency] private readonly SharedActionsSystem _actions = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; private EntityQuery _objQuery; @@ -150,7 +151,7 @@ private void OnSpawnRift(EntityUid uid, DragonComponent component, DragonSpawnRi // cant stack rifts near eachother foreach (var (_, riftXform) in EntityQuery(true)) { - if (riftXform.Coordinates.InRange(EntityManager, xform.Coordinates, RiftRange)) + if (riftXform.Coordinates.InRange(EntityManager, _transform, xform.Coordinates, RiftRange)) { _popup.PopupEntity(Loc.GetString("carp-rift-proximity", ("proximity", RiftRange)), uid, uid); return; diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs index 24ccf611bdabb1..46238fd7c5d7cf 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs @@ -331,7 +331,7 @@ public void QueueExplosion(MapCoordinates epicenter, CameraShake(iterationIntensity.Count * 4f, epicenter, totalIntensity); //For whatever bloody reason, sound system requires ENTITY coordinates. - var mapEntityCoords = EntityCoordinates.FromMap(EntityManager, _mapManager.GetMapEntityId(epicenter.MapId), epicenter); + var mapEntityCoords = EntityCoordinates.FromMap(_mapManager.GetMapEntityId(epicenter.MapId), epicenter, _transformSystem, EntityManager); // play sound. // for the normal audio, we want everyone in pvs range diff --git a/Content.Server/GameTicking/GameTicker.Spawning.cs b/Content.Server/GameTicking/GameTicker.Spawning.cs index 65de36cf80ee1d..52bab07ce8fe18 100644 --- a/Content.Server/GameTicking/GameTicker.Spawning.cs +++ b/Content.Server/GameTicking/GameTicker.Spawning.cs @@ -386,7 +386,7 @@ public EntityCoordinates GetObserverSpawnPoint() // Ideally engine would just spawn them on grid directly I guess? Right now grid traversal is handling it during // update which means we need to add a hack somewhere around it. var spawn = _robustRandom.Pick(_possiblePositions); - var toMap = spawn.ToMap(EntityManager); + var toMap = spawn.ToMap(EntityManager, _transform); if (_mapManager.TryFindGridAt(toMap, out var gridUid, out _)) { diff --git a/Content.Server/Guardian/GuardianSystem.cs b/Content.Server/Guardian/GuardianSystem.cs index 808de9f667b828..e58f997b211d56 100644 --- a/Content.Server/Guardian/GuardianSystem.cs +++ b/Content.Server/Guardian/GuardianSystem.cs @@ -34,6 +34,7 @@ public sealed class GuardianSystem : EntitySystem [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly BodySystem _bodySystem = default!; [Dependency] private readonly SharedContainerSystem _container = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public override void Initialize() { @@ -324,7 +325,7 @@ private void CheckGuardianMove( if (!guardianComponent.GuardianLoose) return; - if (!guardianXform.Coordinates.InRange(EntityManager, hostXform.Coordinates, guardianComponent.DistanceAllowed)) + if (!guardianXform.Coordinates.InRange(EntityManager, _transform, hostXform.Coordinates, guardianComponent.DistanceAllowed)) RetractGuardian(hostUid, hostComponent, guardianUid, guardianComponent); } diff --git a/Content.Server/Hands/Systems/HandsSystem.cs b/Content.Server/Hands/Systems/HandsSystem.cs index 99958db2728b21..c783701003de37 100644 --- a/Content.Server/Hands/Systems/HandsSystem.cs +++ b/Content.Server/Hands/Systems/HandsSystem.cs @@ -35,6 +35,7 @@ public sealed class HandsSystem : SharedHandsSystem [Dependency] private readonly VirtualItemSystem _virtualItemSystem = default!; [Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!; [Dependency] private readonly SharedHandsSystem _handsSystem = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; [Dependency] private readonly PullingSystem _pullingSystem = default!; [Dependency] private readonly ThrowingSystem _throwingSystem = default!; @@ -198,7 +199,7 @@ hands.ActiveHandEntity is not { } throwEnt || throwEnt = splitStack.Value; } - var direction = coordinates.ToMapPos(EntityManager) - Transform(player).WorldPosition; + var direction = coordinates.ToMapPos(EntityManager, _transformSystem) - Transform(player).WorldPosition; if (direction == Vector2.Zero) return true; diff --git a/Content.Server/Implants/SubdermalImplantSystem.cs b/Content.Server/Implants/SubdermalImplantSystem.cs index ac415a0434269c..8eb27414481739 100644 --- a/Content.Server/Implants/SubdermalImplantSystem.cs +++ b/Content.Server/Implants/SubdermalImplantSystem.cs @@ -99,7 +99,7 @@ private void OnScramImplant(EntityUid uid, SubdermalImplantComponent component, return; var xform = Transform(ent); - var entityCoords = xform.Coordinates.ToMap(EntityManager); + var entityCoords = xform.Coordinates.ToMap(EntityManager, _xform); // try to find a valid position to teleport to, teleport to whatever works if we can't var targetCoords = new MapCoordinates(); diff --git a/Content.Server/Magic/MagicSystem.cs b/Content.Server/Magic/MagicSystem.cs index 371814cacbc185..c6915121bfbe50 100644 --- a/Content.Server/Magic/MagicSystem.cs +++ b/Content.Server/Magic/MagicSystem.cs @@ -167,7 +167,7 @@ private void OnProjectileSpell(ProjectileSpellEvent ev) foreach (var pos in GetSpawnPositions(xform, ev.Pos)) { // If applicable, this ensures the projectile is parented to grid on spawn, instead of the map. - var mapPos = pos.ToMap(EntityManager); + var mapPos = pos.ToMap(EntityManager, _transformSystem); var spawnCoords = _mapManager.TryFindGridAt(mapPos, out var gridUid, out _) ? pos.WithEntityId(gridUid, EntityManager) : new(_mapManager.GetMapEntityId(mapPos.MapId), mapPos.Position); diff --git a/Content.Server/NPC/HTN/Preconditions/CoordinatesInRangePrecondition.cs b/Content.Server/NPC/HTN/Preconditions/CoordinatesInRangePrecondition.cs index 3e030aa8197ee7..3485bd2a18c334 100644 --- a/Content.Server/NPC/HTN/Preconditions/CoordinatesInRangePrecondition.cs +++ b/Content.Server/NPC/HTN/Preconditions/CoordinatesInRangePrecondition.cs @@ -22,6 +22,6 @@ public override bool IsMet(NPCBlackboard blackboard) if (!blackboard.TryGetValue(TargetKey, out var target, _entManager)) return false; - return coordinates.InRange(_entManager, target, blackboard.GetValueOrDefault(RangeKey, _entManager)); + return coordinates.InRange(_entManager, _entManager.System(), target, blackboard.GetValueOrDefault(RangeKey, _entManager)); } } diff --git a/Content.Server/NPC/HTN/Preconditions/CoordinatesNotInRangePrecondition.cs b/Content.Server/NPC/HTN/Preconditions/CoordinatesNotInRangePrecondition.cs index 6d8977bb7a7649..9d000ca2eb841b 100644 --- a/Content.Server/NPC/HTN/Preconditions/CoordinatesNotInRangePrecondition.cs +++ b/Content.Server/NPC/HTN/Preconditions/CoordinatesNotInRangePrecondition.cs @@ -22,7 +22,7 @@ public override bool IsMet(NPCBlackboard blackboard) if (!blackboard.TryGetValue(TargetKey, out var target, _entManager)) return false; - return !coordinates.InRange(_entManager, target, blackboard.GetValueOrDefault(RangeKey, _entManager)); + return !coordinates.InRange(_entManager, _entManager.System(), target, blackboard.GetValueOrDefault(RangeKey, _entManager)); } } diff --git a/Content.Server/NPC/HTN/Preconditions/TargetInRangePrecondition.cs b/Content.Server/NPC/HTN/Preconditions/TargetInRangePrecondition.cs index 5d616ba630e5f2..aaccb426d714b1 100644 --- a/Content.Server/NPC/HTN/Preconditions/TargetInRangePrecondition.cs +++ b/Content.Server/NPC/HTN/Preconditions/TargetInRangePrecondition.cs @@ -23,6 +23,6 @@ public override bool IsMet(NPCBlackboard blackboard) !_entManager.TryGetComponent(target, out var targetXform)) return false; - return coordinates.InRange(_entManager, targetXform.Coordinates, blackboard.GetValueOrDefault(RangeKey, _entManager)); + return coordinates.InRange(_entManager, _entManager.System(), targetXform.Coordinates, blackboard.GetValueOrDefault(RangeKey, _entManager)); } } diff --git a/Content.Server/NPC/Pathfinding/PathfindingSystem.cs b/Content.Server/NPC/Pathfinding/PathfindingSystem.cs index 95f931cdd6a693..a59af88ff58d12 100644 --- a/Content.Server/NPC/Pathfinding/PathfindingSystem.cs +++ b/Content.Server/NPC/Pathfinding/PathfindingSystem.cs @@ -405,7 +405,7 @@ public async void GetPathEvent( return null; } - var localPos = xform.InvWorldMatrix.Transform(coordinates.ToMapPos(EntityManager)); + var localPos = xform.InvWorldMatrix.Transform(coordinates.ToMapPos(EntityManager, _transform)); var origin = GetOrigin(localPos); if (!TryGetChunk(origin, comp, out var chunk)) diff --git a/Content.Server/Pointing/EntitySystems/PointingSystem.cs b/Content.Server/Pointing/EntitySystems/PointingSystem.cs index 06d2d6f58b52a6..9b2e14eff8b717 100644 --- a/Content.Server/Pointing/EntitySystems/PointingSystem.cs +++ b/Content.Server/Pointing/EntitySystems/PointingSystem.cs @@ -36,6 +36,7 @@ internal sealed class PointingSystem : SharedPointingSystem [Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly VisibilitySystem _visibilitySystem = default!; [Dependency] private readonly SharedMindSystem _minds = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly ExamineSystemShared _examine = default!; @@ -97,7 +98,7 @@ public bool InRange(EntityUid pointer, EntityCoordinates coordinates) { if (HasComp(pointer)) { - return Transform(pointer).Coordinates.InRange(EntityManager, coordinates, 15); + return Transform(pointer).Coordinates.InRange(EntityManager, _transform, coordinates, 15); } else { @@ -142,7 +143,7 @@ public bool TryPoint(ICommonSession? session, EntityCoordinates coordsPointed, E return false; } - var mapCoordsPointed = coordsPointed.ToMap(EntityManager); + var mapCoordsPointed = coordsPointed.ToMap(EntityManager, _transform); _rotateToFaceSystem.TryFaceCoordinates(player, mapCoordsPointed.Position); var arrow = EntityManager.SpawnEntity("PointingArrow", coordsPointed); @@ -150,7 +151,7 @@ public bool TryPoint(ICommonSession? session, EntityCoordinates coordsPointed, E if (TryComp(arrow, out var pointing)) { if (TryComp(player, out TransformComponent? xformPlayer)) - pointing.StartPosition = EntityCoordinates.FromMap(arrow, xformPlayer.Coordinates.ToMap(EntityManager)).Position; + pointing.StartPosition = EntityCoordinates.FromMap(arrow, xformPlayer.Coordinates.ToMap(EntityManager, _transform), _transform).Position; pointing.EndTime = _gameTiming.CurTime + PointDuration; diff --git a/Content.Server/Respawn/SpecialRespawnSystem.cs b/Content.Server/Respawn/SpecialRespawnSystem.cs index 51c092be18b36d..2822c94093f867 100644 --- a/Content.Server/Respawn/SpecialRespawnSystem.cs +++ b/Content.Server/Respawn/SpecialRespawnSystem.cs @@ -20,6 +20,7 @@ public sealed class SpecialRespawnSystem : SharedSpecialRespawnSystem [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!; [Dependency] private readonly AtmosphereSystem _atmosphere = default!; [Dependency] private readonly IRobustRandom _random = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly TurfSystem _turf = default!; [Dependency] private readonly IChatManager _chat = default!; @@ -129,11 +130,11 @@ private void OnTermination(EntityUid uid, SpecialRespawnComponent component, ref private void Respawn(EntityUid oldEntity, string prototype, EntityCoordinates coords) { var entity = Spawn(prototype, coords); - _adminLog.Add(LogType.Respawn, LogImpact.High, $"{ToPrettyString(oldEntity)} was deleted and was respawned at {coords.ToMap(EntityManager)} as {ToPrettyString(entity)}"); + _adminLog.Add(LogType.Respawn, LogImpact.High, $"{ToPrettyString(oldEntity)} was deleted and was respawned at {coords.ToMap(EntityManager, _transform)} as {ToPrettyString(entity)}"); _chat.SendAdminAlert($"{MetaData(oldEntity).EntityName} was deleted and was respawned as {ToPrettyString(entity)}"); } - /// + /// /// Try to find a random safe tile on the supplied grid /// /// The grid that you're looking for a safe tile on diff --git a/Content.Server/Singularity/EntitySystems/GravityWellSystem.cs b/Content.Server/Singularity/EntitySystems/GravityWellSystem.cs index ce4334391db6e7..f1d0af6f9050e7 100644 --- a/Content.Server/Singularity/EntitySystems/GravityWellSystem.cs +++ b/Content.Server/Singularity/EntitySystems/GravityWellSystem.cs @@ -18,13 +18,13 @@ namespace Content.Server.Singularity.EntitySystems; /// public sealed class GravityWellSystem : SharedGravityWellSystem { -#region Dependencies + #region Dependencies [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IViewVariablesManager _vvManager = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; -#endregion Dependencies + #endregion Dependencies /// /// The minimum range at which gravpulses will act. @@ -155,7 +155,7 @@ public void GravPulse(EntityUid uid, float maxRange, float minRange, float baseR /// The minimum distance at which entities can be affected by the gravity pulse. /// The base velocity added to any entities within affected by the gravity pulse scaled by the displacement of those entities from the epicenter. public void GravPulse(EntityCoordinates entityPos, float maxRange, float minRange, in Matrix3 baseMatrixDeltaV) - => GravPulse(entityPos.ToMap(EntityManager), maxRange, minRange, in baseMatrixDeltaV); + => GravPulse(entityPos.ToMap(EntityManager, _transform), maxRange, minRange, in baseMatrixDeltaV); /// /// Greates a gravitational pulse, shoving around all entities within some distance of an epicenter. @@ -166,7 +166,7 @@ public void GravPulse(EntityCoordinates entityPos, float maxRange, float minRang /// The base radial velocity that will be added to entities within range towards the center of the gravitational pulse. /// The base tangential velocity that will be added to entities within countrclockwise around the center of the gravitational pulse. public void GravPulse(EntityCoordinates entityPos, float maxRange, float minRange, float baseRadialDeltaV = 0.0f, float baseTangentialDeltaV = 0.0f) - => GravPulse(entityPos.ToMap(EntityManager), maxRange, minRange, baseRadialDeltaV, baseTangentialDeltaV); + => GravPulse(entityPos.ToMap(EntityManager, _transform), maxRange, minRange, baseRadialDeltaV, baseTangentialDeltaV); /// /// Causes a gravitational pulse, shoving around all entities within some distance of an epicenter. diff --git a/Content.Server/Singularity/EntitySystems/SingularityAttractorSystem.cs b/Content.Server/Singularity/EntitySystems/SingularityAttractorSystem.cs index 3c44a7fc7af652..bc0de7c8c64f12 100644 --- a/Content.Server/Singularity/EntitySystems/SingularityAttractorSystem.cs +++ b/Content.Server/Singularity/EntitySystems/SingularityAttractorSystem.cs @@ -2,12 +2,7 @@ using Content.Server.Power.EntitySystems; using Content.Server.Singularity.Components; using Content.Shared.Singularity.Components; -using Content.Shared.Singularity.EntitySystems; using Robust.Shared.Map; -using Robust.Shared.Map.Components; -using Robust.Shared.Physics; -using Robust.Shared.Physics.Components; -using Robust.Shared.Physics.Systems; using Robust.Shared.Timing; using System.Numerics; @@ -18,8 +13,8 @@ namespace Content.Server.Singularity.EntitySystems; /// public sealed class SingularityAttractorSystem : EntitySystem { - [Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly IGameTiming _timing = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; /// /// The minimum range at which the attraction will act. @@ -69,7 +64,7 @@ private void Update(EntityUid uid, SingularityAttractorComponent? attractor = nu attractor.LastPulseTime = _timing.CurTime; - var mapPos = xform.Coordinates.ToMap(EntityManager); + var mapPos = xform.Coordinates.ToMap(EntityManager, _transform); if (mapPos == MapCoordinates.Nullspace) return; @@ -77,7 +72,7 @@ private void Update(EntityUid uid, SingularityAttractorComponent? attractor = nu var query = EntityQuery(); foreach (var (singulo, walk, singuloXform) in query) { - var singuloMapPos = singuloXform.Coordinates.ToMap(EntityManager); + var singuloMapPos = singuloXform.Coordinates.ToMap(EntityManager, _transform); if (singuloMapPos.MapId != mapPos.MapId) continue; diff --git a/Content.Server/Storage/EntitySystems/BluespaceLockerSystem.cs b/Content.Server/Storage/EntitySystems/BluespaceLockerSystem.cs index 9995ed40c12238..356768769bb830 100644 --- a/Content.Server/Storage/EntitySystems/BluespaceLockerSystem.cs +++ b/Content.Server/Storage/EntitySystems/BluespaceLockerSystem.cs @@ -26,6 +26,7 @@ public sealed class BluespaceLockerSystem : EntitySystem [Dependency] private readonly WeldableSystem _weldableSystem = default!; [Dependency] private readonly LockSystem _lockSystem = default!; [Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!; + [Dependency] private readonly SharedTransformSystem _transformSystem = default!; [Dependency] private readonly ExplosionSystem _explosionSystem = default!; public override void Initialize() @@ -386,7 +387,7 @@ private void DestroyAfterLimit(EntityUid uid, BluespaceLockerComponent component switch (component.BehaviorProperties.DestroyType) { case BluespaceLockerDestroyType.Explode: - _explosionSystem.QueueExplosion(uid.ToCoordinates().ToMap(EntityManager), + _explosionSystem.QueueExplosion(uid.ToCoordinates().ToMap(EntityManager, _transformSystem), ExplosionSystem.DefaultExplosionPrototypeId, 4, 1, 2, maxTileBreak: 0); goto case BluespaceLockerDestroyType.Delete; case BluespaceLockerDestroyType.Delete: diff --git a/Content.Server/Worldgen/Systems/Carvers/NoiseRangeCarverSystem.cs b/Content.Server/Worldgen/Systems/Carvers/NoiseRangeCarverSystem.cs index aed32bc89c3165..f2e051669a219d 100644 --- a/Content.Server/Worldgen/Systems/Carvers/NoiseRangeCarverSystem.cs +++ b/Content.Server/Worldgen/Systems/Carvers/NoiseRangeCarverSystem.cs @@ -9,6 +9,7 @@ namespace Content.Server.Worldgen.Systems.Carvers; public sealed class NoiseRangeCarverSystem : EntitySystem { [Dependency] private readonly NoiseIndexSystem _index = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; /// public override void Initialize() @@ -19,7 +20,7 @@ public override void Initialize() private void OnPrePlaceDebris(EntityUid uid, NoiseRangeCarverComponent component, ref PrePlaceDebrisFeatureEvent args) { - var coords = WorldGen.WorldToChunkCoords(args.Coords.ToMapPos(EntityManager)); + var coords = WorldGen.WorldToChunkCoords(args.Coords.ToMapPos(EntityManager, _transform)); var val = _index.Evaluate(uid, component.NoiseChannel, coords); foreach (var (low, high) in component.Ranges) diff --git a/Content.Shared/Construction/Conditions/WallmountCondition.cs b/Content.Shared/Construction/Conditions/WallmountCondition.cs index bf3016d4974011..fe4336e6fc7ac7 100644 --- a/Content.Shared/Construction/Conditions/WallmountCondition.cs +++ b/Content.Shared/Construction/Conditions/WallmountCondition.cs @@ -19,8 +19,9 @@ public bool Condition(EntityUid user, EntityCoordinates location, Direction dire var entManager = IoCManager.Resolve(); // get blueprint and user position + var transformSystem = entManager.System(); var userWorldPosition = entManager.GetComponent(user).WorldPosition; - var objWorldPosition = location.ToMap(entManager).Position; + var objWorldPosition = location.ToMap(entManager, transformSystem).Position; // find direction from user to blueprint var userToObject = (objWorldPosition - userWorldPosition); diff --git a/Content.Shared/Examine/ExamineSystemShared.cs b/Content.Shared/Examine/ExamineSystemShared.cs index f792862be1452e..2a5201f76872c3 100644 --- a/Content.Shared/Examine/ExamineSystemShared.cs +++ b/Content.Shared/Examine/ExamineSystemShared.cs @@ -220,7 +220,7 @@ public bool InRangeUnOccluded(EntityUid origin, EntityCoordinates other, float r { var entMan = IoCManager.Resolve(); var originPos = entMan.GetComponent(origin).MapPosition; - var otherPos = other.ToMap(entMan); + var otherPos = other.ToMap(entMan, _transform); return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker); } diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs index bbae03e45b3d34..20e08b2767d23c 100644 --- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs +++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs @@ -114,7 +114,7 @@ public bool TryPickup( && (itemPos.Position - xform.MapPosition.Position).Length() <= MaxAnimationRange && MetaData(entity).VisibilityMask == MetaData(uid).VisibilityMask) // Don't animate aghost pickups. { - var initialPosition = EntityCoordinates.FromMap(coordinateEntity, itemPos, EntityManager); + var initialPosition = EntityCoordinates.FromMap(coordinateEntity, itemPos, TransformSystem, EntityManager); _storage.PlayPickupAnimation(entity, initialPosition, xform.Coordinates, itemXform.LocalRotation, uid); } } diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index 7c85ede9b07187..e4864b1f7fc468 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -459,7 +459,7 @@ protected bool ValidateInteractAndFace(EntityUid user, EntityCoordinates coordin return false; if (!HasComp(user)) - _rotateToFaceSystem.TryFaceCoordinates(user, coordinates.ToMapPos(EntityManager)); + _rotateToFaceSystem.TryFaceCoordinates(user, coordinates.ToMapPos(EntityManager, _transform)); return true; } @@ -612,7 +612,7 @@ public bool InRangeUnobstructed( Ignored combinedPredicate = e => e == origin || (predicate?.Invoke(e) ?? false); var inRange = true; MapCoordinates originPos = default; - var targetPos = otherCoordinates.ToMap(EntityManager); + var targetPos = otherCoordinates.ToMap(EntityManager, _transform); Angle targetRot = default; // So essentially: @@ -785,7 +785,7 @@ public bool InRangeUnobstructed( Ignored? predicate = null, bool popup = false) { - return InRangeUnobstructed(origin, other.ToMap(EntityManager), range, collisionMask, predicate, popup); + return InRangeUnobstructed(origin, other.ToMap(EntityManager, _transform), range, collisionMask, predicate, popup); } /// diff --git a/Content.Shared/Spawning/EntitySystemExtensions.cs b/Content.Shared/Spawning/EntitySystemExtensions.cs index 14b171baeb1f18..507a0f4aa27048 100644 --- a/Content.Shared/Spawning/EntitySystemExtensions.cs +++ b/Content.Shared/Spawning/EntitySystemExtensions.cs @@ -16,7 +16,7 @@ public static class EntitySystemExtensions SharedPhysicsSystem? physicsManager = null) { physicsManager ??= entityManager.System(); - var mapCoordinates = coordinates.ToMap(entityManager); + var mapCoordinates = coordinates.ToMap(entityManager, entityManager.System()); return entityManager.SpawnIfUnobstructed(prototypeName, mapCoordinates, collisionLayer, box, physicsManager); }