]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Remove 700 usages of Component.Owner (#21100)
authorDrSmugleaf <DrSmugleaf@users.noreply.github.com>
Thu, 19 Oct 2023 19:34:31 +0000 (12:34 -0700)
committerGitHub <noreply@github.com>
Thu, 19 Oct 2023 19:34:31 +0000 (12:34 -0700)
261 files changed:
Content.Client/Administration/UI/SpawnExplosion/ExplosionDebugOverlay.cs
Content.Client/Administration/UI/Tabs/AtmosTab/AddAtmosWindow.xaml.cs
Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml.cs
Content.Client/Alerts/ClientAlertsSystem.cs
Content.Client/Atmos/Overlays/AtmosDebugOverlay.cs
Content.Client/Audio/AmbientSoundOverlay.cs
Content.Client/Audio/AmbientSoundSystem.cs
Content.Client/CardboardBox/CardboardBoxSystem.cs
Content.Client/Chasm/ChasmFallingVisualsSystem.cs
Content.Client/Commands/HideMechanismsCommand.cs
Content.Client/Commands/ShowMechanismsCommand.cs
Content.Client/Decals/Overlays/DecalOverlay.cs
Content.Client/Doors/DoorSystem.cs
Content.Client/Effects/ColorFlashEffectSystem.cs
Content.Client/Explosion/ExplosionOverlay.cs
Content.Client/Fluids/PuddleOverlay.cs
Content.Client/GPS/Systems/HandheldGpsSystem.cs
Content.Client/GPS/UI/HandheldGpsStatusControl.cs
Content.Client/Guidebook/Controls/GuideEntityEmbed.xaml.cs
Content.Client/Hands/Systems/HandsSystem.cs
Content.Client/HealthOverlay/HealthOverlaySystem.cs
Content.Client/HealthOverlay/UI/HealthOverlayGui.cs
Content.Client/IconSmoothing/IconSmoothSystem.cs
Content.Client/Interactable/Components/InteractionOutlineComponent.cs
Content.Client/Inventory/ClientInventorySystem.cs
Content.Client/Light/Components/LightBehaviourComponent.cs
Content.Client/Light/RgbLightControllerSystem.cs
Content.Client/NPC/NPCSteeringSystem.cs
Content.Client/NPC/PathfindingSystem.cs
Content.Client/NetworkConfigurator/NetworkConfiguratorLinkOverlay.cs
Content.Client/NetworkConfigurator/Systems/NetworkConfiguratorSystem.cs
Content.Client/NodeContainer/NodeVisualizationOverlay.cs
Content.Client/Outline/InteractionOutlineSystem.cs
Content.Client/Pinpointer/NavMapSystem.cs
Content.Client/Radiation/Overlays/RadiationPulseOverlay.cs
Content.Client/Replay/Spectator/ReplaySpectatorSystem.Position.cs
Content.Client/Revenant/RevenantOverloadedLightsSystem.cs
Content.Client/Rotation/RotationVisualizerSystem.cs
Content.Client/Shuttles/UI/DockingControl.cs
Content.Client/Shuttles/UI/RadarControl.cs
Content.Client/Sprite/SpriteFadeSystem.cs
Content.Client/Storage/Systems/ItemMapperSystem.cs
Content.Client/SubFloor/TrayScannerSystem.cs
Content.Client/UserInterface/Controls/SlotControl.cs
Content.Client/Weather/WeatherOverlay.cs
Content.Client/Weather/WeatherSystem.cs
Content.IntegrationTests/Pair/TestPair.Helpers.cs
Content.IntegrationTests/Tests/Fluids/FluidSpillTest.cs
Content.IntegrationTests/Tests/Interaction/InteractionTest.Helpers.cs
Content.IntegrationTests/Tests/PostMapInitTest.cs
Content.Server/Access/Systems/IdCardSystem.cs
Content.Server/Administration/Commands/RemoveEntityStorageCommand.cs
Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs
Content.Server/Administration/Systems/BufferingSystem.cs
Content.Server/AlertLevel/AlertLevelDisplaySystem.cs
Content.Server/AlertLevel/AlertLevelSystem.cs
Content.Server/Animals/Systems/UdderSystem.cs
Content.Server/Anomaly/Effects/BluespaceAnomalySystem.cs
Content.Server/Anomaly/Effects/ElectricityAnomalySystem.cs
Content.Server/Anomaly/Effects/InjectionAnomalySystem.cs
Content.Server/Anomaly/Effects/PyroclasticAnomalySystem.cs
Content.Server/Atmos/Commands/FillGasCommand.cs
Content.Server/Atmos/Commands/SetAtmosTemperatureCommand.cs
Content.Server/Atmos/Commands/SetTemperatureCommand.cs
Content.Server/Atmos/Components/GridAtmosphereComponent.cs
Content.Server/Atmos/EntitySystems/AirtightSystem.cs
Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs
Content.Server/Atmos/EntitySystems/AtmosphereSystem.BreathTool.cs
Content.Server/Atmos/EntitySystems/AtmosphereSystem.Commands.cs
Content.Server/Atmos/EntitySystems/AtmosphereSystem.GridAtmosphere.cs
Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs
Content.Server/Atmos/EntitySystems/AtmosphereSystem.Monstermos.cs
Content.Server/Atmos/EntitySystems/AtmosphereSystem.Processing.cs
Content.Server/Atmos/EntitySystems/AtmosphereSystem.cs
Content.Server/Atmos/EntitySystems/FlammableSystem.cs
Content.Server/Atmos/EntitySystems/GasTankSystem.cs
Content.Server/Atmos/Monitor/Systems/AtmosMonitoringSystem.cs
Content.Server/Atmos/Piping/Binary/EntitySystems/GasPassiveGateSystem.cs
Content.Server/Atmos/Piping/Binary/EntitySystems/GasRecyclerSystem.cs
Content.Server/Atmos/Piping/Binary/EntitySystems/GasValveSystem.cs
Content.Server/Atmos/Piping/EntitySystems/AtmosDeviceSystem.cs
Content.Server/Atmos/Piping/Other/EntitySystems/GasMinerSystem.cs
Content.Server/Atmos/Piping/Trinary/EntitySystems/GasFilterSystem.cs
Content.Server/Atmos/Piping/Trinary/EntitySystems/PressureControlledValveSystem.cs
Content.Server/Atmos/Piping/Unary/EntitySystems/GasOutletInjectorSystem.cs
Content.Server/Bed/BedSystem.cs
Content.Server/Bible/BibleSystem.cs
Content.Server/Body/Commands/DestroyMechanismCommand.cs
Content.Server/Body/Systems/InternalsSystem.cs
Content.Server/Body/Systems/LungSystem.cs
Content.Server/Body/Systems/RespiratorSystem.cs
Content.Server/Body/Systems/StomachSystem.cs
Content.Server/Body/Systems/ThermalRegulatorSystem.cs
Content.Server/Botany/Systems/LogSystem.cs
Content.Server/Botany/Systems/PlantHolderSystem.cs
Content.Server/Cargo/Systems/CargoSystem.Orders.cs
Content.Server/Cargo/Systems/PricingSystem.cs
Content.Server/Chat/Systems/AutoEmoteSystem.cs
Content.Server/Chemistry/EntitySystems/ChemMasterSystem.cs
Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs
Content.Server/Chemistry/EntitySystems/SolutionInjectOnCollideSystem.cs
Content.Server/Chemistry/EntitySystems/VaporSystem.cs
Content.Server/Chemistry/ReagentEffects/Oxygenate.cs
Content.Server/Chunking/ChunkingSystem.cs
Content.Server/Cloning/CloningConsoleSystem.cs
Content.Server/Cloning/CloningSystem.cs
Content.Server/Clothing/MaskSystem.cs
Content.Server/Communications/CommunicationsConsoleSystem.cs
Content.Server/Construction/Commands/FixRotationsCommand.cs
Content.Server/Construction/Commands/TileReplaceCommand.cs
Content.Server/Construction/Commands/TileWallsCommand.cs
Content.Server/Construction/ConstructionSystem.Computer.cs
Content.Server/Construction/ConstructionSystem.cs
Content.Server/CrewManifest/CrewManifestSystem.cs
Content.Server/Decals/Commands/AddDecalCommand.cs
Content.Server/Decals/DecalSystem.cs
Content.Server/DeviceLinking/Systems/AutoLinkSystem.cs
Content.Server/Doors/Systems/DoorSystem.cs
Content.Server/Doors/Systems/FirelockSystem.cs
Content.Server/Engineering/EntitySystems/DisassembleOnAltVerbSystem.cs
Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs
Content.Server/Explosion/EntitySystems/ClusterGrenadeSystem.cs
Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs
Content.Server/Explosion/EntitySystems/TriggerSystem.Voice.cs
Content.Server/Fluids/EntitySystems/DrainSystem.cs
Content.Server/Fluids/EntitySystems/PuddleDebugDebugOverlaySystem.cs
Content.Server/Fluids/EntitySystems/PuddleSystem.cs
Content.Server/Fluids/EntitySystems/SpraySystem.cs
Content.Server/Forensics/Systems/ForensicScannerSystem.cs
Content.Server/GameTicking/GameTicker.Spawning.cs
Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs
Content.Server/Ghost/Roles/GhostRoleSystem.cs
Content.Server/Gravity/GravityGeneratorSystem.cs
Content.Server/Hands/Systems/HandsSystem.cs
Content.Server/Holiday/Christmas/RandomGiftSystem.cs
Content.Server/IdentityManagement/IdentitySystem.cs
Content.Server/IgnitionSource/IgnitionSourceSystem.cs
Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs
Content.Server/Light/EntitySystems/ExpendableLightSystem.cs
Content.Server/Light/EntitySystems/HandheldLightSystem.cs
Content.Server/Light/EntitySystems/MatchboxSystem.cs
Content.Server/Light/EntitySystems/MatchstickSystem.cs
Content.Server/Light/EntitySystems/PoweredLightSystem.cs
Content.Server/Magic/MagicSystem.cs
Content.Server/MassMedia/Systems/NewsSystem.cs
Content.Server/Mech/Systems/MechSystem.Filtering.cs
Content.Server/Mech/Systems/MechSystem.cs
Content.Server/Medical/BiomassReclaimer/BiomassReclaimerSystem.cs
Content.Server/Medical/CryoPodSystem.cs
Content.Server/Medical/SuitSensors/SuitSensorSystem.cs
Content.Server/Mind/Commands/RenameCommand.cs
Content.Server/Morgue/CrematoriumSystem.cs
Content.Server/Morgue/MorgueSystem.cs
Content.Server/Movement/Systems/JetpackSystem.cs
Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs
Content.Server/NPC/Pathfinding/PathfindingSystem.cs
Content.Server/NPC/Systems/NPCPerceptionSystem.RecentlyInjected.cs
Content.Server/NPC/Systems/NPCUtilitySystem.cs
Content.Server/NPC/Systems/NpcFactionSystem.cs
Content.Server/NodeContainer/EntitySystems/NodeContainerSystem.cs
Content.Server/Nuke/Commands/SendNukeCodesCommand.cs
Content.Server/Nuke/NukeCodePaperSystem.cs
Content.Server/Nutrition/EntitySystems/AnimalHusbandrySystem.cs
Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs
Content.Server/Payload/EntitySystems/PayloadSystem.cs
Content.Server/Physics/Controllers/RandomWalkController.cs
Content.Server/Pinpointer/ProximityBeeperSystem.cs
Content.Server/PneumaticCannon/PneumaticCannonSystem.cs
Content.Server/Pointing/EntitySystems/PointingSystem.cs
Content.Server/Pointing/EntitySystems/RoguePointingSystem.cs
Content.Server/Polymorph/Systems/PolymorphSystem.cs
Content.Server/Power/EntitySystems/CableSystem.Placer.cs
Content.Server/Power/EntitySystems/ExtensionCableSystem.cs
Content.Server/Power/EntitySystems/PowerNetSystem.cs
Content.Server/Power/EntitySystems/PowerReceiverSystem.cs
Content.Server/Radiation/Systems/GeigerSystem.cs
Content.Server/Radiation/Systems/RadiationSystem.GridCast.cs
Content.Server/Research/Systems/ResearchSystem.Client.cs
Content.Server/Research/Systems/ResearchSystem.PointSource.cs
Content.Server/Research/Systems/ResearchSystem.cs
Content.Server/Resist/EscapeInventorySystem.cs
Content.Server/Revenant/EntitySystems/CorporealSystem.cs
Content.Server/Revenant/EntitySystems/RevenantOverloadedLightsSystem.cs
Content.Server/Revenant/EntitySystems/RevenantSystem.cs
Content.Server/Salvage/SalvageRulerCommand.cs
Content.Server/Salvage/SalvageSystem.ExpeditionConsole.cs
Content.Server/Shuttles/Components/ThrusterComponent.cs
Content.Server/Shuttles/Systems/DockingSystem.AutoDock.cs
Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs
Content.Server/Shuttles/Systems/DockingSystem.cs
Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs
Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs
Content.Server/Shuttles/Systems/ShuttleSystem.IFF.cs
Content.Server/Shuttles/Systems/ThrusterSystem.cs
Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs
Content.Server/Singularity/EntitySystems/ContainmentFieldSystem.cs
Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs
Content.Server/Singularity/EntitySystems/GravityWellSystem.cs
Content.Server/Singularity/EntitySystems/SingularitySystem.cs
Content.Server/Solar/EntitySystems/PowerSolarSystem.cs
Content.Server/Speech/EntitySystems/AddAccentClothingSystem.cs
Content.Server/Station/Systems/StationSystem.cs
Content.Server/StationEvents/Events/BluespaceLockerRule.cs
Content.Server/StationEvents/Events/BreakerFlipRule.cs
Content.Server/StationEvents/Events/MeteorSwarmRule.cs
Content.Server/StationEvents/Events/PowerGridCheckRule.cs
Content.Server/StationEvents/Events/RandomSentienceRule.cs
Content.Server/Storage/EntitySystems/BluespaceLockerSystem.cs
Content.Server/Storage/EntitySystems/CursedEntityStorageSystem.cs
Content.Server/Storage/EntitySystems/EntityStorageSystem.cs
Content.Server/Storage/EntitySystems/PickRandomSystem.cs
Content.Server/Storage/EntitySystems/SpawnItemsOnUseSystem.cs
Content.Server/Strip/StrippableSystem.cs
Content.Server/SurveillanceCamera/Systems/SurveillanceCameraMonitorSystem.cs
Content.Server/Tabletop/TabletopSystem.cs
Content.Server/Temperature/Systems/TemperatureSystem.cs
Content.Server/Tools/ToolSystem.Welder.cs
Content.Server/Traitor/Uplink/SurplusBundle/SurplusBundleSystem.cs
Content.Server/Traits/Assorted/NarcolepsySystem.cs
Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/PolyArtifactSystem.cs
Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/ShuffleArtifactSystem.cs
Content.Server/Xenoarchaeology/XenoArtifacts/RandomArtifactSpriteSystem.cs
Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactDeathTriggerSystem.cs
Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactElectricityTriggerSystem.cs
Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactGasTriggerSystem.cs
Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactHeatTriggerSystem.cs
Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactMagnetTriggerSystem.cs
Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactMusicTriggerSystem.cs
Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactPressureTriggerSystem.cs
Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactTimerTriggerSystem.cs
Content.Shared/Access/Systems/SharedIdCardSystem.cs
Content.Shared/Actions/ActionContainerSystem.cs
Content.Shared/Actions/SharedActionsSystem.cs
Content.Shared/Alert/AlertsSystem.cs
Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs
Content.Shared/Chemistry/MetabolismMovespeedModifierSystem.cs
Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs
Content.Shared/Coordinates/EntityCoordinatesExtensions.cs
Content.Shared/Doors/Systems/SharedDoorSystem.cs
Content.Shared/Examine/ExamineSystemShared.cs
Content.Shared/Follower/FollowerSystem.cs
Content.Shared/Friction/TileFrictionController.cs
Content.Shared/Gravity/SharedFloatingVisualizerSystem.cs
Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs
Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs
Content.Shared/Hands/SharedHandVirtualItemSystem.cs
Content.Shared/Lathe/SharedLatheSystem.cs
Content.Shared/Light/SharedHandheldLightSystem.cs
Content.Shared/Maps/TurfHelpers.cs
Content.Shared/Mobs/Systems/MobStateSystem.StateMachine.cs
Content.Shared/Physics/Controllers/SharedConveyorController.cs
Content.Shared/Random/RulesSystem.cs
Content.Shared/Revenant/EntitySystems/SharedRevenantOverloadedLightsSystem.cs
Content.Shared/Singularity/Components/ContainmentFieldGeneratorComponent.cs
Content.Shared/Singularity/EntitySystems/SharedSingularitySystem.cs
Content.Shared/Stacks/SharedStackSystem.cs
Content.Shared/StatusEffect/StatusEffectsSystem.cs
Content.Shared/Storage/EntitySystems/DumpableSystem.cs
Content.Shared/Strip/SharedStrippableSystem.cs
Content.Shared/Weather/SharedWeatherSystem.cs
SpaceStation14.sln.DotSettings

index e175f396615a82a9decbc8329222c444dc8573f9..eede3a6217f007d7d9e794968027fc73985f39d7 100644 (file)
@@ -1,10 +1,12 @@
+using System.Linq;
+using System.Numerics;
 using JetBrains.Annotations;
+using Robust.Client.GameObjects;
 using Robust.Client.Graphics;
 using Robust.Client.ResourceManagement;
 using Robust.Shared.Enums;
 using Robust.Shared.Map;
-using System.Linq;
-using System.Numerics;
+using Robust.Shared.Map.Components;
 
 namespace Content.Client.Administration.UI.SpawnExplosion;
 
@@ -13,7 +15,6 @@ public sealed class ExplosionDebugOverlay : Overlay
 {
     [Dependency] private readonly IEntityManager _entityManager = default!;
     [Dependency] private readonly IEyeManager _eyeManager = default!;
-    [Dependency] private readonly IMapManager _mapManager = default!;
 
     public Dictionary<int, List<Vector2i>>? SpaceTiles;
     public Dictionary<EntityUid, Dictionary<int, List<Vector2i>>> Tiles = new();
@@ -61,14 +62,15 @@ public sealed class ExplosionDebugOverlay : Overlay
         var handle = args.ScreenHandle;
         Box2 gridBounds;
         var xformQuery = _entityManager.GetEntityQuery<TransformComponent>();
+        var xformSystem = _entityManager.System<TransformSystem>();
 
         foreach (var (gridId, tileSets) in Tiles)
         {
-            if (!_mapManager.TryGetGrid(gridId, out var grid))
+            if (!_entityManager.TryGetComponent(gridId, out MapGridComponent? grid))
                 continue;
 
-            var gridXform = xformQuery.GetComponent(grid.Owner);
-            var (_, _, matrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(xformQuery);
+            var gridXform = xformQuery.GetComponent(gridId);
+            var (_, _, matrix, invMatrix) = xformSystem.GetWorldPositionRotationMatrixWithInv(gridXform, xformQuery);
             gridBounds = invMatrix.TransformBox(args.WorldBounds).Enlarged(grid.TileSize * 2);
             DrawText(handle, gridBounds, matrix, tileSets, grid.TileSize);
         }
@@ -114,9 +116,9 @@ public sealed class ExplosionDebugOverlay : Overlay
             }
         }
 
-        if (tileSets.ContainsKey(0))
+        if (tileSets.TryGetValue(0, out var set))
         {
-            var epicenter = tileSets[0].First();
+            var epicenter = set.First();
             var worldCenter = transform.Transform((epicenter + Vector2Helpers.Half) * tileSize);
             var screenCenter = _eyeManager.WorldToScreen(worldCenter) + new Vector2(-24, -24);
             var text = $"{Intensity[0]:F2}\nΣ={TotalIntensity:F1}\nΔ={Slope:F1}";
@@ -129,14 +131,15 @@ public sealed class ExplosionDebugOverlay : Overlay
         var handle = args.WorldHandle;
         Box2 gridBounds;
         var xformQuery = _entityManager.GetEntityQuery<TransformComponent>();
+        var xformSystem = _entityManager.System<TransformSystem>();
 
         foreach (var (gridId, tileSets) in Tiles)
         {
-            if (!_mapManager.TryGetGrid(gridId, out var grid))
+            if (!_entityManager.TryGetComponent(gridId, out MapGridComponent? grid))
                 continue;
 
-            var gridXform = xformQuery.GetComponent(grid.Owner);
-            var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(xformQuery);
+            var gridXform = xformQuery.GetComponent(gridId);
+            var (_, _, worldMatrix, invWorldMatrix) = xformSystem.GetWorldPositionRotationMatrixWithInv(gridXform, xformQuery);
             gridBounds = invWorldMatrix.TransformBox(args.WorldBounds).Enlarged(grid.TileSize * 2);
             handle.SetTransform(worldMatrix);
             DrawTiles(handle, gridBounds, tileSets, SpaceTileSize);
index 2f643caae28977cdfcc238b58646a4b6ecf9028e..7e2fdda3e25a246b70142e6e9977db3b06100e8c 100644 (file)
@@ -1,14 +1,10 @@
-using System.Collections.Generic;
-using System.Linq;
 using JetBrains.Annotations;
 using Robust.Client.AutoGenerated;
 using Robust.Client.Console;
 using Robust.Client.Player;
 using Robust.Client.UserInterface.Controls;
 using Robust.Client.UserInterface.CustomControls;
-using Robust.Shared.GameObjects;
-using Robust.Shared.IoC;
-using Robust.Shared.Map;
+using Robust.Client.UserInterface.XAML;
 using Robust.Shared.Map.Components;
 
 namespace Content.Client.Administration.UI.Tabs.AtmosTab
@@ -17,16 +13,29 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
     [UsedImplicitly]
     public sealed partial class AddAtmosWindow : DefaultWindow
     {
-        private IEnumerable<MapGridComponent>? _data;
+        [Dependency] private readonly IPlayerManager _players = default!;
+        [Dependency] private readonly IEntityManager _entities = default!;
+
+        private readonly List<Entity<MapGridComponent>> _data = new();
+
+        public AddAtmosWindow()
+        {
+            RobustXamlLoader.Load(this);
+            IoCManager.InjectDependencies(this);
+        }
 
         protected override void EnteredTree()
         {
-            _data = IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Owner != 0);
-            foreach (var grid in _data)
+            _data.Clear();
+
+            var player = _players.LocalPlayer?.ControlledEntity;
+            var playerGrid = _entities.GetComponentOrNull<TransformComponent>(player)?.GridUid;
+            var query = IoCManager.Resolve<IEntityManager>().AllEntityQueryEnumerator<MapGridComponent>();
+
+            while (query.MoveNext(out var uid, out var grid))
             {
-                var player = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
-                var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(player)?.GridUid;
-                GridOptions.AddItem($"{grid.Owner} {(playerGrid == grid.Owner ? " (Current)" : "")}");
+                _data.Add((uid, grid));
+                GridOptions.AddItem($"{uid} {(playerGrid == uid ? " (Current)" : "")}");
             }
 
             GridOptions.OnItemSelected += eventArgs => GridOptions.SelectId(eventArgs.Id);
@@ -35,12 +44,8 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
 
         private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
         {
-            if (_data == null)
-                return;
-            var dataList = _data.ToList();
-            var entManager = IoCManager.Resolve<IEntityManager>();
-            var selectedGrid = dataList[GridOptions.SelectedId].Owner;
-            IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"addatmos {entManager.GetNetEntity(selectedGrid)}");
+            var selectedGrid = _data[GridOptions.SelectedId].Owner;
+            IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand($"addatmos {_entities.GetNetEntity(selectedGrid)}");
         }
     }
 }
index 9ad0ca8cc687b5f43b172f9c604ed4248efc435e..3f5df2cf006bd2977b8ed687ad0cbd4cdc8c0e92 100644 (file)
@@ -1,4 +1,3 @@
-using System.Linq;
 using Content.Client.Station;
 using Robust.Client.AutoGenerated;
 using Robust.Client.UserInterface;
@@ -40,13 +39,34 @@ public sealed partial class ObjectsTab : Control
 
     private void RefreshObjectList(ObjectsTabSelection selection)
     {
-        var entities = selection switch
+        var entities = new List<EntityUid>();
+        switch (selection)
         {
-            ObjectsTabSelection.Stations => _entityManager.EntitySysManager.GetEntitySystem<StationSystem>().Stations.ToList(),
-            ObjectsTabSelection.Grids => _entityManager.EntityQuery<MapGridComponent>(true).Select(x => x.Owner).ToList(),
-            ObjectsTabSelection.Maps => _entityManager.EntityQuery<MapComponent>(true).Select(x => x.Owner).ToList(),
-            _ => throw new ArgumentOutOfRangeException(nameof(selection), selection, null),
-        };
+            case ObjectsTabSelection.Stations:
+                entities.AddRange(_entityManager.EntitySysManager.GetEntitySystem<StationSystem>().Stations);
+                break;
+            case ObjectsTabSelection.Grids:
+            {
+                var query = _entityManager.AllEntityQueryEnumerator<MapGridComponent>();
+                while (query.MoveNext(out var uid, out _))
+                {
+                    entities.Add(uid);
+                }
+
+                break;
+            }
+            case ObjectsTabSelection.Maps:
+            {
+                var query = _entityManager.AllEntityQueryEnumerator<MapComponent>();
+                while (query.MoveNext(out var uid, out _))
+                {
+                    entities.Add(uid);
+                }
+                break;
+            }
+            default:
+                throw new ArgumentOutOfRangeException(nameof(selection), selection, null);
+        }
 
         foreach (var control in _objects)
         {
index cfdae7bc931c18d26d95b1a1d9268dc7a53413e5..bb6d2d4df4ed12498b42bb3b32ef3cece47846e6 100644 (file)
@@ -47,20 +47,20 @@ public sealed class ClientAlertsSystem : AlertsSystem
         }
     }
 
-    protected override void AfterShowAlert(AlertsComponent alertsComponent)
+    protected override void AfterShowAlert(Entity<AlertsComponent> alerts)
     {
-        if (_playerManager.LocalPlayer?.ControlledEntity != alertsComponent.Owner)
+        if (_playerManager.LocalPlayer?.ControlledEntity != alerts.Owner)
             return;
 
-        SyncAlerts?.Invoke(this, alertsComponent.Alerts);
+        SyncAlerts?.Invoke(this, alerts.Comp.Alerts);
     }
 
-    protected override void AfterClearAlert(AlertsComponent alertsComponent)
+    protected override void AfterClearAlert(Entity<AlertsComponent> alertsComponent)
     {
         if (_playerManager.LocalPlayer?.ControlledEntity != alertsComponent.Owner)
             return;
 
-        SyncAlerts?.Invoke(this, alertsComponent.Alerts);
+        SyncAlerts?.Invoke(this, alertsComponent.Comp.Alerts);
     }
 
     private void ClientAlertsHandleState(EntityUid uid, AlertsComponent component, ref AfterAutoHandleStateEvent args)
index 6d1752a8c92a716930e0fe4eaa37cf3bff83a73a..72adf276bffbab55b20babe9c11d647af1f444d8 100644 (file)
@@ -4,10 +4,8 @@ using Content.Shared.Atmos;
 using Content.Shared.Atmos.EntitySystems;
 using Robust.Client.Graphics;
 using Robust.Shared.Enums;
-using Robust.Shared.GameObjects;
-using Robust.Shared.IoC;
 using Robust.Shared.Map;
-using Robust.Shared.Maths;
+using Robust.Shared.Map.Components;
 
 namespace Content.Client.Atmos.Overlays
 {
@@ -19,6 +17,7 @@ namespace Content.Client.Atmos.Overlays
         [Dependency] private readonly IMapManager _mapManager = default!;
 
         public override OverlaySpace Space => OverlaySpace.WorldSpace;
+        private List<Entity<MapGridComponent>> _grids = new();
 
         internal AtmosDebugOverlay(AtmosDebugOverlaySystem system)
         {
@@ -41,10 +40,19 @@ namespace Content.Client.Atmos.Overlays
             // 3. "Is this going to make it harder for atmos programmers to add data that may not be chunk-friendly into the atmos debugger?"
             // Nanotrasen needs YOU! to avoid premature optimization in critical debugging tools - 20kdc
 
-            foreach (var mapGrid in _mapManager.FindGridsIntersecting(mapId, worldBounds))
+            _grids.Clear();
+
+            _mapManager.FindGridsIntersecting(mapId, worldBounds, ref _grids, (EntityUid uid, MapGridComponent grid,
+                ref List<Entity<MapGridComponent>> state) =>
+            {
+                state.Add((uid, grid));
+                return true;
+            });
+
+            foreach (var (uid, mapGrid) in _grids)
             {
-                if (!_atmosDebugOverlaySystem.HasData(mapGrid.Owner) ||
-                    !_entManager.TryGetComponent<TransformComponent>(mapGrid.Owner, out var xform))
+                if (!_atmosDebugOverlaySystem.HasData(uid) ||
+                    !_entManager.TryGetComponent<TransformComponent>(uid, out var xform))
                     continue;
 
                 drawHandle.SetTransform(xform.WorldMatrix);
@@ -53,7 +61,7 @@ namespace Content.Client.Atmos.Overlays
                 {
                     foreach (var tile in mapGrid.GetTilesIntersecting(worldBounds))
                     {
-                        var dataMaybeNull = _atmosDebugOverlaySystem.GetData(mapGrid.Owner, tile.GridIndices);
+                        var dataMaybeNull = _atmosDebugOverlaySystem.GetData(uid, tile.GridIndices);
                         if (dataMaybeNull != null)
                         {
                             var data = (SharedAtmosDebugOverlaySystem.AtmosDebugOverlayData) dataMaybeNull;
@@ -61,9 +69,10 @@ namespace Content.Client.Atmos.Overlays
                             {
                                 // -- Mole Count --
                                 float total = 0;
-                                switch (_atmosDebugOverlaySystem.CfgMode) {
+                                switch (_atmosDebugOverlaySystem.CfgMode)
+                                {
                                     case AtmosDebugOverlayMode.TotalMoles:
-                                        foreach (float f in data.Moles)
+                                        foreach (var f in data.Moles)
                                         {
                                             total += f;
                                         }
@@ -75,7 +84,7 @@ namespace Content.Client.Atmos.Overlays
                                         total = data.Temperature;
                                         break;
                                 }
-                                var interp = ((total - _atmosDebugOverlaySystem.CfgBase) / _atmosDebugOverlaySystem.CfgScale);
+                                var interp = (total - _atmosDebugOverlaySystem.CfgBase) / _atmosDebugOverlaySystem.CfgScale;
                                 Color res;
                                 if (_atmosDebugOverlaySystem.CfgCBM)
                                 {
index 3110d81384a2aba6b8564719e697b8bfd2a095d8..703430df9ef1a245d2e9004a9429b083823185a9 100644 (file)
@@ -39,7 +39,7 @@ public sealed class AmbientSoundOverlay : Overlay
 
             if (ambientSound.Enabled)
             {
-                if (_ambient.IsActive(ambientSound))
+                if (_ambient.IsActive((ent, ambientSound)))
                 {
                     worldHandle.DrawCircle(xformSystem.GetWorldPosition(xform), Size, Color.LightGreen.WithAlpha(Alpha * 2f));
                 }
index 8fe331119a6b30c9d10a2e71452dc02ff015be82..aebacb94f63be0e05b9dc1fa392e8b57e356ad59 100644 (file)
@@ -1,18 +1,16 @@
+using System.Linq;
+using System.Numerics;
 using Content.Shared.Audio;
 using Content.Shared.CCVar;
+using Robust.Client.GameObjects;
 using Robust.Client.Graphics;
 using Robust.Client.Player;
 using Robust.Shared.Audio;
-using Robust.Shared.Log;
 using Robust.Shared.Configuration;
-using Robust.Shared.Map;
 using Robust.Shared.Physics;
 using Robust.Shared.Random;
 using Robust.Shared.Timing;
 using Robust.Shared.Utility;
-using System.Linq;
-using System.Numerics;
-using Robust.Client.GameObjects;
 
 namespace Content.Client.Audio;
 //TODO: This is using a incomplete version of the whole "only play nearest sounds" algo, that breaks down a bit should the ambient sound cap get hit.
@@ -50,7 +48,7 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
     /// </summary>
     private int MaxSingleSound => (int) (_maxAmbientCount / (16.0f / 6.0f));
 
-    private readonly Dictionary<AmbientSoundComponent, (IPlayingAudioStream? Stream, SoundSpecifier Sound, string Path)> _playingSounds = new();
+    private readonly Dictionary<Entity<AmbientSoundComponent>, (IPlayingAudioStream? Stream, SoundSpecifier Sound, string Path)> _playingSounds = new();
     private readonly Dictionary<string, int> _playingCount = new();
 
     public bool OverlayEnabled
@@ -80,7 +78,7 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
     /// </summary>
     /// <param name="component"></param>
     /// <returns></returns>
-    public bool IsActive(AmbientSoundComponent component)
+    public bool IsActive(Entity<AmbientSoundComponent> component)
     {
         return _playingSounds.ContainsKey(component);
     }
@@ -100,7 +98,7 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
 
     private void OnShutdown(EntityUid uid, AmbientSoundComponent component, ComponentShutdown args)
     {
-        if (!_playingSounds.Remove(component, out var sound))
+        if (!_playingSounds.Remove((uid, component), out var sound))
             return;
 
         sound.Stream?.Stop();
@@ -113,7 +111,7 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
     {
         _ambienceVolume = value;
 
-        foreach (var (comp, values) in _playingSounds)
+        foreach (var ((_, comp), values) in _playingSounds)
         {
             if (values.Stream == null)
                 continue;
@@ -188,7 +186,7 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
 
     private readonly struct QueryState
     {
-        public readonly Dictionary<string, List<(float Importance, AmbientSoundComponent)>> SourceDict = new();
+        public readonly Dictionary<string, List<(float Importance, Entity<AmbientSoundComponent>)>> SourceDict = new();
         public readonly Vector2 MapPos;
         public readonly TransformComponent Player;
         public readonly EntityQuery<TransformComponent> Query;
@@ -226,7 +224,7 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
 
         // Prioritize far away & loud sounds.
         var importance = range * (ambientComp.Volume + 32);
-        state.SourceDict.GetOrNew(key).Add((importance, ambientComp));
+        state.SourceDict.GetOrNew(key).Add((importance, (ambientComp.Owner, ambientComp)));
         return true;
     }
 
@@ -240,9 +238,10 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
         var mapPos = playerXform.MapPosition;
 
         // Remove out-of-range ambiences
-        foreach (var (comp, sound) in _playingSounds)
+        foreach (var (ent, sound) in _playingSounds)
         {
-            var entity = comp.Owner;
+            var entity = ent.Owner;
+            var comp = ent.Comp;
 
             if (comp.Enabled &&
                 // Don't keep playing sounds that have changed since.
@@ -260,7 +259,7 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
             }
 
             sound.Stream?.Stop();
-            _playingSounds.Remove(comp);
+            _playingSounds.Remove((entity, comp));
             _playingCount[sound.Path] -= 1;
             if (_playingCount[sound.Path] == 0)
                 _playingCount.Remove(sound.Path);
@@ -285,11 +284,12 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
 
             sources.Sort(static (a, b) => b.Importance.CompareTo(a.Importance));
 
-            foreach (var (_, comp) in sources)
+            foreach (var (_, ent) in sources)
             {
-                var uid = comp.Owner;
+                var uid = ent.Owner;
+                var comp = ent.Comp;
 
-                if (_playingSounds.ContainsKey(comp) ||
+                if (_playingSounds.ContainsKey(ent) ||
                     metaQuery.GetComponent(uid).EntityPaused)
                     continue;
 
@@ -303,7 +303,7 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
                 if (stream == null)
                     continue;
 
-                _playingSounds[comp] = (stream, comp.Sound, key);
+                _playingSounds[ent] = (stream, comp.Sound, key);
                 playingCount++;
 
                 if (_playingSounds.Count >= _maxAmbientCount)
index 3c870f6e6ec17091bc1d14e823afcabd163980e4..5e479409cf907541076452aee4a82c2194b3b7fb 100644 (file)
@@ -38,12 +38,16 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
         var mover = GetEntity(msg.Mover);
 
         //Filter out entities in range to see that they're a mob and add them to the mobMoverEntities hash for faster lookup
-        foreach (var moverComp in _entityLookup.GetComponentsInRange<MobMoverComponent>(xform.Coordinates, box.Distance))
+        var movers = new HashSet<Entity<MobMoverComponent>>();
+        _entityLookup.GetEntitiesInRange(xform.Coordinates, box.Distance, movers);
+
+        foreach (var moverComp in movers)
         {
-            if (moverComp.Owner == mover)
+            var uid = moverComp.Owner;
+            if (uid == mover)
                 continue;
 
-            mobMoverEntities.Add(moverComp.Owner);
+            mobMoverEntities.Add(uid);
         }
 
         //Play the effect for the mobs as long as they can see the box and are in range.
index a22ea945ef260812376b2051e1d0b30cc2c1865a..4b04aa9dd713f68f06d4c285e86c0e37b8eb8c29 100644 (file)
@@ -33,7 +33,7 @@ public sealed class ChasmFallingVisualsSystem : EntitySystem
         if (_anim.HasRunningAnimation(player, _chasmFallAnimationKey))
             return;
 
-        _anim.Play(player, GetFallingAnimation(component), _chasmFallAnimationKey);
+        _anim.Play((uid, player), GetFallingAnimation(component), _chasmFallAnimationKey);
     }
 
     private void OnComponentRemove(EntityUid uid, ChasmFallingComponent component, ComponentRemove args)
index e9c2073b20af96792863a5be1e41f216b5f0aea7..28433d2337f6af198638b6ada7955f8316d4e15f 100644 (file)
@@ -16,18 +16,18 @@ namespace Content.Client.Commands
         {
             var entityManager = IoCManager.Resolve<IEntityManager>();
             var containerSys = entityManager.System<SharedContainerSystem>();
-            var organs = entityManager.EntityQuery<OrganComponent>(true);
+            var query = entityManager.AllEntityQueryEnumerator<OrganComponent>();
 
-            foreach (var part in organs)
+            while (query.MoveNext(out var uid, out _))
             {
-                if (!entityManager.TryGetComponent(part.Owner, out SpriteComponent? sprite))
+                if (!entityManager.TryGetComponent(uid, out SpriteComponent? sprite))
                 {
                     continue;
                 }
 
                 sprite.ContainerOccluded = false;
 
-                var tempParent = part.Owner;
+                var tempParent = uid;
                 while (containerSys.TryGetContainingContainer(tempParent, out var container))
                 {
                     if (!container.ShowContents)
index f86aee87149d68dc1dc489ce428613fe8dc5afde..b94278f8c9efb3c3f26bbc9ae2816e39aca9bf7f 100644 (file)
@@ -17,14 +17,11 @@ namespace Content.Client.Commands
         public void Execute(IConsoleShell shell, string argStr, string[] args)
         {
             var entityManager = IoCManager.Resolve<IEntityManager>();
-            var organs = entityManager.EntityQuery<OrganComponent>(true);
+            var query = entityManager.AllEntityQueryEnumerator<OrganComponent, SpriteComponent>();
 
-            foreach (var mechanism in organs)
+            while (query.MoveNext(out _, out var sprite))
             {
-                if (entityManager.TryGetComponent(mechanism.Owner, out SpriteComponent? sprite))
-                {
-                    sprite.ContainerOccluded = false;
-                }
+                sprite.ContainerOccluded = false;
             }
 
             IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand("showcontainedcontext");
index c37a0e3aea35b8e1e353dfad460907759604a585..f2c11e2a682ebfc896cb2ccd0114dedc35599d20 100644 (file)
@@ -31,11 +31,11 @@ namespace Content.Client.Decals.Overlays
             // Shouldn't need to clear cached textures unless the prototypes get reloaded.
             var handle = args.WorldHandle;
             var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
+            var xformSystem = _entManager.System<TransformSystem>();
             var eyeAngle = args.Viewport.Eye?.Rotation ?? Angle.Zero;
 
             foreach (var (decalGrid, xform) in _entManager.EntityQuery<DecalGridComponent, TransformComponent>(true))
             {
-                var gridId = decalGrid.Owner;
                 var zIndexDictionary = decalGrid.DecalRenderIndex;
 
                 if (zIndexDictionary.Count == 0)
@@ -44,7 +44,7 @@ namespace Content.Client.Decals.Overlays
                 if (xform.MapID != args.MapId)
                     continue;
 
-                var (_, worldRot, worldMatrix) = xform.GetWorldPositionRotationMatrix(xformQuery);
+                var (_, worldRot, worldMatrix) = xformSystem.GetWorldPositionRotationMatrix(xform, xformQuery);
 
                 handle.SetTransform(worldMatrix);
 
index c4b88346de4661b11c8952e8ce966645474b5d23..4b82d3506aedd143d8c56c4317fed063fc5f1062 100644 (file)
@@ -22,8 +22,9 @@ public sealed class DoorSystem : SharedDoorSystem
         SubscribeLocalEvent<DoorComponent, AppearanceChangeEvent>(OnAppearanceChange);
     }
 
-    protected override void OnComponentInit(EntityUid uid, DoorComponent comp, ComponentInit args)
+    protected override void OnComponentInit(Entity<DoorComponent> ent, ref ComponentInit args)
     {
+        var comp = ent.Comp;
         comp.OpenSpriteStates = new(2);
         comp.ClosedSpriteStates = new(2);
 
index 34acb7f370f93eb958508936af2dc87f0e429af5..9a844019480bf7c8a8939a143b240abaf3f2efeb 100644 (file)
@@ -114,7 +114,7 @@ public sealed class ColorFlashEffectSystem : SharedColorFlashEffectSystem
             var comp = EnsureComp<ColorFlashEffectComponent>(ent);
             comp.NetSyncEnabled = false;
             comp.Color = sprite.Color;
-            _animation.Play(player, animation, AnimationKey);
+            _animation.Play((ent, player), animation, AnimationKey);
         }
     }
 }
index 17df782887dc93b10cb1b35872a257b5ad23fe4a..2ab84d4438a818dc41e08bc96f742fe58993226f 100644 (file)
@@ -4,6 +4,7 @@ using JetBrains.Annotations;
 using Robust.Client.Graphics;
 using Robust.Shared.Enums;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Random;
 
@@ -63,10 +64,10 @@ public sealed class ExplosionOverlay : Overlay
         Box2 gridBounds;
         foreach (var (gridId, tiles) in visuals.Tiles)
         {
-            if (!_mapManager.TryGetGrid(gridId, out var grid))
+            if (!_entMan.TryGetComponent(gridId, out MapGridComponent? grid))
                 continue;
 
-            var xform = xforms.GetComponent(grid.Owner);
+            var xform = xforms.GetComponent(gridId);
             var (_, _, worldMatrix, invWorldMatrix) = xform.GetWorldPositionRotationMatrixWithInv(xforms);
 
             gridBounds = invWorldMatrix.TransformBox(worldBounds).Enlarged(grid.TileSize * 2);
index f2f5ca1b9ade427a8ae72822a9223fbcd8023905..8c8b13a1efe78ca8fb1d78ed0f91b50f0c6df4de 100644 (file)
@@ -1,9 +1,9 @@
-using System.Numerics;
-using Content.Shared.FixedPoint;
+using Content.Shared.FixedPoint;
 using Robust.Client.Graphics;
 using Robust.Client.ResourceManagement;
 using Robust.Shared.Enums;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 
 namespace Content.Client.Fluids;
 
@@ -52,7 +52,7 @@ public sealed class PuddleOverlay : Overlay
 
         foreach (var gridId in _debugOverlaySystem.TileData.Keys)
         {
-            if (!_mapManager.TryGetGrid(gridId, out var mapGrid))
+            if (!_entityManager.TryGetComponent(gridId, out MapGridComponent? mapGrid))
                 continue;
 
             var gridXform = xformQuery.GetComponent(gridId);
@@ -60,7 +60,7 @@ public sealed class PuddleOverlay : Overlay
             gridBounds = invWorldMatrix.TransformBox(args.WorldBounds).Enlarged(mapGrid.TileSize * 2);
             drawHandle.SetTransform(worldMatrix);
 
-            foreach (var debugOverlayData in _debugOverlaySystem.GetData(mapGrid.Owner))
+            foreach (var debugOverlayData in _debugOverlaySystem.GetData(gridId))
             {
                 var centre = (debugOverlayData.Pos + Vector2Helpers.Half) * mapGrid.TileSize;
 
@@ -85,14 +85,14 @@ public sealed class PuddleOverlay : Overlay
 
         foreach (var gridId in _debugOverlaySystem.TileData.Keys)
         {
-            if (!_mapManager.TryGetGrid(gridId, out var mapGrid))
+            if (!_entityManager.TryGetComponent(gridId, out MapGridComponent? mapGrid))
                 continue;
 
             var gridXform = xformQuery.GetComponent(gridId);
             var (_, _, matrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(xformQuery);
             var gridBounds = invMatrix.TransformBox(args.WorldBounds).Enlarged(mapGrid.TileSize * 2);
 
-            foreach (var debugOverlayData in _debugOverlaySystem.GetData(mapGrid.Owner))
+            foreach (var debugOverlayData in _debugOverlaySystem.GetData(gridId))
             {
                 var centre = (debugOverlayData.Pos + Vector2Helpers.Half) * mapGrid.TileSize;
 
index 5bc92f0c28d9e3206189dda9d76650734562edeb..fa680de1fc055fb7c8b2a84d0bc2d21d8178d5d3 100644 (file)
@@ -12,8 +12,8 @@ public sealed class HandheldGpsSystem : EntitySystem
         SubscribeLocalEvent<HandheldGPSComponent, ItemStatusCollectMessage>(OnItemStatus);
     }
 
-    private void OnItemStatus(EntityUid uid, HandheldGPSComponent component, ItemStatusCollectMessage args)
+    private void OnItemStatus(Entity<HandheldGPSComponent> ent, ref ItemStatusCollectMessage args)
     {
-        args.Controls.Add(new HandheldGpsStatusControl(component));
+        args.Controls.Add(new HandheldGpsStatusControl(ent));
     }
 }
index 2b703105eac03b129ff26e08a047b628c1e78ad8..de6a1031bad0070f475409d4bd7aa11f01e88893 100644 (file)
@@ -9,12 +9,12 @@ namespace Content.Client.GPS.UI;
 
 public sealed class HandheldGpsStatusControl : Control
 {
-    private readonly HandheldGPSComponent _parent;
+    private readonly Entity<HandheldGPSComponent> _parent;
     private readonly RichTextLabel _label;
     private float _updateDif;
     private readonly IEntityManager _entMan;
 
-    public HandheldGpsStatusControl(HandheldGPSComponent parent)
+    public HandheldGpsStatusControl(Entity<HandheldGPSComponent> parent)
     {
         _parent = parent;
         _entMan = IoCManager.Resolve<IEntityManager>();
@@ -28,10 +28,10 @@ public sealed class HandheldGpsStatusControl : Control
         base.FrameUpdate(args);
 
         _updateDif += args.DeltaSeconds;
-        if (_updateDif < _parent.UpdateRate)
+        if (_updateDif < _parent.Comp.UpdateRate)
             return;
 
-        _updateDif -= _parent.UpdateRate;
+        _updateDif -= _parent.Comp.UpdateRate;
 
         UpdateGpsDetails();
     }
@@ -39,7 +39,7 @@ public sealed class HandheldGpsStatusControl : Control
     private void UpdateGpsDetails()
     {
         var posText = "Error";
-        if (_entMan.TryGetComponent(_parent.Owner, out TransformComponent? transComp))
+        if (_entMan.TryGetComponent(_parent, out TransformComponent? transComp))
         {
             var pos =  transComp.MapPosition;
             var x = (int) pos.X;
index 8fd11dc19eb953cb8675eebc2c40781c6f831f8a..d0b39abb374748adf19a37c354a821c86c0013d7 100644 (file)
@@ -5,7 +5,6 @@ using System.Numerics;
 using Content.Client.ContextMenu.UI;
 using Content.Client.Examine;
 using Content.Client.Guidebook.Richtext;
-using Content.Client.Verbs;
 using Content.Client.Verbs.UI;
 using Content.Shared.Input;
 using Content.Shared.Tag;
@@ -37,7 +36,9 @@ public sealed partial class GuideEntityEmbed : BoxContainer, IDocumentTag
 
     public bool Interactive;
 
-    public SpriteComponent? Sprite => View.Sprite;
+    public Entity<SpriteComponent>? Sprite => View.Entity == null || View.Sprite == null
+        ? null
+        : (View.Entity.Value, View.Sprite);
 
     public Vector2 Scale
     {
@@ -127,7 +128,7 @@ public sealed partial class GuideEntityEmbed : BoxContainer, IDocumentTag
         base.Dispose(disposing);
 
         if (Sprite is not null)
-            _entityManager.DeleteEntity(Sprite.Owner);
+            _entityManager.DeleteEntity(Sprite);
     }
 
     public bool TryParseTag(Dictionary<string, string> args, [NotNullWhen(true)] out Control? control)
index 1189f5a66ec754eabc026b16a695dde9e7ac6c22..f44bc1ec97985d4bdfa0bdee6bebaf57839a49cc 100644 (file)
@@ -1,7 +1,5 @@
 using System.Diagnostics.CodeAnalysis;
 using System.Linq;
-using System.Numerics;
-using Content.Client.Animations;
 using Content.Client.Examine;
 using Content.Client.Strip;
 using Content.Client.Verbs.UI;
@@ -15,7 +13,6 @@ using Robust.Client.Player;
 using Robust.Client.UserInterface;
 using Robust.Shared.Containers;
 using Robust.Shared.GameStates;
-using Robust.Shared.Map;
 using Robust.Shared.Timing;
 
 namespace Content.Client.Hands.Systems
@@ -416,21 +413,21 @@ namespace Content.Client.Hands.Systems
             base.RemoveHand(uid, handName, handsComp);
         }
 
-        private void OnHandActivated(HandsComponent? handsComponent)
+        private void OnHandActivated(Entity<HandsComponent>? ent)
         {
-            if (handsComponent == null)
+            if (ent is not { } hand)
                 return;
 
-            if (_playerManager.LocalPlayer?.ControlledEntity != handsComponent.Owner)
+            if (_playerManager.LocalPlayer?.ControlledEntity != hand.Owner)
                 return;
 
-            if (handsComponent.ActiveHand == null)
+            if (hand.Comp.ActiveHand == null)
             {
                 OnPlayerSetActiveHand?.Invoke(null);
                 return;
             }
 
-            OnPlayerSetActiveHand?.Invoke(handsComponent.ActiveHand.Name);
+            OnPlayerSetActiveHand?.Invoke(hand.Comp.ActiveHand.Name);
         }
     }
 }
index 9e1b39aed2ffce88253c46b51b2fff5ee8133417..baeb4fe0259e66f904d1c6fd2e76e6883da6c633 100644 (file)
@@ -1,4 +1,3 @@
-using System.Collections.Generic;
 using Content.Client.HealthOverlay.UI;
 using Content.Shared.Damage;
 using Content.Shared.GameTicking;
@@ -6,8 +5,6 @@ using Content.Shared.Mobs.Components;
 using JetBrains.Annotations;
 using Robust.Client.GameObjects;
 using Robust.Client.Graphics;
-using Robust.Shared.GameObjects;
-using Robust.Shared.IoC;
 
 namespace Content.Client.HealthOverlay
 {
@@ -80,10 +77,9 @@ namespace Content.Client.HealthOverlay
 
             var viewBox = _eyeManager.GetWorldViewport().Enlarged(2.0f);
 
-            foreach (var (mobState, _) in EntityManager.EntityQuery<MobStateComponent, DamageableComponent>())
+            var query = EntityQueryEnumerator<MobStateComponent, DamageableComponent>();
+            while (query.MoveNext(out var entity, out var mobState, out _))
             {
-                var entity = mobState.Owner;
-
                 if (_entities.GetComponent<TransformComponent>(ent).MapID != _entities.GetComponent<TransformComponent>(entity).MapID ||
                     !viewBox.Contains(_entities.GetComponent<TransformComponent>(entity).WorldPosition))
                 {
index 9f0c94acce08b5dd0e135280cfd20f1c5a6aa9a5..e8ec77e540048e17e85391d51031b4532a80a94a 100644 (file)
@@ -70,7 +70,7 @@ namespace Content.Client.HealthOverlay.UI
             Panel.Visible = val;
         }
 
-        private void MoreFrameUpdate(FrameEventArgs args)
+        private void MoreFrameUpdate()
         {
             if (_entities.Deleted(Entity))
             {
@@ -87,7 +87,7 @@ namespace Content.Client.HealthOverlay.UI
 
             var mobStateSystem = _entities.EntitySysManager.GetEntitySystem<MobStateSystem>();
             var mobThresholdSystem = _entities.EntitySysManager.GetEntitySystem<MobThresholdSystem>();
-            if (mobStateSystem.IsAlive(mobState.Owner, mobState))
+            if (mobStateSystem.IsAlive(Entity, mobState))
             {
                 if (!mobThresholdSystem.TryGetThresholdForState(Entity,MobState.Critical, out var threshold))
                 {
@@ -101,7 +101,7 @@ namespace Content.Client.HealthOverlay.UI
                 HealthBar.Ratio = 1 - ((FixedPoint2)(damageable.TotalDamage / threshold)).Float();
                 HealthBar.Visible = true;
             }
-            else if (mobStateSystem.IsCritical(mobState.Owner, mobState))
+            else if (mobStateSystem.IsCritical(Entity, mobState))
             {
                 HealthBar.Ratio = 0;
                 HealthBar.Visible = false;
@@ -118,7 +118,7 @@ namespace Content.Client.HealthOverlay.UI
                     ((damageable.TotalDamage - critThreshold) /
                     (deadThreshold - critThreshold)).Value.Float();
             }
-            else if (mobStateSystem.IsDead(mobState.Owner, mobState))
+            else if (mobStateSystem.IsDead(Entity, mobState))
             {
                 CritBar.Ratio = 0;
                 CritBar.Visible = false;
@@ -136,7 +136,7 @@ namespace Content.Client.HealthOverlay.UI
         {
             base.FrameUpdate(args);
 
-            MoreFrameUpdate(args);
+            MoreFrameUpdate();
 
             if (_entities.Deleted(Entity) || _eyeManager.CurrentMap != _entities.GetComponent<TransformComponent>(Entity).MapID)
             {
index 5b931b7232f074aea78316d83ddb807b6160c359..7334c2fd4320eef39ad99bc849b7158e9b32e026 100644 (file)
@@ -236,6 +236,8 @@ namespace Content.Client.IconSmoothing
                 return;
             }
 
+            var spriteEnt = (uid, sprite);
+
             if (xform.Anchored)
             {
                 if (!_mapManager.TryGetGrid(xform.GridUid, out grid))
@@ -248,13 +250,13 @@ namespace Content.Client.IconSmoothing
             switch (smooth.Mode)
             {
                 case IconSmoothingMode.Corners:
-                    CalculateNewSpriteCorners(grid, smooth, sprite, xform, smoothQuery);
+                    CalculateNewSpriteCorners(grid, smooth, spriteEnt, xform, smoothQuery);
                     break;
                 case IconSmoothingMode.CardinalFlags:
-                    CalculateNewSpriteCardinal(grid, smooth, sprite, xform, smoothQuery);
+                    CalculateNewSpriteCardinal(grid, smooth, spriteEnt, xform, smoothQuery);
                     break;
                 case IconSmoothingMode.Diagonal:
-                    CalculateNewSpriteDiagonal(grid, smooth, sprite, xform, smoothQuery);
+                    CalculateNewSpriteDiagonal(grid, smooth, spriteEnt, xform, smoothQuery);
                     break;
                 default:
                     throw new ArgumentOutOfRangeException();
@@ -262,11 +264,11 @@ namespace Content.Client.IconSmoothing
         }
 
         private void CalculateNewSpriteDiagonal(MapGridComponent? grid, IconSmoothComponent smooth,
-            SpriteComponent sprite, TransformComponent xform, EntityQuery<IconSmoothComponent> smoothQuery)
+            Entity<SpriteComponent> sprite, TransformComponent xform, EntityQuery<IconSmoothComponent> smoothQuery)
         {
             if (grid == null)
             {
-                sprite.LayerSetState(0, $"{smooth.StateBase}0");
+                sprite.Comp.LayerSetState(0, $"{smooth.StateBase}0");
                 return;
             }
 
@@ -289,21 +291,21 @@ namespace Content.Client.IconSmoothing
 
             if (matching)
             {
-                sprite.LayerSetState(0, $"{smooth.StateBase}1");
+                sprite.Comp.LayerSetState(0, $"{smooth.StateBase}1");
             }
             else
             {
-                sprite.LayerSetState(0, $"{smooth.StateBase}0");
+                sprite.Comp.LayerSetState(0, $"{smooth.StateBase}0");
             }
         }
 
-        private void CalculateNewSpriteCardinal(MapGridComponent? grid, IconSmoothComponent smooth, SpriteComponent sprite, TransformComponent xform, EntityQuery<IconSmoothComponent> smoothQuery)
+        private void CalculateNewSpriteCardinal(MapGridComponent? grid, IconSmoothComponent smooth, Entity<SpriteComponent> sprite, TransformComponent xform, EntityQuery<IconSmoothComponent> smoothQuery)
         {
             var dirs = CardinalConnectDirs.None;
 
             if (grid == null)
             {
-                sprite.LayerSetState(0, $"{smooth.StateBase}{(int) dirs}");
+                sprite.Comp.LayerSetState(0, $"{smooth.StateBase}{(int) dirs}");
                 return;
             }
 
@@ -317,7 +319,7 @@ namespace Content.Client.IconSmoothing
             if (MatchingEntity(smooth, grid.GetAnchoredEntitiesEnumerator(pos.Offset(Direction.West)), smoothQuery))
                 dirs |= CardinalConnectDirs.West;
 
-            sprite.LayerSetState(0, $"{smooth.StateBase}{(int) dirs}");
+            sprite.Comp.LayerSetState(0, $"{smooth.StateBase}{(int) dirs}");
 
             var directions = DirectionFlag.None;
 
@@ -330,7 +332,7 @@ namespace Content.Client.IconSmoothing
             if ((dirs & CardinalConnectDirs.West) != 0x0)
                 directions |= DirectionFlag.West;
 
-            CalculateEdge(sprite.Owner, directions, sprite);
+            CalculateEdge(sprite, directions, sprite);
         }
 
         private bool MatchingEntity(IconSmoothComponent smooth, AnchoredEntitiesEnumerator candidates, EntityQuery<IconSmoothComponent> smoothQuery)
@@ -348,7 +350,7 @@ namespace Content.Client.IconSmoothing
             return false;
         }
 
-        private void CalculateNewSpriteCorners(MapGridComponent? grid, IconSmoothComponent smooth, SpriteComponent sprite, TransformComponent xform, EntityQuery<IconSmoothComponent> smoothQuery)
+        private void CalculateNewSpriteCorners(MapGridComponent? grid, IconSmoothComponent smooth, Entity<SpriteComponent> spriteEnt, TransformComponent xform, EntityQuery<IconSmoothComponent> smoothQuery)
         {
             var (cornerNE, cornerNW, cornerSW, cornerSE) = grid == null
                 ? (CornerFill.None, CornerFill.None, CornerFill.None, CornerFill.None)
@@ -359,6 +361,7 @@ namespace Content.Client.IconSmoothing
             // It will also result in 4-8 sprite update events being raised when it only needs to be 1-2.
             // At the very least each event currently only queues a sprite for updating.
             // Oh god sprite component is a mess.
+            var sprite = spriteEnt.Comp;
             sprite.LayerSetState(CornerLayers.NE, $"{smooth.StateBase}{(int) cornerNE}");
             sprite.LayerSetState(CornerLayers.SE, $"{smooth.StateBase}{(int) cornerSE}");
             sprite.LayerSetState(CornerLayers.SW, $"{smooth.StateBase}{(int) cornerSW}");
@@ -378,7 +381,7 @@ namespace Content.Client.IconSmoothing
             if ((cornerNW & cornerSW) != CornerFill.None)
                 directions |= DirectionFlag.West;
 
-            CalculateEdge(sprite.Owner, directions, sprite);
+            CalculateEdge(spriteEnt, directions, sprite);
         }
 
         private (CornerFill ne, CornerFill nw, CornerFill sw, CornerFill se) CalculateCornerFill(MapGridComponent grid, IconSmoothComponent smooth, TransformComponent xform, EntityQuery<IconSmoothComponent> smoothQuery)
index 9c72d763ff8cbaf1e8953ad929b1bc2fb6709bf1..9803920257ca88cadca38247f50f590c98278d91 100644 (file)
@@ -22,11 +22,11 @@ namespace Content.Client.Interactable.Components
         private ShaderInstance? _shader;
         private int _lastRenderScale;
 
-        public void OnMouseEnter(bool inInteractionRange, int renderScale)
+        public void OnMouseEnter(EntityUid uid, bool inInteractionRange, int renderScale)
         {
             _lastRenderScale = renderScale;
             _inRange = inInteractionRange;
-            if (_entMan.TryGetComponent(Owner, out SpriteComponent? sprite) && sprite.PostShader == null)
+            if (_entMan.TryGetComponent(uid, out SpriteComponent? sprite) && sprite.PostShader == null)
             {
                 // TODO why is this creating a new instance of the outline shader every time the mouse enters???
                 _shader = MakeNewShader(inInteractionRange, renderScale);
@@ -34,9 +34,9 @@ namespace Content.Client.Interactable.Components
             }
         }
 
-        public void OnMouseLeave()
+        public void OnMouseLeave(EntityUid uid)
         {
-            if (_entMan.TryGetComponent(Owner, out SpriteComponent? sprite))
+            if (_entMan.TryGetComponent(uid, out SpriteComponent? sprite))
             {
                 if (sprite.PostShader == _shader)
                     sprite.PostShader = null;
@@ -47,9 +47,9 @@ namespace Content.Client.Interactable.Components
             _shader = null;
         }
 
-        public void UpdateInRange(bool inInteractionRange, int renderScale)
+        public void UpdateInRange(EntityUid uid, bool inInteractionRange, int renderScale)
         {
-            if (_entMan.TryGetComponent(Owner, out SpriteComponent? sprite)
+            if (_entMan.TryGetComponent(uid, out SpriteComponent? sprite)
                 && sprite.PostShader == _shader
                 && (inInteractionRange != _inRange || _lastRenderScale != renderScale))
             {
index d6a487f3fd5a5b6a46722a07803ecda91f55fb84..ffff392aa4683a13aeb28e3c672624d424308574 100644 (file)
@@ -107,7 +107,7 @@ namespace Content.Client.Inventory
 
         private void OnShutdown(EntityUid uid, InventoryComponent component, ComponentShutdown args)
         {
-            if (component.Owner != _playerManager.LocalPlayer?.ControlledEntity)
+            if (uid != _playerManager.LocalPlayer?.ControlledEntity)
                 return;
 
             OnUnlinkInventory?.Invoke();
index 282df5c8294b4aa2a09783f81336c97e2b6ed15d..7e8bf82a29e1e6f29c5a01ed70aa25b0b82f7d00 100644 (file)
@@ -408,9 +408,9 @@ namespace Content.Client.Light.Components
         /// <summary>
         /// If we disable all the light behaviours we want to be able to revert the light to its original state.
         /// </summary>
-        private void CopyLightSettings(string property)
+        private void CopyLightSettings(EntityUid uid, string property)
         {
-            if (_entMan.TryGetComponent(Owner, out PointLightComponent? light))
+            if (_entMan.TryGetComponent(uid, out PointLightComponent? light))
             {
                 var propertyValue = AnimationHelper.GetAnimatableProperty(light, property);
                 if (propertyValue != null)
@@ -420,7 +420,7 @@ namespace Content.Client.Light.Components
             }
             else
             {
-                Logger.Warning($"{_entMan.GetComponent<MetaDataComponent>(Owner).EntityName} has a {nameof(LightBehaviourComponent)} but it has no {nameof(PointLightComponent)}! Check the prototype!");
+                Logger.Warning($"{_entMan.GetComponent<MetaDataComponent>(uid).EntityName} has a {nameof(LightBehaviourComponent)} but it has no {nameof(PointLightComponent)}! Check the prototype!");
             }
         }
 
@@ -445,7 +445,7 @@ namespace Content.Client.Light.Components
                 {
                     if (!animations.HasRunningAnimation(uid, animation, KeyPrefix + container.Key))
                     {
-                        CopyLightSettings(container.LightBehaviour.Property);
+                        CopyLightSettings(uid, container.LightBehaviour.Property);
                         container.LightBehaviour.UpdatePlaybackValues(container.Animation);
                         animations.Play(uid, animation, container.Animation, KeyPrefix + container.Key);
                     }
index a9ba34ca7d0485dc80e091a7b5fdb86eb9c97d41..ad8ca475828544a7b025635a6ac4fa56d7e659f7 100644 (file)
@@ -170,11 +170,12 @@ namespace Content.Client.Light
 
         public override void FrameUpdate(float frameTime)
         {
-            foreach (var (rgb, light, sprite) in EntityManager.EntityQuery<RgbLightControllerComponent, PointLightComponent, SpriteComponent>())
+            var lightQuery = EntityQueryEnumerator<RgbLightControllerComponent, PointLightComponent, SpriteComponent>();
+            while (lightQuery.MoveNext(out var uid, out var rgb, out var light, out var sprite))
             {
-                var color = GetCurrentRgbColor(_gameTiming.RealTime, rgb.CreationTick.Value * _gameTiming.TickPeriod, rgb);
+                var color = GetCurrentRgbColor(_gameTiming.RealTime, rgb.CreationTick.Value * _gameTiming.TickPeriod, (uid, rgb));
 
-                _lights.SetColor(light.Owner, color, light);
+                _lights.SetColor(uid, color, light);
 
                 if (rgb.Layers != null)
                 {
@@ -196,17 +197,18 @@ namespace Content.Client.Light
                 }
             }
 
-            foreach (var (map, rgb) in EntityQuery<MapLightComponent, RgbLightControllerComponent>())
+            var mapQuery = EntityQueryEnumerator<MapLightComponent, RgbLightControllerComponent>();
+            while (mapQuery.MoveNext(out var uid, out var map, out var rgb))
             {
-                var color = GetCurrentRgbColor(_gameTiming.RealTime, rgb.CreationTick.Value * _gameTiming.TickPeriod, rgb);
+                var color = GetCurrentRgbColor(_gameTiming.RealTime, rgb.CreationTick.Value * _gameTiming.TickPeriod, (uid, rgb));
                 map.AmbientLightColor = color;
             }
         }
 
-        public static Color GetCurrentRgbColor(TimeSpan curTime, TimeSpan offset, RgbLightControllerComponent rgb)
+        public static Color GetCurrentRgbColor(TimeSpan curTime, TimeSpan offset, Entity<RgbLightControllerComponent> rgb)
         {
             return Color.FromHsv(new Vector4(
-                (float) (((curTime.TotalSeconds - offset.TotalSeconds) * rgb.CycleRate + Math.Abs(rgb.Owner.Id * 0.1)) % 1),
+                (float) (((curTime.TotalSeconds - offset.TotalSeconds) * rgb.Comp.CycleRate + Math.Abs(rgb.Owner.Id * 0.1)) % 1),
                 1.0f,
                 1.0f,
                 1.0f
index 271632d0184602a0bb54d6b9fb6afae3212fc306..bb2145bce0c92bc8d22d0a4c7f3d313484ea0ac5 100644 (file)
@@ -38,9 +38,10 @@ public sealed class NPCSteeringSystem : SharedNPCSteeringSystem
                     Enabled = false
                 });
 
-                foreach (var comp in EntityQuery<NPCSteeringComponent>(true))
+                var query = AllEntityQuery<NPCSteeringComponent>();
+                while (query.MoveNext(out var uid, out var npc))
                 {
-                    RemCompDeferred<NPCSteeringComponent>(comp.Owner);
+                    RemCompDeferred<NPCSteeringComponent>(uid);
                 }
             }
         }
index 518c1f32aaeaa72b444541ffe4f478debd99fd79..548edd601ce871bcd133d033e3aa5f949228feb2 100644 (file)
@@ -2,11 +2,13 @@ using System.Linq;
 using System.Numerics;
 using System.Text;
 using Content.Shared.NPC;
+using Robust.Client.GameObjects;
 using Robust.Client.Graphics;
 using Robust.Client.Input;
 using Robust.Client.ResourceManagement;
 using Robust.Shared.Enums;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 using Robust.Shared.Timing;
 using Robust.Shared.Utility;
 
@@ -20,6 +22,7 @@ namespace Content.Client.NPC
         [Dependency] private readonly IMapManager _mapManager = default!;
         [Dependency] private readonly IResourceCache _cache = default!;
         [Dependency] private readonly NPCSteeringSystem _steering = default!;
+        [Dependency] private readonly MapSystem _mapSystem = default!;
 
         public PathfindingDebugMode Modes
         {
@@ -36,7 +39,7 @@ namespace Content.Client.NPC
                 }
                 else if (!overlayManager.HasOverlay<PathfindingOverlay>())
                 {
-                    overlayManager.AddOverlay(new PathfindingOverlay(EntityManager, _eyeManager, _inputManager, _mapManager, _cache, this));
+                    overlayManager.AddOverlay(new PathfindingOverlay(EntityManager, _eyeManager, _inputManager, _mapManager, _cache, this, _mapSystem));
                 }
 
                 if ((value & PathfindingDebugMode.Steering) != 0x0)
@@ -136,10 +139,12 @@ namespace Content.Client.NPC
         private readonly IInputManager _inputManager;
         private readonly IMapManager _mapManager;
         private readonly PathfindingSystem _system;
+        private readonly MapSystem _mapSystem;
 
         public override OverlaySpace Space => OverlaySpace.ScreenSpace | OverlaySpace.WorldSpace;
 
         private readonly Font _font;
+        private List<Entity<MapGridComponent>> _grids = new();
 
         public PathfindingOverlay(
             IEntityManager entManager,
@@ -147,13 +152,15 @@ namespace Content.Client.NPC
             IInputManager inputManager,
             IMapManager mapManager,
             IResourceCache cache,
-            PathfindingSystem system)
+            PathfindingSystem system,
+            MapSystem mapSystem)
         {
             _entManager = entManager;
             _eyeManager = eyeManager;
             _inputManager = inputManager;
             _mapManager = mapManager;
             _system = system;
+            _mapSystem = mapSystem;
             _font = new VectorFont(cache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10);
         }
 
@@ -182,11 +189,14 @@ namespace Content.Client.NPC
             {
                 var found = false;
 
-                foreach (var grid in _mapManager.FindGridsIntersecting(mouseWorldPos.MapId, aabb))
+                _grids.Clear();
+                _mapManager.FindGridsIntersecting(mouseWorldPos.MapId, aabb, ref _grids);
+
+                foreach (var grid in _grids)
                 {
-                    var netGrid = _entManager.GetNetEntity(grid.Owner);
+                    var netGrid = _entManager.GetNetEntity(grid);
 
-                    if (found || !_system.Breadcrumbs.TryGetValue(netGrid, out var crumbs) || !xformQuery.TryGetComponent(grid.Owner, out var gridXform))
+                    if (found || !_system.Breadcrumbs.TryGetValue(netGrid, out var crumbs) || !xformQuery.TryGetComponent(grid, out var gridXform))
                         continue;
 
                     var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
@@ -262,7 +272,7 @@ namespace Content.Client.NPC
                 if (!_system.Polys.TryGetValue(_entManager.GetNetEntity(gridUid), out var data))
                     return;
 
-                var tileRef = grid.GetTileRef(mouseWorldPos);
+                var tileRef = _mapSystem.GetTileRef(gridUid, grid, mouseWorldPos);
                 var localPos = tileRef.GridIndices;
                 var chunkOrigin = localPos / SharedPathfindingSystem.ChunkSize;
 
@@ -333,12 +343,15 @@ namespace Content.Client.NPC
             if ((_system.Modes & PathfindingDebugMode.Breadcrumbs) != 0x0 &&
                 mouseWorldPos.MapId == args.MapId)
             {
-                foreach (var grid in _mapManager.FindGridsIntersecting(mouseWorldPos.MapId, aabb))
+                _grids.Clear();
+                _mapManager.FindGridsIntersecting(mouseWorldPos.MapId, aabb, ref _grids);
+
+                foreach (var grid in _grids)
                 {
-                    var netGrid = _entManager.GetNetEntity(grid.Owner);
+                    var netGrid = _entManager.GetNetEntity(grid);
 
                     if (!_system.Breadcrumbs.TryGetValue(netGrid, out var crumbs) ||
-                        !xformQuery.TryGetComponent(grid.Owner, out var gridXform))
+                        !xformQuery.TryGetComponent(grid, out var gridXform))
                     {
                         continue;
                     }
@@ -392,12 +405,15 @@ namespace Content.Client.NPC
             if ((_system.Modes & PathfindingDebugMode.Polys) != 0x0 &&
                 mouseWorldPos.MapId == args.MapId)
             {
-                foreach (var grid in _mapManager.FindGridsIntersecting(args.MapId, aabb))
+                _grids.Clear();
+                _mapManager.FindGridsIntersecting(args.MapId, aabb, ref _grids);
+
+                foreach (var grid in _grids)
                 {
-                    var netGrid = _entManager.GetNetEntity(grid.Owner);
+                    var netGrid = _entManager.GetNetEntity(grid);
 
                     if (!_system.Polys.TryGetValue(netGrid, out var data) ||
-                        !xformQuery.TryGetComponent(grid.Owner, out var gridXform))
+                        !xformQuery.TryGetComponent(grid, out var gridXform))
                         continue;
 
                     var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
@@ -428,12 +444,15 @@ namespace Content.Client.NPC
             if ((_system.Modes & PathfindingDebugMode.PolyNeighbors) != 0x0 &&
                 mouseWorldPos.MapId == args.MapId)
             {
-                foreach (var grid in _mapManager.FindGridsIntersecting(args.MapId, aabb))
+                _grids.Clear();
+                _mapManager.FindGridsIntersecting(args.MapId, aabb, ref _grids);
+
+                foreach (var grid in _grids)
                 {
-                    var netGrid = _entManager.GetNetEntity(grid.Owner);
+                    var netGrid = _entManager.GetNetEntity(grid);
 
                     if (!_system.Polys.TryGetValue(netGrid, out var data) ||
-                        !xformQuery.TryGetComponent(grid.Owner, out var gridXform))
+                        !xformQuery.TryGetComponent(grid, out var gridXform))
                         continue;
 
                     var (_, _, worldMatrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
@@ -484,12 +503,15 @@ namespace Content.Client.NPC
 
             if ((_system.Modes & PathfindingDebugMode.Chunks) != 0x0)
             {
-                foreach (var grid in _mapManager.FindGridsIntersecting(args.MapId, args.WorldBounds))
+                _grids.Clear();
+                _mapManager.FindGridsIntersecting(args.MapId, args.WorldBounds, ref _grids);
+
+                foreach (var grid in _grids)
                 {
-                    var netGrid = _entManager.GetNetEntity(grid.Owner);
+                    var netGrid = _entManager.GetNetEntity(grid);
 
                     if (!_system.Breadcrumbs.TryGetValue(netGrid, out var crumbs) ||
-                        !xformQuery.TryGetComponent(grid.Owner, out var gridXform))
+                        !xformQuery.TryGetComponent(grid, out var gridXform))
                         continue;
 
                     var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
index ca135f6ca202ecce612b8b8d9c058790b0189473..4fcdada86842ec8842d5e11d422513f9ee25c4d0 100644 (file)
@@ -1,10 +1,9 @@
 using Content.Client.NetworkConfigurator.Systems;
-using Content.Shared.DeviceNetwork;
 using Content.Shared.DeviceNetwork.Components;
 using Robust.Client.Graphics;
 using Robust.Shared.Enums;
-using Robust.Shared.Random;
 using Robust.Shared.Map;
+using Robust.Shared.Random;
 
 namespace Content.Client.NetworkConfigurator;
 
@@ -28,24 +27,25 @@ public sealed class NetworkConfiguratorLinkOverlay : Overlay
 
     protected override void Draw(in OverlayDrawArgs args)
     {
-        foreach (var tracker in _entityManager.EntityQuery<NetworkConfiguratorActiveLinkOverlayComponent>())
+        var query = _entityManager.EntityQueryEnumerator<NetworkConfiguratorActiveLinkOverlayComponent>();
+        while (query.MoveNext(out var uid, out _))
         {
-            if (_entityManager.Deleted(tracker.Owner) || !_entityManager.TryGetComponent(tracker.Owner, out DeviceListComponent? deviceList))
+            if (_entityManager.Deleted(uid) || !_entityManager.TryGetComponent(uid, out DeviceListComponent? deviceList))
             {
-                _entityManager.RemoveComponentDeferred<NetworkConfiguratorActiveLinkOverlayComponent>(tracker.Owner);
+                _entityManager.RemoveComponentDeferred<NetworkConfiguratorActiveLinkOverlayComponent>(uid);
                 continue;
             }
 
-            if (!Colors.TryGetValue(tracker.Owner, out var color))
+            if (!Colors.TryGetValue(uid, out var color))
             {
                 color = new Color(
                     _random.Next(0, 255),
                     _random.Next(0, 255),
                     _random.Next(0, 255));
-                Colors.Add(tracker.Owner, color);
+                Colors.Add(uid, color);
             }
 
-            var sourceTransform = _entityManager.GetComponent<TransformComponent>(tracker.Owner);
+            var sourceTransform = _entityManager.GetComponent<TransformComponent>(uid);
             if (sourceTransform.MapID == MapId.Nullspace)
             {
                 // Can happen if the item is outside the client's view. In that case,
@@ -53,7 +53,7 @@ public sealed class NetworkConfiguratorLinkOverlay : Overlay
                 continue;
             }
 
-            foreach (var device in _deviceListSystem.GetAllDevices(tracker.Owner, deviceList))
+            foreach (var device in _deviceListSystem.GetAllDevices(uid, deviceList))
             {
                 if (_entityManager.Deleted(device))
                 {
@@ -66,7 +66,7 @@ public sealed class NetworkConfiguratorLinkOverlay : Overlay
                     continue;
                 }
 
-                args.WorldHandle.DrawLine(sourceTransform.WorldPosition, linkTransform.WorldPosition, Colors[tracker.Owner]);
+                args.WorldHandle.DrawLine(sourceTransform.WorldPosition, linkTransform.WorldPosition, Colors[uid]);
             }
         }
     }
index af1861dc47a0777e4344a51b664eac10e683835c..7bd13a12b27b6c5e3db2c4fbc31324ff1a019582 100644 (file)
@@ -1,9 +1,7 @@
-using System.Linq;
 using Content.Client.Actions;
 using Content.Client.Items;
 using Content.Client.Message;
 using Content.Client.Stylesheets;
-using Content.Shared.Actions;
 using Content.Shared.DeviceNetwork.Components;
 using Content.Shared.DeviceNetwork.Systems;
 using Content.Shared.Input;
@@ -94,9 +92,10 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
             return;
         }
 
-        foreach (var tracker in EntityQuery<NetworkConfiguratorActiveLinkOverlayComponent>())
+        var query = EntityQueryEnumerator<NetworkConfiguratorActiveLinkOverlayComponent>();
+        while (query.MoveNext(out var uid, out _))
         {
-            RemCompDeferred<NetworkConfiguratorActiveLinkOverlayComponent>(tracker.Owner);
+            RemCompDeferred<NetworkConfiguratorActiveLinkOverlayComponent>(uid);
         }
 
         _actions.RemoveAction(overlay.Action);
index 85198f01d0cf24e774e118d525d24cd592d4b99d..f10eb9ed8b14e0d75ad8862ab7bd026bd20b2787 100644 (file)
@@ -6,6 +6,7 @@ using Robust.Client.Input;
 using Robust.Client.ResourceManagement;
 using Robust.Shared.Enums;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 using Robust.Shared.Timing;
 using Robust.Shared.Utility;
 using static Content.Shared.NodeContainer.NodeVis;
@@ -22,6 +23,7 @@ namespace Content.Client.NodeContainer
 
         private readonly Dictionary<(int, int), NodeRenderData> _nodeIndex = new();
         private readonly Dictionary<EntityUid, Dictionary<Vector2i, List<(GroupData, NodeDatum)>>> _gridIndex = new ();
+        private List<Entity<MapGridComponent>> _grids = new();
 
         private readonly Font _font;
 
@@ -112,21 +114,24 @@ namespace Content.Client.NodeContainer
             var worldAABB = overlayDrawArgs.WorldAABB;
             var xformQuery = _entityManager.GetEntityQuery<TransformComponent>();
 
-            foreach (var grid in _mapManager.FindGridsIntersecting(map, worldAABB))
+            _grids.Clear();
+            _mapManager.FindGridsIntersecting(map, worldAABB, ref _grids);
+
+            foreach (var grid in _grids)
             {
-                foreach (var entity in _lookup.GetEntitiesIntersecting(grid.Owner, worldAABB))
+                foreach (var entity in _lookup.GetEntitiesIntersecting(grid, worldAABB))
                 {
                     if (!_system.Entities.TryGetValue(entity, out var nodeData))
                         continue;
 
-                    var gridDict = _gridIndex.GetOrNew(grid.Owner);
+                    var gridDict = _gridIndex.GetOrNew(grid);
                     var coords = xformQuery.GetComponent(entity).Coordinates;
 
                     // TODO: This probably shouldn't be capable of returning NaN...
                     if (float.IsNaN(coords.Position.X) || float.IsNaN(coords.Position.Y))
                         continue;
 
-                    var tile = gridDict.GetOrNew(grid.TileIndicesFor(coords));
+                    var tile = gridDict.GetOrNew(grid.Comp.TileIndicesFor(coords));
 
                     foreach (var (group, nodeDatum) in nodeData)
                     {
@@ -141,7 +146,7 @@ namespace Content.Client.NodeContainer
             foreach (var (gridId, gridDict) in _gridIndex)
             {
                 var grid = _mapManager.GetGrid(gridId);
-                var (_, _, worldMatrix, invMatrix) = _entityManager.GetComponent<TransformComponent>(grid.Owner).GetWorldPositionRotationMatrixWithInv();
+                var (_, _, worldMatrix, invMatrix) = _entityManager.GetComponent<TransformComponent>(gridId).GetWorldPositionRotationMatrixWithInv();
 
                 var lCursorBox = invMatrix.TransformBox(cursorBox);
                 foreach (var (pos, list) in gridDict)
index ce1945ed033c99365dea757501b94fffcc7b337e..bb341785d038f4023e43a7bf1f2530eebfd538e4 100644 (file)
@@ -64,7 +64,7 @@ public sealed class InteractionOutlineSystem : EntitySystem
             return;
 
         if (TryComp(_lastHoveredEntity, out InteractionOutlineComponent? outline))
-            outline.OnMouseLeave();
+            outline.OnMouseLeave(_lastHoveredEntity.Value);
     }
 
     public void SetEnabled(bool enabled)
@@ -83,7 +83,7 @@ public sealed class InteractionOutlineSystem : EntitySystem
             return;
 
         if (TryComp(_lastHoveredEntity, out InteractionOutlineComponent? outline))
-            outline.OnMouseLeave();
+            outline.OnMouseLeave(_lastHoveredEntity.Value);
     }
 
     public override void FrameUpdate(float frameTime)
@@ -146,7 +146,7 @@ public sealed class InteractionOutlineSystem : EntitySystem
         {
             if (entityToClick != null && TryComp(entityToClick, out outline))
             {
-                outline.UpdateInRange(inRange, renderScale);
+                outline.UpdateInRange(entityToClick.Value, inRange, renderScale);
             }
 
             return;
@@ -155,14 +155,14 @@ public sealed class InteractionOutlineSystem : EntitySystem
         if (_lastHoveredEntity != null && !Deleted(_lastHoveredEntity) &&
             TryComp(_lastHoveredEntity, out outline))
         {
-            outline.OnMouseLeave();
+            outline.OnMouseLeave(_lastHoveredEntity.Value);
         }
 
         _lastHoveredEntity = entityToClick;
 
         if (_lastHoveredEntity != null && TryComp(_lastHoveredEntity, out outline))
         {
-            outline.OnMouseEnter(inRange, renderScale);
+            outline.OnMouseEnter(_lastHoveredEntity.Value, inRange, renderScale);
         }
     }
 }
index 35b0a32b56aaa1eca037685532c04f1c52a7c5d7..d346d90904a393430e6f0e3bb40afe371fa6c8e4 100644 (file)
@@ -4,6 +4,7 @@ using Robust.Client.Graphics;
 using Robust.Shared.Enums;
 using Robust.Shared.GameStates;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 
 namespace Content.Client.Pinpointer;
 
@@ -42,6 +43,8 @@ public sealed class NavMapOverlay : Overlay
 
     public override OverlaySpace Space => OverlaySpace.WorldSpace;
 
+    private List<Entity<MapGridComponent>> _grids = new();
+
     public NavMapOverlay(IEntityManager entManager, IMapManager mapManager)
     {
         _entManager = entManager;
@@ -54,9 +57,12 @@ public sealed class NavMapOverlay : Overlay
         var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
         var scale = Matrix3.CreateScale(new Vector2(1f, 1f));
 
-        foreach (var grid in _mapManager.FindGridsIntersecting(args.MapId, args.WorldBounds))
+        _grids.Clear();
+        _mapManager.FindGridsIntersecting(args.MapId, args.WorldBounds, ref _grids);
+
+        foreach (var grid in _grids)
         {
-            if (!query.TryGetComponent(grid.Owner, out var navMap) || !xformQuery.TryGetComponent(grid.Owner, out var xform))
+            if (!query.TryGetComponent(grid, out var navMap) || !xformQuery.TryGetComponent(grid.Owner, out var xform))
                 continue;
 
             // TODO: Faster helper method
@@ -67,9 +73,9 @@ public sealed class NavMapOverlay : Overlay
 
             args.WorldHandle.SetTransform(matty);
 
-            for (var x = Math.Floor(localAABB.Left); x <= Math.Ceiling(localAABB.Right); x += SharedNavMapSystem.ChunkSize * grid.TileSize)
+            for (var x = Math.Floor(localAABB.Left); x <= Math.Ceiling(localAABB.Right); x += SharedNavMapSystem.ChunkSize * grid.Comp.TileSize)
             {
-                for (var y = Math.Floor(localAABB.Bottom); y <= Math.Ceiling(localAABB.Top); y += SharedNavMapSystem.ChunkSize * grid.TileSize)
+                for (var y = Math.Floor(localAABB.Bottom); y <= Math.Ceiling(localAABB.Top); y += SharedNavMapSystem.ChunkSize * grid.Comp.TileSize)
                 {
                     var floored = new Vector2i((int) x, (int) y);
 
@@ -89,7 +95,7 @@ public sealed class NavMapOverlay : Overlay
                             continue;
 
                         var tile = chunk.Origin * SharedNavMapSystem.ChunkSize + SharedNavMapSystem.GetTile(mask);
-                        args.WorldHandle.DrawRect(new Box2(tile * grid.TileSize, (tile + 1) * grid.TileSize), Color.Aqua, false);
+                        args.WorldHandle.DrawRect(new Box2(tile * grid.Comp.TileSize, (tile + 1) * grid.Comp.TileSize), Color.Aqua, false);
                     }
                 }
             }
index b10025f56ffbbd85ababbba377ea3bfe97059f70..adc535b2684b4fc2b57bb5a10851a659263bde84 100644 (file)
@@ -1,4 +1,3 @@
-using System.Linq;
 using System.Numerics;
 using Content.Shared.Radiation.Components;
 using Robust.Client.Graphics;
@@ -81,11 +80,10 @@ namespace Content.Client.Radiation.Overlays
 
             var currentEyeLoc = currentEye.Position;
 
-            var pulses = _entityManager.EntityQuery<RadiationPulseComponent>();
-            foreach (var pulse in pulses) //Add all pulses that are not added yet but qualify
+            var pulses = _entityManager.EntityQueryEnumerator<RadiationPulseComponent>();
+            //Add all pulses that are not added yet but qualify
+            while (pulses.MoveNext(out var pulseEntity, out var pulse))
             {
-                var pulseEntity = pulse.Owner;
-
                 if (!_pulses.ContainsKey(pulseEntity) && PulseQualifies(pulseEntity, currentEyeLoc))
                 {
                     _pulses.Add(
index 66768e9fda25274d2e007c4813758bd629a87bf7..427ed039e1726db8e623508718c196c6e239bd54 100644 (file)
@@ -1,4 +1,3 @@
-using System.Linq;
 using Content.Shared.Movement.Components;
 using Robust.Client.GameObjects;
 using Robust.Shared.Map;
@@ -134,9 +133,20 @@ public sealed partial class ReplaySpectatorSystem
             return true;
         }
 
-        var uid = EntityQuery<MapGridComponent>().MaxBy(x => x.LocalAABB.Size.LengthSquared())?.Owner;
-        coords = new EntityCoordinates(uid ?? default, default);
-        return uid != null;
+        Entity<MapGridComponent>? maxUid = null;
+        float? maxSize = null;
+        while (EntityQueryEnumerator<MapGridComponent>().MoveNext(out var uid, out var grid))
+        {
+            var size = grid.LocalAABB.Size.LengthSquared();
+            if (maxSize == null || size > maxSize)
+            {
+                maxUid = (uid, grid);
+                maxSize = size;
+            }
+        }
+
+        coords = new EntityCoordinates(maxUid ?? default, default);
+        return maxUid != null;
     }
 
     private void OnTerminating(EntityUid uid, ReplaySpectatorComponent component, ref EntityTerminatingEvent args)
index 9fd4e4f068f36137d79e462cc2171678ad3ab07d..3f3f3d876c5c47bc33c23f38837f0061e48cdc8e 100644 (file)
@@ -55,7 +55,7 @@ public sealed class RevenantOverloadedLightsSystem : SharedRevenantOverloadedLig
         Dirty(uid, light);
     }
 
-    protected override void OnZap(RevenantOverloadedLightsComponent component)
+    protected override void OnZap(Entity<RevenantOverloadedLightsComponent> component)
     {
 
     }
index 106bd797110121fbbe7a84a0b071ac5273910fad..177c149faa173462cdfc33327f4b210a809136b8 100644 (file)
@@ -77,6 +77,6 @@ public sealed class RotationVisualizerSystem : VisualizerSystem<RotationVisualsC
             }
         };
 
-        AnimationSystem.Play(animationComp, animation, animationKey);
+        AnimationSystem.Play((uid, animationComp), animation, animationKey);
     }
 }
index e477b5a1a22609988f1ece0b3ab4a02fd23583db..92d9959110988ec421ff1773e10669dec4371e97 100644 (file)
@@ -4,6 +4,7 @@ using Content.Shared.Shuttles.BUIStates;
 using Robust.Client.Graphics;
 using Robust.Client.UserInterface;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 using Robust.Shared.Physics;
 using Robust.Shared.Physics.Collision.Shapes;
 
@@ -43,6 +44,8 @@ public class DockingControl : Control
     /// </summary>
     public Dictionary<NetEntity, List<DockingInterfaceState>> Docks = new();
 
+    private List<Entity<MapGridComponent>> _grids = new();
+
     public DockingControl()
     {
         _entManager = IoCManager.Resolve<IEntityManager>();
@@ -147,17 +150,19 @@ public class DockingControl : Control
         // TODO: Getting some overdraw so need to fix that.
         var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
 
-        foreach (var grid in _mapManager.FindGridsIntersecting(gridXform.MapID,
-                     new Box2(worldPos - RangeVector, worldPos + RangeVector)))
+        _grids.Clear();
+        _mapManager.FindGridsIntersecting(gridXform.MapID, new Box2(worldPos - RangeVector, worldPos + RangeVector));
+
+        foreach (var grid in _grids)
         {
             if (grid.Owner == GridEntity)
                 continue;
 
             // Draw the fixtures before drawing any docks in range.
-            if (!_entManager.TryGetComponent<FixturesComponent>(grid.Owner, out var gridFixtures))
+            if (!_entManager.TryGetComponent<FixturesComponent>(grid, out var gridFixtures))
                 continue;
 
-            var gridMatrix = xformQuery.GetComponent(grid.Owner).WorldMatrix;
+            var gridMatrix = xformQuery.GetComponent(grid).WorldMatrix;
 
             Matrix3.Multiply(in gridMatrix, in invMatrix, out var matty);
 
@@ -204,7 +209,7 @@ public class DockingControl : Control
             }
 
             // Draw any docks on that grid
-            if (Docks.TryGetValue(_entManager.GetNetEntity(grid.Owner), out var gridDocks))
+            if (Docks.TryGetValue(_entManager.GetNetEntity(grid), out var gridDocks))
             {
                 foreach (var dock in gridDocks)
                 {
index fa411ca9ba3bec59a2074922f9b9e4ade9167174..764fb854a743440c1deb0f4df7fc8dda793aa3d8 100644 (file)
@@ -3,9 +3,7 @@ using Content.Client.UserInterface.Controls;
 using Content.Shared.Shuttles.BUIStates;
 using Content.Shared.Shuttles.Components;
 using JetBrains.Annotations;
-using Content.Shared.Shuttles.Systems;
 using Robust.Client.Graphics;
-using Robust.Client.Input;
 using Robust.Client.UserInterface;
 using Robust.Client.UserInterface.Controls;
 using Robust.Shared.Collections;
@@ -13,7 +11,6 @@ using Robust.Shared.Input;
 using Robust.Shared.Map;
 using Robust.Shared.Map.Components;
 using Robust.Shared.Physics;
-using Robust.Shared.Physics.Collision.Shapes;
 using Robust.Shared.Physics.Components;
 using Robust.Shared.Utility;
 
@@ -57,6 +54,8 @@ public sealed class RadarControl : MapGridControl
     /// </summary>
     public Action<EntityCoordinates>? OnRadarClick;
 
+    private List<Entity<MapGridComponent>> _grids = new();
+
     public RadarControl() : base(64f, 256f, 256f)
     {
         _transform = _entManager.System<SharedTransformSystem>();
@@ -198,9 +197,11 @@ public sealed class RadarControl : MapGridControl
 
         var shown = new HashSet<EntityUid>();
 
+        _grids.Clear();
+        _mapManager.FindGridsIntersecting(xform.MapID, new Box2(pos - MaxRadarRangeVector, pos + MaxRadarRangeVector), ref _grids);
+
         // Draw other grids... differently
-        foreach (var grid in _mapManager.FindGridsIntersecting(xform.MapID,
-                     new Box2(pos - MaxRadarRangeVector, pos + MaxRadarRangeVector)))
+        foreach (var grid in _grids)
         {
             var gUid = grid.Owner;
             if (gUid == ourGridId || !fixturesQuery.HasComponent(gUid))
@@ -240,7 +241,7 @@ public sealed class RadarControl : MapGridControl
                 (iff == null && IFFComponent.ShowIFFDefault ||
                  (iff.Flags & IFFFlags.HideLabel) == 0x0))
             {
-                var gridBounds = grid.LocalAABB;
+                var gridBounds = grid.Comp.LocalAABB;
                 Label label;
 
                 if (!_iffControls.TryGetValue(gUid, out var control))
index f6a94e6db1b6a215ee7e69ff80fc8faf2b112c78..d4ed1285a893cfd39bcf324162ecc846b8191396 100644 (file)
@@ -77,12 +77,13 @@ public sealed class SpriteFadeSystem : EntitySystem
             }
         }
 
-        foreach (var comp in EntityQuery<FadingSpriteComponent>(true))
+        var query = AllEntityQuery<FadingSpriteComponent>();
+        while (query.MoveNext(out var uid, out var comp))
         {
             if (_comps.Contains(comp))
                 continue;
 
-            if (!spriteQuery.TryGetComponent(comp.Owner, out var sprite))
+            if (!spriteQuery.TryGetComponent(uid, out var sprite))
                 continue;
 
             var newColor = Math.Min(sprite.Color.A + change, comp.OriginalAlpha);
@@ -93,7 +94,7 @@ public sealed class SpriteFadeSystem : EntitySystem
             }
             else
             {
-                RemCompDeferred<FadingSpriteComponent>(comp.Owner);
+                RemCompDeferred<FadingSpriteComponent>(uid);
             }
         }
 
index 71c1c5b3be55d91eb705a6115a7d88ef7787cf68..79fbc96491cc057b6a3224e741fc47216a308422 100644 (file)
@@ -21,26 +21,27 @@ public sealed class ItemMapperSystem : SharedItemMapperSystem
     {
         if (TryComp<SpriteComponent>(uid, out var sprite))
         {
-            component.RSIPath ??= sprite.BaseRSI!.Path!;
+            component.RSIPath ??= sprite.BaseRSI!.Path;
         }
     }
 
     private void OnAppearance(EntityUid uid, ItemMapperComponent component, ref AppearanceChangeEvent args)
     {
-        if (TryComp<SpriteComponent>(component.Owner, out var spriteComponent))
+        if (TryComp<SpriteComponent>(uid, out var spriteComponent))
         {
             if (component.SpriteLayers.Count == 0)
             {
-                InitLayers(component, spriteComponent, args.Component);
+                InitLayers((uid, component, spriteComponent, args.Component));
             }
 
-            EnableLayers(component, spriteComponent, args.Component);
+            EnableLayers((uid, component, spriteComponent, args.Component));
         }
     }
 
-    private void InitLayers(ItemMapperComponent component, SpriteComponent spriteComponent, AppearanceComponent appearance)
+    private void InitLayers(Entity<ItemMapperComponent, SpriteComponent, AppearanceComponent> ent)
     {
-        if (!_appearance.TryGetData<ShowLayerData>(appearance.Owner, StorageMapVisuals.InitLayers, out var wrapper, appearance))
+        var (owner, component, spriteComponent, appearance) = ent;
+        if (!_appearance.TryGetData<ShowLayerData>(owner, StorageMapVisuals.InitLayers, out var wrapper, appearance))
             return;
 
         component.SpriteLayers.AddRange(wrapper.QueuedEntities);
@@ -53,9 +54,10 @@ public sealed class ItemMapperSystem : SharedItemMapperSystem
         }
     }
 
-    private void EnableLayers(ItemMapperComponent component, SpriteComponent spriteComponent, AppearanceComponent appearance)
+    private void EnableLayers(Entity<ItemMapperComponent, SpriteComponent, AppearanceComponent> ent)
     {
-        if (!_appearance.TryGetData<ShowLayerData>(appearance.Owner, StorageMapVisuals.LayerChanged, out var wrapper, appearance))
+        var (owner, component, spriteComponent, appearance) = ent;
+        if (!_appearance.TryGetData<ShowLayerData>(owner, StorageMapVisuals.LayerChanged, out var wrapper, appearance))
             return;
 
         foreach (var layerName in component.SpriteLayers)
index 312a513e32fa58726ac95a1481057cd83ccc2914..6497ba1d688b34d5ee8970e36f1dda2f65ef33ff 100644 (file)
@@ -1,4 +1,3 @@
-using Content.Client.Hands;
 using Content.Shared.Hands.EntitySystems;
 using Content.Shared.Inventory;
 using Content.Shared.SubFloor;
@@ -41,7 +40,7 @@ public sealed class TrayScannerSystem : SharedTrayScannerSystem
         var playerPos = _transform.GetWorldPosition(playerXform, xformQuery);
         var playerMap = playerXform.MapID;
         var range = 0f;
-        HashSet<SubFloorHideComponent> inRange;
+        HashSet<Entity<SubFloorHideComponent>> inRange;
         var scannerQuery = GetEntityQuery<TrayScannerComponent>();
 
         // TODO: Should probably sub to player attached changes / inventory changes but inventory's
@@ -73,23 +72,20 @@ public sealed class TrayScannerSystem : SharedTrayScannerSystem
             canSee = true;
         }
 
+        inRange = new HashSet<Entity<SubFloorHideComponent>>();
+
         if (canSee)
         {
-            inRange = _lookup.GetComponentsInRange<SubFloorHideComponent>(playerMap, playerPos, range);
+            _lookup.GetEntitiesInRange(playerMap, playerPos, range, inRange);
 
-            foreach (var comp in inRange)
+            foreach (var (uid, comp) in inRange)
             {
-                var uid = comp.Owner;
                 if (!comp.IsUnderCover || !comp.BlockAmbience | !comp.BlockInteractions)
                     continue;
 
                 EnsureComp<TrayRevealedComponent>(uid);
             }
         }
-        else
-        {
-            inRange = new HashSet<SubFloorHideComponent>();
-        }
 
         var revealedQuery = AllEntityQuery<TrayRevealedComponent, SpriteComponent, TransformComponent>();
         var subfloorQuery = GetEntityQuery<SubFloorHideComponent>();
@@ -102,7 +98,7 @@ public sealed class TrayScannerSystem : SharedTrayScannerSystem
                 xform.MapID != MapId.Nullspace &&
                 xform.MapID == playerMap &&
                 xform.Anchored &&
-                inRange.Contains(subfloor))
+                inRange.Contains((uid, subfloor)))
             {
                 // Due to the fact client is predicting this server states will reset it constantly
                 if ((!_appearance.TryGetData(uid, SubFloorVisuals.ScannerRevealed, out bool value) || !value) &&
index b0a2198443b56c4c4ea057c9b8dc68de3d01e9f5..37f8de88d6d2c88c09fb4d8f3a57441f181a9662 100644 (file)
@@ -188,10 +188,10 @@ namespace Content.Client.UserInterface.Controls
             if (!EntityHover)
                 return;
 
-            var tempQualifier = HoverSpriteView.Sprite;
+            var tempQualifier = HoverSpriteView.Ent;
             if (tempQualifier != null)
             {
-                IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(tempQualifier.Owner);
+                IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(tempQualifier);
             }
 
             HoverSpriteView.SetEntity(null);
index bd5627292accee58be5a4dc4b8535a30a6826b8e..12af31b8631b6f2492dde2598b4be1114bfc8d6f 100644 (file)
@@ -7,9 +7,9 @@ using Robust.Client.Graphics;
 using Robust.Client.ResourceManagement;
 using Robust.Client.Utility;
 using Robust.Shared.Enums;
-using Robust.Shared.Graphics;
 using Robust.Shared.Graphics.RSI;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 using Robust.Shared.Physics.Components;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Timing;
@@ -99,13 +99,17 @@ public sealed class WeatherOverlay : Overlay
             var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
             var weatherIgnoreQuery = _entManager.GetEntityQuery<IgnoreWeatherComponent>();
 
-            foreach (var grid in _mapManager.FindGridsIntersecting(mapId, worldAABB))
+            // idk if this is safe to cache in a field and clear sloth help
+            var grids = new List<Entity<MapGridComponent>>();
+            _mapManager.FindGridsIntersecting(mapId, worldAABB, ref grids);
+
+            foreach (var grid in grids)
             {
-                var matrix = _transform.GetWorldMatrix(grid.Owner, xformQuery);
+                var matrix = _transform.GetWorldMatrix(grid, xformQuery);
                 Matrix3.Multiply(in matrix, in invMatrix, out var matty);
                 worldHandle.SetTransform(matty);
 
-                foreach (var tile in grid.GetTilesIntersecting(worldAABB))
+                foreach (var tile in grid.Comp.GetTilesIntersecting(worldAABB))
                 {
                     // Ignored tiles for stencil
                     if (_weather.CanWeatherAffect(grid, tile, weatherIgnoreQuery, bodyQuery))
@@ -113,8 +117,8 @@ public sealed class WeatherOverlay : Overlay
                         continue;
                     }
 
-                    var gridTile = new Box2(tile.GridIndices * grid.TileSize,
-                        (tile.GridIndices + Vector2i.One) * grid.TileSize);
+                    var gridTile = new Box2(tile.GridIndices * grid.Comp.TileSize,
+                        (tile.GridIndices + Vector2i.One) * grid.Comp.TileSize);
 
                     worldHandle.DrawRect(gridTile, Color.White);
                 }
index 43ad41ceaad9fe5d80be1cd2568bce4cb0365af1..e1742f479000484d0aeaff86bc90522ea716a4f7 100644 (file)
@@ -18,6 +18,7 @@ public sealed class WeatherSystem : SharedWeatherSystem
     [Dependency] private readonly IOverlayManager _overlayManager = default!;
     [Dependency] private readonly IPlayerManager _playerManager = default!;
     [Dependency] private readonly AudioSystem _audio = default!;
+    [Dependency] private readonly MapSystem _mapSystem = default!;
     [Dependency] private readonly SharedPhysicsSystem _physics = default!;
     [Dependency] private readonly SharedTransformSystem _transform = default!;
 
@@ -76,8 +77,9 @@ public sealed class WeatherSystem : SharedWeatherSystem
         // Work out tiles nearby to determine volume.
         if (TryComp<MapGridComponent>(entXform.GridUid, out var grid))
         {
+            var gridId = entXform.GridUid.Value;
             // Floodfill to the nearest tile and use that for audio.
-            var seed = grid.GetTileRef(entXform.Coordinates);
+            var seed = _mapSystem.GetTileRef(gridId, grid, entXform.Coordinates);
             var frontier = new Queue<TileRef>();
             frontier.Enqueue(seed);
             // If we don't have a nearest node don't play any sound.
@@ -107,7 +109,7 @@ public sealed class WeatherSystem : SharedWeatherSystem
                                 continue;
                             }
 
-                            frontier.Enqueue(grid.GetTileRef(new Vector2i(x, y) + node.GridIndices));
+                            frontier.Enqueue(_mapSystem.GetTileRef(gridId, grid, new Vector2i(x, y) + node.GridIndices));
                         }
                     }
 
index 510dc0b854a4f555b54615c4ad3f51b734ac6833..574644f67ee20ff3290565401c7da1e9ea8c6533 100644 (file)
@@ -23,8 +23,9 @@ public sealed partial class TestPair
         {
             mapData.MapId = Server.MapMan.CreateMap();
             mapData.MapUid = Server.MapMan.GetMapEntityId(mapData.MapId);
-            mapData.MapGrid = Server.MapMan.CreateGrid(mapData.MapId);
-            mapData.GridUid = mapData.MapGrid.Owner; // Fixing this requires an engine PR.
+            var mapGrid = Server.MapMan.CreateGridEntity(mapData.MapId);
+            mapData.MapGrid = mapGrid;
+            mapData.GridUid = mapGrid.Owner; // Fixing this requires an engine PR.
             mapData.GridCoords = new EntityCoordinates(mapData.GridUid, 0, 0);
             var plating = tileDefinitionManager["Plating"];
             var platingTile = new Tile(plating.TileId);
index da806aa10a5097372a74227714c925bb9e5433ab..0d852bf2f0ef5006bb7e0baed491cbdb5cc3ec8d 100644 (file)
@@ -17,11 +17,16 @@ namespace Content.IntegrationTests.Tests.Fluids;
 public sealed class FluidSpill
 {
     private static PuddleComponent? GetPuddle(IEntityManager entityManager, MapGridComponent mapGrid, Vector2i pos)
+    {
+        return GetPuddleEntity(entityManager, mapGrid, pos)?.Comp;
+    }
+
+    private static Entity<PuddleComponent>? GetPuddleEntity(IEntityManager entityManager, MapGridComponent mapGrid, Vector2i pos)
     {
         foreach (var uid in mapGrid.GetAnchoredEntities(pos))
         {
             if (entityManager.TryGetComponent(uid, out PuddleComponent? puddleComponent))
-                return puddleComponent;
+                return (uid, puddleComponent);
         }
 
         return null;
@@ -48,19 +53,19 @@ public sealed class FluidSpill
         await server.WaitPost(() =>
         {
             mapId = mapManager.CreateMap();
-            var grid = mapManager.CreateGrid(mapId);
+            var grid = mapManager.CreateGridEntity(mapId);
             gridId = grid.Owner;
 
             for (var x = 0; x < 3; x++)
             {
                 for (var y = 0; y < 3; y++)
                 {
-                    grid.SetTile(new Vector2i(x, y), new Tile(1));
+                    grid.Comp.SetTile(new Vector2i(x, y), new Tile(1));
                 }
             }
 
-            entityManager.SpawnEntity("WallReinforced", grid.GridTileToLocal(new Vector2i(0, 1)));
-            entityManager.SpawnEntity("WallReinforced", grid.GridTileToLocal(new Vector2i(1, 0)));
+            entityManager.SpawnEntity("WallReinforced", grid.Comp.GridTileToLocal(new Vector2i(0, 1)));
+            entityManager.SpawnEntity("WallReinforced", grid.Comp.GridTileToLocal(new Vector2i(1, 0)));
         });
 
 
@@ -82,12 +87,11 @@ public sealed class FluidSpill
         await server.WaitAssertion(() =>
         {
             var grid = mapManager.GetGrid(gridId);
-            var puddle = GetPuddle(entityManager, grid, puddleOrigin);
-
+            var puddle = GetPuddleEntity(entityManager, grid, puddleOrigin);
 
 #pragma warning disable NUnit2045 // Interdependent tests
             Assert.That(puddle, Is.Not.Null);
-            Assert.That(puddleSystem.CurrentVolume(puddle!.Owner, puddle), Is.EqualTo(FixedPoint2.New(100)));
+            Assert.That(puddleSystem.CurrentVolume(puddle!.Value.Owner, puddle), Is.EqualTo(FixedPoint2.New(100)));
 #pragma warning restore NUnit2045
 
             for (var x = 0; x < 3; x++)
index 453ad6b5ea16de9881439f139348f219f614f4ad..25171e1ea2ed19f05a0029689570c5ab10d6a493 100644 (file)
@@ -13,9 +13,7 @@ using Content.Server.Gravity;
 using Content.Server.Power.Components;
 using Content.Server.Tools.Components;
 using Content.Shared.Atmos;
-using Content.Shared.Construction;
 using Content.Shared.Construction.Prototypes;
-using Content.Shared.DoAfter;
 using Content.Shared.Gravity;
 using Content.Shared.Item;
 using Robust.Client.UserInterface;
@@ -708,8 +706,9 @@ public abstract partial class InteractionTest
             if (proto == null)
                 return;
 
-            grid = MapMan.CreateGrid(MapData.MapId);
-            gridUid = grid.Owner;
+            var gridEnt = MapMan.CreateGridEntity(MapData.MapId);
+            grid = gridEnt;
+            gridUid = gridEnt;
             var gridXform = SEntMan.GetComponent<TransformComponent>(gridUid);
             Transform.SetWorldPosition(gridXform, pos.Position);
             grid.SetTile(SEntMan.GetCoordinates(coords ?? TargetCoords), tile);
index c65095819980e0ddc30759e769c470bf46bb2c30..45bff2f030dd6894096cceece272a6e577532833 100644 (file)
@@ -1,10 +1,10 @@
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
-using System.Threading;
 using Content.Server.GameTicking;
 using Content.Server.Maps;
 using Content.Server.Shuttles.Components;
+using Content.Server.Shuttles.Systems;
 using Content.Server.Spawners.Components;
 using Content.Server.Station.Components;
 using Content.Shared.CCVar;
@@ -13,12 +13,11 @@ using Robust.Server.GameObjects;
 using Robust.Shared.Configuration;
 using Robust.Shared.ContentPack;
 using Robust.Shared.GameObjects;
-using Robust.Shared.Utility;
 using Robust.Shared.Map;
 using Robust.Shared.Map.Components;
 using Robust.Shared.Prototypes;
+using Robust.Shared.Utility;
 using YamlDotNet.RepresentationModel;
-using ShuttleSystem = Content.Server.Shuttles.Systems.ShuttleSystem;
 
 namespace Content.IntegrationTests.Tests
 {
@@ -184,7 +183,7 @@ namespace Content.IntegrationTests.Tests
                 EntityUid? targetGrid = null;
                 var memberQuery = entManager.GetEntityQuery<StationMemberComponent>();
 
-                var grids = mapManager.GetAllMapGrids(mapId).ToList();
+                var grids = mapManager.GetAllGrids(mapId).ToList();
                 var gridUids = grids.Select(o => o.Owner).ToList();
                 targetGrid = gridUids.First();
 
@@ -194,7 +193,7 @@ namespace Content.IntegrationTests.Tests
                     if (!memberQuery.HasComponent(gridEnt))
                         continue;
 
-                    var area = grid.LocalAABB.Width * grid.LocalAABB.Height;
+                    var area = grid.Comp.LocalAABB.Width * grid.Comp.LocalAABB.Height;
 
                     if (area > largest)
                     {
index 82a6c455556c9d9775fc47e62652de890a6209d5..3bf00d34c73d16dfa08a1bccd319589d932d8512 100644 (file)
@@ -1,3 +1,4 @@
+using System.Linq;
 using Content.Server.Administration.Logs;
 using Content.Server.Kitchen.Components;
 using Content.Server.Popups;
@@ -9,7 +10,6 @@ using Content.Shared.Popups;
 using Content.Shared.StatusIcon;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Random;
-using System.Linq;
 
 namespace Content.Server.Access.Systems
 {
@@ -132,12 +132,12 @@ namespace Content.Server.Access.Systems
             }
 
             id.JobIcon = jobIcon.ID;
-            Dirty(id);
+            Dirty(uid, id);
 
             if (player != null)
             {
                 _adminLogger.Add(LogType.Identity, LogImpact.Low,
-                    $"{ToPrettyString(player.Value):player} has changed the job icon of {ToPrettyString(id.Owner):entity} to {jobIcon} ");
+                    $"{ToPrettyString(player.Value):player} has changed the job icon of {ToPrettyString(uid):entity} to {jobIcon} ");
             }
 
             return true;
@@ -181,7 +181,7 @@ namespace Content.Server.Access.Systems
         }
 
         /// <summary>
-        /// Changes the <see cref="Entity.Name"/> of <see cref="Component.Owner"/>.
+        /// Changes the name of the id's owner.
         /// </summary>
         /// <remarks>
         /// If either <see cref="FullName"/> or <see cref="JobTitle"/> is empty, it's replaced by placeholders.
index 48663f579d62a43a422f5519be56ce5013fc6fd2..858e48a71e65871544c18af96202bb8a47ff4fe8 100644 (file)
@@ -38,7 +38,7 @@ namespace Content.Server.Administration.Commands
 
             if (_entManager.TryGetComponent<EntityStorageComponent>(parent, out var storage))
             {
-                entstorage.Remove(entityUid.Value, storage.Owner, storage);
+                entstorage.Remove(entityUid.Value, parent, storage);
             }
             else
             {
index e7b028cb9409eddbfa7a52f0b5653fa6c63774ef..c2f07320b5bb6b14c67e525c134fff54fd3feeaa 100644 (file)
@@ -337,7 +337,7 @@ public sealed partial class AdminVerbSystem
                 Act = () =>
                 {
                     var baseXform = Transform(args.Target);
-                    foreach (var part in _bodySystem.GetBodyChildrenOfType(body.Owner, BodyPartType.Hand, body))
+                    foreach (var part in _bodySystem.GetBodyChildrenOfType(args.Target, BodyPartType.Hand, body))
                     {
                         _transformSystem.AttachToGridOrMap(part.Id);
                         break;
index a8d1f88d7259847212c246a064920b3528b3aa68..f3df34e7d2e0b3d9a3ac22908edf28830b3fc1c7 100644 (file)
@@ -12,7 +12,8 @@ public sealed class BufferingSystem : EntitySystem
 
     public override void Update(float frameTime)
     {
-        foreach (var buffering in EntityQuery<BufferingComponent>())
+        var query = EntityQueryEnumerator<BufferingComponent>();
+        while (query.MoveNext(out var uid, out var buffering))
         {
             if (buffering.BufferingIcon is not null)
             {
@@ -21,7 +22,7 @@ public sealed class BufferingSystem : EntitySystem
                     continue;
 
                 Del(buffering.BufferingIcon.Value);
-                RemComp<AdminFrozenComponent>(buffering.Owner);
+                RemComp<AdminFrozenComponent>(uid);
                 buffering.TimeTilNextBuffer = _random.NextFloat(buffering.MinimumTimeTilNextBuffer, buffering.MaximumTimeTilNextBuffer);
                 buffering.BufferingIcon = null;
             }
@@ -32,8 +33,8 @@ public sealed class BufferingSystem : EntitySystem
                     continue;
 
                 buffering.BufferingTimer = _random.NextFloat(buffering.MinimumBufferTime, buffering.MaximumBufferTime);
-                buffering.BufferingIcon = Spawn("BufferingIcon", new EntityCoordinates(buffering.Owner, Vector2.Zero));
-                EnsureComp<AdminFrozenComponent>(buffering.Owner);
+                buffering.BufferingIcon = Spawn("BufferingIcon", new EntityCoordinates(uid, Vector2.Zero));
+                EnsureComp<AdminFrozenComponent>(uid);
             }
         }
     }
index 043f69e420c64feb51e22f2f46cc858facd0f1d1..4f2108748b885083ad373bc935cd1dce6df12376 100644 (file)
@@ -1,7 +1,6 @@
 using Content.Server.Power.Components;
 using Content.Server.Station.Systems;
 using Content.Shared.AlertLevel;
-using Robust.Server.GameObjects;
 
 namespace Content.Server.AlertLevel;
 
@@ -19,9 +18,10 @@ public sealed class AlertLevelDisplaySystem : EntitySystem
 
     private void OnAlertChanged(AlertLevelChangedEvent args)
     {
-        foreach (var (_, appearance) in EntityManager.EntityQuery<AlertLevelDisplayComponent, AppearanceComponent>())
+        var query = EntityQueryEnumerator<AlertLevelDisplayComponent, AppearanceComponent>();
+        while (query.MoveNext(out var uid, out _, out var appearance))
         {
-            _appearance.SetData(appearance.Owner, AlertLevelDisplay.CurrentLevel, args.AlertLevel, appearance);
+            _appearance.SetData(uid, AlertLevelDisplay.CurrentLevel, args.AlertLevel, appearance);
         }
     }
 
index 121f6f4c1b43d8786c7d18882430d9b52f8114df..66e09d34e0f36c6af8df8fee3728ba8b7652873a 100644 (file)
@@ -2,7 +2,6 @@ using System.Linq;
 using Content.Server.Chat.Systems;
 using Content.Server.Station.Systems;
 using Content.Shared.CCVar;
-using Content.Shared.PDA;
 using Robust.Shared.Audio;
 using Robust.Shared.Configuration;
 using Robust.Shared.Prototypes;
@@ -83,7 +82,8 @@ public sealed class AlertLevelSystem : EntitySystem
             return;
         }
 
-        foreach (var comp in EntityQuery<AlertLevelComponent>())
+        var query = EntityQueryEnumerator<AlertLevelComponent>();
+        while (query.MoveNext(out var uid, out var comp))
         {
             comp.AlertLevels = alerts;
 
@@ -95,7 +95,7 @@ public sealed class AlertLevelSystem : EntitySystem
                     defaultLevel = comp.AlertLevels.Levels.Keys.First();
                 }
 
-                SetLevel(comp.Owner, defaultLevel, true, true, true);
+                SetLevel(uid, defaultLevel, true, true, true);
             }
         }
 
index 4a90c3c3d8532cc28d5d17c392d50f83370905c6..4164aedfd18476e2e3126903fe2dc9e08615b366 100644 (file)
@@ -1,9 +1,6 @@
 using Content.Server.Animals.Components;
-using Content.Server.DoAfter;
-using Content.Server.Nutrition.Components;
 using Content.Server.Popups;
 using Content.Shared.Chemistry.Components;
-using Content.Shared.Chemistry.Components.SolutionManager;
 using Content.Shared.Chemistry.EntitySystems;
 using Content.Shared.DoAfter;
 using Content.Shared.IdentityManagement;
@@ -32,9 +29,11 @@ namespace Content.Server.Animals.Systems
             SubscribeLocalEvent<UdderComponent, GetVerbsEvent<AlternativeVerb>>(AddMilkVerb);
             SubscribeLocalEvent<UdderComponent, MilkingDoAfterEvent>(OnDoAfter);
         }
+
         public override void Update(float frameTime)
         {
-            foreach (var udder in EntityManager.EntityQuery<UdderComponent>(false))
+            var query = EntityQueryEnumerator<UdderComponent>();
+            while (query.MoveNext(out var uid, out var udder))
             {
                 udder.AccumulatedFrameTime += frameTime;
 
@@ -43,19 +42,19 @@ namespace Content.Server.Animals.Systems
                     udder.AccumulatedFrameTime -= udder.UpdateRate;
 
                     // Actually there is food digestion so no problem with instant reagent generation "OnFeed"
-                    if (EntityManager.TryGetComponent(udder.Owner, out HungerComponent? hunger))
+                    if (EntityManager.TryGetComponent(uid, out HungerComponent? hunger))
                     {
                         // Is there enough nutrition to produce reagent?
                         if (_hunger.GetHungerThreshold(hunger) < HungerThreshold.Peckish)
                             continue;
                     }
 
-                    if (!_solutionContainerSystem.TryGetSolution(udder.Owner, udder.TargetSolutionName,
+                    if (!_solutionContainerSystem.TryGetSolution(uid, udder.TargetSolutionName,
                             out var solution))
                         continue;
 
                     //TODO: toxins from bloodstream !?
-                    _solutionContainerSystem.TryAddReagent(udder.Owner, solution, udder.ReagentId,
+                    _solutionContainerSystem.TryAddReagent(uid, solution, udder.ReagentId,
                         udder.QuantityPerUpdate, out var accepted);
                 }
             }
index cd7adbd3e4717af3feb62b1e3a92445f46857480..964a42234d3a0dd0f1ba921b2ecbc64e302e13aa 100644 (file)
@@ -28,9 +28,9 @@ public sealed class BluespaceAnomalySystem : EntitySystem
         var xformQuery = GetEntityQuery<TransformComponent>();
         var xform = xformQuery.GetComponent(uid);
         var range = component.MaxShuffleRadius * args.Severity;
-        var allEnts = _lookup.GetComponentsInRange<MobStateComponent>(xform.Coordinates, range)
-            .Select(x => x.Owner).ToList();
-        allEnts.Add(uid);
+        var mobs = new HashSet<Entity<MobStateComponent>>();
+        _lookup.GetEntitiesInRange(xform.Coordinates, range, mobs);
+        var allEnts = new List<EntityUid>(mobs.Select(m => m.Owner)) { uid };
         var coords = new List<Vector2>();
         foreach (var ent in allEnts)
         {
@@ -51,7 +51,9 @@ public sealed class BluespaceAnomalySystem : EntitySystem
         var mapPos = _xform.GetWorldPosition(xform);
         var radius = component.SupercriticalTeleportRadius;
         var gridBounds = new Box2(mapPos - new Vector2(radius, radius), mapPos + new Vector2(radius, radius));
-        foreach (var comp in _lookup.GetComponentsInRange<MobStateComponent>(xform.Coordinates, component.MaxShuffleRadius))
+        var mobs = new HashSet<Entity<MobStateComponent>>();
+        _lookup.GetEntitiesInRange(xform.Coordinates, component.MaxShuffleRadius, mobs);
+        foreach (var comp in mobs)
         {
             var ent = comp.Owner;
             var randomX = _random.NextFloat(gridBounds.Left, gridBounds.Right);
index 688218d6ca1d463c97e64ef93730920ffeda6d63..bc6aa3bb1fb5b50f395e4a3d2e9a7dca3a50c049 100644 (file)
@@ -1,5 +1,5 @@
 using Content.Server.Electrocution;
-using Content.Server.Emp;
+using Content.Server.Emp;
 using Content.Server.Lightning;
 using Content.Server.Power.Components;
 using Content.Shared.Anomaly.Components;
@@ -31,9 +31,8 @@ public sealed class ElectricityAnomalySystem : EntitySystem
     {
         var range = component.MaxElectrocuteRange * args.Stability;
         var xform = Transform(uid);
-        foreach (var comp in _lookup.GetComponentsInRange<MobStateComponent>(xform.MapPosition, range))
+        foreach (var (ent, comp) in _lookup.GetEntitiesInRange<MobStateComponent>(xform.MapPosition, range))
         {
-            var ent = comp.Owner;
             _lightning.ShootLightning(uid, ent);
         }
     }
@@ -66,14 +65,13 @@ public sealed class ElectricityAnomalySystem : EntitySystem
     {
         base.Update(frameTime);
 
-        foreach (var (elec, anom, xform) in EntityQuery<ElectricityAnomalyComponent, AnomalyComponent, TransformComponent>())
+        var query = EntityQueryEnumerator<ElectricityAnomalyComponent, AnomalyComponent, TransformComponent>();
+        while (query.MoveNext(out var uid, out var elec, out var anom, out var xform))
         {
             if (_timing.CurTime < elec.NextSecond)
                 continue;
             elec.NextSecond = _timing.CurTime + TimeSpan.FromSeconds(1);
 
-            var owner = xform.Owner;
-
             if (!_random.Prob(elec.PassiveElectrocutionChance * anom.Stability))
                 continue;
 
@@ -81,11 +79,9 @@ public sealed class ElectricityAnomalySystem : EntitySystem
             var damage = (int) (elec.MaxElectrocuteDamage * anom.Severity);
             var duration = elec.MaxElectrocuteDuration * anom.Severity;
 
-            foreach (var comp in _lookup.GetComponentsInRange<StatusEffectsComponent>(xform.MapPosition, range))
+            foreach (var (ent, comp) in _lookup.GetEntitiesInRange<StatusEffectsComponent>(xform.MapPosition, range))
             {
-                var ent = comp.Owner;
-
-                _electrocution.TryDoElectrocution(ent, owner, damage, duration, true, statusEffects: comp, ignoreInsulation: true);
+                _electrocution.TryDoElectrocution(ent, uid, damage, duration, true, statusEffects: comp, ignoreInsulation: true);
             }
         }
     }
index 0cc7883808ade1ba4423094c8f9a4f55d18e5bbc..05f1c5c61c64f56ccd882f8539773704f7ac47d0 100644 (file)
@@ -1,8 +1,8 @@
 using System.Linq;
 using Content.Server.Anomaly.Components;
+using Content.Shared.Anomaly.Components;
 using Content.Shared.Chemistry.Components.SolutionManager;
 using Content.Shared.Chemistry.EntitySystems;
-using Content.Shared.Anomaly.Components;
 
 namespace Content.Server.Anomaly.Effects;
 /// <summary>
@@ -44,7 +44,7 @@ public sealed class InjectionAnomalySystem : EntitySystem
         //We get all the entity in the radius into which the reagent will be injected.
         var xformQuery = GetEntityQuery<TransformComponent>();
         var xform = xformQuery.GetComponent(uid);
-        var allEnts = _lookup.GetComponentsInRange<InjectableSolutionComponent>(xform.MapPosition, injectRadius)
+        var allEnts = _lookup.GetEntitiesInRange<InjectableSolutionComponent>(xform.MapPosition, injectRadius)
             .Select(x => x.Owner).ToList();
 
         //for each matching entity found
index 7ee6f12d0534fe127552e5a0268fa26f314dea08..6bd8be002e0adcc23c49536500b660f5beca36ae 100644 (file)
@@ -36,7 +36,10 @@ public sealed class PyroclasticAnomalySystem : EntitySystem
 
     public void IgniteNearby(EntityUid uid, EntityCoordinates coordinates, float severity, float radius)
     {
-        foreach (var flammable in _lookup.GetComponentsInRange<FlammableComponent>(coordinates, radius))
+        var flammables = new HashSet<Entity<FlammableComponent>>();
+        _lookup.GetEntitiesInRange(coordinates, radius, flammables);
+
+        foreach (var flammable in flammables)
         {
             var ent = flammable.Owner;
             var stackAmount = 1 + (int) (severity / 0.15f);
index b6db46abed457552a4baf3d24e23121cf5b94733..7eb34d90662c10d1b1abecc9bad9fb3325dc794a 100644 (file)
@@ -3,7 +3,7 @@ using Content.Server.Atmos.EntitySystems;
 using Content.Shared.Administration;
 using Content.Shared.Atmos;
 using Robust.Shared.Console;
-using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 
 namespace Content.Server.Atmos.Commands
 {
@@ -11,7 +11,6 @@ namespace Content.Server.Atmos.Commands
     public sealed class FillGas : IConsoleCommand
     {
         [Dependency] private readonly IEntityManager _entManager = default!;
-        [Dependency] private readonly IMapManager _mapManager = default!;
 
         public string Command => "fillgas";
         public string Description => "Adds gas to all tiles in a grid.";
@@ -30,7 +29,7 @@ namespace Content.Server.Atmos.Commands
                 return;
             }
 
-            if (!_mapManager.TryGetGrid(gridId, out var grid))
+            if (!_entManager.HasComponent<MapGridComponent>(gridId))
             {
                 shell.WriteLine("Invalid grid ID.");
                 return;
@@ -38,7 +37,7 @@ namespace Content.Server.Atmos.Commands
 
             var atmosphereSystem = _entManager.System<AtmosphereSystem>();
 
-            foreach (var tile in atmosphereSystem.GetAllMixtures(grid.Owner, true))
+            foreach (var tile in atmosphereSystem.GetAllMixtures(gridId.Value, true))
             {
                 tile.AdjustMoles(gasId, moles);
             }
index 1d7e306d5491d3fddcc0965d9f02d49f6686693c..a3ec0f03fd38909a8e7cb6faa913d46d1770a707 100644 (file)
@@ -3,7 +3,7 @@ using Content.Server.Atmos.EntitySystems;
 using Content.Shared.Administration;
 using Content.Shared.Atmos;
 using Robust.Shared.Console;
-using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 
 namespace Content.Server.Atmos.Commands
 {
@@ -11,7 +11,6 @@ namespace Content.Server.Atmos.Commands
     public sealed class SetAtmosTemperatureCommand : IConsoleCommand
     {
         [Dependency] private readonly IEntityManager _entManager = default!;
-        [Dependency] private readonly IMapManager _mapManager = default!;
 
         public string Command => "setatmostemp";
         public string Description => "Sets a grid's temperature (in kelvin).";
@@ -34,7 +33,7 @@ namespace Content.Server.Atmos.Commands
                 return;
             }
 
-            if (!gridId.Value.IsValid() || !_mapManager.TryGetGrid(gridId, out var gridComp))
+            if (!gridId.Value.IsValid() || !_entManager.HasComponent<MapGridComponent>(gridId))
             {
                 shell.WriteLine("Invalid grid ID.");
                 return;
@@ -43,7 +42,7 @@ namespace Content.Server.Atmos.Commands
             var atmosphereSystem = _entManager.System<AtmosphereSystem>();
 
             var tiles = 0;
-            foreach (var tile in atmosphereSystem.GetAllMixtures(gridComp.Owner, true))
+            foreach (var tile in atmosphereSystem.GetAllMixtures(gridId.Value, true))
             {
                 tiles++;
                 tile.Temperature = temperature;
index e6dcbdb4cfa979a85fd87c56d92e53c6155e4cc7..75d358dfd6df30472ee1aad4c9d50b07bec3828f 100644 (file)
@@ -2,11 +2,8 @@ using Content.Server.Administration;
 using Content.Server.Atmos.EntitySystems;
 using Content.Shared.Administration;
 using Content.Shared.Atmos;
-using Robust.Server.GameObjects;
 using Robust.Shared.Console;
-using Robust.Shared.GameObjects;
-using Robust.Shared.Map;
-using Robust.Shared.Maths;
+using Robust.Shared.Map.Components;
 
 namespace Content.Server.Atmos.Commands
 {
@@ -14,7 +11,6 @@ namespace Content.Server.Atmos.Commands
     public sealed class SetTemperatureCommand : IConsoleCommand
     {
         [Dependency] private readonly IEntityManager _entities = default!;
-        [Dependency] private readonly IMapManager _mapManager = default!;
 
         public string Command => "settemp";
         public string Description => "Sets a tile's temperature (in kelvin).";
@@ -40,7 +36,7 @@ namespace Content.Server.Atmos.Commands
                 return;
             }
 
-            if (!_mapManager.TryGetGrid(gridId, out var grid))
+            if (!_entities.HasComponent<MapGridComponent>(gridId))
             {
                 shell.WriteError("Invalid grid.");
                 return;
@@ -49,7 +45,7 @@ namespace Content.Server.Atmos.Commands
             var atmospheres = _entities.EntitySysManager.GetEntitySystem<AtmosphereSystem>();
             var indices = new Vector2i(x, y);
 
-            var tile = atmospheres.GetTileMixture(grid.Owner, null, indices, true);
+            var tile = atmospheres.GetTileMixture(gridId, null, indices, true);
 
             if (tile == null)
             {
index ab24daa7164b4c8cb20a00cdeb6bda7a0c0c1a71..f9301d7029e8b59addd354db80f4166ac82e3b88 100644 (file)
@@ -62,7 +62,7 @@ namespace Content.Server.Atmos.Components
         public readonly HashSet<IPipeNet> PipeNets = new();
 
         [ViewVariables]
-        public readonly HashSet<AtmosDeviceComponent> AtmosDevices = new();
+        public readonly HashSet<Entity<AtmosDeviceComponent>> AtmosDevices = new();
 
         [ViewVariables]
         public Queue<TileAtmosphere> CurrentRunTiles = new();
@@ -74,7 +74,7 @@ namespace Content.Server.Atmos.Components
         public Queue<IPipeNet> CurrentRunPipeNet = new();
 
         [ViewVariables]
-        public Queue<AtmosDeviceComponent> CurrentRunAtmosDevices = new();
+        public Queue<Entity<AtmosDeviceComponent>> CurrentRunAtmosDevices = new();
 
         [ViewVariables]
         public readonly HashSet<Vector2i> InvalidatedCoords = new(1000);
index f899ffb2e82e03ce9930abc9842e70f7c2744f25..97dccbaabb7317ab834994805c0f81dabbef9571 100644 (file)
@@ -4,7 +4,6 @@ using Content.Shared.Atmos;
 using JetBrains.Annotations;
 using Robust.Shared.Map;
 using Robust.Shared.Map.Components;
-using Content.Shared.Destructible;
 
 namespace Content.Server.Atmos.EntitySystems
 {
@@ -24,31 +23,32 @@ namespace Content.Server.Atmos.EntitySystems
             SubscribeLocalEvent<AirtightComponent, MoveEvent>(OnAirtightMoved);
         }
 
-        private void OnAirtightInit(EntityUid uid, AirtightComponent airtight, ComponentInit args)
+        private void OnAirtightInit(Entity<AirtightComponent> airtight, ref ComponentInit args)
         {
-            var xform = EntityManager.GetComponent<TransformComponent>(uid);
+            var xform = EntityManager.GetComponent<TransformComponent>(airtight);
 
-            if (airtight.FixAirBlockedDirectionInitialize)
+            if (airtight.Comp.FixAirBlockedDirectionInitialize)
             {
-                var moveEvent = new MoveEvent(uid, default, default, Angle.Zero, xform.LocalRotation, xform, false);
-                if (AirtightMove(uid, airtight, ref moveEvent))
+                var moveEvent = new MoveEvent(airtight, default, default, Angle.Zero, xform.LocalRotation, xform, false);
+                if (AirtightMove(airtight, ref moveEvent))
                     return;
             }
 
             UpdatePosition(airtight);
         }
 
-        private void OnAirtightShutdown(EntityUid uid, AirtightComponent airtight, ComponentShutdown args)
+        private void OnAirtightShutdown(Entity<AirtightComponent> airtight, ref ComponentShutdown args)
         {
-            var xform = Transform(uid);
+            var xform = Transform(airtight);
 
             // If the grid is deleting no point updating atmos.
-            if (_mapManager.TryGetGrid(xform.GridUid, out var grid))
+            if (HasComp<MapGridComponent>(xform.GridUid) &&
+                MetaData(xform.GridUid.Value).EntityLifeStage > EntityLifeStage.MapInitialized)
             {
-                if (MetaData(grid.Owner).EntityLifeStage > EntityLifeStage.MapInitialized) return;
+                return;
             }
 
-            SetAirblocked(uid, airtight, false, xform);
+            SetAirblocked(airtight, false, xform);
         }
 
         private void OnAirtightPositionChanged(EntityUid uid, AirtightComponent airtight, ref AnchorStateChangedEvent args)
@@ -78,44 +78,47 @@ namespace Content.Server.Atmos.EntitySystems
             }
         }
 
-        private void OnAirtightMoved(EntityUid uid, AirtightComponent airtight, ref MoveEvent ev)
+        private void OnAirtightMoved(Entity<AirtightComponent> airtight, ref MoveEvent ev)
         {
-            AirtightMove(uid, airtight, ref ev);
+            AirtightMove(airtight, ref ev);
         }
 
-        private bool AirtightMove(EntityUid uid, AirtightComponent airtight, ref MoveEvent ev)
+        private bool AirtightMove(Entity<AirtightComponent> ent, ref MoveEvent ev)
         {
+            var (owner, airtight) = ent;
             if (!airtight.RotateAirBlocked || airtight.InitialAirBlockedDirection == (int)AtmosDirection.Invalid)
                 return false;
 
             airtight.CurrentAirBlockedDirection = (int) Rotate((AtmosDirection)airtight.InitialAirBlockedDirection, ev.NewRotation);
             var pos = airtight.LastPosition;
-            UpdatePosition(airtight, ev.Component);
-            var airtightEv = new AirtightChanged(uid, airtight, pos);
-            RaiseLocalEvent(uid, ref airtightEv, true);
+            UpdatePosition(ent, ev.Component);
+            var airtightEv = new AirtightChanged(owner, airtight, pos);
+            RaiseLocalEvent(owner, ref airtightEv, true);
             return true;
         }
 
-        public void SetAirblocked(EntityUid uid, AirtightComponent airtight, bool airblocked, TransformComponent? xform = null)
+        public void SetAirblocked(Entity<AirtightComponent> airtight, bool airblocked, TransformComponent? xform = null)
         {
-            if (airtight.AirBlocked == airblocked)
+            if (airtight.Comp.AirBlocked == airblocked)
                 return;
 
-            if (!Resolve(uid, ref xform))
+            if (!Resolve(airtight, ref xform))
                 return;
 
-            var pos = airtight.LastPosition;
-            airtight.AirBlocked = airblocked;
+            var pos = airtight.Comp.LastPosition;
+            airtight.Comp.AirBlocked = airblocked;
             UpdatePosition(airtight, xform);
-            var airtightEv = new AirtightChanged(uid, airtight, pos);
-            RaiseLocalEvent(uid, ref airtightEv, true);
+            var airtightEv = new AirtightChanged(airtight, airtight, pos);
+            RaiseLocalEvent(airtight, ref airtightEv, true);
         }
 
-        public void UpdatePosition(AirtightComponent airtight, TransformComponent? xform = null)
+        public void UpdatePosition(Entity<AirtightComponent> ent, TransformComponent? xform = null)
         {
-            if (!Resolve(airtight.Owner, ref xform)) return;
+            var (owner, airtight) = ent;
+            if (!Resolve(owner, ref xform))
+                return;
 
-            if (!xform.Anchored || !_mapManager.TryGetGrid(xform.GridUid, out var grid))
+            if (!xform.Anchored || !TryComp(xform.GridUid, out MapGridComponent? grid))
                 return;
 
             airtight.LastPosition = (xform.GridUid.Value, grid.TileIndicesFor(xform.Coordinates));
@@ -124,15 +127,13 @@ namespace Content.Server.Atmos.EntitySystems
 
         public void InvalidatePosition(EntityUid gridId, Vector2i pos, bool fixVacuum = false)
         {
-            if (!_mapManager.TryGetGrid(gridId, out var grid))
+            if (!TryComp(gridId, out MapGridComponent? grid))
                 return;
 
-            var gridUid = grid.Owner;
-
             var query = EntityManager.GetEntityQuery<AirtightComponent>();
             _explosionSystem.UpdateAirtightMap(gridId, pos, grid, query);
             // TODO make atmos system use query
-            _atmosphereSystem.InvalidateTile(gridUid, pos);
+            _atmosphereSystem.InvalidateTile(gridId, pos);
         }
 
         private AtmosDirection Rotate(AtmosDirection myDirection, Angle myAngle)
@@ -146,7 +147,8 @@ namespace Content.Server.Atmos.EntitySystems
             for (var i = 0; i < Atmospherics.Directions; i++)
             {
                 var direction = (AtmosDirection) (1 << i);
-                if (!myDirection.IsFlagSet(direction)) continue;
+                if (!myDirection.IsFlagSet(direction))
+                    continue;
                 var angle = direction.ToAngle();
                 angle += myAngle;
                 newAirBlockedDirs |= angle.ToAtmosDirectionCardinal();
index 8b1c425d89ad14b28a9c50b3b72cd72eea47e746..34f558a2521c55a2fc022b1490b04050de3c07f6 100644 (file)
@@ -4,10 +4,12 @@ using Content.Shared.Atmos;
 using Content.Shared.Atmos.EntitySystems;
 using Content.Shared.CCVar;
 using JetBrains.Annotations;
+using Robust.Server.GameObjects;
 using Robust.Server.Player;
 using Robust.Shared.Configuration;
 using Robust.Shared.Enums;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 
 namespace Content.Server.Atmos.EntitySystems
 {
@@ -18,6 +20,7 @@ namespace Content.Server.Atmos.EntitySystems
         [Dependency] private readonly IMapManager _mapManager = default!;
         [Dependency] private readonly IConfigurationManager _configManager = default!;
         [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
+        [Dependency] private readonly MapSystem _mapSystem = default!;
 
         /// <summary>
         ///     Players allowed to see the atmos debug overlay.
@@ -31,6 +34,8 @@ namespace Content.Server.Atmos.EntitySystems
         /// </summary>
         private float _updateCooldown;
 
+        private List<Entity<MapGridComponent>> _grids = new();
+
         public override void Initialize()
         {
             base.Initialize();
@@ -137,7 +142,10 @@ namespace Content.Server.Atmos.EntitySystems
                 var worldBounds = Box2.CenteredAround(transform.WorldPosition,
                     new Vector2(LocalViewRange, LocalViewRange));
 
-                foreach (var grid in _mapManager.FindGridsIntersecting(transform.MapID, worldBounds))
+                _grids.Clear();
+                _mapManager.FindGridsIntersecting(transform.MapID, worldBounds, ref _grids);
+
+                foreach (var grid in _grids)
                 {
                     var uid = grid.Owner;
 
@@ -147,7 +155,7 @@ namespace Content.Server.Atmos.EntitySystems
                     if (!TryComp(uid, out GridAtmosphereComponent? gridAtmos))
                         continue;
 
-                    var entityTile = grid.GetTileRef(transform.Coordinates).GridIndices;
+                    var entityTile = _mapSystem.GetTileRef(grid, grid, transform.Coordinates).GridIndices;
                     var baseTile = new Vector2i(entityTile.X - (LocalViewRange / 2), entityTile.Y - (LocalViewRange / 2));
                     var debugOverlayContent = new AtmosDebugOverlayData[LocalViewRange * LocalViewRange];
 
@@ -161,7 +169,7 @@ namespace Content.Server.Atmos.EntitySystems
                         }
                     }
 
-                    RaiseNetworkEvent(new AtmosDebugOverlayMessage(GetNetEntity(grid.Owner), baseTile, debugOverlayContent), session.ConnectedClient);
+                    RaiseNetworkEvent(new AtmosDebugOverlayMessage(GetNetEntity(grid), baseTile, debugOverlayContent), session.ConnectedClient);
                 }
             }
         }
index 22270cb541de18bff1a4c5b4eae5004fb4e9585f..741a9341e79ed54f040e8e9a0e68002c75907813 100644 (file)
@@ -22,7 +22,7 @@ public sealed partial class AtmosphereSystem
 
         if (TryComp<InternalsComponent>(old, out var internalsComponent))
         {
-            _internals.DisconnectBreathTool(internalsComponent);
+            _internals.DisconnectBreathTool((old.Value, internalsComponent));
         }
 
         component.IsFunctional = false;
index 75caab93f054e2c65dc7d04abcf67e6ce65741c6..6fbd638844b60a718cf6a5f5ed477da05e9927ca 100644 (file)
@@ -3,7 +3,6 @@ using Content.Server.Administration;
 using Content.Server.Atmos.Components;
 using Content.Shared.Administration;
 using Content.Shared.Atmos;
-using Content.Shared.Maps;
 using Robust.Shared.Console;
 using Robust.Shared.Map;
 using Robust.Shared.Map.Components;
@@ -128,12 +127,13 @@ public sealed partial class AtmosphereSystem
         if (playerMap == null)
             return CompletionResult.FromOptions(options);
 
-        foreach (var grid in _mapManager.GetAllMapGrids(playerMap.Value).OrderBy(o => o.Owner))
+        foreach (var grid in _mapManager.GetAllGrids(playerMap.Value).OrderBy(o => o.Owner))
         {
-            if (!TryComp<TransformComponent>(grid.Owner, out var gridXform))
+            var uid = grid.Owner;
+            if (!TryComp<TransformComponent>(uid, out var gridXform))
                 continue;
 
-            options.Add(new CompletionOption(grid.Owner.ToString(), $"{MetaData(grid.Owner).EntityName} - Map {gridXform.MapID}"));
+            options.Add(new CompletionOption(uid.ToString(), $"{MetaData(uid).EntityName} - Map {gridXform.MapID}"));
         }
 
         return CompletionResult.FromOptions(options);
index 935abb29fc495f3f54af9d597cb519217674868b..036b64cad944b1e296f944c5fc2d9ebe97dce454 100644 (file)
@@ -3,7 +3,6 @@ using Content.Server.Atmos.Components;
 using Content.Server.Atmos.Reactions;
 using Content.Shared.Atmos;
 using Content.Shared.Atmos.Components;
-using Robust.Shared.Map;
 using Robust.Shared.Map.Components;
 using Robust.Shared.Utility;
 
@@ -57,7 +56,7 @@ public sealed partial class AtmosphereSystem
             tile.GridIndex = uid;
         }
 
-        GridRepopulateTiles(mapGrid, gridAtmosphere);
+        GridRepopulateTiles((uid, mapGrid, gridAtmosphere));
     }
 
     private void OnGridSplit(EntityUid uid, GridAtmosphereComponent originalGridAtmos, ref GridSplitEvent args)
@@ -65,14 +64,12 @@ public sealed partial class AtmosphereSystem
         foreach (var newGrid in args.NewGrids)
         {
             // Make extra sure this is a valid grid.
-            if (!_mapManager.TryGetGrid(newGrid, out var mapGrid))
+            if (!TryComp(newGrid, out MapGridComponent? mapGrid))
                 continue;
 
-            var entity = mapGrid.Owner;
-
             // If the new split grid has an atmosphere already somehow, use that. Otherwise, add a new one.
-            if (!TryComp(entity, out GridAtmosphereComponent? newGridAtmos))
-                newGridAtmos = AddComp<GridAtmosphereComponent>(entity);
+            if (!TryComp(newGrid, out GridAtmosphereComponent? newGridAtmos))
+                newGridAtmos = AddComp<GridAtmosphereComponent>(newGrid);
 
             // We assume the tiles on the new grid have the same coordinates as they did on the old grid...
             var enumerator = mapGrid.GetAllTilesEnumerator();
@@ -505,16 +502,15 @@ public sealed partial class AtmosphereSystem
         args.Handled = component.PipeNets.Remove(args.PipeNet);
     }
 
-    private void GridAddAtmosDevice(EntityUid uid, GridAtmosphereComponent component,
-        ref AddAtmosDeviceMethodEvent args)
+    private void GridAddAtmosDevice(Entity<GridAtmosphereComponent> grid, ref AddAtmosDeviceMethodEvent args)
     {
         if (args.Handled)
             return;
 
-        if (!component.AtmosDevices.Add(args.Device))
+        if (!grid.Comp.AtmosDevices.Add((args.Device.Owner, args.Device)))
             return;
 
-        args.Device.JoinedGrid = uid;
+        args.Device.JoinedGrid = grid;
         args.Handled = true;
         args.Result = true;
     }
@@ -525,7 +521,7 @@ public sealed partial class AtmosphereSystem
         if (args.Handled)
             return;
 
-        if (!component.AtmosDevices.Remove(args.Device))
+        if (!component.AtmosDevices.Remove((args.Device.Owner, args.Device)))
             return;
 
         args.Device.JoinedGrid = null;
@@ -538,8 +534,9 @@ public sealed partial class AtmosphereSystem
     /// </summary>
     /// <param name="mapGrid">The grid where to get all valid tiles from.</param>
     /// <param name="gridAtmosphere">The grid atmosphere where the tiles will be repopulated.</param>
-    private void GridRepopulateTiles(MapGridComponent mapGrid, GridAtmosphereComponent gridAtmosphere)
+    private void GridRepopulateTiles(Entity<MapGridComponent, GridAtmosphereComponent> grid)
     {
+        var (uid, mapGrid, gridAtmosphere) = grid;
         var volume = GetVolumeForTiles(mapGrid, 1);
 
         foreach (var tile in mapGrid.GetAllTiles())
@@ -551,16 +548,14 @@ public sealed partial class AtmosphereSystem
             gridAtmosphere.InvalidatedCoords.Add(tile.GridIndices);
         }
 
-        var uid = gridAtmosphere.Owner;
-
-        TryComp(gridAtmosphere.Owner, out GasTileOverlayComponent? overlay);
+        TryComp(uid, out GasTileOverlayComponent? overlay);
 
         // Gotta do this afterwards so we can properly update adjacent tiles.
         foreach (var (position, _) in gridAtmosphere.Tiles.ToArray())
         {
             var ev = new UpdateAdjacentMethodEvent(uid, position);
             GridUpdateAdjacent(uid, gridAtmosphere, ref ev);
-            InvalidateVisuals(mapGrid.Owner, position, overlay);
+            InvalidateVisuals(uid, position, overlay);
         }
     }
 }
index a06bf3504c7e73b3b18d8fb8232b00e9326b8a5d..020684aa3b9757a53da91383033b9548c5c4c1f8 100644 (file)
@@ -22,32 +22,34 @@ namespace Content.Server.Atmos.EntitySystems
         [ViewVariables(VVAccess.ReadWrite)]
         public string? SpaceWindSound { get; private set; } = "/Audio/Effects/space_wind.ogg";
 
-        private HashSet<MovedByPressureComponent> _activePressures = new(8);
+        private readonly HashSet<Entity<MovedByPressureComponent>> _activePressures = new(8);
 
         private void UpdateHighPressure(float frameTime)
         {
-            var toRemove = new RemQueue<MovedByPressureComponent>();
+            var toRemove = new RemQueue<Entity<MovedByPressureComponent>>();
 
-            foreach (var comp in _activePressures)
+            foreach (var ent in _activePressures)
             {
-                var uid = comp.Owner;
+                var (uid, comp) = ent;
                 MetaDataComponent? metadata = null;
 
                 if (Deleted(uid, metadata))
                 {
-                    toRemove.Add(comp);
+                    toRemove.Add((uid, comp));
                     continue;
                 }
 
-                if (Paused(uid, metadata)) continue;
+                if (Paused(uid, metadata))
+                    continue;
 
                 comp.Accumulator += frameTime;
 
-                if (comp.Accumulator < 2f) continue;
+                if (comp.Accumulator < 2f)
+                    continue;
 
                 // Reset it just for VV reasons even though it doesn't matter
                 comp.Accumulator = 0f;
-                toRemove.Add(comp);
+                toRemove.Add(ent);
 
                 if (HasComp<MobStateComponent>(uid) &&
                     TryComp<PhysicsComponent>(uid, out var body))
@@ -86,10 +88,10 @@ namespace Content.Server.Atmos.EntitySystems
             // idk it's hard.
 
             component.Accumulator = 0f;
-            _activePressures.Add(component);
+            _activePressures.Add((uid, component));
         }
 
-        private void HighPressureMovements(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, EntityQuery<PhysicsComponent> bodies, EntityQuery<TransformComponent> xforms, EntityQuery<MovedByPressureComponent> pressureQuery, EntityQuery<MetaDataComponent> metas)
+        private void HighPressureMovements(Entity<GridAtmosphereComponent> gridAtmosphere, TileAtmosphere tile, EntityQuery<PhysicsComponent> bodies, EntityQuery<TransformComponent> xforms, EntityQuery<MovedByPressureComponent> pressureQuery, EntityQuery<MetaDataComponent> metas)
         {
             // TODO ATMOS finish this
 
@@ -118,7 +120,7 @@ namespace Content.Server.Atmos.EntitySystems
                 return;
 
             // Used by ExperiencePressureDifference to correct push/throw directions from tile-relative to physics world.
-            var gridWorldRotation = xforms.GetComponent(gridAtmosphere.Owner).WorldRotation;
+            var gridWorldRotation = xforms.GetComponent(gridAtmosphere).WorldRotation;
 
             // If we're using monstermos, smooth out the yeet direction to follow the flow
             if (MonstermosEqualization)
@@ -151,12 +153,12 @@ namespace Content.Server.Atmos.EntitySystems
                 if (_containers.IsEntityInContainer(entity, metas.GetComponent(entity))) continue;
 
                 var pressureMovements = EnsureComp<MovedByPressureComponent>(entity);
-                if (pressure.LastHighPressureMovementAirCycle < gridAtmosphere.UpdateCounter)
+                if (pressure.LastHighPressureMovementAirCycle < gridAtmosphere.Comp.UpdateCounter)
                 {
                     // tl;dr YEET
                     ExperiencePressureDifference(
-                        pressureMovements,
-                        gridAtmosphere.UpdateCounter,
+                        (entity, pressureMovements),
+                        gridAtmosphere.Comp.UpdateCounter,
                         tile.PressureDifference,
                         tile.PressureDirection, 0,
                         tile.PressureSpecificTarget?.GridIndices.ToEntityCoordinates(tile.GridIndex, _mapManager) ?? EntityCoordinates.Invalid,
@@ -180,7 +182,7 @@ namespace Content.Server.Atmos.EntitySystems
         }
 
         public void ExperiencePressureDifference(
-            MovedByPressureComponent component,
+            Entity<MovedByPressureComponent> ent,
             int cycle,
             float pressureDifference,
             AtmosDirection direction,
@@ -190,12 +192,12 @@ namespace Content.Server.Atmos.EntitySystems
             TransformComponent? xform = null,
             PhysicsComponent? physics = null)
         {
-            var uid = component.Owner;
-
+            var (uid, component) = ent;
             if (!Resolve(uid, ref physics, false))
                 return;
 
-            if (!Resolve(uid, ref xform)) return;
+            if (!Resolve(uid, ref xform))
+                return;
 
             // TODO ATMOS stuns?
 
index c7191b27792921ce77a2f5c1fec519de4427f1ec..aceda3cd332391d8780c8aa0bd6c9009cb9b4b70 100644 (file)
@@ -1,16 +1,15 @@
+using System.Linq;
+using System.Numerics;
 using Content.Server.Atmos.Components;
 using Content.Server.Doors.Systems;
-using Content.Shared.Doors.Components;
 using Content.Shared.Atmos;
 using Content.Shared.Atmos.Components;
 using Content.Shared.Database;
-using Robust.Shared.Map;
+using Content.Shared.Doors.Components;
 using Robust.Shared.Map.Components;
 using Robust.Shared.Physics.Components;
 using Robust.Shared.Random;
 using Robust.Shared.Utility;
-using System.Linq;
-using System.Numerics;
 
 namespace Content.Server.Atmos.EntitySystems
 {
@@ -28,7 +27,7 @@ namespace Content.Server.Atmos.EntitySystems
         private readonly TileAtmosphere[] _depressurizeSpaceTiles = new TileAtmosphere[Atmospherics.MonstermosHardTileLimit];
         private readonly TileAtmosphere[] _depressurizeProgressionOrder = new TileAtmosphere[Atmospherics.MonstermosHardTileLimit * 2];
 
-        private void EqualizePressureInZone(MapGridComponent mapGrid, GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, int cycleNum, GasTileOverlayComponent? visuals)
+        private void EqualizePressureInZone(Entity<MapGridComponent, GridAtmosphereComponent> ent, TileAtmosphere tile, int cycleNum, GasTileOverlayComponent? visuals)
         {
             if (tile.Air == null || (tile.MonstermosInfo.LastCycle >= cycleNum))
                 return; // Already done.
@@ -57,6 +56,7 @@ namespace Content.Server.Atmos.EntitySystems
                 return;
             }
 
+            var (_, mapGrid, gridAtmosphere) = ent;
             var queueCycle = ++gridAtmosphere.EqualizationQueueCycleControl;
             var totalMoles = 0f;
             _equalizeTiles[0] = tile;
@@ -91,7 +91,7 @@ namespace Content.Server.Atmos.EntitySystems
                     {
                         // Looks like someone opened an airlock to space!
 
-                        ExplosivelyDepressurize(mapGrid, gridAtmosphere, tile, cycleNum, visuals);
+                        ExplosivelyDepressurize(ent, tile, cycleNum, visuals);
                         return;
                     }
                 }
@@ -359,7 +359,7 @@ namespace Content.Server.Atmos.EntitySystems
             Array.Clear(_equalizeQueue, 0, Atmospherics.MonstermosTileLimit);
         }
 
-        private void ExplosivelyDepressurize(MapGridComponent mapGrid, GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, int cycleNum, GasTileOverlayComponent? visuals)
+        private void ExplosivelyDepressurize(Entity<MapGridComponent, GridAtmosphereComponent> ent, TileAtmosphere tile, int cycleNum, GasTileOverlayComponent? visuals)
         {
             // Check if explosive depressurization is enabled and if the tile is valid.
             if (!MonstermosDepressurization || tile.Air == null)
@@ -368,6 +368,7 @@ namespace Content.Server.Atmos.EntitySystems
             const int limit = Atmospherics.MonstermosHardTileLimit;
 
             var totalMolesRemoved = 0f;
+            var (owner, mapGrid, gridAtmosphere) = ent;
             var queueCycle = ++gridAtmosphere.EqualizationQueueCycleControl;
 
             var tileCount = 0;
@@ -394,7 +395,7 @@ namespace Content.Server.Atmos.EntitySystems
                         DebugTools.Assert(otherTile2.AdjacentBits.IsFlagSet(direction.GetOpposite()));
                         if (otherTile2.MonstermosInfo.LastQueueCycle == queueCycle) continue;
 
-                        ConsiderFirelocks(gridAtmosphere, otherTile, otherTile2, visuals, mapGrid);
+                        ConsiderFirelocks((owner, gridAtmosphere), otherTile, otherTile2, visuals, mapGrid);
 
                         // The firelocks might have closed on us.
                         if (!otherTile.AdjacentBits.IsFlagSet(direction)) continue;
@@ -527,11 +528,11 @@ namespace Content.Server.Atmos.EntitySystems
             {
                 var direction = ((Vector2)_depressurizeTiles[tileCount - 1].GridIndices - tile.GridIndices).Normalized();
 
-                var gridPhysics = Comp<PhysicsComponent>(mapGrid.Owner);
+                var gridPhysics = Comp<PhysicsComponent>(owner);
 
                 // TODO ATMOS: Come up with better values for these.
-                _physics.ApplyLinearImpulse(mapGrid.Owner, direction * totalMolesRemoved * gridPhysics.Mass, body: gridPhysics);
-                _physics.ApplyAngularImpulse(mapGrid.Owner, Vector2Helpers.Cross(tile.GridIndices - gridPhysics.LocalCenter, direction) * totalMolesRemoved, body: gridPhysics);
+                _physics.ApplyLinearImpulse(owner, direction * totalMolesRemoved * gridPhysics.Mass, body: gridPhysics);
+                _physics.ApplyAngularImpulse(owner, Vector2Helpers.Cross(tile.GridIndices - gridPhysics.LocalCenter, direction) * totalMolesRemoved, body: gridPhysics);
             }
 
             if(tileCount > 10 && (totalMolesRemoved / tileCount) > 10)
@@ -543,7 +544,7 @@ namespace Content.Server.Atmos.EntitySystems
             Array.Clear(_depressurizeProgressionOrder, 0, Atmospherics.MonstermosHardTileLimit * 2);
         }
 
-        private void ConsiderFirelocks(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, TileAtmosphere other, GasTileOverlayComponent? visuals, MapGridComponent mapGrid)
+        private void ConsiderFirelocks(Entity<GridAtmosphereComponent> ent, TileAtmosphere tile, TileAtmosphere other, GasTileOverlayComponent? visuals, MapGridComponent mapGrid)
         {
             var reconsiderAdjacent = false;
 
@@ -566,10 +567,11 @@ namespace Content.Server.Atmos.EntitySystems
             if (!reconsiderAdjacent)
                 return;
 
-            var tileEv = new UpdateAdjacentMethodEvent(mapGrid.Owner, tile.GridIndices);
-            var otherEv = new UpdateAdjacentMethodEvent(mapGrid.Owner, other.GridIndices);
-            GridUpdateAdjacent(mapGrid.Owner, gridAtmosphere, ref tileEv);
-            GridUpdateAdjacent(mapGrid.Owner, gridAtmosphere, ref otherEv);
+            var (owner, gridAtmosphere) = ent;
+            var tileEv = new UpdateAdjacentMethodEvent(owner, tile.GridIndices);
+            var otherEv = new UpdateAdjacentMethodEvent(owner, other.GridIndices);
+            GridUpdateAdjacent(owner, gridAtmosphere, ref tileEv);
+            GridUpdateAdjacent(owner, gridAtmosphere, ref otherEv);
             InvalidateVisuals(tile.GridIndex, tile.GridIndices, visuals);
             InvalidateVisuals(other.GridIndex, other.GridIndices, visuals);
         }
index 38b66a73fafa9a61d9d773ab4bb57a6c79ba3e09..6499291495b618ba3c7a9b7f417a1a4131a51b59 100644 (file)
@@ -26,50 +26,49 @@ namespace Content.Server.Atmos.EntitySystems
         /// </summary>
         private const int InvalidCoordinatesLagCheckIterations = 50;
 
-        private int _currentRunAtmosphereIndex = 0;
-        private bool _simulationPaused = false;
+        private int _currentRunAtmosphereIndex;
+        private bool _simulationPaused;
 
-        private readonly List<GridAtmosphereComponent> _currentRunAtmosphere = new();
+        private readonly List<Entity<GridAtmosphereComponent>> _currentRunAtmosphere = new();
 
         /// <summary>
         ///     Revalidates all invalid coordinates in a grid atmosphere.
         /// </summary>
-        /// <param name="atmosphere">The grid atmosphere in question.</param>
+        /// <param name="ent">The grid atmosphere in question.</param>
         /// <returns>Whether the process succeeded or got paused due to time constrains.</returns>
-        private bool ProcessRevalidate(GridAtmosphereComponent atmosphere, GasTileOverlayComponent? visuals)
+        private bool ProcessRevalidate(Entity<GridAtmosphereComponent> ent, GasTileOverlayComponent? visuals)
         {
+            var (owner, atmosphere) = ent;
             if (!atmosphere.ProcessingPaused)
             {
                 atmosphere.CurrentRunInvalidatedCoordinates = new Queue<Vector2i>(atmosphere.InvalidatedCoords);
                 atmosphere.InvalidatedCoords.Clear();
             }
 
-            var uid = atmosphere.Owner;
-
-            if (!TryComp(uid, out MapGridComponent? mapGridComp))
+            if (!TryComp(owner, out MapGridComponent? mapGridComp))
                 return true;
 
-            var mapUid = _mapManager.GetMapEntityIdOrThrow(Transform(mapGridComp.Owner).MapID);
+            var mapUid = _mapManager.GetMapEntityIdOrThrow(Transform(owner).MapID);
 
-            var volume = GetVolumeForTiles(mapGridComp, 1);
+            var volume = GetVolumeForTiles(mapGridComp);
 
             var number = 0;
             while (atmosphere.CurrentRunInvalidatedCoordinates.TryDequeue(out var indices))
             {
                 if (!atmosphere.Tiles.TryGetValue(indices, out var tile))
                 {
-                    tile = new TileAtmosphere(mapGridComp.Owner, indices,
+                    tile = new TileAtmosphere(owner, indices,
                         new GasMixture(volume) { Temperature = Atmospherics.T20C });
                     atmosphere.Tiles[indices] = tile;
                 }
 
-                var airBlockedEv = new IsTileAirBlockedMethodEvent(uid, indices, MapGridComponent:mapGridComp);
-                GridIsTileAirBlocked(uid, atmosphere, ref airBlockedEv);
+                var airBlockedEv = new IsTileAirBlockedMethodEvent(owner, indices, MapGridComponent:mapGridComp);
+                GridIsTileAirBlocked(owner, atmosphere, ref airBlockedEv);
                 var isAirBlocked = airBlockedEv.Result;
 
                 var oldBlocked = tile.BlockedAirflow;
-                var updateAdjacentEv = new UpdateAdjacentMethodEvent(uid, indices, mapGridComp);
-                GridUpdateAdjacent(uid, atmosphere, ref updateAdjacentEv);
+                var updateAdjacentEv = new UpdateAdjacentMethodEvent(owner, indices, mapGridComp);
+                GridUpdateAdjacent(owner, atmosphere, ref updateAdjacentEv);
 
                 // Blocked airflow changed, rebuild excited groups!
                 if (tile.Excited && tile.BlockedAirflow != oldBlocked)
@@ -99,8 +98,8 @@ namespace Content.Server.Atmos.EntitySystems
                 {
                     if (tile.Air == null && NeedsVacuumFixing(mapGridComp, indices))
                     {
-                        var vacuumEv = new FixTileVacuumMethodEvent(uid, indices);
-                        GridFixTileVacuum(uid, atmosphere, ref vacuumEv);
+                        var vacuumEv = new FixTileVacuumMethodEvent(owner, indices);
+                        GridFixTileVacuum(owner, atmosphere, ref vacuumEv);
                     }
 
                     // Tile used to be space, but isn't anymore.
@@ -122,11 +121,12 @@ namespace Content.Server.Atmos.EntitySystems
 
                 // TODO ATMOS: Query all the contents of this tile (like walls) and calculate the correct thermal conductivity and heat capacity
                 var tileDef = mapGridComp.TryGetTileRef(indices, out var tileRef)
-                    ? tileRef.GetContentTileDefinition(_tileDefinitionManager) : null;
+                    ? tileRef.GetContentTileDefinition(_tileDefinitionManager)
+                    : null;
 
                 tile.ThermalConductivity = tileDef?.ThermalConductivity ?? 0.5f;
                 tile.HeatCapacity = tileDef?.HeatCapacity ?? float.PositiveInfinity;
-                InvalidateVisuals(mapGridComp.Owner, indices, visuals);
+                InvalidateVisuals(owner, indices, visuals);
 
                 for (var i = 0; i < Atmospherics.Directions; i++)
                 {
@@ -137,7 +137,9 @@ namespace Content.Server.Atmos.EntitySystems
                         AddActiveTile(atmosphere, otherTile);
                 }
 
-                if (number++ < InvalidCoordinatesLagCheckIterations) continue;
+                if (number++ < InvalidCoordinatesLagCheckIterations)
+                    continue;
+
                 number = 0;
                 // Process the rest next time.
                 if (_simulationStopwatch.Elapsed.TotalMilliseconds >= AtmosMaxProcessTime)
@@ -149,22 +151,23 @@ namespace Content.Server.Atmos.EntitySystems
             return true;
         }
 
-        private bool ProcessTileEqualize(GridAtmosphereComponent atmosphere, GasTileOverlayComponent? visuals)
+        private bool ProcessTileEqualize(Entity<GridAtmosphereComponent> ent, GasTileOverlayComponent? visuals)
         {
-            if(!atmosphere.ProcessingPaused)
+            var (uid, atmosphere) = ent;
+            if (!atmosphere.ProcessingPaused)
                 atmosphere.CurrentRunTiles = new Queue<TileAtmosphere>(atmosphere.ActiveTiles);
 
-            var uid = atmosphere.Owner;
-
             if (!TryComp(uid, out MapGridComponent? mapGridComp))
                 throw new Exception("Tried to process a grid atmosphere on an entity that isn't a grid!");
 
             var number = 0;
             while (atmosphere.CurrentRunTiles.TryDequeue(out var tile))
             {
-                EqualizePressureInZone(mapGridComp, atmosphere, tile, atmosphere.UpdateCounter, visuals);
+                EqualizePressureInZone((uid, mapGridComp, atmosphere), tile, atmosphere.UpdateCounter, visuals);
+
+                if (number++ < LagCheckIterations)
+                    continue;
 
-                if (number++ < LagCheckIterations) continue;
                 number = 0;
                 // Process the rest next time.
                 if (_simulationStopwatch.Elapsed.TotalMilliseconds >= AtmosMaxProcessTime)
@@ -186,7 +189,9 @@ namespace Content.Server.Atmos.EntitySystems
             {
                 ProcessCell(atmosphere, tile, atmosphere.UpdateCounter, visuals);
 
-                if (number++ < LagCheckIterations) continue;
+                if (number++ < LagCheckIterations)
+                    continue;
+
                 number = 0;
                 // Process the rest next time.
                 if (_simulationStopwatch.Elapsed.TotalMilliseconds >= AtmosMaxProcessTime)
@@ -215,7 +220,9 @@ namespace Content.Server.Atmos.EntitySystems
                 else if(excitedGroup.DismantleCooldown > Atmospherics.ExcitedGroupsDismantleCycles)
                     ExcitedGroupDismantle(gridAtmosphere, excitedGroup);
 
-                if (number++ < LagCheckIterations) continue;
+                if (number++ < LagCheckIterations)
+                    continue;
+
                 number = 0;
                 // Process the rest next time.
                 if (_simulationStopwatch.Elapsed.TotalMilliseconds >= AtmosMaxProcessTime)
@@ -227,9 +234,10 @@ namespace Content.Server.Atmos.EntitySystems
             return true;
         }
 
-        private bool ProcessHighPressureDelta(GridAtmosphereComponent atmosphere)
+        private bool ProcessHighPressureDelta(Entity<GridAtmosphereComponent> ent)
         {
-            if(!atmosphere.ProcessingPaused)
+            var atmosphere = ent.Comp;
+            if (!atmosphere.ProcessingPaused)
                 atmosphere.CurrentRunTiles = new Queue<TileAtmosphere>(atmosphere.HighPressureDelta);
 
             // Note: This is still processed even if space wind is turned off since this handles playing the sounds.
@@ -242,14 +250,15 @@ namespace Content.Server.Atmos.EntitySystems
 
             while (atmosphere.CurrentRunTiles.TryDequeue(out var tile))
             {
-                HighPressureMovements(atmosphere, tile, bodies, xforms, pressureQuery, metas);
+                HighPressureMovements(ent, tile, bodies, xforms, pressureQuery, metas);
                 tile.PressureDifference = 0f;
                 tile.LastPressureDirection = tile.PressureDirection;
                 tile.PressureDirection = AtmosDirection.Invalid;
                 tile.PressureSpecificTarget = null;
                 atmosphere.HighPressureDelta.Remove(tile);
 
-                if (number++ < LagCheckIterations) continue;
+                if (number++ < LagCheckIterations)
+                    continue;
                 number = 0;
                 // Process the rest next time.
                 if (_simulationStopwatch.Elapsed.TotalMilliseconds >= AtmosMaxProcessTime)
@@ -271,7 +280,9 @@ namespace Content.Server.Atmos.EntitySystems
             {
                 ProcessHotspot(atmosphere, hotspot);
 
-                if (number++ < LagCheckIterations) continue;
+                if (number++ < LagCheckIterations)
+                    continue;
+
                 number = 0;
                 // Process the rest next time.
                 if (_simulationStopwatch.Elapsed.TotalMilliseconds >= AtmosMaxProcessTime)
@@ -293,7 +304,9 @@ namespace Content.Server.Atmos.EntitySystems
             {
                 Superconduct(atmosphere, superconductivity);
 
-                if (number++ < LagCheckIterations) continue;
+                if (number++ < LagCheckIterations)
+                    continue;
+
                 number = 0;
                 // Process the rest next time.
                 if (_simulationStopwatch.Elapsed.TotalMilliseconds >= AtmosMaxProcessTime)
@@ -315,7 +328,9 @@ namespace Content.Server.Atmos.EntitySystems
             {
                 pipenet.Update();
 
-                if (number++ < LagCheckIterations) continue;
+                if (number++ < LagCheckIterations)
+                    continue;
+
                 number = 0;
                 // Process the rest next time.
                 if (_simulationStopwatch.Elapsed.TotalMilliseconds >= AtmosMaxProcessTime)
@@ -346,17 +361,19 @@ namespace Content.Server.Atmos.EntitySystems
 
         private bool ProcessAtmosDevices(GridAtmosphereComponent atmosphere)
         {
-            if(!atmosphere.ProcessingPaused)
-                atmosphere.CurrentRunAtmosDevices = new Queue<AtmosDeviceComponent>(atmosphere.AtmosDevices);
+            if (!atmosphere.ProcessingPaused)
+                atmosphere.CurrentRunAtmosDevices = new Queue<Entity<AtmosDeviceComponent>>(atmosphere.AtmosDevices);
 
             var time = _gameTiming.CurTime;
             var number = 0;
             while (atmosphere.CurrentRunAtmosDevices.TryDequeue(out var device))
             {
-                RaiseLocalEvent(device.Owner, new AtmosDeviceUpdateEvent(RealAtmosTime()), false);
-                device.LastProcess = time;
+                RaiseLocalEvent(device, new AtmosDeviceUpdateEvent(RealAtmosTime()));
+                device.Comp.LastProcess = time;
+
+                if (number++ < LagCheckIterations)
+                    continue;
 
-                if (number++ < LagCheckIterations) continue;
                 number = 0;
                 // Process the rest next time.
                 if (_simulationStopwatch.Elapsed.TotalMilliseconds >= AtmosMaxProcessTime)
@@ -376,7 +393,12 @@ namespace Content.Server.Atmos.EntitySystems
             {
                 _currentRunAtmosphereIndex = 0;
                 _currentRunAtmosphere.Clear();
-                _currentRunAtmosphere.AddRange(EntityManager.EntityQuery<GridAtmosphereComponent>());
+
+                var query = EntityQueryEnumerator<GridAtmosphereComponent>();
+                while (query.MoveNext(out var uid, out var grid))
+                {
+                    _currentRunAtmosphere.Add((uid, grid));
+                }
             }
 
             // We set this to true just in case we have to stop processing due to time constraints.
@@ -384,10 +406,11 @@ namespace Content.Server.Atmos.EntitySystems
 
             for (; _currentRunAtmosphereIndex < _currentRunAtmosphere.Count; _currentRunAtmosphereIndex++)
             {
-                var atmosphere = _currentRunAtmosphere[_currentRunAtmosphereIndex];
-                TryComp(atmosphere.Owner, out GasTileOverlayComponent? visuals);
+                var ent = _currentRunAtmosphere[_currentRunAtmosphereIndex];
+                var (owner, atmosphere) = ent;
+                TryComp(owner, out GasTileOverlayComponent? visuals);
 
-                if (atmosphere.LifeStage >= ComponentLifeStage.Stopping || Paused(atmosphere.Owner) || !atmosphere.Simulated)
+                if (atmosphere.LifeStage >= ComponentLifeStage.Stopping || Paused(owner) || !atmosphere.Simulated)
                     continue;
 
                 atmosphere.Timer += frameTime;
@@ -401,7 +424,7 @@ namespace Content.Server.Atmos.EntitySystems
                 switch (atmosphere.State)
                 {
                     case AtmosphereProcessingState.Revalidate:
-                        if (!ProcessRevalidate(atmosphere, visuals))
+                        if (!ProcessRevalidate(ent, visuals))
                         {
                             atmosphere.ProcessingPaused = true;
                             return;
@@ -416,7 +439,7 @@ namespace Content.Server.Atmos.EntitySystems
                             : AtmosphereProcessingState.ActiveTiles;
                         continue;
                     case AtmosphereProcessingState.TileEqualize:
-                        if (!ProcessTileEqualize(atmosphere, visuals))
+                        if (!ProcessTileEqualize(ent, visuals))
                         {
                             atmosphere.ProcessingPaused = true;
                             return;
@@ -447,7 +470,7 @@ namespace Content.Server.Atmos.EntitySystems
                         atmosphere.State = AtmosphereProcessingState.HighPressureDelta;
                         continue;
                     case AtmosphereProcessingState.HighPressureDelta:
-                        if (!ProcessHighPressureDelta(atmosphere))
+                        if (!ProcessHighPressureDelta(ent))
                         {
                             atmosphere.ProcessingPaused = true;
                             return;
index 5d3e989e415d03dfba7702b9edbb14726c303927..91634de8d7afc47fce7f2ec7e9ed7b2e07e14fbd 100644 (file)
@@ -4,7 +4,6 @@ using Content.Server.Body.Systems;
 using Content.Server.Maps;
 using Content.Server.NodeContainer.EntitySystems;
 using Content.Shared.Atmos.EntitySystems;
-using Content.Shared.Maps;
 using JetBrains.Annotations;
 using Robust.Server.GameObjects;
 using Robust.Shared.Containers;
@@ -76,15 +75,16 @@ public sealed partial class AtmosphereSystem : SharedAtmosphereSystem
         if (_exposedTimer < ExposedUpdateDelay)
             return;
 
-        foreach (var (exposed, transform) in EntityManager.EntityQuery<AtmosExposedComponent, TransformComponent>())
+        var query = EntityQueryEnumerator<AtmosExposedComponent, TransformComponent>();
+        while (query.MoveNext(out var uid, out var exposed, out var transform))
         {
-            var air = GetContainingMixture(exposed.Owner, transform:transform);
+            var air = GetContainingMixture(uid, transform:transform);
 
             if (air == null)
                 continue;
 
             var updateEvent = new AtmosExposedUpdateEvent(transform.Coordinates, air, transform);
-            RaiseLocalEvent(exposed.Owner, ref updateEvent);
+            RaiseLocalEvent(uid, ref updateEvent);
         }
 
         _exposedTimer -= ExposedUpdateDelay;
index b2f62572bffb68cd357f6e1cbb1441f4e8d96e68..be3e5cd9341cfd2c9e766903af5d8b2326308d96 100644 (file)
@@ -16,9 +16,7 @@ using Content.Shared.Temperature;
 using Content.Shared.Throwing;
 using Content.Shared.Weapons.Melee.Events;
 using Robust.Server.GameObjects;
-using Robust.Shared.Physics;
 using Robust.Shared.Physics.Components;
-using Robust.Shared.Physics.Dynamics;
 using Robust.Shared.Physics.Events;
 using Robust.Shared.Physics.Systems;
 
@@ -48,7 +46,7 @@ namespace Content.Server.Atmos.EntitySystems
 
         private float _timer;
 
-        private Dictionary<FlammableComponent, float> _fireEvents = new();
+        private readonly Dictionary<Entity<FlammableComponent>, float> _fireEvents = new();
 
         public override void Initialize()
         {
@@ -188,14 +186,14 @@ namespace Content.Server.Atmos.EntitySystems
             args.IsHot = flammable.OnFire;
         }
 
-        private void OnTileFire(EntityUid uid, FlammableComponent flammable, ref TileFireEvent args)
+        private void OnTileFire(Entity<FlammableComponent> ent, ref TileFireEvent args)
         {
             var tempDelta = args.Temperature - MinIgnitionTemperature;
 
-            _fireEvents.TryGetValue(flammable, out var maxTemp);
+            _fireEvents.TryGetValue(ent, out var maxTemp);
 
             if (tempDelta > maxTemp)
-                _fireEvents[flammable] = tempDelta;
+                _fireEvents[ent] = tempDelta;
         }
 
         private void OnRejuvenate(EntityUid uid, FlammableComponent component, RejuvenateEvent args)
@@ -295,7 +293,7 @@ namespace Content.Server.Atmos.EntitySystems
             {
                 // 100 -> 1, 200 -> 2, 400 -> 3...
                 var fireStackMod = Math.Max(MathF.Log2(deltaTemp / 100) + 1, 0);
-                var fireStackDelta = fireStackMod - flammable.FireStacks;
+                var fireStackDelta = fireStackMod - flammable.Comp.FireStacks;
                 var flammableEntity = flammable.Owner;
                 if (fireStackDelta > 0)
                 {
@@ -313,10 +311,9 @@ namespace Content.Server.Atmos.EntitySystems
             _timer -= UpdateTime;
 
             // TODO: This needs cleanup to take off the crust from TemperatureComponent and shit.
-            foreach (var (flammable, transform) in EntityManager.EntityQuery<FlammableComponent, TransformComponent>())
+            var query = EntityQueryEnumerator<FlammableComponent, TransformComponent>();
+            while (query.MoveNext(out var uid, out var flammable, out var transform))
             {
-                var uid = flammable.Owner;
-
                 // Slowly dry ourselves off if wet.
                 if (flammable.FireStacks < 0)
                 {
index 03286f08abcb783f75fb25404a7fb7fb3caa0cd7..df867d351638ac0ace78f9ac41b2be4b31626e03 100644 (file)
@@ -53,31 +53,35 @@ namespace Content.Server.Atmos.EntitySystems
             SubscribeLocalEvent<GasTankComponent, GetVerbsEvent<AlternativeVerb>>(OnGetAlternativeVerb);
         }
 
-        private void OnGasShutdown(EntityUid uid, GasTankComponent component, ComponentShutdown args)
+        private void OnGasShutdown(Entity<GasTankComponent> gasTank, ref ComponentShutdown args)
         {
-            DisconnectFromInternals(component);
+            DisconnectFromInternals(gasTank);
         }
 
-        private void OnGasTankToggleInternals(EntityUid uid, GasTankComponent component, GasTankToggleInternalsMessage args)
+        private void OnGasTankToggleInternals(Entity<GasTankComponent> ent, ref GasTankToggleInternalsMessage args)
         {
             if (args.Session is not IPlayerSession playerSession ||
-                playerSession.AttachedEntity is not {} player) return;
+                playerSession.AttachedEntity == null)
+            {
+                return;
+            }
 
-            ToggleInternals(component);
+            ToggleInternals(ent);
         }
 
-        private void OnGasTankSetPressure(EntityUid uid, GasTankComponent component, GasTankSetPressureMessage args)
+        private void OnGasTankSetPressure(Entity<GasTankComponent> ent, ref GasTankSetPressureMessage args)
         {
-            var pressure = Math.Min(args.Pressure, component.MaxOutputPressure);
+            var pressure = Math.Min(args.Pressure, ent.Comp.MaxOutputPressure);
 
-            component.OutputPressure = pressure;
+            ent.Comp.OutputPressure = pressure;
 
-            UpdateUserInterface(component, true);
+            UpdateUserInterface(ent, true);
         }
 
-        public void UpdateUserInterface(GasTankComponent component, bool initialUpdate = false)
+        public void UpdateUserInterface(Entity<GasTankComponent> ent, bool initialUpdate = false)
         {
-            _ui.TrySetUiState(component.Owner, SharedGasTankUiKey.Key,
+            var (owner, component) = ent;
+            _ui.TrySetUiState(owner, SharedGasTankUiKey.Key,
                 new GasTankBoundUserInterfaceState
                 {
                     TankPressure = component.Air?.Pressure ?? 0,
@@ -87,10 +91,10 @@ namespace Content.Server.Atmos.EntitySystems
                 });
         }
 
-        private void BeforeUiOpen(EntityUid uid, GasTankComponent component, BeforeActivatableUIOpenEvent args)
+        private void BeforeUiOpen(Entity<GasTankComponent> ent, ref BeforeActivatableUIOpenEvent args)
         {
             // Only initial update includes output pressure information, to avoid overwriting client-input as the updates come in.
-            UpdateUserInterface(component, true);
+            UpdateUserInterface(ent, true);
         }
 
         private void OnParentChange(EntityUid uid, GasTankComponent component, ref EntParentChangedMessage args)
@@ -115,12 +119,12 @@ namespace Content.Server.Atmos.EntitySystems
             args.PushMarkup(Loc.GetString(component.IsValveOpen ? "comp-gas-tank-examine-open-valve" : "comp-gas-tank-examine-closed-valve"));
         }
 
-        private void OnActionToggle(EntityUid uid, GasTankComponent component, ToggleActionEvent args)
+        private void OnActionToggle(Entity<GasTankComponent> gasTank, ref ToggleActionEvent args)
         {
             if (args.Handled)
                 return;
 
-            ToggleInternals(component);
+            ToggleInternals(gasTank);
             args.Handled = true;
         }
 
@@ -130,30 +134,33 @@ namespace Content.Server.Atmos.EntitySystems
 
             _timer += frameTime;
 
-            if (_timer < TimerDelay) return;
+            if (_timer < TimerDelay)
+                return;
+
             _timer -= TimerDelay;
 
             var query = EntityQueryEnumerator<GasTankComponent>();
-            while (query.MoveNext(out var uid, out var gasTank))
+            while (query.MoveNext(out var uid, out var comp))
             {
-                if (gasTank.IsValveOpen && !gasTank.IsLowPressure)
+                var gasTank = (uid, comp);
+                if (comp.IsValveOpen && !comp.IsLowPressure)
                 {
-                    ReleaseGas(uid, gasTank);
+                    ReleaseGas(gasTank);
                 }
 
-                if (gasTank.CheckUser)
+                if (comp.CheckUser)
                 {
-                    gasTank.CheckUser = false;
-                    if (Transform(uid).ParentUid != gasTank.User)
+                    comp.CheckUser = false;
+                    if (Transform(uid).ParentUid != comp.User)
                     {
                         DisconnectFromInternals(gasTank);
                         continue;
                     }
                 }
 
-                if (gasTank.Air != null)
+                if (comp.Air != null)
                 {
-                    _atmosphereSystem.React(gasTank.Air, gasTank);
+                    _atmosphereSystem.React(comp.Air, comp);
                 }
                 CheckStatus(gasTank);
                 if (_ui.IsUiOpen(uid, SharedGasTankUiKey.Key))
@@ -163,47 +170,48 @@ namespace Content.Server.Atmos.EntitySystems
             }
         }
 
-        private void ReleaseGas(EntityUid uid, GasTankComponent component)
+        private void ReleaseGas(Entity<GasTankComponent> gasTank)
         {
-            var removed = RemoveAirVolume(component, component.ValveOutputRate * TimerDelay);
-            var environment = _atmosphereSystem.GetContainingMixture(uid, false, true);
+            var removed = RemoveAirVolume(gasTank, gasTank.Comp.ValveOutputRate * TimerDelay);
+            var environment = _atmosphereSystem.GetContainingMixture(gasTank, false, true);
             if (environment != null)
             {
                 _atmosphereSystem.Merge(environment, removed);
             }
             var impulse = removed.TotalMoles * removed.Temperature;
-            _physics.ApplyLinearImpulse(uid, _random.NextAngle().ToWorldVec() * impulse);
-            _physics.ApplyAngularImpulse(uid, _random.NextFloat(-3f, 3f));
-            _audioSys.PlayPvs(component.RuptureSound, uid);
+            _physics.ApplyLinearImpulse(gasTank, _random.NextAngle().ToWorldVec() * impulse);
+            _physics.ApplyAngularImpulse(gasTank, _random.NextFloat(-3f, 3f));
+            _audioSys.PlayPvs(gasTank.Comp.RuptureSound, gasTank);
         }
 
-        private void ToggleInternals(GasTankComponent component)
+        private void ToggleInternals(Entity<GasTankComponent> ent)
         {
-            if (component.IsConnected)
+            if (ent.Comp.IsConnected)
             {
-                DisconnectFromInternals(component);
+                DisconnectFromInternals(ent);
             }
             else
             {
-                ConnectToInternals(component);
+                ConnectToInternals(ent);
             }
         }
 
-        public GasMixture? RemoveAir(GasTankComponent component, float amount)
+        public GasMixture? RemoveAir(Entity<GasTankComponent> gasTank, float amount)
         {
-            var gas = component.Air?.Remove(amount);
-            CheckStatus(component);
+            var gas = gasTank.Comp.Air?.Remove(amount);
+            CheckStatus(gasTank);
             return gas;
         }
 
-        public GasMixture RemoveAirVolume(GasTankComponent component, float volume)
+        public GasMixture RemoveAirVolume(Entity<GasTankComponent> gasTank, float volume)
         {
+            var component = gasTank.Comp;
             if (component.Air == null)
                 return new GasMixture(volume);
 
             var molesNeeded = component.OutputPressure * volume / (Atmospherics.R * component.Air.Temperature);
 
-            var air = RemoveAir(component, molesNeeded);
+            var air = RemoveAir(gasTank, molesNeeded);
 
             if (air != null)
                 air.Volume = volume;
@@ -215,12 +223,13 @@ namespace Content.Server.Atmos.EntitySystems
 
         public bool CanConnectToInternals(GasTankComponent component)
         {
-            var internals = GetInternalsComponent(component);
+            var internals = GetInternalsComponent(component, component.User);
             return internals != null && internals.BreathToolEntity != null && !component.IsValveOpen;
         }
 
-        public void ConnectToInternals(GasTankComponent component)
+        public void ConnectToInternals(Entity<GasTankComponent> ent)
         {
+            var (owner, component) = ent;
             if (component.IsConnected || !CanConnectToInternals(component))
                 return;
 
@@ -228,7 +237,7 @@ namespace Content.Server.Atmos.EntitySystems
             if (internals == null)
                 return;
 
-            if (_internals.TryConnectTank(internals, component.Owner))
+            if (_internals.TryConnectTank((internals.Owner, internals), owner))
                 component.User = internals.Owner;
 
             _actions.SetToggled(component.ToggleActionEntity, component.IsConnected);
@@ -240,13 +249,14 @@ namespace Content.Server.Atmos.EntitySystems
             component.ConnectStream?.Stop();
 
             if (component.ConnectSound != null)
-                component.ConnectStream = _audioSys.PlayPvs(component.ConnectSound, component.Owner);
+                component.ConnectStream = _audioSys.PlayPvs(component.ConnectSound, owner);
 
-            UpdateUserInterface(component);
+            UpdateUserInterface(ent);
         }
 
-        public void DisconnectFromInternals(GasTankComponent component)
+        public void DisconnectFromInternals(Entity<GasTankComponent> ent)
         {
+            var (owner, component) = ent;
             if (component.User == null)
                 return;
 
@@ -259,29 +269,30 @@ namespace Content.Server.Atmos.EntitySystems
             component.DisconnectStream?.Stop();
 
             if (component.DisconnectSound != null)
-                component.DisconnectStream = _audioSys.PlayPvs(component.DisconnectSound, component.Owner);
+                component.DisconnectStream = _audioSys.PlayPvs(component.DisconnectSound, owner);
 
-            UpdateUserInterface(component);
+            UpdateUserInterface(ent);
         }
 
         private InternalsComponent? GetInternalsComponent(GasTankComponent component, EntityUid? owner = null)
         {
             owner ??= component.User;
-            if (Deleted(component.Owner)) return null;
+            if (Deleted(component.Owner))return null;
             if (owner != null) return CompOrNull<InternalsComponent>(owner.Value);
             return _containers.TryGetContainingContainer(component.Owner, out var container)
                 ? CompOrNull<InternalsComponent>(container.Owner)
                 : null;
         }
 
-        public void AssumeAir(GasTankComponent component, GasMixture giver)
+        public void AssumeAir(Entity<GasTankComponent> ent, GasMixture giver)
         {
-            _atmosphereSystem.Merge(component.Air, giver);
-            CheckStatus(component);
+            _atmosphereSystem.Merge(ent.Comp.Air, giver);
+            CheckStatus(ent);
         }
 
-        public void CheckStatus(GasTankComponent component)
+        public void CheckStatus(Entity<GasTankComponent> ent)
         {
+            var (owner, component) = ent;
             if (component.Air == null)
                 return;
 
@@ -305,7 +316,7 @@ namespace Content.Server.Atmos.EntitySystems
                     range = GasTankComponent.MaxExplosionRange;
                 }
 
-                _explosions.TriggerExplosive(component.Owner, radius: range);
+                _explosions.TriggerExplosive(owner, radius: range);
 
                 return;
             }
@@ -314,13 +325,13 @@ namespace Content.Server.Atmos.EntitySystems
             {
                 if (component.Integrity <= 0)
                 {
-                    var environment = _atmosphereSystem.GetContainingMixture(component.Owner, false, true);
+                    var environment = _atmosphereSystem.GetContainingMixture(owner, false, true);
                     if(environment != null)
                         _atmosphereSystem.Merge(environment, component.Air);
 
-                    _audioSys.Play(component.RuptureSound, Filter.Pvs(component.Owner), Transform(component.Owner).Coordinates, true, AudioParams.Default.WithVariation(0.125f));
+                    _audioSys.Play(component.RuptureSound, Filter.Pvs(owner), Transform(owner).Coordinates, true, AudioParams.Default.WithVariation(0.125f));
 
-                    QueueDel(component.Owner);
+                    QueueDel(owner);
                     return;
                 }
 
@@ -332,7 +343,7 @@ namespace Content.Server.Atmos.EntitySystems
             {
                 if (component.Integrity <= 0)
                 {
-                    var environment = _atmosphereSystem.GetContainingMixture(component.Owner, false, true);
+                    var environment = _atmosphereSystem.GetContainingMixture(owner, false, true);
                     if (environment == null)
                         return;
 
index c7995f4ae6c684a91a48470bd9addd49f27c2b8e..efd67550ba1a9beb9c34b516221230172b389ae6 100644 (file)
@@ -1,8 +1,7 @@
-using System.Linq;
-using Content.Server.Atmos.Monitor.Components;
 using Content.Server.Atmos.EntitySystems;
-using Content.Server.Atmos.Piping.EntitySystems;
+using Content.Server.Atmos.Monitor.Components;
 using Content.Server.Atmos.Piping.Components;
+using Content.Server.Atmos.Piping.EntitySystems;
 using Content.Server.DeviceNetwork;
 using Content.Server.DeviceNetwork.Systems;
 using Content.Server.Power.Components;
@@ -87,7 +86,7 @@ public sealed class AtmosMonitorSystem : EntitySystem
         if (!HasComp<ApcPowerReceiverComponent>(uid)
             && TryComp<AtmosDeviceComponent>(uid, out var atmosDeviceComponent))
         {
-            _atmosDeviceSystem.LeaveAtmosphere(atmosDeviceComponent);
+            _atmosDeviceSystem.LeaveAtmosphere((uid, atmosDeviceComponent));
         }
     }
 
@@ -155,18 +154,18 @@ public sealed class AtmosMonitorSystem : EntitySystem
         }
     }
 
-    private void OnPowerChangedEvent(EntityUid uid, AtmosMonitorComponent component, ref PowerChangedEvent args)
+    private void OnPowerChangedEvent(Entity<AtmosMonitorComponent> ent, ref PowerChangedEvent args)
     {
-        if (TryComp<AtmosDeviceComponent>(uid, out var atmosDeviceComponent))
+        if (TryComp<AtmosDeviceComponent>(ent, out var atmosDeviceComponent))
         {
             if (!args.Powered)
             {
-                _atmosDeviceSystem.LeaveAtmosphere(atmosDeviceComponent);
+                _atmosDeviceSystem.LeaveAtmosphere((ent, atmosDeviceComponent));
             }
             else
             {
-                _atmosDeviceSystem.JoinAtmosphere(atmosDeviceComponent);
-                Alert(uid, component.LastAlarmState);
+                _atmosDeviceSystem.JoinAtmosphere((ent, atmosDeviceComponent));
+                Alert(ent, ent.Comp.LastAlarmState);
             }
         }
     }
@@ -305,12 +304,13 @@ public sealed class AtmosMonitorSystem : EntitySystem
     /// <param name="alarms">The alarms that caused this alarm state.</param>
     public void Alert(EntityUid uid, AtmosAlarmType state, HashSet<AtmosMonitorThresholdType>? alarms = null, AtmosMonitorComponent? monitor = null)
     {
-        if (!Resolve(uid, ref monitor)) return;
+        if (!Resolve(uid, ref monitor))
+            return;
 
         monitor.LastAlarmState = state;
         monitor.TrippedThresholds = alarms ?? monitor.TrippedThresholds;
 
-        BroadcastAlertPacket(monitor);
+        BroadcastAlertPacket((uid, monitor));
 
         // TODO: Central system that grabs *all* alarms from wired network
     }
@@ -336,11 +336,13 @@ public sealed class AtmosMonitorSystem : EntitySystem
     ///        is synced between monitors the moment a monitor sends out an alarm,
     ///        or if it is explicitly synced (see ResetAll/Sync).
     /// </remarks>
-    private void BroadcastAlertPacket(AtmosMonitorComponent monitor, TagComponent? tags = null)
+    private void BroadcastAlertPacket(Entity<AtmosMonitorComponent> ent, TagComponent? tags = null)
     {
-        if (!monitor.NetEnabled) return;
+        var (owner, monitor) = ent;
+        if (!monitor.NetEnabled)
+            return;
 
-        if (!Resolve(monitor.Owner, ref tags, false))
+        if (!Resolve(owner, ref tags, false))
         {
             return;
         }
@@ -355,7 +357,7 @@ public sealed class AtmosMonitorSystem : EntitySystem
 
         foreach (var addr in monitor.RegisteredDevices)
         {
-            _deviceNetSystem.QueuePacket(monitor.Owner, addr, payload);
+            _deviceNetSystem.QueuePacket(owner, addr, payload);
         }
     }
 
@@ -367,7 +369,8 @@ public sealed class AtmosMonitorSystem : EntitySystem
     /// <param name="gas">Gas, if applicable.</param>
     public void SetThreshold(EntityUid uid, AtmosMonitorThresholdType type, AtmosAlarmThreshold threshold, Gas? gas = null, AtmosMonitorComponent? monitor = null)
     {
-        if (!Resolve(uid, ref monitor)) return;
+        if (!Resolve(uid, ref monitor))
+            return;
 
         switch (type)
         {
@@ -378,7 +381,8 @@ public sealed class AtmosMonitorSystem : EntitySystem
                 monitor.TemperatureThreshold = threshold;
                 break;
             case AtmosMonitorThresholdType.Gas:
-                if (gas == null || monitor.GasThresholds == null) return;
+                if (gas == null || monitor.GasThresholds == null)
+                    return;
                 monitor.GasThresholds[(Gas) gas] = threshold;
                 break;
         }
index d2326b2b560a2463777370ad833958fb24f07271..9b37aaaf3e1016dbd83f5d99dc4660c1d9b1eb80 100644 (file)
@@ -79,12 +79,12 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
             gate.FlowRate = a*dV/tau + (1-a)*gate.FlowRate; // in L/sec
         }
 
-        private void OnExamined(EntityUid uid, GasPassiveGateComponent gate, ExaminedEvent args)
+        private void OnExamined(Entity<GasPassiveGateComponent> gate, ref ExaminedEvent args)
         {
-            if (!EntityManager.GetComponent<TransformComponent>(gate.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
+            if (!Comp<TransformComponent>(gate).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
                 return;
 
-            var str = Loc.GetString("gas-passive-gate-examined", ("flowRate", $"{gate.FlowRate:0.#}"));
+            var str = Loc.GetString("gas-passive-gate-examined", ("flowRate", $"{gate.Comp.FlowRate:0.#}"));
             args.PushMarkup(str);
         }
     }
index 26000d50cf57782be7cfb5224825a58bbf804037..359123aabf216244d37a77565097284ca1de6ea0 100644 (file)
@@ -1,5 +1,4 @@
 using Content.Server.Atmos.EntitySystems;
-using Content.Shared.Atmos.Piping;
 using Content.Server.Atmos.Piping.Binary.Components;
 using Content.Server.Atmos.Piping.Components;
 using Content.Server.Construction;
@@ -7,6 +6,7 @@ using Content.Server.NodeContainer;
 using Content.Server.NodeContainer.EntitySystems;
 using Content.Server.NodeContainer.Nodes;
 using Content.Shared.Atmos;
+using Content.Shared.Atmos.Piping;
 using Content.Shared.Audio;
 using Content.Shared.Examine;
 using JetBrains.Annotations;
@@ -38,12 +38,13 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
             UpdateAppearance(uid, comp);
         }
 
-        private void OnExamined(EntityUid uid, GasRecyclerComponent comp, ExaminedEvent args)
+        private void OnExamined(Entity<GasRecyclerComponent> ent, ref ExaminedEvent args)
         {
-            if (!EntityManager.GetComponent<TransformComponent>(comp.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
+            var comp = ent.Comp;
+            if (!EntityManager.GetComponent<TransformComponent>(ent).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
                 return;
 
-            if (!EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer)
+            if (!EntityManager.TryGetComponent(ent, out NodeContainerComponent? nodeContainer)
                 || !_nodeContainer.TryGetNode(nodeContainer, comp.InletName, out PipeNode? inlet)
                 || !_nodeContainer.TryGetNode(nodeContainer, comp.OutletName, out PipeNode? _))
             {
@@ -68,13 +69,14 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
             }
         }
 
-        private void OnUpdate(EntityUid uid, GasRecyclerComponent comp, AtmosDeviceUpdateEvent args)
+        private void OnUpdate(Entity<GasRecyclerComponent> ent, ref AtmosDeviceUpdateEvent args)
         {
-            if (!EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer)
+            var comp = ent.Comp;
+            if (!EntityManager.TryGetComponent(ent, out NodeContainerComponent? nodeContainer)
                 || !_nodeContainer.TryGetNode(nodeContainer, comp.InletName, out PipeNode? inlet)
                 || !_nodeContainer.TryGetNode(nodeContainer, comp.OutletName, out PipeNode? outlet))
             {
-                _ambientSoundSystem.SetAmbience(comp.Owner, false);
+                _ambientSoundSystem.SetAmbience(ent, false);
                 return;
             }
 
@@ -92,8 +94,8 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
             }
 
             _atmosphereSystem.Merge(outlet.Air, removed);
-            UpdateAppearance(uid, comp);
-            _ambientSoundSystem.SetAmbience(comp.Owner, true);
+            UpdateAppearance(ent, comp);
+            _ambientSoundSystem.SetAmbience(ent, true);
         }
 
         public float PassiveTransferVol(GasMixture inlet, GasMixture outlet)
index ceabee689db87d81b41396ae313ec9498b7c8ee1..914e732991127f51cd2f8859477b87299cbca04e 100644 (file)
@@ -7,7 +7,6 @@ using Content.Shared.Audio;
 using Content.Shared.Examine;
 using Content.Shared.Interaction;
 using JetBrains.Annotations;
-using Robust.Server.GameObjects;
 using Robust.Shared.Audio;
 using Robust.Shared.Player;
 
@@ -29,9 +28,10 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
             SubscribeLocalEvent<GasValveComponent, ExaminedEvent>(OnExamined);
         }
 
-        private void OnExamined(EntityUid uid, GasValveComponent valve, ExaminedEvent args)
+        private void OnExamined(Entity<GasValveComponent> ent, ref ExaminedEvent args)
         {
-            if (!Comp<TransformComponent>(valve.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
+            var valve = ent.Comp;
+            if (!Comp<TransformComponent>(ent).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
                 return;
 
             if (Loc.TryGetString("gas-valve-system-examined", out var str,
@@ -50,7 +50,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
         private void OnActivate(EntityUid uid, GasValveComponent component, ActivateInWorldEvent args)
         {
             Toggle(uid, component);
-            SoundSystem.Play(component.ValveSound.GetSound(), Filter.Pvs(component.Owner), component.Owner, AudioHelpers.WithVariation(0.25f));
+            SoundSystem.Play(component.ValveSound.GetSound(), Filter.Pvs(uid), uid, AudioHelpers.WithVariation(0.25f));
         }
 
         public void Set(EntityUid uid, GasValveComponent component, bool value)
@@ -60,7 +60,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
                 && _nodeContainer.TryGetNode(nodeContainer, component.InletName, out PipeNode? inlet)
                 && _nodeContainer.TryGetNode(nodeContainer, component.OutletName, out PipeNode? outlet))
             {
-                if (TryComp<AppearanceComponent>(component.Owner,out var appearance))
+                if (TryComp<AppearanceComponent>(uid, out var appearance))
                 {
                     _appearance.SetData(uid, FilterVisuals.Enabled, component.Open, appearance);
                 }
@@ -68,13 +68,13 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
                 {
                     inlet.AddAlwaysReachable(outlet);
                     outlet.AddAlwaysReachable(inlet);
-                    _ambientSoundSystem.SetAmbience(component.Owner, true);
+                    _ambientSoundSystem.SetAmbience(uid, true);
                 }
                 else
                 {
                     inlet.RemoveAlwaysReachable(outlet);
                     outlet.RemoveAlwaysReachable(inlet);
-                    _ambientSoundSystem.SetAmbience(component.Owner, false);
+                    _ambientSoundSystem.SetAmbience(uid, false);
                 }
             }
         }
index a3f5f2113f2ff5d055cd7880b8450b577d78d600..ee7cf37096812172856bfd0b82df3eb8ea2f4084 100644 (file)
@@ -11,10 +11,10 @@ namespace Content.Server.Atmos.Piping.EntitySystems
         [Dependency] private readonly IGameTiming _gameTiming = default!;
         [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
 
-        private float _timer = 0f;
+        private float _timer;
 
         // Set of atmos devices that are off-grid but have JoinSystem set.
-        private readonly HashSet<AtmosDeviceComponent> _joinedDevices = new();
+        private readonly HashSet<Entity<AtmosDeviceComponent>> _joinedDevices = new();
 
         public override void Initialize()
         {
@@ -27,9 +27,10 @@ namespace Content.Server.Atmos.Piping.EntitySystems
             SubscribeLocalEvent<AtmosDeviceComponent, AnchorStateChangedEvent>(OnDeviceAnchorChanged);
         }
 
-        public void JoinAtmosphere(AtmosDeviceComponent component)
+        public void JoinAtmosphere(Entity<AtmosDeviceComponent> ent)
         {
-            var transform = Transform(component.Owner);
+            var component = ent.Comp;
+            var transform = Transform(ent);
 
             if (component.RequireAnchored && !transform.Anchored)
                 return;
@@ -39,16 +40,17 @@ namespace Content.Server.Atmos.Piping.EntitySystems
 
             if (!onGrid && component.JoinSystem)
             {
-                _joinedDevices.Add(component);
+                _joinedDevices.Add(ent);
                 component.JoinedSystem = true;
             }
 
             component.LastProcess = _gameTiming.CurTime;
-            RaiseLocalEvent(component.Owner, new AtmosDeviceEnabledEvent(), false);
+            RaiseLocalEvent(ent, new AtmosDeviceEnabledEvent());
         }
 
-        public void LeaveAtmosphere(AtmosDeviceComponent component)
+        public void LeaveAtmosphere(Entity<AtmosDeviceComponent> ent)
         {
+            var component = ent.Comp;
             // Try to remove the component from an atmosphere, and if not
             if (component.JoinedGrid != null && !_atmosphereSystem.RemoveAtmosDevice(component.JoinedGrid.Value, component))
             {
@@ -59,45 +61,45 @@ namespace Content.Server.Atmos.Piping.EntitySystems
 
             if (component.JoinedSystem)
             {
-                _joinedDevices.Remove(component);
+                _joinedDevices.Remove(ent);
                 component.JoinedSystem = false;
             }
 
             component.LastProcess = TimeSpan.Zero;
-            RaiseLocalEvent(component.Owner, new AtmosDeviceDisabledEvent(), false);
+            RaiseLocalEvent(ent, new AtmosDeviceDisabledEvent());
         }
 
-        public void RejoinAtmosphere(AtmosDeviceComponent component)
+        public void RejoinAtmosphere(Entity<AtmosDeviceComponent> component)
         {
             LeaveAtmosphere(component);
             JoinAtmosphere(component);
         }
 
-        private void OnDeviceInitialize(EntityUid uid, AtmosDeviceComponent component, ComponentInit args)
+        private void OnDeviceInitialize(Entity<AtmosDeviceComponent> ent, ref ComponentInit args)
         {
-            JoinAtmosphere(component);
+            JoinAtmosphere(ent);
         }
 
-        private void OnDeviceShutdown(EntityUid uid, AtmosDeviceComponent component, ComponentShutdown args)
+        private void OnDeviceShutdown(Entity<AtmosDeviceComponent> ent, ref ComponentShutdown args)
         {
-            LeaveAtmosphere(component);
+            LeaveAtmosphere(ent);
         }
 
-        private void OnDeviceAnchorChanged(EntityUid uid, AtmosDeviceComponent component, ref AnchorStateChangedEvent args)
+        private void OnDeviceAnchorChanged(Entity<AtmosDeviceComponent> ent, ref AnchorStateChangedEvent args)
         {
             // Do nothing if the component doesn't require being anchored to function.
-            if (!component.RequireAnchored)
+            if (!ent.Comp.RequireAnchored)
                 return;
 
             if (args.Anchored)
-                JoinAtmosphere(component);
+                JoinAtmosphere(ent);
             else
-                LeaveAtmosphere(component);
+                LeaveAtmosphere(ent);
         }
 
-        private void OnDeviceParentChanged(EntityUid uid, AtmosDeviceComponent component, ref EntParentChangedMessage args)
+        private void OnDeviceParentChanged(Entity<AtmosDeviceComponent> ent, ref EntParentChangedMessage args)
         {
-            RejoinAtmosphere(component);
+            RejoinAtmosphere(ent);
         }
 
         /// <summary>
@@ -116,8 +118,8 @@ namespace Content.Server.Atmos.Piping.EntitySystems
             var time = _gameTiming.CurTime;
             foreach (var device in _joinedDevices)
             {
-                RaiseLocalEvent(device.Owner, new AtmosDeviceUpdateEvent(_atmosphereSystem.AtmosTime), false);
-                device.LastProcess = time;
+                RaiseLocalEvent(device, new AtmosDeviceUpdateEvent(_atmosphereSystem.AtmosTime));
+                device.Comp.LastProcess = time;
             }
         }
     }
index 9cdee72b68e35dfc49604fe57e740c96c341b52e..9853a17f829a9a185de04c4dd55aede5411dd236 100644 (file)
@@ -1,13 +1,10 @@
 using System.Diagnostics.CodeAnalysis;
-using Content.Server.Atmos.Components;
 using Content.Server.Atmos.EntitySystems;
 using Content.Server.Atmos.Piping.Components;
 using Content.Server.Atmos.Piping.Other.Components;
 using Content.Shared.Atmos;
 using JetBrains.Annotations;
 using Robust.Server.GameObjects;
-using Robust.Shared.GameObjects;
-using Robust.Shared.IoC;
 
 namespace Content.Server.Atmos.Piping.Other.EntitySystems
 {
@@ -24,9 +21,10 @@ namespace Content.Server.Atmos.Piping.Other.EntitySystems
             SubscribeLocalEvent<GasMinerComponent, AtmosDeviceUpdateEvent>(OnMinerUpdated);
         }
 
-        private void OnMinerUpdated(EntityUid uid, GasMinerComponent miner, AtmosDeviceUpdateEvent args)
+        private void OnMinerUpdated(Entity<GasMinerComponent> ent, ref AtmosDeviceUpdateEvent args)
         {
-            if (!CheckMinerOperation(miner, out var environment) || !miner.Enabled || !miner.SpawnGas.HasValue || miner.SpawnAmount <= 0f)
+            var miner = ent.Comp;
+            if (!CheckMinerOperation(ent, out var environment) || !miner.Enabled || !miner.SpawnGas.HasValue || miner.SpawnAmount <= 0f)
                 return;
 
             // Time to mine some gas.
@@ -37,9 +35,9 @@ namespace Content.Server.Atmos.Piping.Other.EntitySystems
             _atmosphereSystem.Merge(environment, merger);
         }
 
-        private bool CheckMinerOperation(GasMinerComponent miner, [NotNullWhen(true)] out GasMixture? environment)
+        private bool CheckMinerOperation(Entity<GasMinerComponent> ent, [NotNullWhen(true)] out GasMixture? environment)
         {
-            var uid = miner.Owner;
+            var (uid, miner) = ent;
             environment = _atmosphereSystem.GetContainingMixture(uid, true, true);
 
             var transform = Transform(uid);
index 9f41671bca41a9958be70596987cee17ee46c07d..69a0178a018b882bb2599f3d948f49de5391f4bd 100644 (file)
@@ -14,7 +14,6 @@ using Content.Shared.Interaction;
 using Content.Shared.Popups;
 using JetBrains.Annotations;
 using Robust.Server.GameObjects;
-using Robust.Shared.Player;
 
 namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
 {
@@ -60,16 +59,16 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
                 || !_nodeContainer.TryGetNode(nodeContainer, filter.OutletName, out PipeNode? outletNode)
                 || outletNode.Air.Pressure >= Atmospherics.MaxOutputPressure) // No need to transfer if target is full.
             {
-                _ambientSoundSystem.SetAmbience(filter.Owner, false);
+                _ambientSoundSystem.SetAmbience(uid, false);
                 return;
             }
 
             // We multiply the transfer rate in L/s by the seconds passed since the last process to get the liters.
-            var transferVol = (float)(filter.TransferRate * args.dt);
+            var transferVol = filter.TransferRate * args.dt;
 
             if (transferVol <= 0)
             {
-                _ambientSoundSystem.SetAmbience(filter.Owner, false);
+                _ambientSoundSystem.SetAmbience(uid, false);
                 return;
             }
 
@@ -84,7 +83,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
 
                 var target = filterNode.Air.Pressure < Atmospherics.MaxOutputPressure ? filterNode : inletNode;
                 _atmosphereSystem.Merge(target.Air, filteredOut);
-                _ambientSoundSystem.SetAmbience(filter.Owner, filteredOut.TotalMoles > 0f);
+                _ambientSoundSystem.SetAmbience(uid, filteredOut.TotalMoles > 0f);
             }
 
             _atmosphereSystem.Merge(outletNode.Air, removed);
@@ -95,7 +94,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
             filter.Enabled = false;
 
             UpdateAppearance(uid, filter);
-            _ambientSoundSystem.SetAmbience(filter.Owner, false);
+            _ambientSoundSystem.SetAmbience(uid, false);
 
             DirtyUI(uid, filter);
             _userInterfaceSystem.TryCloseAll(uid, GasFilterUiKey.Key);
@@ -106,7 +105,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
             if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
                 return;
 
-            if (EntityManager.GetComponent<TransformComponent>(filter.Owner).Anchored)
+            if (EntityManager.GetComponent<TransformComponent>(uid).Anchored)
             {
                 _userInterfaceSystem.TryOpen(uid, GasFilterUiKey.Key, actor.PlayerSession);
                 DirtyUI(uid, filter);
@@ -125,7 +124,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
                 return;
 
             _userInterfaceSystem.TrySetUiState(uid, GasFilterUiKey.Key,
-                new GasFilterBoundUserInterfaceState(EntityManager.GetComponent<MetaDataComponent>(filter.Owner).EntityName, filter.TransferRate, filter.Enabled, filter.FilteredGas));
+                new GasFilterBoundUserInterfaceState(MetaData(uid).EntityName, filter.TransferRate, filter.Enabled, filter.FilteredGas));
         }
 
         private void UpdateAppearance(EntityUid uid, GasFilterComponent? filter = null)
index cbb1b33eefb5818dd2466b5aadd2a11dd166ab34..ceea449a31212c4475ec46ebb5ec3a0cbbad9cdc 100644 (file)
@@ -7,7 +7,6 @@ using Content.Server.NodeContainer.Nodes;
 using Content.Shared.Atmos.Piping;
 using Content.Shared.Audio;
 using JetBrains.Annotations;
-using Robust.Server.GameObjects;
 
 namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
 {
@@ -40,7 +39,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
                 || !_nodeContainer.TryGetNode(nodeContainer, comp.ControlName, out PipeNode? controlNode)
                 || !_nodeContainer.TryGetNode(nodeContainer, comp.OutletName, out PipeNode? outletNode))
             {
-                _ambientSoundSystem.SetAmbience(comp.Owner, false);
+                _ambientSoundSystem.SetAmbience(uid, false);
                 comp.Enabled = false;
                 return;
             }
@@ -68,14 +67,14 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
             UpdateAppearance(uid, comp);
 
             // We multiply the transfer rate in L/s by the seconds passed since the last process to get the liters.
-            var transferVolume = (float)(transferRate * args.dt);
+            var transferVolume = transferRate * args.dt;
             if (transferVolume <= 0)
             {
-                _ambientSoundSystem.SetAmbience(comp.Owner, false);
+                _ambientSoundSystem.SetAmbience(uid, false);
                 return;
             }
 
-            _ambientSoundSystem.SetAmbience(comp.Owner, true);
+            _ambientSoundSystem.SetAmbience(uid, true);
             var removed = inletNode.Air.RemoveVolume(transferVolume);
             _atmosphereSystem.Merge(outletNode.Air, removed);
         }
@@ -84,7 +83,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
         {
             comp.Enabled = false;
             UpdateAppearance(uid, comp);
-            _ambientSoundSystem.SetAmbience(comp.Owner, false);
+            _ambientSoundSystem.SetAmbience(uid, false);
         }
 
         private void UpdateAppearance(EntityUid uid, PressureControlledValveComponent? comp = null, AppearanceComponent? appearance = null)
index 49241b43ddedbab03811e997e12ea5b8677410b4..adde584cc3907860901defe096d85dbc01ac81a2 100644 (file)
@@ -7,7 +7,6 @@ using Content.Server.NodeContainer.Nodes;
 using Content.Shared.Atmos.Piping;
 using Content.Shared.Interaction;
 using JetBrains.Annotations;
-using Robust.Server.GameObjects;
 
 namespace Content.Server.Atmos.Piping.Unary.EntitySystems
 {
@@ -40,7 +39,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
 
         public void UpdateAppearance(EntityUid uid, GasOutletInjectorComponent component, AppearanceComponent? appearance = null)
         {
-            if (!Resolve(component.Owner, ref appearance, false))
+            if (!Resolve(uid, ref appearance, false))
                 return;
 
             _appearance.SetData(uid, OutletInjectorVisuals.Enabled, component.Enabled, appearance);
index 12eda65f84e1d743053ef1200b1cdf6e4e1e780a..e7d1e3be3c394e1bfd54a19d0982e448f0221168 100644 (file)
@@ -57,14 +57,16 @@ namespace Content.Server.Bed
         {
             base.Update(frameTime);
 
-            foreach (var (_, bedComponent, strapComponent) in EntityQuery<HealOnBuckleHealingComponent, HealOnBuckleComponent, StrapComponent>())
+            var query = EntityQueryEnumerator<HealOnBuckleHealingComponent, HealOnBuckleComponent, StrapComponent>();
+            while (query.MoveNext(out var uid, out _, out var bedComponent, out var strapComponent))
             {
                 if (_timing.CurTime < bedComponent.NextHealTime)
                     continue;
 
                 bedComponent.NextHealTime += TimeSpan.FromSeconds(bedComponent.HealTime);
 
-                if (strapComponent.BuckledEntities.Count == 0) continue;
+                if (strapComponent.BuckledEntities.Count == 0)
+                    continue;
 
                 foreach (var healedEntity in strapComponent.BuckledEntities)
                 {
@@ -76,7 +78,7 @@ namespace Content.Server.Bed
                     if (HasComp<SleepingComponent>(healedEntity))
                         damage *= bedComponent.SleepMultiplier;
 
-                    _damageableSystem.TryChangeDamage(healedEntity, damage, true, origin: bedComponent.Owner);
+                    _damageableSystem.TryChangeDamage(healedEntity, damage, true, origin: uid);
                 }
             }
         }
index e2cdc8c7440a7acedf95e312e753117de96f725a..b3b41e2f32eca0b99a78e0615dd9dccdb91de685 100644 (file)
@@ -65,7 +65,8 @@ namespace Content.Server.Bible
             }
             _remQueue.Clear();
 
-            foreach (var (respawning, summonableComp) in EntityQuery<SummonableRespawningComponent, SummonableComponent>())
+            var query = EntityQueryEnumerator<SummonableRespawningComponent, SummonableComponent>();
+            while (query.MoveNext(out var uid, out var respawning, out var summonableComp))
             {
                 summonableComp.Accumulator += frameTime;
                 if (summonableComp.Accumulator < summonableComp.RespawnTime)
@@ -79,11 +80,11 @@ namespace Content.Server.Bible
                     summonableComp.Summon = null;
                 }
                 summonableComp.AlreadySummoned = false;
-                _popupSystem.PopupEntity(Loc.GetString("bible-summon-respawn-ready", ("book", summonableComp.Owner)), summonableComp.Owner, PopupType.Medium);
-                SoundSystem.Play("/Audio/Effects/radpulse9.ogg", Filter.Pvs(summonableComp.Owner), summonableComp.Owner, AudioParams.Default.WithVolume(-4f));
+                _popupSystem.PopupEntity(Loc.GetString("bible-summon-respawn-ready", ("book", uid)), uid, PopupType.Medium);
+                SoundSystem.Play("/Audio/Effects/radpulse9.ogg", Filter.Pvs(uid), uid, AudioParams.Default.WithVolume(-4f));
                 // Clean up the accumulator and respawn tracking component
                 summonableComp.Accumulator = 0;
-                _remQueue.Enqueue(respawning.Owner);
+                _remQueue.Enqueue(uid);
             }
         }
 
@@ -167,7 +168,7 @@ namespace Content.Server.Bible
                 {
                     if (!TryComp<TransformComponent>(args.User, out var userXform)) return;
 
-                    AttemptSummon(component, args.User, userXform);
+                    AttemptSummon((uid, component), args.User, userXform);
                 },
                 Text = Loc.GetString("bible-summon-verb"),
                 Priority = 2
@@ -183,9 +184,9 @@ namespace Content.Server.Bible
             args.AddAction(ref component.SummonActionEntity, component.SummonAction);
         }
 
-        private void OnSummon(EntityUid uid, SummonableComponent component, SummonActionEvent args)
+        private void OnSummon(Entity<SummonableComponent> ent, ref SummonActionEvent args)
         {
-            AttemptSummon(component, args.Performer, Transform(args.Performer));
+            AttemptSummon(ent, args.Performer, Transform(args.Performer));
         }
 
         /// <summary>
@@ -198,9 +199,9 @@ namespace Content.Server.Bible
                 return;
 
             var source = component.Source;
-            if (source != null && TryComp<SummonableComponent>(source, out var summonable))
+            if (source != null && HasComp<SummonableComponent>(source))
             {
-                _addQueue.Enqueue(summonable.Owner);
+                _addQueue.Enqueue(source.Value);
             }
         }
 
@@ -209,24 +210,26 @@ namespace Content.Server.Bible
         /// </summary>
         private void OnSpawned(EntityUid uid, FamiliarComponent component, GhostRoleSpawnerUsedEvent args)
         {
-            if (!TryComp<SummonableComponent>(Transform(args.Spawner).ParentUid, out var summonable))
+            var parent = Transform(args.Spawner).ParentUid;
+            if (!TryComp<SummonableComponent>(parent, out var summonable))
                 return;
 
-            component.Source = summonable.Owner;
+            component.Source = parent;
             summonable.Summon = uid;
         }
 
-        private void AttemptSummon(SummonableComponent component, EntityUid user, TransformComponent? position)
+        private void AttemptSummon(Entity<SummonableComponent> ent, EntityUid user, TransformComponent? position)
         {
+            var (uid, component) = ent;
             if (component.AlreadySummoned || component.SpecialItemPrototype == null)
                 return;
             if (component.RequiresBibleUser && !HasComp<BibleUserComponent>(user))
                 return;
             if (!Resolve(user, ref position))
                 return;
-            if (component.Deleted || Deleted(component.Owner))
+            if (component.Deleted || Deleted(uid))
                 return;
-            if (!_blocker.CanInteract(user, component.Owner))
+            if (!_blocker.CanInteract(user, uid))
                 return;
 
             // Make this familiar the component's summon
@@ -237,7 +240,7 @@ namespace Content.Server.Bible
             if (HasComp<GhostRoleMobSpawnerComponent>(familiar))
             {
                 _popupSystem.PopupEntity(Loc.GetString("bible-summon-requested"), user, PopupType.Medium);
-                Transform(familiar).AttachParent(component.Owner);
+                Transform(familiar).AttachParent(uid);
             }
             component.AlreadySummoned = true;
             _actionsSystem.RemoveAction(user, component.SummonActionEntity);
index f4e299fac93199062fd58c89f910b94a952110a5..6ad0631150a3d82918605912f20809688571b99a 100644 (file)
@@ -51,7 +51,7 @@ namespace Content.Server.Body.Commands
             var mechanismName = string.Join(" ", args).ToLowerInvariant();
             var bodySystem = entityManager.System<BodySystem>();
 
-            foreach (var organ in bodySystem.GetBodyOrgans(body.Owner, body))
+            foreach (var organ in bodySystem.GetBodyOrgans(attached, body))
             {
                 if (fac.GetComponentName(organ.Component.GetType()).ToLowerInvariant() == mechanismName)
                 {
index 3e8e2307e3d8c2a9f37d7ae5ff818778b186731d..ec4faa345cdde1966d0e66e2583273a35bcdc0d6 100644 (file)
@@ -81,7 +81,7 @@ public sealed class InternalsSystem : EntitySystem
             return;
         }
 
-        var tank = FindBestGasTank(uid ,internals);
+        var tank = FindBestGasTank(uidinternals);
 
         if (tank == null)
         {
@@ -95,7 +95,7 @@ public sealed class InternalsSystem : EntitySystem
             return;
         }
 
-        _gasTank.ConnectToInternals(tank);
+        _gasTank.ConnectToInternals(tank.Value);
     }
 
     private void StartToggleInternalsDoAfter(EntityUid user, EntityUid target, InternalsComponent internals)
@@ -139,34 +139,36 @@ public sealed class InternalsSystem : EntitySystem
         if (AreInternalsWorking(component))
         {
             var gasTank = Comp<GasTankComponent>(component.GasTankEntity!.Value);
-            args.Gas = _gasTank.RemoveAirVolume(gasTank, Atmospherics.BreathVolume);
+            args.Gas = _gasTank.RemoveAirVolume((component.GasTankEntity.Value, gasTank), Atmospherics.BreathVolume);
             // TODO: Should listen to gas tank updates instead I guess?
             _alerts.ShowAlert(uid, AlertType.Internals, GetSeverity(component));
         }
     }
-    public void DisconnectBreathTool(InternalsComponent component)
+    public void DisconnectBreathTool(Entity<InternalsComponent> ent)
     {
+        var (owner, component) = ent;
         var old = component.BreathToolEntity;
         component.BreathToolEntity = null;
 
         if (TryComp(old, out BreathToolComponent? breathTool) )
         {
             _atmos.DisconnectInternals(breathTool);
-            DisconnectTank(component);
+            DisconnectTank(ent);
         }
 
-        _alerts.ShowAlert(component.Owner, AlertType.Internals, GetSeverity(component));
+        _alerts.ShowAlert(owner, AlertType.Internals, GetSeverity(component));
     }
 
-    public void ConnectBreathTool(InternalsComponent component, EntityUid toolEntity)
+    public void ConnectBreathTool(Entity<InternalsComponent> ent, EntityUid toolEntity)
     {
+        var (owner, component) = ent;
         if (TryComp(component.BreathToolEntity, out BreathToolComponent? tool))
         {
             _atmos.DisconnectInternals(tool);
         }
 
         component.BreathToolEntity = toolEntity;
-        _alerts.ShowAlert(component.Owner, AlertType.Internals, GetSeverity(component));
+        _alerts.ShowAlert(owner, AlertType.Internals, GetSeverity(component));
     }
 
     public void DisconnectTank(InternalsComponent? component)
@@ -175,22 +177,23 @@ public sealed class InternalsSystem : EntitySystem
             return;
 
         if (TryComp(component.GasTankEntity, out GasTankComponent? tank))
-            _gasTank.DisconnectFromInternals(tank);
+            _gasTank.DisconnectFromInternals((component.GasTankEntity.Value, tank));
 
         component.GasTankEntity = null;
         _alerts.ShowAlert(component.Owner, AlertType.Internals, GetSeverity(component));
     }
 
-    public bool TryConnectTank(InternalsComponent component, EntityUid tankEntity)
+    public bool TryConnectTank(Entity<InternalsComponent> ent, EntityUid tankEntity)
     {
+        var component = ent.Comp;
         if (component.BreathToolEntity == null)
             return false;
 
         if (TryComp(component.GasTankEntity, out GasTankComponent? tank))
-            _gasTank.DisconnectFromInternals(tank);
+            _gasTank.DisconnectFromInternals((component.GasTankEntity.Value, tank));
 
         component.GasTankEntity = tankEntity;
-        _alerts.ShowAlert(component.Owner, AlertType.Internals, GetSeverity(component));
+        _alerts.ShowAlert(ent, AlertType.Internals, GetSeverity(component));
         return true;
     }
 
@@ -213,7 +216,7 @@ public sealed class InternalsSystem : EntitySystem
         return 1;
     }
 
-    public GasTankComponent? FindBestGasTank(EntityUid internalsOwner, InternalsComponent component)
+    public Entity<GasTankComponent>? FindBestGasTank(EntityUid internalsOwner, InternalsComponent component)
     {
         // Prioritise
         // 1. back equipped tanks
@@ -227,27 +230,27 @@ public sealed class InternalsSystem : EntitySystem
             TryComp<GasTankComponent>(backEntity, out var backGasTank) &&
             _gasTank.CanConnectToInternals(backGasTank))
         {
-            return backGasTank;
+            return (backEntity.Value, backGasTank);
         }
 
         if (_inventory.TryGetSlotEntity(internalsOwner, "suitstorage", out var entity, inventory, containerManager) &&
             TryComp<GasTankComponent>(entity, out var gasTank) &&
             _gasTank.CanConnectToInternals(gasTank))
         {
-            return gasTank;
+            return (entity.Value, gasTank);
         }
 
-        var tanks = new List<GasTankComponent>();
+        var tanks = new List<Entity<GasTankComponent>>();
 
         foreach (var hand in _hands.EnumerateHands(internalsOwner))
         {
             if (TryComp(hand.HeldEntity, out gasTank) && _gasTank.CanConnectToInternals(gasTank))
-                tanks.Add(gasTank);
+                tanks.Add((hand.HeldEntity.Value, gasTank));
         }
 
         if (tanks.Count > 0)
         {
-            tanks.Sort((x, y) => y.Air.TotalMoles.CompareTo(x.Air.TotalMoles));
+            tanks.Sort((x, y) => y.Comp.Air.TotalMoles.CompareTo(x.Comp.Air.TotalMoles));
             return tanks[0];
         }
 
@@ -258,12 +261,12 @@ public sealed class InternalsSystem : EntitySystem
             while (enumerator.MoveNext(out var container))
             {
                 if (TryComp(container.ContainedEntity, out gasTank) && _gasTank.CanConnectToInternals(gasTank))
-                    tanks.Add(gasTank);
+                    tanks.Add((container.ContainedEntity.Value, gasTank));
             }
 
             if (tanks.Count > 0)
             {
-                tanks.Sort((x, y) => y.Air.TotalMoles.CompareTo(x.Air.TotalMoles));
+                tanks.Sort((x, y) => y.Comp.Air.TotalMoles.CompareTo(x.Comp.Air.TotalMoles));
                 return tanks[0];
             }
         }
index a66efbac0891514b27f58f9789354ccf70293ecb..301cf1431167d2e4c59e96403765ee53467f403e 100644 (file)
@@ -37,7 +37,7 @@ public sealed class LungSystem : EntitySystem
         if (TryComp(args.Equipee, out InternalsComponent? internals))
         {
             component.ConnectedInternalsEntity = args.Equipee;
-            _internals.ConnectBreathTool(internals, uid);
+            _internals.ConnectBreathTool((args.Equipee, internals), uid);
         }
     }
 
index 5bde141b54a7d470befdb03b6ba49c9f02efb45f..58f803acdc6e140050d9b90569ef93b9998abe4c 100644 (file)
@@ -10,7 +10,6 @@ using Content.Shared.Damage;
 using Content.Shared.Database;
 using Content.Shared.Mobs.Systems;
 using JetBrains.Annotations;
-using Robust.Shared.Player;
 using Robust.Shared.Timing;
 
 namespace Content.Server.Body.Systems
@@ -41,10 +40,9 @@ namespace Content.Server.Body.Systems
         {
             base.Update(frameTime);
 
-            foreach (var (respirator, body) in EntityManager.EntityQuery<RespiratorComponent, BodyComponent>())
+            var query = EntityQueryEnumerator<RespiratorComponent, BodyComponent>();
+            while (query.MoveNext(out var uid, out var respirator, out var body))
             {
-                var uid = respirator.Owner;
-
                 if (_mobState.IsDead(uid))
                 {
                     continue;
@@ -55,7 +53,7 @@ namespace Content.Server.Body.Systems
                 if (respirator.AccumulatedFrametime < respirator.CycleDelay)
                     continue;
                 respirator.AccumulatedFrametime -= respirator.CycleDelay;
-                UpdateSaturation(respirator.Owner, -respirator.CycleDelay, respirator);
+                UpdateSaturation(uid, -respirator.CycleDelay, respirator);
 
                 if (!_mobState.IsIncapacitated(uid)) // cannot breathe in crit.
                 {
@@ -99,7 +97,7 @@ namespace Content.Server.Body.Systems
 
             // Inhale gas
             var ev = new InhaleLocationEvent();
-            RaiseLocalEvent(uid, ev, false);
+            RaiseLocalEvent(uid, ev);
 
             ev.Gas ??= _atmosSys.GetContainingMixture(uid, false, true);
 
index 1d793887eef48c62c6c3b076f5006f57116b3c20..5a3f6cf31a9aecb2aef553ea368ebd44431a030e 100644 (file)
@@ -20,7 +20,8 @@ namespace Content.Server.Body.Systems
 
         public override void Update(float frameTime)
         {
-            foreach (var (stomach, organ, sol)in EntityManager.EntityQuery<StomachComponent, OrganComponent, SolutionContainerManagerComponent>())
+            var query = EntityQueryEnumerator<StomachComponent, OrganComponent, SolutionContainerManagerComponent>();
+            while (query.MoveNext(out var uid, out var stomach, out var organ, out var sol))
             {
                 stomach.AccumulatedFrameTime += frameTime;
 
@@ -30,7 +31,7 @@ namespace Content.Server.Body.Systems
                 stomach.AccumulatedFrameTime -= stomach.UpdateInterval;
 
                 // Get our solutions
-                if (!_solutionContainerSystem.TryGetSolution(stomach.Owner, DefaultSolutionName,
+                if (!_solutionContainerSystem.TryGetSolution(uid, DefaultSolutionName,
                         out var stomachSolution, sol))
                     continue;
 
@@ -50,7 +51,7 @@ namespace Content.Server.Body.Systems
                             if (reagent.Quantity > delta.ReagentQuantity.Quantity)
                                 reagent = new(reagent.Reagent, delta.ReagentQuantity.Quantity);
 
-                            _solutionContainerSystem.RemoveReagent((stomach).Owner, stomachSolution, reagent);
+                            _solutionContainerSystem.RemoveReagent(uid, stomachSolution, reagent);
                             transferSolution.AddReagent(reagent);
                         }
 
index 9bfba759a21ace71d8aaeefd76b21f1e90afeab5..60d2e389da32b23ce248d1818484690e127078a4 100644 (file)
@@ -12,14 +12,15 @@ public sealed class ThermalRegulatorSystem : EntitySystem
 
     public override void Update(float frameTime)
     {
-        foreach (var regulator in EntityManager.EntityQuery<ThermalRegulatorComponent>())
+        var query = EntityQueryEnumerator<ThermalRegulatorComponent>();
+        while (query.MoveNext(out var uid, out var regulator))
         {
             regulator.AccumulatedFrametime += frameTime;
             if (regulator.AccumulatedFrametime < 1)
                 continue;
 
             regulator.AccumulatedFrametime -= 1;
-            ProcessThermalRegulation(regulator.Owner, regulator);
+            ProcessThermalRegulation(uid, regulator);
         }
     }
 
index b6cb0dedaf4c940e5386f0a72750730733e01488..a0639e3708cc1b7a66383b80e2859380f6a77c8d 100644 (file)
@@ -3,7 +3,6 @@ using Content.Server.Kitchen.Components;
 using Content.Shared.Hands.EntitySystems;
 using Content.Shared.Interaction;
 using Content.Shared.Random;
-using Content.Shared.Random.Helpers;
 using Robust.Shared.Containers;
 
 namespace Content.Server.Botany.Systems;
@@ -39,7 +38,7 @@ public sealed class LogSystem : EntitySystem
             else
             {
                 var xform = Transform(plank);
-                _containerSystem.AttachParentToContainerOrGrid(xform);
+                _containerSystem.AttachParentToContainerOrGrid((plank, xform));
                 xform.LocalRotation = 0;
                 _randomHelper.RandomOffset(plank, 0.25f);
             }
index c3d57c4ad8537d5e83e710c3f1884cfdbdfa11b5..9991edd230e6dad754837a55d78c922bb03d91f6 100644 (file)
@@ -58,13 +58,14 @@ public sealed class PlantHolderSystem : EntitySystem
     {
         base.Update(frameTime);
 
-        foreach (var plantHolder in EntityQuery<PlantHolderComponent>())
+        var query = EntityQueryEnumerator<PlantHolderComponent>();
+        while (query.MoveNext(out var uid, out var plantHolder))
         {
             if (plantHolder.NextUpdate > _gameTiming.CurTime)
                 continue;
             plantHolder.NextUpdate = _gameTiming.CurTime + plantHolder.UpdateDelay;
 
-            Update(plantHolder.Owner, plantHolder);
+            Update(uid, plantHolder);
         }
     }
 
index 9ea054b62832430319375754a388eabcfdbf18cf..d9327b51505c152c24d4938cd2b13890ccc1aea4 100644 (file)
@@ -1,14 +1,12 @@
 using System.Diagnostics.CodeAnalysis;
 using Content.Server.Cargo.Components;
 using Content.Server.Labels.Components;
+using Content.Server.Paper;
 using Content.Shared.Cargo;
 using Content.Shared.Cargo.BUI;
 using Content.Shared.Cargo.Events;
 using Content.Shared.Cargo.Prototypes;
 using Content.Shared.Database;
-using Content.Shared.GameTicking;
-using Content.Server.Paper;
-using Robust.Server.GameObjects;
 using Robust.Shared.Map;
 using Robust.Shared.Players;
 using Robust.Shared.Prototypes;
@@ -146,7 +144,8 @@ namespace Content.Server.Cargo.Systems
             }
 
             _idCardSystem.TryFindIdCard(player, out var idCard);
-            order.SetApproverData(idCard?.FullName, idCard?.JobTitle);
+            // ReSharper disable once ConditionalAccessQualifierIsNonNullableAccordingToAPIContract
+            order.SetApproverData(idCard.Comp?.FullName, idCard.Comp?.JobTitle);
             _audio.PlayPvs(_audio.GetSound(component.ConfirmSound), uid);
 
             // Log order approval
index 289f383d29cfef27cd01337313e1e6ed5ee29858..509e99a28aacdbf66f13d3d8fdf0353be5bc6604 100644 (file)
@@ -13,6 +13,7 @@ using Content.Shared.Stacks;
 using Robust.Shared.Console;
 using Robust.Shared.Containers;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Utility;
 
@@ -57,7 +58,7 @@ public sealed class PricingSystem : EntitySystem
                 continue;
             }
 
-            if (!_mapManager.TryGetGrid(gridId, out var mapGrid))
+            if (!TryComp(gridId, out MapGridComponent? mapGrid))
             {
                 shell.WriteError($"Grid \"{gridId}\" doesn't exist.");
                 continue;
@@ -65,7 +66,7 @@ public sealed class PricingSystem : EntitySystem
 
             List<(double, EntityUid)> mostValuable = new();
 
-            var value = AppraiseGrid(mapGrid.Owner, null, (uid, price) =>
+            var value = AppraiseGrid(gridId.Value, null, (uid, price) =>
             {
                 mostValuable.Add((price, uid));
                 mostValuable.Sort((i1, i2) => i2.Item1.CompareTo(i1.Item1));
index d8d7f952d5035da77dd06e0901cf26c6f708282e..3d6bd5354011c5d8209a5eed6cbaa9af53169f51 100644 (file)
@@ -1,5 +1,3 @@
-namespace Content.Server.Chat.Systems;
-
 using System.Linq;
 using Content.Shared.Chat.Prototypes;
 using Robust.Shared.Prototypes;
@@ -7,6 +5,8 @@ using Robust.Shared.Random;
 using Robust.Shared.Timing;
 using Robust.Shared.Utility;
 
+namespace Content.Server.Chat.Systems;
+
 public sealed class AutoEmoteSystem : EntitySystem
 {
     [Dependency] private readonly IGameTiming _gameTiming = default!;
@@ -27,14 +27,13 @@ public sealed class AutoEmoteSystem : EntitySystem
         base.Update(frameTime);
 
         var curTime = _gameTiming.CurTime;
-        foreach (var autoEmote in EntityQuery<AutoEmoteComponent>())
+        var query = EntityQueryEnumerator<AutoEmoteComponent>();
+        while (query.MoveNext(out var uid, out var autoEmote))
         {
-            var uid = autoEmote.Owner;
-
             if (autoEmote.NextEmoteTime > curTime)
                 continue;
 
-            foreach ((var key, var time) in autoEmote.EmoteTimers)
+            foreach (var (key, time) in autoEmote.EmoteTimers)
             {
                 if (time > curTime)
                     continue;
index c22e36c993c179a73a9b03cd69ff1de2aded3589..a831165e688eecea6c26bd77b9d9b7b147c4e8a9 100644 (file)
@@ -45,11 +45,11 @@ namespace Content.Server.Chemistry.EntitySystems
         {
             base.Initialize();
 
-            SubscribeLocalEvent<ChemMasterComponent, ComponentStartup>((_, comp, _) => UpdateUiState(comp));
-            SubscribeLocalEvent<ChemMasterComponent, SolutionChangedEvent>((_, comp, _) => UpdateUiState(comp));
-            SubscribeLocalEvent<ChemMasterComponent, EntInsertedIntoContainerMessage>((_, comp, _) => UpdateUiState(comp));
-            SubscribeLocalEvent<ChemMasterComponent, EntRemovedFromContainerMessage>((_, comp, _) => UpdateUiState(comp));
-            SubscribeLocalEvent<ChemMasterComponent, BoundUIOpenedEvent>((_, comp, _) => UpdateUiState(comp));
+            SubscribeLocalEvent<ChemMasterComponent, ComponentStartup>(SubscribeUpdateUiState);
+            SubscribeLocalEvent<ChemMasterComponent, SolutionChangedEvent>(SubscribeUpdateUiState);
+            SubscribeLocalEvent<ChemMasterComponent, EntInsertedIntoContainerMessage>(SubscribeUpdateUiState);
+            SubscribeLocalEvent<ChemMasterComponent, EntRemovedFromContainerMessage>(SubscribeUpdateUiState);
+            SubscribeLocalEvent<ChemMasterComponent, BoundUIOpenedEvent>(SubscribeUpdateUiState);
 
             SubscribeLocalEvent<ChemMasterComponent, ChemMasterSetModeMessage>(OnSetModeMessage);
             SubscribeLocalEvent<ChemMasterComponent, ChemMasterSetPillTypeMessage>(OnSetPillTypeMessage);
@@ -58,12 +58,18 @@ namespace Content.Server.Chemistry.EntitySystems
             SubscribeLocalEvent<ChemMasterComponent, ChemMasterOutputToBottleMessage>(OnOutputToBottleMessage);
         }
 
-        private void UpdateUiState(ChemMasterComponent chemMaster, bool updateLabel = false)
+        private void SubscribeUpdateUiState<T>(Entity<ChemMasterComponent> ent, ref T ev)
         {
-            if (!_solutionContainerSystem.TryGetSolution(chemMaster.Owner, SharedChemMaster.BufferSolutionName, out var bufferSolution))
+            UpdateUiState(ent);
+        }
+
+        private void UpdateUiState(Entity<ChemMasterComponent> ent, bool updateLabel = false)
+        {
+            var (owner, chemMaster) = ent;
+            if (!_solutionContainerSystem.TryGetSolution(owner, SharedChemMaster.BufferSolutionName, out var bufferSolution))
                 return;
-            var inputContainer = _itemSlotsSystem.GetItemOrNull(chemMaster.Owner, SharedChemMaster.InputSlotName);
-            var outputContainer = _itemSlotsSystem.GetItemOrNull(chemMaster.Owner, SharedChemMaster.OutputSlotName);
+            var inputContainer = _itemSlotsSystem.GetItemOrNull(owner, SharedChemMaster.InputSlotName);
+            var outputContainer = _itemSlotsSystem.GetItemOrNull(owner, SharedChemMaster.OutputSlotName);
 
             var bufferReagents = bufferSolution.Contents;
             var bufferCurrentVolume = bufferSolution.Volume;
@@ -72,38 +78,38 @@ namespace Content.Server.Chemistry.EntitySystems
                 chemMaster.Mode, BuildInputContainerInfo(inputContainer), BuildOutputContainerInfo(outputContainer),
                 bufferReagents, bufferCurrentVolume, chemMaster.PillType, chemMaster.PillDosageLimit, updateLabel);
 
-            _userInterfaceSystem.TrySetUiState(chemMaster.Owner, ChemMasterUiKey.Key, state);
+            _userInterfaceSystem.TrySetUiState(owner, ChemMasterUiKey.Key, state);
         }
 
-        private void OnSetModeMessage(EntityUid uid, ChemMasterComponent chemMaster, ChemMasterSetModeMessage message)
+        private void OnSetModeMessage(Entity<ChemMasterComponent> chemMaster, ref ChemMasterSetModeMessage message)
         {
             // Ensure the mode is valid, either Transfer or Discard.
             if (!Enum.IsDefined(typeof(ChemMasterMode), message.ChemMasterMode))
                 return;
 
-            chemMaster.Mode = message.ChemMasterMode;
+            chemMaster.Comp.Mode = message.ChemMasterMode;
             UpdateUiState(chemMaster);
             ClickSound(chemMaster);
         }
 
-        private void OnSetPillTypeMessage(EntityUid uid, ChemMasterComponent chemMaster, ChemMasterSetPillTypeMessage message)
+        private void OnSetPillTypeMessage(Entity<ChemMasterComponent> chemMaster, ref ChemMasterSetPillTypeMessage message)
         {
             // Ensure valid pill type. There are 20 pills selectable, 0-19.
             if (message.PillType > SharedChemMaster.PillTypes - 1)
                 return;
 
-            chemMaster.PillType = message.PillType;
+            chemMaster.Comp.PillType = message.PillType;
             UpdateUiState(chemMaster);
             ClickSound(chemMaster);
         }
 
-        private void OnReagentButtonMessage(EntityUid uid, ChemMasterComponent chemMaster, ChemMasterReagentAmountButtonMessage message)
+        private void OnReagentButtonMessage(Entity<ChemMasterComponent> chemMaster, ref ChemMasterReagentAmountButtonMessage message)
         {
             // Ensure the amount corresponds to one of the reagent amount buttons.
             if (!Enum.IsDefined(typeof(ChemMasterReagentAmount), message.Amount))
                 return;
 
-            switch (chemMaster.Mode)
+            switch (chemMaster.Comp.Mode)
             {
                 case ChemMasterMode.Transfer:
                     TransferReagents(chemMaster, message.ReagentId, message.Amount.GetFixedPoint(), message.FromBuffer);
@@ -119,12 +125,12 @@ namespace Content.Server.Chemistry.EntitySystems
             ClickSound(chemMaster);
         }
 
-        private void TransferReagents(ChemMasterComponent chemMaster, ReagentId id, FixedPoint2 amount, bool fromBuffer)
+        private void TransferReagents(Entity<ChemMasterComponent> chemMaster, ReagentId id, FixedPoint2 amount, bool fromBuffer)
         {
-            var container = _itemSlotsSystem.GetItemOrNull(chemMaster.Owner, SharedChemMaster.InputSlotName);
+            var container = _itemSlotsSystem.GetItemOrNull(chemMaster, SharedChemMaster.InputSlotName);
             if (container is null ||
                 !_solutionContainerSystem.TryGetFitsInDispenser(container.Value, out var containerSolution) ||
-                !_solutionContainerSystem.TryGetSolution(chemMaster.Owner, SharedChemMaster.BufferSolutionName, out var bufferSolution))
+                !_solutionContainerSystem.TryGetSolution(chemMaster, SharedChemMaster.BufferSolutionName, out var bufferSolution))
             {
                 return;
             }
@@ -145,19 +151,18 @@ namespace Content.Server.Chemistry.EntitySystems
             UpdateUiState(chemMaster, updateLabel: true);
         }
 
-        private void DiscardReagents(ChemMasterComponent chemMaster, ReagentId id, FixedPoint2 amount, bool fromBuffer)
+        private void DiscardReagents(Entity<ChemMasterComponent> chemMaster, ReagentId id, FixedPoint2 amount, bool fromBuffer)
         {
-
             if (fromBuffer)
             {
-                if (_solutionContainerSystem.TryGetSolution(chemMaster.Owner, SharedChemMaster.BufferSolutionName, out var bufferSolution))
+                if (_solutionContainerSystem.TryGetSolution(chemMaster, SharedChemMaster.BufferSolutionName, out var bufferSolution))
                     bufferSolution.RemoveReagent(id, amount);
                 else
                     return;
             }
             else
             {
-                var container = _itemSlotsSystem.GetItemOrNull(chemMaster.Owner, SharedChemMaster.InputSlotName);
+                var container = _itemSlotsSystem.GetItemOrNull(chemMaster, SharedChemMaster.InputSlotName);
                 if (container is not null &&
                     _solutionContainerSystem.TryGetFitsInDispenser(container.Value, out var containerSolution))
                 {
@@ -170,10 +175,10 @@ namespace Content.Server.Chemistry.EntitySystems
             UpdateUiState(chemMaster, updateLabel: fromBuffer);
         }
 
-        private void OnCreatePillsMessage(EntityUid uid, ChemMasterComponent chemMaster, ChemMasterCreatePillsMessage message)
+        private void OnCreatePillsMessage(Entity<ChemMasterComponent> chemMaster, ref ChemMasterCreatePillsMessage message)
         {
             var user = message.Session.AttachedEntity;
-            var maybeContainer = _itemSlotsSystem.GetItemOrNull(chemMaster.Owner, SharedChemMaster.OutputSlotName);
+            var maybeContainer = _itemSlotsSystem.GetItemOrNull(chemMaster, SharedChemMaster.OutputSlotName);
             if (maybeContainer is not { Valid: true } container
                 || !TryComp(container, out StorageComponent? storage)
                 || storage.Container is null)
@@ -186,7 +191,7 @@ namespace Content.Server.Chemistry.EntitySystems
                 return;
 
             // Ensure the amount is valid.
-            if (message.Dosage == 0 || message.Dosage > chemMaster.PillDosageLimit)
+            if (message.Dosage == 0 || message.Dosage > chemMaster.Comp.PillDosageLimit)
                 return;
 
             // Ensure label length is within the character limit.
@@ -211,8 +216,8 @@ namespace Content.Server.Chemistry.EntitySystems
                     item, itemSolution, withdrawal.SplitSolution(message.Dosage));
 
                 var pill = EnsureComp<PillComponent>(item);
-                pill.PillType = chemMaster.PillType;
-                Dirty(pill);
+                pill.PillType = chemMaster.Comp.PillType;
+                Dirty(item, pill);
 
                 if (user.HasValue)
                 {
@@ -232,11 +237,10 @@ namespace Content.Server.Chemistry.EntitySystems
             ClickSound(chemMaster);
         }
 
-        private void OnOutputToBottleMessage(
-            EntityUid uid, ChemMasterComponent chemMaster, ChemMasterOutputToBottleMessage message)
+        private void OnOutputToBottleMessage(Entity<ChemMasterComponent> chemMaster, ref ChemMasterOutputToBottleMessage message)
         {
             var user = message.Session.AttachedEntity;
-            var maybeContainer = _itemSlotsSystem.GetItemOrNull(chemMaster.Owner, SharedChemMaster.OutputSlotName);
+            var maybeContainer = _itemSlotsSystem.GetItemOrNull(chemMaster, SharedChemMaster.OutputSlotName);
             if (maybeContainer is not { Valid: true } container
                 || !_solutionContainerSystem.TryGetSolution(
                     container, SharedChemMaster.BottleSolutionName, out var solution))
@@ -277,14 +281,14 @@ namespace Content.Server.Chemistry.EntitySystems
         }
 
         private bool WithdrawFromBuffer(
-            IComponent chemMaster,
+            Entity<ChemMasterComponent> chemMaster,
             FixedPoint2 neededVolume, EntityUid? user,
             [NotNullWhen(returnValue: true)] out Solution? outputSolution)
         {
             outputSolution = null;
 
             if (!_solutionContainerSystem.TryGetSolution(
-                    chemMaster.Owner, SharedChemMaster.BufferSolutionName, out var solution))
+                    chemMaster, SharedChemMaster.BufferSolutionName, out var solution))
             {
                 return false;
             }
@@ -308,9 +312,9 @@ namespace Content.Server.Chemistry.EntitySystems
             return true;
         }
 
-        private void ClickSound(ChemMasterComponent chemMaster)
+        private void ClickSound(Entity<ChemMasterComponent> chemMaster)
         {
-            _audioSystem.PlayPvs(chemMaster.ClickSound, chemMaster.Owner, AudioParams.Default.WithVolume(-2f));
+            _audioSystem.PlayPvs(chemMaster.Comp.ClickSound, chemMaster, AudioParams.Default.WithVolume(-2f));
         }
 
         private ContainerInfo? BuildInputContainerInfo(EntityUid? container)
index ee3b038acc93aac3dd631dcbad1e297ded3e9945..daa2ac80b7de14cca7fbfb7e1109d665d622c098 100644 (file)
@@ -34,11 +34,11 @@ namespace Content.Server.Chemistry.EntitySystems
         {
             base.Initialize();
 
-            SubscribeLocalEvent<ReagentDispenserComponent, ComponentStartup>((_, comp, _) => UpdateUiState(comp));
-            SubscribeLocalEvent<ReagentDispenserComponent, SolutionChangedEvent>((_, comp, _) => UpdateUiState(comp));
-            SubscribeLocalEvent<ReagentDispenserComponent, EntInsertedIntoContainerMessage>((_, comp, _) => UpdateUiState(comp));
-            SubscribeLocalEvent<ReagentDispenserComponent, EntRemovedFromContainerMessage>((_, comp, _) => UpdateUiState(comp));
-            SubscribeLocalEvent<ReagentDispenserComponent, BoundUIOpenedEvent>((_, comp, _) => UpdateUiState(comp));
+            SubscribeLocalEvent<ReagentDispenserComponent, ComponentStartup>(SubscribeUpdateUiState);
+            SubscribeLocalEvent<ReagentDispenserComponent, SolutionChangedEvent>(SubscribeUpdateUiState);
+            SubscribeLocalEvent<ReagentDispenserComponent, EntInsertedIntoContainerMessage>(SubscribeUpdateUiState);
+            SubscribeLocalEvent<ReagentDispenserComponent, EntRemovedFromContainerMessage>(SubscribeUpdateUiState);
+            SubscribeLocalEvent<ReagentDispenserComponent, BoundUIOpenedEvent>(SubscribeUpdateUiState);
             SubscribeLocalEvent<ReagentDispenserComponent, GotEmaggedEvent>(OnEmagged);
 
             SubscribeLocalEvent<ReagentDispenserComponent, ReagentDispenserSetDispenseAmountMessage>(OnSetDispenseAmountMessage);
@@ -46,15 +46,20 @@ namespace Content.Server.Chemistry.EntitySystems
             SubscribeLocalEvent<ReagentDispenserComponent, ReagentDispenserClearContainerSolutionMessage>(OnClearContainerSolutionMessage);
         }
 
-        private void UpdateUiState(ReagentDispenserComponent reagentDispenser)
+        private void SubscribeUpdateUiState<T>(Entity<ReagentDispenserComponent> ent, ref T ev)
         {
-            var outputContainer = _itemSlotsSystem.GetItemOrNull(reagentDispenser.Owner, SharedReagentDispenser.OutputSlotName);
+            UpdateUiState(ent);
+        }
+
+        private void UpdateUiState(Entity<ReagentDispenserComponent> reagentDispenser)
+        {
+            var outputContainer = _itemSlotsSystem.GetItemOrNull(reagentDispenser, SharedReagentDispenser.OutputSlotName);
             var outputContainerInfo = BuildOutputContainerInfo(outputContainer);
 
             var inventory = GetInventory(reagentDispenser);
 
-            var state = new ReagentDispenserBoundUserInterfaceState(outputContainerInfo, inventory, reagentDispenser.DispenseAmount);
-            _userInterfaceSystem.TrySetUiState(reagentDispenser.Owner, ReagentDispenserUiKey.Key, state);
+            var state = new ReagentDispenserBoundUserInterfaceState(outputContainerInfo, inventory, reagentDispenser.Comp.DispenseAmount);
+            _userInterfaceSystem.TrySetUiState(reagentDispenser, ReagentDispenserUiKey.Key, state);
         }
 
         private ContainerInfo? BuildOutputContainerInfo(EntityUid? container)
@@ -73,8 +78,9 @@ namespace Content.Server.Chemistry.EntitySystems
             return null;
         }
 
-        private List<ReagentId> GetInventory(ReagentDispenserComponent reagentDispenser)
+        private List<ReagentId> GetInventory(Entity<ReagentDispenserComponent> ent)
         {
+            var reagentDispenser = ent.Comp;
             var inventory = new List<ReagentId>();
 
             if (reagentDispenser.PackPrototypeId is not null
@@ -83,7 +89,7 @@ namespace Content.Server.Chemistry.EntitySystems
                 inventory.AddRange(packPrototype.Inventory.Select(x => new ReagentId(x, null)));
             }
 
-            if (HasComp<EmaggedComponent>(reagentDispenser.Owner)
+            if (HasComp<EmaggedComponent>(ent)
                 && reagentDispenser.EmagPackPrototypeId is not null
                 && _prototypeManager.TryIndex(reagentDispenser.EmagPackPrototypeId, out ReagentDispenserInventoryPrototype? emagPackPrototype))
             {
@@ -93,32 +99,32 @@ namespace Content.Server.Chemistry.EntitySystems
             return inventory;
         }
 
-        private void OnEmagged(EntityUid uid, ReagentDispenserComponent reagentDispenser, ref GotEmaggedEvent args)
+        private void OnEmagged(Entity<ReagentDispenserComponent> reagentDispenser, ref GotEmaggedEvent args)
         {
             // adding component manually to have correct state
-            EntityManager.AddComponent<EmaggedComponent>(uid);
+            EntityManager.AddComponent<EmaggedComponent>(reagentDispenser);
             UpdateUiState(reagentDispenser);
             args.Handled = true;
         }
 
-        private void OnSetDispenseAmountMessage(EntityUid uid, ReagentDispenserComponent reagentDispenser, ReagentDispenserSetDispenseAmountMessage message)
+        private void OnSetDispenseAmountMessage(Entity<ReagentDispenserComponent> reagentDispenser, ref ReagentDispenserSetDispenseAmountMessage message)
         {
-            reagentDispenser.DispenseAmount = message.ReagentDispenserDispenseAmount;
+            reagentDispenser.Comp.DispenseAmount = message.ReagentDispenserDispenseAmount;
             UpdateUiState(reagentDispenser);
             ClickSound(reagentDispenser);
         }
 
-        private void OnDispenseReagentMessage(EntityUid uid, ReagentDispenserComponent reagentDispenser, ReagentDispenserDispenseReagentMessage message)
+        private void OnDispenseReagentMessage(Entity<ReagentDispenserComponent> reagentDispenser, ref ReagentDispenserDispenseReagentMessage message)
         {
             // Ensure that the reagent is something this reagent dispenser can dispense.
             if (!GetInventory(reagentDispenser).Contains(message.ReagentId))
                 return;
 
-            var outputContainer = _itemSlotsSystem.GetItemOrNull(reagentDispenser.Owner, SharedReagentDispenser.OutputSlotName);
+            var outputContainer = _itemSlotsSystem.GetItemOrNull(reagentDispenser, SharedReagentDispenser.OutputSlotName);
             if (outputContainer is not {Valid: true} || !_solutionContainerSystem.TryGetFitsInDispenser(outputContainer.Value, out var solution))
                 return;
 
-            if (_solutionContainerSystem.TryAddReagent(outputContainer.Value, solution, message.ReagentId, (int)reagentDispenser.DispenseAmount, out var dispensedAmount)
+            if (_solutionContainerSystem.TryAddReagent(outputContainer.Value, solution, message.ReagentId, (int)reagentDispenser.Comp.DispenseAmount, out var dispensedAmount)
                 && message.Session.AttachedEntity is not null)
             {
                 _adminLogger.Add(LogType.ChemicalReaction, LogImpact.Medium,
@@ -129,9 +135,9 @@ namespace Content.Server.Chemistry.EntitySystems
             ClickSound(reagentDispenser);
         }
 
-        private void OnClearContainerSolutionMessage(EntityUid uid, ReagentDispenserComponent reagentDispenser, ReagentDispenserClearContainerSolutionMessage message)
+        private void OnClearContainerSolutionMessage(Entity<ReagentDispenserComponent> reagentDispenser, ref ReagentDispenserClearContainerSolutionMessage message)
         {
-            var outputContainer = _itemSlotsSystem.GetItemOrNull(reagentDispenser.Owner, SharedReagentDispenser.OutputSlotName);
+            var outputContainer = _itemSlotsSystem.GetItemOrNull(reagentDispenser, SharedReagentDispenser.OutputSlotName);
             if (outputContainer is not {Valid: true} || !_solutionContainerSystem.TryGetFitsInDispenser(outputContainer.Value, out var solution))
                 return;
 
@@ -140,9 +146,9 @@ namespace Content.Server.Chemistry.EntitySystems
             ClickSound(reagentDispenser);
         }
 
-        private void ClickSound(ReagentDispenserComponent reagentDispenser)
+        private void ClickSound(Entity<ReagentDispenserComponent> reagentDispenser)
         {
-            _audioSystem.PlayPvs(reagentDispenser.ClickSound, reagentDispenser.Owner, AudioParams.Default.WithVolume(-2f));
+            _audioSystem.PlayPvs(reagentDispenser.Comp.ClickSound, reagentDispenser, AudioParams.Default.WithVolume(-2f));
         }
     }
 }
index 20d9246739d794344f0408f8d958fa234b6ad408..dcfc57a9b252639847273e629059127808da7543 100644 (file)
@@ -1,15 +1,12 @@
 using Content.Server.Body.Components;
 using Content.Server.Body.Systems;
 using Content.Server.Chemistry.Components;
-using Content.Shared.Chemistry.Components.SolutionManager;
 using Content.Shared.Chemistry.EntitySystems;
 using Content.Shared.Inventory;
 using JetBrains.Annotations;
-using Robust.Shared.Physics.Dynamics;
 using Robust.Shared.Physics.Events;
 using Robust.Shared.Prototypes;
 
-
 namespace Content.Server.Chemistry.EntitySystems
 {
     [UsedImplicitly]
@@ -26,13 +23,17 @@ namespace Content.Server.Chemistry.EntitySystems
             SubscribeLocalEvent<SolutionInjectOnCollideComponent, StartCollideEvent>(HandleInjection);
         }
 
-        private void HandleInjection(EntityUid uid, SolutionInjectOnCollideComponent component, ref StartCollideEvent args)
+        private void HandleInjection(Entity<SolutionInjectOnCollideComponent> ent, ref StartCollideEvent args)
         {
+            var component = ent.Comp;
             var target = args.OtherEntity;
 
             if (!args.OtherBody.Hard ||
                 !EntityManager.TryGetComponent<BloodstreamComponent>(target, out var bloodstream) ||
-                !_solutionsSystem.TryGetInjectableSolution(component.Owner, out var solution)) return;
+                !_solutionsSystem.TryGetInjectableSolution(ent, out var solution))
+            {
+                return;
+            }
 
             if (component.BlockSlots != 0x0 && TryComp<InventoryComponent>(target, out var inventory))
             {
index f9256c8ce7a656352b8592ec994dcc746fc1a45e..02788d5a47d38f9659a8bc4aad808d4397fed2ee 100644 (file)
@@ -7,7 +7,6 @@ using Content.Shared.Chemistry.EntitySystems;
 using Content.Shared.Chemistry.Reagent;
 using Content.Shared.FixedPoint;
 using Content.Shared.Physics;
-using Robust.Shared.Spawners;
 using Content.Shared.Throwing;
 using JetBrains.Annotations;
 using Robust.Shared.Map;
@@ -16,7 +15,7 @@ using Robust.Shared.Physics.Components;
 using Robust.Shared.Physics.Events;
 using Robust.Shared.Physics.Systems;
 using Robust.Shared.Prototypes;
-using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent;
+using Robust.Shared.Spawners;
 
 namespace Content.Server.Chemistry.EntitySystems
 {
@@ -57,19 +56,19 @@ namespace Content.Server.Chemistry.EntitySystems
             }
         }
 
-        public void Start(VaporComponent vapor, TransformComponent vaporXform, Vector2 dir, float speed, MapCoordinates target, float aliveTime, EntityUid? user = null)
+        public void Start(Entity<VaporComponent> vapor, TransformComponent vaporXform, Vector2 dir, float speed, MapCoordinates target, float aliveTime, EntityUid? user = null)
         {
-            vapor.Active = true;
-            var despawn = EnsureComp<TimedDespawnComponent>(vapor.Owner);
+            vapor.Comp.Active = true;
+            var despawn = EnsureComp<TimedDespawnComponent>(vapor);
             despawn.Lifetime = aliveTime;
 
             // Set Move
-            if (EntityManager.TryGetComponent(vapor.Owner, out PhysicsComponent? physics))
+            if (EntityManager.TryGetComponent(vapor, out PhysicsComponent? physics))
             {
                 _physics.SetLinearDamping(physics, 0f);
                 _physics.SetAngularDamping(physics, 0f);
 
-                _throwing.TryThrow(vapor.Owner, dir, speed, user: user);
+                _throwing.TryThrow(vapor, dir, speed, user: user);
 
                 var distance = (target.Position - vaporXform.WorldPosition).Length();
                 var time = (distance / physics.LinearVelocity.Length());
@@ -77,41 +76,40 @@ namespace Content.Server.Chemistry.EntitySystems
             }
         }
 
-        internal bool TryAddSolution(VaporComponent vapor, Solution solution)
+        internal bool TryAddSolution(Entity<VaporComponent> vapor, Solution solution)
         {
             if (solution.Volume == 0)
             {
                 return false;
             }
 
-            if (!_solutionContainerSystem.TryGetSolution(vapor.Owner, VaporComponent.SolutionName,
+            if (!_solutionContainerSystem.TryGetSolution(vapor, VaporComponent.SolutionName,
                 out var vaporSolution))
             {
                 return false;
             }
 
-            return _solutionContainerSystem.TryAddSolution(vapor.Owner, vaporSolution, solution);
+            return _solutionContainerSystem.TryAddSolution(vapor, vaporSolution, solution);
         }
 
         public override void Update(float frameTime)
         {
-            foreach (var (vaporComp, solution, xform) in EntityManager
-                .EntityQuery<VaporComponent, SolutionContainerManagerComponent, TransformComponent>())
+            var query = EntityQueryEnumerator<VaporComponent, SolutionContainerManagerComponent, TransformComponent>();
+            while (query.MoveNext(out var uid, out var vaporComp, out var solution, out var xform))
             {
                 foreach (var (_, value) in solution.Solutions)
                 {
-                    Update(frameTime, vaporComp, value, xform);
+                    Update(frameTime, (uid, vaporComp), value, xform);
                 }
             }
         }
 
-        private void Update(float frameTime, VaporComponent vapor, Solution contents, TransformComponent xform)
+        private void Update(float frameTime, Entity<VaporComponent> ent, Solution contents, TransformComponent xform)
         {
+            var (entity, vapor) = ent;
             if (!vapor.Active)
                 return;
 
-            var entity = vapor.Owner;
-
             vapor.ReactTimer += frameTime;
 
             if (vapor.ReactTimer >= ReactTime && TryComp(xform.GridUid, out MapGridComponent? gridComp))
@@ -133,7 +131,7 @@ namespace Content.Server.Chemistry.EntitySystems
                         reaction = reagentQuantity.Quantity;
                     }
 
-                    _solutionContainerSystem.RemoveReagent(vapor.Owner, contents, reagentQuantity.Reagent, reaction);
+                    _solutionContainerSystem.RemoveReagent(entity, contents, reagentQuantity.Reagent, reaction);
                 }
             }
 
index 00ac03181d74d8f08ae0d360d87dcfdc5538232b..28356bbd3077487865ea9f1d445304d7b500a1c4 100644 (file)
@@ -19,7 +19,7 @@ public sealed partial class Oxygenate : ReagentEffect
         if (args.EntityManager.TryGetComponent<RespiratorComponent>(args.SolutionEntity, out var resp))
         {
             var respSys = EntitySystem.Get<RespiratorSystem>();
-            respSys.UpdateSaturation(resp.Owner, args.Quantity.Float() * Factor, resp);
+            respSys.UpdateSaturation(args.SolutionEntity, args.Quantity.Float() * Factor, resp);
         }
     }
 }
index f204b5cf7290d411d6ec91a7c1cd2b87e3961d2f..4ef44d1678d4bca4908a6b3a4a01f5bbed050a3f 100644 (file)
@@ -1,3 +1,4 @@
+using System.Linq;
 using Content.Shared.Decals;
 using Microsoft.Extensions.ObjectPool;
 using Robust.Server.Player;
@@ -5,8 +6,8 @@ using Robust.Shared;
 using Robust.Shared.Configuration;
 using Robust.Shared.Enums;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 using Robust.Shared.Utility;
-using System.Linq;
 
 namespace Content.Shared.Chunking;
 
@@ -87,10 +88,12 @@ public sealed class ChunkingSystem : EntitySystem
 
             var pos = _transform.GetWorldPosition(xform);
             var bounds = _baseViewBounds.Translated(pos).Enlarged(viewEnlargement);
+            var grids = new List<Entity<MapGridComponent>>();
+            _mapManager.FindGridsIntersecting(xform.MapID, bounds, ref grids, true);
 
-            foreach (var grid in _mapManager.FindGridsIntersecting(xform.MapID, bounds, true))
+            foreach (var grid in grids)
             {
-                var netGrid = GetNetEntity(grid.Owner);
+                var netGrid = GetNetEntity(grid);
 
                 if (!chunks.TryGetValue(netGrid, out var set))
                 {
@@ -98,7 +101,7 @@ public sealed class ChunkingSystem : EntitySystem
                     DebugTools.Assert(set.Count == 0);
                 }
 
-                var enumerator = new ChunkIndicesEnumerator(_transform.GetInvWorldMatrix(grid.Owner).TransformBox(bounds), chunkSize);
+                var enumerator = new ChunkIndicesEnumerator(_transform.GetInvWorldMatrix(grid).TransformBox(bounds), chunkSize);
 
                 while (enumerator.MoveNext(out var indices))
                 {
index 29f42bf6c216cd92f623df54d0de36aba68a1be3..0be9b64134514568dd6842365fb30a2d83a40eb7 100644 (file)
@@ -170,7 +170,7 @@ namespace Content.Server.Cloning
             if (mind.UserId.HasValue == false || mind.Session == null)
                 return;
 
-            if (_cloningSystem.TryCloning(cloningPodUid, body.Value, mind, cloningPod, scannerComp.CloningFailChanceMultiplier))
+            if (_cloningSystem.TryCloning(cloningPodUid, body.Value, (mindId, mind), cloningPod, scannerComp.CloningFailChanceMultiplier))
                 _adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(uid)} successfully cloned {ToPrettyString(body.Value)}.");
         }
 
index e94f0d11839d836ca9f90ecdb3f4f2d23e695fa5..c81651c512b6398b7b8025da804ce7c7b91b048e 100644 (file)
@@ -22,7 +22,6 @@ using Content.Shared.Emag.Systems;
 using Content.Shared.Examine;
 using Content.Shared.GameTicking;
 using Content.Shared.Humanoid;
-using Content.Shared.Humanoid.Prototypes;
 using Content.Shared.Mind;
 using Content.Shared.Mind.Components;
 using Content.Shared.Mobs.Systems;
@@ -154,7 +153,7 @@ namespace Content.Server.Cloning
             args.PushMarkup(Loc.GetString("cloning-pod-biomass", ("number", _material.GetMaterialAmount(uid, component.RequiredMaterial))));
         }
 
-        public bool TryCloning(EntityUid uid, EntityUid bodyToClone, MindComponent mind, CloningPodComponent? clonePod, float failChanceModifier = 1)
+        public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Entity<MindComponent> mindEnt, CloningPodComponent? clonePod, float failChanceModifier = 1)
         {
             if (!Resolve(uid, ref clonePod))
                 return false;
@@ -162,12 +161,13 @@ namespace Content.Server.Cloning
             if (HasComp<ActiveCloningPodComponent>(uid))
                 return false;
 
+            var mind = mindEnt.Comp;
             if (ClonesWaitingForMind.TryGetValue(mind, out var clone))
             {
                 if (EntityManager.EntityExists(clone) &&
                     !_mobStateSystem.IsDead(clone) &&
                     TryComp<MindContainerComponent>(clone, out var cloneMindComp) &&
-                    (cloneMindComp.Mind == null || cloneMindComp.Mind == mind.Owner))
+                    (cloneMindComp.Mind == null || cloneMindComp.Mind == mindEnt))
                     return false; // Mind already has clone
 
                 ClonesWaitingForMind.Remove(mind);
@@ -183,7 +183,7 @@ namespace Content.Server.Cloning
             if (!TryComp<HumanoidAppearanceComponent>(bodyToClone, out var humanoid))
                 return false; // whatever body was to be cloned, was not a humanoid
 
-            if (!_prototype.TryIndex<SpeciesPrototype>(humanoid.Species, out var speciesPrototype))
+            if (!_prototype.TryIndex(humanoid.Species, out var speciesPrototype))
                 return false;
 
             if (!TryComp<PhysicsComponent>(bodyToClone, out var physics))
@@ -198,9 +198,12 @@ namespace Content.Server.Cloning
             if (TryComp<UncloneableComponent>(bodyToClone, out _))
             {
                 if (clonePod.ConnectedConsole != null)
+                {
                     _chatSystem.TrySendInGameICMessage(clonePod.ConnectedConsole.Value,
                         Loc.GetString("cloning-console-uncloneable-trait-error"),
                         InGameICChatType.Speak, false);
+                }
+
                 return false;
             }
 
@@ -253,14 +256,13 @@ namespace Content.Server.Cloning
             clonePod.BodyContainer.Insert(mob);
             ClonesWaitingForMind.Add(mind, mob);
             UpdateStatus(uid, CloningPodStatus.NoMind, clonePod);
-            var mindId = mind.Owner;
-            _euiManager.OpenEui(new AcceptCloningEui(mindId, mind, this), client);
+            _euiManager.OpenEui(new AcceptCloningEui(mindEnt, mind, this), client);
 
             AddComp<ActiveCloningPodComponent>(uid);
 
             // TODO: Ideally, components like this should be components on the mind entity so this isn't necessary.
             // Add on special job components to the mob.
-            if (_jobs.MindTryGetJob(mindId, out _, out var prototype))
+            if (_jobs.MindTryGetJob(mindEnt, out _, out var prototype))
             {
                 foreach (var special in prototype.Special)
                 {
index fbf6ac607730c91f3c1842614ac4654a14c7baa3..776979106f388f326c3cf443b40e6363da5e0b7c 100644 (file)
@@ -43,12 +43,13 @@ namespace Content.Server.Clothing
                 args.AddAction(ref component.ToggleActionEntity, component.ToggleAction);
         }
 
-        private void OnToggleMask(EntityUid uid, MaskComponent mask, ToggleMaskEvent args)
+        private void OnToggleMask(Entity<MaskComponent> ent, ref ToggleMaskEvent args)
         {
+            var (uid, mask) = ent;
             if (mask.ToggleActionEntity == null)
                 return;
 
-            if (!_inventorySystem.TryGetSlotEntity(args.Performer, "mask", out var existing) || !mask.Owner.Equals(existing))
+            if (!_inventorySystem.TryGetSlotEntity(args.Performer, "mask", out var existing) || !uid.Equals(existing))
                 return;
 
             mask.IsToggled ^= true;
@@ -58,9 +59,9 @@ namespace Content.Server.Clothing
             _identity.QueueIdentityUpdate(args.Performer);
 
             if (mask.IsToggled)
-                _popupSystem.PopupEntity(Loc.GetString("action-mask-pull-down-popup-message", ("mask", mask.Owner)), args.Performer, args.Performer);
+                _popupSystem.PopupEntity(Loc.GetString("action-mask-pull-down-popup-message", ("mask", uid)), args.Performer, args.Performer);
             else
-                _popupSystem.PopupEntity(Loc.GetString("action-mask-pull-up-popup-message", ("mask", mask.Owner)), args.Performer, args.Performer);
+                _popupSystem.PopupEntity(Loc.GetString("action-mask-pull-up-popup-message", ("mask", uid)), args.Performer, args.Performer);
 
             ToggleMaskComponents(uid, mask, args.Performer);
         }
@@ -115,7 +116,7 @@ namespace Content.Server.Clothing
                 if (TryComp(wearer, out InternalsComponent? internals))
                 {
                     breathTool.ConnectedInternalsEntity = wearer;
-                    _internals.ConnectBreathTool(internals, uid);
+                    _internals.ConnectBreathTool((wearer, internals), uid);
                 }
             }
         }
index b5c938549291050b89dd4283787a55cc54bf2ed3..b2945c2a11950d66e58029c9254e331969c4aa38 100644 (file)
@@ -255,7 +255,7 @@ namespace Content.Server.Communications
 
                 if (_idCardSystem.TryFindIdCard(mob, out var id))
                 {
-                    author = $"{id.FullName} ({CultureInfo.CurrentCulture.TextInfo.ToTitleCase(id.JobTitle ?? string.Empty)})".Trim();
+                    author = $"{id.Comp.FullName} ({CultureInfo.CurrentCulture.TextInfo.ToTitleCase(id.Comp.JobTitle ?? string.Empty)})".Trim();
                 }
             }
 
index 02429fcaa621de86647097d5a370380ea8524e04..d23fa0a31b19102a6b168837dd3d58d0ae0b0572 100644 (file)
@@ -5,7 +5,7 @@ using Content.Shared.Construction;
 using Content.Shared.Tag;
 using Robust.Server.Player;
 using Robust.Shared.Console;
-using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 
 namespace Content.Server.Construction.Commands
 {
@@ -13,7 +13,6 @@ namespace Content.Server.Construction.Commands
     public sealed class FixRotationsCommand : IConsoleCommand
     {
         [Dependency] private readonly IEntityManager _entManager = default!;
-        [Dependency] private readonly IMapManager _mapManager = default!;
 
         // ReSharper disable once StringLiteralTypo
         public string Command => "fixrotations";
@@ -51,13 +50,13 @@ namespace Content.Server.Construction.Commands
                     return;
             }
 
-            if (!_mapManager.TryGetGrid(gridId, out var grid))
+            if (!_entManager.TryGetComponent(gridId, out MapGridComponent? grid))
             {
                 shell.WriteError($"No grid exists with id {gridId}");
                 return;
             }
 
-            if (!_entManager.EntityExists(grid.Owner))
+            if (!_entManager.EntityExists(gridId))
             {
                 shell.WriteError($"Grid {gridId} doesn't have an associated grid entity.");
                 return;
@@ -66,7 +65,7 @@ namespace Content.Server.Construction.Commands
             var changed = 0;
             var tagSystem = _entManager.EntitySysManager.GetEntitySystem<TagSystem>();
 
-            foreach (var child in xformQuery.GetComponent(grid.Owner).ChildEntities)
+            foreach (var child in xformQuery.GetComponent(gridId.Value).ChildEntities)
             {
                 if (!_entManager.EntityExists(child))
                 {
index 7de6c510d499bffbd7f1b91da2a1abe6df80479e..ed1fba2424ae22d6e7bb72b20b7fe22286ea0156 100644 (file)
@@ -3,6 +3,7 @@ using Content.Shared.Administration;
 using Robust.Server.Player;
 using Robust.Shared.Console;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 
 namespace Content.Server.Construction.Commands;
 
@@ -10,7 +11,6 @@ namespace Content.Server.Construction.Commands;
 sealed class TileReplaceCommand : IConsoleCommand
 {
     [Dependency] private readonly IEntityManager _entManager = default!;
-    [Dependency] private readonly IMapManager _mapManager = default!;
     [Dependency] private readonly ITileDefinitionManager _tileDef = default!;
 
     // ReSharper disable once StringLiteralTypo
@@ -58,13 +58,13 @@ sealed class TileReplaceCommand : IConsoleCommand
         var tileA = _tileDef[tileIdA];
         var tileB = _tileDef[tileIdB];
 
-        if (!_mapManager.TryGetGrid(gridId, out var grid))
+        if (!_entManager.TryGetComponent(gridId, out MapGridComponent? grid))
         {
             shell.WriteLine($"No grid exists with id {gridId}");
             return;
         }
 
-        if (!_entManager.EntityExists(grid.Owner))
+        if (!_entManager.EntityExists(gridId))
         {
             shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity.");
             return;
index e91935036487692d706cee498dc74644db16e672..55389e41cc74909e0a1a0d24821766f1dbb7f1de 100644 (file)
@@ -2,9 +2,11 @@ using Content.Server.Administration;
 using Content.Shared.Administration;
 using Content.Shared.Maps;
 using Content.Shared.Tag;
+using Robust.Server.GameObjects;
 using Robust.Server.Player;
 using Robust.Shared.Console;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 
 namespace Content.Server.Construction.Commands
 {
@@ -12,7 +14,6 @@ namespace Content.Server.Construction.Commands
     sealed class TileWallsCommand : IConsoleCommand
     {
         [Dependency] private readonly IEntityManager _entManager = default!;
-        [Dependency] private readonly IMapManager _mapManager = default!;
         [Dependency] private readonly ITileDefinitionManager _tileDefManager = default!;
 
         // ReSharper disable once StringLiteralTypo
@@ -56,13 +57,13 @@ namespace Content.Server.Construction.Commands
                     return;
             }
 
-            if (!_mapManager.TryGetGrid(gridId, out var grid))
+            if (!_entManager.TryGetComponent(gridId, out MapGridComponent? grid))
             {
                 shell.WriteLine($"No grid exists with id {gridId}");
                 return;
             }
 
-            if (!_entManager.EntityExists(grid.Owner))
+            if (!_entManager.EntityExists(gridId))
             {
                 shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity.");
                 return;
@@ -72,7 +73,7 @@ namespace Content.Server.Construction.Commands
             var underplating = _tileDefManager[TilePrototypeId];
             var underplatingTile = new Tile(underplating.TileId);
             var changed = 0;
-            foreach (var child in _entManager.GetComponent<TransformComponent>(grid.Owner).ChildEntities)
+            foreach (var child in _entManager.GetComponent<TransformComponent>(gridId.Value).ChildEntities)
             {
                 if (!_entManager.EntityExists(child))
                 {
@@ -91,7 +92,8 @@ namespace Content.Server.Construction.Commands
                     continue;
                 }
 
-                var tile = grid.GetTileRef(childTransform.Coordinates);
+                var mapSystem = _entManager.System<MapSystem>();
+                var tile = mapSystem.GetTileRef(gridId.Value, grid, childTransform.Coordinates);
                 var tileDef = (ContentTileDefinition) _tileDefManager[tile.Tile.TypeId];
 
                 if (tileDef.ID == TilePrototypeId)
index df96c0a6f8c5e55be576307d6b44687341c41b7c..edc1d26b6d497a77fb86c2166043f166cbc22c17 100644 (file)
@@ -27,7 +27,7 @@ public sealed partial class ConstructionSystem
         }
     }
 
-    private void OnCompMapInit(EntityUid uid, ComputerComponent component, MapInitEvent args)
+    private void OnCompMapInit(Entity<ComputerComponent> component, ref MapInitEvent args)
     {
         CreateComputerBoard(component);
     }
@@ -42,25 +42,26 @@ public sealed partial class ConstructionSystem
     ///     This exists so when you deconstruct computers that were serialized with the map,
     ///     you can retrieve the computer board.
     /// </summary>
-    private void CreateComputerBoard(ComputerComponent component)
+    private void CreateComputerBoard(Entity<ComputerComponent> ent)
     {
+        var component = ent.Comp;
         // Ensure that the construction component is aware of the board container.
-        if (TryComp<ConstructionComponent>(component.Owner, out var construction))
-            AddContainer(component.Owner, "board", construction);
+        if (TryComp<ConstructionComponent>(ent, out var construction))
+            AddContainer(ent, "board", construction);
 
         // We don't do anything if this is null or empty.
         if (string.IsNullOrEmpty(component.BoardPrototype))
             return;
 
-        var container = _container.EnsureContainer<Container>(component.Owner, "board");
+        var container = _container.EnsureContainer<Container>(ent, "board");
 
         // We already contain a board. Note: We don't check if it's the right one!
         if (container.ContainedEntities.Count != 0)
             return;
 
-        var board = EntityManager.SpawnEntity(component.BoardPrototype, Transform(component.Owner).Coordinates);
+        var board = EntityManager.SpawnEntity(component.BoardPrototype, Transform(ent).Coordinates);
 
-        if(!container.Insert(board))
-            Logger.Warning($"Couldn't insert board {board} to computer {component.Owner}!");
+        if (!container.Insert(board))
+            Log.Warning($"Couldn't insert board {board} to computer {ent}!");
     }
 }
index 237540f9feda2104837af5b2aff1437041dcc958..76d37432cb567429e74e7e0d9a6e8534df7712bd 100644 (file)
@@ -44,17 +44,18 @@ namespace Content.Server.Construction
             SubscribeLocalEvent<ConstructionComponent, ComponentStartup>(OnConstructionStartup);
         }
 
-        private void OnConstructionInit(EntityUid uid, ConstructionComponent construction, ComponentInit args)
+        private void OnConstructionInit(Entity<ConstructionComponent> ent, ref ComponentInit args)
         {
-            if (GetCurrentGraph(uid, construction) is not {} graph)
+            var construction = ent.Comp;
+            if (GetCurrentGraph(ent, construction) is not {} graph)
             {
-                _sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid graph specified.");
+                _sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid graph specified.");
                 return;
             }
 
             if (GetNodeFromGraph(graph, construction.Node) is not {} node)
             {
-                _sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid node specified.");
+                _sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid node specified.");
                 return;
             }
 
@@ -63,7 +64,7 @@ namespace Content.Server.Construction
             {
                 if (GetEdgeFromNode(node, edgeIndex) is not {} currentEdge)
                 {
-                    _sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid edge index specified.");
+                    _sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid edge index specified.");
                     return;
                 }
 
@@ -74,11 +75,11 @@ namespace Content.Server.Construction
             {
                 if (GetNodeFromGraph(graph, targetNodeId) is not { } targetNode)
                 {
-                    _sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid target node specified.");
+                    _sawmill.Warning($"Prototype {EntityManager.GetComponent<MetaDataComponent>(ent).EntityPrototype?.ID}'s construction component has an invalid target node specified.");
                     return;
                 }
 
-                UpdatePathfinding(uid, graph, node, targetNode, edge, construction);
+                UpdatePathfinding(ent, graph, node, targetNode, edge, construction);
             }
         }
 
index fa00648c55537129ee043ab7d4d0eca68fdf46f5..aed0575324f5ff00d9e8e772761d243b15fa5507 100644 (file)
@@ -270,14 +270,13 @@ public sealed class CrewManifestCommand : IConsoleCommand
             return CompletionResult.Empty;
         }
 
-        var stations = _entityManager
-            .EntityQuery<StationDataComponent>()
-            .Select(stationData =>
-            {
-                var meta = _entityManager.GetComponent<MetaDataComponent>(stationData.Owner);
-
-                return new CompletionOption(stationData.Owner.ToString(), meta.EntityName);
-            });
+        var stations = new List<CompletionOption>();
+        var query = _entityManager.EntityQueryEnumerator<StationDataComponent>();
+        while (query.MoveNext(out var uid, out _))
+        {
+            var meta = _entityManager.GetComponent<MetaDataComponent>(uid);
+            stations.Add(new CompletionOption(uid.ToString(), meta.EntityName));
+        }
 
         return CompletionResult.FromHintOptions(stations, null);
     }
index b780f0686ddafd57cc59b2be50fb0c85cb7a9fd6..2d9c5a1b254b0f81bb4b2524a8bae22a0d849248 100644 (file)
@@ -3,8 +3,10 @@ using Content.Server.Administration;
 using Content.Shared.Administration;
 using Content.Shared.Decals;
 using Content.Shared.Maps;
+using Robust.Server.GameObjects;
 using Robust.Shared.Console;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 using Robust.Shared.Prototypes;
 
 namespace Content.Server.Decals.Commands
@@ -13,7 +15,6 @@ namespace Content.Server.Decals.Commands
     public sealed class AddDecalCommand : IConsoleCommand
     {
         [Dependency] private readonly IEntityManager _entManager = default!;
-        [Dependency] private readonly IMapManager _mapManager = default!;
         [Dependency] private readonly IPrototypeManager _protoManager = default!;
 
         public string Command => "adddecal";
@@ -46,14 +47,15 @@ namespace Content.Server.Decals.Commands
 
             if (!NetEntity.TryParse(args[3], out var gridIdNet) ||
                 !_entManager.TryGetEntity(gridIdNet, out var gridIdRaw) ||
-                !_mapManager.TryGetGrid(gridIdRaw, out var grid))
+                !_entManager.TryGetComponent(gridIdRaw, out MapGridComponent? grid))
             {
                 shell.WriteError($"Failed parsing gridId '{args[3]}'.");
                 return;
             }
 
-            var coordinates = new EntityCoordinates(grid.Owner, new Vector2(x, y));
-            if (grid.GetTileRef(coordinates).IsSpace())
+            var mapSystem = _entManager.System<MapSystem>();
+            var coordinates = new EntityCoordinates(gridIdRaw.Value, new Vector2(x, y));
+            if (mapSystem.GetTileRef(gridIdRaw.Value, grid, coordinates).IsSpace())
             {
                 shell.WriteError($"Cannot create decal on space tile at {coordinates}.");
                 return;
index 6f40ebae3a3d17aa5a7c3a2e319cb41d4305e7f9..d5a5bf9affa8bcc1a5c8129fdb9d57dc9faa9256 100644 (file)
@@ -9,11 +9,13 @@ using Content.Shared.Database;
 using Content.Shared.Decals;
 using Content.Shared.Maps;
 using Microsoft.Extensions.ObjectPool;
+using Robust.Server.GameObjects;
 using Robust.Server.Player;
 using Robust.Shared;
 using Robust.Shared.Configuration;
 using Robust.Shared.Enums;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 using Robust.Shared.Threading;
 using Robust.Shared.Timing;
 using Robust.Shared.Utility;
@@ -31,6 +33,7 @@ namespace Content.Server.Decals
         [Dependency] private readonly IConfigurationManager _conf = default!;
         [Dependency] private readonly IGameTiming _timing = default!;
         [Dependency] private readonly IAdminLogManager _adminLogger = default!;
+        [Dependency] private readonly MapSystem _mapSystem = default!;
 
         private readonly Dictionary<NetEntity, HashSet<Vector2i>> _dirtyChunks = new();
         private readonly Dictionary<IPlayerSession, Dictionary<NetEntity, HashSet<Vector2i>>> _previousSentChunks = new();
@@ -283,10 +286,10 @@ namespace Content.Server.Decals
                 return false;
 
             var gridId = coordinates.GetGridUid(EntityManager);
-            if (!MapManager.TryGetGrid(gridId, out var grid))
+            if (!TryComp(gridId, out MapGridComponent? grid))
                 return false;
 
-            if (grid.GetTileRef(coordinates).IsSpace(_tileDefMan))
+            if (_mapSystem.GetTileRef(gridId.Value, grid, coordinates).IsSpace(_tileDefMan))
                 return false;
 
             if (!TryComp(gridId, out DecalGridComponent? comp))
index d6169479f84e8c83a4fcb536ff62908414fe8d00..875f29785d698ebd2cb1764fc2e7bac16eac1680 100644 (file)
@@ -19,17 +19,18 @@ public sealed class AutoLinkSystem : EntitySystem
     {
         var xform = Transform(uid);
 
-        foreach (var receiver in EntityQuery<AutoLinkReceiverComponent>())
+        var query = EntityQueryEnumerator<AutoLinkReceiverComponent>();
+        while (query.MoveNext(out var receiverUid, out var receiver))
         {
             if (receiver.AutoLinkChannel != component.AutoLinkChannel)
                 continue; // Not ours.
 
-            var rxXform = Transform(receiver.Owner);
+            var rxXform = Transform(receiverUid);
 
             if (rxXform.GridUid != xform.GridUid)
                 continue;
 
-            _deviceLinkSystem.LinkDefaults(null, uid, receiver.Owner);
+            _deviceLinkSystem.LinkDefaults(null, uid, receiverUid);
         }
     }
 }
index 5899baf2fcd720ed597c6d2957c8e6921a578f45..560149f2289af821a10534ab51c787444ed42bce 100644 (file)
@@ -59,7 +59,7 @@ public sealed class DoorSystem : SharedDoorSystem
             return;
 
         if (door.ChangeAirtight && TryComp(uid, out AirtightComponent? airtight))
-            _airtightSystem.SetAirblocked(uid, airtight, collidable);
+            _airtightSystem.SetAirblocked((uid, airtight), collidable);
 
         // Pathfinding / AI stuff.
         RaiseLocalEvent(new AccessReaderChangeEvent(uid, collidable));
@@ -201,14 +201,14 @@ public sealed class DoorSystem : SharedDoorSystem
         }
     }
 
-    protected override void CheckDoorBump(DoorComponent component, PhysicsComponent body)
+    protected override void CheckDoorBump(Entity<DoorComponent, PhysicsComponent> ent)
     {
-        var uid = body.Owner;
-        if (component.BumpOpen)
+        var (uid, door, physics) = ent;
+        if (door.BumpOpen)
         {
-            foreach (var other in PhysicsSystem.GetContactingEntities(uid, body, approximate: true))
+            foreach (var other in PhysicsSystem.GetContactingEntities(uid, physics, approximate: true))
             {
-                if (Tags.HasTag(other, "DoorBumpOpener") && TryOpen(uid, component, other, false, quiet: true))
+                if (Tags.HasTag(other, "DoorBumpOpener") && TryOpen(uid, door, other, quiet: true))
                     break;
             }
         }
index e2f25c63ab48b118f552ecce1487cd349cb23e05..3d4c8a4ec59e04621dc62b9c80f7c9af69b1b300 100644 (file)
@@ -4,9 +4,7 @@ using Content.Server.Atmos.Monitor.Systems;
 using Content.Server.Popups;
 using Content.Server.Power.Components;
 using Content.Server.Power.EntitySystems;
-using Content.Server.Remotes;
 using Content.Server.Shuttles.Components;
-using Content.Shared.Access.Components;
 using Content.Shared.Access.Systems;
 using Content.Shared.Atmos;
 using Content.Shared.Atmos.Monitor;
@@ -14,11 +12,8 @@ using Content.Shared.Doors;
 using Content.Shared.Doors.Components;
 using Content.Shared.Doors.Systems;
 using Content.Shared.Popups;
-using Microsoft.Extensions.Options;
-using Robust.Server.GameObjects;
-using Robust.Shared.Map.Components;
-using Robust.Shared.Player;
 using Content.Shared.Prying.Components;
+using Robust.Shared.Map.Components;
 
 namespace Content.Server.Doors.Systems
 {
@@ -72,7 +67,8 @@ namespace Content.Server.Doors.Systems
             var appearanceQuery = GetEntityQuery<AppearanceComponent>();
             var xformQuery = GetEntityQuery<TransformComponent>();
 
-            foreach (var (firelock, door) in EntityQuery<FirelockComponent, DoorComponent>())
+            var query = EntityQueryEnumerator<FirelockComponent, DoorComponent>();
+            while (query.MoveNext(out var uid, out var firelock, out var door))
             {
                 // only bother to check pressure on doors that are some variation of closed.
                 if (door.State != DoorState.Closed
@@ -82,7 +78,6 @@ namespace Content.Server.Doors.Systems
                     continue;
                 }
 
-                var uid = door.Owner;
                 if (airtightQuery.TryGetComponent(uid, out var airtight)
                     && xformQuery.TryGetComponent(uid, out var xform)
                     && appearanceQuery.TryGetComponent(uid, out var appearance))
@@ -128,9 +123,9 @@ namespace Content.Server.Doors.Systems
 
             if (door.State == DoorState.Open)
             {
-                if (_doorSystem.TryClose(door.Owner, door))
+                if (_doorSystem.TryClose(uid, door))
                 {
-                    return _doorSystem.OnPartialClose(door.Owner, door);
+                    return _doorSystem.OnPartialClose(uid, door);
                 }
             }
             return false;
@@ -275,7 +270,7 @@ namespace Content.Server.Doors.Systems
             if (airtight.AirBlockedDirection != AtmosDirection.All)
                 tiles.Add(pos);
 
-            var gasses = _atmosSystem.GetTileMixtures(gridAtmosphere.Owner, xform.MapUid, tiles);
+            var gasses = _atmosSystem.GetTileMixtures(xform.ParentUid, xform.MapUid, tiles);
             if (gasses == null)
                 return (false, false);
 
index 3085af0cdce96dad769bb53f924d4cf088e21dec..08bf68c4d290c4babce9453f3e2d0d4d20f65e47 100644 (file)
@@ -3,6 +3,7 @@ using Content.Shared.DoAfter;
 using Content.Shared.Hands.EntitySystems;
 using Content.Shared.Verbs;
 using JetBrains.Annotations;
+
 namespace Content.Server.Engineering.EntitySystems
 {
     [UsedImplicitly]
@@ -52,17 +53,17 @@ namespace Content.Server.Engineering.EntitySystems
                     return;
             }
 
-            if (component.Deleted || Deleted(component.Owner))
+            if (component.Deleted || Deleted(uid))
                 return;
 
-            if (!TryComp<TransformComponent>(component.Owner, out var transformComp))
+            if (!TryComp<TransformComponent>(uid, out var transformComp))
                 return;
 
             var entity = EntityManager.SpawnEntity(component.Prototype, transformComp.Coordinates);
 
             _handsSystem.TryPickup(user, entity);
 
-            EntityManager.DeleteEntity(component.Owner);
+            EntityManager.DeleteEntity(uid);
         }
     }
 }
index 4893552c2c0cbc1c7b2216e03db72cd91582d935..61c4937a271a35d30d753c16313d62ddf56d20ef 100644 (file)
@@ -1,6 +1,6 @@
-using Content.Shared.Coordinates.Helpers;
 using Content.Server.Engineering.Components;
 using Content.Server.Stack;
+using Content.Shared.Coordinates.Helpers;
 using Content.Shared.DoAfter;
 using Content.Shared.Interaction;
 using Content.Shared.Maps;
@@ -58,7 +58,7 @@ namespace Content.Server.Engineering.EntitySystems
             if (component.Deleted || !IsTileClear())
                 return;
 
-            if (EntityManager.TryGetComponent(component.Owner, out StackComponent? stackComp)
+            if (EntityManager.TryGetComponent(uid, out StackComponent? stackComp)
                 && component.RemoveOnInteract && !_stackSystem.Use(uid, 1, stackComp))
             {
                 return;
@@ -66,8 +66,8 @@ namespace Content.Server.Engineering.EntitySystems
 
             EntityManager.SpawnEntity(component.Prototype, args.ClickLocation.SnapToGrid(grid));
 
-            if (component.RemoveOnInteract && stackComp == null && !((!EntityManager.EntityExists(component.Owner) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(component.Owner).EntityLifeStage) >= EntityLifeStage.Deleted))
-                EntityManager.DeleteEntity(component.Owner);
+            if (component.RemoveOnInteract && stackComp == null && !((!EntityManager.EntityExists(uid) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(component.Owner).EntityLifeStage) >= EntityLifeStage.Deleted))
+                EntityManager.DeleteEntity(uid);
         }
     }
 }
index e05056a68c19347ca1978c496cc3b8712da70b54..9467966cb6c9f91153334039278bab81d37d8083 100644 (file)
@@ -4,7 +4,6 @@ using Content.Shared.Explosion;
 using Content.Shared.Interaction;
 using Content.Shared.Interaction.Events;
 using Content.Shared.Throwing;
-using Robust.Server.GameObjects;
 using Robust.Shared.Containers;
 using Robust.Shared.Random;
 
@@ -32,18 +31,22 @@ public sealed class ClusterGrenadeSystem : EntitySystem
         component.GrenadesContainer = _container.EnsureContainer<Container>(uid, "cluster-flash");
     }
 
-    private void OnClugStartup(EntityUid uid, ClusterGrenadeComponent component, ComponentStartup args)
+    private void OnClugStartup(Entity<ClusterGrenadeComponent> clug, ref ComponentStartup args)
     {
+        var component = clug.Comp;
         if (component.FillPrototype != null)
         {
             component.UnspawnedCount = Math.Max(0, component.MaxGrenades - component.GrenadesContainer.ContainedEntities.Count);
-            UpdateAppearance(uid, component);
+            UpdateAppearance(clug);
         }
     }
 
-    private void OnClugUsing(EntityUid uid, ClusterGrenadeComponent component, InteractUsingEvent args)
+    private void OnClugUsing(Entity<ClusterGrenadeComponent> clug, ref InteractUsingEvent args)
     {
-        if (args.Handled) return;
+        if (args.Handled)
+            return;
+
+        var component = clug.Comp;
 
         // TODO: Should use whitelist.
         if (component.GrenadesContainer.ContainedEntities.Count >= component.MaxGrenades ||
@@ -51,7 +54,7 @@ public sealed class ClusterGrenadeSystem : EntitySystem
             return;
 
         component.GrenadesContainer.Insert(args.Used);
-        UpdateAppearance(uid, component);
+        UpdateAppearance(clug);
         args.Handled = true;
     }
 
@@ -63,7 +66,7 @@ public sealed class ClusterGrenadeSystem : EntitySystem
         // TODO: Should be an Update loop
         uid.SpawnTimer((int) (component.Delay * 1000), () =>
         {
-            if (Deleted(component.Owner))
+            if (Deleted(uid))
                 return;
 
             component.CountDown = true;
@@ -71,7 +74,7 @@ public sealed class ClusterGrenadeSystem : EntitySystem
             var grenadesInserted = component.GrenadesContainer.ContainedEntities.Count + component.UnspawnedCount;
             var thrownCount = 0;
             var segmentAngle = 360 / grenadesInserted;
-            while (TryGetGrenade(component, out var grenade))
+            while (TryGetGrenade((uid, component), out var grenade))
             {
                 var angleMin = segmentAngle * thrownCount;
                 var angleMax = segmentAngle * (thrownCount + 1);
@@ -99,14 +102,15 @@ public sealed class ClusterGrenadeSystem : EntitySystem
         args.Handled = true;
     }
 
-    private bool TryGetGrenade(ClusterGrenadeComponent component, out EntityUid grenade)
+    private bool TryGetGrenade(Entity<ClusterGrenadeComponent> ent, out EntityUid grenade)
     {
         grenade = default;
+        var component = ent.Comp;
 
         if (component.UnspawnedCount > 0)
         {
             component.UnspawnedCount--;
-            grenade = EntityManager.SpawnEntity(component.FillPrototype, Transform(component.Owner).MapPosition);
+            grenade = EntityManager.SpawnEntity(component.FillPrototype, Transform(ent).MapPosition);
             return true;
         }
 
@@ -124,10 +128,12 @@ public sealed class ClusterGrenadeSystem : EntitySystem
         return false;
     }
 
-    private void UpdateAppearance(EntityUid uid, ClusterGrenadeComponent component)
+    private void UpdateAppearance(Entity<ClusterGrenadeComponent> ent)
     {
-        if (!TryComp<AppearanceComponent>(component.Owner, out var appearance)) return;
+        var component = ent.Comp;
+        if (!TryComp<AppearanceComponent>(ent, out var appearance))
+            return;
 
-        _appearance.SetData(uid, ClusterGrenadeVisuals.GrenadesCounter, component.GrenadesContainer.ContainedEntities.Count + component.UnspawnedCount, appearance);
+        _appearance.SetData(ent, ClusterGrenadeVisuals.GrenadesCounter, component.GrenadesContainer.ContainedEntities.Count + component.UnspawnedCount, appearance);
     }
 }
index 79985d233b71ce9dec117aa4e2d3294470dab5c2..34028ab43502454f0ec085a8a06a46e56ec768c2 100644 (file)
@@ -59,8 +59,8 @@ public sealed partial class ExplosionSystem : EntitySystem
         // if the explosion is centered on some grid (and not just space), get the transforms.
         if (referenceGrid != null)
         {
-            var targetGrid = _mapManager.GetGrid(referenceGrid.Value);
-            var xform = Transform(targetGrid.Owner);
+            var targetGrid = Comp<MapGridComponent>(referenceGrid.Value);
+            var xform = Transform(referenceGrid.Value);
             targetAngle = xform.WorldRotation;
             targetMatrix = xform.InvWorldMatrix;
             tileSize = targetGrid.TileSize;
@@ -84,17 +84,17 @@ public sealed partial class ExplosionSystem : EntitySystem
             if (!_gridEdges.TryGetValue(gridToTransform, out var edges))
                 continue;
 
-            if (!_mapManager.TryGetGrid(gridToTransform, out var grid))
+            if (!TryComp(gridToTransform, out MapGridComponent? grid))
                 continue;
 
             if (grid.TileSize != tileSize)
             {
-                Logger.Error($"Explosions do not support grids with different grid sizes. GridIds: {gridToTransform} and {referenceGrid}");
+                Log.Error($"Explosions do not support grids with different grid sizes. GridIds: {gridToTransform} and {referenceGrid}");
                 continue;
             }
 
             var xforms = EntityManager.GetEntityQuery<TransformComponent>();
-            var xform = xforms.GetComponent(grid.Owner);
+            var xform = xforms.GetComponent(gridToTransform);
             var  (_, gridWorldRotation, gridWorldMatrix, invGridWorldMatrid) = xform.GetWorldPositionRotationMatrixWithInv(xforms);
 
             var localEpicentre = (Vector2i) invGridWorldMatrid.Transform(epicentre.Position);
@@ -228,7 +228,7 @@ public sealed partial class ExplosionSystem : EntitySystem
         if (!ev.NewTile.Tile.IsEmpty && !ev.OldTile.IsEmpty)
             return;
 
-        if (!_mapManager.TryGetGrid(ev.Entity, out var grid))
+        if (!TryComp(ev.Entity, out MapGridComponent? grid))
             return;
 
         var tileRef = ev.NewTile;
index 28c627e14347ebcb6e070157c2f503d362c705ba..c00f591d92bf83955936bfde584691cf46801f4b 100644 (file)
@@ -4,7 +4,6 @@ using Content.Server.Speech.Components;
 using Content.Shared.Database;
 using Content.Shared.Examine;
 using Content.Shared.Verbs;
-using Robust.Shared.Player;
 
 namespace Content.Server.Explosion.EntitySystems
 {
@@ -26,39 +25,43 @@ namespace Content.Server.Explosion.EntitySystems
                 RemCompDeferred<ActiveListenerComponent>(uid);
         }
 
-        private void OnListen(EntityUid uid, TriggerOnVoiceComponent component, ListenEvent args)
+        private void OnListen(Entity<TriggerOnVoiceComponent> ent, ref ListenEvent args)
         {
+            var component = ent.Comp;
             var message = args.Message.Trim();
 
             if (component.IsRecording)
             {
                 if (message.Length >= component.MinLength || message.Length <= component.MaxLength)
-                    FinishRecording(component, args.Source, args.Message);
+                    FinishRecording(ent, args.Source, args.Message);
                 return;
             }
 
             if (!string.IsNullOrWhiteSpace(component.KeyPhrase) && message.Contains(component.KeyPhrase, StringComparison.InvariantCultureIgnoreCase))
             {
                 _adminLogger.Add(LogType.Trigger, LogImpact.High,
-                        $"A voice-trigger on {ToPrettyString(uid):entity} was triggered by {ToPrettyString(args.Source):speaker} speaking the key-phrase {component.KeyPhrase}.");
-                Trigger(uid, args.Source);
+                        $"A voice-trigger on {ToPrettyString(ent):entity} was triggered by {ToPrettyString(args.Source):speaker} speaking the key-phrase {component.KeyPhrase}.");
+                Trigger(ent, args.Source);
             }
         }
 
-        private void OnVoiceGetAltVerbs(EntityUid uid, TriggerOnVoiceComponent component, GetVerbsEvent<AlternativeVerb> args)
+        private void OnVoiceGetAltVerbs(Entity<TriggerOnVoiceComponent> ent, ref GetVerbsEvent<AlternativeVerb> args)
         {
             if (!args.CanInteract || !args.CanAccess)
                 return;
 
+            var component = ent.Comp;
+
+            var @event = args;
             args.Verbs.Add(new AlternativeVerb()
             {
                 Text = Loc.GetString(component.IsRecording ? "verb-trigger-voice-record-stop" : "verb-trigger-voice-record"),
                 Act = () =>
                 {
                     if (component.IsRecording)
-                        StopRecording(component);
+                        StopRecording(ent);
                     else
-                        StartRecording(component, args.User);
+                        StartRecording(ent, @event.User);
                 },
                 Priority = 1
             });
@@ -73,40 +76,43 @@ namespace Content.Server.Explosion.EntitySystems
                 {
                     component.KeyPhrase = null;
                     component.IsRecording = false;
-                    RemComp<ActiveListenerComponent>(uid);
+                    RemComp<ActiveListenerComponent>(ent);
                 }
             });
         }
 
-        public void StartRecording(TriggerOnVoiceComponent component, EntityUid user)
+        public void StartRecording(Entity<TriggerOnVoiceComponent> ent, EntityUid user)
         {
+            var component = ent.Comp;
             component.IsRecording = true;
-            EnsureComp<ActiveListenerComponent>(component.Owner).Range = component.ListenRange;
+            EnsureComp<ActiveListenerComponent>(ent).Range = component.ListenRange;
 
             _adminLogger.Add(LogType.Trigger, LogImpact.Low,
-                    $"A voice-trigger on {ToPrettyString(component.Owner):entity} has started recording. User: {ToPrettyString(user):user}");
+                    $"A voice-trigger on {ToPrettyString(ent):entity} has started recording. User: {ToPrettyString(user):user}");
 
-            _popupSystem.PopupEntity(Loc.GetString("popup-trigger-voice-start-recording"), component.Owner);
+            _popupSystem.PopupEntity(Loc.GetString("popup-trigger-voice-start-recording"), ent);
         }
 
-        public void StopRecording(TriggerOnVoiceComponent component)
+        public void StopRecording(Entity<TriggerOnVoiceComponent> ent)
         {
+            var component = ent.Comp;
             component.IsRecording = false;
             if (string.IsNullOrWhiteSpace(component.KeyPhrase))
-                RemComp<ActiveListenerComponent>(component.Owner);
+                RemComp<ActiveListenerComponent>(ent);
 
-            _popupSystem.PopupEntity(Loc.GetString("popup-trigger-voice-stop-recording"), component.Owner);
+            _popupSystem.PopupEntity(Loc.GetString("popup-trigger-voice-stop-recording"), ent);
         }
 
-        public void FinishRecording(TriggerOnVoiceComponent component, EntityUid source, string message)
+        public void FinishRecording(Entity<TriggerOnVoiceComponent> ent, EntityUid source, string message)
         {
+            var component = ent.Comp;
             component.KeyPhrase = message;
             component.IsRecording = false;
 
             _adminLogger.Add(LogType.Trigger, LogImpact.Low,
-                    $"A voice-trigger on {ToPrettyString(component.Owner):entity} has recorded a new keyphrase: '{component.KeyPhrase}'. Recorded from {ToPrettyString(source):speaker}");
+                    $"A voice-trigger on {ToPrettyString(ent):entity} has recorded a new keyphrase: '{component.KeyPhrase}'. Recorded from {ToPrettyString(source):speaker}");
 
-            _popupSystem.PopupEntity(Loc.GetString("popup-trigger-voice-recorded", ("keyphrase", component.KeyPhrase!)), component.Owner);
+            _popupSystem.PopupEntity(Loc.GetString("popup-trigger-voice-recorded", ("keyphrase", component.KeyPhrase!)), ent);
         }
 
         private void OnVoiceExamine(EntityUid uid, TriggerOnVoiceComponent component, ExaminedEvent args)
index cefc918b17b1cd01acd5c607f6b8a7389e08bace..ea3df2f8c4685f041f5bda40fb503f683050eadc 100644 (file)
@@ -1,19 +1,18 @@
-using Content.Server.Fluids.Components;
-using Content.Server.Chemistry.EntitySystems;
 using Content.Server.DoAfter;
+using Content.Server.Fluids.Components;
 using Content.Server.Popups;
-using Content.Shared.FixedPoint;
 using Content.Shared.Audio;
 using Content.Shared.Chemistry.Components.SolutionManager;
 using Content.Shared.Chemistry.EntitySystems;
 using Content.Shared.Database;
 using Content.Shared.DoAfter;
 using Content.Shared.Examine;
+using Content.Shared.FixedPoint;
 using Content.Shared.Fluids;
+using Content.Shared.Fluids.Components;
 using Content.Shared.Interaction;
 using Content.Shared.Tag;
 using Content.Shared.Verbs;
-using Content.Shared.Fluids.Components;
 using Robust.Shared.Collections;
 using Robust.Shared.Random;
 using Robust.Shared.Utility;
@@ -96,7 +95,7 @@ public sealed class DrainSystem : SharedDrainSystem
 
         if (drainSolution.MaxVolume == drainSolution.Volume)
         {
-            _puddleSystem.TrySpillAt(Transform(target).Coordinates, containerSolution, out var puddle);
+            _puddleSystem.TrySpillAt(Transform(target).Coordinates, containerSolution, out _);
             _popupSystem.PopupEntity(
                 Loc.GetString("drain-component-empty-verb-target-is-full-message", ("object", target)),
                 container);
@@ -111,7 +110,8 @@ public sealed class DrainSystem : SharedDrainSystem
         var puddleQuery = GetEntityQuery<PuddleComponent>();
         var puddles = new ValueList<(EntityUid Entity, string Solution)>();
 
-        foreach (var drain in EntityQuery<DrainComponent>())
+        var query = EntityQueryEnumerator<DrainComponent>();
+        while (query.MoveNext(out var uid, out var drain))
         {
             drain.Accumulator += frameTime;
             if (drain.Accumulator < drain.DrainFrequency)
@@ -123,32 +123,32 @@ public sealed class DrainSystem : SharedDrainSystem
             // Disable ambient sound from emptying manually
             if (!drain.AutoDrain)
             {
-                _ambientSoundSystem.SetAmbience(drain.Owner, false);
+                _ambientSoundSystem.SetAmbience(uid, false);
                 continue;
             }
 
-            if (!managerQuery.TryGetComponent(drain.Owner, out var manager))
+            if (!managerQuery.TryGetComponent(uid, out var manager))
                 continue;
 
             // Best to do this one every second rather than once every tick...
-            _solutionSystem.TryGetSolution(drain.Owner, DrainComponent.SolutionName, out var drainSolution, manager);
+            _solutionSystem.TryGetSolution(uid, DrainComponent.SolutionName, out var drainSolution, manager);
 
             if (drainSolution is null)
                 continue;
 
             if (drainSolution.AvailableVolume <= 0)
             {
-                _ambientSoundSystem.SetAmbience(drain.Owner, false);
+                _ambientSoundSystem.SetAmbience(uid, false);
                 continue;
             }
 
             // Remove a bit from the buffer
-            _solutionSystem.SplitSolution(drain.Owner, drainSolution, (drain.UnitsDestroyedPerSecond * drain.DrainFrequency));
+            _solutionSystem.SplitSolution(uid, drainSolution, (drain.UnitsDestroyedPerSecond * drain.DrainFrequency));
 
             // This will ensure that UnitsPerSecond is per second...
             var amount = drain.UnitsPerSecond * drain.DrainFrequency;
 
-            if (!xformQuery.TryGetComponent(drain.Owner, out var xform))
+            if (!xformQuery.TryGetComponent(uid, out var xform))
                 continue;
 
             puddles.Clear();
@@ -165,11 +165,11 @@ public sealed class DrainSystem : SharedDrainSystem
 
             if (puddles.Count == 0)
             {
-                _ambientSoundSystem.SetAmbience(drain.Owner, false);
+                _ambientSoundSystem.SetAmbience(uid, false);
                 continue;
             }
 
-            _ambientSoundSystem.SetAmbience(drain.Owner, true);
+            _ambientSoundSystem.SetAmbience(uid, true);
 
             amount /= puddles.Count;
 
@@ -190,7 +190,7 @@ public sealed class DrainSystem : SharedDrainSystem
                 var transferSolution = _solutionSystem.SplitSolution(puddle, puddleSolution,
                     FixedPoint2.Min(FixedPoint2.New(amount), puddleSolution.Volume, drainSolution.AvailableVolume));
 
-                _solutionSystem.TryAddSolution(drain.Owner, drainSolution, transferSolution);
+                _solutionSystem.TryAddSolution(uid, drainSolution, transferSolution);
 
                 if (puddleSolution.Volume <= 0)
                 {
@@ -203,13 +203,15 @@ public sealed class DrainSystem : SharedDrainSystem
     private void OnExamined(EntityUid uid, DrainComponent component, ExaminedEvent args)
     {
         if (!args.IsInDetailsRange ||
-            !TryComp(uid, out SolutionContainerManagerComponent? solutionComp) ||
+            !HasComp<SolutionContainerManagerComponent>(uid) ||
             !_solutionSystem.TryGetSolution(uid, DrainComponent.SolutionName, out var drainSolution))
-        { return; }
+        {
+            return;
+        }
 
-        var text = drainSolution.AvailableVolume != 0 ?
-            Loc.GetString("drain-component-examine-volume", ("volume", drainSolution.AvailableVolume)) :
-            Loc.GetString("drain-component-examine-hint-full");
+        var text = drainSolution.AvailableVolume != 0
+            ? Loc.GetString("drain-component-examine-volume", ("volume", drainSolution.AvailableVolume))
+            Loc.GetString("drain-component-examine-hint-full");
         args.Message.AddMarkup($"\n\n{text}");
     }
 
@@ -218,7 +220,9 @@ public sealed class DrainSystem : SharedDrainSystem
         if (!args.CanReach || args.Target == null ||
             !_tagSystem.HasTag(args.Used, DrainComponent.PlungerTag) ||
             !_solutionSystem.TryGetSolution(args.Target.Value, DrainComponent.SolutionName, out var drainSolution))
-        { return; }
+        {
+            return;
+        }
 
         if (drainSolution.AvailableVolume > 0)
         {
index ec4fb3b399f9e689ac6aabc24176998c66abcdab..59f0a13695eb9292e5ccc8e9f99d3f0efd686cf4 100644 (file)
@@ -1,9 +1,9 @@
 using System.Numerics;
-using Content.Server.Fluids.Components;
 using Content.Shared.Fluids;
 using Content.Shared.Fluids.Components;
 using Robust.Server.Player;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 using Robust.Shared.Timing;
 
 namespace Content.Server.Fluids.EntitySystems;
@@ -15,7 +15,7 @@ public sealed class PuddleDebugDebugOverlaySystem : SharedPuddleDebugOverlaySyst
     [Dependency] private readonly PuddleSystem _puddle = default!;
 
     private readonly HashSet<IPlayerSession> _playerObservers = new();
-
+    private List<Entity<MapGridComponent>> _grids = new();
 
     public bool ToggleObserver(IPlayerSession observer)
     {
@@ -58,8 +58,10 @@ public sealed class PuddleDebugDebugOverlaySystem : SharedPuddleDebugOverlaySyst
             var worldBounds = Box2.CenteredAround(transform.WorldPosition,
                 new Vector2(LocalViewRange, LocalViewRange));
 
+            _grids.Clear();
+            _mapManager.FindGridsIntersecting(transform.MapID, worldBounds, ref _grids);
 
-            foreach (var grid in _mapManager.FindGridsIntersecting(transform.MapID, worldBounds))
+            foreach (var grid in _grids)
             {
                 var data = new List<PuddleDebugOverlayData>();
                 var gridUid = grid.Owner;
@@ -67,7 +69,7 @@ public sealed class PuddleDebugDebugOverlaySystem : SharedPuddleDebugOverlaySyst
                 if (!Exists(gridUid))
                     continue;
 
-                foreach (var uid in grid.GetAnchoredEntities(worldBounds))
+                foreach (var uid in grid.Comp.GetAnchoredEntities(worldBounds))
                 {
                     PuddleComponent? puddle = null;
                     TransformComponent? xform = null;
index 4870f4286fd4e79dece54f5f0d248703941a557c..886cb9eff14f91c9857e4260e92f4088ce32e407 100644 (file)
@@ -1,20 +1,25 @@
 using Content.Server.Administration.Logs;
 using Content.Server.DoAfter;
 using Content.Server.Fluids.Components;
-using Content.Shared.Chemistry;
-using Content.Shared.Chemistry.Reaction;
 using Content.Server.Spreader;
+using Content.Shared.Chemistry;
+using Content.Shared.Chemistry.Components;
 using Content.Shared.Chemistry.EntitySystems;
+using Content.Shared.Chemistry.Reaction;
 using Content.Shared.Chemistry.Reagent;
 using Content.Shared.Database;
+using Content.Shared.Effects;
 using Content.Shared.Examine;
 using Content.Shared.FixedPoint;
 using Content.Shared.Fluids;
-using Content.Shared.Popups;
-using Content.Shared.Slippery;
 using Content.Shared.Fluids.Components;
 using Content.Shared.Friction;
 using Content.Shared.IdentityManagement;
+using Content.Shared.Maps;
+using Content.Shared.Movement.Components;
+using Content.Shared.Movement.Systems;
+using Content.Shared.Popups;
+using Content.Shared.Slippery;
 using Content.Shared.StepTrigger.Components;
 using Content.Shared.StepTrigger.Systems;
 using Robust.Server.GameObjects;
@@ -22,14 +27,9 @@ using Robust.Shared.Audio;
 using Robust.Shared.Map;
 using Robust.Shared.Map.Components;
 using Robust.Shared.Player;
-using Solution = Content.Shared.Chemistry.Components.Solution;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Random;
 using Robust.Shared.Timing;
-using Content.Shared.Movement.Components;
-using Content.Shared.Movement.Systems;
-using Content.Shared.Maps;
-using Content.Shared.Effects;
 
 namespace Content.Server.Fluids.EntitySystems;
 
@@ -509,8 +509,11 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
             return false;
 
         var targets = new List<EntityUid>();
+        var reactive = new HashSet<Entity<ReactiveComponent>>();
+        _lookup.GetEntitiesInRange(coordinates, 1.0f, reactive);
+
         // Get reactive entities nearby--if there are some, it'll spill a bit on them instead.
-        foreach (var ent in _lookup.GetComponentsInRange<ReactiveComponent>(coordinates, 1.0f))
+        foreach (var ent in reactive)
         {
             // sorry! no overload for returning uid, so .owner must be used
             var owner = ent.Owner;
index 8ae9b4b3da2fc41395c5da391e63655bb3cea5ab..f0afd43dd2fb4d10e5751b62a5b2ddddb6a85c85 100644 (file)
@@ -130,14 +130,15 @@ public sealed class SpraySystem : EntitySystem
 
             // Add the solution to the vapor and actually send the thing
             var vaporComponent = Comp<VaporComponent>(vapor);
-            _vapor.TryAddSolution(vaporComponent, newSolution);
+            var ent = (vapor, vaporComponent);
+            _vapor.TryAddSolution(ent, newSolution);
 
             // impulse direction is defined in world-coordinates, not local coordinates
             var impulseDirection = rotation.ToVec();
             var time = diffLength / component.SprayVelocity;
             cooldownTime = MathF.Max(time, cooldownTime);
 
-            _vapor.Start(vaporComponent, vaporXform, impulseDirection * diffLength, component.SprayVelocity, target, time, args.User);
+            _vapor.Start(ent, vaporXform, impulseDirection * diffLength, component.SprayVelocity, target, time, args.User);
 
             if (TryComp<PhysicsComponent>(args.User, out var body))
             {
index 117717fca46f1f8adb39edf3a6e3965518d5f547..69704ddb562bfa0f37461c29301cf4f569b0bec5 100644 (file)
@@ -1,8 +1,5 @@
 using System.Linq;
-using System.Text; // todo: remove this stinky LINQy
-using Robust.Server.GameObjects;
-using Robust.Shared.Audio;
-using Robust.Shared.Timing;
+using System.Text;
 using Content.Server.Paper;
 using Content.Server.Popups;
 using Content.Server.UserInterface;
@@ -11,6 +8,10 @@ using Content.Shared.Forensics;
 using Content.Shared.Hands.EntitySystems;
 using Content.Shared.Interaction;
 using Content.Shared.Verbs;
+using Robust.Server.GameObjects;
+using Robust.Shared.Audio;
+using Robust.Shared.Timing;
+// todo: remove this stinky LINQy
 
 namespace Content.Server.Forensics
 {
@@ -83,7 +84,7 @@ namespace Content.Server.Forensics
                 scanner.LastScannedName = MetaData(args.Args.Target.Value).EntityName;
             }
 
-            OpenUserInterface(args.Args.User, scanner);
+            OpenUserInterface(args.Args.User, (uid, scanner));
         }
 
         /// <remarks>
@@ -160,14 +161,14 @@ namespace Content.Server.Forensics
             UpdateUserInterface(uid, component);
         }
 
-        private void OpenUserInterface(EntityUid user, ForensicScannerComponent component)
+        private void OpenUserInterface(EntityUid user, Entity<ForensicScannerComponent> scanner)
         {
             if (!TryComp<ActorComponent>(user, out var actor))
                 return;
 
-            UpdateUserInterface(component.Owner, component);
+            UpdateUserInterface(scanner, scanner.Comp);
 
-            _uiSystem.TryOpen(component.Owner, ForensicScannerUiKey.Key, actor.PlayerSession);
+            _uiSystem.TryOpen(scanner, ForensicScannerUiKey.Key, actor.PlayerSession);
         }
 
         private void OnPrint(EntityUid uid, ForensicScannerComponent component, ForensicScannerPrintMessage args)
@@ -192,7 +193,7 @@ namespace Content.Server.Forensics
             var printed = EntityManager.SpawnEntity(component.MachineOutput, Transform(uid).Coordinates);
             _handsSystem.PickupOrDrop(args.Session.AttachedEntity, printed, checkActionBlocker: false);
 
-            if (!TryComp<PaperComponent>(printed, out var paper))
+            if (!HasComp<PaperComponent>(printed))
             {
                 _sawmill.Error("Printed paper did not have PaperComponent.");
                 return;
index 1c784641e357543f936c75ac4558387b5adc86eb..0c59f93bb021fad55e1dff01e155ad7a5caad399 100644 (file)
@@ -15,6 +15,7 @@ using Content.Shared.Roles.Jobs;
 using JetBrains.Annotations;
 using Robust.Server.Player;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 using Robust.Shared.Network;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Random;
@@ -34,11 +35,23 @@ namespace Content.Server.GameTicking
         /// How many players have joined the round through normal methods.
         /// Useful for game rules to look at. Doesn't count observers, people in lobby, etc.
         /// </summary>
-        public int PlayersJoinedRoundNormally = 0;
+        public int PlayersJoinedRoundNormally;
 
         // Mainly to avoid allocations.
         private readonly List<EntityCoordinates> _possiblePositions = new();
 
+        private List<EntityUid> GetSpawnableStations()
+        {
+            var spawnableStations = new List<EntityUid>();
+            var query = EntityQueryEnumerator<StationJobsComponent, StationSpawningComponent>();
+            while (query.MoveNext(out var uid, out _, out _))
+            {
+                spawnableStations.Add(uid);
+            }
+
+            return spawnableStations;
+        }
+
         private void SpawnPlayers(List<IPlayerSession> readyPlayers, Dictionary<NetUserId, HumanoidCharacterProfile> profiles, bool force)
         {
             // Allow game rules to spawn players by themselves if needed. (For example, nuke ops or wizard)
@@ -66,8 +79,7 @@ namespace Content.Server.GameTicking
                 }
             }
 
-            var spawnableStations = EntityQuery<StationJobsComponent, StationSpawningComponent>().Select(x => x.Item1.Owner).ToList();
-
+            var spawnableStations = GetSpawnableStations();
             var assignedJobs = _stationJobs.AssignJobs(profiles, spawnableStations);
 
             _stationJobs.AssignOverflowJobs(ref assignedJobs, playerNetIds, profiles, spawnableStations);
@@ -125,7 +137,7 @@ namespace Content.Server.GameTicking
 
             if (station == EntityUid.Invalid)
             {
-                var stations = EntityQuery<StationJobsComponent, StationSpawningComponent>().Select(x => x.Item1.Owner).ToList();
+                var stations = GetSpawnableStations();
                 _robustRandom.Shuffle(stations);
                 if (stations.Count == 0)
                     station = EntityUid.Invalid;
@@ -161,7 +173,8 @@ namespace Content.Server.GameTicking
             restrictedRoles.UnionWith(getDisallowed);
 
             var jobBans = _banManager.GetJobBans(player.UserId);
-            if(jobBans != null) restrictedRoles.UnionWith(jobBans);
+            if (jobBans != null)
+                restrictedRoles.UnionWith(jobBans);
 
             // Pick best job best on prefs.
             jobId ??= _stationJobs.PickBestAvailableJobWithPriority(station, character.JobPriorities, true,
@@ -350,15 +363,16 @@ namespace Content.Server.GameTicking
             // Fallback to a random grid.
             if (_possiblePositions.Count == 0)
             {
-                foreach (var grid in _mapManager.GetAllGrids())
+                var query = AllEntityQuery<MapGridComponent>();
+                while (query.MoveNext(out var uid, out var grid))
                 {
-                    if (!metaQuery.TryGetComponent(grid.Owner, out var meta) ||
+                    if (!metaQuery.TryGetComponent(uid, out var meta) ||
                         meta.EntityPaused)
                     {
                         continue;
                     }
 
-                    _possiblePositions.Add(new EntityCoordinates(grid.Owner, Vector2.Zero));
+                    _possiblePositions.Add(new EntityCoordinates(uid, Vector2.Zero));
                 }
             }
 
index 3bd3d13d2778926ea4310f58ba0b0ddb9a2fd6ff..13d4ed71c8e0b34c583a33e41cec645d6248010e 100644 (file)
@@ -330,13 +330,17 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
         // we can only currently guarantee that NT stations are the only station to
         // exist in the base game.
 
-        var eligible = EntityQuery<StationEventEligibleComponent, NpcFactionMemberComponent>()
-            .Where(x =>
-                _npcFaction.IsFactionHostile(component.Faction, x.Item2.Owner, x.Item2))
-            .Select(x => x.Item1.Owner)
-            .ToList();
+        var eligible = new List<Entity<StationEventEligibleComponent, NpcFactionMemberComponent>>();
+        var eligibleQuery = EntityQueryEnumerator<StationEventEligibleComponent, NpcFactionMemberComponent>();
+        while (eligibleQuery.MoveNext(out var eligibleUid, out var eligibleComp, out var member))
+        {
+            if (!_npcFaction.IsFactionFriendly(component.Faction, eligibleUid, member))
+                continue;
+
+            eligible.Add((eligibleUid, eligibleComp, member));
+        }
 
-        if (!eligible.Any())
+        if (eligible.Count == 0)
             return;
 
         component.TargetStation = _random.Pick(eligible);
index 671b91392c40803c64fd6c7715fbc8a2b560a50d..5a4cc176f2a549f26272ef1f814dad92d1c0f8cf 100644 (file)
@@ -40,12 +40,12 @@ namespace Content.Server.Ghost.Roles
 
         private uint _nextRoleIdentifier;
         private bool _needsUpdateGhostRoleCount = true;
-        private readonly Dictionary<uint, GhostRoleComponent> _ghostRoles = new();
+        private readonly Dictionary<uint, Entity<GhostRoleComponent>> _ghostRoles = new();
         private readonly Dictionary<ICommonSession, GhostRolesEui> _openUis = new();
         private readonly Dictionary<ICommonSession, MakeGhostRoleEui> _openMakeGhostRoleUis = new();
 
         [ViewVariables]
-        public IReadOnlyCollection<GhostRoleComponent> GhostRoles => _ghostRoles.Values;
+        public IReadOnlyCollection<Entity<GhostRoleComponent>> GhostRoles => _ghostRoles.Values;
 
         public override void Initialize()
         {
@@ -65,9 +65,9 @@ namespace Content.Server.Ghost.Roles
             _playerManager.PlayerStatusChanged += PlayerStatusChanged;
         }
 
-        private void OnMobStateChanged(EntityUid uid, GhostTakeoverAvailableComponent component, MobStateChangedEvent args)
+        private void OnMobStateChanged(Entity<GhostTakeoverAvailableComponent> component, ref MobStateChangedEvent args)
         {
-            if (!TryComp(uid, out GhostRoleComponent? ghostRole))
+            if (!TryComp(component, out GhostRoleComponent? ghostRole))
                 return;
 
             switch (args.NewMobState)
@@ -75,12 +75,12 @@ namespace Content.Server.Ghost.Roles
                 case MobState.Alive:
                 {
                     if (!ghostRole.Taken)
-                        RegisterGhostRole(ghostRole);
+                        RegisterGhostRole((component, ghostRole));
                     break;
                 }
                 case MobState.Critical:
                 case MobState.Dead:
-                    UnregisterGhostRole(ghostRole);
+                    UnregisterGhostRole((component, ghostRole));
                     break;
             }
         }
@@ -126,7 +126,8 @@ namespace Content.Server.Ghost.Roles
 
         public void CloseEui(ICommonSession session)
         {
-            if (!_openUis.ContainsKey(session)) return;
+            if (!_openUis.ContainsKey(session))
+                return;
 
             _openUis.Remove(session, out var eui);
 
@@ -176,47 +177,57 @@ namespace Content.Server.Ghost.Roles
             }
         }
 
-        public void RegisterGhostRole(GhostRoleComponent role)
+        public void RegisterGhostRole(Entity<GhostRoleComponent> role)
         {
-            if (_ghostRoles.ContainsValue(role)) return;
-            _ghostRoles[role.Identifier = GetNextRoleIdentifier()] = role;
-            UpdateAllEui();
+            if (_ghostRoles.ContainsValue(role))
+                return;
 
+            _ghostRoles[role.Comp.Identifier = GetNextRoleIdentifier()] = role;
+            UpdateAllEui();
         }
 
-        public void UnregisterGhostRole(GhostRoleComponent role)
+        public void UnregisterGhostRole(Entity<GhostRoleComponent> role)
         {
-            if (!_ghostRoles.ContainsKey(role.Identifier) || _ghostRoles[role.Identifier] != role) return;
-            _ghostRoles.Remove(role.Identifier);
+            var comp = role.Comp;
+            if (!_ghostRoles.ContainsKey(comp.Identifier) || _ghostRoles[comp.Identifier] != role)
+                return;
+
+            _ghostRoles.Remove(comp.Identifier);
             UpdateAllEui();
         }
 
         public void Takeover(ICommonSession player, uint identifier)
         {
-            if (!_ghostRoles.TryGetValue(identifier, out var role)) return;
+            if (!_ghostRoles.TryGetValue(identifier, out var role))
+                return;
 
             var ev = new TakeGhostRoleEvent(player);
-            RaiseLocalEvent(role.Owner, ref ev);
+            RaiseLocalEvent(role, ref ev);
 
-            if (!ev.TookRole) return;
+            if (!ev.TookRole)
+                return;
 
             if (player.AttachedEntity != null)
-                _adminLogger.Add(LogType.GhostRoleTaken, LogImpact.Low, $"{player:player} took the {role.RoleName:roleName} ghost role {ToPrettyString(player.AttachedEntity.Value):entity}");
+                _adminLogger.Add(LogType.GhostRoleTaken, LogImpact.Low, $"{player:player} took the {role.Comp.RoleName:roleName} ghost role {ToPrettyString(player.AttachedEntity.Value):entity}");
 
             CloseEui(player);
         }
 
         public void Follow(ICommonSession player, uint identifier)
         {
-            if (!_ghostRoles.TryGetValue(identifier, out var role)) return;
-            if (player.AttachedEntity == null) return;
+            if (!_ghostRoles.TryGetValue(identifier, out var role))
+                return;
+
+            if (player.AttachedEntity == null)
+                return;
 
-            _followerSystem.StartFollowingEntity(player.AttachedEntity.Value, role.Owner);
+            _followerSystem.StartFollowingEntity(player.AttachedEntity.Value, role);
         }
 
         public void GhostRoleInternalCreateMindAndTransfer(ICommonSession player, EntityUid roleUid, EntityUid mob, GhostRoleComponent? role = null)
         {
-            if (!Resolve(roleUid, ref role)) return;
+            if (!Resolve(roleUid, ref role))
+                return;
 
             DebugTools.AssertNotNull(player.ContentData());
 
@@ -233,10 +244,8 @@ namespace Content.Server.Ghost.Roles
             var roles = new List<GhostRoleInfo>();
             var metaQuery = GetEntityQuery<MetaDataComponent>();
 
-            foreach (var (id, role) in _ghostRoles)
+            foreach (var (id, (uid, role)) in _ghostRoles)
             {
-                var uid = role.Owner;
-
                 if (metaQuery.GetComponent(uid).EntityPaused)
                     continue;
 
@@ -249,8 +258,12 @@ namespace Content.Server.Ghost.Roles
         private void OnPlayerAttached(PlayerAttachedEvent message)
         {
             // Close the session of any player that has a ghost roles window open and isn't a ghost anymore.
-            if (!_openUis.ContainsKey(message.Player)) return;
-            if (EntityManager.HasComponent<GhostComponent>(message.Entity)) return;
+            if (!_openUis.ContainsKey(message.Player))
+                return;
+
+            if (HasComp<GhostComponent>(message.Entity))
+                return;
+
             CloseEui(message.Player);
         }
 
@@ -260,7 +273,7 @@ namespace Content.Server.Ghost.Roles
                 return;
 
             ghostRole.Taken = true;
-            UnregisterGhostRole(ghostRole);
+            UnregisterGhostRole((uid, ghostRole));
         }
 
         private void OnMindRemoved(EntityUid uid, GhostTakeoverAvailableComponent component, MindRemovedMessage args)
@@ -273,7 +286,7 @@ namespace Content.Server.Ghost.Roles
                 return;
 
             ghostRole.Taken = false;
-            RegisterGhostRole(ghostRole);
+            RegisterGhostRole((uid, ghostRole));
         }
 
         public void Reset(RoundRestartCleanupEvent ev)
@@ -304,20 +317,21 @@ namespace Content.Server.Ghost.Roles
             UpdateAllEui();
         }
 
-        private void OnInit(EntityUid uid, GhostRoleComponent role, ComponentInit args)
+        private void OnInit(Entity<GhostRoleComponent> ent, ref ComponentInit args)
         {
+            var role = ent.Comp;
             if (role.Probability < 1f && !_random.Prob(role.Probability))
             {
-                RemComp<GhostRoleComponent>(uid);
+                RemComp<GhostRoleComponent>(ent);
                 return;
             }
 
             if (role.RoleRules == "")
                 role.RoleRules = Loc.GetString("ghost-role-component-default-rules");
-            RegisterGhostRole(role);
+            RegisterGhostRole(ent);
         }
 
-        private void OnShutdown(EntityUid uid, GhostRoleComponent role, ComponentShutdown args)
+        private void OnShutdown(Entity<GhostRoleComponent> role, ref ComponentShutdown args)
         {
             UnregisterGhostRole(role);
         }
@@ -391,7 +405,7 @@ namespace Content.Server.Ghost.Roles
                 MakeSentientCommand.MakeSentient(uid, EntityManager, ghostRole.AllowMovement, ghostRole.AllowSpeech);
 
             GhostRoleInternalCreateMindAndTransfer(args.Player, uid, uid, ghostRole);
-            UnregisterGhostRole(ghostRole);
+            UnregisterGhostRole((uid, ghostRole));
 
             args.TookRole = true;
         }
index 1a9b2ad6e9972f10e2d5d68edeface42259b0269..48002fb823de6cba77cdabadc7f078ad9e1ca20a 100644 (file)
@@ -1,13 +1,12 @@
 using Content.Server.Administration.Logs;
 using Content.Server.Audio;
+using Content.Server.Construction;
 using Content.Server.Power.Components;
 using Content.Shared.Database;
 using Content.Shared.Gravity;
 using Content.Shared.Interaction;
 using Robust.Server.GameObjects;
-using Robust.Server.Player;
 using Robust.Shared.Players;
-using Content.Server.Construction;
 
 namespace Content.Server.Gravity
 {
@@ -56,9 +55,10 @@ namespace Content.Server.Gravity
         {
             base.Update(frameTime);
 
-            foreach (var (gravGen, powerReceiver) in EntityManager
-                .EntityQuery<GravityGeneratorComponent, ApcPowerReceiverComponent>())
+            var query = EntityQueryEnumerator<GravityGeneratorComponent, ApcPowerReceiverComponent>();
+            while (query.MoveNext(out var uid, out var gravGen, out var powerReceiver))
             {
+                var ent = (uid, gravGen, powerReceiver);
                 if (!gravGen.Intact)
                     continue;
 
@@ -108,15 +108,15 @@ namespace Content.Server.Gravity
                 var updateUI = gravGen.NeedUIUpdate;
                 if (!MathHelper.CloseTo(lastCharge, gravGen.Charge))
                 {
-                    UpdateState(gravGen, powerReceiver);
+                    UpdateState(ent);
                     updateUI = true;
                 }
 
                 if (updateUI)
-                    UpdateUI(gravGen, powerReceiver, chargeRate);
+                    UpdateUI(ent, chargeRate);
 
                 if (active != gravGen.GravityActive &&
-                    TryComp<TransformComponent>(gravGen.Owner, out var xform) &&
+                    TryComp<TransformComponent>(uid, out var xform) &&
                     TryComp<GravityComponent>(xform.ParentUid, out var gravity))
                 {
                     // Force it on in the faster path.
@@ -153,12 +153,10 @@ namespace Content.Server.Gravity
             powerReceiver.Load = component.SwitchedOn ? component.ActivePowerUse : component.IdlePowerUse;
         }
 
-        private void UpdateUI(
-            GravityGeneratorComponent component,
-            ApcPowerReceiverComponent powerReceiver,
-            float chargeRate)
+        private void UpdateUI(Entity<GravityGeneratorComponent, ApcPowerReceiverComponent> ent, float chargeRate)
         {
-            if (!_uiSystem.IsUiOpen(component.Owner, SharedGravityGeneratorComponent.GravityGeneratorUiKey.Key))
+            var (_, component, powerReceiver) = ent;
+            if (!_uiSystem.IsUiOpen(ent, SharedGravityGeneratorComponent.GravityGeneratorUiKey.Key))
                 return;
 
             var chargeTarget = chargeRate < 0 ? 0 : component.MaxCharge;
@@ -194,21 +192,21 @@ namespace Content.Server.Gravity
             );
 
             _uiSystem.TrySetUiState(
-                component.Owner,
+                ent,
                 SharedGravityGeneratorComponent.GravityGeneratorUiKey.Key,
                 state);
 
             component.NeedUIUpdate = false;
         }
 
-        private void OnCompInit(EntityUid uid, GravityGeneratorComponent component, ComponentInit args)
+        private void OnCompInit(Entity<GravityGeneratorComponent> ent, ref ComponentInit args)
         {
             ApcPowerReceiverComponent? powerReceiver = null;
-            if (!Resolve(uid, ref powerReceiver, false))
+            if (!Resolve(ent, ref powerReceiver, false))
                 return;
 
-            UpdatePowerState(component, powerReceiver);
-            UpdateState(component, powerReceiver);
+            UpdatePowerState(ent, powerReceiver);
+            UpdateState((ent, ent.Comp, powerReceiver));
         }
 
         private void OnInteractHand(EntityUid uid, GravityGeneratorComponent component, InteractHandEvent args)
@@ -228,9 +226,9 @@ namespace Content.Server.Gravity
             component.NeedUIUpdate = true;
         }
 
-        public void UpdateState(GravityGeneratorComponent grav, ApcPowerReceiverComponent powerReceiver)
+        public void UpdateState(Entity<GravityGeneratorComponent, ApcPowerReceiverComponent> ent)
         {
-            var uid = grav.Owner;
+            var (uid, grav, powerReceiver) = ent;
             var appearance = EntityManager.GetComponentOrNull<AppearanceComponent>(uid);
             _appearance.SetData(uid, GravityGeneratorVisuals.Charge, grav.Charge, appearance);
 
@@ -242,19 +240,19 @@ namespace Content.Server.Gravity
 
             if (!grav.Intact)
             {
-                MakeBroken(uid, grav, appearance);
+                MakeBroken((uid, grav), appearance);
             }
             else if (powerReceiver.PowerReceived < grav.IdlePowerUse)
             {
-                MakeUnpowered(uid, grav, appearance);
+                MakeUnpowered((uid, grav), appearance);
             }
             else if (!grav.SwitchedOn)
             {
-                MakeOff(uid, grav, appearance);
+                MakeOff((uid, grav), appearance);
             }
             else
             {
-                MakeOn(uid, grav, appearance);
+                MakeOn((uid, grav), appearance);
             }
         }
 
@@ -264,32 +262,32 @@ namespace Content.Server.Gravity
             component.MaxCharge = maxChargeMultipler * 1;
         }
 
-        private void MakeBroken(EntityUid uid, GravityGeneratorComponent component, AppearanceComponent? appearance)
+        private void MakeBroken(Entity<GravityGeneratorComponent> ent, AppearanceComponent? appearance)
         {
-            _ambientSoundSystem.SetAmbience(component.Owner, false);
+            _ambientSoundSystem.SetAmbience(ent, false);
 
-            _appearance.SetData(uid, GravityGeneratorVisuals.State, GravityGeneratorStatus.Broken);
+            _appearance.SetData(ent, GravityGeneratorVisuals.State, GravityGeneratorStatus.Broken);
         }
 
-        private void MakeUnpowered(EntityUid uid, GravityGeneratorComponent component, AppearanceComponent? appearance)
+        private void MakeUnpowered(Entity<GravityGeneratorComponent> ent, AppearanceComponent? appearance)
         {
-            _ambientSoundSystem.SetAmbience(component.Owner, false);
+            _ambientSoundSystem.SetAmbience(ent, false);
 
-            _appearance.SetData(uid, GravityGeneratorVisuals.State, GravityGeneratorStatus.Unpowered, appearance);
+            _appearance.SetData(ent, GravityGeneratorVisuals.State, GravityGeneratorStatus.Unpowered, appearance);
         }
 
-        private void MakeOff(EntityUid uid, GravityGeneratorComponent component, AppearanceComponent? appearance)
+        private void MakeOff(Entity<GravityGeneratorComponent> ent, AppearanceComponent? appearance)
         {
-            _ambientSoundSystem.SetAmbience(component.Owner, false);
+            _ambientSoundSystem.SetAmbience(ent, false);
 
-            _appearance.SetData(uid, GravityGeneratorVisuals.State, GravityGeneratorStatus.Off, appearance);
+            _appearance.SetData(ent, GravityGeneratorVisuals.State, GravityGeneratorStatus.Off, appearance);
         }
 
-        private void MakeOn(EntityUid uid, GravityGeneratorComponent component, AppearanceComponent? appearance)
+        private void MakeOn(Entity<GravityGeneratorComponent> ent, AppearanceComponent? appearance)
         {
-            _ambientSoundSystem.SetAmbience(component.Owner, true);
+            _ambientSoundSystem.SetAmbience(ent, true);
 
-            _appearance.SetData(uid, GravityGeneratorVisuals.State, GravityGeneratorStatus.On, appearance);
+            _appearance.SetData(ent, GravityGeneratorVisuals.State, GravityGeneratorStatus.On, appearance);
         }
 
         private void OnSwitchGenerator(
index 298aa57ccf212cdc2d146016bd26fd27d5a2099a..b5b01ac001de4ebb33fa803f61f35646370c17df 100644 (file)
@@ -18,14 +18,11 @@ using Content.Shared.Pulling.Components;
 using Content.Shared.Stacks;
 using Content.Shared.Storage;
 using Content.Shared.Throwing;
-using JetBrains.Annotations;
 using Robust.Server.Player;
-using Robust.Shared.Configuration;
 using Robust.Shared.Containers;
 using Robust.Shared.GameStates;
 using Robust.Shared.Input.Binding;
 using Robust.Shared.Map;
-using Robust.Shared.Player;
 using Robust.Shared.Players;
 using Robust.Shared.Utility;
 
@@ -97,7 +94,7 @@ namespace Content.Server.Hands.Systems
             base.HandleEntityRemoved(uid, hands, args);
 
             if (!Deleted(args.Entity) && TryComp(args.Entity, out HandVirtualItemComponent? @virtual))
-                _virtualSystem.Delete(@virtual, uid);
+                _virtualSystem.Delete((args.Entity, @virtual), uid);
         }
 
         private void HandleBodyPartAdded(EntityUid uid, HandsComponent component, ref BodyPartAddedEvent args)
index 29ec823aa76db9cf9c2ade8f388ff98cae3f9f3b..4581d378f69c08b41ae151e02b4c6df7bf93e3ac 100644 (file)
@@ -57,7 +57,7 @@ public sealed class RandomGiftSystem : EntitySystem
 
         var coords = Transform(args.User).Coordinates;
         var handsEnt = Spawn(component.SelectedEntity, coords);
-        _adminLogger.Add(LogType.EntitySpawn, LogImpact.Low, $"{ToPrettyString(args.User)} used {ToPrettyString(component.Owner)} which spawned {ToPrettyString(handsEnt)}");
+        _adminLogger.Add(LogType.EntitySpawn, LogImpact.Low, $"{ToPrettyString(args.User)} used {ToPrettyString(uid)} which spawned {ToPrettyString(handsEnt)}");
         EnsureComp<ItemComponent>(handsEnt); // For insane mode.
         if (component.Wrapper is not null)
             Spawn(component.Wrapper, coords);
index 3d4be31435e4661a61e5818bdc9f20a7e201b16b..cdb4dc7c6c94814c111ec5f30824c0d67e186153 100644 (file)
@@ -4,14 +4,12 @@ using Content.Server.Humanoid;
 using Content.Shared.Database;
 using Content.Shared.Hands;
 using Content.Shared.Humanoid;
-using Content.Shared.Humanoid.Prototypes;
 using Content.Shared.IdentityManagement;
 using Content.Shared.IdentityManagement.Components;
 using Content.Shared.Inventory;
 using Content.Shared.Inventory.Events;
 using Robust.Shared.Enums;
 using Robust.Shared.GameObjects.Components.Localization;
-using Robust.Shared.Prototypes;
 
 namespace Content.Server.IdentityManagement;
 
@@ -147,8 +145,8 @@ public class IdentitySystem : SharedIdentitySystem
         // Get their name and job from their ID for their presumed name.
         if (_idCard.TryFindIdCard(target, out var id))
         {
-            presumedName = string.IsNullOrWhiteSpace(id.FullName) ? null : id.FullName;
-            presumedJob = id.JobTitle?.ToLowerInvariant();
+            presumedName = string.IsNullOrWhiteSpace(id.Comp.FullName) ? null : id.Comp.FullName;
+            presumedJob = id.Comp.JobTitle?.ToLowerInvariant();
         }
 
         // If it didn't find a job, that's fine.
index 6984dbf56bcd46f41f2731a364999457b71c820f..b70cf7a9a7c8d0d834f79b94486c632e178a3070 100644 (file)
@@ -41,9 +41,9 @@ public sealed class IgnitionSourceSystem : EntitySystem
     {
         base.Update(frameTime);
 
-        foreach (var (component,transform) in EntityQuery<IgnitionSourceComponent,TransformComponent>())
+        var query = EntityQueryEnumerator<IgnitionSourceComponent, TransformComponent>();
+        while (query.MoveNext(out var source, out var component, out var transform))
         {
-            var source = component.Owner;
             if (!component.Ignited)
                 continue;
 
index d50ce8df1fdabcfc7bcfa43462fa19a2dc216ae8..6ce53dc53021c8bedde529e1df6120ecc881d8d6 100644 (file)
@@ -12,7 +12,6 @@ using Content.Shared.Interaction;
 using Content.Shared.Kitchen;
 using Content.Shared.Popups;
 using Content.Shared.Random;
-using Content.Shared.Random.Helpers;
 using Content.Shared.Stacks;
 using JetBrains.Annotations;
 using Robust.Server.GameObjects;
@@ -59,10 +58,9 @@ namespace Content.Server.Kitchen.EntitySystems
         {
             base.Update(frameTime);
 
-            foreach (var (active, reagentGrinder) in EntityQuery<ActiveReagentGrinderComponent, ReagentGrinderComponent>())
+            var query = EntityQueryEnumerator<ActiveReagentGrinderComponent, ReagentGrinderComponent>();
+            while (query.MoveNext(out var uid, out var active, out var reagentGrinder))
             {
-                var uid = reagentGrinder.Owner;
-
                 if (active.EndTime > _timing.CurTime)
                     continue;
 
index 29f5dd7f41d0ad869eaea47d146386231e94ffba..f4db4216cfe1f6000b3de4a7e3c6f8781ecc1707 100644 (file)
@@ -9,8 +9,6 @@ using Content.Shared.Temperature;
 using Content.Shared.Verbs;
 using JetBrains.Annotations;
 using Robust.Server.GameObjects;
-using Robust.Shared.Audio;
-using Robust.Shared.Player;
 using Robust.Shared.Utility;
 
 namespace Content.Server.Light.EntitySystems
@@ -36,15 +34,18 @@ namespace Content.Server.Light.EntitySystems
 
         public override void Update(float frameTime)
         {
-            foreach (var light in EntityManager.EntityQuery<ExpendableLightComponent>())
+            var query = EntityQueryEnumerator<ExpendableLightComponent>();
+            while (query.MoveNext(out var uid, out var light))
             {
-                UpdateLight(light, frameTime);
+                UpdateLight((uid, light), frameTime);
             }
         }
 
-        private void UpdateLight(ExpendableLightComponent component, float frameTime)
+        private void UpdateLight(Entity<ExpendableLightComponent> ent, float frameTime)
         {
-            if (!component.Activated) return;
+            var component = ent.Comp;
+            if (!component.Activated)
+                return;
 
             component.StateExpiryTime -= frameTime;
 
@@ -56,25 +57,25 @@ namespace Content.Server.Light.EntitySystems
                         component.CurrentState = ExpendableLightState.Fading;
                         component.StateExpiryTime = component.FadeOutDuration;
 
-                        UpdateVisualizer(component);
+                        UpdateVisualizer(ent);
 
                         break;
 
                     default:
                     case ExpendableLightState.Fading:
                         component.CurrentState = ExpendableLightState.Dead;
-                        var meta = MetaData(component.Owner);
-                        _metaData.SetEntityName(component.Owner, Loc.GetString(component.SpentName), meta);
-                        _metaData.SetEntityDescription(component.Owner, Loc.GetString(component.SpentDesc), meta);
+                        var meta = MetaData(ent);
+                        _metaData.SetEntityName(ent, Loc.GetString(component.SpentName), meta);
+                        _metaData.SetEntityDescription(ent, Loc.GetString(component.SpentDesc), meta);
 
-                        _tagSystem.AddTag(component.Owner, "Trash");
+                        _tagSystem.AddTag(ent, "Trash");
 
-                        UpdateSounds(component);
-                        UpdateVisualizer(component);
+                        UpdateSounds(ent);
+                        UpdateVisualizer(ent);
 
-                        if (TryComp<ItemComponent>(component.Owner, out var item))
+                        if (TryComp<ItemComponent>(ent, out var item))
                         {
-                            _item.SetHeldPrefix(component.Owner, "unlit", item);
+                            _item.SetHeldPrefix(ent, "unlit", item);
                         }
 
                         break;
@@ -85,20 +86,21 @@ namespace Content.Server.Light.EntitySystems
         /// <summary>
         ///     Enables the light if it is not active. Once active it cannot be turned off.
         /// </summary>
-        public bool TryActivate(ExpendableLightComponent component)
+        public bool TryActivate(Entity<ExpendableLightComponent> ent)
         {
+            var component = ent.Comp;
             if (!component.Activated && component.CurrentState == ExpendableLightState.BrandNew)
             {
-                if (TryComp<ItemComponent>(component.Owner, out var item))
+                if (TryComp<ItemComponent>(ent, out var item))
                 {
-                    _item.SetHeldPrefix(component.Owner, "lit", item);
+                    _item.SetHeldPrefix(ent, "lit", item);
                 }
 
                 component.CurrentState = ExpendableLightState.Lit;
                 component.StateExpiryTime = component.GlowDuration;
 
-                UpdateSounds(component);
-                UpdateVisualizer(component);
+                UpdateSounds(ent);
+                UpdateVisualizer(ent);
 
                 return true;
             }
@@ -106,49 +108,51 @@ namespace Content.Server.Light.EntitySystems
             return false;
         }
 
-        private void UpdateVisualizer(ExpendableLightComponent component, AppearanceComponent? appearance = null)
+        private void UpdateVisualizer(Entity<ExpendableLightComponent> ent, AppearanceComponent? appearance = null)
         {
-            if (!Resolve(component.Owner, ref appearance, false)) return;
+            var component = ent.Comp;
+            if (!Resolve(ent, ref appearance, false))
+                return;
 
-            _appearance.SetData(appearance.Owner, ExpendableLightVisuals.State, component.CurrentState, appearance);
+            _appearance.SetData(ent, ExpendableLightVisuals.State, component.CurrentState, appearance);
 
             switch (component.CurrentState)
             {
                 case ExpendableLightState.Lit:
-                    _appearance.SetData(appearance.Owner, ExpendableLightVisuals.Behavior, component.TurnOnBehaviourID, appearance);
+                    _appearance.SetData(ent, ExpendableLightVisuals.Behavior, component.TurnOnBehaviourID, appearance);
                     break;
 
                 case ExpendableLightState.Fading:
-                    _appearance.SetData(appearance.Owner, ExpendableLightVisuals.Behavior, component.FadeOutBehaviourID, appearance);
+                    _appearance.SetData(ent, ExpendableLightVisuals.Behavior, component.FadeOutBehaviourID, appearance);
                     break;
 
                 case ExpendableLightState.Dead:
-                    _appearance.SetData(appearance.Owner, ExpendableLightVisuals.Behavior, string.Empty, appearance);
+                    _appearance.SetData(ent, ExpendableLightVisuals.Behavior, string.Empty, appearance);
                     var isHotEvent = new IsHotEvent() {IsHot = true};
-                    RaiseLocalEvent(component.Owner, isHotEvent);
+                    RaiseLocalEvent(ent, isHotEvent);
                     break;
             }
         }
 
-        private void UpdateSounds(ExpendableLightComponent component)
+        private void UpdateSounds(Entity<ExpendableLightComponent> ent)
         {
-            var uid = component.Owner;
+            var component = ent.Comp;
 
             switch (component.CurrentState)
             {
                 case ExpendableLightState.Lit:
-                    _audio.PlayPvs(component.LitSound, uid);
+                    _audio.PlayPvs(component.LitSound, ent);
                     break;
                 case ExpendableLightState.Fading:
                     break;
                 default:
-                    _audio.PlayPvs(component.DieSound, uid);
+                    _audio.PlayPvs(component.DieSound, ent);
                     break;
             }
 
-            if (TryComp<ClothingComponent>(uid, out var clothing))
+            if (TryComp<ClothingComponent>(ent, out var clothing))
             {
-                _clothing.SetEquippedPrefix(uid, component.Activated ? "Activated" : string.Empty, clothing);
+                _clothing.SetEquippedPrefix(ent, component.Activated ? "Activated" : string.Empty, clothing);
             }
         }
 
@@ -163,21 +167,23 @@ namespace Content.Server.Light.EntitySystems
             EntityManager.EnsureComponent<PointLightComponent>(uid);
         }
 
-        private void OnExpLightUse(EntityUid uid, ExpendableLightComponent component, UseInHandEvent args)
+        private void OnExpLightUse(Entity<ExpendableLightComponent> ent, ref UseInHandEvent args)
         {
-            if (args.Handled) return;
+            if (args.Handled)
+                return;
+
             var isHotEvent = new IsHotEvent() {IsHot = true};
-            RaiseLocalEvent(uid, isHotEvent);
-            if (TryActivate(component))
+            RaiseLocalEvent(ent, isHotEvent);
+            if (TryActivate(ent))
                 args.Handled = true;
         }
 
-        private void AddIgniteVerb(EntityUid uid, ExpendableLightComponent component, GetVerbsEvent<ActivationVerb> args)
+        private void AddIgniteVerb(Entity<ExpendableLightComponent> ent, ref GetVerbsEvent<ActivationVerb> args)
         {
             if (!args.CanAccess || !args.CanInteract)
                 return;
 
-            if (component.CurrentState != ExpendableLightState.BrandNew)
+            if (ent.Comp.CurrentState != ExpendableLightState.BrandNew)
                 return;
 
             // Ignite the flare or make the glowstick glow.
@@ -186,7 +192,7 @@ namespace Content.Server.Light.EntitySystems
             {
                 Text = Loc.GetString("expendable-light-start-verb"),
                 Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/light.svg.192dpi.png")),
-                Act = () => TryActivate(component)
+                Act = () => TryActivate(ent)
             };
             args.Verbs.Add(verb);
         }
index ff3c61bc6110cba2290813d45c1c347299dfe6e8..f3e7eaca0eab6ba1563f7086e586e09aa18dea5e 100644 (file)
@@ -9,18 +9,14 @@ using Content.Shared.Light.Components;
 using Content.Shared.Rounding;
 using Content.Shared.Toggleable;
 using Content.Shared.Verbs;
-using JetBrains.Annotations;
-using Robust.Server.GameObjects;
 using Robust.Shared.Containers;
 using Robust.Shared.GameStates;
-using Robust.Shared.Prototypes;
 using Robust.Shared.Utility;
 
 namespace Content.Server.Light.EntitySystems
 {
     public sealed class HandheldLightSystem : SharedHandheldLightSystem
     {
-        [Dependency] private readonly IPrototypeManager _proto = default!;
         [Dependency] private readonly ActionsSystem _actions = default!;
         [Dependency] private readonly ActionContainerSystem _actionContainer = default!;
         [Dependency] private readonly PopupSystem _popup = default!;
@@ -31,7 +27,7 @@ namespace Content.Server.Light.EntitySystems
 
         // TODO: Ideally you'd be able to subscribe to power stuff to get events at certain percentages.. or something?
         // But for now this will be better anyway.
-        private readonly HashSet<HandheldLightComponent> _activeLights = new();
+        private readonly HashSet<Entity<HandheldLightComponent>> _activeLights = new();
 
         public override void Initialize()
         {
@@ -55,22 +51,16 @@ namespace Content.Server.Light.EntitySystems
             SubscribeLocalEvent<HandheldLightComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
         }
 
-        private void OnEntInserted(
-            EntityUid uid,
-            HandheldLightComponent component,
-            EntInsertedIntoContainerMessage args)
+        private void OnEntInserted(Entity<HandheldLightComponent> ent, ref EntInsertedIntoContainerMessage args)
         {
             // Not guaranteed to be the correct container for our slot, I don't care.
-            UpdateLevel(uid, component);
+            UpdateLevel(ent);
         }
 
-        private void OnEntRemoved(
-            EntityUid uid,
-            HandheldLightComponent component,
-            EntRemovedFromContainerMessage args)
+        private void OnEntRemoved(Entity<HandheldLightComponent> ent, ref EntRemovedFromContainerMessage args)
         {
             // Ditto above
-            UpdateLevel(uid, component);
+            UpdateLevel(ent);
         }
 
         private void OnGetActions(EntityUid uid, HandheldLightComponent component, GetItemActionsEvent args)
@@ -78,28 +68,29 @@ namespace Content.Server.Light.EntitySystems
             args.AddAction(ref component.ToggleActionEntity, component.ToggleAction);
         }
 
-        private void OnToggleAction(EntityUid uid, HandheldLightComponent component, ToggleActionEvent args)
+        private void OnToggleAction(Entity<HandheldLightComponent> ent, ref ToggleActionEvent args)
         {
             if (args.Handled)
                 return;
 
-            if (component.Activated)
-                TurnOff(uid, component);
+            if (ent.Comp.Activated)
+                TurnOff(ent);
             else
-                TurnOn(args.Performer, uid, component);
+                TurnOn(args.Performer, ent);
 
             args.Handled = true;
         }
 
-        private void OnGetState(EntityUid uid, HandheldLightComponent component, ref ComponentGetState args)
+        private void OnGetState(Entity<HandheldLightComponent> ent, ref ComponentGetState args)
         {
-            args.State = new HandheldLightComponent.HandheldLightComponentState(component.Activated, GetLevel(uid, component));
+            args.State = new HandheldLightComponent.HandheldLightComponentState(ent.Comp.Activated, GetLevel(ent));
         }
 
-        private void OnMapInit(EntityUid uid, HandheldLightComponent component, MapInitEvent args)
+        private void OnMapInit(Entity<HandheldLightComponent> ent, ref MapInitEvent args)
         {
-            _actionContainer.EnsureAction(uid, ref component.ToggleActionEntity, component.ToggleAction);
-            _actions.AddAction(uid, ref component.SelfToggleActionEntity, component.ToggleAction);
+            var component = ent.Comp;
+            _actionContainer.EnsureAction(ent, ref component.ToggleActionEntity, component.ToggleAction);
+            _actions.AddAction(ent, ref component.SelfToggleActionEntity, component.ToggleAction);
         }
 
         private void OnShutdown(EntityUid uid, HandheldLightComponent component, ComponentShutdown args)
@@ -108,31 +99,31 @@ namespace Content.Server.Light.EntitySystems
             _actions.RemoveAction(uid, component.SelfToggleActionEntity);
         }
 
-        private byte? GetLevel(EntityUid uid, HandheldLightComponent component)
+        private byte? GetLevel(Entity<HandheldLightComponent> ent)
         {
             // Curently every single flashlight has the same number of levels for status and that's all it uses the charge for
             // Thus we'll just check if the level changes.
 
-            if (!_powerCell.TryGetBatteryFromSlot(uid, out var battery))
+            if (!_powerCell.TryGetBatteryFromSlot(ent, out var battery))
                 return null;
 
-            if (MathHelper.CloseToPercent(battery.CurrentCharge, 0) || component.Wattage > battery.CurrentCharge)
+            if (MathHelper.CloseToPercent(battery.CurrentCharge, 0) || ent.Comp.Wattage > battery.CurrentCharge)
                 return 0;
 
             return (byte?) ContentHelpers.RoundToNearestLevels(battery.CurrentCharge / battery.MaxCharge * 255, 255, HandheldLightComponent.StatusLevels);
         }
 
-        private void OnRemove(EntityUid uid, HandheldLightComponent component, ComponentRemove args)
+        private void OnRemove(Entity<HandheldLightComponent> ent, ref ComponentRemove args)
         {
-            _activeLights.Remove(component);
+            _activeLights.Remove(ent);
         }
 
-        private void OnActivate(EntityUid uid, HandheldLightComponent component, ActivateInWorldEvent args)
+        private void OnActivate(Entity<HandheldLightComponent> ent, ref ActivateInWorldEvent args)
         {
-            if (args.Handled || !component.ToggleOnInteract)
+            if (args.Handled || !ent.Comp.ToggleOnInteract)
                 return;
 
-            if (ToggleStatus(args.User, uid, component))
+            if (ToggleStatus(args.User, ent))
                 args.Handled = true;
         }
 
@@ -140,9 +131,9 @@ namespace Content.Server.Light.EntitySystems
         ///     Illuminates the light if it is not active, extinguishes it if it is active.
         /// </summary>
         /// <returns>True if the light's status was toggled, false otherwise.</returns>
-        public bool ToggleStatus(EntityUid user, EntityUid uid, HandheldLightComponent component)
+        public bool ToggleStatus(EntityUid user, Entity<HandheldLightComponent> ent)
         {
-            return component.Activated ? TurnOff(uid, component) : TurnOn(user, uid, component);
+            return ent.Comp.Activated ? TurnOff(ent) : TurnOn(user, ent);
         }
 
         private void OnExamine(EntityUid uid, HandheldLightComponent component, ExaminedEvent args)
@@ -160,20 +151,20 @@ namespace Content.Server.Light.EntitySystems
 
         public override void Update(float frameTime)
         {
-            var toRemove = new RemQueue<HandheldLightComponent>();
+            var toRemove = new RemQueue<Entity<HandheldLightComponent>>();
 
             foreach (var handheld in _activeLights)
             {
-                var uid = handheld.Owner;
-
-                if (handheld.Deleted)
+                if (handheld.Comp.Deleted)
                 {
                     toRemove.Add(handheld);
                     continue;
                 }
 
-                if (Paused(uid)) continue;
-                TryUpdate(uid, handheld, frameTime);
+                if (Paused(handheld))
+                    continue;
+
+                TryUpdate(handheld, frameTime);
             }
 
             foreach (var light in toRemove)
@@ -182,39 +173,41 @@ namespace Content.Server.Light.EntitySystems
             }
         }
 
-        private void AddToggleLightVerb(EntityUid uid, HandheldLightComponent component, GetVerbsEvent<ActivationVerb> args)
+        private void AddToggleLightVerb(Entity<HandheldLightComponent> ent, ref GetVerbsEvent<ActivationVerb> args)
         {
-            if (!args.CanAccess || !args.CanInteract || !component.ToggleOnInteract)
+            if (!args.CanAccess || !args.CanInteract || !ent.Comp.ToggleOnInteract)
                 return;
 
+            var @event = args;
             ActivationVerb verb = new()
             {
                 Text = Loc.GetString("verb-common-toggle-light"),
                 Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/light.svg.192dpi.png")),
-                Act = component.Activated
-                    ? () => TurnOff(uid, component)
-                    : () => TurnOn(args.User, uid,  component)
+                Act = ent.Comp.Activated
+                    ? () => TurnOff(ent)
+                    : () => TurnOn(@event.User, ent)
             };
 
             args.Verbs.Add(verb);
         }
 
-        public bool TurnOff(EntityUid uid, HandheldLightComponent component, bool makeNoise = true)
+        public bool TurnOff(Entity<HandheldLightComponent> ent, bool makeNoise = true)
         {
-            if (!component.Activated || !_lights.TryGetLight(uid, out var pointLightComponent))
+            if (!ent.Comp.Activated || !_lights.TryGetLight(ent, out var pointLightComponent))
             {
                 return false;
             }
 
-            _lights.SetEnabled(uid, false, pointLightComponent);
-            SetActivated(uid, false, component, makeNoise);
-            component.Level = null;
-            _activeLights.Remove(component);
+            _lights.SetEnabled(ent, false, pointLightComponent);
+            SetActivated(ent, false, ent, makeNoise);
+            ent.Comp.Level = null;
+            _activeLights.Remove(ent);
             return true;
         }
 
-        public bool TurnOn(EntityUid user, EntityUid uid, HandheldLightComponent component)
+        public bool TurnOn(EntityUid user, Entity<HandheldLightComponent> uid)
         {
+            var component = uid.Comp;
             if (component.Activated || !_lights.TryGetLight(uid, out var pointLightComponent))
             {
                 return false;
@@ -240,17 +233,18 @@ namespace Content.Server.Light.EntitySystems
 
             _lights.SetEnabled(uid, true, pointLightComponent);
             SetActivated(uid, true, component, true);
-            _activeLights.Add(component);
+            _activeLights.Add(uid);
 
             return true;
         }
 
-        public void TryUpdate(EntityUid uid, HandheldLightComponent component, float frameTime)
+        public void TryUpdate(Entity<HandheldLightComponent> uid, float frameTime)
         {
+            var component = uid.Comp;
             if (!_powerCell.TryGetBatteryFromSlot(uid, out var battery) &&
                 !TryComp(uid, out battery))
             {
-                TurnOff(uid, component, false);
+                TurnOff(uid, false);
                 return;
             }
 
@@ -271,20 +265,20 @@ namespace Content.Server.Light.EntitySystems
             }
 
             if (component.Activated && !battery.TryUseCharge(component.Wattage * frameTime))
-                TurnOff(uid, component, false);
+                TurnOff(uid, false);
 
-            UpdateLevel(uid, component);
+            UpdateLevel(uid);
         }
 
-        private void UpdateLevel(EntityUid uid, HandheldLightComponent comp)
+        private void UpdateLevel(Entity<HandheldLightComponent> ent)
         {
-            var level = GetLevel(uid, comp);
+            var level = GetLevel(ent);
 
-            if (level == comp.Level)
+            if (level == ent.Comp.Level)
                 return;
 
-            comp.Level = level;
-            Dirty(comp);
+            ent.Comp.Level = level;
+            Dirty(ent);
         }
     }
 }
index 606b2c00220f7131a5ac09d6ed7b2d2cd74dabbe..9a73e44f8783af8a48da869bd5a78d3fb00a34a5 100644 (file)
@@ -21,7 +21,7 @@ namespace Content.Server.Light.EntitySystems
                 && EntityManager.TryGetComponent(args.Used, out MatchstickComponent? matchstick)
                 && matchstick.CurrentState == SmokableState.Unlit)
             {
-                _stickSystem.Ignite(args.Used, matchstick, args.User);
+                _stickSystem.Ignite((args.Used, matchstick), args.User);
                 args.Handled = true;
             }
         }
index 7fe8aa92376601a32ede8db244ccfa067380d948..88f416ce9d46e577f34c057ab1ff92a79576347f 100644 (file)
@@ -19,7 +19,7 @@ namespace Content.Server.Light.EntitySystems
         [Dependency] private readonly SharedPointLightSystem _lights = default!;
         [Dependency] private readonly TransformSystem _transformSystem = default!;
 
-        private HashSet<MatchstickComponent> _litMatches = new();
+        private readonly HashSet<Entity<MatchstickComponent>> _litMatches = new();
 
         public override void Initialize()
         {
@@ -29,42 +29,43 @@ namespace Content.Server.Light.EntitySystems
             SubscribeLocalEvent<MatchstickComponent, ComponentShutdown>(OnShutdown);
         }
 
-        private void OnShutdown(EntityUid uid, MatchstickComponent component, ComponentShutdown args)
+        private void OnShutdown(Entity<MatchstickComponent> ent, ref ComponentShutdown args)
         {
-            _litMatches.Remove(component);
+            _litMatches.Remove(ent);
         }
 
         public override void Update(float frameTime)
         {
             base.Update(frameTime);
+
             foreach (var match in _litMatches)
             {
-                if (match.CurrentState != SmokableState.Lit || Paused(match.Owner) || match.Deleted)
+                if (match.Comp.CurrentState != SmokableState.Lit || Paused(match) || match.Comp.Deleted)
                     continue;
 
-                var xform = Transform(match.Owner);
+                var xform = Transform(match);
 
                 if (xform.GridUid is not {} gridUid)
                     return;
 
-                var position = _transformSystem.GetGridOrMapTilePosition(match.Owner, xform);
+                var position = _transformSystem.GetGridOrMapTilePosition(match, xform);
 
-                _atmosphereSystem.HotspotExpose(gridUid, position, 400, 50, match.Owner, true);
+                _atmosphereSystem.HotspotExpose(gridUid, position, 400, 50, match, true);
             }
         }
 
-        private void OnInteractUsing(EntityUid uid, MatchstickComponent component, InteractUsingEvent args)
+        private void OnInteractUsing(Entity<MatchstickComponent> ent, ref InteractUsingEvent args)
         {
-            if (args.Handled || component.CurrentState != SmokableState.Unlit)
+            if (args.Handled || ent.Comp.CurrentState != SmokableState.Unlit)
                 return;
 
             var isHotEvent = new IsHotEvent();
-            RaiseLocalEvent(args.Used, isHotEvent, false);
+            RaiseLocalEvent(args.Used, isHotEvent);
 
             if (!isHotEvent.IsHot)
                 return;
 
-            Ignite(uid, component, args.User);
+            Ignite(ent, args.User);
             args.Handled = true;
         }
 
@@ -73,19 +74,21 @@ namespace Content.Server.Light.EntitySystems
             args.IsHot = component.CurrentState == SmokableState.Lit;
         }
 
-        public void Ignite(EntityUid uid, MatchstickComponent component, EntityUid user)
+        public void Ignite(Entity<MatchstickComponent> matchstick, EntityUid user)
         {
+            var component = matchstick.Comp;
+
             // Play Sound
-            SoundSystem.Play(component.IgniteSound.GetSound(), Filter.Pvs(component.Owner),
-                component.Owner, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
+            SoundSystem.Play(component.IgniteSound.GetSound(), Filter.Pvs(matchstick),
+                matchstick, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
 
             // Change state
-            SetState(uid, component, SmokableState.Lit);
-            _litMatches.Add(component);
-            component.Owner.SpawnTimer(component.Duration * 1000, delegate
+            SetState(matchstick, component, SmokableState.Lit);
+            _litMatches.Add(matchstick);
+            matchstick.Owner.SpawnTimer(component.Duration * 1000, delegate
             {
-                SetState(uid, component, SmokableState.Burnt);
-                _litMatches.Remove(component);
+                SetState(matchstick, component, SmokableState.Burnt);
+                _litMatches.Remove(matchstick);
             });
         }
 
index 69d9b669557bf2da58b994516f037e5b7fefe382..cd4322aa26720cf06ebd60f3b5c63bba8bde5835 100644 (file)
@@ -1,16 +1,20 @@
 using Content.Server.Administration.Logs;
 using Content.Server.Clothing.Components;
+using Content.Server.DeviceLinking.Events;
+using Content.Server.DeviceLinking.Systems;
 using Content.Server.DeviceNetwork;
 using Content.Server.DeviceNetwork.Systems;
+using Content.Server.Emp;
 using Content.Server.Ghost;
 using Content.Server.Light.Components;
 using Content.Server.Power.Components;
-using Content.Server.Temperature.Components;
 using Content.Shared.Audio;
 using Content.Shared.Damage;
 using Content.Shared.Database;
+using Content.Shared.DoAfter;
 using Content.Shared.Hands.EntitySystems;
 using Content.Shared.Interaction;
+using Content.Shared.Inventory;
 using Content.Shared.Light;
 using Content.Shared.Light.Components;
 using Content.Shared.Popups;
@@ -19,11 +23,6 @@ using Robust.Shared.Audio;
 using Robust.Shared.Containers;
 using Robust.Shared.Player;
 using Robust.Shared.Timing;
-using Content.Shared.DoAfter;
-using Content.Server.Emp;
-using Content.Server.DeviceLinking.Events;
-using Content.Server.DeviceLinking.Systems;
-using Content.Shared.Inventory;
 
 namespace Content.Server.Light.EntitySystems
 {
@@ -333,7 +332,7 @@ namespace Content.Server.Light.EntitySystems
             light.LastGhostBlink = time;
 
             ToggleBlinkingLight(uid, light, true);
-            light.Owner.SpawnTimer(light.GhostBlinkingTime, () =>
+            uid.SpawnTimer(light.GhostBlinkingTime, () =>
             {
                 ToggleBlinkingLight(uid, light, false);
             });
index 9cca5fa32cc2c4c9cdae4e91b33e4344ae6809de..4fbd9e3ec78de57802d49cf032e13f1fbc81737a 100644 (file)
@@ -16,13 +16,13 @@ using Content.Shared.Magic;
 using Content.Shared.Magic.Events;
 using Content.Shared.Maps;
 using Content.Shared.Physics;
-using Robust.Shared.Spawners;
 using Content.Shared.Storage;
 using Robust.Server.GameObjects;
 using Robust.Shared.Audio;
 using Robust.Shared.Map;
 using Robust.Shared.Random;
 using Robust.Shared.Serialization.Manager;
+using Robust.Shared.Spawners;
 
 namespace Content.Server.Magic;
 
@@ -309,7 +309,7 @@ public sealed class MagicSystem : EntitySystem
                 _boltsSystem.SetBoltsDown(entity, bolts, false);
 
             if (TryComp<DoorComponent>(entity, out var doorComp) && doorComp.State is not DoorState.Open)
-                _doorSystem.StartOpening(doorComp.Owner);
+                _doorSystem.StartOpening(entity);
         }
     }
 
index f5b17fefb898446b579830d3074c8cf75f284a22..98bfe702b6aa4bb1f7bba142c48d65bac931c64f 100644 (file)
@@ -1,25 +1,24 @@
+using System.Linq;
+using Content.Server.Administration.Logs;
+using Content.Server.CartridgeLoader;
+using Content.Server.CartridgeLoader.Cartridges;
+using Content.Server.GameTicking;
 using Content.Server.MassMedia.Components;
 using Content.Server.PDA.Ringer;
+using Content.Server.Popups;
+using Content.Server.StationRecords.Systems;
 using Content.Shared.Access.Components;
 using Content.Shared.Access.Systems;
+using Content.Shared.CartridgeLoader;
+using Content.Shared.CartridgeLoader.Cartridges;
+using Content.Shared.Database;
 using Content.Shared.GameTicking;
 using Content.Shared.MassMedia.Components;
 using Content.Shared.MassMedia.Systems;
 using Content.Shared.PDA;
 using Robust.Server.GameObjects;
-using System.Linq;
-using Content.Server.Administration.Logs;
-using Content.Server.CartridgeLoader.Cartridges;
-using Content.Shared.CartridgeLoader;
-using Content.Shared.CartridgeLoader.Cartridges;
-using Content.Server.CartridgeLoader;
-using Content.Server.GameTicking;
-using Robust.Shared.Timing;
-using Content.Server.Popups;
-using Content.Server.StationRecords.Systems;
-using Content.Shared.Database;
 using Robust.Shared.Containers;
-using Robust.Shared.Utility;
+using Robust.Shared.Timing;
 
 namespace Content.Server.MassMedia.Systems;
 
@@ -222,7 +221,7 @@ public sealed class NewsSystem : EntitySystem
         while (query.MoveNext(out var owner, out var comp))
         {
             if (EntityManager.TryGetComponent<NewsReadCartridgeComponent>(comp.ActiveProgram, out var cartridge))
-                UpdateReadUi(cartridge.Owner, comp.Owner, cartridge);
+                UpdateReadUi(comp.ActiveProgram.Value, owner, cartridge);
         }
     }
 
@@ -267,14 +266,14 @@ public sealed class NewsSystem : EntitySystem
         base.Update(frameTime);
 
         var query = EntityQueryEnumerator<NewsWriteComponent>();
-        while (query.MoveNext(out var comp))
+        while (query.MoveNext(out var uid, out var comp))
         {
             if (comp.ShareAvalible || _timing.CurTime < comp.NextShare)
                 continue;
 
             comp.ShareAvalible = true;
 
-            UpdateWriteUi(comp.Owner, comp);
+            UpdateWriteUi(uid, comp);
         }
     }
 }
index 930a2afbd1582ab5d40f69396e01d983c5a0980d..3de151ba705f521ebc2819a3e4dec3230236b2e6 100644 (file)
@@ -3,7 +3,6 @@ using Content.Server.Atmos.Piping.Components;
 using Content.Server.Mech.Components;
 using Content.Shared.Atmos;
 using Content.Shared.Mech.Components;
-using Robust.Shared.GameObjects;
 
 namespace Content.Server.Mech.Systems;
 
@@ -58,9 +57,9 @@ public sealed partial class MechSystem
 
         var coordinates = Transform(uid).MapPosition;
         GasMixture? destination = null;
-        if (_map.TryFindGridAt(coordinates, out _, out var grid))
+        if (_map.TryFindGridAt(coordinates, out var gridId, out var grid))
         {
-            var tile = grid.GetTileRef(coordinates);
+            var tile = _mapSystem.GetTileRef(gridId, grid, coordinates);
             destination = _atmosphere.GetTileMixture(tile.GridUid, null, tile.GridIndices, true);
         }
 
index 8c34f875bfe00357f4e0655ac683846a3bb445e7..fd8f8fd76790e59aaac0b55cf69b24f006fd585c 100644 (file)
@@ -32,6 +32,7 @@ public sealed partial class MechSystem : SharedMechSystem
     [Dependency] private readonly ContainerSystem _container = default!;
     [Dependency] private readonly DamageableSystem _damageable = default!;
     [Dependency] private readonly IMapManager _map = default!;
+    [Dependency] private readonly MapSystem _mapSystem = default!;
     [Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
     [Dependency] private readonly SharedPopupSystem _popup = default!;
     [Dependency] private readonly UserInterfaceSystem _ui = default!;
index 45f8d2ed98325d9462396faf1bed0ebd3c40749e..f16d13c23cbac80ec30ac77181b5097491c4de34 100644 (file)
@@ -51,7 +51,8 @@ namespace Content.Server.Medical.BiomassReclaimer
         {
             base.Update(frameTime);
 
-            foreach (var (_, reclaimer) in EntityQuery<ActiveBiomassReclaimerComponent, BiomassReclaimerComponent>())
+            var query = EntityQueryEnumerator<ActiveBiomassReclaimerComponent, BiomassReclaimerComponent>();
+            while (query.MoveNext(out var uid, out var _, out var reclaimer))
             {
                 reclaimer.ProcessingTimer -= frameTime;
                 reclaimer.RandomMessTimer -= frameTime;
@@ -62,11 +63,11 @@ namespace Content.Server.Medical.BiomassReclaimer
                     {
                         Solution blood = new();
                         blood.AddReagent(reclaimer.BloodReagent, 50);
-                        _puddleSystem.TrySpillAt(reclaimer.Owner, blood, out _);
+                        _puddleSystem.TrySpillAt(uid, blood, out _);
                     }
                     if (_robustRandom.Prob(0.03f) && reclaimer.SpawnedEntities.Count > 0)
                     {
-                        var thrown = Spawn(_robustRandom.Pick(reclaimer.SpawnedEntities).PrototypeId, Transform(reclaimer.Owner).Coordinates);
+                        var thrown = Spawn(_robustRandom.Pick(reclaimer.SpawnedEntities).PrototypeId, Transform(uid).Coordinates);
                         var direction = new Vector2(_robustRandom.Next(-30, 30), _robustRandom.Next(-30, 30));
                         _throwing.TryThrow(thrown, direction, _robustRandom.Next(1, 10));
                     }
@@ -78,11 +79,11 @@ namespace Content.Server.Medical.BiomassReclaimer
                     continue;
                 }
 
-                _material.SpawnMultipleFromMaterial(reclaimer.CurrentExpectedYield, "Biomass", Transform(reclaimer.Owner).Coordinates);
+                _material.SpawnMultipleFromMaterial(reclaimer.CurrentExpectedYield, "Biomass", Transform(uid).Coordinates);
 
                 reclaimer.BloodReagent = null;
                 reclaimer.SpawnedEntities.Clear();
-                RemCompDeferred<ActiveBiomassReclaimerComponent>(reclaimer.Owner);
+                RemCompDeferred<ActiveBiomassReclaimerComponent>(uid);
             }
         }
         public override void Initialize()
@@ -100,19 +101,19 @@ namespace Content.Server.Medical.BiomassReclaimer
             SubscribeLocalEvent<BiomassReclaimerComponent, ReclaimerDoAfterEvent>(OnDoAfter);
         }
 
-        private void OnSuicide(EntityUid uid, BiomassReclaimerComponent component, SuicideEvent args)
+        private void OnSuicide(Entity<BiomassReclaimerComponent> ent, ref SuicideEvent args)
         {
             if (args.Handled)
                 return;
 
-            if (HasComp<ActiveBiomassReclaimerComponent>(uid))
+            if (HasComp<ActiveBiomassReclaimerComponent>(ent))
                 return;
 
-            if (TryComp<ApcPowerReceiverComponent>(uid, out var power) && !power.Powered)
+            if (TryComp<ApcPowerReceiverComponent>(ent, out var power) && !power.Powered)
                 return;
 
-            _popup.PopupEntity(Loc.GetString("biomass-reclaimer-suicide-others", ("victim", args.Victim)), uid, PopupType.LargeCaution);
-            StartProcessing(args.Victim, component);
+            _popup.PopupEntity(Loc.GetString("biomass-reclaimer-suicide-others", ("victim", args.Victim)), ent, PopupType.LargeCaution);
+            StartProcessing(args.Victim, ent);
             args.SetHandled(SuicideKind.Blunt);
         }
 
@@ -137,22 +138,22 @@ namespace Content.Server.Medical.BiomassReclaimer
                     EnsureComp<ActiveBiomassReclaimerComponent>(uid);
             }
             else
-                RemComp<ActiveBiomassReclaimerComponent>(component.Owner);
+                RemComp<ActiveBiomassReclaimerComponent>(uid);
         }
 
         private void OnUnanchorAttempt(EntityUid uid, ActiveBiomassReclaimerComponent component, UnanchorAttemptEvent args)
         {
             args.Cancel();
         }
-        private void OnAfterInteractUsing(EntityUid uid, BiomassReclaimerComponent component, AfterInteractUsingEvent args)
+        private void OnAfterInteractUsing(Entity<BiomassReclaimerComponent> reclaimer, ref AfterInteractUsingEvent args)
         {
             if (!args.CanReach || args.Target == null)
                 return;
 
-            if (!HasComp<MobStateComponent>(args.Used) || !CanGib(uid, args.Used, component))
+            if (!HasComp<MobStateComponent>(args.Used) || !CanGib(reclaimer, args.Used))
                 return;
 
-            _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, 7f, new ReclaimerDoAfterEvent(), uid, target: args.Target, used: args.Used)
+            _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, 7f, new ReclaimerDoAfterEvent(), reclaimer, target: args.Target, used: args.Used)
             {
                 BreakOnTargetMove = true,
                 BreakOnUserMove = true,
@@ -160,17 +161,17 @@ namespace Content.Server.Medical.BiomassReclaimer
             });
         }
 
-        private void OnClimbedOn(EntityUid uid, BiomassReclaimerComponent component, ref ClimbedOnEvent args)
+        private void OnClimbedOn(Entity<BiomassReclaimerComponent> reclaimer, ref ClimbedOnEvent args)
         {
-            if (!CanGib(uid, args.Climber, component))
+            if (!CanGib(reclaimer, args.Climber))
             {
                 var direction = new Vector2(_robustRandom.Next(-2, 2), _robustRandom.Next(-2, 2));
                 _throwing.TryThrow(args.Climber, direction, 0.5f);
                 return;
             }
-            _adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{ToPrettyString(args.Instigator):player} used a biomass reclaimer to gib {ToPrettyString(args.Climber):target} in {ToPrettyString(uid):reclaimer}");
+            _adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{ToPrettyString(args.Instigator):player} used a biomass reclaimer to gib {ToPrettyString(args.Climber):target} in {ToPrettyString(reclaimer):reclaimer}");
 
-            StartProcessing(args.Climber, component);
+            StartProcessing(args.Climber, reclaimer);
         }
 
         private void OnRefreshParts(EntityUid uid, BiomassReclaimerComponent component, RefreshPartsEvent args)
@@ -193,23 +194,24 @@ namespace Content.Server.Medical.BiomassReclaimer
             args.AddPercentageUpgrade("biomass-reclaimer-component-upgrade-biomass-yield", component.YieldPerUnitMass / component.BaseYieldPerUnitMass);
         }
 
-        private void OnDoAfter(EntityUid uid, BiomassReclaimerComponent component, DoAfterEvent args)
+        private void OnDoAfter(Entity<BiomassReclaimerComponent> reclaimer, ref ReclaimerDoAfterEvent args)
         {
             if (args.Handled || args.Cancelled || args.Args.Target == null || HasComp<BiomassReclaimerComponent>(args.Args.Target.Value))
                 return;
 
-            _adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{ToPrettyString(args.Args.User):player} used a biomass reclaimer to gib {ToPrettyString(args.Args.Target.Value):target} in {ToPrettyString(uid):reclaimer}");
-            StartProcessing(args.Args.Target.Value, component);
+            _adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{ToPrettyString(args.Args.User):player} used a biomass reclaimer to gib {ToPrettyString(args.Args.Target.Value):target} in {ToPrettyString(reclaimer):reclaimer}");
+            StartProcessing(args.Args.Target.Value, reclaimer);
 
             args.Handled = true;
         }
 
-        private void StartProcessing(EntityUid toProcess, BiomassReclaimerComponent component, PhysicsComponent? physics = null)
+        private void StartProcessing(EntityUid toProcess, Entity<BiomassReclaimerComponent> ent, PhysicsComponent? physics = null)
         {
             if (!Resolve(toProcess, ref physics))
                 return;
 
-            AddComp<ActiveBiomassReclaimerComponent>(component.Owner);
+            var component = ent.Comp;
+            AddComp<ActiveBiomassReclaimerComponent>(ent);
 
             if (TryComp<BloodstreamComponent>(toProcess, out var stream))
             {
@@ -225,21 +227,21 @@ namespace Content.Server.Medical.BiomassReclaimer
             QueueDel(toProcess);
         }
 
-        private bool CanGib(EntityUid uid, EntityUid dragged, BiomassReclaimerComponent component)
+        private bool CanGib(Entity<BiomassReclaimerComponent> reclaimer, EntityUid dragged)
         {
-            if (HasComp<ActiveBiomassReclaimerComponent>(uid))
+            if (HasComp<ActiveBiomassReclaimerComponent>(reclaimer))
                 return false;
 
             if (!HasComp<MobStateComponent>(dragged))
                 return false;
 
-            if (!Transform(uid).Anchored)
+            if (!Transform(reclaimer).Anchored)
                 return false;
 
-            if (TryComp<ApcPowerReceiverComponent>(uid, out var power) && !power.Powered)
+            if (TryComp<ApcPowerReceiverComponent>(reclaimer, out var power) && !power.Powered)
                 return false;
 
-            if (component.SafetyEnabled && !_mobState.IsDead(dragged))
+            if (reclaimer.Comp.SafetyEnabled && !_mobState.IsDead(dragged))
                 return false;
 
             // Reject souled bodies in easy mode.
index 7dbaf03a2e0a80fe26cc9053b1f80544c678f6f1..b94d6de6de022a2588937ea6980eb524a644ca2f 100644 (file)
@@ -11,12 +11,14 @@ using Content.Server.NodeContainer.EntitySystems;
 using Content.Server.NodeContainer.NodeGroups;
 using Content.Server.NodeContainer.Nodes;
 using Content.Server.Power.Components;
+using Content.Server.Temperature.Components;
 using Content.Server.UserInterface;
 using Content.Shared.Chemistry;
 using Content.Shared.Chemistry.Components;
 using Content.Shared.Chemistry.Components.SolutionManager;
 using Content.Shared.Chemistry.EntitySystems;
 using Content.Shared.Chemistry.Reagent;
+using Content.Shared.Climbing.Systems;
 using Content.Shared.Containers.ItemSlots;
 using Content.Shared.Database;
 using Content.Shared.DoAfter;
@@ -30,8 +32,6 @@ using Content.Shared.Tools;
 using Content.Shared.Verbs;
 using Robust.Server.GameObjects;
 using Robust.Shared.Timing;
-using Content.Server.Temperature.Components;
-using Content.Shared.Climbing.Systems;
 
 namespace Content.Server.Medical;
 
@@ -83,18 +83,20 @@ public sealed partial class CryoPodSystem: SharedCryoPodSystem
         var itemSlotsQuery = GetEntityQuery<ItemSlotsComponent>();
         var fitsInDispenserQuery = GetEntityQuery<FitsInDispenserComponent>();
         var solutionContainerManagerQuery = GetEntityQuery<SolutionContainerManagerComponent>();
-        foreach (var (_, cryoPod) in EntityQuery<ActiveCryoPodComponent, CryoPodComponent>())
+        var query = EntityQueryEnumerator<ActiveCryoPodComponent, CryoPodComponent>();
+
+        while (query.MoveNext(out var uid, out _, out var cryoPod))
         {
-            metaDataQuery.TryGetComponent(cryoPod.Owner, out var metaDataComponent);
-            if (curTime < cryoPod.NextInjectionTime + _metaDataSystem.GetPauseTime(cryoPod.Owner, metaDataComponent))
+            metaDataQuery.TryGetComponent(uid, out var metaDataComponent);
+            if (curTime < cryoPod.NextInjectionTime + _metaDataSystem.GetPauseTime(uid, metaDataComponent))
                 continue;
             cryoPod.NextInjectionTime = curTime + TimeSpan.FromSeconds(cryoPod.BeakerTransferTime);
 
-            if (!itemSlotsQuery.TryGetComponent(cryoPod.Owner, out var itemSlotsComponent))
+            if (!itemSlotsQuery.TryGetComponent(uid, out var itemSlotsComponent))
             {
                 continue;
             }
-            var container = _itemSlotsSystem.GetItemOrNull(cryoPod.Owner, cryoPod.SolutionContainerName, itemSlotsComponent);
+            var container = _itemSlotsSystem.GetItemOrNull(uid, cryoPod.SolutionContainerName, itemSlotsComponent);
             var patient = cryoPod.BodyContainer.ContainedEntity;
             if (container != null
                 && container.Value.Valid
index ae28db3f29a3dff72b25ac74056f5dd2363ef649..f382d520ffe248a1740a198fd92b5a2d2ff5a89d 100644 (file)
@@ -304,10 +304,10 @@ namespace Content.Server.Medical.SuitSensors
             var userJob = Loc.GetString("suit-sensor-component-unknown-job");
             if (_idCardSystem.TryFindIdCard(sensor.User.Value, out var card))
             {
-                if (card.FullName != null)
-                    userName = card.FullName;
-                if (card.JobTitle != null)
-                    userJob = card.JobTitle;
+                if (card.Comp.FullName != null)
+                    userName = card.Comp.FullName;
+                if (card.Comp.JobTitle != null)
+                    userJob = card.Comp.JobTitle;
             }
 
             // get health mob state
index afdd1caf9b88882d3f74fcca408d2ed6bc28db9e..5674da4ffd34051cae6dfca5cec15f210dc70391 100644 (file)
@@ -61,12 +61,12 @@ public sealed class RenameCommand : IConsoleCommand
         {
             if (idCardSystem.TryFindIdCard(entityUid.Value, out var idCard))
             {
-                idCardSystem.TryChangeFullName(idCard.Owner, name, idCard);
+                idCardSystem.TryChangeFullName(idCard, name, idCard);
 
                 // Records
                 // This is done here because ID cards are linked to station records
                 if (_entManager.TrySystem<StationRecordsSystem>(out var recordsSystem)
-                    && _entManager.TryGetComponent(idCard.Owner, out StationRecordKeyStorageComponent? keyStorage)
+                    && _entManager.TryGetComponent(idCard, out StationRecordKeyStorageComponent? keyStorage)
                     && keyStorage.Key != null)
                 {
                     var origin = keyStorage.Key.Value.OriginStation;
index d713b43f27aa2afded579878390a971417209727..8d05d0abd14657d5eee850c3b6d7a03abdb3543f 100644 (file)
@@ -174,12 +174,13 @@ public sealed class CrematoriumSystem : EntitySystem
     {
         base.Update(frameTime);
 
-        foreach (var (act, crem) in EntityQuery<ActiveCrematoriumComponent, CrematoriumComponent>())
+        var query = EntityQueryEnumerator<ActiveCrematoriumComponent, CrematoriumComponent>();
+        while (query.MoveNext(out var uid, out var act, out var crem))
         {
             act.Accumulator += frameTime;
 
             if (act.Accumulator >= crem.CookTime)
-                FinishCooking(act.Owner, crem);
+                FinishCooking(uid, crem);
         }
     }
 }
index 131689a139e9fa199be3cdf59f7c1bc7072598f2..b300336cd2ecb6de05a59ddc88deb5a167ccdb17 100644 (file)
@@ -1,4 +1,3 @@
-using Content.Server.Morgue.Components;
 using Content.Server.Storage.Components;
 using Content.Shared.Body.Components;
 using Content.Shared.Examine;
@@ -79,20 +78,21 @@ public sealed class MorgueSystem : EntitySystem
     {
         base.Update(frameTime);
 
-        foreach (var (comp, storage, appearance) in EntityQuery<MorgueComponent, EntityStorageComponent, AppearanceComponent>())
+        var query = EntityQueryEnumerator<MorgueComponent, EntityStorageComponent, AppearanceComponent>();
+        while (query.MoveNext(out var uid, out var comp, out var storage, out var appearance))
         {
             comp.AccumulatedFrameTime += frameTime;
 
-            CheckContents(comp.Owner, comp, storage);
+            CheckContents(uid, comp, storage);
 
             if (comp.AccumulatedFrameTime < comp.BeepTime)
                 continue;
 
             comp.AccumulatedFrameTime -= comp.BeepTime;
 
-            if (comp.DoSoulBeep && _appearance.TryGetData<MorgueContents>(appearance.Owner, MorgueVisuals.Contents, out var contents, appearance) && contents == MorgueContents.HasSoul)
+            if (comp.DoSoulBeep && _appearance.TryGetData<MorgueContents>(uid, MorgueVisuals.Contents, out var contents, appearance) && contents == MorgueContents.HasSoul)
             {
-                _audio.PlayPvs(comp.OccupantHasSoulAlarmSound, comp.Owner);
+                _audio.PlayPvs(comp.OccupantHasSoulAlarmSound, uid);
             }
         }
     }
index 79b365be41238c733fc33fbf3605735160fbb5b6..546336890fde2f0d9c74316766e806b22aaa094d 100644 (file)
@@ -26,11 +26,12 @@ public sealed class JetpackSystem : SharedJetpackSystem
         var toDisable = new ValueList<(EntityUid Uid, JetpackComponent Component)>();
         var query = EntityQueryEnumerator<ActiveJetpackComponent, JetpackComponent, GasTankComponent>();
 
-        while (query.MoveNext(out var uid, out var active, out var comp, out var gasTank))
+        while (query.MoveNext(out var uid, out var active, out var comp, out var gasTankComp))
         {
             if (_timing.CurTime < active.TargetTime)
                 continue;
 
+            var gasTank = (uid, gasTankComp);
             active.TargetTime = _timing.CurTime + TimeSpan.FromSeconds(active.EffectCooldown);
             var usedAir = _gasTank.RemoveAir(gasTank, comp.MoleUsage);
 
index 72d6606c910920df1f6f74b21285c4fc68a9079a..c430c71958615b8fb7a1b729922733e6af54828b 100644 (file)
@@ -1,24 +1,20 @@
 using System.Diagnostics.CodeAnalysis;
-using System.Linq;
 using System.Numerics;
 using System.Threading;
 using System.Threading.Tasks;
 using Content.Server.Destructible;
 using Content.Shared.Access.Components;
-using Content.Shared.Climbing;
+using Content.Shared.Climbing.Components;
 using Content.Shared.Doors.Components;
 using Content.Shared.NPC;
 using Content.Shared.Physics;
-using Microsoft.Extensions.ObjectPool;
 using Robust.Shared.Collections;
 using Robust.Shared.Map;
 using Robust.Shared.Map.Components;
 using Robust.Shared.Physics;
-using Robust.Shared.Physics.Components;
 using Robust.Shared.Physics.Events;
 using Robust.Shared.Timing;
 using Robust.Shared.Utility;
-using ClimbableComponent = Content.Shared.Climbing.Components.ClimbableComponent;
 
 namespace Content.Server.NPC.Pathfinding;
 
@@ -102,6 +98,7 @@ public sealed partial class PathfindingSystem
 
         while (query.MoveNext(out var uid, out var comp))
         {
+            var pathfinding = new Entity<GridPathfindingComponent>(uid, comp);
             // TODO: Dump all this shit and just do it live it's probably fast enough.
             if (comp.DirtyChunks.Count == 0 ||
                 curTime < comp.NextUpdate ||
@@ -120,7 +117,7 @@ public sealed partial class PathfindingSystem
 
             foreach (var origin in comp.DirtyChunks)
             {
-                var chunk = GetChunk(origin, uid, comp);
+                var chunk = GetChunk(origin, uid, pathfinding);
                 dirt[idx] = chunk;
                 idx++;
             }
@@ -155,7 +152,7 @@ public sealed partial class PathfindingSystem
                 var climbableQuery = GetEntityQuery<ClimbableComponent>();
                 var fixturesQuery = GetEntityQuery<FixturesComponent>();
                 var xformQuery = GetEntityQuery<TransformComponent>();
-                BuildBreadcrumbs(dirt[i], mapGridComp, accessQuery, destructibleQuery, doorQuery, climbableQuery,
+                BuildBreadcrumbs(dirt[i], (uid, mapGridComp), accessQuery, destructibleQuery, doorQuery, climbableQuery,
                     fixturesQuery, xformQuery);
             });
 
@@ -204,7 +201,7 @@ public sealed partial class PathfindingSystem
                     if (index != it1)
                         return;
 
-                    BuildNavmesh(chunk, comp);
+                    BuildNavmesh(chunk, pathfinding);
 #if DEBUG
                     Interlocked.Increment(ref updateCount);
 #endif
@@ -254,24 +251,24 @@ public sealed partial class PathfindingSystem
 
     private void OnCollisionChange(ref CollisionChangeEvent ev)
     {
-        var xform = Transform(ev.Body.Owner);
+        var xform = Transform(ev.BodyUid);
 
         if (xform.GridUid == null)
             return;
 
         // This will also rebuild on door open / closes which I think is good?
-        var aabb = _lookup.GetAABBNoContainer(ev.Body.Owner, xform.Coordinates.Position, xform.LocalRotation);
+        var aabb = _lookup.GetAABBNoContainer(ev.BodyUid, xform.Coordinates.Position, xform.LocalRotation);
         DirtyChunkArea(xform.GridUid.Value, aabb);
     }
 
     private void OnCollisionLayerChange(ref CollisionLayerChangeEvent ev)
     {
-        var xform = Transform(ev.Body.Owner);
+        var xform = Transform(ev.Body);
 
         if (xform.GridUid == null)
             return;
 
-        var aabb = _lookup.GetAABBNoContainer(ev.Body.Owner, xform.Coordinates.Position, xform.LocalRotation);
+        var aabb = _lookup.GetAABBNoContainer(ev.Body, xform.Coordinates.Position, xform.LocalRotation);
         DirtyChunkArea(xform.GridUid.Value, aabb);
     }
 
@@ -417,7 +414,7 @@ public sealed partial class PathfindingSystem
     }
 
     private void BuildBreadcrumbs(GridPathfindingChunk chunk,
-        MapGridComponent grid,
+        Entity<MapGridComponent> grid,
         EntityQuery<AccessReaderComponent> accessQuery,
         EntityQuery<DestructibleComponent> destructibleQuery,
         EntityQuery<DoorComponent> doorQuery,
@@ -450,7 +447,7 @@ public sealed partial class PathfindingSystem
                 var tilePos = new Vector2i(x, y) + gridOrigin;
                 tilePolys.Clear();
 
-                var tile = grid.GetTileRef(tilePos);
+                var tile = grid.Comp.GetTileRef(tilePos);
                 var flags = tile.Tile.IsEmpty ? PathfindingBreadcrumbFlag.Space : PathfindingBreadcrumbFlag.None;
                 // var isBorder = x < 0 || y < 0 || x == ChunkSize - 1 || y == ChunkSize - 1;
 
@@ -469,7 +466,7 @@ public sealed partial class PathfindingSystem
                     var xform = xformQuery.GetComponent(ent);
 
                     if (xform.ParentUid != grid.Owner ||
-                        grid.LocalToTile(xform.Coordinates) != tilePos)
+                        grid.Comp.LocalToTile(xform.Coordinates) != tilePos)
                     {
                         continue;
                     }
@@ -648,13 +645,13 @@ public sealed partial class PathfindingSystem
                     var polyData = points[x * SubStep + poly.Left, y * SubStep + poly.Bottom].Data;
 
                     var neighbors = new HashSet<PathPoly>();
-                    tilePoly.Add(new PathPoly(grid.Owner, chunk.Origin, GetIndex(x, y), box, polyData, neighbors));
+                    tilePoly.Add(new PathPoly(grid, chunk.Origin, GetIndex(x, y), box, polyData, neighbors));
                 }
             }
         }
 
         // Log.Debug($"Built breadcrumbs in {sw.Elapsed.TotalMilliseconds}ms");
-        SendBreadcrumbs(chunk, grid.Owner);
+        SendBreadcrumbs(chunk, grid);
     }
 
     /// <summary>
@@ -729,12 +726,13 @@ public sealed partial class PathfindingSystem
         }
     }
 
-    private void BuildNavmesh(GridPathfindingChunk chunk, GridPathfindingComponent component)
+    private void BuildNavmesh(GridPathfindingChunk chunk, Entity<GridPathfindingComponent> pathfinding)
     {
         var sw = new Stopwatch();
         sw.Start();
 
         var chunkPolys = chunk.Polygons;
+        var component = pathfinding.Comp;
         component.Chunks.TryGetValue(chunk.Origin + new Vector2i(-1, 0), out var leftChunk);
         component.Chunks.TryGetValue(chunk.Origin + new Vector2i(0, -1), out var bottomChunk);
         component.Chunks.TryGetValue(chunk.Origin + new Vector2i(1, 0), out var rightChunk);
@@ -840,7 +838,7 @@ public sealed partial class PathfindingSystem
         }
 
         // Log.Debug($"Built navmesh in {sw.Elapsed.TotalMilliseconds}ms");
-        SendPolys(chunk, component.Owner, chunkPolys);
+        SendPolys(chunk, pathfinding, chunkPolys);
     }
 
     private void AddNeighbors(PathPoly polyA, PathPoly polyB)
index d8ecebc12cab0905bc585aaec426018be1e41a13..bb0eff7b39116c52e31dcdb913685187588484e3 100644 (file)
@@ -5,7 +5,6 @@ using System.Threading;
 using System.Threading.Tasks;
 using Content.Server.Administration.Managers;
 using Content.Server.Destructible;
-using Content.Server.NPC.HTN;
 using Content.Server.NPC.Systems;
 using Content.Shared.Administration;
 using Content.Shared.NPC;
@@ -577,9 +576,10 @@ namespace Content.Server.NPC.Pathfinding
         {
             var msg = new PathBreadcrumbsMessage();
 
-            foreach (var comp in EntityQuery<GridPathfindingComponent>(true))
+            var query = AllEntityQuery<GridPathfindingComponent>();
+            while (query.MoveNext(out var uid, out var comp))
             {
-                var netGrid = GetNetEntity(comp.Owner);
+                var netGrid = GetNetEntity(uid);
 
                 msg.Breadcrumbs.Add(netGrid, new Dictionary<Vector2i, List<PathfindingBreadcrumb>>(comp.Chunks.Count));
 
@@ -626,9 +626,10 @@ namespace Content.Server.NPC.Pathfinding
         {
             var msg = new PathPolysMessage();
 
-            foreach (var comp in EntityQuery<GridPathfindingComponent>(true))
+            var query = AllEntityQuery<GridPathfindingComponent>();
+            while (query.MoveNext(out var uid, out var comp))
             {
-                var netGrid = GetNetEntity(comp.Owner);
+                var netGrid = GetNetEntity(uid);
 
                 msg.Polys.Add(netGrid, new Dictionary<Vector2i, Dictionary<Vector2i, List<DebugPathPoly>>>(comp.Chunks.Count));
 
index 5b0955a206f575b117faff53245c91e6857320f3..dd4ff6c65f19fd4a675ec8144cb3bc564fc6ba2f 100644 (file)
@@ -10,14 +10,15 @@ public sealed partial class NPCPerceptionSystem
     /// <param name="frameTime"></param>
     private void UpdateRecentlyInjected(float frameTime)
     {
-        foreach (var entity in EntityQuery<NPCRecentlyInjectedComponent>())
+        var query = EntityQueryEnumerator<NPCRecentlyInjectedComponent>();
+        while (query.MoveNext(out var uid, out var entity))
         {
             entity.Accumulator += frameTime;
             if (entity.Accumulator < entity.RemoveTime.TotalSeconds)
                 continue;
             entity.Accumulator = 0;
 
-            RemComp<NPCRecentlyInjectedComponent>(entity.Owner);
+            RemComp<NPCRecentlyInjectedComponent>(uid);
         }
     }
 }
index d8ba19d2388a88de7223dc221bec80b655e7addd..4a9df0e663b478c5992c7a5b0add7dd460c590e3 100644 (file)
@@ -365,7 +365,7 @@ public sealed class NPCUtilitySystem : EntitySystem
                 var compZero = comps[0];
                 comps.RemoveAt(0);
 
-                foreach (var comp in _lookup.GetComponentsInRange(compZero.Component.GetType(), mapPos, vision))
+                foreach (var comp in _lookup.GetEntitiesInRange(compZero.Component.GetType(), mapPos, vision))
                 {
                     var ent = comp.Owner;
 
index d6c23ca6afcf8877b2e58687a589d2f3b7816ea0..08c9353411d046bd5449cb188e17c7856a7ed2ba 100644 (file)
@@ -1,7 +1,7 @@
-using Content.Server.NPC.Components;
-using Robust.Shared.Prototypes;
 using System.Linq;
+using Content.Server.NPC.Components;
 using JetBrains.Annotations;
+using Robust.Shared.Prototypes;
 
 namespace Content.Server.NPC.Systems;
 
@@ -160,15 +160,15 @@ public sealed partial class NpcFactionSystem : EntitySystem
         if (!xformQuery.TryGetComponent(entity, out var entityXform))
             yield break;
 
-        foreach (var comp in _lookup.GetComponentsInRange<NpcFactionMemberComponent>(entityXform.MapPosition, range))
+        foreach (var ent in _lookup.GetEntitiesInRange<NpcFactionMemberComponent>(entityXform.MapPosition, range))
         {
-            if (comp.Owner == entity)
+            if (ent.Owner == entity)
                 continue;
 
-            if (!factions.Overlaps(comp.Factions))
+            if (!factions.Overlaps(ent.Comp.Factions))
                 continue;
 
-            yield return comp.Owner;
+            yield return ent.Owner;
         }
     }
 
index d207f99422f511be7511dbaa9d841e9060c95493..99d18aeb3f9940bffd0ecaf6d91864df43616ba5 100644 (file)
@@ -1,8 +1,8 @@
-using Content.Server.NodeContainer.Nodes;
+using System.Diagnostics.CodeAnalysis;
 using Content.Server.NodeContainer.NodeGroups;
+using Content.Server.NodeContainer.Nodes;
 using Content.Shared.Examine;
 using JetBrains.Annotations;
-using System.Diagnostics.CodeAnalysis;
 
 namespace Content.Server.NodeContainer.EntitySystems
 {
@@ -51,7 +51,7 @@ namespace Content.Server.NodeContainer.EntitySystems
             foreach (var (key, node) in component.Nodes)
             {
                 node.Name = key;
-                node.Initialize(component.Owner, EntityManager);
+                node.Initialize(uid, EntityManager);
             }
         }
 
index 55dca4f70d895fd1c0a542e098d829840b866738..d0e83e4f75e1a50aeec7f459f7da7cb32342b0ff 100644 (file)
@@ -1,7 +1,5 @@
-using System.Linq;
-using Content.Server.Administration;
+using Content.Server.Administration;
 using Content.Server.Station.Components;
-using Content.Server.Station.Systems;
 using Content.Shared.Administration;
 using JetBrains.Annotations;
 using Robust.Shared.Console;
@@ -42,14 +40,14 @@ namespace Content.Server.Nuke.Commands
                 return CompletionResult.Empty;
             }
 
-            var stations = _entityManager
-                .EntityQuery<StationDataComponent>()
-                .Select(stationData =>
-                {
-                    var meta = _entityManager.GetComponent<MetaDataComponent>(stationData.Owner);
+            var stations = new List<CompletionOption>();
+            var query = _entityManager.EntityQueryEnumerator<StationDataComponent>();
+            while (query.MoveNext(out var uid, out var stationData))
+            {
+                var meta = _entityManager.GetComponent<MetaDataComponent>(uid);
 
-                    return new CompletionOption(stationData.Owner.ToString(), meta.EntityName);
-                });
+                stations.Add(new CompletionOption(uid.ToString(), meta.EntityName));
+            }
 
             return CompletionResult.FromHintOptions(stations, null);
         }
index 85e388e6007e04d096534c68ce7e630271c3e081..8df25feebfabcaea92a07f5eb9413b00d21ea880 100644 (file)
@@ -1,5 +1,4 @@
 using System.Diagnostics.CodeAnalysis;
-using System.Linq;
 using Content.Server.Chat.Systems;
 using Content.Server.Fax;
 using Content.Server.Paper;
@@ -103,9 +102,16 @@ namespace Content.Server.Nuke
 
             var codesMessage = new FormattedMessage();
             // Find the first nuke that matches the passed location.
-            var query = EntityQuery<NukeComponent>().ToList();
-            _random.Shuffle(query);
-            foreach (var nuke in query)
+            var nukes = new List<Entity<NukeComponent>>();
+            var query = EntityQueryEnumerator<NukeComponent>();
+            while (query.MoveNext(out var nukeUid, out var nuke))
+            {
+                nukes.Add((nukeUid, nuke));
+            }
+
+            _random.Shuffle(nukes);
+
+            foreach (var (nukeUid, nuke) in nukes)
             {
                 if (!onlyCurrentStation &&
                     (owningStation == null &&
@@ -116,7 +122,7 @@ namespace Content.Server.Nuke
                 }
 
                 codesMessage.PushNewline();
-                codesMessage.AddMarkup(Loc.GetString("nuke-codes-list", ("name", MetaData(nuke.Owner).EntityName), ("code", nuke.Code)));
+                codesMessage.AddMarkup(Loc.GetString("nuke-codes-list", ("name", MetaData(nukeUid).EntityName), ("code", nuke.Code)));
                 break;
             }
 
index 94a80c4bd5e322c1244e301d76deab90bdf364c2..875c328bcb950b46fa8540ea2df3bb916d53fb1c 100644 (file)
@@ -1,6 +1,5 @@
 using Content.Server.Administration.Logs;
 using Content.Server.Interaction.Components;
-using Content.Server.Nutrition.Components;
 using Content.Server.Popups;
 using Content.Shared.Database;
 using Content.Shared.IdentityManagement;
@@ -84,7 +83,8 @@ public sealed class AnimalHusbandrySystem : EntitySystem
 
         var xform = Transform(uid);
 
-        var partners = _entityLookup.GetComponentsInRange<ReproductivePartnerComponent>(xform.Coordinates, component.BreedRange);
+        var partners = new HashSet<Entity<ReproductivePartnerComponent>>();
+        _entityLookup.GetEntitiesInRange(xform.Coordinates, component.BreedRange, partners);
 
         if (partners.Count >= component.Capacity)
             return false;
index 81bba0eb79dc7b686501b93515e25a34f1f08f08..88916e4cf2c31ab1cc3da182447728d72a3accdf 100644 (file)
@@ -1,5 +1,3 @@
-using Content.Server.Chemistry.EntitySystems;
-using Content.Server.Nutrition;
 using Content.Server.Nutrition.Components;
 using Content.Shared.Chemistry.Components;
 using Content.Shared.Chemistry.Components.SolutionManager;
@@ -8,7 +6,6 @@ using Content.Shared.Examine;
 using Content.Shared.FixedPoint;
 using Content.Shared.Hands.EntitySystems;
 using Content.Shared.Interaction;
-using Content.Shared.Item;
 using Robust.Shared.Audio;
 using Robust.Shared.Containers;
 using Robust.Shared.Player;
@@ -74,7 +71,7 @@ namespace Content.Server.Nutrition.EntitySystems
             else
             {
                 var xform = Transform(sliceUid);
-                _containerSystem.AttachParentToContainerOrGrid(xform);
+                _containerSystem.AttachParentToContainerOrGrid((sliceUid, xform));
                 xform.LocalRotation = 0;
             }
 
@@ -113,7 +110,7 @@ namespace Content.Server.Nutrition.EntitySystems
             else
             {
                 var xform = Transform(sliceUid);
-                _containerSystem.AttachParentToContainerOrGrid(xform);
+                _containerSystem.AttachParentToContainerOrGrid((sliceUid, xform));
                 xform.LocalRotation = 0;
             }
 
index 6e0b5cc51579dfde154e48eece48256f261b8691..f57024087d595cd0a97c572e28c9122465a9d456 100644 (file)
@@ -96,8 +96,6 @@ public sealed class PayloadSystem : EntitySystem
             if (_componentFactory.GetComponent(registration.Type) is not Component component)
                 continue;
 
-            component.Owner = uid;
-
             var temp = (object) component;
             _serializationManager.CopyTo(data.Component, ref temp);
             EntityManager.AddComponent(uid, (Component)temp!);
index 8cffa32dbaed7614f07b2e3d927e79ea470579fb..dc5608887e95a6c7e80d13bbe3713a6f0612179e 100644 (file)
@@ -1,13 +1,12 @@
+using Content.Server.Physics.Components;
+using Content.Shared.Follower.Components;
+using Content.Shared.Throwing;
 using Robust.Server.GameObjects;
 using Robust.Shared.Physics.Components;
 using Robust.Shared.Physics.Controllers;
 using Robust.Shared.Random;
 using Robust.Shared.Timing;
 
-using Content.Server.Physics.Components;
-using Content.Shared.Follower.Components;
-using Content.Shared.Throwing;
-
 namespace Content.Server.Physics.Controllers;
 
 /// <summary>
@@ -39,16 +38,17 @@ internal sealed class RandomWalkController : VirtualController
     {
         base.UpdateBeforeSolve(prediction, frameTime);
 
-        foreach(var (randomWalk, physics) in EntityManager.EntityQuery<RandomWalkComponent, PhysicsComponent>())
+        var query = EntityQueryEnumerator<RandomWalkComponent, PhysicsComponent>();
+        while (query.MoveNext(out var uid, out var randomWalk, out var physics))
         {
-            if (EntityManager.HasComponent<ActorComponent>(randomWalk.Owner)
-            ||  EntityManager.HasComponent<ThrownItemComponent>(randomWalk.Owner)
-            ||  EntityManager.HasComponent<FollowerComponent>(randomWalk.Owner))
+            if (EntityManager.HasComponent<ActorComponent>(uid)
+            ||  EntityManager.HasComponent<ThrownItemComponent>(uid)
+            ||  EntityManager.HasComponent<FollowerComponent>(uid))
                 continue;
 
             var curTime = _timing.CurTime;
             if (randomWalk.NextStepTime <= curTime)
-                Update(randomWalk.Owner, randomWalk, physics);
+                Update(uid, randomWalk, physics);
         }
     }
 
@@ -65,7 +65,7 @@ internal sealed class RandomWalkController : VirtualController
 
         var curTime = _timing.CurTime;
         randomWalk.NextStepTime = curTime + TimeSpan.FromSeconds(_random.NextDouble(randomWalk.MinStepCooldown.TotalSeconds, randomWalk.MaxStepCooldown.TotalSeconds));
-        if(!Resolve(randomWalk.Owner, ref physics))
+        if(!Resolve(uid, ref physics))
             return;
 
         var pushAngle = _random.NextAngle();
index 2083a3d98532bf62dcd6a773c8d2c72d3b28ea11..b473d973724e7620f70a4f9a03bcddc13367cc6e 100644 (file)
@@ -64,11 +64,8 @@ public sealed class ProximityBeeperSystem : EntitySystem
         var xform = xformQuery.GetComponent(uid);
         var compType = EntityManager.ComponentFactory.GetRegistration(component.Component).Type;
         float? closestDistance = null;
-        foreach (var comp in _entityLookup.GetComponentsInRange(compType, xform.MapPosition, component.MaximumDistance))
+        foreach (var ent in _entityLookup.GetEntitiesInRange(compType, xform.MapPosition, component.MaximumDistance))
         {
-            // forgive me father, for i have sinned.
-            var ent = comp.Owner;
-
             var dist = (_transform.GetWorldPosition(xform, xformQuery) - _transform.GetWorldPosition(ent, xformQuery)).Length();
             if (dist >= (closestDistance ?? float.MaxValue))
                 continue;
index cbfc263018495f92fd05cd126fd8c839d311ec1e..f16a327e6bfd25ee6e930d1c2d14358798a60557 100644 (file)
@@ -70,10 +70,11 @@ public sealed class PneumaticCannonSystem : SharedPneumaticCannonSystem
         args.Cancel();
     }
 
-    private void OnShoot(EntityUid uid, PneumaticCannonComponent component, ref GunShotEvent args)
+    private void OnShoot(Entity<PneumaticCannonComponent> cannon, ref GunShotEvent args)
     {
+        var (uid, component) = cannon;
         // require a gas tank if it uses gas
-        var gas = GetGas(uid);
+        var gas = GetGas(cannon);
         if (gas == null && component.GasUsage > 0f)
             return;
 
@@ -82,7 +83,7 @@ public sealed class PneumaticCannonSystem : SharedPneumaticCannonSystem
         {
             _stun.TryParalyze(args.User, TimeSpan.FromSeconds(component.HighPowerStunTime), true, status);
             Popup.PopupEntity(Loc.GetString("pneumatic-cannon-component-power-stun",
-                ("cannon", component.Owner)), uid, args.User);
+                ("cannon", uid)), cannon, args.User);
         }
 
         // ignore gas stuff if the cannon doesn't use any
@@ -90,14 +91,14 @@ public sealed class PneumaticCannonSystem : SharedPneumaticCannonSystem
             return;
 
         // this should always be possible, as we'll eject the gas tank when it no longer is
-        var environment = _atmos.GetContainingMixture(component.Owner, false, true);
-        var removed = _gasTank.RemoveAir(gas, component.GasUsage);
+        var environment = _atmos.GetContainingMixture(cannon, false, true);
+        var removed = _gasTank.RemoveAir(gas.Value, component.GasUsage);
         if (environment != null && removed != null)
         {
             _atmos.Merge(environment, removed);
         }
 
-        if (gas.Air.TotalMoles >= component.GasUsage)
+        if (gas.Value.Comp.Air.TotalMoles >= component.GasUsage)
             return;
 
         // eject gas tank
@@ -107,13 +108,13 @@ public sealed class PneumaticCannonSystem : SharedPneumaticCannonSystem
     /// <summary>
     ///     Returns whether the pneumatic cannon has enough gas to shoot an item, as well as the tank itself.
     /// </summary>
-    private GasTankComponent? GetGas(EntityUid uid)
+    private Entity<GasTankComponent>? GetGas(EntityUid uid)
     {
         if (!Container.TryGetContainer(uid, PneumaticCannonComponent.TankSlotId, out var container) ||
             container is not ContainerSlot slot || slot.ContainedEntity is not {} contained)
             return null;
 
-        return TryComp<GasTankComponent>(contained, out var gasTank) ? gasTank : null;
+        return TryComp<GasTankComponent>(contained, out var gasTank) ? (contained, gasTank) : null;
     }
 
     private float GetProjectileSpeedFromPower(PneumaticCannonComponent component)
index 8f00125ea396e46c4319c6af2c42caf2891ec1e9..b253e32e3713f29b8becb290497d6dab219f7ceb 100644 (file)
@@ -166,7 +166,7 @@ namespace Content.Server.Pointing.EntitySystems
             {
                 var arrowVisibility = EntityManager.EnsureComponent<VisibilityComponent>(arrow);
                 layer = playerVisibility.Layer;
-                _visibilitySystem.SetLayer(arrowVisibility, layer);
+                _visibilitySystem.SetLayer(arrow, arrowVisibility, layer);
             }
 
             // Get players that are in range and whose visibility layer matches the arrow's.
@@ -274,26 +274,28 @@ namespace Content.Server.Pointing.EntitySystems
         {
             var currentTime = _gameTiming.CurTime;
 
-            foreach (var component in EntityQuery<PointingArrowComponent>(true))
+            var query = AllEntityQuery<PointingArrowComponent>();
+            while (query.MoveNext(out var uid, out var component))
             {
-                Update(component, currentTime);
+                Update((uid, component), currentTime);
             }
         }
 
-        private void Update(PointingArrowComponent component, TimeSpan currentTime)
+        private void Update(Entity<PointingArrowComponent> pointing, TimeSpan currentTime)
         {
             // TODO: That pause PR
+            var component = pointing.Comp;
             if (component.EndTime > currentTime)
                 return;
 
             if (component.Rogue)
             {
-                RemComp<PointingArrowComponent>(component.Owner);
-                EnsureComp<RoguePointingArrowComponent>(component.Owner);
+                RemComp<PointingArrowComponent>(pointing);
+                EnsureComp<RoguePointingArrowComponent>(pointing);
                 return;
             }
 
-            Del(component.Owner);
+            Del(pointing);
         }
     }
 }
index 160dc80fc35a556f9c7624e8f4c5128e93e2a2ee..be3ceb3b08625a6c4cc5d7361166406a9e968da1 100644 (file)
@@ -1,12 +1,8 @@
-using System.Linq;
 using Content.Server.Explosion.EntitySystems;
 using Content.Server.Pointing.Components;
 using Content.Shared.Pointing.Components;
 using JetBrains.Annotations;
-using Robust.Server.GameObjects;
-using Robust.Shared.Player;
 using Robust.Shared.Random;
-using DrawDepth = Content.Shared.DrawDepth.DrawDepth;
 
 namespace Content.Server.Pointing.EntitySystems
 {
@@ -22,14 +18,19 @@ namespace Content.Server.Pointing.EntitySystems
             if (!Resolve(uid, ref component, ref transform))
                 return null;
 
-            var targets = EntityQuery<PointingArrowAngeringComponent>().ToList();
+            var targets = new List<Entity<PointingArrowAngeringComponent>>();
+            var query = EntityQueryEnumerator<PointingArrowAngeringComponent>();
+            while (query.MoveNext(out var angeringUid, out var angeringComp))
+            {
+                targets.Add((angeringUid, angeringComp));
+            }
 
             if (targets.Count == 0)
                 return null;
 
             var angering = _random.Pick(targets);
-            angering.RemainingAnger -= 1;
-            if (angering.RemainingAnger <= 0)
+            angering.Comp.RemainingAnger -= 1;
+            if (angering.Comp.RemainingAnger <= 0)
                 RemComp<PointingArrowAngeringComponent>(uid);
 
             return angering.Owner;
@@ -53,9 +54,9 @@ namespace Content.Server.Pointing.EntitySystems
 
         public override void Update(float frameTime)
         {
-            foreach (var (component, transform) in EntityManager.EntityQuery<RoguePointingArrowComponent, TransformComponent>())
+            var query = EntityQueryEnumerator<RoguePointingArrowComponent, TransformComponent>();
+            while (query.MoveNext(out var uid, out var component, out var transform))
             {
-                var uid = component.Owner;
                 component.Chasing ??= RandomNearbyPlayer(uid, component, transform);
 
                 if (component.Chasing is not {Valid: true} chasing || Deleted(chasing))
@@ -68,7 +69,7 @@ namespace Content.Server.Pointing.EntitySystems
 
                 if (component.TurningDelay > 0)
                 {
-                    var difference = EntityManager.GetComponent<TransformComponent>(chasing).WorldPosition - transform.WorldPosition;
+                    var difference = Comp<TransformComponent>(chasing).WorldPosition - transform.WorldPosition;
                     var angle = difference.ToAngle();
                     var adjusted = angle.Degrees + 90;
                     var newAngle = Angle.FromDegrees(adjusted);
@@ -83,7 +84,7 @@ namespace Content.Server.Pointing.EntitySystems
 
                 UpdateAppearance(uid, component, transform);
 
-                var toChased = EntityManager.GetComponent<TransformComponent>(chasing).WorldPosition - transform.WorldPosition;
+                var toChased = Comp<TransformComponent>(chasing).WorldPosition - transform.WorldPosition;
 
                 transform.WorldPosition += toChased * frameTime * component.ChasingSpeed;
 
index 6a90928a44e4ef038aaadc80eb20a7724f2cf507..fbf4961f4fd760c8226666dd13d95d200812c90c 100644 (file)
@@ -1,4 +1,3 @@
-using System.Linq;
 using Content.Server.Actions;
 using Content.Server.Humanoid;
 using Content.Server.Inventory;
@@ -173,10 +172,9 @@ namespace Content.Server.Polymorph.Systems
             MakeSentientCommand.MakeSentient(child, EntityManager);
 
             var comp = _compFact.GetComponent<PolymorphedEntityComponent>();
-            comp.Owner = child;
             comp.Parent = uid;
             comp.Prototype = proto.ID;
-            EntityManager.AddComponent(child, comp);
+            AddComp(child, comp);
 
             var childXform = Transform(child);
             childXform.LocalRotation = targetTransformComp.LocalRotation;
index f4a38e7e65b3ba08b0c79854c2dbf700317b312b..c5ca36c3a158ecd2c8d4fb9d346ecafc9b8ee152 100644 (file)
@@ -1,11 +1,9 @@
 using Content.Server.Administration.Logs;
 using Content.Server.Power.Components;
-using Content.Server.Stack;
 using Content.Shared.Database;
 using Content.Shared.Interaction;
 using Content.Shared.Maps;
 using Content.Shared.Stacks;
-using Robust.Shared.Map;
 
 namespace Content.Server.Power.EntitySystems;
 
@@ -18,11 +16,14 @@ public sealed partial class CableSystem
         SubscribeLocalEvent<CablePlacerComponent, AfterInteractEvent>(OnCablePlacerAfterInteract);
     }
 
-    private void OnCablePlacerAfterInteract(EntityUid uid, CablePlacerComponent component, AfterInteractEvent args)
+    private void OnCablePlacerAfterInteract(Entity<CablePlacerComponent> placer, ref AfterInteractEvent args)
     {
-        if (args.Handled || !args.CanReach) return;
+        if (args.Handled || !args.CanReach)
+            return;
 
-        if (component.CablePrototypeId == null) return;
+        var component = placer.Comp;
+        if (component.CablePrototypeId == null)
+            return;
 
         if(!_mapManager.TryGetGrid(args.ClickLocation.GetGridUid(EntityManager), out var grid))
             return;
@@ -39,7 +40,7 @@ public sealed partial class CableSystem
                 return;
         }
 
-        if (TryComp<StackComponent>(component.Owner, out var stack) && !_stack.Use(component.Owner, 1, stack))
+        if (TryComp<StackComponent>(placer, out var stack) && !_stack.Use(placer, 1, stack))
             return;
 
         var newCable = EntityManager.SpawnEntity(component.CablePrototypeId, grid.GridTileToLocal(snapPos));
index 0d88b442d3399715d2446cafaab3fb13b931b4ec..9d68b60418bb6648bcbef515247bdb80792f38e4 100644 (file)
@@ -1,7 +1,7 @@
 using System.Diagnostics.CodeAnalysis;
-using System.Linq;
 using Content.Server.Power.Components;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 using Robust.Shared.Physics;
 using Robust.Shared.Physics.Components;
 
@@ -50,9 +50,10 @@ namespace Content.Server.Power.EntitySystems
             var xform = Transform(uid);
 
             // If grid deleting no need to update power.
-            if (_mapManager.TryGetGrid(xform.GridUid, out var grid))
+            if (HasComp<MapGridComponent>(xform.GridUid) &&
+                MetaData(xform.GridUid.Value).EntityLifeStage > EntityLifeStage.MapInitialized)
             {
-                if (MetaData(grid.Owner).EntityLifeStage > EntityLifeStage.MapInitialized) return;
+                return;
             }
 
             Disconnect(uid, provider);
@@ -72,10 +73,10 @@ namespace Content.Server.Power.EntitySystems
 
             foreach (var receiver in FindAvailableReceivers(uid, provider.TransferRange))
             {
-                receiver.Provider?.LinkedReceivers.Remove(receiver);
-                receiver.Provider = provider;
+                receiver.Comp.Provider?.LinkedReceivers.Remove(receiver);
+                receiver.Comp.Provider = provider;
                 provider.LinkedReceivers.Add(receiver);
-                RaiseLocalEvent(receiver.Owner, new ProviderConnectedEvent(provider), broadcast: false);
+                RaiseLocalEvent(receiver, new ProviderConnectedEvent(provider), broadcast: false);
                 RaiseLocalEvent(uid, new ReceiverConnectedEvent(receiver), broadcast: false);
             }
         }
@@ -95,34 +96,37 @@ namespace Content.Server.Power.EntitySystems
 
         private void ResetReceivers(ExtensionCableProviderComponent provider)
         {
+            var providerId = provider.Owner;
             var receivers = provider.LinkedReceivers.ToArray();
             provider.LinkedReceivers.Clear();
 
             foreach (var receiver in receivers)
             {
+                var receiverId = receiver.Owner;
                 receiver.Provider = null;
-                RaiseLocalEvent(receiver.Owner, new ProviderDisconnectedEvent(provider), broadcast: false);
-                RaiseLocalEvent(provider.Owner, new ReceiverDisconnectedEvent(receiver), broadcast: false);
+                RaiseLocalEvent(receiverId, new ProviderDisconnectedEvent(provider), broadcast: false);
+                RaiseLocalEvent(providerId, new ReceiverDisconnectedEvent((receiverId, receiver)), broadcast: false);
             }
 
             foreach (var receiver in receivers)
             {
                 // No point resetting what the receiver is doing if it's deleting, plus significant perf savings
                 // in not doing needless lookups
-                if (!EntityManager.IsQueuedForDeletion(receiver.Owner)
-                    && MetaData(receiver.Owner).EntityLifeStage <= EntityLifeStage.MapInitialized)
+                var receiverId = receiver.Owner;
+                if (!EntityManager.IsQueuedForDeletion(receiverId)
+                    && MetaData(receiverId).EntityLifeStage <= EntityLifeStage.MapInitialized)
                 {
                     TryFindAndSetProvider(receiver);
                 }
             }
         }
 
-        private IEnumerable<ExtensionCableReceiverComponent> FindAvailableReceivers(EntityUid owner, float range)
+        private IEnumerable<Entity<ExtensionCableReceiverComponent>> FindAvailableReceivers(EntityUid owner, float range)
         {
             var xform = Transform(owner);
             var coordinates = xform.Coordinates;
 
-            if (!_mapManager.TryGetGrid(xform.GridUid, out var grid))
+            if (!TryComp(xform.GridUid, out MapGridComponent? grid))
                 yield break;
 
             var nearbyEntities = grid.GetCellsInSquareArea(coordinates, (int) Math.Ceiling(range / grid.TileSize));
@@ -142,7 +146,7 @@ namespace Content.Server.Power.EntitySystems
                     continue;
 
                 if ((Transform(entity).LocalPosition - xform.LocalPosition).Length() < Math.Min(range, receiver.ReceptionRange))
-                    yield return receiver;
+                    yield return (entity, receiver);
             }
         }
 
@@ -161,7 +165,7 @@ namespace Content.Server.Power.EntitySystems
 
             if (provider != null)
             {
-                RaiseLocalEvent(provider.Owner, new ReceiverDisconnectedEvent(receiver), broadcast: false);
+                RaiseLocalEvent(provider.Owner, new ReceiverDisconnectedEvent((uid, receiver)), broadcast: false);
                 provider.LinkedReceivers.Remove(receiver);
             }
 
@@ -220,7 +224,7 @@ namespace Content.Server.Power.EntitySystems
             RaiseLocalEvent(uid, new ProviderDisconnectedEvent(receiver.Provider), broadcast: false);
             if (receiver.Provider != null)
             {
-                RaiseLocalEvent(receiver.Provider.Owner, new ReceiverDisconnectedEvent(receiver), broadcast: false);
+                RaiseLocalEvent(receiver.Provider.Owner, new ReceiverDisconnectedEvent((uid, receiver)), broadcast: false);
                 receiver.Provider.LinkedReceivers.Remove(receiver);
             }
 
@@ -229,19 +233,22 @@ namespace Content.Server.Power.EntitySystems
 
         private void TryFindAndSetProvider(ExtensionCableReceiverComponent receiver, TransformComponent? xform = null)
         {
-            if (!receiver.Connectable) return;
+            var uid = receiver.Owner;
+            if (!receiver.Connectable)
+                return;
 
-            if (!TryFindAvailableProvider(receiver.Owner, receiver.ReceptionRange, out var provider, xform)) return;
+            if (!TryFindAvailableProvider(uid, receiver.ReceptionRange, out var provider, xform))
+                return;
 
             receiver.Provider = provider;
             provider.LinkedReceivers.Add(receiver);
-            RaiseLocalEvent(receiver.Owner, new ProviderConnectedEvent(provider), broadcast: false);
-            RaiseLocalEvent(provider.Owner, new ReceiverConnectedEvent(receiver), broadcast: false);
+            RaiseLocalEvent(uid, new ProviderConnectedEvent(provider), broadcast: false);
+            RaiseLocalEvent(provider.Owner, new ReceiverConnectedEvent((uid, receiver)), broadcast: false);
         }
 
         private bool TryFindAvailableProvider(EntityUid owner, float range, [NotNullWhen(true)] out ExtensionCableProviderComponent? foundProvider, TransformComponent? xform = null)
         {
-            if (!Resolve(owner, ref xform) || !_mapManager.TryGetGrid(xform.GridUid, out var grid))
+            if (!Resolve(owner, ref xform) || !TryComp(xform.GridUid, out MapGridComponent? grid))
             {
                 foundProvider = null;
                 return false;
@@ -330,9 +337,9 @@ namespace Content.Server.Power.EntitySystems
             /// <summary>
             /// The <see cref="ExtensionCableReceiverComponent"/> that connected.
             /// </summary>
-            public ExtensionCableReceiverComponent Receiver;
+            public Entity<ExtensionCableReceiverComponent> Receiver;
 
-            public ReceiverConnectedEvent(ExtensionCableReceiverComponent receiver)
+            public ReceiverConnectedEvent(Entity<ExtensionCableReceiverComponent> receiver)
             {
                 Receiver = receiver;
             }
@@ -345,9 +352,9 @@ namespace Content.Server.Power.EntitySystems
             /// <summary>
             /// The <see cref="ExtensionCableReceiverComponent"/> that disconnected.
             /// </summary>
-            public ExtensionCableReceiverComponent Receiver;
+            public Entity<ExtensionCableReceiverComponent> Receiver;
 
-            public ReceiverDisconnectedEvent(ExtensionCableReceiverComponent receiver)
+            public ReceiverDisconnectedEvent(Entity<ExtensionCableReceiverComponent> receiver)
             {
                 Receiver = receiver;
             }
index 425f4637afff49926772b8154df76814029b3a92..c39fc7e5fe04e3dc58183cf7e80552ae61f703bb 100644 (file)
@@ -312,7 +312,7 @@ namespace Content.Server.Power.EntitySystems
                 apcReceiver.PoweredLastUpdate = powered;
                 var ev = new PowerChangedEvent(apcReceiver.Powered, apcReceiver.NetworkLoad.ReceivingPower);
 
-                RaiseLocalEvent(apcReceiver.Owner, ref ev);
+                RaiseLocalEvent(uid, ref ev);
 
                 if (appearanceQuery.TryGetComponent(uid, out var appearance))
                     _appearance.SetData(uid, PowerDeviceVisuals.Powered, powered, appearance);
@@ -342,7 +342,7 @@ namespace Content.Server.Power.EntitySystems
         private void UpdateNetworkBattery()
         {
             var enumerator = EntityQueryEnumerator<PowerNetworkBatteryComponent>();
-            while (enumerator.MoveNext(out var powerNetBattery))
+            while (enumerator.MoveNext(out var uid, out var powerNetBattery))
             {
                 var lastSupply = powerNetBattery.LastSupply;
                 var currentSupply = powerNetBattery.CurrentSupply;
@@ -350,12 +350,12 @@ namespace Content.Server.Power.EntitySystems
                 if (lastSupply == 0f && currentSupply != 0f)
                 {
                     var ev = new PowerNetBatterySupplyEvent(true);
-                    RaiseLocalEvent(powerNetBattery.Owner, ref ev);
+                    RaiseLocalEvent(uid, ref ev);
                 }
                 else if (lastSupply > 0f && currentSupply == 0f)
                 {
                     var ev = new PowerNetBatterySupplyEvent(false);
-                    RaiseLocalEvent(powerNetBattery.Owner, ref ev);
+                    RaiseLocalEvent(uid, ref ev);
                 }
 
                 powerNetBattery.LastSupply = currentSupply;
index 35412d174283c15b9797d8dc6bbc4d1b7fe43c18..f1f8bf06168db4929ebf95d6e1b74e8dc19972da 100644 (file)
@@ -73,35 +73,35 @@ namespace Content.Server.Power.EntitySystems
             component.LinkedReceivers.Clear();
         }
 
-        private void OnProviderConnected(EntityUid uid, ApcPowerReceiverComponent receiver, ExtensionCableSystem.ProviderConnectedEvent args)
+        private void OnProviderConnected(Entity<ApcPowerReceiverComponent> receiver, ref ExtensionCableSystem.ProviderConnectedEvent args)
         {
             var providerUid = args.Provider.Owner;
             if (!EntityManager.TryGetComponent<ApcPowerProviderComponent>(providerUid, out var provider))
                 return;
 
-            receiver.Provider = provider;
+            receiver.Comp.Provider = provider;
 
             ProviderChanged(receiver);
         }
 
-        private void OnProviderDisconnected(EntityUid uid, ApcPowerReceiverComponent receiver, ExtensionCableSystem.ProviderDisconnectedEvent args)
+        private void OnProviderDisconnected(Entity<ApcPowerReceiverComponent> receiver, ref ExtensionCableSystem.ProviderDisconnectedEvent args)
         {
-            receiver.Provider = null;
+            receiver.Comp.Provider = null;
 
             ProviderChanged(receiver);
         }
 
-        private void OnReceiverConnected(EntityUid uid, ApcPowerProviderComponent provider, ExtensionCableSystem.ReceiverConnectedEvent args)
+        private void OnReceiverConnected(Entity<ApcPowerProviderComponent> provider, ref ExtensionCableSystem.ReceiverConnectedEvent args)
         {
-            if (EntityManager.TryGetComponent(args.Receiver.Owner, out ApcPowerReceiverComponent? receiver))
+            if (EntityManager.TryGetComponent(args.Receiver, out ApcPowerReceiverComponent? receiver))
             {
-                provider.AddReceiver(receiver);
+                provider.Comp.AddReceiver(receiver);
             }
         }
 
         private void OnReceiverDisconnected(EntityUid uid, ApcPowerProviderComponent provider, ExtensionCableSystem.ReceiverDisconnectedEvent args)
         {
-            if (EntityManager.TryGetComponent(args.Receiver.Owner, out ApcPowerReceiverComponent? receiver))
+            if (EntityManager.TryGetComponent(args.Receiver, out ApcPowerReceiverComponent? receiver))
             {
                 provider.RemoveReceiver(receiver);
             }
@@ -134,13 +134,14 @@ namespace Content.Server.Power.EntitySystems
             args.Verbs.Add(verb);
         }
 
-        private void ProviderChanged(ApcPowerReceiverComponent receiver)
+        private void ProviderChanged(Entity<ApcPowerReceiverComponent> receiver)
         {
-            receiver.NetworkLoad.LinkedNetwork = default;
-            var ev = new PowerChangedEvent(receiver.Powered, receiver.NetworkLoad.ReceivingPower);
+            var comp = receiver.Comp;
+            comp.NetworkLoad.LinkedNetwork = default;
+            var ev = new PowerChangedEvent(comp.Powered, comp.NetworkLoad.ReceivingPower);
 
-            RaiseLocalEvent(receiver.Owner, ref ev);
-            _appearance.SetData(receiver.Owner, PowerDeviceVisuals.Powered, receiver.Powered);
+            RaiseLocalEvent(receiver, ref ev);
+            _appearance.SetData(receiver, PowerDeviceVisuals.Powered, comp.Powered);
         }
 
         /// <summary>
index 640a257694df83d9c48492b5377bb9ca0b9c9997..3a2fe1254927f02bb367b4cf578d10acd0b28aa8 100644 (file)
@@ -32,54 +32,54 @@ public sealed class GeigerSystem : SharedGeigerSystem
         SubscribeLocalEvent<RadiationSystemUpdatedEvent>(OnUpdate);
     }
 
-    private void OnActivate(EntityUid uid, GeigerComponent component, ActivateInWorldEvent args)
+    private void OnActivate(Entity<GeigerComponent> geiger, ref ActivateInWorldEvent args)
     {
-        if (args.Handled || component.AttachedToSuit)
+        if (args.Handled || geiger.Comp.AttachedToSuit)
             return;
         args.Handled = true;
 
-        SetEnabled(uid, component, !component.IsEnabled);
+        SetEnabled(geiger, !geiger.Comp.IsEnabled);
     }
 
-    private void OnEquipped(EntityUid uid, GeigerComponent component, GotEquippedEvent args)
+    private void OnEquipped(Entity<GeigerComponent> geiger, ref GotEquippedEvent args)
     {
-        if (component.AttachedToSuit)
-            SetEnabled(uid, component, true);
-        SetUser(component, args.Equipee);
+        if (geiger.Comp.AttachedToSuit)
+            SetEnabled(geiger, true);
+        SetUser(geiger, args.Equipee);
     }
 
-    private void OnEquippedHand(EntityUid uid, GeigerComponent component, GotEquippedHandEvent args)
+    private void OnEquippedHand(Entity<GeigerComponent> geiger, ref GotEquippedHandEvent args)
     {
-        if (component.AttachedToSuit)
+        if (geiger.Comp.AttachedToSuit)
             return;
 
-        SetUser(component, args.User);
+        SetUser(geiger, args.User);
     }
 
-    private void OnUnequipped(EntityUid uid, GeigerComponent component, GotUnequippedEvent args)
+    private void OnUnequipped(Entity<GeigerComponent> geiger, ref GotUnequippedEvent args)
     {
-        if (component.AttachedToSuit)
-            SetEnabled(uid, component, false);
-        SetUser(component, null);
+        if (geiger.Comp.AttachedToSuit)
+            SetEnabled(geiger, false);
+        SetUser(geiger, null);
     }
 
-    private void OnUnequippedHand(EntityUid uid, GeigerComponent component, GotUnequippedHandEvent args)
+    private void OnUnequippedHand(Entity<GeigerComponent> geiger, ref GotUnequippedHandEvent args)
     {
-        if (component.AttachedToSuit)
+        if (geiger.Comp.AttachedToSuit)
             return;
 
-        SetUser(component, null);
+        SetUser(geiger, null);
     }
 
     private void OnUpdate(RadiationSystemUpdatedEvent ev)
     {
         // update only active geiger counters
         // deactivated shouldn't have rad receiver component
-        var query = EntityQuery<GeigerComponent, RadiationReceiverComponent>();
-        foreach (var (geiger, receiver) in query)
+        var query = EntityQueryEnumerator<GeigerComponent, RadiationReceiverComponent>();
+        while (query.MoveNext(out var uid, out var geiger, out var receiver))
         {
             var rads = receiver.CurrentRadiation;
-            SetCurrentRadiation(geiger.Owner, geiger, rads);
+            SetCurrentRadiation(uid, geiger, rads);
         }
     }
 
@@ -101,21 +101,22 @@ public sealed class GeigerSystem : SharedGeigerSystem
             UpdateSound(uid, component);
         }
 
-        Dirty(component);
+        Dirty(uid, component);
     }
 
-    private void SetUser(GeigerComponent component, EntityUid? user)
+    private void SetUser(Entity<GeigerComponent> component, EntityUid? user)
     {
-        if (component.User == user)
+        if (component.Comp.User == user)
             return;
 
-        component.User = user;
+        component.Comp.User = user;
         Dirty(component);
-        UpdateSound(component.Owner, component);
+        UpdateSound(component, component);
     }
 
-    private void SetEnabled(EntityUid uid, GeigerComponent component, bool isEnabled)
+    private void SetEnabled(Entity<GeigerComponent> geiger, bool isEnabled)
     {
+        var component = geiger.Comp;
         if (component.IsEnabled == isEnabled)
             return;
 
@@ -126,11 +127,11 @@ public sealed class GeigerSystem : SharedGeigerSystem
             component.DangerLevel = GeigerDangerLevel.None;
         }
 
-        _radiation.SetCanReceive(uid, isEnabled);
+        _radiation.SetCanReceive(geiger, isEnabled);
 
-        UpdateAppearance(uid, component);
-        UpdateSound(uid, component);
-        Dirty(component);
+        UpdateAppearance(geiger, component);
+        UpdateSound(geiger, component);
+        Dirty(geiger, component);
     }
 
     private void UpdateAppearance(EntityUid uid, GeigerComponent? component = null,
index fa132186a97854b0c021effb3179700c6162686c..1be8f0fb0400f0c32f482ebc761dd219908e5c4f 100644 (file)
@@ -1,3 +1,4 @@
+using System.Linq;
 using System.Numerics;
 using Content.Server.Radiation.Components;
 using Content.Server.Radiation.Events;
@@ -9,7 +10,6 @@ using Robust.Shared.Containers;
 using Robust.Shared.Map.Components;
 using Robust.Shared.Timing;
 using Robust.Shared.Utility;
-using System.Linq;
 
 namespace Content.Server.Radiation.Systems;
 
@@ -31,7 +31,7 @@ public partial class RadiationSystem
         stopwatch.Start();
 
         var sources = EntityQueryEnumerator<RadiationSourceComponent, TransformComponent>();
-        var destinations = EntityQuery<RadiationReceiverComponent, TransformComponent>();
+        var destinations = EntityQueryEnumerator<RadiationReceiverComponent, TransformComponent>();
         var resistanceQuery = GetEntityQuery<RadiationGridResistanceComponent>();
         var transformQuery = GetEntityQuery<TransformComponent>();
         var gridQuery = GetEntityQuery<MapGridComponent>();
@@ -51,8 +51,8 @@ public partial class RadiationSystem
 
         // trace all rays from rad source to rad receivers
         var rays = new List<RadiationRay>();
-        var receiversTotalRads = new ValueList<(RadiationReceiverComponent, float)>();
-        foreach (var (dest, destTrs) in destinations)
+        var receiversTotalRads = new ValueList<(Entity<RadiationReceiverComponent>, float)>();
+        while (destinations.MoveNext(out var destUid, out var dest, out var destTrs))
         {
             var destWorld = _transform.GetWorldPosition(destTrs, transformQuery);
 
@@ -64,7 +64,7 @@ public partial class RadiationSystem
 
                 // send ray towards destination entity
                 var ray = Irradiate(uid, sourceTrs, sourceWorld,
-                    destTrs.Owner, destTrs, destWorld,
+                    destUid, destTrs, destWorld,
                     intensity, source.Slope, saveVisitedTiles, resistanceQuery, transformQuery, gridQuery);
                 if (ray == null)
                     continue;
@@ -78,9 +78,9 @@ public partial class RadiationSystem
             }
 
             // Apply modifier if the destination entity is hidden within a radiation blocking container
-            rads = GetAdjustedRadiationIntensity(dest.Owner, rads);
+            rads = GetAdjustedRadiationIntensity(destUid, rads);
 
-            receiversTotalRads.Add((dest, rads));
+            receiversTotalRads.Add(((destUid, dest), rads));
         }
 
         // update information for debug overlay
@@ -94,11 +94,11 @@ public partial class RadiationSystem
         {
             // update radiation value of receiver
             // if no radiation rays reached target, that will set it to 0
-            receiver.CurrentRadiation = rads;
+            receiver.Comp.CurrentRadiation = rads;
 
             // also send an event with combination of total rad
             if (rads > 0)
-                IrradiateEntity(receiver.Owner, rads, GridcastUpdateRate);
+                IrradiateEntity(receiver, rads, GridcastUpdateRate);
         }
 
         // raise broadcast event that radiation system has updated
@@ -145,20 +145,21 @@ public partial class RadiationSystem
         {
             if (!gridQuery.TryGetComponent(sourceTrs.GridUid.Value, out var gridComponent))
                 return ray;
-            return Gridcast(gridComponent, ray, saveVisitedTiles, resistanceQuery, sourceTrs, destTrs, transformQuery.GetComponent(sourceTrs.GridUid.Value));
+            return Gridcast((sourceTrs.GridUid.Value, gridComponent), ray, saveVisitedTiles, resistanceQuery, sourceTrs, destTrs, transformQuery.GetComponent(sourceTrs.GridUid.Value));
         }
 
         // lets check how many grids are between source and destination
         // do a box intersection test between target and destination
         // it's not very precise, but really cheap
         var box = Box2.FromTwoPoints(sourceWorld, destWorld);
-        var grids = _mapManager.FindGridsIntersecting(mapId, box, true);
+        var grids = new List<Entity<MapGridComponent>>();
+        _mapManager.FindGridsIntersecting(mapId, box, ref grids, true);
 
         // gridcast through each grid and try to hit some radiation blockers
         // the ray will be updated with each grid that has some blockers
         foreach (var grid in grids)
         {
-            ray = Gridcast(grid, ray, saveVisitedTiles, resistanceQuery, sourceTrs, destTrs, transformQuery.GetComponent(grid.Owner));
+            ray = Gridcast(grid, ray, saveVisitedTiles, resistanceQuery, sourceTrs, destTrs, transformQuery.GetComponent(grid));
 
             // looks like last grid blocked all radiation
             // we can return right now
@@ -169,7 +170,7 @@ public partial class RadiationSystem
         return ray;
     }
 
-    private RadiationRay Gridcast(MapGridComponent grid, RadiationRay ray, bool saveVisitedTiles,
+    private RadiationRay Gridcast(Entity<MapGridComponent> grid, RadiationRay ray, bool saveVisitedTiles,
         EntityQuery<RadiationGridResistanceComponent> resistanceQuery,
         TransformComponent sourceTrs,
         TransformComponent destTrs,
@@ -198,12 +199,12 @@ public partial class RadiationSystem
             : gridTrs.InvLocalMatrix.Transform(ray.Destination);
 
         Vector2i sourceGrid = new(
-            (int) Math.Floor(srcLocal.X / grid.TileSize),
-            (int) Math.Floor(srcLocal.Y / grid.TileSize));
+            (int) Math.Floor(srcLocal.X / grid.Comp.TileSize),
+            (int) Math.Floor(srcLocal.Y / grid.Comp.TileSize));
 
         Vector2i destGrid = new(
-            (int) Math.Floor(dstLocal.X / grid.TileSize),
-            (int) Math.Floor(dstLocal.Y / grid.TileSize));
+            (int) Math.Floor(dstLocal.X / grid.Comp.TileSize),
+            (int) Math.Floor(dstLocal.Y / grid.Comp.TileSize));
 
         // iterate tiles in grid line from source to destination
         var line = new GridLineEnumerator(sourceGrid, destGrid);
index 1bb188251672ee68b53ad71c3ac7e649cad92a54..e813f09ff9f060a5ef5522468f5849fedec3f922 100644 (file)
@@ -1,5 +1,4 @@
 using System.Diagnostics.CodeAnalysis;
-using System.Linq;
 using Content.Server.Power.EntitySystems;
 using Content.Shared.Research.Components;
 using Robust.Server.Player;
@@ -58,9 +57,15 @@ public sealed partial class ResearchSystem
 
     private void OnClientMapInit(EntityUid uid, ResearchClientComponent component, MapInitEvent args)
     {
-        var allServers = EntityQuery<ResearchServerComponent>(true).ToArray();
-        if (allServers.Length > 0)
-            RegisterClient(uid, allServers[0].Owner, component, allServers[0]);
+        var allServers = new List<Entity<ResearchServerComponent>>();
+        var query = AllEntityQuery<ResearchServerComponent>();
+        while (query.MoveNext(out var serverUid, out var serverComp))
+        {
+            allServers.Add((serverUid, serverComp));
+        }
+
+        if (allServers.Count > 0)
+            RegisterClient(uid, allServers[0], component, allServers[0]);
     }
 
     private void OnClientShutdown(EntityUid uid, ResearchClientComponent component, ComponentShutdown args)
index ed8e2eb0a80ce283dd06eaa074a0e91e178a7103..f069b1c80f7d231d681a0911f97b9ce8f012c1dd 100644 (file)
@@ -11,14 +11,14 @@ public sealed partial class ResearchSystem
         SubscribeLocalEvent<ResearchPointSourceComponent, ResearchServerGetPointsPerSecondEvent>(OnGetPointsPerSecond);
     }
 
-    private void OnGetPointsPerSecond(EntityUid uid, ResearchPointSourceComponent component, ref ResearchServerGetPointsPerSecondEvent args)
+    private void OnGetPointsPerSecond(Entity<ResearchPointSourceComponent> source, ref ResearchServerGetPointsPerSecondEvent args)
     {
-        if (CanProduce(component))
-            args.Points += component.PointsPerSecond;
+        if (CanProduce(source))
+            args.Points += source.Comp.PointsPerSecond;
     }
 
-    public bool CanProduce(ResearchPointSourceComponent component)
+    public bool CanProduce(Entity<ResearchPointSourceComponent> source)
     {
-        return component.Active && this.IsPowered(component.Owner, EntityManager);
+        return source.Comp.Active && this.IsPowered(source, EntityManager);
     }
 }
index 7adc30ea2984d873edbf633a4839334103659cce..e89b435800f083a742a18f27567f838f86a56016 100644 (file)
@@ -42,11 +42,13 @@ namespace Content.Server.Research.Systems
         {
             serverUid = null;
             serverComponent = null;
-            foreach (var server in EntityQuery<ResearchServerComponent>())
+
+            var query = EntityQueryEnumerator<ResearchServerComponent>();
+            while (query.MoveNext(out var uid, out var server))
             {
                 if (server.Id != id)
                     continue;
-                serverUid = server.Owner;
+                serverUid = uid;
                 serverComponent = server;
                 return true;
             }
@@ -89,13 +91,14 @@ namespace Content.Server.Research.Systems
 
         public override void Update(float frameTime)
         {
-            foreach (var server in EntityQuery<ResearchServerComponent>())
+            var query = EntityQueryEnumerator<ResearchServerComponent>();
+            while (query.MoveNext(out var uid, out var server))
             {
                 if (server.NextUpdateTime > _timing.CurTime)
                     continue;
                 server.NextUpdateTime = _timing.CurTime + server.ResearchConsoleUpdateTime;
 
-                UpdateServer(server.Owner, (int) server.ResearchConsoleUpdateTime.TotalSeconds, server);
+                UpdateServer(uid, (int) server.ResearchConsoleUpdateTime.TotalSeconds, server);
             }
         }
     }
index ea603084b55c7457bea3821f5d92f613cb74c2b1..1249269de5625629f9338b8ab0c1d81f3fa2e43d 100644 (file)
@@ -1,15 +1,15 @@
 using Content.Server.Contests;
-using Robust.Shared.Containers;
 using Content.Server.Popups;
-using Content.Shared.Storage;
-using Content.Shared.Inventory;
-using Content.Shared.Hands.EntitySystems;
+using Content.Server.Storage.Components;
 using Content.Shared.ActionBlocker;
 using Content.Shared.DoAfter;
-using Content.Shared.Movement.Events;
+using Content.Shared.Hands.EntitySystems;
 using Content.Shared.Interaction.Events;
+using Content.Shared.Inventory;
+using Content.Shared.Movement.Events;
 using Content.Shared.Resist;
-using Content.Server.Storage.Components;
+using Content.Shared.Storage;
+using Robust.Shared.Containers;
 
 namespace Content.Server.Resist;
 
@@ -93,7 +93,7 @@ public sealed class EscapeInventorySystem : EntitySystem
         if (args.Handled || args.Cancelled)
             return;
 
-        _containerSystem.AttachParentToContainerOrGrid(Transform(uid));
+        _containerSystem.AttachParentToContainerOrGrid((uid, Transform(uid)));
         args.Handled = true;
     }
 
index 350d0827565769f7f7e0e46f63e993a20bcca0ad..1d43cb3ac85134860682f60e62a810a8266c9d14 100644 (file)
@@ -17,9 +17,9 @@ public sealed class CorporealSystem : SharedCorporealSystem
 
         if (TryComp<VisibilityComponent>(uid, out var visibility))
         {
-            _visibilitySystem.RemoveLayer(visibility, (int) VisibilityFlags.Ghost, false);
-            _visibilitySystem.AddLayer(visibility, (int) VisibilityFlags.Normal, false);
-            _visibilitySystem.RefreshVisibility(visibility);
+            _visibilitySystem.RemoveLayer(uid, visibility, (int) VisibilityFlags.Ghost, false);
+            _visibilitySystem.AddLayer(uid, visibility, (int) VisibilityFlags.Normal, false);
+            _visibilitySystem.RefreshVisibility(uid, visibility);
         }
     }
 
@@ -29,9 +29,9 @@ public sealed class CorporealSystem : SharedCorporealSystem
 
         if (TryComp<VisibilityComponent>(uid, out var visibility) && _ticker.RunLevel != GameRunLevel.PostRound)
         {
-            _visibilitySystem.AddLayer(visibility, (int) VisibilityFlags.Ghost, false);
-            _visibilitySystem.RemoveLayer(visibility, (int) VisibilityFlags.Normal, false);
-            _visibilitySystem.RefreshVisibility(visibility);
+            _visibilitySystem.AddLayer(uid, visibility, (int) VisibilityFlags.Ghost, false);
+            _visibilitySystem.RemoveLayer(uid, visibility, (int) VisibilityFlags.Normal, false);
+            _visibilitySystem.RefreshVisibility(uid, visibility);
         }
     }
 }
index dadf1cfa6b10114775eee975669507726eebcf1c..2a45b312341a7b2d02235726533e77ce2e94b522 100644 (file)
@@ -11,12 +11,13 @@ public sealed class RevenantOverloadedLightsSystem : SharedRevenantOverloadedLig
 {
     [Dependency] private readonly BeamSystem _beam = default!;
 
-    protected override void OnZap(RevenantOverloadedLightsComponent component)
+    protected override void OnZap(Entity<RevenantOverloadedLightsComponent> lights)
     {
+        var component = lights.Comp;
         if (component.Target == null)
             return;
 
-        var lxform = Transform(component.Owner);
+        var lxform = Transform(lights);
         var txform = Transform(component.Target.Value);
 
         if (!lxform.Coordinates.TryDistance(EntityManager, txform.Coordinates, out var distance))
@@ -24,6 +25,6 @@ public sealed class RevenantOverloadedLightsSystem : SharedRevenantOverloadedLig
         if (distance > component.ZapRange)
             return;
 
-        _beam.TryCreateBeam(component.Owner, component.Target.Value, component.ZapBeamEntityId);
+        _beam.TryCreateBeam(lights, component.Target.Value, component.ZapBeamEntityId);
     }
 }
index 0026533c4a1833af89fc055b394d2c6d644b9b69..d5e1ae1af899b4d989139d372092b96b613f1895 100644 (file)
@@ -77,9 +77,9 @@ public sealed partial class RevenantSystem : EntitySystem
 
         if (_ticker.RunLevel == GameRunLevel.PostRound && TryComp<VisibilityComponent>(uid, out var visibility))
         {
-            _visibility.AddLayer(visibility, (int) VisibilityFlags.Ghost, false);
-            _visibility.RemoveLayer(visibility, (int) VisibilityFlags.Normal, false);
-            _visibility.RefreshVisibility(visibility);
+            _visibility.AddLayer(uid, visibility, (int) VisibilityFlags.Ghost, false);
+            _visibility.RemoveLayer(uid, visibility, (int) VisibilityFlags.Normal, false);
+            _visibility.RefreshVisibility(uid, visibility);
         }
 
         //ghost vision
@@ -185,19 +185,20 @@ public sealed partial class RevenantSystem : EntitySystem
 
     public void MakeVisible(bool visible)
     {
-        foreach (var (_, vis) in EntityQuery<RevenantComponent, VisibilityComponent>())
+        var query = EntityQueryEnumerator<RevenantComponent, VisibilityComponent>();
+        while (query.MoveNext(out var uid, out _, out var vis))
         {
             if (visible)
             {
-                _visibility.AddLayer(vis, (int) VisibilityFlags.Normal, false);
-                _visibility.RemoveLayer(vis, (int) VisibilityFlags.Ghost, false);
+                _visibility.AddLayer(uid, vis, (int) VisibilityFlags.Normal, false);
+                _visibility.RemoveLayer(uid, vis, (int) VisibilityFlags.Ghost, false);
             }
             else
             {
-                _visibility.AddLayer(vis, (int) VisibilityFlags.Ghost, false);
-                _visibility.RemoveLayer(vis, (int) VisibilityFlags.Normal, false);
+                _visibility.AddLayer(uid, vis, (int) VisibilityFlags.Ghost, false);
+                _visibility.RemoveLayer(uid, vis, (int) VisibilityFlags.Normal, false);
             }
-            _visibility.RefreshVisibility(vis);
+            _visibility.RefreshVisibility(uid, vis);
         }
     }
 
@@ -205,7 +206,8 @@ public sealed partial class RevenantSystem : EntitySystem
     {
         base.Update(frameTime);
 
-        foreach (var rev in EntityQuery<RevenantComponent>())
+        var query = EntityQueryEnumerator<RevenantComponent>();
+        while (query.MoveNext(out var uid, out var rev))
         {
             rev.Accumulator += frameTime;
 
@@ -215,7 +217,7 @@ public sealed partial class RevenantSystem : EntitySystem
 
             if (rev.Essence < rev.EssenceRegenCap)
             {
-                ChangeEssenceAmount(rev.Owner, rev.EssencePerSecond, rev, regenCap: true);
+                ChangeEssenceAmount(uid, rev.EssencePerSecond, rev, regenCap: true);
             }
         }
     }
index 9dcf7fc36ee12b9521640d3c5b2ebfdf37dd8c1a..b0a64508c563cf380992cd6f3601caa8cb1d5bd9 100644 (file)
@@ -1,13 +1,8 @@
-using Content.Server.Preferences.Managers;
 using Content.Server.Administration;
 using Content.Shared.Administration;
-using Content.Shared.Preferences;
-using Content.Shared.Roles;
-using Robust.Server.GameObjects;
 using Robust.Server.Player;
 using Robust.Shared.Console;
 using Robust.Shared.Map;
-using Robust.Shared.IoC;
 
 namespace Content.Server.Salvage;
 
@@ -48,9 +43,9 @@ sealed class SalvageRulerCommand : IConsoleCommand
         var entityTransform = _entities.GetComponent<TransformComponent>(entity.Value);
         var total = Box2.UnitCentered;
         var first = true;
-        foreach (var mapGrid in _maps.GetAllMapGrids(entityTransform.MapID))
+        foreach (var mapGrid in _maps.GetAllGrids(entityTransform.MapID))
         {
-            var aabb = _entities.GetComponent<TransformComponent>(mapGrid.Owner).WorldMatrix.TransformBox(mapGrid.LocalAABB);
+            var aabb = _entities.GetComponent<TransformComponent>(mapGrid).WorldMatrix.TransformBox(mapGrid.Comp.LocalAABB);
             if (first)
             {
                 total = aabb;
index d4241b2baf25a4385f70ec53099afa8f1bdfc27f..237645dadf9947056a64f853d8cad6b49402e4c2 100644 (file)
@@ -1,5 +1,4 @@
 using Content.Shared.Procedural;
-using Content.Shared.Salvage;
 using Content.Shared.Salvage.Expeditions;
 
 namespace Content.Server.Salvage;
@@ -24,34 +23,35 @@ public sealed partial class SalvageSystem
         UpdateConsoles(data);
     }
 
-    private void OnSalvageConsoleInit(EntityUid uid, SalvageExpeditionConsoleComponent component, ComponentInit args)
+    private void OnSalvageConsoleInit(Entity<SalvageExpeditionConsoleComponent> console, ref ComponentInit args)
     {
-        UpdateConsole(component);
+        UpdateConsole(console);
     }
 
-    private void OnSalvageConsoleParent(EntityUid uid, SalvageExpeditionConsoleComponent component, ref EntParentChangedMessage args)
+    private void OnSalvageConsoleParent(Entity<SalvageExpeditionConsoleComponent> console, ref EntParentChangedMessage args)
     {
-        UpdateConsole(component);
+        UpdateConsole(console);
     }
 
     private void UpdateConsoles(SalvageExpeditionDataComponent component)
     {
         var state = GetState(component);
 
-        foreach (var (console, xform, uiComp) in EntityQuery<SalvageExpeditionConsoleComponent, TransformComponent, UserInterfaceComponent>(true))
+        var query = AllEntityQuery<SalvageExpeditionConsoleComponent, UserInterfaceComponent, TransformComponent>();
+        while (query.MoveNext(out var uid, out _, out var uiComp, out var xform))
         {
-            var station = _station.GetOwningStation(console.Owner, xform);
+            var station = _station.GetOwningStation(uid, xform);
 
-            if (station != component.Owner)
+            if (station != uid)
                 continue;
 
-            _ui.TrySetUiState(console.Owner, SalvageConsoleUiKey.Expedition, state, ui: uiComp);
+            _ui.TrySetUiState(uid, SalvageConsoleUiKey.Expedition, state, ui: uiComp);
         }
     }
 
-    private void UpdateConsole(SalvageExpeditionConsoleComponent component)
+    private void UpdateConsole(Entity<SalvageExpeditionConsoleComponent> component)
     {
-        var station = _station.GetOwningStation(component.Owner);
+        var station = _station.GetOwningStation(component);
         SalvageExpeditionConsoleState state;
 
         if (TryComp<SalvageExpeditionDataComponent>(station, out var dataComponent))
@@ -63,6 +63,6 @@ public sealed partial class SalvageSystem
             state = new SalvageExpeditionConsoleState(TimeSpan.Zero, false, true, 0, new List<SalvageMissionParams>());
         }
 
-        _ui.TrySetUiState(component.Owner, SalvageConsoleUiKey.Expedition, state);
+        _ui.TrySetUiState(component, SalvageConsoleUiKey.Expedition, state);
     }
 }
index c50feb959a930bb215b6c1280eda51d9618c0df8..e7cfbf8f8e7ee2689a01b725c269a4c0b1c8df2a 100644 (file)
@@ -15,31 +15,8 @@ namespace Content.Server.Shuttles.Components
         /// <summary>
         /// Whether the thruster has been force to be enabled / disabled (e.g. VV, interaction, etc.)
         /// </summary>
-        [ViewVariables(VVAccess.ReadWrite)]
-        public bool Enabled
-        {
-            get => _enabled;
-            [Obsolete("Use the system method")]
-            set
-            {
-                if (_enabled == value) return;
-                _enabled = value;
-
-                var system = EntitySystem.Get<ThrusterSystem>();
-
-                if (!_enabled)
-                {
-                    system.DisableThruster(Owner, this);
-                }
-                else if (system.CanEnable(Owner, this))
-                {
-                    system.EnableThruster(Owner, this);
-                }
-            }
-        }
-
-        [DataField("enabled")]
-        private bool _enabled = true;
+        [DataField, ViewVariables(VVAccess.ReadWrite)]
+        public bool Enabled { get; set; }
 
         /// <summary>
         /// This determines whether the thruster is actually enabled for the purposes of thrust
index 439367a0805a56a4b3d95871bab01315a491cdc2..a09fff5189c7a1781aebe57d5cfae496003a1238 100644 (file)
@@ -1,9 +1,6 @@
 using Content.Server.Shuttles.Components;
 using Content.Shared.Shuttles.Components;
 using Content.Shared.Shuttles.Events;
-using Robust.Shared.Physics.Components;
-using Robust.Shared.Players;
-using Robust.Shared.Utility;
 
 namespace Content.Server.Shuttles.Systems;
 
@@ -35,7 +32,7 @@ public sealed partial class DockingSystem
             if (dockable == null)
                 continue;
 
-            TryDock(dockUid, dock, dockable.Owner, dockable);
+            TryDock(dockUid, dock, dockable.Value);
         }
 
         // Work out recent docks that have gone past their designated threshold.
@@ -114,7 +111,8 @@ public sealed partial class DockingSystem
         var player = args.Session.AttachedEntity;
 
         // TODO: Validation
-        if (player == null || !TryComp<AutoDockComponent>(dork, out var comp)) return;
+        if (player == null || !TryComp<AutoDockComponent>(dork, out var comp))
+            return;
 
         comp.Requesters.Remove(player.Value);
 
index 6ad113f3da49c3edfc34c8f316ca9f71b8e428df..fd9cf67c5a08fc75ea53be1a72b408f203273728 100644 (file)
@@ -1,4 +1,3 @@
-using System.Diagnostics.CodeAnalysis;
 using System.Linq;
 using System.Numerics;
 using Content.Server.Shuttles.Components;
@@ -140,6 +139,7 @@ public sealed partial class DockingSystem
         var isMap = HasComp<MapComponent>(targetGrid);
 
         var validDockConfigs = new List<DockingConfig>();
+        var grids = new List<Entity<MapGridComponent>>();
         if (shuttleDocks.Count > 0)
         {
            // We'll try all combinations of shuttle docks and see which one is most suitable
@@ -174,8 +174,9 @@ public sealed partial class DockingSystem
                    var dockedBounds = new Box2Rotated(shuttleAABB.Translated(spawnPosition.Position), targetAngle, spawnPosition.Position);
 
                    // Check if there's no intersecting grids (AKA oh god it's docking at cargo).
-                   if (_mapManager.FindGridsIntersecting(targetGridXform.MapID,
-                           dockedBounds).Any(o => o.Owner != targetGrid))
+                   grids.Clear();
+                   _mapManager.FindGridsIntersecting(targetGridXform.MapID, dockedBounds, ref grids);
+                   if (grids.Any(o => o.Owner != targetGrid))
                    {
                        continue;
                    }
index ba75ef328411653e021f6a3729653b7eb81b037f..f765ed69769d31e02c4fb0ec21d4ace4d9fce601 100644 (file)
@@ -7,6 +7,7 @@ using Content.Shared.Doors;
 using Content.Shared.Doors.Components;
 using Content.Shared.Shuttles.Events;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 using Robust.Shared.Physics;
 using Robust.Shared.Physics.Collision.Shapes;
 using Robust.Shared.Physics.Components;
@@ -66,7 +67,7 @@ namespace Content.Server.Shuttles.Systems
                 args.Cancel();
         }
 
-        private DockingComponent? GetDockable(EntityUid uid, TransformComponent dockingXform)
+        private Entity<DockingComponent>? GetDockable(EntityUid uid, TransformComponent dockingXform)
         {
             // Did you know Saltern is the most dockable station?
 
@@ -96,12 +97,14 @@ namespace Content.Server.Shuttles.Systems
             var enlargedAABB = aabb.Value.Enlarged(DockingRadius * 1.5f);
 
             // Get any docking ports in range on other grids.
-            foreach (var otherGrid in _mapManager.FindGridsIntersecting(dockingXform.MapID, enlargedAABB))
+            var grids = new List<Entity<MapGridComponent>>();
+            _mapManager.FindGridsIntersecting(dockingXform.MapID, enlargedAABB, ref grids);
+            foreach (var otherGrid in grids)
             {
                 if (otherGrid.Owner == dockingXform.GridUid)
                     continue;
 
-                foreach (var ent in otherGrid.GetAnchoredEntities(enlargedAABB))
+                foreach (var ent in otherGrid.Comp.GetAnchoredEntities(enlargedAABB))
                 {
                     if (!TryComp(ent, out DockingComponent? otherDocking) ||
                         !otherDocking.Enabled ||
@@ -129,7 +132,7 @@ namespace Content.Server.Shuttles.Systems
 
                         // TODO: Need CollisionManager's GJK for accurate bounds
                         // Realistically I want 2 fixtures anyway but I'll deal with that later.
-                        return otherDocking;
+                        return (ent, otherDocking);
                     }
                 }
             }
@@ -443,12 +446,12 @@ namespace Content.Server.Shuttles.Systems
         /// <summary>
         /// Attempts to dock 2 ports together and will return early if it's not possible.
         /// </summary>
-        private void TryDock(EntityUid dockAUid, DockingComponent dockA, EntityUid dockBUid, DockingComponent dockB)
+        private void TryDock(EntityUid dockAUid, DockingComponent dockA, Entity<DockingComponent> dockB)
         {
-            if (!CanDock(dockAUid, dockBUid, dockA, dockB))
+            if (!CanDock(dockAUid, dockB, dockA, dockB))
                 return;
 
-            Dock(dockAUid, dockA, dockBUid, dockB);
+            Dock(dockAUid, dockA, dockB, dockB);
         }
 
         public void Undock(EntityUid dockUid, DockingComponent dock)
index 0603ff75022fe81be8c7ceb00d02376bf8907b79..62478082d88a4a8c6974dbda9022299f252c078e 100644 (file)
@@ -9,7 +9,6 @@ using Content.Shared.Popups;
 using Content.Shared.Shuttles.BUIStates;
 using Content.Shared.Shuttles.Events;
 using Content.Shared.Shuttles.Systems;
-using Robust.Server.GameObjects;
 using Robust.Shared.Map;
 using Robust.Shared.Player;
 using Timer = Robust.Shared.Timing.Timer;
@@ -258,16 +257,17 @@ public sealed partial class EmergencyShuttleSystem
     private void OnEmergencyRepeal(EntityUid uid, EmergencyShuttleConsoleComponent component, EmergencyShuttleRepealMessage args)
     {
         var player = args.Session.AttachedEntity;
-        if (player == null) return;
+        if (player == null)
+            return;
 
-        if (!_idSystem.TryFindIdCard(player.Value, out var idCard) || !_reader.IsAllowed(idCard.Owner, uid))
+        if (!_idSystem.TryFindIdCard(player.Value, out var idCard) || !_reader.IsAllowed(idCard, uid))
         {
             _popup.PopupCursor(Loc.GetString("emergency-shuttle-console-denied"), player.Value, PopupType.Medium);
             return;
         }
 
         // TODO: This is fucking bad
-        if (!component.AuthorizedEntities.Remove(MetaData(idCard.Owner).EntityName))
+        if (!component.AuthorizedEntities.Remove(MetaData(idCard).EntityName))
             return;
 
         _logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle early launch REPEAL by {args.Session:user}");
@@ -283,14 +283,14 @@ public sealed partial class EmergencyShuttleSystem
         if (player == null)
             return;
 
-        if (!_idSystem.TryFindIdCard(player.Value, out var idCard) || !_reader.IsAllowed(idCard.Owner, uid))
+        if (!_idSystem.TryFindIdCard(player.Value, out var idCard) || !_reader.IsAllowed(idCard, uid))
         {
             _popup.PopupCursor(Loc.GetString("emergency-shuttle-console-denied"), args.Session, PopupType.Medium);
             return;
         }
 
         // TODO: This is fucking bad
-        if (!component.AuthorizedEntities.Add(MetaData(idCard.Owner).EntityName))
+        if (!component.AuthorizedEntities.Add(MetaData(idCard).EntityName))
             return;
 
         _logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle early launch AUTH by {args.Session:user}");
index 49e1b1cb84d82b7fa440a8822f078258648e9da0..e19d88b1c29589e8abe45c96e2f027b4a6556199 100644 (file)
@@ -1,29 +1,26 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Numerics;
 using Content.Server.Shuttles.Components;
+using Content.Server.Shuttles.Events;
 using Content.Server.Station.Systems;
 using Content.Shared.Body.Components;
+using Content.Shared.Buckle.Components;
+using Content.Shared.Doors.Components;
 using Content.Shared.Maps;
 using Content.Shared.Parallax;
+using Content.Shared.Shuttles.Components;
 using Content.Shared.Shuttles.Systems;
 using Content.Shared.StatusEffect;
+using JetBrains.Annotations;
 using Robust.Shared.Audio;
 using Robust.Shared.Collections;
 using Robust.Shared.Map;
-using Robust.Shared.Player;
-using Robust.Shared.Utility;
-using System.Diagnostics.CodeAnalysis;
-using System.Numerics;
-using System.Linq;
-using Content.Server.Shuttles.Events;
-using Content.Shared.Body.Components;
-using Content.Shared.Buckle.Components;
-using Content.Shared.Doors.Components;
-using Content.Shared.Mobs.Components;
-using Content.Shared.Shuttles.Components;
-using Content.Shared.Throwing;
-using JetBrains.Annotations;
 using Robust.Shared.Map.Components;
 using Robust.Shared.Physics;
 using Robust.Shared.Physics.Components;
+using Robust.Shared.Player;
+using Robust.Shared.Utility;
 
 namespace Content.Server.Shuttles.Systems;
 
@@ -231,7 +228,7 @@ public sealed partial class ShuttleSystem
         component = AddComp<FTLComponent>(uid);
         component.State = FTLState.Starting;
         // TODO: Need BroadcastGrid to not be bad.
-        SoundSystem.Play(_startupSound.GetSound(), Filter.Empty().AddInRange(Transform(uid).MapPosition, GetSoundRange(component.Owner)), _startupSound.Params);
+        SoundSystem.Play(_startupSound.GetSound(), Filter.Empty().AddInRange(Transform(uid).MapPosition, GetSoundRange(uid)), _startupSound.Params);
         // Make sure the map is setup before we leave to avoid pop-in (e.g. parallax).
         SetupHyperspace();
         return true;
@@ -608,16 +605,20 @@ public sealed partial class ShuttleSystem
         var iteration = 0;
         var lastCount = nearbyGrids.Count;
         var mapId = targetXform.MapID;
+        var grids = new List<Entity<MapGridComponent>>();
 
         while (iteration < FTLProximityIterations)
         {
-            foreach (var grid in _mapManager.FindGridsIntersecting(mapId, targetAABB))
+            grids.Clear();
+            _mapManager.FindGridsIntersecting(mapId, targetAABB, ref grids);
+
+            foreach (var grid in grids)
             {
-                if (!nearbyGrids.Add(grid.Owner))
+                if (!nearbyGrids.Add(grid))
                     continue;
 
-                targetAABB = targetAABB.Union(_transform.GetWorldMatrix(grid.Owner, xformQuery)
-                    .TransformBox(Comp<MapGridComponent>(grid.Owner).LocalAABB));
+                targetAABB = targetAABB.Union(_transform.GetWorldMatrix(grid, xformQuery)
+                    .TransformBox(Comp<MapGridComponent>(grid).LocalAABB));
             }
 
             // Can do proximity
@@ -634,14 +635,15 @@ public sealed partial class ShuttleSystem
             if (iteration != FTLProximityIterations)
                 continue;
 
-            foreach (var grid in _mapManager.GetAllGrids())
+            var query = AllEntityQuery<MapGridComponent>();
+            while (query.MoveNext(out var uid, out var grid))
             {
                 // Don't add anymore as it is irrelevant, but that doesn't mean we need to re-do existing work.
-                if (nearbyGrids.Contains(grid.Owner))
+                if (nearbyGrids.Contains(uid))
                     continue;
 
-                targetAABB = targetAABB.Union(_transform.GetWorldMatrix(grid.Owner, xformQuery)
-                    .TransformBox(Comp<MapGridComponent>(grid.Owner).LocalAABB));
+                targetAABB = targetAABB.Union(_transform.GetWorldMatrix(uid, xformQuery)
+                    .TransformBox(Comp<MapGridComponent>(uid).LocalAABB));
             }
 
             break;
index 15c89b2134a2c9314c27f06afa49426067403933..bf265da2e64422cc64630218b01ec56dc16b9263 100644 (file)
@@ -76,12 +76,14 @@ public sealed partial class ShuttleSystem
     protected override void UpdateIFFInterfaces(EntityUid gridUid, IFFComponent component)
     {
         base.UpdateIFFInterfaces(gridUid, component);
-        foreach (var (comp, xform) in EntityQuery<IFFConsoleComponent, TransformComponent>(true))
+
+        var query = AllEntityQuery<IFFConsoleComponent, TransformComponent>();
+        while (query.MoveNext(out var uid, out var comp, out var xform))
         {
             if (xform.GridUid != gridUid)
                 continue;
 
-            _uiSystem.TrySetUiState(comp.Owner, IFFConsoleUiKey.Key, new IFFConsoleBoundUserInterfaceState()
+            _uiSystem.TrySetUiState(uid, IFFConsoleUiKey.Key, new IFFConsoleBoundUserInterfaceState()
             {
                 AllowedFlags = comp.AllowedFlags,
                 Flags = component.Flags,
index 1fd9fabb803288809d1003737e8f86a907422be6..ed7208ab470b35010aca1c1b95d96cafe13bfce8 100644 (file)
@@ -130,6 +130,15 @@ public sealed class ThrusterSystem : EntitySystem
     private void OnActivateThruster(EntityUid uid, ThrusterComponent component, ActivateInWorldEvent args)
     {
         component.Enabled ^= true;
+
+        if (!component.Enabled)
+        {
+            DisableThruster(uid, component);
+        }
+        else if (CanEnable(uid, component))
+        {
+            EnableThruster(uid, component);
+        }
     }
 
     /// <summary>
index 171f27752f9d2b5cf3db6b03476559ae97a67e50..d58458527f6f48ed868104f554c77f1d4109c1c9 100644 (file)
@@ -1,15 +1,15 @@
 using Content.Server.Administration.Logs;
-using Content.Server.Singularity.Events;
-using Content.Shared.Singularity.Components;
-using Content.Shared.Tag;
-using Robust.Server.GameObjects;
-using Robust.Shared.Physics;
 using Content.Server.Popups;
+using Content.Server.Singularity.Events;
 using Content.Shared.Construction.Components;
 using Content.Shared.Database;
 using Content.Shared.Examine;
 using Content.Shared.Interaction;
 using Content.Shared.Popups;
+using Content.Shared.Singularity.Components;
+using Content.Shared.Tag;
+using Robust.Server.GameObjects;
+using Robust.Shared.Physics;
 using Robust.Shared.Physics.Components;
 using Robust.Shared.Physics.Events;
 
@@ -52,7 +52,7 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem
 
             if (generator.Accumulator >= generator.Threshold)
             {
-                LosePower(uid, generator.PowerLoss, generator);
+                LosePower((uid, generator), generator.PowerLoss);
                 generator.Accumulator -= generator.Threshold;
             }
         }
@@ -63,12 +63,12 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem
     /// <summary>
     /// A generator receives power from a source colliding with it.
     /// </summary>
-    private void HandleGeneratorCollide(EntityUid uid, ContainmentFieldGeneratorComponent component, ref StartCollideEvent args)
+    private void HandleGeneratorCollide(Entity<ContainmentFieldGeneratorComponent> generator, ref StartCollideEvent args)
     {
-        if (_tags.HasTag(args.OtherEntity, component.IDTag))
+        if (_tags.HasTag(args.OtherEntity, generator.Comp.IDTag))
         {
-            ReceivePower(component.PowerReceived, component);
-            component.Accumulator = 0f;
+            ReceivePower(generator.Comp.PowerReceived, generator);
+            generator.Comp.Accumulator = 0f;
         }
     }
 
@@ -81,35 +81,35 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem
             args.PushMarkup(Loc.GetString("comp-containment-off"));
     }
 
-    private void OnInteract(EntityUid uid, ContainmentFieldGeneratorComponent component, InteractHandEvent args)
+    private void OnInteract(Entity<ContainmentFieldGeneratorComponent> generator, ref InteractHandEvent args)
     {
         if (args.Handled)
             return;
 
-        if (TryComp(component.Owner, out TransformComponent? transformComp) && transformComp.Anchored)
+        if (TryComp(generator, out TransformComponent? transformComp) && transformComp.Anchored)
         {
-            if (!component.Enabled)
-                TurnOn(component);
-            else if (component.Enabled && component.IsConnected)
+            if (!generator.Comp.Enabled)
+                TurnOn(generator);
+            else if (generator.Comp.Enabled && generator.Comp.IsConnected)
             {
                 _popupSystem.PopupEntity(Loc.GetString("comp-containment-toggle-warning"), args.User, args.User, PopupType.LargeCaution);
                 return;
             }
             else
-                TurnOff(component);
+                TurnOff(generator);
         }
         args.Handled = true;
     }
 
-    private void OnAnchorChanged(EntityUid uid, ContainmentFieldGeneratorComponent component, ref AnchorStateChangedEvent args)
+    private void OnAnchorChanged(Entity<ContainmentFieldGeneratorComponent> generator, ref AnchorStateChangedEvent args)
     {
         if (!args.Anchored)
-            RemoveConnections(uid, component);
+            RemoveConnections(generator);
     }
 
-    private void OnReanchorEvent(EntityUid uid, ContainmentFieldGeneratorComponent component, ref ReAnchorEvent args)
+    private void OnReanchorEvent(Entity<ContainmentFieldGeneratorComponent> generator, ref ReAnchorEvent args)
     {
-        GridCheck(uid, component);
+        GridCheck(generator);
     }
 
     private void OnUnanchorAttempt(EntityUid uid, ContainmentFieldGeneratorComponent component,
@@ -122,41 +122,42 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem
         }
     }
 
-    private void TurnOn(ContainmentFieldGeneratorComponent component)
+    private void TurnOn(Entity<ContainmentFieldGeneratorComponent> generator)
     {
-        component.Enabled = true;
-        ChangeFieldVisualizer(component);
-        _popupSystem.PopupEntity(Loc.GetString("comp-containment-turned-on"), component.Owner);
+        generator.Comp.Enabled = true;
+        ChangeFieldVisualizer(generator);
+        _popupSystem.PopupEntity(Loc.GetString("comp-containment-turned-on"), generator);
     }
 
-    private void TurnOff(ContainmentFieldGeneratorComponent component)
+    private void TurnOff(Entity<ContainmentFieldGeneratorComponent> generator)
     {
-        component.Enabled = false;
-        ChangeFieldVisualizer(component);
-        _popupSystem.PopupEntity(Loc.GetString("comp-containment-turned-off"), component.Owner);
+        generator.Comp.Enabled = false;
+        ChangeFieldVisualizer(generator);
+        _popupSystem.PopupEntity(Loc.GetString("comp-containment-turned-off"), generator);
     }
 
-    private void OnComponentRemoved(EntityUid uid, ContainmentFieldGeneratorComponent component, ComponentRemove args)
+    private void OnComponentRemoved(Entity<ContainmentFieldGeneratorComponent> generator, ref ComponentRemove args)
     {
-        RemoveConnections(uid, component);
+        RemoveConnections(generator);
     }
 
     /// <summary>
     /// Deletes the fields and removes the respective connections for the generators.
     /// </summary>
-    private void RemoveConnections(EntityUid uid, ContainmentFieldGeneratorComponent component)
+    private void RemoveConnections(Entity<ContainmentFieldGeneratorComponent> generator)
     {
+        var (uid, component) = generator;
         foreach (var (direction, value) in component.Connections)
         {
             foreach (var field in value.Item2)
             {
                 QueueDel(field);
             }
-            value.Item1.Connections.Remove(direction.GetOpposite());
+            value.Item1.Comp.Connections.Remove(direction.GetOpposite());
 
-            if (value.Item1.Connections.Count == 0) //Change isconnected only if there's no more connections
+            if (value.Item1.Comp.Connections.Count == 0) //Change isconnected only if there's no more connections
             {
-                value.Item1.IsConnected = false;
+                value.Item1.Comp.IsConnected = false;
                 ChangeOnLightVisualizer(value.Item1);
             }
 
@@ -164,10 +165,10 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem
         }
         component.Connections.Clear();
         component.IsConnected = false;
-        ChangeOnLightVisualizer(component);
-        ChangeFieldVisualizer(component);
+        ChangeOnLightVisualizer(generator);
+        ChangeFieldVisualizer(generator);
         _adminLogger.Add(LogType.FieldGeneration, LogImpact.Medium, $"{ToPrettyString(uid)} lost field connections"); // Ideally LogImpact would depend on if there is a singulo nearby
-        _popupSystem.PopupEntity(Loc.GetString("comp-containment-disconnected"), component.Owner, PopupType.LargeCaution);
+        _popupSystem.PopupEntity(Loc.GetString("comp-containment-disconnected"), uid, PopupType.LargeCaution);
     }
 
     #endregion
@@ -178,11 +179,12 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem
     /// Stores power in the generator. If it hits the threshold, it tries to establish a connection.
     /// </summary>
     /// <param name="power">The power that this generator received from the collision in <see cref="HandleGeneratorCollide"/></param>
-    public void ReceivePower(int power, ContainmentFieldGeneratorComponent component)
+    public void ReceivePower(int power, Entity<ContainmentFieldGeneratorComponent> generator)
     {
+        var component = generator.Comp;
         component.PowerBuffer += power;
 
-        var genXForm = Transform(component.Owner);
+        var genXForm = Transform(generator);
 
         if (component.PowerBuffer >= component.PowerMinimum)
         {
@@ -194,23 +196,24 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem
                 if (component.Connections.ContainsKey(dir))
                     continue; // This direction already has an active connection
 
-                TryGenerateFieldConnection(dir, component, genXForm);
+                TryGenerateFieldConnection(dir, generator, genXForm);
             }
         }
 
-        ChangePowerVisualizer(power, component);
+        ChangePowerVisualizer(power, generator);
     }
 
-    public void LosePower(EntityUid uid, int power, ContainmentFieldGeneratorComponent component)
+    public void LosePower(Entity<ContainmentFieldGeneratorComponent> generator, int power)
     {
+        var component = generator.Comp;
         component.PowerBuffer -= power;
 
         if (component.PowerBuffer < component.PowerMinimum && component.Connections.Count != 0)
         {
-            RemoveConnections(uid, component);
+            RemoveConnections(generator);
         }
 
-        ChangePowerVisualizer(power, component);
+        ChangePowerVisualizer(power, generator);
     }
 
     /// <summary>
@@ -218,11 +221,12 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem
     /// If all the checks pass and fields spawn, it will store this connection on each respective generator.
     /// </summary>
     /// <param name="dir">The field generator establishes a connection in this direction.</param>
-    /// <param name="component">The field generator component</param>
+    /// <param name="generator">The field generator component</param>
     /// <param name="gen1XForm">The transform component for the first generator</param>
     /// <returns></returns>
-    private bool TryGenerateFieldConnection(Direction dir, ContainmentFieldGeneratorComponent component, TransformComponent gen1XForm)
+    private bool TryGenerateFieldConnection(Direction dir, Entity<ContainmentFieldGeneratorComponent> generator, TransformComponent gen1XForm)
     {
+        var component = generator.Comp;
         if (!component.Enabled)
             return false;
 
@@ -233,7 +237,7 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem
         var dirRad = dir.ToAngle() + genWorldPosRot.WorldRotation; //needs to be like this for the raycast to work properly
 
         var ray = new CollisionRay(genWorldPosRot.WorldPosition, dirRad.ToVec(), component.CollisionMask);
-        var rayCastResults = _physics.IntersectRay(gen1XForm.MapID, ray, component.MaxLength, component.Owner, false);
+        var rayCastResults = _physics.IntersectRay(gen1XForm.MapID, ray, component.MaxLength, generator, false);
         var genQuery = GetEntityQuery<ContainmentFieldGeneratorComponent>();
 
         RayCastResults? closestResult = null;
@@ -254,46 +258,47 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem
             otherFieldGeneratorComponent == component ||
             !TryComp<PhysicsComponent>(ent, out var collidableComponent) ||
             collidableComponent.BodyType != BodyType.Static ||
-            gen1XForm.ParentUid != Transform(otherFieldGeneratorComponent.Owner).ParentUid)
+            gen1XForm.ParentUid != Transform(ent).ParentUid)
         {
             return false;
         }
 
-        var fields = GenerateFieldConnection(component, otherFieldGeneratorComponent);
+        var otherFieldGenerator = (ent, otherFieldGeneratorComponent);
+        var fields = GenerateFieldConnection(generator, otherFieldGenerator);
 
-        component.Connections[dir] = (otherFieldGeneratorComponent, fields);
-        otherFieldGeneratorComponent.Connections[dir.GetOpposite()] = (component, fields);
-        ChangeFieldVisualizer(otherFieldGeneratorComponent);
+        component.Connections[dir] = (otherFieldGenerator, fields);
+        otherFieldGeneratorComponent.Connections[dir.GetOpposite()] = (generator, fields);
+        ChangeFieldVisualizer(otherFieldGenerator);
 
         if (!component.IsConnected)
         {
             component.IsConnected = true;
-            ChangeOnLightVisualizer(component);
+            ChangeOnLightVisualizer(generator);
         }
 
         if (!otherFieldGeneratorComponent.IsConnected)
         {
             otherFieldGeneratorComponent.IsConnected = true;
-            ChangeOnLightVisualizer(otherFieldGeneratorComponent);
+            ChangeOnLightVisualizer(otherFieldGenerator);
         }
 
-        ChangeFieldVisualizer(component);
-        UpdateConnectionLights(component);
-        _popupSystem.PopupEntity(Loc.GetString("comp-containment-connected"), component.Owner);
+        ChangeFieldVisualizer(generator);
+        UpdateConnectionLights(generator);
+        _popupSystem.PopupEntity(Loc.GetString("comp-containment-connected"), generator);
         return true;
     }
 
     /// <summary>
     /// Spawns fields between two generators if the <see cref="TryGenerateFieldConnection"/> finds two generators to connect.
     /// </summary>
-    /// <param name="firstGenComp">The source field generator</param>
-    /// <param name="secondGenComp">The second generator that the source is connected to</param>
+    /// <param name="firstGen">The source field generator</param>
+    /// <param name="secondGen">The second generator that the source is connected to</param>
     /// <returns></returns>
-    private List<EntityUid> GenerateFieldConnection(ContainmentFieldGeneratorComponent firstGenComp, ContainmentFieldGeneratorComponent secondGenComp)
+    private List<EntityUid> GenerateFieldConnection(Entity<ContainmentFieldGeneratorComponent> firstGen, Entity<ContainmentFieldGeneratorComponent> secondGen)
     {
         var fieldList = new List<EntityUid>();
-        var gen1Coords = Transform(firstGenComp.Owner).Coordinates;
-        var gen2Coords = Transform(secondGenComp.Owner).Coordinates;
+        var gen1Coords = Transform(firstGen).Coordinates;
+        var gen2Coords = Transform(secondGen).Coordinates;
 
         var delta = (gen2Coords - gen1Coords).Position;
         var dirVec = delta.Normalized();
@@ -302,10 +307,10 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem
         while (currentOffset.Length() < stopDist)
         {
             var currentCoords = gen1Coords.Offset(currentOffset);
-            var newField = Spawn(firstGenComp.CreatedField, currentCoords);
+            var newField = Spawn(firstGen.Comp.CreatedField, currentCoords);
 
             var fieldXForm = Transform(newField);
-            fieldXForm.AttachParent(firstGenComp.Owner);
+            fieldXForm.AttachParent(firstGen);
             if (dirVec.GetDir() == Direction.East || dirVec.GetDir() == Direction.West)
             {
                 var angle = fieldXForm.LocalPosition.ToAngle();
@@ -324,28 +329,28 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem
     /// <summary>
     /// Creates a light component for the spawned fields.
     /// </summary>
-    public void UpdateConnectionLights(ContainmentFieldGeneratorComponent component)
+    public void UpdateConnectionLights(Entity<ContainmentFieldGeneratorComponent> generator)
     {
-        if (_light.TryGetLight(component.Owner, out var pointLightComponent))
+        if (_light.TryGetLight(generator, out var pointLightComponent))
         {
-            _light.SetEnabled(component.Owner, component.Connections.Count > 0, pointLightComponent);
+            _light.SetEnabled(generator, generator.Comp.Connections.Count > 0, pointLightComponent);
         }
     }
 
     /// <summary>
     /// Checks to see if this or the other gens connected to a new grid. If they did, remove connection.
     /// </summary>
-    public void GridCheck(EntityUid uid, ContainmentFieldGeneratorComponent component)
+    public void GridCheck(Entity<ContainmentFieldGeneratorComponent> generator)
     {
         var xFormQuery = GetEntityQuery<TransformComponent>();
 
-        foreach (var (_, generators) in component.Connections)
+        foreach (var (_, generators) in generator.Comp.Connections)
         {
-            var gen1ParentGrid = xFormQuery.GetComponent(component.Owner).ParentUid;
-            var gent2ParentGrid = xFormQuery.GetComponent(generators.Item1.Owner).ParentUid;
+            var gen1ParentGrid = xFormQuery.GetComponent(generator).ParentUid;
+            var gent2ParentGrid = xFormQuery.GetComponent(generators.Item1).ParentUid;
 
             if (gen1ParentGrid != gent2ParentGrid)
-                RemoveConnections(uid, component);
+                RemoveConnections(generator);
         }
     }
 
@@ -356,32 +361,37 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem
     /// Check if a fields power falls between certain ranges to update the field gen visual for power.
     /// </summary>
     /// <param name="power"></param>
-    /// <param name="component"></param>
-    private void ChangePowerVisualizer(int power, ContainmentFieldGeneratorComponent component)
+    /// <param name="generator"></param>
+    private void ChangePowerVisualizer(int power, Entity<ContainmentFieldGeneratorComponent> generator)
     {
-        _visualizer.SetData(component.Owner, ContainmentFieldGeneratorVisuals.PowerLight, component.PowerBuffer switch {
-            <=0 => PowerLevelVisuals.NoPower,
-            >=25 => PowerLevelVisuals.HighPower,
-            _ => (component.PowerBuffer < component.PowerMinimum) ? PowerLevelVisuals.LowPower : PowerLevelVisuals.MediumPower
+        var component = generator.Comp;
+        _visualizer.SetData(generator, ContainmentFieldGeneratorVisuals.PowerLight, component.PowerBuffer switch
+        {
+            <= 0 => PowerLevelVisuals.NoPower,
+            >= 25 => PowerLevelVisuals.HighPower,
+            _ => (component.PowerBuffer < component.PowerMinimum)
+                ? PowerLevelVisuals.LowPower
+                : PowerLevelVisuals.MediumPower
         });
     }
 
     /// <summary>
     /// Check if a field has any or no connections and if it's enabled to toggle the field level light
     /// </summary>
-    /// <param name="component"></param>
-    private void ChangeFieldVisualizer(ContainmentFieldGeneratorComponent component)
+    /// <param name="generator"></param>
+    private void ChangeFieldVisualizer(Entity<ContainmentFieldGeneratorComponent> generator)
     {
-        _visualizer.SetData(component.Owner, ContainmentFieldGeneratorVisuals.FieldLight, component.Connections.Count switch {
+        _visualizer.SetData(generator, ContainmentFieldGeneratorVisuals.FieldLight, generator.Comp.Connections.Count switch
+        {
             >1 => FieldLevelVisuals.MultipleFields,
             1 => FieldLevelVisuals.OneField,
-            _ => component.Enabled ? FieldLevelVisuals.On : FieldLevelVisuals.NoLevel
+            _ => generator.Comp.Enabled ? FieldLevelVisuals.On : FieldLevelVisuals.NoLevel
         });
     }
 
-    private void ChangeOnLightVisualizer(ContainmentFieldGeneratorComponent component)
+    private void ChangeOnLightVisualizer(Entity<ContainmentFieldGeneratorComponent> generator)
     {
-        _visualizer.SetData(component.Owner, ContainmentFieldGeneratorVisuals.OnLight, component.IsConnected);
+        _visualizer.SetData(generator, ContainmentFieldGeneratorVisuals.OnLight, generator.Comp.IsConnected);
     }
     #endregion
 
index 70cc992dc3c26ddfca983cfc2d2da3e04d5239cf..561db76a470f0b625040eac61cf94688051afed9 100644 (file)
@@ -26,15 +26,15 @@ public sealed class ContainmentFieldSystem : EntitySystem
     {
         var otherBody = args.OtherEntity;
 
-        if (TryComp<SpaceGarbageComponent>(otherBody, out var garbage))
+        if (HasComp<SpaceGarbageComponent>(otherBody))
         {
-            _popupSystem.PopupEntity(Loc.GetString("comp-field-vaporized", ("entity", otherBody)), component.Owner, PopupType.LargeCaution);
-            QueueDel(garbage.Owner);
+            _popupSystem.PopupEntity(Loc.GetString("comp-field-vaporized", ("entity", otherBody)), uid, PopupType.LargeCaution);
+            QueueDel(otherBody);
         }
 
         if (TryComp<PhysicsComponent>(otherBody, out var physics) && physics.Mass <= component.MaxMass && physics.Hard)
         {
-            var fieldDir = Transform(component.Owner).WorldPosition;
+            var fieldDir = Transform(uid).WorldPosition;
             var playerDir = Transform(otherBody).WorldPosition;
 
             _throwing.TryThrow(otherBody, playerDir-fieldDir, strength: component.ThrowForce);
index fd9eb3e8c62aa30b5a4dfa875a97e66ca1934312..a15dad8507e03124a2e4d8bb76d869c77cf4a061 100644 (file)
@@ -304,9 +304,13 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem
         var mapPos = xform.MapPosition;
         var box = Box2.CenteredAround(mapPos.Position, new Vector2(range, range));
         var circle = new Circle(mapPos.Position, range);
-        foreach (var grid in _mapMan.FindGridsIntersecting(mapPos.MapId, box))
-        {   // TODO: Remover grid.Owner when this iterator returns entityuids as well.
-            AttemptConsumeTiles(uid, grid.GetTilesIntersecting(circle), grid.Owner, grid, eventHorizon);
+        var grids = new List<Entity<MapGridComponent>>();
+        _mapMan.FindGridsIntersecting(mapPos.MapId, box, ref grids);
+
+        foreach (var grid in grids)
+        {
+            // TODO: Remover grid.Owner when this iterator returns entityuids as well.
+            AttemptConsumeTiles(uid, grid.Comp.GetTilesIntersecting(circle), grid, grid, eventHorizon);
         }
     }
 
index b10685ed27789f438753632764ede59b804fd4e4..2ba4dbd41cbb0339485b6ba5d8d25366e3e79a6c 100644 (file)
@@ -1,3 +1,6 @@
+using Content.Server.Singularity.Components;
+using Content.Shared.Ghost;
+using Content.Shared.Singularity.EntitySystems;
 using Robust.Shared.Map;
 using Robust.Shared.Map.Components;
 using Robust.Shared.Physics;
@@ -5,10 +8,6 @@ using Robust.Shared.Physics.Components;
 using Robust.Shared.Physics.Systems;
 using Robust.Shared.Timing;
 
-using Content.Shared.Singularity.EntitySystems;
-using Content.Server.Singularity.Components;
-using Content.Shared.Ghost;
-
 namespace Content.Server.Singularity.EntitySystems;
 
 /// <summary>
@@ -58,11 +57,12 @@ public sealed class GravityWellSystem : SharedGravityWellSystem
         if(!_timing.IsFirstTimePredicted)
             return;
 
-        foreach(var (gravWell, xform) in EntityManager.EntityQuery<GravityWellComponent, TransformComponent>())
+        var query = EntityQueryEnumerator<GravityWellComponent, TransformComponent>();
+        while (query.MoveNext(out var uid, out var gravWell, out var xform))
         {
             var curTime = _timing.CurTime;
             if (gravWell.NextPulseTime <= curTime)
-                Update(gravWell.Owner, curTime - gravWell.LastPulseTime, gravWell, xform);
+                Update(uid, curTime - gravWell.LastPulseTime, gravWell, xform);
         }
     }
 
index 37e26b9cc0302c8cf42d274d8d2d5d8cd72fdb52..ddc63156bf0525dcf1eb38b8fc0b0089bd8da3e7 100644 (file)
@@ -1,15 +1,13 @@
-using Robust.Shared.GameStates;
-using Robust.Shared.Player;
-using Robust.Shared.Timing;
-using Robust.Server.GameStates;
-
-using Content.Shared.Singularity.Components;
-using Content.Shared.Singularity.EntitySystems;
-using Content.Shared.Singularity.Events;
-
 using Content.Server.Physics.Components;
 using Content.Server.Singularity.Components;
 using Content.Server.Singularity.Events;
+using Content.Shared.Singularity.Components;
+using Content.Shared.Singularity.EntitySystems;
+using Content.Shared.Singularity.Events;
+using Robust.Server.GameStates;
+using Robust.Shared.GameStates;
+using Robust.Shared.Player;
+using Robust.Shared.Timing;
 
 namespace Content.Server.Singularity.EntitySystems;
 
@@ -75,11 +73,12 @@ public sealed class SingularitySystem : SharedSingularitySystem
         if(!_timing.IsFirstTimePredicted)
             return;
 
-        foreach(var singularity in EntityManager.EntityQuery<SingularityComponent>())
+        var query = EntityQueryEnumerator<SingularityComponent>();
+        while (query.MoveNext(out var uid, out var singularity))
         {
             var curTime = _timing.CurTime;
             if (singularity.NextUpdateTime <= curTime)
-                Update(singularity.Owner, curTime - singularity.LastUpdateTime, singularity);
+                Update(uid, curTime - singularity.LastUpdateTime, singularity);
         }
     }
 
@@ -129,14 +128,15 @@ public sealed class SingularitySystem : SharedSingularitySystem
             return;
 
         singularity.Energy = value;
-        SetLevel(uid, value switch {
-                >= 2400 => 6,
-                >= 1600 => 5,
-                >= 900 => 4,
-                >= 300 => 3,
-                >= 200 => 2,
-                > 0 => 1,
-                _ => 0
+        SetLevel(uid, value switch
+        {
+            >= 2400 => 6,
+            >= 1600 => 5,
+            >= 900 => 4,
+            >= 300 => 3,
+            >= 200 => 2,
+            > 0 => 1,
+            _ => 0
         }, singularity);
     }
 
@@ -204,9 +204,9 @@ public sealed class SingularitySystem : SharedSingularitySystem
 
         MetaDataComponent? metaData = null;
         if (Resolve(uid, ref metaData) && metaData.EntityLifeStage <= EntityLifeStage.Initializing)
-            _audio.Play(comp.FormationSound, Filter.Pvs(comp.Owner), comp.Owner, true);
+            _audio.Play(comp.FormationSound, Filter.Pvs(uid), uid, true);
 
-        comp.AmbientSoundStream = _audio.Play(comp.AmbientSound, Filter.Pvs(comp.Owner), comp.Owner, true);
+        comp.AmbientSoundStream = _audio.Play(comp.AmbientSound, Filter.Pvs(uid), uid, true);
         UpdateSingularityLevel(uid, comp);
     }
 
@@ -236,7 +236,7 @@ public sealed class SingularitySystem : SharedSingularitySystem
 
         MetaDataComponent? metaData = null;
         if (Resolve(uid, ref metaData) && metaData.EntityLifeStage >= EntityLifeStage.Terminating)
-            _audio.Play(comp.DissipationSound, Filter.Pvs(comp.Owner), comp.Owner, true);
+            _audio.Play(comp.DissipationSound, Filter.Pvs(uid), uid, true);
     }
 
     /// <summary>
@@ -283,7 +283,7 @@ public sealed class SingularitySystem : SharedSingularitySystem
         // Should be slightly more efficient than checking literally everything we consume for a singularity component and doing the reverse.
         if (EntityManager.TryGetComponent<SingularityComponent>(args.EventHorizonUid, out var singulo))
         {
-            AdjustEnergy(singulo.Owner, comp.Energy, singularity: singulo);
+            AdjustEnergy(uid, comp.Energy, singularity: singulo);
             SetEnergy(uid, 0.0f, comp);
         }
     }
index cead16b76d326e7dbc8eafbff1ab3d44fc5424f1..6a8fc68d976bd72d2f1151a5026bdd658dfd2c79 100644 (file)
@@ -61,8 +61,7 @@ namespace Content.Server.Solar.EntitySystems
         /// <summary>
         /// Queue of panels to update each cycle.
         /// </summary>
-        private readonly Queue<SolarPanelComponent> _updateQueue = new();
-
+        private readonly Queue<Entity<SolarPanelComponent>> _updateQueue = new();
 
         public override void Initialize()
         {
@@ -102,24 +101,26 @@ namespace Content.Server.Solar.EntitySystems
             if (_updateQueue.Count > 0)
             {
                 var panel = _updateQueue.Dequeue();
-                if (panel.Running)
+                if (panel.Comp.Running)
                     UpdatePanelCoverage(panel);
             }
             else
             {
                 TotalPanelPower = 0;
-                foreach (var (panel, xform) in EntityManager.EntityQuery<SolarPanelComponent, TransformComponent>())
+
+                var query = EntityQueryEnumerator<SolarPanelComponent, TransformComponent>();
+                while (query.MoveNext(out var uid, out var panel, out var xform))
                 {
                     TotalPanelPower += panel.MaxSupply * panel.Coverage;
                     xform.WorldRotation = TargetPanelRotation;
-                    _updateQueue.Enqueue(panel);
+                    _updateQueue.Enqueue((uid, panel));
                 }
             }
         }
 
-        private void UpdatePanelCoverage(SolarPanelComponent panel)
+        private void UpdatePanelCoverage(Entity<SolarPanelComponent> panel)
         {
-            EntityUid entity = panel.Owner;
+            var entity = panel.Owner;
             var xform = EntityManager.GetComponent<TransformComponent>(entity);
 
             // So apparently, and yes, I *did* only find this out later,
@@ -163,8 +164,8 @@ namespace Content.Server.Solar.EntitySystems
             }
 
             // Total coverage calculated; apply it to the panel.
-            panel.Coverage = coverage;
-            UpdateSupply((panel).Owner, panel);
+            panel.Comp.Coverage = coverage;
+            UpdateSupply(panel, panel);
         }
 
         public void UpdateSupply(
index 23dfaef923124f9c64073366c7dfff33d4bd65a3..1f707c2249c3a68e34a96d19fd6afca2ca6a67ed 100644 (file)
@@ -23,16 +23,17 @@ public sealed class AddAccentClothingSystem : EntitySystem
         // check if entity was actually used as clothing
         // not just taken in pockets or something
         var isCorrectSlot = clothing.Slots.HasFlag(args.SlotFlags);
-        if (!isCorrectSlot) return;
+        if (!isCorrectSlot)
+            return;
 
         // does the user already has this accent?
         var componentType = _componentFactory.GetRegistration(component.Accent).Type;
-        if (EntityManager.HasComponent(args.Equipee, componentType)) return;
+        if (HasComp(args.Equipee, componentType))
+            return;
 
         // add accent to the user
         var accentComponent = (Component) _componentFactory.GetComponent(componentType);
-        accentComponent.Owner = args.Equipee;
-        EntityManager.AddComponent(args.Equipee, accentComponent);
+        AddComp(args.Equipee, accentComponent);
 
         // snowflake case for replacement accent
         if (accentComponent is ReplacementAccentComponent rep)
index 8fdf103cd70648e2ed05c15268fea8791fe64c63..65eabd819006e139008268dc04bec3d3e20443e0 100644 (file)
@@ -239,7 +239,7 @@ public sealed class StationSystem : EntitySystem
 
         foreach (var gridUid in dataComponent.Grids)
         {
-            if (!_mapManager.TryGetGrid(gridUid, out var grid) ||
+            if (!TryComp(gridUid, out MapGridComponent? grid) ||
                 !xformQuery.TryGetComponent(gridUid, out var xform))
                 continue;
 
@@ -429,7 +429,7 @@ public sealed class StationSystem : EntitySystem
 
         if (xform.GridUid == EntityUid.Invalid)
         {
-            Logger.Debug("A");
+            Log.Debug("A");
             return null;
         }
 
@@ -438,12 +438,26 @@ public sealed class StationSystem : EntitySystem
 
     public List<EntityUid> GetStations()
     {
-        return EntityQuery<StationDataComponent>().Select(x => x.Owner).ToList();
+        var stations = new List<EntityUid>();
+        var query = EntityQueryEnumerator<StationDataComponent>();
+        while (query.MoveNext(out var uid, out _))
+        {
+            stations.Add(uid);
+        }
+
+        return stations;
     }
 
     public HashSet<EntityUid> GetStationsSet()
     {
-        return EntityQuery<StationDataComponent>().Select(x => x.Owner).ToHashSet();
+        var stations = new HashSet<EntityUid>();
+        var query = EntityQueryEnumerator<StationDataComponent>();
+        while (query.MoveNext(out var uid, out _))
+        {
+            stations.Add(uid);
+        }
+
+        return stations;
     }
 
     /// <summary>
index ddf1ba784cb3a00128ef0f90907d0295af720b3c..709b750334e9b460e5c90fe18a476190cc677ac8 100644 (file)
@@ -1,5 +1,4 @@
-using System.Linq;
-using Content.Server.GameTicking.Rules.Components;
+using Content.Server.GameTicking.Rules.Components;
 using Content.Server.Resist;
 using Content.Server.Station.Components;
 using Content.Server.StationEvents.Components;
@@ -18,13 +17,17 @@ public sealed class BluespaceLockerRule : StationEventSystem<BluespaceLockerRule
     {
         base.Started(uid, component, gameRule, args);
 
-        var targets = EntityQuery<EntityStorageComponent, ResistLockerComponent>().ToList();
+        var targets = new List<EntityUid>();
+        var query = EntityQueryEnumerator<EntityStorageComponent, ResistLockerComponent>();
+        while (query.MoveNext(out var storageUid, out _, out _))
+        {
+            targets.Add(storageUid);
+        }
+
         RobustRandom.Shuffle(targets);
 
-        foreach (var target in targets)
+        foreach (var potentialLink in targets)
         {
-            var potentialLink = target.Item1.Owner;
-
             if (HasComp<AccessReaderComponent>(potentialLink) ||
                 HasComp<BluespaceLockerComponent>(potentialLink) ||
                 !HasComp<StationMemberComponent>(potentialLink.ToCoordinates().GetGridUid(EntityManager)))
index c53f3c5750141955899a01ff00859914013b4b63..494779fe3503168062ed390b722e2fd911c78dcd 100644 (file)
@@ -1,11 +1,9 @@
-using System.Linq;
-using Content.Server.GameTicking.Rules.Components;
+using Content.Server.GameTicking.Rules.Components;
 using Content.Server.Power.Components;
 using Content.Server.Power.EntitySystems;
 using Content.Server.Station.Components;
 using Content.Server.StationEvents.Components;
 using JetBrains.Annotations;
-using Robust.Shared.Random;
 
 namespace Content.Server.StationEvents.Events;
 
@@ -29,12 +27,13 @@ public sealed class BreakerFlipRule : StationEventSystem<BreakerFlipRuleComponen
         if (!TryGetRandomStation(out var chosenStation))
             return;
 
-        var stationApcs = new List<ApcComponent>();
-        foreach (var (apc, transform) in EntityQuery<ApcComponent, TransformComponent>())
+        var stationApcs = new List<Entity<ApcComponent>>();
+        var query = EntityQueryEnumerator<ApcComponent, TransformComponent>();
+        while (query.MoveNext(out var apcUid, out var apc, out var xform))
         {
-            if (apc.MainBreakerEnabled && CompOrNull<StationMemberComponent>(transform.GridUid)?.Station == chosenStation)
+            if (apc.MainBreakerEnabled && CompOrNull<StationMemberComponent>(xform.GridUid)?.Station == chosenStation)
             {
-                stationApcs.Add(apc);
+                stationApcs.Add((apcUid, apc));
             }
         }
 
@@ -46,7 +45,7 @@ public sealed class BreakerFlipRule : StationEventSystem<BreakerFlipRuleComponen
 
         for (var i = 0; i < toDisable; i++)
         {
-            _apcSystem.ApcToggleBreaker(stationApcs[i].Owner, stationApcs[i]);
+            _apcSystem.ApcToggleBreaker(stationApcs[i], stationApcs[i]);
         }
     }
 }
index 5192eef69b1bb543d97fc44558bded48ea38ce5c..ef84d0a9aefa9a93591c103388f21143d5871ce9 100644 (file)
@@ -1,11 +1,11 @@
 using System.Numerics;
 using Content.Server.GameTicking.Rules.Components;
 using Content.Server.StationEvents.Components;
-using Robust.Shared.Spawners;
 using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
 using Robust.Shared.Physics.Components;
 using Robust.Shared.Physics.Systems;
-using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent;
+using Robust.Shared.Spawners;
 
 namespace Content.Server.StationEvents.Events
 {
@@ -43,9 +43,13 @@ namespace Content.Server.StationEvents.Events
             Box2? playableArea = null;
             var mapId = GameTicker.DefaultMap;
 
-            foreach (var grid in MapManager.GetAllMapGrids(mapId))
+            var query = AllEntityQuery<MapGridComponent, TransformComponent>();
+            while (query.MoveNext(out var gridId, out _, out var xform))
             {
-                var aabb = _physics.GetWorldAABB(grid.Owner);
+                if (xform.MapID != mapId)
+                    continue;
+
+                var aabb = _physics.GetWorldAABB(gridId);
                 playableArea = playableArea?.Union(aabb) ?? aabb;
             }
 
index d24f04d800035512e798e091135f3c99ce72c354..fdd3e30d437ad5e5e07c3aee9f8afb2f8a023d3c 100644 (file)
@@ -1,16 +1,14 @@
+using System.Threading;
+using Content.Server.GameTicking.Rules.Components;
 using Content.Server.Power.Components;
+using Content.Server.Power.EntitySystems;
+using Content.Server.Station.Components;
+using Content.Server.StationEvents.Components;
 using JetBrains.Annotations;
 using Robust.Shared.Audio;
 using Robust.Shared.Player;
 using Robust.Shared.Utility;
-using System.Threading;
-using Content.Server.Power.EntitySystems;
 using Timer = Robust.Shared.Timing.Timer;
-using System.Linq;
-using Content.Server.GameTicking.Rules.Components;
-using Robust.Shared.Random;
-using Content.Server.Station.Components;
-using Content.Server.StationEvents.Components;
 
 namespace Content.Server.StationEvents.Events
 {
@@ -26,10 +24,11 @@ namespace Content.Server.StationEvents.Events
             if (!TryGetRandomStation(out var chosenStation))
                 return;
 
-            foreach (var (apc, transform) in EntityQuery<ApcComponent, TransformComponent>(true))
+            var query = AllEntityQuery<ApcComponent, TransformComponent>();
+            while (query.MoveNext(out var apcUid ,out var apc, out var transform))
             {
                 if (apc.MainBreakerEnabled && CompOrNull<StationMemberComponent>(transform.GridUid)?.Station == chosenStation)
-                    component.Powered.Add(apc.Owner);
+                    component.Powered.Add(apcUid);
             }
 
             RobustRandom.Shuffle(component.Powered);
index 8b2128178adf2da238277c663e77f8724caffbd7..d90361fe9629f174075f0244e128d7a72b47e7d9 100644 (file)
@@ -1,8 +1,6 @@
 using System.Linq;
-using Content.Server.Chat.Systems;
 using Content.Server.GameTicking.Rules.Components;
 using Content.Server.Ghost.Roles.Components;
-using Content.Server.Station.Systems;
 using Content.Server.StationEvents.Components;
 
 namespace Content.Server.StationEvents.Events;
@@ -14,7 +12,13 @@ public sealed class RandomSentienceRule : StationEventSystem<RandomSentienceRule
         HashSet<EntityUid> stationsToNotify = new();
 
         var mod = GetSeverityModifier();
-        var targetList = EntityQuery<SentienceTargetComponent>().ToList();
+        var targetList = new List<Entity<SentienceTargetComponent>>();
+        var query = EntityQueryEnumerator<SentienceTargetComponent>();
+        while (query.MoveNext(out var targetUid, out var target))
+        {
+            targetList.Add((targetUid, target));
+        }
+
         RobustRandom.Shuffle(targetList);
 
         var toMakeSentient = (int) (RobustRandom.Next(2, 5) * Math.Sqrt(mod));
@@ -25,12 +29,12 @@ public sealed class RandomSentienceRule : StationEventSystem<RandomSentienceRule
             if (toMakeSentient-- == 0)
                 break;
 
-            RemComp<SentienceTargetComponent>(target.Owner);
-            var ghostRole = EnsureComp<GhostRoleComponent>(target.Owner);
-            EnsureComp<GhostTakeoverAvailableComponent>(target.Owner);
-            ghostRole.RoleName = MetaData(target.Owner).EntityName;
+            RemComp<SentienceTargetComponent>(target);
+            var ghostRole = EnsureComp<GhostRoleComponent>(target);
+            EnsureComp<GhostTakeoverAvailableComponent>(target);
+            ghostRole.RoleName = MetaData(target).EntityName;
             ghostRole.RoleDescription = Loc.GetString("station-event-random-sentience-role-description", ("name", ghostRole.RoleName));
-            groups.Add(Loc.GetString(target.FlavorKind));
+            groups.Add(Loc.GetString(target.Comp.FlavorKind));
         }
 
         if (groups.Count == 0)
@@ -43,8 +47,9 @@ public sealed class RandomSentienceRule : StationEventSystem<RandomSentienceRule
 
         foreach (var target in targetList)
         {
-            var station = StationSystem.GetOwningStation(target.Owner);
-            if(station == null) continue;
+            var station = StationSystem.GetOwningStation(target);
+            if(station == null)
+                continue;
             stationsToNotify.Add((EntityUid) station);
         }
         foreach (var station in stationsToNotify)
index 805eabb3573c23402e32859dd5cfef805fe192f7..4333465f27d9a6eb230704e69d46d3bece605ce6 100644 (file)
@@ -196,7 +196,13 @@ public sealed class BluespaceLockerSystem : EntitySystem
             if (component.BluespaceLinks.Count < component.MinBluespaceLinks)
             {
                 // Get an shuffle the list of all EntityStorages
-                var storages = EntityQuery<EntityStorageComponent>().ToArray();
+                var storages = new List<Entity<EntityStorageComponent>>();
+                var query = EntityQueryEnumerator<EntityStorageComponent>();
+                while (query.MoveNext(out var uid, out var storage))
+                {
+                    storages.Add((uid, storage));
+                }
+
                 _robustRandom.Shuffle(storages);
 
                 // Add valid candidates till MinBluespaceLinks is met
index 1492a3f481b96ff6a8b75cb1cbe59d5a1af20a63..f51c215c6e43a344c8854aa04d8c04a5dce0b337 100644 (file)
@@ -1,10 +1,10 @@
+using System.Linq;
 using Content.Server.Storage.Components;
 using Content.Shared.Audio;
+using Content.Shared.Storage.Components;
 using Robust.Shared.Audio;
 using Robust.Shared.Player;
 using Robust.Shared.Random;
-using System.Linq;
-using Content.Shared.Storage.Components;
 
 namespace Content.Server.Storage.EntitySystems;
 
@@ -28,13 +28,19 @@ public sealed class CursedEntityStorageSystem : EntitySystem
         if (storage.Open || storage.Contents.ContainedEntities.Count <= 0)
             return;
 
-        var lockerQuery = EntityQuery<EntityStorageComponent>().ToList();
-        lockerQuery.Remove(storage);
+        var lockers = new List<Entity<EntityStorageComponent>>();
+        var query = EntityQueryEnumerator<EntityStorageComponent>();
+        while (query.MoveNext(out var storageUid, out var storageComp))
+        {
+            lockers.Add((storageUid, storageComp));
+        }
+
+        lockers.RemoveAll(e => e.Owner == uid);
 
-        if (lockerQuery.Count == 0)
+        if (lockers.Count == 0)
             return;
 
-        var lockerEnt = _random.Pick(lockerQuery).Owner;
+        var lockerEnt = _random.Pick(lockers).Owner;
 
         foreach (var entity in storage.Contents.ContainedEntities.ToArray())
         {
index cbd4883b4cdf73d2919bf0f257d0aff70a85cd88..4bcad622c720d65999528f35ce2c494b4dc0028b 100644 (file)
@@ -12,6 +12,7 @@ using Content.Shared.Storage.Components;
 using Content.Shared.Storage.EntitySystems;
 using Content.Shared.Tools.Systems;
 using Content.Shared.Verbs;
+using Robust.Server.GameObjects;
 using Robust.Shared.Containers;
 using Robust.Shared.GameStates;
 using Robust.Shared.Map;
@@ -23,6 +24,7 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
     [Dependency] private readonly ConstructionSystem _construction = default!;
     [Dependency] private readonly AtmosphereSystem _atmos = default!;
     [Dependency] private readonly IMapManager _map = default!;
+    [Dependency] private readonly MapSystem _mapSystem = default!;
 
     public override void Initialize()
     {
@@ -130,9 +132,9 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
     {
         var targetCoordinates = new EntityCoordinates(uid, component.EnteringOffset).ToMap(EntityManager, TransformSystem);
 
-        if (_map.TryFindGridAt(targetCoordinates, out _, out var grid))
+        if (_map.TryFindGridAt(targetCoordinates, out var gridId, out var grid))
         {
-            return grid.GetTileRef(targetCoordinates);
+            return _mapSystem.GetTileRef(gridId, grid, targetCoordinates);
         }
 
         return null;
index 50f6db459c163f8c6588bb5eb8750b4c35316493..dbbe1dd7785f762d1bd55cdc96a2303da1920627 100644 (file)
@@ -1,11 +1,11 @@
+using System.Linq;
 using Content.Server.Storage.Components;
 using Content.Shared.Database;
 using Content.Shared.Hands.EntitySystems;
+using Content.Shared.Storage;
 using Content.Shared.Verbs;
 using Robust.Shared.Containers;
 using Robust.Shared.Random;
-using System.Linq;
-using Content.Shared.Storage;
 
 namespace Content.Server.Storage.EntitySystems;
 
@@ -55,7 +55,7 @@ public sealed class PickRandomSystem : EntitySystem
 
         var picked = _random.Pick(entities);
         // if it fails to go into a hand of the user, will be on the storage
-        _container.AttachParentToContainerOrGrid(Transform(picked));
+        _container.AttachParentToContainerOrGrid((picked, Transform(picked)));
 
         // TODO: try to put in hands, failing that put it on the storage
         _hands.TryPickupAnyHand(user, picked);
index 061ddee824f41510b4dbbbc40f49475d5c085b3f..25c31e48ca65bb9ab40449c606a412d2a5f565b0 100644 (file)
@@ -4,7 +4,6 @@ using Content.Server.Storage.Components;
 using Content.Shared.Database;
 using Content.Shared.Hands.EntitySystems;
 using Content.Shared.Interaction.Events;
-using Content.Shared.Storage;
 using Robust.Shared.Audio;
 using Robust.Shared.Map;
 using Robust.Shared.Player;
@@ -76,7 +75,7 @@ namespace Content.Server.Storage.EntitySystems
             foreach (var proto in spawnEntities)
             {
                 entityToPlaceInHands = Spawn(proto, coords);
-                _adminLogger.Add(LogType.EntitySpawn, LogImpact.Low, $"{ToPrettyString(args.User)} used {ToPrettyString(component.Owner)} which spawned {ToPrettyString(entityToPlaceInHands.Value)}");
+                _adminLogger.Add(LogType.EntitySpawn, LogImpact.Low, $"{ToPrettyString(args.User)} used {ToPrettyString(uid)} which spawned {ToPrettyString(entityToPlaceInHands.Value)}");
             }
 
             if (component.Sound != null)
index 8f723ab97d4634f4680bc601d9374e5fdc1553e7..a8ddf1a986bdbe9a41cc0fb2fe9b215b8aa9c1b8 100644 (file)
@@ -63,7 +63,7 @@ namespace Content.Server.Strip
             }
         }
 
-        private void OnStripButtonPressed(EntityUid target, StrippableComponent component, StrippingSlotButtonPressed args)
+        private void OnStripButtonPressed(Entity<StrippableComponent> strippable, ref StrippingSlotButtonPressed args)
         {
             if (args.Session.AttachedEntity is not {Valid: true} user ||
                 !TryComp<HandsComponent>(user, out var userHands))
@@ -71,22 +71,22 @@ namespace Content.Server.Strip
 
             if (args.IsHand)
             {
-                StripHand(target, user, args.Slot, component,  userHands);
+                StripHand(user, args.Slot, strippable, userHands);
                 return;
             }
 
-            if (!TryComp<InventoryComponent>(target, out var inventory))
+            if (!TryComp<InventoryComponent>(strippable, out var inventory))
                 return;
 
-            var hasEnt = _inventorySystem.TryGetSlotEntity(target, args.Slot, out var held, inventory);
+            var hasEnt = _inventorySystem.TryGetSlotEntity(strippable, args.Slot, out var held, inventory);
 
             if (userHands.ActiveHandEntity != null && !hasEnt)
-                PlaceActiveHandItemInInventory(user, target, userHands.ActiveHandEntity.Value, args.Slot, component);
+                PlaceActiveHandItemInInventory(user, strippable, userHands.ActiveHandEntity.Value, args.Slot, strippable);
             else if (userHands.ActiveHandEntity == null && hasEnt)
-                TakeItemFromInventory(user, target, held!.Value, args.Slot, component);
+                TakeItemFromInventory(user, strippable, held!.Value, args.Slot, strippable);
         }
 
-        private void StripHand(EntityUid target, EntityUid user, string handId, StrippableComponent component, HandsComponent userHands)
+        private void StripHand(EntityUid user, string handId, Entity<StrippableComponent> target, HandsComponent userHands)
         {
             if (!_handsSystem.TryGetHand(target, handId, out var hand))
                 return;
@@ -101,23 +101,23 @@ namespace Content.Server.Strip
             }
 
             if (userHands.ActiveHandEntity != null && hand.HeldEntity == null)
-                PlaceActiveHandItemInHands(user, target, userHands.ActiveHandEntity.Value, handId, component);
+                PlaceActiveHandItemInHands(user, target, userHands.ActiveHandEntity.Value, handId, target);
             else if (userHands.ActiveHandEntity == null && hand.HeldEntity != null)
-                TakeItemFromHands(user,target, hand.HeldEntity.Value, handId, component);
+                TakeItemFromHands(user, target, hand.HeldEntity.Value, handId, target);
         }
 
-        public override void StartOpeningStripper(EntityUid user, StrippableComponent component, bool openInCombat = false)
+        public override void StartOpeningStripper(EntityUid user, Entity<StrippableComponent> strippable, bool openInCombat = false)
         {
-            base.StartOpeningStripper(user, component, openInCombat);
+            base.StartOpeningStripper(user, strippable, openInCombat);
 
             if (TryComp<CombatModeComponent>(user, out var mode) && mode.IsInCombatMode && !openInCombat)
                 return;
 
             if (TryComp<ActorComponent>(user, out var actor))
             {
-                if (_userInterfaceSystem.SessionHasOpenUi(component.Owner, StrippingUiKey.Key, actor.PlayerSession))
+                if (_userInterfaceSystem.SessionHasOpenUi(strippable, StrippingUiKey.Key, actor.PlayerSession))
                     return;
-                _userInterfaceSystem.TryOpen(component.Owner, StrippingUiKey.Key, actor.PlayerSession);
+                _userInterfaceSystem.TryOpen(strippable, StrippingUiKey.Key, actor.PlayerSession);
             }
         }
 
@@ -126,14 +126,14 @@ namespace Content.Server.Strip
             if (args.Hands == null || !args.CanAccess || !args.CanInteract || args.Target == args.User)
                 return;
 
-            if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
+            if (!HasComp<ActorComponent>(args.User))
                 return;
 
             Verb verb = new()
             {
                 Text = Loc.GetString("strip-verb-get-data-text"),
                 Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/outfit.svg.192dpi.png")),
-                Act = () => StartOpeningStripper(args.User, component, true),
+                Act = () => StartOpeningStripper(args.User, (uid, component), true),
             };
             args.Verbs.Add(verb);
         }
@@ -150,7 +150,7 @@ namespace Content.Server.Strip
             {
                 Text = Loc.GetString("strip-verb-get-data-text"),
                 Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/outfit.svg.192dpi.png")),
-                Act = () => StartOpeningStripper(args.User, component, true),
+                Act = () => StartOpeningStripper(args.User, (uid, component), true),
                 Category = VerbCategory.Examine,
             };
 
@@ -162,10 +162,10 @@ namespace Content.Server.Strip
             if (args.Target == args.User)
                 return;
 
-            if (!TryComp<ActorComponent>(args.User, out var actor))
+            if (!HasComp<ActorComponent>(args.User))
                 return;
 
-            StartOpeningStripper(args.User, component);
+            StartOpeningStripper(args.User, (uid, component));
         }
 
         /// <summary>
@@ -238,7 +238,8 @@ namespace Content.Server.Strip
             _adminLogger.Add(LogType.Stripping, LogImpact.Low, $"{ToPrettyString(user):user} is trying to place the item {ToPrettyString(held):item} in {ToPrettyString(target):target}'s {slot} slot");
 
             var result = await _doAfter.WaitDoAfter(doAfterArgs);
-            if (result != DoAfterStatus.Finished) return;
+            if (result != DoAfterStatus.Finished)
+                return;
 
             DebugTools.Assert(userHands.ActiveHand?.HeldEntity == held);
 
@@ -319,7 +320,7 @@ namespace Content.Server.Strip
             EntityUid target,
             EntityUid item,
             string slot,
-            StrippableComponent component)
+            Entity<StrippableComponent> strippable)
         {
             bool Check()
             {
@@ -368,7 +369,7 @@ namespace Content.Server.Strip
                     _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner-hidden", ("slot", slot)), target,
                         target, PopupType.Large);
                 }
-                else if (_inventorySystem.TryGetSlotEntity(component.Owner, slot, out var slotItem))
+                else if (_inventorySystem.TryGetSlotEntity(strippable, slot, out var slotItem))
                 {
                     _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner", ("user", Identity.Entity(user, EntityManager)), ("item", slotItem)), target,
                         target, PopupType.Large);
@@ -378,9 +379,10 @@ namespace Content.Server.Strip
             _adminLogger.Add(LogType.Stripping, LogImpact.Low, $"{ToPrettyString(user):user} is trying to strip the item {ToPrettyString(item):item} from {ToPrettyString(target):target}");
 
             var result = await _doAfter.WaitDoAfter(doAfterArgs);
-            if (result != DoAfterStatus.Finished) return;
+            if (result != DoAfterStatus.Finished)
+                return;
 
-            if (!_inventorySystem.TryUnequip(user, component.Owner, slot))
+            if (!_inventorySystem.TryUnequip(user, strippable, slot))
                 return;
 
             // Raise a dropped event, so that things like gas tank internals properly deactivate when stripping
@@ -394,7 +396,7 @@ namespace Content.Server.Strip
         /// <summary>
         ///     Takes an item from a hand and places it in the user's active hand.
         /// </summary>
-        private async void TakeItemFromHands(EntityUid user, EntityUid target, EntityUid item, string handName, StrippableComponent component)
+        private async void TakeItemFromHands(EntityUid user, EntityUid target, EntityUid item, string handName, Entity<StrippableComponent> strippable)
         {
             var hands = Comp<HandsComponent>(target);
             var userHands = Comp<HandsComponent>(user);
@@ -419,7 +421,7 @@ namespace Content.Server.Strip
                 return true;
             }
 
-            var userEv = new BeforeStripEvent(component.HandStripDelay);
+            var userEv = new BeforeStripEvent(strippable.Comp.HandStripDelay);
             RaiseLocalEvent(user, userEv);
             var ev = new BeforeGettingStrippedEvent(userEv.Time, userEv.Stealth);
             RaiseLocalEvent(target, ev);
@@ -441,15 +443,16 @@ namespace Content.Server.Strip
                 _popup.PopupEntity(
                     Loc.GetString("strippable-component-alert-owner",
                     ("user", Identity.Entity(user, EntityManager)), ("item", item)),
-                    component.Owner,
-                    component.Owner);
+                    strippable.Owner,
+                    strippable.Owner);
             }
 
             _adminLogger.Add(LogType.Stripping, LogImpact.Low,
                 $"{ToPrettyString(user):user} is trying to strip the item {ToPrettyString(item):item} from {ToPrettyString(target):target}");
 
             var result = await _doAfter.WaitDoAfter(doAfterArgs);
-            if (result != DoAfterStatus.Finished) return;
+            if (result != DoAfterStatus.Finished)
+                return;
 
             _handsSystem.TryDrop(target, item, checkActionBlocker: false, handsComp: hands);
             _handsSystem.PickupOrDrop(user, item, handsComp: userHands);
index 2d691602f731f21ccddad617543792684f877c58..17eee198b8fb2119db003bd955ec4d68391ce7ed 100644 (file)
@@ -1,18 +1,10 @@
 using System.Linq;
-using Content.Server.Chat.Systems;
 using Content.Server.DeviceNetwork;
 using Content.Server.DeviceNetwork.Systems;
 using Content.Server.Power.Components;
 using Content.Server.UserInterface;
-using Content.Server.Wires;
-using Content.Shared.Interaction;
-using Content.Shared.Speech;
 using Content.Shared.SurveillanceCamera;
 using Robust.Server.GameObjects;
-using Robust.Server.Player;
-using Robust.Shared.Prototypes;
-using Robust.Shared.Random;
-using Robust.Shared.Timing;
 
 namespace Content.Server.SurveillanceCamera;
 
@@ -42,21 +34,22 @@ public sealed class SurveillanceCameraMonitorSystem : EntitySystem
 
     public override void Update(float frameTime)
     {
-        foreach (var (_, monitor) in EntityQuery<ActiveSurveillanceCameraMonitorComponent, SurveillanceCameraMonitorComponent>())
+        var query = EntityQueryEnumerator<ActiveSurveillanceCameraMonitorComponent, SurveillanceCameraMonitorComponent>();
+        while (query.MoveNext(out var uid, out _, out var monitor))
         {
-            if (Paused(monitor.Owner))
+            if (Paused(uid))
             {
                 continue;
             }
 
             monitor.LastHeartbeatSent += frameTime;
-            SendHeartbeat(monitor.Owner, monitor);
+            SendHeartbeat(uid, monitor);
             monitor.LastHeartbeat += frameTime;
 
             if (monitor.LastHeartbeat > _maxHeartbeatTime)
             {
-                DisconnectCamera(monitor.Owner, true, monitor);
-                EntityManager.RemoveComponent<ActiveSurveillanceCameraMonitorComponent>(monitor.Owner);
+                DisconnectCamera(uid, true, monitor);
+                EntityManager.RemoveComponent<ActiveSurveillanceCameraMonitorComponent>(uid);
             }
         }
     }
index 3b817c2c61baeaa5fa302c1778d1fb1b440e24d3..2e271080d07f5c21569263cc86c19f50a75eb5d4 100644 (file)
@@ -1,6 +1,5 @@
 using Content.Server.Popups;
 using Content.Server.Tabletop.Components;
-using Content.Shared.Examine;
 using Content.Shared.Hands.Components;
 using Content.Shared.Interaction;
 using Content.Shared.Item;
@@ -178,20 +177,19 @@ namespace Content.Server.Tabletop
         {
             base.Update(frameTime);
 
-            foreach (var gamer in EntityManager.EntityQuery<TabletopGamerComponent>())
+            var query = EntityQueryEnumerator<TabletopGamerComponent>();
+            while (query.MoveNext(out var uid, out var gamer))
             {
-                if (!EntityManager.EntityExists(gamer.Tabletop))
+                if (!Exists(gamer.Tabletop))
                     continue;
 
-                if (!EntityManager.TryGetComponent(gamer.Owner, out ActorComponent? actor))
+                if (!TryComp(uid, out ActorComponent? actor))
                 {
-                    EntityManager.RemoveComponent<TabletopGamerComponent>(gamer.Owner);
+                    EntityManager.RemoveComponent<TabletopGamerComponent>(uid);
                     return;
                 }
 
-                var gamerUid = (gamer).Owner;
-
-                if (actor.PlayerSession.Status != SessionStatus.InGame || !CanSeeTable(gamerUid, gamer.Tabletop))
+                if (actor.PlayerSession.Status != SessionStatus.InGame || !CanSeeTable(uid, gamer.Tabletop))
                     CloseSessionFor(actor.PlayerSession, gamer.Tabletop);
             }
         }
index 0dc5e9391af8da22249f468623372d8569e7d3c0..27521cadf63377637814155c8f0440ac50ee0bc8 100644 (file)
@@ -1,3 +1,4 @@
+using System.Linq;
 using Content.Server.Administration.Logs;
 using Content.Server.Atmos.Components;
 using Content.Server.Atmos.EntitySystems;
@@ -11,7 +12,6 @@ using Content.Shared.Inventory;
 using Content.Shared.Rejuvenate;
 using Content.Shared.Temperature;
 using Robust.Server.GameObjects;
-using System.Linq;
 
 namespace Content.Server.Temperature.Systems;
 
@@ -28,7 +28,7 @@ public sealed class TemperatureSystem : EntitySystem
     ///     This is done because both AtmosExposed and Flammable call ChangeHeat in the same tick, meaning
     ///     that we need some mechanism to ensure it doesn't double dip on damage for both calls.
     /// </summary>
-    public HashSet<TemperatureComponent> ShouldUpdateDamage = new();
+    public HashSet<Entity<TemperatureComponent>> ShouldUpdateDamage = new();
 
     public float UpdateInterval = 1.0f;
 
@@ -99,7 +99,7 @@ public sealed class TemperatureSystem : EntitySystem
         if (!ignoreHeatResistance)
         {
             var ev = new ModifyChangedTemperatureEvent(heatAmount);
-            RaiseLocalEvent(uid, ev, false);
+            RaiseLocalEvent(uid, ev);
             heatAmount = ev.TemperatureDelta;
         }
 
@@ -189,9 +189,9 @@ public sealed class TemperatureSystem : EntitySystem
         }
     }
 
-    private void EnqueueDamage(EntityUid uid, TemperatureComponent component, OnTemperatureChangeEvent args)
+    private void EnqueueDamage(Entity<TemperatureComponent> temperature, ref OnTemperatureChangeEvent args)
     {
-        ShouldUpdateDamage.Add(component);
+        ShouldUpdateDamage.Add(temperature);
     }
 
     private void ChangeDamage(EntityUid uid, TemperatureComponent temperature)
index 8a4b881f9f4310ac5d47e1d9da94e66f6a4902a7..e0dc341a167a83587c6c48e1984b0a1e5485fd4f 100644 (file)
@@ -15,7 +15,6 @@ using Content.Shared.Tools.Components;
 using Content.Shared.Weapons.Melee.Events;
 using Robust.Shared.Audio;
 using Robust.Shared.GameStates;
-using Robust.Shared.Utility;
 
 namespace Content.Server.Tools
 {
@@ -24,7 +23,7 @@ namespace Content.Server.Tools
         private readonly HashSet<EntityUid> _activeWelders = new();
 
         private const float WelderUpdateTimer = 1f;
-        private float _welderTimer = 0f;
+        private float _welderTimer;
 
         public void InitializeWelders()
         {
@@ -112,7 +111,7 @@ namespace Content.Server.Tools
                 _adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(uid):welder} toggled on");
 
             var ev = new WelderToggledEvent(true);
-            RaiseLocalEvent(welder.Owner, ev, false);
+            RaiseLocalEvent(uid, ev);
 
             var hotEvent = new IsHotEvent() {IsHot = true};
             RaiseLocalEvent(uid, hotEvent);
@@ -162,7 +161,7 @@ namespace Content.Server.Tools
                 _adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(uid):welder} toggled off");
 
             var ev = new WelderToggledEvent(false);
-            RaiseLocalEvent(uid, ev, false);
+            RaiseLocalEvent(uid, ev);
 
             var hotEvent = new IsHotEvent() {IsHot = false};
             RaiseLocalEvent(uid, hotEvent);
@@ -187,7 +186,7 @@ namespace Content.Server.Tools
         private void OnWelderStartup(EntityUid uid, WelderComponent welder, ComponentStartup args)
         {
             // TODO: Delete this shit what
-            Dirty(welder);
+            Dirty(uid, welder);
         }
 
         private void OnWelderIsHotEvent(EntityUid uid, WelderComponent welder, IsHotEvent args)
@@ -222,7 +221,7 @@ namespace Content.Server.Tools
         {
             // TODO what
             // ????
-            Dirty(welder);
+            Dirty(uid, welder);
         }
 
         private void OnWelderActivate(EntityUid uid, WelderComponent welder, ActivateInWorldEvent args)
@@ -315,7 +314,7 @@ namespace Content.Server.Tools
                 if (solution.GetTotalPrototypeQuantity(welder.FuelReagent) <= FixedPoint2.Zero)
                     TryTurnWelderOff(tool, null, welder);
 
-                Dirty(welder);
+                Dirty(tool, welder);
             }
 
             _welderTimer -= WelderUpdateTimer;
index 11187e969f17d69deb1e151522c0bda7f366b667..5c0a56d346c43f5fba413034bfdf2b3e23e50546 100644 (file)
@@ -1,8 +1,8 @@
 using System.Linq;
-using Content.Server.Store.Systems;
 using Content.Server.Storage.EntitySystems;
-using Content.Shared.Store;
+using Content.Server.Store.Systems;
 using Content.Shared.FixedPoint;
+using Content.Shared.Store;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Random;
 
@@ -50,7 +50,7 @@ public sealed class SurplusBundleSystem : EntitySystem
         foreach (var item in content)
         {
             var ent = EntityManager.SpawnEntity(item.ProductEntity, cords);
-            _entityStorage.Insert(ent, component.Owner);
+            _entityStorage.Insert(ent, uid);
         }
     }
 
index c1fdde4ed3901c0d38da2a4496c4466024912d20..e4fa1ccbc73c0aad02880e33542a2d993c4eccbc 100644 (file)
@@ -39,7 +39,8 @@ public sealed class NarcolepsySystem : EntitySystem
     {
         base.Update(frameTime);
 
-        foreach (var narcolepsy in EntityQuery<NarcolepsyComponent>())
+        var query = EntityQueryEnumerator<NarcolepsyComponent>();
+        while (query.MoveNext(out var uid, out var narcolepsy))
         {
             narcolepsy.NextIncidentTime -= frameTime;
 
@@ -55,7 +56,7 @@ public sealed class NarcolepsySystem : EntitySystem
             // Make sure the sleep time doesn't cut into the time to next incident.
             narcolepsy.NextIncidentTime += duration;
 
-            _statusEffects.TryAddStatusEffect<ForcedSleepingComponent>(narcolepsy.Owner, StatusEffectKey,
+            _statusEffects.TryAddStatusEffect<ForcedSleepingComponent>(uid, StatusEffectKey,
                 TimeSpan.FromSeconds(duration), false);
         }
     }
index d192e928d8f1f82a615ad11f617f02fa28980bce..ba2786f32d33d28187e9699189d378593fb91ab4 100644 (file)
@@ -1,9 +1,8 @@
+using Content.Server.Polymorph.Systems;
 using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
 using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
 using Content.Shared.Humanoid;
-using Content.Server.Polymorph.Systems;
 using Content.Shared.Mobs.Systems;
-using Content.Shared.Polymorph;
 
 namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
 
@@ -28,7 +27,10 @@ public sealed class PolyArtifactSystem : EntitySystem
     private void OnActivate(EntityUid uid, PolyArtifactComponent component, ArtifactActivatedEvent args)
     {
         var xform = Transform(uid);
-        foreach (var comp in _lookup.GetComponentsInRange<HumanoidAppearanceComponent>(xform.Coordinates, component.Range))
+        var humanoids = new HashSet<Entity<HumanoidAppearanceComponent>>();
+        _lookup.GetEntitiesInRange(xform.Coordinates, component.Range, humanoids);
+
+        foreach (var comp in humanoids)
         {
             var target = comp.Owner;
             if (_mob.IsAlive(target))
index 675d3e9387dd2e6ed11333af6ca9c8778efc1f85..b977cb038c982c2d829307ed59f9b59c65e9258d 100644 (file)
@@ -23,7 +23,7 @@ public sealed class ShuffleArtifactSystem : EntitySystem
         var mobState = GetEntityQuery<MobStateComponent>();
 
         List<EntityCoordinates> allCoords = new();
-        List<TransformComponent> toShuffle = new();
+        List<Entity<TransformComponent>> toShuffle = new();
 
         foreach (var ent in _lookup.GetEntitiesInRange(uid, component.Radius, LookupFlags.Dynamic | LookupFlags.Sundries))
         {
@@ -32,7 +32,7 @@ public sealed class ShuffleArtifactSystem : EntitySystem
 
             var xform = Transform(ent);
 
-            toShuffle.Add(xform);
+            toShuffle.Add((ent, xform));
             allCoords.Add(xform.Coordinates);
         }
 
index c3af6a11e2aa57c9c9c41f4b5fb7fae41b3c467c..091441df21a79e07f8d07eb4c2ee44c5d1bc3cd2 100644 (file)
@@ -24,8 +24,9 @@ public sealed class RandomArtifactSpriteSystem : EntitySystem
     public override void Update(float frameTime)
     {
         base.Update(frameTime);
-        var query = EntityManager.EntityQuery<RandomArtifactSpriteComponent, AppearanceComponent>();
-        foreach (var (component, appearance) in query)
+
+        var query = EntityQueryEnumerator<RandomArtifactSpriteComponent, AppearanceComponent>();
+        while (query.MoveNext(out var uid, out var component, out var appearance))
         {
             if (component.ActivationStart == null)
                 continue;
@@ -33,7 +34,7 @@ public sealed class RandomArtifactSpriteSystem : EntitySystem
             var timeDif = _time.CurTime - component.ActivationStart.Value;
             if (timeDif.Seconds >= component.ActivationTime)
             {
-                _appearance.SetData(appearance.Owner, SharedArtifactsVisuals.IsActivated, false, appearance);
+                _appearance.SetData(uid, SharedArtifactsVisuals.IsActivated, false, appearance);
                 component.ActivationStart = null;
             }
         }
index 4fa21535a4ae027f16d514c77c76f0b0ab91ba73..a92412073408d1bafe0a3301ccda9c0178dd77c7 100644 (file)
@@ -20,8 +20,9 @@ public sealed class ArtifactDeathTriggerSystem : EntitySystem
 
         var deathXform = Transform(ev.Target);
 
-        var toActivate = new List<ArtifactDeathTriggerComponent>();
-        foreach (var (trigger, xform) in EntityQuery<ArtifactDeathTriggerComponent, TransformComponent>())
+        var toActivate = new List<Entity<ArtifactDeathTriggerComponent>>();
+        var query = EntityQueryEnumerator<ArtifactDeathTriggerComponent, TransformComponent>();
+        while (query.MoveNext(out var uid, out var trigger, out var xform))
         {
             if (!deathXform.Coordinates.TryDistance(EntityManager, xform.Coordinates, out var distance))
                 continue;
@@ -29,12 +30,12 @@ public sealed class ArtifactDeathTriggerSystem : EntitySystem
             if (distance > trigger.Range)
                 continue;
 
-            toActivate.Add(trigger);
+            toActivate.Add((uid, trigger));
         }
 
         foreach (var a in toActivate)
         {
-            _artifact.TryActivateArtifact(a.Owner);
+            _artifact.TryActivateArtifact(a);
         }
     }
 }
index 59889971019ba9ca212b134f8186fe04f3cc6188..aa2a16aa1b2ee02df9aac319f3ce23cbef312f5d 100644 (file)
@@ -20,18 +20,20 @@ public sealed class ArtifactElectricityTriggerSystem : EntitySystem
     public override void Update(float frameTime)
     {
         base.Update(frameTime);
-        List<ArtifactComponent> toUpdate = new();
-        foreach (var (trigger, power, artifact) in EntityQuery<ArtifactElectricityTriggerComponent, PowerConsumerComponent, ArtifactComponent>())
+
+        List<Entity<ArtifactComponent>> toUpdate = new();
+        var query = EntityQueryEnumerator<ArtifactElectricityTriggerComponent, PowerConsumerComponent, ArtifactComponent>();
+        while (query.MoveNext(out var uid, out var trigger, out var power, out var artifact))
         {
             if (power.ReceivedPower <= trigger.MinPower)
                 continue;
 
-            toUpdate.Add(artifact);
+            toUpdate.Add((uid, artifact));
         }
 
         foreach (var a in toUpdate)
         {
-            _artifactSystem.TryActivateArtifact(a.Owner, null,  a);
+            _artifactSystem.TryActivateArtifact(a, null, a);
         }
     }
 
index 9a889689233fa8fc356b3783e135702bbf14cbd6..a0c4971d8eb0bf111e3198ea32ce2d3cc0f52ff4 100644 (file)
@@ -30,11 +30,10 @@ public sealed class ArtifactGasTriggerSystem : EntitySystem
     {
         base.Update(frameTime);
 
-        List<ArtifactComponent> toUpdate = new();
-        foreach (var (trigger, artifact, transform) in EntityQuery<ArtifactGasTriggerComponent, ArtifactComponent, TransformComponent>())
+        List<Entity<ArtifactComponent>> toUpdate = new();
+        var query = EntityQueryEnumerator<ArtifactGasTriggerComponent, ArtifactComponent, TransformComponent>();
+        while (query.MoveNext(out var uid, out var trigger, out var artifact, out var transform))
         {
-            var uid = trigger.Owner;
-
             if (trigger.ActivationGas == null)
                 continue;
 
@@ -49,12 +48,12 @@ public sealed class ArtifactGasTriggerSystem : EntitySystem
             if (moles < trigger.ActivationMoles)
                 continue;
 
-            toUpdate.Add(artifact);
+            toUpdate.Add((uid, artifact));
         }
 
         foreach (var a in toUpdate)
         {
-            _artifactSystem.TryActivateArtifact(a.Owner, null, a);
+            _artifactSystem.TryActivateArtifact(a, null, a);
         }
     }
 }
index e54dc9a3532082aad6d2f775e57e51383954bb77..6c62f5d3424eef6e25343e4be36d09a236e58830 100644 (file)
@@ -24,10 +24,10 @@ public sealed class ArtifactHeatTriggerSystem : EntitySystem
     {
         base.Update(frameTime);
 
-        List<ArtifactComponent> toUpdate = new();
-        foreach (var (trigger, transform, artifact) in EntityQuery<ArtifactHeatTriggerComponent, TransformComponent, ArtifactComponent>())
+        List<Entity<ArtifactComponent>> toUpdate = new();
+        var query = EntityQueryEnumerator<ArtifactHeatTriggerComponent, TransformComponent, ArtifactComponent>();
+        while (query.MoveNext(out var uid, out var trigger, out var transform, out var artifact))
         {
-            var uid = trigger.Owner;
             var environment = _atmosphereSystem.GetTileMixture(transform.GridUid, transform.MapUid,
                 _transformSystem.GetGridOrMapTilePosition(uid, transform));
             if (environment == null)
@@ -36,12 +36,12 @@ public sealed class ArtifactHeatTriggerSystem : EntitySystem
             if (environment.Temperature < trigger.ActivationTemperature)
                 continue;
 
-            toUpdate.Add(artifact);
+            toUpdate.Add((uid, artifact));
         }
 
         foreach (var a in toUpdate)
         {
-            _artifactSystem.TryActivateArtifact(a.Owner, null, a);
+            _artifactSystem.TryActivateArtifact(a, null, a);
         }
     }
 
index 1960982841722c704615ff07b99a126bcd6dc439..0220c2ce1aeb0ba01fbd4168d6c53097dd747cba 100644 (file)
@@ -29,13 +29,12 @@ public sealed class ArtifactMagnetTriggerSystem : EntitySystem
         List<EntityUid> toActivate = new();
 
         //assume that there's more instruments than artifacts
-        foreach (var magboot in EntityQuery<MagbootsComponent>())
+        var query = EntityQueryEnumerator<MagbootsComponent, TransformComponent>();
+        while (query.MoveNext(out var uid, out var magboot, out var magXform))
         {
             if (!magboot.On)
                 continue;
 
-            var magXform = Transform(magboot.Owner);
-
             foreach (var (trigger, xform) in artifactQuery)
             {
                 if (!magXform.Coordinates.TryDistance(EntityManager, xform.Coordinates, out var distance))
@@ -44,7 +43,7 @@ public sealed class ArtifactMagnetTriggerSystem : EntitySystem
                 if (distance > trigger.Range)
                     continue;
 
-                toActivate.Add(trigger.Owner);
+                toActivate.Add(uid);
             }
         }
 
@@ -59,7 +58,8 @@ public sealed class ArtifactMagnetTriggerSystem : EntitySystem
         var magXform = Transform(ev.Magnet);
 
         var toActivate = new List<EntityUid>();
-        foreach (var (artifact, xform) in EntityQuery<ArtifactMagnetTriggerComponent, TransformComponent>())
+        var query = EntityQueryEnumerator<ArtifactMagnetTriggerComponent, TransformComponent>();
+        while (query.MoveNext(out var uid, out var artifact, out var xform))
         {
             if (!magXform.Coordinates.TryDistance(EntityManager, xform.Coordinates, out var distance))
                 continue;
@@ -67,7 +67,7 @@ public sealed class ArtifactMagnetTriggerSystem : EntitySystem
             if (distance > artifact.Range)
                 continue;
 
-            toActivate.Add(artifact.Owner);
+            toActivate.Add(uid);
         }
 
         foreach (var a in toActivate)
index 1f2718da2b5cc24c60a6cf6e70c1c603fab58602..c62ed587527e47e15a27b4920e49fe6b53591156 100644 (file)
@@ -11,22 +11,29 @@ public sealed class ArtifactMusicTriggerSystem : EntitySystem
 {
     [Dependency] private readonly ArtifactSystem _artifact = default!;
 
+    private readonly List<Entity<ArtifactMusicTriggerComponent, TransformComponent>> _artifacts = new();
+
     public override void Update(float frameTime)
     {
         base.Update(frameTime);
 
-        var artifactQuery = EntityQuery<ArtifactMusicTriggerComponent, TransformComponent>().ToArray();
-        if (!artifactQuery.Any())
+        _artifacts.Clear();
+        var artifactQuery = EntityQueryEnumerator<ArtifactMusicTriggerComponent, TransformComponent>();
+        while (artifactQuery.MoveNext(out var uid, out var trigger, out var xform))
+        {
+            _artifacts.Add((uid, trigger, xform));
+        }
+
+        if (!_artifacts.Any())
             return;
 
         List<EntityUid> toActivate = new();
+        var query = EntityQueryEnumerator<ActiveInstrumentComponent, TransformComponent>();
 
         //assume that there's more instruments than artifacts
-        foreach (var activeinstrument in EntityQuery<ActiveInstrumentComponent>())
+        while (query.MoveNext(out _, out var instXform))
         {
-            var instXform = Transform(activeinstrument.Owner);
-
-            foreach (var (trigger, xform) in artifactQuery)
+            foreach (var (uid, trigger, xform) in _artifacts)
             {
                 if (!instXform.Coordinates.TryDistance(EntityManager, xform.Coordinates, out var distance))
                     continue;
@@ -34,7 +41,7 @@ public sealed class ArtifactMusicTriggerSystem : EntitySystem
                 if (distance > trigger.Range)
                     continue;
 
-                toActivate.Add(trigger.Owner);
+                toActivate.Add(uid);
             }
         }
 
index aa1d40c5fb2d348c9f47feace3ef39147ced53b3..cf730d8b49fe4c55fca7e501873c7a505668b3d4 100644 (file)
@@ -17,10 +17,10 @@ public sealed class ArtifactPressureTriggerSystem : EntitySystem
     {
         base.Update(frameTime);
 
-        List<ArtifactComponent> toUpdate = new();
-        foreach (var (trigger, artifact, transform) in EntityQuery<ArtifactPressureTriggerComponent, ArtifactComponent, TransformComponent>())
+        List<Entity<ArtifactComponent>> toUpdate = new();
+        var query = EntityQueryEnumerator<ArtifactPressureTriggerComponent, ArtifactComponent, TransformComponent>();
+        while (query.MoveNext(out var uid, out var trigger, out var artifact, out var transform))
         {
-            var uid = trigger.Owner;
             var environment = _atmosphereSystem.GetTileMixture(transform.GridUid, transform.MapUid,
                 _transformSystem.GetGridOrMapTilePosition(uid, transform));
 
@@ -29,12 +29,12 @@ public sealed class ArtifactPressureTriggerSystem : EntitySystem
 
             var pressure = environment.Pressure;
             if (pressure >= trigger.MaxPressureThreshold || pressure <= trigger.MinPressureThreshold)
-                toUpdate.Add(artifact);
+                toUpdate.Add((uid, artifact));
         }
 
         foreach (var a in toUpdate)
         {
-            _artifactSystem.TryActivateArtifact(a.Owner, null, a);
+            _artifactSystem.TryActivateArtifact(a, null, a);
         }
     }
 }
index d8c500c3b189c61304fd68b1af2220e3e1ffc52e..c6ea745e1c79eff469cb4e1628323f60937d98ac 100644 (file)
@@ -24,20 +24,21 @@ public sealed class ArtifactTimerTriggerSystem : EntitySystem
     {
         base.Update(frameTime);
 
-        List<ArtifactComponent> toUpdate = new();
-        foreach (var (trigger, artifact) in EntityQuery<ArtifactTimerTriggerComponent, ArtifactComponent>())
+        List<Entity<ArtifactComponent>> toUpdate = new();
+        var query = EntityQueryEnumerator<ArtifactTimerTriggerComponent, ArtifactComponent>();
+        while (query.MoveNext(out var uid, out var trigger, out var artifact))
         {
             var timeDif = _time.CurTime - trigger.LastActivation;
             if (timeDif <= trigger.ActivationRate)
                 continue;
 
-            toUpdate.Add(artifact);
+            toUpdate.Add((uid, artifact));
             trigger.LastActivation = _time.CurTime;
         }
 
         foreach (var a in toUpdate)
         {
-            _artifactSystem.TryActivateArtifact(a.Owner, null, a);
+            _artifactSystem.TryActivateArtifact(a, null, a);
         }
     }
 }
index 3ef57827e57cc759fd490e9c9d8a0d63f643290d..842e7e7e6ac9eec11669c7ec3f6af2f6fc4bcfd9 100644 (file)
@@ -1,4 +1,3 @@
-using System.Diagnostics.CodeAnalysis;
 using Content.Shared.Access.Components;
 using Content.Shared.Hands.Components;
 using Content.Shared.Inventory;
@@ -14,7 +13,7 @@ public abstract class SharedIdCardSystem : EntitySystem
     ///     Attempt to find an ID card on an entity. This will look in the entity itself, in the entity's hands, and
     ///     in the entity's inventory.
     /// </summary>
-    public bool TryFindIdCard(EntityUid uid, [NotNullWhen(true)] out IdCardComponent? idCard)
+    public bool TryFindIdCard(EntityUid uid, out Entity<IdCardComponent> idCard)
     {
         // check held item?
         if (TryComp(uid, out HandsComponent? hands) &&
@@ -39,17 +38,22 @@ public abstract class SharedIdCardSystem : EntitySystem
     ///     Attempt to get an id card component from an entity, either by getting it directly from the entity, or by
     ///     getting the contained id from a <see cref="PdaComponent"/>.
     /// </summary>
-    public bool TryGetIdCard(EntityUid uid, [NotNullWhen(true)] out IdCardComponent? idCard)
+    public bool TryGetIdCard(EntityUid uid, out Entity<IdCardComponent> idCard)
     {
-        if (TryComp(uid, out idCard))
+        if (TryComp(uid, out IdCardComponent? idCardComp))
+        {
+            idCard = (uid, idCardComp);
             return true;
+        }
 
         if (TryComp(uid, out PdaComponent? pda)
-        && TryComp(pda.ContainedId, out idCard))
+        && TryComp(pda.ContainedId, out idCardComp))
         {
+            idCard = (pda.ContainedId.Value, idCardComp);
             return true;
         }
 
+        idCard = default;
         return false;
     }
 }
index bce0836efb628300a18f4c3fd278ca8d4ce67dce..86d50e3989a943b1aeac02fd11a95c4311ea0fcb 100644 (file)
@@ -60,7 +60,7 @@ public sealed class ActionContainerSystem : EntitySystem
     {
         action = null;
 
-        DebugTools.Assert(comp == null || comp.Owner == uid);
+        DebugTools.AssertOwner(uid, comp);
         comp ??= EnsureComp<ActionsContainerComponent>(uid);
 
         if (Exists(actionId))
@@ -162,7 +162,7 @@ public sealed class ActionContainerSystem : EntitySystem
         if (action.Container != null)
             RemoveAction(actionId, action);
 
-        DebugTools.Assert(comp == null || comp.Owner == uid);
+        DebugTools.AssertOwner(uid, comp);
         comp ??= EnsureComp<ActionsContainerComponent>(uid);
         if (!comp.Container.Insert(actionId))
         {
index 8d2c8c28e3e44de92425ef3c50eb10ef4b428c77..9ad155081acc8491177d30e90d0b6d522d757fd6 100644 (file)
@@ -96,7 +96,7 @@ public abstract class SharedActionsSystem : EntitySystem
     {
         if (result != null)
         {
-            DebugTools.Assert(result.Owner == uid);
+            DebugTools.AssertOwner(uid, result);
             return true;
         }
 
@@ -494,7 +494,7 @@ public abstract class SharedActionsSystem : EntitySystem
                           (TryComp(action.Container, out ActionsContainerComponent? containerComp)
                            && containerComp.Container.Contains(actionId)));
 
-        DebugTools.Assert(comp == null || comp.Owner == performer);
+        DebugTools.AssertOwner(performer, comp);
         comp ??= EnsureComp<ActionsComponent>(performer);
         action.AttachedEntity = performer;
         comp.Actions.Add(actionId);
@@ -523,7 +523,7 @@ public abstract class SharedActionsSystem : EntitySystem
         if (!Resolve(container, ref containerComp))
             return;
 
-        DebugTools.Assert(comp == null || comp.Owner == performer);
+        DebugTools.AssertOwner(performer, comp);
         comp ??= EnsureComp<ActionsComponent>(performer);
 
         foreach (var actionId in actions)
index db6911f12b23dd211c2eae5f31c457b26ccb13a0..1a2d8a05bf2f234f48a03f9913ba586f15e737b6 100644 (file)
@@ -73,7 +73,7 @@ public abstract class AlertsSystem : EntitySystem
     ///     be erased if there is currently a cooldown for the alert)</param>
     public void ShowAlert(EntityUid euid, AlertType alertType, short? severity = null, (TimeSpan, TimeSpan)? cooldown = null)
     {
-        if (!EntityManager.TryGetComponent(euid, out AlertsComponent? alertsComponent))
+        if (!TryComp(euid, out AlertsComponent? alertsComponent))
             return;
 
         if (TryGet(alertType, out var alert))
@@ -94,9 +94,9 @@ public abstract class AlertsSystem : EntitySystem
             alertsComponent.Alerts[alert.AlertKey] = new AlertState
                 { Cooldown = cooldown, Severity = severity, Type = alertType };
 
-            AfterShowAlert(alertsComponent);
+            AfterShowAlert((euid, alertsComponent));
 
-            Dirty(alertsComponent);
+            Dirty(euid, alertsComponent);
         }
         else
         {
@@ -111,7 +111,7 @@ public abstract class AlertsSystem : EntitySystem
     /// </summary>
     public void ClearAlertCategory(EntityUid euid, AlertCategory category)
     {
-        if(!EntityManager.TryGetComponent(euid, out AlertsComponent? alertsComponent))
+        if(!TryComp(euid, out AlertsComponent? alertsComponent))
             return;
 
         var key = AlertKey.ForCategory(category);
@@ -120,9 +120,9 @@ public abstract class AlertsSystem : EntitySystem
             return;
         }
 
-        AfterClearAlert(alertsComponent);
+        AfterClearAlert((euid, alertsComponent));
 
-        Dirty(alertsComponent);
+        Dirty(euid, alertsComponent);
     }
 
     /// <summary>
@@ -140,9 +140,9 @@ public abstract class AlertsSystem : EntitySystem
                 return;
             }
 
-            AfterClearAlert(alertsComponent);
+            AfterClearAlert((euid, alertsComponent));
 
-            Dirty(alertsComponent);
+            Dirty(euid, alertsComponent);
         }
         else
         {
@@ -153,14 +153,12 @@ public abstract class AlertsSystem : EntitySystem
     /// <summary>
     /// Invoked after showing an alert prior to dirtying the component
     /// </summary>
-    /// <param name="alertsComponent"></param>
-    protected virtual void AfterShowAlert(AlertsComponent alertsComponent) { }
+    protected virtual void AfterShowAlert(Entity<AlertsComponent> alerts) { }
 
     /// <summary>
     /// Invoked after clearing an alert prior to dirtying the component
     /// </summary>
-    /// <param name="alertsComponent"></param>
-    protected virtual void AfterClearAlert(AlertsComponent alertsComponent) { }
+    protected virtual void AfterClearAlert(Entity<AlertsComponent> alerts) { }
 
     public override void Initialize()
     {
index 020b47f7081919462b213844d92585187dd487cc..6add0661339df0c29e8340a04ea46ea33fe10c47 100644 (file)
@@ -457,7 +457,7 @@ public abstract partial class SharedBuckleSystem
 
         if (buckleXform.ParentUid == strapUid && !Terminating(buckleXform.ParentUid))
         {
-            _container.AttachParentToContainerOrGrid(buckleXform);
+            _container.AttachParentToContainerOrGrid((buckleUid, buckleXform));
 
             var oldBuckledToWorldRot = _transform.GetWorldRotation(strapUid);
             _transform.SetWorldRotation(buckleXform, oldBuckledToWorldRot);
index 6b7c75514fc1b9b716243300b7b8c0766c84a094..e9d3b7de53d4fef575692f193111d68810b03dcc 100644 (file)
@@ -10,7 +10,7 @@ namespace Content.Shared.Chemistry
         [Dependency] private readonly IGameTiming _gameTiming = default!;
         [Dependency] private readonly MovementSpeedModifierSystem _movespeed = default!;
 
-        private readonly List<MovespeedModifierMetabolismComponent> _components = new();
+        private readonly List<Entity<MovespeedModifierMetabolismComponent>> _components = new();
 
         public override void Initialize()
         {
@@ -27,9 +27,9 @@ namespace Content.Shared.Chemistry
             args.ModifySpeed(component.WalkSpeedModifier, component.SprintSpeedModifier);
         }
 
-        private void AddComponent(EntityUid uid, MovespeedModifierMetabolismComponent component, ComponentStartup args)
+        private void AddComponent(Entity<MovespeedModifierMetabolismComponent> metabolism, ref ComponentStartup args)
         {
-            _components.Add(component);
+            _components.Add(metabolism);
         }
 
         public override void Update(float frameTime)
@@ -40,20 +40,21 @@ namespace Content.Shared.Chemistry
 
             for (var i = _components.Count - 1; i >= 0; i--)
             {
-                var component = _components[i];
+                var metabolism = _components[i];
 
-                if (component.Deleted)
+                if (metabolism.Comp.Deleted)
                 {
                     _components.RemoveAt(i);
                     continue;
                 }
 
-                if (component.ModifierTimer > currentTime) continue;
+                if (metabolism.Comp.ModifierTimer > currentTime)
+                    continue;
 
                 _components.RemoveAt(i);
-                EntityManager.RemoveComponent<MovespeedModifierMetabolismComponent>(component.Owner);
+                EntityManager.RemoveComponent<MovespeedModifierMetabolismComponent>(metabolism);
 
-                _movespeed.RefreshMovementSpeedModifiers(component.Owner);
+                _movespeed.RefreshMovementSpeedModifiers(metabolism);
             }
         }
     }
index cb92892305c4ea0aef0ad7a6e1913d3ef5ead3f2..902b56427afefcc8ffd52f01e87a184106c88fb6 100644 (file)
@@ -88,7 +88,7 @@ namespace Content.Shared.Containers.ItemSlots
         public void AddItemSlot(EntityUid uid, string id, ItemSlot slot, ItemSlotsComponent? itemSlots = null)
         {
             itemSlots ??= EntityManager.EnsureComponent<ItemSlotsComponent>(uid);
-            DebugTools.Assert(itemSlots.Owner == uid);
+            DebugTools.AssertOwner(uid, itemSlots);
 
             if (itemSlots.Slots.TryGetValue(id, out var existing))
             {
index f660ee5eb09697248c6ee6caa7febceb322b63c2..2aadbf8a81c8d1459f07eb8adabf942f10028742 100644 (file)
@@ -21,11 +21,6 @@ namespace Content.Shared.Coordinates
             return new EntityCoordinates(id, x, y);
         }
 
-        public static EntityCoordinates ToCoordinates(this MapGridComponent grid, Vector2 offset)
-        {
-            return ToCoordinates(grid.Owner, offset);
-        }
-
         public static EntityCoordinates ToCoordinates(this MapGridComponent grid, float x, float y)
         {
             return ToCoordinates(grid.Owner, x, y);
index 4a241ba37636cf5417c3ae6af0159e7a12cac410..084c3b4ea2cb7009e172aeb7f7e0bcd837fc5522 100644 (file)
@@ -2,24 +2,22 @@ using System.Linq;
 using Content.Shared.Access.Components;
 using Content.Shared.Access.Systems;
 using Content.Shared.Damage;
-using Content.Shared.DoAfter;
 using Content.Shared.Doors.Components;
 using Content.Shared.Hands.Components;
 using Content.Shared.Interaction;
 using Content.Shared.Physics;
+using Content.Shared.Prying.Components;
 using Content.Shared.Stunnable;
 using Content.Shared.Tag;
 using Robust.Shared.Audio;
 using Robust.Shared.Physics.Components;
 using Robust.Shared.Physics.Events;
 using Robust.Shared.Physics.Systems;
-using Robust.Shared.Serialization;
 using Robust.Shared.Timing;
-using Content.Shared.Prying.Components;
 
 namespace Content.Shared.Doors.Systems;
 
-public abstract partial class SharedDoorSystem : EntitySystem
+public abstract class SharedDoorSystem : EntitySystem
 {
     [Dependency] protected readonly IGameTiming GameTiming = default!;
     [Dependency] protected readonly SharedPhysicsSystem PhysicsSystem = default!;
@@ -45,7 +43,7 @@ public abstract partial class SharedDoorSystem : EntitySystem
     /// <summary>
     ///     A set of doors that are currently opening, closing, or just queued to open/close after some delay.
     /// </summary>
-    private readonly HashSet<DoorComponent> _activeDoors = new();
+    private readonly HashSet<Entity<DoorComponent>> _activeDoors = new();
 
     public override void Initialize()
     {
@@ -64,10 +62,11 @@ public abstract partial class SharedDoorSystem : EntitySystem
 
     }
 
-    protected virtual void OnComponentInit(EntityUid uid, DoorComponent door, ComponentInit args)
+    protected virtual void OnComponentInit(Entity<DoorComponent> ent, ref ComponentInit args)
     {
+        var door = ent.Comp;
         if (door.NextStateChange != null)
-            _activeDoors.Add(door);
+            _activeDoors.Add(ent);
         else
         {
             // Make sure doors are not perpetually stuck opening or closing.
@@ -90,25 +89,26 @@ public abstract partial class SharedDoorSystem : EntitySystem
             || door.State == DoorState.Closing && door.Partial
             || door.State == DoorState.Opening && !door.Partial;
 
-        SetCollidable(uid, collidable, door);
-        AppearanceSystem.SetData(uid, DoorVisuals.State, door.State);
+        SetCollidable(ent, collidable, door);
+        AppearanceSystem.SetData(ent, DoorVisuals.State, door.State);
     }
 
-    private void OnRemove(EntityUid uid, DoorComponent door, ComponentRemove args)
+    private void OnRemove(Entity<DoorComponent> door, ref ComponentRemove args)
     {
         _activeDoors.Remove(door);
     }
 
     #region StateManagement
-    private void OnHandleState(EntityUid uid, DoorComponent door, ref AfterAutoHandleStateEvent args)
+    private void OnHandleState(Entity<DoorComponent> ent, ref AfterAutoHandleStateEvent args)
     {
+        var door = ent.Comp;
         if (door.NextStateChange == null)
-            _activeDoors.Remove(door);
+            _activeDoors.Remove(ent);
         else
-            _activeDoors.Add(door);
+            _activeDoors.Add(ent);
 
-        RaiseLocalEvent(uid, new DoorStateChangedEvent(door.State));
-        AppearanceSystem.SetData(uid, DoorVisuals.State, door.State);
+        RaiseLocalEvent(ent, new DoorStateChangedEvent(door.State));
+        AppearanceSystem.SetData(ent, DoorVisuals.State, door.State);
     }
 
     protected void SetState(EntityUid uid, DoorState state, DoorComponent? door = null)
@@ -123,29 +123,29 @@ public abstract partial class SharedDoorSystem : EntitySystem
         switch (state)
         {
             case DoorState.Opening:
-                _activeDoors.Add(door);
+                _activeDoors.Add((uid, door));
                 door.NextStateChange = GameTiming.CurTime + door.OpenTimeOne;
                 break;
 
             case DoorState.Closing:
-                _activeDoors.Add(door);
+                _activeDoors.Add((uid, door));
                 door.NextStateChange = GameTiming.CurTime + door.CloseTimeOne;
                 break;
 
             case DoorState.Denying:
-                _activeDoors.Add(door);
+                _activeDoors.Add((uid, door));
                 door.NextStateChange = GameTiming.CurTime + door.DenyDuration;
                 break;
 
             case DoorState.Emagging:
-                _activeDoors.Add(door);
+                _activeDoors.Add((uid, door));
                 door.NextStateChange = GameTiming.CurTime + door.EmagDuration;
                 break;
 
             case DoorState.Open:
                 door.Partial = false;
                 if (door.NextStateChange == null)
-                    _activeDoors.Remove(door);
+                    _activeDoors.Remove((uid, door));
                 break;
             case DoorState.Closed:
                 // May want to keep the door around to re-check for opening if we got a contact during closing.
@@ -154,8 +154,8 @@ public abstract partial class SharedDoorSystem : EntitySystem
         }
 
         door.State = state;
-        Dirty(door);
-        RaiseLocalEvent(uid, new DoorStateChangedEvent(state), false);
+        Dirty(uid, door);
+        RaiseLocalEvent(uid, new DoorStateChangedEvent(state));
         AppearanceSystem.SetData(uid, DoorVisuals.State, door.State);
     }
 
@@ -187,7 +187,7 @@ public abstract partial class SharedDoorSystem : EntitySystem
 
         // might not be able to deny without power or some other blocker.
         var ev = new BeforeDoorDeniedEvent();
-        RaiseLocalEvent(uid, ev, false);
+        RaiseLocalEvent(uid, ev);
         if (ev.Cancelled)
             return;
 
@@ -239,7 +239,7 @@ public abstract partial class SharedDoorSystem : EntitySystem
             return false;
 
         var ev = new BeforeDoorOpenedEvent() { User = user };
-        RaiseLocalEvent(uid, ev, false);
+        RaiseLocalEvent(uid, ev);
         if (ev.Cancelled)
             return false;
 
@@ -290,8 +290,8 @@ public abstract partial class SharedDoorSystem : EntitySystem
         SetCollidable(uid, false, door);
         door.Partial = true;
         door.NextStateChange = GameTiming.CurTime + door.CloseTimeTwo;
-        _activeDoors.Add(door);
-        Dirty(door);
+        _activeDoors.Add((uid, door));
+        Dirty(uid, door);
 
     }
     #endregion
@@ -359,7 +359,7 @@ public abstract partial class SharedDoorSystem : EntitySystem
             return false;
 
         door.Partial = true;
-        Dirty(door);
+        Dirty(uid, door);
 
         // Make sure no entity waled into the airlock when it started closing.
         if (!CanClose(uid, door))
@@ -372,7 +372,7 @@ public abstract partial class SharedDoorSystem : EntitySystem
 
         SetCollidable(uid, true, door, physics);
         door.NextStateChange = GameTiming.CurTime + door.CloseTimeTwo;
-        _activeDoors.Add(door);
+        _activeDoors.Add((uid, door));
 
         // Crush any entities. Note that we don't check airlock safety here. This should have been checked before
         // the door closed.
@@ -567,12 +567,12 @@ public abstract partial class SharedDoorSystem : EntitySystem
         if (delay == null || delay.Value <= TimeSpan.Zero)
         {
             door.NextStateChange = null;
-            _activeDoors.Remove(door);
+            _activeDoors.Remove((uid, door));
             return;
         }
 
         door.NextStateChange = GameTiming.CurTime + delay.Value;
-        _activeDoors.Add(door);
+        _activeDoors.Add((uid, door));
     }
 
     /// <summary>
@@ -582,76 +582,78 @@ public abstract partial class SharedDoorSystem : EntitySystem
     {
         var time = GameTiming.CurTime;
 
-        foreach (var door in _activeDoors.ToList())
+        foreach (var ent in _activeDoors.ToList())
         {
+            var door = ent.Comp;
             if (door.Deleted || door.NextStateChange == null)
             {
-                _activeDoors.Remove(door);
+                _activeDoors.Remove(ent);
                 continue;
             }
 
-            if (Paused(door.Owner))
+            if (Paused(ent))
                 continue;
 
             if (door.NextStateChange.Value < time)
-                NextState(door, time);
+                NextState(ent, time);
 
             if (door.State == DoorState.Closed &&
-                TryComp<PhysicsComponent>(door.Owner, out var doorBody))
+                TryComp<PhysicsComponent>(ent, out var doorBody))
             {
                 // If something bumped into us during closing then start to re-open, otherwise, remove it from active.
-                _activeDoors.Remove(door);
-                CheckDoorBump(door, doorBody);
+                _activeDoors.Remove(ent);
+                CheckDoorBump((ent, door, doorBody));
             }
         }
     }
 
-    protected virtual void CheckDoorBump(DoorComponent component, PhysicsComponent body) { }
+    protected virtual void CheckDoorBump(Entity<DoorComponent, PhysicsComponent> ent) { }
 
     /// <summary>
     ///     Makes a door proceed to the next state (if applicable).
     /// </summary>
-    private void NextState(DoorComponent door, TimeSpan time)
+    private void NextState(Entity<DoorComponent> ent, TimeSpan time)
     {
+        var door = ent.Comp;
         door.NextStateChange = null;
 
         if (door.CurrentlyCrushing.Count > 0)
             // This is a closed door that is crushing people and needs to auto-open. Note that we don't check "can open"
             // here. The door never actually finished closing and we don't want people to get stuck inside of doors.
-            StartOpening(door.Owner, door, predicted: true);
+            StartOpening(ent, door, predicted: true);
 
         switch (door.State)
         {
             case DoorState.Opening:
                 // Either fully or partially open this door.
                 if (door.Partial)
-                    SetState(door.Owner, DoorState.Open, door);
+                    SetState(ent, DoorState.Open, door);
                 else
-                    OnPartialOpen(door.Owner, door);
+                    OnPartialOpen(ent, door);
 
                 break;
 
             case DoorState.Closing:
                 // Either fully or partially close this door.
                 if (door.Partial)
-                    SetState(door.Owner, DoorState.Closed, door);
+                    SetState(ent, DoorState.Closed, door);
                 else
-                    OnPartialClose(door.Owner, door);
+                    OnPartialClose(ent, door);
 
                 break;
 
             case DoorState.Denying:
                 // Finish denying entry and return to the closed state.
-                SetState(door.Owner, DoorState.Closed, door);
+                SetState(ent, DoorState.Closed, door);
                 break;
 
             case DoorState.Emagging:
-                StartOpening(door.Owner, door);
+                StartOpening(ent, door);
                 break;
 
             case DoorState.Open:
                 // This door is open, and queued for an auto-close.
-                if (!TryClose(door.Owner, door, predicted: true))
+                if (!TryClose(ent, door, predicted: true))
                 {
                     // The door failed to close (blocked?). Try again in one second.
                     door.NextStateChange = time + TimeSpan.FromSeconds(1);
@@ -660,7 +662,7 @@ public abstract partial class SharedDoorSystem : EntitySystem
 
             case DoorState.Welded:
                 // A welded door? This should never have been active in the first place.
-                Log.Error($"Welded door was in the list of active doors. Door: {ToPrettyString(door.Owner)}");
+                Log.Error($"Welded door was in the list of active doors. Door: {ToPrettyString(ent)}");
                 break;
         }
     }
index 2e0cffd7d27729b6469456fcc72a5a4a45ebbe48..1e6f121aaecb2626c0526b67d5178cf252ece628 100644 (file)
@@ -1,14 +1,11 @@
 using System.Linq;
-using Content.Shared.DragDrop;
-using Content.Shared.Interaction;
-using Content.Shared.Eye.Blinding;
 using Content.Shared.Eye.Blinding.Components;
+using Content.Shared.Interaction;
 using Content.Shared.Mobs.Components;
 using Content.Shared.Mobs.Systems;
 using JetBrains.Annotations;
 using Robust.Shared.Containers;
 using Robust.Shared.Map;
-using Robust.Shared.Network;
 using Robust.Shared.Physics;
 using Robust.Shared.Utility;
 using static Content.Shared.Interaction.SharedInteractionSystem;
@@ -191,7 +188,7 @@ namespace Content.Shared.Examine
                 }
 
                 var bBox = o.BoundingBox;
-                bBox = bBox.Translated(entMan.GetComponent<TransformComponent>(o.Owner).WorldPosition);
+                bBox = bBox.Translated(entMan.GetComponent<TransformComponent>(result.HitEntity).WorldPosition);
 
                 if (bBox.Contains(origin.Position) || bBox.Contains(other.Position))
                 {
@@ -213,15 +210,6 @@ namespace Content.Shared.Examine
             return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
         }
 
-        public static bool InRangeUnOccluded(EntityUid origin, IComponent other, float range = ExamineRange, Ignored? predicate = null, bool ignoreInsideBlocker = true)
-        {
-            var entMan = IoCManager.Resolve<IEntityManager>();
-            var originPos = entMan.GetComponent<TransformComponent>(origin).MapPosition;
-            var otherPos = entMan.GetComponent<TransformComponent>(other.Owner).MapPosition;
-
-            return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
-        }
-
         public static bool InRangeUnOccluded(EntityUid origin, EntityCoordinates other, float range = ExamineRange, Ignored? predicate = null, bool ignoreInsideBlocker = true)
         {
             var entMan = IoCManager.Resolve<IEntityManager>();
index e4a0488dfb5b6fbbe559b022f7e20063ea446eff..58a94d1723a2c7bf65d54b7bc1c18d4560922109 100644 (file)
@@ -151,7 +151,7 @@ public sealed class FollowerSystem : EntitySystem
         {
             followerComp = AddComp<FollowerComponent>(follower);
         }
-        
+
         followerComp.Following = entity;
 
         var followedComp = EnsureComp<FollowedComponent>(entity);
@@ -165,7 +165,7 @@ public sealed class FollowerSystem : EntitySystem
         _physicsSystem.SetLinearVelocity(follower, Vector2.Zero);
 
         var xform = Transform(follower);
-        _containerSystem.AttachParentToContainerOrGrid(xform);
+        _containerSystem.AttachParentToContainerOrGrid((follower, xform));
 
         // If we didn't get to parent's container.
         if (xform.ParentUid != Transform(xform.ParentUid).ParentUid)
index c0af2f4ed4ac198b3a3c64a582b869bd9e4906a2..472f5b574b2a527caef2f9d38361457e6c831429 100644 (file)
@@ -6,16 +6,12 @@ using Content.Shared.Movement.Systems;
 using Content.Shared.Pulling.Components;
 using JetBrains.Annotations;
 using Robust.Shared.Configuration;
-using Robust.Shared.GameStates;
 using Robust.Shared.Map;
 using Robust.Shared.Map.Components;
 using Robust.Shared.Physics.Components;
 using Robust.Shared.Physics.Controllers;
 using Robust.Shared.Physics.Dynamics;
 using Robust.Shared.Physics.Systems;
-using Robust.Shared.Serialization;
-using Robust.Shared.Utility;
-
 
 namespace Content.Shared.Friction
 {
@@ -68,7 +64,7 @@ namespace Content.Shared.Friction
                 // Only apply friction when it's not a mob (or the mob doesn't have control)
                 if (prediction && !body.Predict ||
                     body.BodyStatus == BodyStatus.InAir ||
-                    _mover.UseMobMovement(body.Owner))
+                    _mover.UseMobMovement(uid))
                 {
                     continue;
                 }
@@ -78,7 +74,7 @@ namespace Content.Shared.Friction
 
                 if (!xformQuery.TryGetComponent(uid, out var xform))
                 {
-                    Log.Error($"Unable to get transform for {ToPrettyString(body.Owner)} in tilefrictioncontroller");
+                    Log.Error($"Unable to get transform for {ToPrettyString(uid)} in tilefrictioncontroller");
                     continue;
                 }
 
index 0f06d72192e183819cdb83845a842cb74f7d01cc..57136116caae78e130395840af82bd6684c9f2c9 100644 (file)
@@ -45,7 +45,8 @@ public abstract class SharedFloatingVisualizerSystem : EntitySystem
 
     private void OnGravityChanged(ref GravityChangedEvent args)
     {
-        foreach (var (floating, transform) in EntityQuery<FloatingVisualsComponent, TransformComponent>(true))
+        var query = EntityQueryEnumerator<FloatingVisualsComponent, TransformComponent>();
+        while (query.MoveNext(out var uid, out var floating, out var transform))
         {
             if (transform.MapID == MapId.Nullspace)
                 continue;
@@ -54,9 +55,8 @@ public abstract class SharedFloatingVisualizerSystem : EntitySystem
                 continue;
 
             floating.CanFloat = !args.HasGravity;
-            Dirty(floating);
+            Dirty(uid, floating);
 
-            var uid = floating.Owner;
             if (!args.HasGravity)
                 FloatAnimation(uid, floating.Offset, floating.AnimationKey, floating.AnimationTime);
         }
index 0171b9f70c9dac6bf1d7ef854070b15715560583..edba1f98c463377d82ae91871ad1f777307438dc 100644 (file)
@@ -1,4 +1,3 @@
-using System.Numerics;
 using Content.Shared.Database;
 using Content.Shared.Hands.Components;
 using Content.Shared.Item;
@@ -202,7 +201,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
         {
             // TODO make this check upwards for any container, and parent to that.
             // Currently this just checks the direct parent, so items can still teleport through containers.
-            ContainerSystem.AttachParentToContainerOrGrid(Transform(entity));
+            ContainerSystem.AttachParentToContainerOrGrid((entity, Transform(entity)));
         }
     }
 
index 9f7623329e4082beeff1fc585382dda15605b917..e1de636969b833573291befa7744317467465de0 100644 (file)
@@ -21,7 +21,7 @@ public abstract partial class SharedHandsSystem
     [Dependency] private readonly SharedStorageSystem _storage = default!;
     [Dependency] protected readonly SharedTransformSystem TransformSystem = default!;
 
-    protected event Action<HandsComponent?>? OnHandSetActive;
+    protected event Action<Entity<HandsComponent>?>? OnHandSetActive;
 
     public override void Initialize()
     {
@@ -216,7 +216,7 @@ public abstract partial class SharedHandsSystem
         }
 
         handComp.ActiveHand = hand;
-        OnHandSetActive?.Invoke(handComp);
+        OnHandSetActive?.Invoke((uid, handComp));
 
         if (hand.HeldEntity != null)
             RaiseLocalEvent(hand.HeldEntity.Value, new HandSelectedEvent(uid));
index 7fb4a4c1275968fc551e32bb55c5fd0d8e4d94b0..2e426020cad08e93e041b18e50a5ba4b9391ee03 100644 (file)
@@ -58,7 +58,7 @@ public abstract class SharedHandVirtualItemSystem : EntitySystem
         {
             if (TryComp(hand.HeldEntity, out HandVirtualItemComponent? virt) && virt.BlockingEntity == matching)
             {
-                Delete(virt, user);
+                Delete((hand.HeldEntity.Value, virt), user);
             }
         }
     }
@@ -80,16 +80,16 @@ public abstract class SharedHandVirtualItemSystem : EntitySystem
     /// <summary>
     ///     Queues a deletion for a virtual item and notifies the blocking entity and user.
     /// </summary>
-    public void Delete(HandVirtualItemComponent comp, EntityUid user)
+    public void Delete(Entity<HandVirtualItemComponent> item, EntityUid user)
     {
         if (_net.IsClient)
             return;
 
-        var userEv = new VirtualItemDeletedEvent(comp.BlockingEntity, user);
+        var userEv = new VirtualItemDeletedEvent(item.Comp.BlockingEntity, user);
         RaiseLocalEvent(user, userEv);
-        var targEv = new VirtualItemDeletedEvent(comp.BlockingEntity, user);
-        RaiseLocalEvent(comp.BlockingEntity, targEv);
+        var targEv = new VirtualItemDeletedEvent(item.Comp.BlockingEntity, user);
+        RaiseLocalEvent(item.Comp.BlockingEntity, targEv);
 
-        QueueDel(comp.Owner);
+        QueueDel(item);
     }
 }
index e9482d24d15a272d65824ab75d75d1edd948b9a1..9debaa77190ddd5539538513a0f3d335562f1fb1 100644 (file)
@@ -38,7 +38,7 @@ public abstract class SharedLatheSystem : EntitySystem
         {
             var adjustedAmount = AdjustMaterial(needed, recipe.ApplyMaterialDiscount, component.MaterialUseMultiplier);
 
-            if (_materialStorage.GetMaterialAmount(component.Owner, material) < adjustedAmount * amount)
+            if (_materialStorage.GetMaterialAmount(uid, material) < adjustedAmount * amount)
                 return false;
         }
         return true;
index ad209c95f8e06f8306960cf7d177211734749577..d530b07b18636bb12c8216849a9bbf770aa0ed91 100644 (file)
@@ -52,10 +52,10 @@ public abstract class SharedHandheldLightSystem : EntitySystem
         if (makeNoise)
         {
             var sound = component.Activated ? component.TurnOnSound : component.TurnOffSound;
-            _audio.PlayPvs(sound, component.Owner);
+            _audio.PlayPvs(sound, uid);
         }
 
-        Dirty(component);
+        Dirty(uid, component);
         UpdateVisuals(uid, component);
     }
 
index 6b9d7dbbf9c00a0921305f72793994b1e060a5cc..857244d658ced6165de8e13567e4b20743d30b7d 100644 (file)
@@ -1,11 +1,8 @@
+using System.Diagnostics.CodeAnalysis;
 using System.Linq;
 using System.Runtime.CompilerServices;
-using System.Diagnostics.CodeAnalysis;
-using Content.Shared.Decals;
 using Content.Shared.Physics;
 using Robust.Shared.Map;
-using Robust.Shared.Physics;
-using Robust.Shared.Physics.Components;
 using Robust.Shared.Random;
 
 namespace Content.Shared.Maps
@@ -175,7 +172,7 @@ namespace Content.Shared.Maps
 
             if (map.TryGetGrid(turf.GridUid, out var tileGrid))
             {
-                var gridRot = entManager.GetComponent<TransformComponent>(tileGrid.Owner).WorldRotation;
+                var gridRot = entManager.GetComponent<TransformComponent>(turf.GridUid).WorldRotation;
 
                 // This is scaled to 90 % so it doesn't encompass walls on other tiles.
                 var tileBox = Box2.UnitCentered.Scale(0.9f);
index b07087cafa58122a0ef3f1f5e16338497521de6b..25b63d5b80bbf9d8d340e35d139fdf753b1c100a 100644 (file)
@@ -111,8 +111,8 @@ public partial class MobStateSystem
         OnStateChanged(target, component, oldState, newState);
         RaiseLocalEvent(target, ev, true);
         _adminLogger.Add(LogType.Damaged, oldState == MobState.Alive ? LogImpact.Low : LogImpact.Medium,
-            $"{ToPrettyString(component.Owner):user} state changed from {oldState} to {newState}");
-        Dirty(component);
+            $"{ToPrettyString(target):user} state changed from {oldState} to {newState}");
+        Dirty(target, component);
     }
 
     #endregion
index 8ec6ddbefe5cbf079f228f897b6dd50c810f8ef6..ec17df7a24f8c5d8cfee2cf94ba641c4cc3497db 100644 (file)
@@ -152,7 +152,7 @@ public abstract class SharedConveyorController : VirtualController
 
         foreach (var entity in comp.Intersecting)
         {
-            if (!xformQuery.TryGetComponent(entity, out var entityXform) || entityXform.ParentUid != grid.Owner)
+            if (!xformQuery.TryGetComponent(entity, out var entityXform) || entityXform.ParentUid != xform.GridUid!.Value)
                 continue;
 
             if (!bodyQuery.TryGetComponent(entity, out var physics) || physics.BodyType == BodyType.Static || physics.BodyStatus == BodyStatus.InAir || _gravity.IsWeightless(entity, physics, entityXform))
index 8e9ccadc717985f736c8074b4901009ce38e8ea8..f8711fb63e01d837bf617afee4dddebb80cf0b90 100644 (file)
@@ -17,6 +17,7 @@ public sealed class RulesSystem : EntitySystem
 
     public bool IsTrue(EntityUid uid, RulesPrototype rules)
     {
+        var inRange = new HashSet<Entity<IComponent>>();
         foreach (var rule in rules.Rules)
         {
             switch (rule)
@@ -72,12 +73,13 @@ public sealed class RulesSystem : EntitySystem
                     var count = 0;
 
                     // TODO: Update this when we get the callback version
-                    foreach (var comp in _lookup.GetComponentsInRange<AccessReaderComponent>(xform.MapID,
-                                 worldPos, access.Range))
+                    var entities = new HashSet<Entity<AccessReaderComponent>>();
+                    _lookup.GetEntitiesInRange(xform.MapID, worldPos, access.Range, entities);
+                    foreach (var comp in entities)
                     {
                         if (!_reader.AreAccessTagsAllowed(access.Access, comp) ||
                             access.Anchored &&
-                            (!xformQuery.TryGetComponent(comp.Owner, out var compXform) ||
+                            (!xformQuery.TryGetComponent(comp, out var compXform) ||
                              !compXform.Anchored))
                         {
                             continue;
@@ -113,12 +115,12 @@ public sealed class RulesSystem : EntitySystem
 
                     foreach (var compType in nearbyComps.Components.Values)
                     {
-                        // TODO: Update this when we get the callback version
-                        foreach (var comp in _lookup.GetComponentsInRange(compType.Component.GetType(), xform.MapID,
-                                     worldPos, nearbyComps.Range))
+                        inRange.Clear();
+                        _lookup.GetEntitiesInRange(compType.Component.GetType(), xform.MapID, worldPos, nearbyComps.Range, inRange);
+                        foreach (var comp in inRange)
                         {
                             if (nearbyComps.Anchored &&
-                                (!xformQuery.TryGetComponent(comp.Owner, out var compXform) ||
+                                (!xformQuery.TryGetComponent(comp, out var compXform) ||
                                  !compXform.Anchored))
                             {
                                 continue;
index 40e6a53a00d4733fa21cd497c295f03ca0c98537..7fa2ef51e8aeda63135d432e62e66e5c044994ee 100644 (file)
@@ -20,10 +20,10 @@ public abstract class SharedRevenantOverloadedLightsSystem : EntitySystem
             if (comp.Accumulator < comp.ZapDelay)
                 continue;
 
-            OnZap(comp);
+            OnZap((uid, comp));
             RemCompDeferred(uid, comp);
         }
     }
 
-    protected abstract void OnZap(RevenantOverloadedLightsComponent component);
+    protected abstract void OnZap(Entity<RevenantOverloadedLightsComponent> component);
 }
index d9fc044dceaef9b34518ad3cc2e8f75d1169e051..c704c8bf77b469e507b164009382a099efb9d728 100644 (file)
@@ -92,7 +92,7 @@ public sealed partial class ContainmentFieldGeneratorComponent : Component
     /// Stores a list of fields connected between generators in this direction.
     /// </summary>
     [ViewVariables]
-    public Dictionary<Direction, (ContainmentFieldGeneratorComponent, List<EntityUid>)> Connections = new();
+    public Dictionary<Direction, (Entity<ContainmentFieldGeneratorComponent>, List<EntityUid>)> Connections = new();
 
     /// <summary>
     /// What fields should this spawn?
index 2ea40308b9448dbc4e5b17f8aada16007fa04f2e..acac1dfd84558a8e65fe01969a16bad7cc3ca118 100644 (file)
@@ -1,13 +1,12 @@
 using System.Numerics;
+using Content.Shared.Radiation.Components;
+using Content.Shared.Singularity.Components;
+using Content.Shared.Singularity.Events;
 using Robust.Shared.Containers;
 using Robust.Shared.Physics.Components;
 using Robust.Shared.Physics.Systems;
 using Robust.Shared.Serialization;
 
-using Content.Shared.Radiation.Components;
-using Content.Shared.Singularity.Components;
-using Content.Shared.Singularity.Events;
-
 namespace Content.Shared.Singularity.EntitySystems;
 
 /// <summary>
@@ -89,8 +88,8 @@ public abstract class SharedSingularitySystem : EntitySystem
 
         singularity.Level = value;
         UpdateSingularityLevel(uid, oldValue, singularity);
-        if(!EntityManager.Deleted(singularity.Owner))
-            EntityManager.Dirty(singularity);
+        if (!Deleted(uid))
+            Dirty(uid, singularity);
     }
 
     /// <summary>
index 99e3f7c6de4b20c9105e6c9ace1c311a2260df9c..d70dfc52f951196e5a58506aac36914cf0c281e2 100644 (file)
@@ -1,6 +1,5 @@
 using System.Numerics;
 using Content.Shared.Examine;
-using Content.Shared.Hands;
 using Content.Shared.Hands.Components;
 using Content.Shared.Hands.EntitySystems;
 using Content.Shared.Interaction;
@@ -217,8 +216,8 @@ namespace Content.Shared.Stacks
 
             var map = xform.MapID;
             var bounds = _physics.GetWorldAABB(uid);
-            var intersecting = _entityLookup.GetComponentsIntersecting<StackComponent>(map, bounds,
-                LookupFlags.Dynamic | LookupFlags.Sundries);
+            var intersecting = new HashSet<Entity<StackComponent>>();
+            _entityLookup.GetEntitiesIntersecting(map, bounds, intersecting, LookupFlags.Dynamic | LookupFlags.Sundries);
 
             var merged = false;
             foreach (var otherStack in intersecting)
index 17b886449301f1916b3bcc373171f8631d6e619d..6aec3a8b3b4a0f7ee723b3ff7466c1451c355ec0 100644 (file)
@@ -33,14 +33,14 @@ namespace Content.Shared.StatusEffect
             var curTime = _gameTiming.CurTime;
             var enumerator = EntityQueryEnumerator<ActiveStatusEffectsComponent, StatusEffectsComponent>();
 
-            while (enumerator.MoveNext(out _, out var status))
+            while (enumerator.MoveNext(out var uid, out _, out var status))
             {
                 foreach (var state in status.ActiveEffects.ToArray())
                 {
                     // if we're past the end point of the effect
                     if (curTime > state.Value.Cooldown.Item2)
                     {
-                        TryRemoveStatusEffect(status.Owner, state.Key, status);
+                        TryRemoveStatusEffect(uid, state.Key, status);
                     }
                 }
             }
@@ -134,10 +134,7 @@ namespace Content.Shared.StatusEffect
                 // If they already have the comp, we just won't bother updating anything.
                 if (!EntityManager.HasComponent(uid, _componentFactory.GetRegistration(component).Type))
                 {
-                    // Fuck this shit I hate it
                     var newComponent = (Component) _componentFactory.GetComponent(component);
-                    newComponent.Owner = uid;
-
                     EntityManager.AddComponent(uid, newComponent);
                     status.ActiveEffects[key].RelevantComponent = component;
                 }
index cb53ea829852a007ed62dadb5be0983607f692de..ad86a52665d93d0d5c084ad3fa2237aacfaf67aa 100644 (file)
@@ -133,7 +133,7 @@ public sealed class DumpableSystem : EntitySystem
         foreach (var entity in dumpQueue)
         {
             var transform = Transform(entity);
-            _container.AttachParentToContainerOrGrid(transform);
+            _container.AttachParentToContainerOrGrid((entity, transform));
             _transformSystem.SetLocalPositionRotation(transform, transform.LocalPosition + _random.NextVector2Box() / 2, _random.NextAngle());
         }
 
index 47e1f02ad8faaa0e291fc3092b1db7a62c44de4b..a698ae5035a986fa1e47e44fb60e6ef12ed2c52f 100644 (file)
@@ -29,11 +29,11 @@ public abstract class SharedStrippableSystem : EntitySystem
         if (args.Handled || args.Target != args.User)
             return;
 
-        StartOpeningStripper(args.User, component);
+        StartOpeningStripper(args.User, (uid, component));
         args.Handled = true;
     }
 
-    public virtual void StartOpeningStripper(EntityUid user, StrippableComponent component, bool openInCombat = false)
+    public virtual void StartOpeningStripper(EntityUid user, Entity<StrippableComponent> component, bool openInCombat = false)
     {
 
     }
index 3aba97e92dfceff48101c77b6f2875bf0948af6e..c7040515c8e05dc4f837e742901981f3d6aaeecc 100644 (file)
@@ -101,13 +101,12 @@ public abstract class SharedWeatherSystem : EntitySystem
 
         var curTime = Timing.CurTime;
 
-        foreach (var comp in EntityQuery<WeatherComponent>())
+        var query = EntityQueryEnumerator<WeatherComponent>();
+        while (query.MoveNext(out var uid, out var comp))
         {
             if (comp.Weather.Count == 0)
                 continue;
 
-            var uid = comp.Owner;
-
             foreach (var (proto, weather) in comp.Weather)
             {
                 var endTime = weather.EndTime;
index 72e550ac6e3078de7ec9880ee3d2191030983b17..7d681e02b1d43d4877b049566c956f8dc0bd5cad 100644 (file)
@@ -51,6 +51,7 @@
     <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INVOCABLE_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
     <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/OTHER_BRACES/@EntryValue">NEXT_LINE</s:String>
     <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/TYPE_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
+       <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AABB/@EntryIndexedValue">AABB</s:String>
        <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AL/@EntryIndexedValue">AL</s:String>
        <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=BB/@EntryIndexedValue">BB</s:String>
        <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CC/@EntryIndexedValue">CC</s:String>
@@ -96,7 +97,7 @@
        <s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/QuickList/=F0CA621CDF5AB24282D8CDC11C520997/Entry/=142539C9975BA84BA1996ADB02B1E422/@KeyIndexDefined">True</s:Boolean>
        <s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/QuickList/=F0CA621CDF5AB24282D8CDC11C520997/Entry/=142539C9975BA84BA1996ADB02B1E422/EntryName/@EntryValue">Entity Component</s:String>
        <s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/QuickList/=F0CA621CDF5AB24282D8CDC11C520997/Entry/=142539C9975BA84BA1996ADB02B1E422/Position/@EntryValue">1</s:Int64>
-       
+
 
 
        <s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/QuickList/=F0CA621CDF5AB24282D8CDC11C520997/Entry/=2CBD6971A7955044AD2624B84FB49E38/Position/@EntryValue">9</s:Int64>
        <s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/QuickList/=F0CA621CDF5AB24282D8CDC11C520997/Entry/=567DCF4B487C244A9F6BB46E4E9F3B84/Position/@EntryValue">6</s:Int64>
        <s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/QuickList/=F0CA621CDF5AB24282D8CDC11C520997/Entry/=652E0DBD3559BD4EA35305A83762B0C8/@KeyIndexDefined">True</s:Boolean>
        <s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/QuickList/=F0CA621CDF5AB24282D8CDC11C520997/Entry/=652E0DBD3559BD4EA35305A83762B0C8/EntryName/@EntryValue">XAML Control</s:String>
-       
+
        <s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/QuickList/=F0CA621CDF5AB24282D8CDC11C520997/Entry/=7C233DA875A1B54AB9906002129B9E8C/@KeyIndexDefined">True</s:Boolean>
        <s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/QuickList/=F0CA621CDF5AB24282D8CDC11C520997/Entry/=7C233DA875A1B54AB9906002129B9E8C/EntryName/@EntryValue">Client/Server Net Entity System</s:String>
        <s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/QuickList/=F0CA621CDF5AB24282D8CDC11C520997/Entry/=7C233DA875A1B54AB9906002129B9E8C/Position/@EntryValue">8</s:Int64>
@@ -608,7 +609,7 @@ public sealed partial class $CLASS$ : Shared$CLASS$ {
        <s:Boolean x:Key="/Default/UserDictionary/Words/=Gibs/@EntryIndexedValue">True</s:Boolean>
        <s:Boolean x:Key="/Default/UserDictionary/Words/=godmode/@EntryIndexedValue">True</s:Boolean>
        <s:Boolean x:Key="/Default/UserDictionary/Words/=gridcast/@EntryIndexedValue">True</s:Boolean>
-       
+
        <s:Boolean x:Key="/Default/UserDictionary/Words/=Grindable/@EntryIndexedValue">True</s:Boolean>
        <s:Boolean x:Key="/Default/UserDictionary/Words/=hardcode/@EntryIndexedValue">True</s:Boolean>
        <s:Boolean x:Key="/Default/UserDictionary/Words/=hbox/@EntryIndexedValue">True</s:Boolean>