Working on teleports

This commit is contained in:
Vladislav Khorev committed 2026-06-09 14:43:04 +03:00
1 parent b94f02bd77
commit 0ed7021e90
9 files changed
+60 -3

No files matched your search

+29 -1
View File
@@ -213,6 +213,8 @@ namespace ZL
item.value("positionZ", 0.0f)
);
tz.radius = item.value("radius", 0.0f);
tz.automatic = item.value("automatic", false);
tz.automaticRadius = item.value("automaticRadius", tz.radius);
tz.destinationLocation = item.value("destinationLocation", "");
tz.destinationPosition = Eigen::Vector3f(
item.value("destinationPositionX", 0.0f),
@@ -1406,7 +1408,7 @@ namespace ZL
for (auto& [idx, t] : npcBumpsPlayerCooldown) t -= deltaS;
// Check if player reached target interactive object
if (targetInteractiveObject && player && !targetInteractiveObject->isAnimating) {
if (!tutorialInteractiveObjectsLocked && targetInteractiveObject && player && !targetInteractiveObject->isAnimating) {
const Eigen::Vector3f& approachTarget = targetInteractiveObject->hasInteractionPosition
? targetInteractiveObject->interactionPosition
: targetInteractiveObject->position;
@@ -1467,6 +1469,32 @@ namespace ZL
return;
}
}
if (player) {
for (auto& tz : teleportZones) {
if (!tz.active || !tz.automatic) continue;
const float autoR = tz.automaticRadius > 0.0f ? tz.automaticRadius : tz.radius;
const float dist = (player->position - tz.position).norm();
if (!tz.automaticInitialized) {
// If the player starts inside the zone (e.g. just arrived here via teleport),
// mark them as already inside so they must leave before it can fire.
tz.automaticPlayerInside = (dist <= autoR);
tz.automaticInitialized = true;
continue;
}
const bool isInside = (dist <= autoR);
if (isInside && !tz.automaticPlayerInside) {
tz.automaticPlayerInside = true;
std::cout << "[TELEPORT] Auto-teleport triggered by zone '" << tz.id << "'" << std::endl;
if (onTeleport) onTeleport(tz.destinationLocation, tz.destinationPosition, tz.destinationRotationY);
return;
} else if (!isInside) {
tz.automaticPlayerInside = false;
}
}
}
}
void Location::handleDown(int64_t fingerId, int eventX, int eventY, int mx, int my)