Skip to main content

Timeline

A class in Alta.Timing.Runtime, Alta.Timing.

The game's scheduler for callbacks at a game time or on a repeat (respawns, decay, loot refills and the like). Get it from Instance; it runs on the main thread on both sides, and the server saves its time with the world.

Constructors​

MemberWhat it is
Timeline(TimeSpan startingTime)Creates a Timeline from startingTime.

Fields​

3 private and internal fields
MemberWhat it is
private FastPriorityQueueTimeSpan<Timeline.Entry> entriesPriority queue of scheduled entries, ordered by target time.
private static Timeline instanceBacking field for Instance.
private static Logger loggerNLog logger for this class.

Properties​

MemberWhat it is
TimeSpan DeltaTime { get; private set; }Time the timeline moved in the last Update, scaled by TimeSpeed.
static Timeline Instance { get; }The game's timeline. Created on first use along with a Timeline GameObject whose updater advances it.
TimeSpan Time { get; private set; }Current timeline time. Starts at zero; the server restores it from the world save.
float TimeSpeed { get; set; }Multiplier on how fast timeline time passes. Values of 0 or below are treated as 1.

Events​

MemberWhat it is
event Action<TimeSpan> TimeChangedRaised after each Update with the scaled delta time.

Methods​

MemberWhat it is
Timeline.IEntry CallAfterDuration(Action callback, float durationSeconds)Schedules a one-off callback the given seconds or TimeSpan from now. Returns an entry you can pass to Cancel.
Timeline.IEntry CallAfterDuration(Action callback, TimeSpan duration)Schedules a one-off callback the given seconds or TimeSpan from now. Returns an entry you can pass to Cancel.
Timeline.IEntry CallRepeatableAfterDuration(Action callback, float durationSeconds, float repeatIntervalSeconds)Schedules a callback after a delay and then every interval. Intervals under 0.01 s are scheduled once instead.
Timeline.IEntry CallRepeatableAfterDuration(Action callback, TimeSpan duration, TimeSpan repeatInterval)Schedules a callback after a delay and then every interval. Intervals under 0.01 s are scheduled once instead.
static void Cancel(ref Timeline.IEntry entry)Stops an entry from firing and sets your reference to null. Safe to call with null.
void ClearEntries()Drops every scheduled entry.
static Timeline.SerializedEntryState GetSerializedState(TimeSpan targetTime)Says whether a saved target time is unset, already past or still ahead.
Timeline.IEntry InsertCallbackAtTime(Action callback, TimeSpan time)Schedules a one-off callback at an exact timeline time.
void Load(TimeSpan time)Sets the time and runs every entry that's now due, rescheduling repeating ones.
static Timeline.SerializedEntryState LoadEntry(out Timeline.IEntry entry, Action callback, TimeSpan targetTime, bool isRegistering = true, bool isInvokingPast = true)Restores a saved one-off entry: runs the callback if its time has passed, or schedules it if it's ahead.
static int LoadRepeatableEntry(out Timeline.IEntry entry, Action callback, TimeSpan targetTime, TimeSpan interval)Restores a saved repeating entry and returns how many intervals were missed. It doesn't call the callback for them.
static TimeSpan SaveEntry(Timeline.IEntry entry)Returns an entry's target time for saving, or zero if it's null or already due.
Timeline.SerializedEntryState SerializeEntry(ref Timeline.IEntry iEntry, Action callback, Stream stream, bool isRegistering = true, bool isInvokingPast = true)Writes or reads an entry's target time; on read, runs it if past and schedules it if ahead.
void SerializeRepeatableEntry(ref Timeline.IEntry iEntry, Action callback, Stream stream, bool isInvokingPast)Writes or reads a repeating entry; on read, calls the callback once per missed interval (capped at 1000) and reschedules it.
void Update(TimeSpan deltaTime)Advances the timeline by a real time delta, scaled by TimeSpeed, and runs due entries.
3 private and internal methods
MemberWhat it is
private void EnqueEntry(Timeline.Entry entry)Adds an entry to the queue, doubling the queue's size when it fills.
private Timeline.IEntry InsertRepeatableCallbackAtTime(Action callback, TimeSpan time, TimeSpan repeatInterval)Schedules a repeating callback at a timeline time. Intervals under 0.01 s are logged and scheduled once.
private Timeline.SerializedEntryState SerializeEntry(ref Timeline.IEntry iEntry, Stream stream, out TimeSpan targetTime)Writes or reads an entry's target time; on read, runs it if past and schedules it if ahead.

Used in​

Members of other types that take, return or hold a Timeline: