Generates recurring events in the game Cities Skylines. The interval of a SkylinesTimer
is relevant to game speed. In anouther word, it take the user's game speed (like 1x > / 2x >> / 3x >>>) into account.
Initializes the singleton of SkylinesTimeSource
in your LoadingExtensionBase
:
public override void OnLevelLoaded(LoadMode mode) {
// ...
SkylinesTimeSource.Instance = new SkylinesTimeSource(Singleton<SimulationManager>.instance);
// ...
}
Update SkylinesTimeSource
in every frame:
public override void OnBeforeSimulationFrame() {
base.OnBeforeSimulationFrame();
if (MyMod.Enabled && Loader.IsInGame) {
SkylinesTimeSource.Instance.OnFrameUpdate();
}
}
Initializes a new instance of SkylinesTimer
:
ISkylinesTimer timer = new SkylinesTimer(SkylinesTimeSource.Instance, 60);
timer.Elapsed += () => { /*...*/ };
timer.Start();