Use pathfinding algorithm to determine teleport validity.

This commit is contained in:
2023-07-06 03:22:05 -05:00
parent c97886fbbe
commit 46e3c7f7e7
8 changed files with 38 additions and 16 deletions
+2 -2
View File
@@ -306,10 +306,10 @@ bool Wizard::RightClickAbility(){
float dist=std::clamp(geom2d::line<float>{p.GetPos(),game->GetWorldMousePos()}.length(),0.f,6.5f*24);
vf2d teleportPoint=p.GetPos()+pointTowardsMouse*dist;
while(dist>0&&game->HasTileCollision(game->GetCurrentLevel(),teleportPoint)&&p.CanPathfindTo(p.GetPos(),teleportPoint)){
dist--;
dist-=24;
teleportPoint=p.GetPos()+pointTowardsMouse*dist;
}
if(dist>0){
if(dist>0&&p.CanPathfindTo(p.GetPos(),teleportPoint)){
p.SetState(State::TELEPORT);
p.teleportAnimationTimer=0.35;
p.teleportTarget=teleportPoint;