NoJobEngine 2.0.7
Loading...
Searching...
No Matches
BTInstance.h
Go to the documentation of this file.
1
6#pragma once
7#include "BTTree.h"
8#include <memory>
9#include <stdexcept>
10
11namespace NoJob {
13public:
14 explicit BTInstance(std::shared_ptr<const BTTree> tree) : m_Tree(std::move(tree)) {
15 if (!m_Tree) throw std::invalid_argument("BTInstance requires a tree");
16 }
17 BTStatus Tick(float dt) { m_Context.BeginTick(); return m_Tree->Root().Tick(m_Context, dt); }
18 void Reset() { m_Tree->Root().Reset(m_Context); m_Context.Reset(); }
19 const BTTree& Tree() const { return *m_Tree; }
20 BTContext& Context() { return m_Context; }
21 const BTContext& Context() const { return m_Context; }
22private:
23 std::shared_ptr<const BTTree> m_Tree;
24 BTContext m_Context;
25};
26}
Behavior tree ownership and evaluation.
BTContext & Context()
Definition BTInstance.h:20
BTInstance(std::shared_ptr< const BTTree > tree)
Definition BTInstance.h:14
const BTContext & Context() const
Definition BTInstance.h:21
BTStatus Tick(float dt)
Definition BTInstance.h:17
const BTTree & Tree() const
Definition BTInstance.h:19
BTStatus
Result of a behavior tree node tick.
Definition BTNode.h:13