From 525297c5fe49b4380d083c09b675e38c45c1efc9 Mon Sep 17 00:00:00 2001 From: metalgearsloth Date: Mon, 6 Dec 2021 15:39:46 +1100 Subject: [PATCH] A bunch of AttachedEntity bullshit --- .../Components/Mobs/ActionsComponentTests.cs | 6 ++--- .../Components/Mobs/AlertsComponentTests.cs | 8 +++--- .../Tests/PDA/PDAExtensionsTests.cs | 4 +-- .../Actions/Commands/CooldownAction.cs | 6 ++--- .../Actions/Commands/GrantAction.cs | 4 +-- .../Actions/Commands/RevokeAction.cs | 4 +-- Content.Server/Administration/AdminSystem.cs | 4 +-- .../Administration/Commands/AGhost.cs | 4 +-- .../Commands/RejuvenateCommand.cs | 2 +- Content.Server/Alert/Commands/ClearAlert.cs | 2 +- Content.Server/Alert/Commands/ShowAlert.cs | 2 +- Content.Server/Alert/ServerAlertsComponent.cs | 4 +-- .../Atmos/Components/GasAnalyzerComponent.cs | 2 +- .../Unary/EntitySystems/GasCanisterSystem.cs | 2 +- .../Body/Commands/AddHandCommand.cs | 8 +++--- .../Body/Commands/AttachBodyPartCommand.cs | 2 +- .../Body/Commands/DestroyMechanismCommand.cs | 4 +-- .../Body/Commands/RemoveHandCommand.cs | 2 +- .../Body/Components/BodyScannerComponent.cs | 4 +-- Content.Server/Chat/Commands/MeCommand.cs | 2 +- Content.Server/Chat/Commands/SayCommand.cs | 2 +- Content.Server/Chat/Managers/ChatManager.cs | 2 +- .../Components/ReagentDispenserComponent.cs | 2 +- .../Components/SolutionTransferComponent.cs | 2 +- .../Cloning/Components/CloningPodComponent.cs | 12 ++++----- Content.Server/Commands/CommandUtils.cs | 6 ++--- .../Damage/Commands/GodModeCommand.cs | 4 +-- .../Components/DisposalRouterComponent.cs | 2 +- .../Components/DisposalTaggerComponent.cs | 2 +- .../Disposal/TubeConnectionsCommand.cs | 2 +- .../EntityList/SpawnEntityListCommand.cs | 2 +- .../GameTicking/Presets/PresetSuspicion.cs | 2 +- Content.Server/Hands/Systems/HandsSystem.cs | 4 +-- .../Instruments/InstrumentSystem.cs | 4 +-- Content.Server/Interaction/TilePryCommand.cs | 4 +-- .../EntitySystems/ReagentGrinderSystem.cs | 4 +-- .../Labels/Label/HandLabelerSystem.cs | 2 +- .../System/SignalLinkerSystem.cs | 16 ++++++------ .../Components/MedicalScannerComponent.cs | 4 +-- Content.Server/PDA/PDASystem.cs | 2 +- .../Power/Components/ApcComponent.cs | 4 +-- Content.Server/Sandbox/SandboxManager.cs | 12 ++++----- .../Storage/EntitySystems/StorageSystem.cs | 9 ++++--- .../Tabletop/TabletopSystem.Session.cs | 2 +- .../Uplink/Commands/AddUplinkCommand.cs | 2 +- .../Uplink/Telecrystal/TelecrystalSystem.cs | 2 +- .../UserInterface/ActivatableUISystem.cs | 2 +- .../Verbs/Commands/InvokeVerbCommand.cs | 4 +-- Content.Server/Verbs/VerbSystem.cs | 8 +++--- .../ServerMagazineBarrelComponent.cs | 20 +++++++------- Content.Server/WireHacking/WiresComponent.cs | 2 ++ .../CombatMode/SharedCombatModeSystem.cs | 2 +- .../Containers/ItemSlot/ItemSlotsSystem.cs | 6 ++--- Content.Shared/Cuffs/SharedCuffableSystem.cs | 4 +-- Content.Shared/Gravity/SharedGravitySystem.cs | 3 +-- .../Hands/Components/SharedHandsComponent.cs | 26 +++++++++---------- Content.Shared/Hands/SharedHandsSystem.cs | 2 +- .../Pulling/Systems/SharedPullableSystem.cs | 2 +- 58 files changed, 135 insertions(+), 133 deletions(-) diff --git a/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/ActionsComponentTests.cs b/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/ActionsComponentTests.cs index f1b1dd11c6..f429db3f52 100644 --- a/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/ActionsComponentTests.cs +++ b/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/ActionsComponentTests.cs @@ -75,7 +75,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs await server.WaitAssertion(() => { var playerEnt = serverPlayerManager.Sessions.Single().AttachedEntity; - var actionsComponent = sEntities.GetComponent(playerEnt!.Value); + var actionsComponent = sEntities.GetComponent(playerEnt); // player should begin with their innate actions granted innateActions.AddRange(actionsComponent.InnateActions); @@ -157,7 +157,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs await server.WaitAssertion(() => { var playerEnt = serverPlayerManager.Sessions.Single().AttachedEntity; - var actionsComponent = IoCManager.Resolve().GetComponent(playerEnt!.Value); + var actionsComponent = IoCManager.Resolve().GetComponent(playerEnt); actionsComponent.Revoke(ActionType.DebugInstant); }); @@ -250,7 +250,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs await server.WaitAssertion(() => { - serverPlayerEnt = serverPlayerManager.Sessions.Single().AttachedEntity!.Value; + serverPlayerEnt = serverPlayerManager.Sessions.Single().AttachedEntity; serverActionsComponent = serverEntManager.GetComponent(serverPlayerEnt); // spawn and give them an item that has actions diff --git a/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/AlertsComponentTests.cs b/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/AlertsComponentTests.cs index 663499941a..447b2b0d73 100644 --- a/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/AlertsComponentTests.cs +++ b/Content.IntegrationTests/Tests/GameObjects/Components/Mobs/AlertsComponentTests.cs @@ -30,8 +30,8 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs await server.WaitAssertion(() => { var playerEnt = serverPlayerManager.Sessions.Single().AttachedEntity; - Assert.NotNull(playerEnt); - var alertsComponent = IoCManager.Resolve().GetComponent(playerEnt!.Value); + Assert.That(playerEnt != default); + var alertsComponent = IoCManager.Resolve().GetComponent(playerEnt); Assert.NotNull(alertsComponent); // show 2 alerts @@ -70,8 +70,8 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs await server.WaitAssertion(() => { var playerEnt = serverPlayerManager.Sessions.Single().AttachedEntity; - Assert.NotNull(playerEnt); - var alertsComponent = IoCManager.Resolve().GetComponent(playerEnt!.Value); + Assert.That(playerEnt != default); + var alertsComponent = IoCManager.Resolve().GetComponent(playerEnt); Assert.NotNull(alertsComponent); alertsComponent.ClearAlert(AlertType.Debug1); diff --git a/Content.IntegrationTests/Tests/PDA/PDAExtensionsTests.cs b/Content.IntegrationTests/Tests/PDA/PDAExtensionsTests.cs index 57653a63d9..81275a9f2e 100644 --- a/Content.IntegrationTests/Tests/PDA/PDAExtensionsTests.cs +++ b/Content.IntegrationTests/Tests/PDA/PDAExtensionsTests.cs @@ -59,9 +59,9 @@ namespace Content.IntegrationTests.Tests.PDA await server.WaitAssertion(() => { - var player = sPlayerManager.Sessions.Single().AttachedEntity!.Value; + var player = sPlayerManager.Sessions.Single().AttachedEntity; - Assert.NotNull(player); + Assert.That(player != default); // The player spawns with an ID on by default Assert.NotNull(player.GetHeldId()); diff --git a/Content.Server/Actions/Commands/CooldownAction.cs b/Content.Server/Actions/Commands/CooldownAction.cs index ffb9b45519..67e45ffaa4 100644 --- a/Content.Server/Actions/Commands/CooldownAction.cs +++ b/Content.Server/Actions/Commands/CooldownAction.cs @@ -29,10 +29,10 @@ namespace Content.Server.Actions.Commands if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return; } - if (attachedEntity == null) return; - if (!IoCManager.Resolve().TryGetComponent(attachedEntity.Value, out ServerActionsComponent? actionsComponent)) + if (attachedEntity == default) return; + if (!IoCManager.Resolve().TryGetComponent(attachedEntity, out ServerActionsComponent? actionsComponent)) { - shell.WriteLine("user has no actions component"); + shell.WriteError("user has no actions component"); return; } diff --git a/Content.Server/Actions/Commands/GrantAction.cs b/Content.Server/Actions/Commands/GrantAction.cs index 6c828dcd38..7ed94e89da 100644 --- a/Content.Server/Actions/Commands/GrantAction.cs +++ b/Content.Server/Actions/Commands/GrantAction.cs @@ -27,8 +27,8 @@ namespace Content.Server.Actions.Commands if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return; } - if (attachedEntity == null) return; - if (!IoCManager.Resolve().TryGetComponent(attachedEntity.Value, out ServerActionsComponent? actionsComponent)) + if (attachedEntity == default) return; + if (!IoCManager.Resolve().TryGetComponent(attachedEntity, out ServerActionsComponent? actionsComponent)) { shell.WriteLine("user has no actions component"); return; diff --git a/Content.Server/Actions/Commands/RevokeAction.cs b/Content.Server/Actions/Commands/RevokeAction.cs index 91fcc194d0..0cf89c4d94 100644 --- a/Content.Server/Actions/Commands/RevokeAction.cs +++ b/Content.Server/Actions/Commands/RevokeAction.cs @@ -27,8 +27,8 @@ namespace Content.Server.Actions.Commands var target = args[1]; if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return; } - if (attachedEntity == null) return; - if (!IoCManager.Resolve().TryGetComponent(attachedEntity.Value, out ServerActionsComponent? actionsComponent)) + if (attachedEntity == default) return; + if (!IoCManager.Resolve().TryGetComponent(attachedEntity, out ServerActionsComponent? actionsComponent)) { shell.WriteLine("user has no actions component"); return; diff --git a/Content.Server/Administration/AdminSystem.cs b/Content.Server/Administration/AdminSystem.cs index 52f4a62c76..99f035c404 100644 --- a/Content.Server/Administration/AdminSystem.cs +++ b/Content.Server/Administration/AdminSystem.cs @@ -126,11 +126,11 @@ namespace Content.Server.Administration var username = string.Empty; if (session.AttachedEntity != default) - username = EntityManager.GetComponent(session.AttachedEntity.Value).EntityName; + username = EntityManager.GetComponent(session.AttachedEntity).EntityName; var antag = session.ContentData()?.Mind?.AllRoles.Any(r => r.Antagonist) ?? false; - return new PlayerInfo(name, username, antag, session.AttachedEntity ?? default, session.UserId); + return new PlayerInfo(name, username, antag, session.AttachedEntity, session.UserId); } } } diff --git a/Content.Server/Administration/Commands/AGhost.cs b/Content.Server/Administration/Commands/AGhost.cs index ec639a76f7..c94b609719 100644 --- a/Content.Server/Administration/Commands/AGhost.cs +++ b/Content.Server/Administration/Commands/AGhost.cs @@ -43,8 +43,8 @@ namespace Content.Server.Administration.Commands } var canReturn = mind.CurrentEntity != default; - var coordinates = player.AttachedEntity.HasValue - ? _entities.GetComponent(player.AttachedEntity.Value).Coordinates + var coordinates = player.AttachedEntity != default + ? _entities.GetComponent(player.AttachedEntity).Coordinates : EntitySystem.Get().GetObserverSpawnPoint(); var ghost = _entities.SpawnEntity("AdminObserver", coordinates); diff --git a/Content.Server/Administration/Commands/RejuvenateCommand.cs b/Content.Server/Administration/Commands/RejuvenateCommand.cs index 04591c59f8..73d38b0f0c 100644 --- a/Content.Server/Administration/Commands/RejuvenateCommand.cs +++ b/Content.Server/Administration/Commands/RejuvenateCommand.cs @@ -35,7 +35,7 @@ namespace Content.Server.Administration.Commands shell.WriteLine(Loc.GetString("rejuvenate-command-no-entity-attached-message")); return; } - PerformRejuvenate(player.AttachedEntity.Value); + PerformRejuvenate(player.AttachedEntity); } var entityManager = IoCManager.Resolve(); diff --git a/Content.Server/Alert/Commands/ClearAlert.cs b/Content.Server/Alert/Commands/ClearAlert.cs index 693101d996..850a0d8740 100644 --- a/Content.Server/Alert/Commands/ClearAlert.cs +++ b/Content.Server/Alert/Commands/ClearAlert.cs @@ -34,7 +34,7 @@ namespace Content.Server.Alert.Commands if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return; } - if (!IoCManager.Resolve().TryGetComponent(attachedEntity.Value, out ServerAlertsComponent? alertsComponent)) + if (!IoCManager.Resolve().TryGetComponent(attachedEntity, out ServerAlertsComponent? alertsComponent)) { shell.WriteLine("user has no alerts component"); return; diff --git a/Content.Server/Alert/Commands/ShowAlert.cs b/Content.Server/Alert/Commands/ShowAlert.cs index a328911f95..b55b5d79dc 100644 --- a/Content.Server/Alert/Commands/ShowAlert.cs +++ b/Content.Server/Alert/Commands/ShowAlert.cs @@ -40,7 +40,7 @@ namespace Content.Server.Alert.Commands if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return; } - if (!IoCManager.Resolve().TryGetComponent(attachedEntity.Value, out ServerAlertsComponent? alertsComponent)) + if (!IoCManager.Resolve().TryGetComponent(attachedEntity, out ServerAlertsComponent? alertsComponent)) { shell.WriteLine("user has no alerts component"); return; diff --git a/Content.Server/Alert/ServerAlertsComponent.cs b/Content.Server/Alert/ServerAlertsComponent.cs index e7c33448cb..32db5fd927 100644 --- a/Content.Server/Alert/ServerAlertsComponent.cs +++ b/Content.Server/Alert/ServerAlertsComponent.cs @@ -67,7 +67,7 @@ namespace Content.Server.Alert { Logger.DebugS("alert", "user {0} attempted to" + " click alert {1} which is not currently showing for them", - IoCManager.Resolve().GetComponent(player.Value).EntityName, msg.Type); + IoCManager.Resolve().GetComponent(player).EntityName, msg.Type); break; } @@ -77,7 +77,7 @@ namespace Content.Server.Alert break; } - alert.OnClick?.AlertClicked(new ClickAlertEventArgs(player.Value, alert)); + alert.OnClick?.AlertClicked(new ClickAlertEventArgs(player, alert)); break; } } diff --git a/Content.Server/Atmos/Components/GasAnalyzerComponent.cs b/Content.Server/Atmos/Components/GasAnalyzerComponent.cs index 32c5eb1980..4bec111fd0 100644 --- a/Content.Server/Atmos/Components/GasAnalyzerComponent.cs +++ b/Content.Server/Atmos/Components/GasAnalyzerComponent.cs @@ -235,7 +235,7 @@ namespace Content.Server.Atmos.Components if (handsComponent.GetActiveHand?.Owner is not {Valid: true} activeHandEntity || !_entities.TryGetComponent(activeHandEntity, out GasAnalyzerComponent? gasAnalyzer)) { - serverMsg.Session.AttachedEntity?.PopupMessage(Loc.GetString("gas-analyzer-component-need-gas-analyzer-in-hand-message")); + serverMsg.Session.AttachedEntity.PopupMessage(Loc.GetString("gas-analyzer-component-need-gas-analyzer-in-hand-message")); return; } diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs index d3f1d69c83..6e7848a366 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasCanisterSystem.cs @@ -81,7 +81,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems private bool CheckInteract(ICommonSession session) { - if (session.AttachedEntity is not {} uid + if (session.AttachedEntity is not {Valid: true} uid || !_actionBlockerSystem.CanInteract(uid) || !_actionBlockerSystem.CanUse(uid)) return false; diff --git a/Content.Server/Body/Commands/AddHandCommand.cs b/Content.Server/Body/Commands/AddHandCommand.cs index d709c79246..9d0e9da6dc 100644 --- a/Content.Server/Body/Commands/AddHandCommand.cs +++ b/Content.Server/Body/Commands/AddHandCommand.cs @@ -44,13 +44,13 @@ namespace Content.Server.Body.Commands return; } - if (player.AttachedEntity == null) + if (player.AttachedEntity == default) { shell.WriteLine("You don't have an entity to add a hand to."); return; } - entity = player.AttachedEntity.Value; + entity = player.AttachedEntity; hand = entityManager.SpawnEntity(DefaultHandPrototype, entityManager.GetComponent(entity).Coordinates); break; } @@ -75,13 +75,13 @@ namespace Content.Server.Body.Commands return; } - if (player.AttachedEntity == null) + if (player.AttachedEntity == default) { shell.WriteLine("You don't have an entity to add a hand to."); return; } - entity = player.AttachedEntity.Value; + entity = player.AttachedEntity; hand = entityManager.SpawnEntity(args[0], entityManager.GetComponent(entity).Coordinates); } diff --git a/Content.Server/Body/Commands/AttachBodyPartCommand.cs b/Content.Server/Body/Commands/AttachBodyPartCommand.cs index c46e366400..eacfe32d6e 100644 --- a/Content.Server/Body/Commands/AttachBodyPartCommand.cs +++ b/Content.Server/Body/Commands/AttachBodyPartCommand.cs @@ -44,7 +44,7 @@ namespace Content.Server.Body.Commands return; } - entity = player.AttachedEntity.Value; + entity = player.AttachedEntity; break; case 2: diff --git a/Content.Server/Body/Commands/DestroyMechanismCommand.cs b/Content.Server/Body/Commands/DestroyMechanismCommand.cs index e6e7e255e8..47f7684c14 100644 --- a/Content.Server/Body/Commands/DestroyMechanismCommand.cs +++ b/Content.Server/Body/Commands/DestroyMechanismCommand.cs @@ -31,13 +31,13 @@ namespace Content.Server.Body.Commands return; } - if (player.AttachedEntity == null) + if (player.AttachedEntity == default) { shell.WriteLine("You have no entity."); return; } - if (!IoCManager.Resolve().TryGetComponent(player.AttachedEntity.Value, out SharedBodyComponent? body)) + if (!IoCManager.Resolve().TryGetComponent(player.AttachedEntity, out SharedBodyComponent? body)) { var random = IoCManager.Resolve(); var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}"; diff --git a/Content.Server/Body/Commands/RemoveHandCommand.cs b/Content.Server/Body/Commands/RemoveHandCommand.cs index 60807b59c4..e474ebfb1a 100644 --- a/Content.Server/Body/Commands/RemoveHandCommand.cs +++ b/Content.Server/Body/Commands/RemoveHandCommand.cs @@ -33,7 +33,7 @@ namespace Content.Server.Body.Commands return; } - if (!IoCManager.Resolve().TryGetComponent(player.AttachedEntity.Value, out SharedBodyComponent? body)) + if (!IoCManager.Resolve().TryGetComponent(player.AttachedEntity, out SharedBodyComponent? body)) { var random = IoCManager.Resolve(); var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}"; diff --git a/Content.Server/Body/Components/BodyScannerComponent.cs b/Content.Server/Body/Components/BodyScannerComponent.cs index 75a16fcf73..e62d21befa 100644 --- a/Content.Server/Body/Components/BodyScannerComponent.cs +++ b/Content.Server/Body/Components/BodyScannerComponent.cs @@ -24,12 +24,12 @@ namespace Content.Server.Body.Components var session = actor.PlayerSession; - if (session.AttachedEntity == null) + if (session.AttachedEntity == default) { return; } - if (IoCManager.Resolve().TryGetComponent(session.AttachedEntity.Value, out SharedBodyComponent? body)) + if (IoCManager.Resolve().TryGetComponent(session.AttachedEntity, out SharedBodyComponent? body)) { var state = InterfaceState(body); UserInterface?.SetState(state); diff --git a/Content.Server/Chat/Commands/MeCommand.cs b/Content.Server/Chat/Commands/MeCommand.cs index 9041df60b1..6b75dc13dd 100644 --- a/Content.Server/Chat/Commands/MeCommand.cs +++ b/Content.Server/Chat/Commands/MeCommand.cs @@ -24,7 +24,7 @@ namespace Content.Server.Chat.Commands return; } - if (player.Status != SessionStatus.InGame || !player.AttachedEntity.HasValue) + if (player.Status != SessionStatus.InGame || player.AttachedEntity == default) return; if (args.Length < 1) diff --git a/Content.Server/Chat/Commands/SayCommand.cs b/Content.Server/Chat/Commands/SayCommand.cs index 8f6b5d33ab..890e2d3581 100644 --- a/Content.Server/Chat/Commands/SayCommand.cs +++ b/Content.Server/Chat/Commands/SayCommand.cs @@ -25,7 +25,7 @@ namespace Content.Server.Chat.Commands return; } - if (player.Status != SessionStatus.InGame || !player.AttachedEntity.HasValue) + if (player.Status != SessionStatus.InGame || player.AttachedEntity == default) return; if (args.Length < 1) diff --git a/Content.Server/Chat/Managers/ChatManager.cs b/Content.Server/Chat/Managers/ChatManager.cs index 02cb35f2f4..437abe9f99 100644 --- a/Content.Server/Chat/Managers/ChatManager.cs +++ b/Content.Server/Chat/Managers/ChatManager.cs @@ -306,7 +306,7 @@ namespace Content.Server.Chat.Managers msg.MessageWrap = Loc.GetString("chat-manager-send-dead-chat-wrap-message", ("deadChannelName", Loc.GetString("chat-manager-dead-channel-name")), ("playerName", (playerName))); - msg.SenderEntity = player.AttachedEntity.GetValueOrDefault(); + msg.SenderEntity = player.AttachedEntity; _netManager.ServerSendToMany(msg, clients.ToList()); } diff --git a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs index d6f7dacece..05bf0abca1 100644 --- a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs +++ b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs @@ -143,7 +143,7 @@ namespace Content.Server.Chemistry.Components _ => true, }; - if (!PlayerCanUseDispenser(obj.Session.AttachedEntity.Value, needsPower)) + if (!PlayerCanUseDispenser(obj.Session.AttachedEntity, needsPower)) return; switch (msg.Button) diff --git a/Content.Server/Chemistry/Components/SolutionTransferComponent.cs b/Content.Server/Chemistry/Components/SolutionTransferComponent.cs index efc13a5978..e64041c0ac 100644 --- a/Content.Server/Chemistry/Components/SolutionTransferComponent.cs +++ b/Content.Server/Chemistry/Components/SolutionTransferComponent.cs @@ -96,7 +96,7 @@ namespace Content.Server.Chemistry.Components var amount = Math.Clamp(sval, MinimumTransferAmount.Float(), MaximumTransferAmount.Float()); - serverMsg.Session.AttachedEntity?.PopupMessage(Loc.GetString("comp-solution-transfer-set-amount", + serverMsg.Session.AttachedEntity.PopupMessage(Loc.GetString("comp-solution-transfer-set-amount", ("amount", amount))); SetTransferAmount(FixedPoint2.New(amount)); break; diff --git a/Content.Server/Cloning/Components/CloningPodComponent.cs b/Content.Server/Cloning/Components/CloningPodComponent.cs index bf6b961a39..4326bbcd33 100644 --- a/Content.Server/Cloning/Components/CloningPodComponent.cs +++ b/Content.Server/Cloning/Components/CloningPodComponent.cs @@ -87,13 +87,13 @@ namespace Content.Server.Cloning.Components case UiButton.Clone: if (BodyContainer.ContainedEntity != null) { - obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-occupied")); + obj.Session.AttachedEntity.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-occupied")); return; } if (message.ScanId == null) { - obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-no-selection")); + obj.Session.AttachedEntity.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-no-selection")); return; } @@ -101,7 +101,7 @@ namespace Content.Server.Cloning.Components if (!cloningSystem.IdToDNA.TryGetValue(message.ScanId.Value, out var dna)) { - obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-bad-selection")); + obj.Session.AttachedEntity.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-bad-selection")); return; // ScanId is not in database } @@ -115,7 +115,7 @@ namespace Content.Server.Cloning.Components _entities.TryGetComponent(clone, out MindComponent? cloneMindComp) && (cloneMindComp.Mind == null || cloneMindComp.Mind == mind)) { - obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-already-cloning")); + obj.Session.AttachedEntity.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-already-cloning")); return; // Mind already has clone } @@ -126,14 +126,14 @@ namespace Content.Server.Cloning.Components _entities.TryGetComponent(mind.OwnedEntity.Value, out var state) && !state.IsDead()) { - obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-already-alive")); + obj.Session.AttachedEntity.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-already-alive")); return; // Body controlled by mind is not dead } // Yes, we still need to track down the client because we need to open the Eui if (mind.UserId == null || !_playerManager.TryGetSessionById(mind.UserId.Value, out var client)) { - obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-user-offline")); + obj.Session.AttachedEntity.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-user-offline")); return; // If we can't track down the client, we can't offer transfer. That'd be quite bad. } diff --git a/Content.Server/Commands/CommandUtils.cs b/Content.Server/Commands/CommandUtils.cs index 296d8fe13d..0c4fd86d9c 100644 --- a/Content.Server/Commands/CommandUtils.cs +++ b/Content.Server/Commands/CommandUtils.cs @@ -39,11 +39,11 @@ namespace Content.Server.Commands /// sending a failure to the performer if unable to. /// public static bool TryGetAttachedEntityByUsernameOrId(IConsoleShell shell, - string usernameOrId, IPlayerSession performer, [NotNullWhen(true)] out EntityUid? attachedEntity) + string usernameOrId, IPlayerSession performer, out EntityUid attachedEntity) { - attachedEntity = null; + attachedEntity = default; if (!TryGetSessionByUsernameOrId(shell, usernameOrId, performer, out var session)) return false; - if (session.AttachedEntity == null) + if (session.AttachedEntity == default) { shell.WriteLine("User has no attached entity."); return false; diff --git a/Content.Server/Damage/Commands/GodModeCommand.cs b/Content.Server/Damage/Commands/GodModeCommand.cs index 1d79d7c20c..a94ad5ca37 100644 --- a/Content.Server/Damage/Commands/GodModeCommand.cs +++ b/Content.Server/Damage/Commands/GodModeCommand.cs @@ -31,13 +31,13 @@ namespace Content.Server.Damage.Commands return; } - if (player.AttachedEntity == null) + if (player.AttachedEntity == default) { shell.WriteLine("An entity needs to be specified when you aren't attached to an entity."); return; } - entity = player.AttachedEntity.Value; + entity = player.AttachedEntity; break; case 1: if (!EntityUid.TryParse(args[0], out var id)) diff --git a/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs index 05a7955464..760e9814b9 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs @@ -112,7 +112,7 @@ namespace Content.Server.Disposal.Tube.Components var actionBlocker = EntitySystem.Get(); var groupController = IoCManager.Resolve(); //Check if player can interact in their current state - if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntity!.Value) || !actionBlocker.CanUse(session.AttachedEntity!.Value))) + if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntity) || !actionBlocker.CanUse(session.AttachedEntity))) return false; return true; diff --git a/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs index c83fd1ad3d..ab73137b62 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs @@ -94,7 +94,7 @@ namespace Content.Server.Disposal.Tube.Components var actionBlocker = EntitySystem.Get(); var groupController = IoCManager.Resolve(); //Check if player can interact in their current state - if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntity!.Value) || !actionBlocker.CanUse(session.AttachedEntity!.Value))) + if (!groupController.CanAdminMenu(session) && (!actionBlocker.CanInteract(session.AttachedEntity) || !actionBlocker.CanUse(session.AttachedEntity))) return false; return true; diff --git a/Content.Server/Disposal/TubeConnectionsCommand.cs b/Content.Server/Disposal/TubeConnectionsCommand.cs index 0a7d023c36..b89eadd307 100644 --- a/Content.Server/Disposal/TubeConnectionsCommand.cs +++ b/Content.Server/Disposal/TubeConnectionsCommand.cs @@ -52,7 +52,7 @@ namespace Content.Server.Disposal return; } - tube.PopupDirections(player.AttachedEntity.Value); + tube.PopupDirections(player.AttachedEntity); } } } diff --git a/Content.Server/EntityList/SpawnEntityListCommand.cs b/Content.Server/EntityList/SpawnEntityListCommand.cs index 6da3bac523..9615df7f77 100644 --- a/Content.Server/EntityList/SpawnEntityListCommand.cs +++ b/Content.Server/EntityList/SpawnEntityListCommand.cs @@ -49,7 +49,7 @@ namespace Content.Server.EntityList foreach (var entity in prototype.Entities(prototypeManager)) { - entityManager.SpawnEntity(entity.ID, entityManager.GetComponent(player.AttachedEntity.Value).Coordinates); + entityManager.SpawnEntity(entity.ID, entityManager.GetComponent(player.AttachedEntity).Coordinates); i++; } diff --git a/Content.Server/GameTicking/Presets/PresetSuspicion.cs b/Content.Server/GameTicking/Presets/PresetSuspicion.cs index 0963bb3ed4..7b2f041efb 100644 --- a/Content.Server/GameTicking/Presets/PresetSuspicion.cs +++ b/Content.Server/GameTicking/Presets/PresetSuspicion.cs @@ -72,7 +72,7 @@ namespace Content.Server.GameTicking.Presets } prefList.Add(player); - player.AttachedEntity?.EnsureComponent(); + player.AttachedEntity.EnsureComponent(); } var numTraitors = MathHelper.Clamp(readyPlayers.Count / PlayersPerTraitor, diff --git a/Content.Server/Hands/Systems/HandsSystem.cs b/Content.Server/Hands/Systems/HandsSystem.cs index 774dcf8fea..e5854da71f 100644 --- a/Content.Server/Hands/Systems/HandsSystem.cs +++ b/Content.Server/Hands/Systems/HandsSystem.cs @@ -191,10 +191,10 @@ namespace Content.Server.Hands.Systems var player = playerSession.AttachedEntity; - if (!player.HasValue || !player.Value.IsValid()) + if (player is not {Valid: true}) return false; - return EntityManager.TryGetComponent(player.Value, out hands); + return EntityManager.TryGetComponent(player, out hands); } private void HandleActivateItem(ICommonSession? session) diff --git a/Content.Server/Instruments/InstrumentSystem.cs b/Content.Server/Instruments/InstrumentSystem.cs index 9919cae3ee..c0c48c9bc6 100644 --- a/Content.Server/Instruments/InstrumentSystem.cs +++ b/Content.Server/Instruments/InstrumentSystem.cs @@ -108,11 +108,11 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem { if (instrument.LaggedBatches == (int) (MaxMidiLaggedBatches * (1 / 3d) + 1)) { - instrument.InstrumentPlayer.AttachedEntity?.PopupMessage( + instrument.InstrumentPlayer.AttachedEntity.PopupMessage( Loc.GetString("instrument-component-finger-cramps-light-message")); } else if (instrument.LaggedBatches == (int) (MaxMidiLaggedBatches * (2 / 3d) + 1)) { - instrument.InstrumentPlayer.AttachedEntity?.PopupMessage( + instrument.InstrumentPlayer.AttachedEntity.PopupMessage( Loc.GetString("instrument-component-finger-cramps-serious-message")); } } diff --git a/Content.Server/Interaction/TilePryCommand.cs b/Content.Server/Interaction/TilePryCommand.cs index 1fc66c87c4..47766677e4 100644 --- a/Content.Server/Interaction/TilePryCommand.cs +++ b/Content.Server/Interaction/TilePryCommand.cs @@ -49,9 +49,9 @@ namespace Content.Server.Interaction } var mapManager = IoCManager.Resolve(); - var playerGrid = _entities.GetComponent(player.AttachedEntity.Value).GridID; + var playerGrid = _entities.GetComponent(player.AttachedEntity).GridID; var mapGrid = mapManager.GetGrid(playerGrid); - var playerPosition = _entities.GetComponent(player.AttachedEntity.Value).Coordinates; + var playerPosition = _entities.GetComponent(player.AttachedEntity).Coordinates; var tileDefinitionManager = IoCManager.Resolve(); for (var i = -radius; i <= radius; i++) diff --git a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs index 3d8f1d82ea..b0df3b056f 100644 --- a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs @@ -163,7 +163,7 @@ namespace Content.Server.Kitchen.EntitySystems if (!EntityManager.TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver) || !receiver.Powered) break; ClickSound(component); - DoWork(component, message.Session.AttachedEntity!.Value, + DoWork(component, message.Session.AttachedEntity, SharedReagentGrinderComponent.GrinderProgram.Grind); break; @@ -171,7 +171,7 @@ namespace Content.Server.Kitchen.EntitySystems if (!EntityManager.TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver2) || !receiver2.Powered) break; ClickSound(component); - DoWork(component, message.Session.AttachedEntity!.Value, + DoWork(component, message.Session.AttachedEntity, SharedReagentGrinderComponent.GrinderProgram.Juice); break; diff --git a/Content.Server/Labels/Label/HandLabelerSystem.cs b/Content.Server/Labels/Label/HandLabelerSystem.cs index fdd3adb611..dd500981b3 100644 --- a/Content.Server/Labels/Label/HandLabelerSystem.cs +++ b/Content.Server/Labels/Label/HandLabelerSystem.cs @@ -81,7 +81,7 @@ namespace Content.Server.Labels private bool CheckInteract(ICommonSession session) { - if (session.AttachedEntity is not { } uid + if (session.AttachedEntity is not {Valid: true } uid || !Get().CanInteract(uid) || !Get().CanUse(uid)) return false; diff --git a/Content.Server/MachineLinking/System/SignalLinkerSystem.cs b/Content.Server/MachineLinking/System/SignalLinkerSystem.cs index 35a868db32..ed75573a6f 100644 --- a/Content.Server/MachineLinking/System/SignalLinkerSystem.cs +++ b/Content.Server/MachineLinking/System/SignalLinkerSystem.cs @@ -119,16 +119,16 @@ namespace Content.Server.MachineLinking.System switch (msg.Message) { case SignalPortSelected portSelected: - if (msg.Session.AttachedEntity == null || - !EntityManager.TryGetComponent(msg.Session.AttachedEntity.Value, out HandsComponent? hands) || + if (msg.Session.AttachedEntity == default || + !EntityManager.TryGetComponent(msg.Session.AttachedEntity, out HandsComponent? hands) || !hands.TryGetActiveHeldEntity(out var heldEntity) || !EntityManager.TryGetComponent(heldEntity, out SignalLinkerComponent? signalLinkerComponent) || - !_interaction.InRangeUnobstructed(msg.Session.AttachedEntity.Value, component.Owner, ignoreInsideBlocker: true) || + !_interaction.InRangeUnobstructed(msg.Session.AttachedEntity, component.Owner, ignoreInsideBlocker: true) || !signalLinkerComponent.Port.HasValue || !signalLinkerComponent.Port.Value.transmitter.Outputs.ContainsPort(signalLinkerComponent.Port .Value.port) || !component.Inputs.ContainsPort(portSelected.Port)) return; - LinkerInteraction(msg.Session.AttachedEntity.Value, signalLinkerComponent.Port.Value.transmitter, + LinkerInteraction(msg.Session.AttachedEntity, signalLinkerComponent.Port.Value.transmitter, signalLinkerComponent.Port.Value.port, component, portSelected.Port); break; } @@ -159,13 +159,13 @@ namespace Content.Server.MachineLinking.System switch (msg.Message) { case SignalPortSelected portSelected: - if (msg.Session.AttachedEntity == null || - !EntityManager.TryGetComponent(msg.Session.AttachedEntity.Value, out HandsComponent? hands) || + if (msg.Session.AttachedEntity == default || + !EntityManager.TryGetComponent(msg.Session.AttachedEntity, out HandsComponent? hands) || !hands.TryGetActiveHeldEntity(out var heldEntity) || !EntityManager.TryGetComponent(heldEntity, out SignalLinkerComponent? signalLinkerComponent) || - !_interaction.InRangeUnobstructed(msg.Session.AttachedEntity.Value, component.Owner, ignoreInsideBlocker: true)) + !_interaction.InRangeUnobstructed(msg.Session.AttachedEntity, component.Owner, ignoreInsideBlocker: true)) return; - LinkerSaveInteraction(msg.Session.AttachedEntity.Value, signalLinkerComponent, component, + LinkerSaveInteraction(msg.Session.AttachedEntity, signalLinkerComponent, component, portSelected.Port); break; } diff --git a/Content.Server/Medical/Components/MedicalScannerComponent.cs b/Content.Server/Medical/Components/MedicalScannerComponent.cs index 6a8c660f60..8eb8bf2a0b 100644 --- a/Content.Server/Medical/Components/MedicalScannerComponent.cs +++ b/Content.Server/Medical/Components/MedicalScannerComponent.cs @@ -200,7 +200,7 @@ namespace Content.Server.Medical.Components if (!IoCManager.Resolve().TryGetComponent(_bodyContainer.ContainedEntity.Value, out MindComponent? mindComp) || mindComp.Mind == null) { - obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("medical-scanner-component-msg-no-soul")); + obj.Session.AttachedEntity.PopupMessageCursor(Loc.GetString("medical-scanner-component-msg-no-soul")); break; } @@ -215,7 +215,7 @@ namespace Content.Server.Medical.Components if (mindUser == null) { // For now assume this means soul departed - obj.Session.AttachedEntity?.PopupMessageCursor(Loc.GetString("medical-scanner-component-msg-soul-broken")); + obj.Session.AttachedEntity.PopupMessageCursor(Loc.GetString("medical-scanner-component-msg-soul-broken")); break; } diff --git a/Content.Server/PDA/PDASystem.cs b/Content.Server/PDA/PDASystem.cs index 05df412da7..ee435ccd8a 100644 --- a/Content.Server/PDA/PDASystem.cs +++ b/Content.Server/PDA/PDASystem.cs @@ -145,7 +145,7 @@ namespace Content.Server.PDA private void OnUIMessage(PDAComponent pda, ServerBoundUserInterfaceMessage msg) { // cast EntityUid? to EntityUid - if (msg.Session.AttachedEntity is not { } playerUid) + if (msg.Session.AttachedEntity is not {Valid: true} playerUid) return; switch (msg.Message) diff --git a/Content.Server/Power/Components/ApcComponent.cs b/Content.Server/Power/Components/ApcComponent.cs index a34eb242bd..145a4957db 100644 --- a/Content.Server/Power/Components/ApcComponent.cs +++ b/Content.Server/Power/Components/ApcComponent.cs @@ -93,7 +93,7 @@ namespace Content.Server.Power.Components if (user == null) return; var accessSystem = EntitySystem.Get(); - if (_accessReader == null || accessSystem.IsAllowed(_accessReader, user.Value)) + if (_accessReader == null || accessSystem.IsAllowed(_accessReader, user)) { MainBreakerEnabled = !MainBreakerEnabled; IoCManager.Resolve().GetComponent(Owner).CanDischarge = MainBreakerEnabled; @@ -103,7 +103,7 @@ namespace Content.Server.Power.Components } else { - user.Value.PopupMessageCursor(Loc.GetString("apc-component-insufficient-access")); + user.PopupMessageCursor(Loc.GetString("apc-component-insufficient-access")); } } diff --git a/Content.Server/Sandbox/SandboxManager.cs b/Content.Server/Sandbox/SandboxManager.cs index 3ffeb3b6c9..46ed8590f3 100644 --- a/Content.Server/Sandbox/SandboxManager.cs +++ b/Content.Server/Sandbox/SandboxManager.cs @@ -115,7 +115,7 @@ namespace Content.Server.Sandbox } var player = _playerManager.GetSessionByChannel(message.MsgChannel); - if (player.AttachedEntity == null) + if (player.AttachedEntity == default) { return; } @@ -124,7 +124,7 @@ namespace Content.Server.Sandbox .EnumeratePrototypes() .Select(p => p.ID).ToArray(); - if (_entityManager.TryGetComponent(player.AttachedEntity.Value, out InventoryComponent? inv) + if (_entityManager.TryGetComponent(player.AttachedEntity, out InventoryComponent? inv) && inv.TryGetSlotItem(Slots.IDCARD, out ItemComponent? wornItem)) { if (_entityManager.HasComponent(wornItem.Owner)) @@ -148,10 +148,10 @@ namespace Content.Server.Sandbox } } } - else if (_entityManager.TryGetComponent(player.AttachedEntity.Value, out var hands)) + else if (_entityManager.TryGetComponent(player.AttachedEntity, out var hands)) { var card = CreateFreshId(); - if (!_entityManager.TryGetComponent(player.AttachedEntity.Value, out inv) || !inv.Equip(Slots.IDCARD, card)) + if (!_entityManager.TryGetComponent(player.AttachedEntity, out inv) || !inv.Equip(Slots.IDCARD, card)) { hands.PutInHandOrDrop(_entityManager.GetComponent(card)); } @@ -170,10 +170,10 @@ namespace Content.Server.Sandbox EntityUid CreateFreshId() { - var card = _entityManager.SpawnEntity("CaptainIDCard", _entityManager.GetComponent(player.AttachedEntity.Value).Coordinates); + var card = _entityManager.SpawnEntity("CaptainIDCard", _entityManager.GetComponent(player.AttachedEntity).Coordinates); UpgradeId(card); - _entityManager.GetComponent(card).FullName = _entityManager.GetComponent(player.AttachedEntity.Value).EntityName; + _entityManager.GetComponent(card).FullName = _entityManager.GetComponent(player.AttachedEntity).EntityName; return card; } } diff --git a/Content.Server/Storage/EntitySystems/StorageSystem.cs b/Content.Server/Storage/EntitySystems/StorageSystem.cs index e89668278a..83f0453649 100644 --- a/Content.Server/Storage/EntitySystems/StorageSystem.cs +++ b/Content.Server/Storage/EntitySystems/StorageSystem.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using Content.Server.Hands.Components; using Content.Server.Interaction; using Content.Server.Storage.Components; +using Content.Shared.Interaction; using Content.Shared.Movement; using Content.Shared.Verbs; using JetBrains.Annotations; @@ -151,14 +152,14 @@ namespace Content.Server.Storage.EntitySystems var attachedEntity = session.AttachedEntity; // The component manages the set of sessions, so this invalid session should be removed soon. - if (attachedEntity == null || !IoCManager.Resolve().EntityExists(attachedEntity.Value)) + if (attachedEntity == default || !IoCManager.Resolve().EntityExists(attachedEntity)) continue; - if (storageMap != IoCManager.Resolve().GetComponent(attachedEntity.Value).MapID) + if (storageMap != IoCManager.Resolve().GetComponent(attachedEntity).MapID) continue; - var distanceSquared = (storagePos - IoCManager.Resolve().GetComponent(attachedEntity.Value).WorldPosition).LengthSquared; - if (distanceSquared > InteractionSystem.InteractionRangeSquared) + var distanceSquared = (storagePos - IoCManager.Resolve().GetComponent(attachedEntity).WorldPosition).LengthSquared; + if (distanceSquared > SharedInteractionSystem.InteractionRangeSquared) { storageComp.UnsubscribeSession(session); } diff --git a/Content.Server/Tabletop/TabletopSystem.Session.cs b/Content.Server/Tabletop/TabletopSystem.Session.cs index dcc961fef6..4783c0277e 100644 --- a/Content.Server/Tabletop/TabletopSystem.Session.cs +++ b/Content.Server/Tabletop/TabletopSystem.Session.cs @@ -73,7 +73,7 @@ namespace Content.Server.Tabletop /// The UID of the tabletop game entity. public void OpenSessionFor(IPlayerSession player, EntityUid uid) { - if (!EntityManager.TryGetComponent(uid, out TabletopGameComponent? tabletop) || player.AttachedEntity is not {} attachedEntity) + if (!EntityManager.TryGetComponent(uid, out TabletopGameComponent? tabletop) || player.AttachedEntity is not {Valid: true} attachedEntity) return; // Make sure we have a session, and add the player to it if not added already. diff --git a/Content.Server/Traitor/Uplink/Commands/AddUplinkCommand.cs b/Content.Server/Traitor/Uplink/Commands/AddUplinkCommand.cs index 900d2198f7..7f23fed43d 100644 --- a/Content.Server/Traitor/Uplink/Commands/AddUplinkCommand.cs +++ b/Content.Server/Traitor/Uplink/Commands/AddUplinkCommand.cs @@ -74,7 +74,7 @@ namespace Content.Server.Traitor.Uplink.Commands // Finally add uplink if (!entityManager.EntitySysManager.GetEntitySystem() - .AddUplink(user.Value, uplinkAccount, uplinkEntity)) + .AddUplink(user, uplinkAccount, uplinkEntity)) { shell.WriteLine(Loc.GetString("Failed to add uplink to the player")); return; diff --git a/Content.Server/Traitor/Uplink/Telecrystal/TelecrystalSystem.cs b/Content.Server/Traitor/Uplink/Telecrystal/TelecrystalSystem.cs index 387411ede1..e887c567e0 100644 --- a/Content.Server/Traitor/Uplink/Telecrystal/TelecrystalSystem.cs +++ b/Content.Server/Traitor/Uplink/Telecrystal/TelecrystalSystem.cs @@ -26,7 +26,7 @@ namespace Content.Server.Traitor.Uplink.Telecrystal if (args.Handled) return; - if (args.Target == null || !EntityManager.TryGetComponent(args.Target, out UplinkComponent? uplink)) + if (args.Target == null || !EntityManager.TryGetComponent(args.Target.Value, out UplinkComponent? uplink)) return; // TODO: when uplink will have some auth logic (like PDA ringtone code) diff --git a/Content.Server/UserInterface/ActivatableUISystem.cs b/Content.Server/UserInterface/ActivatableUISystem.cs index 3d50e6c414..bc83ec1fb3 100644 --- a/Content.Server/UserInterface/ActivatableUISystem.cs +++ b/Content.Server/UserInterface/ActivatableUISystem.cs @@ -116,7 +116,7 @@ namespace Content.Server.UserInterface // Must ToList in order to close things safely. foreach (var session in ui.SubscribedSessions.ToArray()) { - if (session.AttachedEntity == null || !_actionBlockerSystem.CanInteract(session.AttachedEntity.Value)) + if (session.AttachedEntity == null || !_actionBlockerSystem.CanInteract(session.AttachedEntity)) { ui.Close(session); } diff --git a/Content.Server/Verbs/Commands/InvokeVerbCommand.cs b/Content.Server/Verbs/Commands/InvokeVerbCommand.cs index 34c4311abd..8b18f94646 100644 --- a/Content.Server/Verbs/Commands/InvokeVerbCommand.cs +++ b/Content.Server/Verbs/Commands/InvokeVerbCommand.cs @@ -32,9 +32,9 @@ namespace Content.Server.Verbs.Commands EntityUid playerEntity = default; if (!int.TryParse(args[0], out var intPlayerUid)) { - if (args[0] == "self" && shell.Player?.AttachedEntity != null) + if (args[0] == "self" && shell.Player?.AttachedEntity != default) { - playerEntity = shell.Player.AttachedEntity.Value; + playerEntity = shell.Player.AttachedEntity; } else { diff --git a/Content.Server/Verbs/VerbSystem.cs b/Content.Server/Verbs/VerbSystem.cs index 0ce54b8892..3ff58540d7 100644 --- a/Content.Server/Verbs/VerbSystem.cs +++ b/Content.Server/Verbs/VerbSystem.cs @@ -36,7 +36,7 @@ namespace Content.Server.Verbs // Get the list of verbs. This effectively also checks that the requested verb is in fact a valid verb that // the user can perform. - var verbs = GetLocalVerbs(args.Target, userEntity.Value, args.Type)[args.Type]; + var verbs = GetLocalVerbs(args.Target, userEntity, args.Type)[args.Type]; // Note that GetLocalVerbs might waste time checking & preparing unrelated verbs even though we know // precisely which one we want to run. However, MOST entities will only have 1 or 2 verbs of a given type. @@ -44,7 +44,7 @@ namespace Content.Server.Verbs // Find the requested verb. if (verbs.TryGetValue(args.RequestedVerb, out var verb)) - ExecuteVerb(verb, userEntity.Value, args.Target); + ExecuteVerb(verb, userEntity, args.Target); else // 404 Verb not found. Note that this could happen due to something as simple as opening the verb menu, walking away, then trying // to run the pickup-item verb. So maybe this shouldn't even be logged? @@ -61,7 +61,7 @@ namespace Content.Server.Verbs return; } - if (player.AttachedEntity == null) + if (player.AttachedEntity == default) { Logger.Warning($"{nameof(HandleVerbRequest)} called by player {player} with no attached entity."); return; @@ -71,7 +71,7 @@ namespace Content.Server.Verbs // this, and some verbs (e.g. view variables) won't even care about whether an entity is accessible through // the entity menu or not. - var response = new VerbsResponseEvent(args.EntityUid, GetLocalVerbs(args.EntityUid, player.AttachedEntity.Value, args.Type)); + var response = new VerbsResponseEvent(args.EntityUid, GetLocalVerbs(args.EntityUid, player.AttachedEntity, args.Type)); RaiseNetworkEvent(response, player.ConnectedClient); } } diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs index 53140aa692..9f9556de2b 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs @@ -202,10 +202,10 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { return default; } - var entity = _chamberContainer.ContainedEntity; + var entity = _chamberContainer.ContainedEntity ?? default; Cycle(); - return (entity != null ? IoCManager.Resolve().GetComponent(entity) : null).TakeBullet(spawnAt); + return entity != default ? IoCManager.Resolve().GetComponent(entity).TakeBullet(spawnAt) : null; } private void Cycle(bool manual = false) @@ -275,14 +275,14 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components var chamberEntity = _chamberContainer.ContainedEntity; if (chamberEntity != null) { - if (!_chamberContainer.Remove(chamberEntity)) + if (!_chamberContainer.Remove(chamberEntity.Value)) { return false; } - var ammoComponent = IoCManager.Resolve().GetComponent(chamberEntity); + var ammoComponent = IoCManager.Resolve().GetComponent(chamberEntity.Value); if (!ammoComponent.Caseless) { - EjectCasing(chamberEntity); + EjectCasing(chamberEntity.Value); } return true; } @@ -297,10 +297,10 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components } // Try and pull a round from the magazine to replace the chamber if possible - var magazine = MagazineContainer.ContainedEntity; - var nextRound = (magazine != null ? IoCManager.Resolve().GetComponent(magazine) : null).TakeAmmo(); + var magazine = MagazineContainer.ContainedEntity ?? default; + var nextRound = magazine != default ? IoCManager.Resolve().GetComponent(magazine).TakeAmmo() : default; - if (nextRound == null) + if (nextRound == default) { return false; } @@ -334,12 +334,12 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components return; } - MagazineContainer.Remove(mag); + MagazineContainer.Remove(mag.Value); SoundSystem.Play(Filter.Pvs(Owner), _soundMagEject.GetSound(), Owner, AudioParams.Default.WithVolume(-2)); if (IoCManager.Resolve().TryGetComponent(user, out HandsComponent? handsComponent)) { - handsComponent.PutInHandOrDrop(IoCManager.Resolve().GetComponent(mag)); + handsComponent.PutInHandOrDrop(IoCManager.Resolve().GetComponent(mag.Value)); } Dirty(); diff --git a/Content.Server/WireHacking/WiresComponent.cs b/Content.Server/WireHacking/WiresComponent.cs index 4e0c6c8bd6..a7ae2f314d 100644 --- a/Content.Server/WireHacking/WiresComponent.cs +++ b/Content.Server/WireHacking/WiresComponent.cs @@ -9,6 +9,8 @@ using Content.Server.UserInterface; using Content.Server.VendingMachines; using Content.Shared.Examine; using Content.Shared.Interaction; +using Content.Shared.Interaction.Helpers; +using Content.Shared.Popups; using Content.Shared.Sound; using Content.Shared.Tools; using Content.Shared.Wires; diff --git a/Content.Shared/CombatMode/SharedCombatModeSystem.cs b/Content.Shared/CombatMode/SharedCombatModeSystem.cs index 4592dd7546..e16829c479 100644 --- a/Content.Shared/CombatMode/SharedCombatModeSystem.cs +++ b/Content.Shared/CombatMode/SharedCombatModeSystem.cs @@ -16,7 +16,7 @@ namespace Content.Shared.CombatMode { var entity = eventArgs.SenderSession.AttachedEntity; - if (entity == null || !EntityManager.TryGetComponent(entity.Value, out SharedCombatModeComponent? combatModeComponent)) + if (entity == null || !EntityManager.TryGetComponent(entity, out SharedCombatModeComponent? combatModeComponent)) { return; } diff --git a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs index da03ac4e28..bf62dbe3bb 100644 --- a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs +++ b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs @@ -244,14 +244,14 @@ namespace Content.Shared.Containers.ItemSlots if (!hands.TryGetActiveHeldEntity(out var item)) return false; - if (!CanInsert(uid, item.Value, slot)) + if (!CanInsert(uid, item, slot)) return false; // hands.Drop(item) checks CanDrop action blocker - if (!_actionBlockerSystem.CanInteract(user) && hands.Drop(item.Value)) + if (!_actionBlockerSystem.CanInteract(user) && hands.Drop(item)) return false; - Insert(uid, slot, item.Value); + Insert(uid, slot, item); return true; } #endregion diff --git a/Content.Shared/Cuffs/SharedCuffableSystem.cs b/Content.Shared/Cuffs/SharedCuffableSystem.cs index c6d3d5cf5c..d4c42a3355 100644 --- a/Content.Shared/Cuffs/SharedCuffableSystem.cs +++ b/Content.Shared/Cuffs/SharedCuffableSystem.cs @@ -35,9 +35,9 @@ namespace Content.Shared.Cuffs private void HandleStopPull(EntityUid uid, SharedCuffableComponent component, StopPullingEvent args) { - if (args.User == null || !EntityManager.EntityExists(args.User.Value) return; + if (args.User == null || !EntityManager.EntityExists(args.User.Value)) return; - if (user == component.Owner && !component.CanStillInteract) + if (args.User.Value == component.Owner && !component.CanStillInteract) { args.Cancel(); } diff --git a/Content.Shared/Gravity/SharedGravitySystem.cs b/Content.Shared/Gravity/SharedGravitySystem.cs index 8f5741e215..e3b651b87c 100644 --- a/Content.Shared/Gravity/SharedGravitySystem.cs +++ b/Content.Shared/Gravity/SharedGravitySystem.cs @@ -12,8 +12,7 @@ namespace Content.Shared.Gravity private void HandleGridInitialize(GridInitializeEvent ev) { - var gridev.EntityUid - gridEnt.EnsureComponent(); + EntityManager.EnsureComponent(ev.EntityUid); } } } diff --git a/Content.Shared/Hands/Components/SharedHandsComponent.cs b/Content.Shared/Hands/Components/SharedHandsComponent.cs index ec2bc45be6..357694ba31 100644 --- a/Content.Shared/Hands/Components/SharedHandsComponent.cs +++ b/Content.Shared/Hands/Components/SharedHandsComponent.cs @@ -112,7 +112,7 @@ namespace Content.Shared.Hands.Components if (hand.HeldEntity == null) continue; - if (!entMan.TryGetComponent(hand.HeldEntity.Value, out SharedItemComponent? item) || item.RsiPath == null) + if (!entMan.TryGetComponent(hand.HeldEntity, out SharedItemComponent? item) || item.RsiPath == null) continue; var handState = new HandVisualState(item.RsiPath, item.EquippedPrefix, hand.Location, item.Color); @@ -250,7 +250,7 @@ namespace Content.Shared.Hands.Components foreach (var hand in Hands) { if (hand.HeldEntity != default) - yield return hand.HeldEntity.Value; + yield return hand.HeldEntity; } } @@ -416,7 +416,7 @@ namespace Content.Shared.Hands.Components if (hand.HeldEntity == null) return false; - var heldEntity = hand.HeldEntity.Value; + var heldEntity = hand.HeldEntity; var handContainer = hand.Container; if (handContainer == null) @@ -447,7 +447,7 @@ namespace Content.Shared.Hands.Components if (hand.HeldEntity == null) return; - var heldEntity = hand.HeldEntity.Value; + var heldEntity = hand.HeldEntity; var handContainer = hand.Container; if (handContainer == null) @@ -475,7 +475,7 @@ namespace Content.Shared.Hands.Components if (hand.HeldEntity == null) return; - var heldEntity = hand.HeldEntity.Value; + var heldEntity = hand.HeldEntity; RemoveHeldEntityFromHand(hand); @@ -538,7 +538,7 @@ namespace Content.Shared.Hands.Components if (hand.HeldEntity == null) return false; - var heldEntity = hand.HeldEntity.Value; + var heldEntity = hand.HeldEntity; if (checkActionBlocker && !PlayerCanDrop()) return false; @@ -557,7 +557,7 @@ namespace Content.Shared.Hands.Components if (hand.HeldEntity == null) return; - var heldEntity = hand.HeldEntity.Value; + var heldEntity = hand.HeldEntity; RemoveHeldEntityFromHand(hand); @@ -713,7 +713,7 @@ namespace Content.Shared.Hands.Components return; await EntitySystem.Get() - .InteractUsing(Owner, activeHeldEntity.Value, heldEntity.Value, EntityCoordinates.Invalid); + .InteractUsing(Owner, activeHeldEntity, heldEntity, EntityCoordinates.Invalid); } public void ActivateItem(bool altInteract = false) @@ -722,7 +722,7 @@ namespace Content.Shared.Hands.Components return; EntitySystem.Get() - .TryUseInteraction(Owner, heldEntity.Value, altInteract); + .TryUseInteraction(Owner, heldEntity, altInteract); } public void ActivateHeldEntity(string handName) @@ -745,14 +745,14 @@ namespace Content.Shared.Hands.Components if (!TryGetHeldEntity(handName, out var heldEntity)) return false; - if (!CanInsertEntityIntoHand(activeHand, heldEntity.Value) || !CanRemoveHeldEntityFromHand(hand)) + if (!CanInsertEntityIntoHand(activeHand, heldEntity) || !CanRemoveHeldEntityFromHand(hand)) return false; if (checkActionBlocker && (!PlayerCanDrop() || !PlayerCanPickup())) return false; RemoveHeldEntityFromHand(hand); - PutEntityIntoHand(activeHand, heldEntity.Value); + PutEntityIntoHand(activeHand, heldEntity); return true; } @@ -761,13 +761,13 @@ namespace Content.Shared.Hands.Components private void DeselectActiveHeldEntity() { if (TryGetActiveHeldEntity(out var entity)) - EntitySystem.Get().HandDeselectedInteraction(Owner, entity.Value); + EntitySystem.Get().HandDeselectedInteraction(Owner, entity); } private void SelectActiveHeldEntity() { if (TryGetActiveHeldEntity(out var entity)) - EntitySystem.Get().HandSelectedInteraction(Owner, entity.Value); + EntitySystem.Get().HandSelectedInteraction(Owner, entity); } private void HandCountChanged() diff --git a/Content.Shared/Hands/SharedHandsSystem.cs b/Content.Shared/Hands/SharedHandsSystem.cs index eed8c4e5c4..11dfda05ed 100644 --- a/Content.Shared/Hands/SharedHandsSystem.cs +++ b/Content.Shared/Hands/SharedHandsSystem.cs @@ -22,7 +22,7 @@ namespace Content.Shared.Hands { var entity = eventArgs.SenderSession.AttachedEntity; - if (entity == default || !EntityManager.TryGetComponent(entity, out SharedHandsComponent? hands)) + if (entity == null || !EntityManager.TryGetComponent(entity, out SharedHandsComponent? hands)) return; hands.ActiveHand = msg.HandName; diff --git a/Content.Shared/Pulling/Systems/SharedPullableSystem.cs b/Content.Shared/Pulling/Systems/SharedPullableSystem.cs index 7c4d1bf85c..f05240bfca 100644 --- a/Content.Shared/Pulling/Systems/SharedPullableSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullableSystem.cs @@ -20,7 +20,7 @@ namespace Content.Shared.Pulling.Systems private void OnRelayMoveInput(EntityUid uid, SharedPullableComponent component, RelayMoveInputEvent args) { var entity = args.Session.AttachedEntity; - if (!entity.HasValue || !_blocker.CanMove(entity.Value)) return; + if (entity == default || !_blocker.CanMove(entity)) return; _pullSystem.TryStopPull(component); } }