| 132 | } |
| 133 | |
| 134 | BehaviorState::BehaviorState(BehaviorTreeConstPtr tree, LuaTable context, Maybe<BlackboardWeakPtr> blackboard) : m_tree(tree), m_luaContext(std::move(context)) { |
| 135 | if (blackboard) |
| 136 | m_board = *blackboard; |
| 137 | else |
| 138 | m_board = make_shared<Blackboard>(m_luaContext); |
| 139 | |
| 140 | LuaFunction require = m_luaContext.get<LuaFunction>("require"); |
| 141 | for (auto script : m_tree->scripts) |
| 142 | require.invoke(script); |
| 143 | |
| 144 | for (String const& name : m_tree->functions) |
| 145 | m_functions.set(name, m_luaContext.get<LuaFunction>(name)); |
| 146 | } |
| 147 | |
| 148 | NodeStatus BehaviorState::run(float dt) { |
| 149 | m_lastDt = dt; |