From a44fa86b68def85a31a9aff17d89977c7d5c9385 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Thu, 28 Sep 2023 16:20:29 -0700 Subject: [PATCH] Update trivial components to use auto comp states (#20539) --- .../UI/AccessOverriderBoundUserInterface.cs | 6 +- .../Access/UI/AccessOverriderWindow.xaml.cs | 4 +- .../UI/IdCardConsoleBoundUserInterface.cs | 6 +- .../Access/UI/IdCardConsoleWindow.xaml.cs | 2 +- Content.Client/Alerts/ClientAlertsSystem.cs | 14 +-- Content.Client/BarSign/BarSignSystem.cs | 23 ++-- Content.Client/Buckle/BuckleSystem.cs | 23 ++-- .../Systems/ChameleonClothingSystem.cs | 9 +- Content.Client/Cuffs/CuffableSystem.cs | 9 -- .../Humanoid/HumanoidAppearanceSystem.cs | 112 +++++++----------- ...manoidMarkingModifierBoundUserInterface.cs | 2 - .../HumanoidMarkingModifierWindow.xaml.cs | 3 +- Content.Client/Implants/ImplanterSystem.cs | 10 +- Content.Client/Lathe/UI/LatheMenu.xaml.cs | 5 +- .../Movement/Systems/ClimbSystem.cs | 11 -- Content.Client/Points/PointSystem.cs | 10 +- .../Radiation/Systems/GeigerSystem.cs | 15 +-- Content.Client/Tabletop/TabletopSystem.cs | 9 -- .../Ranged/Systems/GunSystem.Ballistic.cs | 2 +- .../Access/Systems/AccessOverriderSystem.cs | 8 +- .../BarSign/Systems/BarSignSystem.cs | 11 +- Content.Server/Climbing/ClimbSystem.cs | 7 -- .../Systems/ChameleonClothingSystem.cs | 18 +-- Content.Server/Cuffs/CuffableSystem.cs | 10 +- Content.Server/Doors/Systems/DoorSystem.cs | 15 +-- .../Electrocution/ElectrocutionSystem.cs | 2 +- Content.Server/Implants/ImplanterSystem.cs | 7 -- Content.Server/Lathe/LatheSystem.cs | 14 +-- Content.Server/Points/PointSystem.cs | 7 -- .../Radiation/Systems/GeigerSystem.cs | 14 --- .../Melee/EnergySword/EnergySwordSystem.cs | 4 +- .../Weapons/Melee/MeleeWeaponSystem.cs | 8 +- .../Ranged/Systems/GunSystem.Ballistic.cs | 2 +- .../Weapons/Ranged/Systems/GunSystem.cs | 6 +- .../Zombies/ZombieSystem.Transform.cs | 3 +- Content.Server/Zombies/ZombieSystem.cs | 2 +- .../Components/AccessOverriderComponent.cs | 16 +-- .../Components/IdCardConsoleComponent.cs | 12 +- .../Systems/SharedAccessOverriderSystem.cs | 25 ---- .../Systems/SharedIdCardConsoleSystem.cs | 26 ---- Content.Shared/Alert/AlertsComponent.cs | 7 +- Content.Shared/Alert/AlertsComponentState.cs | 14 --- Content.Shared/Alert/AlertsSystem.cs | 7 -- .../Anomaly/Components/AnomalyComponent.cs | 56 ++++----- .../AnomalySupercriticalComponent.cs | 17 +-- Content.Shared/Anomaly/SharedAnomalySystem.cs | 42 ------- Content.Shared/BarSign/BarSignComponent.cs | 26 +--- .../Body/Components/BodyComponent.cs | 33 ++---- .../Body/Systems/SharedBodySystem.Body.cs | 26 ---- .../Buckle/Components/BuckleComponent.cs | 38 ++---- .../Buckle/Components/StrapComponent.cs | 52 +++----- .../Buckle/SharedBuckleSystem.Buckle.cs | 10 +- .../Buckle/SharedBuckleSystem.Strap.cs | 22 ---- Content.Shared/Buckle/SharedBuckleSystem.cs | 2 +- .../Cabinet/ItemCabinetComponent.cs | 34 +----- .../Cabinet/SharedItemCabinetSystem.cs | 22 ---- .../CartridgeLoader/CartridgeComponent.cs | 14 +-- .../SharedCartridgeLoaderSystem.cs | 22 ---- .../MovespeedModifierMetabolismComponent.cs | 25 +--- .../MetabolismMovespeedModifierSystem.cs | 25 +--- Content.Shared/Climbing/ClimbingComponent.cs | 20 +--- .../Components/ChameleonClothingComponent.cs | 15 +-- .../SharedChameleonClothingSystem.cs | 4 +- Content.Shared/Conveyor/ConveyorComponent.cs | 41 ++----- .../Cuffs/Components/HandcuffComponent.cs | 52 +++----- .../Damage/Components/StaminaComponent.cs | 18 +-- .../Damage/Systems/StaminaSystem.cs | 44 +------ .../Components/DeviceListComponent.cs | 29 +---- .../NetworkConfiguratorComponent.cs | 41 ++----- .../Systems/SharedDeviceListSystem.cs | 24 ---- .../SharedNetworkConfiguratorSystem.cs | 27 ----- .../Doors/Components/AirlockComponent.cs | 51 ++++---- .../Doors/Components/DoorComponent.cs | 92 ++++++-------- .../Doors/Systems/SharedAirlockSystem.cs | 18 --- .../Doors/Systems/SharedDoorSystem.cs | 25 +--- .../Electrocution/InsulatedComponent.cs | 22 +--- .../SharedElectrocutionSystem.cs | 21 +--- Content.Shared/Emoting/EmoteSystem.cs | 68 +++-------- Content.Shared/Emoting/EmotingComponent.cs | 15 ++- .../Follower/Components/FollowedComponent.cs | 6 +- Content.Shared/Follower/FollowerSystem.cs | 29 +---- .../Gravity/FloatingVisualsComponent.cs | 25 +--- .../Gravity/GravityShakeComponent.cs | 6 +- .../Gravity/SharedFloatingVisualizerSystem.cs | 18 --- .../Gravity/SharedGravitySystem.Shake.cs | 30 ----- .../Humanoid/HumanoidAppearanceComponent.cs | 109 ++++++----------- .../Prototypes/HumanoidProfilePrototype.cs | 1 - .../SharedHumanoidAppearanceSystem.cs | 22 +--- .../SharedHumanoidMarkingModifierSystem.cs | 1 - .../Implants/Components/ImplanterComponent.cs | 43 ++----- .../Components/InteractionRelayComponent.cs | 19 +-- .../SharedInteractionSystem.Relay.cs | 22 +--- .../Interaction/SharedInteractionSystem.cs | 4 - .../Jittering/JitteringComponent.cs | 39 ++---- .../Jittering/SharedJitteringSystem.cs | 17 --- Content.Shared/Lathe/LatheComponent.cs | 40 +++---- Content.Shared/Lathe/LatheMessages.cs | 5 +- Content.Shared/Lathe/SharedLatheSystem.cs | 28 ----- .../InsertingMaterialStorageComponent.cs | 21 +--- .../Materials/MaterialReclaimerComponent.cs | 61 ++++------ .../Materials/MaterialStorageComponent.cs | 46 +++---- .../SharedMaterialReclaimerSystem.cs | 21 ---- .../Materials/SharedMaterialStorageSystem.cs | 37 +----- .../Mech/Components/MechComponent.cs | 67 ++++------- .../Mech/Components/MechPilotComponent.cs | 11 +- .../Mech/EntitySystems/SharedMechSystem.cs | 52 -------- .../Components/FootstepModifierComponent.cs | 19 ++- .../Components/InputMoverComponent.cs | 15 ++- .../Components/JetpackUserComponent.cs | 3 +- .../Movement/Components/MobMoverComponent.cs | 11 +- .../MovementSpeedModifierComponent.cs | 29 ++--- .../Systems/MovementSpeedModifierSystem.cs | 39 ------ .../Movement/Systems/SharedJetpackSystem.cs | 25 ---- .../SharedMoverController.Footsteps.cs | 35 ------ .../Systems/SharedMoverController.Input.cs | 57 +-------- .../Systems/SharedMoverController.Mob.cs | 39 ------ .../Movement/Systems/SharedMoverController.cs | 22 ++-- .../Controllers/SharedConveyorController.cs | 19 --- .../Physics/PreventCollideComponent.cs | 14 +-- .../Physics/SharedPreventCollideSystem.cs | 19 +-- .../Placeable/ItemPlacerComponent.cs | 9 +- Content.Shared/Placeable/ItemPlacerSystem.cs | 32 ----- .../Placeable/PlaceableSurfaceComponent.cs | 39 ++---- .../Placeable/PlaceableSurfaceSystem.cs | 26 +--- .../Points/PointManagerComponent.cs | 22 +--- .../Radiation/Components/GeigerComponent.cs | 27 ++--- .../Shuttles/Components/IFFComponent.cs | 7 +- .../Components/RadarConsoleComponent.cs | 5 +- .../Systems/SharedRadarConsoleSystem.cs | 31 ----- .../Systems/SharedShuttleSystem.IFF.cs | 33 ------ .../Shuttles/Systems/SharedShuttleSystem.cs | 5 - Content.Shared/Slippery/SlipperyComponent.cs | 25 +--- Content.Shared/Slippery/SlipperySystem.cs | 18 --- Content.Shared/Speech/SpeechComponent.cs | 27 ++--- Content.Shared/Speech/SpeechSystem.cs | 29 ----- .../Standing/StandingStateComponent.cs | 8 +- .../Standing/StandingStateSystem.cs | 36 ------ .../Components/StepTriggerComponent.cs | 46 ++----- .../StepTrigger/Systems/StepTriggerSystem.cs | 38 +----- .../Storage/Components/BinComponent.cs | 32 ++--- .../Storage/EntitySystems/BinSystem.cs | 18 --- .../Components/TabletopDraggableComponent.cs | 5 +- .../Tabletop/SharedTabletopSystem.cs | 7 -- .../Components/LinkedEntityComponent.cs | 20 +--- .../Components/PortalTimeoutComponent.cs | 18 +-- .../Systems/LinkedEntitySystem.cs | 19 +-- .../Systems/SharedPortalSystem.cs | 16 --- Content.Shared/Timing/UseDelayComponent.cs | 59 ++++----- Content.Shared/Timing/UseDelaySystem.cs | 19 +-- .../Tools/Components/MultipleToolComponent.cs | 68 +++++------ .../Systems/SharedToolSystem.MultipleTool.cs | 17 +-- Content.Shared/Vehicle/SharedVehicleSystem.cs | 12 +- .../Weapons/Melee/MeleeWeaponComponent.cs | 62 +++------- .../Weapons/Melee/SharedMeleeWeaponSystem.cs | 26 +--- .../BallisticAmmoProviderComponent.cs | 27 ++--- .../Systems/SharedGunSystem.Ballistic.cs | 36 +----- Content.Shared/Zombies/ZombieComponent.cs | 3 +- .../Alert/ServerAlertsComponentTests.cs | 6 +- 158 files changed, 806 insertions(+), 2866 deletions(-) delete mode 100644 Content.Shared/Alert/AlertsComponentState.cs delete mode 100644 Content.Shared/Movement/Systems/SharedMoverController.Footsteps.cs delete mode 100644 Content.Shared/Movement/Systems/SharedMoverController.Mob.cs diff --git a/Content.Client/Access/UI/AccessOverriderBoundUserInterface.cs b/Content.Client/Access/UI/AccessOverriderBoundUserInterface.cs index cb43185484..0c23542f79 100644 --- a/Content.Client/Access/UI/AccessOverriderBoundUserInterface.cs +++ b/Content.Client/Access/UI/AccessOverriderBoundUserInterface.cs @@ -1,7 +1,7 @@ +using Content.Shared.Access; using Content.Shared.Access.Components; using Content.Shared.Access.Systems; using Content.Shared.Containers.ItemSlots; -using Robust.Client.GameObjects; using Robust.Shared.Prototypes; using static Content.Shared.Access.Components.AccessOverriderComponent; @@ -23,7 +23,7 @@ namespace Content.Client.Access.UI { base.Open(); - List accessLevels; + List> accessLevels; if (EntMan.TryGetComponent(Owner, out var accessOverrider)) { @@ -33,7 +33,7 @@ namespace Content.Client.Access.UI else { - accessLevels = new List(); + accessLevels = new List>(); _accessOverriderSystem.Log.Error($"No AccessOverrider component found for {EntMan.ToPrettyString(Owner)}!"); } diff --git a/Content.Client/Access/UI/AccessOverriderWindow.xaml.cs b/Content.Client/Access/UI/AccessOverriderWindow.xaml.cs index 6a4dcba307..2fd0057121 100644 --- a/Content.Client/Access/UI/AccessOverriderWindow.xaml.cs +++ b/Content.Client/Access/UI/AccessOverriderWindow.xaml.cs @@ -21,7 +21,7 @@ namespace Content.Client.Access.UI private readonly Dictionary _accessButtons = new(); public AccessOverriderWindow(AccessOverriderBoundUserInterface owner, IPrototypeManager prototypeManager, - List accessLevels) + List> accessLevels) { RobustXamlLoader.Load(this); IoCManager.InjectDependencies(this); @@ -31,7 +31,7 @@ namespace Content.Client.Access.UI foreach (var access in accessLevels) { - if (!prototypeManager.TryIndex(access, out var accessLevel)) + if (!prototypeManager.TryIndex(access, out var accessLevel)) { _logMill.Error($"Unable to find accesslevel for {access}"); continue; diff --git a/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs b/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs index be45e57c8b..898792aa03 100644 --- a/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs +++ b/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs @@ -1,8 +1,8 @@ +using Content.Shared.Access; using Content.Shared.Access.Components; using Content.Shared.Access.Systems; using Content.Shared.Containers.ItemSlots; using Content.Shared.CrewManifest; -using Robust.Client.GameObjects; using Robust.Shared.Prototypes; using static Content.Shared.Access.Components.IdCardConsoleComponent; @@ -23,7 +23,7 @@ namespace Content.Client.Access.UI protected override void Open() { base.Open(); - List accessLevels; + List> accessLevels; if (EntMan.TryGetComponent(Owner, out var idCard)) { @@ -32,7 +32,7 @@ namespace Content.Client.Access.UI } else { - accessLevels = new List(); + accessLevels = new List>(); _idCardConsoleSystem.Log.Error($"No IdCardConsole component found for {EntMan.ToPrettyString(Owner)}!"); } diff --git a/Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs b/Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs index f8450fe578..670ba08871 100644 --- a/Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs +++ b/Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs @@ -28,7 +28,7 @@ namespace Content.Client.Access.UI private string? _lastJobProto; public IdCardConsoleWindow(IdCardConsoleBoundUserInterface owner, IPrototypeManager prototypeManager, - List accessLevels) + List> accessLevels) { RobustXamlLoader.Load(this); IoCManager.InjectDependencies(this); diff --git a/Content.Client/Alerts/ClientAlertsSystem.cs b/Content.Client/Alerts/ClientAlertsSystem.cs index 17f6edb95f..cfdae7bc93 100644 --- a/Content.Client/Alerts/ClientAlertsSystem.cs +++ b/Content.Client/Alerts/ClientAlertsSystem.cs @@ -1,10 +1,8 @@ using System.Linq; using Content.Shared.Alert; -using Content.Shared.Mobs.Systems; using JetBrains.Annotations; using Robust.Client.GameObjects; using Robust.Client.Player; -using Robust.Shared.GameStates; using Robust.Shared.Prototypes; namespace Content.Client.Alerts; @@ -27,7 +25,7 @@ public sealed class ClientAlertsSystem : AlertsSystem SubscribeLocalEvent(OnPlayerAttached); SubscribeLocalEvent(OnPlayerDetached); - SubscribeLocalEvent(ClientAlertsHandleState); + SubscribeLocalEvent(ClientAlertsHandleState); } protected override void LoadPrototypes() { @@ -65,16 +63,10 @@ public sealed class ClientAlertsSystem : AlertsSystem SyncAlerts?.Invoke(this, alertsComponent.Alerts); } - private void ClientAlertsHandleState(EntityUid uid, AlertsComponent component, ref ComponentHandleState args) + private void ClientAlertsHandleState(EntityUid uid, AlertsComponent component, ref AfterAutoHandleStateEvent args) { - var componentAlerts = (args.Current as AlertsComponentState)?.Alerts; - if (componentAlerts == null) - return; - - component.Alerts = new Dictionary(componentAlerts); - if (_playerManager.LocalPlayer?.ControlledEntity == uid) - SyncAlerts?.Invoke(this, componentAlerts); + SyncAlerts?.Invoke(this, component.Alerts); } private void OnPlayerAttached(EntityUid uid, AlertsComponent component, PlayerAttachedEvent args) diff --git a/Content.Client/BarSign/BarSignSystem.cs b/Content.Client/BarSign/BarSignSystem.cs index 7a28948811..05db00d819 100644 --- a/Content.Client/BarSign/BarSignSystem.cs +++ b/Content.Client/BarSign/BarSignSystem.cs @@ -1,7 +1,6 @@ using Content.Shared.BarSign; using Content.Shared.Power; using Robust.Client.GameObjects; -using Robust.Shared.GameStates; using Robust.Shared.Prototypes; namespace Content.Client.BarSign; @@ -13,33 +12,29 @@ public sealed class BarSignSystem : VisualizerSystem public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnHandleState); + SubscribeLocalEvent(OnAfterAutoHandleState); } - private void OnHandleState(EntityUid uid, BarSignComponent component, ref ComponentHandleState args) + private void OnAfterAutoHandleState(EntityUid uid, BarSignComponent component, ref AfterAutoHandleStateEvent args) { - if (args.Current is not BarSignComponentState state) - return; - - component.CurrentSign = state.CurrentSign; - UpdateAppearance(component); + UpdateAppearance(uid, component); } protected override void OnAppearanceChange(EntityUid uid, BarSignComponent component, ref AppearanceChangeEvent args) { - UpdateAppearance(component, args.Component, args.Sprite); + UpdateAppearance(uid, component, args.Component, args.Sprite); } - private void UpdateAppearance(BarSignComponent sign, AppearanceComponent? appearance = null, SpriteComponent? sprite = null) + private void UpdateAppearance(EntityUid id, BarSignComponent sign, AppearanceComponent? appearance = null, SpriteComponent? sprite = null) { - if (!Resolve(sign.Owner, ref appearance, ref sprite)) + if (!Resolve(id, ref appearance, ref sprite)) return; - AppearanceSystem.TryGetData(sign.Owner, PowerDeviceVisuals.Powered, out var powered, appearance); + AppearanceSystem.TryGetData(id, PowerDeviceVisuals.Powered, out var powered, appearance); if (powered - && sign.CurrentSign != null - && _prototypeManager.TryIndex(sign.CurrentSign, out BarSignPrototype? proto)) + && sign.Current != null + && _prototypeManager.TryIndex(sign.Current, out BarSignPrototype? proto)) { sprite.LayerSetState(0, proto.Icon); sprite.LayerSetShader(0, "unshaded"); diff --git a/Content.Client/Buckle/BuckleSystem.cs b/Content.Client/Buckle/BuckleSystem.cs index f09bb1f08a..db5fa2bd99 100644 --- a/Content.Client/Buckle/BuckleSystem.cs +++ b/Content.Client/Buckle/BuckleSystem.cs @@ -3,7 +3,6 @@ using Content.Shared.Buckle; using Content.Shared.Buckle.Components; using Content.Shared.Vehicle.Components; using Robust.Client.GameObjects; -using Robust.Shared.GameStates; namespace Content.Client.Buckle; @@ -15,20 +14,12 @@ internal sealed class BuckleSystem : SharedBuckleSystem { base.Initialize(); - SubscribeLocalEvent(OnBuckleHandleState); + SubscribeLocalEvent(OnBuckleAfterAutoHandleState); SubscribeLocalEvent(OnAppearanceChange); } - private void OnBuckleHandleState(EntityUid uid, BuckleComponent component, ref ComponentHandleState args) + private void OnBuckleAfterAutoHandleState(EntityUid uid, BuckleComponent component, ref AfterAutoHandleStateEvent args) { - if (args.Current is not BuckleComponentState state) - return; - - component.Buckled = state.Buckled; - component.BuckledTo = EnsureEntity(state.BuckledTo, uid); - component.LastEntityBuckledTo = EnsureEntity(state.LastEntityBuckledTo, uid); - component.DontCollide = state.DontCollide; - ActionBlocker.UpdateCanMove(uid); if (!TryComp(uid, out var ownerSprite)) @@ -38,11 +29,11 @@ internal sealed class BuckleSystem : SharedBuckleSystem return; // Adjust draw depth when the chair faces north so that the seat back is drawn over the player. - // Reset the draw depth when rotated in any other direction. - // TODO when ECSing, make this a visualizer - // This code was written before rotatable viewports were introduced, so hard-coding Direction.North - // and comparing it against LocalRotation now breaks this in other rotations. This is a FIXME, but - // better to get it working for most people before we look at a more permanent solution. + // Reset the draw depth when rotated in any other direction. + // TODO when ECSing, make this a visualizer + // This code was written before rotatable viewports were introduced, so hard-coding Direction.North + // and comparing it against LocalRotation now breaks this in other rotations. This is a FIXME, but + // better to get it working for most people before we look at a more permanent solution. if (component is { Buckled: true, LastEntityBuckledTo: { } } && Transform(component.LastEntityBuckledTo.Value).LocalRotation.GetCardinalDir() == Direction.North && TryComp(component.LastEntityBuckledTo, out var buckledSprite)) diff --git a/Content.Client/Clothing/Systems/ChameleonClothingSystem.cs b/Content.Client/Clothing/Systems/ChameleonClothingSystem.cs index a0142614c7..f067d91051 100644 --- a/Content.Client/Clothing/Systems/ChameleonClothingSystem.cs +++ b/Content.Client/Clothing/Systems/ChameleonClothingSystem.cs @@ -3,7 +3,6 @@ using Content.Shared.Clothing.Components; using Content.Shared.Clothing.EntitySystems; using Content.Shared.Inventory; using Robust.Client.GameObjects; -using Robust.Shared.GameStates; using Robust.Shared.Prototypes; namespace Content.Client.Clothing.Systems; @@ -27,7 +26,7 @@ public sealed class ChameleonClothingSystem : SharedChameleonClothingSystem public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(HandleState); + SubscribeLocalEvent(HandleState); PrepareAllVariants(); _proto.PrototypesReloaded += OnProtoReloaded; @@ -44,12 +43,8 @@ public sealed class ChameleonClothingSystem : SharedChameleonClothingSystem PrepareAllVariants(); } - private void HandleState(EntityUid uid, ChameleonClothingComponent component, ref ComponentHandleState args) + private void HandleState(EntityUid uid, ChameleonClothingComponent component, ref AfterAutoHandleStateEvent args) { - if (args.Current is not ChameleonClothingComponentState state) - return; - component.SelectedId = state.SelectedId; - UpdateVisuals(uid, component); } diff --git a/Content.Client/Cuffs/CuffableSystem.cs b/Content.Client/Cuffs/CuffableSystem.cs index e69d292221..aa5ff81f8a 100644 --- a/Content.Client/Cuffs/CuffableSystem.cs +++ b/Content.Client/Cuffs/CuffableSystem.cs @@ -17,15 +17,6 @@ public sealed class CuffableSystem : SharedCuffableSystem SubscribeLocalEvent(OnCuffableShutdown); SubscribeLocalEvent(OnCuffableHandleState); - SubscribeLocalEvent(OnHandcuffHandleState); - } - - private void OnHandcuffHandleState(EntityUid uid, HandcuffComponent component, ref ComponentHandleState args) - { - if (args.Current is not HandcuffComponentState state) - return; - - component.OverlayIconState = state.IconState; } private void OnCuffableShutdown(EntityUid uid, CuffableComponent component, ComponentShutdown args) diff --git a/Content.Client/Humanoid/HumanoidAppearanceSystem.cs b/Content.Client/Humanoid/HumanoidAppearanceSystem.cs index 0b37844c6e..5bae35da5b 100644 --- a/Content.Client/Humanoid/HumanoidAppearanceSystem.cs +++ b/Content.Client/Humanoid/HumanoidAppearanceSystem.cs @@ -1,14 +1,10 @@ -using System.Linq; -using Content.Shared.Ghost; using Content.Shared.Humanoid; using Content.Shared.Humanoid.Markings; using Content.Shared.Humanoid.Prototypes; using Content.Shared.Preferences; using Robust.Client.GameObjects; -using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Utility; -using static Content.Shared.Humanoid.HumanoidAppearanceState; namespace Content.Client.Humanoid; @@ -21,34 +17,20 @@ public sealed class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem { base.Initialize(); - SubscribeLocalEvent(OnHandleState); + SubscribeLocalEvent(OnHandleState); } - private void OnHandleState(EntityUid uid, HumanoidAppearanceComponent component, ref ComponentHandleState args) + private void OnHandleState(EntityUid uid, HumanoidAppearanceComponent component, ref AfterAutoHandleStateEvent args) { - if (args.Current is not HumanoidAppearanceState state) - return; - - ApplyState(uid, component, Comp(uid), state); + UpdateSprite(component, Comp(uid)); } - private void ApplyState(EntityUid uid, HumanoidAppearanceComponent component, SpriteComponent sprite, HumanoidAppearanceState state) + private void UpdateSprite(HumanoidAppearanceComponent component, SpriteComponent sprite) { - component.Sex = state.Sex; - component.Species = state.Species; - component.Age = state.Age; - component.SkinColor = state.SkinColor; - component.EyeColor = state.EyeColor; - component.HiddenLayers = new(state.HiddenLayers); - component.PermanentlyHidden = new(state.PermanentlyHidden); - - component.CustomBaseLayers = state.CustomBaseLayers.ShallowClone(); - UpdateLayers(component, sprite); + ApplyMarkingSet(component, sprite); - ApplyMarkingSet(uid, state.Markings, component, sprite); - - sprite[sprite.LayerMapReserveBlank(HumanoidVisualLayers.Eyes)].Color = state.EyeColor; + sprite[sprite.LayerMapReserveBlank(HumanoidVisualLayers.Eyes)].Color = component.EyeColor; } private static bool IsHidden(HumanoidAppearanceComponent humanoid, HumanoidVisualLayers layer) @@ -60,7 +42,7 @@ public sealed class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem component.BaseLayers.Clear(); // add default species layers - var speciesProto = _prototypeManager.Index(component.Species); + var speciesProto = _prototypeManager.Index(component.Species); var baseSprites = _prototypeManager.Index(speciesProto.SpriteSet); foreach (var (key, id) in baseSprites.Sprites) { @@ -73,7 +55,7 @@ public sealed class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem foreach (var (key, info) in component.CustomBaseLayers) { oldLayers.Remove(key); - SetLayerData(component, sprite, key, info.ID, sexMorph: false, color: info.Color); ; + SetLayerData(component, sprite, key, info.Id, sexMorph: false, color: info.Color); } // hide old layers @@ -161,12 +143,14 @@ public sealed class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem // We need to ensure hair before applying it or coloring can try depend on markings that can be invalid var hairColor = _markingManager.MustMatchSkin(profile.Species, HumanoidVisualLayers.Hair, out var hairAlpha, _prototypeManager) - ? profile.Appearance.SkinColor.WithAlpha(hairAlpha) : profile.Appearance.HairColor; + ? profile.Appearance.SkinColor.WithAlpha(hairAlpha) + : profile.Appearance.HairColor; var hair = new Marking(profile.Appearance.HairStyleId, new[] { hairColor }); var facialHairColor = _markingManager.MustMatchSkin(profile.Species, HumanoidVisualLayers.FacialHair, out var facialHairAlpha, _prototypeManager) - ? profile.Appearance.SkinColor.WithAlpha(facialHairAlpha) : profile.Appearance.FacialHairColor; + ? profile.Appearance.SkinColor.WithAlpha(facialHairAlpha) + : profile.Appearance.FacialHairColor; var facialHair = new Marking(profile.Appearance.FacialHairStyleId, new[] { facialHairColor }); @@ -200,69 +184,60 @@ public sealed class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem DebugTools.Assert(IsClientSide(uid)); - var state = new HumanoidAppearanceState(markings, - new(), - new(), - customBaseLayers, - profile.Sex, - profile.Gender, - profile.Age, - profile.Species, - profile.Appearance.SkinColor, - profile.Appearance.EyeColor); + humanoid.MarkingSet = markings; + humanoid.PermanentlyHidden = new HashSet(); + humanoid.HiddenLayers = new HashSet(); + humanoid.CustomBaseLayers = customBaseLayers; + humanoid.Sex = profile.Sex; + humanoid.Gender = profile.Gender; + humanoid.Age = profile.Age; + humanoid.Species = profile.Species; + humanoid.SkinColor = profile.Appearance.SkinColor; + humanoid.EyeColor = profile.Appearance.EyeColor; - ApplyState(uid, humanoid, Comp(uid), state); + UpdateSprite(humanoid, Comp(uid)); } - private void ApplyMarkingSet(EntityUid uid, - MarkingSet newMarkings, - HumanoidAppearanceComponent humanoid, - SpriteComponent sprite) + private void ApplyMarkingSet(HumanoidAppearanceComponent humanoid, SpriteComponent sprite) { - // skip this entire thing if both sets are empty - if (humanoid.MarkingSet.Markings.Count == 0 && newMarkings.Markings.Count == 0) - return; - // I am lazy and I CBF resolving the previous mess, so I'm just going to nuke the markings. // Really, markings should probably be a separate component altogether. - - ClearAllMarkings(uid, humanoid, sprite); - - humanoid.MarkingSet = new(newMarkings); + ClearAllMarkings(humanoid, sprite); foreach (var markingList in humanoid.MarkingSet.Markings.Values) { foreach (var marking in markingList) { if (_markingManager.TryGetMarking(marking, out var markingPrototype)) - ApplyMarking(uid, markingPrototype, marking.MarkingColors, marking.Visible, humanoid, sprite); + ApplyMarking(markingPrototype, marking.MarkingColors, marking.Visible, humanoid, sprite); } } + + humanoid.ClientOldMarkings = new MarkingSet(humanoid.MarkingSet); } - private void ClearAllMarkings(EntityUid uid, HumanoidAppearanceComponent humanoid, - SpriteComponent sprite) + private void ClearAllMarkings(HumanoidAppearanceComponent humanoid, SpriteComponent sprite) { + foreach (var markingList in humanoid.ClientOldMarkings.Markings.Values) + { + foreach (var marking in markingList) + { + RemoveMarking(marking, sprite); + } + } + + humanoid.ClientOldMarkings.Clear(); + foreach (var markingList in humanoid.MarkingSet.Markings.Values) { foreach (var marking in markingList) { - RemoveMarking(uid, marking, sprite); + RemoveMarking(marking, sprite); } } } - private void ClearMarkings(EntityUid uid, List markings, HumanoidAppearanceComponent humanoid, - SpriteComponent spriteComp) - { - foreach (var marking in markings) - { - RemoveMarking(uid, marking, spriteComp); - } - } - - private void RemoveMarking(EntityUid uid, Marking marking, - SpriteComponent spriteComp) + private void RemoveMarking(Marking marking, SpriteComponent spriteComp) { if (!_markingManager.TryGetMarking(marking, out var prototype)) { @@ -286,8 +261,7 @@ public sealed class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem spriteComp.RemoveLayer(index); } } - private void ApplyMarking(EntityUid uid, - MarkingPrototype markingPrototype, + private void ApplyMarking(MarkingPrototype markingPrototype, IReadOnlyList? colors, bool visible, HumanoidAppearanceComponent humanoid, @@ -393,7 +367,7 @@ public sealed class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem foreach (var marking in markingList) { if (_markingManager.TryGetMarking(marking, out var markingPrototype) && markingPrototype.BodyPart == layer) - ApplyMarking(uid, markingPrototype, marking.MarkingColors, marking.Visible, humanoid, sprite); + ApplyMarking(markingPrototype, marking.MarkingColors, marking.Visible, humanoid, sprite); } } } diff --git a/Content.Client/Humanoid/HumanoidMarkingModifierBoundUserInterface.cs b/Content.Client/Humanoid/HumanoidMarkingModifierBoundUserInterface.cs index a1742219fb..a8872604a4 100644 --- a/Content.Client/Humanoid/HumanoidMarkingModifierBoundUserInterface.cs +++ b/Content.Client/Humanoid/HumanoidMarkingModifierBoundUserInterface.cs @@ -1,7 +1,5 @@ using Content.Shared.Humanoid; using Content.Shared.Humanoid.Markings; -using Robust.Client.GameObjects; -using static Content.Shared.Humanoid.HumanoidAppearanceState; namespace Content.Client.Humanoid; diff --git a/Content.Client/Humanoid/HumanoidMarkingModifierWindow.xaml.cs b/Content.Client/Humanoid/HumanoidMarkingModifierWindow.xaml.cs index 8cf90c4e63..4cde587c58 100644 --- a/Content.Client/Humanoid/HumanoidMarkingModifierWindow.xaml.cs +++ b/Content.Client/Humanoid/HumanoidMarkingModifierWindow.xaml.cs @@ -6,7 +6,6 @@ using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.XAML; using Robust.Shared.Prototypes; -using static Content.Shared.Humanoid.HumanoidAppearanceState; namespace Content.Client.Humanoid; @@ -76,7 +75,7 @@ public sealed partial class HumanoidMarkingModifierWindow : DefaultWindow continue; } - modifier.SetState(true, layerInfo.ID ?? string.Empty, layerInfo.Color ?? Color.White); + modifier.SetState(true, layerInfo.Id ?? string.Empty, layerInfo.Color ?? Color.White); } var eyesColor = Color.White; diff --git a/Content.Client/Implants/ImplanterSystem.cs b/Content.Client/Implants/ImplanterSystem.cs index bf15b9b26b..6949a94d67 100644 --- a/Content.Client/Implants/ImplanterSystem.cs +++ b/Content.Client/Implants/ImplanterSystem.cs @@ -2,7 +2,6 @@ using Content.Client.Items; using Content.Shared.Implants; using Content.Shared.Implants.Components; -using Robust.Shared.GameStates; namespace Content.Client.Implants; @@ -12,17 +11,12 @@ public sealed class ImplanterSystem : SharedImplanterSystem { base.Initialize(); - SubscribeLocalEvent(OnHandleImplanterState); + SubscribeLocalEvent(OnHandleImplanterState); SubscribeLocalEvent(OnItemImplanterStatus); } - private void OnHandleImplanterState(EntityUid uid, ImplanterComponent component, ref ComponentHandleState args) + private void OnHandleImplanterState(EntityUid uid, ImplanterComponent component, ref AfterAutoHandleStateEvent args) { - if (args.Current is not ImplanterComponentState state) - return; - - component.CurrentMode = state.CurrentMode; - component.ImplantOnly = state.ImplantOnly; component.UiUpdateNeeded = true; } diff --git a/Content.Client/Lathe/UI/LatheMenu.xaml.cs b/Content.Client/Lathe/UI/LatheMenu.xaml.cs index 1fd7c78ea4..3b3d90293c 100644 --- a/Content.Client/Lathe/UI/LatheMenu.xaml.cs +++ b/Content.Client/Lathe/UI/LatheMenu.xaml.cs @@ -1,6 +1,5 @@ using System.Linq; using System.Text; -using Content.Shared.FixedPoint; using Content.Shared.Lathe; using Content.Shared.Materials; using Content.Shared.Research.Prototypes; @@ -24,7 +23,7 @@ public sealed partial class LatheMenu : DefaultWindow public event Action? OnServerListButtonPressed; public event Action? RecipeQueueAction; public event Action? OnEjectPressed; - public List Recipes = new(); + public List> Recipes = new(); /// /// Default volume for a sheet if the material's entity prototype has no material composition. @@ -115,7 +114,7 @@ public sealed partial class LatheMenu : DefaultWindow var recipesToShow = new List(); foreach (var recipe in Recipes) { - if (!_prototypeManager.TryIndex(recipe, out var proto)) + if (!_prototypeManager.TryIndex(recipe, out var proto)) continue; if (SearchBar.Text.Trim().Length != 0) diff --git a/Content.Client/Movement/Systems/ClimbSystem.cs b/Content.Client/Movement/Systems/ClimbSystem.cs index 826c3b0a52..003b478b30 100644 --- a/Content.Client/Movement/Systems/ClimbSystem.cs +++ b/Content.Client/Movement/Systems/ClimbSystem.cs @@ -1,7 +1,6 @@ using Content.Client.Interactable; using Content.Shared.Climbing; using Content.Shared.DragDrop; -using Robust.Shared.GameStates; namespace Content.Client.Movement.Systems; @@ -12,19 +11,9 @@ public sealed class ClimbSystem : SharedClimbSystem public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnClimbingState); SubscribeLocalEvent(OnCanDragDropOn); } - private static void OnClimbingState(EntityUid uid, ClimbingComponent component, ref ComponentHandleState args) - { - if (args.Current is not ClimbingComponent.ClimbModeComponentState climbModeState) - return; - - component.IsClimbing = climbModeState.Climbing; - component.OwnerIsTransitioning = climbModeState.IsTransitioning; - } - protected override void OnCanDragDropOn(EntityUid uid, ClimbableComponent component, ref CanDropTargetEvent args) { base.OnCanDragDropOn(uid, component, ref args); diff --git a/Content.Client/Points/PointSystem.cs b/Content.Client/Points/PointSystem.cs index f41c4b09ab..2cc6bd2312 100644 --- a/Content.Client/Points/PointSystem.cs +++ b/Content.Client/Points/PointSystem.cs @@ -3,7 +3,6 @@ using Content.Client.Message; using Content.Shared.Points; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; -using Robust.Shared.GameStates; namespace Content.Client.Points; @@ -17,17 +16,12 @@ public sealed class PointSystem : SharedPointSystem { base.Initialize(); - SubscribeLocalEvent(OnHandleState); + SubscribeLocalEvent(OnHandleState); SubscribeLocalEvent(OnGetCharacterInfoControls); } - private void OnHandleState(EntityUid uid, PointManagerComponent component, ref ComponentHandleState args) + private void OnHandleState(EntityUid uid, PointManagerComponent component, ref AfterAutoHandleStateEvent args) { - if (args.Current is not PointManagerComponentState state) - return; - - component.Points = new(state.Points); - component.Scoreboard = state.Scoreboard; _characterInfo.RequestCharacterInfo(); } diff --git a/Content.Client/Radiation/Systems/GeigerSystem.cs b/Content.Client/Radiation/Systems/GeigerSystem.cs index 7a193d4a75..ffb0ad426e 100644 --- a/Content.Client/Radiation/Systems/GeigerSystem.cs +++ b/Content.Client/Radiation/Systems/GeigerSystem.cs @@ -2,10 +2,6 @@ using Content.Client.Items; using Content.Client.Radiation.UI; using Content.Shared.Radiation.Components; using Content.Shared.Radiation.Systems; -using Robust.Client.GameObjects; -using Robust.Client.Player; -using Robust.Shared.GameStates; -using Robust.Shared.Player; namespace Content.Client.Radiation.Systems; @@ -14,19 +10,12 @@ public sealed class GeigerSystem : SharedGeigerSystem public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnHandleState); + SubscribeLocalEvent(OnHandleState); SubscribeLocalEvent(OnGetStatusMessage); } - private void OnHandleState(EntityUid uid, GeigerComponent component, ref ComponentHandleState args) + private void OnHandleState(EntityUid uid, GeigerComponent component, ref AfterAutoHandleStateEvent args) { - if (args.Current is not GeigerComponentState state) - return; - - component.CurrentRadiation = state.CurrentRadiation; - component.DangerLevel = state.DangerLevel; - component.IsEnabled = state.IsEnabled; - component.User = EnsureEntity(state.User, uid); component.UiUpdateNeeded = true; } diff --git a/Content.Client/Tabletop/TabletopSystem.cs b/Content.Client/Tabletop/TabletopSystem.cs index d43111f39c..c71c34d0ef 100644 --- a/Content.Client/Tabletop/TabletopSystem.cs +++ b/Content.Client/Tabletop/TabletopSystem.cs @@ -11,7 +11,6 @@ using Robust.Client.Input; using Robust.Client.Player; using Robust.Client.UserInterface; using Robust.Client.UserInterface.CustomControls; -using Robust.Shared.GameStates; using Robust.Shared.Input; using Robust.Shared.Input.Binding; using Robust.Shared.Map; @@ -49,7 +48,6 @@ namespace Content.Client.Tabletop .Register(); SubscribeNetworkEvent(OnTabletopPlay); - SubscribeLocalEvent(HandleComponentState); SubscribeLocalEvent(HandleDraggableRemoved); SubscribeLocalEvent(OnAppearanceChange); } @@ -148,13 +146,6 @@ namespace Content.Client.Tabletop _window.OnClose += OnWindowClose; } - private void HandleComponentState(EntityUid uid, TabletopDraggableComponent component, ref ComponentHandleState args) - { - if (args.Current is not TabletopDraggableComponentState state) return; - - component.DraggingPlayer = state.DraggingPlayer; - } - private void OnWindowClose() { if (_table != null) diff --git a/Content.Client/Weapons/Ranged/Systems/GunSystem.Ballistic.cs b/Content.Client/Weapons/Ranged/Systems/GunSystem.Ballistic.cs index e0d4fa8e84..b0e3566bdc 100644 --- a/Content.Client/Weapons/Ranged/Systems/GunSystem.Ballistic.cs +++ b/Content.Client/Weapons/Ranged/Systems/GunSystem.Ballistic.cs @@ -39,7 +39,7 @@ public sealed partial class GunSystem else if (component.UnspawnedCount > 0) { component.UnspawnedCount--; - ent = Spawn(component.FillProto, coordinates); + ent = Spawn(component.Proto, coordinates); EnsureShootable(ent.Value); } diff --git a/Content.Server/Access/Systems/AccessOverriderSystem.cs b/Content.Server/Access/Systems/AccessOverriderSystem.cs index a41c0839da..3ec767c200 100644 --- a/Content.Server/Access/Systems/AccessOverriderSystem.cs +++ b/Content.Server/Access/Systems/AccessOverriderSystem.cs @@ -1,15 +1,15 @@ +using System.Linq; +using Content.Server.Popups; using Content.Shared.Access.Components; using Content.Shared.Access.Systems; using Content.Shared.Administration.Logs; using Content.Shared.Database; +using Content.Shared.DoAfter; using Content.Shared.Interaction; using JetBrains.Annotations; using Robust.Server.GameObjects; using Robust.Shared.Containers; -using System.Linq; using static Content.Shared.Access.Components.AccessOverriderComponent; -using Content.Server.Popups; -using Content.Shared.DoAfter; namespace Content.Server.Access.Systems; @@ -46,7 +46,7 @@ public sealed class AccessOverriderSystem : SharedAccessOverriderSystem if (!_interactionSystem.InRangeUnobstructed(args.User, (EntityUid) args.Target)) return; - var doAfterEventArgs = new DoAfterArgs(EntityManager, args.User, component.DoAfterTime, new AccessOverriderDoAfterEvent(), uid, target: args.Target, used: uid) + var doAfterEventArgs = new DoAfterArgs(EntityManager, args.User, component.DoAfter, new AccessOverriderDoAfterEvent(), uid, target: args.Target, used: uid) { BreakOnTargetMove = true, BreakOnUserMove = true, diff --git a/Content.Server/BarSign/Systems/BarSignSystem.cs b/Content.Server/BarSign/Systems/BarSignSystem.cs index c26fe2c288..4a48140845 100644 --- a/Content.Server/BarSign/Systems/BarSignSystem.cs +++ b/Content.Server/BarSign/Systems/BarSignSystem.cs @@ -1,6 +1,5 @@ using System.Linq; using Content.Shared.BarSign; -using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Random; @@ -15,17 +14,11 @@ namespace Content.Server.BarSign.Systems public override void Initialize() { SubscribeLocalEvent(OnMapInit); - SubscribeLocalEvent(OnGetState); - } - - private void OnGetState(EntityUid uid, BarSignComponent component, ref ComponentGetState args) - { - args.State = new BarSignComponentState(component.CurrentSign); } private void OnMapInit(EntityUid uid, BarSignComponent component, MapInitEvent args) { - if (component.CurrentSign != null) + if (component.Current != null) return; var prototypes = _prototypeManager @@ -40,7 +33,7 @@ namespace Content.Server.BarSign.Systems _metaData.SetEntityName(uid, Loc.GetString(name), meta); _metaData.SetEntityDescription(uid, Loc.GetString(newPrototype.Description), meta); - component.CurrentSign = newPrototype.ID; + component.Current = newPrototype.ID; Dirty(component); } } diff --git a/Content.Server/Climbing/ClimbSystem.cs b/Content.Server/Climbing/ClimbSystem.cs index 73c0eda3f3..e9d25f361f 100644 --- a/Content.Server/Climbing/ClimbSystem.cs +++ b/Content.Server/Climbing/ClimbSystem.cs @@ -21,7 +21,6 @@ using Content.Shared.Popups; using Content.Shared.Verbs; using JetBrains.Annotations; using Robust.Server.GameObjects; -using Robust.Shared.GameStates; using Robust.Shared.Physics; using Robust.Shared.Physics.Collision.Shapes; using Robust.Shared.Physics.Components; @@ -62,7 +61,6 @@ public sealed class ClimbSystem : SharedClimbSystem SubscribeLocalEvent(OnDoAfter); SubscribeLocalEvent(OnClimbEndCollide); SubscribeLocalEvent(OnBuckleChange); - SubscribeLocalEvent(OnClimbingGetState); SubscribeLocalEvent(OnGlassClimbed); } @@ -366,11 +364,6 @@ public sealed class ClimbSystem : SharedClimbSystem StopClimb(uid, component); } - private static void OnClimbingGetState(EntityUid uid, ClimbingComponent component, ref ComponentGetState args) - { - args.State = new ClimbingComponent.ClimbModeComponentState(component.IsClimbing, component.OwnerIsTransitioning); - } - private void OnGlassClimbed(EntityUid uid, GlassTableComponent component, ClimbedOnEvent args) { if (TryComp(args.Climber, out var physics) && physics.Mass <= component.MassLimit) diff --git a/Content.Server/Clothing/Systems/ChameleonClothingSystem.cs b/Content.Server/Clothing/Systems/ChameleonClothingSystem.cs index 10fadbbba1..7dc3b8489d 100644 --- a/Content.Server/Clothing/Systems/ChameleonClothingSystem.cs +++ b/Content.Server/Clothing/Systems/ChameleonClothingSystem.cs @@ -5,7 +5,6 @@ using Content.Shared.IdentityManagement.Components; using Content.Shared.Prototypes; using Content.Shared.Verbs; using Robust.Server.GameObjects; -using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Utility; @@ -22,22 +21,13 @@ public sealed class ChameleonClothingSystem : SharedChameleonClothingSystem { base.Initialize(); SubscribeLocalEvent(OnMapInit); - SubscribeLocalEvent(GetState); SubscribeLocalEvent>(OnVerb); SubscribeLocalEvent(OnSelected); } private void OnMapInit(EntityUid uid, ChameleonClothingComponent component, MapInitEvent args) { - SetSelectedPrototype(uid, component.SelectedId, true, component); - } - - private void GetState(EntityUid uid, ChameleonClothingComponent component, ref ComponentGetState args) - { - args.State = new ChameleonClothingComponentState - { - SelectedId = component.SelectedId - }; + SetSelectedPrototype(uid, component.Default, true, component); } private void OnVerb(EntityUid uid, ChameleonClothingComponent component, GetVerbsEvent args) @@ -72,7 +62,7 @@ public sealed class ChameleonClothingSystem : SharedChameleonClothingSystem if (!Resolve(uid, ref component)) return; - var state = new ChameleonBoundUserInterfaceState(component.Slot, component.SelectedId); + var state = new ChameleonBoundUserInterfaceState(component.Slot, component.Default); _uiSystem.TrySetUiState(uid, ChameleonUiKey.Key, state); } @@ -87,7 +77,7 @@ public sealed class ChameleonClothingSystem : SharedChameleonClothingSystem // check that wasn't already selected // forceUpdate on component init ignores this check - if (component.SelectedId == protoId && !forceUpdate) + if (component.Default == protoId && !forceUpdate) return; // make sure that it is valid change @@ -95,7 +85,7 @@ public sealed class ChameleonClothingSystem : SharedChameleonClothingSystem return; if (!IsValidTarget(proto, component.Slot)) return; - component.SelectedId = protoId; + component.Default = protoId; UpdateIdentityBlocker(uid, component, proto); UpdateVisuals(uid, component); diff --git a/Content.Server/Cuffs/CuffableSystem.cs b/Content.Server/Cuffs/CuffableSystem.cs index 2b65803673..2c28603c3f 100644 --- a/Content.Server/Cuffs/CuffableSystem.cs +++ b/Content.Server/Cuffs/CuffableSystem.cs @@ -1,6 +1,6 @@ using Content.Shared.Cuffs; -using JetBrains.Annotations; using Content.Shared.Cuffs.Components; +using JetBrains.Annotations; using Robust.Shared.GameStates; namespace Content.Server.Cuffs @@ -12,15 +12,9 @@ namespace Content.Server.Cuffs { base.Initialize(); - SubscribeLocalEvent(OnHandcuffGetState); SubscribeLocalEvent(OnCuffableGetState); } - private void OnHandcuffGetState(EntityUid uid, HandcuffComponent component, ref ComponentGetState args) - { - args.State = new HandcuffComponentState(component.OverlayIconState); - } - private void OnCuffableGetState(EntityUid uid, CuffableComponent component, ref ComponentGetState args) { // there are 2 approaches i can think of to handle the handcuff overlay on players @@ -34,7 +28,7 @@ namespace Content.Server.Cuffs args.State = new CuffableComponentState(component.CuffedHandCount, component.CanStillInteract, cuffs?.CuffedRSI, - $"{cuffs?.OverlayIconState}-{component.CuffedHandCount}", + $"{cuffs?.BodyIconState}-{component.CuffedHandCount}", cuffs?.Color); // the iconstate is formatted as blah-2, blah-4, blah-6, etc. // the number corresponds to how many hands are cuffed. diff --git a/Content.Server/Doors/Systems/DoorSystem.cs b/Content.Server/Doors/Systems/DoorSystem.cs index aa4de6b86b..5899baf2fc 100644 --- a/Content.Server/Doors/Systems/DoorSystem.cs +++ b/Content.Server/Doors/Systems/DoorSystem.cs @@ -1,22 +1,19 @@ using Content.Server.Access; +using Content.Server.Administration.Logs; using Content.Server.Atmos.Components; using Content.Server.Atmos.EntitySystems; +using Content.Server.Power.EntitySystems; using Content.Shared.Database; -using Content.Shared.Doors; using Content.Shared.Doors.Components; using Content.Shared.Doors.Systems; using Content.Shared.Emag.Systems; using Content.Shared.Interaction; +using Content.Shared.Prying.Components; +using Content.Shared.Prying.Systems; +using Content.Shared.Tools.Systems; using Robust.Shared.Audio; -using Content.Server.Administration.Logs; -using Content.Server.Power.EntitySystems; -using Content.Shared.Tools; using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Events; -using Content.Shared.DoAfter; -using Content.Shared.Prying.Systems; -using Content.Shared.Prying.Components; -using Content.Shared.Tools.Systems; namespace Content.Server.Doors.Systems; @@ -25,8 +22,6 @@ public sealed class DoorSystem : SharedDoorSystem [Dependency] private readonly IAdminLogManager _adminLog = default!; [Dependency] private readonly DoorBoltSystem _bolts = default!; [Dependency] private readonly AirtightSystem _airtightSystem = default!; - [Dependency] private readonly SharedToolSystem _toolSystem = default!; - [Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!; [Dependency] private readonly PryingSystem _pryingSystem = default!; public override void Initialize() diff --git a/Content.Server/Electrocution/ElectrocutionSystem.cs b/Content.Server/Electrocution/ElectrocutionSystem.cs index c6ce90692f..63517c9962 100644 --- a/Content.Server/Electrocution/ElectrocutionSystem.cs +++ b/Content.Server/Electrocution/ElectrocutionSystem.cs @@ -210,7 +210,7 @@ public sealed class ElectrocutionSystem : SharedElectrocutionSystem return; var siemens = TryComp(args.Used, out var insulation) - ? insulation.SiemensCoefficient + ? insulation.Coefficient : 1; TryDoElectrifiedAct(uid, args.User, siemens, electrified); diff --git a/Content.Server/Implants/ImplanterSystem.cs b/Content.Server/Implants/ImplanterSystem.cs index db5602a2bb..f3072769e4 100644 --- a/Content.Server/Implants/ImplanterSystem.cs +++ b/Content.Server/Implants/ImplanterSystem.cs @@ -8,7 +8,6 @@ using Content.Shared.Interaction; using Content.Shared.Mobs.Components; using Content.Shared.Popups; using Robust.Shared.Containers; -using Robust.Shared.GameStates; namespace Content.Server.Implants; @@ -24,7 +23,6 @@ public sealed partial class ImplanterSystem : SharedImplanterSystem InitializeImplanted(); SubscribeLocalEvent(OnImplanterAfterInteract); - SubscribeLocalEvent(OnImplanterGetState); SubscribeLocalEvent(OnImplant); SubscribeLocalEvent(OnDraw); @@ -109,11 +107,6 @@ public sealed partial class ImplanterSystem : SharedImplanterSystem } - private void OnImplanterGetState(EntityUid uid, ImplanterComponent component, ref ComponentGetState args) - { - args.State = new ImplanterComponentState(component.CurrentMode, component.ImplantOnly); - } - private void OnImplant(EntityUid uid, ImplanterComponent component, ImplantEvent args) { if (args.Cancelled || args.Handled || args.Target == null || args.Used == null) diff --git a/Content.Server/Lathe/LatheSystem.cs b/Content.Server/Lathe/LatheSystem.cs index 9761ae5765..309ee58316 100644 --- a/Content.Server/Lathe/LatheSystem.cs +++ b/Content.Server/Lathe/LatheSystem.cs @@ -107,11 +107,11 @@ namespace Content.Server.Lathe { if (args.Storage != uid) return; - var materialWhitelist = new List(); + var materialWhitelist = new List>(); var recipes = GetAllBaseRecipes(component); foreach (var id in recipes) { - if (!_proto.TryIndex(id, out var proto)) + if (!_proto.TryIndex(id, out var proto)) continue; foreach (var (mat, _) in proto.RequiredMaterials) { @@ -127,7 +127,7 @@ namespace Content.Server.Lathe } [PublicAPI] - public bool TryGetAvailableRecipes(EntityUid uid, [NotNullWhen(true)] out List? recipes, [NotNullWhen(true)] LatheComponent? component = null) + public bool TryGetAvailableRecipes(EntityUid uid, [NotNullWhen(true)] out List>? recipes, [NotNullWhen(true)] LatheComponent? component = null) { recipes = null; if (!Resolve(uid, ref component)) @@ -136,17 +136,17 @@ namespace Content.Server.Lathe return true; } - public List GetAvailableRecipes(EntityUid uid, LatheComponent component) + public List> GetAvailableRecipes(EntityUid uid, LatheComponent component) { var ev = new LatheGetRecipesEvent(uid) { - Recipes = new List(component.StaticRecipes) + Recipes = new List>(component.StaticRecipes) }; RaiseLocalEvent(uid, ev); return ev.Recipes; } - public static List GetAllBaseRecipes(LatheComponent component) + public static List> GetAllBaseRecipes(LatheComponent component) { return component.StaticRecipes.Union(component.DynamicRecipes).ToList(); } @@ -300,7 +300,7 @@ namespace Content.Server.Lathe private void OnPartsRefresh(EntityUid uid, LatheComponent component, RefreshPartsEvent args) { - var printTimeRating = args.PartRatings[component.MachinePartPrintTime]; + var printTimeRating = args.PartRatings[component.MachinePartPrintSpeed]; var materialUseRating = args.PartRatings[component.MachinePartMaterialUse]; component.TimeMultiplier = MathF.Pow(component.PartRatingPrintTimeMultiplier, printTimeRating - 1); diff --git a/Content.Server/Points/PointSystem.cs b/Content.Server/Points/PointSystem.cs index c3265701c0..56831980d0 100644 --- a/Content.Server/Points/PointSystem.cs +++ b/Content.Server/Points/PointSystem.cs @@ -5,7 +5,6 @@ using JetBrains.Annotations; using Robust.Server.GameObjects; using Robust.Server.GameStates; using Robust.Server.Player; -using Robust.Shared.GameStates; using Robust.Shared.Utility; namespace Content.Server.Points; @@ -22,7 +21,6 @@ public sealed class PointSystem : SharedPointSystem base.Initialize(); SubscribeLocalEvent(OnStartup); - SubscribeLocalEvent(OnGetState); } private void OnStartup(EntityUid uid, PointManagerComponent component, ComponentStartup args) @@ -30,11 +28,6 @@ public sealed class PointSystem : SharedPointSystem _pvsOverride.AddGlobalOverride(uid); } - private void OnGetState(EntityUid uid, PointManagerComponent component, ref ComponentGetState args) - { - args.State = new PointManagerComponentState(component.Points, component.Scoreboard); - } - /// /// Adds the specified point value to a player. /// diff --git a/Content.Server/Radiation/Systems/GeigerSystem.cs b/Content.Server/Radiation/Systems/GeigerSystem.cs index 050b169819..640a257694 100644 --- a/Content.Server/Radiation/Systems/GeigerSystem.cs +++ b/Content.Server/Radiation/Systems/GeigerSystem.cs @@ -5,8 +5,6 @@ using Content.Shared.Interaction; using Content.Shared.Inventory.Events; using Content.Shared.Radiation.Components; using Content.Shared.Radiation.Systems; -using Robust.Shared.GameStates; -using Robust.Shared.Player; using Robust.Server.GameObjects; using Robust.Server.Player; @@ -32,7 +30,6 @@ public sealed class GeigerSystem : SharedGeigerSystem SubscribeLocalEvent(OnUnequippedHand); SubscribeLocalEvent(OnUpdate); - SubscribeLocalEvent(OnGetState); } private void OnActivate(EntityUid uid, GeigerComponent component, ActivateInWorldEvent args) @@ -86,17 +83,6 @@ public sealed class GeigerSystem : SharedGeigerSystem } } - private void OnGetState(EntityUid uid, GeigerComponent component, ref ComponentGetState args) - { - args.State = new GeigerComponentState - { - CurrentRadiation = component.CurrentRadiation, - DangerLevel = component.DangerLevel, - IsEnabled = component.IsEnabled, - User = GetNetEntity(component.User) - }; - } - private void SetCurrentRadiation(EntityUid uid, GeigerComponent component, float rads) { // check that it's approx equal diff --git a/Content.Server/Weapons/Melee/EnergySword/EnergySwordSystem.cs b/Content.Server/Weapons/Melee/EnergySword/EnergySwordSystem.cs index 67866e6e5a..fcd42f5a28 100644 --- a/Content.Server/Weapons/Melee/EnergySword/EnergySwordSystem.cs +++ b/Content.Server/Weapons/Melee/EnergySword/EnergySwordSystem.cs @@ -110,7 +110,7 @@ public sealed class EnergySwordSystem : EntitySystem { weaponComp.HitSound = comp.OnHitOff; if (comp.Secret) - weaponComp.HideFromExamine = true; + weaponComp.Hidden = true; } if (comp.IsSharp) @@ -135,7 +135,7 @@ public sealed class EnergySwordSystem : EntitySystem { weaponComp.HitSound = comp.OnHitOn; if (comp.Secret) - weaponComp.HideFromExamine = false; + weaponComp.Hidden = false; } if (TryComp(uid, out var malus)) diff --git a/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs b/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs index c4fec25139..a0a3f6d5d7 100644 --- a/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs +++ b/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs @@ -8,11 +8,13 @@ using Content.Server.Chemistry.EntitySystems; using Content.Server.CombatMode.Disarm; using Content.Server.Contests; using Content.Server.Movement.Systems; -using Content.Shared.Administration.Components; using Content.Shared.Actions.Events; +using Content.Shared.Administration.Components; using Content.Shared.CombatMode; using Content.Shared.Damage.Events; +using Content.Shared.Damage.Systems; using Content.Shared.Database; +using Content.Shared.Effects; using Content.Shared.FixedPoint; using Content.Shared.Hands.Components; using Content.Shared.IdentityManagement; @@ -29,8 +31,6 @@ using Robust.Shared.Map; using Robust.Shared.Player; using Robust.Shared.Players; using Robust.Shared.Random; -using Content.Shared.Effects; -using Content.Shared.Damage.Systems; namespace Content.Server.Weapons.Melee; @@ -57,7 +57,7 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem private void OnMeleeExamineDamage(EntityUid uid, MeleeWeaponComponent component, ref DamageExamineEvent args) { - if (component.HideFromExamine) + if (component.Hidden) return; var damageSpec = GetDamage(uid, args.User, component); diff --git a/Content.Server/Weapons/Ranged/Systems/GunSystem.Ballistic.cs b/Content.Server/Weapons/Ranged/Systems/GunSystem.Ballistic.cs index ef3127e39b..a2990c2037 100644 --- a/Content.Server/Weapons/Ranged/Systems/GunSystem.Ballistic.cs +++ b/Content.Server/Weapons/Ranged/Systems/GunSystem.Ballistic.cs @@ -22,7 +22,7 @@ public sealed partial class GunSystem else if (component.UnspawnedCount > 0) { component.UnspawnedCount--; - ent = Spawn(component.FillProto, coordinates); + ent = Spawn(component.Proto, coordinates); EnsureShootable(ent.Value); } diff --git a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs index 0acb20f5a2..0859cb9442 100644 --- a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs @@ -54,12 +54,12 @@ public sealed partial class GunSystem : SharedGunSystem private void OnBallisticPrice(EntityUid uid, BallisticAmmoProviderComponent component, ref PriceCalculationEvent args) { - if (string.IsNullOrEmpty(component.FillProto) || component.UnspawnedCount == 0) + if (string.IsNullOrEmpty(component.Proto) || component.UnspawnedCount == 0) return; - if (!ProtoManager.TryIndex(component.FillProto, out var proto)) + if (!ProtoManager.TryIndex(component.Proto, out var proto)) { - Log.Error($"Unable to find fill prototype for price on {component.FillProto} on {ToPrettyString(uid)}"); + Log.Error($"Unable to find fill prototype for price on {component.Proto} on {ToPrettyString(uid)}"); return; } diff --git a/Content.Server/Zombies/ZombieSystem.Transform.cs b/Content.Server/Zombies/ZombieSystem.Transform.cs index 19e8013220..3014edd1b9 100644 --- a/Content.Server/Zombies/ZombieSystem.Transform.cs +++ b/Content.Server/Zombies/ZombieSystem.Transform.cs @@ -12,7 +12,6 @@ using Content.Server.NPC; using Content.Server.NPC.Components; using Content.Server.NPC.HTN; using Content.Server.NPC.Systems; -using Content.Server.Nutrition.Components; using Content.Server.Roles; using Content.Server.Speech.Components; using Content.Server.Temperature.Components; @@ -113,7 +112,7 @@ namespace Content.Server.Zombies //This is the actual damage of the zombie. We assign the visual appearance //and range here because of stuff we'll find out later var melee = EnsureComp(target); - melee.ClickAnimation = zombiecomp.AttackAnimation; + melee.Animation = zombiecomp.AttackAnimation; melee.WideAnimation = zombiecomp.AttackAnimation; melee.Range = 1.2f; diff --git a/Content.Server/Zombies/ZombieSystem.cs b/Content.Server/Zombies/ZombieSystem.cs index 0d51da03ae..1f8f5fbd42 100644 --- a/Content.Server/Zombies/ZombieSystem.cs +++ b/Content.Server/Zombies/ZombieSystem.cs @@ -255,7 +255,7 @@ namespace Content.Server.Zombies foreach (var (layer, info) in zombiecomp.BeforeZombifiedCustomBaseLayers) { _humanoidAppearance.SetBaseLayerColor(target, layer, info.Color); - _humanoidAppearance.SetBaseLayerId(target, layer, info.ID); + _humanoidAppearance.SetBaseLayerId(target, layer, info.Id); } if(TryComp(target, out var appcomp)) { diff --git a/Content.Shared/Access/Components/AccessOverriderComponent.cs b/Content.Shared/Access/Components/AccessOverriderComponent.cs index 459cc24f0c..4e1a376ab6 100644 --- a/Content.Shared/Access/Components/AccessOverriderComponent.cs +++ b/Content.Shared/Access/Components/AccessOverriderComponent.cs @@ -2,22 +2,22 @@ using Content.Shared.Access.Systems; using Content.Shared.Containers.ItemSlots; using Robust.Shared.Audio; using Robust.Shared.GameStates; +using Robust.Shared.Prototypes; using Robust.Shared.Serialization; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; namespace Content.Shared.Access.Components; -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] [Access(typeof(SharedAccessOverriderSystem))] public sealed partial class AccessOverriderComponent : Component { public static string PrivilegedIdCardSlotId = "AccessOverrider-privilegedId"; - [DataField("privilegedIdSlot")] + [DataField] public ItemSlot PrivilegedIdSlot = new(); [ViewVariables(VVAccess.ReadWrite)] - [DataField("denialSound")] + [DataField] public SoundSpecifier? DenialSound; public EntityUid TargetAccessReaderId = new(); @@ -33,12 +33,12 @@ public sealed partial class AccessOverriderComponent : Component } } - [DataField("accessLevels", customTypeSerializer: typeof(PrototypeIdListSerializer))] - public List AccessLevels = new(); + [DataField, AutoNetworkedField(true)] + public List> AccessLevels = new(); [ViewVariables(VVAccess.ReadWrite)] - [DataField("doAfter")] - public float DoAfterTime = 0f; + [DataField] + public float DoAfter; [Serializable, NetSerializable] public sealed class AccessOverriderBoundUserInterfaceState : BoundUserInterfaceState diff --git a/Content.Shared/Access/Components/IdCardConsoleComponent.cs b/Content.Shared/Access/Components/IdCardConsoleComponent.cs index dbc78e2474..47f2660d80 100644 --- a/Content.Shared/Access/Components/IdCardConsoleComponent.cs +++ b/Content.Shared/Access/Components/IdCardConsoleComponent.cs @@ -1,12 +1,12 @@ using Content.Shared.Access.Systems; using Content.Shared.Containers.ItemSlots; using Robust.Shared.GameStates; +using Robust.Shared.Prototypes; using Robust.Shared.Serialization; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; namespace Content.Shared.Access.Components; -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] [Access(typeof(SharedIdCardConsoleSystem))] public sealed partial class IdCardConsoleComponent : Component { @@ -16,10 +16,10 @@ public sealed partial class IdCardConsoleComponent : Component public static string PrivilegedIdCardSlotId = "IdCardConsole-privilegedId"; public static string TargetIdCardSlotId = "IdCardConsole-targetId"; - [DataField("privilegedIdSlot")] + [DataField] public ItemSlot PrivilegedIdSlot = new(); - [DataField("targetIdSlot")] + [DataField] public ItemSlot TargetIdSlot = new(); [Serializable, NetSerializable] @@ -41,8 +41,8 @@ public sealed partial class IdCardConsoleComponent : Component // Put this on shared so we just send the state once in PVS range rather than every time the UI updates. - [DataField("accessLevels", customTypeSerializer: typeof(PrototypeIdListSerializer))] - public List AccessLevels = new() + [DataField, AutoNetworkedField] + public List> AccessLevels = new() { "Armory", "Atmospherics", diff --git a/Content.Shared/Access/Systems/SharedAccessOverriderSystem.cs b/Content.Shared/Access/Systems/SharedAccessOverriderSystem.cs index c19fe697e6..36c74ed0dd 100644 --- a/Content.Shared/Access/Systems/SharedAccessOverriderSystem.cs +++ b/Content.Shared/Access/Systems/SharedAccessOverriderSystem.cs @@ -2,7 +2,6 @@ using Content.Shared.Access.Components; using Content.Shared.Containers.ItemSlots; using Content.Shared.DoAfter; using JetBrains.Annotations; -using Robust.Shared.GameStates; using Robust.Shared.Serialization; namespace Content.Shared.Access.Systems @@ -23,19 +22,6 @@ namespace Content.Shared.Access.Systems SubscribeLocalEvent(OnComponentInit); SubscribeLocalEvent(OnComponentRemove); - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); - } - - private void OnHandleState(EntityUid uid, AccessOverriderComponent component, ref ComponentHandleState args) - { - if (args.Current is not AccessOverriderComponentState state) return; - component.AccessLevels = state.AccessLevels; - } - - private void OnGetState(EntityUid uid, AccessOverriderComponent component, ref ComponentGetState args) - { - args.State = new AccessOverriderComponentState(component.AccessLevels); } private void OnComponentInit(EntityUid uid, AccessOverriderComponent component, ComponentInit args) @@ -48,17 +34,6 @@ namespace Content.Shared.Access.Systems _itemSlotsSystem.RemoveItemSlot(uid, component.PrivilegedIdSlot); } - [Serializable, NetSerializable] - private sealed class AccessOverriderComponentState : ComponentState - { - public List AccessLevels; - - public AccessOverriderComponentState(List accessLevels) - { - AccessLevels = accessLevels; - } - } - [Serializable, NetSerializable] public sealed partial class AccessOverriderDoAfterEvent : DoAfterEvent { diff --git a/Content.Shared/Access/Systems/SharedIdCardConsoleSystem.cs b/Content.Shared/Access/Systems/SharedIdCardConsoleSystem.cs index 9abb91de47..12e25e1e22 100644 --- a/Content.Shared/Access/Systems/SharedIdCardConsoleSystem.cs +++ b/Content.Shared/Access/Systems/SharedIdCardConsoleSystem.cs @@ -1,8 +1,6 @@ using Content.Shared.Access.Components; using Content.Shared.Containers.ItemSlots; using JetBrains.Annotations; -using Robust.Shared.GameStates; -using Robust.Shared.Serialization; namespace Content.Shared.Access.Systems { @@ -22,19 +20,6 @@ namespace Content.Shared.Access.Systems SubscribeLocalEvent(OnComponentInit); SubscribeLocalEvent(OnComponentRemove); - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); - } - - private void OnHandleState(EntityUid uid, IdCardConsoleComponent component, ref ComponentHandleState args) - { - if (args.Current is not IdCardConsoleComponentState state) return; - component.AccessLevels = state.AccessLevels; - } - - private void OnGetState(EntityUid uid, IdCardConsoleComponent component, ref ComponentGetState args) - { - args.State = new IdCardConsoleComponentState(component.AccessLevels); } private void OnComponentInit(EntityUid uid, IdCardConsoleComponent component, ComponentInit args) @@ -48,16 +33,5 @@ namespace Content.Shared.Access.Systems _itemSlotsSystem.RemoveItemSlot(uid, component.PrivilegedIdSlot); _itemSlotsSystem.RemoveItemSlot(uid, component.TargetIdSlot); } - - [Serializable, NetSerializable] - private sealed class IdCardConsoleComponentState : ComponentState - { - public List AccessLevels; - - public IdCardConsoleComponentState(List accessLevels) - { - AccessLevels = accessLevels; - } - } } } diff --git a/Content.Shared/Alert/AlertsComponent.cs b/Content.Shared/Alert/AlertsComponent.cs index 4468db4463..05b11e19ef 100644 --- a/Content.Shared/Alert/AlertsComponent.cs +++ b/Content.Shared/Alert/AlertsComponent.cs @@ -6,11 +6,12 @@ namespace Content.Shared.Alert; /// Handles the icons on the right side of the screen. /// Should only be used for player-controlled entities. /// -[RegisterComponent] -[NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] public sealed partial class AlertsComponent : Component { - [ViewVariables] public Dictionary Alerts = new(); + [ViewVariables] + [AutoNetworkedField] + public Dictionary Alerts = new(); public override bool SendOnlyToOwner => true; } diff --git a/Content.Shared/Alert/AlertsComponentState.cs b/Content.Shared/Alert/AlertsComponentState.cs deleted file mode 100644 index c503338ea8..0000000000 --- a/Content.Shared/Alert/AlertsComponentState.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Robust.Shared.Serialization; - -namespace Content.Shared.Alert; - -[Serializable, NetSerializable] -public sealed class AlertsComponentState : ComponentState -{ - public Dictionary Alerts; - - public AlertsComponentState(Dictionary alerts) - { - Alerts = alerts; - } -} diff --git a/Content.Shared/Alert/AlertsSystem.cs b/Content.Shared/Alert/AlertsSystem.cs index 37c49a46ce..db6911f12b 100644 --- a/Content.Shared/Alert/AlertsSystem.cs +++ b/Content.Shared/Alert/AlertsSystem.cs @@ -1,5 +1,4 @@ using System.Diagnostics.CodeAnalysis; -using Robust.Shared.GameStates; using Robust.Shared.Prototypes; namespace Content.Shared.Alert; @@ -170,7 +169,6 @@ public abstract class AlertsSystem : EntitySystem SubscribeLocalEvent(HandleComponentStartup); SubscribeLocalEvent(HandleComponentShutdown); - SubscribeLocalEvent(ClientAlertsGetState); SubscribeNetworkEvent(HandleClickAlert); LoadPrototypes(); @@ -243,9 +241,4 @@ public abstract class AlertsSystem : EntitySystem alert.OnClick?.AlertClicked(player.Value); } - - private static void ClientAlertsGetState(EntityUid uid, AlertsComponent component, ref ComponentGetState args) - { - args.State = new AlertsComponentState(component.Alerts); - } } diff --git a/Content.Shared/Anomaly/Components/AnomalyComponent.cs b/Content.Shared/Anomaly/Components/AnomalyComponent.cs index e1e15561f8..07fc603e26 100644 --- a/Content.Shared/Anomaly/Components/AnomalyComponent.cs +++ b/Content.Shared/Anomaly/Components/AnomalyComponent.cs @@ -2,7 +2,6 @@ using System.Numerics; using Content.Shared.Damage; using Robust.Shared.Audio; using Robust.Shared.GameStates; -using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; namespace Content.Shared.Anomaly.Components; @@ -14,7 +13,8 @@ namespace Content.Shared.Anomaly.Components; /// /// Anomalies and their related components were designed here: https://hackmd.io/@ss14-design/r1sQbkJOs /// -[RegisterComponent, NetworkedComponent, Access(typeof(SharedAnomalySystem))] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +[Access(typeof(SharedAnomalySystem))] public sealed partial class AnomalyComponent : Component { /// @@ -27,7 +27,7 @@ public sealed partial class AnomalyComponent : Component /// Note that this doesn't refer to stability as a percentage: This is an arbitrary /// value that only matters in relation to the and /// - [ViewVariables(VVAccess.ReadWrite)] + [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public float Stability = 0f; /// @@ -39,7 +39,7 @@ public sealed partial class AnomalyComponent : Component /// /// Wacky-Stability scale lives on in my heart. - emo /// - [ViewVariables(VVAccess.ReadWrite)] + [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public float Severity = 0f; #region Health @@ -49,7 +49,7 @@ public sealed partial class AnomalyComponent : Component /// When the health of an anomaly reaches 0, it is destroyed without ever /// reaching a supercritical point. /// - [ViewVariables(VVAccess.ReadWrite)] + [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public float Health = 1f; /// @@ -85,25 +85,26 @@ public sealed partial class AnomalyComponent : Component /// /// The time at which the next artifact pulse will occur. /// - [DataField("nextPulseTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)] + [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField] + [ViewVariables(VVAccess.ReadWrite)] public TimeSpan NextPulseTime = TimeSpan.Zero; /// /// The minimum interval between pulses. /// - [DataField("minPulseLength")] + [DataField] public TimeSpan MinPulseLength = TimeSpan.FromMinutes(1); /// /// The maximum interval between pulses. /// - [DataField("maxPulseLength")] + [DataField] public TimeSpan MaxPulseLength = TimeSpan.FromMinutes(2); /// /// A percentage by which the length of a pulse might vary. /// - [DataField("pulseVariation")] + [DataField] public float PulseVariation = 0.1f; /// @@ -112,19 +113,19 @@ public sealed partial class AnomalyComponent : Component /// /// This is more likely to trend upwards than donwards, because that's funny /// - [DataField("pulseStabilityVariation")] + [DataField] public Vector2 PulseStabilityVariation = new(-0.1f, 0.15f); /// /// The sound played when an anomaly pulses /// - [DataField("pulseSound")] + [DataField] public SoundSpecifier? PulseSound = new SoundCollectionSpecifier("RadiationPulse"); /// /// The sound plays when an anomaly goes supercritical /// - [DataField("supercriticalSound")] + [DataField] public SoundSpecifier? SupercriticalSound = new SoundCollectionSpecifier("explosion"); #endregion @@ -134,7 +135,7 @@ public sealed partial class AnomalyComponent : Component /// /// +/- 0.2 from perfect stability (0.5) /// - [DataField("initialStabilityRange")] + [DataField] public (float, float) InitialStabilityRange = (0.4f, 0.6f); /// @@ -143,25 +144,25 @@ public sealed partial class AnomalyComponent : Component /// /// Between 0 and 0.5, which should be all mild effects /// - [DataField("initialSeverityRange")] + [DataField] public (float, float) InitialSeverityRange = (0.1f, 0.5f); /// /// The particle type that increases the severity of the anomaly. /// - [DataField("severityParticleType")] + [DataField] public AnomalousParticleType SeverityParticleType; /// /// The particle type that destabilizes the anomaly. /// - [DataField("destabilizingParticleType")] + [DataField] public AnomalousParticleType DestabilizingParticleType; /// /// The particle type that weakens the anomalys health. /// - [DataField("weakeningParticleType")] + [DataField] public AnomalousParticleType WeakeningParticleType; #region Points and Vessels @@ -197,14 +198,14 @@ public sealed partial class AnomalyComponent : Component /// The amount of damage dealt when either a player touches the anomaly /// directly or by hitting the anomaly. /// - [DataField("anomalyContactDamage", required: true)] + [DataField(required: true)] public DamageSpecifier AnomalyContactDamage = default!; /// /// The sound effect played when a player /// burns themselves on an anomaly via contact. /// - [DataField("anomalyContactDamageSound")] + [DataField] public SoundSpecifier AnomalyContactDamageSound = new SoundPathSpecifier("/Audio/Effects/lightburn.ogg"); #region Floating Animation @@ -226,23 +227,6 @@ public sealed partial class AnomalyComponent : Component #endregion } -[Serializable, NetSerializable] -public sealed class AnomalyComponentState : ComponentState -{ - public float Severity; - public float Stability; - public float Health; - public TimeSpan NextPulseTime; - - public AnomalyComponentState(float severity, float stability, float health, TimeSpan nextPulseTime) - { - Severity = severity; - Stability = stability; - Health = health; - NextPulseTime = nextPulseTime; - } -} - /// /// Event raised at regular intervals on an anomaly to do whatever its effect is. /// diff --git a/Content.Shared/Anomaly/Components/AnomalySupercriticalComponent.cs b/Content.Shared/Anomaly/Components/AnomalySupercriticalComponent.cs index e5101fef66..bd8f40852d 100644 --- a/Content.Shared/Anomaly/Components/AnomalySupercriticalComponent.cs +++ b/Content.Shared/Anomaly/Components/AnomalySupercriticalComponent.cs @@ -1,5 +1,4 @@ using Robust.Shared.GameStates; -using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; namespace Content.Shared.Anomaly.Components; @@ -7,31 +6,27 @@ namespace Content.Shared.Anomaly.Components; /// /// Tracks anomalies going supercritical /// -[RegisterComponent, NetworkedComponent, Access(typeof(SharedAnomalySystem))] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +[Access(typeof(SharedAnomalySystem))] public sealed partial class AnomalySupercriticalComponent : Component { /// /// The time when the supercritical animation ends and it does whatever effect. /// - [DataField("endTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)] + [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField] + [ViewVariables(VVAccess.ReadWrite)] public TimeSpan EndTime; /// /// The length of the animation before it goes supercritical. /// + [AutoNetworkedField] [ViewVariables(VVAccess.ReadWrite)] public TimeSpan SupercriticalDuration = TimeSpan.FromSeconds(10); /// /// The maximum size the anomaly scales to while going supercritical /// - [DataField("maxScaleAmount")] + [DataField] public float MaxScaleAmount = 3; } - -[Serializable, NetSerializable] -public sealed class AnomalySupercriticalComponentState : ComponentState -{ - public TimeSpan EndTime; - public TimeSpan Duration; -} diff --git a/Content.Shared/Anomaly/SharedAnomalySystem.cs b/Content.Shared/Anomaly/SharedAnomalySystem.cs index 12a97fda42..4b2b3ada70 100644 --- a/Content.Shared/Anomaly/SharedAnomalySystem.cs +++ b/Content.Shared/Anomaly/SharedAnomalySystem.cs @@ -5,7 +5,6 @@ using Content.Shared.Database; using Content.Shared.Interaction; using Content.Shared.Popups; using Content.Shared.Weapons.Melee.Events; -using Robust.Shared.GameStates; using Robust.Shared.Network; using Robust.Shared.Random; using Robust.Shared.Timing; @@ -30,10 +29,6 @@ public abstract class SharedAnomalySystem : EntitySystem { base.Initialize(); - SubscribeLocalEvent(OnAnomalyGetState); - SubscribeLocalEvent(OnAnomalyHandleState); - SubscribeLocalEvent(OnSupercriticalGetState); - SubscribeLocalEvent(OnSupercriticalHandleState); SubscribeLocalEvent(OnInteractHand); SubscribeLocalEvent(OnAttacked); @@ -44,43 +39,6 @@ public abstract class SharedAnomalySystem : EntitySystem _sawmill = Logger.GetSawmill("anomaly"); } - private void OnAnomalyGetState(EntityUid uid, AnomalyComponent component, ref ComponentGetState args) - { - args.State = new AnomalyComponentState( - component.Severity, - component.Stability, - component.Health, - component.NextPulseTime); - } - - private void OnAnomalyHandleState(EntityUid uid, AnomalyComponent component, ref ComponentHandleState args) - { - if (args.Current is not AnomalyComponentState state) - return; - component.Severity = state.Severity; - component.Stability = state.Stability; - component.Health = state.Health; - component.NextPulseTime = state.NextPulseTime; - } - - private void OnSupercriticalGetState(EntityUid uid, AnomalySupercriticalComponent component, ref ComponentGetState args) - { - args.State = new AnomalySupercriticalComponentState - { - EndTime = component.EndTime, - Duration = component.SupercriticalDuration - }; - } - - private void OnSupercriticalHandleState(EntityUid uid, AnomalySupercriticalComponent component, ref ComponentHandleState args) - { - if (args.Current is not AnomalySupercriticalComponentState state) - return; - - component.EndTime = state.EndTime; - component.SupercriticalDuration = state.Duration; - } - private void OnInteractHand(EntityUid uid, AnomalyComponent component, InteractHandEvent args) { DoAnomalyBurnDamage(uid, args.User, component); diff --git a/Content.Shared/BarSign/BarSignComponent.cs b/Content.Shared/BarSign/BarSignComponent.cs index 182597ba2e..d50726216e 100644 --- a/Content.Shared/BarSign/BarSignComponent.cs +++ b/Content.Shared/BarSign/BarSignComponent.cs @@ -1,24 +1,10 @@ using Robust.Shared.GameStates; -using Robust.Shared.Serialization; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; +using Robust.Shared.Prototypes; -namespace Content.Shared.BarSign +namespace Content.Shared.BarSign; + +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] +public sealed partial class BarSignComponent : Component { - [RegisterComponent, NetworkedComponent] - public sealed partial class BarSignComponent : Component - { - [DataField("current", customTypeSerializer:typeof(PrototypeIdSerializer))] - public string? CurrentSign; - } - - [Serializable, NetSerializable] - public sealed class BarSignComponentState : ComponentState - { - public string? CurrentSign; - - public BarSignComponentState(string? current) - { - CurrentSign = current; - } - } + [DataField, AutoNetworkedField] public ProtoId? Current; } diff --git a/Content.Shared/Body/Components/BodyComponent.cs b/Content.Shared/Body/Components/BodyComponent.cs index a93f1e2fd8..481e22150b 100644 --- a/Content.Shared/Body/Components/BodyComponent.cs +++ b/Content.Shared/Body/Components/BodyComponent.cs @@ -4,18 +4,17 @@ using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; -using Robust.Shared.Serialization; namespace Content.Shared.Body.Components; -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] [Access(typeof(SharedBodySystem))] public sealed partial class BodyComponent : Component { /// /// Relevant template to spawn for this body. /// - [DataField] + [DataField, AutoNetworkedField] public ProtoId? Prototype; /// @@ -29,35 +28,17 @@ public sealed partial class BodyComponent : Component [ViewVariables] public string RootPartSlot => RootContainer.ID; - [DataField] public SoundSpecifier GibSound = new SoundCollectionSpecifier("gib"); + [DataField, AutoNetworkedField] + public SoundSpecifier GibSound = new SoundCollectionSpecifier("gib"); /// /// The amount of legs required to move at full speed. /// If 0, then legs do not impact speed. /// - [DataField] public int RequiredLegs; + [DataField, AutoNetworkedField] + public int RequiredLegs; [ViewVariables] - [DataField] + [DataField, AutoNetworkedField] public HashSet LegEntities = new(); } - -[Serializable, NetSerializable] -public sealed class BodyComponentState : ComponentState -{ - public string? Prototype; - public string? RootPartSlot; - public SoundSpecifier GibSound; - public int RequiredLegs; - public HashSet LegNetEntities; - - public BodyComponentState(string? prototype, string? rootPartSlot, SoundSpecifier gibSound, - int requiredLegs, HashSet legNetEntities) - { - Prototype = prototype; - RootPartSlot = rootPartSlot; - GibSound = gibSound; - RequiredLegs = requiredLegs; - LegNetEntities = legNetEntities; - } -} diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Body.cs b/Content.Shared/Body/Systems/SharedBodySystem.Body.cs index 9356224f41..072826f08b 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Body.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Body.cs @@ -6,9 +6,7 @@ using Content.Shared.Body.Part; using Content.Shared.Body.Prototypes; using Content.Shared.DragDrop; using Robust.Shared.Containers; -using Robust.Shared.GameStates; using Robust.Shared.Map; -using MapInitEvent = Robust.Shared.GameObjects.MapInitEvent; namespace Content.Shared.Body.Systems; @@ -30,8 +28,6 @@ public partial class SharedBodySystem SubscribeLocalEvent(OnBodyInit); SubscribeLocalEvent(OnBodyMapInit); SubscribeLocalEvent(OnBodyCanDrag); - SubscribeLocalEvent(OnBodyGetState); - SubscribeLocalEvent(OnBodyHandleState); } private void OnBodyInserted(EntityUid uid, BodyComponent component, EntInsertedIntoContainerMessage args) @@ -82,28 +78,6 @@ public partial class SharedBodySystem } } - private void OnBodyHandleState(EntityUid uid, BodyComponent component, ref ComponentHandleState args) - { - if (args.Current is not BodyComponentState state) - return; - - component.Prototype = state.Prototype != null ? state.Prototype : null!; - component.GibSound = state.GibSound; - component.RequiredLegs = state.RequiredLegs; - component.LegEntities = EntityManager.EnsureEntitySet(state.LegNetEntities, uid); - } - - private void OnBodyGetState(EntityUid uid, BodyComponent component, ref ComponentGetState args) - { - args.State = new BodyComponentState( - component.Prototype, - component.RootPartSlot, - component.GibSound, - component.RequiredLegs, - EntityManager.GetNetEntitySet(component.LegEntities) - ); - } - private void OnBodyInit(EntityUid bodyId, BodyComponent body, ComponentInit args) { // Setup the initial container. diff --git a/Content.Shared/Buckle/Components/BuckleComponent.cs b/Content.Shared/Buckle/Components/BuckleComponent.cs index 8f44c7fead..cf28b56d51 100644 --- a/Content.Shared/Buckle/Components/BuckleComponent.cs +++ b/Content.Shared/Buckle/Components/BuckleComponent.cs @@ -4,7 +4,7 @@ using Robust.Shared.Serialization; namespace Content.Shared.Buckle.Components; -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] [Access(typeof(SharedBuckleSystem))] public sealed partial class BuckleComponent : Component { @@ -13,7 +13,7 @@ public sealed partial class BuckleComponent : Component /// Separated from normal interaction range to fix the "someone buckled to a strap /// across a table two tiles away" problem. /// - [DataField("range")] + [DataField] [ViewVariables(VVAccess.ReadWrite)] public float Range = SharedInteractionSystem.InteractionRange / 1.4f; @@ -21,32 +21,34 @@ public sealed partial class BuckleComponent : Component /// True if the entity is buckled, false otherwise. /// [ViewVariables(VVAccess.ReadWrite)] + [AutoNetworkedField] public bool Buckled; [ViewVariables] + [AutoNetworkedField] public EntityUid? LastEntityBuckledTo; /// /// Whether or not collisions should be possible with the entity we are strapped to /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("dontCollide")] + [DataField, AutoNetworkedField] public bool DontCollide; /// /// Whether or not we should be allowed to pull the entity we are strapped to /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("pullStrap")] + [DataField] public bool PullStrap; /// /// The amount of time that must pass for this entity to /// be able to unbuckle after recently buckling. /// - [DataField("delay")] + [DataField] [ViewVariables(VVAccess.ReadWrite)] - public TimeSpan UnbuckleDelay = TimeSpan.FromSeconds(0.25f); + public TimeSpan Delay = TimeSpan.FromSeconds(0.25f); /// /// The time that this entity buckled at. @@ -58,39 +60,21 @@ public sealed partial class BuckleComponent : Component /// The strap that this component is buckled to. /// [ViewVariables] + [AutoNetworkedField] public EntityUid? BuckledTo; /// /// The amount of space that this entity occupies in a /// . /// - [DataField("size")] + [DataField] [ViewVariables(VVAccess.ReadWrite)] public int Size = 100; /// /// Used for client rendering /// - [ViewVariables] - public int? OriginalDrawDepth; -} - -[Serializable, NetSerializable] -public sealed class BuckleComponentState : ComponentState -{ - public BuckleComponentState(bool buckled, NetEntity? buckledTo, NetEntity? lastEntityBuckledTo, - bool dontCollide) - { - Buckled = buckled; - BuckledTo = buckledTo; - LastEntityBuckledTo = lastEntityBuckledTo; - DontCollide = dontCollide; - } - - public readonly bool Buckled; - public readonly NetEntity? BuckledTo; - public readonly NetEntity? LastEntityBuckledTo; - public readonly bool DontCollide; + [ViewVariables] public int? OriginalDrawDepth; } [ByRefEvent] diff --git a/Content.Shared/Buckle/Components/StrapComponent.cs b/Content.Shared/Buckle/Components/StrapComponent.cs index 8cb11ddd43..4efe154797 100644 --- a/Content.Shared/Buckle/Components/StrapComponent.cs +++ b/Content.Shared/Buckle/Components/StrapComponent.cs @@ -8,28 +8,29 @@ using Robust.Shared.Serialization; namespace Content.Shared.Buckle.Components; -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] [Access(typeof(SharedBuckleSystem), typeof(SharedVehicleSystem))] public sealed partial class StrapComponent : Component { /// /// The entities that are currently buckled /// + [AutoNetworkedField(true)] [ViewVariables] // TODO serialization - public readonly HashSet BuckledEntities = new(); + public HashSet BuckledEntities = new(); /// /// Entities that this strap accepts and can buckle /// If null it accepts any entity /// - [DataField("allowedEntities")] + [DataField] [ViewVariables] public EntityWhitelist? AllowedEntities; /// /// The change in position to the strapped mob /// - [DataField("position")] + [DataField, AutoNetworkedField] [ViewVariables(VVAccess.ReadWrite)] public StrapPosition Position = StrapPosition.None; @@ -43,7 +44,7 @@ public sealed partial class StrapComponent : Component /// whereas the server doesnt, thus the client tries to unbuckle like 15 times because it passes the strap null check /// This is why this needs to be above 0.1 to make the InRange check fail in both client and server. /// - [DataField("maxBuckleDistance", required: false)] + [DataField, AutoNetworkedField] [ViewVariables(VVAccess.ReadWrite)] public float MaxBuckleDistance = 0.2f; @@ -51,8 +52,8 @@ public sealed partial class StrapComponent : Component /// Gets and clamps the buckle offset to MaxBuckleDistance /// [ViewVariables] - public Vector2 BuckleOffset => Vector2.Clamp( - BuckleOffsetUnclamped, + public Vector2 BuckleOffsetClamped => Vector2.Clamp( + BuckleOffset, Vector2.One * -MaxBuckleDistance, Vector2.One * MaxBuckleDistance); @@ -60,21 +61,21 @@ public sealed partial class StrapComponent : Component /// The buckled entity will be offset by this amount from the center of the strap object. /// If this offset it too big, it will be clamped to /// - [DataField("buckleOffset", required: false)] + [DataField, AutoNetworkedField] [ViewVariables(VVAccess.ReadWrite)] - public Vector2 BuckleOffsetUnclamped = Vector2.Zero; + public Vector2 BuckleOffset = Vector2.Zero; /// /// The angle in degrees to rotate the player by when they get strapped /// - [DataField("rotation")] + [DataField] [ViewVariables(VVAccess.ReadWrite)] public int Rotation; /// /// The size of the strap which is compared against when buckling entities /// - [DataField("size")] + [DataField] [ViewVariables(VVAccess.ReadWrite)] public int Size = 100; @@ -87,58 +88,39 @@ public sealed partial class StrapComponent : Component /// /// You can specify the offset the entity will have after unbuckling. /// - [DataField("unbuckleOffset", required: false)] + [DataField] [ViewVariables(VVAccess.ReadWrite)] public Vector2 UnbuckleOffset = Vector2.Zero; /// /// The sound to be played when a mob is buckled /// - [DataField("buckleSound")] + [DataField] [ViewVariables(VVAccess.ReadWrite)] public SoundSpecifier BuckleSound = new SoundPathSpecifier("/Audio/Effects/buckle.ogg"); /// /// The sound to be played when a mob is unbuckled /// - [DataField("unbuckleSound")] + [DataField] [ViewVariables(VVAccess.ReadWrite)] public SoundSpecifier UnbuckleSound = new SoundPathSpecifier("/Audio/Effects/unbuckle.ogg"); /// /// ID of the alert to show when buckled /// - [DataField("buckledAlertType")] + [DataField] [ViewVariables(VVAccess.ReadWrite)] public AlertType BuckledAlertType = AlertType.Buckled; /// /// The sum of the sizes of all the buckled entities in this strap /// + [AutoNetworkedField] [ViewVariables] public int OccupiedSize; } -[Serializable, NetSerializable] -public sealed class StrapComponentState : ComponentState -{ - public readonly StrapPosition Position; - public readonly float MaxBuckleDistance; - public readonly Vector2 BuckleOffsetClamped; - public readonly HashSet BuckledEntities; - public readonly int OccupiedSize; - - public StrapComponentState(StrapPosition position, Vector2 offset, HashSet buckled, - float maxBuckleDistance, int occupiedSize) - { - Position = position; - BuckleOffsetClamped = offset; - BuckledEntities = buckled; - MaxBuckleDistance = maxBuckleDistance; - OccupiedSize = occupiedSize; - } -} - public enum StrapPosition { /// diff --git a/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs b/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs index 3fb77df97d..020b47f708 100644 --- a/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs +++ b/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs @@ -12,14 +12,12 @@ using Content.Shared.Mobs.Components; using Content.Shared.Movement.Events; using Content.Shared.Popups; using Content.Shared.Pulling.Components; -using Content.Shared.Pulling.Events; using Content.Shared.Standing; using Content.Shared.Storage.Components; using Content.Shared.Stunnable; using Content.Shared.Throwing; using Content.Shared.Vehicle.Components; using Content.Shared.Verbs; -using Robust.Shared.GameStates; using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Events; using Robust.Shared.Utility; @@ -32,7 +30,6 @@ public abstract partial class SharedBuckleSystem { SubscribeLocalEvent(OnBuckleComponentStartup); SubscribeLocalEvent(OnBuckleComponentShutdown); - SubscribeLocalEvent(OnBuckleComponentGetState); SubscribeLocalEvent(OnBuckleMove); SubscribeLocalEvent(OnBuckleInteractHand); SubscribeLocalEvent>(AddUnbuckleVerb); @@ -58,11 +55,6 @@ public abstract partial class SharedBuckleSystem component.BuckleTime = default; } - private void OnBuckleComponentGetState(EntityUid uid, BuckleComponent component, ref ComponentGetState args) - { - args.State = new BuckleComponentState(component.Buckled, GetNetEntity(component.BuckledTo), GetNetEntity(component.LastEntityBuckledTo), component.DontCollide); - } - private void OnBuckleMove(EntityUid uid, BuckleComponent component, ref MoveEvent ev) { if (component.BuckledTo is not {} strapUid) @@ -434,7 +426,7 @@ public abstract partial class SharedBuckleSystem if (attemptEvent.Cancelled) return false; - if (_gameTiming.CurTime < buckleComp.BuckleTime + buckleComp.UnbuckleDelay) + if (_gameTiming.CurTime < buckleComp.BuckleTime + buckleComp.Delay) return false; if (!_interaction.InRangeUnobstructed(userUid, strapUid, buckleComp.Range, popup: true)) diff --git a/Content.Shared/Buckle/SharedBuckleSystem.Strap.cs b/Content.Shared/Buckle/SharedBuckleSystem.Strap.cs index 7ffbfd3a42..8616546480 100644 --- a/Content.Shared/Buckle/SharedBuckleSystem.Strap.cs +++ b/Content.Shared/Buckle/SharedBuckleSystem.Strap.cs @@ -7,7 +7,6 @@ using Content.Shared.Interaction; using Content.Shared.Storage; using Content.Shared.Verbs; using Robust.Shared.Containers; -using Robust.Shared.GameStates; namespace Content.Shared.Buckle; @@ -19,9 +18,6 @@ public abstract partial class SharedBuckleSystem SubscribeLocalEvent(OnStrapShutdown); SubscribeLocalEvent((_, c, _) => StrapRemoveAll(c)); - SubscribeLocalEvent(OnStrapGetState); - SubscribeLocalEvent(OnStrapHandleState); - SubscribeLocalEvent(OnStrapEntModifiedFromContainer); SubscribeLocalEvent(OnStrapEntModifiedFromContainer); SubscribeLocalEvent>(AddStrapVerbs); @@ -50,24 +46,6 @@ public abstract partial class SharedBuckleSystem StrapRemoveAll(component); } - private void OnStrapGetState(EntityUid uid, StrapComponent component, ref ComponentGetState args) - { - 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) - { - if (args.Current is not StrapComponentState state) - return; - - component.Position = state.Position; - component.BuckleOffsetUnclamped = state.BuckleOffsetClamped; - component.BuckledEntities.Clear(); - component.BuckledEntities.UnionWith(EnsureEntitySet(state.BuckledEntities, uid)); - component.MaxBuckleDistance = state.MaxBuckleDistance; - component.OccupiedSize = state.OccupiedSize; - } - private void OnStrapEntModifiedFromContainer(EntityUid uid, StrapComponent component, ContainerModifiedMessage message) { if (_gameTiming.ApplyingState) diff --git a/Content.Shared/Buckle/SharedBuckleSystem.cs b/Content.Shared/Buckle/SharedBuckleSystem.cs index 3c9cb1f974..81d479ca34 100644 --- a/Content.Shared/Buckle/SharedBuckleSystem.cs +++ b/Content.Shared/Buckle/SharedBuckleSystem.cs @@ -65,7 +65,7 @@ public abstract partial class SharedBuckleSystem : EntitySystem || !Resolve(buckleUid, ref buckleComp, false)) return; - _transform.SetCoordinates(buckleUid, new EntityCoordinates(strapUid, strapComp.BuckleOffset)); + _transform.SetCoordinates(buckleUid, new EntityCoordinates(strapUid, strapComp.BuckleOffsetClamped)); var buckleTransform = Transform(buckleUid); diff --git a/Content.Shared/Cabinet/ItemCabinetComponent.cs b/Content.Shared/Cabinet/ItemCabinetComponent.cs index 4f49badfa9..71367e8de6 100644 --- a/Content.Shared/Cabinet/ItemCabinetComponent.cs +++ b/Content.Shared/Cabinet/ItemCabinetComponent.cs @@ -1,65 +1,43 @@ using Content.Shared.Containers.ItemSlots; using Robust.Shared.Audio; using Robust.Shared.GameStates; -using Robust.Shared.Serialization; namespace Content.Shared.Cabinet; /// /// Used for entities that can be opened, closed, and can hold one item. E.g., fire extinguisher cabinets. /// -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class ItemCabinetComponent : Component { /// /// Sound to be played when the cabinet door is opened. /// - [DataField("doorSound"), ViewVariables(VVAccess.ReadWrite)] + [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)] public SoundSpecifier? DoorSound; /// /// The that stores the actual item. The entity whitelist, sounds, and other /// behaviours are specified by this definition. /// - [DataField("cabinetSlot"), ViewVariables] + [DataField, ViewVariables] public ItemSlot CabinetSlot = new(); /// /// Whether the cabinet is currently open or not. /// - [DataField("opened")] + [DataField, AutoNetworkedField] public bool Opened; /// /// The state for when the cabinet is open /// - [DataField("openState"), ViewVariables(VVAccess.ReadWrite)] + [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)] public string? OpenState; /// /// The state for when the cabinet is closed /// - [DataField("closedState"), ViewVariables(VVAccess.ReadWrite)] + [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)] public string? ClosedState; } - -[Serializable, NetSerializable] -public sealed class ItemCabinetComponentState : ComponentState -{ - public SoundSpecifier? DoorSound; - - public bool Opened; - - public string? OpenState; - - public string? ClosedState; - - public ItemCabinetComponentState(SoundSpecifier? doorSound, bool opened, string? openState, string? closedState) - { - DoorSound = doorSound; - Opened = opened; - OpenState = openState; - ClosedState = closedState; - } -} - diff --git a/Content.Shared/Cabinet/SharedItemCabinetSystem.cs b/Content.Shared/Cabinet/SharedItemCabinetSystem.cs index 96461f2249..f2f03c1334 100644 --- a/Content.Shared/Cabinet/SharedItemCabinetSystem.cs +++ b/Content.Shared/Cabinet/SharedItemCabinetSystem.cs @@ -4,7 +4,6 @@ using Content.Shared.Lock; using Content.Shared.Verbs; using Robust.Shared.Audio; using Robust.Shared.Containers; -using Robust.Shared.GameStates; using Robust.Shared.Timing; using Robust.Shared.Utility; @@ -19,9 +18,6 @@ public abstract class SharedItemCabinetSystem : EntitySystem /// public override void Initialize() { - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); - SubscribeLocalEvent(OnComponentInit); SubscribeLocalEvent(OnComponentRemove); SubscribeLocalEvent(OnComponentStartup); @@ -35,24 +31,6 @@ public abstract class SharedItemCabinetSystem : EntitySystem SubscribeLocalEvent(OnLockToggleAttempt); } - private void OnGetState(EntityUid uid, ItemCabinetComponent component, ref ComponentGetState args) - { - args.State = new ItemCabinetComponentState(component.DoorSound, - component.Opened, - component.OpenState, - component.ClosedState); - } - - private void OnHandleState(EntityUid uid, ItemCabinetComponent component, ref ComponentHandleState args) - { - if (args.Current is not ItemCabinetComponentState state) - return; - component.DoorSound = state.DoorSound; - component.Opened = state.Opened; - component.OpenState = state.OpenState; - component.ClosedState = state.ClosedState; - } - private void OnComponentInit(EntityUid uid, ItemCabinetComponent cabinet, ComponentInit args) { _itemSlots.AddItemSlot(uid, "ItemCabinet", cabinet.CabinetSlot); diff --git a/Content.Shared/CartridgeLoader/CartridgeComponent.cs b/Content.Shared/CartridgeLoader/CartridgeComponent.cs index 775cc33d81..ba7e6fe2d5 100644 --- a/Content.Shared/CartridgeLoader/CartridgeComponent.cs +++ b/Content.Shared/CartridgeLoader/CartridgeComponent.cs @@ -7,25 +7,19 @@ namespace Content.Shared.CartridgeLoader; /// /// This is used for defining values used for displaying in the program ui in yaml /// -[NetworkedComponent] -[RegisterComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class CartridgeComponent : Component { - [DataField("programName", required: true)] + [DataField(required: true)] public string ProgramName = "default-program-name"; - [DataField("icon")] + [DataField] public SpriteSpecifier? Icon; + [AutoNetworkedField] public InstallationStatus InstallationStatus = InstallationStatus.Cartridge; } -[Serializable, NetSerializable] -public sealed class CartridgeComponentState : ComponentState -{ - public InstallationStatus InstallationStatus; -} - [Serializable, NetSerializable] public enum InstallationStatus { diff --git a/Content.Shared/CartridgeLoader/SharedCartridgeLoaderSystem.cs b/Content.Shared/CartridgeLoader/SharedCartridgeLoaderSystem.cs index 15d29689b8..806723de1e 100644 --- a/Content.Shared/CartridgeLoader/SharedCartridgeLoaderSystem.cs +++ b/Content.Shared/CartridgeLoader/SharedCartridgeLoaderSystem.cs @@ -1,7 +1,5 @@ using Content.Shared.Containers.ItemSlots; using Robust.Shared.Containers; -using Robust.Shared.GameStates; -using Robust.Shared.Map; using Robust.Shared.Network; namespace Content.Shared.CartridgeLoader; @@ -24,10 +22,6 @@ public abstract class SharedCartridgeLoaderSystem : EntitySystem SubscribeLocalEvent(OnItemInserted); SubscribeLocalEvent(OnItemRemoved); - - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); - } private void OnComponentInit(EntityUid uid, CartridgeLoaderComponent loader, ComponentInit args) @@ -55,22 +49,6 @@ public abstract class SharedCartridgeLoaderSystem : EntitySystem UpdateAppearanceData(uid, loader); } - private void OnGetState(EntityUid uid, CartridgeComponent component, ref ComponentGetState args) - { - var state = new CartridgeComponentState(); - state.InstallationStatus = component.InstallationStatus; - - args.State = state; - } - - private void OnHandleState(EntityUid uid, CartridgeComponent component, ref ComponentHandleState args) - { - if (args.Current is not CartridgeComponentState state) - return; - - component.InstallationStatus = state.InstallationStatus; - } - private void UpdateAppearanceData(EntityUid uid, CartridgeLoaderComponent loader) { _appearanceSystem.SetData(uid, CartridgeLoaderVisuals.CartridgeInserted, loader.CartridgeSlot.HasItem); diff --git a/Content.Shared/Chemistry/Components/MovespeedModifierMetabolismComponent.cs b/Content.Shared/Chemistry/Components/MovespeedModifierMetabolismComponent.cs index f0a0c22ba5..62127ab533 100644 --- a/Content.Shared/Chemistry/Components/MovespeedModifierMetabolismComponent.cs +++ b/Content.Shared/Chemistry/Components/MovespeedModifierMetabolismComponent.cs @@ -1,39 +1,22 @@ -using Robust.Shared.Serialization; using Robust.Shared.GameStates; namespace Content.Shared.Chemistry.Components { //TODO: refactor movement modifier component because this is a pretty poor solution - [RegisterComponent] - [NetworkedComponent] + [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class MovespeedModifierMetabolismComponent : Component { - [ViewVariables] + [AutoNetworkedField, ViewVariables] public float WalkSpeedModifier { get; set; } - [ViewVariables] + [AutoNetworkedField, ViewVariables] public float SprintSpeedModifier { get; set; } /// /// When the current modifier is expected to end. /// - [ViewVariables] + [AutoNetworkedField, ViewVariables] public TimeSpan ModifierTimer { get; set; } = TimeSpan.Zero; - - [Serializable, NetSerializable] - public sealed class MovespeedModifierMetabolismComponentState : ComponentState - { - public float WalkSpeedModifier { get; } - public float SprintSpeedModifier { get; } - public TimeSpan ModifierTimer { get; } - - public MovespeedModifierMetabolismComponentState(float walkSpeedModifier, float sprintSpeedModifier, TimeSpan modifierTimer) - { - WalkSpeedModifier = walkSpeedModifier; - SprintSpeedModifier = sprintSpeedModifier; - ModifierTimer = modifierTimer; - } - } } } diff --git a/Content.Shared/Chemistry/MetabolismMovespeedModifierSystem.cs b/Content.Shared/Chemistry/MetabolismMovespeedModifierSystem.cs index cfa7446caa..6b7c75514f 100644 --- a/Content.Shared/Chemistry/MetabolismMovespeedModifierSystem.cs +++ b/Content.Shared/Chemistry/MetabolismMovespeedModifierSystem.cs @@ -1,9 +1,6 @@ using Content.Shared.Chemistry.Components; -using Robust.Shared.GameStates; -using Robust.Shared.Timing; -using Content.Shared.Movement.Components; using Content.Shared.Movement.Systems; -using static Content.Shared.Chemistry.Components.MovespeedModifierMetabolismComponent; +using Robust.Shared.Timing; namespace Content.Shared.Chemistry { @@ -21,30 +18,10 @@ namespace Content.Shared.Chemistry UpdatesOutsidePrediction = true; - SubscribeLocalEvent(OnMovespeedHandleState); - SubscribeLocalEvent(OnGetState); SubscribeLocalEvent(AddComponent); SubscribeLocalEvent(OnRefreshMovespeed); } - private void OnGetState(EntityUid uid, MovespeedModifierMetabolismComponent component, ref ComponentGetState args) - { - args.State = new MovespeedModifierMetabolismComponentState( - component.WalkSpeedModifier, - component.SprintSpeedModifier, - component.ModifierTimer); - } - - private void OnMovespeedHandleState(EntityUid uid, MovespeedModifierMetabolismComponent component, ref ComponentHandleState args) - { - if (args.Current is not MovespeedModifierMetabolismComponentState cast) - return; - - component.WalkSpeedModifier = cast.WalkSpeedModifier; - component.SprintSpeedModifier = cast.SprintSpeedModifier; - component.ModifierTimer = cast.ModifierTimer; - } - private void OnRefreshMovespeed(EntityUid uid, MovespeedModifierMetabolismComponent component, RefreshMovementSpeedModifiersEvent args) { args.ModifySpeed(component.WalkSpeedModifier, component.SprintSpeedModifier); diff --git a/Content.Shared/Climbing/ClimbingComponent.cs b/Content.Shared/Climbing/ClimbingComponent.cs index 40e192d8ef..cd443af6aa 100644 --- a/Content.Shared/Climbing/ClimbingComponent.cs +++ b/Content.Shared/Climbing/ClimbingComponent.cs @@ -1,21 +1,20 @@ using Robust.Shared.GameStates; -using Robust.Shared.Serialization; namespace Content.Shared.Climbing; -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class ClimbingComponent : Component { /// /// Whether the owner is climbing on a climbable entity. /// - [ViewVariables] + [ViewVariables, AutoNetworkedField] public bool IsClimbing { get; set; } /// /// Whether the owner is being moved onto the climbed entity. /// - [ViewVariables] + [ViewVariables, AutoNetworkedField] public bool OwnerIsTransitioning { get; set; } /// @@ -25,17 +24,4 @@ public sealed partial class ClimbingComponent : Component [ViewVariables] public Dictionary DisabledFixtureMasks { get; } = new(); - - [Serializable, NetSerializable] - public sealed class ClimbModeComponentState : ComponentState - { - public ClimbModeComponentState(bool climbing, bool isTransitioning) - { - Climbing = climbing; - IsTransitioning = isTransitioning; - } - - public bool Climbing { get; } - public bool IsTransitioning { get; } - } } diff --git a/Content.Shared/Clothing/Components/ChameleonClothingComponent.cs b/Content.Shared/Clothing/Components/ChameleonClothingComponent.cs index d2f2138670..def4254304 100644 --- a/Content.Shared/Clothing/Components/ChameleonClothingComponent.cs +++ b/Content.Shared/Clothing/Components/ChameleonClothingComponent.cs @@ -3,14 +3,13 @@ using Content.Shared.Inventory; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; namespace Content.Shared.Clothing.Components; /// /// Allow players to change clothing sprite to any other clothing prototype. /// -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] [Access(typeof(SharedChameleonClothingSystem))] public sealed partial class ChameleonClothingComponent : Component { @@ -18,15 +17,15 @@ public sealed partial class ChameleonClothingComponent : Component /// Filter possible chameleon options by their slot flag. /// [ViewVariables(VVAccess.ReadOnly)] - [DataField("slot", required: true)] + [DataField(required: true)] public SlotFlags Slot; /// /// EntityPrototype id that chameleon item is trying to mimic. /// [ViewVariables(VVAccess.ReadOnly)] - [DataField("default", required: true, customTypeSerializer: typeof(PrototypeIdSerializer))] - public string? SelectedId; + [DataField(required: true), AutoNetworkedField] + public EntProtoId? Default; /// /// Current user that wears chameleon clothing. @@ -35,12 +34,6 @@ public sealed partial class ChameleonClothingComponent : Component public EntityUid? User; } -[Serializable, NetSerializable] -public sealed class ChameleonClothingComponentState : ComponentState -{ - public string? SelectedId; -} - [Serializable, NetSerializable] public sealed class ChameleonBoundUserInterfaceState : BoundUserInterfaceState { diff --git a/Content.Shared/Clothing/EntitySystems/SharedChameleonClothingSystem.cs b/Content.Shared/Clothing/EntitySystems/SharedChameleonClothingSystem.cs index 34b48bc292..beac22270c 100644 --- a/Content.Shared/Clothing/EntitySystems/SharedChameleonClothingSystem.cs +++ b/Content.Shared/Clothing/EntitySystems/SharedChameleonClothingSystem.cs @@ -38,8 +38,8 @@ public abstract class SharedChameleonClothingSystem : EntitySystem // This 100% makes sure that server and client have exactly same data. protected void UpdateVisuals(EntityUid uid, ChameleonClothingComponent component) { - if (string.IsNullOrEmpty(component.SelectedId) || - !_proto.TryIndex(component.SelectedId, out EntityPrototype? proto)) + if (string.IsNullOrEmpty(component.Default) || + !_proto.TryIndex(component.Default, out EntityPrototype? proto)) return; // world sprite icon diff --git a/Content.Shared/Conveyor/ConveyorComponent.cs b/Content.Shared/Conveyor/ConveyorComponent.cs index 2af859b4a1..6c95d68c98 100644 --- a/Content.Shared/Conveyor/ConveyorComponent.cs +++ b/Content.Shared/Conveyor/ConveyorComponent.cs @@ -1,66 +1,49 @@ using Content.Shared.DeviceLinking; using Robust.Shared.GameStates; +using Robust.Shared.Prototypes; using Robust.Shared.Serialization; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; namespace Content.Shared.Conveyor; -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class ConveyorComponent : Component { /// /// The angle to move entities by in relation to the owner's rotation. /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("angle")] + [DataField, AutoNetworkedField] public Angle Angle = Angle.Zero; /// /// The amount of units to move the entity by per second. /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("speed")] + [DataField, AutoNetworkedField] public float Speed = 2f; /// /// The current state of this conveyor /// - [ViewVariables(VVAccess.ReadWrite)] + [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public ConveyorState State; - [ViewVariables] + [ViewVariables, AutoNetworkedField] public bool Powered; - [DataField("forwardPort", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string ForwardPort = "Forward"; + [DataField] + public ProtoId ForwardPort = "Forward"; - [DataField("reversePort", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string ReversePort = "Reverse"; + [DataField] + public ProtoId ReversePort = "Reverse"; - [DataField("offPort", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string OffPort = "Off"; + [DataField] + public ProtoId OffPort = "Off"; [ViewVariables] public readonly HashSet Intersecting = new(); } -[Serializable, NetSerializable] -public sealed class ConveyorComponentState : ComponentState -{ - public bool Powered; - public Angle Angle; - public float Speed; - public ConveyorState State; - - public ConveyorComponentState(Angle angle, float speed, ConveyorState state, bool powered) - { - Angle = angle; - Speed = speed; - State = state; - Powered = powered; - } -} - [Serializable, NetSerializable] public enum ConveyorVisuals : byte { diff --git a/Content.Shared/Cuffs/Components/HandcuffComponent.cs b/Content.Shared/Cuffs/Components/HandcuffComponent.cs index da44ee01ff..b43bf18bf8 100644 --- a/Content.Shared/Cuffs/Components/HandcuffComponent.cs +++ b/Content.Shared/Cuffs/Components/HandcuffComponent.cs @@ -2,53 +2,50 @@ using Content.Shared.Damage; using Robust.Shared.Audio; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; -using Robust.Shared.Serialization; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; -using Robust.Shared.Utility; namespace Content.Shared.Cuffs.Components; -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] [Access(typeof(SharedCuffableSystem))] public sealed partial class HandcuffComponent : Component { /// /// The time it takes to cuff an entity. /// - [DataField("cuffTime"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public float CuffTime = 3.5f; /// /// The time it takes to uncuff an entity. /// - [DataField("uncuffTime"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public float UncuffTime = 3.5f; /// /// The time it takes for a cuffed entity to uncuff itself. /// - [DataField("breakoutTime"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public float BreakoutTime = 30f; /// /// If an entity being cuffed is stunned, this amount of time is subtracted from the time it takes to add/remove their cuffs. /// - [DataField("stunBonus"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public float StunBonus = 2f; /// /// Will the cuffs break when removed? /// - [DataField("breakOnRemove"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public bool BreakOnRemove; /// /// Will the cuffs break when removed? /// - [DataField("brokenPrototype", customTypeSerializer: typeof(PrototypeIdSerializer)), ViewVariables(VVAccess.ReadWrite)] - public string? BrokenPrototype; + [DataField, ViewVariables(VVAccess.ReadWrite)] + public EntProtoId? BrokenPrototype; - [DataField("damageOnResist"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public DamageSpecifier DamageOnResist = new() { DamageDict = new() @@ -60,48 +57,37 @@ public sealed partial class HandcuffComponent : Component /// /// The path of the RSI file used for the player cuffed overlay. /// - [DataField("cuffedRSI"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public string? CuffedRSI = "Objects/Misc/handcuffs.rsi"; /// /// The iconstate used with the RSI file for the player cuffed overlay. /// - [DataField("bodyIconState"), ViewVariables(VVAccess.ReadWrite)] - public string? OverlayIconState = "body-overlay"; + [DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] + public string? BodyIconState = "body-overlay"; /// - /// An opptional color specification for + /// An opptional color specification for /// - [DataField("color"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public Color Color = Color.White; - [DataField("startCuffSound"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public SoundSpecifier StartCuffSound = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_start.ogg"); - [DataField("endCuffSound"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public SoundSpecifier EndCuffSound = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_end.ogg"); - [DataField("startBreakoutSound"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public SoundSpecifier StartBreakoutSound = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_breakout_start.ogg"); - [DataField("startUncuffSound"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public SoundSpecifier StartUncuffSound = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_takeoff_start.ogg"); - [DataField("endUncuffSound"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public SoundSpecifier EndUncuffSound = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_takeoff_end.ogg"); } -[Serializable, NetSerializable] -public sealed class HandcuffComponentState : ComponentState -{ - public readonly string? IconState; - - public HandcuffComponentState(string? iconState) - { - IconState = iconState; - } -} - /// /// Event fired on the User when the User attempts to cuff the Target. /// Should generate popups on the User. diff --git a/Content.Shared/Damage/Components/StaminaComponent.cs b/Content.Shared/Damage/Components/StaminaComponent.cs index 3cdc90ecb1..74e0f6c852 100644 --- a/Content.Shared/Damage/Components/StaminaComponent.cs +++ b/Content.Shared/Damage/Components/StaminaComponent.cs @@ -6,48 +6,48 @@ namespace Content.Shared.Damage.Components; /// /// Add to an entity to paralyze it whenever it reaches critical amounts of Stamina DamageType. /// -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] public sealed partial class StaminaComponent : Component { /// /// Have we reached peak stamina damage and been paralyzed? /// - [ViewVariables(VVAccess.ReadWrite), DataField("critical")] + [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] public bool Critical; /// /// How much stamina reduces per second. /// - [ViewVariables(VVAccess.ReadWrite), DataField("decay")] + [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] public float Decay = 3f; /// /// How much time after receiving damage until stamina starts decreasing. /// - [ViewVariables(VVAccess.ReadWrite), DataField("cooldown")] - public float DecayCooldown = 3f; + [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] + public float Cooldown = 3f; /// /// How much stamina damage this entity has taken. /// - [ViewVariables(VVAccess.ReadWrite), DataField("staminaDamage")] + [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] public float StaminaDamage; /// /// How much stamina damage is required to entire stam crit. /// - [ViewVariables(VVAccess.ReadWrite), DataField("critThreshold")] + [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] public float CritThreshold = 100f; /// /// How long will this mob be stunned for? /// - [ViewVariables(VVAccess.ReadWrite), DataField("stunTime")] + [ViewVariables(VVAccess.ReadWrite), DataField] public TimeSpan StunTime = TimeSpan.FromSeconds(6); /// /// To avoid continuously updating our data we track the last time we updated so we can extrapolate our current stamina. /// - [DataField("nextUpdate", customTypeSerializer:typeof(TimeOffsetSerializer))] + [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField] public TimeSpan NextUpdate = TimeSpan.Zero; } diff --git a/Content.Shared/Damage/Systems/StaminaSystem.cs b/Content.Shared/Damage/Systems/StaminaSystem.cs index 7bf2941dac..40c4f7eb8f 100644 --- a/Content.Shared/Damage/Systems/StaminaSystem.cs +++ b/Content.Shared/Damage/Systems/StaminaSystem.cs @@ -16,11 +16,9 @@ using Content.Shared.Throwing; using Content.Shared.Weapons.Melee.Events; using JetBrains.Annotations; using Robust.Shared.Audio; -using Robust.Shared.GameStates; using Robust.Shared.Network; using Robust.Shared.Player; using Robust.Shared.Random; -using Robust.Shared.Serialization; using Robust.Shared.Timing; namespace Content.Shared.Damage.Systems; @@ -52,8 +50,7 @@ public sealed partial class StaminaSystem : EntitySystem SubscribeLocalEvent(OnStamUnpaused); SubscribeLocalEvent(OnStartup); SubscribeLocalEvent(OnShutdown); - SubscribeLocalEvent(OnStamGetState); - SubscribeLocalEvent(OnStamHandleState); + SubscribeLocalEvent(OnStamHandleState); SubscribeLocalEvent(OnDisarmed); SubscribeLocalEvent(OnRejuvenate); @@ -67,31 +64,8 @@ public sealed partial class StaminaSystem : EntitySystem component.NextUpdate += args.PausedTime; } - private void OnStamGetState(EntityUid uid, StaminaComponent component, ref ComponentGetState args) + private void OnStamHandleState(EntityUid uid, StaminaComponent component, ref AfterAutoHandleStateEvent args) { - args.State = new StaminaComponentState() - { - Critical = component.Critical, - Decay = component.Decay, - CritThreshold = component.CritThreshold, - DecayCooldown = component.DecayCooldown, - LastUpdate = component.NextUpdate, - StaminaDamage = component.StaminaDamage, - }; - } - - private void OnStamHandleState(EntityUid uid, StaminaComponent component, ref ComponentHandleState args) - { - if (args.Current is not StaminaComponentState state) - return; - - component.Critical = state.Critical; - component.Decay = state.Decay; - component.CritThreshold = state.CritThreshold; - component.DecayCooldown = state.DecayCooldown; - component.NextUpdate = state.LastUpdate; - component.StaminaDamage = state.StaminaDamage; - if (component.Critical) EnterStamCrit(uid, component); else @@ -283,7 +257,7 @@ public sealed partial class StaminaSystem : EntitySystem // Reset the decay cooldown upon taking damage. if (oldDamage < component.StaminaDamage) { - var nextUpdate = _timing.CurTime + TimeSpan.FromSeconds(component.DecayCooldown); + var nextUpdate = _timing.CurTime + TimeSpan.FromSeconds(component.Cooldown); if (component.NextUpdate < nextUpdate) component.NextUpdate = nextUpdate; @@ -419,18 +393,6 @@ public sealed partial class StaminaSystem : EntitySystem Dirty(component); _adminLogger.Add(LogType.Stamina, LogImpact.Low, $"{ToPrettyString(uid):user} recovered from stamina crit"); } - - [Serializable, NetSerializable] - private sealed class StaminaComponentState : ComponentState - { - public bool Critical; - public float Decay; - public float DecayCooldown; - public float StaminaDamage; - public float CritThreshold; - public TimeSpan LastUpdate; - } - } /// diff --git a/Content.Shared/DeviceNetwork/Components/DeviceListComponent.cs b/Content.Shared/DeviceNetwork/Components/DeviceListComponent.cs index e7fee450d1..8221710292 100644 --- a/Content.Shared/DeviceNetwork/Components/DeviceListComponent.cs +++ b/Content.Shared/DeviceNetwork/Components/DeviceListComponent.cs @@ -1,53 +1,36 @@ using Content.Shared.DeviceNetwork.Systems; using Robust.Shared.GameStates; -using Robust.Shared.Serialization; namespace Content.Shared.DeviceNetwork.Components; -[RegisterComponent] -[NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] [Access(typeof(SharedDeviceListSystem))] public sealed partial class DeviceListComponent : Component { /// /// The list of devices can or can't connect to, depending on the field. /// - [DataField("devices")] + [DataField, AutoNetworkedField] public HashSet Devices = new(); /// /// The limit of devices that can be linked to this device list. /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("deviceLimit")] + [DataField] public int DeviceLimit = 32; /// /// Whether the device list is used as an allow or deny list /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("isAllowList")] + [DataField, AutoNetworkedField] public bool IsAllowList = true; /// /// Whether this device list also handles incoming device net packets /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("handleIncoming")] - public bool HandleIncomingPackets = false; -} - -[Serializable, NetSerializable] -public sealed class DeviceListComponentState : ComponentState -{ - public readonly HashSet Devices; - public readonly bool IsAllowList; - public readonly bool HandleIncomingPackets; - - public DeviceListComponentState(HashSet devices, bool isAllowList, bool handleIncomingPackets) - { - Devices = devices; - IsAllowList = isAllowList; - HandleIncomingPackets = handleIncomingPackets; - } + [DataField, AutoNetworkedField] + public bool HandleIncomingPackets; } diff --git a/Content.Shared/DeviceNetwork/Components/NetworkConfiguratorComponent.cs b/Content.Shared/DeviceNetwork/Components/NetworkConfiguratorComponent.cs index 910aff4a14..7202b803f8 100644 --- a/Content.Shared/DeviceNetwork/Components/NetworkConfiguratorComponent.cs +++ b/Content.Shared/DeviceNetwork/Components/NetworkConfiguratorComponent.cs @@ -2,72 +2,57 @@ using Content.Shared.DeviceLinking; using Content.Shared.DeviceNetwork.Systems; using Robust.Shared.Audio; using Robust.Shared.GameStates; -using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; namespace Content.Shared.DeviceNetwork.Components; -[RegisterComponent] -[NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] [Access(typeof(SharedNetworkConfiguratorSystem))] public sealed partial class NetworkConfiguratorComponent : Component { /// /// Determines whether the configurator is in linking mode or list mode /// - [DataField("linkModeActive")] + [DataField, AutoNetworkedField] [ViewVariables(VVAccess.ReadWrite)] public bool LinkModeActive = true; /// /// The entity containing a this configurator is currently interacting with /// - [DataField("activeDeviceList")] - public EntityUid? ActiveDeviceList = null; + [DataField, AutoNetworkedField] + public EntityUid? ActiveDeviceList; /// /// The entity containing a or this configurator is currently interacting with.
/// If this is set the configurator is in linking mode. ///
- [DataField("activeDeviceLink")] - public EntityUid? ActiveDeviceLink = null; + [DataField] + public EntityUid? ActiveDeviceLink; /// /// The target device this configurator is currently linking with the /// - [DataField("deviceLinkTarget")] - public EntityUid? DeviceLinkTarget = null; + [DataField] + public EntityUid? DeviceLinkTarget; /// /// The list of devices stored in the configurator /// - [DataField("devices")] + [DataField] public Dictionary Devices = new(); - [DataField("useDelay")] + [DataField] [ViewVariables(VVAccess.ReadWrite)] public TimeSpan UseDelay = TimeSpan.FromSeconds(0.5); - [DataField("lastUseAttempt", customTypeSerializer:typeof(TimeOffsetSerializer))] + [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))] [ViewVariables(VVAccess.ReadWrite)] public TimeSpan LastUseAttempt; - [DataField("soundNoAccess")] + [DataField] public SoundSpecifier SoundNoAccess = new SoundPathSpecifier("/Audio/Machines/custom_deny.ogg"); - [DataField("soundSwitchMode")] + [DataField] public SoundSpecifier SoundSwitchMode = new SoundPathSpecifier("/Audio/Machines/quickbeep.ogg"); } - -[Serializable, NetSerializable] -public sealed class NetworkConfiguratorComponentState : ComponentState -{ - public readonly NetEntity? ActiveDeviceList; - public readonly 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 c4d5d688c6..a15d942ad6 100644 --- a/Content.Shared/DeviceNetwork/Systems/SharedDeviceListSystem.cs +++ b/Content.Shared/DeviceNetwork/Systems/SharedDeviceListSystem.cs @@ -1,17 +1,10 @@ using System.Linq; using Content.Shared.DeviceNetwork.Components; -using Robust.Shared.GameStates; namespace Content.Shared.DeviceNetwork.Systems; public abstract class SharedDeviceListSystem : EntitySystem { - public override void Initialize() - { - SubscribeLocalEvent(GetDeviceListState); - SubscribeLocalEvent(HandleDeviceListState); - } - /// /// Updates the device list stored on this entity. /// @@ -57,23 +50,6 @@ public abstract class SharedDeviceListSystem : EntitySystem protected virtual void UpdateShutdownSubscription(EntityUid uid, List devicesList, List oldDevices) { } - - private void GetDeviceListState(EntityUid uid, DeviceListComponent comp, ref ComponentGetState args) - { - args.State = new DeviceListComponentState(GetNetEntitySet(comp.Devices), comp.IsAllowList, comp.HandleIncomingPackets); - } - - private void HandleDeviceListState(EntityUid uid, DeviceListComponent comp, ref ComponentHandleState args) - { - if (args.Current is not DeviceListComponentState state) - { - return; - } - - comp.Devices = EnsureEntitySet(state.Devices, uid); - comp.HandleIncomingPackets = state.HandleIncomingPackets; - comp.IsAllowList = state.IsAllowList; - } } public sealed class DeviceListUpdateEvent : EntityEventArgs diff --git a/Content.Shared/DeviceNetwork/Systems/SharedNetworkConfiguratorSystem.cs b/Content.Shared/DeviceNetwork/Systems/SharedNetworkConfiguratorSystem.cs index 87f77c8f0a..4aa9db199d 100644 --- a/Content.Shared/DeviceNetwork/Systems/SharedNetworkConfiguratorSystem.cs +++ b/Content.Shared/DeviceNetwork/Systems/SharedNetworkConfiguratorSystem.cs @@ -1,37 +1,10 @@ using Content.Shared.Actions; -using Content.Shared.DeviceNetwork.Components; -using Robust.Shared.GameStates; using Robust.Shared.Serialization; namespace Content.Shared.DeviceNetwork.Systems; public abstract class SharedNetworkConfiguratorSystem : EntitySystem { - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(GetNetworkConfiguratorState); - SubscribeLocalEvent(HandleNetworkConfiguratorState); - } - - private void GetNetworkConfiguratorState(EntityUid uid, NetworkConfiguratorComponent comp, - ref ComponentGetState args) - { - args.State = new NetworkConfiguratorComponentState(GetNetEntity(comp.ActiveDeviceList), comp.LinkModeActive); - } - - private void HandleNetworkConfiguratorState(EntityUid uid, NetworkConfiguratorComponent comp, - ref ComponentHandleState args) - { - if (args.Current is not NetworkConfiguratorComponentState state) - { - return; - } - - comp.ActiveDeviceList = EnsureEntity(state.ActiveDeviceList, uid); - comp.LinkModeActive = state.LinkModeActive; - } } public sealed partial class ClearAllOverlaysEvent : InstantActionEvent diff --git a/Content.Shared/Doors/Components/AirlockComponent.cs b/Content.Shared/Doors/Components/AirlockComponent.cs index c64e1ac518..486efa8c51 100644 --- a/Content.Shared/Doors/Components/AirlockComponent.cs +++ b/Content.Shared/Doors/Components/AirlockComponent.cs @@ -1,7 +1,6 @@ using Content.Shared.DeviceLinking; using Content.Shared.Doors.Systems; using Robust.Shared.GameStates; -using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; namespace Content.Shared.Doors.Components; @@ -9,16 +8,17 @@ namespace Content.Shared.Doors.Components; /// /// Companion component to DoorComponent that handles airlock-specific behavior -- wires, requiring power to operate, bolts, and allowing automatic closing. /// -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] [Access(typeof(SharedAirlockSystem), Friend = AccessPermissions.ReadWriteExecute, Other = AccessPermissions.Read)] public sealed partial class AirlockComponent : Component { + // Need to network airlock safety state to avoid mis-predicts when a door auto-closes as the client walks through the door. [ViewVariables(VVAccess.ReadWrite)] - [DataField("safety")] + [DataField, AutoNetworkedField] public bool Safety = true; [ViewVariables(VVAccess.ReadWrite)] - [DataField("emergencyAccess")] + [DataField] public bool EmergencyAccess = false; /// @@ -26,20 +26,20 @@ public sealed partial class AirlockComponent : Component /// Most anything that can pry powered has a pry speed bonus, /// so this default is closer to 6 effectively on e.g. jaws (9 seconds when applied to other default.) /// - [DataField("poweredPryModifier")] + [DataField] public float PoweredPryModifier = 9f; /// /// Whether the maintenance panel should be visible even if the airlock is opened. /// - [DataField("openPanelVisible")] + [DataField] public bool OpenPanelVisible = false; /// /// Whether the airlock should stay open if the airlock was clicked. /// If the airlock was bumped into it will still auto close. /// - [DataField("keepOpenIfClicked")] + [DataField] public bool KeepOpenIfClicked = false; /// @@ -51,7 +51,7 @@ public sealed partial class AirlockComponent : Component /// /// Delay until an open door automatically closes. /// - [DataField("autoCloseDelay")] + [DataField] public TimeSpan AutoCloseDelay = TimeSpan.FromSeconds(5f); /// @@ -64,7 +64,7 @@ public sealed partial class AirlockComponent : Component /// /// The receiver port for turning off automatic closing. /// - [DataField("autoClosePort", customTypeSerializer: typeof(PrototypeIdSerializer))] + [DataField(customTypeSerializer: typeof(PrototypeIdSerializer))] public string AutoClosePort = "AutoClose"; #region Graphics @@ -72,79 +72,68 @@ public sealed partial class AirlockComponent : Component /// /// Whether the door lights should be visible. /// - [DataField("openUnlitVisible")] + [DataField] public bool OpenUnlitVisible = false; /// /// Whether the door should display emergency access lights. /// - [DataField("emergencyAccessLayer")] + [DataField] public bool EmergencyAccessLayer = true; /// /// Whether or not to animate the panel when the door opens or closes. /// - [DataField("animatePanel")] + [DataField] public bool AnimatePanel = true; /// /// The sprite state used to animate the airlock frame when the airlock opens. /// - [DataField("openingSpriteState")] + [DataField] public string OpeningSpriteState = "opening_unlit"; /// /// The sprite state used to animate the airlock panel when the airlock opens. /// - [DataField("openingPanelSpriteState")] + [DataField] public string OpeningPanelSpriteState = "panel_opening"; /// /// The sprite state used to animate the airlock frame when the airlock closes. /// - [DataField("closingSpriteState")] + [DataField] public string ClosingSpriteState = "closing_unlit"; /// /// The sprite state used to animate the airlock panel when the airlock closes. /// - [DataField("closingPanelSpriteState")] + [DataField] public string ClosingPanelSpriteState = "panel_closing"; /// /// The sprite state used for the open airlock lights. /// - [DataField("openSpriteState")] + [DataField] public string OpenSpriteState = "open_unlit"; /// /// The sprite state used for the closed airlock lights. /// - [DataField("closedSpriteState")] + [DataField] public string ClosedSpriteState = "closed_unlit"; /// /// The sprite state used for the 'access denied' lights animation. /// - [DataField("denySpriteState")] + [DataField] public string DenySpriteState = "deny_unlit"; /// /// How long the animation played when the airlock denies access is in seconds. /// - [DataField("denyAnimationTime")] + [DataField] public float DenyAnimationTime = 0.3f; #endregion Graphics } - -[Serializable, NetSerializable] -public sealed class AirlockComponentState : ComponentState -{ - public readonly bool Safety; - - public AirlockComponentState(bool safety) - { - Safety = safety; - } -} diff --git a/Content.Shared/Doors/Components/DoorComponent.cs b/Content.Shared/Doors/Components/DoorComponent.cs index 7cfcba8c5b..d4d121a87a 100644 --- a/Content.Shared/Doors/Components/DoorComponent.cs +++ b/Content.Shared/Doors/Components/DoorComponent.cs @@ -1,20 +1,18 @@ -using System.Runtime.InteropServices; using Content.Shared.Damage; using Content.Shared.Doors.Systems; using Content.Shared.Tools; using JetBrains.Annotations; using Robust.Shared.Audio; using Robust.Shared.GameStates; +using Robust.Shared.Prototypes; using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Timing; using DrawDepthTag = Robust.Shared.GameObjects.DrawDepth; namespace Content.Shared.Doors.Components; -[NetworkedComponent] -[RegisterComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] public sealed partial class DoorComponent : Component { /// @@ -24,7 +22,7 @@ public sealed partial class DoorComponent : Component /// This should never be set directly, use instead. /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("state")] + [DataField, AutoNetworkedField] [Access(typeof(SharedDoorSystem))] public DoorState State = DoorState.Closed; @@ -35,46 +33,47 @@ public sealed partial class DoorComponent : Component /// /// Closing time until impassable. Total time is this plus . /// - [DataField("closeTimeOne")] + [DataField] public TimeSpan CloseTimeOne = TimeSpan.FromSeconds(0.4f); /// /// Closing time until fully closed. Total time is this plus . /// - [DataField("closeTimeTwo")] + [DataField] public TimeSpan CloseTimeTwo = TimeSpan.FromSeconds(0.2f); /// /// Opening time until passable. Total time is this plus . /// - [DataField("openTimeOne")] + [DataField] public TimeSpan OpenTimeOne = TimeSpan.FromSeconds(0.4f); /// /// Opening time until fully open. Total time is this plus . /// - [DataField("openTimeTwo")] + [DataField] public TimeSpan OpenTimeTwo = TimeSpan.FromSeconds(0.2f); /// /// Interval between deny sounds & visuals; /// - [DataField("denyDuration")] + [DataField] public TimeSpan DenyDuration = TimeSpan.FromSeconds(0.45f); - [DataField("emagDuration")] + [DataField] public TimeSpan EmagDuration = TimeSpan.FromSeconds(0.8f); /// /// When the door is active, this is the time when the state will next update. /// + [AutoNetworkedField] public TimeSpan? NextStateChange; /// /// Whether the door is currently partially closed or open. I.e., when the door is "closing" and is already opaque, /// but not yet actually closed. /// - [DataField("partial")] + [DataField, AutoNetworkedField] public bool Partial; #endregion @@ -115,30 +114,30 @@ public sealed partial class DoorComponent : Component /// This is how long a door-crush will stun you. This also determines how long it takes the door to open up /// again. Total stun time is actually given by this plus . /// - [DataField("doorStunTime")] + [DataField] public TimeSpan DoorStunTime = TimeSpan.FromSeconds(2f); - [DataField("crushDamage")] + [DataField] public DamageSpecifier? CrushDamage; /// /// If false, this door is incapable of crushing entities. This just determines whether it will apply damage and /// stun, not whether it can close despite entities being in the way. /// - [DataField("canCrush")] + [DataField] public bool CanCrush = true; /// /// Whether to check for colliding entities before closing. This may be overridden by other system by subscribing to /// . For example, hacked airlocks will set this to false. /// - [DataField("performCollisionCheck")] + [DataField] public bool PerformCollisionCheck = true; /// /// List of EntityUids of entities we're currently crushing. Cleared in OnPartialOpen(). /// - [DataField("currentlyCrushing")] + [DataField, AutoNetworkedField] public HashSet CurrentlyCrushing = new(); #endregion @@ -152,7 +151,7 @@ public sealed partial class DoorComponent : Component /// /// The sprite state used for the door when it's open. /// - [DataField("openSpriteState")] + [DataField] [ViewVariables(VVAccess.ReadWrite)] public string OpenSpriteState = "open"; @@ -165,7 +164,7 @@ public sealed partial class DoorComponent : Component /// /// The sprite state used for the door when it's closed. /// - [DataField("closedSpriteState")] + [DataField] [ViewVariables(VVAccess.ReadWrite)] public string ClosedSpriteState = "closed"; @@ -178,37 +177,37 @@ public sealed partial class DoorComponent : Component /// /// The sprite state used for the door when it's opening. /// - [DataField("openingSpriteState")] + [DataField] public string OpeningSpriteState = "opening"; /// /// The sprite state used for the door when it's closing. /// - [DataField("closingSpriteState")] + [DataField] public string ClosingSpriteState = "closing"; /// /// The sprite state used for the door when it's being emagged. /// - [DataField("emaggingSpriteState")] + [DataField] public string EmaggingSpriteState = "emagging"; /// /// The sprite state used for the door when it's open. /// - [DataField("openingAnimationTime")] + [DataField] public float OpeningAnimationTime = 0.8f; /// /// The sprite state used for the door when it's open. /// - [DataField("closingAnimationTime")] + [DataField] public float ClosingAnimationTime = 0.8f; /// /// The sprite state used for the door when it's open. /// - [DataField("emaggingAnimationTime")] + [DataField] public float EmaggingAnimationTime = 1.5f; /// @@ -237,7 +236,7 @@ public sealed partial class DoorComponent : Component /// /// Time until next state change. Because apparently might not get saved/restored. /// - [DataField("SecondsUntilStateChange")] + [DataField] private float? SecondsUntilStateChange { [UsedImplicitly] @@ -262,47 +261,47 @@ public sealed partial class DoorComponent : Component } #endregion - [DataField("canPry"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public bool CanPry = true; - [DataField("pryingQuality", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string PryingQuality = "Prying"; + [DataField] + public ProtoId PryingQuality = "Prying"; /// /// Default time that the door should take to pry open. /// - [DataField("pryTime"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public float PryTime = 1.5f; - [DataField("changeAirtight")] + [DataField] public bool ChangeAirtight = true; /// /// Whether the door blocks light. /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("occludes")] + [DataField] public bool Occludes = true; /// /// Whether the door will open when it is bumped into. /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("bumpOpen")] + [DataField] public bool BumpOpen = true; /// /// Whether the door will open when it is activated or clicked. /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("clickOpen")] + [DataField] public bool ClickOpen = true; - [DataField("openDrawDepth", customTypeSerializer: typeof(ConstantSerializer))] - public int OpenDrawDepth = (int)DrawDepth.DrawDepth.Doors; + [DataField(customTypeSerializer: typeof(ConstantSerializer))] + public int OpenDrawDepth = (int) DrawDepth.DrawDepth.Doors; - [DataField("closedDrawDepth", customTypeSerializer: typeof(ConstantSerializer))] - public int ClosedDrawDepth = (int)DrawDepth.DrawDepth.Doors; + [DataField(customTypeSerializer: typeof(ConstantSerializer))] + public int ClosedDrawDepth = (int) DrawDepth.DrawDepth.Doors; } [Serializable, NetSerializable] @@ -335,20 +334,3 @@ public enum DoorVisualLayers : byte BaseBolted, BaseEmergencyAccess, } - -[Serializable, NetSerializable] -public sealed class DoorComponentState : ComponentState -{ - public readonly DoorState DoorState; - public readonly HashSet CurrentlyCrushing; - public readonly TimeSpan? NextStateChange; - public readonly bool Partial; - - public DoorComponentState(DoorComponent door, HashSet currentlyCrushing) - { - DoorState = door.State; - CurrentlyCrushing = currentlyCrushing; - NextStateChange = door.NextStateChange; - Partial = door.Partial; - } -} diff --git a/Content.Shared/Doors/Systems/SharedAirlockSystem.cs b/Content.Shared/Doors/Systems/SharedAirlockSystem.cs index 1274e33985..9e1273b784 100644 --- a/Content.Shared/Doors/Systems/SharedAirlockSystem.cs +++ b/Content.Shared/Doors/Systems/SharedAirlockSystem.cs @@ -1,6 +1,5 @@ using Content.Shared.Doors.Components; using Content.Shared.Popups; -using Robust.Shared.GameStates; namespace Content.Shared.Doors.Systems; @@ -14,32 +13,15 @@ public abstract class SharedAirlockSystem : EntitySystem { base.Initialize(); - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); SubscribeLocalEvent(OnBeforeDoorClosed); } - private void OnGetState(EntityUid uid, AirlockComponent airlock, ref ComponentGetState args) - { - // Need to network airlock safety state to avoid mis-predicts when a door auto-closes as the client walks through the door. - args.State = new AirlockComponentState(airlock.Safety); - } - - private void OnHandleState(EntityUid uid, AirlockComponent airlock, ref ComponentHandleState args) - { - if (args.Current is not AirlockComponentState state) - return; - - airlock.Safety = state.Safety; - } - protected virtual void OnBeforeDoorClosed(EntityUid uid, AirlockComponent airlock, BeforeDoorClosedEvent args) { if (!airlock.Safety) args.PerformCollisionCheck = false; } - public void UpdateEmergencyLightStatus(EntityUid uid, AirlockComponent component) { Appearance.SetData(uid, DoorVisuals.EmergencyLights, component.EmergencyAccess); diff --git a/Content.Shared/Doors/Systems/SharedDoorSystem.cs b/Content.Shared/Doors/Systems/SharedDoorSystem.cs index e551517149..4a241ba376 100644 --- a/Content.Shared/Doors/Systems/SharedDoorSystem.cs +++ b/Content.Shared/Doors/Systems/SharedDoorSystem.cs @@ -10,7 +10,6 @@ using Content.Shared.Physics; using Content.Shared.Stunnable; using Content.Shared.Tag; using Robust.Shared.Audio; -using Robust.Shared.GameStates; using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Events; using Robust.Shared.Physics.Systems; @@ -55,8 +54,7 @@ public abstract partial class SharedDoorSystem : EntitySystem SubscribeLocalEvent(OnComponentInit); SubscribeLocalEvent(OnRemove); - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); + SubscribeLocalEvent(OnHandleState); SubscribeLocalEvent(OnActivate); @@ -102,29 +100,14 @@ public abstract partial class SharedDoorSystem : EntitySystem } #region StateManagement - private void OnGetState(EntityUid uid, DoorComponent door, ref ComponentGetState args) + private void OnHandleState(EntityUid uid, DoorComponent door, ref AfterAutoHandleStateEvent args) { - args.State = new DoorComponentState(door, GetNetEntitySet(door.CurrentlyCrushing)); - } - - private void OnHandleState(EntityUid uid, DoorComponent door, ref ComponentHandleState args) - { - if (args.Current is not DoorComponentState state) - return; - - door.CurrentlyCrushing.Clear(); - door.CurrentlyCrushing.UnionWith(EnsureEntitySet(state.CurrentlyCrushing, uid)); - - door.State = state.DoorState; - door.NextStateChange = state.NextStateChange; - door.Partial = state.Partial; - - if (state.NextStateChange == null) + if (door.NextStateChange == null) _activeDoors.Remove(door); else _activeDoors.Add(door); - RaiseLocalEvent(uid, new DoorStateChangedEvent(door.State), false); + RaiseLocalEvent(uid, new DoorStateChangedEvent(door.State)); AppearanceSystem.SetData(uid, DoorVisuals.State, door.State); } diff --git a/Content.Shared/Electrocution/InsulatedComponent.cs b/Content.Shared/Electrocution/InsulatedComponent.cs index cd4e5e32c5..72c6ebcef0 100644 --- a/Content.Shared/Electrocution/InsulatedComponent.cs +++ b/Content.Shared/Electrocution/InsulatedComponent.cs @@ -1,29 +1,17 @@ using Robust.Shared.GameStates; -using Robust.Shared.Serialization; namespace Content.Shared.Electrocution { + [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] [Access(typeof(SharedElectrocutionSystem))] - [RegisterComponent, NetworkedComponent] public sealed partial class InsulatedComponent : Component { + // Technically, people could cheat and figure out which budget insulated gloves are gud and which ones are bad. + // We might want to rethink this a little bit. /// /// Siemens coefficient. Zero means completely insulated. /// - [DataField("coefficient")] - public float SiemensCoefficient { get; set; } = 0f; - } - - // Technically, people could cheat and figure out which budget insulated gloves are gud and which ones are bad. - // We might want to rethink this a little bit. - [NetSerializable, Serializable] - public sealed class InsulatedComponentState : ComponentState - { - public float SiemensCoefficient { get; private set; } - - public InsulatedComponentState(float siemensCoefficient) - { - SiemensCoefficient = siemensCoefficient; - } + [DataField, AutoNetworkedField] + public float Coefficient { get; set; } = 0f; } } diff --git a/Content.Shared/Electrocution/SharedElectrocutionSystem.cs b/Content.Shared/Electrocution/SharedElectrocutionSystem.cs index 67a395bb81..5031d8a911 100644 --- a/Content.Shared/Electrocution/SharedElectrocutionSystem.cs +++ b/Content.Shared/Electrocution/SharedElectrocutionSystem.cs @@ -1,6 +1,5 @@ using Content.Shared.Inventory; using Content.Shared.StatusEffect; -using Robust.Shared.GameStates; namespace Content.Shared.Electrocution { @@ -13,8 +12,6 @@ namespace Content.Shared.Electrocution SubscribeLocalEvent(OnInsulatedElectrocutionAttempt); // as long as legally distinct electric-mice are never added, this should be fine (otherwise a mouse-hat will transfer it's power to the wearer). SubscribeLocalEvent>((e, c, ev) => OnInsulatedElectrocutionAttempt(e, c, ev.Args)); - SubscribeLocalEvent(OnInsulatedGetState); - SubscribeLocalEvent(OnInsulatedHandleState); } public void SetInsulatedSiemensCoefficient(EntityUid uid, float siemensCoefficient, InsulatedComponent? insulated = null) @@ -22,7 +19,7 @@ namespace Content.Shared.Electrocution if (!Resolve(uid, ref insulated)) return; - insulated.SiemensCoefficient = siemensCoefficient; + insulated.Coefficient = siemensCoefficient; Dirty(insulated); } @@ -45,21 +42,7 @@ namespace Content.Shared.Electrocution private void OnInsulatedElectrocutionAttempt(EntityUid uid, InsulatedComponent insulated, ElectrocutionAttemptEvent args) { - args.SiemensCoefficient *= insulated.SiemensCoefficient; + args.SiemensCoefficient *= insulated.Coefficient; } - - private void OnInsulatedGetState(EntityUid uid, InsulatedComponent insulated, ref ComponentGetState args) - { - args.State = new InsulatedComponentState(insulated.SiemensCoefficient); - } - - private void OnInsulatedHandleState(EntityUid uid, InsulatedComponent insulated, ref ComponentHandleState args) - { - if (args.Current is not InsulatedComponentState state) - return; - - insulated.SiemensCoefficient = state.SiemensCoefficient; - } - } } diff --git a/Content.Shared/Emoting/EmoteSystem.cs b/Content.Shared/Emoting/EmoteSystem.cs index 942c6b9de0..fd6361245b 100644 --- a/Content.Shared/Emoting/EmoteSystem.cs +++ b/Content.Shared/Emoting/EmoteSystem.cs @@ -1,60 +1,30 @@ -using Robust.Shared.GameStates; -using Robust.Shared.Serialization; +namespace Content.Shared.Emoting; -namespace Content.Shared.Emoting +public sealed class EmoteSystem : EntitySystem { - public sealed class EmoteSystem : EntitySystem + public override void Initialize() { - public override void Initialize() - { - base.Initialize(); + base.Initialize(); - SubscribeLocalEvent(OnEmoteAttempt); - SubscribeLocalEvent(OnEmotingGetState); - SubscribeLocalEvent(OnEmotingHandleState); - } + SubscribeLocalEvent(OnEmoteAttempt); + } - public void SetEmoting(EntityUid uid, bool value, EmotingComponent? component = null) - { - if (value && !Resolve(uid, ref component)) - return; + public void SetEmoting(EntityUid uid, bool value, EmotingComponent? component = null) + { + if (value && !Resolve(uid, ref component)) + return; - component = EnsureComp(uid); + component = EnsureComp(uid); - if (component.Enabled == value) - return; + if (component.Enabled == value) + return; - Dirty(component); - } + Dirty(component); + } - private void OnEmotingHandleState(EntityUid uid, EmotingComponent component, ref ComponentHandleState args) - { - if (args.Current is not EmotingComponentState state) - return; - - component.Enabled = state.Enabled; - } - - private void OnEmotingGetState(EntityUid uid, EmotingComponent component, ref ComponentGetState args) - { - args.State = new EmotingComponentState(component.Enabled); - } - - private void OnEmoteAttempt(EmoteAttemptEvent args) - { - if (!TryComp(args.Uid, out EmotingComponent? emote) || !emote.Enabled) - args.Cancel(); - } - - [Serializable, NetSerializable] - private sealed class EmotingComponentState : ComponentState - { - public bool Enabled { get; } - - public EmotingComponentState(bool enabled) - { - Enabled = enabled; - } - } + private void OnEmoteAttempt(EmoteAttemptEvent args) + { + if (!TryComp(args.Uid, out EmotingComponent? emote) || !emote.Enabled) + args.Cancel(); } } diff --git a/Content.Shared/Emoting/EmotingComponent.cs b/Content.Shared/Emoting/EmotingComponent.cs index a7a1542a91..873f906f4b 100644 --- a/Content.Shared/Emoting/EmotingComponent.cs +++ b/Content.Shared/Emoting/EmotingComponent.cs @@ -1,12 +1,11 @@ using Robust.Shared.GameStates; -namespace Content.Shared.Emoting +namespace Content.Shared.Emoting; + +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +public sealed partial class EmotingComponent : Component { - [RegisterComponent, NetworkedComponent] - public sealed partial class EmotingComponent : Component - { - [DataField("enabled"), Access(typeof(EmoteSystem), - Friend = AccessPermissions.ReadWrite, - Other = AccessPermissions.Read)] public bool Enabled = true; - } + [DataField, AutoNetworkedField] + [Access(typeof(EmoteSystem), Friend = AccessPermissions.ReadWrite, Other = AccessPermissions.Read)] + public bool Enabled = true; } diff --git a/Content.Shared/Follower/Components/FollowedComponent.cs b/Content.Shared/Follower/Components/FollowedComponent.cs index 83e486668e..7c2ca0efbf 100644 --- a/Content.Shared/Follower/Components/FollowedComponent.cs +++ b/Content.Shared/Follower/Components/FollowedComponent.cs @@ -6,10 +6,10 @@ namespace Content.Shared.Follower.Components; /// /// Attached to entities that are currently being followed by a ghost. /// -[RegisterComponent, Access(typeof(FollowerSystem))] -[NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +[Access(typeof(FollowerSystem))] public sealed partial class FollowedComponent : Component { - [DataField("following")] + [DataField, AutoNetworkedField] public HashSet Following = new(); } diff --git a/Content.Shared/Follower/FollowerSystem.cs b/Content.Shared/Follower/FollowerSystem.cs index 10e7a7be1d..339136ffe8 100644 --- a/Content.Shared/Follower/FollowerSystem.cs +++ b/Content.Shared/Follower/FollowerSystem.cs @@ -8,14 +8,12 @@ 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; +using Robust.Shared.Utility; namespace Content.Shared.Follower; @@ -38,25 +36,6 @@ 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) @@ -242,12 +221,6 @@ 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/Gravity/FloatingVisualsComponent.cs b/Content.Shared/Gravity/FloatingVisualsComponent.cs index 7cf6331e9e..67650baecd 100644 --- a/Content.Shared/Gravity/FloatingVisualsComponent.cs +++ b/Content.Shared/Gravity/FloatingVisualsComponent.cs @@ -1,10 +1,9 @@ using System.Numerics; using Robust.Shared.GameStates; -using Robust.Shared.Serialization; namespace Content.Shared.Gravity; -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] [Access(typeof(SharedFloatingVisualizerSystem))] public sealed partial class FloatingVisualsComponent : Component { @@ -12,33 +11,19 @@ public sealed partial class FloatingVisualsComponent : Component /// How long it takes to go from the bottom of the animation to the top. /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("animationTime")] + [DataField, AutoNetworkedField] public float AnimationTime = 2f; /// /// How far it goes in any direction. /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("offset")] + [DataField, AutoNetworkedField] public Vector2 Offset = new(0, 0.2f); [ViewVariables(VVAccess.ReadWrite)] + [AutoNetworkedField] public bool CanFloat = false; + public readonly string AnimationKey = "gravity"; } - - -[Serializable, NetSerializable] -public sealed class SharedFloatingVisualsComponentState : ComponentState -{ - public float AnimationTime; - public Vector2 Offset; - public bool HasGravity; - - public SharedFloatingVisualsComponentState(float animationTime, Vector2 offset, bool hasGravity) - { - AnimationTime = animationTime; - Offset = offset; - HasGravity = hasGravity; - } -} diff --git a/Content.Shared/Gravity/GravityShakeComponent.cs b/Content.Shared/Gravity/GravityShakeComponent.cs index 5fc1e90230..e8608a9681 100644 --- a/Content.Shared/Gravity/GravityShakeComponent.cs +++ b/Content.Shared/Gravity/GravityShakeComponent.cs @@ -6,12 +6,12 @@ namespace Content.Shared.Gravity; /// /// Indicates this entity is shaking due to gravity changes. /// -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class GravityShakeComponent : Component { - [ViewVariables(VVAccess.ReadWrite), DataField("shakeTimes")] + [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] public int ShakeTimes; - [DataField("nextShake", customTypeSerializer:typeof(TimeOffsetSerializer))] + [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField] public TimeSpan NextShake; } diff --git a/Content.Shared/Gravity/SharedFloatingVisualizerSystem.cs b/Content.Shared/Gravity/SharedFloatingVisualizerSystem.cs index 204f397801..0f06d72192 100644 --- a/Content.Shared/Gravity/SharedFloatingVisualizerSystem.cs +++ b/Content.Shared/Gravity/SharedFloatingVisualizerSystem.cs @@ -1,5 +1,4 @@ using System.Numerics; -using Robust.Shared.GameStates; using Robust.Shared.Map; namespace Content.Shared.Gravity; @@ -18,8 +17,6 @@ public abstract class SharedFloatingVisualizerSystem : EntitySystem SubscribeLocalEvent(OnComponentStartup); SubscribeLocalEvent(OnGravityChanged); SubscribeLocalEvent(OnEntParentChanged); - SubscribeLocalEvent(OnComponentGetState); - SubscribeLocalEvent(OnComponentHandleState); } /// @@ -71,19 +68,4 @@ public abstract class SharedFloatingVisualizerSystem : EntitySystem if (CanFloat(uid, component, transform)) FloatAnimation(uid, component.Offset, component.AnimationKey, component.AnimationTime); } - - private void OnComponentGetState(EntityUid uid, FloatingVisualsComponent component, ref ComponentGetState args) - { - args.State = new SharedFloatingVisualsComponentState(component.AnimationTime, component.Offset, component.CanFloat); - } - - private void OnComponentHandleState(EntityUid uid, FloatingVisualsComponent component, ref ComponentHandleState args) - { - if (args.Current is not SharedFloatingVisualsComponentState state) - return; - - component.AnimationTime = state.AnimationTime; - component.Offset = state.Offset; - component.CanFloat = state.HasGravity; - } } diff --git a/Content.Shared/Gravity/SharedGravitySystem.Shake.cs b/Content.Shared/Gravity/SharedGravitySystem.Shake.cs index f265dedc15..e590baae44 100644 --- a/Content.Shared/Gravity/SharedGravitySystem.Shake.cs +++ b/Content.Shared/Gravity/SharedGravitySystem.Shake.cs @@ -1,6 +1,3 @@ -using Robust.Shared.GameStates; -using Robust.Shared.Serialization; - namespace Content.Shared.Gravity; public abstract partial class SharedGravitySystem @@ -11,8 +8,6 @@ public abstract partial class SharedGravitySystem private void InitializeShake() { SubscribeLocalEvent(OnShakeUnpaused); - SubscribeLocalEvent(OnShakeGetState); - SubscribeLocalEvent(OnShakeHandleState); } private void OnShakeUnpaused(EntityUid uid, GravityShakeComponent component, ref EntityUnpausedEvent args) @@ -63,29 +58,4 @@ public abstract partial class SharedGravitySystem } protected virtual void ShakeGrid(EntityUid uid, GravityComponent? comp = null) {} - - private void OnShakeHandleState(EntityUid uid, GravityShakeComponent component, ref ComponentHandleState args) - { - if (args.Current is not GravityShakeComponentState state) - return; - - component.ShakeTimes = state.ShakeTimes; - component.NextShake = state.NextShake; - } - - private void OnShakeGetState(EntityUid uid, GravityShakeComponent component, ref ComponentGetState args) - { - args.State = new GravityShakeComponentState() - { - ShakeTimes = component.ShakeTimes, - NextShake = component.NextShake, - }; - } - - [Serializable, NetSerializable] - protected sealed class GravityShakeComponentState : ComponentState - { - public int ShakeTimes; - public TimeSpan NextShake; - } } diff --git a/Content.Shared/Humanoid/HumanoidAppearanceComponent.cs b/Content.Shared/Humanoid/HumanoidAppearanceComponent.cs index 82d5750aa5..296545f0b4 100644 --- a/Content.Shared/Humanoid/HumanoidAppearanceComponent.cs +++ b/Content.Shared/Humanoid/HumanoidAppearanceComponent.cs @@ -4,31 +4,31 @@ using Robust.Shared.Enums; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Utility; -using static Content.Shared.Humanoid.HumanoidAppearanceState; namespace Content.Shared.Humanoid; -[NetworkedComponent, RegisterComponent] +[NetworkedComponent, RegisterComponent, AutoGenerateComponentState(true)] public sealed partial class HumanoidAppearanceComponent : Component { - [DataField("markingSet")] + public MarkingSet ClientOldMarkings = new(); + + [DataField] public MarkingSet MarkingSet = new(); - [DataField("baseLayers")] + [DataField] public Dictionary BaseLayers = new(); - [DataField("permanentlyHidden")] + [DataField, AutoNetworkedField(true)] public HashSet PermanentlyHidden = new(); // Couldn't these be somewhere else? - [DataField("gender")] - [ViewVariables] public Gender Gender = default!; + [DataField, AutoNetworkedField] + public Gender Gender; - [DataField("age")] - [ViewVariables] public int Age = 18; + [DataField, AutoNetworkedField] + public int Age = 18; /// /// Any custom base layers this humanoid might have. See: @@ -36,39 +36,39 @@ public sealed partial class HumanoidAppearanceComponent : Component /// Stored on the server, this is merged in the client into /// all layer settings. /// - [DataField("customBaseLayers")] + [DataField, AutoNetworkedField(true)] public Dictionary CustomBaseLayers = new(); /// /// Current species. Dictates things like base body sprites, /// base humanoid to spawn, etc. /// - [DataField("species", customTypeSerializer: typeof(PrototypeIdSerializer), required: true)] - public string Species { get; set; } = default!; + [DataField(required: true), AutoNetworkedField] + public ProtoId Species { get; set; } /// /// The initial profile and base layers to apply to this humanoid. /// - [DataField("initial", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string? Initial { get; private set; } + [DataField] + public ProtoId? Initial { get; private set; } /// /// Skin color of this humanoid. /// - [DataField("skinColor")] + [DataField, AutoNetworkedField] public Color SkinColor { get; set; } = Color.FromHex("#C0967F"); /// /// Visual layers currently hidden. This will affect the base sprite /// on this humanoid layer, and any markings that sit above it. /// - [DataField("hiddenLayers")] + [DataField, AutoNetworkedField(true)] public HashSet HiddenLayers = new(); - [DataField("sex")] + [DataField, AutoNetworkedField] public Sex Sex = Sex.Male; - [DataField("eyeColor")] + [DataField, AutoNetworkedField] public Color EyeColor = Color.Brown; /// @@ -84,65 +84,26 @@ public sealed partial class HumanoidAppearanceComponent : Component public Color? CachedFacialHairColor; } +[DataDefinition] [Serializable, NetSerializable] -public sealed partial class HumanoidAppearanceState : ComponentState +public readonly partial struct CustomBaseLayerInfo { - public readonly MarkingSet Markings; - public readonly HashSet PermanentlyHidden; - public readonly HashSet HiddenLayers; - public readonly Dictionary CustomBaseLayers; - public readonly Sex Sex; - public readonly Gender Gender; - public readonly int Age = 18; - public readonly string Species; - public readonly Color SkinColor; - public readonly Color EyeColor; - - public HumanoidAppearanceState( - MarkingSet currentMarkings, - HashSet permanentlyHidden, - HashSet hiddenLayers, - Dictionary customBaseLayers, - Sex sex, - Gender gender, - int age, - string species, - Color skinColor, - Color eyeColor) + public CustomBaseLayerInfo(string? id, Color? color = null) { - Markings = currentMarkings; - PermanentlyHidden = permanentlyHidden; - HiddenLayers = hiddenLayers; - CustomBaseLayers = customBaseLayers; - Sex = sex; - Gender = gender; - Age = age; - Species = species; - SkinColor = skinColor; - EyeColor = eyeColor; + DebugTools.Assert(id == null || IoCManager.Resolve().HasIndex(id)); + Id = id; + Color = color; } - [DataDefinition] - [Serializable, NetSerializable] - public readonly partial struct CustomBaseLayerInfo - { - public CustomBaseLayerInfo(string? id, Color? color = null) - { - DebugTools.Assert(id == null || IoCManager.Resolve().HasIndex(id)); - ID = id; - Color = color; - } + /// + /// ID of this custom base layer. Must be a . + /// + [DataField] + public ProtoId? Id { get; init; } - /// - /// ID of this custom base layer. Must be a . - /// - [DataField("id", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string? ID { init; get; } - - /// - /// Color of this custom base layer. Null implies skin colour if the corresponding is set to match skin. - /// - [DataField("color")] - public Color? Color { init; get; } - } + /// + /// Color of this custom base layer. Null implies skin colour if the corresponding is set to match skin. + /// + [DataField] + public Color? Color { get; init; } } diff --git a/Content.Shared/Humanoid/Prototypes/HumanoidProfilePrototype.cs b/Content.Shared/Humanoid/Prototypes/HumanoidProfilePrototype.cs index 5752e57c93..7755e3113c 100644 --- a/Content.Shared/Humanoid/Prototypes/HumanoidProfilePrototype.cs +++ b/Content.Shared/Humanoid/Prototypes/HumanoidProfilePrototype.cs @@ -1,6 +1,5 @@ using Content.Shared.Preferences; using Robust.Shared.Prototypes; -using static Content.Shared.Humanoid.HumanoidAppearanceState; namespace Content.Shared.Humanoid.Prototypes; diff --git a/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs b/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs index e7e7b5a672..a61470bfdf 100644 --- a/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs +++ b/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs @@ -1,11 +1,10 @@ +using System.Linq; using Content.Shared.Humanoid.Markings; using Content.Shared.Humanoid.Prototypes; -using Robust.Shared.GameStates; -using Robust.Shared.Prototypes; -using System.Linq; using Content.Shared.Preferences; using Robust.Shared.GameObjects.Components.Localization; using Robust.Shared.Network; +using Robust.Shared.Prototypes; namespace Content.Shared.Humanoid; @@ -31,7 +30,6 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem { base.Initialize(); SubscribeLocalEvent(OnInit); - SubscribeLocalEvent(OnGetState); } private void OnInit(EntityUid uid, HumanoidAppearanceComponent humanoid, ComponentInit args) @@ -57,20 +55,6 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem LoadProfile(uid, startingSet.Profile, humanoid); } - private void OnGetState(EntityUid uid, HumanoidAppearanceComponent component, ref ComponentGetState args) - { - args.State = new HumanoidAppearanceState(component.MarkingSet, - component.PermanentlyHidden, - component.HiddenLayers, - component.CustomBaseLayers, - component.Sex, - component.Gender, - component.Age, - component.Species, - component.SkinColor, - component.EyeColor); - } - /// /// Toggles a humanoid's sprite layer visibility. /// @@ -211,7 +195,7 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem return; if (humanoid.CustomBaseLayers.TryGetValue(layer, out var info)) - humanoid.CustomBaseLayers[layer] = info with { ID = id }; + humanoid.CustomBaseLayers[layer] = info with { Id = id }; else humanoid.CustomBaseLayers[layer] = new(id); diff --git a/Content.Shared/Humanoid/SharedHumanoidMarkingModifierSystem.cs b/Content.Shared/Humanoid/SharedHumanoidMarkingModifierSystem.cs index bd0bad9670..68b3533bd4 100644 --- a/Content.Shared/Humanoid/SharedHumanoidMarkingModifierSystem.cs +++ b/Content.Shared/Humanoid/SharedHumanoidMarkingModifierSystem.cs @@ -1,6 +1,5 @@ using Content.Shared.Humanoid.Markings; using Robust.Shared.Serialization; -using static Content.Shared.Humanoid.HumanoidAppearanceState; namespace Content.Shared.Humanoid; diff --git a/Content.Shared/Implants/Components/ImplanterComponent.cs b/Content.Shared/Implants/Components/ImplanterComponent.cs index e681cab047..85891826f9 100644 --- a/Content.Shared/Implants/Components/ImplanterComponent.cs +++ b/Content.Shared/Implants/Components/ImplanterComponent.cs @@ -1,10 +1,7 @@ -using System.Threading; -using Content.Shared.Containers.ItemSlots; -using Content.Shared.DoAfter; +using Content.Shared.Containers.ItemSlots; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; namespace Content.Shared.Implants.Components; /// @@ -12,7 +9,7 @@ namespace Content.Shared.Implants.Components; /// Some can be single use (implant only) or some can draw out an implant /// //TODO: Rework drawing to work with implant cases when surgery is in -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] public sealed partial class ImplanterComponent : Component { public const string ImplanterSlotId = "implanter_slot"; @@ -21,15 +18,14 @@ public sealed partial class ImplanterComponent : Component /// /// Used for implanters that start with specific implants /// - [ViewVariables] - [DataField("implant", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string? Implant; + [DataField] + public EntProtoId? Implant; /// /// The time it takes to implant someone else /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("implantTime")] + [DataField] public float ImplantTime = 5f; //TODO: Remove when surgery is a thing @@ -38,54 +34,37 @@ public sealed partial class ImplanterComponent : Component /// It's excessively long to deter from implant checking any antag /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("drawTime")] + [DataField] public float DrawTime = 60f; /// /// Good for single-use injectors /// - [ViewVariables] - [DataField("implantOnly")] - public bool ImplantOnly = false; + [DataField, AutoNetworkedField] + public bool ImplantOnly; /// /// The current mode of the implanter /// Mode is changed automatically depending if it implants or draws /// - [ViewVariables] - [DataField("currentMode")] + [DataField, AutoNetworkedField] public ImplanterToggleMode CurrentMode; /// /// The name and description of the implant to show on the implanter /// - [ViewVariables] - [DataField("implantData")] + [DataField] public (string, string) ImplantData; /// /// The for this implanter /// - [ViewVariables] - [DataField("implanterSlot", required:true)] + [DataField(required: true)] public ItemSlot ImplanterSlot = new(); public bool UiUpdateNeeded; } -[Serializable, NetSerializable] -public sealed class ImplanterComponentState : ComponentState -{ - public ImplanterToggleMode CurrentMode; - public bool ImplantOnly; - - public ImplanterComponentState(ImplanterToggleMode currentMode, bool implantOnly) - { - CurrentMode = currentMode; - ImplantOnly = implantOnly; - } -} - [Serializable, NetSerializable] public enum ImplanterToggleMode : byte { diff --git a/Content.Shared/Interaction/Components/InteractionRelayComponent.cs b/Content.Shared/Interaction/Components/InteractionRelayComponent.cs index 1f8b4468ad..2ac9c1e4ef 100644 --- a/Content.Shared/Interaction/Components/InteractionRelayComponent.cs +++ b/Content.Shared/Interaction/Components/InteractionRelayComponent.cs @@ -1,5 +1,4 @@ using Robust.Shared.GameStates; -using Robust.Shared.Serialization; namespace Content.Shared.Interaction.Components; @@ -10,27 +9,13 @@ namespace Content.Shared.Interaction.Components; /// /// Note that extreme caution should be taken when using this, as this will probably bypass many normal can-interact checks. /// -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] [Access(typeof(SharedInteractionSystem))] public sealed partial class InteractionRelayComponent : Component { /// /// The entity the interactions are being relayed to. /// - [ViewVariables] + [ViewVariables, AutoNetworkedField] public EntityUid? RelayEntity; } - -/// -/// Contains network state for -/// -[Serializable, NetSerializable] -public sealed class InteractionRelayComponentState : ComponentState -{ - public NetEntity? RelayEntity; - - public InteractionRelayComponentState(NetEntity? relayEntity) - { - RelayEntity = relayEntity; - } -} diff --git a/Content.Shared/Interaction/SharedInteractionSystem.Relay.cs b/Content.Shared/Interaction/SharedInteractionSystem.Relay.cs index f82b8f7876..77e283b93d 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.Relay.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.Relay.cs @@ -1,35 +1,15 @@ using Content.Shared.Interaction.Components; -using Robust.Shared.GameStates; namespace Content.Shared.Interaction; public abstract partial class SharedInteractionSystem { - public void InitializeRelay() - { - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); - } - - private void OnGetState(EntityUid uid, InteractionRelayComponent component, ref ComponentGetState args) - { - args.State = new InteractionRelayComponentState(GetNetEntity(component.RelayEntity)); - } - - private void OnHandleState(EntityUid uid, InteractionRelayComponent component, ref ComponentHandleState args) - { - if (args.Current is not InteractionRelayComponentState state) - return; - - component.RelayEntity = EnsureEntity(state.RelayEntity, uid); - } - public void SetRelay(EntityUid uid, EntityUid? relayEntity, InteractionRelayComponent? component = null) { if (!Resolve(uid, ref component)) return; component.RelayEntity = relayEntity; - Dirty(component); + Dirty(uid, component); } } diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index 00c357814d..d79a892c71 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -1,4 +1,3 @@ -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Linq; using Content.Shared.ActionBlocker; @@ -7,7 +6,6 @@ using Content.Shared.Administration.Logs; using Content.Shared.Administration.Managers; using Content.Shared.CombatMode; using Content.Shared.Database; -using Content.Shared.Ghost; using Content.Shared.Hands; using Content.Shared.Hands.Components; using Content.Shared.Input; @@ -28,7 +26,6 @@ using Content.Shared.Verbs; using Content.Shared.Wall; using JetBrains.Annotations; using Robust.Shared.Containers; -using Robust.Shared.GameObjects; using Robust.Shared.Input; using Robust.Shared.Input.Binding; using Robust.Shared.Map; @@ -99,7 +96,6 @@ namespace Content.Shared.Interaction new PointerInputCmdHandler(HandleTryPullObject)) .Register(); - InitializeRelay(); InitializeBlocking(); } diff --git a/Content.Shared/Jittering/JitteringComponent.cs b/Content.Shared/Jittering/JitteringComponent.cs index cd8e3aeea7..237629f291 100644 --- a/Content.Shared/Jittering/JitteringComponent.cs +++ b/Content.Shared/Jittering/JitteringComponent.cs @@ -1,33 +1,20 @@ using System.Numerics; using Robust.Shared.GameStates; -using Robust.Shared.Serialization; -namespace Content.Shared.Jittering +namespace Content.Shared.Jittering; + +[Access(typeof(SharedJitteringSystem))] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +public sealed partial class JitteringComponent : Component { - [Access(typeof(SharedJitteringSystem))] - [RegisterComponent, NetworkedComponent] - public sealed partial class JitteringComponent : Component - { - [ViewVariables(VVAccess.ReadWrite)] - public float Amplitude { get; set; } + [AutoNetworkedField] + [ViewVariables(VVAccess.ReadWrite)] + public float Amplitude { get; set; } - [ViewVariables(VVAccess.ReadWrite)] - public float Frequency { get; set; } + [AutoNetworkedField] + [ViewVariables(VVAccess.ReadWrite)] + public float Frequency { get; set; } - [ViewVariables(VVAccess.ReadWrite)] - public Vector2 LastJitter { get; set; } - } - - [Serializable, NetSerializable] - public sealed class JitteringComponentState : ComponentState - { - public float Amplitude { get; } - public float Frequency { get; } - - public JitteringComponentState(float amplitude, float frequency) - { - Amplitude = amplitude; - Frequency = frequency; - } - } + [ViewVariables(VVAccess.ReadWrite)] + public Vector2 LastJitter { get; set; } } diff --git a/Content.Shared/Jittering/SharedJitteringSystem.cs b/Content.Shared/Jittering/SharedJitteringSystem.cs index e0cb2463f9..327a452175 100644 --- a/Content.Shared/Jittering/SharedJitteringSystem.cs +++ b/Content.Shared/Jittering/SharedJitteringSystem.cs @@ -1,6 +1,5 @@ using Content.Shared.Rejuvenate; using Content.Shared.StatusEffect; -using Robust.Shared.GameStates; using Robust.Shared.Timing; namespace Content.Shared.Jittering @@ -21,25 +20,9 @@ namespace Content.Shared.Jittering public override void Initialize() { - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); SubscribeLocalEvent(OnRejuvenate); } - private void OnGetState(EntityUid uid, JitteringComponent component, ref ComponentGetState args) - { - args.State = new JitteringComponentState(component.Amplitude, component.Frequency); - } - - private void OnHandleState(EntityUid uid, JitteringComponent component, ref ComponentHandleState args) - { - if (args.Current is not JitteringComponentState jitteringState) - return; - - component.Amplitude = jitteringState.Amplitude; - component.Frequency = jitteringState.Frequency; - } - private void OnRejuvenate(EntityUid uid, JitteringComponent component, RejuvenateEvent args) { EntityManager.RemoveComponentDeferred(uid); diff --git a/Content.Shared/Lathe/LatheComponent.cs b/Content.Shared/Lathe/LatheComponent.cs index 411695b46d..410db3c86f 100644 --- a/Content.Shared/Lathe/LatheComponent.cs +++ b/Content.Shared/Lathe/LatheComponent.cs @@ -2,42 +2,42 @@ using Content.Shared.Construction.Prototypes; using Content.Shared.Research.Prototypes; using Robust.Shared.Audio; using Robust.Shared.GameStates; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; +using Robust.Shared.Prototypes; namespace Content.Shared.Lathe { - [RegisterComponent, NetworkedComponent] + [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class LatheComponent : Component { /// /// All of the recipes that the lathe has by default /// - [DataField("staticRecipes", customTypeSerializer: typeof(PrototypeIdListSerializer))] - public List StaticRecipes = new(); + [DataField] + public List> StaticRecipes = new(); /// /// All of the recipes that the lathe is capable of researching /// - [DataField("dynamicRecipes", customTypeSerializer: typeof(PrototypeIdListSerializer))] - public List DynamicRecipes = new(); + [DataField] + public List> DynamicRecipes = new(); /// /// The lathe's construction queue /// - [DataField("queue")] + [DataField] public List Queue = new(); /// /// The sound that plays when the lathe is producing an item, if any /// - [DataField("producingSound")] + [DataField] public SoundSpecifier? ProducingSound; + #region Visualizer info - [DataField("idleState", required: true)] + [DataField(required: true)] public string IdleState = default!; - [DataField("runningState", required: true)] + [DataField(required: true)] public string RunningState = default!; #endregion @@ -50,7 +50,7 @@ namespace Content.Shared.Lathe /// /// Whether the lathe can eject the materials stored within it /// - [DataField("canEjectStoredMaterials")] + [DataField] public bool CanEjectStoredMaterials = true; #region MachineUpgrading @@ -63,31 +63,31 @@ namespace Content.Shared.Lathe /// /// The machine part that reduces how long it takes to print a recipe. /// - [DataField("machinePartPrintSpeed", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string MachinePartPrintTime = "Manipulator"; + [DataField] + public ProtoId MachinePartPrintSpeed = "Manipulator"; /// /// The value that is used to calculate the modified /// - [DataField("partRatingPrintTimeMultiplier")] + [DataField] public float PartRatingPrintTimeMultiplier = 0.5f; /// /// A modifier that changes how much of a material is needed to print a recipe /// - [ViewVariables(VVAccess.ReadWrite)] + [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public float MaterialUseMultiplier = 1; /// /// The machine part that reduces how much material it takes to print a recipe. /// - [DataField("machinePartMaterialUse", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string MachinePartMaterialUse = "MatterBin"; + [DataField] + public ProtoId MachinePartMaterialUse = "MatterBin"; /// /// The value that is used to calculate the modifier /// - [DataField("partRatingMaterialUseMultiplier")] + [DataField] public float PartRatingMaterialUseMultiplier = DefaultPartRatingMaterialUseMultiplier; public const float DefaultPartRatingMaterialUseMultiplier = 0.85f; @@ -98,7 +98,7 @@ namespace Content.Shared.Lathe { public readonly EntityUid Lathe; - public List Recipes = new(); + public List> Recipes = new(); public LatheGetRecipesEvent(EntityUid lathe) { diff --git a/Content.Shared/Lathe/LatheMessages.cs b/Content.Shared/Lathe/LatheMessages.cs index 7b28c3f5b0..820c496d30 100644 --- a/Content.Shared/Lathe/LatheMessages.cs +++ b/Content.Shared/Lathe/LatheMessages.cs @@ -1,4 +1,5 @@ using Content.Shared.Research.Prototypes; +using Robust.Shared.Prototypes; using Robust.Shared.Serialization; namespace Content.Shared.Lathe; @@ -6,13 +7,13 @@ namespace Content.Shared.Lathe; [Serializable, NetSerializable] public sealed class LatheUpdateState : BoundUserInterfaceState { - public List Recipes; + public List> Recipes; public List Queue; public LatheRecipePrototype? CurrentlyProducing; - public LatheUpdateState(List recipes, List queue, LatheRecipePrototype? currentlyProducing = null) + public LatheUpdateState(List> recipes, List queue, LatheRecipePrototype? currentlyProducing = null) { Recipes = recipes; Queue = queue; diff --git a/Content.Shared/Lathe/SharedLatheSystem.cs b/Content.Shared/Lathe/SharedLatheSystem.cs index e31925ec6d..e9482d24d1 100644 --- a/Content.Shared/Lathe/SharedLatheSystem.cs +++ b/Content.Shared/Lathe/SharedLatheSystem.cs @@ -2,10 +2,7 @@ using Content.Shared.Emag.Systems; using Content.Shared.Materials; using Content.Shared.Research.Prototypes; using JetBrains.Annotations; -using Robust.Shared.GameStates; using Robust.Shared.Prototypes; -using Robust.Shared.Serialization; -using System.Net.Mail; namespace Content.Shared.Lathe; @@ -21,23 +18,9 @@ public abstract class SharedLatheSystem : EntitySystem { base.Initialize(); - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); SubscribeLocalEvent(OnEmagged); } - private void OnGetState(EntityUid uid, LatheComponent component, ref ComponentGetState args) - { - args.State = new LatheComponentState(component.MaterialUseMultiplier); - } - - private void OnHandleState(EntityUid uid, LatheComponent component, ref ComponentHandleState args) - { - if (args.Current is not LatheComponentState state) - return; - component.MaterialUseMultiplier = state.MaterialUseMultiplier; - } - [PublicAPI] public bool CanProduce(EntityUid uid, string recipe, int amount = 1, LatheComponent? component = null) { @@ -71,14 +54,3 @@ public abstract class SharedLatheSystem : EntitySystem protected abstract bool HasRecipe(EntityUid uid, LatheRecipePrototype recipe, LatheComponent component); } - -[Serializable, NetSerializable] -public sealed class LatheComponentState : ComponentState -{ - public float MaterialUseMultiplier; - - public LatheComponentState(float materialUseMultiplier) - { - MaterialUseMultiplier = materialUseMultiplier; - } -} diff --git a/Content.Shared/Materials/InsertingMaterialStorageComponent.cs b/Content.Shared/Materials/InsertingMaterialStorageComponent.cs index e841853c8e..007dc73345 100644 --- a/Content.Shared/Materials/InsertingMaterialStorageComponent.cs +++ b/Content.Shared/Materials/InsertingMaterialStorageComponent.cs @@ -1,31 +1,18 @@ using Robust.Shared.GameStates; -using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; namespace Content.Shared.Materials; -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class InsertingMaterialStorageComponent : Component { /// /// The time when insertion ends. /// - [DataField("endTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)] + [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField] + [ViewVariables(VVAccess.ReadWrite)] public TimeSpan EndTime; - [ViewVariables] + [ViewVariables, AutoNetworkedField] public Color? MaterialColor; } - -[Serializable, NetSerializable] -public sealed class InsertingMaterialStorageComponentState : ComponentState -{ - public TimeSpan EndTime; - public Color? MaterialColor; - - public InsertingMaterialStorageComponentState(TimeSpan endTime, Color? materialColor) - { - EndTime = endTime; - MaterialColor = materialColor; - } -} diff --git a/Content.Shared/Materials/MaterialReclaimerComponent.cs b/Content.Shared/Materials/MaterialReclaimerComponent.cs index 6108176352..761469f99a 100644 --- a/Content.Shared/Materials/MaterialReclaimerComponent.cs +++ b/Content.Shared/Materials/MaterialReclaimerComponent.cs @@ -3,9 +3,9 @@ using Content.Shared.Construction.Prototypes; using Content.Shared.Whitelist; using Robust.Shared.Audio; using Robust.Shared.GameStates; +using Robust.Shared.Prototypes; using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; namespace Content.Shared.Materials; @@ -13,27 +13,28 @@ namespace Content.Shared.Materials; /// This is a machine that handles converting entities /// into the raw materials and chemicals that make them up. /// -[RegisterComponent, NetworkedComponent, Access(typeof(SharedMaterialReclaimerSystem))] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +[Access(typeof(SharedMaterialReclaimerSystem))] public sealed partial class MaterialReclaimerComponent : Component { /// /// Whether or not the machine has power. We put it here /// so we can network and predict it. /// - [DataField("powered"), ViewVariables(VVAccess.ReadWrite)] + [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)] public bool Powered; /// /// An "enable" toggle for things like interfacing with machine linking /// - [DataField("enabled"), ViewVariables(VVAccess.ReadWrite)] + [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)] public bool Enabled = true; /// /// How efficiently the materials are reclaimed. /// In practice, a multiplier per material when calculating the output of the reclaimer. /// - [DataField("efficiency"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public float Efficiency = 1f; /// @@ -41,46 +42,46 @@ public sealed partial class MaterialReclaimerComponent : Component /// speed scales with the amount of materials being processed /// or if it's just /// - [DataField("scaleProcessSpeed")] + [DataField] public bool ScaleProcessSpeed = true; /// /// How quickly it takes to consume X amount of materials per second. /// For example, with a rate of 50, an entity with 100 total material takes 2 seconds to process. /// - [DataField("baseMaterialProcessRate"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public float BaseMaterialProcessRate = 100f; /// /// How quickly it takes to consume X amount of materials per second. /// For example, with a rate of 50, an entity with 100 total material takes 2 seconds to process. /// - [DataField("materialProcessRate"), ViewVariables(VVAccess.ReadWrite)] + [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)] public float MaterialProcessRate = 100f; /// /// Machine part whose rating modifies /// - [DataField("machinePartProcessRate", customTypeSerializer: typeof(PrototypeIdSerializer)), ViewVariables(VVAccess.ReadWrite)] - public string MachinePartProcessRate = "Manipulator"; + [DataField, ViewVariables(VVAccess.ReadWrite)] + public ProtoId MachinePartProcessRate = "Manipulator"; /// /// How much the machine part quality affects the /// - [DataField("partRatingProcessRateMultiplier"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public float PartRatingProcessRateMultiplier = 1.5f; /// /// The minimum amount fo time it can take to process an entity. /// this value supercedes the calculated one using /// - [DataField("minimumProcessDuration"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public TimeSpan MinimumProcessDuration = TimeSpan.FromSeconds(0.5f); /// /// The id of our output solution /// - [DataField("solutionContainerId"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public string SolutionContainerId = "output"; /// @@ -92,37 +93,37 @@ public sealed partial class MaterialReclaimerComponent : Component /// /// a whitelist for what entities can be inserted into this reclaimer /// - [DataField("whitelist")] + [DataField] public EntityWhitelist? Whitelist; /// /// a blacklist for what entities cannot be inserted into this reclaimer /// - [DataField("blacklist")] + [DataField] public EntityWhitelist? Blacklist; /// /// The sound played when something is being processed. /// - [DataField("sound")] + [DataField] public SoundSpecifier? Sound; /// /// whether or not we cut off the sound early when the reclaiming ends. /// - [DataField("cutOffSound")] + [DataField] public bool CutOffSound = true; /// /// When the next sound will be allowed to be played. Used to prevent spam. /// - [DataField("nextSound", customTypeSerializer: typeof(TimeOffsetSerializer))] + [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))] public TimeSpan NextSound; /// /// Minimum time inbetween each /// - [DataField("soundCooldown")] + [DataField] public TimeSpan SoundCooldown = TimeSpan.FromSeconds(0.8f); public IPlayingAudioStream? Stream; @@ -133,30 +134,10 @@ public sealed partial class MaterialReclaimerComponent : Component /// /// I saw this on the recycler and i'm porting it because it's cute af /// - [DataField("itemsProcessed")] + [DataField, AutoNetworkedField] public int ItemsProcessed; } -[Serializable, NetSerializable] -public sealed class MaterialReclaimerComponentState : ComponentState -{ - public bool Powered; - - public bool Enabled; - - public float MaterialProcessRate; - - public int ItemsProcessed; - - public MaterialReclaimerComponentState(bool powered, bool enabled, float materialProcessRate, int itemsProcessed) - { - Powered = powered; - Enabled = enabled; - MaterialProcessRate = materialProcessRate; - ItemsProcessed = itemsProcessed; - } -} - [NetSerializable, Serializable] public enum RecyclerVisuals { diff --git a/Content.Shared/Materials/MaterialStorageComponent.cs b/Content.Shared/Materials/MaterialStorageComponent.cs index 50935bcd47..c905478bca 100644 --- a/Content.Shared/Materials/MaterialStorageComponent.cs +++ b/Content.Shared/Materials/MaterialStorageComponent.cs @@ -1,67 +1,65 @@ using Content.Shared.Whitelist; using Robust.Shared.Audio; using Robust.Shared.GameStates; +using Robust.Shared.Prototypes; using Robust.Shared.Serialization; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; namespace Content.Shared.Materials; +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] [Access(typeof(SharedMaterialStorageSystem))] -[RegisterComponent, NetworkedComponent] public sealed partial class MaterialStorageComponent : Component { - [DataField("storage", customTypeSerializer: typeof(PrototypeIdDictionarySerializer))] - public Dictionary Storage { get; set; } = new(); + [DataField, AutoNetworkedField] + public Dictionary, int> Storage { get; set; } = new(); /// /// Whether or not interacting with the materialstorage inserts the material in hand. /// - [DataField("insertOnInteract")] + [DataField] public bool InsertOnInteract = true; /// /// How much material the storage can store in total. /// - [ViewVariables(VVAccess.ReadWrite), DataField("storageLimit")] + [ViewVariables(VVAccess.ReadWrite), DataField] public int? StorageLimit; /// /// Whitelist for specifying the kind of items that can be insert into this entity. /// - [DataField("whitelist")] - public EntityWhitelist? EntityWhitelist; + [DataField] + public EntityWhitelist? Whitelist; /// /// Whether or not to drop contained materials when deconstructed. /// - [DataField("dropOnDeconstruct")] + [DataField] public bool DropOnDeconstruct = true; /// /// Whitelist generated on runtime for what specific materials can be inserted into this entity. /// - [DataField("materialWhiteList", customTypeSerializer: typeof(PrototypeIdListSerializer))] - public List? MaterialWhiteList; + [DataField, AutoNetworkedField] + public List>? MaterialWhiteList; /// /// Whether or not the visualization for the insertion animation /// should ignore the color of the material being inserted. /// - [DataField("ignoreColor")] + [DataField] public bool IgnoreColor; /// /// The sound that plays when inserting an item into the storage /// - [DataField("insertingSound")] + [DataField] public SoundSpecifier? InsertingSound; /// /// How long the inserting animation will play /// - [DataField("insertionTime")] + [DataField] public TimeSpan InsertionTime = TimeSpan.FromSeconds(0.79f); // 0.01 off for animation timing } @@ -94,19 +92,5 @@ public record struct GetMaterialWhitelistEvent(EntityUid Storage) { public readonly EntityUid Storage = Storage; - public List Whitelist = new(); -} - -[Serializable, NetSerializable] -public sealed class MaterialStorageComponentState : ComponentState -{ - public Dictionary Storage; - - public List? MaterialWhitelist; - - public MaterialStorageComponentState(Dictionary storage, List? materialWhitelist) - { - Storage = storage; - MaterialWhitelist = materialWhitelist; - } + public List> Whitelist = new(); } diff --git a/Content.Shared/Materials/SharedMaterialReclaimerSystem.cs b/Content.Shared/Materials/SharedMaterialReclaimerSystem.cs index 54ddc91289..3f5832f69a 100644 --- a/Content.Shared/Materials/SharedMaterialReclaimerSystem.cs +++ b/Content.Shared/Materials/SharedMaterialReclaimerSystem.cs @@ -9,7 +9,6 @@ using Content.Shared.Examine; using Content.Shared.Mobs.Components; using Content.Shared.Stacks; using Robust.Shared.Containers; -using Robust.Shared.GameStates; using Robust.Shared.Physics.Events; using Robust.Shared.Timing; @@ -32,8 +31,6 @@ public abstract class SharedMaterialReclaimerSystem : EntitySystem /// public override void Initialize() { - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); SubscribeLocalEvent(OnShutdown); SubscribeLocalEvent(OnUnpaused); SubscribeLocalEvent(OnExamined); @@ -43,24 +40,6 @@ public abstract class SharedMaterialReclaimerSystem : EntitySystem SubscribeLocalEvent(OnActiveUnpaused); } - private void OnGetState(EntityUid uid, MaterialReclaimerComponent component, ref ComponentGetState args) - { - args.State = new MaterialReclaimerComponentState(component.Powered, - component.Enabled, - component.MaterialProcessRate, - component.ItemsProcessed); - } - - private void OnHandleState(EntityUid uid, MaterialReclaimerComponent component, ref ComponentHandleState args) - { - if (args.Current is not MaterialReclaimerComponentState state) - return; - component.Powered = state.Powered; - component.Enabled = state.Enabled; - component.MaterialProcessRate = state.MaterialProcessRate; - component.ItemsProcessed = state.ItemsProcessed; - } - private void OnShutdown(EntityUid uid, MaterialReclaimerComponent component, ComponentShutdown args) { component.Stream?.Stop(); diff --git a/Content.Shared/Materials/SharedMaterialStorageSystem.cs b/Content.Shared/Materials/SharedMaterialStorageSystem.cs index e54ff3faa3..9e6e000d62 100644 --- a/Content.Shared/Materials/SharedMaterialStorageSystem.cs +++ b/Content.Shared/Materials/SharedMaterialStorageSystem.cs @@ -3,7 +3,6 @@ using Content.Shared.Interaction; using Content.Shared.Interaction.Components; using Content.Shared.Stacks; using JetBrains.Annotations; -using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Timing; @@ -26,10 +25,6 @@ public abstract class SharedMaterialStorageSystem : EntitySystem SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnInteractUsing); - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); - SubscribeLocalEvent(OnGetInsertingState); - SubscribeLocalEvent(OnHandleInsertingState); SubscribeLocalEvent(OnUnpaused); } @@ -52,36 +47,6 @@ public abstract class SharedMaterialStorageSystem : EntitySystem _appearance.SetData(uid, MaterialStorageVisuals.Inserting, false); } - private void OnGetState(EntityUid uid, MaterialStorageComponent component, ref ComponentGetState args) - { - args.State = new MaterialStorageComponentState(component.Storage, component.MaterialWhiteList); - } - - private void OnHandleState(EntityUid uid, MaterialStorageComponent component, ref ComponentHandleState args) - { - if (args.Current is not MaterialStorageComponentState state) - return; - - component.Storage = new Dictionary(state.Storage); - - if (state.MaterialWhitelist != null) - component.MaterialWhiteList = new List(state.MaterialWhitelist); - } - - private void OnGetInsertingState(EntityUid uid, InsertingMaterialStorageComponent component, ref ComponentGetState args) - { - args.State = new InsertingMaterialStorageComponentState(component.EndTime, component.MaterialColor); - } - - private void OnHandleInsertingState(EntityUid uid, InsertingMaterialStorageComponent component, ref ComponentHandleState args) - { - if (args.Current is not InsertingMaterialStorageComponentState state) - return; - - component.EndTime = state.EndTime; - component.MaterialColor = state.MaterialColor; - } - private void OnUnpaused(EntityUid uid, InsertingMaterialStorageComponent component, ref EntityUnpausedEvent args) { component.EndTime += args.PausedTime; @@ -222,7 +187,7 @@ public abstract class SharedMaterialStorageSystem : EntitySystem if (!Resolve(toInsert, ref material, ref composition, false)) return false; - if (storage.EntityWhitelist?.IsValid(toInsert) == false) + if (storage.Whitelist?.IsValid(toInsert) == false) return false; if (HasComp(toInsert)) diff --git a/Content.Shared/Mech/Components/MechComponent.cs b/Content.Shared/Mech/Components/MechComponent.cs index ec8fc62dfb..9bf25f4164 100644 --- a/Content.Shared/Mech/Components/MechComponent.cs +++ b/Content.Shared/Mech/Components/MechComponent.cs @@ -3,9 +3,6 @@ using Content.Shared.Whitelist; using Robust.Shared.Containers; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; -using Robust.Shared.Serialization; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; namespace Content.Shared.Mech.Components; @@ -13,33 +10,33 @@ namespace Content.Shared.Mech.Components; /// A large, pilotable machine that has equipment that is /// powered via an internal battery. /// -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class MechComponent : Component { /// /// How much "health" the mech has left. /// - [ViewVariables(VVAccess.ReadWrite)] + [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public FixedPoint2 Integrity; /// /// The maximum amount of damage the mech can take. /// - [DataField("maxIntegrity")] + [DataField, AutoNetworkedField] public FixedPoint2 MaxIntegrity = 250; /// /// How much energy the mech has. /// Derived from the currently inserted battery. /// - [ViewVariables(VVAccess.ReadWrite)] + [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public FixedPoint2 Energy = 0; /// /// The maximum amount of energy the mech can have. /// Derived from the currently inserted battery. /// - [DataField("maxEnergy")] + [DataField, AutoNetworkedField] public FixedPoint2 MaxEnergy = 0; /// @@ -55,13 +52,13 @@ public sealed partial class MechComponent : Component /// A multiplier used to calculate how much of the damage done to a mech /// is transfered to the pilot /// - [DataField("mechToPilotDamageMultiplier")] + [DataField] public float MechToPilotDamageMultiplier; /// /// Whether the mech has been destroyed and is no longer pilotable. /// - [ViewVariables(VVAccess.ReadWrite)] + [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public bool Broken = false; /// @@ -77,7 +74,7 @@ public sealed partial class MechComponent : Component /// The current selected equipment of the mech. /// If null, the mech is using just its fists. /// - [ViewVariables] + [ViewVariables, AutoNetworkedField] public EntityUid? CurrentSelectedEquipment; /// @@ -89,10 +86,10 @@ public sealed partial class MechComponent : Component /// /// A whitelist for inserting equipment items. /// - [DataField("equipmentWhitelist")] + [DataField] public EntityWhitelist? EquipmentWhitelist; - [DataField("pilotWhitelist")] + [DataField] public EntityWhitelist? PilotWhitelist; /// @@ -107,20 +104,20 @@ public sealed partial class MechComponent : Component /// /// How long it takes to enter the mech. /// - [DataField("entryDelay")] + [DataField] public float EntryDelay = 3; /// /// How long it takes to pull *another person* /// outside of the mech. You can exit instantly yourself. /// - [DataField("exitDelay")] + [DataField] public float ExitDelay = 3; /// /// How long it takes to pull out the battery. /// - [DataField("batteryRemovalDelay")] + [DataField] public float BatteryRemovalDelay = 2; /// @@ -130,31 +127,31 @@ public sealed partial class MechComponent : Component /// This needs to be redone /// when mech internals are added /// - [DataField("airtight"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public bool Airtight; /// /// The equipment that the mech initially has when it spawns. /// Good for things like nukie mechs that start with guns. /// - [DataField("startingEquipment", customTypeSerializer: typeof(PrototypeIdListSerializer))] - public List StartingEquipment = new(); + [DataField] + public List StartingEquipment = new(); #region Action Prototypes - [DataField("mechCycleAction", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string MechCycleAction = "ActionMechCycleEquipment"; - [DataField("mechUiAction", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string MechUiAction = "ActionMechOpenUI"; - [DataField("mechEjectAction", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string MechEjectAction = "ActionMechEject"; + [DataField] + public EntProtoId MechCycleAction = "ActionMechCycleEquipment"; + [DataField] + public EntProtoId MechUiAction = "ActionMechOpenUI"; + [DataField] + public EntProtoId MechEjectAction = "ActionMechEject"; #endregion #region Visualizer States - [DataField("baseState")] + [DataField] public string? BaseState; - [DataField("openState")] + [DataField] public string? OpenState; - [DataField("brokenState")] + [DataField] public string? BrokenState; #endregion @@ -162,17 +159,3 @@ public sealed partial class MechComponent : Component [DataField] public EntityUid? MechUiActionEntity; [DataField] public EntityUid? MechEjectActionEntity; } - -/// -/// Contains network state for . -/// -[Serializable, NetSerializable] -public sealed class MechComponentState : ComponentState -{ - public FixedPoint2 Integrity; - public FixedPoint2 MaxIntegrity; - public FixedPoint2 Energy; - public FixedPoint2 MaxEnergy; - public NetEntity? CurrentSelectedEquipment; - public bool Broken; -} diff --git a/Content.Shared/Mech/Components/MechPilotComponent.cs b/Content.Shared/Mech/Components/MechPilotComponent.cs index 364bd0bf14..64bf7082b7 100644 --- a/Content.Shared/Mech/Components/MechPilotComponent.cs +++ b/Content.Shared/Mech/Components/MechPilotComponent.cs @@ -1,5 +1,4 @@ using Robust.Shared.GameStates; -using Robust.Shared.Serialization; namespace Content.Shared.Mech.Components; @@ -9,18 +8,12 @@ namespace Content.Shared.Mech.Components; /// /// Get in the robot, Shinji /// -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class MechPilotComponent : Component { /// /// The mech being piloted /// - [ViewVariables(VVAccess.ReadWrite)] + [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public EntityUid Mech; } - -[Serializable, NetSerializable] -public sealed class MechPilotComponentState : ComponentState -{ - public NetEntity Mech; -} diff --git a/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs b/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs index 7111c67779..1cb08e1a25 100644 --- a/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs +++ b/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs @@ -16,7 +16,6 @@ using Content.Shared.Movement.Systems; using Content.Shared.Popups; using Content.Shared.Weapons.Melee; using Robust.Shared.Containers; -using Robust.Shared.GameStates; using Robust.Shared.Network; using Robust.Shared.Serialization; using Robust.Shared.Timing; @@ -42,11 +41,6 @@ public abstract class SharedMechSystem : EntitySystem /// public override void Initialize() { - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); - SubscribeLocalEvent(OnPilotGetState); - SubscribeLocalEvent(OnPilotHandleState); - SubscribeLocalEvent(OnToggleEquipmentAction); SubscribeLocalEvent(OnEjectPilotEvent); SubscribeLocalEvent(RelayInteractionEvent); @@ -59,52 +53,6 @@ public abstract class SharedMechSystem : EntitySystem SubscribeLocalEvent(OnAttackAttempt); } - #region State Handling - - private void OnGetState(EntityUid uid, MechComponent component, ref ComponentGetState args) - { - args.State = new MechComponentState - { - Integrity = component.Integrity, - MaxIntegrity = component.MaxIntegrity, - Energy = component.Energy, - MaxEnergy = component.MaxEnergy, - CurrentSelectedEquipment = GetNetEntity(component.CurrentSelectedEquipment), - Broken = component.Broken - }; - } - - private void OnHandleState(EntityUid uid, MechComponent component, ref ComponentHandleState args) - { - if (args.Current is not MechComponentState state) - return; - - component.Integrity = state.Integrity; - component.MaxIntegrity = state.MaxIntegrity; - component.Energy = state.Energy; - component.MaxEnergy = state.MaxEnergy; - component.CurrentSelectedEquipment = EnsureEntity(state.CurrentSelectedEquipment, uid); - component.Broken = state.Broken; - } - - private void OnPilotGetState(EntityUid uid, MechPilotComponent component, ref ComponentGetState args) - { - args.State = new MechPilotComponentState - { - Mech = GetNetEntity(component.Mech) - }; - } - - private void OnPilotHandleState(EntityUid uid, MechPilotComponent component, ref ComponentHandleState args) - { - if (args.Current is not MechPilotComponentState state) - return; - - component.Mech = EnsureEntity(state.Mech, uid); - } - - #endregion - private void OnToggleEquipmentAction(EntityUid uid, MechComponent component, MechToggleEquipmentEvent args) { if (args.Handled) diff --git a/Content.Shared/Movement/Components/FootstepModifierComponent.cs b/Content.Shared/Movement/Components/FootstepModifierComponent.cs index 8856327633..bd7b5377bd 100644 --- a/Content.Shared/Movement/Components/FootstepModifierComponent.cs +++ b/Content.Shared/Movement/Components/FootstepModifierComponent.cs @@ -1,15 +1,14 @@ using Robust.Shared.Audio; using Robust.Shared.GameStates; -namespace Content.Shared.Movement.Components +namespace Content.Shared.Movement.Components; + +/// +/// Changes footstep sound +/// +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +public sealed partial class FootstepModifierComponent : Component { - /// - /// Changes footstep sound - /// - [RegisterComponent, NetworkedComponent] - public sealed partial class FootstepModifierComponent : Component - { - [DataField("footstepSoundCollection", required: true)] - public SoundSpecifier Sound = default!; - } + [DataField(required: true), AutoNetworkedField] + public SoundSpecifier FootstepSoundCollection = default!; } diff --git a/Content.Shared/Movement/Components/InputMoverComponent.cs b/Content.Shared/Movement/Components/InputMoverComponent.cs index 1a987a9b29..5562bfaee4 100644 --- a/Content.Shared/Movement/Components/InputMoverComponent.cs +++ b/Content.Shared/Movement/Components/InputMoverComponent.cs @@ -6,8 +6,7 @@ using Robust.Shared.Timing; namespace Content.Shared.Movement.Components { - [RegisterComponent] - [NetworkedComponent] + [RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] public sealed partial class InputMoverComponent : Component { // This class has to be able to handle server TPS being lower than client FPS. @@ -41,36 +40,40 @@ namespace Content.Shared.Movement.Components public Vector2 CurTickWalkMovement; public Vector2 CurTickSprintMovement; + [AutoNetworkedField] public MoveButtons HeldMoveButtons = MoveButtons.None; /// /// Entity our movement is relative to. /// + [AutoNetworkedField] public EntityUid? RelativeEntity; /// /// Although our movement might be relative to a particular entity we may have an additional relative rotation /// e.g. if we've snapped to a different cardinal direction /// - [ViewVariables] + [ViewVariables, AutoNetworkedField] public Angle TargetRelativeRotation = Angle.Zero; /// /// The current relative rotation. This will lerp towards the . /// - [ViewVariables] public Angle RelativeRotation; + [ViewVariables, AutoNetworkedField] + public Angle RelativeRotation; /// /// If we traverse on / off a grid then set a timer to update our relative inputs. /// - [ViewVariables(VVAccess.ReadWrite), DataField("lerpTarget", customTypeSerializer: typeof(TimeOffsetSerializer))] + [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField] + [ViewVariables(VVAccess.ReadWrite)] public TimeSpan LerpTarget; public const float LerpTime = 1.0f; public bool Sprinting => (HeldMoveButtons & MoveButtons.Walk) == 0x0; - [ViewVariables(VVAccess.ReadWrite)] + [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public bool CanMove { get; set; } = true; } } diff --git a/Content.Shared/Movement/Components/JetpackUserComponent.cs b/Content.Shared/Movement/Components/JetpackUserComponent.cs index b59b677b62..972f8c69c6 100644 --- a/Content.Shared/Movement/Components/JetpackUserComponent.cs +++ b/Content.Shared/Movement/Components/JetpackUserComponent.cs @@ -5,8 +5,9 @@ namespace Content.Shared.Movement.Components; /// /// Added to someone using a jetpack for movement purposes /// -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class JetpackUserComponent : Component { + [AutoNetworkedField] public EntityUid Jetpack; } diff --git a/Content.Shared/Movement/Components/MobMoverComponent.cs b/Content.Shared/Movement/Components/MobMoverComponent.cs index e833f2d4b7..a77f415b93 100644 --- a/Content.Shared/Movement/Components/MobMoverComponent.cs +++ b/Content.Shared/Movement/Components/MobMoverComponent.cs @@ -6,14 +6,13 @@ namespace Content.Shared.Movement.Components /// /// Has additional movement data such as footsteps and weightless grab range for an entity. /// - [RegisterComponent] - [NetworkedComponent()] + [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class MobMoverComponent : Component { private float _stepSoundDistance; - [DataField("grabRange")] public float GrabRange = 1.0f; + [DataField] public float GrabRange = 1.0f; - [DataField("pushStrength")] public float PushStrength = 600f; + [DataField] public float PushStrength = 600f; [ViewVariables(VVAccess.ReadWrite)] public EntityCoordinates LastPosition { get; set; } @@ -32,7 +31,7 @@ namespace Content.Shared.Movement.Components } } - [ViewVariables(VVAccess.ReadWrite)] + [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public float GrabRangeVV { get => GrabRange; @@ -44,7 +43,7 @@ namespace Content.Shared.Movement.Components } } - [ViewVariables(VVAccess.ReadWrite)] + [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public float PushStrengthVV { get => PushStrength; diff --git a/Content.Shared/Movement/Components/MovementSpeedModifierComponent.cs b/Content.Shared/Movement/Components/MovementSpeedModifierComponent.cs index 33270c2034..7efc12a731 100644 --- a/Content.Shared/Movement/Components/MovementSpeedModifierComponent.cs +++ b/Content.Shared/Movement/Components/MovementSpeedModifierComponent.cs @@ -7,8 +7,8 @@ namespace Content.Shared.Movement.Components /// Applies basic movement speed and movement modifiers for an entity. /// If this is not present on the entity then they will use defaults for movement. /// - [RegisterComponent] - [NetworkedComponent, Access(typeof(MovementSpeedModifierSystem))] + [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] + [Access(typeof(MovementSpeedModifierSystem))] public sealed partial class MovementSpeedModifierComponent : Component { // Weightless @@ -25,10 +25,10 @@ namespace Content.Shared.Movement.Components public const float DefaultBaseWalkSpeed = 2.5f; public const float DefaultBaseSprintSpeed = 4.5f; - [ViewVariables] + [AutoNetworkedField, ViewVariables] public float WalkSpeedModifier = 1.0f; - [ViewVariables] + [AutoNetworkedField, ViewVariables] public float SprintSpeedModifier = 1.0f; [ViewVariables(VVAccess.ReadWrite)] @@ -56,55 +56,56 @@ namespace Content.Shared.Movement.Components /// /// Minimum speed a mob has to be moving before applying movement friction. /// - [ViewVariables(VVAccess.ReadWrite), DataField("minimumFrictionSpeed")] + [ViewVariables(VVAccess.ReadWrite), DataField] public float MinimumFrictionSpeed = DefaultMinimumFrictionSpeed; /// /// The negative velocity applied for friction when weightless and providing inputs. /// - [ViewVariables(VVAccess.ReadWrite), DataField("weightlessFriction")] + [ViewVariables(VVAccess.ReadWrite), DataField] public float WeightlessFriction = DefaultWeightlessFriction; /// /// The negative velocity applied for friction when weightless and not providing inputs. /// This is essentially how much their speed decreases per second. /// - [ViewVariables(VVAccess.ReadWrite), DataField("weightlessFrictionNoInput")] + [ViewVariables(VVAccess.ReadWrite), DataField] public float WeightlessFrictionNoInput = DefaultWeightlessFrictionNoInput; /// /// The movement speed modifier applied to a mob's total input velocity when weightless. /// - [ViewVariables(VVAccess.ReadWrite), DataField("weightlessModifier")] + [ViewVariables(VVAccess.ReadWrite), DataField] public float WeightlessModifier = DefaultWeightlessModifier; /// /// The acceleration applied to mobs when moving and weightless. /// - [ViewVariables(VVAccess.ReadWrite), DataField("weightlessAcceleration")] + [ViewVariables(VVAccess.ReadWrite), DataField] public float WeightlessAcceleration = DefaultWeightlessAcceleration; /// /// The acceleration applied to mobs when moving. /// - [ViewVariables(VVAccess.ReadWrite), DataField("acceleration")] + [ViewVariables(VVAccess.ReadWrite), DataField] public float Acceleration = DefaultAcceleration; /// /// The negative velocity applied for friction. /// - [ViewVariables(VVAccess.ReadWrite), DataField("friction")] + [ViewVariables(VVAccess.ReadWrite), DataField] public float Friction = DefaultFriction; /// /// The negative velocity applied for friction. /// - [ViewVariables(VVAccess.ReadWrite), DataField("frictionNoInput")] public float? FrictionNoInput = null; + [ViewVariables(VVAccess.ReadWrite), DataField] + public float? FrictionNoInput; - [ViewVariables(VVAccess.ReadWrite), DataField("baseWalkSpeed")] + [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] public float BaseWalkSpeed { get; set; } = DefaultBaseWalkSpeed; - [ViewVariables(VVAccess.ReadWrite), DataField("baseSprintSpeed")] + [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] public float BaseSprintSpeed { get; set; } = DefaultBaseSprintSpeed; [ViewVariables] diff --git a/Content.Shared/Movement/Systems/MovementSpeedModifierSystem.cs b/Content.Shared/Movement/Systems/MovementSpeedModifierSystem.cs index a83fcf78b2..c95ab379c6 100644 --- a/Content.Shared/Movement/Systems/MovementSpeedModifierSystem.cs +++ b/Content.Shared/Movement/Systems/MovementSpeedModifierSystem.cs @@ -1,9 +1,6 @@ using Content.Shared.Inventory; using Content.Shared.Movement.Components; -using Robust.Shared.GameStates; -using Robust.Shared.Serialization; using Robust.Shared.Timing; -using Robust.Shared.Utility; namespace Content.Shared.Movement.Systems { @@ -11,33 +8,6 @@ namespace Content.Shared.Movement.Systems { [Dependency] private readonly IGameTiming _timing = default!; - public override void Initialize() - { - base.Initialize(); - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); - } - - private void OnGetState(EntityUid uid, MovementSpeedModifierComponent component, ref ComponentGetState args) - { - args.State = new MovementSpeedModifierComponentState - { - BaseWalkSpeed = component.BaseWalkSpeed, - BaseSprintSpeed = component.BaseSprintSpeed, - WalkSpeedModifier = component.WalkSpeedModifier, - SprintSpeedModifier = component.SprintSpeedModifier, - }; - } - - private void OnHandleState(EntityUid uid, MovementSpeedModifierComponent component, ref ComponentHandleState args) - { - if (args.Current is not MovementSpeedModifierComponentState state) return; - component.BaseWalkSpeed = state.BaseWalkSpeed; - component.BaseSprintSpeed = state.BaseSprintSpeed; - component.WalkSpeedModifier = state.WalkSpeedModifier; - component.SprintSpeedModifier = state.SprintSpeedModifier; - } - public void RefreshMovementSpeedModifiers(EntityUid uid, MovementSpeedModifierComponent? move = null) { if (!Resolve(uid, ref move, false)) @@ -68,15 +38,6 @@ namespace Content.Shared.Movement.Systems move.Acceleration = acceleration; Dirty(move); } - - [Serializable, NetSerializable] - private sealed class MovementSpeedModifierComponentState : ComponentState - { - public float BaseWalkSpeed; - public float BaseSprintSpeed; - public float WalkSpeedModifier; - public float SprintSpeedModifier; - } } /// diff --git a/Content.Shared/Movement/Systems/SharedJetpackSystem.cs b/Content.Shared/Movement/Systems/SharedJetpackSystem.cs index 26373da256..f624f6c4ce 100644 --- a/Content.Shared/Movement/Systems/SharedJetpackSystem.cs +++ b/Content.Shared/Movement/Systems/SharedJetpackSystem.cs @@ -5,7 +5,6 @@ using Content.Shared.Movement.Components; using Content.Shared.Movement.Events; using Content.Shared.Popups; using Robust.Shared.Containers; -using Robust.Shared.GameStates; using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Systems; using Robust.Shared.Serialization; @@ -31,8 +30,6 @@ public abstract class SharedJetpackSystem : EntitySystem SubscribeLocalEvent(OnJetpackUserCanWeightless); SubscribeLocalEvent(OnJetpackUserEntParentChanged); - SubscribeLocalEvent(OnJetpackUserGetState); - SubscribeLocalEvent(OnJetpackUserHandleState); SubscribeLocalEvent(OnJetpackUserGravityChanged); } @@ -60,22 +57,6 @@ public abstract class SharedJetpackSystem : EntitySystem } } - private void OnJetpackUserHandleState(EntityUid uid, JetpackUserComponent component, ref ComponentHandleState args) - { - if (args.Current is not JetpackUserComponentState state) - return; - - component.Jetpack = EnsureEntity(state.Jetpack, uid); - } - - private void OnJetpackUserGetState(EntityUid uid, JetpackUserComponent component, ref ComponentGetState args) - { - args.State = new JetpackUserComponentState() - { - Jetpack = GetNetEntity(component.Jetpack), - }; - } - private void OnJetpackDropped(EntityUid uid, JetpackComponent component, DroppedEvent args) { SetEnabled(uid, component, false, args.User); @@ -204,12 +185,6 @@ public abstract class SharedJetpackSystem : EntitySystem { return true; } - - [Serializable, NetSerializable] - protected sealed class JetpackUserComponentState : ComponentState - { - public NetEntity Jetpack; - } } [Serializable, NetSerializable] diff --git a/Content.Shared/Movement/Systems/SharedMoverController.Footsteps.cs b/Content.Shared/Movement/Systems/SharedMoverController.Footsteps.cs deleted file mode 100644 index bbaf2250ec..0000000000 --- a/Content.Shared/Movement/Systems/SharedMoverController.Footsteps.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Content.Shared.Movement.Components; -using Robust.Shared.Audio; -using Robust.Shared.GameStates; -using Robust.Shared.Serialization; - -namespace Content.Shared.Movement.Systems; - -public abstract partial class SharedMoverController -{ - private void InitializeFootsteps() - { - SubscribeLocalEvent(OnFootGetState); - SubscribeLocalEvent(OnFootHandleState); - } - - private void OnFootHandleState(EntityUid uid, FootstepModifierComponent component, ref ComponentHandleState args) - { - if (args.Current is not FootstepModifierComponentState state) return; - component.Sound = state.Sound; - } - - private void OnFootGetState(EntityUid uid, FootstepModifierComponent component, ref ComponentGetState args) - { - args.State = new FootstepModifierComponentState() - { - Sound = component.Sound, - }; - } - - [Serializable, NetSerializable] - private sealed class FootstepModifierComponentState : ComponentState - { - public SoundSpecifier Sound = default!; - } -} diff --git a/Content.Shared/Movement/Systems/SharedMoverController.Input.cs b/Content.Shared/Movement/Systems/SharedMoverController.Input.cs index 9d150a0652..425322408e 100644 --- a/Content.Shared/Movement/Systems/SharedMoverController.Input.cs +++ b/Content.Shared/Movement/Systems/SharedMoverController.Input.cs @@ -4,7 +4,6 @@ using Content.Shared.Follower.Components; using Content.Shared.Input; using Content.Shared.Movement.Components; using Content.Shared.Movement.Events; -using Robust.Shared.GameStates; using Robust.Shared.Input; using Robust.Shared.Input.Binding; using Robust.Shared.Players; @@ -49,8 +48,7 @@ namespace Content.Shared.Movement.Systems .Register(); SubscribeLocalEvent(OnInputInit); - SubscribeLocalEvent(OnInputGetState); - SubscribeLocalEvent(OnInputHandleState); + SubscribeLocalEvent(OnInputHandleState); SubscribeLocalEvent(OnInputParentChange); SubscribeLocalEvent(OnAutoParentChange); @@ -75,31 +73,10 @@ namespace Content.Shared.Movement.Systems Dirty(component); } - private void OnInputHandleState(EntityUid uid, InputMoverComponent component, ref ComponentHandleState args) + private void OnInputHandleState(EntityUid uid, InputMoverComponent component, ref AfterAutoHandleStateEvent args) { - if (args.Current is not InputMoverComponentState state) - return; - - component.HeldMoveButtons = state.Buttons; component.LastInputTick = GameTick.Zero; component.LastInputSubTick = 0; - component.CanMove = state.CanMove; - - component.RelativeRotation = state.RelativeRotation; - component.TargetRelativeRotation = state.TargetRelativeRotation; - component.RelativeEntity = EnsureEntity(state.RelativeEntity, uid); - component.LerpTarget = state.LerpAccumulator; - } - - private void OnInputGetState(EntityUid uid, InputMoverComponent component, ref ComponentGetState args) - { - args.State = new InputMoverComponentState( - component.HeldMoveButtons, - component.CanMove, - component.RelativeRotation, - component.TargetRelativeRotation, - GetNetEntity(component.RelativeEntity), - component.LerpTarget); } private void ShutdownInput() @@ -564,35 +541,6 @@ namespace Content.Shared.Movement.Systems } } - [Serializable, NetSerializable] - private sealed class InputMoverComponentState : ComponentState - { - public MoveButtons Buttons { get; } - public readonly bool CanMove; - - /// - /// Our current rotation for movement purposes. This is lerping towards - /// - public Angle RelativeRotation; - - /// - /// Target rotation relative to the . Typically 0 - /// - public Angle TargetRelativeRotation; - public NetEntity? RelativeEntity; - public TimeSpan LerpAccumulator; - - public InputMoverComponentState(MoveButtons buttons, bool canMove, Angle relativeRotation, Angle targetRelativeRotation, NetEntity? relativeEntity, TimeSpan lerpTarget) - { - Buttons = buttons; - CanMove = canMove; - RelativeRotation = relativeRotation; - TargetRelativeRotation = targetRelativeRotation; - RelativeEntity = relativeEntity; - LerpAccumulator = lerpTarget; - } - } - private sealed class ShuttleInputCmdHandler : InputCmdHandler { private readonly SharedMoverController _controller; @@ -615,6 +563,7 @@ namespace Content.Shared.Movement.Systems } [Flags] + [Serializable, NetSerializable] public enum MoveButtons : byte { None = 0, diff --git a/Content.Shared/Movement/Systems/SharedMoverController.Mob.cs b/Content.Shared/Movement/Systems/SharedMoverController.Mob.cs deleted file mode 100644 index 9f6c2f4a48..0000000000 --- a/Content.Shared/Movement/Systems/SharedMoverController.Mob.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Content.Shared.Movement.Components; -using Robust.Shared.GameStates; -using Robust.Shared.Serialization; - -namespace Content.Shared.Movement.Systems; - -public abstract partial class SharedMoverController -{ - private void InitializeMob() - { - SubscribeLocalEvent(OnMobGetState); - SubscribeLocalEvent(OnMobHandleState); - } - - private void OnMobHandleState(EntityUid uid, MobMoverComponent component, ref ComponentHandleState args) - { - if (args.Current is not MobMoverComponentState state) return; - component.GrabRangeVV = state.GrabRange; - component.PushStrengthVV = state.PushStrength; - } - - private void OnMobGetState(EntityUid uid, MobMoverComponent component, ref ComponentGetState args) - { - args.State = new MobMoverComponentState(component.GrabRange, component.PushStrength); - } - - [Serializable, NetSerializable] - private sealed class MobMoverComponentState : ComponentState - { - public float GrabRange; - public float PushStrength; - - public MobMoverComponentState(float grabRange, float pushStrength) - { - GrabRange = grabRange; - PushStrength = pushStrength; - } - } -} diff --git a/Content.Shared/Movement/Systems/SharedMoverController.cs b/Content.Shared/Movement/Systems/SharedMoverController.cs index a9297b9411..af065d0dec 100644 --- a/Content.Shared/Movement/Systems/SharedMoverController.cs +++ b/Content.Shared/Movement/Systems/SharedMoverController.cs @@ -1,8 +1,12 @@ +using System.Diagnostics.CodeAnalysis; +using System.Numerics; +using Content.Shared.Bed.Sleep; using Content.Shared.CCVar; using Content.Shared.Friction; using Content.Shared.Gravity; using Content.Shared.Inventory; using Content.Shared.Maps; +using Content.Shared.Mobs.Systems; using Content.Shared.Movement.Components; using Content.Shared.Movement.Events; using Content.Shared.Pulling.Components; @@ -12,15 +16,11 @@ using Robust.Shared.Configuration; using Robust.Shared.Containers; using Robust.Shared.Map; using Robust.Shared.Physics; +using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Controllers; +using Robust.Shared.Physics.Systems; using Robust.Shared.Timing; using Robust.Shared.Utility; -using System.Diagnostics.CodeAnalysis; -using System.Numerics; -using Content.Shared.Mobs.Systems; -using Robust.Shared.Physics.Components; -using Robust.Shared.Physics.Systems; -using Content.Shared.Bed.Sleep; namespace Content.Shared.Movement.Systems { @@ -88,9 +88,7 @@ namespace Content.Shared.Movement.Systems NoRotateQuery = GetEntityQuery(); CanMoveInAirQuery = GetEntityQuery(); - InitializeFootsteps(); InitializeInput(); - InitializeMob(); InitializeRelay(); _configManager.OnValueChanged(CCVars.RelativeMovement, SetRelativeMovement, true); _configManager.OnValueChanged(CCVars.StopSpeed, SetStopSpeed, true); @@ -440,14 +438,14 @@ namespace Content.Shared.Movement.Systems if (TryComp(uid, out var moverModifier)) { - sound = moverModifier.Sound; + sound = moverModifier.FootstepSoundCollection; return true; } if (_inventory.TryGetSlotEntity(uid, "shoes", out var shoes) && TryComp(shoes, out var modifier)) { - sound = modifier.Sound; + sound = modifier.FootstepSoundCollection; return true; } @@ -468,7 +466,7 @@ namespace Content.Shared.Movement.Systems { if (TryComp(xform.MapUid, out var modifier)) { - sound = modifier.Sound; + sound = modifier.FootstepSoundCollection; return true; } @@ -494,7 +492,7 @@ namespace Content.Shared.Movement.Systems if (TryComp(maybeFootstep, out var footstep)) { - sound = footstep.Sound; + sound = footstep.FootstepSoundCollection; return true; } } diff --git a/Content.Shared/Physics/Controllers/SharedConveyorController.cs b/Content.Shared/Physics/Controllers/SharedConveyorController.cs index 1ba66aa1a3..8ec6ddbefe 100644 --- a/Content.Shared/Physics/Controllers/SharedConveyorController.cs +++ b/Content.Shared/Physics/Controllers/SharedConveyorController.cs @@ -2,7 +2,6 @@ using Content.Shared.Conveyor; using Content.Shared.Gravity; using Content.Shared.Movement.Systems; -using Robust.Shared.GameStates; using Robust.Shared.Map; using Robust.Shared.Physics; using Robust.Shared.Physics.Components; @@ -26,8 +25,6 @@ public abstract class SharedConveyorController : VirtualController public override void Initialize() { UpdatesAfter.Add(typeof(SharedMoverController)); - SubscribeLocalEvent(OnConveyorGetState); - SubscribeLocalEvent(OnConveyorHandleState); SubscribeLocalEvent(OnConveyorStartCollide); SubscribeLocalEvent(OnConveyorEndCollide); @@ -35,22 +32,6 @@ public abstract class SharedConveyorController : VirtualController base.Initialize(); } - private void OnConveyorGetState(EntityUid uid, ConveyorComponent component, ref ComponentGetState args) - { - args.State = new ConveyorComponentState(component.Angle, component.Speed, component.State, component.Powered); - } - - private void OnConveyorHandleState(EntityUid uid, ConveyorComponent component, ref ComponentHandleState args) - { - if (args.Current is not ConveyorComponentState state) - return; - - component.Powered = state.Powered; - component.Angle = state.Angle; - component.Speed = state.Speed; - component.State = state.State; - } - private void OnConveyorStartCollide(EntityUid uid, ConveyorComponent component, ref StartCollideEvent args) { var otherUid = args.OtherEntity; diff --git a/Content.Shared/Physics/PreventCollideComponent.cs b/Content.Shared/Physics/PreventCollideComponent.cs index 429b7b56b3..af59d36773 100644 --- a/Content.Shared/Physics/PreventCollideComponent.cs +++ b/Content.Shared/Physics/PreventCollideComponent.cs @@ -1,24 +1,14 @@ using Robust.Shared.GameStates; -using Robust.Shared.Serialization; namespace Content.Shared.Physics; /// /// Use this to allow a specific UID to prevent collides /// -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class PreventCollideComponent : Component { + [AutoNetworkedField] public EntityUid Uid; } -[Serializable, NetSerializable] -public sealed class PreventCollideComponentState : ComponentState -{ - public NetEntity Uid; - - public PreventCollideComponentState(NetEntity netEntity) - { - Uid = netEntity; - } -} diff --git a/Content.Shared/Physics/SharedPreventCollideSystem.cs b/Content.Shared/Physics/SharedPreventCollideSystem.cs index 408125e140..83d3a918e8 100644 --- a/Content.Shared/Physics/SharedPreventCollideSystem.cs +++ b/Content.Shared/Physics/SharedPreventCollideSystem.cs @@ -1,6 +1,4 @@ -using Robust.Shared.GameStates; -using Robust.Shared.Physics.Dynamics; -using Robust.Shared.Physics.Events; +using Robust.Shared.Physics.Events; namespace Content.Shared.Physics; @@ -10,24 +8,9 @@ public sealed class SharedPreventCollideSystem : EntitySystem { base.Initialize(); - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); SubscribeLocalEvent(OnPreventCollide); } - private void OnGetState(EntityUid uid, PreventCollideComponent component, ref ComponentGetState args) - { - args.State = new PreventCollideComponentState(GetNetEntity(component.Uid)); - } - - private void OnHandleState(EntityUid uid, PreventCollideComponent component, ref ComponentHandleState args) - { - if (args.Current is not PreventCollideComponentState state) - return; - - component.Uid = EnsureEntity(state.Uid, uid); - } - private void OnPreventCollide(EntityUid uid, PreventCollideComponent component, ref PreventCollideEvent args) { if (component.Uid == args.OtherEntity) diff --git a/Content.Shared/Placeable/ItemPlacerComponent.cs b/Content.Shared/Placeable/ItemPlacerComponent.cs index c4fb6079cf..84df2e395a 100644 --- a/Content.Shared/Placeable/ItemPlacerComponent.cs +++ b/Content.Shared/Placeable/ItemPlacerComponent.cs @@ -6,26 +6,27 @@ namespace Content.Shared.Placeable; /// /// Detects items placed on it that match a whitelist. /// -[RegisterComponent, NetworkedComponent, Access(typeof(ItemPlacerSystem))] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +[Access(typeof(ItemPlacerSystem))] public sealed partial class ItemPlacerComponent : Component { /// /// The entities that are currently on top of the placer. /// Guaranteed to have less than enitities if it is set. /// - [DataField("placedEntities")] + [DataField, AutoNetworkedField] public HashSet PlacedEntities = new(); /// /// Whitelist for entities that can be placed. /// - [DataField("whitelist"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public EntityWhitelist? Whitelist; /// /// The max amount of entities that can be placed at the same time. /// If 0, there is no limit. /// - [ViewVariables(VVAccess.ReadWrite), DataField("maxEntities")] + [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] public uint MaxEntities = 1; } diff --git a/Content.Shared/Placeable/ItemPlacerSystem.cs b/Content.Shared/Placeable/ItemPlacerSystem.cs index ccce286214..92dc8eb74b 100644 --- a/Content.Shared/Placeable/ItemPlacerSystem.cs +++ b/Content.Shared/Placeable/ItemPlacerSystem.cs @@ -1,8 +1,5 @@ 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; @@ -21,28 +18,6 @@ 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) @@ -81,13 +56,6 @@ public sealed class ItemPlacerSystem : EntitySystem _placeableSurface.SetPlaceable(uid, true); } - - [Serializable, NetSerializable] - private sealed class ItemPlacerComponentState : ComponentState - { - public uint MaxEntities; - public HashSet Entities = default!; - } } /// diff --git a/Content.Shared/Placeable/PlaceableSurfaceComponent.cs b/Content.Shared/Placeable/PlaceableSurfaceComponent.cs index b30bcedcdb..40fa282ab5 100644 --- a/Content.Shared/Placeable/PlaceableSurfaceComponent.cs +++ b/Content.Shared/Placeable/PlaceableSurfaceComponent.cs @@ -1,35 +1,18 @@ using System.Numerics; using Robust.Shared.GameStates; -using Robust.Shared.Serialization; -namespace Content.Shared.Placeable +namespace Content.Shared.Placeable; + +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +[Access(typeof(PlaceableSurfaceSystem))] +public sealed partial class PlaceableSurfaceComponent : Component { - [RegisterComponent, NetworkedComponent] - [Access(typeof(PlaceableSurfaceSystem))] - public sealed partial class PlaceableSurfaceComponent : Component - { - [DataField("isPlaceable")] - public bool IsPlaceable { get; set; } = true; + [DataField, AutoNetworkedField] + public bool IsPlaceable { get; set; } = true; - [DataField("placeCentered")] - public bool PlaceCentered { get; set; } + [DataField, AutoNetworkedField] + public bool PlaceCentered { get; set; } - [DataField("positionOffset")] - public Vector2 PositionOffset { get; set; } - } - - [Serializable, NetSerializable] - public sealed class PlaceableSurfaceComponentState : ComponentState - { - public readonly bool IsPlaceable; - public readonly bool PlaceCentered; - public readonly Vector2 PositionOffset; - - public PlaceableSurfaceComponentState(bool placeable, bool centered, Vector2 offset) - { - IsPlaceable = placeable; - PlaceCentered = centered; - PositionOffset = offset; - } - } + [DataField, AutoNetworkedField] + public Vector2 PositionOffset { get; set; } } diff --git a/Content.Shared/Placeable/PlaceableSurfaceSystem.cs b/Content.Shared/Placeable/PlaceableSurfaceSystem.cs index 7464c8890c..b0031cfa33 100644 --- a/Content.Shared/Placeable/PlaceableSurfaceSystem.cs +++ b/Content.Shared/Placeable/PlaceableSurfaceSystem.cs @@ -1,8 +1,7 @@ using System.Numerics; -using Content.Shared.Storage.Components; using Content.Shared.Hands.EntitySystems; using Content.Shared.Interaction; -using Robust.Shared.GameStates; +using Content.Shared.Storage.Components; namespace Content.Shared.Placeable { @@ -15,13 +14,6 @@ namespace Content.Shared.Placeable base.Initialize(); SubscribeLocalEvent(OnAfterInteractUsing); - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); - } - - private void OnGetState(EntityUid uid, PlaceableSurfaceComponent component, ref ComponentGetState args) - { - args.State = new PlaceableSurfaceComponentState(component.IsPlaceable, component.PlaceCentered, component.PositionOffset); } public void SetPlaceable(EntityUid uid, bool isPlaceable, PlaceableSurfaceComponent? surface = null) @@ -30,7 +22,7 @@ namespace Content.Shared.Placeable return; surface.IsPlaceable = isPlaceable; - Dirty(surface); + Dirty(uid, surface); } public void SetPlaceCentered(EntityUid uid, bool placeCentered, PlaceableSurfaceComponent? surface = null) @@ -39,7 +31,7 @@ namespace Content.Shared.Placeable return; surface.PlaceCentered = placeCentered; - Dirty(surface); + Dirty(uid, surface); } public void SetPositionOffset(EntityUid uid, Vector2 offset, PlaceableSurfaceComponent? surface = null) @@ -48,7 +40,7 @@ namespace Content.Shared.Placeable return; surface.PositionOffset = offset; - Dirty(surface); + Dirty(uid, surface); } private void OnAfterInteractUsing(EntityUid uid, PlaceableSurfaceComponent surface, AfterInteractUsingEvent args) @@ -74,15 +66,5 @@ namespace Content.Shared.Placeable args.Handled = true; } - - private void OnHandleState(EntityUid uid, PlaceableSurfaceComponent component, ref ComponentHandleState args) - { - if (args.Current is not PlaceableSurfaceComponentState state) - return; - - component.IsPlaceable = state.IsPlaceable; - component.PlaceCentered = state.PlaceCentered; - component.PositionOffset = state.PositionOffset; - } } } diff --git a/Content.Shared/Points/PointManagerComponent.cs b/Content.Shared/Points/PointManagerComponent.cs index 4250d44dc1..91dfef6a4e 100644 --- a/Content.Shared/Points/PointManagerComponent.cs +++ b/Content.Shared/Points/PointManagerComponent.cs @@ -1,7 +1,6 @@ using Content.Shared.FixedPoint; using Robust.Shared.GameStates; using Robust.Shared.Network; -using Robust.Shared.Serialization; using Robust.Shared.Utility; namespace Content.Shared.Points; @@ -9,32 +8,19 @@ namespace Content.Shared.Points; /// /// This is a component that generically stores points for all players. /// -[RegisterComponent, NetworkedComponent, Access(typeof(SharedPointSystem))] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] +[Access(typeof(SharedPointSystem))] public sealed partial class PointManagerComponent : Component { /// /// A dictionary of a player's netuserID to the amount of points they have. /// - [DataField("points")] + [DataField, AutoNetworkedField(true)] public Dictionary Points = new(); /// /// A text-only version of the scoreboard used by the client. /// - [DataField("scoreboard")] + [DataField, AutoNetworkedField] public FormattedMessage Scoreboard = new(); } - -[Serializable, NetSerializable] -public sealed class PointManagerComponentState : ComponentState -{ - public Dictionary Points; - - public FormattedMessage Scoreboard; - - public PointManagerComponentState(Dictionary points, FormattedMessage scoreboard) - { - Points = points; - Scoreboard = scoreboard; - } -} diff --git a/Content.Shared/Radiation/Components/GeigerComponent.cs b/Content.Shared/Radiation/Components/GeigerComponent.cs index ebcd84b3a3..585c1a51dc 100644 --- a/Content.Shared/Radiation/Components/GeigerComponent.cs +++ b/Content.Shared/Radiation/Components/GeigerComponent.cs @@ -9,41 +9,41 @@ namespace Content.Shared.Radiation.Components; /// Geiger counter that shows current radiation level. /// Can be added as a component to clothes. /// -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] [Access(typeof(SharedGeigerSystem))] public sealed partial class GeigerComponent : Component { /// /// If true it will be active only when player equipped it. /// - [DataField("attachedToSuit")] + [DataField] public bool AttachedToSuit; /// /// Is geiger counter currently active? /// If false attached entity will ignore any radiation rays. /// - [DataField("isEnabled")] + [DataField, AutoNetworkedField] public bool IsEnabled; /// /// Should it shows examine message with current radiation level? /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("showExamine")] + [DataField] public bool ShowExamine; /// /// Should it shows item control when equipped by player? /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("showControl")] + [DataField] public bool ShowControl; /// /// Map of sounds that should be play on loop for different radiation levels. /// - [DataField("sounds")] + [DataField] public Dictionary Sounds = new() { {GeigerDangerLevel.Low, new SoundPathSpecifier("/Audio/Items/Geiger/low.ogg")}, @@ -55,13 +55,13 @@ public sealed partial class GeigerComponent : Component /// /// Current radiation level in rad per second. /// - [ViewVariables(VVAccess.ReadOnly)] + [ViewVariables(VVAccess.ReadOnly), AutoNetworkedField] public float CurrentRadiation; /// /// Estimated radiation danger level. /// - [ViewVariables(VVAccess.ReadOnly)] + [ViewVariables(VVAccess.ReadOnly), AutoNetworkedField] public GeigerDangerLevel DangerLevel = GeigerDangerLevel.None; /// @@ -69,7 +69,7 @@ public sealed partial class GeigerComponent : Component /// Because sound is annoying, geiger counter clicks will play /// only for player that equipped it. /// - [ViewVariables(VVAccess.ReadOnly)] + [ViewVariables(VVAccess.ReadOnly), AutoNetworkedField] public EntityUid? User; /// @@ -85,15 +85,6 @@ public sealed partial class GeigerComponent : Component public IPlayingAudioStream? Stream; } -[Serializable, NetSerializable] -public sealed class GeigerComponentState : ComponentState -{ - public float CurrentRadiation; - public GeigerDangerLevel DangerLevel; - public bool IsEnabled; - public NetEntity? User; -} - [Serializable, NetSerializable] public enum GeigerDangerLevel : byte { diff --git a/Content.Shared/Shuttles/Components/IFFComponent.cs b/Content.Shared/Shuttles/Components/IFFComponent.cs index dc834aebf2..24f06e93d4 100644 --- a/Content.Shared/Shuttles/Components/IFFComponent.cs +++ b/Content.Shared/Shuttles/Components/IFFComponent.cs @@ -6,7 +6,8 @@ namespace Content.Shared.Shuttles.Components; /// /// Handles what a grid should look like on radar. /// -[RegisterComponent, NetworkedComponent, Access(typeof(SharedShuttleSystem))] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +[Access(typeof(SharedShuttleSystem))] public sealed partial class IFFComponent : Component { /// @@ -19,13 +20,13 @@ public sealed partial class IFFComponent : Component /// public static readonly Color IFFColor = Color.Aquamarine; - [ViewVariables(VVAccess.ReadWrite), DataField("flags")] + [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] public IFFFlags Flags = IFFFlags.None; /// /// Color for this to show up on IFF. /// - [ViewVariables(VVAccess.ReadWrite), DataField("color")] + [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] public Color Color = IFFColor; } diff --git a/Content.Shared/Shuttles/Components/RadarConsoleComponent.cs b/Content.Shared/Shuttles/Components/RadarConsoleComponent.cs index 952f479822..96018480f1 100644 --- a/Content.Shared/Shuttles/Components/RadarConsoleComponent.cs +++ b/Content.Shared/Shuttles/Components/RadarConsoleComponent.cs @@ -3,7 +3,8 @@ using Robust.Shared.GameStates; namespace Content.Shared.Shuttles.Components; -[RegisterComponent, NetworkedComponent, Access(typeof(SharedRadarConsoleSystem))] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +[Access(typeof(SharedRadarConsoleSystem))] public sealed partial class RadarConsoleComponent : Component { [ViewVariables(VVAccess.ReadWrite)] @@ -16,6 +17,6 @@ public sealed partial class RadarConsoleComponent : Component .SetRange(Owner, value, this); } - [DataField("maxRange")] + [DataField, AutoNetworkedField] public float MaxRange = 256f; } diff --git a/Content.Shared/Shuttles/Systems/SharedRadarConsoleSystem.cs b/Content.Shared/Shuttles/Systems/SharedRadarConsoleSystem.cs index 2e98e89923..a069a2d2e2 100644 --- a/Content.Shared/Shuttles/Systems/SharedRadarConsoleSystem.cs +++ b/Content.Shared/Shuttles/Systems/SharedRadarConsoleSystem.cs @@ -1,6 +1,4 @@ using Content.Shared.Shuttles.Components; -using Robust.Shared.GameStates; -using Robust.Shared.Serialization; namespace Content.Shared.Shuttles.Systems; @@ -9,29 +7,6 @@ public abstract class SharedRadarConsoleSystem : EntitySystem public const float DefaultMinRange = 64f; public const float DefaultMaxRange = 256f; - public override void Initialize() - { - base.Initialize(); - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); - } - - private void OnHandleState(EntityUid uid, RadarConsoleComponent component, ref ComponentHandleState args) - { - if (args.Current is not RadarConsoleComponentState state) - return; - - component.MaxRange = state.Range; - } - - private void OnGetState(EntityUid uid, RadarConsoleComponent component, ref ComponentGetState args) - { - args.State = new RadarConsoleComponentState() - { - Range = component.MaxRange - }; - } - protected virtual void UpdateState(EntityUid uid, RadarConsoleComponent component) { } @@ -45,10 +20,4 @@ public abstract class SharedRadarConsoleSystem : EntitySystem Dirty(uid, component); UpdateState(uid, component); } - - [Serializable, NetSerializable] - protected sealed class RadarConsoleComponentState : ComponentState - { - public float Range; - } } diff --git a/Content.Shared/Shuttles/Systems/SharedShuttleSystem.IFF.cs b/Content.Shared/Shuttles/Systems/SharedShuttleSystem.IFF.cs index a128d76338..587b5fafe0 100644 --- a/Content.Shared/Shuttles/Systems/SharedShuttleSystem.IFF.cs +++ b/Content.Shared/Shuttles/Systems/SharedShuttleSystem.IFF.cs @@ -1,7 +1,5 @@ using Content.Shared.Shuttles.Components; using JetBrains.Annotations; -using Robust.Shared.GameStates; -using Robust.Shared.Serialization; namespace Content.Shared.Shuttles.Systems; @@ -11,12 +9,6 @@ public abstract partial class SharedShuttleSystem * Handles the label visibility on radar controls. This can be hiding the label or applying other effects. */ - private void InitializeIFF() - { - SubscribeLocalEvent(OnIFFGetState); - SubscribeLocalEvent(OnIFFHandleState); - } - protected virtual void UpdateIFFInterfaces(EntityUid gridUid, IFFComponent component) {} /// @@ -61,29 +53,4 @@ public abstract partial class SharedShuttleSystem Dirty(component); UpdateIFFInterfaces(gridUid, component); } - - private void OnIFFHandleState(EntityUid uid, IFFComponent component, ref ComponentHandleState args) - { - if (args.Current is not IFFComponentState state) - return; - - component.Flags = state.Flags; - component.Color = state.Color; - } - - private void OnIFFGetState(EntityUid uid, IFFComponent component, ref ComponentGetState args) - { - args.State = new IFFComponentState() - { - Flags = component.Flags, - Color = component.Color, - }; - } - - [Serializable, NetSerializable] - private sealed class IFFComponentState : ComponentState - { - public IFFFlags Flags; - public Color Color; - } } diff --git a/Content.Shared/Shuttles/Systems/SharedShuttleSystem.cs b/Content.Shared/Shuttles/Systems/SharedShuttleSystem.cs index e75976c585..8471e83df5 100644 --- a/Content.Shared/Shuttles/Systems/SharedShuttleSystem.cs +++ b/Content.Shared/Shuttles/Systems/SharedShuttleSystem.cs @@ -2,11 +2,6 @@ namespace Content.Shared.Shuttles.Systems; public abstract partial class SharedShuttleSystem : EntitySystem { - public override void Initialize() - { - base.Initialize(); - InitializeIFF(); - } } [Flags] diff --git a/Content.Shared/Slippery/SlipperyComponent.cs b/Content.Shared/Slippery/SlipperyComponent.cs index ff395176ed..b470e2cbbd 100644 --- a/Content.Shared/Slippery/SlipperyComponent.cs +++ b/Content.Shared/Slippery/SlipperyComponent.cs @@ -1,7 +1,6 @@ using Content.Shared.StepTrigger.Components; using Robust.Shared.Audio; using Robust.Shared.GameStates; -using Robust.Shared.Serialization; namespace Content.Shared.Slippery { @@ -11,14 +10,13 @@ namespace Content.Shared.Slippery /// /// Requires , see that component for some additional properties. /// - [RegisterComponent] - [NetworkedComponent] + [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class SlipperyComponent : Component { /// /// Path to the sound to be played when a mob slips. /// - [DataField("slipSound")] + [DataField, AutoNetworkedField] [Access(Other = AccessPermissions.ReadWriteExecute)] public SoundSpecifier SlipSound = new SoundPathSpecifier("/Audio/Effects/slip.ogg"); @@ -26,7 +24,7 @@ namespace Content.Shared.Slippery /// How many seconds the mob will be paralyzed for. /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("paralyzeTime")] + [DataField, AutoNetworkedField] [Access(Other = AccessPermissions.ReadWrite)] public float ParalyzeTime = 3f; @@ -34,23 +32,8 @@ namespace Content.Shared.Slippery /// The entity's speed will be multiplied by this to slip it forwards. /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("launchForwardsMultiplier")] + [DataField, AutoNetworkedField] [Access(Other = AccessPermissions.ReadWrite)] public float LaunchForwardsMultiplier = 1f; } - - [Serializable, NetSerializable] - public sealed class SlipperyComponentState : ComponentState - { - public float ParalyzeTime { get; } - public float LaunchForwardsMultiplier { get; } - public string SlipSound { get; } - - public SlipperyComponentState(float paralyzeTime, float launchForwardsMultiplier, string slipSound) - { - ParalyzeTime = paralyzeTime; - LaunchForwardsMultiplier = launchForwardsMultiplier; - SlipSound = slipSound; - } - } } diff --git a/Content.Shared/Slippery/SlipperySystem.cs b/Content.Shared/Slippery/SlipperySystem.cs index a89291aea4..00f023f9a3 100644 --- a/Content.Shared/Slippery/SlipperySystem.cs +++ b/Content.Shared/Slippery/SlipperySystem.cs @@ -5,9 +5,7 @@ using Content.Shared.StatusEffect; using Content.Shared.StepTrigger.Systems; using Content.Shared.Stunnable; using JetBrains.Annotations; -using Robust.Shared.Audio; using Robust.Shared.Containers; -using Robust.Shared.GameStates; using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Systems; @@ -32,22 +30,6 @@ public sealed class SlipperySystem : EntitySystem SubscribeLocalEvent(OnNoSlipAttempt); // as long as slip-resistant mice are never added, this should be fine (otherwise a mouse-hat will transfer it's power to the wearer). SubscribeLocalEvent>((e, c, ev) => OnNoSlipAttempt(e, c, ev.Args)); - SubscribeLocalEvent(OnSlipperyGetState); - SubscribeLocalEvent(OnSlipperyHandleState); - } - - private void OnSlipperyHandleState(EntityUid uid, SlipperyComponent component, ref ComponentHandleState args) - { - if (args.Current is not SlipperyComponentState state) return; - - component.ParalyzeTime = state.ParalyzeTime; - component.LaunchForwardsMultiplier = state.LaunchForwardsMultiplier; - component.SlipSound = new SoundPathSpecifier(state.SlipSound); - } - - private void OnSlipperyGetState(EntityUid uid, SlipperyComponent component, ref ComponentGetState args) - { - args.State = new SlipperyComponentState(component.ParalyzeTime, component.LaunchForwardsMultiplier, _audio.GetSound(component.SlipSound)); } private void HandleStepTrigger(EntityUid uid, SlipperyComponent component, ref StepTriggeredEvent args) diff --git a/Content.Shared/Speech/SpeechComponent.cs b/Content.Shared/Speech/SpeechComponent.cs index f5ef0e0d67..96e05502ad 100644 --- a/Content.Shared/Speech/SpeechComponent.cs +++ b/Content.Shared/Speech/SpeechComponent.cs @@ -1,8 +1,6 @@ -using System.Collections.Specialized; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Audio; using Robust.Shared.GameStates; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary; +using Robust.Shared.Prototypes; namespace Content.Shared.Speech { @@ -10,31 +8,30 @@ namespace Content.Shared.Speech /// Component required for entities to be able to speak. (TODO: Entities can speak fine without this, this only forbids them speak if they have it and enabled is false.) /// Contains the option to let entities make noise when speaking, change speech verbs, datafields for the sounds in question, and relevant AudioParams. /// - [RegisterComponent, NetworkedComponent] + [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class SpeechComponent : Component { - [DataField("enabled"), Access(typeof(SpeechSystem), - Friend = AccessPermissions.ReadWrite, - Other = AccessPermissions.Read)] + [DataField, AutoNetworkedField] + [Access(typeof(SpeechSystem), Friend = AccessPermissions.ReadWrite, Other = AccessPermissions.Read)] public bool Enabled = true; [ViewVariables(VVAccess.ReadWrite)] - [DataField("speechSounds", customTypeSerializer:typeof(PrototypeIdSerializer))] - public string? SpeechSounds; + [DataField] + public ProtoId? SpeechSounds; /// /// What speech verb prototype should be used by default for displaying this entity's messages? /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("speechVerb", customTypeSerializer:typeof(PrototypeIdSerializer))] - public string SpeechVerb = "Default"; + [DataField] + public ProtoId SpeechVerb = "Default"; /// /// A mapping from chat suffixes loc strings to speech verb prototypes that should be conditionally used. /// For things like '?' changing to 'asks' or '!!' making text bold and changing to 'yells'. Can be overridden if necessary. /// - [DataField("suffixSpeechVerbs", customTypeSerializer:typeof(PrototypeIdValueDictionarySerializer))] - public Dictionary SuffixSpeechVerbs = new() + [DataField] + public Dictionary> SuffixSpeechVerbs = new() { { "chat-speech-verb-suffix-exclamation-strong", "DefaultExclamationStrong" }, { "chat-speech-verb-suffix-exclamation", "DefaultExclamation" }, @@ -43,11 +40,11 @@ namespace Content.Shared.Speech { "chat-speech-verb-suffix-mumble", "DefaultMumble" }, }; - [DataField("audioParams")] + [DataField] public AudioParams AudioParams = AudioParams.Default.WithVolume(6f).WithRolloffFactor(4.5f); [ViewVariables(VVAccess.ReadWrite)] - [DataField("soundCooldownTime")] + [DataField] public float SoundCooldownTime { get; set; } = 0.5f; public TimeSpan LastTimeSoundPlayed = TimeSpan.Zero; diff --git a/Content.Shared/Speech/SpeechSystem.cs b/Content.Shared/Speech/SpeechSystem.cs index a21158aa9e..4ce408b91a 100644 --- a/Content.Shared/Speech/SpeechSystem.cs +++ b/Content.Shared/Speech/SpeechSystem.cs @@ -1,6 +1,3 @@ -using Robust.Shared.GameStates; -using Robust.Shared.Serialization; - namespace Content.Shared.Speech { public sealed class SpeechSystem : EntitySystem @@ -10,8 +7,6 @@ namespace Content.Shared.Speech base.Initialize(); SubscribeLocalEvent(OnSpeakAttempt); - SubscribeLocalEvent(OnSpeechGetState); - SubscribeLocalEvent(OnSpeechHandleState); } public void SetSpeech(EntityUid uid, bool value, SpeechComponent? component = null) @@ -27,34 +22,10 @@ namespace Content.Shared.Speech Dirty(component); } - private void OnSpeechHandleState(EntityUid uid, SpeechComponent component, ref ComponentHandleState args) - { - if (args.Current is not SpeechComponentState state) - return; - - component.Enabled = state.Enabled; - } - - private void OnSpeechGetState(EntityUid uid, SpeechComponent component, ref ComponentGetState args) - { - args.State = new SpeechComponentState(component.Enabled); - } - private void OnSpeakAttempt(SpeakAttemptEvent args) { if (!TryComp(args.Uid, out SpeechComponent? speech) || !speech.Enabled) args.Cancel(); } - - [Serializable, NetSerializable] - private sealed class SpeechComponentState : ComponentState - { - public readonly bool Enabled; - - public SpeechComponentState(bool enabled) - { - Enabled = enabled; - } - } } } diff --git a/Content.Shared/Standing/StandingStateComponent.cs b/Content.Shared/Standing/StandingStateComponent.cs index 583839fa10..b1ec6d8668 100644 --- a/Content.Shared/Standing/StandingStateComponent.cs +++ b/Content.Shared/Standing/StandingStateComponent.cs @@ -3,22 +3,22 @@ using Robust.Shared.GameStates; namespace Content.Shared.Standing { + [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] [Access(typeof(StandingStateSystem))] - [RegisterComponent, NetworkedComponent] public sealed partial class StandingStateComponent : Component { [ViewVariables(VVAccess.ReadWrite)] - [DataField("downSound")] + [DataField] public SoundSpecifier DownSound { get; private set; } = new SoundCollectionSpecifier("BodyFall"); - [DataField("standing")] + [DataField, AutoNetworkedField] public bool Standing { get; set; } = true; /// /// List of fixtures that had their collision mask changed when the entity was downed. /// Required for re-adding the collision mask. /// - [DataField("changedFixtures")] + [DataField, AutoNetworkedField(true)] public List ChangedFixtures = new(); } } diff --git a/Content.Shared/Standing/StandingStateSystem.cs b/Content.Shared/Standing/StandingStateSystem.cs index 2716ed02df..bb74a088b3 100644 --- a/Content.Shared/Standing/StandingStateSystem.cs +++ b/Content.Shared/Standing/StandingStateSystem.cs @@ -2,10 +2,8 @@ using Content.Shared.Hands.Components; using Content.Shared.Physics; using Content.Shared.Rotation; using Robust.Shared.Audio; -using Robust.Shared.GameStates; using Robust.Shared.Physics; using Robust.Shared.Physics.Systems; -using Robust.Shared.Serialization; namespace Content.Shared.Standing { @@ -18,26 +16,6 @@ namespace Content.Shared.Standing // If StandingCollisionLayer value is ever changed to more than one layer, the logic needs to be edited. private const int StandingCollisionLayer = (int) CollisionGroup.MidImpassable; - public override void Initialize() - { - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); - } - - private void OnHandleState(EntityUid uid, StandingStateComponent component, ref ComponentHandleState args) - { - if (args.Current is not StandingComponentState state) - return; - - component.Standing = state.Standing; - component.ChangedFixtures = new List(state.ChangedFixtures); - } - - private void OnGetState(EntityUid uid, StandingStateComponent component, ref ComponentGetState args) - { - args.State = new StandingComponentState(component.Standing, component.ChangedFixtures); - } - public bool IsDown(EntityUid uid, StandingStateComponent? standingState = null) { if (!Resolve(uid, ref standingState, false)) @@ -151,20 +129,6 @@ namespace Content.Shared.Standing return true; } - - // I'm not calling it StandingStateComponentState - [Serializable, NetSerializable] - private sealed class StandingComponentState : ComponentState - { - public bool Standing { get; } - public List ChangedFixtures { get; } - - public StandingComponentState(bool standing, List changedFixtures) - { - Standing = standing; - ChangedFixtures = changedFixtures; - } - } } public sealed class DropHandItemsEvent : EventArgs diff --git a/Content.Shared/StepTrigger/Components/StepTriggerComponent.cs b/Content.Shared/StepTrigger/Components/StepTriggerComponent.cs index 21cf5397a1..c4457179a9 100644 --- a/Content.Shared/StepTrigger/Components/StepTriggerComponent.cs +++ b/Content.Shared/StepTrigger/Components/StepTriggerComponent.cs @@ -1,58 +1,56 @@ using Content.Shared.StepTrigger.Systems; using Content.Shared.Whitelist; using Robust.Shared.GameStates; -using Robust.Shared.Serialization; namespace Content.Shared.StepTrigger.Components; -[RegisterComponent] -[NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] [Access(typeof(StepTriggerSystem))] public sealed partial class StepTriggerComponent : Component { /// /// List of entities that are currently colliding with the entity. /// - [ViewVariables] - public readonly HashSet Colliding = new(); + [ViewVariables, AutoNetworkedField(true)] + public HashSet Colliding = new(); /// /// The list of entities that are standing on this entity, /// which shouldn't be able to trigger it again until stepping off. /// - [ViewVariables] - public readonly HashSet CurrentlySteppedOn = new(); + [ViewVariables, AutoNetworkedField(true)] + public HashSet CurrentlySteppedOn = new(); /// /// Whether or not this component will currently try to trigger for entities. /// - [DataField("active")] + [DataField, AutoNetworkedField] public bool Active = true; /// /// Ratio of shape intersection for a trigger to occur. /// - [DataField("intersectRatio")] + [DataField, AutoNetworkedField] public float IntersectRatio = 0.3f; /// /// Entities will only be triggered if their speed exceeds this limit. /// - [DataField("requiredTriggeredSpeed")] - public float RequiredTriggerSpeed = 3.5f; + [DataField, AutoNetworkedField] + public float RequiredTriggeredSpeed = 3.5f; /// /// If any entities occupy the blacklist on the same tile then steptrigger won't work. /// - [DataField("blacklist")] + [DataField] public EntityWhitelist? Blacklist; /// /// If this is true, steptrigger will still occur on entities that are in air / weightless. They do not /// by default. /// - [DataField("ignoreWeightless")] - public bool IgnoreWeightless = false; + [DataField] + public bool IgnoreWeightless; } [RegisterComponent] @@ -61,23 +59,3 @@ public sealed partial class StepTriggerActiveComponent : Component { } - -[Serializable, NetSerializable] -public sealed class StepTriggerComponentState : ComponentState -{ - public float IntersectRatio { get; } - public float RequiredTriggerSpeed { get; } - public readonly HashSet CurrentlySteppedOn; - public readonly HashSet Colliding; - public readonly bool Active; - - public StepTriggerComponentState(float intersectRatio, HashSet currentlySteppedOn, HashSet colliding, float requiredTriggerSpeed, bool active) - { - IntersectRatio = intersectRatio; - CurrentlySteppedOn = currentlySteppedOn; - RequiredTriggerSpeed = requiredTriggerSpeed; - Active = active; - Colliding = colliding; - } -} - diff --git a/Content.Shared/StepTrigger/Systems/StepTriggerSystem.cs b/Content.Shared/StepTrigger/Systems/StepTriggerSystem.cs index 335d9bea9f..ede39b2aa9 100644 --- a/Content.Shared/StepTrigger/Systems/StepTriggerSystem.cs +++ b/Content.Shared/StepTrigger/Systems/StepTriggerSystem.cs @@ -1,6 +1,5 @@ using Content.Shared.Gravity; using Content.Shared.StepTrigger.Components; -using Robust.Shared.GameStates; using Robust.Shared.Map.Components; using Robust.Shared.Physics; using Robust.Shared.Physics.Components; @@ -16,8 +15,7 @@ public sealed class StepTriggerSystem : EntitySystem public override void Initialize() { UpdatesOutsidePrediction = true; - SubscribeLocalEvent(TriggerGetState); - SubscribeLocalEvent(TriggerHandleState); + SubscribeLocalEvent(TriggerHandleState); SubscribeLocalEvent(OnStartCollide); SubscribeLocalEvent(OnEndCollide); @@ -103,7 +101,7 @@ public sealed class StepTriggerSystem : EntitySystem // this is hard to explain var intersect = Box2.Area(otherAabb.Intersect(ourAabb)); var ratio = Math.Max(intersect / Box2.Area(otherAabb), intersect / Box2.Area(ourAabb)); - if (otherPhysics.LinearVelocity.Length() < component.RequiredTriggerSpeed + if (otherPhysics.LinearVelocity.Length() < component.RequiredTriggeredSpeed || component.CurrentlySteppedOn.Contains(otherUid) || ratio < component.IntersectRatio || !CanTrigger(uid, otherUid, component)) @@ -171,24 +169,8 @@ public sealed class StepTriggerSystem : EntitySystem } } - - private void TriggerHandleState(EntityUid uid, StepTriggerComponent component, ref ComponentHandleState args) + private void TriggerHandleState(EntityUid uid, StepTriggerComponent component, ref AfterAutoHandleStateEvent args) { - if (args.Current is not StepTriggerComponentState state) - return; - - component.RequiredTriggerSpeed = state.RequiredTriggerSpeed; - component.IntersectRatio = state.IntersectRatio; - component.Active = state.Active; - var stepped = EnsureEntitySet(state.CurrentlySteppedOn, uid); - var colliding = EnsureEntitySet(state.CurrentlySteppedOn, uid); - - component.CurrentlySteppedOn.Clear(); - component.CurrentlySteppedOn.UnionWith(stepped); - - component.Colliding.Clear(); - component.Colliding.UnionWith(colliding); - if (component.Colliding.Count > 0) { EnsureComp(uid); @@ -199,16 +181,6 @@ public sealed class StepTriggerSystem : EntitySystem } } - private void TriggerGetState(EntityUid uid, StepTriggerComponent component, ref ComponentGetState args) - { - args.State = new StepTriggerComponentState( - component.IntersectRatio, - GetNetEntitySet(component.CurrentlySteppedOn), - GetNetEntitySet(component.Colliding), - component.RequiredTriggerSpeed, - component.Active); - } - public void SetIntersectRatio(EntityUid uid, float ratio, StepTriggerComponent? component = null) { if (!Resolve(uid, ref component)) @@ -226,10 +198,10 @@ public sealed class StepTriggerSystem : EntitySystem if (!Resolve(uid, ref component)) return; - if (MathHelper.CloseToPercent(component.RequiredTriggerSpeed, speed)) + if (MathHelper.CloseToPercent(component.RequiredTriggeredSpeed, speed)) return; - component.RequiredTriggerSpeed = speed; + component.RequiredTriggeredSpeed = speed; Dirty(uid, component); } diff --git a/Content.Shared/Storage/Components/BinComponent.cs b/Content.Shared/Storage/Components/BinComponent.cs index 4294ce1e79..99e2a9844a 100644 --- a/Content.Shared/Storage/Components/BinComponent.cs +++ b/Content.Shared/Storage/Components/BinComponent.cs @@ -3,8 +3,6 @@ using Content.Shared.Whitelist; using Robust.Shared.Containers; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; -using Robust.Shared.Serialization; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; namespace Content.Shared.Storage.Components; @@ -12,7 +10,8 @@ namespace Content.Shared.Storage.Components; /// This is used for things like paper bins, in which /// you can only take off of the top of the bin. /// -[RegisterComponent, NetworkedComponent, Access(typeof(BinSystem))] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +[Access(typeof(BinSystem))] public sealed partial class BinComponent : Component { /// @@ -30,42 +29,25 @@ public sealed partial class BinComponent : Component /// i can handle entities being deleted and removed /// out of order by other systems /// - [DataField("items")] + [DataField, AutoNetworkedField] public List Items = new(); /// /// The items that start in the bin. Sorted in order. /// - [DataField("initialContents", customTypeSerializer: typeof(PrototypeIdListSerializer))] - public List InitialContents = new(); + [DataField] + public List InitialContents = new(); /// /// A whitelist governing what items can be inserted into the bin. /// - [DataField("whitelist")] + [DataField, AutoNetworkedField] public EntityWhitelist? Whitelist; /// /// The maximum amount of items /// that can be stored in the bin. /// - [DataField("maxItems")] + [DataField, AutoNetworkedField] public int MaxItems = 20; } - -[Serializable, NetSerializable] -public sealed class BinComponentState : ComponentState -{ - public List Items; - - public EntityWhitelist? Whitelist; - - public int MaxItems; - - public BinComponentState(List items, EntityWhitelist? whitelist, int maxItems) - { - Items = items; - Whitelist = whitelist; - MaxItems = maxItems; - } -} diff --git a/Content.Shared/Storage/EntitySystems/BinSystem.cs b/Content.Shared/Storage/EntitySystems/BinSystem.cs index e82861f4e1..86726587f0 100644 --- a/Content.Shared/Storage/EntitySystems/BinSystem.cs +++ b/Content.Shared/Storage/EntitySystems/BinSystem.cs @@ -5,7 +5,6 @@ using Content.Shared.Hands.EntitySystems; using Content.Shared.Interaction; using Content.Shared.Storage.Components; using Robust.Shared.Containers; -using Robust.Shared.GameStates; using Robust.Shared.Network; using Robust.Shared.Timing; @@ -27,8 +26,6 @@ public sealed class BinSystem : EntitySystem /// public override void Initialize() { - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); SubscribeLocalEvent(OnStartup); SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnEntRemoved); @@ -36,21 +33,6 @@ public sealed class BinSystem : EntitySystem SubscribeLocalEvent(OnAfterInteractUsing); } - private void OnGetState(EntityUid uid, BinComponent component, ref ComponentGetState args) - { - args.State = new BinComponentState(GetNetEntityList(component.Items), component.Whitelist, component.MaxItems); - } - - private void OnHandleState(EntityUid uid, BinComponent component, ref ComponentHandleState args) - { - if (args.Current is not BinComponentState state) - return; - - component.Items = EnsureEntityList(state.Items, uid); - component.Whitelist = state.Whitelist; - component.MaxItems = state.MaxItems; - } - private void OnStartup(EntityUid uid, BinComponent component, ComponentStartup args) { component.ItemContainer = _container.EnsureContainer(uid, BinContainerId); diff --git a/Content.Shared/Tabletop/Components/TabletopDraggableComponent.cs b/Content.Shared/Tabletop/Components/TabletopDraggableComponent.cs index e1aa281d17..eb8ab36243 100644 --- a/Content.Shared/Tabletop/Components/TabletopDraggableComponent.cs +++ b/Content.Shared/Tabletop/Components/TabletopDraggableComponent.cs @@ -6,11 +6,10 @@ namespace Content.Shared.Tabletop.Components; /// /// Allows an entity to be dragged around by the mouse. The position is updated for all player while dragging. /// -[NetworkedComponent] -[RegisterComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class TabletopDraggableComponent : Component { // The player dragging the piece - [ViewVariables] + [ViewVariables, AutoNetworkedField] public NetUserId? DraggingPlayer; } diff --git a/Content.Shared/Tabletop/SharedTabletopSystem.cs b/Content.Shared/Tabletop/SharedTabletopSystem.cs index 1ff9030341..7bfd9d3457 100644 --- a/Content.Shared/Tabletop/SharedTabletopSystem.cs +++ b/Content.Shared/Tabletop/SharedTabletopSystem.cs @@ -5,7 +5,6 @@ using Content.Shared.Hands.Components; using Content.Shared.Interaction; using Content.Shared.Tabletop.Components; using Content.Shared.Tabletop.Events; -using Robust.Shared.GameStates; using Robust.Shared.Map; using Robust.Shared.Network; using Robust.Shared.Serialization; @@ -22,7 +21,6 @@ namespace Content.Shared.Tabletop public override void Initialize() { - SubscribeLocalEvent(GetDraggableState); SubscribeAllEvent(OnDraggingPlayerChanged); SubscribeAllEvent(OnTabletopMove); } @@ -47,11 +45,6 @@ namespace Content.Shared.Tabletop _transforms.SetLocalPositionNoLerp(transform, msg.Coordinates.Position); } - private void GetDraggableState(EntityUid uid, TabletopDraggableComponent component, ref ComponentGetState args) - { - args.State = new TabletopDraggableComponentState(component.DraggingPlayer); - } - private void OnDraggingPlayerChanged(TabletopDraggingPlayerChangedEvent msg, EntitySessionEventArgs args) { var dragged = GetEntity(msg.DraggedEntityUid); diff --git a/Content.Shared/Teleportation/Components/LinkedEntityComponent.cs b/Content.Shared/Teleportation/Components/LinkedEntityComponent.cs index ae9a1a03d0..f9ad509d1f 100644 --- a/Content.Shared/Teleportation/Components/LinkedEntityComponent.cs +++ b/Content.Shared/Teleportation/Components/LinkedEntityComponent.cs @@ -8,31 +8,21 @@ namespace Content.Shared.Teleportation.Components; /// Represents an entity which is linked to other entities (perhaps portals), and which can be walked through/ /// thrown into to teleport an entity. /// -[RegisterComponent, Access(typeof(LinkedEntitySystem)), NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +[Access(typeof(LinkedEntitySystem))] public sealed partial class LinkedEntityComponent : Component { /// /// The entities that this entity is linked to. /// - [DataField("linkedEntities")] + [DataField, AutoNetworkedField] public HashSet LinkedEntities = new(); /// /// Should this entity be deleted if all of its links are removed? /// - [DataField("deleteOnEmptyLinks")] - public bool DeleteOnEmptyLinks = false; -} - -[Serializable, NetSerializable] -public sealed class LinkedEntityComponentState : ComponentState -{ - public HashSet LinkedEntities; - - public LinkedEntityComponentState(HashSet linkedEntities) - { - LinkedEntities = linkedEntities; - } + [DataField] + public bool DeleteOnEmptyLinks; } [Serializable, NetSerializable] diff --git a/Content.Shared/Teleportation/Components/PortalTimeoutComponent.cs b/Content.Shared/Teleportation/Components/PortalTimeoutComponent.cs index 37441508e1..341c68d7c8 100644 --- a/Content.Shared/Teleportation/Components/PortalTimeoutComponent.cs +++ b/Content.Shared/Teleportation/Components/PortalTimeoutComponent.cs @@ -1,5 +1,4 @@ using Robust.Shared.GameStates; -using Robust.Shared.Serialization; namespace Content.Shared.Teleportation.Components; @@ -7,23 +6,12 @@ namespace Content.Shared.Teleportation.Components; /// Attached to an entity after portal transit to mark that they should not immediately be portaled back /// at the end destination. /// -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class PortalTimeoutComponent : Component { /// /// The portal that was entered. Null if coming from a hand teleporter, etc. /// - [ViewVariables, DataField("enteredPortal")] - public EntityUid? EnteredPortal = null; -} - -[Serializable, NetSerializable] -public sealed class PortalTimeoutComponentState : ComponentState -{ - public NetEntity? EnteredPortal; - - public PortalTimeoutComponentState(NetEntity? enteredPortal) - { - EnteredPortal = enteredPortal; - } + [ViewVariables, DataField, AutoNetworkedField] + public EntityUid? EnteredPortal; } diff --git a/Content.Shared/Teleportation/Systems/LinkedEntitySystem.cs b/Content.Shared/Teleportation/Systems/LinkedEntitySystem.cs index 73e686e8bd..ed97975452 100644 --- a/Content.Shared/Teleportation/Systems/LinkedEntitySystem.cs +++ b/Content.Shared/Teleportation/Systems/LinkedEntitySystem.cs @@ -1,7 +1,6 @@ -using Content.Shared.Teleportation.Components; -using Robust.Shared.GameStates; using System.Diagnostics.CodeAnalysis; using System.Linq; +using Content.Shared.Teleportation.Components; namespace Content.Shared.Teleportation.Systems; @@ -20,22 +19,6 @@ public sealed class LinkedEntitySystem : EntitySystem base.Initialize(); SubscribeLocalEvent(OnLinkShutdown); - - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); - } - - private void OnGetState(EntityUid uid, LinkedEntityComponent component, ref ComponentGetState args) - { - 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 = 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 1ecaca57c3..e614a2c040 100644 --- a/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs +++ b/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs @@ -1,13 +1,11 @@ using System.Linq; using Content.Shared.Ghost; -using Content.Shared.Pinpointer; using Content.Shared.Popups; using Content.Shared.Projectiles; using Content.Shared.Pulling; using Content.Shared.Pulling.Components; using Content.Shared.Teleportation.Components; using Content.Shared.Verbs; -using Robust.Shared.GameStates; using Robust.Shared.Map; using Robust.Shared.Network; using Robust.Shared.Physics.Dynamics; @@ -42,9 +40,6 @@ public abstract class SharedPortalSystem : EntitySystem SubscribeLocalEvent(OnCollide); SubscribeLocalEvent(OnEndCollide); SubscribeLocalEvent>(OnGetVerbs); - - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); } private void OnGetVerbs(EntityUid uid, PortalComponent component, GetVerbsEvent args) @@ -77,17 +72,6 @@ public abstract class SharedPortalSystem : EntitySystem }); } - private void OnGetState(EntityUid uid, PortalTimeoutComponent component, ref ComponentGetState args) - { - 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 = EnsureEntity(state.EnteredPortal, uid); - } - private bool ShouldCollide(string ourId, string otherId, Fixture our, Fixture other) { // most non-hard fixtures shouldn't pass through portals, but projectiles are non-hard as well diff --git a/Content.Shared/Timing/UseDelayComponent.cs b/Content.Shared/Timing/UseDelayComponent.cs index aa12f04847..4135bf26fe 100644 --- a/Content.Shared/Timing/UseDelayComponent.cs +++ b/Content.Shared/Timing/UseDelayComponent.cs @@ -1,45 +1,28 @@ -using System.Threading; using Robust.Shared.GameStates; -using Robust.Shared.Serialization; -namespace Content.Shared.Timing +namespace Content.Shared.Timing; + +/// +/// Timer that creates a cooldown each time an object is activated/used +/// +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] +public sealed partial class UseDelayComponent : Component { + [AutoNetworkedField] + public TimeSpan LastUseTime; + + [AutoNetworkedField] + public TimeSpan? DelayEndTime; + + [DataField, AutoNetworkedField] + [ViewVariables(VVAccess.ReadWrite)] + public TimeSpan Delay = TimeSpan.FromSeconds(1); + /// - /// Timer that creates a cooldown each time an object is activated/used + /// Stores remaining delay pausing (and eventually, serialization). /// - [RegisterComponent] - [NetworkedComponent] - public sealed partial class UseDelayComponent : Component - { - public TimeSpan LastUseTime; + [DataField] + public TimeSpan? RemainingDelay; - public TimeSpan? DelayEndTime; - - [DataField("delay")] - [ViewVariables(VVAccess.ReadWrite)] - public TimeSpan Delay = TimeSpan.FromSeconds(1); - - /// - /// Stores remaining delay pausing (and eventually, serialization). - /// - [DataField("remainingDelay")] - public TimeSpan? RemainingDelay; - - public bool ActiveDelay => DelayEndTime != null; - } - - [Serializable, NetSerializable] - public sealed class UseDelayComponentState : ComponentState - { - public readonly TimeSpan LastUseTime; - public readonly TimeSpan Delay; - public readonly TimeSpan? DelayEndTime; - - public UseDelayComponentState(TimeSpan lastUseTime, TimeSpan delay, TimeSpan? delayEndTime) - { - LastUseTime = lastUseTime; - Delay = delay; - DelayEndTime = delayEndTime; - } - } + public bool ActiveDelay => DelayEndTime != null; } diff --git a/Content.Shared/Timing/UseDelaySystem.cs b/Content.Shared/Timing/UseDelaySystem.cs index f6dcdafe41..1d1d636b89 100644 --- a/Content.Shared/Timing/UseDelaySystem.cs +++ b/Content.Shared/Timing/UseDelaySystem.cs @@ -1,6 +1,4 @@ -using System.Threading; using Content.Shared.Cooldown; -using Robust.Shared.GameStates; using Robust.Shared.Timing; using Robust.Shared.Utility; @@ -16,8 +14,7 @@ public sealed class UseDelaySystem : EntitySystem { base.Initialize(); - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); + SubscribeLocalEvent(OnHandleState); SubscribeLocalEvent(OnPaused); SubscribeLocalEvent(OnUnpaused); @@ -45,26 +42,14 @@ public sealed class UseDelaySystem : EntitySystem _activeDelays.Add(component); } - private void OnHandleState(EntityUid uid, UseDelayComponent component, ref ComponentHandleState args) + private void OnHandleState(EntityUid uid, UseDelayComponent component, ref AfterAutoHandleStateEvent args) { - if (args.Current is not UseDelayComponentState state) - return; - - component.LastUseTime = state.LastUseTime; - component.Delay = state.Delay; - component.DelayEndTime = state.DelayEndTime; - if (component.DelayEndTime == null) _activeDelays.Remove(component); else _activeDelays.Add(component); } - private void OnGetState(EntityUid uid, UseDelayComponent component, ref ComponentGetState args) - { - args.State = new UseDelayComponentState(component.LastUseTime, component.Delay, component.DelayEndTime); - } - public override void Update(float frameTime) { base.Update(frameTime); diff --git a/Content.Shared/Tools/Components/MultipleToolComponent.cs b/Content.Shared/Tools/Components/MultipleToolComponent.cs index 87fa4ad175..4e30abb5ad 100644 --- a/Content.Shared/Tools/Components/MultipleToolComponent.cs +++ b/Content.Shared/Tools/Components/MultipleToolComponent.cs @@ -1,53 +1,41 @@ using Robust.Shared.Audio; using Robust.Shared.GameStates; -using Robust.Shared.Serialization; using Robust.Shared.Utility; -namespace Content.Shared.Tools.Components +namespace Content.Shared.Tools.Components; + +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] +public sealed partial class MultipleToolComponent : Component { - [RegisterComponent, NetworkedComponent] - public sealed partial class MultipleToolComponent : Component + [DataDefinition] + public sealed partial class ToolEntry { - [DataDefinition] - public sealed partial class ToolEntry - { - [DataField("behavior", required: true)] - public PrototypeFlags Behavior = new(); + [DataField(required: true)] + public PrototypeFlags Behavior = new(); - [DataField("useSound")] - public SoundSpecifier? Sound; + [DataField] + public SoundSpecifier? UseSound; - [DataField("changeSound")] - public SoundSpecifier? ChangeSound; + [DataField] + public SoundSpecifier? ChangeSound; - [DataField("sprite")] - public SpriteSpecifier? Sprite; - } - - [DataField("entries", required: true)] - public ToolEntry[] Entries { get; private set; } = Array.Empty(); - - [ViewVariables] - public uint CurrentEntry = 0; - - [ViewVariables] - public string CurrentQualityName = string.Empty; - - [ViewVariables(VVAccess.ReadWrite)] - public bool UiUpdateNeeded; - - [DataField("statusShowBehavior")] - public bool StatusShowBehavior = true; + [DataField] + public SpriteSpecifier? Sprite; } - [NetSerializable, Serializable] - public sealed class MultipleToolComponentState : ComponentState - { - public readonly uint Selected; + [DataField(required: true)] + public ToolEntry[] Entries { get; private set; } = Array.Empty(); - public MultipleToolComponentState(uint selected) - { - Selected = selected; - } - } + [ViewVariables] + [AutoNetworkedField] + public uint CurrentEntry = 0; + + [ViewVariables] + public string CurrentQualityName = string.Empty; + + [ViewVariables(VVAccess.ReadWrite)] + public bool UiUpdateNeeded; + + [DataField] + public bool StatusShowBehavior = true; } diff --git a/Content.Shared/Tools/Systems/SharedToolSystem.MultipleTool.cs b/Content.Shared/Tools/Systems/SharedToolSystem.MultipleTool.cs index d528c1be7d..39a1dc50f3 100644 --- a/Content.Shared/Tools/Systems/SharedToolSystem.MultipleTool.cs +++ b/Content.Shared/Tools/Systems/SharedToolSystem.MultipleTool.cs @@ -1,7 +1,6 @@ using System.Linq; using Content.Shared.Interaction; using Content.Shared.Tools.Components; -using Robust.Shared.GameStates; using Content.Shared.Prying.Components; namespace Content.Shared.Tools; @@ -12,16 +11,11 @@ public abstract partial class SharedToolSystem : EntitySystem { SubscribeLocalEvent(OnMultipleToolStartup); SubscribeLocalEvent(OnMultipleToolActivated); - SubscribeLocalEvent(OnMultipleToolGetState); - SubscribeLocalEvent(OnMultipleToolHandleState); + SubscribeLocalEvent(OnMultipleToolHandleState); } - private void OnMultipleToolHandleState(EntityUid uid, MultipleToolComponent component, ref ComponentHandleState args) + private void OnMultipleToolHandleState(EntityUid uid, MultipleToolComponent component, ref AfterAutoHandleStateEvent args) { - if (args.Current is not MultipleToolComponentState state) - return; - - component.CurrentEntry = state.Selected; SetMultipleTool(uid, component); } @@ -40,11 +34,6 @@ public abstract partial class SharedToolSystem : EntitySystem args.Handled = CycleMultipleTool(uid, multiple, args.User); } - private void OnMultipleToolGetState(EntityUid uid, MultipleToolComponent multiple, ref ComponentGetState args) - { - args.State = new MultipleToolComponentState(multiple.CurrentEntry); - } - public bool CycleMultipleTool(EntityUid uid, MultipleToolComponent? multiple = null, EntityUid? user = null) { if (!Resolve(uid, ref multiple)) @@ -77,7 +66,7 @@ public abstract partial class SharedToolSystem : EntitySystem } var current = multiple.Entries[multiple.CurrentEntry]; - tool.UseSound = current.Sound; + tool.UseSound = current.UseSound; tool.Qualities = current.Behavior; // TODO: Replace this with a better solution later diff --git a/Content.Shared/Vehicle/SharedVehicleSystem.cs b/Content.Shared/Vehicle/SharedVehicleSystem.cs index 9ba22d644a..334c115ba8 100644 --- a/Content.Shared/Vehicle/SharedVehicleSystem.cs +++ b/Content.Shared/Vehicle/SharedVehicleSystem.cs @@ -91,8 +91,8 @@ public abstract partial class SharedVehicleSystem : EntitySystem // This code should be purged anyway but with that being said this doesn't handle components being changed. if (TryComp(uid, out var strap)) { - component.BaseBuckleOffset = strap.BuckleOffset; - strap.BuckleOffsetUnclamped = Vector2.Zero; + component.BaseBuckleOffset = strap.BuckleOffsetClamped; + strap.BuckleOffset = Vector2.Zero; } _modifier.RefreshMovementSpeedModifiers(uid); @@ -301,9 +301,9 @@ public abstract partial class SharedVehicleSystem : EntitySystem return; // TODO: Strap should handle this but buckle E/C moment. - var oldOffset = strap.BuckleOffsetUnclamped; + var oldOffset = strap.BuckleOffset; - strap.BuckleOffsetUnclamped = xform.LocalRotation.Degrees switch + strap.BuckleOffset = xform.LocalRotation.Degrees switch { < 45f => new(0, component.SouthOverride), <= 135f => component.BaseBuckleOffset, @@ -312,13 +312,13 @@ public abstract partial class SharedVehicleSystem : EntitySystem _ => new(0, component.SouthOverride) }; - if (!oldOffset.Equals(strap.BuckleOffsetUnclamped)) + if (!oldOffset.Equals(strap.BuckleOffset)) Dirty(strap); foreach (var buckledEntity in strap.BuckledEntities) { var buckleXform = Transform(buckledEntity); - _transform.SetLocalPositionNoLerp(buckleXform, strap.BuckleOffset); + _transform.SetLocalPositionNoLerp(buckleXform, strap.BuckleOffsetClamped); } } diff --git a/Content.Shared/Weapons/Melee/MeleeWeaponComponent.cs b/Content.Shared/Weapons/Melee/MeleeWeaponComponent.cs index 9e7ad7e3a7..ddc060e558 100644 --- a/Content.Shared/Weapons/Melee/MeleeWeaponComponent.cs +++ b/Content.Shared/Weapons/Melee/MeleeWeaponComponent.cs @@ -3,16 +3,14 @@ using Content.Shared.FixedPoint; using Robust.Shared.Audio; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; -using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; namespace Content.Shared.Weapons.Melee; /// /// When given to a mob lets them do unarmed attacks, or when given to an item lets someone wield it to do attacks. /// -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class MeleeWeaponComponent : Component { // TODO: This is becoming bloated as shit. @@ -20,26 +18,27 @@ public sealed partial class MeleeWeaponComponent : Component /// /// Does this entity do a disarm on alt attack. /// - [DataField("altDisarm"), ViewVariables(VVAccess.ReadWrite)] + [DataField, ViewVariables(VVAccess.ReadWrite)] public bool AltDisarm = true; /// /// Should the melee weapon's damage stats be examinable. /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("hidden")] - public bool HideFromExamine; + [DataField] + public bool Hidden; /// /// Next time this component is allowed to light attack. Heavy attacks are wound up and never have a cooldown. /// - [ViewVariables(VVAccess.ReadWrite), DataField("nextAttack", customTypeSerializer:typeof(TimeOffsetSerializer))] + [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField] + [ViewVariables(VVAccess.ReadWrite)] public TimeSpan NextAttack; /// /// Starts attack cooldown when equipped if true. /// - [ViewVariables(VVAccess.ReadWrite), DataField("resetOnHandSelected")] + [ViewVariables(VVAccess.ReadWrite), DataField] public bool ResetOnHandSelected = true; /* @@ -51,50 +50,51 @@ public sealed partial class MeleeWeaponComponent : Component /// /// How many times we can attack per second. /// - [ViewVariables(VVAccess.ReadWrite), DataField("attackRate")] + [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] public float AttackRate = 1f; /// /// Are we currently holding down the mouse for an attack. /// Used so we can't just hold the mouse button and attack constantly. /// - [ViewVariables(VVAccess.ReadWrite)] + [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] public bool Attacking = false; /// /// Base damage for this weapon. Can be modified via heavy damage or other means. /// - [DataField("damage", required:true)] + [DataField(required:true)] [ViewVariables(VVAccess.ReadWrite)] public DamageSpecifier Damage = default!; - [DataField("bluntStaminaDamageFactor")] [ViewVariables(VVAccess.ReadWrite)] + [DataField] + [ViewVariables(VVAccess.ReadWrite)] public FixedPoint2 BluntStaminaDamageFactor = FixedPoint2.New(0.5f); /// /// Multiplies damage by this amount for single-target attacks. /// - [ViewVariables(VVAccess.ReadWrite), DataField("clickDamageModifier")] + [ViewVariables(VVAccess.ReadWrite), DataField] public FixedPoint2 ClickDamageModifier = FixedPoint2.New(1); // TODO: Temporarily 1.5 until interactionoutline is adjusted to use melee, then probably drop to 1.2 /// /// Nearest edge range to hit an entity. /// - [ViewVariables(VVAccess.ReadWrite), DataField("range")] + [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] public float Range = 1.5f; /// /// Total width of the angle for wide attacks. /// - [ViewVariables(VVAccess.ReadWrite), DataField("angle")] + [ViewVariables(VVAccess.ReadWrite), DataField] public Angle Angle = Angle.FromDegrees(60); - [ViewVariables(VVAccess.ReadWrite), DataField("animation", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string ClickAnimation = "WeaponArcPunch"; + [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] + public EntProtoId Animation = "WeaponArcPunch"; - [ViewVariables(VVAccess.ReadWrite), DataField("wideAnimation", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string WideAnimation = "WeaponArcSlash"; + [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] + public EntProtoId WideAnimation = "WeaponArcSlash"; // Sounds @@ -132,27 +132,3 @@ public sealed class GetMeleeWeaponEvent : HandledEntityEventArgs { public EntityUid? Weapon; } - -[Serializable, NetSerializable] -public sealed class MeleeWeaponComponentState : ComponentState -{ - // None of the other data matters for client as they're not predicted. - - public float AttackRate; - public bool Attacking; - public TimeSpan NextAttack; - - public string ClickAnimation; - public string WideAnimation; - public float Range; - - public MeleeWeaponComponentState(float attackRate, bool attacking, TimeSpan nextAttack, string clickAnimation, string wideAnimation, float range) - { - AttackRate = attackRate; - Attacking = attacking; - NextAttack = nextAttack; - ClickAnimation = clickAnimation; - WideAnimation = wideAnimation; - Range = range; - } -} diff --git a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs index 08ecea4326..9b61fd03b7 100644 --- a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs +++ b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs @@ -20,7 +20,6 @@ using Content.Shared.Weapons.Ranged.Components; using Content.Shared.Weapons.Ranged.Events; using Content.Shared.Weapons.Ranged.Systems; using Robust.Shared.Audio; -using Robust.Shared.GameStates; using Robust.Shared.Map; using Robust.Shared.Physics; using Robust.Shared.Physics.Systems; @@ -65,8 +64,6 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem base.Initialize(); SubscribeLocalEvent(OnMeleeUnpaused); - SubscribeLocalEvent(OnGetState); - SubscribeLocalEvent(OnHandleState); SubscribeLocalEvent(OnMeleeSelected); SubscribeLocalEvent(OnMeleeShotAttempted); SubscribeLocalEvent(OnMeleeShot); @@ -223,25 +220,6 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem AttemptAttack(args.SenderSession.AttachedEntity.Value, weaponUid, weapon, msg, args.SenderSession); } - private void OnGetState(EntityUid uid, MeleeWeaponComponent component, ref ComponentGetState args) - { - args.State = new MeleeWeaponComponentState(component.AttackRate, component.Attacking, component.NextAttack, component.ClickAnimation, component.WideAnimation, component.Range); - } - - private void OnHandleState(EntityUid uid, MeleeWeaponComponent component, ref ComponentHandleState args) - { - if (args.Current is not MeleeWeaponComponentState state) - return; - - component.Attacking = state.Attacking; - component.AttackRate = state.AttackRate; - component.NextAttack = state.NextAttack; - - component.ClickAnimation = state.ClickAnimation; - component.WideAnimation = state.WideAnimation; - component.Range = state.Range; - } - /// /// Gets the total damage a weapon does, including modifiers like wielding and enablind/disabling /// @@ -427,13 +405,13 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem { case LightAttackEvent light: DoLightAttack(user, light, weaponUid, weapon, session); - animation = weapon.ClickAnimation; + animation = weapon.Animation; break; case DisarmAttackEvent disarm: if (!DoDisarm(user, disarm, weaponUid, weapon, session)) return false; - animation = weapon.ClickAnimation; + animation = weapon.Animation; break; case HeavyAttackEvent heavy: if (!DoHeavyAttack(user, heavy, weaponUid, weapon, session)) diff --git a/Content.Shared/Weapons/Ranged/Components/BallisticAmmoProviderComponent.cs b/Content.Shared/Weapons/Ranged/Components/BallisticAmmoProviderComponent.cs index 8d0f6a5283..eb04d3227d 100644 --- a/Content.Shared/Weapons/Ranged/Components/BallisticAmmoProviderComponent.cs +++ b/Content.Shared/Weapons/Ranged/Components/BallisticAmmoProviderComponent.cs @@ -3,37 +3,36 @@ using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; namespace Content.Shared.Weapons.Ranged.Components; -[RegisterComponent, NetworkedComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class BallisticAmmoProviderComponent : Component { - [ViewVariables(VVAccess.ReadWrite), DataField("soundRack")] + [ViewVariables(VVAccess.ReadWrite), DataField] public SoundSpecifier? SoundRack = new SoundPathSpecifier("/Audio/Weapons/Guns/Cock/smg_cock.ogg"); - [ViewVariables(VVAccess.ReadWrite), DataField("soundInsert")] + [ViewVariables(VVAccess.ReadWrite), DataField] public SoundSpecifier? SoundInsert = new SoundPathSpecifier("/Audio/Weapons/Guns/MagIn/bullet_insert.ogg"); - [ViewVariables(VVAccess.ReadWrite), DataField("proto", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string? FillProto; + [ViewVariables(VVAccess.ReadWrite), DataField] + public EntProtoId? Proto; - [ViewVariables(VVAccess.ReadWrite), DataField("capacity")] + [ViewVariables(VVAccess.ReadWrite), DataField] public int Capacity = 30; public int Count => UnspawnedCount + Container.ContainedEntities.Count; - [ViewVariables(VVAccess.ReadWrite), DataField("unspawnedCount")] + [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] public int UnspawnedCount; - [ViewVariables(VVAccess.ReadWrite), DataField("whitelist")] + [ViewVariables(VVAccess.ReadWrite), DataField] public EntityWhitelist? Whitelist; public Container Container = default!; // TODO: Make this use stacks when the typeserializer is done. - [DataField("entities")] + [DataField, AutoNetworkedField] public List Entities = new(); /// @@ -42,18 +41,18 @@ 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")] + [ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField] public bool Cycleable = true; /// /// Is it okay for this entity to directly transfer its valid ammunition into another provider? /// - [ViewVariables(VVAccess.ReadWrite), DataField("mayTransfer")] - public bool MayTransfer = false; + [ViewVariables(VVAccess.ReadWrite), DataField] + public bool MayTransfer; /// /// DoAfter delay for filling a bullet into another ballistic ammo provider. /// - [DataField("fillDelay")] + [DataField] public TimeSpan FillDelay = TimeSpan.FromSeconds(0.5); } diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs index f8b2394315..8ad96fda53 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs @@ -6,7 +6,6 @@ using Content.Shared.Verbs; using Content.Shared.Weapons.Ranged.Components; using Content.Shared.Weapons.Ranged.Events; using Robust.Shared.Containers; -using Robust.Shared.GameStates; using Robust.Shared.Map; using Robust.Shared.Serialization; @@ -29,29 +28,6 @@ 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) @@ -239,7 +215,7 @@ public abstract partial class SharedGunSystem { // TODO this should be part of the prototype, not set on map init. // Alternatively, just track spawned count, instead of unspawned count. - if (component.FillProto != null) + if (component.Proto != null) { component.UnspawnedCount = Math.Max(0, component.Capacity - component.Container.ContainedEntities.Count); UpdateBallisticAppearance(uid, component); @@ -269,7 +245,7 @@ public abstract partial class SharedGunSystem else if (component.UnspawnedCount > 0) { component.UnspawnedCount--; - entity = Spawn(component.FillProto, args.Coordinates); + entity = Spawn(component.Proto, args.Coordinates); args.Ammo.Add((entity, EnsureShootable(entity))); } } @@ -292,14 +268,6 @@ 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/Zombies/ZombieComponent.cs b/Content.Shared/Zombies/ZombieComponent.cs index f03a0baf79..bb1f6bec5f 100644 --- a/Content.Shared/Zombies/ZombieComponent.cs +++ b/Content.Shared/Zombies/ZombieComponent.cs @@ -1,15 +1,14 @@ using Content.Shared.Chat.Prototypes; using Content.Shared.Chemistry.Reagent; using Content.Shared.Damage; -using Content.Shared.Roles; using Content.Shared.Humanoid; +using Content.Shared.Roles; using Content.Shared.StatusIcon; using Robust.Shared.Audio; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; -using static Content.Shared.Humanoid.HumanoidAppearanceState; namespace Content.Shared.Zombies; diff --git a/Content.Tests/Shared/Alert/ServerAlertsComponentTests.cs b/Content.Tests/Shared/Alert/ServerAlertsComponentTests.cs index 83fbb009ea..5d8d49d168 100644 --- a/Content.Tests/Shared/Alert/ServerAlertsComponentTests.cs +++ b/Content.Tests/Shared/Alert/ServerAlertsComponentTests.cs @@ -57,7 +57,7 @@ namespace Content.Tests.Shared.Alert var getty = new ComponentGetState(); entManager.EventBus.RaiseComponentEvent(alertsComponent, getty); - var alertState = (AlertsComponentState) getty.State!; + var alertState = (AlertsComponent.AlertsComponent_AutoState) getty.State!; Assert.NotNull(alertState); Assert.That(alertState.Alerts.Count, Is.EqualTo(1)); Assert.That(alertState.Alerts.ContainsKey(lowpressure.AlertKey)); @@ -66,14 +66,14 @@ namespace Content.Tests.Shared.Alert // Lazy entManager.EventBus.RaiseComponentEvent(alertsComponent, getty); - alertState = (AlertsComponentState) getty.State!; + alertState = (AlertsComponent.AlertsComponent_AutoState) getty.State!; Assert.That(alertState.Alerts.Count, Is.EqualTo(1)); Assert.That(alertState.Alerts.ContainsKey(highpressure.AlertKey)); EntitySystem.Get().ClearAlertCategory(alertsComponent.Owner, AlertCategory.Pressure); entManager.EventBus.RaiseComponentEvent(alertsComponent, getty); - alertState = (AlertsComponentState) getty.State!; + alertState = (AlertsComponent.AlertsComponent_AutoState) getty.State!; Assert.That(alertState.Alerts.Count, Is.EqualTo(0)); } }