itemcooldown auto gen comp state (#15305)
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -6,10 +6,11 @@ namespace Content.Shared.Cooldown
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stores a visual "cooldown" for items, that gets displayed in the hands GUI.
|
/// Stores a visual "cooldown" for items, that gets displayed in the hands GUI.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent]
|
[RegisterComponent, NetworkedComponent]
|
||||||
[NetworkedComponent()]
|
[AutoGenerateComponentState]
|
||||||
public sealed class ItemCooldownComponent : Component
|
public sealed partial class ItemCooldownComponent : Component
|
||||||
{
|
{
|
||||||
|
// TODO: access and system setting and dirtying not this funny stuff
|
||||||
private TimeSpan? _cooldownEnd;
|
private TimeSpan? _cooldownEnd;
|
||||||
private TimeSpan? _cooldownStart;
|
private TimeSpan? _cooldownStart;
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ namespace Content.Shared.Cooldown
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// If null, no cooldown is displayed.
|
/// If null, no cooldown is displayed.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[ViewVariables]
|
[ViewVariables, AutoNetworkedField]
|
||||||
public TimeSpan? CooldownEnd
|
public TimeSpan? CooldownEnd
|
||||||
{
|
{
|
||||||
get => _cooldownEnd;
|
get => _cooldownEnd;
|
||||||
@@ -36,7 +37,7 @@ namespace Content.Shared.Cooldown
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// If null, no cooldown is displayed.
|
/// If null, no cooldown is displayed.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[ViewVariables]
|
[ViewVariables, AutoNetworkedField]
|
||||||
public TimeSpan? CooldownStart
|
public TimeSpan? CooldownStart
|
||||||
{
|
{
|
||||||
get => _cooldownStart;
|
get => _cooldownStart;
|
||||||
@@ -46,35 +47,5 @@ namespace Content.Shared.Cooldown
|
|||||||
Dirty();
|
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() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user