Table of Contents

Class UnityLoopTicker<TState>

Namespace
Uncreated.Warfare.Util.Timing
Assembly
Uncreated.Warfare.dll

Uses a Unity Coroutine(TimeSpan) with the SDG.Framework.Utilities.TimeUtility singleton.

public class UnityLoopTicker<TState> : ILoopTicker<TState>, ILoopTicker, IDisposable

Type Parameters

TState
Inheritance
UnityLoopTicker<TState>
Implements
ILoopTicker<TState>
Inherited Members

Constructors

UnityLoopTicker(MonoBehaviour, ILogger, TimeSpan, bool, TState?, TickerCallback<ILoopTicker<TState>>?)

Create a new timer.

public UnityLoopTicker(MonoBehaviour component, ILogger logger, TimeSpan periodicDelay, bool invokeImmediately, TState? state, TickerCallback<ILoopTicker<TState>>? onTick = null)

Parameters

component MonoBehaviour
logger ILogger
periodicDelay TimeSpan

How often to invoke the timer.

invokeImmediately bool

If the timer should be invoked now or wait a period.

state TState
onTick TickerCallback<ILoopTicker<TState>>

Callback since the timer being invoked now would mean you couldn't subscribe to the event first.

UnityLoopTicker(MonoBehaviour, ILogger, TimeSpan, TimeSpan, TState?, TickerCallback<ILoopTicker<TState>>?)

Create a new timer.

public UnityLoopTicker(MonoBehaviour component, ILogger logger, TimeSpan initialDelay, TimeSpan periodicDelay, TState? state, TickerCallback<ILoopTicker<TState>>? onTick = null)

Parameters

component MonoBehaviour
logger ILogger
initialDelay TimeSpan

How long to wait to initially invoke the timer.

periodicDelay TimeSpan

How often to invoke the timer.

state TState
onTick TickerCallback<ILoopTicker<TState>>

Callback since the timer being invoked now would mean you couldn't subscribe to the event first.

Properties

InitialDelay

Delay before the first invocation.

public TimeSpan InitialDelay { get; }

Property Value

TimeSpan

PeriodicDelay

Delay between each subsequent invocation.

public TimeSpan PeriodicDelay { get; }

Property Value

TimeSpan

State

Generic state that can be used to store information.

public TState? State { get; }

Property Value

TState

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

~UnityLoopTicker()

protected ~UnityLoopTicker()

Events

OnTick

Invoked every Delay seconds.

public event TickerCallback<ILoopTicker<TState>>? OnTick

Event Type

TickerCallback<ILoopTicker<TState>>