From: Plykiya <58439124+Plykiya@users.noreply.github.com> Date: Sat, 13 Jul 2024 21:05:22 +0000 (-0700) Subject: Replace obsolete xform.ToMap() with xformSystem.ToMapCoordinates() (#30010) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=a03b88979e25a9778a30f30612790f6966369fca;p=space-station-14.git Replace obsolete xform.ToMap() with xformSystem.ToMapCoordinates() (#30010) * Get rid of a bunch of obsolete usages * position --------- Co-authored-by: plykiya --- diff --git a/Content.Client/Construction/ConstructionSystem.cs b/Content.Client/Construction/ConstructionSystem.cs index 453658bebf..889c992f7f 100644 --- a/Content.Client/Construction/ConstructionSystem.cs +++ b/Content.Client/Construction/ConstructionSystem.cs @@ -48,11 +48,11 @@ namespace Content.Client.Construction CommandBinds.Builder .Bind(ContentKeyFunctions.OpenCraftingMenu, - new PointerInputCmdHandler(HandleOpenCraftingMenu, outsidePrediction:true)) + new PointerInputCmdHandler(HandleOpenCraftingMenu, outsidePrediction: true)) .Bind(EngineKeyFunctions.Use, new PointerInputCmdHandler(HandleUse, outsidePrediction: true)) .Bind(ContentKeyFunctions.EditorFlipObject, - new PointerInputCmdHandler(HandleFlip, outsidePrediction:true)) + new PointerInputCmdHandler(HandleFlip, outsidePrediction: true)) .Register(); SubscribeLocalEvent(HandleConstructionGhostExamined); @@ -196,7 +196,7 @@ namespace Content.Client.Construction if (GhostPresent(loc)) return false; - var predicate = GetPredicate(prototype.CanBuildInImpassable, loc.ToMap(EntityManager, _transformSystem)); + var predicate = GetPredicate(prototype.CanBuildInImpassable, _transformSystem.ToMapCoordinates(loc)); if (!_examineSystem.InRangeUnOccluded(user, loc, 20f, predicate: predicate)) return false; diff --git a/Content.Client/ContextMenu/UI/EntityMenuUIController.cs b/Content.Client/ContextMenu/UI/EntityMenuUIController.cs index a60619baa3..0462c095ba 100644 --- a/Content.Client/ContextMenu/UI/EntityMenuUIController.cs +++ b/Content.Client/ContextMenu/UI/EntityMenuUIController.cs @@ -170,7 +170,7 @@ namespace Content.Client.ContextMenu.UI if (_combatMode.IsInCombatMode(args.Session?.AttachedEntity)) return false; - var coords = args.Coordinates.ToMap(_entityManager, _xform); + var coords = _xform.ToMapCoordinates(args.Coordinates); if (_verbSystem.TryGetEntityMenuEntities(coords, out var entities)) OpenRootMenu(entities); diff --git a/Content.Client/Gameplay/GameplayStateBase.cs b/Content.Client/Gameplay/GameplayStateBase.cs index 6236cd8e95..63cbfdb09c 100644 --- a/Content.Client/Gameplay/GameplayStateBase.cs +++ b/Content.Client/Gameplay/GameplayStateBase.cs @@ -104,7 +104,8 @@ namespace Content.Client.Gameplay public IEnumerable GetClickableEntities(EntityCoordinates coordinates) { - return GetClickableEntities(coordinates.ToMap(_entityManager, _entitySystemManager.GetEntitySystem())); + var transformSystem = _entitySystemManager.GetEntitySystem(); + return GetClickableEntities(transformSystem.ToMapCoordinates(coordinates)); } public IEnumerable GetClickableEntities(MapCoordinates coordinates) diff --git a/Content.Client/Movement/Systems/JetpackSystem.cs b/Content.Client/Movement/Systems/JetpackSystem.cs index b7f5e48821..e25300d44c 100644 --- a/Content.Client/Movement/Systems/JetpackSystem.cs +++ b/Content.Client/Movement/Systems/JetpackSystem.cs @@ -15,6 +15,7 @@ public sealed class JetpackSystem : SharedJetpackSystem [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly ClothingSystem _clothing = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; + [Dependency] private readonly SharedMapSystem _mapSystem = default!; public override void Initialize() { @@ -73,11 +74,11 @@ public sealed class JetpackSystem : SharedJetpackSystem var uidXform = Transform(uid); var coordinates = uidXform.Coordinates; - var gridUid = coordinates.GetGridUid(EntityManager); + var gridUid = _transform.GetGrid(coordinates); if (TryComp(gridUid, out var grid)) { - coordinates = new EntityCoordinates(gridUid.Value, grid.WorldToLocal(coordinates.ToMapPos(EntityManager, _transform))); + coordinates = new EntityCoordinates(gridUid.Value, _mapSystem.WorldToLocal(gridUid.Value, grid, _transform.ToMapCoordinates(coordinates).Position)); } else if (uidXform.MapUid != null) { diff --git a/Content.Client/NPC/PathfindingSystem.cs b/Content.Client/NPC/PathfindingSystem.cs index d3ae509152..0c72a8f99f 100644 --- a/Content.Client/NPC/PathfindingSystem.cs +++ b/Content.Client/NPC/PathfindingSystem.cs @@ -203,7 +203,7 @@ namespace Content.Client.NPC if (found || !_system.Breadcrumbs.TryGetValue(netGrid, out var crumbs) || !xformQuery.TryGetComponent(grid, out var gridXform)) continue; - var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(); + var (_, _, worldMatrix, invWorldMatrix) = _transformSystem.GetWorldPositionRotationMatrixWithInv(gridXform); var localAABB = invWorldMatrix.TransformBox(aabb.Enlarged(float.Epsilon - SharedPathfindingSystem.ChunkSize)); foreach (var chunk in crumbs) @@ -287,7 +287,7 @@ namespace Content.Client.NPC return; } - var invGridMatrix = gridXform.InvWorldMatrix; + var invGridMatrix = _transformSystem.GetInvWorldMatrix(gridXform); DebugPathPoly? nearest = null; foreach (var poly in tile) @@ -359,7 +359,7 @@ namespace Content.Client.NPC continue; } - var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(); + var (_, _, worldMatrix, invWorldMatrix) = _transformSystem.GetWorldPositionRotationMatrixWithInv(gridXform); worldHandle.SetTransform(worldMatrix); var localAABB = invWorldMatrix.TransformBox(aabb); @@ -419,7 +419,7 @@ namespace Content.Client.NPC !xformQuery.TryGetComponent(grid, out var gridXform)) continue; - var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(); + var (_, _, worldMatrix, invWorldMatrix) = _transformSystem.GetWorldPositionRotationMatrixWithInv(gridXform); worldHandle.SetTransform(worldMatrix); var localAABB = invWorldMatrix.TransformBox(aabb); @@ -458,7 +458,7 @@ namespace Content.Client.NPC !xformQuery.TryGetComponent(grid, out var gridXform)) continue; - var (_, _, worldMatrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(); + var (_, _, worldMatrix, invMatrix) = _transformSystem.GetWorldPositionRotationMatrixWithInv(gridXform); worldHandle.SetTransform(worldMatrix); var localAABB = invMatrix.TransformBox(aabb); @@ -483,7 +483,7 @@ namespace Content.Client.NPC if (neighborPoly.NetEntity != poly.GraphUid) { color = Color.Green; - var neighborMap = _entManager.GetCoordinates(neighborPoly).ToMap(_entManager, _transformSystem); + var neighborMap = _transformSystem.ToMapCoordinates(_entManager.GetCoordinates(neighborPoly)); if (neighborMap.MapId != args.MapId) continue; @@ -517,7 +517,7 @@ namespace Content.Client.NPC !xformQuery.TryGetComponent(grid, out var gridXform)) continue; - var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(); + var (_, _, worldMatrix, invWorldMatrix) = _transformSystem.GetWorldPositionRotationMatrixWithInv(gridXform); worldHandle.SetTransform(worldMatrix); var localAABB = invWorldMatrix.TransformBox(args.WorldBounds); @@ -544,7 +544,7 @@ namespace Content.Client.NPC if (!_entManager.TryGetComponent(_entManager.GetEntity(node.GraphUid), out var graphXform)) continue; - worldHandle.SetTransform(graphXform.WorldMatrix); + worldHandle.SetTransform(_transformSystem.GetWorldMatrix(graphXform)); worldHandle.DrawRect(node.Box, Color.Orange.WithAlpha(0.10f)); } } @@ -568,7 +568,7 @@ namespace Content.Client.NPC continue; matrix = graph; - worldHandle.SetTransform(graphXform.WorldMatrix); + worldHandle.SetTransform(_transformSystem.GetWorldMatrix(graphXform)); } worldHandle.DrawRect(node.Box, new Color(0f, cost / highestGScore, 1f - (cost / highestGScore), 0.10f)); diff --git a/Content.Client/Physics/JointVisualsOverlay.cs b/Content.Client/Physics/JointVisualsOverlay.cs index 09c02746e2..e0b3499a97 100644 --- a/Content.Client/Physics/JointVisualsOverlay.cs +++ b/Content.Client/Physics/JointVisualsOverlay.cs @@ -58,8 +58,8 @@ public sealed class JointVisualsOverlay : Overlay coordsA = coordsA.Offset(rotA.RotateVec(visuals.OffsetA)); coordsB = coordsB.Offset(rotB.RotateVec(visuals.OffsetB)); - var posA = coordsA.ToMapPos(_entManager, xformSystem); - var posB = coordsB.ToMapPos(_entManager, xformSystem); + var posA = xformSystem.ToMapCoordinates(coordsA).Position; + var posB = xformSystem.ToMapCoordinates(coordsB).Position; var diff = (posB - posA); var length = diff.Length(); diff --git a/Content.Client/Pinpointer/UI/NavMapControl.cs b/Content.Client/Pinpointer/UI/NavMapControl.cs index 3c99a18818..413b41c36a 100644 --- a/Content.Client/Pinpointer/UI/NavMapControl.cs +++ b/Content.Client/Pinpointer/UI/NavMapControl.cs @@ -228,8 +228,8 @@ public partial class NavMapControl : MapGridControl { if (!blip.Selectable) continue; - - var currentDistance = (blip.Coordinates.ToMapPos(EntManager, _transformSystem) - worldPosition).Length(); + + var currentDistance = (_transformSystem.ToMapCoordinates(blip.Coordinates).Position - worldPosition).Length(); if (closestDistance < currentDistance || currentDistance * MinimapScale > MaxSelectableDistance) continue; @@ -397,7 +397,7 @@ public partial class NavMapControl : MapGridControl { if (lit && value.Visible) { - var mapPos = coord.ToMap(EntManager, _transformSystem); + var mapPos = _transformSystem.ToMapCoordinates(coord); if (mapPos.MapId != MapId.Nullspace) { @@ -418,7 +418,7 @@ public partial class NavMapControl : MapGridControl if (blip.Texture == null) continue; - var mapPos = blip.Coordinates.ToMap(EntManager, _transformSystem); + var mapPos = _transformSystem.ToMapCoordinates(blip.Coordinates); if (mapPos.MapId != MapId.Nullspace) { @@ -535,7 +535,7 @@ public partial class NavMapControl : MapGridControl // East edge neighborData = 0; if (relativeTile.X != SharedNavMapSystem.ChunkSize - 1) - neighborData = chunk.TileData[i+SharedNavMapSystem.ChunkSize]; + neighborData = chunk.TileData[i + SharedNavMapSystem.ChunkSize]; else if (_navMap.Chunks.TryGetValue(chunkOrigin + Vector2i.Right, out neighborChunk)) neighborData = neighborChunk.TileData[i + SharedNavMapSystem.ChunkSize - SharedNavMapSystem.ArraySize]; @@ -548,7 +548,7 @@ public partial class NavMapControl : MapGridControl // South edge neighborData = 0; if (relativeTile.Y != 0) - neighborData = chunk.TileData[i-1]; + neighborData = chunk.TileData[i - 1]; else if (_navMap.Chunks.TryGetValue(chunkOrigin + Vector2i.Down, out neighborChunk)) neighborData = neighborChunk.TileData[i - 1 + SharedNavMapSystem.ChunkSize]; @@ -561,7 +561,7 @@ public partial class NavMapControl : MapGridControl // West edge neighborData = 0; if (relativeTile.X != 0) - neighborData = chunk.TileData[i-SharedNavMapSystem.ChunkSize]; + neighborData = chunk.TileData[i - SharedNavMapSystem.ChunkSize]; else if (_navMap.Chunks.TryGetValue(chunkOrigin + Vector2i.Left, out neighborChunk)) neighborData = neighborChunk.TileData[i - SharedNavMapSystem.ChunkSize + SharedNavMapSystem.ArraySize]; diff --git a/Content.Client/RCD/AlignRCDConstruction.cs b/Content.Client/RCD/AlignRCDConstruction.cs index d5425425a7..fcbe408a38 100644 --- a/Content.Client/RCD/AlignRCDConstruction.cs +++ b/Content.Client/RCD/AlignRCDConstruction.cs @@ -45,7 +45,7 @@ public sealed class AlignRCDConstruction : PlacementMode _unalignedMouseCoords = ScreenToCursorGrid(mouseScreen); MouseCoords = _unalignedMouseCoords.AlignWithClosestGridTile(SearchBoxSize, _entityManager, _mapManager); - var gridId = MouseCoords.GetGridUid(_entityManager); + var gridId = _transformSystem.GetGrid(MouseCoords); if (!_entityManager.TryGetComponent(gridId, out var mapGrid)) return; @@ -105,8 +105,8 @@ public sealed class AlignRCDConstruction : PlacementMode if (currentState is not GameplayStateBase screen) return false; - - var target = screen.GetClickedEntity(_unalignedMouseCoords.ToMap(_entityManager, _transformSystem)); + + var target = screen.GetClickedEntity(_transformSystem.ToMapCoordinates(_unalignedMouseCoords)); // Determine if the RCD operation is valid or not if (!_rcdSystem.IsRCDOperationStillValid(heldEntity.Value, rcd, mapGridData.Value, target, player.Value, false)) diff --git a/Content.Client/Sandbox/SandboxSystem.cs b/Content.Client/Sandbox/SandboxSystem.cs index 6a1129bb75..8a4c93fa35 100644 --- a/Content.Client/Sandbox/SandboxSystem.cs +++ b/Content.Client/Sandbox/SandboxSystem.cs @@ -17,6 +17,7 @@ namespace Content.Client.Sandbox [Dependency] private readonly IPlacementManager _placement = default!; [Dependency] private readonly ContentEyeSystem _contentEye = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; + [Dependency] private readonly SharedMapSystem _mapSystem = default!; private bool _sandboxEnabled; public bool SandboxAllowed { get; private set; } @@ -92,7 +93,7 @@ namespace Content.Client.Sandbox && EntityManager.TryGetComponent(uid, out MetaDataComponent? comp) && !comp.EntityDeleted) { - if (comp.EntityPrototype == null || comp.EntityPrototype.NoSpawn || comp.EntityPrototype.Abstract) + if (comp.EntityPrototype == null || comp.EntityPrototype.HideSpawnMenu || comp.EntityPrototype.Abstract) return false; if (_placement.Eraser) @@ -109,7 +110,8 @@ namespace Content.Client.Sandbox } // Try copy tile. - if (!_map.TryFindGridAt(coords.ToMap(EntityManager, _transform), out _, out var grid) || !grid.TryGetTileRef(coords, out var tileRef)) + + if (!_map.TryFindGridAt(_transform.ToMapCoordinates(coords), out var gridUid, out var grid) || !_mapSystem.TryGetTileRef(gridUid, grid, coords, out var tileRef)) return false; if (_placement.Eraser) diff --git a/Content.Client/Shuttles/Systems/ShuttleSystem.Console.cs b/Content.Client/Shuttles/Systems/ShuttleSystem.Console.cs index c134b7157c..eb9ec285f8 100644 --- a/Content.Client/Shuttles/Systems/ShuttleSystem.Console.cs +++ b/Content.Client/Shuttles/Systems/ShuttleSystem.Console.cs @@ -35,9 +35,9 @@ public sealed partial class ShuttleSystem switch (mapObj) { case ShuttleBeaconObject beacon: - return GetCoordinates(beacon.Coordinates).ToMap(EntityManager, XformSystem); + return XformSystem.ToMapCoordinates(GetCoordinates(beacon.Coordinates)); case ShuttleExclusionObject exclusion: - return GetCoordinates(exclusion.Coordinates).ToMap(EntityManager, XformSystem); + return XformSystem.ToMapCoordinates(GetCoordinates(exclusion.Coordinates)); case GridMapObject grid: var gridXform = Transform(grid.Entity); diff --git a/Content.Client/Shuttles/UI/ShuttleMapControl.xaml.cs b/Content.Client/Shuttles/UI/ShuttleMapControl.xaml.cs index 8bd4a338cb..53ad4a0b23 100644 --- a/Content.Client/Shuttles/UI/ShuttleMapControl.xaml.cs +++ b/Content.Client/Shuttles/UI/ShuttleMapControl.xaml.cs @@ -519,7 +519,7 @@ public sealed partial class ShuttleMapControl : BaseShuttleControl if (mapO is not ShuttleBeaconObject beacon) continue; - var beaconCoords = EntManager.GetCoordinates(beacon.Coordinates).ToMap(EntManager, _xformSystem); + var beaconCoords = _xformSystem.ToMapCoordinates(EntManager.GetCoordinates(beacon.Coordinates)); var position = Vector2.Transform(beaconCoords.Position, mapTransform); var localPos = ScalePosition(position with {Y = -position.Y}); diff --git a/Content.Client/Storage/Systems/StorageSystem.cs b/Content.Client/Storage/Systems/StorageSystem.cs index a74a118cd0..1e011f08f0 100644 --- a/Content.Client/Storage/Systems/StorageSystem.cs +++ b/Content.Client/Storage/Systems/StorageSystem.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using System.Numerics; using Content.Client.Animations; using Content.Shared.Hands; @@ -149,7 +149,7 @@ public sealed class StorageSystem : SharedStorageSystem return; } - var finalMapPos = finalCoords.ToMapPos(EntityManager, TransformSystem); + var finalMapPos = TransformSystem.ToMapCoordinates(finalCoords).Position; var finalPos = Vector2.Transform(finalMapPos, TransformSystem.GetInvWorldMatrix(initialCoords.EntityId)); _entityPickupAnimation.AnimateEntityPickup(item, initialCoords, finalPos, initialAngle); diff --git a/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs b/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs index eba4f21acb..7604d5f880 100644 --- a/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs +++ b/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs @@ -220,7 +220,7 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem return; } - var targetMap = coordinates.ToMap(EntityManager, TransformSystem); + var targetMap = TransformSystem.ToMapCoordinates(coordinates); if (targetMap.MapId != userXform.MapID) return; diff --git a/Content.Client/Weapons/Ranged/Systems/GunSystem.cs b/Content.Client/Weapons/Ranged/Systems/GunSystem.cs index 7134227767..840d1a9091 100644 --- a/Content.Client/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Client/Weapons/Ranged/Systems/GunSystem.cs @@ -176,7 +176,7 @@ public sealed partial class GunSystem : SharedGunSystem } // Define target coordinates relative to gun entity, so that network latency on moving grids doesn't fuck up the target location. - var coordinates = EntityCoordinates.FromMap(entity, mousePos, TransformSystem, EntityManager); + var coordinates = TransformSystem.ToCoordinates(entity, mousePos); NetEntity? target = null; if (_state.CurrentState is GameplayStateBase screen) @@ -200,7 +200,7 @@ public sealed partial class GunSystem : SharedGunSystem // Rather than splitting client / server for every ammo provider it's easier // to just delete the spawned entities. This is for programmer sanity despite the wasted perf. // This also means any ammo specific stuff can be grabbed as necessary. - var direction = fromCoordinates.ToMapPos(EntityManager, TransformSystem) - toCoordinates.ToMapPos(EntityManager, TransformSystem); + var direction = TransformSystem.ToMapCoordinates(fromCoordinates).Position - TransformSystem.ToMapCoordinates(toCoordinates).Position; var worldAngle = direction.ToAngle().Opposite(); foreach (var (ent, shootable) in ammo) @@ -383,6 +383,6 @@ public sealed partial class GunSystem : SharedGunSystem var uidPlayer = EnsureComp(gunUid); _animPlayer.Stop(gunUid, uidPlayer, "muzzle-flash-light"); - _animPlayer.Play((gunUid, uidPlayer), animTwo,"muzzle-flash-light"); + _animPlayer.Play((gunUid, uidPlayer), animTwo, "muzzle-flash-light"); } } diff --git a/Content.Server/Pointing/EntitySystems/PointingSystem.cs b/Content.Server/Pointing/EntitySystems/PointingSystem.cs index 9dc3b5e1e6..ca7791fb68 100644 --- a/Content.Server/Pointing/EntitySystems/PointingSystem.cs +++ b/Content.Server/Pointing/EntitySystems/PointingSystem.cs @@ -145,8 +145,7 @@ namespace Content.Server.Pointing.EntitySystems _popup.PopupEntity(Loc.GetString("pointing-system-try-point-cannot-reach"), player, player); return false; } - - var mapCoordsPointed = coordsPointed.ToMap(EntityManager, _transform); + var mapCoordsPointed = _transform.ToMapCoordinates(coordsPointed); _rotateToFaceSystem.TryFaceCoordinates(player, mapCoordsPointed.Position); var arrow = EntityManager.SpawnEntity("PointingArrow", coordsPointed); @@ -154,7 +153,7 @@ namespace Content.Server.Pointing.EntitySystems if (TryComp(arrow, out var pointing)) { if (TryComp(player, out TransformComponent? xformPlayer)) - pointing.StartPosition = EntityCoordinates.FromMap(arrow, xformPlayer.Coordinates.ToMap(EntityManager, _transform), _transform).Position; + pointing.StartPosition = _transform.ToCoordinates((player, xformPlayer), _transform.ToMapCoordinates(xformPlayer.Coordinates)).Position; pointing.EndTime = _gameTiming.CurTime + PointDuration; diff --git a/Content.Shared/Actions/SharedActionsSystem.cs b/Content.Shared/Actions/SharedActionsSystem.cs index 0e302f1e02..49c137468e 100644 --- a/Content.Shared/Actions/SharedActionsSystem.cs +++ b/Content.Shared/Actions/SharedActionsSystem.cs @@ -427,7 +427,7 @@ public abstract class SharedActionsSystem : EntitySystem } var entityCoordinatesTarget = GetCoordinates(netCoordinatesTarget); - _rotateToFaceSystem.TryFaceCoordinates(user, entityCoordinatesTarget.ToMapPos(EntityManager, _transformSystem)); + _rotateToFaceSystem.TryFaceCoordinates(user, _transformSystem.ToMapCoordinates(entityCoordinatesTarget).Position); if (!ValidateWorldTarget(user, entityCoordinatesTarget, (actionEnt, worldAction))) return;