Refactor BTTask.get_configuration_warnings()
This commit is contained in:
parent
b1aae71f5f
commit
21c65541bf
|
@ -11,13 +11,10 @@
|
||||||
|
|
||||||
#include "bt_action.h"
|
#include "bt_action.h"
|
||||||
|
|
||||||
String BTAction::get_configuration_warning() const {
|
PackedStringArray BTAction::get_configuration_warnings() const {
|
||||||
String warning = BTTask::get_configuration_warning();
|
PackedStringArray warnings = BTTask::get_configuration_warnings();
|
||||||
if (!warning.is_empty()) {
|
|
||||||
warning += "\n";
|
|
||||||
}
|
|
||||||
if (get_child_count() != 0) {
|
if (get_child_count() != 0) {
|
||||||
warning += "Action can't have child tasks.\n";
|
warnings.append("Action can't have child tasks.");
|
||||||
}
|
}
|
||||||
return warning;
|
return warnings;
|
||||||
}
|
}
|
|
@ -20,7 +20,7 @@ class BTAction : public BTTask {
|
||||||
GDCLASS(BTAction, BTTask);
|
GDCLASS(BTAction, BTTask);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual String get_configuration_warning() const override;
|
virtual PackedStringArray get_configuration_warnings() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BT_ACTION_H
|
#endif // BT_ACTION_H
|
|
@ -33,29 +33,24 @@ void BTAwaitAnimation::set_max_time(double p_max_time) {
|
||||||
|
|
||||||
//**** Task Implementation
|
//**** Task Implementation
|
||||||
|
|
||||||
String BTAwaitAnimation::get_configuration_warning() const {
|
PackedStringArray BTAwaitAnimation::get_configuration_warnings() const {
|
||||||
String warning = BTAction::get_configuration_warning();
|
PackedStringArray warnings = BTAction::get_configuration_warnings();
|
||||||
if (!warning.is_empty()) {
|
|
||||||
warning += "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (animation_player_param.is_null()) {
|
if (animation_player_param.is_null()) {
|
||||||
warning += "Animation Player parameter is not set.\n";
|
warnings.append("Animation Player parameter is not set.");
|
||||||
} else {
|
} else {
|
||||||
if (animation_player_param->get_value_source() == BBParam::SAVED_VALUE && animation_player_param->get_saved_value().is_zero()) {
|
if (animation_player_param->get_value_source() == BBParam::SAVED_VALUE && animation_player_param->get_saved_value().is_zero()) {
|
||||||
warning += "Path to AnimationPlayer node is not set.\n";
|
warnings.append("Path to AnimationPlayer node is not set.");
|
||||||
} else if (animation_player_param->get_value_source() == BBParam::BLACKBOARD_VAR && animation_player_param->get_variable().is_empty()) {
|
} else if (animation_player_param->get_value_source() == BBParam::BLACKBOARD_VAR && animation_player_param->get_variable().is_empty()) {
|
||||||
warning += "AnimationPlayer blackboard variable is not set.\n";
|
warnings.append("AnimationPlayer blackboard variable is not set.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (animation_name == StringName()) {
|
if (animation_name == StringName()) {
|
||||||
warning += "Animation Name is required in order to wait for the animation to finish.\n";
|
warnings.append("Animation Name is required in order to wait for the animation to finish.");
|
||||||
}
|
}
|
||||||
if (max_time <= 0.0) {
|
if (max_time <= 0.0) {
|
||||||
warning += "Max time should be greater than 0.0.\n";
|
warnings.append("Max time should be greater than 0.0.");
|
||||||
}
|
}
|
||||||
|
return warnings;
|
||||||
return warning;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String BTAwaitAnimation::_generate_name() const {
|
String BTAwaitAnimation::_generate_name() const {
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
void set_max_time(double p_max_time);
|
void set_max_time(double p_max_time);
|
||||||
double get_max_time() const { return max_time; }
|
double get_max_time() const { return max_time; }
|
||||||
|
|
||||||
virtual String get_configuration_warning() const override;
|
virtual PackedStringArray get_configuration_warnings() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BT_AWAIT_ANIMATION
|
#endif // BT_AWAIT_ANIMATION
|
|
@ -33,17 +33,17 @@ void BTCallMethod::set_args(Array p_args) {
|
||||||
|
|
||||||
//**** Task Implementation
|
//**** Task Implementation
|
||||||
|
|
||||||
String BTCallMethod::get_configuration_warning() const {
|
PackedStringArray BTCallMethod::get_configuration_warnings() const {
|
||||||
String warnings = BTAction::get_configuration_warning();
|
PackedStringArray warnings = BTAction::get_configuration_warnings();
|
||||||
if (method_name == StringName()) {
|
if (method_name == StringName()) {
|
||||||
warnings += "Method Name is not set.\n";
|
warnings.append("Method Name is not set.");
|
||||||
}
|
}
|
||||||
if (node_param.is_null()) {
|
if (node_param.is_null()) {
|
||||||
warnings += "Node parameter is not set.\n";
|
warnings.append("Node parameter is not set.");
|
||||||
} else if (node_param->get_value_source() == BBParam::SAVED_VALUE && node_param->get_saved_value().is_zero()) {
|
} else if (node_param->get_value_source() == BBParam::SAVED_VALUE && node_param->get_saved_value().is_zero()) {
|
||||||
warnings += "Path to node is not set.\n";
|
warnings.append("Path to node is not set.");
|
||||||
} else if (node_param->get_value_source() == BBParam::BLACKBOARD_VAR && node_param->get_variable() == StringName()) {
|
} else if (node_param->get_value_source() == BBParam::BLACKBOARD_VAR && node_param->get_variable() == StringName()) {
|
||||||
warnings += "Node blackboard variable is not set.\n";
|
warnings.append("Node blackboard variable is not set.");
|
||||||
}
|
}
|
||||||
return warnings;
|
return warnings;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
void set_args(Array p_args);
|
void set_args(Array p_args);
|
||||||
Array get_args() const { return args; }
|
Array get_args() const { return args; }
|
||||||
|
|
||||||
virtual String get_configuration_warning() const override;
|
virtual PackedStringArray get_configuration_warnings() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BT_CALL_METHOD
|
#endif // BT_CALL_METHOD
|
|
@ -66,15 +66,12 @@ int BTConsolePrint::_tick(double p_delta) {
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
String BTConsolePrint::get_configuration_warning() const {
|
PackedStringArray BTConsolePrint::get_configuration_warnings() const {
|
||||||
String warning = BTAction::get_configuration_warning();
|
PackedStringArray warnings = BTAction::get_configuration_warnings();
|
||||||
if (!warning.is_empty()) {
|
|
||||||
warning += "\n";
|
|
||||||
}
|
|
||||||
if (bb_format_parameters.size() > 5) {
|
if (bb_format_parameters.size() > 5) {
|
||||||
warning += "ConsolePrint supports up to 5 format arguments.\n";
|
warnings.append("ConsolePrint supports up to 5 format arguments.");
|
||||||
}
|
}
|
||||||
return warning;
|
return warnings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BTConsolePrint::_bind_methods() {
|
void BTConsolePrint::_bind_methods() {
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
}
|
}
|
||||||
PackedStringArray get_bb_format_parameters() const { return bb_format_parameters; }
|
PackedStringArray get_bb_format_parameters() const { return bb_format_parameters; }
|
||||||
|
|
||||||
virtual String get_configuration_warning() const override;
|
virtual PackedStringArray get_configuration_warnings() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BT_CONSOLE_PRINT_H
|
#endif // BT_CONSOLE_PRINT_H
|
|
@ -23,23 +23,18 @@ void BTPauseAnimation::set_animation_player(Ref<BBNode> p_animation_player) {
|
||||||
|
|
||||||
//**** Task Implementation
|
//**** Task Implementation
|
||||||
|
|
||||||
String BTPauseAnimation::get_configuration_warning() const {
|
PackedStringArray BTPauseAnimation::get_configuration_warnings() const {
|
||||||
String warning = BTAction::get_configuration_warning();
|
PackedStringArray warnings = BTAction::get_configuration_warnings();
|
||||||
if (!warning.is_empty()) {
|
|
||||||
warning += "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (animation_player_param.is_null()) {
|
if (animation_player_param.is_null()) {
|
||||||
warning += "Animation Player parameter is not set.\n";
|
warnings.append("Animation Player parameter is not set.");
|
||||||
} else {
|
} else {
|
||||||
if (animation_player_param->get_value_source() == BBParam::SAVED_VALUE && animation_player_param->get_saved_value().is_zero()) {
|
if (animation_player_param->get_value_source() == BBParam::SAVED_VALUE && animation_player_param->get_saved_value().is_zero()) {
|
||||||
warning += "Path to AnimationPlayer node is not set.\n";
|
warnings.append("Path to AnimationPlayer node is not set.");
|
||||||
} else if (animation_player_param->get_value_source() == BBParam::BLACKBOARD_VAR && animation_player_param->get_variable().is_empty()) {
|
} else if (animation_player_param->get_value_source() == BBParam::BLACKBOARD_VAR && animation_player_param->get_variable().is_empty()) {
|
||||||
warning += "AnimationPlayer blackboard variable is not set.\n";
|
warnings.append("AnimationPlayer blackboard variable is not set.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return warnings;
|
||||||
return warning;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String BTPauseAnimation::_generate_name() const {
|
String BTPauseAnimation::_generate_name() const {
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
void set_animation_player(Ref<BBNode> p_animation_player);
|
void set_animation_player(Ref<BBNode> p_animation_player);
|
||||||
Ref<BBNode> get_animation_player() const { return animation_player_param; }
|
Ref<BBNode> get_animation_player() const { return animation_player_param; }
|
||||||
|
|
||||||
virtual String get_configuration_warning() const override;
|
virtual PackedStringArray get_configuration_warnings() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BT_PAUSE_ANIMATION
|
#endif // BT_PAUSE_ANIMATION
|
||||||
|
|
|
@ -50,26 +50,21 @@ void BTPlayAnimation::set_from_end(bool p_from_end) {
|
||||||
|
|
||||||
//**** Task Implementation
|
//**** Task Implementation
|
||||||
|
|
||||||
String BTPlayAnimation::get_configuration_warning() const {
|
PackedStringArray BTPlayAnimation::get_configuration_warnings() const {
|
||||||
String warning = BTAction::get_configuration_warning();
|
PackedStringArray warnings = BTAction::get_configuration_warnings();
|
||||||
if (!warning.is_empty()) {
|
|
||||||
warning += "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (animation_player_param.is_null()) {
|
if (animation_player_param.is_null()) {
|
||||||
warning += "Animation Player parameter is not set.\n";
|
warnings.append("Animation Player parameter is not set.");
|
||||||
} else {
|
} else {
|
||||||
if (animation_player_param->get_value_source() == BBParam::SAVED_VALUE && animation_player_param->get_saved_value().is_zero()) {
|
if (animation_player_param->get_value_source() == BBParam::SAVED_VALUE && animation_player_param->get_saved_value().is_zero()) {
|
||||||
warning += "Path to AnimationPlayer node is not set.\n";
|
warnings.append("Path to AnimationPlayer node is not set.");
|
||||||
} else if (animation_player_param->get_value_source() == BBParam::BLACKBOARD_VAR && animation_player_param->get_variable().is_empty()) {
|
} else if (animation_player_param->get_value_source() == BBParam::BLACKBOARD_VAR && animation_player_param->get_variable().is_empty()) {
|
||||||
warning += "AnimationPlayer blackboard variable is not set.\n";
|
warnings.append("AnimationPlayer blackboard variable is not set.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (animation_name == StringName() && await_completion > 0.0) {
|
if (animation_name == StringName() && await_completion > 0.0) {
|
||||||
warning += "Animation Name is required in order to wait for the animation to finish.\n";
|
warnings.append("Animation Name is required in order to wait for the animation to finish.");
|
||||||
}
|
}
|
||||||
|
return warnings;
|
||||||
return warning;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String BTPlayAnimation::_generate_name() const {
|
String BTPlayAnimation::_generate_name() const {
|
||||||
|
|
|
@ -59,7 +59,7 @@ public:
|
||||||
void set_from_end(bool p_from_end);
|
void set_from_end(bool p_from_end);
|
||||||
bool get_from_end() const { return from_end; }
|
bool get_from_end() const { return from_end; }
|
||||||
|
|
||||||
virtual String get_configuration_warning() const override;
|
virtual PackedStringArray get_configuration_warnings() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BT_PLAY_ANIMATION
|
#endif // BT_PLAY_ANIMATION
|
|
@ -24,18 +24,15 @@ void BTSetAgentProperty::set_value(Ref<BBVariant> p_value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String BTSetAgentProperty::get_configuration_warning() const {
|
PackedStringArray BTSetAgentProperty::get_configuration_warnings() const {
|
||||||
String warning = BTAction::get_configuration_warning();
|
PackedStringArray warnings = BTAction::get_configuration_warnings();
|
||||||
if (!warning.is_empty()) {
|
|
||||||
warning += "\n";
|
|
||||||
}
|
|
||||||
if (property == StringName()) {
|
if (property == StringName()) {
|
||||||
warning += "`property` should be assigned.\n";
|
warnings.append("`property` should be assigned.");
|
||||||
}
|
}
|
||||||
if (!value.is_valid()) {
|
if (!value.is_valid()) {
|
||||||
warning += "`value` should be assigned.\n";
|
warnings.append("`value` should be assigned.");
|
||||||
}
|
}
|
||||||
return warning;
|
return warnings;
|
||||||
}
|
}
|
||||||
|
|
||||||
String BTSetAgentProperty::_generate_name() const {
|
String BTSetAgentProperty::_generate_name() const {
|
||||||
|
|
|
@ -33,7 +33,7 @@ protected:
|
||||||
virtual int _tick(double p_delta) override;
|
virtual int _tick(double p_delta) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual String get_configuration_warning() const override;
|
virtual PackedStringArray get_configuration_warnings() const override;
|
||||||
|
|
||||||
void set_property(StringName p_prop);
|
void set_property(StringName p_prop);
|
||||||
StringName get_property() const { return property; }
|
StringName get_property() const { return property; }
|
||||||
|
|
|
@ -43,18 +43,15 @@ void BTSetVar::set_value(Ref<BBVariant> p_value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String BTSetVar::get_configuration_warning() const {
|
PackedStringArray BTSetVar::get_configuration_warnings() const {
|
||||||
String warning = BTAction::get_configuration_warning();
|
PackedStringArray warnings = BTAction::get_configuration_warnings();
|
||||||
if (!warning.is_empty()) {
|
|
||||||
warning += "\n";
|
|
||||||
}
|
|
||||||
if (variable.is_empty()) {
|
if (variable.is_empty()) {
|
||||||
warning += "`variable` should be assigned.\n";
|
warnings.append("`variable` should be assigned.");
|
||||||
}
|
}
|
||||||
if (!value.is_valid()) {
|
if (!value.is_valid()) {
|
||||||
warning += "`value` should be assigned.\n";
|
warnings.append("`value` should be assigned.");
|
||||||
}
|
}
|
||||||
return warning;
|
return warnings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BTSetVar::_bind_methods() {
|
void BTSetVar::_bind_methods() {
|
||||||
|
|
|
@ -34,7 +34,7 @@ protected:
|
||||||
virtual int _tick(double p_delta) override;
|
virtual int _tick(double p_delta) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual String get_configuration_warning() const override;
|
virtual PackedStringArray get_configuration_warnings() const override;
|
||||||
|
|
||||||
void set_variable(const String &p_variable);
|
void set_variable(const String &p_variable);
|
||||||
String get_variable() const { return variable; }
|
String get_variable() const { return variable; }
|
||||||
|
|
|
@ -33,23 +33,18 @@ void BTStopAnimation::set_keep_state(bool p_keep_state) {
|
||||||
|
|
||||||
//**** Task Implementation
|
//**** Task Implementation
|
||||||
|
|
||||||
String BTStopAnimation::get_configuration_warning() const {
|
PackedStringArray BTStopAnimation::get_configuration_warnings() const {
|
||||||
String warning = BTAction::get_configuration_warning();
|
PackedStringArray warnings = BTAction::get_configuration_warnings();
|
||||||
if (!warning.is_empty()) {
|
|
||||||
warning += "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (animation_player_param.is_null()) {
|
if (animation_player_param.is_null()) {
|
||||||
warning += "Animation Player parameter is not set.\n";
|
warnings.append("Animation Player parameter is not set.");
|
||||||
} else {
|
} else {
|
||||||
if (animation_player_param->get_value_source() == BBParam::SAVED_VALUE && animation_player_param->get_saved_value().is_zero()) {
|
if (animation_player_param->get_value_source() == BBParam::SAVED_VALUE && animation_player_param->get_saved_value().is_zero()) {
|
||||||
warning += "Path to AnimationPlayer node is not set.\n";
|
warnings.append("Path to AnimationPlayer node is not set.");
|
||||||
} else if (animation_player_param->get_value_source() == BBParam::BLACKBOARD_VAR && animation_player_param->get_variable().is_empty()) {
|
} else if (animation_player_param->get_value_source() == BBParam::BLACKBOARD_VAR && animation_player_param->get_variable().is_empty()) {
|
||||||
warning += "AnimationPlayer blackboard variable is not set.\n";
|
warnings.append("AnimationPlayer blackboard variable is not set.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return warnings;
|
||||||
return warning;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String BTStopAnimation::_generate_name() const {
|
String BTStopAnimation::_generate_name() const {
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
void set_keep_state(bool p_keep_state);
|
void set_keep_state(bool p_keep_state);
|
||||||
bool get_keep_state() const { return keep_state; }
|
bool get_keep_state() const { return keep_state; }
|
||||||
|
|
||||||
virtual String get_configuration_warning() const override;
|
virtual PackedStringArray get_configuration_warnings() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BT_STOP_ANIMATION
|
#endif // BT_STOP_ANIMATION
|
|
@ -251,12 +251,15 @@ Ref<BTTask> BTTask::next_sibling() const {
|
||||||
return Ref<BTTask>();
|
return Ref<BTTask>();
|
||||||
}
|
}
|
||||||
|
|
||||||
String BTTask::get_configuration_warning() const {
|
PackedStringArray BTTask::get_configuration_warnings() const {
|
||||||
String warning = "";
|
PackedStringArray ret;
|
||||||
|
|
||||||
GDVIRTUAL_CALL(_get_configuration_warning, warning);
|
PackedStringArray warnings;
|
||||||
|
if (GDVIRTUAL_CALL(_get_configuration_warning, warnings)) {
|
||||||
|
ret.append_array(warnings);
|
||||||
|
}
|
||||||
|
|
||||||
return warning;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BTTask::print_tree(int p_initial_tabs) const {
|
void BTTask::print_tree(int p_initial_tabs) const {
|
||||||
|
|
|
@ -65,7 +65,7 @@ protected:
|
||||||
GDVIRTUAL0(_enter);
|
GDVIRTUAL0(_enter);
|
||||||
GDVIRTUAL0(_exit);
|
GDVIRTUAL0(_exit);
|
||||||
GDVIRTUAL1R(int, _tick, double);
|
GDVIRTUAL1R(int, _tick, double);
|
||||||
GDVIRTUAL0RC(String, _get_configuration_warning);
|
GDVIRTUAL0RC(PackedStringArray, _get_configuration_warning);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool editor_can_reload_from_file() override { return false; }
|
virtual bool editor_can_reload_from_file() override { return false; }
|
||||||
|
@ -84,7 +84,7 @@ public:
|
||||||
|
|
||||||
virtual Ref<BTTask> clone() const;
|
virtual Ref<BTTask> clone() const;
|
||||||
virtual void initialize(Node *p_agent, const Ref<Blackboard> &p_blackboard);
|
virtual void initialize(Node *p_agent, const Ref<Blackboard> &p_blackboard);
|
||||||
virtual String get_configuration_warning() const;
|
virtual PackedStringArray get_configuration_warnings() const;
|
||||||
|
|
||||||
int execute(double p_delta);
|
int execute(double p_delta);
|
||||||
void cancel();
|
void cancel();
|
||||||
|
|
|
@ -11,13 +11,10 @@
|
||||||
|
|
||||||
#include "bt_composite.h"
|
#include "bt_composite.h"
|
||||||
|
|
||||||
String BTComposite::get_configuration_warning() const {
|
PackedStringArray BTComposite::get_configuration_warnings() const {
|
||||||
String warning = BTTask::get_configuration_warning();
|
PackedStringArray warnings = BTTask::get_configuration_warnings();
|
||||||
if (!warning.is_empty()) {
|
|
||||||
warning += "\n";
|
|
||||||
}
|
|
||||||
if (get_child_count() < 1) {
|
if (get_child_count() < 1) {
|
||||||
warning += "Composite should have at least one child task.\n";
|
warnings.append("Composite should have at least one child task.");
|
||||||
}
|
}
|
||||||
return warning;
|
return warnings;
|
||||||
}
|
}
|
|
@ -20,7 +20,7 @@ class BTComposite : public BTTask {
|
||||||
GDCLASS(BTComposite, BTTask);
|
GDCLASS(BTComposite, BTTask);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual String get_configuration_warning() const override;
|
virtual PackedStringArray get_configuration_warnings() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BT_COMPOSITE_H
|
#endif // BT_COMPOSITE_H
|
|
@ -33,18 +33,15 @@ void BTCheckAgentProperty::set_value(Ref<BBVariant> p_value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String BTCheckAgentProperty::get_configuration_warning() const {
|
PackedStringArray BTCheckAgentProperty::get_configuration_warnings() const {
|
||||||
String warning = BTCondition::get_configuration_warning();
|
PackedStringArray warnings = BTCondition::get_configuration_warnings();
|
||||||
if (!warning.is_empty()) {
|
|
||||||
warning += "\n";
|
|
||||||
}
|
|
||||||
if (property == StringName()) {
|
if (property == StringName()) {
|
||||||
warning += "`property` should be assigned.\n";
|
warnings.append("`property` should be assigned.");
|
||||||
}
|
}
|
||||||
if (!value.is_valid()) {
|
if (!value.is_valid()) {
|
||||||
warning += "`value` should be assigned.\n";
|
warnings.append("`value` should be assigned.");
|
||||||
}
|
}
|
||||||
return warning;
|
return warnings;
|
||||||
}
|
}
|
||||||
|
|
||||||
String BTCheckAgentProperty::_generate_name() const {
|
String BTCheckAgentProperty::_generate_name() const {
|
||||||
|
|
|
@ -35,8 +35,6 @@ protected:
|
||||||
virtual int _tick(double p_delta) override;
|
virtual int _tick(double p_delta) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual String get_configuration_warning() const override;
|
|
||||||
|
|
||||||
void set_property(StringName p_prop);
|
void set_property(StringName p_prop);
|
||||||
StringName get_property() const { return property; }
|
StringName get_property() const { return property; }
|
||||||
|
|
||||||
|
@ -45,6 +43,8 @@ public:
|
||||||
|
|
||||||
void set_value(Ref<BBVariant> p_value);
|
void set_value(Ref<BBVariant> p_value);
|
||||||
Ref<BBVariant> get_value() const { return value; }
|
Ref<BBVariant> get_value() const { return value; }
|
||||||
|
|
||||||
|
virtual PackedStringArray get_configuration_warnings() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BT_CHECK_AGENT_PROPERTY
|
#endif // BT_CHECK_AGENT_PROPERTY
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include "bt_check_trigger.h"
|
#include "bt_check_trigger.h"
|
||||||
|
|
||||||
|
#include "bt_condition.h"
|
||||||
#include "modules/limboai/util/limbo_utility.h"
|
#include "modules/limboai/util/limbo_utility.h"
|
||||||
|
|
||||||
#include "core/variant/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
@ -20,6 +21,14 @@ void BTCheckTrigger::set_variable(String p_variable) {
|
||||||
emit_changed();
|
emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PackedStringArray BTCheckTrigger::get_configuration_warnings() const {
|
||||||
|
PackedStringArray warnings = BTCondition::get_configuration_warnings();
|
||||||
|
if (variable.is_empty()) {
|
||||||
|
warnings.append("Variable is not set.");
|
||||||
|
}
|
||||||
|
return warnings;
|
||||||
|
}
|
||||||
|
|
||||||
String BTCheckTrigger::_generate_name() const {
|
String BTCheckTrigger::_generate_name() const {
|
||||||
if (variable.is_empty()) {
|
if (variable.is_empty()) {
|
||||||
return "CheckTrigger ???";
|
return "CheckTrigger ???";
|
||||||
|
|
|
@ -36,6 +36,8 @@ protected:
|
||||||
public:
|
public:
|
||||||
void set_variable(String p_variable);
|
void set_variable(String p_variable);
|
||||||
String get_variable() const { return variable; }
|
String get_variable() const { return variable; }
|
||||||
|
|
||||||
|
virtual PackedStringArray get_configuration_warnings() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BT_CHECK_TRIGGER
|
#endif // BT_CHECK_TRIGGER
|
|
@ -33,18 +33,15 @@ void BTCheckVar::set_value(Ref<BBVariant> p_value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String BTCheckVar::get_configuration_warning() const {
|
PackedStringArray BTCheckVar::get_configuration_warnings() const {
|
||||||
String warning = BTCondition::get_configuration_warning();
|
PackedStringArray warnings = BTCondition::get_configuration_warnings();
|
||||||
if (!warning.is_empty()) {
|
|
||||||
warning += "\n";
|
|
||||||
}
|
|
||||||
if (variable.is_empty()) {
|
if (variable.is_empty()) {
|
||||||
warning += "`variable` should be assigned.\n";
|
warnings.append("`variable` should be assigned.");
|
||||||
}
|
}
|
||||||
if (!value.is_valid()) {
|
if (!value.is_valid()) {
|
||||||
warning += "`value` should be assigned.\n";
|
warnings.append("`value` should be assigned.");
|
||||||
}
|
}
|
||||||
return warning;
|
return warnings;
|
||||||
}
|
}
|
||||||
|
|
||||||
String BTCheckVar::_generate_name() const {
|
String BTCheckVar::_generate_name() const {
|
||||||
|
|
|
@ -17,9 +17,6 @@
|
||||||
#include "modules/limboai/blackboard/bb_param/bb_variant.h"
|
#include "modules/limboai/blackboard/bb_param/bb_variant.h"
|
||||||
#include "modules/limboai/util/limbo_utility.h"
|
#include "modules/limboai/util/limbo_utility.h"
|
||||||
|
|
||||||
#include "core/object/class_db.h"
|
|
||||||
#include "core/object/object.h"
|
|
||||||
|
|
||||||
class BTCheckVar : public BTCondition {
|
class BTCheckVar : public BTCondition {
|
||||||
GDCLASS(BTCheckVar, BTCondition);
|
GDCLASS(BTCheckVar, BTCondition);
|
||||||
|
|
||||||
|
@ -35,7 +32,7 @@ protected:
|
||||||
virtual int _tick(double p_delta) override;
|
virtual int _tick(double p_delta) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual String get_configuration_warning() const override;
|
virtual PackedStringArray get_configuration_warnings() const override;
|
||||||
|
|
||||||
void set_variable(String p_variable);
|
void set_variable(String p_variable);
|
||||||
String get_variable() const { return variable; }
|
String get_variable() const { return variable; }
|
||||||
|
|
|
@ -11,13 +11,10 @@
|
||||||
|
|
||||||
#include "bt_condition.h"
|
#include "bt_condition.h"
|
||||||
|
|
||||||
String BTCondition::get_configuration_warning() const {
|
PackedStringArray BTCondition::get_configuration_warnings() const {
|
||||||
String warning = BTTask::get_configuration_warning();
|
PackedStringArray warnings = BTTask::get_configuration_warnings();
|
||||||
if (!warning.is_empty()) {
|
|
||||||
warning += "\n";
|
|
||||||
}
|
|
||||||
if (get_child_count() != 0) {
|
if (get_child_count() != 0) {
|
||||||
warning += "Condition task can't have child tasks.\n";
|
warnings.append("Condition task can't have child tasks.");
|
||||||
}
|
}
|
||||||
return warning;
|
return warnings;
|
||||||
}
|
}
|
|
@ -20,7 +20,7 @@ class BTCondition : public BTTask {
|
||||||
GDCLASS(BTCondition, BTTask);
|
GDCLASS(BTCondition, BTTask);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual String get_configuration_warning() const override;
|
virtual PackedStringArray get_configuration_warnings() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BT_CONDITION_H
|
#endif // BT_CONDITION_H
|
|
@ -16,6 +16,35 @@
|
||||||
#include "core/variant/array.h"
|
#include "core/variant/array.h"
|
||||||
#include "scene/main/scene_tree.h"
|
#include "scene/main/scene_tree.h"
|
||||||
|
|
||||||
|
//**** Setters / Getters
|
||||||
|
|
||||||
|
void BTCooldown::set_duration(double p_value) {
|
||||||
|
duration = p_value;
|
||||||
|
emit_changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BTCooldown::set_process_pause(bool p_value) {
|
||||||
|
process_pause = p_value;
|
||||||
|
emit_changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BTCooldown::set_start_cooled(bool p_value) {
|
||||||
|
start_cooled = p_value;
|
||||||
|
emit_changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BTCooldown::set_trigger_on_failure(bool p_value) {
|
||||||
|
trigger_on_failure = p_value;
|
||||||
|
emit_changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BTCooldown::set_cooldown_state_var(String p_value) {
|
||||||
|
cooldown_state_var = p_value;
|
||||||
|
emit_changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
//**** Task Implementation
|
||||||
|
|
||||||
String BTCooldown::_generate_name() const {
|
String BTCooldown::_generate_name() const {
|
||||||
return vformat("Cooldown %s sec", Math::snapped(duration, 0.001));
|
return vformat("Cooldown %s sec", Math::snapped(duration, 0.001));
|
||||||
}
|
}
|
||||||
|
@ -57,6 +86,8 @@ void BTCooldown::_on_timeout() {
|
||||||
timer.unref();
|
timer.unref();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//**** Godot
|
||||||
|
|
||||||
void BTCooldown::_bind_methods() {
|
void BTCooldown::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_duration", "p_value"), &BTCooldown::set_duration);
|
ClassDB::bind_method(D_METHOD("set_duration", "p_value"), &BTCooldown::set_duration);
|
||||||
ClassDB::bind_method(D_METHOD("get_duration"), &BTCooldown::get_duration);
|
ClassDB::bind_method(D_METHOD("get_duration"), &BTCooldown::get_duration);
|
||||||
|
|
|
@ -40,30 +40,19 @@ protected:
|
||||||
virtual int _tick(double p_delta) override;
|
virtual int _tick(double p_delta) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set_duration(double p_value) {
|
void set_duration(double p_value);
|
||||||
duration = p_value;
|
|
||||||
emit_changed();
|
|
||||||
}
|
|
||||||
double get_duration() const { return duration; }
|
double get_duration() const { return duration; }
|
||||||
void set_process_pause(bool p_value) {
|
|
||||||
process_pause = p_value;
|
void set_process_pause(bool p_value);
|
||||||
emit_changed();
|
|
||||||
}
|
|
||||||
bool get_process_pause() const { return process_pause; }
|
bool get_process_pause() const { return process_pause; }
|
||||||
void set_start_cooled(bool p_value) {
|
|
||||||
start_cooled = p_value;
|
void set_start_cooled(bool p_value);
|
||||||
emit_changed();
|
|
||||||
}
|
|
||||||
bool get_start_cooled() const { return start_cooled; }
|
bool get_start_cooled() const { return start_cooled; }
|
||||||
void set_trigger_on_failure(bool p_value) {
|
|
||||||
trigger_on_failure = p_value;
|
void set_trigger_on_failure(bool p_value);
|
||||||
emit_changed();
|
|
||||||
}
|
|
||||||
bool get_trigger_on_failure() const { return trigger_on_failure; }
|
bool get_trigger_on_failure() const { return trigger_on_failure; }
|
||||||
void set_cooldown_state_var(String p_value) {
|
|
||||||
cooldown_state_var = p_value;
|
void set_cooldown_state_var(String p_value);
|
||||||
emit_changed();
|
|
||||||
}
|
|
||||||
String get_cooldown_state_var() const { return cooldown_state_var; }
|
String get_cooldown_state_var() const { return cooldown_state_var; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,10 @@
|
||||||
|
|
||||||
#include "bt_decorator.h"
|
#include "bt_decorator.h"
|
||||||
|
|
||||||
String BTDecorator::get_configuration_warning() const {
|
PackedStringArray BTDecorator::get_configuration_warnings() const {
|
||||||
String warning = BTTask::get_configuration_warning();
|
PackedStringArray warnings = BTTask::get_configuration_warnings();
|
||||||
if (!warning.is_empty()) {
|
|
||||||
warning += "\n";
|
|
||||||
}
|
|
||||||
if (get_child_count() != 1) {
|
if (get_child_count() != 1) {
|
||||||
warning += "Decorator should have a single child task.\n";
|
warnings.append("Decorator should have a single child task.");
|
||||||
}
|
}
|
||||||
return warning;
|
return warnings;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ class BTDecorator : public BTTask {
|
||||||
GDCLASS(BTDecorator, BTTask)
|
GDCLASS(BTDecorator, BTTask)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual String get_configuration_warning() const override;
|
virtual PackedStringArray get_configuration_warnings() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BT_DECORATOR_H
|
#endif // BT_DECORATOR_H
|
|
@ -18,6 +18,11 @@
|
||||||
#include "core/variant/array.h"
|
#include "core/variant/array.h"
|
||||||
#include "core/variant/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
|
void BTDelay::set_seconds(double p_value) {
|
||||||
|
seconds = p_value;
|
||||||
|
emit_changed();
|
||||||
|
}
|
||||||
|
|
||||||
String BTDelay::_generate_name() const {
|
String BTDelay::_generate_name() const {
|
||||||
return vformat("Delay %s sec", Math::snapped(seconds, 0.001));
|
return vformat("Delay %s sec", Math::snapped(seconds, 0.001));
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,7 @@ protected:
|
||||||
virtual int _tick(double p_delta) override;
|
virtual int _tick(double p_delta) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set_seconds(double p_value) {
|
void set_seconds(double p_value);
|
||||||
seconds = p_value;
|
|
||||||
emit_changed();
|
|
||||||
}
|
|
||||||
double get_seconds() const { return seconds; }
|
double get_seconds() const { return seconds; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,20 @@
|
||||||
#include "core/error/error_macros.h"
|
#include "core/error/error_macros.h"
|
||||||
#include "core/variant/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
|
//**** Setters / Getters
|
||||||
|
|
||||||
|
void BTForEach::set_array_var(String p_value) {
|
||||||
|
array_var = p_value;
|
||||||
|
emit_changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BTForEach::set_save_var(String p_value) {
|
||||||
|
save_var = p_value;
|
||||||
|
emit_changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
//**** Task Implementation
|
||||||
|
|
||||||
String BTForEach::_generate_name() const {
|
String BTForEach::_generate_name() const {
|
||||||
return vformat("ForEach %s in %s",
|
return vformat("ForEach %s in %s",
|
||||||
LimboUtility::get_singleton()->decorate_var(save_var),
|
LimboUtility::get_singleton()->decorate_var(save_var),
|
||||||
|
@ -53,6 +67,8 @@ int BTForEach::_tick(double p_delta) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//**** Godot
|
||||||
|
|
||||||
void BTForEach::_bind_methods() {
|
void BTForEach::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_array_var", "p_variable"), &BTForEach::set_array_var);
|
ClassDB::bind_method(D_METHOD("set_array_var", "p_variable"), &BTForEach::set_array_var);
|
||||||
ClassDB::bind_method(D_METHOD("get_array_var"), &BTForEach::get_array_var);
|
ClassDB::bind_method(D_METHOD("get_array_var"), &BTForEach::get_array_var);
|
||||||
|
|
|
@ -33,15 +33,10 @@ protected:
|
||||||
virtual int _tick(double p_delta) override;
|
virtual int _tick(double p_delta) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set_array_var(String p_value) {
|
void set_array_var(String p_value);
|
||||||
array_var = p_value;
|
|
||||||
emit_changed();
|
|
||||||
}
|
|
||||||
String get_array_var() const { return array_var; }
|
String get_array_var() const { return array_var; }
|
||||||
void set_save_var(String p_value) {
|
|
||||||
save_var = p_value;
|
void set_save_var(String p_value);
|
||||||
emit_changed();
|
|
||||||
}
|
|
||||||
String get_save_var() const { return save_var; }
|
String get_save_var() const { return save_var; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,10 @@
|
||||||
|
|
||||||
#include "bt_probability.h"
|
#include "bt_probability.h"
|
||||||
|
|
||||||
#include "core/object/object.h"
|
void BTProbability::set_run_chance(float p_value) {
|
||||||
|
run_chance = p_value;
|
||||||
|
emit_changed();
|
||||||
|
}
|
||||||
|
|
||||||
String BTProbability::_generate_name() const {
|
String BTProbability::_generate_name() const {
|
||||||
return vformat("Probability %.1f%%", run_chance);
|
return vformat("Probability %.1f%%", run_chance);
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
|
|
||||||
#include "bt_decorator.h"
|
#include "bt_decorator.h"
|
||||||
|
|
||||||
#include "core/object/object.h"
|
|
||||||
|
|
||||||
class BTProbability : public BTDecorator {
|
class BTProbability : public BTDecorator {
|
||||||
GDCLASS(BTProbability, BTDecorator);
|
GDCLASS(BTProbability, BTDecorator);
|
||||||
|
|
||||||
|
@ -29,10 +27,7 @@ protected:
|
||||||
virtual int _tick(double p_delta) override;
|
virtual int _tick(double p_delta) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set_run_chance(float p_value) {
|
void set_run_chance(float p_value);
|
||||||
run_chance = p_value;
|
|
||||||
emit_changed();
|
|
||||||
}
|
|
||||||
float get_run_chance() const { return run_chance; }
|
float get_run_chance() const { return run_chance; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,11 @@
|
||||||
|
|
||||||
#include "bt_run_limit.h"
|
#include "bt_run_limit.h"
|
||||||
|
|
||||||
|
void BTRunLimit::set_run_limit(int p_value) {
|
||||||
|
run_limit = p_value;
|
||||||
|
emit_changed();
|
||||||
|
}
|
||||||
|
|
||||||
String BTRunLimit::_generate_name() const {
|
String BTRunLimit::_generate_name() const {
|
||||||
return vformat("RunLimit x%d", run_limit);
|
return vformat("RunLimit x%d", run_limit);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
|
|
||||||
#include "bt_decorator.h"
|
#include "bt_decorator.h"
|
||||||
|
|
||||||
#include "core/object/object.h"
|
|
||||||
|
|
||||||
class BTRunLimit : public BTDecorator {
|
class BTRunLimit : public BTDecorator {
|
||||||
GDCLASS(BTRunLimit, BTDecorator);
|
GDCLASS(BTRunLimit, BTDecorator);
|
||||||
|
|
||||||
|
@ -30,10 +28,7 @@ protected:
|
||||||
virtual int _tick(double p_delta) override;
|
virtual int _tick(double p_delta) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set_run_limit(int p_value) {
|
void set_run_limit(int p_value);
|
||||||
run_limit = p_value;
|
|
||||||
emit_changed();
|
|
||||||
}
|
|
||||||
int get_run_limit() const { return run_limit; }
|
int get_run_limit() const { return run_limit; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,14 @@
|
||||||
|
|
||||||
#include "core/config/engine.h"
|
#include "core/config/engine.h"
|
||||||
#include "core/error/error_macros.h"
|
#include "core/error/error_macros.h"
|
||||||
#include "core/object/object.h"
|
|
||||||
#include "core/typedefs.h"
|
#include "core/typedefs.h"
|
||||||
#include "core/variant/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
|
void BTSubtree::set_subtree(const Ref<BehaviorTree> &p_value) {
|
||||||
|
subtree = p_value;
|
||||||
|
emit_changed();
|
||||||
|
}
|
||||||
|
|
||||||
String BTSubtree::_generate_name() const {
|
String BTSubtree::_generate_name() const {
|
||||||
String s;
|
String s;
|
||||||
if (subtree.is_null()) {
|
if (subtree.is_null()) {
|
||||||
|
@ -51,15 +55,12 @@ int BTSubtree::_tick(double p_delta) {
|
||||||
return get_child(0)->execute(p_delta);
|
return get_child(0)->execute(p_delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
String BTSubtree::get_configuration_warning() const {
|
PackedStringArray BTSubtree::get_configuration_warnings() const {
|
||||||
String warning = BTTask::get_configuration_warning(); // BTDecorator skipped intentionally
|
PackedStringArray warnings = BTTask::get_configuration_warnings(); // ! BTDecorator skipped intentionally
|
||||||
if (!warning.is_empty()) {
|
|
||||||
warning += "\n";
|
|
||||||
}
|
|
||||||
if (subtree.is_null()) {
|
if (subtree.is_null()) {
|
||||||
warning += "Subtree needs to be assigned.\n";
|
warnings.append("Subtree needs to be assigned.");
|
||||||
}
|
}
|
||||||
return warning;
|
return warnings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BTSubtree::_bind_methods() {
|
void BTSubtree::_bind_methods() {
|
||||||
|
|
|
@ -13,9 +13,8 @@
|
||||||
#define BT_SUBTREE_H
|
#define BT_SUBTREE_H
|
||||||
|
|
||||||
#include "bt_new_scope.h"
|
#include "bt_new_scope.h"
|
||||||
#include "modules/limboai/bt/behavior_tree.h"
|
|
||||||
|
|
||||||
#include "core/object/object.h"
|
#include "modules/limboai/bt/behavior_tree.h"
|
||||||
|
|
||||||
class BTSubtree : public BTNewScope {
|
class BTSubtree : public BTNewScope {
|
||||||
GDCLASS(BTSubtree, BTNewScope);
|
GDCLASS(BTSubtree, BTNewScope);
|
||||||
|
@ -30,14 +29,11 @@ protected:
|
||||||
virtual int _tick(double p_delta) override;
|
virtual int _tick(double p_delta) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set_subtree(const Ref<BehaviorTree> &p_value) {
|
void set_subtree(const Ref<BehaviorTree> &p_value);
|
||||||
subtree = p_value;
|
|
||||||
emit_changed();
|
|
||||||
}
|
|
||||||
Ref<BehaviorTree> get_subtree() const { return subtree; }
|
Ref<BehaviorTree> get_subtree() const { return subtree; }
|
||||||
|
|
||||||
virtual void initialize(Node *p_agent, const Ref<Blackboard> &p_blackboard) override;
|
virtual void initialize(Node *p_agent, const Ref<Blackboard> &p_blackboard) override;
|
||||||
virtual String get_configuration_warning() const override;
|
virtual PackedStringArray get_configuration_warnings() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BT_SUBTREE_H
|
#endif // BT_SUBTREE_H
|
|
@ -13,6 +13,11 @@
|
||||||
|
|
||||||
#include "core/math/math_funcs.h"
|
#include "core/math/math_funcs.h"
|
||||||
|
|
||||||
|
void BTTimeLimit::set_time_limit(double p_value) {
|
||||||
|
time_limit = p_value;
|
||||||
|
emit_changed();
|
||||||
|
}
|
||||||
|
|
||||||
String BTTimeLimit::_generate_name() const {
|
String BTTimeLimit::_generate_name() const {
|
||||||
return vformat("TimeLimit %s sec", Math::snapped(time_limit, 0.001));
|
return vformat("TimeLimit %s sec", Math::snapped(time_limit, 0.001));
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,7 @@ protected:
|
||||||
virtual int _tick(double p_delta) override;
|
virtual int _tick(double p_delta) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set_time_limit(double p_value) {
|
void set_time_limit(double p_value);
|
||||||
time_limit = p_value;
|
|
||||||
emit_changed();
|
|
||||||
}
|
|
||||||
double get_time_limit() const { return time_limit; }
|
double get_time_limit() const { return time_limit; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -107,9 +107,17 @@ void TaskTree::_update_item(TreeItem *p_item) {
|
||||||
for (int i = 0; i < p_item->get_button_count(0); i++) {
|
for (int i = 0; i < p_item->get_button_count(0); i++) {
|
||||||
p_item->erase_button(0, i);
|
p_item->erase_button(0, i);
|
||||||
}
|
}
|
||||||
String warning = task->get_configuration_warning();
|
|
||||||
if (!warning.is_empty()) {
|
PackedStringArray warnings = task->get_configuration_warnings();
|
||||||
p_item->add_button(0, get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons")), 0, false, warning);
|
String warning_text;
|
||||||
|
for (int j = 0; j < warnings.size(); j++) {
|
||||||
|
if (j > 0) {
|
||||||
|
warning_text += "\n";
|
||||||
|
}
|
||||||
|
warning_text += warnings[j];
|
||||||
|
}
|
||||||
|
if (!warning_text.is_empty()) {
|
||||||
|
p_item->add_button(0, get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons")), 0, false, warning_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Update probabilities.
|
// TODO: Update probabilities.
|
||||||
|
|
Loading…
Reference in New Issue