* Upgraded UseDelay to support multiple delays per entity * Implement secondary delay for bibles. Also some improvements to make it work nicely. * Documentation is good * Reserve the previous change; now Storage uses the special ID and Bible uses the default. * .0 * Added VV support to UseDelayInfo * Serialize better * No register, just setlength
48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using Robust.Shared.GameStates;
|
|
using Robust.Shared.Serialization;
|
|
|
|
namespace Content.Shared.Timing;
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
[RegisterComponent]
|
|
[NetworkedComponent, AutoGenerateComponentState]
|
|
[Access(typeof(UseDelaySystem))]
|
|
public sealed partial class UseDelayComponent : Component
|
|
{
|
|
[DataField, AutoNetworkedField]
|
|
public Dictionary<string, UseDelayInfo> Delays = [];
|
|
|
|
/// <summary>
|
|
/// Default delay time.
|
|
/// </summary>
|
|
/// <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>
|
|
[DataField]
|
|
public TimeSpan Delay = TimeSpan.FromSeconds(1);
|
|
}
|
|
|
|
[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;
|
|
}
|
|
}
|