From 5a0fc68be217b42c8a20f110c1b293f2b80f209a Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Mon, 11 Sep 2023 09:42:41 +1000 Subject: [PATCH] Content update for NetEntities (#18935) --- Content.Client/Actions/ActionsSystem.cs | 8 +- .../Administration/AdminNameOverlay.cs | 9 +- .../Administration/Systems/AdminVerbSystem.cs | 14 +- .../CustomControls/PlayerListControl.xaml.cs | 14 +- .../UI/ManageSolutions/EditSolutionsEui.cs | 4 +- .../UI/SetOutfit/SetOutfitEui.cs | 5 +- .../UI/SpawnExplosion/SpawnExplosionEui.cs | 10 +- .../AdminbusTab/LoadBlueprintsWindow.xaml.cs | 4 +- .../UI/Tabs/AtmosTab/AddAtmosWindow.xaml.cs | 3 +- .../AtmosTab/SetTemperatureWindow.xaml.cs | 2 +- .../UI/Tabs/PlayerTab/PlayerTab.xaml.cs | 6 +- .../EntitySystems/AtmosDebugOverlaySystem.cs | 2 +- .../EntitySystems/GasTileOverlaySystem.cs | 8 +- .../Atmos/UI/GasAnalyzerWindow.xaml.cs | 2 +- Content.Client/Beam/BeamSystem.cs | 4 +- .../Bql/ToolshedVisualizeWindow.xaml.cs | 2 +- Content.Client/Buckle/BuckleSystem.cs | 4 +- Content.Client/Camera/CameraRecoilSystem.cs | 2 +- .../CardboardBox/CardboardBoxSystem.cs | 12 +- .../CartridgeLoaderBoundUserInterface.cs | 24 ++- .../CharacterInfo/CharacterInfoSystem.cs | 6 +- .../Clothing/ClientClothingSystem.cs | 6 +- .../ConstructionGhostComponent.cs | 1 - .../ConstructionPlacementHijack.cs | 11 +- .../Construction/ConstructionSystem.cs | 43 ++-- .../ContextMenu/UI/EntityMenuElement.cs | 7 +- .../ContextMenu/UI/EntityMenuUIController.cs | 12 +- .../CrewManifest/CrewManifestSystem.cs | 6 +- Content.Client/Decals/DecalPlacementSystem.cs | 6 +- Content.Client/Decals/DecalSystem.cs | 18 +- .../Disposal/Systems/DisposalUnitSystem.cs | 2 +- Content.Client/DragDrop/DragDropSystem.cs | 43 +++- .../Effects/ColorFlashEffectSystem.cs | 6 +- Content.Client/Examine/ExamineSystem.cs | 22 +- .../Explosion/ExplosionOverlaySystem.cs | 9 +- Content.Client/Fax/AdminUI/AdminFaxEui.cs | 6 +- .../Fluids/PuddleDebugOverlaySystem.cs | 2 +- .../GameTicking/Managers/ClientGameTicker.cs | 24 ++- Content.Client/Gameplay/GameplayStateBase.cs | 10 +- .../Gateway/UI/GatewayBoundUserInterface.cs | 2 +- .../Gateway/UI/GatewayWindow.xaml.cs | 13 +- Content.Client/Hands/Systems/HandsSystem.cs | 4 +- .../UI/HealthAnalyzerWindow.xaml.cs | 9 +- .../Humanoid/HumanoidAppearanceSystem.cs | 2 +- .../Instruments/InstrumentSystem.cs | 18 +- .../Instruments/UI/BandMenu.xaml.cs | 5 +- .../UI/InstrumentBoundUserInterface.cs | 10 +- .../Inventory/ClientInventorySystem.cs | 4 +- Content.Client/Items/Systems/ItemSystem.cs | 2 +- Content.Client/Kitchen/UI/GrinderMenu.xaml.cs | 4 +- .../Kitchen/UI/MicrowaveBoundUserInterface.cs | 10 +- .../UI/ReagentGrinderBoundUserInterface.cs | 2 +- Content.Client/LateJoin/LateJoinGui.cs | 9 +- .../Light/RgbLightControllerSystem.cs | 2 +- Content.Client/Maps/GridDraggingSystem.cs | 8 +- .../Ui/NewsWriteBoundUserInterface.cs | 12 +- .../Mech/Ui/Equipment/MechGrabberUi.cs | 4 +- .../Equipment/MechGrabberUiFragment.xaml.cs | 2 +- .../Mech/Ui/Equipment/MechSoundboardUi.cs | 3 +- .../Mech/Ui/MechBoundUserInterface.cs | 4 +- .../CrewMonitoringWindow.xaml.cs | 21 +- Content.Client/NPC/HTN/HTNSystem.cs | 2 +- Content.Client/NPC/NPCSteeringSystem.cs | 6 +- Content.Client/NPC/PathfindingSystem.cs | 40 ++-- .../NodeContainer/NodeGroupSystem.cs | 2 +- .../NodeContainer/NodeVisualizationOverlay.cs | 2 +- Content.Client/Pointing/PointingSystem.cs | 4 +- Content.Client/Popups/PopupSystem.cs | 12 +- .../Projectiles/ProjectileSystem.cs | 6 +- .../Overlays/RadiationDebugOverlay.cs | 12 +- .../Radiation/Systems/GeigerSystem.cs | 2 +- .../Radiation/Systems/RadiationSystem.cs | 6 +- .../ReplaySpectatorSystem.Movement.cs | 9 +- .../ReplaySpectatorSystem.Position.cs | 2 +- .../ReplaySpectatorSystem.Spectate.cs | 10 +- .../RoundEnd/RoundEndSummaryWindow.cs | 6 +- Content.Client/Salvage/FultonSystem.cs | 9 +- .../BUI/RadarConsoleBoundUserInterface.cs | 2 +- .../BUI/ShuttleConsoleBoundUserInterface.cs | 10 +- .../Shuttles/Systems/ShuttleConsoleSystem.cs | 5 +- .../Systems/ShuttleSystem.EmergencyConsole.cs | 2 +- Content.Client/Shuttles/UI/DockingControl.cs | 6 +- Content.Client/Shuttles/UI/RadarControl.cs | 4 +- .../Shuttles/UI/ShuttleConsoleWindow.xaml.cs | 43 ++-- .../Silicons/Borgs/BorgBoundUserInterface.cs | 2 +- Content.Client/Spawners/TimedDespawnSystem.cs | 2 +- Content.Client/Station/StationSystem.cs | 3 +- ...lStationRecordConsoleBoundUserInterface.cs | 2 +- .../GeneralStationRecordConsoleWindow.xaml.cs | 4 +- .../StationRecords/StationRecordsSystem.cs | 7 + .../Storage/StorageBoundUserInterface.cs | 6 +- .../Storage/Systems/StorageSystem.cs | 10 +- Content.Client/Storage/UI/StorageWindow.cs | 2 +- .../UI/SurveillanceCameraMonitorBoundUi.cs | 16 +- Content.Client/Tabletop/TabletopSystem.cs | 30 +-- .../Systems/Actions/ActionUIController.cs | 23 ++- .../Systems/Chat/ChatUIController.cs | 19 +- .../Ghost/Controls/GhostTargetWindow.xaml.cs | 4 +- .../Ghost/Controls/Roles/MakeGhostRoleEui.cs | 3 +- .../Systems/Ghost/GhostUIController.cs | 4 +- .../Inventory/InventoryUIController.cs | 3 +- Content.Client/Vehicle/VehicleSystem.cs | 8 +- Content.Client/Verbs/UI/VerbMenuElement.cs | 2 +- .../Verbs/UI/VerbMenuUIController.cs | 4 +- Content.Client/Verbs/VerbSystem.cs | 8 +- .../Weapons/Melee/MeleeWeaponSystem.cs | 26 ++- .../Weapons/Misc/TetherGunSystem.cs | 2 +- .../Ranged/Systems/GunSystem.Ballistic.cs | 2 +- .../Systems/GunSystem.ChamberMagazine.cs | 2 +- .../Ranged/Systems/GunSystem.Revolver.cs | 6 +- .../Weapons/Ranged/Systems/GunSystem.cs | 32 +-- .../Ui/AnalysisConsoleMenu.xaml.cs | 2 +- Content.IntegrationTests/Pair/TestMapData.cs | 5 + .../Pair/TestPair.Helpers.cs | 50 ++++- .../Tests/Actions/ActionsAddedTest.cs | 30 +-- .../Tests/Chemistry/DispenserTest.cs | 4 +- .../Tests/ClickableTest.cs | 21 +- .../Tests/Climbing/ClimbingTest.cs | 4 +- .../Interaction/ComputerContruction.cs | 6 +- .../Construction/Interaction/CraftingTests.cs | 14 +- .../Interaction/GrilleWindowConstruction.cs | 8 +- .../Interaction/MachineConstruction.cs | 8 +- .../Construction/Interaction/PanelScrewing.cs | 2 + .../Interaction/WallConstruction.cs | 3 +- .../Interaction/WindowConstruction.cs | 4 +- .../Construction/Interaction/WindowRepair.cs | 2 +- .../Tests/ContainerOcclusionTest.cs | 80 ++++---- .../Tests/DoAfter/DoAfterCancellationTests.cs | 12 +- .../Tests/DoAfter/DoAfterServerTest.cs | 4 +- Content.IntegrationTests/Tests/EntityTest.cs | 4 +- .../Components/ActionBlocking/HandCuffTest.cs | 6 +- .../Click/InteractionSystemTests.cs | 2 +- .../Interaction/InteractionTest.Helpers.cs | 171 ++++++++++------ .../Tests/Interaction/InteractionTest.cs | 31 +-- .../Interaction/InteractionTestSystem.cs | 7 +- .../Tests/Interaction/MovementTest.cs | 12 +- .../Networking/SimplePredictReconcileTest.cs | 20 +- .../Tests/Payload/ModularGrenadeTests.cs | 2 +- .../Tests/Slipping/SlippingTest.cs | 6 +- .../Tests/Tiles/TileConstructionTests.cs | 4 +- .../Access/Systems/AccessOverriderSystem.cs | 2 +- .../Access/Systems/AgentIDCardSystem.cs | 2 +- .../Commands/AddBodyPartCommand.cs | 11 +- .../Commands/AddEntityStorageCommand.cs | 14 +- .../Commands/AddMechanismCommand.cs | 9 +- .../Commands/AddPolymorphActionCommand.cs | 11 +- .../Administration/Commands/AddReagent.cs | 13 +- .../Commands/ClearBluespaceLockerLinks.cs | 9 +- .../Administration/Commands/DirtyCommand.cs | 11 +- .../Commands/LinkBluespaceLocker.cs | 22 +- .../Administration/Commands/OSay.cs | 6 +- .../Commands/RemoveBodyPartCommand.cs | 9 +- .../Commands/RemoveEntityStorageCommand.cs | 15 +- .../Commands/RemoveMechanismCommand.cs | 9 +- .../Commands/SetSolutionCapacity.cs | 8 +- .../Commands/SetSolutionTemperature.cs | 8 +- .../Commands/SetSolutionThermalEnergy.cs | 11 +- .../Commands/VariantizeCommand.cs | 12 +- .../Administration/Systems/AdminSystem.cs | 2 +- .../Administration/UI/EditSolutionsEui.cs | 5 +- .../Administration/UI/SetOutfitEui.cs | 3 +- .../Ame/EntitySystems/AmeControllerSystem.cs | 2 +- Content.Server/Animals/Systems/UdderSystem.cs | 2 +- .../Anomaly/AnomalySystem.Commands.cs | 8 +- .../Anomaly/AnomalySystem.Scanner.cs | 2 +- .../Atmos/Commands/AddAtmosCommand.cs | 12 +- .../Atmos/Commands/AddGasCommand.cs | 24 ++- .../Atmos/Commands/DeleteGasCommand.cs | 25 +-- .../Atmos/Commands/FillGasCommand.cs | 21 +- .../Atmos/Commands/RemoveGasCommand.cs | 22 +- .../Commands/SetAtmosTemperatureCommand.cs | 18 +- .../Atmos/Commands/SetTemperatureCommand.cs | 16 +- .../EntitySystems/AtmosDebugOverlaySystem.cs | 2 +- .../AtmosphereSystem.Commands.cs | 4 +- .../Atmos/EntitySystems/GasAnalyzerSystem.cs | 2 +- .../Atmos/EntitySystems/GasTankSystem.cs | 1 - .../EntitySystems/GasTileOverlaySystem.cs | 34 ++-- Content.Server/Beam/BeamSystem.cs | 4 +- .../Body/Commands/AddHandCommand.cs | 42 ++-- .../Body/Commands/AttachBodyPartCommand.cs | 33 +-- .../Body/Systems/InternalsSystem.cs | 2 +- .../Botany/Systems/BotanySwabSystem.cs | 2 +- Content.Server/Camera/CameraRecoilSystem.cs | 5 +- .../CardboardBox/CardboardBoxSystem.cs | 2 +- .../Cargo/Systems/CargoSystem.Orders.cs | 4 +- .../Cargo/Systems/CargoSystem.Shuttle.cs | 8 +- Content.Server/Cargo/Systems/PricingSystem.cs | 4 +- .../CartridgeLoader/CartridgeLoaderSystem.cs | 191 +++++++++++------- .../Cartridges/CrewManifestCartridgeSystem.cs | 18 +- .../Cartridges/NotekeeperCartridgeSystem.cs | 2 +- .../CharacterInfo/CharacterInfoSystem.cs | 4 +- Content.Server/Chat/Managers/ChatManager.cs | 6 +- Content.Server/Chat/Systems/ChatSystem.cs | 4 +- .../EntitySystems/ChemistrySystem.Injector.cs | 2 +- Content.Server/Chunking/ChunkingSystem.cs | 33 +-- Content.Server/Climbing/ClimbSystem.cs | 2 +- .../Cloning/CloningConsoleSystem.cs | 2 +- .../Communications/CommsHackerSystem.cs | 2 +- .../CommunicationsConsoleSystem.cs | 3 +- .../Configurable/ConfigurationSystem.cs | 2 +- .../Commands/FixRotationsCommand.cs | 25 +-- .../Commands/TileReplaceCommand.cs | 20 +- .../Construction/Commands/TileWallsCommand.cs | 27 +-- .../ConstructionSystem.Initial.cs | 12 +- .../ConstructionSystem.Interactions.cs | 8 +- .../Construction/PartExchangerSystem.cs | 2 +- Content.Server/Crayon/CrayonSystem.cs | 2 +- .../CrewManifest/CrewManifestSystem.cs | 16 +- .../Damage/Commands/GodModeCommand.cs | 14 +- Content.Server/Damage/Commands/HurtCommand.cs | 35 ++-- .../Decals/Commands/AddDecalCommand.cs | 13 +- .../Decals/Commands/EditDecalCommand.cs | 21 +- .../Decals/Commands/RemoveDecalCommand.cs | 14 +- Content.Server/Decals/DecalSystem.cs | 74 +++---- .../Systems/SignalTimerSystem.cs | 4 +- .../Systems/NetworkConfiguratorSystem.cs | 4 +- .../Disposal/Mailing/MailingUnitSystem.cs | 2 +- .../Disposal/Tube/DisposalTubeSystem.cs | 11 +- .../Disposal/TubeConnectionsCommand.cs | 4 +- .../Unit/EntitySystems/DisposableSystem.cs | 2 +- .../Unit/EntitySystems/DisposalUnitSystem.cs | 8 +- .../Effects/ColorFlashEffectSystem.cs | 2 +- .../Electrocution/ElectrocuteCommand.cs | 14 +- .../DisassembleOnAltVerbSystem.cs | 2 +- .../EntitySystems/SpawnAfterInteractSystem.cs | 2 +- .../Ensnaring/EnsnareableSystem.Ensnaring.cs | 2 +- Content.Server/Examine/ExamineSystem.cs | 17 +- .../EntitySystems/ExplosionSystem.TileFill.cs | 6 +- .../EntitySystems/ExplosionSystem.Visuals.cs | 8 +- .../Explosion/EntitySystems/TriggerSystem.cs | 2 +- Content.Server/Fax/AdminUI/AdminFaxEui.cs | 6 +- .../Fluids/EntitySystems/DrainSystem.cs | 2 +- .../PuddleDebugDebugOverlaySystem.cs | 2 +- .../EntitySystems/PuddleSystem.Spillable.cs | 2 +- .../Forensics/Systems/ForensicPadSystem.cs | 2 +- .../Systems/ForensicScannerSystem.cs | 4 +- .../GameTicking/Commands/JoinGameCommand.cs | 8 +- .../GameTicking/GameTicker.GameRule.cs | 4 +- .../GameTicking/GameTicker.RoundFlow.cs | 2 +- .../Gateway/Systems/GatewaySystem.cs | 14 +- Content.Server/Ghost/GhostSystem.cs | 30 +-- .../Ghost/Roles/MakeGhostRoleCommand.cs | 18 +- .../Ghost/Roles/UI/MakeGhostRoleEui.cs | 6 +- Content.Server/Guardian/GuardianSystem.cs | 2 +- Content.Server/Hands/Systems/HandsSystem.cs | 6 +- Content.Server/Implants/ImplanterSystem.cs | 4 +- .../Instruments/InstrumentSystem.cs | 50 +++-- .../Interaction/InteractionSystem.cs | 19 +- .../EntitySystems/KitchenSpikeSystem.cs | 2 +- .../Kitchen/EntitySystems/MicrowaveSystem.cs | 6 +- .../EntitySystems/ReagentGrinderSystem.cs | 7 +- .../Kitchen/EntitySystems/SharpSystem.cs | 2 +- Content.Server/Lathe/LatheSystem.cs | 2 +- .../Light/EntitySystems/PoweredLightSystem.cs | 2 +- Content.Server/Magic/MagicSystem.cs | 2 +- Content.Server/Maps/GridDraggingSystem.cs | 26 ++- .../MassMedia/Systems/NewsSystem.cs | 94 +++++---- .../EntitySystems/MechGrabberSystem.cs | 20 +- .../Mech/Systems/MechEquipmentSystem.cs | 2 +- Content.Server/Mech/Systems/MechSystem.cs | 20 +- .../BiomassReclaimerSystem.cs | 2 +- .../CrewMonitoringConsoleSystem.cs | 2 +- Content.Server/Medical/CryoPodSystem.cs | 6 +- Content.Server/Medical/DefibrillatorSystem.cs | 2 +- Content.Server/Medical/HealingSystem.cs | 2 +- .../Medical/HealthAnalyzerSystem.cs | 4 +- .../Medical/Stethoscope/StethoscopeSystem.cs | 2 +- .../Medical/SuitSensors/SuitSensorSystem.cs | 8 +- .../Mind/Commands/MakeSentientCommand.cs | 10 +- Content.Server/Mind/Commands/RenameCommand.cs | 49 +++-- Content.Server/NPC/HTN/HTNSystem.cs | 2 +- .../NPC/Pathfinding/PathfindingSystem.Grid.cs | 8 + .../NPC/Pathfinding/PathfindingSystem.cs | 22 +- .../NPC/Systems/NPCSteeringSystem.cs | 2 +- .../Ninja/Systems/BatteryDrainerSystem.cs | 2 +- .../EntitySystems/NodeGroupSystem.cs | 4 +- .../Nuke/Commands/SendNukeCodesCommand.cs | 9 +- .../Nuke/Commands/ToggleNukeCommand.cs | 13 +- Content.Server/Nuke/NukeSystem.cs | 4 +- .../Nutrition/EntitySystems/DrinkSystem.cs | 2 +- .../Nutrition/EntitySystems/FoodSystem.cs | 2 +- .../EntitySystems/SmokingSystem.Vape.cs | 2 +- Content.Server/PDA/PdaSystem.cs | 24 ++- Content.Server/PDA/Ringer/RingerSystem.cs | 2 +- Content.Server/Paper/PaperSystem.cs | 2 +- .../ParticleAcceleratorSystem.ControlBox.cs | 2 +- .../Pointing/EntitySystems/PointingSystem.cs | 18 +- Content.Server/Popups/PopupSystem.cs | 16 +- .../PowerMonitoringConsoleSystem.cs | 2 +- .../Generator/PortableGeneratorSystem.cs | 2 +- .../Power/SetBatteryPercentCommand.cs | 8 +- .../Projectiles/ProjectileSystem.cs | 2 +- .../Radiation/Systems/GeigerSystem.cs | 2 +- .../Systems/RadiationSystem.Debug.cs | 12 +- .../Systems/RadiationSystem.GridCast.cs | 4 +- .../Radio/EntitySystems/RadioSystem.cs | 2 +- .../Resist/EscapeInventorySystem.cs | 2 +- Content.Server/Resist/ResistLockerSystem.cs | 2 +- .../EntitySystems/RevenantSystem.Abilities.cs | 4 +- Content.Server/Salvage/FultonSystem.cs | 5 +- .../SensorMonitoringConsoleSystem.UI.cs | 2 +- .../Sericulture/SericultureSystem.cs | 2 +- .../Shuttles/Commands/DockCommand.cs | 6 +- .../Systems/DockingSystem.AutoDock.cs | 24 ++- .../Shuttles/Systems/DockingSystem.cs | 8 +- .../Systems/EmergencyShuttleSystem.Console.cs | 2 +- .../Systems/EmergencyShuttleSystem.cs | 2 +- .../Shuttles/Systems/RadarConsoleSystem.cs | 4 +- .../Shuttles/Systems/ShuttleConsoleSystem.cs | 24 ++- .../Silicons/Borgs/BorgSystem.Ui.cs | 10 +- .../EntitySystems/EventHorizonSystem.cs | 6 +- .../EntityConsumedByEventHorizonEvent.cs | 4 +- .../Events/EventHorizonConsumedEntityEvent.cs | 4 +- .../SprayPainter/SprayPainterSystem.cs | 4 +- .../Station/Systems/StationJobsSystem.cs | 13 +- .../Station/Systems/StationSystem.cs | 6 +- .../GeneralStationRecordConsoleComponent.cs | 2 +- .../Components/StationRecordsComponent.cs | 3 +- .../StationRecords/StationRecordSet.cs | 46 ++--- .../GeneralStationRecordConsoleSystem.cs | 6 +- .../Systems/StationRecordsSystem.cs | 72 +++---- Content.Server/Sticky/Systems/StickySystem.cs | 4 +- .../EntitySystems/BluespaceLockerSystem.cs | 2 +- .../Storage/EntitySystems/StorageSystem.cs | 36 ++-- .../Store/Systems/StoreSystem.Command.cs | 8 +- .../Store/Systems/StoreSystem.Ui.cs | 4 +- Content.Server/Store/Systems/StoreSystem.cs | 2 +- Content.Server/Strip/StrippableSystem.cs | 8 +- .../SurveillanceCameraMonitorSystem.cs | 9 +- .../Tabletop/TabletopSystem.Session.cs | 2 +- Content.Server/Tabletop/TabletopSystem.cs | 17 +- .../Teleportation/HandTeleporterSystem.cs | 2 +- .../Tools/ToolSystem.LatticeCutting.cs | 9 +- Content.Server/Tools/ToolSystem.TilePrying.cs | 7 +- .../Commands/Verbs/RunVerbAsCommand.cs | 19 +- .../Toolshed/Commands/VisualizeCommand.cs | 6 +- Content.Server/Verbs/VerbSystem.cs | 10 +- Content.Server/VoiceMask/VoiceMaskSystem.cs | 2 +- .../Weapons/Melee/MeleeWeaponSystem.cs | 12 +- .../Weapons/Ranged/Systems/GunSystem.cs | 17 +- Content.Server/Wires/WiresSystem.cs | 2 +- .../Systems/ArtifactAnalyzerSystem.cs | 4 +- .../XenoArtifacts/ArtifactSystem.Commands.cs | 12 +- .../Components/AccessReaderComponent.cs | 4 +- .../Access/Systems/AccessReaderSystem.cs | 14 +- Content.Shared/Actions/ActionEvents.cs | 12 +- Content.Shared/Actions/ActionsComponent.cs | 4 +- Content.Shared/Actions/BaseActionComponent.cs | 20 +- .../Actions/EntityTargetActionComponent.cs | 2 +- .../Actions/InstantActionComponent.cs | 2 +- Content.Shared/Actions/SharedActionsSystem.cs | 62 +++--- .../Actions/WorldTargetActionComponent.cs | 2 +- .../Administration/EditSolutionsEuiState.cs | 4 +- Content.Shared/Administration/PlayerInfo.cs | 2 +- .../Administration/SetOutfitEuiState.cs | 2 +- .../Atmos/Components/GasAnalyzerComponent.cs | 4 +- .../SharedAtmosDebugOverlaySystem.cs | 4 +- .../SharedGasTileOverlaySystem.cs | 4 +- .../Beam/Components/SharedBeamComponent.cs | 4 +- .../Body/Organ/OrganComponentState.cs | 4 +- Content.Shared/Body/Organ/OrganSlot.cs | 19 +- .../Body/Part/BodyPartComponentState.cs | 4 +- Content.Shared/Body/Part/BodyPartSlot.cs | 28 ++- .../Body/Systems/SharedBodySystem.Body.cs | 17 +- .../Body/Systems/SharedBodySystem.Organs.cs | 15 +- .../Body/Systems/SharedBodySystem.Parts.cs | 27 ++- .../Bql/ToolshedVisualizeEuiState.cs | 4 +- .../Buckle/Components/BuckleComponent.cs | 6 +- .../Buckle/Components/StrapComponent.cs | 4 +- .../Buckle/SharedBuckleSystem.Buckle.cs | 2 +- .../Buckle/SharedBuckleSystem.Strap.cs | 4 +- .../Camera/SharedCameraRecoilSystem.cs | 6 +- .../Components/CardboardBoxComponent.cs | 6 +- .../CartridgeLoaderComponent.cs | 8 +- .../CartridgeLoaderUiMessage.cs | 4 +- .../CartridgeLoader/CartridgeLoaderUiState.cs | 10 +- .../CartridgeLoader/CartridgeUiMessage.cs | 2 +- .../Cartridges/NotekeeperUiState.cs | 2 +- .../SharedCartridgeLoaderSystem.cs | 12 +- .../SharedCharacterInfoSystem.cs | 12 +- Content.Shared/Chat/MsgChatMessage.cs | 4 +- Content.Shared/Climbing/BonkSystem.cs | 2 +- .../EntitySystems/ToggleableClothingSystem.cs | 2 +- Content.Shared/Construction/Events.cs | 18 +- .../Containers/ItemSlot/ItemSlotsSystem.cs | 35 ++-- .../CrewManifest/SharedCrewManifestSystem.cs | 4 +- Content.Shared/Cuffs/SharedCuffableSystem.cs | 4 +- .../Decals/DecalChunkUpdateEvent.cs | 4 +- Content.Shared/Decals/SharedDecalSystem.cs | 8 +- .../Components/DeviceListComponent.cs | 4 +- .../NetworkConfiguratorComponent.cs | 4 +- .../Systems/SharedDeviceListSystem.cs | 4 +- .../SharedNetworkConfiguratorSystem.cs | 4 +- Content.Shared/Devour/SharedDevourSystem.cs | 4 +- .../Disposal/SharedDisposalUnitSystem.cs | 4 +- Content.Shared/DoAfter/DoAfter.cs | 11 +- Content.Shared/DoAfter/DoAfterArgs.cs | 26 ++- Content.Shared/DoAfter/DoAfterComponent.cs | 7 +- .../DoAfter/SharedDoAfterSystem.Update.cs | 2 +- Content.Shared/DoAfter/SharedDoAfterSystem.cs | 27 ++- .../Doors/Components/DoorComponent.cs | 6 +- .../Doors/Systems/SharedDoorSystem.cs | 9 +- .../DragDrop/DragDropRequestEvent.cs | 6 +- .../Effects/ColorFlashEffectEvent.cs | 4 +- .../Examine/ExamineSystemMessages.cs | 12 +- Content.Shared/Examine/ExamineSystemShared.cs | 4 +- .../Explosion/ExplosionVisualsComponent.cs | 4 +- Content.Shared/Fax/AdminFaxEui.cs | 12 +- .../Fluids/SharedPuddleDebugOverlaySystem.cs | 4 +- .../Follower/Components/FollowedComponent.cs | 4 +- Content.Shared/Follower/FollowerSystem.cs | 29 ++- .../GameTicking/SharedGameTicker.cs | 8 +- Content.Shared/Gateway/GatewayUi.cs | 12 +- .../Ghost/Roles/MakeGhostRoleEuiState.cs | 4 +- .../Ghost/Roles/SharedGhostRoleSystem.cs | 2 +- Content.Shared/Ghost/SharedGhostSystem.cs | 10 +- .../EntitySystems/SharedHandsSystem.Drop.cs | 10 +- .../SharedHandsSystem.Interactions.cs | 6 +- .../EntitySystems/SharedHandsSystem.Pickup.cs | 2 +- Content.Shared/Hands/HandEvents.cs | 6 +- .../SharedHumanoidAppearanceSystem.cs | 2 +- .../Implants/SharedImplanterSystem.cs | 2 +- .../Instruments/SharedInstrumentComponent.cs | 22 +- .../InstrumentBoundUserInterfaceMessages.cs | 4 +- .../Components/InteractionRelayComponent.cs | 4 +- .../Helpers/SharedUnoccludedExtensions.cs | 20 +- .../SharedInteractionSystem.Relay.cs | 4 +- .../Interaction/SharedInteractionSystem.cs | 14 +- .../Events/InventoryEquipActEvent.cs | 6 +- .../Inventory/InventorySystem.Equip.cs | 8 +- Content.Shared/Item/ItemComponent.cs | 4 +- .../Kitchen/Components/SharedMicrowave.cs | 8 +- .../Kitchen/SharedReagentGrinder.cs | 8 +- .../Maps/SharedGridDraggingSystem.cs | 4 +- .../Components/SharedNewsWriteComponent.cs | 9 +- .../MassMedia/Systems/SharedNewsSystem.cs | 6 +- .../Mech/Components/MechComponent.cs | 2 +- .../Mech/Components/MechPilotComponent.cs | 2 +- .../Mech/EntitySystems/SharedMechSystem.cs | 8 +- .../Equipment/Systems/MechSoundboardSystem.cs | 2 +- Content.Shared/Mech/MechUI.cs | 18 +- .../Medical/SuitSensor/SharedSuitSensor.cs | 6 +- .../HealthAnalyzerScannedUserMessage.cs | 4 +- .../Movement/Systems/SharedJetpackSystem.cs | 6 +- .../Systems/SharedMoverController.Input.cs | 38 ++-- Content.Shared/NPC/Events/HTNMessage.cs | 2 +- .../NPC/Events/NPCSteeringDebugEvent.cs | 4 +- .../NPC/Events/PathBreadcrumbsMessage.cs | 6 +- .../NPC/Events/PathPolysRefreshMessage.cs | 2 +- Content.Shared/NPC/PathPoly.cs | 6 +- Content.Shared/NodeContainer/NodeVis.cs | 2 +- Content.Shared/PDA/PdaUpdateState.cs | 18 +- .../Physics/PreventCollideComponent.cs | 6 +- .../Physics/SharedPreventCollideSystem.cs | 4 +- .../Placeable/ItemPlacerComponent.cs | 10 +- Content.Shared/Placeable/ItemPlacerSystem.cs | 35 +++- Content.Shared/Pointing/PointingEvents.cs | 5 +- Content.Shared/Popups/SharedPopupSystem.cs | 8 +- .../Projectiles/SharedProjectileSystem.cs | 6 +- .../Pulling/Components/PullableComponent.cs | 4 +- .../SharedPullingStateManagementSystem.cs | 12 +- Content.Shared/RCD/Systems/RCDSystem.cs | 10 +- .../Radiation/Components/GeigerComponent.cs | 2 +- .../Events/OnRadiationOverlayUpdateEvent.cs | 4 +- Content.Shared/Radiation/RadiationRay.cs | 10 +- .../Systems/SharedResearchStealerSystem.cs | 2 +- .../Salvage/Fulton/SharedFultonSystem.cs | 6 +- .../RadarConsoleBoundInterfaceState.cs | 8 +- .../ShuttleConsoleBoundInterfaceState.cs | 6 +- .../Shuttles/Events/AutodockRequestMessage.cs | 2 +- .../Events/EmergencyShuttlePositionMessage.cs | 2 +- .../Events/ShuttleConsoleFTLRequestMessage.cs | 2 +- .../Events/StopAutodockRequestMessage.cs | 2 +- .../Shuttles/Events/UndockRequestMessage.cs | 2 +- .../Systems/SharedShuttleConsoleSystem.cs | 4 +- Content.Shared/Silicons/Borgs/BorgUI.cs | 4 +- .../Borgs/Components/BorgChassisComponent.cs | 2 +- .../Station/StationsUpdatedEvent.cs | 4 +- ...SharedGeneralStationRecordConsoleSystem.cs | 12 +- .../SharedStationRecordsSystem.cs | 43 ++++ .../StationRecords/StationRecordKey.cs | 34 +++- .../StationRecordKeyStorageComponent.cs | 4 +- .../StationRecordKeyStorageSystem.cs | 8 +- .../Components/StepTriggerComponent.cs | 6 +- .../StepTrigger/Systems/StepTriggerSystem.cs | 22 +- .../Storage/Components/BinComponent.cs | 4 +- .../Storage/EntitySystems/BinSystem.cs | 4 +- .../Storage/EntitySystems/DumpableSystem.cs | 6 +- Content.Shared/Storage/Events.cs | 4 +- .../Storage/SharedStorageComponent.cs | 16 +- .../SharedSurveillanceCameraMonitorSystem.cs | 4 +- .../TabletopDraggingPlayerChangedEvent.cs | 4 +- .../Tabletop/Events/TabletopMoveEvent.cs | 6 +- .../Tabletop/Events/TabletopPlayEvent.cs | 6 +- .../Events/TabletopStopPlayingEvent.cs | 4 +- .../Tabletop/SharedTabletopSystem.cs | 17 +- .../Components/LinkedEntityComponent.cs | 4 +- .../Components/PortalTimeoutComponent.cs | 4 +- .../Systems/LinkedEntitySystem.cs | 6 +- .../Systems/SharedPortalSystem.cs | 4 +- .../Throwing/ThrownItemComponent.cs | 5 +- Content.Shared/Throwing/ThrownItemSystem.cs | 4 +- .../Tools/Systems/SharedToolSystem.cs | 20 +- .../Vehicle/Components/RiderComponent.cs | 2 +- .../Vehicle/SharedVehicleSystem.Rider.cs | 2 +- .../SharedVendingMachineSystem.Restock.cs | 2 +- Content.Shared/Verbs/SharedVerbSystem.cs | 8 +- Content.Shared/Verbs/Verb.cs | 4 +- Content.Shared/Verbs/VerbEvents.cs | 14 +- .../Weapons/Melee/Events/AttackEvent.cs | 4 +- .../Weapons/Melee/Events/DisarmAttackEvent.cs | 4 +- .../Weapons/Melee/Events/HeavyAttackEvent.cs | 6 +- .../Weapons/Melee/Events/LightAttackEvent.cs | 6 +- .../Weapons/Melee/Events/MeleeLungeEvent.cs | 6 +- .../Weapons/Melee/Events/StopAttackEvent.cs | 4 +- .../Weapons/Melee/SharedMeleeWeaponSystem.cs | 81 ++++---- .../Weapons/Misc/SharedTetherGunSystem.cs | 8 +- .../BallisticAmmoProviderComponent.cs | 5 +- .../Weapons/Ranged/Events/MuzzleFlashEvent.cs | 4 +- .../Ranged/Events/RequestShootEvent.cs | 6 +- .../Ranged/Events/RequestStopShootEvent.cs | 4 +- .../Systems/SharedGunSystem.Ballistic.cs | 35 +++- .../Systems/SharedGunSystem.Revolver.cs | 6 +- .../Weapons/Ranged/Systems/SharedGunSystem.cs | 14 +- Content.Shared/Wieldable/WieldableSystem.cs | 2 +- .../Equipment/SharedArtifactAnalyzer.cs | 4 +- 526 files changed, 3058 insertions(+), 2215 deletions(-) create mode 100644 Content.Client/StationRecords/StationRecordsSystem.cs create mode 100644 Content.Shared/StationRecords/SharedStationRecordsSystem.cs diff --git a/Content.Client/Actions/ActionsSystem.cs b/Content.Client/Actions/ActionsSystem.cs index 2d9b777abd..c95ce2d526 100644 --- a/Content.Client/Actions/ActionsSystem.cs +++ b/Content.Client/Actions/ActionsSystem.cs @@ -67,12 +67,12 @@ namespace Content.Client.Actions return; component.Actions.Clear(); - component.Actions.UnionWith(state.Actions); + component.Actions.UnionWith(GetEntitySet(state.Actions)); _actionHoldersQueue.Enqueue(uid); } - protected override void AddActionInternal(EntityUid holderId, EntityUid actionId, IContainer container, ActionsComponent holder) + protected override void AddActionInternal(EntityUid holderId, EntityUid actionId, BaseContainer container, ActionsComponent holder) { // Sometimes the client receives actions from the server, before predicting that newly added components will add // their own shared actions. Just in case those systems ever decided to directly access action properties (e.g., @@ -87,7 +87,7 @@ namespace Content.Client.Actions } } - public override void AddAction(EntityUid holderId, EntityUid actionId, EntityUid? provider, ActionsComponent? holder = null, BaseActionComponent? action = null, bool dirty = true, IContainer? actionContainer = null) + public override void AddAction(EntityUid holderId, EntityUid actionId, EntityUid? provider, ActionsComponent? holder = null, BaseActionComponent? action = null, bool dirty = true, BaseContainer? actionContainer = null) { if (!Resolve(holderId, ref holder, false)) return; @@ -195,7 +195,7 @@ namespace Content.Client.Actions } else { - var request = new RequestPerformActionEvent(actionId); + var request = new RequestPerformActionEvent(GetNetEntity(actionId)); EntityManager.RaisePredictiveEvent(request); } } diff --git a/Content.Client/Administration/AdminNameOverlay.cs b/Content.Client/Administration/AdminNameOverlay.cs index 8afee7f366..c21ba2e32c 100644 --- a/Content.Client/Administration/AdminNameOverlay.cs +++ b/Content.Client/Administration/AdminNameOverlay.cs @@ -35,20 +35,21 @@ namespace Content.Client.Administration foreach (var playerInfo in _system.PlayerList) { + var entity = _entityManager.GetEntity(playerInfo.NetEntity); + // Otherwise the entity can not exist yet - if (!_entityManager.EntityExists(playerInfo.EntityUid)) + if (entity == null || !_entityManager.EntityExists(entity)) { continue; } - var entity = playerInfo.EntityUid.Value; // if not on the same map, continue - if (_entityManager.GetComponent(entity).MapID != _eyeManager.CurrentMap) + if (_entityManager.GetComponent(entity.Value).MapID != _eyeManager.CurrentMap) { continue; } - var aabb = _entityLookup.GetWorldAABB(entity); + var aabb = _entityLookup.GetWorldAABB(entity.Value); // if not on screen, continue if (!aabb.Intersects(in viewport)) diff --git a/Content.Client/Administration/Systems/AdminVerbSystem.cs b/Content.Client/Administration/Systems/AdminVerbSystem.cs index e37b51af52..d08ebc0fce 100644 --- a/Content.Client/Administration/Systems/AdminVerbSystem.cs +++ b/Content.Client/Administration/Systems/AdminVerbSystem.cs @@ -24,12 +24,14 @@ namespace Content.Client.Administration.Systems // View variables verbs if (_clientConGroupController.CanViewVar()) { - Verb verb = new(); - verb.Category = VerbCategory.Debug; - verb.Text = "View Variables"; - verb.Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/vv.svg.192dpi.png")); - verb.Act = () => _clientConsoleHost.ExecuteCommand($"vv {args.Target}"); - verb.ClientExclusive = true; // opening VV window is client-side. Don't ask server to run this verb. + Verb verb = new() + { + Category = VerbCategory.Debug, + Text = "View Variables", + Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/vv.svg.192dpi.png")), + Act = () => _clientConsoleHost.ExecuteCommand($"vv {GetNetEntity(args.Target)}"), + ClientExclusive = true // opening VV window is client-side. Don't ask server to run this verb. + }; args.Verbs.Add(verb); } } diff --git a/Content.Client/Administration/UI/CustomControls/PlayerListControl.xaml.cs b/Content.Client/Administration/UI/CustomControls/PlayerListControl.xaml.cs index d5367dfa99..6142e3a831 100644 --- a/Content.Client/Administration/UI/CustomControls/PlayerListControl.xaml.cs +++ b/Content.Client/Administration/UI/CustomControls/PlayerListControl.xaml.cs @@ -18,7 +18,6 @@ namespace Content.Client.Administration.UI.CustomControls public sealed partial class PlayerListControl : BoxContainer { private readonly AdminSystem _adminSystem; - private readonly VerbSystem _verbSystem; private List _playerList = new(); private readonly List _sortedPlayerList = new(); @@ -29,11 +28,14 @@ namespace Content.Client.Administration.UI.CustomControls public Func? OverrideText; public Comparison? Comparison; + private IEntityManager _entManager; + private IUserInterfaceManager _uiManager; + public PlayerListControl() { - _adminSystem = EntitySystem.Get(); - _verbSystem = EntitySystem.Get(); - IoCManager.InjectDependencies(this); + _entManager = IoCManager.Resolve(); + _uiManager = IoCManager.Resolve(); + _adminSystem = _entManager.System(); RobustXamlLoader.Load(this); // Fill the Option data PlayerListContainer.ItemPressed += PlayerListItemPressed; @@ -56,9 +58,9 @@ namespace Content.Client.Administration.UI.CustomControls if (OverrideText != null && args.Button.Children.FirstOrDefault()?.Children?.FirstOrDefault() is Label label) label.Text = GetText(selectedPlayer); } - else if (args.Event.Function == EngineKeyFunctions.UseSecondary && selectedPlayer.EntityUid != null) + else if (args.Event.Function == EngineKeyFunctions.UseSecondary && selectedPlayer.NetEntity != null) { - IoCManager.Resolve().GetUIController().OpenVerbMenu(selectedPlayer.EntityUid.Value); + _uiManager.GetUIController().OpenVerbMenu(_entManager.GetEntity(selectedPlayer.NetEntity.Value)); } } diff --git a/Content.Client/Administration/UI/ManageSolutions/EditSolutionsEui.cs b/Content.Client/Administration/UI/ManageSolutions/EditSolutionsEui.cs index 4bee78fa09..2e1b4dcf34 100644 --- a/Content.Client/Administration/UI/ManageSolutions/EditSolutionsEui.cs +++ b/Content.Client/Administration/UI/ManageSolutions/EditSolutionsEui.cs @@ -12,9 +12,11 @@ namespace Content.Client.Administration.UI.ManageSolutions public sealed class EditSolutionsEui : BaseEui { private readonly EditSolutionsWindow _window; + private IEntityManager _entManager; public EditSolutionsEui() { + _entManager = IoCManager.Resolve(); _window = new EditSolutionsWindow(); _window.OnClose += () => SendMessage(new CloseEuiMessage()); } @@ -34,7 +36,7 @@ namespace Content.Client.Administration.UI.ManageSolutions public override void HandleState(EuiStateBase baseState) { var state = (EditSolutionsEuiState) baseState; - _window.SetTargetEntity(state.Target); + _window.SetTargetEntity(_entManager.GetEntity(state.Target)); _window.UpdateSolutions(state.Solutions); _window.UpdateReagents(); } diff --git a/Content.Client/Administration/UI/SetOutfit/SetOutfitEui.cs b/Content.Client/Administration/UI/SetOutfit/SetOutfitEui.cs index c277116526..7987d464d7 100644 --- a/Content.Client/Administration/UI/SetOutfit/SetOutfitEui.cs +++ b/Content.Client/Administration/UI/SetOutfit/SetOutfitEui.cs @@ -9,8 +9,11 @@ namespace Content.Client.Administration.UI.SetOutfit public sealed class SetOutfitEui : BaseEui { private readonly SetOutfitMenu _window; + private IEntityManager _entManager; + public SetOutfitEui() { + _entManager = IoCManager.Resolve(); _window = new SetOutfitMenu(); _window.OnClose += OnClosed; } @@ -34,7 +37,7 @@ namespace Content.Client.Administration.UI.SetOutfit public override void HandleState(EuiStateBase state) { var outfitState = (SetOutfitEuiState) state; - _window.TargetEntityId = outfitState.TargetEntityId; + _window.TargetEntityId = _entManager.GetEntity(outfitState.TargetNetEntity); } } diff --git a/Content.Client/Administration/UI/SpawnExplosion/SpawnExplosionEui.cs b/Content.Client/Administration/UI/SpawnExplosion/SpawnExplosionEui.cs index 5413b953f8..3a8270afb8 100644 --- a/Content.Client/Administration/UI/SpawnExplosion/SpawnExplosionEui.cs +++ b/Content.Client/Administration/UI/SpawnExplosion/SpawnExplosionEui.cs @@ -10,6 +10,7 @@ namespace Content.Client.Administration.UI.SpawnExplosion; [UsedImplicitly] public sealed class SpawnExplosionEui : BaseEui { + [Dependency] private readonly EntityManager _entManager = default!; [Dependency] private readonly IOverlayManager _overlayManager = default!; private readonly SpawnExplosionWindow _window; @@ -69,7 +70,14 @@ public sealed class SpawnExplosionEui : BaseEui _overlayManager.AddOverlay(_debugOverlay); } - _debugOverlay.Tiles = data.Explosion.Tiles; + var tiles = new Dictionary>>(); + _debugOverlay.Tiles.Clear(); + + foreach (var (nent, det) in data.Explosion.Tiles) + { + tiles[_entManager.GetEntity(nent)] = det; + } + _debugOverlay.SpaceTiles = data.Explosion.SpaceTiles; _debugOverlay.Intensity = data.Explosion.Intensity; _debugOverlay.Slope = data.Slope; diff --git a/Content.Client/Administration/UI/Tabs/AdminbusTab/LoadBlueprintsWindow.xaml.cs b/Content.Client/Administration/UI/Tabs/AdminbusTab/LoadBlueprintsWindow.xaml.cs index 0cc3294df1..770a244a19 100644 --- a/Content.Client/Administration/UI/Tabs/AdminbusTab/LoadBlueprintsWindow.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/AdminbusTab/LoadBlueprintsWindow.xaml.cs @@ -104,7 +104,7 @@ namespace Content.Client.Administration.UI.Tabs.AdminbusTab private void OnTeleportButtonPressed(BaseButton.ButtonEventArgs obj) { IoCManager.Resolve().ExecuteCommand( - $"tp {XCoordinate.Value} {YCoordinate.Value} {MapOptions.SelectedId}"); + $"tp {XCoordinate.Value} {YCoordinate.Value} {new NetEntity(MapOptions.SelectedId)}"); } private void OnSubmitButtonPressed(BaseButton.ButtonEventArgs obj) @@ -112,7 +112,7 @@ namespace Content.Client.Administration.UI.Tabs.AdminbusTab if (MapPath.Text.Length == 0) return; IoCManager.Resolve().ExecuteCommand( - $"loadbp {MapOptions.SelectedId} \"{MapPath.Text}\" {XCoordinate.Value} {YCoordinate.Value} {RotationSpin.Value}"); + $"loadbp {new NetEntity(MapOptions.SelectedId)} \"{MapPath.Text}\" {XCoordinate.Value} {YCoordinate.Value} {RotationSpin.Value}"); } } } diff --git a/Content.Client/Administration/UI/Tabs/AtmosTab/AddAtmosWindow.xaml.cs b/Content.Client/Administration/UI/Tabs/AtmosTab/AddAtmosWindow.xaml.cs index 51ac027901..2f643caae2 100644 --- a/Content.Client/Administration/UI/Tabs/AtmosTab/AddAtmosWindow.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/AtmosTab/AddAtmosWindow.xaml.cs @@ -38,8 +38,9 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab if (_data == null) return; var dataList = _data.ToList(); + var entManager = IoCManager.Resolve(); var selectedGrid = dataList[GridOptions.SelectedId].Owner; - IoCManager.Resolve().ExecuteCommand($"addatmos {selectedGrid}"); + IoCManager.Resolve().ExecuteCommand($"addatmos {entManager.GetNetEntity(selectedGrid)}"); } } } diff --git a/Content.Client/Administration/UI/Tabs/AtmosTab/SetTemperatureWindow.xaml.cs b/Content.Client/Administration/UI/Tabs/AtmosTab/SetTemperatureWindow.xaml.cs index c49cb02511..ca0efbbc7c 100644 --- a/Content.Client/Administration/UI/Tabs/AtmosTab/SetTemperatureWindow.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/AtmosTab/SetTemperatureWindow.xaml.cs @@ -47,7 +47,7 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab var selectedGrid = _data[GridOptions.SelectedId]; IoCManager.Resolve() - .ExecuteCommand($"settemp {TileXSpin.Value} {TileYSpin.Value} {selectedGrid} {TemperatureSpin.Value}"); + .ExecuteCommand($"settemp {TileXSpin.Value} {TileYSpin.Value} {IoCManager.Resolve().GetNetEntity(selectedGrid)} {TemperatureSpin.Value}"); } } } diff --git a/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs b/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs index 7ece83d1cf..91a453e416 100644 --- a/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs @@ -18,6 +18,7 @@ namespace Content.Client.Administration.UI.Tabs.PlayerTab private const string ArrowDown = "↓"; private readonly Color _altColor = Color.FromHex("#292B38"); private readonly Color _defaultColor = Color.FromHex("#2F2F3B"); + private IEntityManager _entManager; private readonly AdminSystem _adminSystem; private IReadOnlyList _players = new List(); @@ -29,7 +30,8 @@ namespace Content.Client.Administration.UI.Tabs.PlayerTab public PlayerTab() { - _adminSystem = EntitySystem.Get(); + _entManager = IoCManager.Resolve(); + _adminSystem = _entManager.System(); RobustXamlLoader.Load(this); RefreshPlayerList(_adminSystem.PlayerList); @@ -119,7 +121,7 @@ namespace Content.Client.Administration.UI.Tabs.PlayerTab player.Antag ? "YES" : "NO", new StyleBoxFlat(useAltColor ? _altColor : _defaultColor), player.Connected); - entry.PlayerUid = player.EntityUid; + entry.PlayerUid = _entManager.GetEntity(player.NetEntity); entry.OnPressed += args => OnEntryPressed?.Invoke(args); PlayerList.AddChild(entry); diff --git a/Content.Client/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs b/Content.Client/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs index db8421d8cc..c849abf70e 100644 --- a/Content.Client/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs +++ b/Content.Client/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs @@ -56,7 +56,7 @@ namespace Content.Client.Atmos.EntitySystems private void HandleAtmosDebugOverlayMessage(AtmosDebugOverlayMessage message) { - _tileData[message.GridId] = message; + _tileData[GetEntity(message.GridId)] = message; } private void HandleAtmosDebugOverlayDisableMessage(AtmosDebugOverlayDisableMessage ev) diff --git a/Content.Client/Atmos/EntitySystems/GasTileOverlaySystem.cs b/Content.Client/Atmos/EntitySystems/GasTileOverlaySystem.cs index ddb0a34085..78185ce6b0 100644 --- a/Content.Client/Atmos/EntitySystems/GasTileOverlaySystem.cs +++ b/Content.Client/Atmos/EntitySystems/GasTileOverlaySystem.cs @@ -65,8 +65,10 @@ namespace Content.Client.Atmos.EntitySystems private void HandleGasOverlayUpdate(GasOverlayUpdateEvent ev) { - foreach (var (grid, removedIndicies) in ev.RemovedChunks) + foreach (var (nent, removedIndicies) in ev.RemovedChunks) { + var grid = GetEntity(nent); + if (!TryComp(grid, out GasTileOverlayComponent? comp)) continue; @@ -76,8 +78,10 @@ namespace Content.Client.Atmos.EntitySystems } } - foreach (var (grid, gridData) in ev.UpdatedChunks) + foreach (var (nent, gridData) in ev.UpdatedChunks) { + var grid = GetEntity(nent); + if (!TryComp(grid, out GasTileOverlayComponent? comp)) continue; diff --git a/Content.Client/Atmos/UI/GasAnalyzerWindow.xaml.cs b/Content.Client/Atmos/UI/GasAnalyzerWindow.xaml.cs index 33c3e8644e..48c3b6f978 100644 --- a/Content.Client/Atmos/UI/GasAnalyzerWindow.xaml.cs +++ b/Content.Client/Atmos/UI/GasAnalyzerWindow.xaml.cs @@ -68,7 +68,7 @@ namespace Content.Client.Atmos.UI _ => GridIcon.OverrideDirection }; - GridIcon.SetEntity(msg.DeviceUid); + GridIcon.SetEntity(IoCManager.Resolve().GetEntity(msg.DeviceUid)); LeftPanel.RemoveAllChildren(); MiddlePanel.RemoveAllChildren(); RightPanel.RemoveAllChildren(); diff --git a/Content.Client/Beam/BeamSystem.cs b/Content.Client/Beam/BeamSystem.cs index c221e79769..4749d4d29b 100644 --- a/Content.Client/Beam/BeamSystem.cs +++ b/Content.Client/Beam/BeamSystem.cs @@ -17,7 +17,9 @@ public sealed class BeamSystem : SharedBeamSystem //TODO: Sometime in the future this needs to be replaced with tiled sprites private void BeamVisualizerMessage(BeamVisualizerEvent args) { - if (TryComp(args.Beam, out var sprites)) + var beam = GetEntity(args.Beam); + + if (TryComp(beam, out var sprites)) { sprites.Rotation = args.UserAngle; diff --git a/Content.Client/Bql/ToolshedVisualizeWindow.xaml.cs b/Content.Client/Bql/ToolshedVisualizeWindow.xaml.cs index 0265e3343e..55ee029a91 100644 --- a/Content.Client/Bql/ToolshedVisualizeWindow.xaml.cs +++ b/Content.Client/Bql/ToolshedVisualizeWindow.xaml.cs @@ -23,7 +23,7 @@ internal sealed partial class ToolshedVisualizeWindow : DefaultWindow protected override Vector2 ContentsMinimumSize => new(500, 700); - public void Update((string name, EntityUid entity)[] entities) + public void Update((string name, NetEntity entity)[] entities) { StatusLabel.Text = _loc.GetString("ui-bql-results-status", ("count", entities.Length)); ItemList.RemoveAllChildren(); diff --git a/Content.Client/Buckle/BuckleSystem.cs b/Content.Client/Buckle/BuckleSystem.cs index 70960d06a2..24f12a7915 100644 --- a/Content.Client/Buckle/BuckleSystem.cs +++ b/Content.Client/Buckle/BuckleSystem.cs @@ -25,8 +25,8 @@ internal sealed class BuckleSystem : SharedBuckleSystem return; component.Buckled = state.Buckled; - component.BuckledTo = state.BuckledTo; - component.LastEntityBuckledTo = state.LastEntityBuckledTo; + component.BuckledTo = EnsureEntity(state.BuckledTo, uid); + component.LastEntityBuckledTo = EnsureEntity(state.LastEntityBuckledTo, uid); component.DontCollide = state.DontCollide; ActionBlockerSystem.UpdateCanMove(uid); diff --git a/Content.Client/Camera/CameraRecoilSystem.cs b/Content.Client/Camera/CameraRecoilSystem.cs index a5dc7e6ecd..65a3fc71c7 100644 --- a/Content.Client/Camera/CameraRecoilSystem.cs +++ b/Content.Client/Camera/CameraRecoilSystem.cs @@ -13,7 +13,7 @@ public sealed class CameraRecoilSystem : SharedCameraRecoilSystem private void OnCameraKick(CameraKickEvent ev) { - KickCamera(ev.Euid, ev.Recoil); + KickCamera(GetEntity(ev.NetEntity), ev.Recoil); } public override void KickCamera(EntityUid uid, Vector2 recoil, CameraRecoilComponent? component = null) diff --git a/Content.Client/CardboardBox/CardboardBoxSystem.cs b/Content.Client/CardboardBox/CardboardBoxSystem.cs index a4a273eaca..3c870f6e6e 100644 --- a/Content.Client/CardboardBox/CardboardBoxSystem.cs +++ b/Content.Client/CardboardBox/CardboardBoxSystem.cs @@ -19,12 +19,14 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem private void OnBoxEffect(PlayBoxEffectMessage msg) { - if (!TryComp(msg.Source, out var box)) + var source = GetEntity(msg.Source); + + if (!TryComp(source, out var box)) return; var xformQuery = GetEntityQuery(); - if (!xformQuery.TryGetComponent(msg.Source, out var xform)) + if (!xformQuery.TryGetComponent(source, out var xform)) return; var sourcePos = xform.MapPosition; @@ -32,12 +34,13 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem //Any mob that can move should be surprised? //God mind rework needs to come faster so it can just check for mind //TODO: Replace with Mind Query when mind rework is in. - var mobMoverEntities = new HashSet(); + var mobMoverEntities = new List(); + var mover = GetEntity(msg.Mover); //Filter out entities in range to see that they're a mob and add them to the mobMoverEntities hash for faster lookup foreach (var moverComp in _entityLookup.GetComponentsInRange(xform.Coordinates, box.Distance)) { - if (moverComp.Owner == msg.Mover) + if (moverComp.Owner == mover) continue; mobMoverEntities.Add(moverComp.Owner); @@ -57,5 +60,6 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem sprite.Offset = new Vector2(0, 1); entTransform.AttachParent(mob); } + } } diff --git a/Content.Client/CartridgeLoader/CartridgeLoaderBoundUserInterface.cs b/Content.Client/CartridgeLoader/CartridgeLoaderBoundUserInterface.cs index 3ae61b182e..e4d6a9fb8b 100644 --- a/Content.Client/CartridgeLoader/CartridgeLoaderBoundUserInterface.cs +++ b/Content.Client/CartridgeLoader/CartridgeLoaderBoundUserInterface.cs @@ -17,8 +17,11 @@ public abstract class CartridgeLoaderBoundUserInterface : BoundUserInterface [ViewVariables] private Control? _activeUiFragment; + private IEntityManager _entManager; + protected CartridgeLoaderBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) { + _entManager = IoCManager.Resolve(); } protected override void UpdateState(BoundUserInterfaceState state) @@ -31,13 +34,16 @@ public abstract class CartridgeLoaderBoundUserInterface : BoundUserInterface return; } - var programs = GetCartridgeComponents(loaderUiState.Programs); + // TODO move this to a component state and ensure the net ids. + var programs = GetCartridgeComponents(_entManager.GetEntityList(loaderUiState.Programs)); UpdateAvailablePrograms(programs); - _activeProgram = loaderUiState.ActiveUI; + var activeUI = _entManager.GetEntity(loaderUiState.ActiveUI); - var ui = RetrieveCartridgeUI(loaderUiState.ActiveUI); - var comp = RetrieveCartridgeComponent(loaderUiState.ActiveUI); + _activeProgram = activeUI; + + var ui = RetrieveCartridgeUI(activeUI); + var comp = RetrieveCartridgeComponent(activeUI); var control = ui?.GetUIFragmentRoot(); //Prevent the same UI fragment from getting disposed and attached multiple times @@ -60,7 +66,7 @@ public abstract class CartridgeLoaderBoundUserInterface : BoundUserInterface protected void ActivateCartridge(EntityUid cartridgeUid) { - var message = new CartridgeLoaderUiMessage(cartridgeUid, CartridgeUiMessageAction.Activate); + var message = new CartridgeLoaderUiMessage(_entManager.GetNetEntity(cartridgeUid), CartridgeUiMessageAction.Activate); SendMessage(message); } @@ -69,19 +75,19 @@ public abstract class CartridgeLoaderBoundUserInterface : BoundUserInterface if (!_activeProgram.HasValue) return; - var message = new CartridgeLoaderUiMessage(_activeProgram.Value, CartridgeUiMessageAction.Deactivate); + var message = new CartridgeLoaderUiMessage(_entManager.GetNetEntity(_activeProgram.Value), CartridgeUiMessageAction.Deactivate); SendMessage(message); } protected void InstallCartridge(EntityUid cartridgeUid) { - var message = new CartridgeLoaderUiMessage(cartridgeUid, CartridgeUiMessageAction.Install); + var message = new CartridgeLoaderUiMessage(_entManager.GetNetEntity(cartridgeUid), CartridgeUiMessageAction.Install); SendMessage(message); } protected void UninstallCartridge(EntityUid cartridgeUid) { - var message = new CartridgeLoaderUiMessage(cartridgeUid, CartridgeUiMessageAction.Uninstall); + var message = new CartridgeLoaderUiMessage(_entManager.GetNetEntity(cartridgeUid), CartridgeUiMessageAction.Uninstall); SendMessage(message); } @@ -126,7 +132,7 @@ public abstract class CartridgeLoaderBoundUserInterface : BoundUserInterface private void SendCartridgeUiReadyEvent(EntityUid cartridgeUid) { - var message = new CartridgeLoaderUiMessage(cartridgeUid, CartridgeUiMessageAction.UIReady); + var message = new CartridgeLoaderUiMessage(_entManager.GetNetEntity(cartridgeUid), CartridgeUiMessageAction.UIReady); SendMessage(message); } diff --git a/Content.Client/CharacterInfo/CharacterInfoSystem.cs b/Content.Client/CharacterInfo/CharacterInfoSystem.cs index cab9ef7c2f..cd96085d31 100644 --- a/Content.Client/CharacterInfo/CharacterInfoSystem.cs +++ b/Content.Client/CharacterInfo/CharacterInfoSystem.cs @@ -30,7 +30,7 @@ public sealed class CharacterInfoSystem : EntitySystem return; } - RaiseNetworkEvent(new RequestCharacterInfoEvent(entity.Value)); + RaiseNetworkEvent(new RequestCharacterInfoEvent(GetNetEntity(entity.Value))); } private void OnPlayerAttached(PlayerAttachSysMessage msg) @@ -43,7 +43,9 @@ public sealed class CharacterInfoSystem : EntitySystem private void OnCharacterInfoEvent(CharacterInfoEvent msg, EntitySessionEventArgs args) { - var data = new CharacterData(msg.EntityUid, msg.JobTitle, msg.Objectives, msg.Briefing, Name(msg.EntityUid)); + var entity = GetEntity(msg.NetEntity); + var data = new CharacterData(entity, msg.JobTitle, msg.Objectives, msg.Briefing, Name(entity)); + OnCharacterUpdate?.Invoke(data); } diff --git a/Content.Client/Clothing/ClientClothingSystem.cs b/Content.Client/Clothing/ClientClothingSystem.cs index f4489b7f74..b16e14d653 100644 --- a/Content.Client/Clothing/ClientClothingSystem.cs +++ b/Content.Client/Clothing/ClientClothingSystem.cs @@ -169,10 +169,12 @@ public sealed class ClientClothingSystem : ClothingSystem private void OnVisualsChanged(EntityUid uid, InventoryComponent component, VisualsChangedEvent args) { - if (!TryComp(args.Item, out ClothingComponent? clothing) || clothing.InSlot == null) + var item = GetEntity(args.Item); + + if (!TryComp(item, out ClothingComponent? clothing) || clothing.InSlot == null) return; - RenderEquipment(uid, args.Item, clothing.InSlot, component, null, clothing); + RenderEquipment(uid, item, clothing.InSlot, component, null, clothing); } private void OnDidUnequip(EntityUid uid, SpriteComponent component, DidUnequipEvent args) diff --git a/Content.Client/Construction/ConstructionGhostComponent.cs b/Content.Client/Construction/ConstructionGhostComponent.cs index 3c983094f5..8f4fe3867e 100644 --- a/Content.Client/Construction/ConstructionGhostComponent.cs +++ b/Content.Client/Construction/ConstructionGhostComponent.cs @@ -8,6 +8,5 @@ namespace Content.Client.Construction public sealed partial class ConstructionGhostComponent : Component { [ViewVariables] public ConstructionPrototype? Prototype { get; set; } - [ViewVariables] public int GhostId { get; set; } } } diff --git a/Content.Client/Construction/ConstructionPlacementHijack.cs b/Content.Client/Construction/ConstructionPlacementHijack.cs index e2e6ab6692..dc5d7bf342 100644 --- a/Content.Client/Construction/ConstructionPlacementHijack.cs +++ b/Content.Client/Construction/ConstructionPlacementHijack.cs @@ -1,12 +1,7 @@ -using System.Collections.Generic; -using System.Linq; -using Content.Shared.Construction; +using System.Linq; using Content.Shared.Construction.Prototypes; -using Robust.Client.Graphics; using Robust.Client.Placement; using Robust.Client.Utility; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; using Robust.Shared.Map; namespace Content.Client.Construction @@ -39,9 +34,9 @@ namespace Content.Client.Construction /// public override bool HijackDeletion(EntityUid entity) { - if (IoCManager.Resolve().TryGetComponent(entity, out ConstructionGhostComponent? ghost)) + if (IoCManager.Resolve().HasComponent(entity)) { - _constructionSystem.ClearGhost(ghost.GhostId); + _constructionSystem.ClearGhost(entity.GetHashCode()); } return true; } diff --git a/Content.Client/Construction/ConstructionSystem.cs b/Content.Client/Construction/ConstructionSystem.cs index 18790ed00e..98d2dfd414 100644 --- a/Content.Client/Construction/ConstructionSystem.cs +++ b/Content.Client/Construction/ConstructionSystem.cs @@ -27,11 +27,9 @@ namespace Content.Client.Construction [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!; [Dependency] private readonly PopupSystem _popupSystem = default!; - private readonly Dictionary _ghosts = new(); + private readonly Dictionary _ghosts = new(); private readonly Dictionary _guideCache = new(); - private int _nextId; - public bool CraftingEnabled { get; private set; } /// @@ -39,6 +37,7 @@ namespace Content.Client.Construction { base.Initialize(); + UpdatesOutsidePrediction = true; SubscribeLocalEvent(HandlePlayerAttached); SubscribeNetworkEvent(HandleAckStructure); SubscribeNetworkEvent(OnConstructionGuideReceived); @@ -107,6 +106,7 @@ namespace Content.Client.Construction private void HandleAckStructure(AckStructureConstructionMessage msg) { + // We get sent a NetEntity but it actually corresponds to our local Entity. ClearGhost(msg.GhostId); } @@ -150,13 +150,13 @@ namespace Content.Client.Construction private bool HandleUse(in PointerInputCmdHandler.PointerInputCmdArgs args) { - if (!args.EntityUid.IsValid() || !args.EntityUid.IsClientSide()) + if (!args.EntityUid.IsValid() || !IsClientSide(args.EntityUid)) return false; - if (!EntityManager.TryGetComponent(args.EntityUid, out var ghostComp)) + if (!HasComp(args.EntityUid)) return false; - TryStartConstruction(ghostComp.GhostId); + TryStartConstruction(args.EntityUid); return true; } @@ -196,9 +196,8 @@ namespace Content.Client.Construction ghost = EntityManager.SpawnEntity("constructionghost", loc); var comp = EntityManager.GetComponent(ghost.Value); comp.Prototype = prototype; - comp.GhostId = _nextId++; EntityManager.GetComponent(ghost.Value).LocalRotation = dir.ToAngle(); - _ghosts.Add(comp.GhostId, comp); + _ghosts.Add(ghost.Value.Id, ghost.Value); var sprite = EntityManager.GetComponent(ghost.Value); sprite.Color = new Color(48, 255, 48, 128); @@ -247,23 +246,25 @@ namespace Content.Client.Construction { foreach (var ghost in _ghosts) { - if (EntityManager.GetComponent(ghost.Value.Owner).Coordinates.Equals(loc)) return true; + if (EntityManager.GetComponent(ghost.Value).Coordinates.Equals(loc)) + return true; } return false; } - public void TryStartConstruction(int ghostId) + public void TryStartConstruction(EntityUid ghostId, ConstructionGhostComponent? ghostComp = null) { - var ghost = _ghosts[ghostId]; + if (!Resolve(ghostId, ref ghostComp)) + return; - if (ghost.Prototype == null) + if (ghostComp.Prototype == null) { throw new ArgumentException($"Can't start construction for a ghost with no prototype. Ghost id: {ghostId}"); } - var transform = EntityManager.GetComponent(ghost.Owner); - var msg = new TryStartStructureConstructionMessage(transform.Coordinates, ghost.Prototype.ID, transform.LocalRotation, ghostId); + var transform = EntityManager.GetComponent(ghostId); + var msg = new TryStartStructureConstructionMessage(GetNetCoordinates(transform.Coordinates), ghostComp.Prototype.ID, transform.LocalRotation, ghostId.Id); RaiseNetworkEvent(msg); } @@ -280,11 +281,11 @@ namespace Content.Client.Construction /// public void ClearGhost(int ghostId) { - if (_ghosts.TryGetValue(ghostId, out var ghost)) - { - EntityManager.QueueDeleteEntity(ghost.Owner); - _ghosts.Remove(ghostId); - } + if (!_ghosts.TryGetValue(ghostId, out var ghost)) + return; + + EntityManager.QueueDeleteEntity(ghost); + _ghosts.Remove(ghostId); } /// @@ -292,9 +293,9 @@ namespace Content.Client.Construction /// public void ClearAllGhosts() { - foreach (var (_, ghost) in _ghosts) + foreach (var ghost in _ghosts.Values) { - EntityManager.QueueDeleteEntity(ghost.Owner); + EntityManager.QueueDeleteEntity(ghost); } _ghosts.Clear(); diff --git a/Content.Client/ContextMenu/UI/EntityMenuElement.cs b/Content.Client/ContextMenu/UI/EntityMenuElement.cs index b16559b58f..cdd171a6e7 100644 --- a/Content.Client/ContextMenu/UI/EntityMenuElement.cs +++ b/Content.Client/ContextMenu/UI/EntityMenuElement.cs @@ -49,7 +49,8 @@ namespace Content.Client.ContextMenu.UI private string? SearchPlayerName(EntityUid entity) { - return _adminSystem.PlayerList.FirstOrDefault(player => player.EntityUid == entity)?.Username; + var netEntity = _entityManager.GetNetEntity(entity); + return _adminSystem.PlayerList.FirstOrDefault(player => player.NetEntity == netEntity)?.Username; } /// @@ -77,12 +78,12 @@ namespace Content.Client.ContextMenu.UI var representation = _entityManager.ToPrettyString(entity); var name = representation.Name; - var id = representation.Uid; + var id = representation.Uid.ToString(); var prototype = representation.Prototype; var playerName = representation.Session?.Name ?? SearchPlayerName(entity); var deleted = representation.Deleted; - return $"{name} ({id}{(prototype != null ? $", {prototype}" : "")}{(playerName != null ? $", {playerName}" : "")}){(deleted ? "D" : "")}"; + return $"{name} ({id} / {_entityManager.GetNetEntity(entity).ToString()}{(prototype != null ? $", {prototype}" : "")}{(playerName != null ? $", {playerName}" : "")}){(deleted ? "D" : "")}"; } private string GetEntityDescription(EntityUid entity) diff --git a/Content.Client/ContextMenu/UI/EntityMenuUIController.cs b/Content.Client/ContextMenu/UI/EntityMenuUIController.cs index 6ca8d95db7..03d5a9486b 100644 --- a/Content.Client/ContextMenu/UI/EntityMenuUIController.cs +++ b/Content.Client/ContextMenu/UI/EntityMenuUIController.cs @@ -133,8 +133,16 @@ namespace Content.Client.ContextMenu.UI var func = args.Function; var funcId = _inputManager.NetworkBindMap.KeyFunctionID(func); - var message = new FullInputCmdMessage(_gameTiming.CurTick, _gameTiming.TickFraction, funcId, - BoundKeyState.Down, _entityManager.GetComponent(entity.Value).Coordinates, args.PointerLocation, entity.Value); + var message = new ClientFullInputCmdMessage( + _gameTiming.CurTick, + _gameTiming.TickFraction, + funcId) + { + State = BoundKeyState.Down, + Coordinates = _entityManager.GetComponent(entity.Value).Coordinates, + ScreenCoordinates = args.PointerLocation, + Uid = entity.Value, + }; var session = _playerManager.LocalPlayer?.Session; if (session != null) diff --git a/Content.Client/CrewManifest/CrewManifestSystem.cs b/Content.Client/CrewManifest/CrewManifestSystem.cs index d821117f6b..05f27620c4 100644 --- a/Content.Client/CrewManifest/CrewManifestSystem.cs +++ b/Content.Client/CrewManifest/CrewManifestSystem.cs @@ -30,10 +30,10 @@ public sealed class CrewManifestSystem : EntitySystem /// /// Requests a crew manifest from the server. /// - /// EntityUid of the entity we're requesting the crew manifest from. - public void RequestCrewManifest(EntityUid uid) + /// EntityUid of the entity we're requesting the crew manifest from. + public void RequestCrewManifest(NetEntity netEntity) { - RaiseNetworkEvent(new RequestCrewManifestMessage(uid)); + RaiseNetworkEvent(new RequestCrewManifestMessage(netEntity)); } private void OnPrototypesReload(PrototypesReloadedEventArgs _) diff --git a/Content.Client/Decals/DecalPlacementSystem.cs b/Content.Client/Decals/DecalPlacementSystem.cs index 03248f4355..c97f8281a1 100644 --- a/Content.Client/Decals/DecalPlacementSystem.cs +++ b/Content.Client/Decals/DecalPlacementSystem.cs @@ -70,7 +70,7 @@ public sealed class DecalPlacementSystem : EntitySystem return false; var decal = new Decal(coords.Position, _decalId, _decalColor, _decalAngle, _zIndex, _cleanable); - RaiseNetworkEvent(new RequestDecalPlacementEvent(decal, coords)); + RaiseNetworkEvent(new RequestDecalPlacementEvent(decal, GetNetCoordinates(coords))); return true; }, @@ -90,7 +90,7 @@ public sealed class DecalPlacementSystem : EntitySystem _erasing = true; - RaiseNetworkEvent(new RequestDecalRemovalEvent(coords)); + RaiseNetworkEvent(new RequestDecalRemovalEvent(GetNetCoordinates(coords))); return true; }, (session, coords, uid) => @@ -128,7 +128,7 @@ public sealed class DecalPlacementSystem : EntitySystem args.Target = args.Target.Offset(new Vector2(-0.5f, -0.5f)); var decal = new Decal(args.Target.Position, args.DecalId, args.Color, Angle.FromDegrees(args.Rotation), args.ZIndex, args.Cleanable); - RaiseNetworkEvent(new RequestDecalPlacementEvent(decal, args.Target)); + RaiseNetworkEvent(new RequestDecalPlacementEvent(decal, GetNetCoordinates(args.Target))); } private void OnFillSlot(FillActionSlotEvent ev) diff --git a/Content.Client/Decals/DecalSystem.cs b/Content.Client/Decals/DecalSystem.cs index 159efced01..66b30545da 100644 --- a/Content.Client/Decals/DecalSystem.cs +++ b/Content.Client/Decals/DecalSystem.cs @@ -92,13 +92,16 @@ namespace Content.Client.Decals private void OnChunkUpdate(DecalChunkUpdateEvent ev) { - foreach (var (gridId, updatedGridChunks) in ev.Data) + foreach (var (netGrid, updatedGridChunks) in ev.Data) { - if (updatedGridChunks.Count == 0) continue; + if (updatedGridChunks.Count == 0) + continue; + + var gridId = GetEntity(netGrid); if (!TryComp(gridId, out DecalGridComponent? gridComp)) { - Logger.Error($"Received decal information for an entity without a decal component: {ToPrettyString(gridId)}"); + Log.Error($"Received decal information for an entity without a decal component: {ToPrettyString(gridId)}"); continue; } @@ -106,13 +109,16 @@ namespace Content.Client.Decals } // Now we'll cull old chunks out of range as the server will send them to us anyway. - foreach (var (gridId, chunks) in ev.RemovedChunks) + foreach (var (netGrid, chunks) in ev.RemovedChunks) { - if (chunks.Count == 0) continue; + if (chunks.Count == 0) + continue; + + var gridId = GetEntity(netGrid); if (!TryComp(gridId, out DecalGridComponent? gridComp)) { - Logger.Error($"Received decal information for an entity without a decal component: {ToPrettyString(gridId)}"); + Log.Error($"Received decal information for an entity without a decal component: {ToPrettyString(gridId)}"); continue; } diff --git a/Content.Client/Disposal/Systems/DisposalUnitSystem.cs b/Content.Client/Disposal/Systems/DisposalUnitSystem.cs index 6c9aea8b9f..d10101754c 100644 --- a/Content.Client/Disposal/Systems/DisposalUnitSystem.cs +++ b/Content.Client/Disposal/Systems/DisposalUnitSystem.cs @@ -46,7 +46,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem component.Powered = state.Powered; component.Engaged = state.Engaged; component.RecentlyEjected.Clear(); - component.RecentlyEjected.AddRange(state.RecentlyEjected); + component.RecentlyEjected.AddRange(EnsureEntityList(state.RecentlyEjected, uid)); } public override bool HasDisposals(EntityUid? uid) diff --git a/Content.Client/DragDrop/DragDropSystem.cs b/Content.Client/DragDrop/DragDropSystem.cs index 84bc63a3b6..23bd662d82 100644 --- a/Content.Client/DragDrop/DragDropSystem.cs +++ b/Content.Client/DragDrop/DragDropSystem.cs @@ -193,27 +193,29 @@ public sealed class DragDropSystem : SharedDragDropSystem // the mouse, canceling the drag, but just being cautious) EndDrag(); + var entity = args.EntityUid; + // possibly initiating a drag // check if the clicked entity is draggable - if (!Exists(args.EntityUid)) + if (!Exists(entity)) { return false; } // check if the entity is reachable - if (!_interactionSystem.InRangeUnobstructed(dragger, args.EntityUid)) + if (!_interactionSystem.InRangeUnobstructed(dragger, entity)) { return false; } var ev = new CanDragEvent(); - RaiseLocalEvent(args.EntityUid, ref ev); + RaiseLocalEvent(entity, ref ev); if (ev.Handled != true) return false; - _draggedEntity = args.EntityUid; + _draggedEntity = entity; _state = DragState.MouseDown; _mouseDownScreenPos = _inputManager.MouseScreenPosition; _mouseDownTime = 0; @@ -309,14 +311,32 @@ public sealed class DragDropSystem : SharedDragDropSystem // adjust the timing info based on the current tick so it appears as if it happened now var replayMsg = savedValue.OriginalMessage; - var adjustedInputMsg = new FullInputCmdMessage(args.OriginalMessage.Tick, - args.OriginalMessage.SubTick, - replayMsg.InputFunctionId, replayMsg.State, replayMsg.Coordinates, replayMsg.ScreenCoordinates, - replayMsg.Uid); + switch (replayMsg) + { + case ClientFullInputCmdMessage clientInput: + replayMsg = new ClientFullInputCmdMessage(args.OriginalMessage.Tick, + args.OriginalMessage.SubTick, + replayMsg.InputFunctionId) + { + State = replayMsg.State, + Coordinates = clientInput.Coordinates, + ScreenCoordinates = clientInput.ScreenCoordinates, + Uid = clientInput.Uid, + }; + break; + case FullInputCmdMessage fullInput: + replayMsg = new FullInputCmdMessage(args.OriginalMessage.Tick, + args.OriginalMessage.SubTick, + replayMsg.InputFunctionId, replayMsg.State, fullInput.Coordinates, fullInput.ScreenCoordinates, + fullInput.Uid); + break; + default: + throw new ArgumentOutOfRangeException(); + } if (savedValue.Session != null) { - _inputSystem.HandleInputCommand(savedValue.Session, EngineKeyFunctions.Use, adjustedInputMsg, + _inputSystem.HandleInputCommand(savedValue.Session, EngineKeyFunctions.Use, replayMsg, true); } @@ -340,10 +360,11 @@ public sealed class DragDropSystem : SharedDragDropSystem } IEnumerable entities; + var coords = args.Coordinates; if (_stateManager.CurrentState is GameplayState screen) { - entities = screen.GetClickableEntities(args.Coordinates); + entities = screen.GetClickableEntities(coords); } else { @@ -371,7 +392,7 @@ public sealed class DragDropSystem : SharedDragDropSystem } // tell the server about the drop attempt - RaiseNetworkEvent(new DragDropRequestEvent(_draggedEntity.Value, entity)); + RaiseNetworkEvent(new DragDropRequestEvent(GetNetEntity(_draggedEntity.Value), GetNetEntity(entity))); EndDrag(); return true; } diff --git a/Content.Client/Effects/ColorFlashEffectSystem.cs b/Content.Client/Effects/ColorFlashEffectSystem.cs index dca675b8df..34acb7f370 100644 --- a/Content.Client/Effects/ColorFlashEffectSystem.cs +++ b/Content.Client/Effects/ColorFlashEffectSystem.cs @@ -31,7 +31,7 @@ public sealed class ColorFlashEffectSystem : SharedColorFlashEffectSystem if (!_timing.IsFirstTimePredicted) return; - OnColorFlashEffect(new ColorFlashEffectEvent(color, entities)); + OnColorFlashEffect(new ColorFlashEffectEvent(color, GetNetEntityList(entities))); } private void OnEffectAnimationCompleted(EntityUid uid, ColorFlashEffectComponent component, AnimationCompletedEvent args) @@ -77,8 +77,10 @@ public sealed class ColorFlashEffectSystem : SharedColorFlashEffectSystem { var color = ev.Color; - foreach (var ent in ev.Entities) + foreach (var nent in ev.Entities) { + var ent = GetEntity(nent); + if (Deleted(ent)) { continue; diff --git a/Content.Client/Examine/ExamineSystem.cs b/Content.Client/Examine/ExamineSystem.cs index 9b55b62281..914ec21527 100644 --- a/Content.Client/Examine/ExamineSystem.cs +++ b/Content.Client/Examine/ExamineSystem.cs @@ -110,19 +110,21 @@ namespace Content.Client.Examine private bool HandleExamine(in PointerInputCmdHandler.PointerInputCmdArgs args) { - if (!args.EntityUid.IsValid() || !EntityManager.EntityExists(args.EntityUid)) + var entity = args.EntityUid; + + if (!args.EntityUid.IsValid() || !EntityManager.EntityExists(entity)) { return false; } _playerEntity = _playerManager.LocalPlayer?.ControlledEntity ?? default; - if (_playerEntity == default || !CanExamine(_playerEntity, args.EntityUid)) + if (_playerEntity == default || !CanExamine(_playerEntity, entity)) { return false; } - DoExamine(args.EntityUid); + DoExamine(entity); return true; } @@ -157,8 +159,10 @@ namespace Content.Client.Examine // Tooltips coming in from the server generally prioritize // opening at the old tooltip rather than the cursor/another entity, // since there's probably one open already if it's coming in from the server. - OpenTooltip(player.Value, ev.EntityUid, ev.CenterAtCursor, ev.OpenAtOldTooltip, ev.KnowTarget); - UpdateTooltipInfo(player.Value, ev.EntityUid, ev.Message, ev.Verbs); + var entity = GetEntity(ev.EntityUid); + + OpenTooltip(player.Value, entity, ev.CenterAtCursor, ev.OpenAtOldTooltip, ev.KnowTarget); + UpdateTooltipInfo(player.Value, entity, ev.Message, ev.Verbs); } public override void SendExamineTooltip(EntityUid player, EntityUid target, FormattedMessage message, bool getVerbs, bool centerAtCursor) @@ -358,12 +362,10 @@ namespace Content.Client.Examine FormattedMessage message; // Basically this just predicts that we can't make out the entity if we have poor vision. - var canSeeClearly = true; - if (HasComp(playerEnt)) - canSeeClearly = false; + var canSeeClearly = !HasComp(playerEnt); OpenTooltip(playerEnt.Value, entity, centeredOnCursor, false, knowTarget: canSeeClearly); - if (entity.IsClientSide() + if (IsClientSide(entity) || _client.RunLevel == ClientRunLevel.SinglePlayerGame) // i.e. a replay { message = GetExamineText(entity, playerEnt); @@ -376,7 +378,7 @@ namespace Content.Client.Examine _idCounter += 1; if (_idCounter == int.MaxValue) _idCounter = 0; - RaiseNetworkEvent(new ExamineSystemMessages.RequestExamineInfoMessage(entity, _idCounter, true)); + RaiseNetworkEvent(new ExamineSystemMessages.RequestExamineInfoMessage(GetNetEntity(entity), _idCounter, true)); } RaiseLocalEvent(entity, new ClientExaminedEvent(entity, playerEnt.Value)); diff --git a/Content.Client/Explosion/ExplosionOverlaySystem.cs b/Content.Client/Explosion/ExplosionOverlaySystem.cs index d182c0be2d..289d217202 100644 --- a/Content.Client/Explosion/ExplosionOverlaySystem.cs +++ b/Content.Client/Explosion/ExplosionOverlaySystem.cs @@ -4,6 +4,7 @@ using Robust.Client.Graphics; using Robust.Client.ResourceManagement; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; +using Robust.Shared.Utility; namespace Content.Client.Explosion; @@ -39,7 +40,13 @@ public sealed class ExplosionOverlaySystem : EntitySystem component.Epicenter = state.Epicenter; component.SpaceTiles = state.SpaceTiles; - component.Tiles = state.Tiles; + component.Tiles.Clear(); + + foreach (var (nent, data) in state.Tiles) + { + component.Tiles[GetEntity(nent)] = data; + } + component.Intensity = state.Intensity; component.ExplosionType = state.ExplosionType; component.SpaceMatrix = state.SpaceMatrix; diff --git a/Content.Client/Fax/AdminUI/AdminFaxEui.cs b/Content.Client/Fax/AdminUI/AdminFaxEui.cs index 695c68e60d..239f0ecc93 100644 --- a/Content.Client/Fax/AdminUI/AdminFaxEui.cs +++ b/Content.Client/Fax/AdminUI/AdminFaxEui.cs @@ -8,14 +8,16 @@ namespace Content.Client.Fax.AdminUI; [UsedImplicitly] public sealed class AdminFaxEui : BaseEui { + private IEntityManager _entManager; private readonly AdminFaxWindow _window; public AdminFaxEui() { + _entManager = IoCManager.Resolve(); _window = new AdminFaxWindow(); _window.OnClose += () => SendMessage(new AdminFaxEuiMsg.Close()); - _window.OnFollowFax += uid => SendMessage(new AdminFaxEuiMsg.Follow(uid)); - _window.OnMessageSend += args => SendMessage(new AdminFaxEuiMsg.Send(args.uid, args.title, + _window.OnFollowFax += uid => SendMessage(new AdminFaxEuiMsg.Follow(_entManager.GetNetEntity(uid))); + _window.OnMessageSend += args => SendMessage(new AdminFaxEuiMsg.Send(_entManager.GetNetEntity(args.uid), args.title, args.stampedBy, args.message, args.stampSprite, args.stampColor)); } diff --git a/Content.Client/Fluids/PuddleDebugOverlaySystem.cs b/Content.Client/Fluids/PuddleDebugOverlaySystem.cs index 345e4b7fa6..cec372cb0b 100644 --- a/Content.Client/Fluids/PuddleDebugOverlaySystem.cs +++ b/Content.Client/Fluids/PuddleDebugOverlaySystem.cs @@ -20,7 +20,7 @@ public sealed class PuddleDebugOverlaySystem : SharedPuddleDebugOverlaySystem private void RenderDebugData(PuddleOverlayDebugMessage message) { - TileData[message.GridUid] = message; + TileData[GetEntity(message.GridUid)] = message; if (_overlay != null) return; diff --git a/Content.Client/GameTicking/Managers/ClientGameTicker.cs b/Content.Client/GameTicking/Managers/ClientGameTicker.cs index 7c94a60aad..dd07f78d94 100644 --- a/Content.Client/GameTicking/Managers/ClientGameTicker.cs +++ b/Content.Client/GameTicking/Managers/ClientGameTicker.cs @@ -22,8 +22,8 @@ namespace Content.Client.GameTicking.Managers [Dependency] private readonly SharedAudioSystem _audio = default!; [ViewVariables] private bool _initialized; - private Dictionary> _jobsAvailable = new(); - private Dictionary _stationNames = new(); + private Dictionary> _jobsAvailable = new(); + private Dictionary _stationNames = new(); /// /// The current round-end window. Could be used to support re-opening the window after closing it. @@ -41,14 +41,14 @@ namespace Content.Client.GameTicking.Managers [ViewVariables] public TimeSpan RoundStartTimeSpan { get; private set; } [ViewVariables] public new bool Paused { get; private set; } - [ViewVariables] public IReadOnlyDictionary> JobsAvailable => _jobsAvailable; - [ViewVariables] public IReadOnlyDictionary StationNames => _stationNames; + [ViewVariables] public IReadOnlyDictionary> JobsAvailable => _jobsAvailable; + [ViewVariables] public IReadOnlyDictionary StationNames => _stationNames; public event Action? InfoBlobUpdated; public event Action? LobbyStatusUpdated; public event Action? LobbySongUpdated; public event Action? LobbyLateJoinStatusUpdated; - public event Action>>? LobbyJobsAvailableUpdated; + public event Action>>? LobbyJobsAvailableUpdated; public override void Initialize() { @@ -89,8 +89,18 @@ namespace Content.Client.GameTicking.Managers private void UpdateJobsAvailable(TickerJobsAvailableEvent message) { - _jobsAvailable = message.JobsAvailableByStation; - _stationNames = message.StationNames; + foreach (var (job, data) in message.JobsAvailableByStation) + { + _jobsAvailable.Clear(); + _jobsAvailable[job] = data; + } + + _stationNames.Clear(); + foreach (var weh in message.StationNames) + { + _stationNames[weh.Key] = weh.Value; + } + LobbyJobsAvailableUpdated?.Invoke(JobsAvailable); } diff --git a/Content.Client/Gameplay/GameplayStateBase.cs b/Content.Client/Gameplay/GameplayStateBase.cs index bd9d7b4499..87fe257cd0 100644 --- a/Content.Client/Gameplay/GameplayStateBase.cs +++ b/Content.Client/Gameplay/GameplayStateBase.cs @@ -174,9 +174,13 @@ namespace Content.Client.Gameplay EntityCoordinates.FromMap(_mapManager, mousePosWorld); } - var message = new FullInputCmdMessage(_timing.CurTick, _timing.TickFraction, funcId, kArgs.State, - coordinates , kArgs.PointerLocation, - entityToClick ?? default); // TODO make entityUid nullable + var message = new ClientFullInputCmdMessage(_timing.CurTick, _timing.TickFraction, funcId) + { + State = kArgs.State, + Coordinates = coordinates, + ScreenCoordinates = kArgs.PointerLocation, + Uid = entityToClick ?? default, + }; // TODO make entityUid nullable // client side command handlers will always be sent the local player session. var session = _playerManager.LocalPlayer?.Session; diff --git a/Content.Client/Gateway/UI/GatewayBoundUserInterface.cs b/Content.Client/Gateway/UI/GatewayBoundUserInterface.cs index 9478f0ab45..53b23272d4 100644 --- a/Content.Client/Gateway/UI/GatewayBoundUserInterface.cs +++ b/Content.Client/Gateway/UI/GatewayBoundUserInterface.cs @@ -20,7 +20,7 @@ public sealed class GatewayBoundUserInterface : BoundUserInterface _window = new GatewayWindow(); _window.OpenPortal += destination => { - SendMessage(new GatewayOpenPortalMessage(destination)); + SendMessage(new GatewayOpenPortalMessage(EntMan.GetNetEntity(destination))); }; _window.OnClose += Close; _window?.OpenCentered(); diff --git a/Content.Client/Gateway/UI/GatewayWindow.xaml.cs b/Content.Client/Gateway/UI/GatewayWindow.xaml.cs index b070cf3176..c20b5e1a70 100644 --- a/Content.Client/Gateway/UI/GatewayWindow.xaml.cs +++ b/Content.Client/Gateway/UI/GatewayWindow.xaml.cs @@ -16,10 +16,11 @@ namespace Content.Client.Gateway.UI; public sealed partial class GatewayWindow : FancyWindow, IComputerWindow { + private readonly IEntityManager _entManager; private readonly IGameTiming _timing; public event Action? OpenPortal; - private List<(EntityUid, string, TimeSpan, bool)> _destinations = default!; + private List<(NetEntity, string, TimeSpan, bool)> _destinations = default!; private EntityUid? _current; private TimeSpan _nextClose; private TimeSpan _lastOpen; @@ -29,13 +30,15 @@ public sealed partial class GatewayWindow : FancyWindow, public GatewayWindow() { RobustXamlLoader.Load(this); - _timing = IoCManager.Resolve(); + var dependencies = IoCManager.Instance!; + _entManager = dependencies.Resolve(); + _timing = dependencies.Resolve(); } public void UpdateState(GatewayBoundUserInterfaceState state) { _destinations = state.Destinations; - _current = state.Current; + _current = _entManager.GetEntity(state.Current); _nextClose = state.NextClose; _lastOpen = state.LastOpen; @@ -64,7 +67,7 @@ public sealed partial class GatewayWindow : FancyWindow, var now = _timing.CurTime; foreach (var dest in _destinations) { - var uid = dest.Item1; + var uid = _entManager.GetEntity(dest.Item1); var name = dest.Item2; var nextReady = dest.Item3; var busy = dest.Item4; @@ -101,7 +104,7 @@ public sealed partial class GatewayWindow : FancyWindow, OpenPortal?.Invoke(uid); }; - if (uid == state.Current) + if (uid == _entManager.GetEntity(state.Current)) { openButton.AddStyleClass(StyleBase.ButtonCaution); } diff --git a/Content.Client/Hands/Systems/HandsSystem.cs b/Content.Client/Hands/Systems/HandsSystem.cs index d8cc822cbd..773ec1491f 100644 --- a/Content.Client/Hands/Systems/HandsSystem.cs +++ b/Content.Client/Hands/Systems/HandsSystem.cs @@ -124,7 +124,7 @@ namespace Content.Client.Hands.Systems #region PickupAnimation private void HandlePickupAnimation(PickupAnimationEvent msg) { - PickupAnimation(msg.ItemUid, msg.InitialPosition, msg.FinalPosition, msg.InitialAngle); + PickupAnimation(GetEntity(msg.ItemUid), GetCoordinates(msg.InitialPosition), msg.FinalPosition, msg.InitialAngle); } public override void PickupAnimation(EntityUid item, EntityCoordinates initialPosition, Vector2 finalPosition, Angle initialAngle, @@ -382,7 +382,7 @@ namespace Content.Client.Hands.Systems // update hands visuals if this item is in a hand (rather then inventory or other container). if (component.Hands.TryGetValue(args.ContainerId, out var hand)) { - UpdateHandVisuals(uid, args.Item, hand, component); + UpdateHandVisuals(uid, GetEntity(args.Item), hand, component); } } #endregion diff --git a/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs b/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs index 2f5431e935..a2f1a4dc5a 100644 --- a/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs +++ b/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs @@ -24,13 +24,16 @@ namespace Content.Client.HealthAnalyzer.UI { var text = new StringBuilder(); var entities = IoCManager.Resolve(); + var target = entities.GetEntity(msg.TargetEntity); - if (msg.TargetEntity != null && entities.TryGetComponent(msg.TargetEntity, out var damageable)) + if (msg.TargetEntity != null && entities.TryGetComponent(target, out var damageable)) { string entityName = "Unknown"; if (msg.TargetEntity != null && - entities.TryGetComponent(msg.TargetEntity.Value, out var metaData)) - entityName = Identity.Name(msg.TargetEntity.Value, entities); + entities.HasComponent(target.Value)) + { + entityName = Identity.Name(target.Value, entities); + } IReadOnlyDictionary damagePerGroup = damageable.DamagePerGroup; IReadOnlyDictionary damagePerType = damageable.Damage.DamageDict; diff --git a/Content.Client/Humanoid/HumanoidAppearanceSystem.cs b/Content.Client/Humanoid/HumanoidAppearanceSystem.cs index 05c9f2eb52..76f1aaaec8 100644 --- a/Content.Client/Humanoid/HumanoidAppearanceSystem.cs +++ b/Content.Client/Humanoid/HumanoidAppearanceSystem.cs @@ -197,7 +197,7 @@ public sealed class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem profile.Appearance.EyeColor, _markingManager); - DebugTools.Assert(uid.IsClientSide()); + DebugTools.Assert(IsClientSide(uid)); var state = new HumanoidAppearanceState(markings, new(), diff --git a/Content.Client/Instruments/InstrumentSystem.cs b/Content.Client/Instruments/InstrumentSystem.cs index 02e3cf0da3..0b969b6efd 100644 --- a/Content.Client/Instruments/InstrumentSystem.cs +++ b/Content.Client/Instruments/InstrumentSystem.cs @@ -54,10 +54,10 @@ public sealed class InstrumentSystem : SharedInstrumentSystem public void SetMaster(EntityUid uid, EntityUid? masterUid) { - if (!TryComp(uid, out InstrumentComponent? instrument)) + if (!HasComp(uid)) return; - RaiseNetworkEvent(new InstrumentSetMasterEvent(uid, masterUid)); + RaiseNetworkEvent(new InstrumentSetMasterEvent(GetNetEntity(uid), GetNetEntity(masterUid))); } public void SetFilteredChannel(EntityUid uid, int channel, bool value) @@ -68,7 +68,7 @@ public sealed class InstrumentSystem : SharedInstrumentSystem if(value) instrument.Renderer?.SendMidiEvent(RobustMidiEvent.AllNotesOff((byte)channel, 0), false); - RaiseNetworkEvent(new InstrumentSetFilteredChannelEvent(uid, channel, value)); + RaiseNetworkEvent(new InstrumentSetFilteredChannelEvent(GetNetEntity(uid), channel, value)); } public override void SetupRenderer(EntityUid uid, bool fromStateChange, SharedInstrumentComponent? component = null) @@ -109,7 +109,7 @@ public sealed class InstrumentSystem : SharedInstrumentSystem if (!fromStateChange) { - RaiseNetworkEvent(new InstrumentStartMidiEvent(uid)); + RaiseNetworkEvent(new InstrumentStartMidiEvent(GetNetEntity(uid))); } } @@ -189,7 +189,7 @@ public sealed class InstrumentSystem : SharedInstrumentSystem if (!fromStateChange && _netManager.IsConnected) { - RaiseNetworkEvent(new InstrumentStopMidiEvent(uid)); + RaiseNetworkEvent(new InstrumentStopMidiEvent(GetNetEntity(uid))); } } @@ -282,7 +282,7 @@ public sealed class InstrumentSystem : SharedInstrumentSystem private void OnMidiEventRx(InstrumentMidiEventEvent midiEv) { - var uid = midiEv.Uid; + var uid = GetEntity(midiEv.Uid); if (!TryComp(uid, out InstrumentComponent? instrument)) return; @@ -354,12 +354,12 @@ public sealed class InstrumentSystem : SharedInstrumentSystem private void OnMidiStart(InstrumentStartMidiEvent ev) { - SetupRenderer(ev.Uid, true); + SetupRenderer(GetEntity(ev.Uid), true); } private void OnMidiStop(InstrumentStopMidiEvent ev) { - EndRenderer(ev.Uid, true); + EndRenderer(GetEntity(ev.Uid), true); } public override void Update(float frameTime) @@ -425,7 +425,7 @@ public sealed class InstrumentSystem : SharedInstrumentSystem if (eventCount == 0) continue; - RaiseNetworkEvent(new InstrumentMidiEventEvent(uid, events)); + RaiseNetworkEvent(new InstrumentMidiEventEvent(GetNetEntity(uid), events)); instrument.SentWithinASec += eventCount; diff --git a/Content.Client/Instruments/UI/BandMenu.xaml.cs b/Content.Client/Instruments/UI/BandMenu.xaml.cs index a225fcdfd6..5fb293a194 100644 --- a/Content.Client/Instruments/UI/BandMenu.xaml.cs +++ b/Content.Client/Instruments/UI/BandMenu.xaml.cs @@ -32,12 +32,13 @@ public sealed partial class BandMenu : DefaultWindow Timer.Spawn(0, Close); } - public void Populate((EntityUid, string)[] nearby) + public void Populate((NetEntity, string)[] nearby, IEntityManager entManager) { BandList.Clear(); - foreach (var (uid, name) in nearby) + foreach (var (nent, name) in nearby) { + var uid = entManager.GetEntity(nent); var item = BandList.AddItem(name, null, true, uid); item.Selected = _owner.Instrument?.Master == uid; } diff --git a/Content.Client/Instruments/UI/InstrumentBoundUserInterface.cs b/Content.Client/Instruments/UI/InstrumentBoundUserInterface.cs index d88eb94130..2a846ff708 100644 --- a/Content.Client/Instruments/UI/InstrumentBoundUserInterface.cs +++ b/Content.Client/Instruments/UI/InstrumentBoundUserInterface.cs @@ -10,15 +10,15 @@ namespace Content.Client.Instruments.UI { public sealed class InstrumentBoundUserInterface : BoundUserInterface { - [Dependency] public readonly IEntityManager Entities = default!; + public IEntityManager Entities => EntMan; [Dependency] public readonly IMidiManager MidiManager = default!; [Dependency] public readonly IFileDialogManager FileDialogManager = default!; [Dependency] public readonly IPlayerManager PlayerManager = default!; [Dependency] public readonly ILocalizationManager Loc = default!; - public readonly InstrumentSystem Instruments = default!; - public readonly ActionBlockerSystem ActionBlocker = default!; - public readonly SharedInteractionSystem Interactions = default!; + public readonly InstrumentSystem Instruments; + public readonly ActionBlockerSystem ActionBlocker; + public readonly SharedInteractionSystem Interactions; [ViewVariables] private InstrumentMenu? _instrumentMenu; [ViewVariables] private BandMenu? _bandMenu; @@ -40,7 +40,7 @@ namespace Content.Client.Instruments.UI switch (message) { case InstrumentBandResponseBuiMessage bandRx: - _bandMenu?.Populate(bandRx.Nearby); + _bandMenu?.Populate(bandRx.Nearby, EntMan); break; default: break; diff --git a/Content.Client/Inventory/ClientInventorySystem.cs b/Content.Client/Inventory/ClientInventorySystem.cs index 5813d69524..e74df5d570 100644 --- a/Content.Client/Inventory/ClientInventorySystem.cs +++ b/Content.Client/Inventory/ClientInventorySystem.cs @@ -282,7 +282,7 @@ namespace Content.Client.Inventory return; EntityManager.RaisePredictiveEvent( - new InteractInventorySlotEvent(item.Value, altInteract: false)); + new InteractInventorySlotEvent(GetNetEntity(item.Value), altInteract: false)); } public void UIInventoryAltActivateItem(string slot, EntityUid uid) @@ -290,7 +290,7 @@ namespace Content.Client.Inventory if (!TryGetSlotEntity(uid, slot, out var item)) return; - EntityManager.RaisePredictiveEvent(new InteractInventorySlotEvent(item.Value, altInteract: true)); + EntityManager.RaisePredictiveEvent(new InteractInventorySlotEvent(GetNetEntity(item.Value), altInteract: true)); } public sealed class SlotData diff --git a/Content.Client/Items/Systems/ItemSystem.cs b/Content.Client/Items/Systems/ItemSystem.cs index 7ddc7d6c6d..e406ba2b55 100644 --- a/Content.Client/Items/Systems/ItemSystem.cs +++ b/Content.Client/Items/Systems/ItemSystem.cs @@ -44,7 +44,7 @@ public sealed class ItemSystem : SharedItemSystem { // if the item is in a container, it might be equipped to hands or inventory slots --> update visuals. if (Container.TryGetContainingContainer(uid, out var container)) - RaiseLocalEvent(container.Owner, new VisualsChangedEvent(uid, container.ID)); + RaiseLocalEvent(container.Owner, new VisualsChangedEvent(GetNetEntity(uid), container.ID)); } /// diff --git a/Content.Client/Kitchen/UI/GrinderMenu.xaml.cs b/Content.Client/Kitchen/UI/GrinderMenu.xaml.cs index 79f212bbf6..1822dd7fff 100644 --- a/Content.Client/Kitchen/UI/GrinderMenu.xaml.cs +++ b/Content.Client/Kitchen/UI/GrinderMenu.xaml.cs @@ -57,7 +57,9 @@ namespace Content.Client.Kitchen.UI ChamberContentBox.EjectButton.Disabled = state.ChamberContents.Length <= 0; GrindButton.Disabled = !state.CanGrind || !state.Powered; JuiceButton.Disabled = !state.CanJuice || !state.Powered; - RefreshContentsDisplay(state.ReagentQuantities, state.ChamberContents, state.HasBeakerIn); + + // TODO move this to a component state and ensure the net ids. + RefreshContentsDisplay(state.ReagentQuantities, _entityManager.GetEntityArray(state.ChamberContents), state.HasBeakerIn); } public void HandleMessage(BoundUserInterfaceMessage message) diff --git a/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs b/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs index 968d9f30a2..deadff91fc 100644 --- a/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs +++ b/Content.Client/Kitchen/UI/MicrowaveBoundUserInterface.cs @@ -20,8 +20,11 @@ namespace Content.Client.Kitchen.UI [ViewVariables] private readonly Dictionary _reagents = new(); + private IEntityManager _entManager; + public MicrowaveBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) { + _entManager = IoCManager.Resolve(); } protected override void Open() @@ -34,7 +37,7 @@ namespace Content.Client.Kitchen.UI _menu.EjectButton.OnPressed += _ => SendMessage(new MicrowaveEjectMessage()); _menu.IngredientsList.OnItemSelected += args => { - SendMessage(new MicrowaveEjectSolidIndexedMessage(_solids[args.ItemIndex])); + SendMessage(new MicrowaveEjectSolidIndexedMessage(EntMan.GetNetEntity(_solids[args.ItemIndex]))); }; _menu.OnCookTimeSelected += (args, buttonIndex) => @@ -57,7 +60,6 @@ namespace Content.Client.Kitchen.UI _menu?.Dispose(); } - protected override void UpdateState(BoundUserInterfaceState state) { base.UpdateState(state); @@ -67,7 +69,9 @@ namespace Content.Client.Kitchen.UI } _menu?.ToggleBusyDisableOverlayPanel(cState.IsMicrowaveBusy); - RefreshContentsDisplay(cState.ContainedSolids); + + // TODO move this to a component state and ensure the net ids. + RefreshContentsDisplay(_entManager.GetEntityArray(cState.ContainedSolids)); if (_menu == null) return; diff --git a/Content.Client/Kitchen/UI/ReagentGrinderBoundUserInterface.cs b/Content.Client/Kitchen/UI/ReagentGrinderBoundUserInterface.cs index c8c978d313..39b85c261b 100644 --- a/Content.Client/Kitchen/UI/ReagentGrinderBoundUserInterface.cs +++ b/Content.Client/Kitchen/UI/ReagentGrinderBoundUserInterface.cs @@ -74,7 +74,7 @@ namespace Content.Client.Kitchen.UI public void EjectChamberContent(EntityUid uid) { - SendMessage(new ReagentGrinderEjectChamberContentMessage(uid)); + SendMessage(new ReagentGrinderEjectChamberContentMessage(EntMan.GetNetEntity(uid))); } } } diff --git a/Content.Client/LateJoin/LateJoinGui.cs b/Content.Client/LateJoin/LateJoinGui.cs index d2b4103140..dd8281ecbf 100644 --- a/Content.Client/LateJoin/LateJoinGui.cs +++ b/Content.Client/LateJoin/LateJoinGui.cs @@ -23,17 +23,18 @@ namespace Content.Client.LateJoin [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IClientConsoleHost _consoleHost = default!; [Dependency] private readonly IConfigurationManager _configManager = default!; + [Dependency] private readonly IEntityManager _entManager = default!; [Dependency] private readonly IEntitySystemManager _entitySystem = default!; [Dependency] private readonly JobRequirementsManager _jobRequirements = default!; - public event Action<(EntityUid, string)> SelectedId; + public event Action<(NetEntity, string)> SelectedId; private readonly ClientGameTicker _gameTicker; private readonly SpriteSystem _sprites; private readonly CrewManifestSystem _crewManifest; - private readonly Dictionary> _jobButtons = new(); - private readonly Dictionary> _jobCategories = new(); + private readonly Dictionary> _jobButtons = new(); + private readonly Dictionary> _jobCategories = new(); private readonly List _jobLists = new(); private readonly Control _base; @@ -281,7 +282,7 @@ namespace Content.Client.LateJoin } } - private void JobsAvailableUpdated(IReadOnlyDictionary> _) + private void JobsAvailableUpdated(IReadOnlyDictionary> _) { RebuildUI(); } diff --git a/Content.Client/Light/RgbLightControllerSystem.cs b/Content.Client/Light/RgbLightControllerSystem.cs index 405cf3d018..ccea86013d 100644 --- a/Content.Client/Light/RgbLightControllerSystem.cs +++ b/Content.Client/Light/RgbLightControllerSystem.cs @@ -205,7 +205,7 @@ namespace Content.Client.Light public static Color GetCurrentRgbColor(TimeSpan curTime, TimeSpan offset, RgbLightControllerComponent rgb) { return Color.FromHsv(new Vector4( - (float) (((curTime.TotalSeconds - offset.TotalSeconds) * rgb.CycleRate + Math.Abs(rgb.Owner.GetHashCode() * 0.1)) % 1), + (float) (((curTime.TotalSeconds - offset.TotalSeconds) * rgb.CycleRate + Math.Abs(rgb.Owner.Id * 0.1)) % 1), 1.0f, 1.0f, 1.0f diff --git a/Content.Client/Maps/GridDraggingSystem.cs b/Content.Client/Maps/GridDraggingSystem.cs index dcf74557ee..16357c8983 100644 --- a/Content.Client/Maps/GridDraggingSystem.cs +++ b/Content.Client/Maps/GridDraggingSystem.cs @@ -47,11 +47,11 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem _dragging = grid; _localPosition = localPosition; - if (TryComp(grid, out var body)) + if (HasComp(grid)) { RaiseNetworkEvent(new GridDragVelocityRequest() { - Grid = grid, + Grid = GetNetEntity(grid), LinearVelocity = Vector2.Zero }); } @@ -69,7 +69,7 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem var distance = _lastMousePosition.Value.Position - xform.WorldPosition; RaiseNetworkEvent(new GridDragVelocityRequest() { - Grid = _dragging.Value, + Grid = GetNetEntity(_dragging.Value), LinearVelocity = distance.LengthSquared() > 0f ? (distance / (float) tickTime.TotalSeconds) * 0.25f : Vector2.Zero, }); } @@ -125,7 +125,7 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem RaiseNetworkEvent(new GridDragRequestPosition() { - Grid = _dragging.Value, + Grid = GetNetEntity(_dragging.Value), WorldPosition = requestedGridOrigin, }); } diff --git a/Content.Client/MassMedia/Ui/NewsWriteBoundUserInterface.cs b/Content.Client/MassMedia/Ui/NewsWriteBoundUserInterface.cs index 1ec19ad411..975dfa3f81 100644 --- a/Content.Client/MassMedia/Ui/NewsWriteBoundUserInterface.cs +++ b/Content.Client/MassMedia/Ui/NewsWriteBoundUserInterface.cs @@ -67,20 +67,14 @@ namespace Content.Client.MassMedia.Ui var stringContent = Rope.Collapse(_menu.ContentInput.TextRope); - if (stringContent == null || stringContent.Length == 0) return; - if (_gameTicker == null) return; + if (stringContent == null || stringContent.Length == 0) + return; - NewsArticle article = new NewsArticle(); var stringName = _menu.NameInput.Text; var name = (stringName.Length <= 25 ? stringName.Trim() : $"{stringName.Trim().Substring(0, 25)}..."); - article.Name = name; - article.Content = stringContent; - article.ShareTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan); - _menu.ContentInput.TextRope = new Rope.Leaf(string.Empty); _menu.NameInput.Text = string.Empty; - - SendMessage(new NewsWriteShareMessage(article)); + SendMessage(new NewsWriteShareMessage(name, stringContent)); } private void OnDeleteButtonPressed(int articleNum) diff --git a/Content.Client/Mech/Ui/Equipment/MechGrabberUi.cs b/Content.Client/Mech/Ui/Equipment/MechGrabberUi.cs index 49bac300e4..4bb9961fc4 100644 --- a/Content.Client/Mech/Ui/Equipment/MechGrabberUi.cs +++ b/Content.Client/Mech/Ui/Equipment/MechGrabberUi.cs @@ -20,9 +20,11 @@ public sealed partial class MechGrabberUi : UIFragment return; _fragment = new MechGrabberUiFragment(); + _fragment.OnEjectAction += e => { - userInterface.SendMessage(new MechGrabberEjectMessage(fragmentOwner.Value, e)); + var entManager = IoCManager.Resolve(); + userInterface.SendMessage(new MechGrabberEjectMessage(entManager.GetNetEntity(fragmentOwner.Value), entManager.GetNetEntity(e))); }; } diff --git a/Content.Client/Mech/Ui/Equipment/MechGrabberUiFragment.xaml.cs b/Content.Client/Mech/Ui/Equipment/MechGrabberUiFragment.xaml.cs index 8fc04d6460..94f86e74a0 100644 --- a/Content.Client/Mech/Ui/Equipment/MechGrabberUiFragment.xaml.cs +++ b/Content.Client/Mech/Ui/Equipment/MechGrabberUiFragment.xaml.cs @@ -23,7 +23,7 @@ public sealed partial class MechGrabberUiFragment : BoxContainer SpaceLabel.Text = $"{state.Contents.Count}/{state.MaxContents}"; for (var i = 0; i < state.Contents.Count; i++) { - var ent = state.Contents[i]; + var ent = _entity.GetEntity(state.Contents[i]); if (!_entity.TryGetComponent(ent, out var meta)) continue; diff --git a/Content.Client/Mech/Ui/Equipment/MechSoundboardUi.cs b/Content.Client/Mech/Ui/Equipment/MechSoundboardUi.cs index d4f12db454..e44e861409 100644 --- a/Content.Client/Mech/Ui/Equipment/MechSoundboardUi.cs +++ b/Content.Client/Mech/Ui/Equipment/MechSoundboardUi.cs @@ -22,7 +22,8 @@ public sealed partial class MechSoundboardUi : UIFragment _fragment = new MechSoundboardUiFragment(); _fragment.OnPlayAction += sound => { - userInterface.SendMessage(new MechSoundboardPlayMessage(fragmentOwner.Value, sound)); + // TODO: IDK dog + userInterface.SendMessage(new MechSoundboardPlayMessage(IoCManager.Resolve().GetNetEntity(fragmentOwner.Value), sound)); }; } diff --git a/Content.Client/Mech/Ui/MechBoundUserInterface.cs b/Content.Client/Mech/Ui/MechBoundUserInterface.cs index 62b4fdf250..4172bdc90f 100644 --- a/Content.Client/Mech/Ui/MechBoundUserInterface.cs +++ b/Content.Client/Mech/Ui/MechBoundUserInterface.cs @@ -27,7 +27,7 @@ public sealed class MechBoundUserInterface : BoundUserInterface _menu.OnRemoveButtonPressed += uid => { - SendMessage(new MechEquipmentRemoveMessage(uid)); + SendMessage(new MechEquipmentRemoveMessage(EntMan.GetNetEntity(uid))); }; } @@ -54,7 +54,7 @@ public sealed class MechBoundUserInterface : BoundUserInterface continue; foreach (var (attached, estate) in state.EquipmentStates) { - if (ent == attached) + if (ent == EntMan.GetEntity(attached)) ui.UpdateState(estate); } } diff --git a/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs b/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs index 40da258a4b..ff08af6bb6 100644 --- a/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs +++ b/Content.Client/Medical/CrewMonitoring/CrewMonitoringWindow.xaml.cs @@ -64,15 +64,18 @@ namespace Content.Client.Medical.CrewMonitoring // add a row for each sensor foreach (var sensor in stSensors.OrderBy(a => a.Name)) { + var sensorEntity = _entManager.GetEntity(sensor.SuitSensorUid); + var coordinates = _entManager.GetCoordinates(sensor.Coordinates); + // add button with username var nameButton = new CrewMonitoringButton() { - SuitSensorUid = sensor.SuitSensorUid, - Coordinates = sensor.Coordinates, + SuitSensorUid = sensorEntity, + Coordinates = coordinates, Text = sensor.Name, Margin = new Thickness(5f, 5f), }; - if (sensor.SuitSensorUid == _trackedButton?.SuitSensorUid) + if (sensorEntity == _trackedButton?.SuitSensorUid) nameButton.AddStyleClass(StyleNano.StyleClassButtonColorGreen); SetColorLabel(nameButton.Label, sensor.TotalDamage, sensor.IsAlive); SensorsTable.AddChild(nameButton); @@ -113,10 +116,10 @@ namespace Content.Client.Medical.CrewMonitoring SensorsTable.AddChild(box); _rowsContent.Add(box); - if (sensor.Coordinates != null && NavMap.Visible) + if (coordinates != null && NavMap.Visible) { - NavMap.TrackedCoordinates.TryAdd(sensor.Coordinates.Value, - (true, sensor.SuitSensorUid == _trackedButton?.SuitSensorUid ? StyleNano.PointGreen : StyleNano.PointRed)); + NavMap.TrackedCoordinates.TryAdd(coordinates.Value, + (true, sensorEntity == _trackedButton?.SuitSensorUid ? StyleNano.PointGreen : StyleNano.PointRed)); nameButton.OnButtonUp += args => { @@ -124,8 +127,8 @@ namespace Content.Client.Medical.CrewMonitoring //Make previous point red NavMap.TrackedCoordinates[_trackedButton.Coordinates.Value] = (true, StyleNano.PointRed); - NavMap.TrackedCoordinates[sensor.Coordinates.Value] = (true, StyleNano.PointGreen); - NavMap.CenterToCoordinates(sensor.Coordinates.Value); + NavMap.TrackedCoordinates[coordinates.Value] = (true, StyleNano.PointGreen); + NavMap.CenterToCoordinates(coordinates.Value); nameButton.AddStyleClass(StyleNano.StyleClassButtonColorGreen); if (_trackedButton != null) @@ -145,7 +148,7 @@ namespace Content.Client.Medical.CrewMonitoring private BoxContainer GetPositionBox(SuitSensorStatus sensor, Vector2 monitorCoordsInStationSpace, bool snap, float precision) { - EntityCoordinates? coordinates = sensor.Coordinates; + EntityCoordinates? coordinates = _entManager.GetCoordinates(sensor.Coordinates); var box = new BoxContainer() { Orientation = LayoutOrientation.Horizontal }; if (coordinates == null || _stationUid == null) diff --git a/Content.Client/NPC/HTN/HTNSystem.cs b/Content.Client/NPC/HTN/HTNSystem.cs index f12dfaf33b..7ea914b8c3 100644 --- a/Content.Client/NPC/HTN/HTNSystem.cs +++ b/Content.Client/NPC/HTN/HTNSystem.cs @@ -46,7 +46,7 @@ public sealed class HTNSystem : EntitySystem private void OnHTNMessage(HTNMessage ev) { - if (!TryComp(ev.Uid, out var htn)) + if (!TryComp(GetEntity(ev.Uid), out var htn)) return; htn.DebugText = ev.Text; diff --git a/Content.Client/NPC/NPCSteeringSystem.cs b/Content.Client/NPC/NPCSteeringSystem.cs index c647c026c1..271632d018 100644 --- a/Content.Client/NPC/NPCSteeringSystem.cs +++ b/Content.Client/NPC/NPCSteeringSystem.cs @@ -61,10 +61,12 @@ public sealed class NPCSteeringSystem : SharedNPCSteeringSystem foreach (var data in ev.Data) { - if (!Exists(data.EntityUid)) + var entity = GetEntity(data.EntityUid); + + if (!Exists(entity)) continue; - var comp = EnsureComp(data.EntityUid); + var comp = EnsureComp(entity); comp.Direction = data.Direction; comp.DangerMap = data.Danger; comp.InterestMap = data.Interest; diff --git a/Content.Client/NPC/PathfindingSystem.cs b/Content.Client/NPC/PathfindingSystem.cs index ea50725b4f..518c1f32aa 100644 --- a/Content.Client/NPC/PathfindingSystem.cs +++ b/Content.Client/NPC/PathfindingSystem.cs @@ -60,8 +60,8 @@ namespace Content.Client.NPC private PathfindingDebugMode _modes = PathfindingDebugMode.None; // It's debug data IDC if it doesn't support snapshots I just want something fast. - public Dictionary>> Breadcrumbs = new(); - public Dictionary>>> Polys = new(); + public Dictionary>> Breadcrumbs = new(); + public Dictionary>>> Polys = new(); public readonly List<(TimeSpan Time, PathRouteMessage Message)> Routes = new(); public override void Initialize() @@ -184,7 +184,9 @@ namespace Content.Client.NPC foreach (var grid in _mapManager.FindGridsIntersecting(mouseWorldPos.MapId, aabb)) { - if (found || !_system.Breadcrumbs.TryGetValue(grid.Owner, out var crumbs) || !xformQuery.TryGetComponent(grid.Owner, out var gridXform)) + var netGrid = _entManager.GetNetEntity(grid.Owner); + + if (found || !_system.Breadcrumbs.TryGetValue(netGrid, out var crumbs) || !xformQuery.TryGetComponent(grid.Owner, out var gridXform)) continue; var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(); @@ -257,7 +259,7 @@ namespace Content.Client.NPC if (!_mapManager.TryFindGridAt(mouseWorldPos, out var gridUid, out var grid) || !xformQuery.TryGetComponent(gridUid, out var gridXform)) return; - if (!_system.Polys.TryGetValue(gridUid, out var data)) + if (!_system.Polys.TryGetValue(_entManager.GetNetEntity(gridUid), out var data)) return; var tileRef = grid.GetTileRef(mouseWorldPos); @@ -333,7 +335,9 @@ namespace Content.Client.NPC { foreach (var grid in _mapManager.FindGridsIntersecting(mouseWorldPos.MapId, aabb)) { - if (!_system.Breadcrumbs.TryGetValue(grid.Owner, out var crumbs) || + var netGrid = _entManager.GetNetEntity(grid.Owner); + + if (!_system.Breadcrumbs.TryGetValue(netGrid, out var crumbs) || !xformQuery.TryGetComponent(grid.Owner, out var gridXform)) { continue; @@ -390,7 +394,9 @@ namespace Content.Client.NPC { foreach (var grid in _mapManager.FindGridsIntersecting(args.MapId, aabb)) { - if (!_system.Polys.TryGetValue(grid.Owner, out var data) || + var netGrid = _entManager.GetNetEntity(grid.Owner); + + if (!_system.Polys.TryGetValue(netGrid, out var data) || !xformQuery.TryGetComponent(grid.Owner, out var gridXform)) continue; @@ -424,7 +430,9 @@ namespace Content.Client.NPC { foreach (var grid in _mapManager.FindGridsIntersecting(args.MapId, aabb)) { - if (!_system.Polys.TryGetValue(grid.Owner, out var data) || + var netGrid = _entManager.GetNetEntity(grid.Owner); + + if (!_system.Polys.TryGetValue(netGrid, out var data) || !xformQuery.TryGetComponent(grid.Owner, out var gridXform)) continue; @@ -450,10 +458,10 @@ namespace Content.Client.NPC Color color; Vector2 neighborPos; - if (neighborPoly.EntityId != poly.GraphUid) + if (neighborPoly.NetEntity != poly.GraphUid) { color = Color.Green; - var neighborMap = neighborPoly.ToMap(_entManager); + var neighborMap = _entManager.GetCoordinates(neighborPoly).ToMap(_entManager); if (neighborMap.MapId != args.MapId) continue; @@ -478,7 +486,9 @@ namespace Content.Client.NPC { foreach (var grid in _mapManager.FindGridsIntersecting(args.MapId, args.WorldBounds)) { - if (!_system.Breadcrumbs.TryGetValue(grid.Owner, out var crumbs) || + var netGrid = _entManager.GetNetEntity(grid.Owner); + + if (!_system.Breadcrumbs.TryGetValue(netGrid, out var crumbs) || !xformQuery.TryGetComponent(grid.Owner, out var gridXform)) continue; @@ -506,7 +516,7 @@ namespace Content.Client.NPC { foreach (var node in route.Message.Path) { - if (!_entManager.TryGetComponent(node.GraphUid, out var graphXform)) + if (!_entManager.TryGetComponent(_entManager.GetEntity(node.GraphUid), out var graphXform)) continue; worldHandle.SetTransform(graphXform.WorldMatrix); @@ -525,12 +535,14 @@ namespace Content.Client.NPC foreach (var (node, cost) in route.Message.Costs) { - if (matrix != node.GraphUid) + var graph = _entManager.GetEntity(node.GraphUid); + + if (matrix != graph) { - if (!_entManager.TryGetComponent(node.GraphUid, out var graphXform)) + if (!_entManager.TryGetComponent(graph, out var graphXform)) continue; - matrix = node.GraphUid; + matrix = graph; worldHandle.SetTransform(graphXform.WorldMatrix); } diff --git a/Content.Client/NodeContainer/NodeGroupSystem.cs b/Content.Client/NodeContainer/NodeGroupSystem.cs index 4afc5ffc48..0a3d7ddad0 100644 --- a/Content.Client/NodeContainer/NodeGroupSystem.cs +++ b/Content.Client/NodeContainer/NodeGroupSystem.cs @@ -69,7 +69,7 @@ namespace Content.Client.NodeContainer Entities = Groups.Values .SelectMany(g => g.Nodes, (data, nodeData) => (data, nodeData)) - .GroupBy(n => n.nodeData.Entity) + .GroupBy(n => GetEntity(n.nodeData.Entity)) .ToDictionary(g => g.Key, g => g.ToArray()); NodeLookup = Groups.Values diff --git a/Content.Client/NodeContainer/NodeVisualizationOverlay.cs b/Content.Client/NodeContainer/NodeVisualizationOverlay.cs index 43e3c12a72..85198f01d0 100644 --- a/Content.Client/NodeContainer/NodeVisualizationOverlay.cs +++ b/Content.Client/NodeContainer/NodeVisualizationOverlay.cs @@ -77,7 +77,7 @@ namespace Content.Client.NodeContainer var node = _system.NodeLookup[(groupId, nodeId)]; - var xform = _entityManager.GetComponent(node.Entity); + var xform = _entityManager.GetComponent(_entityManager.GetEntity(node.Entity)); if (!_mapManager.TryGetGrid(xform.GridUid, out var grid)) return; var gridTile = grid.TileIndicesFor(xform.Coordinates); diff --git a/Content.Client/Pointing/PointingSystem.cs b/Content.Client/Pointing/PointingSystem.cs index f8bae5664b..82b12fbf36 100644 --- a/Content.Client/Pointing/PointingSystem.cs +++ b/Content.Client/Pointing/PointingSystem.cs @@ -31,7 +31,7 @@ public sealed class PointingSystem : SharedPointingSystem private void AddPointingVerb(GetVerbsEvent args) { - if (args.Target.IsClientSide()) + if (IsClientSide(args.Target)) return; // Really this could probably be a properly predicted event, but that requires reworking pointing. For now @@ -57,7 +57,7 @@ public sealed class PointingSystem : SharedPointingSystem Text = Loc.GetString("pointing-verb-get-data-text"), Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/point.svg.192dpi.png")), ClientExclusive = true, - Act = () => RaiseNetworkEvent(new PointingAttemptEvent(args.Target)) + Act = () => RaiseNetworkEvent(new PointingAttemptEvent(GetNetEntity(args.Target))) }; args.Verbs.Add(verb); diff --git a/Content.Client/Popups/PopupSystem.cs b/Content.Client/Popups/PopupSystem.cs index d8d3f079c5..63b8d7f6df 100644 --- a/Content.Client/Popups/PopupSystem.cs +++ b/Content.Client/Popups/PopupSystem.cs @@ -61,9 +61,9 @@ namespace Content.Client.Popups if (recordReplay && _replayRecording.IsRecording) { if (entity != null) - _replayRecording.RecordClientMessage(new PopupEntityEvent(message, type, entity.Value)); + _replayRecording.RecordClientMessage(new PopupEntityEvent(message, type, GetNetEntity(entity.Value))); else - _replayRecording.RecordClientMessage(new PopupCoordinatesEvent(message, type, coordinates)); + _replayRecording.RecordClientMessage(new PopupCoordinatesEvent(message, type, GetNetCoordinates(coordinates))); } var label = new WorldPopupLabel(coordinates) @@ -170,13 +170,15 @@ namespace Content.Client.Popups private void OnPopupCoordinatesEvent(PopupCoordinatesEvent ev) { - PopupMessage(ev.Message, ev.Type, ev.Coordinates, null, false); + PopupMessage(ev.Message, ev.Type, GetCoordinates(ev.Coordinates), null, false); } private void OnPopupEntityEvent(PopupEntityEvent ev) { - if (TryComp(ev.Uid, out TransformComponent? transform)) - PopupMessage(ev.Message, ev.Type, transform.Coordinates, ev.Uid, false); + var entity = GetEntity(ev.Uid); + + if (TryComp(entity, out TransformComponent? transform)) + PopupMessage(ev.Message, ev.Type, transform.Coordinates, entity, false); } private void OnRoundRestart(RoundRestartCleanupEvent ev) diff --git a/Content.Client/Projectiles/ProjectileSystem.cs b/Content.Client/Projectiles/ProjectileSystem.cs index 20be44792f..07da813045 100644 --- a/Content.Client/Projectiles/ProjectileSystem.cs +++ b/Content.Client/Projectiles/ProjectileSystem.cs @@ -19,10 +19,12 @@ public sealed class ProjectileSystem : SharedProjectileSystem private void OnProjectileImpact(ImpactEffectEvent ev) { - if (Deleted(ev.Coordinates.EntityId)) + var coords = GetCoordinates(ev.Coordinates); + + if (Deleted(coords.EntityId)) return; - var ent = Spawn(ev.Prototype, ev.Coordinates); + var ent = Spawn(ev.Prototype, coords); if (TryComp(ent, out var sprite)) { diff --git a/Content.Client/Radiation/Overlays/RadiationDebugOverlay.cs b/Content.Client/Radiation/Overlays/RadiationDebugOverlay.cs index 96fbb5dca8..8c721fa777 100644 --- a/Content.Client/Radiation/Overlays/RadiationDebugOverlay.cs +++ b/Content.Client/Radiation/Overlays/RadiationDebugOverlay.cs @@ -59,8 +59,10 @@ public sealed class RadiationDebugOverlay : Overlay handle.DrawString(_font, screenCenter, ray.Rads.ToString("F2"), 2f, Color.White); } - foreach (var (gridUid, blockers) in ray.Blockers) + foreach (var (netGrid, blockers) in ray.Blockers) { + var gridUid = _entityManager.GetEntity(netGrid); + if (!_mapManager.TryGetGrid(gridUid, out var grid)) continue; @@ -82,8 +84,10 @@ public sealed class RadiationDebugOverlay : Overlay var handle = args.ScreenHandle; var query = _entityManager.GetEntityQuery(); - foreach (var (gridUid, resMap) in resistance) + foreach (var (netGrid, resMap) in resistance) { + var gridUid = _entityManager.GetEntity(netGrid); + if (!_mapManager.TryGetGrid(gridUid, out var grid)) continue; if (query.TryGetComponent(gridUid, out var trs) && trs.MapID != args.MapId) @@ -119,8 +123,10 @@ public sealed class RadiationDebugOverlay : Overlay continue; } - foreach (var (gridUid, blockers) in ray.Blockers) + foreach (var (netGrid, blockers) in ray.Blockers) { + var gridUid = _entityManager.GetEntity(netGrid); + if (!_mapManager.TryGetGrid(gridUid, out var grid)) continue; var (destTile, _) = blockers.Last(); diff --git a/Content.Client/Radiation/Systems/GeigerSystem.cs b/Content.Client/Radiation/Systems/GeigerSystem.cs index d7401dce7e..7a193d4a75 100644 --- a/Content.Client/Radiation/Systems/GeigerSystem.cs +++ b/Content.Client/Radiation/Systems/GeigerSystem.cs @@ -26,7 +26,7 @@ public sealed class GeigerSystem : SharedGeigerSystem component.CurrentRadiation = state.CurrentRadiation; component.DangerLevel = state.DangerLevel; component.IsEnabled = state.IsEnabled; - component.User = state.User; + component.User = EnsureEntity(state.User, uid); component.UiUpdateNeeded = true; } diff --git a/Content.Client/Radiation/Systems/RadiationSystem.cs b/Content.Client/Radiation/Systems/RadiationSystem.cs index 9288c60652..929ad6aa4a 100644 --- a/Content.Client/Radiation/Systems/RadiationSystem.cs +++ b/Content.Client/Radiation/Systems/RadiationSystem.cs @@ -10,7 +10,7 @@ public sealed class RadiationSystem : EntitySystem [Dependency] private readonly IOverlayManager _overlayMan = default!; public List? Rays; - public Dictionary>? ResistanceGrids; + public Dictionary>? ResistanceGrids; public override void Initialize() { @@ -40,15 +40,13 @@ public sealed class RadiationSystem : EntitySystem var str = $"Radiation update: {ev.ElapsedTimeMs}ms with. Receivers: {ev.ReceiversCount}, " + $"Sources: {ev.SourcesCount}, Rays: {ev.Rays.Count}"; - Logger.Info(str); + Log.Info(str); Rays = ev.Rays; } private void OnResistanceUpdate(OnRadiationOverlayResistanceUpdateEvent ev) { - if (!_overlayMan.TryGetOverlay(out RadiationDebugOverlay? overlay)) - return; ResistanceGrids = ev.Grids; } } diff --git a/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Movement.cs b/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Movement.cs index 2b72d2563b..3bb2afe122 100644 --- a/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Movement.cs +++ b/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Movement.cs @@ -55,7 +55,7 @@ public sealed partial class ReplaySpectatorSystem return; } - if (!player.IsClientSide() || !HasComp(player)) + if (!IsClientSide(player) || !HasComp(player)) { // Player is trying to move -> behave like the ghost-on-move component. SpawnSpectatorGhost(new EntityCoordinates(player, default), true); @@ -113,12 +113,9 @@ public sealed partial class ReplaySpectatorSystem _dir = dir; } - public override bool HandleCmdMessage(ICommonSession? session, InputCmdMessage message) + public override bool HandleCmdMessage(IEntityManager entManager, ICommonSession? session, IFullInputCmdMessage message) { - if (message is not FullInputCmdMessage full) - return false; - - if (full.State == BoundKeyState.Down) + if (message.State == BoundKeyState.Down) _sys.Direction |= _dir; else _sys.Direction &= ~_dir; diff --git a/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Position.cs b/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Position.cs index 04fd35da11..66768e9fda 100644 --- a/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Position.cs +++ b/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Position.cs @@ -167,7 +167,7 @@ public sealed partial class ReplaySpectatorSystem private void OnDetached(EntityUid uid, ReplaySpectatorComponent component, PlayerDetachedEvent args) { - if (uid.IsClientSide()) + if (IsClientSide(uid)) QueueDel(uid); else RemCompDeferred(uid, component); diff --git a/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Spectate.cs b/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Spectate.cs index 09325a7a36..f3475c5479 100644 --- a/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Spectate.cs +++ b/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Spectate.cs @@ -51,7 +51,7 @@ public sealed partial class ReplaySpectatorSystem if (old == null) return; - if (old.Value.IsClientSide()) + if (IsClientSide(old.Value)) Del(old.Value); else RemComp(old.Value); @@ -77,7 +77,7 @@ public sealed partial class ReplaySpectatorSystem if (old != null) { - if (old.Value.IsClientSide()) + if (IsClientSide(old.Value)) QueueDel(old.Value); else RemComp(old.Value); @@ -100,12 +100,14 @@ public sealed partial class ReplaySpectatorSystem return; } - if (!EntityUid.TryParse(args[0], out var uid)) + if (!NetEntity.TryParse(args[0], out var netEntity)) { shell.WriteError(Loc.GetString("cmd-parse-failure-uid", ("arg", args[0]))); return; } + var uid = GetEntity(netEntity); + if (!Exists(uid)) { shell.WriteError(Loc.GetString("cmd-parse-failure-entity-exist", ("arg", args[0]))); @@ -120,7 +122,7 @@ public sealed partial class ReplaySpectatorSystem if (args.Length != 1) return CompletionResult.Empty; - return CompletionResult.FromHintOptions(CompletionHelper.EntityUids(args[0], + return CompletionResult.FromHintOptions(CompletionHelper.NetEntities(args[0], EntityManager), Loc.GetString("cmd-replay-spectate-hint")); } } diff --git a/Content.Client/RoundEnd/RoundEndSummaryWindow.cs b/Content.Client/RoundEnd/RoundEndSummaryWindow.cs index 454027597c..b12ebe1807 100644 --- a/Content.Client/RoundEnd/RoundEndSummaryWindow.cs +++ b/Content.Client/RoundEnd/RoundEndSummaryWindow.cs @@ -125,7 +125,9 @@ namespace Content.Client.RoundEnd VerticalExpand = true, }; - if (_entityManager.HasComponent(playerInfo.PlayerEntityUid)) + var playerUid = _entityManager.GetEntity(playerInfo.PlayerNetEntity); + + if (_entityManager.HasComponent(playerUid)) { var spriteView = new SpriteView { @@ -134,7 +136,7 @@ namespace Content.Client.RoundEnd SetSize = new Vector2(32, 32), VerticalExpand = true, }; - spriteView.SetEntity(playerInfo.PlayerEntityUid); + spriteView.SetEntity(playerUid); hBox.AddChild(spriteView); } diff --git a/Content.Client/Salvage/FultonSystem.cs b/Content.Client/Salvage/FultonSystem.cs index 1ecebdfdf8..05e7dd12d9 100644 --- a/Content.Client/Salvage/FultonSystem.cs +++ b/Content.Client/Salvage/FultonSystem.cs @@ -63,15 +63,18 @@ public sealed class FultonSystem : SharedFultonSystem private void OnFultonMessage(FultonAnimationMessage ev) { - if (Deleted(ev.Entity) || !TryComp(ev.Entity, out var entSprite)) + var entity = GetEntity(ev.Entity); + var coordinates = GetCoordinates(ev.Coordinates); + + if (Deleted(entity) || !TryComp(entity, out var entSprite)) return; - var animationEnt = Spawn(null, ev.Coordinates); + var animationEnt = Spawn(null, coordinates); // TODO: Spawn fulton layer var sprite = AddComp(animationEnt); _serManager.CopyTo(entSprite, ref sprite, notNullableOverride: true); - if (TryComp(ev.Entity, out var entAppearance)) + if (TryComp(entity, out var entAppearance)) { var appearance = AddComp(animationEnt); _serManager.CopyTo(entAppearance, ref appearance, notNullableOverride: true); diff --git a/Content.Client/Shuttles/BUI/RadarConsoleBoundUserInterface.cs b/Content.Client/Shuttles/BUI/RadarConsoleBoundUserInterface.cs index e8cc64a00b..41db4bb0b4 100644 --- a/Content.Client/Shuttles/BUI/RadarConsoleBoundUserInterface.cs +++ b/Content.Client/Shuttles/BUI/RadarConsoleBoundUserInterface.cs @@ -38,7 +38,7 @@ public sealed class RadarConsoleBoundUserInterface : BoundUserInterface base.UpdateState(state); if (state is not RadarConsoleBoundInterfaceState cState) return; - _window?.SetMatrix(cState.Coordinates, cState.Angle); + _window?.SetMatrix(EntMan.GetCoordinates(cState.Coordinates), cState.Angle); _window?.UpdateState(cState); } } diff --git a/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs b/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs index b970097641..1df8416ad7 100644 --- a/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs +++ b/Content.Client/Shuttles/BUI/ShuttleConsoleBoundUserInterface.cs @@ -28,7 +28,7 @@ public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface _window.OnClose += OnClose; } - private void OnDestinationPressed(EntityUid obj) + private void OnDestinationPressed(NetEntity obj) { SendMessage(new ShuttleConsoleFTLRequestMessage() { @@ -51,17 +51,17 @@ public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface } } - private void OnStopAutodockPressed(EntityUid obj) + private void OnStopAutodockPressed(NetEntity obj) { SendMessage(new StopAutodockRequestMessage() { DockEntity = obj }); } - private void OnAutodockPressed(EntityUid obj) + private void OnAutodockPressed(NetEntity obj) { SendMessage(new AutodockRequestMessage() { DockEntity = obj }); } - private void OnUndockPressed(EntityUid obj) + private void OnUndockPressed(NetEntity obj) { SendMessage(new UndockRequestMessage() { DockEntity = obj }); } @@ -71,7 +71,7 @@ public sealed class ShuttleConsoleBoundUserInterface : BoundUserInterface base.UpdateState(state); if (state is not ShuttleConsoleBoundInterfaceState cState) return; - _window?.SetMatrix(cState.Coordinates, cState.Angle); + _window?.SetMatrix(EntMan.GetCoordinates(cState.Coordinates), cState.Angle); _window?.UpdateState(cState); } } diff --git a/Content.Client/Shuttles/Systems/ShuttleConsoleSystem.cs b/Content.Client/Shuttles/Systems/ShuttleConsoleSystem.cs index f18f27ccd2..20fff4acfa 100644 --- a/Content.Client/Shuttles/Systems/ShuttleConsoleSystem.cs +++ b/Content.Client/Shuttles/Systems/ShuttleConsoleSystem.cs @@ -44,8 +44,9 @@ namespace Content.Client.Shuttles.Systems { if (args.Current is not PilotComponentState state) return; - var console = state.Console.GetValueOrDefault(); - if (!console.IsValid()) + var console = EnsureEntity(state.Console, uid); + + if (console == null) { component.Console = null; _input.Contexts.SetActiveContext("human"); diff --git a/Content.Client/Shuttles/Systems/ShuttleSystem.EmergencyConsole.cs b/Content.Client/Shuttles/Systems/ShuttleSystem.EmergencyConsole.cs index db3f8f5b58..7086fd0541 100644 --- a/Content.Client/Shuttles/Systems/ShuttleSystem.EmergencyConsole.cs +++ b/Content.Client/Shuttles/Systems/ShuttleSystem.EmergencyConsole.cs @@ -47,7 +47,7 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem { if (_overlay == null) return; - _overlay.StationUid = ev.StationUid; + _overlay.StationUid = GetEntity(ev.StationUid); _overlay.Position = ev.Position; } } diff --git a/Content.Client/Shuttles/UI/DockingControl.cs b/Content.Client/Shuttles/UI/DockingControl.cs index 93c72921bb..e477b5a1a2 100644 --- a/Content.Client/Shuttles/UI/DockingControl.cs +++ b/Content.Client/Shuttles/UI/DockingControl.cs @@ -32,7 +32,7 @@ public class DockingControl : Control private int ScaledMinimapRadius => (int) (MapGridControl.UIDisplayRadius * UIScale); private float MinimapScale => _range != 0 ? ScaledMinimapRadius / _range : 0f; - public EntityUid? ViewedDock; + public NetEntity? ViewedDock; public EntityUid? GridEntity; public EntityCoordinates? Coordinates; @@ -41,7 +41,7 @@ public class DockingControl : Control /// /// Stored by GridID then by docks /// - public Dictionary> Docks = new(); + public Dictionary> Docks = new(); public DockingControl() { @@ -204,7 +204,7 @@ public class DockingControl : Control } // Draw any docks on that grid - if (Docks.TryGetValue(grid.Owner, out var gridDocks)) + if (Docks.TryGetValue(_entManager.GetNetEntity(grid.Owner), out var gridDocks)) { foreach (var dock in gridDocks) { diff --git a/Content.Client/Shuttles/UI/RadarControl.cs b/Content.Client/Shuttles/UI/RadarControl.cs index 4b614cb4d9..fa411ca9ba 100644 --- a/Content.Client/Shuttles/UI/RadarControl.cs +++ b/Content.Client/Shuttles/UI/RadarControl.cs @@ -124,7 +124,7 @@ public sealed class RadarControl : MapGridControl foreach (var state in ls.Docks) { var coordinates = state.Coordinates; - var grid = _docks.GetOrNew(coordinates.EntityId); + var grid = _docks.GetOrNew(_entManager.GetEntity(coordinates.NetEntity)); grid.Add(state); } } @@ -324,7 +324,7 @@ public sealed class RadarControl : MapGridControl { foreach (var state in docks) { - var ent = state.Entity; + var ent = _entManager.GetEntity(state.Entity); var position = state.Coordinates.Position; var uiPosition = matrix.Transform(position); diff --git a/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml.cs b/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml.cs index 61f861bbc7..828b98868f 100644 --- a/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml.cs +++ b/Content.Client/Shuttles/UI/ShuttleConsoleWindow.xaml.cs @@ -22,7 +22,7 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow, private readonly IEntityManager _entManager; private readonly IGameTiming _timing; - private EntityUid? _shuttleUid; + private EntityUid? _shuttleEntity; /// /// Currently selected dock button for camera. @@ -32,19 +32,19 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow, /// /// Stored by grid entityid then by states /// - private readonly Dictionary> _docks = new(); + private readonly Dictionary> _docks = new(); - private readonly Dictionary _destinations = new(); + private readonly Dictionary _destinations = new(); /// /// Next FTL state change. /// public TimeSpan FTLTime; - public Action? UndockPressed; - public Action? StartAutodockPressed; - public Action? StopAutodockPressed; - public Action? DestinationPressed; + public Action? UndockPressed; + public Action? StartAutodockPressed; + public Action? StopAutodockPressed; + public Action? DestinationPressed; public ShuttleConsoleWindow() { @@ -89,7 +89,7 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow, public void SetMatrix(EntityCoordinates? coordinates, Angle? angle) { - _shuttleUid = coordinates?.EntityId; + _shuttleEntity = coordinates?.EntityId; RadarScreen.SetMatrix(coordinates, angle); } @@ -101,7 +101,7 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow, MaxRadarRange.Text = $"{scc.MaxRange:0}"; } - private void UpdateFTL(List<(EntityUid Entity, string Destination, bool Enabled)> destinations, FTLState state, TimeSpan time) + private void UpdateFTL(List<(NetEntity Entity, string Destination, bool Enabled)> destinations, FTLState state, TimeSpan time) { HyperspaceDestinations.DisposeAllChildren(); _destinations.Clear(); @@ -183,14 +183,15 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow, foreach (var dock in docks) { - var grid = _docks.GetOrNew(dock.Coordinates.EntityId); + var grid = _docks.GetOrNew(dock.Coordinates.NetEntity); grid.Add(dock); } DockPorts.DisposeAllChildren(); DockingScreen.Docks = _docks; + var shuttleNetEntity = _entManager.GetNetEntity(_shuttleEntity); - if (_shuttleUid != null && _docks.TryGetValue(_shuttleUid.Value, out var gridDocks)) + if (shuttleNetEntity != null && _docks.TryGetValue(shuttleNetEntity.Value, out var gridDocks)) { var index = 1; @@ -233,7 +234,7 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow, private void OnDockMouseEntered(GUIMouseHoverEventArgs obj, DockingInterfaceState state) { - RadarScreen.HighlightedDock = state.Entity; + RadarScreen.HighlightedDock = _entManager.GetEntity(state.Entity); } private void OnDockMouseExited(GUIMouseHoverEventArgs obj, DockingInterfaceState state) @@ -246,8 +247,6 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow, /// private void OnDockToggled(BaseButton.ButtonEventArgs obj, DockingInterfaceState state) { - var ent = state.Entity; - if (_selectedDock != null) { // If it got untoggled via other means then we'll stop viewing the old dock. @@ -274,9 +273,9 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow, } else { - if (_shuttleUid != null) + if (_shuttleEntity != null) { - DockingScreen.Coordinates = state.Coordinates; + DockingScreen.Coordinates = _entManager.GetCoordinates(state.Coordinates); DockingScreen.Angle = state.Angle; } else @@ -288,9 +287,9 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow, UndockButton.Disabled = false; RadarScreen.Visible = false; DockingScreen.Visible = true; - DockingScreen.ViewedDock = ent; - StartAutodockPressed?.Invoke(ent); - DockingScreen.GridEntity = _shuttleUid; + DockingScreen.ViewedDock = state.Entity; + StartAutodockPressed?.Invoke(state.Entity); + DockingScreen.GridEntity = _shuttleEntity; _selectedDock = obj.Button; } } @@ -310,13 +309,13 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow, { base.Draw(handle); - if (!_entManager.TryGetComponent(_shuttleUid, out var gridBody) || - !_entManager.TryGetComponent(_shuttleUid, out var gridXform)) + if (!_entManager.TryGetComponent(_shuttleEntity, out var gridBody) || + !_entManager.TryGetComponent(_shuttleEntity, out var gridXform)) { return; } - if (_entManager.TryGetComponent(_shuttleUid, out var metadata) && metadata.EntityPaused) + if (_entManager.TryGetComponent(_shuttleEntity, out var metadata) && metadata.EntityPaused) { FTLTime += _timing.FrameTime; } diff --git a/Content.Client/Silicons/Borgs/BorgBoundUserInterface.cs b/Content.Client/Silicons/Borgs/BorgBoundUserInterface.cs index 1d8bd06d9e..3cc2a35d79 100644 --- a/Content.Client/Silicons/Borgs/BorgBoundUserInterface.cs +++ b/Content.Client/Silicons/Borgs/BorgBoundUserInterface.cs @@ -39,7 +39,7 @@ public sealed class BorgBoundUserInterface : BoundUserInterface _menu.RemoveModuleButtonPressed += module => { - SendMessage(new BorgRemoveModuleBuiMessage(module)); + SendMessage(new BorgRemoveModuleBuiMessage(EntMan.GetNetEntity(module))); }; _menu.OnClose += Close; diff --git a/Content.Client/Spawners/TimedDespawnSystem.cs b/Content.Client/Spawners/TimedDespawnSystem.cs index e899eff099..14e34dce44 100644 --- a/Content.Client/Spawners/TimedDespawnSystem.cs +++ b/Content.Client/Spawners/TimedDespawnSystem.cs @@ -6,6 +6,6 @@ public sealed class TimedDespawnSystem : SharedTimedDespawnSystem { protected override bool CanDelete(EntityUid uid) { - return uid.IsClientSide(); + return IsClientSide(uid); } } diff --git a/Content.Client/Station/StationSystem.cs b/Content.Client/Station/StationSystem.cs index 85c9272066..737a12aa60 100644 --- a/Content.Client/Station/StationSystem.cs +++ b/Content.Client/Station/StationSystem.cs @@ -27,6 +27,7 @@ public sealed class StationSystem : EntitySystem private void StationsUpdated(StationsUpdatedEvent ev) { _stations.Clear(); - _stations.UnionWith(ev.Stations); + // TODO this needs to be dona in component states and with the Ensure() methods + _stations.UnionWith(GetEntitySet(ev.Stations)); } } diff --git a/Content.Client/StationRecords/GeneralStationRecordConsoleBoundUserInterface.cs b/Content.Client/StationRecords/GeneralStationRecordConsoleBoundUserInterface.cs index 0743312e11..f888f7e80a 100644 --- a/Content.Client/StationRecords/GeneralStationRecordConsoleBoundUserInterface.cs +++ b/Content.Client/StationRecords/GeneralStationRecordConsoleBoundUserInterface.cs @@ -26,7 +26,7 @@ public sealed class GeneralStationRecordConsoleBoundUserInterface : BoundUserInt private void OnKeySelected(StationRecordKey? key) { - SendMessage(new SelectGeneralStationRecord(key)); + SendMessage(new SelectGeneralStationRecord(EntMan.System().Convert(key))); } private void OnFiltersChanged( diff --git a/Content.Client/StationRecords/GeneralStationRecordConsoleWindow.xaml.cs b/Content.Client/StationRecords/GeneralStationRecordConsoleWindow.xaml.cs index 89c5048f33..b629773708 100644 --- a/Content.Client/StationRecords/GeneralStationRecordConsoleWindow.xaml.cs +++ b/Content.Client/StationRecords/GeneralStationRecordConsoleWindow.xaml.cs @@ -123,7 +123,7 @@ public sealed partial class GeneralStationRecordConsoleWindow : DefaultWindow RecordContainer.RemoveAllChildren(); } } - private void PopulateRecordListing(Dictionary listing, StationRecordKey? selected) + private void PopulateRecordListing(Dictionary<(NetEntity, uint), string> listing, (NetEntity, uint)? selected) { RecordListing.Clear(); RecordListing.ClearSelected(); @@ -134,7 +134,7 @@ public sealed partial class GeneralStationRecordConsoleWindow : DefaultWindow { var item = RecordListing.AddItem(name); item.Metadata = key; - if (selected != null && key.ID == selected.Value.ID) + if (selected != null && key.Item1 == selected.Value.Item1 && key.Item2 == selected.Value.Item2) { item.Selected = true; } diff --git a/Content.Client/StationRecords/StationRecordsSystem.cs b/Content.Client/StationRecords/StationRecordsSystem.cs new file mode 100644 index 0000000000..92ec076d0b --- /dev/null +++ b/Content.Client/StationRecords/StationRecordsSystem.cs @@ -0,0 +1,7 @@ +using Content.Shared.StationRecords; + +namespace Content.Client.StationRecords; + +public sealed class StationRecordsSystem : SharedStationRecordsSystem +{ +} diff --git a/Content.Client/Storage/StorageBoundUserInterface.cs b/Content.Client/Storage/StorageBoundUserInterface.cs index bd83670b3c..25024aa8c5 100644 --- a/Content.Client/Storage/StorageBoundUserInterface.cs +++ b/Content.Client/Storage/StorageBoundUserInterface.cs @@ -54,7 +54,7 @@ namespace Content.Client.Storage if (args.Event.Function == EngineKeyFunctions.UIClick) { - SendMessage(new StorageInteractWithItemEvent(entity)); + SendMessage(new StorageInteractWithItemEvent(EntMan.GetNetEntity(entity))); } else if (EntMan.EntityExists(entity)) { @@ -76,11 +76,11 @@ namespace Content.Client.Storage else if (args.Function == ContentKeyFunctions.ActivateItemInWorld) { EntMan.EntityNetManager?.SendSystemNetworkMessage( - new InteractInventorySlotEvent(entity, altInteract: false)); + new InteractInventorySlotEvent(EntMan.GetNetEntity(entity), altInteract: false)); } else if (args.Function == ContentKeyFunctions.AltActivateItemInWorld) { - EntMan.RaisePredictiveEvent(new InteractInventorySlotEvent(entity, altInteract: true)); + EntMan.RaisePredictiveEvent(new InteractInventorySlotEvent(EntMan.GetNetEntity(entity), altInteract: true)); } else { diff --git a/Content.Client/Storage/Systems/StorageSystem.cs b/Content.Client/Storage/Systems/StorageSystem.cs index 145a7dd9f0..27fbfe651e 100644 --- a/Content.Client/Storage/Systems/StorageSystem.cs +++ b/Content.Client/Storage/Systems/StorageSystem.cs @@ -19,18 +19,20 @@ public sealed class StorageSystem : EntitySystem /// public void HandleAnimatingInsertingEntities(AnimateInsertingEntitiesEvent msg) { - if (!TryComp(msg.Storage, out ClientStorageComponent? storage)) + var store = GetEntity(msg.Storage); + + if (!HasComp(store)) return; - TryComp(msg.Storage, out TransformComponent? transformComp); + TryComp(store, out TransformComponent? transformComp); for (var i = 0; msg.StoredEntities.Count > i; i++) { - var entity = msg.StoredEntities[i]; + var entity = GetEntity(msg.StoredEntities[i]); var initialPosition = msg.EntityPositions[i]; if (EntityManager.EntityExists(entity) && transformComp != null) { - ReusableAnimations.AnimateEntityPickup(entity, initialPosition, transformComp.LocalPosition, msg.EntityAngles[i], EntityManager); + ReusableAnimations.AnimateEntityPickup(entity, GetCoordinates(initialPosition), transformComp.LocalPosition, msg.EntityAngles[i], EntityManager); } } } diff --git a/Content.Client/Storage/UI/StorageWindow.cs b/Content.Client/Storage/UI/StorageWindow.cs index aee8b86c7a..1819f65860 100644 --- a/Content.Client/Storage/UI/StorageWindow.cs +++ b/Content.Client/Storage/UI/StorageWindow.cs @@ -88,7 +88,7 @@ namespace Content.Client.Storage.UI /// public void BuildEntityList(StorageBoundUserInterfaceState state) { - var list = state.StoredEntities.ConvertAll(uid => new EntityListData(uid)); + var list = state.StoredEntities.ConvertAll(nent => new EntityListData(_entityManager.GetEntity(nent))); EntityList.PopulateList(list); //Sets information about entire storage container current capacity diff --git a/Content.Client/SurveillanceCamera/UI/SurveillanceCameraMonitorBoundUi.cs b/Content.Client/SurveillanceCamera/UI/SurveillanceCameraMonitorBoundUi.cs index 2213eb832d..9132dd6ed5 100644 --- a/Content.Client/SurveillanceCamera/UI/SurveillanceCameraMonitorBoundUi.cs +++ b/Content.Client/SurveillanceCamera/UI/SurveillanceCameraMonitorBoundUi.cs @@ -80,7 +80,9 @@ public sealed class SurveillanceCameraMonitorBoundUserInterface : BoundUserInter return; } - if (cast.ActiveCamera == null) + var active = EntMan.GetEntity(cast.ActiveCamera); + + if (active == null) { _window.UpdateState(null, cast.Subnets, cast.ActiveAddress, cast.ActiveSubnet, cast.Cameras); @@ -95,17 +97,17 @@ public sealed class SurveillanceCameraMonitorBoundUserInterface : BoundUserInter { if (_currentCamera == null) { - _eyeLerpingSystem.AddEye(cast.ActiveCamera.Value); - _currentCamera = cast.ActiveCamera; + _eyeLerpingSystem.AddEye(active.Value); + _currentCamera = active; } - else if (_currentCamera != cast.ActiveCamera) + else if (_currentCamera != active) { _eyeLerpingSystem.RemoveEye(_currentCamera.Value); - _eyeLerpingSystem.AddEye(cast.ActiveCamera.Value); - _currentCamera = cast.ActiveCamera; + _eyeLerpingSystem.AddEye(active.Value); + _currentCamera = active; } - if (EntMan.TryGetComponent(cast.ActiveCamera, out var eye)) + if (EntMan.TryGetComponent(active, out var eye)) { _window.UpdateState(eye.Eye, cast.Subnets, cast.ActiveAddress, cast.ActiveSubnet, cast.Cameras); } diff --git a/Content.Client/Tabletop/TabletopSystem.cs b/Content.Client/Tabletop/TabletopSystem.cs index ee0f9646c5..d43111f39c 100644 --- a/Content.Client/Tabletop/TabletopSystem.cs +++ b/Content.Client/Tabletop/TabletopSystem.cs @@ -109,7 +109,7 @@ namespace Content.Client.Tabletop // Only send new position to server when Delay is reached if (_timePassed >= Delay && _table != null) { - RaisePredictiveEvent(new TabletopMoveEvent(_draggedEntity.Value, clampedCoords, _table.Value)); + RaisePredictiveEvent(new TabletopMoveEvent(GetNetEntity(_draggedEntity.Value), clampedCoords, GetNetEntity(_table.Value))); _timePassed -= Delay; } } @@ -125,15 +125,15 @@ namespace Content.Client.Tabletop // Close the currently opened window, if it exists _window?.Close(); - _table = msg.TableUid; + _table = GetEntity(msg.TableUid); // Get the camera entity that the server has created for us - var camera = msg.CameraUid; + var camera = GetEntity(msg.CameraUid); if (!EntityManager.TryGetComponent(camera, out var eyeComponent)) { // If there is no eye, print error and do not open any window - Logger.Error("Camera entity does not have eye component!"); + Log.Error("Camera entity does not have eye component!"); return; } @@ -159,7 +159,7 @@ namespace Content.Client.Tabletop { if (_table != null) { - RaiseNetworkEvent(new TabletopStopPlayingEvent(_table.Value)); + RaiseNetworkEvent(new TabletopStopPlayingEvent(GetNetEntity(_table.Value))); } StopDragging(); @@ -182,9 +182,11 @@ namespace Content.Client.Tabletop { if (_draggedEntity != null && _table != null) { - var ev = new TabletopRequestTakeOut(); - ev.Entity = _draggedEntity.Value; - ev.TableUid = _table.Value; + var ev = new TabletopRequestTakeOut + { + Entity = GetNetEntity(_draggedEntity.Value), + TableUid = GetNetEntity(_table.Value) + }; RaiseNetworkEvent(ev); } return false; @@ -196,8 +198,10 @@ namespace Content.Client.Tabletop if (_playerManager.LocalPlayer is not {ControlledEntity: { } playerEntity}) return false; + var entity = args.EntityUid; + // Return if can not see table or stunned/no hands - if (!CanSeeTable(playerEntity, _table) || !CanDrag(playerEntity, args.EntityUid, out _)) + if (!CanSeeTable(playerEntity, _table) || !CanDrag(playerEntity, entity, out _)) { return false; } @@ -208,7 +212,7 @@ namespace Content.Client.Tabletop return false; } - StartDragging(args.EntityUid, viewport); + StartDragging(entity, viewport); return true; } @@ -247,7 +251,7 @@ namespace Content.Client.Tabletop /// The viewport in which we are dragging. private void StartDragging(EntityUid draggedEntity, ScalingViewport viewport) { - RaisePredictiveEvent(new TabletopDraggingPlayerChangedEvent(draggedEntity, true)); + RaisePredictiveEvent(new TabletopDraggingPlayerChangedEvent(GetNetEntity(draggedEntity), true)); _draggedEntity = draggedEntity; _viewport = viewport; @@ -262,8 +266,8 @@ namespace Content.Client.Tabletop // Set the dragging player on the component to noone if (broadcast && _draggedEntity != null && EntityManager.HasComponent(_draggedEntity.Value)) { - RaisePredictiveEvent(new TabletopMoveEvent(_draggedEntity.Value, Transform(_draggedEntity.Value).MapPosition, _table!.Value)); - RaisePredictiveEvent(new TabletopDraggingPlayerChangedEvent(_draggedEntity.Value, false)); + RaisePredictiveEvent(new TabletopMoveEvent(GetNetEntity(_draggedEntity.Value), Transform(_draggedEntity.Value).MapPosition, GetNetEntity(_table!.Value))); + RaisePredictiveEvent(new TabletopDraggingPlayerChangedEvent(GetNetEntity(_draggedEntity.Value), false)); } _draggedEntity = null; diff --git a/Content.Client/UserInterface/Systems/Actions/ActionUIController.cs b/Content.Client/UserInterface/Systems/Actions/ActionUIController.cs index 7e288070b0..3e9a01e770 100644 --- a/Content.Client/UserInterface/Systems/Actions/ActionUIController.cs +++ b/Content.Client/UserInterface/Systems/Actions/ActionUIController.cs @@ -240,7 +240,7 @@ public sealed class ActionUIController : UIController, IOnStateChanged(action.EntityIcon.Value).Icon? + _dragShadow.Texture = EntityManager.GetComponent(entIcon.Value).Icon? .GetFrame(RSI.State.Direction.South, 0); } else if (action.Icon != null) @@ -958,11 +962,13 @@ public sealed class ActionUIController : UIController, IOnStateChanged(out var handOverlay)) { if (action.ItemIconStyle == ItemActionIconStyle.BigItem && action.Provider != null) { - handOverlay.EntityOverride = action.Provider; + handOverlay.EntityOverride = provider; } else if (action.Toggled && action.IconOn != null) handOverlay.IconOverride = _spriteSystem.Frame0(action.IconOn); @@ -979,9 +985,10 @@ public sealed class ActionUIController : UIController, IOnStateChanged? predicate = null; + var attachedEnt = entityAction.AttachedEntity; if (!entityAction.CanTargetSelf) - predicate = e => e != entityAction.AttachedEntity; + predicate = e => e != attachedEnt; var range = entityAction.CheckCanAccess ? action.Range : -1; diff --git a/Content.Client/UserInterface/Systems/Chat/ChatUIController.cs b/Content.Client/UserInterface/Systems/Chat/ChatUIController.cs index 50431a7c57..0451a4a3aa 100644 --- a/Content.Client/UserInterface/Systems/Chat/ChatUIController.cs +++ b/Content.Client/UserInterface/Systems/Chat/ChatUIController.cs @@ -41,7 +41,6 @@ public sealed class ChatUIController : UIController [Dependency] private readonly IClientAdminManager _admin = default!; [Dependency] private readonly IChatManager _manager = default!; [Dependency] private readonly IConfigurationManager _config = default!; - [Dependency] private readonly IEntityManager _entities = default!; [Dependency] private readonly IEyeManager _eye = default!; [Dependency] private readonly IInputManager _input = default!; [Dependency] private readonly IClientNetManager _net = default!; @@ -390,7 +389,9 @@ public sealed class ChatUIController : UIController private void AddSpeechBubble(ChatMessage msg, SpeechBubble.SpeechType speechType) { - if (!_entities.EntityExists(msg.SenderEntity)) + var ent = EntityManager.GetEntity(msg.SenderEntity); + + if (!EntityManager.EntityExists(ent)) { _sawmill.Debug("Got local chat message with invalid sender entity: {0}", msg.SenderEntity); return; @@ -401,14 +402,14 @@ public sealed class ChatUIController : UIController foreach (var message in messages) { - EnqueueSpeechBubble(msg.SenderEntity, message, speechType); + EnqueueSpeechBubble(ent, message, speechType); } } private void CreateSpeechBubble(EntityUid entity, SpeechBubbleData speechData) { var bubble = - SpeechBubble.CreateSpeechBubble(speechData.Type, speechData.Message, entity, _eye, _manager, _entities); + SpeechBubble.CreateSpeechBubble(speechData.Type, speechData.Message, entity, _eye, _manager, EntityManager); bubble.OnDied += SpeechBubbleDied; @@ -445,7 +446,7 @@ public sealed class ChatUIController : UIController private void EnqueueSpeechBubble(EntityUid entity, string contents, SpeechBubble.SpeechType speechType) { // Don't enqueue speech bubbles for other maps. TODO: Support multiple viewports/maps? - if (_entities.GetComponent(entity).MapID != _eye.CurrentMap) + if (EntityManager.GetComponent(entity).MapID != _eye.CurrentMap) return; if (!_queuedSpeechBubbles.TryGetValue(entity, out var queueData)) @@ -562,7 +563,7 @@ public sealed class ChatUIController : UIController foreach (var (entity, queueData) in _queuedSpeechBubbles.ShallowClone()) { - if (!_entities.EntityExists(entity)) + if (!EntityManager.EntityExists(entity)) { _queuedSpeechBubbles.Remove(entity); continue; @@ -593,14 +594,14 @@ public sealed class ChatUIController : UIController var predicate = static (EntityUid uid, (EntityUid compOwner, EntityUid? attachedEntity) data) => uid == data.compOwner || uid == data.attachedEntity; var playerPos = player != null - ? _entities.GetComponent(player.Value).MapPosition + ? EntityManager.GetComponent(player.Value).MapPosition : MapCoordinates.Nullspace; var occluded = player != null && _examine.IsOccluded(player.Value); foreach (var (ent, bubs) in _activeSpeechBubbles) { - if (_entities.Deleted(ent)) + if (EntityManager.Deleted(ent)) { SetBubbles(bubs, false); continue; @@ -612,7 +613,7 @@ public sealed class ChatUIController : UIController continue; } - var otherPos = _entities.GetComponent(ent).MapPosition; + var otherPos = EntityManager.GetComponent(ent).MapPosition; if (occluded && !ExamineSystemShared.InRangeUnOccluded( playerPos, diff --git a/Content.Client/UserInterface/Systems/Ghost/Controls/GhostTargetWindow.xaml.cs b/Content.Client/UserInterface/Systems/Ghost/Controls/GhostTargetWindow.xaml.cs index 314e77fb0a..1417b47771 100644 --- a/Content.Client/UserInterface/Systems/Ghost/Controls/GhostTargetWindow.xaml.cs +++ b/Content.Client/UserInterface/Systems/Ghost/Controls/GhostTargetWindow.xaml.cs @@ -20,7 +20,7 @@ namespace Content.Client.UserInterface.Systems.Ghost.Controls RobustXamlLoader.Load(this); } - public void UpdateWarps(IEnumerable warps) + public void UpdateWarps(IEnumerable warps, IEntityManager entManager) { // Server COULD send these sorted but how about we just use the client to do it instead _warps = warps @@ -33,7 +33,7 @@ namespace Content.Client.UserInterface.Systems.Ghost.Controls ? Loc.GetString("ghost-target-window-current-button", ("name", w.DisplayName)) : w.DisplayName; - return (name, w.Entity); + return (name, entManager.GetEntity(w.Entity)); }) .ToList(); } diff --git a/Content.Client/UserInterface/Systems/Ghost/Controls/Roles/MakeGhostRoleEui.cs b/Content.Client/UserInterface/Systems/Ghost/Controls/Roles/MakeGhostRoleEui.cs index a6d27a7793..1f41edb931 100644 --- a/Content.Client/UserInterface/Systems/Ghost/Controls/Roles/MakeGhostRoleEui.cs +++ b/Content.Client/UserInterface/Systems/Ghost/Controls/Roles/MakeGhostRoleEui.cs @@ -11,6 +11,7 @@ namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles [UsedImplicitly] public sealed class MakeGhostRoleEui : BaseEui { + [Dependency] private readonly IEntityManager _entManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IClientConsoleHost _consoleHost = default!; @@ -32,7 +33,7 @@ namespace Content.Client.UserInterface.Systems.Ghost.Controls.Roles return; } - _window.SetEntity(uiState.EntityUid); + _window.SetEntity(_entManager.GetEntity(uiState.EntityUid)); } public override void Opened() diff --git a/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs b/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs index d45ff4ee9e..709b7c553c 100644 --- a/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs +++ b/Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs @@ -96,7 +96,7 @@ public sealed class GhostUIController : UIController, IOnSystemChanged(hoverEntity); var fits = _inventorySystem.CanEquip(player.Value, held, control.SlotName, out _, slotDef) && - container.CanInsert(held, _entities); + _container.CanInsert(held, container); hoverSprite.CopyFrom(sprite); hoverSprite.Color = fits ? new Color(0, 255, 0, 127) : new Color(255, 0, 0, 127); diff --git a/Content.Client/Vehicle/VehicleSystem.cs b/Content.Client/Vehicle/VehicleSystem.cs index 007ce34ff0..4cc4b8732e 100644 --- a/Content.Client/Vehicle/VehicleSystem.cs +++ b/Content.Client/Vehicle/VehicleSystem.cs @@ -36,10 +36,12 @@ public sealed class VehicleSystem : SharedVehicleSystem if (args.Current is not RiderComponentState state) return; - if (TryComp(uid, out EyeComponent? eyeComp) && eyeComp.Target == component.Vehicle) - eyeComp.Target = state.Entity; + var entity = EnsureEntity(state.Entity, uid); - component.Vehicle = state.Entity; + if (TryComp(uid, out EyeComponent? eyeComp) && eyeComp.Target == component.Vehicle) + eyeComp.Target = entity; + + component.Vehicle = entity; } private void OnVehicleAppearanceChange(EntityUid uid, VehicleComponent component, ref AppearanceChangeEvent args) diff --git a/Content.Client/Verbs/UI/VerbMenuElement.cs b/Content.Client/Verbs/UI/VerbMenuElement.cs index d124ca6da4..0cb6e15147 100644 --- a/Content.Client/Verbs/UI/VerbMenuElement.cs +++ b/Content.Client/Verbs/UI/VerbMenuElement.cs @@ -51,7 +51,7 @@ namespace Content.Client.Verbs.UI OverrideDirection = Direction.South, SetSize = new Vector2(ElementHeight, ElementHeight), }; - spriteView.SetEntity(verb.IconEntity.Value); + spriteView.SetEntity(entManager.GetEntity(verb.IconEntity.Value)); Icon.AddChild(spriteView); return; diff --git a/Content.Client/Verbs/UI/VerbMenuUIController.cs b/Content.Client/Verbs/UI/VerbMenuUIController.cs index 6ede75f33b..08a16b49fd 100644 --- a/Content.Client/Verbs/UI/VerbMenuUIController.cs +++ b/Content.Client/Verbs/UI/VerbMenuUIController.cs @@ -82,7 +82,7 @@ namespace Content.Client.Verbs.UI // Add indicator that some verbs may be missing. // I long for the day when verbs will all be predicted and this becomes unnecessary. - if (!target.IsClientSide()) + if (!EntityManager.IsClientSide(target)) { _context.AddElement(menu, new ContextMenuElement(Loc.GetString("verb-system-waiting-on-server-text"))); } @@ -244,7 +244,7 @@ namespace Content.Client.Verbs.UI private void HandleVerbsResponse(VerbsResponseEvent msg) { - if (OpenMenu == null || !OpenMenu.Visible || CurrentTarget != msg.Entity) + if (OpenMenu == null || !OpenMenu.Visible || CurrentTarget != EntityManager.GetEntity(msg.Entity)) return; AddServerVerbs(msg.Verbs, OpenMenu); diff --git a/Content.Client/Verbs/VerbSystem.cs b/Content.Client/Verbs/VerbSystem.cs index 1fcd7fd184..e71da351b9 100644 --- a/Content.Client/Verbs/VerbSystem.cs +++ b/Content.Client/Verbs/VerbSystem.cs @@ -180,9 +180,9 @@ namespace Content.Client.Verbs public SortedSet GetVerbs(EntityUid target, EntityUid user, List verbTypes, bool force = false) { - if (!target.IsClientSide()) + if (!IsClientSide(target)) { - RaiseNetworkEvent(new RequestServerVerbsEvent(target, verbTypes, adminRequest: force)); + RaiseNetworkEvent(new RequestServerVerbsEvent(GetNetEntity(target), verbTypes, adminRequest: force)); } // Some admin menu interactions will try get verbs for entities that have not yet been sent to the player. @@ -214,11 +214,11 @@ namespace Content.Client.Verbs return; } - if (verb.ClientExclusive || target.IsClientSide()) + if (verb.ClientExclusive || IsClientSide(target)) // is this a client exclusive (gui) verb? ExecuteVerb(verb, user.Value, target); else - EntityManager.RaisePredictiveEvent(new ExecuteVerbEvent(target, verb)); + EntityManager.RaisePredictiveEvent(new ExecuteVerbEvent(GetNetEntity(target), verb)); } private void HandleVerbResponse(VerbsResponseEvent msg) diff --git a/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs b/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs index 2ae6dbdbf4..5770af23aa 100644 --- a/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs +++ b/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs @@ -74,7 +74,7 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem { if (weapon.Attacking) { - RaisePredictiveEvent(new StopAttackEvent(weaponUid)); + RaisePredictiveEvent(new StopAttackEvent(GetNetEntity(weaponUid))); } } @@ -126,7 +126,7 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem target = screen.GetClickedEntity(mousePos); } - EntityManager.RaisePredictiveEvent(new DisarmAttackEvent(target, coordinates)); + EntityManager.RaisePredictiveEvent(new DisarmAttackEvent(GetNetEntity(target), GetNetCoordinates(coordinates))); return; } @@ -152,7 +152,7 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem target = screen.GetClickedEntity(mousePos); } - RaisePredictiveEvent(new LightAttackEvent(target, weaponUid, coordinates)); + RaisePredictiveEvent(new LightAttackEvent(GetNetEntity(target), GetNetEntity(weaponUid), GetNetCoordinates(coordinates))); } } @@ -182,15 +182,17 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem return false; } + var target = GetEntity(ev.Target); + // They need to either have hands... - if (!HasComp(ev.Target!.Value)) + if (!HasComp(target!.Value)) { // or just be able to be shoved over. - if (TryComp(ev.Target!.Value, out var status) && status.AllowedEffects.Contains("KnockedDown")) + if (TryComp(target, out var status) && status.AllowedEffects.Contains("KnockedDown")) return true; - if (Timing.IsFirstTimePredicted && HasComp(ev.Target.Value)) - PopupSystem.PopupEntity(Loc.GetString("disarm-action-disarmable", ("targetName", ev.Target.Value)), ev.Target.Value); + if (Timing.IsFirstTimePredicted && HasComp(target.Value)) + PopupSystem.PopupEntity(Loc.GetString("disarm-action-disarmable", ("targetName", target.Value)), target.Value); return false; } @@ -222,14 +224,16 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem // This should really be improved. GetEntitiesInArc uses pos instead of bounding boxes. // Server will validate it with InRangeUnobstructed. - var entities = ArcRayCast(userPos, direction.ToWorldAngle(), component.Angle, distance, userXform.MapID, user).ToList(); - RaisePredictiveEvent(new HeavyAttackEvent(meleeUid, entities.GetRange(0, Math.Min(MaxTargets, entities.Count)), coordinates)); + var entities = GetNetEntityList(ArcRayCast(userPos, direction.ToWorldAngle(), component.Angle, distance, userXform.MapID, user).ToList()); + RaisePredictiveEvent(new HeavyAttackEvent(GetNetEntity(meleeUid), entities.GetRange(0, Math.Min(MaxTargets, entities.Count)), GetNetCoordinates(coordinates))); } private void OnMeleeLunge(MeleeLungeEvent ev) { + var ent = GetEntity(ev.Entity); + // Entity might not have been sent by PVS. - if (Exists(ev.Entity)) - DoLunge(ev.Entity, ev.Angle, ev.LocalPos, ev.Animation); + if (Exists(ent)) + DoLunge(ent, ev.Angle, ev.LocalPos, ev.Animation); } } diff --git a/Content.Client/Weapons/Misc/TetherGunSystem.cs b/Content.Client/Weapons/Misc/TetherGunSystem.cs index 2063fa6cf1..dd8f283cbf 100644 --- a/Content.Client/Weapons/Misc/TetherGunSystem.cs +++ b/Content.Client/Weapons/Misc/TetherGunSystem.cs @@ -91,7 +91,7 @@ public sealed class TetherGunSystem : SharedTetherGunSystem RaisePredictiveEvent(new RequestTetherMoveEvent() { - Coordinates = coords + Coordinates = GetNetCoordinates(coords) }); } diff --git a/Content.Client/Weapons/Ranged/Systems/GunSystem.Ballistic.cs b/Content.Client/Weapons/Ranged/Systems/GunSystem.Ballistic.cs index 6c203f7676..e0d4fa8e84 100644 --- a/Content.Client/Weapons/Ranged/Systems/GunSystem.Ballistic.cs +++ b/Content.Client/Weapons/Ranged/Systems/GunSystem.Ballistic.cs @@ -43,7 +43,7 @@ public sealed partial class GunSystem EnsureShootable(ent.Value); } - if (ent != null && ent.Value.IsClientSide()) + if (ent != null && IsClientSide(ent.Value)) Del(ent.Value); var cycledEvent = new GunCycledEvent(); diff --git a/Content.Client/Weapons/Ranged/Systems/GunSystem.ChamberMagazine.cs b/Content.Client/Weapons/Ranged/Systems/GunSystem.ChamberMagazine.cs index 0f1595010f..52c2caaa3a 100644 --- a/Content.Client/Weapons/Ranged/Systems/GunSystem.ChamberMagazine.cs +++ b/Content.Client/Weapons/Ranged/Systems/GunSystem.ChamberMagazine.cs @@ -47,7 +47,7 @@ public sealed partial class GunSystem // This is dirty af. Prediction moment. // We may be predicting spawning entities and the engine just removes them from the container so we'll just delete them. - if (removedArgs.Entity.IsClientSide()) + if (IsClientSide(removedArgs.Entity)) QueueDel(args.Entity); // AFAIK the only main alternative is having some client-specific handling via a bool or otherwise for the state. diff --git a/Content.Client/Weapons/Ranged/Systems/GunSystem.Revolver.cs b/Content.Client/Weapons/Ranged/Systems/GunSystem.Revolver.cs index 93e8266169..33a4042daf 100644 --- a/Content.Client/Weapons/Ranged/Systems/GunSystem.Revolver.cs +++ b/Content.Client/Weapons/Ranged/Systems/GunSystem.Revolver.cs @@ -16,10 +16,12 @@ public sealed partial class GunSystem private void OnRevolverEntRemove(EntityUid uid, RevolverAmmoProviderComponent component, EntRemovedFromContainerMessage args) { - if (args.Container.ID != RevolverContainer) return; + if (args.Container.ID != RevolverContainer) + return; // See ChamberMagazineAmmoProvider - if (!args.Entity.IsClientSide()) return; + if (!IsClientSide(args.Entity)) + return; QueueDel(args.Entity); } diff --git a/Content.Client/Weapons/Ranged/Systems/GunSystem.cs b/Content.Client/Weapons/Ranged/Systems/GunSystem.cs index 4ecd72561f..422d97c5b2 100644 --- a/Content.Client/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Client/Weapons/Ranged/Systems/GunSystem.cs @@ -16,6 +16,7 @@ using Robust.Client.Player; using Robust.Shared.Animations; using Robust.Shared.Input; using Robust.Shared.Map; +using Robust.Shared.Prototypes; using Robust.Shared.Utility; using SharedGunSystem = Content.Shared.Weapons.Ranged.Systems.SharedGunSystem; @@ -30,6 +31,9 @@ public sealed partial class GunSystem : SharedGunSystem [Dependency] private readonly InputSystem _inputSystem = default!; [Dependency] private readonly SharedCameraRecoilSystem _recoil = default!; + [ValidatePrototypeId] + public const string HitscanProto = "HitscanEffect"; + public bool SpreadOverlay { get => _spreadOverlay; @@ -76,7 +80,7 @@ public sealed partial class GunSystem : SharedGunSystem private void OnMuzzleFlash(MuzzleFlashEvent args) { - CreateEffect(args.Uid, args); + CreateEffect(GetEntity(args.Uid), args); } private void OnHitscan(HitscanEvent ev) @@ -84,13 +88,15 @@ public sealed partial class GunSystem : SharedGunSystem // ALL I WANT IS AN ANIMATED EFFECT foreach (var a in ev.Sprites) { - if (a.Sprite is not SpriteSpecifier.Rsi rsi || - Deleted(a.coordinates.EntityId)) - { + if (a.Sprite is not SpriteSpecifier.Rsi rsi) continue; - } - var ent = Spawn("HitscanEffect", a.coordinates); + var coords = GetCoordinates(a.coordinates); + + if (Deleted(coords.EntityId)) + continue; + + var ent = Spawn(HitscanProto, coords); var sprite = Comp(ent); var xform = Transform(ent); xform.LocalRotation = a.angle; @@ -144,7 +150,7 @@ public sealed partial class GunSystem : SharedGunSystem if (_inputSystem.CmdStates.GetState(useKey) != BoundKeyState.Down) { if (gun.ShotCounter != 0) - EntityManager.RaisePredictiveEvent(new RequestStopShootEvent { Gun = gunUid }); + EntityManager.RaisePredictiveEvent(new RequestStopShootEvent { Gun = GetNetEntity(gunUid) }); return; } @@ -156,7 +162,7 @@ public sealed partial class GunSystem : SharedGunSystem if (mousePos.MapId == MapId.Nullspace) { if (gun.ShotCounter != 0) - EntityManager.RaisePredictiveEvent(new RequestStopShootEvent { Gun = gunUid }); + EntityManager.RaisePredictiveEvent(new RequestStopShootEvent { Gun = GetNetEntity(gunUid) }); return; } @@ -168,8 +174,8 @@ public sealed partial class GunSystem : SharedGunSystem EntityManager.RaisePredictiveEvent(new RequestShootEvent { - Coordinates = coordinates, - Gun = gunUid, + Coordinates = GetNetCoordinates(coordinates), + Gun = GetNetEntity(gunUid), }); } @@ -188,7 +194,7 @@ public sealed partial class GunSystem : SharedGunSystem if (throwItems) { Recoil(user, direction, gun.CameraRecoilScalar); - if (ent!.Value.IsClientSide()) + if (IsClientSide(ent!.Value)) Del(ent.Value); else RemoveShootable(ent.Value); @@ -214,7 +220,7 @@ public sealed partial class GunSystem : SharedGunSystem Audio.PlayPredicted(gun.SoundEmpty, gunUid, user); } - if (ent!.Value.IsClientSide()) + if (IsClientSide(ent!.Value)) Del(ent.Value); break; @@ -222,7 +228,7 @@ public sealed partial class GunSystem : SharedGunSystem MuzzleFlash(gunUid, newAmmo, user); Audio.PlayPredicted(gun.SoundGunshot, gunUid, user); Recoil(user, direction, gun.CameraRecoilScalar); - if (ent!.Value.IsClientSide()) + if (IsClientSide(ent!.Value)) Del(ent.Value); else RemoveShootable(ent.Value); diff --git a/Content.Client/Xenoarchaeology/Ui/AnalysisConsoleMenu.xaml.cs b/Content.Client/Xenoarchaeology/Ui/AnalysisConsoleMenu.xaml.cs index 75ba43df2f..1a8ba6c8c9 100644 --- a/Content.Client/Xenoarchaeology/Ui/AnalysisConsoleMenu.xaml.cs +++ b/Content.Client/Xenoarchaeology/Ui/AnalysisConsoleMenu.xaml.cs @@ -71,7 +71,7 @@ public sealed partial class AnalysisConsoleMenu : FancyWindow return; } - UpdateArtifactIcon(state.Artifact); + UpdateArtifactIcon(_ent.GetEntity(state.Artifact)); if (state.ScanReport == null) { diff --git a/Content.IntegrationTests/Pair/TestMapData.cs b/Content.IntegrationTests/Pair/TestMapData.cs index 62fefd8722..bdf1208038 100644 --- a/Content.IntegrationTests/Pair/TestMapData.cs +++ b/Content.IntegrationTests/Pair/TestMapData.cs @@ -16,4 +16,9 @@ public sealed class TestMapData public EntityCoordinates GridCoords { get; set; } public MapCoordinates MapCoords { get; set; } public TileRef Tile { get; set; } + + // Client-side uids + public EntityUid CMapUid { get; set; } + public EntityUid CGridUid { get; set; } + public EntityCoordinates CGridCoords { get; set; } } \ No newline at end of file diff --git a/Content.IntegrationTests/Pair/TestPair.Helpers.cs b/Content.IntegrationTests/Pair/TestPair.Helpers.cs index fc48bfec30..1478a4c7d2 100644 --- a/Content.IntegrationTests/Pair/TestPair.Helpers.cs +++ b/Content.IntegrationTests/Pair/TestPair.Helpers.cs @@ -1,6 +1,8 @@ #nullable enable using System.Linq; +using Robust.Shared.GameObjects; using Robust.Shared.Map; +using Robust.UnitTesting; namespace Content.IntegrationTests.Pair; @@ -16,6 +18,7 @@ public sealed partial class TestPair var tileDefinitionManager = Server.ResolveDependency(); var mapData = new TestMapData(); + TestMap = mapData; await Server.WaitPost(() => { mapData.MapId = Server.MapMan.CreateMap(); @@ -29,11 +32,48 @@ public sealed partial class TestPair mapData.MapCoords = new MapCoordinates(0, 0, mapData.MapId); mapData.Tile = mapData.MapGrid.GetAllTiles().First(); }); - - if (Settings.Connected) - await RunTicksSync(10); - TestMap = mapData; + if (!Settings.Connected) + return mapData; + + await RunTicksSync(10); + mapData.CMapUid = ToClientUid(mapData.MapUid); + mapData.CGridUid = ToClientUid(mapData.GridUid); + mapData.CGridCoords = new EntityCoordinates(mapData.CGridUid, 0, 0); + return mapData; } -} \ No newline at end of file + + /// + /// Convert a client-side uid into a server-side uid + /// + public EntityUid ToServerUid(EntityUid uid) => ConvertUid(uid, Client, Server); + + /// + /// Convert a server-side uid into a client-side uid + /// + public EntityUid ToClientUid(EntityUid uid) => ConvertUid(uid, Server, Client); + + private static EntityUid ConvertUid( + EntityUid uid, + RobustIntegrationTest.IntegrationInstance source, + RobustIntegrationTest.IntegrationInstance destination) + { + if (!uid.IsValid()) + return EntityUid.Invalid; + + if (!source.EntMan.TryGetComponent(uid, out var meta)) + { + Assert.Fail($"Failed to resolve MetaData while converting the EntityUid for entity {uid}"); + return EntityUid.Invalid; + } + + if (!destination.EntMan.TryGetEntity(meta.NetEntity, out var otherUid)) + { + Assert.Fail($"Failed to resolve net ID while converting the EntityUid entity {source.EntMan.ToPrettyString(uid)}"); + return EntityUid.Invalid; + } + + return otherUid.Value; + } +} diff --git a/Content.IntegrationTests/Tests/Actions/ActionsAddedTest.cs b/Content.IntegrationTests/Tests/Actions/ActionsAddedTest.cs index c61fa8974f..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; @@ -23,30 +25,32 @@ public sealed class ActionsAddedTest var client = pair.Client; var sEntMan = server.ResolveDependency(); var cEntMan = client.ResolveDependency(); - var session = server.ResolveDependency().ServerSessions.Single(); + var clientSession = client.ResolveDependency().LocalPlayer?.Session; + var serverSession = server.ResolveDependency().ServerSessions.Single(); var sActionSystem = server.System(); var cActionSystem = client.System(); // Dummy ticker is disabled - client should be in control of a normal mob. - Assert.NotNull(session.AttachedEntity); - var ent = session.AttachedEntity!.Value; - Assert.That(sEntMan.EntityExists(ent)); - Assert.That(cEntMan.EntityExists(ent)); - Assert.That(sEntMan.HasComponent(ent)); - Assert.That(cEntMan.HasComponent(ent)); - Assert.That(sEntMan.HasComponent(ent)); - Assert.That(cEntMan.HasComponent(ent)); + Assert.NotNull(serverSession.AttachedEntity); + var serverEnt = serverSession.AttachedEntity!.Value; + var clientEnt = clientSession!.AttachedEntity!.Value; + Assert.That(sEntMan.EntityExists(serverEnt)); + Assert.That(cEntMan.EntityExists(clientEnt)); + Assert.That(sEntMan.HasComponent(serverEnt)); + Assert.That(cEntMan.HasComponent(clientEnt)); + Assert.That(sEntMan.HasComponent(serverEnt)); + Assert.That(cEntMan.HasComponent(clientEnt)); - var sComp = sEntMan.GetComponent(ent); - var cComp = cEntMan.GetComponent(ent); + var sComp = sEntMan.GetComponent(serverEnt); + var cComp = cEntMan.GetComponent(clientEnt); // Mob should have a combat-mode action. // This action should have a non-null event both on the server & client. var evType = typeof(ToggleCombatActionEvent); - var sActions = sActionSystem.GetActions(ent).Where( + var sActions = sActionSystem.GetActions(serverEnt).Where( x => x.Comp is InstantActionComponent act && act.Event?.GetType() == evType).ToArray(); - var cActions = cActionSystem.GetActions(ent).Where( + var cActions = cActionSystem.GetActions(clientEnt).Where( x => x.Comp is InstantActionComponent act && act.Event?.GetType() == evType).ToArray(); Assert.That(sActions.Length, Is.EqualTo(1)); diff --git a/Content.IntegrationTests/Tests/Chemistry/DispenserTest.cs b/Content.IntegrationTests/Tests/Chemistry/DispenserTest.cs index affb43db3e..13a0bee28e 100644 --- a/Content.IntegrationTests/Tests/Chemistry/DispenserTest.cs +++ b/Content.IntegrationTests/Tests/Chemistry/DispenserTest.cs @@ -29,7 +29,7 @@ public sealed class DispenserTest : InteractionTest // Beaker is back in the player's hands Assert.That(Hands.ActiveHandEntity, Is.Not.Null); - AssertPrototype("Beaker", Hands.ActiveHandEntity); + AssertPrototype("Beaker", SEntMan.GetNetEntity(Hands.ActiveHandEntity)); // Re-insert the beaker await Interact(); @@ -40,6 +40,6 @@ public sealed class DispenserTest : InteractionTest await ClickControl(nameof(ReagentDispenserWindow.EjectButton)); await RunTicks(5); Assert.That(Hands.ActiveHandEntity, Is.Not.Null); - AssertPrototype("Beaker", Hands.ActiveHandEntity); + AssertPrototype("Beaker", SEntMan.GetNetEntity(Hands.ActiveHandEntity)); } } diff --git a/Content.IntegrationTests/Tests/ClickableTest.cs b/Content.IntegrationTests/Tests/ClickableTest.cs index 8a0725ddaa..7608538185 100644 --- a/Content.IntegrationTests/Tests/ClickableTest.cs +++ b/Content.IntegrationTests/Tests/ClickableTest.cs @@ -47,7 +47,7 @@ namespace Content.IntegrationTests.Tests await using var pair = await PoolManager.GetServerClient(new PoolSettings { Connected = true }); var server = pair.Server; var client = pair.Client; - EntityUid entity = default; + var clientEntManager = client.ResolveDependency(); var serverEntManager = server.ResolveDependency(); var eyeManager = client.ResolveDependency(); @@ -56,35 +56,38 @@ namespace Content.IntegrationTests.Tests var eye = client.ResolveDependency().CurrentEye; var testMap = await pair.CreateTestMap(); + + EntityUid serverEnt = default; + await server.WaitPost(() => { - var ent = serverEntManager.SpawnEntity(prototype, testMap.GridCoords); - serverEntManager.System().SetWorldRotation(ent, angle); - entity = ent; + serverEnt = serverEntManager.SpawnEntity(prototype, testMap.GridCoords); + serverEntManager.System().SetWorldRotation(serverEnt, angle); }); // Let client sync up. await pair.RunTicksSync(5); var hit = false; + var clientEnt = clientEntManager.GetEntity(serverEntManager.GetNetEntity(serverEnt)); await client.WaitPost(() => { - var sprite = spriteQuery.GetComponent(entity); + var sprite = spriteQuery.GetComponent(clientEnt); sprite.Scale = new Vector2(scale, scale); // these tests currently all assume player eye is 0 eyeManager.CurrentEye.Rotation = 0; - var pos = clientEntManager.System().GetWorldPosition(entity); - var clickable = clientEntManager.GetComponent(entity); + var pos = clientEntManager.System().GetWorldPosition(clientEnt); + var clickable = clientEntManager.GetComponent(clientEnt); - hit = clickable.CheckClick(sprite, xformQuery.GetComponent(entity), xformQuery, new Vector2(clickPosX, clickPosY) + pos, eye, out _, out _, out _); + hit = clickable.CheckClick(sprite, xformQuery.GetComponent(clientEnt), xformQuery, new Vector2(clickPosX, clickPosY) + pos, eye, out _, out _, out _); }); await server.WaitPost(() => { - serverEntManager.DeleteEntity(entity); + serverEntManager.DeleteEntity(serverEnt); }); await pair.CleanReturnAsync(); diff --git a/Content.IntegrationTests/Tests/Climbing/ClimbingTest.cs b/Content.IntegrationTests/Tests/Climbing/ClimbingTest.cs index e909775793..f6bcc6e129 100644 --- a/Content.IntegrationTests/Tests/Climbing/ClimbingTest.cs +++ b/Content.IntegrationTests/Tests/Climbing/ClimbingTest.cs @@ -29,7 +29,7 @@ public sealed class ClimbingTest : MovementTest // Try to start climbing var sys = SEntMan.System(); - await Server.WaitPost(() => sys.TryClimb(Player, Player, Target.Value, out _)); + await Server.WaitPost(() => sys.TryClimb(SEntMan.GetEntity(Player), SEntMan.GetEntity(Player), SEntMan.GetEntity(Target.Value), out _)); await AwaitDoAfters(); // Player should now be climbing @@ -56,7 +56,7 @@ public sealed class ClimbingTest : MovementTest Assert.That(Delta(), Is.LessThan(0)); // Start climbing - await Server.WaitPost(() => sys.TryClimb(Player, Player, Target.Value, out _)); + await Server.WaitPost(() => sys.TryClimb(SEntMan.GetEntity(Player), SEntMan.GetEntity(Player), SEntMan.GetEntity(Target.Value), out _)); await AwaitDoAfters(); Assert.Multiple(() => diff --git a/Content.IntegrationTests/Tests/Construction/Interaction/ComputerContruction.cs b/Content.IntegrationTests/Tests/Construction/Interaction/ComputerContruction.cs index 87f3c06c12..1cf0135d7a 100644 --- a/Content.IntegrationTests/Tests/Construction/Interaction/ComputerContruction.cs +++ b/Content.IntegrationTests/Tests/Construction/Interaction/ComputerContruction.cs @@ -17,7 +17,9 @@ public sealed class ComputerConstruction : InteractionTest // Initial interaction (ghost turns into real entity) await Interact(Steel, 5); - AssertPrototype(ComputerFrame); + ClientAssertPrototype(ComputerFrame, ClientTarget); + Target = CTestSystem.Ghosts[ClientTarget!.Value.GetHashCode()]; + ClientTarget = null; // Perform construction steps await Interact( @@ -29,7 +31,7 @@ public sealed class ComputerConstruction : InteractionTest Screw); // Construction finished, target entity was replaced with a new one: - AssertPrototype(ComputerId); + AssertPrototype(ComputerId, Target); } [Test] diff --git a/Content.IntegrationTests/Tests/Construction/Interaction/CraftingTests.cs b/Content.IntegrationTests/Tests/Construction/Interaction/CraftingTests.cs index 5c48703dff..c49e20981e 100644 --- a/Content.IntegrationTests/Tests/Construction/Interaction/CraftingTests.cs +++ b/Content.IntegrationTests/Tests/Construction/Interaction/CraftingTests.cs @@ -1,5 +1,6 @@ using System.Linq; using Content.IntegrationTests.Tests.Interaction; +using Content.Shared.DoAfter; using Content.Shared.Stacks; using Robust.Shared.Containers; @@ -40,7 +41,7 @@ public sealed class CraftingTests : InteractionTest { // Spawn a full tack of rods in the user's hands. await PlaceInHands(Rod, 10); - await SpawnEntity((Cable, 10), PlayerCoords); + await SpawnEntity((Cable, 10), SEntMan.GetCoordinates(PlayerCoords)); // Attempt (and fail) to craft without glass. await CraftItem(Spear, shouldSucceed: false); @@ -69,9 +70,10 @@ public sealed class CraftingTests : InteractionTest [Test] public async Task CancelCraft() { - var rods = await SpawnEntity((Rod, 10), TargetCoords); - var wires = await SpawnEntity((Cable, 10), TargetCoords); - var shard = await SpawnEntity(ShardGlass, TargetCoords); + var serverTargetCoords = SEntMan.GetCoordinates(TargetCoords); + var rods = await SpawnEntity((Rod, 10), serverTargetCoords); + var wires = await SpawnEntity((Cable, 10), serverTargetCoords); + var shard = await SpawnEntity(ShardGlass, serverTargetCoords); var rodStack = SEntMan.GetComponent(rods); var wireStack = SEntMan.GetComponent(wires); @@ -86,7 +88,7 @@ public sealed class CraftingTests : InteractionTest }); #pragma warning disable CS4014 // Legacy construction code uses DoAfterAwait. If we await it we will be waiting forever. - await Server.WaitPost(() => SConstruction.TryStartItemConstruction(Spear, Player)); + await Server.WaitPost(() => SConstruction.TryStartItemConstruction(Spear, SEntMan.GetEntity(Player))); #pragma warning restore CS4014 await RunTicks(1); @@ -116,7 +118,7 @@ public sealed class CraftingTests : InteractionTest // Re-attempt the do-after #pragma warning disable CS4014 // Legacy construction code uses DoAfterAwait. See above. - await Server.WaitPost(() => SConstruction.TryStartItemConstruction(Spear, Player)); + await Server.WaitPost(() => SConstruction.TryStartItemConstruction(Spear, SEntMan.GetEntity(Player))); #pragma warning restore CS4014 await RunTicks(1); diff --git a/Content.IntegrationTests/Tests/Construction/Interaction/GrilleWindowConstruction.cs b/Content.IntegrationTests/Tests/Construction/Interaction/GrilleWindowConstruction.cs index 1a2f4bcda1..0de39d2757 100644 --- a/Content.IntegrationTests/Tests/Construction/Interaction/GrilleWindowConstruction.cs +++ b/Content.IntegrationTests/Tests/Construction/Interaction/GrilleWindowConstruction.cs @@ -18,14 +18,16 @@ public sealed class GrilleWindowConstruction : InteractionTest // Construct Grille await StartConstruction(Grille); await Interact(Rod, 10); - AssertPrototype(Grille); + ClientAssertPrototype(Grille, ClientTarget); + Target = CTestSystem.Ghosts[ClientTarget!.Value.GetHashCode()]; var grille = Target; // Construct Window await StartConstruction(Window); await Interact(Glass, 10); - AssertPrototype(Window); + ClientAssertPrototype(Window, ClientTarget); + Target = CTestSystem.Ghosts[ClientTarget!.Value.GetHashCode()]; // Deconstruct Window await Interact(Screw, Wrench); @@ -50,7 +52,7 @@ public sealed class GrilleWindowConstruction : InteractionTest await Client.WaitPost(() => { var proto = ProtoMan.Index(second); - Assert.That(CConSys.TrySpawnGhost(proto, TargetCoords, Direction.South, out _), Is.False); + Assert.That(CConSys.TrySpawnGhost(proto, CEntMan.GetCoordinates(TargetCoords), Direction.South, out _), Is.False); }); } } diff --git a/Content.IntegrationTests/Tests/Construction/Interaction/MachineConstruction.cs b/Content.IntegrationTests/Tests/Construction/Interaction/MachineConstruction.cs index 0382912ccb..17630405a4 100644 --- a/Content.IntegrationTests/Tests/Construction/Interaction/MachineConstruction.cs +++ b/Content.IntegrationTests/Tests/Construction/Interaction/MachineConstruction.cs @@ -15,7 +15,8 @@ public sealed class MachineConstruction : InteractionTest { await StartConstruction(MachineFrame); await Interact(Steel, 5); - AssertPrototype(Unfinished); + ClientAssertPrototype(Unfinished, ClientTarget); + Target = CTestSystem.Ghosts[ClientTarget!.Value.GetHashCode()]; await Interact(Wrench, Cable); AssertPrototype(MachineFrame); await Interact(ProtolatheBoard, Bin1, Bin1, Manipulator1, Manipulator1, Beaker, Beaker, Screw); @@ -61,9 +62,10 @@ public sealed class MachineConstruction : InteractionTest { // Partially deconstruct a protolathe. await SpawnTarget(Protolathe); + var serverTarget = SEntMan.GetEntity(Target!.Value); // Initially has all quality-1 parts. - foreach (var part in SConstruction.GetAllParts(Target!.Value)) + foreach (var part in SConstruction.GetAllParts(serverTarget)) { Assert.That(part.Rating, Is.EqualTo(1)); } @@ -78,7 +80,7 @@ public sealed class MachineConstruction : InteractionTest AssertPrototype(Protolathe); // Query now returns higher quality parts. - foreach (var part in SConstruction.GetAllParts(Target!.Value)) + foreach (var part in SConstruction.GetAllParts(SEntMan.GetEntity(Target!.Value))) { Assert.That(part.Rating, Is.EqualTo(4)); } diff --git a/Content.IntegrationTests/Tests/Construction/Interaction/PanelScrewing.cs b/Content.IntegrationTests/Tests/Construction/Interaction/PanelScrewing.cs index 2f69f3abea..b6d960e288 100644 --- a/Content.IntegrationTests/Tests/Construction/Interaction/PanelScrewing.cs +++ b/Content.IntegrationTests/Tests/Construction/Interaction/PanelScrewing.cs @@ -1,4 +1,6 @@ +using System.Linq; using Content.IntegrationTests.Tests.Interaction; +using Content.Shared.DoAfter; using Content.Shared.Wires; namespace Content.IntegrationTests.Tests.Construction.Interaction; diff --git a/Content.IntegrationTests/Tests/Construction/Interaction/WallConstruction.cs b/Content.IntegrationTests/Tests/Construction/Interaction/WallConstruction.cs index 05cf8cac1b..67a2f8025d 100644 --- a/Content.IntegrationTests/Tests/Construction/Interaction/WallConstruction.cs +++ b/Content.IntegrationTests/Tests/Construction/Interaction/WallConstruction.cs @@ -14,7 +14,8 @@ public sealed class WallConstruction : InteractionTest await StartConstruction(Wall); await Interact(Steel, 2); Assert.That(Hands.ActiveHandEntity, Is.Null); - AssertPrototype(Girder); + ClientAssertPrototype(Girder, ClientTarget); + Target = CTestSystem.Ghosts[ClientTarget!.Value.GetHashCode()]; await Interact(Steel, 2); Assert.That(Hands.ActiveHandEntity, Is.Null); AssertPrototype(WallSolid); diff --git a/Content.IntegrationTests/Tests/Construction/Interaction/WindowConstruction.cs b/Content.IntegrationTests/Tests/Construction/Interaction/WindowConstruction.cs index 2be2020277..46bb892ed9 100644 --- a/Content.IntegrationTests/Tests/Construction/Interaction/WindowConstruction.cs +++ b/Content.IntegrationTests/Tests/Construction/Interaction/WindowConstruction.cs @@ -12,7 +12,7 @@ public sealed class WindowConstruction : InteractionTest { await StartConstruction(Window); await Interact(Glass, 5); - AssertPrototype(Window); + ClientAssertPrototype(Window, ClientTarget); } [Test] @@ -29,7 +29,7 @@ public sealed class WindowConstruction : InteractionTest { await StartConstruction(RWindow); await Interact(RGlass, 5); - AssertPrototype(RWindow); + ClientAssertPrototype(RWindow, ClientTarget); } [Test] diff --git a/Content.IntegrationTests/Tests/Construction/Interaction/WindowRepair.cs b/Content.IntegrationTests/Tests/Construction/Interaction/WindowRepair.cs index e04fbfd142..0bcc935fde 100644 --- a/Content.IntegrationTests/Tests/Construction/Interaction/WindowRepair.cs +++ b/Content.IntegrationTests/Tests/Construction/Interaction/WindowRepair.cs @@ -19,7 +19,7 @@ public sealed class WindowRepair : InteractionTest var damageType = Server.ResolveDependency().Index("Blunt"); var damage = new DamageSpecifier(damageType, FixedPoint2.New(10)); Assert.That(comp.Damage.Total, Is.EqualTo(FixedPoint2.Zero)); - await Server.WaitPost(() => sys.TryChangeDamage(Target, damage, ignoreResistances: true)); + await Server.WaitPost(() => sys.TryChangeDamage(SEntMan.GetEntity(Target), damage, ignoreResistances: true)); await RunTicks(5); Assert.That(comp.Damage.Total, Is.GreaterThan(FixedPoint2.Zero)); diff --git a/Content.IntegrationTests/Tests/ContainerOcclusionTest.cs b/Content.IntegrationTests/Tests/ContainerOcclusionTest.cs index a4af17c346..c61a70faf0 100644 --- a/Content.IntegrationTests/Tests/ContainerOcclusionTest.cs +++ b/Content.IntegrationTests/Tests/ContainerOcclusionTest.cs @@ -35,32 +35,34 @@ namespace Content.IntegrationTests.Tests public async Task TestA() { await using var pair = await PoolManager.GetServerClient(new PoolSettings { Connected = true }); - var s = pair.Server; - var c = pair.Client; + var server = pair.Server; + var client = pair.Client; - var cEntities = c.ResolveDependency(); - var ent = s.ResolveDependency(); + var clientEntManager = client.ResolveDependency(); + var serverEntManager = server.ResolveDependency(); EntityUid dummy = default; - var mapManager = s.ResolveDependency(); + var mapManager = server.ResolveDependency(); var mapId = mapManager.CreateMap(); - await s.WaitPost(() => + await server.WaitPost(() => { var pos = new MapCoordinates(Vector2.Zero, mapId); - var entStorage = ent.EntitySysManager.GetEntitySystem(); - var container = ent.SpawnEntity("ContainerOcclusionA", pos); - dummy = ent.SpawnEntity("ContainerOcclusionDummy", pos); + var entStorage = serverEntManager.EntitySysManager.GetEntitySystem(); + var container = serverEntManager.SpawnEntity("ContainerOcclusionA", pos); + dummy = serverEntManager.SpawnEntity("ContainerOcclusionDummy", pos); entStorage.Insert(dummy, container); }); await pair.RunTicksSync(5); - await c.WaitAssertion(() => + var clientEnt = clientEntManager.GetEntity(serverEntManager.GetNetEntity(dummy)); + + await client.WaitAssertion(() => { - var sprite = cEntities.GetComponent(dummy); - var light = cEntities.GetComponent(dummy); + var sprite = clientEntManager.GetComponent(clientEnt); + var light = clientEntManager.GetComponent(clientEnt); Assert.Multiple(() => { Assert.That(sprite.ContainerOccluded); @@ -75,32 +77,34 @@ namespace Content.IntegrationTests.Tests public async Task TestB() { await using var pair = await PoolManager.GetServerClient(new PoolSettings { Connected = true }); - var s = pair.Server; - var c = pair.Client; + var server = pair.Server; + var client = pair.Client; - var cEntities = c.ResolveDependency(); - var ent = s.ResolveDependency(); + var clientEntManager = client.ResolveDependency(); + var serverEntManager = server.ResolveDependency(); EntityUid dummy = default; - var mapManager = s.ResolveDependency(); + var mapManager = server.ResolveDependency(); var mapId = mapManager.CreateMap(); - await s.WaitPost(() => + await server.WaitPost(() => { var pos = new MapCoordinates(Vector2.Zero, mapId); - var entStorage = ent.EntitySysManager.GetEntitySystem(); - var container = ent.SpawnEntity("ContainerOcclusionB", pos); - dummy = ent.SpawnEntity("ContainerOcclusionDummy", pos); + var entStorage = serverEntManager.EntitySysManager.GetEntitySystem(); + var container = serverEntManager.SpawnEntity("ContainerOcclusionB", pos); + dummy = serverEntManager.SpawnEntity("ContainerOcclusionDummy", pos); entStorage.Insert(dummy, container); }); await pair.RunTicksSync(5); - await c.WaitAssertion(() => + var clientEnt = clientEntManager.GetEntity(serverEntManager.GetNetEntity(dummy)); + + await client.WaitAssertion(() => { - var sprite = cEntities.GetComponent(dummy); - var light = cEntities.GetComponent(dummy); + var sprite = clientEntManager.GetComponent(clientEnt); + var light = clientEntManager.GetComponent(clientEnt); Assert.Multiple(() => { Assert.That(sprite.ContainerOccluded, Is.False); @@ -115,23 +119,23 @@ namespace Content.IntegrationTests.Tests public async Task TestAb() { await using var pair = await PoolManager.GetServerClient(new PoolSettings { Connected = true }); - var s = pair.Server; - var c = pair.Client; + var server = pair.Server; + var client = pair.Client; - var cEntities = c.ResolveDependency(); - var ent = s.ResolveDependency(); + var clientEntManager = client.ResolveDependency(); + var serverEntManager = server.ResolveDependency(); EntityUid dummy = default; - var mapManager = s.ResolveDependency(); + var mapManager = server.ResolveDependency(); var mapId = mapManager.CreateMap(); - await s.WaitPost(() => + await server.WaitPost(() => { var pos = new MapCoordinates(Vector2.Zero, mapId); - var entStorage = ent.EntitySysManager.GetEntitySystem(); - var containerA = ent.SpawnEntity("ContainerOcclusionA", pos); - var containerB = ent.SpawnEntity("ContainerOcclusionB", pos); - dummy = ent.SpawnEntity("ContainerOcclusionDummy", pos); + var entStorage = serverEntManager.EntitySysManager.GetEntitySystem(); + var containerA = serverEntManager.SpawnEntity("ContainerOcclusionA", pos); + var containerB = serverEntManager.SpawnEntity("ContainerOcclusionB", pos); + dummy = serverEntManager.SpawnEntity("ContainerOcclusionDummy", pos); entStorage.Insert(containerB, containerA); entStorage.Insert(dummy, containerB); @@ -139,10 +143,12 @@ namespace Content.IntegrationTests.Tests await pair.RunTicksSync(5); - await c.WaitAssertion(() => + var clientEnt = clientEntManager.GetEntity(serverEntManager.GetNetEntity(dummy)); + + await client.WaitAssertion(() => { - var sprite = cEntities.GetComponent(dummy); - var light = cEntities.GetComponent(dummy); + var sprite = clientEntManager.GetComponent(clientEnt); + var light = clientEntManager.GetComponent(clientEnt); Assert.Multiple(() => { Assert.That(sprite.ContainerOccluded); diff --git a/Content.IntegrationTests/Tests/DoAfter/DoAfterCancellationTests.cs b/Content.IntegrationTests/Tests/DoAfter/DoAfterCancellationTests.cs index 16255d0773..5522ce8c54 100644 --- a/Content.IntegrationTests/Tests/DoAfter/DoAfterCancellationTests.cs +++ b/Content.IntegrationTests/Tests/DoAfter/DoAfterCancellationTests.cs @@ -3,6 +3,8 @@ using Content.IntegrationTests.Tests.Construction.Interaction; using Content.IntegrationTests.Tests.Interaction; using Content.IntegrationTests.Tests.Weldable; using Content.Shared.Tools.Components; +using Content.Server.Tools.Components; +using Content.Shared.DoAfter; namespace Content.IntegrationTests.Tests.DoAfter; @@ -50,10 +52,10 @@ public sealed class DoAfterCancellationTests : InteractionTest await StartConstruction(WallConstruction.Wall); await Interact(Steel, 5, awaitDoAfters: false); await CancelDoAfters(); - Assert.That(Target.HasValue && Target.Value.IsClientSide()); await Interact(Steel, 5); - AssertPrototype(WallConstruction.Girder); + ClientAssertPrototype(WallConstruction.Girder, ClientTarget); + Target = CTestSystem.Ghosts[ClientTarget!.Value.GetHashCode()]; await Interact(Steel, 5, awaitDoAfters: false); await CancelDoAfters(); AssertPrototype(WallConstruction.Girder); @@ -84,7 +86,7 @@ public sealed class DoAfterCancellationTests : InteractionTest await AssertTile(Floor); // Second DoAfter cancels the first. - await Server.WaitPost(() => InteractSys.UserInteraction(Player, TargetCoords, Target)); + await Server.WaitPost(() => InteractSys.UserInteraction(SEntMan.GetEntity(Player), SEntMan.GetCoordinates(TargetCoords), SEntMan.GetEntity(Target))); Assert.That(ActiveDoAfters.Count(), Is.EqualTo(0)); await AssertTile(Floor); @@ -112,7 +114,7 @@ public sealed class DoAfterCancellationTests : InteractionTest // Second DoAfter cancels the first. // Not using helper, because it runs too many ticks & causes the do-after to finish. - await Server.WaitPost(() => InteractSys.UserInteraction(Player, TargetCoords, Target)); + await Server.WaitPost(() => InteractSys.UserInteraction(SEntMan.GetEntity(Player), SEntMan.GetCoordinates(TargetCoords), SEntMan.GetEntity(Target))); Assert.Multiple(() => { Assert.That(ActiveDoAfters.Count(), Is.EqualTo(0)); @@ -135,7 +137,7 @@ public sealed class DoAfterCancellationTests : InteractionTest Assert.That(ActiveDoAfters.Count(), Is.EqualTo(1)); Assert.That(comp.IsWelded, Is.True); }); - await Server.WaitPost(() => InteractSys.UserInteraction(Player, TargetCoords, Target)); + await Server.WaitPost(() => InteractSys.UserInteraction(SEntMan.GetEntity(Player), SEntMan.GetCoordinates(TargetCoords), SEntMan.GetEntity(Target))); Assert.Multiple(() => { Assert.That(ActiveDoAfters.Count(), Is.EqualTo(0)); diff --git a/Content.IntegrationTests/Tests/DoAfter/DoAfterServerTest.cs b/Content.IntegrationTests/Tests/DoAfter/DoAfterServerTest.cs index 252cd5e04b..45c2759aa6 100644 --- a/Content.IntegrationTests/Tests/DoAfter/DoAfterServerTest.cs +++ b/Content.IntegrationTests/Tests/DoAfter/DoAfterServerTest.cs @@ -73,7 +73,7 @@ namespace Content.IntegrationTests.Tests.DoAfter { var tickTime = 1.0f / timing.TickRate; var mob = entityManager.SpawnEntity("DoAfterDummy", MapCoordinates.Nullspace); - var args = new DoAfterArgs(mob, tickTime / 2, ev, null) { Broadcast = true }; + var args = new DoAfterArgs(entityManager, mob, tickTime / 2, ev, null) { Broadcast = true }; #pragma warning disable NUnit2045 // Interdependent assertions. Assert.That(doAfterSystem.TryStartDoAfter(args)); Assert.That(ev.Cancelled, Is.False); @@ -101,7 +101,7 @@ namespace Content.IntegrationTests.Tests.DoAfter var tickTime = 1.0f / timing.TickRate; var mob = entityManager.SpawnEntity("DoAfterDummy", MapCoordinates.Nullspace); - var args = new DoAfterArgs(mob, tickTime * 2, ev, null) { Broadcast = true }; + var args = new DoAfterArgs(entityManager, mob, tickTime * 2, ev, null) { Broadcast = true }; if (!doAfterSystem.TryStartDoAfter(args, out var id)) { diff --git a/Content.IntegrationTests/Tests/EntityTest.cs b/Content.IntegrationTests/Tests/EntityTest.cs index d1430cbe29..453796b916 100644 --- a/Content.IntegrationTests/Tests/EntityTest.cs +++ b/Content.IntegrationTests/Tests/EntityTest.cs @@ -42,6 +42,8 @@ namespace Content.IntegrationTests.Tests { var mapId = mapManager.CreateMap(); var grid = mapManager.CreateGrid(mapId); + // TODO: Fix this better in engine. + grid.SetTile(Vector2i.Zero, new Tile(1)); var coord = new EntityCoordinates(grid.Owner, 0, 0); entityMan.SpawnEntity(protoId, coord); } @@ -57,7 +59,7 @@ namespace Content.IntegrationTests.Tests var query = entityMan.AllEntityQueryEnumerator(); while (query.MoveNext(out var uid, out var meta)) yield return (uid, meta); - }; + } var entityMetas = Query(entityMan).ToList(); foreach (var (uid, meta) in entityMetas) diff --git a/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs b/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs index 55daeed430..1d5dd6d34e 100644 --- a/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs +++ b/Content.IntegrationTests/Tests/GameObjects/Components/ActionBlocking/HandCuffTest.cs @@ -84,8 +84,8 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking Assert.That(cuffed.CuffedHandCount, Is.GreaterThan(0), "Handcuffing a player did not result in their hands being cuffed"); // Test to ensure a player with 4 hands will still only have 2 hands cuffed - AddHand(human, host); - AddHand(human, host); + AddHand(entityManager.GetNetEntity(human), host); + AddHand(entityManager.GetNetEntity(human), host); Assert.Multiple(() => { @@ -101,7 +101,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking await pair.CleanReturnAsync(); } - private static void AddHand(EntityUid to, IServerConsoleHost host) + private static void AddHand(NetEntity to, IServerConsoleHost host) { host.ExecuteCommand(null, $"addhand {to}"); } diff --git a/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs b/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs index 402569981a..b05f273265 100644 --- a/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs +++ b/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs @@ -341,7 +341,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click EntityUid target = default; EntityUid item = default; EntityUid containerEntity = default; - IContainer container = null; + BaseContainer container = null; await server.WaitAssertion(() => { diff --git a/Content.IntegrationTests/Tests/Interaction/InteractionTest.Helpers.cs b/Content.IntegrationTests/Tests/Interaction/InteractionTest.Helpers.cs index abbfa1a2b0..530970407c 100644 --- a/Content.IntegrationTests/Tests/Interaction/InteractionTest.Helpers.cs +++ b/Content.IntegrationTests/Tests/Interaction/InteractionTest.Helpers.cs @@ -13,7 +13,9 @@ using Content.Server.Gravity; using Content.Server.Power.Components; using Content.Server.Tools.Components; using Content.Shared.Atmos; +using Content.Shared.Construction; using Content.Shared.Construction.Prototypes; +using Content.Shared.DoAfter; using Content.Shared.Gravity; using Content.Shared.Item; using Robust.Client.GameObjects; @@ -40,13 +42,15 @@ public abstract partial class InteractionTest await Client.WaitPost(() => { - Assert.That(CConSys.TrySpawnGhost(proto, TargetCoords, Direction.South, out Target), + Assert.That(CConSys.TrySpawnGhost(proto, CEntMan.GetCoordinates(TargetCoords), Direction.South, out var clientTarget), Is.EqualTo(shouldSucceed)); if (!shouldSucceed) return; - var comp = CEntMan.GetComponent(Target!.Value); - ConstructionGhostId = comp.GhostId; + + var comp = CEntMan.GetComponent(clientTarget!.Value); + ClientTarget = clientTarget; + ConstructionGhostId = comp.Owner.Id; }); await RunTicks(1); @@ -61,7 +65,7 @@ public abstract partial class InteractionTest // Please someone purge async construction code Task task = default!; - await Server.WaitPost(() => task = SConstruction.TryStartItemConstruction(prototype, Player)); + await Server.WaitPost(() => task = SConstruction.TryStartItemConstruction(prototype, SEntMan.GetEntity(Player))); Task? tickTask = null; while (!task.IsCompleted) @@ -86,10 +90,10 @@ public abstract partial class InteractionTest [MemberNotNull(nameof(Target))] protected async Task SpawnTarget(string prototype) { - Target = EntityUid.Invalid; + Target = NetEntity.Invalid; await Server.WaitPost(() => { - Target = SEntMan.SpawnEntity(prototype, TargetCoords); + Target = SEntMan.GetNetEntity(SEntMan.SpawnEntity(prototype, SEntMan.GetCoordinates(TargetCoords))); }); await RunTicks(5); @@ -102,8 +106,9 @@ public abstract partial class InteractionTest protected async Task StartDeconstruction(string prototype) { await SpawnTarget(prototype); - Assert.That(SEntMan.TryGetComponent(Target, out ConstructionComponent? comp)); - await Server.WaitPost(() => SConstruction.SetPathfindingTarget(Target!.Value, comp!.DeconstructionNode, comp)); + var serverTarget = SEntMan.GetEntity(Target); + Assert.That(SEntMan.TryGetComponent(serverTarget, out ConstructionComponent? comp)); + await Server.WaitPost(() => SConstruction.SetPathfindingTarget(serverTarget!.Value, comp!.DeconstructionNode, comp)); await RunTicks(5); } @@ -116,7 +121,7 @@ public abstract partial class InteractionTest { await Server.WaitPost(() => { - Assert.That(HandSys.TryDrop(Player, null, false, true, Hands)); + Assert.That(HandSys.TryDrop(SEntMan.GetEntity(Player), null, false, true, Hands)); SEntMan.DeleteEntity(held); SLogger.Debug($"Deleting held entity"); }); @@ -161,16 +166,18 @@ public abstract partial class InteractionTest } // spawn and pick up the new item - var item = await SpawnEntity(entity, PlayerCoords); + var item = await SpawnEntity(entity, SEntMan.GetCoordinates(PlayerCoords)); WelderComponent? welder = null; await Server.WaitPost(() => { - Assert.That(HandSys.TryPickup(Player, item, Hands.ActiveHand, false, false, false, Hands)); + var playerEnt = SEntMan.GetEntity(Player); + + Assert.That(HandSys.TryPickup(playerEnt, item, Hands.ActiveHand, false, false, false, Hands)); // turn on welders if (enableWelder && SEntMan.TryGetComponent(item, out welder) && !welder.Lit) - Assert.That(ToolSys.TryTurnWelderOn(item, Player, welder)); + Assert.That(ToolSys.TryTurnWelderOn(item, playerEnt, welder)); }); await RunTicks(1); @@ -184,9 +191,9 @@ public abstract partial class InteractionTest /// /// Pick up an entity. Defaults to just deleting the previously held entity. /// - protected async Task Pickup(EntityUid? uid = null, bool deleteHeld = true) + protected async Task Pickup(NetEntity? entity = null, bool deleteHeld = true) { - uid ??= Target; + entity ??= Target; if (Hands.ActiveHand == null) { @@ -197,15 +204,17 @@ public abstract partial class InteractionTest if (deleteHeld) await DeleteHeldEntity(); + var uid = SEntMan.GetEntity(entity); + if (!SEntMan.TryGetComponent(uid, out ItemComponent? item)) { - Assert.Fail($"Entity {uid} is not an item"); + Assert.Fail($"Entity {entity} is not an item"); return; } await Server.WaitPost(() => { - Assert.That(HandSys.TryPickup(Player, uid!.Value, Hands.ActiveHand, false, false, false, Hands, item)); + Assert.That(HandSys.TryPickup(SEntMan.GetEntity(Player), uid.Value, Hands.ActiveHand, false, false, false, Hands, item)); }); await RunTicks(1); @@ -225,7 +234,7 @@ public abstract partial class InteractionTest await Server.WaitPost(() => { - Assert.That(HandSys.TryDrop(Player, handsComp: Hands)); + Assert.That(HandSys.TryDrop(SEntMan.GetEntity(Player), handsComp: Hands)); }); await RunTicks(1); @@ -247,7 +256,7 @@ public abstract partial class InteractionTest await Server.WaitPost(() => { - InteractSys.UserInteraction(Player, SEntMan.GetComponent(target).Coordinates, target); + InteractSys.UserInteraction(SEntMan.GetEntity(Player), SEntMan.GetComponent(target).Coordinates, target); }); } @@ -274,7 +283,7 @@ public abstract partial class InteractionTest // (e.g., servers attempt to assemble construction examine hints). if (Target != null) { - await Client.WaitPost(() => ExamineSys.DoExamine(Target.Value)); + await Client.WaitPost(() => ExamineSys.DoExamine(CEntMan.GetEntity(Target.Value))); } await PlaceInHands(entity); @@ -286,16 +295,19 @@ public abstract partial class InteractionTest /// protected async Task Interact(bool shouldSucceed = true, bool awaitDoAfters = true) { - if (Target == null || !Target.Value.IsClientSide()) + var clientTarget = ClientTarget; + + if ((clientTarget?.IsValid() != true || CEntMan.Deleted(clientTarget)) && (Target == null || Target.Value.IsValid())) { - await Server.WaitPost(() => InteractSys.UserInteraction(Player, TargetCoords, Target)); + await Server.WaitPost(() => InteractSys.UserInteraction(SEntMan.GetEntity(Player), SEntMan.GetCoordinates(TargetCoords), SEntMan.GetEntity(Target))); await RunTicks(1); } else { // The entity is client-side, so attempt to start construction - var ghost = CEntMan.GetComponent(Target.Value); - await Client.WaitPost(() => CConSys.TryStartConstruction(ghost.GhostId)); + var clientEnt = ClientTarget ?? CEntMan.GetEntity(Target); + + await Client.WaitPost(() => CConSys.TryStartConstruction(clientEnt!.Value)); await RunTicks(5); } @@ -366,7 +378,7 @@ public abstract partial class InteractionTest { foreach (var doAfter in doAfters) { - DoAfterSys.Cancel(Player, doAfter.Index, DoAfters); + DoAfterSys.Cancel(SEntMan.GetEntity(Player), doAfter.Index, DoAfters); } }); @@ -386,34 +398,33 @@ public abstract partial class InteractionTest /// protected async Task CheckTargetChange(bool shouldSucceed) { - EntityUid newTarget = default; if (Target == null) return; - var target = Target.Value; + var target = Target.Value; await RunTicks(5); - if (target.IsClientSide()) + if (ClientTarget != null && CEntMan.IsClientSide(ClientTarget.Value)) { - Assert.That(CEntMan.Deleted(target), Is.EqualTo(shouldSucceed), + Assert.That(CEntMan.Deleted(ClientTarget.Value), Is.EqualTo(shouldSucceed), $"Construction ghost was {(shouldSucceed ? "not deleted" : "deleted")}."); if (shouldSucceed) { - Assert.That(CTestSystem.Ghosts.TryGetValue(ConstructionGhostId, out newTarget), + Assert.That(CTestSystem.Ghosts.TryGetValue(ConstructionGhostId, out var newWeh), $"Failed to get construction entity from ghost Id"); - await Client.WaitPost(() => CLogger.Debug($"Construction ghost {ConstructionGhostId} became entity {newTarget}")); - Target = newTarget; + await Client.WaitPost(() => CLogger.Debug($"Construction ghost {ConstructionGhostId} became entity {newWeh}")); + Target = newWeh; } } - if (STestSystem.EntChanges.TryGetValue(Target.Value, out newTarget)) + if (STestSystem.EntChanges.TryGetValue(Target.Value, out var newServerWeh)) { await Server.WaitPost( - () => SLogger.Debug($"Construction entity {Target.Value} changed to {newTarget}")); + () => SLogger.Debug($"Construction entity {Target.Value} changed to {newServerWeh}")); - Target = newTarget; + Target = newServerWeh; } if (Target != target) @@ -422,7 +433,7 @@ public abstract partial class InteractionTest #region Asserts - protected void AssertPrototype(string? prototype, EntityUid? target = null) + protected void ClientAssertPrototype(string? prototype, NetEntity? target = null) { target ??= Target; if (target == null) @@ -431,11 +442,17 @@ public abstract partial class InteractionTest return; } - var meta = SEntMan.GetComponent(target.Value); + var meta = SEntMan.GetComponent(SEntMan.GetEntity(target.Value)); Assert.That(meta.EntityPrototype?.ID, Is.EqualTo(prototype)); } - protected void AssertAnchored(bool anchored = true, EntityUid? target = null) + protected void ClientAssertPrototype(string? prototype, EntityUid? target) + { + var netEnt = CTestSystem.Ghosts[target.GetHashCode()]; + AssertPrototype(prototype, netEnt); + } + + protected void AssertPrototype(string? prototype, NetEntity? target = null) { target ??= Target; if (target == null) @@ -444,8 +461,21 @@ public abstract partial class InteractionTest return; } - var sXform = SEntMan.GetComponent(target.Value); - var cXform = CEntMan.GetComponent(target.Value); + var meta = SEntMan.GetComponent(SEntMan.GetEntity(target.Value)); + Assert.That(meta.EntityPrototype?.ID, Is.EqualTo(prototype)); + } + + protected void AssertAnchored(bool anchored = true, NetEntity? target = null) + { + target ??= Target; + if (target == null) + { + Assert.Fail("No target specified"); + return; + } + + var sXform = SEntMan.GetComponent(SEntMan.GetEntity(target.Value)); + var cXform = CEntMan.GetComponent(CEntMan.GetEntity(target.Value)); Assert.Multiple(() => { @@ -454,7 +484,7 @@ public abstract partial class InteractionTest }); } - protected void AssertDeleted(bool deleted = true, EntityUid? target = null) + protected void AssertDeleted(bool deleted = true, NetEntity? target = null) { target ??= Target; if (target == null) @@ -465,15 +495,15 @@ public abstract partial class InteractionTest Assert.Multiple(() => { - Assert.That(SEntMan.Deleted(target), Is.EqualTo(deleted)); - Assert.That(CEntMan.Deleted(target), Is.EqualTo(deleted)); + Assert.That(SEntMan.Deleted(SEntMan.GetEntity(target)), Is.EqualTo(deleted)); + Assert.That(CEntMan.Deleted(CEntMan.GetEntity(target)), Is.EqualTo(deleted)); }); } /// /// Assert whether or not the target has the given component. /// - protected void AssertComp(bool hasComp = true, EntityUid? target = null) + protected void AssertComp(bool hasComp = true, NetEntity? target = null) { target ??= Target; if (target == null) @@ -482,24 +512,25 @@ public abstract partial class InteractionTest return; } - Assert.That(SEntMan.HasComponent(target), Is.EqualTo(hasComp)); + Assert.That(SEntMan.HasComponent(SEntMan.GetEntity(target)), Is.EqualTo(hasComp)); } /// /// Check that the tile at the target position matches some prototype. /// - protected async Task AssertTile(string? proto, EntityCoordinates? coords = null) + protected async Task AssertTile(string? proto, NetCoordinates? coords = null) { var targetTile = proto == null ? Tile.Empty : new Tile(TileMan[proto].TileId); var tile = Tile.Empty; - var pos = (coords ?? TargetCoords).ToMap(SEntMan, Transform); + var serverCoords = SEntMan.GetCoordinates(coords ?? TargetCoords); + var pos = serverCoords.ToMap(SEntMan, Transform); await Server.WaitPost(() => { if (MapMan.TryFindGridAt(pos, out _, out var grid)) - tile = grid.GetTileRef(coords ?? TargetCoords).Tile; + tile = grid.GetTileRef(serverCoords).Tile; }); Assert.That(tile.TypeId, Is.EqualTo(targetTile.TypeId)); @@ -541,11 +572,12 @@ public abstract partial class InteractionTest foreach (var ent in entities) { var transform = xformQuery.GetComponent(ent); + var netEnt = SEntMan.GetNetEntity(ent); if (ent == transform.MapUid || ent == transform.GridUid - || ent == Player - || ent == Target) + || netEnt == Player + || netEnt == Target) { toRemove.Add(ent); } @@ -646,31 +678,31 @@ public abstract partial class InteractionTest /// /// Convenience method to get components on the target. Returns SERVER-SIDE components. /// - protected T Comp(EntityUid? target = null) where T : IComponent + protected T Comp(NetEntity? target = null) where T : IComponent { target ??= Target; if (target == null) Assert.Fail("No target specified"); - return SEntMan.GetComponent(target!.Value); + return SEntMan.GetComponent(SEntMan.GetEntity(target!.Value)); } /// /// Set the tile at the target position to some prototype. /// - protected async Task SetTile(string? proto, EntityCoordinates? coords = null, MapGridComponent? grid = null) + protected async Task SetTile(string? proto, NetCoordinates? coords = null, MapGridComponent? grid = null) { var tile = proto == null ? Tile.Empty : new Tile(TileMan[proto].TileId); - var pos = (coords ?? TargetCoords).ToMap(SEntMan, Transform); + var pos = SEntMan.GetCoordinates(coords ?? TargetCoords).ToMap(SEntMan, Transform); await Server.WaitPost(() => { if (grid != null || MapMan.TryFindGridAt(pos, out var gridUid, out grid)) { - grid.SetTile(coords ?? TargetCoords, tile); + grid.SetTile(SEntMan.GetCoordinates(coords ?? TargetCoords), tile); return; } @@ -681,7 +713,7 @@ public abstract partial class InteractionTest gridUid = grid.Owner; var gridXform = SEntMan.GetComponent(gridUid); Transform.SetWorldPosition(gridXform, pos.Position); - grid.SetTile(coords ?? TargetCoords, tile); + grid.SetTile(SEntMan.GetCoordinates(coords ?? TargetCoords), tile); if (!MapMan.TryFindGridAt(pos, out _, out grid)) Assert.Fail("Failed to create grid?"); @@ -743,7 +775,7 @@ public abstract partial class InteractionTest await RunTicks(15); } - protected bool TryGetBui(Enum key, [NotNullWhen(true)] out BoundUserInterface? bui, EntityUid? target = null, bool shouldSucceed = true) + protected bool TryGetBui(Enum key, [NotNullWhen(true)] out BoundUserInterface? bui, NetEntity? target = null, bool shouldSucceed = true) { bui = null; target ??= Target; @@ -753,17 +785,19 @@ public abstract partial class InteractionTest return false; } - if (!CEntMan.TryGetComponent(target, out var ui)) + var clientTarget = CEntMan.GetEntity(target); + + if (!CEntMan.TryGetComponent(clientTarget, out var ui)) { if (shouldSucceed) - Assert.Fail($"Entity {SEntMan.ToPrettyString(target.Value)} does not have a bui component"); + Assert.Fail($"Entity {SEntMan.ToPrettyString(SEntMan.GetEntity(target.Value))} does not have a bui component"); return false; } if (!ui.OpenInterfaces.TryGetValue(key, out bui)) { if (shouldSucceed) - Assert.Fail($"Entity {SEntMan.ToPrettyString(target.Value)} does not have an open bui with key {key.GetType()}.{key}."); + Assert.Fail($"Entity {SEntMan.ToPrettyString(SEntMan.GetEntity(target.Value))} does not have an open bui with key {key.GetType()}.{key}."); return false; } @@ -909,7 +943,7 @@ public abstract partial class InteractionTest #region Power - protected void ToggleNeedPower(EntityUid? target = null) + protected void ToggleNeedPower(NetEntity? target = null) { var comp = Comp(target); comp.NeedsPower = !comp.NeedsPower; @@ -963,8 +997,8 @@ public abstract partial class InteractionTest protected async Task PressKey( BoundKeyFunction key, int ticks = 1, - EntityCoordinates? coordinates = null, - EntityUid cursorEntity = default) + NetCoordinates? coordinates = null, + NetEntity cursorEntity = default) { await SetKey(key, BoundKeyState.Down, coordinates, cursorEntity); await RunTicks(ticks); @@ -978,15 +1012,20 @@ public abstract partial class InteractionTest protected async Task SetKey( BoundKeyFunction key, BoundKeyState state, - EntityCoordinates? coordinates = null, - EntityUid cursorEntity = default) + NetCoordinates? coordinates = null, + NetEntity cursorEntity = default) { var coords = coordinates ?? TargetCoords; ScreenCoordinates screen = default; var funcId = InputManager.NetworkBindMap.KeyFunctionID(key); - var message = new FullInputCmdMessage(CTiming.CurTick, CTiming.TickFraction, funcId, state, - coords, screen, cursorEntity); + var message = new ClientFullInputCmdMessage(CTiming.CurTick, CTiming.TickFraction, funcId) + { + State = state, + Coordinates = CEntMan.GetCoordinates(coords), + ScreenCoordinates = screen, + Uid = CEntMan.GetEntity(cursorEntity), + }; await Client.WaitPost(() => InputSystem.HandleInputCommand(ClientSession, key, message)); } diff --git a/Content.IntegrationTests/Tests/Interaction/InteractionTest.cs b/Content.IntegrationTests/Tests/Interaction/InteractionTest.cs index ce2c4b6981..a3119a1c30 100644 --- a/Content.IntegrationTests/Tests/Interaction/InteractionTest.cs +++ b/Content.IntegrationTests/Tests/Interaction/InteractionTest.cs @@ -53,22 +53,24 @@ public abstract partial class InteractionTest /// Target coordinates. Note that this does not necessarily correspond to the position of the /// entity. /// - protected EntityCoordinates TargetCoords; + protected NetCoordinates TargetCoords; /// /// Initial player coordinates. Note that this does not necessarily correspond to the position of the /// entity. /// - protected EntityCoordinates PlayerCoords; + protected NetCoordinates PlayerCoords; /// /// The player entity that performs all these interactions. Defaults to an admin-observer with 1 hand. /// - protected EntityUid Player; + protected NetEntity Player; protected ICommonSession ClientSession = default!; protected IPlayerSession ServerSession = default!; + public EntityUid? ClientTarget; + /// /// The current target entity. This is the default entity for various helper functions. /// @@ -77,7 +79,7 @@ public abstract partial class InteractionTest /// interactions often swap out entities, and there are helper methods that attempt to automatically upddate /// the target entity. See /// - protected EntityUid? Target; + protected NetEntity? Target; /// /// When attempting to start construction, this is the client-side ID of the construction ghost. @@ -174,8 +176,8 @@ public abstract partial class InteractionTest // Setup map. await Pair.CreateTestMap(); - PlayerCoords = MapData.GridCoords.Offset(new Vector2(0.5f, 0.5f)).WithEntityId(MapData.MapUid, Transform, SEntMan); - TargetCoords = MapData.GridCoords.Offset(new Vector2(1.5f, 0.5f)).WithEntityId(MapData.MapUid, Transform, SEntMan); + PlayerCoords = SEntMan.GetNetCoordinates(MapData.GridCoords.Offset(new Vector2(0.5f, 0.5f)).WithEntityId(MapData.MapUid, Transform, SEntMan)); + TargetCoords = SEntMan.GetNetCoordinates(MapData.GridCoords.Offset(new Vector2(1.5f, 0.5f)).WithEntityId(MapData.MapUid, Transform, SEntMan)); await SetTile(Plating, grid: MapData.MapGrid); // Get player data @@ -195,15 +197,16 @@ public abstract partial class InteractionTest SEntMan.System().WipeMind(ServerSession.ContentData()?.Mind); old = cPlayerMan.LocalPlayer.ControlledEntity; - Player = SEntMan.SpawnEntity(PlayerPrototype, PlayerCoords); - Actor.Attach(Player, ServerSession); - Hands = SEntMan.GetComponent(Player); - DoAfters = SEntMan.GetComponent(Player); + Player = SEntMan.GetNetEntity(SEntMan.SpawnEntity(PlayerPrototype, SEntMan.GetCoordinates(PlayerCoords))); + var serverPlayerEnt = SEntMan.GetEntity(Player); + Actor.Attach(serverPlayerEnt, ServerSession); + Hands = SEntMan.GetComponent(serverPlayerEnt); + DoAfters = SEntMan.GetComponent(serverPlayerEnt); }); // Check player got attached. await RunTicks(5); - Assert.That(cPlayerMan.LocalPlayer.ControlledEntity, Is.EqualTo(Player)); + Assert.That(CEntMan.GetNetEntity(cPlayerMan.LocalPlayer.ControlledEntity), Is.EqualTo(Player)); // Delete old player entity. await Server.WaitPost(() => @@ -216,7 +219,7 @@ public abstract partial class InteractionTest await Server.WaitPost(() => { var bodySystem = SEntMan.System(); - var hands = bodySystem.GetBodyChildrenOfType(Player, BodyPartType.Hand).ToArray(); + var hands = bodySystem.GetBodyChildrenOfType(SEntMan.GetEntity(Player), BodyPartType.Hand).ToArray(); for (var i = 1; i < hands.Length; i++) { @@ -229,8 +232,8 @@ public abstract partial class InteractionTest await Pair.ReallyBeIdle(5); Assert.Multiple(() => { - Assert.That(cPlayerMan.LocalPlayer.ControlledEntity, Is.EqualTo(Player)); - Assert.That(sPlayerMan.GetSessionByUserId(ClientSession.UserId).AttachedEntity, Is.EqualTo(Player)); + Assert.That(CEntMan.GetNetEntity(cPlayerMan.LocalPlayer.ControlledEntity), Is.EqualTo(Player)); + Assert.That(sPlayerMan.GetSessionByUserId(ClientSession.UserId).AttachedEntity, Is.EqualTo(SEntMan.GetEntity(Player))); }); } diff --git a/Content.IntegrationTests/Tests/Interaction/InteractionTestSystem.cs b/Content.IntegrationTests/Tests/Interaction/InteractionTestSystem.cs index 810a0c24cc..797f77e721 100644 --- a/Content.IntegrationTests/Tests/Interaction/InteractionTestSystem.cs +++ b/Content.IntegrationTests/Tests/Interaction/InteractionTestSystem.cs @@ -12,8 +12,8 @@ namespace Content.IntegrationTests.Tests.Interaction; /// public sealed class InteractionTestSystem : EntitySystem { - public Dictionary Ghosts = new(); - public Dictionary EntChanges = new(); + public Dictionary Ghosts = new(); + public Dictionary EntChanges = new(); public override void Initialize() { @@ -23,7 +23,8 @@ public sealed class InteractionTestSystem : EntitySystem private void OnEntChange(ConstructionChangeEntityEvent ev) { - EntChanges[ev.Old] = ev.New; + Assert.That(!IsClientSide(ev.Old) && !IsClientSide(ev.New)); + EntChanges[GetNetEntity(ev.Old)] = GetNetEntity(ev.New); } private void OnAck(AckStructureConstructionMessage ev) diff --git a/Content.IntegrationTests/Tests/Interaction/MovementTest.cs b/Content.IntegrationTests/Tests/Interaction/MovementTest.cs index 178439d8e2..553b031c2b 100644 --- a/Content.IntegrationTests/Tests/Interaction/MovementTest.cs +++ b/Content.IntegrationTests/Tests/Interaction/MovementTest.cs @@ -27,16 +27,18 @@ public abstract class MovementTest : InteractionTest public override async Task Setup() { await base.Setup(); + var pCoords = SEntMan.GetCoordinates(PlayerCoords); + for (var i = -Tiles; i <= Tiles; i++) { - await SetTile(Plating, PlayerCoords.Offset(new Vector2(i, 0)), MapData.MapGrid); + await SetTile(Plating, SEntMan.GetNetCoordinates(pCoords.Offset(new Vector2(i, 0))), MapData.MapGrid); } AssertGridCount(1); if (AddWalls) { - await SpawnEntity("WallSolid", PlayerCoords.Offset(new Vector2(-Tiles, 0))); - await SpawnEntity("WallSolid", PlayerCoords.Offset(new Vector2(Tiles, 0))); + await SpawnEntity("WallSolid", pCoords.Offset(new Vector2(-Tiles, 0))); + await SpawnEntity("WallSolid", pCoords.Offset(new Vector2(Tiles, 0))); } await AddGravity(); @@ -46,7 +48,7 @@ public abstract class MovementTest : InteractionTest /// /// Get the relative horizontal between two entities. Defaults to using the target & player entity. /// - protected float Delta(EntityUid? target = null, EntityUid? other = null) + protected float Delta(NetEntity? target = null, NetEntity? other = null) { target ??= Target; if (target == null) @@ -55,7 +57,7 @@ public abstract class MovementTest : InteractionTest return 0; } - var delta = Transform.GetWorldPosition(target.Value) - Transform.GetWorldPosition(other ?? Player); + var delta = Transform.GetWorldPosition(SEntMan.GetEntity(target.Value)) - Transform.GetWorldPosition(SEntMan.GetEntity(other ?? Player)); return delta.X; } } diff --git a/Content.IntegrationTests/Tests/Networking/SimplePredictReconcileTest.cs b/Content.IntegrationTests/Tests/Networking/SimplePredictReconcileTest.cs index e6ddd1a90c..ec60af5d42 100644 --- a/Content.IntegrationTests/Tests/Networking/SimplePredictReconcileTest.cs +++ b/Content.IntegrationTests/Tests/Networking/SimplePredictReconcileTest.cs @@ -77,7 +77,7 @@ namespace Content.IntegrationTests.Tests.Networking await client.WaitPost(() => { - clientComponent = cEntityManager.GetComponent(serverEnt); + clientComponent = cEntityManager.GetComponent(cEntityManager.GetEntity(sEntityManager.GetNetEntity(serverEnt))); }); var baseTick = sGameTiming.CurTick.Value; @@ -110,7 +110,7 @@ namespace Content.IntegrationTests.Tests.Networking Assert.That(clientComponent.Foo, Is.False); await client.WaitPost(() => { - cEntityManager.RaisePredictiveEvent(new SetFooMessage(serverEnt, true)); + cEntityManager.RaisePredictiveEvent(new SetFooMessage(sEntityManager.GetNetEntity(serverEnt), true)); }); Assert.That(clientComponent.Foo, Is.True); @@ -190,7 +190,7 @@ namespace Content.IntegrationTests.Tests.Networking // Send event to server to change flag again, this time to disable it.. await client.WaitPost(() => { - cEntityManager.RaisePredictiveEvent(new SetFooMessage(serverEnt, false)); + cEntityManager.RaisePredictiveEvent(new SetFooMessage(sEntityManager.GetNetEntity(serverEnt), false)); Assert.That(clientComponent.Foo, Is.False); }); @@ -270,7 +270,7 @@ namespace Content.IntegrationTests.Tests.Networking // Send first event to disable the flag (reminder: it never got accepted by the server). await client.WaitPost(() => { - cEntityManager.RaisePredictiveEvent(new SetFooMessage(serverEnt, false)); + cEntityManager.RaisePredictiveEvent(new SetFooMessage(sEntityManager.GetNetEntity(serverEnt), false)); Assert.That(clientComponent.Foo, Is.False); }); @@ -298,7 +298,7 @@ namespace Content.IntegrationTests.Tests.Networking // Send another event, to re-enable it. await client.WaitPost(() => { - cEntityManager.RaisePredictiveEvent(new SetFooMessage(serverEnt, true)); + cEntityManager.RaisePredictiveEvent(new SetFooMessage(sEntityManager.GetNetEntity(serverEnt), true)); Assert.That(clientComponent.Foo, Is.True); }); @@ -406,12 +406,14 @@ namespace Content.IntegrationTests.Tests.Networking private void HandleMessage(SetFooMessage message, EntitySessionEventArgs args) { - var component = EntityManager.GetComponent(message.Uid); + var uid = GetEntity(message.Uid); + + var component = EntityManager.GetComponent(uid); var old = component.Foo; if (Allow) { component.Foo = message.NewFoo; - Dirty(message.Uid, component); + Dirty(uid, component); } EventTriggerList.Add((_gameTiming.CurTick, _gameTiming.IsFirstTimePredicted, old, component.Foo, message.NewFoo)); @@ -420,13 +422,13 @@ namespace Content.IntegrationTests.Tests.Networking public sealed class SetFooMessage : EntityEventArgs { - public SetFooMessage(EntityUid uid, bool newFoo) + public SetFooMessage(NetEntity uid, bool newFoo) { Uid = uid; NewFoo = newFoo; } - public EntityUid Uid { get; } + public NetEntity Uid { get; } public bool NewFoo { get; } } } diff --git a/Content.IntegrationTests/Tests/Payload/ModularGrenadeTests.cs b/Content.IntegrationTests/Tests/Payload/ModularGrenadeTests.cs index 7dafdf551c..65f4a9d488 100644 --- a/Content.IntegrationTests/Tests/Payload/ModularGrenadeTests.cs +++ b/Content.IntegrationTests/Tests/Payload/ModularGrenadeTests.cs @@ -18,7 +18,7 @@ public sealed class ModularGrenadeTests : InteractionTest { await PlaceInHands(Steel, 5); await CraftItem("ModularGrenadeRecipe"); - Target = await FindEntity("ModularGrenade"); + Target = SEntMan.GetNetEntity(await FindEntity("ModularGrenade")); await Drop(); await Interact(Cable); diff --git a/Content.IntegrationTests/Tests/Slipping/SlippingTest.cs b/Content.IntegrationTests/Tests/Slipping/SlippingTest.cs index 53ae1e63b4..d64961b0be 100644 --- a/Content.IntegrationTests/Tests/Slipping/SlippingTest.cs +++ b/Content.IntegrationTests/Tests/Slipping/SlippingTest.cs @@ -34,7 +34,7 @@ public sealed class SlippingTest : MovementTest // Player is to the left of the banana peel and has not slipped. #pragma warning disable NUnit2045 Assert.That(Delta(), Is.GreaterThan(0.5f)); - Assert.That(sys.Slipped, Does.Not.Contain(Player)); + Assert.That(sys.Slipped, Does.Not.Contain(SEntMan.GetEntity(Player))); #pragma warning restore NUnit2045 // Walking over the banana slowly does not trigger a slip. @@ -42,14 +42,14 @@ public sealed class SlippingTest : MovementTest await Move(DirectionFlag.East, 1f); #pragma warning disable NUnit2045 Assert.That(Delta(), Is.LessThan(0.5f)); - Assert.That(sys.Slipped, Does.Not.Contain(Player)); + Assert.That(sys.Slipped, Does.Not.Contain(SEntMan.GetEntity(Player))); #pragma warning restore NUnit2045 AssertComp(false, Player); // Moving at normal speeds does trigger a slip. await SetKey(EngineKeyFunctions.Walk, BoundKeyState.Up); await Move(DirectionFlag.West, 1f); - Assert.That(sys.Slipped, Does.Contain(Player)); + Assert.That(sys.Slipped, Does.Contain(SEntMan.GetEntity(Player))); AssertComp(true, Player); } } diff --git a/Content.IntegrationTests/Tests/Tiles/TileConstructionTests.cs b/Content.IntegrationTests/Tests/Tiles/TileConstructionTests.cs index c4b09a8aa4..0a2af88887 100644 --- a/Content.IntegrationTests/Tests/Tiles/TileConstructionTests.cs +++ b/Content.IntegrationTests/Tests/Tiles/TileConstructionTests.cs @@ -42,7 +42,7 @@ public sealed class TileConstructionTests : InteractionTest // Place Lattice var oldPos = TargetCoords; - TargetCoords = new EntityCoordinates(MapData.MapUid, 1, 0); + TargetCoords = SEntMan.GetNetCoordinates(new EntityCoordinates(MapData.MapUid, 1, 0)); await Interact(Rod); TargetCoords = oldPos; await AssertTile(Lattice); @@ -75,7 +75,7 @@ public sealed class TileConstructionTests : InteractionTest // Space -> Lattice var oldPos = TargetCoords; - TargetCoords = new EntityCoordinates(MapData.MapUid, 1, 0); + TargetCoords = SEntMan.GetNetCoordinates(new EntityCoordinates(MapData.MapUid, 1, 0)); await Interact(Rod); TargetCoords = oldPos; await AssertTile(Lattice); diff --git a/Content.Server/Access/Systems/AccessOverriderSystem.cs b/Content.Server/Access/Systems/AccessOverriderSystem.cs index e8fc837a7c..a41c0839da 100644 --- a/Content.Server/Access/Systems/AccessOverriderSystem.cs +++ b/Content.Server/Access/Systems/AccessOverriderSystem.cs @@ -46,7 +46,7 @@ public sealed class AccessOverriderSystem : SharedAccessOverriderSystem if (!_interactionSystem.InRangeUnobstructed(args.User, (EntityUid) args.Target)) return; - var doAfterEventArgs = new DoAfterArgs(args.User, component.DoAfterTime, new AccessOverriderDoAfterEvent(), uid, target: args.Target, used: uid) + var doAfterEventArgs = new DoAfterArgs(EntityManager, args.User, component.DoAfterTime, new AccessOverriderDoAfterEvent(), uid, target: args.Target, used: uid) { BreakOnTargetMove = true, BreakOnUserMove = true, diff --git a/Content.Server/Access/Systems/AgentIDCardSystem.cs b/Content.Server/Access/Systems/AgentIDCardSystem.cs index 1b5037e8d5..b0772fcc32 100644 --- a/Content.Server/Access/Systems/AgentIDCardSystem.cs +++ b/Content.Server/Access/Systems/AgentIDCardSystem.cs @@ -66,7 +66,7 @@ namespace Content.Server.Access.Systems return; var state = new AgentIDCardBoundUserInterfaceState(idCard.FullName ?? "", idCard.JobTitle ?? "", component.Icons); - UserInterfaceSystem.SetUiState(ui, state, args.Session); + _uiSystem.SetUiState(ui, state, args.Session); } private void OnJobChanged(EntityUid uid, AgentIDCardComponent comp, AgentIDCardJobChangedMessage args) diff --git a/Content.Server/Administration/Commands/AddBodyPartCommand.cs b/Content.Server/Administration/Commands/AddBodyPartCommand.cs index 53af89bf9d..235a1ed871 100644 --- a/Content.Server/Administration/Commands/AddBodyPartCommand.cs +++ b/Content.Server/Administration/Commands/AddBodyPartCommand.cs @@ -7,6 +7,8 @@ namespace Content.Server.Administration.Commands [AdminCommand(AdminFlags.Admin)] public sealed class AddBodyPartCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "addbodypart"; public string Description => "Adds a given entity to a containing body."; public string Help => "Usage: addbodypart "; @@ -19,20 +21,21 @@ namespace Content.Server.Administration.Commands return; } - if (!EntityUid.TryParse(args[0], out var childId)) + if (!NetEntity.TryParse(args[0], out var childNetId)) { shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); return; } - if (!EntityUid.TryParse(args[1], out var parentId)) + if (!NetEntity.TryParse(args[1], out var parentNetId)) { shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); return; } - var entityManager = IoCManager.Resolve(); - var bodySystem = entityManager.System(); + var childId = _entManager.GetEntity(childNetId); + var parentId = _entManager.GetEntity(parentNetId); + var bodySystem = _entManager.System(); if (bodySystem.TryCreatePartSlotAndAttach(parentId, args[2], childId)) { diff --git a/Content.Server/Administration/Commands/AddEntityStorageCommand.cs b/Content.Server/Administration/Commands/AddEntityStorageCommand.cs index c91ed6512e..4c562d606d 100644 --- a/Content.Server/Administration/Commands/AddEntityStorageCommand.cs +++ b/Content.Server/Administration/Commands/AddEntityStorageCommand.cs @@ -8,6 +8,8 @@ namespace Content.Server.Administration.Commands [AdminCommand(AdminFlags.Admin)] public sealed class AddEntityStorageCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "addstorage"; public string Description => "Adds a given entity to a containing storage."; public string Help => "Usage: addstorage "; @@ -20,24 +22,22 @@ namespace Content.Server.Administration.Commands return; } - if (!EntityUid.TryParse(args[0], out var entityUid)) + if (!NetEntity.TryParse(args[0], out var entityUidNet) || !_entManager.TryGetEntity(entityUidNet, out var entityUid)) { shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); return; } - if (!EntityUid.TryParse(args[1], out var storageUid)) + if (!NetEntity.TryParse(args[1], out var storageUidNet) || !_entManager.TryGetEntity(storageUidNet, out var storageUid)) { shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); return; } - var entityManager = IoCManager.Resolve(); - - if (entityManager.HasComponent(storageUid) && - entityManager.EntitySysManager.TryGetEntitySystem(out var storageSys)) + if (_entManager.HasComponent(storageUid) && + _entManager.EntitySysManager.TryGetEntitySystem(out var storageSys)) { - storageSys.Insert(entityUid, storageUid); + storageSys.Insert(entityUid.Value, storageUid.Value); } else { diff --git a/Content.Server/Administration/Commands/AddMechanismCommand.cs b/Content.Server/Administration/Commands/AddMechanismCommand.cs index 73ec8ffd81..0f7a442bb1 100644 --- a/Content.Server/Administration/Commands/AddMechanismCommand.cs +++ b/Content.Server/Administration/Commands/AddMechanismCommand.cs @@ -7,6 +7,8 @@ namespace Content.Server.Administration.Commands [AdminCommand(AdminFlags.Admin)] public sealed class AddMechanismCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "addmechanism"; public string Description => "Adds a given entity to a containing body."; public string Help => "Usage: addmechanism "; @@ -19,20 +21,19 @@ namespace Content.Server.Administration.Commands return; } - if (!EntityUid.TryParse(args[0], out var organId)) + if (!NetEntity.TryParse(args[0], out var organIdNet) || !_entManager.TryGetEntity(organIdNet, out var organId)) { shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); return; } - if (!EntityUid.TryParse(args[1], out var partId)) + if (!NetEntity.TryParse(args[1], out var partIdNet) || !_entManager.TryGetEntity(partIdNet, out var partId)) { shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); return; } - var entityManager = IoCManager.Resolve(); - var bodySystem = entityManager.System(); + var bodySystem = _entManager.System(); if (bodySystem.AddOrganToFirstValidSlot(organId, partId)) { diff --git a/Content.Server/Administration/Commands/AddPolymorphActionCommand.cs b/Content.Server/Administration/Commands/AddPolymorphActionCommand.cs index 40544327a9..6223df7a6c 100644 --- a/Content.Server/Administration/Commands/AddPolymorphActionCommand.cs +++ b/Content.Server/Administration/Commands/AddPolymorphActionCommand.cs @@ -8,6 +8,8 @@ namespace Content.Server.Administration.Commands; [AdminCommand(AdminFlags.Fun)] public sealed class AddPolymorphActionCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entityManager = default!; + public string Command => "addpolymorphaction"; public string Description => Loc.GetString("add-polymorph-action-command-description"); @@ -22,16 +24,15 @@ public sealed class AddPolymorphActionCommand : IConsoleCommand return; } - if (!EntityUid.TryParse(args[0], out var entityUid)) + if (!NetEntity.TryParse(args[0], out var entityUidNet) || !_entityManager.TryGetEntity(entityUidNet, out var entityUid)) { shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); return; } - var entityManager = IoCManager.Resolve(); - var polySystem = entityManager.EntitySysManager.GetEntitySystem(); + var polySystem = _entityManager.EntitySysManager.GetEntitySystem(); - entityManager.EnsureComponent(entityUid); - polySystem.CreatePolymorphAction(args[1], entityUid); + _entityManager.EnsureComponent(entityUid.Value); + polySystem.CreatePolymorphAction(args[1], entityUid.Value); } } diff --git a/Content.Server/Administration/Commands/AddReagent.cs b/Content.Server/Administration/Commands/AddReagent.cs index 795de6f91f..f18dd3e99d 100644 --- a/Content.Server/Administration/Commands/AddReagent.cs +++ b/Content.Server/Administration/Commands/AddReagent.cs @@ -14,6 +14,9 @@ namespace Content.Server.Administration.Commands [AdminCommand(AdminFlags.Admin)] public sealed class AddReagent : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly IPrototypeManager _protomanager = default!; + public string Command => "addreagent"; public string Description => "Add (or remove) some amount of reagent from some solution."; public string Help => $"Usage: {Command} "; @@ -26,13 +29,13 @@ namespace Content.Server.Administration.Commands return; } - if (!EntityUid.TryParse(args[0], out var uid)) + if (!NetEntity.TryParse(args[0], out var uidNet) || !_entManager.TryGetEntity(uidNet, out var uid)) { shell.WriteLine($"Invalid entity id."); return; } - if (!IoCManager.Resolve().TryGetComponent(uid, out SolutionContainerManagerComponent? man)) + if (!_entManager.TryGetComponent(uid, out SolutionContainerManagerComponent? man)) { shell.WriteLine($"Entity does not have any solutions."); return; @@ -46,7 +49,7 @@ namespace Content.Server.Administration.Commands } var solution = man.Solutions[args[1]]; - if (!IoCManager.Resolve().HasIndex(args[2])) + if (!_protomanager.HasIndex(args[2])) { shell.WriteLine($"Unknown reagent prototype"); return; @@ -60,9 +63,9 @@ namespace Content.Server.Administration.Commands var quantity = FixedPoint2.New(MathF.Abs(quantityFloat)); if (quantityFloat > 0) - EntitySystem.Get().TryAddReagent(uid, solution, args[2], quantity, out var _); + _entManager.System().TryAddReagent(uid.Value, solution, args[2], quantity, out _); else - EntitySystem.Get().RemoveReagent(uid, solution, args[2], quantity); + _entManager.System().RemoveReagent(uid.Value, solution, args[2], quantity); } } } diff --git a/Content.Server/Administration/Commands/ClearBluespaceLockerLinks.cs b/Content.Server/Administration/Commands/ClearBluespaceLockerLinks.cs index a0c04da38e..7d7e0ab6ce 100644 --- a/Content.Server/Administration/Commands/ClearBluespaceLockerLinks.cs +++ b/Content.Server/Administration/Commands/ClearBluespaceLockerLinks.cs @@ -7,6 +7,8 @@ namespace Content.Server.Administration.Commands; [AdminCommand(AdminFlags.Admin)] public sealed class ClearBluespaceLockerLinks : IConsoleCommand { + [Dependency] private readonly IEntityManager _entityManager = default!; + public string Command => "clearbluespacelockerlinks"; public string Description => "Removes the bluespace links of the given uid. Does not remove links this uid is the target of."; public string Help => "Usage: clearbluespacelockerlinks "; @@ -19,15 +21,12 @@ public sealed class ClearBluespaceLockerLinks : IConsoleCommand return; } - if (!EntityUid.TryParse(args[0], out var entityUid)) + if (!NetEntity.TryParse(args[0], out var entityUidNet) || !_entityManager.TryGetEntity(entityUidNet, out var entityUid)) { shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); return; } - var entityManager = IoCManager.Resolve(); - - if (entityManager.TryGetComponent(entityUid, out var originComponent)) - entityManager.RemoveComponent(entityUid, originComponent); + _entityManager.RemoveComponent(entityUid.Value); } } diff --git a/Content.Server/Administration/Commands/DirtyCommand.cs b/Content.Server/Administration/Commands/DirtyCommand.cs index daf25fc6cc..0ed8689d7f 100644 --- a/Content.Server/Administration/Commands/DirtyCommand.cs +++ b/Content.Server/Administration/Commands/DirtyCommand.cs @@ -6,28 +6,29 @@ namespace Content.Server.Administration.Commands; [AdminCommand(AdminFlags.Debug)] public sealed class DirtyCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "dirty"; public string Description => "Marks all components on an entity as dirty, if not specified, dirties everything"; public string Help => $"Usage: {Command} [entityUid]"; public async void Execute(IConsoleShell shell, string argStr, string[] args) { - var entityManager = IoCManager.Resolve(); switch (args.Length) { case 0: - foreach (var entity in entityManager.GetEntities()) + foreach (var entity in _entManager.GetEntities()) { - DirtyAll(entityManager, entity); + DirtyAll(_entManager, entity); } break; case 1: - if (!EntityUid.TryParse(args[0], out var parsedTarget)) + if (!NetEntity.TryParse(args[0], out var parsedTarget)) { shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); return; } - DirtyAll(entityManager, parsedTarget); + DirtyAll(_entManager, _entManager.GetEntity(parsedTarget)); break; default: shell.WriteLine(Loc.GetString("shell-wrong-arguments-number")); diff --git a/Content.Server/Administration/Commands/LinkBluespaceLocker.cs b/Content.Server/Administration/Commands/LinkBluespaceLocker.cs index 59d16745dd..d2f7e4de15 100644 --- a/Content.Server/Administration/Commands/LinkBluespaceLocker.cs +++ b/Content.Server/Administration/Commands/LinkBluespaceLocker.cs @@ -7,6 +7,8 @@ namespace Content.Server.Administration.Commands; [AdminCommand(AdminFlags.Admin)] public sealed class LinkBluespaceLocker : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "linkbluespacelocker"; public string Description => "Links an entity, the target, to another as a bluespace locker target."; public string Help => "Usage: linkbluespacelocker "; @@ -19,44 +21,42 @@ public sealed class LinkBluespaceLocker : IConsoleCommand return; } - if (!Boolean.TryParse(args[0], out var bidirectional)) + if (!bool.TryParse(args[0], out var bidirectional)) { shell.WriteError(Loc.GetString("shell-invalid-bool")); return; } - if (!EntityUid.TryParse(args[1], out var originUid)) + if (!NetEntity.TryParse(args[1], out var originUidNet) || !_entManager.TryGetEntity(originUidNet, out var originUid)) { shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); return; } - if (!EntityUid.TryParse(args[2], out var targetUid)) + if (!NetEntity.TryParse(args[2], out var targetUidNet) || !_entManager.TryGetEntity(targetUidNet, out var targetUid)) { shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); return; } - var entityManager = IoCManager.Resolve(); - - if (!entityManager.TryGetComponent(originUid, out var originComponent)) + if (!_entManager.HasComponent(originUid)) { shell.WriteError(Loc.GetString("shell-entity-with-uid-lacks-component", ("uid", originUid), ("componentName", nameof(EntityStorageComponent)))); return; } - if (!entityManager.TryGetComponent(targetUid, out var targetComponent)) + if (!_entManager.HasComponent(targetUid)) { shell.WriteError(Loc.GetString("shell-entity-with-uid-lacks-component", ("uid", targetUid), ("componentName", nameof(EntityStorageComponent)))); return; } - entityManager.EnsureComponent(originUid, out var originBluespaceComponent); - originBluespaceComponent.BluespaceLinks.Add(targetUid); - entityManager.EnsureComponent(targetUid, out var targetBluespaceComponent); + _entManager.EnsureComponent(originUid.Value, out var originBluespaceComponent); + originBluespaceComponent.BluespaceLinks.Add(targetUid.Value); + _entManager.EnsureComponent(targetUid.Value, out var targetBluespaceComponent); if (bidirectional) { - targetBluespaceComponent.BluespaceLinks.Add(originUid); + targetBluespaceComponent.BluespaceLinks.Add(originUid.Value); } else if (targetBluespaceComponent.BluespaceLinks.Count == 0) { diff --git a/Content.Server/Administration/Commands/OSay.cs b/Content.Server/Administration/Commands/OSay.cs index e89bd56881..2f17bd9d70 100644 --- a/Content.Server/Administration/Commands/OSay.cs +++ b/Content.Server/Administration/Commands/OSay.cs @@ -46,7 +46,7 @@ public sealed class OSay : LocalizedCommands var chatType = (InGameICChatType) Enum.Parse(typeof(InGameICChatType), args[1]); - if (!EntityUid.TryParse(args[0], out var source) || !_entityManager.EntityExists(source)) + if (!NetEntity.TryParse(args[0], out var sourceNet) || !_entityManager.TryGetEntity(sourceNet, out var source) || !_entityManager.EntityExists(source)) { shell.WriteLine(Loc.GetString("osay-command-error-euid", ("arg", args[0]))); return; @@ -56,7 +56,7 @@ public sealed class OSay : LocalizedCommands if (string.IsNullOrEmpty(message)) return; - _entityManager.System().TrySendInGameICMessage(source, message, chatType, false); - _adminLogger.Add(LogType.Action, LogImpact.Low, $"{(shell.Player != null ? shell.Player.Name : "An administrator")} forced {_entityManager.ToPrettyString(source)} to {args[1]}: {message}"); + _entityManager.System().TrySendInGameICMessage(source.Value, message, chatType, false); + _adminLogger.Add(LogType.Action, LogImpact.Low, $"{(shell.Player != null ? shell.Player.Name : "An administrator")} forced {_entityManager.ToPrettyString(source.Value)} to {args[1]}: {message}"); } } diff --git a/Content.Server/Administration/Commands/RemoveBodyPartCommand.cs b/Content.Server/Administration/Commands/RemoveBodyPartCommand.cs index fbfa62ad6a..179f75d62d 100644 --- a/Content.Server/Administration/Commands/RemoveBodyPartCommand.cs +++ b/Content.Server/Administration/Commands/RemoveBodyPartCommand.cs @@ -7,6 +7,8 @@ namespace Content.Server.Administration.Commands [AdminCommand(AdminFlags.Admin)] public sealed class RemoveBodyPartCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "rmbodypart"; public string Description => "Removes a given entity from it's containing body, if any."; public string Help => "Usage: rmbodypart "; @@ -19,18 +21,17 @@ namespace Content.Server.Administration.Commands return; } - if (!EntityUid.TryParse(args[0], out var entityUid)) + if (!NetEntity.TryParse(args[0], out var entityUidNet) || !_entManager.TryGetEntity(entityUidNet, out var entityUid)) { shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); return; } - var entityManager = IoCManager.Resolve(); - var bodySystem = entityManager.System(); + var bodySystem = _entManager.System(); if (bodySystem.DropPart(entityUid)) { - shell.WriteLine($"Removed body part {entityManager.ToPrettyString(entityUid)}."); + shell.WriteLine($"Removed body part {_entManager.ToPrettyString(entityUid.Value)}."); } else { diff --git a/Content.Server/Administration/Commands/RemoveEntityStorageCommand.cs b/Content.Server/Administration/Commands/RemoveEntityStorageCommand.cs index 990fc1dd0e..48663f579d 100644 --- a/Content.Server/Administration/Commands/RemoveEntityStorageCommand.cs +++ b/Content.Server/Administration/Commands/RemoveEntityStorageCommand.cs @@ -8,6 +8,8 @@ namespace Content.Server.Administration.Commands [AdminCommand(AdminFlags.Admin)] public sealed class RemoveEntityStorageCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "rmstorage"; public string Description => "Removes a given entity from it's containing storage, if any."; public string Help => "Usage: rmstorage "; @@ -20,22 +22,23 @@ namespace Content.Server.Administration.Commands return; } - if (!EntityUid.TryParse(args[0], out var entityUid)) + if (!NetEntity.TryParse(args[0], out var entityNet) || !_entManager.TryGetEntity(entityNet, out var entityUid)) { shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); return; } - var entityManager = IoCManager.Resolve(); + if (!_entManager.EntitySysManager.TryGetEntitySystem(out var entstorage)) + return; - if (!entityManager.EntitySysManager.TryGetEntitySystem(out var entstorage)) return; - if (!entityManager.TryGetComponent(entityUid, out var transform)) return; + if (!_entManager.TryGetComponent(entityUid, out var transform)) + return; var parent = transform.ParentUid; - if (entityManager.TryGetComponent(parent, out var storage)) + if (_entManager.TryGetComponent(parent, out var storage)) { - entstorage.Remove(entityUid, storage.Owner, storage); + entstorage.Remove(entityUid.Value, storage.Owner, storage); } else { diff --git a/Content.Server/Administration/Commands/RemoveMechanismCommand.cs b/Content.Server/Administration/Commands/RemoveMechanismCommand.cs index 37ccc97fdd..cabf6c582b 100644 --- a/Content.Server/Administration/Commands/RemoveMechanismCommand.cs +++ b/Content.Server/Administration/Commands/RemoveMechanismCommand.cs @@ -7,6 +7,8 @@ namespace Content.Server.Administration.Commands [AdminCommand(AdminFlags.Admin)] public sealed class RemoveMechanismCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "rmmechanism"; public string Description => "Removes a given entity from it's containing bodypart, if any."; public string Help => "Usage: rmmechanism "; @@ -19,18 +21,17 @@ namespace Content.Server.Administration.Commands return; } - if (!EntityUid.TryParse(args[0], out var entityUid)) + if (!NetEntity.TryParse(args[0], out var entityNet) || !_entManager.TryGetEntity(entityNet, out var entityUid)) { shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); return; } - var entityManager = IoCManager.Resolve(); - var bodySystem = entityManager.System(); + var bodySystem = _entManager.System(); if (bodySystem.DropOrgan(entityUid)) { - shell.WriteLine($"Removed organ {entityManager.ToPrettyString(entityUid)}"); + shell.WriteLine($"Removed organ {_entManager.ToPrettyString(entityUid.Value)}"); } else { diff --git a/Content.Server/Administration/Commands/SetSolutionCapacity.cs b/Content.Server/Administration/Commands/SetSolutionCapacity.cs index 983d89e3d9..0c439227ff 100644 --- a/Content.Server/Administration/Commands/SetSolutionCapacity.cs +++ b/Content.Server/Administration/Commands/SetSolutionCapacity.cs @@ -9,6 +9,8 @@ namespace Content.Server.Administration.Commands [AdminCommand(AdminFlags.Fun)] public sealed class SetSolutionCapacity : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "setsolutioncapacity"; public string Description => "Set the capacity (maximum volume) of some solution."; public string Help => $"Usage: {Command} "; @@ -21,13 +23,13 @@ namespace Content.Server.Administration.Commands return; } - if (!EntityUid.TryParse(args[0], out var uid)) + if (!NetEntity.TryParse(args[0], out var uidNet)) { shell.WriteLine($"Invalid entity id."); return; } - if (!IoCManager.Resolve().TryGetComponent(uid, out SolutionContainerManagerComponent? man)) + if (!_entManager.TryGetEntity(uidNet, out var uid) || !_entManager.TryGetComponent(uid, out SolutionContainerManagerComponent? man)) { shell.WriteLine($"Entity does not have any solutions."); return; @@ -54,7 +56,7 @@ namespace Content.Server.Administration.Commands } var quantity = FixedPoint2.New(quantityFloat); - EntitySystem.Get().SetCapacity(uid, solution, quantity); + _entManager.System().SetCapacity(uid.Value, solution, quantity); } } } diff --git a/Content.Server/Administration/Commands/SetSolutionTemperature.cs b/Content.Server/Administration/Commands/SetSolutionTemperature.cs index fe6fbcb053..6c6c618d17 100644 --- a/Content.Server/Administration/Commands/SetSolutionTemperature.cs +++ b/Content.Server/Administration/Commands/SetSolutionTemperature.cs @@ -8,6 +8,8 @@ namespace Content.Server.Administration.Commands [AdminCommand(AdminFlags.Fun)] public sealed class SetSolutionTemperature : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "setsolutiontemperature"; public string Description => "Set the temperature of some solution."; public string Help => $"Usage: {Command} "; @@ -20,13 +22,13 @@ namespace Content.Server.Administration.Commands return; } - if (!EntityUid.TryParse(args[0], out var uid)) + if (!NetEntity.TryParse(args[0], out var uidNet) || !_entManager.TryGetEntity(uidNet, out var uid)) { shell.WriteLine($"Invalid entity id."); return; } - if (!IoCManager.Resolve().TryGetComponent(uid, out SolutionContainerManagerComponent? man)) + if (!_entManager.TryGetComponent(uid, out SolutionContainerManagerComponent? man)) { shell.WriteLine($"Entity does not have any solutions."); return; @@ -52,7 +54,7 @@ namespace Content.Server.Administration.Commands return; } - EntitySystem.Get().SetTemperature(uid, solution, quantity); + _entManager.System().SetTemperature(uid.Value, solution, quantity); } } } diff --git a/Content.Server/Administration/Commands/SetSolutionThermalEnergy.cs b/Content.Server/Administration/Commands/SetSolutionThermalEnergy.cs index 6c65a9c2b6..07b51016cc 100644 --- a/Content.Server/Administration/Commands/SetSolutionThermalEnergy.cs +++ b/Content.Server/Administration/Commands/SetSolutionThermalEnergy.cs @@ -8,6 +8,8 @@ namespace Content.Server.Administration.Commands [AdminCommand(AdminFlags.Fun)] public sealed class SetSolutionThermalEnergy : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "setsolutionthermalenergy"; public string Description => "Set the thermal energy of some solution."; public string Help => $"Usage: {Command} "; @@ -20,13 +22,13 @@ namespace Content.Server.Administration.Commands return; } - if (!EntityUid.TryParse(args[0], out var uid)) + if (!NetEntity.TryParse(args[0], out var uidNet) || !_entManager.TryGetEntity(uidNet, out var uid)) { shell.WriteLine($"Invalid entity id."); return; } - if (!IoCManager.Resolve().TryGetComponent(uid, out SolutionContainerManagerComponent? man)) + if (!_entManager.TryGetComponent(uid, out SolutionContainerManagerComponent? man)) { shell.WriteLine($"Entity does not have any solutions."); return; @@ -53,13 +55,14 @@ namespace Content.Server.Administration.Commands shell.WriteLine($"Cannot set the thermal energy of a solution with 0 heat capacity to a non-zero number."); return; } - } else if(quantity <= 0.0f) + } + else if(quantity <= 0.0f) { shell.WriteLine($"Cannot set the thermal energy of a solution with heat capacity to a non-positive number."); return; } - EntitySystem.Get().SetThermalEnergy(uid, solution, quantity); + _entManager.System().SetThermalEnergy(uid.Value, solution, quantity); } } } diff --git a/Content.Server/Administration/Commands/VariantizeCommand.cs b/Content.Server/Administration/Commands/VariantizeCommand.cs index 11141640e9..1b5cbbd4d5 100644 --- a/Content.Server/Administration/Commands/VariantizeCommand.cs +++ b/Content.Server/Administration/Commands/VariantizeCommand.cs @@ -10,6 +10,9 @@ namespace Content.Server.Administration.Commands; [AdminCommand(AdminFlags.Mapping)] public sealed class VariantizeCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly IRobustRandom _random = default!; + public string Command => "variantize"; public string Description => Loc.GetString("variantize-command-description"); @@ -24,16 +27,13 @@ public sealed class VariantizeCommand : IConsoleCommand return; } - var entMan = IoCManager.Resolve(); - var random = IoCManager.Resolve(); - - if (!EntityUid.TryParse(args[0], out var euid)) + if (!NetEntity.TryParse(args[0], out var euidNet) || !_entManager.TryGetEntity(euidNet, out var euid)) { shell.WriteError($"Failed to parse euid '{args[0]}'."); return; } - if (!entMan.TryGetComponent(euid, out MapGridComponent? gridComp)) + if (!_entManager.TryGetComponent(euid, out MapGridComponent? gridComp)) { shell.WriteError($"Euid '{euid}' does not exist or is not a grid."); return; @@ -42,7 +42,7 @@ public sealed class VariantizeCommand : IConsoleCommand foreach (var tile in gridComp.GetAllTiles()) { var def = tile.GetContentTileDefinition(); - var newTile = new Tile(tile.Tile.TypeId, tile.Tile.Flags, def.PickVariant(random)); + var newTile = new Tile(tile.Tile.TypeId, tile.Tile.Flags, def.PickVariant(_random)); gridComp.SetTile(tile.GridIndices, newTile); } } diff --git a/Content.Server/Administration/Systems/AdminSystem.cs b/Content.Server/Administration/Systems/AdminSystem.cs index 03cf10206a..d54a7a2092 100644 --- a/Content.Server/Administration/Systems/AdminSystem.cs +++ b/Content.Server/Administration/Systems/AdminSystem.cs @@ -183,7 +183,7 @@ namespace Content.Server.Administration.Systems var connected = session != null && session.Status is SessionStatus.Connected or SessionStatus.InGame; - return new PlayerInfo(name, entityName, identityName, startingRole, antag, session?.AttachedEntity, data.UserId, + return new PlayerInfo(name, entityName, identityName, startingRole, antag, GetNetEntity(session?.AttachedEntity), data.UserId, connected, _roundActivePlayers.Contains(data.UserId)); } } diff --git a/Content.Server/Administration/UI/EditSolutionsEui.cs b/Content.Server/Administration/UI/EditSolutionsEui.cs index cb5ce8fbfa..5fa386aae7 100644 --- a/Content.Server/Administration/UI/EditSolutionsEui.cs +++ b/Content.Server/Administration/UI/EditSolutionsEui.cs @@ -1,3 +1,4 @@ +using Content.Server.Administration.Systems; using Content.Server.Chemistry.Components.SolutionManager; using Content.Server.EUI; using Content.Shared.Administration; @@ -30,13 +31,13 @@ namespace Content.Server.Administration.UI public override void Closed() { base.Closed(); - EntitySystem.Get().OnEditSolutionsEuiClosed(Player); + _entityManager.System().OnEditSolutionsEuiClosed(Player); } public override EuiStateBase GetNewState() { var solutions = _entityManager.GetComponentOrNull(Target)?.Solutions; - return new EditSolutionsEuiState(Target, solutions); + return new EditSolutionsEuiState(_entityManager.GetNetEntity(Target), solutions); } } } diff --git a/Content.Server/Administration/UI/SetOutfitEui.cs b/Content.Server/Administration/UI/SetOutfitEui.cs index 37b98568d3..6243657c32 100644 --- a/Content.Server/Administration/UI/SetOutfitEui.cs +++ b/Content.Server/Administration/UI/SetOutfitEui.cs @@ -10,6 +10,7 @@ namespace Content.Server.Administration.UI public sealed class SetOutfitEui : BaseEui { [Dependency] private readonly IAdminManager _adminManager = default!; + [Dependency] private readonly IEntityManager _entManager = default!; private readonly EntityUid _target; public SetOutfitEui(EntityUid entity) @@ -30,7 +31,7 @@ namespace Content.Server.Administration.UI { return new SetOutfitEuiState { - TargetEntityId = _target + TargetNetEntity = _entManager.GetNetEntity(_target) }; } diff --git a/Content.Server/Ame/EntitySystems/AmeControllerSystem.cs b/Content.Server/Ame/EntitySystems/AmeControllerSystem.cs index b1ea16be7f..00e6c01064 100644 --- a/Content.Server/Ame/EntitySystems/AmeControllerSystem.cs +++ b/Content.Server/Ame/EntitySystems/AmeControllerSystem.cs @@ -94,7 +94,7 @@ public sealed class AmeControllerSystem : EntitySystem return; var state = GetUiState(uid, controller); - UserInterfaceSystem.SetUiState(bui, state); + _userInterfaceSystem.SetUiState(bui, state); } private AmeControllerBoundUserInterfaceState GetUiState(EntityUid uid, AmeControllerComponent controller) diff --git a/Content.Server/Animals/Systems/UdderSystem.cs b/Content.Server/Animals/Systems/UdderSystem.cs index ecbb4210d7..b57eeaf299 100644 --- a/Content.Server/Animals/Systems/UdderSystem.cs +++ b/Content.Server/Animals/Systems/UdderSystem.cs @@ -66,7 +66,7 @@ namespace Content.Server.Animals.Systems if (!Resolve(uid, ref udder)) return; - var doargs = new DoAfterArgs(userUid, 5, new MilkingDoAfterEvent(), uid, uid, used: containerUid) + var doargs = new DoAfterArgs(EntityManager, userUid, 5, new MilkingDoAfterEvent(), uid, uid, used: containerUid) { BreakOnUserMove = true, BreakOnDamage = true, diff --git a/Content.Server/Anomaly/AnomalySystem.Commands.cs b/Content.Server/Anomaly/AnomalySystem.Commands.cs index 91056976a5..b1a7c44439 100644 --- a/Content.Server/Anomaly/AnomalySystem.Commands.cs +++ b/Content.Server/Anomaly/AnomalySystem.Commands.cs @@ -26,13 +26,13 @@ public sealed partial class AnomalySystem if (args.Length != 1) shell.WriteError("Argument length must be 1"); - if (!EntityUid.TryParse(args[0], out var uid)) + if (!NetEntity.TryParse(args[0], out var uidNet) || !TryGetEntity(uidNet, out var uid)) return; if (!TryComp(uid, out var anomaly)) return; - DoAnomalyPulse(uid, anomaly); + DoAnomalyPulse(uid.Value, anomaly); } [AdminCommand(AdminFlags.Fun)] @@ -41,13 +41,13 @@ public sealed partial class AnomalySystem if (args.Length != 1) shell.WriteError("Argument length must be 1"); - if (!EntityUid.TryParse(args[0], out var uid)) + if (!NetEntity.TryParse(args[0], out var uidNet) || !TryGetEntity(uidNet, out var uid)) return; if (!HasComp(uid)) return; - StartSupercriticalEvent(uid); + StartSupercriticalEvent(uid.Value); } private CompletionResult GetAnomalyCompletion(IConsoleShell shell, string[] args) diff --git a/Content.Server/Anomaly/AnomalySystem.Scanner.cs b/Content.Server/Anomaly/AnomalySystem.Scanner.cs index 37c4384f2f..caff031ace 100644 --- a/Content.Server/Anomaly/AnomalySystem.Scanner.cs +++ b/Content.Server/Anomaly/AnomalySystem.Scanner.cs @@ -79,7 +79,7 @@ public sealed partial class AnomalySystem if (!HasComp(target)) return; - _doAfter.TryStartDoAfter(new DoAfterArgs(args.User, component.ScanDoAfterDuration, new ScannerDoAfterEvent(), uid, target: target, used: uid) + _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.ScanDoAfterDuration, new ScannerDoAfterEvent(), uid, target: target, used: uid) { DistanceThreshold = 2f }); diff --git a/Content.Server/Atmos/Commands/AddAtmosCommand.cs b/Content.Server/Atmos/Commands/AddAtmosCommand.cs index 7a13eef6d2..d943b5bf06 100644 --- a/Content.Server/Atmos/Commands/AddAtmosCommand.cs +++ b/Content.Server/Atmos/Commands/AddAtmosCommand.cs @@ -24,29 +24,27 @@ namespace Content.Server.Atmos.Commands return; } - var entMan = IoCManager.Resolve(); - - if (!EntityUid.TryParse(args[0], out var euid)) + if (!NetEntity.TryParse(args[0], out var eNet) || !_entities.TryGetEntity(eNet, out var euid)) { shell.WriteError($"Failed to parse euid '{args[0]}'."); return; } - if (!entMan.HasComponent(euid)) + if (!_entities.HasComponent(euid)) { shell.WriteError($"Euid '{euid}' does not exist or is not a grid."); return; } - var atmos = entMan.EntitySysManager.GetEntitySystem(); + var atmos = _entities.EntitySysManager.GetEntitySystem(); - if (atmos.HasAtmosphere(euid)) + if (atmos.HasAtmosphere(euid.Value)) { shell.WriteLine("Grid already has an atmosphere."); return; } - _entities.AddComponent(euid); + _entities.AddComponent(euid.Value); shell.WriteLine($"Added atmosphere to grid {euid}."); } diff --git a/Content.Server/Atmos/Commands/AddGasCommand.cs b/Content.Server/Atmos/Commands/AddGasCommand.cs index 2c4eb8785c..3dccf39023 100644 --- a/Content.Server/Atmos/Commands/AddGasCommand.cs +++ b/Content.Server/Atmos/Commands/AddGasCommand.cs @@ -11,28 +11,34 @@ namespace Content.Server.Atmos.Commands [AdminCommand(AdminFlags.Debug)] public sealed class AddGasCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "addgas"; public string Description => "Adds gas at a certain position."; public string Help => "addgas "; public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (args.Length < 5) return; + if (args.Length < 5) + return; - if(!int.TryParse(args[0], out var x) - || !int.TryParse(args[1], out var y) - || !EntityUid.TryParse(args[2], out var euid) - || !(AtmosCommandUtils.TryParseGasID(args[3], out var gasId)) - || !float.TryParse(args[4], out var moles)) return; + if (!int.TryParse(args[0], out var x) + || !int.TryParse(args[1], out var y) + || !NetEntity.TryParse(args[2], out var netEnt) + || !_entManager.TryGetEntity(netEnt, out var euid) + || !(AtmosCommandUtils.TryParseGasID(args[3], out var gasId)) + || !float.TryParse(args[4], out var moles)) + { + return; + } - var entMan = IoCManager.Resolve(); - if (!entMan.HasComponent(euid)) + if (!_entManager.HasComponent(euid)) { shell.WriteError($"Euid '{euid}' does not exist or is not a grid."); return; } - var atmosphereSystem = entMan.EntitySysManager.GetEntitySystem(); + var atmosphereSystem = _entManager.EntitySysManager.GetEntitySystem(); var indices = new Vector2i(x, y); var tile = atmosphereSystem.GetTileMixture(euid, null, indices, true); diff --git a/Content.Server/Atmos/Commands/DeleteGasCommand.cs b/Content.Server/Atmos/Commands/DeleteGasCommand.cs index b38b15cec3..0f0c399b11 100644 --- a/Content.Server/Atmos/Commands/DeleteGasCommand.cs +++ b/Content.Server/Atmos/Commands/DeleteGasCommand.cs @@ -11,6 +11,9 @@ namespace Content.Server.Atmos.Commands [AdminCommand(AdminFlags.Debug)] public sealed class DeleteGasCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly IMapManager _mapManager = default!; + public string Command => "deletegas"; public string Description => "Removes all gases from a grid, or just of one type if specified."; public string Help => $"Usage: {Command} / {Command} / {Command} / {Command}"; @@ -21,8 +24,6 @@ namespace Content.Server.Atmos.Commands EntityUid? gridId; Gas? gas = null; - var entMan = IoCManager.Resolve(); - switch (args.Length) { case 0: @@ -39,7 +40,7 @@ namespace Content.Server.Atmos.Commands return; } - gridId = entMan.GetComponent(playerEntity).GridUid; + gridId = _entManager.GetComponent(playerEntity).GridUid; if (gridId == null) { @@ -51,7 +52,7 @@ namespace Content.Server.Atmos.Commands } case 1: { - if (!EntityUid.TryParse(args[0], out var number)) + if (!NetEntity.TryParse(args[0], out var numberEnt) || !_entManager.TryGetEntity(numberEnt, out var number)) { // Argument is a gas if (player == null) @@ -66,7 +67,7 @@ namespace Content.Server.Atmos.Commands return; } - gridId = entMan.GetComponent(playerEntity).GridUid; + gridId = _entManager.GetComponent(playerEntity).GridUid; if (gridId == null) { @@ -90,7 +91,7 @@ namespace Content.Server.Atmos.Commands } case 2: { - if (!EntityUid.TryParse(args[0], out var first)) + if (!NetEntity.TryParse(args[0], out var firstNet) || !_entManager.TryGetEntity(firstNet, out var first)) { shell.WriteLine($"{args[0]} is not a valid integer for a grid id."); return; @@ -119,15 +120,13 @@ namespace Content.Server.Atmos.Commands return; } - var mapManager = IoCManager.Resolve(); - - if (!mapManager.TryGetGrid(gridId, out _)) + if (!_mapManager.TryGetGrid(gridId, out _)) { shell.WriteLine($"No grid exists with id {gridId}"); return; } - var atmosphereSystem = EntitySystem.Get(); + var atmosphereSystem = _entManager.System(); var tiles = 0; var moles = 0f; @@ -136,7 +135,8 @@ namespace Content.Server.Atmos.Commands { foreach (var tile in atmosphereSystem.GetAllMixtures(gridId.Value, true)) { - if (tile.Immutable) continue; + if (tile.Immutable) + continue; tiles++; moles += tile.TotalMoles; @@ -148,7 +148,8 @@ namespace Content.Server.Atmos.Commands { foreach (var tile in atmosphereSystem.GetAllMixtures(gridId.Value, true)) { - if (tile.Immutable) continue; + if (tile.Immutable) + continue; tiles++; moles += tile.TotalMoles; diff --git a/Content.Server/Atmos/Commands/FillGasCommand.cs b/Content.Server/Atmos/Commands/FillGasCommand.cs index c4befa8510..b6db46abed 100644 --- a/Content.Server/Atmos/Commands/FillGasCommand.cs +++ b/Content.Server/Atmos/Commands/FillGasCommand.cs @@ -10,26 +10,33 @@ namespace Content.Server.Atmos.Commands [AdminCommand(AdminFlags.Debug)] public sealed class FillGas : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly IMapManager _mapManager = default!; + public string Command => "fillgas"; public string Description => "Adds gas to all tiles in a grid."; public string Help => "fillgas "; public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (args.Length < 3) return; - if(!EntityUid.TryParse(args[0], out var gridId) - || !(AtmosCommandUtils.TryParseGasID(args[1], out var gasId)) - || !float.TryParse(args[2], out var moles)) return; + if (args.Length < 3) + return; - var mapMan = IoCManager.Resolve(); + if (!NetEntity.TryParse(args[0], out var gridIdNet) + || !_entManager.TryGetEntity(gridIdNet, out var gridId) + || !(AtmosCommandUtils.TryParseGasID(args[1], out var gasId)) + || !float.TryParse(args[2], out var moles)) + { + return; + } - if (!mapMan.TryGetGrid(gridId, out var grid)) + if (!_mapManager.TryGetGrid(gridId, out var grid)) { shell.WriteLine("Invalid grid ID."); return; } - var atmosphereSystem = EntitySystem.Get(); + var atmosphereSystem = _entManager.System(); foreach (var tile in atmosphereSystem.GetAllMixtures(grid.Owner, true)) { diff --git a/Content.Server/Atmos/Commands/RemoveGasCommand.cs b/Content.Server/Atmos/Commands/RemoveGasCommand.cs index 29b9a1cc76..aeea1119f4 100644 --- a/Content.Server/Atmos/Commands/RemoveGasCommand.cs +++ b/Content.Server/Atmos/Commands/RemoveGasCommand.cs @@ -9,20 +9,28 @@ namespace Content.Server.Atmos.Commands [AdminCommand(AdminFlags.Debug)] public sealed class RemoveGasCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "removegas"; public string Description => "Removes an amount of gases."; public string Help => "removegas \nIf is true, amount will be treated as the ratio of gas to be removed."; public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (args.Length < 5) return; - if(!int.TryParse(args[0], out var x) - || !int.TryParse(args[1], out var y) - || !EntityUid.TryParse(args[2], out var id) - || !float.TryParse(args[3], out var amount) - || !bool.TryParse(args[4], out var ratio)) return; + if (args.Length < 5) + return; - var atmosphereSystem = EntitySystem.Get(); + if (!int.TryParse(args[0], out var x) + || !int.TryParse(args[1], out var y) + || !NetEntity.TryParse(args[2], out var idNet) + || !_entManager.TryGetEntity(idNet, out var id) + || !float.TryParse(args[3], out var amount) + || !bool.TryParse(args[4], out var ratio)) + { + return; + } + + var atmosphereSystem = _entManager.System(); var indices = new Vector2i(x, y); var tile = atmosphereSystem.GetTileMixture(id, null, indices, true); diff --git a/Content.Server/Atmos/Commands/SetAtmosTemperatureCommand.cs b/Content.Server/Atmos/Commands/SetAtmosTemperatureCommand.cs index d146655a52..1d7e306d54 100644 --- a/Content.Server/Atmos/Commands/SetAtmosTemperatureCommand.cs +++ b/Content.Server/Atmos/Commands/SetAtmosTemperatureCommand.cs @@ -10,17 +10,23 @@ namespace Content.Server.Atmos.Commands [AdminCommand(AdminFlags.Debug)] public sealed class SetAtmosTemperatureCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly IMapManager _mapManager = default!; + public string Command => "setatmostemp"; public string Description => "Sets a grid's temperature (in kelvin)."; public string Help => "Usage: setatmostemp "; public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (args.Length < 2) return; - if(!EntityUid.TryParse(args[0], out var gridId) - || !float.TryParse(args[1], out var temperature)) return; + if (args.Length < 2) + return; - var mapMan = IoCManager.Resolve(); + if (!_entManager.TryParseNetEntity(args[0], out var gridId) + || !float.TryParse(args[1], out var temperature)) + { + return; + } if (temperature < Atmospherics.TCMB) { @@ -28,13 +34,13 @@ namespace Content.Server.Atmos.Commands return; } - if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) + if (!gridId.Value.IsValid() || !_mapManager.TryGetGrid(gridId, out var gridComp)) { shell.WriteLine("Invalid grid ID."); return; } - var atmosphereSystem = EntitySystem.Get(); + var atmosphereSystem = _entManager.System(); var tiles = 0; foreach (var tile in atmosphereSystem.GetAllMixtures(gridComp.Owner, true)) diff --git a/Content.Server/Atmos/Commands/SetTemperatureCommand.cs b/Content.Server/Atmos/Commands/SetTemperatureCommand.cs index a668278fe1..e6dcbdb4cf 100644 --- a/Content.Server/Atmos/Commands/SetTemperatureCommand.cs +++ b/Content.Server/Atmos/Commands/SetTemperatureCommand.cs @@ -22,11 +22,17 @@ namespace Content.Server.Atmos.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { - if (args.Length < 4) return; - if(!int.TryParse(args[0], out var x) - || !int.TryParse(args[1], out var y) - || !EntityUid.TryParse(args[2], out var gridId) - || !float.TryParse(args[3], out var temperature)) return; + if (args.Length < 4) + return; + + if (!int.TryParse(args[0], out var x) + || !int.TryParse(args[1], out var y) + || !NetEntity.TryParse(args[2], out var gridIdNet) + || !_entities.TryGetEntity(gridIdNet, out var gridId) + || !float.TryParse(args[3], out var temperature)) + { + return; + } if (temperature < Atmospherics.TCMB) { diff --git a/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs b/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs index 7d00634e4a..8b1c425d89 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs @@ -161,7 +161,7 @@ namespace Content.Server.Atmos.EntitySystems } } - RaiseNetworkEvent(new AtmosDebugOverlayMessage(grid.Owner, baseTile, debugOverlayContent), session.ConnectedClient); + RaiseNetworkEvent(new AtmosDebugOverlayMessage(GetNetEntity(grid.Owner), baseTile, debugOverlayContent), session.ConnectedClient); } } } diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Commands.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Commands.cs index d8c99f0f7a..75caab93f0 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Commands.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Commands.cs @@ -67,7 +67,7 @@ public sealed partial class AtmosphereSystem foreach (var arg in args) { - if(!EntityUid.TryParse(arg, out var euid)) + if (!NetEntity.TryParse(arg, out var netEntity) || !TryGetEntity(netEntity, out var euid)) { shell.WriteError($"Failed to parse euid '{arg}'."); return; @@ -85,7 +85,7 @@ public sealed partial class AtmosphereSystem continue; } - var transform = Transform(euid); + var transform = Transform(euid.Value); foreach (var (indices, tileMain) in gridAtmosphere.Tiles) { diff --git a/Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs b/Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs index 29ff787913..0d7ad48f88 100644 --- a/Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs @@ -229,7 +229,7 @@ namespace Content.Server.Atmos.EntitySystems _userInterface.TrySendUiMessage(uid, GasAnalyzerUiKey.Key, new GasAnalyzerUserMessage(gasMixList.ToArray(), component.Target != null ? Name(component.Target.Value) : string.Empty, - component.Target ?? EntityUid.Invalid, + GetNetEntity(component.Target) ?? NetEntity.Invalid, deviceFlipped)); return true; } diff --git a/Content.Server/Atmos/EntitySystems/GasTankSystem.cs b/Content.Server/Atmos/EntitySystems/GasTankSystem.cs index dcfcdf3331..03286f08ab 100644 --- a/Content.Server/Atmos/EntitySystems/GasTankSystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasTankSystem.cs @@ -77,7 +77,6 @@ namespace Content.Server.Atmos.EntitySystems public void UpdateUserInterface(GasTankComponent component, bool initialUpdate = false) { - var internals = GetInternalsComponent(component); _ui.TrySetUiState(component.Owner, SharedGasTankUiKey.Key, new GasTankBoundUserInterfaceState { diff --git a/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs b/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs index 836d3ba9bf..c229ef50c9 100644 --- a/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs @@ -15,7 +15,6 @@ using Robust.Server.Player; using Robust.Shared; using Robust.Shared.Configuration; using Robust.Shared.Enums; -using Robust.Shared.GameStates; using Robust.Shared.Map; using Robust.Shared.Threading; using Robust.Shared.Timing; @@ -36,15 +35,15 @@ 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 = new DefaultObjectPool>( new DefaultPooledObjectPolicy>(), 64); - private ObjectPool>> _chunkViewerPool = - new DefaultObjectPool>>( - new DefaultPooledObjectPolicy>>(), 64); + private ObjectPool>> _chunkViewerPool = + new DefaultObjectPool>>( + new DefaultPooledObjectPolicy>>(), 64); /// /// Overlay update interval, in seconds. @@ -294,22 +293,21 @@ namespace Content.Server.Atmos.EntitySystems private void UpdatePlayer(IPlayerSession playerSession, GameTick curTick) { - var xformQuery = GetEntityQuery(); - var chunksInRange = _chunkingSys.GetChunksForSession(playerSession, ChunkSize, xformQuery, _chunkIndexPool, _chunkViewerPool); + var chunksInRange = _chunkingSys.GetChunksForSession(playerSession, ChunkSize, _chunkIndexPool, _chunkViewerPool); var previouslySent = _lastSentChunks[playerSession]; var ev = new GasOverlayUpdateEvent(); - foreach (var (grid, oldIndices) in previouslySent) + foreach (var (netGrid, oldIndices) in previouslySent) { // Mark the whole grid as stale and flag for removal. - if (!chunksInRange.TryGetValue(grid, out var chunks)) + if (!chunksInRange.TryGetValue(netGrid, out var chunks)) { - previouslySent.Remove(grid); + previouslySent.Remove(netGrid); // If grid was deleted then don't worry about sending it to the client. - if (_mapManager.IsGrid(grid)) - ev.RemovedChunks[grid] = oldIndices; + if (!TryGetEntity(netGrid, out var gridId) || !_mapManager.IsGrid(gridId.Value)) + ev.RemovedChunks[netGrid] = oldIndices; else { oldIndices.Clear(); @@ -330,19 +328,19 @@ namespace Content.Server.Atmos.EntitySystems if (old.Count == 0) _chunkIndexPool.Return(old); else - ev.RemovedChunks.Add(grid, old); + ev.RemovedChunks.Add(netGrid, old); } - foreach (var (grid, gridChunks) in chunksInRange) + foreach (var (netGrid, gridChunks) in chunksInRange) { // Not all grids have atmospheres. - if (!TryComp(grid, out GasTileOverlayComponent? overlay)) + if (!TryGetEntity(netGrid, out var grid) || !TryComp(grid, out GasTileOverlayComponent? overlay)) continue; List dataToSend = new(); - ev.UpdatedChunks[grid] = dataToSend; + ev.UpdatedChunks[netGrid] = dataToSend; - previouslySent.TryGetValue(grid, out var previousChunks); + previouslySent.TryGetValue(netGrid, out var previousChunks); foreach (var index in gridChunks) { @@ -359,7 +357,7 @@ namespace Content.Server.Atmos.EntitySystems dataToSend.Add(value); } - previouslySent[grid] = gridChunks; + previouslySent[netGrid] = gridChunks; if (previousChunks != null) { previousChunks.Clear(); diff --git a/Content.Server/Beam/BeamSystem.cs b/Content.Server/Beam/BeamSystem.cs index f53f3361b4..a9f994ed56 100644 --- a/Content.Server/Beam/BeamSystem.cs +++ b/Content.Server/Beam/BeamSystem.cs @@ -96,7 +96,7 @@ public sealed class BeamSystem : SharedBeamSystem var distanceLength = distanceCorrection.Length(); - var beamVisualizerEvent = new BeamVisualizerEvent(ent, distanceLength, userAngle, bodyState, shader); + var beamVisualizerEvent = new BeamVisualizerEvent(GetNetEntity(ent), distanceLength, userAngle, bodyState, shader); RaiseNetworkEvent(beamVisualizerEvent); if (controller != null) @@ -119,7 +119,7 @@ public sealed class BeamSystem : SharedBeamSystem beamSpawnPos = beamSpawnPos.Offset(calculatedDistance.Normalized()); var newEnt = Spawn(prototype, beamSpawnPos); - var ev = new BeamVisualizerEvent(newEnt, distanceLength, userAngle, bodyState, shader); + var ev = new BeamVisualizerEvent(GetNetEntity(newEnt), distanceLength, userAngle, bodyState, shader); RaiseNetworkEvent(ev); } diff --git a/Content.Server/Body/Commands/AddHandCommand.cs b/Content.Server/Body/Commands/AddHandCommand.cs index 7b78304756..bdb07ca7e1 100644 --- a/Content.Server/Body/Commands/AddHandCommand.cs +++ b/Content.Server/Body/Commands/AddHandCommand.cs @@ -14,6 +14,10 @@ namespace Content.Server.Body.Commands [AdminCommand(AdminFlags.Fun)] sealed class AddHandCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly IPrototypeManager _protoManager = default!; + [Dependency] private readonly IRobustRandom _random = default!; + [ValidatePrototypeId] public const string DefaultHandPrototype = "LeftHandHuman"; @@ -25,9 +29,6 @@ namespace Content.Server.Body.Commands { var player = shell.Player as IPlayerSession; - var entityManager = IoCManager.Resolve(); - var prototypeManager = IoCManager.Resolve(); - EntityUid entity; EntityUid hand; @@ -48,21 +49,21 @@ namespace Content.Server.Body.Commands } entity = player.AttachedEntity.Value; - hand = entityManager.SpawnEntity(DefaultHandPrototype, entityManager.GetComponent(entity).Coordinates); + hand = _entManager.SpawnEntity(DefaultHandPrototype, _entManager.GetComponent(entity).Coordinates); break; } case 1: { - if (EntityUid.TryParse(args[0], out var uid)) + if (NetEntity.TryParse(args[0], out var uidNet) && _entManager.TryGetEntity(uidNet, out var uid)) { - if (!entityManager.EntityExists(uid)) + if (!_entManager.EntityExists(uid)) { shell.WriteLine($"No entity found with uid {uid}"); return; } - entity = uid; - hand = entityManager.SpawnEntity(DefaultHandPrototype, entityManager.GetComponent(entity).Coordinates); + entity = uid.Value; + hand = _entManager.SpawnEntity(DefaultHandPrototype, _entManager.GetComponent(entity).Coordinates); } else { @@ -79,34 +80,34 @@ namespace Content.Server.Body.Commands } entity = player.AttachedEntity.Value; - hand = entityManager.SpawnEntity(args[0], entityManager.GetComponent(entity).Coordinates); + hand = _entManager.SpawnEntity(args[0], _entManager.GetComponent(entity).Coordinates); } break; } case 2: { - if (!EntityUid.TryParse(args[0], out var uid)) + if (!NetEntity.TryParse(args[0], out var netEnt) || !_entManager.TryGetEntity(netEnt, out var uid)) { shell.WriteLine($"{args[0]} is not a valid entity uid."); return; } - if (!entityManager.EntityExists(uid)) + if (!_entManager.EntityExists(uid)) { shell.WriteLine($"No entity exists with uid {uid}."); return; } - entity = uid; + entity = uid.Value; - if (!prototypeManager.HasIndex(args[1])) + if (!_protoManager.HasIndex(args[1])) { shell.WriteLine($"No hand entity exists with id {args[1]}."); return; } - hand = entityManager.SpawnEntity(args[1], entityManager.GetComponent(entity).Coordinates); + hand = _entManager.SpawnEntity(args[1], _entManager.GetComponent(entity).Coordinates); break; } @@ -117,22 +118,21 @@ namespace Content.Server.Body.Commands } } - if (!entityManager.TryGetComponent(entity, out BodyComponent? body) || body.Root == null) + if (!_entManager.TryGetComponent(entity, out BodyComponent? body) || body.Root == null) { - var random = IoCManager.Resolve(); - var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}"; + var text = $"You have no body{(_random.Prob(0.2f) ? " and you must scream." : ".")}"; shell.WriteLine(text); return; } - if (!entityManager.TryGetComponent(hand, out BodyPartComponent? part)) + if (!_entManager.TryGetComponent(hand, out BodyPartComponent? part)) { shell.WriteLine($"Hand entity {hand} does not have a {nameof(BodyPartComponent)} component."); return; } - var bodySystem = entityManager.System(); + var bodySystem = _entManager.System(); var attachAt = bodySystem.GetBodyChildrenOfType(entity, BodyPartType.Arm, body).FirstOrDefault(); if (attachAt == default) @@ -142,11 +142,11 @@ namespace Content.Server.Body.Commands if (!bodySystem.TryCreatePartSlotAndAttach(attachAt.Id, slotId, hand, attachAt.Component, part)) { - shell.WriteError($"Couldn't create a slot with id {slotId} on entity {entityManager.ToPrettyString(entity)}"); + shell.WriteError($"Couldn't create a slot with id {slotId} on entity {_entManager.ToPrettyString(entity)}"); return; } - shell.WriteLine($"Added hand to entity {entityManager.GetComponent(entity).EntityName}"); + shell.WriteLine($"Added hand to entity {_entManager.GetComponent(entity).EntityName}"); } } } diff --git a/Content.Server/Body/Commands/AttachBodyPartCommand.cs b/Content.Server/Body/Commands/AttachBodyPartCommand.cs index de52cf633a..9a80a200e0 100644 --- a/Content.Server/Body/Commands/AttachBodyPartCommand.cs +++ b/Content.Server/Body/Commands/AttachBodyPartCommand.cs @@ -12,6 +12,8 @@ namespace Content.Server.Body.Commands [AdminCommand(AdminFlags.Fun)] public sealed class AttachBodyPartCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "attachbodypart"; public string Description => "Attaches a body part to you or someone else."; public string Help => $"{Command} / {Command} "; @@ -19,10 +21,9 @@ namespace Content.Server.Body.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { var player = shell.Player as IPlayerSession; - var entityManager = IoCManager.Resolve(); EntityUid bodyId; - EntityUid partUid; + EntityUid? partUid; switch (args.Length) { @@ -39,7 +40,7 @@ namespace Content.Server.Body.Commands return; } - if (!EntityUid.TryParse(args[0], out partUid)) + if (!NetEntity.TryParse(args[0], out var partNet) || !_entManager.TryGetEntity(partNet, out partUid)) { shell.WriteLine($"{args[0]} is not a valid entity uid."); return; @@ -49,53 +50,53 @@ namespace Content.Server.Body.Commands break; case 2: - if (!EntityUid.TryParse(args[0], out var entityUid)) + if (!NetEntity.TryParse(args[0], out var entityNet) || !_entManager.TryGetEntity(entityNet, out var entityUid)) { shell.WriteLine($"{args[0]} is not a valid entity uid."); return; } - if (!EntityUid.TryParse(args[1], out partUid)) + if (!NetEntity.TryParse(args[1], out partNet) || !_entManager.TryGetEntity(partNet, out partUid)) { shell.WriteLine($"{args[1]} is not a valid entity uid."); return; } - if (!entityManager.EntityExists(entityUid)) + if (!_entManager.EntityExists(entityUid)) { shell.WriteLine($"{entityUid} is not a valid entity."); return; } - bodyId = entityUid; + bodyId = entityUid.Value; break; default: shell.WriteLine(Help); return; } - if (!entityManager.TryGetComponent(bodyId, out BodyComponent? body)) + if (!_entManager.TryGetComponent(bodyId, out BodyComponent? body)) { - shell.WriteLine($"Entity {entityManager.GetComponent(bodyId).EntityName} with uid {bodyId} does not have a {nameof(BodyComponent)}."); + shell.WriteLine($"Entity {_entManager.GetComponent(bodyId).EntityName} with uid {bodyId} does not have a {nameof(BodyComponent)}."); return; } - if (!entityManager.EntityExists(partUid)) + if (!_entManager.EntityExists(partUid)) { shell.WriteLine($"{partUid} is not a valid entity."); return; } - if (!entityManager.TryGetComponent(partUid, out BodyPartComponent? part)) + if (!_entManager.TryGetComponent(partUid, out BodyPartComponent? part)) { - shell.WriteLine($"Entity {entityManager.GetComponent(partUid).EntityName} with uid {args[0]} does not have a {nameof(BodyPartComponent)}."); + shell.WriteLine($"Entity {_entManager.GetComponent(partUid.Value).EntityName} with uid {args[0]} does not have a {nameof(BodyPartComponent)}."); return; } - var bodySystem = entityManager.System(); + var bodySystem = _entManager.System(); if (bodySystem.BodyHasChild(bodyId, partUid, body, part)) { - shell.WriteLine($"Body part {entityManager.GetComponent(partUid).EntityName} with uid {partUid} is already attached to entity {entityManager.GetComponent(bodyId).EntityName} with uid {bodyId}"); + shell.WriteLine($"Body part {_entManager.GetComponent(partUid.Value).EntityName} with uid {partUid} is already attached to entity {_entManager.GetComponent(bodyId).EntityName} with uid {bodyId}"); return; } @@ -113,12 +114,12 @@ namespace Content.Server.Body.Commands if (!bodySystem.TryCreatePartSlotAndAttach(attachAt.Id, slotId, partUid, attachAt.Component, part)) { - shell.WriteError($"Could not create slot {slotId} on entity {entityManager.ToPrettyString(bodyId)}"); + shell.WriteError($"Could not create slot {slotId} on entity {_entManager.ToPrettyString(bodyId)}"); return; } } - shell.WriteLine($"Attached part {entityManager.ToPrettyString(partUid)} to {entityManager.ToPrettyString(bodyId)}"); + shell.WriteLine($"Attached part {_entManager.ToPrettyString(partUid.Value)} to {_entManager.ToPrettyString(bodyId)}"); } } } diff --git a/Content.Server/Body/Systems/InternalsSystem.cs b/Content.Server/Body/Systems/InternalsSystem.cs index 08dbfacbc2..3e8e2307e3 100644 --- a/Content.Server/Body/Systems/InternalsSystem.cs +++ b/Content.Server/Body/Systems/InternalsSystem.cs @@ -105,7 +105,7 @@ public sealed class InternalsSystem : EntitySystem var isUser = user == target; var delay = !isUser ? internals.Delay : 1.0f; - _doAfter.TryStartDoAfter(new DoAfterArgs(user, delay, new InternalsDoAfterEvent(), target, target: target) + _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, delay, new InternalsDoAfterEvent(), target, target: target) { BreakOnUserMove = true, BreakOnDamage = true, diff --git a/Content.Server/Botany/Systems/BotanySwabSystem.cs b/Content.Server/Botany/Systems/BotanySwabSystem.cs index 5e5bff0f5c..8f300c9448 100644 --- a/Content.Server/Botany/Systems/BotanySwabSystem.cs +++ b/Content.Server/Botany/Systems/BotanySwabSystem.cs @@ -44,7 +44,7 @@ public sealed class BotanySwabSystem : EntitySystem if (args.Target == null || !args.CanReach || !HasComp(args.Target)) return; - _doAfterSystem.TryStartDoAfter(new DoAfterArgs(args.User, swab.SwabDelay, new BotanySwabDoAfterEvent(), uid, target: args.Target, used: uid) + _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, swab.SwabDelay, new BotanySwabDoAfterEvent(), uid, target: args.Target, used: uid) { Broadcast = true, BreakOnTargetMove = true, diff --git a/Content.Server/Camera/CameraRecoilSystem.cs b/Content.Server/Camera/CameraRecoilSystem.cs index 0022ce3214..ddf47fca79 100644 --- a/Content.Server/Camera/CameraRecoilSystem.cs +++ b/Content.Server/Camera/CameraRecoilSystem.cs @@ -8,8 +8,9 @@ public sealed class CameraRecoilSystem : SharedCameraRecoilSystem { public override void KickCamera(EntityUid euid, Vector2 kickback, CameraRecoilComponent? component = null) { - if (!Resolve(euid, ref component, false)) return; + if (!Resolve(euid, ref component, false)) + return; - RaiseNetworkEvent(new CameraKickEvent(euid, kickback), euid); + RaiseNetworkEvent(new CameraKickEvent(GetNetEntity(euid), kickback), euid); } } diff --git a/Content.Server/CardboardBox/CardboardBoxSystem.cs b/Content.Server/CardboardBox/CardboardBoxSystem.cs index b3f2aa561c..df9743a21a 100644 --- a/Content.Server/CardboardBox/CardboardBoxSystem.cs +++ b/Content.Server/CardboardBox/CardboardBoxSystem.cs @@ -73,7 +73,7 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem { if (_timing.CurTime > component.EffectCooldown) { - RaiseNetworkEvent(new PlayBoxEffectMessage(uid, component.Mover.Value)); + RaiseNetworkEvent(new PlayBoxEffectMessage(GetNetEntity(uid), GetNetEntity(component.Mover.Value))); _audio.PlayPvs(component.EffectSound, uid); component.EffectCooldown = _timing.CurTime + component.CooldownDuration; } diff --git a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs index 6f98b67224..9ea054b628 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs @@ -215,13 +215,15 @@ namespace Content.Server.Cargo.Systems !TryComp(station, out var bankAccount)) return; if (_uiSystem.TryGetUi(consoleUid, CargoConsoleUiKey.Orders, out var bui)) - UserInterfaceSystem.SetUiState(bui, new CargoConsoleInterfaceState( + { + _uiSystem.SetUiState(bui, new CargoConsoleInterfaceState( MetaData(station.Value).EntityName, GetOutstandingOrderCount(orderDatabase), orderDatabase.Capacity, bankAccount.Balance, orderDatabase.Orders )); + } } private void ConsolePopup(ICommonSession session, string text) diff --git a/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs b/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs index ac208df187..80e7cf71e0 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs @@ -95,12 +95,12 @@ public sealed partial class CargoSystem var bui = _uiSystem.GetUi(uid, CargoPalletConsoleUiKey.Sale); if (Transform(uid).GridUid is not EntityUid gridUid) { - UserInterfaceSystem.SetUiState(bui, + _uiSystem.SetUiState(bui, new CargoPalletConsoleInterfaceState(0, 0, false)); return; } GetPalletGoods(gridUid, out var toSell, out var amount); - UserInterfaceSystem.SetUiState(bui, + _uiSystem.SetUiState(bui, new CargoPalletConsoleInterfaceState((int) amount, toSell.Count, true)); } @@ -147,7 +147,7 @@ public sealed partial class CargoSystem var shuttleName = orderDatabase?.Shuttle != null ? MetaData(orderDatabase.Shuttle.Value).EntityName : string.Empty; if (_uiSystem.TryGetUi(uid, CargoConsoleUiKey.Shuttle, out var bui)) - UserInterfaceSystem.SetUiState(bui, new CargoShuttleConsoleBoundUserInterfaceState( + _uiSystem.SetUiState(bui, new CargoShuttleConsoleBoundUserInterfaceState( station != null ? MetaData(station.Value).EntityName : Loc.GetString("cargo-shuttle-console-station-unknown"), string.IsNullOrEmpty(shuttleName) ? Loc.GetString("cargo-shuttle-console-shuttle-not-found") : shuttleName, orders @@ -324,7 +324,7 @@ public sealed partial class CargoSystem var bui = _uiSystem.GetUi(uid, CargoPalletConsoleUiKey.Sale); if (Transform(uid).GridUid is not EntityUid gridUid) { - UserInterfaceSystem.SetUiState(bui, + _uiSystem.SetUiState(bui, new CargoPalletConsoleInterfaceState(0, 0, false)); return; } diff --git a/Content.Server/Cargo/Systems/PricingSystem.cs b/Content.Server/Cargo/Systems/PricingSystem.cs index 1f6d941b6b..d1f6684bc3 100644 --- a/Content.Server/Cargo/Systems/PricingSystem.cs +++ b/Content.Server/Cargo/Systems/PricingSystem.cs @@ -51,7 +51,7 @@ public sealed class PricingSystem : EntitySystem foreach (var gid in args) { - if (!EntityUid.TryParse(gid, out var gridId) || !gridId.IsValid()) + if (!EntityManager.TryParseNetEntity(gid, out var gridId) || !gridId.Value.IsValid()) { shell.WriteError($"Invalid grid ID \"{gid}\"."); continue; @@ -90,7 +90,7 @@ public sealed class PricingSystem : EntitySystem if (!TryComp(uid, out var body) || !TryComp(uid, out var state)) { - Logger.ErrorS("pricing", $"Tried to get the mob price of {ToPrettyString(uid)}, which has no {nameof(BodyComponent)} and no {nameof(MobStateComponent)}."); + Log.Error($"Tried to get the mob price of {ToPrettyString(uid)}, which has no {nameof(BodyComponent)} and no {nameof(MobStateComponent)}."); return; } diff --git a/Content.Server/CartridgeLoader/CartridgeLoaderSystem.cs b/Content.Server/CartridgeLoader/CartridgeLoaderSystem.cs index 42f065a4c2..c9ae2f6c80 100644 --- a/Content.Server/CartridgeLoader/CartridgeLoaderSystem.cs +++ b/Content.Server/CartridgeLoader/CartridgeLoaderSystem.cs @@ -1,4 +1,7 @@ -using Content.Server.DeviceNetwork.Systems; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using Content.Server.DeviceNetwork.Systems; +using Content.Server.PDA; using Content.Shared.CartridgeLoader; using Content.Shared.Interaction; using Robust.Server.Containers; @@ -6,7 +9,6 @@ using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Containers; using Robust.Shared.Map; -using System.Diagnostics.CodeAnalysis; namespace Content.Server.CartridgeLoader; @@ -14,8 +16,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem { [Dependency] private readonly ContainerSystem _containerSystem = default!; [Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!; - - private const string ContainerName = "program-container"; + [Dependency] private readonly PdaSystem _pda = default!; public override void Initialize() { @@ -29,6 +30,66 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem SubscribeLocalEvent(OnUiMessage); } + public IReadOnlyList GetInstalled(EntityUid uid, ContainerManagerComponent? comp = null) + { + if (_containerSystem.TryGetContainer(uid, InstalledContainerId, out var container, comp)) + return container.ContainedEntities; + + return Array.Empty(); + } + + public bool TryGetProgram( + EntityUid uid, + [NotNullWhen(true)] out EntityUid? programUid, + [NotNullWhen(true)] out T? program, + bool installedOnly = false, + CartridgeLoaderComponent? loader = null, + ContainerManagerComponent? containerManager = null) + { + program = default; + programUid = null; + + if (!_containerSystem.TryGetContainer(uid, InstalledContainerId, out var container, containerManager)) + return false; + + foreach (var prog in container.ContainedEntities) + { + if (!TryComp(prog, out program)) + continue; + + programUid = prog; + return true; + } + + if (installedOnly) + return false; + + if (!Resolve(uid, ref loader) || !TryComp(loader.CartridgeSlot.Item, out program)) + return false; + + programUid = loader.CartridgeSlot.Item; + return true; + } + + public bool TryGetProgram( + EntityUid uid, + [NotNullWhen(true)] out EntityUid? programUid, + bool installedOnly = false, + CartridgeLoaderComponent? loader = null, + ContainerManagerComponent? containerManager = null) + { + return TryGetProgram(uid, out programUid, out _, installedOnly, loader, containerManager); + } + + public bool HasProgram( + EntityUid uid, + bool installedOnly = false, + CartridgeLoaderComponent? loader = null, + ContainerManagerComponent? containerManager = null) + { + return TryGetProgram(uid, out _, out _, installedOnly, loader, containerManager); + } + /// /// Updates the cartridge loaders ui state. /// @@ -37,16 +98,17 @@ 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, CartridgeLoaderUiState state, IPlayerSession? session = default!, CartridgeLoaderComponent? loader = default!) + public void UpdateUiState(EntityUid loaderUid, IPlayerSession? session, CartridgeLoaderComponent? loader) { if (!Resolve(loaderUid, ref loader)) return; - state.ActiveUI = loader.ActiveProgram; - state.Programs = GetAvailablePrograms(loaderUid, loader); + if (!_userInterfaceSystem.TryGetUi(loaderUid, loader.UiKey, out var ui)) + return; - if (_userInterfaceSystem.TryGetUi(loaderUid, loader.UiKey, out var ui)) - UserInterfaceSystem.SetUiState(ui, state, session); + var programs = GetAvailablePrograms(loaderUid, loader); + var state = new CartridgeLoaderUiState(programs, GetNetEntity(loader.ActiveProgram)); + _userInterfaceSystem.SetUiState(ui, state, session); } /// @@ -66,7 +128,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem return; if (_userInterfaceSystem.TryGetUi(loaderUid, loader.UiKey, out var ui)) - UserInterfaceSystem.SetUiState(ui, state, session); + _userInterfaceSystem.SetUiState(ui, state, session); } /// @@ -75,21 +137,18 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem /// The cartridge loaders uid /// The cartridge loader component /// A list of all the available program entity ids - public List GetAvailablePrograms(EntityUid uid, CartridgeLoaderComponent? loader = default!) + public List GetAvailablePrograms(EntityUid uid, CartridgeLoaderComponent? loader = default!) { if (!Resolve(uid, ref loader)) - return new List(); + return new List(); - //Don't count a cartridge that has already been installed as available to avoid confusion - if (loader.CartridgeSlot.HasItem && TryFindInstalled(Prototype(loader.CartridgeSlot.Item!.Value)?.ID, loader, out _)) - return loader.InstalledPrograms; + var available = GetNetEntityList(GetInstalled(uid)); - var available = new List(); - available.AddRange(loader.InstalledPrograms); - - if (loader.CartridgeSlot.HasItem) - available.Add(loader.CartridgeSlot.Item!.Value); + if (loader.CartridgeSlot.Item is not { } cartridge) + return available; + // TODO exclude duplicate programs. Or something I dunno I CBF fixing this mess. + available.Add(GetNetEntity(cartridge)); return available; } @@ -102,11 +161,13 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem /// Whether installing the cartridge was successful public bool InstallCartridge(EntityUid loaderUid, EntityUid cartridgeUid, CartridgeLoaderComponent? loader = default!) { - if (!Resolve(loaderUid, ref loader) || loader.InstalledPrograms.Count >= loader.DiskSpace) + if (!Resolve(loaderUid, ref loader)) return false; //This will eventually be replaced by serializing and deserializing the cartridge to copy it when something needs //the data on the cartridge to carry over when installing + + // For anyone stumbling onto this: Do not do this or I will cut you. var prototypeId = Prototype(cartridgeUid)?.ID; return prototypeId != null && InstallProgram(loaderUid, prototypeId, loader: loader); } @@ -121,16 +182,16 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem /// Whether installing the cartridge was successful public bool InstallProgram(EntityUid loaderUid, string prototype, bool deinstallable = true, CartridgeLoaderComponent? loader = default!) { - if (!Resolve(loaderUid, ref loader) || loader.InstalledPrograms.Count >= loader.DiskSpace) + if (!Resolve(loaderUid, ref loader)) return false; - if (!_containerSystem.TryGetContainer(loaderUid, ContainerName, out var container)) + if (!_containerSystem.TryGetContainer(loaderUid, InstalledContainerId, out var container)) return false; - //Prevent installing cartridges that have already been installed - if (TryFindInstalled(prototype, loader, out _)) + if (container.Count >= loader.DiskSpace) return false; + // TODO cancel duplicate program installations var ev = new ProgramInstallationAttempt(loaderUid, prototype); RaiseLocalEvent(ref ev); @@ -138,32 +199,15 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem return false; var installedProgram = Spawn(prototype, new EntityCoordinates(loaderUid, 0, 0)); - container?.Insert(installedProgram); + container.Insert(installedProgram); UpdateCartridgeInstallationStatus(installedProgram, deinstallable ? InstallationStatus.Installed : InstallationStatus.Readonly); - loader.InstalledPrograms.Add(installedProgram); RaiseLocalEvent(installedProgram, new CartridgeAddedEvent(loaderUid)); UpdateUserInterfaceState(loaderUid, loader); return true; } - /// - /// Uninstalls a program using its prototype - /// - /// The cartridge loader uid - /// The prototype name of the program to be uninstalled - /// The cartridge loader component - /// Whether uninstalling the program was successful - public bool UninstallProgram(EntityUid loaderUid, string prototype, CartridgeLoaderComponent? loader = default!) - { - if (!Resolve(loaderUid, ref loader)) - return false; - - return TryFindInstalled(prototype, loader, out var programUid) && - UninstallProgram(loaderUid, programUid.Value, loader); - } - /// /// Uninstalls a program using its uid /// @@ -173,14 +217,16 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem /// Whether uninstalling the program was successful public bool UninstallProgram(EntityUid loaderUid, EntityUid programUid, CartridgeLoaderComponent? loader = default!) { - if (!Resolve(loaderUid, ref loader) || !ContainsCartridge(programUid, loader, true)) + if (!Resolve(loaderUid, ref loader)) + return false; + + if (!GetInstalled(loaderUid).Contains(programUid)) return false; if (loader.ActiveProgram == programUid) loader.ActiveProgram = null; loader.BackgroundPrograms.Remove(programUid); - loader.InstalledPrograms.Remove(programUid); EntityManager.QueueDeleteEntity(programUid); UpdateUserInterfaceState(loaderUid, loader); return true; @@ -194,7 +240,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem if (!Resolve(loaderUid, ref loader)) return; - if (!ContainsCartridge(programUid, loader)) + if (!HasProgram(loaderUid, programUid, loader)) return; if (loader.ActiveProgram.HasValue) @@ -215,7 +261,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem if (!Resolve(loaderUid, ref loader)) return; - if (!ContainsCartridge(programUid, loader) || loader.ActiveProgram != programUid) + if (!HasProgram(loaderUid, programUid, loader) || loader.ActiveProgram != programUid) return; if (!loader.BackgroundPrograms.Contains(programUid)) @@ -236,7 +282,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem if (!Resolve(loaderUid, ref loader)) return; - if (!ContainsCartridge(cartridgeUid, loader)) + if (!HasProgram(loaderUid, cartridgeUid, loader)) return; if (loader.ActiveProgram != cartridgeUid) @@ -253,7 +299,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem if (!Resolve(loaderUid, ref loader)) return; - if (!ContainsCartridge(cartridgeUid, loader)) + if (!HasProgram(loaderUid, cartridgeUid, loader)) return; if (loader.ActiveProgram != cartridgeUid) @@ -264,12 +310,18 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem protected override void OnItemInserted(EntityUid uid, CartridgeLoaderComponent loader, EntInsertedIntoContainerMessage args) { + if (args.Container.ID != InstalledContainerId && args.Container.ID != loader.CartridgeSlot.ID) + return; + RaiseLocalEvent(args.Entity, new CartridgeAddedEvent(uid)); base.OnItemInserted(uid, loader, args); } protected override void OnItemRemoved(EntityUid uid, CartridgeLoaderComponent loader, EntRemovedFromContainerMessage args) { + if (args.Container.ID != InstalledContainerId && args.Container.ID != loader.CartridgeSlot.ID) + return; + var deactivate = loader.BackgroundPrograms.Remove(args.Entity); if (loader.ActiveProgram == args.Entity) @@ -283,6 +335,8 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem RaiseLocalEvent(args.Entity, new CartridgeRemovedEvent(uid)); base.OnItemRemoved(uid, loader, args); + + _pda.UpdatePdaUi(uid); } /// @@ -290,6 +344,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem /// private void OnMapInit(EntityUid uid, CartridgeLoaderComponent component, MapInitEvent args) { + // TODO remove this and use container fill. foreach (var prototype in component.PreinstalledPrograms) { InstallProgram(uid, prototype, deinstallable: false); @@ -308,19 +363,21 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem private void OnLoaderUiMessage(EntityUid loaderUid, CartridgeLoaderComponent component, CartridgeLoaderUiMessage message) { + var cartridge = GetEntity(message.CartridgeUid); + switch (message.Action) { case CartridgeUiMessageAction.Activate: - ActivateProgram(loaderUid, message.CartridgeUid, component); + ActivateProgram(loaderUid, cartridge, component); break; case CartridgeUiMessageAction.Deactivate: - DeactivateProgram(loaderUid, message.CartridgeUid, component); + DeactivateProgram(loaderUid, cartridge, component); break; case CartridgeUiMessageAction.Install: - InstallCartridge(loaderUid, message.CartridgeUid, component); + InstallCartridge(loaderUid, cartridge, component); break; case CartridgeUiMessageAction.Uninstall: - UninstallProgram(loaderUid, message.CartridgeUid, component); + UninstallProgram(loaderUid, cartridge, component); break; case CartridgeUiMessageAction.UIReady: if (component.ActiveProgram.HasValue) @@ -337,7 +394,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem private void OnUiMessage(EntityUid uid, CartridgeLoaderComponent component, CartridgeUiMessage args) { var cartridgeEvent = args.MessageEvent; - cartridgeEvent.LoaderUid = uid; + cartridgeEvent.LoaderUid = GetNetEntity(uid); RelayEvent(component, cartridgeEvent, true); } @@ -367,24 +424,6 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem } } - /// - /// Searches for a program by its prototype name in the list of installed programs - /// - private bool TryFindInstalled(string? prototype, CartridgeLoaderComponent loader, [NotNullWhen(true)] out EntityUid? programUid) - { - foreach (var program in loader.InstalledPrograms) - { - if (Prototype(program)?.ID == prototype) - { - programUid = program; - return true; - } - } - - programUid = default; - return false; - } - /// /// Shortcut for updating the loaders user interface state without passing in a subtype of /// like the does when updating its ui state @@ -392,7 +431,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem /// private void UpdateUserInterfaceState(EntityUid loaderUid, CartridgeLoaderComponent loader) { - UpdateUiState(loaderUid, new CartridgeLoaderUiState(), null, loader); + UpdateUiState(loaderUid, null, loader); } private void UpdateCartridgeInstallationStatus(EntityUid cartridgeUid, InstallationStatus installationStatus, CartridgeComponent? cartridgeComponent = default!) @@ -400,13 +439,13 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem if (Resolve(cartridgeUid, ref cartridgeComponent)) { cartridgeComponent.InstallationStatus = installationStatus; - Dirty(cartridgeComponent); + Dirty(cartridgeUid, cartridgeComponent); } } - private static bool ContainsCartridge(EntityUid cartridgeUid, CartridgeLoaderComponent loader, bool onlyInstalled = false) + private bool HasProgram(EntityUid loader, EntityUid program, CartridgeLoaderComponent component) { - return !onlyInstalled && loader.CartridgeSlot.Item?.Equals(cartridgeUid) == true || loader.InstalledPrograms.Contains(cartridgeUid); + return component.CartridgeSlot.Item == program || GetInstalled(loader).Contains(program); } } diff --git a/Content.Server/CartridgeLoader/Cartridges/CrewManifestCartridgeSystem.cs b/Content.Server/CartridgeLoader/Cartridges/CrewManifestCartridgeSystem.cs index 49fb2e1732..fca29a4013 100644 --- a/Content.Server/CartridgeLoader/Cartridges/CrewManifestCartridgeSystem.cs +++ b/Content.Server/CartridgeLoader/Cartridges/CrewManifestCartridgeSystem.cs @@ -4,6 +4,7 @@ using Content.Shared.CartridgeLoader; using Content.Shared.CartridgeLoader.Cartridges; using Content.Shared.CCVar; using Robust.Shared.Configuration; +using Robust.Shared.Containers; using Robust.Shared.Prototypes; namespace Content.Server.CartridgeLoader.Cartridges; @@ -41,7 +42,7 @@ public sealed class CrewManifestCartridgeSystem : EntitySystem /// private void OnUiMessage(EntityUid uid, CrewManifestCartridgeComponent component, CartridgeMessageEvent args) { - UpdateUiState(uid, args.LoaderUid, component); + UpdateUiState(uid, GetEntity(args.LoaderUid), component); } /// @@ -78,14 +79,17 @@ public sealed class CrewManifestCartridgeSystem : EntitySystem { _unsecureViewersAllowed = unsecureViewersAllowed; - var allCartridgeLoaders = AllEntityQuery(); - - while (allCartridgeLoaders.MoveNext(out EntityUid loaderUid, out CartridgeLoaderComponent? comp)) + var allCartridgeLoaders = AllEntityQuery(); + while (allCartridgeLoaders.MoveNext(out var loaderUid, out var comp, out var cont)) { if (_unsecureViewersAllowed) - _cartridgeLoader?.InstallProgram(loaderUid, CartridgePrototypeName, false, comp); - else - _cartridgeLoader?.UninstallProgram(loaderUid, CartridgePrototypeName, comp); + { + _cartridgeLoader.InstallProgram(loaderUid, CartridgePrototypeName, false, comp); + return; + } + + if (_cartridgeLoader.TryGetProgram(loaderUid, out var program, true, comp, cont)) + _cartridgeLoader.UninstallProgram(loaderUid, program.Value, comp); } } diff --git a/Content.Server/CartridgeLoader/Cartridges/NotekeeperCartridgeSystem.cs b/Content.Server/CartridgeLoader/Cartridges/NotekeeperCartridgeSystem.cs index 92c6ea6d76..287f682402 100644 --- a/Content.Server/CartridgeLoader/Cartridges/NotekeeperCartridgeSystem.cs +++ b/Content.Server/CartridgeLoader/Cartridges/NotekeeperCartridgeSystem.cs @@ -42,7 +42,7 @@ public sealed class NotekeeperCartridgeSystem : EntitySystem component.Notes.Remove(message.Note); } - UpdateUiState(uid, args.LoaderUid, component); + UpdateUiState(uid, GetEntity(args.LoaderUid), component); } diff --git a/Content.Server/CharacterInfo/CharacterInfoSystem.cs b/Content.Server/CharacterInfo/CharacterInfoSystem.cs index 5790e4f376..602f9e8af0 100644 --- a/Content.Server/CharacterInfo/CharacterInfoSystem.cs +++ b/Content.Server/CharacterInfo/CharacterInfoSystem.cs @@ -22,7 +22,7 @@ public sealed class CharacterInfoSystem : EntitySystem private void OnRequestCharacterInfoEvent(RequestCharacterInfoEvent msg, EntitySessionEventArgs args) { if (!args.SenderSession.AttachedEntity.HasValue - || args.SenderSession.AttachedEntity != msg.EntityUid) + || args.SenderSession.AttachedEntity != GetEntity(msg.NetEntity)) return; var entity = args.SenderSession.AttachedEntity.Value; @@ -51,6 +51,6 @@ public sealed class CharacterInfoSystem : EntitySystem briefing = _roles.MindGetBriefing(mindId); } - RaiseNetworkEvent(new CharacterInfoEvent(entity, jobTitle, conditions, briefing), args.SenderSession); + RaiseNetworkEvent(new CharacterInfoEvent(GetNetEntity(entity), jobTitle, conditions, briefing), args.SenderSession); } } diff --git a/Content.Server/Chat/Managers/ChatManager.cs b/Content.Server/Chat/Managers/ChatManager.cs index cecd08a7c6..aa055e4491 100644 --- a/Content.Server/Chat/Managers/ChatManager.cs +++ b/Content.Server/Chat/Managers/ChatManager.cs @@ -242,7 +242,7 @@ namespace Content.Server.Chat.Managers public void ChatMessageToOne(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, INetChannel client, Color? colorOverride = null, bool recordReplay = false, string? audioPath = null, float audioVolume = 0) { - var msg = new ChatMessage(channel, message, wrappedMessage, source, hideChat, colorOverride, audioPath, audioVolume); + var msg = new ChatMessage(channel, message, wrappedMessage, _entityManager.GetNetEntity(source), hideChat, colorOverride, audioPath, audioVolume); _netManager.ServerSendMessage(new MsgChatMessage() { Message = msg }, client); if (!recordReplay) @@ -260,7 +260,7 @@ namespace Content.Server.Chat.Managers public void ChatMessageToMany(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, List clients, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0) { - var msg = new ChatMessage(channel, message, wrappedMessage, source, hideChat, colorOverride, audioPath, audioVolume); + var msg = new ChatMessage(channel, message, wrappedMessage, _entityManager.GetNetEntity(source), hideChat, colorOverride, audioPath, audioVolume); _netManager.ServerSendToMany(new MsgChatMessage() { Message = msg }, clients); if (!recordReplay) @@ -290,7 +290,7 @@ namespace Content.Server.Chat.Managers public void ChatMessageToAll(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0) { - var msg = new ChatMessage(channel, message, wrappedMessage, source, hideChat, colorOverride, audioPath, audioVolume); + var msg = new ChatMessage(channel, message, wrappedMessage, _entityManager.GetNetEntity(source), hideChat, colorOverride, audioPath, audioVolume); _netManager.ServerSendToAll(new MsgChatMessage() { Message = msg }); if (!recordReplay) diff --git a/Content.Server/Chat/Systems/ChatSystem.cs b/Content.Server/Chat/Systems/ChatSystem.cs index 5d27065229..acc375b8b1 100644 --- a/Content.Server/Chat/Systems/ChatSystem.cs +++ b/Content.Server/Chat/Systems/ChatSystem.cs @@ -484,7 +484,7 @@ public sealed partial class ChatSystem : SharedChatSystem _chatManager.ChatMessageToOne(ChatChannel.Whisper, obfuscatedMessage, wrappedUnknownMessage, source, false, session.ConnectedClient); } - _replay.RecordServerMessage(new ChatMessage(ChatChannel.Whisper, message, wrappedMessage, source, MessageRangeHideChatForReplay(range))); + _replay.RecordServerMessage(new ChatMessage(ChatChannel.Whisper, message, wrappedMessage, GetNetEntity(source), MessageRangeHideChatForReplay(range))); var ev = new EntitySpokeEvent(source, message, channel, obfuscatedMessage); RaiseLocalEvent(source, ev, true); @@ -651,7 +651,7 @@ public sealed partial class ChatSystem : SharedChatSystem _chatManager.ChatMessageToOne(channel, message, wrappedMessage, source, entHideChat, session.ConnectedClient); } - _replay.RecordServerMessage(new ChatMessage(channel, message, wrappedMessage, source, MessageRangeHideChatForReplay(range))); + _replay.RecordServerMessage(new ChatMessage(channel, message, wrappedMessage, GetNetEntity(source), MessageRangeHideChatForReplay(range))); } /// diff --git a/Content.Server/Chemistry/EntitySystems/ChemistrySystem.Injector.cs b/Content.Server/Chemistry/EntitySystems/ChemistrySystem.Injector.cs index f3bac645d7..eb4c274c94 100644 --- a/Content.Server/Chemistry/EntitySystems/ChemistrySystem.Injector.cs +++ b/Content.Server/Chemistry/EntitySystems/ChemistrySystem.Injector.cs @@ -259,7 +259,7 @@ public sealed partial class ChemistrySystem _adminLogger.Add(LogType.Ingestion, $"{EntityManager.ToPrettyString(user):user} is attempting to inject themselves with a solution {SolutionContainerSystem.ToPrettyString(solution):solution}."); } - _doAfter.TryStartDoAfter(new DoAfterArgs(user, actualDelay, new InjectorDoAfterEvent(), injector, target: target, used: injector) + _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, actualDelay, new InjectorDoAfterEvent(), injector, target: target, used: injector) { BreakOnUserMove = true, BreakOnDamage = true, diff --git a/Content.Server/Chunking/ChunkingSystem.cs b/Content.Server/Chunking/ChunkingSystem.cs index f04a720fc9..f204b5cf72 100644 --- a/Content.Server/Chunking/ChunkingSystem.cs +++ b/Content.Server/Chunking/ChunkingSystem.cs @@ -20,11 +20,14 @@ public sealed class ChunkingSystem : EntitySystem [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; + private EntityQuery _xformQuery; + private Box2 _baseViewBounds; public override void Initialize() { base.Initialize(); + _xformQuery = GetEntityQuery(); _configurationManager.OnValueChanged(CVars.NetMaxUpdateRange, OnPvsRangeChanged, true); } @@ -36,16 +39,15 @@ public sealed class ChunkingSystem : EntitySystem private void OnPvsRangeChanged(float value) => _baseViewBounds = Box2.UnitCentered.Scale(value); - public Dictionary> GetChunksForSession( + public Dictionary> GetChunksForSession( IPlayerSession session, int chunkSize, - EntityQuery xformQuery, ObjectPool> indexPool, - ObjectPool>> viewerPool, + ObjectPool>> viewerPool, float? viewEnlargement = null) { var viewers = GetSessionViewers(session); - var chunks = GetChunksForViewers(viewers, chunkSize, indexPool, viewerPool, viewEnlargement ?? chunkSize, xformQuery); + var chunks = GetChunksForViewers(viewers, chunkSize, indexPool, viewerPool, viewEnlargement ?? chunkSize); return chunks; } @@ -65,37 +67,38 @@ public sealed class ChunkingSystem : EntitySystem return viewers; } - private Dictionary> GetChunksForViewers( + private Dictionary> GetChunksForViewers( HashSet viewers, int chunkSize, ObjectPool> indexPool, - ObjectPool>> viewerPool, - float viewEnlargement, - EntityQuery xformQuery) + ObjectPool>> viewerPool, + float viewEnlargement) { - Dictionary> chunks = viewerPool.Get(); + var chunks = viewerPool.Get(); DebugTools.Assert(chunks.Count == 0); foreach (var viewerUid in viewers) { - if (!xformQuery.TryGetComponent(viewerUid, out var xform)) + if (!_xformQuery.TryGetComponent(viewerUid, out var xform)) { - Log.Error($"Player has deleted viewer entities? Viewers: {string.Join(", ", viewers.Select(x => ToPrettyString(x)))}"); + Log.Error($"Player has deleted viewer entities? Viewers: {string.Join(", ", viewers.Select(ToPrettyString))}"); continue; } - var pos = _transform.GetWorldPosition(xform, xformQuery); + var pos = _transform.GetWorldPosition(xform); var bounds = _baseViewBounds.Translated(pos).Enlarged(viewEnlargement); foreach (var grid in _mapManager.FindGridsIntersecting(xform.MapID, bounds, true)) { - if (!chunks.TryGetValue(grid.Owner, out var set)) + var netGrid = GetNetEntity(grid.Owner); + + if (!chunks.TryGetValue(netGrid, out var set)) { - chunks[grid.Owner] = set = indexPool.Get(); + chunks[netGrid] = set = indexPool.Get(); DebugTools.Assert(set.Count == 0); } - var enumerator = new ChunkIndicesEnumerator(_transform.GetInvWorldMatrix(grid.Owner, xformQuery).TransformBox(bounds), chunkSize); + var enumerator = new ChunkIndicesEnumerator(_transform.GetInvWorldMatrix(grid.Owner).TransformBox(bounds), chunkSize); while (enumerator.MoveNext(out var indices)) { diff --git a/Content.Server/Climbing/ClimbSystem.cs b/Content.Server/Climbing/ClimbSystem.cs index 539463eed4..08830fc89c 100644 --- a/Content.Server/Climbing/ClimbSystem.cs +++ b/Content.Server/Climbing/ClimbSystem.cs @@ -128,7 +128,7 @@ public sealed class ClimbSystem : SharedClimbSystem if (climbing.IsClimbing) return true; - var args = new DoAfterArgs(user, comp.ClimbDelay, new ClimbDoAfterEvent(), entityToMove, target: climbable, used: entityToMove) + var args = new DoAfterArgs(EntityManager, user, comp.ClimbDelay, new ClimbDoAfterEvent(), entityToMove, target: climbable, used: entityToMove) { BreakOnTargetMove = true, BreakOnUserMove = true, diff --git a/Content.Server/Cloning/CloningConsoleSystem.cs b/Content.Server/Cloning/CloningConsoleSystem.cs index aea0532bfc..29f42bf6c2 100644 --- a/Content.Server/Cloning/CloningConsoleSystem.cs +++ b/Content.Server/Cloning/CloningConsoleSystem.cs @@ -145,7 +145,7 @@ namespace Content.Server.Cloning } var newState = GetUserInterfaceState(consoleComponent); - UserInterfaceSystem.SetUiState(ui, newState); + _uiSystem.SetUiState(ui, newState); } public void TryClone(EntityUid uid, EntityUid cloningPodUid, EntityUid scannerUid, CloningPodComponent? cloningPod = null, MedicalScannerComponent? scannerComp = null, CloningConsoleComponent? consoleComponent = null) diff --git a/Content.Server/Communications/CommsHackerSystem.cs b/Content.Server/Communications/CommsHackerSystem.cs index 6ef9e1b1bb..95cad6eb97 100644 --- a/Content.Server/Communications/CommsHackerSystem.cs +++ b/Content.Server/Communications/CommsHackerSystem.cs @@ -38,7 +38,7 @@ public sealed class CommsHackerSystem : SharedCommsHackerSystem if (!_gloves.AbilityCheck(uid, args, out var target)) return; - var doAfterArgs = new DoAfterArgs(uid, comp.Delay, new TerrorDoAfterEvent(), target: target, used: uid, eventTarget: uid) + var doAfterArgs = new DoAfterArgs(EntityManager, uid, comp.Delay, new TerrorDoAfterEvent(), target: target, used: uid, eventTarget: uid) { BreakOnDamage = true, BreakOnUserMove = true, diff --git a/Content.Server/Communications/CommunicationsConsoleSystem.cs b/Content.Server/Communications/CommunicationsConsoleSystem.cs index b78389b57d..b7ad536816 100644 --- a/Content.Server/Communications/CommunicationsConsoleSystem.cs +++ b/Content.Server/Communications/CommunicationsConsoleSystem.cs @@ -31,6 +31,7 @@ namespace Content.Server.Communications [Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly RoundEndSystem _roundEndSystem = default!; [Dependency] private readonly StationSystem _stationSystem = default!; + [Dependency] private readonly UserInterfaceSystem _uiSystem = default!; [Dependency] private readonly IConfigurationManager _cfg = default!; [Dependency] private readonly IAdminLogManager _adminLogger = default!; @@ -151,7 +152,7 @@ namespace Content.Server.Communications } if (comp.UserInterface is not null) - UserInterfaceSystem.SetUiState(comp.UserInterface, new CommunicationsConsoleInterfaceState( + _uiSystem.SetUiState(comp.UserInterface, new CommunicationsConsoleInterfaceState( CanAnnounce(comp), CanCallOrRecall(comp), levels, diff --git a/Content.Server/Configurable/ConfigurationSystem.cs b/Content.Server/Configurable/ConfigurationSystem.cs index cfe580f391..c134c1a87d 100644 --- a/Content.Server/Configurable/ConfigurationSystem.cs +++ b/Content.Server/Configurable/ConfigurationSystem.cs @@ -43,7 +43,7 @@ public sealed class ConfigurationSystem : EntitySystem private void UpdateUi(EntityUid uid, ConfigurationComponent component) { if (_uiSystem.TryGetUi(uid, ConfigurationUiKey.Key, out var ui)) - UserInterfaceSystem.SetUiState(ui, new ConfigurationBoundUserInterfaceState(component.Config)); + _uiSystem.SetUiState(ui, new ConfigurationBoundUserInterfaceState(component.Config)); } private void OnUpdate(EntityUid uid, ConfigurationComponent component, ConfigurationUpdatedMessage args) diff --git a/Content.Server/Construction/Commands/FixRotationsCommand.cs b/Content.Server/Construction/Commands/FixRotationsCommand.cs index 307f0159a9..02429fcaa6 100644 --- a/Content.Server/Construction/Commands/FixRotationsCommand.cs +++ b/Content.Server/Construction/Commands/FixRotationsCommand.cs @@ -10,8 +10,11 @@ using Robust.Shared.Map; namespace Content.Server.Construction.Commands { [AdminCommand(AdminFlags.Mapping)] - sealed class FixRotationsCommand : IConsoleCommand + public sealed class FixRotationsCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly IMapManager _mapManager = default!; + // ReSharper disable once StringLiteralTypo public string Command => "fixrotations"; public string Description => "Sets the rotation of all occluders, low walls and windows to south."; @@ -20,9 +23,8 @@ namespace Content.Server.Construction.Commands public void Execute(IConsoleShell shell, string argsOther, string[] args) { var player = shell.Player as IPlayerSession; - var entityManager = IoCManager.Resolve(); EntityUid? gridId; - var xformQuery = entityManager.GetEntityQuery(); + var xformQuery = _entManager.GetEntityQuery(); switch (args.Length) { @@ -36,7 +38,7 @@ namespace Content.Server.Construction.Commands gridId = xformQuery.GetComponent(playerEntity).GridUid; break; case 1: - if (!EntityUid.TryParse(args[0], out var id)) + if (!NetEntity.TryParse(args[0], out var idNet) || !_entManager.TryGetEntity(idNet, out var id)) { shell.WriteError($"{args[0]} is not a valid entity."); return; @@ -49,25 +51,24 @@ namespace Content.Server.Construction.Commands return; } - var mapManager = IoCManager.Resolve(); - if (!mapManager.TryGetGrid(gridId, out var grid)) + if (!_mapManager.TryGetGrid(gridId, out var grid)) { shell.WriteError($"No grid exists with id {gridId}"); return; } - if (!entityManager.EntityExists(grid.Owner)) + if (!_entManager.EntityExists(grid.Owner)) { shell.WriteError($"Grid {gridId} doesn't have an associated grid entity."); return; } var changed = 0; - var tagSystem = entityManager.EntitySysManager.GetEntitySystem(); + var tagSystem = _entManager.EntitySysManager.GetEntitySystem(); foreach (var child in xformQuery.GetComponent(grid.Owner).ChildEntities) { - if (!entityManager.EntityExists(child)) + if (!_entManager.EntityExists(child)) { continue; } @@ -76,14 +77,14 @@ namespace Content.Server.Construction.Commands // Occluders should only count if the state of it right now is enabled. // This prevents issues with edge firelocks. - if (entityManager.TryGetComponent(child, out var occluder)) + if (_entManager.TryGetComponent(child, out var occluder)) { valid |= occluder.Enabled; } // low walls & grilles - valid |= entityManager.HasComponent(child); + valid |= _entManager.HasComponent(child); // cables - valid |= entityManager.HasComponent(child); + valid |= _entManager.HasComponent(child); // anything else that might need this forced valid |= tagSystem.HasTag(child, "ForceFixRotations"); // override diff --git a/Content.Server/Construction/Commands/TileReplaceCommand.cs b/Content.Server/Construction/Commands/TileReplaceCommand.cs index c730c81f8d..7de6c510d4 100644 --- a/Content.Server/Construction/Commands/TileReplaceCommand.cs +++ b/Content.Server/Construction/Commands/TileReplaceCommand.cs @@ -9,6 +9,10 @@ namespace Content.Server.Construction.Commands; [AdminCommand(AdminFlags.Mapping)] sealed class TileReplaceCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly IMapManager _mapManager = default!; + [Dependency] private readonly ITileDefinitionManager _tileDef = default!; + // ReSharper disable once StringLiteralTypo public string Command => "tilereplace"; public string Description => "Replaces one tile with another."; @@ -17,7 +21,6 @@ sealed class TileReplaceCommand : IConsoleCommand public void Execute(IConsoleShell shell, string argStr, string[] args) { var player = shell.Player as IPlayerSession; - var entityManager = IoCManager.Resolve(); EntityUid? gridId; string tileIdA; string tileIdB; @@ -31,12 +34,13 @@ sealed class TileReplaceCommand : IConsoleCommand return; } - gridId = entityManager.GetComponent(playerEntity).GridUid; + gridId = _entManager.GetComponent(playerEntity).GridUid; tileIdA = args[0]; tileIdB = args[1]; break; case 3: - if (!EntityUid.TryParse(args[0], out var id)) + if (!NetEntity.TryParse(args[0], out var idNet) || + !_entManager.TryGetEntity(idNet, out var id)) { shell.WriteLine($"{args[0]} is not a valid entity."); return; @@ -51,18 +55,16 @@ sealed class TileReplaceCommand : IConsoleCommand return; } - var tileDefinitionManager = IoCManager.Resolve(); - var tileA = tileDefinitionManager[tileIdA]; - var tileB = tileDefinitionManager[tileIdB]; + var tileA = _tileDef[tileIdA]; + var tileB = _tileDef[tileIdB]; - var mapManager = IoCManager.Resolve(); - if (!mapManager.TryGetGrid(gridId, out var grid)) + if (!_mapManager.TryGetGrid(gridId, out var grid)) { shell.WriteLine($"No grid exists with id {gridId}"); return; } - if (!entityManager.EntityExists(grid.Owner)) + if (!_entManager.EntityExists(grid.Owner)) { shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity."); return; diff --git a/Content.Server/Construction/Commands/TileWallsCommand.cs b/Content.Server/Construction/Commands/TileWallsCommand.cs index af079405d2..e919350364 100644 --- a/Content.Server/Construction/Commands/TileWallsCommand.cs +++ b/Content.Server/Construction/Commands/TileWallsCommand.cs @@ -11,6 +11,10 @@ namespace Content.Server.Construction.Commands [AdminCommand(AdminFlags.Mapping)] sealed class TileWallsCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly IMapManager _mapManager = default!; + [Dependency] private readonly ITileDefinitionManager _tileDefManager = default!; + // ReSharper disable once StringLiteralTypo public string Command => "tilewalls"; public string Description => "Puts an underplating tile below every wall on a grid."; @@ -25,7 +29,6 @@ namespace Content.Server.Construction.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { var player = shell.Player as IPlayerSession; - var entityManager = IoCManager.Resolve(); EntityUid? gridId; switch (args.Length) @@ -37,10 +40,10 @@ namespace Content.Server.Construction.Commands return; } - gridId = entityManager.GetComponent(playerEntity).GridUid; + gridId = _entManager.GetComponent(playerEntity).GridUid; break; case 1: - if (!EntityUid.TryParse(args[0], out var id)) + if (!NetEntity.TryParse(args[0], out var idNet) || !_entManager.TryGetEntity(idNet, out var id)) { shell.WriteLine($"{args[0]} is not a valid entity."); return; @@ -53,27 +56,25 @@ namespace Content.Server.Construction.Commands return; } - var mapManager = IoCManager.Resolve(); - if (!mapManager.TryGetGrid(gridId, out var grid)) + if (!_mapManager.TryGetGrid(gridId, out var grid)) { shell.WriteLine($"No grid exists with id {gridId}"); return; } - if (!entityManager.EntityExists(grid.Owner)) + if (!_entManager.EntityExists(grid.Owner)) { shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity."); return; } - var tileDefinitionManager = IoCManager.Resolve(); - var tagSystem = entityManager.EntitySysManager.GetEntitySystem(); - var underplating = tileDefinitionManager[TilePrototypeId]; + var tagSystem = _entManager.EntitySysManager.GetEntitySystem(); + var underplating = _tileDefManager[TilePrototypeId]; var underplatingTile = new Tile(underplating.TileId); var changed = 0; - foreach (var child in entityManager.GetComponent(grid.Owner).ChildEntities) + foreach (var child in _entManager.GetComponent(grid.Owner).ChildEntities) { - if (!entityManager.EntityExists(child)) + if (!_entManager.EntityExists(child)) { continue; } @@ -83,7 +84,7 @@ namespace Content.Server.Construction.Commands continue; } - var childTransform = entityManager.GetComponent(child); + var childTransform = _entManager.GetComponent(child); if (!childTransform.Anchored) { @@ -91,7 +92,7 @@ namespace Content.Server.Construction.Commands } var tile = grid.GetTileRef(childTransform.Coordinates); - var tileDef = (ContentTileDefinition) tileDefinitionManager[tile.Tile.TypeId]; + var tileDef = (ContentTileDefinition) _tileDefManager[tile.Tile.TypeId]; if (tileDef.ID == TilePrototypeId) { diff --git a/Content.Server/Construction/ConstructionSystem.Initial.cs b/Content.Server/Construction/ConstructionSystem.Initial.cs index 2284ade6bd..5c2aecb548 100644 --- a/Content.Server/Construction/ConstructionSystem.Initial.cs +++ b/Content.Server/Construction/ConstructionSystem.Initial.cs @@ -247,7 +247,7 @@ namespace Content.Server.Construction return null; } - var doAfterArgs = new DoAfterArgs(user, doAfterTime, new AwaitedDoAfterEvent(), null) + var doAfterArgs = new DoAfterArgs(EntityManager, user, doAfterTime, new AwaitedDoAfterEvent(), null) { BreakOnDamage = true, BreakOnTargetMove = false, @@ -432,9 +432,11 @@ namespace Content.Server.Construction _beingBuilt[args.SenderSession] = newSet; } + var location = GetCoordinates(ev.Location); + foreach (var condition in constructionPrototype.Conditions) { - if (!condition.Condition(user, ev.Location, ev.Angle.GetCardinalDir())) + if (!condition.Condition(user, location, ev.Angle.GetCardinalDir())) { Cleanup(); return; @@ -453,7 +455,7 @@ namespace Content.Server.Construction return; } - var mapPos = ev.Location.ToMap(EntityManager); + var mapPos = location.ToMap(EntityManager); var predicate = GetPredicate(constructionPrototype.CanBuildInImpassable, mapPos); if (!_interactionSystem.InRangeUnobstructed(user, mapPos, predicate: predicate)) @@ -515,11 +517,11 @@ namespace Content.Server.Construction var xform = Transform(structure); var wasAnchored = xform.Anchored; xform.Anchored = false; - xform.Coordinates = ev.Location; + xform.Coordinates = GetCoordinates(ev.Location); xform.LocalRotation = constructionPrototype.CanRotate ? ev.Angle : Angle.Zero; xform.Anchored = wasAnchored; - RaiseNetworkEvent(new AckStructureConstructionMessage(ev.Ack, structure)); + RaiseNetworkEvent(new AckStructureConstructionMessage(ev.Ack, GetNetEntity(structure))); _adminLogger.Add(LogType.Construction, LogImpact.Low, $"{ToPrettyString(user):player} has turned a {ev.PrototypeName} construction ghost into {ToPrettyString(structure)} at {Transform(structure).Coordinates}"); Cleanup(); } diff --git a/Content.Server/Construction/ConstructionSystem.Interactions.cs b/Content.Server/Construction/ConstructionSystem.Interactions.cs index 3336736fac..e6c0f039b0 100644 --- a/Content.Server/Construction/ConstructionSystem.Interactions.cs +++ b/Content.Server/Construction/ConstructionSystem.Interactions.cs @@ -240,7 +240,7 @@ namespace Content.Server.Construction interactDoAfter.User, interactDoAfter.Used!.Value, uid, - interactDoAfter.ClickLocation); + GetCoordinates(interactDoAfter.ClickLocation)); doAfterState = DoAfterState.Completed; } @@ -281,9 +281,9 @@ namespace Content.Server.Construction // If we still haven't completed this step's DoAfter... if (doAfterState == DoAfterState.None && insertStep.DoAfter > 0) { - var doAfterEv = new ConstructionInteractDoAfterEvent(interactUsing); + var doAfterEv = new ConstructionInteractDoAfterEvent(EntityManager, interactUsing); - var doAfterEventArgs = new DoAfterArgs(interactUsing.User, step.DoAfter, doAfterEv, uid, uid, interactUsing.Used) + var doAfterEventArgs = new DoAfterArgs(EntityManager, interactUsing.User, step.DoAfter, doAfterEv, uid, uid, interactUsing.Used) { BreakOnDamage = false, BreakOnTargetMove = true, @@ -367,7 +367,7 @@ namespace Content.Server.Construction uid, TimeSpan.FromSeconds(toolInsertStep.DoAfter), new [] { toolInsertStep.Tool }, - new ConstructionInteractDoAfterEvent(interactUsing), + new ConstructionInteractDoAfterEvent(EntityManager, interactUsing), out var doAfter); return result && doAfter != null ? HandleResult.DoAfter : HandleResult.False; diff --git a/Content.Server/Construction/PartExchangerSystem.cs b/Content.Server/Construction/PartExchangerSystem.cs index f5d7a4c354..a4030a70d4 100644 --- a/Content.Server/Construction/PartExchangerSystem.cs +++ b/Content.Server/Construction/PartExchangerSystem.cs @@ -170,7 +170,7 @@ public sealed class PartExchangerSystem : EntitySystem component.AudioStream = _audio.PlayPvs(component.ExchangeSound, uid); - _doAfter.TryStartDoAfter(new DoAfterArgs(args.User, component.ExchangeDuration, new ExchangerDoAfterEvent(), uid, target: args.Target, used: uid) + _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.ExchangeDuration, new ExchangerDoAfterEvent(), uid, target: args.Target, used: uid) { BreakOnDamage = true, BreakOnUserMove = true diff --git a/Content.Server/Crayon/CrayonSystem.cs b/Content.Server/Crayon/CrayonSystem.cs index fd684f53d7..7cc2c20d89 100644 --- a/Content.Server/Crayon/CrayonSystem.cs +++ b/Content.Server/Crayon/CrayonSystem.cs @@ -99,7 +99,7 @@ public sealed class CrayonSystem : SharedCrayonSystem if (component.UserInterface?.SubscribedSessions.Contains(actor.PlayerSession) == true) { // Tell the user interface the selected stuff - UserInterfaceSystem.SetUiState(component.UserInterface, new CrayonBoundUserInterfaceState(component.SelectedState, component.SelectableColor, component.Color)); + _uiSystem.SetUiState(component.UserInterface, new CrayonBoundUserInterfaceState(component.SelectedState, component.SelectableColor, component.Color)); } args.Handled = true; diff --git a/Content.Server/CrewManifest/CrewManifestSystem.cs b/Content.Server/CrewManifest/CrewManifestSystem.cs index 23cd9c88ea..9471c88c9e 100644 --- a/Content.Server/CrewManifest/CrewManifestSystem.cs +++ b/Content.Server/CrewManifest/CrewManifestSystem.cs @@ -65,7 +65,7 @@ public sealed class CrewManifestSystem : EntitySystem return; } - OpenEui(message.Id, sessionCast); + OpenEui(GetEntity(message.Id), sessionCast); } // Not a big fan of this one. Rebuilds the crew manifest every time @@ -213,15 +213,7 @@ public sealed class CrewManifestSystem : EntitySystem } entries.Entries = entries.Entries.OrderBy(e => e.JobTitle).ThenBy(e => e.Name).ToList(); - - if (_cachedEntries.ContainsKey(station)) - { - _cachedEntries[station] = entries; - } - else - { - _cachedEntries.Add(station, entries); - } + _cachedEntries[station] = entries; } } @@ -247,7 +239,7 @@ public sealed class CrewManifestCommand : IConsoleCommand return; } - if (!EntityUid.TryParse(args[0], out var uid)) + if (!NetEntity.TryParse(args[0], out var uidNet) || !_entityManager.TryGetEntity(uidNet, out var uid)) { shell.WriteLine($"{args[0]} is not a valid entity UID."); return; @@ -261,7 +253,7 @@ public sealed class CrewManifestCommand : IConsoleCommand var crewManifestSystem = _entityManager.System(); - crewManifestSystem.OpenEui(uid, session); + crewManifestSystem.OpenEui(uid.Value, session); } public CompletionResult GetCompletion(IConsoleShell shell, string[] args) diff --git a/Content.Server/Damage/Commands/GodModeCommand.cs b/Content.Server/Damage/Commands/GodModeCommand.cs index d5d3d32b59..92a0e53f0f 100644 --- a/Content.Server/Damage/Commands/GodModeCommand.cs +++ b/Content.Server/Damage/Commands/GodModeCommand.cs @@ -10,6 +10,8 @@ namespace Content.Server.Damage.Commands [AdminCommand(AdminFlags.Admin)] public sealed class GodModeCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "godmode"; public string Description => "Makes your entity or another invulnerable to almost anything. May have irreversible changes."; public string Help => $"Usage: {Command} / {Command} "; @@ -19,8 +21,6 @@ namespace Content.Server.Damage.Commands var player = shell.Player as IPlayerSession; EntityUid entity; - var entityManager = IoCManager.Resolve(); - switch (args.Length) { case 0: @@ -39,29 +39,29 @@ namespace Content.Server.Damage.Commands entity = player.AttachedEntity.Value; break; case 1: - if (!EntityUid.TryParse(args[0], out var id)) + if (!NetEntity.TryParse(args[0], out var idNet) || !_entManager.TryGetEntity(idNet, out var id)) { shell.WriteLine($"{args[0]} isn't a valid entity id."); return; } - if (!entityManager.EntityExists(id)) + if (!_entManager.EntityExists(id)) { shell.WriteLine($"No entity found with id {id}."); return; } - entity = id; + entity = id.Value; break; default: shell.WriteLine(Help); return; } - var godmodeSystem = EntitySystem.Get(); + var godmodeSystem = _entManager.System(); var enabled = godmodeSystem.ToggleGodmode(entity); - var name = entityManager.GetComponent(entity).EntityName; + var name = _entManager.GetComponent(entity).EntityName; shell.WriteLine(enabled ? $"Enabled godmode for entity {name} with id {entity}" diff --git a/Content.Server/Damage/Commands/HurtCommand.cs b/Content.Server/Damage/Commands/HurtCommand.cs index 8e00ad14b2..af9c1ee8fc 100644 --- a/Content.Server/Damage/Commands/HurtCommand.cs +++ b/Content.Server/Damage/Commands/HurtCommand.cs @@ -13,15 +13,13 @@ namespace Content.Server.Damage.Commands [AdminCommand(AdminFlags.Fun)] sealed class DamageCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + public string Command => "damage"; public string Description => Loc.GetString("damage-command-description"); public string Help => Loc.GetString("damage-command-help", ("command", Command)); - private readonly IPrototypeManager _prototypeManager = default!; - public DamageCommand() { - _prototypeManager = IoCManager.Resolve(); - } - public CompletionResult GetCompletion(IConsoleShell shell, string[] args) { if (args.Length == 1) @@ -75,28 +73,27 @@ namespace Content.Server.Damage.Commands func = (entity, ignoreResistances) => { var damage = new DamageSpecifier(damageGroup, amount); - EntitySystem.Get().TryChangeDamage(entity, damage, ignoreResistances); + _entManager.System().TryChangeDamage(entity, damage, ignoreResistances); }; return true; } // Fall back to DamageType - else if (_prototypeManager.TryIndex(args[0], out var damageType)) + + if (_prototypeManager.TryIndex(args[0], out var damageType)) { func = (entity, ignoreResistances) => { var damage = new DamageSpecifier(damageType, amount); - EntitySystem.Get().TryChangeDamage(entity, damage, ignoreResistances); + _entManager.System().TryChangeDamage(entity, damage, ignoreResistances); }; return true; } - else - { - shell.WriteLine(Loc.GetString("damage-command-error-type", ("arg", args[0]))); - func = null; - return false; - } + + shell.WriteLine(Loc.GetString("damage-command-error-type", ("arg", args[0]))); + func = null; + return false; } public void Execute(IConsoleShell shell, string argStr, string[] args) @@ -107,11 +104,11 @@ namespace Content.Server.Damage.Commands return; } - EntityUid target; - var entMan = IoCManager.Resolve(); + EntityUid? target; + if (args.Length == 4) { - if (!EntityUid.TryParse(args[3], out target) || !entMan.EntityExists(target)) + if (!_entManager.TryParseNetEntity(args[3], out target) || !_entManager.EntityExists(target)) { shell.WriteLine(Loc.GetString("damage-command-error-euid", ("arg", args[3]))); return; @@ -127,7 +124,7 @@ namespace Content.Server.Damage.Commands return; } - if (!TryParseDamageArgs(shell, target, args, out var damageFunc)) + if (!TryParseDamageArgs(shell, target.Value, args, out var damageFunc)) return; bool ignoreResistances; @@ -144,7 +141,7 @@ namespace Content.Server.Damage.Commands ignoreResistances = false; } - damageFunc(target, ignoreResistances); + damageFunc(target.Value, ignoreResistances); } } } diff --git a/Content.Server/Decals/Commands/AddDecalCommand.cs b/Content.Server/Decals/Commands/AddDecalCommand.cs index be57d91786..b780f0686d 100644 --- a/Content.Server/Decals/Commands/AddDecalCommand.cs +++ b/Content.Server/Decals/Commands/AddDecalCommand.cs @@ -12,6 +12,10 @@ namespace Content.Server.Decals.Commands [AdminCommand(AdminFlags.Mapping)] public sealed class AddDecalCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly IMapManager _mapManager = default!; + [Dependency] private readonly IPrototypeManager _protoManager = default!; + public string Command => "adddecal"; public string Description => "Creates a decal on the map"; public string Help => $"{Command} [angle= zIndex= color=]"; @@ -23,7 +27,7 @@ namespace Content.Server.Decals.Commands return; } - if (!IoCManager.Resolve().HasIndex(args[0])) + if (!_protoManager.HasIndex(args[0])) { shell.WriteError($"Cannot find decalprototype '{args[0]}'."); } @@ -40,8 +44,9 @@ namespace Content.Server.Decals.Commands return; } - var mapManager = IoCManager.Resolve(); - if (!EntityUid.TryParse(args[3], out var gridIdRaw) || !mapManager.TryGetGrid(gridIdRaw, out var grid)) + if (!NetEntity.TryParse(args[3], out var gridIdNet) || + !_entManager.TryGetEntity(gridIdNet, out var gridIdRaw) || + !_mapManager.TryGetGrid(gridIdRaw, out var grid)) { shell.WriteError($"Failed parsing gridId '{args[3]}'."); return; @@ -101,7 +106,7 @@ namespace Content.Server.Decals.Commands } } - if(EntitySystem.Get().TryAddDecal(args[0], coordinates, out var uid, color, rotation, zIndex)) + if (_entManager.System().TryAddDecal(args[0], coordinates, out var uid, color, rotation, zIndex)) { shell.WriteLine($"Successfully created decal {uid}."); } diff --git a/Content.Server/Decals/Commands/EditDecalCommand.cs b/Content.Server/Decals/Commands/EditDecalCommand.cs index a300d21850..baaef1f3f6 100644 --- a/Content.Server/Decals/Commands/EditDecalCommand.cs +++ b/Content.Server/Decals/Commands/EditDecalCommand.cs @@ -9,6 +9,9 @@ namespace Content.Server.Decals; [AdminCommand(AdminFlags.Mapping)] public sealed class EditDecalCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly IMapManager _mapManager = default!; + public string Command => "editdecal"; public string Description => "Edits a decal."; public string Help => $@"{Command} \n @@ -28,7 +31,7 @@ Possible modes are:\n return; } - if (!EntityUid.TryParse(args[0], out var gridId)) + if (!NetEntity.TryParse(args[0], out var gridIdNet) || !_entManager.TryGetEntity(gridIdNet, out var gridId)) { shell.WriteError($"Failed parsing gridId '{args[3]}'."); return; @@ -40,13 +43,13 @@ Possible modes are:\n return; } - if (!IoCManager.Resolve().GridExists(gridId)) + if (!_mapManager.GridExists(gridId)) { shell.WriteError($"No grid with gridId {gridId} exists."); return; } - var decalSystem = EntitySystem.Get(); + var decalSystem = _entManager.System(); switch (args[2].ToLower()) { case "position": @@ -62,7 +65,7 @@ Possible modes are:\n return; } - if (!decalSystem.SetDecalPosition(gridId, uid, new(gridId, new Vector2(x, y)))) + if (!decalSystem.SetDecalPosition(gridId.Value, uid, new(gridId.Value, new Vector2(x, y)))) { shell.WriteError("Failed changing decalposition."); } @@ -80,7 +83,7 @@ Possible modes are:\n return; } - if (!decalSystem.SetDecalColor(gridId, uid, color)) + if (!decalSystem.SetDecalColor(gridId.Value, uid, color)) { shell.WriteError("Failed changing decal color."); } @@ -92,7 +95,7 @@ Possible modes are:\n return; } - if (!decalSystem.SetDecalId(gridId, uid, args[3])) + if (!decalSystem.SetDecalId(gridId.Value, uid, args[3])) { shell.WriteError("Failed changing decal id."); } @@ -110,7 +113,7 @@ Possible modes are:\n return; } - if (!decalSystem.SetDecalRotation(gridId, uid, Angle.FromDegrees(degrees))) + if (!decalSystem.SetDecalRotation(gridId.Value, uid, Angle.FromDegrees(degrees))) { shell.WriteError("Failed changing decal rotation."); } @@ -128,7 +131,7 @@ Possible modes are:\n return; } - if (!decalSystem.SetDecalZIndex(gridId, uid, zIndex)) + if (!decalSystem.SetDecalZIndex(gridId.Value, uid, zIndex)) { shell.WriteError("Failed changing decal zIndex."); } @@ -146,7 +149,7 @@ Possible modes are:\n return; } - if (!decalSystem.SetDecalCleanable(gridId, uid, cleanable)) + if (!decalSystem.SetDecalCleanable(gridId.Value, uid, cleanable)) { shell.WriteError("Failed changing decal cleanable flag."); } diff --git a/Content.Server/Decals/Commands/RemoveDecalCommand.cs b/Content.Server/Decals/Commands/RemoveDecalCommand.cs index 3c7d44d5c4..771c66fbbd 100644 --- a/Content.Server/Decals/Commands/RemoveDecalCommand.cs +++ b/Content.Server/Decals/Commands/RemoveDecalCommand.cs @@ -2,12 +2,16 @@ using Content.Server.Administration; using Content.Shared.Administration; using Robust.Shared.Console; using Robust.Shared.Map; +using SQLitePCL; namespace Content.Server.Decals.Commands { [AdminCommand(AdminFlags.Mapping)] public sealed class RemoveDecalCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly IMapManager _mapManager = default!; + public string Command => "rmdecal"; public string Description => "removes a decal"; public string Help => $"{Command} "; @@ -25,14 +29,16 @@ namespace Content.Server.Decals.Commands return; } - if (!EntityUid.TryParse(args[1], out var rawGridId) || - !IoCManager.Resolve().GridExists(rawGridId)) + if (!NetEntity.TryParse(args[1], out var rawGridIdNet) || + !_entManager.TryGetEntity(rawGridIdNet, out var rawGridId) || + !_mapManager.GridExists(rawGridId)) { shell.WriteError("Failed parsing gridId."); + return; } - var decalSystem = EntitySystem.Get(); - if (decalSystem.RemoveDecal(rawGridId, uid)) + var decalSystem = _entManager.System(); + if (decalSystem.RemoveDecal(rawGridId.Value, uid)) { shell.WriteLine($"Successfully removed decal {uid}."); return; diff --git a/Content.Server/Decals/DecalSystem.cs b/Content.Server/Decals/DecalSystem.cs index e76ca25069..6f40ebae3a 100644 --- a/Content.Server/Decals/DecalSystem.cs +++ b/Content.Server/Decals/DecalSystem.cs @@ -1,4 +1,3 @@ -using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Numerics; using System.Threading.Tasks; @@ -14,7 +13,6 @@ using Robust.Server.Player; using Robust.Shared; using Robust.Shared.Configuration; using Robust.Shared.Enums; -using Robust.Shared.GameStates; using Robust.Shared.Map; using Robust.Shared.Threading; using Robust.Shared.Timing; @@ -34,8 +32,8 @@ namespace Content.Server.Decals [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IAdminLogManager _adminLogger = default!; - private readonly Dictionary> _dirtyChunks = new(); - private readonly Dictionary>> _previousSentChunks = new(); + private readonly Dictionary> _dirtyChunks = 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); @@ -44,9 +42,9 @@ namespace Content.Server.Decals new DefaultObjectPool>( new DefaultPooledObjectPolicy>(), 64); - private ObjectPool>> _chunkViewerPool = - new DefaultObjectPool>>( - new DefaultPooledObjectPolicy>>(), 64); + private ObjectPool>> _chunkViewerPool = + new DefaultObjectPool>>( + new DefaultPooledObjectPolicy>>(), 64); public override void Initialize() { @@ -203,10 +201,12 @@ namespace Content.Server.Decals if (!_adminManager.HasAdminFlag(session, AdminFlags.Spawn)) return; - if (!ev.Coordinates.IsValid(EntityManager)) + var coordinates = GetCoordinates(ev.Coordinates); + + if (!coordinates.IsValid(EntityManager)) return; - if (!TryAddDecal(ev.Decal, ev.Coordinates, out _)) + if (!TryAddDecal(ev.Decal, coordinates, out _)) return; if (eventArgs.SenderSession.AttachedEntity != null) @@ -230,10 +230,12 @@ namespace Content.Server.Decals if (!_adminManager.HasAdminFlag(session, AdminFlags.Spawn)) return; - if (!ev.Coordinates.IsValid(EntityManager)) + var coordinates = GetCoordinates(ev.Coordinates); + + if (!coordinates.IsValid(EntityManager)) return; - var gridId = ev.Coordinates.GetGridUid(EntityManager); + var gridId = coordinates.GetGridUid(EntityManager); if (gridId == null) return; @@ -256,8 +258,9 @@ namespace Content.Server.Decals } } - protected override void DirtyChunk(EntityUid id, Vector2i chunkIndices, DecalChunk chunk) + protected override void DirtyChunk(EntityUid uid, Vector2i chunkIndices, DecalChunk chunk) { + var id = GetNetEntity(uid); chunk.LastModified = _timing.CurTick; if(!_dirtyChunks.ContainsKey(id)) _dirtyChunks[id] = new HashSet(); @@ -409,8 +412,8 @@ namespace Content.Server.Decals foreach (var ent in _dirtyChunks.Keys) { - if (TryComp(ent, out DecalGridComponent? decals)) - Dirty(decals); + if (TryGetEntity(ent, out var uid) && TryComp(uid, out DecalGridComponent? decals)) + Dirty(uid.Value, decals); } if (!PvsEnabled) @@ -431,8 +434,7 @@ namespace Content.Server.Decals public void UpdatePlayer(IPlayerSession player) { - var xformQuery = GetEntityQuery(); - var chunksInRange = _chunking.GetChunksForSession(player, ChunkSize, xformQuery, _chunkIndexPool, _chunkViewerPool); + var chunksInRange = _chunking.GetChunksForSession(player, ChunkSize, _chunkIndexPool, _chunkViewerPool); var staleChunks = _chunkViewerPool.Get(); var previouslySent = _previousSentChunks[player]; @@ -440,16 +442,16 @@ namespace Content.Server.Decals // Then, remove them from previousSentChunks (for stuff like grids out of range) // and also mark them as stale for networking. - foreach (var (gridId, oldIndices) in previouslySent) + foreach (var (netGrid, oldIndices) in previouslySent) { // Mark the whole grid as stale and flag for removal. - if (!chunksInRange.TryGetValue(gridId, out var chunks)) + if (!chunksInRange.TryGetValue(netGrid, out var chunks)) { - previouslySent.Remove(gridId); + previouslySent.Remove(netGrid); // Was the grid deleted? - if (MapManager.IsGrid(gridId)) - staleChunks[gridId] = oldIndices; + if (!TryGetEntity(netGrid, out var gridId) || !MapManager.IsGrid(gridId.Value)) + staleChunks[netGrid] = oldIndices; else { // If grid was deleted then don't worry about telling the client to delete the chunk. @@ -465,7 +467,9 @@ namespace Content.Server.Decals // Get individual stale chunks. foreach (var chunk in oldIndices) { - if (chunks.Contains(chunk)) continue; + if (chunks.Contains(chunk)) + continue; + elmo.Add(chunk); } @@ -475,16 +479,16 @@ namespace Content.Server.Decals continue; } - staleChunks.Add(gridId, elmo); + staleChunks.Add(netGrid, elmo); } var updatedChunks = _chunkViewerPool.Get(); - foreach (var (gridId, gridChunks) in chunksInRange) + foreach (var (netGrid, gridChunks) in chunksInRange) { var newChunks = _chunkIndexPool.Get(); - _dirtyChunks.TryGetValue(gridId, out var dirtyChunks); + _dirtyChunks.TryGetValue(netGrid, out var dirtyChunks); - if (!previouslySent.TryGetValue(gridId, out var previousChunks)) + if (!previouslySent.TryGetValue(netGrid, out var previousChunks)) newChunks.UnionWith(gridChunks); else { @@ -498,19 +502,19 @@ namespace Content.Server.Decals _chunkIndexPool.Return(previousChunks); } - previouslySent[gridId] = gridChunks; + previouslySent[netGrid] = gridChunks; if (newChunks.Count == 0) _chunkIndexPool.Return(newChunks); else - updatedChunks[gridId] = newChunks; + updatedChunks[netGrid] = newChunks; } //send all gridChunks to client SendChunkUpdates(player, updatedChunks, staleChunks); } - private void ReturnToPool(Dictionary> chunks) + private void ReturnToPool(Dictionary> chunks) { foreach (var (_, previous) in chunks) { @@ -524,12 +528,14 @@ namespace Content.Server.Decals private void SendChunkUpdates( IPlayerSession session, - Dictionary> updatedChunks, - Dictionary> staleChunks) + Dictionary> updatedChunks, + Dictionary> staleChunks) { - var updatedDecals = new Dictionary>(); - foreach (var (gridId, chunks) in updatedChunks) + var updatedDecals = new Dictionary>(); + foreach (var (netGrid, chunks) in updatedChunks) { + var gridId = GetEntity(netGrid); + var collection = ChunkCollection(gridId); if (collection == null) continue; @@ -542,7 +548,7 @@ namespace Content.Server.Decals ? chunk : new()); } - updatedDecals[gridId] = gridChunks; + updatedDecals[netGrid] = gridChunks; } if (updatedDecals.Count != 0 || staleChunks.Count != 0) diff --git a/Content.Server/DeviceLinking/Systems/SignalTimerSystem.cs b/Content.Server/DeviceLinking/Systems/SignalTimerSystem.cs index c42e1e5a5a..3a7fd6bec9 100644 --- a/Content.Server/DeviceLinking/Systems/SignalTimerSystem.cs +++ b/Content.Server/DeviceLinking/Systems/SignalTimerSystem.cs @@ -40,7 +40,7 @@ public sealed class SignalTimerSystem : EntitySystem if (_ui.TryGetUi(uid, SignalTimerUiKey.Key, out var bui)) { - UserInterfaceSystem.SetUiState(bui, new SignalTimerBoundUserInterfaceState(component.Label, + _ui.SetUiState(bui, new SignalTimerBoundUserInterfaceState(component.Label, TimeSpan.FromSeconds(component.Delay).Minutes.ToString("D2"), TimeSpan.FromSeconds(component.Delay).Seconds.ToString("D2"), component.CanEditLabel, @@ -60,7 +60,7 @@ public sealed class SignalTimerSystem : EntitySystem if (_ui.TryGetUi(uid, SignalTimerUiKey.Key, out var bui)) { - UserInterfaceSystem.SetUiState(bui, new SignalTimerBoundUserInterfaceState(signalTimer.Label, + _ui.SetUiState(bui, new SignalTimerBoundUserInterfaceState(signalTimer.Label, TimeSpan.FromSeconds(signalTimer.Delay).Minutes.ToString("D2"), TimeSpan.FromSeconds(signalTimer.Delay).Seconds.ToString("D2"), signalTimer.CanEditLabel, diff --git a/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs b/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs index 9bbdc890a7..c250761687 100644 --- a/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs +++ b/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs @@ -473,7 +473,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem return; if (_uiSystem.OpenUi(bui, actor.PlayerSession)) - UserInterfaceSystem.SetUiState(bui, new DeviceListUserInterfaceState( + _uiSystem.SetUiState(bui, new DeviceListUserInterfaceState( _deviceListSystem.GetDeviceList(configurator.ActiveDeviceList.Value) .Select(v => (v.Key, MetaData(v.Value).EntityName)).ToHashSet() )); @@ -505,7 +505,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem } if (_uiSystem.TryGetUi(uid, NetworkConfiguratorUiKey.List, out var bui)) - UserInterfaceSystem.SetUiState(bui, new NetworkConfiguratorUserInterfaceState(devices)); + _uiSystem.SetUiState(bui, new NetworkConfiguratorUserInterfaceState(devices)); } /// diff --git a/Content.Server/Disposal/Mailing/MailingUnitSystem.cs b/Content.Server/Disposal/Mailing/MailingUnitSystem.cs index 4dea3d23e1..7993ccc07d 100644 --- a/Content.Server/Disposal/Mailing/MailingUnitSystem.cs +++ b/Content.Server/Disposal/Mailing/MailingUnitSystem.cs @@ -177,7 +177,7 @@ public sealed class MailingUnitSystem : EntitySystem var state = new MailingUnitBoundUserInterfaceState(component.DisposalUnitInterfaceState, component.Target, component.TargetList, component.Tag); if (_userInterfaceSystem.TryGetUi(uid, MailingUnitUiKey.Key, out var bui)) - UserInterfaceSystem.SetUiState(bui, state); + _userInterfaceSystem.SetUiState(bui, state); } private void OnTargetSelected(EntityUid uid, MailingUnitComponent component, TargetSelectedMessage args) diff --git a/Content.Server/Disposal/Tube/DisposalTubeSystem.cs b/Content.Server/Disposal/Tube/DisposalTubeSystem.cs index cf819dfd78..477a167fa2 100644 --- a/Content.Server/Disposal/Tube/DisposalTubeSystem.cs +++ b/Content.Server/Disposal/Tube/DisposalTubeSystem.cs @@ -325,8 +325,9 @@ namespace Content.Server.Disposal.Tube args.Cancel(); } - if (_uiSystem.TryGetUi(uid, SharedDisposalTaggerComponent.DisposalTaggerUiKey.Key, out var bui)) - UserInterfaceSystem.SetUiState(bui, new SharedDisposalTaggerComponent.DisposalTaggerUserInterfaceState(tagger.Tag)); + if (_uiSystem.TryGetUi(uid, DisposalTaggerUiKey.Key, out var bui)) + _uiSystem.SetUiState(bui, + new DisposalTaggerUserInterfaceState(tagger.Tag)); } /// @@ -335,11 +336,11 @@ namespace Content.Server.Disposal.Tube /// Returns a private void UpdateRouterUserInterface(EntityUid uid, DisposalRouterComponent router) { - var bui = _uiSystem.GetUiOrNull(uid, SharedDisposalTaggerComponent.DisposalTaggerUiKey.Key); + var bui = _uiSystem.GetUiOrNull(uid, DisposalTaggerUiKey.Key); if (router.Tags.Count <= 0) { if (bui is not null) - UserInterfaceSystem.SetUiState(bui, new SharedDisposalTaggerComponent.DisposalTaggerUserInterfaceState("")); + _uiSystem.SetUiState(bui, new DisposalTaggerUserInterfaceState("")); return; } @@ -354,7 +355,7 @@ namespace Content.Server.Disposal.Tube taglist.Remove(taglist.Length - 2, 2); if (bui is not null) - UserInterfaceSystem.SetUiState(bui, new SharedDisposalTaggerComponent.DisposalTaggerUserInterfaceState(taglist.ToString())); + _uiSystem.SetUiState(bui, new DisposalTaggerUserInterfaceState(taglist.ToString())); } private void OnAnchorChange(EntityUid uid, DisposalTubeComponent component, ref AnchorStateChangedEvent args) diff --git a/Content.Server/Disposal/TubeConnectionsCommand.cs b/Content.Server/Disposal/TubeConnectionsCommand.cs index 98f8a2bfe0..7895dcbca6 100644 --- a/Content.Server/Disposal/TubeConnectionsCommand.cs +++ b/Content.Server/Disposal/TubeConnectionsCommand.cs @@ -31,7 +31,7 @@ namespace Content.Server.Disposal return; } - if (!EntityUid.TryParse(args[0], out var id)) + if (!NetEntity.TryParse(args[0], out var idNet) || !_entities.TryGetEntity(idNet, out var id)) { shell.WriteLine(Loc.GetString("shell-invalid-entity-uid",("uid", args[0]))); return; @@ -51,7 +51,7 @@ namespace Content.Server.Disposal return; } - _entities.System().PopupDirections(id, tube, player.AttachedEntity.Value); + _entities.System().PopupDirections(id.Value, tube, player.AttachedEntity.Value); } } } diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs index 83e079746e..3edc2a5fa7 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs @@ -57,7 +57,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems if (!Resolve(uid, ref holder)) return false; - if (!holder.Container.CanInsert(toInsert)) + if (!_containerSystem.CanInsert(toInsert, holder.Container)) { return false; } diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs index e97215f646..41db7b1dd8 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs @@ -96,7 +96,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem component.NextFlush, component.Powered, component.Engaged, - component.RecentlyEjected); + GetNetEntityList(component.RecentlyEjected)); } private void OnUnpaused(EntityUid uid, SharedDisposalUnitComponent component, ref EntityUnpausedEvent args) @@ -499,7 +499,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem // Can't check if our target AND disposals moves currently so we'll just check target. // if you really want to check if disposals moves then add a predicate. - var doAfterArgs = new DoAfterArgs(userId.Value, delay, new DisposalDoAfterEvent(), unitId, target: toInsertId, used: unitId) + var doAfterArgs = new DoAfterArgs(EntityManager, userId.Value, delay, new DisposalDoAfterEvent(), unitId, target: toInsertId, used: unitId) { BreakOnDamage = true, BreakOnTargetMove = true, @@ -753,10 +753,10 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem public override bool CanInsert(EntityUid uid, SharedDisposalUnitComponent component, EntityUid entity) { - if (!base.CanInsert(uid, component, entity) || component is not SharedDisposalUnitComponent serverComp) + if (!base.CanInsert(uid, component, entity)) return false; - return serverComp.Container.CanInsert(entity); + return _containerSystem.CanInsert(entity, component.Container); } /// diff --git a/Content.Server/Effects/ColorFlashEffectSystem.cs b/Content.Server/Effects/ColorFlashEffectSystem.cs index b3cc66a441..2d29134657 100644 --- a/Content.Server/Effects/ColorFlashEffectSystem.cs +++ b/Content.Server/Effects/ColorFlashEffectSystem.cs @@ -7,6 +7,6 @@ public sealed class ColorFlashEffectSystem : SharedColorFlashEffectSystem { public override void RaiseEffect(Color color, List entities, Filter filter) { - RaiseNetworkEvent(new ColorFlashEffectEvent(color, entities), filter); + RaiseNetworkEvent(new ColorFlashEffectEvent(color, GetNetEntityList(entities)), filter); } } diff --git a/Content.Server/Electrocution/ElectrocuteCommand.cs b/Content.Server/Electrocution/ElectrocuteCommand.cs index af8b3e5a5e..75eb64c1bb 100644 --- a/Content.Server/Electrocution/ElectrocuteCommand.cs +++ b/Content.Server/Electrocution/ElectrocuteCommand.cs @@ -8,6 +8,8 @@ namespace Content.Server.Electrocution [AdminCommand(AdminFlags.Fun)] public sealed class ElectrocuteCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "electrocute"; public string Description => Loc.GetString("electrocute-command-description"); public string Help => $"{Command} "; @@ -24,15 +26,15 @@ namespace Content.Server.Electrocution return; } - var entityManager = IoCManager.Resolve(); - - if (!EntityUid.TryParse(args[0], out var uid) || !entityManager.EntityExists(uid)) + if (!NetEntity.TryParse(args[0], out var uidNet) || + !_entManager.TryGetEntity(uidNet, out var uid) || + !_entManager.EntityExists(uid)) { shell.WriteError($"Invalid entity specified!"); return; } - if (!entityManager.EntitySysManager.GetEntitySystem().CanApplyEffect(uid, ElectrocutionStatusEffect)) + if (!_entManager.EntitySysManager.GetEntitySystem().CanApplyEffect(uid.Value, ElectrocutionStatusEffect)) { shell.WriteError(Loc.GetString("electrocute-command-entity-cannot-be-electrocuted")); return; @@ -48,8 +50,8 @@ namespace Content.Server.Electrocution damage = 10; } - entityManager.EntitySysManager.GetEntitySystem() - .TryDoElectrocution(uid, null, damage, TimeSpan.FromSeconds(seconds), refresh: true, ignoreInsulation: true); + _entManager.EntitySysManager.GetEntitySystem() + .TryDoElectrocution(uid.Value, null, damage, TimeSpan.FromSeconds(seconds), refresh: true, ignoreInsulation: true); } } } diff --git a/Content.Server/Engineering/EntitySystems/DisassembleOnAltVerbSystem.cs b/Content.Server/Engineering/EntitySystems/DisassembleOnAltVerbSystem.cs index 91bf49b7ec..3085af0cdc 100644 --- a/Content.Server/Engineering/EntitySystems/DisassembleOnAltVerbSystem.cs +++ b/Content.Server/Engineering/EntitySystems/DisassembleOnAltVerbSystem.cs @@ -42,7 +42,7 @@ namespace Content.Server.Engineering.EntitySystems if (component.DoAfterTime > 0 && TryGet(out var doAfterSystem)) { - var doAfterArgs = new DoAfterArgs(user, component.DoAfterTime, new AwaitedDoAfterEvent(), null) + var doAfterArgs = new DoAfterArgs(EntityManager, user, component.DoAfterTime, new AwaitedDoAfterEvent(), null) { BreakOnUserMove = true, }; diff --git a/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs b/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs index 2367789b99..4893552c2c 100644 --- a/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs +++ b/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs @@ -45,7 +45,7 @@ namespace Content.Server.Engineering.EntitySystems if (component.DoAfterTime > 0) { - var doAfterArgs = new DoAfterArgs(args.User, component.DoAfterTime, new AwaitedDoAfterEvent(), null) + var doAfterArgs = new DoAfterArgs(EntityManager, args.User, component.DoAfterTime, new AwaitedDoAfterEvent(), null) { BreakOnUserMove = true, }; diff --git a/Content.Server/Ensnaring/EnsnareableSystem.Ensnaring.cs b/Content.Server/Ensnaring/EnsnareableSystem.Ensnaring.cs index 1359e1d550..bb1690c935 100644 --- a/Content.Server/Ensnaring/EnsnareableSystem.Ensnaring.cs +++ b/Content.Server/Ensnaring/EnsnareableSystem.Ensnaring.cs @@ -98,7 +98,7 @@ public sealed partial class EnsnareableSystem var freeTime = user == target ? component.BreakoutTime : component.FreeTime; var breakOnMove = !component.CanMoveBreakout; - var doAfterEventArgs = new DoAfterArgs(user, freeTime, new EnsnareableDoAfterEvent(), target, target: target, used: ensnare) + var doAfterEventArgs = new DoAfterArgs(EntityManager, user, freeTime, new EnsnareableDoAfterEvent(), target, target: target, used: ensnare) { BreakOnUserMove = breakOnMove, BreakOnTargetMove = breakOnMove, diff --git a/Content.Server/Examine/ExamineSystem.cs b/Content.Server/Examine/ExamineSystem.cs index d50f0cafdc..98aa806885 100644 --- a/Content.Server/Examine/ExamineSystem.cs +++ b/Content.Server/Examine/ExamineSystem.cs @@ -38,7 +38,7 @@ namespace Content.Server.Examine verbs = _verbSystem.GetLocalVerbs(target, player, typeof(ExamineVerb)); var ev = new ExamineSystemMessages.ExamineInfoResponseMessage( - target, 0, message, verbs?.ToList(), centerAtCursor + GetNetEntity(target), 0, message, verbs?.ToList(), centerAtCursor ); RaiseNetworkEvent(ev, session.ConnectedClient); @@ -49,29 +49,30 @@ namespace Content.Server.Examine var player = (IPlayerSession) eventArgs.SenderSession; var session = eventArgs.SenderSession; var channel = player.ConnectedClient; + var entity = GetEntity(request.NetEntity); if (session.AttachedEntity is not {Valid: true} playerEnt - || !EntityManager.EntityExists(request.EntityUid)) + || !EntityManager.EntityExists(entity)) { RaiseNetworkEvent(new ExamineSystemMessages.ExamineInfoResponseMessage( - request.EntityUid, request.Id, _entityNotFoundMessage), channel); + request.NetEntity, request.Id, _entityNotFoundMessage), channel); return; } - if (!CanExamine(playerEnt, request.EntityUid)) + if (!CanExamine(playerEnt, entity)) { RaiseNetworkEvent(new ExamineSystemMessages.ExamineInfoResponseMessage( - request.EntityUid, request.Id, _entityOutOfRangeMessage, knowTarget: false), channel); + request.NetEntity, request.Id, _entityOutOfRangeMessage, knowTarget: false), channel); return; } SortedSet? verbs = null; if (request.GetVerbs) - verbs = _verbSystem.GetLocalVerbs(request.EntityUid, playerEnt, typeof(ExamineVerb)); + verbs = _verbSystem.GetLocalVerbs(entity, playerEnt, typeof(ExamineVerb)); - var text = GetExamineText(request.EntityUid, player.AttachedEntity); + var text = GetExamineText(entity, player.AttachedEntity); RaiseNetworkEvent(new ExamineSystemMessages.ExamineInfoResponseMessage( - request.EntityUid, request.Id, text, verbs?.ToList()), channel); + request.NetEntity, request.Id, text, verbs?.ToList()), channel); } } } diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.TileFill.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.TileFill.cs index fc16c9daa4..65ca6e782c 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.TileFill.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.TileFill.cs @@ -331,12 +331,12 @@ public sealed partial class ExplosionSystem : EntitySystem var (area, iterationIntensity, spaceData, gridData, spaceMatrix) = results.Value; - Logger.Info($"Generated explosion preview with {area} tiles in {stopwatch.Elapsed.TotalMilliseconds}ms"); + Log.Info($"Generated explosion preview with {area} tiles in {stopwatch.Elapsed.TotalMilliseconds}ms"); - Dictionary>> tileLists = new(); + Dictionary>> tileLists = new(); foreach (var (grid, data) in gridData) { - tileLists.Add(grid, data.TileLists); + tileLists.Add(GetNetEntity(grid), data.TileLists); } return new ExplosionVisualsState( diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.Visuals.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.Visuals.cs index 5d3adff1c2..08374d7392 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.Visuals.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.Visuals.cs @@ -15,12 +15,18 @@ public sealed partial class ExplosionSystem : EntitySystem private void OnGetState(EntityUid uid, ExplosionVisualsComponent component, ref ComponentGetState args) { + Dictionary>> tileLists = new(); + foreach (var (grid, data) in component.Tiles) + { + tileLists.Add(GetNetEntity(grid), data); + } + args.State = new ExplosionVisualsState( component.Epicenter, component.ExplosionType, component.Intensity, component.SpaceTiles, - component.Tiles, + tileLists, component.SpaceMatrix, component.SpaceTileSize); } diff --git a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs index e5d8f69850..427edf21e3 100644 --- a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs +++ b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs @@ -236,7 +236,7 @@ namespace Content.Server.Explosion.EntitySystems if (user != null) { // Check if entity is bomb/mod. grenade/etc - if (_container.TryGetContainer(uid, "payload", out IContainer? container) && + if (_container.TryGetContainer(uid, "payload", out BaseContainer? container) && container.ContainedEntities.Count > 0 && TryComp(container.ContainedEntities[0], out ChemicalPayloadComponent? chemicalPayloadComponent)) { diff --git a/Content.Server/Fax/AdminUI/AdminFaxEui.cs b/Content.Server/Fax/AdminUI/AdminFaxEui.cs index 77b570bc0a..c8be6618e4 100644 --- a/Content.Server/Fax/AdminUI/AdminFaxEui.cs +++ b/Content.Server/Fax/AdminUI/AdminFaxEui.cs @@ -32,7 +32,7 @@ public sealed class AdminFaxEui : BaseEui var entries = new List(); while (faxes.MoveNext(out var uid, out var fax, out var device)) { - entries.Add(new AdminFaxEntry(uid, fax.FaxName, device.Address)); + entries.Add(new AdminFaxEntry(_entityManager.GetNetEntity(uid), fax.FaxName, device.Address)); } return new AdminFaxEuiState(entries); } @@ -49,14 +49,14 @@ public sealed class AdminFaxEui : BaseEui !_entityManager.HasComponent(Player.AttachedEntity.Value)) return; - _followerSystem.StartFollowingEntity(Player.AttachedEntity.Value, followData.TargetFax); + _followerSystem.StartFollowingEntity(Player.AttachedEntity.Value, _entityManager.GetEntity(followData.TargetFax)); break; } case AdminFaxEuiMsg.Send sendData: { var printout = new FaxPrintout(sendData.Content, sendData.Title, null, sendData.StampState, new() { new StampDisplayInfo { StampedName = sendData.From, StampedColor = sendData.StampColor } }); - _faxSystem.Receive(sendData.Target, printout); + _faxSystem.Receive(_entityManager.GetEntity(sendData.Target), printout); break; } } diff --git a/Content.Server/Fluids/EntitySystems/DrainSystem.cs b/Content.Server/Fluids/EntitySystems/DrainSystem.cs index 425e21153c..d067a64e13 100644 --- a/Content.Server/Fluids/EntitySystems/DrainSystem.cs +++ b/Content.Server/Fluids/EntitySystems/DrainSystem.cs @@ -228,7 +228,7 @@ public sealed class DrainSystem : SharedDrainSystem _audioSystem.PlayPvs(component.PlungerSound, uid); - var doAfterArgs = new DoAfterArgs(args.User, component.UnclogDuration, new DrainDoAfterEvent(),uid, args.Target, args.Used) + var doAfterArgs = new DoAfterArgs(EntityManager, args.User, component.UnclogDuration, new DrainDoAfterEvent(),uid, args.Target, args.Used) { BreakOnTargetMove = true, BreakOnUserMove = true, diff --git a/Content.Server/Fluids/EntitySystems/PuddleDebugDebugOverlaySystem.cs b/Content.Server/Fluids/EntitySystems/PuddleDebugDebugOverlaySystem.cs index b09d74c4d0..ec4fb3b399 100644 --- a/Content.Server/Fluids/EntitySystems/PuddleDebugDebugOverlaySystem.cs +++ b/Content.Server/Fluids/EntitySystems/PuddleDebugDebugOverlaySystem.cs @@ -79,7 +79,7 @@ public sealed class PuddleDebugDebugOverlaySystem : SharedPuddleDebugOverlaySyst data.Add(new PuddleDebugOverlayData(pos, vol)); } - RaiseNetworkEvent(new PuddleOverlayDebugMessage(gridUid, data.ToArray())); + RaiseNetworkEvent(new PuddleOverlayDebugMessage(GetNetEntity(gridUid), data.ToArray())); } } diff --git a/Content.Server/Fluids/EntitySystems/PuddleSystem.Spillable.cs b/Content.Server/Fluids/EntitySystems/PuddleSystem.Spillable.cs index 94283bd745..ff12aed729 100644 --- a/Content.Server/Fluids/EntitySystems/PuddleSystem.Spillable.cs +++ b/Content.Server/Fluids/EntitySystems/PuddleSystem.Spillable.cs @@ -181,7 +181,7 @@ public sealed partial class PuddleSystem { verb.Act = () => { - _doAfterSystem.TryStartDoAfter(new DoAfterArgs(args.User, component.SpillDelay ?? 0, new SpillDoAfterEvent(), uid, target: uid) + _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.SpillDelay ?? 0, new SpillDoAfterEvent(), uid, target: uid) { BreakOnTargetMove = true, BreakOnUserMove = true, diff --git a/Content.Server/Forensics/Systems/ForensicPadSystem.cs b/Content.Server/Forensics/Systems/ForensicPadSystem.cs index b82d5903e7..ad39817f8b 100644 --- a/Content.Server/Forensics/Systems/ForensicPadSystem.cs +++ b/Content.Server/Forensics/Systems/ForensicPadSystem.cs @@ -81,7 +81,7 @@ namespace Content.Server.Forensics { var ev = new ForensicPadDoAfterEvent(sample); - var doAfterEventArgs = new DoAfterArgs(user, pad.ScanDelay, ev, used, target: target, used: used) + var doAfterEventArgs = new DoAfterArgs(EntityManager, user, pad.ScanDelay, ev, used, target: target, used: used) { BreakOnTargetMove = true, BreakOnUserMove = true, diff --git a/Content.Server/Forensics/Systems/ForensicScannerSystem.cs b/Content.Server/Forensics/Systems/ForensicScannerSystem.cs index 247236217d..117717fca4 100644 --- a/Content.Server/Forensics/Systems/ForensicScannerSystem.cs +++ b/Content.Server/Forensics/Systems/ForensicScannerSystem.cs @@ -91,7 +91,7 @@ namespace Content.Server.Forensics /// private void StartScan(EntityUid uid, ForensicScannerComponent component, EntityUid user, EntityUid target) { - _doAfterSystem.TryStartDoAfter(new DoAfterArgs(user, component.ScanDelay, new ForensicScannerDoAfterEvent(), uid, target: target, used: uid) + _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, user, component.ScanDelay, new ForensicScannerDoAfterEvent(), uid, target: target, used: uid) { BreakOnTargetMove = true, BreakOnUserMove = true, @@ -107,7 +107,7 @@ namespace Content.Server.Forensics var verb = new UtilityVerb() { Act = () => StartScan(uid, component, args.User, args.Target), - IconEntity = uid, + IconEntity = GetNetEntity(uid), Text = Loc.GetString("forensic-scanner-verb-text"), Message = Loc.GetString("forensic-scanner-verb-message") }; diff --git a/Content.Server/GameTicking/Commands/JoinGameCommand.cs b/Content.Server/GameTicking/Commands/JoinGameCommand.cs index acb211d8bd..366e6c4e77 100644 --- a/Content.Server/GameTicking/Commands/JoinGameCommand.cs +++ b/Content.Server/GameTicking/Commands/JoinGameCommand.cs @@ -11,6 +11,7 @@ namespace Content.Server.GameTicking.Commands [AnyCommand] sealed class JoinGameCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; public string Command => "joingame"; @@ -36,9 +37,8 @@ namespace Content.Server.GameTicking.Commands return; } - var ticker = EntitySystem.Get(); - var stationSystem = EntitySystem.Get(); - var stationJobs = EntitySystem.Get(); + var ticker = _entManager.System(); + var stationJobs = _entManager.System(); if (ticker.PlayerGameStatuses.TryGetValue(player.UserId, out var status) && status == PlayerGameStatus.JoinedGame) { @@ -61,7 +61,7 @@ namespace Content.Server.GameTicking.Commands shell.WriteError(Loc.GetString("shell-argument-must-be-number")); } - var station = new EntityUid(sid); + var station = _entManager.GetEntity(new NetEntity(sid)); var jobPrototype = _prototypeManager.Index(id); if(stationJobs.TryGetJobSlot(station, jobPrototype, out var slots) == false || slots == 0) { diff --git a/Content.Server/GameTicking/GameTicker.GameRule.cs b/Content.Server/GameTicking/GameTicker.GameRule.cs index 31a37f85a3..82e2872914 100644 --- a/Content.Server/GameTicking/GameTicker.GameRule.cs +++ b/Content.Server/GameTicking/GameTicker.GameRule.cs @@ -247,10 +247,10 @@ public sealed partial class GameTicker foreach (var rule in args) { - if (!EntityUid.TryParse(rule, out var ruleEnt)) + if (!NetEntity.TryParse(rule, out var ruleEntNet) || !TryGetEntity(ruleEntNet, out var ruleEnt)) continue; - EndGameRule(ruleEnt); + EndGameRule(ruleEnt.Value); } } diff --git a/Content.Server/GameTicking/GameTicker.RoundFlow.cs b/Content.Server/GameTicking/GameTicker.RoundFlow.cs index 7643a28961..df2aafa901 100644 --- a/Content.Server/GameTicking/GameTicker.RoundFlow.cs +++ b/Content.Server/GameTicking/GameTicker.RoundFlow.cs @@ -373,7 +373,7 @@ namespace Content.Server.GameTicking PlayerOOCName = contentPlayerData?.Name ?? "(IMPOSSIBLE: REGISTERED MIND WITH NO OWNER)", // Character name takes precedence over current entity name PlayerICName = playerIcName, - PlayerEntityUid = entity, + PlayerNetEntity = GetNetEntity(entity), Role = antag ? roles.First(role => role.Antagonist).Name : roles.FirstOrDefault().Name ?? Loc.GetString("game-ticker-unknown-role"), diff --git a/Content.Server/Gateway/Systems/GatewaySystem.cs b/Content.Server/Gateway/Systems/GatewaySystem.cs index 3613f6734e..21cb58c3bd 100644 --- a/Content.Server/Gateway/Systems/GatewaySystem.cs +++ b/Content.Server/Gateway/Systems/GatewaySystem.cs @@ -66,18 +66,18 @@ public sealed class GatewaySystem : EntitySystem private void UpdateUserInterface(EntityUid uid, GatewayComponent comp) { - var destinations = new List<(EntityUid, String, TimeSpan, bool)>(); + var destinations = new List<(NetEntity, String, TimeSpan, bool)>(); foreach (var destUid in comp.Destinations) { var dest = Comp(destUid); if (!dest.Enabled) continue; - destinations.Add((destUid, dest.Name, dest.NextReady, HasComp(destUid))); + destinations.Add((GetNetEntity(destUid), dest.Name, dest.NextReady, HasComp(destUid))); } GetDestination(uid, out var current); - var state = new GatewayBoundUserInterfaceState(destinations, current, comp.NextClose, comp.LastOpen); + var state = new GatewayBoundUserInterfaceState(destinations, GetNetEntity(current), comp.NextClose, comp.LastOpen); _ui.TrySetUiState(uid, GatewayUiKey.Key, state); } @@ -89,15 +89,17 @@ public sealed class GatewaySystem : EntitySystem private void OnOpenPortal(EntityUid uid, GatewayComponent comp, GatewayOpenPortalMessage args) { // can't link if portal is already open on either side, the destination is invalid or on cooldown + var desto = GetEntity(args.Destination); + if (HasComp(uid) || - HasComp(args.Destination) || - !TryComp(args.Destination, out var dest) || + HasComp(desto) || + !TryComp(desto, out var dest) || !dest.Enabled || _timing.CurTime < dest.NextReady) return; // TODO: admin log??? - OpenPortal(uid, comp, args.Destination, dest); + OpenPortal(uid, comp, desto, dest); } private void OpenPortal(EntityUid uid, GatewayComponent comp, EntityUid dest, GatewayDestinationComponent destComp) diff --git a/Content.Server/Ghost/GhostSystem.cs b/Content.Server/Ghost/GhostSystem.cs index c7941fa7a5..0201de79ad 100644 --- a/Content.Server/Ghost/GhostSystem.cs +++ b/Content.Server/Ghost/GhostSystem.cs @@ -189,7 +189,7 @@ namespace Content.Server.Ghost if (args.SenderSession.AttachedEntity is not {Valid: true} entity || !EntityManager.HasComponent(entity)) { - Logger.Warning($"User {args.SenderSession.Name} sent a {nameof(GhostWarpsRequestEvent)} without being a ghost."); + Log.Warning($"User {args.SenderSession.Name} sent a {nameof(GhostWarpsRequestEvent)} without being a ghost."); return; } @@ -204,7 +204,7 @@ namespace Content.Server.Ghost !ghost.CanReturnToBody || !EntityManager.TryGetComponent(attached, out ActorComponent? actor)) { - Logger.Warning($"User {args.SenderSession.Name} sent an invalid {nameof(GhostReturnToBodyRequest)}"); + Log.Warning($"User {args.SenderSession.Name} sent an invalid {nameof(GhostReturnToBodyRequest)}"); return; } @@ -216,25 +216,27 @@ namespace Content.Server.Ghost if (args.SenderSession.AttachedEntity is not {Valid: true} attached || !EntityManager.TryGetComponent(attached, out GhostComponent? ghost)) { - Logger.Warning($"User {args.SenderSession.Name} tried to warp to {msg.Target} without being a ghost."); + Log.Warning($"User {args.SenderSession.Name} tried to warp to {msg.Target} without being a ghost."); return; } - if (!EntityManager.EntityExists(msg.Target)) + var target = GetEntity(msg.Target); + + if (!EntityManager.EntityExists(target)) { - Logger.Warning($"User {args.SenderSession.Name} tried to warp to an invalid entity id: {msg.Target}"); + Log.Warning($"User {args.SenderSession.Name} tried to warp to an invalid entity id: {msg.Target}"); return; } - if (TryComp(msg.Target, out WarpPointComponent? warp) && warp.Follow - || HasComp(msg.Target)) + if (TryComp(target, out WarpPointComponent? warp) && warp.Follow + || HasComp(target)) { - _followerSystem.StartFollowingEntity(ghost.Owner, msg.Target); + _followerSystem.StartFollowingEntity(attached, target); return; } - var xform = Transform(ghost.Owner); - xform.Coordinates = Transform(msg.Target).Coordinates; + var xform = Transform(attached); + xform.Coordinates = Transform(target).Coordinates; xform.AttachToGridOrMap(); if (TryComp(attached, out PhysicsComponent? physics)) _physics.SetLinearVelocity(attached, Vector2.Zero, body: physics); @@ -250,11 +252,13 @@ namespace Content.Server.Ghost private IEnumerable GetLocationWarps() { - foreach (var warp in EntityManager.EntityQuery(true)) + var allQuery = AllEntityQuery(); + + while (allQuery.MoveNext(out var uid, out var warp)) { if (warp.Location != null) { - yield return new GhostWarp(warp.Owner, warp.Location, true); + yield return new GhostWarp(GetNetEntity(uid), warp.Location, true); } } } @@ -273,7 +277,7 @@ namespace Content.Server.Ghost var playerInfo = $"{EntityManager.GetComponent(attached).EntityName} ({jobName})"; if (_mobState.IsAlive(attached) || _mobState.IsCritical(attached)) - yield return new GhostWarp(attached, playerInfo, false); + yield return new GhostWarp(GetNetEntity(attached), playerInfo, false); } } } diff --git a/Content.Server/Ghost/Roles/MakeGhostRoleCommand.cs b/Content.Server/Ghost/Roles/MakeGhostRoleCommand.cs index b26738d976..45c577de22 100644 --- a/Content.Server/Ghost/Roles/MakeGhostRoleCommand.cs +++ b/Content.Server/Ghost/Roles/MakeGhostRoleCommand.cs @@ -9,6 +9,8 @@ namespace Content.Server.Ghost.Roles [AdminCommand(AdminFlags.Admin)] public sealed class MakeGhostRoleCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "makeghostrole"; public string Description => "Turns an entity into a ghost role."; public string Help => $"Usage: {Command} []"; @@ -21,21 +23,19 @@ namespace Content.Server.Ghost.Roles return; } - var entityManager = IoCManager.Resolve(); - - if (!EntityUid.TryParse(args[0], out var uid)) + if (!NetEntity.TryParse(args[0], out var uidNet) || !_entManager.TryGetEntity(uidNet, out var uid)) { shell.WriteLine($"{args[0]} is not a valid entity uid."); return; } - if (!entityManager.TryGetComponent(uid, out MetaDataComponent? metaData)) + if (!_entManager.TryGetComponent(uid, out MetaDataComponent? metaData)) { shell.WriteLine($"No entity found with uid {uid}"); return; } - if (entityManager.TryGetComponent(uid, out MindContainerComponent? mind) && + if (_entManager.TryGetComponent(uid, out MindContainerComponent? mind) && mind.HasMind) { shell.WriteLine($"Entity {metaData.EntityName} with id {uid} already has a mind."); @@ -46,20 +46,20 @@ namespace Content.Server.Ghost.Roles var description = args[2]; var rules = args.Length >= 4 ? args[3] : Loc.GetString("ghost-role-component-default-rules"); - if (entityManager.TryGetComponent(uid, out GhostRoleComponent? ghostRole)) + if (_entManager.TryGetComponent(uid, out GhostRoleComponent? ghostRole)) { shell.WriteLine($"Entity {metaData.EntityName} with id {uid} already has a {nameof(GhostRoleComponent)}"); return; } - if (entityManager.TryGetComponent(uid, out GhostTakeoverAvailableComponent? takeOver)) + if (_entManager.HasComponent(uid)) { shell.WriteLine($"Entity {metaData.EntityName} with id {uid} already has a {nameof(GhostTakeoverAvailableComponent)}"); return; } - ghostRole = entityManager.AddComponent(uid); - entityManager.AddComponent(uid); + ghostRole = _entManager.AddComponent(uid.Value); + _entManager.AddComponent(uid.Value); ghostRole.RoleName = name; ghostRole.RoleDescription = description; ghostRole.RoleRules = rules; diff --git a/Content.Server/Ghost/Roles/UI/MakeGhostRoleEui.cs b/Content.Server/Ghost/Roles/UI/MakeGhostRoleEui.cs index c2f46f7c79..ff1967f966 100644 --- a/Content.Server/Ghost/Roles/UI/MakeGhostRoleEui.cs +++ b/Content.Server/Ghost/Roles/UI/MakeGhostRoleEui.cs @@ -6,6 +6,8 @@ namespace Content.Server.Ghost.Roles.UI { public sealed class MakeGhostRoleEui : BaseEui { + [Dependency] private readonly IEntityManager _entManager = default!; + public MakeGhostRoleEui(EntityUid entityUid) { EntityUid = entityUid; @@ -15,14 +17,14 @@ namespace Content.Server.Ghost.Roles.UI public override EuiStateBase GetNewState() { - return new MakeGhostRoleEuiState(EntityUid); + return new MakeGhostRoleEuiState(_entManager.GetNetEntity(EntityUid)); } public override void Closed() { base.Closed(); - EntitySystem.Get().CloseMakeGhostRoleEui(Player); + _entManager.System().CloseMakeGhostRoleEui(Player); } } } diff --git a/Content.Server/Guardian/GuardianSystem.cs b/Content.Server/Guardian/GuardianSystem.cs index 0cfcbe032e..4283869a25 100644 --- a/Content.Server/Guardian/GuardianSystem.cs +++ b/Content.Server/Guardian/GuardianSystem.cs @@ -167,7 +167,7 @@ namespace Content.Server.Guardian return; } - _doAfterSystem.TryStartDoAfter(new DoAfterArgs(user, component.InjectionDelay, new GuardianCreatorDoAfterEvent(), injector, target: target, used: injector) + _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, user, component.InjectionDelay, new GuardianCreatorDoAfterEvent(), injector, target: target, used: injector) { BreakOnTargetMove = true, BreakOnUserMove = true diff --git a/Content.Server/Hands/Systems/HandsSystem.cs b/Content.Server/Hands/Systems/HandsSystem.cs index 9a72d31207..b746eea6ec 100644 --- a/Content.Server/Hands/Systems/HandsSystem.cs +++ b/Content.Server/Hands/Systems/HandsSystem.cs @@ -105,7 +105,7 @@ namespace Content.Server.Hands.Systems if (exclude != null) filter = filter.RemoveWhereAttachedEntity(entity => entity == exclude); - RaiseNetworkEvent(new PickupAnimationEvent(item, initialPosition, finalPosition, initialAngle), filter); + RaiseNetworkEvent(new PickupAnimationEvent(GetNetEntity(item), GetNetCoordinates(initialPosition), finalPosition, initialAngle), filter); } protected override void HandleEntityRemoved(EntityUid uid, HandsComponent hands, EntRemovedFromContainerMessage args) @@ -178,7 +178,7 @@ namespace Content.Server.Hands.Systems #endregion #region interactions - private bool HandleThrowItem(ICommonSession? session, EntityCoordinates coords, EntityUid uid) + private bool HandleThrowItem(ICommonSession? session, EntityCoordinates coordinates, EntityUid entity) { if (session is not IPlayerSession playerSession) return false; @@ -201,7 +201,7 @@ namespace Content.Server.Hands.Systems throwEnt = splitStack.Value; } - var direction = coords.ToMapPos(EntityManager) - Transform(player).WorldPosition; + var direction = coordinates.ToMapPos(EntityManager) - Transform(player).WorldPosition; if (direction == Vector2.Zero) return true; diff --git a/Content.Server/Implants/ImplanterSystem.cs b/Content.Server/Implants/ImplanterSystem.cs index 1ebf3a1d5e..db5602a2bb 100644 --- a/Content.Server/Implants/ImplanterSystem.cs +++ b/Content.Server/Implants/ImplanterSystem.cs @@ -69,7 +69,7 @@ public sealed partial class ImplanterSystem : SharedImplanterSystem /// The implanter being used public void TryImplant(ImplanterComponent component, EntityUid user, EntityUid target, EntityUid implanter) { - var args = new DoAfterArgs(user, component.ImplantTime, new ImplantEvent(), implanter, target: target, used: implanter) + var args = new DoAfterArgs(EntityManager, user, component.ImplantTime, new ImplantEvent(), implanter, target: target, used: implanter) { BreakOnUserMove = true, BreakOnTargetMove = true, @@ -96,7 +96,7 @@ public sealed partial class ImplanterSystem : SharedImplanterSystem //TODO: Remove when surgery is in public void TryDraw(ImplanterComponent component, EntityUid user, EntityUid target, EntityUid implanter) { - var args = new DoAfterArgs(user, component.DrawTime, new DrawEvent(), implanter, target: target, used: implanter) + var args = new DoAfterArgs(EntityManager, user, component.DrawTime, new DrawEvent(), implanter, target: target, used: implanter) { BreakOnUserMove = true, BreakOnTargetMove = true, diff --git a/Content.Server/Instruments/InstrumentSystem.cs b/Content.Server/Instruments/InstrumentSystem.cs index f1415ba388..7094706950 100644 --- a/Content.Server/Instruments/InstrumentSystem.cs +++ b/Content.Server/Instruments/InstrumentSystem.cs @@ -61,13 +61,13 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem [AdminCommand(AdminFlags.Fun)] private void AddToBandCommand(IConsoleShell shell, string _, string[] args) { - if (!EntityUid.TryParse(args[0], out var firstUid)) + if (!NetEntity.TryParse(args[0], out var firstUidNet) || !TryGetEntity(firstUidNet, out var firstUid)) { shell.WriteError($"Cannot parse first Uid"); return; } - if (!EntityUid.TryParse(args[1], out var secondUid)) + if (!NetEntity.TryParse(args[1], out var secondUidNet) || !TryGetEntity(secondUidNet, out var secondUid)) { shell.WriteError($"Cannot parse second Uid"); return; @@ -79,15 +79,15 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem return; } - var otherInstrument = Comp(secondUid); + var otherInstrument = Comp(secondUid.Value); otherInstrument.Playing = true; otherInstrument.Master = firstUid; - Dirty(secondUid, otherInstrument); + Dirty(secondUid.Value, otherInstrument); } private void OnMidiStart(InstrumentStartMidiEvent msg, EntitySessionEventArgs args) { - var uid = msg.Uid; + var uid = GetEntity(msg.Uid); if (!TryComp(uid, out InstrumentComponent? instrument)) return; @@ -101,7 +101,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem private void OnMidiStop(InstrumentStopMidiEvent msg, EntitySessionEventArgs args) { - var uid = msg.Uid; + var uid = GetEntity(msg.Uid); if (!TryComp(uid, out InstrumentComponent? instrument)) return; @@ -114,8 +114,8 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem private void OnMidiSetMaster(InstrumentSetMasterEvent msg, EntitySessionEventArgs args) { - var uid = msg.Uid; - var master = msg.Master; + var uid = GetEntity(msg.Uid); + var master = GetEntity(msg.Master); if (!HasComp(uid)) return; @@ -150,7 +150,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem private void OnMidiSetFilteredChannel(InstrumentSetFilteredChannelEvent msg, EntitySessionEventArgs args) { - var uid = msg.Uid; + var uid = GetEntity(msg.Uid); if (!TryComp(uid, out InstrumentComponent? instrument)) return; @@ -166,7 +166,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem if (msg.Value) { // Prevent stuck notes when turning off a channel... Shrimple. - RaiseNetworkEvent(new InstrumentMidiEventEvent(uid, new []{RobustMidiEvent.AllNotesOff((byte)msg.Channel, 0)})); + RaiseNetworkEvent(new InstrumentMidiEventEvent(msg.Uid, new []{RobustMidiEvent.AllNotesOff((byte)msg.Channel, 0)})); } Dirty(uid, instrument); @@ -215,19 +215,19 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem _bandRequestQueue.Add(args); } - public (EntityUid, string)[] GetBands(EntityUid uid) + public (NetEntity, string)[] GetBands(EntityUid uid) { var metadataQuery = EntityManager.GetEntityQuery(); if (Deleted(uid, metadataQuery)) - return Array.Empty<(EntityUid, string)>(); + return Array.Empty<(NetEntity, string)>(); - var list = new ValueList<(EntityUid, string)>(); + var list = new ValueList<(NetEntity, string)>(); var instrumentQuery = EntityManager.GetEntityQuery(); if (!TryComp(uid, out InstrumentComponent? originInstrument) || originInstrument.InstrumentPlayer?.AttachedEntity is not {} originPlayer) - return Array.Empty<(EntityUid, string)>(); + return Array.Empty<(NetEntity, string)>(); // It's probably faster to get all possible active instruments than all entities in range var activeEnumerator = EntityManager.EntityQueryEnumerator(); @@ -254,7 +254,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem || !metadataQuery.TryGetComponent(entity, out var metadata)) continue; - list.Add((entity, $"{playerMetadata.EntityName} - {metadata.EntityName}")); + list.Add((GetNetEntity(entity), $"{playerMetadata.EntityName} - {metadata.EntityName}")); } return list.ToArray(); @@ -267,10 +267,12 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem if (instrument.Playing) { - // Reset puppet instruments too. - RaiseNetworkEvent(new InstrumentMidiEventEvent(uid, new[]{RobustMidiEvent.SystemReset(0)})); + var netUid = GetNetEntity(uid); - RaiseNetworkEvent(new InstrumentStopMidiEvent(uid)); + // Reset puppet instruments too. + RaiseNetworkEvent(new InstrumentMidiEventEvent(netUid, new[]{RobustMidiEvent.SystemReset(0)})); + + RaiseNetworkEvent(new InstrumentStopMidiEvent(netUid)); } instrument.Playing = false; @@ -284,7 +286,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem private void OnMidiEventRx(InstrumentMidiEventEvent msg, EntitySessionEventArgs args) { - var uid = msg.Uid; + var uid = GetEntity(msg.Uid); if (!TryComp(uid, out InstrumentComponent? instrument)) return; @@ -292,8 +294,10 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem if (!instrument.Playing || args.SenderSession != instrument.InstrumentPlayer || instrument.InstrumentPlayer == null - || args.SenderSession.AttachedEntity is not {} attached) + || args.SenderSession.AttachedEntity is not { } attached) + { return; + } var send = true; @@ -361,8 +365,10 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem foreach (var request in _bandRequestQueue) { - var nearby = GetBands(request.Entity); - _bui.TrySendUiMessage(request.Entity, request.UiKey, new InstrumentBandResponseBuiMessage(nearby), + var entity = GetEntity(request.Entity); + + var nearby = GetBands(entity); + _bui.TrySendUiMessage(entity, request.UiKey, new InstrumentBandResponseBuiMessage(nearby), (IPlayerSession)request.Session); } diff --git a/Content.Server/Interaction/InteractionSystem.cs b/Content.Server/Interaction/InteractionSystem.cs index f887e565a9..30eeb6e946 100644 --- a/Content.Server/Interaction/InteractionSystem.cs +++ b/Content.Server/Interaction/InteractionSystem.cs @@ -63,34 +63,37 @@ namespace Content.Server.Interaction private void HandleDragDropRequestEvent(DragDropRequestEvent msg, EntitySessionEventArgs args) { - if (Deleted(msg.Dragged) || Deleted(msg.Target)) + var dragged = GetEntity(msg.Dragged); + var target = GetEntity(msg.Target); + + if (Deleted(dragged) || Deleted(target)) return; var user = args.SenderSession.AttachedEntity; - if (user == null || !_actionBlockerSystem.CanInteract(user.Value, msg.Target)) + if (user == null || !_actionBlockerSystem.CanInteract(user.Value, target)) return; // must be in range of both the target and the object they are drag / dropping // Client also does this check but ya know we gotta validate it. - if (!InRangeUnobstructed(user.Value, msg.Dragged, popup: true) - || !InRangeUnobstructed(user.Value, msg.Target, popup: true)) + if (!InRangeUnobstructed(user.Value, dragged, popup: true) + || !InRangeUnobstructed(user.Value, target, popup: true)) { return; } - var dragArgs = new DragDropDraggedEvent(user.Value, msg.Target); + var dragArgs = new DragDropDraggedEvent(user.Value, target); // trigger dragdrops on the dropped entity - RaiseLocalEvent(msg.Dragged, ref dragArgs); + RaiseLocalEvent(dragged, ref dragArgs); if (dragArgs.Handled) return; - var dropArgs = new DragDropTargetEvent(user.Value, msg.Dragged); + var dropArgs = new DragDropTargetEvent(user.Value, dragged); // trigger dragdrops on the target entity (what you are dropping onto) - RaiseLocalEvent(msg.Target, ref dropArgs); + RaiseLocalEvent(GetEntity(msg.Target), ref dropArgs); } #endregion diff --git a/Content.Server/Kitchen/EntitySystems/KitchenSpikeSystem.cs b/Content.Server/Kitchen/EntitySystems/KitchenSpikeSystem.cs index 65342ca3e1..04a224a3a7 100644 --- a/Content.Server/Kitchen/EntitySystems/KitchenSpikeSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/KitchenSpikeSystem.cs @@ -252,7 +252,7 @@ namespace Content.Server.Kitchen.EntitySystems butcherable.BeingButchered = true; component.InUse = true; - var doAfterArgs = new DoAfterArgs(userUid, component.SpikeDelay + butcherable.ButcherDelay, new SpikeDoAfterEvent(), uid, target: victimUid, used: uid) + var doAfterArgs = new DoAfterArgs(EntityManager, userUid, component.SpikeDelay + butcherable.ButcherDelay, new SpikeDoAfterEvent(), uid, target: victimUid, used: uid) { BreakOnTargetMove = true, BreakOnUserMove = true, diff --git a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs index cee2e6ce49..878a14ef73 100644 --- a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs @@ -288,8 +288,8 @@ namespace Content.Server.Kitchen.EntitySystems if (ui == null) return; - UserInterfaceSystem.SetUiState(ui, new MicrowaveUpdateUserInterfaceState( - component.Storage.ContainedEntities.ToArray(), + _userInterface.SetUiState(ui, new MicrowaveUpdateUserInterfaceState( + GetNetEntityArray(component.Storage.ContainedEntities.ToArray()), HasComp(uid), component.CurrentCookTimeButtonIndex, component.CurrentCookTimerTime @@ -482,7 +482,7 @@ namespace Content.Server.Kitchen.EntitySystems if (!HasContents(component) || HasComp(uid)) return; - component.Storage.Remove(args.EntityID); + component.Storage.Remove(EntityManager.GetEntity(args.EntityID)); UpdateUserInterfaceState(uid, component); } diff --git a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs index 4198e6d703..68d9577dd6 100644 --- a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs @@ -206,7 +206,7 @@ namespace Content.Server.Kitchen.EntitySystems this.IsPowered(uid, EntityManager), canJuice, canGrind, - inputContainer.ContainedEntities.Select(item => item).ToArray(), + GetNetEntityArray(inputContainer.ContainedEntities.ToArray()), containerSolution?.Contents.ToArray() ); _userInterfaceSystem.TrySetUiState(uid, ReagentGrinderUiKey.Key, state); @@ -242,10 +242,11 @@ namespace Content.Server.Kitchen.EntitySystems return; var inputContainer = _containerSystem.EnsureContainer(uid, SharedReagentGrinder.InputContainerId); + var ent = GetEntity(message.EntityId); - if (inputContainer.Remove(message.EntityId)) + if (inputContainer.Remove(ent)) { - message.EntityId.RandomOffset(0.4f); + ent.RandomOffset(0.4f); ClickSound(uid, reagentGrinder); UpdateUiState(uid); } diff --git a/Content.Server/Kitchen/EntitySystems/SharpSystem.cs b/Content.Server/Kitchen/EntitySystems/SharpSystem.cs index 4ebc6fe74d..f270fe76d2 100644 --- a/Content.Server/Kitchen/EntitySystems/SharpSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/SharpSystem.cs @@ -66,7 +66,7 @@ public sealed class SharpSystem : EntitySystem return; var doAfter = - new DoAfterArgs(user, sharp.ButcherDelayModifier * butcher.ButcherDelay, new SharpDoAfterEvent(), knife, target: target, used: knife) + new DoAfterArgs(EntityManager, user, sharp.ButcherDelayModifier * butcher.ButcherDelay, new SharpDoAfterEvent(), knife, target: target, used: knife) { BreakOnTargetMove = true, BreakOnUserMove = true, diff --git a/Content.Server/Lathe/LatheSystem.cs b/Content.Server/Lathe/LatheSystem.cs index 808292416c..9761ae5765 100644 --- a/Content.Server/Lathe/LatheSystem.cs +++ b/Content.Server/Lathe/LatheSystem.cs @@ -224,7 +224,7 @@ namespace Content.Server.Lathe var producing = component.CurrentRecipe ?? component.Queue.FirstOrDefault(); var state = new LatheUpdateState(GetAvailableRecipes(uid, component), component.Queue, producing); - UserInterfaceSystem.SetUiState(ui, state); + _uiSys.SetUiState(ui, state); } private void OnGetRecipes(EntityUid uid, TechnologyDatabaseComponent component, LatheGetRecipesEvent args) diff --git a/Content.Server/Light/EntitySystems/PoweredLightSystem.cs b/Content.Server/Light/EntitySystems/PoweredLightSystem.cs index 144190cf8e..b84a2688e5 100644 --- a/Content.Server/Light/EntitySystems/PoweredLightSystem.cs +++ b/Content.Server/Light/EntitySystems/PoweredLightSystem.cs @@ -138,7 +138,7 @@ namespace Content.Server.Light.EntitySystems } // removing a working bulb, so require a delay - _doAfterSystem.TryStartDoAfter(new DoAfterArgs(userUid, light.EjectBulbDelay, new PoweredLightDoAfterEvent(), uid, target: uid) + _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, userUid, light.EjectBulbDelay, new PoweredLightDoAfterEvent(), uid, target: uid) { BreakOnUserMove = true, BreakOnDamage = true, diff --git a/Content.Server/Magic/MagicSystem.cs b/Content.Server/Magic/MagicSystem.cs index 1632b654b9..c4ed74604d 100644 --- a/Content.Server/Magic/MagicSystem.cs +++ b/Content.Server/Magic/MagicSystem.cs @@ -96,7 +96,7 @@ public sealed class MagicSystem : EntitySystem private void AttemptLearn(EntityUid uid, SpellbookComponent component, UseInHandEvent args) { - var doAfterEventArgs = new DoAfterArgs(args.User, component.LearnTime, new SpellbookDoAfterEvent(), uid, target: uid) + var doAfterEventArgs = new DoAfterArgs(EntityManager, args.User, component.LearnTime, new SpellbookDoAfterEvent(), uid, target: uid) { BreakOnTargetMove = true, BreakOnUserMove = true, diff --git a/Content.Server/Maps/GridDraggingSystem.cs b/Content.Server/Maps/GridDraggingSystem.cs index eef3e56849..90770af1ad 100644 --- a/Content.Server/Maps/GridDraggingSystem.cs +++ b/Content.Server/Maps/GridDraggingSystem.cs @@ -50,24 +50,34 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem private void OnRequestVelocity(GridDragVelocityRequest ev, EntitySessionEventArgs args) { + var grid = GetEntity(ev.Grid); + if (args.SenderSession is not IPlayerSession playerSession || !_admin.CanCommand(playerSession, CommandName) || - !Exists(ev.Grid) || - Deleted(ev.Grid)) return; + !Exists(grid) || + Deleted(grid)) + { + return; + } - var gridBody = Comp(ev.Grid); - _physics.SetLinearVelocity(ev.Grid, ev.LinearVelocity, body: gridBody); - _physics.SetAngularVelocity(ev.Grid, 0f, body: gridBody); + var gridBody = Comp(grid); + _physics.SetLinearVelocity(grid, ev.LinearVelocity, body: gridBody); + _physics.SetAngularVelocity(grid, 0f, body: gridBody); } private void OnRequestDrag(GridDragRequestPosition msg, EntitySessionEventArgs args) { + var grid = GetEntity(msg.Grid); + if (args.SenderSession is not IPlayerSession playerSession || !_admin.CanCommand(playerSession, CommandName) || - !Exists(msg.Grid) || - Deleted(msg.Grid)) return; + !Exists(grid) || + Deleted(grid)) + { + return; + } - var gridXform = Transform(msg.Grid); + var gridXform = Transform(grid); gridXform.WorldPosition = msg.WorldPosition; } diff --git a/Content.Server/MassMedia/Systems/NewsSystem.cs b/Content.Server/MassMedia/Systems/NewsSystem.cs index 43d6545100..f5b17fefb8 100644 --- a/Content.Server/MassMedia/Systems/NewsSystem.cs +++ b/Content.Server/MassMedia/Systems/NewsSystem.cs @@ -13,9 +13,13 @@ using Content.Server.CartridgeLoader.Cartridges; using Content.Shared.CartridgeLoader; using Content.Shared.CartridgeLoader.Cartridges; using Content.Server.CartridgeLoader; +using Content.Server.GameTicking; using Robust.Shared.Timing; using Content.Server.Popups; +using Content.Server.StationRecords.Systems; using Content.Shared.Database; +using Robust.Shared.Containers; +using Robust.Shared.Utility; namespace Content.Server.MassMedia.Systems; @@ -24,14 +28,15 @@ public sealed class NewsSystem : EntitySystem [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly UserInterfaceSystem _ui = default!; [Dependency] private readonly RingerSystem _ringer = default!; - [Dependency] private readonly CartridgeLoaderSystem? _cartridgeLoaderSystem = default!; + [Dependency] private readonly CartridgeLoaderSystem _cartridgeLoaderSystem = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly PopupSystem _popup = default!; [Dependency] private readonly IAdminLogManager _adminLogger = default!; - + [Dependency] private readonly GameTicker _ticker = default!; [Dependency] private readonly AccessReaderSystem _accessReader = default!; + [Dependency] private readonly StationRecordsSystem _stationRecords = default!; - + // TODO remove this. Dont store data on systems private readonly List _articles = new List(); public override void Initialize() @@ -103,45 +108,51 @@ public sealed class NewsSystem : EntitySystem if (message.Action == NewsReadUiAction.NotificationSwith) component.NotificationOn = !component.NotificationOn; - UpdateReadUi(uid, args.LoaderUid, component); + UpdateReadUi(uid, GetEntity(args.LoaderUid), component); } public void OnWriteUiShareMessage(EntityUid uid, NewsWriteComponent component, NewsWriteShareMessage msg) { - var article = msg.Article; + // dont blindly trust input from clients. + if (msg.Session.AttachedEntity is not {} author) + return; - var author = msg.Session.AttachedEntity; - if (author.HasValue - && _accessReader.FindAccessItemsInventory(author.Value, out var items) - && _accessReader.FindStationRecordKeys(author.Value, out var stationRecordKeys, items)) + if (!_accessReader.FindAccessItemsInventory(author, out var items)) + return; + + if (!_accessReader.FindStationRecordKeys(author, out var stationRecordKeys, items)) + return; + + string? authorName = null; + foreach (var item in items) { - article.AuthorStationRecordKeyIds = stationRecordKeys; - - foreach (var item in items) + // ID Card + if (TryComp(item, out IdCardComponent? id)) { - // ID Card - if (TryComp(item, out IdCardComponent? id)) - { - article.Author = id.FullName; - break; - } - // PDA - else if (TryComp(item, out PdaComponent? pda) - && pda.ContainedId != null - && TryComp(pda.ContainedId, out id)) - { - article.Author = id.FullName; - break; - } + authorName = id.FullName; + break; + } + + if (TryComp(item, out PdaComponent? pda) + && pda.ContainedId != null + && TryComp(pda.ContainedId, out id)) + { + authorName = id.FullName; + break; } } - _audio.PlayPvs(component.ConfirmSound, uid); + NewsArticle article = new NewsArticle + { + Author = authorName, + Name = (msg.Name.Length <= 25 ? msg.Name.Trim() : $"{msg.Name.Trim().Substring(0, 25)}..."), + Content = msg.Content, + ShareTime = _ticker.RoundDuration() - if (author != null) - _adminLogger.Add(LogType.Chat, LogImpact.Medium, $"{ToPrettyString(author.Value):actor} created news article {article.Name} by {article.Author}: {article.Content}"); - else - _adminLogger.Add(LogType.Chat, LogImpact.Medium, $"{msg.Session.Name:actor} created news article {article.Name}: {article.Content}"); + }; + + _audio.PlayPvs(component.ConfirmSound, uid); + _adminLogger.Add(LogType.Chat, LogImpact.Medium, $"{ToPrettyString(author):actor} created news article {article.Name} by {article.Author}: {article.Content}"); _articles.Add(article); component.ShareAvalible = false; @@ -192,18 +203,15 @@ public sealed class NewsSystem : EntitySystem private void TryNotify() { - var query = EntityQueryEnumerator(); + var query = EntityQueryEnumerator(); - while (query.MoveNext(out var owner, out var comp, out var ringer)) + while (query.MoveNext(out var uid, out var comp, out var ringer, out var cont)) { - foreach (var app in comp.InstalledPrograms) - { - if (EntityManager.TryGetComponent(app, out var cartridge) && cartridge.NotificationOn) - { - _ringer.RingerPlayRingtone(owner, ringer); - break; - } - } + if (!_cartridgeLoaderSystem.HasProgram(uid, false, comp, cont)) + continue; + + _ringer.RingerPlayRingtone(uid, ringer); + break; } } @@ -242,9 +250,11 @@ public sealed class NewsSystem : EntitySystem { return true; } + + var conv = _stationRecords.Convert(articleToDelete.AuthorStationRecordKeyIds); if (user.HasValue && _accessReader.FindStationRecordKeys(user.Value, out var recordKeys) - && recordKeys.Intersect(articleToDelete.AuthorStationRecordKeyIds).Any()) + && recordKeys.Intersect(conv).Any()) { return true; } diff --git a/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs b/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs index 84f60573b1..499f833ac8 100644 --- a/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs +++ b/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs @@ -56,10 +56,12 @@ public sealed class MechGrabberSystem : EntitySystem if (!_interaction.InRangeUnobstructed(mech, targetCoords)) return; - if (!component.ItemContainer.Contains(msg.Item)) + var item = GetEntity(msg.Item); + + if (!component.ItemContainer.Contains(item)) return; - RemoveItem(uid, mech, msg.Item, component); + RemoveItem(uid, mech, item, component); } /// @@ -77,11 +79,11 @@ public sealed class MechGrabberSystem : EntitySystem component.ItemContainer.Remove(toRemove); var mechxform = Transform(mech); var xform = Transform(toRemove); - xform.AttachToGridOrMap(); + _transform.AttachToGridOrMap(toRemove, xform); + var (mechPos, mechRot) = _transform.GetWorldPositionRotation(mechxform); - var offset = _transform.GetWorldPosition(mechxform) + _transform.GetWorldRotation(mechxform).RotateVec(component.DepositOffset); - _transform.SetWorldPosition(xform, offset); - _transform.SetWorldRotation(xform, Angle.Zero); + var offset = mechPos + mechRot.RotateVec(component.DepositOffset); + _transform.SetWorldPositionRotation(xform, offset, Angle.Zero); _mech.UpdateUserInterface(mech); } @@ -113,10 +115,10 @@ public sealed class MechGrabberSystem : EntitySystem { var state = new MechGrabberUiState { - Contents = component.ItemContainer.ContainedEntities.ToList(), + Contents = GetNetEntityList(component.ItemContainer.ContainedEntities.ToList()), MaxContents = component.MaxContents }; - args.States.Add(uid, state); + args.States.Add(GetNetEntity(uid), state); } private void OnInteract(EntityUid uid, MechGrabberComponent component, InteractNoHandEvent args) @@ -148,7 +150,7 @@ public sealed class MechGrabberSystem : EntitySystem args.Handled = true; component.AudioStream = _audio.PlayPvs(component.GrabSound, uid); - _doAfter.TryStartDoAfter(new DoAfterArgs(args.User, component.GrabDelay, new GrabberDoAfterEvent(), uid, target: target, used: uid) + _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.GrabDelay, new GrabberDoAfterEvent(), uid, target: target, used: uid) { BreakOnTargetMove = true, BreakOnUserMove = true diff --git a/Content.Server/Mech/Systems/MechEquipmentSystem.cs b/Content.Server/Mech/Systems/MechEquipmentSystem.cs index 71b31b6f30..5191f53004 100644 --- a/Content.Server/Mech/Systems/MechEquipmentSystem.cs +++ b/Content.Server/Mech/Systems/MechEquipmentSystem.cs @@ -45,7 +45,7 @@ public sealed class MechEquipmentSystem : EntitySystem _popup.PopupEntity(Loc.GetString("mech-equipment-begin-install", ("item", uid)), mech); - var doAfterEventArgs = new DoAfterArgs(args.User, component.InstallDuration, new InsertEquipmentEvent(), uid, target: mech, used: uid) + var doAfterEventArgs = new DoAfterArgs(EntityManager, args.User, component.InstallDuration, new InsertEquipmentEvent(), uid, target: mech, used: uid) { BreakOnTargetMove = true, BreakOnUserMove = true diff --git a/Content.Server/Mech/Systems/MechSystem.cs b/Content.Server/Mech/Systems/MechSystem.cs index 453b471df6..8c34f875bf 100644 --- a/Content.Server/Mech/Systems/MechSystem.cs +++ b/Content.Server/Mech/Systems/MechSystem.cs @@ -93,7 +93,7 @@ public sealed partial class MechSystem : SharedMechSystem if (TryComp(args.Used, out var tool) && tool.Qualities.Contains("Prying") && component.BatterySlot.ContainedEntity != null) { - var doAfterEventArgs = new DoAfterArgs(args.User, component.BatteryRemovalDelay, new RemoveBatteryEvent(), uid, target: uid, used: args.Target) + var doAfterEventArgs = new DoAfterArgs(EntityManager, args.User, component.BatteryRemovalDelay, new RemoveBatteryEvent(), uid, target: uid, used: args.Target) { BreakOnTargetMove = true, BreakOnUserMove = true, @@ -146,13 +146,15 @@ public sealed partial class MechSystem : SharedMechSystem private void OnRemoveEquipmentMessage(EntityUid uid, MechComponent component, MechEquipmentRemoveMessage args) { - if (!Exists(args.Equipment) || Deleted(args.Equipment)) + var equip = GetEntity(args.Equipment); + + if (!Exists(equip) || Deleted(equip)) return; - if (!component.EquipmentContainer.ContainedEntities.Contains(args.Equipment)) + if (!component.EquipmentContainer.ContainedEntities.Contains(equip)) return; - RemoveEquipment(uid, args.Equipment, component); + RemoveEquipment(uid, equip, component); } private void OnOpenUi(EntityUid uid, MechComponent component, MechOpenUiEvent args) @@ -179,7 +181,7 @@ public sealed partial class MechSystem : SharedMechSystem Text = Loc.GetString("mech-verb-enter"), Act = () => { - var doAfterEventArgs = new DoAfterArgs(args.User, component.EntryDelay, new MechEntryEvent(), uid, target: uid) + var doAfterEventArgs = new DoAfterArgs(EntityManager, args.User, component.EntryDelay, new MechEntryEvent(), uid, target: uid) { BreakOnUserMove = true, }; @@ -209,7 +211,7 @@ public sealed partial class MechSystem : SharedMechSystem return; } - var doAfterEventArgs = new DoAfterArgs(args.User, component.ExitDelay, new MechExitEvent(), uid, target: uid) + var doAfterEventArgs = new DoAfterArgs(EntityManager, args.User, component.ExitDelay, new MechExitEvent(), uid, target: uid) { BreakOnUserMove = true, BreakOnTargetMove = true, @@ -282,9 +284,11 @@ public sealed partial class MechSystem : SharedMechSystem { var ev = new MechEquipmentUiMessageRelayEvent(args); var allEquipment = new List(component.EquipmentContainer.ContainedEntities); + var argEquip = GetEntity(args.Equipment); + foreach (var equipment in allEquipment) { - if (args.Equipment == equipment) + if (argEquip == equipment) RaiseLocalEvent(equipment, ev); } } @@ -307,7 +311,7 @@ public sealed partial class MechSystem : SharedMechSystem EquipmentStates = ev.States }; var ui = _ui.GetUi(uid, MechUiKey.Key); - UserInterfaceSystem.SetUiState(ui, state); + _ui.SetUiState(ui, state); } public override void BreakMech(EntityUid uid, MechComponent? component = null) diff --git a/Content.Server/Medical/BiomassReclaimer/BiomassReclaimerSystem.cs b/Content.Server/Medical/BiomassReclaimer/BiomassReclaimerSystem.cs index 880f702d1c..40637c5362 100644 --- a/Content.Server/Medical/BiomassReclaimer/BiomassReclaimerSystem.cs +++ b/Content.Server/Medical/BiomassReclaimer/BiomassReclaimerSystem.cs @@ -152,7 +152,7 @@ namespace Content.Server.Medical.BiomassReclaimer if (!HasComp(args.Used) || !CanGib(uid, args.Used, component)) return; - _doAfterSystem.TryStartDoAfter(new DoAfterArgs(args.User, 7f, new ReclaimerDoAfterEvent(), uid, target: args.Target, used: args.Used) + _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, 7f, new ReclaimerDoAfterEvent(), uid, target: args.Target, used: args.Used) { BreakOnTargetMove = true, BreakOnUserMove = true, diff --git a/Content.Server/Medical/CrewMonitoring/CrewMonitoringConsoleSystem.cs b/Content.Server/Medical/CrewMonitoring/CrewMonitoringConsoleSystem.cs index 3b73ce80c4..ed65070436 100644 --- a/Content.Server/Medical/CrewMonitoring/CrewMonitoringConsoleSystem.cs +++ b/Content.Server/Medical/CrewMonitoring/CrewMonitoringConsoleSystem.cs @@ -59,7 +59,7 @@ namespace Content.Server.Medical.CrewMonitoring // update all sensors info var allSensors = component.ConnectedSensors.Values.ToList(); - UserInterfaceSystem.SetUiState(bui, new CrewMonitoringState(allSensors, component.Snap, component.Precision)); + _uiSystem.SetUiState(bui, new CrewMonitoringState(allSensors, component.Snap, component.Precision)); } } } diff --git a/Content.Server/Medical/CryoPodSystem.cs b/Content.Server/Medical/CryoPodSystem.cs index 57f1799fad..ddd29d26a2 100644 --- a/Content.Server/Medical/CryoPodSystem.cs +++ b/Content.Server/Medical/CryoPodSystem.cs @@ -134,7 +134,7 @@ public sealed partial class CryoPodSystem: SharedCryoPodSystem if (cryoPodComponent.BodyContainer.ContainedEntity != null) return; - var doAfterArgs = new DoAfterArgs(args.User, cryoPodComponent.EntryDelay, new CryoPodDragFinished(), uid, target: args.Dragged, used: uid) + var doAfterArgs = new DoAfterArgs(EntityManager, args.User, cryoPodComponent.EntryDelay, new CryoPodDragFinished(), uid, target: args.Dragged, used: uid) { BreakOnDamage = true, BreakOnTargetMove = true, @@ -184,8 +184,8 @@ public sealed partial class CryoPodSystem: SharedCryoPodSystem _userInterfaceSystem.TrySendUiMessage( uid, HealthAnalyzerUiKey.Key, - new HealthAnalyzerScannedUserMessage(cryoPodComponent.BodyContainer.ContainedEntity, - temp != null ? temp.CurrentTemperature : 0, bloodstream != null ? bloodstream.BloodSolution.FillFraction : 0)); + new HealthAnalyzerScannedUserMessage(GetNetEntity(cryoPodComponent.BodyContainer.ContainedEntity), + temp?.CurrentTemperature ?? 0, bloodstream != null ? bloodstream.BloodSolution.FillFraction : 0)); } private void OnInteractUsing(EntityUid uid, CryoPodComponent cryoPodComponent, InteractUsingEvent args) diff --git a/Content.Server/Medical/DefibrillatorSystem.cs b/Content.Server/Medical/DefibrillatorSystem.cs index f86f6b24b3..d80d8bdb65 100644 --- a/Content.Server/Medical/DefibrillatorSystem.cs +++ b/Content.Server/Medical/DefibrillatorSystem.cs @@ -177,7 +177,7 @@ public sealed class DefibrillatorSystem : EntitySystem return false; _audio.PlayPvs(component.ChargeSound, uid); - return _doAfter.TryStartDoAfter(new DoAfterArgs(user, component.DoAfterDuration, new DefibrillatorZapDoAfterEvent(), + return _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, component.DoAfterDuration, new DefibrillatorZapDoAfterEvent(), uid, target, uid) { BlockDuplicate = true, diff --git a/Content.Server/Medical/HealingSystem.cs b/Content.Server/Medical/HealingSystem.cs index 35d70209b5..2e04e1b03c 100644 --- a/Content.Server/Medical/HealingSystem.cs +++ b/Content.Server/Medical/HealingSystem.cs @@ -187,7 +187,7 @@ public sealed class HealingSystem : EntitySystem : component.Delay * GetScaledHealingPenalty(user, component); var doAfterEventArgs = - new DoAfterArgs(user, delay, new HealingDoAfterEvent(), target, target: target, used: uid) + new DoAfterArgs(EntityManager, user, delay, new HealingDoAfterEvent(), target, target: target, used: uid) { //Raise the event on the target if it's not self, otherwise raise it on self. BreakOnUserMove = true, diff --git a/Content.Server/Medical/HealthAnalyzerSystem.cs b/Content.Server/Medical/HealthAnalyzerSystem.cs index 7e07e4ac97..79d55e8068 100644 --- a/Content.Server/Medical/HealthAnalyzerSystem.cs +++ b/Content.Server/Medical/HealthAnalyzerSystem.cs @@ -32,7 +32,7 @@ namespace Content.Server.Medical _audio.PlayPvs(healthAnalyzer.ScanningBeginSound, uid); - _doAfterSystem.TryStartDoAfter(new DoAfterArgs(args.User, healthAnalyzer.ScanDelay, new HealthAnalyzerDoAfterEvent(), uid, target: args.Target, used: uid) + _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, healthAnalyzer.ScanDelay, new HealthAnalyzerDoAfterEvent(), uid, target: args.Target, used: uid) { BreakOnTargetMove = true, BreakOnUserMove = true, @@ -75,7 +75,7 @@ namespace Content.Server.Medical OpenUserInterface(user, healthAnalyzer); - _uiSystem.SendUiMessage(healthAnalyzer.UserInterface, new HealthAnalyzerScannedUserMessage(target, temp != null ? temp.CurrentTemperature : float.NaN, + _uiSystem.SendUiMessage(healthAnalyzer.UserInterface, new HealthAnalyzerScannedUserMessage(GetNetEntity(target), temp != null ? temp.CurrentTemperature : float.NaN, bloodstream != null ? bloodstream.BloodSolution.FillFraction : float.NaN)); } } diff --git a/Content.Server/Medical/Stethoscope/StethoscopeSystem.cs b/Content.Server/Medical/Stethoscope/StethoscopeSystem.cs index 9f28d44d59..9521c14f2e 100644 --- a/Content.Server/Medical/Stethoscope/StethoscopeSystem.cs +++ b/Content.Server/Medical/Stethoscope/StethoscopeSystem.cs @@ -105,7 +105,7 @@ namespace Content.Server.Medical.Stethoscope // construct the doafter and start it private void StartListening(EntityUid scope, EntityUid user, EntityUid target, StethoscopeComponent comp) { - _doAfterSystem.TryStartDoAfter(new DoAfterArgs(user, comp.Delay, new StethoscopeDoAfterEvent(), scope, target: target, used: scope) + _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, user, comp.Delay, new StethoscopeDoAfterEvent(), scope, target: target, used: scope) { BreakOnTargetMove = true, BreakOnUserMove = true, diff --git a/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs b/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs index 597b647646..3871852a11 100644 --- a/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs +++ b/Content.Server/Medical/SuitSensors/SuitSensorSystem.cs @@ -321,7 +321,7 @@ namespace Content.Server.Medical.SuitSensors totalDamage = damageable.TotalDamage.Int(); // finally, form suit sensor status - var status = new SuitSensorStatus(uid, userName, userJob); + var status = new SuitSensorStatus(GetNetEntity(uid), userName, userJob); switch (sensor.Mode) { case SuitSensorMode.SensorBinary: @@ -353,7 +353,7 @@ namespace Content.Server.Medical.SuitSensors coordinates = EntityCoordinates.Invalid; } - status.Coordinates = coordinates; + status.Coordinates = GetNetCoordinates(coordinates); break; } @@ -404,11 +404,11 @@ namespace Content.Server.Medical.SuitSensors payload.TryGetValue(SuitSensorConstants.NET_TOTAL_DAMAGE, out int? totalDamage); payload.TryGetValue(SuitSensorConstants.NET_COORDINATES, out EntityCoordinates? cords); - var status = new SuitSensorStatus(suitSensorUid, name, job) + var status = new SuitSensorStatus(GetNetEntity(suitSensorUid), name, job) { IsAlive = isAlive.Value, TotalDamage = totalDamage, - Coordinates = cords, + Coordinates = GetNetCoordinates(cords), }; return status; } diff --git a/Content.Server/Mind/Commands/MakeSentientCommand.cs b/Content.Server/Mind/Commands/MakeSentientCommand.cs index 04907962a0..5e19d135b6 100644 --- a/Content.Server/Mind/Commands/MakeSentientCommand.cs +++ b/Content.Server/Mind/Commands/MakeSentientCommand.cs @@ -12,6 +12,8 @@ namespace Content.Server.Mind.Commands [AdminCommand(AdminFlags.Admin)] public sealed class MakeSentientCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "makesentient"; public string Description => "Makes an entity sentient (able to be controlled by a player)"; public string Help => "makesentient "; @@ -24,21 +26,19 @@ namespace Content.Server.Mind.Commands return; } - if (!EntityUid.TryParse(args[0], out var entId)) + if (!NetEntity.TryParse(args[0], out var entNet) || !_entManager.TryGetEntity(entNet, out var entId)) { shell.WriteLine("Invalid argument."); return; } - var entityManager = IoCManager.Resolve(); - - if (!entityManager.EntityExists(entId)) + if (!_entManager.EntityExists(entId)) { shell.WriteLine("Invalid entity specified!"); return; } - MakeSentient(entId, entityManager, true, true); + MakeSentient(entId.Value, _entManager, true, true); } public static void MakeSentient(EntityUid uid, IEntityManager entityManager, bool allowMovement = true, bool allowSpeech = true) diff --git a/Content.Server/Mind/Commands/RenameCommand.cs b/Content.Server/Mind/Commands/RenameCommand.cs index cbe8be239d..afdd1caf9b 100644 --- a/Content.Server/Mind/Commands/RenameCommand.cs +++ b/Content.Server/Mind/Commands/RenameCommand.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using Content.Server.Access.Systems; using Content.Server.Administration; using Content.Server.Administration.Systems; @@ -17,6 +18,9 @@ namespace Content.Server.Mind.Commands; [AdminCommand(AdminFlags.VarEdit)] public sealed class RenameCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; + public string Command => "rename"; public string Description => "Renames an entity and its cloner entries, ID cards, and PDAs."; public string Help => "rename "; @@ -36,53 +40,53 @@ public sealed class RenameCommand : IConsoleCommand return; } - var entMan = IoCManager.Resolve(); - - if (!TryParseUid(args[0], shell, entMan, out var entityUid)) + if (!TryParseUid(args[0], shell, _entManager, out var entityUid)) return; // Metadata - var metadata = entMan.GetComponent(entityUid); + var metadata = _entManager.GetComponent(entityUid.Value); var oldName = metadata.EntityName; - entMan.System().SetEntityName(entityUid, name, metadata); + _entManager.System().SetEntityName(entityUid.Value, name, metadata); - var minds = entMan.System(); + var minds = _entManager.System(); - if (minds.TryGetMind(entityUid, out var mindId, out var mind)) + if (minds.TryGetMind(entityUid.Value, out var mindId, out var mind)) { // Mind mind.CharacterName = name; } // Id Cards - if (entMan.TrySystem(out var idCardSystem)) + if (_entManager.TrySystem(out var idCardSystem)) { - if (idCardSystem.TryFindIdCard(entityUid, out var idCard)) + if (idCardSystem.TryFindIdCard(entityUid.Value, out var idCard)) { idCardSystem.TryChangeFullName(idCard.Owner, name, idCard); // Records // This is done here because ID cards are linked to station records - if (entMan.TrySystem(out var recordsSystem) - && entMan.TryGetComponent(idCard.Owner, out StationRecordKeyStorageComponent? keyStorage) + if (_entManager.TrySystem(out var recordsSystem) + && _entManager.TryGetComponent(idCard.Owner, out StationRecordKeyStorageComponent? keyStorage) && keyStorage.Key != null) { - if (recordsSystem.TryGetRecord(keyStorage.Key.Value.OriginStation, + var origin = keyStorage.Key.Value.OriginStation; + + if (recordsSystem.TryGetRecord(origin, keyStorage.Key.Value, out var generalRecord)) { generalRecord.Name = name; } - recordsSystem.Synchronize(keyStorage.Key.Value.OriginStation); + recordsSystem.Synchronize(origin); } } } // PDAs - if (entMan.TrySystem(out var pdaSystem)) + if (_entManager.TrySystem(out var pdaSystem)) { - var query = entMan.EntityQueryEnumerator(); + var query = _entManager.EntityQueryEnumerator(); while (query.MoveNext(out var uid, out var pda)) { if (pda.OwnerName == oldName) @@ -93,21 +97,20 @@ public sealed class RenameCommand : IConsoleCommand } // Admin Overlay - if (entMan.TrySystem(out var adminSystem) - && entMan.TryGetComponent(entityUid, out var actorComp)) + if (_entManager.TrySystem(out var adminSystem) + && _entManager.TryGetComponent(entityUid, out var actorComp)) { adminSystem.UpdatePlayerList(actorComp.PlayerSession); } } - private static bool TryParseUid(string str, IConsoleShell shell, - IEntityManager entMan, out EntityUid entityUid) + private bool TryParseUid(string str, IConsoleShell shell, + IEntityManager entMan, [NotNullWhen(true)] out EntityUid? entityUid) { - if (EntityUid.TryParse(str, out entityUid) && entMan.EntityExists(entityUid)) + if (NetEntity.TryParse(str, out var entityUidNet) && _entManager.TryGetEntity(entityUidNet, out entityUid) && entMan.EntityExists(entityUid)) return true; - var playerMan = IoCManager.Resolve(); - if (playerMan.TryGetSessionByUsername(str, out var session) && session.AttachedEntity.HasValue) + if (_playerManager.TryGetSessionByUsername(str, out var session) && session.AttachedEntity.HasValue) { entityUid = session.AttachedEntity.Value; return true; @@ -117,6 +120,8 @@ public sealed class RenameCommand : IConsoleCommand shell.WriteError("Can't find username/uid: " + str); else shell.WriteError(str + " does not have an entity."); + + entityUid = EntityUid.Invalid; return false; } } diff --git a/Content.Server/NPC/HTN/HTNSystem.cs b/Content.Server/NPC/HTN/HTNSystem.cs index b557ff3d4d..6fa9af0ccd 100644 --- a/Content.Server/NPC/HTN/HTNSystem.cs +++ b/Content.Server/NPC/HTN/HTNSystem.cs @@ -231,7 +231,7 @@ public sealed class HTNSystem : EntitySystem RaiseNetworkEvent(new HTNMessage() { - Uid = uid, + Uid = GetNetEntity(uid), Text = text.ToString(), }, session.ConnectedClient); } diff --git a/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs b/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs index ca970815b6..a173cb7942 100644 --- a/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs +++ b/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs @@ -465,6 +465,14 @@ public sealed partial class PathfindingSystem continue; } + var xform = xformQuery.GetComponent(ent); + + if (xform.ParentUid != grid.Owner || + grid.LocalToTile(xform.Coordinates) != tilePos) + { + continue; + } + tileEntities.Add(ent); } diff --git a/Content.Server/NPC/Pathfinding/PathfindingSystem.cs b/Content.Server/NPC/Pathfinding/PathfindingSystem.cs index 06ff9faa69..d8ecebc12c 100644 --- a/Content.Server/NPC/Pathfinding/PathfindingSystem.cs +++ b/Content.Server/NPC/Pathfinding/PathfindingSystem.cs @@ -495,16 +495,16 @@ namespace Content.Server.NPC.Pathfinding private DebugPathPoly GetDebugPoly(PathPoly poly) { // Create fake neighbors for it - var neighbors = new List(poly.Neighbors.Count); + var neighbors = new List(poly.Neighbors.Count); foreach (var neighbor in poly.Neighbors) { - neighbors.Add(neighbor.Coordinates); + neighbors.Add(GetNetCoordinates(neighbor.Coordinates)); } return new DebugPathPoly() { - GraphUid = poly.GraphUid, + GraphUid = GetNetEntity(poly.GraphUid), ChunkOrigin = poly.ChunkOrigin, TileIndex = poly.TileIndex, Box = poly.Box, @@ -579,12 +579,14 @@ namespace Content.Server.NPC.Pathfinding foreach (var comp in EntityQuery(true)) { - msg.Breadcrumbs.Add(comp.Owner, new Dictionary>(comp.Chunks.Count)); + var netGrid = GetNetEntity(comp.Owner); + + msg.Breadcrumbs.Add(netGrid, new Dictionary>(comp.Chunks.Count)); foreach (var chunk in comp.Chunks) { var data = GetCrumbs(chunk.Value); - msg.Breadcrumbs[comp.Owner].Add(chunk.Key, data); + msg.Breadcrumbs[netGrid].Add(chunk.Key, data); } } @@ -626,12 +628,14 @@ namespace Content.Server.NPC.Pathfinding foreach (var comp in EntityQuery(true)) { - msg.Polys.Add(comp.Owner, new Dictionary>>(comp.Chunks.Count)); + var netGrid = GetNetEntity(comp.Owner); + + msg.Polys.Add(netGrid, new Dictionary>>(comp.Chunks.Count)); foreach (var chunk in comp.Chunks) { var data = GetPolys(chunk.Value); - msg.Polys[comp.Owner].Add(chunk.Key, data); + msg.Polys[netGrid].Add(chunk.Key, data); } } @@ -646,7 +650,7 @@ namespace Content.Server.NPC.Pathfinding var msg = new PathBreadcrumbsRefreshMessage() { Origin = chunk.Origin, - GridUid = gridUid, + GridUid = GetNetEntity(gridUid), Data = GetCrumbs(chunk), }; @@ -680,7 +684,7 @@ namespace Content.Server.NPC.Pathfinding var msg = new PathPolysRefreshMessage() { Origin = chunk.Origin, - GridUid = gridUid, + GridUid = GetNetEntity(gridUid), Polys = data, }; diff --git a/Content.Server/NPC/Systems/NPCSteeringSystem.cs b/Content.Server/NPC/Systems/NPCSteeringSystem.cs index 8d6f640955..62fd13fc9f 100644 --- a/Content.Server/NPC/Systems/NPCSteeringSystem.cs +++ b/Content.Server/NPC/Systems/NPCSteeringSystem.cs @@ -268,7 +268,7 @@ public sealed partial class NPCSteeringSystem : SharedNPCSteeringSystem var (uid, steering, mover, _) = npcs[i]; data.Add(new NPCSteeringDebugData( - uid, + GetNetEntity(uid), mover.CurTickSprintMovement, steering.Interest, steering.Danger, diff --git a/Content.Server/Ninja/Systems/BatteryDrainerSystem.cs b/Content.Server/Ninja/Systems/BatteryDrainerSystem.cs index 1910969f19..d5871c147d 100644 --- a/Content.Server/Ninja/Systems/BatteryDrainerSystem.cs +++ b/Content.Server/Ninja/Systems/BatteryDrainerSystem.cs @@ -45,7 +45,7 @@ public sealed class BatteryDrainerSystem : SharedBatteryDrainerSystem return; } - var doAfterArgs = new DoAfterArgs(uid, comp.DrainTime, new DrainDoAfterEvent(), target: target, eventTarget: uid) + var doAfterArgs = new DoAfterArgs(EntityManager, uid, comp.DrainTime, new DrainDoAfterEvent(), target: target, eventTarget: uid) { BreakOnUserMove = true, MovementThreshold = 0.5f, diff --git a/Content.Server/NodeContainer/EntitySystems/NodeGroupSystem.cs b/Content.Server/NodeContainer/EntitySystems/NodeGroupSystem.cs index 2f53bff7ad..e4bd303150 100644 --- a/Content.Server/NodeContainer/EntitySystems/NodeGroupSystem.cs +++ b/Content.Server/NodeContainer/EntitySystems/NodeGroupSystem.cs @@ -409,7 +409,7 @@ namespace Content.Server.NodeContainer.EntitySystems RaiseNetworkEvent(msg, player.ConnectedClient); } - private static NodeVis.GroupData VisMakeGroupState(BaseNodeGroup group) + private NodeVis.GroupData VisMakeGroupState(BaseNodeGroup group) { return new() { @@ -421,7 +421,7 @@ namespace Content.Server.NodeContainer.EntitySystems Name = n.Name, NetId = n.NetId, Reachable = n.ReachableNodes.Select(r => r.NetId).ToArray(), - Entity = n.Owner, + Entity = GetNetEntity(n.Owner), Type = n.GetType().Name }).ToArray(), DebugData = group.GetDebugData() diff --git a/Content.Server/Nuke/Commands/SendNukeCodesCommand.cs b/Content.Server/Nuke/Commands/SendNukeCodesCommand.cs index fccfbe7c6b..55dca4f70d 100644 --- a/Content.Server/Nuke/Commands/SendNukeCodesCommand.cs +++ b/Content.Server/Nuke/Commands/SendNukeCodesCommand.cs @@ -18,11 +18,6 @@ namespace Content.Server.Nuke.Commands [Dependency] private readonly IEntityManager _entityManager = default!; - public SendNukeCodesCommand() - { - IoCManager.InjectDependencies(this); - } - public void Execute(IConsoleShell shell, string argStr, string[] args) { if (args.Length != 1) @@ -31,13 +26,13 @@ namespace Content.Server.Nuke.Commands return; } - if (!EntityUid.TryParse(args[0], out var uid)) + if (!NetEntity.TryParse(args[0], out var uidNet) || !_entityManager.TryGetEntity(uidNet, out var uid)) { shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); return; } - _entityManager.System().SendNukeCodes(uid); + _entityManager.System().SendNukeCodes(uid.Value); } public CompletionResult GetCompletion(IConsoleShell shell, string[] args) diff --git a/Content.Server/Nuke/Commands/ToggleNukeCommand.cs b/Content.Server/Nuke/Commands/ToggleNukeCommand.cs index 6caafc13c4..e499afb225 100644 --- a/Content.Server/Nuke/Commands/ToggleNukeCommand.cs +++ b/Content.Server/Nuke/Commands/ToggleNukeCommand.cs @@ -16,12 +16,12 @@ public sealed class ToggleNukeCommand : LocalizedCommands public override void Execute(IConsoleShell shell, string argStr, string[] args) { - EntityUid bombUid; + EntityUid? bombUid = null; NukeComponent? bomb = null; if (args.Length >= 2) { - if (!EntityUid.TryParse(args[1], out bombUid)) + if (!_entManager.TryParseNetEntity(args[1], out bombUid)) { shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number")); return; @@ -31,12 +31,13 @@ public sealed class ToggleNukeCommand : LocalizedCommands { var query = _entManager.EntityQueryEnumerator(); - while (query.MoveNext(out bombUid, out bomb)) + while (query.MoveNext(out var bomba, out bomb)) { + bombUid = bomba; break; } - if (bomb == null) + if (bombUid == null) { shell.WriteError(Loc.GetString("cmd-nukearm-not-found")); return; @@ -53,10 +54,10 @@ public sealed class ToggleNukeCommand : LocalizedCommands return; } - nukeSys.SetRemainingTime(bombUid, timer, bomb); + nukeSys.SetRemainingTime(bombUid.Value, timer, bomb); } - nukeSys.ToggleBomb(bombUid, bomb); + nukeSys.ToggleBomb(bombUid.Value, bomb); } public override CompletionResult GetCompletion(IConsoleShell shell, string[] args) diff --git a/Content.Server/Nuke/NukeSystem.cs b/Content.Server/Nuke/NukeSystem.cs index 6adbd7ffc8..97c3b6c94f 100644 --- a/Content.Server/Nuke/NukeSystem.cs +++ b/Content.Server/Nuke/NukeSystem.cs @@ -377,7 +377,7 @@ public sealed class NukeSystem : EntitySystem CooldownTime = (int) component.CooldownTime }; - UserInterfaceSystem.SetUiState(ui, state); + _ui.SetUiState(ui, state); } private void PlayNukeKeypadSound(EntityUid uid, int number, NukeComponent? component = null) @@ -568,7 +568,7 @@ public sealed class NukeSystem : EntitySystem private void DisarmBombDoafter(EntityUid uid, EntityUid user, NukeComponent nuke) { - var doAfter = new DoAfterArgs(user, nuke.DisarmDoafterLength, new NukeDisarmDoAfterEvent(), uid, target: uid) + var doAfter = new DoAfterArgs(EntityManager, user, nuke.DisarmDoafterLength, new NukeDisarmDoAfterEvent(), uid, target: uid) { BreakOnDamage = true, BreakOnTargetMove = true, diff --git a/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs b/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs index 980c08d4bc..1aff7e1e9b 100644 --- a/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs @@ -311,7 +311,7 @@ public sealed class DrinkSystem : EntitySystem var flavors = _flavorProfile.GetLocalizedFlavorsMessage(user, drinkSolution); - var doAfterEventArgs = new DoAfterArgs( + var doAfterEventArgs = new DoAfterArgs(EntityManager, user, forceDrink ? drink.ForceFeedDelay : drink.Delay, new ConsumeDoAfterEvent(drinkSolution.Name, flavors), diff --git a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs index 6c522a8b28..67e19ae17d 100644 --- a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs @@ -170,7 +170,7 @@ namespace Content.Server.Nutrition.EntitySystems _adminLogger.Add(LogType.Ingestion, LogImpact.Low, $"{ToPrettyString(target):target} is eating {ToPrettyString(food):food} {SolutionContainerSystem.ToPrettyString(foodSolution)}"); } - var doAfterArgs = new DoAfterArgs( + var doAfterArgs = new DoAfterArgs(EntityManager, user, forceFeed ? foodComp.ForceFeedDelay : foodComp.Delay, new ConsumeDoAfterEvent(foodSolution.Name, flavors), diff --git a/Content.Server/Nutrition/EntitySystems/SmokingSystem.Vape.cs b/Content.Server/Nutrition/EntitySystems/SmokingSystem.Vape.cs index 5b1ced8b18..4dd9aff9ac 100644 --- a/Content.Server/Nutrition/EntitySystems/SmokingSystem.Vape.cs +++ b/Content.Server/Nutrition/EntitySystems/SmokingSystem.Vape.cs @@ -113,7 +113,7 @@ namespace Content.Server.Nutrition.EntitySystems if (!exploded) { var vapeDoAfterEvent = new VapeDoAfterEvent(solution, forced); - _doAfterSystem.TryStartDoAfter(new DoAfterArgs(args.User, delay, vapeDoAfterEvent, uid, target: args.Target, used: uid) + _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, delay, vapeDoAfterEvent, uid, target: args.Target, used: uid) { BreakOnTargetMove = true, BreakOnUserMove = false, diff --git a/Content.Server/PDA/PdaSystem.cs b/Content.Server/PDA/PdaSystem.cs index e1650f19b3..ae0fc1e1dc 100644 --- a/Content.Server/PDA/PdaSystem.cs +++ b/Content.Server/PDA/PdaSystem.cs @@ -12,6 +12,7 @@ using Content.Server.Station.Systems; using Content.Server.Store.Components; using Content.Server.Store.Systems; using Content.Shared.Access.Components; +using Content.Shared.CartridgeLoader; using Content.Shared.Light.Components; using Content.Shared.PDA; using Robust.Server.GameObjects; @@ -67,6 +68,13 @@ namespace Content.Server.PDA protected override void OnItemRemoved(EntityUid uid, PdaComponent pda, EntRemovedFromContainerMessage args) { + if (args.Container.ID != pda.IdSlot.ID && args.Container.ID != pda.PenSlot.ID) + return; + + // TODO: This is super cursed just use compstates please. + if (MetaData(uid).EntityLifeStage >= EntityLifeStage.Terminating) + return; + base.OnItemRemoved(uid, pda, args); UpdatePdaUi(uid, pda); } @@ -105,9 +113,12 @@ namespace Content.Server.PDA /// /// Send new UI state to clients, call if you modify something like uplink. /// - public void UpdatePdaUi(EntityUid uid, PdaComponent pda) + public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null) { - if (!_ui.TryGetUi(uid, PdaUiKey.Key, out _)) + if (!Resolve(uid, ref pda, false)) + return; + + if (!_ui.TryGetUi(uid, PdaUiKey.Key, out var ui)) return; var address = GetDeviceNetAddress(uid); @@ -119,8 +130,15 @@ namespace Content.Server.PDA // TODO: Update the level and name of the station with each call to UpdatePdaUi is only needed for latejoin players. // TODO: If someone can implement changing the level and name of the station when changing the PDA grid, this can be removed. + // TODO don't make this depend on cartridge loader!?!? + if (!TryComp(uid, out CartridgeLoaderComponent? loader)) + return; + + var programs = _cartridgeLoader.GetAvailablePrograms(uid, loader); var id = CompOrNull(pda.ContainedId); var state = new PdaUpdateState( + programs, + GetNetEntity(loader.ActiveProgram), pda.FlashlightOn, pda.PenSlot.HasItem, new PdaIdInfoText @@ -136,7 +154,7 @@ namespace Content.Server.PDA hasInstrument, address); - _cartridgeLoader?.UpdateUiState(uid, state); + _ui.SetUiState(ui, state); } private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaRequestUpdateInterfaceMessage msg) diff --git a/Content.Server/PDA/Ringer/RingerSystem.cs b/Content.Server/PDA/Ringer/RingerSystem.cs index b132fa761f..2145dae326 100644 --- a/Content.Server/PDA/Ringer/RingerSystem.cs +++ b/Content.Server/PDA/Ringer/RingerSystem.cs @@ -164,7 +164,7 @@ namespace Content.Server.PDA.Ringer private void UpdateRingerUserInterface(EntityUid uid, RingerComponent ringer) { if (_ui.TryGetUi(uid, RingerUiKey.Key, out var bui)) - UserInterfaceSystem.SetUiState(bui, new RingerUpdateState(HasComp(uid), ringer.Ringtone)); + _ui.SetUiState(bui, new RingerUpdateState(HasComp(uid), ringer.Ringtone)); } public bool ToggleRingerUI(EntityUid uid, IPlayerSession session) diff --git a/Content.Server/Paper/PaperSystem.cs b/Content.Server/Paper/PaperSystem.cs index e3c4e4091b..f38013e14d 100644 --- a/Content.Server/Paper/PaperSystem.cs +++ b/Content.Server/Paper/PaperSystem.cs @@ -213,7 +213,7 @@ namespace Content.Server.Paper return; if (_uiSystem.TryGetUi(uid, PaperUiKey.Key, out var bui)) - UserInterfaceSystem.SetUiState(bui, new PaperBoundUserInterfaceState(paperComp.Content, paperComp.StampedBy, paperComp.Mode), session); + _uiSystem.SetUiState(bui, new PaperBoundUserInterfaceState(paperComp.Content, paperComp.StampedBy, paperComp.Mode), session); } } diff --git a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.ControlBox.cs b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.ControlBox.cs index 489038af12..20ed276967 100644 --- a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.ControlBox.cs +++ b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.ControlBox.cs @@ -233,7 +233,7 @@ public sealed partial class ParticleAcceleratorSystem receive = powerConsumer.ReceivedPower; } - UserInterfaceSystem.SetUiState(bui, new ParticleAcceleratorUIState( + _uiSystem.SetUiState(bui, new ParticleAcceleratorUIState( comp.Assembled, comp.Enabled, comp.SelectedStrength, diff --git a/Content.Server/Pointing/EntitySystems/PointingSystem.cs b/Content.Server/Pointing/EntitySystems/PointingSystem.cs index 5d96b4c5bb..9d1eb466fc 100644 --- a/Content.Server/Pointing/EntitySystems/PointingSystem.cs +++ b/Content.Server/Pointing/EntitySystems/PointingSystem.cs @@ -65,6 +65,8 @@ namespace Content.Server.Pointing.EntitySystems private void SendMessage(EntityUid source, IEnumerable viewers, EntityUid pointed, string selfMessage, string viewerMessage, string? viewerPointedAtMessage = null) { + var netSource = GetNetEntity(source); + foreach (var viewer in viewers) { if (viewer.AttachedEntity is not {Valid: true} viewerEntity) @@ -78,10 +80,10 @@ namespace Content.Server.Pointing.EntitySystems ? viewerPointedAtMessage : viewerMessage; - RaiseNetworkEvent(new PopupEntityEvent(message, PopupType.Small, source), viewerEntity); + RaiseNetworkEvent(new PopupEntityEvent(message, PopupType.Small, netSource), viewerEntity); } - _replay.RecordServerMessage(new PopupEntityEvent(viewerMessage, PopupType.Small, source)); + _replay.RecordServerMessage(new PopupEntityEvent(viewerMessage, PopupType.Small, netSource)); } public bool InRange(EntityUid pointer, EntityCoordinates coordinates) @@ -100,13 +102,13 @@ namespace Content.Server.Pointing.EntitySystems { if (session?.AttachedEntity is not { } player) { - Logger.Warning($"Player {session} attempted to point without any attached entity"); + Log.Warning($"Player {session} attempted to point without any attached entity"); return false; } if (!coords.IsValid(EntityManager)) { - Logger.Warning($"Player {ToPrettyString(player)} attempted to point at invalid coordinates: {coords}"); + Log.Warning($"Player {ToPrettyString(player)} attempted to point at invalid coordinates: {coords}"); return false; } @@ -247,10 +249,12 @@ namespace Content.Server.Pointing.EntitySystems private void OnPointAttempt(PointingAttemptEvent ev, EntitySessionEventArgs args) { - if (TryComp(ev.Target, out TransformComponent? xform)) - TryPoint(args.SenderSession, xform.Coordinates, ev.Target); + var target = GetEntity(ev.Target); + + if (TryComp(target, out TransformComponent? xform)) + TryPoint(args.SenderSession, xform.Coordinates, target); else - Logger.Warning($"User {args.SenderSession} attempted to point at a non-existent entity uid: {ev.Target}"); + Log.Warning($"User {args.SenderSession} attempted to point at a non-existent entity uid: {ev.Target}"); } public override void Shutdown() diff --git a/Content.Server/Popups/PopupSystem.cs b/Content.Server/Popups/PopupSystem.cs index 9c4b0ae082..407d2c49aa 100644 --- a/Content.Server/Popups/PopupSystem.cs +++ b/Content.Server/Popups/PopupSystem.cs @@ -31,37 +31,37 @@ namespace Content.Server.Popups public override void PopupCoordinates(string message, EntityCoordinates coordinates, Filter filter, bool replayRecord, PopupType type = PopupType.Small) { - RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, coordinates), filter, replayRecord); + RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, GetNetCoordinates(coordinates)), filter, replayRecord); } public override void PopupCoordinates(string message, EntityCoordinates coordinates, PopupType type = PopupType.Small) { var mapPos = coordinates.ToMap(EntityManager); var filter = Filter.Empty().AddPlayersByPvs(mapPos, entManager: EntityManager, playerMan: _player, cfgMan: _cfg); - RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, coordinates), filter); + RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, GetNetCoordinates(coordinates)), filter); } public override void PopupCoordinates(string message, EntityCoordinates coordinates, ICommonSession recipient, PopupType type = PopupType.Small) { - RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, coordinates), recipient); + RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, GetNetCoordinates(coordinates)), recipient); } public override void PopupCoordinates(string message, EntityCoordinates coordinates, EntityUid recipient, PopupType type = PopupType.Small) { if (TryComp(recipient, out ActorComponent? actor)) - RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, coordinates), actor.PlayerSession); + RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, GetNetCoordinates(coordinates)), actor.PlayerSession); } public override void PopupEntity(string message, EntityUid uid, PopupType type = PopupType.Small) { var filter = Filter.Empty().AddPlayersByPvs(uid, entityManager:EntityManager, playerMan: _player, cfgMan: _cfg); - RaiseNetworkEvent(new PopupEntityEvent(message, type, uid), filter); + RaiseNetworkEvent(new PopupEntityEvent(message, type, GetNetEntity(uid)), filter); } public override void PopupEntity(string message, EntityUid uid, EntityUid recipient, PopupType type=PopupType.Small) { if (TryComp(recipient, out ActorComponent? actor)) - RaiseNetworkEvent(new PopupEntityEvent(message, type, uid), actor.PlayerSession); + RaiseNetworkEvent(new PopupEntityEvent(message, type, GetNetEntity(uid)), actor.PlayerSession); } public override void PopupClient(string message, EntityUid uid, EntityUid recipient, PopupType type = PopupType.Small) @@ -72,12 +72,12 @@ namespace Content.Server.Popups public override void PopupEntity(string message, EntityUid uid, ICommonSession recipient, PopupType type = PopupType.Small) { - RaiseNetworkEvent(new PopupEntityEvent(message, type, uid), recipient); + RaiseNetworkEvent(new PopupEntityEvent(message, type, GetNetEntity(uid)), recipient); } public override void PopupEntity(string message, EntityUid uid, Filter filter, bool recordReplay, PopupType type = PopupType.Small) { - RaiseNetworkEvent(new PopupEntityEvent(message, type, uid), filter, recordReplay); + RaiseNetworkEvent(new PopupEntityEvent(message, type, GetNetEntity(uid)), filter, recordReplay); } } } diff --git a/Content.Server/Power/EntitySystems/PowerMonitoringConsoleSystem.cs b/Content.Server/Power/EntitySystems/PowerMonitoringConsoleSystem.cs index 07e1a62eed..6bf4e69334 100644 --- a/Content.Server/Power/EntitySystems/PowerMonitoringConsoleSystem.cs +++ b/Content.Server/Power/EntitySystems/PowerMonitoringConsoleSystem.cs @@ -100,7 +100,7 @@ internal sealed class PowerMonitoringConsoleSystem : EntitySystem // Actually set state. if (_userInterfaceSystem.TryGetUi(target, PowerMonitoringConsoleUiKey.Key, out var bui)) - UserInterfaceSystem.SetUiState(bui, new PowerMonitoringConsoleBoundInterfaceState(totalSources, totalLoads, sources.ToArray(), loads.ToArray())); + _userInterfaceSystem.SetUiState(bui, new PowerMonitoringConsoleBoundInterfaceState(totalSources, totalLoads, sources.ToArray(), loads.ToArray())); } private int CompareLoadOrSources(PowerMonitoringConsoleEntry x, PowerMonitoringConsoleEntry y) diff --git a/Content.Server/Power/Generator/PortableGeneratorSystem.cs b/Content.Server/Power/Generator/PortableGeneratorSystem.cs index d2ac6973fd..416f509978 100644 --- a/Content.Server/Power/Generator/PortableGeneratorSystem.cs +++ b/Content.Server/Power/Generator/PortableGeneratorSystem.cs @@ -72,7 +72,7 @@ public sealed class PortableGeneratorSystem : SharedPortableGeneratorSystem if (fuelGenerator.On || !Transform(uid).Anchored) return; - _doAfter.TryStartDoAfter(new DoAfterArgs(user, component.StartTime, new GeneratorStartedEvent(), uid, uid) + _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, component.StartTime, new GeneratorStartedEvent(), uid, uid) { BreakOnDamage = true, BreakOnTargetMove = true, BreakOnUserMove = true, RequireCanInteract = true, NeedHand = true diff --git a/Content.Server/Power/SetBatteryPercentCommand.cs b/Content.Server/Power/SetBatteryPercentCommand.cs index 5fd39ceb67..775ca412d3 100644 --- a/Content.Server/Power/SetBatteryPercentCommand.cs +++ b/Content.Server/Power/SetBatteryPercentCommand.cs @@ -8,6 +8,8 @@ namespace Content.Server.Power [AdminCommand(AdminFlags.Debug)] public sealed class SetBatteryPercentCommand : IConsoleCommand { + [Dependency] private readonly IEntityManager _entManager = default!; + public string Command => "setbatterypercent"; public string Description => "Drains or recharges a battery by entity uid and percentage, i.e.: forall with Battery do setbatterypercent $ID 0"; public string Help => $"{Command} "; @@ -20,7 +22,7 @@ namespace Content.Server.Power return; } - if (!EntityUid.TryParse(args[0], out var id)) + if (!NetEntity.TryParse(args[0], out var netEnt) || !_entManager.TryGetEntity(netEnt, out var id)) { shell.WriteLine($"{args[0]} is not a valid entity id."); return; @@ -32,9 +34,7 @@ namespace Content.Server.Power return; } - var entityManager = IoCManager.Resolve(); - - if (!entityManager.TryGetComponent(id, out var battery)) + if (!_entManager.TryGetComponent(id, out var battery)) { shell.WriteLine($"No battery found with id {id}."); return; diff --git a/Content.Server/Projectiles/ProjectileSystem.cs b/Content.Server/Projectiles/ProjectileSystem.cs index 41c7a04dc2..61d67a469b 100644 --- a/Content.Server/Projectiles/ProjectileSystem.cs +++ b/Content.Server/Projectiles/ProjectileSystem.cs @@ -78,7 +78,7 @@ public sealed class ProjectileSystem : SharedProjectileSystem if (component.ImpactEffect != null && TryComp(uid, out var xform)) { - RaiseNetworkEvent(new ImpactEffectEvent(component.ImpactEffect, xform.Coordinates), Filter.Pvs(xform.Coordinates, entityMan: EntityManager)); + RaiseNetworkEvent(new ImpactEffectEvent(component.ImpactEffect, GetNetCoordinates(xform.Coordinates)), Filter.Pvs(xform.Coordinates, entityMan: EntityManager)); } } } diff --git a/Content.Server/Radiation/Systems/GeigerSystem.cs b/Content.Server/Radiation/Systems/GeigerSystem.cs index fdbb6e353c..050b169819 100644 --- a/Content.Server/Radiation/Systems/GeigerSystem.cs +++ b/Content.Server/Radiation/Systems/GeigerSystem.cs @@ -93,7 +93,7 @@ public sealed class GeigerSystem : SharedGeigerSystem CurrentRadiation = component.CurrentRadiation, DangerLevel = component.DangerLevel, IsEnabled = component.IsEnabled, - User = component.User + User = GetNetEntity(component.User) }; } diff --git a/Content.Server/Radiation/Systems/RadiationSystem.Debug.cs b/Content.Server/Radiation/Systems/RadiationSystem.Debug.cs index bd422663f2..97f2e485ca 100644 --- a/Content.Server/Radiation/Systems/RadiationSystem.Debug.cs +++ b/Content.Server/Radiation/Systems/RadiationSystem.Debug.cs @@ -56,18 +56,14 @@ public partial class RadiationSystem if (_debugSessions.Count == 0) return; - var query = GetEntityQuery(); - var dict = new Dictionary>(); + var dict = new Dictionary>(); - var gridQuery = AllEntityQuery(); + var gridQuery = AllEntityQuery(); - while (gridQuery.MoveNext(out var gridUid, out var grid)) + while (gridQuery.MoveNext(out var gridUid, out _, out var resistance)) { - if (!query.TryGetComponent(gridUid, out var resistance)) - continue; - var resMap = resistance.ResistancePerTile; - dict.Add(gridUid, resMap); + dict.Add(GetNetEntity(gridUid), resMap); } var ev = new OnRadiationOverlayResistanceUpdateEvent(dict); diff --git a/Content.Server/Radiation/Systems/RadiationSystem.GridCast.cs b/Content.Server/Radiation/Systems/RadiationSystem.GridCast.cs index 8edb6c1455..719b3fc1ca 100644 --- a/Content.Server/Radiation/Systems/RadiationSystem.GridCast.cs +++ b/Content.Server/Radiation/Systems/RadiationSystem.GridCast.cs @@ -122,7 +122,7 @@ public partial class RadiationSystem // create a new radiation ray from source to destination // at first we assume that it doesn't hit any radiation blockers // and has only distance penalty - var ray = new RadiationRay(mapId, sourceUid, sourceWorld, destUid, destWorld, rads); + var ray = new RadiationRay(mapId, GetNetEntity(sourceUid), sourceWorld, GetNetEntity(destUid), destWorld, rads); // if source and destination on the same grid it's possible that // between them can be another grid (ie. shuttle in center of donut station) @@ -214,7 +214,7 @@ public partial class RadiationSystem // save data for debug if needed if (saveVisitedTiles && blockers.Count > 0) - ray.Blockers.Add(gridUid, blockers); + ray.Blockers.Add(GetNetEntity(gridUid), blockers); return ray; } diff --git a/Content.Server/Radio/EntitySystems/RadioSystem.cs b/Content.Server/Radio/EntitySystems/RadioSystem.cs index 86c05b478b..c4f66a0cd9 100644 --- a/Content.Server/Radio/EntitySystems/RadioSystem.cs +++ b/Content.Server/Radio/EntitySystems/RadioSystem.cs @@ -87,7 +87,7 @@ public sealed class RadioSystem : EntitySystem ChatChannel.Radio, message, wrappedMessage, - EntityUid.Invalid); + NetEntity.Invalid); var chatMsg = new MsgChatMessage { Message = chat }; var ev = new RadioReceiveEvent(message, messageSource, channel, chatMsg); diff --git a/Content.Server/Resist/EscapeInventorySystem.cs b/Content.Server/Resist/EscapeInventorySystem.cs index 77a837587a..64f3baf9c7 100644 --- a/Content.Server/Resist/EscapeInventorySystem.cs +++ b/Content.Server/Resist/EscapeInventorySystem.cs @@ -69,7 +69,7 @@ public sealed class EscapeInventorySystem : EntitySystem if (component.IsEscaping) return; - var doAfterEventArgs = new DoAfterArgs(user, component.BaseResistTime * multiplier, new EscapeInventoryEvent(), user, target: container) + var doAfterEventArgs = new DoAfterArgs(EntityManager, user, component.BaseResistTime * multiplier, new EscapeInventoryEvent(), user, target: container) { BreakOnTargetMove = false, BreakOnUserMove = true, diff --git a/Content.Server/Resist/ResistLockerSystem.cs b/Content.Server/Resist/ResistLockerSystem.cs index 58b898ac96..7a17a2eba1 100644 --- a/Content.Server/Resist/ResistLockerSystem.cs +++ b/Content.Server/Resist/ResistLockerSystem.cs @@ -45,7 +45,7 @@ public sealed class ResistLockerSystem : EntitySystem if (!Resolve(target, ref storageComponent, ref resistLockerComponent)) return; - var doAfterEventArgs = new DoAfterArgs(user, resistLockerComponent.ResistTime, new ResistLockerDoAfterEvent(), target, target: target) + var doAfterEventArgs = new DoAfterArgs(EntityManager, user, resistLockerComponent.ResistTime, new ResistLockerDoAfterEvent(), target, target: target) { BreakOnTargetMove = false, BreakOnUserMove = true, diff --git a/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs b/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs index a9f32f6615..b3caced0da 100644 --- a/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs +++ b/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs @@ -82,7 +82,7 @@ public sealed partial class RevenantSystem private void BeginSoulSearchDoAfter(EntityUid uid, EntityUid target, RevenantComponent revenant) { - var searchDoAfter = new DoAfterArgs(uid, revenant.SoulSearchDuration, new SoulEvent(), uid, target: target) + var searchDoAfter = new DoAfterArgs(EntityManager, uid, revenant.SoulSearchDuration, new SoulEvent(), uid, target: target) { BreakOnUserMove = true, BreakOnDamage = true, @@ -136,7 +136,7 @@ public sealed partial class RevenantSystem return; } - var doAfter = new DoAfterArgs(uid, revenant.HarvestDebuffs.X, new HarvestEvent(), uid, target: target) + var doAfter = new DoAfterArgs(EntityManager, uid, revenant.HarvestDebuffs.X, new HarvestEvent(), uid, target: target) { DistanceThreshold = 2, BreakOnUserMove = true, diff --git a/Content.Server/Salvage/FultonSystem.cs b/Content.Server/Salvage/FultonSystem.cs index fab0709fd9..23145cc1a8 100644 --- a/Content.Server/Salvage/FultonSystem.cs +++ b/Content.Server/Salvage/FultonSystem.cs @@ -55,6 +55,7 @@ public sealed class FultonSystem : SharedFultonSystem !_container.IsEntityOrParentInContainer(component.Beacon.Value, xform: beaconXform)) { var xform = Transform(uid); + var metadata = MetaData(uid); var oldCoords = xform.Coordinates; var offset = _random.NextVector2(1.5f); var localPos = TransformSystem.GetInvWorldMatrix(beaconXform.ParentUid) @@ -64,8 +65,8 @@ public sealed class FultonSystem : SharedFultonSystem RaiseNetworkEvent(new FultonAnimationMessage() { - Entity = uid, - Coordinates = oldCoords, + Entity = GetNetEntity(uid, metadata), + Coordinates = GetNetCoordinates(oldCoords, metadata), }); } diff --git a/Content.Server/SensorMonitoring/SensorMonitoringConsoleSystem.UI.cs b/Content.Server/SensorMonitoring/SensorMonitoringConsoleSystem.UI.cs index e08e9fed6c..a09badcd59 100644 --- a/Content.Server/SensorMonitoring/SensorMonitoringConsoleSystem.UI.cs +++ b/Content.Server/SensorMonitoring/SensorMonitoringConsoleSystem.UI.cs @@ -36,7 +36,7 @@ public sealed partial class SensorMonitoringConsoleSystem else { fullState ??= CalculateFullState(); - UserInterfaceSystem.SetUiState(ui, fullState, session); + _userInterface.SetUiState(ui, fullState, session); comp.InitialUIStateSent.Add(session); } } diff --git a/Content.Server/Sericulture/SericultureSystem.cs b/Content.Server/Sericulture/SericultureSystem.cs index 011e225c28..c100d3d4a5 100644 --- a/Content.Server/Sericulture/SericultureSystem.cs +++ b/Content.Server/Sericulture/SericultureSystem.cs @@ -45,7 +45,7 @@ public sealed partial class SericultureSystem : EntitySystem return; } - var doAfter = new DoAfterArgs(uid, comp.ProductionLength, new SericultureDoAfterEvent(), uid) + var doAfter = new DoAfterArgs(EntityManager, uid, comp.ProductionLength, new SericultureDoAfterEvent(), uid) { BreakOnUserMove = true, BlockDuplicate = true, diff --git a/Content.Server/Shuttles/Commands/DockCommand.cs b/Content.Server/Shuttles/Commands/DockCommand.cs index 7a621c2b80..5f287e0397 100644 --- a/Content.Server/Shuttles/Commands/DockCommand.cs +++ b/Content.Server/Shuttles/Commands/DockCommand.cs @@ -22,13 +22,13 @@ public sealed class DockCommand : IConsoleCommand return; } - if (!EntityUid.TryParse(args[0], out var airlock1)) + if (!NetEntity.TryParse(args[0], out var airlock1Net) || !_entManager.TryGetEntity(airlock1Net, out var airlock1)) { shell.WriteError(Loc.GetString("cmd-dock-invalid", ("entity", args[0]))); return; } - if (!EntityUid.TryParse(args[1], out var airlock2)) + if (!NetEntity.TryParse(args[1], out var airlock2Net) || !_entManager.TryGetEntity(airlock2Net, out var airlock2)) { shell.WriteError(Loc.GetString("cmd-dock-invalid", ("entity", args[1]))); return; @@ -47,7 +47,7 @@ public sealed class DockCommand : IConsoleCommand } var dockSystem = _entManager.System(); - dockSystem.Dock(airlock1, dock1, airlock2, dock2); + dockSystem.Dock(airlock1.Value, dock1, airlock2.Value, dock2); if (dock1.DockedWith == airlock2) { diff --git a/Content.Server/Shuttles/Systems/DockingSystem.AutoDock.cs b/Content.Server/Shuttles/Systems/DockingSystem.AutoDock.cs index 1a18cd2cb3..439367a080 100644 --- a/Content.Server/Shuttles/Systems/DockingSystem.AutoDock.cs +++ b/Content.Server/Shuttles/Systems/DockingSystem.AutoDock.cs @@ -65,7 +65,7 @@ public sealed partial class DockingSystem if ((worldPos - otherWorldPos).Length() < comp.Radius) continue; - _sawmill.Debug($"Removed RecentlyDocked from {ToPrettyString(uid)} and {ToPrettyString(comp.LastDocked)}"); + Log.Debug($"Removed RecentlyDocked from {ToPrettyString(uid)} and {ToPrettyString(comp.LastDocked)}"); RemComp(uid); RemComp(comp.LastDocked); } @@ -73,48 +73,52 @@ public sealed partial class DockingSystem private void OnRequestUndock(EntityUid uid, ShuttleConsoleComponent component, UndockRequestMessage args) { - _sawmill.Debug($"Received undock request for {ToPrettyString(args.DockEntity)}"); + var dork = GetEntity(args.DockEntity); + + Log.Debug($"Received undock request for {ToPrettyString(dork)}"); // TODO: Validation - if (!TryComp(args.DockEntity, out var dock) || + if (!TryComp(dork, out var dock) || !dock.Docked || HasComp(Transform(uid).GridUid)) { return; } - Undock(args.DockEntity, dock); + Undock(dork, dock); } private void OnRequestAutodock(EntityUid uid, ShuttleConsoleComponent component, AutodockRequestMessage args) { - _sawmill.Debug($"Received autodock request for {ToPrettyString(args.DockEntity)}"); + var dork = GetEntity(args.DockEntity); + Log.Debug($"Received autodock request for {ToPrettyString(dork)}"); var player = args.Session.AttachedEntity; if (player == null || - !HasComp(args.DockEntity) || + !HasComp(dork) || HasComp(Transform(uid).GridUid)) { return; } // TODO: Validation - var comp = EnsureComp(args.DockEntity); + var comp = EnsureComp(dork); comp.Requesters.Add(player.Value); } private void OnRequestStopAutodock(EntityUid uid, ShuttleConsoleComponent component, StopAutodockRequestMessage args) { - _sawmill.Debug($"Received stop autodock request for {ToPrettyString(args.DockEntity)}"); + var dork = GetEntity(args.DockEntity); + Log.Debug($"Received stop autodock request for {ToPrettyString(dork)}"); var player = args.Session.AttachedEntity; // TODO: Validation - if (player == null || !TryComp(args.DockEntity, out var comp)) return; + if (player == null || !TryComp(dork, out var comp)) return; comp.Requesters.Remove(player.Value); if (comp.Requesters.Count == 0) - RemComp(args.DockEntity); + RemComp(dork); } } diff --git a/Content.Server/Shuttles/Systems/DockingSystem.cs b/Content.Server/Shuttles/Systems/DockingSystem.cs index 16b6237883..a00a9e0f58 100644 --- a/Content.Server/Shuttles/Systems/DockingSystem.cs +++ b/Content.Server/Shuttles/Systems/DockingSystem.cs @@ -28,7 +28,6 @@ namespace Content.Server.Shuttles.Systems [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; - private ISawmill _sawmill = default!; private const string DockingFixture = "docking"; private const string DockingJoint = "docking"; private const float DockingRadius = 0.20f; @@ -36,7 +35,6 @@ namespace Content.Server.Shuttles.Systems public override void Initialize() { base.Initialize(); - _sawmill = Logger.GetSawmill("docking"); SubscribeLocalEvent(OnStartup); SubscribeLocalEvent(OnShutdown); SubscribeLocalEvent(OnAnchorChange); @@ -114,7 +112,7 @@ namespace Content.Server.Shuttles.Systems if (otherDockingFixture == null) { DebugTools.Assert(false); - _sawmill.Error($"Found null docking fixture on {ent}"); + Log.Error($"Found null docking fixture on {ent}"); continue; } @@ -159,7 +157,7 @@ namespace Content.Server.Shuttles.Systems !TryComp(dockBUid, out DockingComponent? dockB)) { DebugTools.Assert(false); - _sawmill.Error($"Tried to cleanup {dockAUid} but not docked?"); + Log.Error($"Tried to cleanup {dockAUid} but not docked?"); dockA.DockedWith = null; if (dockA.DockJoint != null) @@ -288,7 +286,7 @@ namespace Content.Server.Shuttles.Systems (dockAUid, dockBUid) = (dockBUid, dockAUid); } - _sawmill.Debug($"Docking between {dockAUid} and {dockBUid}"); + Log.Debug($"Docking between {dockAUid} and {dockBUid}"); // https://gamedev.stackexchange.com/questions/98772/b2distancejoint-with-frequency-equal-to-0-vs-b2weldjoint diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs index d0d8b9ff7b..0603ff7502 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs @@ -340,7 +340,7 @@ public sealed partial class EmergencyShuttleSystem } if (_uiSystem.TryGetUi(uid, EmergencyConsoleUiKey.Key, out var bui)) - UserInterfaceSystem.SetUiState( + _uiSystem.SetUiState( bui, new EmergencyConsoleBoundUserInterfaceState() { diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs index a6bdc043a9..1a1debc9e3 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs @@ -165,7 +165,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem RaiseNetworkEvent(new EmergencyShuttlePositionMessage() { - StationUid = targetGrid, + StationUid = GetNetEntity(targetGrid), Position = config.Area, }); } diff --git a/Content.Server/Shuttles/Systems/RadarConsoleSystem.cs b/Content.Server/Shuttles/Systems/RadarConsoleSystem.cs index a52c40cb2c..a8d380541b 100644 --- a/Content.Server/Shuttles/Systems/RadarConsoleSystem.cs +++ b/Content.Server/Shuttles/Systems/RadarConsoleSystem.cs @@ -45,9 +45,9 @@ public sealed class RadarConsoleSystem : SharedRadarConsoleSystem } if (_uiSystem.TryGetUi(uid, RadarConsoleUiKey.Key, out var bui)) - UserInterfaceSystem.SetUiState(bui, new RadarConsoleBoundInterfaceState( + _uiSystem.SetUiState(bui, new RadarConsoleBoundInterfaceState( component.MaxRange, - coordinates, + GetNetCoordinates(coordinates), angle, new List() )); diff --git a/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs b/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs index fd814530ae..04b53a505a 100644 --- a/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs +++ b/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs @@ -74,7 +74,9 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem private void OnDestinationMessage(EntityUid uid, ShuttleConsoleComponent component, ShuttleConsoleFTLRequestMessage args) { - if (!TryComp(args.Destination, out var dest)) + var destination = GetEntity(args.Destination); + + if (!TryComp(destination, out var dest)) { return; } @@ -118,14 +120,14 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem return; } - var dock = HasComp(args.Destination) && HasComp(args.Destination); + var dock = HasComp(destination) && HasComp(destination); var tagEv = new FTLTagEvent(); RaiseLocalEvent(xform.GridUid.Value, ref tagEv); var ev = new ShuttleConsoleFTLTravelStartEvent(uid); RaiseLocalEvent(ref ev); - _shuttle.FTLTravel(xform.GridUid.Value, shuttle, args.Destination, dock: dock, priorityTag: tagEv.Tag); + _shuttle.FTLTravel(xform.GridUid.Value, shuttle, destination, dock: dock, priorityTag: tagEv.Tag); } private void OnDock(DockEvent ev) @@ -225,7 +227,7 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem private void OnGetState(EntityUid uid, PilotComponent component, ref ComponentGetState args) { - args.State = new PilotComponentState(component.Console); + args.State = new PilotComponentState(GetNetEntity(component.Console)); } /// @@ -244,9 +246,9 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem var state = new DockingInterfaceState() { - Coordinates = xform.Coordinates, + Coordinates = GetNetCoordinates(xform.Coordinates), Angle = xform.LocalRotation, - Entity = uid, + Entity = GetNetEntity(uid), Connected = comp.Docked, Color = comp.RadarColor, HighlightedColor = comp.HighlightedRadarColor, @@ -275,7 +277,7 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem var shuttleGridUid = consoleXform?.GridUid; - var destinations = new List<(EntityUid, string, bool)>(); + var destinations = new List<(NetEntity, string, bool)>(); var ftlState = FTLState.Available; var ftlTime = TimeSpan.Zero; @@ -324,22 +326,24 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem canTravel = false; } - destinations.Add((destUid, name, canTravel)); + destinations.Add((GetNetEntity(destUid), name, canTravel)); } } docks ??= GetAllDocks(); if (_ui.TryGetUi(consoleUid, ShuttleConsoleUiKey.Key, out var bui)) - UserInterfaceSystem.SetUiState(bui, new ShuttleConsoleBoundInterfaceState( + { + _ui.SetUiState(bui, new ShuttleConsoleBoundInterfaceState( ftlState, ftlTime, destinations, range, - consoleXform?.Coordinates, + GetNetCoordinates(consoleXform?.Coordinates), consoleXform?.LocalRotation, docks )); + } } public override void Update(float frameTime) diff --git a/Content.Server/Silicons/Borgs/BorgSystem.Ui.cs b/Content.Server/Silicons/Borgs/BorgSystem.Ui.cs index aefe91b07c..ad2622af50 100644 --- a/Content.Server/Silicons/Borgs/BorgSystem.Ui.cs +++ b/Content.Server/Silicons/Borgs/BorgSystem.Ui.cs @@ -84,13 +84,15 @@ public sealed partial class BorgSystem if (args.Session.AttachedEntity is not { } attachedEntity) return; - if (!component.ModuleContainer.Contains(args.Module)) + var module = GetEntity(args.Module); + + if (!component.ModuleContainer.Contains(module)) return; _adminLog.Add(LogType.Action, LogImpact.Medium, - $"{ToPrettyString(attachedEntity):player} removed module {ToPrettyString(args.Module)} from borg {ToPrettyString(uid)}"); - component.ModuleContainer.Remove(args.Module); - _hands.TryPickupAnyHand(attachedEntity, args.Module); + $"{ToPrettyString(attachedEntity):player} removed module {ToPrettyString(module)} from borg {ToPrettyString(uid)}"); + component.ModuleContainer.Remove(module); + _hands.TryPickupAnyHand(attachedEntity, module); UpdateUI(uid, component); } diff --git a/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs b/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs index 69d1fd7c34..fd9eb3e8c6 100644 --- a/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs +++ b/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs @@ -120,7 +120,7 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem /// /// Makes an event horizon consume a given entity. /// - public void ConsumeEntity(EntityUid hungry, EntityUid morsel, EventHorizonComponent eventHorizon, IContainer? outerContainer = null) + public void ConsumeEntity(EntityUid hungry, EntityUid morsel, EventHorizonComponent eventHorizon, BaseContainer? outerContainer = null) { if (!EntityManager.IsQueuedForDeletion(morsel) // I saw it log twice a few times for some reason? && (HasComp(morsel) @@ -140,7 +140,7 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem /// /// Makes an event horizon attempt to consume a given entity. /// - public bool AttemptConsumeEntity(EntityUid hungry, EntityUid morsel, EventHorizonComponent eventHorizon, IContainer? outerContainer = null) + public bool AttemptConsumeEntity(EntityUid hungry, EntityUid morsel, EventHorizonComponent eventHorizon, BaseContainer? outerContainer = null) { if (!CanConsumeEntity(hungry, morsel, eventHorizon)) return false; @@ -192,7 +192,7 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem /// Excludes the event horizon itself. /// All immune entities within the container will be dumped to a given container or the map/grid if that is impossible. /// - public void ConsumeEntitiesInContainer(EntityUid hungry, IContainer container, EventHorizonComponent eventHorizon, IContainer? outerContainer = null) + public void ConsumeEntitiesInContainer(EntityUid hungry, BaseContainer container, EventHorizonComponent eventHorizon, BaseContainer? outerContainer = null) { // Removing the immune entities from the container needs to be deferred until after iteration or the iterator raises an error. List immune = new(); diff --git a/Content.Server/Singularity/Events/EntityConsumedByEventHorizonEvent.cs b/Content.Server/Singularity/Events/EntityConsumedByEventHorizonEvent.cs index 84e8a8ff2b..ce5184c717 100644 --- a/Content.Server/Singularity/Events/EntityConsumedByEventHorizonEvent.cs +++ b/Content.Server/Singularity/Events/EntityConsumedByEventHorizonEvent.cs @@ -8,7 +8,7 @@ namespace Content.Server.Singularity.Events; /// [ByRefEvent] public readonly record struct EntityConsumedByEventHorizonEvent -(EntityUid entity, EntityUid eventHorizonUid, EventHorizonComponent eventHorizon, IContainer? container) +(EntityUid entity, EntityUid eventHorizonUid, EventHorizonComponent eventHorizon, BaseContainer? container) { /// /// The entity being consumed by the event horizon. @@ -29,5 +29,5 @@ public readonly record struct EntityConsumedByEventHorizonEvent /// The innermost container of the entity being consumed by the event horizon that is not also in the process of being consumed by the event horizon. /// Used to correctly dump out the contents containers that are consumed by the event horizon. /// - public readonly IContainer? Container = container; + public readonly BaseContainer? Container = container; } diff --git a/Content.Server/Singularity/Events/EventHorizonConsumedEntityEvent.cs b/Content.Server/Singularity/Events/EventHorizonConsumedEntityEvent.cs index 1934219517..d71b1da7e7 100644 --- a/Content.Server/Singularity/Events/EventHorizonConsumedEntityEvent.cs +++ b/Content.Server/Singularity/Events/EventHorizonConsumedEntityEvent.cs @@ -8,7 +8,7 @@ namespace Content.Server.Singularity.Events; /// [ByRefEvent] public readonly record struct EventHorizonConsumedEntityEvent -(EntityUid entity, EntityUid eventHorizonUid, EventHorizonComponent eventHorizon, IContainer? container) +(EntityUid entity, EntityUid eventHorizonUid, EventHorizonComponent eventHorizon, BaseContainer? container) { /// /// The entity being consumed by the event horizon. @@ -29,5 +29,5 @@ public readonly record struct EventHorizonConsumedEntityEvent /// The innermost container of the entity being consumed by the event horizon that is not also in the process of being consumed by the event horizon. /// Used to correctly dump out the contents containers that are consumed by the event horizon. /// - public readonly IContainer? Container = container; + public readonly BaseContainer? Container = container; } diff --git a/Content.Server/SprayPainter/SprayPainterSystem.cs b/Content.Server/SprayPainter/SprayPainterSystem.cs index 7fe6ecfb37..1b44b7b0ba 100644 --- a/Content.Server/SprayPainter/SprayPainterSystem.cs +++ b/Content.Server/SprayPainter/SprayPainterSystem.cs @@ -108,7 +108,7 @@ public sealed class SprayPainterSystem : SharedSprayPainterSystem } component.IsSpraying = true; - var doAfterEventArgs = new DoAfterArgs(args.User, component.AirlockSprayTime, new SprayPainterDoAfterEvent(sprite, null), uid, target: target, used: uid) + var doAfterEventArgs = new DoAfterArgs(EntityManager, args.User, component.AirlockSprayTime, new SprayPainterDoAfterEvent(sprite, null), uid, target: target, used: uid) { BreakOnTargetMove = true, BreakOnUserMove = true, @@ -129,7 +129,7 @@ public sealed class SprayPainterSystem : SharedSprayPainterSystem if(!component.ColorPalette.TryGetValue(component.PickedColor, out var color)) return; - var doAfterEventArgs = new DoAfterArgs(args.User, component.PipeSprayTime, new SprayPainterDoAfterEvent(null, color), uid, target, uid) + var doAfterEventArgs = new DoAfterArgs(EntityManager, args.User, component.PipeSprayTime, new SprayPainterDoAfterEvent(null, color), uid, target, uid) { BreakOnTargetMove = true, BreakOnUserMove = true, diff --git a/Content.Server/Station/Systems/StationJobsSystem.cs b/Content.Server/Station/Systems/StationJobsSystem.cs index 3f52d6810b..2709bc2072 100644 --- a/Content.Server/Station/Systems/StationJobsSystem.cs +++ b/Content.Server/Station/Systems/StationJobsSystem.cs @@ -450,7 +450,7 @@ public sealed partial class StationJobsSystem : EntitySystem private bool _availableJobsDirty; - private TickerJobsAvailableEvent _cachedAvailableJobs = new (new Dictionary(), new Dictionary>()); + private TickerJobsAvailableEvent _cachedAvailableJobs = new (new Dictionary(), new Dictionary>()); /// /// Assembles an event from the current available-to-play jobs. @@ -461,18 +461,19 @@ public sealed partial class StationJobsSystem : EntitySystem { // If late join is disallowed, return no available jobs. if (_gameTicker.DisallowLateJoin) - return new TickerJobsAvailableEvent(new Dictionary(), new Dictionary>()); + return new TickerJobsAvailableEvent(new Dictionary(), new Dictionary>()); - var jobs = new Dictionary>(); - var stationNames = new Dictionary(); + var jobs = new Dictionary>(); + var stationNames = new Dictionary(); var query = EntityQueryEnumerator(); while (query.MoveNext(out var station, out var comp)) { + var netStation = GetNetEntity(station); var list = comp.JobList.ToDictionary(x => x.Key, x => x.Value); - jobs.Add(station, list); - stationNames.Add(station, Name(station)); + jobs.Add(netStation, list); + stationNames.Add(netStation, Name(station)); } return new TickerJobsAvailableEvent(stationNames, jobs); } diff --git a/Content.Server/Station/Systems/StationSystem.cs b/Content.Server/Station/Systems/StationSystem.cs index 182cbb5a48..8fdf103cd7 100644 --- a/Content.Server/Station/Systems/StationSystem.cs +++ b/Content.Server/Station/Systems/StationSystem.cs @@ -85,7 +85,7 @@ public sealed class StationSystem : EntitySystem { if (e.NewStatus == SessionStatus.Connected) { - RaiseNetworkEvent(new StationsUpdatedEvent(GetStationsSet()), e.Session); + RaiseNetworkEvent(new StationsUpdatedEvent(GetNetEntitySet(GetStationsSet())), e.Session); } } @@ -93,7 +93,7 @@ public sealed class StationSystem : EntitySystem private void OnStationAdd(EntityUid uid, StationDataComponent component, ComponentStartup args) { - RaiseNetworkEvent(new StationsUpdatedEvent(GetStationsSet()), Filter.Broadcast()); + RaiseNetworkEvent(new StationsUpdatedEvent(GetNetEntitySet(GetStationsSet())), Filter.Broadcast()); var metaData = MetaData(uid); RaiseLocalEvent(new StationInitializedEvent(uid)); @@ -108,7 +108,7 @@ public sealed class StationSystem : EntitySystem RemComp(grid); } - RaiseNetworkEvent(new StationsUpdatedEvent(GetStationsSet()), Filter.Broadcast()); + RaiseNetworkEvent(new StationsUpdatedEvent(GetNetEntitySet(GetStationsSet())), Filter.Broadcast()); } private void OnPreGameMapLoad(PreGameMapLoad ev) diff --git a/Content.Server/StationRecords/Components/GeneralStationRecordConsoleComponent.cs b/Content.Server/StationRecords/Components/GeneralStationRecordConsoleComponent.cs index 076ab44783..e5b7f7a260 100644 --- a/Content.Server/StationRecords/Components/GeneralStationRecordConsoleComponent.cs +++ b/Content.Server/StationRecords/Components/GeneralStationRecordConsoleComponent.cs @@ -5,6 +5,6 @@ namespace Content.Server.StationRecords; [RegisterComponent] public sealed partial class GeneralStationRecordConsoleComponent : Component { - public StationRecordKey? ActiveKey { get; set; } + public (NetEntity, uint)? ActiveKey { get; set; } public GeneralStationRecordsFilter? Filter { get; set; } } diff --git a/Content.Server/StationRecords/Components/StationRecordsComponent.cs b/Content.Server/StationRecords/Components/StationRecordsComponent.cs index aab272e814..4ea65522f4 100644 --- a/Content.Server/StationRecords/Components/StationRecordsComponent.cs +++ b/Content.Server/StationRecords/Components/StationRecordsComponent.cs @@ -9,5 +9,6 @@ public sealed partial class StationRecordsComponent : Component // Every single record in this station, by key. // Essentially a columnar database, but I really suck // at implementing that so - [ViewVariables] public readonly StationRecordSet Records = new(); + [IncludeDataField] + public StationRecordSet Records = new(); } diff --git a/Content.Server/StationRecords/StationRecordSet.cs b/Content.Server/StationRecords/StationRecordSet.cs index bc0bc5a427..2f6b220a78 100644 --- a/Content.Server/StationRecords/StationRecordSet.cs +++ b/Content.Server/StationRecords/StationRecordSet.cs @@ -1,6 +1,7 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using Content.Shared.StationRecords; +using Robust.Shared.Utility; namespace Content.Server.StationRecords; @@ -9,15 +10,20 @@ namespace Content.Server.StationRecords; /// Keyed by StationRecordKey, which should be obtained from /// an entity that stores a reference to it. /// -public sealed class StationRecordSet +[DataDefinition] +public sealed partial class StationRecordSet { + [DataField("currentRecordId")] private uint _currentRecordId; - private HashSet _keys = new(); + // TODO add custom type serializer so that keys don't have to be written twice. + [DataField("keys")] + public HashSet Keys = new(); + [DataField("recentlyAccessed")] private HashSet _recentlyAccessed = new(); - [ViewVariables] + [DataField("tables")] // TODO ensure all of this data is serializable. private Dictionary> _tables = new(); /// @@ -46,16 +52,17 @@ public sealed class StationRecordSet } /// - /// Add a new record into this set of entries. + /// Add an entry into a record. /// - /// Station that we're adding the record for. - /// A key that represents the record in this set. - public StationRecordKey AddRecord(EntityUid station) + /// Entry to add. + /// Type of the entry that's being added. + public StationRecordKey AddRecordEntry(EntityUid station, T entry) { + if (entry == null) + return StationRecordKey.Invalid; + var key = new StationRecordKey(_currentRecordId++, station); - - _keys.Add(key); - + AddRecordEntry(key, entry); return key; } @@ -67,18 +74,11 @@ public sealed class StationRecordSet /// Type of the entry that's being added. public void AddRecordEntry(StationRecordKey key, T entry) { - if (!_keys.Contains(key) || entry == null) - { + if (entry == null) return; - } - if (!_tables.TryGetValue(typeof(T), out var table)) - { - table = new(); - _tables.Add(typeof(T), table); - } - - table.Add(key, entry); + if (Keys.Add(key)) + _tables.GetOrNew(typeof(T))[key] = entry; } /// @@ -92,7 +92,7 @@ public sealed class StationRecordSet { entry = default; - if (!_keys.Contains(key) + if (!Keys.Contains(key) || !_tables.TryGetValue(typeof(T), out var table) || !table.TryGetValue(key, out var entryObject)) { @@ -113,7 +113,7 @@ public sealed class StationRecordSet /// True if the entry exists, false otherwise. public bool HasRecordEntry(StationRecordKey key) { - return _keys.Contains(key) + return Keys.Contains(key) && _tables.TryGetValue(typeof(T), out var table) && table.ContainsKey(key); } @@ -142,7 +142,7 @@ public sealed class StationRecordSet /// True if successful, false otherwise. public bool RemoveAllRecords(StationRecordKey key) { - if (!_keys.Remove(key)) + if (!Keys.Remove(key)) { return false; } diff --git a/Content.Server/StationRecords/Systems/GeneralStationRecordConsoleSystem.cs b/Content.Server/StationRecords/Systems/GeneralStationRecordConsoleSystem.cs index 6f3a2a5fa1..ea8eed8445 100644 --- a/Content.Server/StationRecords/Systems/GeneralStationRecordConsoleSystem.cs +++ b/Content.Server/StationRecords/Systems/GeneralStationRecordConsoleSystem.cs @@ -63,7 +63,7 @@ public sealed class GeneralStationRecordConsoleSystem : EntitySystem var consoleRecords = _stationRecordsSystem.GetRecordsOfType(owningStation.Value, stationRecordsComponent); - var listing = new Dictionary(); + var listing = new Dictionary<(NetEntity, uint), string>(); foreach (var pair in consoleRecords) { @@ -72,7 +72,7 @@ public sealed class GeneralStationRecordConsoleSystem : EntitySystem continue; } - listing.Add(pair.Item1, pair.Item2.Name); + listing.Add(_stationRecordsSystem.Convert(pair.Item1), pair.Item2.Name); } if (listing.Count == 0) @@ -89,7 +89,7 @@ public sealed class GeneralStationRecordConsoleSystem : EntitySystem GeneralStationRecord? record = null; if (console.ActiveKey != null) { - _stationRecordsSystem.TryGetRecord(owningStation.Value, console.ActiveKey.Value, out record, + _stationRecordsSystem.TryGetRecord(owningStation.Value, _stationRecordsSystem.Convert(console.ActiveKey.Value), out record, stationRecordsComponent); } diff --git a/Content.Server/StationRecords/Systems/StationRecordsSystem.cs b/Content.Server/StationRecords/Systems/StationRecordsSystem.cs index f98bc67c33..c70e1d0d9a 100644 --- a/Content.Server/StationRecords/Systems/StationRecordsSystem.cs +++ b/Content.Server/StationRecords/Systems/StationRecordsSystem.cs @@ -1,11 +1,7 @@ using System.Diagnostics.CodeAnalysis; -using System.Linq; using Content.Server.GameTicking; -using Content.Server.Station.Systems; -using Content.Shared.Access.Components; using Content.Server.Forensics; using Content.Shared.Inventory; -using Content.Shared.Nuke; using Content.Shared.PDA; using Content.Shared.Preferences; using Content.Shared.Roles; @@ -34,7 +30,7 @@ namespace Content.Server.StationRecords.Systems; /// depend on this general record being created. This is subject /// to change. /// -public sealed class StationRecordsSystem : EntitySystem +public sealed class StationRecordsSystem : SharedStationRecordsSystem { [Dependency] private readonly InventorySystem _inventorySystem = default!; [Dependency] private readonly StationRecordKeyStorageSystem _keyStorageSystem = default!; @@ -131,8 +127,9 @@ public sealed class StationRecordsSystem : EntitySystem DNA = dna }; - var key = AddRecord(station, records); - AddRecordEntry(key, record, records); + var key = AddRecordEntry(station, record); + if (!key.IsValid()) + return; if (idUid != null) { @@ -148,7 +145,7 @@ public sealed class StationRecordsSystem : EntitySystem } } - RaiseLocalEvent(new AfterGeneralRecordCreatedEvent(key, record, profile)); + RaiseLocalEvent(new AfterGeneralRecordCreatedEvent(station, key, record, profile)); } /// @@ -160,13 +157,10 @@ public sealed class StationRecordsSystem : EntitySystem /// True if the record was removed, false otherwise. public bool RemoveRecord(EntityUid station, StationRecordKey key, StationRecordsComponent? records = null) { - if (station != key.OriginStation || !Resolve(station, ref records)) - { + if (!Resolve(station, ref records)) return false; - } - - RaiseLocalEvent(new RecordRemovedEvent(key)); + RaiseLocalEvent(new RecordRemovedEvent(station, key)); return records.Records.RemoveAllRecords(key); } @@ -185,10 +179,8 @@ public sealed class StationRecordsSystem : EntitySystem { entry = default; - if (key.OriginStation != station || !Resolve(station, ref records)) - { + if (!Resolve(station, ref records)) return false; - } return records.Records.TryGetRecordEntry(key, out entry); } @@ -210,43 +202,20 @@ public sealed class StationRecordsSystem : EntitySystem return records.Records.GetRecordsOfType(); } - /// - /// Adds a record to a station's record set. - /// - /// The station to add a record to. - /// Station records component. - /// - /// A station record key, which can be used to add and get records. - /// - /// - /// Occurs when the entity given does not have a station records component. - /// - public StationRecordKey AddRecord(EntityUid station, StationRecordsComponent? records) - { - if (!Resolve(station, ref records)) - { - throw new ArgumentException($"Could not retrieve a {nameof(StationRecordsComponent)} from entity {station}"); - } - - return records.Records.AddRecord(station); - } - /// /// Adds a record entry to a station's record set. /// - /// The key to add the record to. + /// The station to add the record to. /// The record to add. /// Station records component. /// The type of record to add. - public void AddRecordEntry(StationRecordKey key, T record, + public StationRecordKey AddRecordEntry(EntityUid station, T record, StationRecordsComponent? records = null) { - if (!Resolve(key.OriginStation, ref records)) - { - return; - } + if (!Resolve(station, ref records)) + return StationRecordKey.Invalid; - records.Records.AddRecordEntry(key, record); + return records.Records.AddRecordEntry(station, record); } /// @@ -263,7 +232,7 @@ public sealed class StationRecordsSystem : EntitySystem foreach (var key in records.Records.GetRecentlyAccessed()) { - RaiseLocalEvent(new RecordModifiedEvent(key)); + RaiseLocalEvent(new RecordModifiedEvent(station, key)); } records.Records.ClearRecentlyAccessed(); @@ -278,6 +247,7 @@ public sealed class StationRecordsSystem : EntitySystem /// public sealed class AfterGeneralRecordCreatedEvent : EntityEventArgs { + public readonly EntityUid Station; public StationRecordKey Key { get; } public GeneralStationRecord Record { get; } /// @@ -287,8 +257,10 @@ public sealed class AfterGeneralRecordCreatedEvent : EntityEventArgs /// public HumanoidCharacterProfile? Profile { get; } - public AfterGeneralRecordCreatedEvent(StationRecordKey key, GeneralStationRecord record, HumanoidCharacterProfile? profile) + public AfterGeneralRecordCreatedEvent(EntityUid station, StationRecordKey key, GeneralStationRecord record, + HumanoidCharacterProfile? profile) { + Station = station; Key = key; Record = record; Profile = profile; @@ -303,10 +275,12 @@ public sealed class AfterGeneralRecordCreatedEvent : EntityEventArgs /// public sealed class RecordRemovedEvent : EntityEventArgs { + public readonly EntityUid Station; public StationRecordKey Key { get; } - public RecordRemovedEvent(StationRecordKey key) + public RecordRemovedEvent(EntityUid station, StationRecordKey key) { + Station = station; Key = key; } } @@ -318,10 +292,12 @@ public sealed class RecordRemovedEvent : EntityEventArgs /// public sealed class RecordModifiedEvent : EntityEventArgs { + public readonly EntityUid Station; public StationRecordKey Key { get; } - public RecordModifiedEvent(StationRecordKey key) + public RecordModifiedEvent(EntityUid station, StationRecordKey key) { + Station = station; Key = key; } } diff --git a/Content.Server/Sticky/Systems/StickySystem.cs b/Content.Server/Sticky/Systems/StickySystem.cs index 8d89d20615..330b878c05 100644 --- a/Content.Server/Sticky/Systems/StickySystem.cs +++ b/Content.Server/Sticky/Systems/StickySystem.cs @@ -86,7 +86,7 @@ public sealed class StickySystem : EntitySystem component.Stick = true; // start sticking object to target - _doAfterSystem.TryStartDoAfter(new DoAfterArgs(user, delay, new StickyDoAfterEvent(), uid, target: target, used: uid) + _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, user, delay, new StickyDoAfterEvent(), uid, target: target, used: uid) { BreakOnTargetMove = true, BreakOnUserMove = true, @@ -133,7 +133,7 @@ public sealed class StickySystem : EntitySystem component.Stick = false; // start unsticking object - _doAfterSystem.TryStartDoAfter(new DoAfterArgs(user, delay, new StickyDoAfterEvent(), uid, target: uid) + _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, user, delay, new StickyDoAfterEvent(), uid, target: uid) { BreakOnTargetMove = true, BreakOnUserMove = true, diff --git a/Content.Server/Storage/EntitySystems/BluespaceLockerSystem.cs b/Content.Server/Storage/EntitySystems/BluespaceLockerSystem.cs index cd832f8f31..805eabb357 100644 --- a/Content.Server/Storage/EntitySystems/BluespaceLockerSystem.cs +++ b/Content.Server/Storage/EntitySystems/BluespaceLockerSystem.cs @@ -284,7 +284,7 @@ public sealed class BluespaceLockerSystem : EntitySystem { EnsureComp(uid); - _doAfterSystem.TryStartDoAfter(new DoAfterArgs(uid, component.BehaviorProperties.Delay, new BluespaceLockerDoAfterEvent(), uid)); + _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, uid, component.BehaviorProperties.Delay, new BluespaceLockerDoAfterEvent(), uid)); return; } diff --git a/Content.Server/Storage/EntitySystems/StorageSystem.cs b/Content.Server/Storage/EntitySystems/StorageSystem.cs index 530aa726eb..99ed0e17d9 100644 --- a/Content.Server/Storage/EntitySystems/StorageSystem.cs +++ b/Content.Server/Storage/EntitySystems/StorageSystem.cs @@ -151,7 +151,7 @@ namespace Content.Server.Storage.EntitySystems UtilityVerb verb = new() { Text = Loc.GetString("storage-component-transfer-verb"), - IconEntity = args.Using, + IconEntity = GetNetEntity(args.Using), Act = () => TransferEntities(uid, args.Target, component, lockComponent, targetStorage, targetLock) }; @@ -218,7 +218,7 @@ namespace Content.Server.Storage.EntitySystems // The last half of the if is because carpets exist and this is terrible if (storageComp.AreaInsert && (args.Target == null || !HasComp(args.Target.Value))) { - var validStorables = new List(); + var validStorables = new List(); var itemQuery = GetEntityQuery(); foreach (var entity in _entityLookupSystem.GetEntitiesInRange(args.ClickLocation, storageComp.AreaInsertRadius, LookupFlags.Dynamic | LookupFlags.Sundries)) @@ -231,13 +231,13 @@ namespace Content.Server.Storage.EntitySystems continue; } - validStorables.Add(entity); + validStorables.Add(GetNetEntity(entity)); } //If there's only one then let's be generous if (validStorables.Count > 1) { - var doAfterArgs = new DoAfterArgs(args.User, 0.2f * validStorables.Count, new AreaPickupDoAfterEvent(validStorables), uid, target: uid) + var doAfterArgs = new DoAfterArgs(EntityManager, args.User, 0.2f * validStorables.Count, new AreaPickupDoAfterEvent(validStorables), uid, target: uid) { BreakOnDamage = true, BreakOnUserMove = true, @@ -273,9 +273,9 @@ namespace Content.Server.Storage.EntitySystems if (PlayerInsertEntityInWorld(uid, args.User, target, storageComp)) { - RaiseNetworkEvent(new AnimateInsertingEntitiesEvent(uid, - new List { target }, - new List { position }, + RaiseNetworkEvent(new AnimateInsertingEntitiesEvent(GetNetEntity(uid), + new List { GetNetEntity(target) }, + new List { GetNetCoordinates(position) }, new List { transformOwner.LocalRotation })); } } @@ -294,8 +294,10 @@ namespace Content.Server.Storage.EntitySystems var xformQuery = GetEntityQuery(); xformQuery.TryGetComponent(uid, out var xform); - foreach (var entity in args.Entities) + foreach (var nent in args.Entities) { + var entity = GetEntity(nent); + // Check again, situation may have changed for some entities, but we'll still pick up any that are valid if (_containerSystem.IsEntityInContainer(entity) || entity == args.Args.User @@ -329,7 +331,7 @@ namespace Content.Server.Storage.EntitySystems if (successfullyInserted.Count > 0) { _audio.PlayPvs(component.StorageInsertSound, uid); - RaiseNetworkEvent(new AnimateInsertingEntitiesEvent(uid, successfullyInserted, successfullyInsertedPositions, successfullyInsertedAngles)); + RaiseNetworkEvent(new AnimateInsertingEntitiesEvent(GetNetEntity(uid), GetNetEntityList(successfullyInserted), GetNetCoordinatesList(successfullyInsertedPositions), successfullyInsertedAngles)); } args.Handled = true; @@ -359,13 +361,15 @@ namespace Content.Server.Storage.EntitySystems if (args.Session.AttachedEntity is not EntityUid player) return; - if (!Exists(args.InteractedItemUID)) + var interacted = GetEntity(args.InteractedItemUID); + + if (!Exists(interacted)) { - Log.Error($"Player {args.Session} interacted with non-existent item {args.InteractedItemUID} stored in {ToPrettyString(uid)}"); + Log.Error($"Player {args.Session} interacted with non-existent item {interacted} stored in {ToPrettyString(uid)}"); return; } - if (!_actionBlockerSystem.CanInteract(player, args.InteractedItemUID) || storageComp.Storage == null || !storageComp.Storage.Contains(args.InteractedItemUID)) + if (!_actionBlockerSystem.CanInteract(player, interacted) || storageComp.Storage == null || !storageComp.Storage.Contains(interacted)) return; // Does the player have hands? @@ -375,14 +379,14 @@ namespace Content.Server.Storage.EntitySystems // If the user's active hand is empty, try pick up the item. if (hands.ActiveHandEntity == null) { - if (_sharedHandsSystem.TryPickupAnyHand(player, args.InteractedItemUID, handsComp: hands) + if (_sharedHandsSystem.TryPickupAnyHand(player, interacted, handsComp: hands) && storageComp.StorageRemoveSound != null) _audio.Play(storageComp.StorageRemoveSound, Filter.Pvs(uid, entityManager: EntityManager), uid, true, AudioParams.Default); return; } // Else, interact using the held item - _interactionSystem.InteractUsing(player, hands.ActiveHandEntity.Value, args.InteractedItemUID, Transform(args.InteractedItemUID).Coordinates, checkCanInteract: false); + _interactionSystem.InteractUsing(player, hands.ActiveHandEntity.Value, interacted, Transform(interacted).Coordinates, checkCanInteract: false); } private void OnInsertItemMessage(EntityUid uid, ServerStorageComponent storageComp, StorageInsertItemMessage args) @@ -732,11 +736,11 @@ namespace Content.Server.Storage.EntitySystems if (storageComp.Storage == null) return; - var state = new StorageBoundUserInterfaceState((List) storageComp.Storage.ContainedEntities, storageComp.StorageUsed, storageComp.StorageCapacityMax); + var state = new StorageBoundUserInterfaceState(GetNetEntityList(storageComp.Storage.ContainedEntities.ToList()), storageComp.StorageUsed, storageComp.StorageCapacityMax); var bui = _uiSystem.GetUiOrNull(uid, StorageUiKey.Key); if (bui != null) - UserInterfaceSystem.SetUiState(bui, state); + _uiSystem.SetUiState(bui, state); } private void Popup(EntityUid _, EntityUid player, string message, ServerStorageComponent storageComp) diff --git a/Content.Server/Store/Systems/StoreSystem.Command.cs b/Content.Server/Store/Systems/StoreSystem.Command.cs index 5823bfe028..d259da2c95 100644 --- a/Content.Server/Store/Systems/StoreSystem.Command.cs +++ b/Content.Server/Store/Systems/StoreSystem.Command.cs @@ -26,8 +26,10 @@ public sealed partial class StoreSystem return; } - if (!EntityUid.TryParse(args[0], out var uid) || !float.TryParse(args[2], out var id)) + if (!NetEntity.TryParse(args[0], out var uidNet) || !TryGetEntity(uidNet, out var uid) || !float.TryParse(args[2], out var id)) + { return; + } if (!TryComp(uid, out var store)) return; @@ -37,7 +39,7 @@ public sealed partial class StoreSystem { args[1], id } }; - TryAddCurrency(currency, uid, store); + TryAddCurrency(currency, uid.Value, store); } private CompletionResult AddCurrencyCommandCompletions(IConsoleShell shell, string[] args) @@ -53,7 +55,7 @@ public sealed partial class StoreSystem return CompletionResult.FromHintOptions(allStores, ""); } - if (args.Length == 2 && EntityUid.TryParse(args[0], out var uid)) + if (args.Length == 2 && NetEntity.TryParse(args[0], out var uidNet) && TryGetEntity(uidNet, out var uid)) { if (TryComp(uid, out var store)) return CompletionResult.FromHintOptions(store.CurrencyWhitelist, ""); diff --git a/Content.Server/Store/Systems/StoreSystem.Ui.cs b/Content.Server/Store/Systems/StoreSystem.Ui.cs index 5de4542509..c5b8761808 100644 --- a/Content.Server/Store/Systems/StoreSystem.Ui.cs +++ b/Content.Server/Store/Systems/StoreSystem.Ui.cs @@ -97,12 +97,12 @@ public sealed partial class StoreSystem // only tell operatives to lock their uplink if it can be locked var showFooter = HasComp(store); var state = new StoreUpdateState(component.LastAvailableListings, allCurrency, showFooter); - UserInterfaceSystem.SetUiState(ui, state); + _ui.SetUiState(ui, state); } private void OnRequestUpdate(EntityUid uid, StoreComponent component, StoreRequestUpdateInterfaceMessage args) { - UpdateUserInterface(args.Session.AttachedEntity, args.Entity, component); + UpdateUserInterface(args.Session.AttachedEntity, GetEntity(args.Entity), component); } private void BeforeActivatableUiOpen(EntityUid uid, StoreComponent component, BeforeActivatableUIOpenEvent args) diff --git a/Content.Server/Store/Systems/StoreSystem.cs b/Content.Server/Store/Systems/StoreSystem.cs index 3f769b6736..d5b17f440e 100644 --- a/Content.Server/Store/Systems/StoreSystem.cs +++ b/Content.Server/Store/Systems/StoreSystem.cs @@ -183,7 +183,7 @@ public sealed partial class StoreSystem : EntitySystem var ui = _ui.GetUiOrNull(uid, StoreUiKey.Key); if (ui != null) { - UserInterfaceSystem.SetUiState(ui, new StoreInitializeState(preset.StoreName)); + _ui.SetUiState(ui, new StoreInitializeState(preset.StoreName)); } } } diff --git a/Content.Server/Strip/StrippableSystem.cs b/Content.Server/Strip/StrippableSystem.cs index 8052765a55..8f723ab97d 100644 --- a/Content.Server/Strip/StrippableSystem.cs +++ b/Content.Server/Strip/StrippableSystem.cs @@ -217,7 +217,7 @@ namespace Content.Server.Strip var ev = new BeforeGettingStrippedEvent(userEv.Time, userEv.Stealth); RaiseLocalEvent(target, ev); - var doAfterArgs = new DoAfterArgs(user, ev.Time, new AwaitedDoAfterEvent(), null, target: target, used: held) + var doAfterArgs = new DoAfterArgs(EntityManager, user, ev.Time, new AwaitedDoAfterEvent(), null, target: target, used: held) { ExtraCheck = Check, AttemptFrequency = AttemptFrequency.EveryTick, @@ -289,7 +289,7 @@ namespace Content.Server.Strip var ev = new BeforeGettingStrippedEvent(userEv.Time, userEv.Stealth); RaiseLocalEvent(target, ev); - var doAfterArgs = new DoAfterArgs(user, ev.Time, new AwaitedDoAfterEvent(), null, target: target, used: held) + var doAfterArgs = new DoAfterArgs(EntityManager, user, ev.Time, new AwaitedDoAfterEvent(), null, target: target, used: held) { ExtraCheck = Check, AttemptFrequency = AttemptFrequency.EveryTick, @@ -349,7 +349,7 @@ namespace Content.Server.Strip var ev = new BeforeGettingStrippedEvent(userEv.Time, userEv.Stealth); RaiseLocalEvent(target, ev); - var doAfterArgs = new DoAfterArgs(user, ev.Time, new AwaitedDoAfterEvent(), null, target: target, used: item) + var doAfterArgs = new DoAfterArgs(EntityManager, user, ev.Time, new AwaitedDoAfterEvent(), null, target: target, used: item) { ExtraCheck = Check, AttemptFrequency = AttemptFrequency.EveryTick, @@ -424,7 +424,7 @@ namespace Content.Server.Strip var ev = new BeforeGettingStrippedEvent(userEv.Time, userEv.Stealth); RaiseLocalEvent(target, ev); - var doAfterArgs = new DoAfterArgs(user, ev.Time, new AwaitedDoAfterEvent(), null, target: target, used: item) + var doAfterArgs = new DoAfterArgs(EntityManager, user, ev.Time, new AwaitedDoAfterEvent(), null, target: target, used: item) { ExtraCheck = Check, AttemptFrequency = AttemptFrequency.EveryTick, diff --git a/Content.Server/SurveillanceCamera/Systems/SurveillanceCameraMonitorSystem.cs b/Content.Server/SurveillanceCamera/Systems/SurveillanceCameraMonitorSystem.cs index 09f767ffd9..2d691602f7 100644 --- a/Content.Server/SurveillanceCamera/Systems/SurveillanceCameraMonitorSystem.cs +++ b/Content.Server/SurveillanceCamera/Systems/SurveillanceCameraMonitorSystem.cs @@ -488,14 +488,7 @@ public sealed class SurveillanceCameraMonitorSystem : EntitySystem return; } - IPlayerSession? session = null; - if (player != null - && TryComp(player, out ActorComponent? actor)) - { - session = actor.PlayerSession; - } - - var state = new SurveillanceCameraMonitorUiState(monitor.ActiveCamera, monitor.KnownSubnets.Keys.ToHashSet(), monitor.ActiveCameraAddress, monitor.ActiveSubnet, monitor.KnownCameras); + var state = new SurveillanceCameraMonitorUiState(GetNetEntity(monitor.ActiveCamera), monitor.KnownSubnets.Keys.ToHashSet(), monitor.ActiveCameraAddress, monitor.ActiveSubnet, monitor.KnownCameras); _userInterface.TrySetUiState(uid, SurveillanceCameraMonitorUiKey.Key, state); } } diff --git a/Content.Server/Tabletop/TabletopSystem.Session.cs b/Content.Server/Tabletop/TabletopSystem.Session.cs index b6e182e936..588c4f129d 100644 --- a/Content.Server/Tabletop/TabletopSystem.Session.cs +++ b/Content.Server/Tabletop/TabletopSystem.Session.cs @@ -90,7 +90,7 @@ namespace Content.Server.Tabletop session.Players[player] = new TabletopSessionPlayerData { Camera = camera }; // Tell the gamer to open a viewport for the tabletop game - RaiseNetworkEvent(new TabletopPlayEvent(uid, camera, Loc.GetString(tabletop.BoardName), tabletop.Size), player.ConnectedClient); + RaiseNetworkEvent(new TabletopPlayEvent(GetNetEntity(uid), GetNetEntity(camera), Loc.GetString(tabletop.BoardName), tabletop.Size), player.ConnectedClient); } /// diff --git a/Content.Server/Tabletop/TabletopSystem.cs b/Content.Server/Tabletop/TabletopSystem.cs index 145ba33511..82a93f6d58 100644 --- a/Content.Server/Tabletop/TabletopSystem.cs +++ b/Content.Server/Tabletop/TabletopSystem.cs @@ -46,16 +46,19 @@ namespace Content.Server.Tabletop if (args.SenderSession is not IPlayerSession playerSession) return; - if (!TryComp(msg.TableUid, out TabletopGameComponent? tabletop) || tabletop.Session is not { } session) - return; + var table = GetEntity(msg.TableUid); + if (!TryComp(table, out TabletopGameComponent? tabletop) || tabletop.Session is not { } session) + return; if (!msg.Entity.IsValid()) return; - if (!TryComp(msg.Entity, out TabletopHologramComponent? hologram)) + var entity = GetEntity(msg.Entity); + + if (!TryComp(entity, out TabletopHologramComponent? hologram)) { - _popupSystem.PopupEntity(Loc.GetString("tabletop-error-remove-non-hologram"), msg.TableUid, args.SenderSession); + _popupSystem.PopupEntity(Loc.GetString("tabletop-error-remove-non-hologram"), table, args.SenderSession); return; } @@ -64,7 +67,7 @@ namespace Content.Server.Tabletop return; // Find the entity, remove it from the session and set it's position to the tabletop - session.Entities.TryGetValue(msg.Entity, out var result); + session.Entities.TryGetValue(entity, out var result); session.Entities.Remove(result); _entityManager.QueueDeleteEntity(result); } @@ -106,7 +109,7 @@ namespace Content.Server.Tabletop if (args.SenderSession is not IPlayerSession playerSession) return; - if (!TryComp(msg.TableUid, out TabletopGameComponent? tabletop) || tabletop.Session is not { } session) + if (!TryComp(GetEntity(msg.TableUid), out TabletopGameComponent? tabletop) || tabletop.Session is not { } session) return; // Check if player is actually playing at this table @@ -153,7 +156,7 @@ namespace Content.Server.Tabletop private void OnStopPlaying(TabletopStopPlayingEvent msg, EntitySessionEventArgs args) { - CloseSessionFor((IPlayerSession)args.SenderSession, msg.TableUid); + CloseSessionFor((IPlayerSession)args.SenderSession, GetEntity(msg.TableUid)); } private void OnPlayerDetached(EntityUid uid, TabletopGamerComponent component, PlayerDetachedEvent args) diff --git a/Content.Server/Teleportation/HandTeleporterSystem.cs b/Content.Server/Teleportation/HandTeleporterSystem.cs index f1fceb2054..4bfe03ba42 100644 --- a/Content.Server/Teleportation/HandTeleporterSystem.cs +++ b/Content.Server/Teleportation/HandTeleporterSystem.cs @@ -54,7 +54,7 @@ public sealed class HandTeleporterSystem : EntitySystem if (xform.ParentUid != xform.GridUid) return; - var doafterArgs = new DoAfterArgs(args.User, component.PortalCreationDelay, new TeleporterDoAfterEvent(), uid, used: uid) + var doafterArgs = new DoAfterArgs(EntityManager, args.User, component.PortalCreationDelay, new TeleporterDoAfterEvent(), uid, used: uid) { BreakOnDamage = true, BreakOnUserMove = true, diff --git a/Content.Server/Tools/ToolSystem.LatticeCutting.cs b/Content.Server/Tools/ToolSystem.LatticeCutting.cs index c1557ee7c5..674a810239 100644 --- a/Content.Server/Tools/ToolSystem.LatticeCutting.cs +++ b/Content.Server/Tools/ToolSystem.LatticeCutting.cs @@ -26,11 +26,12 @@ public sealed partial class ToolSystem if (args.Cancelled) return; - var gridUid = args.Coordinates.GetGridUid(EntityManager); + var coords = GetCoordinates(args.Coordinates); + var gridUid = coords.GetGridUid(EntityManager); if (gridUid == null) return; var grid = _mapManager.GetGrid(gridUid.Value); - var tile = grid.GetTileRef(args.Coordinates); + var tile = grid.GetTileRef(coords); if (_tileDefinitionManager[tile.Tile.TypeId] is not ContentTileDefinition tileDef || !tileDef.CanWirecutter @@ -69,9 +70,11 @@ public sealed partial class ToolSystem || string.IsNullOrEmpty(tileDef.BaseTurf) || _tileDefinitionManager[tileDef.BaseTurf] is not ContentTileDefinition newDef || tile.IsBlockedTurf(true)) + { return false; + } - var ev = new LatticeCuttingCompleteEvent(coordinates); + var ev = new LatticeCuttingCompleteEvent(GetNetCoordinates(coordinates)); return UseTool(toolEntity, user, toolEntity, component.Delay, component.QualityNeeded, ev); } } diff --git a/Content.Server/Tools/ToolSystem.TilePrying.cs b/Content.Server/Tools/ToolSystem.TilePrying.cs index 1f602dae37..614d6b8734 100644 --- a/Content.Server/Tools/ToolSystem.TilePrying.cs +++ b/Content.Server/Tools/ToolSystem.TilePrying.cs @@ -31,14 +31,15 @@ public sealed partial class ToolSystem if (args.Cancelled) return; - var gridUid = args.Coordinates.GetGridUid(EntityManager); + var coords = GetCoordinates(args.Coordinates); + var gridUid = coords.GetGridUid(EntityManager); if (!_mapManager.TryGetGrid(gridUid, out var grid)) { Log.Error("Attempted to pry from a non-existent grid?"); return; } - var tile = grid.GetTileRef(args.Coordinates); + var tile = grid.GetTileRef(coords); var center = _turf.GetTileCenter(tile); if (args.Used != null) { @@ -74,7 +75,7 @@ public sealed partial class ToolSystem if (!tileDef.CanCrowbar && !(tileDef.CanAxe && component.Advanced)) return false; - var ev = new TilePryingDoAfterEvent(coordinates); + var ev = new TilePryingDoAfterEvent(GetNetCoordinates(coordinates)); return UseTool(toolEntity, user, toolEntity, component.Delay, component.QualityNeeded, ev, toolComponent: tool); } diff --git a/Content.Server/Toolshed/Commands/Verbs/RunVerbAsCommand.cs b/Content.Server/Toolshed/Commands/Verbs/RunVerbAsCommand.cs index 100fbc2306..1b11dffeea 100644 --- a/Content.Server/Toolshed/Commands/Verbs/RunVerbAsCommand.cs +++ b/Content.Server/Toolshed/Commands/Verbs/RunVerbAsCommand.cs @@ -14,10 +14,10 @@ public sealed class RunVerbAsCommand : ToolshedCommand private SharedVerbSystem? _verb; [CommandImplementation] - public IEnumerable RunVerbAs( + public IEnumerable RunVerbAs( [CommandInvocationContext] IInvocationContext ctx, - [PipedArgument] IEnumerable input, - [CommandArgument] ValueRef runner, + [PipedArgument] IEnumerable input, + [CommandArgument] ValueRef runner, [CommandArgument] string verb ) { @@ -26,16 +26,17 @@ public sealed class RunVerbAsCommand : ToolshedCommand foreach (var i in input) { - var runnerEid = runner.Evaluate(ctx); + var runnerNet = runner.Evaluate(ctx); + var runnerEid = EntityManager.GetEntity(runnerNet); - - if (EntityManager.Deleted(runnerEid) && runnerEid != default) + if (EntityManager.Deleted(runnerEid) && runnerEid.IsValid()) ctx.ReportError(new DeadEntity(runnerEid)); if (ctx.GetErrors().Any()) yield break; - var verbs = _verb.GetLocalVerbs(i, runnerEid, Verb.VerbTypes, true); + var eId = EntityManager.GetEntity(i); + var verbs = _verb.GetLocalVerbs(eId, runnerEid, Verb.VerbTypes, true); // if the "verb name" is actually a verb-type, try run any verb of that type. var verbType = Verb.VerbTypes.FirstOrDefault(x => x.Name == verb); @@ -44,7 +45,7 @@ public sealed class RunVerbAsCommand : ToolshedCommand var verbTy = verbs.FirstOrDefault(v => v.GetType() == verbType); if (verbTy != null) { - _verb.ExecuteVerb(verbTy, runnerEid, i, forced: true); + _verb.ExecuteVerb(verbTy, runnerEid, eId, forced: true); yield return i; } } @@ -53,7 +54,7 @@ public sealed class RunVerbAsCommand : ToolshedCommand { if (verbTy.Text.ToLowerInvariant() == verb) { - _verb.ExecuteVerb(verbTy, runnerEid, i, forced: true); + _verb.ExecuteVerb(verbTy, runnerEid, eId, forced: true); yield return i; } } diff --git a/Content.Server/Toolshed/Commands/VisualizeCommand.cs b/Content.Server/Toolshed/Commands/VisualizeCommand.cs index 7dcc790cb8..4ef08a91bf 100644 --- a/Content.Server/Toolshed/Commands/VisualizeCommand.cs +++ b/Content.Server/Toolshed/Commands/VisualizeCommand.cs @@ -28,7 +28,7 @@ public sealed class VisualizeCommand : ToolshedCommand } var ui = new ToolshedVisualizeEui( - input.Select(e => (EntName(e), e)).ToArray() + input.Select(e => (EntName(e), EntityManager.GetNetEntity(e))).ToArray() ); _euiManager.OpenEui(ui, (IPlayerSession) ctx.Session); _euiManager.QueueStateUpdate(ui); @@ -36,9 +36,9 @@ public sealed class VisualizeCommand : ToolshedCommand } internal sealed class ToolshedVisualizeEui : BaseEui { - private readonly (string name, EntityUid entity)[] _entities; + private readonly (string name, NetEntity entity)[] _entities; - public ToolshedVisualizeEui((string name, EntityUid entity)[] entities) + public ToolshedVisualizeEui((string name, NetEntity entity)[] entities) { _entities = entities; } diff --git a/Content.Server/Verbs/VerbSystem.cs b/Content.Server/Verbs/VerbSystem.cs index 28d300ade5..6d12b08e86 100644 --- a/Content.Server/Verbs/VerbSystem.cs +++ b/Content.Server/Verbs/VerbSystem.cs @@ -27,15 +27,15 @@ namespace Content.Server.Verbs { var player = (IPlayerSession) eventArgs.SenderSession; - if (!EntityManager.EntityExists(args.EntityUid)) + if (!EntityManager.EntityExists(GetEntity(args.EntityUid))) { - Logger.Warning($"{nameof(HandleVerbRequest)} called on a non-existent entity with id {args.EntityUid} by player {player}."); + Log.Warning($"{nameof(HandleVerbRequest)} called on a non-existent entity with id {args.EntityUid} by player {player}."); return; } if (player.AttachedEntity is not {} attached) { - Logger.Warning($"{nameof(HandleVerbRequest)} called by player {player} with no attached entity."); + Log.Warning($"{nameof(HandleVerbRequest)} called by player {player} with no attached entity."); return; } @@ -54,11 +54,11 @@ namespace Content.Server.Verbs if (type != null) verbTypes.Add(type); else - Logger.Error($"Unknown verb type received: {key}"); + Log.Error($"Unknown verb type received: {key}"); } var response = - new VerbsResponseEvent(args.EntityUid, GetLocalVerbs(args.EntityUid, attached, verbTypes, force)); + new VerbsResponseEvent(args.EntityUid, GetLocalVerbs(GetEntity(args.EntityUid), attached, verbTypes, force)); RaiseNetworkEvent(response, player.ConnectedClient); } diff --git a/Content.Server/VoiceMask/VoiceMaskSystem.cs b/Content.Server/VoiceMask/VoiceMaskSystem.cs index 5143237fa0..fdd5f3a9f4 100644 --- a/Content.Server/VoiceMask/VoiceMaskSystem.cs +++ b/Content.Server/VoiceMask/VoiceMaskSystem.cs @@ -84,6 +84,6 @@ public sealed partial class VoiceMaskSystem : EntitySystem } if (_uiSystem.TryGetUi(owner, VoiceMaskUIKey.Key, out var bui)) - UserInterfaceSystem.SetUiState(bui, new VoiceMaskBuiState(component.VoiceName)); + _uiSystem.SetUiState(bui, new VoiceMaskBuiState(component.VoiceName)); } } diff --git a/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs b/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs index c8f894ea19..c4fec25139 100644 --- a/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs +++ b/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs @@ -102,15 +102,15 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem return false; } - var target = ev.Target!.Value; + var target = GetEntity(ev.Target!.Value); - if (!TryComp(ev.Target.Value, out var targetHandsComponent)) + if (!TryComp(target, out var targetHandsComponent)) { - if (!TryComp(ev.Target!.Value, out var status) || !status.AllowedEffects.Contains("KnockedDown")) + if (!TryComp(target, out var status) || !status.AllowedEffects.Contains("KnockedDown")) return false; } - if (!InRange(user, ev.Target.Value, component.Range, session)) + if (!InRange(user, target, component.Range, session)) { return false; } @@ -122,7 +122,7 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem inTargetHand = targetHandsComponent.ActiveHand.HeldEntity!.Value; } - Interaction.DoContactInteraction(user, ev.Target); + Interaction.DoContactInteraction(user, target); var attemptEvent = new DisarmAttemptEvent(target, user, inTargetHand); @@ -228,7 +228,7 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem filter = Filter.Pvs(user, entityManager: EntityManager); } - RaiseNetworkEvent(new MeleeLungeEvent(user, angle, localPos, animation), filter); + RaiseNetworkEvent(new MeleeLungeEvent(GetNetEntity(user), angle, localPos, animation), filter); } private void OnSpeechHit(EntityUid owner, MeleeSpeechComponent comp, MeleeHitEvent args) diff --git a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs index 2bb1dc8245..0acb20f5a2 100644 --- a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs @@ -398,7 +398,7 @@ public sealed partial class GunSystem : SharedGunSystem // Lord // Forgive me for the shitcode I am about to do // Effects tempt me not - var sprites = new List<(EntityCoordinates coordinates, Angle angle, SpriteSpecifier sprite, float scale)>(); + var sprites = new List<(NetCoordinates coordinates, Angle angle, SpriteSpecifier sprite, float scale)>(); var gridUid = fromCoordinates.GetGridUid(EntityManager); var angle = mapDirection; @@ -421,18 +421,27 @@ public sealed partial class GunSystem : SharedGunSystem { if (hitscan.MuzzleFlash != null) { - sprites.Add((fromCoordinates.Offset(angle.ToVec().Normalized() / 2), angle, hitscan.MuzzleFlash, 1f)); + var coords = fromCoordinates.Offset(angle.ToVec().Normalized() / 2); + var netCoords = GetNetCoordinates(coords); + + sprites.Add((netCoords, angle, hitscan.MuzzleFlash, 1f)); } if (hitscan.TravelFlash != null) { - sprites.Add((fromCoordinates.Offset(angle.ToVec() * (distance + 0.5f) / 2), angle, hitscan.TravelFlash, distance - 1.5f)); + var coords = fromCoordinates.Offset(angle.ToVec() * (distance + 0.5f) / 2); + var netCoords = GetNetCoordinates(coords); + + sprites.Add((netCoords, angle, hitscan.TravelFlash, distance - 1.5f)); } } if (hitscan.ImpactFlash != null) { - sprites.Add((fromCoordinates.Offset(angle.ToVec() * distance), angle.FlipPositive(), hitscan.ImpactFlash, 1f)); + var coords = fromCoordinates.Offset(angle.ToVec() * distance); + var netCoords = GetNetCoordinates(coords); + + sprites.Add((netCoords, angle.FlipPositive(), hitscan.ImpactFlash, 1f)); } if (sprites.Count > 0) diff --git a/Content.Server/Wires/WiresSystem.cs b/Content.Server/Wires/WiresSystem.cs index 90f6b5c954..07f0de2ebe 100644 --- a/Content.Server/Wires/WiresSystem.cs +++ b/Content.Server/Wires/WiresSystem.cs @@ -742,7 +742,7 @@ public sealed class WiresSystem : SharedWiresSystem if (_toolTime > 0f) { - var args = new DoAfterArgs(user, _toolTime, new WireDoAfterEvent(action, id), target, target: target, used: toolEntity) + var args = new DoAfterArgs(EntityManager, user, _toolTime, new WireDoAfterEvent(action, id), target, target: target, used: toolEntity) { NeedHand = true, BreakOnDamage = true, diff --git a/Content.Server/Xenoarchaeology/Equipment/Systems/ArtifactAnalyzerSystem.cs b/Content.Server/Xenoarchaeology/Equipment/Systems/ArtifactAnalyzerSystem.cs index 30d9bae7e8..49036fb19d 100644 --- a/Content.Server/Xenoarchaeology/Equipment/Systems/ArtifactAnalyzerSystem.cs +++ b/Content.Server/Xenoarchaeology/Equipment/Systems/ArtifactAnalyzerSystem.cs @@ -214,11 +214,11 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem var scanning = TryComp(component.AnalyzerEntity, out var active); var remaining = active != null ? _timing.CurTime - active.StartTime : TimeSpan.Zero; - var state = new AnalysisConsoleScanUpdateState(artifact, analyzerConnected, serverConnected, + var state = new AnalysisConsoleScanUpdateState(GetNetEntity(artifact), analyzerConnected, serverConnected, canScan, canPrint, msg, scanning, remaining, totalTime, points); var bui = _ui.GetUi(uid, ArtifactAnalzyerUiKey.Key); - UserInterfaceSystem.SetUiState(bui, state); + _ui.SetUiState(bui, state); } /// diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.Commands.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.Commands.cs index 37f974f6b0..649a7a34f1 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.Commands.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.Commands.cs @@ -25,7 +25,7 @@ public partial class ArtifactSystem if (args.Length != 2) shell.WriteError("Argument length must be 2"); - if (!EntityUid.TryParse(args[0], out var uid) || ! int.TryParse(args[1], out var id)) + if (!NetEntity.TryParse(args[0], out var uidNet) || !TryGetEntity(uidNet, out var uid) || !int.TryParse(args[1], out var id)) return; if (!TryComp(uid, out var artifact)) @@ -33,13 +33,13 @@ public partial class ArtifactSystem if (artifact.NodeTree.FirstOrDefault(n => n.Id == id) is { } node) { - EnterNode(uid, ref node); + EnterNode(uid.Value, ref node); } } private CompletionResult ForceArtifactNodeCompletions(IConsoleShell shell, string[] args) { - if (args.Length == 2 && EntityUid.TryParse(args[0], out var uid)) + if (args.Length == 2 && NetEntity.TryParse(args[0], out var uidNet) && TryGetEntity(uidNet, out var uid)) { if (TryComp(uid, out var artifact)) { @@ -56,13 +56,13 @@ public partial class ArtifactSystem if (args.Length != 1) shell.WriteError("Argument length must be 1"); - if (!EntityUid.TryParse(args[0], out var uid)) + if (!NetEntity.TryParse(args[0], out var uidNet) || !TryGetEntity(uidNet, out var uid)) return; if (!TryComp(uid, out var artifact)) return; - var pointSum = GetResearchPointValue(uid, artifact, true); - shell.WriteLine($"Max point value for {ToPrettyString(uid)} with {artifact.NodeTree.Count} nodes: {pointSum}"); + var pointSum = GetResearchPointValue(uid.Value, artifact, true); + shell.WriteLine($"Max point value for {ToPrettyString(uid.Value)} with {artifact.NodeTree.Count} nodes: {pointSum}"); } } diff --git a/Content.Shared/Access/Components/AccessReaderComponent.cs b/Content.Shared/Access/Components/AccessReaderComponent.cs index 68bbc1e9ad..796646c83c 100644 --- a/Content.Shared/Access/Components/AccessReaderComponent.cs +++ b/Content.Shared/Access/Components/AccessReaderComponent.cs @@ -61,9 +61,9 @@ public sealed class AccessReaderComponentState : ComponentState public List> AccessLists; - public HashSet AccessKeys; + public List<(NetEntity, uint)> AccessKeys; - public AccessReaderComponentState(bool enabled, HashSet denyTags, List> accessLists, HashSet accessKeys) + public AccessReaderComponentState(bool enabled, HashSet denyTags, List> accessLists, List<(NetEntity, uint)> accessKeys) { Enabled = enabled; DenyTags = denyTags; diff --git a/Content.Shared/Access/Systems/AccessReaderSystem.cs b/Content.Shared/Access/Systems/AccessReaderSystem.cs index 4e22c3b5e6..8794500b90 100644 --- a/Content.Shared/Access/Systems/AccessReaderSystem.cs +++ b/Content.Shared/Access/Systems/AccessReaderSystem.cs @@ -21,6 +21,7 @@ public sealed class AccessReaderSystem : EntitySystem [Dependency] private readonly InventorySystem _inventorySystem = default!; [Dependency] private readonly SharedHandsSystem _handsSystem = default!; [Dependency] private readonly SharedContainerSystem _containerSystem = default!; + [Dependency] private readonly SharedStationRecordsSystem _records = default!; public override void Initialize() { @@ -36,7 +37,7 @@ public sealed class AccessReaderSystem : EntitySystem private void OnGetState(EntityUid uid, AccessReaderComponent component, ref ComponentGetState args) { args.State = new AccessReaderComponentState(component.Enabled, component.DenyTags, component.AccessLists, - component.AccessKeys); + _records.Convert(component.AccessKeys)); } private void OnHandleState(EntityUid uid, AccessReaderComponent component, ref ComponentHandleState args) @@ -44,7 +45,16 @@ public sealed class AccessReaderSystem : EntitySystem if (args.Current is not AccessReaderComponentState state) return; component.Enabled = state.Enabled; - component.AccessKeys = new(state.AccessKeys); + component.AccessKeys.Clear(); + foreach (var key in state.AccessKeys) + { + var id = EnsureEntity(key.Item1, uid); + if (!id.IsValid()) + continue; + + component.AccessKeys.Add(new StationRecordKey(key.Item2, id)); + } + component.AccessLists = new(state.AccessLists); component.DenyTags = new(state.DenyTags); } diff --git a/Content.Shared/Actions/ActionEvents.cs b/Content.Shared/Actions/ActionEvents.cs index 3d45d3ef1a..c6f873c78a 100644 --- a/Content.Shared/Actions/ActionEvents.cs +++ b/Content.Shared/Actions/ActionEvents.cs @@ -65,22 +65,22 @@ public sealed class GetItemActionsEvent : EntityEventArgs [Serializable, NetSerializable] public sealed class RequestPerformActionEvent : EntityEventArgs { - public readonly EntityUid Action; - public readonly EntityUid? EntityTarget; - public readonly EntityCoordinates? EntityCoordinatesTarget; + public readonly NetEntity Action; + public readonly NetEntity? EntityTarget; + public readonly NetCoordinates? EntityCoordinatesTarget; - public RequestPerformActionEvent(EntityUid action) + public RequestPerformActionEvent(NetEntity action) { Action = action; } - public RequestPerformActionEvent(EntityUid action, EntityUid entityTarget) + public RequestPerformActionEvent(NetEntity action, NetEntity entityTarget) { Action = action; EntityTarget = entityTarget; } - public RequestPerformActionEvent(EntityUid action, EntityCoordinates entityCoordinatesTarget) + public RequestPerformActionEvent(NetEntity action, NetCoordinates entityCoordinatesTarget) { Action = action; EntityCoordinatesTarget = entityCoordinatesTarget; diff --git a/Content.Shared/Actions/ActionsComponent.cs b/Content.Shared/Actions/ActionsComponent.cs index bceb08b121..f7db07a85a 100644 --- a/Content.Shared/Actions/ActionsComponent.cs +++ b/Content.Shared/Actions/ActionsComponent.cs @@ -21,9 +21,9 @@ public sealed partial class ActionsComponent : Component [Serializable, NetSerializable] public sealed class ActionsComponentState : ComponentState { - public readonly HashSet Actions; + public readonly HashSet Actions; - public ActionsComponentState(HashSet actions) + public ActionsComponentState(HashSet actions) { Actions = actions; } diff --git a/Content.Shared/Actions/BaseActionComponent.cs b/Content.Shared/Actions/BaseActionComponent.cs index 7ece8e2b1f..5580c19e19 100644 --- a/Content.Shared/Actions/BaseActionComponent.cs +++ b/Content.Shared/Actions/BaseActionComponent.cs @@ -149,19 +149,19 @@ public abstract class BaseActionComponentState : ComponentState public (TimeSpan Start, TimeSpan End)? Cooldown; public TimeSpan? UseDelay; public int? Charges; - public EntityUid? Provider; - public EntityUid? EntityIcon; + public NetEntity? Provider; + public NetEntity? EntityIcon; public bool CheckCanInteract; public bool ClientExclusive; public int Priority; - public EntityUid? AttachedEntity; + public NetEntity? AttachedEntity; public bool AutoPopulate; public bool AutoRemove; public bool Temporary; public ItemActionIconStyle ItemIconStyle; public SoundSpecifier? Sound; - protected BaseActionComponentState(BaseActionComponent component) + protected BaseActionComponentState(BaseActionComponent component, IEntityManager entManager) { Icon = component.Icon; IconOn = component.IconOn; @@ -172,12 +172,18 @@ public abstract class BaseActionComponentState : ComponentState Cooldown = component.Cooldown; UseDelay = component.UseDelay; Charges = component.Charges; - Provider = component.Provider; - EntityIcon = component.EntityIcon; + + // TODO ACTION REFACTOR fix bugs + if (entManager.TryGetNetEntity(component.Provider, out var provider)) + Provider = provider; + if (entManager.TryGetNetEntity(component.EntityIcon, out var icon)) + EntityIcon = icon; + if (entManager.TryGetNetEntity(component.AttachedEntity, out var attached)) + AttachedEntity = attached; + CheckCanInteract = component.CheckCanInteract; ClientExclusive = component.ClientExclusive; Priority = component.Priority; - AttachedEntity = component.AttachedEntity; AutoPopulate = component.AutoPopulate; AutoRemove = component.AutoRemove; Temporary = component.Temporary; diff --git a/Content.Shared/Actions/EntityTargetActionComponent.cs b/Content.Shared/Actions/EntityTargetActionComponent.cs index 33c4bf8cef..9024f42e0e 100644 --- a/Content.Shared/Actions/EntityTargetActionComponent.cs +++ b/Content.Shared/Actions/EntityTargetActionComponent.cs @@ -27,7 +27,7 @@ public sealed class EntityTargetActionComponentState : BaseActionComponentState public EntityWhitelist? Whitelist; public bool CanTargetSelf; - public EntityTargetActionComponentState(EntityTargetActionComponent component) : base(component) + public EntityTargetActionComponentState(EntityTargetActionComponent component, IEntityManager entManager) : base(component, entManager) { Whitelist = component.Whitelist; CanTargetSelf = component.CanTargetSelf; diff --git a/Content.Shared/Actions/InstantActionComponent.cs b/Content.Shared/Actions/InstantActionComponent.cs index f97ca04a46..04c9b94556 100644 --- a/Content.Shared/Actions/InstantActionComponent.cs +++ b/Content.Shared/Actions/InstantActionComponent.cs @@ -19,7 +19,7 @@ public sealed partial class InstantActionComponent : BaseActionComponent [Serializable, NetSerializable] public sealed class InstantActionComponentState : BaseActionComponentState { - public InstantActionComponentState(InstantActionComponent component) : base(component) + public InstantActionComponentState(InstantActionComponent component, IEntityManager entManager) : base(component, entManager) { } } diff --git a/Content.Shared/Actions/SharedActionsSystem.cs b/Content.Shared/Actions/SharedActionsSystem.cs index 12e5c2260a..3d476dd48c 100644 --- a/Content.Shared/Actions/SharedActionsSystem.cs +++ b/Content.Shared/Actions/SharedActionsSystem.cs @@ -65,20 +65,20 @@ public abstract class SharedActionsSystem : EntitySystem private void OnInstantGetState(EntityUid uid, InstantActionComponent component, ref ComponentGetState args) { - args.State = new InstantActionComponentState(component); + args.State = new InstantActionComponentState(component, EntityManager); } private void OnEntityTargetGetState(EntityUid uid, EntityTargetActionComponent component, ref ComponentGetState args) { - args.State = new EntityTargetActionComponentState(component); + args.State = new EntityTargetActionComponentState(component, EntityManager); } private void OnWorldTargetGetState(EntityUid uid, WorldTargetActionComponent component, ref ComponentGetState args) { - args.State = new WorldTargetActionComponentState(component); + args.State = new WorldTargetActionComponentState(component, EntityManager); } - private void BaseHandleState(BaseActionComponent component, BaseActionComponentState state) + private void BaseHandleState(EntityUid uid, BaseActionComponent component, BaseActionComponentState state) where T : BaseActionComponent { component.Icon = state.Icon; component.IconOn = state.IconOn; @@ -89,12 +89,12 @@ public abstract class SharedActionsSystem : EntitySystem component.Cooldown = state.Cooldown; component.UseDelay = state.UseDelay; component.Charges = state.Charges; - component.Provider = state.Provider; - component.EntityIcon = state.EntityIcon; + component.Provider = EnsureEntity(state.Provider, uid); + component.EntityIcon = EnsureEntity(state.EntityIcon, uid); component.CheckCanInteract = state.CheckCanInteract; component.ClientExclusive = state.ClientExclusive; component.Priority = state.Priority; - component.AttachedEntity = state.AttachedEntity; + component.AttachedEntity = EnsureEntity(state.AttachedEntity, uid); component.AutoPopulate = state.AutoPopulate; component.AutoRemove = state.AutoRemove; component.Temporary = state.Temporary; @@ -107,7 +107,7 @@ public abstract class SharedActionsSystem : EntitySystem if (args.Current is not InstantActionComponentState state) return; - BaseHandleState(component, state); + BaseHandleState(uid, component, state); } private void OnEntityTargetHandleState(EntityUid uid, EntityTargetActionComponent component, ref ComponentHandleState args) @@ -115,7 +115,7 @@ public abstract class SharedActionsSystem : EntitySystem if (args.Current is not EntityTargetActionComponentState state) return; - BaseHandleState(component, state); + BaseHandleState(uid, component, state); component.Whitelist = state.Whitelist; component.CanTargetSelf = state.CanTargetSelf; } @@ -125,7 +125,7 @@ public abstract class SharedActionsSystem : EntitySystem if (args.Current is not WorldTargetActionComponentState state) return; - BaseHandleState(component, state); + BaseHandleState(uid, component, state); } private void OnGetActionData(EntityUid uid, T component, ref GetActionDataEvent args) where T : BaseActionComponent @@ -177,7 +177,7 @@ public abstract class SharedActionsSystem : EntitySystem protected bool TryGetContainer( EntityUid holderId, - [NotNullWhen(true)] out IContainer? container, + [NotNullWhen(true)] out BaseContainer? container, ContainerManagerComponent? containerManager = null) { return _containerSystem.TryGetContainer(holderId, ActionContainerId, out container, containerManager); @@ -185,7 +185,7 @@ public abstract class SharedActionsSystem : EntitySystem protected bool TryGetProvidedContainer( EntityUid providerId, - [NotNullWhen(true)] out IContainer? container, + [NotNullWhen(true)] out BaseContainer? container, ContainerManagerComponent? containerManager = null) { return _containerSystem.TryGetContainer(providerId, ProvidedActionContainerId, out container, containerManager); @@ -215,7 +215,9 @@ public abstract class SharedActionsSystem : EntitySystem if (action.AttachedEntity == null) return; - if (!TryComp(action.AttachedEntity, out ActionsComponent? comp)) + var ent = action.AttachedEntity; + + if (!TryComp(ent, out ActionsComponent? comp)) { action.AttachedEntity = null; return; @@ -267,7 +269,7 @@ public abstract class SharedActionsSystem : EntitySystem private void OnActionsGetState(EntityUid uid, ActionsComponent component, ref ComponentGetState args) { - args.State = new ActionsComponentState(component.Actions); + args.State = new ActionsComponentState(GetNetEntitySet(component.Actions)); } private void OnActionsShutdown(EntityUid uid, ActionsComponent component, ComponentShutdown args) @@ -291,20 +293,22 @@ public abstract class SharedActionsSystem : EntitySystem if (!TryComp(user, out ActionsComponent? component)) return; - if (!TryComp(ev.Action, out MetaDataComponent? metaData)) + var actionEnt = GetEntity(ev.Action); + + if (!TryComp(actionEnt, out MetaDataComponent? metaData)) return; - var name = Name(ev.Action, metaData); + var name = Name(actionEnt, metaData); // Does the user actually have the requested action? - if (!component.Actions.Contains(ev.Action)) + if (!component.Actions.Contains(actionEnt)) { _adminLogger.Add(LogType.Action, $"{ToPrettyString(user):user} attempted to perform an action that they do not have: {name}."); return; } - var action = GetActionData(ev.Action); + var action = GetActionData(actionEnt); if (action == null || !action.Enabled) return; @@ -318,12 +322,14 @@ public abstract class SharedActionsSystem : EntitySystem switch (action) { case EntityTargetActionComponent entityAction: - if (ev.EntityTarget is not { Valid: true } entityTarget) + if (ev.EntityTarget is not { Valid: true } netTarget) { Log.Error($"Attempted to perform an entity-targeted action without a target! Action: {name}"); return; } + var entityTarget = GetEntity(netTarget); + var targetWorldPos = _transformSystem.GetWorldPosition(entityTarget); _rotateToFaceSystem.TryFaceCoordinates(user, targetWorldPos); @@ -344,18 +350,19 @@ public abstract class SharedActionsSystem : EntitySystem if (entityAction.Event != null) { entityAction.Event.Target = entityTarget; - Dirty(ev.Action, entityAction); + Dirty(actionEnt, entityAction); performEvent = entityAction.Event; } break; case WorldTargetActionComponent worldAction: - if (ev.EntityCoordinatesTarget is not { } entityCoordinatesTarget) + if (ev.EntityCoordinatesTarget is not { } netCoordinatesTarget) { Log.Error($"Attempted to perform a world-targeted action without a target! Action: {name}"); return; } + var entityCoordinatesTarget = GetCoordinates(netCoordinatesTarget); _rotateToFaceSystem.TryFaceCoordinates(user, entityCoordinatesTarget.Position); if (!ValidateWorldTarget(user, entityCoordinatesTarget, worldAction)) @@ -375,7 +382,7 @@ public abstract class SharedActionsSystem : EntitySystem if (worldAction.Event != null) { worldAction.Event.Target = entityCoordinatesTarget; - Dirty(ev.Action, worldAction); + Dirty(actionEnt, worldAction); performEvent = worldAction.Event; } @@ -403,7 +410,7 @@ public abstract class SharedActionsSystem : EntitySystem performEvent.Performer = user; // All checks passed. Perform the action! - PerformAction(user, component, ev.Action, action, performEvent, curTime); + PerformAction(user, component, actionEnt, action, performEvent, curTime); } public bool ValidateEntityTarget(EntityUid user, EntityUid target, EntityTargetActionComponent action) @@ -477,11 +484,12 @@ public abstract class SharedActionsSystem : EntitySystem { // This here is required because of client-side prediction (RaisePredictiveEvent results in event re-use). actionEvent.Handled = false; + var provider = action.Provider; - if (action.Provider == null) + if (provider == null) RaiseLocalEvent(performer, (object) actionEvent, broadcast: true); else - RaiseLocalEvent(action.Provider.Value, (object) actionEvent, broadcast: true); + RaiseLocalEvent(provider.Value, (object) actionEvent, broadcast: true); handled = actionEvent.Handled; } @@ -550,7 +558,7 @@ public abstract class SharedActionsSystem : EntitySystem /// Component of /// Component of /// Action container of - public virtual void AddAction(EntityUid holderId, EntityUid actionId, EntityUid? provider, ActionsComponent? holder = null, BaseActionComponent? action = null, bool dirty = true, IContainer? actionContainer = null) + public virtual void AddAction(EntityUid holderId, EntityUid actionId, EntityUid? provider, ActionsComponent? holder = null, BaseActionComponent? action = null, bool dirty = true, BaseContainer? actionContainer = null) { action ??= GetActionData(actionId); // TODO remove when action subscriptions are split up @@ -572,7 +580,7 @@ public abstract class SharedActionsSystem : EntitySystem Dirty(holderId, holder); } - protected virtual void AddActionInternal(EntityUid holderId, EntityUid actionId, IContainer container, ActionsComponent holder) + protected virtual void AddActionInternal(EntityUid holderId, EntityUid actionId, BaseContainer container, ActionsComponent holder) { container.Insert(actionId); holder.Actions.Add(actionId); diff --git a/Content.Shared/Actions/WorldTargetActionComponent.cs b/Content.Shared/Actions/WorldTargetActionComponent.cs index f2ee34f530..4974b4478d 100644 --- a/Content.Shared/Actions/WorldTargetActionComponent.cs +++ b/Content.Shared/Actions/WorldTargetActionComponent.cs @@ -19,7 +19,7 @@ public sealed partial class WorldTargetActionComponent : BaseTargetActionCompone [Serializable, NetSerializable] public sealed class WorldTargetActionComponentState : BaseActionComponentState { - public WorldTargetActionComponentState(WorldTargetActionComponent component) : base(component) + public WorldTargetActionComponentState(WorldTargetActionComponent component, IEntityManager entManager) : base(component, entManager) { } } diff --git a/Content.Shared/Administration/EditSolutionsEuiState.cs b/Content.Shared/Administration/EditSolutionsEuiState.cs index 218202ff3d..782c4b84f2 100644 --- a/Content.Shared/Administration/EditSolutionsEuiState.cs +++ b/Content.Shared/Administration/EditSolutionsEuiState.cs @@ -7,10 +7,10 @@ namespace Content.Shared.Administration [Serializable, NetSerializable] public sealed class EditSolutionsEuiState : EuiStateBase { - public readonly EntityUid Target; + public readonly NetEntity Target; public readonly Dictionary? Solutions; - public EditSolutionsEuiState(EntityUid target, Dictionary? solutions) + public EditSolutionsEuiState(NetEntity target, Dictionary? solutions) { Target = target; Solutions = solutions; diff --git a/Content.Shared/Administration/PlayerInfo.cs b/Content.Shared/Administration/PlayerInfo.cs index d6b3f0c0dc..bc1195dc47 100644 --- a/Content.Shared/Administration/PlayerInfo.cs +++ b/Content.Shared/Administration/PlayerInfo.cs @@ -10,7 +10,7 @@ namespace Content.Shared.Administration string IdentityName, string StartingJob, bool Antag, - EntityUid? EntityUid, + NetEntity? NetEntity, NetUserId SessionId, bool Connected, bool ActiveThisRound); diff --git a/Content.Shared/Administration/SetOutfitEuiState.cs b/Content.Shared/Administration/SetOutfitEuiState.cs index 495543509e..f1b4837859 100644 --- a/Content.Shared/Administration/SetOutfitEuiState.cs +++ b/Content.Shared/Administration/SetOutfitEuiState.cs @@ -6,6 +6,6 @@ namespace Content.Shared.Administration [Serializable, NetSerializable] public sealed class SetOutfitEuiState : EuiStateBase { - public EntityUid TargetEntityId; + public NetEntity TargetNetEntity; } } diff --git a/Content.Shared/Atmos/Components/GasAnalyzerComponent.cs b/Content.Shared/Atmos/Components/GasAnalyzerComponent.cs index 852b6c6a7a..51ae8cc740 100644 --- a/Content.Shared/Atmos/Components/GasAnalyzerComponent.cs +++ b/Content.Shared/Atmos/Components/GasAnalyzerComponent.cs @@ -32,11 +32,11 @@ public sealed partial class GasAnalyzerComponent : Component public sealed class GasAnalyzerUserMessage : BoundUserInterfaceMessage { public string DeviceName; - public EntityUid DeviceUid; + public NetEntity DeviceUid; public bool DeviceFlipped; public string? Error; public GasMixEntry[] NodeGasMixes; - public GasAnalyzerUserMessage(GasMixEntry[] nodeGasMixes, string deviceName, EntityUid deviceUid, bool deviceFlipped, string? error = null) + public GasAnalyzerUserMessage(GasMixEntry[] nodeGasMixes, string deviceName, NetEntity deviceUid, bool deviceFlipped, string? error = null) { NodeGasMixes = nodeGasMixes; DeviceName = deviceName; diff --git a/Content.Shared/Atmos/EntitySystems/SharedAtmosDebugOverlaySystem.cs b/Content.Shared/Atmos/EntitySystems/SharedAtmosDebugOverlaySystem.cs index 4abdc2131f..d52c6a4ae7 100644 --- a/Content.Shared/Atmos/EntitySystems/SharedAtmosDebugOverlaySystem.cs +++ b/Content.Shared/Atmos/EntitySystems/SharedAtmosDebugOverlaySystem.cs @@ -39,13 +39,13 @@ namespace Content.Shared.Atmos.EntitySystems [Serializable, NetSerializable] public sealed class AtmosDebugOverlayMessage : EntityEventArgs { - public EntityUid GridId { get; } + public NetEntity GridId { get; } public Vector2i BaseIdx { get; } // LocalViewRange*LocalViewRange public AtmosDebugOverlayData[] OverlayData { get; } - public AtmosDebugOverlayMessage(EntityUid gridIndices, Vector2i baseIdx, AtmosDebugOverlayData[] overlayData) + public AtmosDebugOverlayMessage(NetEntity gridIndices, Vector2i baseIdx, AtmosDebugOverlayData[] overlayData) { GridId = gridIndices; BaseIdx = baseIdx; diff --git a/Content.Shared/Atmos/EntitySystems/SharedGasTileOverlaySystem.cs b/Content.Shared/Atmos/EntitySystems/SharedGasTileOverlaySystem.cs index b4722fb53f..eb0079eb35 100644 --- a/Content.Shared/Atmos/EntitySystems/SharedGasTileOverlaySystem.cs +++ b/Content.Shared/Atmos/EntitySystems/SharedGasTileOverlaySystem.cs @@ -103,8 +103,8 @@ namespace Content.Shared.Atmos.EntitySystems [Serializable, NetSerializable] public sealed class GasOverlayUpdateEvent : EntityEventArgs { - public Dictionary> UpdatedChunks = new(); - public Dictionary> RemovedChunks = new(); + public Dictionary> UpdatedChunks = new(); + public Dictionary> RemovedChunks = new(); } } } diff --git a/Content.Shared/Beam/Components/SharedBeamComponent.cs b/Content.Shared/Beam/Components/SharedBeamComponent.cs index 7cd5da1610..9c5c5dd344 100644 --- a/Content.Shared/Beam/Components/SharedBeamComponent.cs +++ b/Content.Shared/Beam/Components/SharedBeamComponent.cs @@ -97,13 +97,13 @@ public sealed class BeamFiredEvent : EntityEventArgs [Serializable, NetSerializable] public sealed class BeamVisualizerEvent : EntityEventArgs { - public readonly EntityUid Beam; + public readonly NetEntity Beam; public readonly float DistanceLength; public readonly Angle UserAngle; public readonly string? BodyState; public readonly string Shader = "unshaded"; - public BeamVisualizerEvent(EntityUid beam, float distanceLength, Angle userAngle, string? bodyState = null, string shader = "unshaded") + public BeamVisualizerEvent(NetEntity beam, float distanceLength, Angle userAngle, string? bodyState = null, string shader = "unshaded") { Beam = beam; DistanceLength = distanceLength; diff --git a/Content.Shared/Body/Organ/OrganComponentState.cs b/Content.Shared/Body/Organ/OrganComponentState.cs index 821c2c2e5b..6ca323fd13 100644 --- a/Content.Shared/Body/Organ/OrganComponentState.cs +++ b/Content.Shared/Body/Organ/OrganComponentState.cs @@ -5,10 +5,10 @@ namespace Content.Shared.Body.Organ; [Serializable, NetSerializable] public sealed class OrganComponentState : ComponentState { - public readonly EntityUid? Body; + public readonly NetEntity? Body; public readonly OrganSlot? Parent; - public OrganComponentState(EntityUid? body, OrganSlot? parent) + public OrganComponentState(NetEntity? body, OrganSlot? parent) { Body = body; Parent = parent; diff --git a/Content.Shared/Body/Organ/OrganSlot.cs b/Content.Shared/Body/Organ/OrganSlot.cs index 924e4f8aaf..e67c9852bc 100644 --- a/Content.Shared/Body/Organ/OrganSlot.cs +++ b/Content.Shared/Body/Organ/OrganSlot.cs @@ -5,10 +5,23 @@ namespace Content.Shared.Body.Organ; [Serializable, NetSerializable] [Access(typeof(SharedBodySystem))] -[DataRecord] -public sealed record OrganSlot(string Id, EntityUid Parent) +[DataDefinition] +public sealed partial record OrganSlot { - public EntityUid? Child { get; set; } + [DataField("id")] + public string Id = string.Empty; + + [NonSerialized] + [DataField("parent")] + public EntityUid Parent; + + public NetEntity NetParent; + + [NonSerialized] + [DataField("child")] + public EntityUid? Child; + + public NetEntity? NetChild; // Rider doesn't suggest explicit properties during deconstruction without this public void Deconstruct(out EntityUid? child, out string id, out EntityUid parent) diff --git a/Content.Shared/Body/Part/BodyPartComponentState.cs b/Content.Shared/Body/Part/BodyPartComponentState.cs index bd3cf55efd..e50ecdda12 100644 --- a/Content.Shared/Body/Part/BodyPartComponentState.cs +++ b/Content.Shared/Body/Part/BodyPartComponentState.cs @@ -6,7 +6,7 @@ namespace Content.Shared.Body.Part; [Serializable, NetSerializable] public sealed class BodyPartComponentState : ComponentState { - public readonly EntityUid? Body; + public readonly NetEntity? Body; public readonly BodyPartSlot? ParentSlot; public readonly Dictionary Children; public readonly Dictionary Organs; @@ -15,7 +15,7 @@ public sealed class BodyPartComponentState : ComponentState public readonly BodyPartSymmetry Symmetry; public BodyPartComponentState( - EntityUid? body, + NetEntity? body, BodyPartSlot? parentSlot, Dictionary children, Dictionary organs, diff --git a/Content.Shared/Body/Part/BodyPartSlot.cs b/Content.Shared/Body/Part/BodyPartSlot.cs index da80a6d832..8f6348ce33 100644 --- a/Content.Shared/Body/Part/BodyPartSlot.cs +++ b/Content.Shared/Body/Part/BodyPartSlot.cs @@ -5,10 +5,32 @@ namespace Content.Shared.Body.Part; [Serializable, NetSerializable] [Access(typeof(SharedBodySystem))] -[DataRecord] -public sealed record BodyPartSlot(string Id, EntityUid Parent, BodyPartType? Type) +[DataDefinition] +public sealed partial record BodyPartSlot { - public EntityUid? Child { get; set; } + [DataField("id")] + public string Id = string.Empty; + + [DataField("type")] + public BodyPartType? Type; + + [NonSerialized] + [DataField("parent")] + public EntityUid Parent; + + public NetEntity NetParent; + + [NonSerialized] + [DataField("child")] + public EntityUid? Child; + + public NetEntity? NetChild; + + public void SetChild(EntityUid? child, NetEntity? netChild) + { + Child = child; + NetChild = netChild; + } // Rider doesn't suggest explicit properties during deconstruction without this public void Deconstruct(out EntityUid? child, out string id, out EntityUid parent, out BodyPartType? type) diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Body.cs b/Content.Shared/Body/Systems/SharedBodySystem.Body.cs index 151f287cdb..9519faf0f1 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Body.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Body.cs @@ -38,7 +38,7 @@ public partial class SharedBodySystem var prototype = Prototypes.Index(body.Prototype); - if (!_netManager.IsClient || bodyId.IsClientSide()) + if (!_netManager.IsClient || IsClientSide(bodyId)) InitBody(body, prototype); Dirty(body); // Client doesn't actually spawn the body, need to sync it @@ -72,7 +72,12 @@ public partial class SharedBodySystem body.Root != null) return false; - slot = new BodyPartSlot(slotId, bodyId.Value, null); + slot = new BodyPartSlot + { + Id = slotId, + Parent = bodyId.Value, + NetParent = GetNetEntity(bodyId.Value), + }; body.Root = slot; return true; @@ -86,7 +91,13 @@ public partial class SharedBodySystem return; var bodyId = Spawn(root.Part, body.Owner.ToCoordinates()); var partComponent = Comp(bodyId); - var slot = new BodyPartSlot(root.Part, body.Owner, partComponent.PartType); + var slot = new BodyPartSlot + { + Id = root.Part, + Type = partComponent.PartType, + Parent = body.Owner, + NetParent = GetNetEntity(body.Owner), + }; body.Root = slot; partComponent.Body = bodyId; diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Organs.cs b/Content.Shared/Body/Systems/SharedBodySystem.Organs.cs index dbfadc6a0f..57fea15ba4 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Organs.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Organs.cs @@ -12,6 +12,8 @@ namespace Content.Shared.Body.Systems; public partial class SharedBodySystem { + [Dependency] private readonly SharedContainerSystem _container = default!; + private void InitializeOrgans() { SubscribeLocalEvent(OnOrganGetState); @@ -23,7 +25,12 @@ public partial class SharedBodySystem if (!Resolve(parent, ref part, false)) return null; - var slot = new OrganSlot(slotId, parent); + var slot = new OrganSlot() + { + Id = slotId, + Parent = parent, + NetParent = GetNetEntity(parent), + }; part.Organs.Add(slotId, slot); return slot; @@ -35,12 +42,12 @@ public partial class SharedBodySystem slot.Child == null && Resolve(organId.Value, ref organ, false) && Containers.TryGetContainer(slot.Parent, BodyContainerId, out var container) && - container.CanInsert(organId.Value); + _container.CanInsert(organId.Value, container); } private void OnOrganGetState(EntityUid uid, OrganComponent organ, ref ComponentGetState args) { - args.State = new OrganComponentState(organ.Body, organ.ParentSlot); + args.State = new OrganComponentState(GetNetEntity(organ.Body), organ.ParentSlot); } private void OnOrganHandleState(EntityUid uid, OrganComponent organ, ref ComponentHandleState args) @@ -48,7 +55,7 @@ public partial class SharedBodySystem if (args.Current is not OrganComponentState state) return; - organ.Body = state.Body; + organ.Body = EnsureEntity(state.Body, uid); organ.ParentSlot = state.Parent; } diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs b/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs index 8c55fe9cdd..b58a9cefd2 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs @@ -26,7 +26,7 @@ public partial class SharedBodySystem private void OnPartGetState(EntityUid uid, BodyPartComponent part, ref ComponentGetState args) { args.State = new BodyPartComponentState( - part.Body, + GetNetEntity(part.Body), part.ParentSlot, part.Children, part.Organs, @@ -41,7 +41,7 @@ public partial class SharedBodySystem if (args.Current is not BodyPartComponentState state) return; - part.Body = state.Body; + part.Body = EnsureEntity(state.Body, uid); part.ParentSlot = state.ParentSlot; // TODO use containers. This is broken and does not work. part.Children = state.Children; // TODO use containers. This is broken and does not work. part.Organs = state.Organs; // TODO end my suffering. @@ -54,7 +54,7 @@ public partial class SharedBodySystem { if (part.ParentSlot is { } slot) { - slot.Child = null; + slot.SetChild(null, GetNetEntity(null)); DirtyAllComponents(slot.Parent); } @@ -73,7 +73,13 @@ public partial class SharedBodySystem if (!Resolve(parent, ref part, false)) return null; - var slot = new BodyPartSlot(slotId, parent, partType); + var slot = new BodyPartSlot + { + Id = slotId, + Type = partType, + Parent = parent, + NetParent = GetNetEntity(parent), + }; part.Children.Add(slotId, slot); return slot; @@ -91,7 +97,12 @@ public partial class SharedBodySystem !Resolve(parentId.Value, ref parent, false)) return false; - slot = new BodyPartSlot(id, parentId.Value, null); + slot = new BodyPartSlot + { + Id = id, + Parent = parentId.Value, + NetParent = GetNetEntity(parentId.Value), + }; if (!parent.Children.TryAdd(id, slot)) { slot = null; @@ -171,7 +182,7 @@ public partial class SharedBodySystem Resolve(partId.Value, ref part, false) && (slot.Type == null || slot.Type == part.PartType) && Containers.TryGetContainer(slot.Parent, BodyContainerId, out var container) && - container.CanInsert(partId.Value); + _container.CanInsert(partId.Value, container); } public virtual bool AttachPart( @@ -191,7 +202,7 @@ public partial class SharedBodySystem if (!container.Insert(partId.Value)) return false; - slot.Child = partId; + slot.SetChild(partId, GetNetEntity(partId)); part.ParentSlot = slot; if (TryComp(slot.Parent, out BodyPartComponent? parentPart)) @@ -241,7 +252,7 @@ public partial class SharedBodySystem var oldBodyNullable = part.Body; - slot.Child = null; + slot.SetChild(null, null); part.ParentSlot = null; part.Body = null; diff --git a/Content.Shared/Bql/ToolshedVisualizeEuiState.cs b/Content.Shared/Bql/ToolshedVisualizeEuiState.cs index 9505854614..64595f6ecf 100644 --- a/Content.Shared/Bql/ToolshedVisualizeEuiState.cs +++ b/Content.Shared/Bql/ToolshedVisualizeEuiState.cs @@ -6,9 +6,9 @@ namespace Content.Shared.Bql; [Serializable, NetSerializable] public sealed class ToolshedVisualizeEuiState : EuiStateBase { - public readonly (string name, EntityUid entity)[] Entities; + public readonly (string name, NetEntity entity)[] Entities; - public ToolshedVisualizeEuiState((string name, EntityUid entity)[] entities) + public ToolshedVisualizeEuiState((string name, NetEntity entity)[] entities) { Entities = entities; } diff --git a/Content.Shared/Buckle/Components/BuckleComponent.cs b/Content.Shared/Buckle/Components/BuckleComponent.cs index f477f646e2..8f44c7fead 100644 --- a/Content.Shared/Buckle/Components/BuckleComponent.cs +++ b/Content.Shared/Buckle/Components/BuckleComponent.cs @@ -78,7 +78,7 @@ public sealed partial class BuckleComponent : Component [Serializable, NetSerializable] public sealed class BuckleComponentState : ComponentState { - public BuckleComponentState(bool buckled, EntityUid? buckledTo, EntityUid? lastEntityBuckledTo, + public BuckleComponentState(bool buckled, NetEntity? buckledTo, NetEntity? lastEntityBuckledTo, bool dontCollide) { Buckled = buckled; @@ -88,8 +88,8 @@ public sealed class BuckleComponentState : ComponentState } public readonly bool Buckled; - public readonly EntityUid? BuckledTo; - public readonly EntityUid? LastEntityBuckledTo; + public readonly NetEntity? BuckledTo; + public readonly NetEntity? LastEntityBuckledTo; public readonly bool DontCollide; } diff --git a/Content.Shared/Buckle/Components/StrapComponent.cs b/Content.Shared/Buckle/Components/StrapComponent.cs index 3ffbe86c3b..8cb11ddd43 100644 --- a/Content.Shared/Buckle/Components/StrapComponent.cs +++ b/Content.Shared/Buckle/Components/StrapComponent.cs @@ -125,10 +125,10 @@ public sealed class StrapComponentState : ComponentState public readonly StrapPosition Position; public readonly float MaxBuckleDistance; public readonly Vector2 BuckleOffsetClamped; - public readonly HashSet BuckledEntities; + public readonly HashSet BuckledEntities; public readonly int OccupiedSize; - public StrapComponentState(StrapPosition position, Vector2 offset, HashSet buckled, + public StrapComponentState(StrapPosition position, Vector2 offset, HashSet buckled, float maxBuckleDistance, int occupiedSize) { Position = position; diff --git a/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs b/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs index 935bd18b40..e4b9e4391f 100644 --- a/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs +++ b/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs @@ -59,7 +59,7 @@ public abstract partial class SharedBuckleSystem private void OnBuckleComponentGetState(EntityUid uid, BuckleComponent component, ref ComponentGetState args) { - args.State = new BuckleComponentState(component.Buckled, component.BuckledTo, component.LastEntityBuckledTo, component.DontCollide); + args.State = new BuckleComponentState(component.Buckled, GetNetEntity(component.BuckledTo), GetNetEntity(component.LastEntityBuckledTo), component.DontCollide); } private void OnBuckleMove(EntityUid uid, BuckleComponent component, ref MoveEvent ev) diff --git a/Content.Shared/Buckle/SharedBuckleSystem.Strap.cs b/Content.Shared/Buckle/SharedBuckleSystem.Strap.cs index 1549129dc0..423a829809 100644 --- a/Content.Shared/Buckle/SharedBuckleSystem.Strap.cs +++ b/Content.Shared/Buckle/SharedBuckleSystem.Strap.cs @@ -52,7 +52,7 @@ public abstract partial class SharedBuckleSystem private void OnStrapGetState(EntityUid uid, StrapComponent component, ref ComponentGetState args) { - args.State = new StrapComponentState(component.Position, component.BuckleOffset, component.BuckledEntities, component.MaxBuckleDistance, component.OccupiedSize); + args.State = new StrapComponentState(component.Position, component.BuckleOffset, GetNetEntitySet(component.BuckledEntities), component.MaxBuckleDistance, component.OccupiedSize); } private void OnStrapHandleState(EntityUid uid, StrapComponent component, ref ComponentHandleState args) @@ -63,7 +63,7 @@ public abstract partial class SharedBuckleSystem component.Position = state.Position; component.BuckleOffsetUnclamped = state.BuckleOffsetClamped; component.BuckledEntities.Clear(); - component.BuckledEntities.UnionWith(state.BuckledEntities); + component.BuckledEntities.UnionWith(EnsureEntitySet(state.BuckledEntities, uid)); component.MaxBuckleDistance = state.MaxBuckleDistance; component.OccupiedSize = state.OccupiedSize; } diff --git a/Content.Shared/Camera/SharedCameraRecoilSystem.cs b/Content.Shared/Camera/SharedCameraRecoilSystem.cs index 3a5fe372e2..ec57524c05 100644 --- a/Content.Shared/Camera/SharedCameraRecoilSystem.cs +++ b/Content.Shared/Camera/SharedCameraRecoilSystem.cs @@ -82,12 +82,12 @@ public abstract class SharedCameraRecoilSystem : EntitySystem [NetSerializable] public sealed class CameraKickEvent : EntityEventArgs { - public readonly EntityUid Euid; + public readonly NetEntity NetEntity; public readonly Vector2 Recoil; - public CameraKickEvent(EntityUid euid, Vector2 recoil) + public CameraKickEvent(NetEntity netEntity, Vector2 recoil) { Recoil = recoil; - Euid = euid; + NetEntity = netEntity; } } diff --git a/Content.Shared/CardboardBox/Components/CardboardBoxComponent.cs b/Content.Shared/CardboardBox/Components/CardboardBoxComponent.cs index fb663af720..0e607f5076 100644 --- a/Content.Shared/CardboardBox/Components/CardboardBoxComponent.cs +++ b/Content.Shared/CardboardBox/Components/CardboardBoxComponent.cs @@ -61,10 +61,10 @@ public sealed partial class CardboardBoxComponent : Component [Serializable, NetSerializable] public sealed class PlayBoxEffectMessage : EntityEventArgs { - public EntityUid Source; - public EntityUid Mover; + public NetEntity Source; + public NetEntity Mover; - public PlayBoxEffectMessage(EntityUid source, EntityUid mover) + public PlayBoxEffectMessage(NetEntity source, NetEntity mover) { Source = source; Mover = mover; diff --git a/Content.Shared/CartridgeLoader/CartridgeLoaderComponent.cs b/Content.Shared/CartridgeLoader/CartridgeLoaderComponent.cs index 5a7c40f3d1..5ff5fdd9a3 100644 --- a/Content.Shared/CartridgeLoader/CartridgeLoaderComponent.cs +++ b/Content.Shared/CartridgeLoader/CartridgeLoaderComponent.cs @@ -14,7 +14,7 @@ public sealed partial class CartridgeLoaderComponent : Component /// /// List of programs that come preinstalled with this cartridge loader /// - [DataField("preinstalled")] + [DataField("preinstalled")] // TODO remove this and use container fill. public List PreinstalledPrograms = new(); /// @@ -29,12 +29,6 @@ public sealed partial class CartridgeLoaderComponent : Component [ViewVariables] public readonly List BackgroundPrograms = new(); - /// - /// The list of program entities that are spawned into the cartridge loaders program container - /// - [DataField("installedCartridges")] - public List InstalledPrograms = new(); - /// /// The maximum amount of programs that can be installed on the cartridge loader entity /// diff --git a/Content.Shared/CartridgeLoader/CartridgeLoaderUiMessage.cs b/Content.Shared/CartridgeLoader/CartridgeLoaderUiMessage.cs index 5f7aaec026..18c5cf9f91 100644 --- a/Content.Shared/CartridgeLoader/CartridgeLoaderUiMessage.cs +++ b/Content.Shared/CartridgeLoader/CartridgeLoaderUiMessage.cs @@ -5,10 +5,10 @@ namespace Content.Shared.CartridgeLoader; [Serializable, NetSerializable] public sealed class CartridgeLoaderUiMessage : BoundUserInterfaceMessage { - public readonly EntityUid CartridgeUid; + public readonly NetEntity CartridgeUid; public readonly CartridgeUiMessageAction Action; - public CartridgeLoaderUiMessage(EntityUid cartridgeUid, CartridgeUiMessageAction action) + public CartridgeLoaderUiMessage(NetEntity cartridgeUid, CartridgeUiMessageAction action) { CartridgeUid = cartridgeUid; Action = action; diff --git a/Content.Shared/CartridgeLoader/CartridgeLoaderUiState.cs b/Content.Shared/CartridgeLoader/CartridgeLoaderUiState.cs index 2e7a961c96..0bc3f66a57 100644 --- a/Content.Shared/CartridgeLoader/CartridgeLoaderUiState.cs +++ b/Content.Shared/CartridgeLoader/CartridgeLoaderUiState.cs @@ -7,6 +7,12 @@ namespace Content.Shared.CartridgeLoader; [Serializable, NetSerializable] public class CartridgeLoaderUiState : BoundUserInterfaceState { - public EntityUid? ActiveUI; - public List Programs = new(); + public NetEntity? ActiveUI; + public List Programs; + + public CartridgeLoaderUiState(List programs, NetEntity? activeUI) + { + Programs = programs; + ActiveUI = activeUI; + } } diff --git a/Content.Shared/CartridgeLoader/CartridgeUiMessage.cs b/Content.Shared/CartridgeLoader/CartridgeUiMessage.cs index 537fa1c921..1155030f93 100644 --- a/Content.Shared/CartridgeLoader/CartridgeUiMessage.cs +++ b/Content.Shared/CartridgeLoader/CartridgeUiMessage.cs @@ -16,5 +16,5 @@ public sealed class CartridgeUiMessage : BoundUserInterfaceMessage [Serializable, NetSerializable] public abstract class CartridgeMessageEvent : EntityEventArgs { - public EntityUid LoaderUid; + public NetEntity LoaderUid; } diff --git a/Content.Shared/CartridgeLoader/Cartridges/NotekeeperUiState.cs b/Content.Shared/CartridgeLoader/Cartridges/NotekeeperUiState.cs index c71dd0fff0..52c86936ec 100644 --- a/Content.Shared/CartridgeLoader/Cartridges/NotekeeperUiState.cs +++ b/Content.Shared/CartridgeLoader/Cartridges/NotekeeperUiState.cs @@ -5,7 +5,7 @@ namespace Content.Shared.CartridgeLoader.Cartridges; [Serializable, NetSerializable] public sealed class NotekeeperUiState : BoundUserInterfaceState { - public List Notes; + public List Notes; public NotekeeperUiState(List notes) { diff --git a/Content.Shared/CartridgeLoader/SharedCartridgeLoaderSystem.cs b/Content.Shared/CartridgeLoader/SharedCartridgeLoaderSystem.cs index 0bd7c5ec16..15d29689b8 100644 --- a/Content.Shared/CartridgeLoader/SharedCartridgeLoaderSystem.cs +++ b/Content.Shared/CartridgeLoader/SharedCartridgeLoaderSystem.cs @@ -2,13 +2,18 @@ using Robust.Shared.Containers; using Robust.Shared.GameStates; using Robust.Shared.Map; +using Robust.Shared.Network; namespace Content.Shared.CartridgeLoader; public abstract class SharedCartridgeLoaderSystem : EntitySystem { + public const string InstalledContainerId = "program-container"; + [Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!; [Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!; + [Dependency] private readonly SharedContainerSystem _container = default!; + [Dependency] private readonly INetManager _netMan = default!; public override void Initialize() { @@ -36,11 +41,8 @@ public abstract class SharedCartridgeLoaderSystem : EntitySystem private void OnComponentRemove(EntityUid uid, CartridgeLoaderComponent loader, ComponentRemove args) { _itemSlotsSystem.RemoveItemSlot(uid, loader.CartridgeSlot); - - foreach (var program in loader.InstalledPrograms) - { - EntityManager.QueueDeleteEntity(program); - } + if (_container.TryGetContainer(uid, InstalledContainerId, out var cont)) + cont.Shutdown(EntityManager, _netMan); } protected virtual void OnItemInserted(EntityUid uid, CartridgeLoaderComponent loader, EntInsertedIntoContainerMessage args) diff --git a/Content.Shared/CharacterInfo/SharedCharacterInfoSystem.cs b/Content.Shared/CharacterInfo/SharedCharacterInfoSystem.cs index 89b55e54fa..b330af2629 100644 --- a/Content.Shared/CharacterInfo/SharedCharacterInfoSystem.cs +++ b/Content.Shared/CharacterInfo/SharedCharacterInfoSystem.cs @@ -6,25 +6,25 @@ namespace Content.Shared.CharacterInfo; [Serializable, NetSerializable] public sealed class RequestCharacterInfoEvent : EntityEventArgs { - public readonly EntityUid EntityUid; + public readonly NetEntity NetEntity; - public RequestCharacterInfoEvent(EntityUid entityUid) + public RequestCharacterInfoEvent(NetEntity netEntity) { - EntityUid = entityUid; + NetEntity = netEntity; } } [Serializable, NetSerializable] public sealed class CharacterInfoEvent : EntityEventArgs { - public readonly EntityUid EntityUid; + public readonly NetEntity NetEntity; public readonly string JobTitle; public readonly Dictionary> Objectives; public readonly string? Briefing; - public CharacterInfoEvent(EntityUid entityUid, string jobTitle, Dictionary> objectives, string? briefing) + public CharacterInfoEvent(NetEntity netEntity, string jobTitle, Dictionary> objectives, string? briefing) { - EntityUid = entityUid; + NetEntity = netEntity; JobTitle = jobTitle; Objectives = objectives; Briefing = briefing; diff --git a/Content.Shared/Chat/MsgChatMessage.cs b/Content.Shared/Chat/MsgChatMessage.cs index fee886b023..27ab203d6e 100644 --- a/Content.Shared/Chat/MsgChatMessage.cs +++ b/Content.Shared/Chat/MsgChatMessage.cs @@ -13,7 +13,7 @@ namespace Content.Shared.Chat public ChatChannel Channel; public string Message; public string WrappedMessage; - public EntityUid SenderEntity; + public NetEntity SenderEntity; public bool HideChat; public Color? MessageColorOverride; public string? AudioPath; @@ -22,7 +22,7 @@ namespace Content.Shared.Chat [NonSerialized] public bool Read; - public ChatMessage(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat = false, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0) + public ChatMessage(ChatChannel channel, string message, string wrappedMessage, NetEntity source, bool hideChat = false, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0) { Channel = channel; Message = message; diff --git a/Content.Shared/Climbing/BonkSystem.cs b/Content.Shared/Climbing/BonkSystem.cs index 25f3d7e33c..eda392fa31 100644 --- a/Content.Shared/Climbing/BonkSystem.cs +++ b/Content.Shared/Climbing/BonkSystem.cs @@ -76,7 +76,7 @@ public sealed partial class BonkSystem : EntitySystem if (args.Handled || !HasComp(args.Dragged)) return; - var doAfterArgs = new DoAfterArgs(args.Dragged, component.BonkDelay, new BonkDoAfterEvent(), uid, target: uid) + var doAfterArgs = new DoAfterArgs(EntityManager, args.Dragged, component.BonkDelay, new BonkDoAfterEvent(), uid, target: uid) { BreakOnTargetMove = true, BreakOnUserMove = true, diff --git a/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs b/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs index ae143e1f90..53f7284bbe 100644 --- a/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs +++ b/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs @@ -93,7 +93,7 @@ public sealed class ToggleableClothingSystem : EntitySystem var (time, stealth) = _strippable.GetStripTimeModifiers(user, wearer, (float) component.StripDelay.Value.TotalSeconds); - var args = new DoAfterArgs(user, time, new ToggleClothingDoAfterEvent(), item, wearer, item) + var args = new DoAfterArgs(EntityManager, user, time, new ToggleClothingDoAfterEvent(), item, wearer, item) { BreakOnDamage = true, BreakOnTargetMove = true, diff --git a/Content.Shared/Construction/Events.cs b/Content.Shared/Construction/Events.cs index f231407ff4..12f2c198a3 100644 --- a/Content.Shared/Construction/Events.cs +++ b/Content.Shared/Construction/Events.cs @@ -15,7 +15,7 @@ public sealed class TryStartStructureConstructionMessage : EntityEventArgs /// /// Position to start building. /// - public readonly EntityCoordinates Location; + public readonly NetCoordinates Location; /// /// The construction prototype to start building. @@ -27,9 +27,13 @@ public sealed class TryStartStructureConstructionMessage : EntityEventArgs /// /// Identifier to be sent back in the acknowledgement so that the client can clean up its ghost. /// + /// + /// So essentially the client is sending its own entity to the server so it knows to delete it when it gets server + /// response back. + /// public readonly int Ack; - public TryStartStructureConstructionMessage(EntityCoordinates loc, string prototypeName, Angle angle, int ack) + public TryStartStructureConstructionMessage(NetCoordinates loc, string prototypeName, Angle angle, int ack) { Location = loc; PrototypeName = prototypeName; @@ -67,9 +71,9 @@ public sealed class AckStructureConstructionMessage : EntityEventArgs /// /// The entity that is now being constructed, if any. /// - public readonly EntityUid? Uid; + public readonly NetEntity? Uid; - public AckStructureConstructionMessage(int ghostId, EntityUid? uid = null) + public AckStructureConstructionMessage(int ghostId, NetEntity? uid = null) { GhostId = ghostId; Uid = uid; @@ -110,15 +114,15 @@ public sealed class ResponseConstructionGuide : EntityEventArgs public sealed partial class ConstructionInteractDoAfterEvent : DoAfterEvent { [DataField("clickLocation")] - public EntityCoordinates ClickLocation; + public NetCoordinates ClickLocation; private ConstructionInteractDoAfterEvent() { } - public ConstructionInteractDoAfterEvent(InteractUsingEvent ev) + public ConstructionInteractDoAfterEvent(IEntityManager entManager, InteractUsingEvent ev) { - ClickLocation = ev.ClickLocation; + ClickLocation = entManager.GetNetCoordinates(ev.ClickLocation); } public override DoAfterEvent Clone() => this; diff --git a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs index 1d491a01ba..cb92892305 100644 --- a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs +++ b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs @@ -246,6 +246,9 @@ namespace Content.Shared.Containers.ItemSlots /// public bool CanInsert(EntityUid uid, EntityUid usedUid, EntityUid? user, ItemSlot slot, bool swap = false, EntityUid? popup = null) { + if (slot.ContainerSlot == null) + return false; + if (slot.Locked) return false; @@ -265,7 +268,7 @@ namespace Content.Shared.Containers.ItemSlots if (ev.Cancelled) return false; - return slot.ContainerSlot?.CanInsertIfEmpty(usedUid, EntityManager) ?? false; + return _containers.CanInsert(usedUid, slot.ContainerSlot, assumeEmpty: true); } /// @@ -325,16 +328,16 @@ namespace Content.Shared.Containers.ItemSlots public bool CanEject(EntityUid uid, EntityUid? user, ItemSlot slot) { - if (slot.Locked || slot.Item == null) + if (slot.Locked || slot.ContainerSlot?.ContainedEntity is not {} item) return false; - var ev = new ItemSlotEjectAttemptEvent(uid, slot.Item.Value, user, slot); + var ev = new ItemSlotEjectAttemptEvent(uid, item, user, slot); RaiseLocalEvent(uid, ref ev); - RaiseLocalEvent(slot.Item.Value, ref ev); + RaiseLocalEvent(item, ref ev); if (ev.Cancelled) return false; - return slot.ContainerSlot?.CanRemove(slot.Item.Value, EntityManager) ?? false; + return _containers.CanRemove(item, slot.ContainerSlot); } /// @@ -435,11 +438,13 @@ namespace Content.Shared.Containers.ItemSlots var verbSubject = slot.Name != string.Empty ? Loc.GetString(slot.Name) - : Name(args.Using.Value) ?? string.Empty; + : Name(args.Using.Value); - AlternativeVerb verb = new(); - verb.IconEntity = args.Using; - verb.Act = () => Insert(uid, slot, args.Using.Value, args.User, excludeUserAudio: true); + AlternativeVerb verb = new() + { + IconEntity = GetNetEntity(args.Using), + Act = () => Insert(uid, slot, args.Using.Value, args.User, excludeUserAudio: true) + }; if (slot.InsertVerbText != null) { @@ -491,7 +496,7 @@ namespace Content.Shared.Containers.ItemSlots AlternativeVerb verb = new() { - IconEntity = slot.Item, + IconEntity = GetNetEntity(slot.Item), Act = () => TryEjectToHands(uid, slot, args.User, excludeUserAudio: true) }; @@ -528,9 +533,11 @@ namespace Content.Shared.Containers.ItemSlots ? Loc.GetString(slot.Name) : Name(slot.Item!.Value); - InteractionVerb takeVerb = new(); - takeVerb.IconEntity = slot.Item; - takeVerb.Act = () => TryEjectToHands(uid, slot, args.User, excludeUserAudio: true); + InteractionVerb takeVerb = new() + { + IconEntity = GetNetEntity(slot.Item), + Act = () => TryEjectToHands(uid, slot, args.User, excludeUserAudio: true) + }; if (slot.EjectVerbText == null) takeVerb.Text = Loc.GetString("take-item-verb-text", ("subject", verbSubject)); @@ -556,7 +563,7 @@ namespace Content.Shared.Containers.ItemSlots InteractionVerb insertVerb = new() { - IconEntity = args.Using, + IconEntity = GetNetEntity(args.Using), Act = () => Insert(uid, slot, args.Using.Value, args.User, excludeUserAudio: true) }; diff --git a/Content.Shared/CrewManifest/SharedCrewManifestSystem.cs b/Content.Shared/CrewManifest/SharedCrewManifestSystem.cs index 0f174175fc..7e4c824e20 100644 --- a/Content.Shared/CrewManifest/SharedCrewManifestSystem.cs +++ b/Content.Shared/CrewManifest/SharedCrewManifestSystem.cs @@ -11,9 +11,9 @@ namespace Content.Shared.CrewManifest; [Serializable, NetSerializable] public sealed class RequestCrewManifestMessage : EntityEventArgs { - public EntityUid Id { get; } + public NetEntity Id { get; } - public RequestCrewManifestMessage(EntityUid id) + public RequestCrewManifestMessage(NetEntity id) { Id = id; } diff --git a/Content.Shared/Cuffs/SharedCuffableSystem.cs b/Content.Shared/Cuffs/SharedCuffableSystem.cs index e2f4eafad9..9294083a44 100644 --- a/Content.Shared/Cuffs/SharedCuffableSystem.cs +++ b/Content.Shared/Cuffs/SharedCuffableSystem.cs @@ -479,7 +479,7 @@ namespace Content.Shared.Cuffs if (HasComp(target)) cuffTime = 0.0f; // cuff them instantly. - var doAfterEventArgs = new DoAfterArgs(user, cuffTime, new AddCuffDoAfterEvent(), handcuff, target, handcuff) + var doAfterEventArgs = new DoAfterArgs(EntityManager, user, cuffTime, new AddCuffDoAfterEvent(), handcuff, target, handcuff) { BreakOnTargetMove = true, BreakOnUserMove = true, @@ -566,7 +566,7 @@ namespace Content.Shared.Cuffs } var uncuffTime = isOwner ? cuff.BreakoutTime : cuff.UncuffTime; - var doAfterEventArgs = new DoAfterArgs(user, uncuffTime, new UnCuffDoAfterEvent(), target, target, cuffsToRemove) + var doAfterEventArgs = new DoAfterArgs(EntityManager, user, uncuffTime, new UnCuffDoAfterEvent(), target, target, cuffsToRemove) { BreakOnUserMove = true, BreakOnTargetMove = true, diff --git a/Content.Shared/Decals/DecalChunkUpdateEvent.cs b/Content.Shared/Decals/DecalChunkUpdateEvent.cs index 74bea5333c..eb8ee93b95 100644 --- a/Content.Shared/Decals/DecalChunkUpdateEvent.cs +++ b/Content.Shared/Decals/DecalChunkUpdateEvent.cs @@ -6,7 +6,7 @@ namespace Content.Shared.Decals [Serializable, NetSerializable] public sealed class DecalChunkUpdateEvent : EntityEventArgs { - public Dictionary> Data = new(); - public Dictionary> RemovedChunks = new(); + public Dictionary> Data = new(); + public Dictionary> RemovedChunks = new(); } } diff --git a/Content.Shared/Decals/SharedDecalSystem.cs b/Content.Shared/Decals/SharedDecalSystem.cs index f22029d6e1..79bf826eed 100644 --- a/Content.Shared/Decals/SharedDecalSystem.cs +++ b/Content.Shared/Decals/SharedDecalSystem.cs @@ -149,9 +149,9 @@ namespace Content.Shared.Decals public sealed class RequestDecalPlacementEvent : EntityEventArgs { public Decal Decal; - public EntityCoordinates Coordinates; + public NetCoordinates Coordinates; - public RequestDecalPlacementEvent(Decal decal, EntityCoordinates coordinates) + public RequestDecalPlacementEvent(Decal decal, NetCoordinates coordinates) { Decal = decal; Coordinates = coordinates; @@ -161,9 +161,9 @@ namespace Content.Shared.Decals [Serializable, NetSerializable] public sealed class RequestDecalRemovalEvent : EntityEventArgs { - public EntityCoordinates Coordinates; + public NetCoordinates Coordinates; - public RequestDecalRemovalEvent(EntityCoordinates coordinates) + public RequestDecalRemovalEvent(NetCoordinates coordinates) { Coordinates = coordinates; } diff --git a/Content.Shared/DeviceNetwork/Components/DeviceListComponent.cs b/Content.Shared/DeviceNetwork/Components/DeviceListComponent.cs index a85ea1b6f8..e7fee450d1 100644 --- a/Content.Shared/DeviceNetwork/Components/DeviceListComponent.cs +++ b/Content.Shared/DeviceNetwork/Components/DeviceListComponent.cs @@ -40,11 +40,11 @@ public sealed partial class DeviceListComponent : Component [Serializable, NetSerializable] public sealed class DeviceListComponentState : ComponentState { - public readonly HashSet Devices; + public readonly HashSet Devices; public readonly bool IsAllowList; public readonly bool HandleIncomingPackets; - public DeviceListComponentState(HashSet devices, bool isAllowList, bool handleIncomingPackets) + public DeviceListComponentState(HashSet devices, bool isAllowList, bool handleIncomingPackets) { Devices = devices; IsAllowList = isAllowList; diff --git a/Content.Shared/DeviceNetwork/Components/NetworkConfiguratorComponent.cs b/Content.Shared/DeviceNetwork/Components/NetworkConfiguratorComponent.cs index 57987cd6a8..910aff4a14 100644 --- a/Content.Shared/DeviceNetwork/Components/NetworkConfiguratorComponent.cs +++ b/Content.Shared/DeviceNetwork/Components/NetworkConfiguratorComponent.cs @@ -62,10 +62,10 @@ public sealed partial class NetworkConfiguratorComponent : Component [Serializable, NetSerializable] public sealed class NetworkConfiguratorComponentState : ComponentState { - public readonly EntityUid? ActiveDeviceList; + public readonly NetEntity? ActiveDeviceList; public readonly bool LinkModeActive; - public NetworkConfiguratorComponentState(EntityUid? activeDeviceList, bool linkModeActive) + public NetworkConfiguratorComponentState(NetEntity? activeDeviceList, bool linkModeActive) { ActiveDeviceList = activeDeviceList; LinkModeActive = linkModeActive; diff --git a/Content.Shared/DeviceNetwork/Systems/SharedDeviceListSystem.cs b/Content.Shared/DeviceNetwork/Systems/SharedDeviceListSystem.cs index 2f9112d58e..c4d5d688c6 100644 --- a/Content.Shared/DeviceNetwork/Systems/SharedDeviceListSystem.cs +++ b/Content.Shared/DeviceNetwork/Systems/SharedDeviceListSystem.cs @@ -60,7 +60,7 @@ public abstract class SharedDeviceListSystem : EntitySystem private void GetDeviceListState(EntityUid uid, DeviceListComponent comp, ref ComponentGetState args) { - args.State = new DeviceListComponentState(comp.Devices, comp.IsAllowList, comp.HandleIncomingPackets); + args.State = new DeviceListComponentState(GetNetEntitySet(comp.Devices), comp.IsAllowList, comp.HandleIncomingPackets); } private void HandleDeviceListState(EntityUid uid, DeviceListComponent comp, ref ComponentHandleState args) @@ -70,7 +70,7 @@ public abstract class SharedDeviceListSystem : EntitySystem return; } - comp.Devices = state.Devices; + comp.Devices = EnsureEntitySet(state.Devices, uid); comp.HandleIncomingPackets = state.HandleIncomingPackets; comp.IsAllowList = state.IsAllowList; } diff --git a/Content.Shared/DeviceNetwork/Systems/SharedNetworkConfiguratorSystem.cs b/Content.Shared/DeviceNetwork/Systems/SharedNetworkConfiguratorSystem.cs index 716f49eb2d..87f77c8f0a 100644 --- a/Content.Shared/DeviceNetwork/Systems/SharedNetworkConfiguratorSystem.cs +++ b/Content.Shared/DeviceNetwork/Systems/SharedNetworkConfiguratorSystem.cs @@ -18,7 +18,7 @@ public abstract class SharedNetworkConfiguratorSystem : EntitySystem private void GetNetworkConfiguratorState(EntityUid uid, NetworkConfiguratorComponent comp, ref ComponentGetState args) { - args.State = new NetworkConfiguratorComponentState(comp.ActiveDeviceList, comp.LinkModeActive); + args.State = new NetworkConfiguratorComponentState(GetNetEntity(comp.ActiveDeviceList), comp.LinkModeActive); } private void HandleNetworkConfiguratorState(EntityUid uid, NetworkConfiguratorComponent comp, @@ -29,7 +29,7 @@ public abstract class SharedNetworkConfiguratorSystem : EntitySystem return; } - comp.ActiveDeviceList = state.ActiveDeviceList; + comp.ActiveDeviceList = EnsureEntity(state.ActiveDeviceList, uid); comp.LinkModeActive = state.LinkModeActive; } } diff --git a/Content.Shared/Devour/SharedDevourSystem.cs b/Content.Shared/Devour/SharedDevourSystem.cs index bdc198034b..cef8ad8de1 100644 --- a/Content.Shared/Devour/SharedDevourSystem.cs +++ b/Content.Shared/Devour/SharedDevourSystem.cs @@ -53,7 +53,7 @@ public abstract class SharedDevourSystem : EntitySystem case MobState.Critical: case MobState.Dead: - _doAfterSystem.TryStartDoAfter(new DoAfterArgs(uid, component.DevourTime, new DevourDoAfterEvent(), uid, target: target, used: uid) + _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, uid, component.DevourTime, new DevourDoAfterEvent(), uid, target: target, used: uid) { BreakOnTargetMove = true, BreakOnUserMove = true, @@ -72,7 +72,7 @@ public abstract class SharedDevourSystem : EntitySystem if (component.SoundStructureDevour != null) _audioSystem.PlayPredicted(component.SoundStructureDevour, uid, uid, component.SoundStructureDevour.Params); - _doAfterSystem.TryStartDoAfter(new DoAfterArgs(uid, component.StructureDevourTime, new DevourDoAfterEvent(), uid, target: target, used: uid) + _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, uid, component.StructureDevourTime, new DevourDoAfterEvent(), uid, target: target, used: uid) { BreakOnTargetMove = true, BreakOnUserMove = true, diff --git a/Content.Shared/Disposal/SharedDisposalUnitSystem.cs b/Content.Shared/Disposal/SharedDisposalUnitSystem.cs index f0c32c5ee0..600036a891 100644 --- a/Content.Shared/Disposal/SharedDisposalUnitSystem.cs +++ b/Content.Shared/Disposal/SharedDisposalUnitSystem.cs @@ -142,9 +142,9 @@ public abstract class SharedDisposalUnitSystem : EntitySystem public TimeSpan? NextFlush; public bool Powered; public bool Engaged; - public List RecentlyEjected; + public List RecentlyEjected; - public DisposalUnitComponentState(SoundSpecifier? flushSound, DisposalsPressureState state, TimeSpan nextPressurized, TimeSpan automaticEngageTime, TimeSpan? nextFlush, bool powered, bool engaged, List recentlyEjected) + public DisposalUnitComponentState(SoundSpecifier? flushSound, DisposalsPressureState state, TimeSpan nextPressurized, TimeSpan automaticEngageTime, TimeSpan? nextFlush, bool powered, bool engaged, List recentlyEjected) { FlushSound = flushSound; State = state; diff --git a/Content.Shared/DoAfter/DoAfter.cs b/Content.Shared/DoAfter/DoAfter.cs index 248227c8af..d999b370b3 100644 --- a/Content.Shared/DoAfter/DoAfter.cs +++ b/Content.Shared/DoAfter/DoAfter.cs @@ -44,9 +44,12 @@ public sealed partial class DoAfter /// /// Position of the user relative to their parent when the do after was started. /// + [NonSerialized] [DataField("userPosition")] public EntityCoordinates UserPosition; + public NetCoordinates NetUserPosition; + /// /// Distance from the user to the target when the do after was started. /// @@ -62,9 +65,12 @@ public sealed partial class DoAfter /// /// If is true, this is the entity that was in the active hand when the doafter started. /// + [NonSerialized] [DataField("activeItem")] public EntityUid? InitialItem; + public NetEntity? NetInitialItem; + // cached attempt event for the sake of avoiding unnecessary reflection every time this needs to be raised. [NonSerialized] public object? AttemptEvent; @@ -86,7 +92,7 @@ public sealed partial class DoAfter StartTime = startTime; } - public DoAfter(DoAfter other) + public DoAfter(IEntityManager entManager, DoAfter other) { Index = other.Index; Args = new(other.Args); @@ -97,6 +103,9 @@ public sealed partial class DoAfter TargetDistance = other.TargetDistance; InitialHand = other.InitialHand; InitialItem = other.InitialItem; + + NetUserPosition = other.NetUserPosition; + NetInitialItem = other.NetInitialItem; } } diff --git a/Content.Shared/DoAfter/DoAfterArgs.cs b/Content.Shared/DoAfter/DoAfterArgs.cs index 7c68c8b74a..c5cbc1f302 100644 --- a/Content.Shared/DoAfter/DoAfterArgs.cs +++ b/Content.Shared/DoAfter/DoAfterArgs.cs @@ -10,9 +10,12 @@ public sealed partial class DoAfterArgs /// /// The entity invoking do_after /// + [NonSerialized] [DataField("user", required: true)] public EntityUid User; + public NetEntity NetUser; + /// /// How long does the do_after require to complete /// @@ -22,15 +25,21 @@ public sealed partial class DoAfterArgs /// /// Applicable target (if relevant) /// + [NonSerialized] [DataField("target")] public EntityUid? Target; + public NetEntity? NetTarget; + /// /// Entity used by the User on the Target. /// + [NonSerialized] [DataField("using")] public EntityUid? Used; + public NetEntity? NetUsed; + #region Event options /// /// The event that will get raised when the DoAfter has finished. If null, this will simply raise a @@ -48,9 +57,12 @@ public sealed partial class DoAfterArgs /// /// Entity which will receive the directed event. If null, no directed event will be raised. /// + [NonSerialized] [DataField("eventTarget")] public EntityUid? EventTarget; + public NetEntity? NetEventTarget; + /// /// Should the DoAfter event broadcast? If this is false, then should be a valid entity. /// @@ -173,6 +185,7 @@ public sealed partial class DoAfterArgs /// The entity being targeted by the DoAFter. Not the same as . /// The entity being used during the DoAfter. E.g., a tool public DoAfterArgs( + IEntityManager entManager, EntityUid user, TimeSpan delay, DoAfterEvent @event, @@ -186,6 +199,10 @@ public sealed partial class DoAfterArgs Used = used; EventTarget = eventTarget; Event = @event; + + NetUser = entManager.GetNetEntity(User); + NetTarget = entManager.GetNetEntity(Target); + NetUsed = entManager.GetNetEntity(Used); } private DoAfterArgs() @@ -202,13 +219,14 @@ public sealed partial class DoAfterArgs /// The entity being targeted by the DoAfter. Not the same as . /// The entity being used during the DoAfter. E.g., a tool public DoAfterArgs( + IEntityManager entManager, EntityUid user, float seconds, DoAfterEvent @event, EntityUid? eventTarget, EntityUid? target = null, EntityUid? used = null) - : this(user, TimeSpan.FromSeconds(seconds), @event, eventTarget, target, used) + : this(entManager, user, TimeSpan.FromSeconds(seconds), @event, eventTarget, target, used) { } @@ -238,6 +256,12 @@ public sealed partial class DoAfterArgs CancelDuplicate = other.CancelDuplicate; DuplicateCondition = other.DuplicateCondition; + // Networked + NetUser = other.NetUser; + NetTarget = other.NetTarget; + NetUsed = other.NetUsed; + NetEventTarget = other.NetEventTarget; + Event = other.Event.Clone(); } } diff --git a/Content.Shared/DoAfter/DoAfterComponent.cs b/Content.Shared/DoAfter/DoAfterComponent.cs index 7fb42b34b9..ce45e35c59 100644 --- a/Content.Shared/DoAfter/DoAfterComponent.cs +++ b/Content.Shared/DoAfter/DoAfterComponent.cs @@ -24,7 +24,7 @@ public sealed class DoAfterComponentState : ComponentState public readonly ushort NextId; public readonly Dictionary DoAfters; - public DoAfterComponentState(DoAfterComponent component) + public DoAfterComponentState(IEntityManager entManager, DoAfterComponent component) { NextId = component.NextId; @@ -36,9 +36,10 @@ public sealed class DoAfterComponentState : ComponentState DoAfters = component.DoAfters; #else DoAfters = new(); - foreach (var (id, doafter) in component.DoAfters) + foreach (var (id, doAfter) in component.DoAfters) { - DoAfters.Add(id, new DoAfter(doafter)); + var newDoAfter = new DoAfter(entManager, doAfter); + DoAfters.Add(id, newDoAfter); } #endif } diff --git a/Content.Shared/DoAfter/SharedDoAfterSystem.Update.cs b/Content.Shared/DoAfter/SharedDoAfterSystem.Update.cs index 8903e23b89..32f46e5791 100644 --- a/Content.Shared/DoAfter/SharedDoAfterSystem.Update.cs +++ b/Content.Shared/DoAfter/SharedDoAfterSystem.Update.cs @@ -71,7 +71,7 @@ public abstract partial class SharedDoAfterSystem : EntitySystem } if (dirty) - Dirty(comp); + Dirty(uid, comp); if (comp.DoAfters.Count == 0) RemCompDeferred(uid, active); diff --git a/Content.Shared/DoAfter/SharedDoAfterSystem.cs b/Content.Shared/DoAfter/SharedDoAfterSystem.cs index 4bb6005b1c..472db8cfd6 100644 --- a/Content.Shared/DoAfter/SharedDoAfterSystem.cs +++ b/Content.Shared/DoAfter/SharedDoAfterSystem.cs @@ -100,7 +100,7 @@ public abstract partial class SharedDoAfterSystem : EntitySystem private void OnDoAfterGetState(EntityUid uid, DoAfterComponent comp, ref ComponentGetState args) { - args.State = new DoAfterComponentState(comp); + args.State = new DoAfterComponentState(EntityManager, comp); } private void OnDoAfterHandleState(EntityUid uid, DoAfterComponent comp, ref ComponentHandleState args) @@ -115,7 +115,18 @@ public abstract partial class SharedDoAfterSystem : EntitySystem comp.DoAfters.Clear(); foreach (var (id, doAfter) in state.DoAfters) { - comp.DoAfters.Add(id, new(doAfter)); + var newDoAfter = new DoAfter(EntityManager, doAfter); + comp.DoAfters.Add(id, newDoAfter); + + // Networking yay (if you have an easier way dear god please). + newDoAfter.UserPosition = EnsureCoordinates(newDoAfter.NetUserPosition, uid); + newDoAfter.InitialItem = EnsureEntity(newDoAfter.NetInitialItem, uid); + + var doAfterArgs = newDoAfter.Args; + doAfterArgs.Target = EnsureEntity(doAfterArgs.NetTarget, uid); + doAfterArgs.Used = EnsureEntity(doAfterArgs.NetUsed, uid); + doAfterArgs.User = EnsureEntity(doAfterArgs.NetUser, uid); + doAfterArgs.EventTarget = EnsureEntity(doAfterArgs.NetEventTarget, uid); } comp.NextId = state.NextId; @@ -195,6 +206,16 @@ public abstract partial class SharedDoAfterSystem : EntitySystem id = new DoAfterId(args.User, comp.NextId++); var doAfter = new DoAfter(id.Value.Index, args, GameTiming.CurTime); + // Networking yay + doAfter.NetUserPosition = GetNetCoordinates(doAfter.UserPosition); + doAfter.NetInitialItem = GetNetEntity(doAfter.InitialItem); + + // Networking yay + args.NetTarget = GetNetEntity(args.Target); + args.NetUsed = GetNetEntity(args.Used); + args.NetUser = GetNetEntity(args.User); + args.NetEventTarget = GetNetEntity(args.EventTarget); + if (args.BreakOnUserMove || args.BreakOnTargetMove) doAfter.UserPosition = Transform(args.User).Coordinates; @@ -322,7 +343,7 @@ public abstract partial class SharedDoAfterSystem : EntitySystem } InternalCancel(doAfter, comp); - Dirty(comp); + Dirty(entity, comp); } private void InternalCancel(DoAfter doAfter, DoAfterComponent component) diff --git a/Content.Shared/Doors/Components/DoorComponent.cs b/Content.Shared/Doors/Components/DoorComponent.cs index 847ea2ba92..567afa0770 100644 --- a/Content.Shared/Doors/Components/DoorComponent.cs +++ b/Content.Shared/Doors/Components/DoorComponent.cs @@ -340,14 +340,14 @@ public enum DoorVisualLayers : byte public sealed class DoorComponentState : ComponentState { public readonly DoorState DoorState; - public readonly HashSet CurrentlyCrushing; + public readonly HashSet CurrentlyCrushing; public readonly TimeSpan? NextStateChange; public readonly bool Partial; - public DoorComponentState(DoorComponent door) + public DoorComponentState(DoorComponent door, HashSet currentlyCrushing) { DoorState = door.State; - CurrentlyCrushing = door.CurrentlyCrushing; + CurrentlyCrushing = currentlyCrushing; NextStateChange = door.NextStateChange; Partial = door.Partial; } diff --git a/Content.Shared/Doors/Systems/SharedDoorSystem.cs b/Content.Shared/Doors/Systems/SharedDoorSystem.cs index 7dc7d13017..3fc912deba 100644 --- a/Content.Shared/Doors/Systems/SharedDoorSystem.cs +++ b/Content.Shared/Doors/Systems/SharedDoorSystem.cs @@ -101,7 +101,7 @@ public abstract partial class SharedDoorSystem : EntitySystem #region StateManagement private void OnGetState(EntityUid uid, DoorComponent door, ref ComponentGetState args) { - args.State = new DoorComponentState(door); + args.State = new DoorComponentState(door, GetNetEntitySet(door.CurrentlyCrushing)); } private void OnHandleState(EntityUid uid, DoorComponent door, ref ComponentHandleState args) @@ -109,11 +109,8 @@ public abstract partial class SharedDoorSystem : EntitySystem if (args.Current is not DoorComponentState state) return; - if (!door.CurrentlyCrushing.SetEquals(state.CurrentlyCrushing)) - { - door.CurrentlyCrushing.Clear(); - door.CurrentlyCrushing.UnionWith(state.CurrentlyCrushing); - } + door.CurrentlyCrushing.Clear(); + door.CurrentlyCrushing.UnionWith(EnsureEntitySet(state.CurrentlyCrushing, uid)); door.State = state.DoorState; door.NextStateChange = state.NextStateChange; diff --git a/Content.Shared/DragDrop/DragDropRequestEvent.cs b/Content.Shared/DragDrop/DragDropRequestEvent.cs index af32997942..34b4a7a947 100644 --- a/Content.Shared/DragDrop/DragDropRequestEvent.cs +++ b/Content.Shared/DragDrop/DragDropRequestEvent.cs @@ -11,14 +11,14 @@ namespace Content.Shared.DragDrop /// /// Entity that was dragged and dropped. /// - public EntityUid Dragged { get; } + public NetEntity Dragged { get; } /// /// Entity that was drag dropped on. /// - public EntityUid Target { get; } + public NetEntity Target { get; } - public DragDropRequestEvent(EntityUid dragged, EntityUid target) + public DragDropRequestEvent(NetEntity dragged, NetEntity target) { Dragged = dragged; Target = target; diff --git a/Content.Shared/Effects/ColorFlashEffectEvent.cs b/Content.Shared/Effects/ColorFlashEffectEvent.cs index 0396d39547..06043d3c00 100644 --- a/Content.Shared/Effects/ColorFlashEffectEvent.cs +++ b/Content.Shared/Effects/ColorFlashEffectEvent.cs @@ -13,9 +13,9 @@ public sealed class ColorFlashEffectEvent : EntityEventArgs /// public Color Color; - public List Entities; + public List Entities; - public ColorFlashEffectEvent(Color color, List entities) + public ColorFlashEffectEvent(Color color, List entities) { Color = color; Entities = entities; diff --git a/Content.Shared/Examine/ExamineSystemMessages.cs b/Content.Shared/Examine/ExamineSystemMessages.cs index 50549c37b1..5d5c67431a 100644 --- a/Content.Shared/Examine/ExamineSystemMessages.cs +++ b/Content.Shared/Examine/ExamineSystemMessages.cs @@ -9,15 +9,15 @@ namespace Content.Shared.Examine [Serializable, NetSerializable] public sealed class RequestExamineInfoMessage : EntityEventArgs { - public readonly EntityUid EntityUid; - + public readonly NetEntity NetEntity; + public readonly int Id; public readonly bool GetVerbs; - public RequestExamineInfoMessage(EntityUid entityUid, int id, bool getVerbs=false) + public RequestExamineInfoMessage(NetEntity netEntity, int id, bool getVerbs=false) { - EntityUid = entityUid; + NetEntity = netEntity; Id = id; GetVerbs = getVerbs; } @@ -26,7 +26,7 @@ namespace Content.Shared.Examine [Serializable, NetSerializable] public sealed class ExamineInfoResponseMessage : EntityEventArgs { - public readonly EntityUid EntityUid; + public readonly NetEntity EntityUid; public readonly int Id; public readonly FormattedMessage Message; @@ -37,7 +37,7 @@ namespace Content.Shared.Examine public readonly bool KnowTarget; - public ExamineInfoResponseMessage(EntityUid entityUid, int id, FormattedMessage message, List? verbs=null, + public ExamineInfoResponseMessage(NetEntity entityUid, int id, FormattedMessage message, List? verbs=null, bool centerAtCursor=true, bool openAtOldTooltip=true, bool knowTarget = true) { EntityUid = entityUid; diff --git a/Content.Shared/Examine/ExamineSystemShared.cs b/Content.Shared/Examine/ExamineSystemShared.cs index a092b7052f..cb4845498f 100644 --- a/Content.Shared/Examine/ExamineSystemShared.cs +++ b/Content.Shared/Examine/ExamineSystemShared.cs @@ -48,7 +48,7 @@ namespace Content.Shared.Examine public bool IsInDetailsRange(EntityUid examiner, EntityUid entity) { - if (entity.IsClientSide()) + if (IsClientSide(entity)) return true; // check if the mob is in critical or dead @@ -72,7 +72,7 @@ namespace Content.Shared.Examine public bool CanExamine(EntityUid examiner, EntityUid examined) { // special check for client-side entities stored in null-space for some UI guff. - if (examined.IsClientSide()) + if (IsClientSide(examined)) return true; return !Deleted(examined) && CanExamine(examiner, EntityManager.GetComponent(examined).MapPosition, diff --git a/Content.Shared/Explosion/ExplosionVisualsComponent.cs b/Content.Shared/Explosion/ExplosionVisualsComponent.cs index 24bcdf5d45..5baa59fc5a 100644 --- a/Content.Shared/Explosion/ExplosionVisualsComponent.cs +++ b/Content.Shared/Explosion/ExplosionVisualsComponent.cs @@ -24,7 +24,7 @@ public sealed class ExplosionVisualsState : ComponentState { public MapCoordinates Epicenter; public Dictionary>? SpaceTiles; - public Dictionary>> Tiles; + public Dictionary>> Tiles; public List Intensity; public string ExplosionType = string.Empty; public Matrix3 SpaceMatrix; @@ -35,7 +35,7 @@ public sealed class ExplosionVisualsState : ComponentState string typeID, List intensity, Dictionary>? spaceTiles, - Dictionary>> tiles, + Dictionary>> tiles, Matrix3 spaceMatrix, ushort spaceTileSize) { diff --git a/Content.Shared/Fax/AdminFaxEui.cs b/Content.Shared/Fax/AdminFaxEui.cs index 40fc5d72da..7b3e1fae8d 100644 --- a/Content.Shared/Fax/AdminFaxEui.cs +++ b/Content.Shared/Fax/AdminFaxEui.cs @@ -17,11 +17,11 @@ public sealed class AdminFaxEuiState : EuiStateBase [Serializable, NetSerializable] public sealed class AdminFaxEntry { - public EntityUid Uid { get; } + public NetEntity Uid { get; } public string Name { get; } public string Address { get; } - public AdminFaxEntry(EntityUid uid, string name, string address) + public AdminFaxEntry(NetEntity uid, string name, string address) { Uid = uid; Name = name; @@ -39,9 +39,9 @@ public static class AdminFaxEuiMsg [Serializable, NetSerializable] public sealed class Follow : EuiMessageBase { - public EntityUid TargetFax { get; } + public NetEntity TargetFax { get; } - public Follow(EntityUid targetFax) + public Follow(NetEntity targetFax) { TargetFax = targetFax; } @@ -50,14 +50,14 @@ public static class AdminFaxEuiMsg [Serializable, NetSerializable] public sealed class Send : EuiMessageBase { - public EntityUid Target { get; } + public NetEntity Target { get; } public string Title { get; } public string From { get; } public string Content { get; } public string StampState { get; } public Color StampColor { get; } - public Send(EntityUid target, string title, string from, string content, string stamp, Color stampColor) + public Send(NetEntity target, string title, string from, string content, string stamp, Color stampColor) { Target = target; Title = title; diff --git a/Content.Shared/Fluids/SharedPuddleDebugOverlaySystem.cs b/Content.Shared/Fluids/SharedPuddleDebugOverlaySystem.cs index df0a05fa64..6f6d56cf60 100644 --- a/Content.Shared/Fluids/SharedPuddleDebugOverlaySystem.cs +++ b/Content.Shared/Fluids/SharedPuddleDebugOverlaySystem.cs @@ -26,10 +26,10 @@ public sealed class PuddleOverlayDebugMessage : EntityEventArgs { public PuddleDebugOverlayData[] OverlayData { get; } - public EntityUid GridUid { get; } + public NetEntity GridUid { get; } - public PuddleOverlayDebugMessage(EntityUid gridUid, PuddleDebugOverlayData[] overlayData) + public PuddleOverlayDebugMessage(NetEntity gridUid, PuddleDebugOverlayData[] overlayData) { GridUid = gridUid; OverlayData = overlayData; diff --git a/Content.Shared/Follower/Components/FollowedComponent.cs b/Content.Shared/Follower/Components/FollowedComponent.cs index 259af7c484..83e486668e 100644 --- a/Content.Shared/Follower/Components/FollowedComponent.cs +++ b/Content.Shared/Follower/Components/FollowedComponent.cs @@ -7,9 +7,9 @@ namespace Content.Shared.Follower.Components; /// Attached to entities that are currently being followed by a ghost. /// [RegisterComponent, Access(typeof(FollowerSystem))] -[NetworkedComponent, AutoGenerateComponentState] +[NetworkedComponent] public sealed partial class FollowedComponent : Component { - [AutoNetworkedField(true), DataField("following")] + [DataField("following")] public HashSet Following = new(); } diff --git a/Content.Shared/Follower/FollowerSystem.cs b/Content.Shared/Follower/FollowerSystem.cs index 334b80466a..10e7a7be1d 100644 --- a/Content.Shared/Follower/FollowerSystem.cs +++ b/Content.Shared/Follower/FollowerSystem.cs @@ -8,12 +8,14 @@ using Content.Shared.Physics.Pull; using Content.Shared.Tag; using Content.Shared.Verbs; using Robust.Shared.Containers; +using Robust.Shared.GameStates; using Robust.Shared.Map; using Robust.Shared.Map.Events; using Robust.Shared.Network; using Robust.Shared.Utility; using Robust.Shared.Physics; using Robust.Shared.Physics.Systems; +using Robust.Shared.Serialization; namespace Content.Shared.Follower; @@ -36,6 +38,25 @@ public sealed class FollowerSystem : EntitySystem SubscribeLocalEvent(OnGotEquippedHand); SubscribeLocalEvent(OnFollowedTerminating); SubscribeLocalEvent(OnBeforeSave); + + SubscribeLocalEvent(OnFollowedGetState); + SubscribeLocalEvent(OnFollowedHandleState); + } + + private void OnFollowedGetState(EntityUid uid, FollowedComponent component, ref ComponentGetState args) + { + args.State = new FollowedComponentState() + { + Following = GetNetEntitySet(component.Following), + }; + } + + private void OnFollowedHandleState(EntityUid uid, FollowedComponent component, ref ComponentHandleState args) + { + if (args.Current is not FollowedComponentState state) + return; + + component.Following = EnsureEntitySet(state.Following, uid); } private void OnBeforeSave(BeforeSaveEvent ev) @@ -58,7 +79,7 @@ public sealed class FollowerSystem : EntitySystem private void OnGetAlternativeVerbs(GetVerbsEvent ev) { - if (ev.User == ev.Target || ev.Target.IsClientSide()) + if (ev.User == ev.Target || IsClientSide(ev.Target)) return; if (HasComp(ev.User)) @@ -221,6 +242,12 @@ public sealed class FollowerSystem : EntitySystem StopFollowingEntity(player, uid, followed); } } + + [Serializable, NetSerializable] + private sealed class FollowedComponentState : ComponentState + { + public HashSet Following = new(); + } } public abstract class FollowEvent : EntityEventArgs diff --git a/Content.Shared/GameTicking/SharedGameTicker.cs b/Content.Shared/GameTicking/SharedGameTicker.cs index 62af2caef5..b4e8218429 100644 --- a/Content.Shared/GameTicking/SharedGameTicker.cs +++ b/Content.Shared/GameTicking/SharedGameTicker.cs @@ -124,10 +124,10 @@ namespace Content.Shared.GameTicking /// /// The Status of the Player in the lobby (ready, observer, ...) /// - public Dictionary> JobsAvailableByStation { get; } - public Dictionary StationNames { get; } + public Dictionary> JobsAvailableByStation { get; } + public Dictionary StationNames { get; } - public TickerJobsAvailableEvent(Dictionary stationNames, Dictionary> jobsAvailableByStation) + public TickerJobsAvailableEvent(Dictionary stationNames, Dictionary> jobsAvailableByStation) { StationNames = stationNames; JobsAvailableByStation = jobsAvailableByStation; @@ -143,7 +143,7 @@ namespace Content.Shared.GameTicking public string PlayerOOCName; public string? PlayerICName; public string Role; - public EntityUid? PlayerEntityUid; + public NetEntity? PlayerNetEntity; public bool Antag; public bool Observer; public bool Connected; diff --git a/Content.Shared/Gateway/GatewayUi.cs b/Content.Shared/Gateway/GatewayUi.cs index b3ab67e396..75518c2be8 100644 --- a/Content.Shared/Gateway/GatewayUi.cs +++ b/Content.Shared/Gateway/GatewayUi.cs @@ -26,12 +26,12 @@ public sealed class GatewayBoundUserInterfaceState : BoundUserInterfaceState /// /// List of enabled destinations and information about them. /// - public readonly List<(EntityUid, string, TimeSpan, bool)> Destinations; + public readonly List<(NetEntity, string, TimeSpan, bool)> Destinations; /// /// Which destination it is currently linked to, if any. /// - public readonly EntityUid? Current; + public readonly NetEntity? Current; /// /// Time the portal will close at. @@ -43,8 +43,8 @@ public sealed class GatewayBoundUserInterfaceState : BoundUserInterfaceState /// public readonly TimeSpan LastOpen; - public GatewayBoundUserInterfaceState(List<(EntityUid, string, TimeSpan, bool)> destinations, - EntityUid? current, TimeSpan nextClose, TimeSpan lastOpen) + public GatewayBoundUserInterfaceState(List<(NetEntity, string, TimeSpan, bool)> destinations, + NetEntity? current, TimeSpan nextClose, TimeSpan lastOpen) { Destinations = destinations; Current = current; @@ -56,9 +56,9 @@ public sealed class GatewayBoundUserInterfaceState : BoundUserInterfaceState [Serializable, NetSerializable] public sealed class GatewayOpenPortalMessage : BoundUserInterfaceMessage { - public EntityUid Destination; + public NetEntity Destination; - public GatewayOpenPortalMessage(EntityUid destination) + public GatewayOpenPortalMessage(NetEntity destination) { Destination = destination; } diff --git a/Content.Shared/Ghost/Roles/MakeGhostRoleEuiState.cs b/Content.Shared/Ghost/Roles/MakeGhostRoleEuiState.cs index 3bde2517c3..8dd05e62f3 100644 --- a/Content.Shared/Ghost/Roles/MakeGhostRoleEuiState.cs +++ b/Content.Shared/Ghost/Roles/MakeGhostRoleEuiState.cs @@ -6,11 +6,11 @@ namespace Content.Shared.Ghost.Roles [Serializable, NetSerializable] public sealed class MakeGhostRoleEuiState : EuiStateBase { - public MakeGhostRoleEuiState(EntityUid entityUid) + public MakeGhostRoleEuiState(NetEntity entityUid) { EntityUid = entityUid; } - public EntityUid EntityUid { get; } + public NetEntity EntityUid { get; } } } diff --git a/Content.Shared/Ghost/Roles/SharedGhostRoleSystem.cs b/Content.Shared/Ghost/Roles/SharedGhostRoleSystem.cs index 8aae54aa5b..b64844e9a0 100644 --- a/Content.Shared/Ghost/Roles/SharedGhostRoleSystem.cs +++ b/Content.Shared/Ghost/Roles/SharedGhostRoleSystem.cs @@ -7,6 +7,6 @@ namespace Content.Shared.Ghost.Roles { public string Name { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; - public EntityUid Id; + public NetEntity Id; } } diff --git a/Content.Shared/Ghost/SharedGhostSystem.cs b/Content.Shared/Ghost/SharedGhostSystem.cs index 2bd2f8788f..1bd0bbacb9 100644 --- a/Content.Shared/Ghost/SharedGhostSystem.cs +++ b/Content.Shared/Ghost/SharedGhostSystem.cs @@ -66,7 +66,7 @@ namespace Content.Shared.Ghost [Serializable, NetSerializable] public struct GhostWarp { - public GhostWarp(EntityUid entity, string displayName, bool isWarpPoint) + public GhostWarp(NetEntity entity, string displayName, bool isWarpPoint) { Entity = entity; DisplayName = displayName; @@ -77,11 +77,13 @@ namespace Content.Shared.Ghost /// The entity representing the warp point. /// This is passed back to the server in /// - public EntityUid Entity { get; } + public NetEntity Entity { get; } + /// /// The display name to be surfaced in the ghost warps menu /// public string DisplayName { get; } + /// /// Whether this warp represents a warp point or a player /// @@ -112,9 +114,9 @@ namespace Content.Shared.Ghost [Serializable, NetSerializable] public sealed class GhostWarpToTargetRequestEvent : EntityEventArgs { - public EntityUid Target { get; } + public NetEntity Target { get; } - public GhostWarpToTargetRequestEvent(EntityUid target) + public GhostWarpToTargetRequestEvent(NetEntity target) { Target = target; } diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs index 87edd47282..e43f2561a1 100644 --- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs +++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs @@ -8,6 +8,8 @@ namespace Content.Shared.Hands.EntitySystems; public abstract partial class SharedHandsSystem : EntitySystem { + [Dependency] private readonly SharedContainerSystem _container = default!; + private void InitializeDrop() { SubscribeLocalEvent(HandleEntityRemoved); @@ -32,10 +34,10 @@ public abstract partial class SharedHandsSystem : EntitySystem /// public bool CanDropHeld(EntityUid uid, Hand hand, bool checkActionBlocker = true) { - if (hand.HeldEntity == null) + if (hand.Container?.ContainedEntity is not {} held) return false; - if (!hand.Container!.CanRemove(hand.HeldEntity.Value, EntityManager)) + if (!_container.CanRemove(held, hand.Container)) return false; if (checkActionBlocker && !_actionBlocker.CanDrop(uid)) @@ -110,7 +112,7 @@ public abstract partial class SharedHandsSystem : EntitySystem /// /// Attempts to move a held item from a hand into a container that is not another hand, without dropping it on the floor in-between. /// - public bool TryDropIntoContainer(EntityUid uid, EntityUid entity, IContainer targetContainer, bool checkActionBlocker = true, HandsComponent? handsComp = null) + public bool TryDropIntoContainer(EntityUid uid, EntityUid entity, BaseContainer targetContainer, bool checkActionBlocker = true, HandsComponent? handsComp = null) { if (!Resolve(uid, ref handsComp)) return false; @@ -121,7 +123,7 @@ public abstract partial class SharedHandsSystem : EntitySystem if (!CanDropHeld(uid, hand, checkActionBlocker)) return false; - if (!targetContainer.CanInsert(entity, EntityManager)) + if (!_container.CanInsert(entity, targetContainer)) return false; DoDrop(uid, hand, false, handsComp); diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Interactions.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Interactions.cs index 439ce3d2db..1cd9ad9d6e 100644 --- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Interactions.cs +++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Interactions.cs @@ -86,13 +86,13 @@ public abstract partial class SharedHandsSystem : EntitySystem var newActiveIndex = component.SortedHands.IndexOf(component.ActiveHand.Name) + 1; var nextHand = component.SortedHands[newActiveIndex % component.Hands.Count]; - TrySetActiveHand(component.Owner, nextHand, component); + TrySetActiveHand(session.AttachedEntity.Value, nextHand, component); } - private bool DropPressed(ICommonSession? session, EntityCoordinates coords, EntityUid uid) + private bool DropPressed(ICommonSession? session, EntityCoordinates coords, EntityUid netEntity) { if (TryComp(session?.AttachedEntity, out HandsComponent? hands) && hands.ActiveHand != null) - TryDrop(session.AttachedEntity!.Value, hands.ActiveHand, coords, handsComp: hands); + TryDrop(session.AttachedEntity.Value, hands.ActiveHand, coords, handsComp: hands); // always send to server. return false; diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs index eaa10ed077..e62723df06 100644 --- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs +++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs @@ -181,7 +181,7 @@ public abstract partial class SharedHandsSystem : EntitySystem return false; // check can insert (including raising attempt events). - return handContainer.CanInsert(entity, EntityManager); + return _containerSystem.CanInsert(entity, handContainer); } /// diff --git a/Content.Shared/Hands/HandEvents.cs b/Content.Shared/Hands/HandEvents.cs index a17caa0bcb..29242b4a7e 100644 --- a/Content.Shared/Hands/HandEvents.cs +++ b/Content.Shared/Hands/HandEvents.cs @@ -117,12 +117,12 @@ namespace Content.Shared.Hands [Serializable, NetSerializable] public sealed class PickupAnimationEvent : EntityEventArgs { - public EntityUid ItemUid { get; } - public EntityCoordinates InitialPosition { get; } + public NetEntity ItemUid { get; } + public NetCoordinates InitialPosition { get; } public Vector2 FinalPosition { get; } public Angle InitialAngle { get; } - public PickupAnimationEvent(EntityUid itemUid, EntityCoordinates initialPosition, + public PickupAnimationEvent(NetEntity itemUid, NetCoordinates initialPosition, Vector2 finalPosition, Angle initialAngle) { ItemUid = itemUid; diff --git a/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs b/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs index 15adefbd89..a4e3393c7e 100644 --- a/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs +++ b/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs @@ -36,7 +36,7 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem private void OnInit(EntityUid uid, HumanoidAppearanceComponent humanoid, ComponentInit args) { - if (string.IsNullOrEmpty(humanoid.Species) || _netManager.IsClient && !uid.IsClientSide()) + if (string.IsNullOrEmpty(humanoid.Species) || _netManager.IsClient && !IsClientSide(uid)) { return; } diff --git a/Content.Shared/Implants/SharedImplanterSystem.cs b/Content.Shared/Implants/SharedImplanterSystem.cs index 6d0a65f238..1cf9f44663 100644 --- a/Content.Shared/Implants/SharedImplanterSystem.cs +++ b/Content.Shared/Implants/SharedImplanterSystem.cs @@ -111,7 +111,7 @@ public abstract class SharedImplanterSystem : EntitySystem continue; //Don't remove a permanent implant and look for the next that can be drawn - if (!implantContainer.CanRemove(implant)) + if (!_container.CanRemove(implant, implantContainer)) { var implantName = Identity.Entity(implant, EntityManager); var targetName = Identity.Entity(target, EntityManager); diff --git a/Content.Shared/Instruments/SharedInstrumentComponent.cs b/Content.Shared/Instruments/SharedInstrumentComponent.cs index 61a3d28f46..cdd85b90ac 100644 --- a/Content.Shared/Instruments/SharedInstrumentComponent.cs +++ b/Content.Shared/Instruments/SharedInstrumentComponent.cs @@ -42,9 +42,9 @@ public abstract partial class SharedInstrumentComponent : Component [Serializable, NetSerializable] public sealed class InstrumentStopMidiEvent : EntityEventArgs { - public EntityUid Uid { get; } + public NetEntity Uid { get; } - public InstrumentStopMidiEvent(EntityUid uid) + public InstrumentStopMidiEvent(NetEntity uid) { Uid = uid; } @@ -56,10 +56,10 @@ public sealed class InstrumentStopMidiEvent : EntityEventArgs [Serializable, NetSerializable] public sealed class InstrumentSetMasterEvent : EntityEventArgs { - public EntityUid Uid { get; } - public EntityUid? Master { get; } + public NetEntity Uid { get; } + public NetEntity? Master { get; } - public InstrumentSetMasterEvent(EntityUid uid, EntityUid? master) + public InstrumentSetMasterEvent(NetEntity uid, NetEntity? master) { Uid = uid; Master = master; @@ -72,11 +72,11 @@ public sealed class InstrumentSetMasterEvent : EntityEventArgs [Serializable, NetSerializable] public sealed class InstrumentSetFilteredChannelEvent : EntityEventArgs { - public EntityUid Uid { get; } + public NetEntity Uid { get; } public int Channel { get; } public bool Value { get; } - public InstrumentSetFilteredChannelEvent(EntityUid uid, int channel, bool value) + public InstrumentSetFilteredChannelEvent(NetEntity uid, int channel, bool value) { Uid = uid; Channel = channel; @@ -90,9 +90,9 @@ public sealed class InstrumentSetFilteredChannelEvent : EntityEventArgs [Serializable, NetSerializable] public sealed class InstrumentStartMidiEvent : EntityEventArgs { - public EntityUid Uid { get; } + public NetEntity Uid { get; } - public InstrumentStartMidiEvent(EntityUid uid) + public InstrumentStartMidiEvent(NetEntity uid) { Uid = uid; } @@ -104,10 +104,10 @@ public sealed class InstrumentStartMidiEvent : EntityEventArgs [Serializable, NetSerializable] public sealed class InstrumentMidiEventEvent : EntityEventArgs { - public EntityUid Uid { get; } + public NetEntity Uid { get; } public RobustMidiEvent[] MidiEvent { get; } - public InstrumentMidiEventEvent(EntityUid uid, RobustMidiEvent[] midiEvent) + public InstrumentMidiEventEvent(NetEntity uid, RobustMidiEvent[] midiEvent) { Uid = uid; MidiEvent = midiEvent; diff --git a/Content.Shared/Instruments/UI/InstrumentBoundUserInterfaceMessages.cs b/Content.Shared/Instruments/UI/InstrumentBoundUserInterfaceMessages.cs index 47471b0e22..5e75a36004 100644 --- a/Content.Shared/Instruments/UI/InstrumentBoundUserInterfaceMessages.cs +++ b/Content.Shared/Instruments/UI/InstrumentBoundUserInterfaceMessages.cs @@ -10,9 +10,9 @@ public sealed class InstrumentBandRequestBuiMessage : BoundUserInterfaceMessage [Serializable, NetSerializable] public sealed class InstrumentBandResponseBuiMessage : BoundUserInterfaceMessage { - public (EntityUid, string)[] Nearby { get; set; } + public (NetEntity, string)[] Nearby { get; set; } - public InstrumentBandResponseBuiMessage((EntityUid, string)[] nearby) + public InstrumentBandResponseBuiMessage((NetEntity, string)[] nearby) { Nearby = nearby; } diff --git a/Content.Shared/Interaction/Components/InteractionRelayComponent.cs b/Content.Shared/Interaction/Components/InteractionRelayComponent.cs index a7b47875c6..1f8b4468ad 100644 --- a/Content.Shared/Interaction/Components/InteractionRelayComponent.cs +++ b/Content.Shared/Interaction/Components/InteractionRelayComponent.cs @@ -27,9 +27,9 @@ public sealed partial class InteractionRelayComponent : Component [Serializable, NetSerializable] public sealed class InteractionRelayComponentState : ComponentState { - public EntityUid? RelayEntity; + public NetEntity? RelayEntity; - public InteractionRelayComponentState(EntityUid? relayEntity) + public InteractionRelayComponentState(NetEntity? relayEntity) { RelayEntity = relayEntity; } diff --git a/Content.Shared/Interaction/Helpers/SharedUnoccludedExtensions.cs b/Content.Shared/Interaction/Helpers/SharedUnoccludedExtensions.cs index 0a13fc4f1b..9ea48a89c8 100644 --- a/Content.Shared/Interaction/Helpers/SharedUnoccludedExtensions.cs +++ b/Content.Shared/Interaction/Helpers/SharedUnoccludedExtensions.cs @@ -32,7 +32,7 @@ namespace Content.Shared.Interaction.Helpers public static bool InRangeUnOccluded( this EntityUid origin, - IContainer other, + BaseContainer other, float range = InteractionRange, Ignored? predicate = null, bool ignoreInsideBlocker = true) @@ -90,7 +90,7 @@ namespace Content.Shared.Interaction.Helpers public static bool InRangeUnOccluded( this IComponent origin, - IContainer other, + BaseContainer other, float range = InteractionRange, Ignored? predicate = null, bool ignoreInsideBlocker = true) @@ -130,7 +130,7 @@ namespace Content.Shared.Interaction.Helpers #region Containers public static bool InRangeUnOccluded( - this IContainer origin, + this BaseContainer origin, EntityUid other, float range = InteractionRange, Ignored? predicate = null, @@ -143,7 +143,7 @@ namespace Content.Shared.Interaction.Helpers } public static bool InRangeUnOccluded( - this IContainer origin, + this BaseContainer origin, IComponent other, float range = InteractionRange, Ignored? predicate = null, @@ -155,8 +155,8 @@ namespace Content.Shared.Interaction.Helpers } public static bool InRangeUnOccluded( - this IContainer origin, - IContainer other, + this BaseContainer origin, + BaseContainer other, float range = InteractionRange, Ignored? predicate = null, bool ignoreInsideBlocker = true) @@ -169,7 +169,7 @@ namespace Content.Shared.Interaction.Helpers } public static bool InRangeUnOccluded( - this IContainer origin, + this BaseContainer origin, EntityCoordinates other, float range = InteractionRange, Ignored? predicate = null, @@ -181,7 +181,7 @@ namespace Content.Shared.Interaction.Helpers } public static bool InRangeUnOccluded( - this IContainer origin, + this BaseContainer origin, MapCoordinates other, float range = InteractionRange, Ignored? predicate = null, @@ -226,7 +226,7 @@ namespace Content.Shared.Interaction.Helpers public static bool InRangeUnOccluded( this EntityCoordinates origin, - IContainer other, + BaseContainer other, float range = InteractionRange, Ignored? predicate = null, bool ignoreInsideBlocker = true) @@ -304,7 +304,7 @@ namespace Content.Shared.Interaction.Helpers public static bool InRangeUnOccluded( this MapCoordinates origin, - IContainer other, + BaseContainer other, float range = InteractionRange, Ignored? predicate = null, bool ignoreInsideBlocker = true) diff --git a/Content.Shared/Interaction/SharedInteractionSystem.Relay.cs b/Content.Shared/Interaction/SharedInteractionSystem.Relay.cs index b8cf4c7b2f..f82b8f7876 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.Relay.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.Relay.cs @@ -13,7 +13,7 @@ public abstract partial class SharedInteractionSystem private void OnGetState(EntityUid uid, InteractionRelayComponent component, ref ComponentGetState args) { - args.State = new InteractionRelayComponentState(component.RelayEntity); + args.State = new InteractionRelayComponentState(GetNetEntity(component.RelayEntity)); } private void OnHandleState(EntityUid uid, InteractionRelayComponent component, ref ComponentHandleState args) @@ -21,7 +21,7 @@ public abstract partial class SharedInteractionSystem if (args.Current is not InteractionRelayComponentState state) return; - component.RelayEntity = state.RelayEntity; + component.RelayEntity = EnsureEntity(state.RelayEntity, uid); } public void SetRelay(EntityUid uid, EntityUid? relayEntity, InteractionRelayComponent? component = null) diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index bf276dff0b..830a3cd936 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -205,8 +205,10 @@ namespace Content.Shared.Interaction /// private void HandleInteractInventorySlotEvent(InteractInventorySlotEvent msg, EntitySessionEventArgs args) { + var item = GetEntity(msg.ItemUid); + // client sanitization - if (!TryComp(msg.ItemUid, out TransformComponent? itemXform) || !ValidateClientInput(args.SenderSession, itemXform.Coordinates, msg.ItemUid, out var user)) + if (!TryComp(item, out TransformComponent? itemXform) || !ValidateClientInput(args.SenderSession, itemXform.Coordinates, item, out var user)) { Logger.InfoS("system.interaction", $"Inventory interaction validation failed. Session={args.SenderSession}"); return; @@ -219,10 +221,10 @@ namespace Content.Shared.Interaction if (msg.AltInteract) // Use 'UserInteraction' function - behaves as if the user alt-clicked the item in the world. - UserInteraction(user.Value, itemXform.Coordinates, msg.ItemUid, msg.AltInteract); + UserInteraction(user.Value, itemXform.Coordinates, item, msg.AltInteract); else // User used 'E'. We want to activate it, not simulate clicking on the item - InteractionActivate(user.Value, msg.ItemUid); + InteractionActivate(user.Value, item); } public bool HandleAltUseInteraction(ICommonSession? session, EntityCoordinates coords, EntityUid uid) @@ -1093,7 +1095,7 @@ namespace Content.Shared.Interaction return false; } - if (uid.IsClientSide()) + if (IsClientSide(uid)) { Logger.WarningS("system.interaction", $"Client sent interaction with client-side entity. Session={session}, Uid={uid}"); @@ -1148,14 +1150,14 @@ namespace Content.Shared.Interaction /// /// Entity that was interacted with. /// - public EntityUid ItemUid { get; } + public NetEntity ItemUid { get; } /// /// Whether the interaction used the alt-modifier to trigger alternative interactions. /// public bool AltInteract { get; } - public InteractInventorySlotEvent(EntityUid itemUid, bool altInteract = false) + public InteractInventorySlotEvent(NetEntity itemUid, bool altInteract = false) { ItemUid = itemUid; AltInteract = altInteract; diff --git a/Content.Shared/Inventory/Events/InventoryEquipActEvent.cs b/Content.Shared/Inventory/Events/InventoryEquipActEvent.cs index ec9fb7be91..59b5a3c69e 100644 --- a/Content.Shared/Inventory/Events/InventoryEquipActEvent.cs +++ b/Content.Shared/Inventory/Events/InventoryEquipActEvent.cs @@ -8,13 +8,13 @@ namespace Content.Shared.Inventory.Events; [NetSerializable, Serializable] public sealed class InventoryEquipActEvent : EntityEventArgs { - public readonly EntityUid Uid; - public readonly EntityUid ItemUid; + public readonly NetEntity Uid; + public readonly NetEntity ItemUid; public readonly string Slot; public readonly bool Silent; public readonly bool Force; - public InventoryEquipActEvent(EntityUid uid, EntityUid itemUid, string slot, bool silent = false, bool force = false) + public InventoryEquipActEvent(NetEntity uid, NetEntity itemUid, string slot, bool silent = false, bool force = false) { Uid = uid; ItemUid = itemUid; diff --git a/Content.Shared/Inventory/InventorySystem.Equip.cs b/Content.Shared/Inventory/InventorySystem.Equip.cs index 25dcf56921..f3181a87b1 100644 --- a/Content.Shared/Inventory/InventorySystem.Equip.cs +++ b/Content.Shared/Inventory/InventorySystem.Equip.cs @@ -360,7 +360,7 @@ public abstract partial class InventorySystem } //we need to do this to make sure we are 100% removing this entity, since we are now dropping dependant slots - if (!force && !slotContainer.CanRemove(removedItem.Value)) + if (!force && !_containerSystem.CanRemove(removedItem.Value, slotContainer)) return false; foreach (var slotDef in GetSlots(target, inventory)) @@ -426,14 +426,12 @@ public abstract partial class InventorySystem if ((containerSlot == null || slotDefinition == null) && !TryGetSlotContainer(target, slot, out containerSlot, out slotDefinition, inventory)) return false; - if (containerSlot.ContainedEntity == null) + if (containerSlot.ContainedEntity is not {} itemUid) return false; - if (!containerSlot.ContainedEntity.HasValue || !containerSlot.CanRemove(containerSlot.ContainedEntity.Value)) + if (!_containerSystem.CanRemove(itemUid, containerSlot)) return false; - var itemUid = containerSlot.ContainedEntity.Value; - // make sure the user can actually reach the target if (!CanAccess(actor, target, itemUid)) { diff --git a/Content.Shared/Item/ItemComponent.cs b/Content.Shared/Item/ItemComponent.cs index 894601f176..7516f4faca 100644 --- a/Content.Shared/Item/ItemComponent.cs +++ b/Content.Shared/Item/ItemComponent.cs @@ -56,10 +56,10 @@ public sealed class ItemComponentState : ComponentState [Serializable, NetSerializable] public sealed class VisualsChangedEvent : EntityEventArgs { - public readonly EntityUid Item; + public readonly NetEntity Item; public readonly string ContainerId; - public VisualsChangedEvent(EntityUid item, string containerId) + public VisualsChangedEvent(NetEntity item, string containerId) { Item = item; ContainerId = containerId; diff --git a/Content.Shared/Kitchen/Components/SharedMicrowave.cs b/Content.Shared/Kitchen/Components/SharedMicrowave.cs index 06ac79af98..e86ecf01c5 100644 --- a/Content.Shared/Kitchen/Components/SharedMicrowave.cs +++ b/Content.Shared/Kitchen/Components/SharedMicrowave.cs @@ -18,8 +18,8 @@ namespace Content.Shared.Kitchen.Components [Serializable, NetSerializable] public sealed class MicrowaveEjectSolidIndexedMessage : BoundUserInterfaceMessage { - public EntityUid EntityID; - public MicrowaveEjectSolidIndexedMessage(EntityUid entityId) + public NetEntity EntityID; + public MicrowaveEjectSolidIndexedMessage(NetEntity entityId) { EntityID = entityId; } @@ -50,12 +50,12 @@ namespace Content.Shared.Kitchen.Components [NetSerializable, Serializable] public sealed class MicrowaveUpdateUserInterfaceState : BoundUserInterfaceState { - public EntityUid[] ContainedSolids; + public NetEntity[] ContainedSolids; public bool IsMicrowaveBusy; public int ActiveButtonIndex; public uint CurrentCookTime; - public MicrowaveUpdateUserInterfaceState(EntityUid[] containedSolids, + public MicrowaveUpdateUserInterfaceState(NetEntity[] containedSolids, bool isMicrowaveBusy, int activeButtonIndex, uint currentCookTime) { ContainedSolids = containedSolids; diff --git a/Content.Shared/Kitchen/SharedReagentGrinder.cs b/Content.Shared/Kitchen/SharedReagentGrinder.cs index 97c13814b0..dc94884288 100644 --- a/Content.Shared/Kitchen/SharedReagentGrinder.cs +++ b/Content.Shared/Kitchen/SharedReagentGrinder.cs @@ -32,8 +32,8 @@ namespace Content.Shared.Kitchen [Serializable, NetSerializable] public sealed class ReagentGrinderEjectChamberContentMessage : BoundUserInterfaceMessage { - public EntityUid EntityId; - public ReagentGrinderEjectChamberContentMessage(EntityUid entityId) + public NetEntity EntityId; + public ReagentGrinderEjectChamberContentMessage(NetEntity entityId) { EntityId = entityId; } @@ -84,9 +84,9 @@ namespace Content.Shared.Kitchen public bool Powered; public bool CanJuice; public bool CanGrind; - public EntityUid[] ChamberContents; + public NetEntity[] ChamberContents; public ReagentQuantity[]? ReagentQuantities; - public ReagentGrinderInterfaceState(bool isBusy, bool hasBeaker, bool powered, bool canJuice, bool canGrind, EntityUid[] chamberContents, ReagentQuantity[]? heldBeakerContents) + public ReagentGrinderInterfaceState(bool isBusy, bool hasBeaker, bool powered, bool canJuice, bool canGrind, NetEntity[] chamberContents, ReagentQuantity[]? heldBeakerContents) { IsBusy = isBusy; HasBeakerIn = hasBeaker; diff --git a/Content.Shared/Maps/SharedGridDraggingSystem.cs b/Content.Shared/Maps/SharedGridDraggingSystem.cs index 40dc6852aa..9cc0ce1fe7 100644 --- a/Content.Shared/Maps/SharedGridDraggingSystem.cs +++ b/Content.Shared/Maps/SharedGridDraggingSystem.cs @@ -27,13 +27,13 @@ public sealed class GridDragToggleMessage : EntityEventArgs [Serializable, NetSerializable] public sealed class GridDragRequestPosition : EntityEventArgs { - public EntityUid Grid; + public NetEntity Grid; public Vector2 WorldPosition; } [Serializable, NetSerializable] public sealed class GridDragVelocityRequest : EntityEventArgs { - public EntityUid Grid; + public NetEntity Grid; public Vector2 LinearVelocity; } diff --git a/Content.Shared/MassMedia/Components/SharedNewsWriteComponent.cs b/Content.Shared/MassMedia/Components/SharedNewsWriteComponent.cs index 7ab737d48b..503b8ee13b 100644 --- a/Content.Shared/MassMedia/Components/SharedNewsWriteComponent.cs +++ b/Content.Shared/MassMedia/Components/SharedNewsWriteComponent.cs @@ -25,11 +25,12 @@ public sealed class NewsWriteBoundUserInterfaceState : BoundUserInterfaceState [Serializable, NetSerializable] public sealed class NewsWriteShareMessage : BoundUserInterfaceMessage { - public NewsArticle Article; - - public NewsWriteShareMessage(NewsArticle article) + public readonly string Name; + public readonly string Content; + public NewsWriteShareMessage(string name, string content) { - Article = article; + Name = name; + Content = content; } } diff --git a/Content.Shared/MassMedia/Systems/SharedNewsSystem.cs b/Content.Shared/MassMedia/Systems/SharedNewsSystem.cs index 1021f26734..64bc74229c 100644 --- a/Content.Shared/MassMedia/Systems/SharedNewsSystem.cs +++ b/Content.Shared/MassMedia/Systems/SharedNewsSystem.cs @@ -1,13 +1,13 @@ -using Content.Shared.StationRecords; +using Robust.Shared.Serialization; namespace Content.Shared.MassMedia.Systems; -[Serializable] +[Serializable, NetSerializable] public struct NewsArticle { public string Name; public string Content; public string? Author; - public ICollection? AuthorStationRecordKeyIds; + public ICollection<(NetEntity, uint)>? AuthorStationRecordKeyIds; public TimeSpan ShareTime; } diff --git a/Content.Shared/Mech/Components/MechComponent.cs b/Content.Shared/Mech/Components/MechComponent.cs index 54cb1ea06e..2f889a8d49 100644 --- a/Content.Shared/Mech/Components/MechComponent.cs +++ b/Content.Shared/Mech/Components/MechComponent.cs @@ -169,6 +169,6 @@ public sealed class MechComponentState : ComponentState public FixedPoint2 MaxIntegrity; public FixedPoint2 Energy; public FixedPoint2 MaxEnergy; - public EntityUid? CurrentSelectedEquipment; + public NetEntity? CurrentSelectedEquipment; public bool Broken; } diff --git a/Content.Shared/Mech/Components/MechPilotComponent.cs b/Content.Shared/Mech/Components/MechPilotComponent.cs index 127ec58099..364bd0bf14 100644 --- a/Content.Shared/Mech/Components/MechPilotComponent.cs +++ b/Content.Shared/Mech/Components/MechPilotComponent.cs @@ -22,5 +22,5 @@ public sealed partial class MechPilotComponent : Component [Serializable, NetSerializable] public sealed class MechPilotComponentState : ComponentState { - public EntityUid Mech; + public NetEntity Mech; } diff --git a/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs b/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs index 95dd906e35..026f731729 100644 --- a/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs +++ b/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs @@ -69,7 +69,7 @@ public abstract class SharedMechSystem : EntitySystem MaxIntegrity = component.MaxIntegrity, Energy = component.Energy, MaxEnergy = component.MaxEnergy, - CurrentSelectedEquipment = component.CurrentSelectedEquipment, + CurrentSelectedEquipment = GetNetEntity(component.CurrentSelectedEquipment), Broken = component.Broken }; } @@ -83,7 +83,7 @@ public abstract class SharedMechSystem : EntitySystem component.MaxIntegrity = state.MaxIntegrity; component.Energy = state.Energy; component.MaxEnergy = state.MaxEnergy; - component.CurrentSelectedEquipment = state.CurrentSelectedEquipment; + component.CurrentSelectedEquipment = EnsureEntity(state.CurrentSelectedEquipment, uid); component.Broken = state.Broken; } @@ -91,7 +91,7 @@ public abstract class SharedMechSystem : EntitySystem { args.State = new MechPilotComponentState { - Mech = component.Mech + Mech = GetNetEntity(component.Mech) }; } @@ -100,7 +100,7 @@ public abstract class SharedMechSystem : EntitySystem if (args.Current is not MechPilotComponentState state) return; - component.Mech = state.Mech; + component.Mech = EnsureEntity(state.Mech, uid); } #endregion diff --git a/Content.Shared/Mech/Equipment/Systems/MechSoundboardSystem.cs b/Content.Shared/Mech/Equipment/Systems/MechSoundboardSystem.cs index 5431c659c3..b4254fe079 100644 --- a/Content.Shared/Mech/Equipment/Systems/MechSoundboardSystem.cs +++ b/Content.Shared/Mech/Equipment/Systems/MechSoundboardSystem.cs @@ -31,7 +31,7 @@ public sealed class MechSoundboardSystem : EntitySystem { Sounds = sounds.ToList() }; - args.States.Add(uid, state); + args.States.Add(GetNetEntity(uid), state); } private void OnSoundboardMessage(EntityUid uid, MechSoundboardComponent comp, MechEquipmentUiMessageRelayEvent args) diff --git a/Content.Shared/Mech/MechUI.cs b/Content.Shared/Mech/MechUI.cs index f555fe69bd..0d62307883 100644 --- a/Content.Shared/Mech/MechUI.cs +++ b/Content.Shared/Mech/MechUI.cs @@ -13,7 +13,7 @@ public enum MechUiKey : byte /// public sealed class MechEquipmentUiStateReadyEvent : EntityEventArgs { - public Dictionary States = new(); + public Dictionary States = new(); } /// @@ -35,9 +35,9 @@ public sealed class MechEquipmentUiMessageRelayEvent : EntityEventArgs [Serializable, NetSerializable] public sealed class MechEquipmentRemoveMessage : BoundUserInterfaceMessage { - public EntityUid Equipment; + public NetEntity Equipment; - public MechEquipmentRemoveMessage(EntityUid equipment) + public MechEquipmentRemoveMessage(NetEntity equipment) { Equipment = equipment; } @@ -49,7 +49,7 @@ public sealed class MechEquipmentRemoveMessage : BoundUserInterfaceMessage [Serializable, NetSerializable] public abstract class MechEquipmentUiMessage : BoundUserInterfaceMessage { - public EntityUid Equipment; + public NetEntity Equipment; } /// @@ -58,9 +58,9 @@ public abstract class MechEquipmentUiMessage : BoundUserInterfaceMessage [Serializable, NetSerializable] public sealed class MechGrabberEjectMessage : MechEquipmentUiMessage { - public EntityUid Item; + public NetEntity Item; - public MechGrabberEjectMessage(EntityUid equipment, EntityUid uid) + public MechGrabberEjectMessage(NetEntity equipment, NetEntity uid) { Equipment = equipment; Item = uid; @@ -75,7 +75,7 @@ public sealed class MechSoundboardPlayMessage : MechEquipmentUiMessage { public int Sound; - public MechSoundboardPlayMessage(EntityUid equipment, int sound) + public MechSoundboardPlayMessage(NetEntity equipment, int sound) { Equipment = equipment; Sound = sound; @@ -106,13 +106,13 @@ public sealed class MechSoundboardPlayMessage : MechEquipmentUiMessage [Serializable, NetSerializable] public sealed class MechBoundUiState : BoundUserInterfaceState { - public Dictionary EquipmentStates = new(); + public Dictionary EquipmentStates = new(); } [Serializable, NetSerializable] public sealed class MechGrabberUiState : BoundUserInterfaceState { - public List Contents = new(); + public List Contents = new(); public int MaxContents; } diff --git a/Content.Shared/Medical/SuitSensor/SharedSuitSensor.cs b/Content.Shared/Medical/SuitSensor/SharedSuitSensor.cs index 8d2d7e230a..4e27959f89 100644 --- a/Content.Shared/Medical/SuitSensor/SharedSuitSensor.cs +++ b/Content.Shared/Medical/SuitSensor/SharedSuitSensor.cs @@ -6,7 +6,7 @@ namespace Content.Shared.Medical.SuitSensor [Serializable, NetSerializable] public sealed class SuitSensorStatus { - public SuitSensorStatus(EntityUid suitSensorUid, string name, string job) + public SuitSensorStatus(NetEntity suitSensorUid, string name, string job) { SuitSensorUid = suitSensorUid; Name = name; @@ -14,12 +14,12 @@ namespace Content.Shared.Medical.SuitSensor } public TimeSpan Timestamp; - public EntityUid SuitSensorUid; + public NetEntity SuitSensorUid; public string Name; public string Job; public bool IsAlive; public int? TotalDamage; - public EntityCoordinates? Coordinates; + public NetCoordinates? Coordinates; } [Serializable, NetSerializable] diff --git a/Content.Shared/MedicalScanner/HealthAnalyzerScannedUserMessage.cs b/Content.Shared/MedicalScanner/HealthAnalyzerScannedUserMessage.cs index 2691f1b7fc..eb50323d38 100644 --- a/Content.Shared/MedicalScanner/HealthAnalyzerScannedUserMessage.cs +++ b/Content.Shared/MedicalScanner/HealthAnalyzerScannedUserMessage.cs @@ -8,11 +8,11 @@ namespace Content.Shared.MedicalScanner; [Serializable, NetSerializable] public sealed class HealthAnalyzerScannedUserMessage : BoundUserInterfaceMessage { - public readonly EntityUid? TargetEntity; + public readonly NetEntity? TargetEntity; public float Temperature; public float BloodLevel; - public HealthAnalyzerScannedUserMessage(EntityUid? targetEntity, float temperature, float bloodLevel) + public HealthAnalyzerScannedUserMessage(NetEntity? targetEntity, float temperature, float bloodLevel) { TargetEntity = targetEntity; Temperature = temperature; diff --git a/Content.Shared/Movement/Systems/SharedJetpackSystem.cs b/Content.Shared/Movement/Systems/SharedJetpackSystem.cs index 0047de376c..f5516d9ec9 100644 --- a/Content.Shared/Movement/Systems/SharedJetpackSystem.cs +++ b/Content.Shared/Movement/Systems/SharedJetpackSystem.cs @@ -62,14 +62,14 @@ public abstract class SharedJetpackSystem : EntitySystem if (args.Current is not JetpackUserComponentState state) return; - component.Jetpack = state.Jetpack; + component.Jetpack = EnsureEntity(state.Jetpack, uid); } private void OnJetpackUserGetState(EntityUid uid, JetpackUserComponent component, ref ComponentGetState args) { args.State = new JetpackUserComponentState() { - Jetpack = component.Jetpack, + Jetpack = GetNetEntity(component.Jetpack), }; } @@ -198,7 +198,7 @@ public abstract class SharedJetpackSystem : EntitySystem [Serializable, NetSerializable] protected sealed class JetpackUserComponentState : ComponentState { - public EntityUid Jetpack; + public NetEntity Jetpack; } } diff --git a/Content.Shared/Movement/Systems/SharedMoverController.Input.cs b/Content.Shared/Movement/Systems/SharedMoverController.Input.cs index 41314d421a..9d150a0652 100644 --- a/Content.Shared/Movement/Systems/SharedMoverController.Input.cs +++ b/Content.Shared/Movement/Systems/SharedMoverController.Input.cs @@ -87,7 +87,7 @@ namespace Content.Shared.Movement.Systems component.RelativeRotation = state.RelativeRotation; component.TargetRelativeRotation = state.TargetRelativeRotation; - component.RelativeEntity = state.RelativeEntity; + component.RelativeEntity = EnsureEntity(state.RelativeEntity, uid); component.LerpTarget = state.LerpAccumulator; } @@ -98,7 +98,7 @@ namespace Content.Shared.Movement.Systems component.CanMove, component.RelativeRotation, component.TargetRelativeRotation, - component.RelativeEntity, + GetNetEntity(component.RelativeEntity), component.LerpTarget); } @@ -493,11 +493,11 @@ namespace Content.Shared.Movement.Systems _angle = direction.ToAngle(); } - public override bool HandleCmdMessage(ICommonSession? session, InputCmdMessage message) + public override bool HandleCmdMessage(IEntityManager entManager, ICommonSession? session, IFullInputCmdMessage message) { - if (message is not FullInputCmdMessage full || session?.AttachedEntity == null) return false; + if (session?.AttachedEntity == null) return false; - if (full.State != BoundKeyState.Up) + if (message.State != BoundKeyState.Up) return false; _controller.RotateCamera(session.AttachedEntity.Value, _angle); @@ -514,11 +514,11 @@ namespace Content.Shared.Movement.Systems _controller = controller; } - public override bool HandleCmdMessage(ICommonSession? session, InputCmdMessage message) + public override bool HandleCmdMessage(IEntityManager entManager, ICommonSession? session, IFullInputCmdMessage message) { - if (message is not FullInputCmdMessage full || session?.AttachedEntity == null) return false; + if (session?.AttachedEntity == null) return false; - if (full.State != BoundKeyState.Up) + if (message.State != BoundKeyState.Up) return false; _controller.ResetCamera(session.AttachedEntity.Value); @@ -537,11 +537,11 @@ namespace Content.Shared.Movement.Systems _dir = dir; } - public override bool HandleCmdMessage(ICommonSession? session, InputCmdMessage message) + public override bool HandleCmdMessage(IEntityManager entManager, ICommonSession? session, IFullInputCmdMessage message) { - if (message is not FullInputCmdMessage full || session?.AttachedEntity == null) return false; + if (session?.AttachedEntity == null) return false; - _controller.HandleDirChange(session.AttachedEntity.Value, _dir, message.SubTick, full.State == BoundKeyState.Down); + _controller.HandleDirChange(session.AttachedEntity.Value, _dir, message.SubTick, message.State == BoundKeyState.Down); return false; } } @@ -555,11 +555,11 @@ namespace Content.Shared.Movement.Systems _controller = controller; } - public override bool HandleCmdMessage(ICommonSession? session, InputCmdMessage message) + public override bool HandleCmdMessage(IEntityManager entManager, ICommonSession? session, IFullInputCmdMessage message) { - if (message is not FullInputCmdMessage full || session?.AttachedEntity == null) return false; + if (session?.AttachedEntity == null) return false; - _controller.HandleRunChange(session.AttachedEntity.Value, full.SubTick, full.State == BoundKeyState.Down); + _controller.HandleRunChange(session.AttachedEntity.Value, message.SubTick, message.State == BoundKeyState.Down); return false; } } @@ -579,10 +579,10 @@ namespace Content.Shared.Movement.Systems /// Target rotation relative to the . Typically 0 /// public Angle TargetRelativeRotation; - public EntityUid? RelativeEntity; + public NetEntity? RelativeEntity; public TimeSpan LerpAccumulator; - public InputMoverComponentState(MoveButtons buttons, bool canMove, Angle relativeRotation, Angle targetRelativeRotation, EntityUid? relativeEntity, TimeSpan lerpTarget) + public InputMoverComponentState(MoveButtons buttons, bool canMove, Angle relativeRotation, Angle targetRelativeRotation, NetEntity? relativeEntity, TimeSpan lerpTarget) { Buttons = buttons; CanMove = canMove; @@ -604,11 +604,11 @@ namespace Content.Shared.Movement.Systems _button = button; } - public override bool HandleCmdMessage(ICommonSession? session, InputCmdMessage message) + public override bool HandleCmdMessage(IEntityManager entManager, ICommonSession? session, IFullInputCmdMessage message) { - if (message is not FullInputCmdMessage full || session?.AttachedEntity == null) return false; + if (session?.AttachedEntity == null) return false; - _controller.HandleShuttleInput(session.AttachedEntity.Value, _button, full.SubTick, full.State == BoundKeyState.Down); + _controller.HandleShuttleInput(session.AttachedEntity.Value, _button, message.SubTick, message.State == BoundKeyState.Down); return false; } } diff --git a/Content.Shared/NPC/Events/HTNMessage.cs b/Content.Shared/NPC/Events/HTNMessage.cs index 415f2cf817..95f10cf7ad 100644 --- a/Content.Shared/NPC/Events/HTNMessage.cs +++ b/Content.Shared/NPC/Events/HTNMessage.cs @@ -8,6 +8,6 @@ namespace Content.Shared.NPC; [Serializable, NetSerializable] public sealed class HTNMessage : EntityEventArgs { - public EntityUid Uid; + public NetEntity Uid; public string Text = string.Empty; } diff --git a/Content.Shared/NPC/Events/NPCSteeringDebugEvent.cs b/Content.Shared/NPC/Events/NPCSteeringDebugEvent.cs index 0dd14c4c1a..11d840e647 100644 --- a/Content.Shared/NPC/Events/NPCSteeringDebugEvent.cs +++ b/Content.Shared/NPC/Events/NPCSteeringDebugEvent.cs @@ -19,13 +19,13 @@ public sealed class NPCSteeringDebugEvent : EntityEventArgs [Serializable, NetSerializable] public readonly record struct NPCSteeringDebugData( - EntityUid EntityUid, + NetEntity EntityUid, Vector2 Direction, float[] Interest, float[] Danger, List DangerPoints) { - public readonly EntityUid EntityUid = EntityUid; + public readonly NetEntity EntityUid = EntityUid; public readonly Vector2 Direction = Direction; public readonly float[] Interest = Interest; public readonly float[] Danger = Danger; diff --git a/Content.Shared/NPC/Events/PathBreadcrumbsMessage.cs b/Content.Shared/NPC/Events/PathBreadcrumbsMessage.cs index fd62e411e0..17bec4c63b 100644 --- a/Content.Shared/NPC/Events/PathBreadcrumbsMessage.cs +++ b/Content.Shared/NPC/Events/PathBreadcrumbsMessage.cs @@ -5,13 +5,13 @@ namespace Content.Shared.NPC; [Serializable, NetSerializable] public sealed class PathBreadcrumbsMessage : EntityEventArgs { - public Dictionary>> Breadcrumbs = new(); + public Dictionary>> Breadcrumbs = new(); } [Serializable, NetSerializable] public sealed class PathBreadcrumbsRefreshMessage : EntityEventArgs { - public EntityUid GridUid; + public NetEntity GridUid; public Vector2i Origin; public List Data = new(); } @@ -19,5 +19,5 @@ public sealed class PathBreadcrumbsRefreshMessage : EntityEventArgs [Serializable, NetSerializable] public sealed class PathPolysMessage : EntityEventArgs { - public Dictionary>>> Polys = new(); + public Dictionary>>> Polys = new(); } diff --git a/Content.Shared/NPC/Events/PathPolysRefreshMessage.cs b/Content.Shared/NPC/Events/PathPolysRefreshMessage.cs index afb788e027..194cc1d979 100644 --- a/Content.Shared/NPC/Events/PathPolysRefreshMessage.cs +++ b/Content.Shared/NPC/Events/PathPolysRefreshMessage.cs @@ -5,7 +5,7 @@ namespace Content.Shared.NPC; [Serializable, NetSerializable] public sealed class PathPolysRefreshMessage : EntityEventArgs { - public EntityUid GridUid; + public NetEntity GridUid; public Vector2i Origin; /// diff --git a/Content.Shared/NPC/PathPoly.cs b/Content.Shared/NPC/PathPoly.cs index 426c6e1a00..ad5832a04a 100644 --- a/Content.Shared/NPC/PathPoly.cs +++ b/Content.Shared/NPC/PathPoly.cs @@ -16,17 +16,17 @@ namespace Content.Shared.NPC; [Serializable, NetSerializable] public sealed class DebugPathPoly { - public EntityUid GraphUid; + public NetEntity GraphUid; public Vector2i ChunkOrigin; public byte TileIndex; public Box2 Box; public PathfindingData Data; - public List Neighbors = default!; + public List Neighbors = default!; } [Serializable, NetSerializable] public sealed class DebugPathPolyNeighbor { - public EntityCoordinates Coordinates; + public NetCoordinates Coordinates; } diff --git a/Content.Shared/NodeContainer/NodeVis.cs b/Content.Shared/NodeContainer/NodeVis.cs index 0208eb613e..24982f272a 100644 --- a/Content.Shared/NodeContainer/NodeVis.cs +++ b/Content.Shared/NodeContainer/NodeVis.cs @@ -36,7 +36,7 @@ namespace Content.Shared.NodeContainer [Serializable, NetSerializable] public sealed class NodeDatum { - public EntityUid Entity; + public NetEntity Entity; public int NetId; public int[] Reachable = Array.Empty(); public string Name = ""; diff --git a/Content.Shared/PDA/PdaUpdateState.cs b/Content.Shared/PDA/PdaUpdateState.cs index f5e44e7beb..c11b8e09f2 100644 --- a/Content.Shared/PDA/PdaUpdateState.cs +++ b/Content.Shared/PDA/PdaUpdateState.cs @@ -4,7 +4,9 @@ using Robust.Shared.Serialization; namespace Content.Shared.PDA { [Serializable, NetSerializable] - public sealed class PdaUpdateState : CartridgeLoaderUiState + public sealed class PdaUpdateState : CartridgeLoaderUiState // WTF is this. what. I ... fuck me I just want net entities to work + // TODO purge this shit + //AAAAAAAAAAAAAAAA { public bool FlashlightEnabled; public bool HasPen; @@ -14,9 +16,17 @@ namespace Content.Shared.PDA public bool CanPlayMusic; public string? Address; - public PdaUpdateState(bool flashlightEnabled, bool hasPen, PdaIdInfoText pdaOwnerInfo, - string? stationName, bool hasUplink = false, - bool canPlayMusic = false, string? address = null) + public PdaUpdateState( + List programs, + NetEntity? activeUI, + bool flashlightEnabled, + bool hasPen, + PdaIdInfoText pdaOwnerInfo, + string? stationName, + bool hasUplink = false, + bool canPlayMusic = false, + string? address = null) + : base(programs, activeUI) { FlashlightEnabled = flashlightEnabled; HasPen = hasPen; diff --git a/Content.Shared/Physics/PreventCollideComponent.cs b/Content.Shared/Physics/PreventCollideComponent.cs index 73c4c2e48a..429b7b56b3 100644 --- a/Content.Shared/Physics/PreventCollideComponent.cs +++ b/Content.Shared/Physics/PreventCollideComponent.cs @@ -15,10 +15,10 @@ public sealed partial class PreventCollideComponent : Component [Serializable, NetSerializable] public sealed class PreventCollideComponentState : ComponentState { - public EntityUid Uid; + public NetEntity Uid; - public PreventCollideComponentState(PreventCollideComponent component) + public PreventCollideComponentState(NetEntity netEntity) { - Uid = component.Uid; + Uid = netEntity; } } diff --git a/Content.Shared/Physics/SharedPreventCollideSystem.cs b/Content.Shared/Physics/SharedPreventCollideSystem.cs index 805981fe31..408125e140 100644 --- a/Content.Shared/Physics/SharedPreventCollideSystem.cs +++ b/Content.Shared/Physics/SharedPreventCollideSystem.cs @@ -17,7 +17,7 @@ public sealed class SharedPreventCollideSystem : EntitySystem private void OnGetState(EntityUid uid, PreventCollideComponent component, ref ComponentGetState args) { - args.State = new PreventCollideComponentState(component); + args.State = new PreventCollideComponentState(GetNetEntity(component.Uid)); } private void OnHandleState(EntityUid uid, PreventCollideComponent component, ref ComponentHandleState args) @@ -25,7 +25,7 @@ public sealed class SharedPreventCollideSystem : EntitySystem if (args.Current is not PreventCollideComponentState state) return; - component.Uid = state.Uid; + component.Uid = EnsureEntity(state.Uid, uid); } private void OnPreventCollide(EntityUid uid, PreventCollideComponent component, ref PreventCollideEvent args) diff --git a/Content.Shared/Placeable/ItemPlacerComponent.cs b/Content.Shared/Placeable/ItemPlacerComponent.cs index ce22f56492..c4fb6079cf 100644 --- a/Content.Shared/Placeable/ItemPlacerComponent.cs +++ b/Content.Shared/Placeable/ItemPlacerComponent.cs @@ -6,14 +6,14 @@ namespace Content.Shared.Placeable; /// /// Detects items placed on it that match a whitelist. /// -[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(ItemPlacerSystem))] +[RegisterComponent, NetworkedComponent, Access(typeof(ItemPlacerSystem))] public sealed partial class ItemPlacerComponent : Component { /// /// The entities that are currently on top of the placer. - /// Guaranteed to have less than enitites if it is set. - /// - [DataField("placedEntities"), AutoNetworkedField] + /// Guaranteed to have less than enitities if it is set. + /// + [DataField("placedEntities")] public HashSet PlacedEntities = new(); /// @@ -26,6 +26,6 @@ public sealed partial class ItemPlacerComponent : Component /// The max amount of entities that can be placed at the same time. /// If 0, there is no limit. /// - [ViewVariables(VVAccess.ReadWrite), DataField("maxEntities"), AutoNetworkedField] + [ViewVariables(VVAccess.ReadWrite), DataField("maxEntities")] public uint MaxEntities = 1; } diff --git a/Content.Shared/Placeable/ItemPlacerSystem.cs b/Content.Shared/Placeable/ItemPlacerSystem.cs index 83bb47b617..ccce286214 100644 --- a/Content.Shared/Placeable/ItemPlacerSystem.cs +++ b/Content.Shared/Placeable/ItemPlacerSystem.cs @@ -1,6 +1,8 @@ using Robust.Shared.Physics.Events; using Robust.Shared.Physics.Systems; using System.Linq; +using Robust.Shared.GameStates; +using Robust.Shared.Serialization; namespace Content.Shared.Placeable; @@ -19,6 +21,28 @@ public sealed class ItemPlacerSystem : EntitySystem SubscribeLocalEvent(OnStartCollide); SubscribeLocalEvent(OnEndCollide); + SubscribeLocalEvent(OnPlacerGetState); + SubscribeLocalEvent(OnPlacerHandleState); + } + + private void OnPlacerHandleState(EntityUid uid, ItemPlacerComponent component, ref ComponentHandleState args) + { + if (args.Current is not ItemPlacerComponentState state) + return; + + component.MaxEntities = state.MaxEntities; + component.PlacedEntities.Clear(); + var ents = EnsureEntitySet(state.Entities, uid); + component.PlacedEntities.UnionWith(ents); + } + + private void OnPlacerGetState(EntityUid uid, ItemPlacerComponent component, ref ComponentGetState args) + { + args.State = new ItemPlacerComponentState() + { + MaxEntities = component.MaxEntities, + Entities = GetNetEntitySet(component.PlacedEntities), + }; } private void OnStartCollide(EntityUid uid, ItemPlacerComponent comp, ref StartCollideEvent args) @@ -57,16 +81,23 @@ public sealed class ItemPlacerSystem : EntitySystem _placeableSurface.SetPlaceable(uid, true); } + + [Serializable, NetSerializable] + private sealed class ItemPlacerComponentState : ComponentState + { + public uint MaxEntities; + public HashSet Entities = default!; + } } /// /// Raised on the when an item is placed and it is under the item limit. /// [ByRefEvent] -public record struct ItemPlacedEvent(EntityUid OtherEntity); +public readonly record struct ItemPlacedEvent(EntityUid OtherEntity); /// /// Raised on the when an item is removed from it. /// [ByRefEvent] -public record struct ItemRemovedEvent(EntityUid OtherEntity); +public readonly record struct ItemRemovedEvent(EntityUid OtherEntity); diff --git a/Content.Shared/Pointing/PointingEvents.cs b/Content.Shared/Pointing/PointingEvents.cs index c65cc759fb..90c31bcfec 100644 --- a/Content.Shared/Pointing/PointingEvents.cs +++ b/Content.Shared/Pointing/PointingEvents.cs @@ -3,15 +3,16 @@ using Robust.Shared.Serialization; namespace Content.Shared.Pointing; // TODO just make pointing properly predicted? +// So true /// /// Event raised when someone runs the client-side pointing verb. /// [Serializable, NetSerializable] public sealed class PointingAttemptEvent : EntityEventArgs { - public EntityUid Target; + public NetEntity Target; - public PointingAttemptEvent(EntityUid target) + public PointingAttemptEvent(NetEntity target) { Target = target; } diff --git a/Content.Shared/Popups/SharedPopupSystem.cs b/Content.Shared/Popups/SharedPopupSystem.cs index 4f3619dbd3..50013a5435 100644 --- a/Content.Shared/Popups/SharedPopupSystem.cs +++ b/Content.Shared/Popups/SharedPopupSystem.cs @@ -124,9 +124,9 @@ namespace Content.Shared.Popups [Serializable, NetSerializable] public sealed class PopupCoordinatesEvent : PopupEvent { - public EntityCoordinates Coordinates { get; } + public NetCoordinates Coordinates { get; } - public PopupCoordinatesEvent(string message, PopupType type, EntityCoordinates coordinates) : base(message, type) + public PopupCoordinatesEvent(string message, PopupType type, NetCoordinates coordinates) : base(message, type) { Coordinates = coordinates; } @@ -138,9 +138,9 @@ namespace Content.Shared.Popups [Serializable, NetSerializable] public sealed class PopupEntityEvent : PopupEvent { - public EntityUid Uid { get; } + public NetEntity Uid { get; } - public PopupEntityEvent(string message, PopupType type, EntityUid uid) : base(message, type) + public PopupEntityEvent(string message, PopupType type, NetEntity uid) : base(message, type) { Uid = uid; } diff --git a/Content.Shared/Projectiles/SharedProjectileSystem.cs b/Content.Shared/Projectiles/SharedProjectileSystem.cs index f835a7f1c4..5d4046556a 100644 --- a/Content.Shared/Projectiles/SharedProjectileSystem.cs +++ b/Content.Shared/Projectiles/SharedProjectileSystem.cs @@ -49,7 +49,7 @@ public abstract partial class SharedProjectileSystem : EntitySystem args.Handled = true; - _doAfter.TryStartDoAfter(new DoAfterArgs(args.User, component.RemovalTime.Value, + _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.RemovalTime.Value, new RemoveEmbeddedProjectileEvent(), eventTarget: uid, target: uid) { DistanceThreshold = SharedInteractionSystem.InteractionRange, @@ -143,9 +143,9 @@ public abstract partial class SharedProjectileSystem : EntitySystem public sealed class ImpactEffectEvent : EntityEventArgs { public string Prototype; - public EntityCoordinates Coordinates; + public NetCoordinates Coordinates; - public ImpactEffectEvent(string prototype, EntityCoordinates coordinates) + public ImpactEffectEvent(string prototype, NetCoordinates coordinates) { Prototype = prototype; Coordinates = coordinates; diff --git a/Content.Shared/Pulling/Components/PullableComponent.cs b/Content.Shared/Pulling/Components/PullableComponent.cs index 4ed369af0c..51ab2c91e4 100644 --- a/Content.Shared/Pulling/Components/PullableComponent.cs +++ b/Content.Shared/Pulling/Components/PullableComponent.cs @@ -54,9 +54,9 @@ namespace Content.Shared.Pulling.Components [Serializable, NetSerializable] public sealed class PullableComponentState : ComponentState { - public readonly EntityUid? Puller; + public readonly NetEntity? Puller; - public PullableComponentState(EntityUid? puller) + public PullableComponentState(NetEntity? puller) { Puller = puller; } diff --git a/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs b/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs index b73565d5b2..63f6d64867 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs @@ -33,7 +33,7 @@ namespace Content.Shared.Pulling private void OnGetState(EntityUid uid, SharedPullableComponent component, ref ComponentGetState args) { - args.State = new PullableComponentState(component.Puller); + args.State = new PullableComponentState(GetNetEntity(component.Puller)); } private void OnHandleState(EntityUid uid, SharedPullableComponent component, ref ComponentHandleState args) @@ -41,21 +41,23 @@ namespace Content.Shared.Pulling if (args.Current is not PullableComponentState state) return; - if (!state.Puller.HasValue) + var puller = EnsureEntity(state.Puller, uid); + + if (!puller.HasValue) { ForceDisconnectPullable(component); return; } - if (component.Puller == state.Puller) + if (component.Puller == puller) { // don't disconnect and reconnect a puller for no reason return; } - if (!TryComp(state.Puller.Value, out var comp)) + if (!TryComp(puller, out var comp)) { - Log.Error($"Pullable state for entity {ToPrettyString(uid)} had invalid puller entity {ToPrettyString(state.Puller.Value)}"); + Log.Error($"Pullable state for entity {ToPrettyString(uid)} had invalid puller entity {ToPrettyString(puller.Value)}"); // ensure it disconnects from any different puller, still ForceDisconnectPullable(component); return; diff --git a/Content.Shared/RCD/Systems/RCDSystem.cs b/Content.Shared/RCD/Systems/RCDSystem.cs index 784c9ef3ee..f94d155d97 100644 --- a/Content.Shared/RCD/Systems/RCDSystem.cs +++ b/Content.Shared/RCD/Systems/RCDSystem.cs @@ -95,7 +95,7 @@ public sealed class RCDSystem : EntitySystem return; } - var doAfterArgs = new DoAfterArgs(user, comp.Delay, new RCDDoAfterEvent(location, comp.Mode), uid, target: args.Target, used: uid) + var doAfterArgs = new DoAfterArgs(EntityManager, user, comp.Delay, new RCDDoAfterEvent(GetNetCoordinates(location), comp.Mode), uid, target: args.Target, used: uid) { BreakOnDamage = true, NeedHand = true, @@ -115,7 +115,7 @@ public sealed class RCDSystem : EntitySystem if (args.Event?.DoAfter?.Args == null) return; - var location = args.Event.Location; + var location = GetCoordinates(args.Event.Location); var gridId = location.GetGridUid(EntityManager); if (!HasComp(gridId)) @@ -140,7 +140,7 @@ public sealed class RCDSystem : EntitySystem return; var user = args.User; - var location = args.Location; + var location = GetCoordinates(args.Location); var gridId = location.GetGridUid(EntityManager); if (!HasComp(gridId)) @@ -316,7 +316,7 @@ public sealed class RCDSystem : EntitySystem public sealed partial class RCDDoAfterEvent : DoAfterEvent { [DataField("location", required: true)] - public EntityCoordinates Location = default!; + public NetCoordinates Location = default!; [DataField("startingMode", required: true)] public RcdMode StartingMode = default!; @@ -325,7 +325,7 @@ public sealed partial class RCDDoAfterEvent : DoAfterEvent { } - public RCDDoAfterEvent(EntityCoordinates location, RcdMode startingMode) + public RCDDoAfterEvent(NetCoordinates location, RcdMode startingMode) { Location = location; StartingMode = startingMode; diff --git a/Content.Shared/Radiation/Components/GeigerComponent.cs b/Content.Shared/Radiation/Components/GeigerComponent.cs index 8d5c67a591..ebcd84b3a3 100644 --- a/Content.Shared/Radiation/Components/GeigerComponent.cs +++ b/Content.Shared/Radiation/Components/GeigerComponent.cs @@ -91,7 +91,7 @@ public sealed class GeigerComponentState : ComponentState public float CurrentRadiation; public GeigerDangerLevel DangerLevel; public bool IsEnabled; - public EntityUid? User; + public NetEntity? User; } [Serializable, NetSerializable] diff --git a/Content.Shared/Radiation/Events/OnRadiationOverlayUpdateEvent.cs b/Content.Shared/Radiation/Events/OnRadiationOverlayUpdateEvent.cs index 54a528a9ea..a93ca4c616 100644 --- a/Content.Shared/Radiation/Events/OnRadiationOverlayUpdateEvent.cs +++ b/Content.Shared/Radiation/Events/OnRadiationOverlayUpdateEvent.cs @@ -72,9 +72,9 @@ public sealed class OnRadiationOverlayResistanceUpdateEvent : EntityEventArgs /// /// Key is grids uid. Values are tiles with their rad resistance. /// - public readonly Dictionary> Grids; + public readonly Dictionary> Grids; - public OnRadiationOverlayResistanceUpdateEvent(Dictionary> grids) + public OnRadiationOverlayResistanceUpdateEvent(Dictionary> grids) { Grids = grids; } diff --git a/Content.Shared/Radiation/RadiationRay.cs b/Content.Shared/Radiation/RadiationRay.cs index 31c466e6c2..ca8ab5af66 100644 --- a/Content.Shared/Radiation/RadiationRay.cs +++ b/Content.Shared/Radiation/RadiationRay.cs @@ -19,7 +19,7 @@ public sealed class RadiationRay /// /// Uid of entity with . /// - public EntityUid SourceUid; + public NetEntity SourceUid; /// /// World coordinates of radiation source. /// @@ -27,7 +27,7 @@ public sealed class RadiationRay /// /// Uid of entity with radiation receiver component. /// - public EntityUid DestinationUid; + public NetEntity DestinationUid; /// /// World coordinates of radiation receiver. /// @@ -50,10 +50,10 @@ public sealed class RadiationRay /// Last tile may have negative value if ray has lost all intensity. /// Grid traversal order isn't guaranteed. /// - public Dictionary> Blockers = new(); + public Dictionary> Blockers = new(); - public RadiationRay(MapId mapId, EntityUid sourceUid, Vector2 source, - EntityUid destinationUid, Vector2 destination, float rads) + public RadiationRay(MapId mapId, NetEntity sourceUid, Vector2 source, + NetEntity destinationUid, Vector2 destination, float rads) { MapId = mapId; SourceUid = sourceUid; diff --git a/Content.Shared/Research/Systems/SharedResearchStealerSystem.cs b/Content.Shared/Research/Systems/SharedResearchStealerSystem.cs index 64f596023d..1fffa8c025 100644 --- a/Content.Shared/Research/Systems/SharedResearchStealerSystem.cs +++ b/Content.Shared/Research/Systems/SharedResearchStealerSystem.cs @@ -43,7 +43,7 @@ public abstract class SharedResearchStealerSystem : EntitySystem return; } - var doAfterArgs = new DoAfterArgs(uid, comp.Delay, new ResearchStealDoAfterEvent(), target: target, used: uid, eventTarget: uid) + var doAfterArgs = new DoAfterArgs(EntityManager, uid, comp.Delay, new ResearchStealDoAfterEvent(), target: target, used: uid, eventTarget: uid) { BreakOnDamage = true, BreakOnUserMove = true, diff --git a/Content.Shared/Salvage/Fulton/SharedFultonSystem.cs b/Content.Shared/Salvage/Fulton/SharedFultonSystem.cs index e0706d4880..3ddd42f2b7 100644 --- a/Content.Shared/Salvage/Fulton/SharedFultonSystem.cs +++ b/Content.Shared/Salvage/Fulton/SharedFultonSystem.cs @@ -147,7 +147,7 @@ public abstract partial class SharedFultonSystem : EntitySystem var ev = new FultonedDoAfterEvent(); _doAfter.TryStartDoAfter( - new DoAfterArgs(args.User, component.ApplyFultonDuration, ev, args.Target, args.Target, args.Used) + new DoAfterArgs(EntityManager, args.User, component.ApplyFultonDuration, ev, args.Target, args.Target, args.Used) { CancelDuplicate = true, MovementThreshold = 0.5f, @@ -188,7 +188,7 @@ public abstract partial class SharedFultonSystem : EntitySystem [Serializable, NetSerializable] protected sealed class FultonAnimationMessage : EntityEventArgs { - public EntityUid Entity; - public EntityCoordinates Coordinates; + public NetEntity Entity; + public NetCoordinates Coordinates; } } diff --git a/Content.Shared/Shuttles/BUIStates/RadarConsoleBoundInterfaceState.cs b/Content.Shared/Shuttles/BUIStates/RadarConsoleBoundInterfaceState.cs index 4fb3e62e5f..d60f5274b5 100644 --- a/Content.Shared/Shuttles/BUIStates/RadarConsoleBoundInterfaceState.cs +++ b/Content.Shared/Shuttles/BUIStates/RadarConsoleBoundInterfaceState.cs @@ -12,7 +12,7 @@ public class RadarConsoleBoundInterfaceState : BoundUserInterfaceState /// /// The relevant coordinates to base the radar around. /// - public EntityCoordinates? Coordinates; + public NetCoordinates? Coordinates; /// /// The relevant rotation to rotate the angle around. @@ -23,7 +23,7 @@ public class RadarConsoleBoundInterfaceState : BoundUserInterfaceState public RadarConsoleBoundInterfaceState( float maxRange, - EntityCoordinates? coordinates, + NetCoordinates? coordinates, Angle? angle, List docks) { @@ -40,9 +40,9 @@ public class RadarConsoleBoundInterfaceState : BoundUserInterfaceState [Serializable, NetSerializable] public sealed class DockingInterfaceState { - public EntityCoordinates Coordinates; + public NetCoordinates Coordinates; public Angle Angle; - public EntityUid Entity; + public NetEntity Entity; public bool Connected; public Color Color; public Color HighlightedColor; diff --git a/Content.Shared/Shuttles/BUIStates/ShuttleConsoleBoundInterfaceState.cs b/Content.Shared/Shuttles/BUIStates/ShuttleConsoleBoundInterfaceState.cs index a008ee4343..db38416ce2 100644 --- a/Content.Shared/Shuttles/BUIStates/ShuttleConsoleBoundInterfaceState.cs +++ b/Content.Shared/Shuttles/BUIStates/ShuttleConsoleBoundInterfaceState.cs @@ -18,14 +18,14 @@ public sealed class ShuttleConsoleBoundInterfaceState : RadarConsoleBoundInterfa /// public readonly TimeSpan FTLTime; - public List<(EntityUid Entity, string Destination, bool Enabled)> Destinations; + public List<(NetEntity Entity, string Destination, bool Enabled)> Destinations; public ShuttleConsoleBoundInterfaceState( FTLState ftlState, TimeSpan ftlTime, - List<(EntityUid Entity, string Destination, bool Enabled)> destinations, + List<(NetEntity Entity, string Destination, bool Enabled)> destinations, float maxRange, - EntityCoordinates? coordinates, + NetCoordinates? coordinates, Angle? angle, List docks) : base(maxRange, coordinates, angle, docks) { diff --git a/Content.Shared/Shuttles/Events/AutodockRequestMessage.cs b/Content.Shared/Shuttles/Events/AutodockRequestMessage.cs index 7e4f579038..39b91e6278 100644 --- a/Content.Shared/Shuttles/Events/AutodockRequestMessage.cs +++ b/Content.Shared/Shuttles/Events/AutodockRequestMessage.cs @@ -8,5 +8,5 @@ namespace Content.Shared.Shuttles.Events; [Serializable, NetSerializable] public sealed class AutodockRequestMessage : BoundUserInterfaceMessage { - public EntityUid DockEntity; + public NetEntity DockEntity; } diff --git a/Content.Shared/Shuttles/Events/EmergencyShuttlePositionMessage.cs b/Content.Shared/Shuttles/Events/EmergencyShuttlePositionMessage.cs index e021492c20..187b89467a 100644 --- a/Content.Shared/Shuttles/Events/EmergencyShuttlePositionMessage.cs +++ b/Content.Shared/Shuttles/Events/EmergencyShuttlePositionMessage.cs @@ -8,6 +8,6 @@ namespace Content.Shared.Shuttles.Events; [Serializable, NetSerializable] public sealed class EmergencyShuttlePositionMessage : EntityEventArgs { - public EntityUid? StationUid; + public NetEntity? StationUid; public Box2? Position; } diff --git a/Content.Shared/Shuttles/Events/ShuttleConsoleFTLRequestMessage.cs b/Content.Shared/Shuttles/Events/ShuttleConsoleFTLRequestMessage.cs index e1aac65ea3..73fd9d2c64 100644 --- a/Content.Shared/Shuttles/Events/ShuttleConsoleFTLRequestMessage.cs +++ b/Content.Shared/Shuttles/Events/ShuttleConsoleFTLRequestMessage.cs @@ -8,5 +8,5 @@ namespace Content.Shared.Shuttles.Events; [Serializable, NetSerializable] public sealed class ShuttleConsoleFTLRequestMessage : BoundUserInterfaceMessage { - public EntityUid Destination; + public NetEntity Destination; } diff --git a/Content.Shared/Shuttles/Events/StopAutodockRequestMessage.cs b/Content.Shared/Shuttles/Events/StopAutodockRequestMessage.cs index 599c8b06e0..e00e1553e2 100644 --- a/Content.Shared/Shuttles/Events/StopAutodockRequestMessage.cs +++ b/Content.Shared/Shuttles/Events/StopAutodockRequestMessage.cs @@ -8,5 +8,5 @@ namespace Content.Shared.Shuttles.Events; [Serializable, NetSerializable] public sealed class StopAutodockRequestMessage : BoundUserInterfaceMessage { - public EntityUid DockEntity; + public NetEntity DockEntity; } diff --git a/Content.Shared/Shuttles/Events/UndockRequestMessage.cs b/Content.Shared/Shuttles/Events/UndockRequestMessage.cs index b29bf36c04..533d3b7973 100644 --- a/Content.Shared/Shuttles/Events/UndockRequestMessage.cs +++ b/Content.Shared/Shuttles/Events/UndockRequestMessage.cs @@ -8,5 +8,5 @@ namespace Content.Shared.Shuttles.Events; [Serializable, NetSerializable] public sealed class UndockRequestMessage : BoundUserInterfaceMessage { - public EntityUid DockEntity; + public NetEntity DockEntity; } diff --git a/Content.Shared/Shuttles/Systems/SharedShuttleConsoleSystem.cs b/Content.Shared/Shuttles/Systems/SharedShuttleConsoleSystem.cs index 5b3949b6c2..f6224a8af6 100644 --- a/Content.Shared/Shuttles/Systems/SharedShuttleConsoleSystem.cs +++ b/Content.Shared/Shuttles/Systems/SharedShuttleConsoleSystem.cs @@ -20,9 +20,9 @@ namespace Content.Shared.Shuttles.Systems [Serializable, NetSerializable] protected sealed class PilotComponentState : ComponentState { - public EntityUid? Console { get; } + public NetEntity? Console { get; } - public PilotComponentState(EntityUid? uid) + public PilotComponentState(NetEntity? uid) { Console = uid; } diff --git a/Content.Shared/Silicons/Borgs/BorgUI.cs b/Content.Shared/Silicons/Borgs/BorgUI.cs index 601f9a2178..fd6abc8992 100644 --- a/Content.Shared/Silicons/Borgs/BorgUI.cs +++ b/Content.Shared/Silicons/Borgs/BorgUI.cs @@ -48,9 +48,9 @@ public sealed class BorgSetNameBuiMessage : BoundUserInterfaceMessage [Serializable, NetSerializable] public sealed class BorgRemoveModuleBuiMessage : BoundUserInterfaceMessage { - public EntityUid Module; + public NetEntity Module; - public BorgRemoveModuleBuiMessage(EntityUid module) + public BorgRemoveModuleBuiMessage(NetEntity module) { Module = module; } diff --git a/Content.Shared/Silicons/Borgs/Components/BorgChassisComponent.cs b/Content.Shared/Silicons/Borgs/Components/BorgChassisComponent.cs index 36441b50ad..71d3a7bd16 100644 --- a/Content.Shared/Silicons/Borgs/Components/BorgChassisComponent.cs +++ b/Content.Shared/Silicons/Borgs/Components/BorgChassisComponent.cs @@ -33,7 +33,7 @@ public sealed partial class BorgChassisComponent : Component public string BrainContainerId = "borg_brain"; [ViewVariables(VVAccess.ReadWrite)] - public ContainerSlot BrainContainer = new(); + public ContainerSlot BrainContainer = default!; public EntityUid? BrainEntity => BrainContainer.ContainedEntity; #endregion diff --git a/Content.Shared/Station/StationsUpdatedEvent.cs b/Content.Shared/Station/StationsUpdatedEvent.cs index 6e35630bbe..ff782b7650 100644 --- a/Content.Shared/Station/StationsUpdatedEvent.cs +++ b/Content.Shared/Station/StationsUpdatedEvent.cs @@ -5,9 +5,9 @@ namespace Content.Shared.Station; [NetSerializable, Serializable] public sealed class StationsUpdatedEvent : EntityEventArgs { - public readonly HashSet Stations; + public readonly HashSet Stations; - public StationsUpdatedEvent(HashSet stations) + public StationsUpdatedEvent(HashSet stations) { Stations = stations; } diff --git a/Content.Shared/StationRecords/SharedGeneralStationRecordConsoleSystem.cs b/Content.Shared/StationRecords/SharedGeneralStationRecordConsoleSystem.cs index 6eb8f505ff..27288a7a1f 100644 --- a/Content.Shared/StationRecords/SharedGeneralStationRecordConsoleSystem.cs +++ b/Content.Shared/StationRecords/SharedGeneralStationRecordConsoleSystem.cs @@ -32,12 +32,12 @@ public sealed class GeneralStationRecordConsoleState : BoundUserInterfaceState /// /// Current selected key. /// - public StationRecordKey? SelectedKey { get; } + public (NetEntity, uint)? SelectedKey { get; } public GeneralStationRecord? Record { get; } - public Dictionary? RecordListing { get; } + public Dictionary<(NetEntity, uint), string>? RecordListing { get; } public GeneralStationRecordsFilter? Filter { get; } - public GeneralStationRecordConsoleState(StationRecordKey? key, GeneralStationRecord? record, - Dictionary? recordListing, GeneralStationRecordsFilter? newFilter) + public GeneralStationRecordConsoleState((NetEntity, uint)? key, GeneralStationRecord? record, + Dictionary<(NetEntity, uint), string>? recordListing, GeneralStationRecordsFilter? newFilter) { SelectedKey = key; Record = record; @@ -52,9 +52,9 @@ public sealed class GeneralStationRecordConsoleState : BoundUserInterfaceState [Serializable, NetSerializable] public sealed class SelectGeneralStationRecord : BoundUserInterfaceMessage { - public StationRecordKey? SelectedKey { get; } + public (NetEntity, uint)? SelectedKey { get; } - public SelectGeneralStationRecord(StationRecordKey? selectedKey) + public SelectGeneralStationRecord((NetEntity, uint)? selectedKey) { SelectedKey = selectedKey; } diff --git a/Content.Shared/StationRecords/SharedStationRecordsSystem.cs b/Content.Shared/StationRecords/SharedStationRecordsSystem.cs new file mode 100644 index 0000000000..c2cc418f54 --- /dev/null +++ b/Content.Shared/StationRecords/SharedStationRecordsSystem.cs @@ -0,0 +1,43 @@ +namespace Content.Shared.StationRecords; + +public abstract class SharedStationRecordsSystem : EntitySystem +{ + public StationRecordKey? Convert((NetEntity, uint)? input) + { + return input == null ? null : Convert(input.Value); + } + + public (NetEntity, uint)? Convert(StationRecordKey? input) + { + return input == null ? null : Convert(input.Value); + } + + public StationRecordKey Convert((NetEntity, uint) input) + { + return new StationRecordKey(input.Item2, GetEntity(input.Item1)); + } + public (NetEntity, uint) Convert(StationRecordKey input) + { + return (GetNetEntity(input.OriginStation), input.Id); + } + + public List<(NetEntity, uint)> Convert(ICollection input) + { + var result = new List<(NetEntity, uint)>(input.Count); + foreach (var entry in input) + { + result.Add(Convert(entry)); + } + return result; + } + + public List Convert(ICollection<(NetEntity, uint)> input) + { + var result = new List(input.Count); + foreach (var entry in input) + { + result.Add(Convert(entry)); + } + return result; + } +} diff --git a/Content.Shared/StationRecords/StationRecordKey.cs b/Content.Shared/StationRecords/StationRecordKey.cs index d52ba4743c..937c3aa3ef 100644 --- a/Content.Shared/StationRecords/StationRecordKey.cs +++ b/Content.Shared/StationRecords/StationRecordKey.cs @@ -1,21 +1,37 @@ -using Robust.Shared.Serialization; - namespace Content.Shared.StationRecords; // Station record keys. These should be stored somewhere, // preferably within an ID card. -[Serializable, NetSerializable] -public readonly struct StationRecordKey +public readonly struct StationRecordKey : IEquatable { - [ViewVariables] - public uint ID { get; } + [DataField("id")] + public readonly uint Id; - [ViewVariables] - public EntityUid OriginStation { get; } + [DataField("station")] + public readonly EntityUid OriginStation; + + public static StationRecordKey Invalid = default; public StationRecordKey(uint id, EntityUid originStation) { - ID = id; + Id = id; OriginStation = originStation; } + + public bool Equals(StationRecordKey other) + { + return Id == other.Id && OriginStation.Id == other.OriginStation.Id; + } + + public override bool Equals(object? obj) + { + return obj is StationRecordKey other && Equals(other); + } + + public override int GetHashCode() + { + return HashCode.Combine(Id, OriginStation); + } + + public bool IsValid() => OriginStation.IsValid(); } diff --git a/Content.Shared/StationRecords/StationRecordKeyStorageComponent.cs b/Content.Shared/StationRecords/StationRecordKeyStorageComponent.cs index 1b7fc89d64..6509c223b6 100644 --- a/Content.Shared/StationRecords/StationRecordKeyStorageComponent.cs +++ b/Content.Shared/StationRecords/StationRecordKeyStorageComponent.cs @@ -16,9 +16,9 @@ public sealed partial class StationRecordKeyStorageComponent : Component [Serializable, NetSerializable] public sealed class StationRecordKeyStorageComponentState : ComponentState { - public StationRecordKey? Key; + public (NetEntity, uint)? Key; - public StationRecordKeyStorageComponentState(StationRecordKey? key) + public StationRecordKeyStorageComponentState((NetEntity, uint)? key) { Key = key; } diff --git a/Content.Shared/StationRecords/StationRecordKeyStorageSystem.cs b/Content.Shared/StationRecords/StationRecordKeyStorageSystem.cs index 94eda02c5f..05af0807f2 100644 --- a/Content.Shared/StationRecords/StationRecordKeyStorageSystem.cs +++ b/Content.Shared/StationRecords/StationRecordKeyStorageSystem.cs @@ -4,6 +4,8 @@ namespace Content.Shared.StationRecords; public sealed class StationRecordKeyStorageSystem : EntitySystem { + [Dependency] private readonly SharedStationRecordsSystem _records = default!; + public override void Initialize() { base.Initialize(); @@ -14,14 +16,14 @@ public sealed class StationRecordKeyStorageSystem : EntitySystem private void OnGetState(EntityUid uid, StationRecordKeyStorageComponent component, ref ComponentGetState args) { - args.State = new StationRecordKeyStorageComponentState(component.Key); + args.State = new StationRecordKeyStorageComponentState(_records.Convert(component.Key)); } private void OnHandleState(EntityUid uid, StationRecordKeyStorageComponent component, ref ComponentHandleState args) { if (args.Current is not StationRecordKeyStorageComponentState state) return; - component.Key = state.Key; + component.Key = _records.Convert(state.Key); } /// @@ -38,7 +40,7 @@ public sealed class StationRecordKeyStorageSystem : EntitySystem } keyStorage.Key = key; - Dirty(keyStorage); + Dirty(uid, keyStorage); } /// diff --git a/Content.Shared/StepTrigger/Components/StepTriggerComponent.cs b/Content.Shared/StepTrigger/Components/StepTriggerComponent.cs index 5031a3decd..7c84e54bdc 100644 --- a/Content.Shared/StepTrigger/Components/StepTriggerComponent.cs +++ b/Content.Shared/StepTrigger/Components/StepTriggerComponent.cs @@ -60,11 +60,11 @@ public sealed class StepTriggerComponentState : ComponentState { public float IntersectRatio { get; } public float RequiredTriggerSpeed { get; } - public readonly HashSet CurrentlySteppedOn; - public readonly HashSet Colliding; + public readonly HashSet CurrentlySteppedOn; + public readonly HashSet Colliding; public readonly bool Active; - public StepTriggerComponentState(float intersectRatio, HashSet currentlySteppedOn, HashSet colliding, float requiredTriggerSpeed, bool active) + public StepTriggerComponentState(float intersectRatio, HashSet currentlySteppedOn, HashSet colliding, float requiredTriggerSpeed, bool active) { IntersectRatio = intersectRatio; CurrentlySteppedOn = currentlySteppedOn; diff --git a/Content.Shared/StepTrigger/Systems/StepTriggerSystem.cs b/Content.Shared/StepTrigger/Systems/StepTriggerSystem.cs index d0abac8cbd..081262de0f 100644 --- a/Content.Shared/StepTrigger/Systems/StepTriggerSystem.cs +++ b/Content.Shared/StepTrigger/Systems/StepTriggerSystem.cs @@ -171,18 +171,14 @@ public sealed class StepTriggerSystem : EntitySystem component.RequiredTriggerSpeed = state.RequiredTriggerSpeed; component.IntersectRatio = state.IntersectRatio; component.Active = state.Active; + var stepped = EnsureEntitySet(state.CurrentlySteppedOn, uid); + var colliding = EnsureEntitySet(state.CurrentlySteppedOn, uid); - if (!component.CurrentlySteppedOn.SetEquals(state.CurrentlySteppedOn)) - { - component.CurrentlySteppedOn.Clear(); - component.CurrentlySteppedOn.UnionWith(state.CurrentlySteppedOn); - } + component.CurrentlySteppedOn.Clear(); + component.CurrentlySteppedOn.UnionWith(stepped); - if (!component.Colliding.SetEquals(state.Colliding)) - { - component.Colliding.Clear(); - component.Colliding.UnionWith(state.Colliding); - } + component.Colliding.Clear(); + component.Colliding.UnionWith(colliding); if (component.Colliding.Count > 0) { @@ -194,12 +190,12 @@ public sealed class StepTriggerSystem : EntitySystem } } - private static void TriggerGetState(EntityUid uid, StepTriggerComponent component, ref ComponentGetState args) + private void TriggerGetState(EntityUid uid, StepTriggerComponent component, ref ComponentGetState args) { args.State = new StepTriggerComponentState( component.IntersectRatio, - component.CurrentlySteppedOn, - component.Colliding, + GetNetEntitySet(component.CurrentlySteppedOn), + GetNetEntitySet(component.Colliding), component.RequiredTriggerSpeed, component.Active); } diff --git a/Content.Shared/Storage/Components/BinComponent.cs b/Content.Shared/Storage/Components/BinComponent.cs index 13617a60a1..4294ce1e79 100644 --- a/Content.Shared/Storage/Components/BinComponent.cs +++ b/Content.Shared/Storage/Components/BinComponent.cs @@ -56,13 +56,13 @@ public sealed partial class BinComponent : Component [Serializable, NetSerializable] public sealed class BinComponentState : ComponentState { - public List Items; + public List Items; public EntityWhitelist? Whitelist; public int MaxItems; - public BinComponentState(List items, EntityWhitelist? whitelist, int maxItems) + public BinComponentState(List items, EntityWhitelist? whitelist, int maxItems) { Items = items; Whitelist = whitelist; diff --git a/Content.Shared/Storage/EntitySystems/BinSystem.cs b/Content.Shared/Storage/EntitySystems/BinSystem.cs index 897a20b45d..e82861f4e1 100644 --- a/Content.Shared/Storage/EntitySystems/BinSystem.cs +++ b/Content.Shared/Storage/EntitySystems/BinSystem.cs @@ -38,7 +38,7 @@ public sealed class BinSystem : EntitySystem private void OnGetState(EntityUid uid, BinComponent component, ref ComponentGetState args) { - args.State = new BinComponentState(component.Items, component.Whitelist, component.MaxItems); + args.State = new BinComponentState(GetNetEntityList(component.Items), component.Whitelist, component.MaxItems); } private void OnHandleState(EntityUid uid, BinComponent component, ref ComponentHandleState args) @@ -46,7 +46,7 @@ public sealed class BinSystem : EntitySystem if (args.Current is not BinComponentState state) return; - component.Items = new List(state.Items); + component.Items = EnsureEntityList(state.Items, uid); component.Whitelist = state.Whitelist; component.MaxItems = state.MaxItems; } diff --git a/Content.Shared/Storage/EntitySystems/DumpableSystem.cs b/Content.Shared/Storage/EntitySystems/DumpableSystem.cs index 2131fdc9e8..d44cda40f4 100644 --- a/Content.Shared/Storage/EntitySystems/DumpableSystem.cs +++ b/Content.Shared/Storage/EntitySystems/DumpableSystem.cs @@ -81,7 +81,7 @@ public sealed class DumpableSystem : EntitySystem StartDoAfter(uid, args.Target, args.User, dumpable); }, Text = Loc.GetString("dump-disposal-verb-name", ("unit", args.Target)), - IconEntity = uid + IconEntity = GetNetEntity(uid) }; args.Verbs.Add(verb); } @@ -95,7 +95,7 @@ public sealed class DumpableSystem : EntitySystem StartDoAfter(uid, args.Target, args.User, dumpable); }, Text = Loc.GetString("dump-placeable-verb-name", ("surface", args.Target)), - IconEntity = uid + IconEntity = GetNetEntity(uid) }; args.Verbs.Add(verb); } @@ -108,7 +108,7 @@ public sealed class DumpableSystem : EntitySystem float delay = storage.StoredEntities.Count * (float) dumpable.DelayPerItem.TotalSeconds * dumpable.Multiplier; - _doAfterSystem.TryStartDoAfter(new DoAfterArgs(userUid, delay, new DumpableDoAfterEvent(), storageUid, target: targetUid, used: storageUid) + _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, userUid, delay, new DumpableDoAfterEvent(), storageUid, target: targetUid, used: storageUid) { BreakOnTargetMove = true, BreakOnUserMove = true, diff --git a/Content.Shared/Storage/Events.cs b/Content.Shared/Storage/Events.cs index 42defac7ff..c14495e171 100644 --- a/Content.Shared/Storage/Events.cs +++ b/Content.Shared/Storage/Events.cs @@ -7,13 +7,13 @@ namespace Content.Shared.Storage; public sealed partial class AreaPickupDoAfterEvent : DoAfterEvent { [DataField("entities", required: true)] - public IReadOnlyList Entities = default!; + public IReadOnlyList Entities = default!; private AreaPickupDoAfterEvent() { } - public AreaPickupDoAfterEvent(List entities) + public AreaPickupDoAfterEvent(List entities) { Entities = entities; } diff --git a/Content.Shared/Storage/SharedStorageComponent.cs b/Content.Shared/Storage/SharedStorageComponent.cs index b8694739d2..4573af6863 100644 --- a/Content.Shared/Storage/SharedStorageComponent.cs +++ b/Content.Shared/Storage/SharedStorageComponent.cs @@ -10,11 +10,11 @@ namespace Content.Shared.Storage [Serializable, NetSerializable] public sealed class StorageBoundUserInterfaceState : BoundUserInterfaceState { - public readonly List StoredEntities; + public readonly List StoredEntities; public readonly int StorageSizeUsed; public readonly int StorageCapacityMax; - public StorageBoundUserInterfaceState(List storedEntities, int storageSizeUsed, int storageCapacityMax) + public StorageBoundUserInterfaceState(List storedEntities, int storageSizeUsed, int storageCapacityMax) { StoredEntities = storedEntities; StorageSizeUsed = storageSizeUsed; @@ -30,8 +30,8 @@ namespace Content.Shared.Storage [Serializable, NetSerializable] public sealed class StorageInteractWithItemEvent : BoundUserInterfaceMessage { - public readonly EntityUid InteractedItemUID; - public StorageInteractWithItemEvent(EntityUid interactedItemUID) + public readonly NetEntity InteractedItemUID; + public StorageInteractWithItemEvent(NetEntity interactedItemUID) { InteractedItemUID = interactedItemUID; } @@ -59,12 +59,12 @@ namespace Content.Shared.Storage [Serializable, NetSerializable] public sealed class AnimateInsertingEntitiesEvent : EntityEventArgs { - public readonly EntityUid Storage; - public readonly List StoredEntities; - public readonly List EntityPositions; + public readonly NetEntity Storage; + public readonly List StoredEntities; + public readonly List EntityPositions; public readonly List EntityAngles; - public AnimateInsertingEntitiesEvent(EntityUid storage, List storedEntities, List entityPositions, List entityAngles) + public AnimateInsertingEntitiesEvent(NetEntity storage, List storedEntities, List entityPositions, List entityAngles) { Storage = storage; StoredEntities = storedEntities; diff --git a/Content.Shared/SurveillanceCamera/SharedSurveillanceCameraMonitorSystem.cs b/Content.Shared/SurveillanceCamera/SharedSurveillanceCameraMonitorSystem.cs index 9f64ff31fa..cc6193a090 100644 --- a/Content.Shared/SurveillanceCamera/SharedSurveillanceCameraMonitorSystem.cs +++ b/Content.Shared/SurveillanceCamera/SharedSurveillanceCameraMonitorSystem.cs @@ -9,7 +9,7 @@ public sealed class SurveillanceCameraMonitorUiState : BoundUserInterfaceState { // The active camera on the monitor. If this is null, the part of the UI // that contains the monitor should clear. - public EntityUid? ActiveCamera { get; } + public NetEntity? ActiveCamera { get; } // Currently available subnets. Does not send the entirety of the possible // cameras to view because that could be really, really large @@ -23,7 +23,7 @@ public sealed class SurveillanceCameraMonitorUiState : BoundUserInterfaceState // Known cameras, by address and name. public Dictionary Cameras { get; } - public SurveillanceCameraMonitorUiState(EntityUid? activeCamera, HashSet subnets, string activeAddress, string activeSubnet, Dictionary cameras) + public SurveillanceCameraMonitorUiState(NetEntity? activeCamera, HashSet subnets, string activeAddress, string activeSubnet, Dictionary cameras) { ActiveCamera = activeCamera; Subnets = subnets; diff --git a/Content.Shared/Tabletop/Events/TabletopDraggingPlayerChangedEvent.cs b/Content.Shared/Tabletop/Events/TabletopDraggingPlayerChangedEvent.cs index 8f32327db0..f51cb89634 100644 --- a/Content.Shared/Tabletop/Events/TabletopDraggingPlayerChangedEvent.cs +++ b/Content.Shared/Tabletop/Events/TabletopDraggingPlayerChangedEvent.cs @@ -12,11 +12,11 @@ namespace Content.Shared.Tabletop.Events /// /// The UID of the entity being dragged. /// - public EntityUid DraggedEntityUid; + public NetEntity DraggedEntityUid; public bool IsDragging; - public TabletopDraggingPlayerChangedEvent(EntityUid draggedEntityUid, bool isDragging) + public TabletopDraggingPlayerChangedEvent(NetEntity draggedEntityUid, bool isDragging) { DraggedEntityUid = draggedEntityUid; IsDragging = isDragging; diff --git a/Content.Shared/Tabletop/Events/TabletopMoveEvent.cs b/Content.Shared/Tabletop/Events/TabletopMoveEvent.cs index f6ac2e53a0..8abbd90aec 100644 --- a/Content.Shared/Tabletop/Events/TabletopMoveEvent.cs +++ b/Content.Shared/Tabletop/Events/TabletopMoveEvent.cs @@ -14,7 +14,7 @@ namespace Content.Shared.Tabletop.Events /// /// The UID of the entity being moved. /// - public EntityUid MovedEntityUid { get; } + public NetEntity MovedEntityUid { get; } /// /// The new coordinates of the entity being moved. @@ -24,9 +24,9 @@ namespace Content.Shared.Tabletop.Events /// /// The UID of the table the entity is being moved on. /// - public EntityUid TableUid { get; } + public NetEntity TableUid { get; } - public TabletopMoveEvent(EntityUid movedEntityUid, MapCoordinates coordinates, EntityUid tableUid) + public TabletopMoveEvent(NetEntity movedEntityUid, MapCoordinates coordinates, NetEntity tableUid) { MovedEntityUid = movedEntityUid; Coordinates = coordinates; diff --git a/Content.Shared/Tabletop/Events/TabletopPlayEvent.cs b/Content.Shared/Tabletop/Events/TabletopPlayEvent.cs index dfd3079e2f..566434bce7 100644 --- a/Content.Shared/Tabletop/Events/TabletopPlayEvent.cs +++ b/Content.Shared/Tabletop/Events/TabletopPlayEvent.cs @@ -8,12 +8,12 @@ namespace Content.Shared.Tabletop.Events [Serializable, NetSerializable] public sealed class TabletopPlayEvent : EntityEventArgs { - public EntityUid TableUid; - public EntityUid CameraUid; + public NetEntity TableUid; + public NetEntity CameraUid; public string Title; public Vector2i Size; - public TabletopPlayEvent(EntityUid tableUid, EntityUid cameraUid, string title, Vector2i size) + public TabletopPlayEvent(NetEntity tableUid, NetEntity cameraUid, string title, Vector2i size) { TableUid = tableUid; CameraUid = cameraUid; diff --git a/Content.Shared/Tabletop/Events/TabletopStopPlayingEvent.cs b/Content.Shared/Tabletop/Events/TabletopStopPlayingEvent.cs index f52bede662..23301dec4a 100644 --- a/Content.Shared/Tabletop/Events/TabletopStopPlayingEvent.cs +++ b/Content.Shared/Tabletop/Events/TabletopStopPlayingEvent.cs @@ -11,9 +11,9 @@ namespace Content.Shared.Tabletop.Events /// /// The entity UID of the table associated with this tabletop game. /// - public EntityUid TableUid; + public NetEntity TableUid; - public TabletopStopPlayingEvent(EntityUid tableUid) + public TabletopStopPlayingEvent(NetEntity tableUid) { TableUid = tableUid; } diff --git a/Content.Shared/Tabletop/SharedTabletopSystem.cs b/Content.Shared/Tabletop/SharedTabletopSystem.cs index 542542054a..1ff9030341 100644 --- a/Content.Shared/Tabletop/SharedTabletopSystem.cs +++ b/Content.Shared/Tabletop/SharedTabletopSystem.cs @@ -35,12 +35,15 @@ namespace Content.Shared.Tabletop if (args.SenderSession is not { AttachedEntity: { } playerEntity } playerSession) return; - if (!CanSeeTable(playerEntity, msg.TableUid) || !CanDrag(playerEntity, msg.MovedEntityUid, out _)) + var table = GetEntity(msg.TableUid); + var moved = GetEntity(msg.MovedEntityUid); + + if (!CanSeeTable(playerEntity, table) || !CanDrag(playerEntity, moved, out _)) return; // Move the entity and dirty it (we use the map ID from the entity so noone can try to be funny and move the item to another map) - var transform = EntityManager.GetComponent(msg.MovedEntityUid); - _transforms.SetParent(msg.MovedEntityUid, transform, _mapMan.GetMapEntityId(transform.MapID)); + var transform = EntityManager.GetComponent(moved); + _transforms.SetParent(moved, transform, _mapMan.GetMapEntityId(transform.MapID)); _transforms.SetLocalPositionNoLerp(transform, msg.Coordinates.Position); } @@ -51,13 +54,13 @@ namespace Content.Shared.Tabletop private void OnDraggingPlayerChanged(TabletopDraggingPlayerChangedEvent msg, EntitySessionEventArgs args) { - var dragged = msg.DraggedEntityUid; + var dragged = GetEntity(msg.DraggedEntityUid); if (!TryComp(dragged, out TabletopDraggableComponent? draggableComponent)) return; draggableComponent.DraggingPlayer = msg.IsDragging ? args.SenderSession.UserId : null; - Dirty(draggableComponent); + Dirty(dragged, draggableComponent); if (!TryComp(dragged, out AppearanceComponent? appearance)) return; @@ -89,8 +92,8 @@ namespace Content.Shared.Tabletop [Serializable, NetSerializable] public sealed class TabletopRequestTakeOut : EntityEventArgs { - public EntityUid Entity; - public EntityUid TableUid; + public NetEntity Entity; + public NetEntity TableUid; } #region Utility diff --git a/Content.Shared/Teleportation/Components/LinkedEntityComponent.cs b/Content.Shared/Teleportation/Components/LinkedEntityComponent.cs index b4dddafea3..ae9a1a03d0 100644 --- a/Content.Shared/Teleportation/Components/LinkedEntityComponent.cs +++ b/Content.Shared/Teleportation/Components/LinkedEntityComponent.cs @@ -27,9 +27,9 @@ public sealed partial class LinkedEntityComponent : Component [Serializable, NetSerializable] public sealed class LinkedEntityComponentState : ComponentState { - public HashSet LinkedEntities; + public HashSet LinkedEntities; - public LinkedEntityComponentState(HashSet linkedEntities) + public LinkedEntityComponentState(HashSet linkedEntities) { LinkedEntities = linkedEntities; } diff --git a/Content.Shared/Teleportation/Components/PortalTimeoutComponent.cs b/Content.Shared/Teleportation/Components/PortalTimeoutComponent.cs index 7c4c078eb2..37441508e1 100644 --- a/Content.Shared/Teleportation/Components/PortalTimeoutComponent.cs +++ b/Content.Shared/Teleportation/Components/PortalTimeoutComponent.cs @@ -20,9 +20,9 @@ public sealed partial class PortalTimeoutComponent : Component [Serializable, NetSerializable] public sealed class PortalTimeoutComponentState : ComponentState { - public EntityUid? EnteredPortal; + public NetEntity? EnteredPortal; - public PortalTimeoutComponentState(EntityUid? enteredPortal) + public PortalTimeoutComponentState(NetEntity? enteredPortal) { EnteredPortal = enteredPortal; } diff --git a/Content.Shared/Teleportation/Systems/LinkedEntitySystem.cs b/Content.Shared/Teleportation/Systems/LinkedEntitySystem.cs index 165e136505..12667e4886 100644 --- a/Content.Shared/Teleportation/Systems/LinkedEntitySystem.cs +++ b/Content.Shared/Teleportation/Systems/LinkedEntitySystem.cs @@ -26,13 +26,15 @@ public sealed class LinkedEntitySystem : EntitySystem private void OnGetState(EntityUid uid, LinkedEntityComponent component, ref ComponentGetState args) { - args.State = new LinkedEntityComponentState(component.LinkedEntities); + args.State = new LinkedEntityComponentState(GetNetEntitySet(component.LinkedEntities)); } private void OnHandleState(EntityUid uid, LinkedEntityComponent component, ref ComponentHandleState args) { if (args.Current is LinkedEntityComponentState state) - component.LinkedEntities = state.LinkedEntities; + { + component.LinkedEntities = EnsureEntitySet(state.LinkedEntities, uid); + } } private void OnLinkShutdown(EntityUid uid, LinkedEntityComponent component, ComponentShutdown args) diff --git a/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs b/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs index bb235bee5e..1ecaca57c3 100644 --- a/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs +++ b/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs @@ -79,13 +79,13 @@ public abstract class SharedPortalSystem : EntitySystem private void OnGetState(EntityUid uid, PortalTimeoutComponent component, ref ComponentGetState args) { - args.State = new PortalTimeoutComponentState(component.EnteredPortal); + args.State = new PortalTimeoutComponentState(GetNetEntity(component.EnteredPortal)); } private void OnHandleState(EntityUid uid, PortalTimeoutComponent component, ref ComponentHandleState args) { if (args.Current is PortalTimeoutComponentState state) - component.EnteredPortal = state.EnteredPortal; + component.EnteredPortal = EnsureEntity(state.EnteredPortal, uid); } private bool ShouldCollide(string ourId, string otherId, Fixture our, Fixture other) diff --git a/Content.Shared/Throwing/ThrownItemComponent.cs b/Content.Shared/Throwing/ThrownItemComponent.cs index 7a986d9b1d..eb09127dea 100644 --- a/Content.Shared/Throwing/ThrownItemComponent.cs +++ b/Content.Shared/Throwing/ThrownItemComponent.cs @@ -6,15 +6,16 @@ namespace Content.Shared.Throwing [RegisterComponent, NetworkedComponent] public sealed partial class ThrownItemComponent : Component { + [ViewVariables(VVAccess.ReadWrite), DataField("thrower")] public EntityUid? Thrower { get; set; } } [Serializable, NetSerializable] public sealed class ThrownItemComponentState : ComponentState { - public EntityUid? Thrower { get; } + public NetEntity? Thrower { get; } - public ThrownItemComponentState(EntityUid? thrower) + public ThrownItemComponentState(NetEntity? thrower) { Thrower = thrower; } diff --git a/Content.Shared/Throwing/ThrownItemSystem.cs b/Content.Shared/Throwing/ThrownItemSystem.cs index 2fcad4b184..7fb1cc6b8a 100644 --- a/Content.Shared/Throwing/ThrownItemSystem.cs +++ b/Content.Shared/Throwing/ThrownItemSystem.cs @@ -38,7 +38,7 @@ namespace Content.Shared.Throwing private void OnGetState(EntityUid uid, ThrownItemComponent component, ref ComponentGetState args) { - args.State = new ThrownItemComponentState(component.Thrower); + args.State = new ThrownItemComponentState(GetNetEntity(component.Thrower)); } private void OnHandleState(EntityUid uid, ThrownItemComponent component, ref ComponentHandleState args) @@ -49,7 +49,7 @@ namespace Content.Shared.Throwing return; } - component.Thrower = state.Thrower.Value; + component.Thrower = EnsureEntity(state.Thrower.Value, uid); } private void ThrowItem(EntityUid uid, ThrownItemComponent component, ThrownEvent args) diff --git a/Content.Shared/Tools/Systems/SharedToolSystem.cs b/Content.Shared/Tools/Systems/SharedToolSystem.cs index 7073b10f9d..716a9332d0 100644 --- a/Content.Shared/Tools/Systems/SharedToolSystem.cs +++ b/Content.Shared/Tools/Systems/SharedToolSystem.cs @@ -29,7 +29,7 @@ public abstract partial class SharedToolSystem : EntitySystem ev.DoAfter = args.DoAfter; if (args.OriginalTarget != null) - RaiseLocalEvent(args.OriginalTarget.Value, (object) ev); + RaiseLocalEvent(GetEntity(args.OriginalTarget.Value), (object) ev); else RaiseLocalEvent((object) ev); } @@ -108,8 +108,8 @@ public abstract partial class SharedToolSystem : EntitySystem if (!CanStartToolUse(tool, user, target, toolQualitiesNeeded, toolComponent)) return false; - var toolEvent = new ToolDoAfterEvent(doAfterEv, target); - var doAfterArgs = new DoAfterArgs(user, delay / toolComponent.SpeedModifier, toolEvent, tool, target: target, used: tool) + var toolEvent = new ToolDoAfterEvent(doAfterEv, GetNetEntity(target)); + var doAfterArgs = new DoAfterArgs(EntityManager, user, delay / toolComponent.SpeedModifier, toolEvent, tool, target: target, used: tool) { BreakOnDamage = true, BreakOnTargetMove = true, @@ -214,7 +214,7 @@ public abstract partial class SharedToolSystem : EntitySystem /// Entity that the wrapped do after event will get directed at. If null, event will be broadcast. /// [DataField("target")] - public EntityUid? OriginalTarget; + public NetEntity? OriginalTarget; [DataField("wrappedEvent")] public DoAfterEvent WrappedEvent = default!; @@ -223,7 +223,7 @@ public abstract partial class SharedToolSystem : EntitySystem { } - public ToolDoAfterEvent(DoAfterEvent wrappedEvent, EntityUid? originalTarget) + public ToolDoAfterEvent(DoAfterEvent wrappedEvent, NetEntity? originalTarget) { DebugTools.Assert(wrappedEvent.GetType().HasCustomAttribute(), "Tool event is not serializable"); @@ -247,13 +247,13 @@ public abstract partial class SharedToolSystem : EntitySystem protected sealed partial class LatticeCuttingCompleteEvent : DoAfterEvent { [DataField("coordinates", required:true)] - public EntityCoordinates Coordinates; + public NetCoordinates Coordinates; private LatticeCuttingCompleteEvent() { } - public LatticeCuttingCompleteEvent(EntityCoordinates coordinates) + public LatticeCuttingCompleteEvent(NetCoordinates coordinates) { Coordinates = coordinates; } @@ -264,14 +264,14 @@ public abstract partial class SharedToolSystem : EntitySystem [Serializable, NetSerializable] protected sealed partial class TilePryingDoAfterEvent : DoAfterEvent { - [DataField("coordinates", required:true)] - public EntityCoordinates Coordinates; + [DataField("coordinates", required: true)] + public NetCoordinates Coordinates; private TilePryingDoAfterEvent() { } - public TilePryingDoAfterEvent(EntityCoordinates coordinates) + public TilePryingDoAfterEvent(NetCoordinates coordinates) { Coordinates = coordinates; } diff --git a/Content.Shared/Vehicle/Components/RiderComponent.cs b/Content.Shared/Vehicle/Components/RiderComponent.cs index f006f9011e..a6618842e4 100644 --- a/Content.Shared/Vehicle/Components/RiderComponent.cs +++ b/Content.Shared/Vehicle/Components/RiderComponent.cs @@ -21,5 +21,5 @@ public sealed partial class RiderComponent : Component [Serializable, NetSerializable] public sealed class RiderComponentState : ComponentState { - public EntityUid? Entity; + public NetEntity? Entity; } diff --git a/Content.Shared/Vehicle/SharedVehicleSystem.Rider.cs b/Content.Shared/Vehicle/SharedVehicleSystem.Rider.cs index b4b566390c..3acd823c73 100644 --- a/Content.Shared/Vehicle/SharedVehicleSystem.Rider.cs +++ b/Content.Shared/Vehicle/SharedVehicleSystem.Rider.cs @@ -18,7 +18,7 @@ public abstract partial class SharedVehicleSystem { args.State = new RiderComponentState() { - Entity = component.Vehicle, + Entity = GetNetEntity(component.Vehicle), }; } diff --git a/Content.Shared/VendingMachines/SharedVendingMachineSystem.Restock.cs b/Content.Shared/VendingMachines/SharedVendingMachineSystem.Restock.cs index 2385982f8d..87e2f0890a 100644 --- a/Content.Shared/VendingMachines/SharedVendingMachineSystem.Restock.cs +++ b/Content.Shared/VendingMachines/SharedVendingMachineSystem.Restock.cs @@ -67,7 +67,7 @@ public abstract partial class SharedVendingMachineSystem args.Handled = true; - var doAfterArgs = new DoAfterArgs(args.User, (float) component.RestockDelay.TotalSeconds, new RestockDoAfterEvent(), target, + var doAfterArgs = new DoAfterArgs(EntityManager, args.User, (float) component.RestockDelay.TotalSeconds, new RestockDoAfterEvent(), target, target: target, used: uid) { BreakOnTargetMove = true, diff --git a/Content.Shared/Verbs/SharedVerbSystem.cs b/Content.Shared/Verbs/SharedVerbSystem.cs index 301c5555ee..40cb2d5002 100644 --- a/Content.Shared/Verbs/SharedVerbSystem.cs +++ b/Content.Shared/Verbs/SharedVerbSystem.cs @@ -24,14 +24,16 @@ namespace Content.Shared.Verbs if (user == null) return; + var target = GetEntity(args.Target); + // It is possible that client-side prediction can cause this event to be raised after the target entity has // been deleted. So we need to check that the entity still exists. - if (Deleted(args.Target) || Deleted(user)) + if (Deleted(target) || Deleted(user)) return; // Get the list of verbs. This effectively also checks that the requested verb is in fact a valid verb that // the user can perform. - var verbs = GetLocalVerbs(args.Target, user.Value, args.RequestedVerb.GetType()); + var verbs = GetLocalVerbs(target, user.Value, args.RequestedVerb.GetType()); // Note that GetLocalVerbs might waste time checking & preparing unrelated verbs even though we know // precisely which one we want to run. However, MOST entities will only have 1 or 2 verbs of a given type. @@ -39,7 +41,7 @@ namespace Content.Shared.Verbs // Find the requested verb. if (verbs.TryGetValue(args.RequestedVerb, out var verb)) - ExecuteVerb(verb, user.Value, args.Target); + ExecuteVerb(verb, user.Value, target); } /// diff --git a/Content.Shared/Verbs/Verb.cs b/Content.Shared/Verbs/Verb.cs index cd5edc22d9..33576b6b9c 100644 --- a/Content.Shared/Verbs/Verb.cs +++ b/Content.Shared/Verbs/Verb.cs @@ -112,7 +112,7 @@ namespace Content.Shared.Verbs /// If this is not null, and no icon or icon texture were specified, a sprite view of this entity will be /// used as the icon for this verb. /// - public EntityUid? IconEntity; + public NetEntity? IconEntity; /// /// Whether or not to close the context menu after using it to run this verb. @@ -221,7 +221,7 @@ namespace Content.Shared.Verbs typeof(AlternativeVerb), typeof(ActivationVerb), typeof(ExamineVerb), - typeof(EquipmentVerb) + typeof(EquipmentVerb) }; } diff --git a/Content.Shared/Verbs/VerbEvents.cs b/Content.Shared/Verbs/VerbEvents.cs index 64b92385c5..9a09d5d7a1 100644 --- a/Content.Shared/Verbs/VerbEvents.cs +++ b/Content.Shared/Verbs/VerbEvents.cs @@ -10,7 +10,7 @@ namespace Content.Shared.Verbs [Serializable, NetSerializable] public sealed class RequestServerVerbsEvent : EntityEventArgs { - public readonly EntityUid EntityUid; + public readonly NetEntity EntityUid; public readonly List VerbTypes = new(); @@ -18,11 +18,11 @@ namespace Content.Shared.Verbs /// If the target item is inside of some storage (e.g., backpack), this is the entity that owns that item /// slot. Needed for validating that the user can access the target item. /// - public readonly EntityUid? SlotOwner; + public readonly NetEntity? SlotOwner; public readonly bool AdminRequest; - public RequestServerVerbsEvent(EntityUid entityUid, IEnumerable verbTypes, EntityUid? slotOwner = null, bool adminRequest = false) + public RequestServerVerbsEvent(NetEntity entityUid, IEnumerable verbTypes, NetEntity? slotOwner = null, bool adminRequest = false) { EntityUid = entityUid; SlotOwner = slotOwner; @@ -40,9 +40,9 @@ namespace Content.Shared.Verbs public sealed class VerbsResponseEvent : EntityEventArgs { public readonly List? Verbs; - public readonly EntityUid Entity; + public readonly NetEntity Entity; - public VerbsResponseEvent(EntityUid entity, SortedSet? verbs) + public VerbsResponseEvent(NetEntity entity, SortedSet? verbs) { Entity = entity; @@ -57,10 +57,10 @@ namespace Content.Shared.Verbs [Serializable, NetSerializable] public sealed class ExecuteVerbEvent : EntityEventArgs { - public readonly EntityUid Target; + public readonly NetEntity Target; public readonly Verb RequestedVerb; - public ExecuteVerbEvent(EntityUid target, Verb requestedVerb) + public ExecuteVerbEvent(NetEntity target, Verb requestedVerb) { Target = target; RequestedVerb = requestedVerb; diff --git a/Content.Shared/Weapons/Melee/Events/AttackEvent.cs b/Content.Shared/Weapons/Melee/Events/AttackEvent.cs index cb731258d9..b823016832 100644 --- a/Content.Shared/Weapons/Melee/Events/AttackEvent.cs +++ b/Content.Shared/Weapons/Melee/Events/AttackEvent.cs @@ -10,9 +10,9 @@ namespace Content.Shared.Weapons.Melee.Events /// /// Coordinates being attacked. /// - public readonly EntityCoordinates Coordinates; + public readonly NetCoordinates Coordinates; - protected AttackEvent(EntityCoordinates coordinates) + protected AttackEvent(NetCoordinates coordinates) { Coordinates = coordinates; } diff --git a/Content.Shared/Weapons/Melee/Events/DisarmAttackEvent.cs b/Content.Shared/Weapons/Melee/Events/DisarmAttackEvent.cs index 51b6f90904..204b7b9f62 100644 --- a/Content.Shared/Weapons/Melee/Events/DisarmAttackEvent.cs +++ b/Content.Shared/Weapons/Melee/Events/DisarmAttackEvent.cs @@ -6,9 +6,9 @@ namespace Content.Shared.Weapons.Melee.Events; [Serializable, NetSerializable] public sealed class DisarmAttackEvent : AttackEvent { - public EntityUid? Target; + public NetEntity? Target; - public DisarmAttackEvent(EntityUid? target, EntityCoordinates coordinates) : base(coordinates) + public DisarmAttackEvent(NetEntity? target, NetCoordinates coordinates) : base(coordinates) { Target = target; } diff --git a/Content.Shared/Weapons/Melee/Events/HeavyAttackEvent.cs b/Content.Shared/Weapons/Melee/Events/HeavyAttackEvent.cs index 47d5d7f6c9..6ea6caadc9 100644 --- a/Content.Shared/Weapons/Melee/Events/HeavyAttackEvent.cs +++ b/Content.Shared/Weapons/Melee/Events/HeavyAttackEvent.cs @@ -9,14 +9,14 @@ namespace Content.Shared.Weapons.Melee.Events; [Serializable, NetSerializable] public sealed class HeavyAttackEvent : AttackEvent { - public readonly EntityUid Weapon; + public readonly NetEntity Weapon; /// /// As what the client swung at will not match server we'll have them tell us what they hit so we can verify. /// - public List Entities; + public List Entities; - public HeavyAttackEvent(EntityUid weapon, List entities, EntityCoordinates coordinates) : base(coordinates) + public HeavyAttackEvent(NetEntity weapon, List entities, NetCoordinates coordinates) : base(coordinates) { Weapon = weapon; Entities = entities; diff --git a/Content.Shared/Weapons/Melee/Events/LightAttackEvent.cs b/Content.Shared/Weapons/Melee/Events/LightAttackEvent.cs index 9b0f979f7d..0318747f38 100644 --- a/Content.Shared/Weapons/Melee/Events/LightAttackEvent.cs +++ b/Content.Shared/Weapons/Melee/Events/LightAttackEvent.cs @@ -9,10 +9,10 @@ namespace Content.Shared.Weapons.Melee.Events; [Serializable, NetSerializable] public sealed class LightAttackEvent : AttackEvent { - public readonly EntityUid? Target; - public readonly EntityUid Weapon; + public readonly NetEntity? Target; + public readonly NetEntity Weapon; - public LightAttackEvent(EntityUid? target, EntityUid weapon, EntityCoordinates coordinates) : base(coordinates) + public LightAttackEvent(NetEntity? target, NetEntity weapon, NetCoordinates coordinates) : base(coordinates) { Target = target; Weapon = weapon; diff --git a/Content.Shared/Weapons/Melee/Events/MeleeLungeEvent.cs b/Content.Shared/Weapons/Melee/Events/MeleeLungeEvent.cs index 012bec8ab5..66acc213c1 100644 --- a/Content.Shared/Weapons/Melee/Events/MeleeLungeEvent.cs +++ b/Content.Shared/Weapons/Melee/Events/MeleeLungeEvent.cs @@ -9,7 +9,7 @@ namespace Content.Shared.Weapons.Melee.Events; [Serializable, NetSerializable] public sealed class MeleeLungeEvent : EntityEventArgs { - public EntityUid Entity; + public NetEntity Entity; /// /// Width of the attack angle. @@ -26,9 +26,9 @@ public sealed class MeleeLungeEvent : EntityEventArgs /// public string? Animation; - public MeleeLungeEvent(EntityUid uid, Angle angle, Vector2 localPos, string? animation) + public MeleeLungeEvent(NetEntity entity, Angle angle, Vector2 localPos, string? animation) { - Entity = uid; + Entity = entity; Angle = angle; LocalPos = localPos; Animation = animation; diff --git a/Content.Shared/Weapons/Melee/Events/StopAttackEvent.cs b/Content.Shared/Weapons/Melee/Events/StopAttackEvent.cs index e7fa5cd4a2..ff98a5fb66 100644 --- a/Content.Shared/Weapons/Melee/Events/StopAttackEvent.cs +++ b/Content.Shared/Weapons/Melee/Events/StopAttackEvent.cs @@ -5,9 +5,9 @@ namespace Content.Shared.Weapons.Melee.Events; [Serializable, NetSerializable] public sealed class StopAttackEvent : EntityEventArgs { - public readonly EntityUid Weapon; + public readonly NetEntity Weapon; - public StopAttackEvent(EntityUid weapon) + public StopAttackEvent(NetEntity weapon) { Weapon = weapon; } diff --git a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs index 05f9997813..08ecea4326 100644 --- a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs +++ b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs @@ -164,7 +164,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem return; if (!TryGetWeapon(user.Value, out var weaponUid, out var weapon) || - weaponUid != msg.Weapon) + weaponUid != GetEntity(msg.Weapon)) { return; } @@ -184,12 +184,12 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem return; if (!TryGetWeapon(user.Value, out var weaponUid, out var weapon) || - weaponUid != msg.Weapon) + weaponUid != GetEntity(msg.Weapon)) { return; } - AttemptAttack(args.SenderSession.AttachedEntity!.Value, msg.Weapon, weapon, msg, args.SenderSession); + AttemptAttack(args.SenderSession.AttachedEntity!.Value, weaponUid, weapon, msg, args.SenderSession); } private void OnHeavyAttack(HeavyAttackEvent msg, EntitySessionEventArgs args) @@ -200,12 +200,12 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem } if (!TryGetWeapon(args.SenderSession.AttachedEntity.Value, out var weaponUid, out var weapon) || - weaponUid != msg.Weapon) + weaponUid != GetEntity(msg.Weapon)) { return; } - AttemptAttack(args.SenderSession.AttachedEntity.Value, msg.Weapon, weapon, msg, args.SenderSession); + AttemptAttack(args.SenderSession.AttachedEntity.Value, weaponUid, weapon, msg, args.SenderSession); } private void OnDisarmAttack(DisarmAttackEvent msg, EntitySessionEventArgs args) @@ -330,7 +330,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem public void AttemptLightAttackMiss(EntityUid user, EntityUid weaponUid, MeleeWeaponComponent weapon, EntityCoordinates coordinates) { - AttemptAttack(user, weaponUid, weapon, new LightAttackEvent(null, weaponUid, coordinates), null); + AttemptAttack(user, weaponUid, weapon, new LightAttackEvent(null, GetNetEntity(weaponUid), GetNetCoordinates(coordinates)), null); } public bool AttemptLightAttack(EntityUid user, EntityUid weaponUid, MeleeWeaponComponent weapon, EntityUid target) @@ -338,7 +338,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem if (!TryComp(target, out var targetXform)) return false; - return AttemptAttack(user, weaponUid, weapon, new LightAttackEvent(target, weaponUid, targetXform.Coordinates), null); + return AttemptAttack(user, weaponUid, weapon, new LightAttackEvent(GetNetEntity(target), GetNetEntity(weaponUid), GetNetCoordinates(targetXform.Coordinates)), null); } public bool AttemptDisarmAttack(EntityUid user, EntityUid weaponUid, MeleeWeaponComponent weapon, EntityUid target) @@ -346,7 +346,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem if (!TryComp(target, out var targetXform)) return false; - return AttemptAttack(user, weaponUid, weapon, new DisarmAttackEvent(target, targetXform.Coordinates), null); + return AttemptAttack(user, weaponUid, weapon, new DisarmAttackEvent(GetNetEntity(target), GetNetCoordinates(targetXform.Coordinates)), null); } /// @@ -366,16 +366,20 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem switch (attack) { case LightAttackEvent light: - if (!Blocker.CanAttack(user, light.Target)) + var lightTarget = GetEntity(light.Target); + + if (!Blocker.CanAttack(user, lightTarget)) return false; // Can't self-attack if you're the weapon - if (weaponUid == light.Target) + if (weaponUid == lightTarget) return false; break; case DisarmAttackEvent disarm: - if (!Blocker.CanAttack(user, disarm.Target)) + var disarmTarget = GetEntity(disarm.Target); + + if (!Blocker.CanAttack(user, disarmTarget)) return false; break; default: @@ -441,7 +445,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem throw new NotImplementedException(); } - DoLungeAnimation(user, weapon.Angle, attack.Coordinates.ToMap(EntityManager, TransformSystem), weapon.Range, animation); + DoLungeAnimation(user, weapon.Angle, GetCoordinates(attack.Coordinates).ToMap(EntityManager, TransformSystem), weapon.Range, animation); } weapon.Attacking = true; @@ -454,13 +458,14 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem { // If I do not come back later to fix Light Attacks being Heavy Attacks you can throw me in the spider pit -Errant var damage = GetDamage(meleeUid, user, component) * GetHeavyDamageModifier(meleeUid, user, component); + var target = GetEntity(ev.Target); // For consistency with wide attacks stuff needs damageable. - if (Deleted(ev.Target) || - !HasComp(ev.Target) || - !TryComp(ev.Target, out var targetXform) || + if (Deleted(target) || + !HasComp(target) || + !TryComp(target, out var targetXform) || // Not in LOS. - !InRange(user, ev.Target.Value, component.Range, session)) + !InRange(user, target.Value, component.Range, session)) { // Leave IsHit set to true, because the only time it's set to false // is when a melee weapon is examined. Misses are inferred from an @@ -485,7 +490,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem // Sawmill.Debug($"Melee damage is {damage.Total} out of {component.Damage.Total}"); // Raise event before doing damage so we can cancel damage if the event is handled - var hitEvent = new MeleeHitEvent(new List { ev.Target.Value }, user, meleeUid, damage); + var hitEvent = new MeleeHitEvent(new List { target.Value }, user, meleeUid, damage); RaiseLocalEvent(meleeUid, hitEvent); if (hitEvent.Handled) @@ -493,43 +498,45 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem var targets = new List(1) { - ev.Target.Value + target.Value }; - Interaction.DoContactInteraction(ev.Weapon, ev.Target); - Interaction.DoContactInteraction(user, ev.Weapon); + var weapon = GetEntity(ev.Weapon); + + Interaction.DoContactInteraction(weapon, target); + Interaction.DoContactInteraction(user, weapon); // If the user is using a long-range weapon, this probably shouldn't be happening? But I'll interpret melee as a // somewhat messy scuffle. See also, heavy attacks. - Interaction.DoContactInteraction(user, ev.Target); + Interaction.DoContactInteraction(user, target); // For stuff that cares about it being attacked. var attackedEvent = new AttackedEvent(meleeUid, user, targetXform.Coordinates); - RaiseLocalEvent(ev.Target.Value, attackedEvent); + RaiseLocalEvent(target.Value, attackedEvent); var modifiedDamage = DamageSpecifier.ApplyModifierSets(damage + hitEvent.BonusDamage + attackedEvent.BonusDamage, hitEvent.ModifiersList); - var damageResult = Damageable.TryChangeDamage(ev.Target, modifiedDamage, origin:user); + var damageResult = Damageable.TryChangeDamage(target, modifiedDamage, origin:user); if (damageResult != null && damageResult.Total > FixedPoint2.Zero) { // If the target has stamina and is taking blunt damage, they should also take stamina damage based on their blunt to stamina factor if (damageResult.DamageDict.TryGetValue("Blunt", out var bluntDamage)) { - _stamina.TakeStaminaDamage(ev.Target.Value, (bluntDamage * component.BluntStaminaDamageFactor).Float(), visual: false, source: user, with: meleeUid == user ? null : meleeUid); + _stamina.TakeStaminaDamage(target.Value, (bluntDamage * component.BluntStaminaDamageFactor).Float(), visual: false, source: user, with: meleeUid == user ? null : meleeUid); } if (meleeUid == user) { AdminLogger.Add(LogType.MeleeHit, LogImpact.Medium, - $"{ToPrettyString(user):actor} melee attacked (light) {ToPrettyString(ev.Target.Value):subject} using their hands and dealt {damageResult.Total:damage} damage"); + $"{ToPrettyString(user):actor} melee attacked (light) {ToPrettyString(target.Value):subject} using their hands and dealt {damageResult.Total:damage} damage"); } else { AdminLogger.Add(LogType.MeleeHit, LogImpact.Medium, - $"{ToPrettyString(user):actor} melee attacked (light) {ToPrettyString(ev.Target.Value):subject} using {ToPrettyString(meleeUid):tool} and dealt {damageResult.Total:damage} damage"); + $"{ToPrettyString(user):actor} melee attacked (light) {ToPrettyString(target.Value):subject} using {ToPrettyString(meleeUid):tool} and dealt {damageResult.Total:damage} damage"); } - PlayHitSound(ev.Target.Value, user, GetHighestDamageSound(modifiedDamage, _protoManager), hitEvent.HitSoundOverride, component.HitSound); + PlayHitSound(target.Value, user, GetHighestDamageSound(modifiedDamage, _protoManager), hitEvent.HitSoundOverride, component.HitSound); } else { @@ -561,7 +568,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem if (!TryComp(user, out var userXform)) return false; - var targetMap = ev.Coordinates.ToMap(EntityManager, TransformSystem); + var targetMap = GetCoordinates(ev.Coordinates).ToMap(EntityManager, TransformSystem); if (targetMap.MapId != userXform.MapID) return false; @@ -571,7 +578,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem var distance = Math.Min(component.Range, direction.Length()); var damage = GetDamage(meleeUid, user, component); - var entities = ev.Entities; + var entities = GetEntityList(ev.Entities); if (entities.Count == 0) { @@ -632,12 +639,14 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem if (hitEvent.Handled) return true; - Interaction.DoContactInteraction(user, ev.Weapon); + var weapon = GetEntity(ev.Weapon); + + Interaction.DoContactInteraction(user, weapon); // For stuff that cares about it being attacked. foreach (var target in targets) { - Interaction.DoContactInteraction(ev.Weapon, target); + Interaction.DoContactInteraction(weapon, target); // If the user is using a long-range weapon, this probably shouldn't be happening? But I'll interpret melee as a // somewhat messy scuffle. See also, light attacks. @@ -648,7 +657,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem foreach (var entity in targets) { - var attackedEvent = new AttackedEvent(meleeUid, user, ev.Coordinates); + var attackedEvent = new AttackedEvent(meleeUid, user, GetCoordinates(ev.Coordinates)); RaiseLocalEvent(entity, attackedEvent); var modifiedDamage = DamageSpecifier.ApplyModifierSets(damage + hitEvent.BonusDamage + attackedEvent.BonusDamage, hitEvent.ModifiersList); @@ -820,9 +829,13 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem protected virtual bool DoDisarm(EntityUid user, DisarmAttackEvent ev, EntityUid meleeUid, MeleeWeaponComponent component, ICommonSession? session) { - if (Deleted(ev.Target) || - user == ev.Target) + var target = GetEntity(ev.Target); + + if (Deleted(target) || + user == target) + { return false; + } // Play a sound to give instant feedback; same with playing the animations Audio.PlayPredicted(component.SwingSound, meleeUid, user); diff --git a/Content.Shared/Weapons/Misc/SharedTetherGunSystem.cs b/Content.Shared/Weapons/Misc/SharedTetherGunSystem.cs index 3c88e716b6..807395c465 100644 --- a/Content.Shared/Weapons/Misc/SharedTetherGunSystem.cs +++ b/Content.Shared/Weapons/Misc/SharedTetherGunSystem.cs @@ -112,14 +112,16 @@ public abstract partial class SharedTetherGunSystem : EntitySystem return; } - if (!msg.Coordinates.TryDistance(EntityManager, TransformSystem, Transform(gunUid.Value).Coordinates, + var coords = GetCoordinates(msg.Coordinates); + + if (!coords.TryDistance(EntityManager, TransformSystem, Transform(gunUid.Value).Coordinates, out var distance) || distance > gun.MaxDistance) { return; } - TransformSystem.SetCoordinates(gun.TetherEntity.Value, msg.Coordinates); + TransformSystem.SetCoordinates(gun.TetherEntity.Value, coords); } private void OnTetherRanged(EntityUid uid, TetherGunComponent component, AfterInteractEvent args) @@ -283,7 +285,7 @@ public abstract partial class SharedTetherGunSystem : EntitySystem [Serializable, NetSerializable] protected sealed class RequestTetherMoveEvent : EntityEventArgs { - public EntityCoordinates Coordinates; + public NetCoordinates Coordinates; } [Serializable, NetSerializable] diff --git a/Content.Shared/Weapons/Ranged/Components/BallisticAmmoProviderComponent.cs b/Content.Shared/Weapons/Ranged/Components/BallisticAmmoProviderComponent.cs index d5fb2e7dc8..8d0f6a5283 100644 --- a/Content.Shared/Weapons/Ranged/Components/BallisticAmmoProviderComponent.cs +++ b/Content.Shared/Weapons/Ranged/Components/BallisticAmmoProviderComponent.cs @@ -7,7 +7,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy namespace Content.Shared.Weapons.Ranged.Components; -[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +[RegisterComponent, NetworkedComponent] public sealed partial class BallisticAmmoProviderComponent : Component { [ViewVariables(VVAccess.ReadWrite), DataField("soundRack")] @@ -25,7 +25,6 @@ public sealed partial class BallisticAmmoProviderComponent : Component public int Count => UnspawnedCount + Container.ContainedEntities.Count; [ViewVariables(VVAccess.ReadWrite), DataField("unspawnedCount")] - [AutoNetworkedField] public int UnspawnedCount; [ViewVariables(VVAccess.ReadWrite), DataField("whitelist")] @@ -35,7 +34,6 @@ public sealed partial class BallisticAmmoProviderComponent : Component // TODO: Make this use stacks when the typeserializer is done. [DataField("entities")] - [AutoNetworkedField(true)] public List Entities = new(); /// @@ -45,7 +43,6 @@ public sealed partial class BallisticAmmoProviderComponent : Component /// Set to false for entities like turrets to avoid users being able to cycle them. /// [ViewVariables(VVAccess.ReadWrite), DataField("cycleable")] - [AutoNetworkedField] public bool Cycleable = true; /// diff --git a/Content.Shared/Weapons/Ranged/Events/MuzzleFlashEvent.cs b/Content.Shared/Weapons/Ranged/Events/MuzzleFlashEvent.cs index ca9c3f8706..91f5e6cd86 100644 --- a/Content.Shared/Weapons/Ranged/Events/MuzzleFlashEvent.cs +++ b/Content.Shared/Weapons/Ranged/Events/MuzzleFlashEvent.cs @@ -8,7 +8,7 @@ namespace Content.Shared.Weapons.Ranged.Events; [Serializable, NetSerializable] public sealed class MuzzleFlashEvent : EntityEventArgs { - public EntityUid Uid; + public NetEntity Uid; public string Prototype; /// @@ -16,7 +16,7 @@ public sealed class MuzzleFlashEvent : EntityEventArgs /// public bool MatchRotation; - public MuzzleFlashEvent(EntityUid uid, string prototype, bool matchRotation = false) + public MuzzleFlashEvent(NetEntity uid, string prototype, bool matchRotation = false) { Uid = uid; Prototype = prototype; diff --git a/Content.Shared/Weapons/Ranged/Events/RequestShootEvent.cs b/Content.Shared/Weapons/Ranged/Events/RequestShootEvent.cs index af352d8445..21e90b2108 100644 --- a/Content.Shared/Weapons/Ranged/Events/RequestShootEvent.cs +++ b/Content.Shared/Weapons/Ranged/Events/RequestShootEvent.cs @@ -9,6 +9,6 @@ namespace Content.Shared.Weapons.Ranged.Events; [Serializable, NetSerializable] public sealed class RequestShootEvent : EntityEventArgs { - public EntityUid Gun; - public EntityCoordinates Coordinates; -} \ No newline at end of file + public NetEntity Gun; + public NetCoordinates Coordinates; +} diff --git a/Content.Shared/Weapons/Ranged/Events/RequestStopShootEvent.cs b/Content.Shared/Weapons/Ranged/Events/RequestStopShootEvent.cs index 5fc1f5dc4e..8cbe6f6487 100644 --- a/Content.Shared/Weapons/Ranged/Events/RequestStopShootEvent.cs +++ b/Content.Shared/Weapons/Ranged/Events/RequestStopShootEvent.cs @@ -8,5 +8,5 @@ namespace Content.Shared.Weapons.Ranged.Events; [Serializable, NetSerializable] public sealed class RequestStopShootEvent : EntityEventArgs { - public EntityUid Gun; -} \ No newline at end of file + public NetEntity Gun; +} diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs index aea7fb4e8b..f8b2394315 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs @@ -29,6 +29,29 @@ public abstract partial class SharedGunSystem SubscribeLocalEvent(OnBallisticAfterInteract); SubscribeLocalEvent(OnBallisticAmmoFillDoAfter); SubscribeLocalEvent(OnBallisticUse); + + SubscribeLocalEvent(OnBallisticGetState); + SubscribeLocalEvent(OnBallisticHandleState); + } + + private void OnBallisticGetState(EntityUid uid, BallisticAmmoProviderComponent component, ref ComponentGetState args) + { + args.State = new BallisticAmmoProviderComponentState() + { + UnspawnedCount = component.UnspawnedCount, + Cycleable = component.Cycleable, + Entities = GetNetEntityList(component.Entities), + }; + } + + private void OnBallisticHandleState(EntityUid uid, BallisticAmmoProviderComponent component, ref ComponentHandleState args) + { + if (args.Current is not BallisticAmmoProviderComponentState state) + return; + + component.UnspawnedCount = state.UnspawnedCount; + component.Cycleable = state.Cycleable; + component.Entities = EnsureEntityList(state.Entities, uid); } private void OnBallisticUse(EntityUid uid, BallisticAmmoProviderComponent component, UseInHandEvent args) @@ -73,7 +96,7 @@ public abstract partial class SharedGunSystem args.Handled = true; - _doAfter.TryStartDoAfter(new DoAfterArgs(args.User, component.FillDelay, new AmmoFillDoAfterEvent(), used: uid, target: args.Target, eventTarget: uid) + _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.FillDelay, new AmmoFillDoAfterEvent(), used: uid, target: args.Target, eventTarget: uid) { BreakOnTargetMove = true, BreakOnUserMove = true, @@ -141,7 +164,7 @@ public abstract partial class SharedGunSystem SimulateInsertAmmo(ent.Value, args.Target.Value, Transform(args.Target.Value).Coordinates); } - if (ent.Value.IsClientSide()) + if (IsClientSide(ent.Value)) Del(ent.Value); } @@ -269,6 +292,14 @@ public abstract partial class SharedGunSystem Appearance.SetData(uid, AmmoVisuals.AmmoCount, GetBallisticShots(component), appearance); Appearance.SetData(uid, AmmoVisuals.AmmoMax, component.Capacity, appearance); } + + [Serializable, NetSerializable] + private sealed class BallisticAmmoProviderComponentState : ComponentState + { + public int UnspawnedCount; + public List Entities = new(); + public bool Cycleable = true; + } } /// diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs index f66950711e..f5eb7e8712 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs @@ -47,7 +47,7 @@ public partial class SharedGunSystem args.State = new RevolverAmmoProviderComponentState { CurrentIndex = component.CurrentIndex, - AmmoSlots = component.AmmoSlots, + AmmoSlots = GetNetEntityList(component.AmmoSlots), Chambers = component.Chambers, }; } @@ -64,7 +64,7 @@ public partial class SharedGunSystem // Need to copy across the state rather than the ref. for (var i = 0; i < component.AmmoSlots.Count; i++) { - component.AmmoSlots[i] = state.AmmoSlots[i]; + component.AmmoSlots[i] = EnsureEntity(state.AmmoSlots[i], uid); component.Chambers[i] = state.Chambers[i]; } @@ -416,7 +416,7 @@ public partial class SharedGunSystem protected sealed class RevolverAmmoProviderComponentState : ComponentState { public int CurrentIndex; - public List AmmoSlots = default!; + public List AmmoSlots = default!; public bool?[] Chambers = default!; } diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs index 797a2f472d..5ef5112152 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs @@ -131,18 +131,20 @@ public abstract partial class SharedGunSystem : EntitySystem return; } - if (ent != msg.Gun) + if (ent != GetEntity(msg.Gun)) return; - gun.ShootCoordinates = msg.Coordinates; + gun.ShootCoordinates = GetCoordinates(msg.Coordinates); Log.Debug($"Set shoot coordinates to {gun.ShootCoordinates}"); AttemptShoot(user.Value, ent, gun); } private void OnStopShootRequest(RequestStopShootEvent ev, EntitySessionEventArgs args) { + var gunUid = GetEntity(ev.Gun); + if (args.SenderSession.AttachedEntity == null || - !TryComp(ev.Gun, out var gun) || + !TryComp(gunUid, out var gun) || !TryGetGun(args.SenderSession.AttachedEntity.Value, out _, out var userGun)) { return; @@ -151,7 +153,7 @@ public abstract partial class SharedGunSystem : EntitySystem if (userGun != gun) return; - StopShooting(ev.Gun, gun); + StopShooting(gunUid, gun); } public bool CanShoot(GunComponent component) @@ -432,7 +434,7 @@ public abstract partial class SharedGunSystem : EntitySystem if (sprite == null) return; - var ev = new MuzzleFlashEvent(gun, sprite, user == gun); + var ev = new MuzzleFlashEvent(GetNetEntity(gun), sprite, user == gun); CreateEffect(gun, ev, user); } @@ -454,7 +456,7 @@ public abstract partial class SharedGunSystem : EntitySystem [Serializable, NetSerializable] public sealed class HitscanEvent : EntityEventArgs { - public List<(EntityCoordinates coordinates, Angle angle, SpriteSpecifier Sprite, float Distance)> Sprites = new(); + public List<(NetCoordinates coordinates, Angle angle, SpriteSpecifier Sprite, float Distance)> Sprites = new(); } } diff --git a/Content.Shared/Wieldable/WieldableSystem.cs b/Content.Shared/Wieldable/WieldableSystem.cs index 020e5c2ad0..d4d83dfdf7 100644 --- a/Content.Shared/Wieldable/WieldableSystem.cs +++ b/Content.Shared/Wieldable/WieldableSystem.cs @@ -170,7 +170,7 @@ public sealed class WieldableSystem : EntitySystem if (ev.Cancelled) return false; - var doargs = new DoAfterArgs(user, component.WieldTime, new WieldableDoAfterEvent(), used, used: used) + var doargs = new DoAfterArgs(EntityManager, user, component.WieldTime, new WieldableDoAfterEvent(), used, used: used) { BreakOnUserMove = false, BreakOnDamage = true diff --git a/Content.Shared/Xenoarchaeology/Equipment/SharedArtifactAnalyzer.cs b/Content.Shared/Xenoarchaeology/Equipment/SharedArtifactAnalyzer.cs index 3945d93ca3..151bea990f 100644 --- a/Content.Shared/Xenoarchaeology/Equipment/SharedArtifactAnalyzer.cs +++ b/Content.Shared/Xenoarchaeology/Equipment/SharedArtifactAnalyzer.cs @@ -32,7 +32,7 @@ public sealed class AnalysisConsoleExtractButtonPressedMessage : BoundUserInterf [Serializable, NetSerializable] public sealed class AnalysisConsoleScanUpdateState : BoundUserInterfaceState { - public EntityUid? Artifact; + public NetEntity? Artifact; public bool AnalyzerConnected; @@ -52,7 +52,7 @@ public sealed class AnalysisConsoleScanUpdateState : BoundUserInterfaceState public int PointAmount; - public AnalysisConsoleScanUpdateState(EntityUid? artifact, bool analyzerConnected, bool serverConnected, bool canScan, bool canPrint, + public AnalysisConsoleScanUpdateState(NetEntity? artifact, bool analyzerConnected, bool serverConnected, bool canScan, bool canPrint, FormattedMessage? scanReport, bool scanning, TimeSpan timeRemaining, TimeSpan totalTime, int pointAmount) { Artifact = artifact;