Fix default object value issues

This commit is contained in:
Serhii Snitsaruk 2024-01-23 15:56:30 +01:00
parent 8c67886b52
commit dc40109ade
3 changed files with 11 additions and 11 deletions

View File

@ -22,6 +22,14 @@
#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));
}
emit_changed();
}
Ref<BehaviorTree> BehaviorTree::clone() const {
Ref<BehaviorTree> copy = duplicate(false);
copy->set_path("");
@ -57,9 +65,8 @@ 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), "set_blackboard_source", "get_blackboard_source");
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");
}
BehaviorTree::BehaviorTree() {
blackboard_source = Ref<BlackboardSource>(memnew(BlackboardSource));
}

View File

@ -40,10 +40,7 @@ public:
virtual bool editor_can_reload_from_file() override { return false; }
#endif
void set_blackboard_source(const Ref<BlackboardSource> &p_source) {
blackboard_source = p_source;
emit_changed();
}
void set_blackboard_source(const Ref<BlackboardSource> &p_source);
Ref<BlackboardSource> get_blackboard_source() const { return blackboard_source; }
void set_description(String p_value) {

View File

@ -86,9 +86,6 @@ void BTPlayer::set_behavior_tree(const Ref<BehaviorTree> &p_tree) {
void BTPlayer::set_blackboard_source(const Ref<BlackboardSource> &p_source) {
blackboard_source = p_source;
if (blackboard_source.is_null()) {
blackboard_source = Ref<BlackboardSource>(memnew(BlackboardSource));
}
_update_blackboard_source();
}
@ -232,7 +229,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), "set_blackboard_source", "get_blackboard_source");
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::BOOL, "prefetch_nodepath_vars"), "set_prefetch_nodepath_vars", "get_prefetch_nodepath_vars");
BIND_ENUM_CONSTANT(IDLE);
@ -250,7 +247,6 @@ void BTPlayer::_bind_methods() {
}
BTPlayer::BTPlayer() {
blackboard = Ref<Blackboard>(memnew(Blackboard));
}
BTPlayer::~BTPlayer() {