using System;
using Robust.Shared.IoC;
using Robust.Shared.Timing;
namespace Content.Shared.Cooldown
{
///
/// Utilities for working with cooldowns.
///
public static class Cooldowns
{
/// game timing to use, otherwise will resolve using IoCManager.
/// a cooldown interval starting at GameTiming.Curtime and ending at (offset) from CurTime.
/// For example, passing TimeSpan.FromSeconds(5) will create an interval
/// from now to 5 seconds from now.
public static (TimeSpan start, TimeSpan end) FromNow(TimeSpan offset, IGameTiming? gameTiming = null)
{
var now = (gameTiming ?? IoCManager.Resolve()).CurTime;
return (now, now + offset);
}
///
public static (TimeSpan start, TimeSpan end) SecondsFromNow(double seconds, IGameTiming? gameTiming = null)
{
return FromNow(TimeSpan.FromSeconds(seconds), gameTiming);
}
}
}