Compare commits
6 Commits
97d0ca3837
...
8b2b47c1ce
Author | SHA1 | Date |
---|---|---|
Wilson E. Alvarez | 8b2b47c1ce | |
Serhii Snitsaruk | 106608aca9 | |
Serhii Snitsaruk | d5bc62830a | |
Wilson E. Alvarez | b5fe6bb77f | |
Wilson E. Alvarez | cae111ffa4 | |
Wilson E. Alvarez | fb26b79482 |
|
@ -182,60 +182,47 @@ Ref<BTTask> BTTask::clone() const {
|
|||
|
||||
// * Children are duplicated via children property. See _set_children().
|
||||
|
||||
// * Make BBParam properties unique.
|
||||
HashMap<Ref<Resource>, Ref<Resource>> duplicates;
|
||||
#ifdef LIMBOAI_MODULE
|
||||
// Make BBParam properties unique.
|
||||
List<PropertyInfo> props;
|
||||
inst->get_property_list(&props);
|
||||
HashMap<Ref<Resource>, Ref<Resource>> duplicates;
|
||||
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
|
||||
if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Variant v = inst->get(E->get().name);
|
||||
|
||||
if (v.is_ref_counted()) {
|
||||
Ref<RefCounted> ref = v;
|
||||
if (ref.is_valid()) {
|
||||
Ref<Resource> res = ref;
|
||||
if (res.is_valid() && res->is_class("BBParam")) {
|
||||
if (!duplicates.has(res)) {
|
||||
duplicates[res] = res->duplicate();
|
||||
}
|
||||
res = duplicates[res];
|
||||
inst->set(E->get().name, res);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
PropertyInfo prop = E->get();
|
||||
#elif LIMBOAI_GDEXTENSION
|
||||
// Make BBParam properties unique.
|
||||
TypedArray<Dictionary> props = inst->get_property_list();
|
||||
HashMap<Ref<Resource>, Ref<Resource>> duplicates;
|
||||
for (int i = 0; i < props.size(); i++) {
|
||||
Dictionary prop = props[i];
|
||||
if (!(int(prop["usage"]) & PROPERTY_USAGE_STORAGE)) {
|
||||
PropertyInfo prop = PropertyInfo::from_dict(props[i]);
|
||||
#endif
|
||||
if (!(prop.usage & PROPERTY_USAGE_STORAGE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
StringName prop_name = prop["name"];
|
||||
Variant v = inst->get(prop_name);
|
||||
|
||||
if (v.get_type() == Variant::OBJECT && int(prop["hint"]) == PROPERTY_HINT_RESOURCE_TYPE) {
|
||||
Ref<RefCounted> ref = v;
|
||||
if (ref.is_valid()) {
|
||||
Ref<Resource> res = ref;
|
||||
Variant prop_value = inst->get(prop.name);
|
||||
Ref<Resource> res = prop_value;
|
||||
if (res.is_valid() && res->is_class("BBParam")) {
|
||||
// Duplicate BBParam
|
||||
if (!duplicates.has(res)) {
|
||||
duplicates[res] = res->duplicate();
|
||||
}
|
||||
res = duplicates[res];
|
||||
inst->set(prop_name, res);
|
||||
inst->set(prop.name, res);
|
||||
} else if (prop_value.get_type() == Variant::ARRAY) {
|
||||
// Duplicate BBParams instances inside an array.
|
||||
// - This code doesn't handle arrays of arrays.
|
||||
// - A partial workaround for: https://github.com/godotengine/godot/issues/74918
|
||||
// - We actually don't want to duplicate resources in clone() except for BBParam subtypes.
|
||||
Array arr = prop_value;
|
||||
if (arr.is_typed() && ClassDB::is_parent_class(arr.get_typed_class_name(), LW_NAME(BBParam))) {
|
||||
for (int j = 0; j < arr.size(); j++) {
|
||||
Ref<Resource> bb_param = arr[j];
|
||||
if (bb_param.is_valid()) {
|
||||
arr[j] = bb_param->duplicate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // LIMBOAI_MODULE & LIMBOAI_GDEXTENSION
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "core/object/class_db.h"
|
||||
#include "core/object/object.h"
|
||||
#include "core/templates/hash_set.h"
|
||||
#include "editor/editor_main_screen.h"
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_undo_redo_manager.h"
|
||||
#include "editor/gui/editor_spin_slider.h"
|
||||
|
@ -42,6 +43,7 @@
|
|||
#include "scene/gui/popup.h"
|
||||
#include "scene/gui/popup_menu.h"
|
||||
#include "scene/gui/split_container.h"
|
||||
#include "scene/gui/tab_bar.h"
|
||||
#include "scene/gui/tree.h"
|
||||
#include "scene/resources/texture.h"
|
||||
#endif // LIMBOAI_MODULE
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#ifdef TOOLS_ENABLED
|
||||
#include "core/io/resource.h"
|
||||
#include "core/variant/variant.h"
|
||||
#include "editor/editor_main_screen.h"
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/plugins/script_editor_plugin.h"
|
||||
#endif // TOOLS_ENABLED
|
||||
|
@ -213,7 +214,7 @@ Variant VARIANT_DEFAULT(Variant::Type p_type) {
|
|||
void SHOW_BUILTIN_DOC(const String &p_topic) {
|
||||
#ifdef LIMBOAI_MODULE
|
||||
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
|
||||
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.");
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#define EDITOR_FILE_SYSTEM() (EditorFileSystem::get_singleton())
|
||||
#define EDITOR_SETTINGS() (EditorSettings::get_singleton())
|
||||
#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())
|
||||
#define SCENE_TREE() (SceneTree::get_singleton())
|
||||
#define IS_DEBUGGER_ACTIVE() (EngineDebugger::is_active())
|
||||
#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 EDIT_RESOURCE(m_res) EditorNode::get_singleton()->edit_resource(m_res)
|
||||
#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 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()))
|
||||
|
|
|
@ -40,6 +40,7 @@ LimboStringNames::LimboStringNames() {
|
|||
add_child = SN("add_child");
|
||||
add_child_at_index = SN("add_child_at_index");
|
||||
AnimationFilter = SN("AnimationFilter");
|
||||
BBParam = SN("BBParam");
|
||||
behavior_tree_finished = SN("behavior_tree_finished");
|
||||
bold = SN("bold");
|
||||
button_down = SN("button_down");
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
StringName add_child;
|
||||
StringName Add;
|
||||
StringName AnimationFilter;
|
||||
StringName BBParam;
|
||||
StringName behavior_tree_finished;
|
||||
StringName bold;
|
||||
StringName button_down;
|
||||
|
|
|
@ -395,6 +395,12 @@ String LimboUtility::get_property_hint_text(PropertyHint p_hint) const {
|
|||
case PROPERTY_HINT_ARRAY_TYPE: {
|
||||
return "ARRAY_TYPE";
|
||||
}
|
||||
case PROPERTY_HINT_DICTIONARY_TYPE: {
|
||||
return "DICTIONARY_TYPE";
|
||||
}
|
||||
case PROPERTY_HINT_TOOL_BUTTON: {
|
||||
return "TOOL_BUTTON";
|
||||
}
|
||||
case PROPERTY_HINT_LOCALE_ID: {
|
||||
return "LOCALE_ID";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue