diff --git a/Content.Client/Administration/UI/Tabs/AdminbusTab/LoadBlueprintsWindow.xaml.cs b/Content.Client/Administration/UI/Tabs/AdminbusTab/LoadBlueprintsWindow.xaml.cs index 374093c576..0cc3294df1 100644 --- a/Content.Client/Administration/UI/Tabs/AdminbusTab/LoadBlueprintsWindow.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/AdminbusTab/LoadBlueprintsWindow.xaml.cs @@ -40,6 +40,7 @@ namespace Content.Client.Administration.UI.Tabs.AdminbusTab private void Reset() { var entManager = IoCManager.Resolve(); + var xformSystem = entManager.System(); var playerManager = IoCManager.Resolve(); var player = playerManager.LocalPlayer?.ControlledEntity; @@ -50,16 +51,16 @@ namespace Content.Client.Administration.UI.Tabs.AdminbusTab if (entManager.TryGetComponent(player, out var xform)) { currentMap = xform.MapID; - position = xform.WorldPosition; + position = xformSystem.GetWorldPosition(xform); if (entManager.TryGetComponent(xform.GridUid, out var gridXform)) { - rotation = gridXform.WorldRotation; + rotation = xformSystem.GetWorldRotation(gridXform); } else { // MapId moment - rotation = xform.WorldRotation - xform.LocalRotation; + rotation = xformSystem.GetWorldRotation(xform) - xform.LocalRotation; } } diff --git a/Content.Client/Administration/UI/Tabs/AtmosTab/AddGasWindow.xaml.cs b/Content.Client/Administration/UI/Tabs/AtmosTab/AddGasWindow.xaml.cs index 55db123ea6..87db34fbec 100644 --- a/Content.Client/Administration/UI/Tabs/AtmosTab/AddGasWindow.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/AtmosTab/AddGasWindow.xaml.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using System.Linq; using Content.Client.Atmos.EntitySystems; using Content.Shared.Atmos.Prototypes; @@ -8,9 +7,6 @@ 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.Shared.Map.Components; namespace Content.Client.Administration.UI.Tabs.AtmosTab @@ -19,24 +15,31 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab [UsedImplicitly] public sealed partial class AddGasWindow : DefaultWindow { - private IEnumerable? _gridData; + private List? _gridData; private IEnumerable? _gasData; protected override void EnteredTree() { // Fill out grids - _gridData = IoCManager.Resolve().GetAllGrids().Where(g => (int) g.Owner != 0); - foreach (var grid in _gridData) + var entManager = IoCManager.Resolve(); + var playerManager = IoCManager.Resolve(); + + var gridQuery = entManager.AllEntityQueryEnumerator(); + _gridData ??= new List(); + _gridData.Clear(); + + while (gridQuery.MoveNext(out var uid, out _)) { - var player = IoCManager.Resolve().LocalPlayer?.ControlledEntity; - var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridUid; - GridOptions.AddItem($"{grid.Owner} {(playerGrid == grid.Owner ? " (Current)" : "")}"); + var player = playerManager.LocalPlayer?.ControlledEntity; + var playerGrid = entManager.GetComponentOrNull(player)?.GridUid; + GridOptions.AddItem($"{uid} {(playerGrid == uid ? " (Current)" : "")}"); } GridOptions.OnItemSelected += eventArgs => GridOptions.SelectId(eventArgs.Id); // Fill out gases - _gasData = EntitySystem.Get().Gases; + _gasData = entManager.System().Gases; + foreach (var gas in _gasData) { var gasName = Loc.GetString(gas.Name); @@ -53,8 +56,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab if (_gridData == null || _gasData == null) return; - var gridList = _gridData.ToList(); - var gridIndex = gridList[GridOptions.SelectedId].Owner; + var gridIndex = _gridData[GridOptions.SelectedId]; var gasList = _gasData.ToList(); var gasId = gasList[GasOptions.SelectedId].ID; diff --git a/Content.Client/Administration/UI/Tabs/AtmosTab/FillGasWindow.xaml.cs b/Content.Client/Administration/UI/Tabs/AtmosTab/FillGasWindow.xaml.cs index 34212ac6d3..5e17d3d031 100644 --- a/Content.Client/Administration/UI/Tabs/AtmosTab/FillGasWindow.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/AtmosTab/FillGasWindow.xaml.cs @@ -19,24 +19,32 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab [UsedImplicitly] public sealed partial class FillGasWindow : DefaultWindow { - private IEnumerable? _gridData; + private List? _gridData; private IEnumerable? _gasData; protected override void EnteredTree() { // Fill out grids - _gridData = IoCManager.Resolve().GetAllGrids().Where(g => (int) g.Owner != 0); - foreach (var grid in _gridData) + var entManager = IoCManager.Resolve(); + var playerManager = IoCManager.Resolve(); + + var gridQuery = entManager.AllEntityQueryEnumerator(); + _gridData ??= new List(); + _gridData.Clear(); + + while (gridQuery.MoveNext(out var uid, out _)) { - var player = IoCManager.Resolve().LocalPlayer?.ControlledEntity; - var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridUid; - GridOptions.AddItem($"{grid.Owner} {(playerGrid == grid.Owner ? " (Current)" : "")}"); + var player = playerManager.LocalPlayer?.ControlledEntity; + var playerGrid = entManager.GetComponentOrNull(player)?.GridUid; + GridOptions.AddItem($"{uid} {(playerGrid == uid ? " (Current)" : "")}"); + _gridData.Add(uid); } GridOptions.OnItemSelected += eventArgs => GridOptions.SelectId(eventArgs.Id); // Fill out gases - _gasData = EntitySystem.Get().Gases; + _gasData = entManager.System().Gases; + foreach (var gas in _gasData) { var gasName = Loc.GetString(gas.Name); @@ -53,8 +61,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab if (_gridData == null || _gasData == null) return; - var gridList = _gridData.ToList(); - var gridIndex = gridList[GridOptions.SelectedId].Owner; + var gridIndex = _gridData[GridOptions.SelectedId]; var gasList = _gasData.ToList(); var gasId = gasList[GasOptions.SelectedId].ID; diff --git a/Content.Client/Administration/UI/Tabs/AtmosTab/SetTemperatureWindow.xaml.cs b/Content.Client/Administration/UI/Tabs/AtmosTab/SetTemperatureWindow.xaml.cs index 028dccd014..c49cb02511 100644 --- a/Content.Client/Administration/UI/Tabs/AtmosTab/SetTemperatureWindow.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/AtmosTab/SetTemperatureWindow.xaml.cs @@ -17,16 +17,23 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab [UsedImplicitly] public sealed partial class SetTemperatureWindow : DefaultWindow { - private IEnumerable? _data; + private List? _data; protected override void EnteredTree() { - _data = IoCManager.Resolve().GetAllGrids().Where(g => (int) g.Owner != 0); - foreach (var grid in _data) + var entManager = IoCManager.Resolve(); + var playerManager = IoCManager.Resolve(); + + var gridQuery = entManager.AllEntityQueryEnumerator(); + _data ??= new List(); + _data.Clear(); + + while (gridQuery.MoveNext(out var uid, out _)) { - var player = IoCManager.Resolve().LocalPlayer?.ControlledEntity; - var playerGrid = IoCManager.Resolve().GetComponentOrNull(player)?.GridUid; - GridOptions.AddItem($"{grid.Owner} {(playerGrid == grid.Owner ? " (Current)" : "")}"); + var player = playerManager.LocalPlayer?.ControlledEntity; + var playerGrid = entManager.GetComponentOrNull(player)?.GridUid; + GridOptions.AddItem($"{uid} {(playerGrid == uid ? " (Current)" : "")}"); + _data.Add(uid); } GridOptions.OnItemSelected += eventArgs => GridOptions.SelectId(eventArgs.Id); @@ -37,8 +44,8 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab { if (_data == null) return; - var dataList = _data.ToList(); - var selectedGrid = dataList[GridOptions.SelectedId].Owner; + + var selectedGrid = _data[GridOptions.SelectedId]; IoCManager.Resolve() .ExecuteCommand($"settemp {TileXSpin.Value} {TileYSpin.Value} {selectedGrid} {TemperatureSpin.Value}"); } diff --git a/Content.Client/Audio/AmbientSoundOverlay.cs b/Content.Client/Audio/AmbientSoundOverlay.cs index 9e43bfa793..3110d81384 100644 --- a/Content.Client/Audio/AmbientSoundOverlay.cs +++ b/Content.Client/Audio/AmbientSoundOverlay.cs @@ -9,9 +9,9 @@ namespace Content.Client.Audio; /// public sealed class AmbientSoundOverlay : Overlay { - private IEntityManager _entManager; - private AmbientSoundSystem _ambient; - private EntityLookupSystem _lookup; + private readonly IEntityManager _entManager; + private readonly AmbientSoundSystem _ambient; + private readonly EntityLookupSystem _lookup; public override OverlaySpace Space => OverlaySpace.WorldSpace; @@ -27,6 +27,7 @@ public sealed class AmbientSoundOverlay : Overlay var worldHandle = args.WorldHandle; var ambientQuery = _entManager.GetEntityQuery(); var xformQuery = _entManager.GetEntityQuery(); + var xformSystem = _entManager.System(); const float Size = 0.25f; const float Alpha = 0.25f; @@ -40,16 +41,16 @@ public sealed class AmbientSoundOverlay : Overlay { if (_ambient.IsActive(ambientSound)) { - worldHandle.DrawCircle(xform.WorldPosition, Size, Color.LightGreen.WithAlpha(Alpha * 2f)); + worldHandle.DrawCircle(xformSystem.GetWorldPosition(xform), Size, Color.LightGreen.WithAlpha(Alpha * 2f)); } else { - worldHandle.DrawCircle(xform.WorldPosition, Size, Color.Orange.WithAlpha(Alpha)); + worldHandle.DrawCircle(xformSystem.GetWorldPosition(xform), Size, Color.Orange.WithAlpha(Alpha)); } } else { - worldHandle.DrawCircle(xform.WorldPosition, Size, Color.Red.WithAlpha(Alpha)); + worldHandle.DrawCircle(xformSystem.GetWorldPosition(xform), Size, Color.Red.WithAlpha(Alpha)); } } } diff --git a/Content.Client/Inventory/ClientInventorySystem.cs b/Content.Client/Inventory/ClientInventorySystem.cs index afd15a272d..b454ad27a3 100644 --- a/Content.Client/Inventory/ClientInventorySystem.cs +++ b/Content.Client/Inventory/ClientInventorySystem.cs @@ -32,7 +32,7 @@ namespace Content.Client.Inventory public Action? EntitySlotUpdate = null; public Action? OnSlotAdded = null; public Action? OnSlotRemoved = null; - public Action? OnLinkInventorySlots = null; + public Action? OnLinkInventorySlots = null; public Action? OnUnlinkInventory = null; public Action? OnSpriteUpdate = null; @@ -138,7 +138,7 @@ namespace Content.Client.Inventory } } - OnLinkInventorySlots?.Invoke(component); + OnLinkInventorySlots?.Invoke(uid, component); } public override void Shutdown() @@ -173,7 +173,7 @@ namespace Content.Client.Inventory } OnUnlinkInventory?.Invoke(); - OnLinkInventorySlots?.Invoke(component); + OnLinkInventorySlots?.Invoke(player.Value, component); } public void SetSlotHighlight(EntityUid owner, InventorySlotsComponent component, string slotName, bool state) diff --git a/Content.Client/UserInterface/Systems/Inventory/InventoryUIController.cs b/Content.Client/UserInterface/Systems/Inventory/InventoryUIController.cs index e7ad70b058..cd0236519f 100644 --- a/Content.Client/UserInterface/Systems/Inventory/InventoryUIController.cs +++ b/Content.Client/UserInterface/Systems/Inventory/InventoryUIController.cs @@ -28,6 +28,7 @@ public sealed class InventoryUIController : UIController, IOnStateEntered _slotGroups = new(); @@ -222,26 +223,26 @@ public sealed class InventoryUIController : UIController, IOnStateEntered query) + private void UpdateColliding(EntityUid uid, StepTriggerComponent component, TransformComponent ownerTransform, EntityUid otherUid, EntityQuery query) { if (!query.TryGetComponent(otherUid, out var otherPhysics)) return; // TODO: This shouldn't be calculating based on world AABBs. - var ourAabb = _entityLookup.GetWorldAABB(component.Owner, ownerTransform); + var ourAabb = _entityLookup.GetWorldAABB(uid, ownerTransform); var otherAabb = _entityLookup.GetWorldAABB(otherUid); if (!ourAabb.Intersects(otherAabb)) { if (component.CurrentlySteppedOn.Remove(otherUid)) { - Dirty(component); + Dirty(uid, component); } return; } @@ -101,17 +99,16 @@ public sealed class StepTriggerSystem : EntitySystem if (otherPhysics.LinearVelocity.Length() < component.RequiredTriggerSpeed || component.CurrentlySteppedOn.Contains(otherUid) || otherAabb.IntersectPercentage(ourAabb) < component.IntersectRatio - || !CanTrigger(component.Owner, otherUid, component)) + || !CanTrigger(uid, otherUid, component)) { return; } - var ev = new StepTriggeredEvent { Source = component.Owner, Tripper = otherUid }; - RaiseLocalEvent(component.Owner, ref ev, true); + var ev = new StepTriggeredEvent { Source = uid, Tripper = otherUid }; + RaiseLocalEvent(uid, ref ev, true); component.CurrentlySteppedOn.Add(otherUid); - Dirty(component); - return; + Dirty(uid, component); } private bool CanTrigger(EntityUid uid, EntityUid otherUid, StepTriggerComponent component) @@ -140,7 +137,7 @@ public sealed class StepTriggerSystem : EntitySystem if (component.Colliding.Add(otherUid)) { - Dirty(component); + Dirty(uid, component); } } @@ -152,7 +149,7 @@ public sealed class StepTriggerSystem : EntitySystem return; component.CurrentlySteppedOn.Remove(otherUid); - Dirty(component); + Dirty(uid, component); if (component.Colliding.Count == 0) { @@ -211,7 +208,7 @@ public sealed class StepTriggerSystem : EntitySystem return; component.IntersectRatio = ratio; - Dirty(component); + Dirty(uid, component); } public void SetRequiredTriggerSpeed(EntityUid uid, float speed, StepTriggerComponent? component = null) @@ -223,7 +220,7 @@ public sealed class StepTriggerSystem : EntitySystem return; component.RequiredTriggerSpeed = speed; - Dirty(component); + Dirty(uid, component); } public void SetActive(EntityUid uid, bool active, StepTriggerComponent? component = null) @@ -235,7 +232,7 @@ public sealed class StepTriggerSystem : EntitySystem return; component.Active = active; - Dirty(component); + Dirty(uid, component); } } diff --git a/Content.Shared/Storage/EntitySystems/SharedItemCounterSystem.cs b/Content.Shared/Storage/EntitySystems/SharedItemCounterSystem.cs index b2912db2a5..8ef62c45c4 100644 --- a/Content.Shared/Storage/EntitySystems/SharedItemCounterSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SharedItemCounterSystem.cs @@ -21,32 +21,32 @@ namespace Content.Shared.Storage.EntitySystems private void CounterEntityInserted(EntityUid uid, ItemCounterComponent itemCounter, EntInsertedIntoContainerMessage args) { - if (!EntityManager.TryGetComponent(itemCounter.Owner, out AppearanceComponent? appearanceComponent)) + if (!EntityManager.TryGetComponent(uid, out AppearanceComponent? appearanceComponent)) return; var count = GetCount(args, itemCounter); if (count == null) return; - _appearance.SetData(itemCounter.Owner, StackVisuals.Actual, count, appearanceComponent); + _appearance.SetData(uid, StackVisuals.Actual, count, appearanceComponent); if (itemCounter.MaxAmount != null) - _appearance.SetData(itemCounter.Owner, StackVisuals.MaxCount, itemCounter.MaxAmount, appearanceComponent); + _appearance.SetData(uid, StackVisuals.MaxCount, itemCounter.MaxAmount, appearanceComponent); } private void CounterEntityRemoved(EntityUid uid, ItemCounterComponent itemCounter, EntRemovedFromContainerMessage args) { - if (!EntityManager.TryGetComponent(itemCounter.Owner, out AppearanceComponent? appearanceComponent)) + if (!EntityManager.TryGetComponent(uid, out AppearanceComponent? appearanceComponent)) return; var count = GetCount(args, itemCounter); if (count == null) return; - _appearance.SetData(itemCounter.Owner, StackVisuals.Actual, count, appearanceComponent); + _appearance.SetData(uid, StackVisuals.Actual, count, appearanceComponent); if (itemCounter.MaxAmount != null) - _appearance.SetData(itemCounter.Owner, StackVisuals.MaxCount, itemCounter.MaxAmount, appearanceComponent); + _appearance.SetData(uid, StackVisuals.MaxCount, itemCounter.MaxAmount, appearanceComponent); } protected abstract int? GetCount(ContainerModifiedMessage msg, ItemCounterComponent itemCounter); diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Interactions.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Interactions.cs index 4ffbe8fc63..53dc9dfced 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Interactions.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Interactions.cs @@ -78,7 +78,7 @@ public abstract partial class SharedGunSystem Audio.PlayPredicted(component.SoundModeToggle, uid, user); Popup(Loc.GetString("gun-selected-mode", ("mode", GetLocSelector(fire))), uid, user); - Dirty(component); + Dirty(uid, component); } /// diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs index 040d3f5713..50a89cb93e 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs @@ -8,6 +8,7 @@ using Robust.Shared.Serialization; using Robust.Shared.Utility; using System; using System.Linq; +using JetBrains.Annotations; namespace Content.Shared.Weapons.Ranged.Systems; @@ -164,7 +165,7 @@ public partial class SharedGunSystem Popup(Loc.GetString("gun-revolver-insert"), revolverUid, user); UpdateRevolverAppearance(revolverUid, component); UpdateAmmoCount(uid); - Dirty(component); + Dirty(uid, component); return true; } @@ -223,6 +224,7 @@ public partial class SharedGunSystem return count; } + [PublicAPI] private int GetRevolverUnspentCount(RevolverAmmoProviderComponent component) { var count = 0; @@ -261,7 +263,8 @@ public partial class SharedGunSystem if (slot == null) { - if (chamber == null) continue; + if (chamber == null) + continue; // Too lazy to make a new method don't sue me. if (!_netManager.IsClient) @@ -294,7 +297,7 @@ public partial class SharedGunSystem Audio.PlayPredicted(component.SoundEject, revolverUid, user); UpdateAmmoCount(revolverUid); UpdateRevolverAppearance(revolverUid, component); - Dirty(component); + Dirty(revolverUid, component); } } @@ -366,12 +369,12 @@ public partial class SharedGunSystem component.AmmoContainer.Remove(ent.Value); component.AmmoSlots[index] = null; args.Ammo.Add((ent.Value, EnsureComp(ent.Value))); - Transform(ent.Value).Coordinates = args.Coordinates; + TransformSystem.SetCoordinates(ent.Value, args.Coordinates); } } UpdateRevolverAppearance(uid, component); - Dirty(component); + Dirty(uid, component); } private void Cycle(RevolverAmmoProviderComponent component, int count = 1) diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs index 3d0530e3aa..f0500d1fbd 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs @@ -329,7 +329,7 @@ public abstract partial class SharedGunSystem : EntitySystem CauseImpulse(fromCoordinates, toCoordinates.Value, user, userPhysics); } - Dirty(gun); + Dirty(gunUid, gun); } public void Shoot( @@ -366,7 +366,7 @@ public abstract partial class SharedGunSystem : EntitySystem protected void SetCartridgeSpent(EntityUid uid, CartridgeAmmoComponent cartridge, bool spent) { if (cartridge.Spent != spent) - Dirty(cartridge); + Dirty(uid, cartridge); cartridge.Spent = spent; Appearance.SetData(uid, AmmoVisuals.Spent, spent); @@ -380,14 +380,14 @@ public abstract partial class SharedGunSystem : EntitySystem bool playSound = true) { // TODO: Sound limit version. - var offsetPos = (Random.NextVector2(EjectOffset)); + var offsetPos = Random.NextVector2(EjectOffset); var xform = Transform(entity); var coordinates = xform.Coordinates; coordinates = coordinates.Offset(offsetPos); - xform.LocalRotation = Random.NextAngle(); - xform.Coordinates = coordinates; + TransformSystem.SetLocalRotation(xform, Random.NextAngle()); + TransformSystem.SetCoordinates(entity, xform, coordinates); if (playSound && TryComp(entity, out var cartridge)) {