diff --git a/bt/actions/bt_console_print.cpp b/bt/actions/bt_console_print.cpp index 8d5c089..d7d0943 100644 --- a/bt/actions/bt_console_print.cpp +++ b/bt/actions/bt_console_print.cpp @@ -17,7 +17,7 @@ String BTConsolePrint::_generate_name() const { return vformat("ConsolePrint \"%s\"", tx); } -int BTConsolePrint::_tick(float p_delta) { +int BTConsolePrint::_tick(double p_delta) { switch (bb_format_parameters.size()) { case 0: { print_line(text); diff --git a/bt/actions/bt_console_print.h b/bt/actions/bt_console_print.h index c9b1c27..e1f22a3 100644 --- a/bt/actions/bt_console_print.h +++ b/bt/actions/bt_console_print.h @@ -18,7 +18,7 @@ protected: static void _bind_methods(); virtual String _generate_name() const override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; public: void set_text(String p_value) { diff --git a/bt/actions/bt_fail.cpp b/bt/actions/bt_fail.cpp index 82e5b13..f86034a 100644 --- a/bt/actions/bt_fail.cpp +++ b/bt/actions/bt_fail.cpp @@ -2,6 +2,6 @@ #include "bt_fail.h" -int BTFail::_tick(float p_delta) { +int BTFail::_tick(double p_delta) { return FAILURE; } diff --git a/bt/actions/bt_fail.h b/bt/actions/bt_fail.h index 20f27fc..3f51db9 100644 --- a/bt/actions/bt_fail.h +++ b/bt/actions/bt_fail.h @@ -10,7 +10,7 @@ class BTFail : public BTAction { GDCLASS(BTFail, BTAction); protected: - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; }; #endif // BT_FAIL_H \ No newline at end of file diff --git a/bt/actions/bt_random_wait.cpp b/bt/actions/bt_random_wait.cpp index 51b8619..f0c4a93 100644 --- a/bt/actions/bt_random_wait.cpp +++ b/bt/actions/bt_random_wait.cpp @@ -5,16 +5,16 @@ String BTRandomWait::_generate_name() const { return vformat("Wait %s to %s sec", - Math::snapped(duration_min_max.x, 0.001), - Math::snapped(duration_min_max.y, 0.001)); + Math::snapped(min_duration, 0.001), + Math::snapped(max_duration, 0.001)); } void BTRandomWait::_enter() { time_passed = 0.0; - duration = Math::random(duration_min_max.x, duration_min_max.y); + duration = Math::random(min_duration, max_duration); } -int BTRandomWait::_tick(float p_delta) { +int BTRandomWait::_tick(double p_delta) { time_passed += p_delta; if (time_passed < duration) { return RUNNING; @@ -23,9 +23,28 @@ int BTRandomWait::_tick(float p_delta) { } } -void BTRandomWait::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_duration_min_max", "p_value"), &BTRandomWait::set_duration_min_max); - ClassDB::bind_method(D_METHOD("get_duration_min_max"), &BTRandomWait::get_duration_min_max); - - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "duration_min_max"), "set_duration_min_max", "get_duration_min_max"); +void BTRandomWait::set_min_duration(double p_max_duration) { + min_duration = p_max_duration; + if (max_duration < min_duration) { + set_max_duration(min_duration); + } + emit_changed(); +} + +void BTRandomWait::set_max_duration(double p_max_duration) { + max_duration = p_max_duration; + if (min_duration > max_duration) { + set_min_duration(max_duration); + } + emit_changed(); +} + +void BTRandomWait::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_min_duration"), &BTRandomWait::set_min_duration); + ClassDB::bind_method(D_METHOD("get_min_duration"), &BTRandomWait::get_min_duration); + ClassDB::bind_method(D_METHOD("set_max_duration"), &BTRandomWait::set_max_duration); + ClassDB::bind_method(D_METHOD("get_max_duration"), &BTRandomWait::get_max_duration); + + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "min_duration"), "set_min_duration", "get_min_duration"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "max_duration"), "set_max_duration", "get_max_duration"); } diff --git a/bt/actions/bt_random_wait.h b/bt/actions/bt_random_wait.h index bddf1ab..4b15109 100644 --- a/bt/actions/bt_random_wait.h +++ b/bt/actions/bt_random_wait.h @@ -10,24 +10,25 @@ class BTRandomWait : public BTAction { GDCLASS(BTRandomWait, BTAction); private: - Vector2 duration_min_max = Vector2(1.0, 2.0); + double min_duration = 1.0; + double max_duration = 2.0; - float time_passed = 0.0; - float duration = 0.0; + double time_passed = 0.0; + double duration = 0.0; protected: static void _bind_methods(); virtual String _generate_name() const override; virtual void _enter() override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; public: - void set_duration_min_max(Vector2 p_value) { - duration_min_max = p_value; - emit_changed(); - } - Vector2 get_duration_min_max() const { return duration_min_max; } + void set_min_duration(double p_max_duration); + double get_min_duration() const { return min_duration; } + + void set_max_duration(double p_max_duration); + double get_max_duration() const { return max_duration; } }; #endif // BT_RANDOM_WAIT_H \ No newline at end of file diff --git a/bt/actions/bt_wait.cpp b/bt/actions/bt_wait.cpp index ac07056..8a67d9a 100644 --- a/bt/actions/bt_wait.cpp +++ b/bt/actions/bt_wait.cpp @@ -14,7 +14,7 @@ void BTWait::_enter() { time_passed = 0.0; } -int BTWait::_tick(float p_delta) { +int BTWait::_tick(double p_delta) { time_passed += p_delta; if (time_passed < duration) { return RUNNING; diff --git a/bt/actions/bt_wait.h b/bt/actions/bt_wait.h index fbf76fb..5c544cf 100644 --- a/bt/actions/bt_wait.h +++ b/bt/actions/bt_wait.h @@ -10,23 +10,23 @@ class BTWait : public BTAction { GDCLASS(BTWait, BTAction); private: - float duration = 1.0; + double duration = 1.0; - float time_passed = 0.0; + double time_passed = 0.0; protected: static void _bind_methods(); virtual String _generate_name() const override; virtual void _enter() override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; public: - void set_duration(float p_value) { + void set_duration(double p_value) { duration = p_value; emit_changed(); } - float get_duration() const { return duration; } + double get_duration() const { return duration; } }; #endif // BT_WAIT_H \ No newline at end of file diff --git a/bt/actions/bt_wait_ticks.cpp b/bt/actions/bt_wait_ticks.cpp index 6c3d32d..02ae53b 100644 --- a/bt/actions/bt_wait_ticks.cpp +++ b/bt/actions/bt_wait_ticks.cpp @@ -13,7 +13,7 @@ void BTWaitTicks::_enter() { num_passed = 0; } -int BTWaitTicks::_tick(float p_delta) { +int BTWaitTicks::_tick(double p_delta) { num_passed += 1; if (num_passed < num_ticks) { return RUNNING; diff --git a/bt/actions/bt_wait_ticks.h b/bt/actions/bt_wait_ticks.h index 3ddb89b..0b47fb0 100644 --- a/bt/actions/bt_wait_ticks.h +++ b/bt/actions/bt_wait_ticks.h @@ -19,7 +19,7 @@ protected: virtual String _generate_name() const override; virtual void _enter() override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; public: void set_num_ticks(int p_value) { diff --git a/bt/bt_player.cpp b/bt/bt_player.cpp index 38472e0..4ecff8a 100644 --- a/bt/bt_player.cpp +++ b/bt/bt_player.cpp @@ -45,7 +45,7 @@ void BTPlayer::set_active(bool p_active) { set_process_input(active && is_not_editor); } -void BTPlayer::update(float p_delta) { +void BTPlayer::update(double p_delta) { if (!tree_instance.is_valid()) { ERR_PRINT_ONCE(vformat("BTPlayer doesn't have a behavior tree with a valid root task to execute (owner: %s)", get_owner())); return; diff --git a/bt/bt_player.h b/bt/bt_player.h index b89087b..e8acb99 100644 --- a/bt/bt_player.h +++ b/bt/bt_player.h @@ -55,7 +55,7 @@ public: void set_prefetch_nodepath_vars(bool p_value) { prefetch_nodepath_vars = p_value; } bool get_prefetch_nodepath_vars() const { return prefetch_nodepath_vars; } - void update(float p_delta); + void update(double p_delta); void restart(); int get_last_status() const { return last_status; } diff --git a/bt/bt_state.cpp b/bt/bt_state.cpp index 3f79cf3..67e1e6b 100644 --- a/bt/bt_state.cpp +++ b/bt/bt_state.cpp @@ -17,7 +17,7 @@ void BTState::_exit() { tree_instance->cancel(); } -void BTState::_update(float p_delta) { +void BTState::_update(double p_delta) { ERR_FAIL_COND(tree_instance == nullptr); int status = tree_instance->execute(p_delta); if (status == BTTask::SUCCESS) { diff --git a/bt/bt_state.h b/bt/bt_state.h index 5f97311..5082e6f 100644 --- a/bt/bt_state.h +++ b/bt/bt_state.h @@ -23,7 +23,7 @@ protected: virtual void _setup() override; // virtual void _enter() override {} virtual void _exit() override; - virtual void _update(float p_delta) override; + virtual void _update(double p_delta) override; public: void set_behavior_tree(const Ref &p_value) { behavior_tree = p_value; } diff --git a/bt/bt_task.cpp b/bt/bt_task.cpp index 04f752d..0bc11f5 100644 --- a/bt/bt_task.cpp +++ b/bt/bt_task.cpp @@ -130,7 +130,7 @@ Ref BTTask::clone() const { return inst; } -int BTTask::execute(float p_delta) { +int BTTask::execute(double p_delta) { if (status != RUNNING) { if (!GDVIRTUAL_CALL(_enter)) { _enter(); diff --git a/bt/bt_task.h b/bt/bt_task.h index a4a9dc9..793880a 100644 --- a/bt/bt_task.h +++ b/bt/bt_task.h @@ -44,13 +44,13 @@ protected: virtual void _setup() {} virtual void _enter() {} virtual void _exit() {} - virtual int _tick(float p_delta) { return FAILURE; } + virtual int _tick(double p_delta) { return FAILURE; } GDVIRTUAL0RC(String, _generate_name); GDVIRTUAL0(_setup); GDVIRTUAL0(_enter); GDVIRTUAL0(_exit); - GDVIRTUAL1R(int, _tick, float); + GDVIRTUAL1R(int, _tick, double); GDVIRTUAL0RC(String, _get_configuration_warning); public: @@ -72,7 +72,7 @@ public: virtual void initialize(Node *p_agent, const Ref &p_blackboard); virtual String get_configuration_warning() const; - int execute(float p_delta); + int execute(double p_delta); void cancel(); int get_status() const { return status; } diff --git a/bt/composites/bt_dynamic_selector.cpp b/bt/composites/bt_dynamic_selector.cpp index 2e486e5..526f586 100644 --- a/bt/composites/bt_dynamic_selector.cpp +++ b/bt/composites/bt_dynamic_selector.cpp @@ -6,7 +6,7 @@ void BTDynamicSelector::_enter() { last_running_idx = 0; } -int BTDynamicSelector::_tick(float p_delta) { +int BTDynamicSelector::_tick(double p_delta) { int status = SUCCESS; int i; for (i = 0; i < get_child_count(); i++) { diff --git a/bt/composites/bt_dynamic_selector.h b/bt/composites/bt_dynamic_selector.h index 059e755..ac3a332 100644 --- a/bt/composites/bt_dynamic_selector.h +++ b/bt/composites/bt_dynamic_selector.h @@ -14,7 +14,7 @@ private: protected: virtual void _enter() override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; }; #endif // BT_DYNAMIC_SELECTOR_H \ No newline at end of file diff --git a/bt/composites/bt_dynamic_sequence.cpp b/bt/composites/bt_dynamic_sequence.cpp index e8c6833..8e73959 100644 --- a/bt/composites/bt_dynamic_sequence.cpp +++ b/bt/composites/bt_dynamic_sequence.cpp @@ -6,7 +6,7 @@ void BTDynamicSequence::_enter() { last_running_idx = 0; } -int BTDynamicSequence::_tick(float p_delta) { +int BTDynamicSequence::_tick(double p_delta) { int status = SUCCESS; int i; for (i = 0; i < get_child_count(); i++) { diff --git a/bt/composites/bt_dynamic_sequence.h b/bt/composites/bt_dynamic_sequence.h index 66999f7..a02772a 100644 --- a/bt/composites/bt_dynamic_sequence.h +++ b/bt/composites/bt_dynamic_sequence.h @@ -14,7 +14,7 @@ private: protected: virtual void _enter() override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; }; #endif // BT_DYNAMIC_SEQUENCE_H \ No newline at end of file diff --git a/bt/composites/bt_parallel.cpp b/bt/composites/bt_parallel.cpp index 19bb4b5..970e4c6 100644 --- a/bt/composites/bt_parallel.cpp +++ b/bt/composites/bt_parallel.cpp @@ -9,7 +9,7 @@ void BTParallel::_enter() { } } -int BTParallel::_tick(float p_delta) { +int BTParallel::_tick(double p_delta) { int num_succeeded = 0; int num_failed = 0; int return_status = RUNNING; diff --git a/bt/composites/bt_parallel.h b/bt/composites/bt_parallel.h index 5da2733..c83d8e0 100644 --- a/bt/composites/bt_parallel.h +++ b/bt/composites/bt_parallel.h @@ -18,7 +18,7 @@ protected: static void _bind_methods(); virtual void _enter() override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; public: int get_num_successes_required() const { return num_successes_required; } diff --git a/bt/composites/bt_random_selector.cpp b/bt/composites/bt_random_selector.cpp index db61e87..aabfcce 100644 --- a/bt/composites/bt_random_selector.cpp +++ b/bt/composites/bt_random_selector.cpp @@ -13,7 +13,7 @@ void BTRandomSelector::_enter() { indicies.shuffle(); } -int BTRandomSelector::_tick(float p_delta) { +int BTRandomSelector::_tick(double p_delta) { int status = FAILURE; for (int i = last_running_idx; i < get_child_count(); i++) { status = get_child(indicies[i])->execute(p_delta); diff --git a/bt/composites/bt_random_selector.h b/bt/composites/bt_random_selector.h index 75140c5..c27c733 100644 --- a/bt/composites/bt_random_selector.h +++ b/bt/composites/bt_random_selector.h @@ -15,6 +15,6 @@ private: protected: virtual void _enter() override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; }; #endif // BT_RANDOM_SELECTOR_H \ No newline at end of file diff --git a/bt/composites/bt_random_sequence.cpp b/bt/composites/bt_random_sequence.cpp index f041ce6..34e825d 100644 --- a/bt/composites/bt_random_sequence.cpp +++ b/bt/composites/bt_random_sequence.cpp @@ -13,7 +13,7 @@ void BTRandomSequence::_enter() { indicies.shuffle(); } -int BTRandomSequence::_tick(float p_delta) { +int BTRandomSequence::_tick(double p_delta) { int status = SUCCESS; for (int i = last_running_idx; i < get_child_count(); i++) { status = get_child(indicies[i])->execute(p_delta); diff --git a/bt/composites/bt_random_sequence.h b/bt/composites/bt_random_sequence.h index 9c65ae8..d32cf10 100644 --- a/bt/composites/bt_random_sequence.h +++ b/bt/composites/bt_random_sequence.h @@ -15,6 +15,6 @@ private: protected: virtual void _enter() override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; }; #endif // BT_RANDOM_SEQUENCE_H \ No newline at end of file diff --git a/bt/composites/bt_selector.cpp b/bt/composites/bt_selector.cpp index 9f01540..7a06092 100644 --- a/bt/composites/bt_selector.cpp +++ b/bt/composites/bt_selector.cpp @@ -6,7 +6,7 @@ void BTSelector::_enter() { last_running_idx = 0; } -int BTSelector::_tick(float p_delta) { +int BTSelector::_tick(double p_delta) { int status = FAILURE; for (int i = last_running_idx; i < get_child_count(); i++) { status = get_child(i)->execute(p_delta); diff --git a/bt/composites/bt_selector.h b/bt/composites/bt_selector.h index bc43994..2f9b703 100644 --- a/bt/composites/bt_selector.h +++ b/bt/composites/bt_selector.h @@ -13,6 +13,6 @@ private: protected: virtual void _enter() override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; }; #endif // BT_SELECTOR_H \ No newline at end of file diff --git a/bt/composites/bt_sequence.cpp b/bt/composites/bt_sequence.cpp index 3b4b5e7..178cf6d 100644 --- a/bt/composites/bt_sequence.cpp +++ b/bt/composites/bt_sequence.cpp @@ -6,7 +6,7 @@ void BTSequence::_enter() { last_running_idx = 0; } -int BTSequence::_tick(float p_delta) { +int BTSequence::_tick(double p_delta) { int status = SUCCESS; for (int i = last_running_idx; i < get_child_count(); i++) { status = get_child(i)->execute(p_delta); diff --git a/bt/composites/bt_sequence.h b/bt/composites/bt_sequence.h index dd61497..1883e54 100644 --- a/bt/composites/bt_sequence.h +++ b/bt/composites/bt_sequence.h @@ -14,7 +14,7 @@ private: protected: virtual void _enter() override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; }; #endif // BT_SEQUENCE_H \ No newline at end of file diff --git a/bt/decorators/bt_always_fail.cpp b/bt/decorators/bt_always_fail.cpp index cfa42a4..fdb040e 100644 --- a/bt/decorators/bt_always_fail.cpp +++ b/bt/decorators/bt_always_fail.cpp @@ -2,7 +2,7 @@ #include "bt_always_fail.h" -int BTAlwaysFail::_tick(float p_delta) { +int BTAlwaysFail::_tick(double p_delta) { if (get_child_count() > 0 && get_child(0)->execute(p_delta) == RUNNING) { return RUNNING; } diff --git a/bt/decorators/bt_always_fail.h b/bt/decorators/bt_always_fail.h index 9021313..58ed1ec 100644 --- a/bt/decorators/bt_always_fail.h +++ b/bt/decorators/bt_always_fail.h @@ -10,7 +10,7 @@ class BTAlwaysFail : public BTDecorator { GDCLASS(BTAlwaysFail, BTDecorator); protected: - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; }; #endif // BT_ALWAYS_FAIL_H \ No newline at end of file diff --git a/bt/decorators/bt_always_succeed.cpp b/bt/decorators/bt_always_succeed.cpp index a868a0b..21659fb 100644 --- a/bt/decorators/bt_always_succeed.cpp +++ b/bt/decorators/bt_always_succeed.cpp @@ -2,7 +2,7 @@ #include "bt_always_succeed.h" -int BTAlwaysSucceed::_tick(float p_delta) { +int BTAlwaysSucceed::_tick(double p_delta) { if (get_child_count() > 0 && get_child(0)->execute(p_delta) == RUNNING) { return RUNNING; } diff --git a/bt/decorators/bt_always_succeed.h b/bt/decorators/bt_always_succeed.h index 936349c..77e8f6b 100644 --- a/bt/decorators/bt_always_succeed.h +++ b/bt/decorators/bt_always_succeed.h @@ -10,7 +10,7 @@ class BTAlwaysSucceed : public BTDecorator { GDCLASS(BTAlwaysSucceed, BTDecorator); protected: - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; }; #endif // BT_ALWAYS_SUCCEED_H \ No newline at end of file diff --git a/bt/decorators/bt_cooldown.cpp b/bt/decorators/bt_cooldown.cpp index 1d76bcc..d5e475d 100644 --- a/bt/decorators/bt_cooldown.cpp +++ b/bt/decorators/bt_cooldown.cpp @@ -20,7 +20,7 @@ void BTCooldown::_setup() { } } -int BTCooldown::_tick(float p_delta) { +int BTCooldown::_tick(double p_delta) { ERR_FAIL_COND_V_MSG(get_child_count() == 0, FAILURE, "BT decorator has no child."); if (get_blackboard()->get_var(cooldown_state_var, true)) { return FAILURE; diff --git a/bt/decorators/bt_cooldown.h b/bt/decorators/bt_cooldown.h index 05330e1..6490edc 100644 --- a/bt/decorators/bt_cooldown.h +++ b/bt/decorators/bt_cooldown.h @@ -11,7 +11,7 @@ class BTCooldown : public BTDecorator { GDCLASS(BTCooldown, BTDecorator); private: - float duration = 10.0; + double duration = 10.0; bool process_pause = false; bool start_cooled = false; bool trigger_on_failure = false; @@ -27,14 +27,14 @@ protected: virtual String _generate_name() const override; virtual void _setup() override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; public: - void set_duration(float p_value) { + void set_duration(double p_value) { duration = p_value; emit_changed(); } - float get_duration() const { return duration; } + double get_duration() const { return duration; } void set_process_pause(bool p_value) { process_pause = p_value; emit_changed(); diff --git a/bt/decorators/bt_delay.cpp b/bt/decorators/bt_delay.cpp index 3076100..03c28c9 100644 --- a/bt/decorators/bt_delay.cpp +++ b/bt/decorators/bt_delay.cpp @@ -16,7 +16,7 @@ void BTDelay::_enter() { time_passed = 0.0; } -int BTDelay::_tick(float p_delta) { +int BTDelay::_tick(double p_delta) { ERR_FAIL_COND_V_MSG(get_child_count() == 0, FAILURE, "BT decorator has no child."); time_passed += p_delta; if (time_passed <= seconds) { diff --git a/bt/decorators/bt_delay.h b/bt/decorators/bt_delay.h index 34e4267..f67b6bd 100644 --- a/bt/decorators/bt_delay.h +++ b/bt/decorators/bt_delay.h @@ -10,22 +10,22 @@ class BTDelay : public BTDecorator { GDCLASS(BTDelay, BTDecorator); private: - float seconds = 1.0; - float time_passed = 0.0; + double seconds = 1.0; + double time_passed = 0.0; protected: static void _bind_methods(); virtual String _generate_name() const override; virtual void _enter() override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; public: - void set_seconds(float p_value) { + void set_seconds(double p_value) { seconds = p_value; emit_changed(); } - float get_seconds() const { return seconds; } + double get_seconds() const { return seconds; } }; #endif // BT_DELAY_H \ No newline at end of file diff --git a/bt/decorators/bt_for_each.cpp b/bt/decorators/bt_for_each.cpp index 46d5fb8..ba1037f 100644 --- a/bt/decorators/bt_for_each.cpp +++ b/bt/decorators/bt_for_each.cpp @@ -17,7 +17,7 @@ void BTForEach::_enter() { current_idx = 0; } -int BTForEach::_tick(float p_delta) { +int BTForEach::_tick(double p_delta) { ERR_FAIL_COND_V_MSG(get_child_count() == 0, FAILURE, "ForEach decorator has no child."); ERR_FAIL_COND_V_MSG(save_var.is_empty(), FAILURE, "ForEach save variable is not set."); ERR_FAIL_COND_V_MSG(array_var.is_empty(), FAILURE, "ForEach array variable is not set."); diff --git a/bt/decorators/bt_for_each.h b/bt/decorators/bt_for_each.h index 9f65ca0..9f8e40f 100644 --- a/bt/decorators/bt_for_each.h +++ b/bt/decorators/bt_for_each.h @@ -20,7 +20,7 @@ protected: virtual String _generate_name() const override; virtual void _enter() override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; public: void set_array_var(String p_value) { diff --git a/bt/decorators/bt_invert.cpp b/bt/decorators/bt_invert.cpp index a5fcd24..f7299de 100644 --- a/bt/decorators/bt_invert.cpp +++ b/bt/decorators/bt_invert.cpp @@ -2,7 +2,7 @@ #include "bt_invert.h" -int BTInvert::_tick(float p_delta) { +int BTInvert::_tick(double p_delta) { ERR_FAIL_COND_V_MSG(get_child_count() == 0, FAILURE, "BT decorator has no child."); int status = get_child(0)->execute(p_delta); if (status == SUCCESS) { diff --git a/bt/decorators/bt_invert.h b/bt/decorators/bt_invert.h index 5b0519b..60d14f7 100644 --- a/bt/decorators/bt_invert.h +++ b/bt/decorators/bt_invert.h @@ -10,7 +10,7 @@ class BTInvert : public BTDecorator { GDCLASS(BTInvert, BTDecorator); protected: - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; }; #endif // BT_INVERT_H \ No newline at end of file diff --git a/bt/decorators/bt_new_scope.cpp b/bt/decorators/bt_new_scope.cpp index aa649d0..cae651b 100644 --- a/bt/decorators/bt_new_scope.cpp +++ b/bt/decorators/bt_new_scope.cpp @@ -18,7 +18,7 @@ void BTNewScope::initialize(Node *p_agent, const Ref &p_blackboard) BTDecorator::initialize(p_agent, bb); } -int BTNewScope::_tick(float p_delta) { +int BTNewScope::_tick(double p_delta) { ERR_FAIL_COND_V_MSG(get_child_count() == 0, FAILURE, "BT decorator has no child."); return get_child(0)->execute(p_delta); } diff --git a/bt/decorators/bt_new_scope.h b/bt/decorators/bt_new_scope.h index 15bb43b..6afeac8 100644 --- a/bt/decorators/bt_new_scope.h +++ b/bt/decorators/bt_new_scope.h @@ -19,7 +19,7 @@ protected: void _set_blackboard_data(const Dictionary &p_value) { blackboard_data = p_value; } Dictionary _get_blackboard_data() const { return blackboard_data; } - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; public: virtual void initialize(Node *p_agent, const Ref &p_blackboard) override; diff --git a/bt/decorators/bt_probability.cpp b/bt/decorators/bt_probability.cpp index ec149fc..54db6cc 100644 --- a/bt/decorators/bt_probability.cpp +++ b/bt/decorators/bt_probability.cpp @@ -7,7 +7,7 @@ String BTProbability::_generate_name() const { return vformat("Probability %.1f%%", run_chance); } -int BTProbability::_tick(float p_delta) { +int BTProbability::_tick(double p_delta) { ERR_FAIL_COND_V_MSG(get_child_count() == 0, FAILURE, "BT decorator has no child."); if (get_child(0)->get_status() == RUNNING or Math::randf() <= run_chance) { return get_child(0)->execute(p_delta); diff --git a/bt/decorators/bt_probability.h b/bt/decorators/bt_probability.h index 7aa7613..dcb7e80 100644 --- a/bt/decorators/bt_probability.h +++ b/bt/decorators/bt_probability.h @@ -16,7 +16,7 @@ protected: static void _bind_methods(); virtual String _generate_name() const override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; public: void set_run_chance(float p_value) { diff --git a/bt/decorators/bt_repeat.cpp b/bt/decorators/bt_repeat.cpp index 49d9466..fc6ccfc 100644 --- a/bt/decorators/bt_repeat.cpp +++ b/bt/decorators/bt_repeat.cpp @@ -12,7 +12,7 @@ void BTRepeat::_enter() { cur_iteration = 1; } -int BTRepeat::_tick(float p_delta) { +int BTRepeat::_tick(double p_delta) { ERR_FAIL_COND_V_MSG(get_child_count() == 0, FAILURE, "BT decorator has no child."); int status = get_child(0)->execute(p_delta); if (status == RUNNING) { diff --git a/bt/decorators/bt_repeat.h b/bt/decorators/bt_repeat.h index d213a8a..3cc954a 100644 --- a/bt/decorators/bt_repeat.h +++ b/bt/decorators/bt_repeat.h @@ -19,7 +19,7 @@ protected: virtual String _generate_name() const override; virtual void _enter() override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; public: void set_times(int p_value) { diff --git a/bt/decorators/bt_repeat_until_failure.cpp b/bt/decorators/bt_repeat_until_failure.cpp index 21e6b73..9e0d56a 100644 --- a/bt/decorators/bt_repeat_until_failure.cpp +++ b/bt/decorators/bt_repeat_until_failure.cpp @@ -2,7 +2,7 @@ #include "bt_repeat_until_failure.h" -int BTRepeatUntilFailure::_tick(float p_delta) { +int BTRepeatUntilFailure::_tick(double p_delta) { ERR_FAIL_COND_V_MSG(get_child_count() == 0, FAILURE, "BT decorator has no child."); if (get_child(0)->execute(p_delta) == FAILURE) { return SUCCESS; diff --git a/bt/decorators/bt_repeat_until_failure.h b/bt/decorators/bt_repeat_until_failure.h index 5e06795..13d15c1 100644 --- a/bt/decorators/bt_repeat_until_failure.h +++ b/bt/decorators/bt_repeat_until_failure.h @@ -10,7 +10,7 @@ class BTRepeatUntilFailure : public BTDecorator { GDCLASS(BTRepeatUntilFailure, BTDecorator); protected: - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; }; #endif // BT_REPEAT_UNTIL_FAILURE_H \ No newline at end of file diff --git a/bt/decorators/bt_repeat_until_success.cpp b/bt/decorators/bt_repeat_until_success.cpp index d9247d1..2ed13ca 100644 --- a/bt/decorators/bt_repeat_until_success.cpp +++ b/bt/decorators/bt_repeat_until_success.cpp @@ -2,7 +2,7 @@ #include "bt_repeat_until_success.h" -int BTRepeatUntilSuccess::_tick(float p_delta) { +int BTRepeatUntilSuccess::_tick(double p_delta) { ERR_FAIL_COND_V_MSG(get_child_count() == 0, FAILURE, "BT decorator has no child."); if (get_child(0)->execute(p_delta) == SUCCESS) { return SUCCESS; diff --git a/bt/decorators/bt_repeat_until_success.h b/bt/decorators/bt_repeat_until_success.h index 7729379..1acca99 100644 --- a/bt/decorators/bt_repeat_until_success.h +++ b/bt/decorators/bt_repeat_until_success.h @@ -10,7 +10,7 @@ class BTRepeatUntilSuccess : public BTDecorator { GDCLASS(BTRepeatUntilSuccess, BTDecorator); protected: - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; }; #endif // BT_REPEAT_UNTIL_SUCCESS_H \ No newline at end of file diff --git a/bt/decorators/bt_run_limit.cpp b/bt/decorators/bt_run_limit.cpp index d6ffa92..b95b0a1 100644 --- a/bt/decorators/bt_run_limit.cpp +++ b/bt/decorators/bt_run_limit.cpp @@ -6,7 +6,7 @@ String BTRunLimit::_generate_name() const { return vformat("RunLimit x%d", run_limit); } -int BTRunLimit::_tick(float p_delta) { +int BTRunLimit::_tick(double p_delta) { ERR_FAIL_COND_V_MSG(get_child_count() == 0, FAILURE, "BT decorator has no child."); if (get_child(0)->get_status() != RUNNING) { if (num_runs >= run_limit) { diff --git a/bt/decorators/bt_run_limit.h b/bt/decorators/bt_run_limit.h index 7b69ea1..b9c579c 100644 --- a/bt/decorators/bt_run_limit.h +++ b/bt/decorators/bt_run_limit.h @@ -17,7 +17,7 @@ protected: static void _bind_methods(); virtual String _generate_name() const override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; public: void set_run_limit(int p_value) { diff --git a/bt/decorators/bt_subtree.cpp b/bt/decorators/bt_subtree.cpp index e35c717..8fa0200 100644 --- a/bt/decorators/bt_subtree.cpp +++ b/bt/decorators/bt_subtree.cpp @@ -35,7 +35,7 @@ void BTSubtree::initialize(Node *p_agent, const Ref &p_blackboard) { BTNewScope::initialize(p_agent, p_blackboard); } -int BTSubtree::_tick(float p_delta) { +int BTSubtree::_tick(double p_delta) { ERR_FAIL_COND_V_MSG(get_child_count() == 0, FAILURE, "BT decorator doesn't have a child."); return get_child(0)->execute(p_delta); } diff --git a/bt/decorators/bt_subtree.h b/bt/decorators/bt_subtree.h index 95c294b..8d978eb 100644 --- a/bt/decorators/bt_subtree.h +++ b/bt/decorators/bt_subtree.h @@ -17,7 +17,7 @@ protected: static void _bind_methods(); virtual String _generate_name() const override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; public: void set_subtree(const Ref &p_value) { diff --git a/bt/decorators/bt_time_limit.cpp b/bt/decorators/bt_time_limit.cpp index b4864e6..b95d612 100644 --- a/bt/decorators/bt_time_limit.cpp +++ b/bt/decorators/bt_time_limit.cpp @@ -11,7 +11,7 @@ void BTTimeLimit::_enter() { time_passed = 0.0; } -int BTTimeLimit::_tick(float p_delta) { +int BTTimeLimit::_tick(double p_delta) { ERR_FAIL_COND_V_MSG(get_child_count() == 0, FAILURE, "BT decorator has no child."); time_passed += p_delta; int status = get_child(0)->execute(p_delta); diff --git a/bt/decorators/bt_time_limit.h b/bt/decorators/bt_time_limit.h index cd7d713..97d1e4b 100644 --- a/bt/decorators/bt_time_limit.h +++ b/bt/decorators/bt_time_limit.h @@ -10,22 +10,22 @@ class BTTimeLimit : public BTDecorator { GDCLASS(BTTimeLimit, BTDecorator); private: - float time_limit = 5.0; - float time_passed = 0.0; + double time_limit = 5.0; + double time_passed = 0.0; protected: static void _bind_methods(); virtual String _generate_name() const override; virtual void _enter() override; - virtual int _tick(float p_delta) override; + virtual int _tick(double p_delta) override; public: - void set_time_limit(float p_value) { + void set_time_limit(double p_value) { time_limit = p_value; emit_changed(); } - float get_time_limit() const { return time_limit; } + double get_time_limit() const { return time_limit; } }; #endif // BT_TIME_LIMIT_H \ No newline at end of file diff --git a/limbo_hsm.cpp b/limbo_hsm.cpp index b7a9d6d..e390b5b 100644 --- a/limbo_hsm.cpp +++ b/limbo_hsm.cpp @@ -83,7 +83,7 @@ void LimboHSM::_exit() { LimboState::_exit(); } -void LimboHSM::_update(float p_delta) { +void LimboHSM::_update(double p_delta) { if (active) { ERR_FAIL_COND(active_state == nullptr); LimboState::_update(p_delta); @@ -211,18 +211,10 @@ void LimboHSM::_notification(int p_what) { case NOTIFICATION_POST_ENTER_TREE: { } break; case NOTIFICATION_PROCESS: { - // if (!Engine::get_singleton()->is_editor_hint()) { - // if (update_mode == UpdateMode::IDLE) { _update(get_process_delta_time()); - // } - // } } break; case NOTIFICATION_PHYSICS_PROCESS: { - // if (!Engine::get_singleton()->is_editor_hint()) { - // if (update_mode == UpdateMode::PHYSICS) { _update(get_physics_process_delta_time()); - // } - // } } break; } } diff --git a/limbo_hsm.h b/limbo_hsm.h index 4238024..99248e1 100644 --- a/limbo_hsm.h +++ b/limbo_hsm.h @@ -38,7 +38,7 @@ protected: virtual void _initialize(Node *p_agent, const Ref &p_blackboard) override; virtual void _enter() override; virtual void _exit() override; - virtual void _update(float p_delta) override; + virtual void _update(double p_delta) override; void _change_state(LimboState *p_state); @@ -56,7 +56,7 @@ public: virtual void initialize(Node *p_agent, const Ref &p_parent_scope = nullptr); virtual bool dispatch(const String &p_event, const Variant &p_cargo) override; - void update(float p_delta) { _update(p_delta); } + void update(double p_delta) { _update(p_delta); } void add_transition(Node *p_from_state, Node *p_to_state, const String &p_event); // void add_transition_from_any_state(Node *p_to_state, const String &p_event); LimboState *anystate() const { return nullptr; }; diff --git a/limbo_state.cpp b/limbo_state.cpp index c885f59..34dd675 100644 --- a/limbo_state.cpp +++ b/limbo_state.cpp @@ -45,7 +45,7 @@ void LimboState::_exit() { active = false; }; -void LimboState::_update(float p_delta) { +void LimboState::_update(double p_delta) { GDVIRTUAL_CALL(_update, p_delta); emit_signal(LimboStringNames::get_singleton()->updated, p_delta); }; diff --git a/limbo_state.h b/limbo_state.h index 40e665b..b19d831 100644 --- a/limbo_state.h +++ b/limbo_state.h @@ -42,12 +42,12 @@ protected: virtual void _setup(); virtual void _enter(); virtual void _exit(); - virtual void _update(float p_delta); + virtual void _update(double p_delta); GDVIRTUAL0(_setup); GDVIRTUAL0(_enter); GDVIRTUAL0(_exit); - GDVIRTUAL1(_update, float); + GDVIRTUAL1(_update, double); void add_event_handler(const String &p_event, const Callable &p_handler);