Code cleanup: Purge calls to obsolete EntityCoordinates methods (#26292)

* Purge calls to obsolete EntityCoordinates methods

* Pizza defruited; rerun those tests!
This commit is contained in:
Tayrtahn
2024-03-20 21:59:56 -04:00
committed by GitHub
parent b34777177c
commit f4cb02fb0c
34 changed files with 70 additions and 56 deletions

View File

@@ -27,6 +27,7 @@ namespace Content.Client.Construction
[Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!; [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly PopupSystem _popupSystem = default!;
private readonly Dictionary<int, EntityUid> _ghosts = new(); private readonly Dictionary<int, EntityUid> _ghosts = new();
@@ -195,7 +196,7 @@ namespace Content.Client.Construction
return false; return false;
// This InRangeUnobstructed should probably be replaced with "is there something blocking us in that tile?" // 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)) if (!_interactionSystem.InRangeUnobstructed(user, loc, 20f, predicate: predicate))
return false; return false;

View File

@@ -170,7 +170,7 @@ namespace Content.Client.ContextMenu.UI
if (_combatMode.IsInCombatMode(args.Session?.AttachedEntity)) if (_combatMode.IsInCombatMode(args.Session?.AttachedEntity))
return false; return false;
var coords = args.Coordinates.ToMap(_entityManager); var coords = args.Coordinates.ToMap(_entityManager, _xform);
if (_verbSystem.TryGetEntityMenuEntities(coords, out var entities)) if (_verbSystem.TryGetEntityMenuEntities(coords, out var entities))
OpenRootMenu(entities); OpenRootMenu(entities);

View File

@@ -104,7 +104,7 @@ namespace Content.Client.Gameplay
public IEnumerable<EntityUid> GetClickableEntities(EntityCoordinates coordinates) public IEnumerable<EntityUid> GetClickableEntities(EntityCoordinates coordinates)
{ {
return GetClickableEntities(coordinates.ToMap(_entityManager)); return GetClickableEntities(coordinates.ToMap(_entityManager, _entitySystemManager.GetEntitySystem<SharedTransformSystem>()));
} }
public IEnumerable<EntityUid> GetClickableEntities(MapCoordinates coordinates) public IEnumerable<EntityUid> GetClickableEntities(MapCoordinates coordinates)

View File

@@ -23,6 +23,7 @@ namespace Content.Client.NPC
[Dependency] private readonly IResourceCache _cache = default!; [Dependency] private readonly IResourceCache _cache = default!;
[Dependency] private readonly NPCSteeringSystem _steering = default!; [Dependency] private readonly NPCSteeringSystem _steering = default!;
[Dependency] private readonly MapSystem _mapSystem = default!; [Dependency] private readonly MapSystem _mapSystem = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
public PathfindingDebugMode Modes public PathfindingDebugMode Modes
{ {
@@ -39,7 +40,7 @@ namespace Content.Client.NPC
} }
else if (!overlayManager.HasOverlay<PathfindingOverlay>()) else if (!overlayManager.HasOverlay<PathfindingOverlay>())
{ {
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) if ((value & PathfindingDebugMode.Steering) != 0x0)
@@ -140,6 +141,7 @@ namespace Content.Client.NPC
private readonly IMapManager _mapManager; private readonly IMapManager _mapManager;
private readonly PathfindingSystem _system; private readonly PathfindingSystem _system;
private readonly MapSystem _mapSystem; private readonly MapSystem _mapSystem;
private readonly SharedTransformSystem _transformSystem;
public override OverlaySpace Space => OverlaySpace.ScreenSpace | OverlaySpace.WorldSpace; public override OverlaySpace Space => OverlaySpace.ScreenSpace | OverlaySpace.WorldSpace;
@@ -153,7 +155,8 @@ namespace Content.Client.NPC
IMapManager mapManager, IMapManager mapManager,
IResourceCache cache, IResourceCache cache,
PathfindingSystem system, PathfindingSystem system,
MapSystem mapSystem) MapSystem mapSystem,
SharedTransformSystem transformSystem)
{ {
_entManager = entManager; _entManager = entManager;
_eyeManager = eyeManager; _eyeManager = eyeManager;
@@ -161,6 +164,7 @@ namespace Content.Client.NPC
_mapManager = mapManager; _mapManager = mapManager;
_system = system; _system = system;
_mapSystem = mapSystem; _mapSystem = mapSystem;
_transformSystem = transformSystem;
_font = new VectorFont(cache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10); _font = new VectorFont(cache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10);
} }
@@ -480,7 +484,7 @@ namespace Content.Client.NPC
if (neighborPoly.NetEntity != poly.GraphUid) if (neighborPoly.NetEntity != poly.GraphUid)
{ {
color = Color.Green; color = Color.Green;
var neighborMap = _entManager.GetCoordinates(neighborPoly).ToMap(_entManager); var neighborMap = _entManager.GetCoordinates(neighborPoly).ToMap(_entManager, _transformSystem);
if (neighborMap.MapId != args.MapId) if (neighborMap.MapId != args.MapId)
continue; continue;

View File

@@ -22,7 +22,7 @@ public sealed class PopupOverlay : Overlay
private readonly PopupSystem _popup; private readonly PopupSystem _popup;
private readonly PopupUIController _controller; private readonly PopupUIController _controller;
private readonly ExamineSystemShared _examine; private readonly ExamineSystemShared _examine;
private readonly SharedTransformSystem _transform;
private readonly ShaderInstance _shader; private readonly ShaderInstance _shader;
public override OverlaySpace Space => OverlaySpace.ScreenSpace; public override OverlaySpace Space => OverlaySpace.ScreenSpace;
@@ -35,6 +35,7 @@ public sealed class PopupOverlay : Overlay
IUserInterfaceManager uiManager, IUserInterfaceManager uiManager,
PopupUIController controller, PopupUIController controller,
ExamineSystemShared examine, ExamineSystemShared examine,
SharedTransformSystem transform,
PopupSystem popup) PopupSystem popup)
{ {
_configManager = configManager; _configManager = configManager;
@@ -42,6 +43,7 @@ public sealed class PopupOverlay : Overlay
_playerMgr = playerMgr; _playerMgr = playerMgr;
_uiManager = uiManager; _uiManager = uiManager;
_examine = examine; _examine = examine;
_transform = transform;
_popup = popup; _popup = popup;
_controller = controller; _controller = controller;
@@ -76,7 +78,7 @@ public sealed class PopupOverlay : Overlay
foreach (var popup in _popup.WorldLabels) foreach (var popup in _popup.WorldLabels)
{ {
var mapPos = popup.InitialPos.ToMap(_entManager); var mapPos = popup.InitialPos.ToMap(_entManager, _transform);
if (mapPos.MapId != args.MapId) if (mapPos.MapId != args.MapId)
continue; continue;

View File

@@ -28,6 +28,7 @@ namespace Content.Client.Popups
[Dependency] private readonly IUserInterfaceManager _uiManager = default!; [Dependency] private readonly IUserInterfaceManager _uiManager = default!;
[Dependency] private readonly IReplayRecordingManager _replayRecording = default!; [Dependency] private readonly IReplayRecordingManager _replayRecording = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!; [Dependency] private readonly ExamineSystemShared _examine = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public IReadOnlyList<WorldPopupLabel> WorldLabels => _aliveWorldLabels; public IReadOnlyList<WorldPopupLabel> WorldLabels => _aliveWorldLabels;
public IReadOnlyList<CursorPopupLabel> CursorLabels => _aliveCursorLabels; public IReadOnlyList<CursorPopupLabel> CursorLabels => _aliveCursorLabels;
@@ -54,6 +55,7 @@ namespace Content.Client.Popups
_uiManager, _uiManager,
_uiManager.GetUIController<PopupUIController>(), _uiManager.GetUIController<PopupUIController>(),
_examine, _examine,
_transform,
this)); this));
} }

View File

@@ -121,7 +121,10 @@ namespace Content.Client.Radiation.Overlays
private bool PulseQualifies(EntityUid pulseEntity, MapCoordinates currentEyeLoc) private bool PulseQualifies(EntityUid pulseEntity, MapCoordinates currentEyeLoc)
{ {
return _entityManager.GetComponent<TransformComponent>(pulseEntity).MapID == currentEyeLoc.MapId && _entityManager.GetComponent<TransformComponent>(pulseEntity).Coordinates.InRange(_entityManager, EntityCoordinates.FromMap(_entityManager, _entityManager.GetComponent<TransformComponent>(pulseEntity).ParentUid, currentEyeLoc), MaxDist); var transformComponent = _entityManager.GetComponent<TransformComponent>(pulseEntity);
var transformSystem = _entityManager.System<SharedTransformSystem>();
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) private sealed record RadiationShaderInstance(MapCoordinates CurrentMapCoords, float Range, TimeSpan Start, float Duration)

View File

@@ -16,6 +16,7 @@ namespace Content.Client.Sandbox
[Dependency] private readonly IMapManager _map = default!; [Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly IPlacementManager _placement = default!; [Dependency] private readonly IPlacementManager _placement = default!;
[Dependency] private readonly ContentEyeSystem _contentEye = default!; [Dependency] private readonly ContentEyeSystem _contentEye = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
private bool _sandboxEnabled; private bool _sandboxEnabled;
public bool SandboxAllowed { get; private set; } public bool SandboxAllowed { get; private set; }
@@ -108,7 +109,7 @@ namespace Content.Client.Sandbox
} }
// Try copy tile. // 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; return false;
if (_placement.Eraser) if (_placement.Eraser)

View File

@@ -238,7 +238,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. // 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) 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); _physics.ApplyLinearImpulse(uid, pos * moveForce, body: physics);
} }
else else

View File

@@ -22,8 +22,8 @@ namespace Content.Server.Chemistry.EntitySystems
[UsedImplicitly] [UsedImplicitly]
internal sealed class VaporSystem : EntitySystem internal sealed class VaporSystem : EntitySystem
{ {
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!; [Dependency] private readonly IPrototypeManager _protoManager = default!;
[Dependency] private readonly SharedMapSystem _map = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!; [Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
[Dependency] private readonly ThrowingSystem _throwing = default!; [Dependency] private readonly ThrowingSystem _throwing = default!;
@@ -115,7 +115,7 @@ namespace Content.Server.Chemistry.EntitySystems
{ {
vapor.ReactTimer = 0; vapor.ReactTimer = 0;
var tile = gridComp.GetTileRef(xform.Coordinates.ToVector2i(EntityManager, _mapManager)); var tile = _map.GetTileRef(xform.GridUid.Value, gridComp, xform.Coordinates);
foreach (var reagentQuantity in contents.Contents.ToArray()) foreach (var reagentQuantity in contents.Contents.ToArray())
{ {
if (reagentQuantity.Quantity == FixedPoint2.Zero) continue; if (reagentQuantity.Quantity == FixedPoint2.Zero) continue;

View File

@@ -46,7 +46,8 @@ namespace Content.Server.Construction.Conditions
if (transform.GridUid == null) if (transform.GridUid == null)
return false; return false;
var indices = transform.Coordinates.ToVector2i(entityManager, IoCManager.Resolve<IMapManager>()); var transformSys = entityManager.System<SharedTransformSystem>();
var indices = transform.Coordinates.ToVector2i(entityManager, IoCManager.Resolve<IMapManager>(), transformSys);
var lookup = entityManager.EntitySysManager.GetEntitySystem<EntityLookupSystem>(); var lookup = entityManager.EntitySysManager.GetEntitySystem<EntityLookupSystem>();
var entities = indices.GetEntitiesInTile(transform.GridUid.Value, LookupFlags.Approximate | LookupFlags.Static, lookup); var entities = indices.GetEntitiesInTile(transform.GridUid.Value, LookupFlags.Approximate | LookupFlags.Static, lookup);

View File

@@ -2,7 +2,6 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Content.Server.Construction.Components; using Content.Server.Construction.Components;
using Content.Server.Storage.EntitySystems;
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Construction; using Content.Shared.Construction;
using Content.Shared.Construction.Prototypes; using Content.Shared.Construction.Prototypes;
@@ -15,7 +14,6 @@ using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Inventory; using Content.Shared.Inventory;
using Content.Shared.Storage; using Content.Shared.Storage;
using Content.Shared.Tag;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Timing; using Robust.Shared.Timing;
@@ -30,8 +28,7 @@ namespace Content.Server.Construction
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!; [Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!; [Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly EntityLookupSystem _lookupSystem = default!; [Dependency] private readonly EntityLookupSystem _lookupSystem = default!;
[Dependency] private readonly StorageSystem _storageSystem = default!; [Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
// --- WARNING! LEGACY CODE AHEAD! --- // --- WARNING! LEGACY CODE AHEAD! ---
// This entire file contains the legacy code for initial construction. // This entire file contains the legacy code for initial construction.
@@ -465,7 +462,7 @@ namespace Content.Server.Construction
return; return;
} }
var mapPos = location.ToMap(EntityManager); var mapPos = location.ToMap(EntityManager, _transformSystem);
var predicate = GetPredicate(constructionPrototype.CanBuildInImpassable, mapPos); var predicate = GetPredicate(constructionPrototype.CanBuildInImpassable, mapPos);
if (!_interactionSystem.InRangeUnobstructed(user, mapPos, predicate: predicate)) if (!_interactionSystem.InRangeUnobstructed(user, mapPos, predicate: predicate))

View File

@@ -31,6 +31,7 @@ public sealed partial class DragonSystem : EntitySystem
[Dependency] private readonly RoleSystem _role = default!; [Dependency] private readonly RoleSystem _role = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!; [Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
private EntityQuery<CarpRiftsConditionComponent> _objQuery; private EntityQuery<CarpRiftsConditionComponent> _objQuery;
@@ -150,7 +151,7 @@ public sealed partial class DragonSystem : EntitySystem
// cant stack rifts near eachother // cant stack rifts near eachother
foreach (var (_, riftXform) in EntityQuery<DragonRiftComponent, TransformComponent>(true)) foreach (var (_, riftXform) in EntityQuery<DragonRiftComponent, TransformComponent>(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); _popup.PopupEntity(Loc.GetString("carp-rift-proximity", ("proximity", RiftRange)), uid, uid);
return; return;

View File

@@ -331,7 +331,7 @@ public sealed partial class ExplosionSystem : EntitySystem
CameraShake(iterationIntensity.Count * 4f, epicenter, totalIntensity); CameraShake(iterationIntensity.Count * 4f, epicenter, totalIntensity);
//For whatever bloody reason, sound system requires ENTITY coordinates. //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. // play sound.
// for the normal audio, we want everyone in pvs range // for the normal audio, we want everyone in pvs range

View File

@@ -386,7 +386,7 @@ namespace Content.Server.GameTicking
// Ideally engine would just spawn them on grid directly I guess? Right now grid traversal is handling it during // 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. // update which means we need to add a hack somewhere around it.
var spawn = _robustRandom.Pick(_possiblePositions); var spawn = _robustRandom.Pick(_possiblePositions);
var toMap = spawn.ToMap(EntityManager); var toMap = spawn.ToMap(EntityManager, _transform);
if (_mapManager.TryFindGridAt(toMap, out var gridUid, out _)) if (_mapManager.TryFindGridAt(toMap, out var gridUid, out _))
{ {

View File

@@ -34,6 +34,7 @@ namespace Content.Server.Guardian
[Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly BodySystem _bodySystem = default!; [Dependency] private readonly BodySystem _bodySystem = default!;
[Dependency] private readonly SharedContainerSystem _container = default!; [Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -324,7 +325,7 @@ namespace Content.Server.Guardian
if (!guardianComponent.GuardianLoose) if (!guardianComponent.GuardianLoose)
return; 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); RetractGuardian(hostUid, hostComponent, guardianUid, guardianComponent);
} }

View File

@@ -35,6 +35,7 @@ namespace Content.Server.Hands.Systems
[Dependency] private readonly VirtualItemSystem _virtualItemSystem = default!; [Dependency] private readonly VirtualItemSystem _virtualItemSystem = default!;
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!; [Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!; [Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly PullingSystem _pullingSystem = default!; [Dependency] private readonly PullingSystem _pullingSystem = default!;
[Dependency] private readonly ThrowingSystem _throwingSystem = default!; [Dependency] private readonly ThrowingSystem _throwingSystem = default!;
@@ -198,7 +199,7 @@ namespace Content.Server.Hands.Systems
throwEnt = splitStack.Value; throwEnt = splitStack.Value;
} }
var direction = coordinates.ToMapPos(EntityManager) - Transform(player).WorldPosition; var direction = coordinates.ToMapPos(EntityManager, _transformSystem) - Transform(player).WorldPosition;
if (direction == Vector2.Zero) if (direction == Vector2.Zero)
return true; return true;

View File

@@ -99,7 +99,7 @@ public sealed class SubdermalImplantSystem : SharedSubdermalImplantSystem
return; return;
var xform = Transform(ent); 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 // try to find a valid position to teleport to, teleport to whatever works if we can't
var targetCoords = new MapCoordinates(); var targetCoords = new MapCoordinates();

View File

@@ -167,7 +167,7 @@ public sealed class MagicSystem : EntitySystem
foreach (var pos in GetSpawnPositions(xform, ev.Pos)) foreach (var pos in GetSpawnPositions(xform, ev.Pos))
{ {
// If applicable, this ensures the projectile is parented to grid on spawn, instead of the map. // 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 _) var spawnCoords = _mapManager.TryFindGridAt(mapPos, out var gridUid, out _)
? pos.WithEntityId(gridUid, EntityManager) ? pos.WithEntityId(gridUid, EntityManager)
: new(_mapManager.GetMapEntityId(mapPos.MapId), mapPos.Position); : new(_mapManager.GetMapEntityId(mapPos.MapId), mapPos.Position);

View File

@@ -22,6 +22,6 @@ public sealed partial class CoordinatesInRangePrecondition : HTNPrecondition
if (!blackboard.TryGetValue<EntityCoordinates>(TargetKey, out var target, _entManager)) if (!blackboard.TryGetValue<EntityCoordinates>(TargetKey, out var target, _entManager))
return false; return false;
return coordinates.InRange(_entManager, target, blackboard.GetValueOrDefault<float>(RangeKey, _entManager)); return coordinates.InRange(_entManager, _entManager.System<SharedTransformSystem>(), target, blackboard.GetValueOrDefault<float>(RangeKey, _entManager));
} }
} }

View File

@@ -22,7 +22,7 @@ public sealed partial class CoordinatesNotInRangePrecondition : HTNPrecondition
if (!blackboard.TryGetValue<EntityCoordinates>(TargetKey, out var target, _entManager)) if (!blackboard.TryGetValue<EntityCoordinates>(TargetKey, out var target, _entManager))
return false; return false;
return !coordinates.InRange(_entManager, target, blackboard.GetValueOrDefault<float>(RangeKey, _entManager)); return !coordinates.InRange(_entManager, _entManager.System<SharedTransformSystem>(), target, blackboard.GetValueOrDefault<float>(RangeKey, _entManager));
} }
} }

View File

@@ -23,6 +23,6 @@ public sealed partial class TargetInRangePrecondition : HTNPrecondition
!_entManager.TryGetComponent<TransformComponent>(target, out var targetXform)) !_entManager.TryGetComponent<TransformComponent>(target, out var targetXform))
return false; return false;
return coordinates.InRange(_entManager, targetXform.Coordinates, blackboard.GetValueOrDefault<float>(RangeKey, _entManager)); return coordinates.InRange(_entManager, _entManager.System<SharedTransformSystem>(), targetXform.Coordinates, blackboard.GetValueOrDefault<float>(RangeKey, _entManager));
} }
} }

View File

@@ -405,7 +405,7 @@ namespace Content.Server.NPC.Pathfinding
return null; return null;
} }
var localPos = xform.InvWorldMatrix.Transform(coordinates.ToMapPos(EntityManager)); var localPos = xform.InvWorldMatrix.Transform(coordinates.ToMapPos(EntityManager, _transform));
var origin = GetOrigin(localPos); var origin = GetOrigin(localPos);
if (!TryGetChunk(origin, comp, out var chunk)) if (!TryGetChunk(origin, comp, out var chunk))

View File

@@ -36,6 +36,7 @@ namespace Content.Server.Pointing.EntitySystems
[Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly VisibilitySystem _visibilitySystem = default!; [Dependency] private readonly VisibilitySystem _visibilitySystem = default!;
[Dependency] private readonly SharedMindSystem _minds = default!; [Dependency] private readonly SharedMindSystem _minds = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!; [Dependency] private readonly ExamineSystemShared _examine = default!;
@@ -97,7 +98,7 @@ namespace Content.Server.Pointing.EntitySystems
{ {
if (HasComp<GhostComponent>(pointer)) if (HasComp<GhostComponent>(pointer))
{ {
return Transform(pointer).Coordinates.InRange(EntityManager, coordinates, 15); return Transform(pointer).Coordinates.InRange(EntityManager, _transform, coordinates, 15);
} }
else else
{ {
@@ -142,7 +143,7 @@ namespace Content.Server.Pointing.EntitySystems
return false; return false;
} }
var mapCoordsPointed = coordsPointed.ToMap(EntityManager); var mapCoordsPointed = coordsPointed.ToMap(EntityManager, _transform);
_rotateToFaceSystem.TryFaceCoordinates(player, mapCoordsPointed.Position); _rotateToFaceSystem.TryFaceCoordinates(player, mapCoordsPointed.Position);
var arrow = EntityManager.SpawnEntity("PointingArrow", coordsPointed); var arrow = EntityManager.SpawnEntity("PointingArrow", coordsPointed);
@@ -150,7 +151,7 @@ namespace Content.Server.Pointing.EntitySystems
if (TryComp<PointingArrowComponent>(arrow, out var pointing)) if (TryComp<PointingArrowComponent>(arrow, out var pointing))
{ {
if (TryComp(player, out TransformComponent? xformPlayer)) 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; pointing.EndTime = _gameTiming.CurTime + PointDuration;

View File

@@ -20,6 +20,7 @@ public sealed class SpecialRespawnSystem : SharedSpecialRespawnSystem
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!; [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
[Dependency] private readonly AtmosphereSystem _atmosphere = default!; [Dependency] private readonly AtmosphereSystem _atmosphere = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly TurfSystem _turf = default!; [Dependency] private readonly TurfSystem _turf = default!;
[Dependency] private readonly IChatManager _chat = default!; [Dependency] private readonly IChatManager _chat = default!;
@@ -129,11 +130,11 @@ public sealed class SpecialRespawnSystem : SharedSpecialRespawnSystem
private void Respawn(EntityUid oldEntity, string prototype, EntityCoordinates coords) private void Respawn(EntityUid oldEntity, string prototype, EntityCoordinates coords)
{ {
var entity = Spawn(prototype, 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)}"); _chat.SendAdminAlert($"{MetaData(oldEntity).EntityName} was deleted and was respawned as {ToPrettyString(entity)}");
} }
/// <summary> /// <summary>
/// Try to find a random safe tile on the supplied grid /// Try to find a random safe tile on the supplied grid
/// </summary> /// </summary>
/// <param name="targetGrid">The grid that you're looking for a safe tile on</param> /// <param name="targetGrid">The grid that you're looking for a safe tile on</param>

View File

@@ -18,13 +18,13 @@ namespace Content.Server.Singularity.EntitySystems;
/// </summary> /// </summary>
public sealed class GravityWellSystem : SharedGravityWellSystem public sealed class GravityWellSystem : SharedGravityWellSystem
{ {
#region Dependencies #region Dependencies
[Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IViewVariablesManager _vvManager = default!; [Dependency] private readonly IViewVariablesManager _vvManager = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly SharedTransformSystem _transform = default!;
#endregion Dependencies #endregion Dependencies
/// <summary> /// <summary>
/// The minimum range at which gravpulses will act. /// The minimum range at which gravpulses will act.
@@ -155,7 +155,7 @@ public sealed class GravityWellSystem : SharedGravityWellSystem
/// <param name="minRange">The minimum distance at which entities can be affected by the gravity pulse.</param> /// <param name="minRange">The minimum distance at which entities can be affected by the gravity pulse.</param>
/// <param name="baseMatrixDeltaV">The base velocity added to any entities within affected by the gravity pulse scaled by the displacement of those entities from the epicenter.</param> /// <param name="baseMatrixDeltaV">The base velocity added to any entities within affected by the gravity pulse scaled by the displacement of those entities from the epicenter.</param>
public void GravPulse(EntityCoordinates entityPos, float maxRange, float minRange, in Matrix3 baseMatrixDeltaV) 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);
/// <summary> /// <summary>
/// Greates a gravitational pulse, shoving around all entities within some distance of an epicenter. /// Greates a gravitational pulse, shoving around all entities within some distance of an epicenter.
@@ -166,7 +166,7 @@ public sealed class GravityWellSystem : SharedGravityWellSystem
/// <param name="baseRadialDeltaV">The base radial velocity that will be added to entities within range towards the center of the gravitational pulse.</param> /// <param name="baseRadialDeltaV">The base radial velocity that will be added to entities within range towards the center of the gravitational pulse.</param>
/// <param name="baseTangentialDeltaV">The base tangential velocity that will be added to entities within countrclockwise around the center of the gravitational pulse.</param> /// <param name="baseTangentialDeltaV">The base tangential velocity that will be added to entities within countrclockwise around the center of the gravitational pulse.</param>
public void GravPulse(EntityCoordinates entityPos, float maxRange, float minRange, float baseRadialDeltaV = 0.0f, float baseTangentialDeltaV = 0.0f) 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);
/// <summary> /// <summary>
/// Causes a gravitational pulse, shoving around all entities within some distance of an epicenter. /// Causes a gravitational pulse, shoving around all entities within some distance of an epicenter.

View File

@@ -2,12 +2,7 @@ using Content.Server.Physics.Components;
using Content.Server.Power.EntitySystems; using Content.Server.Power.EntitySystems;
using Content.Server.Singularity.Components; using Content.Server.Singularity.Components;
using Content.Shared.Singularity.Components; using Content.Shared.Singularity.Components;
using Content.Shared.Singularity.EntitySystems;
using Robust.Shared.Map; 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 Robust.Shared.Timing;
using System.Numerics; using System.Numerics;
@@ -18,8 +13,8 @@ namespace Content.Server.Singularity.EntitySystems;
/// </summary> /// </summary>
public sealed class SingularityAttractorSystem : EntitySystem public sealed class SingularityAttractorSystem : EntitySystem
{ {
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
/// <summary> /// <summary>
/// The minimum range at which the attraction will act. /// The minimum range at which the attraction will act.
@@ -69,7 +64,7 @@ public sealed class SingularityAttractorSystem : EntitySystem
attractor.LastPulseTime = _timing.CurTime; attractor.LastPulseTime = _timing.CurTime;
var mapPos = xform.Coordinates.ToMap(EntityManager); var mapPos = xform.Coordinates.ToMap(EntityManager, _transform);
if (mapPos == MapCoordinates.Nullspace) if (mapPos == MapCoordinates.Nullspace)
return; return;
@@ -77,7 +72,7 @@ public sealed class SingularityAttractorSystem : EntitySystem
var query = EntityQuery<SingularityComponent, RandomWalkComponent, TransformComponent>(); var query = EntityQuery<SingularityComponent, RandomWalkComponent, TransformComponent>();
foreach (var (singulo, walk, singuloXform) in query) 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) if (singuloMapPos.MapId != mapPos.MapId)
continue; continue;

View File

@@ -26,6 +26,7 @@ public sealed class BluespaceLockerSystem : EntitySystem
[Dependency] private readonly WeldableSystem _weldableSystem = default!; [Dependency] private readonly WeldableSystem _weldableSystem = default!;
[Dependency] private readonly LockSystem _lockSystem = default!; [Dependency] private readonly LockSystem _lockSystem = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!; [Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly ExplosionSystem _explosionSystem = default!; [Dependency] private readonly ExplosionSystem _explosionSystem = default!;
public override void Initialize() public override void Initialize()
@@ -386,7 +387,7 @@ public sealed class BluespaceLockerSystem : EntitySystem
switch (component.BehaviorProperties.DestroyType) switch (component.BehaviorProperties.DestroyType)
{ {
case BluespaceLockerDestroyType.Explode: case BluespaceLockerDestroyType.Explode:
_explosionSystem.QueueExplosion(uid.ToCoordinates().ToMap(EntityManager), _explosionSystem.QueueExplosion(uid.ToCoordinates().ToMap(EntityManager, _transformSystem),
ExplosionSystem.DefaultExplosionPrototypeId, 4, 1, 2, maxTileBreak: 0); ExplosionSystem.DefaultExplosionPrototypeId, 4, 1, 2, maxTileBreak: 0);
goto case BluespaceLockerDestroyType.Delete; goto case BluespaceLockerDestroyType.Delete;
case BluespaceLockerDestroyType.Delete: case BluespaceLockerDestroyType.Delete:

View File

@@ -9,6 +9,7 @@ namespace Content.Server.Worldgen.Systems.Carvers;
public sealed class NoiseRangeCarverSystem : EntitySystem public sealed class NoiseRangeCarverSystem : EntitySystem
{ {
[Dependency] private readonly NoiseIndexSystem _index = default!; [Dependency] private readonly NoiseIndexSystem _index = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
/// <inheritdoc /> /// <inheritdoc />
public override void Initialize() public override void Initialize()
@@ -19,7 +20,7 @@ public sealed class NoiseRangeCarverSystem : EntitySystem
private void OnPrePlaceDebris(EntityUid uid, NoiseRangeCarverComponent component, private void OnPrePlaceDebris(EntityUid uid, NoiseRangeCarverComponent component,
ref PrePlaceDebrisFeatureEvent args) 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); var val = _index.Evaluate(uid, component.NoiseChannel, coords);
foreach (var (low, high) in component.Ranges) foreach (var (low, high) in component.Ranges)

View File

@@ -19,8 +19,9 @@ namespace Content.Shared.Construction.Conditions
var entManager = IoCManager.Resolve<IEntityManager>(); var entManager = IoCManager.Resolve<IEntityManager>();
// get blueprint and user position // get blueprint and user position
var transformSystem = entManager.System<SharedTransformSystem>();
var userWorldPosition = entManager.GetComponent<TransformComponent>(user).WorldPosition; var userWorldPosition = entManager.GetComponent<TransformComponent>(user).WorldPosition;
var objWorldPosition = location.ToMap(entManager).Position; var objWorldPosition = location.ToMap(entManager, transformSystem).Position;
// find direction from user to blueprint // find direction from user to blueprint
var userToObject = (objWorldPosition - userWorldPosition); var userToObject = (objWorldPosition - userWorldPosition);

View File

@@ -220,7 +220,7 @@ namespace Content.Shared.Examine
{ {
var entMan = IoCManager.Resolve<IEntityManager>(); var entMan = IoCManager.Resolve<IEntityManager>();
var originPos = entMan.GetComponent<TransformComponent>(origin).MapPosition; var originPos = entMan.GetComponent<TransformComponent>(origin).MapPosition;
var otherPos = other.ToMap(entMan); var otherPos = other.ToMap(entMan, _transform);
return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker); return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
} }

View File

@@ -114,7 +114,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
&& (itemPos.Position - xform.MapPosition.Position).Length() <= MaxAnimationRange && (itemPos.Position - xform.MapPosition.Position).Length() <= MaxAnimationRange
&& MetaData(entity).VisibilityMask == MetaData(uid).VisibilityMask) // Don't animate aghost pickups. && 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); _storage.PlayPickupAnimation(entity, initialPosition, xform.Coordinates, itemXform.LocalRotation, uid);
} }
} }

View File

@@ -459,7 +459,7 @@ namespace Content.Shared.Interaction
return false; return false;
if (!HasComp<NoRotateOnInteractComponent>(user)) if (!HasComp<NoRotateOnInteractComponent>(user))
_rotateToFaceSystem.TryFaceCoordinates(user, coordinates.ToMapPos(EntityManager)); _rotateToFaceSystem.TryFaceCoordinates(user, coordinates.ToMapPos(EntityManager, _transform));
return true; return true;
} }
@@ -612,7 +612,7 @@ namespace Content.Shared.Interaction
Ignored combinedPredicate = e => e == origin || (predicate?.Invoke(e) ?? false); Ignored combinedPredicate = e => e == origin || (predicate?.Invoke(e) ?? false);
var inRange = true; var inRange = true;
MapCoordinates originPos = default; MapCoordinates originPos = default;
var targetPos = otherCoordinates.ToMap(EntityManager); var targetPos = otherCoordinates.ToMap(EntityManager, _transform);
Angle targetRot = default; Angle targetRot = default;
// So essentially: // So essentially:
@@ -785,7 +785,7 @@ namespace Content.Shared.Interaction
Ignored? predicate = null, Ignored? predicate = null,
bool popup = false) bool popup = false)
{ {
return InRangeUnobstructed(origin, other.ToMap(EntityManager), range, collisionMask, predicate, popup); return InRangeUnobstructed(origin, other.ToMap(EntityManager, _transform), range, collisionMask, predicate, popup);
} }
/// <summary> /// <summary>

View File

@@ -16,7 +16,7 @@ namespace Content.Shared.Spawning
SharedPhysicsSystem? physicsManager = null) SharedPhysicsSystem? physicsManager = null)
{ {
physicsManager ??= entityManager.System<SharedPhysicsSystem>(); physicsManager ??= entityManager.System<SharedPhysicsSystem>();
var mapCoordinates = coordinates.ToMap(entityManager); var mapCoordinates = coordinates.ToMap(entityManager, entityManager.System<SharedTransformSystem>());
return entityManager.SpawnIfUnobstructed(prototypeName, mapCoordinates, collisionLayer, box, physicsManager); return entityManager.SpawnIfUnobstructed(prototypeName, mapCoordinates, collisionLayer, box, physicsManager);
} }