diff --git a/Content.Shared/Access/Components/IdCardComponent.cs b/Content.Shared/Access/Components/IdCardComponent.cs index 06dc11b091..5c11fef78a 100644 --- a/Content.Shared/Access/Components/IdCardComponent.cs +++ b/Content.Shared/Access/Components/IdCardComponent.cs @@ -6,28 +6,18 @@ using Robust.Shared.Serialization; namespace Content.Shared.Access.Components { [RegisterComponent, NetworkedComponent] + [AutoGenerateComponentState] [Access(typeof(SharedIdCardSystem), typeof(SharedPDASystem), typeof(SharedAgentIdCardSystem))] - public sealed class IdCardComponent : Component + public sealed partial class IdCardComponent : Component { [DataField("fullName")] + [AutoNetworkedField] [Access(typeof(SharedIdCardSystem), typeof(SharedPDASystem), typeof(SharedAgentIdCardSystem), Other = AccessPermissions.ReadWrite)] // FIXME Friends public string? FullName; [DataField("jobTitle")] + [AutoNetworkedField] public string? JobTitle; } - - [Serializable, NetSerializable] - public sealed class IdCardComponentState : ComponentState - { - public string? FullName; - public string? JobTitle; - - public IdCardComponentState(string? fullName, string? jobTitle) - { - FullName = fullName; - JobTitle = jobTitle; - } - } } diff --git a/Content.Shared/Access/Systems/SharedIdCardSystem.cs b/Content.Shared/Access/Systems/SharedIdCardSystem.cs index 52b8cc4358..dcc5af8bc7 100644 --- a/Content.Shared/Access/Systems/SharedIdCardSystem.cs +++ b/Content.Shared/Access/Systems/SharedIdCardSystem.cs @@ -11,28 +11,6 @@ public abstract class SharedIdCardSystem : EntitySystem { [Dependency] private readonly InventorySystem _inventorySystem = default!; - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(OnComponentGetState); - SubscribeLocalEvent(OnComponentHandleState); - } - - private void OnComponentGetState(EntityUid uid, IdCardComponent component, ref ComponentGetState args) - { - args.State = new IdCardComponentState(component.FullName, component.JobTitle); - } - - private void OnComponentHandleState(EntityUid uid, IdCardComponent component, ref ComponentHandleState args) - { - if (args.Current is IdCardComponentState state) - { - component.FullName = state.FullName; - component.JobTitle = state.JobTitle; - } - } - /// /// Attempt to find an ID card on an entity. This will look in the entity itself, in the entity's hands, and /// in the entity's inventory. diff --git a/Content.Shared/Content.Shared.csproj b/Content.Shared/Content.Shared.csproj index c15aecd962..f9ecb7fb14 100644 --- a/Content.Shared/Content.Shared.csproj +++ b/Content.Shared/Content.Shared.csproj @@ -28,4 +28,5 @@ + diff --git a/Content.Shared/Parallax/Biomes/BiomeComponent.cs b/Content.Shared/Parallax/Biomes/BiomeComponent.cs index ce9ac6c351..ac960f5ce7 100644 --- a/Content.Shared/Parallax/Biomes/BiomeComponent.cs +++ b/Content.Shared/Parallax/Biomes/BiomeComponent.cs @@ -4,16 +4,18 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy namespace Content.Shared.Parallax.Biomes; -[RegisterComponent, NetworkedComponent] -public sealed class BiomeComponent : Component +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] +public sealed partial class BiomeComponent : Component { public FastNoiseLite Noise = new(); [ViewVariables(VVAccess.ReadWrite), DataField("seed")] + [AutoNetworkedField] public int Seed; [ViewVariables(VVAccess.ReadWrite), DataField("prototype", customTypeSerializer: typeof(PrototypeIdSerializer))] + [AutoNetworkedField] public string BiomePrototype = "Grasslands"; // TODO: Need to flag tiles as not requiring custom data anymore, e.g. if we spawn an ent and don't unspawn it. diff --git a/Content.Shared/Parallax/Biomes/SharedBiomeSystem.cs b/Content.Shared/Parallax/Biomes/SharedBiomeSystem.cs index f15286849a..1e34e63cda 100644 --- a/Content.Shared/Parallax/Biomes/SharedBiomeSystem.cs +++ b/Content.Shared/Parallax/Biomes/SharedBiomeSystem.cs @@ -20,25 +20,14 @@ public abstract class SharedBiomeSystem : EntitySystem public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnBiomeGetState); - SubscribeLocalEvent(OnBiomeHandleState); + SubscribeLocalEvent(OnBiomeAfterHandleState); } - private void OnBiomeHandleState(EntityUid uid, BiomeComponent component, ref ComponentHandleState args) + private void OnBiomeAfterHandleState(EntityUid uid, BiomeComponent component, ref AfterAutoHandleStateEvent args) { - if (args.Current is not BiomeComponentState state) - return; - - component.Seed = state.Seed; - component.BiomePrototype = state.Prototype; component.Noise.SetSeed(component.Seed); } - private void OnBiomeGetState(EntityUid uid, BiomeComponent component, ref ComponentGetState args) - { - args.State = new BiomeComponentState(component.Seed, component.BiomePrototype); - } - protected T Pick(List collection, float value) { DebugTools.Assert(value is >= 0f and <= 1f); @@ -317,17 +306,4 @@ public abstract class SharedBiomeSystem : EntitySystem // Domain warps require separate noise } - - [Serializable, NetSerializable] - private sealed class BiomeComponentState : ComponentState - { - public int Seed; - public string Prototype; - - public BiomeComponentState(int seed, string prototype) - { - Seed = seed; - Prototype = prototype; - } - } } diff --git a/SpaceStation14.sln b/SpaceStation14.sln index 1515cf820a..6b71fcce0f 100644 --- a/SpaceStation14.sln +++ b/SpaceStation14.sln @@ -56,6 +56,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MSBuild", "MSBuild", "{5040 RobustToolbox\MSBuild\Robust.Trimming.targets = RobustToolbox\MSBuild\Robust.Trimming.targets RobustToolbox\MSBuild\Robust.Platform.props = RobustToolbox\MSBuild\Robust.Platform.props RobustToolbox\MSBuild\Robust.Configurations.props = RobustToolbox\MSBuild\Robust.Configurations.props + RobustToolbox\MSBuild\Robust.CompNetworkGenerator.targets = RobustToolbox\MSBuild\Robust.CompNetworkGenerator.targets EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{806ED41A-411B-4B3B-BEB6-DEC6DCA4C205}" @@ -120,6 +121,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Project Files", "Project Fi RobustToolbox\RELEASE-NOTES.md = RobustToolbox\RELEASE-NOTES.md EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robust.Shared.CompNetworkGenerator", "RobustToolbox\Robust.Shared.CompNetworkGenerator\Robust.Shared.CompNetworkGenerator.csproj", "{07CA34A1-1D37-4771-A2E3-495A1044AE0B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -399,6 +402,14 @@ Global {424445D4-F5D9-4CA9-A435-0A36E8AA28F3}.DebugOpt|Any CPU.Build.0 = DebugOpt|Any CPU {424445D4-F5D9-4CA9-A435-0A36E8AA28F3}.Tools|Any CPU.ActiveCfg = Tools|Any CPU {424445D4-F5D9-4CA9-A435-0A36E8AA28F3}.Tools|Any CPU.Build.0 = Tools|Any CPU + {07CA34A1-1D37-4771-A2E3-495A1044AE0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {07CA34A1-1D37-4771-A2E3-495A1044AE0B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {07CA34A1-1D37-4771-A2E3-495A1044AE0B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {07CA34A1-1D37-4771-A2E3-495A1044AE0B}.Release|Any CPU.Build.0 = Release|Any CPU + {07CA34A1-1D37-4771-A2E3-495A1044AE0B}.DebugOpt|Any CPU.ActiveCfg = DebugOpt|Any CPU + {07CA34A1-1D37-4771-A2E3-495A1044AE0B}.DebugOpt|Any CPU.Build.0 = DebugOpt|Any CPU + {07CA34A1-1D37-4771-A2E3-495A1044AE0B}.Tools|Any CPU.ActiveCfg = Tools|Any CPU + {07CA34A1-1D37-4771-A2E3-495A1044AE0B}.Tools|Any CPU.Build.0 = Tools|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -428,6 +439,7 @@ Global {8A21C7CA-2EB8-40E5-8043-33582C06D139} = {83B4CBBA-547A-42F0-A7CD-8A67D93196CE} {952AAF2A-DF63-4A7D-8094-3453893EBA80} = {83B4CBBA-547A-42F0-A7CD-8A67D93196CE} {A965CB3B-FD31-44AF-8872-85ABA436098D} = {83B4CBBA-547A-42F0-A7CD-8A67D93196CE} + {07CA34A1-1D37-4771-A2E3-495A1044AE0B} = {83B4CBBA-547A-42F0-A7CD-8A67D93196CE} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {AA37ED9F-F8D6-468E-A101-658AD605B09A}