Compare commits
4 Commits
a22185e784
...
a179388b19
Author | SHA1 | Date |
---|---|---|
|
a179388b19 | |
|
76e02a75e5 | |
|
1b9cf17339 | |
|
bbdafa9033 |
|
@ -83,7 +83,7 @@ void BTInstance::register_with_debugger() {
|
||||||
|
|
||||||
void BTInstance::unregister_with_debugger() {
|
void BTInstance::unregister_with_debugger() {
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (LimboDebugger::get_singleton()->is_active()) {
|
if (LimboDebugger::get_singleton() && LimboDebugger::get_singleton()->is_active()) {
|
||||||
LimboDebugger::get_singleton()->unregister_bt_instance(get_instance_id());
|
LimboDebugger::get_singleton()->unregister_bt_instance(get_instance_id());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -151,5 +151,6 @@ BTInstance::~BTInstance() {
|
||||||
emit_signal(LW_NAME(freed));
|
emit_signal(LW_NAME(freed));
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
_remove_custom_monitor();
|
_remove_custom_monitor();
|
||||||
|
unregister_with_debugger();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
VARIANT_ENUM_CAST(BTPlayer::UpdateMode);
|
VARIANT_ENUM_CAST(BTPlayer::UpdateMode);
|
||||||
|
|
||||||
void BTPlayer::_load_tree() {
|
void BTPlayer::_instantiate_bt() {
|
||||||
bt_instance.unref();
|
bt_instance.unref();
|
||||||
ERR_FAIL_COND_MSG(!behavior_tree.is_valid(), "BTPlayer: Initialization failed - needs a valid behavior tree.");
|
ERR_FAIL_COND_MSG(!behavior_tree.is_valid(), "BTPlayer: Initialization failed - needs a valid behavior tree.");
|
||||||
ERR_FAIL_COND_MSG(!behavior_tree->get_root_task().is_valid(), "BTPlayer: Initialization failed - behavior tree has no valid root task.");
|
ERR_FAIL_COND_MSG(!behavior_tree->get_root_task().is_valid(), "BTPlayer: Initialization failed - behavior tree has no valid root task.");
|
||||||
|
@ -70,6 +70,19 @@ void BTPlayer::_update_blackboard_plan() {
|
||||||
blackboard_plan->set_base_plan(behavior_tree.is_valid() ? behavior_tree->get_blackboard_plan() : nullptr);
|
blackboard_plan->set_base_plan(behavior_tree.is_valid() ? behavior_tree->get_blackboard_plan() : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BTPlayer::_initialize() {
|
||||||
|
if (blackboard.is_null()) {
|
||||||
|
blackboard = Ref<Blackboard>(memnew(Blackboard));
|
||||||
|
}
|
||||||
|
if (blackboard_plan.is_valid()) {
|
||||||
|
// Don't overwrite existing blackboard values as they may be initialized from code.
|
||||||
|
blackboard_plan->populate_blackboard(blackboard, false, this, _get_scene_root());
|
||||||
|
}
|
||||||
|
if (behavior_tree.is_valid()) {
|
||||||
|
_instantiate_bt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BTPlayer::set_bt_instance(const Ref<BTInstance> &p_bt_instance) {
|
void BTPlayer::set_bt_instance(const Ref<BTInstance> &p_bt_instance) {
|
||||||
ERR_FAIL_COND_MSG(p_bt_instance.is_null(), "BTPlayer: Failed to set behavior tree instance - instance is null.");
|
ERR_FAIL_COND_MSG(p_bt_instance.is_null(), "BTPlayer: Failed to set behavior tree instance - instance is null.");
|
||||||
ERR_FAIL_COND_MSG(!p_bt_instance->is_instance_valid(), "BTPlayer: Failed to set behavior tree instance - instance is not valid.");
|
ERR_FAIL_COND_MSG(!p_bt_instance->is_instance_valid(), "BTPlayer: Failed to set behavior tree instance - instance is not valid.");
|
||||||
|
@ -78,6 +91,11 @@ void BTPlayer::set_bt_instance(const Ref<BTInstance> &p_bt_instance) {
|
||||||
blackboard = p_bt_instance->get_blackboard();
|
blackboard = p_bt_instance->get_blackboard();
|
||||||
agent_node = p_bt_instance->get_agent()->get_path();
|
agent_node = p_bt_instance->get_agent()->get_path();
|
||||||
|
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
|
bt_instance->set_monitor_performance(monitor_performance);
|
||||||
|
bt_instance->register_with_debugger();
|
||||||
|
#endif // DEBUG_ENABLED
|
||||||
|
|
||||||
blackboard_plan.unref();
|
blackboard_plan.unref();
|
||||||
behavior_tree.unref();
|
behavior_tree.unref();
|
||||||
}
|
}
|
||||||
|
@ -104,7 +122,8 @@ void BTPlayer::set_behavior_tree(const Ref<BehaviorTree> &p_tree) {
|
||||||
} else {
|
} else {
|
||||||
behavior_tree = p_tree;
|
behavior_tree = p_tree;
|
||||||
if (get_owner() && is_inside_tree()) {
|
if (get_owner() && is_inside_tree()) {
|
||||||
_load_tree();
|
_update_blackboard_plan();
|
||||||
|
_initialize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,16 +198,7 @@ void BTPlayer::_notification(int p_notification) {
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_READY: {
|
case NOTIFICATION_READY: {
|
||||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||||
if (blackboard.is_null()) {
|
_initialize();
|
||||||
blackboard = Ref<Blackboard>(memnew(Blackboard));
|
|
||||||
}
|
|
||||||
if (blackboard_plan.is_valid()) {
|
|
||||||
// Don't overwrite existing blackboard values as they may be initialized from code.
|
|
||||||
blackboard_plan->populate_blackboard(blackboard, false, this, _get_scene_root());
|
|
||||||
}
|
|
||||||
if (behavior_tree.is_valid()) {
|
|
||||||
_load_tree();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
_update_blackboard_plan();
|
_update_blackboard_plan();
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,9 @@ private:
|
||||||
|
|
||||||
Ref<BTInstance> bt_instance;
|
Ref<BTInstance> bt_instance;
|
||||||
|
|
||||||
void _load_tree();
|
void _instantiate_bt();
|
||||||
void _update_blackboard_plan();
|
void _update_blackboard_plan();
|
||||||
|
void _initialize();
|
||||||
_FORCE_INLINE_ Node *_get_scene_root() const { return scene_root_hint ? scene_root_hint : get_owner(); }
|
_FORCE_INLINE_ Node *_get_scene_root() const { return scene_root_hint ? scene_root_hint : get_owner(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "editor/editor_file_system.h"
|
#include "editor/editor_file_system.h"
|
||||||
#include "editor/editor_help.h"
|
#include "editor/editor_help.h"
|
||||||
#include "editor/editor_interface.h"
|
#include "editor/editor_interface.h"
|
||||||
|
#include "editor/editor_main_screen.h"
|
||||||
#include "editor/editor_paths.h"
|
#include "editor/editor_paths.h"
|
||||||
#include "editor/editor_settings.h"
|
#include "editor/editor_settings.h"
|
||||||
#include "editor/filesystem_dock.h"
|
#include "editor/filesystem_dock.h"
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "core/io/resource.h"
|
#include "core/io/resource.h"
|
||||||
#include "core/variant/variant.h"
|
#include "core/variant/variant.h"
|
||||||
#include "editor/editor_node.h"
|
#include "editor/editor_node.h"
|
||||||
|
#include "editor/editor_main_screen.h"
|
||||||
#include "editor/plugins/script_editor_plugin.h"
|
#include "editor/plugins/script_editor_plugin.h"
|
||||||
#endif // TOOLS_ENABLED
|
#endif // TOOLS_ENABLED
|
||||||
|
|
||||||
|
@ -213,7 +214,7 @@ Variant VARIANT_DEFAULT(Variant::Type p_type) {
|
||||||
void SHOW_BUILTIN_DOC(const String &p_topic) {
|
void SHOW_BUILTIN_DOC(const String &p_topic) {
|
||||||
#ifdef LIMBOAI_MODULE
|
#ifdef LIMBOAI_MODULE
|
||||||
ScriptEditor::get_singleton()->goto_help(p_topic);
|
ScriptEditor::get_singleton()->goto_help(p_topic);
|
||||||
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
|
EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
|
||||||
#elif LIMBOAI_GDEXTENSION
|
#elif LIMBOAI_GDEXTENSION
|
||||||
TypedArray<ScriptEditorBase> open_editors = EditorInterface::get_singleton()->get_script_editor()->get_open_script_editors();
|
TypedArray<ScriptEditorBase> open_editors = EditorInterface::get_singleton()->get_script_editor()->get_open_script_editors();
|
||||||
ERR_FAIL_COND_MSG(open_editors.size() == 0, "Can't open help page. Need at least one script open in the script editor.");
|
ERR_FAIL_COND_MSG(open_editors.size() == 0, "Can't open help page. Need at least one script open in the script editor.");
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#define EDITOR_FILE_SYSTEM() (EditorFileSystem::get_singleton())
|
#define EDITOR_FILE_SYSTEM() (EditorFileSystem::get_singleton())
|
||||||
#define EDITOR_SETTINGS() (EditorSettings::get_singleton())
|
#define EDITOR_SETTINGS() (EditorSettings::get_singleton())
|
||||||
#define BASE_CONTROL() (EditorNode::get_singleton()->get_gui_base())
|
#define BASE_CONTROL() (EditorNode::get_singleton()->get_gui_base())
|
||||||
#define MAIN_SCREEN_CONTROL() (EditorNode::get_singleton()->get_main_screen_control())
|
#define MAIN_SCREEN_CONTROL() (EditorNode::get_singleton()->get_editor_main_screen()->get_control())
|
||||||
#define SCENE_TREE() (SceneTree::get_singleton())
|
#define SCENE_TREE() (SceneTree::get_singleton())
|
||||||
#define IS_DEBUGGER_ACTIVE() (EngineDebugger::is_active())
|
#define IS_DEBUGGER_ACTIVE() (EngineDebugger::is_active())
|
||||||
#define FS_DOCK_SELECT_FILE(m_path) FileSystemDock::get_singleton()->select_file(m_path)
|
#define FS_DOCK_SELECT_FILE(m_path) FileSystemDock::get_singleton()->select_file(m_path)
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
#define GET_PROJECT_SETTINGS_DIR() EditorPaths::get_singleton()->get_project_settings_dir()
|
#define GET_PROJECT_SETTINGS_DIR() EditorPaths::get_singleton()->get_project_settings_dir()
|
||||||
#define EDIT_RESOURCE(m_res) EditorNode::get_singleton()->edit_resource(m_res)
|
#define EDIT_RESOURCE(m_res) EditorNode::get_singleton()->edit_resource(m_res)
|
||||||
#define INSPECTOR_GET_EDITED_OBJECT() (InspectorDock::get_inspector_singleton()->get_edited_object())
|
#define INSPECTOR_GET_EDITED_OBJECT() (InspectorDock::get_inspector_singleton()->get_edited_object())
|
||||||
#define SET_MAIN_SCREEN_EDITOR(m_name) (EditorNode::get_singleton()->select_editor_by_name(m_name))
|
#define SET_MAIN_SCREEN_EDITOR(m_name) (EditorNode::get_singleton()->get_editor_main_screen()->select_by_name(m_name))
|
||||||
#define FILE_EXISTS(m_path) FileAccess::exists(m_path)
|
#define FILE_EXISTS(m_path) FileAccess::exists(m_path)
|
||||||
#define DIR_ACCESS_CREATE() DirAccess::create(DirAccess::ACCESS_RESOURCES)
|
#define DIR_ACCESS_CREATE() DirAccess::create(DirAccess::ACCESS_RESOURCES)
|
||||||
#define PERFORMANCE_ADD_CUSTOM_MONITOR(m_id, m_callable) (Performance::get_singleton()->add_custom_monitor(m_id, m_callable, Variant()))
|
#define PERFORMANCE_ADD_CUSTOM_MONITOR(m_id, m_callable) (Performance::get_singleton()->add_custom_monitor(m_id, m_callable, Variant()))
|
||||||
|
@ -85,7 +85,7 @@ using namespace godot;
|
||||||
#define EDITOR_FILE_SYSTEM() (EditorInterface::get_singleton()->get_resource_filesystem())
|
#define EDITOR_FILE_SYSTEM() (EditorInterface::get_singleton()->get_resource_filesystem())
|
||||||
#define EDITOR_SETTINGS() (EditorInterface::get_singleton()->get_editor_settings())
|
#define EDITOR_SETTINGS() (EditorInterface::get_singleton()->get_editor_settings())
|
||||||
#define BASE_CONTROL() (EditorInterface::get_singleton()->get_base_control())
|
#define BASE_CONTROL() (EditorInterface::get_singleton()->get_base_control())
|
||||||
#define MAIN_SCREEN_CONTROL() (EditorInterface::get_singleton()->get_editor_main_screen())
|
#define MAIN_SCREEN_CONTROL() (EditorInterface::get_singleton()->get_editor_main_screen()->get_control())
|
||||||
#define SCENE_TREE() ((SceneTree *)(Engine::get_singleton()->get_main_loop()))
|
#define SCENE_TREE() ((SceneTree *)(Engine::get_singleton()->get_main_loop()))
|
||||||
#define IS_DEBUGGER_ACTIVE() (EngineDebugger::get_singleton()->is_active())
|
#define IS_DEBUGGER_ACTIVE() (EngineDebugger::get_singleton()->is_active())
|
||||||
#define FS_DOCK_SELECT_FILE(m_path) EditorInterface::get_singleton()->get_file_system_dock()->navigate_to_path(m_path)
|
#define FS_DOCK_SELECT_FILE(m_path) EditorInterface::get_singleton()->get_file_system_dock()->navigate_to_path(m_path)
|
||||||
|
|
|
@ -416,6 +416,12 @@ String LimboUtility::get_property_hint_text(PropertyHint p_hint) const {
|
||||||
case PROPERTY_HINT_MAX: {
|
case PROPERTY_HINT_MAX: {
|
||||||
return "MAX";
|
return "MAX";
|
||||||
}
|
}
|
||||||
|
case PROPERTY_HINT_DICTIONARY_TYPE: {
|
||||||
|
return "DICTIONARY_TYPE";
|
||||||
|
}
|
||||||
|
case PROPERTY_HINT_TOOL_BUTTON: {
|
||||||
|
return "TOOL_BUTTON";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue