diff --git a/Content.Client/AI/ClientPathfindingDebugSystem.cs b/Content.Client/AI/ClientPathfindingDebugSystem.cs index b796dafed1..1068bcae54 100644 --- a/Content.Client/AI/ClientPathfindingDebugSystem.cs +++ b/Content.Client/AI/ClientPathfindingDebugSystem.cs @@ -18,6 +18,7 @@ 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 417059745a..247ce80b95 100644 --- a/Content.Client/Body/UI/BodyScannerBoundUserInterface.cs +++ b/Content.Client/Body/UI/BodyScannerBoundUserInterface.cs @@ -14,6 +14,9 @@ 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() @@ -40,7 +43,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(scannerState.Uid); + _display?.UpdateDisplay(_entity); } protected override void Dispose(bool disposing) diff --git a/Content.Client/Body/UI/BodyScannerDisplay.cs b/Content.Client/Body/UI/BodyScannerDisplay.cs index 4f81434264..852527014e 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.Valid) + if(entity == null) return; _currentEntity = entity; @@ -125,7 +125,12 @@ namespace Content.Client.Body.UI public void BodyPartOnItemSelected(ItemListSelectedEventArgs args) { - if (IoCManager.Resolve().TryGetComponent(_currentEntity, out var body)) + if (_currentEntity == null) + return; + + var body = IoCManager.Resolve().GetComponentOrNull(_currentEntity); + + if (body == null) { return; } diff --git a/Content.Client/ContextMenu/UI/EntityMenuPresenter.cs b/Content.Client/ContextMenu/UI/EntityMenuPresenter.cs index 22c3b7af84..033e23b333 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.Valid) + if (entity == null) { // 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 bbd20d1612..5a8169b957 100644 --- a/Content.Client/Decals/DecalOverlay.cs +++ b/Content.Client/Decals/DecalOverlay.cs @@ -4,8 +4,10 @@ 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 1895a5fabf..abe5f35685 100644 --- a/Content.Client/Hands/HandsGui.xaml.cs +++ b/Content.Client/Hands/HandsGui.xaml.cs @@ -99,7 +99,8 @@ namespace Content.Client.Hands _itemSlotManager.SetItemSlot(newButton, hand.HeldItem); // Show blocked overlay if hand is blocked. - newButton.Blocked.Visible = IoCManager.Resolve().HasComponent(hand.HeldItem); + newButton.Blocked.Visible = + hand.HeldItem != null && 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 2c4884d301..dee8e4f03c 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", IoCManager.Resolve().GetComponent(Owner.Owner).EntityName))}"); + _strippingMenu = new StrippingMenu($"{Loc.GetString("strippable-bound-user-interface-stripping-menu-title",("ownerName", Name: 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 fb7c928529..485e9b9070 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", entities.GetComponent(state.Entity.Value).EntityName))}\n"); + text.Append($"{Loc.GetString("medical-scanner-window-entity-health-text", ("entityName", Name: 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 2550656763..8594dc5eb7 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 (!IoCManager.Resolve().HasComponent(entity)) + if (entity == null || !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 8b99a3ce9d..0c92ca875a 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.Valid) + if (lastStorage == null) { 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 54114f20af..18ffa4ac79 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.Valid || !EntitySystem.Get().CanMove(self)) + if (self == null || !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 cc8f0fe797..6c5c317bed 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 (!IoCManager.Resolve().TryGetComponent(target, out MeleeWeaponComponent? meleeWeaponComponent)) + if (target == null || !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 1d48a9fdb8..60a383e9cb 100644 --- a/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponEquippedCon.cs +++ b/Content.Server/AI/Utility/Considerations/Combat/Melee/MeleeWeaponEquippedCon.cs @@ -10,10 +10,14 @@ namespace Content.Server.AI.Utility.Considerations.Combat.Melee { protected override float GetScore(Blackboard context) { - return IoCManager.Resolve() - .HasComponent(context.GetState().GetValue()) - ? 1.0f - : 0.0f; + var equipped = context.GetState().GetValue(); + + if (equipped == null) + { + return 0.0f; + } + + return IoCManager.Resolve().HasComponent(equipped) ? 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 1ab36c3b9f..d84c977509 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 (!IoCManager.Resolve().TryGetComponent(target, out MeleeWeaponComponent? meleeWeaponComponent)) + if (target == null || !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 95b7a2c37a..47f23d0f41 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 (!IoCManager.Resolve().TryGetComponent(target, out DamageableComponent? damageableComponent)) + if (target == null || !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 7a62879524..37b3f99552 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 (!IoCManager.Resolve().TryGetComponent(target, out MobStateComponent? mobState)) + if (target == null || !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 4ccc3d7190..26622c9723 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 (!IoCManager.Resolve().TryGetComponent(target, out MobStateComponent? mobState)) + if (target == null || !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 371896c161..ebed8d3c34 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.Valid) + if (owner == null) { return 0; } diff --git a/Content.Server/AI/Utility/Considerations/Hands/FreeHandCon.cs b/Content.Server/AI/Utility/Considerations/Hands/FreeHandCon.cs index e2e82b30fe..029775d5f3 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 (!IoCManager.Resolve().TryGetComponent(owner, out HandsComponent? handsComponent)) + if (owner == null || !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 8c98253d6a..14ccfbf4d2 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 (!IoCManager.Resolve().HasComponent(target)) + if (target == null || !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 5d5bb917b6..b7fcd97b1c 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 (!IoCManager.Resolve().HasComponent(target)) + if (target == null || !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 9a0b16ece6..e7a7fbc5ca 100644 --- a/Content.Server/AI/Utility/Considerations/Nutrition/Drink/DrinkValueCon.cs +++ b/Content.Server/AI/Utility/Considerations/Nutrition/Drink/DrinkValueCon.cs @@ -13,7 +13,8 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Drink { var target = context.GetState().GetValue(); - if (IoCManager.Resolve().Deleted(target) + if (target == null + || 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 b90f80bdae..6ea21c75db 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 (!IoCManager.Resolve().TryGetComponent(owner, out ThirstComponent? thirst)) + if (owner == null || !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 28b003f2a8..3341d8a193 100644 --- a/Content.Server/AI/Utility/Considerations/Nutrition/Food/FoodValueCon.cs +++ b/Content.Server/AI/Utility/Considerations/Nutrition/Food/FoodValueCon.cs @@ -13,9 +13,8 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Food { var target = context.GetState().GetValue(); - if (!IoCManager.Resolve().TryGetComponent(target, out var foodComp) - || !EntitySystem.Get() - .TryGetSolution(target, foodComp.SolutionName, out var food)) + if (target == null || !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 29a0157683..33cc9dca90 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 (!IoCManager.Resolve().TryGetComponent(owner, out HungerComponent? hunger)) + if (owner == null || !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 28b80f6f5a..17c41986ae 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().Valid ? 0.0f : 1.0f; + return state.GetValue() == null ? 1.0f : 0.0f; } } } diff --git a/Content.Server/AI/Utility/NpcBehaviorManager.cs b/Content.Server/AI/Utility/NpcBehaviorManager.cs index ef1513797c..f1760ef3e2 100644 --- a/Content.Server/AI/Utility/NpcBehaviorManager.cs +++ b/Content.Server/AI/Utility/NpcBehaviorManager.cs @@ -28,6 +28,7 @@ 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 7e9ac324a6..0fb7209a16 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", entMan.GetComponent(args.Performer).EntityName), - ("targetName", entMan.GetComponent(args.Target).EntityName))); + ("performerName", Name: entMan.GetComponent(args.Performer).EntityName), + ("targetName", Name: entMan.GetComponent(args.Target).EntityName))); args.Performer.PopupMessageCursor(Loc.GetString("disarm-action-popup-message-cursor", - ("targetName", entMan.GetComponent(args.Target).EntityName))); + ("targetName", Name: 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 8921d7d986..4a481f0195 100644 --- a/Content.Server/Atmos/EntitySystems/AirtightSystem.cs +++ b/Content.Server/Atmos/EntitySystems/AirtightSystem.cs @@ -14,6 +14,7 @@ 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 1b8c60e87d..ec5f538c4c 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", _entities.GetComponent(Owner).EntityName))); + Loc.GetString("mechanism-component-no-way-to-install-message", ("partName", Name: _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", _entities.GetComponent(Owner).EntityName))); + Loc.GetString("mechanism-component-no-useful-way-to-use-message",("partName", Name: _entities.GetComponent(Owner).EntityName))); return; } diff --git a/Content.Server/Body/Systems/LungSystem.cs b/Content.Server/Body/Systems/LungSystem.cs index 0f002de83d..c68392d01b 100644 --- a/Content.Server/Body/Systems/LungSystem.cs +++ b/Content.Server/Body/Systems/LungSystem.cs @@ -115,6 +115,8 @@ 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 a5d74ac2cf..9c15a5e5ab 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", _entMan.GetComponent(Owner).EntityName))); + ("name", 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", _entMan.GetComponent(Owner).EntityName))); + ("name", Name: _entMan.GetComponent(Owner).EntityName))); user.PopupMessageOtherClients(Loc.GetString("plant-holder-component-remove-weeds-others-message", - ("otherName", _entMan.GetComponent(user).EntityName))); + ("otherName", Name: _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", _entMan.GetComponent(Owner).EntityName))); + ("name", Name: _entMan.GetComponent(Owner).EntityName))); user.PopupMessageOtherClients(Loc.GetString("plant-holder-component-remove-plant-others-message", - ("name", _entMan.GetComponent(user).EntityName))); + ("name", Name: _entMan.GetComponent(user).EntityName))); RemovePlant(); } else diff --git a/Content.Server/Botany/Components/SeedExtractorComponent.cs b/Content.Server/Botany/Components/SeedExtractorComponent.cs index 82b1d1825d..c2a95b37ce 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", _entMan.GetComponent(eventArgs.Using).EntityName))); + eventArgs.User.PopupMessageCursor(Loc.GetString("seed-extractor-component-interact-message",("name", 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 56995c40c5..c9123aac14 100644 --- a/Content.Server/Botany/Seed.cs +++ b/Content.Server/Botany/Seed.cs @@ -280,7 +280,8 @@ namespace Content.Server.Botany public IEnumerable AutoHarvest(EntityCoordinates position, int yieldMod = 1) { - if (position.IsValid(IoCManager.Resolve()) && ProductPrototypes.Count > 0) + if (position.IsValid(IoCManager.Resolve()) && ProductPrototypes != null && + ProductPrototypes.Count > 0) return GenerateProduct(position, yieldMod); return Enumerable.Empty(); @@ -290,10 +291,10 @@ namespace Content.Server.Botany { AddToDatabase(); - if (!user.Valid) + if (user == null) return Enumerable.Empty(); - if (ProductPrototypes.Count == 0 || Yield <= 0) + if (ProductPrototypes == null || ProductPrototypes.Count == 0 || Yield <= 0) { user.PopupMessageCursor(Loc.GetString("botany-harvest-fail-message")); return Enumerable.Empty(); @@ -311,8 +312,14 @@ namespace Content.Server.Botany if (yieldMod < 0) { yieldMod = 1; + totalYield = Yield; } - totalYield = Math.Max(1, Yield * yieldMod); + else + { + totalYield = Yield * yieldMod; + } + + totalYield = Math.Max(1, totalYield); } var random = IoCManager.Resolve(); diff --git a/Content.Server/Chat/Managers/ChatManager.cs b/Content.Server/Chat/Managers/ChatManager.cs index e050fee103..02cb35f2f4 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", _entManager.GetComponent(source).EntityName)); + msg.MessageWrap = Loc.GetString("chat-manager-entity-say-wrap-message",("entityName", Name: _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", _entManager.GetComponent(source).EntityName)); + msg.MessageWrap = Loc.GetString("chat-manager-entity-me-wrap-message", ("entityName",Name: _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 84db4dba7c..4dcb0c58cc 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 (!_entities.HasComponent(dragged)) + if (target == null || !_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 e193e979fc..89d795852d 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.Valid || !args.CanAccess || !args.CanInteract) + if (args.User == null || !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 4a597d6807..db5c289747 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) - args.PushMarkup(Loc.GetString("construction-examine-condition-airlock-bolt", ("entityName", entMan.GetComponent(entity).EntityName)) + "\n"); + if (Value == true) + args.PushMarkup(Loc.GetString("construction-examine-condition-airlock-bolt", ("entityName", Name: entMan.GetComponent(entity).EntityName)) + "\n"); else - args.PushMarkup(Loc.GetString("construction-examine-condition-airlock-unbolt", ("entityName", entMan.GetComponent(entity).EntityName)) + "\n"); + args.PushMarkup(Loc.GetString("construction-examine-condition-airlock-unbolt", ("entityName", Name: entMan.GetComponent(entity).EntityName)) + "\n"); return true; } diff --git a/Content.Server/Construction/Conditions/DoorWelded.cs b/Content.Server/Construction/Conditions/DoorWelded.cs index 817cecb599..2ba8f99c92 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", entMan.GetComponent(entity).EntityName)) + "\n"); + args.PushMarkup(Loc.GetString("construction-examine-condition-door-weld", ("entityName", Name: entMan.GetComponent(entity).EntityName)) + "\n"); else - args.PushMarkup(Loc.GetString("construction-examine-condition-door-unweld", ("entityName", entMan.GetComponent(entity).EntityName)) + "\n"); + args.PushMarkup(Loc.GetString("construction-examine-condition-door-unweld", ("entityName", Name: 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 7548a8cb4e..54c63038c8 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.Valid) + if (player == null) { return false; } diff --git a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs index ce20a1d209..a282d38b30 100644 --- a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs +++ b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs @@ -39,6 +39,7 @@ 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 e612f8069a..382424b138 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", _entMan.GetComponent(speaker).EntityName)); + msg.MessageWrap = Loc.GetString("chat-radio-message-wrap", ("channel", $"\\[{channel}\\]"), ("name", 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 5cf16bb977..ba07419840 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.Valid) + if (source != null) { SoundSystem.Play(Filter.Pvs(source), _disarmedSound.GetSound(), source, AudioHelpers.WithVariation(0.025f)); - if (target.Valid) + if (target != null) { if (ActiveHand != null && Drop(ActiveHand, false)) { - 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))); + 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))); } else { - 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))); + 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))); } } } diff --git a/Content.Server/Hands/Systems/HandsSystem.cs b/Content.Server/Hands/Systems/HandsSystem.cs index edbb88c727..8b216ed1b4 100644 --- a/Content.Server/Hands/Systems/HandsSystem.cs +++ b/Content.Server/Hands/Systems/HandsSystem.cs @@ -33,6 +33,7 @@ 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 5c85c1acfa..7ebed04056 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", _entMan.GetComponent(source).EntityName)); + msg.MessageWrap = Loc.GetString("chat-radio-message-wrap", ("channel", $"\\[{channel}\\]"), ("name", 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 c31eafeda2..f0aade547d 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, - (activeHand.Owner, canEquip)); + (Uid: activeHand.Owner, canEquip)); Dirty(); } diff --git a/Content.Server/Light/EntitySystems/LightReplacerSystem.cs b/Content.Server/Light/EntitySystems/LightReplacerSystem.cs index 0b4d81a21e..77a00db063 100644 --- a/Content.Server/Light/EntitySystems/LightReplacerSystem.cs +++ b/Content.Server/Light/EntitySystems/LightReplacerSystem.cs @@ -67,12 +67,17 @@ namespace Content.Server.Light.EntitySystems // standard interaction checks if (!_blocker.CanInteract(eventArgs.User)) return; - // 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); + 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); + } } /// @@ -103,7 +108,7 @@ namespace Content.Server.Light.EntitySystems (e) => EntityManager.GetComponentOrNull(e)?.Type == fixture.BulbType); // found bulb in inserted storage - if (bulb.Valid) + if (bulb != null) { // 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 3c7aaf5730..44948fd3cf 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", EntityManager.GetComponent(lockComp.Owner).EntityName))); + ("entityName", Name: EntityManager.GetComponent(lockComp.Owner).EntityName))); } public bool TryLock(EntityUid uid, EntityUid user, LockComponent? lockComp = null) @@ -78,10 +78,13 @@ namespace Content.Server.Lock if (!HasUserAccess(uid, user, quiet: false)) return false; - lockComp.Owner.PopupMessage(user, Loc.GetString("lock-comp-do-lock-success", ("entityName", EntityManager.GetComponent(lockComp.Owner).EntityName))); + lockComp.Owner.PopupMessage(user, Loc.GetString("lock-comp-do-lock-success", ("entityName",Name: EntityManager.GetComponent(lockComp.Owner).EntityName))); lockComp.Locked = true; - SoundSystem.Play(Filter.Pvs(lockComp.Owner), lockComp.LockSound.GetSound(), lockComp.Owner, AudioParams.Default.WithVolume(-5)); + if(lockComp.LockSound != null) + { + SoundSystem.Play(Filter.Pvs(lockComp.Owner), lockComp.LockSound.GetSound(), lockComp.Owner, AudioParams.Default.WithVolume(-5)); + } if (EntityManager.TryGetComponent(lockComp.Owner, out AppearanceComponent? appearanceComp)) { @@ -107,7 +110,10 @@ 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; - SoundSystem.Play(Filter.Pvs(lockComp.Owner), lockComp.UnlockSound.GetSound(), lockComp.Owner, AudioParams.Default.WithVolume(-5)); + if(lockComp.UnlockSound != null) + { + 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 e7baf76595..efabeeae3e 100644 --- a/Content.Server/Maps/GameMapManager.cs +++ b/Content.Server/Maps/GameMapManager.cs @@ -21,6 +21,7 @@ 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 bbfdd7bd69..d1b4362a68 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", EntityManager.GetComponent(drink.Owner).EntityName)), uid, Filter.Entities(userUid)); + ("owner", Name: 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", EntityManager.GetComponent(drink.Owner).EntityName)), uid, Filter.Entities(userUid)); + ("entity", Name: 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", EntityManager.GetComponent(drink.Owner).EntityName)), uid, Filter.Entities(userUid)); + ("owner", Name: 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", EntityManager.GetComponent(drink.Owner).EntityName)), uid, Filter.Entities(userUid)); + ("entity", Name: 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 10123efc6e..79a46755bd 100644 --- a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using Content.Server.Body.Components; using Content.Server.Body.Systems; using Content.Server.Chemistry.EntitySystems; @@ -18,13 +19,17 @@ 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 195e5aa519..0908fa117e 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.Valid || !args.CanAccess || !args.CanInteract) + if (args.User == null || !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 de063e9a3a..bbcc87d782 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.Valid && _toolSystem.HasQuality(held, "Pulsing")) + if ((held != null) && _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 5e8561793b..d5138ef1bc 100644 --- a/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs +++ b/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs @@ -134,9 +134,12 @@ namespace Content.Server.PowerCell.Components if (cell == null || !CanRemoveCell) return null; if (!_cellContainer.Remove(cell.Owner)) return null; //Dirty(); - if (!_entities.TryGetComponent(user, out HandsComponent? hands) || !hands.PutInHand(_entities.GetComponent(cell.Owner))) + if (user != null) { - _entities.GetComponent(cell.Owner).Coordinates = _entities.GetComponent(user).Coordinates; + if (!_entities.TryGetComponent(user, out HandsComponent? hands) || !hands.PutInHand(_entities.GetComponent(cell.Owner))) + { + _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 8a4087e1d0..a26afd0556 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.Valid) + if (user != null) { 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 cbabdcac4e..cb5077a8ca 100644 --- a/Content.Server/Radio/Components/IRadio.cs +++ b/Content.Server/Radio/Components/IRadio.cs @@ -1,5 +1,6 @@ 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 d4276711dd..061e471b28 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.Valid) return; // No valid lockers anywhere. + if (lockerEnt == null) 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 ebefa243f5..c7c0a47baf 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.Valid) + if (source != null) { var knock = EntityManager.GetComponent(uid); SoundSystem.Play(Filter.Pvs(source), knock.StunAttemptSound.GetSound(), source, AudioHelpers.WithVariation(0.025f)); - if (target.Valid) + if (target != null) { // TODO: Use PopupSystem - 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))); + 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))); } } diff --git a/Content.Server/Suspicion/SuspicionRoleComponent.cs b/Content.Server/Suspicion/SuspicionRoleComponent.cs index 925f08c794..df51ff8537 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, role.Owner)); + allies.Add((role.Role!.Mind.CharacterName, Uid: 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 1530acd599..b44f600799 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; + private bool _isPrying = false; [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", _entMan.GetComponent(victim).EntityName),("owner", _entMan.GetComponent(Owner).EntityName)); + var othersMessage = Loc.GetString("toilet-component-suicide-head-message-others", ("victim",Name: _entMan.GetComponent(victim).EntityName),("owner", Name: _entMan.GetComponent(Owner).EntityName)); victim.PopupMessageOtherClients(othersMessage); - var selfMessage = Loc.GetString("toilet-component-suicide-head-message", ("owner", _entMan.GetComponent(Owner).EntityName)); + var selfMessage = Loc.GetString("toilet-component-suicide-head-message", ("owner", Name: _entMan.GetComponent(Owner).EntityName)); victim.PopupMessage(selfMessage); return SuicideKind.Asphyxiation; } else { - var othersMessage = Loc.GetString("toilet-component-suicide-message-others",("victim", _entMan.GetComponent(victim).EntityName),("owner", _entMan.GetComponent(Owner).EntityName)); + var othersMessage = Loc.GetString("toilet-component-suicide-message-others",("victim", Name: _entMan.GetComponent(victim).EntityName),("owner", Name: _entMan.GetComponent(Owner).EntityName)); victim.PopupMessageOtherClients(othersMessage); - var selfMessage = Loc.GetString("toilet-component-suicide-message", ("owner", _entMan.GetComponent(Owner).EntityName)); + var selfMessage = Loc.GetString("toilet-component-suicide-message", ("owner",Name: _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 6e2cebee3a..dc6012d76b 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; } - bool IUse.UseEntity(UseEntityEventArgs eventArgs) + public bool UseEntity(UseEntityEventArgs eventArgs) { if (BoltOpen) { @@ -284,7 +284,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components return true; } - async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) + public async Task 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 ceb555cd1d..6b90cf9917 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; } - bool IUse.UseEntity(UseEntityEventArgs eventArgs) + public bool UseEntity(UseEntityEventArgs eventArgs) { Cycle(true); return true; } - async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) + public async Task 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 96e8c3768f..6966a64f88 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 /// /// /// - bool IUse.UseEntity(UseEntityEventArgs eventArgs) + public bool UseEntity(UseEntityEventArgs eventArgs) { EjectAllSlots(); Dirty(); @@ -260,7 +260,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components return true; } - async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) + public async Task 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 fca9faee5f..7e0a30b51f 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); } - bool IUse.UseEntity(UseEntityEventArgs eventArgs) + public bool 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.Valid && _entities.GetComponent(magazine).ShotsLeft == 0) + if (_autoEjectMag && magazine != null && _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(); } - async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) + public async Task 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 df7d7a7b41..1cac1d8605 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, part.Owner); + parts[i] = (slot.Id, Owner: part.Owner); i++; } diff --git a/Content.Shared/Hands/Components/SharedHandsComponent.cs b/Content.Shared/Hands/Components/SharedHandsComponent.cs index 82c2b6dc24..67028d1353 100644 --- a/Content.Shared/Hands/Components/SharedHandsComponent.cs +++ b/Content.Shared/Hands/Components/SharedHandsComponent.cs @@ -111,6 +111,9 @@ 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; @@ -230,8 +233,8 @@ namespace Content.Shared.Hands.Components public bool TryGetActiveHeldEntity(out EntityUid heldEntity) { - heldEntity = GetActiveHand()?.HeldEntity ?? EntityUid.Invalid; - return !heldEntity.Valid; + heldEntity = GetActiveHand()?.HeldEntity ?? default; + return heldEntity != null; } public bool IsHolding(EntityUid entity) @@ -412,7 +415,7 @@ namespace Content.Shared.Hands.Components /// private bool CanRemoveHeldEntityFromHand(Hand hand) { - if (!hand.HeldEntity.Valid) + if (hand.HeldEntity == null) return false; var heldEntity = hand.HeldEntity; @@ -443,7 +446,7 @@ namespace Content.Shared.Hands.Components /// private void RemoveHeldEntityFromHand(Hand hand) { - if (!hand.HeldEntity.Valid) + if (hand.HeldEntity == null) return; var heldEntity = hand.HeldEntity; @@ -534,7 +537,7 @@ namespace Content.Shared.Hands.Components private bool CanPutHeldEntityIntoContainer(Hand hand, IContainer targetContainer, bool checkActionBlocker) { - if (!hand.HeldEntity.Valid) + if (hand.HeldEntity == null) return false; var heldEntity = hand.HeldEntity; @@ -553,7 +556,7 @@ namespace Content.Shared.Hands.Components /// private void PutHeldEntityIntoContainer(Hand hand, IContainer targetContainer) { - if (!hand.HeldEntity.Valid) + if (hand.HeldEntity == null) return; var heldEntity = hand.HeldEntity; diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index 7a83056741..3b64493d67 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.Valid && used.Valid && _actionBlockerSystem.CanUse(user)) + if (user != null && used != null && _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.Valid || !item.Valid || !_actionBlockerSystem.CanDrop(user)) return false; + if (user == null || item == null || !_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 89bb1d7da2..4e551dedae 100644 --- a/Content.Shared/Standing/StandingStateSystem.cs +++ b/Content.Shared/Standing/StandingStateSystem.cs @@ -12,6 +12,8 @@ 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))