feat: added client node and registered clue id

This commit is contained in:
Sara Gerretsen 2025-10-12 12:54:06 +02:00
parent 38081a7fd0
commit acb7351ea7
11 changed files with 167 additions and 82 deletions

View file

@ -2,12 +2,22 @@
#include "ydi_server.h"
#include <core/config/engine.h>
void ServerNode::_bind_methods() {}
void ServerNode::_bind_methods() {
ADD_SIGNAL(MethodInfo("new_clue", PropertyInfo(Variant::INT, "id")));
}
void ServerNode::enter_tree() {
ydi::server::open();
}
void ServerNode::process(double delta) {
Vector<NetworkData::ClueID> new_clues{};
if (ydi::server::receive::new_clues(new_clues)) {
for (NetworkData::ClueID clue : new_clues) {
emit_signal("new_clue", clue);
}
}
}
void ServerNode::exit_tree() {
ydi::server::close();
}
@ -20,6 +30,9 @@ void ServerNode::_notification(int what) {
case NOTIFICATION_ENTER_TREE:
enter_tree();
return;
case NOTIFICATION_PROCESS:
process(get_process_delta_time());
return;
case NOTIFICATION_EXIT_TREE:
exit_tree();
return;