]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
autogen parallax state (#15384)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Sat, 22 Apr 2023 12:02:23 +0000 (12:02 +0000)
committerGitHub <noreply@github.com>
Sat, 22 Apr 2023 12:02:23 +0000 (22:02 +1000)
Co-authored-by: deltanedas <@deltanedas:kde.org>
Content.Client/Parallax/ParallaxSystem.cs
Content.Server/Parallax/ParallaxSystem.cs
Content.Shared/Parallax/ParallaxComponent.cs

index a3d86743db0a445b286628adc156caf00a5c2644..5ad7bd4e56299a9a818c7fde4cfaad7077f6c021 100644 (file)
@@ -2,7 +2,6 @@ using Content.Client.Parallax.Data;
 using Content.Client.Parallax.Managers;
 using Content.Shared.Parallax;
 using Robust.Client.Graphics;
-using Robust.Shared.GameStates;
 using Robust.Shared.Map;
 using Robust.Shared.Prototypes;
 
@@ -22,8 +21,9 @@ public sealed class ParallaxSystem : SharedParallaxSystem
     {
         base.Initialize();
         _overlay.AddOverlay(new ParallaxOverlay());
-        SubscribeLocalEvent<ParallaxComponent, ComponentHandleState>(OnParallaxHandleState);
         _protoManager.PrototypesReloaded += OnReload;
+
+        SubscribeLocalEvent<ParallaxComponent, AfterAutoHandleStateEvent>(OnAfterAutoHandleState);
     }
 
     private void OnReload(PrototypesReloadedEventArgs obj)
@@ -48,11 +48,8 @@ public sealed class ParallaxSystem : SharedParallaxSystem
         _protoManager.PrototypesReloaded -= OnReload;
     }
 
-    private void OnParallaxHandleState(EntityUid uid, ParallaxComponent component, ref ComponentHandleState args)
+    private void OnAfterAutoHandleState(EntityUid uid, ParallaxComponent component, ref AfterAutoHandleStateEvent args)
     {
-        if (args.Current is not ParallaxComponentState state) return;
-        component.Parallax = state.Parallax;
-
         if (!_parallax.IsLoaded(component.Parallax))
         {
             _parallax.LoadParallaxByName(component.Parallax);
index 497e5bc4f5a4371a9635431e09b9b152dbb58765..5a896295d28b00e0b3740ea73396f7333696bc99 100644 (file)
@@ -1,23 +1,5 @@
 using Content.Shared.Parallax;
-using Robust.Shared.GameStates;
 
 namespace Content.Server.Parallax;
 
-public sealed class ParallaxSystem : SharedParallaxSystem
-{
-    public override void Initialize()
-    {
-        base.Initialize();
-
-        SubscribeLocalEvent<ParallaxComponent, ComponentGetState>(OnParallaxGetState);
-    }
-
-    private void OnParallaxGetState(EntityUid uid, ParallaxComponent component, ref ComponentGetState args)
-    {
-        args.State = new ParallaxComponentState
-        {
-            Parallax = component.Parallax
-        };
-    }
-
-}
+public sealed class ParallaxSystem : SharedParallaxSystem { }
index 8566be2fc04a751eaf89a6c640cfb751b82c9c0f..62ba704e97b00c60c61493788ad4b00bea470112 100644 (file)
@@ -6,11 +6,11 @@ namespace Content.Shared.Parallax;
 /// <summary>
 /// Handles per-map parallax
 /// </summary>
-[RegisterComponent, NetworkedComponent]
-public sealed class ParallaxComponent : Component
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
+public sealed partial class ParallaxComponent : Component
 {
     // I wish I could use a typeserializer here but parallax is extremely client-dependent.
-    [DataField("parallax")]
+    [DataField("parallax"), AutoNetworkedField]
     public string Parallax = "Default";
 
     [UsedImplicitly, ViewVariables(VVAccess.ReadWrite)]