2023-07-21 09:50:06 +00:00
|
|
|
/**
|
|
|
|
* bb_param.h
|
|
|
|
* =============================================================================
|
2024-01-19 16:05:01 +00:00
|
|
|
* Copyright 2021-2024 Serhii Snitsaruk
|
2023-07-21 09:50:06 +00:00
|
|
|
*
|
|
|
|
* 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-20 16:26:46 +00:00
|
|
|
|
|
|
|
#ifndef BB_PARAM_H
|
|
|
|
#define BB_PARAM_H
|
|
|
|
|
2024-01-10 22:26:24 +00:00
|
|
|
#include "../../blackboard/blackboard.h"
|
|
|
|
#include "../../util/limbo_utility.h"
|
2023-07-20 16:35:36 +00:00
|
|
|
|
2024-01-10 22:26:24 +00:00
|
|
|
#ifdef LIMBOAI_MODULE
|
2022-12-15 07:26:52 +00:00
|
|
|
#include "core/io/resource.h"
|
2024-01-06 20:05:08 +00:00
|
|
|
#endif // LIMBOAI_MODULE
|
|
|
|
|
|
|
|
#ifdef LIMBOAI_GDEXTENSION
|
|
|
|
#include <godot_cpp/classes/resource.hpp>
|
2024-01-13 16:10:42 +00:00
|
|
|
#endif // LIMBOAI_GDEXTENSION
|
2022-10-20 16:26:46 +00:00
|
|
|
|
|
|
|
class BBParam : public Resource {
|
|
|
|
GDCLASS(BBParam, Resource);
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum ValueSource : unsigned int {
|
|
|
|
SAVED_VALUE,
|
|
|
|
BLACKBOARD_VAR
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
ValueSource value_source;
|
|
|
|
Variant saved_value;
|
2024-03-04 11:49:09 +00:00
|
|
|
StringName variable;
|
2022-10-20 16:26:46 +00:00
|
|
|
|
2022-10-20 20:53:09 +00:00
|
|
|
_FORCE_INLINE_ void _update_name() {
|
|
|
|
set_name((value_source == SAVED_VALUE) ? String(saved_value) : LimboUtility::get_singleton()->decorate_var(variable));
|
|
|
|
}
|
|
|
|
|
2022-10-20 16:26:46 +00:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2024-03-20 22:57:42 +00:00
|
|
|
_FORCE_INLINE_ void _assign_default_value() { saved_value = VARIANT_DEFAULT(get_type()); }
|
2023-08-07 12:29:58 +00:00
|
|
|
|
2022-10-20 16:26:46 +00:00
|
|
|
void _get_property_list(List<PropertyInfo> *p_list) const;
|
|
|
|
|
|
|
|
public:
|
2022-10-20 20:53:09 +00:00
|
|
|
void set_value_source(ValueSource p_value);
|
2022-10-20 16:26:46 +00:00
|
|
|
ValueSource get_value_source() const { return value_source; }
|
|
|
|
|
2022-10-20 20:53:09 +00:00
|
|
|
void set_saved_value(Variant p_value);
|
2022-10-25 20:01:00 +00:00
|
|
|
Variant get_saved_value();
|
2022-10-20 16:26:46 +00:00
|
|
|
|
2024-03-04 11:49:09 +00:00
|
|
|
void set_variable(const StringName &p_variable);
|
|
|
|
StringName get_variable() const { return variable; }
|
2022-10-20 16:26:46 +00:00
|
|
|
|
2024-01-06 20:05:08 +00:00
|
|
|
#ifdef LIMBOAI_MODULE
|
2022-12-15 07:26:52 +00:00
|
|
|
virtual String to_string() override;
|
2024-01-13 16:10:42 +00:00
|
|
|
#elif LIMBOAI_GDEXTENSION
|
2024-01-09 21:23:38 +00:00
|
|
|
virtual String _to_string();
|
2024-01-06 20:05:08 +00:00
|
|
|
#endif
|
2022-10-25 21:07:27 +00:00
|
|
|
|
2024-05-18 11:37:24 +00:00
|
|
|
virtual Variant::Type get_type() const { return Variant::NIL; }
|
|
|
|
virtual Variant::Type get_variable_expected_type() const { return get_type(); }
|
2024-05-01 21:32:44 +00:00
|
|
|
virtual Variant get_value(Node *p_scene_root, const Ref<Blackboard> &p_blackboard, const Variant &p_default = Variant());
|
2022-10-20 16:26:46 +00:00
|
|
|
|
|
|
|
BBParam();
|
|
|
|
};
|
|
|
|
|
2024-01-19 16:05:01 +00:00
|
|
|
#endif // BB_PARAM_H
|