Expand UseDelay to support multiple delays per entity; fix bible healing and bag pickup (#27234)
* 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
This commit is contained in:
@@ -1,38 +1,47 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Timing;
|
||||
|
||||
/// <summary>
|
||||
/// Timer that creates a cooldown each time an object is activated/used
|
||||
/// 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>
|
||||
/// <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]
|
||||
[NetworkedComponent, AutoGenerateComponentState]
|
||||
[Access(typeof(UseDelaySystem))]
|
||||
public sealed partial class UseDelayComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// When the delay starts.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField]
|
||||
[AutoPausedField]
|
||||
public TimeSpan DelayStartTime;
|
||||
[DataField, AutoNetworkedField]
|
||||
public Dictionary<string, UseDelayInfo> Delays = [];
|
||||
|
||||
/// <summary>
|
||||
/// When the delay ends.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField]
|
||||
[AutoPausedField]
|
||||
public TimeSpan DelayEndTime;
|
||||
|
||||
/// <summary>
|
||||
/// Default delay time
|
||||
/// 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]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[AutoNetworkedField]
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user