Adapt for web, make CharacterState class

This commit is contained in:
Vladislav Khorev committed 2026-06-18 20:02:59 +03:00
1 parent c891161d69
commit 0eb9d0be25
88 files changed
+810 -102277

No files matched your search

+18 -14
View File
@@ -14,6 +14,7 @@
#include <android/log.h>
#endif
#ifdef EMSCRIPTEN
#include <emscripten.h>
#endif
@@ -326,10 +327,10 @@ namespace ZL
menuManager.setChatUnread(idx, unread, msg);
};
if (locations["uni_interior"]->player)
locations["uni_interior"]->player->onDeathAnimComplete = [this]() { startDarklandsTransition(); };
locations["uni_interior"]->player->state.onDeathAnimComplete = [this]() { startDarklandsTransition(); };
for (auto& npc : locations["uni_interior"]->npcs) {
if (npc && npc->canAttack) {
npc->onDeathAnimComplete = [this]() { menuManager.onEnemyKilledInUniInterior(); };
if (npc && npc->state.canAttack) {
npc->state.onDeathAnimComplete = [this]() { menuManager.onEnemyKilledInUniInterior(); };
}
}
@@ -368,7 +369,7 @@ namespace ZL
menuManager.setChatUnread(idx, unread, msg);
};
if (locations["uni_exterior"]->player)
locations["uni_exterior"]->player->onDeathAnimComplete = [this]() { startDarklandsTransition(); };
locations["uni_exterior"]->player->state.onDeathAnimComplete = [this]() { startDarklandsTransition(); };
LocationSetup params_dorm;
//params_dorm.gameObjectsJsonPath = "resources/config2/gameobjects_dorm.json";
@@ -415,7 +416,7 @@ namespace ZL
menuManager.setChatUnread(idx, unread, msg);
};
if (locations["location_dorm"]->player)
locations["location_dorm"]->player->onDeathAnimComplete = [this]() { startDarklandsTransition(); };
locations["location_dorm"]->player->state.onDeathAnimComplete = [this]() { startDarklandsTransition(); };
locations["location_dorm"]->onPlayerTaxiRequired = [this]() {
menuManager.tutorialShowTaxiHint();
@@ -453,14 +454,17 @@ namespace ZL
return;
}
if (currentLocation)
{
currentLocation->scriptEngine.callLocationExitCallback();
currentLocation->dialogueSystem.stopDialogue();
}
currentLocation = it->second;
if (currentLocation->player) {
currentLocation->player->position = destPos;
currentLocation->player->state.position = destPos;
currentLocation->player->setTarget(destPos);
currentLocation->player->stopInPlace();
currentLocation->player->facingAngle = destRotY;
currentLocation->player->targetFacingAngle = destRotY;
currentLocation->player->state.facingAngle = destRotY;
currentLocation->player->state.targetFacingAngle = destRotY;
}
currentLocation->cameraAzimuth = destRotY;
currentLocation->isDarklands = isDarklands;
@@ -572,7 +576,7 @@ namespace ZL
// Wire HP-change callbacks so all player instances update the health bar HUD.
for (auto& [name, loc] : locations) {
if (loc->player) {
loc->player->onHpChanged = [this](float hp, float maxHp) {
loc->player->state.onHpChanged = [this](float hp, float maxHp) {
menuManager.updateHealthBar(hp, maxHp);
};
}
@@ -1051,15 +1055,15 @@ namespace ZL
//std::cout << "current y: " << y << std::endl;
//y = y - 0.002;
std::cout << "Player pos: " << currentLocation->player->position.transpose() << std::endl;
std::cout << "Player pos: " << currentLocation->player->state.position.transpose() << std::endl;
//currentLocation->npcs[0]->walkSpeed -= 0.01f;
//std::cout << "Walk speed: " << currentLocation->npcs[0]->walkSpeed << std::endl;
break;
case SDLK_p:
currentLocation = locations["uni_interior"];
currentLocation->player->position = Eigen::Vector3f(-0.0189243, 0, -13.4314);
currentLocation->player->setTarget(currentLocation->player->position);
currentLocation->player->state.position = Eigen::Vector3f(-0.0189243, 0, -13.4314);
currentLocation->player->setTarget(currentLocation->player->state.position);
//std::cout << "Switched to location " << ((currentLocation == locations["location1"]) ? "1" : "2") << std::endl;
break;
@@ -1151,12 +1155,12 @@ namespace ZL
if (!currentLocation) return;
if (currentLocation->player) {
currentLocation->player->slowMoTimeRemaining = currentLocation->player->slowMoActiveTime;
currentLocation->player->state.slowMoTimeRemaining = currentLocation->player->state.slowMoActiveTime;
}
for (auto& npc : currentLocation->npcs) {
if (npc) {
npc->slowMoTimeRemaining = npc->slowMoActiveTime;
npc->state.slowMoTimeRemaining = npc->state.slowMoActiveTime;
}
}
}