rollback to 1.7, which is the same as 1.5 (ugh)

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1533 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2002-06-22 00:59:02 +00:00
parent 7846ddd0d7
commit d597e91e44
@@ -1,9 +1,9 @@
// //
// $Id: TilePath.java,v 1.8 2002/06/18 21:22:34 ray Exp $ // $Id: TilePath.java,v 1.9 2002/06/22 00:59:02 ray Exp $
package com.threerings.miso.scene; package com.threerings.miso.scene;
import java.awt.Point; import java.awt.*;
import java.util.List; import java.util.List;
import com.threerings.util.DirectionCodes; import com.threerings.util.DirectionCodes;
@@ -21,7 +21,7 @@ import com.threerings.miso.scene.util.IsoUtil;
* Only ambulatory sprites can follow a tile path, and their tile * Only ambulatory sprites can follow a tile path, and their tile
* coordinates are updated as the path is traversed. * coordinates are updated as the path is traversed.
*/ */
public class TilePath extends ScreenTilePath public class TilePath extends LineSegmentPath
implements DirectionCodes implements DirectionCodes
{ {
/** /**
@@ -39,29 +39,51 @@ public class TilePath extends ScreenTilePath
IsoSceneViewModel model, MisoCharacterSprite sprite, List tiles, IsoSceneViewModel model, MisoCharacterSprite sprite, List tiles,
int destx, int desty) int destx, int desty)
{ {
super(model); // I won't make any jokes if you don't. _model = model;
// set up the path nodes // set up the path nodes
createPath(sprite, tiles, destx, desty); createPath(sprite, tiles, destx, desty);
} }
// documentation inherited // documentation inherited
protected boolean shouldComputeTileCoords () public boolean tick (Pathable pable, long timestamp)
{ {
return !_arrived; boolean moved = super.tick(pable, timestamp);
}
// documentation inherited if (moved) {
protected void setTileCoords (MisoCharacterSprite mcs, Point pos) MisoCharacterSprite mcs = (MisoCharacterSprite)pable;
{ int sx = mcs.getX(), sy = mcs.getY();
// if the sprite has reached the destination tile, Point pos = new Point();
// update the sprite's tile location and remember
// we've arrived // check whether we've arrived at the destination tile
if (pos.x == _dest.getTileX() && if (!_arrived) {
pos.y == _dest.getTileY()) { // get the sprite's latest tile coordinates
super.setTileCoords(mcs, pos); IsoUtil.screenToTile(_model, sx, sy, pos);
_arrived = true;
// if the sprite has reached the destination tile,
// update the sprite's tile location and remember
// we've arrived
int dtx = _dest.getTileX(), dty = _dest.getTileY();
if (pos.x == dtx && pos.y == dty) {
mcs.setTileLocation(dtx, dty);
// Log.info("Sprite arrived [dtx=" + dtx +
// ", dty=" + dty + "].");
_arrived = true;
}
}
// get the sprite's latest fine coordinates
IsoUtil.tileToScreen(_model, mcs.getTileX(), mcs.getTileY(), pos);
Point fpos = new Point();
IsoUtil.pixelToFine(_model, sx - pos.x, sy - pos.y, fpos);
// inform the sprite
mcs.setFineLocation(fpos.x, fpos.y);
// Log.info("Sprite moved [s=" + mcs + "].");
} }
return moved;
} }
// documentation inherited // documentation inherited
@@ -162,4 +184,7 @@ public class TilePath extends ScreenTilePath
/** The destination tile path node. */ /** The destination tile path node. */
protected TilePathNode _dest; protected TilePathNode _dest;
/** The iso scene view model. */
protected IsoSceneViewModel _model;
} }