From 48b61f6bcc942d7ac92b9584d3075b135167db5f Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Sun, 6 Sep 2020 16:11:53 +0200 Subject: [PATCH] Replace every usage of GridCoordinates with EntityCoordinates (#2021) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update RobustToolbox * Transition direct type usages * More updates * Fix invalid use of to map * Update RobustToolbox * Fix dropping items * Rename name usages of "GridCoordinates" to "EntityCoordinates" * Revert "Update RobustToolbox" This reverts commit 9f334a17c5908ded0043a63158bb671e4aa3f346. * Revert "Update RobustToolbox" This reverts commit 3a9c8cfa3606fa501aa84407796d2ad920853a09. # Conflicts: # RobustToolbox * Fix cursed IMapGrid method usage. * GridTileLookupTest now uses EntityCoordinates Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com> Co-authored-by: Víctor Aguilera Puerto --- Content.Client/ClientNotifyManager.cs | 12 ++-- .../ConstructionPlacementHijack.cs | 2 +- .../Components/LowWallComponent.cs | 2 +- .../Movement/PlayerInputMoverComponent.cs | 2 +- .../EntitySystems/AI/ClientAiDebugSystem.cs | 2 +- .../EntitySystems/ConstructionSystem.cs | 10 ++-- .../EntitySystems/DoAfter/DoAfterGui.cs | 2 +- .../EntitySystems/DoAfter/DoAfterSystem.cs | 4 +- .../EntitySystems/ExamineSystem.cs | 2 +- .../EntitySystems/MeleeWeaponSystem.cs | 4 +- .../GameObjects/EntitySystems/VerbSystem.cs | 18 ++---- Content.Client/State/GameScreenBase.cs | 9 ++- Content.Client/Utility/RangeExtensions.cs | 6 +- Content.IntegrationTests/DummyGameTicker.cs | 8 +-- .../Tests/AI/AiControllerTest.cs | 4 +- .../Tests/Atmos/AtmosHelpersTest.cs | 25 +++++--- Content.IntegrationTests/Tests/BuckleTest.cs | 3 +- Content.IntegrationTests/Tests/EntityTest.cs | 13 +++-- .../Tests/Fluids/PuddleTest.cs | 12 ++-- .../Tests/GravityGridTest.cs | 3 +- .../Tests/GridTileLookupTest.cs | 12 ++-- .../Tests/Interaction/InRangeUnobstructed.cs | 28 ++++----- .../Tests/MindEntityDeletionTest.cs | 3 +- .../Tests/Networking/ConnectTest.cs | 2 +- Content.IntegrationTests/Tests/PowerTest.cs | 19 +++--- .../Combat/Melee/SwingMeleeWeaponOperator.cs | 4 +- .../Combat/Melee/UnarmedCombatOperator.cs | 4 +- .../Inventory/InteractWithEntityOperator.cs | 2 +- .../Operators/Movement/MoveToGridOperator.cs | 8 +-- .../AI/Utility/Actions/Idle/WanderAndWait.cs | 4 +- .../Actions/Test/MoveRightAndLeftTen.cs | 6 +- .../Movement/TargetDistanceCon.cs | 4 +- Content.Server/AI/Utils/Visibility.cs | 16 ++--- .../States/Clothing/NearbyClothingState.cs | 2 +- .../Combat/Nearby/NearbyMeleeWeapons.cs | 2 +- .../States/Mobs/NearbyBodiesState.cs | 2 +- .../States/Mobs/NearbyPlayersState.cs | 2 +- .../States/Nutrition/NearbyDrinkState.cs | 2 +- .../States/Nutrition/NearbyFoodState.cs | 2 +- Content.Server/Administration/WarpCommand.cs | 22 ++++--- Content.Server/Atmos/AtmosHelpers.cs | 14 +++-- Content.Server/Atmos/GasSprayerComponent.cs | 2 +- Content.Server/Atmos/GasVaporComponent.cs | 10 ++-- .../Atmos/HighPressureMovementController.cs | 8 +-- .../Atmos/IGridAtmosphereComponent.cs | 2 +- Content.Server/Atmos/TileAtmosphere.cs | 5 +- Content.Server/Body/BodyPart.cs | 4 +- Content.Server/Chat/ChatManager.cs | 6 +- .../ExplosionReactionEffect.cs | 2 +- Content.Server/Explosions/ExplosionHelper.cs | 27 ++++++--- .../ActionBlocking/CuffableComponent.cs | 2 +- .../Components/Atmos/AirtightComponent.cs | 6 +- .../Components/Atmos/BarotraumaComponent.cs | 7 ++- .../Components/Atmos/GasAnalyzerComponent.cs | 14 +++-- .../Atmos/GridAtmosphereComponent.cs | 4 +- .../Piping/Scrubbers/BaseSiphonComponent.cs | 8 ++- .../Atmos/Piping/Vents/BaseVentComponent.cs | 8 ++- .../Body/Respiratory/LungComponent.cs | 4 +- .../Components/Buckle/BuckleComponent.cs | 4 +- .../Components/Cargo/CargoConsoleComponent.cs | 2 +- .../Chemistry/ChemMasterComponent.cs | 8 +-- .../Components/Chemistry/SolutionComponent.cs | 2 +- .../Components/Chemistry/VaporComponent.cs | 2 +- .../Components/Damage/BreakableComponent.cs | 2 +- .../Damage/DestructibleComponent.cs | 4 +- .../Components/Damage/RuinableComponent.cs | 2 +- .../Disposal/DisposalHolderComponent.cs | 2 +- .../Disposal/DisposalTubeComponent.cs | 2 +- .../Explosion/ExplosiveComponent.cs | 2 +- .../Explosion/FlashExplosiveComponent.cs | 2 +- .../ExtinguisherCabinetComponent.cs | 2 +- .../ExtinguisherCabinetFilledComponent.cs | 2 +- .../Components/Fluids/CanSpillComponent.cs | 2 +- .../Components/Fluids/PuddleComponent.cs | 4 +- .../Components/Fluids/SpillExtensions.cs | 11 ++-- .../Components/Fluids/SprayComponent.cs | 4 +- .../Components/GUI/HandsComponent.cs | 14 ++--- .../Components/GUI/InventoryComponent.cs | 2 +- .../Interactable/HandheldLightComponent.cs | 4 +- .../Interactable/TilePryingComponent.cs | 10 ++-- .../Components/Interactable/ToolCommands.cs | 2 +- .../Interactable/WelderComponent.cs | 4 +- .../Items/FloorTileItemComponent.cs | 2 +- .../Components/Items/RCD/RCDComponent.cs | 6 +- .../Items/Storage/Fill/CustodialClosetFill.cs | 2 +- .../Fill/EmergencyClosetFillComponent.cs | 2 +- .../Items/Storage/Fill/MedkitFillComponent.cs | 2 +- .../Storage/Fill/StorageFillComponent.cs | 2 +- .../Storage/Fill/ToolLockerFillComponent.cs | 2 +- .../Fill/ToolboxElectricalFillComponent.cs | 2 +- .../Fill/ToolboxEmergencyFillComponent.cs | 2 +- .../Storage/Fill/ToolboxGoldFillComponent.cs | 2 +- .../Fill/UtilityBeltClothingFillComponent.cs | 2 +- .../Components/Items/Storage/ItemComponent.cs | 10 +--- .../Items/Storage/ServerStorageComponent.cs | 2 +- .../Components/Kitchen/MicrowaveComponent.cs | 2 +- .../MachineLinking/SignalReceiverComponent.cs | 2 +- .../SignalTransmitterComponent.cs | 2 +- .../Markers/ConditionalSpawnerComponent.cs | 2 +- .../Markers/TimedSpawnerComponent.cs | 2 +- .../Markers/TrashSpawnerComponent.cs | 4 +- .../Components/Mobs/MindComponent.cs | 5 +- .../Movement/AiControllerComponent.cs | 2 +- .../Movement/PlayerInputMoverComponent.cs | 2 +- .../Movement/ServerPortalComponent.cs | 8 +-- .../Movement/ServerTeleporterComponent.cs | 17 +++--- .../Movement/ShuttleControllerComponent.cs | 2 +- .../NodeContainer/NodeGroups/AMENodeGroup.cs | 2 +- .../Components/Nutrition/FoodComponent.cs | 2 +- .../Nutrition/FoodContainerComponent.cs | 2 +- .../Components/PDA/PDAComponent.cs | 2 +- .../Pointing/RoguePointingArrowComponent.cs | 4 +- .../Components/PottedPlantHideComponent.cs | 2 +- .../Components/Power/AME/AMEPartComponent.cs | 2 +- .../PowerProviderComponent.cs | 2 +- .../PowerReceiverComponent.cs | 10 ++-- .../PoweredLightComponent.cs | 4 +- .../Components/Power/WirePlacerComponent.cs | 2 +- .../Projectiles/HitscanComponent.cs | 16 ++--- .../Projectiles/ProjectileComponent.cs | 4 +- .../Projectiles/ThrownItemComponent.cs | 4 +- .../Components/Research/LatheComponent.cs | 2 +- .../Rotatable/FlippableComponent.cs | 2 +- .../Components/Stack/StackComponent.cs | 4 +- .../StationEvents/RadiationPulseComponent.cs | 2 +- .../VendingMachineComponent.cs | 2 +- .../Components/Weapon/FlashableComponent.cs | 4 +- .../Components/Weapon/Melee/FlashComponent.cs | 4 +- .../Weapon/Melee/MeleeWeaponComponent.cs | 12 ++-- .../Weapon/Melee/StunbatonComponent.cs | 18 +++--- .../Ranged/Ammunition/AmmoBoxComponent.cs | 2 +- .../Weapon/Ranged/Ammunition/AmmoComponent.cs | 8 ++- .../Ammunition/RangedMagazineComponent.cs | 4 +- .../Ranged/Ammunition/SpeedLoaderComponent.cs | 2 +- .../Barrels/BoltActionBarrelComponent.cs | 16 ++--- .../Ranged/Barrels/PumpBarrelComponent.cs | 8 +-- .../Ranged/Barrels/RevolverBarrelComponent.cs | 10 ++-- .../Barrels/ServerBatteryBarrelComponent.cs | 14 ++--- .../Barrels/ServerMagazineBarrelComponent.cs | 20 +++---- .../Barrels/ServerRangedBarrelComponent.cs | 20 +++---- .../Ranged/ServerRangedWeaponComponent.cs | 4 +- .../Accessible/AiReachableSystem.cs | 13 +++-- .../AI/Pathfinding/PathfindingSystem.cs | 12 ++-- .../ServerPathfindingDebugSystem.cs | 12 ++-- .../AI/Steering/AiSteeringSystem.cs | 55 +++++++++--------- .../Steering/EntityTargetSteeringRequest.cs | 12 ++-- .../AI/Steering/GridTargetSteeringRequest.cs | 11 ++-- .../AI/Steering/IAiSteeringRequest.cs | 10 ++-- .../Atmos/GasTileOverlaySystem.cs | 2 +- .../EntitySystems/Click/InteractionSystem.cs | 44 +++++++------- .../EntitySystems/ConstructionSystem.cs | 11 ++-- .../EntitySystems/DoAfter/DoAfter.cs | 18 +++--- .../GameObjects/EntitySystems/HandsSystem.cs | 23 ++++---- .../EntitySystems/ListeningSystem.cs | 11 ++-- .../GameObjects/EntitySystems/MoverSystem.cs | 18 ++++-- .../EntitySystems/PointingSystem.cs | 12 ++-- .../EntitySystems/SignalLinkerSystem.cs | 7 +-- Content.Server/GameTicking/GameTicker.cs | 29 +++++----- .../GameTicking/GameTickerCommands.cs | 4 +- Content.Server/GlobalVerbs/PointingVerb.cs | 4 +- Content.Server/GlobalVerbs/PullingVerb.cs | 2 +- .../Components/Items/IHandsComponent.cs | 4 +- .../Interfaces/GameTicking/IGameTicker.cs | 6 +- Content.Server/Observer/Ghost.cs | 2 +- Content.Server/PDA/PDAUplinkManager.cs | 2 +- Content.Server/Placement/SpawnHelpers.cs | 2 +- Content.Server/Sandbox/SandboxManager.cs | 2 +- Content.Server/ServerNotifyManager.cs | 2 +- .../StationEvents/RadiationStorm.cs | 17 +++--- Content.Server/Throw/ThrowHelper.cs | 21 ++++--- Content.Server/Utility/NotifyExtensions.cs | 2 +- .../Components/Movement/IMoverComponent.cs | 2 +- .../SharedPlayerInputMoverComponent.cs | 2 +- .../Movement/SharedTeleporterComponent.cs | 4 +- .../Components/SharedDoAfterComponent.cs | 22 +++---- .../EntitySystemMessages/DragDropMessage.cs | 4 +- .../GameObjects/EntitySystems/ActSystem.cs | 4 +- .../EntitySystems/SharedConstructionSystem.cs | 4 +- .../EntitySystems/SharedInteractionSystem.cs | 8 +-- .../EntitySystems/SharedMoverSystem.cs | 3 +- .../Components/Interaction/IAfterInteract.cs | 6 +- .../Components/Interaction/IAttack.cs | 7 +-- .../Components/Interaction/IDragDrop.cs | 4 +- .../Components/Interaction/IInteractUsing.cs | 6 +- .../Components/Interaction/ILand.cs | 8 +-- .../Components/Interaction/IRangedInteract.cs | 6 +- .../Interfaces/ISharedNotifyManager.cs | 4 +- Content.Shared/Maps/TurfHelpers.cs | 29 ++++++---- Content.Shared/Physics/ConveyedController.cs | 2 +- Content.Shared/Physics/MoverController.cs | 2 +- Content.Shared/Physics/Pull/PullController.cs | 16 ++--- Content.Shared/Physics/SlipController.cs | 2 +- Content.Shared/SharedNotifyManager.cs | 6 +- .../Utility/EntityCoordinatesExtensions.cs | 58 +++++++++++++++++++ .../Utility/SharedDirectionExtensions.cs | 7 +-- .../Utility/SharedRangeExtensions.cs | 49 ++++++++-------- 196 files changed, 780 insertions(+), 676 deletions(-) create mode 100644 Content.Shared/Utility/EntityCoordinatesExtensions.cs diff --git a/Content.Client/ClientNotifyManager.cs b/Content.Client/ClientNotifyManager.cs index 4481945b21..ccb4ae3a03 100644 --- a/Content.Client/ClientNotifyManager.cs +++ b/Content.Client/ClientNotifyManager.cs @@ -49,7 +49,7 @@ namespace Content.Client private void DoNotifyCoordinates(MsgDoNotifyCoordinates message) { - PopupMessage(_eyeManager.WorldToScreen(message.Coordinates), message.Message); + PopupMessage(_eyeManager.CoordinatesToScreen(message.Coordinates), message.Message); } private void DoNotifyEntity(MsgDoNotifyEntity message) @@ -59,27 +59,27 @@ namespace Content.Client return; } - PopupMessage(_eyeManager.WorldToScreen(entity.Transform.GridPosition), message.Message); + PopupMessage(_eyeManager.CoordinatesToScreen(entity.Transform.Coordinates), message.Message); } public override void PopupMessage(IEntity source, IEntity viewer, string message) { - if (viewer != _playerManager.LocalPlayer.ControlledEntity) + if (viewer != _playerManager.LocalPlayer?.ControlledEntity) { return; } - PopupMessage(_eyeManager.WorldToScreen(source.Transform.GridPosition), message); + PopupMessage(_eyeManager.CoordinatesToScreen(source.Transform.Coordinates), message); } - public override void PopupMessage(GridCoordinates coordinates, IEntity viewer, string message) + public override void PopupMessage(EntityCoordinates coordinates, IEntity viewer, string message) { if (viewer != _playerManager.LocalPlayer.ControlledEntity) { return; } - PopupMessage(_eyeManager.WorldToScreen(coordinates), message); + PopupMessage(_eyeManager.CoordinatesToScreen(coordinates), message); } public override void PopupMessageCursor(IEntity viewer, string message) diff --git a/Content.Client/Construction/ConstructionPlacementHijack.cs b/Content.Client/Construction/ConstructionPlacementHijack.cs index bd4431f751..f601ba5927 100644 --- a/Content.Client/Construction/ConstructionPlacementHijack.cs +++ b/Content.Client/Construction/ConstructionPlacementHijack.cs @@ -20,7 +20,7 @@ namespace Content.Client.Construction } /// - public override bool HijackPlacementRequest(GridCoordinates coordinates) + public override bool HijackPlacementRequest(EntityCoordinates coordinates) { if (_prototype != null) { diff --git a/Content.Client/GameObjects/Components/LowWallComponent.cs b/Content.Client/GameObjects/Components/LowWallComponent.cs index 29554f3cd8..4ee6e93a1e 100644 --- a/Content.Client/GameObjects/Components/LowWallComponent.cs +++ b/Content.Client/GameObjects/Components/LowWallComponent.cs @@ -37,7 +37,7 @@ namespace Content.Client.GameObjects.Components { base.Startup(); - _overlayEntity = Owner.EntityManager.SpawnEntity("LowWallOverlay", Owner.Transform.GridPosition); + _overlayEntity = Owner.EntityManager.SpawnEntity("LowWallOverlay", Owner.Transform.Coordinates); _overlayEntity.Transform.AttachParent(Owner); _overlaySprite = _overlayEntity.GetComponent(); diff --git a/Content.Client/GameObjects/Components/Movement/PlayerInputMoverComponent.cs b/Content.Client/GameObjects/Components/Movement/PlayerInputMoverComponent.cs index fcdde82ef8..84af66d532 100644 --- a/Content.Client/GameObjects/Components/Movement/PlayerInputMoverComponent.cs +++ b/Content.Client/GameObjects/Components/Movement/PlayerInputMoverComponent.cs @@ -9,7 +9,7 @@ namespace Content.Client.GameObjects.Components.Movement [ComponentReference(typeof(IMoverComponent))] public class PlayerInputMoverComponent : SharedPlayerInputMoverComponent { - public override GridCoordinates LastPosition { get; set; } + public override EntityCoordinates LastPosition { get; set; } public override float StepSoundDistance { get; set; } } } diff --git a/Content.Client/GameObjects/EntitySystems/AI/ClientAiDebugSystem.cs b/Content.Client/GameObjects/EntitySystems/AI/ClientAiDebugSystem.cs index 688e3116aa..70ab6690bb 100644 --- a/Content.Client/GameObjects/EntitySystems/AI/ClientAiDebugSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/AI/ClientAiDebugSystem.cs @@ -52,7 +52,7 @@ namespace Content.Client.GameObjects.EntitySystems.AI continue; } - var (x, y) = _eyeManager.WorldToScreen(entity.Transform.GridPosition).Position; + var (x, y) = _eyeManager.CoordinatesToScreen(entity.Transform.Coordinates).Position; var offsetPosition = new Vector2(x - panel.Width / 2, y - panel.Height - 50f); panel.Visible = true; diff --git a/Content.Client/GameObjects/EntitySystems/ConstructionSystem.cs b/Content.Client/GameObjects/EntitySystems/ConstructionSystem.cs index f079208d85..9003bf3ffe 100644 --- a/Content.Client/GameObjects/EntitySystems/ConstructionSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/ConstructionSystem.cs @@ -150,7 +150,7 @@ namespace Content.Client.GameObjects.EntitySystems /// /// Creates a construction ghost at the given location. /// - public void SpawnGhost(ConstructionPrototype prototype, GridCoordinates loc, Direction dir) + public void SpawnGhost(ConstructionPrototype prototype, EntityCoordinates loc, Direction dir) { if (GhostPresent(loc)) { @@ -174,11 +174,11 @@ namespace Content.Client.GameObjects.EntitySystems /// /// Checks if any construction ghosts are present at the given position /// - private bool GhostPresent(GridCoordinates loc) + private bool GhostPresent(EntityCoordinates loc) { - foreach (KeyValuePair ghost in _ghosts) + foreach (var ghost in _ghosts) { - if (ghost.Value.Owner.Transform.GridPosition.Equals(loc)) + if (ghost.Value.Owner.Transform.Coordinates.Equals(loc)) { return true; } @@ -191,7 +191,7 @@ namespace Content.Client.GameObjects.EntitySystems { var ghost = _ghosts[ghostId]; var transform = ghost.Owner.Transform; - var msg = new TryStartStructureConstructionMessage(transform.GridPosition, ghost.Prototype.ID, transform.LocalRotation, ghostId); + var msg = new TryStartStructureConstructionMessage(transform.Coordinates, ghost.Prototype.ID, transform.LocalRotation, ghostId); RaiseNetworkEvent(msg); } diff --git a/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterGui.cs b/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterGui.cs index a6724c0f6a..4be9d551ea 100644 --- a/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterGui.cs +++ b/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterGui.cs @@ -159,7 +159,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter } // Set position ready for 2nd+ frames. - _playerPosition = _eyeManager.WorldToScreen(AttachedEntity.Transform.GridPosition); + _playerPosition = _eyeManager.CoordinatesToScreen(AttachedEntity.Transform.Coordinates); LayoutContainer.SetPosition(this, new Vector2(_playerPosition.X - Width / 2, _playerPosition.Y - Height - 30.0f)); if (_firstDraw) diff --git a/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterSystem.cs b/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterSystem.cs index cc0337a941..65327d4811 100644 --- a/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/DoAfter/DoAfterSystem.cs @@ -98,7 +98,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter return; } - var userGrid = _player.Transform.GridPosition; + var userGrid = _player.Transform.Coordinates; // Check cancellations / finishes foreach (var (id, doAfter) in doAfters) @@ -133,7 +133,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter { var targetEntity = _entityManager.GetEntity(doAfter.TargetUid); - if (targetEntity.Transform.GridPosition != doAfter.TargetGrid) + if (targetEntity.Transform.Coordinates != doAfter.TargetGrid) { doAfterComponent.Cancel(id, currentTime); continue; diff --git a/Content.Client/GameObjects/EntitySystems/ExamineSystem.cs b/Content.Client/GameObjects/EntitySystems/ExamineSystem.cs index a9e4fb4187..e26a5b658e 100644 --- a/Content.Client/GameObjects/EntitySystems/ExamineSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/ExamineSystem.cs @@ -50,7 +50,7 @@ namespace Content.Client.GameObjects.EntitySystems base.Shutdown(); } - private bool HandleExamine(ICommonSession session, GridCoordinates coords, EntityUid uid) + private bool HandleExamine(ICommonSession session, EntityCoordinates coords, EntityUid uid) { if (!uid.IsValid() || !_entityManager.TryGetEntity(uid, out var examined)) { diff --git a/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs b/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs index 83a8950ba1..d337fef5b5 100644 --- a/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs @@ -52,7 +52,7 @@ namespace Content.Client.GameObjects.EntitySystems var lunge = attacker.EnsureComponent(); lunge.SetData(msg.Angle); - var entity = EntityManager.SpawnEntity(weaponArc.Prototype, attacker.Transform.GridPosition); + var entity = EntityManager.SpawnEntity(weaponArc.Prototype, attacker.Transform.Coordinates); entity.Transform.LocalRotation = msg.Angle; var weaponArcAnimation = entity.GetComponent(); @@ -68,7 +68,7 @@ namespace Content.Client.GameObjects.EntitySystems { EffectSprite = sourceSprite.BaseRSI.Path.ToString(), RsiState = sourceSprite.LayerGetState(0).Name, - Coordinates = attacker.Transform.GridPosition, + Coordinates = attacker.Transform.Coordinates, Color = Vector4.Multiply(new Vector4(255, 255, 255, 125), 1.0f), ColorDelta = Vector4.Multiply(new Vector4(0, 0, 0, -10), 1.0f), Velocity = msg.Angle.ToVec(), diff --git a/Content.Client/GameObjects/EntitySystems/VerbSystem.cs b/Content.Client/GameObjects/EntitySystems/VerbSystem.cs index 7f26504431..aab42dc0af 100644 --- a/Content.Client/GameObjects/EntitySystems/VerbSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/VerbSystem.cs @@ -1,22 +1,18 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Reflection; using System.Threading; using Content.Client.State; using Content.Client.UserInterface; using Content.Client.Utility; using Content.Shared.GameObjects.EntitySystemMessages; -using Content.Shared.GameObjects.EntitySystems; using Content.Shared.GameObjects.Verbs; using Content.Shared.Input; -using Content.Shared.Physics; using JetBrains.Annotations; using Robust.Client.GameObjects.EntitySystems; using Robust.Client.Graphics; using Robust.Client.Graphics.Drawing; using Robust.Client.Interfaces.GameObjects.Components; -using Robust.Client.Interfaces.Graphics.ClientEye; using Robust.Client.Interfaces.Input; using Robust.Client.Interfaces.ResourceManagement; using Robust.Client.Interfaces.State; @@ -27,12 +23,9 @@ using Robust.Client.UserInterface.Controls; using Robust.Client.Utility; using Robust.Shared.Containers; using Robust.Shared.GameObjects; -using Robust.Shared.GameObjects.Systems; using Robust.Shared.Input; using Robust.Shared.Input.Binding; using Robust.Shared.Interfaces.GameObjects; -using Robust.Shared.Interfaces.Map; -using Robust.Shared.Interfaces.Physics; using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; using Robust.Shared.Log; @@ -53,7 +46,6 @@ namespace Content.Client.GameObjects.EntitySystems [Dependency] private readonly IItemSlotManager _itemSlotManager = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!; - [Dependency] private readonly IMapManager _mapManager = default!; private EntityList _currentEntityList; private VerbPopup _currentVerbListRoot; @@ -67,7 +59,7 @@ namespace Content.Client.GameObjects.EntitySystems public override void Initialize() { base.Initialize(); - + SubscribeNetworkEvent(FillEntityPopup); IoCManager.InjectDependencies(this); @@ -118,10 +110,10 @@ namespace Content.Client.GameObjects.EntitySystems { return false; } - - var mapCoordinates = args.Coordinates.ToMap(_mapManager); + + var mapCoordinates = args.Coordinates.ToMap(_entityManager); var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; - + if (playerEntity == null || !TryGetContextEntities(playerEntity, mapCoordinates, out var entities)) { return false; @@ -469,7 +461,7 @@ namespace Content.Client.GameObjects.EntitySystems var funcId = _master._inputManager.NetworkBindMap.KeyFunctionID(args.Function); var message = new FullInputCmdMessage(_master._gameTiming.CurTick, _master._gameTiming.TickFraction, funcId, BoundKeyState.Down, - _entity.Transform.GridPosition, + _entity.Transform.Coordinates, args.PointerLocation, _entity.Uid); // client side command handlers will always be sent the local player session. diff --git a/Content.Client/State/GameScreenBase.cs b/Content.Client/State/GameScreenBase.cs index 4caf83d86d..915e5e4937 100644 --- a/Content.Client/State/GameScreenBase.cs +++ b/Content.Client/State/GameScreenBase.cs @@ -3,7 +3,6 @@ using System.Collections.Immutable; using System.Linq; using Content.Client.GameObjects.Components; using Content.Client.Utility; -using Content.Shared.Utility; using Robust.Client.GameObjects.EntitySystems; using Robust.Client.Interfaces.GameObjects; using Robust.Client.Interfaces.Graphics.ClientEye; @@ -111,9 +110,9 @@ namespace Content.Client.State return entitiesUnderPosition.Count > 0 ? entitiesUnderPosition[0] : null; } - public IList GetEntitiesUnderPosition(GridCoordinates coordinates) + public IList GetEntitiesUnderPosition(EntityCoordinates coordinates) { - return GetEntitiesUnderPosition(coordinates.ToMap(MapManager)); + return GetEntitiesUnderPosition(coordinates.ToMap(EntityManager)); } public IList GetEntitiesUnderPosition(MapCoordinates coordinates) @@ -152,7 +151,7 @@ namespace Content.Client.State /// state manager to use to get the current game screen /// coordinates to check /// the entities under the position, empty list if none found - public static IList GetEntitiesUnderPosition(IStateManager stateManager, GridCoordinates coordinates) + public static IList GetEntitiesUnderPosition(IStateManager stateManager, EntityCoordinates coordinates) { if (stateManager.CurrentState is GameScreenBase gameScreenBase) { @@ -184,7 +183,7 @@ namespace Content.Client.State var transx = x.clicked.Transform; var transy = y.clicked.Transform; - val = transx.GridPosition.Y.CompareTo(transy.GridPosition.Y); + val = transx.Coordinates.Y.CompareTo(transy.Coordinates.Y); if (val != 0) { return val; diff --git a/Content.Client/Utility/RangeExtensions.cs b/Content.Client/Utility/RangeExtensions.cs index c69eb91f6c..326d0735de 100644 --- a/Content.Client/Utility/RangeExtensions.cs +++ b/Content.Client/Utility/RangeExtensions.cs @@ -56,15 +56,15 @@ namespace Content.Client.Utility public static bool InRangeUnobstructed( this LocalPlayer origin, - GridCoordinates other, + EntityCoordinates other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, Ignored predicate = null, bool ignoreInsideBlocker = false, bool popup = false) { - var mapManager = IoCManager.Resolve(); - var otherPosition = other.ToMap(mapManager); + var entityManager = IoCManager.Resolve(); + var otherPosition = other.ToMap(entityManager); return origin.InRangeUnobstructed(otherPosition, range, collisionMask, predicate, ignoreInsideBlocker, popup); diff --git a/Content.IntegrationTests/DummyGameTicker.cs b/Content.IntegrationTests/DummyGameTicker.cs index e6b7e2a3ef..09f669139e 100644 --- a/Content.IntegrationTests/DummyGameTicker.cs +++ b/Content.IntegrationTests/DummyGameTicker.cs @@ -58,10 +58,10 @@ namespace Content.IntegrationTests { } - public GridCoordinates GetLateJoinSpawnPoint() => GridCoordinates.InvalidGrid; - public GridCoordinates GetJobSpawnPoint(string jobId) => GridCoordinates.InvalidGrid; - public GridCoordinates GetObserverSpawnPoint() => GridCoordinates.InvalidGrid; - + public EntityCoordinates GetLateJoinSpawnPoint() => EntityCoordinates.Invalid; + public EntityCoordinates GetJobSpawnPoint(string jobId) => EntityCoordinates.Invalid; + public EntityCoordinates GetObserverSpawnPoint() => EntityCoordinates.Invalid; + public void EquipStartingGear(IEntity entity, StartingGearPrototype startingGear) { } diff --git a/Content.IntegrationTests/Tests/AI/AiControllerTest.cs b/Content.IntegrationTests/Tests/AI/AiControllerTest.cs index 12517b2092..6f9efaaa5b 100644 --- a/Content.IntegrationTests/Tests/AI/AiControllerTest.cs +++ b/Content.IntegrationTests/Tests/AI/AiControllerTest.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Content.Server.GameObjects.Components.Movement; +using Content.Shared.Utility; using NUnit.Framework; using Robust.Server.AI; using Robust.Shared.GameObjects; @@ -50,7 +51,7 @@ namespace Content.IntegrationTests.Tests.AI if (!comps.ContainsKey("AiController")) continue; - var aiEntity = entityManager.SpawnEntity(entity.ID, new GridCoordinates(new Vector2(0, 0), grid.Index)); + var aiEntity = entityManager.SpawnEntity(entity.ID, grid.ToCoordinates()); var aiController = aiEntity.GetComponent(); Assert.That(processorNames.Contains(aiController.LogicName), $"Could not find valid processor named {aiController.LogicName} on entity {entity.ID}"); } @@ -58,6 +59,5 @@ namespace Content.IntegrationTests.Tests.AI await server.WaitIdleAsync(); } - } } diff --git a/Content.IntegrationTests/Tests/Atmos/AtmosHelpersTest.cs b/Content.IntegrationTests/Tests/Atmos/AtmosHelpersTest.cs index 844198ce66..28dff11b83 100644 --- a/Content.IntegrationTests/Tests/Atmos/AtmosHelpersTest.cs +++ b/Content.IntegrationTests/Tests/Atmos/AtmosHelpersTest.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using Content.Server.Atmos; using NUnit.Framework; +using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Map; namespace Content.IntegrationTests.Tests.Atmos @@ -10,17 +11,23 @@ namespace Content.IntegrationTests.Tests.Atmos public class AtmosHelpersTest : ContentIntegrationTest { [Test] - public async Task GetTileAtmosphereGridCoordinatesNullTest() + public async Task GetTileAtmosphereEntityCoordinatesNullTest() { var server = StartServerDummyTicker(); + await server.WaitIdleAsync(); + + var entityManager = server.ResolveDependency(); + server.Assert(() => { Assert.DoesNotThrow(() => { - var atmosphere = default(GridCoordinates).GetTileAtmosphere(); + var atmosphere1 = default(EntityCoordinates).GetTileAtmosphere(); + var atmosphere2 = default(EntityCoordinates).GetTileAtmosphere(entityManager); - Assert.Null(atmosphere); + Assert.Null(atmosphere1); + Assert.Null(atmosphere2); }); }); @@ -28,7 +35,7 @@ namespace Content.IntegrationTests.Tests.Atmos } [Test] - public async Task GetTileAirGridCoordinatesNullTest() + public async Task GetTileAirEntityCoordinatesNullTest() { var server = StartServerDummyTicker(); @@ -36,7 +43,7 @@ namespace Content.IntegrationTests.Tests.Atmos { Assert.DoesNotThrow(() => { - var air = default(GridCoordinates).GetTileAir(); + var air = default(EntityCoordinates).GetTileAir(); Assert.Null(air); }); @@ -46,7 +53,7 @@ namespace Content.IntegrationTests.Tests.Atmos } [Test] - public async Task TryGetTileAtmosphereGridCoordinatesNullTest() + public async Task TryGetTileAtmosphereEntityCoordinatesNullTest() { var server = StartServerDummyTicker(); @@ -54,7 +61,7 @@ namespace Content.IntegrationTests.Tests.Atmos { Assert.DoesNotThrow(() => { - var hasAtmosphere = default(GridCoordinates).TryGetTileAtmosphere(out var atmosphere); + var hasAtmosphere = default(EntityCoordinates).TryGetTileAtmosphere(out var atmosphere); Assert.False(hasAtmosphere); Assert.Null(atmosphere); @@ -65,7 +72,7 @@ namespace Content.IntegrationTests.Tests.Atmos } [Test] - public async Task TryGetTileTileAirGridCoordinatesNullTest() + public async Task TryGetTileTileAirEntityCoordinatesNullTest() { var server = StartServerDummyTicker(); @@ -73,7 +80,7 @@ namespace Content.IntegrationTests.Tests.Atmos { Assert.DoesNotThrow(() => { - var hasAir = default(GridCoordinates).TryGetTileAir(out var air); + var hasAir = default(EntityCoordinates).TryGetTileAir(out var air); Assert.False(hasAir); Assert.Null(air); diff --git a/Content.IntegrationTests/Tests/BuckleTest.cs b/Content.IntegrationTests/Tests/BuckleTest.cs index 93836aa903..d1fd3f7746 100644 --- a/Content.IntegrationTests/Tests/BuckleTest.cs +++ b/Content.IntegrationTests/Tests/BuckleTest.cs @@ -7,6 +7,7 @@ using Content.Shared.Damage; using Content.Shared.GameObjects.Components.Buckle; using Content.Shared.GameObjects.Components.Damage; using Content.Shared.GameObjects.EntitySystems; +using Content.Shared.Utility; using NUnit.Framework; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Map; @@ -193,7 +194,7 @@ namespace Content.IntegrationTests.Tests var entityManager = IoCManager.Resolve(); var gridId = new GridId(1); var grid = mapManager.CreateGrid(mapId, gridId); - var coordinates = new GridCoordinates((0, 0), gridId); + var coordinates = grid.GridEntityId.ToCoordinates(); var tileManager = IoCManager.Resolve(); var tileId = tileManager["underplating"].TileId; var tile = new Tile(tileId); diff --git a/Content.IntegrationTests/Tests/EntityTest.cs b/Content.IntegrationTests/Tests/EntityTest.cs index 1409b8029f..67857a6aab 100644 --- a/Content.IntegrationTests/Tests/EntityTest.cs +++ b/Content.IntegrationTests/Tests/EntityTest.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Content.Shared.Utility; using NUnit.Framework; using Robust.Server.Interfaces.Timing; using Robust.Shared.GameObjects; @@ -52,7 +53,7 @@ namespace Content.IntegrationTests.Tests var tileDefinition = tileDefinitionManager["underplating"]; var tile = new Tile(tileDefinition.TileId); - var coordinates = new GridCoordinates(0, 0, gridId); + var coordinates = grid.ToCoordinates(); grid.SetTile(coordinates, tile); @@ -61,7 +62,7 @@ namespace Content.IntegrationTests.Tests server.Assert(() => { - var testLocation = new GridCoordinates(new Vector2(0, 0), grid); + var testLocation = grid.ToCoordinates(); //Generate list of non-abstract prototypes to test foreach (var prototype in prototypeMan.EnumeratePrototypes()) @@ -160,7 +161,7 @@ namespace Content.IntegrationTests.Tests var tileDefinition = tileDefinitionManager["underplating"]; var tile = new Tile(tileDefinition.TileId); - var coordinates = new GridCoordinates(0, 0, gridId); + var coordinates = grid.ToCoordinates(); grid.SetTile(coordinates, tile); @@ -169,7 +170,7 @@ namespace Content.IntegrationTests.Tests server.Assert(() => { - var testLocation = new GridCoordinates(new Vector2(0, 0), grid); + var testLocation = grid.ToCoordinates(); foreach (var type in componentFactory.AllRegisteredTypes) { @@ -255,7 +256,7 @@ namespace Content.IntegrationTests.Tests var tileDefinition = tileDefinitionManager["underplating"]; var tile = new Tile(tileDefinition.TileId); - var coordinates = new GridCoordinates(0, 0, gridId); + var coordinates = grid.ToCoordinates(); grid.SetTile(coordinates, tile); @@ -300,7 +301,7 @@ namespace Content.IntegrationTests.Tests { foreach (var distinct in distinctComponents) { - var testLocation = new GridCoordinates(new Vector2(0, 0), grid); + var testLocation = grid.ToCoordinates(); var entity = entityManager.SpawnEntity("AllComponentsOneEntityDeleteTestEntity", testLocation); Assert.That(entity.Initialized); diff --git a/Content.IntegrationTests/Tests/Fluids/PuddleTest.cs b/Content.IntegrationTests/Tests/Fluids/PuddleTest.cs index 4333444c65..adb8b8677c 100644 --- a/Content.IntegrationTests/Tests/Fluids/PuddleTest.cs +++ b/Content.IntegrationTests/Tests/Fluids/PuddleTest.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using Content.Server.GameObjects.Components.Fluids; using Content.Shared.Chemistry; +using Content.Shared.Utility; using NUnit.Framework; using Robust.Server.Interfaces.Timing; using Robust.Shared.Interfaces.Map; @@ -23,7 +24,7 @@ namespace Content.IntegrationTests.Tests.Fluids var pauseManager = server.ResolveDependency(); var tileDefinitionManager = server.ResolveDependency(); - GridCoordinates coordinates = default; + EntityCoordinates coordinates = default; // Build up test environment server.Post(() => @@ -42,7 +43,7 @@ namespace Content.IntegrationTests.Tests.Fluids var tileDefinition = tileDefinitionManager["underplating"]; var tile = new Tile(tileDefinition.TileId); - coordinates = new GridCoordinates(0, 0, gridId); + coordinates = grid.ToCoordinates(); grid.SetTile(coordinates, tile); @@ -69,6 +70,7 @@ namespace Content.IntegrationTests.Tests.Fluids await server.WaitIdleAsync(); var mapManager = server.ResolveDependency(); var pauseManager = server.ResolveDependency(); + IMapGrid grid = null; // Build up test environment server.Post(() => @@ -79,9 +81,9 @@ namespace Content.IntegrationTests.Tests.Fluids var gridId = new GridId(1); - if (!mapManager.GridExists(gridId)) + if (!mapManager.TryGetGrid(gridId, out grid)) { - mapManager.CreateGrid(mapId, gridId); + grid = mapManager.CreateGrid(mapId, gridId); } }); @@ -90,7 +92,7 @@ namespace Content.IntegrationTests.Tests.Fluids server.Assert(() => { var gridId = new GridId(1); - var coordinates = new GridCoordinates(0, 0, gridId); + var coordinates = grid.ToCoordinates(); var solution = new Solution("water", ReagentUnit.New(20)); var puddle = solution.SpillAt(coordinates, "PuddleSmear"); Assert.Null(puddle); diff --git a/Content.IntegrationTests/Tests/GravityGridTest.cs b/Content.IntegrationTests/Tests/GravityGridTest.cs index 82c694b26a..30a51e0491 100644 --- a/Content.IntegrationTests/Tests/GravityGridTest.cs +++ b/Content.IntegrationTests/Tests/GravityGridTest.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using Content.Server.GameObjects.Components.Gravity; using Content.Server.GameObjects.Components.Power.ApcNetComponents; +using Content.Shared.Utility; using NUnit.Framework; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Map; @@ -37,7 +38,7 @@ namespace Content.IntegrationTests.Tests var entityMan = IoCManager.Resolve(); - generator = entityMan.SpawnEntity("GravityGenerator", new GridCoordinates(new Vector2(0, 0), grid2.Index)); + generator = entityMan.SpawnEntity("GravityGenerator", grid2.ToCoordinates()); Assert.That(generator.HasComponent()); Assert.That(generator.HasComponent()); var generatorComponent = generator.GetComponent(); diff --git a/Content.IntegrationTests/Tests/GridTileLookupTest.cs b/Content.IntegrationTests/Tests/GridTileLookupTest.cs index e59794fcca..137c6d7041 100644 --- a/Content.IntegrationTests/Tests/GridTileLookupTest.cs +++ b/Content.IntegrationTests/Tests/GridTileLookupTest.cs @@ -31,7 +31,7 @@ namespace Content.IntegrationTests.Tests List entities; var mapOne = mapManager.CreateMap(); var gridOne = mapManager.CreateGrid(mapOne); - + var tileDefinition = tileDefinitionManager["underplating"]; var underplating = new Tile(tileDefinition.TileId); gridOne.SetTile(new MapIndices(0, 0), underplating); @@ -45,8 +45,8 @@ namespace Content.IntegrationTests.Tests entities = tileLookup.GetEntitiesIntersecting(gridOne.Index, new MapIndices(1000, 1000)).ToList(); Assert.That(entities.Count, Is.EqualTo(0)); - var entityOne = entityManager.SpawnEntity("HumanMob_Content", new GridCoordinates(Vector2.Zero, gridOne)); - entityManager.SpawnEntity("HumanMob_Content", new GridCoordinates(Vector2.One, gridOne)); + var entityOne = entityManager.SpawnEntity("HumanMob_Content", new EntityCoordinates(gridOne.GridEntityId, Vector2.Zero)); + entityManager.SpawnEntity("HumanMob_Content", new EntityCoordinates(gridOne.GridEntityId, Vector2.One)); var entityTiles = tileLookup.GetIndices(entityOne); Assert.That(entityTiles.Count, Is.EqualTo(2)); @@ -54,11 +54,11 @@ namespace Content.IntegrationTests.Tests entities = tileLookup.GetEntitiesIntersecting(entityOne).ToList(); // Includes station entity Assert.That(entities.Count, Is.EqualTo(3)); - + // Both dummies should be in each corner of the 0,0 tile but only one dummy intersects -1,-1 entities = tileLookup.GetEntitiesIntersecting(gridOne.Index, new MapIndices(-1, -1)).ToList(); Assert.That(entities.Count, Is.EqualTo(1)); - + entities = tileLookup.GetEntitiesIntersecting(gridOne.Index, new MapIndices(0, 0)).ToList(); Assert.That(entities.Count, Is.EqualTo(2)); }); @@ -66,4 +66,4 @@ namespace Content.IntegrationTests.Tests await server.WaitIdleAsync(); } } -} \ No newline at end of file +} diff --git a/Content.IntegrationTests/Tests/Interaction/InRangeUnobstructed.cs b/Content.IntegrationTests/Tests/Interaction/InRangeUnobstructed.cs index 6ff7cfba99..c9d4186d09 100644 --- a/Content.IntegrationTests/Tests/Interaction/InRangeUnobstructed.cs +++ b/Content.IntegrationTests/Tests/Interaction/InRangeUnobstructed.cs @@ -41,7 +41,7 @@ namespace Content.IntegrationTests.Tests.Interaction IEntity other = null; IContainer container = null; IComponent component = null; - GridCoordinates gridCoordinates = default; + EntityCoordinates entityCoordinates = default; MapCoordinates mapCoordinates = default; server.Assert(() => @@ -53,7 +53,7 @@ namespace Content.IntegrationTests.Tests.Interaction other = entityManager.SpawnEntity(HumanId, coordinates); container = ContainerManagerComponent.Ensure("InRangeUnobstructedTestOtherContainer", other); component = other.Transform; - gridCoordinates = other.Transform.GridPosition; + entityCoordinates = other.Transform.Coordinates; mapCoordinates = other.Transform.MapPosition; }); @@ -73,9 +73,9 @@ namespace Content.IntegrationTests.Tests.Interaction Assert.True(origin.InRangeUnobstructed(container)); Assert.True(container.InRangeUnobstructed(origin)); - // Entity <-> GridCoordinates - Assert.True(origin.InRangeUnobstructed(gridCoordinates)); - Assert.True(gridCoordinates.InRangeUnobstructed(origin)); + // Entity <-> EntityCoordinates + Assert.True(origin.InRangeUnobstructed(entityCoordinates)); + Assert.True(entityCoordinates.InRangeUnobstructed(origin)); // Entity <-> MapCoordinates Assert.True(origin.InRangeUnobstructed(mapCoordinates)); @@ -97,9 +97,9 @@ namespace Content.IntegrationTests.Tests.Interaction Assert.True(origin.InRangeUnobstructed(container)); Assert.True(container.InRangeUnobstructed(origin)); - // Entity <-> GridCoordinates - Assert.True(origin.InRangeUnobstructed(gridCoordinates)); - Assert.True(gridCoordinates.InRangeUnobstructed(origin)); + // Entity <-> EntityCoordinates + Assert.True(origin.InRangeUnobstructed(entityCoordinates)); + Assert.True(entityCoordinates.InRangeUnobstructed(origin)); // Entity <-> MapCoordinates Assert.True(origin.InRangeUnobstructed(mapCoordinates)); @@ -121,9 +121,9 @@ namespace Content.IntegrationTests.Tests.Interaction Assert.False(origin.InRangeUnobstructed(container)); Assert.False(container.InRangeUnobstructed(origin)); - // Entity <-> GridCoordinates - Assert.False(origin.InRangeUnobstructed(gridCoordinates)); - Assert.False(gridCoordinates.InRangeUnobstructed(origin)); + // Entity <-> EntityCoordinates + Assert.False(origin.InRangeUnobstructed(entityCoordinates)); + Assert.False(entityCoordinates.InRangeUnobstructed(origin)); // Entity <-> MapCoordinates Assert.False(origin.InRangeUnobstructed(mapCoordinates)); @@ -144,9 +144,9 @@ namespace Content.IntegrationTests.Tests.Interaction Assert.True(origin.InRangeUnobstructed(container, InteractionRangeDivided15Times3)); Assert.True(container.InRangeUnobstructed(origin, InteractionRangeDivided15Times3)); - // Entity <-> GridCoordinates - Assert.True(origin.InRangeUnobstructed(gridCoordinates, InteractionRangeDivided15Times3)); - Assert.True(gridCoordinates.InRangeUnobstructed(origin, InteractionRangeDivided15Times3)); + // Entity <-> EntityCoordinates + Assert.True(origin.InRangeUnobstructed(entityCoordinates, InteractionRangeDivided15Times3)); + Assert.True(entityCoordinates.InRangeUnobstructed(origin, InteractionRangeDivided15Times3)); // Entity <-> MapCoordinates Assert.True(origin.InRangeUnobstructed(mapCoordinates, InteractionRangeDivided15Times3)); diff --git a/Content.IntegrationTests/Tests/MindEntityDeletionTest.cs b/Content.IntegrationTests/Tests/MindEntityDeletionTest.cs index acbe780035..14efdeb9fb 100644 --- a/Content.IntegrationTests/Tests/MindEntityDeletionTest.cs +++ b/Content.IntegrationTests/Tests/MindEntityDeletionTest.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using Content.Server.Mobs; using Content.Server.Players; +using Content.Shared.Utility; using NUnit.Framework; using Robust.Server.Interfaces.GameObjects; using Robust.Server.Interfaces.Player; @@ -128,7 +129,7 @@ namespace Content.IntegrationTests.Tests mapMan.CreateNewMapEntity(MapId.Nullspace); - playerEnt = entMgr.SpawnEntity(null, new GridCoordinates(Vector2.Zero, grid.Index)); + playerEnt = entMgr.SpawnEntity(null, grid.ToCoordinates()); mind = new Mind(player.SessionId); player.ContentData().Mind = mind; diff --git a/Content.IntegrationTests/Tests/Networking/ConnectTest.cs b/Content.IntegrationTests/Tests/Networking/ConnectTest.cs index 984bcccb8e..1bf135cc82 100644 --- a/Content.IntegrationTests/Tests/Networking/ConnectTest.cs +++ b/Content.IntegrationTests/Tests/Networking/ConnectTest.cs @@ -50,7 +50,7 @@ namespace Content.IntegrationTests.Tests.Networking var lastSvEntity = svEntityManager.GetEntities().Last(); var lastClEntity = clEntityManager.GetEntity(lastSvEntity.Uid); - Assert.That(lastClEntity.Transform.GridPosition, Is.EqualTo(lastSvEntity.Transform.GridPosition)); + Assert.That(lastClEntity.Transform.Coordinates, Is.EqualTo(lastSvEntity.Transform.Coordinates)); } } } diff --git a/Content.IntegrationTests/Tests/PowerTest.cs b/Content.IntegrationTests/Tests/PowerTest.cs index 5b41142b7d..8d9e997c5e 100644 --- a/Content.IntegrationTests/Tests/PowerTest.cs +++ b/Content.IntegrationTests/Tests/PowerTest.cs @@ -8,6 +8,7 @@ using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; using System.Threading.Tasks; +using Content.Shared.Utility; namespace Content.IntegrationTests.Tests { @@ -30,9 +31,9 @@ namespace Content.IntegrationTests.Tests mapMan.CreateMap(new MapId(1)); var grid = mapMan.CreateGrid(new MapId(1)); - var generatorEnt = entityMan.SpawnEntity("DebugGenerator", new GridCoordinates(new Vector2(0, 0), grid.Index)); - var consumerEnt1 = entityMan.SpawnEntity("DebugConsumer", new GridCoordinates(new Vector2(0, 1), grid.Index)); - var consumerEnt2 = entityMan.SpawnEntity("DebugConsumer", new GridCoordinates(new Vector2(0, 2), grid.Index)); + var generatorEnt = entityMan.SpawnEntity("DebugGenerator", grid.ToCoordinates()); + var consumerEnt1 = entityMan.SpawnEntity("DebugConsumer", grid.ToCoordinates(0, 1)); + var consumerEnt2 = entityMan.SpawnEntity("DebugConsumer", grid.ToCoordinates(0, 2)); Assert.That(generatorEnt.TryGetComponent(out supplier)); Assert.That(consumerEnt1.TryGetComponent(out consumer1)); @@ -74,9 +75,9 @@ namespace Content.IntegrationTests.Tests mapMan.CreateMap(new MapId(1)); var grid = mapMan.CreateGrid(new MapId(1)); - var generatorEnt = entityMan.SpawnEntity("DebugGenerator", new GridCoordinates(new Vector2(0, 0), grid.Index)); - var substationEnt = entityMan.SpawnEntity("DebugSubstation", new GridCoordinates(new Vector2(0, 1), grid.Index)); - var apcEnt = entityMan.SpawnEntity("DebugApc", new GridCoordinates(new Vector2(0, 2), grid.Index)); + var generatorEnt = entityMan.SpawnEntity("DebugGenerator", grid.ToCoordinates()); + var substationEnt = entityMan.SpawnEntity("DebugSubstation", grid.ToCoordinates(0, 1)); + var apcEnt = entityMan.SpawnEntity("DebugApc", grid.ToCoordinates(0, 2)); Assert.That(generatorEnt.TryGetComponent(out var generatorSupplier)); @@ -120,9 +121,9 @@ namespace Content.IntegrationTests.Tests mapMan.CreateMap(new MapId(1)); var grid = mapMan.CreateGrid(new MapId(1)); - var apcEnt = entityMan.SpawnEntity("DebugApc", new GridCoordinates(new Vector2(0, 0), grid.Index)); - var apcExtensionEnt = entityMan.SpawnEntity("ApcExtensionCable", new GridCoordinates(new Vector2(0, 1), grid.Index)); - var powerReceiverEnt = entityMan.SpawnEntity("DebugPowerReceiver", new GridCoordinates(new Vector2(0, 2), grid.Index)); + var apcEnt = entityMan.SpawnEntity("DebugApc", grid.ToCoordinates(0, 0)); + var apcExtensionEnt = entityMan.SpawnEntity("ApcExtensionCable", grid.ToCoordinates(0, 1)); + var powerReceiverEnt = entityMan.SpawnEntity("DebugPowerReceiver", grid.ToCoordinates(0, 2)); Assert.That(apcEnt.TryGetComponent(out var apc)); Assert.That(apcExtensionEnt.TryGetComponent(out var provider)); diff --git a/Content.Server/AI/Operators/Combat/Melee/SwingMeleeWeaponOperator.cs b/Content.Server/AI/Operators/Combat/Melee/SwingMeleeWeaponOperator.cs index d9c6ce5383..4d57b08519 100644 --- a/Content.Server/AI/Operators/Combat/Melee/SwingMeleeWeaponOperator.cs +++ b/Content.Server/AI/Operators/Combat/Melee/SwingMeleeWeaponOperator.cs @@ -66,7 +66,7 @@ namespace Content.Server.AI.Operators.Combat.Melee var meleeWeapon = hands.GetActiveHand.Owner; meleeWeapon.TryGetComponent(out MeleeWeaponComponent meleeWeaponComponent); - if ((_target.Transform.GridPosition.Position - _owner.Transform.GridPosition.Position).Length > + if ((_target.Transform.Coordinates.Position - _owner.Transform.Coordinates.Position).Length > meleeWeaponComponent.Range) { return Outcome.Failed; @@ -74,7 +74,7 @@ namespace Content.Server.AI.Operators.Combat.Melee var interactionSystem = IoCManager.Resolve().GetEntitySystem(); - interactionSystem.UseItemInHand(_owner, _target.Transform.GridPosition, _target.Uid); + interactionSystem.UseItemInHand(_owner, _target.Transform.Coordinates, _target.Uid); _elapsedTime += frameTime; return Outcome.Continuing; } diff --git a/Content.Server/AI/Operators/Combat/Melee/UnarmedCombatOperator.cs b/Content.Server/AI/Operators/Combat/Melee/UnarmedCombatOperator.cs index 0a6b6697fe..f509844fc3 100644 --- a/Content.Server/AI/Operators/Combat/Melee/UnarmedCombatOperator.cs +++ b/Content.Server/AI/Operators/Combat/Melee/UnarmedCombatOperator.cs @@ -72,14 +72,14 @@ namespace Content.Server.AI.Operators.Combat.Melee return Outcome.Failed; } - if ((_target.Transform.GridPosition.Position - _owner.Transform.GridPosition.Position).Length > + if ((_target.Transform.Coordinates.Position - _owner.Transform.Coordinates.Position).Length > _unarmedCombat.Range) { return Outcome.Failed; } var interactionSystem = IoCManager.Resolve().GetEntitySystem(); - interactionSystem.UseItemInHand(_owner, _target.Transform.GridPosition, _target.Uid); + interactionSystem.UseItemInHand(_owner, _target.Transform.Coordinates, _target.Uid); _elapsedTime += frameTime; return Outcome.Continuing; } diff --git a/Content.Server/AI/Operators/Inventory/InteractWithEntityOperator.cs b/Content.Server/AI/Operators/Inventory/InteractWithEntityOperator.cs index 94702d95d6..161772e72c 100644 --- a/Content.Server/AI/Operators/Inventory/InteractWithEntityOperator.cs +++ b/Content.Server/AI/Operators/Inventory/InteractWithEntityOperator.cs @@ -41,7 +41,7 @@ namespace Content.Server.AI.Operators.Inventory // Click on da thing var interactionSystem = IoCManager.Resolve().GetEntitySystem(); - interactionSystem.UseItemInHand(_owner, _useTarget.Transform.GridPosition, _useTarget.Uid); + interactionSystem.UseItemInHand(_owner, _useTarget.Transform.Coordinates, _useTarget.Uid); return Outcome.Success; } diff --git a/Content.Server/AI/Operators/Movement/MoveToGridOperator.cs b/Content.Server/AI/Operators/Movement/MoveToGridOperator.cs index 11d90389a7..c86923d3ec 100644 --- a/Content.Server/AI/Operators/Movement/MoveToGridOperator.cs +++ b/Content.Server/AI/Operators/Movement/MoveToGridOperator.cs @@ -11,10 +11,10 @@ namespace Content.Server.AI.Operators.Movement { private readonly IEntity _owner; private GridTargetSteeringRequest _request; - private readonly GridCoordinates _target; + private readonly EntityCoordinates _target; public float DesiredRange { get; set; } - public MoveToGridOperator(IEntity owner, GridCoordinates target, float desiredRange = 1.5f) + public MoveToGridOperator(IEntity owner, EntityCoordinates target, float desiredRange = 1.5f) { _owner = owner; _target = target; @@ -33,7 +33,7 @@ namespace Content.Server.AI.Operators.Movement steering.Register(_owner, _request); return true; } - + public override void Shutdown(Outcome outcome) { base.Shutdown(outcome); @@ -60,4 +60,4 @@ namespace Content.Server.AI.Operators.Movement } } } -} \ No newline at end of file +} diff --git a/Content.Server/AI/Utility/Actions/Idle/WanderAndWait.cs b/Content.Server/AI/Utility/Actions/Idle/WanderAndWait.cs index 5cb13cea2c..0574f10e5a 100644 --- a/Content.Server/AI/Utility/Actions/Idle/WanderAndWait.cs +++ b/Content.Server/AI/Utility/Actions/Idle/WanderAndWait.cs @@ -33,7 +33,7 @@ namespace Content.Server.AI.Utility.Actions.Idle var robustRandom = IoCManager.Resolve(); var randomGrid = FindRandomGrid(robustRandom); float waitTime; - if (randomGrid != GridCoordinates.InvalidGrid) + if (randomGrid != EntityCoordinates.Invalid) { waitTime = robustRandom.Next(3, 8); } @@ -60,7 +60,7 @@ namespace Content.Server.AI.Utility.Actions.Idle }; } - private GridCoordinates FindRandomGrid(IRobustRandom robustRandom) + private EntityCoordinates FindRandomGrid(IRobustRandom robustRandom) { // Very inefficient (should weight each region by its node count) but better than the old system var reachableSystem = EntitySystem.Get(); diff --git a/Content.Server/AI/Utility/Actions/Test/MoveRightAndLeftTen.cs b/Content.Server/AI/Utility/Actions/Test/MoveRightAndLeftTen.cs index d2625eddb8..545c317a67 100644 --- a/Content.Server/AI/Utility/Actions/Test/MoveRightAndLeftTen.cs +++ b/Content.Server/AI/Utility/Actions/Test/MoveRightAndLeftTen.cs @@ -21,8 +21,8 @@ namespace Content.Server.AI.Utility.Actions.Test public override void SetupOperators(Blackboard context) { - var currentPosition = Owner.Transform.GridPosition; - var nextPosition = Owner.Transform.GridPosition.Offset(new Vector2(10.0f, 0.0f)); + var currentPosition = Owner.Transform.Coordinates; + var nextPosition = Owner.Transform.Coordinates.Offset(new Vector2(10.0f, 0.0f)); var originalPosOp = new MoveToGridOperator(Owner, currentPosition, 0.25f); var newPosOp = new MoveToGridOperator(Owner, nextPosition, 0.25f); @@ -32,7 +32,7 @@ namespace Content.Server.AI.Utility.Actions.Test originalPosOp }); } - + protected override IReadOnlyCollection> GetConsiderations(Blackboard context) { var considerationsManager = IoCManager.Resolve(); diff --git a/Content.Server/AI/Utility/Considerations/Movement/TargetDistanceCon.cs b/Content.Server/AI/Utility/Considerations/Movement/TargetDistanceCon.cs index a22fcc17e8..ec6df87121 100644 --- a/Content.Server/AI/Utility/Considerations/Movement/TargetDistanceCon.cs +++ b/Content.Server/AI/Utility/Considerations/Movement/TargetDistanceCon.cs @@ -13,9 +13,9 @@ namespace Content.Server.AI.Utility.Considerations.Movement { return 0.0f; } - + // Anything further than 100 tiles gets clamped - return (target.Transform.GridPosition.Position - self.Transform.GridPosition.Position).Length / 100; + return (target.Transform.Coordinates.Position - self.Transform.Coordinates.Position).Length / 100; } } } diff --git a/Content.Server/AI/Utils/Visibility.cs b/Content.Server/AI/Utils/Visibility.cs index 1c66937cde..d79f9f0db9 100644 --- a/Content.Server/AI/Utils/Visibility.cs +++ b/Content.Server/AI/Utils/Visibility.cs @@ -26,7 +26,7 @@ namespace Content.Server.AI.Utils if (owner.TryGetComponent(out AiControllerComponent controller)) { - var targetRange = (target.Transform.GridPosition.Position - owner.Transform.GridPosition.Position).Length; + var targetRange = (target.Transform.Coordinates.Position - owner.Transform.Coordinates.Position).Length; if (targetRange > controller.VisionRadius) { return false; @@ -35,9 +35,9 @@ namespace Content.Server.AI.Utils range = controller.VisionRadius; } - var angle = new Angle(target.Transform.GridPosition.Position - owner.Transform.GridPosition.Position); + var angle = new Angle(target.Transform.Coordinates.Position - owner.Transform.Coordinates.Position); var ray = new CollisionRay( - owner.Transform.GridPosition.Position, + owner.Transform.Coordinates.Position, angle.ToVec(), (int)(CollisionGroup.Opaque | CollisionGroup.Impassable | CollisionGroup.MobImpassable)); @@ -47,25 +47,25 @@ namespace Content.Server.AI.Utils } // Should this be in robust or something? Fark it - public static IEnumerable GetNearestEntities(GridCoordinates grid, Type component, float range) + public static IEnumerable GetNearestEntities(EntityCoordinates grid, Type component, float range) { var inRange = GetEntitiesInRange(grid, component, range).ToList(); - var sortedInRange = inRange.OrderBy(o => (o.Transform.GridPosition.Position - grid.Position).Length); + var sortedInRange = inRange.OrderBy(o => (o.Transform.Coordinates.Position - grid.Position).Length); return sortedInRange; } - public static IEnumerable GetEntitiesInRange(GridCoordinates grid, Type component, float range) + public static IEnumerable GetEntitiesInRange(EntityCoordinates grid, Type component, float range) { var entityManager = IoCManager.Resolve(); foreach (var entity in entityManager.GetEntities(new TypeEntityQuery(component))) { - if (entity.Transform.GridPosition.GridID != grid.GridID) + if (entity.Transform.Coordinates.GetGridId(entityManager) != grid.GetGridId(entityManager)) { continue; } - if ((entity.Transform.GridPosition.Position - grid.Position).Length <= range) + if ((entity.Transform.Coordinates.Position - grid.Position).Length <= range) { yield return entity; } diff --git a/Content.Server/AI/WorldState/States/Clothing/NearbyClothingState.cs b/Content.Server/AI/WorldState/States/Clothing/NearbyClothingState.cs index c8a654a01c..a98e6e90f2 100644 --- a/Content.Server/AI/WorldState/States/Clothing/NearbyClothingState.cs +++ b/Content.Server/AI/WorldState/States/Clothing/NearbyClothingState.cs @@ -24,7 +24,7 @@ namespace Content.Server.AI.WorldState.States.Clothing } foreach (var entity in Visibility - .GetNearestEntities(Owner.Transform.GridPosition, typeof(ClothingComponent), controller.VisionRadius)) + .GetNearestEntities(Owner.Transform.Coordinates, typeof(ClothingComponent), controller.VisionRadius)) { if (ContainerHelpers.TryGetContainer(entity, out var container)) { diff --git a/Content.Server/AI/WorldState/States/Combat/Nearby/NearbyMeleeWeapons.cs b/Content.Server/AI/WorldState/States/Combat/Nearby/NearbyMeleeWeapons.cs index c6d88f5530..89cc63dc25 100644 --- a/Content.Server/AI/WorldState/States/Combat/Nearby/NearbyMeleeWeapons.cs +++ b/Content.Server/AI/WorldState/States/Combat/Nearby/NearbyMeleeWeapons.cs @@ -22,7 +22,7 @@ namespace Content.Server.AI.WorldState.States.Combat.Nearby } foreach (var entity in Visibility - .GetNearestEntities(Owner.Transform.GridPosition, typeof(MeleeWeaponComponent), controller.VisionRadius)) + .GetNearestEntities(Owner.Transform.Coordinates, typeof(MeleeWeaponComponent), controller.VisionRadius)) { result.Add(entity); } diff --git a/Content.Server/AI/WorldState/States/Mobs/NearbyBodiesState.cs b/Content.Server/AI/WorldState/States/Mobs/NearbyBodiesState.cs index b6664b00c7..0c0693b51d 100644 --- a/Content.Server/AI/WorldState/States/Mobs/NearbyBodiesState.cs +++ b/Content.Server/AI/WorldState/States/Mobs/NearbyBodiesState.cs @@ -21,7 +21,7 @@ namespace Content.Server.AI.WorldState.States.Mobs return result; } - foreach (var entity in Visibility.GetEntitiesInRange(Owner.Transform.GridPosition, typeof(ISharedBodyManagerComponent), controller.VisionRadius)) + foreach (var entity in Visibility.GetEntitiesInRange(Owner.Transform.Coordinates, typeof(ISharedBodyManagerComponent), controller.VisionRadius)) { if (entity == Owner) continue; result.Add(entity); diff --git a/Content.Server/AI/WorldState/States/Mobs/NearbyPlayersState.cs b/Content.Server/AI/WorldState/States/Mobs/NearbyPlayersState.cs index 1ba739e3aa..d915006a3a 100644 --- a/Content.Server/AI/WorldState/States/Mobs/NearbyPlayersState.cs +++ b/Content.Server/AI/WorldState/States/Mobs/NearbyPlayersState.cs @@ -23,7 +23,7 @@ namespace Content.Server.AI.WorldState.States.Mobs } var playerManager = IoCManager.Resolve(); - var nearbyPlayers = playerManager.GetPlayersInRange(Owner.Transform.GridPosition, (int) controller.VisionRadius); + var nearbyPlayers = playerManager.GetPlayersInRange(Owner.Transform.Coordinates, (int) controller.VisionRadius); foreach (var player in nearbyPlayers) { diff --git a/Content.Server/AI/WorldState/States/Nutrition/NearbyDrinkState.cs b/Content.Server/AI/WorldState/States/Nutrition/NearbyDrinkState.cs index 15cd69cda2..bd104a29fd 100644 --- a/Content.Server/AI/WorldState/States/Nutrition/NearbyDrinkState.cs +++ b/Content.Server/AI/WorldState/States/Nutrition/NearbyDrinkState.cs @@ -24,7 +24,7 @@ namespace Content.Server.AI.WorldState.States.Nutrition } foreach (var entity in Visibility - .GetNearestEntities(Owner.Transform.GridPosition, typeof(DrinkComponent), controller.VisionRadius)) + .GetNearestEntities(Owner.Transform.Coordinates, typeof(DrinkComponent), controller.VisionRadius)) { if (ContainerHelpers.TryGetContainer(entity, out var container)) { diff --git a/Content.Server/AI/WorldState/States/Nutrition/NearbyFoodState.cs b/Content.Server/AI/WorldState/States/Nutrition/NearbyFoodState.cs index ba44a9d9c5..59eb53f0e0 100644 --- a/Content.Server/AI/WorldState/States/Nutrition/NearbyFoodState.cs +++ b/Content.Server/AI/WorldState/States/Nutrition/NearbyFoodState.cs @@ -24,7 +24,7 @@ namespace Content.Server.AI.WorldState.States.Nutrition } foreach (var entity in Visibility - .GetNearestEntities(Owner.Transform.GridPosition, typeof(FoodComponent), controller.VisionRadius)) + .GetNearestEntities(Owner.Transform.Coordinates, typeof(FoodComponent), controller.VisionRadius)) { if (ContainerHelpers.TryGetContainer(entity, out var container)) { diff --git a/Content.Server/Administration/WarpCommand.cs b/Content.Server/Administration/WarpCommand.cs index e54bca1671..5d35c4087d 100644 --- a/Content.Server/Administration/WarpCommand.cs +++ b/Content.Server/Administration/WarpCommand.cs @@ -60,32 +60,36 @@ namespace Content.Server.Administration var mapManager = IoCManager.Resolve(); var currentMap = player.AttachedEntity.Transform.MapID; var currentGrid = player.AttachedEntity.Transform.GridID; + var entityManager = IoCManager.Resolve(); var found = comp.EntityQuery() .Where(p => p.Location == location) - .Select(p => p.Owner.Transform.GridPosition) - .OrderBy(p => p, Comparer.Create((a, b) => + .Select(p => p.Owner.Transform.Coordinates) + .OrderBy(p => p, Comparer.Create((a, b) => { // Sort so that warp points on the same grid/map are first. // So if you have two maps loaded with the same warp points, // it will prefer the warp points on the map you're currently on. - if (a.GridID == b.GridID) + var aGrid = a.GetGridId(entityManager); + var bGrid = b.GetGridId(entityManager); + + if (aGrid == bGrid) { return 0; } - if (a.GridID == currentGrid) + if (aGrid == currentGrid) { return -1; } - if (b.GridID == currentGrid) + if (bGrid == currentGrid) { return 1; } - var mapA = mapManager.GetGrid(a.GridID).ParentMapId; - var mapB = mapManager.GetGrid(b.GridID).ParentMapId; + var mapA = mapManager.GetGrid(aGrid).ParentMapId; + var mapB = mapManager.GetGrid(bGrid).ParentMapId; if (mapA == mapB) { @@ -106,9 +110,9 @@ namespace Content.Server.Administration })) .FirstOrDefault(); - if (found.GridID != GridId.Invalid) + if (found.GetGridId(entityManager) != GridId.Invalid) { - player.AttachedEntity.Transform.GridPosition = found; + player.AttachedEntity.Transform.Coordinates = found; if (player.AttachedEntity.TryGetComponent(out ICollidableComponent collidable)) { collidable.Stop(); diff --git a/Content.Server/Atmos/AtmosHelpers.cs b/Content.Server/Atmos/AtmosHelpers.cs index 28c8e165c5..4e0d313d89 100644 --- a/Content.Server/Atmos/AtmosHelpers.cs +++ b/Content.Server/Atmos/AtmosHelpers.cs @@ -2,31 +2,35 @@ using System.Diagnostics.CodeAnalysis; using Content.Server.GameObjects.EntitySystems; using Robust.Shared.GameObjects.Systems; +using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Map; namespace Content.Server.Atmos { public static class AtmosHelpers { - public static TileAtmosphere? GetTileAtmosphere(this GridCoordinates coordinates) + public static TileAtmosphere? GetTileAtmosphere(this EntityCoordinates coordinates, IEntityManager? entityManager = null) { - var gridAtmos = EntitySystem.Get().GetGridAtmosphere(coordinates.GridID); + entityManager ??= IoCManager.Resolve(); + + var gridAtmos = EntitySystem.Get().GetGridAtmosphere(coordinates.GetGridId(entityManager)); return gridAtmos?.GetTile(coordinates); } - public static GasMixture? GetTileAir(this GridCoordinates coordinates) + public static GasMixture? GetTileAir(this EntityCoordinates coordinates) { return coordinates.GetTileAtmosphere()?.Air; } - public static bool TryGetTileAtmosphere(this GridCoordinates coordinates, [MaybeNullWhen(false)] out TileAtmosphere atmosphere) + public static bool TryGetTileAtmosphere(this EntityCoordinates coordinates, [MaybeNullWhen(false)] out TileAtmosphere atmosphere) { // ReSharper disable once ConditionIsAlwaysTrueOrFalse return !Equals(atmosphere = coordinates.GetTileAtmosphere()!, default); } - public static bool TryGetTileAir(this GridCoordinates coordinates, [MaybeNullWhen(false)] out GasMixture air) + public static bool TryGetTileAir(this EntityCoordinates coordinates, [MaybeNullWhen(false)] out GasMixture air) { // ReSharper disable once ConditionIsAlwaysTrueOrFalse return !Equals(air = coordinates.GetTileAir()!, default); diff --git a/Content.Server/Atmos/GasSprayerComponent.cs b/Content.Server/Atmos/GasSprayerComponent.cs index 7bcb9361d9..99d166b297 100644 --- a/Content.Server/Atmos/GasSprayerComponent.cs +++ b/Content.Server/Atmos/GasSprayerComponent.cs @@ -53,7 +53,7 @@ namespace Content.Server.Atmos { tank.TryRemoveReagent(_fuelType, ReagentUnit.New(_fuelCost)); - var playerPos = eventArgs.User.Transform.GridPosition; + var playerPos = eventArgs.User.Transform.Coordinates; var direction = (eventArgs.ClickLocation.Position - playerPos.Position).Normalized; playerPos.Offset(direction/2); diff --git a/Content.Server/Atmos/GasVaporComponent.cs b/Content.Server/Atmos/GasVaporComponent.cs index b28d2396a6..243bc96f30 100644 --- a/Content.Server/Atmos/GasVaporComponent.cs +++ b/Content.Server/Atmos/GasVaporComponent.cs @@ -8,9 +8,9 @@ using Robust.Shared.IoC; using Robust.Shared.Maths; using Robust.Shared.Serialization; using Robust.Shared.ViewVariables; -using Content.Server.GameObjects.Components.Atmos; using Content.Server.Interfaces; using Content.Shared.Atmos; +using Robust.Shared.Map; namespace Content.Server.Atmos { @@ -18,6 +18,8 @@ namespace Content.Server.Atmos class GasVaporComponent : Component, ICollideBehavior, IGasMixtureHolder { [Dependency] private readonly IMapManager _mapManager = default!; + [Dependency] private readonly IEntityManager _entityManager = default!; + public override string Name => "GasVapor"; [ViewVariables] public GasMixture Air { get; set; } @@ -76,10 +78,10 @@ namespace Content.Server.Atmos foreach (var tile in tiles) { - var pos = tile.GridIndices.ToGridCoordinates(_mapManager, tile.GridIndex); - var atmos = AtmosHelpers.GetTileAtmosphere(pos); + var pos = tile.GridIndices.ToEntityCoordinates(_mapManager, tile.GridIndex); + var atmos = pos.GetTileAtmosphere(_entityManager); - if (atmos.Air == null) + if (atmos?.Air == null) { return; } diff --git a/Content.Server/Atmos/HighPressureMovementController.cs b/Content.Server/Atmos/HighPressureMovementController.cs index 133d141fb0..8a9eb2af83 100644 --- a/Content.Server/Atmos/HighPressureMovementController.cs +++ b/Content.Server/Atmos/HighPressureMovementController.cs @@ -26,7 +26,7 @@ namespace Content.Server.Atmos private const float ThrowForce = 100f; public void ExperiencePressureDifference(int cycle, float pressureDifference, AtmosDirection direction, - float pressureResistanceProbDelta, GridCoordinates throwTarget) + float pressureResistanceProbDelta, EntityCoordinates throwTarget) { if (ControlledComponent == null) return; @@ -52,10 +52,10 @@ namespace Content.Server.Atmos if (maxForce > ThrowForce) { - if (throwTarget != GridCoordinates.InvalidGrid) + if (throwTarget != EntityCoordinates.Invalid) { var moveForce = maxForce * MathHelper.Clamp(moveProb, 0, 100) / 150f; - var pos = ((throwTarget.Position - transform.GridPosition.Position).Normalized + direction.ToDirection().ToVec()).Normalized; + var pos = ((throwTarget.Position - transform.Coordinates.Position).Normalized + direction.ToDirection().ToVec()).Normalized; LinearVelocity = pos * moveForce; } @@ -74,7 +74,7 @@ namespace Content.Server.Atmos { base.UpdateAfterProcessing(); - if (ControlledComponent != null && !_physicsManager.IsWeightless(ControlledComponent.Owner.Transform.GridPosition)) + if (ControlledComponent != null && !_physicsManager.IsWeightless(ControlledComponent.Owner.Transform.Coordinates)) { LinearVelocity *= 0.85f; if (MathF.Abs(LinearVelocity.Length) < 1f) diff --git a/Content.Server/Atmos/IGridAtmosphereComponent.cs b/Content.Server/Atmos/IGridAtmosphereComponent.cs index 1b53d33610..1a8f76954c 100644 --- a/Content.Server/Atmos/IGridAtmosphereComponent.cs +++ b/Content.Server/Atmos/IGridAtmosphereComponent.cs @@ -117,7 +117,7 @@ namespace Content.Server.Atmos /// /// /// - TileAtmosphere GetTile(GridCoordinates coordinates, bool createSpace = true); + TileAtmosphere GetTile(EntityCoordinates coordinates, bool createSpace = true); /// /// Returns if the tile in question is air-blocked. diff --git a/Content.Server/Atmos/TileAtmosphere.cs b/Content.Server/Atmos/TileAtmosphere.cs index d13bcb8b7e..04186e3686 100644 --- a/Content.Server/Atmos/TileAtmosphere.cs +++ b/Content.Server/Atmos/TileAtmosphere.cs @@ -9,6 +9,7 @@ using Content.Server.Interfaces; using Content.Shared.Atmos; using Content.Shared.Audio; using Content.Shared.Maps; +using Content.Shared.Utility; using JetBrains.Annotations; using Robust.Server.GameObjects.EntitySystems; using Robust.Server.GameObjects.EntitySystems.TileLookup; @@ -188,7 +189,7 @@ namespace Content.Server.Atmos { if(_soundCooldown == 0) EntitySystem.Get().PlayAtCoords("/Audio/Effects/space_wind.ogg", - GridIndices.ToGridCoordinates(_mapManager, GridIndex), AudioHelpers.WithVariation(0.125f).WithVolume(MathHelper.Clamp(PressureDifference / 10, 10, 100))); + GridIndices.ToEntityCoordinates(_mapManager, GridIndex), AudioHelpers.WithVariation(0.125f).WithVolume(MathHelper.Clamp(PressureDifference / 10, 10, 100))); } foreach (var entity in _gridTileLookupSystem.GetEntitiesIntersecting(GridIndex, GridIndices)) @@ -203,7 +204,7 @@ namespace Content.Server.Atmos var pressureMovements = physics.EnsureController(); if (pressure.LastHighPressureMovementAirCycle < _gridAtmosphereComponent.UpdateCounter) { - pressureMovements.ExperiencePressureDifference(_gridAtmosphereComponent.UpdateCounter, PressureDifference, _pressureDirection, 0, PressureSpecificTarget?.GridIndices.ToGridCoordinates(_mapManager, GridIndex) ?? GridCoordinates.InvalidGrid); + pressureMovements.ExperiencePressureDifference(_gridAtmosphereComponent.UpdateCounter, PressureDifference, _pressureDirection, 0, PressureSpecificTarget?.GridIndices.ToEntityCoordinates(_mapManager, GridIndex) ?? EntityCoordinates.Invalid); } } diff --git a/Content.Server/Body/BodyPart.cs b/Content.Server/Body/BodyPart.cs index 544ce651ec..51e59aee20 100644 --- a/Content.Server/Body/BodyPart.cs +++ b/Content.Server/Body/BodyPart.cs @@ -328,7 +328,7 @@ namespace Content.Server.Body SizeUsed -= mechanismTarget.Size; var entityManager = IoCManager.Resolve(); - var position = dropLocation.Transform.GridPosition; + var position = dropLocation.Transform.Coordinates; var mechanismEntity = entityManager.SpawnEntity("BaseDroppedMechanism", position); dropped = mechanismEntity.GetComponent(); @@ -524,7 +524,7 @@ namespace Content.Server.Body return false; } - dropped = IoCManager.Resolve().SpawnEntity("BaseDroppedBodyPart", Body.Owner.Transform.GridPosition); + dropped = IoCManager.Resolve().SpawnEntity("BaseDroppedBodyPart", Body.Owner.Transform.Coordinates); dropped.GetComponent().TransferBodyPartData(this); diff --git a/Content.Server/Chat/ChatManager.cs b/Content.Server/Chat/ChatManager.cs index 0b8a36840b..f9174847a8 100644 --- a/Content.Server/Chat/ChatManager.cs +++ b/Content.Server/Chat/ChatManager.cs @@ -37,7 +37,7 @@ namespace Content.Server.Chat //TODO: make prio based? private List _chatTransformHandlers; - + [Dependency] private readonly IEntitySystemManager _entitySystemManager = default!; [Dependency] private readonly IServerNetManager _netManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; @@ -112,7 +112,7 @@ namespace Content.Server.Chat // Ensure the first letter inside the message string is always a capital letter message = message[0].ToString().ToUpper() + message.Remove(0,1); - var pos = source.Transform.GridPosition; + var pos = source.Transform.Coordinates; var clients = _playerManager.GetPlayersInRange(pos, VoiceRange).Select(p => p.ConnectedClient); var msg = _netManager.CreateNetMessage(); @@ -144,7 +144,7 @@ namespace Content.Server.Chat return; } - var pos = source.Transform.GridPosition; + var pos = source.Transform.Coordinates; var clients = _playerManager.GetPlayersInRange(pos, VoiceRange).Select(p => p.ConnectedClient); var msg = _netManager.CreateNetMessage(); diff --git a/Content.Server/Chemistry/ReactionEffects/ExplosionReactionEffect.cs b/Content.Server/Chemistry/ReactionEffects/ExplosionReactionEffect.cs index 3e46751ab2..b9c5530fea 100644 --- a/Content.Server/Chemistry/ReactionEffects/ExplosionReactionEffect.cs +++ b/Content.Server/Chemistry/ReactionEffects/ExplosionReactionEffect.cs @@ -58,7 +58,7 @@ namespace Content.Server.Chemistry.ReactionEffects int finalHeavyImpactRange = (int)MathF.Round(_heavyImpactRange * floatIntensity); int finalLightImpactRange = (int)MathF.Round(_lightImpactRange * floatIntensity); int finalFlashRange = (int)MathF.Round(_flashRange * floatIntensity); - ExplosionHelper.SpawnExplosion(solutionEntity.Transform.GridPosition, finalDevastationRange, + ExplosionHelper.SpawnExplosion(solutionEntity.Transform.Coordinates, finalDevastationRange, finalHeavyImpactRange, finalLightImpactRange, finalFlashRange); } } diff --git a/Content.Server/Explosions/ExplosionHelper.cs b/Content.Server/Explosions/ExplosionHelper.cs index 1b61f037f3..b5e13936d6 100644 --- a/Content.Server/Explosions/ExplosionHelper.cs +++ b/Content.Server/Explosions/ExplosionHelper.cs @@ -26,13 +26,14 @@ namespace Content.Server.Explosions /// private static Vector2 _epicenterDistance = (0.1f, 0.1f); - public static void SpawnExplosion(GridCoordinates coords, int devastationRange, int heavyImpactRange, int lightImpactRange, int flashRange) + public static void SpawnExplosion(EntityCoordinates coords, int devastationRange, int heavyImpactRange, int lightImpactRange, int flashRange) { var tileDefinitionManager = IoCManager.Resolve(); var serverEntityManager = IoCManager.Resolve(); var entitySystemManager = IoCManager.Resolve(); var mapManager = IoCManager.Resolve(); var robustRandom = IoCManager.Resolve(); + var entityManager = IoCManager.Resolve(); var maxRange = MathHelper.Max(devastationRange, heavyImpactRange, lightImpactRange, 0f); //Entity damage calculation @@ -45,17 +46,21 @@ namespace Content.Server.Explosions if (!entity.Transform.IsMapTransform) continue; - var distanceFromEntity = (int)entity.Transform.GridPosition.Distance(mapManager, coords); + if (!entity.Transform.Coordinates.TryDistance(entityManager, coords, out var distance)) + { + continue; + } + ExplosionSeverity severity; - if (distanceFromEntity < devastationRange) + if (distance < devastationRange) { severity = ExplosionSeverity.Destruction; } - else if (distanceFromEntity < heavyImpactRange) + else if (distance < heavyImpactRange) { severity = ExplosionSeverity.Heavy; } - else if (distanceFromEntity < lightImpactRange) + else if (distance < lightImpactRange) { severity = ExplosionSeverity.Light; } @@ -70,7 +75,7 @@ namespace Content.Server.Explosions //Tile damage calculation mockup //TODO: make it into some sort of actual damage component or whatever the boys think is appropriate - var mapGrid = mapManager.GetGrid(coords.GridID); + var mapGrid = mapManager.GetGrid(coords.GetGridId(entityManager)); var circle = new Circle(coords.Position, maxRange); var tiles = mapGrid.GetTilesIntersecting(circle); foreach (var tile in tiles) @@ -82,12 +87,16 @@ namespace Content.Server.Explosions { continue; } - var distanceFromTile = (int) tileLoc.Distance(mapManager, coords); + + if (!tileLoc.TryDistance(entityManager, coords, out var distance)) + { + continue; + } var zeroTile = new Tile(tileDefinitionManager[baseTurfs[0]].TileId); var previousTile = new Tile(tileDefinitionManager[baseTurfs[^1]].TileId); - switch (distanceFromTile) + switch (distance) { case var d when d < devastationRange: mapGrid.SetTile(tileLoc, zeroTile); @@ -137,7 +146,7 @@ namespace Content.Server.Explosions } var playerPos = player.AttachedEntity.Transform.WorldPosition; - var delta = coords.ToMapPos(mapManager) - playerPos; + var delta = coords.ToMapPos(entityManager) - playerPos; //Change if zero. Will result in a NaN later breaking camera shake if not changed if (delta.EqualsApprox((0.0f, 0.0f))) delta = _epicenterDistance; diff --git a/Content.Server/GameObjects/Components/ActionBlocking/CuffableComponent.cs b/Content.Server/GameObjects/Components/ActionBlocking/CuffableComponent.cs index 79473ac91c..78c25ce7e8 100644 --- a/Content.Server/GameObjects/Components/ActionBlocking/CuffableComponent.cs +++ b/Content.Server/GameObjects/Components/ActionBlocking/CuffableComponent.cs @@ -134,7 +134,7 @@ namespace Content.Server.GameObjects.Components.ActionBlocking var entity = _container.ContainedEntities[_container.ContainedEntities.Count - 1]; _container.Remove(entity); - entity.Transform.WorldPosition = Owner.Transform.GridPosition.Position; + entity.Transform.WorldPosition = Owner.Transform.Coordinates.Position; } if (dirty) diff --git a/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs b/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs index 3703eff58d..9e422a8767 100644 --- a/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs @@ -4,6 +4,7 @@ using Robust.Server.Interfaces.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components.Transform; using Robust.Shared.GameObjects.Systems; +using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Map; using Robust.Shared.IoC; using Robust.Shared.Log; @@ -17,6 +18,7 @@ namespace Content.Server.GameObjects.Components.Atmos public class AirtightComponent : Component, IMapInit { [Dependency] private readonly IMapManager _mapManager = default!; + [Dependency] private readonly IEntityManager _entityManager = default!; private (GridId, MapIndices) _lastPosition; @@ -89,7 +91,7 @@ namespace Content.Server.GameObjects.Components.Atmos if (_fixVacuum) { - var mapIndices = Owner.Transform.GridPosition.ToMapIndices(_mapManager); + var mapIndices = Owner.Transform.Coordinates.ToMapIndices(_entityManager, _mapManager); EntitySystem.Get().GetGridAtmosphere(Owner.Transform.GridID)?.FixVacuum(mapIndices); } @@ -109,7 +111,7 @@ namespace Content.Server.GameObjects.Components.Atmos private void UpdatePosition() { - var mapIndices = Owner.Transform.GridPosition.ToMapIndices(_mapManager); + var mapIndices = Owner.Transform.Coordinates.ToMapIndices(_entityManager, _mapManager); UpdatePosition(Owner.Transform.GridID, mapIndices); } diff --git a/Content.Server/GameObjects/Components/Atmos/BarotraumaComponent.cs b/Content.Server/GameObjects/Components/Atmos/BarotraumaComponent.cs index cabaf72d5a..d877165791 100644 --- a/Content.Server/GameObjects/Components/Atmos/BarotraumaComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/BarotraumaComponent.cs @@ -9,6 +9,7 @@ using Content.Shared.Damage; using Content.Shared.GameObjects.Components.Mobs; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; +using Robust.Shared.Interfaces.GameObjects; namespace Content.Server.GameObjects.Components.Atmos { @@ -18,6 +19,8 @@ namespace Content.Server.GameObjects.Components.Atmos [RegisterComponent] public class BarotraumaComponent : Component { + [Robust.Shared.IoC.Dependency] private readonly IEntityManager _entityManager = default!; + public override string Name => "Barotrauma"; [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -26,8 +29,8 @@ namespace Content.Server.GameObjects.Components.Atmos if (!Owner.TryGetComponent(out IDamageableComponent damageable)) return; Owner.TryGetComponent(out ServerStatusEffectsComponent status); - var coordinates = Owner.Transform.GridPosition; - var gridAtmos = EntitySystem.Get().GetGridAtmosphere(coordinates.GridID); + var coordinates = Owner.Transform.Coordinates; + var gridAtmos = EntitySystem.Get().GetGridAtmosphere(coordinates.GetGridId(_entityManager)); var tile = gridAtmos?.GetTile(coordinates); var pressure = 1f; diff --git a/Content.Server/GameObjects/Components/Atmos/GasAnalyzerComponent.cs b/Content.Server/GameObjects/Components/Atmos/GasAnalyzerComponent.cs index 58ba7c67eb..46cc78574f 100644 --- a/Content.Server/GameObjects/Components/Atmos/GasAnalyzerComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/GasAnalyzerComponent.cs @@ -13,6 +13,7 @@ using Robust.Server.Interfaces.GameObjects; using Robust.Server.Interfaces.Player; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; +using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Map; using Robust.Shared.IoC; using Robust.Shared.Localization; @@ -25,12 +26,13 @@ namespace Content.Server.GameObjects.Components.Atmos public class GasAnalyzerComponent : SharedGasAnalyzerComponent, IAfterInteract, IDropped, IUse { [Dependency] private readonly IMapManager _mapManager = default!; + [Dependency] private readonly IEntityManager _entityManager = default!; private GasAnalyzerDanger _pressureDanger; private float _timeSinceSync; private const float TimeBetweenSyncs = 2f; private bool _checkPlayer = false; // Check at the player pos or at some other tile? - private GridCoordinates? _position; // The tile that we scanned + private EntityCoordinates? _position; // The tile that we scanned [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(GasAnalyzerUiKey.Key); @@ -69,7 +71,7 @@ namespace Content.Server.GameObjects.Components.Atmos /// /// The session to open the ui for /// The position to analyze the gas - public void OpenInterface(IPlayerSession session, GridCoordinates pos) + public void OpenInterface(IPlayerSession session, EntityCoordinates pos) { _checkPlayer = false; _position = pos; @@ -100,7 +102,7 @@ namespace Content.Server.GameObjects.Components.Atmos // Already get the pressure before Dirty(), because we can't get the EntitySystem in that thread or smth var pressure = 0f; var gam = EntitySystem.Get().GetGridAtmosphere(Owner.Transform.GridID); - var tile = gam?.GetTile(Owner.Transform.GridPosition).Air; + var tile = gam?.GetTile(Owner.Transform.Coordinates).Air; if (tile != null) { pressure = tile.Pressure; @@ -148,18 +150,18 @@ namespace Content.Server.GameObjects.Components.Atmos } } - var pos = Owner.Transform.GridPosition; + var pos = Owner.Transform.Coordinates; if (!_checkPlayer && _position.HasValue) { // Check if position is out of range => don't update - if (!_position.Value.InRange(_mapManager, pos, SharedInteractionSystem.InteractionRange)) + if (!_position.Value.InRange(_entityManager, pos, SharedInteractionSystem.InteractionRange)) return; pos = _position.Value; } var atmosSystem = EntitySystem.Get(); - var gam = atmosSystem.GetGridAtmosphere(pos.GridID); + var gam = atmosSystem.GetGridAtmosphere(pos.GetGridId(_entityManager)); var tile = gam?.GetTile(pos).Air; if (tile == null) { diff --git a/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs b/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs index 907a7b278c..705b9c585f 100644 --- a/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs @@ -374,9 +374,9 @@ namespace Content.Server.GameObjects.Components.Atmos } /// - public TileAtmosphere? GetTile(GridCoordinates coordinates, bool createSpace = true) + public TileAtmosphere? GetTile(EntityCoordinates coordinates, bool createSpace = true) { - return GetTile(coordinates.ToMapIndices(_mapManager), createSpace); + return GetTile(coordinates.ToMapIndices(_serverEntityManager, _mapManager), createSpace); } /// diff --git a/Content.Server/GameObjects/Components/Atmos/Piping/Scrubbers/BaseSiphonComponent.cs b/Content.Server/GameObjects/Components/Atmos/Piping/Scrubbers/BaseSiphonComponent.cs index 16d04a20fb..da90efdad2 100644 --- a/Content.Server/GameObjects/Components/Atmos/Piping/Scrubbers/BaseSiphonComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/Piping/Scrubbers/BaseSiphonComponent.cs @@ -6,6 +6,8 @@ using Robust.Shared.GameObjects.Systems; using Robust.Shared.Log; using Robust.Shared.ViewVariables; using System.Linq; +using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.GameObjects.Components.Atmos.Piping { @@ -14,6 +16,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping /// public abstract class BaseSiphonComponent : PipeNetDeviceComponent { + [Dependency] private readonly IEntityManager _entityManager = default!; + [ViewVariables] private PipeNode _scrubberOutlet; @@ -40,11 +44,11 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping public override void Update() { - var tileAtmos = AtmosHelpers.GetTileAtmosphere(Owner.Transform.GridPosition); + var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere(_entityManager); if (tileAtmos == null) return; ScrubGas(tileAtmos.Air, _scrubberOutlet.Air); - _atmosSystem.GetGridAtmosphere(Owner.Transform.GridID).Invalidate(tileAtmos.GridIndices); + _atmosSystem.GetGridAtmosphere(Owner.Transform.GridID)?.Invalidate(tileAtmos.GridIndices); } protected abstract void ScrubGas(GasMixture inletGas, GasMixture outletGas); diff --git a/Content.Server/GameObjects/Components/Atmos/Piping/Vents/BaseVentComponent.cs b/Content.Server/GameObjects/Components/Atmos/Piping/Vents/BaseVentComponent.cs index 334d647712..a9240c3556 100644 --- a/Content.Server/GameObjects/Components/Atmos/Piping/Vents/BaseVentComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/Piping/Vents/BaseVentComponent.cs @@ -6,6 +6,8 @@ using Robust.Shared.GameObjects.Systems; using Robust.Shared.Log; using Robust.Shared.ViewVariables; using System.Linq; +using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.GameObjects.Components.Atmos.Piping { @@ -14,13 +16,13 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping /// public abstract class BaseVentComponent : PipeNetDeviceComponent { + [Dependency] private readonly IEntityManager _entityManager = default!; + [ViewVariables] private PipeNode _ventInlet; private AtmosphereSystem _atmosSystem; - - public override void Initialize() { base.Initialize(); @@ -42,7 +44,7 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping public override void Update() { - var tileAtmos = AtmosHelpers.GetTileAtmosphere(Owner.Transform.GridPosition); + var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere(_entityManager); if (tileAtmos == null) return; VentGas(_ventInlet.Air, tileAtmos.Air); diff --git a/Content.Server/GameObjects/Components/Body/Respiratory/LungComponent.cs b/Content.Server/GameObjects/Components/Body/Respiratory/LungComponent.cs index 1596b01c64..e8392c7948 100644 --- a/Content.Server/GameObjects/Components/Body/Respiratory/LungComponent.cs +++ b/Content.Server/GameObjects/Components/Body/Respiratory/LungComponent.cs @@ -83,7 +83,7 @@ namespace Content.Server.GameObjects.Components.Body.Respiratory return; } - if (!Owner.Transform.GridPosition.TryGetTileAir(out var tileAir)) + if (!Owner.Transform.Coordinates.TryGetTileAir(out var tileAir)) { return; } @@ -104,7 +104,7 @@ namespace Content.Server.GameObjects.Components.Body.Respiratory return; } - if (!Owner.Transform.GridPosition.TryGetTileAir(out var tileAir)) + if (!Owner.Transform.Coordinates.TryGetTileAir(out var tileAir)) { return; } diff --git a/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs b/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs index 8e42c59e96..1893a36fc4 100644 --- a/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs +++ b/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs @@ -426,9 +426,9 @@ namespace Content.Server.GameObjects.Components.Buckle return; } - var bucklePosition = BuckledTo.Owner.Transform.GridPosition.Offset(BuckleOffset.Value); + var bucklePosition = BuckledTo.Owner.Transform.Coordinates.Offset(BuckleOffset.Value); - if (moveEvent.NewPosition.InRange(_mapManager, bucklePosition, 0.2f)) + if (moveEvent.NewPosition.InRange(_entityManager, bucklePosition, 0.2f)) { return; } diff --git a/Content.Server/GameObjects/Components/Cargo/CargoConsoleComponent.cs b/Content.Server/GameObjects/Components/Cargo/CargoConsoleComponent.cs index 9f630edd1a..6e167e2a62 100644 --- a/Content.Server/GameObjects/Components/Cargo/CargoConsoleComponent.cs +++ b/Content.Server/GameObjects/Components/Cargo/CargoConsoleComponent.cs @@ -168,7 +168,7 @@ namespace Content.Server.GameObjects.Components.Cargo continue; for (var i = 0; i < order.Amount; i++) { - Owner.EntityManager.SpawnEntity(product.Product, Owner.Transform.GridPosition); + Owner.EntityManager.SpawnEntity(product.Product, Owner.Transform.Coordinates); } } break; diff --git a/Content.Server/GameObjects/Components/Chemistry/ChemMasterComponent.cs b/Content.Server/GameObjects/Components/Chemistry/ChemMasterComponent.cs index e862d74b58..e62002fb32 100644 --- a/Content.Server/GameObjects/Components/Chemistry/ChemMasterComponent.cs +++ b/Content.Server/GameObjects/Components/Chemistry/ChemMasterComponent.cs @@ -279,7 +279,7 @@ namespace Content.Server.GameObjects.Components.Chemistry var actualVolume = ReagentUnit.Min(individualVolume, ReagentUnit.New(30)); for (int i = 0; i < bottleAmount; i++) { - var bottle = Owner.EntityManager.SpawnEntity("bottle", Owner.Transform.GridPosition); + var bottle = Owner.EntityManager.SpawnEntity("bottle", Owner.Transform.Coordinates); var bufferSolution = BufferSolution.Solution.SplitSolution(actualVolume); @@ -298,7 +298,7 @@ namespace Content.Server.GameObjects.Components.Chemistry } //Put it on the floor - bottle.Transform.GridPosition = user.Transform.GridPosition; + bottle.Transform.Coordinates = user.Transform.Coordinates; //Give it an offset bottle.RandomOffset(0.2f); } @@ -313,7 +313,7 @@ namespace Content.Server.GameObjects.Components.Chemistry var actualVolume = ReagentUnit.Min(individualVolume, ReagentUnit.New(50)); for (int i = 0; i < pillAmount; i++) { - var pill = Owner.EntityManager.SpawnEntity("pill", Owner.Transform.GridPosition); + var pill = Owner.EntityManager.SpawnEntity("pill", Owner.Transform.Coordinates); var bufferSolution = BufferSolution.Solution.SplitSolution(actualVolume); @@ -333,7 +333,7 @@ namespace Content.Server.GameObjects.Components.Chemistry } //Put it on the floor - pill.Transform.GridPosition = user.Transform.GridPosition; + pill.Transform.Coordinates = user.Transform.Coordinates; //Give it an offset pill.RandomOffset(0.2f); } diff --git a/Content.Server/GameObjects/Components/Chemistry/SolutionComponent.cs b/Content.Server/GameObjects/Components/Chemistry/SolutionComponent.cs index 71c6ee7996..f987e1f2a2 100644 --- a/Content.Server/GameObjects/Components/Chemistry/SolutionComponent.cs +++ b/Content.Server/GameObjects/Components/Chemistry/SolutionComponent.cs @@ -499,7 +499,7 @@ namespace Content.Server.GameObjects.Components.Chemistry } //Play reaction sound client-side - _audioSystem.PlayAtCoords("/Audio/Effects/Chemistry/bubbles.ogg", Owner.Transform.GridPosition); + _audioSystem.PlayAtCoords("/Audio/Effects/Chemistry/bubbles.ogg", Owner.Transform.Coordinates); } /// diff --git a/Content.Server/GameObjects/Components/Chemistry/VaporComponent.cs b/Content.Server/GameObjects/Components/Chemistry/VaporComponent.cs index 31734a5924..3d89de3d30 100644 --- a/Content.Server/GameObjects/Components/Chemistry/VaporComponent.cs +++ b/Content.Server/GameObjects/Components/Chemistry/VaporComponent.cs @@ -75,7 +75,7 @@ namespace Content.Server.GameObjects.Components.Chemistry var amount = _transferAmount / ReagentUnit.New(tiles.Count()); foreach (var tile in tiles) { - var pos = tile.GridIndices.ToGridCoordinates(_mapManager, tile.GridIndex); + var pos = tile.GridIndices.ToEntityCoordinates(_mapManager, tile.GridIndex); contents.SplitSolution(amount).SpillAt(pos, "PuddleSmear", false); // TODO: Make non PuddleSmear? } } diff --git a/Content.Server/GameObjects/Components/Damage/BreakableComponent.cs b/Content.Server/GameObjects/Components/Damage/BreakableComponent.cs index d1425cce58..994373dde3 100644 --- a/Content.Server/GameObjects/Components/Damage/BreakableComponent.cs +++ b/Content.Server/GameObjects/Components/Damage/BreakableComponent.cs @@ -70,7 +70,7 @@ namespace Content.Server.GameObjects.Components.Damage _actSystem.HandleBreakage(Owner); if (!Owner.Deleted && DestroySound != string.Empty) { - var pos = Owner.Transform.GridPosition; + var pos = Owner.Transform.Coordinates; EntitySystem.Get().PlayAtCoords(DestroySound, pos); } } diff --git a/Content.Server/GameObjects/Components/Damage/DestructibleComponent.cs b/Content.Server/GameObjects/Components/Damage/DestructibleComponent.cs index 7ba91324a5..194464ee61 100644 --- a/Content.Server/GameObjects/Components/Damage/DestructibleComponent.cs +++ b/Content.Server/GameObjects/Components/Damage/DestructibleComponent.cs @@ -32,7 +32,7 @@ namespace Content.Server.GameObjects.Components.Damage { if (!string.IsNullOrWhiteSpace(SpawnOnDestroy) && eventArgs.IsSpawnWreck) { - Owner.EntityManager.SpawnEntity(SpawnOnDestroy, Owner.Transform.GridPosition); + Owner.EntityManager.SpawnEntity(SpawnOnDestroy, Owner.Transform.Coordinates); } } @@ -53,7 +53,7 @@ namespace Content.Server.GameObjects.Components.Damage { if (!Owner.Deleted) { - var pos = Owner.Transform.GridPosition; + var pos = Owner.Transform.Coordinates; ActSystem.HandleDestruction(Owner, true); //This will call IDestroyAct.OnDestroy on this component (and all other components on this entity) if (DestroySound != string.Empty) diff --git a/Content.Server/GameObjects/Components/Damage/RuinableComponent.cs b/Content.Server/GameObjects/Components/Damage/RuinableComponent.cs index 713448fd1a..16dbb09af4 100644 --- a/Content.Server/GameObjects/Components/Damage/RuinableComponent.cs +++ b/Content.Server/GameObjects/Components/Damage/RuinableComponent.cs @@ -61,7 +61,7 @@ namespace Content.Server.GameObjects.Components.Damage if (!Owner.Deleted && DestroySound != string.Empty) { - var pos = Owner.Transform.GridPosition; + var pos = Owner.Transform.Coordinates; EntitySystem.Get().PlayAtCoords(DestroySound, pos); } diff --git a/Content.Server/GameObjects/Components/Disposal/DisposalHolderComponent.cs b/Content.Server/GameObjects/Components/Disposal/DisposalHolderComponent.cs index ed19c29447..d9b890d53d 100644 --- a/Content.Server/GameObjects/Components/Disposal/DisposalHolderComponent.cs +++ b/Content.Server/GameObjects/Components/Disposal/DisposalHolderComponent.cs @@ -88,7 +88,7 @@ namespace Content.Server.GameObjects.Components.Disposal PreviousTube = CurrentTube; } - Owner.Transform.GridPosition = tube.Owner.Transform.GridPosition; + Owner.Transform.Coordinates = tube.Owner.Transform.Coordinates; CurrentTube = tube; NextTube = tube.NextTube(this); StartingTime = 0.1f; diff --git a/Content.Server/GameObjects/Components/Disposal/DisposalTubeComponent.cs b/Content.Server/GameObjects/Components/Disposal/DisposalTubeComponent.cs index 8a002a3dea..2fb8728fc8 100644 --- a/Content.Server/GameObjects/Components/Disposal/DisposalTubeComponent.cs +++ b/Content.Server/GameObjects/Components/Disposal/DisposalTubeComponent.cs @@ -273,7 +273,7 @@ namespace Content.Server.GameObjects.Components.Disposal } _lastClang = _gameTiming.CurTime; - EntitySystem.Get().PlayAtCoords(_clangSound, Owner.Transform.GridPosition); + EntitySystem.Get().PlayAtCoords(_clangSound, Owner.Transform.Coordinates); break; } } diff --git a/Content.Server/GameObjects/Components/Explosion/ExplosiveComponent.cs b/Content.Server/GameObjects/Components/Explosion/ExplosiveComponent.cs index 39b49c13fb..759edb5d5b 100644 --- a/Content.Server/GameObjects/Components/Explosion/ExplosiveComponent.cs +++ b/Content.Server/GameObjects/Components/Explosion/ExplosiveComponent.cs @@ -34,7 +34,7 @@ namespace Content.Server.GameObjects.Components.Explosion if (_beingExploded) return true; _beingExploded = true; - ExplosionHelper.SpawnExplosion(Owner.Transform.GridPosition, DevastationRange, HeavyImpactRange, LightImpactRange, FlashRange); + ExplosionHelper.SpawnExplosion(Owner.Transform.Coordinates, DevastationRange, HeavyImpactRange, LightImpactRange, FlashRange); Owner.Delete(); return true; diff --git a/Content.Server/GameObjects/Components/Explosion/FlashExplosiveComponent.cs b/Content.Server/GameObjects/Components/Explosion/FlashExplosiveComponent.cs index c8d6120edd..06a3b1f816 100644 --- a/Content.Server/GameObjects/Components/Explosion/FlashExplosiveComponent.cs +++ b/Content.Server/GameObjects/Components/Explosion/FlashExplosiveComponent.cs @@ -44,7 +44,7 @@ namespace Content.Server.GameObjects.Components.Explosion if (_sound != null) { - EntitySystem.Get().PlayAtCoords(_sound, Owner.Transform.GridPosition); + EntitySystem.Get().PlayAtCoords(_sound, Owner.Transform.Coordinates); } if (_deleteOnFlash && !Owner.Deleted) diff --git a/Content.Server/GameObjects/Components/ExtinguisherCabinetComponent.cs b/Content.Server/GameObjects/Components/ExtinguisherCabinetComponent.cs index 38640b766c..e5a715f045 100644 --- a/Content.Server/GameObjects/Components/ExtinguisherCabinetComponent.cs +++ b/Content.Server/GameObjects/Components/ExtinguisherCabinetComponent.cs @@ -89,7 +89,7 @@ namespace Content.Server.GameObjects.Components } else if (ItemContainer.Remove(ItemContainer.ContainedEntity)) { - ItemContainer.ContainedEntity.Transform.GridPosition = Owner.Transform.GridPosition; + ItemContainer.ContainedEntity.Transform.Coordinates = Owner.Transform.Coordinates; } } else diff --git a/Content.Server/GameObjects/Components/ExtinguisherCabinetFilledComponent.cs b/Content.Server/GameObjects/Components/ExtinguisherCabinetFilledComponent.cs index f9a861e238..6b93f63160 100644 --- a/Content.Server/GameObjects/Components/ExtinguisherCabinetFilledComponent.cs +++ b/Content.Server/GameObjects/Components/ExtinguisherCabinetFilledComponent.cs @@ -13,7 +13,7 @@ namespace Content.Server.GameObjects.Components { base.Initialize(); - ItemContainer.Insert(Owner.EntityManager.SpawnEntity("FireExtinguisher", Owner.Transform.GridPosition)); + ItemContainer.Insert(Owner.EntityManager.SpawnEntity("FireExtinguisher", Owner.Transform.Coordinates)); } } } diff --git a/Content.Server/GameObjects/Components/Fluids/CanSpillComponent.cs b/Content.Server/GameObjects/Components/Fluids/CanSpillComponent.cs index b14063b7a4..bee90b967c 100644 --- a/Content.Server/GameObjects/Components/Fluids/CanSpillComponent.cs +++ b/Content.Server/GameObjects/Components/Fluids/CanSpillComponent.cs @@ -39,7 +39,7 @@ namespace Content.Server.GameObjects.Components.Fluids { var solutionComponent = component.Owner.GetComponent(); // Need this as when we split the component's owner may be deleted - var entityLocation = component.Owner.Transform.GridPosition; + var entityLocation = component.Owner.Transform.Coordinates; var solution = solutionComponent.SplitSolution(solutionComponent.CurrentVolume); solution.SpillAt(entityLocation, "PuddleSmear"); } diff --git a/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs b/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs index 2ba084cef7..a26703122e 100644 --- a/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs +++ b/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs @@ -195,7 +195,7 @@ namespace Content.Server.GameObjects.Components.Fluids return true; } - EntitySystem.Get().PlayAtCoords(_spillSound, Owner.Transform.GridPosition); + EntitySystem.Get().PlayAtCoords(_spillSound, Owner.Transform.Coordinates); return true; } @@ -354,7 +354,7 @@ namespace Content.Server.GameObjects.Components.Fluids var mapGrid = _mapManager.GetGrid(Owner.Transform.GridID); - if (!Owner.Transform.GridPosition.Offset(direction).TryGetTileRef(out var tile)) + if (!Owner.Transform.Coordinates.Offset(direction).TryGetTileRef(out var tile)) { return false; } diff --git a/Content.Server/GameObjects/Components/Fluids/SpillExtensions.cs b/Content.Server/GameObjects/Components/Fluids/SpillExtensions.cs index 5f9c45580f..e8b8f9c24f 100644 --- a/Content.Server/GameObjects/Components/Fluids/SpillExtensions.cs +++ b/Content.Server/GameObjects/Components/Fluids/SpillExtensions.cs @@ -23,7 +23,7 @@ namespace Content.Server.GameObjects.Components.Fluids /// The puddle if one was created, null otherwise. public static PuddleComponent? SpillAt(this Solution solution, IEntity entity, string prototype, bool sound = true) { - var coordinates = entity.Transform.GridPosition; + var coordinates = entity.Transform.Coordinates; return solution.SpillAt(coordinates, prototype, sound); } @@ -52,7 +52,7 @@ namespace Content.Server.GameObjects.Components.Fluids /// The prototype to use. /// Whether or not to play the spill sound. /// The puddle if one was created, null otherwise. - public static PuddleComponent? SpillAt(this Solution solution, GridCoordinates coordinates, string prototype, bool sound = true) + public static PuddleComponent? SpillAt(this Solution solution, EntityCoordinates coordinates, string prototype, bool sound = true) { if (solution.TotalVolume == 0) { @@ -63,7 +63,8 @@ namespace Content.Server.GameObjects.Components.Fluids var entityManager = IoCManager.Resolve(); var serverEntityManager = IoCManager.Resolve(); - var mapGrid = mapManager.GetGrid(coordinates.GridID); + var gridId = coordinates.GetGridId(entityManager); + var mapGrid = mapManager.GetGrid(gridId); // If space return early, let that spill go out into the void var tileRef = mapGrid.GetTileRef(coordinates); @@ -74,7 +75,7 @@ namespace Content.Server.GameObjects.Components.Fluids // Get normalized co-ordinate for spill location and spill it in the centre // TODO: Does SnapGrid or something else already do this? - var spillTileMapGrid = mapManager.GetGrid(coordinates.GridID); + var spillTileMapGrid = mapManager.GetGrid(gridId); var spillTileRef = spillTileMapGrid.GetTileRef(coordinates).GridIndices; var spillGridCoords = spillTileMapGrid.GridTileToLocal(spillTileRef); @@ -119,7 +120,7 @@ namespace Content.Server.GameObjects.Components.Fluids /// The puddle if one was created, null otherwise. /// Play the spill sound. /// True if a puddle was created, false otherwise. - public static bool TrySpillAt(this Solution solution, GridCoordinates coordinates, string prototype, [NotNullWhen(true)] out PuddleComponent? puddle, bool sound = true) + public static bool TrySpillAt(this Solution solution, EntityCoordinates coordinates, string prototype, [NotNullWhen(true)] out PuddleComponent? puddle, bool sound = true) { puddle = solution.SpillAt(coordinates, prototype, sound); return puddle != null; diff --git a/Content.Server/GameObjects/Components/Fluids/SprayComponent.cs b/Content.Server/GameObjects/Components/Fluids/SprayComponent.cs index 598bb16a6a..9d42b72acc 100644 --- a/Content.Server/GameObjects/Components/Fluids/SprayComponent.cs +++ b/Content.Server/GameObjects/Components/Fluids/SprayComponent.cs @@ -74,8 +74,8 @@ namespace Content.Server.GameObjects.Components.Fluids return; } - var playerPos = eventArgs.User.Transform.GridPosition; - if (eventArgs.ClickLocation.GridID != playerPos.GridID) + var playerPos = eventArgs.User.Transform.Coordinates; + if (eventArgs.ClickLocation.GetGridId(_serverEntityManager) != playerPos.GetGridId(_serverEntityManager)) return; if (!Owner.TryGetComponent(out SolutionComponent contents)) diff --git a/Content.Server/GameObjects/Components/GUI/HandsComponent.cs b/Content.Server/GameObjects/Components/GUI/HandsComponent.cs index bda951b392..0acabf0c98 100644 --- a/Content.Server/GameObjects/Components/GUI/HandsComponent.cs +++ b/Content.Server/GameObjects/Components/GUI/HandsComponent.cs @@ -181,7 +181,7 @@ namespace Content.Server.GameObjects.Components.GUI { if (!PutInHand(item, mobCheck)) { - item.Owner.Transform.GridPosition = Owner.Transform.GridPosition; + item.Owner.Transform.Coordinates = Owner.Transform.Coordinates; } } @@ -245,7 +245,7 @@ namespace Content.Server.GameObjects.Components.GUI return false; } - public bool Drop(string slot, GridCoordinates coords, bool doMobChecks = true) + public bool Drop(string slot, EntityCoordinates coords, bool doMobChecks = true) { var hand = GetHand(slot); if (!CanDrop(slot) || hand?.Entity == null) @@ -264,7 +264,7 @@ namespace Content.Server.GameObjects.Components.GUI return false; item.RemovedFromSlot(); - item.Owner.Transform.GridPosition = coords; + item.Owner.Transform.Coordinates = coords; if (ContainerHelpers.TryGetContainer(Owner, out var container)) { @@ -277,7 +277,7 @@ namespace Content.Server.GameObjects.Components.GUI return true; } - public bool Drop(IEntity entity, GridCoordinates coords, bool doMobChecks = true) + public bool Drop(IEntity entity, EntityCoordinates coords, bool doMobChecks = true) { if (entity == null) { @@ -311,7 +311,7 @@ namespace Content.Server.GameObjects.Components.GUI } item.RemovedFromSlot(); - item.Owner.Transform.GridPosition = Owner.Transform.GridPosition; + item.Owner.Transform.Coordinates = Owner.Transform.Coordinates; if (item.Owner.TryGetComponent(out var spriteComponent)) { @@ -564,7 +564,7 @@ namespace Content.Server.GameObjects.Components.GUI controller.StartPull(Owner.GetComponent()); } - public void MovePulledObject(GridCoordinates puller, GridCoordinates to) + public void MovePulledObject(EntityCoordinates puller, EntityCoordinates to) { if (PulledObject != null && PulledObject.TryGetController(out PullController controller)) @@ -655,7 +655,7 @@ namespace Content.Server.GameObjects.Components.GUI if (used != null) { interactionSystem.Interaction(Owner, used, hand.Entity, - GridCoordinates.InvalidGrid); + EntityCoordinates.Invalid); } else { diff --git a/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs b/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs index 13353f664d..aa7d873ab4 100644 --- a/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs +++ b/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs @@ -446,7 +446,7 @@ namespace Content.Server.GameObjects.Components.GUI if (activeHand != null) { interactionSystem.Interaction(Owner, activeHand.Owner, itemContainedInSlot.Owner, - new GridCoordinates()); + new EntityCoordinates()); } else if (Unequip(msg.Inventoryslot)) { diff --git a/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs b/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs index 588200c738..ae3e86e268 100644 --- a/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/HandheldLightComponent.cs @@ -234,7 +234,7 @@ namespace Content.Server.GameObjects.Components.Interactable if (!hands.PutInHand(cell.Owner.GetComponent())) { - cell.Owner.Transform.GridPosition = user.Transform.GridPosition; + cell.Owner.Transform.Coordinates = user.Transform.Coordinates; } EntitySystem.Get().PlayFromEntity("/Audio/Items/pistol_magout.ogg", Owner); @@ -292,7 +292,7 @@ namespace Content.Server.GameObjects.Components.Interactable return; } - var cell = Owner.EntityManager.SpawnEntity("PowerCellSmallStandard", Owner.Transform.GridPosition); + var cell = Owner.EntityManager.SpawnEntity("PowerCellSmallStandard", Owner.Transform.Coordinates); _cellContainer.Insert(cell); } } diff --git a/Content.Server/GameObjects/Components/Interactable/TilePryingComponent.cs b/Content.Server/GameObjects/Components/Interactable/TilePryingComponent.cs index d474db9f37..9d88c4a0a2 100644 --- a/Content.Server/GameObjects/Components/Interactable/TilePryingComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/TilePryingComponent.cs @@ -1,5 +1,4 @@ -using Content.Server.GameObjects.EntitySystems.Click; -using Content.Shared.GameObjects.Components.Interactable; +using Content.Shared.GameObjects.Components.Interactable; using Content.Shared.Interfaces.GameObjects.Components; using Content.Shared.Maps; using Content.Shared.Utility; @@ -15,7 +14,6 @@ namespace Content.Server.GameObjects.Components.Interactable [RegisterComponent] public class TilePryingComponent : Component, IAfterInteract { - [Dependency] private readonly IEntitySystemManager _entitySystemManager = default!; [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!; [Dependency] private readonly IMapManager _mapManager = default!; @@ -33,12 +31,12 @@ namespace Content.Server.GameObjects.Components.Interactable serializer.DataField(ref _toolComponentNeeded, "toolComponentNeeded", true); } - public async void TryPryTile(IEntity user, GridCoordinates clickLocation) + public async void TryPryTile(IEntity user, EntityCoordinates clickLocation) { if (!Owner.TryGetComponent(out var tool) && _toolComponentNeeded) return; - var mapGrid = _mapManager.GetGrid(clickLocation.GridID); + var mapGrid = _mapManager.GetGrid(clickLocation.GetGridId(Owner.EntityManager)); var tile = mapGrid.GetTileRef(clickLocation); var coordinates = mapGrid.GridTileToLocal(tile.GridIndices); @@ -53,7 +51,7 @@ namespace Content.Server.GameObjects.Components.Interactable if (_toolComponentNeeded && !await tool!.UseTool(user, null, 0f, ToolQuality.Prying)) return; - coordinates.PryTile(_mapManager, _tileDefinitionManager, Owner.EntityManager); + coordinates.PryTile(Owner.EntityManager, _mapManager); } } } diff --git a/Content.Server/GameObjects/Components/Interactable/ToolCommands.cs b/Content.Server/GameObjects/Components/Interactable/ToolCommands.cs index 9dd07ff951..1c833051ad 100644 --- a/Content.Server/GameObjects/Components/Interactable/ToolCommands.cs +++ b/Content.Server/GameObjects/Components/Interactable/ToolCommands.cs @@ -49,7 +49,7 @@ namespace Content.Server.GameObjects.Components.Interactable var mapManager = IoCManager.Resolve(); var playerGrid = player.AttachedEntity.Transform.GridID; var mapGrid = mapManager.GetGrid(playerGrid); - var playerPosition = player.AttachedEntity.Transform.GridPosition; + var playerPosition = player.AttachedEntity.Transform.Coordinates; var tileDefinitionManager = IoCManager.Resolve(); for (var i = -radius; i <= radius; i++) diff --git a/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs b/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs index 68a347f8d5..eadd2adb0e 100644 --- a/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs @@ -201,7 +201,7 @@ namespace Content.Server.GameObjects.Components.Interactable PlaySoundCollection("WelderOn", -5); _welderSystem.Subscribe(this); - Owner.Transform.GridPosition + Owner.Transform.Coordinates .GetTileAtmosphere()?.HotspotExpose(700f, 50f, true); return true; @@ -243,7 +243,7 @@ namespace Content.Server.GameObjects.Components.Interactable _solutionComponent?.TryRemoveReagent("chem.WeldingFuel", ReagentUnit.New(FuelLossRate * frameTime)); - Owner.Transform.GridPosition + Owner.Transform.Coordinates .GetTileAtmosphere()?.HotspotExpose(700f, 50f, true); if (Fuel == 0) diff --git a/Content.Server/GameObjects/Components/Items/FloorTileItemComponent.cs b/Content.Server/GameObjects/Components/Items/FloorTileItemComponent.cs index d39515349f..2503662b8d 100644 --- a/Content.Server/GameObjects/Components/Items/FloorTileItemComponent.cs +++ b/Content.Server/GameObjects/Components/Items/FloorTileItemComponent.cs @@ -40,7 +40,7 @@ namespace Content.Server.GameObjects.Components.Items if (!Owner.TryGetComponent(out StackComponent stack)) return; var attacked = eventArgs.Target; - var mapGrid = _mapManager.GetGrid(eventArgs.ClickLocation.GridID); + var mapGrid = _mapManager.GetGrid(eventArgs.ClickLocation.GetGridId(Owner.EntityManager)); var tile = mapGrid.GetTileRef(eventArgs.ClickLocation); var tileDef = (ContentTileDefinition)_tileDefinitionManager[tile.Tile.TypeId]; diff --git a/Content.Server/GameObjects/Components/Items/RCD/RCDComponent.cs b/Content.Server/GameObjects/Components/Items/RCD/RCDComponent.cs index b685db4f10..d1719f232a 100644 --- a/Content.Server/GameObjects/Components/Items/RCD/RCDComponent.cs +++ b/Content.Server/GameObjects/Components/Items/RCD/RCDComponent.cs @@ -97,7 +97,7 @@ namespace Content.Server.GameObjects.Components.Items.RCD //No changing mode mid-RCD var startingMode = _mode; - var mapGrid = _mapManager.GetGrid(eventArgs.ClickLocation.GridID); + var mapGrid = _mapManager.GetGrid(eventArgs.ClickLocation.GetGridId(Owner.EntityManager)); var tile = mapGrid.GetTileRef(eventArgs.ClickLocation); var snapPos = mapGrid.SnapGridCellFor(eventArgs.ClickLocation, SnapGridOffset.Center); @@ -166,8 +166,8 @@ namespace Content.Server.GameObjects.Components.Items.RCD return false; } - var coordinates = mapGrid.GridTileToLocal(tile.GridIndices); - if (coordinates == GridCoordinates.InvalidGrid || !eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true)) + var coordinates = mapGrid.ToCoordinates(tile.GridIndices); + if (coordinates == EntityCoordinates.Invalid || !eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true)) { return false; } diff --git a/Content.Server/GameObjects/Components/Items/Storage/Fill/CustodialClosetFill.cs b/Content.Server/GameObjects/Components/Items/Storage/Fill/CustodialClosetFill.cs index 2138b1a780..b257da50c3 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/Fill/CustodialClosetFill.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/Fill/CustodialClosetFill.cs @@ -16,7 +16,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill void Spawn(string prototype) { - storage.Insert(Owner.EntityManager.SpawnEntity(prototype, Owner.Transform.GridPosition)); + storage.Insert(Owner.EntityManager.SpawnEntity(prototype, Owner.Transform.Coordinates)); } Spawn("MopItem"); diff --git a/Content.Server/GameObjects/Components/Items/Storage/Fill/EmergencyClosetFillComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/Fill/EmergencyClosetFillComponent.cs index f1e6deb10e..08f2cbdaa9 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/Fill/EmergencyClosetFillComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/Fill/EmergencyClosetFillComponent.cs @@ -18,7 +18,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill void Spawn(string prototype) { - storage.Insert(Owner.EntityManager.SpawnEntity(prototype, Owner.Transform.GridPosition)); + storage.Insert(Owner.EntityManager.SpawnEntity(prototype, Owner.Transform.Coordinates)); } if (random.Prob(0.4f)) diff --git a/Content.Server/GameObjects/Components/Items/Storage/Fill/MedkitFillComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/Fill/MedkitFillComponent.cs index 94dabf7576..283a6976b5 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/Fill/MedkitFillComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/Fill/MedkitFillComponent.cs @@ -18,7 +18,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill void Spawn(string prototype) { - storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.GridPosition)); + storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.Coordinates)); } Spawn("Brutepack"); diff --git a/Content.Server/GameObjects/Components/Items/Storage/Fill/StorageFillComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/Fill/StorageFillComponent.cs index 66b13739e1..ae309a1765 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/Fill/StorageFillComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/Fill/StorageFillComponent.cs @@ -34,7 +34,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill void Spawn(string prototype) { - storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.GridPosition)); + storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.Coordinates)); } foreach (var prototype in _contents) diff --git a/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolLockerFillComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolLockerFillComponent.cs index c3b1feca9f..6d6c6ecb68 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolLockerFillComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolLockerFillComponent.cs @@ -18,7 +18,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill void Spawn(string prototype) { - storage.Insert(Owner.EntityManager.SpawnEntity(prototype, Owner.Transform.GridPosition)); + storage.Insert(Owner.EntityManager.SpawnEntity(prototype, Owner.Transform.Coordinates)); } if (random.Prob(0.4f)) diff --git a/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxElectricalFillComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxElectricalFillComponent.cs index 39e74b5556..9e76c505ed 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxElectricalFillComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxElectricalFillComponent.cs @@ -21,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill void Spawn(string prototype) { - storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.GridPosition)); + storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.Coordinates)); } Spawn("Screwdriver"); diff --git a/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxEmergencyFillComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxEmergencyFillComponent.cs index 1dd6c7a882..3748d42ce3 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxEmergencyFillComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxEmergencyFillComponent.cs @@ -21,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill void Spawn(string prototype) { - storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.GridPosition)); + storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.Coordinates)); } Spawn("BreathMaskClothing"); diff --git a/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxGoldFillComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxGoldFillComponent.cs index 11f2a5bfbd..5fbbb069d2 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxGoldFillComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/Fill/ToolboxGoldFillComponent.cs @@ -21,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill void Spawn(string prototype) { - storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.GridPosition)); + storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.Coordinates)); } Spawn("GoldStack"); diff --git a/Content.Server/GameObjects/Components/Items/Storage/Fill/UtilityBeltClothingFillComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/Fill/UtilityBeltClothingFillComponent.cs index 9fe010fe8c..a304d84425 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/Fill/UtilityBeltClothingFillComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/Fill/UtilityBeltClothingFillComponent.cs @@ -18,7 +18,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill void Spawn(string prototype) { - storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.GridPosition)); + storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.Coordinates)); } Spawn("Crowbar"); diff --git a/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs index 265d925ad1..a55ff54cab 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs @@ -1,8 +1,6 @@ using Content.Server.GameObjects.Components.GUI; -using Content.Server.GameObjects.EntitySystems; using Content.Server.Interfaces.GameObjects.Components.Items; using Content.Server.Throw; -using Content.Server.Utility; using Content.Shared.GameObjects; using Content.Shared.GameObjects.Components.Items; using Content.Shared.GameObjects.EntitySystems; @@ -14,8 +12,6 @@ using Robust.Shared.Containers; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components; using Robust.Shared.Interfaces.GameObjects; -using Robust.Shared.Interfaces.Map; -using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Serialization; @@ -26,8 +22,6 @@ namespace Content.Server.GameObjects.Components.Items.Storage [ComponentReference(typeof(IItemComponent))] public class ItemComponent : StorableComponent, IInteractHand, IExAct, IEquipped, IUnequipped, IItemComponent { - [Dependency] private readonly IMapManager _mapManager = default!; - public override string Name => "Item"; public override uint? NetID => ContentNetIDs.ITEM; @@ -142,8 +136,8 @@ namespace Content.Server.GameObjects.Components.Items.Storage public void OnExplosion(ExplosionEventArgs eventArgs) { var sourceLocation = eventArgs.Source; - var targetLocation = eventArgs.Target.Transform.GridPosition; - var dirVec = (targetLocation.ToMapPos(_mapManager) - sourceLocation.ToMapPos(_mapManager)).Normalized; + var targetLocation = eventArgs.Target.Transform.Coordinates; + var dirVec = (targetLocation.ToMapPos(Owner.EntityManager) - sourceLocation.ToMapPos(Owner.EntityManager)).Normalized; var throwForce = 1.0f; diff --git a/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs index 6b8acac68a..6ec0c5ce35 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs @@ -365,7 +365,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage var ownerTransform = Owner.Transform; var playerTransform = player.Transform; - if (!playerTransform.GridPosition.InRange(_mapManager, ownerTransform.GridPosition, 2) || + if (!playerTransform.Coordinates.InRange(_entityManager, ownerTransform.Coordinates, 2) || !ownerTransform.IsMapTransform && !playerTransform.ContainsEntity(ownerTransform)) { diff --git a/Content.Server/GameObjects/Components/Kitchen/MicrowaveComponent.cs b/Content.Server/GameObjects/Components/Kitchen/MicrowaveComponent.cs index 56258a27f7..66c3eea090 100644 --- a/Content.Server/GameObjects/Components/Kitchen/MicrowaveComponent.cs +++ b/Content.Server/GameObjects/Components/Kitchen/MicrowaveComponent.cs @@ -339,7 +339,7 @@ namespace Content.Server.GameObjects.Components.Kitchen if (recipeToCook != null) { var entityToSpawn = goodMeal ? recipeToCook.Result : _badRecipeName; - _entityManager.SpawnEntity(entityToSpawn, Owner.Transform.GridPosition); + _entityManager.SpawnEntity(entityToSpawn, Owner.Transform.Coordinates); } } _audioSystem.PlayFromEntity(_cookingCompleteSound, Owner, AudioParams.Default.WithVolume(-1f)); diff --git a/Content.Server/GameObjects/Components/MachineLinking/SignalReceiverComponent.cs b/Content.Server/GameObjects/Components/MachineLinking/SignalReceiverComponent.cs index fcd03af914..23a386ff23 100644 --- a/Content.Server/GameObjects/Components/MachineLinking/SignalReceiverComponent.cs +++ b/Content.Server/GameObjects/Components/MachineLinking/SignalReceiverComponent.cs @@ -74,7 +74,7 @@ namespace Content.Server.GameObjects.Components.MachineLinking return true; } - if (transmitter.Range > 0 && !Owner.Transform.GridPosition.InRange(_mapManager, transmitter.Owner.Transform.GridPosition, transmitter.Range)) + if (transmitter.Range > 0 && !Owner.Transform.Coordinates.InRange(Owner.EntityManager, transmitter.Owner.Transform.Coordinates, transmitter.Range)) { Owner.PopupMessage(user, Loc.GetString("Out of range.")); return false; diff --git a/Content.Server/GameObjects/Components/MachineLinking/SignalTransmitterComponent.cs b/Content.Server/GameObjects/Components/MachineLinking/SignalTransmitterComponent.cs index d2df05bc3d..5ed69e2d74 100644 --- a/Content.Server/GameObjects/Components/MachineLinking/SignalTransmitterComponent.cs +++ b/Content.Server/GameObjects/Components/MachineLinking/SignalTransmitterComponent.cs @@ -98,7 +98,7 @@ namespace Content.Server.GameObjects.Components.MachineLinking foreach (var receiver in _receivers) { - if (Range > 0 && !Owner.Transform.GridPosition.InRange(_mapManager, receiver.Owner.Transform.GridPosition, Range)) + if (Range > 0 && !Owner.Transform.Coordinates.InRange(Owner.EntityManager, receiver.Owner.Transform.Coordinates, Range)) { continue; } diff --git a/Content.Server/GameObjects/Components/Markers/ConditionalSpawnerComponent.cs b/Content.Server/GameObjects/Components/Markers/ConditionalSpawnerComponent.cs index 1e22218ae8..adb46a368b 100644 --- a/Content.Server/GameObjects/Components/Markers/ConditionalSpawnerComponent.cs +++ b/Content.Server/GameObjects/Components/Markers/ConditionalSpawnerComponent.cs @@ -87,7 +87,7 @@ namespace Content.Server.GameObjects.Components.Markers } if(!Owner.Deleted) - _entityManager.SpawnEntity(_robustRandom.Pick(Prototypes), Owner.Transform.GridPosition); + _entityManager.SpawnEntity(_robustRandom.Pick(Prototypes), Owner.Transform.Coordinates); } public virtual void MapInit() diff --git a/Content.Server/GameObjects/Components/Markers/TimedSpawnerComponent.cs b/Content.Server/GameObjects/Components/Markers/TimedSpawnerComponent.cs index a374a35816..a223349e16 100644 --- a/Content.Server/GameObjects/Components/Markers/TimedSpawnerComponent.cs +++ b/Content.Server/GameObjects/Components/Markers/TimedSpawnerComponent.cs @@ -80,7 +80,7 @@ namespace Content.Server.GameObjects.Components.Markers for (int i = 0; i < number; i++) { var entity = _robustRandom.Pick(Prototypes); - _entityManager.SpawnEntity(entity, Owner.Transform.GridPosition); + _entityManager.SpawnEntity(entity, Owner.Transform.Coordinates); } } } diff --git a/Content.Server/GameObjects/Components/Markers/TrashSpawnerComponent.cs b/Content.Server/GameObjects/Components/Markers/TrashSpawnerComponent.cs index 1a193b4974..1235f2d6cb 100644 --- a/Content.Server/GameObjects/Components/Markers/TrashSpawnerComponent.cs +++ b/Content.Server/GameObjects/Components/Markers/TrashSpawnerComponent.cs @@ -42,7 +42,7 @@ namespace Content.Server.GameObjects.Components.Markers { if (RarePrototypes.Count > 0 && (RareChance == 1.0f || _robustRandom.Prob(RareChance))) { - _entityManager.SpawnEntity(_robustRandom.Pick(RarePrototypes), Owner.Transform.GridPosition); + _entityManager.SpawnEntity(_robustRandom.Pick(RarePrototypes), Owner.Transform.Coordinates); return; } @@ -64,7 +64,7 @@ namespace Content.Server.GameObjects.Components.Markers var x_negative = random.Prob(0.5f) ? -1 : 1; var y_negative = random.Prob(0.5f) ? -1 : 1; - var entity = _entityManager.SpawnEntity(_robustRandom.Pick(Prototypes), Owner.Transform.GridPosition); + var entity = _entityManager.SpawnEntity(_robustRandom.Pick(Prototypes), Owner.Transform.Coordinates); entity.Transform.LocalPosition += new Vector2(random.NextFloat() * Offset * x_negative, random.NextFloat() * Offset * y_negative); } diff --git a/Content.Server/GameObjects/Components/Mobs/MindComponent.cs b/Content.Server/GameObjects/Components/Mobs/MindComponent.cs index 9c199a2cd9..11bfa70cec 100644 --- a/Content.Server/GameObjects/Components/Mobs/MindComponent.cs +++ b/Content.Server/GameObjects/Components/Mobs/MindComponent.cs @@ -135,13 +135,14 @@ namespace Content.Server.GameObjects.Components.Mobs } else { - var spawnPosition = Owner.Transform.GridPosition; + var spawnPosition = Owner.Transform.Coordinates; Timer.Spawn(0, () => { // Async this so that we don't throw if the grid we're on is being deleted. var mapMan = IoCManager.Resolve(); - if (spawnPosition.GridID == GridId.Invalid || !mapMan.GridExists(spawnPosition.GridID)) + var gridId = spawnPosition.GetGridId(Owner.EntityManager); + if (gridId == GridId.Invalid || !mapMan.GridExists(gridId)) { spawnPosition = IoCManager.Resolve().GetObserverSpawnPoint(); } diff --git a/Content.Server/GameObjects/Components/Movement/AiControllerComponent.cs b/Content.Server/GameObjects/Components/Movement/AiControllerComponent.cs index dc651ef36c..a9603b64ae 100644 --- a/Content.Server/GameObjects/Components/Movement/AiControllerComponent.cs +++ b/Content.Server/GameObjects/Components/Movement/AiControllerComponent.cs @@ -151,7 +151,7 @@ namespace Content.Server.GameObjects.Components.Movement (Vector2 walking, Vector2 sprinting) IMoverComponent.VelocityDir => Sprinting ? (Vector2.Zero, VelocityDir) : (VelocityDir, Vector2.Zero); - public GridCoordinates LastPosition { get; set; } + public EntityCoordinates LastPosition { get; set; } [ViewVariables(VVAccess.ReadWrite)] public float StepSoundDistance { get; set; } diff --git a/Content.Server/GameObjects/Components/Movement/PlayerInputMoverComponent.cs b/Content.Server/GameObjects/Components/Movement/PlayerInputMoverComponent.cs index d3ba8882db..b5637c5eb2 100644 --- a/Content.Server/GameObjects/Components/Movement/PlayerInputMoverComponent.cs +++ b/Content.Server/GameObjects/Components/Movement/PlayerInputMoverComponent.cs @@ -12,7 +12,7 @@ namespace Content.Server.GameObjects.Components.Movement [ComponentReference(typeof(IMoverComponent))] public class PlayerInputMoverComponent : SharedPlayerInputMoverComponent { - public override GridCoordinates LastPosition { get; set; } + public override EntityCoordinates LastPosition { get; set; } public override float StepSoundDistance { get; set; } } diff --git a/Content.Server/GameObjects/Components/Movement/ServerPortalComponent.cs b/Content.Server/GameObjects/Components/Movement/ServerPortalComponent.cs index c80771c2de..ca948a52f7 100644 --- a/Content.Server/GameObjects/Components/Movement/ServerPortalComponent.cs +++ b/Content.Server/GameObjects/Components/Movement/ServerPortalComponent.cs @@ -183,15 +183,15 @@ namespace Content.Server.GameObjects.Components.Movement return; } - var position = _connectingTeleporter.Transform.GridPosition; + var position = _connectingTeleporter.Transform.Coordinates; var soundPlayer = EntitySystem.Get(); // Departure // Do we need to rate-limit sounds to stop ear BLAST? - soundPlayer.PlayAtCoords(_departureSound, entity.Transform.GridPosition); + soundPlayer.PlayAtCoords(_departureSound, entity.Transform.Coordinates); entity.Transform.AttachToGridOrMap(); - entity.Transform.GridPosition = position; - soundPlayer.PlayAtCoords(_arrivalSound, entity.Transform.GridPosition); + entity.Transform.Coordinates = position; + soundPlayer.PlayAtCoords(_arrivalSound, entity.Transform.Coordinates); TryChangeState(PortalState.RecentlyTeleported); // To stop spam teleporting. Could potentially look at adding a timer to flush this from the portal ImmuneEntities.Add(entity); diff --git a/Content.Server/GameObjects/Components/Movement/ServerTeleporterComponent.cs b/Content.Server/GameObjects/Components/Movement/ServerTeleporterComponent.cs index f731f04646..36c90fabf0 100644 --- a/Content.Server/GameObjects/Components/Movement/ServerTeleporterComponent.cs +++ b/Content.Server/GameObjects/Components/Movement/ServerTeleporterComponent.cs @@ -3,6 +3,7 @@ using System; using System.Linq; using Content.Shared.GameObjects.Components.Movement; using Content.Shared.Interfaces.GameObjects.Components; +using Content.Shared.Utility; using Robust.Server.GameObjects; using Robust.Server.GameObjects.EntitySystems; using Robust.Server.Interfaces.GameObjects; @@ -83,7 +84,7 @@ namespace Content.Server.GameObjects.Components.Movement { if (_teleporterType == TeleporterType.Directed) { - TryDirectedTeleport(eventArgs.User, eventArgs.ClickLocation.ToMap(_mapManager)); + TryDirectedTeleport(eventArgs.User, eventArgs.ClickLocation.ToMap(Owner.EntityManager)); } if (_teleporterType == TeleporterType.Random) @@ -164,13 +165,13 @@ namespace Content.Server.GameObjects.Components.Movement private Vector2 RandomEmptySpot(IEntity user, int range) { - Vector2 targetVector = user.Transform.GridPosition.Position; + Vector2 targetVector = user.Transform.Coordinates.Position; // Definitely a better way to do this foreach (var i in Enumerable.Range(0, 5)) { var randomRange = _spreadRandom.Next(0, range); var angle = Angle.FromDegrees(_spreadRandom.Next(0, 359)); - targetVector = user.Transform.GridPosition.Position + angle.ToVec() * randomRange; + targetVector = user.Transform.Coordinates.Position + angle.ToVec() * randomRange; if (EmptySpace(user, targetVector)) { return targetVector; @@ -201,7 +202,7 @@ namespace Content.Server.GameObjects.Components.Movement { var randomRange = _spreadRandom.Next(0, _range); var angle = Angle.FromDegrees(_spreadRandom.Next(0, 359)); - targetVector = user.Transform.GridPosition.Position + angle.ToVec() * randomRange; + targetVector = user.Transform.Coordinates.Position + angle.ToVec() * randomRange; } // Start / Continue if (_state == ItemTeleporterState.Off) @@ -222,7 +223,7 @@ namespace Content.Server.GameObjects.Components.Movement public void Teleport(IEntity user, Vector2 vector) { // Messy maybe? - var targetGrid = new GridCoordinates(vector, user.Transform.GridID); + var targetGrid = user.ToCoordinates(vector); var soundPlayer = EntitySystem.Get(); // If portals use those, otherwise just move em over @@ -230,7 +231,7 @@ namespace Content.Server.GameObjects.Components.Movement { // Call Delete here as the teleporter should have control over portal longevity // Departure portal - var departurePortal = _serverEntityManager.SpawnEntity("Portal", user.Transform.GridPosition); + var departurePortal = _serverEntityManager.SpawnEntity("Portal", user.Transform.Coordinates); departurePortal.TryGetComponent(out var departureComponent); // Arrival portal @@ -244,12 +245,12 @@ namespace Content.Server.GameObjects.Components.Movement else { // Departure - soundPlayer.PlayAtCoords(_departureSound, user.Transform.GridPosition); + soundPlayer.PlayAtCoords(_departureSound, user.Transform.Coordinates); // Arrival user.Transform.AttachToGridOrMap(); user.Transform.WorldPosition = vector; - soundPlayer.PlayAtCoords(_arrivalSound, user.Transform.GridPosition); + soundPlayer.PlayAtCoords(_arrivalSound, user.Transform.Coordinates); } } diff --git a/Content.Server/GameObjects/Components/Movement/ShuttleControllerComponent.cs b/Content.Server/GameObjects/Components/Movement/ShuttleControllerComponent.cs index e0b7f49f66..3475896dc3 100644 --- a/Content.Server/GameObjects/Components/Movement/ShuttleControllerComponent.cs +++ b/Content.Server/GameObjects/Components/Movement/ShuttleControllerComponent.cs @@ -58,7 +58,7 @@ namespace Content.Server.GameObjects.Components.Movement public bool Sprinting => false; public (Vector2 walking, Vector2 sprinting) VelocityDir { get; } = (Vector2.Zero, Vector2.Zero); - public GridCoordinates LastPosition { get; set; } + public EntityCoordinates LastPosition { get; set; } public float StepSoundDistance { get; set; } public void SetVelocityDirection(Direction direction, ushort subTick, bool enabled) diff --git a/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/AMENodeGroup.cs b/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/AMENodeGroup.cs index 93fcaae955..7ded82a3dc 100644 --- a/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/AMENodeGroup.cs +++ b/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/AMENodeGroup.cs @@ -144,7 +144,7 @@ namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups intensity = Math.Min(intensity, 8); - ExplosionHelper.SpawnExplosion(epicenter.Owner.Transform.GridPosition, intensity / 2, intensity, intensity * 2, intensity * 3); + ExplosionHelper.SpawnExplosion(epicenter.Owner.Transform.Coordinates, intensity / 2, intensity, intensity * 2, intensity * 3); } diff --git a/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs b/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs index b346108d1e..88b34282b8 100644 --- a/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs +++ b/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs @@ -202,7 +202,7 @@ namespace Content.Server.GameObjects.Components.Nutrition } //We're empty. Become trash. - var position = Owner.Transform.GridPosition; + var position = Owner.Transform.Coordinates; var finisher = Owner.EntityManager.SpawnEntity(_trashPrototype, position); // If the user is holding the item diff --git a/Content.Server/GameObjects/Components/Nutrition/FoodContainerComponent.cs b/Content.Server/GameObjects/Components/Nutrition/FoodContainerComponent.cs index 24fd20008d..ee766595f9 100644 --- a/Content.Server/GameObjects/Components/Nutrition/FoodContainerComponent.cs +++ b/Content.Server/GameObjects/Components/Nutrition/FoodContainerComponent.cs @@ -60,7 +60,7 @@ namespace Content.Server.GameObjects.Components.Nutrition return false; } - var itemToSpawn = _entityManager.SpawnEntity(GetRandomPrototype(), Owner.Transform.GridPosition); + var itemToSpawn = _entityManager.SpawnEntity(GetRandomPrototype(), Owner.Transform.Coordinates); handsComponent.PutInHandOrDrop(itemToSpawn.GetComponent()); _count--; if (_count < 1) diff --git a/Content.Server/GameObjects/Components/PDA/PDAComponent.cs b/Content.Server/GameObjects/Components/PDA/PDAComponent.cs index bf85b1274c..69b310edb1 100644 --- a/Content.Server/GameObjects/Components/PDA/PDAComponent.cs +++ b/Content.Server/GameObjects/Components/PDA/PDAComponent.cs @@ -72,7 +72,7 @@ namespace Content.Server.GameObjects.Components.PDA UserInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage; } - var idCard = _entityManager.SpawnEntity(_startingIdCard, Owner.Transform.GridPosition); + var idCard = _entityManager.SpawnEntity(_startingIdCard, Owner.Transform.Coordinates); var idCardComponent = idCard.GetComponent(); _idSlot.Insert(idCardComponent.Owner); ContainedID = idCardComponent; diff --git a/Content.Server/GameObjects/Components/Pointing/RoguePointingArrowComponent.cs b/Content.Server/GameObjects/Components/Pointing/RoguePointingArrowComponent.cs index f20f1305d5..8c25d37eb1 100644 --- a/Content.Server/GameObjects/Components/Pointing/RoguePointingArrowComponent.cs +++ b/Content.Server/GameObjects/Components/Pointing/RoguePointingArrowComponent.cs @@ -42,7 +42,7 @@ namespace Content.Server.GameObjects.Components.Pointing private IEntity? RandomNearbyPlayer() { var players = _playerManager - .GetPlayersInRange(Owner.Transform.GridPosition, 15) + .GetPlayersInRange(Owner.Transform.Coordinates, 15) .Where(player => player.AttachedEntity != null) .ToArray(); @@ -127,7 +127,7 @@ namespace Content.Server.GameObjects.Components.Pointing return; } - ExplosionHelper.SpawnExplosion(Owner.Transform.GridPosition, 0, 2, 1, 1); + ExplosionHelper.SpawnExplosion(Owner.Transform.Coordinates, 0, 2, 1, 1); EntitySystem.Get().PlayFromEntity("/Audio/Effects/explosion.ogg", Owner); Owner.Delete(); diff --git a/Content.Server/GameObjects/Components/PottedPlantHideComponent.cs b/Content.Server/GameObjects/Components/PottedPlantHideComponent.cs index bd7dd1a28b..f3747aa382 100644 --- a/Content.Server/GameObjects/Components/PottedPlantHideComponent.cs +++ b/Content.Server/GameObjects/Components/PottedPlantHideComponent.cs @@ -81,7 +81,7 @@ namespace Content.Server.GameObjects.Components } else if (_itemContainer.Remove(_itemContainer.ContainedEntity)) { - _itemContainer.ContainedEntity.Transform.GridPosition = Owner.Transform.GridPosition; + _itemContainer.ContainedEntity.Transform.Coordinates = Owner.Transform.Coordinates; } return true; diff --git a/Content.Server/GameObjects/Components/Power/AME/AMEPartComponent.cs b/Content.Server/GameObjects/Components/Power/AME/AMEPartComponent.cs index 9c07e21943..9dd4879e26 100644 --- a/Content.Server/GameObjects/Components/Power/AME/AMEPartComponent.cs +++ b/Content.Server/GameObjects/Components/Power/AME/AMEPartComponent.cs @@ -34,7 +34,7 @@ namespace Content.Server.GameObjects.Components.Power.AME if (activeHandEntity.TryGetComponent(out var multitool) && multitool.Qualities == ToolQuality.Multitool) { - var mapGrid = _mapManager.GetGrid(args.ClickLocation.GridID); + var mapGrid = _mapManager.GetGrid(args.ClickLocation.GetGridId(_serverEntityManager)); var tile = mapGrid.GetTileRef(args.ClickLocation); var snapPos = mapGrid.SnapGridCellFor(args.ClickLocation, SnapGridOffset.Center); diff --git a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerProviderComponent.cs b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerProviderComponent.cs index b0fcd57588..b6b59ad714 100644 --- a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerProviderComponent.cs +++ b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerProviderComponent.cs @@ -100,7 +100,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents .Where(receiver => receiver != null) .Where(receiver => receiver.Connectable) .Where(receiver => receiver.NeedsProvider) - .Where(receiver => receiver.Owner.Transform.GridPosition.Distance(_mapManager, Owner.Transform.GridPosition) < Math.Min(PowerTransferRange, receiver.PowerReceptionRange)) + .Where(receiver => receiver.Owner.Transform.Coordinates.TryDistance(_serverEntityManager, Owner.Transform.Coordinates, out var distance) && distance < Math.Min(PowerTransferRange, receiver.PowerReceptionRange)) .ToList(); } diff --git a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs index 2402c6ea51..bca4524740 100644 --- a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs +++ b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs @@ -128,11 +128,13 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents { if (provider.Connectable) { - var distanceToProvider = provider.Owner.Transform.GridPosition.Distance(_mapManager, Owner.Transform.GridPosition); - if (distanceToProvider < Math.Min(PowerReceptionRange, provider.PowerTransferRange)) + if (provider.Owner.Transform.Coordinates.TryDistance(_serverEntityManager, Owner.Transform.Coordinates, out var distance)) { - foundProvider = provider; - return true; + if (distance < Math.Min(PowerReceptionRange, provider.PowerTransferRange)) + { + foundProvider = provider; + return true; + } } } } diff --git a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/PoweredLightComponent.cs b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/PoweredLightComponent.cs index 4ac42d949e..152b4f4b60 100644 --- a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/PoweredLightComponent.cs +++ b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverUsers/PoweredLightComponent.cs @@ -168,7 +168,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece if (!user.TryGetComponent(out HandsComponent hands) || !hands.PutInHand(bulb.Owner.GetComponent())) - bulb.Owner.Transform.GridPosition = user.Transform.GridPosition; + bulb.Owner.Transform.Coordinates = user.Transform.Coordinates; } public override void ExposeData(ObjectSerializer serializer) @@ -267,7 +267,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece _ => throw new ArgumentOutOfRangeException() }; - var entity = Owner.EntityManager.SpawnEntity(prototype, Owner.Transform.GridPosition); + var entity = Owner.EntityManager.SpawnEntity(prototype, Owner.Transform.Coordinates); _lightBulbContainer.Insert(entity); } } diff --git a/Content.Server/GameObjects/Components/Power/WirePlacerComponent.cs b/Content.Server/GameObjects/Components/Power/WirePlacerComponent.cs index 5b79399c9d..d649f5033e 100644 --- a/Content.Server/GameObjects/Components/Power/WirePlacerComponent.cs +++ b/Content.Server/GameObjects/Components/Power/WirePlacerComponent.cs @@ -38,7 +38,7 @@ namespace Content.Server.GameObjects.Components.Power public void AfterInteract(AfterInteractEventArgs eventArgs) { if (!eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true)) return; - if(!_mapManager.TryGetGrid(eventArgs.ClickLocation.GridID, out var grid)) + if(!_mapManager.TryGetGrid(eventArgs.ClickLocation.GetGridId(_entityManager), out var grid)) return; var snapPos = grid.SnapGridCellFor(eventArgs.ClickLocation, SnapGridOffset.Center); var snapCell = grid.GetSnapGridCell(snapPos, SnapGridOffset.Center); diff --git a/Content.Server/GameObjects/Components/Projectiles/HitscanComponent.cs b/Content.Server/GameObjects/Components/Projectiles/HitscanComponent.cs index d3b56dde1b..091b582574 100644 --- a/Content.Server/GameObjects/Components/Projectiles/HitscanComponent.cs +++ b/Content.Server/GameObjects/Components/Projectiles/HitscanComponent.cs @@ -65,7 +65,7 @@ namespace Content.Server.GameObjects.Components.Projectiles _startTime = _gameTiming.CurTime; _deathTime = _startTime + TimeSpan.FromSeconds(1); - var afterEffect = AfterEffects(user.Transform.GridPosition, angle, distance, 1.0f); + var afterEffect = AfterEffects(user.Transform.Coordinates, angle, distance, 1.0f); if (afterEffect != null) { effectSystem.CreateParticle(afterEffect); @@ -80,7 +80,7 @@ namespace Content.Server.GameObjects.Components.Projectiles effectSystem.CreateParticle(impactEffect); } - var muzzleEffect = MuzzleFlash(user.Transform.GridPosition, angle); + var muzzleEffect = MuzzleFlash(user.Transform.Coordinates, angle); if (muzzleEffect != null) { effectSystem.CreateParticle(muzzleEffect); @@ -91,7 +91,7 @@ namespace Content.Server.GameObjects.Components.Projectiles { // TODO: No wall component so ? var offset = angle.ToVec().Normalized / 2; - EntitySystem.Get().PlayAtCoords(_soundHitWall, user.Transform.GridPosition.Translated(offset)); + EntitySystem.Get().PlayAtCoords(_soundHitWall, user.Transform.Coordinates.Offset(offset)); } Timer.Spawn((int) _deathTime.TotalMilliseconds, () => @@ -103,7 +103,7 @@ namespace Content.Server.GameObjects.Components.Projectiles }); } - private EffectSystemMessage MuzzleFlash(GridCoordinates grid, Angle angle) + private EffectSystemMessage MuzzleFlash(EntityCoordinates grid, Angle angle) { if (_muzzleFlash == null) { @@ -117,7 +117,7 @@ namespace Content.Server.GameObjects.Components.Projectiles EffectSprite = _muzzleFlash, Born = _startTime, DeathTime = _deathTime, - Coordinates = grid.Translated(offset), + Coordinates = grid.Offset(offset), //Rotated from east facing Rotation = (float) angle.Theta, Color = Vector4.Multiply(new Vector4(255, 255, 255, 750), ColorModifier), @@ -128,7 +128,7 @@ namespace Content.Server.GameObjects.Components.Projectiles return message; } - private EffectSystemMessage AfterEffects(GridCoordinates origin, Angle angle, float distance, float offset = 0.0f) + private EffectSystemMessage AfterEffects(EntityCoordinates origin, Angle angle, float distance, float offset = 0.0f) { var midPointOffset = angle.ToVec() * distance / 2; var message = new EffectSystemMessage @@ -137,7 +137,7 @@ namespace Content.Server.GameObjects.Components.Projectiles Born = _startTime, DeathTime = _deathTime, Size = new Vector2(distance - offset, 1f), - Coordinates = origin.Translated(midPointOffset), + Coordinates = origin.Offset(midPointOffset), //Rotated from east facing Rotation = (float) angle.Theta, Color = Vector4.Multiply(new Vector4(255, 255, 255, 750), ColorModifier), @@ -161,7 +161,7 @@ namespace Content.Server.GameObjects.Components.Projectiles EffectSprite = _impactFlash, Born = _startTime, DeathTime = _deathTime, - Coordinates = Owner.Transform.GridPosition.Translated(angle.ToVec() * distance), + Coordinates = Owner.Transform.Coordinates.Offset(angle.ToVec() * distance), //Rotated from east facing Rotation = (float) angle.FlipPositive(), Color = Vector4.Multiply(new Vector4(255, 255, 255, 750), ColorModifier), diff --git a/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs b/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs index e9dd0df848..3bfaf7d652 100644 --- a/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs +++ b/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs @@ -84,10 +84,10 @@ namespace Content.Server.GameObjects.Components.Projectiles if (_soundHitSpecies != null && entity.HasComponent()) { - EntitySystem.Get().PlayAtCoords(_soundHitSpecies, entity.Transform.GridPosition); + EntitySystem.Get().PlayAtCoords(_soundHitSpecies, entity.Transform.Coordinates); } else if (_soundHit != null) { - EntitySystem.Get().PlayAtCoords(_soundHit, entity.Transform.GridPosition); + EntitySystem.Get().PlayAtCoords(_soundHit, entity.Transform.Coordinates); } if (entity.TryGetComponent(out IDamageableComponent damage)) diff --git a/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs b/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs index df97af93e8..e3d2c73f04 100644 --- a/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs +++ b/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs @@ -74,7 +74,7 @@ namespace Content.Server.GameObjects.Components.Projectiles body.Status = BodyStatus.OnGround; Owner.RemoveComponent(); - EntitySystem.Get().LandInteraction(User, Owner, Owner.Transform.GridPosition); + EntitySystem.Get().LandInteraction(User, Owner, Owner.Transform.Coordinates); } } @@ -109,7 +109,7 @@ namespace Content.Server.GameObjects.Components.Projectiles return; } - if (IoCManager.Resolve().IsWeightless(Owner.Transform.GridPosition)) + if (IoCManager.Resolve().IsWeightless(Owner.Transform.Coordinates)) { StartStopTimer(); return; diff --git a/Content.Server/GameObjects/Components/Research/LatheComponent.cs b/Content.Server/GameObjects/Components/Research/LatheComponent.cs index be55677be9..257bdb7c8f 100644 --- a/Content.Server/GameObjects/Components/Research/LatheComponent.cs +++ b/Content.Server/GameObjects/Components/Research/LatheComponent.cs @@ -126,7 +126,7 @@ namespace Content.Server.GameObjects.Components.Research { Producing = false; _producingRecipe = null; - Owner.EntityManager.SpawnEntity(recipe.Result, Owner.Transform.GridPosition); + Owner.EntityManager.SpawnEntity(recipe.Result, Owner.Transform.Coordinates); UserInterface?.SendMessage(new LatheStoppedProducingRecipeMessage()); State = LatheState.Base; SetAppearance(LatheVisualState.Idle); diff --git a/Content.Server/GameObjects/Components/Rotatable/FlippableComponent.cs b/Content.Server/GameObjects/Components/Rotatable/FlippableComponent.cs index 4ebead529b..73cd6b2fbb 100644 --- a/Content.Server/GameObjects/Components/Rotatable/FlippableComponent.cs +++ b/Content.Server/GameObjects/Components/Rotatable/FlippableComponent.cs @@ -31,7 +31,7 @@ namespace Content.Server.GameObjects.Components.Rotatable return; } - Owner.EntityManager.SpawnEntity(_entity, Owner.Transform.GridPosition); + Owner.EntityManager.SpawnEntity(_entity, Owner.Transform.Coordinates); Owner.Delete(); } diff --git a/Content.Server/GameObjects/Components/Stack/StackComponent.cs b/Content.Server/GameObjects/Components/Stack/StackComponent.cs index a32ee539e3..79c17b0489 100644 --- a/Content.Server/GameObjects/Components/Stack/StackComponent.cs +++ b/Content.Server/GameObjects/Components/Stack/StackComponent.cs @@ -71,9 +71,9 @@ namespace Content.Server.GameObjects.Components.Stack stack.Add(toTransfer); var popupPos = eventArgs.ClickLocation; - if (popupPos == GridCoordinates.InvalidGrid) + if (popupPos == EntityCoordinates.Invalid) { - popupPos = eventArgs.User.Transform.GridPosition; + popupPos = eventArgs.User.Transform.Coordinates; } diff --git a/Content.Server/GameObjects/Components/StationEvents/RadiationPulseComponent.cs b/Content.Server/GameObjects/Components/StationEvents/RadiationPulseComponent.cs index da755bf91d..86dbe57a12 100644 --- a/Content.Server/GameObjects/Components/StationEvents/RadiationPulseComponent.cs +++ b/Content.Server/GameObjects/Components/StationEvents/RadiationPulseComponent.cs @@ -53,7 +53,7 @@ namespace Content.Server.GameObjects.Components.StationEvents } }); - EntitySystem.Get().PlayAtCoords("/Audio/Weapons/Guns/Gunshots/laser3.ogg", Owner.Transform.GridPosition); + EntitySystem.Get().PlayAtCoords("/Audio/Weapons/Guns/Gunshots/laser3.ogg", Owner.Transform.Coordinates); Dirty(); } diff --git a/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs b/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs index 363dbf98ac..5b5420b31e 100644 --- a/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs +++ b/Content.Server/GameObjects/Components/VendingMachines/VendingMachineComponent.cs @@ -188,7 +188,7 @@ namespace Content.Server.GameObjects.Components.VendingMachines { _ejecting = false; TrySetVisualState(VendingMachineVisualState.Normal); - Owner.EntityManager.SpawnEntity(id, Owner.Transform.GridPosition); + Owner.EntityManager.SpawnEntity(id, Owner.Transform.Coordinates); }); EntitySystem.Get().PlayFromEntity(_soundVend, Owner, AudioParams.Default.WithVolume(-2f)); diff --git a/Content.Server/GameObjects/Components/Weapon/FlashableComponent.cs b/Content.Server/GameObjects/Components/Weapon/FlashableComponent.cs index 4646c136c1..4ac0c3d026 100644 --- a/Content.Server/GameObjects/Components/Weapon/FlashableComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/FlashableComponent.cs @@ -31,7 +31,7 @@ namespace Content.Server.GameObjects.Components.Weapon public static void FlashAreaHelper(IEntity source, float range, float duration, string sound = null) { - foreach (var entity in IoCManager.Resolve().GetEntitiesInRange(source.Transform.GridPosition, range)) + foreach (var entity in IoCManager.Resolve().GetEntitiesInRange(source.Transform.Coordinates, range)) { if (!source.InRangeUnobstructed(entity, range, popup: true)) continue; @@ -42,7 +42,7 @@ namespace Content.Server.GameObjects.Components.Weapon if (!string.IsNullOrEmpty(sound)) { - IoCManager.Resolve().GetEntitySystem().PlayAtCoords(sound, source.Transform.GridPosition); + IoCManager.Resolve().GetEntitySystem().PlayAtCoords(sound, source.Transform.Coordinates); } } } diff --git a/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs b/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs index 580d1282ca..3ab0b8c28a 100644 --- a/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Melee/FlashComponent.cs @@ -83,7 +83,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee return false; } - foreach (var entity in _entityManager.GetEntitiesInRange(Owner.Transform.GridPosition, _range)) + foreach (var entity in _entityManager.GetEntitiesInRange(Owner.Transform.Coordinates, _range)) { Flash(entity, eventArgs.User, _aoeFlashDuration); } @@ -114,7 +114,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee }); } - EntitySystem.Get().PlayAtCoords("/Audio/Weapons/flash.ogg", Owner.Transform.GridPosition, + EntitySystem.Get().PlayAtCoords("/Audio/Weapons/flash.ogg", Owner.Transform.Coordinates, AudioParams.Default); return true; diff --git a/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs b/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs index ef2cf24729..77e6cdc879 100644 --- a/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Melee/MeleeWeaponComponent.cs @@ -8,7 +8,6 @@ using Robust.Server.GameObjects.EntitySystems; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; -using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Physics; using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; @@ -17,15 +16,12 @@ using Robust.Shared.Serialization; using Robust.Shared.ViewVariables; using Content.Shared.Damage; using Content.Shared.Interfaces.GameObjects.Components; -using Robust.Server.GameObjects; -using Robust.Shared.GameObjects.EntitySystemMessages; namespace Content.Server.GameObjects.Components.Weapon.Melee { [RegisterComponent] public class MeleeWeaponComponent : Component, IAttack { - [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IPhysicsManager _physicsManager = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; @@ -90,8 +86,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee if(curTime < _cooldownEnd) return true; - var location = eventArgs.User.Transform.GridPosition; - var angle = new Angle(eventArgs.ClickLocation.ToMapPos(_mapManager) - location.ToMapPos(_mapManager)); + var location = eventArgs.User.Transform.Coordinates; + var angle = new Angle(eventArgs.ClickLocation.ToMapPos(Owner.EntityManager) - location.ToMapPos(Owner.EntityManager)); // This should really be improved. GetEntitiesInArc uses pos instead of bounding boxes. var entities = ArcRayCast(eventArgs.User.Transform.WorldPosition, angle, eventArgs.User); @@ -150,8 +146,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee var target = eventArgs.TargetEntity; - var location = eventArgs.User.Transform.GridPosition; - var angle = new Angle(eventArgs.ClickLocation.ToMapPos(_mapManager) - location.ToMapPos(_mapManager)); + var location = eventArgs.User.Transform.Coordinates; + var angle = new Angle(eventArgs.ClickLocation.ToMapPos(Owner.EntityManager) - location.ToMapPos(Owner.EntityManager)); var audioSystem = EntitySystem.Get(); if (target != null) diff --git a/Content.Server/GameObjects/Components/Weapon/Melee/StunbatonComponent.cs b/Content.Server/GameObjects/Components/Weapon/Melee/StunbatonComponent.cs index 18e3e5c764..78d7c24bbd 100644 --- a/Content.Server/GameObjects/Components/Weapon/Melee/StunbatonComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Melee/StunbatonComponent.cs @@ -92,7 +92,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee if (!Cell.TryUseCharge(EnergyPerUse)) return true; - EntitySystem.Get().PlayAtCoords("/Audio/Weapons/egloves.ogg", Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f)); + EntitySystem.Get().PlayAtCoords("/Audio/Weapons/egloves.ogg", Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); foreach (var entity in entities) { @@ -112,7 +112,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee if (!(Cell.CurrentCharge < EnergyPerUse)) return true; - EntitySystem.Get().PlayAtCoords(AudioHelpers.GetRandomFileFromSoundCollection("sparks"), Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f)); + EntitySystem.Get().PlayAtCoords(AudioHelpers.GetRandomFileFromSoundCollection("sparks"), Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); TurnOff(); return true; @@ -142,7 +142,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee var sprite = Owner.GetComponent(); var item = Owner.GetComponent(); - EntitySystem.Get().PlayAtCoords(AudioHelpers.GetRandomFileFromSoundCollection("sparks"), Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f)); + EntitySystem.Get().PlayAtCoords(AudioHelpers.GetRandomFileFromSoundCollection("sparks"), Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); item.EquippedPrefix = "off"; sprite.LayerSetState(0, "stunbaton_off"); @@ -162,7 +162,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee if (cell == null) { - EntitySystem.Get().PlayAtCoords("/Audio/Machines/button.ogg", Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f)); + EntitySystem.Get().PlayAtCoords("/Audio/Machines/button.ogg", Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); Owner.PopupMessage(user, Loc.GetString("Cell missing...")); return; @@ -170,12 +170,12 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee if (cell.CurrentCharge < EnergyPerUse) { - EntitySystem.Get().PlayAtCoords("/Audio/Machines/button.ogg", Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f)); + EntitySystem.Get().PlayAtCoords("/Audio/Machines/button.ogg", Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); Owner.PopupMessage(user, Loc.GetString("Dead cell...")); return; } - EntitySystem.Get().PlayAtCoords(AudioHelpers.GetRandomFileFromSoundCollection("sparks"), Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f)); + EntitySystem.Get().PlayAtCoords(AudioHelpers.GetRandomFileFromSoundCollection("sparks"), Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); item.EquippedPrefix = "on"; sprite.LayerSetState(0, "stunbaton_on"); @@ -230,10 +230,10 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee if (!hands.PutInHand(cell.Owner.GetComponent())) { - cell.Owner.Transform.GridPosition = user.Transform.GridPosition; + cell.Owner.Transform.Coordinates = user.Transform.Coordinates; } - EntitySystem.Get().PlayAtCoords("/Audio/Items/pistol_magout.ogg", Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f)); + EntitySystem.Get().PlayAtCoords("/Audio/Items/pistol_magout.ogg", Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); } public void Examine(FormattedMessage message, bool inDetailsRange) @@ -251,7 +251,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee return; } - var cell = Owner.EntityManager.SpawnEntity("PowerCellSmallHyper", Owner.Transform.GridPosition); + var cell = Owner.EntityManager.SpawnEntity("PowerCellSmallHyper", Owner.Transform.Coordinates); _cellContainer.Insert(cell); } diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/AmmoBoxComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/AmmoBoxComponent.cs index f4843118b7..9c0b83af28 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/AmmoBoxComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/AmmoBoxComponent.cs @@ -89,7 +89,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition if (_unspawnedCount > 0) { - ammo = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.GridPosition); + ammo = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.Coordinates); _unspawnedCount--; } diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/AmmoComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/AmmoComponent.cs index 1cb559aeaa..b01f9a6a39 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/AmmoComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/AmmoComponent.cs @@ -7,6 +7,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.EntitySystemMessages; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; using Robust.Shared.Localization; @@ -26,6 +27,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition public class AmmoComponent : Component, IExamine { [Dependency] private readonly IGameTiming _gameTiming = default!; + [Dependency] private readonly IEntityManager _entityManager = default!; public override string Name => "Ammo"; public BallisticCaliber Caliber => _caliber; @@ -106,7 +108,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition } } - public IEntity TakeBullet(GridCoordinates spawnAtGrid, MapCoordinates spawnAtMap) + public IEntity TakeBullet(EntityCoordinates spawnAtGrid, MapCoordinates spawnAtMap) { if (_ammoIsProjectile) { @@ -124,7 +126,9 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition appearanceComponent.SetData(AmmoVisuals.Spent, true); } - var entity = spawnAtGrid.GridID != GridId.Invalid ? Owner.EntityManager.SpawnEntity(_projectileId, spawnAtGrid) : Owner.EntityManager.SpawnEntity(_projectileId, spawnAtMap); + var entity = spawnAtGrid.GetGridId(_entityManager) != GridId.Invalid + ? Owner.EntityManager.SpawnEntity(_projectileId, spawnAtGrid) + : Owner.EntityManager.SpawnEntity(_projectileId, spawnAtMap); DebugTools.AssertNotNull(entity); return entity; diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/RangedMagazineComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/RangedMagazineComponent.cs index 79f6121d3d..9c6d4c4d5d 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/RangedMagazineComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/RangedMagazineComponent.cs @@ -132,7 +132,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition else if (_unspawnedCount > 0) { _unspawnedCount--; - ammo = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.GridPosition); + ammo = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.Coordinates); } UpdateAppearance(); @@ -160,7 +160,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition var itemComponent = ammo.GetComponent(); if (!handsComponent.CanPutInHand(itemComponent)) { - ammo.Transform.GridPosition = eventArgs.User.Transform.GridPosition; + ammo.Transform.Coordinates = eventArgs.User.Transform.Coordinates; ServerRangedBarrelComponent.EjectCasing(ammo); } else diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/SpeedLoaderComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/SpeedLoaderComponent.cs index e5bd9de782..86c7ab25c7 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/SpeedLoaderComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Ammunition/SpeedLoaderComponent.cs @@ -139,7 +139,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition if (_unspawnedCount > 0) { - entity = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.GridPosition); + entity = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.Coordinates); _unspawnedCount--; } diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/BoltActionBarrelComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/BoltActionBarrelComponent.cs index 3755370ea7..2135a6879f 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/BoltActionBarrelComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/BoltActionBarrelComponent.cs @@ -72,7 +72,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels TryEjectChamber(); if (_soundBoltOpen != null) { - soundSystem.PlayAtCoords(_soundBoltOpen, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2)); + soundSystem.PlayAtCoords(_soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } } else @@ -80,7 +80,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels TryFeedChamber(); if (_soundBoltClosed != null) { - soundSystem.PlayAtCoords(_soundBoltClosed, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2)); + soundSystem.PlayAtCoords(_soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } } @@ -121,7 +121,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels if (_unspawnedCount > 0) { _unspawnedCount--; - var chamberEntity = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.GridPosition); + var chamberEntity = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.Coordinates); _chamberContainer.Insert(chamberEntity); } } @@ -186,7 +186,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels return _chamberContainer.ContainedEntity; } - public override IEntity TakeProjectile(GridCoordinates spawnAtGrid, MapCoordinates spawnAtMap) + public override IEntity TakeProjectile(EntityCoordinates spawnAtGrid, MapCoordinates spawnAtMap) { var chamberEntity = _chamberContainer.ContainedEntity; if (_autoCycle) @@ -229,7 +229,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels { if (_soundCycle != null) { - EntitySystem.Get().PlayAtCoords(_soundCycle, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2)); + EntitySystem.Get().PlayAtCoords(_soundCycle, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } } @@ -261,7 +261,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels _chamberContainer.Insert(ammo); if (_soundInsert != null) { - EntitySystem.Get().PlayAtCoords(_soundInsert, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2)); + EntitySystem.Get().PlayAtCoords(_soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } Dirty(); UpdateAppearance(); @@ -274,7 +274,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels _spawnedAmmo.Push(ammo); if (_soundInsert != null) { - EntitySystem.Get().PlayAtCoords(_soundInsert, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2)); + EntitySystem.Get().PlayAtCoords(_soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } Dirty(); UpdateAppearance(); @@ -338,7 +338,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels else if (_unspawnedCount > 0) { _unspawnedCount--; - var ammoEntity = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.GridPosition); + var ammoEntity = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.Coordinates); _chamberContainer.Insert(ammoEntity); return true; } diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/PumpBarrelComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/PumpBarrelComponent.cs index 9dd3d9c7b5..d1981567e3 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/PumpBarrelComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/PumpBarrelComponent.cs @@ -144,7 +144,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels return _chamberContainer.ContainedEntity; } - public override IEntity TakeProjectile(GridCoordinates spawnAtGrid, MapCoordinates spawnAtMap) + public override IEntity TakeProjectile(EntityCoordinates spawnAtGrid, MapCoordinates spawnAtMap) { var chamberEntity = _chamberContainer.ContainedEntity; if (!_manualCycle) @@ -181,7 +181,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels if (_unspawnedCount > 0) { _unspawnedCount--; - var ammoEntity = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.GridPosition); + var ammoEntity = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.Coordinates); _chamberContainer.Insert(ammoEntity); } @@ -189,7 +189,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels { if (_soundCycle != null) { - EntitySystem.Get().PlayAtCoords(_soundCycle, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2)); + EntitySystem.Get().PlayAtCoords(_soundCycle, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } } @@ -218,7 +218,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels UpdateAppearance(); if (_soundInsert != null) { - EntitySystem.Get().PlayAtCoords(_soundInsert, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2)); + EntitySystem.Get().PlayAtCoords(_soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } return true; } diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/RevolverBarrelComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/RevolverBarrelComponent.cs index 0430263cd0..8989462aab 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/RevolverBarrelComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/RevolverBarrelComponent.cs @@ -103,7 +103,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels for (var i = 0; i < _unspawnedCount; i++) { - var entity = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.GridPosition); + var entity = Owner.EntityManager.SpawnEntity(_fillPrototype, Owner.Transform.Coordinates); _ammoSlots[idx] = entity; _ammoContainer.Insert(entity); idx++; @@ -152,7 +152,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels _ammoContainer.Insert(entity); if (_soundInsert != null) { - EntitySystem.Get().PlayAtCoords(_soundInsert, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2)); + EntitySystem.Get().PlayAtCoords(_soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } Dirty(); @@ -182,7 +182,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels _currentSlot = random; if (_soundSpin != null) { - EntitySystem.Get().PlayAtCoords(_soundSpin, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2)); + EntitySystem.Get().PlayAtCoords(_soundSpin, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } Dirty(); } @@ -198,7 +198,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels /// /// /// - public override IEntity TakeProjectile(GridCoordinates spawnAtGrid, MapCoordinates spawnAtMap) + public override IEntity TakeProjectile(EntityCoordinates spawnAtGrid, MapCoordinates spawnAtMap) { var ammo = _ammoSlots[_currentSlot]; IEntity bullet = null; @@ -236,7 +236,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels { if (_soundEject != null) { - EntitySystem.Get().PlayAtCoords(_soundEject, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-1)); + EntitySystem.Get().PlayAtCoords(_soundEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-1)); } } diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerBatteryBarrelComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerBatteryBarrelComponent.cs index e6e6094dab..4e2545e507 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerBatteryBarrelComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerBatteryBarrelComponent.cs @@ -108,7 +108,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels _powerCellContainer = ContainerManagerComponent.Ensure($"{Name}-powercell-container", Owner, out var existing); if (!existing && _powerCellPrototype != null) { - var powerCellEntity = Owner.EntityManager.SpawnEntity(_powerCellPrototype, Owner.Transform.GridPosition); + var powerCellEntity = Owner.EntityManager.SpawnEntity(_powerCellPrototype, Owner.Transform.Coordinates); _powerCellContainer.Insert(powerCellEntity); } @@ -140,14 +140,14 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels var ammo = _ammoContainer.ContainedEntity; if (ammo == null) { - ammo = Owner.EntityManager.SpawnEntity(_ammoPrototype, Owner.Transform.GridPosition); + ammo = Owner.EntityManager.SpawnEntity(_ammoPrototype, Owner.Transform.Coordinates); _ammoContainer.Insert(ammo); } return ammo; } - public override IEntity TakeProjectile(GridCoordinates spawnAtGrid, MapCoordinates spawnAtMap) + public override IEntity TakeProjectile(EntityCoordinates spawnAtGrid, MapCoordinates spawnAtMap) { var powerCellEntity = _powerCellContainer.ContainedEntity; @@ -177,7 +177,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels else { entity = Owner.Transform.GridID != GridId.Invalid ? - Owner.EntityManager.SpawnEntity(_ammoPrototype, Owner.Transform.GridPosition) + Owner.EntityManager.SpawnEntity(_ammoPrototype, Owner.Transform.Coordinates) : Owner.EntityManager.SpawnEntity(_ammoPrototype, Owner.Transform.MapPosition); } @@ -222,7 +222,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels if (_soundPowerCellInsert != null) { - EntitySystem.Get().PlayAtCoords(_soundPowerCellInsert, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2)); + EntitySystem.Get().PlayAtCoords(_soundPowerCellInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } _powerCellContainer.Insert(entity); @@ -270,12 +270,12 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels if (!hands.PutInHand(cell.Owner.GetComponent())) { - cell.Owner.Transform.GridPosition = user.Transform.GridPosition; + cell.Owner.Transform.Coordinates = user.Transform.Coordinates; } if (_soundPowerCellEject != null) { - EntitySystem.Get().PlayAtCoords(_soundPowerCellEject, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2)); + EntitySystem.Get().PlayAtCoords(_soundPowerCellEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } return true; } diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerMagazineBarrelComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerMagazineBarrelComponent.cs index cdda71816d..7c83614cdc 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerMagazineBarrelComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerMagazineBarrelComponent.cs @@ -98,7 +98,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels TryEjectChamber(); if (_soundBoltOpen != null) { - soundSystem.PlayAtCoords(_soundBoltOpen, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2)); + soundSystem.PlayAtCoords(_soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } } else @@ -106,7 +106,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels TryFeedChamber(); if (_soundBoltClosed != null) { - soundSystem.PlayAtCoords(_soundBoltClosed, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2)); + soundSystem.PlayAtCoords(_soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } } @@ -197,7 +197,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels if (!existing && _magFillPrototype != null) { - var magEntity = Owner.EntityManager.SpawnEntity(_magFillPrototype, Owner.Transform.GridPosition); + var magEntity = Owner.EntityManager.SpawnEntity(_magFillPrototype, Owner.Transform.Coordinates); _magazineContainer.Insert(magEntity); } @@ -210,7 +210,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels return BoltOpen ? null : _chamberContainer.ContainedEntity; } - public override IEntity TakeProjectile(GridCoordinates spawnAtGrid, MapCoordinates spawnAtMap) + public override IEntity TakeProjectile(EntityCoordinates spawnAtGrid, MapCoordinates spawnAtMap) { if (BoltOpen) { @@ -239,7 +239,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels { if (_soundBoltOpen != null) { - soundSystem.PlayAtCoords(_soundBoltOpen, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-5)); + soundSystem.PlayAtCoords(_soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5)); } if (ContainerHelpers.TryGetContainer(Owner, out var container)) @@ -254,7 +254,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels { if (_soundRack != null) { - soundSystem.PlayAtCoords(_soundRack, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2)); + soundSystem.PlayAtCoords(_soundRack, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } } @@ -282,7 +282,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels { if (_soundBoltClosed != null) { - EntitySystem.Get().PlayAtCoords(_soundBoltClosed, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-5)); + EntitySystem.Get().PlayAtCoords(_soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5)); } Owner.PopupMessage(eventArgs.User, Loc.GetString("Bolt closed")); BoltOpen = false; @@ -337,7 +337,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels if (_soundAutoEject != null) { var soundSystem = EntitySystem.Get(); - soundSystem.PlayAtCoords(_soundAutoEject, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2)); + soundSystem.PlayAtCoords(_soundAutoEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } _magazineContainer.Remove(magazine); @@ -364,7 +364,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels _magazineContainer.Remove(mag); if (_soundMagEject != null) { - EntitySystem.Get().PlayAtCoords(_soundMagEject, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2)); + EntitySystem.Get().PlayAtCoords(_soundMagEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } if (user.TryGetComponent(out HandsComponent handsComponent)) @@ -403,7 +403,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels { if (_soundMagInsert != null) { - EntitySystem.Get().PlayAtCoords(_soundMagInsert, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2)); + EntitySystem.Get().PlayAtCoords(_soundMagInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } Owner.PopupMessage(eventArgs.User, Loc.GetString("Magazine inserted")); _magazineContainer.Insert(eventArgs.Using); diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs index 1ee780b0d9..01ecec0104 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs @@ -54,7 +54,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels private TimeSpan _lastFire; public abstract IEntity PeekAmmo(); - public abstract IEntity TakeProjectile(GridCoordinates spawnAtGrid, MapCoordinates spawnAtMap); + public abstract IEntity TakeProjectile(EntityCoordinates spawnAtGrid, MapCoordinates spawnAtMap); // Recoil / spray control private Angle _minAngle; @@ -224,16 +224,16 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels { if (_soundEmpty != null) { - soundSystem.PlayAtCoords(_soundEmpty, Owner.Transform.GridPosition); + soundSystem.PlayAtCoords(_soundEmpty, Owner.Transform.Coordinates); } return; } var ammo = PeekAmmo(); - var projectile = TakeProjectile(shooter.Transform.GridPosition, shooter.Transform.MapPosition); + var projectile = TakeProjectile(shooter.Transform.Coordinates, shooter.Transform.MapPosition); if (projectile == null) { - soundSystem.PlayAtCoords(_soundEmpty, Owner.Transform.GridPosition); + soundSystem.PlayAtCoords(_soundEmpty, Owner.Transform.Coordinates); return; } @@ -274,7 +274,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels throw new InvalidOperationException(); } - soundSystem.PlayAtCoords(_soundGunshot, Owner.Transform.GridPosition); + soundSystem.PlayAtCoords(_soundGunshot, Owner.Transform.Coordinates); _lastFire = _gameTiming.CurTime; return; @@ -309,7 +309,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels const float ejectOffset = 0.2f; var ammo = entity.GetComponent(); var offsetPos = (robustRandom.NextFloat() * ejectOffset, robustRandom.NextFloat() * ejectOffset); - entity.Transform.GridPosition = entity.Transform.GridPosition.Offset(offsetPos); + entity.Transform.Coordinates = entity.Transform.Coordinates.Offset(offsetPos); entity.Transform.LocalRotation = robustRandom.Pick(ejectDirections).ToAngle(); if (ammo.SoundCollectionEject == null || !playSound) @@ -324,7 +324,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels var soundCollection = prototypeManager.Index(ammo.SoundCollectionEject); var randomFile = robustRandom.Pick(soundCollection.PickFiles); - EntitySystem.Get().PlayAtCoords(randomFile, entity.Transform.GridPosition, AudioParams.Default.WithVolume(-1)); + EntitySystem.Get().PlayAtCoords(randomFile, entity.Transform.Coordinates, AudioParams.Default.WithVolume(-1)); } /// @@ -375,7 +375,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels else { projectile = - Owner.EntityManager.SpawnEntity(baseProjectile.Prototype.ID, Owner.Transform.GridPosition); + Owner.EntityManager.SpawnEntity(baseProjectile.Prototype.ID, Owner.Transform.Coordinates); } Angle projectileAngle; @@ -391,7 +391,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels var collidableComponent = projectile.GetComponent(); collidableComponent.Status = BodyStatus.InAir; - projectile.Transform.GridPosition = Owner.Transform.GridPosition; + projectile.Transform.Coordinates = Owner.Transform.Coordinates; var projectileComponent = projectile.GetComponent(); projectileComponent.IgnoreEntity(shooter); @@ -426,7 +426,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels /// private void FireHitscan(IEntity shooter, HitscanComponent hitscan, Angle angle) { - var ray = new CollisionRay(Owner.Transform.GridPosition.Position, angle.ToVec(), (int) hitscan.CollisionMask); + var ray = new CollisionRay(Owner.Transform.Coordinates.Position, angle.ToVec(), (int) hitscan.CollisionMask); var physicsManager = IoCManager.Resolve(); var rayCastResults = physicsManager.IntersectRay(Owner.Transform.MapID, ray, hitscan.MaxLength, shooter, false).ToList(); diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/ServerRangedWeaponComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/ServerRangedWeaponComponent.cs index f490be0c1a..e8ea1a012a 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/ServerRangedWeaponComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/ServerRangedWeaponComponent.cs @@ -166,10 +166,10 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged { var soundSystem = EntitySystem.Get(); soundSystem.PlayAtCoords("/Audio/Items/bikehorn.ogg", - Owner.Transform.GridPosition, AudioParams.Default, 5); + Owner.Transform.Coordinates, AudioParams.Default, 5); soundSystem.PlayAtCoords("/Audio/Weapons/Guns/Gunshots/bang.ogg", - Owner.Transform.GridPosition, AudioParams.Default, 5); + Owner.Transform.Coordinates, AudioParams.Default, 5); if (user.TryGetComponent(out IDamageableComponent health)) { diff --git a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs index 4f866d3348..f0a58dc39e 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs @@ -38,6 +38,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible */ [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; + [Dependency] private readonly IEntityManager _entityManager = default!; private PathfindingSystem _pathfindingSystem; @@ -160,7 +161,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible /// public bool CanAccess(IEntity entity, IEntity target, float range = 0.0f) { - var targetTile = _mapManager.GetGrid(target.Transform.GridID).GetTileRef(target.Transform.GridPosition); + var targetTile = _mapManager.GetGrid(target.Transform.GridID).GetTileRef(target.Transform.Coordinates); var targetNode = _pathfindingSystem.GetNode(targetTile); var collisionMask = 0; @@ -198,7 +199,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible return false; } - var entityTile = _mapManager.GetGrid(entity.Transform.GridID).GetTileRef(entity.Transform.GridPosition); + var entityTile = _mapManager.GetGrid(entity.Transform.GridID).GetTileRef(entity.Transform.Coordinates); var entityNode = _pathfindingSystem.GetNode(entityTile); var entityRegion = GetRegion(entityNode); var targetRegion = GetRegion(targetNode); @@ -408,7 +409,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible /// public PathfindingRegion GetRegion(IEntity entity) { - var entityTile = _mapManager.GetGrid(entity.Transform.GridID).GetTileRef(entity.Transform.GridPosition); + var entityTile = _mapManager.GetGrid(entity.Transform.GridID).GetTileRef(entity.Transform.Coordinates); var entityNode = _pathfindingSystem.GetNode(entityTile); return GetRegion(entityNode); } @@ -632,7 +633,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible { return; } - + if (!_regions.ContainsKey(chunk.GridId)) { _regions.Add(chunk.GridId, new Dictionary>()); @@ -714,7 +715,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible foreach (var node in region.Nodes) { - var nodeVector = grid.GridTileToLocal(node.TileRef.GridIndices).ToMapPos(_mapManager); + var nodeVector = grid.GridTileToLocal(node.TileRef.GridIndices).ToMapPos(_entityManager); debugRegionNodes.Add(nodeVector); } @@ -743,7 +744,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible foreach (var node in region.Nodes) { - var nodeVector = grid.GridTileToLocal(node.TileRef.GridIndices).ToMapPos(_mapManager); + var nodeVector = grid.GridTileToLocal(node.TileRef.GridIndices).ToMapPos(_entityManager); debugResult[_runningCacheIdx].Add(nodeVector); } diff --git a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/PathfindingSystem.cs b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/PathfindingSystem.cs index ff672ee634..44e868cea1 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/PathfindingSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/PathfindingSystem.cs @@ -30,6 +30,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding public class PathfindingSystem : EntitySystem { [Dependency] private readonly IMapManager _mapManager = default!; + [Dependency] private readonly IEntityManager _entityManager = default!; public IReadOnlyDictionary> Graph => _graph; private readonly Dictionary> _graph = new Dictionary>(); @@ -180,7 +181,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding /// public PathfindingNode GetNode(IEntity entity) { - var tile = _mapManager.GetGrid(entity.Transform.GridID).GetTileRef(entity.Transform.GridPosition); + var tile = _mapManager.GetGrid(entity.Transform.GridID).GetTileRef(entity.Transform.Coordinates); return GetNode(tile); } @@ -280,7 +281,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding } var grid = _mapManager.GetGrid(entity.Transform.GridID); - var tileRef = grid.GetTileRef(entity.Transform.GridPosition); + var tileRef = grid.GetTileRef(entity.Transform.Coordinates); var chunk = GetChunk(tileRef); var node = chunk.GetNode(tileRef); @@ -337,7 +338,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding // The pathfinding graph is tile-based so first we'll check if they're on a different tile and if we need to update. // If you get entities bigger than 1 tile wide you'll need some other system so god help you. - var newTile = _mapManager.GetGrid(moveEvent.NewPosition.GridID).GetTileRef(moveEvent.NewPosition); + var newTile = _mapManager.GetGrid(moveEvent.NewPosition.GetGridId(_entityManager)).GetTileRef(moveEvent.NewPosition); if (oldNode == null || oldNode.TileRef == newTile) { @@ -359,9 +360,10 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding // TODO: Need to rethink the pathfinder utils (traversable etc.). Maybe just chuck them all in PathfindingSystem // Otherwise you get the steerer using this and the pathfinders using a different traversable. // Also look at increasing tile cost the more physics entities are on it - public bool CanTraverse(IEntity entity, GridCoordinates grid) + public bool CanTraverse(IEntity entity, EntityCoordinates coordinates) { - var tile = _mapManager.GetGrid(grid.GridID).GetTileRef(grid); + var gridId = coordinates.GetGridId(_entityManager); + var tile = _mapManager.GetGrid(gridId).GetTileRef(coordinates); var node = GetNode(tile); return CanTraverse(entity, node); } diff --git a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/ServerPathfindingDebugSystem.cs b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/ServerPathfindingDebugSystem.cs index cc93480280..18d1c97a45 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/ServerPathfindingDebugSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/ServerPathfindingDebugSystem.cs @@ -35,16 +35,16 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding foreach (var tile in routeDebug.Route) { var tileGrid = mapManager.GetGrid(tile.GridIndex).GridTileToLocal(tile.GridIndices); - route.Add(mapManager.GetGrid(tile.GridIndex).LocalToWorld(tileGrid).Position); + route.Add(tileGrid.ToMapPos(EntityManager)); } var cameFrom = new Dictionary(); foreach (var (from, to) in routeDebug.CameFrom) { var tileOneGrid = mapManager.GetGrid(from.GridIndex).GridTileToLocal(from.GridIndices); - var tileOneWorld = mapManager.GetGrid(from.GridIndex).LocalToWorld(tileOneGrid).Position; + var tileOneWorld = tileOneGrid.ToMapPos(EntityManager); var tileTwoGrid = mapManager.GetGrid(to.GridIndex).GridTileToLocal(to.GridIndices); - var tileTwoWorld = mapManager.GetGrid(to.GridIndex).LocalToWorld(tileTwoGrid).Position; + var tileTwoWorld = tileTwoGrid.ToMapPos(EntityManager); cameFrom.Add(tileOneWorld, tileTwoWorld); } @@ -52,7 +52,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding foreach (var (tile, score) in routeDebug.GScores) { var tileGrid = mapManager.GetGrid(tile.GridIndex).GridTileToLocal(tile.GridIndices); - gScores.Add(mapManager.GetGrid(tile.GridIndex).LocalToWorld(tileGrid).Position, score); + gScores.Add(tileGrid.ToMapPos(EntityManager), score); } var systemMessage = new SharedAiDebug.AStarRouteMessage( @@ -73,14 +73,14 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding foreach (var tile in routeDebug.Route) { var tileGrid = mapManager.GetGrid(tile.GridIndex).GridTileToLocal(tile.GridIndices); - route.Add(mapManager.GetGrid(tile.GridIndex).LocalToWorld(tileGrid).Position); + route.Add(tileGrid.ToMapPos(EntityManager)); } var jumpNodes = new List(); foreach (var tile in routeDebug.JumpNodes) { var tileGrid = mapManager.GetGrid(tile.GridIndex).GridTileToLocal(tile.GridIndices); - jumpNodes.Add(mapManager.GetGrid(tile.GridIndex).LocalToWorld(tileGrid).Position); + jumpNodes.Add(tileGrid.ToMapPos(EntityManager)); } var systemMessage = new SharedAiDebug.JpsRouteMessage( diff --git a/Content.Server/GameObjects/EntitySystems/AI/Steering/AiSteeringSystem.cs b/Content.Server/GameObjects/EntitySystems/AI/Steering/AiSteeringSystem.cs index 2d852011b0..55a7415b28 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Steering/AiSteeringSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Steering/AiSteeringSystem.cs @@ -25,8 +25,9 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering public sealed class AiSteeringSystem : EntitySystem { // http://www.red3d.com/cwr/papers/1999/gdc99steer.html for a steering overview - [Dependency] private IMapManager _mapManager = default!; - [Dependency] private IPauseManager _pauseManager = default!; + [Dependency] private readonly IMapManager _mapManager = default!; + [Dependency] private readonly IPauseManager _pauseManager = default!; + [Dependency] private readonly IEntityManager _entityManager = default!; private PathfindingSystem _pathfindingSystem; @@ -57,7 +58,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering private int _listIndex; // Cache nextGrid - private readonly Dictionary _nextGrid = new Dictionary(); + private readonly Dictionary _nextGrid = new Dictionary(); /// /// Current live paths for AI @@ -78,11 +79,11 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering /// /// Get a fixed position for the target entity; if they move then re-path /// - private readonly Dictionary _entityTargetPosition = new Dictionary(); + private readonly Dictionary _entityTargetPosition = new Dictionary(); // Anti-Stuck // Given the collision avoidance can lead to twitching need to store a reference position and check if we've been near this too long - private readonly Dictionary _stuckPositions = new Dictionary(); + private readonly Dictionary _stuckPositions = new Dictionary(); public override void Initialize() { @@ -268,7 +269,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering // Validation // Check if we can even arrive -> Currently only samegrid movement supported - if (entity.Transform.GridID != steeringRequest.TargetGrid.GridID) + if (entity.Transform.GridID != steeringRequest.TargetGrid.GetGridId(_entityManager)) { controller.VelocityDir = Vector2.Zero; return SteeringStatus.NoPath; @@ -413,7 +414,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering var cancelToken = new CancellationTokenSource(); var gridManager = _mapManager.GetGrid(entity.Transform.GridID); - var startTile = gridManager.GetTileRef(entity.Transform.GridPosition); + var startTile = gridManager.GetTileRef(entity.Transform.Coordinates); var endTile = gridManager.GetTileRef(steeringRequest.TargetGrid); var collisionMask = 0; if (entity.TryGetComponent(out ICollidableComponent collidableComponent)) @@ -443,7 +444,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering { _pathfindingRequests.Remove(entity); - var entityTile = _mapManager.GetGrid(entity.Transform.GridID).GetTileRef(entity.Transform.GridPosition); + var entityTile = _mapManager.GetGrid(entity.Transform.GridID).GetTileRef(entity.Transform.Coordinates); var tile = path.Dequeue(); var closestDistance = PathfindingHelpers.OctileDistance(entityTile, tile); @@ -465,12 +466,12 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering } /// - /// Get the next tile as GridCoordinates + /// Get the next tile as EntityCoordinates /// /// /// /// - private GridCoordinates? NextGrid(IEntity entity, IAiSteeringRequest steeringRequest) + private EntityCoordinates? NextGrid(IEntity entity, IAiSteeringRequest steeringRequest) { // Remove the cached grid if (!_paths.ContainsKey(entity) && _nextGrid.ContainsKey(entity)) @@ -481,7 +482,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering // If no tiles left just move towards the target (if we're close) if (!_paths.ContainsKey(entity) || _paths[entity].Count == 0) { - if ((steeringRequest.TargetGrid.Position - entity.Transform.GridPosition.Position).Length <= 2.0f) + if ((steeringRequest.TargetGrid.Position - entity.Transform.Coordinates.Position).Length <= 2.0f) { return steeringRequest.TargetGrid; } @@ -491,7 +492,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering } if (!_nextGrid.TryGetValue(entity, out var nextGrid) || - (nextGrid.Position - entity.Transform.GridPosition.Position).Length <= TileTolerance) + (nextGrid.Position - entity.Transform.Coordinates.Position).Length <= TileTolerance) { UpdateGridCache(entity); nextGrid = _nextGrid[entity]; @@ -502,7 +503,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering } /// - /// Rather than converting TileRef to GridCoordinates over and over we'll just cache it + /// Rather than converting TileRef to EntityCoordinates over and over we'll just cache it /// /// /// @@ -515,19 +516,19 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering } /// - /// Check if we've been near our last GridCoordinates too long and try to fix it + /// Check if we've been near our last EntityCoordinates too long and try to fix it /// /// private void HandleStuck(IEntity entity) { if (!_stuckPositions.TryGetValue(entity, out var stuckPosition)) { - _stuckPositions[entity] = entity.Transform.GridPosition; + _stuckPositions[entity] = entity.Transform.Coordinates; _stuckCounter[entity] = 0; return; } - if ((entity.Transform.GridPosition.Position - stuckPosition.Position).Length <= 1.0f) + if ((entity.Transform.Coordinates.Position - stuckPosition.Position).Length <= 1.0f) { _stuckCounter.TryGetValue(entity, out var stuckCount); _stuckCounter[entity] = stuckCount + 1; @@ -535,7 +536,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering else { // No longer stuck - _stuckPositions[entity] = entity.Transform.GridPosition; + _stuckPositions[entity] = entity.Transform.Coordinates; _stuckCounter[entity] = 0; return; } @@ -558,11 +559,13 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering /// /// /// - private Vector2 Seek(IEntity entity, GridCoordinates grid) + private Vector2 Seek(IEntity entity, EntityCoordinates grid) { // is-even much - var entityPos = entity.Transform.GridPosition; - return entityPos == grid ? Vector2.Zero : (grid.Position - entityPos.Position).Normalized; + var entityPos = entity.Transform.Coordinates; + return entityPos == grid + ? Vector2.Zero + : (grid.Position - entityPos.Position).Normalized; } /// @@ -572,9 +575,9 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering /// /// /// - private Vector2 Arrival(IEntity entity, GridCoordinates grid, float slowingDistance = 1.0f) + private Vector2 Arrival(IEntity entity, EntityCoordinates grid, float slowingDistance = 1.0f) { - var entityPos = entity.Transform.GridPosition; + var entityPos = entity.Transform.Coordinates; DebugTools.Assert(slowingDistance > 0.0f); if (entityPos == grid) { @@ -593,8 +596,8 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering /// private Vector2 Pursuit(IEntity entity, IEntity target) { - var entityPos = entity.Transform.GridPosition; - var targetPos = target.Transform.GridPosition; + var entityPos = entity.Transform.Coordinates; + var targetPos = target.Transform.Coordinates; if (entityPos == targetPos) { return Vector2.Zero; @@ -630,7 +633,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering var avoidanceVector = Vector2.Zero; var checkTiles = new HashSet(); var avoidTiles = new HashSet(); - var entityGridCoords = entity.Transform.GridPosition; + var entityGridCoords = entity.Transform.Coordinates; var grid = _mapManager.GetGrid(entity.Transform.GridID); var currentTile = grid.GetTileRef(entityGridCoords); var halfwayTile = grid.GetTileRef(entityGridCoords.Offset(direction / 2)); @@ -665,7 +668,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering continue; } - var centerGrid = physicsEntity.Transform.GridPosition; + var centerGrid = physicsEntity.Transform.Coordinates; // Check how close we are to center of tile and get the inverse; if we're closer this is stronger var additionalVector = (centerGrid.Position - entityGridCoords.Position); var distance = additionalVector.Length; diff --git a/Content.Server/GameObjects/EntitySystems/AI/Steering/EntityTargetSteeringRequest.cs b/Content.Server/GameObjects/EntitySystems/AI/Steering/EntityTargetSteeringRequest.cs index 06da9d3bda..e0c8651744 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Steering/EntityTargetSteeringRequest.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Steering/EntityTargetSteeringRequest.cs @@ -7,16 +7,16 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering { public SteeringStatus Status { get; set; } = SteeringStatus.Pending; public MapCoordinates TargetMap => _target.Transform.MapPosition; - public GridCoordinates TargetGrid => _target.Transform.GridPosition; + public EntityCoordinates TargetGrid => _target.Transform.Coordinates; public IEntity Target => _target; private IEntity _target; /// public float ArrivalDistance { get; } - + /// public float PathfindingProximity { get; } - + /// /// How far the target can move before we re-path /// @@ -24,12 +24,12 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering /// public bool RequiresInRangeUnobstructed { get; } - + /// /// To avoid spamming InRangeUnobstructed we'll apply a cd to it. /// public float TimeUntilInteractionCheck { get; set; } - + public EntityTargetSteeringRequest(IEntity target, float arrivalDistance, float pathfindingProximity = 0.5f, bool requiresInRangeUnobstructed = false) { _target = target; @@ -38,4 +38,4 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering RequiresInRangeUnobstructed = requiresInRangeUnobstructed; } } -} \ No newline at end of file +} diff --git a/Content.Server/GameObjects/EntitySystems/AI/Steering/GridTargetSteeringRequest.cs b/Content.Server/GameObjects/EntitySystems/AI/Steering/GridTargetSteeringRequest.cs index 7a0efe74a7..1478595930 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Steering/GridTargetSteeringRequest.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Steering/GridTargetSteeringRequest.cs @@ -1,3 +1,4 @@ +using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Map; using Robust.Shared.IoC; using Robust.Shared.Map; @@ -8,7 +9,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering { public SteeringStatus Status { get; set; } = SteeringStatus.Pending; public MapCoordinates TargetMap { get; } - public GridCoordinates TargetGrid { get; } + public EntityCoordinates TargetGrid { get; } /// public float ArrivalDistance { get; } /// @@ -19,15 +20,15 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering public float TimeUntilInteractionCheck { get; set; } = 0.0f; - public GridTargetSteeringRequest(GridCoordinates targetGrid, float arrivalDistance, float pathfindingProximity = 0.5f, bool requiresInRangeUnobstructed = false) + public GridTargetSteeringRequest(EntityCoordinates targetGrid, float arrivalDistance, float pathfindingProximity = 0.5f, bool requiresInRangeUnobstructed = false) { // Get it once up front so we the manager doesn't have to continuously get it - var mapManager = IoCManager.Resolve(); - TargetMap = targetGrid.ToMap(mapManager); + var entityManager = IoCManager.Resolve(); + TargetMap = targetGrid.ToMap(entityManager); TargetGrid = targetGrid; ArrivalDistance = arrivalDistance; PathfindingProximity = pathfindingProximity; RequiresInRangeUnobstructed = requiresInRangeUnobstructed; } } -} \ No newline at end of file +} diff --git a/Content.Server/GameObjects/EntitySystems/AI/Steering/IAiSteeringRequest.cs b/Content.Server/GameObjects/EntitySystems/AI/Steering/IAiSteeringRequest.cs index 264c675b2c..bfe9ff15ab 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Steering/IAiSteeringRequest.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Steering/IAiSteeringRequest.cs @@ -6,25 +6,25 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering { SteeringStatus Status { get; set; } MapCoordinates TargetMap { get; } - GridCoordinates TargetGrid { get; } + EntityCoordinates TargetGrid { get; } /// /// How close we have to get before we've arrived /// float ArrivalDistance { get; } - + /// /// How close the pathfinder needs to get. Typically you want this set lower than ArrivalDistance /// float PathfindingProximity { get; } - + /// /// If we need LOS on the entity first before interaction /// bool RequiresInRangeUnobstructed { get; } - + /// /// To avoid spamming InRangeUnobstructed we'll apply a cd to it. /// public float TimeUntilInteractionCheck { get; set; } } -} \ No newline at end of file +} diff --git a/Content.Server/GameObjects/EntitySystems/Atmos/GasTileOverlaySystem.cs b/Content.Server/GameObjects/EntitySystems/Atmos/GasTileOverlaySystem.cs index 41f2c4f4fc..f3392ea51c 100644 --- a/Content.Server/GameObjects/EntitySystems/Atmos/GasTileOverlaySystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Atmos/GasTileOverlaySystem.cs @@ -207,7 +207,7 @@ namespace Content.Server.GameObjects.EntitySystems.Atmos continue; } - var entityTile = grid.GetTileRef(entity.Transform.GridPosition).GridIndices; + var entityTile = grid.GetTileRef(entity.Transform.Coordinates).GridIndices; for (var x = -maxXDiff; x <= maxXDiff; x++) { diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs index 2fd492635f..7537377f95 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs @@ -6,7 +6,6 @@ using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Movement; using Content.Server.GameObjects.Components.Timing; using Content.Server.Interfaces.GameObjects.Components.Items; -using Content.Server.Utility; using Content.Shared.GameObjects.Components.Inventory; using Content.Shared.GameObjects.EntitySystemMessages; using Content.Shared.GameObjects.EntitySystems; @@ -40,6 +39,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click public sealed class InteractionSystem : SharedInteractionSystem { [Dependency] private readonly IMapManager _mapManager = default!; + [Dependency] private readonly IEntityManager _entityManager = default!; public override void Initialize() { @@ -94,7 +94,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click } } - private bool HandleActivateItemInWorld(ICommonSession session, GridCoordinates coords, EntityUid uid) + private bool HandleActivateItemInWorld(ICommonSession session, EntityCoordinates coords, EntityUid uid) { if (!EntityManager.TryGetEntity(uid, out var used)) return false; @@ -106,7 +106,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click return false; } - if (!playerEnt.Transform.GridPosition.InRange(_mapManager, used.Transform.GridPosition, InteractionRange)) + if (!playerEnt.Transform.Coordinates.InRange(EntityManager, used.Transform.Coordinates, InteractionRange)) { return false; } @@ -151,10 +151,10 @@ namespace Content.Server.GameObjects.EntitySystems.Click } } - private bool HandleWideAttack(ICommonSession session, GridCoordinates coords, EntityUid uid) + private bool HandleWideAttack(ICommonSession session, EntityCoordinates coords, EntityUid uid) { // client sanitization - if (!_mapManager.GridExists(coords.GridID)) + if (!_mapManager.GridExists(coords.GetGridId(_entityManager))) { Logger.InfoS("system.interaction", $"Invalid Coordinates: client={session}, coords={coords}"); return true; @@ -189,7 +189,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click /// /// /// - internal void UseItemInHand(IEntity entity, GridCoordinates coords, EntityUid uid) + internal void UseItemInHand(IEntity entity, EntityCoordinates coords, EntityUid uid) { if (entity.HasComponent()) { @@ -206,10 +206,10 @@ namespace Content.Server.GameObjects.EntitySystems.Click } } - private bool HandleClientUseItemInHand(ICommonSession session, GridCoordinates coords, EntityUid uid) + private bool HandleClientUseItemInHand(ICommonSession session, EntityCoordinates coords, EntityUid uid) { // client sanitization - if (!_mapManager.GridExists(coords.GridID)) + if (!_mapManager.GridExists(coords.GetGridId(_entityManager))) { Logger.InfoS("system.interaction", $"Invalid Coordinates: client={session}, coords={coords}"); return true; @@ -237,10 +237,10 @@ namespace Content.Server.GameObjects.EntitySystems.Click return true; } - private bool HandleTryPullObject(ICommonSession session, GridCoordinates coords, EntityUid uid) + private bool HandleTryPullObject(ICommonSession session, EntityCoordinates coords, EntityUid uid) { // client sanitization - if (!_mapManager.GridExists(coords.GridID)) + if (!_mapManager.GridExists(coords.GetGridId(_entityManager))) { Logger.InfoS("system.interaction", $"Invalid Coordinates for pulling: client={session}, coords={coords}"); return false; @@ -282,7 +282,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click return false; } - var dist = player.Transform.GridPosition.Position - pulledObject.Transform.GridPosition.Position; + var dist = player.Transform.Coordinates.Position - pulledObject.Transform.Coordinates.Position; if (dist.LengthSquared > InteractionRangeSquared) { return false; @@ -308,7 +308,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click return false; } - private void UserInteraction(IEntity player, GridCoordinates coordinates, EntityUid clickedUid) + private void UserInteraction(IEntity player, EntityCoordinates coordinates, EntityUid clickedUid) { // Get entity clicked upon from UID if valid UID, if not assume no entity clicked upon and null if (!EntityManager.TryGetEntity(clickedUid, out var attacked)) @@ -323,7 +323,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click } // Verify player is on the same map as the entity he clicked on - if (_mapManager.GetGrid(coordinates.GridID).ParentMapId != playerTransform.MapID) + if (_mapManager.GetGrid(coordinates.GetGridId(EntityManager)).ParentMapId != playerTransform.MapID) { Logger.WarningS("system.interaction", $"Player named {player.Name} clicked on a map he isn't located on"); @@ -340,7 +340,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click if (ActionBlockerSystem.CanChangeDirection(player)) { - var diff = coordinates.ToMapPos(_mapManager) - playerTransform.MapPosition.Position; + var diff = coordinates.ToMapPos(EntityManager) - playerTransform.MapPosition.Position; if (diff.LengthSquared > 0.01f) { playerTransform.LocalRotation = new Angle(diff); @@ -373,7 +373,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click if (item != null) { // After attack: Check if we clicked on an empty location, if so the only interaction we can do is AfterInteract - var distSqrt = (playerTransform.WorldPosition - coordinates.ToMapPos(_mapManager)).LengthSquared; + var distSqrt = (playerTransform.WorldPosition - coordinates.ToMapPos(EntityManager)).LengthSquared; InteractAfter(player, item, coordinates, distSqrt <= InteractionRangeSquared); } @@ -418,7 +418,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click /// /// We didn't click on any entity, try doing an AfterInteract on the click location /// - private void InteractAfter(IEntity user, IEntity weapon, GridCoordinates clickLocation, bool canReach) + private void InteractAfter(IEntity user, IEntity weapon, EntityCoordinates clickLocation, bool canReach) { var message = new AfterInteractMessage(user, weapon, null, clickLocation, canReach); RaiseLocalEvent(message); @@ -440,7 +440,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click /// Uses a weapon/object on an entity /// Finds components with the InteractUsing interface and calls their function /// - public async Task Interaction(IEntity user, IEntity weapon, IEntity attacked, GridCoordinates clickLocation) + public async Task Interaction(IEntity user, IEntity weapon, IEntity attacked, EntityCoordinates clickLocation) { var attackMsg = new InteractUsingMessage(user, weapon, attacked, clickLocation); RaiseLocalEvent(attackMsg); @@ -607,7 +607,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click /// Calls Land on all components that implement the ILand interface /// on an entity that has landed after being thrown. /// - public void LandInteraction(IEntity user, IEntity landing, GridCoordinates landLocation) + public void LandInteraction(IEntity user, IEntity landing, EntityCoordinates landLocation) { var landMsg = new LandMessage(user, landing, landLocation); RaiseLocalEvent(landMsg); @@ -752,7 +752,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click /// Will have two behaviors, either "uses" the weapon at range on the entity if it is capable of accepting that action /// Or it will use the weapon itself on the position clicked, regardless of what was there /// - public void RangedInteraction(IEntity user, IEntity weapon, IEntity attacked, GridCoordinates clickLocation) + public void RangedInteraction(IEntity user, IEntity weapon, IEntity attacked, EntityCoordinates clickLocation) { var rangedMsg = new RangedInteractMessage(user, weapon, attacked, clickLocation); RaiseLocalEvent(rangedMsg); @@ -793,10 +793,10 @@ namespace Content.Server.GameObjects.EntitySystems.Click } } - private void DoAttack(IEntity player, GridCoordinates coordinates, bool wideAttack, EntityUid target = default) + private void DoAttack(IEntity player, EntityCoordinates coordinates, bool wideAttack, EntityUid target = default) { // Verify player is on the same map as the entity he clicked on - if (_mapManager.GetGrid(coordinates.GridID).ParentMapId != player.Transform.MapID) + if (_mapManager.GetGrid(coordinates.GetGridId(_entityManager)).ParentMapId != player.Transform.MapID) { Logger.WarningS("system.interaction", $"Player named {player.Name} clicked on a map he isn't located on"); @@ -804,7 +804,7 @@ namespace Content.Server.GameObjects.EntitySystems.Click } if (!ActionBlockerSystem.CanAttack(player) || - (!wideAttack && !InRangeUnobstructed(player.Transform.MapPosition, coordinates.ToMap(_mapManager), ignoreInsideBlocker:true))) + (!wideAttack && !player.InRangeUnobstructed(coordinates, ignoreInsideBlocker:true))) { return; } diff --git a/Content.Server/GameObjects/EntitySystems/ConstructionSystem.cs b/Content.Server/GameObjects/EntitySystems/ConstructionSystem.cs index 557a6e8bf7..00d456bbdb 100644 --- a/Content.Server/GameObjects/EntitySystems/ConstructionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/ConstructionSystem.cs @@ -6,7 +6,6 @@ using Content.Server.GameObjects.Components.GUI; using Content.Server.GameObjects.Components.Interactable; using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Stack; -using Content.Server.Utility; using Content.Shared.Construction; using Content.Shared.GameObjects.Components; using Content.Shared.GameObjects.Components.Interactable; @@ -20,7 +19,6 @@ using Robust.Server.Interfaces.Player; using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects.Components; -using Robust.Shared.Interfaces.Map; using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; @@ -36,7 +34,6 @@ namespace Content.Server.GameObjects.EntitySystems internal class ConstructionSystem : SharedConstructionSystem { [Dependency] private readonly IPrototypeManager _prototypeManager = default!; - [Dependency] private readonly IMapManager _mapManager = default!; private readonly Dictionary _craftRecipes = new Dictionary(); @@ -240,7 +237,7 @@ namespace Content.Server.GameObjects.EntitySystems { ConstructionStepMaterial.MaterialType.Glass, "GlassSheet1" } }; - private bool TryStartStructureConstruction(IEntity placingEnt, GridCoordinates loc, string prototypeName, Angle angle) + private bool TryStartStructureConstruction(IEntity placingEnt, EntityCoordinates loc, string prototypeName, Angle angle) { var prototype = _prototypeManager.Index(prototypeName); @@ -380,7 +377,7 @@ namespace Content.Server.GameObjects.EntitySystems var stage = constructPrototype.Stages[constructionComponent.Stage]; - if (await TryProcessStep(constructEntity, stage.Forward, handTool, user, transformComponent.GridPosition)) + if (await TryProcessStep(constructEntity, stage.Forward, handTool, user, transformComponent.Coordinates)) { constructionComponent.Stage++; if (constructionComponent.Stage == constructPrototype.Stages.Count - 1) @@ -402,7 +399,7 @@ namespace Content.Server.GameObjects.EntitySystems } } - else if (await TryProcessStep(constructEntity, stage.Backward, handTool, user, transformComponent.GridPosition)) + else if (await TryProcessStep(constructEntity, stage.Backward, handTool, user, transformComponent.Coordinates)) { constructionComponent.Stage--; stage = constructPrototype.Stages[constructionComponent.Stage]; @@ -439,7 +436,7 @@ namespace Content.Server.GameObjects.EntitySystems } } - private async Task TryProcessStep(IEntity constructEntity, ConstructionStep step, IEntity slapped, IEntity user, GridCoordinates gridCoords) + private async Task TryProcessStep(IEntity constructEntity, ConstructionStep step, IEntity slapped, IEntity user, EntityCoordinates gridCoords) { if (step == null) { diff --git a/Content.Server/GameObjects/EntitySystems/DoAfter/DoAfter.cs b/Content.Server/GameObjects/EntitySystems/DoAfter/DoAfter.cs index 7cf9bdb56d..7a37e924ef 100644 --- a/Content.Server/GameObjects/EntitySystems/DoAfter/DoAfter.cs +++ b/Content.Server/GameObjects/EntitySystems/DoAfter/DoAfter.cs @@ -23,9 +23,9 @@ namespace Content.Server.GameObjects.EntitySystems.DoAfter public float Elapsed { get; set; } - public GridCoordinates UserGrid { get; } + public EntityCoordinates UserGrid { get; } - public GridCoordinates TargetGrid { get; } + public EntityCoordinates TargetGrid { get; } private bool _tookDamage; @@ -42,13 +42,13 @@ namespace Content.Server.GameObjects.EntitySystems.DoAfter if (eventArgs.BreakOnUserMove) { - UserGrid = eventArgs.User.Transform.GridPosition; + UserGrid = eventArgs.User.Transform.Coordinates; } if (eventArgs.BreakOnTargetMove) { // Target should never be null if the bool is set. - TargetGrid = eventArgs.Target!.Transform.GridPosition; + TargetGrid = eventArgs.Target!.Transform.Coordinates; } // For this we need to stay on the same hand slot and need the same item in that hand slot @@ -94,7 +94,7 @@ namespace Content.Server.GameObjects.EntitySystems.DoAfter { Tcs.SetResult(DoAfterStatus.Finished); } - + return; } @@ -110,7 +110,7 @@ namespace Content.Server.GameObjects.EntitySystems.DoAfter { return true; } - + //https://github.com/tgstation/tgstation/blob/1aa293ea337283a0191140a878eeba319221e5df/code/__HELPERS/mobs.dm if (EventArgs.CancelToken.IsCancellationRequested) { @@ -118,12 +118,12 @@ namespace Content.Server.GameObjects.EntitySystems.DoAfter } // TODO :Handle inertia in space. - if (EventArgs.BreakOnUserMove && EventArgs.User.Transform.GridPosition != UserGrid) + if (EventArgs.BreakOnUserMove && EventArgs.User.Transform.Coordinates != UserGrid) { return true; } - if (EventArgs.BreakOnTargetMove && EventArgs.Target!.Transform.GridPosition != TargetGrid) + if (EventArgs.BreakOnTargetMove && EventArgs.Target!.Transform.Coordinates != TargetGrid) { return true; } @@ -170,7 +170,7 @@ namespace Content.Server.GameObjects.EntitySystems.DoAfter } } } - + return false; } diff --git a/Content.Server/GameObjects/EntitySystems/HandsSystem.cs b/Content.Server/GameObjects/EntitySystems/HandsSystem.cs index 967335dcc5..c9e29ebf27 100644 --- a/Content.Server/GameObjects/EntitySystems/HandsSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/HandsSystem.cs @@ -10,12 +10,14 @@ using Content.Shared.GameObjects.Components.Inventory; using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Input; using Content.Shared.Interfaces; +using Content.Shared.Utility; using JetBrains.Annotations; using Robust.Server.GameObjects.EntitySystemMessages; using Robust.Server.Interfaces.Player; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Input.Binding; +using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Map; using Robust.Shared.IoC; using Robust.Shared.Localization; @@ -28,6 +30,7 @@ namespace Content.Server.GameObjects.EntitySystems internal sealed class HandsSystem : EntitySystem { [Dependency] private readonly IMapManager _mapManager = default!; + [Dependency] private readonly IEntityManager _entityManager = default!; private const float ThrowForce = 1.5f; // Throwing force of mobs in Newtons @@ -107,7 +110,7 @@ namespace Content.Server.GameObjects.EntitySystems } } - private bool HandleDrop(ICommonSession session, GridCoordinates coords, EntityUid uid) + private bool HandleDrop(ICommonSession session, EntityCoordinates coords, EntityUid uid) { var ent = ((IPlayerSession) session).AttachedEntity; @@ -120,13 +123,13 @@ namespace Content.Server.GameObjects.EntitySystems if (handsComp.GetActiveHand == null) return false; - var entCoords = ent.Transform.GridPosition.Position; + var entCoords = ent.Transform.Coordinates.Position; var entToDesiredDropCoords = coords.Position - entCoords; var targetLength = Math.Min(entToDesiredDropCoords.Length, SharedInteractionSystem.InteractionRange - 0.001f); // InteractionRange is reduced due to InRange not dealing with floating point error - var newCoords = new GridCoordinates((entToDesiredDropCoords.Normalized * targetLength) + entCoords, coords.GridID); - var rayLength = Get().UnobstructedDistance(ent.Transform.MapPosition, newCoords.ToMap(_mapManager), ignoredEnt: ent); + var newCoords = coords.WithPosition((entToDesiredDropCoords.Normalized * targetLength) + entCoords).ToMap(_entityManager); + var rayLength = Get().UnobstructedDistance(ent.Transform.MapPosition, newCoords, ignoredEnt: ent); - handsComp.Drop(handsComp.ActiveHand, new GridCoordinates(entCoords + (entToDesiredDropCoords.Normalized * rayLength), coords.GridID)); + handsComp.Drop(handsComp.ActiveHand, coords.WithPosition(entCoords + (entToDesiredDropCoords.Normalized * rayLength))); return true; } @@ -139,7 +142,7 @@ namespace Content.Server.GameObjects.EntitySystems handsComp.ActivateItem(); } - private bool HandleThrowItem(ICommonSession session, GridCoordinates coords, EntityUid uid) + private bool HandleThrowItem(ICommonSession session, EntityCoordinates coords, EntityUid uid) { var plyEnt = ((IPlayerSession)session).AttachedEntity; @@ -165,14 +168,14 @@ namespace Content.Server.GameObjects.EntitySystems else { stackComp.Use(1); - throwEnt = throwEnt.EntityManager.SpawnEntity(throwEnt.Prototype.ID, plyEnt.Transform.GridPosition); + throwEnt = throwEnt.EntityManager.SpawnEntity(throwEnt.Prototype.ID, plyEnt.Transform.Coordinates); // can only throw one item at a time, regardless of what the prototype stack size is. if (throwEnt.TryGetComponent(out var newStackComp)) newStackComp.Count = 1; } - ThrowHelper.ThrowTo(throwEnt, ThrowForce, coords, plyEnt.Transform.GridPosition, false, plyEnt); + ThrowHelper.ThrowTo(throwEnt, ThrowForce, coords, plyEnt.Transform.Coordinates, false, plyEnt); return true; } @@ -228,7 +231,7 @@ namespace Content.Server.GameObjects.EntitySystems } } - private bool HandleMovePulledObject(ICommonSession session, GridCoordinates coords, EntityUid uid) + private bool HandleMovePulledObject(ICommonSession session, EntityCoordinates coords, EntityUid uid) { var playerEntity = session.AttachedEntity; @@ -238,7 +241,7 @@ namespace Content.Server.GameObjects.EntitySystems return false; } - hands.MovePulledObject(playerEntity.Transform.GridPosition, coords); + hands.MovePulledObject(playerEntity.Transform.Coordinates, coords); return false; } diff --git a/Content.Server/GameObjects/EntitySystems/ListeningSystem.cs b/Content.Server/GameObjects/EntitySystems/ListeningSystem.cs index f69477e089..a200300cf1 100644 --- a/Content.Server/GameObjects/EntitySystems/ListeningSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/ListeningSystem.cs @@ -9,15 +9,16 @@ namespace Content.Server.GameObjects.EntitySystems { internal sealed class ListeningSystem : EntitySystem { - [Dependency] private readonly IMapManager _mapManager = default!; - - public void PingListeners(IEntity source, GridCoordinates sourcePos, string message) + public void PingListeners(IEntity source, EntityCoordinates sourcePos, string message) { foreach (var listener in ComponentManager.EntityQuery()) { - var dist = sourcePos.Distance(_mapManager, listener.Owner.Transform.GridPosition); + if (!sourcePos.TryDistance(EntityManager, listener.Owner.Transform.Coordinates, out var distance)) + { + return; + } - listener.PassSpeechData(message, source, dist); + listener.PassSpeechData(message, source, distance); } } } diff --git a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs index 31087803c6..c95e6d4a59 100644 --- a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs @@ -17,6 +17,7 @@ using Robust.Server.GameObjects.EntitySystems; using Robust.Server.Interfaces.Timing; using Robust.Shared.GameObjects.Components; using Robust.Shared.GameObjects.Components.Transform; +using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; @@ -35,6 +36,7 @@ namespace Content.Server.GameObjects.EntitySystems [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!; [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!; + [Dependency] private readonly IEntityManager _entityManager = default!; private AudioSystem _audioSystem = default!; @@ -92,14 +94,18 @@ namespace Content.Server.GameObjects.EntitySystems { var transform = mover.Owner.Transform; // Handle footsteps. - if (_mapManager.GridExists(mover.LastPosition.GridID)) + if (_mapManager.GridExists(mover.LastPosition.GetGridId(EntityManager))) { // Can happen when teleporting between grids. - var distance = transform.GridPosition.Distance(_mapManager, mover.LastPosition); + if (!transform.Coordinates.TryDistance(_entityManager, mover.LastPosition, out var distance)) + { + return; + } + mover.StepSoundDistance += distance; } - mover.LastPosition = transform.GridPosition; + mover.LastPosition = transform.Coordinates; float distanceNeeded; if (mover.Sprinting) { @@ -127,15 +133,15 @@ namespace Content.Server.GameObjects.EntitySystems } else { - PlayFootstepSound(transform.GridPosition); + PlayFootstepSound(transform.Coordinates); } } } - private void PlayFootstepSound(GridCoordinates coordinates) + private void PlayFootstepSound(EntityCoordinates coordinates) { // Step one: figure out sound collection prototype. - var grid = _mapManager.GetGrid(coordinates.GridID); + var grid = _mapManager.GetGrid(coordinates.GetGridId(EntityManager)); var tile = grid.GetTileRef(coordinates); // If the coordinates have a catwalk, it's always catwalk. diff --git a/Content.Server/GameObjects/EntitySystems/PointingSystem.cs b/Content.Server/GameObjects/EntitySystems/PointingSystem.cs index d271d0a052..50bfd070d2 100644 --- a/Content.Server/GameObjects/EntitySystems/PointingSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/PointingSystem.cs @@ -75,12 +75,12 @@ namespace Content.Server.GameObjects.EntitySystems } } - public bool InRange(GridCoordinates from, GridCoordinates to) + public bool InRange(EntityCoordinates from, EntityCoordinates to) { - return from.InRange(_mapManager, to, 15); + return from.InRange(EntityManager, to, 15); } - public bool TryPoint(ICommonSession? session, GridCoordinates coords, EntityUid uid) + public bool TryPoint(ICommonSession? session, EntityCoordinates coords, EntityUid uid) { var player = (session as IPlayerSession)?.ContentData()?.Mind?.CurrentEntity; if (player == null) @@ -100,7 +100,7 @@ namespace Content.Server.GameObjects.EntitySystems return false; } - if (!InRange(coords, player.Transform.GridPosition)) + if (!InRange(coords, player.Transform.Coordinates)) { player.PopupMessage(Loc.GetString("You can't reach there!")); return false; @@ -108,7 +108,7 @@ namespace Content.Server.GameObjects.EntitySystems if (ActionBlockerSystem.CanChangeDirection(player)) { - var diff = coords.ToMapPos(_mapManager) - player.Transform.MapPosition.Position; + var diff = coords.ToMapPos(EntityManager) - player.Transform.MapPosition.Position; if (diff.LengthSquared > 0.01f) { player.Transform.LocalRotation = new Angle(diff); @@ -154,7 +154,7 @@ namespace Content.Server.GameObjects.EntitySystems } else { - var tileRef = _mapManager.GetGrid(coords.GridID).GetTileRef(coords); + var tileRef = _mapManager.GetGrid(coords.GetGridId(EntityManager)).GetTileRef(coords); var tileDef = _tileDefinitionManager[tileRef.Tile.TypeId]; selfMessage = Loc.GetString("You point at {0}.", tileDef.DisplayName); diff --git a/Content.Server/GameObjects/EntitySystems/SignalLinkerSystem.cs b/Content.Server/GameObjects/EntitySystems/SignalLinkerSystem.cs index 04e7fee928..aa5b1a1ce7 100644 --- a/Content.Server/GameObjects/EntitySystems/SignalLinkerSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/SignalLinkerSystem.cs @@ -64,7 +64,7 @@ namespace Content.Server.GameObjects.EntitySystems } } - private bool HandleUse(ICommonSession session, GridCoordinates coords, EntityUid uid) + private bool HandleUse(ICommonSession session, EntityCoordinates coords, EntityUid uid) { if (!_transmitters.TryGetValue(session.SessionId, out var signalTransmitter)) { @@ -76,11 +76,6 @@ namespace Content.Server.GameObjects.EntitySystems return false; } - if (entity == null) - { - return false; - } - if (entity.TryGetComponent(out var signalReceiver)) { if (signalReceiver.Interact(session.AttachedEntity, signalTransmitter)) diff --git a/Content.Server/GameTicking/GameTicker.cs b/Content.Server/GameTicking/GameTicker.cs index 54407dca9a..82cb34bbbc 100644 --- a/Content.Server/GameTicking/GameTicker.cs +++ b/Content.Server/GameTicking/GameTicker.cs @@ -28,6 +28,7 @@ using Content.Shared.GameObjects.Components.PDA; using Content.Shared.Network.NetMessages; using Content.Shared.Preferences; using Content.Shared.Roles; +using Content.Shared.Utility; using Prometheus; using Robust.Server.Interfaces; using Robust.Server.Interfaces.Maps; @@ -91,7 +92,7 @@ namespace Content.Server.GameTicking [ViewVariables] private bool _roundStartCountdownHasNotStartedYetDueToNoPlayers; private DateTime _roundStartTimeUtc; [ViewVariables] private GameRunLevel _runLevel; - [ViewVariables(VVAccess.ReadWrite)] private GridCoordinates _spawnPoint; + [ViewVariables(VVAccess.ReadWrite)] private EntityCoordinates _spawnPoint; [ViewVariables] private bool DisallowLateJoin { get; set; } = false; @@ -540,7 +541,7 @@ namespace Content.Server.GameTicking private IEntity _spawnPlayerMob(Job job, bool lateJoin = true) { - GridCoordinates coordinates = lateJoin ? GetLateJoinSpawnPoint() : GetJobSpawnPoint(job.Prototype.ID); + EntityCoordinates coordinates = lateJoin ? GetLateJoinSpawnPoint() : GetJobSpawnPoint(job.Prototype.ID); var entity = _entityManager.SpawnEntity(PlayerPrototypeName, coordinates); var startingGear = _prototypeManager.Index(job.StartingGear); EquipStartingGear(entity, startingGear); @@ -556,7 +557,7 @@ namespace Content.Server.GameTicking foreach (var (slot, equipmentStr) in gear) { - var equipmentEntity = _entityManager.SpawnEntity(equipmentStr, entity.Transform.GridPosition); + var equipmentEntity = _entityManager.SpawnEntity(equipmentStr, entity.Transform.Coordinates); inventory.Equip(slot, equipmentEntity.GetComponent()); } } @@ -566,7 +567,7 @@ namespace Content.Server.GameTicking var inhand = startingGear.Inhand; foreach (var (hand, prototype) in inhand) { - var inhandEntity = _entityManager.SpawnEntity(prototype, entity.Transform.GridPosition); + var inhandEntity = _entityManager.SpawnEntity(prototype, entity.Transform.Coordinates); handsComponent.PutInHand(inhandEntity.GetComponent(), hand); } } @@ -586,15 +587,15 @@ namespace Content.Server.GameTicking return _entityManager.SpawnEntity(ObserverPrototypeName, coordinates); } - public GridCoordinates GetLateJoinSpawnPoint() + public EntityCoordinates GetLateJoinSpawnPoint() { var location = _spawnPoint; - var possiblePoints = new List(); + var possiblePoints = new List(); foreach (var entity in _entityManager.GetEntities(new TypeEntityQuery(typeof(SpawnPointComponent)))) { var point = entity.GetComponent(); - if (point.SpawnType == SpawnPointType.LateJoin) possiblePoints.Add(entity.Transform.GridPosition); + if (point.SpawnType == SpawnPointType.LateJoin) possiblePoints.Add(entity.Transform.Coordinates); } if (possiblePoints.Count != 0) location = _robustRandom.Pick(possiblePoints); @@ -602,16 +603,16 @@ namespace Content.Server.GameTicking return location; } - public GridCoordinates GetJobSpawnPoint(string jobId) + public EntityCoordinates GetJobSpawnPoint(string jobId) { var location = _spawnPoint; - var possiblePoints = new List(); + var possiblePoints = new List(); foreach (var entity in _entityManager.GetEntities(new TypeEntityQuery(typeof(SpawnPointComponent)))) { var point = entity.GetComponent(); if (point.SpawnType == SpawnPointType.Job && point.Job.ID == jobId) - possiblePoints.Add(entity.Transform.GridPosition); + possiblePoints.Add(entity.Transform.Coordinates); } if (possiblePoints.Count != 0) location = _robustRandom.Pick(possiblePoints); @@ -619,16 +620,16 @@ namespace Content.Server.GameTicking return location; } - public GridCoordinates GetObserverSpawnPoint() + public EntityCoordinates GetObserverSpawnPoint() { var location = _spawnPoint; - var possiblePoints = new List(); + var possiblePoints = new List(); foreach (var entity in _entityManager.GetEntities(new TypeEntityQuery(typeof(SpawnPointComponent)))) { var point = entity.GetComponent(); if (point.SpawnType == SpawnPointType.Observer) - possiblePoints.Add(entity.Transform.GridPosition); + possiblePoints.Add(entity.Transform.Coordinates); } if (possiblePoints.Count != 0) location = _robustRandom.Pick(possiblePoints); @@ -684,7 +685,7 @@ namespace Content.Server.GameTicking var startTime = _gameTiming.RealTime; var grid = _mapLoader.LoadBlueprint(newMapId, MapFile); - _spawnPoint = new GridCoordinates(Vector2.Zero, grid); + _spawnPoint = grid.ToCoordinates(); var timeSpan = _gameTiming.RealTime - startTime; Logger.InfoS("ticker", $"Loaded map in {timeSpan.TotalMilliseconds:N2}ms."); diff --git a/Content.Server/GameTicking/GameTickerCommands.cs b/Content.Server/GameTicking/GameTickerCommands.cs index b8d073af9e..6ebda18401 100644 --- a/Content.Server/GameTicking/GameTickerCommands.cs +++ b/Content.Server/GameTicking/GameTickerCommands.cs @@ -408,7 +408,7 @@ namespace Content.Server.GameTicking continue; } - var tile = grid.GetTileRef(childEntity.Transform.GridPosition); + var tile = grid.GetTileRef(childEntity.Transform.Coordinates); var tileDef = (ContentTileDefinition) tileDefinitionManager[tile.Tile.TypeId]; if (tileDef.Name == "underplating") @@ -416,7 +416,7 @@ namespace Content.Server.GameTicking continue; } - grid.SetTile(childEntity.Transform.GridPosition, underplatingTile); + grid.SetTile(childEntity.Transform.Coordinates, underplatingTile); changed++; } diff --git a/Content.Server/GlobalVerbs/PointingVerb.cs b/Content.Server/GlobalVerbs/PointingVerb.cs index d2952b60d6..c3cdef56f4 100644 --- a/Content.Server/GlobalVerbs/PointingVerb.cs +++ b/Content.Server/GlobalVerbs/PointingVerb.cs @@ -25,7 +25,7 @@ namespace Content.Server.GlobalVerbs return; } - if (!EntitySystem.Get().InRange(user.Transform.GridPosition, target.Transform.GridPosition)) + if (!EntitySystem.Get().InRange(user.Transform.Coordinates, target.Transform.Coordinates)) { return; } @@ -47,7 +47,7 @@ namespace Content.Server.GlobalVerbs return; } - EntitySystem.Get().TryPoint(actor.playerSession, target.Transform.GridPosition, target.Uid); + EntitySystem.Get().TryPoint(actor.playerSession, target.Transform.Coordinates, target.Uid); } } } diff --git a/Content.Server/GlobalVerbs/PullingVerb.cs b/Content.Server/GlobalVerbs/PullingVerb.cs index 6213d443a5..b3b24617de 100644 --- a/Content.Server/GlobalVerbs/PullingVerb.cs +++ b/Content.Server/GlobalVerbs/PullingVerb.cs @@ -31,7 +31,7 @@ namespace Content.Server.GlobalVerbs return; } - var dist = user.Transform.GridPosition.Position - target.Transform.GridPosition.Position; + var dist = user.Transform.Coordinates.Position - target.Transform.Coordinates.Position; if (dist.LengthSquared > SharedInteractionSystem.InteractionRangeSquared) { return; diff --git a/Content.Server/Interfaces/GameObjects/Components/Items/IHandsComponent.cs b/Content.Server/Interfaces/GameObjects/Components/Items/IHandsComponent.cs index 832fb7858f..a840d589fb 100644 --- a/Content.Server/Interfaces/GameObjects/Components/Items/IHandsComponent.cs +++ b/Content.Server/Interfaces/GameObjects/Components/Items/IHandsComponent.cs @@ -133,7 +133,7 @@ namespace Content.Server.Interfaces.GameObjects.Components.Items /// /// Whether to check the for the mob or not. /// True if an item was dropped, false otherwise. - bool Drop(string slot, GridCoordinates coords, bool doMobChecks = true); + bool Drop(string slot, EntityCoordinates coords, bool doMobChecks = true); /// /// Drop the specified entity in our hands to a certain position. @@ -155,7 +155,7 @@ namespace Content.Server.Interfaces.GameObjects.Components.Items /// /// Thrown if is not actually held in any hand. /// - bool Drop(IEntity entity, GridCoordinates coords, bool doMobChecks = true); + bool Drop(IEntity entity, EntityCoordinates coords, bool doMobChecks = true); /// /// Drop the item contained in a slot into another container. diff --git a/Content.Server/Interfaces/GameTicking/IGameTicker.cs b/Content.Server/Interfaces/GameTicking/IGameTicker.cs index 8f218a4850..379ad83828 100644 --- a/Content.Server/Interfaces/GameTicking/IGameTicker.cs +++ b/Content.Server/Interfaces/GameTicking/IGameTicker.cs @@ -31,9 +31,9 @@ namespace Content.Server.Interfaces.GameTicking void MakeJoinGame(IPlayerSession player, string jobId); void ToggleReady(IPlayerSession player, bool ready); - GridCoordinates GetLateJoinSpawnPoint(); - GridCoordinates GetJobSpawnPoint(string jobId); - GridCoordinates GetObserverSpawnPoint(); + EntityCoordinates GetLateJoinSpawnPoint(); + EntityCoordinates GetJobSpawnPoint(string jobId); + EntityCoordinates GetObserverSpawnPoint(); void EquipStartingGear(IEntity entity, StartingGearPrototype startingGear); diff --git a/Content.Server/Observer/Ghost.cs b/Content.Server/Observer/Ghost.cs index e1ea953bd6..2f094a9f74 100644 --- a/Content.Server/Observer/Ghost.cs +++ b/Content.Server/Observer/Ghost.cs @@ -46,7 +46,7 @@ namespace Content.Server.Observer mind.VisitingEntity.Delete(); } - var position = player.AttachedEntity?.Transform.GridPosition ?? IoCManager.Resolve().GetObserverSpawnPoint(); + var position = player.AttachedEntity?.Transform.Coordinates ?? IoCManager.Resolve().GetObserverSpawnPoint(); if (canReturn && player.AttachedEntity.TryGetComponent(out IDamageableComponent damageable)) { diff --git a/Content.Server/PDA/PDAUplinkManager.cs b/Content.Server/PDA/PDAUplinkManager.cs index c1baaf9533..a207fce8ef 100644 --- a/Content.Server/PDA/PDAUplinkManager.cs +++ b/Content.Server/PDA/PDAUplinkManager.cs @@ -119,7 +119,7 @@ namespace Content.Server.PDA var player = _entityManager.GetEntity(acc.AccountHolder); var hands = player.GetComponent(); hands.PutInHandOrDrop(_entityManager.SpawnEntity(listing.ItemId, - player.Transform.GridPosition).GetComponent()); + player.Transform.Coordinates).GetComponent()); return true; } } diff --git a/Content.Server/Placement/SpawnHelpers.cs b/Content.Server/Placement/SpawnHelpers.cs index a6675fa712..e60d365d3e 100644 --- a/Content.Server/Placement/SpawnHelpers.cs +++ b/Content.Server/Placement/SpawnHelpers.cs @@ -13,7 +13,7 @@ namespace Content.Server.Placement /// Spawns a spotlight ground turret that will track any living entities in range. /// /// - public static void SpawnLightTurret(GridCoordinates position) + public static void SpawnLightTurret(EntityCoordinates position) { var entMan = IoCManager.Resolve(); var tBase = entMan.SpawnEntity("TurretBase", position); diff --git a/Content.Server/Sandbox/SandboxManager.cs b/Content.Server/Sandbox/SandboxManager.cs index 78b89871dd..df3d7c1a0d 100644 --- a/Content.Server/Sandbox/SandboxManager.cs +++ b/Content.Server/Sandbox/SandboxManager.cs @@ -115,7 +115,7 @@ namespace Content.Server.Sandbox ; hands.PutInHandOrDrop( _entityManager.SpawnEntity("CaptainIDCard", - player.AttachedEntity.Transform.GridPosition).GetComponent()); + player.AttachedEntity.Transform.Coordinates).GetComponent()); } } diff --git a/Content.Server/ServerNotifyManager.cs b/Content.Server/ServerNotifyManager.cs index ee3129d4c1..7dd9984245 100644 --- a/Content.Server/ServerNotifyManager.cs +++ b/Content.Server/ServerNotifyManager.cs @@ -44,7 +44,7 @@ namespace Content.Server _netManager.ServerSendMessage(netMessage, actor.playerSession.ConnectedClient); } - public override void PopupMessage(GridCoordinates coordinates, IEntity viewer, string message) + public override void PopupMessage(EntityCoordinates coordinates, IEntity viewer, string message) { if (!viewer.TryGetComponent(out IActorComponent actor)) { diff --git a/Content.Server/StationEvents/RadiationStorm.cs b/Content.Server/StationEvents/RadiationStorm.cs index 9163b097e3..9d3d7854bd 100644 --- a/Content.Server/StationEvents/RadiationStorm.cs +++ b/Content.Server/StationEvents/RadiationStorm.cs @@ -1,5 +1,6 @@ using Content.Server.GameObjects.Components.Mobs; using Content.Shared.GameObjects.Components.Mobs; +using Content.Shared.Utility; using JetBrains.Annotations; using Robust.Server.GameObjects.EntitySystems; using Robust.Shared.GameObjects.Systems; @@ -17,7 +18,7 @@ namespace Content.Server.StationEvents public sealed class RadiationStorm : StationEvent { // Based on Goonstation style radiation storm with some TG elements (announcer, etc.) - + [Dependency] private IEntityManager _entityManager = default!; [Dependency] private IMapManager _mapManager = default!; [Dependency] private IRobustRandom _robustRandom = default!; @@ -65,12 +66,12 @@ namespace Content.Server.StationEvents public override void Shutdown() { base.Shutdown(); - + // IOC uninject? _entityManager = null; _mapManager = null; _robustRandom = null; - + var componentManager = IoCManager.Resolve(); foreach (var overlay in componentManager.EntityQuery()) @@ -78,7 +79,7 @@ namespace Content.Server.StationEvents overlay.RemoveOverlay(SharedOverlayID.RadiationPulseOverlay); } } - + public override void Update(float frameTime) { _timeElapsed += frameTime; @@ -112,20 +113,20 @@ namespace Content.Server.StationEvents } private void SpawnPulse(IMapGrid mapGrid) - { + { _entityManager.SpawnEntity("RadiationPulse", FindRandomGrid(mapGrid)); _timeUntilPulse = _robustRandom.NextFloat() * (MaxPulseDelay - MinPulseDelay) + MinPulseDelay; _pulsesRemaining -= 1; } - private GridCoordinates FindRandomGrid(IMapGrid mapGrid) + private EntityCoordinates FindRandomGrid(IMapGrid mapGrid) { // TODO: Need to get valid tiles? (maybe just move right if the tile we chose is invalid?) var randomX = _robustRandom.Next((int) mapGrid.WorldBounds.Left, (int) mapGrid.WorldBounds.Right); var randomY = _robustRandom.Next((int) mapGrid.WorldBounds.Bottom, (int) mapGrid.WorldBounds.Top); - return mapGrid.GridTileToLocal(new MapIndices(randomX, randomY)); + return mapGrid.ToCoordinates(randomX, randomY); } } -} \ No newline at end of file +} diff --git a/Content.Server/Throw/ThrowHelper.cs b/Content.Server/Throw/ThrowHelper.cs index ad8e76b4bf..c347d3c3ef 100644 --- a/Content.Server/Throw/ThrowHelper.cs +++ b/Content.Server/Throw/ThrowHelper.cs @@ -4,7 +4,6 @@ using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Physics; using Robust.Shared.GameObjects.Components; using Robust.Shared.Interfaces.GameObjects; -using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; @@ -40,12 +39,12 @@ namespace Content.Server.Throw /// /// The entity that did the throwing. An opposite impulse will be applied to this entity if passed in. /// - public static void Throw(IEntity thrownEnt, float throwForce, GridCoordinates targetLoc, GridCoordinates sourceLoc, bool spread = false, IEntity throwSourceEnt = null) + public static void Throw(IEntity thrownEnt, float throwForce, EntityCoordinates targetLoc, EntityCoordinates sourceLoc, bool spread = false, IEntity throwSourceEnt = null) { if (!thrownEnt.TryGetComponent(out ICollidableComponent colComp)) return; - var mapManager = IoCManager.Resolve(); + var entityManager = IoCManager.Resolve(); colComp.CanCollide = true; // I can now collide with player, so that i can do damage. @@ -60,7 +59,7 @@ namespace Content.Server.Throw colComp.PhysicsShapes[0].CollisionMask |= (int) CollisionGroup.ThrownItem; colComp.Status = BodyStatus.InAir; } - var angle = new Angle(targetLoc.ToMapPos(mapManager) - sourceLoc.ToMapPos(mapManager)); + var angle = new Angle(targetLoc.ToMapPos(entityManager) - sourceLoc.ToMapPos(entityManager)); if (spread) { @@ -90,7 +89,7 @@ namespace Content.Server.Throw { var physicsMgr = IoCManager.Resolve(); - if (physicsMgr.IsWeightless(throwSourceEnt.Transform.GridPosition)) + if (physicsMgr.IsWeightless(throwSourceEnt.Transform.Coordinates)) { // We don't check for surrounding entities, // so you'll still get knocked around if you're hugging the station wall in zero g. @@ -126,14 +125,18 @@ namespace Content.Server.Throw /// /// The entity that did the throwing. An opposite impulse will be applied to this entity if passed in. /// - public static void ThrowTo(IEntity thrownEnt, float throwForceMax, GridCoordinates targetLoc, - GridCoordinates sourceLoc, bool spread = false, IEntity throwSourceEnt = null) + public static void ThrowTo(IEntity thrownEnt, float throwForceMax, EntityCoordinates targetLoc, + EntityCoordinates sourceLoc, bool spread = false, IEntity throwSourceEnt = null) { - var mapManager = IoCManager.Resolve(); + var entityManager = IoCManager.Resolve(); var timing = IoCManager.Resolve(); // Calculate the force necessary to land a throw based on throw duration, mass and distance. - var distance = (targetLoc.ToMapPos(mapManager) - sourceLoc.ToMapPos(mapManager)).Length; + if (!targetLoc.TryDistance(entityManager, sourceLoc, out var distance)) + { + return; + } + var throwDuration = ThrownItemComponent.DefaultThrowTime; var mass = 1f; if (thrownEnt.TryGetComponent(out ICollidableComponent physicsComponent)) diff --git a/Content.Server/Utility/NotifyExtensions.cs b/Content.Server/Utility/NotifyExtensions.cs index c617c25cbd..d4ae473f31 100644 --- a/Content.Server/Utility/NotifyExtensions.cs +++ b/Content.Server/Utility/NotifyExtensions.cs @@ -19,7 +19,7 @@ namespace Content.Server.Utility public static void PopupMessageOtherClients(this IEntity source, string message, int range = 15) { var playerManager = IoCManager.Resolve(); - var viewers = playerManager.GetPlayersInRange(source.Transform.GridPosition, range); + var viewers = playerManager.GetPlayersInRange(source.Transform.Coordinates, range); foreach (var viewer in viewers) { diff --git a/Content.Shared/GameObjects/Components/Movement/IMoverComponent.cs b/Content.Shared/GameObjects/Components/Movement/IMoverComponent.cs index 975a2c6477..bafe58dd82 100644 --- a/Content.Shared/GameObjects/Components/Movement/IMoverComponent.cs +++ b/Content.Shared/GameObjects/Components/Movement/IMoverComponent.cs @@ -39,7 +39,7 @@ namespace Content.Shared.GameObjects.Components.Movement /// (Vector2 walking, Vector2 sprinting) VelocityDir { get; } - GridCoordinates LastPosition { get; set; } + EntityCoordinates LastPosition { get; set; } float StepSoundDistance { get; set; } diff --git a/Content.Shared/GameObjects/Components/Movement/SharedPlayerInputMoverComponent.cs b/Content.Shared/GameObjects/Components/Movement/SharedPlayerInputMoverComponent.cs index de864025fc..9edd468da6 100644 --- a/Content.Shared/GameObjects/Components/Movement/SharedPlayerInputMoverComponent.cs +++ b/Content.Shared/GameObjects/Components/Movement/SharedPlayerInputMoverComponent.cs @@ -132,7 +132,7 @@ namespace Content.Shared.GameObjects.Components.Movement } } - public abstract GridCoordinates LastPosition { get; set; } + public abstract EntityCoordinates LastPosition { get; set; } public abstract float StepSoundDistance { get; set; } /// diff --git a/Content.Shared/GameObjects/Components/Movement/SharedTeleporterComponent.cs b/Content.Shared/GameObjects/Components/Movement/SharedTeleporterComponent.cs index de607bb84f..ef166a77fb 100644 --- a/Content.Shared/GameObjects/Components/Movement/SharedTeleporterComponent.cs +++ b/Content.Shared/GameObjects/Components/Movement/SharedTeleporterComponent.cs @@ -38,9 +38,9 @@ namespace Content.Shared.GameObjects.Components.Movement [Serializable, NetSerializable] public class TeleportMessage : ComponentMessage { - public readonly GridCoordinates Target; + public readonly EntityCoordinates Target; - public TeleportMessage(GridCoordinates target) + public TeleportMessage(EntityCoordinates target) { Target = target; } diff --git a/Content.Shared/GameObjects/Components/SharedDoAfterComponent.cs b/Content.Shared/GameObjects/Components/SharedDoAfterComponent.cs index 9cea4de79d..d8be76081f 100644 --- a/Content.Shared/GameObjects/Components/SharedDoAfterComponent.cs +++ b/Content.Shared/GameObjects/Components/SharedDoAfterComponent.cs @@ -31,23 +31,23 @@ namespace Content.Shared.GameObjects.Components { // To see what these do look at DoAfter and DoAfterEventArgs public byte ID { get; } - + public TimeSpan StartTime { get; } - - public GridCoordinates UserGrid { get; } - - public GridCoordinates TargetGrid { get; } - + + public EntityCoordinates UserGrid { get; } + + public EntityCoordinates TargetGrid { get; } + public EntityUid TargetUid { get; } public float Delay { get; } - + // TODO: The other ones need predicting public bool BreakOnUserMove { get; } - + public bool BreakOnTargetMove { get; } - - public DoAfterMessage(byte id, GridCoordinates userGrid, GridCoordinates targetGrid, TimeSpan startTime, float delay, bool breakOnUserMove, bool breakOnTargetMove, EntityUid targetUid = default) + + public DoAfterMessage(byte id, EntityCoordinates userGrid, EntityCoordinates targetGrid, TimeSpan startTime, float delay, bool breakOnUserMove, bool breakOnTargetMove, EntityUid targetUid = default) { ID = id; UserGrid = userGrid; @@ -59,4 +59,4 @@ namespace Content.Shared.GameObjects.Components TargetUid = targetUid; } } -} \ No newline at end of file +} diff --git a/Content.Shared/GameObjects/EntitySystemMessages/DragDropMessage.cs b/Content.Shared/GameObjects/EntitySystemMessages/DragDropMessage.cs index 8b5648e401..8812af2294 100644 --- a/Content.Shared/GameObjects/EntitySystemMessages/DragDropMessage.cs +++ b/Content.Shared/GameObjects/EntitySystemMessages/DragDropMessage.cs @@ -11,11 +11,11 @@ namespace Content.Shared.GameObjects.EntitySystemMessages [Serializable, NetSerializable] public class DragDropMessage : EntitySystemMessage { - public GridCoordinates DropLocation { get; } + public EntityCoordinates DropLocation { get; } public EntityUid Dropped { get; } public EntityUid Target { get; } - public DragDropMessage(GridCoordinates dropLocation, EntityUid dropped, EntityUid target) + public DragDropMessage(EntityCoordinates dropLocation, EntityUid dropped, EntityUid target) { DropLocation = dropLocation; Dropped = dropped; diff --git a/Content.Shared/GameObjects/EntitySystems/ActSystem.cs b/Content.Shared/GameObjects/EntitySystems/ActSystem.cs index a5e6aea7e7..27ac9d68f5 100644 --- a/Content.Shared/GameObjects/EntitySystems/ActSystem.cs +++ b/Content.Shared/GameObjects/EntitySystems/ActSystem.cs @@ -47,7 +47,7 @@ namespace Content.Shared.GameObjects.EntitySystems public class ExplosionEventArgs : EventArgs { - public GridCoordinates Source { get; set; } + public EntityCoordinates Source { get; set; } public IEntity Target { get; set; } public ExplosionSeverity Severity { get; set; } } @@ -71,7 +71,7 @@ namespace Content.Shared.GameObjects.EntitySystems owner.Delete(); } - public void HandleExplosion(GridCoordinates source, IEntity target, ExplosionSeverity severity) + public void HandleExplosion(EntityCoordinates source, IEntity target, ExplosionSeverity severity) { var eventArgs = new ExplosionEventArgs { diff --git a/Content.Shared/GameObjects/EntitySystems/SharedConstructionSystem.cs b/Content.Shared/GameObjects/EntitySystems/SharedConstructionSystem.cs index b19ed13e6d..dd9305a673 100644 --- a/Content.Shared/GameObjects/EntitySystems/SharedConstructionSystem.cs +++ b/Content.Shared/GameObjects/EntitySystems/SharedConstructionSystem.cs @@ -22,7 +22,7 @@ namespace Content.Shared.GameObjects.EntitySystems /// /// Position to start building. /// - public readonly GridCoordinates Location; + public readonly EntityCoordinates Location; /// /// The construction prototype to start building. @@ -36,7 +36,7 @@ namespace Content.Shared.GameObjects.EntitySystems /// public readonly int Ack; - public TryStartStructureConstructionMessage(GridCoordinates loc, string prototypeName, Angle angle, int ack) + public TryStartStructureConstructionMessage(EntityCoordinates loc, string prototypeName, Angle angle, int ack) { Location = loc; PrototypeName = prototypeName; diff --git a/Content.Shared/GameObjects/EntitySystems/SharedInteractionSystem.cs b/Content.Shared/GameObjects/EntitySystems/SharedInteractionSystem.cs index 87bff6af83..dbd202a7cd 100644 --- a/Content.Shared/GameObjects/EntitySystems/SharedInteractionSystem.cs +++ b/Content.Shared/GameObjects/EntitySystems/SharedInteractionSystem.cs @@ -5,7 +5,6 @@ using Content.Shared.Physics; using JetBrains.Annotations; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; -using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Physics; using Robust.Shared.IoC; using Robust.Shared.Localization; @@ -21,7 +20,6 @@ namespace Content.Shared.GameObjects.EntitySystems public class SharedInteractionSystem : EntitySystem { [Dependency] private readonly IPhysicsManager _physicsManager = default!; - [Dependency] private readonly IMapManager _mapManager = default!; public const float InteractionRange = 2; public const float InteractionRangeSquared = InteractionRange * InteractionRange; @@ -284,7 +282,7 @@ namespace Content.Shared.GameObjects.EntitySystems /// public bool InRangeUnobstructed( IEntity origin, - GridCoordinates other, + EntityCoordinates other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, Ignored predicate = null, @@ -292,7 +290,7 @@ namespace Content.Shared.GameObjects.EntitySystems bool popup = false) { var originPosition = origin.Transform.MapPosition; - var otherPosition = other.ToMap(_mapManager); + var otherPosition = other.ToMap(EntityManager); predicate ??= e => e == origin; var inRange = InRangeUnobstructed(originPosition, otherPosition, range, collisionMask, predicate, ignoreInsideBlocker); @@ -522,7 +520,7 @@ namespace Content.Shared.GameObjects.EntitySystems if (target == null) { - otherPosition = args.ClickLocation.ToMap(_mapManager); + otherPosition = args.ClickLocation.ToMap(EntityManager); } else { diff --git a/Content.Shared/GameObjects/EntitySystems/SharedMoverSystem.cs b/Content.Shared/GameObjects/EntitySystems/SharedMoverSystem.cs index 57c66cb3f5..4d983ef655 100644 --- a/Content.Shared/GameObjects/EntitySystems/SharedMoverSystem.cs +++ b/Content.Shared/GameObjects/EntitySystems/SharedMoverSystem.cs @@ -5,7 +5,6 @@ using Content.Shared.GameObjects.Components.Movement; using Content.Shared.Physics; using Content.Shared.Physics.Pull; using Robust.Shared.Configuration; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Input; @@ -58,7 +57,7 @@ namespace Content.Shared.GameObjects.EntitySystems collidable.EnsureController(); var weightless = !transform.Owner.HasComponent() && - _physicsManager.IsWeightless(transform.GridPosition); + _physicsManager.IsWeightless(transform.Coordinates); if (weightless) { diff --git a/Content.Shared/Interfaces/GameObjects/Components/Interaction/IAfterInteract.cs b/Content.Shared/Interfaces/GameObjects/Components/Interaction/IAfterInteract.cs index 99a8e3d3b3..9c5724fb28 100644 --- a/Content.Shared/Interfaces/GameObjects/Components/Interaction/IAfterInteract.cs +++ b/Content.Shared/Interfaces/GameObjects/Components/Interaction/IAfterInteract.cs @@ -21,7 +21,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components public class AfterInteractEventArgs : EventArgs { public IEntity User { get; set; } - public GridCoordinates ClickLocation { get; set; } + public EntityCoordinates ClickLocation { get; set; } public IEntity Target { get; set; } public bool CanReach { get; set; } } @@ -55,7 +55,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components /// /// Location that the user clicked outside of their interaction range. /// - public GridCoordinates ClickLocation { get; } + public EntityCoordinates ClickLocation { get; } /// /// Is the click location close enough to reach by the player? This does not check for obstructions, just that the target is within @@ -63,7 +63,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components /// public bool CanReach { get; } - public AfterInteractMessage(IEntity user, IEntity itemInHand, IEntity attacked, GridCoordinates clickLocation, bool canReach) + public AfterInteractMessage(IEntity user, IEntity itemInHand, IEntity attacked, EntityCoordinates clickLocation, bool canReach) { User = user; Attacked = attacked; diff --git a/Content.Shared/Interfaces/GameObjects/Components/Interaction/IAttack.cs b/Content.Shared/Interfaces/GameObjects/Components/Interaction/IAttack.cs index 0a1a310405..8e8ad11fb4 100644 --- a/Content.Shared/Interfaces/GameObjects/Components/Interaction/IAttack.cs +++ b/Content.Shared/Interfaces/GameObjects/Components/Interaction/IAttack.cs @@ -20,20 +20,19 @@ namespace Content.Shared.Interfaces.GameObjects.Components public class AttackEventArgs : EventArgs { - public AttackEventArgs(IEntity user, GridCoordinates clickLocation, bool wideAttack, EntityUid target = default) + public AttackEventArgs(IEntity user, EntityCoordinates clickLocation, bool wideAttack, EntityUid target = default) { User = user; ClickLocation = clickLocation; WideAttack = wideAttack; Target = target; - IEntity? targetEntity = null; - IoCManager.Resolve()?.TryGetEntity(Target, out targetEntity); + IoCManager.Resolve().TryGetEntity(Target, out var targetEntity); TargetEntity = targetEntity; } public IEntity User { get; } - public GridCoordinates ClickLocation { get; } + public EntityCoordinates ClickLocation { get; } public bool WideAttack { get; } public EntityUid Target { get; } public IEntity? TargetEntity { get; } diff --git a/Content.Shared/Interfaces/GameObjects/Components/Interaction/IDragDrop.cs b/Content.Shared/Interfaces/GameObjects/Components/Interaction/IDragDrop.cs index e93db0b9c1..e71bd265b8 100644 --- a/Content.Shared/Interfaces/GameObjects/Components/Interaction/IDragDrop.cs +++ b/Content.Shared/Interfaces/GameObjects/Components/Interaction/IDragDrop.cs @@ -42,7 +42,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components /// The location where is being dropped. /// The entity that is being dragged and dropped. /// The entity that is being dropped onto. - public DragDropEventArgs(IEntity user, GridCoordinates dropLocation, IEntity dropped, IEntity target) + public DragDropEventArgs(IEntity user, EntityCoordinates dropLocation, IEntity dropped, IEntity target) { User = user; DropLocation = dropLocation; @@ -58,7 +58,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components /// /// The location where is being dropped. /// - public GridCoordinates DropLocation { get; } + public EntityCoordinates DropLocation { get; } /// /// The entity that is being dragged and dropped. diff --git a/Content.Shared/Interfaces/GameObjects/Components/Interaction/IInteractUsing.cs b/Content.Shared/Interfaces/GameObjects/Components/Interaction/IInteractUsing.cs index 5b28a693e0..70341dbc78 100644 --- a/Content.Shared/Interfaces/GameObjects/Components/Interaction/IInteractUsing.cs +++ b/Content.Shared/Interfaces/GameObjects/Components/Interaction/IInteractUsing.cs @@ -29,7 +29,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components public class InteractUsingEventArgs : EventArgs, ITargetedInteractEventArgs { public IEntity User { get; set; } - public GridCoordinates ClickLocation { get; set; } + public EntityCoordinates ClickLocation { get; set; } public IEntity Using { get; set; } public IEntity Target { get; set; } } @@ -63,9 +63,9 @@ namespace Content.Shared.Interfaces.GameObjects.Components /// /// The original location that was clicked by the user. /// - public GridCoordinates ClickLocation { get; } + public EntityCoordinates ClickLocation { get; } - public InteractUsingMessage(IEntity user, IEntity itemInHand, IEntity attacked, GridCoordinates clickLocation) + public InteractUsingMessage(IEntity user, IEntity itemInHand, IEntity attacked, EntityCoordinates clickLocation) { User = user; ItemInHand = itemInHand; diff --git a/Content.Shared/Interfaces/GameObjects/Components/Interaction/ILand.cs b/Content.Shared/Interfaces/GameObjects/Components/Interaction/ILand.cs index 9b002c85e3..ec3b194a3d 100644 --- a/Content.Shared/Interfaces/GameObjects/Components/Interaction/ILand.cs +++ b/Content.Shared/Interfaces/GameObjects/Components/Interaction/ILand.cs @@ -16,14 +16,14 @@ namespace Content.Shared.Interfaces.GameObjects.Components public class LandEventArgs : EventArgs { - public LandEventArgs(IEntity user, GridCoordinates landingLocation) + public LandEventArgs(IEntity user, EntityCoordinates landingLocation) { User = user; LandingLocation = landingLocation; } public IEntity User { get; } - public GridCoordinates LandingLocation { get; } + public EntityCoordinates LandingLocation { get; } } /// @@ -50,9 +50,9 @@ namespace Content.Shared.Interfaces.GameObjects.Components /// /// Location where the item landed. /// - public GridCoordinates LandLocation { get; } + public EntityCoordinates LandLocation { get; } - public LandMessage(IEntity user, IEntity thrown, GridCoordinates landLocation) + public LandMessage(IEntity user, IEntity thrown, EntityCoordinates landLocation) { User = user; Thrown = thrown; diff --git a/Content.Shared/Interfaces/GameObjects/Components/Interaction/IRangedInteract.cs b/Content.Shared/Interfaces/GameObjects/Components/Interaction/IRangedInteract.cs index 77dbf612b5..e62f734680 100644 --- a/Content.Shared/Interfaces/GameObjects/Components/Interaction/IRangedInteract.cs +++ b/Content.Shared/Interfaces/GameObjects/Components/Interaction/IRangedInteract.cs @@ -24,7 +24,7 @@ namespace Content.Shared.Interfaces.GameObjects.Components { public IEntity User { get; set; } public IEntity Using { get; set; } - public GridCoordinates ClickLocation { get; set; } + public EntityCoordinates ClickLocation { get; set; } } /// @@ -56,9 +56,9 @@ namespace Content.Shared.Interfaces.GameObjects.Components /// /// Location that the user clicked outside of their interaction range. /// - public GridCoordinates ClickLocation { get; } + public EntityCoordinates ClickLocation { get; } - public RangedInteractMessage(IEntity user, IEntity itemInHand, IEntity attacked, GridCoordinates clickLocation) + public RangedInteractMessage(IEntity user, IEntity itemInHand, IEntity attacked, EntityCoordinates clickLocation) { User = user; ItemInHand = itemInHand; diff --git a/Content.Shared/Interfaces/ISharedNotifyManager.cs b/Content.Shared/Interfaces/ISharedNotifyManager.cs index 3948945d74..be950de1ea 100644 --- a/Content.Shared/Interfaces/ISharedNotifyManager.cs +++ b/Content.Shared/Interfaces/ISharedNotifyManager.cs @@ -23,7 +23,7 @@ namespace Content.Shared.Interfaces /// Location on a grid that the message floats up from. /// The client attached entity that the message is being sent to. /// Text contents of the message. - void PopupMessage(GridCoordinates coordinates, IEntity viewer, string message); + void PopupMessage(EntityCoordinates coordinates, IEntity viewer, string message); /// /// Makes a string of text float up from a client's cursor. @@ -64,7 +64,7 @@ namespace Content.Shared.Interfaces /// Location on a grid that the message floats up from. /// The client attached entity that the message is being sent to. /// Text contents of the message. - public static void PopupMessage(this GridCoordinates coordinates, IEntity viewer, string message) + public static void PopupMessage(this EntityCoordinates coordinates, IEntity viewer, string message) { var notifyManager = IoCManager.Resolve(); notifyManager.PopupMessage(coordinates, viewer, message); diff --git a/Content.Shared/Maps/TurfHelpers.cs b/Content.Shared/Maps/TurfHelpers.cs index 41ae6fb666..406d91331e 100644 --- a/Content.Shared/Maps/TurfHelpers.cs +++ b/Content.Shared/Maps/TurfHelpers.cs @@ -45,33 +45,36 @@ namespace Content.Shared.Maps /// /// Attempts to get the turf at a certain coordinates or null if no such turf is found. /// - public static TileRef? GetTileRef(this GridCoordinates coordinates) + public static TileRef? GetTileRef(this EntityCoordinates coordinates, IEntityManager? entityManager = null, IMapManager? mapManager = null) { - if (!coordinates.GridID.IsValid()) + entityManager ??= IoCManager.Resolve(); + + if (!coordinates.IsValid(entityManager)) return null; - var mapManager = IoCManager.Resolve(); + mapManager ??= IoCManager.Resolve(); - if (!mapManager.TryGetGrid(coordinates.GridID, out var grid)) + if (!mapManager.TryGetGrid(coordinates.GetGridId(entityManager), out var grid)) return null; - if (!grid.TryGetTileRef(coordinates.ToMapIndices(mapManager), out var tile)) + if (!grid.TryGetTileRef(coordinates.ToMapIndices(entityManager, mapManager), out var tile)) return null; return tile; } - public static bool TryGetTileRef(this GridCoordinates coordinates, [NotNullWhen(true)] out TileRef? turf) + public static bool TryGetTileRef(this EntityCoordinates coordinates, [NotNullWhen(true)] out TileRef? turf) { return (turf = coordinates.GetTileRef()) != null; } - public static bool PryTile(this GridCoordinates coordinates, - IMapManager? mapManager = null, ITileDefinitionManager? tileDefinitionManager = null, IEntityManager? entityManager = null) + public static bool PryTile(this EntityCoordinates coordinates, IEntityManager? entityManager = null, + IMapManager? mapManager = null) { + entityManager ??= IoCManager.Resolve(); mapManager ??= IoCManager.Resolve(); - return coordinates.ToMapIndices(mapManager).PryTile(coordinates.GridID); + return coordinates.ToMapIndices(entityManager, mapManager).PryTile(coordinates.GetGridId(entityManager)); } public static bool PryTile(this MapIndices indices, GridId gridId, @@ -109,7 +112,7 @@ namespace Content.Shared.Maps var half = mapGrid.TileSize / 2f; //Actually spawn the relevant tile item at the right position and give it some random offset. - var tileItem = entityManager.SpawnEntity(tileDef.ItemDropPrototypeName, indices.ToGridCoordinates(mapManager, tileRef.GridIndex).Offset(new Vector2(half, half))); + var tileItem = entityManager.SpawnEntity(tileDef.ItemDropPrototypeName, indices.ToEntityCoordinates(mapManager, tileRef.GridIndex).Offset(new Vector2(half, half))); tileItem.RandomOffset(0.25f); return true; } @@ -147,9 +150,11 @@ namespace Content.Shared.Maps return false; } - public static GridCoordinates GridPosition(this TileRef turf) + public static EntityCoordinates GridPosition(this TileRef turf, IMapManager? mapManager = null) { - return new GridCoordinates(turf.X, turf.Y, turf.GridIndex); + mapManager ??= IoCManager.Resolve(); + + return turf.GridIndices.ToEntityCoordinates(mapManager, turf.GridIndex); } /// diff --git a/Content.Shared/Physics/ConveyedController.cs b/Content.Shared/Physics/ConveyedController.cs index ae03951174..7e133095f0 100644 --- a/Content.Shared/Physics/ConveyedController.cs +++ b/Content.Shared/Physics/ConveyedController.cs @@ -15,7 +15,7 @@ namespace Content.Shared.Physics public void Move(Vector2 velocityDirection, float speed) { if (ControlledComponent?.Owner.HasComponent() == false && - IoCManager.Resolve().IsWeightless(ControlledComponent.Owner.Transform.GridPosition)) + IoCManager.Resolve().IsWeightless(ControlledComponent.Owner.Transform.Coordinates)) { return; } diff --git a/Content.Shared/Physics/MoverController.cs b/Content.Shared/Physics/MoverController.cs index 5554895988..6c628bc8dc 100644 --- a/Content.Shared/Physics/MoverController.cs +++ b/Content.Shared/Physics/MoverController.cs @@ -17,7 +17,7 @@ namespace Content.Shared.Physics public void Move(Vector2 velocityDirection, float speed) { if (ControlledComponent?.Owner.HasComponent() == false - && _physicsManager.IsWeightless(ControlledComponent.Owner.Transform.GridPosition)) + && _physicsManager.IsWeightless(ControlledComponent.Owner.Transform.Coordinates)) { return; } diff --git a/Content.Shared/Physics/Pull/PullController.cs b/Content.Shared/Physics/Pull/PullController.cs index 8bb76473be..0dfee54213 100644 --- a/Content.Shared/Physics/Pull/PullController.cs +++ b/Content.Shared/Physics/Pull/PullController.cs @@ -3,7 +3,7 @@ using System; using Content.Shared.GameObjects.EntitySystems; using Robust.Shared.Containers; using Robust.Shared.GameObjects.Components; -using Robust.Shared.Interfaces.Map; +using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; @@ -22,7 +22,7 @@ namespace Content.Shared.Physics.Pull public bool GettingPulled => _puller != null; - private GridCoordinates? _movingTo; + private EntityCoordinates? _movingTo; public ICollidableComponent? Puller => _puller; @@ -76,23 +76,23 @@ namespace Content.Shared.Physics.Pull ControlledComponent.TryRemoveController(); } - public void TryMoveTo(GridCoordinates from, GridCoordinates to) + public void TryMoveTo(EntityCoordinates from, EntityCoordinates to) { if (_puller == null || ControlledComponent == null) { return; } - var mapManager = IoCManager.Resolve(); + var entityManager = IoCManager.Resolve(); - if (!from.InRange(mapManager, to, SharedInteractionSystem.InteractionRange)) + if (!from.InRange(entityManager, to, SharedInteractionSystem.InteractionRange)) { return; } ControlledComponent.WakeBody(); - var dist = _puller.Owner.Transform.GridPosition.Position - to.Position; + var dist = _puller.Owner.Transform.Coordinates.Position - to.Position; if (Math.Sqrt(dist.LengthSquared) > DistBeforeStopPull || Math.Sqrt(dist.LengthSquared) < 0.25f) @@ -125,7 +125,7 @@ namespace Content.Shared.Physics.Pull } else if (_movingTo.HasValue) { - var diff = _movingTo.Value.Position - ControlledComponent.Owner.Transform.GridPosition.Position; + var diff = _movingTo.Value.Position - ControlledComponent.Owner.Transform.Coordinates.Position; LinearVelocity = diff.Normalized * 5; } else if (dist.Length > DistBeforePull) @@ -153,7 +153,7 @@ namespace Content.Shared.Physics.Pull return; } - if (ControlledComponent.Owner.Transform.GridPosition.Position.EqualsApprox(_movingTo.Value.Position, 0.01)) + if (ControlledComponent.Owner.Transform.Coordinates.Position.EqualsApprox(_movingTo.Value.Position, 0.01)) { _movingTo = null; } diff --git a/Content.Shared/Physics/SlipController.cs b/Content.Shared/Physics/SlipController.cs index 4339e3de47..7a83b1ea40 100644 --- a/Content.Shared/Physics/SlipController.cs +++ b/Content.Shared/Physics/SlipController.cs @@ -22,7 +22,7 @@ namespace Content.Shared.Physics return; } - if (_physicsManager.IsWeightless(ControlledComponent.Owner.Transform.GridPosition)) + if (_physicsManager.IsWeightless(ControlledComponent.Owner.Transform.Coordinates)) { return; } diff --git a/Content.Shared/SharedNotifyManager.cs b/Content.Shared/SharedNotifyManager.cs index 844693e474..9a28a21bb0 100644 --- a/Content.Shared/SharedNotifyManager.cs +++ b/Content.Shared/SharedNotifyManager.cs @@ -12,7 +12,7 @@ namespace Content.Shared { public abstract void PopupMessage(IEntity source, IEntity viewer, string message); - public abstract void PopupMessage(GridCoordinates coordinates, IEntity viewer, string message); + public abstract void PopupMessage(EntityCoordinates coordinates, IEntity viewer, string message); public abstract void PopupMessageCursor(IEntity viewer, string message); @@ -50,12 +50,12 @@ namespace Content.Shared #endregion public string Message { get; set; } - public GridCoordinates Coordinates; + public EntityCoordinates Coordinates; public override void ReadFromBuffer(NetIncomingMessage buffer) { Message = buffer.ReadString(); - Coordinates = buffer.ReadGridLocalCoordinates(); + Coordinates = buffer.ReadEntityCoordinates(); } public override void WriteToBuffer(NetOutgoingMessage buffer) diff --git a/Content.Shared/Utility/EntityCoordinatesExtensions.cs b/Content.Shared/Utility/EntityCoordinatesExtensions.cs new file mode 100644 index 0000000000..9c38d0f08b --- /dev/null +++ b/Content.Shared/Utility/EntityCoordinatesExtensions.cs @@ -0,0 +1,58 @@ +#nullable enable +using Robust.Shared.GameObjects; +using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.Interfaces.Map; +using Robust.Shared.IoC; +using Robust.Shared.Map; +using Vector2 = Robust.Shared.Maths.Vector2; + +namespace Content.Shared.Utility +{ + public static class EntityCoordinatesExtensions + { + public static EntityCoordinates ToCoordinates(this EntityUid id, Vector2 offset) + { + return new EntityCoordinates(id, offset); + } + + public static EntityCoordinates ToCoordinates(this EntityUid id, float x, float y) + { + return new EntityCoordinates(id, x, y); + } + + public static EntityCoordinates ToCoordinates(this EntityUid id) + { + return ToCoordinates(id, Vector2.Zero); + } + + public static EntityCoordinates ToCoordinates(this IEntity entity, Vector2 offset) + { + return ToCoordinates(entity.Uid, offset); + } + + public static EntityCoordinates ToCoordinates(this IEntity entity, float x, float y) + { + return new EntityCoordinates(entity.Uid, x, y); + } + + public static EntityCoordinates ToCoordinates(this IEntity entity) + { + return ToCoordinates(entity.Uid, Vector2.Zero); + } + + public static EntityCoordinates ToCoordinates(this IMapGrid grid, Vector2 offset) + { + return ToCoordinates(grid.GridEntityId, offset); + } + + public static EntityCoordinates ToCoordinates(this IMapGrid grid, float x, float y) + { + return ToCoordinates(grid.GridEntityId, x, y); + } + + public static EntityCoordinates ToCoordinates(this IMapGrid grid) + { + return ToCoordinates(grid.GridEntityId, Vector2.Zero); + } + } +} diff --git a/Content.Shared/Utility/SharedDirectionExtensions.cs b/Content.Shared/Utility/SharedDirectionExtensions.cs index c33a482b86..a30b37de57 100644 --- a/Content.Shared/Utility/SharedDirectionExtensions.cs +++ b/Content.Shared/Utility/SharedDirectionExtensions.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using Content.Shared.Maps; -using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; using Robust.Shared.Map; @@ -59,10 +58,8 @@ namespace Content.Shared.Utility /// Gets tiles in random directions from the given one. /// /// An enumerable of the adjacent tiles. - public static IEnumerable AdjacentTilesRandom(this GridCoordinates coordinates, bool ignoreSpace = false) + public static IEnumerable AdjacentTilesRandom(this EntityCoordinates coordinates, bool ignoreSpace = false) { - var mapManager = IoCManager.Resolve(); - foreach (var direction in RandomDirections()) { var adjacent = coordinates.Offset(direction).GetTileRef(); @@ -81,7 +78,7 @@ namespace Content.Shared.Utility } } - public static GridCoordinates Offset(this GridCoordinates coordinates, Direction direction) + public static EntityCoordinates Offset(this EntityCoordinates coordinates, Direction direction) { return coordinates.Offset(direction.ToVec()); } diff --git a/Content.Shared/Utility/SharedRangeExtensions.cs b/Content.Shared/Utility/SharedRangeExtensions.cs index 326d2adfeb..5e8e9a50c0 100644 --- a/Content.Shared/Utility/SharedRangeExtensions.cs +++ b/Content.Shared/Utility/SharedRangeExtensions.cs @@ -4,7 +4,6 @@ using Content.Shared.Physics; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects.Components; -using Robust.Shared.Interfaces.Map; using Robust.Shared.IoC; using Robust.Shared.Map; using static Content.Shared.GameObjects.EntitySystems.SharedInteractionSystem; @@ -59,7 +58,7 @@ namespace Content.Shared.Utility public static bool InRangeUnobstructed( this IEntity origin, - GridCoordinates other, + EntityCoordinates other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, Ignored predicate = null, @@ -133,7 +132,7 @@ namespace Content.Shared.Utility public static bool InRangeUnobstructed( this IComponent origin, - GridCoordinates other, + EntityCoordinates other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, Ignored predicate = null, @@ -210,7 +209,7 @@ namespace Content.Shared.Utility public static bool InRangeUnobstructed( this IContainer origin, - GridCoordinates other, + EntityCoordinates other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, Ignored predicate = null, @@ -239,17 +238,17 @@ namespace Content.Shared.Utility } #endregion - #region GridCoordinates + #region EntityCoordinates public static bool InRangeUnobstructed( - this GridCoordinates origin, + this EntityCoordinates origin, IEntity other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, Ignored predicate = null, bool ignoreInsideBlocker = false) { - var mapManager = IoCManager.Resolve(); - var originPosition = origin.ToMap(mapManager); + var entityManager = IoCManager.Resolve(); + var originPosition = origin.ToMap(entityManager); var otherPosition = other.Transform.MapPosition; return SharedInteractionSystem.InRangeUnobstructed(originPosition, otherPosition, range, collisionMask, @@ -257,15 +256,15 @@ namespace Content.Shared.Utility } public static bool InRangeUnobstructed( - this GridCoordinates origin, + this EntityCoordinates origin, IComponent other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, Ignored predicate = null, bool ignoreInsideBlocker = false) { - var mapManager = IoCManager.Resolve(); - var originPosition = origin.ToMap(mapManager); + var entityManager = IoCManager.Resolve(); + var originPosition = origin.ToMap(entityManager); var otherPosition = other.Owner.Transform.MapPosition; return SharedInteractionSystem.InRangeUnobstructed(originPosition, otherPosition, range, collisionMask, @@ -273,15 +272,15 @@ namespace Content.Shared.Utility } public static bool InRangeUnobstructed( - this GridCoordinates origin, + this EntityCoordinates origin, IContainer other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, Ignored predicate = null, bool ignoreInsideBlocker = false) { - var mapManager = IoCManager.Resolve(); - var originPosition = origin.ToMap(mapManager); + var entityManager = IoCManager.Resolve(); + var originPosition = origin.ToMap(entityManager); var otherPosition = other.Owner.Transform.MapPosition; return SharedInteractionSystem.InRangeUnobstructed(originPosition, otherPosition, range, collisionMask, @@ -289,31 +288,31 @@ namespace Content.Shared.Utility } public static bool InRangeUnobstructed( - this GridCoordinates origin, - GridCoordinates other, + this EntityCoordinates origin, + EntityCoordinates other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, Ignored predicate = null, bool ignoreInsideBlocker = false) { - var mapManager = IoCManager.Resolve(); - var originPosition = origin.ToMap(mapManager); - var otherPosition = other.ToMap(mapManager); + var entityManager = IoCManager.Resolve(); + var originPosition = origin.ToMap(entityManager); + var otherPosition = other.ToMap(entityManager); return SharedInteractionSystem.InRangeUnobstructed(originPosition, otherPosition, range, collisionMask, predicate, ignoreInsideBlocker); } public static bool InRangeUnobstructed( - this GridCoordinates origin, + this EntityCoordinates origin, MapCoordinates other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, Ignored predicate = null, bool ignoreInsideBlocker = false) { - var mapManager = IoCManager.Resolve(); - var originPosition = origin.ToMap(mapManager); + var entityManager = IoCManager.Resolve(); + var originPosition = origin.ToMap(entityManager); return SharedInteractionSystem.InRangeUnobstructed(originPosition, other, range, collisionMask, predicate, ignoreInsideBlocker); @@ -365,14 +364,14 @@ namespace Content.Shared.Utility public static bool InRangeUnobstructed( this MapCoordinates origin, - GridCoordinates other, + EntityCoordinates other, float range = InteractionRange, CollisionGroup collisionMask = CollisionGroup.Impassable, Ignored predicate = null, bool ignoreInsideBlocker = false) { - var mapManager = IoCManager.Resolve(); - var otherPosition = other.ToMap(mapManager); + var entityManager = IoCManager.Resolve(); + var otherPosition = other.ToMap(entityManager); return SharedInteractionSystem.InRangeUnobstructed(origin, otherPosition, range, collisionMask, predicate, ignoreInsideBlocker);