limboai/bt/bt_state.h

57 lines
1.6 KiB
C
Raw Normal View History

/**
* bt_state.h
* =============================================================================
* Copyright 2021-2024 Serhii Snitsaruk
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
2022-10-19 18:54:21 +00:00
#ifndef BT_STATE_H
#define BT_STATE_H
2024-01-07 04:54:17 +00:00
#include "../hsm/limbo_state.h"
2023-07-20 16:35:36 +00:00
2024-01-07 04:54:17 +00:00
#include "../bt/behavior_tree.h"
#include "../bt/tasks/bt_task.h"
2022-10-19 18:54:21 +00:00
class BTState : public LimboState {
GDCLASS(BTState, LimboState);
private:
Ref<BehaviorTree> behavior_tree;
2022-12-16 14:29:36 +00:00
Ref<BTTask> tree_instance;
StringName success_event;
StringName failure_event;
2022-10-19 18:54:21 +00:00
protected:
static void _bind_methods();
void _notification(int p_notification);
virtual bool _should_use_new_scope() const override { return true; }
2024-03-11 17:58:40 +00:00
virtual void _update_blackboard_plan() override;
virtual void _setup() override;
virtual void _exit() override;
virtual void _update(double p_delta) override;
2022-10-19 18:54:21 +00:00
public:
void set_behavior_tree(const Ref<BehaviorTree> &p_value);
2022-10-19 18:54:21 +00:00
Ref<BehaviorTree> get_behavior_tree() const { return behavior_tree; }
Ref<BTTask> get_tree_instance() const { return tree_instance; }
void set_success_event(const StringName &p_success_event) { success_event = p_success_event; }
StringName get_success_event() const { return success_event; }
2022-11-04 12:26:49 +00:00
void set_failure_event(const StringName &p_failure_event) { failure_event = p_failure_event; }
StringName get_failure_event() const { return failure_event; }
2022-11-04 12:26:49 +00:00
BTState();
2022-10-19 18:54:21 +00:00
};
2024-01-13 16:10:42 +00:00
#endif // BT_STATE_H