diff --git a/Content.Client/AI/ClientAiDebugSystem.cs b/Content.Client/AI/ClientAiDebugSystem.cs index fb3a657c4b..7290bdf945 100644 --- a/Content.Client/AI/ClientAiDebugSystem.cs +++ b/Content.Client/AI/ClientAiDebugSystem.cs @@ -40,7 +40,7 @@ namespace Content.Client.AI var deletedEntities = new List(0); foreach (var (entity, panel) in _aiBoxes) { - if (entity.Deleted) + if ((!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) { deletedEntities.Add(entity); continue; diff --git a/Content.Client/Chat/UI/SpeechBubble.cs b/Content.Client/Chat/UI/SpeechBubble.cs index e20335a30b..5c849850f2 100644 --- a/Content.Client/Chat/UI/SpeechBubble.cs +++ b/Content.Client/Chat/UI/SpeechBubble.cs @@ -116,7 +116,7 @@ namespace Content.Client.Chat.UI Modulate = Color.White; } - if (_senderEntity.Deleted || _timeLeft <= 0) + if ((!IoCManager.Resolve().EntityExists(_senderEntity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(_senderEntity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || _timeLeft <= 0) { // Timer spawn to prevent concurrent modification exception. Timer.Spawn(0, Die); diff --git a/Content.Client/ContextMenu/UI/EntityMenuElement.cs b/Content.Client/ContextMenu/UI/EntityMenuElement.cs index 96aa0c2243..d46341b9f0 100644 --- a/Content.Client/ContextMenu/UI/EntityMenuElement.cs +++ b/Content.Client/ContextMenu/UI/EntityMenuElement.cs @@ -2,6 +2,7 @@ using Content.Client.Stylesheets; using Robust.Client.GameObjects; using Robust.Client.UserInterface.Controls; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Maths; namespace Content.Client.ContextMenu.UI @@ -57,7 +58,7 @@ namespace Content.Client.ContextMenu.UI /// public void UpdateEntity(IEntity? entity = null) { - if (Entity != null && !Entity.Deleted) + if (Entity != null && !((!IoCManager.Resolve().EntityExists(Entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted)) entity ??= Entity; EntityIcon.Sprite = entity?.GetComponentOrNull(); diff --git a/Content.Client/ContextMenu/UI/EntityMenuPresenter.cs b/Content.Client/ContextMenu/UI/EntityMenuPresenter.cs index 504b670778..d5866df317 100644 --- a/Content.Client/ContextMenu/UI/EntityMenuPresenter.cs +++ b/Content.Client/ContextMenu/UI/EntityMenuPresenter.cs @@ -184,7 +184,7 @@ namespace Content.Client.ContextMenu.UI foreach (var entity in Elements.Keys.ToList()) { - if (entity.Deleted || !ignoreFov && !_examineSystem.CanExamine(player, entity)) + if ((!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !ignoreFov && !_examineSystem.CanExamine(player, entity)) RemoveEntity(entity); } } @@ -335,7 +335,7 @@ namespace Content.Client.ContextMenu.UI if (entityElement.Entity != null) { - if (!entityElement.Entity.Deleted) + if (!((!IoCManager.Resolve().EntityExists(entityElement.Entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entityElement.Entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted)) return entityElement.Entity; continue; } diff --git a/Content.Client/DoAfter/DoAfterSystem.cs b/Content.Client/DoAfter/DoAfterSystem.cs index 5f03cae7bf..240d8be54f 100644 --- a/Content.Client/DoAfter/DoAfterSystem.cs +++ b/Content.Client/DoAfter/DoAfterSystem.cs @@ -51,7 +51,7 @@ namespace Content.Client.DoAfter var currentTime = _gameTiming.CurTime; // Can't see any I guess? - if (_attachedEntity == null || _attachedEntity.Deleted) + if (_attachedEntity == null || (!IoCManager.Resolve().EntityExists(_attachedEntity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(_attachedEntity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) return; var viewbox = _eyeManager.GetWorldViewport().Enlarged(2.0f); diff --git a/Content.Client/DragDrop/DragDropSystem.cs b/Content.Client/DragDrop/DragDropSystem.cs index f65a4d3c44..e55f43e3bc 100644 --- a/Content.Client/DragDrop/DragDropSystem.cs +++ b/Content.Client/DragDrop/DragDropSystem.cs @@ -176,7 +176,7 @@ namespace Content.Client.DragDrop private bool OnBeginDrag() { - if (_dragDropHelper.Dragged == null || _dragDropHelper.Dragged.Deleted) + if (_dragDropHelper.Dragged == null || (!IoCManager.Resolve().EntityExists(_dragDropHelper.Dragged.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(_dragDropHelper.Dragged.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) { // something happened to the clicked entity or we moved the mouse off the target so // we shouldn't replay the original click @@ -213,7 +213,7 @@ namespace Content.Client.DragDrop private bool OnContinueDrag(float frameTime) { - if (_dragDropHelper.Dragged == null || _dragDropHelper.Dragged.Deleted) + if (_dragDropHelper.Dragged == null || (!IoCManager.Resolve().EntityExists(_dragDropHelper.Dragged.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(_dragDropHelper.Dragged.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) { return false; } @@ -352,9 +352,9 @@ namespace Content.Client.DragDrop private void HighlightTargets() { if (_dragDropHelper.Dragged == null || - _dragDropHelper.Dragged.Deleted || + (!IoCManager.Resolve().EntityExists(_dragDropHelper.Dragged.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(_dragDropHelper.Dragged.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || _dragShadow == null || - _dragShadow.Deleted) + (!IoCManager.Resolve().EntityExists(_dragShadow.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(_dragShadow.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) { Logger.Warning("Programming error. Can't highlight drag and drop targets, not currently " + "dragging anything or dragged entity / shadow was deleted."); diff --git a/Content.Client/Entry/EntryPoint.cs b/Content.Client/Entry/EntryPoint.cs index 7043970921..dbf99df92c 100644 --- a/Content.Client/Entry/EntryPoint.cs +++ b/Content.Client/Entry/EntryPoint.cs @@ -151,7 +151,7 @@ namespace Content.Client.Entry /// public static void DetachPlayerFromEntity(EntityDetachedEventArgs eventArgs) { - if (!eventArgs.OldEntity.Deleted) + if (!((!IoCManager.Resolve().EntityExists(eventArgs.OldEntity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(eventArgs.OldEntity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted)) { eventArgs.OldEntity.RemoveComponent(); } diff --git a/Content.Client/HealthOverlay/HealthOverlaySystem.cs b/Content.Client/HealthOverlay/HealthOverlaySystem.cs index 8d43da2692..7f5969c5a8 100644 --- a/Content.Client/HealthOverlay/HealthOverlaySystem.cs +++ b/Content.Client/HealthOverlay/HealthOverlaySystem.cs @@ -72,7 +72,7 @@ namespace Content.Client.HealthOverlay return; } - if (_attachedEntity == null || _attachedEntity.Deleted) + if (_attachedEntity == null || (!IoCManager.Resolve().EntityExists(_attachedEntity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(_attachedEntity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) { return; } diff --git a/Content.Client/HealthOverlay/UI/HealthOverlayGui.cs b/Content.Client/HealthOverlay/UI/HealthOverlayGui.cs index 7f41f8f458..4fb76f3be8 100644 --- a/Content.Client/HealthOverlay/UI/HealthOverlayGui.cs +++ b/Content.Client/HealthOverlay/UI/HealthOverlayGui.cs @@ -72,7 +72,7 @@ namespace Content.Client.HealthOverlay.UI private void MoreFrameUpdate(FrameEventArgs args) { - if (Entity.Deleted) + if ((!IoCManager.Resolve().EntityExists(Entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) { return; } @@ -138,7 +138,7 @@ namespace Content.Client.HealthOverlay.UI MoreFrameUpdate(args); - if (Entity.Deleted || + if ((!IoCManager.Resolve().EntityExists(Entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || _eyeManager.CurrentMap != Entity.Transform.MapID) { Visible = false; diff --git a/Content.Client/Items/Managers/ItemSlotManager.cs b/Content.Client/Items/Managers/ItemSlotManager.cs index 5c5aef9bf6..76b8b7c85a 100644 --- a/Content.Client/Items/Managers/ItemSlotManager.cs +++ b/Content.Client/Items/Managers/ItemSlotManager.cs @@ -104,7 +104,7 @@ namespace Content.Client.Items.Managers } if (entity == null || - entity.Deleted || + (!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !entity.TryGetComponent(out ItemCooldownComponent? cooldown) || !cooldown.CooldownStart.HasValue || !cooldown.CooldownEnd.HasValue) diff --git a/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs b/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs index 500a5da277..805c647233 100644 --- a/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs +++ b/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs @@ -115,7 +115,7 @@ namespace Content.Client.Kitchen.UI return; } - if (entity.Deleted) + if ((!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) { continue; } diff --git a/Content.Client/Viewport/GameScreenBase.cs b/Content.Client/Viewport/GameScreenBase.cs index fecfe4b493..bdfde55710 100644 --- a/Content.Client/Viewport/GameScreenBase.cs +++ b/Content.Client/Viewport/GameScreenBase.cs @@ -132,7 +132,7 @@ namespace Content.Client.Viewport return; } - if (_lastHoveredEntity != null && !_lastHoveredEntity.Deleted && + if (_lastHoveredEntity != null && !((!IoCManager.Resolve().EntityExists(_lastHoveredEntity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(_lastHoveredEntity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) && _lastHoveredEntity.TryGetComponent(out outline)) { outline.OnMouseLeave(); diff --git a/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs b/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs index 3924e12bd6..27d329d839 100644 --- a/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs +++ b/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs @@ -51,7 +51,7 @@ namespace Content.Client.Weapons.Melee return; } - if (!attacker.Deleted) + if (!((!IoCManager.Resolve().EntityExists(attacker.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(attacker.Uid).EntityLifeStage) >= EntityLifeStage.Deleted)) { var lunge = attacker.EnsureComponent(); lunge.SetData(msg.Angle); @@ -88,7 +88,7 @@ namespace Content.Client.Weapons.Melee foreach (var uid in msg.Hits) { - if (!EntityManager.TryGetEntity(uid, out var hitEntity) || hitEntity.Deleted) + if (!EntityManager.TryGetEntity(uid, out var hitEntity) || (!IoCManager.Resolve().EntityExists(hitEntity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(hitEntity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) { continue; } diff --git a/Content.IntegrationTests/Tests/Fluids/PuddleTest.cs b/Content.IntegrationTests/Tests/Fluids/PuddleTest.cs index bc91846bd9..719d17e820 100644 --- a/Content.IntegrationTests/Tests/Fluids/PuddleTest.cs +++ b/Content.IntegrationTests/Tests/Fluids/PuddleTest.cs @@ -6,6 +6,7 @@ using Content.Shared.Coordinates; using Content.Shared.FixedPoint; using NUnit.Framework; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Timing; @@ -156,7 +157,7 @@ namespace Content.IntegrationTests.Tests.Fluids Assert.True(puddle.Owner.Paused); // Check that the puddle still exists - Assert.False(puddle.Owner.Deleted); + Assert.False((!IoCManager.Resolve().EntityExists(puddle.Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(puddle.Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted); }); // Unpause the map @@ -170,7 +171,7 @@ namespace Content.IntegrationTests.Tests.Fluids Assert.False(puddle.Owner.Paused); // Check that the puddle still exists - Assert.False(puddle.Owner.Deleted); + Assert.False((!IoCManager.Resolve().EntityExists(puddle.Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(puddle.Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted); }); // Wait enough time for it to evaporate diff --git a/Content.Server/AI/EntitySystems/AiSystem.cs b/Content.Server/AI/EntitySystems/AiSystem.cs index 19a94bedfd..b1793c94f6 100644 --- a/Content.Server/AI/EntitySystems/AiSystem.cs +++ b/Content.Server/AI/EntitySystems/AiSystem.cs @@ -51,7 +51,7 @@ namespace Content.Server.AI.EntitySystems foreach (var message in _queuedMobStateMessages) { // TODO: Need to generecise this but that will be part of a larger cleanup later anyway. - if (message.Entity.Deleted || + if ((!IoCManager.Resolve().EntityExists(message.Entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(message.Entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !message.Entity.TryGetComponent(out UtilityAi? controller)) { continue; diff --git a/Content.Server/AI/Operators/Inventory/PickupEntityOperator.cs b/Content.Server/AI/Operators/Inventory/PickupEntityOperator.cs index 7b2e60635a..bff728996d 100644 --- a/Content.Server/AI/Operators/Inventory/PickupEntityOperator.cs +++ b/Content.Server/AI/Operators/Inventory/PickupEntityOperator.cs @@ -22,7 +22,7 @@ namespace Content.Server.AI.Operators.Inventory public override Outcome Execute(float frameTime) { - if (_target.Deleted || + if ((!IoCManager.Resolve().EntityExists(_target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(_target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !_target.HasComponent() || _target.IsInContainer() || !_owner.InRangeUnobstructed(_target, popup: true)) diff --git a/Content.Server/AI/Operators/Nutrition/UseDrinkInInventoryOperator.cs b/Content.Server/AI/Operators/Nutrition/UseDrinkInInventoryOperator.cs index fac0695046..90a05f4414 100644 --- a/Content.Server/AI/Operators/Nutrition/UseDrinkInInventoryOperator.cs +++ b/Content.Server/AI/Operators/Nutrition/UseDrinkInInventoryOperator.cs @@ -30,7 +30,7 @@ namespace Content.Server.AI.Operators.Nutrition } // TODO: Also have this check storage a la backpack etc. - if (_target.Deleted || + 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)) { diff --git a/Content.Server/AI/Operators/Nutrition/UseFoodInInventoryOperator.cs b/Content.Server/AI/Operators/Nutrition/UseFoodInInventoryOperator.cs index c92ae7d52e..59eed160a9 100644 --- a/Content.Server/AI/Operators/Nutrition/UseFoodInInventoryOperator.cs +++ b/Content.Server/AI/Operators/Nutrition/UseFoodInInventoryOperator.cs @@ -29,7 +29,7 @@ namespace Content.Server.AI.Operators.Nutrition } // TODO: Also have this check storage a la backpack etc. - if (_target.Deleted || + 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)) { @@ -57,7 +57,7 @@ namespace Content.Server.AI.Operators.Nutrition return Outcome.Failed; } - if (_target.Deleted || + if ((!IoCManager.Resolve().EntityExists(_target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(_target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || foodComponent.UsesRemaining == 0 || _owner.TryGetComponent(out HungerComponent? hungerComponent) && hungerComponent.CurrentHunger >= hungerComponent.HungerThresholds[HungerThreshold.Okay]) diff --git a/Content.Server/AI/Pathfinding/PathfindingSystem.cs b/Content.Server/AI/Pathfinding/PathfindingSystem.cs index 213d5e38f0..7ee7d1046e 100644 --- a/Content.Server/AI/Pathfinding/PathfindingSystem.cs +++ b/Content.Server/AI/Pathfinding/PathfindingSystem.cs @@ -265,7 +265,7 @@ namespace Content.Server.AI.Pathfinding /// private void HandleEntityAdd(IEntity entity) { - if (entity.Deleted || + if ((!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || _lastKnownPositions.ContainsKey(entity) || !entity.TryGetComponent(out IPhysBody? physics) || !PathfindingNode.IsRelevant(entity, physics)) @@ -305,7 +305,7 @@ namespace Content.Server.AI.Pathfinding private void HandleEntityMove(MoveEvent moveEvent) { // If we've moved to space or the likes then remove us. - if (moveEvent.Sender.Deleted || + if ((!IoCManager.Resolve().EntityExists(moveEvent.Sender.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(moveEvent.Sender.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !moveEvent.Sender.TryGetComponent(out IPhysBody? physics) || !PathfindingNode.IsRelevant(moveEvent.Sender, physics) || moveEvent.NewPosition.GetGridId(EntityManager) == GridId.Invalid) diff --git a/Content.Server/AI/Steering/AiSteeringSystem.cs b/Content.Server/AI/Steering/AiSteeringSystem.cs index 389b5fcb28..2821204d3b 100644 --- a/Content.Server/AI/Steering/AiSteeringSystem.cs +++ b/Content.Server/AI/Steering/AiSteeringSystem.cs @@ -248,7 +248,7 @@ namespace Content.Server.AI.Steering private SteeringStatus Steer(IEntity entity, IAiSteeringRequest steeringRequest, float frameTime) { // Main optimisation to be done below is the redundant calls and adding more variables - if (entity.Deleted || + if ((!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !entity.TryGetComponent(out AiControllerComponent? controller) || !EntitySystem.Get().CanMove(entity.Uid) || !entity.Transform.GridID.IsValid()) @@ -258,7 +258,7 @@ namespace Content.Server.AI.Steering var entitySteering = steeringRequest as EntityTargetSteeringRequest; - if (entitySteering != null && entitySteering.Target.Deleted) + if (entitySteering != null && (!IoCManager.Resolve().EntityExists(entitySteering.Target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entitySteering.Target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) { controller.VelocityDir = Vector2.Zero; return SteeringStatus.NoPath; @@ -660,7 +660,7 @@ namespace Content.Server.AI.Steering // err for now we'll just assume the first entity is the center and just add a vector for it //Pathfinding updates are deferred so this may not be done yet. - if (physicsEntity.Deleted) continue; + if ((!IoCManager.Resolve().EntityExists(physicsEntity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(physicsEntity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) continue; // 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 diff --git a/Content.Server/AI/Utility/Considerations/Combat/TargetHealthCon.cs b/Content.Server/AI/Utility/Considerations/Combat/TargetHealthCon.cs index 9196904a72..e999c172f2 100644 --- a/Content.Server/AI/Utility/Considerations/Combat/TargetHealthCon.cs +++ b/Content.Server/AI/Utility/Considerations/Combat/TargetHealthCon.cs @@ -1,6 +1,8 @@ using Content.Server.AI.WorldState; using Content.Server.AI.WorldState.States; using Content.Shared.Damage; +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.Deleted || !target.TryGetComponent(out DamageableComponent? damageableComponent)) + if (target == null || (!IoCManager.Resolve().EntityExists(target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !target.TryGetComponent(out DamageableComponent? damageableComponent)) { return 0.0f; } diff --git a/Content.Server/AI/Utility/Considerations/Movement/TargetDistanceCon.cs b/Content.Server/AI/Utility/Considerations/Movement/TargetDistanceCon.cs index e3c912acf5..6533915a1a 100644 --- a/Content.Server/AI/Utility/Considerations/Movement/TargetDistanceCon.cs +++ b/Content.Server/AI/Utility/Considerations/Movement/TargetDistanceCon.cs @@ -1,5 +1,7 @@ using Content.Server.AI.WorldState; using Content.Server.AI.WorldState.States; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Utility.Considerations.Movement { @@ -9,7 +11,7 @@ namespace Content.Server.AI.Utility.Considerations.Movement { var self = context.GetState().GetValue(); var target = context.GetState().GetValue(); - if (target == null || target.Deleted || target.Transform.GridID != self?.Transform.GridID) + if (target == null || (!IoCManager.Resolve().EntityExists(target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || target.Transform.GridID != self?.Transform.GridID) { return 0.0f; } diff --git a/Content.Server/AI/Utility/Considerations/Nutrition/Drink/DrinkValueCon.cs b/Content.Server/AI/Utility/Considerations/Nutrition/Drink/DrinkValueCon.cs index 8ef53c8a46..79a1c6b47b 100644 --- a/Content.Server/AI/Utility/Considerations/Nutrition/Drink/DrinkValueCon.cs +++ b/Content.Server/AI/Utility/Considerations/Nutrition/Drink/DrinkValueCon.cs @@ -3,6 +3,7 @@ using Content.Server.AI.WorldState.States; using Content.Server.Chemistry.EntitySystems; using Content.Server.Nutrition.Components; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Utility.Considerations.Nutrition.Drink { @@ -13,7 +14,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Drink var target = context.GetState().GetValue(); if (target == null - || target.Deleted + || (!IoCManager.Resolve().EntityExists(target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !EntitySystem.Get().TryGetSolution(target.Uid, DrinkComponent.DefaultSolutionName, out var drink)) { 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 3c370a1a32..eb3210b6d2 100644 --- a/Content.Server/AI/Utility/Considerations/Nutrition/Food/FoodValueCon.cs +++ b/Content.Server/AI/Utility/Considerations/Nutrition/Food/FoodValueCon.cs @@ -3,6 +3,7 @@ using Content.Server.AI.WorldState.States; using Content.Server.Chemistry.EntitySystems; using Content.Server.Nutrition.Components; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.AI.Utility.Considerations.Nutrition.Food { @@ -12,7 +13,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Food { var target = context.GetState().GetValue(); - if (target == null || target.Deleted || !target.TryGetComponent(out var foodComp) || + if (target == null || (!IoCManager.Resolve().EntityExists(target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !target.TryGetComponent(out var foodComp) || !EntitySystem.Get().TryGetSolution(target.Uid, foodComp.SolutionName, out var food)) { return 0.0f; diff --git a/Content.Server/AI/WorldState/States/Inventory/InventoryState.cs b/Content.Server/AI/WorldState/States/Inventory/InventoryState.cs index a26863f5a1..fbc7af7d66 100644 --- a/Content.Server/AI/WorldState/States/Inventory/InventoryState.cs +++ b/Content.Server/AI/WorldState/States/Inventory/InventoryState.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.Inventory { @@ -16,7 +17,7 @@ namespace Content.Server.AI.WorldState.States.Inventory { foreach (var item in handsComponent.GetAllHeldItems()) { - if (item.Owner.Deleted) + if ((!IoCManager.Resolve().EntityExists(item.Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(item.Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) continue; yield return item.Owner; diff --git a/Content.Server/Atmos/Components/GasTankComponent.cs b/Content.Server/Atmos/Components/GasTankComponent.cs index e9e0f63306..5a6b42137c 100644 --- a/Content.Server/Atmos/Components/GasTankComponent.cs +++ b/Content.Server/Atmos/Components/GasTankComponent.cs @@ -19,6 +19,7 @@ using Robust.Server.Player; using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Player; using Robust.Shared.Serialization.Manager.Attributes; @@ -229,7 +230,7 @@ namespace Content.Server.Atmos.Components private InternalsComponent? GetInternalsComponent(IEntity? owner = null) { - if (Owner.Deleted) return null; + if ((!IoCManager.Resolve().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) return null; if (owner != null) return owner.GetComponentOrNull(); return Owner.TryGetContainer(out var container) ? container.Owner.GetComponentOrNull() diff --git a/Content.Server/Botany/Components/PlantHolderComponent.cs b/Content.Server/Botany/Components/PlantHolderComponent.cs index a5a85362a1..59fdf4e4fd 100644 --- a/Content.Server/Botany/Components/PlantHolderComponent.cs +++ b/Content.Server/Botany/Components/PlantHolderComponent.cs @@ -421,7 +421,7 @@ namespace Content.Server.Botany.Components public bool DoHarvest(IEntity user) { - if (Seed == null || user.Deleted || !EntitySystem.Get().CanInteract(user.Uid)) + if (Seed == null || (!IoCManager.Resolve().EntityExists(user.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(user.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !EntitySystem.Get().CanInteract(user.Uid)) return false; if (Harvest && !Dead) @@ -651,7 +651,7 @@ namespace Content.Server.Botany.Components var user = eventArgs.User; var usingItem = eventArgs.Using; - if (usingItem.Deleted || !EntitySystem.Get().CanInteract(user.Uid)) + 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)) diff --git a/Content.Server/Cargo/Components/CargoTelepadComponent.cs b/Content.Server/Cargo/Components/CargoTelepadComponent.cs index 285e269168..cc0a24abc6 100644 --- a/Content.Server/Cargo/Components/CargoTelepadComponent.cs +++ b/Content.Server/Cargo/Components/CargoTelepadComponent.cs @@ -87,14 +87,14 @@ namespace Content.Server.Cargo.Components spriteComponent.LayerSetState(0, "idle"); Owner.SpawnTimer((int) (TeleportDelay * 1000), () => { - if (!Deleted && !Owner.Deleted && _currentState == CargoTelepadState.Charging && _teleportQueue.Count > 0) + 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) spriteComponent.LayerSetState(0, "beam"); Owner.SpawnTimer((int) (TeleportDuration * 1000), () => { - if (!Deleted && !Owner.Deleted && _currentState == CargoTelepadState.Teleporting && _teleportQueue.Count > 0) + if (!Deleted && !((!IoCManager.Resolve().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) && _currentState == CargoTelepadState.Teleporting && _teleportQueue.Count > 0) { SoundSystem.Play(Filter.Pvs(Owner), _teleportSound.GetSound(), Owner, AudioParams.Default.WithVolume(-8f)); SpawnProduct(_teleportQueue[0]); diff --git a/Content.Server/Chemistry/Components/FoamSolutionAreaEffectComponent.cs b/Content.Server/Chemistry/Components/FoamSolutionAreaEffectComponent.cs index 6713c2dfb5..402e8dc290 100644 --- a/Content.Server/Chemistry/Components/FoamSolutionAreaEffectComponent.cs +++ b/Content.Server/Chemistry/Components/FoamSolutionAreaEffectComponent.cs @@ -68,7 +68,7 @@ namespace Content.Server.Chemistry.Components protected override void OnKill() { - if (Owner.Deleted) + if ((!IoCManager.Resolve().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) return; if (Owner.TryGetComponent(out AppearanceComponent? appearance)) { diff --git a/Content.Server/Chemistry/Components/SmokeSolutionAreaEffectComponent.cs b/Content.Server/Chemistry/Components/SmokeSolutionAreaEffectComponent.cs index 92e065147a..2711e41586 100644 --- a/Content.Server/Chemistry/Components/SmokeSolutionAreaEffectComponent.cs +++ b/Content.Server/Chemistry/Components/SmokeSolutionAreaEffectComponent.cs @@ -6,6 +6,7 @@ using Content.Shared.Chemistry.Reagent; using Content.Shared.FixedPoint; using Content.Shared.Smoking; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.Chemistry.Components { @@ -55,7 +56,7 @@ namespace Content.Server.Chemistry.Components protected override void OnKill() { - if (Owner.Deleted) + if ((!IoCManager.Resolve().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) return; Owner.Delete(); } diff --git a/Content.Server/Conveyor/ConveyorSystem.cs b/Content.Server/Conveyor/ConveyorSystem.cs index da8301be7b..9c846a8cd9 100644 --- a/Content.Server/Conveyor/ConveyorSystem.cs +++ b/Content.Server/Conveyor/ConveyorSystem.cs @@ -134,7 +134,7 @@ namespace Content.Server.Conveyor //todo uuuhhh cache this foreach (var entity in _entityLookup.GetEntitiesIntersecting(comp.Owner, flags: LookupFlags.Approximate)) { - if (entity.Deleted) + if ((!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) { continue; } diff --git a/Content.Server/Engineering/EntitySystems/DisassembleOnActivateSystem.cs b/Content.Server/Engineering/EntitySystems/DisassembleOnActivateSystem.cs index 7dedae6d28..2491d4e8b7 100644 --- a/Content.Server/Engineering/EntitySystems/DisassembleOnActivateSystem.cs +++ b/Content.Server/Engineering/EntitySystems/DisassembleOnActivateSystem.cs @@ -6,6 +6,7 @@ using Content.Shared.Interaction; using Content.Shared.Interaction.Helpers; using JetBrains.Annotations; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; namespace Content.Server.Engineering.EntitySystems { @@ -40,7 +41,7 @@ namespace Content.Server.Engineering.EntitySystems component.TokenSource.Cancel(); } - if (component.Deleted || component.Owner.Deleted) + if (component.Deleted || (!IoCManager.Resolve().EntityExists(component.Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(component.Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) return; var entity = EntityManager.SpawnEntity(component.Prototype, component.Owner.Transform.Coordinates); diff --git a/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs b/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs index 7fcad8a294..d231f103bd 100644 --- a/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs +++ b/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs @@ -57,7 +57,7 @@ namespace Content.Server.Engineering.EntitySystems return; } - if (component.Deleted || component.Owner.Deleted) + 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) @@ -68,7 +68,7 @@ namespace Content.Server.Engineering.EntitySystems EntityManager.SpawnEntity(component.Prototype, args.ClickLocation.SnapToGrid(grid)); - if (component.RemoveOnInteract && stackComp == null && !component.Owner.Deleted) + if (component.RemoveOnInteract && stackComp == null && !((!IoCManager.Resolve().EntityExists(component.Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(component.Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted)) component.Owner.Delete(); } } diff --git a/Content.Server/Explosion/Components/ClusterFlashComponent.cs b/Content.Server/Explosion/Components/ClusterFlashComponent.cs index 6cd69da443..0409d3209b 100644 --- a/Content.Server/Explosion/Components/ClusterFlashComponent.cs +++ b/Content.Server/Explosion/Components/ClusterFlashComponent.cs @@ -93,7 +93,7 @@ namespace Content.Server.Explosion.Components return false; Owner.SpawnTimer((int) (_delay * 1000), () => { - if (Owner.Deleted) + if ((!IoCManager.Resolve().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) return; _countDown = true; var random = IoCManager.Resolve(); @@ -116,7 +116,7 @@ namespace Content.Server.Explosion.Components grenade.SpawnTimer(delay, () => { - if (grenade.Deleted) + if ((!IoCManager.Resolve().EntityExists(grenade.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(grenade.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) return; EntitySystem.Get().Trigger(grenade, eventArgs.User); diff --git a/Content.Server/Explosion/Components/ExplosionLaunchedComponent.cs b/Content.Server/Explosion/Components/ExplosionLaunchedComponent.cs index bf04c5ef14..822902d2bd 100644 --- a/Content.Server/Explosion/Components/ExplosionLaunchedComponent.cs +++ b/Content.Server/Explosion/Components/ExplosionLaunchedComponent.cs @@ -13,7 +13,7 @@ namespace Content.Server.Explosion.Components void IExAct.OnExplosion(ExplosionEventArgs eventArgs) { - if (Owner.Deleted) + if ((!IoCManager.Resolve().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) return; var sourceLocation = eventArgs.Source; diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs index 4192f10c48..76e1f5229b 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs @@ -130,7 +130,7 @@ namespace Content.Server.Explosion.EntitySystems // and splitted into two lists based on if they are Impassable or not foreach (var entity in entitiesInRange) { - if (entity.Deleted || entity.IsInContainer()) + if ((!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || entity.IsInContainer()) { continue; } diff --git a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs index d7e21de886..921a73baa7 100644 --- a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs +++ b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs @@ -132,7 +132,7 @@ namespace Content.Server.Explosion.EntitySystems Timer.Spawn(delay, () => { - if (triggered.Deleted) return; + if ((!IoCManager.Resolve().EntityExists(triggered.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(triggered.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) return; Trigger(triggered, user); }); } diff --git a/Content.Server/Fluids/Components/BucketComponent.cs b/Content.Server/Fluids/Components/BucketComponent.cs index b4f5695e35..f6d1cc9db7 100644 --- a/Content.Server/Fluids/Components/BucketComponent.cs +++ b/Content.Server/Fluids/Components/BucketComponent.cs @@ -10,6 +10,7 @@ using Content.Shared.Popups; using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Player; using Robust.Shared.Serialization.Manager.Attributes; @@ -86,7 +87,7 @@ namespace Content.Server.Fluids.Components _currentlyUsing.Remove(eventArgs.Using.Uid); if (result == DoAfterStatus.Cancelled || - Owner.Deleted || + (!IoCManager.Resolve().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || mopComponent.Deleted || CurrentVolume <= 0 || !Owner.InRangeUnobstructed(mopComponent.Owner)) diff --git a/Content.Server/Fluids/Components/MopComponent.cs b/Content.Server/Fluids/Components/MopComponent.cs index 508e1a42d8..aa65b4f5ae 100644 --- a/Content.Server/Fluids/Components/MopComponent.cs +++ b/Content.Server/Fluids/Components/MopComponent.cs @@ -11,6 +11,7 @@ using Content.Shared.Popups; using Content.Shared.Sound; using Robust.Shared.Audio; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Player; using Robust.Shared.Serialization.Manager.Attributes; @@ -127,7 +128,7 @@ namespace Content.Server.Fluids.Components Mopping = false; if (result == DoAfterStatus.Cancelled || - Owner.Deleted || + (!IoCManager.Resolve().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || puddleComponent.Deleted) return false; diff --git a/Content.Server/Fluids/EntitySystems/PuddleSystem.cs b/Content.Server/Fluids/EntitySystems/PuddleSystem.cs index d827364f7a..a45506f3ca 100644 --- a/Content.Server/Fluids/EntitySystems/PuddleSystem.cs +++ b/Content.Server/Fluids/EntitySystems/PuddleSystem.cs @@ -61,7 +61,7 @@ namespace Content.Server.Fluids.EntitySystems private void UpdateVisuals(EntityUid uid, PuddleComponent puddleComponent) { - if (puddleComponent.Owner.Deleted || EmptyHolder(uid, puddleComponent) || + if ((!IoCManager.Resolve().EntityExists(puddleComponent.Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(puddleComponent.Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || EmptyHolder(uid, puddleComponent) || !EntityManager.TryGetComponent(uid, out var appearanceComponent)) { return; diff --git a/Content.Server/Ghost/GhostSystem.cs b/Content.Server/Ghost/GhostSystem.cs index 7ce6f5dcf1..41f692c82f 100644 --- a/Content.Server/Ghost/GhostSystem.cs +++ b/Content.Server/Ghost/GhostSystem.cs @@ -181,7 +181,7 @@ namespace Content.Server.Ghost private void DeleteEntity(EntityUid uid) { if (!EntityManager.TryGetEntity(uid, out var entity) - || entity.Deleted + || (!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || (!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) == EntityLifeStage.Terminating) return; diff --git a/Content.Server/Inventory/Components/InventoryComponent.cs b/Content.Server/Inventory/Components/InventoryComponent.cs index b8413fbce6..cfe7fe626d 100644 --- a/Content.Server/Inventory/Components/InventoryComponent.cs +++ b/Content.Server/Inventory/Components/InventoryComponent.cs @@ -124,7 +124,7 @@ namespace Content.Server.Inventory.Components } var containedEntity = _slotContainers[slot].ContainedEntity; - if (containedEntity?.Deleted == true) + if ((containedEntity != null ? (!IoCManager.Resolve().EntityExists(containedEntity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(containedEntity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted : null) == true) { _slotContainers.Remove(slot); containedEntity = null; diff --git a/Content.Server/Inventory/InventoryHelpers.cs b/Content.Server/Inventory/InventoryHelpers.cs index cd645d5faf..ca120e9830 100644 --- a/Content.Server/Inventory/InventoryHelpers.cs +++ b/Content.Server/Inventory/InventoryHelpers.cs @@ -16,7 +16,7 @@ namespace Content.Server.Inventory var user = inventory.Owner; // Let's do nothing if the owner of the inventory has been deleted. - if (user.Deleted) + if ((!IoCManager.Resolve().EntityExists(user.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(user.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) return false; // If we don't have that slot or there's already an item there, we do nothing. diff --git a/Content.Server/Light/Components/EmergencyLightComponent.cs b/Content.Server/Light/Components/EmergencyLightComponent.cs index 76a38dba86..a73df9ccec 100644 --- a/Content.Server/Light/Components/EmergencyLightComponent.cs +++ b/Content.Server/Light/Components/EmergencyLightComponent.cs @@ -80,7 +80,7 @@ namespace Content.Server.Light.Components public void OnUpdate(float frameTime) { - if (Owner.Deleted || !Owner.TryGetComponent(out BatteryComponent? battery) || Owner.Paused) + if ((!IoCManager.Resolve().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !Owner.TryGetComponent(out BatteryComponent? battery) || Owner.Paused) { return; } diff --git a/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs b/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs index d4f8576d3c..96ba413a93 100644 --- a/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs +++ b/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs @@ -105,7 +105,7 @@ namespace Content.Server.Morgue.Components _cremateCancelToken = new CancellationTokenSource(); Owner.SpawnTimer(_burnMilis, () => { - if (Owner.Deleted) + if ((!IoCManager.Resolve().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) return; Appearance?.SetData(CrematoriumVisuals.Burning, false); diff --git a/Content.Server/Morgue/Components/MorgueTrayComponent.cs b/Content.Server/Morgue/Components/MorgueTrayComponent.cs index cedb15a009..18143453ef 100644 --- a/Content.Server/Morgue/Components/MorgueTrayComponent.cs +++ b/Content.Server/Morgue/Components/MorgueTrayComponent.cs @@ -1,5 +1,6 @@ using Content.Shared.Interaction; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.ViewVariables; namespace Content.Server.Morgue.Components @@ -15,7 +16,7 @@ namespace Content.Server.Morgue.Components void IActivate.Activate(ActivateEventArgs eventArgs) { - if (Morgue != null && !Morgue.Deleted && Morgue.TryGetComponent(out var comp)) + if (Morgue != null && !((!IoCManager.Resolve().EntityExists(Morgue.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Morgue.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) && Morgue.TryGetComponent(out var comp)) { comp.Activate(new ActivateEventArgs(eventArgs.User, Morgue)); } diff --git a/Content.Server/PneumaticCannon/PneumaticCannonSystem.cs b/Content.Server/PneumaticCannon/PneumaticCannonSystem.cs index 75e79f1366..7b9d30dcff 100644 --- a/Content.Server/PneumaticCannon/PneumaticCannonSystem.cs +++ b/Content.Server/PneumaticCannon/PneumaticCannonSystem.cs @@ -224,7 +224,7 @@ namespace Content.Server.PneumaticCannon if (!comp.Owner.TryGetComponent(out var storage)) return; - if (data.User.Deleted) + if ((!IoCManager.Resolve().EntityExists(data.User.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(data.User.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) return; if (storage.StoredEntities == null) return; diff --git a/Content.Server/Projectiles/Components/HitscanComponent.cs b/Content.Server/Projectiles/Components/HitscanComponent.cs index 6f6c20571c..4015978314 100644 --- a/Content.Server/Projectiles/Components/HitscanComponent.cs +++ b/Content.Server/Projectiles/Components/HitscanComponent.cs @@ -96,7 +96,7 @@ namespace Content.Server.Projectiles.Components Owner.SpawnTimer((int) _deathTime.TotalMilliseconds, () => { - if (!Owner.Deleted) + if (!((!IoCManager.Resolve().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted)) { Owner.Delete(); } diff --git a/Content.Server/Projectiles/ProjectileSystem.cs b/Content.Server/Projectiles/ProjectileSystem.cs index 77a3d8a1ea..e34e970c52 100644 --- a/Content.Server/Projectiles/ProjectileSystem.cs +++ b/Content.Server/Projectiles/ProjectileSystem.cs @@ -39,7 +39,7 @@ namespace Content.Server.Projectiles var coordinates = args.OtherFixture.Body.Owner.Transform.Coordinates; var playerFilter = Filter.Pvs(coordinates); - if (!otherEntity.Deleted && component.SoundHitSpecies != null && + if (!((!IoCManager.Resolve().EntityExists(otherEntity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(otherEntity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) && component.SoundHitSpecies != null && otherEntity.HasComponent()) { SoundSystem.Play(playerFilter, component.SoundHitSpecies.GetSound(), coordinates); @@ -52,7 +52,7 @@ namespace Content.Server.Projectiles SoundSystem.Play(playerFilter, soundHit, coordinates); } - if (!otherEntity.Deleted) + if (!((!IoCManager.Resolve().EntityExists(otherEntity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(otherEntity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted)) { var dmg = _damageableSystem.TryChangeDamage(otherEntity.Uid, component.Damage); component.DamagedEntity = true; @@ -63,7 +63,7 @@ namespace Content.Server.Projectiles } // Damaging it can delete it - if (!otherEntity.Deleted && otherEntity.TryGetComponent(out CameraRecoilComponent? recoilComponent)) + if (!((!IoCManager.Resolve().EntityExists(otherEntity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(otherEntity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) && otherEntity.TryGetComponent(out CameraRecoilComponent? recoilComponent)) { var direction = args.OurFixture.Body.LinearVelocity.Normalized; recoilComponent.Kick(direction); diff --git a/Content.Server/Radiation/RadiationPulseComponent.cs b/Content.Server/Radiation/RadiationPulseComponent.cs index 7c1828bdf0..58b0e9b830 100644 --- a/Content.Server/Radiation/RadiationPulseComponent.cs +++ b/Content.Server/Radiation/RadiationPulseComponent.cs @@ -108,7 +108,7 @@ namespace Content.Server.Radiation public void Update(float frameTime) { - if (!Decay || Owner.Deleted) + if (!Decay || (!IoCManager.Resolve().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) return; if (_duration <= 0f) diff --git a/Content.Server/Radiation/RadiationPulseSystem.cs b/Content.Server/Radiation/RadiationPulseSystem.cs index 7142952880..6f5eb0497e 100644 --- a/Content.Server/Radiation/RadiationPulseSystem.cs +++ b/Content.Server/Radiation/RadiationPulseSystem.cs @@ -32,12 +32,12 @@ namespace Content.Server.Radiation comp.Update(RadiationCooldown); var ent = comp.Owner; - if (ent.Deleted) continue; + if ((!IoCManager.Resolve().EntityExists(ent.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(ent.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) continue; foreach (var entity in _lookup.GetEntitiesInRange(ent.Transform.Coordinates, comp.Range)) { // For now at least still need this because it uses a list internally then returns and this may be deleted before we get to it. - if (entity.Deleted) continue; + if ((!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) continue; // Note: Radiation is liable for a refactor (stinky Sloth coding a basic version when he did StationEvents) // so this ToArray doesn't really matter. diff --git a/Content.Server/Spawners/Components/ConditionalSpawnerComponent.cs b/Content.Server/Spawners/Components/ConditionalSpawnerComponent.cs index 3e377b0af5..c2e202be82 100644 --- a/Content.Server/Spawners/Components/ConditionalSpawnerComponent.cs +++ b/Content.Server/Spawners/Components/ConditionalSpawnerComponent.cs @@ -61,7 +61,7 @@ namespace Content.Server.Spawners.Components return; } - if(!Owner.Deleted) + if(!((!IoCManager.Resolve().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted)) IoCManager.Resolve().SpawnEntity(_robustRandom.Pick(Prototypes), Owner.Transform.Coordinates); } diff --git a/Content.Server/Spawners/Components/RandomSpawnerComponent.cs b/Content.Server/Spawners/Components/RandomSpawnerComponent.cs index f763473b33..248beb16d4 100644 --- a/Content.Server/Spawners/Components/RandomSpawnerComponent.cs +++ b/Content.Server/Spawners/Components/RandomSpawnerComponent.cs @@ -47,7 +47,7 @@ namespace Content.Server.Spawners.Components return; } - if(!Owner.Deleted) + if(!((!IoCManager.Resolve().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted)) { var random = IoCManager.Resolve(); diff --git a/Content.Server/StationEvents/Events/GasLeak.cs b/Content.Server/StationEvents/Events/GasLeak.cs index 8f306e1c49..aa4e1540a4 100644 --- a/Content.Server/StationEvents/Events/GasLeak.cs +++ b/Content.Server/StationEvents/Events/GasLeak.cs @@ -123,7 +123,7 @@ namespace Content.Server.StationEvents.Events if (!_foundTile || _targetGrid == null || - _targetGrid.Deleted || + (!IoCManager.Resolve().EntityExists(_targetGrid.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(_targetGrid.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !atmosphereSystem.IsSimulatedGrid(_targetGrid.Transform.GridID)) { Running = false; @@ -156,7 +156,7 @@ namespace Content.Server.StationEvents.Events { if (!_foundTile || _targetGrid == null || - _targetGrid.Deleted || + (!IoCManager.Resolve().EntityExists(_targetGrid.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(_targetGrid.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !atmosphereSystem.IsSimulatedGrid(_targetGrid.Transform.GridID)) { return; diff --git a/Content.Server/StationEvents/Events/PowerGridCheck.cs b/Content.Server/StationEvents/Events/PowerGridCheck.cs index 43e632b975..200359c25f 100644 --- a/Content.Server/StationEvents/Events/PowerGridCheck.cs +++ b/Content.Server/StationEvents/Events/PowerGridCheck.cs @@ -53,7 +53,7 @@ namespace Content.Server.StationEvents.Events { foreach (var entity in _powered) { - if (entity.Deleted) continue; + if ((!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) continue; if (entity.TryGetComponent(out ApcPowerReceiverComponent? powerReceiverComponent)) { diff --git a/Content.Server/Throwing/ThrowHelper.cs b/Content.Server/Throwing/ThrowHelper.cs index 9f42d8fe36..f0dd22f780 100644 --- a/Content.Server/Throwing/ThrowHelper.cs +++ b/Content.Server/Throwing/ThrowHelper.cs @@ -33,7 +33,7 @@ namespace Content.Server.Throwing /// The ratio of impulse applied to the thrower internal static void TryThrow(this IEntity entity, Vector2 direction, float strength = 1.0f, IEntity? user = null, float pushbackRatio = 1.0f) { - if (entity.Deleted || + if ((!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || strength <= 0f || !entity.TryGetComponent(out PhysicsComponent? physicsComponent)) { diff --git a/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs b/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs index a36cf82fbf..7435ed7ca1 100644 --- a/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs +++ b/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs @@ -269,7 +269,7 @@ namespace Content.Server.Weapon.Melee var hitBloodstreams = new List(); foreach (var entity in args.HitEntities) { - if (entity.Deleted) + if ((!IoCManager.Resolve().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) continue; if (entity.TryGetComponent(out var bloodstream)) diff --git a/Content.Shared/Nutrition/EntitySystems/SharedCreamPieSystem.cs b/Content.Shared/Nutrition/EntitySystems/SharedCreamPieSystem.cs index 51da449a78..0555adab15 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 (args.Thrown.Deleted || !args.Thrown.TryGetComponent(out CreamPieComponent? creamPie)) return; + if ((!IoCManager.Resolve().EntityExists(args.Thrown.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(args.Thrown.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || !args.Thrown.TryGetComponent(out CreamPieComponent? creamPie)) return; SetCreamPied(uid, creamPied, true); diff --git a/Content.Shared/Pulling/Systems/SharedPullingSystem.cs b/Content.Shared/Pulling/Systems/SharedPullingSystem.cs index 8fcf548769..ad00d87be8 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingSystem.cs @@ -165,7 +165,7 @@ namespace Content.Shared.Pulling // The pulled object may have already been deleted. // TODO: Work out why. Monkey + meat spike is a good test for this, // assuming you're still pulling the monkey when it gets gibbed. - if (pulled.Deleted) + if ((!IoCManager.Resolve().EntityExists(pulled.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(pulled.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) { return; } diff --git a/Content.Shared/Throwing/ThrownItemSystem.cs b/Content.Shared/Throwing/ThrownItemSystem.cs index 5a73b751a7..b880f3e0b2 100644 --- a/Content.Shared/Throwing/ThrownItemSystem.cs +++ b/Content.Shared/Throwing/ThrownItemSystem.cs @@ -113,7 +113,7 @@ namespace Content.Shared.Throwing public void LandComponent(ThrownItemComponent thrownItem) { - if (thrownItem.Deleted || thrownItem.Owner.Deleted || _containerSystem.IsEntityInContainer(thrownItem.Owner.Uid)) return; + if (thrownItem.Deleted || (!IoCManager.Resolve().EntityExists(thrownItem.Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(thrownItem.Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || _containerSystem.IsEntityInContainer(thrownItem.Owner.Uid)) return; var landing = thrownItem.Owner;