Add small improvements
This commit is contained in:
parent
f9f2a67bbf
commit
8d3249d8a8
|
@ -118,7 +118,7 @@ void BTPlayer::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "active"), "set_active", "get_active");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_restart"), "set_auto_restart", "get_auto_restart");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard", PROPERTY_HINT_NONE, "Blackboard", 0), "", "get_blackboard");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "_blackboard_data"), "_set_blackboard_data", "_get_blackboard_data");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "_blackboard_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "_set_blackboard_data", "_get_blackboard_data");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "prefetch_nodepath_vars"), "set_prefetch_nodepath_vars", "get_prefetch_nodepath_vars");
|
||||
|
||||
BIND_ENUM_CONSTANT(IDLE);
|
||||
|
|
|
@ -17,9 +17,9 @@ void BTState::_exit() {
|
|||
void BTState::_update(float p_delta) {
|
||||
int status = root_task->execute(p_delta);
|
||||
if (status == BTTask::SUCCESS) {
|
||||
get_root()->dispatch("success", Variant());
|
||||
get_root()->dispatch(success_event, Variant());
|
||||
} else if (status == BTTask::FAILURE) {
|
||||
get_root()->dispatch("failure", Variant());
|
||||
get_root()->dispatch(failure_event, Variant());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,18 @@ void BTState::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_behavior_tree", "p_value"), &BTState::set_behavior_tree);
|
||||
ClassDB::bind_method(D_METHOD("get_behavior_tree"), &BTState::get_behavior_tree);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_success_event", "p_event_name"), &BTState::set_success_event);
|
||||
ClassDB::bind_method(D_METHOD("get_success_event"), &BTState::get_success_event);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_failure_event", "p_event_name"), &BTState::set_failure_event);
|
||||
ClassDB::bind_method(D_METHOD("get_failure_event"), &BTState::get_failure_event);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "behavior_tree", PROPERTY_HINT_RESOURCE_TYPE, "BehaviorTree"), "set_behavior_tree", "get_behavior_tree");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "success_event"), "set_success_event", "get_success_event");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "failure_event"), "set_failure_event", "get_failure_event");
|
||||
}
|
||||
|
||||
BTState::BTState() {
|
||||
success_event = "success";
|
||||
failure_event = "failure";
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ class BTState : public LimboState {
|
|||
private:
|
||||
Ref<BehaviorTree> behavior_tree;
|
||||
Ref<BTTask> root_task;
|
||||
String success_event;
|
||||
String failure_event;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
@ -27,6 +29,12 @@ public:
|
|||
void set_behavior_tree(const Ref<BehaviorTree> &p_value) { behavior_tree = p_value; }
|
||||
Ref<BehaviorTree> get_behavior_tree() const { return behavior_tree; }
|
||||
|
||||
void set_success_event(String p_success_event) { success_event = p_success_event; }
|
||||
String get_success_event() const { return success_event; }
|
||||
|
||||
void set_failure_event(String p_failure_event) { failure_event = p_failure_event; }
|
||||
String get_failure_event() const { return failure_event; }
|
||||
|
||||
BTState();
|
||||
};
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ void LimboState::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "EVENT_FINISHED", PROPERTY_HINT_NONE, "", 0), "", "event_finished");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "agent", PROPERTY_HINT_RESOURCE_TYPE, "Object", 0), "set_agent", "get_agent");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "blackboard", PROPERTY_HINT_RESOURCE_TYPE, "Blackboard", 0), "", "get_blackboard");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "_blackboard_data"), "_set_blackboard_data", "_get_blackboard_data");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "_blackboard_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "_set_blackboard_data", "_get_blackboard_data");
|
||||
|
||||
ADD_SIGNAL(MethodInfo("setup"));
|
||||
ADD_SIGNAL(MethodInfo("entered"));
|
||||
|
|
Loading…
Reference in New Issue