Fix and integrate BT

This commit is contained in:
2024-01-10 14:42:21 +01:00
parent a9d20cb7f9
commit 3ba5c8932b
16 changed files with 551 additions and 109 deletions

View File

@@ -12,7 +12,7 @@ typedef enum BzBTStatus {
BZ_BT_ERROR,
} BzBTStatus;
typedef BzBTStatus(*BzBTActionFn)(void *data);
typedef BzBTStatus(*BzBTActionFn)(void *data, f32 dt);
typedef enum BzBTNodeType {
// Composite
@@ -38,8 +38,12 @@ typedef struct BzBTNodeState BzBTNodeState;
typedef struct BzBTState {
const BzBTNode *root;
BzBTNodeState *first;
BzBTNodeState *last;
BzBTNodeState *_first;
BzBTNodeState *_last;
BzBTActionFn onSuccess;
BzBTActionFn onFailure;
BzBTActionFn onError;
BzObjectPool *nodeStatePool;
void *userData;
@@ -91,6 +95,8 @@ BzBTNode *bzBTNodeNext(const BzBTNode *node);
const BzBTNodeState *bzBTNodeStateNext(const BzBTNodeState *state);
bool bzBTNodeMatchesState(const BzBTNode *node, const BzBTNodeState *state);
BzBTNode *bzBTCompStateGetRunningChild(const BzBTNodeState *state);
i32 bzBTRepeatStateGetIter(const BzBTNodeState *state);
f32 bzBTDelayStateGetElapsed(const BzBTNodeState *state);