generated from Persson-dev/Godot-Xmake
make world abstract
This commit is contained in:
39
src/client/ClientWorld.cpp
Normal file
39
src/client/ClientWorld.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <client/ClientWorld.h>
|
||||
|
||||
#include <blitz/godot/NetworkInterface.h>
|
||||
#include <client/Player.h>
|
||||
#include <godot_cpp/classes/engine.hpp>
|
||||
#include <godot_cpp/classes/multiplayer_api.hpp>
|
||||
|
||||
namespace blitz {
|
||||
|
||||
using namespace godot;
|
||||
|
||||
void ClientWorld::_bind_methods() {}
|
||||
|
||||
ClientWorld::ClientWorld() {}
|
||||
|
||||
ClientWorld::~ClientWorld() {}
|
||||
|
||||
void ClientWorld::_process(float delta) {
|
||||
#if DEBUG_ENABLED
|
||||
if (Engine::get_singleton()->is_editor_hint())
|
||||
return;
|
||||
#endif
|
||||
m_PassedTime += delta;
|
||||
if (m_PassedTime < 0.05f)
|
||||
return;
|
||||
|
||||
|
||||
UpdatePlayerPos();
|
||||
}
|
||||
|
||||
void ClientWorld::UpdatePlayerPos() {
|
||||
Player* player = GetPlayerById(get_multiplayer()->get_unique_id());
|
||||
if (player) {
|
||||
m_NetworkInterface->BroadcastPacket(protocol::packets::PlayerPositionAndRotation(
|
||||
{get_multiplayer()->get_unique_id(), player->get_position(), player->GetCameraRotation()}));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace blitz
|
||||
Reference in New Issue
Block a user