diff --git a/Content.Client/Guidebook/GuidebookSystem.cs b/Content.Client/Guidebook/GuidebookSystem.cs index 675a025d7a..ac88c4120f 100644 --- a/Content.Client/Guidebook/GuidebookSystem.cs +++ b/Content.Client/Guidebook/GuidebookSystem.cs @@ -32,6 +32,7 @@ public sealed class GuidebookSystem : EntitySystem [Dependency] private readonly RgbLightControllerSystem _rgbLightControllerSystem = default!; [Dependency] private readonly SharedPointLightSystem _pointLightSystem = default!; [Dependency] private readonly TagSystem _tags = default!; + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; public event Action>, List>?, @@ -140,17 +141,16 @@ public sealed class GuidebookSystem : EntitySystem }); } - private void OnGuidebookControlsTestActivateInWorld(EntityUid uid, GuidebookControlsTestComponent component, ActivateInWorldEvent args) - { - Transform(uid).LocalRotation += Angle.FromDegrees(90); - } + private void OnGuidebookControlsTestActivateInWorld(EntityUid uid, GuidebookControlsTestComponent component, ActivateInWorldEvent args) => Transform(uid).LocalRotation += Angle.FromDegrees(90); private void OnGuidebookControlsTestInteractHand(EntityUid uid, GuidebookControlsTestComponent component, InteractHandEvent args) { - if (!TryComp(uid, out var speech) || speech.SpeechSounds is null) + if (!TryComp(uid, out var speech) + || !_prototypeManager.TryIndex(speech.SpeechSounds, out var sounds)) return; - _audioSystem.PlayGlobal(speech.SpeechSounds, Filter.Local(), false, speech.AudioParams); + // TODO: I don't know if this is correct. Help. + _audioSystem.PlayGlobal(sounds.SaySound, Filter.Local(), false, speech.AudioParams); } public void FakeClientActivateInWorld(EntityUid activated) diff --git a/Content.IntegrationTests/Tests/SaveLoadSaveTest.cs b/Content.IntegrationTests/Tests/SaveLoadSaveTest.cs index af60db5532..756437e26d 100644 --- a/Content.IntegrationTests/Tests/SaveLoadSaveTest.cs +++ b/Content.IntegrationTests/Tests/SaveLoadSaveTest.cs @@ -2,7 +2,8 @@ using System.IO; using System.Linq; using Content.Shared.CCVar; using Robust.Server.GameObjects; -using Robust.Server.Maps; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Configuration; using Robust.Shared.ContentPack; using Robust.Shared.GameObjects; diff --git a/Content.Server/Administration/Commands/LoadGameMapCommand.cs b/Content.Server/Administration/Commands/LoadGameMapCommand.cs index ea31c1ecb1..0cc6098dd5 100644 --- a/Content.Server/Administration/Commands/LoadGameMapCommand.cs +++ b/Content.Server/Administration/Commands/LoadGameMapCommand.cs @@ -3,7 +3,8 @@ using System.Numerics; using Content.Server.GameTicking; using Content.Server.Maps; using Content.Shared.Administration; -using Robust.Server.Maps; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Console; using Robust.Shared.ContentPack; using Robust.Shared.Map; diff --git a/Content.Server/Administration/Systems/AdminTestArenaSystem.cs b/Content.Server/Administration/Systems/AdminTestArenaSystem.cs index e3671bcdfb..76fcd81751 100644 --- a/Content.Server/Administration/Systems/AdminTestArenaSystem.cs +++ b/Content.Server/Administration/Systems/AdminTestArenaSystem.cs @@ -1,4 +1,5 @@ using Robust.Server.GameObjects; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Map; using Robust.Shared.Map.Components; using Robust.Shared.Network; diff --git a/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs b/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs index 1480c28bf2..cc0ebd62e9 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs @@ -13,7 +13,8 @@ using Content.Shared.GameTicking; using Content.Shared.Shuttles.Components; using Content.Shared.Tiles; using Content.Shared.Whitelist; -using Robust.Server.Maps; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Map; using Robust.Shared.Random; using Robust.Shared.Audio; diff --git a/Content.Server/Cargo/Systems/CargoSystem.cs b/Content.Server/Cargo/Systems/CargoSystem.cs index 25e63c9f18..26b67632c9 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.cs @@ -17,6 +17,8 @@ using Robust.Server.GameObjects; using Robust.Shared.Audio.Systems; using Robust.Shared.Configuration; using Robust.Shared.Map; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Prototypes; using Robust.Shared.Timing; using Robust.Shared.Random; diff --git a/Content.Server/DeltaV/Station/Systems/StationSurfaceSystem.cs b/Content.Server/DeltaV/Station/Systems/StationSurfaceSystem.cs index 387d111735..129866e72b 100644 --- a/Content.Server/DeltaV/Station/Systems/StationSurfaceSystem.cs +++ b/Content.Server/DeltaV/Station/Systems/StationSurfaceSystem.cs @@ -1,6 +1,8 @@ using Content.Server.Parallax; using Content.Server.Station.Components; using Robust.Server.GameObjects; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; namespace Content.Server.Station.Systems; diff --git a/Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs b/Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs index a8d40882c4..1988a07cea 100644 --- a/Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs +++ b/Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs @@ -20,7 +20,7 @@ public sealed class DeviceListSystem : SharedDeviceListSystem SubscribeLocalEvent(OnShutdown); SubscribeLocalEvent(OnBeforeBroadcast); SubscribeLocalEvent(OnBeforePacketSent); - SubscribeLocalEvent(OnMapSave); + SubscribeLocalEvent(OnMapSave); } private void OnShutdown(EntityUid uid, DeviceListComponent component, ComponentShutdown args) @@ -124,14 +124,14 @@ public sealed class DeviceListSystem : SharedDeviceListSystem Dirty(list); } - private void OnMapSave(BeforeSaveEvent ev) + private void OnMapSave(BeforeSerializationEvent ev) { List toRemove = new(); var query = GetEntityQuery(); var enumerator = AllEntityQuery(); while (enumerator.MoveNext(out var uid, out var device, out var xform)) { - if (xform.MapUid != ev.Map) + if (!ev.MapIds.Contains(xform.MapID)) continue; foreach (var ent in device.Devices) @@ -144,7 +144,10 @@ public sealed class DeviceListSystem : SharedDeviceListSystem continue; } - if (linkedXform.MapUid == ev.Map) + // This is assuming that **all** of the map is getting saved. + // Which is not necessarily true. + // AAAAAAAAAAAAAA + if (ev.MapIds.Contains(linkedXform.MapID)) continue; toRemove.Add(ent); diff --git a/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs b/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs index efaf568094..645d28f6d2 100644 --- a/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs +++ b/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs @@ -67,15 +67,18 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem SubscribeLocalEvent(OnComponentRemoved); - SubscribeLocalEvent(OnMapSave); + SubscribeLocalEvent(OnMapSave); } - private void OnMapSave(BeforeSaveEvent ev) + private void OnMapSave(BeforeSerializationEvent ev) { var enumerator = AllEntityQuery(); while (enumerator.MoveNext(out var uid, out var conf)) { - if (CompOrNull(conf.ActiveDeviceList)?.MapUid != ev.Map) + if (!TryComp(conf.ActiveDeviceList, out TransformComponent? listXform)) + continue; + + if (!ev.MapIds.Contains(listXform.MapID)) continue; // The linked device list is (probably) being saved. Make sure that the configurator is also being saved @@ -83,9 +86,10 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem // containing a set of all entities that are about to be saved, which would make checking this much easier. // This is a shitty bandaid, and will force close the UI during auto-saves. // TODO Map serialization refactor + // I'm refactoring it now and I still dont know what to do var xform = Transform(uid); - if (xform.MapUid == ev.Map && IsSaveable(uid)) + if (ev.MapIds.Contains(xform.MapID) && IsSaveable(uid)) continue; _uiSystem.CloseUi(uid, NetworkConfiguratorUiKey.Configure); diff --git a/Content.Server/GameTicking/GameTicker.RoundFlow.cs b/Content.Server/GameTicking/GameTicker.RoundFlow.cs index 223167bc69..6d1d428296 100644 --- a/Content.Server/GameTicking/GameTicker.RoundFlow.cs +++ b/Content.Server/GameTicking/GameTicker.RoundFlow.cs @@ -13,7 +13,8 @@ using Content.Shared.Players; using Content.Shared.Preferences; using JetBrains.Annotations; using Prometheus; -using Robust.Server.Maps; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Asynchronous; using Robust.Shared.Audio; using Robust.Shared.Map; diff --git a/Content.Server/GameTicking/GameTicker.cs b/Content.Server/GameTicking/GameTicker.cs index 8220be80c7..058e2fedb0 100644 --- a/Content.Server/GameTicking/GameTicker.cs +++ b/Content.Server/GameTicking/GameTicker.cs @@ -21,6 +21,8 @@ using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; using Robust.Shared.Console; using Robust.Shared.Map; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Prototypes; using Robust.Shared.Random; using Robust.Shared.Timing; diff --git a/Content.Server/GameTicking/Rules/LoadMapRuleSystem.cs b/Content.Server/GameTicking/Rules/LoadMapRuleSystem.cs index d2686ecdcd..6304d3c248 100644 --- a/Content.Server/GameTicking/Rules/LoadMapRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/LoadMapRuleSystem.cs @@ -2,7 +2,8 @@ using Content.Server.GameTicking.Rules.Components; using Content.Server.GridPreloader; using Content.Shared.GameTicking.Components; using Robust.Server.GameObjects; -using Robust.Server.Maps; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Map; using Robust.Shared.Prototypes; diff --git a/Content.Server/GridPreloader/GridPreloaderSystem.cs b/Content.Server/GridPreloader/GridPreloaderSystem.cs index e12ce41a31..9be1ccfdc8 100644 --- a/Content.Server/GridPreloader/GridPreloaderSystem.cs +++ b/Content.Server/GridPreloader/GridPreloaderSystem.cs @@ -3,7 +3,8 @@ using Content.Shared.CCVar; using Content.Shared.GridPreloader.Prototypes; using Content.Shared.GridPreloader.Systems; using Robust.Server.GameObjects; -using Robust.Server.Maps; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Configuration; using Robust.Shared.Map; using Robust.Shared.Map.Components; diff --git a/Content.Server/Mapping/MappingCommand.cs b/Content.Server/Mapping/MappingCommand.cs index 70647d3281..2a76073630 100644 --- a/Content.Server/Mapping/MappingCommand.cs +++ b/Content.Server/Mapping/MappingCommand.cs @@ -4,7 +4,8 @@ using Content.Server.GameTicking; using Content.Shared.Administration; using Content.Shared.CCVar; using Robust.Server.GameObjects; -using Robust.Server.Maps; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Configuration; using Robust.Shared.Console; using Robust.Shared.ContentPack; diff --git a/Content.Server/Mapping/MappingSystem.cs b/Content.Server/Mapping/MappingSystem.cs index 28bb3afbe1..b7aef88268 100644 --- a/Content.Server/Mapping/MappingSystem.cs +++ b/Content.Server/Mapping/MappingSystem.cs @@ -3,7 +3,8 @@ using Content.Server.Administration; using Content.Shared.Administration; using Content.Shared.CCVar; using Robust.Server.GameObjects; -using Robust.Server.Maps; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Configuration; using Robust.Shared.Console; using Robust.Shared.ContentPack; diff --git a/Content.Server/Maps/MapMigrationSystem.cs b/Content.Server/Maps/MapMigrationSystem.cs index 62885cf819..288de35de3 100644 --- a/Content.Server/Maps/MapMigrationSystem.cs +++ b/Content.Server/Maps/MapMigrationSystem.cs @@ -2,7 +2,8 @@ using System.IO; using System.Linq; using Robust.Server.GameObjects; -using Robust.Server.Maps; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.ContentPack; using Robust.Shared.Map.Events; using Robust.Shared.Prototypes; diff --git a/Content.Server/Maps/ResaveCommand.cs b/Content.Server/Maps/ResaveCommand.cs index cc4d13dded..27065c22b1 100644 --- a/Content.Server/Maps/ResaveCommand.cs +++ b/Content.Server/Maps/ResaveCommand.cs @@ -2,7 +2,8 @@ using System.Linq; using Content.Server.Administration; using Content.Shared.Administration; using Robust.Server.GameObjects; -using Robust.Server.Maps; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Console; using Robust.Shared.ContentPack; using Robust.Shared.Map; diff --git a/Content.Server/Procedural/DungeonSystem.cs b/Content.Server/Procedural/DungeonSystem.cs index db306eff32..9bdcfbeeff 100644 --- a/Content.Server/Procedural/DungeonSystem.cs +++ b/Content.Server/Procedural/DungeonSystem.cs @@ -16,6 +16,8 @@ using Robust.Shared.Collections; using Robust.Shared.Configuration; using Robust.Shared.Console; using Robust.Shared.Map; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Map.Components; using Robust.Shared.Prototypes; using Robust.Shared.Random; diff --git a/Content.Server/Salvage/SalvageSystem.Magnet.cs b/Content.Server/Salvage/SalvageSystem.Magnet.cs index 117235c069..fbe4b17b1e 100644 --- a/Content.Server/Salvage/SalvageSystem.Magnet.cs +++ b/Content.Server/Salvage/SalvageSystem.Magnet.cs @@ -9,7 +9,8 @@ using Content.Shared.Mobs.Components; using Content.Shared.Procedural; using Content.Shared.Radio; using Content.Shared.Salvage.Magnet; -using Robust.Server.Maps; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Map; using Robust.Shared.Map.Components; diff --git a/Content.Server/Salvage/SalvageSystem.cs b/Content.Server/Salvage/SalvageSystem.cs index 7d9dcbe02f..28e5d56821 100644 --- a/Content.Server/Salvage/SalvageSystem.cs +++ b/Content.Server/Salvage/SalvageSystem.cs @@ -27,7 +27,8 @@ using Content.Shared.Construction.EntitySystems; using Content.Shared.Random; using Content.Shared.Random.Helpers; using Content.Shared.Tools.Components; -using Robust.Server.Maps; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; using Robust.Shared.Map.Components; diff --git a/Content.Server/Shipyard/ShipyardSystem.cs b/Content.Server/Shipyard/ShipyardSystem.cs index d627cfd546..7371e25e01 100644 --- a/Content.Server/Shipyard/ShipyardSystem.cs +++ b/Content.Server/Shipyard/ShipyardSystem.cs @@ -6,6 +6,8 @@ using Content.Shared.DeltaV.CCVars; using Content.Shared.Tag; using Robust.Server.GameObjects; using Robust.Shared.Configuration; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; namespace Content.Server.Shipyard; diff --git a/Content.Server/Shuttles/Systems/ArrivalsSystem.cs b/Content.Server/Shuttles/Systems/ArrivalsSystem.cs index 47613c3aca..1347f2c4c2 100644 --- a/Content.Server/Shuttles/Systems/ArrivalsSystem.cs +++ b/Content.Server/Shuttles/Systems/ArrivalsSystem.cs @@ -32,6 +32,8 @@ using Robust.Shared.Collections; using Robust.Shared.Configuration; using Robust.Shared.Console; using Robust.Shared.Map; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Random; diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs index 08dac15fe9..1c566dcd32 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs @@ -30,7 +30,8 @@ using Content.Shared.Shuttles.Events; using Content.Shared.Tag; using Content.Shared.Tiles; using Robust.Server.GameObjects; -using Robust.Server.Maps; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Audio.Systems; using Robust.Shared.Configuration; using Robust.Shared.Map; diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.cs index 71afab0954..bb4f27d7af 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.cs @@ -20,6 +20,8 @@ using Robust.Shared.Audio.Systems; using Robust.Shared.Configuration; using Robust.Shared.Map; using Robust.Shared.Map.Components; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Physics; using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Systems; diff --git a/Content.Server/StationEvents/Events/PirateRadioSpawnRule.cs b/Content.Server/StationEvents/Events/PirateRadioSpawnRule.cs index 7e5a0ac24e..dd962ffa35 100644 --- a/Content.Server/StationEvents/Events/PirateRadioSpawnRule.cs +++ b/Content.Server/StationEvents/Events/PirateRadioSpawnRule.cs @@ -1,5 +1,6 @@ using Robust.Server.GameObjects; -using Robust.Server.Maps; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Configuration; using Robust.Shared.Map; using Robust.Shared.Prototypes; diff --git a/Content.Server/_Goobstation/Ghostbar/GhostBarSystem.cs b/Content.Server/_Goobstation/Ghostbar/GhostBarSystem.cs index caf9bbb309..046a96fa08 100644 --- a/Content.Server/_Goobstation/Ghostbar/GhostBarSystem.cs +++ b/Content.Server/_Goobstation/Ghostbar/GhostBarSystem.cs @@ -6,7 +6,8 @@ using Content.Server.Players.PlayTimeTracking; // Einstein Engines using Content.Server.Station.Systems; using Robust.Shared.Map; using Robust.Shared.Prototypes; -using Robust.Server.Maps; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Random; using Content.Shared.Ghost; using Content.Server._Goobstation.Ghostbar.Components; diff --git a/Content.Server/_Goobstation/Teleportation/Systems/PocketDimensionSystem.cs b/Content.Server/_Goobstation/Teleportation/Systems/PocketDimensionSystem.cs index a3e98db21d..204e043774 100644 --- a/Content.Server/_Goobstation/Teleportation/Systems/PocketDimensionSystem.cs +++ b/Content.Server/_Goobstation/Teleportation/Systems/PocketDimensionSystem.cs @@ -8,6 +8,8 @@ using Robust.Server.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.Map; using Robust.Shared.Map.Components; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; namespace Content.Server.Teleportation; diff --git a/Content.Server/_Lavaland/Procedural/Systems/LavalandPlanetSystem.cs b/Content.Server/_Lavaland/Procedural/Systems/LavalandPlanetSystem.cs index af9642b8af..f5fba17919 100644 --- a/Content.Server/_Lavaland/Procedural/Systems/LavalandPlanetSystem.cs +++ b/Content.Server/_Lavaland/Procedural/Systems/LavalandPlanetSystem.cs @@ -17,7 +17,8 @@ using Content.Shared.Parallax.Biomes; using Content.Shared.Salvage; using Content.Shared.Shuttles.Components; using Robust.Server.GameObjects; -using Robust.Server.Maps; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Configuration; using Robust.Shared.Map; using Robust.Shared.Map.Components; diff --git a/Content.Server/_Lavaland/Salvage/ShelterCapsuleSystem.cs b/Content.Server/_Lavaland/Salvage/ShelterCapsuleSystem.cs index 2ed0f44b56..0d8f73e9c0 100644 --- a/Content.Server/_Lavaland/Salvage/ShelterCapsuleSystem.cs +++ b/Content.Server/_Lavaland/Salvage/ShelterCapsuleSystem.cs @@ -6,6 +6,8 @@ using Content.Shared._Lavaland.Shelter; using Content.Shared.Chemistry.Components; using Robust.Server.GameObjects; using Robust.Shared.Map; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Prototypes; namespace Content.Server._Lavaland.Salvage; diff --git a/Content.Server/_Lavaland/Shuttles/Systems/DockingConsoleSystem.cs b/Content.Server/_Lavaland/Shuttles/Systems/DockingConsoleSystem.cs index 5de04bbcbf..5ea208f0a6 100644 --- a/Content.Server/_Lavaland/Shuttles/Systems/DockingConsoleSystem.cs +++ b/Content.Server/_Lavaland/Shuttles/Systems/DockingConsoleSystem.cs @@ -14,8 +14,11 @@ using Content.Shared.Whitelist; using Robust.Server.GameObjects; using Robust.Shared.Map; using Robust.Shared.Map.Components; +using Robust.Shared.EntitySerialization; +using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Utility; using Timer = Robust.Shared.Timing.Timer; +using Robust.Shared.EntitySerialization.Systems; namespace Content.Server._Lavaland.Shuttles.Systems; @@ -229,4 +232,4 @@ public sealed class DockingConsoleSystem : SharedDockingConsoleSystem return null; } -} \ No newline at end of file +} diff --git a/Content.Shared/Body/Prototypes/BodyPrototypeSerializer.cs b/Content.Shared/Body/Prototypes/BodyPrototypeSerializer.cs index ae09976704..46453e0c50 100644 --- a/Content.Shared/Body/Prototypes/BodyPrototypeSerializer.cs +++ b/Content.Shared/Body/Prototypes/BodyPrototypeSerializer.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using Content.Shared.Body.Organ; using Content.Shared.Prototypes; using Robust.Shared.Prototypes; @@ -40,12 +40,6 @@ public sealed class BodyPrototypeSerializer : ITypeReader("slots"); var allConnections = new Dictionary? Connections, Dictionary? Organs)>(); - foreach (var (keyNode, valueNode) in slotNodes) + foreach (var (slotId, valueNode) in slotNodes) { - var slotId = ((ValueDataNode) keyNode).Value; - var slot = ((MappingDataNode) valueNode); + var slot = (MappingDataNode) valueNode; string? part = null; if (slot.TryGet("part", out var value)) @@ -155,9 +142,9 @@ public sealed class BodyPrototypeSerializer : ITypeReader(); - foreach (var (organKeyNode, organValueNode) in slotOrgansNode) + foreach (var (organKey, organValueNode) in slotOrgansNode) { - organs.Add(((ValueDataNode) organKeyNode).Value, ((ValueDataNode) organValueNode).Value); + organs.Add(organKey, ((ValueDataNode) organValueNode).Value); } } diff --git a/Content.Shared/Containers/ContainerFillComponent.cs b/Content.Shared/Containers/ContainerFillComponent.cs index 7ce5fa8850..aa8c98fd1f 100644 --- a/Content.Shared/Containers/ContainerFillComponent.cs +++ b/Content.Shared/Containers/ContainerFillComponent.cs @@ -49,13 +49,11 @@ public sealed class ContainerFillSerializer : ITypeValidator(key, context); - var listVal = (val is SequenceDataNode seq) ? ListSerializer.Validate(serializationManager, seq, dependencies, context) : new ErrorNode(val, "ContainerFillComponent prototypes must be a sequence/list"); - mapping.Add(keyVal, listVal); + mapping.Add(new ValidatedValueNode(node.GetKeyNode(key)), listVal); } return new ValidatedMappingNode(mapping); diff --git a/Content.Shared/Decals/DecalGridChunkCollectionTypeSerializer.cs b/Content.Shared/Decals/DecalGridChunkCollectionTypeSerializer.cs index ba89c8a695..f22b3ea1cd 100644 --- a/Content.Shared/Decals/DecalGridChunkCollectionTypeSerializer.cs +++ b/Content.Shared/Decals/DecalGridChunkCollectionTypeSerializer.cs @@ -29,7 +29,7 @@ namespace Content.Shared.Decals IDependencyCollection dependencies, SerializationHookContext hookCtx, ISerializationContext? context = null, ISerializationManager.InstantiationDelegate? _ = default) { - node.TryGetValue(new ValueDataNode("version"), out var versionNode); + node.TryGetValue("version", out var versionNode); var version = ((ValueDataNode?) versionNode)?.AsInt() ?? 1; Dictionary dictionary; @@ -47,7 +47,7 @@ namespace Content.Shared.Decals foreach (var (decalUidNode, decalData) in deckNodes) { - var dUid = serializationManager.Read(decalUidNode, hookCtx, context); + var dUid = uint.Parse(decalUidNode, CultureInfo.InvariantCulture); var coords = serializationManager.Read(decalData, hookCtx, context); var chunkOrigin = SharedMapSystem.GetChunkIndices(coords, SharedDecalSystem.ChunkSize); @@ -149,7 +149,7 @@ namespace Content.Shared.Decals { var decal = decalLookup[uid]; // Inline coordinates - decks.Add(serializationManager.WriteValue(uid, alwaysWrite, context), serializationManager.WriteValue(decal.Coordinates, alwaysWrite, context)); + decks.Add(uid.ToString(), serializationManager.WriteValue(decal.Coordinates, alwaysWrite, context)); } lookupNode.Add("decals", decks); diff --git a/Content.Shared/Eye/VisibilityFlags.cs b/Content.Shared/Eye/VisibilityFlags.cs index 892de27abd..d483e39c6e 100644 --- a/Content.Shared/Eye/VisibilityFlags.cs +++ b/Content.Shared/Eye/VisibilityFlags.cs @@ -9,10 +9,11 @@ namespace Content.Shared.Eye None = 0, Normal = 1 << 0, Ghost = 1 << 1, - PsionicInvisibility = 1 << 2, //Nyano - Summary: adds Psionic Invisibility as a visibility layer. Currently does nothing. + Subfloor = 1 << 2, + PsionicInvisibility = 1 << 3, //Nyano - Summary: adds Psionic Invisibility as a visibility layer. Currently does nothing. Ethereal = 1 << 3, TelegnosticProjection = 5, AGhost = 1 << 5, // WD EDIT - Abductor = 1 << 10, // I HATE BITWISE OPERATIONS!! GRAAAAH + Abductor = 1 << 10, // I HATE BITWISE OPERATIONS!! GRAAAAH } } diff --git a/Content.Shared/SubFloor/SharedSubFloorHideSystem.cs b/Content.Shared/SubFloor/SharedSubFloorHideSystem.cs index cebc84ecb9..812003aae8 100644 --- a/Content.Shared/SubFloor/SharedSubFloorHideSystem.cs +++ b/Content.Shared/SubFloor/SharedSubFloorHideSystem.cs @@ -1,7 +1,10 @@ using Content.Shared.Audio; +using Content.Shared.Construction.Components; using Content.Shared.Explosion; +using Content.Shared.Eye; using Content.Shared.Interaction.Events; using Content.Shared.Maps; +using Content.Shared.Popups; using JetBrains.Annotations; using Robust.Shared.Map; using Robust.Shared.Map.Components; @@ -17,12 +20,19 @@ namespace Content.Shared.SubFloor { [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!; [Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!; + [Dependency] protected readonly SharedMapSystem Map = default!; [Dependency] protected readonly SharedAppearanceSystem Appearance = default!; + [Dependency] private readonly SharedVisibilitySystem _visibility = default!; + [Dependency] protected readonly SharedPopupSystem _popup = default!; + + private EntityQuery _hideQuery; public override void Initialize() { base.Initialize(); + _hideQuery = GetEntityQuery(); + SubscribeLocalEvent(OnTileChanged); SubscribeLocalEvent(OnSubFloorStarted); SubscribeLocalEvent(OnSubFloorTerminating); @@ -31,6 +41,32 @@ namespace Content.Shared.SubFloor SubscribeLocalEvent(OnInteractionAttempt); SubscribeLocalEvent(OnAttackAttempt); SubscribeLocalEvent(OnGetExplosionResistance); + SubscribeLocalEvent(OnAnchorAttempt); + SubscribeLocalEvent(OnUnanchorAttempt); + } + + private void OnAnchorAttempt(EntityUid uid, SubFloorHideComponent component, AnchorAttemptEvent args) + { + // No teleporting entities through floor tiles when anchoring them. + var xform = Transform(uid); + + if (TryComp(xform.GridUid, out var grid) + && HasFloorCover(xform.GridUid.Value, grid, Map.TileIndicesFor(xform.GridUid.Value, grid, xform.Coordinates))) + { + _popup.PopupClient(Loc.GetString("subfloor-anchor-failure", ("entity", uid)), args.User); + args.Cancel(); + } + } + + private void OnUnanchorAttempt(EntityUid uid, SubFloorHideComponent component, UnanchorAttemptEvent args) + { + // No un-anchoring things under the floor. Only required for something like vents, which are still interactable + // despite being partially under the floor. + if (component.IsUnderCover) + { + _popup.PopupClient(Loc.GetString("subfloor-unanchor-failure", ("entity", uid)), args.User); + args.Cancel(); + } } private void OnGetExplosionResistance(EntityUid uid, SubFloorHideComponent component, ref GetExplosionResistanceEvent args) @@ -66,7 +102,7 @@ namespace Content.Shared.SubFloor return; // Regardless of whether we're on a subfloor or not, unhide. - component.IsUnderCover = false; + SetUnderCover((uid, component), false); UpdateAppearance(uid, component); } @@ -79,20 +115,23 @@ namespace Content.Shared.SubFloor } else if (component.IsUnderCover) { - component.IsUnderCover = false; + SetUnderCover((uid, component), false); UpdateAppearance(uid, component); } } private void OnTileChanged(ref TileChangedEvent args) { - if (args.OldTile.IsEmpty) - return; // Nothing is anchored here anyways. + foreach (var change in args.Changes) + { + if (change.OldTile.IsEmpty) + continue; // Nothing is anchored here anyways. - if (args.NewTile.Tile.IsEmpty) - return; // Anything that was here will be unanchored anyways. + if (change.NewTile.IsEmpty) + continue; // Anything that was here will be unanchored anyways. - UpdateTile(Comp(args.NewTile.GridUid), args.NewTile.GridIndices); + UpdateTile(args.Entity, args.Entity.Comp, change.GridIndices); + } } /// @@ -104,33 +143,44 @@ namespace Content.Shared.SubFloor return; if (xform.Anchored && TryComp(xform.GridUid, out var grid)) - component.IsUnderCover = HasFloorCover(grid, grid.TileIndicesFor(xform.Coordinates)); + SetUnderCover((uid, component), HasFloorCover(xform.GridUid.Value, grid, Map.TileIndicesFor(xform.GridUid.Value, grid, xform.Coordinates))); else - component.IsUnderCover = false; + SetUnderCover((uid, component), false); UpdateAppearance(uid, component); } - public bool HasFloorCover(MapGridComponent grid, Vector2i position) + private void SetUnderCover(Entity entity, bool value) + { + // If it's not undercover or it always has visible layers then normal visibility. + _visibility.SetLayer(entity.Owner, value && entity.Comp.VisibleLayers.Count == 0 ? (ushort) VisibilityFlags.Subfloor : (ushort) VisibilityFlags.Normal); + + if (entity.Comp.IsUnderCover == value) + return; + + entity.Comp.IsUnderCover = value; + } + + public bool HasFloorCover(EntityUid gridUid, MapGridComponent grid, Vector2i position) { // TODO Redo this function. Currently wires on an asteroid are always "below the floor" - var tileDef = (ContentTileDefinition) _tileDefinitionManager[grid.GetTileRef(position).Tile.TypeId]; + var tileDef = (ContentTileDefinition) _tileDefinitionManager[Map.GetTileRef(gridUid, grid, position).Tile.TypeId]; return !tileDef.IsSubFloor; } - private void UpdateTile(MapGridComponent grid, Vector2i position) + private void UpdateTile(EntityUid gridUid, MapGridComponent grid, Vector2i position) { - var covered = HasFloorCover(grid, position); + var covered = HasFloorCover(gridUid, grid, position); - foreach (var uid in grid.GetAnchoredEntities(position)) + foreach (var uid in Map.GetAnchoredEntities(gridUid, grid, position)) { - if (!TryComp(uid, out SubFloorHideComponent? hideComp)) + if (!_hideQuery.TryComp(uid, out var hideComp)) continue; if (hideComp.IsUnderCover == covered) continue; - hideComp.IsUnderCover = covered; + SetUnderCover((uid, hideComp), covered); UpdateAppearance(uid, hideComp); } } @@ -153,6 +203,12 @@ namespace Content.Shared.SubFloor Appearance.SetData(uid, SubFloorVisuals.Covered, hideComp.IsUnderCover, appearance); } } + + [Serializable, NetSerializable] + protected sealed class ShowSubfloorRequestEvent : EntityEventArgs + { + public bool Value; + } } [Serializable, NetSerializable]