2021-10-25 20:06:12 +13:00
|
|
|
using System;
|
2020-08-13 14:40:27 +02:00
|
|
|
using System.Threading;
|
2020-01-22 17:08:14 -05:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-03-05 01:08:38 +01:00
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2020-11-22 17:00:06 +02:00
|
|
|
using Robust.Shared.ViewVariables;
|
2020-01-22 17:08:14 -05:00
|
|
|
|
2021-10-25 20:06:12 +13:00
|
|
|
namespace Content.Shared.Timing
|
2020-01-22 17:08:14 -05:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Timer that creates a cooldown each time an object is activated/used
|
|
|
|
|
/// </summary>
|
2022-02-08 00:42:49 -08:00
|
|
|
[RegisterComponent]
|
2022-01-31 00:27:29 +11:00
|
|
|
public sealed class UseDelayComponent : Component
|
2020-01-22 17:08:14 -05:00
|
|
|
{
|
2022-01-31 00:27:29 +11:00
|
|
|
[ViewVariables]
|
|
|
|
|
public TimeSpan LastUseTime;
|
2020-01-22 17:08:14 -05:00
|
|
|
|
2022-01-31 00:27:29 +11:00
|
|
|
[ViewVariables]
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("delay")]
|
2022-01-31 00:27:29 +11:00
|
|
|
public float Delay = 1;
|
2020-01-22 17:08:14 -05:00
|
|
|
|
2022-01-31 00:27:29 +11:00
|
|
|
[ViewVariables]
|
|
|
|
|
public float Elapsed = 0f;
|
2020-01-22 17:08:14 -05:00
|
|
|
|
2022-01-31 00:27:29 +11:00
|
|
|
public CancellationTokenSource? CancellationTokenSource;
|
2020-01-22 17:08:14 -05:00
|
|
|
|
2022-01-31 00:27:29 +11:00
|
|
|
public bool ActiveDelay => CancellationTokenSource is { Token: { IsCancellationRequested: false } };
|
2020-01-22 17:08:14 -05:00
|
|
|
}
|
|
|
|
|
}
|