2022-03-09 20:12:17 +13:00
|
|
|
using Robust.Shared.GameStates;
|
2024-04-25 22:25:52 -04:00
|
|
|
using Robust.Shared.Serialization;
|
2020-01-22 17:08:14 -05:00
|
|
|
|
2023-09-28 16:20:29 -07:00
|
|
|
namespace Content.Shared.Timing;
|
2022-03-09 20:12:17 +13:00
|
|
|
|
2023-09-28 16:20:29 -07:00
|
|
|
/// <summary>
|
2024-04-25 22:25:52 -04:00
|
|
|
/// Timer that creates a cooldown each time an object is activated/used.
|
|
|
|
|
/// Can support additional, separate cooldown timers on the object by passing a unique ID with the system methods.
|
2023-09-28 16:20:29 -07:00
|
|
|
/// </summary>
|
2024-01-03 21:33:09 -04:00
|
|
|
[RegisterComponent]
|
2024-04-26 17:58:06 +10:00
|
|
|
[NetworkedComponent]
|
2024-01-03 21:33:09 -04:00
|
|
|
[Access(typeof(UseDelaySystem))]
|
2023-09-28 16:20:29 -07:00
|
|
|
public sealed partial class UseDelayComponent : Component
|
|
|
|
|
{
|
2024-04-26 17:58:06 +10:00
|
|
|
[DataField]
|
2024-04-25 22:25:52 -04:00
|
|
|
public Dictionary<string, UseDelayInfo> Delays = [];
|
2022-03-09 20:12:17 +13:00
|
|
|
|
2023-09-28 16:20:29 -07:00
|
|
|
/// <summary>
|
2024-04-25 22:25:52 -04:00
|
|
|
/// Default delay time.
|
2023-09-28 16:20:29 -07:00
|
|
|
/// </summary>
|
2024-04-25 22:25:52 -04:00
|
|
|
/// <remarks>
|
|
|
|
|
/// This is only used at MapInit and should not be expected
|
|
|
|
|
/// to reflect the length of the default delay after that.
|
|
|
|
|
/// Use <see cref="UseDelaySystem.TryGetDelayInfo"/> instead.
|
|
|
|
|
/// </remarks>
|
2023-09-28 16:20:29 -07:00
|
|
|
[DataField]
|
2024-01-03 21:33:09 -04:00
|
|
|
public TimeSpan Delay = TimeSpan.FromSeconds(1);
|
2020-01-22 17:08:14 -05:00
|
|
|
}
|
2024-04-25 22:25:52 -04:00
|
|
|
|
2024-04-26 17:58:06 +10:00
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public sealed class UseDelayComponentState : IComponentState
|
|
|
|
|
{
|
|
|
|
|
public Dictionary<string, UseDelayInfo> Delays = new();
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-25 22:25:52 -04:00
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
[DataDefinition]
|
|
|
|
|
public sealed partial class UseDelayInfo
|
|
|
|
|
{
|
|
|
|
|
[DataField]
|
|
|
|
|
public TimeSpan Length { get; set; }
|
|
|
|
|
[DataField]
|
|
|
|
|
public TimeSpan StartTime { get; set; }
|
|
|
|
|
[DataField]
|
|
|
|
|
public TimeSpan EndTime { get; set; }
|
|
|
|
|
|
|
|
|
|
public UseDelayInfo(TimeSpan length, TimeSpan startTime = default, TimeSpan endTime = default)
|
|
|
|
|
{
|
|
|
|
|
Length = length;
|
|
|
|
|
StartTime = startTime;
|
|
|
|
|
EndTime = endTime;
|
|
|
|
|
}
|
|
|
|
|
}
|