]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
ghost auto gen comp state (#15304)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Fri, 14 Apr 2023 19:46:17 +0000 (19:46 +0000)
committerGitHub <noreply@github.com>
Fri, 14 Apr 2023 19:46:17 +0000 (12:46 -0700)
Co-authored-by: deltanedas <@deltanedas:kde.org>
Content.Shared/Ghost/SharedGhostComponent.cs

index c4075cc3097616b049c7ba9936d83b34b1f4801c..07ae1ff81baa7a98865fe10b964ae4ac5dcefeb6 100644 (file)
@@ -3,9 +3,11 @@ using Robust.Shared.Serialization;
 
 namespace Content.Shared.Ghost
 {
-    [NetworkedComponent()]
-    public abstract class SharedGhostComponent : Component
+    [NetworkedComponent]
+    [AutoGenerateComponentState]
+    public abstract partial class SharedGhostComponent : Component
     {
+        // TODO: instead of this funny stuff just give it access and update in system dirtying when needed
         [ViewVariables(VVAccess.ReadWrite)]
         public bool CanGhostInteract
         {
@@ -18,7 +20,7 @@ namespace Content.Shared.Ghost
             }
         }
 
-        [DataField("canInteract")]
+        [DataField("canInteract"), AutoNetworkedField]
         private bool _canGhostInteract;
 
         /// <summary>
@@ -37,41 +39,8 @@ namespace Content.Shared.Ghost
             }
         }
 
-        [DataField("canReturnToBody")]
+        [DataField("canReturnToBody"), AutoNetworkedField]
         private bool _canReturnToBody;
-
-        public override ComponentState GetComponentState()
-        {
-            return new GhostComponentState(CanReturnToBody, CanGhostInteract);
-        }
-
-        public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
-        {
-            base.HandleComponentState(curState, nextState);
-
-            if (curState is not GhostComponentState state)
-            {
-                return;
-            }
-
-            CanReturnToBody = state.CanReturnToBody;
-            CanGhostInteract = state.CanGhostInteract;
-        }
-    }
-
-    [Serializable, NetSerializable]
-    public sealed class GhostComponentState : ComponentState
-    {
-        public bool CanReturnToBody { get; }
-        public bool CanGhostInteract { get; }
-
-        public GhostComponentState(
-            bool canReturnToBody,
-            bool canGhostInteract)
-        {
-            CanReturnToBody = canReturnToBody;
-            CanGhostInteract = canGhostInteract;
-        }
     }
 }