42 lines
875 B
C++
42 lines
875 B
C++
#include "server_node.h"
|
|
#include "ydi_server.h"
|
|
#include <core/config/engine.h>
|
|
|
|
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();
|
|
}
|
|
|
|
void ServerNode::_notification(int what) {
|
|
if (Engine::get_singleton()->is_editor_hint()) {
|
|
return;
|
|
}
|
|
switch (what) {
|
|
case NOTIFICATION_ENTER_TREE:
|
|
enter_tree();
|
|
return;
|
|
case NOTIFICATION_PROCESS:
|
|
process(get_process_delta_time());
|
|
return;
|
|
case NOTIFICATION_EXIT_TREE:
|
|
exit_tree();
|
|
return;
|
|
default:
|
|
return;
|
|
}
|
|
}
|