diff --git a/bt/bt_state.cpp b/bt/bt_state.cpp index cbcafc7..a56af70 100644 --- a/bt/bt_state.cpp +++ b/bt/bt_state.cpp @@ -1,13 +1,18 @@ /* bt_state.cpp */ #include "bt_state.h" +#include "core/class_db.h" #include "core/variant.h" #include "modules/limboai/bt/bt_task.h" +#include "modules/limboai/limbo_state.h" +// void BTState::initialize(Object *p_agent, const Ref &p_blackboard) { void BTState::_setup() { - blackboard->prefetch_nodepath_vars(this); - root_task = behavior_tree->instance(get_owner(), blackboard); - root_task->initialize(get_owner(), blackboard); + // blackboard->prefetch_nodepath_vars(this); + // blackboard->set_parent_scope(p_blackboard); + root_task = behavior_tree->instance(get_agent(), get_blackboard()); + + // LimboState::initialize(p_agent, blackboard); } void BTState::_exit() { @@ -26,9 +31,13 @@ void BTState::_update(float p_delta) { void BTState::_bind_methods() { ClassDB::bind_method(D_METHOD("set_behavior_tree", "p_value"), &BTState::set_behavior_tree); ClassDB::bind_method(D_METHOD("get_behavior_tree"), &BTState::get_behavior_tree); - // ClassDB::bind_method(D_METHOD("set_blackboard", "p_blackboard"), &BTState::set_blackboard); - ClassDB::bind_method(D_METHOD("get_blackboard"), &BTState::get_blackboard); + // ClassDB::bind_method(D_METHOD("_get_blackboard_data"), &BTState::_get_blackboard_data); + // ClassDB::bind_method(D_METHOD("_set_blackboard_data", "p_data"), &BTState::_set_blackboard_data); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "behavior_tree", PROPERTY_HINT_RESOURCE_TYPE, "BehaviorTree"), "set_behavior_tree", "get_behavior_tree"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard", PROPERTY_HINT_NONE, "Blackboard", 0), "", "get_blackboard"); + ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "blackboard_data"), "_set_blackboard_data", "_get_blackboard_data"); +} + +BTState::BTState() { + // blackboard = Ref(memnew(Blackboard)); } diff --git a/bt/bt_state.h b/bt/bt_state.h index 9ae1160..63765aa 100644 --- a/bt/bt_state.h +++ b/bt/bt_state.h @@ -13,22 +13,27 @@ class BTState : public LimboState { private: Ref behavior_tree; - Ref blackboard; + // Ref blackboard; Ref root_task; protected: static void _bind_methods(); virtual void _setup(); - // virtual void _enter() {} + virtual void _enter() {} virtual void _exit(); virtual void _update(float p_delta); + // void _set_blackboard_data(Dictionary p_value) { blackboard->set_data(p_value); } + // Dictionary _get_blackboard_data() const { return blackboard->get_data(); } + public: void set_behavior_tree(const Ref &p_value) { behavior_tree = p_value; } Ref get_behavior_tree() const { return behavior_tree; } - // void set_blackboard(const Ref &p_value) { blackboard = p_value; } - Ref get_blackboard() const { return blackboard; } + + // virtual void initialize(Object *p_agent, const Ref &p_blackboard); + + BTState(); }; #endif // BT_STATE_H \ No newline at end of file