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

index 1a7c94c7fe1b0071a1647d99c8dff66e674eb7ee..32560ec6cbd6a5511a5b2c0308baf5e40d03248c 100644 (file)
@@ -6,10 +6,11 @@ namespace Content.Shared.Cooldown
     /// <summary>
     ///     Stores a visual "cooldown" for items, that gets displayed in the hands GUI.
     /// </summary>
-    [RegisterComponent]
-    [NetworkedComponent()]
-    public sealed class ItemCooldownComponent : Component
+    [RegisterComponent, NetworkedComponent]
+    [AutoGenerateComponentState]
+    public sealed partial class ItemCooldownComponent : Component
     {
+        // TODO: access and system setting and dirtying not this funny stuff
         private TimeSpan? _cooldownEnd;
         private TimeSpan? _cooldownStart;
 
@@ -19,7 +20,7 @@ namespace Content.Shared.Cooldown
         /// <remarks>
         ///     If null, no cooldown is displayed.
         /// </remarks>
-        [ViewVariables]
+        [ViewVariables, AutoNetworkedField]
         public TimeSpan? CooldownEnd
         {
             get => _cooldownEnd;
@@ -36,7 +37,7 @@ namespace Content.Shared.Cooldown
         /// <remarks>
         ///     If null, no cooldown is displayed.
         /// </remarks>
-        [ViewVariables]
+        [ViewVariables, AutoNetworkedField]
         public TimeSpan? CooldownStart
         {
             get => _cooldownStart;
@@ -46,35 +47,5 @@ namespace Content.Shared.Cooldown
                 Dirty();
             }
         }
-
-        public override ComponentState GetComponentState()
-        {
-            return new ItemCooldownComponentState
-            {
-                CooldownEnd = CooldownEnd,
-                CooldownStart = CooldownStart
-            };
-        }
-
-        public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
-        {
-            base.HandleComponentState(curState, nextState);
-
-            if (curState is not ItemCooldownComponentState cast)
-                return;
-
-            CooldownStart = cast.CooldownStart;
-            CooldownEnd = cast.CooldownEnd;
-        }
-
-        [Serializable, NetSerializable]
-        private sealed class ItemCooldownComponentState : ComponentState
-        {
-            public TimeSpan? CooldownStart { get; set; }
-            public TimeSpan? CooldownEnd { get; set; }
-
-            public ItemCooldownComponentState() {
-            }
-        }
     }
 }