From 9d3814f8d4a76c5d6ba10b51a89c18c4498a0eed Mon Sep 17 00:00:00 2001 From: Josef Date: Sun, 12 May 2024 18:25:45 +0200 Subject: [PATCH] Sequences --- RJAction.h | 6 +++--- RJNetworkNode.h | 6 +++--- RJSelector.h | 6 +++--- RJSensor.h | 6 +++--- RJSequenceAction.cpp | 40 ++++++++++++++++++++++++++++++++++++---- RJSequenceAction.h | 21 ++++++++++++++------- RJUpdatable.h | 7 ++++--- 7 files changed, 66 insertions(+), 26 deletions(-) diff --git a/RJAction.h b/RJAction.h index 1ae9fff..5cad7a5 100644 --- a/RJAction.h +++ b/RJAction.h @@ -1,7 +1,7 @@ /* RJAction.h */ -#ifndef ROKOJORI_CORE__ACTION_H -#define ROKOJORI_CORE__ACTION_H +#ifndef ROKOJORI__ACTION_H +#define ROKOJORI__ACTION_H #include "./RJNetworkNode.h" @@ -25,4 +25,4 @@ public: }; -#endif // ROKOJORI_CORE__ACTION_H \ No newline at end of file +#endif // ROKOJORI__ACTION_H \ No newline at end of file diff --git a/RJNetworkNode.h b/RJNetworkNode.h index 6065d45..84bc3fa 100644 --- a/RJNetworkNode.h +++ b/RJNetworkNode.h @@ -1,7 +1,7 @@ /* RJNetworkNode.h */ -#ifndef ROKOJORI_CORE__NETWORK_NODE_H -#define ROKOJORI_CORE__NETWORK_NODE_H +#ifndef ROKOJORI__NETWORK_NODE_H +#define ROKOJORI__NETWORK_NODE_H #include "scene/main/node.h" @@ -20,4 +20,4 @@ public: }; -#endif // ROKOJORI_CORE__NETWORK_NODE_H \ No newline at end of file +#endif // ROKOJORI__NETWORK_NODE_H \ No newline at end of file diff --git a/RJSelector.h b/RJSelector.h index d4e39f4..4609e2d 100644 --- a/RJSelector.h +++ b/RJSelector.h @@ -1,7 +1,7 @@ /* RJSelector.h */ -#ifndef ROKOJORI_CORE__SELECTOR_H -#define ROKOJORI_CORE__SELECTOR_H +#ifndef ROKOJORI__SELECTOR_H +#define ROKOJORI__SELECTOR_H #include "scene/main/node.h" #include "core/io/resource.h" @@ -24,4 +24,4 @@ public: }; -#endif // ROKOJORI_CORE__SELECTOR_H \ No newline at end of file +#endif // ROKOJORI__SELECTOR_H \ No newline at end of file diff --git a/RJSensor.h b/RJSensor.h index d9150fc..4e2c98e 100644 --- a/RJSensor.h +++ b/RJSensor.h @@ -1,7 +1,7 @@ /* RJSensor.h */ -#ifndef ROKOJORI_CORE__SENSOR_H -#define ROKOJORI_CORE__SENSOR_H +#ifndef ROKOJORI__SENSOR_H +#define ROKOJORI__SENSOR_H #include "./RJNetworkNode.h" @@ -25,4 +25,4 @@ public: }; -#endif // ROKOJORI_CORE__SENSOR_H \ No newline at end of file +#endif // ROKOJORI__SENSOR_H \ No newline at end of file diff --git a/RJSequenceAction.cpp b/RJSequenceAction.cpp index 7b9b071..c7d7103 100644 --- a/RJSequenceAction.cpp +++ b/RJSequenceAction.cpp @@ -6,16 +6,48 @@ void RJSequenceAction::_bind_methods() { - GDVIRTUAL_BIND( dispatchStartEvent ); - GDVIRTUAL_BIND( dispatchCancelEvent ); - GDVIRTUAL_BIND( dispatchEndEvent ); + GDVIRTUAL_BIND( cancelAction ); + + ClassDB::bind_method( D_METHOD( "dispatchStart" ) , &RJSequenceAction::dispatchStart ); + ClassDB::bind_method( D_METHOD( "dispatchCancelled" ) , &RJSequenceAction::dispatchCancelled ); + ClassDB::bind_method( D_METHOD( "dispatchEnd" ) , &RJSequenceAction::dispatchEnd ); + ClassDB::bind_method( D_METHOD( "getLastSequenceActionID" ) , &RJSequenceAction::getLastSequenceActionID ); + + ADD_SIGNAL (MethodInfo( "onSequenceDone" , PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::BOOL, "success") ) ); +} + +int RJSequenceAction::dispatchStart() +{ + if ( idCounter > 1000000 ) + { + idCounter = 0; + } + + idCounter++; + + return idCounter; +} + +int RJSequenceAction::getLastSequenceActionID() +{ + return idCounter; +} + +void RJSequenceAction::dispatchCancelled( int id ) +{ + emit_signal( SNAME( "onSequenceDone" ), id, false ); +} + +void RJSequenceAction::dispatchEnd( int id ) +{ + emit_signal( SNAME( "onSequenceDone" ), id, true ); } RJSequenceAction::RJSequenceAction() { - } + RJSequenceAction::~RJSequenceAction() { diff --git a/RJSequenceAction.h b/RJSequenceAction.h index 606219f..47e7ebf 100644 --- a/RJSequenceAction.h +++ b/RJSequenceAction.h @@ -1,25 +1,32 @@ /* RJSequenceAction.h */ -#ifndef ROKOJORI_CORE__SEQUENCE_ACTION_H -#define ROKOJORI_CORE__SEQUENCE_ACTION_H +#ifndef ROKOJORI__SEQUENCE_ACTION_H +#define ROKOJORI__SEQUENCE_ACTION_H + #include "./RJAction.h" -class RJSequenceAction : public RJAction +class RJSequenceAction : public RJAction { GDCLASS(RJSequenceAction, RJAction); protected: static void _bind_methods(); + int idCounter = 0; public: - GDVIRTUAL0( dispatchStartEvent ); - GDVIRTUAL0( dispatchCancelEvent ); - GDVIRTUAL0( dispatchEndEvent ); + int dispatchStart(); + void dispatchCancelled( int id ); + void dispatchEnd( int id ); + + int getLastSequenceActionID(); + GDVIRTUAL1( cancelAction, int ); + + /* signal onSequenceDone */ RJSequenceAction(); @@ -27,4 +34,4 @@ public: }; -#endif // ROKOJORI_CORE__SEQUENCE_ACTION_H +#endif // ROKOJORI__SEQUENCE_ACTION_H diff --git a/RJUpdatable.h b/RJUpdatable.h index ecac7a0..3a487af 100644 --- a/RJUpdatable.h +++ b/RJUpdatable.h @@ -1,8 +1,9 @@ /* RJUpdatable.h */ -#ifndef ROKOJORI_CORE__UPDATABLE_H -#define ROKOJORI_CORE__UPDATABLE_H +#ifndef ROKOJORI__UPDATABLE_H +#define ROKOJORI__UPDATABLE_H + #include "./RJNetworkNode.h" @@ -25,4 +26,4 @@ public: }; -#endif // ROKOJORI_CORE__UPDATABLE_H +#endif // ROKOJORI__UPDATABLE_H