v2.1.0: fixed char swapping placing both chars in same cell briefly

This commit is contained in:
Evan Debenham
2023-04-27 13:15:08 -04:00
parent aed47bc3a3
commit 6b88ea9369
@@ -213,7 +213,10 @@ public abstract class Char extends Actor {
return true; return true;
} }
int curPos = pos; //we do a little raw position shuffling here so that the characters are never
// on the same cell when logic such as occupyCell() is triggered
int oldPos = pos;
int newPos = c.pos;
//warp instantly with allies in this case //warp instantly with allies in this case
if (c == Dungeon.hero && Dungeon.hero.hasTalent(Talent.ALLY_WARP)){ if (c == Dungeon.hero && Dungeon.hero.hasTalent(Talent.ALLY_WARP)){
@@ -221,8 +224,10 @@ public abstract class Char extends Actor {
if (PathFinder.distance[pos] == Integer.MAX_VALUE){ if (PathFinder.distance[pos] == Integer.MAX_VALUE){
return true; return true;
} }
ScrollOfTeleportation.appear(this, c.pos); pos = newPos;
ScrollOfTeleportation.appear(c, curPos); c.pos = oldPos;
ScrollOfTeleportation.appear(this, newPos);
ScrollOfTeleportation.appear(c, oldPos);
Dungeon.observe(); Dungeon.observe();
GameScene.updateFog(); GameScene.updateFog();
return true; return true;
@@ -233,11 +238,13 @@ public abstract class Char extends Actor {
return true; return true;
} }
moveSprite( pos, c.pos ); c.pos = oldPos;
move( c.pos ); moveSprite( oldPos, newPos );
move( newPos );
c.sprite.move( c.pos, curPos );
c.move( curPos ); c.pos = newPos;
c.sprite.move( newPos, oldPos );
c.move( oldPos );
c.spend( 1 / c.speed() ); c.spend( 1 / c.speed() );