diff --git a/Content.Client/AI/ClientPathfindingDebugSystem.cs b/Content.Client/AI/ClientPathfindingDebugSystem.cs index 1068bcae54..b796dafed1 100644 --- a/Content.Client/AI/ClientPathfindingDebugSystem.cs +++ b/Content.Client/AI/ClientPathfindingDebugSystem.cs @@ -18,7 +18,6 @@ namespace Content.Client.AI #if DEBUG public class ClientPathfindingDebugSystem : EntitySystem { - [Dependency] private readonly IOverlayManager _overlayManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IEyeManager _eyeManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; diff --git a/Content.Client/Body/UI/BodyScannerBoundUserInterface.cs b/Content.Client/Body/UI/BodyScannerBoundUserInterface.cs index 247ce80b95..417059745a 100644 --- a/Content.Client/Body/UI/BodyScannerBoundUserInterface.cs +++ b/Content.Client/Body/UI/BodyScannerBoundUserInterface.cs @@ -14,9 +14,6 @@ namespace Content.Client.Body.UI [ViewVariables] private BodyScannerDisplay? _display; - [ViewVariables] - private EntityUid _entity; - public BodyScannerBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) { } protected override void Open() @@ -43,7 +40,7 @@ namespace Content.Client.Body.UI throw new ArgumentException($"Received an invalid entity with id {scannerState.Uid} for body scanner with id {Owner.Owner} at {entMan.GetComponent(Owner.Owner).MapPosition}"); } - _display?.UpdateDisplay(_entity); + _display?.UpdateDisplay(scannerState.Uid); } protected override void Dispose(bool disposing) diff --git a/Content.Client/Body/UI/BodyScannerDisplay.cs b/Content.Client/Body/UI/BodyScannerDisplay.cs index 852527014e..4f81434264 100644 --- a/Content.Client/Body/UI/BodyScannerDisplay.cs +++ b/Content.Client/Body/UI/BodyScannerDisplay.cs @@ -104,7 +104,7 @@ namespace Content.Client.Body.UI public void UpdateDisplay(EntityUid entity) { - if(entity == null) + if(!entity.Valid) return; _currentEntity = entity; @@ -125,12 +125,7 @@ namespace Content.Client.Body.UI public void BodyPartOnItemSelected(ItemListSelectedEventArgs args) { - if (_currentEntity == null) - return; - - var body = IoCManager.Resolve().GetComponentOrNull(_currentEntity); - - if (body == null) + if (IoCManager.Resolve().TryGetComponent(_currentEntity, out var body)) { return; } diff --git a/Content.Client/ContextMenu/UI/EntityMenuPresenter.cs b/Content.Client/ContextMenu/UI/EntityMenuPresenter.cs index 033e23b333..22c3b7af84 100644 --- a/Content.Client/ContextMenu/UI/EntityMenuPresenter.cs +++ b/Content.Client/ContextMenu/UI/EntityMenuPresenter.cs @@ -288,7 +288,7 @@ namespace Content.Client.ContextMenu.UI // Get the first entity in the sub-menus var entity = GetFirstEntityOrNull(element.SubMenu); - if (entity == null) + if (!entity.Valid) { // This whole element has no associated entities. We should remove it element.Dispose(); diff --git a/Content.Client/Decals/DecalOverlay.cs b/Content.Client/Decals/DecalOverlay.cs index 5a8169b957..bbd20d1612 100644 --- a/Content.Client/Decals/DecalOverlay.cs +++ b/Content.Client/Decals/DecalOverlay.cs @@ -4,10 +4,8 @@ using Robust.Client.Graphics; using Robust.Client.Utility; using Robust.Shared.Enums; using Robust.Shared.Map; -using Robust.Shared.Maths; using Robust.Shared.Prototypes; using Robust.Shared.Utility; -using Robust.Shared.Maths; namespace Content.Client.Decals { diff --git a/Content.Client/Hands/HandsGui.xaml.cs b/Content.Client/Hands/HandsGui.xaml.cs index abe5f35685..1895a5fabf 100644 --- a/Content.Client/Hands/HandsGui.xaml.cs +++ b/Content.Client/Hands/HandsGui.xaml.cs @@ -99,8 +99,7 @@ namespace Content.Client.Hands _itemSlotManager.SetItemSlot(newButton, hand.HeldItem); // Show blocked overlay if hand is blocked. - newButton.Blocked.Visible = - hand.HeldItem != null && IoCManager.Resolve().HasComponent(hand.HeldItem); + newButton.Blocked.Visible = IoCManager.Resolve().HasComponent(hand.HeldItem); } if (TryGetActiveHand(out var activeHand)) diff --git a/Content.Client/Inventory/StrippableBoundUserInterface.cs b/Content.Client/Inventory/StrippableBoundUserInterface.cs index dee8e4f03c..2c4884d301 100644 --- a/Content.Client/Inventory/StrippableBoundUserInterface.cs +++ b/Content.Client/Inventory/StrippableBoundUserInterface.cs @@ -29,7 +29,7 @@ namespace Content.Client.Inventory { base.Open(); - _strippingMenu = new StrippingMenu($"{Loc.GetString("strippable-bound-user-interface-stripping-menu-title",("ownerName", Name: IoCManager.Resolve().GetComponent(Owner.Owner).EntityName))}"); + _strippingMenu = new StrippingMenu($"{Loc.GetString("strippable-bound-user-interface-stripping-menu-title",("ownerName", IoCManager.Resolve().GetComponent(Owner.Owner).EntityName))}"); _strippingMenu.OnClose += Close; _strippingMenu.OpenCentered(); diff --git a/Content.Client/MedicalScanner/UI/MedicalScannerWindow.xaml.cs b/Content.Client/MedicalScanner/UI/MedicalScannerWindow.xaml.cs index 485e9b9070..fb7c928529 100644 --- a/Content.Client/MedicalScanner/UI/MedicalScannerWindow.xaml.cs +++ b/Content.Client/MedicalScanner/UI/MedicalScannerWindow.xaml.cs @@ -36,7 +36,7 @@ namespace Content.Client.MedicalScanner.UI } else { - text.Append($"{Loc.GetString("medical-scanner-window-entity-health-text", ("entityName", Name: entities.GetComponent(state.Entity.Value).EntityName))}\n"); + text.Append($"{Loc.GetString("medical-scanner-window-entity-health-text", ("entityName", entities.GetComponent(state.Entity.Value).EntityName))}\n"); var totalDamage = state.DamagePerType.Values.Sum(); diff --git a/Content.Server/AI/LoadBalancer/AiActionRequestJob.cs b/Content.Server/AI/LoadBalancer/AiActionRequestJob.cs index 8594dc5eb7..2550656763 100644 --- a/Content.Server/AI/LoadBalancer/AiActionRequestJob.cs +++ b/Content.Server/AI/LoadBalancer/AiActionRequestJob.cs @@ -39,7 +39,7 @@ namespace Content.Server.AI.LoadBalancer var entity = _request.Context.GetState().GetValue(); - if (entity == null || !IoCManager.Resolve().HasComponent(entity)) + if (!IoCManager.Resolve().HasComponent(entity)) { return null; } diff --git a/Content.Server/AI/Utility/Actions/Idle/CloseLastEntityStorage.cs b/Content.Server/AI/Utility/Actions/Idle/CloseLastEntityStorage.cs index 0c92ca875a..8b99a3ce9d 100644 --- a/Content.Server/AI/Utility/Actions/Idle/CloseLastEntityStorage.cs +++ b/Content.Server/AI/Utility/Actions/Idle/CloseLastEntityStorage.cs @@ -25,7 +25,7 @@ namespace Content.Server.AI.Utility.Actions.Idle { var lastStorage = context.GetState().GetValue(); - if (lastStorage == null) + if (!lastStorage.Valid) { ActionOperators = new Queue(new AiOperator[] { diff --git a/Content.Server/AI/Utility/Considerations/ActionBlocker/CanMoveCon.cs b/Content.Server/AI/Utility/Considerations/ActionBlocker/CanMoveCon.cs index 18ffa4ac79..54114f20af 100644 --- a/Content.Server/AI/Utility/Considerations/ActionBlocker/CanMoveCon.cs +++ b/Content.Server/AI/Utility/Considerations/ActionBlocker/CanMoveCon.cs @@ -12,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.ActionBlocker { var self = context.GetState().GetValue(); - if (self == null || !EntitySystem.Get().CanMove(self)) + if (!self.Valid || !EntitySystem.Get().CanMove(self)) { return 0.0f; } diff --git a/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponDamageCon.cs b/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponDamageCon.cs index 6c5c317bed..cc8f0fe797 100644 --- a/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponDamageCon.cs +++ b/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponDamageCon.cs @@ -12,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat.Melee { var target = context.GetState().GetValue(); - if (target == null || !IoCManager.Resolve().TryGetComponent(target, out MeleeWeaponComponent? meleeWeaponComponent)) + if (!IoCManager.Resolve().TryGetComponent(target, out MeleeWeaponComponent? meleeWeaponComponent)) { return 0.0f; } diff --git a/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponEquippedCon.cs b/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponEquippedCon.cs index 60a383e9cb..1d48a9fdb8 100644 --- a/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponEquippedCon.cs +++ b/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponEquippedCon.cs @@ -10,14 +10,10 @@ namespace Content.Server.AI.Utility.Considerations.Combat.Melee { protected override float GetScore(Blackboard context) { - var equipped = context.GetState().GetValue(); - - if (equipped == null) - { - return 0.0f; - } - - return IoCManager.Resolve().HasComponent(equipped) ? 1.0f : 0.0f; + return IoCManager.Resolve() + .HasComponent(context.GetState().GetValue()) + ? 1.0f + : 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 d84c977509..1ab36c3b9f 100644 --- a/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponSpeedCon.cs +++ b/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponSpeedCon.cs @@ -12,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat.Melee { var target = context.GetState().GetValue(); - if (target == null || !IoCManager.Resolve().TryGetComponent(target, out MeleeWeaponComponent? meleeWeaponComponent)) + if (!IoCManager.Resolve().TryGetComponent(target, 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 47f23d0f41..95b7a2c37a 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().TryGetComponent(target, out DamageableComponent? damageableComponent)) + if (!IoCManager.Resolve().TryGetComponent(target, 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 37b3f99552..7a62879524 100644 --- a/Content.Server/AI/Utility/Considerations/Combat/TargetIsCritCon.cs +++ b/Content.Server/AI/Utility/Considerations/Combat/TargetIsCritCon.cs @@ -12,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat { var target = context.GetState().GetValue(); - if (target == null || !IoCManager.Resolve().TryGetComponent(target, out MobStateComponent? mobState)) + if (!IoCManager.Resolve().TryGetComponent(target, 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 26622c9723..4ccc3d7190 100644 --- a/Content.Server/AI/Utility/Considerations/Combat/TargetIsDeadCon.cs +++ b/Content.Server/AI/Utility/Considerations/Combat/TargetIsDeadCon.cs @@ -12,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat { var target = context.GetState().GetValue(); - if (target == null || !IoCManager.Resolve().TryGetComponent(target, out MobStateComponent? mobState)) + if (!IoCManager.Resolve().TryGetComponent(target, 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 ebed8d3c34..371896c161 100644 --- a/Content.Server/AI/Utility/Considerations/Containers/TargetAccessibleCon.cs +++ b/Content.Server/AI/Utility/Considerations/Containers/TargetAccessibleCon.cs @@ -43,7 +43,7 @@ namespace Content.Server.AI.Utility.Considerations.Containers var owner = context.GetState().GetValue(); - if (owner == null) + if (!owner.Valid) { return 0; } diff --git a/Content.Server/AI/Utility/Considerations/Hands/FreeHandCon.cs b/Content.Server/AI/Utility/Considerations/Hands/FreeHandCon.cs index 029775d5f3..e2e82b30fe 100644 --- a/Content.Server/AI/Utility/Considerations/Hands/FreeHandCon.cs +++ b/Content.Server/AI/Utility/Considerations/Hands/FreeHandCon.cs @@ -12,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Hands { var owner = context.GetState().GetValue(); - if (owner == null || !IoCManager.Resolve().TryGetComponent(owner, out HandsComponent? handsComponent)) + if (!IoCManager.Resolve().TryGetComponent(owner, out HandsComponent? handsComponent)) { return 0.0f; } diff --git a/Content.Server/AI/Utility/Considerations/Inventory/CanPutTargetInInventoryCon.cs b/Content.Server/AI/Utility/Considerations/Inventory/CanPutTargetInInventoryCon.cs index 14ccfbf4d2..8c98253d6a 100644 --- a/Content.Server/AI/Utility/Considerations/Inventory/CanPutTargetInInventoryCon.cs +++ b/Content.Server/AI/Utility/Considerations/Inventory/CanPutTargetInInventoryCon.cs @@ -16,7 +16,7 @@ namespace Content.Server.AI.Utility.Considerations.Inventory // If not then check if we have a free hand var target = context.GetState().GetValue(); - if (target == null || !IoCManager.Resolve().HasComponent(target)) + if (!IoCManager.Resolve().HasComponent(target)) { return 0.0f; } diff --git a/Content.Server/AI/Utility/Considerations/Inventory/TargetInOurInventoryCon.cs b/Content.Server/AI/Utility/Considerations/Inventory/TargetInOurInventoryCon.cs index b7fcd97b1c..5d5bb917b6 100644 --- a/Content.Server/AI/Utility/Considerations/Inventory/TargetInOurInventoryCon.cs +++ b/Content.Server/AI/Utility/Considerations/Inventory/TargetInOurInventoryCon.cs @@ -13,7 +13,7 @@ namespace Content.Server.AI.Utility.Considerations.Inventory { var target = context.GetState().GetValue(); - if (target == null || !IoCManager.Resolve().HasComponent(target)) + if (!IoCManager.Resolve().HasComponent(target)) { 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 e7a7fbc5ca..9a0b16ece6 100644 --- a/Content.Server/AI/Utility/Considerations/Nutrition/Drink/DrinkValueCon.cs +++ b/Content.Server/AI/Utility/Considerations/Nutrition/Drink/DrinkValueCon.cs @@ -13,8 +13,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Drink { var target = context.GetState().GetValue(); - if (target == null - || IoCManager.Resolve().Deleted(target) + if (IoCManager.Resolve().Deleted(target) || !EntitySystem.Get().TryGetSolution(target, DrinkComponent.DefaultSolutionName, out var drink)) { 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 6ea21c75db..b90f80bdae 100644 --- a/Content.Server/AI/Utility/Considerations/Nutrition/Drink/ThirstCon.cs +++ b/Content.Server/AI/Utility/Considerations/Nutrition/Drink/ThirstCon.cs @@ -13,7 +13,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Drink { var owner = context.GetState().GetValue(); - if (owner == null || !IoCManager.Resolve().TryGetComponent(owner, out ThirstComponent? thirst)) + if (!IoCManager.Resolve().TryGetComponent(owner, 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 3341d8a193..28b003f2a8 100644 --- a/Content.Server/AI/Utility/Considerations/Nutrition/Food/FoodValueCon.cs +++ b/Content.Server/AI/Utility/Considerations/Nutrition/Food/FoodValueCon.cs @@ -13,8 +13,9 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Food { var target = context.GetState().GetValue(); - if (target == null || !IoCManager.Resolve().TryGetComponent(target, out var foodComp) - || !EntitySystem.Get().TryGetSolution(target, foodComp.SolutionName, out var food)) + if (!IoCManager.Resolve().TryGetComponent(target, out var foodComp) + || !EntitySystem.Get() + .TryGetSolution(target, 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 33cc9dca90..29a0157683 100644 --- a/Content.Server/AI/Utility/Considerations/Nutrition/Food/HungerCon.cs +++ b/Content.Server/AI/Utility/Considerations/Nutrition/Food/HungerCon.cs @@ -14,7 +14,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Food { var owner = context.GetState().GetValue(); - if (owner == null || !IoCManager.Resolve().TryGetComponent(owner, out HungerComponent? hunger)) + if (!IoCManager.Resolve().TryGetComponent(owner, out HungerComponent? hunger)) { return 0.0f; } diff --git a/Content.Server/AI/Utility/Considerations/State/StoredStateEntityIsNullCon.cs b/Content.Server/AI/Utility/Considerations/State/StoredStateEntityIsNullCon.cs index 17c41986ae..28b80f6f5a 100644 --- a/Content.Server/AI/Utility/Considerations/State/StoredStateEntityIsNullCon.cs +++ b/Content.Server/AI/Utility/Considerations/State/StoredStateEntityIsNullCon.cs @@ -28,7 +28,7 @@ namespace Content.Server.AI.Utility.Considerations.State } context.GetStoredState(stateData, out StoredStateData state); - return state.GetValue() == null ? 1.0f : 0.0f; + return state.GetValue().Valid ? 0.0f : 1.0f; } } } diff --git a/Content.Server/AI/Utility/NpcBehaviorManager.cs b/Content.Server/AI/Utility/NpcBehaviorManager.cs index f1760ef3e2..ef1513797c 100644 --- a/Content.Server/AI/Utility/NpcBehaviorManager.cs +++ b/Content.Server/AI/Utility/NpcBehaviorManager.cs @@ -28,7 +28,6 @@ namespace Content.Server.AI.Utility internal sealed class NpcBehaviorManager : INpcBehaviorManager { [Dependency] private readonly IDynamicTypeFactory _typeFactory = default!; - [Dependency] private readonly IEntityManager _entityManager = default!; private readonly NpcActionComparer _comparer = new(); diff --git a/Content.Server/Actions/Actions/DisarmAction.cs b/Content.Server/Actions/Actions/DisarmAction.cs index 0fb7209a16..7e9ac324a6 100644 --- a/Content.Server/Actions/Actions/DisarmAction.cs +++ b/Content.Server/Actions/Actions/DisarmAction.cs @@ -83,10 +83,10 @@ namespace Content.Server.Actions.Actions SoundSystem.Play(Filter.Pvs(args.Performer), PunchMissSound.GetSound(), args.Performer, AudioHelpers.WithVariation(0.025f)); args.Performer.PopupMessageOtherClients(Loc.GetString("disarm-action-popup-message-other-clients", - ("performerName", Name: entMan.GetComponent(args.Performer).EntityName), - ("targetName", Name: entMan.GetComponent(args.Target).EntityName))); + ("performerName", entMan.GetComponent(args.Performer).EntityName), + ("targetName", entMan.GetComponent(args.Target).EntityName))); args.Performer.PopupMessageCursor(Loc.GetString("disarm-action-popup-message-cursor", - ("targetName", Name: entMan.GetComponent(args.Target).EntityName))); + ("targetName", entMan.GetComponent(args.Target).EntityName))); system.SendLunge(angle, args.Performer); return; } diff --git a/Content.Server/Atmos/EntitySystems/AirtightSystem.cs b/Content.Server/Atmos/EntitySystems/AirtightSystem.cs index 4a481f0195..8921d7d986 100644 --- a/Content.Server/Atmos/EntitySystems/AirtightSystem.cs +++ b/Content.Server/Atmos/EntitySystems/AirtightSystem.cs @@ -14,7 +14,6 @@ namespace Content.Server.Atmos.EntitySystems { [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; - [Dependency] private readonly SpreaderSystem _spreaderSystem = default!; public override void Initialize() { diff --git a/Content.Server/Body/Components/MechanismComponent.cs b/Content.Server/Body/Components/MechanismComponent.cs index ec5f538c4c..1b8c60e87d 100644 --- a/Content.Server/Body/Components/MechanismComponent.cs +++ b/Content.Server/Body/Components/MechanismComponent.cs @@ -88,7 +88,7 @@ namespace Content.Server.Body.Components else // If surgery cannot be performed, show message saying so. { eventArgs.Target?.PopupMessage(eventArgs.User, - Loc.GetString("mechanism-component-no-way-to-install-message", ("partName", Name: _entities.GetComponent(Owner).EntityName))); + Loc.GetString("mechanism-component-no-way-to-install-message", ("partName", _entities.GetComponent(Owner).EntityName))); } } @@ -114,7 +114,7 @@ namespace Content.Server.Body.Components if (!OptionsCache.TryGetValue(key, out var targetObject)) { BodyCache.Owner.PopupMessage(PerformerCache.Value, - Loc.GetString("mechanism-component-no-useful-way-to-use-message",("partName", Name: _entities.GetComponent(Owner).EntityName))); + Loc.GetString("mechanism-component-no-useful-way-to-use-message",("partName", _entities.GetComponent(Owner).EntityName))); return; } diff --git a/Content.Server/Body/Systems/LungSystem.cs b/Content.Server/Body/Systems/LungSystem.cs index c68392d01b..0f002de83d 100644 --- a/Content.Server/Body/Systems/LungSystem.cs +++ b/Content.Server/Body/Systems/LungSystem.cs @@ -115,8 +115,6 @@ public class LungSystem : EntitySystem // TODO Jesus Christ make this event based. if (mech.Body != null && EntityManager.TryGetComponent((mech.Body).Owner, out InternalsComponent? internals) && - internals.BreathToolEntity != null && - internals.GasTankEntity != null && EntityManager.TryGetComponent(internals.BreathToolEntity, out BreathToolComponent? breathTool) && breathTool.IsFunctional && EntityManager.TryGetComponent(internals.GasTankEntity, out GasTankComponent? gasTank)) diff --git a/Content.Server/Botany/Components/PlantHolderComponent.cs b/Content.Server/Botany/Components/PlantHolderComponent.cs index 9c15a5e5ab..a5d74ac2cf 100644 --- a/Content.Server/Botany/Components/PlantHolderComponent.cs +++ b/Content.Server/Botany/Components/PlantHolderComponent.cs @@ -684,7 +684,7 @@ namespace Content.Server.Botany.Components } user.PopupMessageCursor(Loc.GetString("plant-holder-component-already-seeded-message", - ("name", Name: _entMan.GetComponent(Owner).EntityName))); + ("name", _entMan.GetComponent(Owner).EntityName))); return false; } @@ -693,9 +693,9 @@ namespace Content.Server.Botany.Components if (WeedLevel > 0) { user.PopupMessageCursor(Loc.GetString("plant-holder-component-remove-weeds-message", - ("name", Name: _entMan.GetComponent(Owner).EntityName))); + ("name", _entMan.GetComponent(Owner).EntityName))); user.PopupMessageOtherClients(Loc.GetString("plant-holder-component-remove-weeds-others-message", - ("otherName", Name: _entMan.GetComponent(user).EntityName))); + ("otherName", _entMan.GetComponent(user).EntityName))); WeedLevel = 0; UpdateSprite(); } @@ -712,9 +712,9 @@ namespace Content.Server.Botany.Components if (Seed != null) { user.PopupMessageCursor(Loc.GetString("plant-holder-component-remove-plant-message", - ("name", Name: _entMan.GetComponent(Owner).EntityName))); + ("name", _entMan.GetComponent(Owner).EntityName))); user.PopupMessageOtherClients(Loc.GetString("plant-holder-component-remove-plant-others-message", - ("name", Name: _entMan.GetComponent(user).EntityName))); + ("name", _entMan.GetComponent(user).EntityName))); RemovePlant(); } else diff --git a/Content.Server/Botany/Components/SeedExtractorComponent.cs b/Content.Server/Botany/Components/SeedExtractorComponent.cs index c2a95b37ce..82b1d1825d 100644 --- a/Content.Server/Botany/Components/SeedExtractorComponent.cs +++ b/Content.Server/Botany/Components/SeedExtractorComponent.cs @@ -30,7 +30,7 @@ namespace Content.Server.Botany.Components if (_entMan.TryGetComponent(eventArgs.Using, out ProduceComponent? produce) && produce.Seed != null) { - eventArgs.User.PopupMessageCursor(Loc.GetString("seed-extractor-component-interact-message",("name", Name: _entMan.GetComponent(eventArgs.Using).EntityName))); + eventArgs.User.PopupMessageCursor(Loc.GetString("seed-extractor-component-interact-message",("name", _entMan.GetComponent(eventArgs.Using).EntityName))); _entMan.QueueDeleteEntity(eventArgs.Using); diff --git a/Content.Server/Botany/Seed.cs b/Content.Server/Botany/Seed.cs index c9123aac14..56995c40c5 100644 --- a/Content.Server/Botany/Seed.cs +++ b/Content.Server/Botany/Seed.cs @@ -280,8 +280,7 @@ namespace Content.Server.Botany public IEnumerable AutoHarvest(EntityCoordinates position, int yieldMod = 1) { - if (position.IsValid(IoCManager.Resolve()) && ProductPrototypes != null && - ProductPrototypes.Count > 0) + if (position.IsValid(IoCManager.Resolve()) && ProductPrototypes.Count > 0) return GenerateProduct(position, yieldMod); return Enumerable.Empty(); @@ -291,10 +290,10 @@ namespace Content.Server.Botany { AddToDatabase(); - if (user == null) + if (!user.Valid) return Enumerable.Empty(); - if (ProductPrototypes == null || ProductPrototypes.Count == 0 || Yield <= 0) + if (ProductPrototypes.Count == 0 || Yield <= 0) { user.PopupMessageCursor(Loc.GetString("botany-harvest-fail-message")); return Enumerable.Empty(); @@ -312,14 +311,8 @@ namespace Content.Server.Botany if (yieldMod < 0) { yieldMod = 1; - totalYield = Yield; } - else - { - totalYield = Yield * yieldMod; - } - - totalYield = Math.Max(1, totalYield); + totalYield = Math.Max(1, Yield * yieldMod); } var random = IoCManager.Resolve(); diff --git a/Content.Server/Chat/Managers/ChatManager.cs b/Content.Server/Chat/Managers/ChatManager.cs index 02cb35f2f4..e050fee103 100644 --- a/Content.Server/Chat/Managers/ChatManager.cs +++ b/Content.Server/Chat/Managers/ChatManager.cs @@ -197,7 +197,7 @@ namespace Content.Server.Chat.Managers var msg = _netManager.CreateNetMessage(); msg.Channel = ChatChannel.Local; msg.Message = message; - msg.MessageWrap = Loc.GetString("chat-manager-entity-say-wrap-message",("entityName", Name: _entManager.GetComponent(source).EntityName)); + msg.MessageWrap = Loc.GetString("chat-manager-entity-say-wrap-message",("entityName", _entManager.GetComponent(source).EntityName)); msg.SenderEntity = source; msg.HideChat = hideChat; _netManager.ServerSendToMany(msg, clients); @@ -234,7 +234,7 @@ namespace Content.Server.Chat.Managers var msg = _netManager.CreateNetMessage(); msg.Channel = ChatChannel.Emotes; msg.Message = action; - msg.MessageWrap = Loc.GetString("chat-manager-entity-me-wrap-message", ("entityName",Name: _entManager.GetComponent(source).EntityName)); + msg.MessageWrap = Loc.GetString("chat-manager-entity-me-wrap-message", ("entityName", _entManager.GetComponent(source).EntityName)); msg.SenderEntity = source; _netManager.ServerSendToMany(msg, clients); } diff --git a/Content.Server/Climbing/Components/ClimbableComponent.cs b/Content.Server/Climbing/Components/ClimbableComponent.cs index 4dcb0c58cc..84db4dba7c 100644 --- a/Content.Server/Climbing/Components/ClimbableComponent.cs +++ b/Content.Server/Climbing/Components/ClimbableComponent.cs @@ -115,7 +115,7 @@ namespace Content.Server.Climbing.Components return false; } - if (target == null || !_entities.HasComponent(dragged)) + if (!_entities.HasComponent(dragged)) { reason = Loc.GetString("comp-climbable-cant-climb"); return false; diff --git a/Content.Server/Clothing/MagbootsSystem.cs b/Content.Server/Clothing/MagbootsSystem.cs index 89d795852d..e193e979fc 100644 --- a/Content.Server/Clothing/MagbootsSystem.cs +++ b/Content.Server/Clothing/MagbootsSystem.cs @@ -25,7 +25,7 @@ namespace Content.Server.Clothing private void AddToggleVerb(EntityUid uid, MagbootsComponent component, GetActivationVerbsEvent args) { - if (args.User == null || !args.CanAccess || !args.CanInteract) + if (!args.User.Valid || !args.CanAccess || !args.CanInteract) return; Verb verb = new(); diff --git a/Content.Server/Construction/Conditions/AirlockBolted.cs b/Content.Server/Construction/Conditions/AirlockBolted.cs index db5c289747..4a597d6807 100644 --- a/Content.Server/Construction/Conditions/AirlockBolted.cs +++ b/Content.Server/Construction/Conditions/AirlockBolted.cs @@ -37,10 +37,10 @@ namespace Content.Server.Construction.Conditions if (airlock.BoltsDown != Value) { - if (Value == true) - args.PushMarkup(Loc.GetString("construction-examine-condition-airlock-bolt", ("entityName", Name: entMan.GetComponent(entity).EntityName)) + "\n"); + if (Value) + args.PushMarkup(Loc.GetString("construction-examine-condition-airlock-bolt", ("entityName", entMan.GetComponent(entity).EntityName)) + "\n"); else - args.PushMarkup(Loc.GetString("construction-examine-condition-airlock-unbolt", ("entityName", Name: entMan.GetComponent(entity).EntityName)) + "\n"); + args.PushMarkup(Loc.GetString("construction-examine-condition-airlock-unbolt", ("entityName", entMan.GetComponent(entity).EntityName)) + "\n"); return true; } diff --git a/Content.Server/Construction/Conditions/DoorWelded.cs b/Content.Server/Construction/Conditions/DoorWelded.cs index 2ba8f99c92..817cecb599 100644 --- a/Content.Server/Construction/Conditions/DoorWelded.cs +++ b/Content.Server/Construction/Conditions/DoorWelded.cs @@ -36,9 +36,9 @@ namespace Content.Server.Construction.Conditions if (door.IsWeldedShut != Welded) { if (Welded == true) - args.PushMarkup(Loc.GetString("construction-examine-condition-door-weld", ("entityName", Name: entMan.GetComponent(entity).EntityName)) + "\n"); + args.PushMarkup(Loc.GetString("construction-examine-condition-door-weld", ("entityName", entMan.GetComponent(entity).EntityName)) + "\n"); else - args.PushMarkup(Loc.GetString("construction-examine-condition-door-unweld", ("entityName", Name: entMan.GetComponent(entity).EntityName)) + "\n"); + args.PushMarkup(Loc.GetString("construction-examine-condition-door-unweld", ("entityName", entMan.GetComponent(entity).EntityName)) + "\n"); return true; } diff --git a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs index 54c63038c8..7548a8cb4e 100644 --- a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs +++ b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs @@ -90,7 +90,7 @@ namespace Content.Server.Disposal.Unit.Components private bool PlayerCanUse(EntityUid player) { - if (player == null) + if (!player.Valid) { return false; } diff --git a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs index a282d38b30..ce20a1d209 100644 --- a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs +++ b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs @@ -39,7 +39,6 @@ namespace Content.Server.Explosion.EntitySystems { [Dependency] private readonly ExplosionSystem _explosions = default!; [Dependency] private readonly FlashSystem _flashSystem = default!; - [Dependency] private readonly AdminLogSystem _logSystem = default!; public override void Initialize() { diff --git a/Content.Server/Ghost/Components/GhostRadioComponent.cs b/Content.Server/Ghost/Components/GhostRadioComponent.cs index 382424b138..e612f8069a 100644 --- a/Content.Server/Ghost/Components/GhostRadioComponent.cs +++ b/Content.Server/Ghost/Components/GhostRadioComponent.cs @@ -36,7 +36,7 @@ namespace Content.Server.Ghost.Components msg.Channel = ChatChannel.Radio; msg.Message = message; //Square brackets are added here to avoid issues with escaping - msg.MessageWrap = Loc.GetString("chat-radio-message-wrap", ("channel", $"\\[{channel}\\]"), ("name", Name: _entMan.GetComponent(speaker).EntityName)); + msg.MessageWrap = Loc.GetString("chat-radio-message-wrap", ("channel", $"\\[{channel}\\]"), ("name", _entMan.GetComponent(speaker).EntityName)); _netManager.ServerSendMessage(msg, playerChannel); } diff --git a/Content.Server/Hands/Components/HandsComponent.cs b/Content.Server/Hands/Components/HandsComponent.cs index ba07419840..5cf16bb977 100644 --- a/Content.Server/Hands/Components/HandsComponent.cs +++ b/Content.Server/Hands/Components/HandsComponent.cs @@ -99,21 +99,21 @@ namespace Content.Server.Hands.Components var source = @event.Source; var target = @event.Target; - if (source != null) + if (source.Valid) { SoundSystem.Play(Filter.Pvs(source), _disarmedSound.GetSound(), source, AudioHelpers.WithVariation(0.025f)); - if (target != null) + if (target.Valid) { if (ActiveHand != null && Drop(ActiveHand, false)) { - source.PopupMessageOtherClients(Loc.GetString("hands-component-disarm-success-others-message", ("disarmer", Name: _entities.GetComponent(source).EntityName), ("disarmed", Name: _entities.GetComponent(target).EntityName))); - source.PopupMessageCursor(Loc.GetString("hands-component-disarm-success-message", ("disarmed", Name: _entities.GetComponent(target).EntityName))); + source.PopupMessageOtherClients(Loc.GetString("hands-component-disarm-success-others-message", ("disarmer", _entities.GetComponent(source).EntityName), ("disarmed", _entities.GetComponent(target).EntityName))); + source.PopupMessageCursor(Loc.GetString("hands-component-disarm-success-message", ("disarmed", _entities.GetComponent(target).EntityName))); } else { - source.PopupMessageOtherClients(Loc.GetString("hands-component-shove-success-others-message", ("shover", Name: _entities.GetComponent(source).EntityName), ("shoved", Name: _entities.GetComponent(target).EntityName))); - source.PopupMessageCursor(Loc.GetString("hands-component-shove-success-message", ("shoved", Name: _entities.GetComponent(target).EntityName))); + source.PopupMessageOtherClients(Loc.GetString("hands-component-shove-success-others-message", ("shover", _entities.GetComponent(source).EntityName), ("shoved", _entities.GetComponent(target).EntityName))); + source.PopupMessageCursor(Loc.GetString("hands-component-shove-success-message", ("shoved", _entities.GetComponent(target).EntityName))); } } } diff --git a/Content.Server/Hands/Systems/HandsSystem.cs b/Content.Server/Hands/Systems/HandsSystem.cs index 8b216ed1b4..edbb88c727 100644 --- a/Content.Server/Hands/Systems/HandsSystem.cs +++ b/Content.Server/Hands/Systems/HandsSystem.cs @@ -33,7 +33,6 @@ namespace Content.Server.Hands.Systems [UsedImplicitly] internal sealed class HandsSystem : SharedHandsSystem { - [Dependency] private readonly InteractionSystem _interactionSystem = default!; [Dependency] private readonly StackSystem _stackSystem = default!; [Dependency] private readonly HandVirtualItemSystem _virtualItemSystem = default!; [Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!; diff --git a/Content.Server/Headset/HeadsetComponent.cs b/Content.Server/Headset/HeadsetComponent.cs index 7ebed04056..5c85c1acfa 100644 --- a/Content.Server/Headset/HeadsetComponent.cs +++ b/Content.Server/Headset/HeadsetComponent.cs @@ -70,7 +70,7 @@ namespace Content.Server.Headset msg.Channel = ChatChannel.Radio; msg.Message = message; //Square brackets are added here to avoid issues with escaping - msg.MessageWrap = Loc.GetString("chat-radio-message-wrap", ("channel", $"\\[{channel}\\]"), ("name", Name: _entMan.GetComponent(source).EntityName)); + msg.MessageWrap = Loc.GetString("chat-radio-message-wrap", ("channel", $"\\[{channel}\\]"), ("name", _entMan.GetComponent(source).EntityName)); _netManager.ServerSendMessage(msg, playerChannel); } } diff --git a/Content.Server/Inventory/Components/InventoryComponent.cs b/Content.Server/Inventory/Components/InventoryComponent.cs index f0aade547d..c31eafeda2 100644 --- a/Content.Server/Inventory/Components/InventoryComponent.cs +++ b/Content.Server/Inventory/Components/InventoryComponent.cs @@ -468,7 +468,7 @@ namespace Content.Server.Inventory.Components var canEquip = CanEquip(msg.Inventoryslot, activeHand, true, out var reason); _hoverEntity = new KeyValuePair(msg.Inventoryslot, - (Uid: activeHand.Owner, canEquip)); + (activeHand.Owner, canEquip)); Dirty(); } diff --git a/Content.Server/Light/EntitySystems/LightReplacerSystem.cs b/Content.Server/Light/EntitySystems/LightReplacerSystem.cs index 77a00db063..0b4d81a21e 100644 --- a/Content.Server/Light/EntitySystems/LightReplacerSystem.cs +++ b/Content.Server/Light/EntitySystems/LightReplacerSystem.cs @@ -67,17 +67,12 @@ namespace Content.Server.Light.EntitySystems // standard interaction checks if (!_blocker.CanInteract(eventArgs.User)) return; - if (eventArgs.Used != null) - { - var usedUid = eventArgs.Used; - - // want to insert a new light bulb? - if (EntityManager.TryGetComponent(usedUid, out LightBulbComponent ? bulb)) - eventArgs.Handled = TryInsertBulb(uid, usedUid, eventArgs.User, true, component, bulb); - // add bulbs from storage? - else if (EntityManager.TryGetComponent(usedUid, out ServerStorageComponent? storage)) - eventArgs.Handled = TryInsertBulbsFromStorage(uid, usedUid, eventArgs.User, component, storage); - } + // want to insert a new light bulb? + if (EntityManager.TryGetComponent(eventArgs.Used, out LightBulbComponent ? bulb)) + eventArgs.Handled = TryInsertBulb(uid, eventArgs.Used, eventArgs.User, true, component, bulb); + // add bulbs from storage? + else if (EntityManager.TryGetComponent(eventArgs.Used, out ServerStorageComponent? storage)) + eventArgs.Handled = TryInsertBulbsFromStorage(uid, eventArgs.Used, eventArgs.User, component, storage); } /// @@ -108,7 +103,7 @@ namespace Content.Server.Light.EntitySystems (e) => EntityManager.GetComponentOrNull(e)?.Type == fixture.BulbType); // found bulb in inserted storage - if (bulb != null) + if (bulb.Valid) { // try to remove it var hasRemoved = replacer.InsertedBulbs.Remove(bulb); diff --git a/Content.Server/Lock/LockSystem.cs b/Content.Server/Lock/LockSystem.cs index 44948fd3cf..3c7aaf5730 100644 --- a/Content.Server/Lock/LockSystem.cs +++ b/Content.Server/Lock/LockSystem.cs @@ -64,7 +64,7 @@ namespace Content.Server.Lock args.PushText(Loc.GetString(lockComp.Locked ? "lock-comp-on-examined-is-locked" : "lock-comp-on-examined-is-unlocked", - ("entityName", Name: EntityManager.GetComponent(lockComp.Owner).EntityName))); + ("entityName", EntityManager.GetComponent(lockComp.Owner).EntityName))); } public bool TryLock(EntityUid uid, EntityUid user, LockComponent? lockComp = null) @@ -78,13 +78,10 @@ namespace Content.Server.Lock if (!HasUserAccess(uid, user, quiet: false)) return false; - lockComp.Owner.PopupMessage(user, Loc.GetString("lock-comp-do-lock-success", ("entityName",Name: EntityManager.GetComponent(lockComp.Owner).EntityName))); + lockComp.Owner.PopupMessage(user, Loc.GetString("lock-comp-do-lock-success", ("entityName", EntityManager.GetComponent(lockComp.Owner).EntityName))); lockComp.Locked = true; - if(lockComp.LockSound != null) - { - SoundSystem.Play(Filter.Pvs(lockComp.Owner), lockComp.LockSound.GetSound(), lockComp.Owner, AudioParams.Default.WithVolume(-5)); - } + SoundSystem.Play(Filter.Pvs(lockComp.Owner), lockComp.LockSound.GetSound(), lockComp.Owner, AudioParams.Default.WithVolume(-5)); if (EntityManager.TryGetComponent(lockComp.Owner, out AppearanceComponent? appearanceComp)) { @@ -110,10 +107,7 @@ namespace Content.Server.Lock lockComp.Owner.PopupMessage(user, Loc.GetString("lock-comp-do-unlock-success", ("entityName", Name: EntityManager.GetComponent(lockComp.Owner).EntityName))); lockComp.Locked = false; - if(lockComp.UnlockSound != null) - { - SoundSystem.Play(Filter.Pvs(lockComp.Owner), lockComp.UnlockSound.GetSound(), lockComp.Owner, AudioParams.Default.WithVolume(-5)); - } + SoundSystem.Play(Filter.Pvs(lockComp.Owner), lockComp.UnlockSound.GetSound(), lockComp.Owner, AudioParams.Default.WithVolume(-5)); if (EntityManager.TryGetComponent(lockComp.Owner, out AppearanceComponent? appearanceComp)) { diff --git a/Content.Server/Maps/GameMapManager.cs b/Content.Server/Maps/GameMapManager.cs index efabeeae3e..e7baf76595 100644 --- a/Content.Server/Maps/GameMapManager.cs +++ b/Content.Server/Maps/GameMapManager.cs @@ -21,7 +21,6 @@ public class GameMapManager : IGameMapManager [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IChatManager _chatManager = default!; - [Dependency] private readonly IMapLoader _mapLoader = default!; private GameMapPrototype _currentMap = default!; private bool _currentMapForced; diff --git a/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs b/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs index d1b4362a68..bbfdd7bd69 100644 --- a/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs @@ -263,7 +263,7 @@ namespace Content.Server.Nutrition.EntitySystems if (!drink.Opened) { _popupSystem.PopupEntity(Loc.GetString("drink-component-try-use-drink-not-open", - ("owner", Name: EntityManager.GetComponent(drink.Owner).EntityName)), uid, Filter.Entities(userUid)); + ("owner", EntityManager.GetComponent(drink.Owner).EntityName)), uid, Filter.Entities(userUid)); return true; } @@ -274,7 +274,7 @@ namespace Content.Server.Nutrition.EntitySystems drinkSolution.DrainAvailable <= 0) { _popupSystem.PopupEntity(Loc.GetString("drink-component-try-use-drink-is-empty", - ("entity", Name: EntityManager.GetComponent(drink.Owner).EntityName)), uid, Filter.Entities(userUid)); + ("entity", EntityManager.GetComponent(drink.Owner).EntityName)), uid, Filter.Entities(userUid)); return true; } @@ -345,7 +345,7 @@ namespace Content.Server.Nutrition.EntitySystems if (!drink.Opened) { _popupSystem.PopupEntity(Loc.GetString("drink-component-try-use-drink-not-open", - ("owner", Name: EntityManager.GetComponent(drink.Owner).EntityName)), uid, Filter.Entities(userUid)); + ("owner", EntityManager.GetComponent(drink.Owner).EntityName)), uid, Filter.Entities(userUid)); return true; } @@ -353,7 +353,7 @@ namespace Content.Server.Nutrition.EntitySystems drinkSolution.DrainAvailable <= 0) { _popupSystem.PopupEntity(Loc.GetString("drink-component-try-use-drink-is-empty", - ("entity", Name: EntityManager.GetComponent(drink.Owner).EntityName)), uid, Filter.Entities(userUid)); + ("entity", EntityManager.GetComponent(drink.Owner).EntityName)), uid, Filter.Entities(userUid)); return true; } diff --git a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs index 79a46755bd..10123efc6e 100644 --- a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using Content.Server.Body.Components; using Content.Server.Body.Systems; using Content.Server.Chemistry.EntitySystems; @@ -19,17 +18,13 @@ using Content.Shared.Interaction; using Content.Shared.Interaction.Helpers; using Content.Shared.Inventory; using Content.Shared.MobState.Components; -using Content.Shared.Tag; using Content.Shared.Verbs; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Player; -using System.Collections.Generic; using Robust.Shared.Utility; -using Content.Server.Inventory.Components; -using Content.Shared.Inventory; using Content.Shared.Hands; namespace Content.Server.Nutrition.EntitySystems diff --git a/Content.Server/PAI/PAISystem.cs b/Content.Server/PAI/PAISystem.cs index 0908fa117e..195e5aa519 100644 --- a/Content.Server/PAI/PAISystem.cs +++ b/Content.Server/PAI/PAISystem.cs @@ -129,7 +129,7 @@ namespace Content.Server.PAI private void AddWipeVerb(EntityUid uid, PAIComponent pai, GetActivationVerbsEvent args) { - if (args.User == null || !args.CanAccess || !args.CanInteract) + if (!args.User.Valid || !args.CanAccess || !args.CanInteract) return; if (EntityManager.TryGetComponent(uid, out var mind) && mind.HasMind) diff --git a/Content.Server/Power/EntitySystems/CableMultitoolSystem.cs b/Content.Server/Power/EntitySystems/CableMultitoolSystem.cs index bbcc87d782..de063e9a3a 100644 --- a/Content.Server/Power/EntitySystems/CableMultitoolSystem.cs +++ b/Content.Server/Power/EntitySystems/CableMultitoolSystem.cs @@ -48,7 +48,7 @@ namespace Content.Server.Power.EntitySystems var held = hand.HeldEntity; // Pulsing is hardcoded here because I don't think it needs to be more complex than that right now. // Update if I'm wrong. - if ((held != null) && _toolSystem.HasQuality(held, "Pulsing")) + if (held.Valid && _toolSystem.HasQuality(held, "Pulsing")) { args.PushMarkup(GenerateCableMarkup(uid)); // args.PushFancyUpdatingPowerGraphs(uid); diff --git a/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs b/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs index d5138ef1bc..5e8561793b 100644 --- a/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs +++ b/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs @@ -134,12 +134,9 @@ namespace Content.Server.PowerCell.Components if (cell == null || !CanRemoveCell) return null; if (!_cellContainer.Remove(cell.Owner)) return null; //Dirty(); - if (user != null) + if (!_entities.TryGetComponent(user, out HandsComponent? hands) || !hands.PutInHand(_entities.GetComponent(cell.Owner))) { - if (!_entities.TryGetComponent(user, out HandsComponent? hands) || !hands.PutInHand(_entities.GetComponent(cell.Owner))) - { - _entities.GetComponent(cell.Owner).Coordinates = _entities.GetComponent(user).Coordinates; - } + _entities.GetComponent(cell.Owner).Coordinates = _entities.GetComponent(user).Coordinates; } else { diff --git a/Content.Server/RCD/Systems/RCDSystem.cs b/Content.Server/RCD/Systems/RCDSystem.cs index a26afd0556..8a4087e1d0 100644 --- a/Content.Server/RCD/Systems/RCDSystem.cs +++ b/Content.Server/RCD/Systems/RCDSystem.cs @@ -235,7 +235,7 @@ namespace Content.Server.RCD.Systems mode = (++mode) % _modes.Length; //Then, do a rollover on the value so it doesnt hit an invalid state rcd.Mode = (RcdMode) mode; //Finally, cast the newly acquired int mode to an RCDmode so we can use it. - if (user != null) + if (user.Valid) { var msg = Loc.GetString("rcd-component-change-mode", ("mode", rcd.Mode.ToString())); rcd.Owner.PopupMessage(user, msg); //Prints an overhead message above the RCD diff --git a/Content.Server/Radio/Components/IRadio.cs b/Content.Server/Radio/Components/IRadio.cs index cb5077a8ca..cbabdcac4e 100644 --- a/Content.Server/Radio/Components/IRadio.cs +++ b/Content.Server/Radio/Components/IRadio.cs @@ -1,6 +1,5 @@ using Robust.Shared.GameObjects; using System.Collections.Generic; -using Robust.Shared.GameObjects; namespace Content.Server.Radio.Components { diff --git a/Content.Server/Storage/Components/CursedEntityStorageComponent.cs b/Content.Server/Storage/Components/CursedEntityStorageComponent.cs index 061e471b28..d4276711dd 100644 --- a/Content.Server/Storage/Components/CursedEntityStorageComponent.cs +++ b/Content.Server/Storage/Components/CursedEntityStorageComponent.cs @@ -39,7 +39,7 @@ namespace Content.Server.Storage.Components var lockerEnt = _robustRandom.Pick(lockers); - if (lockerEnt == null) return; // No valid lockers anywhere. + if (!lockerEnt.Valid) return; // No valid lockers anywhere. var locker = _entMan.GetComponent(lockerEnt); diff --git a/Content.Server/Stunnable/StunSystem.cs b/Content.Server/Stunnable/StunSystem.cs index c7c0a47baf..ebefa243f5 100644 --- a/Content.Server/Stunnable/StunSystem.cs +++ b/Content.Server/Stunnable/StunSystem.cs @@ -40,16 +40,16 @@ namespace Content.Server.Stunnable var source = args.Source; var target = args.Target; - if (source != null) + if (source.Valid) { var knock = EntityManager.GetComponent(uid); SoundSystem.Play(Filter.Pvs(source), knock.StunAttemptSound.GetSound(), source, AudioHelpers.WithVariation(0.025f)); - if (target != null) + if (target.Valid) { // TODO: Use PopupSystem - source.PopupMessageOtherClients(Loc.GetString("stunned-component-disarm-success-others", ("source", Name: EntityManager.GetComponent(source).EntityName), ("target", Name: EntityManager.GetComponent(target).EntityName))); - source.PopupMessageCursor(Loc.GetString("stunned-component-disarm-success", ("target", Name: EntityManager.GetComponent(target).EntityName))); + source.PopupMessageOtherClients(Loc.GetString("stunned-component-disarm-success-others", ("source", EntityManager.GetComponent(source).EntityName), ("target", EntityManager.GetComponent(target).EntityName))); + source.PopupMessageCursor(Loc.GetString("stunned-component-disarm-success", ("target", EntityManager.GetComponent(target).EntityName))); } } diff --git a/Content.Server/Suspicion/SuspicionRoleComponent.cs b/Content.Server/Suspicion/SuspicionRoleComponent.cs index df51ff8537..925f08c794 100644 --- a/Content.Server/Suspicion/SuspicionRoleComponent.cs +++ b/Content.Server/Suspicion/SuspicionRoleComponent.cs @@ -161,7 +161,7 @@ namespace Content.Server.Suspicion continue; } - allies.Add((role.Role!.Mind.CharacterName, Uid: role.Owner)); + allies.Add((role.Role!.Mind.CharacterName, role.Owner)); } return new SuspicionRoleComponentState(Role?.Name, Role?.Antagonist, allies.ToArray()); diff --git a/Content.Server/Toilet/ToiletComponent.cs b/Content.Server/Toilet/ToiletComponent.cs index b44f600799..1530acd599 100644 --- a/Content.Server/Toilet/ToiletComponent.cs +++ b/Content.Server/Toilet/ToiletComponent.cs @@ -40,7 +40,7 @@ namespace Content.Server.Toilet private const float PryLidTime = 1f; - private bool _isPrying = false; + private bool _isPrying; [DataField("pryingQuality", customTypeSerializer:typeof(PrototypeIdSerializer))] private string _pryingQuality = "Prying"; @@ -157,20 +157,20 @@ namespace Content.Server.Toilet if (_entMan.TryGetComponent(victim, out var body) && body.HasPartOfType(BodyPartType.Head)) { - var othersMessage = Loc.GetString("toilet-component-suicide-head-message-others", ("victim",Name: _entMan.GetComponent(victim).EntityName),("owner", Name: _entMan.GetComponent(Owner).EntityName)); + var othersMessage = Loc.GetString("toilet-component-suicide-head-message-others", ("victim", _entMan.GetComponent(victim).EntityName),("owner", _entMan.GetComponent(Owner).EntityName)); victim.PopupMessageOtherClients(othersMessage); - var selfMessage = Loc.GetString("toilet-component-suicide-head-message", ("owner", Name: _entMan.GetComponent(Owner).EntityName)); + var selfMessage = Loc.GetString("toilet-component-suicide-head-message", ("owner", _entMan.GetComponent(Owner).EntityName)); victim.PopupMessage(selfMessage); return SuicideKind.Asphyxiation; } else { - var othersMessage = Loc.GetString("toilet-component-suicide-message-others",("victim", Name: _entMan.GetComponent(victim).EntityName),("owner", Name: _entMan.GetComponent(Owner).EntityName)); + var othersMessage = Loc.GetString("toilet-component-suicide-message-others",("victim", _entMan.GetComponent(victim).EntityName),("owner", _entMan.GetComponent(Owner).EntityName)); victim.PopupMessageOtherClients(othersMessage); - var selfMessage = Loc.GetString("toilet-component-suicide-message", ("owner",Name: _entMan.GetComponent(Owner).EntityName)); + var selfMessage = Loc.GetString("toilet-component-suicide-message", ("owner", _entMan.GetComponent(Owner).EntityName)); victim.PopupMessage(selfMessage); return SuicideKind.Blunt; diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs index dc6012d76b..6e2cebee3a 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs @@ -270,7 +270,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components return false; } - public bool UseEntity(UseEntityEventArgs eventArgs) + bool IUse.UseEntity(UseEntityEventArgs eventArgs) { if (BoltOpen) { @@ -284,7 +284,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components return true; } - public async Task InteractUsing(InteractUsingEventArgs eventArgs) + async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { return TryInsertBullet(eventArgs.User, eventArgs.Using); } diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs index 6b90cf9917..ceb555cd1d 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs @@ -226,13 +226,13 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components return false; } - public bool UseEntity(UseEntityEventArgs eventArgs) + bool IUse.UseEntity(UseEntityEventArgs eventArgs) { Cycle(true); return true; } - public async Task InteractUsing(InteractUsingEventArgs eventArgs) + async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { return TryInsertBullet(eventArgs); } diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs index 6966a64f88..96e8c3768f 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs @@ -252,7 +252,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components /// /// /// - public bool UseEntity(UseEntityEventArgs eventArgs) + bool IUse.UseEntity(UseEntityEventArgs eventArgs) { EjectAllSlots(); Dirty(); @@ -260,7 +260,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components return true; } - public async Task InteractUsing(InteractUsingEventArgs eventArgs) + async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { return TryInsertBullet(eventArgs.User, eventArgs.Using); } diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs index 7e0a30b51f..fca9faee5f 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs @@ -248,7 +248,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components _appearanceComponent?.SetData(AmmoVisuals.AmmoMax, Capacity); } - public bool UseEntity(UseEntityEventArgs eventArgs) + bool IUse.UseEntity(UseEntityEventArgs eventArgs) { // Behavior: // If bolt open just close it @@ -305,7 +305,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components _chamberContainer.Insert(nextRound); - if (_autoEjectMag && magazine != null && _entities.GetComponent(magazine).ShotsLeft == 0) + if (_autoEjectMag && magazine.Valid && _entities.GetComponent(magazine).ShotsLeft == 0) { SoundSystem.Play(Filter.Pvs(Owner), _soundAutoEject.GetSound(), Owner, AudioParams.Default.WithVolume(-2)); @@ -391,7 +391,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components UpdateAppearance(); } - public async Task InteractUsing(InteractUsingEventArgs eventArgs) + async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { if (CanInsertMagazine(eventArgs.User, eventArgs.Using, quiet: false)) { diff --git a/Content.Shared/Body/Components/SharedBodyComponent.cs b/Content.Shared/Body/Components/SharedBodyComponent.cs index 1cac1d8605..df7d7a7b41 100644 --- a/Content.Shared/Body/Components/SharedBodyComponent.cs +++ b/Content.Shared/Body/Components/SharedBodyComponent.cs @@ -468,7 +468,7 @@ namespace Content.Shared.Body.Components var i = 0; foreach (var (part, slot) in SlotParts) { - parts[i] = (slot.Id, Owner: part.Owner); + parts[i] = (slot.Id, part.Owner); i++; } diff --git a/Content.Shared/Hands/Components/SharedHandsComponent.cs b/Content.Shared/Hands/Components/SharedHandsComponent.cs index 67028d1353..82c2b6dc24 100644 --- a/Content.Shared/Hands/Components/SharedHandsComponent.cs +++ b/Content.Shared/Hands/Components/SharedHandsComponent.cs @@ -111,9 +111,6 @@ namespace Content.Shared.Hands.Components var hands = new List(); foreach (var hand in Hands) { - if (hand.HeldEntity == null) - continue; - if (!entMan.TryGetComponent(hand.HeldEntity, out SharedItemComponent? item) || item.RsiPath == null) continue; @@ -233,8 +230,8 @@ namespace Content.Shared.Hands.Components public bool TryGetActiveHeldEntity(out EntityUid heldEntity) { - heldEntity = GetActiveHand()?.HeldEntity ?? default; - return heldEntity != null; + heldEntity = GetActiveHand()?.HeldEntity ?? EntityUid.Invalid; + return !heldEntity.Valid; } public bool IsHolding(EntityUid entity) @@ -415,7 +412,7 @@ namespace Content.Shared.Hands.Components /// private bool CanRemoveHeldEntityFromHand(Hand hand) { - if (hand.HeldEntity == null) + if (!hand.HeldEntity.Valid) return false; var heldEntity = hand.HeldEntity; @@ -446,7 +443,7 @@ namespace Content.Shared.Hands.Components /// private void RemoveHeldEntityFromHand(Hand hand) { - if (hand.HeldEntity == null) + if (!hand.HeldEntity.Valid) return; var heldEntity = hand.HeldEntity; @@ -537,7 +534,7 @@ namespace Content.Shared.Hands.Components private bool CanPutHeldEntityIntoContainer(Hand hand, IContainer targetContainer, bool checkActionBlocker) { - if (hand.HeldEntity == null) + if (!hand.HeldEntity.Valid) return false; var heldEntity = hand.HeldEntity; @@ -556,7 +553,7 @@ namespace Content.Shared.Hands.Components /// private void PutHeldEntityIntoContainer(Hand hand, IContainer targetContainer) { - if (hand.HeldEntity == null) + if (!hand.HeldEntity.Valid) return; var heldEntity = hand.HeldEntity; diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index 3b64493d67..7a83056741 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -650,7 +650,7 @@ namespace Content.Shared.Interaction /// public void TryUseInteraction(EntityUid user, EntityUid used, bool altInteract = false) { - if (user != null && used != null && _actionBlockerSystem.CanUse(user)) + if (user.Valid && used.Valid && _actionBlockerSystem.CanUse(user)) { if (altInteract) AltInteract(user, used); @@ -820,7 +820,7 @@ namespace Content.Shared.Interaction /// public bool TryDroppedInteraction(EntityUid user, EntityUid item) { - if (user == null || item == null || !_actionBlockerSystem.CanDrop(user)) return false; + if (!user.Valid || !item.Valid || !_actionBlockerSystem.CanDrop(user)) return false; DroppedInteraction(user, item); return true; diff --git a/Content.Shared/Standing/StandingStateSystem.cs b/Content.Shared/Standing/StandingStateSystem.cs index 4e551dedae..89bb1d7da2 100644 --- a/Content.Shared/Standing/StandingStateSystem.cs +++ b/Content.Shared/Standing/StandingStateSystem.cs @@ -12,8 +12,6 @@ namespace Content.Shared.Standing { public sealed class StandingStateSystem : EntitySystem { - [Dependency] private readonly SharedHandsSystem _sharedHandsSystem = default!; - public bool IsDown(EntityUid uid, StandingStateComponent? standingState = null) { if (!Resolve(uid, ref standingState, false))