Add/Get name for nodes in behaviour tree
This commit is contained in:
@@ -15,6 +15,7 @@ struct BzBTNode {
|
||||
BzBTNode *next;
|
||||
|
||||
BzBTNodeType type;
|
||||
const char *name;
|
||||
union {
|
||||
struct {
|
||||
i32 n;
|
||||
@@ -24,10 +25,8 @@ struct BzBTNode {
|
||||
} delay;
|
||||
struct {
|
||||
BzBTActionFn fn;
|
||||
const char *name;
|
||||
} action;
|
||||
} as;
|
||||
|
||||
};
|
||||
|
||||
struct BzBTNodeState {
|
||||
@@ -167,14 +166,19 @@ BzBTNode *bzBTDecorDelay(BzObjectPool *nodePool, BzBTNode *parent, f32 ms) {
|
||||
return node;
|
||||
}
|
||||
|
||||
BzBTNode *bzBTAction(BzObjectPool *nodePool, BzBTNode *parent, BzBTActionFn fn,
|
||||
const char *name) {
|
||||
BzBTNode *bzBTAction(BzObjectPool *nodePool, BzBTNode *parent, BzBTActionFn fn) {
|
||||
BzBTNode *node = bzBTNodeMake(nodePool, parent, BZ_BT_ACTION);
|
||||
node->as.action.fn = fn;
|
||||
node->as.action.name = name;
|
||||
return node;
|
||||
}
|
||||
|
||||
void bzBTNodeSetName(BzBTNode *node, const char *name) {
|
||||
node->name = name;
|
||||
}
|
||||
const char *bzBTNodeGetName(const BzBTNode *node) {
|
||||
return node->name;
|
||||
}
|
||||
|
||||
i32 bzBTDecorGetRepeat(const BzBTNode *node) {
|
||||
BZ_ASSERT(node->type == BZ_BT_DECOR_REPEAT);
|
||||
return node->as.repeat.n;
|
||||
@@ -188,10 +192,6 @@ BzBTActionFn bzBTActionGetFn(const BzBTNode *node) {
|
||||
BZ_ASSERT(node->type == BZ_BT_ACTION);
|
||||
return node->as.action.fn;
|
||||
}
|
||||
const char *bzBTActionGetName(const BzBTNode *node) {
|
||||
BZ_ASSERT(node->type == BZ_BT_ACTION);
|
||||
return node->as.action.name;
|
||||
}
|
||||
|
||||
BzBTNodeType bzBTGetNodeType(const BzBTNode *node) {
|
||||
return node->type;
|
||||
|
||||
Reference in New Issue
Block a user