diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..bfc46c4 --- /dev/null +++ b/.clangd @@ -0,0 +1,2 @@ +# Cannot suppress driver diagnostics +# https://github.com/clangd/clangd/issues/1142 diff --git a/.helix/config.toml b/.helix/config.toml new file mode 100644 index 0000000..add7d1e --- /dev/null +++ b/.helix/config.toml @@ -0,0 +1,2 @@ +[keys.normal."space"] +B = ":run-shell-command scons" diff --git a/project/main.tscn b/project/main.tscn new file mode 100644 index 0000000..eb44bf2 --- /dev/null +++ b/project/main.tscn @@ -0,0 +1,5 @@ +[gd_scene format=3 uid="uid://cjrkxv8ix1h8s"] + +[node name="Node3D" type="Node3D"] + +[node name="MarshConnector" type="MarshConnector" parent="."] diff --git a/project/project.godot b/project/project.godot index 2cf0cd8..8e013ce 100644 --- a/project/project.godot +++ b/project/project.godot @@ -11,6 +11,7 @@ config_version=5 [application] config/name="Visualisation for MARSH" +run/main_scene="uid://cjrkxv8ix1h8s" config/features=PackedStringArray("4.4", "GL Compatibility") config/icon="res://icon.svg" diff --git a/src/marshconnector.cpp b/src/marshconnector.cpp index dea069b..b06b93d 100644 --- a/src/marshconnector.cpp +++ b/src/marshconnector.cpp @@ -1,17 +1,39 @@ #include "marshconnector.h" -#include + +#include "godot_cpp/classes/engine.hpp" +#include "godot_cpp/core/memory.hpp" +#include "godot_cpp/core/print_string.hpp" using namespace godot; -void MarshConnector::_bind_methods() {} +void MarshConnector::_bind_methods() { + ClassDB::bind_method(D_METHOD("send_heartbeat"), + &MarshConnector::send_heartbeat); +} MarshConnector::MarshConnector() { - // Initialize any variables here. + // Initialize member variables time_passed = 0.0; + + heartbeat_timer = memnew(Timer); + add_child(heartbeat_timer); + heartbeat_timer->set_wait_time(1.0); + heartbeat_timer->set_one_shot(false); + heartbeat_timer->set_autostart(true); + heartbeat_timer->connect("timeout", Callable(this, "send_heartbeat")); + + if (Engine::get_singleton()->is_editor_hint()) { + // Don't run _process() in the editor + set_process_mode(Node::ProcessMode::PROCESS_MODE_DISABLED); + } } MarshConnector::~MarshConnector() { - // Add your cleanup here. + // Free only manually managed member variables } void MarshConnector::_process(double delta) { time_passed += delta; } + +void MarshConnector::send_heartbeat() { + print_line("Sending HEARTBEAT at ", time_passed, " seconds"); +} diff --git a/src/marshconnector.h b/src/marshconnector.h index dbdee27..845cb09 100644 --- a/src/marshconnector.h +++ b/src/marshconnector.h @@ -1,7 +1,8 @@ #ifndef MARSHCONNECTOR_H #define MARSHCONNECTOR_H -#include +#include "godot_cpp/classes/node.hpp" +#include "godot_cpp/classes/timer.hpp" namespace godot { @@ -10,6 +11,7 @@ class MarshConnector : public Node { private: double time_passed; + Timer *heartbeat_timer; protected: static void _bind_methods(); @@ -19,6 +21,8 @@ public: ~MarshConnector(); void _process(double delta) override; + + void send_heartbeat(); }; } // namespace godot