IEnum Tasks

Modularity provides lightweight, opt-in "tasks" you can start/stop per script component instance.

Important: In this version, an IEnum task is just a function with signature void(ScriptContext&, float) that is called every frame while it's registered.

Macros

  • IEnum_Start(fn) — Start a task
  • IEnum_Stop(fn) — Stop a task
  • IEnum_Ensure(fn) — Start if not already running

Example: Toggle Rotation

1 400">static 400">bool autoRotate = 400">false;
2 400">static 400">glm::400">vec3 speed = {0, 45, 0};
3
4 400">static 400">void RotateTask(400">ScriptContext& ctx, 400">float dt) {
5 400">if (!ctx.object) 400">return;
6 ctx.SetRotation(ctx.object->rotation + speed * dt);
7 }
8
9 400">extern "C" 400">void Script_OnInspector(400">ScriptContext& ctx) {
10 400">ImGui::Checkbox("Auto Rotate", &autoRotate);
11 400">if (autoRotate) IEnum_Ensure(RotateTask);
12 400">else IEnum_Stop(RotateTask);
13 ctx.MarkDirty();
14 }

Notes

  • Tasks are stored per ScriptComponent instance.
  • Don't spam logs every frame inside a task; use "warn once" patterns.
  • Use IEnum to avoid cluttering TickUpdate with conditional logic.