diff --git a/Content.Client/Body/UI/BodyScannerDisplay.cs b/Content.Client/Body/UI/BodyScannerDisplay.cs index 497e00708b..f7684c71f9 100644 --- a/Content.Client/Body/UI/BodyScannerDisplay.cs +++ b/Content.Client/Body/UI/BodyScannerDisplay.cs @@ -146,7 +146,7 @@ namespace Content.Client.Body.UI BodyPartLabel.Text = $"{Loc.GetString(slotName)}: {Loc.GetString(part.Owner.Name)}"; // TODO BODY Part damage - if (part.Owner.TryGetComponent(out DamageableComponent? damageable)) + if (IoCManager.Resolve().TryGetComponent(part.Owner.Uid, out DamageableComponent? damageable)) { BodyPartHealth.Text = Loc.GetString("body-scanner-display-body-part-damage-text",("damage", damageable.TotalDamage)); } diff --git a/Content.Client/Fluids/PuddleVisualizer.cs b/Content.Client/Fluids/PuddleVisualizer.cs index f6724e406f..560e56d1f7 100644 --- a/Content.Client/Fluids/PuddleVisualizer.cs +++ b/Content.Client/Fluids/PuddleVisualizer.cs @@ -25,7 +25,7 @@ namespace Content.Client.Fluids { base.InitializeEntity(entity); - if (!entity.TryGetComponent(out SpriteComponent? spriteComponent)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out SpriteComponent? spriteComponent)) { Logger.Warning($"Missing SpriteComponent for PuddleVisualizer on entityUid = {entity.Uid}"); return; @@ -69,5 +69,5 @@ namespace Content.Client.Fluids spriteComponent.Color = newColor; } } - -} \ No newline at end of file + +} diff --git a/Content.Client/Storage/ClientStorageComponent.cs b/Content.Client/Storage/ClientStorageComponent.cs index f6572880ac..ed51af412e 100644 --- a/Content.Client/Storage/ClientStorageComponent.cs +++ b/Content.Client/Storage/ClientStorageComponent.cs @@ -181,8 +181,8 @@ namespace Content.Client.Storage if (!IoCManager.Resolve().TryGetEntity(entityUid, out var entity)) return; - entity.TryGetComponent(out ISpriteComponent? sprite); - entity.TryGetComponent(out ItemComponent? item); + IoCManager.Resolve().TryGetComponent(entity.Uid, out ISpriteComponent? sprite); + IoCManager.Resolve().TryGetComponent(entity.Uid, out ItemComponent? item); button.AddChild(new BoxContainer { @@ -252,7 +252,7 @@ namespace Content.Client.Storage { var controlledEntity = IoCManager.Resolve().LocalPlayer?.ControlledEntity; - if (controlledEntity != null && controlledEntity.TryGetComponent(out HandsComponent? hands)) + if (controlledEntity != null && IoCManager.Resolve().TryGetComponent(controlledEntity.Uid, out HandsComponent? hands)) { #pragma warning disable 618 StorageEntity.SendNetworkMessage(new InsertEntityMessage()); diff --git a/Content.Client/Storage/Visualizers/MappedItemVisualizer.cs b/Content.Client/Storage/Visualizers/MappedItemVisualizer.cs index d1d3c88714..53d81ce757 100644 --- a/Content.Client/Storage/Visualizers/MappedItemVisualizer.cs +++ b/Content.Client/Storage/Visualizers/MappedItemVisualizer.cs @@ -4,6 +4,7 @@ using Content.Shared.Storage.Components; 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; @@ -19,7 +20,7 @@ namespace Content.Client.Storage.Visualizers { base.InitializeEntity(entity); - if (entity.TryGetComponent(out var spriteComponent)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out var spriteComponent)) { _rsiPath ??= spriteComponent.BaseRSI!.Path!; } diff --git a/Content.Client/Storage/Visualizers/StorageVisualizer.cs b/Content.Client/Storage/Visualizers/StorageVisualizer.cs index 43a8df5684..7cc3f4111e 100644 --- a/Content.Client/Storage/Visualizers/StorageVisualizer.cs +++ b/Content.Client/Storage/Visualizers/StorageVisualizer.cs @@ -2,6 +2,7 @@ using Content.Shared.Storage; using JetBrains.Annotations; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Client.Storage.Visualizers @@ -18,7 +19,7 @@ namespace Content.Client.Storage.Visualizers public override void InitializeEntity(IEntity entity) { - if (!entity.TryGetComponent(out ISpriteComponent? sprite)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out ISpriteComponent? sprite)) { return; } diff --git a/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs b/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs index c4f5e010a0..ae36255dfa 100644 --- a/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs +++ b/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs @@ -78,7 +78,7 @@ namespace Content.IntegrationTests.Tests.Buckle chair = entityManager.SpawnEntity(StrapDummyId, coordinates); // Default state, unbuckled - Assert.True(human.TryGetComponent(out buckle)); + Assert.True(IoCManager.Resolve().TryGetComponent(human.Uid, out buckle)); Assert.NotNull(buckle); Assert.Null(buckle.BuckledTo); Assert.False(buckle.Buckled); @@ -88,7 +88,7 @@ namespace Content.IntegrationTests.Tests.Buckle Assert.True(standingState.Stand(human.Uid)); // Default state, no buckled entities, strap - Assert.True(chair.TryGetComponent(out strap)); + Assert.True(IoCManager.Resolve().TryGetComponent(chair.Uid, out strap)); Assert.NotNull(strap); Assert.IsEmpty(strap.BuckledEntities); Assert.Zero(strap.OccupiedSize); @@ -239,10 +239,10 @@ namespace Content.IntegrationTests.Tests.Buckle IEntity chair = entityManager.SpawnEntity(StrapDummyId, coordinates); // Component sanity check - Assert.True(human.TryGetComponent(out buckle)); + Assert.True(IoCManager.Resolve().TryGetComponent(human.Uid, out buckle)); Assert.True(IoCManager.Resolve().HasComponent(chair.Uid)); - Assert.True(human.TryGetComponent(out hands)); - Assert.True(human.TryGetComponent(out body)); + Assert.True(IoCManager.Resolve().TryGetComponent(human.Uid, out hands)); + Assert.True(IoCManager.Resolve().TryGetComponent(human.Uid, out body)); // Buckle Assert.True(buckle.TryBuckle(human, chair)); @@ -255,7 +255,7 @@ namespace Content.IntegrationTests.Tests.Buckle var akms = entityManager.SpawnEntity(ItemDummyId, coordinates); // Equip items - Assert.True(akms.TryGetComponent(out ItemComponent item)); + Assert.True(IoCManager.Resolve().TryGetComponent(akms.Uid, out ItemComponent item)); Assert.True(hands.PutInHand(item)); } }); @@ -324,7 +324,7 @@ namespace Content.IntegrationTests.Tests.Buckle chair = entityManager.SpawnEntity(StrapDummyId, coordinates); // Component sanity check - Assert.True(human.TryGetComponent(out buckle)); + Assert.True(IoCManager.Resolve().TryGetComponent(human.Uid, out buckle)); Assert.True(IoCManager.Resolve().HasComponent(chair.Uid)); // Buckle diff --git a/Content.IntegrationTests/Tests/Commands/RejuvenateTest.cs b/Content.IntegrationTests/Tests/Commands/RejuvenateTest.cs index bd72d5f8b4..7515a906c8 100644 --- a/Content.IntegrationTests/Tests/Commands/RejuvenateTest.cs +++ b/Content.IntegrationTests/Tests/Commands/RejuvenateTest.cs @@ -48,8 +48,8 @@ namespace Content.IntegrationTests.Tests.Commands var human = entityManager.SpawnEntity("DamageableDummy", MapCoordinates.Nullspace); // Sanity check - Assert.True(human.TryGetComponent(out DamageableComponent damageable)); - Assert.True(human.TryGetComponent(out MobStateComponent mobState)); + Assert.True(IoCManager.Resolve().TryGetComponent(human.Uid, out DamageableComponent damageable)); + Assert.True(IoCManager.Resolve().TryGetComponent(human.Uid, out MobStateComponent mobState)); mobState.UpdateState(0); Assert.That(mobState.IsAlive, Is.True); Assert.That(mobState.IsCritical, Is.False); diff --git a/Content.Server/AI/Utility/UtilityAiHelpers.cs b/Content.Server/AI/Utility/UtilityAiHelpers.cs index a1765b9390..3243bca6e3 100644 --- a/Content.Server/AI/Utility/UtilityAiHelpers.cs +++ b/Content.Server/AI/Utility/UtilityAiHelpers.cs @@ -2,6 +2,7 @@ using Content.Server.AI.Components; using Content.Server.AI.Utility.AiLogic; using Content.Server.AI.WorldState; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Utility { @@ -9,7 +10,7 @@ namespace Content.Server.AI.Utility { public static Blackboard? GetBlackboard(IEntity entity) { - if (!entity.TryGetComponent(out AiControllerComponent? aiControllerComponent)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out AiControllerComponent? aiControllerComponent)) { return null; } diff --git a/Content.Server/Actions/Actions/PAIMidi.cs b/Content.Server/Actions/Actions/PAIMidi.cs index 717c8a3f42..10d5aa516a 100644 --- a/Content.Server/Actions/Actions/PAIMidi.cs +++ b/Content.Server/Actions/Actions/PAIMidi.cs @@ -23,8 +23,8 @@ namespace Content.Server.Actions.Actions public void DoInstantAction(InstantActionEventArgs args) { - if (!args.Performer.TryGetComponent(out var serverUi)) return; - if (!args.Performer.TryGetComponent(out var actor)) return; + if (!IoCManager.Resolve().TryGetComponent(args.Performer.Uid, out var serverUi)) return; + if (!IoCManager.Resolve().TryGetComponent(args.Performer.Uid, out var actor)) return; if (!serverUi.TryGetBoundUserInterface(InstrumentUiKey.Key,out var bui)) return; bui.Toggle(actor.PlayerSession); diff --git a/Content.Server/Actions/Commands/CooldownAction.cs b/Content.Server/Actions/Commands/CooldownAction.cs index b4eeca63ea..04d0c9b7f2 100644 --- a/Content.Server/Actions/Commands/CooldownAction.cs +++ b/Content.Server/Actions/Commands/CooldownAction.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; using Robust.Shared.Timing; @@ -29,7 +30,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/Alert/Click/RemoveCuffs.cs b/Content.Server/Alert/Click/RemoveCuffs.cs index 6ef8fd87c4..6f163f77d9 100644 --- a/Content.Server/Alert/Click/RemoveCuffs.cs +++ b/Content.Server/Alert/Click/RemoveCuffs.cs @@ -1,6 +1,8 @@ using Content.Server.Cuffs.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 CuffableComponent? cuffableComponent)) + if (IoCManager.Resolve().TryGetComponent(args.Player.Uid, out CuffableComponent? cuffableComponent)) { cuffableComponent.TryUncuff(args.Player); } diff --git a/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs b/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs index b3b82cc276..14e5b8e001 100644 --- a/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs +++ b/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs @@ -74,7 +74,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/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs index 527f11e676..470e083ed5 100644 --- a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs +++ b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs @@ -97,7 +97,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems private void OnPumpInteractHand(EntityUid uid, GasVolumePumpComponent 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/Body/Components/BodyScannerComponent.cs b/Content.Server/Body/Components/BodyScannerComponent.cs index bd17d36887..ca19f0a55a 100644 --- a/Content.Server/Body/Components/BodyScannerComponent.cs +++ b/Content.Server/Body/Components/BodyScannerComponent.cs @@ -3,6 +3,7 @@ using Content.Shared.Body.Components; using Content.Shared.Interaction; using Robust.Server.GameObjects; 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 void IActivate.Activate(ActivateEventArgs eventArgs) { - if (!eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if (!IoCManager.Resolve().TryGetComponent(eventArgs.User.Uid, out ActorComponent? actor)) { return; } @@ -28,7 +29,7 @@ namespace Content.Server.Body.Components return; } - if (session.AttachedEntity.TryGetComponent(out SharedBodyComponent? body)) + if (IoCManager.Resolve().TryGetComponent(session.AttachedEntity.Uid, out SharedBodyComponent? body)) { var state = InterfaceState(body); UserInterface?.SetState(state); diff --git a/Content.Server/Buckle/Systems/BuckleSystem.cs b/Content.Server/Buckle/Systems/BuckleSystem.cs index 4337bdd9ad..5dfa21fbc5 100644 --- a/Content.Server/Buckle/Systems/BuckleSystem.cs +++ b/Content.Server/Buckle/Systems/BuckleSystem.cs @@ -7,6 +7,7 @@ using JetBrains.Annotations; using Robust.Server.GameObjects; using Robust.Shared.Containers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; namespace Content.Server.Buckle.Systems @@ -40,7 +41,7 @@ namespace Content.Server.Buckle.Systems { if (!args.CanAccess || !args.CanInteract || !component.Buckled) return; - + Verb verb = new(); verb.Act = () => component.TryUnbuckle(args.User); verb.Text = Loc.GetString("verb-categories-unbuckle"); @@ -94,7 +95,7 @@ namespace Content.Server.Buckle.Systems // This fixes buckle offsets and draw depths. foreach (var buckledEntity in strap.BuckledEntities) { - if (!buckledEntity.TryGetComponent(out BuckleComponent? buckled)) + if (!IoCManager.Resolve().TryGetComponent(buckledEntity.Uid, out BuckleComponent? buckled)) { continue; } @@ -111,7 +112,7 @@ namespace Content.Server.Buckle.Systems { foreach (var buckledEntity in strap.BuckledEntities) { - if (!buckledEntity.TryGetComponent(out BuckleComponent? buckled)) + if (!IoCManager.Resolve().TryGetComponent(buckledEntity.Uid, out BuckleComponent? buckled)) { continue; } diff --git a/Content.Server/Chemistry/EntitySystems/SolutionTransferSystem.cs b/Content.Server/Chemistry/EntitySystems/SolutionTransferSystem.cs index 6be2c98c69..2b4d008aff 100644 --- a/Content.Server/Chemistry/EntitySystems/SolutionTransferSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/SolutionTransferSystem.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using Content.Shared.Chemistry.Reagent; using Content.Shared.FixedPoint; using Content.Shared.Popups; +using Robust.Shared.IoC; namespace Content.Server.Chemistry.EntitySystems { @@ -31,9 +32,9 @@ namespace Content.Server.Chemistry.EntitySystems if (!args.CanAccess || !args.CanInteract || !component.CanChangeTransferAmount) return; - if (!args.User.TryGetComponent(out var actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out var actor)) return; - + // Custom transfer verb Verb custom = new(); custom.Text = Loc.GetString("comp-solution-transfer-verb-custom-amount"); @@ -61,7 +62,7 @@ namespace Content.Server.Chemistry.EntitySystems // we want to sort by size, not alphabetically by the verb text. verb.Priority = priority; priority--; - + args.Verbs.Add(verb); } } diff --git a/Content.Server/Cloning/CloningSystem.cs b/Content.Server/Cloning/CloningSystem.cs index 8da8695dd9..4e4d5a15cc 100644 --- a/Content.Server/Cloning/CloningSystem.cs +++ b/Content.Server/Cloning/CloningSystem.cs @@ -36,7 +36,7 @@ namespace Content.Server.Cloning { if (!ClonesWaitingForMind.TryGetValue(mind, out var entityUid) || !EntityManager.TryGetEntity(entityUid, out var entity) || - !entity.TryGetComponent(out MindComponent? mindComp) || + !IoCManager.Resolve().TryGetComponent(entity.Uid, out MindComponent? mindComp) || mindComp.Mind != null) return; @@ -48,7 +48,7 @@ namespace Content.Server.Cloning private void HandleActivate(EntityUid uid, CloningPodComponent component, ActivateInWorldEvent args) { if (!component.Powered || - !args.User.TryGetComponent(out ActorComponent? actor)) + !IoCManager.Resolve().TryGetComponent(args.User.Uid, out ActorComponent? actor)) { return; } @@ -60,7 +60,7 @@ namespace Content.Server.Cloning { if (component.Parent == EntityUid.Invalid || !EntityManager.TryGetEntity(component.Parent, out var parent) || - !parent.TryGetComponent(out var cloningPodComponent) || + !IoCManager.Resolve().TryGetComponent(parent.Uid, out var cloningPodComponent) || component.Owner != cloningPodComponent.BodyContainer?.ContainedEntity) { IoCManager.Resolve().RemoveComponent(component.Owner.Uid); diff --git a/Content.Server/Cuffs/CuffableSystem.cs b/Content.Server/Cuffs/CuffableSystem.cs index aaced49f5b..11db2b62d0 100644 --- a/Content.Server/Cuffs/CuffableSystem.cs +++ b/Content.Server/Cuffs/CuffableSystem.cs @@ -66,7 +66,7 @@ namespace Content.Server.Cuffs if (args.User == args.Target) { // This UncuffAttemptEvent check should probably be In MobStateSystem, not here? - if (userEntity.TryGetComponent(out var state)) + if (IoCManager.Resolve().TryGetComponent(userEntity.Uid, out var state)) { // Manually check this. if (state.IsIncapacitated()) @@ -101,7 +101,7 @@ namespace Content.Server.Cuffs { var owner = message.Sender; - if (!owner.TryGetComponent(out CuffableComponent? cuffable) || + if (!IoCManager.Resolve().TryGetComponent(owner.Uid, out CuffableComponent? cuffable) || !cuffable.Initialized) return; var dirty = false; diff --git a/Content.Server/Disposal/Tube/DisposalTubeSystem.cs b/Content.Server/Disposal/Tube/DisposalTubeSystem.cs index 8feae7c746..0c6c8ce28f 100644 --- a/Content.Server/Disposal/Tube/DisposalTubeSystem.cs +++ b/Content.Server/Disposal/Tube/DisposalTubeSystem.cs @@ -28,13 +28,13 @@ namespace Content.Server.Disposal.Tube SubscribeLocalEvent(AddOpenUIVerbs); SubscribeLocalEvent(AddOpenUIVerbs); } - + private void AddOpenUIVerbs(EntityUid uid, DisposalTaggerComponent component, GetInteractionVerbsEvent args) { if (!args.CanAccess || !args.CanInteract) return; - if (!args.User.TryGetComponent(out var actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out var actor)) return; var player = actor.PlayerSession; @@ -42,7 +42,7 @@ namespace Content.Server.Disposal.Tube verb.Text = Loc.GetString("configure-verb-get-data-text"); verb.IconTexture = "/Textures/Interface/VerbIcons/settings.svg.192dpi.png"; verb.Act = () => component.OpenUserInterface(actor); - args.Verbs.Add(verb); + args.Verbs.Add(verb); } private void AddOpenUIVerbs(EntityUid uid, DisposalRouterComponent component, GetInteractionVerbsEvent args) @@ -50,7 +50,7 @@ namespace Content.Server.Disposal.Tube if (!args.CanAccess || !args.CanInteract) return; - if (!args.User.TryGetComponent(out var actor)) + if (!IoCManager.Resolve().TryGetComponent(args.User.Uid, out var actor)) return; var player = actor.PlayerSession; diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs index c596e61e5f..1baf67953e 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs @@ -1,5 +1,5 @@ using System.Linq; -using Content.Server.Atmos; + using Content.Server.Atmos; using Content.Server.Atmos.EntitySystems; using Content.Server.Disposal.Tube.Components; using Content.Server.Disposal.Tube; diff --git a/Content.Server/Fluids/Components/MopComponent.cs b/Content.Server/Fluids/Components/MopComponent.cs index 19e2cc80b9..fd326e7574 100644 --- a/Content.Server/Fluids/Components/MopComponent.cs +++ b/Content.Server/Fluids/Components/MopComponent.cs @@ -111,7 +111,7 @@ namespace Content.Server.Fluids.Components return true; } - if (!eventArgs.Target.TryGetComponent(out PuddleComponent? puddleComponent) || + if (!IoCManager.Resolve().TryGetComponent(eventArgs.Target.Uid, out PuddleComponent? puddleComponent) || !solutionSystem.TryGetSolution(puddleComponent.OwnerUid, puddleComponent.SolutionName, out var puddleSolution)) return false; @@ -141,7 +141,7 @@ namespace Content.Server.Fluids.Components transferAmount = FixedPoint2.Min(PickupAmount, puddleSolution.TotalVolume, CurrentVolume); // is the puddle cleaned? - if (puddleSolution.TotalVolume - transferAmount <= 0) + if (puddleSolution.TotalVolume - transferAmount <= 0) { IoCManager.Resolve().DeleteEntity(puddleComponent.Owner.Uid); diff --git a/Content.Server/GameTicking/GameTicker.Spawning.cs b/Content.Server/GameTicking/GameTicker.Spawning.cs index 24234f8d77..158b8419c9 100644 --- a/Content.Server/GameTicking/GameTicker.Spawning.cs +++ b/Content.Server/GameTicking/GameTicker.Spawning.cs @@ -230,7 +230,7 @@ namespace Content.Server.GameTicking #region Equip Helpers public void EquipStartingGear(IEntity entity, StartingGearPrototype startingGear, HumanoidCharacterProfile? profile) { - if (entity.TryGetComponent(out InventoryComponent? inventory)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out InventoryComponent? inventory)) { foreach (var slot in EquipmentSlotDefines.AllSlots) { @@ -243,7 +243,7 @@ namespace Content.Server.GameTicking } } - if (entity.TryGetComponent(out HandsComponent? handsComponent)) + if (IoCManager.Resolve().TryGetComponent(entity.Uid, out HandsComponent? handsComponent)) { var inhand = startingGear.Inhand; foreach (var (hand, prototype) in inhand) @@ -256,7 +256,7 @@ namespace Content.Server.GameTicking public void EquipIdCard(IEntity entity, string characterName, JobPrototype jobPrototype) { - if (!entity.TryGetComponent(out InventoryComponent? inventory)) + if (!IoCManager.Resolve().TryGetComponent(entity.Uid, out InventoryComponent? inventory)) return; if (!inventory.TryGetSlotItem(EquipmentSlotDefines.Slots.IDCARD, out ItemComponent? item)) @@ -266,7 +266,7 @@ namespace Content.Server.GameTicking var itemEntity = item.Owner; - if (!itemEntity.TryGetComponent(out PDAComponent? pdaComponent) || pdaComponent.ContainedID == null) + if (!IoCManager.Resolve().TryGetComponent(itemEntity.Uid, out PDAComponent? pdaComponent) || pdaComponent.ContainedID == null) return; var card = pdaComponent.ContainedID; diff --git a/Content.Server/Interaction/Components/ClumsyComponent.cs b/Content.Server/Interaction/Components/ClumsyComponent.cs index bba250447d..bbf753b6b6 100644 --- a/Content.Server/Interaction/Components/ClumsyComponent.cs +++ b/Content.Server/Interaction/Components/ClumsyComponent.cs @@ -30,7 +30,7 @@ namespace Content.Server.Interaction.Components /// True if a "bad action" happened, false if the normal action should happen. public static bool TryRollClumsy(IEntity entity, float chance) { - return entity.TryGetComponent(out ClumsyComponent? clumsy) + return IoCManager.Resolve().TryGetComponent(entity.Uid, out ClumsyComponent? clumsy) && clumsy.RollClumsy(chance); } } diff --git a/Content.Server/Light/EntitySystems/UnpoweredFlashlightSystem.cs b/Content.Server/Light/EntitySystems/UnpoweredFlashlightSystem.cs index 642676ea41..f018a40bd4 100644 --- a/Content.Server/Light/EntitySystems/UnpoweredFlashlightSystem.cs +++ b/Content.Server/Light/EntitySystems/UnpoweredFlashlightSystem.cs @@ -8,6 +8,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.Localization; using Robust.Shared.Player; using System; +using Robust.Shared.IoC; namespace Content.Server.Light.EntitySystems { @@ -36,13 +37,13 @@ namespace Content.Server.Light.EntitySystems public void ToggleLight(UnpoweredFlashlightComponent flashlight) { - if (!flashlight.Owner.TryGetComponent(out PointLightComponent? light)) + if (!IoCManager.Resolve().TryGetComponent(flashlight.Owner.Uid, out PointLightComponent? light)) return; flashlight.LightOn = !flashlight.LightOn; light.Enabled = flashlight.LightOn; - if (flashlight.Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(flashlight.Owner.Uid, out AppearanceComponent? appearance)) appearance.SetData(UnpoweredFlashlightVisuals.LightOn, flashlight.LightOn); SoundSystem.Play(Filter.Pvs(light.Owner), flashlight.ToggleSound.GetSound(), flashlight.Owner); diff --git a/Content.Server/Lock/LockSystem.cs b/Content.Server/Lock/LockSystem.cs index 13adfb1466..37ff61597a 100644 --- a/Content.Server/Lock/LockSystem.cs +++ b/Content.Server/Lock/LockSystem.cs @@ -35,7 +35,7 @@ namespace Content.Server.Lock private void OnStartup(EntityUid uid, LockComponent lockComp, ComponentStartup args) { - if (lockComp.Owner.TryGetComponent(out AppearanceComponent? appearance)) + if (IoCManager.Resolve().TryGetComponent(lockComp.Owner.Uid, out AppearanceComponent? appearance)) { appearance.SetData(StorageVisuals.CanLock, true); } @@ -71,22 +71,22 @@ namespace Content.Server.Lock { if (!Resolve(uid, ref lockComp)) return false; - + if (!CanToggleLock(uid, user, quiet: false)) return false; - + if (!HasUserAccess(uid, user, quiet: false)) return false; lockComp.Owner.PopupMessage(user, Loc.GetString("lock-comp-do-lock-success", ("entityName",lockComp.Owner.Name))); lockComp.Locked = true; - + if(lockComp.LockSound != null) { SoundSystem.Play(Filter.Pvs(lockComp.Owner), lockComp.LockSound.GetSound(), lockComp.Owner, AudioParams.Default.WithVolume(-5)); } - if (lockComp.Owner.TryGetComponent(out AppearanceComponent? appearanceComp)) + if (IoCManager.Resolve().TryGetComponent(lockComp.Owner.Uid, out AppearanceComponent? appearanceComp)) { appearanceComp.SetData(StorageVisuals.Locked, true); } @@ -100,22 +100,22 @@ namespace Content.Server.Lock { if (!Resolve(uid, ref lockComp)) return false; - + if (!CanToggleLock(uid, user, quiet: false)) return false; - + if (!HasUserAccess(uid, user, quiet: false)) return false; lockComp.Owner.PopupMessage(user, Loc.GetString("lock-comp-do-unlock-success", ("entityName", lockComp.Owner.Name))); lockComp.Locked = false; - + if(lockComp.UnlockSound != null) { SoundSystem.Play(Filter.Pvs(lockComp.Owner), lockComp.UnlockSound.GetSound(), lockComp.Owner, AudioParams.Default.WithVolume(-5)); } - if (lockComp.Owner.TryGetComponent(out AppearanceComponent? appearanceComp)) + if (IoCManager.Resolve().TryGetComponent(lockComp.Owner.Uid, out AppearanceComponent? appearanceComp)) { appearanceComp.SetData(StorageVisuals.Locked, false); } diff --git a/Content.Server/Morgue/Components/MorgueTrayComponent.cs b/Content.Server/Morgue/Components/MorgueTrayComponent.cs index 18143453ef..c9510df4d2 100644 --- a/Content.Server/Morgue/Components/MorgueTrayComponent.cs +++ b/Content.Server/Morgue/Components/MorgueTrayComponent.cs @@ -16,7 +16,7 @@ namespace Content.Server.Morgue.Components void IActivate.Activate(ActivateEventArgs eventArgs) { - if (Morgue != null && !((!IoCManager.Resolve().EntityExists(Morgue.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Morgue.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) && Morgue.TryGetComponent(out var comp)) + if (Morgue != null && !((!IoCManager.Resolve().EntityExists(Morgue.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Morgue.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) && IoCManager.Resolve().TryGetComponent(Morgue.Uid, out var comp)) { comp.Activate(new ActivateEventArgs(eventArgs.User, Morgue)); } diff --git a/Content.Server/Research/Components/ResearchClientComponent.cs b/Content.Server/Research/Components/ResearchClientComponent.cs index cad05ed8f2..a852a05876 100644 --- a/Content.Server/Research/Components/ResearchClientComponent.cs +++ b/Content.Server/Research/Components/ResearchClientComponent.cs @@ -57,7 +57,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; OpenUserInterface(actor.PlayerSession); diff --git a/Content.Server/Tabletop/TabletopSystem.Draggable.cs b/Content.Server/Tabletop/TabletopSystem.Draggable.cs index d5267bac15..3410b8b3c2 100644 --- a/Content.Server/Tabletop/TabletopSystem.Draggable.cs +++ b/Content.Server/Tabletop/TabletopSystem.Draggable.cs @@ -4,6 +4,7 @@ using Content.Shared.Tabletop.Events; using Robust.Server.Player; using Robust.Shared.GameObjects; using Robust.Shared.GameStates; +using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; using DrawDepth = Content.Shared.DrawDepth.DrawDepth; @@ -60,11 +61,11 @@ namespace Content.Server.Tabletop { var draggedEntity = EntityManager.GetEntity(msg.DraggedEntityUid); - if (!draggedEntity.TryGetComponent(out var draggableComponent)) return; + if (!IoCManager.Resolve().TryGetComponent(draggedEntity.Uid, out var draggableComponent)) return; draggableComponent.DraggingPlayer = msg.DraggingPlayer; - if (!draggedEntity.TryGetComponent(out var appearance)) return; + if (!IoCManager.Resolve().TryGetComponent(draggedEntity.Uid, out var appearance)) return; if (draggableComponent.DraggingPlayer != null) { diff --git a/Content.Server/Tools/ToolSystem.Welder.cs b/Content.Server/Tools/ToolSystem.Welder.cs index 503d2c21d8..d4552a0fad 100644 --- a/Content.Server/Tools/ToolSystem.Welder.cs +++ b/Content.Server/Tools/ToolSystem.Welder.cs @@ -17,6 +17,7 @@ using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.GameStates; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Player; @@ -209,7 +210,7 @@ namespace Content.Server.Tools // TODO: Clean up this inherited oldcode. - if (args.Target.TryGetComponent(out ReagentTankComponent? tank) + if (IoCManager.Resolve().TryGetComponent(args.Target.Uid, out ReagentTankComponent? tank) && tank.TankType == ReagentTankType.Fuel && _solutionContainerSystem.TryGetDrainableSolution(args.Target.Uid, out var targetSolution) && _solutionContainerSystem.TryGetSolution(uid, welder.FuelSolution, out var welderSolution)) diff --git a/Content.Server/UserInterface/ActivatableUISystem.cs b/Content.Server/UserInterface/ActivatableUISystem.cs index 0649769802..e6e2bfdb13 100644 --- a/Content.Server/UserInterface/ActivatableUISystem.cs +++ b/Content.Server/UserInterface/ActivatableUISystem.cs @@ -67,7 +67,7 @@ namespace Content.Server.UserInterface private bool InteractUI(IEntity user, ActivatableUIComponent aui) { - if (!user.TryGetComponent(out ActorComponent? actor)) return false; + if (!IoCManager.Resolve().TryGetComponent(user.Uid, out ActorComponent? actor)) return false; if (aui.AdminOnly && !_adminManager.IsAdmin(actor.PlayerSession)) return false; diff --git a/Content.Shared/Lathe/SharedLatheComponent.cs b/Content.Shared/Lathe/SharedLatheComponent.cs index ee1dc79546..55ccabe92e 100644 --- a/Content.Shared/Lathe/SharedLatheComponent.cs +++ b/Content.Shared/Lathe/SharedLatheComponent.cs @@ -18,8 +18,8 @@ namespace Content.Shared.Lathe public bool CanProduce(LatheRecipePrototype recipe, int quantity = 1) { - if (!Owner.TryGetComponent(out SharedMaterialStorageComponent? storage) - || !Owner.TryGetComponent(out SharedLatheDatabaseComponent? database)) return false; + if (!IoCManager.Resolve().TryGetComponent(Owner.Uid, out SharedMaterialStorageComponent? storage) + || !IoCManager.Resolve().TryGetComponent(Owner.Uid, out SharedLatheDatabaseComponent? database)) return false; if (!database.Contains(recipe)) return false; diff --git a/Content.Shared/Movement/EntitySystems/SharedMoverSystem.cs b/Content.Shared/Movement/EntitySystems/SharedMoverSystem.cs index 2accfda950..95f2d03ada 100644 --- a/Content.Shared/Movement/EntitySystems/SharedMoverSystem.cs +++ b/Content.Shared/Movement/EntitySystems/SharedMoverSystem.cs @@ -54,7 +54,7 @@ namespace Content.Shared.Movement.EntitySystems // For stuff like "Moving out of locker" or the likes if (owner.IsInContainer() && - (!owner.TryGetComponent(out MobStateComponent? mobState) || + (!IoCManager.Resolve().TryGetComponent(owner.Uid, out MobStateComponent? mobState) || mobState.IsAlive())) { var relayMoveEvent = new RelayMovementEntityEvent(owner); @@ -85,7 +85,7 @@ namespace Content.Shared.Movement.EntitySystems if (ent == null || !IoCManager.Resolve().EntityExists(ent.Uid)) return false; - if (!ent.TryGetComponent(out T? comp)) + if (!IoCManager.Resolve().TryGetComponent(ent.Uid, out T? comp)) return false; component = comp; diff --git a/Content.Shared/Storage/EntitySystems/SharedItemCounterSystem.cs b/Content.Shared/Storage/EntitySystems/SharedItemCounterSystem.cs index 018962581e..a481fe7fd5 100644 --- a/Content.Shared/Storage/EntitySystems/SharedItemCounterSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SharedItemCounterSystem.cs @@ -3,6 +3,7 @@ using Content.Shared.Storage.Components; using JetBrains.Annotations; using Robust.Shared.Containers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Shared.Storage.EntitySystems { @@ -20,32 +21,32 @@ namespace Content.Shared.Storage.EntitySystems private void CounterEntityInserted(EntityUid uid, ItemCounterComponent itemCounter, EntInsertedIntoContainerMessage args) { - if (!itemCounter.Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)) return; - + if (!IoCManager.Resolve().TryGetComponent(itemCounter.Owner.Uid, out AppearanceComponent? appearanceComponent)) return; + var count = GetCount(args, itemCounter); if (count == null) return; - + appearanceComponent.SetData(StackVisuals.Actual, count); if (itemCounter.MaxAmount != null) appearanceComponent.SetData(StackVisuals.MaxCount, itemCounter.MaxAmount); - + } private void CounterEntityRemoved(EntityUid uid, ItemCounterComponent itemCounter, EntRemovedFromContainerMessage args) { - if (!itemCounter.Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)) return; - + if (!IoCManager.Resolve().TryGetComponent(itemCounter.Owner.Uid, out AppearanceComponent? appearanceComponent)) return; + var count = GetCount(args, itemCounter); if (count == null) return; - + appearanceComponent.SetData(StackVisuals.Actual, count); if (itemCounter.MaxAmount != null) appearanceComponent.SetData(StackVisuals.MaxCount, itemCounter.MaxAmount); } - + protected abstract int? GetCount(ContainerModifiedMessage msg, ItemCounterComponent itemCounter); } -} \ No newline at end of file +} diff --git a/Content.Shared/Storage/EntitySystems/SharedItemMapperSystem.cs b/Content.Shared/Storage/EntitySystems/SharedItemMapperSystem.cs index 9609387567..b8a4836c1d 100644 --- a/Content.Shared/Storage/EntitySystems/SharedItemMapperSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SharedItemMapperSystem.cs @@ -3,6 +3,7 @@ using Content.Shared.Storage.Components; using JetBrains.Annotations; using Robust.Shared.Containers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Shared.Storage.EntitySystems { @@ -20,7 +21,7 @@ namespace Content.Shared.Storage.EntitySystems private void InitLayers(EntityUid uid, ItemMapperComponent component, ComponentInit args) { - if (component.Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)) + if (IoCManager.Resolve().TryGetComponent(component.Owner.Uid, out AppearanceComponent? appearanceComponent)) { var list = new List(component.MapLayers.Keys); appearanceComponent.SetData(StorageMapVisuals.InitLayers, new ShowLayerData(list)); @@ -30,7 +31,7 @@ namespace Content.Shared.Storage.EntitySystems private void MapperEntityRemoved(EntityUid uid, ItemMapperComponent itemMapper, EntRemovedFromContainerMessage args) { - if (itemMapper.Owner.TryGetComponent(out AppearanceComponent? appearanceComponent) + if (IoCManager.Resolve().TryGetComponent(itemMapper.Owner.Uid, out AppearanceComponent? appearanceComponent) && TryGetLayers(args, itemMapper, out var containedLayers)) { appearanceComponent.SetData(StorageMapVisuals.LayerChanged, new ShowLayerData(containedLayers)); @@ -40,7 +41,7 @@ namespace Content.Shared.Storage.EntitySystems private void MapperEntityInserted(EntityUid uid, ItemMapperComponent itemMapper, EntInsertedIntoContainerMessage args) { - if (itemMapper.Owner.TryGetComponent(out AppearanceComponent? appearanceComponent) + if (IoCManager.Resolve().TryGetComponent(itemMapper.Owner.Uid, out AppearanceComponent? appearanceComponent) && TryGetLayers(args, itemMapper, out var containedLayers)) { appearanceComponent.SetData(StorageMapVisuals.LayerChanged, new ShowLayerData(containedLayers)); @@ -51,4 +52,4 @@ namespace Content.Shared.Storage.EntitySystems ItemMapperComponent itemMapper, out IReadOnlyList containedLayers); } -} \ No newline at end of file +}