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

@@ -7,7 +7,7 @@ BzObjectPool *nodeStatePool = NULL;
BzBTNode *printBT = NULL;
BzBTState agentState;
BzBTStatus printAction(void *data) {
BzBTStatus printAction(void *data, f32 dt) {
bzLogInfo("Hello, world!");
return BZ_BT_SUCCESS;
}
@@ -48,7 +48,7 @@ void deinit(int *game) {
bzObjectPoolDestroy(nodeStatePool);
}
void igRenderBTNode(const BzBTNode *node, const BzBTNodeState *state, bool sameLine, i32 depth) {
void igVisualizeBTState(const BzBTNode *node, const BzBTNodeState *state, bool sameLine, i32 depth) {
const BzBTNode *child = bzBTNodeChild(node);
BzBTNodeType type = bzBTGetNodeType(node);
char extraInfo[128];
@@ -109,7 +109,7 @@ void igRenderBTNode(const BzBTNode *node, const BzBTNodeState *state, bool sameL
while (child) {
if (hasSingleChild) igSameLine(0, 0);
igRenderBTNode(child, state, hasSingleChild, depth);
igVisualizeBTState(child, state, hasSingleChild, depth);
child = bzBTNodeNext(child);
}
}
@@ -117,7 +117,7 @@ void igRenderBTNode(const BzBTNode *node, const BzBTNodeState *state, bool sameL
void igRenderBT(BzBTState *state) {
const BzBTNode *root = state->root;
if (igBegin("BehaviourTree", NULL, 0)) {
igRenderBTNode(root, state->first, false, 0);
igVisualizeBTState(root, state->_first, false, 0);
}
igEnd();
}