Add bt nodes init
This commit is contained in:
@@ -146,6 +146,12 @@ Asset::LoadResult BehaviorTree::load()
|
||||
return LoadResult::Failed;
|
||||
}
|
||||
|
||||
// Init graph
|
||||
if (Graph.Root)
|
||||
{
|
||||
Graph.Root->Init(this);
|
||||
}
|
||||
|
||||
return LoadResult::Ok;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,18 @@ public:
|
||||
API_FIELD() String Name;
|
||||
|
||||
// TODO: decorators/conditionals
|
||||
// TODO: init methods
|
||||
// TODO: instance data ctor/dtor
|
||||
// TODO: start/stop methods
|
||||
// TODO: update method
|
||||
|
||||
/// <summary>
|
||||
/// Initializes node state. Called after whole tree is loaded and nodes hierarchy is setup.
|
||||
/// </summary>
|
||||
/// <param name="tree">Node owner asset.</param>
|
||||
API_FUNCTION() virtual void Init(BehaviorTree* tree)
|
||||
{
|
||||
}
|
||||
|
||||
void Serialize(SerializeStream& stream, const void* otherObj) override;
|
||||
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override;
|
||||
};
|
||||
|
||||
@@ -18,3 +18,9 @@ void BehaviorTreeNode::Deserialize(DeserializeStream& stream, ISerializeModifier
|
||||
Name.Clear(); // Missing Name is assumes as unnamed node
|
||||
DESERIALIZE(Name);
|
||||
}
|
||||
|
||||
void BehaviorTreeCompoundNode::Init(BehaviorTree* tree)
|
||||
{
|
||||
for (BehaviorTreeNode* child : Children)
|
||||
child->Init(tree);
|
||||
}
|
||||
|
||||
@@ -12,11 +12,14 @@ API_CLASS(Abstract) class FLAXENGINE_API BehaviorTreeCompoundNode : public Behav
|
||||
{
|
||||
DECLARE_SCRIPTING_TYPE_WITH_CONSTRUCTOR_IMPL(BehaviorTreeCompoundNode, BehaviorTreeNode);
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
/// List with all child nodes.
|
||||
/// </summary>
|
||||
API_FIELD(Readonly) Array<BehaviorTreeNode*, InlinedAllocation<8>> Children;
|
||||
|
||||
public:
|
||||
// [BehaviorTreeNode]
|
||||
void Init(BehaviorTree* tree) override;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user