Allow advertisement timers to prewarm (#26900)
Allow advertisement timers to prewarm.
This commit is contained in:
@@ -37,13 +37,14 @@ public sealed class AdvertiseSystem : EntitySystem
|
||||
|
||||
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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user