Some improvements, added cutscene stub

This commit is contained in:
Vladislav Khorev committed 2026-05-09 23:31:49 +03:00
1 parent 72e05cdc28
commit be05643b70
27 files changed
+3480 -40

No files matched your search

+32 -12
View File
@@ -141,6 +141,9 @@ namespace ZL
scriptEngine.init(this, &inventory, params.scriptPath);
dialogueSystem.setOnCutsceneFinished([this](const std::string& cutsceneId) {
scriptEngine.callCutsceneCompleteCallback(cutsceneId);
});
}
@@ -294,7 +297,7 @@ namespace ZL
const auto addCharacter = [&](const Character* other) {
if (!other || other == self) return;
if (other->hp <= 0.f) return;
if (other->hp <= 0.f || !other->enabled) return;
if (distancePointToSegmentXZ(other->position, start, end) > kDynamicObstacleInfluenceDist) {
return;
@@ -468,19 +471,25 @@ namespace ZL
void Location::navigationEditorSave()
{
std::string filename;
std::string baseName;
for (int i = 1; ; ++i) {
char buf[32];
snprintf(buf, sizeof(buf), "saved_mesh%03d.json", i);
filename = buf;
if (!std::filesystem::exists(filename)) break;
snprintf(buf, sizeof(buf), "saved_mesh%03d", i);
baseName = buf;
if (!std::filesystem::exists(baseName + ".json")) break;
}
if (navigation && navigation->saveConfig(filename)) {
std::cout << "[NAV_EDITOR] Saved navigation config to: " << filename << "\n";
} else {
std::cerr << "[NAV_EDITOR] Failed to save to: " << filename << "\n";
}
if (!navigation) return;
if (navigation->saveConfig(baseName + ".json"))
std::cout << "[NAV_EDITOR] Saved config to: " << baseName << ".json\n";
else
std::cerr << "[NAV_EDITOR] Failed to save config to: " << baseName << ".json\n";
if (navigation->saveGrid(baseName + ".txt"))
std::cout << "[NAV_EDITOR] Saved grid to: " << baseName << ".txt\n";
else
std::cerr << "[NAV_EDITOR] Failed to save grid to: " << baseName << ".txt\n";
}
void Location::navigationEditorReload()
@@ -565,6 +574,7 @@ namespace ZL
std::cout << "[RAYCAST_NPC] " << npc->npcId << " is dead, skipping" << std::endl;
continue;
}
if (!npc->enabled) continue;
const float dx = rayOrigin.x() - npc->position.x();
const float dz = rayOrigin.z() - npc->position.z();
const float a = rayDir.x() * rayDir.x() + rayDir.z() * rayDir.z();
@@ -919,7 +929,7 @@ namespace ZL
Character* a = characters[i];
Character* b = characters[j];
if (!a || !b) continue;
if (a->hp <= 0.f || b->hp <= 0.f) continue;
if (a->hp <= 0.f || b->hp <= 0.f || !a->enabled || !b->enabled) continue;
const float minDist = a->collisionRadius + b->collisionRadius;
if (minDist <= 0.f) continue;
@@ -1023,7 +1033,7 @@ namespace ZL
for (Character* walker : characters) {
if (!walker || walker == mover) continue;
if (walker->hp <= 0.f) continue;
if (walker->hp <= 0.f || !walker->enabled) continue;
if (!walker->isMoving()) continue;
if (replanCooldownRemainingMs.find(walker) != replanCooldownRemainingMs.end()) {
@@ -1301,6 +1311,16 @@ namespace ZL
return dialogueSystem.startDialogue(dialogueId);
}
bool Location::requestCutsceneStart(const std::string& cutsceneId)
{
return dialogueSystem.startCutscene(cutsceneId);
}
void Location::setOnCutsceneFinished(std::function<void(const std::string&)> cb)
{
dialogueSystem.setOnCutsceneFinished(std::move(cb));
}
void Location::setDialogueFlag(const std::string& flag, int value)
{
dialogueSystem.setFlag(flag, value);