fixed: spawning ships

This commit is contained in:
anime committed 2026-03-02 17:47:46 +06:00
1 parent 7e5aa22fee
commit 26233f934f
4 files changed
+195 -4

No files matched your search

+26
View File
@@ -16,6 +16,7 @@
#endif
#ifdef NETWORK
#include "network/WebSocketClientBase.h"
#ifdef EMSCRIPTEN
#include "network/WebSocketClientEmscripten.h"
#else
@@ -443,6 +444,31 @@ namespace ZL
}
#endif
networkClient->Poll();
#ifdef NETWORK
auto* wsBase = dynamic_cast<ZL::WebSocketClientBase*>(networkClient.get());
if (wsBase) {
auto spawns = wsBase->getPendingSpawns();
for (auto& st : spawns) {
if (st.id == wsBase->getClientId()) {
// применяем к локальному кораблю
ZL::Environment::shipState.position = st.position;
ZL::Environment::shipState.rotation = st.rotation;
// обнуляем движение чтобы не было рывков
ZL::Environment::shipState.currentAngularVelocity = Eigen::Vector3f::Zero();
ZL::Environment::shipState.velocity = 0.0f;
ZL::Environment::shipState.selectedVelocity = 0;
ZL::Environment::shipState.discreteMag = 0.0f;
ZL::Environment::shipState.discreteAngle = -1;
std::cout << "Game: Applied SPAWN at "
<< st.position.x() << ", "
<< st.position.y() << ", "
<< st.position.z() << std::endl;
}
}
}
#endif
}
mainThreadHandler.processMainThreadTasks();