]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
singulo distortion auto gen comp state (#15306)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Fri, 14 Apr 2023 19:47:32 +0000 (19:47 +0000)
committerGitHub <noreply@github.com>
Fri, 14 Apr 2023 19:47:32 +0000 (12:47 -0700)
Co-authored-by: deltanedas <@deltanedas:kde.org>
Content.Shared/Singularity/Components/SingularityDistortionComponent.cs

index 5d21cdad6025e851f5908b72c839d38e44f5465d..73313661de169d5ff1b1a9467c4879eed2fab826 100644 (file)
@@ -1,60 +1,31 @@
 using Robust.Shared.GameStates;
 using Robust.Shared.Serialization;
+
 namespace Content.Shared.Singularity.Components
 {
-    [RegisterComponent]
-    [NetworkedComponent]
-    public sealed class SingularityDistortionComponent : Component
+    [RegisterComponent, NetworkedComponent]
+    [AutoGenerateComponentState]
+    public sealed partial class SingularityDistortionComponent : Component
     {
+        // TODO: use access and remove this funny stuff
         [DataField("intensity")]
         private float _intensity = 31.25f;
 
         [DataField("falloffPower")]
         private float _falloffPower = MathF.Sqrt(2f);
 
-        [ViewVariables(VVAccess.ReadWrite)]
+        [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
         public float Intensity
         {
             get => _intensity;
             set => this.SetAndDirtyIfChanged(ref _intensity, value);
         }
 
-        [ViewVariables(VVAccess.ReadWrite)]
+        [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
         public float FalloffPower
         {
             get => _falloffPower;
             set => this.SetAndDirtyIfChanged(ref _falloffPower, value);
         }
-
-        public override ComponentState GetComponentState()
-        {
-            return new SingularityDistortionComponentState(Intensity, FalloffPower);
-        }
-
-        public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
-        {
-            base.HandleComponentState(curState, nextState);
-
-            if (curState is not SingularityDistortionComponentState state)
-            {
-                return;
-            }
-
-            Intensity = state.Intensity;
-            FalloffPower = state.Falloff;
-        }
-    }
-
-    [Serializable, NetSerializable]
-    public sealed class SingularityDistortionComponentState : ComponentState
-    {
-        public SingularityDistortionComponentState(float intensity, float falloff)
-        {
-            Intensity = intensity;
-            Falloff = falloff;
-        }
-
-        public float Intensity { get; }
-        public float Falloff { get; }
     }
 }