/// <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;
/// <remarks>
/// If null, no cooldown is displayed.
/// </remarks>
- [ViewVariables]
+ [ViewVariables, AutoNetworkedField]
public TimeSpan? CooldownEnd
{
get => _cooldownEnd;
/// <remarks>
/// If null, no cooldown is displayed.
/// </remarks>
- [ViewVariables]
+ [ViewVariables, AutoNetworkedField]
public TimeSpan? CooldownStart
{
get => _cooldownStart;
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() {
- }
- }
}
}