From a2bbda43cc1669596942048c60b4ca80c00bbe6b Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Tue, 24 Oct 2023 21:55:20 +1100 Subject: [PATCH] Revert "Update submodule to 172.0.0 (#21222)" (#21225) --- Content.Client/Actions/ActionsSystem.cs | 9 +- .../Managers/ClientAdminManager.cs | 2 +- .../UI/Tabs/AdminTab/TeleportWindow.xaml.cs | 1 + Content.Client/Alerts/ClientAlertsSystem.cs | 9 +- .../CharacterInfo/CharacterInfoSystem.cs | 12 ++ .../Construction/ConstructionSystem.cs | 6 +- Content.Client/Drugs/DrugOverlaySystem.cs | 9 +- Content.Client/Drunk/DrunkSystem.cs | 9 +- Content.Client/Eye/Blinding/BlindingSystem.cs | 18 +- .../Eye/Blinding/BlurryVisionSystem.cs | 11 +- Content.Client/Eye/EyeLerpingSystem.cs | 4 +- Content.Client/Fullscreen/FullscreenHook.cs | 2 +- Content.Client/Gameplay/GameplayStateBase.cs | 2 +- Content.Client/Ghost/GhostSystem.cs | 12 +- Content.Client/Hands/Systems/HandsSystem.cs | 8 +- .../HealthOverlay/HealthOverlaySystem.cs | 13 +- .../Inventory/ClientInventorySystem.cs | 9 +- Content.Client/Mind/MindSystem.cs | 20 --- Content.Client/Overlays/EquipmentHudSystem.cs | 9 +- .../Physics/Controllers/MoverController.cs | 17 +- Content.Client/Players/PlayerSystem.cs | 4 +- Content.Client/Popups/PopupSystem.cs | 1 + .../ReplaySpectatorSystem.Movement.cs | 2 +- .../ReplaySpectatorSystem.Position.cs | 12 +- .../ReplaySpectatorSystem.Spectate.cs | 14 +- .../Replay/Spectator/ReplaySpectatorSystem.cs | 3 +- Content.Client/Sandbox/SandboxSystem.cs | 2 +- Content.Client/Traits/ParacusiaSystem.cs | 6 +- .../Character/CharacterUIController.cs | 8 +- .../Systems/Chat/ChatUIController.cs | 29 +++- .../DamageOverlayUiController.cs | 10 +- .../Systems/Sandbox/SandboxUIController.cs | 2 +- .../Weapons/Melee/MeleeWeaponSystem.cs | 3 +- Content.IntegrationTests/Pair/TestPair.cs | 8 +- .../Tests/Actions/ActionsAddedTest.cs | 4 +- .../Tests/Administration/Logs/AddTests.cs | 8 +- .../Tests/Administration/Logs/QueryTests.cs | 5 +- .../Tests/Cleanup/EuiManagerTest.cs | 2 +- .../Tests/Interaction/InteractionTest.cs | 5 +- .../Tests/Minds/GhostRoleTests.cs | 3 +- .../Tests/Minds/MindTests.EntityDeletion.cs | 13 +- .../Tests/Minds/MindTests.Helpers.cs | 20 +-- .../Tests/Minds/MindTests.ReconnectTests.cs | 9 +- .../Tests/Minds/MindTests.cs | 30 ++-- .../Tests/Toolshed/ToolshedTest.cs | 7 +- Content.MapRenderer/Painters/MapPainter.cs | 2 +- .../AdminPermsChangedEventArgs.cs | 6 +- .../Administration/Commands/AGhost.cs | 3 +- .../Commands/AdminWhoCommand.cs | 3 +- .../Commands/AnnounceUiCommand.cs | 3 +- .../Administration/Commands/BanCommand.cs | 11 +- .../Administration/Commands/BanListCommand.cs | 4 +- .../Commands/BanPanelCommand.cs | 8 +- .../Administration/Commands/ControlMob.cs | 14 +- .../Administration/Commands/DSay.cs | 4 +- .../Administration/Commands/DeAdminCommand.cs | 4 +- .../Commands/ExplosionCommand.cs | 3 +- .../Administration/Commands/FaxUiCommand.cs | 3 +- .../Commands/OpenAdminLogsCommand.cs | 3 +- .../Commands/OpenAdminNotesCommand.cs | 4 +- .../Commands/OpenPermissionsCommand.cs | 4 +- .../Commands/OpenUserVisibleNotesCommand.cs | 3 +- .../Administration/Commands/PardonCommand.cs | 3 +- .../Commands/PlayGlobalSoundCommand.cs | 1 + .../Administration/Commands/ReAdminCommand.cs | 4 +- .../Administration/Commands/SetAdminOOC.cs | 4 +- .../Administration/Commands/SetMindCommand.cs | 1 - .../Commands/SetOutfitCommand.cs | 3 +- .../Administration/Commands/WarpCommand.cs | 4 +- .../ContentNetworkResourceManager.cs | 4 +- .../Logs/AdminLogManager.Json.cs | 6 +- .../Logs/Converters/PlayerSessionConverter.cs | 6 +- .../Administration/Managers/AdminManager.cs | 52 +++--- .../Administration/Managers/BanManager.cs | 3 +- .../Administration/Managers/IAdminManager.cs | 15 +- .../Administration/Managers/IBanManager.cs | 4 +- .../Administration/Notes/AdminNotesManager.cs | 2 +- .../Administration/Notes/AdminNotesSystem.cs | 2 +- .../Notes/IAdminNotesManager.cs | 2 +- .../QuickDialogSystem.OpenDialog.cs | 10 +- .../Administration/QuickDialogSystem.cs | 7 +- .../Administration/Systems/AdminSystem.cs | 8 +- .../Systems/AdminTestArenaSystem.cs | 4 +- .../Administration/Systems/AdminVerbSystem.cs | 18 +- .../Administration/Systems/BwoinkSystem.cs | 5 +- .../Administration/Toolshed/AdminsCommand.cs | 6 +- Content.Server/Afk/AFKSystem.cs | 9 +- Content.Server/Afk/AfkManager.cs | 15 +- Content.Server/Afk/Events/AFKEvent.cs | 6 +- Content.Server/Afk/Events/UnAFKEvent.cs | 6 +- Content.Server/Alert/Commands/ClearAlert.cs | 3 +- Content.Server/Alert/Commands/ShowAlert.cs | 3 +- .../Commands/SetAlertLevelCommand.cs | 5 +- Content.Server/Antag/AntagSelectionSystem.cs | 9 +- .../Arcade/BlockGame/BlockGame.Ui.cs | 20 +-- .../BlockGame/BlockGameArcadeComponent.cs | 6 +- .../Arcade/BlockGame/BlockGameArcadeSystem.cs | 6 +- .../Atmos/Commands/DeleteGasCommand.cs | 3 +- .../Atmos/Commands/ShowAtmosCommand.cs | 3 +- .../EntitySystems/AtmosDebugOverlaySystem.cs | 11 +- .../Atmos/EntitySystems/GasTankSystem.cs | 7 + .../EntitySystems/GasTileOverlaySystem.cs | 7 +- .../Body/Commands/AddHandCommand.cs | 3 +- .../Body/Commands/AttachBodyPartCommand.cs | 4 +- .../Body/Commands/DestroyMechanismCommand.cs | 3 +- .../Body/Commands/RemoveHandCommand.cs | 3 +- Content.Server/Body/Systems/BodySystem.cs | 2 +- .../Cargo/Systems/CargoSystem.Orders.cs | 2 +- .../CartridgeLoader/CartridgeLoaderSystem.cs | 6 +- .../Chat/Commands/AdminChatCommand.cs | 3 +- Content.Server/Chat/Commands/LOOCCommand.cs | 3 +- Content.Server/Chat/Commands/MeCommand.cs | 3 +- Content.Server/Chat/Commands/OOCCommand.cs | 3 +- Content.Server/Chat/Commands/SayCommand.cs | 3 +- .../Chat/Commands/SuicideCommand.cs | 3 +- .../Chat/Commands/WhisperCommand.cs | 3 +- Content.Server/Chat/Managers/ChatManager.cs | 16 +- Content.Server/Chat/Managers/IChatManager.cs | 12 +- Content.Server/Chat/Systems/ChatSystem.cs | 21 +-- .../EntitySystems/ChemistryGuideDataSystem.cs | 1 - Content.Server/Chunking/ChunkingSystem.cs | 6 +- Content.Server/Commands/CommandUtils.cs | 7 +- .../Commands/FixRotationsCommand.cs | 3 +- .../Commands/TileReplaceCommand.cs | 3 +- .../Construction/Commands/TileWallsCommand.cs | 5 +- .../ConstructionSystem.Initial.cs | 2 +- .../CrewManifest/CrewManifestSystem.cs | 17 +- .../Damage/Commands/GodModeCommand.cs | 4 +- .../Damage/ForceSay/DamageForceSaySystem.cs | 1 + Content.Server/Database/UserDbDataManager.cs | 14 +- Content.Server/Decals/DecalSystem.cs | 13 +- .../Disposal/TubeConnectionsCommand.cs | 3 +- Content.Server/EUI/BaseEui.cs | 2 +- Content.Server/EUI/EuiManager.cs | 2 +- .../EntityList/SpawnEntityListCommand.cs | 3 +- Content.Server/Examine/ExamineSystem.cs | 3 +- .../PuddleDebugDebugOverlaySystem.cs | 8 +- Content.Server/Fluids/ShowFluidsCommand.cs | 3 +- .../GameTicking/Commands/JoinGameCommand.cs | 3 +- .../GameTicking/Commands/ObserveCommand.cs | 3 +- .../GameTicking/Commands/RespawnCommand.cs | 2 +- .../Commands/ToggleReadyCommand.cs | 3 +- .../GameTicking/GameTicker.GamePreset.cs | 6 +- .../GameTicking/GameTicker.Lobby.cs | 8 +- .../GameTicking/GameTicker.Player.cs | 19 +- .../GameTicking/GameTicker.RoundFlow.cs | 24 +-- .../GameTicking/GameTicker.Spawning.cs | 28 +-- .../Rules/Components/TraitorRuleComponent.cs | 4 +- .../Rules/InactivityTimeRestartRuleSystem.cs | 1 - .../GameTicking/Rules/NukeopsRuleSystem.cs | 18 +- .../GameTicking/Rules/PiratesRuleSystem.cs | 4 +- .../GameTicking/Rules/RespawnRuleSystem.cs | 1 - .../GameTicking/Rules/TraitorRuleSystem.cs | 13 +- .../GameTicking/Rules/ZombieRuleSystem.cs | 10 +- Content.Server/Ghost/Ghost.cs | 3 +- .../Roles/Components/TakeGhostRoleEvent.cs | 2 +- Content.Server/Ghost/Roles/GhostRoleSystem.cs | 10 +- .../Gravity/GravityGeneratorSystem.cs | 4 +- Content.Server/Hands/Systems/HandsSystem.cs | 9 +- .../HumanoidAppearanceSystem.Modifier.cs | 5 +- .../Instruments/InstrumentComponent.cs | 4 +- .../Instruments/InstrumentSystem.cs | 6 +- .../Interaction/InteractionSystem.cs | 1 + Content.Server/Interaction/TilePryCommand.cs | 5 +- .../MagicMirror/MagicMirrorSystem.cs | 5 +- Content.Server/Mapping/MappingCommand.cs | 2 +- Content.Server/Maps/GridDraggingSystem.cs | 9 +- Content.Server/Medical/DefibrillatorSystem.cs | 2 +- Content.Server/Mind/Commands/RenameCommand.cs | 1 - Content.Server/Mind/MindSystem.cs | 162 +++++++----------- Content.Server/Mind/Toolshed/MindCommand.cs | 6 +- Content.Server/Motd/MOTDCommand.cs | 7 +- Content.Server/Motd/MOTDSystem.cs | 14 +- Content.Server/Motd/SetMOTDCommand.cs | 7 +- .../Movement/Systems/LagCompensationSystem.cs | 2 +- Content.Server/NPC/Commands/NPCCommand.cs | 3 +- Content.Server/NPC/HTN/HTNSystem.cs | 7 +- .../NPC/Pathfinding/PathfindingSystem.cs | 4 +- .../NPC/Systems/NPCSteeringSystem.cs | 4 +- .../EntitySystems/NodeGroupSystem.cs | 7 +- Content.Server/Nutrition/Hungry.cs | 4 +- .../Commands/ListObjectivesCommand.cs | 2 +- Content.Server/PDA/PdaSystem.cs | 8 +- Content.Server/PDA/Ringer/RingerSystem.cs | 3 +- Content.Server/Paper/PaperSystem.cs | 6 +- Content.Server/Parallax/BiomeSystem.cs | 3 +- .../ParticleAcceleratorSystem.ControlBox.cs | 17 +- .../ParticleAcceleratorSystem.Parts.cs | 4 +- .../PlayTimeTrackingManager.cs | 40 ++--- .../PlayTimeTrackingSystem.cs | 13 +- Content.Server/Players/PlayerData.cs | 30 ++++ Content.Server/Players/PlayerSystem.cs | 4 +- .../Pointing/EntitySystems/PointingSystem.cs | 5 +- Content.Server/Popups/PopupSystem.cs | 1 + Content.Server/Prayer/PrayerSystem.cs | 7 +- .../Managers/IServerPreferencesManager.cs | 8 +- .../Managers/ServerPreferencesManager.cs | 8 +- Content.Server/Pulling/PullingSystem.cs | 2 +- .../Systems/RadiationSystem.Debug.cs | 2 +- .../Research/Systems/ResearchSystem.Client.cs | 3 +- Content.Server/Salvage/SalvageRulerCommand.cs | 3 +- .../Sandbox/Commands/ColorNetworkCommand.cs | 3 +- Content.Server/Sandbox/SandboxSystem.cs | 1 - .../SensorMonitoringConsoleComponent.cs | 2 +- .../SensorMonitoringConsoleSystem.UI.cs | 4 +- .../ServerUpdates/ServerUpdateManager.cs | 1 - .../Systems/EmergencyShuttleSystem.cs | 3 +- .../Silicons/Borgs/BorgSystem.Modules.cs | 2 +- Content.Server/Silicons/Borgs/BorgSystem.cs | 2 +- .../Silicons/Laws/SiliconLawSystem.cs | 5 +- .../Station/Systems/StationJobsSystem.cs | 2 +- .../Storage/EntitySystems/StorageSystem.cs | 3 +- Content.Server/Tabletop/TabletopSession.cs | 4 +- .../Tabletop/TabletopSystem.Session.cs | 8 +- Content.Server/Tabletop/TabletopSystem.cs | 7 +- .../Commands/AdminDebug/ACmdCommand.cs | 4 +- .../Toolshed/Commands/VisualizeCommand.cs | 3 +- .../Uplink/Commands/AddUplinkCommand.cs | 5 +- .../UserInterface/ActivatableUIComponent.cs | 4 +- .../UserInterface/ActivatableUISystem.cs | 8 +- .../UserInterface/StatValuesCommand.cs | 3 +- Content.Server/Verbs/VerbSystem.cs | 5 +- Content.Server/Voting/IVoteHandle.cs | 4 +- .../Voting/Managers/IVoteManager.cs | 6 +- .../Managers/VoteManager.DefaultVotes.cs | 12 +- Content.Server/Voting/Managers/VoteManager.cs | 31 ++-- Content.Server/Voting/VoteCommands.cs | 9 +- Content.Server/Voting/VoteOptions.cs | 8 +- .../Weapons/Melee/MeleeWeaponSystem.cs | 4 +- Content.Server/Wires/WiresSystem.cs | 4 +- .../Systems/ArtifactAnalyzerSystem.cs | 3 +- .../Managers/ISharedAdminManager.cs | 2 +- Content.Shared/Buckle/SharedBuckleSystem.cs | 2 +- .../SharedHandsSystem.Interactions.cs | 2 +- .../Interaction/SharedInteractionSystem.cs | 2 +- .../Mind/Components/MindContainerComponent.cs | 65 ++----- Content.Shared/Mind/MindComponent.cs | 49 +++--- Content.Shared/Mind/SharedMindSystem.cs | 91 +++------- .../Movement/Events/MoveInputEvent.cs | 2 + .../Systems/SharedContentEyeSystem.cs | 2 +- .../Systems/SharedMoverController.Input.cs | 2 +- .../{ContentPlayerData.cs => PlayerData.cs} | 21 ++- Content.Shared/Players/PlayerDataExt.cs | 30 ---- Content.Shared/Players/SharedPlayerSystem.cs | 4 +- Content.Shared/Popups/SharedPopupSystem.cs | 1 + .../Pulling/Systems/SharedPullingSystem.cs | 2 +- Content.Shared/Roles/Jobs/SharedJobSystem.cs | 2 +- .../Weapons/Melee/SharedMeleeWeaponSystem.cs | 2 +- RobustToolbox | 2 +- 249 files changed, 1048 insertions(+), 966 deletions(-) create mode 100644 Content.Server/Players/PlayerData.cs rename Content.Shared/Players/{ContentPlayerData.cs => PlayerData.cs} (73%) delete mode 100644 Content.Shared/Players/PlayerDataExt.cs diff --git a/Content.Client/Actions/ActionsSystem.cs b/Content.Client/Actions/ActionsSystem.cs index a487e5d8d8..83d927c94b 100644 --- a/Content.Client/Actions/ActionsSystem.cs +++ b/Content.Client/Actions/ActionsSystem.cs @@ -2,6 +2,7 @@ using System.IO; using System.Linq; using Content.Shared.Actions; using JetBrains.Annotations; +using Robust.Client.GameObjects; using Robust.Client.Player; using Robust.Shared.ContentPack; using Robust.Shared.GameStates; @@ -40,8 +41,8 @@ namespace Content.Client.Actions public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnPlayerAttached); - SubscribeLocalEvent(OnPlayerDetached); + SubscribeLocalEvent(OnPlayerAttached); + SubscribeLocalEvent(OnPlayerDetached); SubscribeLocalEvent(HandleComponentState); SubscribeLocalEvent(OnInstantHandleState); @@ -195,12 +196,12 @@ namespace Content.Client.Actions return GetActions(user); } - private void OnPlayerAttached(EntityUid uid, ActionsComponent component, LocalPlayerAttachedEvent args) + private void OnPlayerAttached(EntityUid uid, ActionsComponent component, PlayerAttachedEvent args) { LinkAllActions(component); } - private void OnPlayerDetached(EntityUid uid, ActionsComponent component, LocalPlayerDetachedEvent? args = null) + private void OnPlayerDetached(EntityUid uid, ActionsComponent component, PlayerDetachedEvent? args = null) { UnlinkAllActions(); } diff --git a/Content.Client/Administration/Managers/ClientAdminManager.cs b/Content.Client/Administration/Managers/ClientAdminManager.cs index 1a1366c6f2..8978e2fd6d 100644 --- a/Content.Client/Administration/Managers/ClientAdminManager.cs +++ b/Content.Client/Administration/Managers/ClientAdminManager.cs @@ -4,7 +4,7 @@ using Robust.Client.Console; using Robust.Client.Player; using Robust.Shared.ContentPack; using Robust.Shared.Network; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Utility; namespace Content.Client.Administration.Managers diff --git a/Content.Client/Administration/UI/Tabs/AdminTab/TeleportWindow.xaml.cs b/Content.Client/Administration/UI/Tabs/AdminTab/TeleportWindow.xaml.cs index 1978b5c3c0..c5a9bd036a 100644 --- a/Content.Client/Administration/UI/Tabs/AdminTab/TeleportWindow.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/AdminTab/TeleportWindow.xaml.cs @@ -5,6 +5,7 @@ using Robust.Client.Console; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; using Robust.Shared.IoC; +using Robust.Shared.Players; namespace Content.Client.Administration.UI.Tabs.AdminTab { diff --git a/Content.Client/Alerts/ClientAlertsSystem.cs b/Content.Client/Alerts/ClientAlertsSystem.cs index 5089022415..bb6d2d4df4 100644 --- a/Content.Client/Alerts/ClientAlertsSystem.cs +++ b/Content.Client/Alerts/ClientAlertsSystem.cs @@ -1,6 +1,7 @@ using System.Linq; using Content.Shared.Alert; using JetBrains.Annotations; +using Robust.Client.GameObjects; using Robust.Client.Player; using Robust.Shared.Prototypes; @@ -21,8 +22,8 @@ public sealed class ClientAlertsSystem : AlertsSystem { base.Initialize(); - SubscribeLocalEvent(OnPlayerAttached); - SubscribeLocalEvent(OnPlayerDetached); + SubscribeLocalEvent(OnPlayerAttached); + SubscribeLocalEvent(OnPlayerDetached); SubscribeLocalEvent(ClientAlertsHandleState); } @@ -68,7 +69,7 @@ public sealed class ClientAlertsSystem : AlertsSystem SyncAlerts?.Invoke(this, component.Alerts); } - private void OnPlayerAttached(EntityUid uid, AlertsComponent component, LocalPlayerAttachedEvent args) + private void OnPlayerAttached(EntityUid uid, AlertsComponent component, PlayerAttachedEvent args) { if (_playerManager.LocalPlayer?.ControlledEntity != uid) return; @@ -86,7 +87,7 @@ public sealed class ClientAlertsSystem : AlertsSystem ClearAlerts?.Invoke(this, EventArgs.Empty); } - private void OnPlayerDetached(EntityUid uid, AlertsComponent component, LocalPlayerDetachedEvent args) + private void OnPlayerDetached(EntityUid uid, AlertsComponent component, PlayerDetachedEvent args) { ClearAlerts?.Invoke(this, EventArgs.Empty); } diff --git a/Content.Client/CharacterInfo/CharacterInfoSystem.cs b/Content.Client/CharacterInfo/CharacterInfoSystem.cs index 844a352a18..93bd86d140 100644 --- a/Content.Client/CharacterInfo/CharacterInfoSystem.cs +++ b/Content.Client/CharacterInfo/CharacterInfoSystem.cs @@ -1,5 +1,6 @@ using Content.Shared.CharacterInfo; using Content.Shared.Objectives; +using Robust.Client.GameObjects; using Robust.Client.Player; using Robust.Client.UserInterface; @@ -10,11 +11,14 @@ public sealed class CharacterInfoSystem : EntitySystem [Dependency] private readonly IPlayerManager _players = default!; public event Action? OnCharacterUpdate; + public event Action? OnCharacterDetached; public override void Initialize() { base.Initialize(); + SubscribeLocalEvent(OnPlayerAttached); + SubscribeNetworkEvent(OnCharacterInfoEvent); } @@ -29,6 +33,14 @@ public sealed class CharacterInfoSystem : EntitySystem RaiseNetworkEvent(new RequestCharacterInfoEvent(GetNetEntity(entity.Value))); } + private void OnPlayerAttached(PlayerAttachSysMessage msg) + { + if (msg.AttachedEntity == default) + { + OnCharacterDetached?.Invoke(); + } + } + private void OnCharacterInfoEvent(CharacterInfoEvent msg, EntitySessionEventArgs args) { var entity = GetEntity(msg.NetEntity); diff --git a/Content.Client/Construction/ConstructionSystem.cs b/Content.Client/Construction/ConstructionSystem.cs index 9fc638cea2..98d2dfd414 100644 --- a/Content.Client/Construction/ConstructionSystem.cs +++ b/Content.Client/Construction/ConstructionSystem.cs @@ -38,7 +38,7 @@ namespace Content.Client.Construction base.Initialize(); UpdatesOutsidePrediction = true; - SubscribeLocalEvent(HandlePlayerAttached); + SubscribeLocalEvent(HandlePlayerAttached); SubscribeNetworkEvent(HandleAckStructure); SubscribeNetworkEvent(OnConstructionGuideReceived); @@ -110,9 +110,9 @@ namespace Content.Client.Construction ClearGhost(msg.GhostId); } - private void HandlePlayerAttached(LocalPlayerAttachedEvent msg) + private void HandlePlayerAttached(PlayerAttachSysMessage msg) { - var available = IsCraftingAvailable(msg.Entity); + var available = IsCraftingAvailable(msg.AttachedEntity); UpdateCraftingAvailability(available); } diff --git a/Content.Client/Drugs/DrugOverlaySystem.cs b/Content.Client/Drugs/DrugOverlaySystem.cs index ec0d014072..7be63b4c50 100644 --- a/Content.Client/Drugs/DrugOverlaySystem.cs +++ b/Content.Client/Drugs/DrugOverlaySystem.cs @@ -1,4 +1,5 @@ using Content.Shared.Drugs; +using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Client.Player; @@ -23,18 +24,18 @@ public sealed class DrugOverlaySystem : EntitySystem SubscribeLocalEvent(OnInit); SubscribeLocalEvent(OnShutdown); - SubscribeLocalEvent(OnPlayerAttached); - SubscribeLocalEvent(OnPlayerDetached); + SubscribeLocalEvent(OnPlayerAttached); + SubscribeLocalEvent(OnPlayerDetached); _overlay = new(); } - private void OnPlayerAttached(EntityUid uid, SeeingRainbowsComponent component, LocalPlayerAttachedEvent args) + private void OnPlayerAttached(EntityUid uid, SeeingRainbowsComponent component, PlayerAttachedEvent args) { _overlayMan.AddOverlay(_overlay); } - private void OnPlayerDetached(EntityUid uid, SeeingRainbowsComponent component, LocalPlayerDetachedEvent args) + private void OnPlayerDetached(EntityUid uid, SeeingRainbowsComponent component, PlayerDetachedEvent args) { _overlay.Intoxication = 0; _overlayMan.RemoveOverlay(_overlay); diff --git a/Content.Client/Drunk/DrunkSystem.cs b/Content.Client/Drunk/DrunkSystem.cs index 4f2ec70b56..0573b2ff3e 100644 --- a/Content.Client/Drunk/DrunkSystem.cs +++ b/Content.Client/Drunk/DrunkSystem.cs @@ -1,4 +1,5 @@ using Content.Shared.Drunk; +using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Client.Player; @@ -18,18 +19,18 @@ public sealed class DrunkSystem : SharedDrunkSystem SubscribeLocalEvent(OnDrunkInit); SubscribeLocalEvent(OnDrunkShutdown); - SubscribeLocalEvent(OnPlayerAttached); - SubscribeLocalEvent(OnPlayerDetached); + SubscribeLocalEvent(OnPlayerAttached); + SubscribeLocalEvent(OnPlayerDetached); _overlay = new(); } - private void OnPlayerAttached(EntityUid uid, DrunkComponent component, LocalPlayerAttachedEvent args) + private void OnPlayerAttached(EntityUid uid, DrunkComponent component, PlayerAttachedEvent args) { _overlayMan.AddOverlay(_overlay); } - private void OnPlayerDetached(EntityUid uid, DrunkComponent component, LocalPlayerDetachedEvent args) + private void OnPlayerDetached(EntityUid uid, DrunkComponent component, PlayerDetachedEvent args) { _overlay.CurrentBoozePower = 0; _overlayMan.RemoveOverlay(_overlay); diff --git a/Content.Client/Eye/Blinding/BlindingSystem.cs b/Content.Client/Eye/Blinding/BlindingSystem.cs index f255f7ef01..f0b760d838 100644 --- a/Content.Client/Eye/Blinding/BlindingSystem.cs +++ b/Content.Client/Eye/Blinding/BlindingSystem.cs @@ -1,7 +1,17 @@ + +using Content.Shared.Eye.Blinding; +using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Client.Player; +using System; +using System.Collections.Generic; +using System.Linq; +using Content.Shared.Administration; +using Content.Shared.Administration.Events; using Content.Shared.Eye.Blinding.Components; using Content.Shared.GameTicking; +using Robust.Shared.GameObjects; +using Robust.Shared.Network; namespace Content.Client.Eye.Blinding; @@ -21,20 +31,20 @@ public sealed class BlindingSystem : EntitySystem SubscribeLocalEvent(OnBlindInit); SubscribeLocalEvent(OnBlindShutdown); - SubscribeLocalEvent(OnPlayerAttached); - SubscribeLocalEvent(OnPlayerDetached); + SubscribeLocalEvent(OnPlayerAttached); + SubscribeLocalEvent(OnPlayerDetached); SubscribeNetworkEvent(RoundRestartCleanup); _overlay = new(); } - private void OnPlayerAttached(EntityUid uid, BlindableComponent component, LocalPlayerAttachedEvent args) + private void OnPlayerAttached(EntityUid uid, BlindableComponent component, PlayerAttachedEvent args) { _overlayMan.AddOverlay(_overlay); } - private void OnPlayerDetached(EntityUid uid, BlindableComponent component, LocalPlayerDetachedEvent args) + private void OnPlayerDetached(EntityUid uid, BlindableComponent component, PlayerDetachedEvent args) { _overlayMan.RemoveOverlay(_overlay); _lightManager.Enabled = true; diff --git a/Content.Client/Eye/Blinding/BlurryVisionSystem.cs b/Content.Client/Eye/Blinding/BlurryVisionSystem.cs index 8be5b4ed93..1bac2a97bf 100644 --- a/Content.Client/Eye/Blinding/BlurryVisionSystem.cs +++ b/Content.Client/Eye/Blinding/BlurryVisionSystem.cs @@ -1,6 +1,9 @@ +using Content.Shared.Eye.Blinding; using Content.Shared.Eye.Blinding.Components; +using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Client.Player; +using Robust.Shared.GameStates; namespace Content.Client.Eye.Blinding; @@ -17,18 +20,18 @@ public sealed class BlurryVisionSystem : EntitySystem SubscribeLocalEvent(OnBlurryInit); SubscribeLocalEvent(OnBlurryShutdown); - SubscribeLocalEvent(OnPlayerAttached); - SubscribeLocalEvent(OnPlayerDetached); + SubscribeLocalEvent(OnPlayerAttached); + SubscribeLocalEvent(OnPlayerDetached); _overlay = new(); } - private void OnPlayerAttached(EntityUid uid, BlurryVisionComponent component, LocalPlayerAttachedEvent args) + private void OnPlayerAttached(EntityUid uid, BlurryVisionComponent component, PlayerAttachedEvent args) { _overlayMan.AddOverlay(_overlay); } - private void OnPlayerDetached(EntityUid uid, BlurryVisionComponent component, LocalPlayerDetachedEvent args) + private void OnPlayerDetached(EntityUid uid, BlurryVisionComponent component, PlayerDetachedEvent args) { _overlayMan.RemoveOverlay(_overlay); } diff --git a/Content.Client/Eye/EyeLerpingSystem.cs b/Content.Client/Eye/EyeLerpingSystem.cs index b46921a9b4..8e54196b81 100644 --- a/Content.Client/Eye/EyeLerpingSystem.cs +++ b/Content.Client/Eye/EyeLerpingSystem.cs @@ -30,7 +30,7 @@ public sealed class EyeLerpingSystem : EntitySystem SubscribeLocalEvent(OnAttached); SubscribeLocalEvent(HandleMapChange); - SubscribeLocalEvent(OnDetached); + SubscribeLocalEvent(OnDetached); UpdatesAfter.Add(typeof(TransformSystem)); UpdatesAfter.Add(typeof(PhysicsSystem)); @@ -94,7 +94,7 @@ public sealed class EyeLerpingSystem : EntitySystem AddEye(ev.Entity, ev.Component, true); } - private void OnDetached(EntityUid uid, LerpingEyeComponent component, LocalPlayerDetachedEvent args) + private void OnDetached(EntityUid uid, LerpingEyeComponent component, PlayerDetachedEvent args) { if (!component.ManuallyAdded) RemCompDeferred(uid, component); diff --git a/Content.Client/Fullscreen/FullscreenHook.cs b/Content.Client/Fullscreen/FullscreenHook.cs index 7917fddfbb..78a0151736 100644 --- a/Content.Client/Fullscreen/FullscreenHook.cs +++ b/Content.Client/Fullscreen/FullscreenHook.cs @@ -4,7 +4,7 @@ using Robust.Client.Input; using Robust.Shared.Input.Binding; using Robust.Shared; using Robust.Shared.Configuration; -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Client.Fullscreen; public sealed class FullscreenHook diff --git a/Content.Client/Gameplay/GameplayStateBase.cs b/Content.Client/Gameplay/GameplayStateBase.cs index 454c063260..788a4e5dff 100644 --- a/Content.Client/Gameplay/GameplayStateBase.cs +++ b/Content.Client/Gameplay/GameplayStateBase.cs @@ -16,7 +16,7 @@ using Robust.Shared.Console; using Robust.Shared.Input; using Robust.Shared.Input.Binding; using Robust.Shared.Map; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Timing; namespace Content.Client.Gameplay diff --git a/Content.Client/Ghost/GhostSystem.cs b/Content.Client/Ghost/GhostSystem.cs index a89d0858d9..5727534109 100644 --- a/Content.Client/Ghost/GhostSystem.cs +++ b/Content.Client/Ghost/GhostSystem.cs @@ -58,10 +58,10 @@ namespace Content.Client.Ghost SubscribeLocalEvent(OnGhostRemove); SubscribeLocalEvent(OnGhostState); - SubscribeLocalEvent(OnGhostPlayerAttach); - SubscribeLocalEvent(OnGhostPlayerDetach); + SubscribeLocalEvent(OnGhostPlayerAttach); + SubscribeLocalEvent(OnGhostPlayerDetach); - SubscribeLocalEvent(OnPlayerAttach); + SubscribeLocalEvent(OnPlayerAttach); SubscribeNetworkEvent(OnGhostWarpsResponse); SubscribeNetworkEvent(OnUpdateGhostRoleCount); @@ -130,7 +130,7 @@ namespace Content.Client.Ghost PlayerRemoved?.Invoke(component); } - private void OnGhostPlayerAttach(EntityUid uid, GhostComponent component, LocalPlayerAttachedEvent localPlayerAttachedEvent) + private void OnGhostPlayerAttach(EntityUid uid, GhostComponent component, PlayerAttachedEvent playerAttachedEvent) { if (uid != _playerManager.LocalPlayer?.ControlledEntity) return; @@ -161,13 +161,13 @@ namespace Content.Client.Ghost return true; } - private void OnGhostPlayerDetach(EntityUid uid, GhostComponent component, LocalPlayerDetachedEvent args) + private void OnGhostPlayerDetach(EntityUid uid, GhostComponent component, PlayerDetachedEvent args) { if (PlayerDetach(uid)) component.IsAttached = false; } - private void OnPlayerAttach(LocalPlayerAttachedEvent ev) + private void OnPlayerAttach(PlayerAttachedEvent ev) { if (!HasComp(ev.Entity)) PlayerDetach(ev.Entity); diff --git a/Content.Client/Hands/Systems/HandsSystem.cs b/Content.Client/Hands/Systems/HandsSystem.cs index 31de7ec143..ed40589f7f 100644 --- a/Content.Client/Hands/Systems/HandsSystem.cs +++ b/Content.Client/Hands/Systems/HandsSystem.cs @@ -42,8 +42,8 @@ namespace Content.Client.Hands.Systems { base.Initialize(); - SubscribeLocalEvent(HandlePlayerAttached); - SubscribeLocalEvent(HandlePlayerDetached); + SubscribeLocalEvent(HandlePlayerAttached); + SubscribeLocalEvent(HandlePlayerDetached); SubscribeLocalEvent(OnHandsStartup); SubscribeLocalEvent(OnHandsShutdown); SubscribeLocalEvent(HandleComponentState); @@ -361,12 +361,12 @@ namespace Content.Client.Hands.Systems #region Gui - private void HandlePlayerAttached(EntityUid uid, HandsComponent component, LocalPlayerAttachedEvent args) + private void HandlePlayerAttached(EntityUid uid, HandsComponent component, PlayerAttachedEvent args) { OnPlayerHandsAdded?.Invoke(component); } - private void HandlePlayerDetached(EntityUid uid, HandsComponent component, LocalPlayerDetachedEvent args) + private void HandlePlayerDetached(EntityUid uid, HandsComponent component, PlayerDetachedEvent args) { OnPlayerHandsRemoved?.Invoke(); } diff --git a/Content.Client/HealthOverlay/HealthOverlaySystem.cs b/Content.Client/HealthOverlay/HealthOverlaySystem.cs index 29ac937199..baeb4fe025 100644 --- a/Content.Client/HealthOverlay/HealthOverlaySystem.cs +++ b/Content.Client/HealthOverlay/HealthOverlaySystem.cs @@ -3,8 +3,8 @@ using Content.Shared.Damage; using Content.Shared.GameTicking; using Content.Shared.Mobs.Components; using JetBrains.Annotations; +using Robust.Client.GameObjects; using Robust.Client.Graphics; -using Robust.Client.Player; namespace Content.Client.HealthOverlay { @@ -13,9 +13,9 @@ namespace Content.Client.HealthOverlay { [Dependency] private readonly IEyeManager _eyeManager = default!; [Dependency] private readonly IEntityManager _entities = default!; - [Dependency] private readonly IPlayerManager _player = default!; private readonly Dictionary _guis = new(); + private EntityUid? _attachedEntity; private bool _enabled; public bool Enabled @@ -42,6 +42,7 @@ namespace Content.Client.HealthOverlay base.Initialize(); SubscribeNetworkEvent(Reset); + SubscribeLocalEvent(HandlePlayerAttached); } public void Reset(RoundRestartCleanupEvent ev) @@ -52,6 +53,12 @@ namespace Content.Client.HealthOverlay } _guis.Clear(); + _attachedEntity = default; + } + + private void HandlePlayerAttached(PlayerAttachSysMessage message) + { + _attachedEntity = message.AttachedEntity; } public override void FrameUpdate(float frameTime) @@ -63,7 +70,7 @@ namespace Content.Client.HealthOverlay return; } - if (_player.LocalEntity is not {} ent || Deleted(ent)) + if (_attachedEntity is not {} ent || Deleted(ent)) { return; } diff --git a/Content.Client/Inventory/ClientInventorySystem.cs b/Content.Client/Inventory/ClientInventorySystem.cs index f0a12b3b1f..ffff392aa4 100644 --- a/Content.Client/Inventory/ClientInventorySystem.cs +++ b/Content.Client/Inventory/ClientInventorySystem.cs @@ -10,6 +10,7 @@ using Content.Shared.Inventory; using Content.Shared.Inventory.Events; using Content.Shared.Storage; using JetBrains.Annotations; +using Robust.Client.GameObjects; using Robust.Client.Player; using Robust.Client.UserInterface; using Robust.Shared.Containers; @@ -42,8 +43,8 @@ namespace Content.Client.Inventory UpdatesOutsidePrediction = true; base.Initialize(); - SubscribeLocalEvent(OnPlayerAttached); - SubscribeLocalEvent(OnPlayerDetached); + SubscribeLocalEvent(OnPlayerAttached); + SubscribeLocalEvent(OnPlayerDetached); SubscribeLocalEvent(OnShutdown); @@ -112,12 +113,12 @@ namespace Content.Client.Inventory OnUnlinkInventory?.Invoke(); } - private void OnPlayerDetached(EntityUid uid, InventorySlotsComponent component, LocalPlayerDetachedEvent args) + private void OnPlayerDetached(EntityUid uid, InventorySlotsComponent component, PlayerDetachedEvent args) { OnUnlinkInventory?.Invoke(); } - private void OnPlayerAttached(EntityUid uid, InventorySlotsComponent component, LocalPlayerAttachedEvent args) + private void OnPlayerAttached(EntityUid uid, InventorySlotsComponent component, PlayerAttachedEvent args) { if (TryGetSlots(uid, out var definitions)) { diff --git a/Content.Client/Mind/MindSystem.cs b/Content.Client/Mind/MindSystem.cs index cc43c349e4..87d9e9ddbe 100644 --- a/Content.Client/Mind/MindSystem.cs +++ b/Content.Client/Mind/MindSystem.cs @@ -4,24 +4,4 @@ namespace Content.Client.Mind; public sealed class MindSystem : SharedMindSystem { - public override void Initialize() - { - base.Initialize(); - SubscribeLocalEvent(OnHandleState); - } - - private void OnHandleState(EntityUid uid, MindComponent component, ref AfterAutoHandleStateEvent args) - { - // Because minds are generally not networked, there might be weird situations were a client thinks multiple - // users share a mind? E.g., if an admin periodical gets sent all minds via some PVS override, but doesn't get - // sent intermediate states? Not sure if this is actually possible, but better to be safe. - foreach (var (user, mind) in UserMinds) - { - if (mind == uid) - UserMinds.Remove(user); - } - - if (component.UserId != null) - UserMinds[component.UserId.Value] = uid; - } } diff --git a/Content.Client/Overlays/EquipmentHudSystem.cs b/Content.Client/Overlays/EquipmentHudSystem.cs index ac618691d8..1d5ec03291 100644 --- a/Content.Client/Overlays/EquipmentHudSystem.cs +++ b/Content.Client/Overlays/EquipmentHudSystem.cs @@ -1,6 +1,7 @@ using Content.Shared.GameTicking; using Content.Shared.Inventory; using Content.Shared.Inventory.Events; +using Robust.Client.GameObjects; using Robust.Client.Player; namespace Content.Client.Overlays; @@ -23,8 +24,8 @@ public abstract class EquipmentHudSystem : EntitySystem where T : IComponent SubscribeLocalEvent(OnStartup); SubscribeLocalEvent(OnRemove); - SubscribeLocalEvent(OnPlayerAttached); - SubscribeLocalEvent(OnPlayerDetached); + SubscribeLocalEvent(OnPlayerAttached); + SubscribeLocalEvent(OnPlayerDetached); SubscribeLocalEvent(OnCompEquip); SubscribeLocalEvent(OnCompUnequip); @@ -64,12 +65,12 @@ public abstract class EquipmentHudSystem : EntitySystem where T : IComponent RefreshOverlay(uid); } - private void OnPlayerAttached(LocalPlayerAttachedEvent args) + private void OnPlayerAttached(PlayerAttachedEvent args) { RefreshOverlay(args.Entity); } - private void OnPlayerDetached(LocalPlayerDetachedEvent args) + private void OnPlayerDetached(PlayerDetachedEvent args) { if (_player.LocalPlayer?.ControlledEntity == null) Deactivate(); diff --git a/Content.Client/Physics/Controllers/MoverController.cs b/Content.Client/Physics/Controllers/MoverController.cs index 52340b3391..54c5c3de15 100644 --- a/Content.Client/Physics/Controllers/MoverController.cs +++ b/Content.Client/Physics/Controllers/MoverController.cs @@ -1,6 +1,7 @@ using Content.Shared.Movement.Components; using Content.Shared.Movement.Systems; using Content.Shared.Pulling.Components; +using Robust.Client.GameObjects; using Robust.Client.Physics; using Robust.Client.Player; using Robust.Shared.Physics.Components; @@ -16,10 +17,10 @@ namespace Content.Client.Physics.Controllers public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnRelayPlayerAttached); - SubscribeLocalEvent(OnRelayPlayerDetached); - SubscribeLocalEvent(OnPlayerAttached); - SubscribeLocalEvent(OnPlayerDetached); + SubscribeLocalEvent(OnRelayPlayerAttached); + SubscribeLocalEvent(OnRelayPlayerDetached); + SubscribeLocalEvent(OnPlayerAttached); + SubscribeLocalEvent(OnPlayerDetached); SubscribeLocalEvent(OnUpdatePredicted); SubscribeLocalEvent(OnUpdateRelayTargetPredicted); @@ -53,7 +54,7 @@ namespace Content.Client.Physics.Controllers // What if the entity is being pulled by a vehicle controlled by the player? } - private void OnRelayPlayerAttached(EntityUid uid, RelayInputMoverComponent component, LocalPlayerAttachedEvent args) + private void OnRelayPlayerAttached(EntityUid uid, RelayInputMoverComponent component, PlayerAttachedEvent args) { Physics.UpdateIsPredicted(uid); Physics.UpdateIsPredicted(component.RelayEntity); @@ -61,7 +62,7 @@ namespace Content.Client.Physics.Controllers SetMoveInput(inputMover, MoveButtons.None); } - private void OnRelayPlayerDetached(EntityUid uid, RelayInputMoverComponent component, LocalPlayerDetachedEvent args) + private void OnRelayPlayerDetached(EntityUid uid, RelayInputMoverComponent component, PlayerDetachedEvent args) { Physics.UpdateIsPredicted(uid); Physics.UpdateIsPredicted(component.RelayEntity); @@ -69,12 +70,12 @@ namespace Content.Client.Physics.Controllers SetMoveInput(inputMover, MoveButtons.None); } - private void OnPlayerAttached(EntityUid uid, InputMoverComponent component, LocalPlayerAttachedEvent args) + private void OnPlayerAttached(EntityUid uid, InputMoverComponent component, PlayerAttachedEvent args) { SetMoveInput(component, MoveButtons.None); } - private void OnPlayerDetached(EntityUid uid, InputMoverComponent component, LocalPlayerDetachedEvent args) + private void OnPlayerDetached(EntityUid uid, InputMoverComponent component, PlayerDetachedEvent args) { SetMoveInput(component, MoveButtons.None); } diff --git a/Content.Client/Players/PlayerSystem.cs b/Content.Client/Players/PlayerSystem.cs index dba95ef7a6..d5ce4ec197 100644 --- a/Content.Client/Players/PlayerSystem.cs +++ b/Content.Client/Players/PlayerSystem.cs @@ -1,11 +1,11 @@ using Content.Shared.Players; -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Client.Players; public sealed class PlayerSystem : SharedPlayerSystem { - public override ContentPlayerData? ContentData(ICommonSession? session) + public override PlayerData? ContentData(ICommonSession? session) { return null; } diff --git a/Content.Client/Popups/PopupSystem.cs b/Content.Client/Popups/PopupSystem.cs index d68272a107..1d4ca19ce2 100644 --- a/Content.Client/Popups/PopupSystem.cs +++ b/Content.Client/Popups/PopupSystem.cs @@ -9,6 +9,7 @@ using Robust.Client.UserInterface; using Robust.Shared.Configuration; using Robust.Shared.Map; using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Prototypes; using Robust.Shared.Replays; using Robust.Shared.Timing; diff --git a/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Movement.cs b/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Movement.cs index d48a1eab46..3bb2afe122 100644 --- a/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Movement.cs +++ b/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Movement.cs @@ -2,7 +2,7 @@ using Content.Shared.Movement.Components; using Robust.Shared.Input; using Robust.Shared.Input.Binding; using Robust.Shared.Map; -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Client.Replay.Spectator; diff --git a/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Position.cs b/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Position.cs index 479e2eff97..45a175e688 100644 --- a/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Position.cs +++ b/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Position.cs @@ -1,5 +1,5 @@ using Content.Shared.Movement.Components; -using Robust.Client.Player; +using Robust.Client.GameObjects; using Robust.Shared.Map; using Robust.Shared.Map.Components; using Robust.Shared.Network; @@ -79,7 +79,7 @@ public sealed partial class ReplaySpectatorSystem public void SetSpectatorPosition(SpectatorData data) { - if (_player.LocalSession == null) + if (_player.LocalPlayer == null) return; if (data.Controller != null @@ -87,13 +87,13 @@ public sealed partial class ReplaySpectatorSystem && Exists(session.AttachedEntity) && Transform(session.AttachedEntity.Value).MapID != MapId.Nullspace) { - _player.SetAttachedEntity(_player.LocalSession, session.AttachedEntity); + _player.LocalPlayer.AttachEntity(session.AttachedEntity.Value, EntityManager, _client); return; } if (Exists(data.Entity) && Transform(data.Entity).MapID != MapId.Nullspace) { - _player.SetAttachedEntity(_player.LocalSession, data.Entity); + _player.LocalPlayer.AttachEntity(data.Entity, EntityManager, _client); return; } @@ -118,7 +118,7 @@ public sealed partial class ReplaySpectatorSystem return; } - if (data.Eye != null && TryComp(_player.LocalSession.AttachedEntity, out InputMoverComponent? newMover)) + if (data.Eye != null && TryComp(_player.LocalPlayer.ControlledEntity, out InputMoverComponent? newMover)) { newMover.RelativeEntity = data.Eye.Value.Ent; newMover.TargetRelativeRotation = newMover.RelativeRotation = data.Eye.Value.Rot; @@ -177,7 +177,7 @@ public sealed partial class ReplaySpectatorSystem SetSpectatorPosition(default); } - private void OnDetached(EntityUid uid, ReplaySpectatorComponent component, LocalPlayerDetachedEvent args) + private void OnDetached(EntityUid uid, ReplaySpectatorComponent component, PlayerDetachedEvent args) { if (IsClientSide(uid)) QueueDel(uid); diff --git a/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Spectate.cs b/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Spectate.cs index 80a8429055..f3475c5479 100644 --- a/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Spectate.cs +++ b/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Spectate.cs @@ -32,10 +32,10 @@ public sealed partial class ReplaySpectatorSystem public void SpectateEntity(EntityUid target) { - if (_player.LocalSession == null) + if (_player.LocalPlayer == null) return; - var old = _player.LocalSession.AttachedEntity; + var old = _player.LocalPlayer.ControlledEntity; if (old == target) { @@ -44,7 +44,7 @@ public sealed partial class ReplaySpectatorSystem return; } - _player.SetAttachedEntity(_player.LocalSession, target); + _player.LocalPlayer.AttachEntity(target, EntityManager, _client); EnsureComp(target); _stateMan.RequestStateChange(); @@ -59,10 +59,10 @@ public sealed partial class ReplaySpectatorSystem public TransformComponent SpawnSpectatorGhost(EntityCoordinates coords, bool gridAttach) { - if (_player.LocalSession == null) + if (_player.LocalPlayer == null) throw new InvalidOperationException(); - var old = _player.LocalSession.AttachedEntity; + var old = _player.LocalPlayer.ControlledEntity; var ent = Spawn("ReplayObserver", coords); _eye.SetMaxZoom(ent, Vector2.One * 5); @@ -73,7 +73,7 @@ public sealed partial class ReplaySpectatorSystem if (gridAttach) _transform.AttachToGridOrMap(ent); - _player.SetAttachedEntity(_player.LocalSession, ent); + _player.LocalPlayer.AttachEntity(ent, EntityManager, _client); if (old != null) { @@ -93,7 +93,7 @@ public sealed partial class ReplaySpectatorSystem { if (args.Length == 0) { - if (_player.LocalSession?.AttachedEntity is { } current) + if (_player.LocalPlayer?.ControlledEntity is { } current) SpawnSpectatorGhost(new EntityCoordinates(current, default), true); else SpawnSpectatorGhost(default, true); diff --git a/Content.Client/Replay/Spectator/ReplaySpectatorSystem.cs b/Content.Client/Replay/Spectator/ReplaySpectatorSystem.cs index 3b9662ed8c..c75529c037 100644 --- a/Content.Client/Replay/Spectator/ReplaySpectatorSystem.cs +++ b/Content.Client/Replay/Spectator/ReplaySpectatorSystem.cs @@ -6,6 +6,7 @@ using Robust.Client.Player; using Robust.Client.Replays.Playback; using Robust.Client.State; using Robust.Shared.Console; +using Robust.Shared.Network; using Robust.Shared.Serialization.Markdown.Mapping; namespace Content.Client.Replay.Spectator; @@ -39,7 +40,7 @@ public sealed partial class ReplaySpectatorSystem : EntitySystem SubscribeLocalEvent>(OnGetAlternativeVerbs); SubscribeLocalEvent(OnTerminating); - SubscribeLocalEvent(OnDetached); + SubscribeLocalEvent(OnDetached); SubscribeLocalEvent(OnParentChanged); InitializeBlockers(); diff --git a/Content.Client/Sandbox/SandboxSystem.cs b/Content.Client/Sandbox/SandboxSystem.cs index d16751e371..7dcbfa0ee0 100644 --- a/Content.Client/Sandbox/SandboxSystem.cs +++ b/Content.Client/Sandbox/SandboxSystem.cs @@ -5,7 +5,7 @@ using Robust.Client.Console; using Robust.Client.Placement; using Robust.Client.Placement.Modes; using Robust.Shared.Map; -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Client.Sandbox { diff --git a/Content.Client/Traits/ParacusiaSystem.cs b/Content.Client/Traits/ParacusiaSystem.cs index 87abec80bb..34c7d6859e 100644 --- a/Content.Client/Traits/ParacusiaSystem.cs +++ b/Content.Client/Traits/ParacusiaSystem.cs @@ -1,6 +1,8 @@ using System.Numerics; using Content.Shared.Traits.Assorted; +using Content.Client.Camera; using Robust.Shared.Random; +using Robust.Client.GameObjects; using Robust.Client.Player; using Robust.Shared.Timing; @@ -17,7 +19,7 @@ public sealed class ParacusiaSystem : SharedParacusiaSystem { base.Initialize(); SubscribeLocalEvent(OnComponentStartup); - SubscribeLocalEvent(OnPlayerDetach); + SubscribeLocalEvent(OnPlayerDetach); } public override void Update(float frameTime) @@ -38,7 +40,7 @@ public sealed class ParacusiaSystem : SharedParacusiaSystem component.NextIncidentTime = _timing.CurTime + TimeSpan.FromSeconds(_random.NextFloat(component.MinTimeBetweenIncidents, component.MaxTimeBetweenIncidents)); } - private void OnPlayerDetach(EntityUid uid, ParacusiaComponent component, LocalPlayerDetachedEvent args) + private void OnPlayerDetach(EntityUid uid, ParacusiaComponent component, PlayerDetachedEvent args) { component.Stream?.Stop(); } diff --git a/Content.Client/UserInterface/Systems/Character/CharacterUIController.cs b/Content.Client/UserInterface/Systems/Character/CharacterUIController.cs index 45bdada6e7..925b2dae4f 100644 --- a/Content.Client/UserInterface/Systems/Character/CharacterUIController.cs +++ b/Content.Client/UserInterface/Systems/Character/CharacterUIController.cs @@ -8,7 +8,6 @@ using Content.Client.UserInterface.Systems.Objectives.Controls; using Content.Shared.Input; using JetBrains.Annotations; using Robust.Client.GameObjects; -using Robust.Client.Player; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controllers; using Robust.Client.UserInterface.Controls; @@ -22,7 +21,6 @@ namespace Content.Client.UserInterface.Systems.Character; [UsedImplicitly] public sealed class CharacterUIController : UIController, IOnStateEntered, IOnStateExited, IOnSystemChanged { - [Dependency] private readonly IPlayerManager _player = default!; [UISystemDependency] private readonly CharacterInfoSystem _characterInfo = default!; [UISystemDependency] private readonly SpriteSystem _sprite = default!; @@ -58,13 +56,13 @@ public sealed class CharacterUIController : UIController, IOnStateEntered(OnChatMessage); _net.RegisterNetMessage(OnDeleteChatMessagesBy); @@ -171,7 +170,7 @@ public sealed class ChatUIController : UIController _speechBubbleRoot = new LayoutContainer(); - UpdateChannelPermissions(); + OnLocalPlayerChanged(new LocalPlayerChangedEventArgs(null, _player.LocalPlayer)); _input.SetInputCommand(ContentKeyFunctions.FocusChat, InputCmdHandler.FromDelegate(_ => FocusChat())); @@ -364,7 +363,29 @@ public sealed class ChatUIController : UIController _speechBubbleRoot.SetPositionLast(); } - private void OnAttachedChanged(EntityUid uid) + private void OnLocalPlayerChanged(LocalPlayerChangedEventArgs obj) + { + if (obj.OldPlayer != null) + { + obj.OldPlayer.EntityAttached -= OnLocalPlayerEntityAttached; + obj.OldPlayer.EntityDetached -= OnLocalPlayerEntityDetached; + } + + if (obj.NewPlayer != null) + { + obj.NewPlayer.EntityAttached += OnLocalPlayerEntityAttached; + obj.NewPlayer.EntityDetached += OnLocalPlayerEntityDetached; + } + + UpdateChannelPermissions(); + } + + private void OnLocalPlayerEntityAttached(EntityAttachedEventArgs obj) + { + UpdateChannelPermissions(); + } + + private void OnLocalPlayerEntityDetached(EntityDetachedEventArgs obj) { UpdateChannelPermissions(); } diff --git a/Content.Client/UserInterface/Systems/DamageOverlays/DamageOverlayUiController.cs b/Content.Client/UserInterface/Systems/DamageOverlays/DamageOverlayUiController.cs index ba4a871199..0836314dbc 100644 --- a/Content.Client/UserInterface/Systems/DamageOverlays/DamageOverlayUiController.cs +++ b/Content.Client/UserInterface/Systems/DamageOverlays/DamageOverlayUiController.cs @@ -1,9 +1,11 @@ +using Content.Client.Alerts; using Content.Shared.Damage; using Content.Shared.FixedPoint; using Content.Shared.Mobs; using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Systems; using JetBrains.Annotations; +using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Client.Player; using Robust.Client.UserInterface; @@ -23,13 +25,13 @@ public sealed class DamageOverlayUiController : UIController public override void Initialize() { _overlay = new Overlays.DamageOverlay(); - SubscribeLocalEvent(OnPlayerAttach); - SubscribeLocalEvent(OnPlayerDetached); + SubscribeLocalEvent(OnPlayerAttach); + SubscribeLocalEvent(OnPlayerDetached); SubscribeLocalEvent(OnMobStateChanged); SubscribeLocalEvent(OnThresholdCheck); } - private void OnPlayerAttach(LocalPlayerAttachedEvent args) + private void OnPlayerAttach(PlayerAttachedEvent args) { ClearOverlay(); if (!EntityManager.TryGetComponent(args.Entity, out var mobState)) @@ -39,7 +41,7 @@ public sealed class DamageOverlayUiController : UIController _overlayManager.AddOverlay(_overlay); } - private void OnPlayerDetached(LocalPlayerDetachedEvent args) + private void OnPlayerDetached(PlayerDetachedEvent args) { _overlayManager.RemoveOverlay(_overlay); ClearOverlay(); diff --git a/Content.Client/UserInterface/Systems/Sandbox/SandboxUIController.cs b/Content.Client/UserInterface/Systems/Sandbox/SandboxUIController.cs index 778de82210..d7ec9f3497 100644 --- a/Content.Client/UserInterface/Systems/Sandbox/SandboxUIController.cs +++ b/Content.Client/UserInterface/Systems/Sandbox/SandboxUIController.cs @@ -17,7 +17,7 @@ using Robust.Client.UserInterface.Controllers; using Robust.Client.UserInterface.Controllers.Implementations; using Robust.Shared.Input.Binding; using Robust.Shared.Map; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Utility; using static Robust.Client.UserInterface.Controls.BaseButton; diff --git a/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs b/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs index 2d2883d8b7..397032cd15 100644 --- a/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs +++ b/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs @@ -16,8 +16,7 @@ using Robust.Client.State; using Robust.Shared.Input; using Robust.Shared.Map; using Robust.Shared.Player; -using Robust.Shared.Prototypes; -using Robust.Shared.Timing; +using Robust.Shared.Players; namespace Content.Client.Weapons.Melee; diff --git a/Content.IntegrationTests/Pair/TestPair.cs b/Content.IntegrationTests/Pair/TestPair.cs index 2672b4db56..2971573ff2 100644 --- a/Content.IntegrationTests/Pair/TestPair.cs +++ b/Content.IntegrationTests/Pair/TestPair.cs @@ -3,11 +3,13 @@ using System.Collections.Generic; using System.IO; using System.Linq; using Content.Server.GameTicking; +using Content.Server.Players; +using Content.Shared.Mind; using Content.Shared.Players; +using Robust.Server.Player; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Network; -using Robust.Shared.Player; using Robust.Shared.Timing; using Robust.UnitTesting; @@ -28,8 +30,8 @@ public sealed partial class TestPair public RobustIntegrationTest.ServerIntegrationInstance Server { get; private set; } = default!; public RobustIntegrationTest.ClientIntegrationInstance Client { get; private set; } = default!; - public ICommonSession? Player => Server.PlayerMan.Sessions.FirstOrDefault(); - public ContentPlayerData? PlayerData => Player?.Data.ContentData(); + public IPlayerSession? Player => (IPlayerSession?) Server.PlayerMan.Sessions.FirstOrDefault(); + public PlayerData? PlayerData => Player?.Data.ContentData(); public PoolTestLogHandler ServerLogHandler { get; private set; } = default!; public PoolTestLogHandler ClientLogHandler { get; private set; } = default!; diff --git a/Content.IntegrationTests/Tests/Actions/ActionsAddedTest.cs b/Content.IntegrationTests/Tests/Actions/ActionsAddedTest.cs index 01daeea93c..01f8bdd938 100644 --- a/Content.IntegrationTests/Tests/Actions/ActionsAddedTest.cs +++ b/Content.IntegrationTests/Tests/Actions/ActionsAddedTest.cs @@ -3,6 +3,8 @@ using Content.Shared.Actions; using Content.Shared.CombatMode; using Robust.Server.Player; using Robust.Shared.GameObjects; +using Robust.Shared.Players; +using PlayerManager = Robust.Client.Player.PlayerManager; namespace Content.IntegrationTests.Tests.Actions; @@ -24,7 +26,7 @@ public sealed class ActionsAddedTest var sEntMan = server.ResolveDependency(); var cEntMan = client.ResolveDependency(); var clientSession = client.ResolveDependency().LocalPlayer?.Session; - var serverSession = server.ResolveDependency().Sessions.Single(); + var serverSession = server.ResolveDependency().ServerSessions.Single(); var sActionSystem = server.System(); var cActionSystem = client.System(); diff --git a/Content.IntegrationTests/Tests/Administration/Logs/AddTests.cs b/Content.IntegrationTests/Tests/Administration/Logs/AddTests.cs index 98c7363a6c..6562a26b5e 100644 --- a/Content.IntegrationTests/Tests/Administration/Logs/AddTests.cs +++ b/Content.IntegrationTests/Tests/Administration/Logs/AddTests.cs @@ -7,6 +7,8 @@ using Content.Shared.Administration.Logs; using Content.Shared.Database; using Robust.Server.Player; using Robust.Shared.GameObjects; +using Robust.Shared.Map; +using Robust.Shared.Utility; namespace Content.IntegrationTests.Tests.Administration.Logs; @@ -175,7 +177,7 @@ public sealed class AddTests await server.WaitPost(() => { - var player = sPlayers.Sessions.First(); + var player = sPlayers.ServerSessions.First(); playerGuid = player.UserId; Assert.DoesNotThrow(() => @@ -278,7 +280,7 @@ public sealed class AddTests await server.WaitPost(() => { - var player = sPlayers.Sessions.Single(); + var player = sPlayers.ServerSessions.Single(); sAdminLogSystem.Add(LogType.Unknown, $"{player} {player} test log: {guid}"); }); @@ -316,7 +318,7 @@ public sealed class AddTests await server.WaitPost(() => { - var player = sPlayers.Sessions.Single(); + var player = sPlayers.ServerSessions.Single(); sAdminLogSystem.Add(LogType.Unknown, $"{player:first} {player:second} test log: {guid}"); }); diff --git a/Content.IntegrationTests/Tests/Administration/Logs/QueryTests.cs b/Content.IntegrationTests/Tests/Administration/Logs/QueryTests.cs index 5a58757d53..1155edfad2 100644 --- a/Content.IntegrationTests/Tests/Administration/Logs/QueryTests.cs +++ b/Content.IntegrationTests/Tests/Administration/Logs/QueryTests.cs @@ -5,7 +5,6 @@ using Content.Server.GameTicking; using Content.Shared.Database; using Robust.Server.Player; using Robust.Shared.GameObjects; -using Robust.Shared.Player; namespace Content.IntegrationTests.Tests.Administration.Logs; @@ -28,11 +27,11 @@ public sealed class QueryTests var date = DateTime.UtcNow; var guid = Guid.NewGuid(); - ICommonSession player = default; + IPlayerSession player = default; await server.WaitPost(() => { - player = sPlayers.Sessions.First(); + player = sPlayers.ServerSessions.First(); sAdminLogSystem.Add(LogType.Unknown, $"{player.AttachedEntity:Entity} test log: {guid}"); }); diff --git a/Content.IntegrationTests/Tests/Cleanup/EuiManagerTest.cs b/Content.IntegrationTests/Tests/Cleanup/EuiManagerTest.cs index e2bff03501..9aac4e2892 100644 --- a/Content.IntegrationTests/Tests/Cleanup/EuiManagerTest.cs +++ b/Content.IntegrationTests/Tests/Cleanup/EuiManagerTest.cs @@ -25,7 +25,7 @@ public sealed class EuiManagerTest await server.WaitAssertion(() => { - var clientSession = sPlayerManager.Sessions.Single(); + var clientSession = sPlayerManager.ServerSessions.Single(); var ui = new AdminAnnounceEui(); eui.OpenEui(ui, clientSession); }); diff --git a/Content.IntegrationTests/Tests/Interaction/InteractionTest.cs b/Content.IntegrationTests/Tests/Interaction/InteractionTest.cs index df77410e54..b4b6c2239f 100644 --- a/Content.IntegrationTests/Tests/Interaction/InteractionTest.cs +++ b/Content.IntegrationTests/Tests/Interaction/InteractionTest.cs @@ -14,7 +14,6 @@ using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; using Content.Shared.Interaction; using Content.Shared.Mind; -using Content.Shared.Players; using Robust.Client.Input; using Robust.Client.UserInterface; using Robust.Server.GameObjects; @@ -22,7 +21,7 @@ using Robust.Server.Player; using Robust.Shared.GameObjects; using Robust.Shared.Log; using Robust.Shared.Map; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Prototypes; using Robust.Shared.Timing; using Robust.UnitTesting; @@ -68,7 +67,7 @@ public abstract partial class InteractionTest protected NetEntity Player; protected ICommonSession ClientSession = default!; - protected ICommonSession ServerSession = default!; + protected IPlayerSession ServerSession = default!; public EntityUid? ClientTarget; diff --git a/Content.IntegrationTests/Tests/Minds/GhostRoleTests.cs b/Content.IntegrationTests/Tests/Minds/GhostRoleTests.cs index 22a185798e..28e49645c9 100644 --- a/Content.IntegrationTests/Tests/Minds/GhostRoleTests.cs +++ b/Content.IntegrationTests/Tests/Minds/GhostRoleTests.cs @@ -5,7 +5,6 @@ using Content.Server.Ghost.Roles.Components; using Content.Server.Players; using Content.Shared.Ghost; using Content.Shared.Mind; -using Content.Shared.Players; using Robust.Shared.Console; using Robust.Shared.GameObjects; using Robust.Shared.Map; @@ -44,7 +43,7 @@ public sealed class GhostRoleTests var sPlayerMan = server.ResolveDependency(); var conHost = client.ResolveDependency(); var mindSystem = entMan.System(); - var session = sPlayerMan.Sessions.Single(); + var session = sPlayerMan.ServerSessions.Single(); var originalMindId = session.ContentData()!.Mind!.Value; // Spawn player entity & attach diff --git a/Content.IntegrationTests/Tests/Minds/MindTests.EntityDeletion.cs b/Content.IntegrationTests/Tests/Minds/MindTests.EntityDeletion.cs index a67a45ecb4..9fc68ef93d 100644 --- a/Content.IntegrationTests/Tests/Minds/MindTests.EntityDeletion.cs +++ b/Content.IntegrationTests/Tests/Minds/MindTests.EntityDeletion.cs @@ -2,7 +2,6 @@ using System.Linq; using Content.Server.Players; using Content.Shared.Ghost; using Content.Shared.Mind; -using Content.Shared.Players; using Robust.Server.Console; using Robust.Server.GameObjects; using Robust.Server.Player; @@ -36,7 +35,7 @@ public sealed partial class MindTests MindComponent mind = default!; await server.WaitAssertion(() => { - var player = playerMan.Sessions.Single(); + var player = playerMan.ServerSessions.Single(); playerEnt = entMan.SpawnEntity(null, MapCoordinates.Nullspace); visitEnt = entMan.SpawnEntity(null, MapCoordinates.Nullspace); @@ -82,7 +81,7 @@ public sealed partial class MindTests var entMan = server.ResolveDependency(); var mapManager = server.ResolveDependency(); var playerMan = server.ResolveDependency(); - var player = playerMan.Sessions.Single(); + var player = playerMan.ServerSessions.Single(); var mindSystem = entMan.EntitySysManager.GetEntitySystem(); @@ -129,7 +128,7 @@ public sealed partial class MindTests var entMan = server.ResolveDependency(); var playerMan = server.ResolveDependency(); - var player = playerMan.Sessions.Single(); + var player = playerMan.ServerSessions.Single(); Assert.That(!entMan.HasComponent(player.AttachedEntity), "Player was initially a ghost?"); @@ -163,7 +162,7 @@ public sealed partial class MindTests var mindSystem = entMan.EntitySysManager.GetEntitySystem(); var mind = GetMind(pair); - var player = playerMan.Sessions.Single(); + var player = playerMan.ServerSessions.Single(); #pragma warning disable NUnit2045 // Interdependent assertions. Assert.That(player.AttachedEntity, Is.Not.Null); Assert.That(entMan.EntityExists(player.AttachedEntity)); @@ -219,7 +218,7 @@ public sealed partial class MindTests var playerMan = server.ResolveDependency(); var serverConsole = server.ResolveDependency(); - var player = playerMan.Sessions.Single(); + var player = playerMan.ServerSessions.Single(); var ghost = await BecomeGhost(pair); @@ -264,7 +263,7 @@ public sealed partial class MindTests var playerMan = server.ResolveDependency(); var serverConsole = server.ResolveDependency(); - var player = playerMan.Sessions.Single(); + var player = playerMan.ServerSessions.Single(); EntityUid ghost = default!; diff --git a/Content.IntegrationTests/Tests/Minds/MindTests.Helpers.cs b/Content.IntegrationTests/Tests/Minds/MindTests.Helpers.cs index bbc011acac..f71a6ad5f9 100644 --- a/Content.IntegrationTests/Tests/Minds/MindTests.Helpers.cs +++ b/Content.IntegrationTests/Tests/Minds/MindTests.Helpers.cs @@ -3,14 +3,12 @@ using Content.IntegrationTests.Pair; using Content.Server.Players; using Content.Shared.Ghost; using Content.Shared.Mind; -using Content.Shared.Players; using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Enums; using Robust.Shared.GameObjects; using Robust.Shared.Map; using Robust.Shared.Network; -using Robust.Shared.Player; namespace Content.IntegrationTests.Tests.Minds; @@ -38,7 +36,7 @@ public sealed partial class MindTests var playerMan = pair.Server.ResolveDependency(); var mindSys = entMan.System(); - var player = playerMan.Sessions.Single(); + var player = playerMan.ServerSessions.Single(); EntityUid entity = default; EntityUid mindId = default!; @@ -73,7 +71,7 @@ public sealed partial class MindTests EntityUid mindId = default!; MindComponent mind = default!; - var player = playerMan.Sessions.Single(); + var player = playerMan.ServerSessions.Single(); await pair.Server.WaitAssertion(() => { var oldUid = player.AttachedEntity; @@ -120,7 +118,7 @@ public sealed partial class MindTests { var playerMan = pair.Server.ResolveDependency(); var entMan = pair.Server.ResolveDependency(); - var player = playerMan.Sessions.SingleOrDefault(); + var player = playerMan.ServerSessions.SingleOrDefault(); Assert.That(player, Is.Not.Null); var mindId = player.ContentData()!.Mind!.Value; @@ -141,7 +139,7 @@ public sealed partial class MindTests var netManager = pair.Client.ResolveDependency(); var playerMan = pair.Server.ResolveDependency(); var entMan = pair.Server.ResolveDependency(); - var player = playerMan.Sessions.Single(); + var player = playerMan.ServerSessions.Single(); var mindId = player.ContentData()!.Mind!.Value; var mind = entMan.GetComponent(mindId); @@ -163,21 +161,21 @@ public sealed partial class MindTests { var netManager = pair.Client.ResolveDependency(); var playerMan = pair.Server.ResolveDependency(); - Assert.That(!playerMan.Sessions.Any()); + Assert.That(!playerMan.ServerSessions.Any()); await Task.WhenAll(pair.Client.WaitIdleAsync(), pair.Client.WaitIdleAsync()); pair.Client.SetConnectTarget(pair.Server); await pair.Client.WaitPost(() => netManager.ClientConnect(null!, 0, username)); await pair.RunTicksSync(5); - var player = playerMan.Sessions.Single(); + var player = playerMan.ServerSessions.Single(); Assert.That(player.Status, Is.EqualTo(SessionStatus.InGame)); } - private static async Task DisconnectReconnect(Pair.TestPair pair) + private static async Task DisconnectReconnect(Pair.TestPair pair) { var playerMan = pair.Server.ResolveDependency(); - var player = playerMan.Sessions.Single(); + var player = playerMan.ServerSessions.Single(); var name = player.Name; var id = player.UserId; @@ -185,7 +183,7 @@ public sealed partial class MindTests await Connect(pair, name); // Session has changed - var newSession = playerMan.Sessions.Single(); + var newSession = playerMan.ServerSessions.Single(); Assert.Multiple(() => { Assert.That(newSession, Is.Not.EqualTo(player)); diff --git a/Content.IntegrationTests/Tests/Minds/MindTests.ReconnectTests.cs b/Content.IntegrationTests/Tests/Minds/MindTests.ReconnectTests.cs index 9939ebc545..ea2110c03a 100644 --- a/Content.IntegrationTests/Tests/Minds/MindTests.ReconnectTests.cs +++ b/Content.IntegrationTests/Tests/Minds/MindTests.ReconnectTests.cs @@ -49,7 +49,7 @@ public sealed partial class MindTests var mind = GetMind(pair); var playerMan = pair.Server.ResolveDependency(); - var player = playerMan.Sessions.Single(); + var player = playerMan.ServerSessions.Single(); var name = player.Name; var user = player.UserId; Assert.That(mind.Comp.OwnedEntity, Is.Not.Null); @@ -72,7 +72,7 @@ public sealed partial class MindTests // Reconnect await Connect(pair, name); - player = playerMan.Sessions.Single(); + player = playerMan.ServerSessions.Single(); Assert.Multiple(() => { Assert.That(user, Is.EqualTo(player.UserId)); @@ -127,10 +127,8 @@ public sealed partial class MindTests var mindSys = entMan.System(); var mind = GetMind(pair); - Assert.Null(mind.Comp.VisitingEntity); - // Make player visit a new mob - var original = mind.Comp.OwnedEntity; + var original = mind.Comp.CurrentEntity; EntityUid visiting = default; await pair.Server.WaitAssertion(() => { @@ -139,7 +137,6 @@ public sealed partial class MindTests }); await pair.RunTicksSync(5); - Assert.That(mind.Comp.VisitingEntity, Is.EqualTo(visiting)); await DisconnectReconnect(pair); // Player is back in control of the visited mob, mind was preserved diff --git a/Content.IntegrationTests/Tests/Minds/MindTests.cs b/Content.IntegrationTests/Tests/Minds/MindTests.cs index c9788b80a6..fb2fef43ed 100644 --- a/Content.IntegrationTests/Tests/Minds/MindTests.cs +++ b/Content.IntegrationTests/Tests/Minds/MindTests.cs @@ -11,7 +11,6 @@ using Content.Shared.Damage.Prototypes; using Content.Shared.FixedPoint; using Content.Shared.Mind; using Content.Shared.Mind.Components; -using Content.Shared.Players; using Content.Shared.Roles; using Content.Shared.Roles.Jobs; using Robust.Server.Console; @@ -68,12 +67,13 @@ public sealed partial class MindTests var entity = entMan.SpawnEntity(null, new MapCoordinates()); var mindComp = entMan.EnsureComponent(entity); - var mind = mindSystem.CreateMind(null); + var mindId = mindSystem.CreateMind(null); + var mind = entMan.GetComponent(mindId); - Assert.That(mind.Comp.UserId, Is.EqualTo(null)); + Assert.That(mind.UserId, Is.EqualTo(null)); - mindSystem.TransferTo(mind, entity, mind: mind); - Assert.That(mindSystem.GetMind(entity, mindComp), Is.EqualTo(mind.Owner)); + mindSystem.TransferTo(mindId, entity, mind: mind); + Assert.That(mindSystem.GetMind(entity, mindComp), Is.EqualTo(mindId)); }); await pair.CleanReturnAsync(); @@ -94,11 +94,11 @@ public sealed partial class MindTests var entity = entMan.SpawnEntity(null, new MapCoordinates()); var mindComp = entMan.EnsureComponent(entity); - var mindId = mindSystem.CreateMind(null).Owner; + var mindId = mindSystem.CreateMind(null); mindSystem.TransferTo(mindId, entity); Assert.That(mindSystem.GetMind(entity, mindComp), Is.EqualTo(mindId)); - var mind2 = mindSystem.CreateMind(null).Owner; + var mind2 = mindSystem.CreateMind(null); mindSystem.TransferTo(mind2, entity); Assert.Multiple(() => { @@ -184,7 +184,7 @@ public sealed partial class MindTests var mindComp = entMan.EnsureComponent(entity); entMan.EnsureComponent(targetEntity); - var mind = mindSystem.CreateMind(null).Owner; + var mind = mindSystem.CreateMind(null); mindSystem.TransferTo(mind, entity); @@ -276,7 +276,7 @@ public sealed partial class MindTests var entity = entMan.SpawnEntity(null, new MapCoordinates()); var mindComp = entMan.EnsureComponent(entity); - var mindId = mindSystem.CreateMind(null).Owner; + var mindId = mindSystem.CreateMind(null); var mind = entMan.EnsureComponent(mindId); Assert.That(mind.UserId, Is.EqualTo(null)); @@ -334,7 +334,7 @@ public sealed partial class MindTests public async Task TestPlayerCanGhost() { // Client is needed to spawn session - await using var pair = await PoolManager.GetServerClient(new PoolSettings { Connected = true, DummyTicker = false }); + await using var pair = await PoolManager.GetServerClient(new PoolSettings { Connected = true }); var server = pair.Server; var entMan = server.ResolveDependency(); @@ -346,7 +346,7 @@ public sealed partial class MindTests EntityUid entity = default!; EntityUid mindId = default!; MindComponent mind = default!; - var player = playerMan.Sessions.Single(); + var player = playerMan.ServerSessions.Single(); await server.WaitAssertion(() => { @@ -407,6 +407,12 @@ public sealed partial class MindTests await pair.CleanReturnAsync(); } + // TODO Implement + /*[Test] + public async Task TestPlayerCanReturnFromGhostWhenDead() + { + }*/ + [Test] public async Task TestGhostDoesNotInfiniteLoop() { @@ -427,7 +433,7 @@ public sealed partial class MindTests EntityUid ghost = default!; EntityUid mindId = default!; MindComponent mind = default!; - var player = playerMan.Sessions.Single(); + var player = playerMan.ServerSessions.Single(); await server.WaitAssertion(() => { diff --git a/Content.IntegrationTests/Tests/Toolshed/ToolshedTest.cs b/Content.IntegrationTests/Tests/Toolshed/ToolshedTest.cs index d6aec781a9..ca7eeac199 100644 --- a/Content.IntegrationTests/Tests/Toolshed/ToolshedTest.cs +++ b/Content.IntegrationTests/Tests/Toolshed/ToolshedTest.cs @@ -2,7 +2,8 @@ using System.Collections.Generic; using Content.IntegrationTests.Pair; using Content.Server.Administration.Managers; -using Robust.Shared.Player; +using Robust.Server.Player; +using Robust.Shared.Players; using Robust.Shared.Toolshed; using Robust.Shared.Toolshed.Errors; using Robust.Shared.Toolshed.Syntax; @@ -59,7 +60,7 @@ public abstract class ToolshedTest : IInvocationContext AdminManager = Server.ResolveDependency(); } - protected bool InvokeCommand(string command, out object? result, ICommonSession? session = null) + protected bool InvokeCommand(string command, out object? result, IPlayerSession? session = null) { return Toolshed.InvokeCommand(this, command, null, out result); } @@ -94,7 +95,7 @@ public abstract class ToolshedTest : IInvocationContext return true; } - protected ICommonSession? InvocationSession { get; set; } + protected IPlayerSession? InvocationSession { get; set; } public ICommonSession? Session { diff --git a/Content.MapRenderer/Painters/MapPainter.cs b/Content.MapRenderer/Painters/MapPainter.cs index 8f3dd59baf..b799db78a5 100644 --- a/Content.MapRenderer/Painters/MapPainter.cs +++ b/Content.MapRenderer/Painters/MapPainter.cs @@ -68,7 +68,7 @@ namespace Content.MapRenderer.Painters await server.WaitPost(() => { - var playerEntity = sPlayerManager.Sessions.Single().AttachedEntity; + var playerEntity = sPlayerManager.ServerSessions.Single().AttachedEntity; if (playerEntity.HasValue) { diff --git a/Content.Server/Administration/AdminPermsChangedEventArgs.cs b/Content.Server/Administration/AdminPermsChangedEventArgs.cs index 07eb416be6..24ca7aca68 100644 --- a/Content.Server/Administration/AdminPermsChangedEventArgs.cs +++ b/Content.Server/Administration/AdminPermsChangedEventArgs.cs @@ -1,5 +1,5 @@ using Content.Shared.Administration; -using Robust.Shared.Player; +using Robust.Server.Player; namespace Content.Server.Administration { @@ -8,7 +8,7 @@ namespace Content.Server.Administration /// public sealed class AdminPermsChangedEventArgs : EventArgs { - public AdminPermsChangedEventArgs(ICommonSession player, AdminFlags? flags) + public AdminPermsChangedEventArgs(IPlayerSession player, AdminFlags? flags) { Player = player; Flags = flags; @@ -17,7 +17,7 @@ namespace Content.Server.Administration /// /// The player that had their admin permissions changed. /// - public ICommonSession Player { get; } + public IPlayerSession Player { get; } /// /// The admin flags of the player. Null if the player is no longer an admin. diff --git a/Content.Server/Administration/Commands/AGhost.cs b/Content.Server/Administration/Commands/AGhost.cs index 2d1a15a0be..42a8600ff1 100644 --- a/Content.Server/Administration/Commands/AGhost.cs +++ b/Content.Server/Administration/Commands/AGhost.cs @@ -2,6 +2,7 @@ using Content.Shared.Administration; using Content.Shared.Ghost; using Content.Shared.Mind; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Administration.Commands @@ -17,7 +18,7 @@ namespace Content.Server.Administration.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player == null) { shell.WriteLine("Nah"); diff --git a/Content.Server/Administration/Commands/AdminWhoCommand.cs b/Content.Server/Administration/Commands/AdminWhoCommand.cs index 9765e8385f..8e6c402c4e 100644 --- a/Content.Server/Administration/Commands/AdminWhoCommand.cs +++ b/Content.Server/Administration/Commands/AdminWhoCommand.cs @@ -2,6 +2,7 @@ using Content.Server.Administration.Managers; using Content.Server.Afk; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Utility; @@ -34,7 +35,7 @@ public sealed class AdminWhoCommand : IConsoleCommand if (adminData.Title is { } title) sb.Append($": [{title}]"); - if (shell.Player is { } player && adminMgr.HasAdminFlag(player, AdminFlags.Admin)) + if (shell.Player is IPlayerSession player && adminMgr.HasAdminFlag(player, AdminFlags.Admin)) { if (afk.IsAfk(admin)) sb.Append(" [AFK]"); diff --git a/Content.Server/Administration/Commands/AnnounceUiCommand.cs b/Content.Server/Administration/Commands/AnnounceUiCommand.cs index d80db96686..c4cd7f13e4 100644 --- a/Content.Server/Administration/Commands/AnnounceUiCommand.cs +++ b/Content.Server/Administration/Commands/AnnounceUiCommand.cs @@ -1,6 +1,7 @@ using Content.Server.Administration.UI; using Content.Server.EUI; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Administration.Commands @@ -16,7 +17,7 @@ namespace Content.Server.Administration.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player == null) { shell.WriteLine("This does not work from the server console."); diff --git a/Content.Server/Administration/Commands/BanCommand.cs b/Content.Server/Administration/Commands/BanCommand.cs index 156fdf496a..58a801e410 100644 --- a/Content.Server/Administration/Commands/BanCommand.cs +++ b/Content.Server/Administration/Commands/BanCommand.cs @@ -1,8 +1,15 @@ using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Text; using Content.Server.Administration.Managers; +using Content.Server.Administration.Notes; +using Content.Server.Database; +using Content.Server.GameTicking; using Content.Shared.Administration; using Content.Shared.CCVar; using Content.Shared.Database; +using Content.Shared.Players.PlayTimeTracking; using Robust.Server.Player; using Robust.Shared.Configuration; using Robust.Shared.Console; @@ -77,7 +84,7 @@ public sealed class BanCommand : LocalizedCommands } var located = await _locator.LookupIdByNameOrIdAsync(target); - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (located == null) { @@ -95,7 +102,7 @@ public sealed class BanCommand : LocalizedCommands { if (args.Length == 1) { - var options = _playerManager.Sessions.Select(c => c.Name).OrderBy(c => c).ToArray(); + var options = _playerManager.ServerSessions.Select(c => c.Name).OrderBy(c => c).ToArray(); return CompletionResult.FromHintOptions(options, LocalizationManager.GetString("cmd-ban-hint")); } diff --git a/Content.Server/Administration/Commands/BanListCommand.cs b/Content.Server/Administration/Commands/BanListCommand.cs index a5bc97dce3..1c2be52394 100644 --- a/Content.Server/Administration/Commands/BanListCommand.cs +++ b/Content.Server/Administration/Commands/BanListCommand.cs @@ -36,7 +36,7 @@ public sealed class BanListCommand : LocalizedCommands return; } - if (shell.Player is not { } player) + if (shell.Player is not IPlayerSession player) { var bans = await _dbManager.GetServerBansAsync(data.LastAddress, data.UserId, data.LastHWId, false); @@ -67,7 +67,7 @@ public sealed class BanListCommand : LocalizedCommands return CompletionResult.Empty; var playerMgr = IoCManager.Resolve(); - var options = playerMgr.Sessions.Select(c => c.Name).OrderBy(c => c).ToArray(); + var options = playerMgr.ServerSessions.Select(c => c.Name).OrderBy(c => c).ToArray(); return CompletionResult.FromHintOptions(options, Loc.GetString("cmd-banlist-hint")); } } diff --git a/Content.Server/Administration/Commands/BanPanelCommand.cs b/Content.Server/Administration/Commands/BanPanelCommand.cs index 9f9ec9e89f..6036e5aa6e 100644 --- a/Content.Server/Administration/Commands/BanPanelCommand.cs +++ b/Content.Server/Administration/Commands/BanPanelCommand.cs @@ -1,6 +1,12 @@ using Content.Shared.Administration; using Robust.Shared.Console; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; using Content.Server.EUI; +using Robust.Server.Player; namespace Content.Server.Administration.Commands; @@ -15,7 +21,7 @@ public sealed class BanPanelCommand : LocalizedCommands public override async void Execute(IConsoleShell shell, string argStr, string[] args) { - if (shell.Player is not { } player) + if (shell.Player is not IPlayerSession player) { shell.WriteError(Loc.GetString("cmd-banpanel-server")); return; diff --git a/Content.Server/Administration/Commands/ControlMob.cs b/Content.Server/Administration/Commands/ControlMob.cs index 317461a373..2d205e44d3 100644 --- a/Content.Server/Administration/Commands/ControlMob.cs +++ b/Content.Server/Administration/Commands/ControlMob.cs @@ -1,5 +1,6 @@ -using Content.Server.Mind; using Content.Shared.Administration; +using Content.Shared.Mind; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Administration.Commands @@ -15,7 +16,7 @@ namespace Content.Server.Administration.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (shell.Player is not { } player) + if (shell.Player is not IPlayerSession player) { shell.WriteLine("shell-server-cannot"); return; @@ -41,7 +42,14 @@ namespace Content.Server.Administration.Commands return; } - _entities.System().ControlMob(player.UserId, target); + var mindSystem = _entities.System(); + if (!mindSystem.TryGetMind(target, out var mindId, out var mind)) + { + shell.WriteLine(Loc.GetString("shell-entity-is-not-mob")); + return; + } + + mindSystem.TransferTo(mindId, target, mind: mind); } } } diff --git a/Content.Server/Administration/Commands/DSay.cs b/Content.Server/Administration/Commands/DSay.cs index 61b47d7856..79b0e8db7d 100644 --- a/Content.Server/Administration/Commands/DSay.cs +++ b/Content.Server/Administration/Commands/DSay.cs @@ -1,5 +1,7 @@ +using Content.Server.Chat; using Content.Server.Chat.Systems; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Administration.Commands @@ -15,7 +17,7 @@ namespace Content.Server.Administration.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player == null) { shell.WriteLine("shell-only-players-can-run-this-command"); diff --git a/Content.Server/Administration/Commands/DeAdminCommand.cs b/Content.Server/Administration/Commands/DeAdminCommand.cs index cf65941200..c2bbfa7a33 100644 --- a/Content.Server/Administration/Commands/DeAdminCommand.cs +++ b/Content.Server/Administration/Commands/DeAdminCommand.cs @@ -1,8 +1,10 @@ using Content.Server.Administration.Managers; using Content.Shared.Administration; using JetBrains.Annotations; +using Robust.Server.Player; using Robust.Shared.Console; + namespace Content.Server.Administration.Commands { [UsedImplicitly] @@ -15,7 +17,7 @@ namespace Content.Server.Administration.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player == null) { shell.WriteLine("You cannot use this command from the server console."); diff --git a/Content.Server/Administration/Commands/ExplosionCommand.cs b/Content.Server/Administration/Commands/ExplosionCommand.cs index 56ed78b2e2..d48b69a5ad 100644 --- a/Content.Server/Administration/Commands/ExplosionCommand.cs +++ b/Content.Server/Administration/Commands/ExplosionCommand.cs @@ -3,6 +3,7 @@ using Content.Server.EUI; using Content.Server.Explosion.EntitySystems; using Content.Shared.Administration; using Content.Shared.Explosion; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Map; using Robust.Shared.Prototypes; @@ -20,7 +21,7 @@ public sealed class OpenExplosionEui : IConsoleCommand public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player == null) { shell.WriteError("This does not work from the server console."); diff --git a/Content.Server/Administration/Commands/FaxUiCommand.cs b/Content.Server/Administration/Commands/FaxUiCommand.cs index cf9e97e399..b06d36d08b 100644 --- a/Content.Server/Administration/Commands/FaxUiCommand.cs +++ b/Content.Server/Administration/Commands/FaxUiCommand.cs @@ -1,6 +1,7 @@ using Content.Server.EUI; using Content.Server.Fax.AdminUI; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Administration.Commands; @@ -15,7 +16,7 @@ public sealed class FaxUiCommand : IConsoleCommand public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player == null) { shell.WriteLine("shell-only-players-can-run-this-command"); diff --git a/Content.Server/Administration/Commands/OpenAdminLogsCommand.cs b/Content.Server/Administration/Commands/OpenAdminLogsCommand.cs index 47ff3e1a1c..9f28dc907c 100644 --- a/Content.Server/Administration/Commands/OpenAdminLogsCommand.cs +++ b/Content.Server/Administration/Commands/OpenAdminLogsCommand.cs @@ -1,6 +1,7 @@ using Content.Server.Administration.Logs; using Content.Server.EUI; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Administration.Commands; @@ -14,7 +15,7 @@ public sealed class OpenAdminLogsCommand : IConsoleCommand public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (shell.Player is not { } player) + if (shell.Player is not IPlayerSession player) { shell.WriteLine("This does not work from the server console."); return; diff --git a/Content.Server/Administration/Commands/OpenAdminNotesCommand.cs b/Content.Server/Administration/Commands/OpenAdminNotesCommand.cs index e6ae4f7616..147c0d6a82 100644 --- a/Content.Server/Administration/Commands/OpenAdminNotesCommand.cs +++ b/Content.Server/Administration/Commands/OpenAdminNotesCommand.cs @@ -1,5 +1,7 @@ using Content.Server.Administration.Notes; +using Content.Server.Database; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Administration.Commands; @@ -15,7 +17,7 @@ public sealed class OpenAdminNotesCommand : IConsoleCommand public async void Execute(IConsoleShell shell, string argStr, string[] args) { - if (shell.Player is not { } player) + if (shell.Player is not IPlayerSession player) { shell.WriteError("This does not work from the server console."); return; diff --git a/Content.Server/Administration/Commands/OpenPermissionsCommand.cs b/Content.Server/Administration/Commands/OpenPermissionsCommand.cs index fd3227d4aa..78d56cb4fb 100644 --- a/Content.Server/Administration/Commands/OpenPermissionsCommand.cs +++ b/Content.Server/Administration/Commands/OpenPermissionsCommand.cs @@ -1,8 +1,10 @@ using Content.Server.Administration.UI; using Content.Server.EUI; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; + namespace Content.Server.Administration.Commands { [AdminCommand(AdminFlags.Permissions)] @@ -14,7 +16,7 @@ namespace Content.Server.Administration.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player == null) { shell.WriteLine("This does not work from the server console."); diff --git a/Content.Server/Administration/Commands/OpenUserVisibleNotesCommand.cs b/Content.Server/Administration/Commands/OpenUserVisibleNotesCommand.cs index 507c7ab279..d61114fcae 100644 --- a/Content.Server/Administration/Commands/OpenUserVisibleNotesCommand.cs +++ b/Content.Server/Administration/Commands/OpenUserVisibleNotesCommand.cs @@ -1,6 +1,7 @@ using Content.Server.Administration.Notes; using Content.Shared.Administration; using Content.Shared.CCVar; +using Robust.Server.Player; using Robust.Shared.Configuration; using Robust.Shared.Console; @@ -26,7 +27,7 @@ public sealed class OpenUserVisibleNotesCommand : IConsoleCommand return; } - if (shell.Player is not { } player) + if (shell.Player is not IPlayerSession player) { shell.WriteError("This does not work from the server console."); return; diff --git a/Content.Server/Administration/Commands/PardonCommand.cs b/Content.Server/Administration/Commands/PardonCommand.cs index 9cbaaece31..869024eb7c 100644 --- a/Content.Server/Administration/Commands/PardonCommand.cs +++ b/Content.Server/Administration/Commands/PardonCommand.cs @@ -1,6 +1,7 @@ using System.Text; using Content.Server.Database; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Administration.Commands @@ -14,7 +15,7 @@ namespace Content.Server.Administration.Commands public async void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; var dbMan = IoCManager.Resolve(); if (args.Length != 1) diff --git a/Content.Server/Administration/Commands/PlayGlobalSoundCommand.cs b/Content.Server/Administration/Commands/PlayGlobalSoundCommand.cs index fdf067181d..ec5b21dcee 100644 --- a/Content.Server/Administration/Commands/PlayGlobalSoundCommand.cs +++ b/Content.Server/Administration/Commands/PlayGlobalSoundCommand.cs @@ -6,6 +6,7 @@ using Robust.Shared.Audio; using Robust.Shared.Console; using Robust.Shared.ContentPack; using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Prototypes; namespace Content.Server.Administration.Commands; diff --git a/Content.Server/Administration/Commands/ReAdminCommand.cs b/Content.Server/Administration/Commands/ReAdminCommand.cs index a3f5993766..12ff13221a 100644 --- a/Content.Server/Administration/Commands/ReAdminCommand.cs +++ b/Content.Server/Administration/Commands/ReAdminCommand.cs @@ -1,7 +1,9 @@ using Content.Server.Administration.Managers; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; + namespace Content.Server.Administration.Commands { [AnyCommand] @@ -13,7 +15,7 @@ namespace Content.Server.Administration.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player == null) { shell.WriteLine("You cannot use this command from the server console."); diff --git a/Content.Server/Administration/Commands/SetAdminOOC.cs b/Content.Server/Administration/Commands/SetAdminOOC.cs index 27528e1940..bb11b938d8 100644 --- a/Content.Server/Administration/Commands/SetAdminOOC.cs +++ b/Content.Server/Administration/Commands/SetAdminOOC.cs @@ -1,6 +1,8 @@ + using Content.Server.Database; using Content.Server.Preferences.Managers; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Administration.Commands @@ -14,7 +16,7 @@ namespace Content.Server.Administration.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (shell.Player == null) + if (!(shell.Player is IPlayerSession)) { shell.WriteError(Loc.GetString("shell-only-players-can-run-this-command")); return; diff --git a/Content.Server/Administration/Commands/SetMindCommand.cs b/Content.Server/Administration/Commands/SetMindCommand.cs index 5310c2dd7f..b9ff329ed2 100644 --- a/Content.Server/Administration/Commands/SetMindCommand.cs +++ b/Content.Server/Administration/Commands/SetMindCommand.cs @@ -2,7 +2,6 @@ using Content.Server.Players; using Content.Shared.Administration; using Content.Shared.Mind; using Content.Shared.Mind.Components; -using Content.Shared.Players; using Robust.Server.Player; using Robust.Shared.Console; diff --git a/Content.Server/Administration/Commands/SetOutfitCommand.cs b/Content.Server/Administration/Commands/SetOutfitCommand.cs index b2e7f4e6cc..28172ee6c5 100644 --- a/Content.Server/Administration/Commands/SetOutfitCommand.cs +++ b/Content.Server/Administration/Commands/SetOutfitCommand.cs @@ -10,6 +10,7 @@ using Content.Shared.PDA; using Content.Shared.Preferences; using Content.Shared.Roles; using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Prototypes; @@ -56,7 +57,7 @@ namespace Content.Server.Administration.Commands if (args.Length == 1) { - if (shell.Player is not { } player) + if (shell.Player is not IPlayerSession player) { shell.WriteError(Loc.GetString("set-outfit-command-is-not-player-error")); return; diff --git a/Content.Server/Administration/Commands/WarpCommand.cs b/Content.Server/Administration/Commands/WarpCommand.cs index 0d6da0d993..30a6d127aa 100644 --- a/Content.Server/Administration/Commands/WarpCommand.cs +++ b/Content.Server/Administration/Commands/WarpCommand.cs @@ -4,9 +4,11 @@ using Content.Server.Warps; using Content.Shared.Administration; using Content.Shared.Follower; using Content.Shared.Ghost; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Enums; using Robust.Shared.Map; +using Robust.Shared.Physics; using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Systems; @@ -26,7 +28,7 @@ namespace Content.Server.Administration.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player == null) { shell.WriteLine("Only players can use this command"); diff --git a/Content.Server/Administration/ContentNetworkResourceManager.cs b/Content.Server/Administration/ContentNetworkResourceManager.cs index dd95a2d897..0d3f3291e6 100644 --- a/Content.Server/Administration/ContentNetworkResourceManager.cs +++ b/Content.Server/Administration/ContentNetworkResourceManager.cs @@ -1,8 +1,8 @@ using Content.Server.Database; using Content.Shared.CCVar; +using Robust.Server.Player; using Robust.Server.Upload; using Robust.Shared.Configuration; -using Robust.Shared.Player; using Robust.Shared.Upload; namespace Content.Server.Administration; @@ -22,7 +22,7 @@ public sealed class ContentNetworkResourceManager _netRes.OnResourceUploaded += OnUploadResource; } - private async void OnUploadResource(ICommonSession session, NetworkResourceUploadMessage msg) + private async void OnUploadResource(IPlayerSession session, NetworkResourceUploadMessage msg) { if (StoreUploaded) await _serverDb.AddUploadedResourceLogAsync(session.UserId, DateTime.Now, msg.RelativePath.ToString(), msg.Data); diff --git a/Content.Server/Administration/Logs/AdminLogManager.Json.cs b/Content.Server/Administration/Logs/AdminLogManager.Json.cs index 0a67d61cef..63f30c7a66 100644 --- a/Content.Server/Administration/Logs/AdminLogManager.Json.cs +++ b/Content.Server/Administration/Logs/AdminLogManager.Json.cs @@ -3,8 +3,8 @@ using System.Text.Json; using System.Text.Json.Serialization; using Content.Server.Administration.Logs.Converters; using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Map; -using Robust.Shared.Player; namespace Content.Server.Administration.Logs; @@ -44,7 +44,7 @@ public sealed partial class AdminLogManager var value = properties[key]; value = value switch { - ICommonSession player => new SerializablePlayer(player), + IPlayerSession player => new SerializablePlayer(player), EntityCoordinates entityCoordinates => new SerializableEntityCoordinates(_entityManager, entityCoordinates), _ => value }; @@ -56,7 +56,7 @@ public sealed partial class AdminLogManager { EntityUid id => id, EntityStringRepresentation rep => rep.Uid, - ICommonSession {AttachedEntity: {Valid: true}} session => session.AttachedEntity, + IPlayerSession {AttachedEntity: {Valid: true}} session => session.AttachedEntity, IComponent component => component.Owner, _ => null }; diff --git a/Content.Server/Administration/Logs/Converters/PlayerSessionConverter.cs b/Content.Server/Administration/Logs/Converters/PlayerSessionConverter.cs index c1567448cc..0605c2db2a 100644 --- a/Content.Server/Administration/Logs/Converters/PlayerSessionConverter.cs +++ b/Content.Server/Administration/Logs/Converters/PlayerSessionConverter.cs @@ -1,5 +1,5 @@ using System.Text.Json; -using Robust.Shared.Player; +using Robust.Server.Player; namespace Content.Server.Administration.Logs.Converters; @@ -36,9 +36,9 @@ public sealed class PlayerSessionConverter : AdminLogConverter _admins = new(); + private readonly Dictionary _admins = new(); private readonly HashSet _promotedPlayers = new(); public event Action? OnPermsChanged; - public IEnumerable ActiveAdmins => _admins + public IEnumerable ActiveAdmins => _admins .Where(p => p.Value.Data.Active) .Select(p => p.Key); - public IEnumerable AllAdmins => _admins.Select(p => p.Key); + public IEnumerable AllAdmins => _admins.Select(p => p.Key); private readonly AdminCommandPermissions _commandPermissions = new(); private readonly AdminCommandPermissions _toolshedCommandPermissions = new(); @@ -56,7 +56,7 @@ namespace Content.Server.Administration.Managers public AdminData? GetAdminData(ICommonSession session, bool includeDeAdmin = false) { - if (_admins.TryGetValue(session, out var reg) && (reg.Data.Active || includeDeAdmin)) + if (_admins.TryGetValue((IPlayerSession)session, out var reg) && (reg.Data.Active || includeDeAdmin)) { return reg.Data; } @@ -66,13 +66,13 @@ namespace Content.Server.Administration.Managers public AdminData? GetAdminData(EntityUid uid, bool includeDeAdmin = false) { - if (_playerManager.TryGetSessionByEntity(uid, out var session)) - return GetAdminData(session, includeDeAdmin); + if (_playerManager.TryGetSessionByEntity(uid, out var session) && session is IPlayerSession playerSession) + return GetAdminData(playerSession, includeDeAdmin); return null; } - public void DeAdmin(ICommonSession session) + public void DeAdmin(IPlayerSession session) { if (!_admins.TryGetValue(session, out var reg)) { @@ -95,7 +95,7 @@ namespace Content.Server.Administration.Managers UpdateAdminStatus(session); } - public void ReAdmin(ICommonSession session) + public void ReAdmin(IPlayerSession session) { if (!_admins.TryGetValue(session, out var reg)) { @@ -119,7 +119,7 @@ namespace Content.Server.Administration.Managers UpdateAdminStatus(session); } - public async void ReloadAdmin(ICommonSession player) + public async void ReloadAdmin(IPlayerSession player) { var data = await LoadAdminData(player); var curAdmin = _admins.GetValueOrDefault(player); @@ -236,7 +236,7 @@ namespace Content.Server.Administration.Managers _toolshed.ActivePermissionController = this; } - public void PromoteHost(ICommonSession player) + public void PromoteHost(IPlayerSession player) { _promotedPlayers.Add(player.UserId); @@ -250,7 +250,7 @@ namespace Content.Server.Administration.Managers } // NOTE: Also sends commands list for non admins.. - private void UpdateAdminStatus(ICommonSession session) + private void UpdateAdminStatus(IPlayerSession session) { var msg = new MsgUpdateAdminStatus(); @@ -290,7 +290,7 @@ namespace Content.Server.Administration.Managers } } - private async void LoginAdminMaybe(ICommonSession session) + private async void LoginAdminMaybe(IPlayerSession session) { var adminDat = await LoadAdminData(session); if (adminDat == null) @@ -323,7 +323,7 @@ namespace Content.Server.Administration.Managers UpdateAdminStatus(session); } - private async Task<(AdminData dat, int? rankId, bool specialLogin)?> LoadAdminData(ICommonSession session) + private async Task<(AdminData dat, int? rankId, bool specialLogin)?> LoadAdminData(IPlayerSession session) { var promoteHost = IsLocal(session) && _cfg.GetCVar(CCVars.ConsoleLoginLocal) || _promotedPlayers.Contains(session.UserId) @@ -387,7 +387,7 @@ namespace Content.Server.Administration.Managers } } - private static bool IsLocal(ICommonSession player) + private static bool IsLocal(IPlayerSession player) { var ep = player.ConnectedClient.RemoteEndPoint; var addr = ep.Address; @@ -419,7 +419,7 @@ namespace Content.Server.Administration.Managers return false; } - public bool CanCommand(ICommonSession session, string cmdName) + public bool CanCommand(IPlayerSession session, string cmdName) { if (_commandPermissions.AnyCommands.Contains(cmdName)) { @@ -474,7 +474,7 @@ namespace Content.Server.Administration.Managers return true; } - var data = GetAdminData(user); + var data = GetAdminData((IPlayerSession)user); if (data == null) { // Player isn't an admin. @@ -520,32 +520,32 @@ namespace Content.Server.Administration.Managers return (attribs.Length != 0, attribs); } - public bool CanViewVar(ICommonSession session) + public bool CanViewVar(IPlayerSession session) { return CanCommand(session, "vv"); } - public bool CanAdminPlace(ICommonSession session) + public bool CanAdminPlace(IPlayerSession session) { return GetAdminData(session)?.CanAdminPlace() ?? false; } - public bool CanScript(ICommonSession session) + public bool CanScript(IPlayerSession session) { return GetAdminData(session)?.CanScript() ?? false; } - public bool CanAdminMenu(ICommonSession session) + public bool CanAdminMenu(IPlayerSession session) { return GetAdminData(session)?.CanAdminMenu() ?? false; } - public bool CanAdminReloadPrototypes(ICommonSession session) + public bool CanAdminReloadPrototypes(IPlayerSession session) { return GetAdminData(session)?.CanAdminReloadPrototypes() ?? false; } - private void SendPermsChangedEvent(ICommonSession session) + private void SendPermsChangedEvent(IPlayerSession session) { var flags = GetAdminData(session)?.Flags; OnPermsChanged?.Invoke(new AdminPermsChangedEventArgs(session, flags)); @@ -553,7 +553,7 @@ namespace Content.Server.Administration.Managers private sealed class AdminReg { - public readonly ICommonSession Session; + public readonly IPlayerSession Session; public AdminData Data; public int? RankId; @@ -561,7 +561,7 @@ namespace Content.Server.Administration.Managers // Such as console.loginlocal or promotehost public bool IsSpecialLogin; - public AdminReg(ICommonSession session, AdminData data) + public AdminReg(IPlayerSession session, AdminData data) { Data = data; Session = session; diff --git a/Content.Server/Administration/Managers/BanManager.cs b/Content.Server/Administration/Managers/BanManager.cs index 4d51d35576..765df17b17 100644 --- a/Content.Server/Administration/Managers/BanManager.cs +++ b/Content.Server/Administration/Managers/BanManager.cs @@ -15,7 +15,6 @@ using Robust.Server.Player; using Robust.Shared.Configuration; using Robust.Shared.Enums; using Robust.Shared.Network; -using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Utility; @@ -284,7 +283,7 @@ public sealed class BanManager : IBanManager, IPostInjectInit SendRoleBans(player); } - public void SendRoleBans(ICommonSession pSession) + public void SendRoleBans(IPlayerSession pSession) { var roleBans = _cachedRoleBans.GetValueOrDefault(pSession.UserId) ?? new HashSet(); var bans = new MsgRoleBans() diff --git a/Content.Server/Administration/Managers/IAdminManager.cs b/Content.Server/Administration/Managers/IAdminManager.cs index a52ec7b099..eeed5cc36e 100644 --- a/Content.Server/Administration/Managers/IAdminManager.cs +++ b/Content.Server/Administration/Managers/IAdminManager.cs @@ -1,8 +1,9 @@ using Content.Shared.Administration; using Content.Shared.Administration.Managers; -using Robust.Shared.Player; +using Robust.Server.Player; using Robust.Shared.Toolshed; + namespace Content.Server.Administration.Managers { /// @@ -21,12 +22,12 @@ namespace Content.Server.Administration.Managers /// /// This does not include admins that are de-adminned. /// - IEnumerable ActiveAdmins { get; } + IEnumerable ActiveAdmins { get; } /// /// Gets all admins currently on the server, even de-adminned ones. /// - IEnumerable AllAdmins { get; } + IEnumerable AllAdmins { get; } /// /// De-admins an admin temporarily so they are effectively a normal player. @@ -34,18 +35,18 @@ namespace Content.Server.Administration.Managers /// /// De-adminned admins are able to re-admin at any time if they so desire. /// - void DeAdmin(ICommonSession session); + void DeAdmin(IPlayerSession session); /// /// Re-admins a de-adminned admin. /// - void ReAdmin(ICommonSession session); + void ReAdmin(IPlayerSession session); /// /// Re-loads the permissions of an player in case their admin data changed DB-side. /// /// - void ReloadAdmin(ICommonSession player); + void ReloadAdmin(IPlayerSession player); /// /// Reloads admin permissions for all admins with a certain rank. @@ -56,7 +57,7 @@ namespace Content.Server.Administration.Managers void Initialize(); - void PromoteHost(ICommonSession player); + void PromoteHost(IPlayerSession player); bool TryGetCommandFlags(CommandSpec command, out AdminFlags[]? flags); } diff --git a/Content.Server/Administration/Managers/IBanManager.cs b/Content.Server/Administration/Managers/IBanManager.cs index dafe3d35bd..8458feac8d 100644 --- a/Content.Server/Administration/Managers/IBanManager.cs +++ b/Content.Server/Administration/Managers/IBanManager.cs @@ -2,8 +2,8 @@ using System.Collections.Immutable; using System.Net; using System.Threading.Tasks; using Content.Shared.Database; +using Robust.Server.Player; using Robust.Shared.Network; -using Robust.Shared.Player; namespace Content.Server.Administration.Managers; @@ -55,5 +55,5 @@ public interface IBanManager /// Sends role bans to the target /// /// Player's session - public void SendRoleBans(ICommonSession pSession); + public void SendRoleBans(IPlayerSession pSession); } diff --git a/Content.Server/Administration/Notes/AdminNotesManager.cs b/Content.Server/Administration/Notes/AdminNotesManager.cs index 0c1e7f3daa..8a7846663f 100644 --- a/Content.Server/Administration/Notes/AdminNotesManager.cs +++ b/Content.Server/Administration/Notes/AdminNotesManager.cs @@ -11,7 +11,7 @@ using Content.Shared.Database; using Content.Shared.Players.PlayTimeTracking; using Robust.Shared.Configuration; using Robust.Shared.Network; -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Server.Administration.Notes; diff --git a/Content.Server/Administration/Notes/AdminNotesSystem.cs b/Content.Server/Administration/Notes/AdminNotesSystem.cs index f2eb033dca..fd9f3f6bfa 100644 --- a/Content.Server/Administration/Notes/AdminNotesSystem.cs +++ b/Content.Server/Administration/Notes/AdminNotesSystem.cs @@ -1,13 +1,13 @@ using Content.Server.Administration.Commands; using Content.Server.Chat.Managers; using Content.Server.EUI; +using Content.Shared.Chat; using Content.Shared.Database; using Content.Shared.Verbs; using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Enums; -using Robust.Shared.Player; using Robust.Shared.Utility; namespace Content.Server.Administration.Notes; diff --git a/Content.Server/Administration/Notes/IAdminNotesManager.cs b/Content.Server/Administration/Notes/IAdminNotesManager.cs index a726bd11c8..ae7133c56d 100644 --- a/Content.Server/Administration/Notes/IAdminNotesManager.cs +++ b/Content.Server/Administration/Notes/IAdminNotesManager.cs @@ -2,7 +2,7 @@ using System.Threading.Tasks; using Content.Server.Database; using Content.Shared.Administration.Notes; using Content.Shared.Database; -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Server.Administration.Notes; diff --git a/Content.Server/Administration/QuickDialogSystem.OpenDialog.cs b/Content.Server/Administration/QuickDialogSystem.OpenDialog.cs index fb013a88ad..521bee776f 100644 --- a/Content.Server/Administration/QuickDialogSystem.OpenDialog.cs +++ b/Content.Server/Administration/QuickDialogSystem.OpenDialog.cs @@ -1,6 +1,6 @@ using Content.Shared.Administration; using JetBrains.Annotations; -using Robust.Shared.Player; +using Robust.Server.Player; namespace Content.Server.Administration; @@ -16,7 +16,7 @@ public sealed partial class QuickDialogSystem /// The action to execute upon the dialog being cancelled. /// Type of the input. [PublicAPI] - public void OpenDialog(ICommonSession session, string title, string prompt, Action okAction, + public void OpenDialog(IPlayerSession session, string title, string prompt, Action okAction, Action? cancelAction = null) { OpenDialogInternal( @@ -53,7 +53,7 @@ public sealed partial class QuickDialogSystem /// Type of the first input. /// Type of the second input. [PublicAPI] - public void OpenDialog(ICommonSession session, string title, string prompt1, string prompt2, + public void OpenDialog(IPlayerSession session, string title, string prompt1, string prompt2, Action okAction, Action? cancelAction = null) { OpenDialogInternal( @@ -96,7 +96,7 @@ public sealed partial class QuickDialogSystem /// Type of the second input. /// Type of the third input. [PublicAPI] - public void OpenDialog(ICommonSession session, string title, string prompt1, string prompt2, + public void OpenDialog(IPlayerSession session, string title, string prompt1, string prompt2, string prompt3, Action okAction, Action? cancelAction = null) { OpenDialogInternal( @@ -142,7 +142,7 @@ public sealed partial class QuickDialogSystem /// Type of the third input. /// Type of the fourth input. [PublicAPI] - public void OpenDialog(ICommonSession session, string title, string prompt1, string prompt2, + public void OpenDialog(IPlayerSession session, string title, string prompt1, string prompt2, string prompt3, string prompt4, Action okAction, Action? cancelAction = null) { OpenDialogInternal( diff --git a/Content.Server/Administration/QuickDialogSystem.cs b/Content.Server/Administration/QuickDialogSystem.cs index 96423e5223..51b8cf79c2 100644 --- a/Content.Server/Administration/QuickDialogSystem.cs +++ b/Content.Server/Administration/QuickDialogSystem.cs @@ -1,9 +1,12 @@ -using System.Diagnostics.CodeAnalysis; +using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; using Content.Shared.Administration; +using Microsoft.CodeAnalysis.CSharp.Syntax; using Robust.Server.Player; using Robust.Shared.Enums; using Robust.Shared.Network; using Robust.Shared.Player; +using Robust.Shared.Serialization.TypeSerializers.Interfaces; namespace Content.Server.Administration; @@ -84,7 +87,7 @@ public sealed partial class QuickDialogSystem : EntitySystem _openDialogsByUser.Remove(user); } - private void OpenDialogInternal(ICommonSession session, string title, List entries, QuickDialogButtonFlag buttons, Action okAction, Action cancelAction) + private void OpenDialogInternal(IPlayerSession session, string title, List entries, QuickDialogButtonFlag buttons, Action okAction, Action cancelAction) { var did = GetDialogId(); RaiseNetworkEvent( diff --git a/Content.Server/Administration/Systems/AdminSystem.cs b/Content.Server/Administration/Systems/AdminSystem.cs index feabaa2aad..66f7a8999b 100644 --- a/Content.Server/Administration/Systems/AdminSystem.cs +++ b/Content.Server/Administration/Systems/AdminSystem.cs @@ -109,7 +109,7 @@ namespace Content.Server.Administration.Systems } } - public void UpdatePlayerList(ICommonSession player) + public void UpdatePlayerList(IPlayerSession player) { _playerList[player.UserId] = GetPlayerInfo(player.Data, player); @@ -203,7 +203,7 @@ namespace Content.Server.Administration.Systems UpdatePanicBunker(); } - private void SendFullPlayerList(ICommonSession playerSession) + private void SendFullPlayerList(IPlayerSession playerSession) { var ev = new FullPlayerListEvent(); @@ -212,7 +212,7 @@ namespace Content.Server.Administration.Systems RaiseNetworkEvent(ev, playerSession.ConnectedClient); } - private PlayerInfo GetPlayerInfo(SessionData data, ICommonSession? session) + private PlayerInfo GetPlayerInfo(IPlayerData data, IPlayerSession? session) { var name = data.UserName; var entityName = string.Empty; @@ -326,7 +326,7 @@ namespace Content.Server.Administration.Systems /// chat messages and showing a popup to other players. /// Their items are dropped on the ground. /// - public void Erase(ICommonSession player) + public void Erase(IPlayerSession player) { var entity = player.AttachedEntity; _chat.DeleteMessagesBy(player); diff --git a/Content.Server/Administration/Systems/AdminTestArenaSystem.cs b/Content.Server/Administration/Systems/AdminTestArenaSystem.cs index e3671bcdfb..e65acf571c 100644 --- a/Content.Server/Administration/Systems/AdminTestArenaSystem.cs +++ b/Content.Server/Administration/Systems/AdminTestArenaSystem.cs @@ -1,8 +1,8 @@ using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Map; using Robust.Shared.Map.Components; using Robust.Shared.Network; -using Robust.Shared.Player; namespace Content.Server.Administration.Systems; @@ -20,7 +20,7 @@ public sealed class AdminTestArenaSystem : EntitySystem public Dictionary ArenaMap { get; private set; } = new(); public Dictionary ArenaGrid { get; private set; } = new(); - public (EntityUid Map, EntityUid? Grid) AssertArenaLoaded(ICommonSession admin) + public (EntityUid Map, EntityUid? Grid) AssertArenaLoaded(IPlayerSession admin) { if (ArenaMap.TryGetValue(admin.UserId, out var arenaMap) && !Deleted(arenaMap) && !Terminating(arenaMap)) { diff --git a/Content.Server/Administration/Systems/AdminVerbSystem.cs b/Content.Server/Administration/Systems/AdminVerbSystem.cs index bc065745f5..c7e23374a3 100644 --- a/Content.Server/Administration/Systems/AdminVerbSystem.cs +++ b/Content.Server/Administration/Systems/AdminVerbSystem.cs @@ -6,7 +6,6 @@ using Content.Server.Disposal.Tube; using Content.Server.Disposal.Tube.Components; using Content.Server.EUI; using Content.Server.Ghost.Roles; -using Content.Server.Mind; using Content.Server.Mind.Commands; using Content.Server.Prayer; using Content.Server.Xenoarchaeology.XenoArtifacts; @@ -19,15 +18,17 @@ using Content.Shared.Database; using Content.Shared.Examine; using Content.Shared.GameTicking; using Content.Shared.Inventory; +using Content.Shared.Mind; using Content.Shared.Mind.Components; using Content.Shared.Popups; using Content.Shared.Verbs; using Robust.Server.Console; using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Map; using Robust.Shared.Map.Components; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Prototypes; using Robust.Shared.Timing; using Robust.Shared.Toolshed; @@ -55,7 +56,7 @@ namespace Content.Server.Administration.Systems [Dependency] private readonly UserInterfaceSystem _uiSystem = default!; [Dependency] private readonly PrayerSystem _prayerSystem = default!; [Dependency] private readonly EuiManager _eui = default!; - [Dependency] private readonly MindSystem _mindSystem = default!; + [Dependency] private readonly SharedMindSystem _mindSystem = default!; [Dependency] private readonly ToolshedManager _toolshed = default!; [Dependency] private readonly RejuvenateSystem _rejuvenate = default!; [Dependency] private readonly SharedPopupSystem _popup = default!; @@ -276,7 +277,12 @@ namespace Content.Server.Administration.Systems // TODO VERB ICON control mob icon Act = () => { - _mindSystem.ControlMob(args.User, args.Target); + MakeSentientCommand.MakeSentient(args.Target, EntityManager); + + if (!_minds.TryGetMind(player, out var mindId, out var mind)) + return; + + _mindSystem.TransferTo(mindId, args.Target, ghostCheckOverride: true, mind: mind); }, Impact = LogImpact.High, ConfirmationPopup = true @@ -352,7 +358,7 @@ namespace Content.Server.Administration.Systems var message = ExamineSystemShared.InRangeUnOccluded(args.User, args.Target) ? Loc.GetString("in-range-unoccluded-verb-on-activate-not-occluded") : Loc.GetString("in-range-unoccluded-verb-on-activate-occluded"); - + _popup.PopupEntity(message, args.Target, args.User); } }; @@ -426,7 +432,7 @@ namespace Content.Server.Administration.Systems } } - public void OpenEditSolutionsEui(ICommonSession session, EntityUid uid) + public void OpenEditSolutionsEui(IPlayerSession session, EntityUid uid) { if (session.AttachedEntity == null) return; diff --git a/Content.Server/Administration/Systems/BwoinkSystem.cs b/Content.Server/Administration/Systems/BwoinkSystem.cs index 31ef285a88..98e5af1126 100644 --- a/Content.Server/Administration/Systems/BwoinkSystem.cs +++ b/Content.Server/Administration/Systems/BwoinkSystem.cs @@ -17,7 +17,6 @@ using Robust.Shared; using Robust.Shared.Configuration; using Robust.Shared.Enums; using Robust.Shared.Network; -using Robust.Shared.Player; using Robust.Shared.Timing; using Robust.Shared.Utility; @@ -120,7 +119,7 @@ namespace Content.Server.Administration.Systems _typingUpdateTimestamps[args.SenderSession.UserId] = (_timing.RealTime, msg.Typing); // Non-admins can only ever type on their own ahelp, guard against fake messages - var isAdmin = _adminManager.GetAdminData(args.SenderSession)?.HasFlag(AdminFlags.Adminhelp) ?? false; + var isAdmin = _adminManager.GetAdminData((IPlayerSession) args.SenderSession)?.HasFlag(AdminFlags.Adminhelp) ?? false; var channel = isAdmin ? msg.Channel : args.SenderSession.UserId; var update = new BwoinkPlayerTypingUpdated(channel, args.SenderSession.Name, msg.Typing); @@ -377,7 +376,7 @@ namespace Content.Server.Administration.Systems protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySessionEventArgs eventArgs) { base.OnBwoinkTextMessage(message, eventArgs); - var senderSession = eventArgs.SenderSession; + var senderSession = (IPlayerSession) eventArgs.SenderSession; // TODO: Sanitize text? // Confirm that this person is actually allowed to send a message here. diff --git a/Content.Server/Administration/Toolshed/AdminsCommand.cs b/Content.Server/Administration/Toolshed/AdminsCommand.cs index 1d64f748fd..aa82e0f1d9 100644 --- a/Content.Server/Administration/Toolshed/AdminsCommand.cs +++ b/Content.Server/Administration/Toolshed/AdminsCommand.cs @@ -1,6 +1,6 @@ using Content.Server.Administration.Managers; using Content.Shared.Administration; -using Robust.Shared.Player; +using Robust.Server.Player; using Robust.Shared.Toolshed; namespace Content.Server.Administration.Toolshed; @@ -11,13 +11,13 @@ public sealed class AdminsCommand : ToolshedCommand [Dependency] private readonly IAdminManager _admin = default!; [CommandImplementation("active")] - public IEnumerable Active() + public IEnumerable Active() { return _admin.ActiveAdmins; } [CommandImplementation("all")] - public IEnumerable All() + public IEnumerable All() { return _admin.AllAdmins; } diff --git a/Content.Server/Afk/AFKSystem.cs b/Content.Server/Afk/AFKSystem.cs index f634a415dc..0938f45f73 100644 --- a/Content.Server/Afk/AFKSystem.cs +++ b/Content.Server/Afk/AFKSystem.cs @@ -1,3 +1,4 @@ +using System.Linq; using Content.Server.Afk.Events; using Content.Server.GameTicking; using Content.Shared.CCVar; @@ -23,7 +24,7 @@ public sealed class AFKSystem : EntitySystem private float _checkDelay; private TimeSpan _checkTime; - private readonly HashSet _afkPlayers = new(); + private readonly HashSet _afkPlayers = new(); public override void Initialize() { @@ -72,9 +73,11 @@ public sealed class AFKSystem : EntitySystem _checkTime = _timing.CurTime + TimeSpan.FromSeconds(_checkDelay); - foreach (var pSession in Filter.GetAllPlayers()) + foreach (var session in Filter.GetAllPlayers()) { - if (pSession.Status != SessionStatus.InGame) continue; + if (session.Status != SessionStatus.InGame) continue; + + var pSession = (IPlayerSession) session; var isAfk = _afkManager.IsAfk(pSession); if (isAfk && _afkPlayers.Add(pSession)) diff --git a/Content.Server/Afk/AfkManager.cs b/Content.Server/Afk/AfkManager.cs index 52dc7715df..24cd1e28ce 100644 --- a/Content.Server/Afk/AfkManager.cs +++ b/Content.Server/Afk/AfkManager.cs @@ -5,7 +5,6 @@ using Robust.Shared.Configuration; using Robust.Shared.Console; using Robust.Shared.Enums; using Robust.Shared.Input; -using Robust.Shared.Player; using Robust.Shared.Timing; namespace Content.Server.Afk @@ -21,13 +20,13 @@ namespace Content.Server.Afk /// /// The player to check. /// True if the player is AFK, false otherwise. - bool IsAfk(ICommonSession player); + bool IsAfk(IPlayerSession player); /// /// Resets AFK status for the player as if they just did an action and are definitely not AFK. /// /// The player to set AFK status for. - void PlayerDidAction(ICommonSession player); + void PlayerDidAction(IPlayerSession player); void Initialize(); } @@ -41,7 +40,7 @@ namespace Content.Server.Afk [Dependency] private readonly IConfigurationManager _cfg = default!; [Dependency] private readonly IConsoleHost _consoleHost = default!; - private readonly Dictionary _lastActionTimes = new(); + private readonly Dictionary _lastActionTimes = new(); public void Initialize() { @@ -56,7 +55,7 @@ namespace Content.Server.Afk HandleInputCmd); } - public void PlayerDidAction(ICommonSession player) + public void PlayerDidAction(IPlayerSession player) { if (player.Status == SessionStatus.Disconnected) // Make sure we don't re-add to the dictionary if the player is disconnected now. @@ -65,7 +64,7 @@ namespace Content.Server.Afk _lastActionTimes[player] = _gameTiming.RealTime; } - public bool IsAfk(ICommonSession player) + public bool IsAfk(IPlayerSession player) { if (!_lastActionTimes.TryGetValue(player, out var time)) // Some weird edge case like disconnected clients. Just say true I guess. @@ -88,13 +87,13 @@ namespace Content.Server.Afk private void ConsoleHostOnAnyCommandExecuted(IConsoleShell shell, string commandname, string argstr, string[] args) { - if (shell.Player is { } player) + if (shell.Player is IPlayerSession player) PlayerDidAction(player); } private void HandleInputCmd(FullInputCmdMessage msg, EntitySessionEventArgs args) { - PlayerDidAction(args.SenderSession); + PlayerDidAction((IPlayerSession) args.SenderSession); } } } diff --git a/Content.Server/Afk/Events/AFKEvent.cs b/Content.Server/Afk/Events/AFKEvent.cs index ee9d548043..6adb950e47 100644 --- a/Content.Server/Afk/Events/AFKEvent.cs +++ b/Content.Server/Afk/Events/AFKEvent.cs @@ -1,4 +1,4 @@ -using Robust.Shared.Player; +using Robust.Server.Player; namespace Content.Server.Afk.Events; @@ -8,9 +8,9 @@ namespace Content.Server.Afk.Events; [ByRefEvent] public readonly struct AFKEvent { - public readonly ICommonSession Session; + public readonly IPlayerSession Session; - public AFKEvent(ICommonSession playerSession) + public AFKEvent(IPlayerSession playerSession) { Session = playerSession; } diff --git a/Content.Server/Afk/Events/UnAFKEvent.cs b/Content.Server/Afk/Events/UnAFKEvent.cs index 0983c256f0..3dd034583c 100644 --- a/Content.Server/Afk/Events/UnAFKEvent.cs +++ b/Content.Server/Afk/Events/UnAFKEvent.cs @@ -1,4 +1,4 @@ -using Robust.Shared.Player; +using Robust.Server.Player; namespace Content.Server.Afk.Events; @@ -8,9 +8,9 @@ namespace Content.Server.Afk.Events; [ByRefEvent] public readonly struct UnAFKEvent { - public readonly ICommonSession Session; + public readonly IPlayerSession Session; - public UnAFKEvent(ICommonSession playerSession) + public UnAFKEvent(IPlayerSession playerSession) { Session = playerSession; } diff --git a/Content.Server/Alert/Commands/ClearAlert.cs b/Content.Server/Alert/Commands/ClearAlert.cs index 1759612702..e43f06413c 100644 --- a/Content.Server/Alert/Commands/ClearAlert.cs +++ b/Content.Server/Alert/Commands/ClearAlert.cs @@ -2,6 +2,7 @@ using Content.Server.Administration; using Content.Server.Commands; using Content.Shared.Administration; using Content.Shared.Alert; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Alert.Commands @@ -15,7 +16,7 @@ namespace Content.Server.Alert.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player?.AttachedEntity == null) { shell.WriteLine("You don't have an entity."); diff --git a/Content.Server/Alert/Commands/ShowAlert.cs b/Content.Server/Alert/Commands/ShowAlert.cs index 11901e9af0..edb634b546 100644 --- a/Content.Server/Alert/Commands/ShowAlert.cs +++ b/Content.Server/Alert/Commands/ShowAlert.cs @@ -2,6 +2,7 @@ using Content.Server.Administration; using Content.Server.Commands; using Content.Shared.Administration; using Content.Shared.Alert; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Alert.Commands @@ -15,7 +16,7 @@ namespace Content.Server.Alert.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player?.AttachedEntity == null) { shell.WriteLine("You cannot run this from the server or without an attached entity."); diff --git a/Content.Server/AlertLevel/Commands/SetAlertLevelCommand.cs b/Content.Server/AlertLevel/Commands/SetAlertLevelCommand.cs index 2c432a2419..009a8b5f23 100644 --- a/Content.Server/AlertLevel/Commands/SetAlertLevelCommand.cs +++ b/Content.Server/AlertLevel/Commands/SetAlertLevelCommand.cs @@ -3,6 +3,7 @@ using Content.Server.Administration; using Content.Server.Station.Systems; using Content.Shared.Administration; using JetBrains.Annotations; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.AlertLevel.Commands @@ -18,7 +19,7 @@ namespace Content.Server.AlertLevel.Commands public CompletionResult GetCompletion(IConsoleShell shell, string[] args) { var levelNames = new string[] {}; - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player?.AttachedEntity != null) { var stationUid = EntitySystem.Get().GetOwningStation(player.AttachedEntity.Value); @@ -53,7 +54,7 @@ namespace Content.Server.AlertLevel.Commands return; } - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player?.AttachedEntity == null) { shell.WriteLine(Loc.GetString("shell-only-players-can-run-this-command")); diff --git a/Content.Server/Antag/AntagSelectionSystem.cs b/Content.Server/Antag/AntagSelectionSystem.cs index 737b723d39..5e323f5ab8 100644 --- a/Content.Server/Antag/AntagSelectionSystem.cs +++ b/Content.Server/Antag/AntagSelectionSystem.cs @@ -22,7 +22,6 @@ using Content.Server.Station.Systems; using Content.Server.Shuttles.Systems; using Content.Shared.Mobs; using Robust.Server.Containers; -using Robust.Shared.Player; using Robust.Shared.Prototypes; namespace Content.Server.Antag; @@ -89,9 +88,9 @@ public sealed class AntagSelectionSystem : GameRuleSystem out List chosen, bool includeHeads = false) { - var allPlayers = _playerSystem.Sessions.ToList(); - var playerList = new List(); - var prefList = new List(); + var allPlayers = _playerSystem.ServerSessions.ToList(); + var playerList = new List(); + var prefList = new List(); chosen = new List(); foreach (var player in allPlayers) { @@ -117,7 +116,7 @@ public sealed class AntagSelectionSystem : GameRuleSystem var antags = Math.Clamp(allPlayers.Count / antagsPerPlayer, 1, maxAntags); for (var antag = 0; antag < antags; antag++) { - ICommonSession? chosenPlayer = null; + IPlayerSession chosenPlayer = null!; if (prefList.Count == 0) { if (playerList.Count == 0) diff --git a/Content.Server/Arcade/BlockGame/BlockGame.Ui.cs b/Content.Server/Arcade/BlockGame/BlockGame.Ui.cs index ef69600783..92a96ea226 100644 --- a/Content.Server/Arcade/BlockGame/BlockGame.Ui.cs +++ b/Content.Server/Arcade/BlockGame/BlockGame.Ui.cs @@ -1,6 +1,6 @@ using Content.Shared.Arcade; +using Robust.Server.Player; using System.Linq; -using Robust.Shared.Player; namespace Content.Server.Arcade.BlockGame; @@ -166,7 +166,7 @@ public sealed partial class BlockGame /// /// The message to send to a specific player/spectator. /// The target recipient. - private void SendMessage(BoundUserInterfaceMessage message, ICommonSession session) + private void SendMessage(BoundUserInterfaceMessage message, IPlayerSession session) { if (_uiSystem.TryGetUi(_owner, BlockGameUiKey.Key, out var bui)) _uiSystem.TrySendUiMessage(bui, message, session); @@ -176,7 +176,7 @@ public sealed partial class BlockGame /// Handles sending the current state of the game to a player that has just opened the UI. /// /// The target recipient. - public void UpdateNewPlayerUI(ICommonSession session) + public void UpdateNewPlayerUI(IPlayerSession session) { if (_gameOver) { @@ -209,7 +209,7 @@ public sealed partial class BlockGame /// Handles broadcasting the full player-visible game state to a specific player/spectator. /// /// The target recipient. - private void FullUpdate(ICommonSession session) + private void FullUpdate(IPlayerSession session) { UpdateFieldUI(session); SendNextPieceUpdate(session); @@ -235,7 +235,7 @@ public sealed partial class BlockGame /// Handles broadcasting the current location of all of the blocks in the playfield + the active piece to a specific player/spectator. /// /// The target recipient. - public void UpdateFieldUI(ICommonSession session) + public void UpdateFieldUI(IPlayerSession session) { if (!Started) return; @@ -283,7 +283,7 @@ public sealed partial class BlockGame /// Broadcasts the state of the next queued piece to a specific viewer. /// /// The target recipient. - private void SendNextPieceUpdate(ICommonSession session) + private void SendNextPieceUpdate(IPlayerSession session) { SendMessage(new BlockGameMessages.BlockGameVisualUpdateMessage(NextPiece.BlocksForPreview(), BlockGameMessages.BlockGameVisualType.NextBlock), session); } @@ -303,7 +303,7 @@ public sealed partial class BlockGame /// Broadcasts the state of the currently held piece to a specific viewer. /// /// The target recipient. - private void SendHoldPieceUpdate(ICommonSession session) + private void SendHoldPieceUpdate(IPlayerSession session) { if (HeldPiece.HasValue) SendMessage(new BlockGameMessages.BlockGameVisualUpdateMessage(HeldPiece.Value.BlocksForPreview(), BlockGameMessages.BlockGameVisualType.HoldBlock), session); @@ -323,7 +323,7 @@ public sealed partial class BlockGame /// Broadcasts the current game level to a specific viewer. /// /// The target recipient. - private void SendLevelUpdate(ICommonSession session) + private void SendLevelUpdate(IPlayerSession session) { SendMessage(new BlockGameMessages.BlockGameLevelUpdateMessage(Level), session); } @@ -340,7 +340,7 @@ public sealed partial class BlockGame /// Broadcasts the current game score to a specific viewer. /// /// The target recipient. - private void SendPointsUpdate(ICommonSession session) + private void SendPointsUpdate(IPlayerSession session) { SendMessage(new BlockGameMessages.BlockGameScoreUpdateMessage(Points), session); } @@ -357,7 +357,7 @@ public sealed partial class BlockGame /// Broadcasts the current game high score positions to a specific viewer. /// /// The target recipient. - private void SendHighscoreUpdate(ICommonSession session) + private void SendHighscoreUpdate(IPlayerSession session) { SendMessage(new BlockGameMessages.BlockGameHighScoreUpdateMessage(_arcadeSystem.GetLocalHighscores(), _arcadeSystem.GetGlobalHighscores()), session); } diff --git a/Content.Server/Arcade/BlockGame/BlockGameArcadeComponent.cs b/Content.Server/Arcade/BlockGame/BlockGameArcadeComponent.cs index 5613d91544..268d5be4d2 100644 --- a/Content.Server/Arcade/BlockGame/BlockGameArcadeComponent.cs +++ b/Content.Server/Arcade/BlockGame/BlockGameArcadeComponent.cs @@ -1,4 +1,4 @@ -using Robust.Shared.Player; +using Robust.Server.Player; namespace Content.Server.Arcade.BlockGame; @@ -13,10 +13,10 @@ public sealed partial class BlockGameArcadeComponent : Component /// /// The player currently playing the active session of NT-BG. /// - public ICommonSession? Player = null; + public IPlayerSession? Player = null; /// /// The players currently viewing (but not playing) the active session of NT-BG. /// - public readonly List Spectators = new(); + public readonly List Spectators = new(); } diff --git a/Content.Server/Arcade/BlockGame/BlockGameArcadeSystem.cs b/Content.Server/Arcade/BlockGame/BlockGameArcadeSystem.cs index ecc5bfd3e2..dac29accc9 100644 --- a/Content.Server/Arcade/BlockGame/BlockGameArcadeSystem.cs +++ b/Content.Server/Arcade/BlockGame/BlockGameArcadeSystem.cs @@ -2,7 +2,7 @@ using Content.Server.Power.Components; using Content.Server.UserInterface; using Content.Shared.Arcade; using Robust.Server.GameObjects; -using Robust.Shared.Player; +using Robust.Server.Player; namespace Content.Server.Arcade.BlockGame; @@ -30,7 +30,7 @@ public sealed class BlockGameArcadeSystem : EntitySystem } } - private void UpdatePlayerStatus(EntityUid uid, ICommonSession session, PlayerBoundUserInterface? bui = null, BlockGameArcadeComponent? blockGame = null) + private void UpdatePlayerStatus(EntityUid uid, IPlayerSession session, PlayerBoundUserInterface? bui = null, BlockGameArcadeComponent? blockGame = null) { if (!Resolve(uid, ref blockGame)) return; @@ -67,7 +67,7 @@ public sealed class BlockGameArcadeSystem : EntitySystem private void OnAfterUiClose(EntityUid uid, BlockGameArcadeComponent component, BoundUIClosedEvent args) { - if (args.Session is not { } session) + if (args.Session is not IPlayerSession session) return; if (component.Player != session) diff --git a/Content.Server/Atmos/Commands/DeleteGasCommand.cs b/Content.Server/Atmos/Commands/DeleteGasCommand.cs index 9e7594c024..0f0c399b11 100644 --- a/Content.Server/Atmos/Commands/DeleteGasCommand.cs +++ b/Content.Server/Atmos/Commands/DeleteGasCommand.cs @@ -2,6 +2,7 @@ using Content.Server.Administration; using Content.Server.Atmos.EntitySystems; using Content.Shared.Administration; using Content.Shared.Atmos; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Map; @@ -19,7 +20,7 @@ namespace Content.Server.Atmos.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; EntityUid? gridId; Gas? gas = null; diff --git a/Content.Server/Atmos/Commands/ShowAtmosCommand.cs b/Content.Server/Atmos/Commands/ShowAtmosCommand.cs index 263ef947d0..5ad73ec906 100644 --- a/Content.Server/Atmos/Commands/ShowAtmosCommand.cs +++ b/Content.Server/Atmos/Commands/ShowAtmosCommand.cs @@ -1,6 +1,7 @@ using Content.Server.Administration; using Content.Server.Atmos.EntitySystems; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Atmos.Commands @@ -14,7 +15,7 @@ namespace Content.Server.Atmos.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player == null) { shell.WriteLine("You must be a player to use this command."); diff --git a/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs b/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs index 90edd4caed..34f558a252 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs @@ -10,7 +10,6 @@ using Robust.Shared.Configuration; using Robust.Shared.Enums; using Robust.Shared.Map; using Robust.Shared.Map.Components; -using Robust.Shared.Player; namespace Content.Server.Atmos.EntitySystems { @@ -28,7 +27,7 @@ namespace Content.Server.Atmos.EntitySystems /// To modify it see and /// . /// - private readonly HashSet _playerObservers = new(); + private readonly HashSet _playerObservers = new(); /// /// Overlay update ticks per second. @@ -49,17 +48,17 @@ namespace Content.Server.Atmos.EntitySystems _playerManager.PlayerStatusChanged -= OnPlayerStatusChanged; } - public bool AddObserver(ICommonSession observer) + public bool AddObserver(IPlayerSession observer) { return _playerObservers.Add(observer); } - public bool HasObserver(ICommonSession observer) + public bool HasObserver(IPlayerSession observer) { return _playerObservers.Contains(observer); } - public bool RemoveObserver(ICommonSession observer) + public bool RemoveObserver(IPlayerSession observer) { if (!_playerObservers.Remove(observer)) { @@ -77,7 +76,7 @@ namespace Content.Server.Atmos.EntitySystems /// /// The observer to toggle. /// true if added, false if removed. - public bool ToggleObserver(ICommonSession observer) + public bool ToggleObserver(IPlayerSession observer) { if (HasObserver(observer)) { diff --git a/Content.Server/Atmos/EntitySystems/GasTankSystem.cs b/Content.Server/Atmos/EntitySystems/GasTankSystem.cs index 17715435b2..df867d3516 100644 --- a/Content.Server/Atmos/EntitySystems/GasTankSystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasTankSystem.cs @@ -12,6 +12,7 @@ using Content.Shared.Toggleable; using Content.Shared.Verbs; using JetBrains.Annotations; using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.Physics.Systems; @@ -59,6 +60,12 @@ namespace Content.Server.Atmos.EntitySystems private void OnGasTankToggleInternals(Entity ent, ref GasTankToggleInternalsMessage args) { + if (args.Session is not IPlayerSession playerSession || + playerSession.AttachedEntity == null) + { + return; + } + ToggleInternals(ent); } diff --git a/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs b/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs index b0e8cf71c7..c229ef50c9 100644 --- a/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs @@ -16,7 +16,6 @@ using Robust.Shared; using Robust.Shared.Configuration; using Robust.Shared.Enums; using Robust.Shared.Map; -using Robust.Shared.Player; using Robust.Shared.Threading; using Robust.Shared.Timing; using Robust.Shared.Utility; @@ -36,7 +35,7 @@ namespace Content.Server.Atmos.EntitySystems [Robust.Shared.IoC.Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; [Robust.Shared.IoC.Dependency] private readonly ChunkingSystem _chunkingSys = default!; - private readonly Dictionary>> _lastSentChunks = new(); + private readonly Dictionary>> _lastSentChunks = new(); // Oh look its more duplicated decal system code! private ObjectPool> _chunkIndexPool = @@ -287,12 +286,12 @@ namespace Content.Server.Atmos.EntitySystems // Now we'll go through each player, then through each chunk in range of that player checking if the player is still in range // If they are, check if they need the new data to send (i.e. if there's an overlay for the gas). // Afterwards we reset all the chunk data for the next time we tick. - var players = _playerManager.Sessions.Where(x => x.Status == SessionStatus.InGame).ToArray(); + var players = _playerManager.ServerSessions.Where(x => x.Status == SessionStatus.InGame).ToArray(); var opts = new ParallelOptions { MaxDegreeOfParallelism = _parMan.ParallelProcessCount }; Parallel.ForEach(players, opts, p => UpdatePlayer(p, curTick)); } - private void UpdatePlayer(ICommonSession playerSession, GameTick curTick) + private void UpdatePlayer(IPlayerSession playerSession, GameTick curTick) { var chunksInRange = _chunkingSys.GetChunksForSession(playerSession, ChunkSize, _chunkIndexPool, _chunkViewerPool); var previouslySent = _lastSentChunks[playerSession]; diff --git a/Content.Server/Body/Commands/AddHandCommand.cs b/Content.Server/Body/Commands/AddHandCommand.cs index 655d0c88f9..308295c06c 100644 --- a/Content.Server/Body/Commands/AddHandCommand.cs +++ b/Content.Server/Body/Commands/AddHandCommand.cs @@ -4,6 +4,7 @@ using Content.Server.Body.Systems; using Content.Shared.Administration; using Content.Shared.Body.Components; using Content.Shared.Body.Part; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Prototypes; using Robust.Shared.Random; @@ -26,7 +27,7 @@ namespace Content.Server.Body.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; EntityUid entity; EntityUid hand; diff --git a/Content.Server/Body/Commands/AttachBodyPartCommand.cs b/Content.Server/Body/Commands/AttachBodyPartCommand.cs index 24604b88b7..267b520808 100644 --- a/Content.Server/Body/Commands/AttachBodyPartCommand.cs +++ b/Content.Server/Body/Commands/AttachBodyPartCommand.cs @@ -1,8 +1,10 @@ +using System.Linq; using Content.Server.Administration; using Content.Server.Body.Systems; using Content.Shared.Administration; using Content.Shared.Body.Components; using Content.Shared.Body.Part; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Body.Commands @@ -18,7 +20,7 @@ namespace Content.Server.Body.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; EntityUid bodyId; EntityUid? partUid; diff --git a/Content.Server/Body/Commands/DestroyMechanismCommand.cs b/Content.Server/Body/Commands/DestroyMechanismCommand.cs index 3aa28f4072..6ad0631150 100644 --- a/Content.Server/Body/Commands/DestroyMechanismCommand.cs +++ b/Content.Server/Body/Commands/DestroyMechanismCommand.cs @@ -2,6 +2,7 @@ using Content.Server.Administration; using Content.Server.Body.Systems; using Content.Shared.Administration; using Content.Shared.Body.Components; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Random; @@ -16,7 +17,7 @@ namespace Content.Server.Body.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player == null) { shell.WriteLine("Only a player can run this command."); diff --git a/Content.Server/Body/Commands/RemoveHandCommand.cs b/Content.Server/Body/Commands/RemoveHandCommand.cs index 4a2956ae7a..729db4bc44 100644 --- a/Content.Server/Body/Commands/RemoveHandCommand.cs +++ b/Content.Server/Body/Commands/RemoveHandCommand.cs @@ -4,6 +4,7 @@ using Content.Server.Body.Systems; using Content.Shared.Administration; using Content.Shared.Body.Components; using Content.Shared.Body.Part; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Random; @@ -21,7 +22,7 @@ namespace Content.Server.Body.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player == null) { shell.WriteLine("Only a player can run this command."); diff --git a/Content.Server/Body/Systems/BodySystem.cs b/Content.Server/Body/Systems/BodySystem.cs index 242b02d78c..f2f848c488 100644 --- a/Content.Server/Body/Systems/BodySystem.cs +++ b/Content.Server/Body/Systems/BodySystem.cs @@ -116,7 +116,7 @@ public sealed class BodySystem : SharedBodySystem if (!Resolve(bodyId, ref body, false)) return new HashSet(); - if (TerminatingOrDeleted(bodyId) || EntityManager.IsQueuedForDeletion(bodyId)) + if (LifeStage(bodyId) >= EntityLifeStage.Terminating || EntityManager.IsQueuedForDeletion(bodyId)) return new HashSet(); var xform = Transform(bodyId); diff --git a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs index f659357ad3..d9327b5150 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs @@ -8,7 +8,7 @@ using Content.Shared.Cargo.Events; using Content.Shared.Cargo.Prototypes; using Content.Shared.Database; using Robust.Shared.Map; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Prototypes; using Robust.Shared.Utility; diff --git a/Content.Server/CartridgeLoader/CartridgeLoaderSystem.cs b/Content.Server/CartridgeLoader/CartridgeLoaderSystem.cs index 02b2eee771..9f7acce4fd 100644 --- a/Content.Server/CartridgeLoader/CartridgeLoaderSystem.cs +++ b/Content.Server/CartridgeLoader/CartridgeLoaderSystem.cs @@ -6,9 +6,9 @@ using Content.Shared.CartridgeLoader; using Content.Shared.Interaction; using Robust.Server.Containers; using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Containers; using Robust.Shared.Map; -using Robust.Shared.Player; namespace Content.Server.CartridgeLoader; @@ -98,7 +98,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem /// and use this method to update its state so the cartridge loaders state can be added to it. /// /// - public void UpdateUiState(EntityUid loaderUid, ICommonSession? session, CartridgeLoaderComponent? loader) + public void UpdateUiState(EntityUid loaderUid, IPlayerSession? session, CartridgeLoaderComponent? loader) { if (!Resolve(loaderUid, ref loader)) return; @@ -122,7 +122,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem /// This method is called "UpdateCartridgeUiState" but cartridges and a programs are the same. A cartridge is just a program as a visible item. /// /// - public void UpdateCartridgeUiState(EntityUid loaderUid, BoundUserInterfaceState state, ICommonSession? session = default!, CartridgeLoaderComponent? loader = default!) + public void UpdateCartridgeUiState(EntityUid loaderUid, BoundUserInterfaceState state, IPlayerSession? session = default!, CartridgeLoaderComponent? loader = default!) { if (!Resolve(loaderUid, ref loader)) return; diff --git a/Content.Server/Chat/Commands/AdminChatCommand.cs b/Content.Server/Chat/Commands/AdminChatCommand.cs index 979051e9d3..8aa95ffee1 100644 --- a/Content.Server/Chat/Commands/AdminChatCommand.cs +++ b/Content.Server/Chat/Commands/AdminChatCommand.cs @@ -1,6 +1,7 @@ using Content.Server.Administration; using Content.Server.Chat.Managers; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Chat.Commands @@ -14,7 +15,7 @@ namespace Content.Server.Chat.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = (IPlayerSession?) shell.Player; if (player == null) { diff --git a/Content.Server/Chat/Commands/LOOCCommand.cs b/Content.Server/Chat/Commands/LOOCCommand.cs index 9e16193fc3..a897a0b2bf 100644 --- a/Content.Server/Chat/Commands/LOOCCommand.cs +++ b/Content.Server/Chat/Commands/LOOCCommand.cs @@ -1,5 +1,6 @@ using Content.Server.Chat.Systems; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Enums; @@ -14,7 +15,7 @@ namespace Content.Server.Chat.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (shell.Player is not { } player) + if (shell.Player is not IPlayerSession player) { shell.WriteError("This command cannot be run from the server."); return; diff --git a/Content.Server/Chat/Commands/MeCommand.cs b/Content.Server/Chat/Commands/MeCommand.cs index e763d5656e..36f86cf4d6 100644 --- a/Content.Server/Chat/Commands/MeCommand.cs +++ b/Content.Server/Chat/Commands/MeCommand.cs @@ -1,5 +1,6 @@ using Content.Server.Chat.Systems; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Enums; @@ -14,7 +15,7 @@ namespace Content.Server.Chat.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (shell.Player is not { } player) + if (shell.Player is not IPlayerSession player) { shell.WriteError("This command cannot be run from the server."); return; diff --git a/Content.Server/Chat/Commands/OOCCommand.cs b/Content.Server/Chat/Commands/OOCCommand.cs index 36f6303fbd..bef2024608 100644 --- a/Content.Server/Chat/Commands/OOCCommand.cs +++ b/Content.Server/Chat/Commands/OOCCommand.cs @@ -1,5 +1,6 @@ using Content.Server.Chat.Managers; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Chat.Commands @@ -13,7 +14,7 @@ namespace Content.Server.Chat.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (shell.Player is not { } player) + if (shell.Player is not IPlayerSession player) { shell.WriteError("This command cannot be run from the server."); return; diff --git a/Content.Server/Chat/Commands/SayCommand.cs b/Content.Server/Chat/Commands/SayCommand.cs index 273f908c9a..7c2125d8c1 100644 --- a/Content.Server/Chat/Commands/SayCommand.cs +++ b/Content.Server/Chat/Commands/SayCommand.cs @@ -1,5 +1,6 @@ using Content.Server.Chat.Systems; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Enums; @@ -14,7 +15,7 @@ namespace Content.Server.Chat.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (shell.Player is not { } player) + if (shell.Player is not IPlayerSession player) { shell.WriteError("This command cannot be run from the server."); return; diff --git a/Content.Server/Chat/Commands/SuicideCommand.cs b/Content.Server/Chat/Commands/SuicideCommand.cs index c967ba78d7..389ff039bf 100644 --- a/Content.Server/Chat/Commands/SuicideCommand.cs +++ b/Content.Server/Chat/Commands/SuicideCommand.cs @@ -1,6 +1,7 @@ using Content.Server.GameTicking; using Content.Shared.Administration; using Content.Shared.Mind; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Enums; @@ -17,7 +18,7 @@ namespace Content.Server.Chat.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (shell.Player is not { } player) + if (shell.Player is not IPlayerSession player) { shell.WriteLine(Loc.GetString("shell-cannot-run-command-from-server")); return; diff --git a/Content.Server/Chat/Commands/WhisperCommand.cs b/Content.Server/Chat/Commands/WhisperCommand.cs index c88e2519ee..41eba8b384 100644 --- a/Content.Server/Chat/Commands/WhisperCommand.cs +++ b/Content.Server/Chat/Commands/WhisperCommand.cs @@ -1,5 +1,6 @@ using Content.Server.Chat.Systems; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Enums; @@ -14,7 +15,7 @@ namespace Content.Server.Chat.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (shell.Player is not { } player) + if (shell.Player is not IPlayerSession player) { shell.WriteError("This command cannot be run from the server."); return; diff --git a/Content.Server/Chat/Managers/ChatManager.cs b/Content.Server/Chat/Managers/ChatManager.cs index 59a9d305bd..88e143d24e 100644 --- a/Content.Server/Chat/Managers/ChatManager.cs +++ b/Content.Server/Chat/Managers/ChatManager.cs @@ -10,9 +10,11 @@ using Content.Shared.CCVar; using Content.Shared.Chat; using Content.Shared.Database; using Content.Shared.Mind; +using Robust.Server.Player; using Robust.Shared.Configuration; using Robust.Shared.Network; using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Replays; using Robust.Shared.Utility; @@ -49,8 +51,8 @@ namespace Content.Server.Chat.Managers private bool _oocEnabled = true; private bool _adminOocEnabled = true; - public Dictionary SenderKeys { get; } = new(); - public Dictionary> SenderEntities { get; } = new(); + public Dictionary SenderKeys { get; } = new(); + public Dictionary> SenderEntities { get; } = new(); public void Initialize() { @@ -77,7 +79,7 @@ namespace Content.Server.Chat.Managers DispatchServerAnnouncement(Loc.GetString(val ? "chat-manager-admin-ooc-chat-enabled-message" : "chat-manager-admin-ooc-chat-disabled-message")); } - public void DeleteMessagesBy(ICommonSession player) + public void DeleteMessagesBy(IPlayerSession player) { var key = SenderKeys.GetValueOrDefault(player); var entities = SenderEntities.GetValueOrDefault(player) ?? new HashSet(); @@ -163,7 +165,7 @@ namespace Content.Server.Chat.Managers /// The player sending the message. /// The message. /// The type of message. - public void TrySendOOCMessage(ICommonSession player, string message, OOCChatType type) + public void TrySendOOCMessage(IPlayerSession player, string message, OOCChatType type) { // Check if message exceeds the character limit if (message.Length > MaxMessageLength) @@ -187,7 +189,7 @@ namespace Content.Server.Chat.Managers #region Private API - private void SendOOC(ICommonSession player, string message) + private void SendOOC(IPlayerSession player, string message) { if (_adminManager.IsAdmin(player)) { @@ -224,7 +226,7 @@ namespace Content.Server.Chat.Managers _adminLogger.Add(LogType.Chat, LogImpact.Low, $"OOC from {player:Player}: {message}"); } - private void SendAdminChat(ICommonSession player, string message) + private void SendAdminChat(IPlayerSession player, string message) { if (!_adminManager.IsAdmin(player)) { @@ -324,7 +326,7 @@ namespace Content.Server.Chat.Managers } } - public bool MessageCharacterLimit(ICommonSession? player, string message) + public bool MessageCharacterLimit(IPlayerSession? player, string message) { var isOverLength = false; diff --git a/Content.Server/Chat/Managers/IChatManager.cs b/Content.Server/Chat/Managers/IChatManager.cs index 5317b3054e..10103f011d 100644 --- a/Content.Server/Chat/Managers/IChatManager.cs +++ b/Content.Server/Chat/Managers/IChatManager.cs @@ -1,6 +1,8 @@ using Content.Shared.Chat; +using Robust.Server.Player; using Robust.Shared.Network; using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Server.Chat.Managers { @@ -10,12 +12,12 @@ namespace Content.Server.Chat.Managers /// Keys identifying messages sent by a specific player, used when sending /// /// - Dictionary SenderKeys { get; } + Dictionary SenderKeys { get; } /// /// Tracks which entities a player was attached to while sending messages. /// - Dictionary> SenderEntities { get; } + Dictionary> SenderEntities { get; } void Initialize(); @@ -28,7 +30,7 @@ namespace Content.Server.Chat.Managers void DispatchServerMessage(ICommonSession player, string message, bool suppressLog = false); - void TrySendOOCMessage(ICommonSession player, string message, OOCChatType type); + void TrySendOOCMessage(IPlayerSession player, string message, OOCChatType type); void SendHookOOC(string sender, string message); void SendAdminAnnouncement(string message); @@ -45,8 +47,8 @@ namespace Content.Server.Chat.Managers void ChatMessageToAll(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0, int? senderKey = null); - bool MessageCharacterLimit(ICommonSession player, string message); + bool MessageCharacterLimit(IPlayerSession player, string message); - void DeleteMessagesBy(ICommonSession player); + void DeleteMessagesBy(IPlayerSession player); } } diff --git a/Content.Server/Chat/Systems/ChatSystem.cs b/Content.Server/Chat/Systems/ChatSystem.cs index 3315f61c2f..455d34c907 100644 --- a/Content.Server/Chat/Systems/ChatSystem.cs +++ b/Content.Server/Chat/Systems/ChatSystem.cs @@ -7,6 +7,7 @@ using Content.Server.Administration.Logs; using Content.Server.Administration.Managers; using Content.Server.Chat.Managers; using Content.Server.GameTicking; +using Content.Server.Players; using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Shared.ActionBlocker; @@ -17,7 +18,6 @@ using Content.Shared.Ghost; using Content.Shared.IdentityManagement; using Content.Shared.Interaction; using Content.Shared.Mobs.Systems; -using Content.Shared.Players; using Content.Shared.Radio; using Robust.Server.GameObjects; using Robust.Server.Player; @@ -26,6 +26,7 @@ using Robust.Shared.Configuration; using Robust.Shared.Console; using Robust.Shared.Network; using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Prototypes; using Robust.Shared.Random; using Robust.Shared.Replays; @@ -146,7 +147,7 @@ public sealed partial class ChatSystem : SharedChatSystem InGameICChatType desiredType, bool hideChat, bool hideLog = false, IConsoleShell? shell = null, - ICommonSession? player = null, string? nameOverride = null, + IPlayerSession? player = null, string? nameOverride = null, bool checkRadioPrefix = true, bool ignoreActionBlocker = false) { @@ -171,7 +172,7 @@ public sealed partial class ChatSystem : SharedChatSystem ChatTransmitRange range, bool hideLog = false, IConsoleShell? shell = null, - ICommonSession? player = null, + IPlayerSession? player = null, string? nameOverride = null, bool checkRadioPrefix = true, bool ignoreActionBlocker = false @@ -252,7 +253,7 @@ public sealed partial class ChatSystem : SharedChatSystem InGameOOCChatType type, bool hideChat, IConsoleShell? shell = null, - ICommonSession? player = null + IPlayerSession? player = null ) { if (!CanSendInGame(message, shell, player)) @@ -546,7 +547,7 @@ public sealed partial class ChatSystem : SharedChatSystem } // ReSharper disable once InconsistentNaming - private void SendLOOC(EntityUid source, ICommonSession player, string message, bool hideChat) + private void SendLOOC(EntityUid source, IPlayerSession player, string message, bool hideChat) { var name = FormattedMessage.EscapeText(Identity.Name(source, EntityManager)); @@ -570,7 +571,7 @@ public sealed partial class ChatSystem : SharedChatSystem _adminLogger.Add(LogType.Chat, LogImpact.Low, $"LOOC from {player:Player}: {message}"); } - private void SendDeadChat(EntityUid source, ICommonSession player, string message, bool hideChat) + private void SendDeadChat(EntityUid source, IPlayerSession player, string message, bool hideChat) { var clients = GetDeadChatClients(); var playerName = Name(source); @@ -627,13 +628,13 @@ public sealed partial class ChatSystem : SharedChatSystem initialResult = MessageRangeCheckResult.Full; break; case ChatTransmitRange.GhostRangeLimit: - initialResult = (data.Observer && data.Range < 0 && !_adminManager.IsAdmin(session)) ? MessageRangeCheckResult.HideChat : MessageRangeCheckResult.Full; + initialResult = (data.Observer && data.Range < 0 && !_adminManager.IsAdmin((IPlayerSession) session)) ? MessageRangeCheckResult.HideChat : MessageRangeCheckResult.Full; break; case ChatTransmitRange.HideChat: initialResult = MessageRangeCheckResult.HideChat; break; case ChatTransmitRange.NoGhosts: - initialResult = (data.Observer && !_adminManager.IsAdmin(session)) ? MessageRangeCheckResult.Disallowed : MessageRangeCheckResult.Full; + initialResult = (data.Observer && !_adminManager.IsAdmin((IPlayerSession) session)) ? MessageRangeCheckResult.Disallowed : MessageRangeCheckResult.Full; break; } var insistHideChat = data.HideChatOverride ?? false; @@ -665,7 +666,7 @@ public sealed partial class ChatSystem : SharedChatSystem /// /// Returns true if the given player is 'allowed' to send the given message, false otherwise. /// - private bool CanSendInGame(string message, IConsoleShell? shell = null, ICommonSession? player = null) + private bool CanSendInGame(string message, IConsoleShell? shell = null, IPlayerSession? player = null) { // Non-players don't have to worry about these restrictions. if (player == null) @@ -693,7 +694,7 @@ public sealed partial class ChatSystem : SharedChatSystem { var newMessage = message.Trim(); newMessage = SanitizeMessageReplaceWords(newMessage); - + if (capitalize) newMessage = SanitizeMessageCapital(newMessage); if (capitalizeTheWordI) diff --git a/Content.Server/Chemistry/EntitySystems/ChemistryGuideDataSystem.cs b/Content.Server/Chemistry/EntitySystems/ChemistryGuideDataSystem.cs index 7485c0e901..8cbdd82f07 100644 --- a/Content.Server/Chemistry/EntitySystems/ChemistryGuideDataSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ChemistryGuideDataSystem.cs @@ -2,7 +2,6 @@ using Content.Shared.Chemistry.Reagent; using Robust.Server.Player; using Robust.Shared.Enums; -using Robust.Shared.Player; using Robust.Shared.Prototypes; namespace Content.Server.Chemistry.EntitySystems; diff --git a/Content.Server/Chunking/ChunkingSystem.cs b/Content.Server/Chunking/ChunkingSystem.cs index 6f44c43be8..4ef44d1678 100644 --- a/Content.Server/Chunking/ChunkingSystem.cs +++ b/Content.Server/Chunking/ChunkingSystem.cs @@ -1,12 +1,12 @@ using System.Linq; using Content.Shared.Decals; using Microsoft.Extensions.ObjectPool; +using Robust.Server.Player; using Robust.Shared; using Robust.Shared.Configuration; using Robust.Shared.Enums; using Robust.Shared.Map; using Robust.Shared.Map.Components; -using Robust.Shared.Player; using Robust.Shared.Utility; namespace Content.Shared.Chunking; @@ -41,7 +41,7 @@ public sealed class ChunkingSystem : EntitySystem private void OnPvsRangeChanged(float value) => _baseViewBounds = Box2.UnitCentered.Scale(value); public Dictionary> GetChunksForSession( - ICommonSession session, + IPlayerSession session, int chunkSize, ObjectPool> indexPool, ObjectPool>> viewerPool, @@ -52,7 +52,7 @@ public sealed class ChunkingSystem : EntitySystem return chunks; } - private HashSet GetSessionViewers(ICommonSession session) + private HashSet GetSessionViewers(IPlayerSession session) { var viewers = new HashSet(); if (session.Status != SessionStatus.InGame || session.AttachedEntity is null) diff --git a/Content.Server/Commands/CommandUtils.cs b/Content.Server/Commands/CommandUtils.cs index 172f3324e3..11adaec9a2 100644 --- a/Content.Server/Commands/CommandUtils.cs +++ b/Content.Server/Commands/CommandUtils.cs @@ -3,7 +3,6 @@ using System.Globalization; using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Network; -using Robust.Shared.Player; namespace Content.Server.Commands { @@ -17,7 +16,7 @@ namespace Content.Server.Commands /// sending a failure to the performer if unable to. /// public static bool TryGetSessionByUsernameOrId(IConsoleShell shell, - string usernameOrId, ICommonSession performer, [NotNullWhen(true)] out ICommonSession? session) + string usernameOrId, IPlayerSession performer, [NotNullWhen(true)] out IPlayerSession? session) { var plyMgr = IoCManager.Resolve(); if (plyMgr.TryGetSessionByUsername(usernameOrId, out session)) return true; @@ -37,7 +36,7 @@ namespace Content.Server.Commands /// sending a failure to the performer if unable to. /// public static bool TryGetAttachedEntityByUsernameOrId(IConsoleShell shell, - string usernameOrId, ICommonSession performer, out EntityUid attachedEntity) + string usernameOrId, IPlayerSession performer, out EntityUid attachedEntity) { attachedEntity = default; if (!TryGetSessionByUsernameOrId(shell, usernameOrId, performer, out var session)) return false; @@ -68,7 +67,7 @@ namespace Content.Server.Commands transform.LocalPosition.Y.ToString(CultureInfo.InvariantCulture)); ruleString = ruleString.Replace("$NAME", entMan.GetComponent(ent).EntityName); - if (shell.Player is { } player) + if (shell.Player is IPlayerSession player) { if (player.AttachedEntity is {Valid: true} p) { diff --git a/Content.Server/Construction/Commands/FixRotationsCommand.cs b/Content.Server/Construction/Commands/FixRotationsCommand.cs index bdbfaf170d..d23fa0a31b 100644 --- a/Content.Server/Construction/Commands/FixRotationsCommand.cs +++ b/Content.Server/Construction/Commands/FixRotationsCommand.cs @@ -3,6 +3,7 @@ using Content.Server.Power.Components; using Content.Shared.Administration; using Content.Shared.Construction; using Content.Shared.Tag; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Map.Components; @@ -20,7 +21,7 @@ namespace Content.Server.Construction.Commands public void Execute(IConsoleShell shell, string argsOther, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; EntityUid? gridId; var xformQuery = _entManager.GetEntityQuery(); diff --git a/Content.Server/Construction/Commands/TileReplaceCommand.cs b/Content.Server/Construction/Commands/TileReplaceCommand.cs index f63fd4c13e..ed1fba2424 100644 --- a/Content.Server/Construction/Commands/TileReplaceCommand.cs +++ b/Content.Server/Construction/Commands/TileReplaceCommand.cs @@ -1,5 +1,6 @@ using Content.Server.Administration; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Map; using Robust.Shared.Map.Components; @@ -19,7 +20,7 @@ sealed class TileReplaceCommand : IConsoleCommand public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; EntityUid? gridId; string tileIdA; string tileIdB; diff --git a/Content.Server/Construction/Commands/TileWallsCommand.cs b/Content.Server/Construction/Commands/TileWallsCommand.cs index 731d4da7f8..55389e41cc 100644 --- a/Content.Server/Construction/Commands/TileWallsCommand.cs +++ b/Content.Server/Construction/Commands/TileWallsCommand.cs @@ -2,9 +2,10 @@ using Content.Server.Administration; using Content.Shared.Administration; using Content.Shared.Maps; using Content.Shared.Tag; +using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Map; -using Robust.Server.GameObjects; using Robust.Shared.Map.Components; namespace Content.Server.Construction.Commands @@ -28,7 +29,7 @@ namespace Content.Server.Construction.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; EntityUid? gridId; switch (args.Length) diff --git a/Content.Server/Construction/ConstructionSystem.Initial.cs b/Content.Server/Construction/ConstructionSystem.Initial.cs index 21978f2d0c..e74edb5da2 100644 --- a/Content.Server/Construction/ConstructionSystem.Initial.cs +++ b/Content.Server/Construction/ConstructionSystem.Initial.cs @@ -16,7 +16,7 @@ using Content.Shared.Interaction; using Content.Shared.Inventory; using Content.Shared.Storage; using Robust.Shared.Containers; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Timing; namespace Content.Server.Construction diff --git a/Content.Server/CrewManifest/CrewManifestSystem.cs b/Content.Server/CrewManifest/CrewManifestSystem.cs index 4c4f17f61d..aed0575324 100644 --- a/Content.Server/CrewManifest/CrewManifestSystem.cs +++ b/Content.Server/CrewManifest/CrewManifestSystem.cs @@ -10,9 +10,10 @@ using Content.Shared.CCVar; using Content.Shared.CrewManifest; using Content.Shared.GameTicking; using Content.Shared.StationRecords; +using Robust.Server.Player; using Robust.Shared.Configuration; using Robust.Shared.Console; -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Server.CrewManifest; @@ -59,7 +60,7 @@ public sealed class CrewManifestSystem : EntitySystem private void OnRequestCrewManifest(RequestCrewManifestMessage message, EntitySessionEventArgs args) { - if (args.SenderSession is not { } sessionCast + if (args.SenderSession is not IPlayerSession sessionCast || !_configManager.GetCVar(CCVars.CrewManifestWithoutEntity)) { return; @@ -92,12 +93,12 @@ public sealed class CrewManifestSystem : EntitySystem private void OnBoundUiClose(EntityUid uid, CrewManifestViewerComponent component, BoundUIClosedEvent ev) { var owningStation = _stationSystem.GetOwningStation(uid); - if (owningStation == null || ev.Session is not { } session) + if (owningStation == null || ev.Session is not IPlayerSession sessionCast) { return; } - CloseEui(owningStation.Value, session, uid); + CloseEui(owningStation.Value, sessionCast, uid); } /// @@ -125,7 +126,7 @@ public sealed class CrewManifestSystem : EntitySystem private void OpenEuiFromBui(EntityUid uid, CrewManifestViewerComponent component, CrewManifestOpenUiMessage msg) { var owningStation = _stationSystem.GetOwningStation(uid); - if (owningStation == null || msg.Session is not { } session) + if (owningStation == null || msg.Session is not IPlayerSession sessionCast) { return; } @@ -135,7 +136,7 @@ public sealed class CrewManifestSystem : EntitySystem return; } - OpenEui(owningStation.Value, session, uid); + OpenEui(owningStation.Value, sessionCast, uid); } /// @@ -144,7 +145,7 @@ public sealed class CrewManifestSystem : EntitySystem /// Station that we're displaying the crew manifest for. /// The player's session. /// If this EUI should be 'owned' by an entity. - public void OpenEui(EntityUid station, ICommonSession session, EntityUid? owner = null) + public void OpenEui(EntityUid station, IPlayerSession session, EntityUid? owner = null) { if (!HasComp(station)) { @@ -251,7 +252,7 @@ public sealed class CrewManifestCommand : IConsoleCommand return; } - if (shell.Player == null || shell.Player is not { } session) + if (shell.Player == null || shell.Player is not IPlayerSession session) { shell.WriteLine("You must run this from a client."); return; diff --git a/Content.Server/Damage/Commands/GodModeCommand.cs b/Content.Server/Damage/Commands/GodModeCommand.cs index 866737f17a..92a0e53f0f 100644 --- a/Content.Server/Damage/Commands/GodModeCommand.cs +++ b/Content.Server/Damage/Commands/GodModeCommand.cs @@ -1,6 +1,8 @@ using Content.Server.Administration; +using Content.Server.Damage.Systems; using Content.Shared.Administration; using Content.Shared.Damage.Systems; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Damage.Commands @@ -16,7 +18,7 @@ namespace Content.Server.Damage.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; EntityUid entity; switch (args.Length) diff --git a/Content.Server/Damage/ForceSay/DamageForceSaySystem.cs b/Content.Server/Damage/ForceSay/DamageForceSaySystem.cs index 457fab4bb2..3d3346403a 100644 --- a/Content.Server/Damage/ForceSay/DamageForceSaySystem.cs +++ b/Content.Server/Damage/ForceSay/DamageForceSaySystem.cs @@ -6,6 +6,7 @@ using Content.Shared.Mobs.Systems; using Content.Shared.Stunnable; using Robust.Server.GameObjects; using Robust.Server.Player; +using Robust.Shared.Players; using Robust.Shared.Prototypes; using Robust.Shared.Random; using Robust.Shared.Timing; diff --git a/Content.Server/Database/UserDbDataManager.cs b/Content.Server/Database/UserDbDataManager.cs index f8b1611fd5..f2c506240b 100644 --- a/Content.Server/Database/UserDbDataManager.cs +++ b/Content.Server/Database/UserDbDataManager.cs @@ -2,8 +2,8 @@ using System.Threading.Tasks; using Content.Server.Players.PlayTimeTracking; using Content.Server.Preferences.Managers; +using Robust.Server.Player; using Robust.Shared.Network; -using Robust.Shared.Player; using Robust.Shared.Utility; namespace Content.Server.Database; @@ -25,7 +25,7 @@ public sealed class UserDbDataManager // TODO: Ideally connected/disconnected would be subscribed to IPlayerManager directly, // but this runs into ordering issues with game ticker. - public void ClientConnected(ICommonSession session) + public void ClientConnected(IPlayerSession session) { DebugTools.Assert(!_users.ContainsKey(session.UserId), "We should not have any cached data on client connect."); @@ -36,7 +36,7 @@ public sealed class UserDbDataManager _users.Add(session.UserId, data); } - public void ClientDisconnected(ICommonSession session) + public void ClientDisconnected(IPlayerSession session) { _users.Remove(session.UserId, out var data); if (data == null) @@ -49,24 +49,24 @@ public sealed class UserDbDataManager _playTimeTracking.ClientDisconnected(session); } - private async Task Load(ICommonSession session, CancellationToken cancel) + private async Task Load(IPlayerSession session, CancellationToken cancel) { await Task.WhenAll( _prefs.LoadData(session, cancel), _playTimeTracking.LoadData(session, cancel)); } - public Task WaitLoadComplete(ICommonSession session) + public Task WaitLoadComplete(IPlayerSession session) { return _users[session.UserId].Task; } - public bool IsLoadComplete(ICommonSession session) + public bool IsLoadComplete(IPlayerSession session) { return GetLoadTask(session).IsCompleted; } - public Task GetLoadTask(ICommonSession session) + public Task GetLoadTask(IPlayerSession session) { return _users[session.UserId].Task; } diff --git a/Content.Server/Decals/DecalSystem.cs b/Content.Server/Decals/DecalSystem.cs index ce2e0711e7..ed281e05ba 100644 --- a/Content.Server/Decals/DecalSystem.cs +++ b/Content.Server/Decals/DecalSystem.cs @@ -16,7 +16,6 @@ using Robust.Shared.Configuration; using Robust.Shared.Enums; using Robust.Shared.Map; using Robust.Shared.Map.Components; -using Robust.Shared.Player; using Robust.Shared.Threading; using Robust.Shared.Timing; using Robust.Shared.Utility; @@ -37,7 +36,7 @@ namespace Content.Server.Decals [Dependency] private readonly MapSystem _mapSystem = default!; private readonly Dictionary> _dirtyChunks = new(); - private readonly Dictionary>> _previousSentChunks = new(); + private readonly Dictionary>> _previousSentChunks = new(); private static readonly Vector2 _boundsMinExpansion = new(0.01f, 0.01f); private static readonly Vector2 _boundsMaxExpansion = new(1.01f, 1.01f); @@ -198,7 +197,7 @@ namespace Content.Server.Decals private void OnDecalPlacementRequest(RequestDecalPlacementEvent ev, EntitySessionEventArgs eventArgs) { - if (eventArgs.SenderSession is not { } session) + if (eventArgs.SenderSession is not IPlayerSession session) return; // bad @@ -227,7 +226,7 @@ namespace Content.Server.Decals private void OnDecalRemovalRequest(RequestDecalRemovalEvent ev, EntitySessionEventArgs eventArgs) { - if (eventArgs.SenderSession is not { } session) + if (eventArgs.SenderSession is not IPlayerSession session) return; // bad @@ -428,7 +427,7 @@ namespace Content.Server.Decals if (PvsEnabled) { - var players = _playerManager.Sessions.Where(x => x.Status == SessionStatus.InGame).ToArray(); + var players = _playerManager.ServerSessions.Where(x => x.Status == SessionStatus.InGame).ToArray(); var opts = new ParallelOptions { MaxDegreeOfParallelism = _parMan.ParallelProcessCount }; Parallel.ForEach(players, opts, UpdatePlayer); } @@ -436,7 +435,7 @@ namespace Content.Server.Decals _dirtyChunks.Clear(); } - public void UpdatePlayer(ICommonSession player) + public void UpdatePlayer(IPlayerSession player) { var chunksInRange = _chunking.GetChunksForSession(player, ChunkSize, _chunkIndexPool, _chunkViewerPool); var staleChunks = _chunkViewerPool.Get(); @@ -531,7 +530,7 @@ namespace Content.Server.Decals } private void SendChunkUpdates( - ICommonSession session, + IPlayerSession session, Dictionary> updatedChunks, Dictionary> staleChunks) { diff --git a/Content.Server/Disposal/TubeConnectionsCommand.cs b/Content.Server/Disposal/TubeConnectionsCommand.cs index 55e6465937..7895dcbca6 100644 --- a/Content.Server/Disposal/TubeConnectionsCommand.cs +++ b/Content.Server/Disposal/TubeConnectionsCommand.cs @@ -2,6 +2,7 @@ using Content.Server.Administration; using Content.Server.Disposal.Tube; using Content.Server.Disposal.Tube.Components; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Disposal @@ -17,7 +18,7 @@ namespace Content.Server.Disposal public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player?.AttachedEntity == null) { shell.WriteLine(Loc.GetString("shell-only-players-can-run-this-command")); diff --git a/Content.Server/EUI/BaseEui.cs b/Content.Server/EUI/BaseEui.cs index 70cbfc3775..4a41ad40a5 100644 --- a/Content.Server/EUI/BaseEui.cs +++ b/Content.Server/EUI/BaseEui.cs @@ -1,6 +1,6 @@ using Content.Shared.Eui; using Robust.Shared.Network; -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Server.EUI { diff --git a/Content.Server/EUI/EuiManager.cs b/Content.Server/EUI/EuiManager.cs index fe8e486b68..4d99719525 100644 --- a/Content.Server/EUI/EuiManager.cs +++ b/Content.Server/EUI/EuiManager.cs @@ -2,7 +2,7 @@ using Robust.Server.Player; using Robust.Shared.Enums; using Robust.Shared.Network; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Utility; namespace Content.Server.EUI diff --git a/Content.Server/EntityList/SpawnEntityListCommand.cs b/Content.Server/EntityList/SpawnEntityListCommand.cs index 027d25dc2c..0891bbd12a 100644 --- a/Content.Server/EntityList/SpawnEntityListCommand.cs +++ b/Content.Server/EntityList/SpawnEntityListCommand.cs @@ -1,6 +1,7 @@ using Content.Server.Administration; using Content.Shared.Administration; using Content.Shared.EntityList; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Prototypes; @@ -21,7 +22,7 @@ namespace Content.Server.EntityList return; } - if (shell.Player is not { } player) + if (shell.Player is not IPlayerSession player) { shell.WriteError("You must be a player to run this command."); return; diff --git a/Content.Server/Examine/ExamineSystem.cs b/Content.Server/Examine/ExamineSystem.cs index 3447810896..98aa806885 100644 --- a/Content.Server/Examine/ExamineSystem.cs +++ b/Content.Server/Examine/ExamineSystem.cs @@ -4,6 +4,7 @@ using Content.Shared.Examine; using Content.Shared.Verbs; using JetBrains.Annotations; using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Utility; namespace Content.Server.Examine @@ -45,7 +46,7 @@ namespace Content.Server.Examine private void ExamineInfoRequest(ExamineSystemMessages.RequestExamineInfoMessage request, EntitySessionEventArgs eventArgs) { - var player = eventArgs.SenderSession; + var player = (IPlayerSession) eventArgs.SenderSession; var session = eventArgs.SenderSession; var channel = player.ConnectedClient; var entity = GetEntity(request.NetEntity); diff --git a/Content.Server/Fluids/EntitySystems/PuddleDebugDebugOverlaySystem.cs b/Content.Server/Fluids/EntitySystems/PuddleDebugDebugOverlaySystem.cs index c17eea684d..59f0a13695 100644 --- a/Content.Server/Fluids/EntitySystems/PuddleDebugDebugOverlaySystem.cs +++ b/Content.Server/Fluids/EntitySystems/PuddleDebugDebugOverlaySystem.cs @@ -1,9 +1,9 @@ using System.Numerics; using Content.Shared.Fluids; using Content.Shared.Fluids.Components; +using Robust.Server.Player; using Robust.Shared.Map; using Robust.Shared.Map.Components; -using Robust.Shared.Player; using Robust.Shared.Timing; namespace Content.Server.Fluids.EntitySystems; @@ -14,10 +14,10 @@ public sealed class PuddleDebugDebugOverlaySystem : SharedPuddleDebugOverlaySyst [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly PuddleSystem _puddle = default!; - private readonly HashSet _playerObservers = new(); + private readonly HashSet _playerObservers = new(); private List> _grids = new(); - public bool ToggleObserver(ICommonSession observer) + public bool ToggleObserver(IPlayerSession observer) { NextTick ??= _timing.CurTime + Cooldown; @@ -31,7 +31,7 @@ public sealed class PuddleDebugDebugOverlaySystem : SharedPuddleDebugOverlaySyst return true; } - private void RemoveObserver(ICommonSession observer) + private void RemoveObserver(IPlayerSession observer) { if (!_playerObservers.Remove(observer)) { diff --git a/Content.Server/Fluids/ShowFluidsCommand.cs b/Content.Server/Fluids/ShowFluidsCommand.cs index 71ac273a45..f122eadea7 100644 --- a/Content.Server/Fluids/ShowFluidsCommand.cs +++ b/Content.Server/Fluids/ShowFluidsCommand.cs @@ -1,6 +1,7 @@ using Content.Server.Administration; using Content.Server.Fluids.EntitySystems; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Fluids; @@ -14,7 +15,7 @@ public sealed class ShowFluidsCommand : IConsoleCommand public string Help => $"Usage: {Command}"; public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player == null) { shell.WriteLine("You must be a player to use this command."); diff --git a/Content.Server/GameTicking/Commands/JoinGameCommand.cs b/Content.Server/GameTicking/Commands/JoinGameCommand.cs index 3276b91200..366e6c4e77 100644 --- a/Content.Server/GameTicking/Commands/JoinGameCommand.cs +++ b/Content.Server/GameTicking/Commands/JoinGameCommand.cs @@ -2,6 +2,7 @@ using Content.Server.Station.Systems; using Content.Shared.Administration; using Content.Shared.GameTicking; using Content.Shared.Roles; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Prototypes; @@ -29,7 +30,7 @@ namespace Content.Server.GameTicking.Commands return; } - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player == null) { diff --git a/Content.Server/GameTicking/Commands/ObserveCommand.cs b/Content.Server/GameTicking/Commands/ObserveCommand.cs index 747e54e28b..d608dda9c1 100644 --- a/Content.Server/GameTicking/Commands/ObserveCommand.cs +++ b/Content.Server/GameTicking/Commands/ObserveCommand.cs @@ -1,5 +1,6 @@ using Content.Shared.Administration; using Content.Shared.GameTicking; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.GameTicking.Commands @@ -13,7 +14,7 @@ namespace Content.Server.GameTicking.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (shell.Player is not { } player) + if (shell.Player is not IPlayerSession player) { return; } diff --git a/Content.Server/GameTicking/Commands/RespawnCommand.cs b/Content.Server/GameTicking/Commands/RespawnCommand.cs index 4f101d0939..057572297f 100644 --- a/Content.Server/GameTicking/Commands/RespawnCommand.cs +++ b/Content.Server/GameTicking/Commands/RespawnCommand.cs @@ -14,7 +14,7 @@ namespace Content.Server.GameTicking.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (args.Length > 1) { shell.WriteLine("Must provide <= 1 argument."); diff --git a/Content.Server/GameTicking/Commands/ToggleReadyCommand.cs b/Content.Server/GameTicking/Commands/ToggleReadyCommand.cs index df418c27ee..e68c4c5fa7 100644 --- a/Content.Server/GameTicking/Commands/ToggleReadyCommand.cs +++ b/Content.Server/GameTicking/Commands/ToggleReadyCommand.cs @@ -1,4 +1,5 @@ using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.GameTicking.Commands @@ -12,7 +13,7 @@ namespace Content.Server.GameTicking.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (args.Length != 1) { shell.WriteError(Loc.GetString("shell-wrong-arguments-number")); diff --git a/Content.Server/GameTicking/GameTicker.GamePreset.cs b/Content.Server/GameTicking/GameTicker.GamePreset.cs index 2d7539bd0f..a5e6d7a605 100644 --- a/Content.Server/GameTicking/GameTicker.GamePreset.cs +++ b/Content.Server/GameTicking/GameTicker.GamePreset.cs @@ -11,7 +11,7 @@ using Content.Shared.Ghost; using Content.Shared.Mind; using Content.Shared.Mobs.Components; using JetBrains.Annotations; -using Robust.Shared.Player; +using Robust.Server.Player; namespace Content.Server.GameTicking { @@ -29,7 +29,7 @@ namespace Content.Server.GameTicking /// public GamePresetPrototype? CurrentPreset { get; private set; } - private bool StartPreset(ICommonSession[] origReadyPlayers, bool force) + private bool StartPreset(IPlayerSession[] origReadyPlayers, bool force) { var startAttempt = new RoundStartAttemptEvent(origReadyPlayers, force); RaiseLocalEvent(startAttempt); @@ -214,7 +214,7 @@ namespace Content.Server.GameTicking { if (mind.Session != null) // Logging is suppressed to prevent spam from ghost attempts caused by movement attempts { - _chatManager.DispatchServerMessage(mind.Session, Loc.GetString("comp-mind-ghosting-prevented"), + _chatManager.DispatchServerMessage((IPlayerSession) mind.Session, Loc.GetString("comp-mind-ghosting-prevented"), true); } diff --git a/Content.Server/GameTicking/GameTicker.Lobby.cs b/Content.Server/GameTicking/GameTicker.Lobby.cs index 1943a82617..b7b6a29a5a 100644 --- a/Content.Server/GameTicking/GameTicker.Lobby.cs +++ b/Content.Server/GameTicking/GameTicker.Lobby.cs @@ -1,8 +1,10 @@ using System.Linq; using Content.Shared.GameTicking; using Content.Server.Station.Components; +using Robust.Server.Player; using Robust.Shared.Network; using Robust.Shared.Player; +using Robust.Shared.Players; using System.Text; namespace Content.Server.GameTicking @@ -77,7 +79,7 @@ namespace Content.Server.GameTicking ("roundId", RoundId), ("playerCount", playerCount), ("readyCount", readyCount), ("mapName", stationNames.ToString()),("gmTitle", gmTitle),("desc", desc)); } - private TickerLobbyStatusEvent GetStatusMsg(ICommonSession session) + private TickerLobbyStatusEvent GetStatusMsg(IPlayerSession session) { _playerGameStatuses.TryGetValue(session.UserId, out var status); return new TickerLobbyStatusEvent(RunLevel != GameRunLevel.PreRoundLobby, LobbySong, LobbyBackground,status == PlayerGameStatus.ReadyToPlay, _roundStartTime, RoundPreloadTime, _roundStartTimeSpan, Paused); @@ -85,7 +87,7 @@ namespace Content.Server.GameTicking private void SendStatusToAll() { - foreach (var player in _playerManager.Sessions) + foreach (var player in _playerManager.ServerSessions) { RaiseNetworkEvent(GetStatusMsg(player), player.ConnectedClient); } @@ -146,7 +148,7 @@ namespace Content.Server.GameTicking } } - public void ToggleReady(ICommonSession player, bool ready) + public void ToggleReady(IPlayerSession player, bool ready) { if (!_playerGameStatuses.ContainsKey(player.UserId)) return; diff --git a/Content.Server/GameTicking/GameTicker.Player.cs b/Content.Server/GameTicking/GameTicker.Player.cs index 334af3f4fd..3aef1bbe78 100644 --- a/Content.Server/GameTicking/GameTicker.Player.cs +++ b/Content.Server/GameTicking/GameTicker.Player.cs @@ -1,4 +1,5 @@ using Content.Server.Database; +using Content.Server.Players; using Content.Shared.GameTicking; using Content.Shared.GameWindow; using Content.Shared.Players; @@ -6,7 +7,6 @@ using Content.Shared.Preferences; using JetBrains.Annotations; using Robust.Server.Player; using Robust.Shared.Enums; -using Robust.Shared.Player; using Robust.Shared.Timing; using Robust.Shared.Utility; @@ -49,14 +49,14 @@ namespace Content.Server.GameTicking // Always make sure the client has player data. if (session.Data.ContentDataUncast == null) { - var data = new ContentPlayerData(session.UserId, args.Session.Name); + var data = new PlayerData(session.UserId, args.Session.Name); data.Mind = mindId; session.Data.ContentDataUncast = data; } // Make the player actually join the game. // timer time must be > tick length - Timer.Spawn(0, () => _playerManager.JoinGame(args.Session)); + Timer.Spawn(0, args.Session.JoinGame); var record = await _dbManager.GetPlayerRecordByUserId(args.Session.UserId); var firstConnection = record != null && @@ -100,7 +100,8 @@ namespace Content.Server.GameTicking } else { - _playerManager.SetAttachedEntity(session, mind.CurrentEntity); + // Simply re-attach to existing entity. + session.AttachToEntity(mind.CurrentEntity); PlayerJoinGame(session); } @@ -145,12 +146,12 @@ namespace Content.Server.GameTicking } } - private HumanoidCharacterProfile GetPlayerProfile(ICommonSession p) + private HumanoidCharacterProfile GetPlayerProfile(IPlayerSession p) { return (HumanoidCharacterProfile) _prefsManager.GetPreferences(p.UserId).SelectedCharacter; } - public void PlayerJoinGame(ICommonSession session, bool silent = false) + public void PlayerJoinGame(IPlayerSession session, bool silent = false) { if (!silent) _chatManager.DispatchServerMessage(session, Loc.GetString("game-ticker-player-join-game-message")); @@ -161,7 +162,7 @@ namespace Content.Server.GameTicking RaiseNetworkEvent(new TickerJoinGameEvent(), session.ConnectedClient); } - private void PlayerJoinLobby(ICommonSession session) + private void PlayerJoinLobby(IPlayerSession session) { _playerGameStatuses[session.UserId] = LobbyEnabled ? PlayerGameStatus.NotReadyToPlay : PlayerGameStatus.ReadyToPlay; _db.AddRoundPlayers(RoundId, session.UserId); @@ -181,9 +182,9 @@ namespace Content.Server.GameTicking public sealed class PlayerJoinedLobbyEvent : EntityEventArgs { - public readonly ICommonSession PlayerSession; + public readonly IPlayerSession PlayerSession; - public PlayerJoinedLobbyEvent(ICommonSession playerSession) + public PlayerJoinedLobbyEvent(IPlayerSession playerSession) { PlayerSession = playerSession; } diff --git a/Content.Server/GameTicking/GameTicker.RoundFlow.cs b/Content.Server/GameTicking/GameTicker.RoundFlow.cs index 85f833bd1c..df2aafa901 100644 --- a/Content.Server/GameTicking/GameTicker.RoundFlow.cs +++ b/Content.Server/GameTicking/GameTicker.RoundFlow.cs @@ -12,6 +12,7 @@ using Content.Shared.Preferences; using JetBrains.Annotations; using Prometheus; using Robust.Server.Maps; +using Robust.Server.Player; using Robust.Shared.Asynchronous; using Robust.Shared.Audio; using Robust.Shared.Map; @@ -204,7 +205,7 @@ namespace Content.Server.GameTicking var startingEvent = new RoundStartingEvent(RoundId); RaiseLocalEvent(startingEvent); - var readyPlayers = new List(); + var readyPlayers = new List(); var readyPlayerProfiles = new Dictionary(); foreach (var (userId, status) in _playerGameStatuses) @@ -343,7 +344,7 @@ namespace Content.Server.GameTicking { connected = true; } - ContentPlayerData? contentPlayerData = null; + PlayerData? contentPlayerData = null; if (userId != null && _playerManager.TryGetPlayerData(userId.Value, out var playerData)) { contentPlayerData = playerData.ContentData(); @@ -359,7 +360,8 @@ namespace Content.Server.GameTicking else if (mind.CurrentEntity != null && TryName(mind.CurrentEntity.Value, out var icName)) playerIcName = icName; - if (TryGetEntity(mind.OriginalOwnedEntity, out var entity)) + var entity = mind.OriginalOwnedEntity; + if (Exists(entity)) _pvsOverride.AddGlobalOverride(entity.Value, recursive: true); var roles = _roles.MindGetAllRoles(mindId); @@ -492,7 +494,7 @@ namespace Content.Server.GameTicking private void ResettingCleanup() { // Move everybody currently in the server to lobby. - foreach (var player in _playerManager.Sessions) + foreach (var player in _playerManager.ServerSessions) { PlayerJoinLobby(player); } @@ -540,7 +542,7 @@ namespace Content.Server.GameTicking DisallowLateJoin = false; _playerGameStatuses.Clear(); - foreach (var session in _playerManager.Sessions) + foreach (var session in _playerManager.ServerSessions) { _playerGameStatuses[session.UserId] = LobbyEnabled ? PlayerGameStatus.NotReadyToPlay : PlayerGameStatus.ReadyToPlay; } @@ -734,10 +736,10 @@ namespace Content.Server.GameTicking /// public sealed class RoundStartAttemptEvent : CancellableEntityEventArgs { - public ICommonSession[] Players { get; } + public IPlayerSession[] Players { get; } public bool Forced { get; } - public RoundStartAttemptEvent(ICommonSession[] players, bool forced) + public RoundStartAttemptEvent(IPlayerSession[] players, bool forced) { Players = players; Forced = forced; @@ -756,11 +758,11 @@ namespace Content.Server.GameTicking /// If you want to handle a specific player being spawned, remove it from this list and do what you need. /// /// If you spawn a player by yourself from this event, don't forget to call on them. - public List PlayerPool { get; } + public List PlayerPool { get; } public IReadOnlyDictionary Profiles { get; } public bool Forced { get; } - public RulePlayerSpawningEvent(List playerPool, IReadOnlyDictionary profiles, bool forced) + public RulePlayerSpawningEvent(List playerPool, IReadOnlyDictionary profiles, bool forced) { PlayerPool = playerPool; Profiles = profiles; @@ -774,11 +776,11 @@ namespace Content.Server.GameTicking /// public sealed class RulePlayerJobsAssignedEvent { - public ICommonSession[] Players { get; } + public IPlayerSession[] Players { get; } public IReadOnlyDictionary Profiles { get; } public bool Forced { get; } - public RulePlayerJobsAssignedEvent(ICommonSession[] players, IReadOnlyDictionary profiles, bool forced) + public RulePlayerJobsAssignedEvent(IPlayerSession[] players, IReadOnlyDictionary profiles, bool forced) { Players = players; Profiles = profiles; diff --git a/Content.Server/GameTicking/GameTicker.Spawning.cs b/Content.Server/GameTicking/GameTicker.Spawning.cs index c2bf523657..0c59f93bb0 100644 --- a/Content.Server/GameTicking/GameTicker.Spawning.cs +++ b/Content.Server/GameTicking/GameTicker.Spawning.cs @@ -3,20 +3,20 @@ using System.Linq; using System.Numerics; using Content.Server.Administration.Managers; using Content.Server.Ghost; +using Content.Server.Players; using Content.Server.Spawners.Components; using Content.Server.Speech.Components; using Content.Server.Station.Components; using Content.Shared.CCVar; using Content.Shared.Database; -using Content.Shared.Players; using Content.Shared.Preferences; using Content.Shared.Roles; using Content.Shared.Roles.Jobs; using JetBrains.Annotations; +using Robust.Server.Player; using Robust.Shared.Map; using Robust.Shared.Map.Components; using Robust.Shared.Network; -using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Random; using Robust.Shared.Utility; @@ -29,7 +29,7 @@ namespace Content.Server.GameTicking [Dependency] private readonly SharedJobSystem _jobs = default!; [ValidatePrototypeId] - public const string ObserverPrototypeName = "MobObserver"; + private const string ObserverPrototypeName = "MobObserver"; /// /// How many players have joined the round through normal methods. @@ -52,7 +52,7 @@ namespace Content.Server.GameTicking return spawnableStations; } - private void SpawnPlayers(List readyPlayers, Dictionary profiles, bool force) + private void SpawnPlayers(List readyPlayers, Dictionary profiles, bool force) { // Allow game rules to spawn players by themselves if needed. (For example, nuke ops or wizard) RaiseLocalEvent(new RulePlayerSpawningEvent(readyPlayers, profiles, force)); @@ -116,7 +116,7 @@ namespace Content.Server.GameTicking RaiseLocalEvent(new RulePlayerJobsAssignedEvent(assignedJobs.Keys.Select(x => _playerManager.GetSessionByUserId(x)).ToArray(), profiles, force)); } - private void SpawnPlayer(ICommonSession player, EntityUid station, string? jobId = null, bool lateJoin = true, bool silent = false) + private void SpawnPlayer(IPlayerSession player, EntityUid station, string? jobId = null, bool lateJoin = true, bool silent = false) { var character = GetPlayerProfile(player); @@ -129,7 +129,7 @@ namespace Content.Server.GameTicking SpawnPlayer(player, character, station, jobId, lateJoin, silent); } - private void SpawnPlayer(ICommonSession player, HumanoidCharacterProfile character, EntityUid station, string? jobId = null, bool lateJoin = true, bool silent = false) + private void SpawnPlayer(IPlayerSession player, HumanoidCharacterProfile character, EntityUid station, string? jobId = null, bool lateJoin = true, bool silent = false) { // Can't spawn players with a dummy ticker! if (DummyTicker) @@ -271,7 +271,7 @@ namespace Content.Server.GameTicking RaiseLocalEvent(mob, aev, true); } - public void Respawn(ICommonSession player) + public void Respawn(IPlayerSession player) { _mind.WipeMind(player); _adminLogger.Add(LogType.Respawn, LogImpact.Medium, $"Player {player} was respawned."); @@ -289,7 +289,7 @@ namespace Content.Server.GameTicking /// The station they're spawning on /// An optional job for them to spawn as /// Whether or not the player should be greeted upon joining - public void MakeJoinGame(ICommonSession player, EntityUid station, string? jobId = null, bool silent = false) + public void MakeJoinGame(IPlayerSession player, EntityUid station, string? jobId = null, bool silent = false) { if (!_playerGameStatuses.ContainsKey(player.UserId)) return; @@ -303,7 +303,7 @@ namespace Content.Server.GameTicking /// /// Causes the given player to join the current game as observer ghost. See also /// - public void JoinAsObserver(ICommonSession player) + public void JoinAsObserver(IPlayerSession player) { // Can't spawn players with a dummy ticker! if (DummyTicker) @@ -317,7 +317,7 @@ namespace Content.Server.GameTicking /// Spawns an observer ghost and attaches the given player to it. If the player does not yet have a mind, the /// player is given a new mind with the observer role. Otherwise, the current mind is transferred to the ghost. /// - public void SpawnObserver(ICommonSession player) + public void SpawnObserver(IPlayerSession player) { if (DummyTicker) return; @@ -430,13 +430,13 @@ namespace Content.Server.GameTicking [PublicAPI] public sealed class PlayerBeforeSpawnEvent : HandledEntityEventArgs { - public ICommonSession Player { get; } + public IPlayerSession Player { get; } public HumanoidCharacterProfile Profile { get; } public string? JobId { get; } public bool LateJoin { get; } public EntityUid Station { get; } - public PlayerBeforeSpawnEvent(ICommonSession player, HumanoidCharacterProfile profile, string? jobId, bool lateJoin, EntityUid station) + public PlayerBeforeSpawnEvent(IPlayerSession player, HumanoidCharacterProfile profile, string? jobId, bool lateJoin, EntityUid station) { Player = player; Profile = profile; @@ -455,7 +455,7 @@ namespace Content.Server.GameTicking public sealed class PlayerSpawnCompleteEvent : EntityEventArgs { public EntityUid Mob { get; } - public ICommonSession Player { get; } + public IPlayerSession Player { get; } public string? JobId { get; } public bool LateJoin { get; } public EntityUid Station { get; } @@ -464,7 +464,7 @@ namespace Content.Server.GameTicking // Ex. If this is the 27th person to join, this will be 27. public int JoinOrder { get; } - public PlayerSpawnCompleteEvent(EntityUid mob, ICommonSession player, string? jobId, bool lateJoin, int joinOrder, EntityUid station, HumanoidCharacterProfile profile) + public PlayerSpawnCompleteEvent(EntityUid mob, IPlayerSession player, string? jobId, bool lateJoin, int joinOrder, EntityUid station, HumanoidCharacterProfile profile) { Mob = mob; Player = player; diff --git a/Content.Server/GameTicking/Rules/Components/TraitorRuleComponent.cs b/Content.Server/GameTicking/Rules/Components/TraitorRuleComponent.cs index 7af87179d6..883abef52f 100644 --- a/Content.Server/GameTicking/Rules/Components/TraitorRuleComponent.cs +++ b/Content.Server/GameTicking/Rules/Components/TraitorRuleComponent.cs @@ -1,7 +1,7 @@ using Content.Shared.Preferences; using Content.Shared.Roles; +using Robust.Server.Player; using Robust.Shared.Audio; -using Robust.Shared.Player; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; namespace Content.Server.GameTicking.Rules.Components; @@ -26,7 +26,7 @@ public sealed partial class TraitorRuleComponent : Component public SelectionState SelectionStatus = SelectionState.WaitingForSpawn; public TimeSpan AnnounceAt = TimeSpan.Zero; - public Dictionary StartCandidates = new(); + public Dictionary StartCandidates = new(); /// /// Path to antagonist alert sound. diff --git a/Content.Server/GameTicking/Rules/InactivityTimeRestartRuleSystem.cs b/Content.Server/GameTicking/Rules/InactivityTimeRestartRuleSystem.cs index b775b7af56..c2e91ba4a5 100644 --- a/Content.Server/GameTicking/Rules/InactivityTimeRestartRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/InactivityTimeRestartRuleSystem.cs @@ -2,7 +2,6 @@ using System.Threading; using Content.Server.Chat.Managers; using Content.Server.GameTicking.Rules.Components; using Robust.Server.Player; -using Robust.Shared.Player; using Timer = Robust.Shared.Timing.Timer; namespace Content.Server.GameTicking.Rules; diff --git a/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs b/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs index 4d3eee81e2..13d4ed71c8 100644 --- a/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs @@ -602,11 +602,11 @@ public sealed class NukeopsRuleSystem : GameRuleSystem var maxOperatives = nukeops.MaxOps; // Dear lord what is happening HERE. - var everyone = new List(ev.PlayerPool); - var prefList = new List(); - var medPrefList = new List(); - var cmdrPrefList = new List(); - var operatives = new List(); + var everyone = new List(ev.PlayerPool); + var prefList = new List(); + var medPrefList = new List(); + var cmdrPrefList = new List(); + var operatives = new List(); // The LINQ expression ReSharper keeps suggesting is completely unintelligible so I'm disabling it // ReSharper disable once ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator @@ -637,7 +637,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem for (var i = 0; i < numNukies; i++) { // TODO: Please fix this if you touch it. - ICommonSession nukeOp; + IPlayerSession nukeOp; // Only one commander, so we do it at the start if (i == 0) { @@ -908,7 +908,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem _npcFaction.AddFaction(mob, "Syndicate"); } - private void SpawnOperatives(int spawnCount, List sessions, bool addSpawnPoints, NukeopsRuleComponent component) + private void SpawnOperatives(int spawnCount, List sessions, bool addSpawnPoints, NukeopsRuleComponent component) { if (component.NukieOutpost == null) return; @@ -987,10 +987,10 @@ public sealed class NukeopsRuleSystem : GameRuleSystem var playersPerOperative = component.PlayersPerOperative; var maxOperatives = component.MaxOps; - var playerPool = _playerManager.Sessions.ToList(); + var playerPool = _playerManager.ServerSessions.ToList(); var numNukies = MathHelper.Clamp(playerPool.Count / playersPerOperative, 1, maxOperatives); - var operatives = new List(); + var operatives = new List(); SpawnOperatives(numNukies, operatives, true, component); } diff --git a/Content.Server/GameTicking/Rules/PiratesRuleSystem.cs b/Content.Server/GameTicking/Rules/PiratesRuleSystem.cs index 0785d81d09..b223161c10 100644 --- a/Content.Server/GameTicking/Rules/PiratesRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/PiratesRuleSystem.cs @@ -15,10 +15,10 @@ using Content.Shared.Preferences; using Content.Shared.Roles; using Robust.Server.GameObjects; using Robust.Server.Maps; +using Robust.Server.Player; using Robust.Shared.Configuration; using Robust.Shared.Enums; using Robust.Shared.Map; -using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Random; using Robust.Shared.Utility; @@ -141,7 +141,7 @@ public sealed class PiratesRuleSystem : GameRuleSystem (int) Math.Min( Math.Floor((double) ev.PlayerPool.Count / _cfg.GetCVar(CCVars.PiratesPlayersPerOp)), _cfg.GetCVar(CCVars.PiratesMaxOps))); - var ops = new ICommonSession[numOps]; + var ops = new IPlayerSession[numOps]; for (var i = 0; i < numOps; i++) { ops[i] = _random.PickAndTake(ev.PlayerPool); diff --git a/Content.Server/GameTicking/Rules/RespawnRuleSystem.cs b/Content.Server/GameTicking/Rules/RespawnRuleSystem.cs index 738883fff3..a286808623 100644 --- a/Content.Server/GameTicking/Rules/RespawnRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/RespawnRuleSystem.cs @@ -6,7 +6,6 @@ using Content.Shared.Chat; using Content.Shared.Interaction.Events; using Content.Shared.Mind; using Content.Shared.Mobs; -using Content.Shared.Players; using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Network; diff --git a/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs b/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs index ef949d09fc..01317dbfc1 100644 --- a/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs @@ -17,8 +17,9 @@ using Content.Shared.PDA; using Content.Shared.Preferences; using Content.Shared.Roles; using Content.Shared.Roles.Jobs; +using Robust.Server.Player; using Robust.Shared.Configuration; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Prototypes; using Robust.Shared.Random; using Robust.Shared.Timing; @@ -150,9 +151,9 @@ public sealed class TraitorRuleSystem : GameRuleSystem } } - private List FindPotentialTraitors(in Dictionary candidates, TraitorRuleComponent component) + private List FindPotentialTraitors(in Dictionary candidates, TraitorRuleComponent component) { - var list = new List(); + var list = new List(); var pendingQuery = GetEntityQuery(); foreach (var player in candidates.Keys) @@ -170,7 +171,7 @@ public sealed class TraitorRuleSystem : GameRuleSystem list.Add(player); } - var prefList = new List(); + var prefList = new List(); foreach (var player in list) { @@ -188,9 +189,9 @@ public sealed class TraitorRuleSystem : GameRuleSystem return prefList; } - private List PickTraitors(int traitorCount, List prefList) + private List PickTraitors(int traitorCount, List prefList) { - var results = new List(traitorCount); + var results = new List(traitorCount); if (prefList.Count == 0) { Log.Info("Insufficient ready players to fill up with traitors, stopping the selection."); diff --git a/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs b/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs index a4febc385c..82ae4b8fa6 100644 --- a/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs @@ -23,7 +23,7 @@ using Content.Shared.Zombies; using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Configuration; -using Robust.Shared.Player; +using Robust.Shared.Prototypes; using Robust.Shared.Random; using Robust.Shared.Timing; @@ -264,9 +264,9 @@ public sealed class ZombieRuleSystem : GameRuleSystem return; component.InfectedChosen = true; - var allPlayers = _playerManager.Sessions.ToList(); - var playerList = new List(); - var prefList = new List(); + var allPlayers = _playerManager.ServerSessions.ToList(); + var playerList = new List(); + var prefList = new List(); foreach (var player in allPlayers) { if (player.AttachedEntity == null || !HasComp(player.AttachedEntity) || HasComp(player.AttachedEntity)) @@ -288,7 +288,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem var totalInfected = 0; while (totalInfected < numInfected) { - ICommonSession zombie; + IPlayerSession zombie; if (prefList.Count == 0) { if (playerList.Count == 0) diff --git a/Content.Server/Ghost/Ghost.cs b/Content.Server/Ghost/Ghost.cs index 1453bf3faa..d04b1197af 100644 --- a/Content.Server/Ghost/Ghost.cs +++ b/Content.Server/Ghost/Ghost.cs @@ -1,6 +1,7 @@ using Content.Server.GameTicking; using Content.Shared.Administration; using Content.Shared.Mind; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Ghost @@ -16,7 +17,7 @@ namespace Content.Server.Ghost public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player == null) { shell.WriteLine("You have no session, you can't ghost."); diff --git a/Content.Server/Ghost/Roles/Components/TakeGhostRoleEvent.cs b/Content.Server/Ghost/Roles/Components/TakeGhostRoleEvent.cs index 16d46871fe..c97e3be9dc 100644 --- a/Content.Server/Ghost/Roles/Components/TakeGhostRoleEvent.cs +++ b/Content.Server/Ghost/Roles/Components/TakeGhostRoleEvent.cs @@ -1,4 +1,4 @@ -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Server.Ghost.Roles.Components; diff --git a/Content.Server/Ghost/Roles/GhostRoleSystem.cs b/Content.Server/Ghost/Roles/GhostRoleSystem.cs index f372cb4f62..5a4cc176f2 100644 --- a/Content.Server/Ghost/Roles/GhostRoleSystem.cs +++ b/Content.Server/Ghost/Roles/GhostRoleSystem.cs @@ -4,6 +4,7 @@ using Content.Server.Ghost.Roles.Components; using Content.Server.Ghost.Roles.Events; using Content.Server.Ghost.Roles.UI; using Content.Server.Mind.Commands; +using Content.Server.Players; using Content.Shared.Administration; using Content.Shared.Database; using Content.Shared.Follower; @@ -13,14 +14,13 @@ using Content.Shared.Ghost.Roles; using Content.Shared.Mind; using Content.Shared.Mind.Components; using Content.Shared.Mobs; -using Content.Shared.Players; using Content.Shared.Roles; using JetBrains.Annotations; using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Enums; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Random; using Robust.Shared.Utility; @@ -97,7 +97,7 @@ namespace Content.Server.Ghost.Roles return unchecked(_nextRoleIdentifier++); } - public void OpenEui(ICommonSession session) + public void OpenEui(IPlayerSession session) { if (session.AttachedEntity is not {Valid: true} attached || !EntityManager.HasComponent(attached)) @@ -111,7 +111,7 @@ namespace Content.Server.Ghost.Roles eui.StateDirty(); } - public void OpenMakeGhostRoleEui(ICommonSession session, EntityUid uid) + public void OpenMakeGhostRoleEui(IPlayerSession session, EntityUid uid) { if (session.AttachedEntity == null) return; @@ -420,7 +420,7 @@ namespace Content.Server.Ghost.Roles public void Execute(IConsoleShell shell, string argStr, string[] args) { if(shell.Player != null) - EntitySystem.Get().OpenEui(shell.Player); + EntitySystem.Get().OpenEui((IPlayerSession)shell.Player); else shell.WriteLine("You can only open the ghost roles UI on a client."); } diff --git a/Content.Server/Gravity/GravityGeneratorSystem.cs b/Content.Server/Gravity/GravityGeneratorSystem.cs index 0bd159f61a..48002fb823 100644 --- a/Content.Server/Gravity/GravityGeneratorSystem.cs +++ b/Content.Server/Gravity/GravityGeneratorSystem.cs @@ -6,7 +6,7 @@ using Content.Shared.Database; using Content.Shared.Gravity; using Content.Shared.Interaction; using Robust.Server.GameObjects; -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Server.Gravity { @@ -139,7 +139,7 @@ namespace Content.Server.Gravity return; if (session is { AttachedEntity: { } }) - _adminLogger.Add(LogType.Action, on ? LogImpact.Medium : LogImpact.High, $"{session:player} set ${ToPrettyString(uid):target} to {(on ? "on" : "off")}"); + _adminLogger.Add(LogType.Action, on ? LogImpact.Medium : LogImpact.High, $"{ToPrettyString(session.AttachedEntity.Value):player} set ${ToPrettyString(uid):target} to {(on ? "on" : "off")}"); component.SwitchedOn = on; UpdatePowerState(component, powerReceiver); diff --git a/Content.Server/Hands/Systems/HandsSystem.cs b/Content.Server/Hands/Systems/HandsSystem.cs index e3e6699537..b5b01ac001 100644 --- a/Content.Server/Hands/Systems/HandsSystem.cs +++ b/Content.Server/Hands/Systems/HandsSystem.cs @@ -18,11 +18,12 @@ using Content.Shared.Pulling.Components; using Content.Shared.Stacks; using Content.Shared.Storage; using Content.Shared.Throwing; +using Robust.Server.Player; using Robust.Shared.Containers; using Robust.Shared.GameStates; using Robust.Shared.Input.Binding; using Robust.Shared.Map; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Utility; namespace Content.Server.Hands.Systems @@ -158,9 +159,9 @@ namespace Content.Server.Hands.Systems #endregion #region interactions - private bool HandleThrowItem(ICommonSession? playerSession, EntityCoordinates coordinates, EntityUid entity) + private bool HandleThrowItem(ICommonSession? session, EntityCoordinates coordinates, EntityUid entity) { - if (playerSession == null) + if (session is not IPlayerSession playerSession) return false; if (playerSession.AttachedEntity is not {Valid: true} player || @@ -219,7 +220,7 @@ namespace Content.Server.Hands.Systems // TODO: move to storage or inventory private void HandleSmartEquip(ICommonSession? session, string equipmentSlot) { - if (session is not { } playerSession) + if (session is not IPlayerSession playerSession) return; if (playerSession.AttachedEntity is not {Valid: true} plyEnt || !Exists(plyEnt)) diff --git a/Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.Modifier.cs b/Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.Modifier.cs index b47fe71714..7c0bb7383b 100644 --- a/Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.Modifier.cs +++ b/Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.Modifier.cs @@ -3,6 +3,7 @@ using Content.Shared.Administration; using Content.Shared.Humanoid; using Content.Shared.Verbs; using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Utility; namespace Content.Server.Humanoid; @@ -47,7 +48,7 @@ public sealed partial class HumanoidAppearanceSystem private void OnBaseLayersSet(EntityUid uid, HumanoidAppearanceComponent component, HumanoidMarkingModifierBaseLayersSetMessage message) { - if (message.Session is not { } player + if (message.Session is not IPlayerSession player || !_adminManager.HasAdminFlag(player, AdminFlags.Fun)) { return; @@ -80,7 +81,7 @@ public sealed partial class HumanoidAppearanceSystem private void OnMarkingsSet(EntityUid uid, HumanoidAppearanceComponent component, HumanoidMarkingModifierMarkingSetMessage message) { - if (message.Session is not { } player + if (message.Session is not IPlayerSession player || !_adminManager.HasAdminFlag(player, AdminFlags.Fun)) { return; diff --git a/Content.Server/Instruments/InstrumentComponent.cs b/Content.Server/Instruments/InstrumentComponent.cs index 4302ab6791..810d265314 100644 --- a/Content.Server/Instruments/InstrumentComponent.cs +++ b/Content.Server/Instruments/InstrumentComponent.cs @@ -1,7 +1,7 @@ using Content.Server.UserInterface; using Content.Shared.Instruments; using Robust.Server.GameObjects; -using Robust.Shared.Player; +using Robust.Server.Player; namespace Content.Server.Instruments; @@ -17,7 +17,7 @@ public sealed partial class InstrumentComponent : SharedInstrumentComponent [ViewVariables] public uint LastSequencerTick = 0; // TODO Instruments: Make this ECS - public ICommonSession? InstrumentPlayer => + public IPlayerSession? InstrumentPlayer => _entMan.GetComponentOrNull(Owner)?.CurrentSingleUser ?? _entMan.GetComponentOrNull(Owner)?.PlayerSession; } diff --git a/Content.Server/Instruments/InstrumentSystem.cs b/Content.Server/Instruments/InstrumentSystem.cs index 6f8369182c..ec23382105 100644 --- a/Content.Server/Instruments/InstrumentSystem.cs +++ b/Content.Server/Instruments/InstrumentSystem.cs @@ -9,12 +9,12 @@ using Content.Shared.Physics; using Content.Shared.Popups; using JetBrains.Annotations; using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Audio.Midi; using Robust.Shared.Collections; using Robust.Shared.Configuration; using Robust.Shared.Console; using Robust.Shared.GameStates; -using Robust.Shared.Player; using Robust.Shared.Timing; namespace Content.Server.Instruments; @@ -385,7 +385,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem var nearby = GetBands(entity); _bui.TrySendUiMessage(entity, request.UiKey, new InstrumentBandResponseBuiMessage(nearby), - request.Session); + (IPlayerSession)request.Session); } _bandRequestQueue.Clear(); @@ -447,7 +447,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem } } - public void ToggleInstrumentUi(EntityUid uid, ICommonSession session, InstrumentComponent? component = null) + public void ToggleInstrumentUi(EntityUid uid, IPlayerSession session, InstrumentComponent? component = null) { if (!Resolve(uid, ref component)) return; diff --git a/Content.Server/Interaction/InteractionSystem.cs b/Content.Server/Interaction/InteractionSystem.cs index 9237a1f7dd..a612b73840 100644 --- a/Content.Server/Interaction/InteractionSystem.cs +++ b/Content.Server/Interaction/InteractionSystem.cs @@ -13,6 +13,7 @@ using Robust.Server.GameObjects; using Robust.Shared.Containers; using Robust.Shared.Input.Binding; using Robust.Shared.Map; +using Robust.Shared.Players; using Robust.Shared.Random; namespace Content.Server.Interaction diff --git a/Content.Server/Interaction/TilePryCommand.cs b/Content.Server/Interaction/TilePryCommand.cs index fa75b6d9e4..4fe3599df9 100644 --- a/Content.Server/Interaction/TilePryCommand.cs +++ b/Content.Server/Interaction/TilePryCommand.cs @@ -1,7 +1,10 @@ using System.Numerics; using Content.Server.Administration; +using Content.Server.Tools.Components; using Content.Shared.Administration; using Content.Shared.Maps; +using Content.Shared.Tools.Components; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Map; @@ -21,7 +24,7 @@ namespace Content.Server.Interaction public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player?.AttachedEntity is not {} attached) { return; diff --git a/Content.Server/MagicMirror/MagicMirrorSystem.cs b/Content.Server/MagicMirror/MagicMirrorSystem.cs index a599a2c868..90a0b19b7d 100644 --- a/Content.Server/MagicMirror/MagicMirrorSystem.cs +++ b/Content.Server/MagicMirror/MagicMirrorSystem.cs @@ -5,7 +5,8 @@ using Content.Shared.Humanoid; using Content.Shared.Humanoid.Markings; using Content.Shared.MagicMirror; using Robust.Server.GameObjects; -using Robust.Shared.Player; +using Robust.Server.Player; +using Robust.Shared.Players; namespace Content.Server.MagicMirror; @@ -146,7 +147,7 @@ public sealed class MagicMirrorSystem : EntitySystem private void UpdateInterface(EntityUid uid, EntityUid playerUid, ICommonSession session, HumanoidAppearanceComponent? humanoid = null) { - if (!Resolve(playerUid, ref humanoid) || session is not { } player) + if (!Resolve(playerUid, ref humanoid) || session is not IPlayerSession player) { return; } diff --git a/Content.Server/Mapping/MappingCommand.cs b/Content.Server/Mapping/MappingCommand.cs index d72a5c4178..e4a4cd8942 100644 --- a/Content.Server/Mapping/MappingCommand.cs +++ b/Content.Server/Mapping/MappingCommand.cs @@ -40,7 +40,7 @@ namespace Content.Server.Mapping public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (shell.Player is not { } player) + if (shell.Player is not IPlayerSession player) { shell.WriteError(Loc.GetString("cmd-savemap-server")); return; diff --git a/Content.Server/Maps/GridDraggingSystem.cs b/Content.Server/Maps/GridDraggingSystem.cs index 7d7b61955b..90770af1ad 100644 --- a/Content.Server/Maps/GridDraggingSystem.cs +++ b/Content.Server/Maps/GridDraggingSystem.cs @@ -1,9 +1,10 @@ using Content.Shared.Maps; using Robust.Server.Console; +using Robust.Server.Player; +using Robust.Shared.Players; using Robust.Shared.Utility; using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Systems; -using Robust.Shared.Player; namespace Content.Server.Maps; @@ -26,7 +27,7 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem public void Toggle(ICommonSession session) { - if (session is not { } pSession) + if (session is not IPlayerSession pSession) return; DebugTools.Assert(_admin.CanCommand(pSession, CommandName)); @@ -51,7 +52,7 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem { var grid = GetEntity(ev.Grid); - if (args.SenderSession is not { } playerSession || + if (args.SenderSession is not IPlayerSession playerSession || !_admin.CanCommand(playerSession, CommandName) || !Exists(grid) || Deleted(grid)) @@ -68,7 +69,7 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem { var grid = GetEntity(msg.Grid); - if (args.SenderSession is not { } playerSession || + if (args.SenderSession is not IPlayerSession playerSession || !_admin.CanCommand(playerSession, CommandName) || !Exists(grid) || Deleted(grid)) diff --git a/Content.Server/Medical/DefibrillatorSystem.cs b/Content.Server/Medical/DefibrillatorSystem.cs index d041f8ee9d..4ffa9f558d 100644 --- a/Content.Server/Medical/DefibrillatorSystem.cs +++ b/Content.Server/Medical/DefibrillatorSystem.cs @@ -18,7 +18,7 @@ using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Systems; using Content.Shared.Timing; using Content.Shared.Toggleable; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Timing; namespace Content.Server.Medical; diff --git a/Content.Server/Mind/Commands/RenameCommand.cs b/Content.Server/Mind/Commands/RenameCommand.cs index 2d65adc508..5674da4ffd 100644 --- a/Content.Server/Mind/Commands/RenameCommand.cs +++ b/Content.Server/Mind/Commands/RenameCommand.cs @@ -54,7 +54,6 @@ public sealed class RenameCommand : IConsoleCommand { // Mind mind.CharacterName = name; - _entManager.Dirty(mindId, mind); } // Id Cards diff --git a/Content.Server/Mind/MindSystem.cs b/Content.Server/Mind/MindSystem.cs index f23e9b6407..373007fd1b 100644 --- a/Content.Server/Mind/MindSystem.cs +++ b/Content.Server/Mind/MindSystem.cs @@ -1,7 +1,6 @@ using System.Diagnostics.CodeAnalysis; using Content.Server.Administration.Logs; using Content.Server.GameTicking; -using Content.Server.Mind.Commands; using Content.Shared.Database; using Content.Shared.Ghost; using Content.Shared.Mind; @@ -11,9 +10,7 @@ using Robust.Server.GameObjects; using Robust.Server.GameStates; using Robust.Server.Player; using Robust.Shared.Map; -using Robust.Shared.Map.Components; using Robust.Shared.Network; -using Robust.Shared.Player; using Robust.Shared.Timing; using Robust.Shared.Utility; @@ -49,14 +46,20 @@ public sealed class MindSystem : SharedMindSystem mind.UserId = null; } - if (mind.OwnedEntity != null && !TerminatingOrDeleted(mind.OwnedEntity.Value)) - TransferTo(uid, null, mind: mind, createGhost: false); + if (!TryComp(mind.OwnedEntity, out MetaDataComponent? meta) || meta.EntityLifeStage >= EntityLifeStage.Terminating) + return; + RaiseLocalEvent(mind.OwnedEntity.Value, new MindRemovedMessage(uid, mind), true); mind.OwnedEntity = null; + mind.OwnedComponent = null; } private void OnMindContainerTerminating(EntityUid uid, MindContainerComponent component, ref EntityTerminatingEvent args) { + // Let's not create ghosts if not in the middle of the round. + if (_gameTicker.RunLevel == GameRunLevel.PreRoundLobby) + return; + if (!TryGetMind(uid, out var mindId, out var mind, component)) return; @@ -73,45 +76,46 @@ public sealed class MindSystem : SharedMindSystem } TransferTo(mindId, null, createGhost: false, mind: mind); - DebugTools.AssertNull(mind.OwnedEntity); - if (!component.GhostOnShutdown || mind.Session == null || _gameTicker.RunLevel == GameRunLevel.PreRoundLobby) - return; + if (component.GhostOnShutdown && mind.Session != null) + { + var xform = Transform(uid); + var gridId = xform.GridUid; + var spawnPosition = Transform(uid).Coordinates; - var xform = Transform(uid); - var gridId = xform.GridUid; - var spawnPosition = Transform(uid).Coordinates; + // Use a regular timer here because the entity has probably been deleted. + Timer.Spawn(0, () => + { + // Make extra sure the round didn't end between spawning the timer and it being executed. + if (_gameTicker.RunLevel == GameRunLevel.PreRoundLobby) + return; - // Use a regular timer here because the entity has probably been deleted. - Timer.Spawn(0, () => - { - // Make extra sure the round didn't end between spawning the timer and it being executed. - if (_gameTicker.RunLevel == GameRunLevel.PreRoundLobby) - return; + // Async this so that we don't throw if the grid we're on is being deleted. + if (!_maps.GridExists(gridId)) + spawnPosition = _gameTicker.GetObserverSpawnPoint(); - // Async this so that we don't throw if the grid we're on is being deleted. - if (!HasComp(gridId)) - spawnPosition = _gameTicker.GetObserverSpawnPoint(); + // TODO refactor observer spawning. + // please. + if (!spawnPosition.IsValid(EntityManager)) + { + // This should be an error, if it didn't cause tests to start erroring when they delete a player. + Log.Warning($"Entity \"{ToPrettyString(uid)}\" for {mind.CharacterName} was deleted, and no applicable spawn location is available."); + TransferTo(mindId, null, createGhost: false, mind: mind); + return; + } - // TODO refactor observer spawning. - // please. - if (!spawnPosition.IsValid(EntityManager)) - { - // This should be an error, if it didn't cause tests to start erroring when they delete a player. - Log.Warning($"Entity \"{ToPrettyString(uid)}\" for {mind.CharacterName} was deleted, and no applicable spawn location is available."); - TransferTo(mindId, null, createGhost: false, mind: mind); - return; - } + var ghost = Spawn("MobObserver", spawnPosition); + var ghostComponent = Comp(ghost); + _ghosts.SetCanReturnToBody(ghostComponent, false); - var ghost = Spawn(GameTicker.ObserverPrototypeName, spawnPosition); - var ghostComponent = Comp(ghost); - _ghosts.SetCanReturnToBody(ghostComponent, false); + // Log these to make sure they're not causing the GameTicker round restart bugs... + Log.Debug($"Entity \"{ToPrettyString(uid)}\" for {mind.CharacterName} was deleted, spawned \"{ToPrettyString(ghost)}\"."); - // Log these to make sure they're not causing the GameTicker round restart bugs... - Log.Debug($"Entity \"{ToPrettyString(uid)}\" for {mind.CharacterName} was deleted, spawned \"{ToPrettyString(ghost)}\"."); - _metaData.SetEntityName(ghost, mind.CharacterName ?? string.Empty); - TransferTo(mindId, ghost, mind: mind); - }); + var val = mind.CharacterName ?? string.Empty; + _metaData.SetEntityName(ghost, val); + TransferTo(mindId, ghost, mind: mind); + }); + } } public override bool TryGetMind(NetUserId user, [NotNullWhen(true)] out EntityUid? mindId, [NotNullWhen(true)] out MindComponent? mind) @@ -126,18 +130,18 @@ public sealed class MindSystem : SharedMindSystem return false; } - public bool TryGetSession(EntityUid? mindId, [NotNullWhen(true)] out ICommonSession? session) + public bool TryGetSession(EntityUid? mindId, [NotNullWhen(true)] out IPlayerSession? session) { session = null; - return TryComp(mindId, out MindComponent? mind) && (session = mind.Session) != null; + return TryComp(mindId, out MindComponent? mind) && (session = (IPlayerSession?) mind.Session) != null; } - public ICommonSession? GetSession(MindComponent mind) + public IPlayerSession? GetSession(MindComponent mind) { - return mind.Session; + return (IPlayerSession?) mind.Session; } - public bool TryGetSession(MindComponent mind, [NotNullWhen(true)] out ICommonSession? session) + public bool TryGetSession(MindComponent mind, [NotNullWhen(true)] out IPlayerSession? session) { return (session = GetSession(mind)) != null; } @@ -175,9 +179,7 @@ public sealed class MindSystem : SharedMindSystem return; } - if (GetSession(mind) is { } session) - _actor.Attach(entity, session); - + GetSession(mind)?.AttachToEntity(entity); mind.VisitingEntity = entity; // EnsureComp instead of AddComp to deal with deferred deletions. @@ -196,14 +198,13 @@ public sealed class MindSystem : SharedMindSystem if (mind.VisitingEntity == null) return; - RemoveVisitingEntity(mindId, mind); + RemoveVisitingEntity(mind); if (mind.Session == null || mind.Session.AttachedEntity == mind.VisitingEntity) return; var owned = mind.OwnedEntity; - if (GetSession(mind) is { } session) - _actor.Attach(owned, session); + GetSession(mind)?.AttachToEntity(owned); if (owned.HasValue) { @@ -218,10 +219,11 @@ public sealed class MindSystem : SharedMindSystem if (mind == null && !Resolve(mindId, ref mind)) return; + base.TransferTo(mindId, entity, ghostCheckOverride, createGhost, mind); + if (entity == mind.OwnedEntity) return; - Dirty(mindId, mind); MindContainerComponent? component = null; var alreadyAttached = false; @@ -245,33 +247,27 @@ public sealed class MindSystem : SharedMindSystem } else if (createGhost) { - // TODO remove this option. - // Transfer-to-null should just detach a mind. - // If people want to create a ghost, that should be done explicitly via some TransferToGhost() method, not - // not implicitly via optional arguments. - var position = Deleted(mind.OwnedEntity) ? _gameTicker.GetObserverSpawnPoint().ToMap(EntityManager, _transform) : Transform(mind.OwnedEntity.Value).MapPosition; entity = Spawn("MobObserver", position); - component = EnsureComp(entity.Value); var ghostComponent = Comp(entity.Value); _ghosts.SetCanReturnToBody(ghostComponent, false); } + var oldComp = mind.OwnedComponent; var oldEntity = mind.OwnedEntity; - if (TryComp(oldEntity, out MindContainerComponent? oldContainer)) + if (oldComp != null && oldEntity != null) { - oldContainer.Mind = null; - mind.OwnedEntity = null; - Entity mindEnt = (mindId, mind); - Entity containerEnt = (oldEntity.Value, oldContainer); - RaiseLocalEvent(oldEntity.Value, new MindRemovedMessage(mindEnt, containerEnt)); - RaiseLocalEvent(mindId, new MindGotRemovedEvent(mindEnt, containerEnt)); - Dirty(oldEntity.Value, oldContainer); + if (oldComp.Mind != null) + _pvsOverride.ClearOverride(oldComp.Mind.Value); + oldComp.Mind = null; + RaiseLocalEvent(oldEntity.Value, new MindRemovedMessage(oldEntity.Value, mind), true); } + SetOwnedEntity(mind, entity, component); + // Don't do the full deletion cleanup if we're transferring to our VisitingEntity if (alreadyAttached) { @@ -285,7 +281,7 @@ public sealed class MindSystem : SharedMindSystem || !TryComp(mind.VisitingEntity!, out GhostComponent? ghostComponent) // visiting entity is not a Ghost || !ghostComponent.CanReturnToBody)) // it is a ghost, but cannot return to body anyway, so it's okay { - RemoveVisitingEntity(mindId, mind); + RemoveVisitingEntity(mind); } // Player is CURRENTLY connected. @@ -293,20 +289,14 @@ public sealed class MindSystem : SharedMindSystem if (session != null && !alreadyAttached && mind.VisitingEntity == null) { _actor.Attach(entity, session, true); - DebugTools.Assert(session.AttachedEntity == entity, $"Failed to attach entity."); Log.Info($"Session {session.Name} transferred to entity {entity}."); } - if (entity != null) + if (mind.OwnedComponent != null) { - component!.Mind = mindId; - mind.OwnedEntity = entity; - mind.OriginalOwnedEntity ??= GetNetEntity(mind.OwnedEntity); - Entity mindEnt = (mindId, mind); - Entity containerEnt = (entity.Value, component); - RaiseLocalEvent(entity.Value, new MindAddedMessage(mindEnt, containerEnt)); - RaiseLocalEvent(mindId, new MindGotAddedEvent(mindEnt, containerEnt)); - Dirty(entity.Value, component); + mind.OwnedComponent.Mind = mindId; + RaiseLocalEvent(mind.OwnedEntity!.Value, new MindAddedMessage(), true); + mind.OriginalOwnedEntity ??= mind.OwnedEntity; } } @@ -323,7 +313,6 @@ public sealed class MindSystem : SharedMindSystem if (mind.UserId == userId) return; - Dirty(mindId, mind); _pvsOverride.ClearOverride(mindId); if (userId != null && !_players.TryGetPlayerData(userId.Value, out _)) { @@ -374,27 +363,4 @@ public sealed class MindSystem : SharedMindSystem if (_players.GetPlayerData(userId.Value).ContentData() is { } data) data.Mind = mindId; } - - public void ControlMob(EntityUid user, EntityUid target) - { - if (TryComp(user, out ActorComponent? actor)) - ControlMob(actor.PlayerSession.UserId, target); - } - - public void ControlMob(NetUserId user, EntityUid target) - { - var (mindId, mind) = GetOrCreateMind(user); - - if (mind.CurrentEntity == target) - return; - - if (mind.OwnedEntity == target) - { - UnVisit(mindId, mind); - return; - } - - MakeSentientCommand.MakeSentient(target, EntityManager); - TransferTo(mindId, target, ghostCheckOverride: true, mind: mind); - } } diff --git a/Content.Server/Mind/Toolshed/MindCommand.cs b/Content.Server/Mind/Toolshed/MindCommand.cs index 917e6fb7f1..b53f9a6a9c 100644 --- a/Content.Server/Mind/Toolshed/MindCommand.cs +++ b/Content.Server/Mind/Toolshed/MindCommand.cs @@ -1,5 +1,5 @@ using Content.Shared.Mind; -using Robust.Shared.Player; +using Robust.Server.Player; using Robust.Shared.Toolshed; using Robust.Shared.Toolshed.Errors; using Robust.Shared.Toolshed.Syntax; @@ -15,7 +15,7 @@ public sealed class MindCommand : ToolshedCommand private SharedMindSystem? _mind; [CommandImplementation("get")] - public MindComponent? Get([PipedArgument] ICommonSession session) + public MindComponent? Get([PipedArgument] IPlayerSession session) { _mind ??= GetSys(); return _mind.TryGetMind(session, out _, out var mind) ? mind : null; @@ -32,7 +32,7 @@ public sealed class MindCommand : ToolshedCommand public EntityUid Control( [CommandInvocationContext] IInvocationContext ctx, [PipedArgument] EntityUid target, - [CommandArgument] ValueRef playerRef) + [CommandArgument] ValueRef playerRef) { _mind ??= GetSys(); diff --git a/Content.Server/Motd/MOTDCommand.cs b/Content.Server/Motd/MOTDCommand.cs index 9e59589b95..a1aa4d2df5 100644 --- a/Content.Server/Motd/MOTDCommand.cs +++ b/Content.Server/Motd/MOTDCommand.cs @@ -1,5 +1,6 @@ using Content.Server.Administration.Managers; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Motd; @@ -13,10 +14,10 @@ internal sealed class MOTDCommand : LocalizedCommands [Dependency] private readonly IAdminManager _adminManager = default!; public override string Command => "motd"; - + public override void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = (IPlayerSession?)shell.Player; if (args.Length < 1 || (player != null && _adminManager is AdminManager aMan && !aMan.CanCommand(player, "set-motd"))) shell.ConsoleHost.ExecuteCommand(shell.Player, "get-motd"); else @@ -25,7 +26,7 @@ internal sealed class MOTDCommand : LocalizedCommands public override CompletionResult GetCompletion(IConsoleShell shell, string[] args) { - var player = shell.Player; + var player = (IPlayerSession?)shell.Player; if (player != null && _adminManager is AdminManager aMan && !aMan.CanCommand(player, "set-motd")) return CompletionResult.Empty; if (args.Length == 1) diff --git a/Content.Server/Motd/MOTDSystem.cs b/Content.Server/Motd/MOTDSystem.cs index 39d780f108..e749fe48f3 100644 --- a/Content.Server/Motd/MOTDSystem.cs +++ b/Content.Server/Motd/MOTDSystem.cs @@ -2,9 +2,9 @@ using Content.Server.Chat.Managers; using Content.Server.GameTicking; using Content.Shared.CCVar; using Content.Shared.Chat; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Configuration; -using Robust.Shared.Player; namespace Content.Server.Motd; @@ -41,7 +41,7 @@ public sealed class MOTDSystem : EntitySystem { if (string.IsNullOrEmpty(_messageOfTheDay)) return; - + var wrappedMessage = Loc.GetString("motd-wrap-message", ("motd", _messageOfTheDay)); _chatManager.ChatMessageToAll(ChatChannel.Server, _messageOfTheDay, wrappedMessage, source: EntityUid.Invalid, hideChat: false, recordReplay: true); } @@ -49,11 +49,11 @@ public sealed class MOTDSystem : EntitySystem /// /// Sends the Message Of The Day, if any, to a specific player. /// - public void TrySendMOTD(ICommonSession player) + public void TrySendMOTD(IPlayerSession player) { if (string.IsNullOrEmpty(_messageOfTheDay)) return; - + var wrappedMessage = Loc.GetString("motd-wrap-message", ("motd", _messageOfTheDay)); _chatManager.ChatMessageToOne(ChatChannel.Server, _messageOfTheDay, wrappedMessage, source: EntityUid.Invalid, hideChat: false, client: player.ConnectedClient); } @@ -68,10 +68,10 @@ public sealed class MOTDSystem : EntitySystem { if (string.IsNullOrEmpty(_messageOfTheDay)) return; - + var wrappedMessage = Loc.GetString("motd-wrap-message", ("motd", _messageOfTheDay)); shell.WriteLine(wrappedMessage); - if (shell.Player is { } player) + if (shell.Player is IPlayerSession player) _chatManager.ChatMessageToOne(ChatChannel.Server, _messageOfTheDay, wrappedMessage, source: EntityUid.Invalid, hideChat: false, client: player.ConnectedClient); } @@ -92,7 +92,7 @@ public sealed class MOTDSystem : EntitySystem { if (val == _messageOfTheDay) return; - + _messageOfTheDay = val; TrySendMOTD(); } diff --git a/Content.Server/Motd/SetMOTDCommand.cs b/Content.Server/Motd/SetMOTDCommand.cs index 9678781c87..f3f52b0670 100644 --- a/Content.Server/Motd/SetMOTDCommand.cs +++ b/Content.Server/Motd/SetMOTDCommand.cs @@ -4,6 +4,7 @@ using Content.Shared.Administration; using Content.Shared.Database; using Content.Shared.CCVar; using Content.Server.Chat.Managers; +using Robust.Server.Player; using Robust.Shared.Configuration; using Robust.Shared.Console; @@ -20,18 +21,18 @@ public sealed class SetMotdCommand : LocalizedCommands [Dependency] private readonly IConfigurationManager _configurationManager = default!; public override string Command => "set-motd"; - + public override void Execute(IConsoleShell shell, string argStr, string[] args) { string motd = ""; - var player = shell.Player; + var player = (IPlayerSession?)shell.Player; if (args.Length > 0) { motd = string.Join(" ", args).Trim(); if (player != null && _chatManager.MessageCharacterLimit(player, motd)) return; // check function prints its own error response } - + _configurationManager.SetCVar(CCVars.MOTD, motd); // A hook in MOTDSystem broadcasts changes to the MOTD to everyone so we don't need to do it here. if (string.IsNullOrEmpty(motd)) { diff --git a/Content.Server/Movement/Systems/LagCompensationSystem.cs b/Content.Server/Movement/Systems/LagCompensationSystem.cs index 0576fe8f25..64965c2fee 100644 --- a/Content.Server/Movement/Systems/LagCompensationSystem.cs +++ b/Content.Server/Movement/Systems/LagCompensationSystem.cs @@ -1,7 +1,7 @@ using Content.Server.Movement.Components; using Robust.Server.Player; using Robust.Shared.Map; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Timing; namespace Content.Server.Movement.Systems; diff --git a/Content.Server/NPC/Commands/NPCCommand.cs b/Content.Server/NPC/Commands/NPCCommand.cs index 7f9e56b8ca..57fe223b66 100644 --- a/Content.Server/NPC/Commands/NPCCommand.cs +++ b/Content.Server/NPC/Commands/NPCCommand.cs @@ -2,6 +2,7 @@ using Content.Server.Administration; using Content.Server.EUI; using Content.Server.NPC.UI; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.NPC.Commands; @@ -14,7 +15,7 @@ public sealed class NPCCommand : IConsoleCommand public string Help => $"{Command}"; public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (shell.Player is not { } playerSession) + if (shell.Player is not IPlayerSession playerSession) { return; } diff --git a/Content.Server/NPC/HTN/HTNSystem.cs b/Content.Server/NPC/HTN/HTNSystem.cs index a7689fbabe..2c1dadb127 100644 --- a/Content.Server/NPC/HTN/HTNSystem.cs +++ b/Content.Server/NPC/HTN/HTNSystem.cs @@ -4,14 +4,17 @@ using System.Threading; using Content.Server.Administration.Managers; using Robust.Shared.CPUJob.JobQueues; using Robust.Shared.CPUJob.JobQueues.Queues; +using Content.Server.NPC.Components; using Content.Server.NPC.HTN.PrimitiveTasks; using Content.Server.NPC.Systems; using Content.Shared.Administration; using Content.Shared.Mobs; using Content.Shared.NPC; +using Content.Shared.NPC; using JetBrains.Annotations; using Robust.Server.GameObjects; -using Robust.Shared.Player; +using Robust.Server.Player; +using Robust.Shared.Players; using Robust.Shared.Prototypes; using Robust.Shared.Utility; @@ -45,7 +48,7 @@ public sealed class HTNSystem : EntitySystem private void OnHTNMessage(RequestHTNMessage msg, EntitySessionEventArgs args) { - if (!_admin.HasAdminFlag(args.SenderSession, AdminFlags.Debug)) + if (!_admin.HasAdminFlag((IPlayerSession) args.SenderSession, AdminFlags.Debug)) { _subscribers.Remove(args.SenderSession); return; diff --git a/Content.Server/NPC/Pathfinding/PathfindingSystem.cs b/Content.Server/NPC/Pathfinding/PathfindingSystem.cs index 1b1f6f5476..bb0eff7b39 100644 --- a/Content.Server/NPC/Pathfinding/PathfindingSystem.cs +++ b/Content.Server/NPC/Pathfinding/PathfindingSystem.cs @@ -13,7 +13,7 @@ using Robust.Shared.Enums; using Robust.Shared.Map; using Robust.Shared.Physics; using Robust.Shared.Physics.Systems; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Random; using Robust.Shared.Threading; using Robust.Shared.Timing; @@ -528,7 +528,7 @@ namespace Content.Server.NPC.Pathfinding private void OnBreadcrumbs(RequestPathfindingDebugMessage msg, EntitySessionEventArgs args) { - var pSession = args.SenderSession; + var pSession = (IPlayerSession) args.SenderSession; if (!_adminManager.HasAdminFlag(pSession, AdminFlags.Debug)) { diff --git a/Content.Server/NPC/Systems/NPCSteeringSystem.cs b/Content.Server/NPC/Systems/NPCSteeringSystem.cs index e5b62acfe8..61b43df6f0 100644 --- a/Content.Server/NPC/Systems/NPCSteeringSystem.cs +++ b/Content.Server/NPC/Systems/NPCSteeringSystem.cs @@ -17,12 +17,14 @@ using Content.Shared.NPC; using Content.Shared.NPC.Events; using Content.Shared.Physics; using Content.Shared.Weapons.Melee; +using Robust.Server.Player; using Robust.Shared.Configuration; using Robust.Shared.Map; using Robust.Shared.Physics; using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Systems; using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Random; using Robust.Shared.Timing; using Robust.Shared.Utility; @@ -145,7 +147,7 @@ public sealed partial class NPCSteeringSystem : SharedNPCSteeringSystem private void OnDebugRequest(RequestNPCSteeringDebugEvent msg, EntitySessionEventArgs args) { - if (!_admin.IsAdmin(args.SenderSession)) + if (!_admin.IsAdmin((IPlayerSession)args.SenderSession)) return; if (msg.Enabled) diff --git a/Content.Server/NodeContainer/EntitySystems/NodeGroupSystem.cs b/Content.Server/NodeContainer/EntitySystems/NodeGroupSystem.cs index 9ee9702c5b..e4bd303150 100644 --- a/Content.Server/NodeContainer/EntitySystems/NodeGroupSystem.cs +++ b/Content.Server/NodeContainer/EntitySystems/NodeGroupSystem.cs @@ -9,7 +9,6 @@ using JetBrains.Annotations; using Robust.Server.Player; using Robust.Shared.Enums; using Robust.Shared.Map; -using Robust.Shared.Player; using Robust.Shared.Utility; namespace Content.Server.NodeContainer.EntitySystems @@ -30,7 +29,7 @@ namespace Content.Server.NodeContainer.EntitySystems private readonly List _visDeletes = new(); private readonly List _visSends = new(); - private readonly HashSet _visPlayers = new(); + private readonly HashSet _visPlayers = new(); private readonly HashSet _toRemake = new(); private readonly HashSet _nodeGroups = new(); private readonly HashSet _toRemove = new(); @@ -75,7 +74,7 @@ namespace Content.Server.NodeContainer.EntitySystems private void HandleEnableMsg(NodeVis.MsgEnable msg, EntitySessionEventArgs args) { - var session = args.SenderSession; + var session = (IPlayerSession) args.SenderSession; if (!_adminManager.HasAdminFlag(session, AdminFlags.Debug)) return; @@ -398,7 +397,7 @@ namespace Content.Server.NodeContainer.EntitySystems } } - private void VisSendFullStateImmediate(ICommonSession player) + private void VisSendFullStateImmediate(IPlayerSession player) { var msg = new NodeVis.MsgData(); diff --git a/Content.Server/Nutrition/Hungry.cs b/Content.Server/Nutrition/Hungry.cs index ae68dcd2fd..c27f302a8d 100644 --- a/Content.Server/Nutrition/Hungry.cs +++ b/Content.Server/Nutrition/Hungry.cs @@ -1,7 +1,9 @@ using Content.Server.Administration; +using Content.Server.Nutrition.Components; using Content.Shared.Administration; using Content.Shared.Nutrition.Components; using Content.Shared.Nutrition.EntitySystems; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Nutrition @@ -17,7 +19,7 @@ namespace Content.Server.Nutrition public void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player == null) { shell.WriteLine("You cannot use this command unless you are a player."); diff --git a/Content.Server/Objectives/Commands/ListObjectivesCommand.cs b/Content.Server/Objectives/Commands/ListObjectivesCommand.cs index 97fc943269..93dec3fa44 100644 --- a/Content.Server/Objectives/Commands/ListObjectivesCommand.cs +++ b/Content.Server/Objectives/Commands/ListObjectivesCommand.cs @@ -18,7 +18,7 @@ namespace Content.Server.Objectives.Commands public override void Execute(IConsoleShell shell, string argStr, string[] args) { - var player = shell.Player; + var player = shell.Player as IPlayerSession; if (player == null || !_players.TryGetSessionByUsername(args[0], out player)) { shell.WriteError(LocalizationManager.GetString("shell-target-player-does-not-exist")); diff --git a/Content.Server/PDA/PdaSystem.cs b/Content.Server/PDA/PdaSystem.cs index 44e2659841..6c506dc3dd 100644 --- a/Content.Server/PDA/PdaSystem.cs +++ b/Content.Server/PDA/PdaSystem.cs @@ -4,6 +4,9 @@ using Content.Server.DeviceNetwork.Components; using Content.Server.Instruments; using Content.Server.Light.EntitySystems; using Content.Server.Light.Events; +using Content.Server.MassMedia.Components; +using Content.Server.MassMedia.Systems; +using Content.Server.Mind; using Content.Server.PDA.Ringer; using Content.Server.Station.Systems; using Content.Server.Store.Components; @@ -13,6 +16,7 @@ using Content.Shared.CartridgeLoader; using Content.Shared.Light.Components; using Content.Shared.PDA; using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Containers; namespace Content.Server.PDA @@ -176,7 +180,7 @@ namespace Content.Server.PDA return; if (HasComp(uid)) - _ringer.ToggleRingerUI(uid, msg.Session); + _ringer.ToggleRingerUI(uid, (IPlayerSession) msg.Session); } private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaShowMusicMessage msg) @@ -185,7 +189,7 @@ namespace Content.Server.PDA return; if (TryComp(uid, out var instrument)) - _instrument.ToggleInstrumentUi(uid, msg.Session, instrument); + _instrument.ToggleInstrumentUi(uid, (IPlayerSession) msg.Session, instrument); } private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaShowUplinkMessage msg) diff --git a/Content.Server/PDA/Ringer/RingerSystem.cs b/Content.Server/PDA/Ringer/RingerSystem.cs index 7494d5e12c..a772e76bc4 100644 --- a/Content.Server/PDA/Ringer/RingerSystem.cs +++ b/Content.Server/PDA/Ringer/RingerSystem.cs @@ -7,6 +7,7 @@ using Content.Shared.PDA.Ringer; using Content.Shared.Popups; using Content.Shared.Store; using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Audio; using Robust.Shared.Network; using Robust.Shared.Player; @@ -181,7 +182,7 @@ namespace Content.Server.PDA.Ringer _ui.SetUiState(bui, new RingerUpdateState(isPlaying, ringer.Ringtone)); } - public bool ToggleRingerUI(EntityUid uid, ICommonSession session) + public bool ToggleRingerUI(EntityUid uid, IPlayerSession session) { if (_ui.TryGetUi(uid, RingerUiKey.Key, out var bui)) _ui.ToggleUi(bui, session); diff --git a/Content.Server/Paper/PaperSystem.cs b/Content.Server/Paper/PaperSystem.cs index 553bcaa0a2..f38013e14d 100644 --- a/Content.Server/Paper/PaperSystem.cs +++ b/Content.Server/Paper/PaperSystem.cs @@ -4,11 +4,15 @@ using Content.Server.Popups; using Content.Server.UserInterface; using Content.Shared.Database; using Content.Shared.Examine; +using Content.Shared.IdentityManagement; using Content.Shared.Interaction; using Content.Shared.Paper; using Content.Shared.Tag; using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Player; +using Robust.Shared.Utility; +using Robust.Shared.Audio; using static Content.Shared.Paper.SharedPaperComponent; namespace Content.Server.Paper @@ -203,7 +207,7 @@ namespace Content.Server.Paper _appearance.SetData(uid, PaperVisuals.Status, status, appearance); } - public void UpdateUserInterface(EntityUid uid, PaperComponent? paperComp = null, ICommonSession? session = null) + public void UpdateUserInterface(EntityUid uid, PaperComponent? paperComp = null, IPlayerSession? session = null) { if (!Resolve(uid, ref paperComp)) return; diff --git a/Content.Server/Parallax/BiomeSystem.cs b/Content.Server/Parallax/BiomeSystem.cs index c9017ac821..a9d78afa86 100644 --- a/Content.Server/Parallax/BiomeSystem.cs +++ b/Content.Server/Parallax/BiomeSystem.cs @@ -282,8 +282,9 @@ public sealed partial class BiomeSystem : SharedBiomeSystem } // Get chunks in range - foreach (var pSession in Filter.GetAllPlayers(_playerManager)) + foreach (var client in Filter.GetAllPlayers(_playerManager)) { + var pSession = (IPlayerSession) client; if (xformQuery.TryGetComponent(pSession.AttachedEntity, out var xform) && _handledEntities.Add(pSession.AttachedEntity.Value) && diff --git a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.ControlBox.cs b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.ControlBox.cs index f200c991d7..20ed276967 100644 --- a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.ControlBox.cs +++ b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.ControlBox.cs @@ -2,10 +2,11 @@ using Content.Server.ParticleAccelerator.Components; using Content.Server.Power.Components; using Content.Shared.Database; using Content.Shared.Singularity.Components; +using Robust.Server.Player; +using Robust.Server.GameObjects; using Robust.Shared.Utility; using System.Diagnostics; using Content.Shared.CCVar; -using Robust.Shared.Player; namespace Content.Server.ParticleAccelerator.EntitySystems; @@ -59,7 +60,7 @@ public sealed partial class ParticleAcceleratorSystem FireEmitter(comp.StarboardEmitter!.Value, strength); } - public void SwitchOn(EntityUid uid, ICommonSession? user = null, ParticleAcceleratorControlBoxComponent? comp = null) + public void SwitchOn(EntityUid uid, IPlayerSession? user = null, ParticleAcceleratorControlBoxComponent? comp = null) { if (!Resolve(uid, ref comp)) return; @@ -82,7 +83,7 @@ public sealed partial class ParticleAcceleratorSystem UpdateUI(uid, comp); } - public void SwitchOff(EntityUid uid, ICommonSession? user = null, ParticleAcceleratorControlBoxComponent? comp = null) + public void SwitchOff(EntityUid uid, IPlayerSession? user = null, ParticleAcceleratorControlBoxComponent? comp = null) { if (!Resolve(uid, ref comp)) return; @@ -130,7 +131,7 @@ public sealed partial class ParticleAcceleratorSystem UpdateUI(uid, comp); } - public void SetStrength(EntityUid uid, ParticleAcceleratorPowerState strength, ICommonSession? user = null, ParticleAcceleratorControlBoxComponent? comp = null) + public void SetStrength(EntityUid uid, ParticleAcceleratorPowerState strength, IPlayerSession? user = null, ParticleAcceleratorControlBoxComponent? comp = null) { if (!Resolve(uid, ref comp)) return; @@ -346,10 +347,10 @@ public sealed partial class ParticleAcceleratorSystem if (msg.Enabled) { if (comp.Assembled) - SwitchOn(uid, msg.Session, comp); + SwitchOn(uid, (IPlayerSession?) msg.Session, comp); } else - SwitchOff(uid, msg.Session, comp); + SwitchOff(uid, (IPlayerSession?) msg.Session, comp); UpdateUI(uid, comp); } @@ -363,7 +364,7 @@ public sealed partial class ParticleAcceleratorSystem if (TryComp(uid, out var apcPower) && !apcPower.Powered) return; - SetStrength(uid, msg.State, msg.Session, comp); + SetStrength(uid, msg.State, (IPlayerSession?) msg.Session, comp); UpdateUI(uid, comp); } @@ -377,7 +378,7 @@ public sealed partial class ParticleAcceleratorSystem if (TryComp(uid, out var apcPower) && !apcPower.Powered) return; - RescanParts(uid, msg.Session, comp); + RescanParts(uid, (IPlayerSession?) msg.Session, comp); UpdateUI(uid, comp); } diff --git a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.Parts.cs b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.Parts.cs index abc68543ff..271d17a0c4 100644 --- a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.Parts.cs +++ b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.Parts.cs @@ -2,9 +2,9 @@ using System.Diagnostics.CodeAnalysis; using System.Numerics; using Content.Server.ParticleAccelerator.Components; using JetBrains.Annotations; +using Robust.Server.Player; using Robust.Shared.Map.Components; using Robust.Shared.Physics.Events; -using Robust.Shared.Player; namespace Content.Server.ParticleAccelerator.EntitySystems; @@ -18,7 +18,7 @@ public sealed partial class ParticleAcceleratorSystem SubscribeLocalEvent(BodyTypeChanged); } - public void RescanParts(EntityUid uid, ICommonSession? user = null, ParticleAcceleratorControlBoxComponent? controller = null) + public void RescanParts(EntityUid uid, IPlayerSession? user = null, ParticleAcceleratorControlBoxComponent? controller = null) { if (!Resolve(uid, ref controller)) return; diff --git a/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingManager.cs b/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingManager.cs index bcc6f211ed..50c64e718c 100644 --- a/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingManager.cs +++ b/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingManager.cs @@ -5,18 +5,18 @@ using System.Threading.Tasks; using Content.Server.Database; using Content.Shared.CCVar; using Content.Shared.Players.PlayTimeTracking; +using Robust.Server.Player; using Robust.Shared.Asynchronous; using Robust.Shared.Collections; using Robust.Shared.Configuration; using Robust.Shared.Exceptions; using Robust.Shared.Network; -using Robust.Shared.Player; using Robust.Shared.Timing; using Robust.Shared.Utility; namespace Content.Server.Players.PlayTimeTracking; -public delegate void CalcPlayTimeTrackersCallback(ICommonSession player, HashSet trackers); +public delegate void CalcPlayTimeTrackersCallback(IPlayerSession player, HashSet trackers); /// /// Tracks play time for players, across all roles. @@ -66,7 +66,7 @@ public sealed class PlayTimeTrackingManager private ISawmill _sawmill = default!; // List of players that need some kind of update (refresh timers or resend). - private ValueList _playersDirty; + private ValueList _playersDirty; // DB auto-saving logic. private TimeSpan _saveInterval; @@ -76,7 +76,7 @@ public sealed class PlayTimeTrackingManager // We must block server shutdown on these to avoid losing data. private readonly List _pendingSaveTasks = new(); - private readonly Dictionary _playTimeData = new(); + private readonly Dictionary _playTimeData = new(); public event CalcPlayTimeTrackersCallback? CalcTrackers; @@ -139,7 +139,7 @@ public sealed class PlayTimeTrackingManager _playersDirty.Clear(); } - private void RefreshSingleTracker(ICommonSession dirty, PlayTimeData data, TimeSpan time) + private void RefreshSingleTracker(IPlayerSession dirty, PlayTimeData data, TimeSpan time) { DebugTools.Assert(data.Initialized); @@ -181,7 +181,7 @@ public sealed class PlayTimeTrackingManager /// so APIs like return up-to-date info. /// /// - public void FlushTracker(ICommonSession player) + public void FlushTracker(IPlayerSession player) { var time = _timing.RealTime; var data = _playTimeData[player]; @@ -201,7 +201,7 @@ public sealed class PlayTimeTrackingManager } } - private void SendPlayTimes(ICommonSession pSession) + private void SendPlayTimes(IPlayerSession pSession) { var roles = GetTrackerTimes(pSession); @@ -228,7 +228,7 @@ public sealed class PlayTimeTrackingManager /// /// Save all modified time trackers for a player to the database. /// - public async void SaveSession(ICommonSession session) + public async void SaveSession(IPlayerSession session) { // This causes all trackers to refresh, ah well. FlushAllTrackers(); @@ -278,7 +278,7 @@ public sealed class PlayTimeTrackingManager _sawmill.Debug($"Saved {log.Count} trackers"); } - private async Task DoSaveSessionAsync(ICommonSession session) + private async Task DoSaveSessionAsync(IPlayerSession session) { var log = new List(); @@ -299,7 +299,7 @@ public sealed class PlayTimeTrackingManager _sawmill.Debug($"Saved {log.Count} trackers for {session.Name}"); } - public async Task LoadData(ICommonSession session, CancellationToken cancel) + public async Task LoadData(IPlayerSession session, CancellationToken cancel) { var data = new PlayTimeData(); _playTimeData.Add(session, data); @@ -318,14 +318,14 @@ public sealed class PlayTimeTrackingManager QueueSendTimers(session); } - public void ClientDisconnected(ICommonSession session) + public void ClientDisconnected(IPlayerSession session) { SaveSession(session); _playTimeData.Remove(session); } - public void AddTimeToTracker(ICommonSession id, string tracker, TimeSpan time) + public void AddTimeToTracker(IPlayerSession id, string tracker, TimeSpan time) { if (!_playTimeData.TryGetValue(id, out var data) || !data.Initialized) throw new InvalidOperationException("Play time info is not yet loaded for this player!"); @@ -341,17 +341,17 @@ public sealed class PlayTimeTrackingManager data.DbTrackersDirty.Add(tracker); } - public void AddTimeToOverallPlaytime(ICommonSession id, TimeSpan time) + public void AddTimeToOverallPlaytime(IPlayerSession id, TimeSpan time) { AddTimeToTracker(id, PlayTimeTrackingShared.TrackerOverall, time); } - public TimeSpan GetOverallPlaytime(ICommonSession id) + public TimeSpan GetOverallPlaytime(IPlayerSession id) { return GetPlayTimeForTracker(id, PlayTimeTrackingShared.TrackerOverall); } - public bool TryGetTrackerTimes(ICommonSession id, [NotNullWhen(true)] out Dictionary? time) + public bool TryGetTrackerTimes(IPlayerSession id, [NotNullWhen(true)] out Dictionary? time) { time = null; @@ -364,7 +364,7 @@ public sealed class PlayTimeTrackingManager return true; } - public Dictionary GetTrackerTimes(ICommonSession id) + public Dictionary GetTrackerTimes(IPlayerSession id) { if (!_playTimeData.TryGetValue(id, out var data) || !data.Initialized) throw new InvalidOperationException("Play time info is not yet loaded for this player!"); @@ -372,7 +372,7 @@ public sealed class PlayTimeTrackingManager return data.TrackerTimes; } - public TimeSpan GetPlayTimeForTracker(ICommonSession id, string tracker) + public TimeSpan GetPlayTimeForTracker(IPlayerSession id, string tracker) { if (!_playTimeData.TryGetValue(id, out var data) || !data.Initialized) throw new InvalidOperationException("Play time info is not yet loaded for this player!"); @@ -383,7 +383,7 @@ public sealed class PlayTimeTrackingManager /// /// Queue for play time trackers to be refreshed on a player, in case the set of active trackers may have changed. /// - public void QueueRefreshTrackers(ICommonSession player) + public void QueueRefreshTrackers(IPlayerSession player) { if (DirtyPlayer(player) is { } data) data.NeedRefreshTackers = true; @@ -392,13 +392,13 @@ public sealed class PlayTimeTrackingManager /// /// Queue for play time information to be sent to a client, for showing in UIs etc. /// - public void QueueSendTimers(ICommonSession player) + public void QueueSendTimers(IPlayerSession player) { if (DirtyPlayer(player) is { } data) data.NeedSendTimers = true; } - private PlayTimeData? DirtyPlayer(ICommonSession player) + private PlayTimeData? DirtyPlayer(IPlayerSession player) { if (!_playTimeData.TryGetValue(player, out var data) || !data.Initialized) return null; diff --git a/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs b/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs index f865b25bac..13d0794dd5 100644 --- a/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs +++ b/Content.Server/Players/PlayTimeTracking/PlayTimeTrackingSystem.cs @@ -14,7 +14,6 @@ using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Configuration; using Robust.Shared.Network; -using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Utility; @@ -56,7 +55,7 @@ public sealed class PlayTimeTrackingSystem : EntitySystem _tracking.CalcTrackers -= CalcTrackers; } - private void CalcTrackers(ICommonSession player, HashSet trackers) + private void CalcTrackers(IPlayerSession player, HashSet trackers) { if (_afk.IsAfk(player)) return; @@ -68,7 +67,7 @@ public sealed class PlayTimeTrackingSystem : EntitySystem trackers.UnionWith(GetTimedRoles(player)); } - private bool IsPlayerAlive(ICommonSession session) + private bool IsPlayerAlive(IPlayerSession session) { var attached = session.AttachedEntity; if (attached == null) @@ -94,7 +93,7 @@ public sealed class PlayTimeTrackingSystem : EntitySystem } } - private IEnumerable GetTimedRoles(ICommonSession session) + private IEnumerable GetTimedRoles(IPlayerSession session) { var contentData = _playerManager.GetPlayerData(session.UserId).ContentData(); @@ -157,7 +156,7 @@ public sealed class PlayTimeTrackingSystem : EntitySystem _tracking.QueueSendTimers(ev.PlayerSession); } - public bool IsAllowed(ICommonSession player, string role) + public bool IsAllowed(IPlayerSession player, string role) { if (!_prototypes.TryIndex(role, out var job) || job.Requirements == null || @@ -169,7 +168,7 @@ public sealed class PlayTimeTrackingSystem : EntitySystem return JobRequirements.TryRequirementsMet(job, playTimes, out _, EntityManager, _prototypes); } - public HashSet GetDisallowedJobs(ICommonSession player) + public HashSet GetDisallowedJobs(IPlayerSession player) { var roles = new HashSet(); if (!_cfg.GetCVar(CCVars.GameRoleTimers)) @@ -231,7 +230,7 @@ public sealed class PlayTimeTrackingSystem : EntitySystem } } - public void PlayerRolesChanged(ICommonSession player) + public void PlayerRolesChanged(IPlayerSession player) { _tracking.QueueRefreshTrackers(player); } diff --git a/Content.Server/Players/PlayerData.cs b/Content.Server/Players/PlayerData.cs new file mode 100644 index 0000000000..b0ca6f3c18 --- /dev/null +++ b/Content.Server/Players/PlayerData.cs @@ -0,0 +1,30 @@ +using Content.Shared.Players; +using Robust.Server.Player; +using Robust.Shared.Players; + +namespace Content.Server.Players +{ + public static class PlayerDataExt + { + /// + /// Gets the correctly cast instance of content player data from an engine player data storage. + /// + public static PlayerData? ContentData(this IPlayerSession session) + { + return session.Data.ContentData(); + } + + public static PlayerData? ContentData(this ICommonSession session) + { + return ((IPlayerSession) session).ContentData(); + } + + /// + /// Gets the mind that is associated with this player. + /// + public static EntityUid? GetMind(this IPlayerSession session) + { + return session.Data.ContentData()?.Mind; + } + } +} diff --git a/Content.Server/Players/PlayerSystem.cs b/Content.Server/Players/PlayerSystem.cs index c79683c338..0c407aa876 100644 --- a/Content.Server/Players/PlayerSystem.cs +++ b/Content.Server/Players/PlayerSystem.cs @@ -1,11 +1,11 @@ using Content.Shared.Players; -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Server.Players; public sealed class PlayerSystem : SharedPlayerSystem { - public override ContentPlayerData? ContentData(ICommonSession? session) + public override PlayerData? ContentData(ICommonSession? session) { return session?.ContentData(); } diff --git a/Content.Server/Pointing/EntitySystems/PointingSystem.cs b/Content.Server/Pointing/EntitySystems/PointingSystem.cs index 6fcdfcf994..b253e32e37 100644 --- a/Content.Server/Pointing/EntitySystems/PointingSystem.cs +++ b/Content.Server/Pointing/EntitySystems/PointingSystem.cs @@ -20,6 +20,7 @@ using Robust.Shared.Enums; using Robust.Shared.Input.Binding; using Robust.Shared.Map; using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Replays; using Robust.Shared.Timing; @@ -169,7 +170,7 @@ namespace Content.Server.Pointing.EntitySystems } // Get players that are in range and whose visibility layer matches the arrow's. - bool ViewerPredicate(ICommonSession playerSession) + bool ViewerPredicate(IPlayerSession playerSession) { if (!_minds.TryGetMind(playerSession, out _, out var mind) || mind.CurrentEntity is not { Valid: true } ent || @@ -181,7 +182,7 @@ namespace Content.Server.Pointing.EntitySystems } var viewers = Filter.Empty() - .AddWhere(session1 => ViewerPredicate(session1)) + .AddWhere(session1 => ViewerPredicate((IPlayerSession) session1)) .Recipients; string selfMessage; diff --git a/Content.Server/Popups/PopupSystem.cs b/Content.Server/Popups/PopupSystem.cs index 61ccaf4423..483d4f3d3f 100644 --- a/Content.Server/Popups/PopupSystem.cs +++ b/Content.Server/Popups/PopupSystem.cs @@ -4,6 +4,7 @@ using Robust.Server.Player; using Robust.Shared.Configuration; using Robust.Shared.Map; using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Server.Popups { diff --git a/Content.Server/Prayer/PrayerSystem.cs b/Content.Server/Prayer/PrayerSystem.cs index e20291cc06..be6ae80bfd 100644 --- a/Content.Server/Prayer/PrayerSystem.cs +++ b/Content.Server/Prayer/PrayerSystem.cs @@ -5,11 +5,12 @@ using Content.Server.Chat.Managers; using Content.Server.Popups; using Content.Shared.Database; using Content.Shared.Popups; +using Robust.Server.Player; +using Robust.Shared.Player; using Content.Shared.Chat; using Content.Shared.Prayer; using Content.Shared.Verbs; using Robust.Server.GameObjects; -using Robust.Shared.Player; namespace Content.Server.Prayer; /// @@ -73,7 +74,7 @@ public sealed class PrayerSystem : EntitySystem /// The IPlayerSession that sent the message /// The main message sent to the player via the chatbox /// The popup to notify the player, also prepended to the messageString - public void SendSubtleMessage(ICommonSession target, ICommonSession source, string messageString, string popupMessage) + public void SendSubtleMessage(IPlayerSession target, IPlayerSession source, string messageString, string popupMessage) { if (target.AttachedEntity == null) return; @@ -95,7 +96,7 @@ public sealed class PrayerSystem : EntitySystem /// You may be wondering, "Why the admin chat, specifically? Nobody even reads it!" /// Exactly. /// - public void Pray(ICommonSession sender, PrayableComponent comp, string message) + public void Pray(IPlayerSession sender, PrayableComponent comp, string message) { if (sender.AttachedEntity == null) return; diff --git a/Content.Server/Preferences/Managers/IServerPreferencesManager.cs b/Content.Server/Preferences/Managers/IServerPreferencesManager.cs index a36b053717..8c06e00ab1 100644 --- a/Content.Server/Preferences/Managers/IServerPreferencesManager.cs +++ b/Content.Server/Preferences/Managers/IServerPreferencesManager.cs @@ -2,8 +2,8 @@ using System.Diagnostics.CodeAnalysis; using System.Threading; using System.Threading.Tasks; using Content.Shared.Preferences; +using Robust.Server.Player; using Robust.Shared.Network; -using Robust.Shared.Player; namespace Content.Server.Preferences.Managers { @@ -11,12 +11,12 @@ namespace Content.Server.Preferences.Managers { void Init(); - Task LoadData(ICommonSession session, CancellationToken cancel); - void OnClientDisconnected(ICommonSession session); + Task LoadData(IPlayerSession session, CancellationToken cancel); + void OnClientDisconnected(IPlayerSession session); bool TryGetCachedPreferences(NetUserId userId, [NotNullWhen(true)] out PlayerPreferences? playerPreferences); PlayerPreferences GetPreferences(NetUserId userId); IEnumerable> GetSelectedProfilesForPlayers(List userIds); - bool HavePreferencesLoaded(ICommonSession session); + bool HavePreferencesLoaded(IPlayerSession session); } } diff --git a/Content.Server/Preferences/Managers/ServerPreferencesManager.cs b/Content.Server/Preferences/Managers/ServerPreferencesManager.cs index a0b5e8ce65..ea04d00e82 100644 --- a/Content.Server/Preferences/Managers/ServerPreferencesManager.cs +++ b/Content.Server/Preferences/Managers/ServerPreferencesManager.cs @@ -8,9 +8,9 @@ using Content.Shared.CCVar; using Content.Shared.Humanoid.Prototypes; using Content.Shared.Preferences; using Content.Shared.Roles; +using Robust.Server.Player; using Robust.Shared.Configuration; using Robust.Shared.Network; -using Robust.Shared.Player; using Robust.Shared.Prototypes; @@ -167,7 +167,7 @@ namespace Content.Server.Preferences.Managers } // Should only be called via UserDbDataManager. - public async Task LoadData(ICommonSession session, CancellationToken cancel) + public async Task LoadData(IPlayerSession session, CancellationToken cancel) { if (!ShouldStorePrefs(session.ConnectedClient.AuthType)) { @@ -207,12 +207,12 @@ namespace Content.Server.Preferences.Managers } } - public void OnClientDisconnected(ICommonSession session) + public void OnClientDisconnected(IPlayerSession session) { _cachedPlayerPrefs.Remove(session.UserId); } - public bool HavePreferencesLoaded(ICommonSession session) + public bool HavePreferencesLoaded(IPlayerSession session) { return _cachedPlayerPrefs.ContainsKey(session.UserId); } diff --git a/Content.Server/Pulling/PullingSystem.cs b/Content.Server/Pulling/PullingSystem.cs index 69bb7c9370..f7ea0aae57 100644 --- a/Content.Server/Pulling/PullingSystem.cs +++ b/Content.Server/Pulling/PullingSystem.cs @@ -4,7 +4,7 @@ using Content.Shared.Pulling.Components; using JetBrains.Annotations; using Robust.Server.GameObjects; using Robust.Shared.Input.Binding; -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Server.Pulling { diff --git a/Content.Server/Radiation/Systems/RadiationSystem.Debug.cs b/Content.Server/Radiation/Systems/RadiationSystem.Debug.cs index 56806d8c9c..97f2e485ca 100644 --- a/Content.Server/Radiation/Systems/RadiationSystem.Debug.cs +++ b/Content.Server/Radiation/Systems/RadiationSystem.Debug.cs @@ -7,7 +7,7 @@ using Content.Shared.Radiation.Systems; using Robust.Shared.Console; using Robust.Shared.Enums; using Robust.Shared.Map.Components; -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Server.Radiation.Systems; diff --git a/Content.Server/Research/Systems/ResearchSystem.Client.cs b/Content.Server/Research/Systems/ResearchSystem.Client.cs index 135ef8fe88..e813f09ff9 100644 --- a/Content.Server/Research/Systems/ResearchSystem.Client.cs +++ b/Content.Server/Research/Systems/ResearchSystem.Client.cs @@ -1,6 +1,7 @@ using System.Diagnostics.CodeAnalysis; using Content.Server.Power.EntitySystems; using Content.Shared.Research.Components; +using Robust.Server.Player; namespace Content.Server.Research.Systems; @@ -45,7 +46,7 @@ public sealed partial class ResearchSystem if (!this.IsPowered(uid, EntityManager)) return; - _uiSystem.TryToggleUi(uid, ResearchClientUiKey.Key, args.Session); + _uiSystem.TryToggleUi(uid, ResearchClientUiKey.Key, (IPlayerSession) args.Session); } #endregion diff --git a/Content.Server/Salvage/SalvageRulerCommand.cs b/Content.Server/Salvage/SalvageRulerCommand.cs index a1fd609741..b0a64508c5 100644 --- a/Content.Server/Salvage/SalvageRulerCommand.cs +++ b/Content.Server/Salvage/SalvageRulerCommand.cs @@ -1,5 +1,6 @@ using Content.Server.Administration; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Map; @@ -25,7 +26,7 @@ sealed class SalvageRulerCommand : IConsoleCommand return; } - if (shell.Player is not { } player) + if (shell.Player is not IPlayerSession player) { shell.WriteError(Loc.GetString("shell-only-players-can-run-this-command")); return; diff --git a/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs b/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs index cc20b71946..0b9148f0fb 100644 --- a/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs +++ b/Content.Server/Sandbox/Commands/ColorNetworkCommand.cs @@ -4,6 +4,7 @@ using Content.Server.Atmos.Piping.EntitySystems; using Content.Server.NodeContainer; using Content.Server.NodeContainer.NodeGroups; using Content.Shared.Administration; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Sandbox.Commands @@ -19,7 +20,7 @@ namespace Content.Server.Sandbox.Commands { var sandboxManager = EntitySystem.Get(); var adminManager = IoCManager.Resolve(); - if (shell.IsClient && (!sandboxManager.IsSandboxEnabled && !adminManager.HasAdminFlag(shell.Player!, AdminFlags.Mapping))) + if (shell.IsClient && (!sandboxManager.IsSandboxEnabled && !adminManager.HasAdminFlag((IPlayerSession)shell.Player!, AdminFlags.Mapping))) { shell.WriteError("You are not currently able to use mapping commands."); } diff --git a/Content.Server/Sandbox/SandboxSystem.cs b/Content.Server/Sandbox/SandboxSystem.cs index 194cf59843..ec9b1a0c3c 100644 --- a/Content.Server/Sandbox/SandboxSystem.cs +++ b/Content.Server/Sandbox/SandboxSystem.cs @@ -13,7 +13,6 @@ using Robust.Server.Console; using Robust.Server.Placement; using Robust.Server.Player; using Robust.Shared.Enums; -using Robust.Shared.Player; namespace Content.Server.Sandbox { diff --git a/Content.Server/SensorMonitoring/SensorMonitoringConsoleComponent.cs b/Content.Server/SensorMonitoring/SensorMonitoringConsoleComponent.cs index 63b4d9daef..cd4f2ea23b 100644 --- a/Content.Server/SensorMonitoring/SensorMonitoringConsoleComponent.cs +++ b/Content.Server/SensorMonitoring/SensorMonitoringConsoleComponent.cs @@ -1,7 +1,7 @@ using Content.Shared.SensorMonitoring; using Robust.Server.Player; using Robust.Shared.Collections; -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Server.SensorMonitoring; diff --git a/Content.Server/SensorMonitoring/SensorMonitoringConsoleSystem.UI.cs b/Content.Server/SensorMonitoring/SensorMonitoringConsoleSystem.UI.cs index 6c0dddeb26..a09badcd59 100644 --- a/Content.Server/SensorMonitoring/SensorMonitoringConsoleSystem.UI.cs +++ b/Content.Server/SensorMonitoring/SensorMonitoringConsoleSystem.UI.cs @@ -1,5 +1,7 @@ using Content.Server.DeviceNetwork.Components; using Content.Shared.SensorMonitoring; +using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Collections; using ConsoleUIState = Content.Shared.SensorMonitoring.SensorMonitoringConsoleBoundInterfaceState; using IncrementalUIState = Content.Shared.SensorMonitoring.SensorMonitoringIncrementalUpdate; @@ -128,7 +130,7 @@ public sealed partial class SensorMonitoringConsoleSystem if (!args.UiKey.Equals(SensorMonitoringConsoleUiKey.Key)) return; - if (args.Session is not { } player) + if (args.Session is not IPlayerSession player) return; component.InitialUIStateSent.Remove(player); diff --git a/Content.Server/ServerUpdates/ServerUpdateManager.cs b/Content.Server/ServerUpdates/ServerUpdateManager.cs index f4e54984e9..769c5d58d7 100644 --- a/Content.Server/ServerUpdates/ServerUpdateManager.cs +++ b/Content.Server/ServerUpdates/ServerUpdateManager.cs @@ -6,7 +6,6 @@ using Robust.Server.Player; using Robust.Server.ServerStatus; using Robust.Shared.Configuration; using Robust.Shared.Enums; -using Robust.Shared.Player; using Robust.Shared.Timing; namespace Content.Server.ServerUpdates; diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs index 3ef3d97a21..1a1debc9e3 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs @@ -20,6 +20,7 @@ using Content.Shared.Tag; using Content.Shared.Tiles; using Robust.Server.GameObjects; using Robust.Server.Maps; +using Robust.Server.Player; using Robust.Shared.Configuration; using Robust.Shared.Map; using Robust.Shared.Map.Components; @@ -139,7 +140,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem /// private void OnShuttleRequestPosition(EmergencyShuttleRequestPositionMessage msg, EntitySessionEventArgs args) { - if (!_admin.IsAdmin(args.SenderSession)) + if (!_admin.IsAdmin((IPlayerSession) args.SenderSession)) return; var player = args.SenderSession.AttachedEntity; diff --git a/Content.Server/Silicons/Borgs/BorgSystem.Modules.cs b/Content.Server/Silicons/Borgs/BorgSystem.Modules.cs index c080420266..31d826087d 100644 --- a/Content.Server/Silicons/Borgs/BorgSystem.Modules.cs +++ b/Content.Server/Silicons/Borgs/BorgSystem.Modules.cs @@ -229,7 +229,7 @@ public sealed partial class BorgSystem if (!TryComp(chassis, out var hands)) return; - if (TerminatingOrDeleted(uid)) + if (LifeStage(uid) >= EntityLifeStage.Terminating) { foreach (var (hand, item) in component.ProvidedItems) { diff --git a/Content.Server/Silicons/Borgs/BorgSystem.cs b/Content.Server/Silicons/Borgs/BorgSystem.cs index 883cb3b3d8..611dfa6ea2 100644 --- a/Content.Server/Silicons/Borgs/BorgSystem.cs +++ b/Content.Server/Silicons/Borgs/BorgSystem.cs @@ -21,7 +21,7 @@ using Content.Shared.Throwing; using Content.Shared.Wires; using Robust.Server.GameObjects; using Robust.Shared.Containers; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Random; namespace Content.Server.Silicons.Borgs; diff --git a/Content.Server/Silicons/Laws/SiliconLawSystem.cs b/Content.Server/Silicons/Laws/SiliconLawSystem.cs index 41ddd9651b..1d5c2e35e8 100644 --- a/Content.Server/Silicons/Laws/SiliconLawSystem.cs +++ b/Content.Server/Silicons/Laws/SiliconLawSystem.cs @@ -18,6 +18,7 @@ using Content.Shared.Silicons.Laws.Components; using Content.Shared.Stunnable; using Content.Shared.Wires; using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Prototypes; using Robust.Shared.Toolshed; @@ -93,7 +94,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem HashSet? radioChannels = intrinsicRadio?.Channels; var state = new SiliconLawBuiState(GetLaws(uid), radioChannels); - _userInterface.TrySetUiState(args.Entity, SiliconLawsUiKey.Key, state, args.Session); + _userInterface.TrySetUiState(args.Entity, SiliconLawsUiKey.Key, state, (IPlayerSession) args.Session); } private void OnPlayerSpawnComplete(EntityUid uid, SiliconLawBoundComponent component, PlayerSpawnCompleteEvent args) @@ -169,7 +170,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem if (component.AntagonistRole == null) return; - _roles.MindTryRemoveRole(args.Mind); + _roles.MindTryRemoveRole(args.OldMindId); } private void EnsureEmaggedRole(EntityUid uid, EmagSiliconLawComponent component) diff --git a/Content.Server/Station/Systems/StationJobsSystem.cs b/Content.Server/Station/Systems/StationJobsSystem.cs index eeaace03b2..2709bc2072 100644 --- a/Content.Server/Station/Systems/StationJobsSystem.cs +++ b/Content.Server/Station/Systems/StationJobsSystem.cs @@ -41,7 +41,7 @@ public sealed partial class StationJobsSystem : EntitySystem if (_availableJobsDirty) { _cachedAvailableJobs = GenerateJobsAvailableEvent(); - RaiseNetworkEvent(_cachedAvailableJobs, Filter.Empty().AddPlayers(_playerManager.Sessions)); + RaiseNetworkEvent(_cachedAvailableJobs, Filter.Empty().AddPlayers(_playerManager.ServerSessions)); _availableJobsDirty = false; } } diff --git a/Content.Server/Storage/EntitySystems/StorageSystem.cs b/Content.Server/Storage/EntitySystems/StorageSystem.cs index 8b4ae1c76f..3430449957 100644 --- a/Content.Server/Storage/EntitySystems/StorageSystem.cs +++ b/Content.Server/Storage/EntitySystems/StorageSystem.cs @@ -9,6 +9,7 @@ using Content.Shared.Storage.EntitySystems; using Content.Shared.Timing; using Content.Shared.Verbs; using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Map; using Robust.Shared.Player; using Robust.Shared.Prototypes; @@ -134,7 +135,7 @@ public sealed partial class StorageSystem : SharedStorageSystem /// If the user has nested-UIs open (e.g., PDA UI open when pda is in a backpack), close them. /// /// - public void CloseNestedInterfaces(EntityUid uid, ICommonSession session, StorageComponent? storageComp = null) + public void CloseNestedInterfaces(EntityUid uid, IPlayerSession session, StorageComponent? storageComp = null) { if (!Resolve(uid, ref storageComp)) return; diff --git a/Content.Server/Tabletop/TabletopSession.cs b/Content.Server/Tabletop/TabletopSession.cs index 5e7c6ac02e..d94b4fd657 100644 --- a/Content.Server/Tabletop/TabletopSession.cs +++ b/Content.Server/Tabletop/TabletopSession.cs @@ -1,6 +1,6 @@ using System.Numerics; +using Robust.Server.Player; using Robust.Shared.Map; -using Robust.Shared.Player; namespace Content.Server.Tabletop { @@ -17,7 +17,7 @@ namespace Content.Server.Tabletop /// /// The set of players currently playing this tabletop game. /// - public readonly Dictionary Players = new(); + public readonly Dictionary Players = new(); /// /// All entities bound to this session. If you create an entity for this session, you have to add it here. diff --git a/Content.Server/Tabletop/TabletopSystem.Session.cs b/Content.Server/Tabletop/TabletopSystem.Session.cs index 8f1bc7005d..e9dea0c66a 100644 --- a/Content.Server/Tabletop/TabletopSystem.Session.cs +++ b/Content.Server/Tabletop/TabletopSystem.Session.cs @@ -1,7 +1,7 @@ using System.Numerics; using Content.Server.Tabletop.Components; using Content.Shared.Tabletop.Events; -using Robust.Shared.Player; +using Robust.Server.Player; using Robust.Shared.Utility; namespace Content.Server.Tabletop @@ -66,7 +66,7 @@ namespace Content.Server.Tabletop /// /// The player session in question. /// The UID of the tabletop game entity. - public void OpenSessionFor(ICommonSession player, EntityUid uid) + public void OpenSessionFor(IPlayerSession player, EntityUid uid) { if (!EntityManager.TryGetComponent(uid, out TabletopGameComponent? tabletop) || player.AttachedEntity is not {Valid: true} attachedEntity) return; @@ -98,7 +98,7 @@ namespace Content.Server.Tabletop /// The player in question. /// The UID of the tabletop game entity. /// Whether to remove the from the player's attached entity. - public void CloseSessionFor(ICommonSession player, EntityUid uid, bool removeGamerComponent = true) + public void CloseSessionFor(IPlayerSession player, EntityUid uid, bool removeGamerComponent = true) { if (!EntityManager.TryGetComponent(uid, out TabletopGameComponent? tabletop) || tabletop.Session is not { } session) return; @@ -129,7 +129,7 @@ namespace Content.Server.Tabletop /// The player in question. /// An offset from the tabletop position for the camera. Zero by default. /// The UID of the camera entity. - private EntityUid CreateCamera(TabletopGameComponent tabletop, ICommonSession player, Vector2 offset = default) + private EntityUid CreateCamera(TabletopGameComponent tabletop, IPlayerSession player, Vector2 offset = default) { DebugTools.AssertNotNull(tabletop.Session); diff --git a/Content.Server/Tabletop/TabletopSystem.cs b/Content.Server/Tabletop/TabletopSystem.cs index b81331d62e..2e271080d0 100644 --- a/Content.Server/Tabletop/TabletopSystem.cs +++ b/Content.Server/Tabletop/TabletopSystem.cs @@ -9,6 +9,7 @@ using Content.Shared.Tabletop.Events; using Content.Shared.Verbs; using JetBrains.Annotations; using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Enums; using Robust.Shared.Map; using Robust.Shared.Utility; @@ -41,7 +42,7 @@ namespace Content.Server.Tabletop private void OnTabletopRequestTakeOut(TabletopRequestTakeOut msg, EntitySessionEventArgs args) { - if (args.SenderSession is not { } playerSession) + if (args.SenderSession is not IPlayerSession playerSession) return; var table = GetEntity(msg.TableUid); @@ -104,7 +105,7 @@ namespace Content.Server.Tabletop protected override void OnTabletopMove(TabletopMoveEvent msg, EntitySessionEventArgs args) { - if (args.SenderSession is not { } playerSession) + if (args.SenderSession is not IPlayerSession playerSession) return; if (!TryComp(GetEntity(msg.TableUid), out TabletopGameComponent? tabletop) || tabletop.Session is not { } session) @@ -154,7 +155,7 @@ namespace Content.Server.Tabletop private void OnStopPlaying(TabletopStopPlayingEvent msg, EntitySessionEventArgs args) { - CloseSessionFor(args.SenderSession, GetEntity(msg.TableUid)); + CloseSessionFor((IPlayerSession)args.SenderSession, GetEntity(msg.TableUid)); } private void OnPlayerDetached(EntityUid uid, TabletopGamerComponent component, PlayerDetachedEvent args) diff --git a/Content.Server/Toolshed/Commands/AdminDebug/ACmdCommand.cs b/Content.Server/Toolshed/Commands/AdminDebug/ACmdCommand.cs index f113e49655..d2b3cc261c 100644 --- a/Content.Server/Toolshed/Commands/AdminDebug/ACmdCommand.cs +++ b/Content.Server/Toolshed/Commands/AdminDebug/ACmdCommand.cs @@ -1,7 +1,7 @@ using Content.Server.Administration; using Content.Server.Administration.Managers; using Content.Shared.Administration; -using Robust.Shared.Player; +using Robust.Server.Player; using Robust.Shared.Toolshed; using Robust.Shared.Toolshed.Syntax; @@ -25,7 +25,7 @@ public sealed class ACmdCommand : ToolshedCommand public bool CanInvoke( [CommandInvocationContext] IInvocationContext ctx, [PipedArgument] CommandSpec command, - [CommandArgument] ValueRef player + [CommandArgument] ValueRef player ) { // Deliberately discard the error. diff --git a/Content.Server/Toolshed/Commands/VisualizeCommand.cs b/Content.Server/Toolshed/Commands/VisualizeCommand.cs index 2225bfaf44..4ef08a91bf 100644 --- a/Content.Server/Toolshed/Commands/VisualizeCommand.cs +++ b/Content.Server/Toolshed/Commands/VisualizeCommand.cs @@ -4,6 +4,7 @@ using Content.Server.EUI; using Content.Shared.Administration; using Content.Shared.Bql; using Content.Shared.Eui; +using Robust.Server.Player; using Robust.Shared.Toolshed; using Robust.Shared.Toolshed.Errors; @@ -29,7 +30,7 @@ public sealed class VisualizeCommand : ToolshedCommand var ui = new ToolshedVisualizeEui( input.Select(e => (EntName(e), EntityManager.GetNetEntity(e))).ToArray() ); - _euiManager.OpenEui(ui, ctx.Session); + _euiManager.OpenEui(ui, (IPlayerSession) ctx.Session); _euiManager.QueueStateUpdate(ui); } } diff --git a/Content.Server/Traitor/Uplink/Commands/AddUplinkCommand.cs b/Content.Server/Traitor/Uplink/Commands/AddUplinkCommand.cs index fd656a9f71..1feab11b99 100644 --- a/Content.Server/Traitor/Uplink/Commands/AddUplinkCommand.cs +++ b/Content.Server/Traitor/Uplink/Commands/AddUplinkCommand.cs @@ -5,7 +5,6 @@ using Content.Shared.FixedPoint; using Robust.Server.Player; using Robust.Shared.Configuration; using Robust.Shared.Console; -using Robust.Shared.Player; namespace Content.Server.Traitor.Uplink.Commands { @@ -37,7 +36,7 @@ namespace Content.Server.Traitor.Uplink.Commands return; } - ICommonSession? session; + IPlayerSession? session; if (args.Length > 0) { // Get player entity @@ -49,7 +48,7 @@ namespace Content.Server.Traitor.Uplink.Commands } else { - session = shell.Player; + session = (IPlayerSession?) shell.Player; } if (session?.AttachedEntity is not { } user) diff --git a/Content.Server/UserInterface/ActivatableUIComponent.cs b/Content.Server/UserInterface/ActivatableUIComponent.cs index 34f9c0f397..bb020608e2 100644 --- a/Content.Server/UserInterface/ActivatableUIComponent.cs +++ b/Content.Server/UserInterface/ActivatableUIComponent.cs @@ -1,4 +1,4 @@ -using Robust.Shared.Player; +using Robust.Server.Player; using Robust.Shared.Reflection; using Robust.Shared.Serialization; @@ -65,7 +65,7 @@ namespace Content.Server.UserInterface /// NOTE: DO NOT DIRECTLY SET, USE ActivatableUISystem.SetCurrentSingleUser /// [ViewVariables] - public ICommonSession? CurrentSingleUser; + public IPlayerSession? CurrentSingleUser; void ISerializationHooks.AfterDeserialization() { diff --git a/Content.Server/UserInterface/ActivatableUISystem.cs b/Content.Server/UserInterface/ActivatableUISystem.cs index adeeed7c19..59086415b4 100644 --- a/Content.Server/UserInterface/ActivatableUISystem.cs +++ b/Content.Server/UserInterface/ActivatableUISystem.cs @@ -8,7 +8,7 @@ using Content.Shared.Interaction.Events; using Content.Shared.UserInterface; using Content.Shared.Verbs; using Robust.Server.GameObjects; -using Robust.Shared.Player; +using Robust.Server.Player; namespace Content.Server.UserInterface; @@ -173,7 +173,7 @@ public sealed partial class ActivatableUISystem : EntitySystem return true; } - public void SetCurrentSingleUser(EntityUid uid, ICommonSession? v, ActivatableUIComponent? aui = null) + public void SetCurrentSingleUser(EntityUid uid, IPlayerSession? v, ActivatableUIComponent? aui = null) { if (!Resolve(uid, ref aui)) return; @@ -231,9 +231,9 @@ public sealed class UserOpenActivatableUIAttemptEvent : CancellableEntityEventAr public sealed class AfterActivatableUIOpenEvent : EntityEventArgs { public EntityUid User { get; } - public readonly ICommonSession Session; + public readonly IPlayerSession Session; - public AfterActivatableUIOpenEvent(EntityUid who, ICommonSession session) + public AfterActivatableUIOpenEvent(EntityUid who, IPlayerSession session) { User = who; Session = session; diff --git a/Content.Server/UserInterface/StatValuesCommand.cs b/Content.Server/UserInterface/StatValuesCommand.cs index fe2ee380fe..b13b596323 100644 --- a/Content.Server/UserInterface/StatValuesCommand.cs +++ b/Content.Server/UserInterface/StatValuesCommand.cs @@ -8,6 +8,7 @@ using Content.Shared.Materials; using Content.Shared.Research.Prototypes; using Content.Shared.UserInterface; using Content.Shared.Weapons.Melee; +using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Prototypes; @@ -26,7 +27,7 @@ public sealed class StatValuesCommand : IConsoleCommand public string Help => $"{Command} "; public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (shell.Player is not { } pSession) + if (shell.Player is not IPlayerSession pSession) { shell.WriteError(Loc.GetString("stat-values-server")); return; diff --git a/Content.Server/Verbs/VerbSystem.cs b/Content.Server/Verbs/VerbSystem.cs index e304c6b4af..6d12b08e86 100644 --- a/Content.Server/Verbs/VerbSystem.cs +++ b/Content.Server/Verbs/VerbSystem.cs @@ -6,6 +6,7 @@ using Content.Shared.Administration.Logs; using Content.Shared.Database; using Content.Shared.Hands.Components; using Content.Shared.Verbs; +using Robust.Server.Player; namespace Content.Server.Verbs { @@ -24,7 +25,7 @@ namespace Content.Server.Verbs private void HandleVerbRequest(RequestServerVerbsEvent args, EntitySessionEventArgs eventArgs) { - var player = eventArgs.SenderSession; + var player = (IPlayerSession) eventArgs.SenderSession; if (!EntityManager.EntityExists(GetEntity(args.EntityUid))) { @@ -42,7 +43,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 force = args.AdminRequest && eventArgs.SenderSession is { } playerSession && + var force = args.AdminRequest && eventArgs.SenderSession is IPlayerSession playerSession && _adminMgr.HasAdminFlag(playerSession, AdminFlags.Admin); List verbTypes = new(); diff --git a/Content.Server/Voting/IVoteHandle.cs b/Content.Server/Voting/IVoteHandle.cs index 869f2017d7..13f64e6ef8 100644 --- a/Content.Server/Voting/IVoteHandle.cs +++ b/Content.Server/Voting/IVoteHandle.cs @@ -1,5 +1,5 @@ using Content.Server.Voting.Managers; -using Robust.Shared.Player; +using Robust.Server.Player; namespace Content.Server.Voting { @@ -75,7 +75,7 @@ namespace Content.Server.Voting /// /// is not a valid option ID. /// - void CastVote(ICommonSession session, int? optionId); + void CastVote(IPlayerSession session, int? optionId); /// /// Cancel this vote. diff --git a/Content.Server/Voting/Managers/IVoteManager.cs b/Content.Server/Voting/Managers/IVoteManager.cs index d95fac9ae9..6a92e70fff 100644 --- a/Content.Server/Voting/Managers/IVoteManager.cs +++ b/Content.Server/Voting/Managers/IVoteManager.cs @@ -1,6 +1,6 @@ using System.Diagnostics.CodeAnalysis; using Content.Shared.Voting; -using Robust.Shared.Player; +using Robust.Server.Player; namespace Content.Server.Voting.Managers { @@ -41,7 +41,7 @@ namespace Content.Server.Voting.Managers /// True if can start votes right now, /// and if provided if they can start votes of type . /// - bool CanCallVote(ICommonSession initiator, StandardVoteType? voteType = null); + bool CanCallVote(IPlayerSession initiator, StandardVoteType? voteType = null); /// /// Initiate a standard vote such as restart round, that can be initiated by players. @@ -51,7 +51,7 @@ namespace Content.Server.Voting.Managers /// If null it is assumed to be an automatic vote by the server. /// /// The type of standard vote to make. - void CreateStandardVote(ICommonSession? initiator, StandardVoteType voteType); + void CreateStandardVote(IPlayerSession? initiator, StandardVoteType voteType); /// /// Create a non-standard vote with special parameters. diff --git a/Content.Server/Voting/Managers/VoteManager.DefaultVotes.cs b/Content.Server/Voting/Managers/VoteManager.DefaultVotes.cs index e1bffa769d..55e88e2a8c 100644 --- a/Content.Server/Voting/Managers/VoteManager.DefaultVotes.cs +++ b/Content.Server/Voting/Managers/VoteManager.DefaultVotes.cs @@ -6,8 +6,8 @@ using Content.Server.RoundEnd; using Content.Shared.CCVar; using Content.Shared.Database; using Content.Shared.Voting; +using Robust.Server.Player; using Robust.Shared.Configuration; -using Robust.Shared.Player; using Robust.Shared.Random; namespace Content.Server.Voting.Managers @@ -21,7 +21,7 @@ namespace Content.Server.Voting.Managers {StandardVoteType.Map, CCVars.VoteMapEnabled}, }; - public void CreateStandardVote(ICommonSession? initiator, StandardVoteType voteType) + public void CreateStandardVote(IPlayerSession? initiator, StandardVoteType voteType) { if (initiator != null) _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"{initiator} initiated a {voteType.ToString()} vote"); @@ -47,7 +47,7 @@ namespace Content.Server.Voting.Managers TimeoutStandardVote(voteType); } - private void CreateRestartVote(ICommonSession? initiator) + private void CreateRestartVote(IPlayerSession? initiator) { var alone = _playerManager.PlayerCount == 1 && initiator != null; var options = new VoteOptions @@ -100,7 +100,7 @@ namespace Content.Server.Voting.Managers vote.CastVote(initiator, 0); } - foreach (var player in _playerManager.Sessions) + foreach (var player in _playerManager.ServerSessions) { if (player != initiator) { @@ -110,7 +110,7 @@ namespace Content.Server.Voting.Managers } } - private void CreatePresetVote(ICommonSession? initiator) + private void CreatePresetVote(IPlayerSession? initiator) { var presets = GetGamePresets(); @@ -156,7 +156,7 @@ namespace Content.Server.Voting.Managers }; } - private void CreateMapVote(ICommonSession? initiator) + private void CreateMapVote(IPlayerSession? initiator) { var maps = _gameMapManager.CurrentlyEligibleMaps().ToDictionary(map => map, map => map.MapName); diff --git a/Content.Server/Voting/Managers/VoteManager.cs b/Content.Server/Voting/Managers/VoteManager.cs index 90089afb54..98ad8d8341 100644 --- a/Content.Server/Voting/Managers/VoteManager.cs +++ b/Content.Server/Voting/Managers/VoteManager.cs @@ -16,7 +16,6 @@ using Robust.Server.Player; using Robust.Shared.Configuration; using Robust.Shared.Enums; using Robust.Shared.Network; -using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Random; using Robust.Shared.Timing; @@ -46,7 +45,7 @@ namespace Content.Server.Voting.Managers private readonly Dictionary _standardVoteTimeout = new(); private readonly Dictionary _voteTimeout = new(); - private readonly HashSet _playerCanCallVoteDirty = new(); + private readonly HashSet _playerCanCallVoteDirty = new(); private readonly StandardVoteType[] _standardVoteTypeValues = Enum.GetValues(); public void Initialize() @@ -107,7 +106,7 @@ namespace Content.Server.Voting.Managers } } - private void CastVote(VoteReg v, ICommonSession player, int? option) + private void CastVote(VoteReg v, IPlayerSession player, int? option) { if (!IsValidOption(v, option)) throw new ArgumentOutOfRangeException(nameof(option), "Invalid vote option ID"); @@ -229,7 +228,7 @@ namespace Content.Server.Voting.Managers private void SendUpdates(VoteReg v) { - foreach (var player in _playerManager.Sessions) + foreach (var player in _playerManager.ServerSessions) { SendSingleUpdate(v, player); } @@ -238,7 +237,7 @@ namespace Content.Server.Voting.Managers v.Dirty = false; } - private void SendSingleUpdate(VoteReg v, ICommonSession player) + private void SendSingleUpdate(VoteReg v, IPlayerSession player) { var msg = new MsgVoteData(); @@ -278,10 +277,10 @@ namespace Content.Server.Voting.Managers private void DirtyCanCallVoteAll() { - _playerCanCallVoteDirty.UnionWith(_playerManager.Sessions); + _playerCanCallVoteDirty.UnionWith(_playerManager.ServerSessions); } - private void SendUpdateCanCallVote(ICommonSession player) + private void SendUpdateCanCallVote(IPlayerSession player) { var msg = new MsgVoteCanCall(); msg.CanCall = CanCallVote(player, null, out var isAdmin, out var timeSpan); @@ -307,7 +306,7 @@ namespace Content.Server.Voting.Managers } private bool CanCallVote( - ICommonSession initiator, + IPlayerSession initiator, StandardVoteType? voteType, out bool isAdmin, out TimeSpan timeSpan) @@ -354,7 +353,7 @@ namespace Content.Server.Voting.Managers return !_voteTimeout.TryGetValue(initiator.UserId, out timeSpan); } - public bool CanCallVote(ICommonSession initiator, StandardVoteType? voteType = null) + public bool CanCallVote(IPlayerSession initiator, StandardVoteType? voteType = null) { return CanCallVote(initiator, voteType, out _, out _); } @@ -407,14 +406,14 @@ namespace Content.Server.Voting.Managers return false; } - private void DirtyCanCallVote(ICommonSession player) + private void DirtyCanCallVote(IPlayerSession player) { _playerCanCallVoteDirty.Add(player); } #region Preset Votes - private void WirePresetVoteInitiator(VoteOptions options, ICommonSession? player) + private void WirePresetVoteInitiator(VoteOptions options, IPlayerSession? player) { if (player != null) { @@ -433,13 +432,13 @@ namespace Content.Server.Voting.Managers private sealed class VoteReg { public readonly int Id; - public readonly Dictionary CastVotes = new(); + public readonly Dictionary CastVotes = new(); public readonly VoteEntry[] Entries; public readonly string Title; public readonly string InitiatorText; public readonly TimeSpan StartTime; public readonly TimeSpan EndTime; - public readonly HashSet VotesDirty = new(); + public readonly HashSet VotesDirty = new(); public bool Cancelled; public bool Finished; @@ -447,10 +446,10 @@ namespace Content.Server.Voting.Managers public VoteFinishedEventHandler? OnFinished; public VoteCancelledEventHandler? OnCancelled; - public ICommonSession? Initiator { get; } + public IPlayerSession? Initiator { get; } public VoteReg(int id, VoteEntry[] entries, string title, string initiatorText, - ICommonSession? initiator, TimeSpan start, TimeSpan end) + IPlayerSession? initiator, TimeSpan start, TimeSpan end) { Id = id; Entries = entries; @@ -518,7 +517,7 @@ namespace Content.Server.Voting.Managers return _mgr.IsValidOption(_reg, optionId); } - public void CastVote(ICommonSession session, int? optionId) + public void CastVote(IPlayerSession session, int? optionId) { _mgr.CastVote(_reg, session, optionId); } diff --git a/Content.Server/Voting/VoteCommands.cs b/Content.Server/Voting/VoteCommands.cs index 498c9d0494..cb296a7d58 100644 --- a/Content.Server/Voting/VoteCommands.cs +++ b/Content.Server/Voting/VoteCommands.cs @@ -6,6 +6,7 @@ using Content.Server.Voting.Managers; using Content.Shared.Administration; using Content.Shared.Database; using Content.Shared.Voting; +using Robust.Server.Player; using Robust.Shared.Console; namespace Content.Server.Voting @@ -35,14 +36,14 @@ namespace Content.Server.Voting var mgr = IoCManager.Resolve(); - if (shell.Player != null && !mgr.CanCallVote(shell.Player, type)) + if (shell.Player != null && !mgr.CanCallVote((IPlayerSession) shell.Player, type)) { _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"{shell.Player} failed to start {type.ToString()} vote"); shell.WriteError(Loc.GetString("cmd-createvote-cannot-call-vote-now")); return; } - mgr.CreateStandardVote(shell.Player, type); + mgr.CreateStandardVote((IPlayerSession?) shell.Player, type); } public CompletionResult GetCompletion(IConsoleShell shell, string[] args) @@ -91,7 +92,7 @@ namespace Content.Server.Voting options.Options.Add((args[i], i)); } - options.SetInitiatorOrServer(shell.Player); + options.SetInitiatorOrServer((IPlayerSession?) shell.Player); if (shell.Player != null) _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"{shell.Player} initiated a custom vote: {options.Title} - {string.Join("; ", options.Options.Select(x => x.text))}"); @@ -186,7 +187,7 @@ namespace Content.Server.Voting return; } - vote.CastVote(shell.Player!, optionN); + vote.CastVote((IPlayerSession) shell.Player!, optionN); } } diff --git a/Content.Server/Voting/VoteOptions.cs b/Content.Server/Voting/VoteOptions.cs index 5475d10d32..6e6d0465ed 100644 --- a/Content.Server/Voting/VoteOptions.cs +++ b/Content.Server/Voting/VoteOptions.cs @@ -1,4 +1,4 @@ -using Robust.Shared.Player; +using Robust.Server.Player; namespace Content.Server.Voting @@ -16,7 +16,7 @@ namespace Content.Server.Voting /// /// The player that started the vote. Used to keep track of player cooldowns to avoid vote spam. /// - public ICommonSession? InitiatorPlayer { get; set; } + public IPlayerSession? InitiatorPlayer { get; set; } /// /// The shown title of the vote. @@ -43,13 +43,13 @@ namespace Content.Server.Voting /// Sets and /// by setting the latter to the player's name. /// - public void SetInitiator(ICommonSession player) + public void SetInitiator(IPlayerSession player) { InitiatorPlayer = player; InitiatorText = player.Name; } - public void SetInitiatorOrServer(ICommonSession? player) + public void SetInitiatorOrServer(IPlayerSession? player) { if (player != null) { diff --git a/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs b/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs index 3d9c3e8219..1b6b2ebef1 100644 --- a/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs +++ b/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs @@ -24,9 +24,11 @@ using Content.Shared.StatusEffect; using Content.Shared.Tag; using Content.Shared.Weapons.Melee; using Content.Shared.Weapons.Melee.Events; +using Robust.Server.Player; using Robust.Shared.Audio; using Robust.Shared.Map; using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Random; namespace Content.Server.Weapons.Melee; @@ -172,7 +174,7 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem EntityCoordinates targetCoordinates; Angle targetLocalAngle; - if (session is { } pSession) + if (session is IPlayerSession pSession) { (targetCoordinates, targetLocalAngle) = _lag.GetCoordinatesAngle(target, pSession); } diff --git a/Content.Server/Wires/WiresSystem.cs b/Content.Server/Wires/WiresSystem.cs index b6452efa8a..e75ad0a9ef 100644 --- a/Content.Server/Wires/WiresSystem.cs +++ b/Content.Server/Wires/WiresSystem.cs @@ -16,7 +16,7 @@ using Content.Shared.Tools; using Content.Shared.Tools.Components; using Content.Shared.Wires; using Robust.Server.GameObjects; -using Robust.Shared.Player; +using Robust.Server.Player; using Robust.Shared.Prototypes; using Robust.Shared.Random; using SharedToolSystem = Content.Shared.Tools.Systems.SharedToolSystem; @@ -616,7 +616,7 @@ public sealed class WiresSystem : SharedWiresSystem wires.WireSeed), ui: ui); } - public void OpenUserInterface(EntityUid uid, ICommonSession player) + public void OpenUserInterface(EntityUid uid, IPlayerSession player) { if (_uiSystem.TryGetUi(uid, WiresUiKey.Key, out var ui)) _uiSystem.OpenUi(ui, player); diff --git a/Content.Server/Xenoarchaeology/Equipment/Systems/ArtifactAnalyzerSystem.cs b/Content.Server/Xenoarchaeology/Equipment/Systems/ArtifactAnalyzerSystem.cs index 9200928d66..49036fb19d 100644 --- a/Content.Server/Xenoarchaeology/Equipment/Systems/ArtifactAnalyzerSystem.cs +++ b/Content.Server/Xenoarchaeology/Equipment/Systems/ArtifactAnalyzerSystem.cs @@ -17,6 +17,7 @@ using Content.Shared.Xenoarchaeology.Equipment; using Content.Shared.Xenoarchaeology.XenoArtifacts; using JetBrains.Annotations; using Robust.Server.GameObjects; +using Robust.Server.Player; using Robust.Shared.Audio; using Robust.Shared.Prototypes; using Robust.Shared.Timing; @@ -228,7 +229,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem /// private void OnServerSelectionMessage(EntityUid uid, AnalysisConsoleComponent component, AnalysisConsoleServerSelectionMessage args) { - _ui.TryOpen(uid, ResearchClientUiKey.Key, args.Session); + _ui.TryOpen(uid, ResearchClientUiKey.Key, (IPlayerSession) args.Session); } /// diff --git a/Content.Shared/Administration/Managers/ISharedAdminManager.cs b/Content.Shared/Administration/Managers/ISharedAdminManager.cs index 22d918d4a3..7e01c81433 100644 --- a/Content.Shared/Administration/Managers/ISharedAdminManager.cs +++ b/Content.Shared/Administration/Managers/ISharedAdminManager.cs @@ -1,4 +1,4 @@ -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Shared.Administration.Managers; diff --git a/Content.Shared/Buckle/SharedBuckleSystem.cs b/Content.Shared/Buckle/SharedBuckleSystem.cs index 1441745b5d..7edf2448ae 100644 --- a/Content.Shared/Buckle/SharedBuckleSystem.cs +++ b/Content.Shared/Buckle/SharedBuckleSystem.cs @@ -11,7 +11,7 @@ using Robust.Shared.Containers; using Robust.Shared.Map; using Robust.Shared.Network; using Robust.Shared.Physics.Systems; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Timing; namespace Content.Shared.Buckle; diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Interactions.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Interactions.cs index dfa72fcfb7..d0c3be3b31 100644 --- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Interactions.cs +++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Interactions.cs @@ -6,7 +6,7 @@ using Content.Shared.Input; using Content.Shared.Localizations; using Robust.Shared.Input.Binding; using Robust.Shared.Map; -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Shared.Hands.EntitySystems; diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index 7981deaee6..4a9a43ca2c 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -34,7 +34,7 @@ using Robust.Shared.Network; using Robust.Shared.Physics; using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Systems; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Random; using Robust.Shared.Serialization; using Robust.Shared.Timing; diff --git a/Content.Shared/Mind/Components/MindContainerComponent.cs b/Content.Shared/Mind/Components/MindContainerComponent.cs index 62b26cbd35..ca0f14d994 100644 --- a/Content.Shared/Mind/Components/MindContainerComponent.cs +++ b/Content.Shared/Mind/Components/MindContainerComponent.cs @@ -1,25 +1,24 @@ using System.Diagnostics.CodeAnalysis; -using Robust.Shared.GameStates; namespace Content.Shared.Mind.Components { /// - /// This component indicates that this entity may have mind, which is simply an entity with a . - /// The mind entity is not actually stored in a "container", but is simply stored in nullspace. + /// Stores a on a mob. /// - [RegisterComponent, Access(typeof(SharedMindSystem)), NetworkedComponent, AutoGenerateComponentState] + [RegisterComponent, Access(typeof(SharedMindSystem))] public sealed partial class MindContainerComponent : Component { /// /// The mind controlling this mob. Can be null. /// - [DataField, AutoNetworkedField] + [ViewVariables] [Access(typeof(SharedMindSystem), Other = AccessPermissions.ReadWriteExecute)] // FIXME Friends public EntityUid? Mind { get; set; } /// /// True if we have a mind, false otherwise. /// + [ViewVariables] [MemberNotNullWhen(true, nameof(Mind))] public bool HasMind => Mind != null; @@ -27,7 +26,7 @@ namespace Content.Shared.Mind.Components /// Whether examining should show information about the mind or not. /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("showExamineInfo"), AutoNetworkedField] + [DataField("showExamineInfo")] public bool ShowExamineInfo { get; set; } /// @@ -39,59 +38,19 @@ namespace Content.Shared.Mind.Components public bool GhostOnShutdown { get; set; } = true; } - public abstract class MindEvent : EntityEventArgs + public sealed class MindRemovedMessage : EntityEventArgs { - public readonly Entity Mind; - public readonly Entity Container; + public EntityUid OldMindId; + public MindComponent OldMind; - public MindEvent(Entity mind, Entity container) + public MindRemovedMessage(EntityUid oldMindId, MindComponent oldMind) { - Mind = mind; - Container = container; + OldMindId = oldMindId; + OldMind = oldMind; } } - /// - /// Event raised directed at a mind-container when a mind gets removed. - /// - public sealed class MindRemovedMessage : MindEvent + public sealed class MindAddedMessage : EntityEventArgs { - public MindRemovedMessage(Entity mind, Entity container) - : base(mind, container) - { - } - } - - /// - /// Event raised directed at a mind when it gets removed from a mind-container. - /// - public sealed class MindGotRemovedEvent : MindEvent - { - public MindGotRemovedEvent(Entity mind, Entity container) - : base(mind, container) - { - } - } - - /// - /// Event raised directed at a mind-container when a mind gets added. - /// - public sealed class MindAddedMessage : MindEvent - { - public MindAddedMessage(Entity mind, Entity container) - : base(mind, container) - { - } - } - - /// - /// Event raised directed at a mind when it gets added to a mind-container. - /// - public sealed class MindGotAddedEvent : MindEvent - { - public MindGotAddedEvent(Entity mind, Entity container) - : base(mind, container) - { - } } } diff --git a/Content.Shared/Mind/MindComponent.cs b/Content.Shared/Mind/MindComponent.cs index b147a2dbbe..3ea92c3ce7 100644 --- a/Content.Shared/Mind/MindComponent.cs +++ b/Content.Shared/Mind/MindComponent.cs @@ -1,86 +1,84 @@ using Content.Shared.GameTicking; using Content.Shared.Mind.Components; -using Robust.Shared.GameStates; using Robust.Shared.Network; -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Shared.Mind { /// - /// This component stores information about a player/mob mind. The component will be attached to a mind-entity - /// which is stored in null-space. The entity that is currently "possessed" by the mind will have a - /// . + /// This is added as a component to mind entities, not to player entities. + /// for the one that is added to players. + /// A mind represents the IC "mind" of a player. + /// Roles are attached as components to its owning entity. /// /// - /// Roles are attached as components on the mind-entity entity. /// Think of it like this: if a player is supposed to have their memories, /// their mind follows along. /// /// Things such as respawning do not follow, because you're a new character. /// Getting borged, cloned, turned into a catbeast, etc... will keep it following you. - /// - /// Minds are stored in null-space, and are thus generally not set to players unless that player is the owner - /// of the mind. As a result it should be safe to network "secret" information like roles & objectives /// - [RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] + [RegisterComponent] public sealed partial class MindComponent : Component { - [DataField, AutoNetworkedField] - public List Objectives = new(); + internal readonly List Objectives = new(); /// /// The session ID of the player owning this mind. /// - [DataField, AutoNetworkedField, Access(typeof(SharedMindSystem))] + [ViewVariables, Access(typeof(SharedMindSystem))] public NetUserId? UserId { get; set; } /// /// The session ID of the original owner, if any. /// May end up used for round-end information (as the owner may have abandoned Mind since) /// - [DataField, AutoNetworkedField, Access(typeof(SharedMindSystem))] + [ViewVariables, Access(typeof(SharedMindSystem))] public NetUserId? OriginalOwnerUserId { get; set; } /// - /// The first entity that this mind controlled. Used for round end information. + /// Entity UID for the first entity that this mind controlled. Used for round end. /// Might be relevant if the player has ghosted since. /// - [DataField, AutoNetworkedField] - public NetEntity? OriginalOwnedEntity; - // This is a net entity, because this field currently ddoes not get set to null when this entity is deleted. - // This is a lazy way to ensure that people check that the entity still exists. - // TODO MIND Fix this properly by adding an OriginalMindContainerComponent or something like that. + [ViewVariables] public EntityUid? OriginalOwnedEntity; [ViewVariables] public bool IsVisitingEntity => VisitingEntity != null; - [DataField, AutoNetworkedField, Access(typeof(SharedMindSystem))] + [ViewVariables, Access(typeof(SharedMindSystem))] public EntityUid? VisitingEntity { get; set; } [ViewVariables] public EntityUid? CurrentEntity => VisitingEntity ?? OwnedEntity; - [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)] + [ViewVariables(VVAccess.ReadWrite)] public string? CharacterName { get; set; } /// /// The time of death for this Mind. /// Can be null - will be null if the Mind is not considered "dead". /// - [DataField] + [ViewVariables] public TimeSpan? TimeOfDeath { get; set; } + /// + /// The component currently owned by this mind. + /// Can be null. + /// + [ViewVariables] public MindContainerComponent? OwnedComponent; + /// /// The entity currently owned by this mind. /// Can be null. /// - [DataField, AutoNetworkedField, Access(typeof(SharedMindSystem))] + [ViewVariables, Access(typeof(SharedMindSystem))] public EntityUid? OwnedEntity { get; set; } + // TODO move objectives out of mind component /// /// An enumerable over all the objective entities this mind has. /// - [ViewVariables, Obsolete("Use Objectives field")] + [ViewVariables] public IEnumerable AllObjectives => Objectives; /// @@ -102,7 +100,6 @@ namespace Content.Shared.Mind /// Can be null, in which case the player is currently not logged in. /// [ViewVariables, Access(typeof(SharedMindSystem), typeof(SharedGameTicker))] - // TODO remove this after moving IPlayerManager functions to shared public ICommonSession? Session { get; set; } } } diff --git a/Content.Shared/Mind/SharedMindSystem.cs b/Content.Shared/Mind/SharedMindSystem.cs index 66a0325963..cc4ac4af23 100644 --- a/Content.Shared/Mind/SharedMindSystem.cs +++ b/Content.Shared/Mind/SharedMindSystem.cs @@ -1,5 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using System.Linq; using Content.Shared.Administration.Logs; using Content.Shared.Database; using Content.Shared.Examine; @@ -13,7 +12,7 @@ using Content.Shared.Objectives.Systems; using Content.Shared.Players; using Robust.Shared.Map; using Robust.Shared.Network; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Utility; namespace Content.Shared.Mind; @@ -26,7 +25,7 @@ public abstract class SharedMindSystem : EntitySystem [Dependency] private readonly SharedPlayerSystem _player = default!; [Dependency] private readonly MetaDataSystem _metadata = default!; - [ViewVariables] + // This is dictionary is required to track the minds of disconnected players that may have had their entity deleted. protected readonly Dictionary UserMinds = new(); public override void Initialize() @@ -37,7 +36,6 @@ public abstract class SharedMindSystem : EntitySystem SubscribeLocalEvent(OnSuicide); SubscribeLocalEvent(OnVisitingTerminating); SubscribeLocalEvent(OnReset); - SubscribeLocalEvent(OnMindStartup); } public override void Shutdown() @@ -46,29 +44,6 @@ public abstract class SharedMindSystem : EntitySystem WipeAllMinds(); } - private void OnMindStartup(EntityUid uid, MindComponent component, ComponentStartup args) - { - if (component.UserId == null) - return; - - if (UserMinds.TryAdd(component.UserId.Value, uid)) - return; - - var existing = UserMinds[component.UserId.Value]; - if (existing == uid) - return; - - if (!Exists(existing)) - { - Log.Error($"Found deleted entity in mind dictionary while initializing mind {ToPrettyString(uid)}"); - UserMinds[component.UserId.Value] = uid; - return; - } - - Log.Error($"Encountered a user {component.UserId} that is already assigned to a mind while initializing mind {ToPrettyString(uid)}. Ignoring user field."); - component.UserId = null; - } - private void OnReset(RoundRestartCleanupEvent ev) { WipeAllMinds(); @@ -76,22 +51,12 @@ public abstract class SharedMindSystem : EntitySystem public virtual void WipeAllMinds() { - Log.Info($"Wiping all minds"); - foreach (var mind in UserMinds.Values.ToArray()) - { - WipeMind(mind); - } - - if (UserMinds.Count == 0) - return; - foreach (var mind in UserMinds.Values) { - if (Exists(mind)) - Log.Error($"Failed to wipe mind: {ToPrettyString(mind)}"); + WipeMind(mind); } - UserMinds.Clear(); + DebugTools.Assert(UserMinds.Count == 0); } public EntityUid? GetMind(NetUserId user) @@ -115,26 +80,6 @@ public abstract class SharedMindSystem : EntitySystem return false; } - public bool TryGetMind(NetUserId user, [NotNullWhen(true)] out Entity? mind) - { - if (!TryGetMind(user, out var mindId, out var mindComp)) - { - mind = null; - return false; - } - - mind = (mindId.Value, mindComp); - return true; - } - - public Entity GetOrCreateMind(NetUserId user) - { - if (!TryGetMind(user, out var mind)) - mind = CreateMind(user); - - return mind.Value; - } - private void OnVisitingTerminating(EntityUid uid, VisitingMindComponent component, ref EntityTerminatingEvent args) { if (component.MindId != null) @@ -183,7 +128,7 @@ public abstract class SharedMindSystem : EntitySystem return null; } - public Entity CreateMind(NetUserId? userId, string? name = null) + public EntityUid CreateMind(NetUserId? userId, string? name = null) { var mindId = Spawn(null, MapCoordinates.Nullspace); _metadata.SetEntityName(mindId, name == null ? "mind" : $"mind ({name})"); @@ -191,7 +136,7 @@ public abstract class SharedMindSystem : EntitySystem mind.CharacterName = name; SetUserId(mindId, userId, mind); - return (mindId, mind); + return mindId; } /// @@ -250,7 +195,7 @@ public abstract class SharedMindSystem : EntitySystem /// Cleans up the VisitingEntity. /// /// - protected void RemoveVisitingEntity(EntityUid mindId, MindComponent mind) + protected void RemoveVisitingEntity(MindComponent mind) { if (mind.VisitingEntity == null) return; @@ -265,7 +210,6 @@ public abstract class SharedMindSystem : EntitySystem RemCompDeferred(oldVisitingEnt, visitComp); } - Dirty(mindId, mind); RaiseLocalEvent(oldVisitingEnt, new MindUnvisitedMessage(), true); } @@ -284,7 +228,7 @@ public abstract class SharedMindSystem : EntitySystem if (mindId == null || !Resolve(mindId.Value, ref mind, false)) return; - TransferTo(mindId.Value, null, createGhost:false, mind: mind); + TransferTo(mindId.Value, null, mind: mind); SetUserId(mindId.Value, null, mind: mind); } @@ -409,11 +353,11 @@ public abstract class SharedMindSystem : EntitySystem } public bool TryGetMind( - ContentPlayerData contentPlayer, + PlayerData player, out EntityUid mindId, [NotNullWhen(true)] out MindComponent? mind) { - mindId = contentPlayer.Mind ?? default; + mindId = player.Mind ?? default; return TryComp(mindId, out mind); } @@ -447,6 +391,21 @@ public abstract class SharedMindSystem : EntitySystem return TryComp(mindContainer.Mind, out role); } + /// + /// Sets the Mind's OwnedComponent and OwnedEntity + /// + /// Mind to set OwnedComponent and OwnedEntity on + /// Entity owned by + /// MindContainerComponent owned by + protected void SetOwnedEntity(MindComponent mind, EntityUid? uid, MindContainerComponent? mindContainerComponent) + { + if (uid != null) + Resolve(uid.Value, ref mindContainerComponent); + + mind.OwnedEntity = uid; + mind.OwnedComponent = mindContainerComponent; + } + /// /// Sets the Mind's UserId, Session, and updates the player's PlayerData. This should have no direct effect on the /// entity that any mind is connected to, except as a side effect of the fact that it may change a player's diff --git a/Content.Shared/Movement/Events/MoveInputEvent.cs b/Content.Shared/Movement/Events/MoveInputEvent.cs index 89e5636acd..8e1b43f8bd 100644 --- a/Content.Shared/Movement/Events/MoveInputEvent.cs +++ b/Content.Shared/Movement/Events/MoveInputEvent.cs @@ -1,3 +1,5 @@ +using Robust.Shared.Players; + namespace Content.Shared.Movement.Events; /// diff --git a/Content.Shared/Movement/Systems/SharedContentEyeSystem.cs b/Content.Shared/Movement/Systems/SharedContentEyeSystem.cs index 4b81619fd0..27e0080c87 100644 --- a/Content.Shared/Movement/Systems/SharedContentEyeSystem.cs +++ b/Content.Shared/Movement/Systems/SharedContentEyeSystem.cs @@ -5,7 +5,7 @@ using Content.Shared.Ghost; using Content.Shared.Input; using Content.Shared.Movement.Components; using Robust.Shared.Input.Binding; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Serialization; namespace Content.Shared.Movement.Systems; diff --git a/Content.Shared/Movement/Systems/SharedMoverController.Input.cs b/Content.Shared/Movement/Systems/SharedMoverController.Input.cs index 1d323a9187..425322408e 100644 --- a/Content.Shared/Movement/Systems/SharedMoverController.Input.cs +++ b/Content.Shared/Movement/Systems/SharedMoverController.Input.cs @@ -6,7 +6,7 @@ using Content.Shared.Movement.Components; using Content.Shared.Movement.Events; using Robust.Shared.Input; using Robust.Shared.Input.Binding; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Serialization; using Robust.Shared.Timing; using Robust.Shared.Utility; diff --git a/Content.Shared/Players/ContentPlayerData.cs b/Content.Shared/Players/PlayerData.cs similarity index 73% rename from Content.Shared/Players/ContentPlayerData.cs rename to Content.Shared/Players/PlayerData.cs index 7545eb58fc..c6274c950b 100644 --- a/Content.Shared/Players/ContentPlayerData.cs +++ b/Content.Shared/Players/PlayerData.cs @@ -1,15 +1,16 @@ using Content.Shared.GameTicking; using Content.Shared.Mind; using Robust.Shared.Network; +using Robust.Shared.Player; namespace Content.Shared.Players; /// /// Content side for all data that tracks a player session. -/// Use to retrieve this from an . +/// Use to retrieve this from an . /// Not currently used on the client. /// -public sealed class ContentPlayerData +public sealed class PlayerData { /// /// The session ID of the player owning this data. @@ -37,9 +38,21 @@ public sealed class ContentPlayerData /// public bool ExplicitlyDeadminned { get; set; } - public ContentPlayerData(NetUserId userId, string name) + public PlayerData(NetUserId userId, string name) { UserId = userId; Name = name; } -} \ No newline at end of file +} + + +public static class PlayerDataExt +{ + /// + /// Gets the correctly cast instance of content player data from an engine player data storage. + /// + public static PlayerData? ContentData(this IPlayerData data) + { + return (PlayerData?) data.ContentDataUncast; + } +} diff --git a/Content.Shared/Players/PlayerDataExt.cs b/Content.Shared/Players/PlayerDataExt.cs deleted file mode 100644 index eba4d8339d..0000000000 --- a/Content.Shared/Players/PlayerDataExt.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Robust.Shared.Player; - -namespace Content.Shared.Players; - -public static class PlayerDataExt -{ - /// - /// Gets the correctly cast instance of content player data from an engine player data storage. - /// - public static ContentPlayerData? ContentData(this SessionData data) - { - return (ContentPlayerData?) data.ContentDataUncast; - } - - /// - /// Gets the correctly cast instance of content player data from an engine player data storage. - /// - public static ContentPlayerData? ContentData(this ICommonSession session) - { - return session.Data.ContentData(); - } - - /// - /// Gets the mind that is associated with this player. - /// - public static EntityUid? GetMind(this ICommonSession session) - { - return session.Data.ContentData()?.Mind; - } -} \ No newline at end of file diff --git a/Content.Shared/Players/SharedPlayerSystem.cs b/Content.Shared/Players/SharedPlayerSystem.cs index 7271c5688a..6fc7ad6a40 100644 --- a/Content.Shared/Players/SharedPlayerSystem.cs +++ b/Content.Shared/Players/SharedPlayerSystem.cs @@ -1,4 +1,4 @@ -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Shared.Players; @@ -8,5 +8,5 @@ namespace Content.Shared.Players; /// public abstract class SharedPlayerSystem : EntitySystem { - public abstract ContentPlayerData? ContentData(ICommonSession? session); + public abstract PlayerData? ContentData(ICommonSession? session); } diff --git a/Content.Shared/Popups/SharedPopupSystem.cs b/Content.Shared/Popups/SharedPopupSystem.cs index e4565b90e8..50013a5435 100644 --- a/Content.Shared/Popups/SharedPopupSystem.cs +++ b/Content.Shared/Popups/SharedPopupSystem.cs @@ -1,5 +1,6 @@ using Robust.Shared.Map; using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Serialization; namespace Content.Shared.Popups diff --git a/Content.Shared/Pulling/Systems/SharedPullingSystem.cs b/Content.Shared/Pulling/Systems/SharedPullingSystem.cs index 0c139ee9e3..6f19d048b4 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingSystem.cs @@ -12,7 +12,7 @@ using Robust.Shared.Map; using Robust.Shared.Physics; using Robust.Shared.Physics.Events; using Robust.Shared.Physics.Systems; -using Robust.Shared.Player; +using Robust.Shared.Players; namespace Content.Shared.Pulling { diff --git a/Content.Shared/Roles/Jobs/SharedJobSystem.cs b/Content.Shared/Roles/Jobs/SharedJobSystem.cs index af97ea1350..ac18d04e9c 100644 --- a/Content.Shared/Roles/Jobs/SharedJobSystem.cs +++ b/Content.Shared/Roles/Jobs/SharedJobSystem.cs @@ -2,7 +2,7 @@ using System.Linq; using Content.Shared.Players; using Content.Shared.Players.PlayTimeTracking; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Prototypes; using Robust.Shared.Utility; diff --git a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs index 62af6067d0..4b740b8d3c 100644 --- a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs +++ b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs @@ -23,7 +23,7 @@ using Robust.Shared.Audio; using Robust.Shared.Map; using Robust.Shared.Physics; using Robust.Shared.Physics.Systems; -using Robust.Shared.Player; +using Robust.Shared.Players; using Robust.Shared.Prototypes; using Robust.Shared.Timing; diff --git a/RobustToolbox b/RobustToolbox index 9750b113c8..554e0777b1 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit 9750b113c81e7535d892326568760bc976072436 +Subproject commit 554e0777b1ba6ba096d8f4407d5c35ecc7b0f22f -- 2.51.2