Files
OldThink/Content.Shared/Timing/UseDelayComponent.cs

39 lines
1.4 KiB
C#
Raw Normal View History

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;
namespace Content.Shared.Timing;
2022-03-09 20:12:17 +13: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]
[NetworkedComponent, AutoGenerateComponentState, AutoGenerateComponentPause]
2024-01-03 21:33:09 -04:00
[Access(typeof(UseDelaySystem))]
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]
[AutoPausedField]
2024-01-03 21:33:09 -04:00
public TimeSpan DelayStartTime;
2024-01-03 21:33:09 -04:00
/// <summary>
/// When the delay ends.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField]
[AutoPausedField]
2024-01-03 21:33:09 -04:00
public TimeSpan DelayEndTime;
2022-03-09 20:12:17 +13:00
/// <summary>
2024-01-03 21:33:09 -04:00
/// Default delay time
/// </summary>
[DataField]
2024-01-03 21:33:09 -04:00
[ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
public TimeSpan Delay = TimeSpan.FromSeconds(1);
}