2022-03-09 20:12:17 +13:00
using Robust.Shared.GameStates ;
2024-01-03 21:33:09 -04:00
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom ;
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>
/// Timer that creates a cooldown each time an object is activated/used
/// </summary>
2024-01-03 21:33:09 -04:00
/// <remarks>
/// Currently it only supports a single delay per entity, this means that for things that have two delay interactions they will share one timer, so this can cause issues. For example, the bible has a delay when opening the storage UI and when applying it's interaction effect, and they share the same delay.
/// </remarks>
[RegisterComponent]
2024-02-26 04:36:19 +01:00
[NetworkedComponent, AutoGenerateComponentState, AutoGenerateComponentPause]
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-01-03 21:33:09 -04:00
/// <summary>
/// When the delay starts.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField]
2024-02-26 04:36:19 +01:00
[AutoPausedField]
2024-01-03 21:33:09 -04:00
public TimeSpan DelayStartTime ;
2020-01-22 17:08:14 -05:00
2024-01-03 21:33:09 -04:00
/// <summary>
/// When the delay ends.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField]
2024-02-26 04:36:19 +01:00
[AutoPausedField]
2024-01-03 21:33:09 -04:00
public TimeSpan DelayEndTime ;
2022-03-09 20:12:17 +13:00
2023-09-28 16:20:29 -07:00
/// <summary>
2024-01-03 21:33:09 -04:00
/// Default delay time
2023-09-28 16:20:29 -07:00
/// </summary>
[DataField]
2024-01-03 21:33:09 -04:00
[ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public TimeSpan Delay = TimeSpan . FromSeconds ( 1 ) ;
2020-01-22 17:08:14 -05:00
}