Files
tbd-station-14/Content.Shared/Utility/Cooldowns.cs
Acruid ca4fd649fe Massive Namespace Cleanup (#3120)
* Engine namespace changes.

* Automated remove redundant using statements.

* Simplified Graphics namespace.

* Apparently the container system stores full type names in the map file.😞 This updates those names.

* API Changes to LocalizationManager.LoadCulture.

* Update submodule to v0.3.2
2021-02-11 01:13:03 -08:00

29 lines
1.1 KiB
C#

using System;
using Robust.Shared.IoC;
using Robust.Shared.Timing;
namespace Content.Shared.Utility
{
/// <summary>
/// Utilities for working with cooldowns.
/// </summary>
public static class Cooldowns
{
/// <param name="gameTiming">game timing to use, otherwise will resolve using IoCManager.</param>
/// <returns>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.</returns>
public static (TimeSpan start, TimeSpan end) FromNow(TimeSpan offset, IGameTiming gameTiming = null)
{
var now = (gameTiming ?? IoCManager.Resolve<IGameTiming>()).CurTime;
return (now, now + offset);
}
/// <see cref="FromNow"/>
public static (TimeSpan start, TimeSpan end) SecondsFromNow(double seconds, IGameTiming gameTiming = null)
{
return FromNow(TimeSpan.FromSeconds(seconds), gameTiming);
}
}
}