Skip to content

Instantly share code, notes, and snippets.

@pardeike
Created April 15, 2020 19:27
Show Gist options
  • Save pardeike/5e460064f4c1bd5b6618840f971e2f9a to your computer and use it in GitHub Desktop.
Save pardeike/5e460064f4c1bd5b6618840f971e2f9a to your computer and use it in GitHub Desktop.
static void RunEvery(int tickInterval, int currentTicks, Action[] actions)
{
var len = actions.Length;
for (var i = 0; i < len; i++)
{
var offset = len > 1 ? i + i * ((tickInterval - len) / len) : 0;
if (offset % tickInterval == currentTicks % tickInterval)
actions[i]();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment