Very basic fsm
This commit is contained in:
8
engine/breeze/ai/fsm.c
Normal file
8
engine/breeze/ai/fsm.c
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#include "fsm.h"
|
||||||
|
|
||||||
|
void bzFSMSetState(BzFSMState *state, const BzFSMState *newState, void *data) {
|
||||||
|
state->exit(data);
|
||||||
|
newState->enter(data);
|
||||||
|
*state = *newState;
|
||||||
|
}
|
||||||
|
|
||||||
20
engine/breeze/ai/fsm.h
Normal file
20
engine/breeze/ai/fsm.h
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#ifndef BREEZE_FSM_H
|
||||||
|
#define BREEZE_FSM_H
|
||||||
|
|
||||||
|
#include "../defines.h"
|
||||||
|
|
||||||
|
#define BZ_FSM_STACK_SIZE 2
|
||||||
|
|
||||||
|
typedef void(*BzFSMFn)(void *data);
|
||||||
|
|
||||||
|
typedef struct BzFSMState {
|
||||||
|
BzFSMFn enter;
|
||||||
|
BzFSMFn exit;
|
||||||
|
BzFSMFn update;
|
||||||
|
} BzFSMState;
|
||||||
|
|
||||||
|
void bzFSMSetState(BzFSMState *state, const BzFSMState *newState, void *data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //BREEZE_FSM_H
|
||||||
Reference in New Issue
Block a user