Mod Helpers  v5.9.6
A centralized collection of library code, helpful services, and end-user functions for mod management and information.
HamstarHelpers.Services.Timers.Timers Class Reference

Provides a way to delay the onset of a given action by a set amount of ticks. As a secondary function, MainOnTickGet() provides a way to use Main.OnTick for running background tasks at 60FPS. More...

Static Public Member Functions

static Func< bool > MainOnTickGet ()
 Returns a delegate that returns true when at least 1/60th second (1 60FPS 'tick') has fully elapsed since the last time the delegate returned true (seems necessary?). More...
 
static void RunNow (Action action)
 Convenience method to run a given action 'now' (AKA a 0 delay timer). More...
 
static void RunUntil (Func< bool > func, bool runsWhilePaused)
 Convenience method to repeatedly run a given action 'now' (AKA a 0 delay timer) until indicated otherwise. More...
 
static void RunUntil (Func< bool > func, int times, bool runsWhilePaused)
 Convenience method to repeatedly run a given action 'now' (AKA a 0 delay timer) the indicated number of times, or until indicated otherwise. More...
 
static void SetTimer (int tickDuration, bool runsWhilePaused, Func< bool > func)
 Creates a 'timer' that waits the given amount of ticks before running the given action. Not multi-threaded, but does not obstruct current thread. More...
 
static void SetTimer (string name, int tickDuration, bool runsWhilePaused, Func< bool > func)
 Creates a 'timer' that waits the given amount of ticks before running the given action. Not multi-threaded, but does not obstruct current thread. More...
 
static void SetTimer (string name, int tickDuration, bool runsWhilePaused, Func< int > action)
 Creates a 'timer' that waits the given amount of ticks before running the given action. Not multi-threaded, but does not obstruct current thread. More...
 
static int GetTimerTickDuration (string name)
 Indicates time remaining for the given 'timer'. More...
 
static void UnsetTimer (string name)
 Ends a given 'timer'. More...
 
static void ResetAll ()
 Ends all 'timers'. More...
 

Detailed Description

Provides a way to delay the onset of a given action by a set amount of ticks. As a secondary function, MainOnTickGet() provides a way to use Main.OnTick for running background tasks at 60FPS.

Definition at line 13 of file Timers.cs.

Member Function Documentation

◆ GetTimerTickDuration()

static int HamstarHelpers.Services.Timers.Timers.GetTimerTickDuration ( string  name)
static

Indicates time remaining for the given 'timer'.

Parameters
nameIdentifier of timer.
Returns

Definition at line 156 of file Timers.cs.

◆ MainOnTickGet()

static Func<bool> HamstarHelpers.Services.Timers.Timers.MainOnTickGet ( )
static

Returns a delegate that returns true when at least 1/60th second (1 60FPS 'tick') has fully elapsed since the last time the delegate returned true (seems necessary?).

Returns

Definition at line 25 of file Timers.cs.

◆ ResetAll()

static void HamstarHelpers.Services.Timers.Timers.ResetAll ( )
static

Ends all 'timers'.

Definition at line 191 of file Timers.cs.

◆ RunNow()

static void HamstarHelpers.Services.Timers.Timers.RunNow ( Action  action)
static

Convenience method to run a given action 'now' (AKA a 0 delay timer).

Parameters
action

Definition at line 56 of file Timers.cs.

◆ RunUntil() [1/2]

static void HamstarHelpers.Services.Timers.Timers.RunUntil ( Func< bool >  func,
bool  runsWhilePaused 
)
static

Convenience method to repeatedly run a given action 'now' (AKA a 0 delay timer) until indicated otherwise.

Parameters
funcReturn true to repeat timer.
runsWhilePaused

Definition at line 69 of file Timers.cs.

◆ RunUntil() [2/2]

static void HamstarHelpers.Services.Timers.Timers.RunUntil ( Func< bool >  func,
int  times,
bool  runsWhilePaused 
)
static

Convenience method to repeatedly run a given action 'now' (AKA a 0 delay timer) the indicated number of times, or until indicated otherwise.

Parameters
funcReturn true to repeat timer.
times
runsWhilePaused

Definition at line 82 of file Timers.cs.

◆ SetTimer() [1/3]

static void HamstarHelpers.Services.Timers.Timers.SetTimer ( int  tickDuration,
bool  runsWhilePaused,
Func< bool >  func 
)
static

Creates a 'timer' that waits the given amount of ticks before running the given action. Not multi-threaded, but does not obstruct current thread.

Parameters
tickDuration
runsWhilePaused
funcAction to run. Returns true to make the action repeat after another period of the given tick duration.

Definition at line 103 of file Timers.cs.

◆ SetTimer() [2/3]

static void HamstarHelpers.Services.Timers.Timers.SetTimer ( string  name,
int  tickDuration,
bool  runsWhilePaused,
Func< bool >  func 
)
static

Creates a 'timer' that waits the given amount of ticks before running the given action. Not multi-threaded, but does not obstruct current thread.

Parameters
nameIdentifier of timer. Re-assigning with this identifier replaces any existing timer.
tickDuration
runsWhilePaused
funcAction to run. Returns true to make the action repeat after another period of the given tick duration.

Definition at line 118 of file Timers.cs.

◆ SetTimer() [3/3]

static void HamstarHelpers.Services.Timers.Timers.SetTimer ( string  name,
int  tickDuration,
bool  runsWhilePaused,
Func< int >  action 
)
static

Creates a 'timer' that waits the given amount of ticks before running the given action. Not multi-threaded, but does not obstruct current thread.

Parameters
nameIdentifier of timer. Re-assigning with this identifier replaces any existing timer.
tickDuration
runsWhilePaused
actionAction to run. Returns a value of ticks to indicate the next duration of the next timer loop. Return 0 to terminate loop.

Definition at line 137 of file Timers.cs.

◆ UnsetTimer()

static void HamstarHelpers.Services.Timers.Timers.UnsetTimer ( string  name)
static

Ends a given 'timer'.

Parameters
nameIdentifier of timer.

Definition at line 174 of file Timers.cs.


The documentation for this class was generated from the following files: