Modify path visualization
This commit is contained in:
1 parent
542fc191fa
commit
53328484b8
14 files changed
+175
-41
No files matched your search
+29
-4
@@ -140,6 +140,8 @@ namespace FRG
|
||||
|
||||
void Location::stopCharacter(Character& character)
|
||||
{
|
||||
if (player && character.entityId() == player->entityId())
|
||||
pathVisualization.cancel();
|
||||
gameServer_.submit(StopCharacterCommand{locationId_, character.entityId()});
|
||||
}
|
||||
|
||||
@@ -2056,6 +2058,19 @@ namespace FRG
|
||||
// Any new gameplay click invalidates the previous click feedback. Ground
|
||||
// clicks and interactive-object clicks that require walking start a replacement.
|
||||
pathVisualization.cancel();
|
||||
auto findClickPath = [&](const Vec3fp& target) {
|
||||
PathFinder::PathResult result;
|
||||
result.endpoint = playerState->position;
|
||||
result.waypoints = { playerState->position };
|
||||
if (locationState->activeNavigationIndex >= 0 &&
|
||||
locationState->activeNavigationIndex <
|
||||
static_cast<int>(locationState->navigationMaps.size())) {
|
||||
return locationState->navigationMaps[
|
||||
locationState->activeNavigationIndex].findPathResult(
|
||||
playerState->position, target);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
//logger() << "[CLICK] Camera position: (" << camPos.x() << ", " << camPos.y() << ", " << camPos.z() << ")" << std::endl;
|
||||
//logger() << "[CLICK] Ray direction: (" << rayDir.x() << ", " << rayDir.y() << ", " << rayDir.z() << ")" << std::endl;
|
||||
@@ -2071,7 +2086,10 @@ namespace FRG
|
||||
? clickedObject->state.interactionPosition
|
||||
: Vec3fp::fromEigen(clickedObject->state.position);
|
||||
setCharacterTarget(*player, interactionTarget);
|
||||
pathVisualization.start(*player, interactionTarget.toEigen());
|
||||
pathVisualization.start(
|
||||
*player, interactionTarget.toEigen(),
|
||||
findClickPath(interactionTarget),
|
||||
PathVisualization::Style::InteractiveObject);
|
||||
//logger() << "[CLICK] Player moving to object..." << std::endl;
|
||||
}
|
||||
else {
|
||||
@@ -2111,6 +2129,7 @@ namespace FRG
|
||||
pathVisualization.start(
|
||||
*player,
|
||||
clickedNpcState->position.toEigen(),
|
||||
findClickPath(clickedNpcState->position),
|
||||
PathVisualization::Style::Hostile);
|
||||
}
|
||||
// Must follow any destination: in lockstep the last order of
|
||||
@@ -2142,7 +2161,10 @@ namespace FRG
|
||||
//logger() << "[CLICK] NPC " << npcIndex << " out of talk range (distance " << distance
|
||||
// << " > " << NPC_TALK_DISTANCE << "); walking to NPC..." << std::endl;
|
||||
setCharacterTarget(*player, clickedNpcState->position);
|
||||
pathVisualization.start(*player, clickedNpcState->position.toEigen());
|
||||
pathVisualization.start(
|
||||
*player, clickedNpcState->position.toEigen(),
|
||||
findClickPath(clickedNpcState->position),
|
||||
PathVisualization::Style::InteractiveObject);
|
||||
gameServer_.submit(SetLocationTargetsCommand{
|
||||
locationId_, std::string(), clickedNpc->entityId(),
|
||||
std::string()});
|
||||
@@ -2173,11 +2195,14 @@ namespace FRG
|
||||
pathVisualization.start(
|
||||
*player,
|
||||
clickedTeleport->position,
|
||||
findClickPath(Vec3fp::fromEigen(clickedTeleport->position)),
|
||||
PathVisualization::Style::Teleport);
|
||||
} else {
|
||||
const Eigen::Vector3f clickedDestination(hit.x(), 0.f, hit.z());
|
||||
setCharacterTarget(*player, Vec3fp::fromEigen(clickedDestination));
|
||||
pathVisualization.start(*player, clickedDestination);
|
||||
const Vec3fp destination = Vec3fp::fromEigen(clickedDestination);
|
||||
setCharacterTarget(*player, destination);
|
||||
pathVisualization.start(
|
||||
*player, clickedDestination, findClickPath(destination));
|
||||
gameServer_.submit(SetLocationTargetsCommand{
|
||||
locationId_, std::string(), std::string(), std::string()});
|
||||
if (onPlayerFloorWalk) onPlayerFloorWalk();
|
||||
|
||||
Reference in new issue
Block a user