Port BBParam classes

This commit is contained in:
Serhii Snitsaruk 2024-01-06 21:05:08 +01:00
parent 2c4e343a48
commit 8eed672213
35 changed files with 36 additions and 36 deletions

View File

@ -13,7 +13,6 @@
#define BB_AABB_H #define BB_AABB_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBAabb : public BBParam { class BBAabb : public BBParam {
GDCLASS(BBAabb, BBParam); GDCLASS(BBAabb, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_ARRAY_H #define BB_ARRAY_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBArray : public BBParam { class BBArray : public BBParam {
GDCLASS(BBArray, BBParam); GDCLASS(BBArray, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_BASIS_H #define BB_BASIS_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBBasis : public BBParam { class BBBasis : public BBParam {
GDCLASS(BBBasis, BBParam); GDCLASS(BBBasis, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_BOOL_H #define BB_BOOL_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBBool : public BBParam { class BBBool : public BBParam {
GDCLASS(BBBool, BBParam); GDCLASS(BBBool, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_BYTE_ARRAY_H #define BB_BYTE_ARRAY_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBByteArray : public BBParam { class BBByteArray : public BBParam {
GDCLASS(BBByteArray, BBParam); GDCLASS(BBByteArray, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_COLOR_H #define BB_COLOR_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBColor : public BBParam { class BBColor : public BBParam {
GDCLASS(BBColor, BBParam); GDCLASS(BBColor, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_COLOR_ARRAY_H #define BB_COLOR_ARRAY_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBColorArray : public BBParam { class BBColorArray : public BBParam {
GDCLASS(BBColorArray, BBParam); GDCLASS(BBColorArray, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_DICTIONARY_H #define BB_DICTIONARY_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBDictionary : public BBParam { class BBDictionary : public BBParam {
GDCLASS(BBDictionary, BBParam); GDCLASS(BBDictionary, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_FLOAT_H #define BB_FLOAT_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBFloat : public BBParam { class BBFloat : public BBParam {
GDCLASS(BBFloat, BBParam); GDCLASS(BBFloat, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_FLOAT_ARRAY_H #define BB_FLOAT_ARRAY_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBFloatArray : public BBParam { class BBFloatArray : public BBParam {
GDCLASS(BBFloatArray, BBParam); GDCLASS(BBFloatArray, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_INT_H #define BB_INT_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBInt : public BBParam { class BBInt : public BBParam {
GDCLASS(BBInt, BBParam); GDCLASS(BBInt, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_INT_ARRAY_H #define BB_INT_ARRAY_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBIntArray : public BBParam { class BBIntArray : public BBParam {
GDCLASS(BBIntArray, BBParam); GDCLASS(BBIntArray, BBParam);

View File

@ -10,9 +10,14 @@
*/ */
#include "bb_node.h" #include "bb_node.h"
#ifdef LIMBOAI_MODULE
#include "core/error/error_macros.h" #include "core/error/error_macros.h"
#include "core/variant/variant.h"
#include "scene/main/node.h" #include "scene/main/node.h"
#endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION
#include <godot_cpp/classes/node.hpp>
#endif // LIMBOAI_GDEXTENSION
Variant BBNode::get_value(Object *p_agent, const Ref<Blackboard> &p_blackboard, const Variant &p_default) { Variant BBNode::get_value(Object *p_agent, const Ref<Blackboard> &p_blackboard, const Variant &p_default) {
ERR_FAIL_COND_V(p_agent == nullptr, Variant()); ERR_FAIL_COND_V(p_agent == nullptr, Variant());
@ -28,7 +33,7 @@ Variant BBNode::get_value(Object *p_agent, const Ref<Blackboard> &p_blackboard,
if (val.get_type() == Variant::NODE_PATH) { if (val.get_type() == Variant::NODE_PATH) {
Node *agent = Object::cast_to<Node>(p_agent); Node *agent = Object::cast_to<Node>(p_agent);
ERR_FAIL_COND_V_MSG(agent == nullptr, Variant(), "BBNode: p_agent must be a Node."); ERR_FAIL_COND_V_MSG(agent == nullptr, Variant(), "BBNode: p_agent must be a Node.");
return agent->get_node(val); return agent->get_node_or_null(val);
} else { } else {
Object *obj = val; Object *obj = val;
if (unlikely(obj == nullptr && val.get_type() != Variant::NIL)) { if (unlikely(obj == nullptr && val.get_type() != Variant::NIL)) {

View File

@ -13,7 +13,6 @@
#define BB_NODE_H #define BB_NODE_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBNode : public BBParam { class BBNode : public BBParam {
GDCLASS(BBNode, BBParam); GDCLASS(BBNode, BBParam);

View File

@ -11,6 +11,7 @@
#include "bb_param.h" #include "bb_param.h"
#ifdef LIMBOAI_MODULE
#include "modules/limboai/util/limbo_utility.h" #include "modules/limboai/util/limbo_utility.h"
#include "core/core_bind.h" #include "core/core_bind.h"
@ -19,6 +20,13 @@
#include "core/object/object.h" #include "core/object/object.h"
#include "core/variant/variant.h" #include "core/variant/variant.h"
#include "core/variant/variant_utility.h" #include "core/variant/variant_utility.h"
#endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION
#include "util/limbo_utility.h"
using namespace godot;
#endif // LIMBOAI_GDEXTENSION
VARIANT_ENUM_CAST(BBParam::ValueSource); VARIANT_ENUM_CAST(BBParam::ValueSource);
@ -49,6 +57,7 @@ void BBParam::set_variable(const String &p_value) {
emit_changed(); emit_changed();
} }
#ifdef LIMBOAI_MODULE
String BBParam::to_string() { String BBParam::to_string() {
if (value_source == SAVED_VALUE) { if (value_source == SAVED_VALUE) {
String s = saved_value.stringify(); String s = saved_value.stringify();
@ -70,6 +79,7 @@ String BBParam::to_string() {
return LimboUtility::get_singleton()->decorate_var(variable); return LimboUtility::get_singleton()->decorate_var(variable);
} }
} }
#endif // LIMBOAI_MODULE
Variant BBParam::get_value(Object *p_agent, const Ref<Blackboard> &p_blackboard, const Variant &p_default) { Variant BBParam::get_value(Object *p_agent, const Ref<Blackboard> &p_blackboard, const Variant &p_default) {
ERR_FAIL_COND_V(!p_blackboard.is_valid(), p_default); ERR_FAIL_COND_V(!p_blackboard.is_valid(), p_default);

View File

@ -12,6 +12,7 @@
#ifndef BB_PARAM_H #ifndef BB_PARAM_H
#define BB_PARAM_H #define BB_PARAM_H
#ifdef LIMBOAI_MODULE
#include "modules/limboai/blackboard/blackboard.h" #include "modules/limboai/blackboard/blackboard.h"
#include "modules/limboai/util/limbo_utility.h" #include "modules/limboai/util/limbo_utility.h"
@ -19,6 +20,17 @@
#include "core/object/object.h" #include "core/object/object.h"
#include "core/typedefs.h" #include "core/typedefs.h"
#include "core/variant/variant.h" #include "core/variant/variant.h"
#endif // LIMBOAI_MODULE
#ifdef LIMBOAI_GDEXTENSION
#include "blackboard/blackboard.h"
#include "util/limbo_utility.h"
#include <godot_cpp/classes/object.hpp>
#include <godot_cpp/classes/resource.hpp>
#include <godot_cpp/core/type_info.hpp>
#include <godot_cpp/variant/variant.hpp>
#endif
class BBParam : public Resource { class BBParam : public Resource {
GDCLASS(BBParam, Resource); GDCLASS(BBParam, Resource);
@ -42,8 +54,13 @@ protected:
static void _bind_methods(); static void _bind_methods();
_FORCE_INLINE_ void _assign_default_value() { _FORCE_INLINE_ void _assign_default_value() {
#ifdef LIMBOAI_MODULE
Callable::CallError err; Callable::CallError err;
Variant::construct(get_type(), saved_value, nullptr, 0, err); Variant::construct(get_type(), saved_value, nullptr, 0, err);
#endif
#ifdef LIMBOAI_GDEXTENSION
saved_value.clear();
#endif
} }
void _get_property_list(List<PropertyInfo> *p_list) const; void _get_property_list(List<PropertyInfo> *p_list) const;
@ -60,7 +77,9 @@ public:
void set_variable(const String &p_value); void set_variable(const String &p_value);
String get_variable() const { return variable; } String get_variable() const { return variable; }
#ifdef LIMBOAI_MODULE
virtual String to_string() override; virtual String to_string() override;
#endif
virtual Variant get_value(Object *p_agent, const Ref<Blackboard> &p_blackboard, const Variant &p_default = Variant()); virtual Variant get_value(Object *p_agent, const Ref<Blackboard> &p_blackboard, const Variant &p_default = Variant());

View File

@ -13,7 +13,6 @@
#define BB_PLANE_H #define BB_PLANE_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBPlane : public BBParam { class BBPlane : public BBParam {
GDCLASS(BBPlane, BBParam); GDCLASS(BBPlane, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_QUATERNION_H #define BB_QUATERNION_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBQuaternion : public BBParam { class BBQuaternion : public BBParam {
GDCLASS(BBQuaternion, BBParam); GDCLASS(BBQuaternion, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_RECT2_H #define BB_RECT2_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBRect2 : public BBParam { class BBRect2 : public BBParam {
GDCLASS(BBRect2, BBParam); GDCLASS(BBRect2, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_RECT2I_H #define BB_RECT2I_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBRect2i : public BBParam { class BBRect2i : public BBParam {
GDCLASS(BBRect2i, BBParam); GDCLASS(BBRect2i, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_STRING_H #define BB_STRING_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBString : public BBParam { class BBString : public BBParam {
GDCLASS(BBString, BBParam); GDCLASS(BBString, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_STRING_ARRAY_H #define BB_STRING_ARRAY_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBStringArray : public BBParam { class BBStringArray : public BBParam {
GDCLASS(BBStringArray, BBParam); GDCLASS(BBStringArray, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_STRING_NAME_H #define BB_STRING_NAME_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBStringName : public BBParam { class BBStringName : public BBParam {
GDCLASS(BBStringName, BBParam); GDCLASS(BBStringName, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_TRANSFORM2D_H #define BB_TRANSFORM2D_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBTransform2D : public BBParam { class BBTransform2D : public BBParam {
GDCLASS(BBTransform2D, BBParam); GDCLASS(BBTransform2D, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_TRANSFORM3D_H #define BB_TRANSFORM3D_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBTransform3D : public BBParam { class BBTransform3D : public BBParam {
GDCLASS(BBTransform3D, BBParam); GDCLASS(BBTransform3D, BBParam);

View File

@ -10,8 +10,6 @@
*/ */
#include "bb_variant.h" #include "bb_variant.h"
#include "core/object/object.h"
#include "core/variant/variant.h"
void BBVariant::set_type(Variant::Type p_type) { void BBVariant::set_type(Variant::Type p_type) {
if (type != p_type) { if (type != p_type) {

View File

@ -13,8 +13,6 @@
#define BB_VARIANT_H #define BB_VARIANT_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
#include "core/variant/variant.h"
class BBVariant : public BBParam { class BBVariant : public BBParam {
GDCLASS(BBVariant, BBParam); GDCLASS(BBVariant, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_VECTOR2_H #define BB_VECTOR2_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBVector2 : public BBParam { class BBVector2 : public BBParam {
GDCLASS(BBVector2, BBParam); GDCLASS(BBVector2, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_VECTOR2_ARRAY_H #define BB_VECTOR2_ARRAY_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBVector2Array : public BBParam { class BBVector2Array : public BBParam {
GDCLASS(BBVector2Array, BBParam); GDCLASS(BBVector2Array, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_VECTOR2I_H #define BB_VECTOR2I_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBVector2i : public BBParam { class BBVector2i : public BBParam {
GDCLASS(BBVector2i, BBParam); GDCLASS(BBVector2i, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_VECTOR3_H #define BB_VECTOR3_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBVector3 : public BBParam { class BBVector3 : public BBParam {
GDCLASS(BBVector3, BBParam); GDCLASS(BBVector3, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_VECTOR3_ARRAY_H #define BB_VECTOR3_ARRAY_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBVector3Array : public BBParam { class BBVector3Array : public BBParam {
GDCLASS(BBVector3Array, BBParam); GDCLASS(BBVector3Array, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_VECTOR3I_H #define BB_VECTOR3I_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBVector3i : public BBParam { class BBVector3i : public BBParam {
GDCLASS(BBVector3i, BBParam); GDCLASS(BBVector3i, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_VECTOR4_H #define BB_VECTOR4_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBVector4 : public BBParam { class BBVector4 : public BBParam {
GDCLASS(BBVector4, BBParam); GDCLASS(BBVector4, BBParam);

View File

@ -13,7 +13,6 @@
#define BB_VECTOR4I_H #define BB_VECTOR4I_H
#include "bb_param.h" #include "bb_param.h"
#include "core/object/object.h"
class BBVector4i : public BBParam { class BBVector4i : public BBParam {
GDCLASS(BBVector4i, BBParam); GDCLASS(BBVector4i, BBParam);