2023-07-21 09:50:06 +00:00
|
|
|
/**
|
|
|
|
* behavior_tree.h
|
|
|
|
* =============================================================================
|
2024-03-04 20:36:16 +00:00
|
|
|
* Copyright 2021-2024 Serhii Snitsaruk
|
2023-07-21 09:50:06 +00:00
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style
|
|
|
|
* license that can be found in the LICENSE file or at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
|
|
|
* =============================================================================
|
|
|
|
*/
|
2022-08-30 16:48:49 +00:00
|
|
|
|
|
|
|
#ifndef BEHAVIOR_TREE_H
|
|
|
|
#define BEHAVIOR_TREE_H
|
|
|
|
|
2024-01-23 19:02:23 +00:00
|
|
|
#include "../blackboard/blackboard_plan.h"
|
2024-01-06 23:47:46 +00:00
|
|
|
#include "tasks/bt_task.h"
|
2023-07-20 16:35:36 +00:00
|
|
|
|
2024-01-06 23:47:46 +00:00
|
|
|
#ifdef LIMBOAI_MODULE
|
|
|
|
#include "core/io/resource.h"
|
|
|
|
#endif // LIMBOAI_MODULE
|
|
|
|
|
|
|
|
#ifdef LIMBOAI_GDEXTENSION
|
|
|
|
#include <godot_cpp/classes/resource.hpp>
|
|
|
|
using namespace godot;
|
|
|
|
#endif // LIMBOAI_GDEXTENSION
|
2022-08-30 16:48:49 +00:00
|
|
|
|
|
|
|
class BehaviorTree : public Resource {
|
|
|
|
GDCLASS(BehaviorTree, Resource);
|
|
|
|
|
|
|
|
private:
|
|
|
|
String description;
|
2024-01-23 19:02:23 +00:00
|
|
|
Ref<BlackboardPlan> blackboard_plan;
|
2022-08-30 16:48:49 +00:00
|
|
|
Ref<BTTask> root_task;
|
|
|
|
|
2024-01-26 13:35:33 +00:00
|
|
|
void _plan_changed();
|
2024-05-14 09:39:32 +00:00
|
|
|
void _set_editor_behavior_tree_hint();
|
|
|
|
void _unset_editor_behavior_tree_hint();
|
2024-01-26 13:35:33 +00:00
|
|
|
|
2022-08-30 16:48:49 +00:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
2024-01-06 23:47:46 +00:00
|
|
|
#ifdef LIMBOAI_MODULE
|
2022-12-19 09:29:46 +00:00
|
|
|
virtual bool editor_can_reload_from_file() override { return false; }
|
2024-01-06 23:47:46 +00:00
|
|
|
#endif
|
2022-12-19 09:29:46 +00:00
|
|
|
|
2024-01-25 13:27:14 +00:00
|
|
|
void set_description(const String &p_value);
|
|
|
|
String get_description() const { return description; }
|
|
|
|
|
2024-01-23 19:02:23 +00:00
|
|
|
void set_blackboard_plan(const Ref<BlackboardPlan> &p_plan);
|
|
|
|
Ref<BlackboardPlan> get_blackboard_plan() const { return blackboard_plan; }
|
2024-01-23 14:31:56 +00:00
|
|
|
|
2024-01-25 13:27:14 +00:00
|
|
|
void set_root_task(const Ref<BTTask> &p_value);
|
2022-08-30 16:48:49 +00:00
|
|
|
Ref<BTTask> get_root_task() const { return root_task; }
|
|
|
|
|
|
|
|
Ref<BehaviorTree> clone() const;
|
2024-01-10 21:45:42 +00:00
|
|
|
void copy_other(const Ref<BehaviorTree> &p_other);
|
2024-05-01 21:20:17 +00:00
|
|
|
Ref<BTTask> instantiate(Node *p_agent, const Ref<Blackboard> &p_blackboard, Node *p_scene_root) const;
|
2024-01-23 14:31:56 +00:00
|
|
|
|
|
|
|
BehaviorTree();
|
2024-01-26 13:35:33 +00:00
|
|
|
~BehaviorTree();
|
2022-08-30 16:48:49 +00:00
|
|
|
};
|
|
|
|
|
2024-01-13 16:10:42 +00:00
|
|
|
#endif // BEHAVIOR_TREE_H
|