Fixing minor bugs
This commit is contained in:
1 parent
c7b3f04cd4
commit
3495d28edf
9 files changed
+115
-25
No files matched your search
+63
-1
@@ -141,6 +141,35 @@ namespace ZL
|
||||
|
||||
npcs.push_back(std::move(npc02));
|
||||
|
||||
// Teleport zone visuals: an upward fountain of sparks parked at the
|
||||
// teleport position, so the player can spot the zone from a distance.
|
||||
teleportPosition = params.teleportPosition;
|
||||
teleportRadius = params.teleportRadius;
|
||||
if (teleportRadius > 0.0f) {
|
||||
teleportSparks = std::make_unique<SparkEmitter>();
|
||||
std::vector<Vector3f> teleportEmitPoints;
|
||||
teleportEmitPoints.push_back(Vector3f{ teleportPosition.x(), teleportPosition.y(), teleportPosition.z() });
|
||||
teleportSparks->setEmissionPoints(teleportEmitPoints);
|
||||
teleportSparks->setTexture(sparkTexture);
|
||||
teleportSparks->setEmissionRate(50.0f);
|
||||
teleportSparks->setMaxParticles(80);
|
||||
teleportSparks->setParticleSize(0.15f);
|
||||
teleportSparks->setBiasX(0.0f);
|
||||
teleportSparks->setEmissionDirection(Vector3f{ 0.0f, 1.0f, 0.0f });
|
||||
teleportSparks->setSpeedRange(0.5f, 1.0f);
|
||||
teleportSparks->setZSpeedRange(0.5f, 1.5f);
|
||||
teleportSparks->setScaleRange(0.5f, 1.0f);
|
||||
teleportSparks->setLifeTimeRange(1500.0f, 2500.0f);
|
||||
teleportSparks->setUseWorldSpace(true);
|
||||
teleportSparks->markConfigured();
|
||||
|
||||
// If the player happens to spawn already inside the zone, treat them
|
||||
// as in-zone so they don't immediately teleport on the first update.
|
||||
if (player && (player->position - teleportPosition).norm() <= teleportRadius) {
|
||||
playerInTeleportZone = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Create shadow map (2048x2048, ortho size 40, near 0.1, far 100)
|
||||
shadowMap = std::make_unique<ShadowMap>(2048, 40.0f, 0.1f, 100.0f);
|
||||
shadowMap->setLightDirection(Eigen::Vector3f(-0.5f, -1.0f, -0.3f));
|
||||
@@ -403,10 +432,15 @@ namespace ZL
|
||||
const Eigen::Matrix4f currentView = renderer.GetCurrentModelViewMatrix();
|
||||
if (player) player->prepareHitSparksForDraw(currentView);
|
||||
for (auto& npc : npcs) npc->prepareHitSparksForDraw(currentView);
|
||||
if (teleportSparks) teleportSparks->prepareForDraw(currentView);
|
||||
|
||||
if (player) player->draw(renderer);
|
||||
for (auto& npc : npcs) npc->draw(renderer);
|
||||
|
||||
if (teleportSparks) {
|
||||
teleportSparks->draw(renderer, Environment::zoom, Environment::width, Environment::height);
|
||||
}
|
||||
|
||||
#ifdef SHOW_PATH
|
||||
drawDebugNavigation();
|
||||
#endif
|
||||
@@ -592,11 +626,16 @@ namespace ZL
|
||||
|
||||
if (player) player->prepareHitSparksForDraw(cameraViewMatrix);
|
||||
for (auto& npc : npcs) npc->prepareHitSparksForDraw(cameraViewMatrix);
|
||||
if (teleportSparks) teleportSparks->prepareForDraw(cameraViewMatrix);
|
||||
|
||||
if (player) player->drawWithShadow(renderer, lightFromCamera, shadowMap->getDepthTexture(), lightDirCamera);
|
||||
CheckGlError(__FILE__, __LINE__);
|
||||
|
||||
for (auto& npc : npcs) npc->drawWithShadow(renderer, lightFromCamera, shadowMap->getDepthTexture(), lightDirCamera);
|
||||
|
||||
if (teleportSparks) {
|
||||
teleportSparks->draw(renderer, Environment::zoom, Environment::width, Environment::height);
|
||||
}
|
||||
#endif
|
||||
CheckGlError(__FILE__, __LINE__);
|
||||
|
||||
@@ -681,6 +720,29 @@ namespace ZL
|
||||
targetInteractNpcIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Drive teleport spark animation regardless of whether the zone is armed.
|
||||
if (teleportSparks) {
|
||||
teleportSparks->update(static_cast<float>(delta));
|
||||
}
|
||||
|
||||
// Teleport zone: rising-edge trigger only. The destination location's
|
||||
// callback is responsible for placing the player back inside its own
|
||||
// zone and setting playerInTeleportZone = true so we don't bounce.
|
||||
if (player && onTeleport && teleportRadius > 0.0f) {
|
||||
float distToZone = (player->position - teleportPosition).norm();
|
||||
if (distToZone <= teleportRadius) {
|
||||
if (!playerInTeleportZone) {
|
||||
playerInTeleportZone = true;
|
||||
std::cout << "[TELEPORT] Player entered teleport zone" << std::endl;
|
||||
onTeleport();
|
||||
return; // active location may have changed
|
||||
}
|
||||
}
|
||||
else {
|
||||
playerInTeleportZone = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Location::handleDown(int64_t fingerId, int eventX, int eventY, int mx, int my)
|
||||
@@ -742,7 +804,7 @@ namespace ZL
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (npcIndex != -1) {
|
||||
if (npcIndex != -1 && clickedNpc->hp > 0) {
|
||||
targetInteractiveObject = nullptr;
|
||||
|
||||
if (clickedNpc->canAttack) {
|
||||
|
||||
Reference in new issue
Block a user