Rename BlackboardSource => BlackboardPlan

Because it's a better name ;)
This commit is contained in:
Serhii Snitsaruk 2024-01-23 20:02:23 +01:00
parent b04f7530e4
commit 20a995d1d2
13 changed files with 109 additions and 96 deletions

View File

@ -1,5 +1,5 @@
/**
* blackboard_source.cpp
* blackboard_plan.cpp
* =============================================================================
* Copyright 2021-2024 Serhii Snitsaruk
*
@ -9,9 +9,9 @@
* =============================================================================
*/
#include "blackboard_source.h"
#include "blackboard_plan.h"
bool BlackboardSource::_set(const StringName &p_name, const Variant &p_value) {
bool BlackboardPlan::_set(const StringName &p_name, const Variant &p_value) {
String prop_name = p_name;
// * Editor
@ -46,7 +46,7 @@ bool BlackboardSource::_set(const StringName &p_name, const Variant &p_value) {
return false;
}
bool BlackboardSource::_get(const StringName &p_name, Variant &r_ret) const {
bool BlackboardPlan::_get(const StringName &p_name, Variant &r_ret) const {
String prop_name = p_name;
// * Editor
@ -75,7 +75,7 @@ bool BlackboardSource::_get(const StringName &p_name, Variant &r_ret) const {
return true;
}
void BlackboardSource::_get_property_list(List<PropertyInfo> *p_list) const {
void BlackboardPlan::_get_property_list(List<PropertyInfo> *p_list) const {
for (const KeyValue<String, BBVariable> &kv : data) {
String var_name = kv.key;
BBVariable var = kv.value;
@ -92,11 +92,11 @@ void BlackboardSource::_get_property_list(List<PropertyInfo> *p_list) const {
}
}
bool BlackboardSource::_property_can_revert(const StringName &p_name) const {
bool BlackboardPlan::_property_can_revert(const StringName &p_name) const {
return base.is_valid() && base->data.has(p_name);
}
bool BlackboardSource::_property_get_revert(const StringName &p_name, Variant &r_property) const {
bool BlackboardPlan::_property_get_revert(const StringName &p_name, Variant &r_property) const {
if (base->data.has(p_name)) {
r_property = base->data[p_name].get_value();
return true;
@ -104,40 +104,40 @@ bool BlackboardSource::_property_get_revert(const StringName &p_name, Variant &r
return false;
}
void BlackboardSource::set_base_source(const Ref<BlackboardSource> &p_base) {
void BlackboardPlan::set_base_plan(const Ref<BlackboardPlan> &p_base) {
base = p_base;
sync_with_base_source();
sync_with_base_plan();
emit_changed();
}
void BlackboardSource::set_value(const String &p_name, const Variant &p_value) {
void BlackboardPlan::set_value(const String &p_name, const Variant &p_value) {
ERR_FAIL_COND(!data.has(p_name));
data.get(p_name).set_value(p_value);
}
Variant BlackboardSource::get_value(const String &p_name) const {
Variant BlackboardPlan::get_value(const String &p_name) const {
ERR_FAIL_COND_V(!data.has(p_name), Variant());
return data.get(p_name).get_value();
}
void BlackboardSource::add_var(const String &p_name, const BBVariable &p_var) {
void BlackboardPlan::add_var(const String &p_name, const BBVariable &p_var) {
ERR_FAIL_COND(data.has(p_name));
ERR_FAIL_COND(base.is_valid());
data.insert(p_name, p_var);
}
void BlackboardSource::remove_var(const String &p_name) {
void BlackboardPlan::remove_var(const String &p_name) {
ERR_FAIL_COND(!data.has(p_name));
ERR_FAIL_COND(base.is_valid());
data.erase(p_name);
}
BBVariable BlackboardSource::get_var(const String &p_name) {
BBVariable BlackboardPlan::get_var(const String &p_name) {
ERR_FAIL_COND_V(!data.has(p_name), BBVariable());
return data.get(p_name);
}
PackedStringArray BlackboardSource::list_vars() const {
PackedStringArray BlackboardPlan::list_vars() const {
PackedStringArray ret;
for (const KeyValue<String, BBVariable> &kv : data) {
ret.append(kv.key);
@ -145,10 +145,12 @@ PackedStringArray BlackboardSource::list_vars() const {
return ret;
}
void BlackboardSource::sync_with_base_source() {
void BlackboardPlan::sync_with_base_plan() {
if (base.is_null()) {
return;
}
// Sync variables with the base plan.
for (const KeyValue<String, BBVariable> &kv : base->data) {
if (!data.has(kv.key)) {
data.insert(kv.key, kv.value.duplicate());
@ -163,9 +165,16 @@ void BlackboardSource::sync_with_base_source() {
var.set_value(kv.value.get_value());
}
}
// Erase variables that do not exist in the base plan.
for (const KeyValue<String, BBVariable> &kv : data) {
if (!base->data.has(kv.key)) {
data.erase(kv.key);
}
}
}
Ref<Blackboard> BlackboardSource::create_blackboard() {
Ref<Blackboard> BlackboardPlan::create_blackboard() {
Ref<Blackboard> bb = memnew(Blackboard);
for (const KeyValue<String, BBVariable> &kv : data) {
bb->add_var(kv.key, kv.value.duplicate());
@ -173,7 +182,7 @@ Ref<Blackboard> BlackboardSource::create_blackboard() {
return bb;
}
void BlackboardSource::populate_blackboard(const Ref<Blackboard> &p_blackboard, bool overwrite) {
void BlackboardPlan::populate_blackboard(const Ref<Blackboard> &p_blackboard, bool overwrite) {
for (const KeyValue<String, BBVariable> &kv : data) {
if (p_blackboard->has_var(kv.key)) {
if (overwrite) {
@ -186,9 +195,12 @@ void BlackboardSource::populate_blackboard(const Ref<Blackboard> &p_blackboard,
}
}
BlackboardSource::BlackboardSource() {
// TODO: REMOVE ALL BELOW
data.insert("speed", BBVariable(Variant::Type::FLOAT, PropertyHint::PROPERTY_HINT_NONE, ""));
data.insert("limit_speed", BBVariable(Variant::Type::BOOL, PropertyHint::PROPERTY_HINT_NONE, ""));
BlackboardPlan::BlackboardPlan() {
// TODO: REMOVE THE TEST DATA BELOW.
data.insert("speed", BBVariable(Variant::Type::FLOAT));
data["speed"].set_value(200.0);
data.insert("limit_speed", BBVariable(Variant::Type::BOOL));
data["limit_speed"].set_value(500.0);
data.insert("about", BBVariable(Variant::Type::STRING, PropertyHint::PROPERTY_HINT_MULTILINE_TEXT, ""));
data["about"].set_value("Hello, World!");
}

View File

@ -1,5 +1,5 @@
/**
* blackboard_source.h
* blackboard_plan.h
* =============================================================================
* Copyright 2021-2024 Serhii Snitsaruk
*
@ -9,23 +9,23 @@
* =============================================================================
*/
#ifndef BLACKBOARD_SOURCE_H
#define BLACKBOARD_SOURCE_H
#ifndef BLACKBOARD_PLAN_H
#define BLACKBOARD_PLAN_H
#include "core/io/resource.h"
#include "bb_variable.h"
#include "blackboard.h"
class BlackboardSource : public Resource {
GDCLASS(BlackboardSource, Resource);
class BlackboardPlan : public Resource {
GDCLASS(BlackboardPlan, Resource);
private:
HashMap<String, BBVariable> data;
// When base is not null, the source is considered to be derived from the base source.
// A derived source can only have variables that exist in the base source.
Ref<BlackboardSource> base;
// When base is not null, the plan is considered to be derived from the base plan.
// A derived plan can only have variables that exist in the base plan.
Ref<BlackboardPlan> base;
protected:
bool _set(const StringName &p_name, const Variant &p_value);
@ -35,8 +35,8 @@ protected:
bool _property_get_revert(const StringName &p_name, Variant &r_property) const;
public:
void set_base_source(const Ref<BlackboardSource> &p_base);
Ref<BlackboardSource> get_base_source() const { return base; }
void set_base_plan(const Ref<BlackboardPlan> &p_base);
Ref<BlackboardPlan> get_base_plan() const { return base; }
void set_value(const String &p_name, const Variant &p_value);
Variant get_value(const String &p_name) const;
@ -46,13 +46,13 @@ public:
PackedStringArray list_vars() const;
bool is_empty() const { return data.is_empty(); }
void sync_with_base_source();
void sync_with_base_plan();
bool is_derived() { return base.is_valid(); }
Ref<Blackboard> create_blackboard();
void populate_blackboard(const Ref<Blackboard> &p_blackboard, bool overwrite);
BlackboardSource();
BlackboardPlan();
};
#endif // BLACKBOARD_SOURCE_H
#endif // BLACKBOARD_PLAN_H

View File

@ -22,10 +22,10 @@
#include "godot_cpp/core/error_macros.hpp"
#endif // ! LIMBOAI_GDEXTENSION
void BehaviorTree::set_blackboard_source(const Ref<BlackboardSource> &p_source) {
blackboard_source = p_source;
if (blackboard_source.is_null()) {
blackboard_source = Ref<BlackboardSource>(memnew(BlackboardSource));
void BehaviorTree::set_blackboard_plan(const Ref<BlackboardPlan> &p_plan) {
blackboard_plan = p_plan;
if (blackboard_plan.is_null()) {
blackboard_plan = Ref<BlackboardPlan>(memnew(BlackboardPlan));
}
emit_changed();
}
@ -55,8 +55,8 @@ Ref<BTTask> BehaviorTree::instantiate(Node *p_agent, const Ref<Blackboard> &p_bl
void BehaviorTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_description", "p_value"), &BehaviorTree::set_description);
ClassDB::bind_method(D_METHOD("get_description"), &BehaviorTree::get_description);
ClassDB::bind_method(D_METHOD("set_blackboard_source", "p_source"), &BehaviorTree::set_blackboard_source);
ClassDB::bind_method(D_METHOD("get_blackboard_source"), &BehaviorTree::get_blackboard_source);
ClassDB::bind_method(D_METHOD("set_blackboard_plan", "p_plan"), &BehaviorTree::set_blackboard_plan);
ClassDB::bind_method(D_METHOD("get_blackboard_plan"), &BehaviorTree::get_blackboard_plan);
ClassDB::bind_method(D_METHOD("set_root_task", "p_value"), &BehaviorTree::set_root_task);
ClassDB::bind_method(D_METHOD("get_root_task"), &BehaviorTree::get_root_task);
ClassDB::bind_method(D_METHOD("clone"), &BehaviorTree::clone);
@ -65,7 +65,7 @@ void BehaviorTree::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "description", PROPERTY_HINT_MULTILINE_TEXT), "set_description", "get_description");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "root_task", PROPERTY_HINT_RESOURCE_TYPE, "BTTask", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "set_root_task", "get_root_task");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard_source", PROPERTY_HINT_RESOURCE_TYPE, "BlackboardSource", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT), "set_blackboard_source", "get_blackboard_source");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard_plan", PROPERTY_HINT_RESOURCE_TYPE, "BlackboardPlan", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT), "set_blackboard_plan", "get_blackboard_plan");
}
BehaviorTree::BehaviorTree() {

View File

@ -12,7 +12,7 @@
#ifndef BEHAVIOR_TREE_H
#define BEHAVIOR_TREE_H
#include "../blackboard/blackboard_source.h"
#include "../blackboard/blackboard_plan.h"
#include "tasks/bt_task.h"
#ifdef LIMBOAI_MODULE
@ -29,7 +29,7 @@ class BehaviorTree : public Resource {
private:
String description;
Ref<BlackboardSource> blackboard_source;
Ref<BlackboardPlan> blackboard_plan;
Ref<BTTask> root_task;
protected:
@ -40,8 +40,8 @@ public:
virtual bool editor_can_reload_from_file() override { return false; }
#endif
void set_blackboard_source(const Ref<BlackboardSource> &p_source);
Ref<BlackboardSource> get_blackboard_source() const { return blackboard_source; }
void set_blackboard_plan(const Ref<BlackboardPlan> &p_plan);
Ref<BlackboardPlan> get_blackboard_plan() const { return blackboard_plan; }
void set_description(String p_value) {
description = p_value;

View File

@ -63,15 +63,16 @@ void BTPlayer::_load_tree() {
#endif
}
void BTPlayer::_update_blackboard_source() {
if (behavior_tree.is_valid() && behavior_tree->get_blackboard_source().is_valid()) {
if (blackboard_source.is_null()) {
blackboard_source = Ref<BlackboardSource>(memnew(BlackboardSource));
}
if (blackboard_source == behavior_tree->get_blackboard_source()) {
blackboard_source->sync_with_base_source();
void BTPlayer::_update_blackboard_plan() {
if (blackboard_plan.is_null()) {
blackboard_plan = Ref<BlackboardPlan>(memnew(BlackboardPlan));
}
if (behavior_tree.is_valid()) {
if (blackboard_plan == behavior_tree->get_blackboard_plan()) {
blackboard_plan->sync_with_base_plan();
} else {
blackboard_source->set_base_source(behavior_tree->get_blackboard_source());
blackboard_plan->set_base_plan(behavior_tree->get_blackboard_plan());
}
}
}
@ -81,12 +82,12 @@ void BTPlayer::set_behavior_tree(const Ref<BehaviorTree> &p_tree) {
if (Engine::get_singleton()->is_editor_hint() == false && get_owner()) {
_load_tree();
}
_update_blackboard_source();
_update_blackboard_plan();
}
void BTPlayer::set_blackboard_source(const Ref<BlackboardSource> &p_source) {
blackboard_source = p_source;
_update_blackboard_source();
void BTPlayer::set_blackboard_plan(const Ref<BlackboardPlan> &p_plan) {
blackboard_plan = p_plan;
_update_blackboard_plan();
}
void BTPlayer::set_update_mode(UpdateMode p_mode) {
@ -182,8 +183,8 @@ void BTPlayer::_notification(int p_notification) {
if (blackboard.is_null()) {
blackboard = Ref<Blackboard>(memnew(Blackboard));
}
if (blackboard_source.is_valid()) {
blackboard_source->populate_blackboard(blackboard, false);
if (blackboard_plan.is_valid()) {
blackboard_plan->populate_blackboard(blackboard, false);
}
if (behavior_tree.is_valid()) {
_load_tree();
@ -221,8 +222,8 @@ void BTPlayer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_prefetch_nodepath_vars", "p_value"), &BTPlayer::set_prefetch_nodepath_vars);
ClassDB::bind_method(D_METHOD("get_prefetch_nodepath_vars"), &BTPlayer::get_prefetch_nodepath_vars);
ClassDB::bind_method(D_METHOD("set_blackboard_source", "p_blackboard"), &BTPlayer::set_blackboard_source);
ClassDB::bind_method(D_METHOD("get_blackboard_source"), &BTPlayer::get_blackboard_source);
ClassDB::bind_method(D_METHOD("set_blackboard_plan", "p_plan"), &BTPlayer::set_blackboard_plan);
ClassDB::bind_method(D_METHOD("get_blackboard_plan"), &BTPlayer::get_blackboard_plan);
ClassDB::bind_method(D_METHOD("update", "p_delta"), &BTPlayer::update);
ClassDB::bind_method(D_METHOD("restart"), &BTPlayer::restart);
@ -232,7 +233,7 @@ void BTPlayer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "update_mode", PROPERTY_HINT_ENUM, "Idle,Physics,Manual"), "set_update_mode", "get_update_mode");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "active"), "set_active", "get_active");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard", PROPERTY_HINT_NONE, "Blackboard", 0), "set_blackboard", "get_blackboard");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard_source", PROPERTY_HINT_RESOURCE_TYPE, "BlackboardSource", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT), "set_blackboard_source", "get_blackboard_source");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard_plan", PROPERTY_HINT_RESOURCE_TYPE, "BlackboardPlan", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT), "set_blackboard_plan", "get_blackboard_plan");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "prefetch_nodepath_vars"), "set_prefetch_nodepath_vars", "get_prefetch_nodepath_vars");
BIND_ENUM_CONSTANT(IDLE);

View File

@ -13,7 +13,7 @@
#define BT_PLAYER_H
#include "../blackboard/blackboard.h"
#include "../blackboard/blackboard_source.h"
#include "../blackboard/blackboard_plan.h"
#include "behavior_tree.h"
#include "tasks/bt_task.h"
@ -37,7 +37,7 @@ public:
private:
Ref<BehaviorTree> behavior_tree;
Ref<BlackboardSource> blackboard_source;
Ref<BlackboardPlan> blackboard_plan;
UpdateMode update_mode = UpdateMode::PHYSICS;
bool active = true;
Ref<Blackboard> blackboard;
@ -47,7 +47,7 @@ private:
Ref<BTTask> tree_instance;
void _load_tree();
void _update_blackboard_source();
void _update_blackboard_plan();
protected:
static void _bind_methods();
@ -58,8 +58,8 @@ public:
void set_behavior_tree(const Ref<BehaviorTree> &p_tree);
Ref<BehaviorTree> get_behavior_tree() const { return behavior_tree; };
void set_blackboard_source(const Ref<BlackboardSource> &p_source);
Ref<BlackboardSource> get_blackboard_source() const { return blackboard_source; }
void set_blackboard_plan(const Ref<BlackboardPlan> &p_plan);
Ref<BlackboardPlan> get_blackboard_plan() const { return blackboard_plan; }
void set_update_mode(UpdateMode p_mode);
UpdateMode get_update_mode() const { return update_mode; }

View File

@ -26,15 +26,15 @@
#include <godot_cpp/classes/engine_debugger.hpp>
#endif // LIMBOAI_GDEXTENSION
void BTState::_update_blackboard_source() {
if (behavior_tree.is_valid() && behavior_tree->get_blackboard_source().is_valid()) {
if (get_blackboard_source().is_null()) {
set_blackboard_source(Ref<BlackboardSource>(memnew(BlackboardSource)));
void BTState::_update_blackboard_plan() {
if (behavior_tree.is_valid() && behavior_tree->get_blackboard_plan().is_valid()) {
if (get_blackboard_plan().is_null()) {
set_blackboard_plan(Ref<BlackboardPlan>(memnew(BlackboardPlan)));
}
if (get_blackboard_source() == behavior_tree->get_blackboard_source()) {
get_blackboard_source()->sync_with_base_source();
if (get_blackboard_plan() == behavior_tree->get_blackboard_plan()) {
get_blackboard_plan()->sync_with_base_plan();
} else {
get_blackboard_source()->set_base_source(behavior_tree->get_blackboard_source());
get_blackboard_plan()->set_base_plan(behavior_tree->get_blackboard_plan());
}
}
}

View File

@ -26,7 +26,7 @@ private:
String success_event;
String failure_event;
void _update_blackboard_source();
void _update_blackboard_plan();
protected:
static void _bind_methods();

View File

@ -16,8 +16,8 @@ void BTNewScope::initialize(Node *p_agent, const Ref<Blackboard> &p_blackboard)
ERR_FAIL_COND(p_blackboard == nullptr);
Ref<Blackboard> bb;
if (blackboard_source.is_valid()) {
bb = blackboard_source->create_blackboard();
if (blackboard_plan.is_valid()) {
bb = blackboard_plan->create_blackboard();
} else {
bb = Ref<Blackboard>(memnew(Blackboard));
}
@ -33,8 +33,8 @@ BT::Status BTNewScope::_tick(double p_delta) {
}
void BTNewScope::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_blackboard_source", "p_source"), &BTNewScope::set_blackboard_source);
ClassDB::bind_method(D_METHOD("get_blackboard_source"), &BTNewScope::get_blackboard_source);
ClassDB::bind_method(D_METHOD("set_blackboard_plan", "p_plan"), &BTNewScope::set_blackboard_plan);
ClassDB::bind_method(D_METHOD("get_blackboard_plan"), &BTNewScope::get_blackboard_plan);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard_source", PROPERTY_HINT_RESOURCE_TYPE, "BlackboardSource", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT), "set_blackboard_source", "get_blackboard_source");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard_plan", PROPERTY_HINT_RESOURCE_TYPE, "BlackboardPlan", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT), "set_blackboard_plan", "get_blackboard_plan");
}

View File

@ -14,20 +14,20 @@
#include "../bt_decorator.h"
#include "../../../blackboard/blackboard_source.h"
#include "../../../blackboard/blackboard_plan.h"
class BTNewScope : public BTDecorator {
GDCLASS(BTNewScope, BTDecorator);
TASK_CATEGORY(Decorators);
private:
Ref<BlackboardSource> blackboard_source;
Ref<BlackboardPlan> blackboard_plan;
protected:
static void _bind_methods();
void set_blackboard_source(const Ref<BlackboardSource> &p_source) { blackboard_source = p_source; }
Ref<BlackboardSource> get_blackboard_source() const { return blackboard_source; }
void set_blackboard_plan(const Ref<BlackboardPlan> &p_plan) { blackboard_plan = p_plan; }
Ref<BlackboardPlan> get_blackboard_plan() const { return blackboard_plan; }
virtual Status _tick(double p_delta) override;

View File

@ -69,8 +69,8 @@ void LimboState::_initialize(Node *p_agent, const Ref<Blackboard> &p_blackboard)
agent = p_agent;
if (!p_blackboard.is_null()) {
if (blackboard_source.is_valid() && !blackboard_source->is_empty()) {
blackboard = blackboard_source->create_blackboard();
if (blackboard_plan.is_valid() && !blackboard_plan->is_empty()) {
blackboard = blackboard_plan->create_blackboard();
blackboard->set_parent_scope(p_blackboard);
} else {
blackboard = p_blackboard;
@ -180,8 +180,8 @@ void LimboState::_bind_methods() {
ClassDB::bind_method(D_METHOD("clear_guard"), &LimboState::clear_guard);
ClassDB::bind_method(D_METHOD("get_blackboard"), &LimboState::get_blackboard);
ClassDB::bind_method(D_METHOD("set_blackboard_source", "p_source"), &LimboState::set_blackboard_source);
ClassDB::bind_method(D_METHOD("get_blackboard_source"), &LimboState::get_blackboard_source);
ClassDB::bind_method(D_METHOD("set_blackboard_plan", "p_plan"), &LimboState::set_blackboard_plan);
ClassDB::bind_method(D_METHOD("get_blackboard_plan"), &LimboState::get_blackboard_plan);
#ifdef LIMBOAI_MODULE
GDVIRTUAL_BIND(_setup);
@ -195,7 +195,7 @@ void LimboState::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "EVENT_FINISHED", PROPERTY_HINT_NONE, "", 0), "", "event_finished");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "agent", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_agent", "get_agent");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard", PROPERTY_HINT_RESOURCE_TYPE, "Blackboard", 0), "", "get_blackboard");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard_source", PROPERTY_HINT_RESOURCE_TYPE, "BlackboardSource", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_blackboard_source", "get_blackboard_source");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard_plan", PROPERTY_HINT_RESOURCE_TYPE, "BlackboardPlan", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_blackboard_plan", "get_blackboard_plan");
ADD_SIGNAL(MethodInfo("setup"));
ADD_SIGNAL(MethodInfo("entered"));

View File

@ -13,7 +13,7 @@
#define LIMBO_STATE_H
#include "../blackboard/blackboard.h"
#include "../blackboard/blackboard_source.h"
#include "../blackboard/blackboard_plan.h"
#include "../util/limbo_string_names.h"
@ -38,7 +38,7 @@ class LimboState : public Node {
GDCLASS(LimboState, Node);
private:
Ref<BlackboardSource> blackboard_source;
Ref<BlackboardPlan> blackboard_plan;
Node *agent;
Ref<Blackboard> blackboard;
HashMap<String, Callable> handlers;
@ -70,8 +70,8 @@ protected:
void add_event_handler(const String &p_event, const Callable &p_handler);
public:
void set_blackboard_source(const Ref<BlackboardSource> p_source) { blackboard_source = p_source; }
Ref<BlackboardSource> get_blackboard_source() const { return blackboard_source; }
void set_blackboard_plan(const Ref<BlackboardPlan> p_plan) { blackboard_plan = p_plan; }
Ref<BlackboardPlan> get_blackboard_plan() const { return blackboard_plan; }
Ref<Blackboard> get_blackboard() const { return blackboard; }

View File

@ -47,7 +47,7 @@
#include "blackboard/bb_param/bb_vector4.h"
#include "blackboard/bb_param/bb_vector4i.h"
#include "blackboard/blackboard.h"
#include "blackboard/blackboard_source.h"
#include "blackboard/blackboard_plan.h"
#include "bt/behavior_tree.h"
#include "bt/bt_player.h"
#include "bt/bt_state.h"
@ -134,7 +134,7 @@ void initialize_limboai_module(ModuleInitializationLevel p_level) {
GDREGISTER_CLASS(LimboUtility);
GDREGISTER_CLASS(Blackboard);
GDREGISTER_CLASS(BlackboardSource);
GDREGISTER_CLASS(BlackboardPlan);
GDREGISTER_CLASS(LimboState);
GDREGISTER_CLASS(LimboHSM);