Properly clear state
This commit is contained in:
@@ -470,8 +470,13 @@ static inline BzBTExecReturn bzBTExecuteComposite(const BzBTNode *node, f32 dt,
|
||||
bzBTClearNodeState(pChild, state, statePool);
|
||||
pChild = pChild->next;
|
||||
}
|
||||
// For finished parallel composites clean up all children
|
||||
if (finished && isParallel) {
|
||||
execStateClear(&execReturn.state, statePool);
|
||||
}
|
||||
|
||||
if (finished) {
|
||||
// Finished composites mustn't have state
|
||||
BZ_ASSERT(execReturn.state.first == NULL);
|
||||
if (nodeState) releaseNodeState(nodeState, statePool);
|
||||
return execReturn;
|
||||
@@ -501,12 +506,11 @@ static inline BzBTExecReturn bzBTExecuteDecorator(const BzBTNode *node, f32 dt,
|
||||
case BZ_BT_DECOR_DELAY:
|
||||
nodeState = ensureValidNodeState(node, nodeState, statePool);
|
||||
nodeState->as.delay.elapsed += dt;
|
||||
execStatePushBack(&execReturn.state, nodeState);
|
||||
if (nodeState->as.delay.elapsed < node->as.delay.ms) {
|
||||
execStatePushBack(&execReturn.state, nodeState);
|
||||
execReturn.status = BZ_BT_RUNNING;
|
||||
return execReturn;
|
||||
}
|
||||
BZ_ASSERT(nodeState == execStatePopFront(&execReturn.state));
|
||||
releaseNodeState(nodeState, statePool);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -27,9 +27,10 @@ bool init(int *game) {
|
||||
// print "Hello, world!"
|
||||
printBT = bzBTMakeRoot(nodePool);
|
||||
BzBTNode *pseq = bzBTCompPSelector(nodePool, printBT);
|
||||
bzBTDecorDelay(nodePool, pseq, 2.0f);
|
||||
BzBTNode *node = bzBTDecorFail(nodePool, pseq);
|
||||
bzBTDecorDelay(nodePool, node, 2.0f);
|
||||
|
||||
BzBTNode *node = bzBTDecorRepeat(nodePool, pseq, 5);
|
||||
node = bzBTDecorRepeat(nodePool, pseq, 5);
|
||||
|
||||
BzBTNode *seq = bzBTCompSequence(nodePool, node);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user