19 void *(*findNext)(void);
21 struct Task *(*run)(
struct Task *task);
39#define TASK_HEADER(Type) \
50 void (*setState)(struct Type *task, s32 state); \
51 void (*setSubstate)(struct Type *task, s32 substate); \
52 void (*setStep)(struct Type *task, s32 step); \
53 void (*setCounter)(struct Type *task, s32 counter); \
54 void (*nextState)(struct Type *task); \
55 void (*nextSubstate)(struct Type *task); \
56 void (*nextStep)(struct Type *task); \
57 void (*tickCounter)(struct Type *task); \
59 void (*destroy)(struct Type *task)
67#define TASK_REGISTRY_SIZE 100
void clearTaskRegistry(void)
Forgets every registered task.
void taskNextStep(Task *task)
Task method: goes to the next step, with its counter at 0.
Task * runTask(Task *task)
Runs a frame of a task and its children; returns it, or NULL once it is gone.
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
#define TASK_REGISTRY_SIZE
The tasks the registry holds at most.
void taskTickCounter(Task *task)
Task method: counts one more.
void * createTaskWithId(void(*update)(), s32 size, s32 childrenSize, s32 id)
Allocates a zeroed task of size bytes (header included) with room for childrenSize / 4 child tasks.
void unregisterTask(Task *task)
Removes a task from the registry.
void registerTask(Task *task)
Adds a task to the first free entry of the registry (ignored when it is full)
void * findNextTask(void)
The next registered task that matches findTask's id and keys (-1 matches anything),...
void destroyTask(Task *task)
Default destructor: kills the children, then frees the task.
TaskRegistry TASK_REGISTRY
void taskSetCounter(Task *task, s32 counter)
Task method: sets the counter.
void taskSetState(Task *task, s32 state)
Task method: goes to state state, from substate 0.
void taskSetStep(Task *task, s32 step)
Task method: goes to step step, with its counter at 0.
struct Task * executeTask(struct Task *task)
One frame of a task and its children; returns NULL once the task is gone.
#define TASK_HEADER(Type)
void taskSetSubstate(Task *task, s32 substate)
Task method: goes to substate substate, from step 0.
void taskNextState(Task *task)
Task method: goes to the next state, from substate 0.
void runChildTasks(Task *task)
Runs a frame of each child of a task, dropping the ones that end.
void killTask(Task *task)
Ends a task now: its last update and destroy run at once.
void * findTask(s32 id, s32 key1, s32 key2)
The first registered task that matches (-1 matches anything), or NULL.
void taskNextSubstate(Task *task)
Task method: goes to the next substate, from step 0.
The task registry's methods (TASK_REGISTRY.funcs)
void(* remove)(struct Task *task)
void(* runChildren)(struct Task *task)
void(* kill)(struct Task *task)
void(* add)(struct Task *task)
Tasks created with an id, so that other code can find them.
Task * tasks[100]
NULL for a free entry.
s32 findId
-1 matches anything
Any task, seen through its header.