From cc6ed911be34271e964083c7fff94eae76d0ad6c Mon Sep 17 00:00:00 2001 From: praydog Date: Wed, 13 Nov 2024 13:16:55 -0800 Subject: [PATCH] DD2: Tentative fix for BHVT action list --- shared/sdk/MotionFsm2Layer.cpp | 11 ++++++++++- shared/sdk/MotionFsm2Layer.hpp | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/shared/sdk/MotionFsm2Layer.cpp b/shared/sdk/MotionFsm2Layer.cpp index fa165492b..857065264 100644 --- a/shared/sdk/MotionFsm2Layer.cpp +++ b/shared/sdk/MotionFsm2Layer.cpp @@ -325,7 +325,7 @@ void BehaviorTree::set_current_node(sdk::behaviortree::TreeNode* node, uint32_t method->call(sdk::get_thread_context(), this, node->get_id(), tree_idx, set_node_info); } -bool is_delayed() { +bool TreeObject::is_delayed() const { #if TDB_VER >= 69 static auto bhvt_manager = sdk::get_native_singleton("via.behaviortree.BehaviorTreeManager"); static auto bhvt_manager_t = sdk::find_type_definition("via.behaviortree.BehaviorTreeManager"); @@ -333,6 +333,15 @@ bool is_delayed() { static auto is_delay_setup_objects_prop = utility::re_type::get_field_desc(bhvt_manager_retype, "DelaySetupObjects"); const auto is_delay_setup_objects = utility::re_managed_object::get_field((::REManagedObject*)bhvt_manager, is_delay_setup_objects_prop); + + if (!is_delay_setup_objects) { + // For some reason this can happen + if (this->actions.count == 0 && this->conditions.count == 0 && this->transitions.count == 0) { + if (this->delayed_actions.count > 0 || this->delayed_conditions.count > 0 || this->delayed_transitions.count > 0) { + return true; + } + } + } #else const auto is_delay_setup_objects = false; #endif diff --git a/shared/sdk/MotionFsm2Layer.hpp b/shared/sdk/MotionFsm2Layer.hpp index a07dba774..b22d97489 100644 --- a/shared/sdk/MotionFsm2Layer.hpp +++ b/shared/sdk/MotionFsm2Layer.hpp @@ -235,6 +235,7 @@ class TreeObjectData : public regenny::via::behaviortree::TreeObjectData { class TreeObject : public regenny::via::behaviortree::TreeObject { public: + bool is_delayed() const; void relocate(uintptr_t old_start, uintptr_t old_end, sdk::NativeArrayNoCapacity& new_nodes); void relocate_datas(uintptr_t old_start, uintptr_t old_end, sdk::NativeArrayNoCapacity& new_nodes);