diff --git a/Content.Client/Actions/ActionsSystem.cs b/Content.Client/Actions/ActionsSystem.cs index 5c64a51d66..1210cc0e12 100644 --- a/Content.Client/Actions/ActionsSystem.cs +++ b/Content.Client/Actions/ActionsSystem.cs @@ -85,7 +85,7 @@ namespace Content.Client.Actions { var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; if (playerEntity == null || - !playerEntity.TryGetComponent(out var actionsComponent)) return false; + !IoCManager.Resolve().TryGetComponent(playerEntity.Uid, out var actionsComponent)) return false; actionsComponent.HandleHotbarKeybind(slot, args); return true; @@ -99,7 +99,7 @@ namespace Content.Client.Actions { var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; if (playerEntity == null || - !playerEntity.TryGetComponent( out var actionsComponent)) return false; + !IoCManager.Resolve().TryGetComponent(playerEntity.Uid, out var actionsComponent)) return false; actionsComponent.HandleChangeHotbarKeybind(hotbar, args); return true; @@ -111,7 +111,7 @@ namespace Content.Client.Actions { var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; if (playerEntity == null || - !playerEntity.TryGetComponent( out var actionsComponent)) return false; + !IoCManager.Resolve().TryGetComponent(playerEntity.Uid, out var actionsComponent)) return false; return actionsComponent.TargetingOnUse(args); } @@ -120,7 +120,7 @@ namespace Content.Client.Actions { var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; if (playerEntity == null || - !playerEntity.TryGetComponent( out var actionsComponent)) return; + !IoCManager.Resolve().TryGetComponent(playerEntity.Uid, out var actionsComponent)) return; actionsComponent.ToggleActionsMenu(); } diff --git a/Content.Client/Actions/UI/ActionSlot.cs b/Content.Client/Actions/UI/ActionSlot.cs index 36702eddd9..77db508340 100644 --- a/Content.Client/Actions/UI/ActionSlot.cs +++ b/Content.Client/Actions/UI/ActionSlot.cs @@ -231,7 +231,7 @@ namespace Content.Client.Actions.UI { ActionPrototype actionPrototype => new ActionAttempt(actionPrototype), ItemActionPrototype itemActionPrototype => - (Item != null && Item.TryGetComponent(out var itemActions)) ? + (Item != null && IoCManager.Resolve().TryGetComponent(Item.Uid, out var itemActions)) ? new ItemActionAttempt(itemActionPrototype, Item, itemActions) : null, _ => null }; @@ -504,7 +504,7 @@ namespace Content.Client.Actions.UI if (Item != null) { - SetItemIcon(Item.TryGetComponent(out var spriteComponent) ? spriteComponent : null); + SetItemIcon(IoCManager.Resolve().TryGetComponent(Item.Uid, out var spriteComponent) ? spriteComponent : null); } else { diff --git a/Content.Client/Animations/ReusableAnimations.cs b/Content.Client/Animations/ReusableAnimations.cs index f69626fd30..48b55416c9 100644 --- a/Content.Client/Animations/ReusableAnimations.cs +++ b/Content.Client/Animations/ReusableAnimations.cs @@ -17,7 +17,7 @@ namespace Content.Client.Animations var animatableClone = IoCManager.Resolve().SpawnEntity("clientsideclone", initialPosition); animatableClone.Name = entity.Name; - if (!entity.TryGetComponent(out SpriteComponent? sprite0)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out SpriteComponent? sprite0)) { Logger.Error("Entity ({0}) couldn't be animated for pickup since it doesn't have a {1}!", entity.Name, nameof(SpriteComponent)); return; diff --git a/Content.Client/Atmos/Visualizers/PipeConnectorVisualizer.cs b/Content.Client/Atmos/Visualizers/PipeConnectorVisualizer.cs index 9da44150d8..aa2d47c796 100644 --- a/Content.Client/Atmos/Visualizers/PipeConnectorVisualizer.cs +++ b/Content.Client/Atmos/Visualizers/PipeConnectorVisualizer.cs @@ -41,7 +41,7 @@ namespace Content.Client.Atmos.Visualizers { base.InitializeEntity(entity); - if (!entity.TryGetComponent(out var sprite)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out var sprite)) return; if (_connectorRsi == null) diff --git a/Content.Client/Audio/AmbientSoundSystem.cs b/Content.Client/Audio/AmbientSoundSystem.cs index ac19253201..ab9295671d 100644 --- a/Content.Client/Audio/AmbientSoundSystem.cs +++ b/Content.Client/Audio/AmbientSoundSystem.cs @@ -136,7 +136,7 @@ namespace Content.Client.Audio foreach (var entity in _lookup.GetEntitiesInRange(coordinates, _maxAmbientRange, LookupFlags.Approximate | LookupFlags.IncludeAnchored)) { - if (!entity.TryGetComponent(out AmbientSoundComponent? ambientComp) || + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out AmbientSoundComponent? ambientComp) || _playingSounds.ContainsKey(ambientComp) || !ambientComp.Enabled || // We'll also do this crude distance check because it's what we're doing in the active loop above. diff --git a/Content.Client/Buckle/BuckleComponent.cs b/Content.Client/Buckle/BuckleComponent.cs index 2e342aa203..db048aea26 100644 --- a/Content.Client/Buckle/BuckleComponent.cs +++ b/Content.Client/Buckle/BuckleComponent.cs @@ -1,6 +1,7 @@ using Content.Shared.Buckle.Components; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Client.Buckle { @@ -30,7 +31,7 @@ namespace Content.Client.Buckle LastEntityBuckledTo = buckle.LastEntityBuckledTo; DontCollide = buckle.DontCollide; - if (!Owner.TryGetComponent(out SpriteComponent? ownerSprite)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out SpriteComponent? ownerSprite)) { return; } diff --git a/Content.Client/Buckle/BuckleVisualizer.cs b/Content.Client/Buckle/BuckleVisualizer.cs index ada75bfc34..a991b90ad7 100644 --- a/Content.Client/Buckle/BuckleVisualizer.cs +++ b/Content.Client/Buckle/BuckleVisualizer.cs @@ -33,7 +33,7 @@ namespace Content.Client.Buckle { var sprite = IoCManager.Resolve().GetComponent(component.Owner.Uid); - if (!sprite.Owner.TryGetComponent(out AnimationPlayerComponent? animation)) + if (!IoCManager.Resolve().TryGetComponent(sprite.Owner.Uid, out AnimationPlayerComponent? animation)) { sprite.Rotation = rotation; return; diff --git a/Content.Client/Cargo/CargoConsoleBoundUserInterface.cs b/Content.Client/Cargo/CargoConsoleBoundUserInterface.cs index 4e85b9fe3a..d56f740c6e 100644 --- a/Content.Client/Cargo/CargoConsoleBoundUserInterface.cs +++ b/Content.Client/Cargo/CargoConsoleBoundUserInterface.cs @@ -4,6 +4,7 @@ using Content.Shared.Cargo; using Content.Shared.Cargo.Components; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.ViewVariables; using static Content.Shared.Cargo.Components.SharedCargoConsoleComponent; using static Robust.Client.UserInterface.Controls.BaseButton; @@ -49,8 +50,8 @@ namespace Content.Client.Cargo { base.Open(); - if (!Owner.Owner.TryGetComponent(out GalacticMarketComponent? market) || - !Owner.Owner.TryGetComponent(out CargoOrderDatabaseComponent? orders)) return; + if (!IoCManager.Resolve().TryGetComponent(Owner.Owner.Uid, out GalacticMarketComponent? market) || + !IoCManager.Resolve().TryGetComponent(Owner.Owner.Uid, out CargoOrderDatabaseComponent? orders)) return; Market = market; Orders = orders; diff --git a/Content.Client/CharacterAppearance/Systems/HumanoidAppearanceSystem.cs b/Content.Client/CharacterAppearance/Systems/HumanoidAppearanceSystem.cs index a31f17f075..6d7067610e 100644 --- a/Content.Client/CharacterAppearance/Systems/HumanoidAppearanceSystem.cs +++ b/Content.Client/CharacterAppearance/Systems/HumanoidAppearanceSystem.cs @@ -50,7 +50,7 @@ namespace Content.Client.CharacterAppearance.Systems { foreach (var (part, _) in body.Parts) { - if (part.Owner.TryGetComponent(out SpriteComponent? partSprite)) + if (IoCManager.Resolve().TryGetComponent(part.Owner.Uid, out SpriteComponent? partSprite)) { partSprite!.Color = component.Appearance.SkinColor; } @@ -108,7 +108,7 @@ namespace Content.Client.CharacterAppearance.Systems private void BodyPartAdded(HumanoidAppearanceBodyPartAddedEvent args) { if(!EntityManager.TryGetEntity(args.Uid, out var owner)) return; - if (!owner.TryGetComponent(out SpriteComponent? sprite)) + if (!IoCManager.Resolve().TryGetComponent(owner.Uid, out SpriteComponent? sprite)) { return; } @@ -132,7 +132,7 @@ namespace Content.Client.CharacterAppearance.Systems private void BodyPartRemoved(HumanoidAppearanceBodyPartRemovedEvent args) { if(!EntityManager.TryGetEntity(args.Uid, out var owner)) return; - if (!owner.TryGetComponent(out SpriteComponent? sprite)) + if (!IoCManager.Resolve().TryGetComponent(owner.Uid, out SpriteComponent? sprite)) { return; } diff --git a/Content.Client/CharacterInfo/Components/CharacterInfoComponent.cs b/Content.Client/CharacterInfo/Components/CharacterInfoComponent.cs index c5e1404a5e..9dd66273c4 100644 --- a/Content.Client/CharacterInfo/Components/CharacterInfoComponent.cs +++ b/Content.Client/CharacterInfo/Components/CharacterInfoComponent.cs @@ -50,7 +50,7 @@ namespace Content.Client.CharacterInfo.Components { case CharacterInfoMessage characterInfoMessage: _control.UpdateUI(characterInfoMessage); - if (Owner.TryGetComponent(out ISpriteComponent? spriteComponent)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ISpriteComponent? spriteComponent)) { _control.SpriteView.Sprite = spriteComponent; } diff --git a/Content.Client/CharacterInterface/CharacterInterfaceSystem.cs b/Content.Client/CharacterInterface/CharacterInterfaceSystem.cs index 589b97bc3e..c3ad1fa525 100644 --- a/Content.Client/CharacterInterface/CharacterInterfaceSystem.cs +++ b/Content.Client/CharacterInterface/CharacterInterfaceSystem.cs @@ -38,7 +38,7 @@ namespace Content.Client.CharacterInterface private void HandleOpenCharacterMenu() { if (_playerManager.LocalPlayer?.ControlledEntity == null - || !_playerManager.LocalPlayer.ControlledEntity.TryGetComponent(out CharacterInterfaceComponent? characterInterface)) + || !IoCManager.Resolve().TryGetComponent(_playerManager.LocalPlayer.ControlledEntity.Uid, out CharacterInterfaceComponent? characterInterface)) { return; } diff --git a/Content.Client/Clickable/ClickableComponent.cs b/Content.Client/Clickable/ClickableComponent.cs index 2037602bf1..2bafe81188 100644 --- a/Content.Client/Clickable/ClickableComponent.cs +++ b/Content.Client/Clickable/ClickableComponent.cs @@ -29,7 +29,7 @@ namespace Content.Client.Clickable /// True if the click worked, false otherwise. public bool CheckClick(Vector2 worldPos, out int drawDepth, out uint renderOrder) { - if (!Owner.TryGetComponent(out ISpriteComponent? sprite) || !sprite.Visible) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out ISpriteComponent? sprite) || !sprite.Visible) { drawDepth = default; renderOrder = default; diff --git a/Content.Client/Clothing/ClothingComponent.cs b/Content.Client/Clothing/ClothingComponent.cs index 4cd1d1ee46..0725588509 100644 --- a/Content.Client/Clothing/ClothingComponent.cs +++ b/Content.Client/Clothing/ClothingComponent.cs @@ -42,7 +42,7 @@ namespace Content.Client.Clothing if (!Owner.TryGetContainer(out IContainer? container)) return; - if (!container.Owner.TryGetComponent(out ClientInventoryComponent? inventory)) + if (!IoCManager.Resolve().TryGetComponent(container.Owner.Uid, out ClientInventoryComponent? inventory)) return; if (!inventory.TryFindItemSlots(Owner, out EquipmentSlotDefines.Slots? slots)) return; diff --git a/Content.Client/CombatMode/CombatModeSystem.cs b/Content.Client/CombatMode/CombatModeSystem.cs index 26c27fd538..64661b52b3 100644 --- a/Content.Client/CombatMode/CombatModeSystem.cs +++ b/Content.Client/CombatMode/CombatModeSystem.cs @@ -4,6 +4,7 @@ using Content.Shared.Targeting; using JetBrains.Annotations; using Robust.Client.GameObjects; using Robust.Client.Player; +using Robust.Shared.GameObjects; using Robust.Shared.Input.Binding; using Robust.Shared.IoC; @@ -34,7 +35,7 @@ namespace Content.Client.CombatMode public bool IsInCombatMode() { var entity = _playerManager.LocalPlayer?.ControlledEntity; - if (entity == null || !entity.TryGetComponent(out CombatModeComponent? combatMode)) + if (entity == null || !IoCManager.Resolve().TryGetComponent(entity.Uid, out CombatModeComponent? combatMode)) { return false; } diff --git a/Content.Client/Commands/DebugCommands.cs b/Content.Client/Commands/DebugCommands.cs index 33e44930ed..c297ef616c 100644 --- a/Content.Client/Commands/DebugCommands.cs +++ b/Content.Client/Commands/DebugCommands.cs @@ -55,7 +55,7 @@ namespace Content.Client.Commands foreach (var component in components) { - if (component.Owner.TryGetComponent(out ISpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out ISpriteComponent? sprite)) { sprite.DrawDepth = (int) DrawDepth.Overlays; } diff --git a/Content.Client/Commands/HideMechanismsCommand.cs b/Content.Client/Commands/HideMechanismsCommand.cs index 282fedeff5..64efe026b0 100644 --- a/Content.Client/Commands/HideMechanismsCommand.cs +++ b/Content.Client/Commands/HideMechanismsCommand.cs @@ -21,7 +21,7 @@ namespace Content.Client.Commands foreach (var mechanism in mechanisms) { - if (!mechanism.Owner.TryGetComponent(out SpriteComponent? sprite)) + if (!IoCManager.Resolve().TryGetComponent(mechanism.Owner.Uid, out SpriteComponent? sprite)) { continue; } diff --git a/Content.Client/Commands/ShowMechanismsCommand.cs b/Content.Client/Commands/ShowMechanismsCommand.cs index b61912a854..50eb37f817 100644 --- a/Content.Client/Commands/ShowMechanismsCommand.cs +++ b/Content.Client/Commands/ShowMechanismsCommand.cs @@ -23,7 +23,7 @@ namespace Content.Client.Commands foreach (var mechanism in mechanisms) { - if (mechanism.Owner.TryGetComponent(out SpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(mechanism.Owner.Uid, out SpriteComponent? sprite)) { sprite.ContainerOccluded = false; } diff --git a/Content.Client/Construction/ConstructionPlacementHijack.cs b/Content.Client/Construction/ConstructionPlacementHijack.cs index 93eaed99c1..a495fbeead 100644 --- a/Content.Client/Construction/ConstructionPlacementHijack.cs +++ b/Content.Client/Construction/ConstructionPlacementHijack.cs @@ -5,6 +5,7 @@ using Robust.Client.Graphics; using Robust.Client.Placement; using Robust.Client.Utility; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Map; namespace Content.Client.Construction @@ -37,7 +38,7 @@ namespace Content.Client.Construction /// public override bool HijackDeletion(IEntity entity) { - if (entity.TryGetComponent(out ConstructionGhostComponent? ghost)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ConstructionGhostComponent? ghost)) { _constructionSystem.ClearGhost(ghost.GhostId); } diff --git a/Content.Client/Construction/ConstructionSystem.cs b/Content.Client/Construction/ConstructionSystem.cs index fcafdba817..7f644642b9 100644 --- a/Content.Client/Construction/ConstructionSystem.cs +++ b/Content.Client/Construction/ConstructionSystem.cs @@ -147,7 +147,7 @@ namespace Content.Client.Construction var entity = EntityManager.GetEntity(args.EntityUid); - if (!entity.TryGetComponent(out var ghostComp)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out var ghostComp)) return false; TryStartConstruction(ghostComp.GhostId); diff --git a/Content.Client/ContextMenu/UI/EntityMenuPresenterGrouping.cs b/Content.Client/ContextMenu/UI/EntityMenuPresenterGrouping.cs index 9c8f2ae3b0..767cd55725 100644 --- a/Content.Client/ContextMenu/UI/EntityMenuPresenterGrouping.cs +++ b/Content.Client/ContextMenu/UI/EntityMenuPresenterGrouping.cs @@ -39,8 +39,8 @@ namespace Content.Client.ContextMenu.UI (a, b) => IoCManager.Resolve().GetComponent(a.Uid).EntityPrototype!.ID == IoCManager.Resolve().GetComponent(b.Uid).EntityPrototype!.ID, (a, b) => { - a.TryGetComponent(out var spriteA); - b.TryGetComponent(out var spriteB); + IoCManager.Resolve().TryGetComponent(a.Uid, out var spriteA); + IoCManager.Resolve().TryGetComponent(b.Uid, out var spriteB); if (spriteA == null || spriteB == null) return spriteA == spriteB; diff --git a/Content.Client/Cuffs/Components/HandcuffComponent.cs b/Content.Client/Cuffs/Components/HandcuffComponent.cs index 9be4196aea..b3415a5b0b 100644 --- a/Content.Client/Cuffs/Components/HandcuffComponent.cs +++ b/Content.Client/Cuffs/Components/HandcuffComponent.cs @@ -2,6 +2,7 @@ using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Client.Cuffs.Components { @@ -21,7 +22,7 @@ namespace Content.Client.Cuffs.Components return; } - if (Owner.TryGetComponent(out var sprite)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var sprite)) { sprite.LayerSetState(0, new RSI.StateId(state.IconState)); // TODO: safety check to see if RSI contains the state? } diff --git a/Content.Client/Damage/DamageVisualizer.cs b/Content.Client/Damage/DamageVisualizer.cs index b5e34b2f73..0944b045db 100644 --- a/Content.Client/Damage/DamageVisualizer.cs +++ b/Content.Client/Damage/DamageVisualizer.cs @@ -291,8 +291,8 @@ namespace Content.Client.Damage private void InitializeVisualizer(IEntity entity, DamageVisualizerDataComponent damageData) { - if (!entity.TryGetComponent(out SpriteComponent? spriteComponent) - || !entity.TryGetComponent(out var damageComponent) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out SpriteComponent? spriteComponent) + || !IoCManager.Resolve().TryGetComponent(entity.Uid, out var damageComponent) || !IoCManager.Resolve().HasComponent(entity.Uid)) return; diff --git a/Content.Client/Disposal/Systems/DisposalUnitSystem.cs b/Content.Client/Disposal/Systems/DisposalUnitSystem.cs index 84b55bff5a..1c183dce0d 100644 --- a/Content.Client/Disposal/Systems/DisposalUnitSystem.cs +++ b/Content.Client/Disposal/Systems/DisposalUnitSystem.cs @@ -3,6 +3,8 @@ using Content.Client.Disposal.Components; using Content.Client.Disposal.UI; using Content.Shared.Disposal; using Robust.Client.GameObjects; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Client.Disposal.Systems { @@ -38,7 +40,7 @@ namespace Content.Client.Disposal.Systems { if (component.Deleted) return true; - if (!component.Owner.TryGetComponent(out ClientUserInterfaceComponent? userInterface)) return true; + if (!IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out ClientUserInterfaceComponent? userInterface)) return true; var state = component.UiState; if (state == null) return true; diff --git a/Content.Client/Disposal/UI/DisposalUnitBoundUserInterface.cs b/Content.Client/Disposal/UI/DisposalUnitBoundUserInterface.cs index 1168d77a57..50982edf1c 100644 --- a/Content.Client/Disposal/UI/DisposalUnitBoundUserInterface.cs +++ b/Content.Client/Disposal/UI/DisposalUnitBoundUserInterface.cs @@ -3,6 +3,7 @@ using Content.Client.Disposal.Systems; using JetBrains.Annotations; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using static Content.Shared.Disposal.Components.SharedDisposalUnitComponent; namespace Content.Client.Disposal.UI @@ -52,7 +53,7 @@ namespace Content.Client.Disposal.UI Window?.UpdateState(cast); // Kinda icky but we just want client to handle its own lerping and not flood bandwidth for it. - if (!Owner.Owner.TryGetComponent(out DisposalUnitComponent? component)) return; + if (!IoCManager.Resolve().TryGetComponent(Owner.Owner.Uid, out DisposalUnitComponent? component)) return; component.UiState = cast; EntitySystem.Get().UpdateActive(component, true); diff --git a/Content.Client/DoAfter/UI/DoAfterGui.cs b/Content.Client/DoAfter/UI/DoAfterGui.cs index 1b7b2d4da9..ff11a7a64d 100644 --- a/Content.Client/DoAfter/UI/DoAfterGui.cs +++ b/Content.Client/DoAfter/UI/DoAfterGui.cs @@ -153,7 +153,7 @@ namespace Content.Client.DoAfter.UI } if (RETURNED_VALUE != true || - !AttachedEntity.TryGetComponent(out DoAfterComponent? doAfterComponent)) + !IoCManager.Resolve().TryGetComponent(AttachedEntity.Uid, out DoAfterComponent? doAfterComponent)) { Visible = false; return; diff --git a/Content.Client/DragDrop/DragDropSystem.cs b/Content.Client/DragDrop/DragDropSystem.cs index 317d36f422..e6991c2de4 100644 --- a/Content.Client/DragDrop/DragDropSystem.cs +++ b/Content.Client/DragDrop/DragDropSystem.cs @@ -183,7 +183,7 @@ namespace Content.Client.DragDrop return false; } - if (_dragDropHelper.Dragged.TryGetComponent(out var draggedSprite)) + if (IoCManager.Resolve().TryGetComponent(_dragDropHelper.Dragged.Uid, out var draggedSprite)) { // pop up drag shadow under mouse var mousePos = _eyeManager.ScreenToMap(_dragDropHelper.MouseScreenPosition); @@ -374,7 +374,7 @@ namespace Content.Client.DragDrop var pvsEntities = IoCManager.Resolve().GetEntitiesIntersecting(_eyeManager.CurrentMap, bounds, LookupFlags.Approximate | LookupFlags.IncludeAnchored); foreach (var pvsEntity in pvsEntities) { - if (!pvsEntity.TryGetComponent(out ISpriteComponent? inRangeSprite) || + if (!IoCManager.Resolve().TryGetComponent(pvsEntity.Uid, out ISpriteComponent? inRangeSprite) || !inRangeSprite.Visible || pvsEntity == _dragDropHelper.Dragged) continue; diff --git a/Content.Client/Examine/ExamineSystem.cs b/Content.Client/Examine/ExamineSystem.cs index a226d0b5a1..f11268172c 100644 --- a/Content.Client/Examine/ExamineSystem.cs +++ b/Content.Client/Examine/ExamineSystem.cs @@ -136,7 +136,7 @@ namespace Content.Client.Examine }; vBox.AddChild(hBox); - if (entity.TryGetComponent(out ISpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ISpriteComponent? sprite)) { hBox.AddChild(new SpriteView { Sprite = sprite, OverrideDirection = Direction.South }); } diff --git a/Content.Client/Ghost/GhostSystem.cs b/Content.Client/Ghost/GhostSystem.cs index 64f59c91cb..577a3e1a66 100644 --- a/Content.Client/Ghost/GhostSystem.cs +++ b/Content.Client/Ghost/GhostSystem.cs @@ -36,7 +36,7 @@ namespace Content.Client.Ghost foreach (var ghost in EntityManager.GetAllComponents(typeof(GhostComponent), true)) { - if (ghost.Owner.TryGetComponent(out SpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(ghost.Owner.Uid, out SpriteComponent? sprite)) { sprite.Visible = value; } @@ -60,7 +60,7 @@ namespace Content.Client.Ghost private void OnGhostInit(EntityUid uid, GhostComponent component, ComponentInit args) { - if (component.Owner.TryGetComponent(out SpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out SpriteComponent? sprite)) { sprite.Visible = GhostVisibility; } @@ -104,7 +104,7 @@ namespace Content.Client.Ghost var entity = _playerManager.LocalPlayer?.ControlledEntity; if (entity == null || - !entity.TryGetComponent(out GhostComponent? ghost)) + !IoCManager.Resolve().TryGetComponent(entity.Uid, out GhostComponent? ghost)) { return; } diff --git a/Content.Client/Gravity/GravityGeneratorVisualizer.cs b/Content.Client/Gravity/GravityGeneratorVisualizer.cs index a20b1042bd..622516bda9 100644 --- a/Content.Client/Gravity/GravityGeneratorVisualizer.cs +++ b/Content.Client/Gravity/GravityGeneratorVisualizer.cs @@ -42,7 +42,7 @@ namespace Content.Client.Gravity { base.InitializeEntity(entity); - if (!entity.TryGetComponent(out SpriteComponent? sprite)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out SpriteComponent? sprite)) return; sprite.LayerMapReserveBlank(GravityGeneratorVisualLayers.Base); diff --git a/Content.Client/Hands/HandsComponent.cs b/Content.Client/Hands/HandsComponent.cs index 5949b44316..ee24ba625d 100644 --- a/Content.Client/Hands/HandsComponent.cs +++ b/Content.Client/Hands/HandsComponent.cs @@ -1,6 +1,7 @@ using Content.Shared.Hands.Components; using Robust.Shared.Containers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Client.Hands { @@ -37,7 +38,7 @@ namespace Content.Client.Hands public void UpdateHandContainers() { - if (!Owner.TryGetComponent(out var containerMan)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out var containerMan)) return; foreach (var hand in Hands) diff --git a/Content.Client/Hands/Systems/HandsSystem.cs b/Content.Client/Hands/Systems/HandsSystem.cs index fc98ea8d1c..094704ef5e 100644 --- a/Content.Client/Hands/Systems/HandsSystem.cs +++ b/Content.Client/Hands/Systems/HandsSystem.cs @@ -89,7 +89,7 @@ namespace Content.Client.Hands { var player = _playerManager.LocalPlayer?.ControlledEntity; - if (player == null || !player.TryGetComponent(out HandsComponent? hands)) + if (player == null || !IoCManager.Resolve().TryGetComponent(player.Uid, out HandsComponent? hands)) return null; return hands; diff --git a/Content.Client/HealthOverlay/UI/HealthOverlayGui.cs b/Content.Client/HealthOverlay/UI/HealthOverlayGui.cs index 4fb76f3be8..c8657e37c6 100644 --- a/Content.Client/HealthOverlay/UI/HealthOverlayGui.cs +++ b/Content.Client/HealthOverlay/UI/HealthOverlayGui.cs @@ -77,8 +77,8 @@ namespace Content.Client.HealthOverlay.UI return; } - if (!Entity.TryGetComponent(out MobStateComponent? mobState) || - !Entity.TryGetComponent(out DamageableComponent? damageable)) + if (!IoCManager.Resolve().TryGetComponent(Entity.Uid, out MobStateComponent? mobState) || + !IoCManager.Resolve().TryGetComponent(Entity.Uid, out DamageableComponent? damageable)) { CritBar.Visible = false; HealthBar.Visible = false; diff --git a/Content.Client/IconSmoothing/IconSmoothSystem.cs b/Content.Client/IconSmoothing/IconSmoothSystem.cs index 3ad65b1727..35d0f72285 100644 --- a/Content.Client/IconSmoothing/IconSmoothSystem.cs +++ b/Content.Client/IconSmoothing/IconSmoothSystem.cs @@ -53,7 +53,7 @@ namespace Content.Client.IconSmoothing var senderEnt = ev.Sender; if (IoCManager.Resolve().EntityExists(senderEnt.Uid) && _mapManager.TryGetGrid(senderEnt.Transform.GridID, out var grid1) && - senderEnt.TryGetComponent(out IconSmoothComponent? iconSmooth) + IoCManager.Resolve().TryGetComponent(senderEnt.Uid, out IconSmoothComponent? iconSmooth) && iconSmooth.Running) { var coords = senderEnt.Transform.Coordinates; diff --git a/Content.Client/Instruments/UI/InstrumentBoundUserInterface.cs b/Content.Client/Instruments/UI/InstrumentBoundUserInterface.cs index 67bafc8e43..d9bf9d3eea 100644 --- a/Content.Client/Instruments/UI/InstrumentBoundUserInterface.cs +++ b/Content.Client/Instruments/UI/InstrumentBoundUserInterface.cs @@ -1,4 +1,6 @@ using Robust.Client.GameObjects; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.ViewVariables; namespace Content.Client.Instruments.UI @@ -16,7 +18,7 @@ namespace Content.Client.Instruments.UI protected override void Open() { - if (!Owner.Owner.TryGetComponent(out var instrument)) return; + if (!IoCManager.Resolve().TryGetComponent(Owner.Owner.Uid, out var instrument)) return; Instrument = instrument; _instrumentMenu = new InstrumentMenu(this); diff --git a/Content.Client/Interactable/Components/InteractionOutlineComponent.cs b/Content.Client/Interactable/Components/InteractionOutlineComponent.cs index f97b128ab3..f7329835e9 100644 --- a/Content.Client/Interactable/Components/InteractionOutlineComponent.cs +++ b/Content.Client/Interactable/Components/InteractionOutlineComponent.cs @@ -25,7 +25,7 @@ namespace Content.Client.Interactable.Components { _lastRenderScale = renderScale; _inRange = inInteractionRange; - if (Owner.TryGetComponent(out ISpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ISpriteComponent? sprite)) { sprite.PostShader = MakeNewShader(inInteractionRange, renderScale); sprite.RenderOrder = IoCManager.Resolve().CurrentTick.Value; @@ -34,7 +34,7 @@ namespace Content.Client.Interactable.Components public void OnMouseLeave() { - if (Owner.TryGetComponent(out ISpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ISpriteComponent? sprite)) { sprite.PostShader = null; sprite.RenderOrder = 0; @@ -46,7 +46,7 @@ namespace Content.Client.Interactable.Components public void UpdateInRange(bool inInteractionRange, int renderScale) { - if (Owner.TryGetComponent(out ISpriteComponent? sprite) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ISpriteComponent? sprite) && (inInteractionRange != _inRange || _lastRenderScale != renderScale)) { _inRange = inInteractionRange; diff --git a/Content.Client/Inventory/ClientInventoryComponent.cs b/Content.Client/Inventory/ClientInventoryComponent.cs index 45e6471fd9..03e0a110ba 100644 --- a/Content.Client/Inventory/ClientInventoryComponent.cs +++ b/Content.Client/Inventory/ClientInventoryComponent.cs @@ -140,7 +140,7 @@ namespace Content.Client.Inventory return; } - if (entity.TryGetComponent(out ClothingComponent? clothing)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ClothingComponent? clothing)) { var flag = SlotMasks[slot]; var data = clothing.GetEquippedStateInfo(flag, SpeciesId); diff --git a/Content.Client/Items/Components/ItemComponent.cs b/Content.Client/Items/Components/ItemComponent.cs index cd552ee288..4d04ba481b 100644 --- a/Content.Client/Items/Components/ItemComponent.cs +++ b/Content.Client/Items/Components/ItemComponent.cs @@ -2,6 +2,7 @@ using Content.Client.Hands; using Content.Shared.Item; using Robust.Shared.Containers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Client.Items.Components { @@ -14,7 +15,7 @@ namespace Content.Client.Items.Components if (!Owner.TryGetContainer(out var container)) return; - if (container.Owner.TryGetComponent(out HandsComponent? hands)) + if (IoCManager.Resolve().TryGetComponent(container.Owner.Uid, out HandsComponent? hands)) hands.UpdateHandVisualizer(); } } diff --git a/Content.Client/Items/Managers/ItemSlotManager.cs b/Content.Client/Items/Managers/ItemSlotManager.cs index 76d7dce9b6..4f2fa0b0a3 100644 --- a/Content.Client/Items/Managers/ItemSlotManager.cs +++ b/Content.Client/Items/Managers/ItemSlotManager.cs @@ -42,12 +42,12 @@ namespace Content.Client.Items.Managers else { ISpriteComponent? sprite; - if (entity.TryGetComponent(out HandVirtualItemComponent? virtPull) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out HandVirtualItemComponent? virtPull) && _entityManager.TryGetComponent(virtPull.BlockingEntity, out ISpriteComponent pulledSprite)) { sprite = pulledSprite; } - else if (!entity.TryGetComponent(out sprite)) + else if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out sprite)) { return false; } @@ -105,7 +105,7 @@ namespace Content.Client.Items.Managers if (entity == null || (!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || - !entity.TryGetComponent(out ItemCooldownComponent? cooldown) || + !IoCManager.Resolve().TryGetComponent(entity.Uid, out ItemCooldownComponent? cooldown) || !cooldown.CooldownStart.HasValue || !cooldown.CooldownEnd.HasValue) { diff --git a/Content.Client/Items/UI/ItemStatusPanel.cs b/Content.Client/Items/UI/ItemStatusPanel.cs index 8afa76be4d..8d1dcd0ba2 100644 --- a/Content.Client/Items/UI/ItemStatusPanel.cs +++ b/Content.Client/Items/UI/ItemStatusPanel.cs @@ -156,7 +156,7 @@ namespace Content.Client.Items.UI if (_entity == null) return; - if (_entity.TryGetComponent(out HandVirtualItemComponent? virtualItem) + if (IoCManager.Resolve().TryGetComponent(_entity.Uid, out HandVirtualItemComponent? virtualItem) && _entityManager.TryGetEntity(virtualItem.BlockingEntity, out var blockEnt)) { _itemNameLabel.Text = blockEnt.Name; diff --git a/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs b/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs index 805c647233..ad3b129daa 100644 --- a/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs +++ b/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs @@ -121,11 +121,11 @@ namespace Content.Client.Kitchen.UI } Texture? texture; - if (entity.TryGetComponent(out IconComponent? iconComponent)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out IconComponent? iconComponent)) { texture = iconComponent.Icon?.Default; } - else if (entity.TryGetComponent(out SpriteComponent? spriteComponent)) + else if (IoCManager.Resolve().TryGetComponent(entity.Uid, out SpriteComponent? spriteComponent)) { texture = spriteComponent.Icon?.Default; } diff --git a/Content.Client/Lathe/UI/LatheBoundUserInterface.cs b/Content.Client/Lathe/UI/LatheBoundUserInterface.cs index 54b21e13d3..0af7cae5d5 100644 --- a/Content.Client/Lathe/UI/LatheBoundUserInterface.cs +++ b/Content.Client/Lathe/UI/LatheBoundUserInterface.cs @@ -37,9 +37,9 @@ namespace Content.Client.Lathe.UI { base.Open(); - if (!Owner.Owner.TryGetComponent(out MaterialStorageComponent? storage) - || !Owner.Owner.TryGetComponent(out SharedLatheComponent? lathe) - || !Owner.Owner.TryGetComponent(out SharedLatheDatabaseComponent? database)) return; + if (!IoCManager.Resolve().TryGetComponent(Owner.Owner.Uid, out MaterialStorageComponent? storage) + || !IoCManager.Resolve().TryGetComponent(Owner.Owner.Uid, out SharedLatheComponent? lathe) + || !IoCManager.Resolve().TryGetComponent(Owner.Owner.Uid, out SharedLatheDatabaseComponent? database)) return; Storage = storage; Lathe = lathe; diff --git a/Content.Client/Light/Components/LightBehaviourComponent.cs b/Content.Client/Light/Components/LightBehaviourComponent.cs index 6ef0920830..62b0e4cea5 100644 --- a/Content.Client/Light/Components/LightBehaviourComponent.cs +++ b/Content.Client/Light/Components/LightBehaviourComponent.cs @@ -58,7 +58,7 @@ namespace Content.Client.Light.Components _random = random; _parent = parent; - if (Enabled && _parent.TryGetComponent(out PointLightComponent? light)) + if (Enabled && IoCManager.Resolve().TryGetComponent(_parent.Uid, out PointLightComponent? light)) { light.Enabled = true; } @@ -68,7 +68,7 @@ namespace Content.Client.Light.Components public void UpdatePlaybackValues(Animation owner) { - if (_parent.TryGetComponent(out PointLightComponent? light)) + if (IoCManager.Resolve().TryGetComponent(_parent.Uid, out PointLightComponent? light)) { light.Enabled = true; } @@ -99,7 +99,7 @@ namespace Content.Client.Light.Components throw new InvalidOperationException("Property parameter is null! Check the prototype!"); } - if (_parent.TryGetComponent(out PointLightComponent? light)) + if (IoCManager.Resolve().TryGetComponent(_parent.Uid, out PointLightComponent? light)) { AnimationHelper.SetAnimatableProperty(light, Property, value); } @@ -395,7 +395,7 @@ namespace Content.Client.Light.Components // TODO: Do NOT ensure component here. And use eventbus events instead... Owner.EnsureComponent(); - if (Owner.TryGetComponent(out AnimationPlayerComponent? animation)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AnimationPlayerComponent? animation)) { #pragma warning disable 618 animation.AnimationCompleted += OnAnimationCompleted; @@ -430,7 +430,7 @@ namespace Content.Client.Light.Components { container.LightBehaviour.UpdatePlaybackValues(container.Animation); - if (Owner.TryGetComponent(out AnimationPlayerComponent? animation)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AnimationPlayerComponent? animation)) { animation.Play(container.Animation, container.FullKey); } @@ -442,7 +442,7 @@ namespace Content.Client.Light.Components /// private void CopyLightSettings() { - if (Owner.TryGetComponent(out PointLightComponent? light)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out PointLightComponent? light)) { _originalColor = light.Color; _originalEnabled = light.Enabled; @@ -463,7 +463,7 @@ namespace Content.Client.Light.Components /// public void StartLightBehaviour(string id = "") { - if (!Owner.TryGetComponent(out AnimationPlayerComponent? animation)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out AnimationPlayerComponent? animation)) { return; } @@ -491,7 +491,7 @@ namespace Content.Client.Light.Components /// Should the light have its original settings applied? public void StopLightBehaviour(string id = "", bool removeBehaviour = false, bool resetToOriginalSettings = false) { - if (!Owner.TryGetComponent(out AnimationPlayerComponent? animation)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out AnimationPlayerComponent? animation)) { return; } @@ -519,7 +519,7 @@ namespace Content.Client.Light.Components _animations.Remove(container); } - if (resetToOriginalSettings && Owner.TryGetComponent(out PointLightComponent? light)) + if (resetToOriginalSettings && IoCManager.Resolve().TryGetComponent(Owner.Uid, out PointLightComponent? light)) { light.Color = _originalColor; light.Enabled = _originalEnabled; diff --git a/Content.Client/MachineLinking/SignalSwitchVisualizer.cs b/Content.Client/MachineLinking/SignalSwitchVisualizer.cs index fee7370451..c86d95a650 100644 --- a/Content.Client/MachineLinking/SignalSwitchVisualizer.cs +++ b/Content.Client/MachineLinking/SignalSwitchVisualizer.cs @@ -2,6 +2,7 @@ using JetBrains.Annotations; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Client.MachineLinking @@ -16,7 +17,7 @@ namespace Content.Client.MachineLinking { base.InitializeEntity(entity); - if (entity.TryGetComponent(out SpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out SpriteComponent? sprite)) { sprite.LayerMapReserveBlank(Layer); } diff --git a/Content.Client/Markers/MarkerComponent.cs b/Content.Client/Markers/MarkerComponent.cs index ff75539928..19cc4ed824 100644 --- a/Content.Client/Markers/MarkerComponent.cs +++ b/Content.Client/Markers/MarkerComponent.cs @@ -1,5 +1,6 @@ using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Client.Markers { @@ -19,7 +20,7 @@ namespace Content.Client.Markers { var system = EntitySystem.Get(); - if (Owner.TryGetComponent(out ISpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ISpriteComponent? sprite)) { sprite.Visible = system.MarkersVisible; } diff --git a/Content.Client/MobState/Overlays/CritOverlay.cs b/Content.Client/MobState/Overlays/CritOverlay.cs index 3813e7e69f..0c802081cb 100644 --- a/Content.Client/MobState/Overlays/CritOverlay.cs +++ b/Content.Client/MobState/Overlays/CritOverlay.cs @@ -2,6 +2,7 @@ using Content.Shared.MobState.Components; using Robust.Client.Graphics; using Robust.Client.Player; using Robust.Shared.Enums; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Maths; using Robust.Shared.Prototypes; @@ -31,7 +32,7 @@ namespace Content.Client.MobState.Overlays return false; } - if (playerEntity.TryGetComponent(out var mobState)) + if (IoCManager.Resolve().TryGetComponent(playerEntity.Uid, out var mobState)) { if (critical) if (mobState.IsCritical()) diff --git a/Content.Client/ParticleAccelerator/ParticleAcceleratorPartVisualizer.cs b/Content.Client/ParticleAccelerator/ParticleAcceleratorPartVisualizer.cs index 3d5fa2c935..fb9b7ee3f1 100644 --- a/Content.Client/ParticleAccelerator/ParticleAcceleratorPartVisualizer.cs +++ b/Content.Client/ParticleAccelerator/ParticleAcceleratorPartVisualizer.cs @@ -4,6 +4,7 @@ using Content.Shared.Singularity.Components; using JetBrains.Annotations; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization; using Robust.Shared.Serialization.Manager.Attributes; @@ -35,7 +36,7 @@ namespace Content.Client.ParticleAccelerator public override void InitializeEntity(IEntity entity) { base.InitializeEntity(entity); - if (!entity.TryGetComponent(out var sprite)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out var sprite)) { throw new EntityCreationException("No sprite component found in entity that has ParticleAcceleratorPartVisualizer"); } diff --git a/Content.Client/Physics/Controllers/MoverController.cs b/Content.Client/Physics/Controllers/MoverController.cs index 2f61d90b1e..1a6f9f9ccd 100644 --- a/Content.Client/Physics/Controllers/MoverController.cs +++ b/Content.Client/Physics/Controllers/MoverController.cs @@ -19,8 +19,8 @@ namespace Content.Client.Physics.Controllers var player = _playerManager.LocalPlayer?.ControlledEntity; if (player == null || - !player.TryGetComponent(out IMoverComponent? mover) || - !player.TryGetComponent(out PhysicsComponent? body)) return; + !IoCManager.Resolve().TryGetComponent(player.Uid, out IMoverComponent? mover) || + !IoCManager.Resolve().TryGetComponent(player.Uid, out PhysicsComponent? body)) return; // Essentially we only want to set our mob to predicted so every other entity we just interpolate // (i.e. only see what the server has sent us). @@ -30,7 +30,7 @@ namespace Content.Client.Physics.Controllers // We set joints to predicted given these can affect how our mob moves. // I would only recommend disabling this if you make pulling not use joints anymore (someday maybe?) - if (player.TryGetComponent(out JointComponent? jointComponent)) + if (IoCManager.Resolve().TryGetComponent(player.Uid, out JointComponent? jointComponent)) { foreach (var joint in jointComponent.GetJoints) { @@ -40,10 +40,10 @@ namespace Content.Client.Physics.Controllers } // If we're being pulled then we won't predict anything and will receive server lerps so it looks way smoother. - if (player.TryGetComponent(out SharedPullableComponent? pullableComp)) + if (IoCManager.Resolve().TryGetComponent(player.Uid, out SharedPullableComponent? pullableComp)) { var puller = pullableComp.Puller; - if (puller != null && puller.TryGetComponent(out var pullerBody)) + if (puller != null && IoCManager.Resolve().TryGetComponent(puller.Uid, out var pullerBody)) { pullerBody.Predict = false; body.Predict = false; @@ -51,20 +51,20 @@ namespace Content.Client.Physics.Controllers } // If we're pulling a mob then make sure that isn't predicted so it doesn't fuck our velocity up. - if (player.TryGetComponent(out SharedPullerComponent? pullerComp)) + if (IoCManager.Resolve().TryGetComponent(player.Uid, out SharedPullerComponent? pullerComp)) { var pulling = pullerComp.Pulling; if (pulling != null && IoCManager.Resolve().HasComponent(pulling.Uid) && - pulling.TryGetComponent(out PhysicsComponent? pullingBody)) + IoCManager.Resolve().TryGetComponent(pulling.Uid, out PhysicsComponent? pullingBody)) { pullingBody.Predict = false; } } // Server-side should just be handled on its own so we'll just do this shizznit - if (player.TryGetComponent(out IMobMoverComponent? mobMover)) + if (IoCManager.Resolve().TryGetComponent(player.Uid, out IMobMoverComponent? mobMover)) { HandleMobMovement(mover, body, mobMover); return; diff --git a/Content.Client/Pointing/Components/PointingArrowComponent.cs b/Content.Client/Pointing/Components/PointingArrowComponent.cs index 4be2892b38..11916b80b7 100644 --- a/Content.Client/Pointing/Components/PointingArrowComponent.cs +++ b/Content.Client/Pointing/Components/PointingArrowComponent.cs @@ -1,6 +1,7 @@ using Content.Shared.Pointing.Components; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using DrawDepth = Content.Shared.DrawDepth.DrawDepth; namespace Content.Client.Pointing.Components @@ -12,7 +13,7 @@ namespace Content.Client.Pointing.Components { base.Startup(); - if (Owner.TryGetComponent(out SpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out SpriteComponent? sprite)) { sprite.DrawDepth = (int) DrawDepth.Overlays; } diff --git a/Content.Client/Pointing/Components/RoguePointingArrowComponent.cs b/Content.Client/Pointing/Components/RoguePointingArrowComponent.cs index 976505c7ad..782042c160 100644 --- a/Content.Client/Pointing/Components/RoguePointingArrowComponent.cs +++ b/Content.Client/Pointing/Components/RoguePointingArrowComponent.cs @@ -1,6 +1,7 @@ using Content.Shared.Pointing.Components; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using DrawDepth = Content.Shared.DrawDepth.DrawDepth; namespace Content.Client.Pointing.Components @@ -12,7 +13,7 @@ namespace Content.Client.Pointing.Components { base.Startup(); - if (Owner.TryGetComponent(out SpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out SpriteComponent? sprite)) { sprite.DrawDepth = (int) DrawDepth.Overlays; } diff --git a/Content.Client/Pointing/RoguePointingArrowVisualizer.cs b/Content.Client/Pointing/RoguePointingArrowVisualizer.cs index 9eb17c8f75..c5a974fff4 100644 --- a/Content.Client/Pointing/RoguePointingArrowVisualizer.cs +++ b/Content.Client/Pointing/RoguePointingArrowVisualizer.cs @@ -27,7 +27,7 @@ namespace Content.Client.Pointing { var sprite = IoCManager.Resolve().GetComponent(component.Owner.Uid); - if (!sprite.Owner.TryGetComponent(out AnimationPlayerComponent? animation)) + if (!IoCManager.Resolve().TryGetComponent(sprite.Owner.Uid, out AnimationPlayerComponent? animation)) { sprite.Rotation = rotation; return; diff --git a/Content.Client/Recycling/RecyclerVisualizer.cs b/Content.Client/Recycling/RecyclerVisualizer.cs index 5d584582d8..96cb5802fd 100644 --- a/Content.Client/Recycling/RecyclerVisualizer.cs +++ b/Content.Client/Recycling/RecyclerVisualizer.cs @@ -3,6 +3,7 @@ using Content.Shared.Recycling; using JetBrains.Annotations; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Client.Recycling @@ -20,8 +21,8 @@ namespace Content.Client.Recycling { base.InitializeEntity(entity); - if (!entity.TryGetComponent(out ISpriteComponent? sprite) || - !entity.TryGetComponent(out AppearanceComponent? appearance)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out ISpriteComponent? sprite) || + !IoCManager.Resolve().TryGetComponent(entity.Uid, out AppearanceComponent? appearance)) { return; } diff --git a/Content.Client/Research/UI/ResearchConsoleBoundUserInterface.cs b/Content.Client/Research/UI/ResearchConsoleBoundUserInterface.cs index 0fcd499e40..7fb900bdaf 100644 --- a/Content.Client/Research/UI/ResearchConsoleBoundUserInterface.cs +++ b/Content.Client/Research/UI/ResearchConsoleBoundUserInterface.cs @@ -2,6 +2,7 @@ using Content.Shared.Research.Prototypes; using JetBrains.Annotations; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using static Content.Shared.Research.Components.SharedResearchConsoleComponent; namespace Content.Client.Research.UI @@ -23,7 +24,7 @@ namespace Content.Client.Research.UI { base.Open(); - if (!Owner.Owner.TryGetComponent(out _technologyDatabase)) return; + if (!IoCManager.Resolve().TryGetComponent(Owner.Owner.Uid, out _technologyDatabase)) return; _consoleMenu = new ResearchConsoleMenu(this); diff --git a/Content.Client/Rotation/RotationVisualizer.cs b/Content.Client/Rotation/RotationVisualizer.cs index 1105f16763..faba72e7b3 100644 --- a/Content.Client/Rotation/RotationVisualizer.cs +++ b/Content.Client/Rotation/RotationVisualizer.cs @@ -35,7 +35,7 @@ namespace Content.Client.Rotation { var sprite = IoCManager.Resolve().GetComponent(component.Owner.Uid); - if (!sprite.Owner.TryGetComponent(out AnimationPlayerComponent? animation)) + if (!IoCManager.Resolve().TryGetComponent(sprite.Owner.Uid, out AnimationPlayerComponent? animation)) { sprite.Rotation = rotation; return; diff --git a/Content.Client/Singularity/Components/ContainmentFieldComponent.cs b/Content.Client/Singularity/Components/ContainmentFieldComponent.cs index ea6afc64ef..a3bd3f4a5b 100644 --- a/Content.Client/Singularity/Components/ContainmentFieldComponent.cs +++ b/Content.Client/Singularity/Components/ContainmentFieldComponent.cs @@ -1,6 +1,7 @@ using Content.Shared.Singularity.Components; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Log; namespace Content.Client.Singularity.Components @@ -17,7 +18,7 @@ namespace Content.Client.Singularity.Components { base.Initialize(); - if (!Owner.TryGetComponent(out _spriteComponent)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out _spriteComponent)) { Logger.Error($"{nameof(ContainmentFieldComponent)} created without {nameof(SpriteComponent)}"); } diff --git a/Content.Client/Singularity/SingularityOverlay.cs b/Content.Client/Singularity/SingularityOverlay.cs index 020dfb93c9..b4a057d02d 100644 --- a/Content.Client/Singularity/SingularityOverlay.cs +++ b/Content.Client/Singularity/SingularityOverlay.cs @@ -95,7 +95,7 @@ namespace Content.Client.Singularity } else { - if (!singuloEntity.TryGetComponent(out var distortion)) + if (!IoCManager.Resolve().TryGetComponent(singuloEntity.Uid, out var distortion)) { _singularities.Remove(activeSinguloUid); } diff --git a/Content.Client/Stack/StackVisualizer.cs b/Content.Client/Stack/StackVisualizer.cs index 092e81f5bd..d0e06cb312 100644 --- a/Content.Client/Stack/StackVisualizer.cs +++ b/Content.Client/Stack/StackVisualizer.cs @@ -5,6 +5,7 @@ using Content.Shared.Stacks; using JetBrains.Annotations; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Utility; @@ -83,7 +84,7 @@ namespace Content.Client.Stack if (_isComposite && _spriteLayers.Count > 0 - && entity.TryGetComponent(out var spriteComponent)) + && IoCManager.Resolve().TryGetComponent(entity.Uid, out var spriteComponent)) { var spritePath = _spritePath ?? spriteComponent.BaseRSI!.Path!; diff --git a/Content.Client/StationEvents/RadiationPulseOverlay.cs b/Content.Client/StationEvents/RadiationPulseOverlay.cs index 6bef4d2dd6..4b707d3ee2 100644 --- a/Content.Client/StationEvents/RadiationPulseOverlay.cs +++ b/Content.Client/StationEvents/RadiationPulseOverlay.cs @@ -108,7 +108,7 @@ namespace Content.Client.StationEvents { if (_entityManager.TryGetEntity(activePulseUid, out var pulseEntity) && PulseQualifies(pulseEntity, currentEyeLoc) && - pulseEntity.TryGetComponent(out var pulse)) + IoCManager.Resolve().TryGetComponent(pulseEntity.Uid, out var pulse)) { var shaderInstance = _pulses[activePulseUid]; shaderInstance.instance.CurrentMapCoords = pulseEntity.Transform.MapPosition.Position; diff --git a/Content.Client/Storage/Visualizers/BagOpenCloseVisualizer.cs b/Content.Client/Storage/Visualizers/BagOpenCloseVisualizer.cs index 363c6cf061..5f2c3016d7 100644 --- a/Content.Client/Storage/Visualizers/BagOpenCloseVisualizer.cs +++ b/Content.Client/Storage/Visualizers/BagOpenCloseVisualizer.cs @@ -5,6 +5,7 @@ using Content.Shared.Storage.Components; using JetBrains.Annotations; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Log; using Robust.Shared.Serialization; using Robust.Shared.Serialization.Manager.Attributes; @@ -31,7 +32,7 @@ namespace Content.Client.Storage.Visualizers base.InitializeEntity(entity); if (_openIcon != null && - entity.TryGetComponent(out var spriteComponent) && + IoCManager.Resolve().TryGetComponent(entity.Uid, out var spriteComponent) && spriteComponent.BaseRSI?.Path != null) { spriteComponent.LayerMapReserveBlank(OpenIcon); diff --git a/Content.Client/Suspicion/SuspicionGui.xaml.cs b/Content.Client/Suspicion/SuspicionGui.xaml.cs index 064fcebe2b..fe78715743 100644 --- a/Content.Client/Suspicion/SuspicionGui.xaml.cs +++ b/Content.Client/Suspicion/SuspicionGui.xaml.cs @@ -65,7 +65,7 @@ namespace Content.Client.Suspicion return false; } - return _playerManager.LocalPlayer.ControlledEntity.TryGetComponent(out suspicion); + return IoCManager.Resolve().TryGetComponent(_playerManager.LocalPlayer.ControlledEntity.Uid, out suspicion); } public void UpdateLabel() diff --git a/Content.Client/Suspicion/TraitorOverlay.cs b/Content.Client/Suspicion/TraitorOverlay.cs index 9646a42dfe..e5a1318e23 100644 --- a/Content.Client/Suspicion/TraitorOverlay.cs +++ b/Content.Client/Suspicion/TraitorOverlay.cs @@ -41,7 +41,7 @@ namespace Content.Client.Suspicion var viewport = _eyeManager.GetWorldViewport(); var ent = _playerManager.LocalPlayer?.ControlledEntity; - if (ent == null || ent.TryGetComponent(out SuspicionRoleComponent? sus) != true) + if (ent == null || IoCManager.Resolve().TryGetComponent(ent.Uid, out SuspicionRoleComponent? sus) != true) { return; } @@ -54,7 +54,7 @@ namespace Content.Client.Suspicion continue; } - if (!ally.TryGetComponent(out IPhysBody? physics)) + if (!IoCManager.Resolve().TryGetComponent(ally.Uid, out IPhysBody? physics)) { continue; } diff --git a/Content.Client/VendingMachines/VendingMachineBoundUserInterface.cs b/Content.Client/VendingMachines/VendingMachineBoundUserInterface.cs index c2119c39f9..156d2d09fe 100644 --- a/Content.Client/VendingMachines/VendingMachineBoundUserInterface.cs +++ b/Content.Client/VendingMachines/VendingMachineBoundUserInterface.cs @@ -2,6 +2,7 @@ using Content.Shared.VendingMachines; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.ViewVariables; using static Content.Shared.VendingMachines.SharedVendingMachineComponent; @@ -22,7 +23,7 @@ namespace Content.Client.VendingMachines { base.Open(); - if (!Owner.Owner.TryGetComponent(out SharedVendingMachineComponent? vendingMachine)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Owner.Uid, out SharedVendingMachineComponent? vendingMachine)) { return; } diff --git a/Content.Client/Viewport/GameScreenBase.cs b/Content.Client/Viewport/GameScreenBase.cs index bdfde55710..571ebcb20f 100644 --- a/Content.Client/Viewport/GameScreenBase.cs +++ b/Content.Client/Viewport/GameScreenBase.cs @@ -115,7 +115,7 @@ namespace Content.Client.Viewport InteractionOutlineComponent? outline; if(!_outlineEnabled || !ConfigurationManager.GetCVar(CCVars.OutlineEnabled)) { - if(entityToClick != null && entityToClick.TryGetComponent(out outline)) + if(entityToClick != null && IoCManager.Resolve().TryGetComponent(entityToClick.Uid, out outline)) { outline.OnMouseLeave(); //Prevent outline remains from persisting post command. } @@ -124,7 +124,7 @@ namespace Content.Client.Viewport if (entityToClick == _lastHoveredEntity) { - if (entityToClick != null && entityToClick.TryGetComponent(out outline)) + if (entityToClick != null && IoCManager.Resolve().TryGetComponent(entityToClick.Uid, out outline)) { outline.UpdateInRange(inRange, renderScale); } @@ -133,14 +133,14 @@ namespace Content.Client.Viewport } if (_lastHoveredEntity != null && !((!IoCManager.Resolve().EntityExists(_lastHoveredEntity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(_lastHoveredEntity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) && - _lastHoveredEntity.TryGetComponent(out outline)) + IoCManager.Resolve().TryGetComponent(_lastHoveredEntity.Uid, out outline)) { outline.OnMouseLeave(); } _lastHoveredEntity = entityToClick; - if (_lastHoveredEntity != null && _lastHoveredEntity.TryGetComponent(out outline)) + if (_lastHoveredEntity != null && IoCManager.Resolve().TryGetComponent(_lastHoveredEntity.Uid, out outline)) { outline.OnMouseEnter(inRange, renderScale); } @@ -167,7 +167,7 @@ namespace Content.Client.Viewport var foundEntities = new List<(IEntity clicked, int drawDepth, uint renderOrder)>(); foreach (var entity in entities) { - if (entity.TryGetComponent(out var component) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out var component) && !entity.IsInContainer() && component.CheckClick(coordinates.Position, out var drawDepthClicked, out var renderOrder)) { diff --git a/Content.Client/Weapons/Melee/Components/MeleeLungeComponent.cs b/Content.Client/Weapons/Melee/Components/MeleeLungeComponent.cs index f902cdedf2..0b26421fb0 100644 --- a/Content.Client/Weapons/Melee/Components/MeleeLungeComponent.cs +++ b/Content.Client/Weapons/Melee/Components/MeleeLungeComponent.cs @@ -39,7 +39,7 @@ namespace Content.Client.Weapons.Melee.Components offset *= (ResetTime - _time) / ResetTime; } - if (Owner.TryGetComponent(out ISpriteComponent? spriteComponent)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ISpriteComponent? spriteComponent)) { spriteComponent.Offset = offset; } diff --git a/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs b/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs index 4f725949f2..c5e7e0e2eb 100644 --- a/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs +++ b/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs @@ -65,7 +65,7 @@ namespace Content.Client.Weapons.Melee // Due to ISpriteComponent limitations, weapons that don't use an RSI won't have this effect. if (EntityManager.TryGetEntity(msg.Source, out var source) && msg.TextureEffect && - source.TryGetComponent(out ISpriteComponent? sourceSprite) && + IoCManager.Resolve().TryGetComponent(source.Uid, out ISpriteComponent? sourceSprite) && sourceSprite.BaseRSI?.Path != null) { var curTime = _gameTiming.CurTime; @@ -93,7 +93,7 @@ namespace Content.Client.Weapons.Melee continue; } - if (!hitEntity.TryGetComponent(out ISpriteComponent? sprite)) + if (!IoCManager.Resolve().TryGetComponent(hitEntity.Uid, out ISpriteComponent? sprite)) { continue; } diff --git a/Content.Client/Weapons/Ranged/RangedWeaponSystem.cs b/Content.Client/Weapons/Ranged/RangedWeaponSystem.cs index 38ffb63802..43d363bb21 100644 --- a/Content.Client/Weapons/Ranged/RangedWeaponSystem.cs +++ b/Content.Client/Weapons/Ranged/RangedWeaponSystem.cs @@ -48,12 +48,12 @@ namespace Content.Client.Weapons.Ranged } var entity = _playerManager.LocalPlayer?.ControlledEntity; - if (entity == null || !entity.TryGetComponent(out SharedHandsComponent? hands)) + if (entity == null || !IoCManager.Resolve().TryGetComponent(entity.Uid, out SharedHandsComponent? hands)) { return; } - if (!hands.TryGetActiveHeldEntity(out var held) || !held.TryGetComponent(out ClientRangedWeaponComponent? weapon)) + if (!hands.TryGetActiveHeldEntity(out var held) || !IoCManager.Resolve().TryGetComponent(held.Uid, out ClientRangedWeaponComponent? weapon)) { _blocked = true; return; diff --git a/Content.IntegrationTests/Tests/Body/LegTest.cs b/Content.IntegrationTests/Tests/Body/LegTest.cs index 1c4dd56790..e68e608e46 100644 --- a/Content.IntegrationTests/Tests/Body/LegTest.cs +++ b/Content.IntegrationTests/Tests/Body/LegTest.cs @@ -48,8 +48,8 @@ namespace Content.IntegrationTests.Tests.Body var entityManager = IoCManager.Resolve(); var human = entityManager.SpawnEntity("HumanBodyAndAppearanceDummy", new MapCoordinates(Vector2.Zero, mapId)); - Assert.That(human.TryGetComponent(out SharedBodyComponent body)); - Assert.That(human.TryGetComponent(out appearance)); + Assert.That(IoCManager.Resolve().TryGetComponent(human.Uid, out SharedBodyComponent body)); + Assert.That(IoCManager.Resolve().TryGetComponent(human.Uid, out appearance)); Assert.That(!appearance.TryGetData(RotationVisuals.RotationState, out RotationState _)); diff --git a/Content.IntegrationTests/Tests/Body/LungTest.cs b/Content.IntegrationTests/Tests/Body/LungTest.cs index 40721196a7..9c3444bc5c 100644 --- a/Content.IntegrationTests/Tests/Body/LungTest.cs +++ b/Content.IntegrationTests/Tests/Body/LungTest.cs @@ -66,11 +66,11 @@ namespace Content.IntegrationTests.Tests.Body var bodySys = EntitySystem.Get(); var lungSys = EntitySystem.Get(); - Assert.That(human.TryGetComponent(out SharedBodyComponent body)); + Assert.That(IoCManager.Resolve().TryGetComponent(human.Uid, out SharedBodyComponent body)); var lungs = bodySys.GetComponentsOnMechanisms(human.Uid, body).ToArray(); Assert.That(lungs.Count, Is.EqualTo(1)); - Assert.That(human.TryGetComponent(out BloodstreamComponent bloodstream)); + Assert.That(IoCManager.Resolve().TryGetComponent(human.Uid, out BloodstreamComponent bloodstream)); var gas = new GasMixture(1); @@ -172,7 +172,7 @@ namespace Content.IntegrationTests.Tests.Body human = entityManager.SpawnEntity("HumanBodyAndBloodstreamDummy", coordinates); Assert.True(IoCManager.Resolve().HasComponent(human.Uid)); - Assert.True(human.TryGetComponent(out respirator)); + Assert.True(IoCManager.Resolve().TryGetComponent(human.Uid, out respirator)); Assert.False(respirator.Suffocating); }); diff --git a/Content.IntegrationTests/Tests/DeviceNetwork/DeviceNetworkTest.cs b/Content.IntegrationTests/Tests/DeviceNetwork/DeviceNetworkTest.cs index a873978f82..4f75bcc9ca 100644 --- a/Content.IntegrationTests/Tests/DeviceNetwork/DeviceNetworkTest.cs +++ b/Content.IntegrationTests/Tests/DeviceNetwork/DeviceNetworkTest.cs @@ -82,13 +82,13 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork device1 = entityManager.SpawnEntity("DummyNetworkDevice", MapCoordinates.Nullspace); - Assert.That(device1.TryGetComponent(out networkComponent1), Is.True); + Assert.That(IoCManager.Resolve().TryGetComponent(device1.Uid, out networkComponent1), Is.True); Assert.That(networkComponent1.Open, Is.True); Assert.That(networkComponent1.Address, Is.Not.EqualTo(string.Empty)); device2 = entityManager.SpawnEntity("DummyNetworkDevice", MapCoordinates.Nullspace); - Assert.That(device2.TryGetComponent(out networkComponent2), Is.True); + Assert.That(IoCManager.Resolve().TryGetComponent(device2.Uid, out networkComponent2), Is.True); Assert.That(networkComponent2.Open, Is.True); Assert.That(networkComponent2.Address, Is.Not.EqualTo(string.Empty)); @@ -145,14 +145,14 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork device1 = entityManager.SpawnEntity("DummyWirelessNetworkDevice", MapCoordinates.Nullspace); - Assert.That(device1.TryGetComponent(out networkComponent1), Is.True); - Assert.That(device1.TryGetComponent(out wirelessNetworkComponent), Is.True); + Assert.That(IoCManager.Resolve().TryGetComponent(device1.Uid, out networkComponent1), Is.True); + Assert.That(IoCManager.Resolve().TryGetComponent(device1.Uid, out wirelessNetworkComponent), Is.True); Assert.That(networkComponent1.Open, Is.True); Assert.That(networkComponent1.Address, Is.Not.EqualTo(string.Empty)); device2 = entityManager.SpawnEntity("DummyWirelessNetworkDevice", new MapCoordinates(new Robust.Shared.Maths.Vector2(0,50), MapId.Nullspace)); - Assert.That(device2.TryGetComponent(out networkComponent2), Is.True); + Assert.That(IoCManager.Resolve().TryGetComponent(device2.Uid, out networkComponent2), Is.True); Assert.That(networkComponent2.Open, Is.True); Assert.That(networkComponent2.Address, Is.Not.EqualTo(string.Empty)); @@ -232,14 +232,14 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork device1 = entityManager.SpawnEntity("DummyWiredNetworkDevice", MapCoordinates.Nullspace); - Assert.That(device1.TryGetComponent(out networkComponent1), Is.True); - Assert.That(device1.TryGetComponent(out wiredNetworkComponent), Is.True); + Assert.That(IoCManager.Resolve().TryGetComponent(device1.Uid, out networkComponent1), Is.True); + Assert.That(IoCManager.Resolve().TryGetComponent(device1.Uid, out wiredNetworkComponent), Is.True); Assert.That(networkComponent1.Open, Is.True); Assert.That(networkComponent1.Address, Is.Not.EqualTo(string.Empty)); device2 = entityManager.SpawnEntity("DummyWiredNetworkDevice", new MapCoordinates(new Robust.Shared.Maths.Vector2(0, 2), MapId.Nullspace)); - Assert.That(device2.TryGetComponent(out networkComponent2), Is.True); + Assert.That(IoCManager.Resolve().TryGetComponent(device2.Uid, out networkComponent2), Is.True); Assert.That(networkComponent2.Open, Is.True); Assert.That(networkComponent2.Address, Is.Not.EqualTo(string.Empty)); diff --git a/Content.IntegrationTests/Tests/Disposal/DisposalUnitTest.cs b/Content.IntegrationTests/Tests/Disposal/DisposalUnitTest.cs index 6765d2c6c8..35dbe06d7f 100644 --- a/Content.IntegrationTests/Tests/Disposal/DisposalUnitTest.cs +++ b/Content.IntegrationTests/Tests/Disposal/DisposalUnitTest.cs @@ -146,7 +146,8 @@ namespace Content.IntegrationTests.Tests.Disposal disposalTrunk = entityManager.SpawnEntity("DisposalTrunkDummy", disposalUnit.Transform.MapPosition); // Test for components existing - Assert.True(disposalUnit.TryGetComponent(out unit!)); + ref DisposalUnitComponent? comp = ref unit!; + Assert.True(IoCManager.Resolve().TryGetComponent(disposalUnit.Uid, out comp)); Assert.True(IoCManager.Resolve().HasComponent(disposalTrunk.Uid)); // Can't insert, unanchored and unpowered @@ -190,7 +191,7 @@ namespace Content.IntegrationTests.Tests.Disposal await server.WaitAssertion(() => { // Remove power need - Assert.True(disposalUnit.TryGetComponent(out ApcPowerReceiverComponent power)); + Assert.True(IoCManager.Resolve().TryGetComponent(disposalUnit.Uid, out ApcPowerReceiverComponent power)); power!.NeedsPower = false; Assert.True(unit.Powered); diff --git a/Content.IntegrationTests/Tests/Doors/AirlockTest.cs b/Content.IntegrationTests/Tests/Doors/AirlockTest.cs index 89eca86557..9af9029278 100644 --- a/Content.IntegrationTests/Tests/Doors/AirlockTest.cs +++ b/Content.IntegrationTests/Tests/Doors/AirlockTest.cs @@ -65,7 +65,7 @@ namespace Content.IntegrationTests.Tests.Doors airlock = entityManager.SpawnEntity("AirlockDummy", MapCoordinates.Nullspace); - Assert.True(airlock.TryGetComponent(out doorComponent)); + Assert.True(IoCManager.Resolve().TryGetComponent(airlock.Uid, out doorComponent)); Assert.That(doorComponent.State, Is.EqualTo(SharedDoorComponent.DoorState.Closed)); }); @@ -136,9 +136,9 @@ namespace Content.IntegrationTests.Tests.Doors airlock = entityManager.SpawnEntity("AirlockDummy", new MapCoordinates((0, 0), mapId)); - Assert.True(physicsDummy.TryGetComponent(out physBody)); + Assert.True(IoCManager.Resolve().TryGetComponent(physicsDummy.Uid, out physBody)); - Assert.True(airlock.TryGetComponent(out doorComponent)); + Assert.True(IoCManager.Resolve().TryGetComponent(airlock.Uid, out doorComponent)); Assert.That(doorComponent.State, Is.EqualTo(SharedDoorComponent.DoorState.Closed)); }); diff --git a/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs b/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs index ed54c7652b..e94bdb317d 100644 --- a/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs +++ b/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs @@ -66,11 +66,13 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking human.Transform.WorldPosition = otherHuman.Transform.WorldPosition; // Test for components existing - Assert.True(human.TryGetComponent(out cuffed!), $"Human has no {nameof(CuffableComponent)}"); - Assert.True(human.TryGetComponent(out hands!), $"Human has no {nameof(HandsComponent)}"); - Assert.True(human.TryGetComponent(out SharedBodyComponent? _), $"Human has no {nameof(SharedBodyComponent)}"); - Assert.True(cuffs.TryGetComponent(out HandcuffComponent? _), $"Handcuff has no {nameof(HandcuffComponent)}"); - Assert.True(secondCuffs.TryGetComponent(out HandcuffComponent? _), $"Second handcuffs has no {nameof(HandcuffComponent)}"); + ref CuffableComponent? comp = ref cuffed!; + Assert.True(IoCManager.Resolve().TryGetComponent(human.Uid, out comp), $"Human has no {nameof(CuffableComponent)}"); + ref HandsComponent? comp1 = ref hands!; + Assert.True(IoCManager.Resolve().TryGetComponent(human.Uid, out comp1), $"Human has no {nameof(HandsComponent)}"); + Assert.True(IoCManager.Resolve().TryGetComponent(human.Uid, out SharedBodyComponent? _), $"Human has no {nameof(SharedBodyComponent)}"); + Assert.True(IoCManager.Resolve().TryGetComponent(cuffs.Uid, out HandcuffComponent? _), $"Handcuff has no {nameof(HandcuffComponent)}"); + Assert.True(IoCManager.Resolve().TryGetComponent(secondCuffs.Uid, out HandcuffComponent? _), $"Second handcuffs has no {nameof(HandcuffComponent)}"); // Test to ensure cuffed players register the handcuffs cuffed.TryAddNewCuffs(human, cuffs); diff --git a/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/ActionsComponentTests.cs b/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/ActionsComponentTests.cs index a91919bfb2..88da4fe102 100644 --- a/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/ActionsComponentTests.cs +++ b/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/ActionsComponentTests.cs @@ -251,7 +251,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs // spawn and give them an item that has actions serverFlashlight = serverEntManager.SpawnEntity("TestFlashlight", new EntityCoordinates(serverPlayerEnt.Uid, (0, 0))); - Assert.That(serverFlashlight.TryGetComponent(out var itemActions)); + Assert.That(IoCManager.Resolve().TryGetComponent(serverFlashlight.Uid, out var itemActions)); // we expect this only to have a toggle light action initially var actionConfigs = itemActions.ActionConfigs.ToList(); Assert.That(actionConfigs.Count == 1); diff --git a/Content.IntegrationTests/Tests/GameObjects/Components/Movement/ClimbUnitTest.cs b/Content.IntegrationTests/Tests/GameObjects/Components/Movement/ClimbUnitTest.cs index 0ef1d70637..e6e9182c67 100644 --- a/Content.IntegrationTests/Tests/GameObjects/Components/Movement/ClimbUnitTest.cs +++ b/Content.IntegrationTests/Tests/GameObjects/Components/Movement/ClimbUnitTest.cs @@ -54,8 +54,9 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Movement // Test for climb components existing // Players and tables should have these in their prototypes. - Assert.That(human.TryGetComponent(out climbing!), "Human has no climbing"); - Assert.That(table.TryGetComponent(out ClimbableComponent? _), "Table has no climbable"); + ref ClimbingComponent? comp = ref climbing!; + Assert.That(IoCManager.Resolve().TryGetComponent(human.Uid, out comp), "Human has no climbing"); + Assert.That(IoCManager.Resolve().TryGetComponent(table.Uid, out ClimbableComponent? _), "Table has no climbable"); // Now let's make the player enter a climbing transitioning state. climbing.IsClimbing = true; diff --git a/Content.IntegrationTests/Tests/Gravity/WeightlessStatusTests.cs b/Content.IntegrationTests/Tests/Gravity/WeightlessStatusTests.cs index dc27712f31..0bbbf43529 100644 --- a/Content.IntegrationTests/Tests/Gravity/WeightlessStatusTests.cs +++ b/Content.IntegrationTests/Tests/Gravity/WeightlessStatusTests.cs @@ -6,6 +6,7 @@ using Content.Shared.Alert; using Content.Shared.Coordinates; using NUnit.Framework; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Map; namespace Content.IntegrationTests.Tests.Gravity @@ -52,7 +53,7 @@ namespace Content.IntegrationTests.Tests.Gravity var coordinates = grid.ToCoordinates(); human = entityManager.SpawnEntity("HumanDummy", coordinates); - Assert.True(human.TryGetComponent(out alerts)); + Assert.True(IoCManager.Resolve().TryGetComponent(human.Uid, out alerts)); }); // Let WeightlessSystem and GravitySystem tick diff --git a/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs b/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs index 7fd08bc699..d148a856ee 100644 --- a/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs +++ b/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs @@ -95,7 +95,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click Assert.That(interactUsing, Is.False); Assert.That(interactHand); - Assert.That(user.TryGetComponent(out var hands)); + Assert.That(IoCManager.Resolve().TryGetComponent(user.Uid, out var hands)); Assert.That(hands.PutInHand(IoCManager.Resolve().GetComponent(item.Uid))); interactionSystem.UserInteraction(user, target.Transform.Coordinates, target.Uid); @@ -167,7 +167,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click Assert.That(interactUsing, Is.False); Assert.That(interactHand, Is.False); - Assert.That(user.TryGetComponent(out var hands)); + Assert.That(IoCManager.Resolve().TryGetComponent(user.Uid, out var hands)); Assert.That(hands.PutInHand(IoCManager.Resolve().GetComponent(item.Uid))); interactionSystem.UserInteraction(user, target.Transform.Coordinates, target.Uid); @@ -236,7 +236,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click Assert.That(interactUsing, Is.False); Assert.That(interactHand); - Assert.That(user.TryGetComponent(out var hands)); + Assert.That(IoCManager.Resolve().TryGetComponent(user.Uid, out var hands)); Assert.That(hands.PutInHand(IoCManager.Resolve().GetComponent(item.Uid))); interactionSystem.UserInteraction(user, target.Transform.Coordinates, target.Uid); @@ -306,7 +306,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click Assert.That(interactUsing, Is.False); Assert.That(interactHand, Is.False); - Assert.That(user.TryGetComponent(out var hands)); + Assert.That(IoCManager.Resolve().TryGetComponent(user.Uid, out var hands)); Assert.That(hands.PutInHand(IoCManager.Resolve().GetComponent(item.Uid))); interactionSystem.UserInteraction(user, target.Transform.Coordinates, target.Uid); @@ -391,7 +391,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click Assert.That(interactUsing, Is.False); Assert.That(interactHand); - Assert.That(user.TryGetComponent(out var hands)); + Assert.That(IoCManager.Resolve().TryGetComponent(user.Uid, out var hands)); Assert.That(hands.PutInHand(IoCManager.Resolve().GetComponent(item.Uid))); interactionSystem.UserInteraction(user, target.Transform.Coordinates, target.Uid); diff --git a/Content.IntegrationTests/Tests/ShuttleTest.cs b/Content.IntegrationTests/Tests/ShuttleTest.cs index 1593082791..6f1758d093 100644 --- a/Content.IntegrationTests/Tests/ShuttleTest.cs +++ b/Content.IntegrationTests/Tests/ShuttleTest.cs @@ -4,6 +4,7 @@ using Content.Server.Shuttles; using Content.Server.Shuttles.Components; using NUnit.Framework; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; using Robust.Shared.Physics; @@ -30,8 +31,8 @@ namespace Content.IntegrationTests.Tests var grid = mapMan.CreateGrid(mapId); gridEnt = entMan.GetEntity(grid.GridEntityId); - Assert.That(gridEnt.TryGetComponent(out ShuttleComponent? shuttleComponent)); - Assert.That(gridEnt.TryGetComponent(out PhysicsComponent? physicsComponent)); + Assert.That(IoCManager.Resolve().TryGetComponent(gridEnt.Uid, out ShuttleComponent? shuttleComponent)); + Assert.That(IoCManager.Resolve().TryGetComponent(gridEnt.Uid, out PhysicsComponent? physicsComponent)); Assert.That(physicsComponent!.BodyType, Is.EqualTo(BodyType.Dynamic)); Assert.That(gridEnt.Transform.LocalPosition, Is.EqualTo(Vector2.Zero)); physicsComponent.ApplyLinearImpulse(Vector2.One); diff --git a/Content.Server/AI/Components/AiControllerComponent.cs b/Content.Server/AI/Components/AiControllerComponent.cs index 468a245860..a81cf32512 100644 --- a/Content.Server/AI/Components/AiControllerComponent.cs +++ b/Content.Server/AI/Components/AiControllerComponent.cs @@ -61,7 +61,7 @@ namespace Content.Server.AI.Components { get { - if (Owner.TryGetComponent(out MovementSpeedModifierComponent? component)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out MovementSpeedModifierComponent? component)) { return component.CurrentWalkSpeed; } @@ -78,7 +78,7 @@ namespace Content.Server.AI.Components { get { - if (Owner.TryGetComponent(out MovementSpeedModifierComponent? component)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out MovementSpeedModifierComponent? component)) { return component.CurrentSprintSpeed; } diff --git a/Content.Server/AI/EntitySystems/AiFactionTagSystem.cs b/Content.Server/AI/EntitySystems/AiFactionTagSystem.cs index c5971584db..936bc27130 100644 --- a/Content.Server/AI/EntitySystems/AiFactionTagSystem.cs +++ b/Content.Server/AI/EntitySystems/AiFactionTagSystem.cs @@ -55,7 +55,7 @@ namespace Content.Server.AI.EntitySystems public Faction GetHostileFactions(Faction faction) => _hostileFactions.TryGetValue(faction, out var hostiles) ? hostiles : Faction.None; public Faction GetFactions(IEntity entity) => - entity.TryGetComponent(out AiFactionTagComponent? factionTags) + IoCManager.Resolve().TryGetComponent(entity.Uid, out AiFactionTagComponent? factionTags) ? factionTags.Factions : Faction.None; diff --git a/Content.Server/AI/EntitySystems/AiSystem.cs b/Content.Server/AI/EntitySystems/AiSystem.cs index 1ad9758aae..86d2b1bb77 100644 --- a/Content.Server/AI/EntitySystems/AiSystem.cs +++ b/Content.Server/AI/EntitySystems/AiSystem.cs @@ -52,7 +52,7 @@ namespace Content.Server.AI.EntitySystems { // TODO: Need to generecise this but that will be part of a larger cleanup later anyway. if ((!IoCManager.Resolve().EntityExists(message.Entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(message.Entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || - !message.Entity.TryGetComponent(out UtilityAi? controller)) + !IoCManager.Resolve().TryGetComponent(message.Entity.Uid, out UtilityAi? controller)) { continue; } diff --git a/Content.Server/AI/Operators/Combat/Melee/SwingMeleeWeaponOperator.cs b/Content.Server/AI/Operators/Combat/Melee/SwingMeleeWeaponOperator.cs index 0ebf617e0a..315e963ec6 100644 --- a/Content.Server/AI/Operators/Combat/Melee/SwingMeleeWeaponOperator.cs +++ b/Content.Server/AI/Operators/Combat/Melee/SwingMeleeWeaponOperator.cs @@ -29,7 +29,7 @@ namespace Content.Server.AI.Operators.Combat.Melee return true; } - if (!_owner.TryGetComponent(out CombatModeComponent? combatModeComponent)) + if (!IoCManager.Resolve().TryGetComponent(_owner.Uid, out CombatModeComponent? combatModeComponent)) { return false; } @@ -47,7 +47,7 @@ namespace Content.Server.AI.Operators.Combat.Melee if (!base.Shutdown(outcome)) return false; - if (_owner.TryGetComponent(out CombatModeComponent? combatModeComponent)) + if (IoCManager.Resolve().TryGetComponent(_owner.Uid, out CombatModeComponent? combatModeComponent)) { combatModeComponent.IsInCombatMode = false; } @@ -62,13 +62,13 @@ namespace Content.Server.AI.Operators.Combat.Melee return Outcome.Success; } - if (!_owner.TryGetComponent(out HandsComponent? hands) || hands.GetActiveHand == null) + if (!IoCManager.Resolve().TryGetComponent(_owner.Uid, out HandsComponent? hands) || hands.GetActiveHand == null) { return Outcome.Failed; } var meleeWeapon = hands.GetActiveHand.Owner; - meleeWeapon.TryGetComponent(out MeleeWeaponComponent? meleeWeaponComponent); + IoCManager.Resolve().TryGetComponent(meleeWeapon.Uid, out MeleeWeaponComponent? meleeWeaponComponent); if ((_target.Transform.Coordinates.Position - _owner.Transform.Coordinates.Position).Length > meleeWeaponComponent?.Range) diff --git a/Content.Server/AI/Operators/Combat/Melee/UnarmedCombatOperator.cs b/Content.Server/AI/Operators/Combat/Melee/UnarmedCombatOperator.cs index 0a569afaa9..dcc8abd803 100644 --- a/Content.Server/AI/Operators/Combat/Melee/UnarmedCombatOperator.cs +++ b/Content.Server/AI/Operators/Combat/Melee/UnarmedCombatOperator.cs @@ -29,7 +29,7 @@ namespace Content.Server.AI.Operators.Combat.Melee return true; } - if (!_owner.TryGetComponent(out CombatModeComponent? combatModeComponent)) + if (!IoCManager.Resolve().TryGetComponent(_owner.Uid, out CombatModeComponent? combatModeComponent)) { return false; } @@ -39,7 +39,7 @@ namespace Content.Server.AI.Operators.Combat.Melee combatModeComponent.IsInCombatMode = true; } - if (_owner.TryGetComponent(out UnarmedCombatComponent? unarmedCombatComponent)) + if (IoCManager.Resolve().TryGetComponent(_owner.Uid, out UnarmedCombatComponent? unarmedCombatComponent)) { _unarmedCombat = unarmedCombatComponent; } @@ -56,7 +56,7 @@ namespace Content.Server.AI.Operators.Combat.Melee if (!base.Shutdown(outcome)) return false; - if (_owner.TryGetComponent(out CombatModeComponent? combatModeComponent)) + if (IoCManager.Resolve().TryGetComponent(_owner.Uid, out CombatModeComponent? combatModeComponent)) { combatModeComponent.IsInCombatMode = false; } diff --git a/Content.Server/AI/Operators/Inventory/CloseStorageOperator.cs b/Content.Server/AI/Operators/Inventory/CloseStorageOperator.cs index 3780cefe9f..30356b7174 100644 --- a/Content.Server/AI/Operators/Inventory/CloseStorageOperator.cs +++ b/Content.Server/AI/Operators/Inventory/CloseStorageOperator.cs @@ -4,6 +4,7 @@ using Content.Server.Storage.Components; using Content.Shared.Interaction; using Content.Shared.Interaction.Helpers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Operators.Inventory { @@ -58,7 +59,7 @@ namespace Content.Server.AI.Operators.Inventory return Outcome.Failed; } - if (!_target.TryGetComponent(out EntityStorageComponent? storageComponent) || + if (!IoCManager.Resolve().TryGetComponent(_target.Uid, out EntityStorageComponent? storageComponent) || storageComponent.IsWeldedShut) { return Outcome.Failed; diff --git a/Content.Server/AI/Operators/Inventory/DropEntityOperator.cs b/Content.Server/AI/Operators/Inventory/DropEntityOperator.cs index 1808434ed8..67bcba2ee2 100644 --- a/Content.Server/AI/Operators/Inventory/DropEntityOperator.cs +++ b/Content.Server/AI/Operators/Inventory/DropEntityOperator.cs @@ -1,5 +1,6 @@ using Content.Server.Hands.Components; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Operators.Inventory { @@ -20,7 +21,7 @@ namespace Content.Server.AI.Operators.Inventory /// public override Outcome Execute(float frameTime) { - if (!_owner.TryGetComponent(out HandsComponent? handsComponent)) + if (!IoCManager.Resolve().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent)) { return Outcome.Failed; } diff --git a/Content.Server/AI/Operators/Inventory/DropHandItemsOperator.cs b/Content.Server/AI/Operators/Inventory/DropHandItemsOperator.cs index 3ab558d009..d36406246c 100644 --- a/Content.Server/AI/Operators/Inventory/DropHandItemsOperator.cs +++ b/Content.Server/AI/Operators/Inventory/DropHandItemsOperator.cs @@ -1,5 +1,6 @@ using Content.Server.Hands.Components; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Operators.Inventory { @@ -14,7 +15,7 @@ namespace Content.Server.AI.Operators.Inventory public override Outcome Execute(float frameTime) { - if (!_owner.TryGetComponent(out HandsComponent? handsComponent)) + if (!IoCManager.Resolve().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent)) { return Outcome.Failed; } diff --git a/Content.Server/AI/Operators/Inventory/EquipEntityOperator.cs b/Content.Server/AI/Operators/Inventory/EquipEntityOperator.cs index e42de80336..39867823fd 100644 --- a/Content.Server/AI/Operators/Inventory/EquipEntityOperator.cs +++ b/Content.Server/AI/Operators/Inventory/EquipEntityOperator.cs @@ -1,5 +1,6 @@ using Content.Server.Hands.Components; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Operators.Inventory { @@ -15,7 +16,7 @@ namespace Content.Server.AI.Operators.Inventory public override Outcome Execute(float frameTime) { - if (!_owner.TryGetComponent(out HandsComponent? handsComponent)) + if (!IoCManager.Resolve().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent)) { return Outcome.Failed; } diff --git a/Content.Server/AI/Operators/Inventory/InteractWithEntityOperator.cs b/Content.Server/AI/Operators/Inventory/InteractWithEntityOperator.cs index 39f3c5a200..b85c7a4ac4 100644 --- a/Content.Server/AI/Operators/Inventory/InteractWithEntityOperator.cs +++ b/Content.Server/AI/Operators/Inventory/InteractWithEntityOperator.cs @@ -33,7 +33,7 @@ namespace Content.Server.AI.Operators.Inventory return Outcome.Failed; } - if (_owner.TryGetComponent(out CombatModeComponent? combatModeComponent)) + if (IoCManager.Resolve().TryGetComponent(_owner.Uid, out CombatModeComponent? combatModeComponent)) { combatModeComponent.IsInCombatMode = false; } diff --git a/Content.Server/AI/Operators/Inventory/OpenStorageOperator.cs b/Content.Server/AI/Operators/Inventory/OpenStorageOperator.cs index 32250ab9b8..3fdee9fbd9 100644 --- a/Content.Server/AI/Operators/Inventory/OpenStorageOperator.cs +++ b/Content.Server/AI/Operators/Inventory/OpenStorageOperator.cs @@ -5,6 +5,7 @@ using Content.Shared.Interaction; using Content.Shared.Interaction.Helpers; using Robust.Shared.Containers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Operators.Inventory { @@ -34,7 +35,7 @@ namespace Content.Server.AI.Operators.Inventory return Outcome.Failed; } - if (!container.Owner.TryGetComponent(out EntityStorageComponent? storageComponent) || + if (!IoCManager.Resolve().TryGetComponent(container.Owner.Uid, out EntityStorageComponent? storageComponent) || storageComponent.IsWeldedShut) { return Outcome.Failed; diff --git a/Content.Server/AI/Operators/Inventory/PickupEntityOperator.cs b/Content.Server/AI/Operators/Inventory/PickupEntityOperator.cs index 68fdb4d9f8..f833974251 100644 --- a/Content.Server/AI/Operators/Inventory/PickupEntityOperator.cs +++ b/Content.Server/AI/Operators/Inventory/PickupEntityOperator.cs @@ -30,7 +30,7 @@ namespace Content.Server.AI.Operators.Inventory return Outcome.Failed; } - if (!_owner.TryGetComponent(out HandsComponent? handsComponent)) + if (!IoCManager.Resolve().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent)) { return Outcome.Failed; } diff --git a/Content.Server/AI/Operators/Inventory/UseItemInInventoryOperator.cs b/Content.Server/AI/Operators/Inventory/UseItemInInventoryOperator.cs index fec7a7b7a9..8bb037b730 100644 --- a/Content.Server/AI/Operators/Inventory/UseItemInInventoryOperator.cs +++ b/Content.Server/AI/Operators/Inventory/UseItemInInventoryOperator.cs @@ -1,6 +1,7 @@ using Content.Server.Hands.Components; using Content.Server.Items; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Operators.Inventory { @@ -21,12 +22,12 @@ namespace Content.Server.AI.Operators.Inventory public override Outcome Execute(float frameTime) { // TODO: Also have this check storage a la backpack etc. - if (!_owner.TryGetComponent(out HandsComponent? handsComponent)) + if (!IoCManager.Resolve().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent)) { return Outcome.Failed; } - if (!_target.TryGetComponent(out ItemComponent? itemComponent)) + if (!IoCManager.Resolve().TryGetComponent(_target.Uid, out ItemComponent? itemComponent)) { return Outcome.Failed; } diff --git a/Content.Server/AI/Operators/Nutrition/UseDrinkInInventoryOperator.cs b/Content.Server/AI/Operators/Nutrition/UseDrinkInInventoryOperator.cs index 90a05f4414..5fd1f6d71d 100644 --- a/Content.Server/AI/Operators/Nutrition/UseDrinkInInventoryOperator.cs +++ b/Content.Server/AI/Operators/Nutrition/UseDrinkInInventoryOperator.cs @@ -31,8 +31,8 @@ namespace Content.Server.AI.Operators.Nutrition // TODO: Also have this check storage a la backpack etc. if ((!IoCManager.Resolve().EntityExists(_target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(_target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || - !_owner.TryGetComponent(out HandsComponent? handsComponent) || - !_target.TryGetComponent(out ItemComponent? itemComponent)) + !IoCManager.Resolve().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent) || + !IoCManager.Resolve().TryGetComponent(_target.Uid, out ItemComponent? itemComponent)) { return Outcome.Failed; } @@ -43,7 +43,7 @@ namespace Content.Server.AI.Operators.Nutrition { if (handsComponent.GetItem(slot) != itemComponent) continue; handsComponent.ActiveHand = slot; - if (!_target.TryGetComponent(out drinkComponent)) + if (!IoCManager.Resolve().TryGetComponent(_target.Uid, out drinkComponent)) { return Outcome.Failed; } @@ -59,7 +59,7 @@ namespace Content.Server.AI.Operators.Nutrition } if (drinkComponent.Deleted || EntitySystem.Get().IsEmpty(drinkComponent.Owner.Uid, drinkComponent) - || _owner.TryGetComponent(out ThirstComponent? thirstComponent) && + || IoCManager.Resolve().TryGetComponent(_owner.Uid, out ThirstComponent? thirstComponent) && thirstComponent.CurrentThirst >= thirstComponent.ThirstThresholds[ThirstThreshold.Okay]) { return Outcome.Success; diff --git a/Content.Server/AI/Operators/Nutrition/UseFoodInInventoryOperator.cs b/Content.Server/AI/Operators/Nutrition/UseFoodInInventoryOperator.cs index 59eed160a9..480a1d1599 100644 --- a/Content.Server/AI/Operators/Nutrition/UseFoodInInventoryOperator.cs +++ b/Content.Server/AI/Operators/Nutrition/UseFoodInInventoryOperator.cs @@ -30,8 +30,8 @@ namespace Content.Server.AI.Operators.Nutrition // TODO: Also have this check storage a la backpack etc. if ((!IoCManager.Resolve().EntityExists(_target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(_target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || - !_owner.TryGetComponent(out HandsComponent? handsComponent) || - !_target.TryGetComponent(out ItemComponent? itemComponent)) + !IoCManager.Resolve().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent) || + !IoCManager.Resolve().TryGetComponent(_target.Uid, out ItemComponent? itemComponent)) { return Outcome.Failed; } @@ -42,7 +42,7 @@ namespace Content.Server.AI.Operators.Nutrition { if (handsComponent.GetItem(slot) != itemComponent) continue; handsComponent.ActiveHand = slot; - if (!_target.TryGetComponent(out foodComponent)) + if (!IoCManager.Resolve().TryGetComponent(_target.Uid, out foodComponent)) { return Outcome.Failed; } @@ -59,7 +59,7 @@ namespace Content.Server.AI.Operators.Nutrition if ((!IoCManager.Resolve().EntityExists(_target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(_target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || foodComponent.UsesRemaining == 0 || - _owner.TryGetComponent(out HungerComponent? hungerComponent) && + IoCManager.Resolve().TryGetComponent(_owner.Uid, out HungerComponent? hungerComponent) && hungerComponent.CurrentHunger >= hungerComponent.HungerThresholds[HungerThreshold.Okay]) { return Outcome.Success; diff --git a/Content.Server/AI/Pathfinding/Accessible/AiReachableSystem.cs b/Content.Server/AI/Pathfinding/Accessible/AiReachableSystem.cs index 48328e95b8..45360958c5 100644 --- a/Content.Server/AI/Pathfinding/Accessible/AiReachableSystem.cs +++ b/Content.Server/AI/Pathfinding/Accessible/AiReachableSystem.cs @@ -181,7 +181,7 @@ namespace Content.Server.AI.Pathfinding.Accessible var targetNode = _pathfindingSystem.GetNode(targetTile); var collisionMask = 0; - if (entity.TryGetComponent(out IPhysBody? physics)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out IPhysBody? physics)) { collisionMask = physics.CollisionMask; } diff --git a/Content.Server/AI/Pathfinding/Accessible/ReachableArgs.cs b/Content.Server/AI/Pathfinding/Accessible/ReachableArgs.cs index 6255f1a758..423cc90db3 100644 --- a/Content.Server/AI/Pathfinding/Accessible/ReachableArgs.cs +++ b/Content.Server/AI/Pathfinding/Accessible/ReachableArgs.cs @@ -29,7 +29,7 @@ namespace Content.Server.AI.Pathfinding.Accessible public static ReachableArgs GetArgs(IEntity entity) { var collisionMask = 0; - if (entity.TryGetComponent(out IPhysBody? physics)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out IPhysBody? physics)) { collisionMask = physics.CollisionMask; } diff --git a/Content.Server/AI/Pathfinding/PathfindingNode.cs b/Content.Server/AI/Pathfinding/PathfindingNode.cs index 10dd58c9d0..1184bd79f9 100644 --- a/Content.Server/AI/Pathfinding/PathfindingNode.cs +++ b/Content.Server/AI/Pathfinding/PathfindingNode.cs @@ -267,7 +267,7 @@ namespace Content.Server.AI.Pathfinding // TODO: Check for powered I think (also need an event for when it's depowered // AccessReader calls this whenever opening / closing but it can seem to get called multiple times // Which may or may not be intended? - if (entity.TryGetComponent(out AccessReader? accessReader) && !_accessReaders.ContainsKey(entity)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out AccessReader? accessReader) && !_accessReaders.ContainsKey(entity)) { _accessReaders.Add(entity, accessReader); ParentChunk.Dirty(); diff --git a/Content.Server/AI/Pathfinding/PathfindingSystem.cs b/Content.Server/AI/Pathfinding/PathfindingSystem.cs index 7ee7d1046e..7343912160 100644 --- a/Content.Server/AI/Pathfinding/PathfindingSystem.cs +++ b/Content.Server/AI/Pathfinding/PathfindingSystem.cs @@ -267,7 +267,7 @@ namespace Content.Server.AI.Pathfinding { if ((!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || _lastKnownPositions.ContainsKey(entity) || - !entity.TryGetComponent(out IPhysBody? physics) || + !IoCManager.Resolve().TryGetComponent(entity.Uid, out IPhysBody? physics) || !PathfindingNode.IsRelevant(entity, physics)) { return; @@ -306,7 +306,7 @@ namespace Content.Server.AI.Pathfinding { // If we've moved to space or the likes then remove us. if ((!IoCManager.Resolve().EntityExists(moveEvent.Sender.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(moveEvent.Sender.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || - !moveEvent.Sender.TryGetComponent(out IPhysBody? physics) || + !IoCManager.Resolve().TryGetComponent(moveEvent.Sender.Uid, out IPhysBody? physics) || !PathfindingNode.IsRelevant(moveEvent.Sender, physics) || moveEvent.NewPosition.GetGridId(EntityManager) == GridId.Invalid) { @@ -371,7 +371,7 @@ namespace Content.Server.AI.Pathfinding public bool CanTraverse(IEntity entity, PathfindingNode node) { - if (entity.TryGetComponent(out IPhysBody? physics) && + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out IPhysBody? physics) && (physics.CollisionMask & node.BlockedCollisionMask) != 0) { return false; diff --git a/Content.Server/AI/Steering/AiSteeringSystem.cs b/Content.Server/AI/Steering/AiSteeringSystem.cs index 2821204d3b..c38326f303 100644 --- a/Content.Server/AI/Steering/AiSteeringSystem.cs +++ b/Content.Server/AI/Steering/AiSteeringSystem.cs @@ -129,7 +129,7 @@ namespace Content.Server.AI.Steering /// public void Unregister(IEntity entity) { - if (entity.TryGetComponent(out AiControllerComponent? controller)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out AiControllerComponent? controller)) { controller.VelocityDir = Vector2.Zero; } @@ -249,7 +249,7 @@ namespace Content.Server.AI.Steering { // Main optimisation to be done below is the redundant calls and adding more variables if ((!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || - !entity.TryGetComponent(out AiControllerComponent? controller) || + !IoCManager.Resolve().TryGetComponent(entity.Uid, out AiControllerComponent? controller) || !EntitySystem.Get().CanMove(entity.Uid) || !entity.Transform.GridID.IsValid()) { @@ -420,7 +420,7 @@ namespace Content.Server.AI.Steering var startTile = gridManager.GetTileRef(entity.Transform.Coordinates); var endTile = gridManager.GetTileRef(steeringRequest.TargetGrid); var collisionMask = 0; - if (entity.TryGetComponent(out IPhysBody? physics)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out IPhysBody? physics)) { collisionMask = physics.CollisionMask; } @@ -606,7 +606,7 @@ namespace Content.Server.AI.Steering return Vector2.Zero; } - if (target.TryGetComponent(out IPhysBody? physics)) + if (IoCManager.Resolve().TryGetComponent(target.Uid, out IPhysBody? physics)) { var targetDistance = (targetPos.Position - entityPos.Position); targetPos = targetPos.Offset(physics.LinearVelocity * targetDistance); @@ -624,7 +624,7 @@ namespace Content.Server.AI.Steering /// private Vector2 CollisionAvoidance(IEntity entity, Vector2 direction, ICollection ignoredTargets) { - if (direction == Vector2.Zero || !entity.TryGetComponent(out IPhysBody? physics)) + if (direction == Vector2.Zero || !IoCManager.Resolve().TryGetComponent(entity.Uid, out IPhysBody? physics)) { return Vector2.Zero; } @@ -665,7 +665,7 @@ namespace Content.Server.AI.Steering // if we're moving in the same direction then ignore // So if 2 entities are moving towards each other and both detect a collision they'll both move in the same direction // i.e. towards the right - if (physicsEntity.TryGetComponent(out IPhysBody? otherPhysics) && + if (IoCManager.Resolve().TryGetComponent(physicsEntity.Uid, out IPhysBody? otherPhysics) && Vector2.Dot(otherPhysics.LinearVelocity, direction) > 0) { continue; diff --git a/Content.Server/AI/Utility/Actions/Combat/Melee/MeleeWeaponAttackEntity.cs b/Content.Server/AI/Utility/Actions/Combat/Melee/MeleeWeaponAttackEntity.cs index 453e793545..9a4ee18e6b 100644 --- a/Content.Server/AI/Utility/Actions/Combat/Melee/MeleeWeaponAttackEntity.cs +++ b/Content.Server/AI/Utility/Actions/Combat/Melee/MeleeWeaponAttackEntity.cs @@ -27,7 +27,7 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee { MoveToEntityOperator moveOperator; var equipped = context.GetState().GetValue(); - if (equipped != null && equipped.TryGetComponent(out MeleeWeaponComponent? meleeWeaponComponent)) + if (equipped != null && IoCManager.Resolve().TryGetComponent(equipped.Uid, out MeleeWeaponComponent? meleeWeaponComponent)) { moveOperator = new MoveToEntityOperator(Owner, Target, meleeWeaponComponent.Range - 0.01f); } diff --git a/Content.Server/AI/Utility/Actions/Combat/Melee/UnarmedAttackEntity.cs b/Content.Server/AI/Utility/Actions/Combat/Melee/UnarmedAttackEntity.cs index 873b2440ee..7297411981 100644 --- a/Content.Server/AI/Utility/Actions/Combat/Melee/UnarmedAttackEntity.cs +++ b/Content.Server/AI/Utility/Actions/Combat/Melee/UnarmedAttackEntity.cs @@ -24,7 +24,7 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee public override void SetupOperators(Blackboard context) { MoveToEntityOperator moveOperator; - if (Owner.TryGetComponent(out UnarmedCombatComponent? unarmedCombatComponent)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out UnarmedCombatComponent? unarmedCombatComponent)) { moveOperator = new MoveToEntityOperator(Owner, Target, unarmedCombatComponent.Range - 0.01f); } diff --git a/Content.Server/AI/Utility/Considerations/Clothing/ClothingInInventoryCon.cs b/Content.Server/AI/Utility/Considerations/Clothing/ClothingInInventoryCon.cs index 1dd5b9b8e7..6368f5d457 100644 --- a/Content.Server/AI/Utility/Considerations/Clothing/ClothingInInventoryCon.cs +++ b/Content.Server/AI/Utility/Considerations/Clothing/ClothingInInventoryCon.cs @@ -3,6 +3,8 @@ using Content.Server.AI.WorldState.States.Clothing; using Content.Server.AI.WorldState.States.Inventory; using Content.Server.Clothing.Components; using Content.Shared.Inventory; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Utility.Considerations.Clothing { @@ -23,7 +25,7 @@ namespace Content.Server.AI.Utility.Considerations.Clothing foreach (var entity in context.GetState().GetValue()) { - if (!entity.TryGetComponent(out ClothingComponent? clothingComponent)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out ClothingComponent? clothingComponent)) { continue; } diff --git a/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponDamageCon.cs b/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponDamageCon.cs index 470db45994..efcdc77644 100644 --- a/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponDamageCon.cs +++ b/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponDamageCon.cs @@ -1,6 +1,8 @@ using Content.Server.AI.WorldState; using Content.Server.AI.WorldState.States.Combat; using Content.Server.Weapon.Melee.Components; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Utility.Considerations.Combat.Melee { @@ -10,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat.Melee { var target = context.GetState().GetValue(); - if (target == null || !target.TryGetComponent(out MeleeWeaponComponent? meleeWeaponComponent)) + if (target == null || !IoCManager.Resolve().TryGetComponent(target.Uid, out MeleeWeaponComponent? meleeWeaponComponent)) { return 0.0f; } diff --git a/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponSpeedCon.cs b/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponSpeedCon.cs index 1c877e75bc..3e14dff7c6 100644 --- a/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponSpeedCon.cs +++ b/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponSpeedCon.cs @@ -1,6 +1,8 @@ using Content.Server.AI.WorldState; using Content.Server.AI.WorldState.States.Combat; using Content.Server.Weapon.Melee.Components; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Utility.Considerations.Combat.Melee { @@ -10,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat.Melee { var target = context.GetState().GetValue(); - if (target == null || !target.TryGetComponent(out MeleeWeaponComponent? meleeWeaponComponent)) + if (target == null || !IoCManager.Resolve().TryGetComponent(target.Uid, out MeleeWeaponComponent? meleeWeaponComponent)) { return 0.0f; } diff --git a/Content.Server/AI/Utility/Considerations/Combat/TargetHealthCon.cs b/Content.Server/AI/Utility/Considerations/Combat/TargetHealthCon.cs index 790d5db937..56a23d9eef 100644 --- a/Content.Server/AI/Utility/Considerations/Combat/TargetHealthCon.cs +++ b/Content.Server/AI/Utility/Considerations/Combat/TargetHealthCon.cs @@ -12,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat { var target = context.GetState().GetValue(); - if (target == null || !IoCManager.Resolve().EntityExists(target.Uid) || !target.TryGetComponent(out DamageableComponent? damageableComponent)) + if (target == null || !IoCManager.Resolve().EntityExists(target.Uid) || !IoCManager.Resolve().TryGetComponent(target.Uid, out DamageableComponent? damageableComponent)) { return 0.0f; } diff --git a/Content.Server/AI/Utility/Considerations/Combat/TargetIsCritCon.cs b/Content.Server/AI/Utility/Considerations/Combat/TargetIsCritCon.cs index 7bd4ff2adb..946edec33d 100644 --- a/Content.Server/AI/Utility/Considerations/Combat/TargetIsCritCon.cs +++ b/Content.Server/AI/Utility/Considerations/Combat/TargetIsCritCon.cs @@ -1,6 +1,8 @@ using Content.Server.AI.WorldState; using Content.Server.AI.WorldState.States; using Content.Shared.MobState.Components; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Utility.Considerations.Combat { @@ -10,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat { var target = context.GetState().GetValue(); - if (target == null || !target.TryGetComponent(out MobStateComponent? mobState)) + if (target == null || !IoCManager.Resolve().TryGetComponent(target.Uid, out MobStateComponent? mobState)) { return 0.0f; } diff --git a/Content.Server/AI/Utility/Considerations/Combat/TargetIsDeadCon.cs b/Content.Server/AI/Utility/Considerations/Combat/TargetIsDeadCon.cs index 271c1ff929..60d1bfb8b9 100644 --- a/Content.Server/AI/Utility/Considerations/Combat/TargetIsDeadCon.cs +++ b/Content.Server/AI/Utility/Considerations/Combat/TargetIsDeadCon.cs @@ -1,6 +1,8 @@ using Content.Server.AI.WorldState; using Content.Server.AI.WorldState.States; using Content.Shared.MobState.Components; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Utility.Considerations.Combat { @@ -10,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat { var target = context.GetState().GetValue(); - if (target == null || !target.TryGetComponent(out MobStateComponent? mobState)) + if (target == null || !IoCManager.Resolve().TryGetComponent(target.Uid, out MobStateComponent? mobState)) { return 0.0f; } diff --git a/Content.Server/AI/Utility/Considerations/Containers/TargetAccessibleCon.cs b/Content.Server/AI/Utility/Considerations/Containers/TargetAccessibleCon.cs index 234a98c612..4c9d6a95cd 100644 --- a/Content.Server/AI/Utility/Considerations/Containers/TargetAccessibleCon.cs +++ b/Content.Server/AI/Utility/Considerations/Containers/TargetAccessibleCon.cs @@ -5,6 +5,7 @@ using Content.Server.Storage.Components; using Content.Shared.Interaction; using Robust.Shared.Containers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Utility.Considerations.Containers { @@ -24,7 +25,7 @@ namespace Content.Server.AI.Utility.Considerations.Containers if (target.TryGetContainer(out var container)) { - if (container.Owner.TryGetComponent(out EntityStorageComponent? storageComponent)) + if (IoCManager.Resolve().TryGetComponent(container.Owner.Uid, out EntityStorageComponent? storageComponent)) { if (storageComponent.IsWeldedShut && !storageComponent.Open) { diff --git a/Content.Server/AI/Utility/Considerations/Hands/FreeHandCon.cs b/Content.Server/AI/Utility/Considerations/Hands/FreeHandCon.cs index 6f12825434..f01567278b 100644 --- a/Content.Server/AI/Utility/Considerations/Hands/FreeHandCon.cs +++ b/Content.Server/AI/Utility/Considerations/Hands/FreeHandCon.cs @@ -1,6 +1,8 @@ using Content.Server.AI.WorldState; using Content.Server.AI.WorldState.States; using Content.Server.Hands.Components; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Utility.Considerations.Hands { @@ -10,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Hands { var owner = context.GetState().GetValue(); - if (owner == null || !owner.TryGetComponent(out HandsComponent? handsComponent)) + if (owner == null || !IoCManager.Resolve().TryGetComponent(owner.Uid, out HandsComponent? handsComponent)) { return 0.0f; } diff --git a/Content.Server/AI/Utility/Considerations/Nutrition/Drink/ThirstCon.cs b/Content.Server/AI/Utility/Considerations/Nutrition/Drink/ThirstCon.cs index 1a3c97f718..95760be285 100644 --- a/Content.Server/AI/Utility/Considerations/Nutrition/Drink/ThirstCon.cs +++ b/Content.Server/AI/Utility/Considerations/Nutrition/Drink/ThirstCon.cs @@ -2,6 +2,8 @@ using Content.Server.AI.WorldState; using Content.Server.AI.WorldState.States; using Content.Server.Nutrition.Components; using Content.Shared.Nutrition.Components; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Utility.Considerations.Nutrition.Drink { @@ -11,7 +13,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Drink { var owner = context.GetState().GetValue(); - if (owner == null || !owner.TryGetComponent(out ThirstComponent? thirst)) + if (owner == null || !IoCManager.Resolve().TryGetComponent(owner.Uid, out ThirstComponent? thirst)) { return 0.0f; } diff --git a/Content.Server/AI/Utility/Considerations/Nutrition/Food/FoodValueCon.cs b/Content.Server/AI/Utility/Considerations/Nutrition/Food/FoodValueCon.cs index 05be51230a..b0a1657739 100644 --- a/Content.Server/AI/Utility/Considerations/Nutrition/Food/FoodValueCon.cs +++ b/Content.Server/AI/Utility/Considerations/Nutrition/Food/FoodValueCon.cs @@ -14,7 +14,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Food var target = context.GetState().GetValue(); if (target == null || !IoCManager.Resolve().EntityExists(target.Uid) - || !target.TryGetComponent(out var foodComp) + || !IoCManager.Resolve().TryGetComponent(target.Uid, out var foodComp) || !EntitySystem.Get().TryGetSolution(target.Uid, foodComp.SolutionName, out var food)) { return 0.0f; diff --git a/Content.Server/AI/Utility/Considerations/Nutrition/Food/HungerCon.cs b/Content.Server/AI/Utility/Considerations/Nutrition/Food/HungerCon.cs index bdc5284094..bbfa55c334 100644 --- a/Content.Server/AI/Utility/Considerations/Nutrition/Food/HungerCon.cs +++ b/Content.Server/AI/Utility/Considerations/Nutrition/Food/HungerCon.cs @@ -2,6 +2,8 @@ using Content.Server.AI.WorldState; using Content.Server.AI.WorldState.States; using Content.Server.Nutrition.Components; using Content.Shared.Nutrition.Components; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Utility.Considerations.Nutrition.Food { @@ -12,7 +14,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Food { var owner = context.GetState().GetValue(); - if (owner == null || !owner.TryGetComponent(out HungerComponent? hunger)) + if (owner == null || !IoCManager.Resolve().TryGetComponent(owner.Uid, out HungerComponent? hunger)) { return 0.0f; } diff --git a/Content.Server/AI/Utility/ExpandableActions/Clothing/Gloves/EquipAnyGlovesExp.cs b/Content.Server/AI/Utility/ExpandableActions/Clothing/Gloves/EquipAnyGlovesExp.cs index 139083588f..a88414efc3 100644 --- a/Content.Server/AI/Utility/ExpandableActions/Clothing/Gloves/EquipAnyGlovesExp.cs +++ b/Content.Server/AI/Utility/ExpandableActions/Clothing/Gloves/EquipAnyGlovesExp.cs @@ -9,6 +9,7 @@ using Content.Server.AI.WorldState.States; using Content.Server.AI.WorldState.States.Inventory; using Content.Server.Clothing.Components; using Content.Shared.Inventory; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Gloves @@ -37,7 +38,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Gloves foreach (var entity in context.GetState().GetValue()) { - if (entity.TryGetComponent(out ClothingComponent? clothing) && + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ClothingComponent? clothing) && (clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.GLOVES) != 0) { yield return new EquipGloves {Owner = owner, Target = entity, Bonus = Bonus}; diff --git a/Content.Server/AI/Utility/ExpandableActions/Clothing/Gloves/PickUpAnyNearbyGlovesExp.cs b/Content.Server/AI/Utility/ExpandableActions/Clothing/Gloves/PickUpAnyNearbyGlovesExp.cs index 669fe88dc2..a34839afd7 100644 --- a/Content.Server/AI/Utility/ExpandableActions/Clothing/Gloves/PickUpAnyNearbyGlovesExp.cs +++ b/Content.Server/AI/Utility/ExpandableActions/Clothing/Gloves/PickUpAnyNearbyGlovesExp.cs @@ -9,6 +9,7 @@ using Content.Server.AI.WorldState.States; using Content.Server.AI.WorldState.States.Clothing; using Content.Server.Clothing.Components; using Content.Shared.Inventory; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Gloves @@ -35,7 +36,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Gloves foreach (var entity in context.GetState().GetValue()) { - if (entity.TryGetComponent(out ClothingComponent? clothing) && + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ClothingComponent? clothing) && (clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.GLOVES) != 0) { yield return new PickUpGloves {Owner = owner, Target = entity, Bonus = Bonus}; diff --git a/Content.Server/AI/Utility/ExpandableActions/Clothing/Head/EquipAnyHeadExp.cs b/Content.Server/AI/Utility/ExpandableActions/Clothing/Head/EquipAnyHeadExp.cs index 23d6af0a6e..69cd62d789 100644 --- a/Content.Server/AI/Utility/ExpandableActions/Clothing/Head/EquipAnyHeadExp.cs +++ b/Content.Server/AI/Utility/ExpandableActions/Clothing/Head/EquipAnyHeadExp.cs @@ -9,6 +9,7 @@ using Content.Server.AI.WorldState.States; using Content.Server.AI.WorldState.States.Inventory; using Content.Server.Clothing.Components; using Content.Shared.Inventory; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Head @@ -36,7 +37,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Head foreach (var entity in context.GetState().GetValue()) { - if (entity.TryGetComponent(out ClothingComponent? clothing) && + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ClothingComponent? clothing) && (clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.HEAD) != 0) { yield return new EquipHead {Owner = owner, Target = entity, Bonus = Bonus}; diff --git a/Content.Server/AI/Utility/ExpandableActions/Clothing/Head/PickUpAnyNearbyHeadExp.cs b/Content.Server/AI/Utility/ExpandableActions/Clothing/Head/PickUpAnyNearbyHeadExp.cs index b69972cbee..bb5175e6b1 100644 --- a/Content.Server/AI/Utility/ExpandableActions/Clothing/Head/PickUpAnyNearbyHeadExp.cs +++ b/Content.Server/AI/Utility/ExpandableActions/Clothing/Head/PickUpAnyNearbyHeadExp.cs @@ -9,6 +9,7 @@ using Content.Server.AI.WorldState.States; using Content.Server.AI.WorldState.States.Clothing; using Content.Server.Clothing.Components; using Content.Shared.Inventory; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Head @@ -35,7 +36,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Head foreach (var entity in context.GetState().GetValue()) { - if (entity.TryGetComponent(out ClothingComponent? clothing) && + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ClothingComponent? clothing) && (clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.HEAD) != 0) { yield return new PickUpHead {Owner = owner, Target = entity, Bonus = Bonus}; diff --git a/Content.Server/AI/Utility/ExpandableActions/Clothing/OuterClothing/EquipAnyOuterClothingExp.cs b/Content.Server/AI/Utility/ExpandableActions/Clothing/OuterClothing/EquipAnyOuterClothingExp.cs index 7dfaf113ac..6c926a62fd 100644 --- a/Content.Server/AI/Utility/ExpandableActions/Clothing/OuterClothing/EquipAnyOuterClothingExp.cs +++ b/Content.Server/AI/Utility/ExpandableActions/Clothing/OuterClothing/EquipAnyOuterClothingExp.cs @@ -9,6 +9,7 @@ using Content.Server.AI.WorldState.States; using Content.Server.AI.WorldState.States.Inventory; using Content.Server.Clothing.Components; using Content.Shared.Inventory; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; namespace Content.Server.AI.Utility.ExpandableActions.Clothing.OuterClothing @@ -37,7 +38,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Clothing.OuterClothing foreach (var entity in context.GetState().GetValue()) { - if (entity.TryGetComponent(out ClothingComponent? clothing) && + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ClothingComponent? clothing) && (clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.OUTERCLOTHING) != 0) { yield return new EquipOuterClothing {Owner = owner, Target = entity, Bonus = Bonus}; diff --git a/Content.Server/AI/Utility/ExpandableActions/Clothing/OuterClothing/PickUpAnyNearbyOuterClothingExp.cs b/Content.Server/AI/Utility/ExpandableActions/Clothing/OuterClothing/PickUpAnyNearbyOuterClothingExp.cs index 965ccf9a78..c7233b45e0 100644 --- a/Content.Server/AI/Utility/ExpandableActions/Clothing/OuterClothing/PickUpAnyNearbyOuterClothingExp.cs +++ b/Content.Server/AI/Utility/ExpandableActions/Clothing/OuterClothing/PickUpAnyNearbyOuterClothingExp.cs @@ -9,6 +9,7 @@ using Content.Server.AI.WorldState.States; using Content.Server.AI.WorldState.States.Clothing; using Content.Server.Clothing.Components; using Content.Shared.Inventory; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; namespace Content.Server.AI.Utility.ExpandableActions.Clothing.OuterClothing @@ -36,7 +37,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Clothing.OuterClothing foreach (var entity in context.GetState().GetValue()) { - if (entity.TryGetComponent(out ClothingComponent? clothing) && + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ClothingComponent? clothing) && (clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.OUTERCLOTHING) != 0) { yield return new PickUpOuterClothing {Owner = owner, Target = entity, Bonus = Bonus}; diff --git a/Content.Server/AI/Utility/ExpandableActions/Clothing/Shoes/EquipAnyShoesExp.cs b/Content.Server/AI/Utility/ExpandableActions/Clothing/Shoes/EquipAnyShoesExp.cs index a5192d9a8e..2e6997a86b 100644 --- a/Content.Server/AI/Utility/ExpandableActions/Clothing/Shoes/EquipAnyShoesExp.cs +++ b/Content.Server/AI/Utility/ExpandableActions/Clothing/Shoes/EquipAnyShoesExp.cs @@ -9,6 +9,7 @@ using Content.Server.AI.WorldState.States; using Content.Server.AI.WorldState.States.Inventory; using Content.Server.Clothing.Components; using Content.Shared.Inventory; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Shoes @@ -37,7 +38,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Shoes foreach (var entity in context.GetState().GetValue()) { - if (entity.TryGetComponent(out ClothingComponent? clothing) && + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ClothingComponent? clothing) && (clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.SHOES) != 0) { yield return new EquipShoes {Owner = owner, Target = entity, Bonus = Bonus}; diff --git a/Content.Server/AI/Utility/ExpandableActions/Clothing/Shoes/PickUpAnyNearbyShoesExp.cs b/Content.Server/AI/Utility/ExpandableActions/Clothing/Shoes/PickUpAnyNearbyShoesExp.cs index 404db0235b..102946b4ae 100644 --- a/Content.Server/AI/Utility/ExpandableActions/Clothing/Shoes/PickUpAnyNearbyShoesExp.cs +++ b/Content.Server/AI/Utility/ExpandableActions/Clothing/Shoes/PickUpAnyNearbyShoesExp.cs @@ -9,6 +9,7 @@ using Content.Server.AI.WorldState.States; using Content.Server.AI.WorldState.States.Clothing; using Content.Server.Clothing.Components; using Content.Shared.Inventory; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Shoes @@ -36,7 +37,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Clothing.Shoes foreach (var entity in context.GetState().GetValue()) { - if (entity.TryGetComponent(out ClothingComponent? clothing) && + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ClothingComponent? clothing) && (clothing.SlotFlags & EquipmentSlotDefines.SlotFlags.SHOES) != 0) { yield return new PickUpShoes {Owner = owner, Target = entity, Bonus = Bonus}; diff --git a/Content.Server/AI/Utility/ExpandableActions/Combat/Melee/MeleeAttackNearbyExp.cs b/Content.Server/AI/Utility/ExpandableActions/Combat/Melee/MeleeAttackNearbyExp.cs index 7b8f7d8144..6b46fcc898 100644 --- a/Content.Server/AI/Utility/ExpandableActions/Combat/Melee/MeleeAttackNearbyExp.cs +++ b/Content.Server/AI/Utility/ExpandableActions/Combat/Melee/MeleeAttackNearbyExp.cs @@ -31,7 +31,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Combat.Melee public override IEnumerable GetActions(Blackboard context) { var owner = context.GetState().GetValue(); - if (!owner.TryGetComponent(out AiControllerComponent? controller)) + if (!IoCManager.Resolve().TryGetComponent(owner.Uid, out AiControllerComponent? controller)) { throw new InvalidOperationException(); } diff --git a/Content.Server/AI/Utility/ExpandableActions/Combat/Melee/UnarmedAttackNearbyHostilesExp.cs b/Content.Server/AI/Utility/ExpandableActions/Combat/Melee/UnarmedAttackNearbyHostilesExp.cs index 97e88c1536..d2441b5b62 100644 --- a/Content.Server/AI/Utility/ExpandableActions/Combat/Melee/UnarmedAttackNearbyHostilesExp.cs +++ b/Content.Server/AI/Utility/ExpandableActions/Combat/Melee/UnarmedAttackNearbyHostilesExp.cs @@ -31,7 +31,7 @@ namespace Content.Server.AI.Utility.ExpandableActions.Combat.Melee public override IEnumerable GetActions(Blackboard context) { var owner = context.GetState().GetValue(); - if (!owner.TryGetComponent(out AiControllerComponent? controller)) + if (!IoCManager.Resolve().TryGetComponent(owner.Uid, out AiControllerComponent? controller)) { throw new InvalidOperationException(); } diff --git a/Content.Server/AI/WorldState/States/Clothing/EquippedClothingState.cs b/Content.Server/AI/WorldState/States/Clothing/EquippedClothingState.cs index c9d642ad04..e5d3fa6676 100644 --- a/Content.Server/AI/WorldState/States/Clothing/EquippedClothingState.cs +++ b/Content.Server/AI/WorldState/States/Clothing/EquippedClothingState.cs @@ -3,6 +3,7 @@ using Content.Server.Inventory.Components; using Content.Shared.Inventory; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.WorldState.States.Clothing { @@ -15,7 +16,7 @@ namespace Content.Server.AI.WorldState.States.Clothing { var result = new Dictionary(); - if (!Owner.TryGetComponent(out InventoryComponent? inventoryComponent)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out InventoryComponent? inventoryComponent)) { return result; } diff --git a/Content.Server/AI/WorldState/States/Clothing/NearbyClothingState.cs b/Content.Server/AI/WorldState/States/Clothing/NearbyClothingState.cs index 3d10e1c619..02420aa344 100644 --- a/Content.Server/AI/WorldState/States/Clothing/NearbyClothingState.cs +++ b/Content.Server/AI/WorldState/States/Clothing/NearbyClothingState.cs @@ -19,7 +19,7 @@ namespace Content.Server.AI.WorldState.States.Clothing { var result = new List(); - if (!Owner.TryGetComponent(out AiControllerComponent? controller)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out AiControllerComponent? controller)) { return result; } diff --git a/Content.Server/AI/WorldState/States/Combat/Nearby/NearbyMeleeWeapons.cs b/Content.Server/AI/WorldState/States/Combat/Nearby/NearbyMeleeWeapons.cs index ad817ed313..4bf667902b 100644 --- a/Content.Server/AI/WorldState/States/Combat/Nearby/NearbyMeleeWeapons.cs +++ b/Content.Server/AI/WorldState/States/Combat/Nearby/NearbyMeleeWeapons.cs @@ -4,6 +4,7 @@ using Content.Server.AI.Utils; using Content.Server.Weapon.Melee.Components; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.WorldState.States.Combat.Nearby { @@ -16,7 +17,7 @@ namespace Content.Server.AI.WorldState.States.Combat.Nearby { var result = new List(); - if (!Owner.TryGetComponent(out AiControllerComponent? controller)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out AiControllerComponent? controller)) { return result; } diff --git a/Content.Server/AI/WorldState/States/Hands/AnyFreeHandState.cs b/Content.Server/AI/WorldState/States/Hands/AnyFreeHandState.cs index d960685999..b7209dab07 100644 --- a/Content.Server/AI/WorldState/States/Hands/AnyFreeHandState.cs +++ b/Content.Server/AI/WorldState/States/Hands/AnyFreeHandState.cs @@ -1,5 +1,7 @@ using Content.Server.Hands.Components; using JetBrains.Annotations; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.WorldState.States.Hands { @@ -9,7 +11,7 @@ namespace Content.Server.AI.WorldState.States.Hands public override string Name => "AnyFreeHand"; public override bool GetValue() { - if (!Owner.TryGetComponent(out HandsComponent? handsComponent)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out HandsComponent? handsComponent)) { return false; } diff --git a/Content.Server/AI/WorldState/States/Hands/FreeHands.cs b/Content.Server/AI/WorldState/States/Hands/FreeHands.cs index 5214d65ea2..7e295419ca 100644 --- a/Content.Server/AI/WorldState/States/Hands/FreeHands.cs +++ b/Content.Server/AI/WorldState/States/Hands/FreeHands.cs @@ -1,6 +1,8 @@ using System.Collections.Generic; using Content.Server.Hands.Components; using JetBrains.Annotations; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.WorldState.States.Hands { @@ -13,7 +15,7 @@ namespace Content.Server.AI.WorldState.States.Hands { var result = new List(); - if (!Owner.TryGetComponent(out HandsComponent? handsComponent)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out HandsComponent? handsComponent)) { return result; } diff --git a/Content.Server/AI/WorldState/States/Hands/HandItemsState.cs b/Content.Server/AI/WorldState/States/Hands/HandItemsState.cs index 7651afcbc6..e35818ab03 100644 --- a/Content.Server/AI/WorldState/States/Hands/HandItemsState.cs +++ b/Content.Server/AI/WorldState/States/Hands/HandItemsState.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using Content.Server.Hands.Components; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.WorldState.States.Hands { @@ -12,7 +13,7 @@ namespace Content.Server.AI.WorldState.States.Hands public override List GetValue() { var result = new List(); - if (!Owner.TryGetComponent(out HandsComponent? handsComponent)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out HandsComponent? handsComponent)) { return result; } diff --git a/Content.Server/AI/WorldState/States/Inventory/EquippedEntityState.cs b/Content.Server/AI/WorldState/States/Inventory/EquippedEntityState.cs index f4615a6e52..556a31468b 100644 --- a/Content.Server/AI/WorldState/States/Inventory/EquippedEntityState.cs +++ b/Content.Server/AI/WorldState/States/Inventory/EquippedEntityState.cs @@ -1,6 +1,7 @@ using Content.Server.Hands.Components; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.WorldState.States.Inventory { @@ -14,7 +15,7 @@ namespace Content.Server.AI.WorldState.States.Inventory public override IEntity? GetValue() { - if (!Owner.TryGetComponent(out HandsComponent? handsComponent)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out HandsComponent? handsComponent)) { return null; } diff --git a/Content.Server/AI/WorldState/States/Inventory/InventoryState.cs b/Content.Server/AI/WorldState/States/Inventory/InventoryState.cs index fbc7af7d66..d058d6d8af 100644 --- a/Content.Server/AI/WorldState/States/Inventory/InventoryState.cs +++ b/Content.Server/AI/WorldState/States/Inventory/InventoryState.cs @@ -13,7 +13,7 @@ namespace Content.Server.AI.WorldState.States.Inventory public override IEnumerable GetValue() { - if (Owner.TryGetComponent(out HandsComponent? handsComponent)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out HandsComponent? handsComponent)) { foreach (var item in handsComponent.GetAllHeldItems()) { diff --git a/Content.Server/AI/WorldState/States/Mobs/NearbyBodiesState.cs b/Content.Server/AI/WorldState/States/Mobs/NearbyBodiesState.cs index 1c20b224fa..36a3d346a9 100644 --- a/Content.Server/AI/WorldState/States/Mobs/NearbyBodiesState.cs +++ b/Content.Server/AI/WorldState/States/Mobs/NearbyBodiesState.cs @@ -4,6 +4,7 @@ using Content.Server.AI.Utils; using Content.Shared.Body.Components; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.WorldState.States.Mobs { @@ -16,7 +17,7 @@ namespace Content.Server.AI.WorldState.States.Mobs { var result = new List(); - if (!Owner.TryGetComponent(out AiControllerComponent? controller)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out AiControllerComponent? controller)) { return result; } diff --git a/Content.Server/AI/WorldState/States/Mobs/NearbyPlayersState.cs b/Content.Server/AI/WorldState/States/Mobs/NearbyPlayersState.cs index 8e05c82751..646e061fb8 100644 --- a/Content.Server/AI/WorldState/States/Mobs/NearbyPlayersState.cs +++ b/Content.Server/AI/WorldState/States/Mobs/NearbyPlayersState.cs @@ -20,7 +20,7 @@ namespace Content.Server.AI.WorldState.States.Mobs { var result = new List(); - if (!Owner.TryGetComponent(out AiControllerComponent? controller)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out AiControllerComponent? controller)) { return result; } diff --git a/Content.Server/AI/WorldState/States/Nutrition/HungryState.cs b/Content.Server/AI/WorldState/States/Nutrition/HungryState.cs index 4f29487228..a75252d5ec 100644 --- a/Content.Server/AI/WorldState/States/Nutrition/HungryState.cs +++ b/Content.Server/AI/WorldState/States/Nutrition/HungryState.cs @@ -2,6 +2,8 @@ using System; using Content.Server.Nutrition.Components; using Content.Shared.Nutrition.Components; using JetBrains.Annotations; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.WorldState.States.Nutrition { @@ -12,7 +14,7 @@ namespace Content.Server.AI.WorldState.States.Nutrition public override bool GetValue() { - if (!Owner.TryGetComponent(out HungerComponent? hungerComponent)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out HungerComponent? hungerComponent)) { return false; } diff --git a/Content.Server/AI/WorldState/States/Nutrition/NearbyDrinkState.cs b/Content.Server/AI/WorldState/States/Nutrition/NearbyDrinkState.cs index 9b25c5fda4..a14a01e626 100644 --- a/Content.Server/AI/WorldState/States/Nutrition/NearbyDrinkState.cs +++ b/Content.Server/AI/WorldState/States/Nutrition/NearbyDrinkState.cs @@ -19,7 +19,7 @@ namespace Content.Server.AI.WorldState.States.Nutrition { var result = new List(); - if (!Owner.TryGetComponent(out AiControllerComponent? controller)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out AiControllerComponent? controller)) { return result; } diff --git a/Content.Server/AI/WorldState/States/Nutrition/NearbyFoodState.cs b/Content.Server/AI/WorldState/States/Nutrition/NearbyFoodState.cs index 728344bc21..332b15809b 100644 --- a/Content.Server/AI/WorldState/States/Nutrition/NearbyFoodState.cs +++ b/Content.Server/AI/WorldState/States/Nutrition/NearbyFoodState.cs @@ -19,7 +19,7 @@ namespace Content.Server.AI.WorldState.States.Nutrition { var result = new List(); - if (!Owner.TryGetComponent(out AiControllerComponent? controller)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out AiControllerComponent? controller)) { return result; } diff --git a/Content.Server/AI/WorldState/States/Nutrition/ThirstyState.cs b/Content.Server/AI/WorldState/States/Nutrition/ThirstyState.cs index e9c120e91a..94c11b6120 100644 --- a/Content.Server/AI/WorldState/States/Nutrition/ThirstyState.cs +++ b/Content.Server/AI/WorldState/States/Nutrition/ThirstyState.cs @@ -2,6 +2,8 @@ using System; using Content.Server.Nutrition.Components; using Content.Shared.Nutrition.Components; using JetBrains.Annotations; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.WorldState.States.Nutrition { @@ -12,7 +14,7 @@ namespace Content.Server.AI.WorldState.States.Nutrition public override bool GetValue() { - if (!Owner.TryGetComponent(out ThirstComponent? thirstComponent)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out ThirstComponent? thirstComponent)) { return false; } diff --git a/Content.Server/AME/AMENodeGroup.cs b/Content.Server/AME/AMENodeGroup.cs index 23b01bcb18..b459c84e78 100644 --- a/Content.Server/AME/AMENodeGroup.cs +++ b/Content.Server/AME/AMENodeGroup.cs @@ -46,7 +46,7 @@ namespace Content.Server.AME foreach (var node in groupNodes) { var nodeOwner = node.Owner; - if (nodeOwner.TryGetComponent(out AMEShieldComponent? shield)) + if (IoCManager.Resolve().TryGetComponent(nodeOwner.Uid, out AMEShieldComponent? shield)) { var nodeNeighbors = grid.GetCellsInSquareArea(nodeOwner.Transform.Coordinates, 1) .Select(sgc => IoCManager.Resolve().GetEntity(sgc)) @@ -69,7 +69,7 @@ namespace Content.Server.AME foreach (var node in groupNodes) { var nodeOwner = node.Owner; - if (nodeOwner.TryGetComponent(out AMEControllerComponent? controller)) + if (IoCManager.Resolve().TryGetComponent(nodeOwner.Uid, out AMEControllerComponent? controller)) { if (_masterController == null) { diff --git a/Content.Server/AME/Components/AMEControllerComponent.cs b/Content.Server/AME/Components/AMEControllerComponent.cs index 71850393d9..1d18b4c13d 100644 --- a/Content.Server/AME/Components/AMEControllerComponent.cs +++ b/Content.Server/AME/Components/AMEControllerComponent.cs @@ -38,7 +38,7 @@ namespace Content.Server.AME.Components [DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); [DataField("injectSound")] private SoundSpecifier _injectSound = new SoundPathSpecifier("/Audio/Effects/bang.ogg"); - private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; + private bool Powered => !IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) || receiver.Powered; [ViewVariables] private int _stability = 100; @@ -55,9 +55,9 @@ namespace Content.Server.AME.Components UserInterface.OnReceiveMessage += OnUiReceiveMessage; } - Owner.TryGetComponent(out _appearance); + IoCManager.Resolve().TryGetComponent(Owner.Uid, out _appearance); - Owner.TryGetComponent(out _powerSupplier); + IoCManager.Resolve().TryGetComponent(Owner.Uid, out _powerSupplier); _injecting = false; InjectionAmount = 2; @@ -96,7 +96,7 @@ namespace Content.Server.AME.Components if (jar is null) return; - jar.TryGetComponent(out var fuelJar); + IoCManager.Resolve().TryGetComponent(jar.Uid, out var fuelJar); if (fuelJar != null && _powerSupplier != null) { var availableInject = fuelJar.FuelAmount >= InjectionAmount ? InjectionAmount : fuelJar.FuelAmount; @@ -120,12 +120,12 @@ namespace Content.Server.AME.Components /// Data relevant to the event such as the actor which triggered it. void IActivate.Activate(ActivateEventArgs args) { - if (!args.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) { return; } - if (!args.User.TryGetComponent(out HandsComponent? hands)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out HandsComponent? hands)) { Owner.PopupMessage(args.User, Loc.GetString("ame-controller-component-interact-no-hands-text")); return; @@ -246,7 +246,7 @@ namespace Content.Server.AME.Components _jarSlot.Remove(jar); UpdateUserInterface(); - if (!user.TryGetComponent(out var hands) || !jar.TryGetComponent(out var item)) + if (!IoCManager.Resolve().TryGetComponent(user.Uid, out var hands) || !IoCManager.Resolve().TryGetComponent(jar.Uid, out var item)) return; if (hands.CanPutInHand(item)) hands.PutInHand(item); @@ -290,7 +290,7 @@ namespace Content.Server.AME.Components private AMENodeGroup? GetAMENodeGroup() { - Owner.TryGetComponent(out NodeContainerComponent? nodeContainer); + IoCManager.Resolve().TryGetComponent(Owner.Uid, out NodeContainerComponent? nodeContainer); var engineNodeGroup = nodeContainer?.Nodes.Values .Select(node => node.NodeGroup) @@ -336,7 +336,7 @@ namespace Content.Server.AME.Components async Task IInteractUsing.InteractUsing(InteractUsingEventArgs args) { - if (!args.User.TryGetComponent(out HandsComponent? hands)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out HandsComponent? hands)) { Owner.PopupMessage(args.User, Loc.GetString("ame-controller-component-interact-using-no-hands-text")); return true; @@ -349,7 +349,7 @@ namespace Content.Server.AME.Components } var activeHandEntity = hands.GetActiveHand.Owner; - if (activeHandEntity.TryGetComponent(out var fuelContainer)) + if (IoCManager.Resolve().TryGetComponent(activeHandEntity.Uid, out var fuelContainer)) { if (HasJar) { diff --git a/Content.Server/AME/Components/AMEShieldComponent.cs b/Content.Server/AME/Components/AMEShieldComponent.cs index 33fd8802d5..61faaa5a03 100644 --- a/Content.Server/AME/Components/AMEShieldComponent.cs +++ b/Content.Server/AME/Components/AMEShieldComponent.cs @@ -2,6 +2,7 @@ using Content.Shared.AME; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.ViewVariables; namespace Content.Server.AME.Components @@ -21,8 +22,8 @@ namespace Content.Server.AME.Components protected override void Initialize() { base.Initialize(); - Owner.TryGetComponent(out _appearance); - Owner.TryGetComponent(out _pointLight); + IoCManager.Resolve().TryGetComponent(Owner.Uid, out _appearance); + IoCManager.Resolve().TryGetComponent(Owner.Uid, out _pointLight); } public void SetCore() diff --git a/Content.Server/Access/Components/IdCardConsoleComponent.cs b/Content.Server/Access/Components/IdCardConsoleComponent.cs index be12f74a82..b4c769051e 100644 --- a/Content.Server/Access/Components/IdCardConsoleComponent.cs +++ b/Content.Server/Access/Components/IdCardConsoleComponent.cs @@ -22,7 +22,7 @@ namespace Content.Server.Access.Components [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(IdCardConsoleUiKey.Key); - [ViewVariables] private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; + [ViewVariables] private bool Powered => !IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) || receiver.Powered; protected override void Initialize() { @@ -69,7 +69,7 @@ namespace Content.Server.Access.Components /// private bool PrivilegedIdIsAuthorized() { - if (!Owner.TryGetComponent(out AccessReader? reader)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out AccessReader? reader)) { return true; } diff --git a/Content.Server/Actions/Actions/CombatMode.cs b/Content.Server/Actions/Actions/CombatMode.cs index c00ab41d5d..17ec641b0a 100644 --- a/Content.Server/Actions/Actions/CombatMode.cs +++ b/Content.Server/Actions/Actions/CombatMode.cs @@ -2,6 +2,8 @@ using Content.Server.CombatMode; using Content.Shared.Actions.Behaviors; using Content.Shared.Popups; using JetBrains.Annotations; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Serialization.Manager.Attributes; @@ -13,7 +15,7 @@ namespace Content.Server.Actions.Actions { public bool DoToggleAction(ToggleActionEventArgs args) { - if (!args.Performer.TryGetComponent(out CombatModeComponent? combatMode)) + if (!IoCManager.Resolve().TryGetComponent(args.Performer.Uid, out CombatModeComponent? combatMode)) { return false; } diff --git a/Content.Server/Actions/Actions/DisarmAction.cs b/Content.Server/Actions/Actions/DisarmAction.cs index d60828fcc6..837179d9a7 100644 --- a/Content.Server/Actions/Actions/DisarmAction.cs +++ b/Content.Server/Actions/Actions/DisarmAction.cs @@ -55,7 +55,7 @@ namespace Content.Server.Actions.Actions if (disarmedActs.Length == 0) { - if (args.Performer.TryGetComponent(out ActorComponent? actor)) + if (IoCManager.Resolve().TryGetComponent(args.Performer.Uid, out ActorComponent? actor)) { // Fall back to a normal interaction with the entity var player = actor.PlayerSession; @@ -68,7 +68,7 @@ namespace Content.Server.Actions.Actions return; } - if (!args.Performer.TryGetComponent(out var actions)) return; + if (!IoCManager.Resolve().TryGetComponent(args.Performer.Uid, out var actions)) return; if (args.Target == args.Performer || !EntitySystem.Get().CanAttack(args.Performer.Uid)) return; var random = IoCManager.Resolve(); diff --git a/Content.Server/Actions/Actions/GhostBoo.cs b/Content.Server/Actions/Actions/GhostBoo.cs index 150cd487e7..43c25d2dad 100644 --- a/Content.Server/Actions/Actions/GhostBoo.cs +++ b/Content.Server/Actions/Actions/GhostBoo.cs @@ -23,7 +23,7 @@ namespace Content.Server.Actions.Actions public void DoInstantAction(InstantActionEventArgs args) { - if (!args.Performer.TryGetComponent(out var actions)) return; + if (!IoCManager.Resolve().TryGetComponent(args.Performer.Uid, out var actions)) return; // find all IGhostBooAffected nearby and do boo on them var ents = IoCManager.Resolve().GetEntitiesInRange(args.Performer, _radius); diff --git a/Content.Server/Actions/Actions/ScreamAction.cs b/Content.Server/Actions/Actions/ScreamAction.cs index ee3e6952e8..f050337fd5 100644 --- a/Content.Server/Actions/Actions/ScreamAction.cs +++ b/Content.Server/Actions/Actions/ScreamAction.cs @@ -42,8 +42,8 @@ namespace Content.Server.Actions.Actions public void DoInstantAction(InstantActionEventArgs args) { if (!EntitySystem.Get().CanSpeak(args.Performer.Uid)) return; - if (!args.Performer.TryGetComponent(out var humanoid)) return; - if (!args.Performer.TryGetComponent(out var actions)) return; + if (!IoCManager.Resolve().TryGetComponent(args.Performer.Uid, out var humanoid)) return; + if (!IoCManager.Resolve().TryGetComponent(args.Performer.Uid, out var actions)) return; if (_random.Prob(.01f)) { diff --git a/Content.Server/Actions/Commands/GrantAction.cs b/Content.Server/Actions/Commands/GrantAction.cs index b864e904ff..376d3e3687 100644 --- a/Content.Server/Actions/Commands/GrantAction.cs +++ b/Content.Server/Actions/Commands/GrantAction.cs @@ -5,6 +5,7 @@ using Content.Shared.Actions; using Content.Shared.Administration; using Robust.Server.Player; using Robust.Shared.Console; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; namespace Content.Server.Actions.Commands @@ -27,7 +28,7 @@ namespace Content.Server.Actions.Commands } if (attachedEntity == null) return; - if (!attachedEntity.TryGetComponent(out ServerActionsComponent? actionsComponent)) + if (!IoCManager.Resolve().TryGetComponent(attachedEntity.Uid, out ServerActionsComponent? actionsComponent)) { shell.WriteLine("user has no actions component"); return; diff --git a/Content.Server/Actions/Commands/RevokeAction.cs b/Content.Server/Actions/Commands/RevokeAction.cs index 4366c7fca3..4b657e8ffd 100644 --- a/Content.Server/Actions/Commands/RevokeAction.cs +++ b/Content.Server/Actions/Commands/RevokeAction.cs @@ -5,6 +5,7 @@ using Content.Shared.Actions; using Content.Shared.Administration; using Robust.Server.Player; using Robust.Shared.Console; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; namespace Content.Server.Actions.Commands @@ -27,7 +28,7 @@ namespace Content.Server.Actions.Commands if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return; } if (attachedEntity == null) return; - if (!attachedEntity.TryGetComponent(out ServerActionsComponent? actionsComponent)) + if (!IoCManager.Resolve().TryGetComponent(attachedEntity.Uid, out ServerActionsComponent? actionsComponent)) { shell.WriteLine("user has no actions component"); return; diff --git a/Content.Server/Actions/ServerActionsComponent.cs b/Content.Server/Actions/ServerActionsComponent.cs index 145ea23cf6..c5a66cd39c 100644 --- a/Content.Server/Actions/ServerActionsComponent.cs +++ b/Content.Server/Actions/ServerActionsComponent.cs @@ -160,7 +160,7 @@ namespace Content.Server.Actions return null; } - if (!item.TryGetComponent(out var actionsComponent)) + if (!IoCManager.Resolve().TryGetComponent(item.Uid, out var actionsComponent)) { Logger.DebugS("action", "user {0} attempted to perform" + " item action {1} for item {2} which has no ItemActionsComponent", diff --git a/Content.Server/Actions/Spells/GiveItemSpell.cs b/Content.Server/Actions/Spells/GiveItemSpell.cs index 9d1eb142eb..7e2faf84fc 100644 --- a/Content.Server/Actions/Spells/GiveItemSpell.cs +++ b/Content.Server/Actions/Spells/GiveItemSpell.cs @@ -36,7 +36,7 @@ namespace Content.Server.Actions.Spells { var caster = args.Performer; - if (!caster.TryGetComponent(out HandsComponent? handsComponent)) + if (!IoCManager.Resolve().TryGetComponent(caster.Uid, out HandsComponent? handsComponent)) { caster.PopupMessage(Loc.GetString("spell-fail-no-hands")); return; @@ -54,7 +54,7 @@ namespace Content.Server.Actions.Spells // TODO: Look this is shitty and ideally a test would do it var spawnedProto = IoCManager.Resolve().SpawnEntity(ItemProto, caster.Transform.MapPosition); - if (!spawnedProto.TryGetComponent(out ItemComponent? itemComponent)) + if (!IoCManager.Resolve().TryGetComponent(spawnedProto.Uid, out ItemComponent? itemComponent)) { Logger.Error($"Tried to use {nameof(GiveItemSpell)} but prototype has no {nameof(ItemComponent)}?"); IoCManager.Resolve().DeleteEntity(spawnedProto.Uid); diff --git a/Content.Server/Administration/AdminVerbSystem.cs b/Content.Server/Administration/AdminVerbSystem.cs index 5003573e0a..ba715fe8cc 100644 --- a/Content.Server/Administration/AdminVerbSystem.cs +++ b/Content.Server/Administration/AdminVerbSystem.cs @@ -56,7 +56,7 @@ namespace Content.Server.Administration private void AddDebugVerbs(GetOtherVerbsEvent args) { - if (!args.User.TryGetComponent(out var actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out var actor)) return; var player = actor.PlayerSession; @@ -89,7 +89,7 @@ namespace Content.Server.Administration if (_groupController.CanCommand(player, "controlmob") && args.User != args.Target && IoCManager.Resolve().HasComponent(args.User.Uid) && - args.Target.TryGetComponent(out var targetMind)) + IoCManager.Resolve().TryGetComponent(args.Target.Uid, out var targetMind)) { Verb verb = new(); verb.Text = Loc.GetString("control-mob-verb-get-data-text"); @@ -127,7 +127,7 @@ namespace Content.Server.Administration { var coords = args.Target.Transform.Coordinates; Timer.Spawn(_gameTiming.TickPeriod, () => _explosions.SpawnExplosion(coords, 0, 1, 2, 1), CancellationToken.None); - if (args.Target.TryGetComponent(out SharedBodyComponent? body)) + if (IoCManager.Resolve().TryGetComponent(args.Target.Uid, out SharedBodyComponent? body)) { body.Gib(); } @@ -168,7 +168,7 @@ namespace Content.Server.Administration // Get Disposal tube direction verb if (_groupController.CanCommand(player, "tubeconnections") && - args.Target.TryGetComponent(out var tube)) + IoCManager.Resolve().TryGetComponent(args.Target.Uid, out var tube)) { Verb verb = new(); verb.Text = Loc.GetString("tube-direction-verb-get-data-text"); @@ -194,7 +194,7 @@ namespace Content.Server.Administration // Configuration verb. Is this even used for anything!? if (_groupController.CanAdminMenu(player) && - args.Target.TryGetComponent(out var config)) + IoCManager.Resolve().TryGetComponent(args.Target.Uid, out var config)) { Verb verb = new(); verb.Text = Loc.GetString("configure-verb-get-data-text"); diff --git a/Content.Server/Administration/Commands/ControlMob.cs b/Content.Server/Administration/Commands/ControlMob.cs index 3c5d70f1e3..49e89db485 100644 --- a/Content.Server/Administration/Commands/ControlMob.cs +++ b/Content.Server/Administration/Commands/ControlMob.cs @@ -50,7 +50,7 @@ namespace Content.Server.Administration.Commands } var target = entityManager.GetEntity(eUid); - if (!target.TryGetComponent(out MindComponent? mindComponent)) + if (!IoCManager.Resolve().TryGetComponent(target.Uid, out MindComponent? mindComponent)) { shell.WriteLine(Loc.GetString("shell-entity-is-not-mob")); return; diff --git a/Content.Server/Administration/Commands/RejuvenateCommand.cs b/Content.Server/Administration/Commands/RejuvenateCommand.cs index 9bf43f5aca..189aad25cc 100644 --- a/Content.Server/Administration/Commands/RejuvenateCommand.cs +++ b/Content.Server/Administration/Commands/RejuvenateCommand.cs @@ -59,17 +59,17 @@ namespace Content.Server.Administration.Commands EntitySystem.Get().TryRemoveAllStatusEffects(target.Uid); - if (target.TryGetComponent(out FlammableComponent? flammable)) + if (IoCManager.Resolve().TryGetComponent(target.Uid, out FlammableComponent? flammable)) { EntitySystem.Get().Extinguish(target.Uid, flammable); } - if (target.TryGetComponent(out DamageableComponent? damageable)) + if (IoCManager.Resolve().TryGetComponent(target.Uid, out DamageableComponent? damageable)) { EntitySystem.Get().SetAllDamage(damageable, 0); } - if (target.TryGetComponent(out CreamPiedComponent? creamPied)) + if (IoCManager.Resolve().TryGetComponent(target.Uid, out CreamPiedComponent? creamPied)) { EntitySystem.Get().SetCreamPied(target.Uid, creamPied, false); } diff --git a/Content.Server/Administration/Commands/SetOutfitCommand.cs b/Content.Server/Administration/Commands/SetOutfitCommand.cs index f2b3bd74a5..211b420f54 100644 --- a/Content.Server/Administration/Commands/SetOutfitCommand.cs +++ b/Content.Server/Administration/Commands/SetOutfitCommand.cs @@ -53,7 +53,7 @@ namespace Content.Server.Administration.Commands var target = entityManager.GetEntity(eUid); - if (!target.TryGetComponent(out var inventoryComponent)) + if (!IoCManager.Resolve().TryGetComponent(target.Uid, out var inventoryComponent)) { shell.WriteLine(Loc.GetString("shell-target-entity-does-not-have-message",("missing", "inventory"))); return; @@ -82,7 +82,7 @@ namespace Content.Server.Administration.Commands HumanoidCharacterProfile? profile = null; // Check if we are setting the outfit of a player to respect the preferences - if (target.TryGetComponent(out var actorComponent)) + if (IoCManager.Resolve().TryGetComponent(target.Uid, out var actorComponent)) { var userId = actorComponent.PlayerSession.UserId; var preferencesManager = IoCManager.Resolve(); @@ -100,7 +100,7 @@ namespace Content.Server.Administration.Commands } var equipmentEntity = entityManager.SpawnEntity(gearStr, target.Transform.Coordinates); if (slot == EquipmentSlotDefines.Slots.IDCARD && - equipmentEntity.TryGetComponent(out var pdaComponent) && + IoCManager.Resolve().TryGetComponent(equipmentEntity.Uid, out var pdaComponent) && pdaComponent.ContainedID != null) { pdaComponent.ContainedID.FullName = target.Name; diff --git a/Content.Server/Administration/Commands/WarpCommand.cs b/Content.Server/Administration/Commands/WarpCommand.cs index f37c366782..359f56aae1 100644 --- a/Content.Server/Administration/Commands/WarpCommand.cs +++ b/Content.Server/Administration/Commands/WarpCommand.cs @@ -114,7 +114,7 @@ namespace Content.Server.Administration.Commands if (found.GetGridId(entMan) != GridId.Invalid) { player.AttachedEntity.Transform.Coordinates = found; - if (player.AttachedEntity.TryGetComponent(out IPhysBody? physics)) + if (IoCManager.Resolve().TryGetComponent(player.AttachedEntity.Uid, out IPhysBody? physics)) { physics.LinearVelocity = Vector2.Zero; } diff --git a/Content.Server/Alert/Click/ResistFire.cs b/Content.Server/Alert/Click/ResistFire.cs index 94d0e594dc..344be21afc 100644 --- a/Content.Server/Alert/Click/ResistFire.cs +++ b/Content.Server/Alert/Click/ResistFire.cs @@ -3,6 +3,7 @@ using Content.Server.Atmos.EntitySystems; using Content.Shared.Alert; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.Alert.Click @@ -16,7 +17,7 @@ namespace Content.Server.Alert.Click { public void AlertClicked(ClickAlertEventArgs args) { - if (args.Player.TryGetComponent(out FlammableComponent? flammable)) + if (IoCManager.Resolve().TryGetComponent(args.Player.Uid, out FlammableComponent? flammable)) { EntitySystem.Get().Resist(args.Player.Uid, flammable); } diff --git a/Content.Server/Alert/Click/StopBeingPulled.cs b/Content.Server/Alert/Click/StopBeingPulled.cs index f69fe44661..a7b35117e1 100644 --- a/Content.Server/Alert/Click/StopBeingPulled.cs +++ b/Content.Server/Alert/Click/StopBeingPulled.cs @@ -4,6 +4,7 @@ using Content.Shared.Pulling.Components; using Content.Shared.Pulling; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.Alert.Click @@ -20,7 +21,7 @@ namespace Content.Server.Alert.Click if (!EntitySystem.Get().CanInteract(args.Player.Uid)) return; - if (args.Player.TryGetComponent(out var playerPullable)) + if (IoCManager.Resolve().TryGetComponent(args.Player.Uid, out var playerPullable)) { EntitySystem.Get().TryStopPull(playerPullable); } diff --git a/Content.Server/Alert/Click/StopPiloting.cs b/Content.Server/Alert/Click/StopPiloting.cs index 64b6841a70..22970eff55 100644 --- a/Content.Server/Alert/Click/StopPiloting.cs +++ b/Content.Server/Alert/Click/StopPiloting.cs @@ -5,6 +5,7 @@ using Content.Shared.Shuttles; using Content.Shared.Shuttles.Components; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.Alert.Click @@ -18,7 +19,7 @@ namespace Content.Server.Alert.Click { public void AlertClicked(ClickAlertEventArgs args) { - if (args.Player.TryGetComponent(out PilotComponent? pilotComponent) && + if (IoCManager.Resolve().TryGetComponent(args.Player.Uid, out PilotComponent? pilotComponent) && pilotComponent.Console != null) { EntitySystem.Get().RemovePilot(pilotComponent); diff --git a/Content.Server/Alert/Click/Unbuckle.cs b/Content.Server/Alert/Click/Unbuckle.cs index 38ac730bfc..435f0c1e02 100644 --- a/Content.Server/Alert/Click/Unbuckle.cs +++ b/Content.Server/Alert/Click/Unbuckle.cs @@ -1,6 +1,8 @@ using Content.Server.Buckle.Components; using Content.Shared.Alert; using JetBrains.Annotations; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.Alert.Click @@ -14,7 +16,7 @@ namespace Content.Server.Alert.Click { public void AlertClicked(ClickAlertEventArgs args) { - if (args.Player.TryGetComponent(out BuckleComponent? buckle)) + if (IoCManager.Resolve().TryGetComponent(args.Player.Uid, out BuckleComponent? buckle)) { buckle.TryUnbuckle(args.Player); } diff --git a/Content.Server/Alert/Commands/ClearAlert.cs b/Content.Server/Alert/Commands/ClearAlert.cs index 3ddc04a72d..93d89bb895 100644 --- a/Content.Server/Alert/Commands/ClearAlert.cs +++ b/Content.Server/Alert/Commands/ClearAlert.cs @@ -5,6 +5,7 @@ using Content.Shared.Administration; using Content.Shared.Alert; using Robust.Server.Player; using Robust.Shared.Console; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; namespace Content.Server.Alert.Commands @@ -33,7 +34,7 @@ namespace Content.Server.Alert.Commands if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return; } - if (!attachedEntity.TryGetComponent(out ServerAlertsComponent? alertsComponent)) + if (!IoCManager.Resolve().TryGetComponent(attachedEntity.Uid, out ServerAlertsComponent? alertsComponent)) { shell.WriteLine("user has no alerts component"); return; diff --git a/Content.Server/Alert/Commands/ShowAlert.cs b/Content.Server/Alert/Commands/ShowAlert.cs index 05cf1397a8..e63be7a72e 100644 --- a/Content.Server/Alert/Commands/ShowAlert.cs +++ b/Content.Server/Alert/Commands/ShowAlert.cs @@ -5,6 +5,7 @@ using Content.Shared.Administration; using Content.Shared.Alert; using Robust.Server.Player; using Robust.Shared.Console; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; namespace Content.Server.Alert.Commands @@ -39,7 +40,7 @@ namespace Content.Server.Alert.Commands if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return; } - if (!attachedEntity.TryGetComponent(out ServerAlertsComponent? alertsComponent)) + if (!IoCManager.Resolve().TryGetComponent(attachedEntity.Uid, out ServerAlertsComponent? alertsComponent)) { shell.WriteLine("user has no alerts component"); return; diff --git a/Content.Server/Animals/Systems/UdderSystem.cs b/Content.Server/Animals/Systems/UdderSystem.cs index 823e42b253..ae56860f15 100644 --- a/Content.Server/Animals/Systems/UdderSystem.cs +++ b/Content.Server/Animals/Systems/UdderSystem.cs @@ -42,7 +42,7 @@ namespace Content.Server.Animals.Systems continue; // Actually there is food digestion so no problem with instant reagent generation "OnFeed" - if (udder.Owner.TryGetComponent(out var hunger)) + if (IoCManager.Resolve().TryGetComponent(udder.Owner.Uid, out var hunger)) { hunger.HungerThresholds.TryGetValue(HungerThreshold.Peckish, out var targetThreshold); diff --git a/Content.Server/Arcade/Components/BlockGameArcadeComponent.cs b/Content.Server/Arcade/Components/BlockGameArcadeComponent.cs index 23ddb79cde..310d2fa14a 100644 --- a/Content.Server/Arcade/Components/BlockGameArcadeComponent.cs +++ b/Content.Server/Arcade/Components/BlockGameArcadeComponent.cs @@ -49,7 +49,7 @@ namespace Content.Server.Arcade.Components void IActivate.Activate(ActivateEventArgs eventArgs) { - if(!Powered || !eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if(!Powered || !IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) return; if(!EntitySystem.Get().CanInteract(eventArgs.User.Uid)) diff --git a/Content.Server/Atmos/Components/AtmosPlaqueComponent.cs b/Content.Server/Atmos/Components/AtmosPlaqueComponent.cs index 7723ed90cb..83b2951a4c 100644 --- a/Content.Server/Atmos/Components/AtmosPlaqueComponent.cs +++ b/Content.Server/Atmos/Components/AtmosPlaqueComponent.cs @@ -84,7 +84,7 @@ namespace Content.Server.Atmos.Components _ => "Uhm", }; - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { var state = _type == PlaqueType.Zumos ? "zumosplaque" : "atmosplaque"; diff --git a/Content.Server/Atmos/Components/BreathToolComponent.cs b/Content.Server/Atmos/Components/BreathToolComponent.cs index d1ebbc483c..993eb12da8 100644 --- a/Content.Server/Atmos/Components/BreathToolComponent.cs +++ b/Content.Server/Atmos/Components/BreathToolComponent.cs @@ -1,6 +1,7 @@ using Content.Server.Body.Components; using Content.Shared.Inventory; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.Atmos.Components @@ -32,7 +33,7 @@ namespace Content.Server.Atmos.Components if ((EquipmentSlotDefines.SlotMasks[eventArgs.Slot] & _allowedSlots) != _allowedSlots) return; IsFunctional = true; - if (eventArgs.User.TryGetComponent(out InternalsComponent? internals)) + if (IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out InternalsComponent? internals)) { ConnectedInternalsEntity = eventArgs.User; internals.ConnectBreathTool(Owner); @@ -49,7 +50,7 @@ namespace Content.Server.Atmos.Components var old = ConnectedInternalsEntity; ConnectedInternalsEntity = null; - if (old != null && old.TryGetComponent(out var internalsComponent)) + if (old != null && IoCManager.Resolve().TryGetComponent(old.Uid, out var internalsComponent)) { internalsComponent.DisconnectBreathTool(); } diff --git a/Content.Server/Atmos/Components/GasAnalyzerComponent.cs b/Content.Server/Atmos/Components/GasAnalyzerComponent.cs index 2c452d1068..d15155a6c2 100644 --- a/Content.Server/Atmos/Components/GasAnalyzerComponent.cs +++ b/Content.Server/Atmos/Components/GasAnalyzerComponent.cs @@ -40,7 +40,7 @@ namespace Content.Server.Atmos.Components UserInterface.OnClosed += UserInterfaceOnClose; } - Owner.TryGetComponent(out _appearance); + IoCManager.Resolve().TryGetComponent(Owner.Uid, out _appearance); } public override ComponentState GetComponentState() @@ -161,11 +161,11 @@ namespace Content.Server.Atmos.Components if (session.AttachedEntity == null) return; - if (!session.AttachedEntity.TryGetComponent(out HandsComponent? handsComponent)) + if (!IoCManager.Resolve().TryGetComponent(session.AttachedEntity.Uid, out HandsComponent? handsComponent)) return; var activeHandEntity = handsComponent?.GetActiveHand?.Owner; - if (activeHandEntity == null || !activeHandEntity.TryGetComponent(out GasAnalyzerComponent? gasAnalyzer)) + if (activeHandEntity == null || !IoCManager.Resolve().TryGetComponent(activeHandEntity.Uid, out GasAnalyzerComponent? gasAnalyzer)) { return; } @@ -226,14 +226,14 @@ namespace Content.Server.Atmos.Components return; } - if (!player.TryGetComponent(out HandsComponent? handsComponent)) + if (!IoCManager.Resolve().TryGetComponent(player.Uid, out HandsComponent? handsComponent)) { Owner.PopupMessage(player, Loc.GetString("gas-analyzer-component-player-has-no-hands-message")); return; } var activeHandEntity = handsComponent.GetActiveHand?.Owner; - if (activeHandEntity == null || !activeHandEntity.TryGetComponent(out GasAnalyzerComponent? gasAnalyzer)) + if (activeHandEntity == null || !IoCManager.Resolve().TryGetComponent(activeHandEntity.Uid, out GasAnalyzerComponent? gasAnalyzer)) { serverMsg.Session.AttachedEntity?.PopupMessage(Loc.GetString("gas-analyzer-component-need-gas-analyzer-in-hand-message")); return; @@ -253,7 +253,7 @@ namespace Content.Server.Atmos.Components return true; } - if (eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if (IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) { OpenInterface(actor.PlayerSession, eventArgs.ClickLocation); } @@ -265,7 +265,7 @@ namespace Content.Server.Atmos.Components void IDropped.Dropped(DroppedEventArgs eventArgs) { - if (eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if (IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) { CloseInterface(actor.PlayerSession); } @@ -273,7 +273,7 @@ namespace Content.Server.Atmos.Components bool IUse.UseEntity(UseEntityEventArgs eventArgs) { - if (eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if (IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) { ToggleInterface(actor.PlayerSession); return true; diff --git a/Content.Server/Atmos/Components/GasTankComponent.cs b/Content.Server/Atmos/Components/GasTankComponent.cs index 22d7812bb9..c31d8b7761 100644 --- a/Content.Server/Atmos/Components/GasTankComponent.cs +++ b/Content.Server/Atmos/Components/GasTankComponent.cs @@ -155,14 +155,14 @@ namespace Content.Server.Atmos.Components bool IUse.UseEntity(UseEntityEventArgs eventArgs) { - if (!eventArgs.User.TryGetComponent(out ActorComponent? actor)) return false; + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) return false; OpenInterface(actor.PlayerSession); return true; } void IActivate.Activate(ActivateEventArgs eventArgs) { - if (!eventArgs.User.TryGetComponent(out ActorComponent? actor)) return; + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) return; OpenInterface(actor.PlayerSession); } @@ -328,7 +328,7 @@ namespace Content.Server.Atmos.Components { public bool DoToggleAction(ToggleItemActionEventArgs args) { - if (!args.Item.TryGetComponent(out var gasTankComponent)) return false; + if (!IoCManager.Resolve().TryGetComponent(args.Item.Uid, out var gasTankComponent)) return false; // no change if (gasTankComponent.IsConnected == args.ToggledOn) return false; gasTankComponent.ToggleInternals(); diff --git a/Content.Server/Atmos/Components/MovedByPressureComponent.cs b/Content.Server/Atmos/Components/MovedByPressureComponent.cs index c9787d7e7e..3118f219e8 100644 --- a/Content.Server/Atmos/Components/MovedByPressureComponent.cs +++ b/Content.Server/Atmos/Components/MovedByPressureComponent.cs @@ -42,7 +42,7 @@ namespace Content.Server.Atmos.Components public void ExperiencePressureDifference(int cycle, float pressureDifference, AtmosDirection direction, float pressureResistanceProbDelta, EntityCoordinates throwTarget) { - if (!Owner.TryGetComponent(out PhysicsComponent? physics)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out PhysicsComponent? physics)) return; // TODO ATMOS stuns? @@ -72,7 +72,7 @@ namespace Content.Server.Atmos.Components Owner.SpawnTimer(2000, () => { - if (Deleted || !Owner.TryGetComponent(out PhysicsComponent? physicsComponent)) return; + if (Deleted || !IoCManager.Resolve().TryGetComponent(Owner.Uid, out PhysicsComponent? physicsComponent)) return; // Uhh if you get race conditions good luck buddy. if (IoCManager.Resolve().HasComponent(physicsComponent.Owner.Uid)) @@ -118,7 +118,7 @@ namespace Content.Server.Atmos.Components public static bool IsMovedByPressure(this IEntity entity, [NotNullWhen(true)] out MovedByPressureComponent? moved) { - return entity.TryGetComponent(out moved) && + return IoCManager.Resolve().TryGetComponent(entity.Uid, out moved) && moved.Enabled; } } diff --git a/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs b/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs index f952b6e76d..8225998713 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs @@ -7,6 +7,7 @@ using JetBrains.Annotations; using Robust.Server.Player; using Robust.Shared.Configuration; using Robust.Shared.Enums; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; @@ -142,7 +143,7 @@ namespace Content.Server.Atmos.EntitySystems { if (!EntityManager.TryGetEntity(grid.GridEntityId, out var gridEnt)) continue; - if (!gridEnt.TryGetComponent(out var gam)) continue; + if (!IoCManager.Resolve().TryGetComponent(gridEnt.Uid, out var gam)) continue; var entityTile = grid.GetTileRef(entity.Transform.Coordinates).GridIndices; var baseTile = new Vector2i(entityTile.X - (LocalViewRange / 2), entityTile.Y - (LocalViewRange / 2)); diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs index bb2695edd6..6433bf92bf 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs @@ -1526,7 +1526,7 @@ namespace Content.Server.Atmos.EntitySystems public bool TryGetMapGrid(GridAtmosphereComponent gridAtmosphere, [NotNullWhen(true)] out IMapGrid? mapGrid) { - if (gridAtmosphere.Owner.TryGetComponent(out IMapGridComponent? mapGridComponent)) + if (IoCManager.Resolve().TryGetComponent(gridAtmosphere.Owner.Uid, out IMapGridComponent? mapGridComponent)) { mapGrid = mapGridComponent.Grid; return true; diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs index 846d0be429..ddfea355f7 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs @@ -5,6 +5,7 @@ using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; using Robust.Shared.Physics; @@ -33,7 +34,7 @@ namespace Content.Server.Atmos.EntitySystems foreach (var entity in _gridtileLookupSystem.GetEntitiesIntersecting(tile.GridIndex, tile.GridIndices)) { - if (!entity.TryGetComponent(out IPhysBody? physics) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out IPhysBody? physics) || !entity.IsMovedByPressure(out var pressure) || entity.IsInContainer()) continue; diff --git a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs index f66142f789..151eed66a4 100644 --- a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs +++ b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs @@ -225,7 +225,7 @@ namespace Content.Server.Atmos.EntitySystems flammable.FireStacks = MathF.Min(0, flammable.FireStacks + 1); } - flammable.Owner.TryGetComponent(out ServerAlertsComponent? status); + IoCManager.Resolve().TryGetComponent(flammable.Owner.Uid, out ServerAlertsComponent? status); if (!flammable.OnFire) { diff --git a/Content.Server/Atmos/EntitySystems/GasTankSystem.cs b/Content.Server/Atmos/EntitySystems/GasTankSystem.cs index 3080367c8a..da89e453a2 100644 --- a/Content.Server/Atmos/EntitySystems/GasTankSystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasTankSystem.cs @@ -24,7 +24,7 @@ namespace Content.Server.Atmos.EntitySystems private void AddOpenUIVerb(EntityUid uid, GasTankComponent component, GetActivationVerbsEvent args) { - if (!args.CanAccess || !args.User.TryGetComponent(out var actor)) + if (!args.CanAccess || !IoCManager.Resolve().TryGetComponent(args.User.Uid, out var actor)) return; Verb verb = new(); diff --git a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs index ccfead7f73..d94b32c8e2 100644 --- a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs +++ b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs @@ -92,7 +92,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems private void OnPumpInteractHand(EntityUid uid, GasPressurePumpComponent component, InteractHandEvent args) { - if (!args.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) return; if (component.Owner.Transform.Anchored) diff --git a/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasFilterSystem.cs b/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasFilterSystem.cs index cc4032059a..d0c9d49649 100644 --- a/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasFilterSystem.cs +++ b/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasFilterSystem.cs @@ -81,7 +81,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems private void OnFilterInteractHand(EntityUid uid, GasFilterComponent component, InteractHandEvent args) { - if (!args.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) return; if (component.Owner.Transform.Anchored) diff --git a/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs b/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs index bcb82771b2..ac0aafb41e 100644 --- a/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs +++ b/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs @@ -106,7 +106,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems private void OnMixerInteractHand(EntityUid uid, GasMixerComponent component, InteractHandEvent args) { - if (!args.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) return; if (component.Owner.Transform.Anchored) diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs index ef77be9a34..0fa28d5f2b 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs @@ -244,7 +244,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems private void OnCanisterActivate(EntityUid uid, GasCanisterComponent component, ActivateInWorldEvent args) { - if (!args.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) return; _userInterfaceSystem.GetUiOrNull(uid, GasCanisterUiKey.Key)?.Open(actor.PlayerSession); @@ -254,7 +254,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems private void OnCanisterInteractHand(EntityUid uid, GasCanisterComponent component, InteractHandEvent args) { - if (!args.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) return; _userInterfaceSystem.GetUiOrNull(uid, GasCanisterUiKey.Key)?.Open(actor.PlayerSession); @@ -271,11 +271,11 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems return; // Check the used item is valid... - if (!args.Used.TryGetComponent(out GasTankComponent? _)) + if (!IoCManager.Resolve().TryGetComponent(args.Used.Uid, out GasTankComponent? _)) return; // Check the user has hands. - if (!args.User.TryGetComponent(out HandsComponent? hands)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out HandsComponent? hands)) return; if (!args.User.InRangeUnobstructed(canister, SharedInteractionSystem.InteractionRange, popup: true)) diff --git a/Content.Server/BarSign/Systems/BarSignSystem.cs b/Content.Server/BarSign/Systems/BarSignSystem.cs index 99365b5d33..98df6c1978 100644 --- a/Content.Server/BarSign/Systems/BarSignSystem.cs +++ b/Content.Server/BarSign/Systems/BarSignSystem.cs @@ -67,9 +67,9 @@ namespace Content.Server.BarSign.Systems return; } - if (component.Owner.TryGetComponent(out SpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out SpriteComponent? sprite)) { - if (!component.Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || !receiver.Powered) + if (!IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out ApcPowerReceiverComponent? receiver) || !receiver.Powered) { sprite.LayerSetState(0, "empty"); sprite.LayerSetShader(0, "shaded"); diff --git a/Content.Server/Body/Commands/AttachBodyPartCommand.cs b/Content.Server/Body/Commands/AttachBodyPartCommand.cs index 4264b5cf8e..bb6f88cb03 100644 --- a/Content.Server/Body/Commands/AttachBodyPartCommand.cs +++ b/Content.Server/Body/Commands/AttachBodyPartCommand.cs @@ -73,7 +73,7 @@ namespace Content.Server.Body.Commands return; } - if (!entity.TryGetComponent(out SharedBodyComponent? body)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out SharedBodyComponent? body)) { shell.WriteLine($"Entity {entity.Name} with uid {entity.Uid} does not have a {nameof(SharedBodyComponent)} component."); return; @@ -85,7 +85,7 @@ namespace Content.Server.Body.Commands return; } - if (!partEntity.TryGetComponent(out SharedBodyPartComponent? part)) + if (!IoCManager.Resolve().TryGetComponent(partEntity.Uid, out SharedBodyPartComponent? part)) { shell.WriteLine($"Entity {partEntity.Name} with uid {args[0]} does not have a {nameof(SharedBodyPartComponent)} component."); return; diff --git a/Content.Server/Body/Commands/DestroyMechanismCommand.cs b/Content.Server/Body/Commands/DestroyMechanismCommand.cs index 657e5f3459..f2aa21c433 100644 --- a/Content.Server/Body/Commands/DestroyMechanismCommand.cs +++ b/Content.Server/Body/Commands/DestroyMechanismCommand.cs @@ -3,6 +3,7 @@ using Content.Shared.Administration; using Content.Shared.Body.Components; using Robust.Server.Player; using Robust.Shared.Console; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Random; @@ -36,7 +37,7 @@ namespace Content.Server.Body.Commands return; } - if (!player.AttachedEntity.TryGetComponent(out SharedBodyComponent? body)) + if (!IoCManager.Resolve().TryGetComponent(player.AttachedEntity.Uid, out SharedBodyComponent? body)) { var random = IoCManager.Resolve(); var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}"; diff --git a/Content.Server/Body/Commands/RemoveHandCommand.cs b/Content.Server/Body/Commands/RemoveHandCommand.cs index 184cf7141f..c6a5221d2c 100644 --- a/Content.Server/Body/Commands/RemoveHandCommand.cs +++ b/Content.Server/Body/Commands/RemoveHandCommand.cs @@ -5,6 +5,7 @@ using Content.Shared.Body.Components; using Content.Shared.Body.Part; using Robust.Server.Player; using Robust.Shared.Console; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Random; @@ -32,7 +33,7 @@ namespace Content.Server.Body.Commands return; } - if (!player.AttachedEntity.TryGetComponent(out SharedBodyComponent? body)) + if (!IoCManager.Resolve().TryGetComponent(player.AttachedEntity.Uid, out SharedBodyComponent? body)) { var random = IoCManager.Resolve(); var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}"; diff --git a/Content.Server/Body/Components/BodyComponent.cs b/Content.Server/Body/Components/BodyComponent.cs index a53ee3f57b..a0fb78c782 100644 --- a/Content.Server/Body/Components/BodyComponent.cs +++ b/Content.Server/Body/Components/BodyComponent.cs @@ -60,7 +60,7 @@ namespace Content.Server.Body.Components // a crash within the character preview menu in the lobby var entity = IoCManager.Resolve().SpawnEntity(preset.PartIDs[slot.Id], Owner.Transform.MapPosition); - if (!entity.TryGetComponent(out SharedBodyPartComponent? part)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out SharedBodyPartComponent? part)) { Logger.Error($"Entity {slot.Id} does not have a {nameof(SharedBodyPartComponent)} component."); continue; @@ -90,7 +90,7 @@ namespace Content.Server.Body.Components SoundSystem.Play(Filter.Pvs(Owner), _gibSound.GetSound(), Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.025f)); - if (Owner.TryGetComponent(out ContainerManagerComponent? container)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ContainerManagerComponent? container)) { foreach (var cont in container.GetAllContainers()) { diff --git a/Content.Server/Body/Components/BodyPartComponent.cs b/Content.Server/Body/Components/BodyPartComponent.cs index 2798a6ce9a..dc4ba1b041 100644 --- a/Content.Server/Body/Components/BodyPartComponent.cs +++ b/Content.Server/Body/Components/BodyPartComponent.cs @@ -66,7 +66,7 @@ namespace Content.Server.Body.Components { var entity = IoCManager.Resolve().SpawnEntity(mechanismId, Owner.Transform.MapPosition); - if (!entity.TryGetComponent(out SharedMechanismComponent? mechanism)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out SharedMechanismComponent? mechanism)) { Logger.Error($"Entity {mechanismId} does not have a {nameof(SharedMechanismComponent)} component."); continue; @@ -104,7 +104,7 @@ namespace Content.Server.Body.Components _surgeonCache = null; _owningBodyCache = null; - if (eventArgs.Target.TryGetComponent(out SharedBodyComponent? body)) + if (IoCManager.Resolve().TryGetComponent(eventArgs.Target.Uid, out SharedBodyComponent? body)) { SendSlots(eventArgs, body); } @@ -161,7 +161,7 @@ namespace Content.Server.Body.Components private void ReceiveBodyPartSlot(int key) { if (_surgeonCache == null || - !_surgeonCache.TryGetComponent(out ActorComponent? actor)) + !IoCManager.Resolve().TryGetComponent(_surgeonCache.Uid, out ActorComponent? actor)) { return; } diff --git a/Content.Server/Body/Components/InternalsComponent.cs b/Content.Server/Body/Components/InternalsComponent.cs index 35a027a175..75e6cb9f49 100644 --- a/Content.Server/Body/Components/InternalsComponent.cs +++ b/Content.Server/Body/Components/InternalsComponent.cs @@ -1,5 +1,6 @@ using Content.Server.Atmos.Components; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.ViewVariables; namespace Content.Server.Body.Components @@ -16,7 +17,7 @@ namespace Content.Server.Body.Components var old = BreathToolEntity; BreathToolEntity = null; - if (old != null && old.TryGetComponent(out BreathToolComponent? breathTool) ) + if (old != null && IoCManager.Resolve().TryGetComponent(old.Uid, out BreathToolComponent? breathTool) ) { breathTool.DisconnectInternals(); DisconnectTank(); @@ -25,7 +26,7 @@ namespace Content.Server.Body.Components public void ConnectBreathTool(IEntity toolEntity) { - if (BreathToolEntity != null && BreathToolEntity.TryGetComponent(out BreathToolComponent? tool)) + if (BreathToolEntity != null && IoCManager.Resolve().TryGetComponent(BreathToolEntity.Uid, out BreathToolComponent? tool)) { tool.DisconnectInternals(); } @@ -35,7 +36,7 @@ namespace Content.Server.Body.Components public void DisconnectTank() { - if (GasTankEntity != null && GasTankEntity.TryGetComponent(out GasTankComponent? tank)) + if (GasTankEntity != null && IoCManager.Resolve().TryGetComponent(GasTankEntity.Uid, out GasTankComponent? tank)) { tank.DisconnectFromInternals(Owner); } @@ -48,7 +49,7 @@ namespace Content.Server.Body.Components if (BreathToolEntity == null) return false; - if (GasTankEntity != null && GasTankEntity.TryGetComponent(out GasTankComponent? tank)) + if (GasTankEntity != null && IoCManager.Resolve().TryGetComponent(GasTankEntity.Uid, out GasTankComponent? tank)) { tank.DisconnectFromInternals(Owner); } @@ -61,9 +62,9 @@ namespace Content.Server.Body.Components { return BreathToolEntity != null && GasTankEntity != null && - BreathToolEntity.TryGetComponent(out BreathToolComponent? breathTool) && + IoCManager.Resolve().TryGetComponent(BreathToolEntity.Uid, out BreathToolComponent? breathTool) && breathTool.IsFunctional && - GasTankEntity.TryGetComponent(out GasTankComponent? gasTank) && + IoCManager.Resolve().TryGetComponent(GasTankEntity.Uid, out GasTankComponent? gasTank) && gasTank.Air != null; } diff --git a/Content.Server/Body/Components/MechanismComponent.cs b/Content.Server/Body/Components/MechanismComponent.cs index d95593fe50..589aab450d 100644 --- a/Content.Server/Body/Components/MechanismComponent.cs +++ b/Content.Server/Body/Components/MechanismComponent.cs @@ -9,6 +9,7 @@ using Content.Shared.Popups; using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Utility; using Robust.Shared.ViewVariables; @@ -43,11 +44,11 @@ namespace Content.Server.Body.Components PerformerCache = null; BodyCache = null; - if (eventArgs.Target.TryGetComponent(out SharedBodyComponent? body)) + if (IoCManager.Resolve().TryGetComponent(eventArgs.Target.Uid, out SharedBodyComponent? body)) { SendBodyPartListToUser(eventArgs, body); } - else if (eventArgs.Target.TryGetComponent(out var part)) + else if (IoCManager.Resolve().TryGetComponent(eventArgs.Target.Uid, out var part)) { DebugTools.AssertNotNull(part); @@ -76,7 +77,7 @@ namespace Content.Server.Body.Components } if (OptionsCache.Count > 0 && - eventArgs.User.TryGetComponent(out ActorComponent? actor)) + IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) { OpenSurgeryUI(actor.PlayerSession); UpdateSurgeryUIBodyPartRequest(actor.PlayerSession, toSend); @@ -96,7 +97,7 @@ namespace Content.Server.Body.Components private void HandleReceiveBodyPart(int key) { if (PerformerCache == null || - !PerformerCache.TryGetComponent(out ActorComponent? actor)) + !IoCManager.Resolve().TryGetComponent(PerformerCache.Uid, out ActorComponent? actor)) { return; } diff --git a/Content.Server/Body/Surgery/Components/SurgeryToolComponent.cs b/Content.Server/Body/Surgery/Components/SurgeryToolComponent.cs index 6892b58bb6..4007508af8 100644 --- a/Content.Server/Body/Surgery/Components/SurgeryToolComponent.cs +++ b/Content.Server/Body/Surgery/Components/SurgeryToolComponent.cs @@ -54,7 +54,7 @@ namespace Content.Server.Body.Surgery.Components return false; } - if (!eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) { return false; } @@ -62,7 +62,7 @@ namespace Content.Server.Body.Surgery.Components CloseAllSurgeryUIs(); // Attempt surgery on a body by sending a list of operable parts for the client to choose from - if (eventArgs.Target.TryGetComponent(out SharedBodyComponent? body)) + if (IoCManager.Resolve().TryGetComponent(eventArgs.Target.Uid, out SharedBodyComponent? body)) { // Create dictionary to send to client (text to be shown : data sent back if selected) var toSend = new Dictionary(); @@ -89,7 +89,7 @@ namespace Content.Server.Body.Surgery.Components NotUsefulPopup(); } } - else if (eventArgs.Target.TryGetComponent(out var part)) + else if (IoCManager.Resolve().TryGetComponent(eventArgs.Target.Uid, out var part)) { // Attempt surgery on a DroppedBodyPart - there's only one possible target so no need for selection UI PerformerCache = eventArgs.User; @@ -214,7 +214,7 @@ namespace Content.Server.Body.Surgery.Components private void HandleReceiveBodyPart(int key) { if (PerformerCache == null || - !PerformerCache.TryGetComponent(out ActorComponent? actor)) + !IoCManager.Resolve().TryGetComponent(PerformerCache.Uid, out ActorComponent? actor)) { return; } @@ -248,7 +248,7 @@ namespace Content.Server.Body.Surgery.Components !_optionsCache.TryGetValue(key, out var targetObject) || targetObject is not MechanismComponent target || PerformerCache == null || - !PerformerCache.TryGetComponent(out ActorComponent? actor)) + !IoCManager.Resolve().TryGetComponent(PerformerCache.Uid, out ActorComponent? actor)) { NotUsefulAnymorePopup(); return; diff --git a/Content.Server/Body/Systems/LungSystem.cs b/Content.Server/Body/Systems/LungSystem.cs index 9e77149c06..39f8e1afc3 100644 --- a/Content.Server/Body/Systems/LungSystem.cs +++ b/Content.Server/Body/Systems/LungSystem.cs @@ -114,9 +114,9 @@ public class LungSystem : EntitySystem EntityManager.TryGetComponent(mech.Body.OwnerUid, out InternalsComponent? internals) && internals.BreathToolEntity != null && internals.GasTankEntity != null && - internals.BreathToolEntity.TryGetComponent(out BreathToolComponent? breathTool) && + IoCManager.Resolve().TryGetComponent(internals.BreathToolEntity.Uid, out BreathToolComponent? breathTool) && breathTool.IsFunctional && - internals.GasTankEntity.TryGetComponent(out GasTankComponent? gasTank)) + IoCManager.Resolve().TryGetComponent(internals.GasTankEntity.Uid, out GasTankComponent? gasTank)) { TakeGasFrom(uid, frameTime, gasTank.RemoveAirVolume(Atmospherics.BreathVolume), lung); return; diff --git a/Content.Server/Botany/Components/PlantHolderComponent.cs b/Content.Server/Botany/Components/PlantHolderComponent.cs index b20e7d4eec..f9fe988cc8 100644 --- a/Content.Server/Botany/Components/PlantHolderComponent.cs +++ b/Content.Server/Botany/Components/PlantHolderComponent.cs @@ -426,7 +426,7 @@ namespace Content.Server.Botany.Components if (Harvest && !Dead) { - if (user.TryGetComponent(out HandsComponent? hands)) + if (IoCManager.Resolve().TryGetComponent(user.Uid, out HandsComponent? hands)) { if (!Seed.CheckHarvest(user, hands.GetActiveHand?.Owner)) return false; @@ -654,7 +654,7 @@ namespace Content.Server.Botany.Components if ((!IoCManager.Resolve().EntityExists(usingItem.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(usingItem.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !EntitySystem.Get().CanInteract(user.Uid)) return false; - if (usingItem.TryGetComponent(out SeedComponent? seeds)) + if (IoCManager.Resolve().TryGetComponent(usingItem.Uid, out SeedComponent? seeds)) { if (Seed == null) { @@ -734,7 +734,7 @@ namespace Content.Server.Botany.Components var targetEntity = Owner.Uid; var solutionEntity = usingItem.Uid; - if (usingItem.TryGetComponent(out SprayComponent? spray)) + if (IoCManager.Resolve().TryGetComponent(usingItem.Uid, out SprayComponent? spray)) { sprayed = true; amount = FixedPoint2.New(1); @@ -804,7 +804,7 @@ namespace Content.Server.Botany.Components return DoHarvest(user); } - if (usingItem.TryGetComponent(out var produce)) + if (IoCManager.Resolve().TryGetComponent(usingItem.Uid, out var produce)) { user.PopupMessageCursor(Loc.GetString("plant-holder-component-compost-message", ("owner", Owner), diff --git a/Content.Server/Botany/Components/ProduceComponent.cs b/Content.Server/Botany/Components/ProduceComponent.cs index ea9fad7ca9..9b4877bf2d 100644 --- a/Content.Server/Botany/Components/ProduceComponent.cs +++ b/Content.Server/Botany/Components/ProduceComponent.cs @@ -35,7 +35,7 @@ namespace Content.Server.Botany.Components if (Seed == null) return; - if (Owner.TryGetComponent(out SpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out SpriteComponent? sprite)) { sprite.LayerSetRSI(0, Seed.PlantRsi); sprite.LayerSetState(0, Seed.PlantIconState); diff --git a/Content.Server/Botany/Components/SeedExtractorComponent.cs b/Content.Server/Botany/Components/SeedExtractorComponent.cs index 44647c2ae3..8403efec93 100644 --- a/Content.Server/Botany/Components/SeedExtractorComponent.cs +++ b/Content.Server/Botany/Components/SeedExtractorComponent.cs @@ -27,7 +27,7 @@ namespace Content.Server.Botany.Components if (!_powerReceiver?.Powered ?? false) return false; - if (eventArgs.Using.TryGetComponent(out ProduceComponent? produce) && produce.Seed != null) + if (IoCManager.Resolve().TryGetComponent(eventArgs.Using.Uid, out ProduceComponent? produce) && produce.Seed != null) { eventArgs.User.PopupMessageCursor(Loc.GetString("seed-extractor-component-interact-message",("name", eventArgs.Using.Name))); diff --git a/Content.Server/Botany/Seed.cs b/Content.Server/Botany/Seed.cs index b16ee1112e..51aef6ffad 100644 --- a/Content.Server/Botany/Seed.cs +++ b/Content.Server/Botany/Seed.cs @@ -257,7 +257,7 @@ namespace Content.Server.Botany var seedComp = seed.EnsureComponent(); seedComp.Seed = this; - if (seed.TryGetComponent(out SpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(seed.Uid, out SpriteComponent? sprite)) { // Seed state will always be seed. Blame the spriter if that's not the case! sprite.LayerSetSprite(0, new SpriteSpecifier.Rsi(PlantRsi, "seed")); diff --git a/Content.Server/Buckle/Components/BuckleComponent.cs b/Content.Server/Buckle/Components/BuckleComponent.cs index cea4458fe5..ae6c0b7986 100644 --- a/Content.Server/Buckle/Components/BuckleComponent.cs +++ b/Content.Server/Buckle/Components/BuckleComponent.cs @@ -154,7 +154,7 @@ namespace Content.Server.Buckle.Components return false; } - if (!to.TryGetComponent(out strap)) + if (!IoCManager.Resolve().TryGetComponent(to.Uid, out strap)) { return false; } @@ -255,7 +255,7 @@ namespace Content.Server.Buckle.Components SendMessage(new BuckleMessage(Owner, to)); #pragma warning restore 618 - if (Owner.TryGetComponent(out SharedPullableComponent? ownerPullable)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out SharedPullableComponent? ownerPullable)) { if (ownerPullable.Puller != null) { @@ -263,7 +263,7 @@ namespace Content.Server.Buckle.Components } } - if (to.TryGetComponent(out SharedPullableComponent? toPullable)) + if (IoCManager.Resolve().TryGetComponent(to.Uid, out SharedPullableComponent? toPullable)) { if (toPullable.Puller == Owner) { diff --git a/Content.Server/Buckle/Components/StrapComponent.cs b/Content.Server/Buckle/Components/StrapComponent.cs index 0fa44f5f1e..6a0279e880 100644 --- a/Content.Server/Buckle/Components/StrapComponent.cs +++ b/Content.Server/Buckle/Components/StrapComponent.cs @@ -9,6 +9,7 @@ using Content.Shared.Interaction; using Content.Shared.Sound; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Players; using Robust.Shared.Serialization; using Robust.Shared.Serialization.Manager.Attributes; @@ -148,7 +149,7 @@ namespace Content.Server.Buckle.Components { foreach (var entity in _buckledEntities.ToArray()) { - if (entity.TryGetComponent(out var buckle)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out var buckle)) { buckle.TryUnbuckle(entity, true); } @@ -165,7 +166,7 @@ namespace Content.Server.Buckle.Components bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs) { - if (!eventArgs.User.TryGetComponent(out var buckle)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out var buckle)) { return false; } @@ -175,7 +176,7 @@ namespace Content.Server.Buckle.Components public override bool DragDropOn(DragDropEvent eventArgs) { - if (!eventArgs.Dragged.TryGetComponent(out BuckleComponent? buckleComponent)) return false; + if (!IoCManager.Resolve().TryGetComponent(eventArgs.Dragged.Uid, out BuckleComponent? buckleComponent)) return false; return buckleComponent.TryBuckle(eventArgs.User, Owner); } } diff --git a/Content.Server/Buckle/Systems/StrapSystem.cs b/Content.Server/Buckle/Systems/StrapSystem.cs index a0c038472b..9c40cf7013 100644 --- a/Content.Server/Buckle/Systems/StrapSystem.cs +++ b/Content.Server/Buckle/Systems/StrapSystem.cs @@ -61,7 +61,7 @@ namespace Content.Server.Buckle.Systems } // Add a verb to buckle the user. - if (args.User.TryGetComponent(out var buckle) && + if (IoCManager.Resolve().TryGetComponent(args.User.Uid, out var buckle) && buckle.BuckledTo != component && args.User != component.Owner && component.HasSpace(buckle) && @@ -76,7 +76,7 @@ namespace Content.Server.Buckle.Systems // If the user is currently holding/pulling an entity that can be buckled, add a verb for that. if (args.Using != null && - args.Using.TryGetComponent(out var usingBuckle) && + IoCManager.Resolve().TryGetComponent(args.Using.Uid, out var usingBuckle) && component.HasSpace(usingBuckle) && _interactionSystem.InRangeUnobstructed(args.Using, args.Target, range: usingBuckle.Range)) { diff --git a/Content.Server/Cargo/Components/CargoConsoleComponent.cs b/Content.Server/Cargo/Components/CargoConsoleComponent.cs index fac57efc0b..c599e2e1ea 100644 --- a/Content.Server/Cargo/Components/CargoConsoleComponent.cs +++ b/Content.Server/Cargo/Components/CargoConsoleComponent.cs @@ -58,7 +58,7 @@ namespace Content.Server.Cargo.Components [DataField("errorSound")] private SoundSpecifier _errorSound = new SoundPathSpecifier("/Audio/Effects/error.ogg"); - private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; + private bool Powered => !IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) || receiver.Powered; private CargoConsoleSystem _cargoConsoleSystem = default!; [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(CargoConsoleUiKey.Key); @@ -91,7 +91,7 @@ namespace Content.Server.Cargo.Components private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage serverMsg) { - if (!Owner.TryGetComponent(out CargoOrderDatabaseComponent? orders)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out CargoOrderDatabaseComponent? orders)) { return; } @@ -175,7 +175,7 @@ namespace Content.Server.Cargo.Components { foreach (IEntity entity in enumerator) { - if (IoCManager.Resolve().HasComponent(entity.Uid) && entity.TryGetComponent(out var powerReceiver) && powerReceiver.Powered) + if (IoCManager.Resolve().HasComponent(entity.Uid) && IoCManager.Resolve().TryGetComponent(entity.Uid, out var powerReceiver) && powerReceiver.Powered) { cargoTelepad = entity; break; @@ -184,7 +184,7 @@ namespace Content.Server.Cargo.Components } if (cargoTelepad != null) { - if (cargoTelepad.TryGetComponent(out var telepadComponent)) + if (IoCManager.Resolve().TryGetComponent(cargoTelepad.Uid, out var telepadComponent)) { var approvedOrders = _cargoConsoleSystem.RemoveAndGetApprovedOrders(orders.Database.Id); orders.Database.ClearOrderCapacity(); diff --git a/Content.Server/Cargo/Components/CargoTelepadComponent.cs b/Content.Server/Cargo/Components/CargoTelepadComponent.cs index cc0a24abc6..e77e8fabd5 100644 --- a/Content.Server/Cargo/Components/CargoTelepadComponent.cs +++ b/Content.Server/Cargo/Components/CargoTelepadComponent.cs @@ -67,14 +67,14 @@ namespace Content.Server.Cargo.Components { if (args.Powered && _currentState == CargoTelepadState.Unpowered) { _currentState = CargoTelepadState.Idle; - if(Owner.TryGetComponent(out var spriteComponent) && spriteComponent.LayerCount > 0) + if(IoCManager.Resolve().TryGetComponent(Owner.Uid, out var spriteComponent) && spriteComponent.LayerCount > 0) spriteComponent.LayerSetState(0, "idle"); TeleportLoop(); } else if (!args.Powered) { _currentState = CargoTelepadState.Unpowered; - if (Owner.TryGetComponent(out var spriteComponent) && spriteComponent.LayerCount > 0) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var spriteComponent) && spriteComponent.LayerCount > 0) spriteComponent.LayerSetState(0, "offline"); } } @@ -83,14 +83,14 @@ namespace Content.Server.Cargo.Components if (_currentState == CargoTelepadState.Idle && _teleportQueue.Count > 0) { _currentState = CargoTelepadState.Charging; - if (Owner.TryGetComponent(out var spriteComponent) && spriteComponent.LayerCount > 0) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var spriteComponent) && spriteComponent.LayerCount > 0) spriteComponent.LayerSetState(0, "idle"); Owner.SpawnTimer((int) (TeleportDelay * 1000), () => { if (!Deleted && !((!IoCManager.Resolve().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) && _currentState == CargoTelepadState.Charging && _teleportQueue.Count > 0) { _currentState = CargoTelepadState.Teleporting; - if (Owner.TryGetComponent(out var spriteComponent) && spriteComponent.LayerCount > 0) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var spriteComponent) && spriteComponent.LayerCount > 0) spriteComponent.LayerSetState(0, "beam"); Owner.SpawnTimer((int) (TeleportDuration * 1000), () => { @@ -99,7 +99,7 @@ namespace Content.Server.Cargo.Components SoundSystem.Play(Filter.Pvs(Owner), _teleportSound.GetSound(), Owner, AudioParams.Default.WithVolume(-8f)); SpawnProduct(_teleportQueue[0]); _teleportQueue.RemoveAt(0); - if (Owner.TryGetComponent(out var spriteComponent) && spriteComponent.LayerCount > 0) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var spriteComponent) && spriteComponent.LayerCount > 0) spriteComponent.LayerSetState(0, "idle"); _currentState = CargoTelepadState.Idle; TeleportLoop(); diff --git a/Content.Server/CharacterAppearance/Components/MagicMirrorComponent.cs b/Content.Server/CharacterAppearance/Components/MagicMirrorComponent.cs index 75957f76d0..5c144ab689 100644 --- a/Content.Server/CharacterAppearance/Components/MagicMirrorComponent.cs +++ b/Content.Server/CharacterAppearance/Components/MagicMirrorComponent.cs @@ -48,7 +48,7 @@ namespace Content.Server.CharacterAppearance.Components return; } - if (!obj.Session.AttachedEntity.TryGetComponent(out HumanoidAppearanceComponent? looks)) + if (!IoCManager.Resolve().TryGetComponent(obj.Session.AttachedEntity.Uid, out HumanoidAppearanceComponent? looks)) { return; } @@ -96,12 +96,12 @@ namespace Content.Server.CharacterAppearance.Components void IActivate.Activate(ActivateEventArgs eventArgs) { - if (!eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) { return; } - if (!eventArgs.User.TryGetComponent(out HumanoidAppearanceComponent? looks)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out HumanoidAppearanceComponent? looks)) { Owner.PopupMessage(eventArgs.User, Loc.GetString("magic-mirror-component-activate-user-has-no-hair")); return; diff --git a/Content.Server/CharacterAppearance/Systems/HumanoidAppearanceSystem.cs b/Content.Server/CharacterAppearance/Systems/HumanoidAppearanceSystem.cs index 1482c03c31..de3f66a6b9 100644 --- a/Content.Server/CharacterAppearance/Systems/HumanoidAppearanceSystem.cs +++ b/Content.Server/CharacterAppearance/Systems/HumanoidAppearanceSystem.cs @@ -3,6 +3,7 @@ using Content.Shared.CharacterAppearance.Components; using Content.Shared.CharacterAppearance.Systems; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.CharacterAppearance.Systems { @@ -21,7 +22,7 @@ namespace Content.Server.CharacterAppearance.Systems { foreach (var (part, _) in body.Parts) { - if (part.Owner.TryGetComponent(out SpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(part.Owner.Uid, out SpriteComponent? sprite)) { sprite!.Color = component.Appearance.SkinColor; } diff --git a/Content.Server/CharacterInfo/CharacterInfoComponent.cs b/Content.Server/CharacterInfo/CharacterInfoComponent.cs index 3613fb2fe3..3524e26e7a 100644 --- a/Content.Server/CharacterInfo/CharacterInfoComponent.cs +++ b/Content.Server/CharacterInfo/CharacterInfoComponent.cs @@ -5,6 +5,7 @@ using Content.Server.Roles; using Content.Shared.CharacterInfo; using Content.Shared.Objectives; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Network; using Robust.Shared.Players; @@ -23,7 +24,7 @@ namespace Content.Server.CharacterInfo case RequestCharacterInfoMessage _: var conditions = new Dictionary>(); var jobTitle = "No Profession"; - if (Owner.TryGetComponent(out MindComponent? mindComponent)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out MindComponent? mindComponent)) { var mind = mindComponent.Mind; diff --git a/Content.Server/Chat/Managers/ChatManager.cs b/Content.Server/Chat/Managers/ChatManager.cs index bb77d2c220..aa625f3746 100644 --- a/Content.Server/Chat/Managers/ChatManager.cs +++ b/Content.Server/Chat/Managers/ChatManager.cs @@ -122,7 +122,7 @@ namespace Content.Server.Chat.Managers } // Check if message exceeds the character limit if the sender is a player - if (source.TryGetComponent(out ActorComponent? actor) && + if (IoCManager.Resolve().TryGetComponent(source.Uid, out ActorComponent? actor) && message.Length > MaxMessageLength) { var feedback = Loc.GetString("chat-manager-max-message-length-exceeded-message", ("limit", MaxMessageLength)); @@ -168,9 +168,9 @@ namespace Content.Server.Chat.Managers message = message[0].ToString().ToUpper() + message.Remove(0, 1); - if (source.TryGetComponent(out InventoryComponent? inventory) && + if (IoCManager.Resolve().TryGetComponent(source.Uid, out InventoryComponent? inventory) && inventory.TryGetSlotItem(EquipmentSlotDefines.Slots.EARS, out ItemComponent? item) && - item.Owner.TryGetComponent(out HeadsetComponent? headset)) + IoCManager.Resolve().TryGetComponent(item.Owner.Uid, out HeadsetComponent? headset)) { headset.RadioRequested = true; } @@ -208,7 +208,7 @@ namespace Content.Server.Chat.Managers } // Check if entity is a player - if (!source.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(source.Uid, out ActorComponent? actor)) { return; } diff --git a/Content.Server/Chemistry/Components/ChemMasterComponent.cs b/Content.Server/Chemistry/Components/ChemMasterComponent.cs index b499501a40..e3e8cf2928 100644 --- a/Content.Server/Chemistry/Components/ChemMasterComponent.cs +++ b/Content.Server/Chemistry/Components/ChemMasterComponent.cs @@ -51,7 +51,7 @@ namespace Content.Server.Chemistry.Components private bool _bufferModeTransfer = true; [ViewVariables] - private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; + private bool Powered => !IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) || receiver.Powered; [ViewVariables] private Solution BufferSolution => _bufferSolution ??= EntitySystem.Get().EnsureSolution(Owner.Uid, SolutionName); @@ -183,7 +183,7 @@ namespace Content.Server.Chemistry.Components private ChemMasterBoundUserInterfaceState GetUserInterfaceState() { var beaker = BeakerSlot.Item; - if (beaker is null || !beaker.TryGetComponent(out FitsInDispenserComponent? fits) || + if (beaker is null || !IoCManager.Resolve().TryGetComponent(beaker.Uid, out FitsInDispenserComponent? fits) || !EntitySystem.Get().TryGetSolution(beaker.Uid, fits.Solution, out var beakerSolution)) { return new ChemMasterBoundUserInterfaceState(Powered, false, FixedPoint2.New(0), FixedPoint2.New(0), @@ -208,7 +208,7 @@ namespace Content.Server.Chemistry.Components if (!BeakerSlot.HasItem && _bufferModeTransfer) return; var beaker = BeakerSlot.Item; - if (beaker is null || !beaker.TryGetComponent(out FitsInDispenserComponent? fits) || + if (beaker is null || !IoCManager.Resolve().TryGetComponent(beaker.Uid, out FitsInDispenserComponent? fits) || !EntitySystem.Get().TryGetSolution(beaker.Uid, fits.Solution, out var beakerSolution)) return; @@ -316,8 +316,8 @@ namespace Content.Server.Chemistry.Components EntitySystem.Get().TryAddSolution(bottle.Uid, bottleSolution, bufferSolution); //Try to give them the bottle - if (user.TryGetComponent(out var hands) && - bottle.TryGetComponent(out var item)) + if (IoCManager.Resolve().TryGetComponent(user.Uid, out var hands) && + IoCManager.Resolve().TryGetComponent(bottle.Uid, out var item)) { if (hands.CanPutInHand(item)) { @@ -357,15 +357,15 @@ namespace Content.Server.Chemistry.Components EntitySystem.Get().TryAddSolution(pill.Uid, pillSolution, bufferSolution); //Change pill Sprite component state - if (!pill.TryGetComponent(out SpriteComponent? sprite)) + if (!IoCManager.Resolve().TryGetComponent(pill.Uid, out SpriteComponent? sprite)) { return; } sprite?.LayerSetState(0, "pill" + _pillType); //Try to give them the bottle - if (user.TryGetComponent(out var hands) && - pill.TryGetComponent(out var item)) + if (IoCManager.Resolve().TryGetComponent(user.Uid, out var hands) && + IoCManager.Resolve().TryGetComponent(pill.Uid, out var item)) { if (hands.CanPutInHand(item)) { @@ -393,12 +393,12 @@ namespace Content.Server.Chemistry.Components /// Data relevant to the event such as the actor which triggered it. void IActivate.Activate(ActivateEventArgs args) { - if (!args.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) { return; } - if (!args.User.TryGetComponent(out HandsComponent? hands)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out HandsComponent? hands)) { Owner.PopupMessage(args.User, Loc.GetString("chem-master-component-activate-no-hands")); return; diff --git a/Content.Server/Chemistry/Components/FoamSolutionAreaEffectComponent.cs b/Content.Server/Chemistry/Components/FoamSolutionAreaEffectComponent.cs index 284d7904a7..a156153199 100644 --- a/Content.Server/Chemistry/Components/FoamSolutionAreaEffectComponent.cs +++ b/Content.Server/Chemistry/Components/FoamSolutionAreaEffectComponent.cs @@ -23,7 +23,7 @@ namespace Content.Server.Chemistry.Components protected override void UpdateVisuals() { - if (Owner.TryGetComponent(out AppearanceComponent? appearance) && + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance) && EntitySystem.Get().TryGetSolution(Owner.Uid, SolutionName, out var solution)) { appearance.SetData(FoamVisuals.Color, solution.Color.WithAlpha(0.80f)); @@ -35,13 +35,13 @@ namespace Content.Server.Chemistry.Components if (!EntitySystem.Get().TryGetSolution(Owner.Uid, SolutionName, out var solution)) return; - if (!entity.TryGetComponent(out BloodstreamComponent? bloodstream)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out BloodstreamComponent? bloodstream)) return; // TODO: Add a permeability property to clothing // For now it just adds to protection for each clothing equipped var protection = 0f; - if (entity.TryGetComponent(out InventoryComponent? inventory)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out InventoryComponent? inventory)) { foreach (var slot in inventory.Slots) { @@ -70,7 +70,7 @@ namespace Content.Server.Chemistry.Components { if ((!IoCManager.Resolve().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) return; - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(FoamVisuals.State, true); } diff --git a/Content.Server/Chemistry/Components/InjectorComponent.cs b/Content.Server/Chemistry/Components/InjectorComponent.cs index f8e42d229c..ad265a8d7f 100644 --- a/Content.Server/Chemistry/Components/InjectorComponent.cs +++ b/Content.Server/Chemistry/Components/InjectorComponent.cs @@ -136,7 +136,7 @@ namespace Content.Server.Chemistry.Components { TryInject(targetEntity, refillableSolution, eventArgs.User, true); } - else if (targetEntity.TryGetComponent(out BloodstreamComponent? bloodstream)) + else if (IoCManager.Resolve().TryGetComponent(targetEntity.Uid, out BloodstreamComponent? bloodstream)) { TryInjectIntoBloodstream(bloodstream, eventArgs.User); } diff --git a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs index 92168f5e13..d31d3a9532 100644 --- a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs +++ b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs @@ -63,7 +63,7 @@ namespace Content.Server.Chemistry.Components } [ViewVariables] - private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; + private bool Powered => !IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) || receiver.Powered; [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ReagentDispenserUiKey.Key); @@ -225,7 +225,7 @@ namespace Content.Server.Chemistry.Components private ReagentDispenserBoundUserInterfaceState GetUserInterfaceState() { var beaker = BeakerSlot.Item; - if (beaker == null || !beaker.TryGetComponent(out FitsInDispenserComponent? fits) || + if (beaker == null || !IoCManager.Resolve().TryGetComponent(beaker.Uid, out FitsInDispenserComponent? fits) || !EntitySystem.Get().TryGetSolution(beaker.Uid, fits.Solution, out var solution)) { return new ReagentDispenserBoundUserInterfaceState(Powered, false, FixedPoint2.New(0), @@ -251,7 +251,7 @@ namespace Content.Server.Chemistry.Components { var beaker = BeakerSlot.Item; - if (beaker == null || !beaker.TryGetComponent(out FitsInDispenserComponent? fits) || + if (beaker == null || !IoCManager.Resolve().TryGetComponent(beaker.Uid, out FitsInDispenserComponent? fits) || !EntitySystem.Get() .TryGetSolution(beaker.Uid, fits.Solution, out var solution)) return; @@ -269,7 +269,7 @@ namespace Content.Server.Chemistry.Components { var beaker = BeakerSlot.Item; - if (beaker is null || !beaker.TryGetComponent(out FitsInDispenserComponent? fits) + if (beaker is null || !IoCManager.Resolve().TryGetComponent(beaker.Uid, out FitsInDispenserComponent? fits) || !EntitySystem.Get() .TryGetSolution(beaker.Uid, fits.Solution, out var solution)) return; @@ -285,12 +285,12 @@ namespace Content.Server.Chemistry.Components /// Data relevant to the event such as the actor which triggered it. void IActivate.Activate(ActivateEventArgs args) { - if (!args.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) { return; } - if (!args.User.TryGetComponent(out HandsComponent? hands)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out HandsComponent? hands)) { Owner.PopupMessage(args.User, Loc.GetString("reagent-dispenser-component-activate-no-hands")); return; diff --git a/Content.Server/Chemistry/Components/SmokeSolutionAreaEffectComponent.cs b/Content.Server/Chemistry/Components/SmokeSolutionAreaEffectComponent.cs index 76b23cfa32..2d8f0c75ef 100644 --- a/Content.Server/Chemistry/Components/SmokeSolutionAreaEffectComponent.cs +++ b/Content.Server/Chemistry/Components/SmokeSolutionAreaEffectComponent.cs @@ -19,7 +19,7 @@ namespace Content.Server.Chemistry.Components protected override void UpdateVisuals() { - if (Owner.TryGetComponent(out AppearanceComponent? appearance) && + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance) && EntitySystem.Get().TryGetSolution(Owner.Uid, SolutionName, out var solution)) { appearance.SetData(SmokeVisuals.Color, solution.Color); @@ -31,10 +31,10 @@ namespace Content.Server.Chemistry.Components if (!EntitySystem.Get().TryGetSolution(Owner.Uid, SolutionName, out var solution)) return; - if (!entity.TryGetComponent(out BloodstreamComponent? bloodstream)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out BloodstreamComponent? bloodstream)) return; - if (entity.TryGetComponent(out InternalsComponent? internals) && + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out InternalsComponent? internals) && internals.AreInternalsWorking()) return; diff --git a/Content.Server/Chemistry/Components/SolutionAreaEffectComponent.cs b/Content.Server/Chemistry/Components/SolutionAreaEffectComponent.cs index fd99b9c9dd..2201bea440 100644 --- a/Content.Server/Chemistry/Components/SolutionAreaEffectComponent.cs +++ b/Content.Server/Chemistry/Components/SolutionAreaEffectComponent.cs @@ -85,7 +85,7 @@ namespace Content.Server.Chemistry.Components var newEffect = IoCManager.Resolve().SpawnEntity(IoCManager.Resolve().GetComponent(Owner.Uid).EntityPrototype.ID, grid.DirectionToGrid(coords, dir)); - if (!newEffect.TryGetComponent(out SolutionAreaEffectComponent? effectComponent)) + if (!IoCManager.Resolve().TryGetComponent(newEffect.Uid, out SolutionAreaEffectComponent? effectComponent)) { IoCManager.Resolve().DeleteEntity(newEffect.Uid); return; diff --git a/Content.Server/Chemistry/Components/SolutionTransferComponent.cs b/Content.Server/Chemistry/Components/SolutionTransferComponent.cs index 0ef6543843..a03a5d176d 100644 --- a/Content.Server/Chemistry/Components/SolutionTransferComponent.cs +++ b/Content.Server/Chemistry/Components/SolutionTransferComponent.cs @@ -126,7 +126,7 @@ namespace Content.Server.Chemistry.Components } - if (CanReceive && target.TryGetComponent(out ReagentTankComponent? tank) + if (CanReceive && IoCManager.Resolve().TryGetComponent(target.Uid, out ReagentTankComponent? tank) && solutionsSys.TryGetRefillableSolution(Owner.Uid, out var ownerRefill) && solutionsSys.TryGetDrainableSolution(eventArgs.Target.Uid, out var targetDrain)) { diff --git a/Content.Server/Chemistry/Components/TransformableContainerComponent.cs b/Content.Server/Chemistry/Components/TransformableContainerComponent.cs index ecdc0c0ca2..f2d61feb6f 100644 --- a/Content.Server/Chemistry/Components/TransformableContainerComponent.cs +++ b/Content.Server/Chemistry/Components/TransformableContainerComponent.cs @@ -23,7 +23,7 @@ namespace Content.Server.Chemistry.Components { base.Initialize(); - if (Owner.TryGetComponent(out SpriteComponent? sprite) && + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out SpriteComponent? sprite) && sprite.BaseRSIPath != null) { InitialSprite = new SpriteSpecifier.Rsi(new ResourcePath(sprite.BaseRSIPath), "icon"); diff --git a/Content.Server/Chemistry/EntitySystems/SolutionContainerSystem.cs b/Content.Server/Chemistry/EntitySystems/SolutionContainerSystem.cs index 665bacecd1..2995bee9db 100644 --- a/Content.Server/Chemistry/EntitySystems/SolutionContainerSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/SolutionContainerSystem.cs @@ -294,7 +294,7 @@ namespace Content.Server.Chemistry.EntitySystems { var reagentQuantity = FixedPoint2.New(0); if (EntityManager.TryGetEntity(ownerUid, out var owner) - && owner.TryGetComponent(out SolutionContainerManagerComponent? managerComponent)) + && IoCManager.Resolve().TryGetComponent(owner.Uid, out SolutionContainerManagerComponent? managerComponent)) { foreach (var solution in managerComponent.Solutions.Values) { diff --git a/Content.Server/Chemistry/EntitySystems/SolutionInjectOnCollideSystem.cs b/Content.Server/Chemistry/EntitySystems/SolutionInjectOnCollideSystem.cs index 04b1ec19c6..3fb0556ea9 100644 --- a/Content.Server/Chemistry/EntitySystems/SolutionInjectOnCollideSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/SolutionInjectOnCollideSystem.cs @@ -30,7 +30,7 @@ namespace Content.Server.Chemistry.EntitySystems private void HandleInjection(EntityUid uid, SolutionInjectOnCollideComponent component, StartCollideEvent args) { - if (!args.OtherFixture.Body.Owner.TryGetComponent(out var bloodstream) || + if (!IoCManager.Resolve().TryGetComponent(args.OtherFixture.Body.Owner.Uid, out var bloodstream) || !_solutionsSystem.TryGetInjectableSolution(component.Owner.Uid, out var solution)) return; var solRemoved = solution.SplitSolution(component.TransferAmount); diff --git a/Content.Server/Chemistry/EntitySystems/TransformableContainerSystem.cs b/Content.Server/Chemistry/EntitySystems/TransformableContainerSystem.cs index 0c91156f24..20f4ad5b37 100644 --- a/Content.Server/Chemistry/EntitySystems/TransformableContainerSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/TransformableContainerSystem.cs @@ -51,7 +51,7 @@ namespace Content.Server.Chemistry.EntitySystems new SpriteSpecifier.Rsi( new ResourcePath("Objects/Consumable/Drinks/" + proto.SpriteReplacementPath), "icon"); var ownerEntity = EntityManager.GetEntity(uid); - if (ownerEntity.TryGetComponent(out SpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(ownerEntity.Uid, out SpriteComponent? sprite)) { sprite?.LayerSetSprite(0, spriteSpec); } @@ -68,7 +68,7 @@ namespace Content.Server.Chemistry.EntitySystems component.CurrentReagent = null; component.Transformed = false; - if (component.Owner.TryGetComponent(out SpriteComponent? sprite) && + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out SpriteComponent? sprite) && component.InitialSprite != null) { sprite.LayerSetSprite(0, component.InitialSprite); diff --git a/Content.Server/Chemistry/EntitySystems/VaporSystem.cs b/Content.Server/Chemistry/EntitySystems/VaporSystem.cs index 8da6d20227..515e0580a6 100644 --- a/Content.Server/Chemistry/EntitySystems/VaporSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/VaporSystem.cs @@ -52,7 +52,7 @@ namespace Content.Server.Chemistry.EntitySystems vapor.Target = target; vapor.AliveTime = aliveTime; // Set Move - if (vapor.Owner.TryGetComponent(out PhysicsComponent? physics)) + if (IoCManager.Resolve().TryGetComponent(vapor.Owner.Uid, out PhysicsComponent? physics)) { physics.BodyStatus = BodyStatus.InAir; physics.ApplyLinearImpulse(dir * speed); diff --git a/Content.Server/Chemistry/TileReactions/CleanTileReaction.cs b/Content.Server/Chemistry/TileReactions/CleanTileReaction.cs index de609a939e..cdd4290932 100644 --- a/Content.Server/Chemistry/TileReactions/CleanTileReaction.cs +++ b/Content.Server/Chemistry/TileReactions/CleanTileReaction.cs @@ -25,7 +25,7 @@ namespace Content.Server.Chemistry.TileReactions var amount = FixedPoint2.Zero; foreach (var entity in entities) { - if (entity.TryGetComponent(out CleanableComponent? cleanable)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out CleanableComponent? cleanable)) { var next = (amount + cleanable.CleanAmount) * CleanAmountMultiplier; // Nothing left? diff --git a/Content.Server/Climbing/ClimbSystem.cs b/Content.Server/Climbing/ClimbSystem.cs index 214eb3b3a0..ec13166924 100644 --- a/Content.Server/Climbing/ClimbSystem.cs +++ b/Content.Server/Climbing/ClimbSystem.cs @@ -41,7 +41,7 @@ namespace Content.Server.Climbing return; // Check that the user climb. - if (!args.User.TryGetComponent(out ClimbingComponent? climbingComponent) || + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing) return; diff --git a/Content.Server/Climbing/Components/ClimbableComponent.cs b/Content.Server/Climbing/Components/ClimbableComponent.cs index 042087ca11..4acc706a46 100644 --- a/Content.Server/Climbing/Components/ClimbableComponent.cs +++ b/Content.Server/Climbing/Components/ClimbableComponent.cs @@ -75,7 +75,7 @@ namespace Content.Server.Climbing.Components } if (!IoCManager.Resolve().HasComponent(user.Uid) || - !user.TryGetComponent(out SharedBodyComponent? body)) + !IoCManager.Resolve().TryGetComponent(user.Uid, out SharedBodyComponent? body)) { reason = Loc.GetString("comp-climbable-cant-climb"); return false; @@ -159,7 +159,7 @@ namespace Content.Server.Climbing.Components var result = await EntitySystem.Get().WaitDoAfter(doAfterEventArgs); - if (result != DoAfterStatus.Cancelled && entityToMove.TryGetComponent(out PhysicsComponent? body) && body.Fixtures.Count >= 1) + if (result != DoAfterStatus.Cancelled && IoCManager.Resolve().TryGetComponent(entityToMove.Uid, out PhysicsComponent? body) && body.Fixtures.Count >= 1) { var entityPos = entityToMove.Transform.WorldPosition; @@ -193,7 +193,7 @@ namespace Content.Server.Climbing.Components public async void TryClimb(IEntity user) { - if (!user.TryGetComponent(out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing) + if (!IoCManager.Resolve().TryGetComponent(user.Uid, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing) return; var doAfterEventArgs = new DoAfterEventArgs(user, _climbDelay, default, Owner) @@ -206,7 +206,7 @@ namespace Content.Server.Climbing.Components var result = await EntitySystem.Get().WaitDoAfter(doAfterEventArgs); - if (result != DoAfterStatus.Cancelled && user.TryGetComponent(out PhysicsComponent? body) && body.Fixtures.Count >= 1) + if (result != DoAfterStatus.Cancelled && IoCManager.Resolve().TryGetComponent(user.Uid, out PhysicsComponent? body) && body.Fixtures.Count >= 1) { // TODO: Remove the copy-paste code var userPos = user.Transform.WorldPosition; diff --git a/Content.Server/Cloning/Components/CloningPodComponent.cs b/Content.Server/Cloning/Components/CloningPodComponent.cs index db7bfe47a7..9665e10f53 100644 --- a/Content.Server/Cloning/Components/CloningPodComponent.cs +++ b/Content.Server/Cloning/Components/CloningPodComponent.cs @@ -26,7 +26,7 @@ namespace Content.Server.Cloning.Components [Dependency] private readonly EuiManager _euiManager = null!; [ViewVariables] - public bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; + public bool Powered => !IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) || receiver.Powered; [ViewVariables] public BoundUserInterface? UserInterface => @@ -70,7 +70,7 @@ namespace Content.Server.Cloning.Components private void UpdateAppearance() { - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(CloningPodVisuals.Status, Status); } @@ -108,9 +108,9 @@ namespace Content.Server.Cloning.Components if (cloningSystem.ClonesWaitingForMind.TryGetValue(mind, out var cloneUid)) { if (IoCManager.Resolve().TryGetEntity(cloneUid, out var clone) && - clone.TryGetComponent(out var cloneState) && + IoCManager.Resolve().TryGetComponent(clone.Uid, out var cloneState) && !cloneState.IsDead() && - clone.TryGetComponent(out MindComponent? cloneMindComp) && + IoCManager.Resolve().TryGetComponent(clone.Uid, out MindComponent? cloneMindComp) && (cloneMindComp.Mind == null || cloneMindComp.Mind == mind)) { obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-already-cloning")); @@ -121,7 +121,7 @@ namespace Content.Server.Cloning.Components } if (mind.OwnedEntity != null && - mind.OwnedEntity.TryGetComponent(out var state) && + IoCManager.Resolve().TryGetComponent(mind.OwnedEntity.Uid, out var state) && !state.IsDead()) { obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-already-alive")); diff --git a/Content.Server/Clothing/Components/ClothingComponent.cs b/Content.Server/Clothing/Components/ClothingComponent.cs index d8d0f3e593..90f4e8330e 100644 --- a/Content.Server/Clothing/Components/ClothingComponent.cs +++ b/Content.Server/Clothing/Components/ClothingComponent.cs @@ -61,8 +61,8 @@ namespace Content.Server.Clothing.Components bool IUse.UseEntity(UseEntityEventArgs eventArgs) { if (!_quickEquipEnabled) return false; - if (!eventArgs.User.TryGetComponent(out InventoryComponent? inv) - || !eventArgs.User.TryGetComponent(out HandsComponent? hands)) return false; + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out InventoryComponent? inv) + || !IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out HandsComponent? hands)) return false; foreach (var (slot, flag) in SlotMasks) { diff --git a/Content.Server/Clothing/Components/MagbootsComponent.cs b/Content.Server/Clothing/Components/MagbootsComponent.cs index dc000ac78e..5c961082a9 100644 --- a/Content.Server/Clothing/Components/MagbootsComponent.cs +++ b/Content.Server/Clothing/Components/MagbootsComponent.cs @@ -15,6 +15,7 @@ using JetBrains.Annotations; using Robust.Server.GameObjects; using Robust.Shared.Containers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Players; using Robust.Shared.Serialization.Manager.Attributes; @@ -59,12 +60,12 @@ namespace Content.Server.Clothing.Components { if (On && eventArgs.Slot == Slots.SHOES) { - if (eventArgs.User.TryGetComponent(out MovedByPressureComponent? movedByPressure)) + if (IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out MovedByPressureComponent? movedByPressure)) { movedByPressure.Enabled = true; } - if (eventArgs.User.TryGetComponent(out ServerAlertsComponent? alerts)) + if (IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ServerAlertsComponent? alerts)) { alerts.ClearAlert(AlertType.Magboots); } @@ -81,15 +82,15 @@ namespace Content.Server.Clothing.Components if (!Owner.TryGetContainer(out var container)) return; - if (container.Owner.TryGetComponent(out InventoryComponent? inventoryComponent) + if (IoCManager.Resolve().TryGetComponent(container.Owner.Uid, out InventoryComponent? inventoryComponent) && inventoryComponent.GetSlotItem(Slots.SHOES)?.Owner == Owner) { - if (container.Owner.TryGetComponent(out MovedByPressureComponent? movedByPressure)) + if (IoCManager.Resolve().TryGetComponent(container.Owner.Uid, out MovedByPressureComponent? movedByPressure)) { movedByPressure.Enabled = false; } - if (container.Owner.TryGetComponent(out ServerAlertsComponent? alerts)) + if (IoCManager.Resolve().TryGetComponent(container.Owner.Uid, out ServerAlertsComponent? alerts)) { if (On) { @@ -126,7 +127,7 @@ namespace Content.Server.Clothing.Components { public bool DoToggleAction(ToggleItemActionEventArgs args) { - if (!args.Item.TryGetComponent(out var magboots)) + if (!IoCManager.Resolve().TryGetComponent(args.Item.Uid, out var magboots)) return false; magboots.Toggle(args.Performer); diff --git a/Content.Server/Communications/CommunicationsConsoleComponent.cs b/Content.Server/Communications/CommunicationsConsoleComponent.cs index 117d24e691..0fa28d3084 100644 --- a/Content.Server/Communications/CommunicationsConsoleComponent.cs +++ b/Content.Server/Communications/CommunicationsConsoleComponent.cs @@ -25,7 +25,7 @@ namespace Content.Server.Communications { [Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IChatManager _chatManager = default!; - private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; + private bool Powered => !IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) || receiver.Powered; private RoundEndSystem RoundEndSystem => EntitySystem.Get(); diff --git a/Content.Server/Computer/ComputerComponent.cs b/Content.Server/Computer/ComputerComponent.cs index 9e14020e71..5c98c60b2c 100644 --- a/Content.Server/Computer/ComputerComponent.cs +++ b/Content.Server/Computer/ComputerComponent.cs @@ -26,8 +26,8 @@ namespace Content.Server.Computer // Let's ensure the container manager and container are here. Owner.EnsureContainer("board", out var _); - if (Owner.TryGetComponent(out ApcPowerReceiverComponent? powerReceiver) && - Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? powerReceiver) && + IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(ComputerVisuals.Powered, powerReceiver.Powered); } @@ -49,7 +49,7 @@ namespace Content.Server.Computer private void PowerReceiverOnOnPowerStateChanged(PowerChangedMessage e) { - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(ComputerVisuals.Powered, e.Powered); } @@ -63,7 +63,7 @@ namespace Content.Server.Computer private void CreateComputerBoard() { // Ensure that the construction component is aware of the board container. - if (Owner.TryGetComponent(out ConstructionComponent? construction)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ConstructionComponent? construction)) EntitySystem.Get().AddContainer(Owner.Uid, "board", construction); // We don't do anything if this is null or empty. diff --git a/Content.Server/Configurable/ConfigurationComponent.cs b/Content.Server/Configurable/ConfigurationComponent.cs index 570c193a95..b428d9472f 100644 --- a/Content.Server/Configurable/ConfigurationComponent.cs +++ b/Content.Server/Configurable/ConfigurationComponent.cs @@ -12,6 +12,7 @@ using Content.Shared.Verbs; using Robust.Server.Console; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; @@ -80,10 +81,10 @@ namespace Content.Server.Configurable async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { - if (UserInterface == null || !eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if (UserInterface == null || !IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) return false; - if (!eventArgs.Using.TryGetComponent(out var tool) || !tool.Qualities.Contains(_qualityNeeded)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.Using.Uid, out var tool) || !tool.Qualities.Contains(_qualityNeeded)) return false; OpenUserInterface(actor); diff --git a/Content.Server/Construction/Completions/BuildComputer.cs b/Content.Server/Construction/Completions/BuildComputer.cs index 2cab2e7674..883e3a6a8a 100644 --- a/Content.Server/Construction/Completions/BuildComputer.cs +++ b/Content.Server/Construction/Completions/BuildComputer.cs @@ -41,7 +41,7 @@ namespace Content.Server.Construction.Completions var board = container.ContainedEntities[0]; - if (!board.TryGetComponent(out ComputerBoardComponent? boardComponent)) + if (!IoCManager.Resolve().TryGetComponent(board.Uid, out ComputerBoardComponent? boardComponent)) { Logger.Warning($"Computer entity {uid} had an invalid entity in container \"{Container}\"! Aborting build computer action."); return; diff --git a/Content.Server/Construction/Completions/BuildMachine.cs b/Content.Server/Construction/Completions/BuildMachine.cs index 499c942243..b6e24e6d5d 100644 --- a/Content.Server/Construction/Completions/BuildMachine.cs +++ b/Content.Server/Construction/Completions/BuildMachine.cs @@ -5,6 +5,7 @@ using Content.Shared.Construction; using JetBrains.Annotations; using Robust.Shared.Containers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Log; using Robust.Shared.Serialization.Manager.Attributes; @@ -53,7 +54,7 @@ namespace Content.Server.Construction.Completions var board = entBoardContainer.ContainedEntities[0]; - if (!board.TryGetComponent(out MachineBoardComponent? boardComponent)) + if (!IoCManager.Resolve().TryGetComponent(board.Uid, out MachineBoardComponent? boardComponent)) { Logger.Warning($"Machine frame entity {uid} had an invalid entity in container \"{MachineFrameComponent.BoardContainer}\"! Aborting build machine action."); return; @@ -91,14 +92,14 @@ namespace Content.Server.Construction.Completions } var constructionSystem = entityManager.EntitySysManager.GetEntitySystem(); - if (machine.TryGetComponent(out ConstructionComponent? construction)) + if (IoCManager.Resolve().TryGetComponent(machine.Uid, out ConstructionComponent? construction)) { // We only add these two container. If some construction needs to take other containers into account, fix this. constructionSystem.AddContainer(machine.Uid, MachineFrameComponent.BoardContainer, construction); constructionSystem.AddContainer(machine.Uid, MachineFrameComponent.PartContainer, construction); } - if (machine.TryGetComponent(out MachineComponent? machineComp)) + if (IoCManager.Resolve().TryGetComponent(machine.Uid, out MachineComponent? machineComp)) { machineComp.RefreshParts(); } diff --git a/Content.Server/Construction/Components/MachineComponent.cs b/Content.Server/Construction/Components/MachineComponent.cs index cdcba94efd..7f2534a65c 100644 --- a/Content.Server/Construction/Components/MachineComponent.cs +++ b/Content.Server/Construction/Components/MachineComponent.cs @@ -32,7 +32,7 @@ namespace Content.Server.Construction.Components { foreach (var entity in _partContainer.ContainedEntities) { - if (entity.TryGetComponent(out var machinePart)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out var machinePart)) yield return machinePart; } } @@ -70,7 +70,7 @@ namespace Content.Server.Construction.Components throw new Exception($"Couldn't insert board with prototype {BoardPrototype} to machine with prototype {IoCManager.Resolve().GetComponent(Owner.Uid).EntityPrototype?.ID ?? "N/A"}!"); } - if (!board.TryGetComponent(out var machineBoard)) + if (!IoCManager.Resolve().TryGetComponent(board.Uid, out var machineBoard)) { throw new Exception($"Entity with prototype {BoardPrototype} doesn't have a {nameof(MachineBoardComponent)}!"); } diff --git a/Content.Server/Construction/Components/MachineFrameComponent.cs b/Content.Server/Construction/Components/MachineFrameComponent.cs index f0a28a591b..9226cc876a 100644 --- a/Content.Server/Construction/Components/MachineFrameComponent.cs +++ b/Content.Server/Construction/Components/MachineFrameComponent.cs @@ -122,7 +122,7 @@ namespace Content.Server.Construction.Components RegenerateProgress(); - if (Owner.TryGetComponent(out var construction)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var construction)) { // Attempt to set pathfinding to the machine node... EntitySystem.Get().SetPathfindingTarget(OwnerUid, "machine", construction); @@ -168,7 +168,7 @@ namespace Content.Server.Construction.Components if (!HasBoard) { - if (Owner.TryGetComponent(out appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out appearance)) { appearance.SetData(MachineFrameVisuals.State, 1); } @@ -187,10 +187,10 @@ namespace Content.Server.Construction.Components var board = _boardContainer.ContainedEntities[0]; - if (!board.TryGetComponent(out var machineBoard)) + if (!IoCManager.Resolve().TryGetComponent(board.Uid, out var machineBoard)) return; - if (Owner.TryGetComponent(out appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out appearance)) { appearance.SetData(MachineFrameVisuals.State, 2); } @@ -199,7 +199,7 @@ namespace Content.Server.Construction.Components foreach (var part in _partContainer.ContainedEntities) { - if (part.TryGetComponent(out var machinePart)) + if (IoCManager.Resolve().TryGetComponent(part.Uid, out var machinePart)) { // Check this is part of the requirements... if (!Requirements.ContainsKey(machinePart.PartType)) @@ -211,7 +211,7 @@ namespace Content.Server.Construction.Components _progress[machinePart.PartType]++; } - if (part.TryGetComponent(out var stack)) + if (IoCManager.Resolve().TryGetComponent(part.Uid, out var stack)) { var type = stack.StackTypeId; // Check this is part of the requirements... @@ -254,7 +254,7 @@ namespace Content.Server.Construction.Components async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { - if (!HasBoard && eventArgs.Using.TryGetComponent(out var machineBoard)) + if (!HasBoard && IoCManager.Resolve().TryGetComponent(eventArgs.Using.Uid, out var machineBoard)) { if (eventArgs.Using.TryRemoveFromContainer()) { @@ -264,12 +264,12 @@ namespace Content.Server.Construction.Components // Setup requirements and progress... ResetProgressAndRequirements(machineBoard); - if (Owner.TryGetComponent(out var appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var appearance)) { appearance.SetData(MachineFrameVisuals.State, 2); } - if (Owner.TryGetComponent(out ConstructionComponent? construction)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ConstructionComponent? construction)) { // So prying the components off works correctly. EntitySystem.Get().ResetEdge(OwnerUid, construction); @@ -280,7 +280,7 @@ namespace Content.Server.Construction.Components } else if (HasBoard) { - if (eventArgs.Using.TryGetComponent(out var machinePart)) + if (IoCManager.Resolve().TryGetComponent(eventArgs.Using.Uid, out var machinePart)) { if (!Requirements.ContainsKey(machinePart.PartType)) return false; @@ -293,7 +293,7 @@ namespace Content.Server.Construction.Components } } - if (eventArgs.Using.TryGetComponent(out var stack)) + if (IoCManager.Resolve().TryGetComponent(eventArgs.Using.Uid, out var stack)) { var type = stack.StackTypeId; if (!MaterialRequirements.ContainsKey(type)) diff --git a/Content.Server/Construction/Components/WelderRefinableComponent.cs b/Content.Server/Construction/Components/WelderRefinableComponent.cs index 1347dd0162..fc52577b39 100644 --- a/Content.Server/Construction/Components/WelderRefinableComponent.cs +++ b/Content.Server/Construction/Components/WelderRefinableComponent.cs @@ -41,7 +41,7 @@ namespace Content.Server.Construction.Components async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { // check if object is welder - if (!eventArgs.Using.TryGetComponent(out ToolComponent? tool)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.Using.Uid, out ToolComponent? tool)) return false; // check if someone is already welding object @@ -70,7 +70,7 @@ namespace Content.Server.Construction.Components // TODO: If something has a stack... Just use a prototype with a single thing in the stack. // This is not a good way to do it. - if (droppedEnt.TryGetComponent(out var stack)) + if (IoCManager.Resolve().TryGetComponent(droppedEnt.Uid, out var stack)) EntitySystem.Get().SetCount(droppedEnt.Uid,1, stack); } diff --git a/Content.Server/Construction/Conditions/AirlockBolted.cs b/Content.Server/Construction/Conditions/AirlockBolted.cs index 0314d208b6..e43c6291cf 100644 --- a/Content.Server/Construction/Conditions/AirlockBolted.cs +++ b/Content.Server/Construction/Conditions/AirlockBolted.cs @@ -8,6 +8,7 @@ using Robust.Shared.Utility; using System.Threading.Tasks; using Content.Server.Doors.Components; using Content.Shared.Examine; +using Robust.Shared.IoC; namespace Content.Server.Construction.Conditions { @@ -30,7 +31,7 @@ namespace Content.Server.Construction.Conditions { var entity = args.Examined; - if (!entity.TryGetComponent(out AirlockComponent? airlock)) return false; + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out AirlockComponent? airlock)) return false; if (airlock.BoltsDown != Value) { diff --git a/Content.Server/Construction/Conditions/ContainerEmpty.cs b/Content.Server/Construction/Conditions/ContainerEmpty.cs index 9eeb81aafa..1dfec7202b 100644 --- a/Content.Server/Construction/Conditions/ContainerEmpty.cs +++ b/Content.Server/Construction/Conditions/ContainerEmpty.cs @@ -6,6 +6,7 @@ using JetBrains.Annotations; using Robust.Server.Containers; using Robust.Shared.Containers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Utility; @@ -44,7 +45,7 @@ namespace Content.Server.Construction.Conditions var entity = args.Examined; - if (!entity.TryGetComponent(out ContainerManagerComponent? containerManager) || + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out ContainerManagerComponent? containerManager) || !containerManager.TryGetContainer(Container, out var container)) return false; if (container.ContainedEntities.Count == 0) diff --git a/Content.Server/Construction/Conditions/ContainerNotEmpty.cs b/Content.Server/Construction/Conditions/ContainerNotEmpty.cs index 3c384b498c..343c0e8f4a 100644 --- a/Content.Server/Construction/Conditions/ContainerNotEmpty.cs +++ b/Content.Server/Construction/Conditions/ContainerNotEmpty.cs @@ -6,6 +6,7 @@ using JetBrains.Annotations; using Robust.Server.Containers; using Robust.Shared.Containers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Utility; @@ -37,7 +38,7 @@ namespace Content.Server.Construction.Conditions var entity = args.Examined; - if (!entity.TryGetComponent(out ContainerManagerComponent? containerManager) || + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out ContainerManagerComponent? containerManager) || !containerManager.TryGetContainer(Container, out var container)) return false; if (container.ContainedEntities.Count != 0) diff --git a/Content.Server/Construction/Conditions/DoorWelded.cs b/Content.Server/Construction/Conditions/DoorWelded.cs index 147b3a63ad..72b4f1200f 100644 --- a/Content.Server/Construction/Conditions/DoorWelded.cs +++ b/Content.Server/Construction/Conditions/DoorWelded.cs @@ -4,6 +4,7 @@ using Content.Shared.Construction; using Content.Shared.Examine; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Serialization.Manager.Attributes; @@ -28,7 +29,7 @@ namespace Content.Server.Construction.Conditions { var entity = args.Examined; - if (!entity.TryGetComponent(out ServerDoorComponent? door)) return false; + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out ServerDoorComponent? door)) return false; if (door.IsWeldedShut != Welded) { diff --git a/Content.Server/Construction/Conditions/MachineFrameComplete.cs b/Content.Server/Construction/Conditions/MachineFrameComplete.cs index 9b598be314..616915f404 100644 --- a/Content.Server/Construction/Conditions/MachineFrameComplete.cs +++ b/Content.Server/Construction/Conditions/MachineFrameComplete.cs @@ -5,6 +5,7 @@ using Content.Shared.Construction; using Content.Shared.Examine; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Utility; @@ -37,7 +38,7 @@ namespace Content.Server.Construction.Conditions { var entity = args.Examined; - if (!entity.TryGetComponent(out var machineFrame)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out var machineFrame)) return false; if (!machineFrame.HasBoard) diff --git a/Content.Server/Construction/Conditions/ToiletLidClosed.cs b/Content.Server/Construction/Conditions/ToiletLidClosed.cs index 490113cb83..f5969af0e1 100644 --- a/Content.Server/Construction/Conditions/ToiletLidClosed.cs +++ b/Content.Server/Construction/Conditions/ToiletLidClosed.cs @@ -4,6 +4,7 @@ using Content.Shared.Construction; using Content.Shared.Examine; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Serialization.Manager.Attributes; @@ -25,7 +26,7 @@ namespace Content.Server.Construction.Conditions { var entity = args.Examined; - if (!entity.TryGetComponent(out ToiletComponent? toilet)) return false; + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out ToiletComponent? toilet)) return false; if (!toilet.LidOpen) return false; args.PushMarkup(Loc.GetString("construction-examine-condition-toilet-lid-closed") + "\n"); diff --git a/Content.Server/Construction/Conditions/WirePanel.cs b/Content.Server/Construction/Conditions/WirePanel.cs index 859c5af53c..b42bc65f91 100644 --- a/Content.Server/Construction/Conditions/WirePanel.cs +++ b/Content.Server/Construction/Conditions/WirePanel.cs @@ -5,6 +5,7 @@ using Content.Shared.Construction; using Content.Shared.Examine; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Utility; @@ -29,7 +30,7 @@ namespace Content.Server.Construction.Conditions { var entity = args.Examined; - if (!entity.TryGetComponent(out WiresComponent? wires)) return false; + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out WiresComponent? wires)) return false; switch (Open) { diff --git a/Content.Server/Construction/ConstructionSystem.Initial.cs b/Content.Server/Construction/ConstructionSystem.Initial.cs index 6c484c3f51..471ec63d13 100644 --- a/Content.Server/Construction/ConstructionSystem.Initial.cs +++ b/Content.Server/Construction/ConstructionSystem.Initial.cs @@ -45,11 +45,11 @@ namespace Content.Server.Construction // LEGACY CODE. See warning at the top of the file! private IEnumerable EnumerateNearby(IEntity user) { - if (user.TryGetComponent(out HandsComponent? hands)) + if (IoCManager.Resolve().TryGetComponent(user.Uid, out HandsComponent? hands)) { foreach (var itemComponent in hands?.GetAllHeldItems()!) { - if (itemComponent.Owner.TryGetComponent(out ServerStorageComponent? storage)) + if (IoCManager.Resolve().TryGetComponent(itemComponent.Owner.Uid, out ServerStorageComponent? storage)) { foreach (var storedEntity in storage.StoredEntities!) { @@ -61,11 +61,11 @@ namespace Content.Server.Construction } } - if (user!.TryGetComponent(out InventoryComponent? inventory)) + if (IoCManager.Resolve().TryGetComponent(user!.Uid, out InventoryComponent? inventory)) { foreach (var held in inventory.GetAllHeldItems()) { - if (held.TryGetComponent(out ServerStorageComponent? storage)) + if (IoCManager.Resolve().TryGetComponent(held.Uid, out ServerStorageComponent? storage)) { foreach (var storedEntity in storage.StoredEntities!) { @@ -299,7 +299,7 @@ namespace Content.Server.Construction if (user == null || !Get().CanInteract(user.Uid)) return; - if (!user.TryGetComponent(out HandsComponent? hands)) return; + if (!IoCManager.Resolve().TryGetComponent(user.Uid, out HandsComponent? hands)) return; foreach (var condition in constructionPrototype.Conditions) { @@ -328,7 +328,7 @@ namespace Content.Server.Construction var item = await Construct(user, "item_construction", constructionGraph, edge, targetNode); - if(item != null && item.TryGetComponent(out ItemComponent? itemComp)) + if(item != null && IoCManager.Resolve().TryGetComponent(item.Uid, out ItemComponent? itemComp)) hands.PutInHandOrDrop(itemComp); } @@ -399,7 +399,7 @@ namespace Content.Server.Construction if (user == null || !Get().CanInteract(user.Uid) - || !user.TryGetComponent(out HandsComponent? hands) || hands.GetActiveHand == null + || !IoCManager.Resolve().TryGetComponent(user.Uid, out HandsComponent? hands) || hands.GetActiveHand == null || !user.InRangeUnobstructed(ev.Location, ignoreInsideBlocker:constructionPrototype.CanBuildInImpassable)) { Cleanup(); diff --git a/Content.Server/Containers/ContainerExt.cs b/Content.Server/Containers/ContainerExt.cs index 0c89dfed27..698f9ef2d9 100644 --- a/Content.Server/Containers/ContainerExt.cs +++ b/Content.Server/Containers/ContainerExt.cs @@ -15,7 +15,7 @@ namespace Content.Server.Containers foreach (var entity in container.ContainedEntities) { if (IoCManager.Resolve().GetComponent(entity.Uid).EntityPrototype?.ID == prototypeId) total++; - if(!entity.TryGetComponent(out var component)) continue; + if(!IoCManager.Resolve().TryGetComponent(entity.Uid, out var component)) continue; total += component.CountPrototypeOccurencesRecursive(prototypeId); } } diff --git a/Content.Server/Conveyor/ConveyorSystem.cs b/Content.Server/Conveyor/ConveyorSystem.cs index a1a46fd3c9..a4b445d45d 100644 --- a/Content.Server/Conveyor/ConveyorSystem.cs +++ b/Content.Server/Conveyor/ConveyorSystem.cs @@ -42,9 +42,9 @@ namespace Content.Server.Conveyor private void UpdateAppearance(ConveyorComponent component) { - if (component.Owner.TryGetComponent(out var appearance)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out var appearance)) { - if (component.Owner.TryGetComponent(out var receiver) && receiver.Powered) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out var receiver) && receiver.Powered) { appearance.SetData(ConveyorVisuals.State, component.State); } @@ -100,7 +100,7 @@ namespace Content.Server.Conveyor return false; } - if (component.Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) && + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out ApcPowerReceiverComponent? receiver) && !receiver.Powered) { return false; @@ -144,7 +144,7 @@ namespace Content.Server.Conveyor continue; } - if (!entity.TryGetComponent(out IPhysBody? physics) || + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out IPhysBody? physics) || physics.BodyType == BodyType.Static || physics.BodyStatus == BodyStatus.InAir || entity.IsWeightless()) { continue; diff --git a/Content.Server/Crayon/CrayonComponent.cs b/Content.Server/Crayon/CrayonComponent.cs index 19208d6760..9280e9fe65 100644 --- a/Content.Server/Crayon/CrayonComponent.cs +++ b/Content.Server/Crayon/CrayonComponent.cs @@ -97,7 +97,7 @@ namespace Content.Server.Crayon // Opens the selection window bool IUse.UseEntity(UseEntityEventArgs eventArgs) { - if (eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if (IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) { UserInterface?.Toggle(actor.PlayerSession); if (UserInterface?.SessionHasOpen(actor.PlayerSession) == true) @@ -132,7 +132,7 @@ namespace Content.Server.Crayon } var entity = IoCManager.Resolve().SpawnEntity("CrayonDecal", eventArgs.ClickLocation); - if (entity.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out AppearanceComponent? appearance)) { appearance.SetData(CrayonVisuals.State, SelectedState); appearance.SetData(CrayonVisuals.Color, _color); @@ -150,7 +150,7 @@ namespace Content.Server.Crayon void IDropped.Dropped(DroppedEventArgs eventArgs) { - if (eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if (IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) UserInterface?.Close(actor.PlayerSession); } } diff --git a/Content.Server/Cuffs/Components/CuffableComponent.cs b/Content.Server/Cuffs/Components/CuffableComponent.cs index b795502695..896ffc282a 100644 --- a/Content.Server/Cuffs/Components/CuffableComponent.cs +++ b/Content.Server/Cuffs/Components/CuffableComponent.cs @@ -67,7 +67,7 @@ namespace Content.Server.Cuffs.Components if (CuffedHandCount > 0) { - if (LastAddedCuffs.TryGetComponent(out var cuffs)) + if (IoCManager.Resolve().TryGetComponent(LastAddedCuffs.Uid, out var cuffs)) { return new CuffableComponentState(CuffedHandCount, CanStillInteract, @@ -105,14 +105,14 @@ namespace Content.Server.Cuffs.Components } // Success! - if (user.TryGetComponent(out HandsComponent? handsComponent) && handsComponent.IsHolding(handcuff)) + if (IoCManager.Resolve().TryGetComponent(user.Uid, out HandsComponent? handsComponent) && handsComponent.IsHolding(handcuff)) { // Good lord handscomponent is scuffed, I hope some smug person will fix it someday handsComponent.Drop(handcuff); } Container.Insert(handcuff); - CanStillInteract = Owner.TryGetComponent(out HandsComponent? ownerHands) && ownerHands.HandNames.Count() > CuffedHandCount; + CanStillInteract = IoCManager.Resolve().TryGetComponent(Owner.Uid, out HandsComponent? ownerHands) && ownerHands.HandNames.Count() > CuffedHandCount; OnCuffedStateChanged?.Invoke(); UpdateAlert(); @@ -132,7 +132,7 @@ namespace Content.Server.Cuffs.Components /// public void UpdateHeldItems() { - if (!Owner.TryGetComponent(out HandsComponent? handsComponent)) return; + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out HandsComponent? handsComponent)) return; var itemCount = handsComponent.GetAllHeldItems().Count(); var freeHandCount = handsComponent.HandNames.Count() - CuffedHandCount; @@ -159,7 +159,7 @@ namespace Content.Server.Cuffs.Components /// private void UpdateAlert() { - if (Owner.TryGetComponent(out ServerAlertsComponent? status)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ServerAlertsComponent? status)) { if (CanStillInteract) { @@ -201,7 +201,7 @@ namespace Content.Server.Cuffs.Components } } - if (!cuffsToRemove.TryGetComponent(out var cuff)) + if (!IoCManager.Resolve().TryGetComponent(cuffsToRemove.Uid, out var cuff)) { Logger.Warning($"A user is trying to remove handcuffs without a {nameof(HandcuffComponent)}. This should never happen!"); return; @@ -270,13 +270,13 @@ namespace Content.Server.Cuffs.Components cuffsToRemove.Name = cuff.BrokenName; IoCManager.Resolve().GetComponent(cuffsToRemove.Uid).EntityDescription = cuff.BrokenDesc; - if (cuffsToRemove.TryGetComponent(out var sprite) && cuff.BrokenState != null) + if (IoCManager.Resolve().TryGetComponent(cuffsToRemove.Uid, out var sprite) && cuff.BrokenState != null) { sprite.LayerSetState(0, cuff.BrokenState); // TODO: safety check to see if RSI contains the state? } } - CanStillInteract = Owner.TryGetComponent(out HandsComponent? handsComponent) && handsComponent.HandNames.Count() > CuffedHandCount; + CanStillInteract = IoCManager.Resolve().TryGetComponent(Owner.Uid, out HandsComponent? handsComponent) && handsComponent.HandNames.Count() > CuffedHandCount; OnCuffedStateChanged?.Invoke(); UpdateAlert(); Dirty(); diff --git a/Content.Server/Cuffs/Components/HandcuffComponent.cs b/Content.Server/Cuffs/Components/HandcuffComponent.cs index 1de8c3c770..e5cf45d265 100644 --- a/Content.Server/Cuffs/Components/HandcuffComponent.cs +++ b/Content.Server/Cuffs/Components/HandcuffComponent.cs @@ -148,7 +148,7 @@ namespace Content.Server.Cuffs.Components { if (_cuffing) return true; - if (eventArgs.Target == null || !EntitySystem.Get().CanUse(eventArgs.User.Uid) || !eventArgs.Target.TryGetComponent(out var cuffed)) + if (eventArgs.Target == null || !EntitySystem.Get().CanUse(eventArgs.User.Uid) || !IoCManager.Resolve().TryGetComponent(eventArgs.Target.Uid, out var cuffed)) { return false; } @@ -165,7 +165,7 @@ namespace Content.Server.Cuffs.Components return true; } - if (!eventArgs.Target.TryGetComponent(out var hands)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.Target.Uid, out var hands)) { eventArgs.User.PopupMessage(Loc.GetString("handcuff-component-target-has-no-hands-error",("targetName", eventArgs.Target))); return true; diff --git a/Content.Server/Damage/Commands/HurtCommand.cs b/Content.Server/Damage/Commands/HurtCommand.cs index 16ddeabb7f..ee2ba9124a 100644 --- a/Content.Server/Damage/Commands/HurtCommand.cs +++ b/Content.Server/Damage/Commands/HurtCommand.cs @@ -197,7 +197,7 @@ namespace Content.Server.Damage.Commands return; } - if (!entity.TryGetComponent(out DamageableComponent? damageable)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out DamageableComponent? damageable)) { shell.WriteLine($"Entity {entity.Name} with id {entity.Uid} does not have a {nameof(DamageableComponent)}."); return; diff --git a/Content.Server/Damage/Systems/DamageOnToolInteractSystem.cs b/Content.Server/Damage/Systems/DamageOnToolInteractSystem.cs index c15d66126b..7aff24d612 100644 --- a/Content.Server/Damage/Systems/DamageOnToolInteractSystem.cs +++ b/Content.Server/Damage/Systems/DamageOnToolInteractSystem.cs @@ -28,7 +28,7 @@ namespace Content.Server.Damage.Systems return; if (component.WeldingDamage is {} weldingDamage - && args.Used.TryGetComponent(out var welder) + && IoCManager.Resolve().TryGetComponent(args.Used.Uid, out var welder) && welder.Lit) { var dmg = _damageableSystem.TryChangeDamage(args.Target.Uid, weldingDamage); @@ -40,7 +40,7 @@ namespace Content.Server.Damage.Systems args.Handled = true; } else if (component.DefaultDamage is {} damage - && args.Used.TryGetComponent(out var tool) + && IoCManager.Resolve().TryGetComponent(args.Used.Uid, out var tool) && tool.Qualities.ContainsAny(component.Tools)) { var dmg = _damageableSystem.TryChangeDamage(args.Target.Uid, damage); diff --git a/Content.Server/DeviceNetwork/Systems/ApcNetworkSystem.cs b/Content.Server/DeviceNetwork/Systems/ApcNetworkSystem.cs index 2320420f83..844162af7a 100644 --- a/Content.Server/DeviceNetwork/Systems/ApcNetworkSystem.cs +++ b/Content.Server/DeviceNetwork/Systems/ApcNetworkSystem.cs @@ -4,6 +4,7 @@ using JetBrains.Annotations; using Robust.Shared.GameObjects; using Content.Server.Power.EntitySystems; using Content.Server.Power.Nodes; +using Robust.Shared.IoC; namespace Content.Server.DeviceNetwork.Systems { @@ -35,7 +36,7 @@ namespace Content.Server.DeviceNetwork.Systems private void OnProviderConnected(EntityUid uid, ApcNetworkComponent component, ExtensionCableSystem.ProviderConnectedEvent args) { - if (!args.Provider.Owner.TryGetComponent(out NodeContainerComponent? nodeContainer)) return; + if (!IoCManager.Resolve().TryGetComponent(args.Provider.Owner.Uid, out NodeContainerComponent? nodeContainer)) return; if (nodeContainer.TryGetNode("power", out CableNode? node)) { diff --git a/Content.Server/DeviceNetwork/Systems/WirelessNetworkSystem.cs b/Content.Server/DeviceNetwork/Systems/WirelessNetworkSystem.cs index be009b6543..9d3873fdee 100644 --- a/Content.Server/DeviceNetwork/Systems/WirelessNetworkSystem.cs +++ b/Content.Server/DeviceNetwork/Systems/WirelessNetworkSystem.cs @@ -1,6 +1,7 @@ using Content.Server.DeviceNetwork.Components; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.DeviceNetwork.Systems { @@ -24,7 +25,7 @@ namespace Content.Server.DeviceNetwork.Systems var position = sender.Transform.WorldPosition; var distance = (ownPosition - position).Length; - if(sender.TryGetComponent(out var sendingComponent) && distance > sendingComponent.Range) + if(IoCManager.Resolve().TryGetComponent(sender.Uid, out var sendingComponent) && distance > sendingComponent.Range) { args.Cancel(); } diff --git a/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs index 524d386406..5c832cb9b8 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs @@ -36,7 +36,7 @@ namespace Content.Server.Disposal.Tube.Components [ViewVariables] public bool Anchored => - !Owner.TryGetComponent(out IPhysBody? physics) || + !IoCManager.Resolve().TryGetComponent(Owner.Uid, out IPhysBody? physics) || physics.BodyType == BodyType.Static; [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(DisposalRouterUiKey.Key); @@ -160,12 +160,12 @@ namespace Content.Server.Disposal.Tube.Components /// Data relevant to the event such as the actor which triggered it. void IActivate.Activate(ActivateEventArgs args) { - if (!args.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) { return; } - if (!args.User.TryGetComponent(out HandsComponent? hands)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out HandsComponent? hands)) { Owner.PopupMessage(args.User, Loc.GetString("disposal-router-window-tag-input-activate-no-hands")); return; diff --git a/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs index 9c88780bfa..0cbf565891 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs @@ -33,7 +33,7 @@ namespace Content.Server.Disposal.Tube.Components [ViewVariables] public bool Anchored => - !Owner.TryGetComponent(out PhysicsComponent? physics) || + !IoCManager.Resolve().TryGetComponent(Owner.Uid, out PhysicsComponent? physics) || physics.BodyType == BodyType.Static; [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(DisposalTaggerUiKey.Key); @@ -126,12 +126,12 @@ namespace Content.Server.Disposal.Tube.Components /// Data relevant to the event such as the actor which triggered it. void IActivate.Activate(ActivateEventArgs args) { - if (!args.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) { return; } - if (!args.User.TryGetComponent(out HandsComponent? hands)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out HandsComponent? hands)) { Owner.PopupMessage(args.User, Loc.GetString("disposal-tagger-window-activate-no-hands")); return; diff --git a/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs index 4c101fd752..6090457ebc 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs @@ -38,7 +38,7 @@ namespace Content.Server.Disposal.Tube.Components [ViewVariables] private bool Anchored => - !Owner.TryGetComponent(out PhysicsComponent? physics) || + !IoCManager.Resolve().TryGetComponent(Owner.Uid, out PhysicsComponent? physics) || physics.BodyType == BodyType.Static; /// @@ -91,7 +91,7 @@ namespace Content.Server.Disposal.Tube.Components foreach (var entity in Contents.ContainedEntities.ToArray()) { - if (!entity.TryGetComponent(out DisposalHolderComponent? holder)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out DisposalHolderComponent? holder)) { continue; } @@ -109,7 +109,7 @@ namespace Content.Server.Disposal.Tube.Components private void UpdateVisualState() { - if (!Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { return; } @@ -125,7 +125,7 @@ namespace Content.Server.Disposal.Tube.Components public void AnchoredChanged() { - if (!Owner.TryGetComponent(out PhysicsComponent? physics)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out PhysicsComponent? physics)) { return; } diff --git a/Content.Server/Disposal/TubeConnectionsCommand.cs b/Content.Server/Disposal/TubeConnectionsCommand.cs index ba56e48582..45513b1ddf 100644 --- a/Content.Server/Disposal/TubeConnectionsCommand.cs +++ b/Content.Server/Disposal/TubeConnectionsCommand.cs @@ -44,7 +44,7 @@ namespace Content.Server.Disposal return; } - if (!entity.TryGetComponent(out IDisposalTubeComponent? tube)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out IDisposalTubeComponent? tube)) { shell.WriteLine(Loc.GetString("shell-entity-with-uid-lacks-component", ("uid", id), diff --git a/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs b/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs index dac575cb21..341b2fbe62 100644 --- a/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs +++ b/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs @@ -95,7 +95,7 @@ namespace Content.Server.Disposal.Unit.Components return false; } - if (entity.TryGetComponent(out IPhysBody? physics)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out IPhysBody? physics)) { physics.CanCollide = false; } diff --git a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs index 72f0be5e07..b6fe29c6ca 100644 --- a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs +++ b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs @@ -14,6 +14,7 @@ using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Player; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; @@ -74,7 +75,7 @@ namespace Content.Server.Disposal.Unit.Components [ViewVariables] public bool Powered => - !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || + !IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) || receiver.Powered; [ViewVariables] public PressureState State => Pressure >= 1 ? PressureState.Ready : PressureState.Pressurizing; diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs index 1baf67953e..0f95740e0d 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs @@ -47,7 +47,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems foreach (var entity in holder.Container.ContainedEntities.ToArray()) { - if (entity.TryGetComponent(out IPhysBody? physics)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out IPhysBody? physics)) { physics.CanCollide = true; } diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs index c2d3963f96..ff491f4248 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs @@ -172,7 +172,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems #region Eventbus Handlers private void HandleActivate(EntityUid uid, DisposalUnitComponent component, ActivateInWorldEvent args) { - if (!args.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) { return; } @@ -187,7 +187,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems private void HandleInteractHand(EntityUid uid, DisposalUnitComponent component, InteractHandEvent args) { - if (!args.User.TryGetComponent(out ActorComponent? actor)) return; + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) return; // Duplicated code here, not sure how else to get actor inside to make UserInterface happy. @@ -198,7 +198,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems private void HandleInteractUsing(EntityUid uid, DisposalUnitComponent component, InteractUsingEvent args) { - if (!args.User.TryGetComponent(out HandsComponent? hands)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out HandsComponent? hands)) { return; } @@ -302,7 +302,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems { var currentTime = GameTiming.CurTime; - if (!args.Entity.TryGetComponent(out HandsComponent? hands) || + if (!IoCManager.Resolve().TryGetComponent(args.Entity.Uid, out HandsComponent? hands) || hands.Count == 0 || currentTime < component.LastExitAttempt + ExitAttemptDelay) { @@ -351,7 +351,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems if (count > 0) { - if (!component.Owner.TryGetComponent(out PhysicsComponent? disposalsBody)) + if (!IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out PhysicsComponent? disposalsBody)) { component.RecentlyEjected.Clear(); } @@ -504,7 +504,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems public void UpdateVisualState(DisposalUnitComponent component, bool flush) { - if (!component.Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (!IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out AppearanceComponent? appearance)) { return; } @@ -633,7 +633,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems { TryQueueEngage(component); - if (entity.TryGetComponent(out ActorComponent? actor)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ActorComponent? actor)) { component.UserInterface?.Close(actor.PlayerSession); } diff --git a/Content.Server/Doors/Components/FirelockComponent.cs b/Content.Server/Doors/Components/FirelockComponent.cs index 1e43518e69..7b66c55db4 100644 --- a/Content.Server/Doors/Components/FirelockComponent.cs +++ b/Content.Server/Doors/Components/FirelockComponent.cs @@ -2,6 +2,7 @@ using Content.Server.Atmos.Components; using Content.Server.Atmos.EntitySystems; using Content.Shared.Doors; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.Doors.Components @@ -30,7 +31,7 @@ namespace Content.Server.Doors.Components if (DoorComponent != null && DoorComponent.State == SharedDoorComponent.DoorState.Open && DoorComponent.CanCloseGeneric()) { DoorComponent.Close(); - if (Owner.TryGetComponent(out AirtightComponent? airtight)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AirtightComponent? airtight)) { EntitySystem.Get().SetAirblocked(airtight, true); } diff --git a/Content.Server/Doors/Components/ServerDoorComponent.cs b/Content.Server/Doors/Components/ServerDoorComponent.cs index c7f0c54fe7..a06f0eb2dd 100644 --- a/Content.Server/Doors/Components/ServerDoorComponent.cs +++ b/Content.Server/Doors/Components/ServerDoorComponent.cs @@ -291,7 +291,7 @@ namespace Content.Server.Doors.Components { Open(); - if (user.TryGetComponent(out HandsComponent? hands) && hands.Count == 0) + if (IoCManager.Resolve().TryGetComponent(user.Uid, out HandsComponent? hands) && hands.Count == 0) { SoundSystem.Play(Filter.Pvs(Owner), _tryOpenDoorSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2)); @@ -310,7 +310,7 @@ namespace Content.Server.Doors.Components return false; } - if (!Owner.TryGetComponent(out AccessReader? access)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out AccessReader? access)) { return true; } @@ -334,7 +334,7 @@ namespace Content.Server.Doors.Components /// private bool HasAccessType(string accessType) { - if (Owner.TryGetComponent(out AccessReader? access)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AccessReader? access)) { return access.AccessLists.Any(list => list.Contains(accessType)); } @@ -365,12 +365,12 @@ namespace Content.Server.Doors.Components public void Open() { State = DoorState.Opening; - if (Occludes && Owner.TryGetComponent(out OccluderComponent? occluder)) + if (Occludes && IoCManager.Resolve().TryGetComponent(Owner.Uid, out OccluderComponent? occluder)) { occluder.Enabled = false; } - if (ChangeAirtight && Owner.TryGetComponent(out AirtightComponent? airtight)) + if (ChangeAirtight && IoCManager.Resolve().TryGetComponent(Owner.Uid, out AirtightComponent? airtight)) { EntitySystem.Get().SetAirblocked(airtight, false); } @@ -398,7 +398,7 @@ namespace Content.Server.Doors.Components { base.OnPartialOpen(); - if (ChangeAirtight && Owner.TryGetComponent(out AirtightComponent? airtight)) + if (ChangeAirtight && IoCManager.Resolve().TryGetComponent(Owner.Uid, out AirtightComponent? airtight)) { EntitySystem.Get().SetAirblocked(airtight, false); } @@ -408,7 +408,7 @@ namespace Content.Server.Doors.Components private void QuickOpen(bool refresh) { - if (Occludes && Owner.TryGetComponent(out OccluderComponent? occluder)) + if (Occludes && IoCManager.Resolve().TryGetComponent(Owner.Uid, out OccluderComponent? occluder)) { occluder.Enabled = false; } @@ -445,7 +445,7 @@ namespace Content.Server.Doors.Components return false; } - if (!Owner.TryGetComponent(out AccessReader? access)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out AccessReader? access)) { return true; } @@ -483,7 +483,7 @@ namespace Content.Server.Doors.Components { var safety = SafetyCheck(); - if (safety && Owner.TryGetComponent(out PhysicsComponent? physicsComponent)) + if (safety && IoCManager.Resolve().TryGetComponent(Owner.Uid, out PhysicsComponent? physicsComponent)) { var broadPhaseSystem = EntitySystem.Get(); @@ -527,7 +527,7 @@ namespace Content.Server.Doors.Components OnPartialClose(); await Timer.Delay(CloseTimeTwo, _stateChangeCancelTokenSource.Token); - if (Occludes && Owner.TryGetComponent(out OccluderComponent? occluder)) + if (Occludes && IoCManager.Resolve().TryGetComponent(Owner.Uid, out OccluderComponent? occluder)) { occluder.Enabled = true; } @@ -543,7 +543,7 @@ namespace Content.Server.Doors.Components // if safety is off, crushes people inside of the door, temporarily turning off collisions with them while doing so. var becomeairtight = ChangeAirtight && (SafetyCheck() || !TryCrush()); - if (becomeairtight && Owner.TryGetComponent(out AirtightComponent? airtight)) + if (becomeairtight && IoCManager.Resolve().TryGetComponent(Owner.Uid, out AirtightComponent? airtight)) { EntitySystem.Get().SetAirblocked(airtight, true); } @@ -673,7 +673,7 @@ namespace Content.Server.Doors.Components async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { - if(!eventArgs.Using.TryGetComponent(out ToolComponent? tool)) + if(!IoCManager.Resolve().TryGetComponent(eventArgs.Using.Uid, out ToolComponent? tool)) { return false; } @@ -710,7 +710,7 @@ namespace Content.Server.Doors.Components } // for welding doors - if (CanWeldShut && tool.Owner.TryGetComponent(out WelderComponent? welder) && welder.Lit) + if (CanWeldShut && IoCManager.Resolve().TryGetComponent(tool.Owner.Uid, out WelderComponent? welder) && welder.Lit) { if(!_beingWelded) { @@ -745,7 +745,7 @@ namespace Content.Server.Doors.Components private void CreateDoorElectronicsBoard() { // Ensure that the construction component is aware of the board container. - if (Owner.TryGetComponent(out ConstructionComponent? construction)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ConstructionComponent? construction)) EntitySystem.Get().AddContainer(Owner.Uid, "board", construction); // We don't do anything if this is null or empty. diff --git a/Content.Server/Doors/Systems/AirlockSystem.cs b/Content.Server/Doors/Systems/AirlockSystem.cs index ea5dc50f6b..df81252479 100644 --- a/Content.Server/Doors/Systems/AirlockSystem.cs +++ b/Content.Server/Doors/Systems/AirlockSystem.cs @@ -4,6 +4,7 @@ using Content.Shared.Doors; using Content.Shared.Popups; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; namespace Content.Server.Doors.Systems @@ -87,7 +88,7 @@ namespace Content.Server.Doors.Systems private void OnDoorClickShouldActivate(EntityUid uid, AirlockComponent component, DoorClickShouldActivateEvent args) { if (component.WiresComponent != null && component.WiresComponent.IsPanelOpen && - args.Args.User.TryGetComponent(out ActorComponent? actor)) + IoCManager.Resolve().TryGetComponent(args.Args.User.Uid, out ActorComponent? actor)) { component.WiresComponent.OpenInterface(actor.PlayerSession); args.Handled = true; diff --git a/Content.Server/Engineering/EntitySystems/DisassembleOnActivateSystem.cs b/Content.Server/Engineering/EntitySystems/DisassembleOnActivateSystem.cs index 3f92c21c58..4bb25a43e6 100644 --- a/Content.Server/Engineering/EntitySystems/DisassembleOnActivateSystem.cs +++ b/Content.Server/Engineering/EntitySystems/DisassembleOnActivateSystem.cs @@ -46,8 +46,8 @@ namespace Content.Server.Engineering.EntitySystems var entity = EntityManager.SpawnEntity(component.Prototype, component.Owner.Transform.Coordinates); - if (args.User.TryGetComponent(out var hands) - && entity.TryGetComponent(out var item)) + if (IoCManager.Resolve().TryGetComponent(args.User.Uid, out var hands) + && IoCManager.Resolve().TryGetComponent(entity.Uid, out var item)) { hands.PutInHandOrDrop(item); } diff --git a/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs b/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs index 592bf018dc..371ede26e8 100644 --- a/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs +++ b/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs @@ -60,7 +60,7 @@ namespace Content.Server.Engineering.EntitySystems if (component.Deleted || (!IoCManager.Resolve().EntityExists(component.Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(component.Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) return; - if (component.Owner.TryGetComponent(out var stackComp) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out var stackComp) && component.RemoveOnInteract && !_stackSystem.Use(uid, 1, stackComp)) { return; diff --git a/Content.Server/Explosion/Components/ClusterFlashComponent.cs b/Content.Server/Explosion/Components/ClusterFlashComponent.cs index b12fd96e75..ac21046678 100644 --- a/Content.Server/Explosion/Components/ClusterFlashComponent.cs +++ b/Content.Server/Explosion/Components/ClusterFlashComponent.cs @@ -155,7 +155,7 @@ namespace Content.Server.Explosion.Components private void UpdateAppearance() { - if (!Owner.TryGetComponent(out AppearanceComponent? appearance)) return; + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) return; appearance.SetData(ClusterFlashVisuals.GrenadesCounter, _grenadesContainer.ContainedEntities.Count + _unspawnedCount); } diff --git a/Content.Server/Explosion/Components/OnUseTimerTriggerComponent.cs b/Content.Server/Explosion/Components/OnUseTimerTriggerComponent.cs index 4268139833..2a2a8a2c19 100644 --- a/Content.Server/Explosion/Components/OnUseTimerTriggerComponent.cs +++ b/Content.Server/Explosion/Components/OnUseTimerTriggerComponent.cs @@ -3,6 +3,7 @@ using Content.Server.Explosion.EntitySystems; using Content.Shared.Interaction; using Content.Shared.Trigger; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.Explosion.Components @@ -18,7 +19,7 @@ namespace Content.Server.Explosion.Components // TODO: Need to split this out so it's a generic "OnUseTimerTrigger" component. public void Trigger(IEntity user) { - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) appearance.SetData(TriggerVisuals.VisualState, TriggerVisualState.Primed); EntitySystem.Get().HandleTimerTrigger(TimeSpan.FromSeconds(_delay), Owner, user); diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs index 76e1f5229b..06d1861a9b 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs @@ -82,7 +82,7 @@ namespace Content.Server.Explosion.EntitySystems foreach (var player in players) { - if (player.AttachedEntity == null || !player.AttachedEntity.TryGetComponent(out CameraRecoilComponent? recoil)) + if (player.AttachedEntity == null || !IoCManager.Resolve().TryGetComponent(player.AttachedEntity.Uid, out CameraRecoilComponent? recoil)) { continue; } @@ -141,7 +141,7 @@ namespace Content.Server.Explosion.EntitySystems continue; } - if (!entity.TryGetComponent(out PhysicsComponent? body) || body.Fixtures.Count < 1) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out PhysicsComponent? body) || body.Fixtures.Count < 1) { continue; } diff --git a/Content.Server/Extinguisher/FireExtinguisherComponent.cs b/Content.Server/Extinguisher/FireExtinguisherComponent.cs index 5d90ce7b9f..bcab8b78fd 100644 --- a/Content.Server/Extinguisher/FireExtinguisherComponent.cs +++ b/Content.Server/Extinguisher/FireExtinguisherComponent.cs @@ -104,13 +104,13 @@ namespace Content.Server.Extinguisher _safety = state; - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) appearance.SetData(FireExtinguisherVisuals.Safety, _safety); } void IDropped.Dropped(DroppedEventArgs eventArgs) { - if (_hasSafety && Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (_hasSafety && IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) appearance.SetData(FireExtinguisherVisuals.Safety, _safety); } } diff --git a/Content.Server/Flash/FlashSystem.cs b/Content.Server/Flash/FlashSystem.cs index 173e920c64..30e2221ef4 100644 --- a/Content.Server/Flash/FlashSystem.cs +++ b/Content.Server/Flash/FlashSystem.cs @@ -88,7 +88,7 @@ namespace Content.Server.Flash if (comp.HasUses) { // TODO flash visualizer - if (!comp.Owner.TryGetComponent(out var sprite)) + if (!IoCManager.Resolve().TryGetComponent(comp.Owner.Uid, out var sprite)) return false; if (--comp.Uses == 0) diff --git a/Content.Server/Fluids/Components/BucketComponent.cs b/Content.Server/Fluids/Components/BucketComponent.cs index f6d1cc9db7..24c92713a8 100644 --- a/Content.Server/Fluids/Components/BucketComponent.cs +++ b/Content.Server/Fluids/Components/BucketComponent.cs @@ -56,7 +56,7 @@ namespace Content.Server.Fluids.Components var solutionsSys = EntitySystem.Get(); if (!solutionsSys.TryGetSolution(Owner.Uid, SolutionName, out var contents) || _currentlyUsing.Contains(eventArgs.Using.Uid) || - !eventArgs.Using.TryGetComponent(out MopComponent? mopComponent) || + !IoCManager.Resolve().TryGetComponent(eventArgs.Using.Uid, out MopComponent? mopComponent) || mopComponent.Mopping) { return false; diff --git a/Content.Server/Fluids/Components/SpillExtensions.cs b/Content.Server/Fluids/Components/SpillExtensions.cs index 5815ab2a12..c31c9c12e6 100644 --- a/Content.Server/Fluids/Components/SpillExtensions.cs +++ b/Content.Server/Fluids/Components/SpillExtensions.cs @@ -118,7 +118,7 @@ namespace Content.Server.Fluids.Components { foreach (var entity in tileRef.GetEntitiesInTileFast(gridTileLookupSystem)) { - if (entity.TryGetComponent(out PuddleComponent? p)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out PuddleComponent? p)) { puddle = p; return true; @@ -183,7 +183,7 @@ namespace Content.Server.Fluids.Components { foreach (var spillEntity in spillEntities) { - if (!spillEntity.TryGetComponent(out PuddleComponent? puddleComponent)) continue; + if (!IoCManager.Resolve().TryGetComponent(spillEntity.Uid, out PuddleComponent? puddleComponent)) continue; if (!overflow && puddleSystem.WouldOverflow(puddleComponent.Owner.Uid, solution, puddleComponent)) return null; diff --git a/Content.Server/Fluids/Components/SprayComponent.cs b/Content.Server/Fluids/Components/SprayComponent.cs index 04c99ec285..955789fdcb 100644 --- a/Content.Server/Fluids/Components/SprayComponent.cs +++ b/Content.Server/Fluids/Components/SprayComponent.cs @@ -137,7 +137,7 @@ namespace Content.Server.Fluids.Components var vapor = entManager.SpawnEntity(_vaporPrototype, playerPos.Offset(distance < 1 ? quarter : threeQuarters)); vapor.Transform.LocalRotation = rotation; - if (vapor.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(vapor.Uid, out AppearanceComponent? appearance)) { appearance.SetData(VaporVisuals.Color, contents.Color.WithAlpha(1f)); appearance.SetData(VaporVisuals.State, true); @@ -152,7 +152,7 @@ namespace Content.Server.Fluids.Components var impulseDirection = vapor.Transform.WorldRotation.ToVec(); vaporSystem.Start(vaporComponent, impulseDirection, _sprayVelocity, target, _sprayAliveTime); - if (_impulse > 0f && eventArgs.User.TryGetComponent(out IPhysBody? body)) + if (_impulse > 0f && IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out IPhysBody? body)) { body.ApplyLinearImpulse(-impulseDirection * _impulse); } @@ -163,7 +163,7 @@ namespace Content.Server.Fluids.Components _lastUseTime = curTime; _cooldownEnd = _lastUseTime + TimeSpan.FromSeconds(_cooldownTime); - if (Owner.TryGetComponent(out ItemCooldownComponent? cooldown)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ItemCooldownComponent? cooldown)) { cooldown.CooldownStart = _lastUseTime; cooldown.CooldownEnd = _cooldownEnd; diff --git a/Content.Server/GameTicking/Presets/GamePreset.cs b/Content.Server/GameTicking/Presets/GamePreset.cs index 7756df24aa..63da616ee4 100644 --- a/Content.Server/GameTicking/Presets/GamePreset.cs +++ b/Content.Server/GameTicking/Presets/GamePreset.cs @@ -58,7 +58,7 @@ namespace Content.Server.GameTicking.Presets // (If the mob survives, that's a bug. Ghosting is kept regardless.) var canReturn = canReturnGlobal && mind.CharacterDeadPhysically; - if (playerEntity != null && canReturnGlobal && playerEntity.TryGetComponent(out MobStateComponent? mobState)) + if (playerEntity != null && canReturnGlobal && IoCManager.Resolve().TryGetComponent(playerEntity.Uid, out MobStateComponent? mobState)) { if (mobState.IsCritical()) { diff --git a/Content.Server/GameTicking/Presets/PresetTraitorDeathMatch.cs b/Content.Server/GameTicking/Presets/PresetTraitorDeathMatch.cs index d47fe15ab1..785eba5cc5 100644 --- a/Content.Server/GameTicking/Presets/PresetTraitorDeathMatch.cs +++ b/Content.Server/GameTicking/Presets/PresetTraitorDeathMatch.cs @@ -80,7 +80,7 @@ namespace Content.Server.GameTicking.Presets // Delete anything that may contain "dangerous" role-specific items. // (This includes the PDA, as everybody gets the captain PDA in this mode for true-all-access reasons.) - if (mind.OwnedEntity != null && mind.OwnedEntity.TryGetComponent(out InventoryComponent? inventory)) + if (mind.OwnedEntity != null && IoCManager.Resolve().TryGetComponent(mind.OwnedEntity.Uid, out InventoryComponent? inventory)) { var victimSlots = new[] {EquipmentSlotDefines.Slots.IDCARD, EquipmentSlotDefines.Slots.BELT, EquipmentSlotDefines.Slots.BACKPACK}; foreach (var slot in victimSlots) @@ -151,7 +151,7 @@ namespace Content.Server.GameTicking.Presets var avoidMeEntity = avoidMeMind.OwnedEntity; if (avoidMeEntity == null) continue; - if (avoidMeEntity.TryGetComponent(out MobStateComponent? mobState)) + if (IoCManager.Resolve().TryGetComponent(avoidMeEntity.Uid, out MobStateComponent? mobState)) { // Does have mob state component; if critical or dead, they don't really matter for spawn checks if (mobState.IsCritical() || mobState.IsDead()) @@ -198,7 +198,7 @@ namespace Content.Server.GameTicking.Presets public override bool OnGhostAttempt(Mind.Mind mind, bool canReturnGlobal) { var entity = mind.OwnedEntity; - if ((entity != null) && (entity.TryGetComponent(out MobStateComponent? mobState))) + if ((entity != null) && IoCManager.Resolve().TryGetComponent(entity.Uid, out MobStateComponent? mobState)) { if (mobState.IsCritical()) { diff --git a/Content.Server/GameTicking/Rules/RuleDeathMatch.cs b/Content.Server/GameTicking/Rules/RuleDeathMatch.cs index 003cb8d4fb..2ee27b63fb 100644 --- a/Content.Server/GameTicking/Rules/RuleDeathMatch.cs +++ b/Content.Server/GameTicking/Rules/RuleDeathMatch.cs @@ -64,7 +64,7 @@ namespace Content.Server.GameTicking.Rules { var playerEntity = playerSession.AttachedEntity; if (playerEntity == null - || !playerEntity.TryGetComponent(out MobStateComponent? state)) + || !IoCManager.Resolve().TryGetComponent(playerEntity.Uid, out MobStateComponent? state)) { continue; } diff --git a/Content.Server/GameTicking/Rules/RuleSuspicion.cs b/Content.Server/GameTicking/Rules/RuleSuspicion.cs index 1d48c92ab0..e3a6c69ba9 100644 --- a/Content.Server/GameTicking/Rules/RuleSuspicion.cs +++ b/Content.Server/GameTicking/Rules/RuleSuspicion.cs @@ -91,7 +91,7 @@ namespace Content.Server.GameTicking.Rules foreach (var playerSession in _playerManager.ServerSessions) { if (playerSession.AttachedEntity == null - || !playerSession.AttachedEntity.TryGetComponent(out MobStateComponent? mobState) + || !IoCManager.Resolve().TryGetComponent(playerSession.AttachedEntity.Uid, out MobStateComponent? mobState) || !IoCManager.Resolve().HasComponent(playerSession.AttachedEntity.Uid)) { continue; diff --git a/Content.Server/Ghost/Components/GhostRadioComponent.cs b/Content.Server/Ghost/Components/GhostRadioComponent.cs index 7ce0d58b50..7929e5e116 100644 --- a/Content.Server/Ghost/Components/GhostRadioComponent.cs +++ b/Content.Server/Ghost/Components/GhostRadioComponent.cs @@ -26,7 +26,7 @@ namespace Content.Server.Ghost.Components public void Receive(string message, int channel, IEntity speaker) { - if (!Owner.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out ActorComponent? actor)) return; var playerChannel = actor.PlayerSession.ConnectedClient; diff --git a/Content.Server/Ghost/GhostSystem.cs b/Content.Server/Ghost/GhostSystem.cs index adf783b4cd..7f8269e2bd 100644 --- a/Content.Server/Ghost/GhostSystem.cs +++ b/Content.Server/Ghost/GhostSystem.cs @@ -64,7 +64,7 @@ namespace Content.Server.Ghost visibility.Layer |= (int) VisibilityFlags.Ghost; visibility.Layer &= ~(int) VisibilityFlags.Normal; - if (component.Owner.TryGetComponent(out EyeComponent? eye)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out EyeComponent? eye)) { eye.VisibilityMask |= (uint) VisibilityFlags.Ghost; } @@ -78,14 +78,14 @@ namespace Content.Server.Ghost if ((!IoCManager.Resolve().EntityExists(component.Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(component.Owner.Uid).EntityLifeStage) < EntityLifeStage.Terminating) { // Entity can't be seen by ghosts anymore. - if (component.Owner.TryGetComponent(out VisibilityComponent? visibility)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out VisibilityComponent? visibility)) { visibility.Layer &= ~(int) VisibilityFlags.Ghost; visibility.Layer |= (int) VisibilityFlags.Normal; } // Entity can't see ghosts anymore. - if (component.Owner.TryGetComponent(out EyeComponent? eye)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out EyeComponent? eye)) { eye.VisibilityMask &= ~(uint) VisibilityFlags.Ghost; } @@ -132,9 +132,9 @@ namespace Content.Server.Ghost var entity = args.SenderSession.AttachedEntity; if (entity == null || - !entity.TryGetComponent(out GhostComponent? ghost) || + !IoCManager.Resolve().TryGetComponent(entity.Uid, out GhostComponent? ghost) || !ghost.CanReturnToBody || - !entity.TryGetComponent(out ActorComponent? actor)) + !IoCManager.Resolve().TryGetComponent(entity.Uid, out ActorComponent? actor)) { Logger.Warning($"User {args.SenderSession.Name} sent an invalid {nameof(GhostReturnToBodyRequest)}"); return; @@ -146,7 +146,7 @@ namespace Content.Server.Ghost private void OnGhostWarpToLocationRequest(GhostWarpToLocationRequestEvent msg, EntitySessionEventArgs args) { if (args.SenderSession.AttachedEntity == null || - !args.SenderSession.AttachedEntity.TryGetComponent(out GhostComponent? ghost)) + !IoCManager.Resolve().TryGetComponent(args.SenderSession.AttachedEntity.Uid, out GhostComponent? ghost)) { Logger.Warning($"User {args.SenderSession.Name} tried to warp to {msg.Name} without being a ghost."); return; @@ -163,7 +163,7 @@ namespace Content.Server.Ghost private void OnGhostWarpToTargetRequest(GhostWarpToTargetRequestEvent msg, EntitySessionEventArgs args) { if (args.SenderSession.AttachedEntity == null || - !args.SenderSession.AttachedEntity.TryGetComponent(out GhostComponent? ghost)) + !IoCManager.Resolve().TryGetComponent(args.SenderSession.AttachedEntity.Uid, out GhostComponent? ghost)) { Logger.Warning($"User {args.SenderSession.Name} tried to warp to {msg.Target} without being a ghost."); return; @@ -185,7 +185,7 @@ namespace Content.Server.Ghost || (!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) == EntityLifeStage.Terminating) return; - if (entity.TryGetComponent(out var mind)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out var mind)) mind.GhostOnShutdown = false; IoCManager.Resolve().DeleteEntity(entity.Uid); } diff --git a/Content.Server/Gravity/EntitySystems/GravityShakeSystem.cs b/Content.Server/Gravity/EntitySystems/GravityShakeSystem.cs index a4653cf6e8..f24d511961 100644 --- a/Content.Server/Gravity/EntitySystems/GravityShakeSystem.cs +++ b/Content.Server/Gravity/EntitySystems/GravityShakeSystem.cs @@ -81,7 +81,7 @@ namespace Content.Server.Gravity.EntitySystems { if (player.AttachedEntity == null || player.AttachedEntity.Transform.GridID != gridId - || !player.AttachedEntity.TryGetComponent(out CameraRecoilComponent? recoil)) + || !IoCManager.Resolve().TryGetComponent(player.AttachedEntity.Uid, out CameraRecoilComponent? recoil)) { continue; } diff --git a/Content.Server/Gravity/EntitySystems/WeightlessSystem.cs b/Content.Server/Gravity/EntitySystems/WeightlessSystem.cs index 1baa981e24..c660bed6e0 100644 --- a/Content.Server/Gravity/EntitySystems/WeightlessSystem.cs +++ b/Content.Server/Gravity/EntitySystems/WeightlessSystem.cs @@ -99,13 +99,13 @@ namespace Content.Server.Gravity.EntitySystems private void EntParentChanged(ref EntParentChangedMessage ev) { - if (!ev.Entity.TryGetComponent(out ServerAlertsComponent? status)) + if (!IoCManager.Resolve().TryGetComponent(ev.Entity.Uid, out ServerAlertsComponent? status)) { return; } if (ev.OldParent != null && - ev.OldParent.TryGetComponent(out IMapGridComponent? mapGrid)) + IoCManager.Resolve().TryGetComponent(ev.OldParent.Uid, out IMapGridComponent? mapGrid)) { var oldGrid = mapGrid.GridIndex; diff --git a/Content.Server/Hands/Components/HandsComponent.cs b/Content.Server/Hands/Components/HandsComponent.cs index 0d1fae024d..caae8f95a2 100644 --- a/Content.Server/Hands/Components/HandsComponent.cs +++ b/Content.Server/Hands/Components/HandsComponent.cs @@ -38,12 +38,12 @@ namespace Content.Server.Hands.Components protected override void OnHeldEntityRemovedFromHand(IEntity heldEntity, HandState handState) { - if (heldEntity.TryGetComponent(out ItemComponent? item)) + if (IoCManager.Resolve().TryGetComponent(heldEntity.Uid, out ItemComponent? item)) { item.RemovedFromSlot(); _entitySystemManager.GetEntitySystem().UnequippedHandInteraction(Owner, heldEntity, handState); } - if (heldEntity.TryGetComponent(out SpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(heldEntity.Uid, out SpriteComponent? sprite)) { sprite.RenderOrder = IoCManager.Resolve().CurrentTick.Value; } @@ -123,8 +123,8 @@ namespace Content.Server.Hands.Components private bool BreakPulls() { // What is this API?? - if (!Owner.TryGetComponent(out SharedPullerComponent? puller) - || puller.Pulling == null || !puller.Pulling.TryGetComponent(out SharedPullableComponent? pullable)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out SharedPullerComponent? puller) + || puller.Pulling == null || !IoCManager.Resolve().TryGetComponent(puller.Pulling.Uid, out SharedPullableComponent? pullable)) return false; return _entitySystemManager.GetEntitySystem().TryStopPull(pullable); @@ -163,7 +163,7 @@ namespace Content.Server.Hands.Components if (!TryGetHeldEntity(handName, out var heldEntity)) return null; - heldEntity.TryGetComponent(out ItemComponent? item); + IoCManager.Resolve().TryGetComponent(heldEntity.Uid, out ItemComponent? item); return item; } @@ -177,7 +177,7 @@ namespace Content.Server.Hands.Components if (!TryGetHeldEntity(handName, out var heldEntity)) return false; - return heldEntity.TryGetComponent(out item); + return IoCManager.Resolve().TryGetComponent(heldEntity.Uid, out item); } /// @@ -190,7 +190,7 @@ namespace Content.Server.Hands.Components if (!TryGetActiveHeldEntity(out var heldEntity)) return null; - heldEntity.TryGetComponent(out ItemComponent? item); + IoCManager.Resolve().TryGetComponent(heldEntity.Uid, out ItemComponent? item); return item; } } @@ -199,7 +199,7 @@ namespace Content.Server.Hands.Components { foreach (var entity in GetAllHeldEntities()) { - if (entity.TryGetComponent(out ItemComponent? item)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ItemComponent? item)) yield return item; } } diff --git a/Content.Server/Hands/Systems/HandsSystem.cs b/Content.Server/Hands/Systems/HandsSystem.cs index 6c9dfbaec1..291506991c 100644 --- a/Content.Server/Hands/Systems/HandsSystem.cs +++ b/Content.Server/Hands/Systems/HandsSystem.cs @@ -85,7 +85,7 @@ namespace Content.Server.Hands.Systems foreach (var hand in component.Hands) { if (hand.HeldEntity == null - || !hand.HeldEntity.TryGetComponent(out HandVirtualItemComponent? virtualItem) + || !IoCManager.Resolve().TryGetComponent(hand.HeldEntity.Uid, out HandVirtualItemComponent? virtualItem) || virtualItem.BlockingEntity != args.Pulled.Owner.Uid) continue; @@ -101,7 +101,7 @@ namespace Content.Server.Hands.Systems if (player == null) return; - if (!player.TryGetComponent(out SharedHandsComponent? hands)) + if (!IoCManager.Resolve().TryGetComponent(player.Uid, out SharedHandsComponent? hands)) return; if (!hands.TryGetSwapHandsResult(out var nextHand)) @@ -117,7 +117,7 @@ namespace Content.Server.Hands.Systems if (player == null) return false; - if (!player.TryGetComponent(out SharedHandsComponent? hands)) + if (!IoCManager.Resolve().TryGetComponent(player.Uid, out SharedHandsComponent? hands)) return false; var activeHand = hands.ActiveHand; @@ -194,7 +194,7 @@ namespace Content.Server.Hands.Systems if (playerEnt == null || !IoCManager.Resolve().EntityExists(playerEnt.Uid)) return false; - return playerEnt.TryGetComponent(out hands); + return IoCManager.Resolve().TryGetComponent(playerEnt.Uid, out hands); } private void HandleActivateItem(ICommonSession? session) @@ -223,12 +223,12 @@ namespace Content.Server.Hands.Systems if (playerEnt == null || !IoCManager.Resolve().EntityExists(playerEnt.Uid) || playerEnt.IsInContainer() || - !playerEnt.TryGetComponent(out SharedHandsComponent? hands) || + !IoCManager.Resolve().TryGetComponent(playerEnt.Uid, out SharedHandsComponent? hands) || !hands.TryGetActiveHeldEntity(out var throwEnt) || !_actionBlockerSystem.CanThrow(playerEnt.Uid)) return false; - if (throwEnt.TryGetComponent(out StackComponent? stack) && stack.Count > 1 && stack.ThrowIndividually) + if (IoCManager.Resolve().TryGetComponent(throwEnt.Uid, out StackComponent? stack) && stack.Count > 1 && stack.ThrowIndividually) { var splitStack = _stackSystem.Split(throwEnt.Uid, 1, playerEnt.Transform.Coordinates, stack); @@ -272,12 +272,12 @@ namespace Content.Server.Hands.Systems if (plyEnt == null || !IoCManager.Resolve().EntityExists(plyEnt.Uid)) return; - if (!plyEnt.TryGetComponent(out SharedHandsComponent? hands) || - !plyEnt.TryGetComponent(out InventoryComponent? inventory)) + if (!IoCManager.Resolve().TryGetComponent(plyEnt.Uid, out SharedHandsComponent? hands) || + !IoCManager.Resolve().TryGetComponent(plyEnt.Uid, out InventoryComponent? inventory)) return; if (!inventory.TryGetSlotItem(equipmentSlot, out ItemComponent? equipmentItem) || - !equipmentItem.Owner.TryGetComponent(out ServerStorageComponent? storageComponent)) + !IoCManager.Resolve().TryGetComponent(equipmentItem.Owner.Uid, out ServerStorageComponent? storageComponent)) { plyEnt.PopupMessage(Loc.GetString("hands-system-missing-equipment-slot", ("slotName", SlotNames[equipmentSlot].ToLower()))); return; diff --git a/Content.Server/Headset/HeadsetComponent.cs b/Content.Server/Headset/HeadsetComponent.cs index 5256d9c8e1..a9c6cd7e54 100644 --- a/Content.Server/Headset/HeadsetComponent.cs +++ b/Content.Server/Headset/HeadsetComponent.cs @@ -59,7 +59,7 @@ namespace Content.Server.Headset { if (Owner.TryGetContainer(out var container)) { - if (!container.Owner.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(container.Owner.Uid, out ActorComponent? actor)) return; var playerChannel = actor.PlayerSession.ConnectedClient; diff --git a/Content.Server/Interaction/InteractionSystem.cs b/Content.Server/Interaction/InteractionSystem.cs index 5cdc5c5727..979dcbe68c 100644 --- a/Content.Server/Interaction/InteractionSystem.cs +++ b/Content.Server/Interaction/InteractionSystem.cs @@ -225,7 +225,7 @@ namespace Content.Server.Interaction return true; } - if (userEntity.TryGetComponent(out CombatModeComponent? combatMode) && combatMode.IsInCombatMode) + if (IoCManager.Resolve().TryGetComponent(userEntity.Uid, out CombatModeComponent? combatMode) && combatMode.IsInCombatMode) DoAttack(userEntity, coords, true); return true; @@ -291,7 +291,7 @@ namespace Content.Server.Interaction if (!InRangeUnobstructed(userEntity, pulledObject, popup: true)) return false; - if (!pulledObject.TryGetComponent(out SharedPullableComponent? pull)) + if (!IoCManager.Resolve().TryGetComponent(pulledObject.Uid, out SharedPullableComponent? pull)) return false; return _pullSystem.TogglePull(userEntity, pull); @@ -309,7 +309,7 @@ namespace Content.Server.Interaction public async void UserInteraction(IEntity user, EntityCoordinates coordinates, EntityUid clickedUid, bool altInteract = false) { // TODO COMBAT Consider using alt-interact for advanced combat? maybe alt-interact disarms? - if (!altInteract && user.TryGetComponent(out CombatModeComponent? combatMode) && combatMode.IsInCombatMode) + if (!altInteract && IoCManager.Resolve().TryGetComponent(user.Uid, out CombatModeComponent? combatMode) && combatMode.IsInCombatMode) { DoAttack(user, coordinates, false, clickedUid); return; @@ -334,7 +334,7 @@ namespace Content.Server.Interaction } // Verify user has a hand, and find what object they are currently holding in their active hand - if (!user.TryGetComponent(out var hands)) + if (!IoCManager.Resolve().TryGetComponent(user.Uid, out var hands)) return; var item = hands.GetActiveHand?.Owner; @@ -481,7 +481,7 @@ namespace Content.Server.Interaction } // Verify user has a hand, and find what object they are currently holding in their active hand - if (user.TryGetComponent(out var hands)) + if (IoCManager.Resolve().TryGetComponent(user.Uid, out var hands)) { var item = hands.GetActiveHand?.Owner; diff --git a/Content.Server/Inventory/Components/InventoryComponent.cs b/Content.Server/Inventory/Components/InventoryComponent.cs index 6477c3a5e1..1df18d760a 100644 --- a/Content.Server/Inventory/Components/InventoryComponent.cs +++ b/Content.Server/Inventory/Components/InventoryComponent.cs @@ -225,7 +225,7 @@ namespace Content.Server.Inventory.Components } } - if (Owner.TryGetComponent(out IInventoryController? controller)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out IInventoryController? controller)) { pass = controller.CanEquip(slot, item.Owner, pass, out var controllerReason); reason = controllerReason ?? reason; @@ -411,7 +411,7 @@ namespace Content.Server.Inventory.Components if (container is not ContainerSlot slot || !_slotContainers.ContainsValue(slot)) return; - if (entity.TryGetComponent(out ItemComponent? itemComp)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ItemComponent? itemComp)) { itemComp.RemovedFromSlot(); } @@ -434,7 +434,7 @@ namespace Content.Server.Inventory.Components var hands = IoCManager.Resolve().GetComponent(Owner.Uid); var activeHand = hands.ActiveHand; var activeItem = hands.GetActiveHand; - if (activeHand != null && activeItem != null && activeItem.Owner.TryGetComponent(out ItemComponent? item)) + if (activeHand != null && activeItem != null && IoCManager.Resolve().TryGetComponent(activeItem.Owner.Uid, out ItemComponent? item)) { hands.TryDropNoInteraction(); if (!Equip(msg.Inventoryslot, item, true, out var reason)) @@ -511,7 +511,7 @@ namespace Content.Server.Inventory.Components if (!HasSlot(msg.Slot)) // client input sanitization return; var item = GetSlotItem(msg.Slot); - if (item != null && item.Owner.TryGetComponent(out ServerStorageComponent? storage)) + if (item != null && IoCManager.Resolve().TryGetComponent(item.Owner.Uid, out ServerStorageComponent? storage)) storage.OpenStorageUI(Owner); break; } diff --git a/Content.Server/Inventory/InventoryHelpers.cs b/Content.Server/Inventory/InventoryHelpers.cs index 7b88f50f43..f91e67ce31 100644 --- a/Content.Server/Inventory/InventoryHelpers.cs +++ b/Content.Server/Inventory/InventoryHelpers.cs @@ -38,7 +38,7 @@ namespace Content.Server.Inventory } // If this doesn't have an item component, then we can't do anything with it. - if (!item.TryGetComponent(out ItemComponent? itemComp)) + if (!IoCManager.Resolve().TryGetComponent(item.Uid, out ItemComponent? itemComp)) return DeleteItem(); // We finally try to equip the item, otherwise we delete it. diff --git a/Content.Server/Jobs/GiveItemOnHolidaySpecial.cs b/Content.Server/Jobs/GiveItemOnHolidaySpecial.cs index fdbd425323..1629bdc08c 100644 --- a/Content.Server/Jobs/GiveItemOnHolidaySpecial.cs +++ b/Content.Server/Jobs/GiveItemOnHolidaySpecial.cs @@ -32,7 +32,7 @@ namespace Content.Server.Jobs var entity = IoCManager.Resolve().SpawnEntity(Prototype, mob.Transform.Coordinates); - if (!entity.TryGetComponent(out ItemComponent? item) || !mob.TryGetComponent(out HandsComponent? hands)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out ItemComponent? item) || !IoCManager.Resolve().TryGetComponent(mob.Uid, out HandsComponent? hands)) return; hands.PutInHand(item, false); diff --git a/Content.Server/Kitchen/Components/KitchenSpikeComponent.cs b/Content.Server/Kitchen/Components/KitchenSpikeComponent.cs index 411ecaa68f..1f0f0b00a5 100644 --- a/Content.Server/Kitchen/Components/KitchenSpikeComponent.cs +++ b/Content.Server/Kitchen/Components/KitchenSpikeComponent.cs @@ -67,7 +67,7 @@ namespace Content.Server.Kitchen.Components private void UpdateAppearance() { - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(KitchenSpikeVisuals.Status, (_meatParts > 0) ? KitchenSpikeStatus.Bloody : KitchenSpikeStatus.Empty); } @@ -83,7 +83,7 @@ namespace Content.Server.Kitchen.Components return false; } - if (!victim.TryGetComponent(out butcherable)) + if (!IoCManager.Resolve().TryGetComponent(victim.Uid, out butcherable)) { Owner.PopupMessage(user, Loc.GetString("comp-kitchen-spike-deny-butcher", ("victim", victim), ("this", Owner))); return false; @@ -106,7 +106,7 @@ namespace Content.Server.Kitchen.Components return; // Prevent dead from being spiked TODO: Maybe remove when rounds can be played and DOT is implemented - if (victim.TryGetComponent(out var state) && + if (IoCManager.Resolve().TryGetComponent(victim.Uid, out var state) && !state.IsDead()) { Owner.PopupMessage(user, Loc.GetString("comp-kitchen-spike-deny-not-dead", ("victim", victim))); diff --git a/Content.Server/Kitchen/Components/MicrowaveComponent.cs b/Content.Server/Kitchen/Components/MicrowaveComponent.cs index 88f7dbd8de..4f4467ad70 100644 --- a/Content.Server/Kitchen/Components/MicrowaveComponent.cs +++ b/Content.Server/Kitchen/Components/MicrowaveComponent.cs @@ -68,7 +68,7 @@ namespace Content.Server.Kitchen.Components /// [ViewVariables] private uint _currentCookTimerTime = 1; - private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; + private bool Powered => !IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) || receiver.Powered; private bool HasContents => EntitySystem.Get() .TryGetSolution(Owner.Uid, SolutionName, out var solution) && @@ -206,7 +206,7 @@ namespace Content.Server.Kitchen.Components finalState = MicrowaveVisualState.Broken; } - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(PowerDeviceVisuals.VisualState, finalState); } @@ -220,7 +220,7 @@ namespace Content.Server.Kitchen.Components void IActivate.Activate(ActivateEventArgs eventArgs) { - if (!eventArgs.User.TryGetComponent(out ActorComponent? actor) || !Powered) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor) || !Powered) { return; } @@ -251,7 +251,7 @@ namespace Content.Server.Kitchen.Components return false; } - if (itemEntity.TryGetComponent(out var attackPourable)) + if (IoCManager.Resolve().TryGetComponent(itemEntity.Uid, out var attackPourable)) { var solutionsSystem = EntitySystem.Get(); if (!solutionsSystem.TryGetDrainableSolution(itemEntity.Uid, out var attackSolution)) @@ -517,7 +517,7 @@ namespace Content.Server.Kitchen.Components { var headCount = 0; - if (victim.TryGetComponent(out var body)) + if (IoCManager.Resolve().TryGetComponent(victim.Uid, out var body)) { var headSlots = body.GetSlotsOfType(BodyPartType.Head); diff --git a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs index 726af14961..ad1438e1bf 100644 --- a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs @@ -73,7 +73,7 @@ namespace Content.Server.Kitchen.EntitySystems component.HeldBeaker = beaker; EnqueueUiUpdate(component); //We are done, return. Insert the beaker and exit! - if (component.Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(SharedReagentGrinderComponent.ReagentGrinderVisualState.BeakerAttached, component.BeakerContainer.ContainedEntity != null); @@ -85,7 +85,7 @@ namespace Content.Server.Kitchen.EntitySystems } //Next, see if the user is trying to insert something they want to be ground/juiced. - if (!heldEnt.TryGetComponent(out ExtractableComponent? juice)) + if (!IoCManager.Resolve().TryGetComponent(heldEnt.Uid, out ExtractableComponent? juice)) { //Entity did NOT pass the whitelist for grind/juice. //Wouldn't want the clown grinding up the Captain's ID card now would you? @@ -113,7 +113,7 @@ namespace Content.Server.Kitchen.EntitySystems { if (args.Handled) return; - if (!args.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) { return; } @@ -161,7 +161,7 @@ namespace Content.Server.Kitchen.EntitySystems switch (message.Message) { case SharedReagentGrinderComponent.ReagentGrinderGrindStartMessage msg: - if (!component.Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || + if (!IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out ApcPowerReceiverComponent? receiver) || !receiver.Powered) break; ClickSound(component); DoWork(component, message.Session.AttachedEntity!, @@ -169,7 +169,7 @@ namespace Content.Server.Kitchen.EntitySystems break; case SharedReagentGrinderComponent.ReagentGrinderJuiceStartMessage msg: - if (!component.Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver2) || + if (!IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out ApcPowerReceiverComponent? receiver2) || !receiver2.Powered) break; ClickSound(component); DoWork(component, message.Session.AttachedEntity!, @@ -226,7 +226,7 @@ namespace Content.Server.Kitchen.EntitySystems { foreach (var entity in comp.Chamber.ContainedEntities) { - if (canJuice || !entity.TryGetComponent(out ExtractableComponent? component)) continue; + if (canJuice || !IoCManager.Resolve().TryGetComponent(entity.Uid, out ExtractableComponent? component)) continue; canJuice = component.JuiceSolution != null; canGrind = component.GrindableSolution != null @@ -239,7 +239,7 @@ namespace Content.Server.Kitchen.EntitySystems ( comp.Busy, comp.BeakerContainer.ContainedEntity != null, - comp.Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) && receiver.Powered, + IoCManager.Resolve().TryGetComponent(comp.Owner.Uid, out ApcPowerReceiverComponent? receiver) && receiver.Powered, canJuice, canGrind, comp.Chamber.ContainedEntities.Select(item => item.Uid).ToArray(), @@ -264,14 +264,14 @@ namespace Content.Server.Kitchen.EntitySystems component.BeakerContainer.Remove(beaker); - if (user == null || !user.TryGetComponent(out var hands) || - !beaker.TryGetComponent(out var item)) + if (user == null || !IoCManager.Resolve().TryGetComponent(user.Uid, out var hands) || + !IoCManager.Resolve().TryGetComponent(beaker.Uid, out var item)) return; hands.PutInHandOrDrop(item); component.HeldBeaker = null; EnqueueUiUpdate(component); - if (component.Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(SharedReagentGrinderComponent.ReagentGrinderVisualState.BeakerAttached, component.BeakerContainer.ContainedEntity != null); @@ -286,7 +286,7 @@ namespace Content.Server.Kitchen.EntitySystems SharedReagentGrinderComponent.GrinderProgram program) { //Have power, are we busy, chamber has anything to grind, a beaker for the grounds to go? - if (!component.Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || !receiver.Powered || + if (!IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out ApcPowerReceiverComponent? receiver) || !receiver.Powered || component.Busy || component.Chamber.ContainedEntities.Count <= 0 || component.BeakerContainer.ContainedEntity == null || component.HeldBeaker == null) { @@ -308,7 +308,7 @@ namespace Content.Server.Kitchen.EntitySystems { foreach (var item in component.Chamber.ContainedEntities.ToList()) { - if (!item.TryGetComponent(out ExtractableComponent? extract) + if (!IoCManager.Resolve().TryGetComponent(item.Uid, out ExtractableComponent? extract) || extract.GrindableSolution == null || !_solutionsSystem.TryGetSolution(item.Uid, extract.GrindableSolution, out var solution)) continue; @@ -334,7 +334,7 @@ namespace Content.Server.Kitchen.EntitySystems { foreach (var item in component.Chamber.ContainedEntities.ToList()) { - if (!item.TryGetComponent(out var juiceMe) + if (!IoCManager.Resolve().TryGetComponent(item.Uid, out var juiceMe) || juiceMe.JuiceSolution == null) { Logger.Warning("Couldn't find a juice solution on entityUid:{0}", item.Uid); diff --git a/Content.Server/Labels/Label/HandLabelerSystem.cs b/Content.Server/Labels/Label/HandLabelerSystem.cs index fcc1a08c0d..bba3fdefb3 100644 --- a/Content.Server/Labels/Label/HandLabelerSystem.cs +++ b/Content.Server/Labels/Label/HandLabelerSystem.cs @@ -71,7 +71,7 @@ namespace Content.Server.Labels private void OnUseInHand(EntityUid uid, HandLabelerComponent handLabeler, UseInHandEvent args) { - if (!args.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) return; handLabeler.Owner.GetUIOrNull(HandLabelerUiKey.Key)?.Open(actor.PlayerSession); diff --git a/Content.Server/Lathe/Components/LatheComponent.cs b/Content.Server/Lathe/Components/LatheComponent.cs index 9797b2d907..59d22ba347 100644 --- a/Content.Server/Lathe/Components/LatheComponent.cs +++ b/Content.Server/Lathe/Components/LatheComponent.cs @@ -42,7 +42,7 @@ namespace Content.Server.Lathe.Components [ViewVariables] private LatheRecipePrototype? _producingRecipe; [ViewVariables] - private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; + private bool Powered => !IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) || receiver.Powered; private static readonly TimeSpan InsertionTime = TimeSpan.FromSeconds(0.9f); @@ -82,13 +82,13 @@ namespace Content.Server.Lathe.Components break; case LatheServerSelectionMessage _: - if (!Owner.TryGetComponent(out ResearchClientComponent? researchClient)) return; + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out ResearchClientComponent? researchClient)) return; researchClient.OpenUserInterface(message.Session); break; case LatheServerSyncMessage _: - if (!Owner.TryGetComponent(out TechnologyDatabaseComponent? database) - || !Owner.TryGetComponent(out ProtolatheDatabaseComponent? protoDatabase)) return; + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out TechnologyDatabaseComponent? database) + || !IoCManager.Resolve().TryGetComponent(Owner.Uid, out ProtolatheDatabaseComponent? protoDatabase)) return; if (database.SyncWithServer()) protoDatabase.Sync(); @@ -101,7 +101,7 @@ namespace Content.Server.Lathe.Components internal bool Produce(LatheRecipePrototype recipe) { - if (Producing || !Powered || !CanProduce(recipe) || !Owner.TryGetComponent(out MaterialStorageComponent? storage)) return false; + if (Producing || !Powered || !CanProduce(recipe) || !IoCManager.Resolve().TryGetComponent(Owner.Uid, out MaterialStorageComponent? storage)) return false; UserInterface?.SendMessage(new LatheFullQueueMessage(GetIdQueue())); @@ -139,7 +139,7 @@ namespace Content.Server.Lathe.Components void IActivate.Activate(ActivateEventArgs eventArgs) { - if (!eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) return; if (!Powered) { @@ -151,12 +151,12 @@ namespace Content.Server.Lathe.Components async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { - if (!Owner.TryGetComponent(out MaterialStorageComponent? storage) - || !eventArgs.Using.TryGetComponent(out MaterialComponent? material)) return false; + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out MaterialStorageComponent? storage) + || !IoCManager.Resolve().TryGetComponent(eventArgs.Using.Uid, out MaterialComponent? material)) return false; var multiplier = 1; - if (eventArgs.Using.TryGetComponent(out StackComponent? stack)) multiplier = stack.Count; + if (IoCManager.Resolve().TryGetComponent(eventArgs.Using.Uid, out StackComponent? stack)) multiplier = stack.Count; var totalAmount = 0; @@ -209,7 +209,7 @@ namespace Content.Server.Lathe.Components private void SetAppearance(LatheVisualState state) { - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(PowerDeviceVisuals.VisualState, state); } diff --git a/Content.Server/Lathe/Components/ProtolatheDatabaseComponent.cs b/Content.Server/Lathe/Components/ProtolatheDatabaseComponent.cs index da8c35cbeb..1c3963f5e0 100644 --- a/Content.Server/Lathe/Components/ProtolatheDatabaseComponent.cs +++ b/Content.Server/Lathe/Components/ProtolatheDatabaseComponent.cs @@ -27,7 +27,7 @@ namespace Content.Server.Lathe.Components /// public void Sync() { - if (!Owner.TryGetComponent(out TechnologyDatabaseComponent? database)) return; + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out TechnologyDatabaseComponent? database)) return; foreach (var technology in database.Technologies) { diff --git a/Content.Server/Light/Components/EmergencyLightComponent.cs b/Content.Server/Light/Components/EmergencyLightComponent.cs index c05946b13f..5a8fe47ca0 100644 --- a/Content.Server/Light/Components/EmergencyLightComponent.cs +++ b/Content.Server/Light/Components/EmergencyLightComponent.cs @@ -60,7 +60,7 @@ namespace Content.Server.Light.Components /// public void UpdateState() { - if (!Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver)) { return; } @@ -80,7 +80,7 @@ namespace Content.Server.Light.Components public void OnUpdate(float frameTime) { - if ((!IoCManager.Resolve().EntityExists(Owner.Uid) || !Owner.TryGetComponent(out BatteryComponent? battery) || IoCManager.Resolve().GetComponent(Owner.Uid).EntityPaused)) + if ((!IoCManager.Resolve().EntityExists(Owner.Uid) || !IoCManager.Resolve().TryGetComponent(Owner.Uid, out BatteryComponent? battery) || IoCManager.Resolve().GetComponent(Owner.Uid).EntityPaused)) { return; } @@ -98,7 +98,7 @@ namespace Content.Server.Light.Components battery.CurrentCharge += _chargingWattage * frameTime * _chargingEfficiency; if (battery.IsFullyCharged) { - if (Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver)) { receiver.Load = 1; } @@ -110,23 +110,23 @@ namespace Content.Server.Light.Components private void TurnOff() { - if (Owner.TryGetComponent(out PointLightComponent? light)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out PointLightComponent? light)) { light.Enabled = false; } - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) appearance.SetData(EmergencyLightVisuals.On, false); } private void TurnOn() { - if (Owner.TryGetComponent(out PointLightComponent? light)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out PointLightComponent? light)) { light.Enabled = true; } - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) appearance.SetData(EmergencyLightVisuals.On, true); } diff --git a/Content.Server/Light/Components/ExpendableLightComponent.cs b/Content.Server/Light/Components/ExpendableLightComponent.cs index 70c1c60805..c914090b46 100644 --- a/Content.Server/Light/Components/ExpendableLightComponent.cs +++ b/Content.Server/Light/Components/ExpendableLightComponent.cs @@ -36,14 +36,14 @@ namespace Content.Server.Light.Components { base.Initialize(); - if (Owner.TryGetComponent(out var item)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var item)) { item.EquippedPrefix = "unlit"; } CurrentState = ExpendableLightState.BrandNew; Owner.EnsureComponent(); - Owner.TryGetComponent(out _appearance); + IoCManager.Resolve().TryGetComponent(Owner.Uid, out _appearance); } /// @@ -53,7 +53,7 @@ namespace Content.Server.Light.Components { if (!Activated && CurrentState == ExpendableLightState.BrandNew) { - if (Owner.TryGetComponent(out var item)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var item)) { item.EquippedPrefix = "lit"; } @@ -92,7 +92,7 @@ namespace Content.Server.Light.Components private void UpdateSpriteAndSounds(bool on) { - if (Owner.TryGetComponent(out SpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out SpriteComponent? sprite)) { switch (CurrentState) { @@ -126,7 +126,7 @@ namespace Content.Server.Light.Components } } - if (Owner.TryGetComponent(out ClothingComponent? clothing)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ClothingComponent? clothing)) { clothing.ClothingEquippedPrefix = on ? "Activated" : string.Empty; } @@ -161,7 +161,7 @@ namespace Content.Server.Light.Components UpdateSpriteAndSounds(Activated); UpdateVisualizer(); - if (Owner.TryGetComponent(out var item)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var item)) { item.EquippedPrefix = "unlit"; } diff --git a/Content.Server/Light/Components/HandheldLightComponent.cs b/Content.Server/Light/Components/HandheldLightComponent.cs index 4bb06c9020..680d396945 100644 --- a/Content.Server/Light/Components/HandheldLightComponent.cs +++ b/Content.Server/Light/Components/HandheldLightComponent.cs @@ -167,22 +167,22 @@ namespace Content.Server.Light.Components private void SetState(bool on) { - if (Owner.TryGetComponent(out SpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out SpriteComponent? sprite)) { sprite.LayerSetVisible(1, on); } - if (Owner.TryGetComponent(out PointLightComponent? light)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out PointLightComponent? light)) { light.Enabled = on; } - if (Owner.TryGetComponent(out ClothingComponent? clothing)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ClothingComponent? clothing)) { clothing.ClothingEquippedPrefix = Loc.GetString(on ? "on" : "off"); } - if (Owner.TryGetComponent(out ItemComponent? item)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ItemComponent? item)) { item.EquippedPrefix = Loc.GetString(on ? "on" : "off"); } @@ -254,7 +254,7 @@ namespace Content.Server.Light.Components { public bool DoToggleAction(ToggleItemActionEventArgs args) { - if (!args.Item.TryGetComponent(out var lightComponent)) return false; + if (!IoCManager.Resolve().TryGetComponent(args.Item.Uid, out var lightComponent)) return false; if (lightComponent.Activated == args.ToggledOn) return false; return lightComponent.ToggleStatus(args.Performer); } diff --git a/Content.Server/Light/EntitySystems/MatchboxSystem.cs b/Content.Server/Light/EntitySystems/MatchboxSystem.cs index df75139a24..2c66d86d81 100644 --- a/Content.Server/Light/EntitySystems/MatchboxSystem.cs +++ b/Content.Server/Light/EntitySystems/MatchboxSystem.cs @@ -2,6 +2,7 @@ using Content.Server.Light.Components; using Content.Shared.Interaction; using Content.Shared.Smoking; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.Light.EntitySystems { @@ -16,7 +17,7 @@ namespace Content.Server.Light.EntitySystems private void OnInteractUsing(EntityUid uid, MatchboxComponent component, InteractUsingEvent args) { if (!args.Handled - && args.Used.TryGetComponent(out var matchstick) + && IoCManager.Resolve().TryGetComponent(args.Used.Uid, out var matchstick) && matchstick.CurrentState == SmokableState.Unlit) { Get().Ignite(matchstick, args.User); diff --git a/Content.Server/Light/EntitySystems/MatchstickSystem.cs b/Content.Server/Light/EntitySystems/MatchstickSystem.cs index 33b9bf17a9..446c0fb25f 100644 --- a/Content.Server/Light/EntitySystems/MatchstickSystem.cs +++ b/Content.Server/Light/EntitySystems/MatchstickSystem.cs @@ -84,7 +84,7 @@ namespace Content.Server.Light.EntitySystems component.PointLightComponent.Enabled = component.CurrentState == SmokableState.Lit; } - if (component.Owner.TryGetComponent(out ItemComponent? item)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out ItemComponent? item)) { switch (component.CurrentState) { @@ -97,7 +97,7 @@ namespace Content.Server.Light.EntitySystems } } - if (component.Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(SmokingVisuals.Smoking, component.CurrentState); } diff --git a/Content.Server/Light/EntitySystems/PoweredLightSystem.cs b/Content.Server/Light/EntitySystems/PoweredLightSystem.cs index 7346382de1..bf7488fcd1 100644 --- a/Content.Server/Light/EntitySystems/PoweredLightSystem.cs +++ b/Content.Server/Light/EntitySystems/PoweredLightSystem.cs @@ -340,7 +340,7 @@ namespace Content.Server.Light.EntitySystems light.IsBlinking = isNowBlinking; - if (!light.Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (!IoCManager.Resolve().TryGetComponent(light.Owner.Uid, out AppearanceComponent? appearance)) return; appearance.SetData(PoweredLightVisuals.Blinking, isNowBlinking); } diff --git a/Content.Server/MachineLinking/System/SignalLinkerSystem.cs b/Content.Server/MachineLinking/System/SignalLinkerSystem.cs index 7888a17b84..c50dbb97ca 100644 --- a/Content.Server/MachineLinking/System/SignalLinkerSystem.cs +++ b/Content.Server/MachineLinking/System/SignalLinkerSystem.cs @@ -13,6 +13,7 @@ using Content.Shared.MachineLinking; using Content.Shared.Popups; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Utility; @@ -80,8 +81,8 @@ namespace Content.Server.MachineLinking.System { if (args.Handled) return; - if (!args.Used.TryGetComponent(out var linker) || !linker.Port.HasValue || - !args.User.TryGetComponent(out ActorComponent? actor) || + if (!IoCManager.Resolve().TryGetComponent(args.Used.Uid, out var linker) || !linker.Port.HasValue || + !IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor) || !linker.Port.Value.transmitter.Outputs.TryGetPort(linker.Port.Value.port, out var port)) { return; @@ -120,9 +121,9 @@ namespace Content.Server.MachineLinking.System { case SignalPortSelected portSelected: if (msg.Session.AttachedEntity == null || - !msg.Session.AttachedEntity.TryGetComponent(out HandsComponent? hands) || + !IoCManager.Resolve().TryGetComponent(msg.Session.AttachedEntity.Uid, out HandsComponent? hands) || !hands.TryGetActiveHeldEntity(out var heldEntity) || - !heldEntity.TryGetComponent(out SignalLinkerComponent? signalLinkerComponent) || + !IoCManager.Resolve().TryGetComponent(heldEntity.Uid, out SignalLinkerComponent? signalLinkerComponent) || !_interaction.InRangeUnobstructed(msg.Session.AttachedEntity, component.Owner, ignoreInsideBlocker: true) || !signalLinkerComponent.Port.HasValue || !signalLinkerComponent.Port.Value.transmitter.Outputs.ContainsPort(signalLinkerComponent.Port @@ -160,9 +161,9 @@ namespace Content.Server.MachineLinking.System { case SignalPortSelected portSelected: if (msg.Session.AttachedEntity == null || - !msg.Session.AttachedEntity.TryGetComponent(out HandsComponent? hands) || + !IoCManager.Resolve().TryGetComponent(msg.Session.AttachedEntity.Uid, out HandsComponent? hands) || !hands.TryGetActiveHeldEntity(out var heldEntity) || - !heldEntity.TryGetComponent(out SignalLinkerComponent? signalLinkerComponent) || + !IoCManager.Resolve().TryGetComponent(heldEntity.Uid, out SignalLinkerComponent? signalLinkerComponent) || !_interaction.InRangeUnobstructed(msg.Session.AttachedEntity, component.Owner, ignoreInsideBlocker: true)) return; LinkerSaveInteraction(msg.Session.AttachedEntity, signalLinkerComponent, component, @@ -176,8 +177,8 @@ namespace Content.Server.MachineLinking.System { if (args.Handled) return; - if (!args.Used.TryGetComponent(out var linker) || - !args.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(args.Used.Uid, out var linker) || + !IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) { return; } @@ -276,10 +277,8 @@ namespace Content.Server.MachineLinking.System private bool IsInRange(SignalTransmitterComponent transmitterComponent, SignalReceiverComponent receiverComponent) { - if (transmitterComponent.Owner.TryGetComponent( - out var transmitterPowerReceiverComponent) && - receiverComponent.Owner.TryGetComponent( - out var receiverPowerReceiverComponent) + if (IoCManager.Resolve().TryGetComponent(transmitterComponent.Owner.Uid, out var transmitterPowerReceiverComponent) && + IoCManager.Resolve().TryGetComponent(receiverComponent.Owner.Uid, out var receiverPowerReceiverComponent) ) //&& todo are they on the same powernet? { return true; diff --git a/Content.Server/Medical/Components/HealingComponent.cs b/Content.Server/Medical/Components/HealingComponent.cs index e3bab68ca9..20b60078ed 100644 --- a/Content.Server/Medical/Components/HealingComponent.cs +++ b/Content.Server/Medical/Components/HealingComponent.cs @@ -10,6 +10,7 @@ using Content.Shared.Interaction; using Content.Shared.Interaction.Helpers; using Content.Shared.Stacks; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.ViewVariables; @@ -40,7 +41,7 @@ namespace Content.Server.Medical.Components return false; } - if (!eventArgs.Target.TryGetComponent(out DamageableComponent? targetDamage)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.Target.Uid, out DamageableComponent? targetDamage)) { return true; } @@ -60,7 +61,7 @@ namespace Content.Server.Medical.Components return true; } - if (Owner.TryGetComponent(out var stack) && !EntitySystem.Get().Use(Owner.Uid, 1, stack)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var stack) && !EntitySystem.Get().Use(Owner.Uid, 1, stack)) { return true; } diff --git a/Content.Server/Medical/Components/MedicalScannerComponent.cs b/Content.Server/Medical/Components/MedicalScannerComponent.cs index 4a169bd3df..1b5ab9859d 100644 --- a/Content.Server/Medical/Components/MedicalScannerComponent.cs +++ b/Content.Server/Medical/Components/MedicalScannerComponent.cs @@ -37,7 +37,7 @@ namespace Content.Server.Medical.Components private ContainerSlot _bodyContainer = default!; [ViewVariables] - private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; + private bool Powered => !IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) || receiver.Powered; [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(MedicalScannerUiKey.Key); @@ -72,7 +72,7 @@ namespace Content.Server.Medical.Components var body = _bodyContainer.ContainedEntity; if (body == null) { - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance?.SetData(MedicalScannerVisuals.Status, MedicalScannerStatus.Open); } @@ -80,7 +80,7 @@ namespace Content.Server.Medical.Components return EmptyUIState; } - if (!body.TryGetComponent(out DamageableComponent? damageable)) + if (!IoCManager.Resolve().TryGetComponent(body.Uid, out DamageableComponent? damageable)) { return EmptyUIState; } @@ -91,7 +91,7 @@ namespace Content.Server.Medical.Components } var cloningSystem = EntitySystem.Get(); - var scanned = _bodyContainer.ContainedEntity.TryGetComponent(out MindComponent? mindComponent) && + var scanned = IoCManager.Resolve().TryGetComponent(_bodyContainer.ContainedEntity.Uid, out MindComponent? mindComponent) && mindComponent.Mind != null && cloningSystem.HasDnaScan(mindComponent.Mind); @@ -147,7 +147,7 @@ namespace Content.Server.Medical.Components private void UpdateAppearance() { - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(MedicalScannerVisuals.Status, GetStatus()); } @@ -155,7 +155,7 @@ namespace Content.Server.Medical.Components void IActivate.Activate(ActivateEventArgs args) { - if (!args.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) { return; } @@ -200,7 +200,7 @@ namespace Content.Server.Medical.Components { var cloningSystem = EntitySystem.Get(); - if (!_bodyContainer.ContainedEntity.TryGetComponent(out MindComponent? mindComp) || mindComp.Mind == null) + if (!IoCManager.Resolve().TryGetComponent(_bodyContainer.ContainedEntity.Uid, out MindComponent? mindComp) || mindComp.Mind == null) { obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("medical-scanner-component-msg-no-soul")); break; diff --git a/Content.Server/Mind/Components/MindComponent.cs b/Content.Server/Mind/Components/MindComponent.cs index ecbd54ee5e..eb7ce71bb6 100644 --- a/Content.Server/Mind/Components/MindComponent.cs +++ b/Content.Server/Mind/Components/MindComponent.cs @@ -87,7 +87,7 @@ namespace Content.Server.Mind.Components var visiting = Mind?.VisitingEntity; if (visiting != null) { - if (visiting.TryGetComponent(out GhostComponent? ghost)) + if (IoCManager.Resolve().TryGetComponent(visiting.Uid, out GhostComponent? ghost)) { EntitySystem.Get().SetCanReturnToBody(ghost, false); } @@ -131,7 +131,7 @@ namespace Content.Server.Mind.Components } var dead = - Owner.TryGetComponent(out var state) && + IoCManager.Resolve().TryGetComponent(Owner.Uid, out var state) && state.IsDead(); if (!HasMind) diff --git a/Content.Server/Mind/Mind.cs b/Content.Server/Mind/Mind.cs index 452db0ea44..cdef9db3ab 100644 --- a/Content.Server/Mind/Mind.cs +++ b/Content.Server/Mind/Mind.cs @@ -296,7 +296,7 @@ namespace Content.Server.Mind if (IsVisitingEntity && (ghostCheckOverride // to force mind transfer, for example from ControlMobVerb - || !VisitingEntity!.TryGetComponent(out GhostComponent? ghostComponent) // visiting entity is not a Ghost + || !IoCManager.Resolve().TryGetComponent(VisitingEntity!.Uid, out GhostComponent? ghostComponent) // visiting entity is not a Ghost || !ghostComponent.CanReturnToBody)) // it is a ghost, but cannot return to body anyway, so it's okay { VisitingEntity = null; diff --git a/Content.Server/Mining/Components/AsteroidRockComponent.cs b/Content.Server/Mining/Components/AsteroidRockComponent.cs index 10b1bb731c..f7d3cd0c71 100644 --- a/Content.Server/Mining/Components/AsteroidRockComponent.cs +++ b/Content.Server/Mining/Components/AsteroidRockComponent.cs @@ -25,7 +25,7 @@ namespace Content.Server.Mining.Components protected override void Initialize() { base.Initialize(); - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(AsteroidRockVisuals.State, _random.Pick(SpriteStates)); } @@ -34,12 +34,12 @@ namespace Content.Server.Mining.Components async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { var item = eventArgs.Using; - if (!item.TryGetComponent(out MeleeWeaponComponent? meleeWeaponComponent)) + if (!IoCManager.Resolve().TryGetComponent(item.Uid, out MeleeWeaponComponent? meleeWeaponComponent)) return false; EntitySystem.Get().TryChangeDamage(Owner.Uid, meleeWeaponComponent.Damage); - if (!item.TryGetComponent(out PickaxeComponent? pickaxeComponent)) + if (!IoCManager.Resolve().TryGetComponent(item.Uid, out PickaxeComponent? pickaxeComponent)) return true; SoundSystem.Play(Filter.Pvs(Owner), pickaxeComponent.MiningSound.GetSound(), Owner, AudioParams.Default); diff --git a/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs b/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs index ab4e34a90e..74e6dbb8e5 100644 --- a/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs +++ b/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs @@ -133,7 +133,7 @@ namespace Content.Server.Morgue.Components SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat) { - if (victim.TryGetComponent(out ActorComponent? actor) && actor.PlayerSession.ContentData()?.Mind is {} mind) + if (IoCManager.Resolve().TryGetComponent(victim.Uid, out ActorComponent? actor) && actor.PlayerSession.ContentData()?.Mind is {} mind) { EntitySystem.Get().OnGhostAttempt(mind, false); mind.OwnedEntity?.PopupMessage(Loc.GetString("crematorium-entity-storage-component-suicide-message")); diff --git a/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs b/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs index aadfc7d3f2..b264e76462 100644 --- a/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs +++ b/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs @@ -124,7 +124,7 @@ namespace Content.Server.Morgue.Components count++; if (!hasMob && IoCManager.Resolve().HasComponent(entity.Uid)) hasMob = true; - if (!hasSoul && entity.TryGetComponent(out var actor) && actor.PlayerSession != null) + if (!hasSoul && IoCManager.Resolve().TryGetComponent(entity.Uid, out var actor) && actor.PlayerSession != null) hasSoul = true; } Appearance?.SetData(MorgueVisuals.HasContents, count > 0); diff --git a/Content.Server/NodeContainer/Nodes/PipeNode.cs b/Content.Server/NodeContainer/Nodes/PipeNode.cs index 44e34cc035..5e4c3ca375 100644 --- a/Content.Server/NodeContainer/Nodes/PipeNode.cs +++ b/Content.Server/NodeContainer/Nodes/PipeNode.cs @@ -275,8 +275,8 @@ namespace Content.Server.NodeContainer.Nodes /// private void UpdateAppearance() { - if (!Owner.TryGetComponent(out AppearanceComponent? appearance) - || !Owner.TryGetComponent(out NodeContainerComponent? container)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance) + || !IoCManager.Resolve().TryGetComponent(Owner.Uid, out NodeContainerComponent? container)) return; var netConnectedDirections = PipeDirection.None; diff --git a/Content.Server/Nutrition/Components/HungerComponent.cs b/Content.Server/Nutrition/Components/HungerComponent.cs index 599cb7aa3c..aa9dca5fef 100644 --- a/Content.Server/Nutrition/Components/HungerComponent.cs +++ b/Content.Server/Nutrition/Components/HungerComponent.cs @@ -88,13 +88,13 @@ namespace Content.Server.Nutrition.Components { // Revert slow speed if required if (_lastHungerThreshold == HungerThreshold.Starving && _currentHungerThreshold != HungerThreshold.Dead && - Owner.TryGetComponent(out MovementSpeedModifierComponent? movementSlowdownComponent)) + IoCManager.Resolve().TryGetComponent(Owner.Uid, out MovementSpeedModifierComponent? movementSlowdownComponent)) { EntitySystem.Get().RefreshMovementSpeedModifiers(OwnerUid); } // Update UI - Owner.TryGetComponent(out ServerAlertsComponent? alertsComponent); + IoCManager.Resolve().TryGetComponent(Owner.Uid, out ServerAlertsComponent? alertsComponent); if (HungerThresholdAlertTypes.TryGetValue(_currentHungerThreshold, out var alertId)) { @@ -185,7 +185,7 @@ namespace Content.Server.Nutrition.Components return; // --> Current Hunger is below dead threshold - if (!Owner.TryGetComponent(out MobStateComponent? mobState)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out MobStateComponent? mobState)) return; if (!mobState.IsDead()) diff --git a/Content.Server/Nutrition/Components/ThirstComponent.cs b/Content.Server/Nutrition/Components/ThirstComponent.cs index 73aee2c905..931dbdf25b 100644 --- a/Content.Server/Nutrition/Components/ThirstComponent.cs +++ b/Content.Server/Nutrition/Components/ThirstComponent.cs @@ -87,13 +87,13 @@ namespace Content.Server.Nutrition.Components { // Revert slow speed if required if (_lastThirstThreshold == ThirstThreshold.Parched && _currentThirstThreshold != ThirstThreshold.Dead && - Owner.TryGetComponent(out MovementSpeedModifierComponent? movementSlowdownComponent)) + IoCManager.Resolve().TryGetComponent(Owner.Uid, out MovementSpeedModifierComponent? movementSlowdownComponent)) { EntitySystem.Get().RefreshMovementSpeedModifiers(OwnerUid); } // Update UI - Owner.TryGetComponent(out ServerAlertsComponent? alertsComponent); + IoCManager.Resolve().TryGetComponent(Owner.Uid, out ServerAlertsComponent? alertsComponent); if (ThirstThresholdAlertTypes.TryGetValue(_currentThirstThreshold, out var alertId)) { @@ -182,7 +182,7 @@ namespace Content.Server.Nutrition.Components return; // --> Current Hunger is below dead threshold - if (!Owner.TryGetComponent(out MobStateComponent? mobState)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out MobStateComponent? mobState)) return; if (!mobState.IsDead()) diff --git a/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs b/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs index e7ef1023c2..4cc0ed7bcc 100644 --- a/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs @@ -25,7 +25,7 @@ namespace Content.Server.Nutrition.EntitySystems { SoundSystem.Play(Filter.Pvs(creamPie.Owner), creamPie.Sound.GetSound(), creamPie.Owner, AudioHelpers.WithVariation(0.125f)); - if (creamPie.Owner.TryGetComponent(out var foodComp) && _solutionsSystem.TryGetSolution(creamPie.Owner.Uid, foodComp.SolutionName, out var solution)) + if (IoCManager.Resolve().TryGetComponent(creamPie.Owner.Uid, out var foodComp) && _solutionsSystem.TryGetSolution(creamPie.Owner.Uid, foodComp.SolutionName, out var solution)) { solution.SpillAt(creamPie.Owner, "PuddleSmear", false); } diff --git a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs index 392fbb9a76..39498fce8a 100644 --- a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs @@ -207,7 +207,7 @@ namespace Content.Server.Nutrition.EntitySystems EntityManager.DeleteEntity(component.OwnerUid); // Put the trash in the user's hand - if (finisher.TryGetComponent(out ItemComponent? item) && + if (IoCManager.Resolve().TryGetComponent(finisher.Uid, out ItemComponent? item) && handsComponent.CanPutInHand(item)) { handsComponent.PutInHand(item); @@ -420,7 +420,7 @@ namespace Content.Server.Nutrition.EntitySystems foreach (var item in hands.GetAllHeldItems()) { // Is utensil? - if (!item.Owner.TryGetComponent(out UtensilComponent? utensil)) + if (!IoCManager.Resolve().TryGetComponent(item.Owner.Uid, out UtensilComponent? utensil)) continue; if ((utensil.Types & component.Utensil) != 0 && // Acceptable type? diff --git a/Content.Server/Nutrition/EntitySystems/SmokingSystem.cs b/Content.Server/Nutrition/EntitySystems/SmokingSystem.cs index fb364373f7..3672769723 100644 --- a/Content.Server/Nutrition/EntitySystems/SmokingSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/SmokingSystem.cs @@ -96,7 +96,7 @@ namespace Content.Server.Nutrition.EntitySystems // This is awful. I hate this so much. // TODO: Please, someone refactor containers and free me from this bullshit. if (!smokable.Owner.TryGetContainerMan(out var containerManager) || - !containerManager.Owner.TryGetComponent(out BloodstreamComponent? bloodstream)) + !IoCManager.Resolve().TryGetComponent(containerManager.Owner.Uid, out BloodstreamComponent? bloodstream)) continue; _reactiveSystem.ReactionEntity(containerManager.OwnerUid, ReactionMethod.Ingestion, inhaledSolution); diff --git a/Content.Server/Nutrition/Hungry.cs b/Content.Server/Nutrition/Hungry.cs index c05ca157bb..9199f1bfe8 100644 --- a/Content.Server/Nutrition/Hungry.cs +++ b/Content.Server/Nutrition/Hungry.cs @@ -4,6 +4,8 @@ using Content.Shared.Administration; using Content.Shared.Nutrition.Components; using Robust.Server.Player; using Robust.Shared.Console; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.Nutrition { @@ -29,7 +31,7 @@ namespace Content.Server.Nutrition return; } - if (!player.AttachedEntity.TryGetComponent(out HungerComponent? hunger)) + if (!IoCManager.Resolve().TryGetComponent(player.AttachedEntity.Uid, out HungerComponent? hunger)) { shell.WriteLine($"Your entity does not have a {nameof(HungerComponent)} component."); return; diff --git a/Content.Server/Objectives/Conditions/StealCondition.cs b/Content.Server/Objectives/Conditions/StealCondition.cs index 0f1ec48b77..6d7524d1c7 100644 --- a/Content.Server/Objectives/Conditions/StealCondition.cs +++ b/Content.Server/Objectives/Conditions/StealCondition.cs @@ -3,6 +3,7 @@ using Content.Server.Containers; using Content.Server.Objectives.Interfaces; using JetBrains.Annotations; using Robust.Shared.Containers; +using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Log; @@ -57,7 +58,7 @@ namespace Content.Server.Objectives.Conditions get { if (_mind?.OwnedEntity == null) return 0f; - if (!_mind.OwnedEntity.TryGetComponent(out var containerManagerComponent)) return 0f; + if (!IoCManager.Resolve().TryGetComponent(_mind.OwnedEntity.Uid, out var containerManagerComponent)) return 0f; float count = containerManagerComponent.CountPrototypeOccurencesRecursive(_prototypeId); return count/_amount; diff --git a/Content.Server/PDA/PDAExtensions.cs b/Content.Server/PDA/PDAExtensions.cs index a944d3a712..29903eb451 100644 --- a/Content.Server/PDA/PDAExtensions.cs +++ b/Content.Server/PDA/PDAExtensions.cs @@ -3,6 +3,7 @@ using Content.Server.Access.Components; using Content.Server.Hands.Components; using Content.Server.Inventory.Components; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.PDA { @@ -18,18 +19,18 @@ namespace Content.Server.PDA { IdCardComponent? firstIdInPda = null; - if (player.TryGetComponent(out HandsComponent? hands)) + if (IoCManager.Resolve().TryGetComponent(player.Uid, out HandsComponent? hands)) { foreach (var item in hands.GetAllHeldItems()) { if (firstIdInPda == null && - item.Owner.TryGetComponent(out PDAComponent? pda) && + IoCManager.Resolve().TryGetComponent(item.Owner.Uid, out PDAComponent? pda) && pda.ContainedID != null) { firstIdInPda = pda.ContainedID; } - if (item.Owner.TryGetComponent(out IdCardComponent? card)) + if (IoCManager.Resolve().TryGetComponent(item.Owner.Uid, out IdCardComponent? card)) { return card; } @@ -43,18 +44,18 @@ namespace Content.Server.PDA IdCardComponent? firstIdInInventory = null; - if (player.TryGetComponent(out InventoryComponent? inventory)) + if (IoCManager.Resolve().TryGetComponent(player.Uid, out InventoryComponent? inventory)) { foreach (var item in inventory.GetAllHeldItems()) { if (firstIdInInventory == null && - item.TryGetComponent(out PDAComponent? pda) && + IoCManager.Resolve().TryGetComponent(item.Uid, out PDAComponent? pda) && pda.ContainedID != null) { firstIdInInventory = pda.ContainedID; } - if (item.TryGetComponent(out IdCardComponent? card)) + if (IoCManager.Resolve().TryGetComponent(item.Uid, out IdCardComponent? card)) { return card; } diff --git a/Content.Server/PDA/PDASystem.cs b/Content.Server/PDA/PDASystem.cs index 0bde413992..81a9f9ffe1 100644 --- a/Content.Server/PDA/PDASystem.cs +++ b/Content.Server/PDA/PDASystem.cs @@ -112,7 +112,7 @@ namespace Content.Server.PDA private bool OpenUI(PDAComponent pda, IEntity user) { - if (!user.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(user.Uid, out ActorComponent? actor)) return false; var ui = pda.Owner.GetUIOrNull(PDAUiKey.Key); @@ -123,7 +123,7 @@ namespace Content.Server.PDA private void UpdatePDAAppearance(PDAComponent pda) { - if (pda.Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(pda.Owner.Uid, out AppearanceComponent? appearance)) appearance.SetData(PDAVisuals.IDCardInserted, pda.ContainedID != null); } @@ -155,7 +155,7 @@ namespace Content.Server.PDA break; case PDAToggleFlashlightMessage _: { - if (pda.Owner.TryGetComponent(out UnpoweredFlashlightComponent? flashlight)) + if (IoCManager.Resolve().TryGetComponent(pda.Owner.Uid, out UnpoweredFlashlightComponent? flashlight)) _unpoweredFlashlight.ToggleLight(flashlight); break; } @@ -172,7 +172,7 @@ namespace Content.Server.PDA } case PDAShowUplinkMessage _: { - if (pda.Owner.TryGetComponent(out UplinkComponent? uplink)) + if (IoCManager.Resolve().TryGetComponent(pda.Owner.Uid, out UplinkComponent? uplink)) _uplinkSystem.ToggleUplinkUI(uplink, msg.Session); break; } diff --git a/Content.Server/Paper/PaperComponent.cs b/Content.Server/Paper/PaperComponent.cs index cb62eb9497..77257efa16 100644 --- a/Content.Server/Paper/PaperComponent.cs +++ b/Content.Server/Paper/PaperComponent.cs @@ -43,7 +43,7 @@ namespace Content.Server.Paper Content = content + '\n'; UpdateUserInterface(); - if (!Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) return; var status = string.IsNullOrWhiteSpace(content) @@ -74,7 +74,7 @@ namespace Content.Server.Paper bool IUse.UseEntity(UseEntityEventArgs eventArgs) { - if (!eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) return false; _mode = PaperAction.Read; @@ -91,7 +91,7 @@ namespace Content.Server.Paper Content += msg.Text + '\n'; - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(PaperVisuals.Status, PaperStatus.Written); } @@ -104,7 +104,7 @@ namespace Content.Server.Paper { if (!eventArgs.Using.HasTag("Write")) return false; - if (!eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) return false; _mode = PaperAction.Write; diff --git a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs index d2e2c6bc61..7c2530b8c2 100644 --- a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs +++ b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs @@ -222,12 +222,12 @@ namespace Content.Server.ParticleAccelerator.Components void IActivate.Activate(ActivateEventArgs eventArgs) { - if (!eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) { return; } - if (Owner.TryGetComponent(out var wires) && wires.IsPanelOpen) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var wires) && wires.IsPanelOpen) { wires.OpenInterface(actor.PlayerSession); } @@ -334,7 +334,7 @@ namespace Content.Server.ParticleAccelerator.Components private void UpdateWireStatus() { - if (!Owner.TryGetComponent(out WiresComponent? wires)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out WiresComponent? wires)) { return; } @@ -577,7 +577,7 @@ namespace Content.Server.ParticleAccelerator.Components private void UpdateAppearance() { - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(ParticleAcceleratorVisuals.VisualState, _apcPowerReceiverComponent!.Powered @@ -683,7 +683,7 @@ namespace Content.Server.ParticleAccelerator.Components private void UpdatePartVisualState(ParticleAcceleratorPartComponent? component) { - if (component == null || !component.Owner.TryGetComponent(out var appearanceComponent)) + if (component == null || !IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out var appearanceComponent)) { return; } diff --git a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorEmitterComponent.cs b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorEmitterComponent.cs index fef04614bc..420829bfce 100644 --- a/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorEmitterComponent.cs +++ b/Content.Server/ParticleAccelerator/Components/ParticleAcceleratorEmitterComponent.cs @@ -18,7 +18,7 @@ namespace Content.Server.ParticleAccelerator.Components { var projectile = IoCManager.Resolve().SpawnEntity("ParticlesProjectile", Owner.Transform.Coordinates); - if (!projectile.TryGetComponent(out var particleProjectileComponent)) + if (!IoCManager.Resolve().TryGetComponent(projectile.Uid, out var particleProjectileComponent)) { Logger.Error("ParticleAcceleratorEmitter tried firing particles, but they was spawned without a ParticleProjectileComponent"); return; diff --git a/Content.Server/ParticleAccelerator/Components/ParticleProjectileComponent.cs b/Content.Server/ParticleAccelerator/Components/ParticleProjectileComponent.cs index 8200f9d858..5358d9a94d 100644 --- a/Content.Server/ParticleAccelerator/Components/ParticleProjectileComponent.cs +++ b/Content.Server/ParticleAccelerator/Components/ParticleProjectileComponent.cs @@ -22,21 +22,21 @@ namespace Content.Server.ParticleAccelerator.Components { State = state; - if (!Owner.TryGetComponent(out var physicsComponent)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out var physicsComponent)) { Logger.Error("ParticleProjectile tried firing, but it was spawned without a CollidableComponent"); return; } physicsComponent.BodyStatus = BodyStatus.InAir; - if (!Owner.TryGetComponent(out var projectileComponent)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out var projectileComponent)) { Logger.Error("ParticleProjectile tried firing, but it was spawned without a ProjectileComponent"); return; } projectileComponent.IgnoreEntity(firer); - if (!Owner.TryGetComponent(out var singuloFoodComponent)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out var singuloFoodComponent)) { Logger.Error("ParticleProjectile tried firing, but it was spawned without a SinguloFoodComponent"); return; @@ -61,7 +61,7 @@ namespace Content.Server.ParticleAccelerator.Components _ => "0" }; - if (!Owner.TryGetComponent(out var spriteComponent)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out var spriteComponent)) { Logger.Error("ParticleProjectile tried firing, but it was spawned without a SpriteComponent"); return; diff --git a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorPartSystem.cs b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorPartSystem.cs index 0b5709402d..7eef004449 100644 --- a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorPartSystem.cs +++ b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorPartSystem.cs @@ -1,6 +1,7 @@ using Content.Server.ParticleAccelerator.Components; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.ParticleAccelerator.EntitySystems { @@ -25,7 +26,7 @@ namespace Content.Server.ParticleAccelerator.EntitySystems private static void RotateEvent(ref RotateEvent ev) { - if (ev.Sender.TryGetComponent(out ParticleAcceleratorPartComponent? part)) + if (IoCManager.Resolve().TryGetComponent(ev.Sender.Uid, out ParticleAcceleratorPartComponent? part)) { part.Rotated(); } diff --git a/Content.Server/Physics/Controllers/MoverController.cs b/Content.Server/Physics/Controllers/MoverController.cs index 1dfb49bdd2..f5480af77e 100644 --- a/Content.Server/Physics/Controllers/MoverController.cs +++ b/Content.Server/Physics/Controllers/MoverController.cs @@ -303,9 +303,9 @@ namespace Content.Server.Physics.Controllers mobMover.StepSoundDistance -= distanceNeeded; - if (mover.Owner.TryGetComponent(out var inventory) + if (IoCManager.Resolve().TryGetComponent(mover.Owner.Uid, out var inventory) && inventory.TryGetSlotItem(EquipmentSlotDefines.Slots.SHOES, out var item) - && item.Owner.TryGetComponent(out var modifier)) + && IoCManager.Resolve().TryGetComponent(item.Owner.Uid, out var modifier)) { modifier.PlayFootstep(); } diff --git a/Content.Server/Physics/Controllers/PullController.cs b/Content.Server/Physics/Controllers/PullController.cs index ecc83477f0..dc240129c5 100644 --- a/Content.Server/Physics/Controllers/PullController.cs +++ b/Content.Server/Physics/Controllers/PullController.cs @@ -82,7 +82,7 @@ namespace Content.Server.Physics.Controllers continue; } - if (!pullable.Owner.TryGetComponent(out var physics) || + if (!IoCManager.Resolve().TryGetComponent(pullable.Owner.Uid, out var physics) || physics.BodyType == BodyType.Static || movingTo.MapId != pullable.Owner.Transform.MapID) { @@ -119,7 +119,7 @@ namespace Content.Server.Physics.Controllers var impulse = accel * physics.Mass * frameTime; physics.ApplyLinearImpulse(impulse); - if (puller.TryGetComponent(out var pullerPhysics)) + if (IoCManager.Resolve().TryGetComponent(puller.Uid, out var pullerPhysics)) { pullerPhysics.WakeBody(); pullerPhysics.ApplyLinearImpulse(-impulse); diff --git a/Content.Server/PneumaticCannon/PneumaticCannonSystem.cs b/Content.Server/PneumaticCannon/PneumaticCannonSystem.cs index 12cf5d627e..c31c025447 100644 --- a/Content.Server/PneumaticCannon/PneumaticCannonSystem.cs +++ b/Content.Server/PneumaticCannon/PneumaticCannonSystem.cs @@ -109,7 +109,7 @@ namespace Content.Server.PneumaticCannon return; } - if (args.Used.TryGetComponent(out var tool)) + if (IoCManager.Resolve().TryGetComponent(args.Used.Uid, out var tool)) { if (tool.Qualities.Contains(component.ToolModifyMode)) { @@ -138,8 +138,8 @@ namespace Content.Server.PneumaticCannon // this overrides the ServerStorageComponent's insertion stuff because // it's not event-based yet and I can't cancel it, so tools and stuff // will modify mode/power then get put in anyway - if (args.Used.TryGetComponent(out var item) - && component.Owner.TryGetComponent(out var storage)) + if (IoCManager.Resolve().TryGetComponent(args.Used.Uid, out var item) + && IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out var storage)) { if (storage.CanInsert(args.Used)) { @@ -175,7 +175,7 @@ namespace Content.Server.PneumaticCannon public void AddToQueue(PneumaticCannonComponent comp, IEntity user, EntityCoordinates click) { - if (!comp.Owner.TryGetComponent(out var storage)) + if (!IoCManager.Resolve().TryGetComponent(comp.Owner.Uid, out var storage)) return; if (storage.StoredEntities == null) return; if (storage.StoredEntities.Count == 0) @@ -221,7 +221,7 @@ namespace Content.Server.PneumaticCannon return; } - if (!comp.Owner.TryGetComponent(out var storage)) + if (!IoCManager.Resolve().TryGetComponent(comp.Owner.Uid, out var storage)) return; if ((!IoCManager.Resolve().EntityExists(data.User.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(data.User.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) @@ -234,7 +234,7 @@ namespace Content.Server.PneumaticCannon storage.Remove(ent); SoundSystem.Play(Filter.Pvs(data.User), comp.FireSound.GetSound(), comp.OwnerUid, AudioParams.Default); - if (data.User.TryGetComponent(out var recoil)) + if (IoCManager.Resolve().TryGetComponent(data.User.Uid, out var recoil)) { recoil.Kick(Vector2.One * data.Strength); } @@ -244,7 +244,7 @@ namespace Content.Server.PneumaticCannon // lasagna, anybody? ent.EnsureComponent(); - if(data.User.TryGetComponent(out var status) + if(IoCManager.Resolve().TryGetComponent(data.User.Uid, out var status) && comp.Power == PneumaticCannonPower.High) { _stun.TryParalyze(data.User.Uid, TimeSpan.FromSeconds(comp.HighPowerStunTime), status); @@ -276,7 +276,7 @@ namespace Content.Server.PneumaticCannon return false; // not sure how it wouldnt, but it might not! who knows - if (component.GasTankSlot.ContainedEntity.TryGetComponent(out var tank)) + if (IoCManager.Resolve().TryGetComponent(component.GasTankSlot.ContainedEntity.Uid, out var tank)) { if (tank.Air.TotalMoles < usage) return false; @@ -323,7 +323,7 @@ namespace Content.Server.PneumaticCannon var ent = component.GasTankSlot.ContainedEntity; if (component.GasTankSlot.Remove(ent)) { - if (user.TryGetComponent(out var hands)) + if (IoCManager.Resolve().TryGetComponent(user.Uid, out var hands)) { hands.TryPutInActiveHandOrAny(ent); } @@ -336,7 +336,7 @@ namespace Content.Server.PneumaticCannon public void TryEjectAllItems(PneumaticCannonComponent component, IEntity user) { - if (component.Owner.TryGetComponent(out var storage)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out var storage)) { if (storage.StoredEntities == null) return; foreach (var entity in storage.StoredEntities.ToArray()) @@ -351,7 +351,7 @@ namespace Content.Server.PneumaticCannon private void UpdateAppearance(PneumaticCannonComponent component) { - if (component.Owner.TryGetComponent(out var appearance)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out var appearance)) { appearance.SetData(PneumaticCannonVisuals.Tank, component.GasTankSlot.ContainedEntities.Count != 0); diff --git a/Content.Server/Pointing/Components/PointingArrowComponent.cs b/Content.Server/Pointing/Components/PointingArrowComponent.cs index d38499f44c..bbd416b90d 100644 --- a/Content.Server/Pointing/Components/PointingArrowComponent.cs +++ b/Content.Server/Pointing/Components/PointingArrowComponent.cs @@ -58,7 +58,7 @@ namespace Content.Server.Pointing.Components { base.Startup(); - if (Owner.TryGetComponent(out SpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out SpriteComponent? sprite)) { sprite.DrawDepth = (int) DrawDepth.Overlays; } diff --git a/Content.Server/Pointing/EntitySystems/PointingSystem.cs b/Content.Server/Pointing/EntitySystems/PointingSystem.cs index 4f4d77d7e3..080b762375 100644 --- a/Content.Server/Pointing/EntitySystems/PointingSystem.cs +++ b/Content.Server/Pointing/EntitySystems/PointingSystem.cs @@ -122,7 +122,7 @@ namespace Content.Server.Pointing.EntitySystems var arrow = EntityManager.SpawnEntity("pointingarrow", mapCoords); var layer = (int) VisibilityFlags.Normal; - if (player.TryGetComponent(out VisibilityComponent? playerVisibility)) + if (IoCManager.Resolve().TryGetComponent(player.Uid, out VisibilityComponent? playerVisibility)) { var arrowVisibility = arrow.EnsureComponent(); layer = arrowVisibility.Layer = playerVisibility.Layer; @@ -133,7 +133,7 @@ namespace Content.Server.Pointing.EntitySystems { var ent = playerSession.ContentData()?.Mind?.CurrentEntity; - if (ent is null || (!ent.TryGetComponent(out var eyeComp) || (eyeComp.VisibilityMask & layer) == 0)) return false; + if (ent is null || (!IoCManager.Resolve().TryGetComponent(ent.Uid, out var eyeComp) || (eyeComp.VisibilityMask & layer) == 0)) return false; return ent.Transform.MapPosition.InRange(player.Transform.MapPosition, PointingRange); } @@ -203,7 +203,7 @@ namespace Content.Server.Pointing.EntitySystems if (IoCManager.Resolve().HasComponent(args.Target.Uid)) return; - if (!args.User.TryGetComponent(out var actor) || + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out var actor) || !InRange(args.User, args.Target.Transform.Coordinates)) return; diff --git a/Content.Server/Power/Components/ApcComponent.cs b/Content.Server/Power/Components/ApcComponent.cs index 99a7353075..02ad92ad44 100644 --- a/Content.Server/Power/Components/ApcComponent.cs +++ b/Content.Server/Power/Components/ApcComponent.cs @@ -56,7 +56,7 @@ namespace Content.Server.Power.Components [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ApcUiKey.Key); - public BatteryComponent? Battery => Owner.TryGetComponent(out BatteryComponent? batteryComponent) ? batteryComponent : null; + public BatteryComponent? Battery => IoCManager.Resolve().TryGetComponent(Owner.Uid, out BatteryComponent? batteryComponent) ? batteryComponent : null; [ComponentDependency] private AccessReader? _accessReader = null; @@ -117,12 +117,12 @@ namespace Content.Server.Power.Components _lastChargeState = newState; _lastChargeStateChange = _gameTiming.CurTime; - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(ApcVisuals.ChargeState, newState); } - if (Owner.TryGetComponent(out SharedPointLightComponent? light)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out SharedPointLightComponent? light)) { light.Color = newState switch { @@ -135,7 +135,7 @@ namespace Content.Server.Power.Components } } - Owner.TryGetComponent(out BatteryComponent? battery); + IoCManager.Resolve().TryGetComponent(Owner.Uid, out BatteryComponent? battery); var newCharge = battery?.CurrentCharge; if (newCharge != null && newCharge != _lastCharge && _lastChargeChange + TimeSpan.FromSeconds(VisualsChangeDelay) < _gameTiming.CurTime) @@ -162,7 +162,7 @@ namespace Content.Server.Power.Components private ApcChargeState CalcChargeState() { - if (!Owner.TryGetComponent(out BatteryComponent? battery)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out BatteryComponent? battery)) { return ApcChargeState.Lack; } @@ -203,7 +203,7 @@ namespace Content.Server.Power.Components void IActivate.Activate(ActivateEventArgs eventArgs) { - if (!eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) { return; } diff --git a/Content.Server/Power/Components/ApcPowerReceiverComponent.cs b/Content.Server/Power/Components/ApcPowerReceiverComponent.cs index d515b069d9..cf3ed33dbe 100644 --- a/Content.Server/Power/Components/ApcPowerReceiverComponent.cs +++ b/Content.Server/Power/Components/ApcPowerReceiverComponent.cs @@ -87,7 +87,7 @@ namespace Content.Server.Power.Components #pragma warning restore 618 IoCManager.Resolve().EventBus.RaiseLocalEvent(Owner.Uid, new PowerChangedEvent(Powered, NetworkLoad.ReceivingPower)); - if (Owner.TryGetComponent(out var appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var appearance)) { appearance.SetData(PowerDeviceVisuals.Powered, Powered); } diff --git a/Content.Server/Power/Components/BaseCharger.cs b/Content.Server/Power/Components/BaseCharger.cs index ed5559009f..559f8af05f 100644 --- a/Content.Server/Power/Components/BaseCharger.cs +++ b/Content.Server/Power/Components/BaseCharger.cs @@ -98,12 +98,12 @@ namespace Content.Server.Power.Components Container.Remove(heldItem); _heldBattery = null; - if (user.TryGetComponent(out HandsComponent? handsComponent)) + if (IoCManager.Resolve().TryGetComponent(user.Uid, out HandsComponent? handsComponent)) { handsComponent.PutInHandOrDrop(IoCManager.Resolve().GetComponent(heldItem.Uid)); } - if (heldItem.TryGetComponent(out ServerBatteryBarrelComponent? batteryBarrelComponent)) + if (IoCManager.Resolve().TryGetComponent(heldItem.Uid, out ServerBatteryBarrelComponent? batteryBarrelComponent)) { batteryBarrelComponent.UpdateAppearance(); } @@ -118,7 +118,7 @@ namespace Content.Server.Power.Components private CellChargerStatus GetStatus() { - if (Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) && + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) && !receiver.Powered) { return CellChargerStatus.Off; @@ -161,13 +161,13 @@ namespace Content.Server.Power.Components // Not called UpdateAppearance just because it messes with the load var status = GetStatus(); if (_status == status || - !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver)) + !IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver)) { return; } _status = status; - Owner.TryGetComponent(out AppearanceComponent? appearance); + IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance); switch (_status) { @@ -206,7 +206,7 @@ namespace Content.Server.Power.Components private void TransferPower(float frameTime) { - if (Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) && + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) && !receiver.Powered) { return; diff --git a/Content.Server/Power/Components/BaseNetConnectorComponent.cs b/Content.Server/Power/Components/BaseNetConnectorComponent.cs index beea86d6d5..7410199d27 100644 --- a/Content.Server/Power/Components/BaseNetConnectorComponent.cs +++ b/Content.Server/Power/Components/BaseNetConnectorComponent.cs @@ -3,6 +3,7 @@ using System.Linq; using Content.Server.NodeContainer; using Content.Server.NodeContainer.NodeGroups; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; @@ -67,7 +68,7 @@ namespace Content.Server.Power.Components private bool TryFindNet([NotNullWhen(true)] out TNetType? foundNet) { - if (Owner.TryGetComponent(out var container)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var container)) { var compatibleNet = container.Nodes.Values .Where(node => (NodeId == null || NodeId == node.Name) && node.NodeGroupID == (NodeGroupID) Voltage) diff --git a/Content.Server/Power/Components/CableComponent.cs b/Content.Server/Power/Components/CableComponent.cs index 73a0564dc2..ec82613de4 100644 --- a/Content.Server/Power/Components/CableComponent.cs +++ b/Content.Server/Power/Components/CableComponent.cs @@ -51,7 +51,7 @@ namespace Content.Server.Power.Components var droppedEnt = IoCManager.Resolve().SpawnEntity(_cableDroppedOnCutPrototype, eventArgs.ClickLocation); // TODO: Literally just use a prototype that has a single thing in the stack, it's not that complicated... - if (droppedEnt.TryGetComponent(out var stack)) + if (IoCManager.Resolve().TryGetComponent(droppedEnt.Uid, out var stack)) EntitySystem.Get().SetCount(droppedEnt.Uid, 1, stack); return true; diff --git a/Content.Server/Power/Components/CablePlacerComponent.cs b/Content.Server/Power/Components/CablePlacerComponent.cs index fc3b2d0e6d..d6cf656708 100644 --- a/Content.Server/Power/Components/CablePlacerComponent.cs +++ b/Content.Server/Power/Components/CablePlacerComponent.cs @@ -57,7 +57,7 @@ namespace Content.Server.Power.Components } } - if (Owner.TryGetComponent(out var stack) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var stack) && !EntitySystem.Get().Use(Owner.Uid, 1, stack)) return false; diff --git a/Content.Server/Power/EntitySystems/CableMultitoolSystem.cs b/Content.Server/Power/EntitySystems/CableMultitoolSystem.cs index c14982af77..3f26e121d2 100644 --- a/Content.Server/Power/EntitySystems/CableMultitoolSystem.cs +++ b/Content.Server/Power/EntitySystems/CableMultitoolSystem.cs @@ -43,7 +43,7 @@ namespace Content.Server.Power.EntitySystems if (args.IsInDetailsRange) { // Determine if they are holding a multitool. - if (args.Examiner.TryGetComponent(out var hands) && hands.TryGetActiveHand(out var hand)) + if (IoCManager.Resolve().TryGetComponent(args.Examiner.Uid, out var hands) && hands.TryGetActiveHand(out var hand)) { var held = hand.HeldEntity; // Pulsing is hardcoded here because I don't think it needs to be more complex than that right now. diff --git a/Content.Server/Power/EntitySystems/ExtensionCableSystem.cs b/Content.Server/Power/EntitySystems/ExtensionCableSystem.cs index d3815efbd4..e24d91b373 100644 --- a/Content.Server/Power/EntitySystems/ExtensionCableSystem.cs +++ b/Content.Server/Power/EntitySystems/ExtensionCableSystem.cs @@ -120,7 +120,7 @@ namespace Content.Server.Power.EntitySystems private void OnReceiverStarted(EntityUid uid, ExtensionCableReceiverComponent receiver, ComponentStartup args) { - if (receiver.Owner.TryGetComponent(out PhysicsComponent? physicsComponent)) + if (IoCManager.Resolve().TryGetComponent(receiver.Owner.Uid, out PhysicsComponent? physicsComponent)) { receiver.Connectable = physicsComponent.BodyType == BodyType.Static; } @@ -181,7 +181,7 @@ namespace Content.Server.Power.EntitySystems foreach (var entity in nearbyEntities) { - if (!entity.TryGetComponent(out var provider)) continue; + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out var provider)) continue; if (!provider.Connectable) continue; diff --git a/Content.Server/Power/NodeGroups/ApcNet.cs b/Content.Server/Power/NodeGroups/ApcNet.cs index 3043e4dd03..eb1357dc41 100644 --- a/Content.Server/Power/NodeGroups/ApcNet.cs +++ b/Content.Server/Power/NodeGroups/ApcNet.cs @@ -7,6 +7,7 @@ using Content.Server.Power.EntitySystems; using Content.Server.Power.Pow3r; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; using Robust.Shared.ViewVariables; @@ -66,7 +67,7 @@ namespace Content.Server.Power.NodeGroups public void AddApc(ApcComponent apc) { - if (apc.Owner.TryGetComponent(out PowerNetworkBatteryComponent? netBattery)) + if (IoCManager.Resolve().TryGetComponent(apc.Owner.Uid, out PowerNetworkBatteryComponent? netBattery)) netBattery.NetworkBattery.LinkedNetworkDischarging = default; QueueNetworkReconnect(); @@ -75,7 +76,7 @@ namespace Content.Server.Power.NodeGroups public void RemoveApc(ApcComponent apc) { - if (apc.Owner.TryGetComponent(out PowerNetworkBatteryComponent? netBattery)) + if (IoCManager.Resolve().TryGetComponent(apc.Owner.Uid, out PowerNetworkBatteryComponent? netBattery)) netBattery.NetworkBattery.LinkedNetworkDischarging = default; QueueNetworkReconnect(); diff --git a/Content.Server/Power/NodeGroups/PowerNet.cs b/Content.Server/Power/NodeGroups/PowerNet.cs index 38fc6e2d32..7d44670dfc 100644 --- a/Content.Server/Power/NodeGroups/PowerNet.cs +++ b/Content.Server/Power/NodeGroups/PowerNet.cs @@ -100,7 +100,7 @@ namespace Content.Server.Power.NodeGroups public void RemoveDischarger(BatteryDischargerComponent discharger) { // Can be missing if the entity is being deleted, not a big deal. - if (discharger.Owner.TryGetComponent(out PowerNetworkBatteryComponent? battery)) + if (IoCManager.Resolve().TryGetComponent(discharger.Owner.Uid, out PowerNetworkBatteryComponent? battery)) battery.NetworkBattery.LinkedNetworkCharging = default; Dischargers.Remove(discharger); @@ -118,7 +118,7 @@ namespace Content.Server.Power.NodeGroups public void RemoveCharger(BatteryChargerComponent charger) { // Can be missing if the entity is being deleted, not a big deal. - if (charger.Owner.TryGetComponent(out PowerNetworkBatteryComponent? battery)) + if (IoCManager.Resolve().TryGetComponent(charger.Owner.Uid, out PowerNetworkBatteryComponent? battery)) battery.NetworkBattery.LinkedNetworkCharging = default; Chargers.Remove(charger); diff --git a/Content.Server/Power/SMES/SmesComponent.cs b/Content.Server/Power/SMES/SmesComponent.cs index bd2f90d531..b1a3205983 100644 --- a/Content.Server/Power/SMES/SmesComponent.cs +++ b/Content.Server/Power/SMES/SmesComponent.cs @@ -47,7 +47,7 @@ namespace Content.Server.Power.SMES _lastChargeLevel = newLevel; _lastChargeLevelChange = _gameTiming.CurTime; - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(SmesVisuals.LastChargeLevel, newLevel); } @@ -59,7 +59,7 @@ namespace Content.Server.Power.SMES _lastChargeState = newChargeState; _lastChargeStateChange = _gameTiming.CurTime; - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(SmesVisuals.LastChargeState, newChargeState); } @@ -68,7 +68,7 @@ namespace Content.Server.Power.SMES private int GetNewChargeLevel() { - if (!Owner.TryGetComponent(out BatteryComponent? battery)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out BatteryComponent? battery)) { return 0; } diff --git a/Content.Server/PowerCell/Components/PowerCellComponent.cs b/Content.Server/PowerCell/Components/PowerCellComponent.cs index 0da339dec3..c2e0f49563 100644 --- a/Content.Server/PowerCell/Components/PowerCellComponent.cs +++ b/Content.Server/PowerCell/Components/PowerCellComponent.cs @@ -79,7 +79,7 @@ namespace Content.Server.PowerCell.Components private void UpdateVisuals() { - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(PowerCellVisuals.ChargeLevel, GetLevel(CurrentCharge / MaxCharge)); } diff --git a/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs b/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs index 934a0da45c..f50443701c 100644 --- a/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs +++ b/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs @@ -81,7 +81,7 @@ namespace Content.Server.PowerCell.Components get { if (_cellContainer.ContainedEntity == null) return null; - return _cellContainer.ContainedEntity.TryGetComponent(out PowerCellComponent? cell) ? cell : null; + return IoCManager.Resolve().TryGetComponent(_cellContainer.ContainedEntity.Uid, out PowerCellComponent? cell) ? cell : null; } } @@ -134,7 +134,7 @@ namespace Content.Server.PowerCell.Components //Dirty(); if (user != null) { - if (!user.TryGetComponent(out HandsComponent? hands) || !hands.PutInHand(IoCManager.Resolve().GetComponent(cell.Owner.Uid))) + if (!IoCManager.Resolve().TryGetComponent(user.Uid, out HandsComponent? hands) || !hands.PutInHand(IoCManager.Resolve().GetComponent(cell.Owner.Uid))) { cell.Owner.Transform.Coordinates = user.Transform.Coordinates; } @@ -162,8 +162,8 @@ namespace Content.Server.PowerCell.Components public bool InsertCell(IEntity cell, bool playSound = true) { if (Cell != null) return false; - if (!cell.TryGetComponent(out var _)) return false; - if (!cell.TryGetComponent(out var cellComponent)) return false; + if (!IoCManager.Resolve().TryGetComponent(cell.Uid, out (ItemComponent?) var _)) return false; + if (!IoCManager.Resolve().TryGetComponent(cell.Uid, out var cellComponent)) return false; if (cellComponent.CellSize != SlotSize) return false; if (!_cellContainer.Insert(cell)) return false; //Dirty(); diff --git a/Content.Server/Projectiles/ProjectileSystem.cs b/Content.Server/Projectiles/ProjectileSystem.cs index c4adb0d4a3..65b8ab2c86 100644 --- a/Content.Server/Projectiles/ProjectileSystem.cs +++ b/Content.Server/Projectiles/ProjectileSystem.cs @@ -63,7 +63,7 @@ namespace Content.Server.Projectiles } // Damaging it can delete it - if (!((!IoCManager.Resolve().EntityExists(otherEntity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(otherEntity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) && otherEntity.TryGetComponent(out CameraRecoilComponent? recoilComponent)) + if (!((!IoCManager.Resolve().EntityExists(otherEntity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(otherEntity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) && IoCManager.Resolve().TryGetComponent(otherEntity.Uid, out CameraRecoilComponent? recoilComponent)) { var direction = args.OurFixture.Body.LinearVelocity.Normalized; recoilComponent.Kick(direction); diff --git a/Content.Server/Pulling/PullingSystem.cs b/Content.Server/Pulling/PullingSystem.cs index eb3eabe508..21913431a1 100644 --- a/Content.Server/Pulling/PullingSystem.cs +++ b/Content.Server/Pulling/PullingSystem.cs @@ -3,7 +3,9 @@ using Content.Shared.Pulling; using Content.Shared.Pulling.Components; using JetBrains.Annotations; using Robust.Server.GameObjects; +using Robust.Shared.GameObjects; using Robust.Shared.Input.Binding; +using Robust.Shared.IoC; using Robust.Shared.Players; namespace Content.Server.Pulling @@ -39,7 +41,7 @@ namespace Content.Server.Pulling return; } - if (!pulled.TryGetComponent(out SharedPullableComponent? pullable)) + if (!IoCManager.Resolve().TryGetComponent(pulled.Uid, out SharedPullableComponent? pullable)) { return; } diff --git a/Content.Server/Recycling/Components/RecyclerComponent.cs b/Content.Server/Recycling/Components/RecyclerComponent.cs index d1cd624b4b..eccc17f065 100644 --- a/Content.Server/Recycling/Components/RecyclerComponent.cs +++ b/Content.Server/Recycling/Components/RecyclerComponent.cs @@ -11,6 +11,7 @@ using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Analyzers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; @@ -40,7 +41,7 @@ namespace Content.Server.Recycling.Components private void Clean() { - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(RecyclerVisuals.Bloody, false); } @@ -48,7 +49,7 @@ namespace Content.Server.Recycling.Components SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat) { - if (victim.TryGetComponent(out ActorComponent? actor) && actor.PlayerSession.ContentData()?.Mind is {} mind) + if (IoCManager.Resolve().TryGetComponent(victim.Uid, out ActorComponent? actor) && actor.PlayerSession.ContentData()?.Mind is {} mind) { EntitySystem.Get().OnGhostAttempt(mind, false); mind.OwnedEntity?.PopupMessage(Loc.GetString("recycler-component-suicide-message")); @@ -56,7 +57,7 @@ namespace Content.Server.Recycling.Components victim.PopupMessageOtherClients(Loc.GetString("recycler-component-suicide-message-others", ("victim",victim))); - if (victim.TryGetComponent(out var body)) + if (IoCManager.Resolve().TryGetComponent(victim.Uid, out var body)) { body.Gib(true); } diff --git a/Content.Server/Recycling/RecyclerSystem.cs b/Content.Server/Recycling/RecyclerSystem.cs index 6ea28f38a0..97c596e805 100644 --- a/Content.Server/Recycling/RecyclerSystem.cs +++ b/Content.Server/Recycling/RecyclerSystem.cs @@ -29,7 +29,7 @@ namespace Content.Server.Recycling // TODO: Prevent collision with recycled items // Can only recycle things that are recyclable... And also check the safety of the thing to recycle. - if (!entity.TryGetComponent(out RecyclableComponent? recyclable) || !recyclable.Safe && component.Safe) return; + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out RecyclableComponent? recyclable) || !recyclable.Safe && component.Safe) return; // Mobs are a special case! if (CanGib(component, entity)) @@ -46,12 +46,12 @@ namespace Content.Server.Recycling { // We suppose this entity has a Recyclable component. return IoCManager.Resolve().HasComponent(entity.Uid) && !component.Safe && - component.Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) && receiver.Powered; + IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out ApcPowerReceiverComponent? receiver) && receiver.Powered; } public void Bloodstain(RecyclerComponent component) { - if (component.Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(RecyclerVisuals.Bloody, true); } diff --git a/Content.Server/Repairable/RepairableSystem.cs b/Content.Server/Repairable/RepairableSystem.cs index b8296d9bca..81f0834e34 100644 --- a/Content.Server/Repairable/RepairableSystem.cs +++ b/Content.Server/Repairable/RepairableSystem.cs @@ -27,7 +27,7 @@ namespace Content.Server.Repairable public async void Repair(EntityUid uid, RepairableComponent component, InteractUsingEvent args) { // Only try repair the target if it is damaged - if (!component.Owner.TryGetComponent(out DamageableComponent? damageable) || damageable.TotalDamage == 0) + if (!IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out DamageableComponent? damageable) || damageable.TotalDamage == 0) return; // Can the tool actually repair this, does it have enough fuel? diff --git a/Content.Server/Research/Components/ResearchConsoleComponent.cs b/Content.Server/Research/Components/ResearchConsoleComponent.cs index 3ec7adf925..4e33bc4f76 100644 --- a/Content.Server/Research/Components/ResearchConsoleComponent.cs +++ b/Content.Server/Research/Components/ResearchConsoleComponent.cs @@ -27,7 +27,7 @@ namespace Content.Server.Research.Components [DataField("sound")] private SoundSpecifier _soundCollectionName = new SoundCollectionSpecifier("keyboard"); - [ViewVariables] private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; + [ViewVariables] private bool Powered => !IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) || receiver.Powered; [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ResearchConsoleUiKey.Key); @@ -47,9 +47,9 @@ namespace Content.Server.Research.Components private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage message) { - if (!Owner.TryGetComponent(out TechnologyDatabaseComponent? database)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out TechnologyDatabaseComponent? database)) return; - if (!Owner.TryGetComponent(out ResearchClientComponent? client)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out ResearchClientComponent? client)) return; if (!Powered) return; @@ -90,7 +90,7 @@ namespace Content.Server.Research.Components private ResearchConsoleBoundInterfaceState GetNewUiState() { - if (!Owner.TryGetComponent(out ResearchClientComponent? client) || + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out ResearchClientComponent? client) || client.Server == null) return new ResearchConsoleBoundInterfaceState(default, default); @@ -111,7 +111,7 @@ namespace Content.Server.Research.Components void IActivate.Activate(ActivateEventArgs eventArgs) { - if (!eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) return; if (!Powered) { diff --git a/Content.Server/Research/Components/ResearchPointSourceComponent.cs b/Content.Server/Research/Components/ResearchPointSourceComponent.cs index 39d95fe36d..9de840fce5 100644 --- a/Content.Server/Research/Components/ResearchPointSourceComponent.cs +++ b/Content.Server/Research/Components/ResearchPointSourceComponent.cs @@ -1,6 +1,7 @@ using Content.Server.Power.Components; using Content.Shared.Interaction; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; @@ -42,7 +43,7 @@ namespace Content.Server.Research.Components protected override void Initialize() { base.Initialize(); - Owner.TryGetComponent(out _powerReceiver); + IoCManager.Resolve().TryGetComponent(Owner.Uid, out _powerReceiver); } } } diff --git a/Content.Server/Research/Components/ResearchServerComponent.cs b/Content.Server/Research/Components/ResearchServerComponent.cs index fada87fc84..d43d60094f 100644 --- a/Content.Server/Research/Components/ResearchServerComponent.cs +++ b/Content.Server/Research/Components/ResearchServerComponent.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using Content.Server.Power.Components; using Content.Shared.Research.Prototypes; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; @@ -73,7 +74,7 @@ namespace Content.Server.Research.Components Id = ServerCount++; EntitySystem.Get()?.RegisterServer(this); Database = Owner.EnsureComponent(); - Owner.TryGetComponent(out _powerReceiver); + IoCManager.Resolve().TryGetComponent(Owner.Uid, out _powerReceiver); } /// diff --git a/Content.Server/Research/Components/TechnologyDatabaseComponent.cs b/Content.Server/Research/Components/TechnologyDatabaseComponent.cs index ebfbcdd62e..764bad415e 100644 --- a/Content.Server/Research/Components/TechnologyDatabaseComponent.cs +++ b/Content.Server/Research/Components/TechnologyDatabaseComponent.cs @@ -1,6 +1,7 @@ using Content.Shared.Research.Components; using Content.Shared.Research.Prototypes; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Players; namespace Content.Server.Research.Components @@ -41,7 +42,7 @@ namespace Content.Server.Research.Components /// Whether it could sync or not public bool SyncWithServer() { - if (!Owner.TryGetComponent(out ResearchClientComponent? client)) return false; + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out ResearchClientComponent? client)) return false; if (client.Server?.Database == null) return false; Sync(client.Server.Database); diff --git a/Content.Server/Rotatable/RotatableSystem.cs b/Content.Server/Rotatable/RotatableSystem.cs index e262ac45ac..1d2d80d672 100644 --- a/Content.Server/Rotatable/RotatableSystem.cs +++ b/Content.Server/Rotatable/RotatableSystem.cs @@ -39,7 +39,7 @@ namespace Content.Server.Rotatable // Check if the object is anchored, and whether we are still allowed to rotate it. if (!component.RotateWhileAnchored && - component.Owner.TryGetComponent(out IPhysBody? physics) && + IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out IPhysBody? physics) && physics.BodyType == BodyType.Static) return; @@ -76,7 +76,7 @@ namespace Content.Server.Rotatable /// public static void TryFlip(FlippableComponent component, IEntity user) { - if (component.Owner.TryGetComponent(out IPhysBody? physics) && + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out IPhysBody? physics) && physics.BodyType == BodyType.Static) { component.Owner.PopupMessage(user, Loc.GetString("flippable-component-try-flip-is-stuck")); diff --git a/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs b/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs index 621399f4fa..e7737fc54f 100644 --- a/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs +++ b/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs @@ -57,7 +57,7 @@ namespace Content.Server.Sandbox.Commands } var target = entityManager.GetEntity(eUid); - if (!target.TryGetComponent(out NodeContainerComponent? nodeContainerComponent)) + if (!IoCManager.Resolve().TryGetComponent(target.Uid, out NodeContainerComponent? nodeContainerComponent)) { shell.WriteLine(Loc.GetString("shell-entity-is-not-node-container")); return; @@ -87,7 +87,7 @@ namespace Content.Server.Sandbox.Commands foreach (var x in group.Nodes) { - if (!x.Owner.TryGetComponent(out var atmosPipeColorComponent)) continue; + if (!IoCManager.Resolve().TryGetComponent(x.Owner.Uid, out var atmosPipeColorComponent)) continue; EntitySystem.Get().SetColor(x.Owner.Uid, atmosPipeColorComponent, color); } diff --git a/Content.Server/Sandbox/SandboxManager.cs b/Content.Server/Sandbox/SandboxManager.cs index ac982f0770..6b2119ba7b 100644 --- a/Content.Server/Sandbox/SandboxManager.cs +++ b/Content.Server/Sandbox/SandboxManager.cs @@ -124,19 +124,19 @@ namespace Content.Server.Sandbox .EnumeratePrototypes() .Select(p => p.ID).ToArray(); - if (player.AttachedEntity.TryGetComponent(out InventoryComponent? inv) + if (IoCManager.Resolve().TryGetComponent(player.AttachedEntity.Uid, out InventoryComponent? inv) && inv.TryGetSlotItem(Slots.IDCARD, out ItemComponent? wornItem)) { if (IoCManager.Resolve().HasComponent(wornItem.Owner.Uid)) { UpgradeId(wornItem.Owner); } - else if (wornItem.Owner.TryGetComponent(out PDAComponent? pda)) + else if (IoCManager.Resolve().TryGetComponent(wornItem.Owner.Uid, out PDAComponent? pda)) { if (pda.ContainedID == null) { var newID = CreateFreshId(); - if (pda.Owner.TryGetComponent(out ItemSlotsComponent? itemSlots)) + if (IoCManager.Resolve().TryGetComponent(pda.Owner.Uid, out ItemSlotsComponent? itemSlots)) { _entityManager.EntitySysManager.GetEntitySystem(). TryInsert(wornItem.Owner.Uid, pda.IdSlot, newID); @@ -148,10 +148,10 @@ namespace Content.Server.Sandbox } } } - else if (player.AttachedEntity.TryGetComponent(out var hands)) + else if (IoCManager.Resolve().TryGetComponent(player.AttachedEntity.Uid, out var hands)) { var card = CreateFreshId(); - if (!player.AttachedEntity.TryGetComponent(out inv) || !inv.Equip(Slots.IDCARD, card)) + if (!IoCManager.Resolve().TryGetComponent(player.AttachedEntity.Uid, out inv) || !inv.Equip(Slots.IDCARD, card)) { hands.PutInHandOrDrop(IoCManager.Resolve().GetComponent(card.Uid)); } @@ -162,7 +162,7 @@ namespace Content.Server.Sandbox var accessSystem = EntitySystem.Get(); accessSystem.TrySetTags(id.Uid, allAccess); - if (id.TryGetComponent(out SpriteComponent? sprite)) + if (IoCManager.Resolve().TryGetComponent(id.Uid, out SpriteComponent? sprite)) { sprite.LayerSetState(0, "gold"); } diff --git a/Content.Server/Security/Systems/DeployableBarrierSystem.cs b/Content.Server/Security/Systems/DeployableBarrierSystem.cs index b67bbc1f67..445cebb234 100644 --- a/Content.Server/Security/Systems/DeployableBarrierSystem.cs +++ b/Content.Server/Security/Systems/DeployableBarrierSystem.cs @@ -4,6 +4,7 @@ using Content.Shared.Security; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; using System; +using Robust.Shared.IoC; namespace Content.Server.Security.Systems { @@ -18,7 +19,7 @@ namespace Content.Server.Security.Systems private void OnStartup(EntityUid uid, DeployableBarrierComponent component, ComponentStartup args) { - if (!component.Owner.TryGetComponent(out LockComponent? lockComponent)) + if (!IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out LockComponent? lockComponent)) return; ToggleBarrierDeploy(component, lockComponent.Locked); @@ -33,13 +34,13 @@ namespace Content.Server.Security.Systems { component.Owner.Transform.Anchored = isDeployed; - if (!component.Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)) + if (!IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out AppearanceComponent? appearanceComponent)) return; var state = isDeployed ? DeployableBarrierState.Deployed : DeployableBarrierState.Idle; appearanceComponent.SetData(DeployableBarrierVisuals.State, state); - if (component.Owner.TryGetComponent(out PointLightComponent? light)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out PointLightComponent? light)) light.Enabled = isDeployed; } } diff --git a/Content.Server/Shuttles/EntitySystems/ShuttleConsoleSystem.cs b/Content.Server/Shuttles/EntitySystems/ShuttleConsoleSystem.cs index e028546819..cbeb0c4e31 100644 --- a/Content.Server/Shuttles/EntitySystems/ShuttleConsoleSystem.cs +++ b/Content.Server/Shuttles/EntitySystems/ShuttleConsoleSystem.cs @@ -133,7 +133,7 @@ namespace Content.Server.Shuttles.EntitySystems public void AddPilot(IEntity entity, ShuttleConsoleComponent component) { if (!_blocker.CanInteract(entity.Uid) || - !entity.TryGetComponent(out PilotComponent? pilotComponent) || + !IoCManager.Resolve().TryGetComponent(entity.Uid, out PilotComponent? pilotComponent) || component.SubscribedPilots.Contains(pilotComponent)) { return; @@ -141,7 +141,7 @@ namespace Content.Server.Shuttles.EntitySystems component.SubscribedPilots.Add(pilotComponent); - if (entity.TryGetComponent(out ServerAlertsComponent? alertsComponent)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ServerAlertsComponent? alertsComponent)) { alertsComponent.ShowAlert(AlertType.PilotingShuttle); } @@ -163,7 +163,7 @@ namespace Content.Server.Shuttles.EntitySystems if (!helmsman.SubscribedPilots.Remove(pilotComponent)) return; - if (pilotComponent.Owner.TryGetComponent(out ServerAlertsComponent? alertsComponent)) + if (IoCManager.Resolve().TryGetComponent(pilotComponent.Owner.Uid, out ServerAlertsComponent? alertsComponent)) { alertsComponent.ClearAlert(AlertType.PilotingShuttle); } @@ -176,7 +176,7 @@ namespace Content.Server.Shuttles.EntitySystems public void RemovePilot(IEntity entity) { - if (!entity.TryGetComponent(out PilotComponent? pilotComponent)) return; + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out PilotComponent? pilotComponent)) return; RemovePilot(pilotComponent); } diff --git a/Content.Server/Shuttles/EntitySystems/ShuttleSystem.cs b/Content.Server/Shuttles/EntitySystems/ShuttleSystem.cs index 2e8991ae70..246cd3064b 100644 --- a/Content.Server/Shuttles/EntitySystems/ShuttleSystem.cs +++ b/Content.Server/Shuttles/EntitySystems/ShuttleSystem.cs @@ -62,7 +62,7 @@ namespace Content.Server.Shuttles.EntitySystems return; } - if (!component.Owner.TryGetComponent(out PhysicsComponent? physicsComponent)) + if (!IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out PhysicsComponent? physicsComponent)) { return; } @@ -75,7 +75,7 @@ namespace Content.Server.Shuttles.EntitySystems public void Toggle(ShuttleComponent component) { - if (!component.Owner.TryGetComponent(out PhysicsComponent? physicsComponent)) return; + if (!IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out PhysicsComponent? physicsComponent)) return; component.Enabled = !component.Enabled; @@ -111,7 +111,7 @@ namespace Content.Server.Shuttles.EntitySystems // None of the below is necessary for any cleanup if we're just deleting. if (EntityManager.GetComponent(uid).EntityLifeStage >= EntityLifeStage.Terminating) return; - if (!component.Owner.TryGetComponent(out PhysicsComponent? physicsComponent)) + if (!IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out PhysicsComponent? physicsComponent)) { return; } diff --git a/Content.Server/Singularity/Components/ContainmentFieldConnection.cs b/Content.Server/Singularity/Components/ContainmentFieldConnection.cs index f61ffa4d98..1eee6a5fab 100644 --- a/Content.Server/Singularity/Components/ContainmentFieldConnection.cs +++ b/Content.Server/Singularity/Components/ContainmentFieldConnection.cs @@ -54,7 +54,7 @@ namespace Content.Server.Singularity.Components { var currentCoords = pos1.Offset(currentOffset); var newEnt = entityManager.SpawnEntity("ContainmentField", currentCoords); - if (!newEnt.TryGetComponent(out var containmentFieldComponent)) + if (!IoCManager.Resolve().TryGetComponent(newEnt.Uid, out var containmentFieldComponent)) { Logger.Error("While creating Fields in ContainmentFieldConnection, a ContainmentField without a ContainmentFieldComponent was created. Deleting newly spawned ContainmentField..."); IoCManager.Resolve().DeleteEntity(newEnt.Uid); @@ -75,7 +75,7 @@ namespace Content.Server.Singularity.Components public bool CanRepell(IEntity toRepell) { var powerNeeded = 1; - if (toRepell.TryGetComponent(out var singularityComponent)) + if (IoCManager.Resolve().TryGetComponent(toRepell.Uid, out var singularityComponent)) { powerNeeded += 2*singularityComponent.Level; } diff --git a/Content.Server/Singularity/Components/ContainmentFieldGeneratorComponent.cs b/Content.Server/Singularity/Components/ContainmentFieldGeneratorComponent.cs index e28cde993b..7e0a035c8e 100644 --- a/Content.Server/Singularity/Components/ContainmentFieldGeneratorComponent.cs +++ b/Content.Server/Singularity/Components/ContainmentFieldGeneratorComponent.cs @@ -5,6 +5,7 @@ using Content.Shared.Physics; using Content.Shared.Singularity.Components; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Log; using Robust.Shared.Maths; using Robust.Shared.Physics; @@ -113,11 +114,11 @@ namespace Content.Server.Singularity.Components } if(closestResult == null) continue; var ent = closestResult.Value.HitEntity; - if (!ent.TryGetComponent(out var fieldGeneratorComponent) || + if (!IoCManager.Resolve().TryGetComponent(ent.Uid, out var fieldGeneratorComponent) || fieldGeneratorComponent.Owner == Owner || !fieldGeneratorComponent.HasFreeConnections() || IsConnectedWith(fieldGeneratorComponent) || - !ent.TryGetComponent(out var collidableComponent) || + !IoCManager.Resolve().TryGetComponent(ent.Uid, out var collidableComponent) || collidableComponent.BodyType != BodyType.Static) { continue; diff --git a/Content.Server/Singularity/Components/RadiationCollectorComponent.cs b/Content.Server/Singularity/Components/RadiationCollectorComponent.cs index a1f0e2642a..4c43d8dfdd 100644 --- a/Content.Server/Singularity/Components/RadiationCollectorComponent.cs +++ b/Content.Server/Singularity/Components/RadiationCollectorComponent.cs @@ -74,7 +74,7 @@ namespace Content.Server.Singularity.Components protected void SetAppearance(RadiationCollectorVisualState state) { - if (Owner.TryGetComponent(out var appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var appearance)) { appearance.SetData(RadiationCollectorVisuals.VisualState, state); } diff --git a/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs b/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs index 3873c57cf7..3e10672535 100644 --- a/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs +++ b/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs @@ -3,6 +3,7 @@ using Content.Server.Singularity.Components; using Content.Shared.Singularity.Components; using Content.Shared.Tag; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Physics.Dynamics; namespace Content.Server.Singularity.EntitySystems @@ -21,7 +22,7 @@ namespace Content.Server.Singularity.EntitySystems private void HandleParticleCollide(EntityUid uid, ParticleProjectileComponent component, StartCollideEvent args) { - if (args.OtherFixture.Body.Owner.TryGetComponent(out var singularityGeneratorComponent)) + if (IoCManager.Resolve().TryGetComponent(args.OtherFixture.Body.Owner.Uid, out var singularityGeneratorComponent)) { singularityGeneratorComponent.Power += component.State switch { diff --git a/Content.Server/Singularity/EntitySystems/EmitterSystem.cs b/Content.Server/Singularity/EntitySystems/EmitterSystem.cs index b4abbf713a..4aab1ed70c 100644 --- a/Content.Server/Singularity/EntitySystems/EmitterSystem.cs +++ b/Content.Server/Singularity/EntitySystems/EmitterSystem.cs @@ -44,7 +44,7 @@ namespace Content.Server.Singularity.EntitySystems return; } - if (component.Owner.TryGetComponent(out PhysicsComponent? phys) && phys.BodyType == BodyType.Static) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out PhysicsComponent? phys) && phys.BodyType == BodyType.Static) { if (!component.IsOn) { @@ -168,7 +168,7 @@ namespace Content.Server.Singularity.EntitySystems { var projectile = IoCManager.Resolve().SpawnEntity(component.BoltType, component.Owner.Transform.Coordinates); - if (!projectile.TryGetComponent(out var physicsComponent)) + if (!IoCManager.Resolve().TryGetComponent(projectile.Uid, out var physicsComponent)) { Logger.Error("Emitter tried firing a bolt, but it was spawned without a PhysicsComponent"); return; @@ -176,7 +176,7 @@ namespace Content.Server.Singularity.EntitySystems physicsComponent.BodyStatus = BodyStatus.InAir; - if (!projectile.TryGetComponent(out var projectileComponent)) + if (!IoCManager.Resolve().TryGetComponent(projectile.Uid, out var projectileComponent)) { Logger.Error("Emitter tried firing a bolt, but it was spawned without a ProjectileComponent"); return; diff --git a/Content.Server/Singularity/EntitySystems/SingularitySystem.cs b/Content.Server/Singularity/EntitySystems/SingularitySystem.cs index 6c978b6ed8..e5f4e55583 100644 --- a/Content.Server/Singularity/EntitySystems/SingularitySystem.cs +++ b/Content.Server/Singularity/EntitySystems/SingularitySystem.cs @@ -114,7 +114,7 @@ namespace Content.Server.Singularity.EntitySystems if (CanDestroy(component, entity)) return; // Singularity priority management / etc. - if (entity.TryGetComponent(out var otherSingulo)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out var otherSingulo)) { // MERGE if (!otherSingulo.BeingDeletedByAnotherSingularity) @@ -127,7 +127,7 @@ namespace Content.Server.Singularity.EntitySystems IoCManager.Resolve().QueueDeleteEntity(entity.Uid); - if (entity.TryGetComponent(out var singuloFood)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out var singuloFood)) component.Energy += singuloFood.Energy; else component.Energy++; @@ -166,7 +166,7 @@ namespace Content.Server.Singularity.EntitySystems { // I tried having it so level 6 can de-anchor. BAD IDEA, MASSIVE LAG. if (entity == component.Owner || - !entity.TryGetComponent(out var collidableComponent) || + !IoCManager.Resolve().TryGetComponent(entity.Uid, out var collidableComponent) || collidableComponent.BodyType == BodyType.Static) continue; if (!CanPull(entity)) continue; diff --git a/Content.Server/Sprite/Components/RandomSpriteColorComponent.cs b/Content.Server/Sprite/Components/RandomSpriteColorComponent.cs index 13db3ca25c..fe30a1cc8b 100644 --- a/Content.Server/Sprite/Components/RandomSpriteColorComponent.cs +++ b/Content.Server/Sprite/Components/RandomSpriteColorComponent.cs @@ -36,7 +36,7 @@ namespace Content.Server.Sprite.Components private void UpdateColor() { - if (Owner.TryGetComponent(out SpriteComponent? spriteComponent) && _selectedColor != null) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out SpriteComponent? spriteComponent) && _selectedColor != null) { spriteComponent.LayerSetState(0, _baseState); spriteComponent.LayerSetColor(0, _colors[_selectedColor]); diff --git a/Content.Server/Sprite/Components/RandomSpriteStateComponent.cs b/Content.Server/Sprite/Components/RandomSpriteStateComponent.cs index 6dcfd5c86c..de56228dd9 100644 --- a/Content.Server/Sprite/Components/RandomSpriteStateComponent.cs +++ b/Content.Server/Sprite/Components/RandomSpriteStateComponent.cs @@ -23,7 +23,7 @@ namespace Content.Server.Sprite.Components { base.Initialize(); if (_spriteStates == null) return; - if (!Owner.TryGetComponent(out SpriteComponent? spriteComponent)) return; + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out SpriteComponent? spriteComponent)) return; spriteComponent.LayerSetState(_spriteLayer, _random.Pick(_spriteStates)); } } diff --git a/Content.Server/Stack/StackSystem.cs b/Content.Server/Stack/StackSystem.cs index 068853b726..0de34e4021 100644 --- a/Content.Server/Stack/StackSystem.cs +++ b/Content.Server/Stack/StackSystem.cs @@ -89,7 +89,7 @@ namespace Content.Server.Stack if (args.Handled) return; - if (!args.Used.TryGetComponent(out var otherStack)) + if (!IoCManager.Resolve().TryGetComponent(args.Used.Uid, out var otherStack)) return; if (!otherStack.StackTypeId.Equals(stack.StackTypeId)) diff --git a/Content.Server/StationEvents/Events/PowerGridCheck.cs b/Content.Server/StationEvents/Events/PowerGridCheck.cs index 200359c25f..f2f9d4cd91 100644 --- a/Content.Server/StationEvents/Events/PowerGridCheck.cs +++ b/Content.Server/StationEvents/Events/PowerGridCheck.cs @@ -55,7 +55,7 @@ namespace Content.Server.StationEvents.Events { if ((!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) continue; - if (entity.TryGetComponent(out ApcPowerReceiverComponent? powerReceiverComponent)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ApcPowerReceiverComponent? powerReceiverComponent)) { powerReceiverComponent.PowerDisabled = false; } diff --git a/Content.Server/Storage/Components/EntityStorageComponent.cs b/Content.Server/Storage/Components/EntityStorageComponent.cs index ed87d921a8..70192007d5 100644 --- a/Content.Server/Storage/Components/EntityStorageComponent.cs +++ b/Content.Server/Storage/Components/EntityStorageComponent.cs @@ -152,7 +152,7 @@ namespace Content.Server.Storage.Components Contents.ShowContents = _showContents; Contents.OccludesLight = _occludesLight; - if (Owner.TryGetComponent(out var surface)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var surface)) { EntitySystem.Get().SetPlaceable(Owner.Uid, Open, surface); } @@ -173,7 +173,7 @@ namespace Content.Server.Storage.Components return false; } - if (Owner.TryGetComponent(out var @lock) && @lock.Locked) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var @lock) && @lock.Locked) { if (!silent) Owner.PopupMessage(user, Loc.GetString("entity-storage-component-locked-message")); return false; @@ -270,7 +270,7 @@ namespace Content.Server.Storage.Components private void UpdateAppearance() { - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(StorageVisuals.CanWeld, _canWeldShut); appearance.SetData(StorageVisuals.Welded, _isWeldedShut); @@ -279,7 +279,7 @@ namespace Content.Server.Storage.Components private void ModifyComponents() { - if (!_isCollidableWhenOpen && Owner.TryGetComponent(out var manager)) + if (!_isCollidableWhenOpen && IoCManager.Resolve().TryGetComponent(Owner.Uid, out var manager)) { if (Open) { @@ -297,12 +297,12 @@ namespace Content.Server.Storage.Components } } - if (Owner.TryGetComponent(out var surface)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var surface)) { EntitySystem.Get().SetPlaceable(Owner.Uid, Open, surface); } - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(StorageVisuals.Open, Open); } @@ -311,7 +311,7 @@ namespace Content.Server.Storage.Components protected virtual bool AddToContents(IEntity entity) { if (entity == Owner) return false; - if (entity.TryGetComponent(out IPhysBody? entityPhysicsComponent)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out IPhysBody? entityPhysicsComponent)) { if (MaxSize < entityPhysicsComponent.GetWorldAABB().Size.X || MaxSize < entityPhysicsComponent.GetWorldAABB().Size.Y) @@ -335,7 +335,7 @@ namespace Content.Server.Storage.Components if (Contents.Remove(contained)) { contained.Transform.WorldPosition = ContentsDumpPosition(); - if (contained.TryGetComponent(out var physics)) + if (IoCManager.Resolve().TryGetComponent(contained.Uid, out var physics)) { physics.CanCollide = true; } @@ -376,7 +376,7 @@ namespace Content.Server.Storage.Components if (!Contents.Insert(entity)) return false; entity.Transform.LocalPosition = Vector2.Zero; - if (entity.TryGetComponent(out IPhysBody? body)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out IPhysBody? body)) { body.CanCollide = false; } diff --git a/Content.Server/Storage/Components/SecretStashComponent.cs b/Content.Server/Storage/Components/SecretStashComponent.cs index 4b3c705755..5033478a66 100644 --- a/Content.Server/Storage/Components/SecretStashComponent.cs +++ b/Content.Server/Storage/Components/SecretStashComponent.cs @@ -5,6 +5,7 @@ using Content.Shared.Item; using Content.Shared.Popups; using Robust.Shared.Containers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; @@ -49,7 +50,7 @@ namespace Content.Server.Storage.Components return false; } - if (!itemToHide.TryGetComponent(out ItemComponent? item)) + if (!IoCManager.Resolve().TryGetComponent(itemToHide.Uid, out ItemComponent? item)) return false; if (item.Size > _maxItemSize) @@ -59,7 +60,7 @@ namespace Content.Server.Storage.Components return false; } - if (!user.TryGetComponent(out HandsComponent? hands)) + if (!IoCManager.Resolve().TryGetComponent(user.Uid, out HandsComponent? hands)) return false; if (!hands.Drop(itemToHide, _itemContainer)) @@ -82,9 +83,9 @@ namespace Content.Server.Storage.Components Owner.PopupMessage(user, Loc.GetString("comp-secret-stash-action-get-item-found-something", ("stash", SecretPartName))); - if (user.TryGetComponent(out HandsComponent? hands)) + if (IoCManager.Resolve().TryGetComponent(user.Uid, out HandsComponent? hands)) { - if (!_itemContainer.ContainedEntity.TryGetComponent(out ItemComponent? item)) + if (!IoCManager.Resolve().TryGetComponent(_itemContainer.ContainedEntity.Uid, out ItemComponent? item)) return false; hands.PutInHandOrDrop(item); } diff --git a/Content.Server/Storage/Components/ServerStorageComponent.cs b/Content.Server/Storage/Components/ServerStorageComponent.cs index 2f3886972a..f66b4a71e2 100644 --- a/Content.Server/Storage/Components/ServerStorageComponent.cs +++ b/Content.Server/Storage/Components/ServerStorageComponent.cs @@ -143,13 +143,13 @@ namespace Content.Server.Storage.Components { EnsureInitialCalculated(); - if (entity.TryGetComponent(out ServerStorageComponent? storage) && + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ServerStorageComponent? storage) && storage._storageCapacityMax >= _storageCapacityMax) { return false; } - if (entity.TryGetComponent(out SharedItemComponent? store) && + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out SharedItemComponent? store) && store.Size > _storageCapacityMax - _storageUsed) { return false; @@ -197,7 +197,7 @@ namespace Content.Server.Storage.Components Logger.DebugS(LoggerName, $"Storage (UID {Owner.Uid}) had entity (UID {message.Entity.Uid}) inserted into it."); var size = 0; - if (message.Entity.TryGetComponent(out SharedItemComponent? storable)) + if (IoCManager.Resolve().TryGetComponent(message.Entity.Uid, out SharedItemComponent? storable)) size = storable.Size; _storageUsed += size; @@ -239,7 +239,7 @@ namespace Content.Server.Storage.Components { EnsureInitialCalculated(); - if (!player.TryGetComponent(out HandsComponent? hands) || + if (!IoCManager.Resolve().TryGetComponent(player.Uid, out HandsComponent? hands) || hands.GetActiveHand == null) { return false; @@ -473,7 +473,7 @@ namespace Content.Server.Storage.Components break; } - if (!entity.TryGetComponent(out ItemComponent? item) || !player.TryGetComponent(out HandsComponent? hands)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out ItemComponent? item) || !IoCManager.Resolve().TryGetComponent(player.Uid, out HandsComponent? hands)) { break; } diff --git a/Content.Server/Storage/Components/StorageFillComponent.cs b/Content.Server/Storage/Components/StorageFillComponent.cs index 0e16db0451..c9dd9330c9 100644 --- a/Content.Server/Storage/Components/StorageFillComponent.cs +++ b/Content.Server/Storage/Components/StorageFillComponent.cs @@ -28,7 +28,7 @@ namespace Content.Server.Storage.Components return; } - if (!Owner.TryGetComponent(out IStorageComponent? storage)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out IStorageComponent? storage)) { Logger.Error($"StorageFillComponent couldn't find any StorageComponent ({Owner})"); return; diff --git a/Content.Server/Storage/EntitySystems/ItemCounterSystem.cs b/Content.Server/Storage/EntitySystems/ItemCounterSystem.cs index 43f76c7b68..c12c4d320f 100644 --- a/Content.Server/Storage/EntitySystems/ItemCounterSystem.cs +++ b/Content.Server/Storage/EntitySystems/ItemCounterSystem.cs @@ -3,6 +3,8 @@ using Content.Shared.Storage.Components; using Content.Shared.Storage.EntitySystems; using JetBrains.Annotations; using Robust.Shared.Containers; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.Storage.EntitySystems { @@ -11,7 +13,7 @@ namespace Content.Server.Storage.EntitySystems { protected override int? GetCount(ContainerModifiedMessage msg, ItemCounterComponent itemCounter) { - if (!msg.Container.Owner.TryGetComponent(out ServerStorageComponent? component) + if (!IoCManager.Resolve().TryGetComponent(msg.Container.Owner.Uid, out ServerStorageComponent? component) || component.StoredEntities == null) { return null; diff --git a/Content.Server/Storage/EntitySystems/ItemMapperSystem.cs b/Content.Server/Storage/EntitySystems/ItemMapperSystem.cs index 84ba80ab5d..e2b3c1535d 100644 --- a/Content.Server/Storage/EntitySystems/ItemMapperSystem.cs +++ b/Content.Server/Storage/EntitySystems/ItemMapperSystem.cs @@ -6,6 +6,7 @@ using JetBrains.Annotations; using Robust.Shared.Analyzers; using Robust.Shared.Containers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.Storage.EntitySystems { @@ -16,7 +17,7 @@ namespace Content.Server.Storage.EntitySystems ItemMapperComponent itemMapper, out IReadOnlyList showLayers) { - if (msg.Container.Owner.TryGetComponent(out ServerStorageComponent? component)) + if (IoCManager.Resolve().TryGetComponent(msg.Container.Owner.Uid, out ServerStorageComponent? component)) { var containedLayers = component.StoredEntities ?? new List(); var list = new List(); diff --git a/Content.Server/Storage/EntitySystems/SpawnItemsOnUseSystem.cs b/Content.Server/Storage/EntitySystems/SpawnItemsOnUseSystem.cs index be16994d48..5c521a8125 100644 --- a/Content.Server/Storage/EntitySystems/SpawnItemsOnUseSystem.cs +++ b/Content.Server/Storage/EntitySystems/SpawnItemsOnUseSystem.cs @@ -59,7 +59,7 @@ namespace Content.Server.Storage.EntitySystems } if (entityToPlaceInHands != null - && args.User.TryGetComponent(out var hands)) + && IoCManager.Resolve().TryGetComponent(args.User.Uid, out var hands)) { hands.TryPutInAnyHand(entityToPlaceInHands); } diff --git a/Content.Server/Storage/EntitySystems/StorageSystem.cs b/Content.Server/Storage/EntitySystems/StorageSystem.cs index 408b63a9f9..91fe177611 100644 --- a/Content.Server/Storage/EntitySystems/StorageSystem.cs +++ b/Content.Server/Storage/EntitySystems/StorageSystem.cs @@ -117,7 +117,7 @@ namespace Content.Server.Storage.EntitySystems { var oldParentEntity = message.Container.Owner; - if (oldParentEntity.TryGetComponent(out ServerStorageComponent? storageComp)) + if (IoCManager.Resolve().TryGetComponent(oldParentEntity.Uid, out ServerStorageComponent? storageComp)) { storageComp.HandleEntityMaybeRemoved(message); } @@ -127,7 +127,7 @@ namespace Content.Server.Storage.EntitySystems { var oldParentEntity = message.Container.Owner; - if (oldParentEntity.TryGetComponent(out ServerStorageComponent? storageComp)) + if (IoCManager.Resolve().TryGetComponent(oldParentEntity.Uid, out ServerStorageComponent? storageComp)) { storageComp.HandleEntityMaybeInserted(message); } diff --git a/Content.Server/Strip/StrippableComponent.cs b/Content.Server/Strip/StrippableComponent.cs index 3e24cc5f5e..ff462456ff 100644 --- a/Content.Server/Strip/StrippableComponent.cs +++ b/Content.Server/Strip/StrippableComponent.cs @@ -45,17 +45,17 @@ namespace Content.Server.Strip Owner.EnsureComponentWarn(); Owner.EnsureComponentWarn(); - if (Owner.TryGetComponent(out CuffableComponent? cuffed)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out CuffableComponent? cuffed)) { cuffed.OnCuffedStateChanged += UpdateSubscribed; } - if (Owner.TryGetComponent(out InventoryComponent? inventory)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out InventoryComponent? inventory)) { inventory.OnItemChanged += UpdateSubscribed; } - if (Owner.TryGetComponent(out HandsComponent? hands)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out HandsComponent? hands)) { hands.OnItemChanged += UpdateSubscribed; } @@ -80,7 +80,7 @@ namespace Content.Server.Strip public override bool Drop(DragDropEvent args) { - if (!args.User.TryGetComponent(out ActorComponent? actor)) return false; + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) return false; OpenUserInterface(actor.PlayerSession); return true; @@ -90,7 +90,7 @@ namespace Content.Server.Strip { var dictionary = new Dictionary(); - if (!Owner.TryGetComponent(out CuffableComponent? cuffed)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out CuffableComponent? cuffed)) { return dictionary; } @@ -107,7 +107,7 @@ namespace Content.Server.Strip { var dictionary = new Dictionary(); - if (!Owner.TryGetComponent(out InventoryComponent? inventory)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out InventoryComponent? inventory)) { return dictionary; } @@ -124,7 +124,7 @@ namespace Content.Server.Strip { var dictionary = new Dictionary(); - if (!Owner.TryGetComponent(out HandsComponent? hands)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out HandsComponent? hands)) { return dictionary; } @@ -394,7 +394,7 @@ namespace Content.Server.Strip private void HandleUserInterfaceMessage(ServerBoundUserInterfaceMessage obj) { var user = obj.Session.AttachedEntity; - if (user == null || !(user.TryGetComponent(out HandsComponent? userHands))) return; + if (user == null || !IoCManager.Resolve().TryGetComponent(user.Uid, out HandsComponent? userHands)) return; var placingItem = userHands.GetActiveHand != null; @@ -402,7 +402,7 @@ namespace Content.Server.Strip { case StrippingInventoryButtonPressed inventoryMessage: - if (Owner.TryGetComponent(out var inventory)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var inventory)) { if (inventory.TryGetSlotItem(inventoryMessage.Slot, out ItemComponent? _)) placingItem = false; @@ -416,7 +416,7 @@ namespace Content.Server.Strip case StrippingHandButtonPressed handMessage: - if (Owner.TryGetComponent(out var hands)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var hands)) { if (hands.TryGetItem(handMessage.Hand, out _)) placingItem = false; @@ -430,7 +430,7 @@ namespace Content.Server.Strip case StrippingHandcuffButtonPressed handcuffMessage: - if (Owner.TryGetComponent(out var cuffed)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var cuffed)) { foreach (var entity in cuffed.StoredEntities) { diff --git a/Content.Server/Strip/StrippableSystem.cs b/Content.Server/Strip/StrippableSystem.cs index 7941e06baf..88de8859e1 100644 --- a/Content.Server/Strip/StrippableSystem.cs +++ b/Content.Server/Strip/StrippableSystem.cs @@ -1,6 +1,7 @@ using Content.Shared.Verbs; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; namespace Content.Server.Strip @@ -19,7 +20,7 @@ namespace Content.Server.Strip if (args.Hands == null || !args.CanAccess || !args.CanInteract || args.Target == args.User) return; - if (!args.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) return; Verb verb = new(); diff --git a/Content.Server/Stunnable/StunbatonSystem.cs b/Content.Server/Stunnable/StunbatonSystem.cs index ba4a2cb30e..ad6420d059 100644 --- a/Content.Server/Stunnable/StunbatonSystem.cs +++ b/Content.Server/Stunnable/StunbatonSystem.cs @@ -121,7 +121,7 @@ namespace Content.Server.Stunnable private void StunEntity(IEntity entity, StunbatonComponent comp) { - if (!entity.TryGetComponent(out StatusEffectsComponent? status) || !comp.Activated) return; + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out StatusEffectsComponent? status) || !comp.Activated) return; // TODO: Make slowdown inflicted customizable. @@ -145,7 +145,7 @@ namespace Content.Server.Stunnable _jitterSystem.DoJitter(entity.Uid, slowdownTime, status:status); _stutteringSystem.DoStutter(entity.Uid, slowdownTime, status); - if (!comp.Owner.TryGetComponent(out var slot) || slot.Cell == null || !(slot.Cell.CurrentCharge < comp.EnergyPerUse)) + if (!IoCManager.Resolve().TryGetComponent(comp.Owner.Uid, out var slot) || slot.Cell == null || !(slot.Cell.CurrentCharge < comp.EnergyPerUse)) return; SoundSystem.Play(Filter.Pvs(comp.Owner), comp.SparksSound.GetSound(), comp.Owner, AudioHelpers.WithVariation(0.25f)); @@ -159,8 +159,8 @@ namespace Content.Server.Stunnable return; } - if (!comp.Owner.TryGetComponent(out var sprite) || - !comp.Owner.TryGetComponent(out var item)) return; + if (!IoCManager.Resolve().TryGetComponent(comp.Owner.Uid, out var sprite) || + !IoCManager.Resolve().TryGetComponent(comp.Owner.Uid, out var item)) return; SoundSystem.Play(Filter.Pvs(comp.Owner), comp.SparksSound.GetSound(), comp.Owner, AudioHelpers.WithVariation(0.25f)); item.EquippedPrefix = "off"; @@ -176,12 +176,12 @@ namespace Content.Server.Stunnable return; } - if (!comp.Owner.TryGetComponent(out var sprite) || - !comp.Owner.TryGetComponent(out var item)) + if (!IoCManager.Resolve().TryGetComponent(comp.Owner.Uid, out var sprite) || + !IoCManager.Resolve().TryGetComponent(comp.Owner.Uid, out var item)) return; var playerFilter = Filter.Pvs(comp.Owner); - if (!comp.Owner.TryGetComponent(out var slot)) + if (!IoCManager.Resolve().TryGetComponent(comp.Owner.Uid, out var slot)) return; if (slot.Cell == null) diff --git a/Content.Server/Suspicion/SuspicionRoleComponent.cs b/Content.Server/Suspicion/SuspicionRoleComponent.cs index 5e683bd518..5d2c82c5e3 100644 --- a/Content.Server/Suspicion/SuspicionRoleComponent.cs +++ b/Content.Server/Suspicion/SuspicionRoleComponent.cs @@ -9,6 +9,7 @@ using Content.Shared.Examine; using Content.Shared.MobState.Components; using Content.Shared.Suspicion; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Players; using Robust.Shared.Utility; @@ -59,7 +60,7 @@ namespace Content.Server.Suspicion public bool IsDead() { - return Owner.TryGetComponent(out MobStateComponent? state) && + return IoCManager.Resolve().TryGetComponent(Owner.Uid, out MobStateComponent? state) && state.IsDead(); } @@ -75,7 +76,7 @@ namespace Content.Server.Suspicion public void SyncRoles() { - if (!Owner.TryGetComponent(out MindComponent? mind) || + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out MindComponent? mind) || !mind.HasMind) { return; diff --git a/Content.Server/Tabletop/TabletopSystem.Session.cs b/Content.Server/Tabletop/TabletopSystem.Session.cs index 8ec2f80718..d4c1513c69 100644 --- a/Content.Server/Tabletop/TabletopSystem.Session.cs +++ b/Content.Server/Tabletop/TabletopSystem.Session.cs @@ -82,7 +82,7 @@ namespace Content.Server.Tabletop if (session.Players.ContainsKey(player)) return; - if(attachedEntity.TryGetComponent(out var gamer)) + if(IoCManager.Resolve().TryGetComponent(attachedEntity.Uid, out var gamer)) CloseSessionFor(player, gamer.Tabletop, false); // Set the entity as an absolute GAMER. @@ -111,7 +111,7 @@ namespace Content.Server.Tabletop if (!session.Players.TryGetValue(player, out var data)) return; - if(removeGamerComponent && player.AttachedEntity is {} attachedEntity && attachedEntity.TryGetComponent(out TabletopGamerComponent? gamer)) + if(removeGamerComponent && player.AttachedEntity is {} attachedEntity && IoCManager.Resolve().TryGetComponent(attachedEntity.Uid, out TabletopGamerComponent? gamer)) { // We invalidate this to prevent an infinite feedback from removing the component. gamer.Tabletop = EntityUid.Invalid; diff --git a/Content.Server/Tabletop/TabletopSystem.cs b/Content.Server/Tabletop/TabletopSystem.cs index 99ac7b76cd..f4db76a41c 100644 --- a/Content.Server/Tabletop/TabletopSystem.cs +++ b/Content.Server/Tabletop/TabletopSystem.cs @@ -42,7 +42,7 @@ namespace Content.Server.Tabletop if (!args.CanAccess || !args.CanInteract) return; - if (!args.User.TryGetComponent(out var actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out var actor)) return; Verb verb = new(); @@ -97,7 +97,7 @@ namespace Content.Server.Tabletop if (!EntityManager.EntityExists(gamer.Tabletop)) continue; - if (!gamer.Owner.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(gamer.Owner.Uid, out ActorComponent? actor)) { IoCManager.Resolve().RemoveComponent(gamer.Owner.Uid); return; diff --git a/Content.Server/Temperature/Components/HeatResistanceComponent.cs b/Content.Server/Temperature/Components/HeatResistanceComponent.cs index 27feb3cb3a..401dda2d55 100644 --- a/Content.Server/Temperature/Components/HeatResistanceComponent.cs +++ b/Content.Server/Temperature/Components/HeatResistanceComponent.cs @@ -2,6 +2,7 @@ using Content.Server.Clothing.Components; using Content.Server.Inventory.Components; using Content.Shared.Inventory; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.Temperature.Components { @@ -14,7 +15,7 @@ namespace Content.Server.Temperature.Components { // TODO: When making into system: Any animal that touches bulb that has no // InventoryComponent but still would have default heat resistance in the future (maybe) - if (!Owner.TryGetComponent(out var inventoryComp)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out var inventoryComp)) { // Magical number just copied from below return int.MinValue; diff --git a/Content.Server/Temperature/Components/TemperatureComponent.cs b/Content.Server/Temperature/Components/TemperatureComponent.cs index 7f2ef63e70..b7a9b9764d 100644 --- a/Content.Server/Temperature/Components/TemperatureComponent.cs +++ b/Content.Server/Temperature/Components/TemperatureComponent.cs @@ -2,6 +2,7 @@ using Content.Shared.Atmos; using Content.Shared.Damage; using Content.Shared.FixedPoint; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Physics; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; @@ -45,7 +46,7 @@ namespace Content.Server.Temperature.Components { get { - if (Owner.TryGetComponent(out var physics) && physics.Mass != 0) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var physics) && physics.Mass != 0) { return SpecificHeat * physics.Mass; } diff --git a/Content.Server/Throwing/ThrowHelper.cs b/Content.Server/Throwing/ThrowHelper.cs index 9c0c1daa14..dd8f2212bf 100644 --- a/Content.Server/Throwing/ThrowHelper.cs +++ b/Content.Server/Throwing/ThrowHelper.cs @@ -35,7 +35,7 @@ namespace Content.Server.Throwing { if ((!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || strength <= 0f || - !entity.TryGetComponent(out PhysicsComponent? physicsComponent)) + !IoCManager.Resolve().TryGetComponent(entity.Uid, out PhysicsComponent? physicsComponent)) { return; } @@ -94,7 +94,7 @@ namespace Content.Server.Throwing } // Give thrower an impulse in the other direction - if (user != null && pushbackRatio > 0.0f && user.TryGetComponent(out IPhysBody? body)) + if (user != null && pushbackRatio > 0.0f && IoCManager.Resolve().TryGetComponent(user.Uid, out IPhysBody? body)) { var msg = new ThrowPushbackAttemptEvent(); IoCManager.Resolve().EventBus.RaiseLocalEvent(body.Owner.Uid, msg); diff --git a/Content.Server/Tiles/FloorTileItemComponent.cs b/Content.Server/Tiles/FloorTileItemComponent.cs index b2f2b0e29c..2deb8d4fbe 100644 --- a/Content.Server/Tiles/FloorTileItemComponent.cs +++ b/Content.Server/Tiles/FloorTileItemComponent.cs @@ -58,7 +58,7 @@ namespace Content.Server.Tiles if (!eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true)) return true; - if (!Owner.TryGetComponent(out StackComponent? stack)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out StackComponent? stack)) return true; var mapManager = IoCManager.Resolve(); diff --git a/Content.Server/Toilet/ToiletComponent.cs b/Content.Server/Toilet/ToiletComponent.cs index c9b51b017a..76431a8697 100644 --- a/Content.Server/Toilet/ToiletComponent.cs +++ b/Content.Server/Toilet/ToiletComponent.cs @@ -68,7 +68,7 @@ namespace Content.Server.Toilet async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { // are player trying place or lift of cistern lid? - if (eventArgs.Using.TryGetComponent(out ToolComponent? tool) + if (IoCManager.Resolve().TryGetComponent(eventArgs.Using.Uid, out ToolComponent? tool) && tool.Qualities.Contains(_pryingQuality)) { // check if someone is already prying this toilet @@ -112,7 +112,7 @@ namespace Content.Server.Toilet // just want to up/down seat? // check that nobody seats on seat right now - if (Owner.TryGetComponent(out StrapComponent? strap)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out StrapComponent? strap)) { if (strap.BuckledEntities.Count != 0) return false; @@ -143,7 +143,7 @@ namespace Content.Server.Toilet private void UpdateSprite() { - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(ToiletVisuals.LidOpen, LidOpen); appearance.SetData(ToiletVisuals.SeatUp, IsSeatUp); @@ -153,7 +153,7 @@ namespace Content.Server.Toilet SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat) { // check that victim even have head - if (victim.TryGetComponent(out var body) && + if (IoCManager.Resolve().TryGetComponent(victim.Uid, out var body) && body.HasPartOfType(BodyPartType.Head)) { var othersMessage = Loc.GetString("toilet-component-suicide-head-message-others", ("victim",victim.Name),("owner", Owner.Name)); diff --git a/Content.Server/Tools/Components/TilePryingComponent.cs b/Content.Server/Tools/Components/TilePryingComponent.cs index 02cbc49254..bf12ed8af0 100644 --- a/Content.Server/Tools/Components/TilePryingComponent.cs +++ b/Content.Server/Tools/Components/TilePryingComponent.cs @@ -34,7 +34,7 @@ namespace Content.Server.Tools.Components public async void TryPryTile(IEntity user, EntityCoordinates clickLocation) { - if (!Owner.TryGetComponent(out var tool) && _toolComponentNeeded) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out var tool) && _toolComponentNeeded) return; if (!_mapManager.TryGetGrid(clickLocation.GetGridId(IoCManager.Resolve()), out var mapGrid)) diff --git a/Content.Server/Traitor/Uplink/UplinkSystem.cs b/Content.Server/Traitor/Uplink/UplinkSystem.cs index 695cca2ef4..4f3416f18d 100644 --- a/Content.Server/Traitor/Uplink/UplinkSystem.cs +++ b/Content.Server/Traitor/Uplink/UplinkSystem.cs @@ -126,8 +126,8 @@ namespace Content.Server.Traitor.Uplink return; } - if (player.TryGetComponent(out HandsComponent? hands) && - entity.TryGetComponent(out ItemComponent? item)) + if (IoCManager.Resolve().TryGetComponent(player.Uid, out HandsComponent? hands) && + IoCManager.Resolve().TryGetComponent(entity.Uid, out ItemComponent? item)) { hands.PutInHandOrDrop(item); } @@ -153,7 +153,7 @@ namespace Content.Server.Traitor.Uplink return; // try to put it into players hands - if (player.TryGetComponent(out SharedHandsComponent? hands)) + if (IoCManager.Resolve().TryGetComponent(player.Uid, out SharedHandsComponent? hands)) hands.TryPutInAnyHand(EntityManager.GetEntity(tcUid.Value)); // play buying sound @@ -208,7 +208,7 @@ namespace Content.Server.Traitor.Uplink private IEntity? FindUplinkTarget(IEntity user) { // Try to find PDA in inventory - if (user.TryGetComponent(out InventoryComponent? inventory)) + if (IoCManager.Resolve().TryGetComponent(user.Uid, out InventoryComponent? inventory)) { var foundPDA = inventory.LookupItems().FirstOrDefault(); if (foundPDA != null) @@ -216,7 +216,7 @@ namespace Content.Server.Traitor.Uplink } // Also check hands - if (user.TryGetComponent(out HandsComponent? hands)) + if (IoCManager.Resolve().TryGetComponent(user.Uid, out HandsComponent? hands)) { var heldItems = hands.GetAllHeldItems(); foreach (var item in heldItems) diff --git a/Content.Server/TraitorDeathMatch/Components/TraitorDeathMatchRedemptionComponent.cs b/Content.Server/TraitorDeathMatch/Components/TraitorDeathMatchRedemptionComponent.cs index d830c3881b..779804e3f2 100644 --- a/Content.Server/TraitorDeathMatch/Components/TraitorDeathMatchRedemptionComponent.cs +++ b/Content.Server/TraitorDeathMatch/Components/TraitorDeathMatchRedemptionComponent.cs @@ -21,14 +21,14 @@ namespace Content.Server.TraitorDeathMatch.Components async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { - if (!eventArgs.User.TryGetComponent(out var userInv)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out var userInv)) { Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message", ("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-inventory-message")))); return false; } - if (!eventArgs.User.TryGetComponent(out var userMindComponent)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out var userMindComponent)) { Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message", ("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-mind-message")))); @@ -43,14 +43,14 @@ namespace Content.Server.TraitorDeathMatch.Components return false; } - if (!eventArgs.Using.TryGetComponent(out var victimUplink)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.Using.Uid, out var victimUplink)) { Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message", ("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-pda-message")))); return false; } - if (!eventArgs.Using.TryGetComponent(out var victimPDAOwner)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.Using.Uid, out var victimPDAOwner)) { Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message", ("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-pda-owner-message")))); @@ -68,7 +68,7 @@ namespace Content.Server.TraitorDeathMatch.Components UplinkComponent? userUplink = null; if (userPDAEntity != null) - if (userPDAEntity.TryGetComponent(out var userUplinkComponent)) + if (IoCManager.Resolve().TryGetComponent(userPDAEntity.Uid, out var userUplinkComponent)) userUplink = userUplinkComponent; if (userUplink == null) diff --git a/Content.Server/VendingMachines/VendingMachineComponent.cs b/Content.Server/VendingMachines/VendingMachineComponent.cs index 2b36b4225c..8de515d3f1 100644 --- a/Content.Server/VendingMachines/VendingMachineComponent.cs +++ b/Content.Server/VendingMachines/VendingMachineComponent.cs @@ -41,7 +41,7 @@ namespace Content.Server.VendingMachines private string _packPrototypeId = string.Empty; private string _spriteName = ""; - private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; + private bool Powered => !IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver) || receiver.Powered; private bool _broken; [DataField("soundVend")] @@ -57,7 +57,7 @@ namespace Content.Server.VendingMachines void IActivate.Activate(ActivateEventArgs eventArgs) { - if(!eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if(!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) { return; } @@ -109,7 +109,7 @@ namespace Content.Server.VendingMachines UserInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage; } - if (Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ApcPowerReceiverComponent? receiver)) { TrySetVisualState(receiver.Powered ? VendingMachineVisualState.Normal : VendingMachineVisualState.Off); } @@ -193,7 +193,7 @@ namespace Content.Server.VendingMachines private void TryEject(string id, IEntity? sender) { - if (Owner.TryGetComponent(out var accessReader)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out var accessReader)) { var accessSystem = EntitySystem.Get(); if (sender == null || !accessSystem.IsAllowed(accessReader, sender.Uid)) @@ -235,7 +235,7 @@ namespace Content.Server.VendingMachines finalState = VendingMachineVisualState.Off; } - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(VendingMachineVisuals.VisualState, finalState); } diff --git a/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs b/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs index 7435ed7ca1..61ef5b3329 100644 --- a/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs +++ b/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs @@ -272,7 +272,7 @@ namespace Content.Server.Weapon.Melee if ((!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) continue; - if (entity.TryGetComponent(out var bloodstream)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out var bloodstream)) hitBloodstreams.Add(bloodstream); } diff --git a/Content.Server/Weapon/Ranged/Ammunition/Components/AmmoBoxComponent.cs b/Content.Server/Weapon/Ranged/Ammunition/Components/AmmoBoxComponent.cs index e8a4c9592f..8ee3808ee3 100644 --- a/Content.Server/Weapon/Ranged/Ammunition/Components/AmmoBoxComponent.cs +++ b/Content.Server/Weapon/Ranged/Ammunition/Components/AmmoBoxComponent.cs @@ -73,7 +73,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components private void UpdateAppearance() { - if (Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearanceComponent)) { appearanceComponent.SetData(MagazineBarrelVisuals.MagLoaded, true); appearanceComponent.SetData(AmmoVisuals.AmmoCount, AmmoLeft); @@ -104,7 +104,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components public bool TryInsertAmmo(IEntity user, IEntity entity) { - if (!entity.TryGetComponent(out AmmoComponent? ammoComponent)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out AmmoComponent? ammoComponent)) { return false; } @@ -134,7 +134,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components return TryInsertAmmo(eventArgs.User, eventArgs.Using); } - if (eventArgs.Using.TryGetComponent(out RangedMagazineComponent? rangedMagazine)) + if (IoCManager.Resolve().TryGetComponent(eventArgs.Using.Uid, out RangedMagazineComponent? rangedMagazine)) { for (var i = 0; i < Math.Max(10, rangedMagazine.ShotsLeft); i++) { @@ -160,7 +160,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components private bool TryUse(IEntity user) { - if (!user.TryGetComponent(out HandsComponent? handsComponent)) + if (!IoCManager.Resolve().TryGetComponent(user.Uid, out HandsComponent? handsComponent)) { return false; } @@ -172,7 +172,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components return false; } - if (ammo.TryGetComponent(out ItemComponent? item)) + if (IoCManager.Resolve().TryGetComponent(ammo.Uid, out ItemComponent? item)) { if (!handsComponent.CanPutInHand(item)) { diff --git a/Content.Server/Weapon/Ranged/Ammunition/Components/AmmoComponent.cs b/Content.Server/Weapon/Ranged/Ammunition/Components/AmmoComponent.cs index 194c0f3a56..b6be339de5 100644 --- a/Content.Server/Weapon/Ranged/Ammunition/Components/AmmoComponent.cs +++ b/Content.Server/Weapon/Ranged/Ammunition/Components/AmmoComponent.cs @@ -117,7 +117,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components } _spent = true; - if (Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearanceComponent)) { appearanceComponent.SetData(AmmoVisuals.Spent, true); } diff --git a/Content.Server/Weapon/Ranged/Ammunition/Components/RangedMagazineComponent.cs b/Content.Server/Weapon/Ranged/Ammunition/Components/RangedMagazineComponent.cs index 9154f342f8..b9eba32b17 100644 --- a/Content.Server/Weapon/Ranged/Ammunition/Components/RangedMagazineComponent.cs +++ b/Content.Server/Weapon/Ranged/Ammunition/Components/RangedMagazineComponent.cs @@ -77,7 +77,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components } } - if (Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearanceComponent)) { _appearanceComponent = appearanceComponent; } @@ -93,7 +93,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components public bool TryInsertAmmo(IEntity user, IEntity ammo) { - if (!ammo.TryGetComponent(out AmmoComponent? ammoComponent)) + if (!IoCManager.Resolve().TryGetComponent(ammo.Uid, out AmmoComponent? ammoComponent)) { return false; } @@ -142,7 +142,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components bool IUse.UseEntity(UseEntityEventArgs eventArgs) { - if (!eventArgs.User.TryGetComponent(out HandsComponent? handsComponent)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out HandsComponent? handsComponent)) { return false; } diff --git a/Content.Server/Weapon/Ranged/Ammunition/Components/SpeedLoaderComponent.cs b/Content.Server/Weapon/Ranged/Ammunition/Components/SpeedLoaderComponent.cs index 584db2acf2..97b4f51436 100644 --- a/Content.Server/Weapon/Ranged/Ammunition/Components/SpeedLoaderComponent.cs +++ b/Content.Server/Weapon/Ranged/Ammunition/Components/SpeedLoaderComponent.cs @@ -59,7 +59,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components private void UpdateAppearance() { - if (Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearanceComponent)) { appearanceComponent?.SetData(MagazineBarrelVisuals.MagLoaded, true); appearanceComponent?.SetData(AmmoVisuals.AmmoCount, AmmoLeft); @@ -69,7 +69,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components public bool TryInsertAmmo(IEntity user, IEntity entity) { - if (!entity.TryGetComponent(out AmmoComponent? ammoComponent)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out AmmoComponent? ammoComponent)) { return false; } @@ -95,7 +95,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components private bool UseEntity(IEntity user) { - if (!user.TryGetComponent(out HandsComponent? handsComponent)) + if (!IoCManager.Resolve().TryGetComponent(user.Uid, out HandsComponent? handsComponent)) { return false; } @@ -147,7 +147,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components // This area is dirty but not sure of an easier way to do it besides add an interface or somethin var changed = false; - if (eventArgs.Target.TryGetComponent(out RevolverBarrelComponent? revolverBarrel)) + if (IoCManager.Resolve().TryGetComponent(eventArgs.Target.Uid, out RevolverBarrelComponent? revolverBarrel)) { for (var i = 0; i < Capacity; i++) { @@ -167,7 +167,7 @@ namespace Content.Server.Weapon.Ranged.Ammunition.Components TryInsertAmmo(eventArgs.User, ammo); break; } - } else if (eventArgs.Target.TryGetComponent(out BoltActionBarrelComponent? boltActionBarrel)) + } else if (IoCManager.Resolve().TryGetComponent(eventArgs.Target.Uid, out BoltActionBarrelComponent? boltActionBarrel)) { for (var i = 0; i < Capacity; i++) { diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs index ea60dbb6d2..d69d79f283 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs @@ -125,7 +125,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components // (Is one chambered?, is the bullet spend) var chamber = (chamberedExists, false); - if (chamberedExists && _chamberContainer.ContainedEntity!.TryGetComponent(out var ammo)) + if (chamberedExists && IoCManager.Resolve().TryGetComponent(_chamberContainer.ContainedEntity!.Uid, out var ammo)) { chamber.Item2 = ammo.Spent; } @@ -155,7 +155,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components _chamberContainer = ContainerHelpers.EnsureContainer(Owner, $"{Name}-chamber-container"); - if (Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearanceComponent)) { _appearanceComponent = appearanceComponent; } @@ -230,7 +230,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components public bool TryInsertBullet(IEntity user, IEntity ammo) { - if (!ammo.TryGetComponent(out AmmoComponent? ammoComponent)) + if (!IoCManager.Resolve().TryGetComponent(ammo.Uid, out AmmoComponent? ammoComponent)) { return false; } diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs index 4d7a5ba722..a0a7a45023 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs @@ -86,7 +86,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components // (Is one chambered?, is the bullet spend) var chamber = (chamberedExists, false); - if (chamberedExists && _chamberContainer.ContainedEntity!.TryGetComponent(out var ammo)) + if (chamberedExists && IoCManager.Resolve().TryGetComponent(_chamberContainer.ContainedEntity!.Uid, out var ammo)) { chamber.Item2 = ammo.Spent; } @@ -125,7 +125,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components _unspawnedCount--; } - if (Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearanceComponent)) { _appearanceComponent = appearanceComponent; } @@ -198,7 +198,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components public bool TryInsertBullet(InteractUsingEventArgs eventArgs) { - if (!eventArgs.Using.TryGetComponent(out AmmoComponent? ammoComponent)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.Using.Uid, out AmmoComponent? ammoComponent)) { return false; } diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs index a710100ddf..0f3ad4298f 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs @@ -82,7 +82,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { slotsSpent[i] = null; var ammoEntity = _ammoSlots[i]; - if (ammoEntity != null && ammoEntity.TryGetComponent(out AmmoComponent? ammo)) + if (ammoEntity != null && IoCManager.Resolve().TryGetComponent(ammoEntity.Uid, out AmmoComponent? ammo)) { slotsSpent[i] = ammo.Spent; } @@ -126,7 +126,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components private void UpdateAppearance() { - if (!Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { return; } @@ -139,7 +139,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components public bool TryInsertBullet(IEntity user, IEntity entity) { - if (!entity.TryGetComponent(out AmmoComponent? ammoComponent)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out AmmoComponent? ammoComponent)) { return false; } diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs index f69b0da36a..d2d1b74de1 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs @@ -106,7 +106,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components _ammoContainer = ContainerHelpers.EnsureContainer(Owner, $"{Name}-ammo-container"); } - if (Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearanceComponent)) { _appearanceComponent = appearanceComponent; } @@ -178,13 +178,13 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components entity = IoCManager.Resolve().SpawnEntity(_ammoPrototype, spawnAt); } - if (entity.TryGetComponent(out ProjectileComponent? projectileComponent)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ProjectileComponent? projectileComponent)) { if (energyRatio < 1.0) { projectileComponent.Damage *= energyRatio; } - } else if (entity.TryGetComponent(out HitscanComponent? hitscanComponent)) + } else if (IoCManager.Resolve().TryGetComponent(entity.Uid, out HitscanComponent? hitscanComponent)) { hitscanComponent.Damage *= energyRatio; hitscanComponent.ColorModifier = energyRatio; @@ -242,7 +242,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components return false; } - if (!user.TryGetComponent(out HandsComponent? hands)) + if (!IoCManager.Resolve().TryGetComponent(user.Uid, out HandsComponent? hands)) { return false; } diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs index 2566dd4a76..0146781c60 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs @@ -154,7 +154,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { (int, int)? count = null; var magazine = MagazineContainer.ContainedEntity; - if (magazine != null && magazine.TryGetComponent(out RangedMagazineComponent? rangedMagazineComponent)) + if (magazine != null && IoCManager.Resolve().TryGetComponent(magazine.Uid, out RangedMagazineComponent? rangedMagazineComponent)) { count = (rangedMagazineComponent.ShotsLeft, rangedMagazineComponent.Capacity); } @@ -170,7 +170,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { base.Initialize(); - if (Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearanceComponent)) { _appearanceComponent = appearanceComponent; } @@ -338,7 +338,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components MagazineContainer.Remove(mag); SoundSystem.Play(Filter.Pvs(Owner), _soundMagEject.GetSound(), Owner, AudioParams.Default.WithVolume(-2)); - if (user.TryGetComponent(out HandsComponent? handsComponent)) + if (IoCManager.Resolve().TryGetComponent(user.Uid, out HandsComponent? handsComponent)) { handsComponent.PutInHandOrDrop(IoCManager.Resolve().GetComponent(mag.Uid)); } @@ -349,7 +349,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components public bool CanInsertMagazine(IEntity user, IEntity magazine, bool quiet = true) { - if (!magazine.TryGetComponent(out RangedMagazineComponent? magazineComponent)) + if (!IoCManager.Resolve().TryGetComponent(magazine.Uid, out RangedMagazineComponent? magazineComponent)) { return false; } @@ -403,7 +403,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components } // Insert 1 ammo - if (eventArgs.Using.TryGetComponent(out AmmoComponent? ammoComponent)) + if (IoCManager.Resolve().TryGetComponent(eventArgs.Using.Uid, out AmmoComponent? ammoComponent)) { if (!BoltOpen) { diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/ServerRangedBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/ServerRangedBarrelComponent.cs index 19dd2d9e85..5bebf49382 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/ServerRangedBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/ServerRangedBarrelComponent.cs @@ -149,7 +149,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components protected override void OnRemove() { base.OnRemove(); - if (Owner.TryGetComponent(out ServerRangedWeaponComponent? rangedWeaponComponent)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ServerRangedWeaponComponent? rangedWeaponComponent)) { rangedWeaponComponent.Barrel = null; rangedWeaponComponent.FireHandler -= Fire; @@ -215,19 +215,19 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components var direction = (targetPos - shooter.Transform.WorldPosition).ToAngle(); var angle = GetRecoilAngle(direction); // This should really be client-side but for now we'll just leave it here - if (shooter.TryGetComponent(out CameraRecoilComponent? recoilComponent)) + if (IoCManager.Resolve().TryGetComponent(shooter.Uid, out CameraRecoilComponent? recoilComponent)) { recoilComponent.Kick(-angle.ToVec() * 0.15f); } // This section probably needs tweaking so there can be caseless hitscan etc. - if (projectile.TryGetComponent(out HitscanComponent? hitscan)) + if (IoCManager.Resolve().TryGetComponent(projectile.Uid, out HitscanComponent? hitscan)) { FireHitscan(shooter, hitscan, angle); } else if (IoCManager.Resolve().HasComponent(projectile.Uid) && ammo != null && - ammo.TryGetComponent(out AmmoComponent? ammoComponent)) + IoCManager.Resolve().TryGetComponent(ammo.Uid, out AmmoComponent? ammoComponent)) { FireProjectiles(shooter, projectile, ammoComponent.ProjectilesFired, ammoComponent.EvenSpreadAngle, angle, ammoComponent.Velocity, ammo); diff --git a/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs b/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs index b4751d2cf2..256eedbcbb 100644 --- a/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs +++ b/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs @@ -146,12 +146,12 @@ namespace Content.Server.Weapon.Ranged /// Target position on the map to shoot at. private void TryFire(IEntity user, Vector2 targetPos) { - if (!user.TryGetComponent(out HandsComponent? hands) || hands.GetActiveHand?.Owner != Owner) + if (!IoCManager.Resolve().TryGetComponent(user.Uid, out HandsComponent? hands) || hands.GetActiveHand?.Owner != Owner) { return; } - if (!user.TryGetComponent(out CombatModeComponent? combat) || !combat.IsInCombatMode) + if (!IoCManager.Resolve().TryGetComponent(user.Uid, out CombatModeComponent? combat) || !combat.IsInCombatMode) { return; } diff --git a/Content.Server/Weapon/WeaponCapacitorChargerComponent.cs b/Content.Server/Weapon/WeaponCapacitorChargerComponent.cs index d7af61facf..b9a4e82cba 100644 --- a/Content.Server/Weapon/WeaponCapacitorChargerComponent.cs +++ b/Content.Server/Weapon/WeaponCapacitorChargerComponent.cs @@ -3,6 +3,7 @@ using Content.Server.PowerCell.Components; using Content.Server.Weapon.Ranged.Barrels.Components; using Content.Shared.Interaction; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.Weapon { @@ -18,13 +19,13 @@ namespace Content.Server.Weapon public override bool IsEntityCompatible(IEntity entity) { - return entity.TryGetComponent(out ServerBatteryBarrelComponent? battery) && battery.PowerCell != null || - entity.TryGetComponent(out PowerCellSlotComponent? slot) && slot.HasCell; + return IoCManager.Resolve().TryGetComponent(entity.Uid, out ServerBatteryBarrelComponent? battery) && battery.PowerCell != null || + IoCManager.Resolve().TryGetComponent(entity.Uid, out PowerCellSlotComponent? slot) && slot.HasCell; } protected override BatteryComponent? GetBatteryFrom(IEntity entity) { - if (entity.TryGetComponent(out PowerCellSlotComponent? slot)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out PowerCellSlotComponent? slot)) { if (slot.Cell != null) { @@ -32,7 +33,7 @@ namespace Content.Server.Weapon } } - if (entity.TryGetComponent(out ServerBatteryBarrelComponent? battery)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out ServerBatteryBarrelComponent? battery)) { if (battery.PowerCell != null) { diff --git a/Content.Server/Window/WindowComponent.cs b/Content.Server/Window/WindowComponent.cs index 52c84a1c7b..cfb6093237 100644 --- a/Content.Server/Window/WindowComponent.cs +++ b/Content.Server/Window/WindowComponent.cs @@ -44,8 +44,8 @@ namespace Content.Server.Window void IExamine.Examine(FormattedMessage message, bool inDetailsRange) { - if (!Owner.TryGetComponent(out DamageableComponent? damageable) || - !Owner.TryGetComponent(out DestructibleComponent? destructible)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out DamageableComponent? damageable) || + !IoCManager.Resolve().TryGetComponent(Owner.Uid, out DestructibleComponent? destructible)) { return; } diff --git a/Content.Server/WireHacking/WiresComponent.cs b/Content.Server/WireHacking/WiresComponent.cs index 330735b78a..9059be9559 100644 --- a/Content.Server/WireHacking/WiresComponent.cs +++ b/Content.Server/WireHacking/WiresComponent.cs @@ -117,7 +117,7 @@ namespace Content.Server.WireHacking private void UpdateAppearance() { - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(WiresVisuals.MaintenancePanelState, IsPanelOpen && IsPanelVisible); } @@ -175,7 +175,7 @@ namespace Content.Server.WireHacking base.Initialize(); _audioSystem = EntitySystem.Get(); - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(WiresVisuals.MaintenancePanelState, IsPanelOpen); } @@ -416,7 +416,7 @@ namespace Content.Server.WireHacking return; } - if (!player.TryGetComponent(out HandsComponent? handsComponent)) + if (!IoCManager.Resolve().TryGetComponent(player.Uid, out HandsComponent? handsComponent)) { Owner.PopupMessage(player, Loc.GetString("wires-component-ui-on-receive-message-no-hands")); return; @@ -431,7 +431,7 @@ namespace Content.Server.WireHacking var activeHandEntity = handsComponent.GetActiveHand?.Owner; ToolComponent? tool = null; if(activeHandEntity != null) - activeHandEntity.TryGetComponent(out tool); + IoCManager.Resolve().TryGetComponent(activeHandEntity.Uid, out tool); var toolSystem = EntitySystem.Get(); switch (msg.Action) @@ -502,7 +502,7 @@ namespace Content.Server.WireHacking async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { - if (!eventArgs.Using.TryGetComponent(out var tool)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.Using.Uid, out var tool)) { return false; } @@ -514,7 +514,7 @@ namespace Content.Server.WireHacking (tool.Qualities.Contains(_cuttingQuality) || tool.Qualities.Contains(_pulsingQuality))) { - if (eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if (IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) { OpenInterface(actor.PlayerSession); return true; diff --git a/Content.Shared/Actions/Behaviors/IActionBehavior.cs b/Content.Shared/Actions/Behaviors/IActionBehavior.cs index 74dc3ca08f..83d8638b64 100644 --- a/Content.Shared/Actions/Behaviors/IActionBehavior.cs +++ b/Content.Shared/Actions/Behaviors/IActionBehavior.cs @@ -1,6 +1,7 @@ using System; using Content.Shared.Actions.Components; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Shared.Actions.Behaviors { @@ -34,7 +35,7 @@ namespace Content.Shared.Actions.Behaviors { Performer = performer; ActionType = actionType; - if (!Performer.TryGetComponent(out PerformerActions)) + if (!IoCManager.Resolve().TryGetComponent(Performer.Uid, out PerformerActions)) { throw new InvalidOperationException($"performer {performer.Name} tried to perform action {actionType} " + $" but the performer had no actions component," + diff --git a/Content.Shared/Actions/Behaviors/Item/IItemActionBehavior.cs b/Content.Shared/Actions/Behaviors/Item/IItemActionBehavior.cs index e49a6a9ba0..ce7fff3f22 100644 --- a/Content.Shared/Actions/Behaviors/Item/IItemActionBehavior.cs +++ b/Content.Shared/Actions/Behaviors/Item/IItemActionBehavior.cs @@ -1,6 +1,7 @@ using System; using Content.Shared.Actions.Components; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Shared.Actions.Behaviors.Item { @@ -40,7 +41,7 @@ namespace Content.Shared.Actions.Behaviors.Item Performer = performer; ActionType = actionType; Item = item; - if (!Item.TryGetComponent(out ItemActions)) + if (!IoCManager.Resolve().TryGetComponent(Item.Uid, out ItemActions)) { throw new InvalidOperationException($"performer {performer.Name} tried to perform item action {actionType} " + $" for item {Item.Name} but the item had no ItemActionsComponent," + diff --git a/Content.Shared/Actions/Components/ItemActionsComponent.cs b/Content.Shared/Actions/Components/ItemActionsComponent.cs index 8540492155..983d06cb5b 100644 --- a/Content.Shared/Actions/Components/ItemActionsComponent.cs +++ b/Content.Shared/Actions/Components/ItemActionsComponent.cs @@ -4,6 +4,7 @@ using Content.Shared.Hands; using Content.Shared.Hands.Components; using Content.Shared.Inventory; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Log; using Robust.Shared.Serialization; using Robust.Shared.Serialization.Manager.Attributes; @@ -183,7 +184,7 @@ namespace Content.Shared.Actions.Components void IEquippedHand.EquippedHand(EquippedHandEventArgs eventArgs) { // this entity cannot be granted actions if no actions component - if (!eventArgs.User.TryGetComponent(out var actionsComponent)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out var actionsComponent)) return; Holder = eventArgs.User; _holderActionsComponent = actionsComponent; @@ -195,7 +196,7 @@ namespace Content.Shared.Actions.Components void IEquipped.Equipped(EquippedEventArgs eventArgs) { // this entity cannot be granted actions if no actions component - if (!eventArgs.User.TryGetComponent(out var actionsComponent)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out var actionsComponent)) return; Holder = eventArgs.User; _holderActionsComponent = actionsComponent; diff --git a/Content.Shared/Body/Components/SharedBodyComponent.cs b/Content.Shared/Body/Components/SharedBodyComponent.cs index f9f622908b..8d926a7211 100644 --- a/Content.Shared/Body/Components/SharedBodyComponent.cs +++ b/Content.Shared/Body/Components/SharedBodyComponent.cs @@ -547,7 +547,7 @@ namespace Content.Shared.Body.Components continue; } - if (!entity.TryGetComponent(out SharedBodyPartComponent? part)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out SharedBodyPartComponent? part)) { continue; } diff --git a/Content.Shared/Body/Components/SharedBodyPartComponent.cs b/Content.Shared/Body/Components/SharedBodyPartComponent.cs index c24f308f27..4c03aace80 100644 --- a/Content.Shared/Body/Components/SharedBodyPartComponent.cs +++ b/Content.Shared/Body/Components/SharedBodyPartComponent.cs @@ -370,7 +370,7 @@ namespace Content.Shared.Body.Components continue; } - if (!entity.TryGetComponent(out SharedMechanismComponent? mechanism)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out SharedMechanismComponent? mechanism)) { continue; } diff --git a/Content.Shared/Buckle/Components/SharedStrapComponent.cs b/Content.Shared/Buckle/Components/SharedStrapComponent.cs index 4dc912f01e..5c68a6a8d9 100644 --- a/Content.Shared/Buckle/Components/SharedStrapComponent.cs +++ b/Content.Shared/Buckle/Components/SharedStrapComponent.cs @@ -3,6 +3,7 @@ using Content.Shared.DragDrop; using Content.Shared.Interaction.Helpers; using Robust.Shared.GameObjects; using Robust.Shared.GameStates; +using Robust.Shared.IoC; using Robust.Shared.Serialization; namespace Content.Shared.Buckle.Components @@ -32,7 +33,7 @@ namespace Content.Shared.Buckle.Components bool IDragDropOn.CanDragDropOn(DragDropEvent eventArgs) { - if (!eventArgs.Dragged.TryGetComponent(out SharedBuckleComponent? buckleComponent)) return false; + if (!IoCManager.Resolve().TryGetComponent(eventArgs.Dragged.Uid, out SharedBuckleComponent? buckleComponent)) return false; bool Ignored(IEntity entity) => entity == eventArgs.User || entity == eventArgs.Dragged || entity == eventArgs.Target; return eventArgs.Target.InRangeUnobstructed(eventArgs.Dragged, buckleComponent.Range, predicate: Ignored); diff --git a/Content.Shared/CombatMode/SharedCombatModeSystem.cs b/Content.Shared/CombatMode/SharedCombatModeSystem.cs index 70101b35bf..973bef9a54 100644 --- a/Content.Shared/CombatMode/SharedCombatModeSystem.cs +++ b/Content.Shared/CombatMode/SharedCombatModeSystem.cs @@ -1,4 +1,5 @@ using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Shared.CombatMode { @@ -16,7 +17,7 @@ namespace Content.Shared.CombatMode { var entity = eventArgs.SenderSession?.AttachedEntity; - if (entity == null || !entity.TryGetComponent(out SharedCombatModeComponent? combatModeComponent)) + if (entity == null || !IoCManager.Resolve().TryGetComponent(entity.Uid, out SharedCombatModeComponent? combatModeComponent)) { return; } diff --git a/Content.Shared/Construction/Steps/MaterialConstructionGraphStep.cs b/Content.Shared/Construction/Steps/MaterialConstructionGraphStep.cs index 90c4f8a982..3efd21922b 100644 --- a/Content.Shared/Construction/Steps/MaterialConstructionGraphStep.cs +++ b/Content.Shared/Construction/Steps/MaterialConstructionGraphStep.cs @@ -34,7 +34,7 @@ namespace Content.Shared.Construction.Steps public bool EntityValid(IEntity entity, [NotNullWhen(true)] out SharedStackComponent? stack) { - if (entity.TryGetComponent(out SharedStackComponent? otherStack) && otherStack.StackTypeId.Equals(MaterialPrototypeId) && otherStack.Count >= Amount) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out SharedStackComponent? otherStack) && otherStack.StackTypeId.Equals(MaterialPrototypeId) && otherStack.Count >= Amount) stack = otherStack; else stack = null; diff --git a/Content.Shared/Disposal/SharedDisposalUnitSystem.cs b/Content.Shared/Disposal/SharedDisposalUnitSystem.cs index 98adba3299..2a685d96f3 100644 --- a/Content.Shared/Disposal/SharedDisposalUnitSystem.cs +++ b/Content.Shared/Disposal/SharedDisposalUnitSystem.cs @@ -53,17 +53,17 @@ namespace Content.Shared.Disposal return false; // TODO: Probably just need a disposable tag. - if (!entity.TryGetComponent(out SharedItemComponent? storable) && + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out SharedItemComponent? storable) && !IoCManager.Resolve().HasComponent(entity.Uid)) { return false; } - if (!entity.TryGetComponent(out IPhysBody? physics) || + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out IPhysBody? physics) || !physics.CanCollide && storable == null) { - if (!(entity.TryGetComponent(out MobStateComponent? damageState) && damageState.IsDead())) + if (!(IoCManager.Resolve().TryGetComponent(entity.Uid, out MobStateComponent? damageState) && damageState.IsDead())) { return false; } diff --git a/Content.Shared/Examine/ExamineSystemShared.cs b/Content.Shared/Examine/ExamineSystemShared.cs index 473b868836..5d921482c0 100644 --- a/Content.Shared/Examine/ExamineSystemShared.cs +++ b/Content.Shared/Examine/ExamineSystemShared.cs @@ -71,7 +71,7 @@ namespace Content.Shared.Examine [Pure] public virtual bool CanExamine(IEntity examiner, MapCoordinates target, Ignored? predicate = null) { - if (!examiner.TryGetComponent(out ExaminerComponent? examinerComponent)) + if (!IoCManager.Resolve().TryGetComponent(examiner.Uid, out ExaminerComponent? examinerComponent)) return false; if (!examinerComponent.DoRangeCheck) @@ -128,7 +128,7 @@ namespace Content.Shared.Examine foreach (var result in rayResults) { - if (!result.HitEntity.TryGetComponent(out OccluderComponent? o)) + if (!IoCManager.Resolve().TryGetComponent(result.HitEntity.Uid, out OccluderComponent? o)) { continue; } diff --git a/Content.Shared/Hands/Components/SharedHandsComponent.cs b/Content.Shared/Hands/Components/SharedHandsComponent.cs index 8ee09519cc..a95c6fce56 100644 --- a/Content.Shared/Hands/Components/SharedHandsComponent.cs +++ b/Content.Shared/Hands/Components/SharedHandsComponent.cs @@ -102,7 +102,7 @@ namespace Content.Shared.Hands.Components public void UpdateHandVisualizer() { - if (!Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out AppearanceComponent? appearance)) return; var hands = new List(); @@ -111,7 +111,7 @@ namespace Content.Shared.Hands.Components if (hand.HeldEntity == null) continue; - if (!hand.HeldEntity.TryGetComponent(out SharedItemComponent? item) || item.RsiPath == null) + if (!IoCManager.Resolve().TryGetComponent(hand.HeldEntity.Uid, out SharedItemComponent? item) || item.RsiPath == null) continue; var handState = new HandVisualState(item.RsiPath, item.EquippedPrefix, hand.Location, item.Color); diff --git a/Content.Shared/Hands/SharedHandsSystem.cs b/Content.Shared/Hands/SharedHandsSystem.cs index e3aeeb7a06..e9ac802ce5 100644 --- a/Content.Shared/Hands/SharedHandsSystem.cs +++ b/Content.Shared/Hands/SharedHandsSystem.cs @@ -3,6 +3,7 @@ using Robust.Shared.Containers; using Robust.Shared.GameObjects; using Robust.Shared.Serialization; using System; +using Robust.Shared.IoC; namespace Content.Shared.Hands { @@ -22,7 +23,7 @@ namespace Content.Shared.Hands { var entity = eventArgs.SenderSession.AttachedEntity; - if (entity == null || !entity.TryGetComponent(out SharedHandsComponent? hands)) + if (entity == null || !IoCManager.Resolve().TryGetComponent(entity.Uid, out SharedHandsComponent? hands)) return; hands.ActiveHand = msg.HandName; diff --git a/Content.Shared/Interaction/RotateToFaceSystem.cs b/Content.Shared/Interaction/RotateToFaceSystem.cs index 4a90785c96..4511dc7b47 100644 --- a/Content.Shared/Interaction/RotateToFaceSystem.cs +++ b/Content.Shared/Interaction/RotateToFaceSystem.cs @@ -52,7 +52,7 @@ namespace Content.Shared.Interaction } else { - if (user.TryGetComponent(out SharedBuckleComponent? buckle) && buckle.Buckled) + if (IoCManager.Resolve().TryGetComponent(user.Uid, out SharedBuckleComponent? buckle) && buckle.Buckled) { var suid = buckle.LastEntityBuckledTo; if (suid != null) diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index 31acf61a9a..325a1d2b8d 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -154,7 +154,7 @@ namespace Content.Shared.Interaction foreach (var result in rayResults) { - if (!result.HitEntity.TryGetComponent(out IPhysBody? p)) + if (!IoCManager.Resolve().TryGetComponent(result.HitEntity.Uid, out IPhysBody? p)) { continue; } @@ -441,7 +441,7 @@ namespace Content.Shared.Interaction protected void InteractionActivate(IEntity user, IEntity used) { - if (used.TryGetComponent(out var delayComponent)) + if (IoCManager.Resolve().TryGetComponent(used.Uid, out var delayComponent)) { if (delayComponent.ActiveDelay) return; @@ -469,7 +469,7 @@ namespace Content.Shared.Interaction return; } - if (!used.TryGetComponent(out IActivate? activateComp)) + if (!IoCManager.Resolve().TryGetComponent(used.Uid, out IActivate? activateComp)) return; var activateEventArgs = new ActivateEventArgs(user, used); @@ -503,7 +503,7 @@ namespace Content.Shared.Interaction /// public void UseInteraction(IEntity user, IEntity used) { - if (used.TryGetComponent(out var delayComponent)) + if (IoCManager.Resolve().TryGetComponent(used.Uid, out var delayComponent)) { if (delayComponent.ActiveDelay) return; diff --git a/Content.Shared/Item/SharedItemComponent.cs b/Content.Shared/Item/SharedItemComponent.cs index a4ca8fe165..9e6313d961 100644 --- a/Content.Shared/Item/SharedItemComponent.cs +++ b/Content.Shared/Item/SharedItemComponent.cs @@ -6,6 +6,7 @@ using Content.Shared.Interaction.Helpers; using Content.Shared.Inventory; using Robust.Shared.GameObjects; using Robust.Shared.GameStates; +using Robust.Shared.IoC; using Robust.Shared.Maths; using Robust.Shared.Physics; using Robust.Shared.Players; @@ -117,7 +118,7 @@ namespace Content.Shared.Item if (user.Transform.MapID != Owner.Transform.MapID) return false; - if (!Owner.TryGetComponent(out IPhysBody? physics) || physics.BodyType == BodyType.Static) + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out IPhysBody? physics) || physics.BodyType == BodyType.Static) return false; return user.InRangeUnobstructed(Owner, ignoreInsideBlocker: true, popup: popup); @@ -140,7 +141,7 @@ namespace Content.Shared.Item if (!CanPickup(user)) return false; - if (!user.TryGetComponent(out SharedHandsComponent? hands)) + if (!IoCManager.Resolve().TryGetComponent(user.Uid, out SharedHandsComponent? hands)) return false; var activeHand = hands.ActiveHand; diff --git a/Content.Shared/MobState/Components/MobStateComponent.cs b/Content.Shared/MobState/Components/MobStateComponent.cs index 032a8477c6..14b6349b13 100644 --- a/Content.Shared/MobState/Components/MobStateComponent.cs +++ b/Content.Shared/MobState/Components/MobStateComponent.cs @@ -66,7 +66,7 @@ namespace Content.Shared.MobState.Components protected override void OnRemove() { - if (Owner.TryGetComponent(out SharedAlertsComponent? status)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out SharedAlertsComponent? status)) { status.ClearAlert(AlertType.HumanHealth); } diff --git a/Content.Shared/Movement/Components/MovementIgnoreGravityComponent.cs b/Content.Shared/Movement/Components/MovementIgnoreGravityComponent.cs index e8baaa177f..ed383367e1 100644 --- a/Content.Shared/Movement/Components/MovementIgnoreGravityComponent.cs +++ b/Content.Shared/Movement/Components/MovementIgnoreGravityComponent.cs @@ -17,7 +17,7 @@ namespace Content.Shared.Movement.Components public static bool IsWeightless(this IEntity entity, PhysicsComponent? body = null, EntityCoordinates? coords = null, IMapManager? mapManager = null, IEntityManager? entityManager = null) { if (body == null) - entity.TryGetComponent(out body); + IoCManager.Resolve().TryGetComponent(entity.Uid, out body); if (IoCManager.Resolve().HasComponent(entity.Uid) || (body?.BodyType & (BodyType.Static | BodyType.Kinematic)) != 0) return false; diff --git a/Content.Shared/Movement/EntitySystems/SharedMobMoverSystem.cs b/Content.Shared/Movement/EntitySystems/SharedMobMoverSystem.cs index ea7654ce99..f0b995462e 100644 --- a/Content.Shared/Movement/EntitySystems/SharedMobMoverSystem.cs +++ b/Content.Shared/Movement/EntitySystems/SharedMobMoverSystem.cs @@ -43,7 +43,7 @@ namespace Content.Shared.Movement.EntitySystems if (otherBody.BodyType != BodyType.Dynamic || !otherFixture.Hard) return; - if (!ourFixture.Body.Owner.TryGetComponent(out IMobMoverComponent? mobMover) || worldNormal == Vector2.Zero) return; + if (!IoCManager.Resolve().TryGetComponent(ourFixture.Body.Owner.Uid, out IMobMoverComponent? mobMover) || worldNormal == Vector2.Zero) return; otherBody.ApplyLinearImpulse(-worldNormal * mobMover.PushStrength * frameTime); } diff --git a/Content.Shared/Movement/SharedMoverController.cs b/Content.Shared/Movement/SharedMoverController.cs index 00effb7edd..34e76937f3 100644 --- a/Content.Shared/Movement/SharedMoverController.cs +++ b/Content.Shared/Movement/SharedMoverController.cs @@ -166,7 +166,7 @@ namespace Content.Shared.Movement return body.BodyStatus == BodyStatus.OnGround && IoCManager.Resolve().HasComponent(body.Owner.Uid) && // If we're being pulled then don't mess with our velocity. - (!body.Owner.TryGetComponent(out SharedPullableComponent? pullable) || !pullable.BeingPulled) && + (!IoCManager.Resolve().TryGetComponent(body.Owner.Uid, out SharedPullableComponent? pullable) || !pullable.BeingPulled) && _blocker.CanMove(body.OwnerUid); } @@ -186,7 +186,7 @@ namespace Content.Shared.Movement !otherCollider.CanCollide || ((collider.CollisionMask & otherCollider.CollisionLayer) == 0 && (otherCollider.CollisionMask & collider.CollisionLayer) == 0) || - (otherCollider.Owner.TryGetComponent(out SharedPullableComponent? pullable) && pullable.BeingPulled)) + (IoCManager.Resolve().TryGetComponent(otherCollider.Owner.Uid, out SharedPullableComponent? pullable) && pullable.BeingPulled)) { continue; } diff --git a/Content.Shared/Nutrition/EntitySystems/SharedCreamPieSystem.cs b/Content.Shared/Nutrition/EntitySystems/SharedCreamPieSystem.cs index 4190b92517..8ab0b371b8 100644 --- a/Content.Shared/Nutrition/EntitySystems/SharedCreamPieSystem.cs +++ b/Content.Shared/Nutrition/EntitySystems/SharedCreamPieSystem.cs @@ -62,7 +62,7 @@ namespace Content.Shared.Nutrition.EntitySystems private void OnCreamPiedHitBy(EntityUid uid, CreamPiedComponent creamPied, ThrowHitByEvent args) { - if (!IoCManager.Resolve().EntityExists(args.Thrown.Uid) || !args.Thrown.TryGetComponent(out CreamPieComponent? creamPie)) return; + if (!IoCManager.Resolve().EntityExists(args.Thrown.Uid) || !IoCManager.Resolve().TryGetComponent(args.Thrown.Uid, out CreamPieComponent? creamPie)) return; SetCreamPied(uid, creamPied, true); diff --git a/Content.Shared/Placeable/PlaceableSurfaceSystem.cs b/Content.Shared/Placeable/PlaceableSurfaceSystem.cs index 1f8a4cd9b0..5773b20580 100644 --- a/Content.Shared/Placeable/PlaceableSurfaceSystem.cs +++ b/Content.Shared/Placeable/PlaceableSurfaceSystem.cs @@ -52,7 +52,7 @@ namespace Content.Shared.Placeable if (!surface.IsPlaceable) return; - if(!args.User.TryGetComponent(out var handComponent)) + if(!IoCManager.Resolve().TryGetComponent(args.User.Uid, out var handComponent)) return; if (!args.ClickLocation.IsValid(IoCManager.Resolve())) diff --git a/Content.Shared/Pulling/Components/PullableComponent.cs b/Content.Shared/Pulling/Components/PullableComponent.cs index 6874b13bb1..7a7aa491e0 100644 --- a/Content.Shared/Pulling/Components/PullableComponent.cs +++ b/Content.Shared/Pulling/Components/PullableComponent.cs @@ -71,7 +71,7 @@ namespace Content.Shared.Pulling.Components return; } - if (!entity.TryGetComponent(out var comp)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out var comp)) { Logger.Error($"Entity {state.Puller.Value} for pulling had no Puller component"); // ensure it disconnects from any different puller, still diff --git a/Content.Shared/Pulling/Systems/SharedPullerSystem.cs b/Content.Shared/Pulling/Systems/SharedPullerSystem.cs index b8838b386b..d452a380e8 100644 --- a/Content.Shared/Pulling/Systems/SharedPullerSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullerSystem.cs @@ -48,7 +48,7 @@ namespace Content.Shared.Pulling.Systems if (args.Puller.OwnerUid != uid) return; - if (component.Owner.TryGetComponent(out SharedAlertsComponent? alerts)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out SharedAlertsComponent? alerts)) alerts.ShowAlert(AlertType.Pulling); RefreshMovementSpeed(component); @@ -62,7 +62,7 @@ namespace Content.Shared.Pulling.Systems if (args.Puller.OwnerUid != uid) return; - if (component.Owner.TryGetComponent(out SharedAlertsComponent? alerts)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out SharedAlertsComponent? alerts)) alerts.ClearAlert(AlertType.Pulling); RefreshMovementSpeed(component); diff --git a/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs b/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs index 0b08f9bfa8..914c229b26 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs @@ -43,7 +43,7 @@ namespace Content.Shared.Pulling ForceSetMovingTo(pullable, null); // Joint shutdown - if (puller.Owner.TryGetComponent(out var jointComp)) + if (IoCManager.Resolve().TryGetComponent(puller.Owner.Uid, out var jointComp)) { if (jointComp.GetJoints.Contains(pullable.PullJoint!)) { diff --git a/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs b/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs index 966d2b817c..5332bbaf67 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs @@ -39,7 +39,7 @@ namespace Content.Shared.Pulling return false; } - if (!pulled.TryGetComponent(out var _physics)) + if (!IoCManager.Resolve().TryGetComponent(pulled.Uid, out var _physics)) { return false; } @@ -59,7 +59,7 @@ namespace Content.Shared.Pulling return false; } - if (puller.TryGetComponent(out var buckle)) + if (IoCManager.Resolve().TryGetComponent(puller.Uid, out var buckle)) { // Prevent people pulling the chair they're on, etc. if (buckle.Buckled && (buckle.LastEntityBuckledTo == pulled.Uid)) @@ -102,11 +102,11 @@ namespace Content.Shared.Pulling public bool TryStartPull(IEntity puller, IEntity pullable) { - if (!puller.TryGetComponent(out var pullerComp)) + if (!IoCManager.Resolve().TryGetComponent(puller.Uid, out var pullerComp)) { return false; } - if (!pullable.TryGetComponent(out var pullableComp)) + if (!IoCManager.Resolve().TryGetComponent(pullable.Uid, out var pullableComp)) { return false; } @@ -126,12 +126,12 @@ namespace Content.Shared.Pulling return false; } - if (!puller.Owner.TryGetComponent(out var pullerPhysics)) + if (!IoCManager.Resolve().TryGetComponent(puller.Owner.Uid, out var pullerPhysics)) { return false; } - if (!pullable.Owner.TryGetComponent(out var pullablePhysics)) + if (!IoCManager.Resolve().TryGetComponent(pullable.Owner.Uid, out var pullablePhysics)) { return false; } @@ -143,7 +143,7 @@ namespace Content.Shared.Pulling var oldPullable = puller.Pulling; if (oldPullable != null) { - if (oldPullable.TryGetComponent(out var oldPullableComp)) + if (IoCManager.Resolve().TryGetComponent(oldPullable.Uid, out var oldPullableComp)) { if (!TryStopPull(oldPullableComp)) { diff --git a/Content.Shared/Pulling/Systems/SharedPullingSystem.cs b/Content.Shared/Pulling/Systems/SharedPullingSystem.cs index ad00d87be8..b1d77d0b74 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingSystem.cs @@ -105,7 +105,7 @@ namespace Content.Shared.Pulling if (args.Pulled.OwnerUid != uid) return; - if (component.Owner.TryGetComponent(out SharedAlertsComponent? alerts)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out SharedAlertsComponent? alerts)) alerts.ShowAlert(AlertType.Pulled); } @@ -114,7 +114,7 @@ namespace Content.Shared.Pulling if (args.Pulled.OwnerUid != uid) return; - if (component.Owner.TryGetComponent(out SharedAlertsComponent? alerts)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out SharedAlertsComponent? alerts)) alerts.ClearAlert(AlertType.Pulled); } @@ -170,7 +170,7 @@ namespace Content.Shared.Pulling return; } - if (!pulled.TryGetComponent(out IPhysBody? physics)) + if (!IoCManager.Resolve().TryGetComponent(pulled.Uid, out IPhysBody? physics)) { return; } @@ -183,16 +183,16 @@ namespace Content.Shared.Pulling // TODO: When Joint networking is less shitcodey fix this to use a dedicated joints message. private void HandleContainerInsert(EntInsertedIntoContainerMessage message) { - if (message.Entity.TryGetComponent(out SharedPullableComponent? pullable)) + if (IoCManager.Resolve().TryGetComponent(message.Entity.Uid, out SharedPullableComponent? pullable)) { TryStopPull(pullable); } - if (message.Entity.TryGetComponent(out SharedPullerComponent? puller)) + if (IoCManager.Resolve().TryGetComponent(message.Entity.Uid, out SharedPullerComponent? puller)) { if (puller.Pulling == null) return; - if (!puller.Pulling.TryGetComponent(out SharedPullableComponent? pulling)) + if (!IoCManager.Resolve().TryGetComponent(puller.Pulling.Uid, out SharedPullableComponent? pulling)) { return; } @@ -215,7 +215,7 @@ namespace Content.Shared.Pulling return false; } - if (!pulled.TryGetComponent(out SharedPullableComponent? pullable)) + if (!IoCManager.Resolve().TryGetComponent(pulled.Uid, out SharedPullableComponent? pullable)) { return false; } @@ -253,7 +253,7 @@ namespace Content.Shared.Pulling private void UpdatePulledRotation(IEntity puller, IEntity pulled) { // TODO: update once ComponentReference works with directed event bus. - if (!pulled.TryGetComponent(out RotatableComponent? rotatable)) + if (!IoCManager.Resolve().TryGetComponent(pulled.Uid, out RotatableComponent? rotatable)) return; if (!rotatable.RotateWhilePulling) diff --git a/Content.Shared/Shuttles/Components/PilotComponent.cs b/Content.Shared/Shuttles/Components/PilotComponent.cs index 30b2d71d20..7fc279f4a4 100644 --- a/Content.Shared/Shuttles/Components/PilotComponent.cs +++ b/Content.Shared/Shuttles/Components/PilotComponent.cs @@ -39,7 +39,7 @@ namespace Content.Shared.Shuttles.Components } if (!IoCManager.Resolve().TryGetEntity(state.Console.Value, out var consoleEnt) || - !consoleEnt.TryGetComponent(out SharedShuttleConsoleComponent? shuttleConsoleComponent)) + !IoCManager.Resolve().TryGetComponent(consoleEnt.Uid, out SharedShuttleConsoleComponent? shuttleConsoleComponent)) { Logger.Warning($"Unable to set Helmsman console to {state.Console.Value}"); return; diff --git a/Content.Shared/Singularity/SharedSingularitySystem.cs b/Content.Shared/Singularity/SharedSingularitySystem.cs index fcf2b71a57..6b45613c4b 100644 --- a/Content.Shared/Singularity/SharedSingularitySystem.cs +++ b/Content.Shared/Singularity/SharedSingularitySystem.cs @@ -68,12 +68,12 @@ namespace Content.Shared.Singularity singularity.Level = value; - if (singularity.Owner.TryGetComponent(out SharedRadiationPulseComponent? pulse)) + if (IoCManager.Resolve().TryGetComponent(singularity.Owner.Uid, out SharedRadiationPulseComponent? pulse)) { pulse.RadsPerSecond = 10 * value; } - if (singularity.Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(singularity.Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(SingularityVisuals.Level, value); } @@ -83,7 +83,7 @@ namespace Content.Shared.Singularity circle.Radius = value - 0.5f; } - if (singularity.Owner.TryGetComponent(out SingularityDistortionComponent? distortion)) + if (IoCManager.Resolve().TryGetComponent(singularity.Owner.Uid, out SingularityDistortionComponent? distortion)) { distortion.Falloff = GetFalloff(value); distortion.Intensity = GetIntensity(value); diff --git a/Content.Shared/Slippery/SharedSlipperySystem.cs b/Content.Shared/Slippery/SharedSlipperySystem.cs index 0f953f75ae..bc8eb075a5 100644 --- a/Content.Shared/Slippery/SharedSlipperySystem.cs +++ b/Content.Shared/Slippery/SharedSlipperySystem.cs @@ -130,7 +130,7 @@ namespace Content.Shared.Slippery continue; } - if (!entity.TryGetComponent(out PhysicsComponent? otherPhysics) || + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out PhysicsComponent? otherPhysics) || !body.GetWorldAABB().Intersects(otherPhysics.GetWorldAABB())) { component.Colliding.Remove(uid); diff --git a/Content.Shared/Storage/SharedStorageComponent.cs b/Content.Shared/Storage/SharedStorageComponent.cs index 068149d962..83e3eeef1a 100644 --- a/Content.Shared/Storage/SharedStorageComponent.cs +++ b/Content.Shared/Storage/SharedStorageComponent.cs @@ -7,6 +7,7 @@ using Content.Shared.Interaction.Events; using Content.Shared.Placeable; using Robust.Shared.GameObjects; using Robust.Shared.GameStates; +using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Serialization; @@ -28,7 +29,7 @@ namespace Content.Shared.Storage bool IDraggable.CanDrop(CanDropEvent args) { - return args.Target.TryGetComponent(out PlaceableSurfaceComponent? placeable) && + return IoCManager.Resolve().TryGetComponent(args.Target.Uid, out PlaceableSurfaceComponent? placeable) && placeable.IsPlaceable; } diff --git a/Content.Shared/Strip/Components/SharedStrippingComponent.cs b/Content.Shared/Strip/Components/SharedStrippingComponent.cs index 294f5c331f..b8e2702b36 100644 --- a/Content.Shared/Strip/Components/SharedStrippingComponent.cs +++ b/Content.Shared/Strip/Components/SharedStrippingComponent.cs @@ -1,5 +1,6 @@ using Content.Shared.DragDrop; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Shared.Strip.Components { @@ -13,7 +14,7 @@ namespace Content.Shared.Strip.Components bool IDragDropOn.CanDragDropOn(DragDropEvent eventArgs) { - if (!eventArgs.Dragged.TryGetComponent(out SharedStrippableComponent? strippable)) return false; + if (!IoCManager.Resolve().TryGetComponent(eventArgs.Dragged.Uid, out SharedStrippableComponent? strippable)) return false; return strippable.CanBeStripped(Owner); } diff --git a/Content.Shared/Tag/TagComponentExtensions.cs b/Content.Shared/Tag/TagComponentExtensions.cs index 082a160705..edf4687863 100644 --- a/Content.Shared/Tag/TagComponentExtensions.cs +++ b/Content.Shared/Tag/TagComponentExtensions.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Prototypes; namespace Content.Shared.Tag @@ -71,7 +72,7 @@ namespace Content.Shared.Tag /// public static bool TryAddTag(this IEntity entity, string id) { - return entity.TryGetComponent(out TagComponent? tagComponent) && + return IoCManager.Resolve().TryGetComponent(entity.Uid, out TagComponent? tagComponent) && tagComponent.AddTag(id); } @@ -89,7 +90,7 @@ namespace Content.Shared.Tag /// public static bool TryAddTags(this IEntity entity, params string[] ids) { - return entity.TryGetComponent(out TagComponent? tagComponent) && + return IoCManager.Resolve().TryGetComponent(entity.Uid, out TagComponent? tagComponent) && tagComponent.AddTags(ids); } @@ -107,7 +108,7 @@ namespace Content.Shared.Tag /// public static bool TryAddTags(this IEntity entity, IEnumerable ids) { - return entity.TryGetComponent(out TagComponent? tagComponent) && + return IoCManager.Resolve().TryGetComponent(entity.Uid, out TagComponent? tagComponent) && tagComponent.AddTags(ids); } @@ -122,7 +123,7 @@ namespace Content.Shared.Tag /// public static bool HasTag(this IEntity entity, string id) { - return entity.TryGetComponent(out TagComponent? tagComponent) && + return IoCManager.Resolve().TryGetComponent(entity.Uid, out TagComponent? tagComponent) && tagComponent.HasTag(id); } @@ -137,7 +138,7 @@ namespace Content.Shared.Tag /// public static bool HasAllTags(this IEntity entity, params string[] ids) { - return entity.TryGetComponent(out TagComponent? tagComponent) && + return IoCManager.Resolve().TryGetComponent(entity.Uid, out TagComponent? tagComponent) && tagComponent.HasAllTags(ids); } @@ -152,7 +153,7 @@ namespace Content.Shared.Tag /// public static bool HasAllTags(this IEntity entity, IEnumerable ids) { - return entity.TryGetComponent(out TagComponent? tagComponent) && + return IoCManager.Resolve().TryGetComponent(entity.Uid, out TagComponent? tagComponent) && tagComponent.HasAllTags(ids); } @@ -167,7 +168,7 @@ namespace Content.Shared.Tag /// public static bool HasAnyTag(this IEntity entity, params string[] ids) { - return entity.TryGetComponent(out TagComponent? tagComponent) && + return IoCManager.Resolve().TryGetComponent(entity.Uid, out TagComponent? tagComponent) && tagComponent.HasAnyTag(ids); } @@ -182,7 +183,7 @@ namespace Content.Shared.Tag /// public static bool HasAnyTag(this IEntity entity, IEnumerable ids) { - return entity.TryGetComponent(out TagComponent? tagComponent) && + return IoCManager.Resolve().TryGetComponent(entity.Uid, out TagComponent? tagComponent) && tagComponent.HasAnyTag(ids); } @@ -199,7 +200,7 @@ namespace Content.Shared.Tag /// public static bool RemoveTag(this IEntity entity, string id) { - return entity.TryGetComponent(out TagComponent? tagComponent) && + return IoCManager.Resolve().TryGetComponent(entity.Uid, out TagComponent? tagComponent) && tagComponent.RemoveTag(id); } @@ -216,7 +217,7 @@ namespace Content.Shared.Tag /// public static bool RemoveTags(this IEntity entity, params string[] ids) { - return entity.TryGetComponent(out TagComponent? tagComponent) && + return IoCManager.Resolve().TryGetComponent(entity.Uid, out TagComponent? tagComponent) && tagComponent.RemoveTags(ids); } @@ -233,7 +234,7 @@ namespace Content.Shared.Tag /// public static bool RemoveTags(this IEntity entity, IEnumerable ids) { - return entity.TryGetComponent(out TagComponent? tagComponent) && + return IoCManager.Resolve().TryGetComponent(entity.Uid, out TagComponent? tagComponent) && tagComponent.RemoveTags(ids); } } diff --git a/Content.Shared/Throwing/ThrownItemSystem.cs b/Content.Shared/Throwing/ThrownItemSystem.cs index f81c67aa52..b68ab291c5 100644 --- a/Content.Shared/Throwing/ThrownItemSystem.cs +++ b/Content.Shared/Throwing/ThrownItemSystem.cs @@ -53,7 +53,7 @@ namespace Content.Shared.Throwing private void ThrowItem(EntityUid uid, ThrownItemComponent component, ThrownEvent args) { - if (!component.Owner.TryGetComponent(out PhysicsComponent? physicsComponent) || + if (!IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out PhysicsComponent? physicsComponent) || physicsComponent.Fixtures.Count != 1) return; if (_fixtures.GetFixtureOrNull(physicsComponent, ThrowingFixture) != null) diff --git a/Content.Shared/Timing/UseDelayComponent.cs b/Content.Shared/Timing/UseDelayComponent.cs index 79793296a2..53ca67815d 100644 --- a/Content.Shared/Timing/UseDelayComponent.cs +++ b/Content.Shared/Timing/UseDelayComponent.cs @@ -46,7 +46,7 @@ namespace Content.Shared.Timing _lastUseTime = IoCManager.Resolve().CurTime; - if (Owner.TryGetComponent(out ItemCooldownComponent? cooldown)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ItemCooldownComponent? cooldown)) { cooldown.CooldownStart = _lastUseTime; cooldown.CooldownEnd = _lastUseTime + TimeSpan.FromSeconds(Delay); @@ -59,7 +59,7 @@ namespace Content.Shared.Timing cancellationTokenSource?.Cancel(); ActiveDelay = false; - if (Owner.TryGetComponent(out ItemCooldownComponent? cooldown)) + if (IoCManager.Resolve().TryGetComponent(Owner.Uid, out ItemCooldownComponent? cooldown)) { cooldown.CooldownEnd = IoCManager.Resolve().CurTime; } diff --git a/Content.Shared/Verbs/SharedVerbSystem.cs b/Content.Shared/Verbs/SharedVerbSystem.cs index a6771c4fd7..79235677f4 100644 --- a/Content.Shared/Verbs/SharedVerbSystem.cs +++ b/Content.Shared/Verbs/SharedVerbSystem.cs @@ -42,14 +42,14 @@ namespace Content.Shared.Verbs var canInteract = force || _actionBlockerSystem.CanInteract(user.Uid); IEntity? @using = null; - if (user.TryGetComponent(out SharedHandsComponent? hands) && (force || _actionBlockerSystem.CanUse(user.Uid))) + if (IoCManager.Resolve().TryGetComponent(user.Uid, out SharedHandsComponent? hands) && (force || _actionBlockerSystem.CanUse(user.Uid))) { hands.TryGetActiveHeldEntity(out @using); // Check whether the "Held" entity is a virtual pull entity. If yes, set that as the entity being "Used". // This allows you to do things like buckle a dragged person onto a surgery table, without click-dragging // their sprite. - if (@using != null && @using.TryGetComponent(out var pull)) + if (@using != null && IoCManager.Resolve().TryGetComponent(@using.Uid, out var pull)) { @using = IoCManager.Resolve().GetEntity(pull.BlockingEntity); }