Interactable C++

This commit is contained in:
Josef 2024-08-05 09:12:40 +02:00
parent 29c6666c18
commit 4b2343bb83
5 changed files with 166 additions and 0 deletions

33
RJInteractable.cpp Normal file
View File

@ -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; }

40
RJInteractable.h Normal file
View File

@ -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

42
RJInteractor.cpp Normal file
View File

@ -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; }

47
RJInteractor.h Normal file
View File

@ -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

View File

@ -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<RJAction>();
ClassDB::register_class<RJCaster>();
ClassDB::register_class<RJInteractable>();
ClassDB::register_class<RJInteractor>();
ClassDB::register_class<RJIntProperty>();
ClassDB::register_class<RJNetworkNode>();
ClassDB::register_class<RJPointable>();