From 4b2343bb83406bca540d4553a022a16c981f43f3 Mon Sep 17 00:00:00 2001 From: Josef Date: Mon, 5 Aug 2024 09:12:40 +0200 Subject: [PATCH] Interactable C++ --- RJInteractable.cpp | 33 ++++++++++++++++++++++++++++++++ RJInteractable.h | 40 +++++++++++++++++++++++++++++++++++++++ RJInteractor.cpp | 42 +++++++++++++++++++++++++++++++++++++++++ RJInteractor.h | 47 ++++++++++++++++++++++++++++++++++++++++++++++ register_types.cpp | 4 ++++ 5 files changed, 166 insertions(+) create mode 100644 RJInteractable.cpp create mode 100644 RJInteractable.h create mode 100644 RJInteractor.cpp create mode 100644 RJInteractor.h diff --git a/RJInteractable.cpp b/RJInteractable.cpp new file mode 100644 index 0000000..284d0d7 --- /dev/null +++ b/RJInteractable.cpp @@ -0,0 +1,33 @@ + +/* RJInteractable.cpp */ + +#include "RJInteractable.h" + +// Registers fields, signals and methods for Godot +void RJInteractable::_bind_methods() +{ + // onInteraction: RJAction* + ClassDB::bind_method( D_METHOD( "set_onInteraction", "onInteraction" ), &RJInteractable::set_onInteraction ); + ClassDB::bind_method( D_METHOD( "get_onInteraction"), &RJInteractable::get_onInteraction); + ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "onInteraction", PROPERTY_HINT_NODE_TYPE ), "set_onInteraction", "get_onInteraction" ); + +} + +// Constructor +RJInteractable::RJInteractable() +{ + +} + +// Destructor +RJInteractable::~RJInteractable() +{ + +} + +// onInteraction: RJAction* +RJAction* RJInteractable::get_onInteraction() const { return onInteraction; } +void RJInteractable::set_onInteraction( RJAction* p_onInteraction ) { onInteraction = p_onInteraction; } + + + diff --git a/RJInteractable.h b/RJInteractable.h new file mode 100644 index 0000000..85a3113 --- /dev/null +++ b/RJInteractable.h @@ -0,0 +1,40 @@ + +/* RJInteractable.h */ + +#ifndef ROKOJORI__INTERACTABLE_H +#define ROKOJORI__INTERACTABLE_H + +#include "./RJGodotHeaders.h" +#include "./RJAction.h" +#include "scene/3d/node_3d.h" + + + + +class RJInteractable : public Node3D +{ + GDCLASS( RJInteractable, Node3D ); + +protected: + static void _bind_methods(); + + + + // onInteraction : RJAction* + RJAction* onInteraction = nullptr; + +public: + + + // onInteraction : RJAction* + RJAction* get_onInteraction() const; void set_onInteraction( RJAction* p_onInteraction ); + + // Constructor + RJInteractable(); + + // Destructor + ~RJInteractable(); +}; + + +#endif // ROKOJORI__INTERACTABLE_H diff --git a/RJInteractor.cpp b/RJInteractor.cpp new file mode 100644 index 0000000..e0761fe --- /dev/null +++ b/RJInteractor.cpp @@ -0,0 +1,42 @@ + +/* RJInteractor.cpp */ + +#include "RJInteractor.h" + +// Registers fields, signals and methods for Godot +void RJInteractor::_bind_methods() +{ + // input: RJSensor* + ClassDB::bind_method( D_METHOD( "set_input", "input" ), &RJInteractor::set_input ); + ClassDB::bind_method( D_METHOD( "get_input"), &RJInteractor::get_input); + ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "input", PROPERTY_HINT_NODE_TYPE ), "set_input", "get_input" ); + + // pointer: RJPointer* + ClassDB::bind_method( D_METHOD( "set_pointer", "pointer" ), &RJInteractor::set_pointer ); + ClassDB::bind_method( D_METHOD( "get_pointer"), &RJInteractor::get_pointer); + ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "pointer", PROPERTY_HINT_NODE_TYPE ), "set_pointer", "get_pointer" ); + +} + +// Constructor +RJInteractor::RJInteractor() +{ + +} + +// Destructor +RJInteractor::~RJInteractor() +{ + +} + +// input: RJSensor* +RJSensor* RJInteractor::get_input() const { return input; } +void RJInteractor::set_input( RJSensor* p_input ) { input = p_input; } + +// pointer: RJPointer* +RJPointer* RJInteractor::get_pointer() const { return pointer; } +void RJInteractor::set_pointer( RJPointer* p_pointer ) { pointer = p_pointer; } + + + diff --git a/RJInteractor.h b/RJInteractor.h new file mode 100644 index 0000000..167e416 --- /dev/null +++ b/RJInteractor.h @@ -0,0 +1,47 @@ + +/* RJInteractor.h */ + +#ifndef ROKOJORI__INTERACTOR_H +#define ROKOJORI__INTERACTOR_H + +#include "./RJGodotHeaders.h" +#include "./RJSensor.h" +#include "./RJPointer.h" +#include "scene/3d/node_3d.h" + + + + +class RJInteractor : public Node3D +{ + GDCLASS( RJInteractor, Node3D ); + +protected: + static void _bind_methods(); + + + + // input : RJSensor* + RJSensor* input = nullptr; + + // pointer : RJPointer* + RJPointer* pointer = nullptr; + +public: + + + // input : RJSensor* + RJSensor* get_input() const; void set_input( RJSensor* p_input ); + + // pointer : RJPointer* + RJPointer* get_pointer() const; void set_pointer( RJPointer* p_pointer ); + + // Constructor + RJInteractor(); + + // Destructor + ~RJInteractor(); +}; + + +#endif // ROKOJORI__INTERACTOR_H diff --git a/register_types.cpp b/register_types.cpp index 45bfa87..06600a0 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -6,6 +6,8 @@ #include "./RJAction.h" #include "./RJCaster.h" +#include "./RJInteractable.h" +#include "./RJInteractor.h" #include "./RJIntProperty.h" #include "./RJNetworkNode.h" #include "./RJPointable.h" @@ -28,6 +30,8 @@ void initialize_rokojori_action_library_module( ModuleInitializationLevel p_leve ClassDB::register_class(); ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class();