From 84ab1e8f26b651cf7b0b813ab84d05eb36a399c1 Mon Sep 17 00:00:00 2001 From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Fri, 14 Apr 2023 19:46:44 +0000 Subject: [PATCH] itemcooldown auto gen comp state (#15305) Co-authored-by: deltanedas <@deltanedas:kde.org> --- .../Cooldown/ItemCooldownComponent.cs | 41 +++---------------- 1 file changed, 6 insertions(+), 35 deletions(-) diff --git a/Content.Shared/Cooldown/ItemCooldownComponent.cs b/Content.Shared/Cooldown/ItemCooldownComponent.cs index 1a7c94c7fe..32560ec6cb 100644 --- a/Content.Shared/Cooldown/ItemCooldownComponent.cs +++ b/Content.Shared/Cooldown/ItemCooldownComponent.cs @@ -6,10 +6,11 @@ namespace Content.Shared.Cooldown /// /// Stores a visual "cooldown" for items, that gets displayed in the hands GUI. /// - [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 /// /// If null, no cooldown is displayed. /// - [ViewVariables] + [ViewVariables, AutoNetworkedField] public TimeSpan? CooldownEnd { get => _cooldownEnd; @@ -36,7 +37,7 @@ namespace Content.Shared.Cooldown /// /// If null, no cooldown is displayed. /// - [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() { - } - } } }