[DataField]
public int MaximumWait { get; private set; } = 10 * 60;
+ /// <summary>
+ /// If true, the delay before the first advertisement (at MapInit) will ignore <see cref="MinimumWait"/>
+ /// and instead be rolled between 0 and <see cref="MaximumWait"/>. This only applies to the initial delay;
+ /// <see cref="MinimumWait"/> will be respected after that.
+ /// </summary>
+ [DataField]
+ public bool Prewarm = true;
+
/// <summary>
/// The identifier for the advertisements pack prototype.
/// </summary>
private void OnMapInit(EntityUid uid, AdvertiseComponent advert, MapInitEvent args)
{
- RandomizeNextAdvertTime(advert);
+ var prewarm = advert.Prewarm;
+ RandomizeNextAdvertTime(advert, prewarm);
_nextCheckTime = MathHelper.Min(advert.NextAdvertisementTime, _nextCheckTime);
}
- private void RandomizeNextAdvertTime(AdvertiseComponent advert)
+ private void RandomizeNextAdvertTime(AdvertiseComponent advert, bool prewarm = false)
{
- var minDuration = Math.Max(1, advert.MinimumWait);
+ var minDuration = prewarm ? 0 : Math.Max(1, advert.MinimumWait);
var maxDuration = Math.Max(minDuration, advert.MaximumWait);
var waitDuration = TimeSpan.FromSeconds(_random.Next(minDuration, maxDuration));