Tiles are now immutable, so the DisplayMisoScene becomes the arbiter of
whether or not a traverser can traverse a tile. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2119 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: DisplayMisoScene.java,v 1.7 2002/09/23 21:54:50 mdb Exp $
|
||||
// $Id: DisplayMisoScene.java,v 1.8 2003/01/13 22:53:56 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -34,4 +34,14 @@ public interface DisplayMisoScene
|
||||
* origin falls in the requested region.
|
||||
*/
|
||||
public void getSceneObjects (Rectangle region, ObjectSet set);
|
||||
|
||||
/**
|
||||
* Returns true if the supplied traverser can traverse the specified
|
||||
* tile coordinate. The traverser is whatever object is passed along
|
||||
* to the path finder when a path is being computed. Scene
|
||||
* implementations which support custom traversal based on the type of
|
||||
* the traverser will want to reflect the traverser's class and act
|
||||
* acordingly.
|
||||
*/
|
||||
public boolean canTraverse (Object traverser, int x, int y);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: DisplayMisoSceneImpl.java,v 1.63 2002/12/11 23:05:07 shaper Exp $
|
||||
// $Id: DisplayMisoSceneImpl.java,v 1.64 2003/01/13 22:53:56 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.threerings.media.tile.NoSuchTileException;
|
||||
import com.threerings.media.tile.NoSuchTileSetException;
|
||||
import com.threerings.media.tile.ObjectTile;
|
||||
import com.threerings.media.tile.Tile;
|
||||
import com.threerings.media.tile.TileException;
|
||||
import com.threerings.media.tile.TileLayer;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
@@ -73,6 +72,7 @@ public class DisplayMisoSceneImpl
|
||||
// create the individual tile layer objects
|
||||
_base = new BaseTileLayer(new BaseTile[swid*shei], swid, shei);
|
||||
_fringe = new TileLayer(new Tile[swid*shei], swid, shei);
|
||||
_covered = new boolean[swid*shei];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,7 +142,7 @@ public class DisplayMisoSceneImpl
|
||||
int tsid = (fqTid >> 16) & 0xFFFF, tid = (fqTid & 0xFFFF);
|
||||
try {
|
||||
expandObject(col, row, tsid, tid, fqTid, ii/3);
|
||||
} catch (TileException te) {
|
||||
} catch (NoSuchTileSetException te) {
|
||||
Log.warning("Scene contains non-existent object tile " +
|
||||
"[tsid=" + tsid + ", tid=" + tid +
|
||||
", col=" + col + ", row=" + row + "].");
|
||||
@@ -213,6 +213,14 @@ public class DisplayMisoSceneImpl
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public boolean canTraverse (Object trav, int x, int y)
|
||||
{
|
||||
BaseTile tile = getBaseTile(x, y);
|
||||
return (((tile == null) || tile.isPassable()) &&
|
||||
!_covered[y*_model.width+x]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string representation of this Miso scene object.
|
||||
*/
|
||||
@@ -276,10 +284,7 @@ public class DisplayMisoSceneImpl
|
||||
continue;
|
||||
}
|
||||
|
||||
BaseTile tile = _base.getTile(xx, yy);
|
||||
if (tile != null) {
|
||||
tile.setCovered(covered);
|
||||
}
|
||||
_covered[yy*_model.width+xx] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,6 +304,9 @@ public class DisplayMisoSceneImpl
|
||||
/** The fringe layer of tiles. */
|
||||
protected TileLayer _fringe;
|
||||
|
||||
/** Information on which tiles are covered by object tiles. */
|
||||
protected boolean[] _covered;
|
||||
|
||||
/** The scene object records. */
|
||||
protected ArrayList _objects = new ArrayList();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: IsoSceneView.java,v 1.127 2002/12/05 23:06:30 mdb Exp $
|
||||
// $Id: IsoSceneView.java,v 1.128 2003/01/13 22:53:56 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -455,7 +455,7 @@ public class IsoSceneView implements SceneView
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public Path getPath (MisoCharacterSprite sprite, int x, int y)
|
||||
public Path getPath (Sprite sprite, int x, int y)
|
||||
{
|
||||
// make sure we have a scene
|
||||
if (_scene == null) {
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
//
|
||||
// $Id: MisoCharacterSprite.java,v 1.7 2002/12/05 23:06:30 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
import com.threerings.cast.CharacterSprite;
|
||||
import com.threerings.miso.tile.BaseTile;
|
||||
|
||||
/**
|
||||
* The miso character sprite extends the basic character sprite to support
|
||||
* the notion of tile passability.
|
||||
*/
|
||||
public class MisoCharacterSprite extends CharacterSprite
|
||||
implements Traverser
|
||||
{
|
||||
// documentation inherited
|
||||
public boolean canTraverse (BaseTile tile)
|
||||
{
|
||||
// by default, passability is solely the province of the tile
|
||||
return tile.isPassable();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SceneView.java,v 1.31 2002/09/24 05:33:05 mdb Exp $
|
||||
// $Id: SceneView.java,v 1.32 2003/01/13 22:53:56 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.awt.Polygon;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import com.threerings.media.sprite.Sprite;
|
||||
import com.threerings.media.util.Path;
|
||||
|
||||
/**
|
||||
@@ -50,7 +51,7 @@ public interface SceneView
|
||||
*
|
||||
* @return the sprite's path, or null if no valid path exists.
|
||||
*/
|
||||
public Path getPath (MisoCharacterSprite sprite, int x, int y);
|
||||
public Path getPath (Sprite sprite, int x, int y);
|
||||
|
||||
/**
|
||||
* Returns screen coordinates given the specified full coordinates.
|
||||
@@ -79,8 +80,8 @@ public interface SceneView
|
||||
/**
|
||||
* Returns information about the object over which the mouse is
|
||||
* currently hovering (either a {@link SceneObject} or a {@link
|
||||
* MisoCharacterSprite}), or null if the mouse is not hovering over
|
||||
* anything of interest.
|
||||
* Sprite}), or null if the mouse is not hovering over anything of
|
||||
* interest.
|
||||
*/
|
||||
public Object getHoverObject ();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: TilePath.java,v 1.11 2002/12/05 23:06:30 mdb Exp $
|
||||
// $Id: TilePath.java,v 1.12 2003/01/13 22:53:56 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.List;
|
||||
|
||||
import com.threerings.util.DirectionCodes;
|
||||
|
||||
import com.threerings.media.sprite.Sprite;
|
||||
import com.threerings.media.util.LineSegmentPath;
|
||||
import com.threerings.media.util.PathNode;
|
||||
import com.threerings.media.util.Pathable;
|
||||
@@ -35,9 +36,8 @@ public class TilePath extends LineSegmentPath
|
||||
* @param desty the destination y-position in screen pixel
|
||||
* coordinates.
|
||||
*/
|
||||
public TilePath (
|
||||
IsoSceneViewModel model, MisoCharacterSprite sprite, List tiles,
|
||||
int destx, int desty)
|
||||
public TilePath (IsoSceneViewModel model, Sprite sprite,
|
||||
List tiles, int destx, int desty)
|
||||
{
|
||||
_model = model;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class TilePath extends LineSegmentPath
|
||||
boolean moved = super.tick(pable, timestamp);
|
||||
|
||||
if (moved) {
|
||||
MisoCharacterSprite mcs = (MisoCharacterSprite)pable;
|
||||
Sprite mcs = (Sprite)pable;
|
||||
int sx = mcs.getX(), sy = mcs.getY();
|
||||
Point pos = new Point();
|
||||
|
||||
@@ -94,8 +94,7 @@ public class TilePath extends LineSegmentPath
|
||||
* from its starting position to the given destination coordinates
|
||||
* following the given list of tile coordinates.
|
||||
*/
|
||||
protected void createPath (
|
||||
MisoCharacterSprite sprite, List tiles, int destx, int desty)
|
||||
protected void createPath (Sprite sprite, List tiles, int destx, int desty)
|
||||
{
|
||||
// constrain destination pixels to fine coordinates
|
||||
Point fpos = new Point();
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
//
|
||||
// $Id: Traverser.java,v 1.4 2001/11/27 22:17:42 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
import com.threerings.miso.tile.BaseTile;
|
||||
|
||||
/**
|
||||
* The <code>Traverser</code> interface should be implemented by
|
||||
* sprites that are going to traverse some path in a scene. This
|
||||
* allows path determination to take into account any special
|
||||
* abilities the traverser may have that alter the traversability of
|
||||
* tiles.
|
||||
*/
|
||||
public interface Traverser
|
||||
{
|
||||
/**
|
||||
* Return whether the traverser can traverse the specified tile.
|
||||
*
|
||||
* @param tile the tile to traverse.
|
||||
*
|
||||
* @return whether the tile is traversable.
|
||||
*/
|
||||
public boolean canTraverse (BaseTile tile);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: AStarPathUtil.java,v 1.20 2002/09/13 00:51:19 ray Exp $
|
||||
// $Id: AStarPathUtil.java,v 1.21 2003/01/13 22:53:56 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene.util;
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.threerings.media.util.MathUtil;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.scene.DisplayMisoScene;
|
||||
import com.threerings.miso.scene.Traverser;
|
||||
import com.threerings.miso.tile.BaseTile;
|
||||
|
||||
/**
|
||||
@@ -45,7 +44,7 @@ public class AStarPathUtil
|
||||
* @return the list of points in the path.
|
||||
*/
|
||||
public static List getPath (
|
||||
DisplayMisoScene scene, int tilewid, int tilehei, Traverser trav,
|
||||
DisplayMisoScene scene, int tilewid, int tilehei, Object trav,
|
||||
int ax, int ay, int bx, int by)
|
||||
{
|
||||
AStarInfo info = new AStarInfo(scene, tilewid, tilehei, trav, bx, by);
|
||||
@@ -212,7 +211,7 @@ class AStarInfo
|
||||
public int tilewid, tilehei;
|
||||
|
||||
/** The traverser moving along the path. */
|
||||
public Traverser trav;
|
||||
public Object trav;
|
||||
|
||||
/** The set of open nodes being searched. */
|
||||
public SortedSet open;
|
||||
@@ -227,7 +226,7 @@ class AStarInfo
|
||||
public int maxcost;
|
||||
|
||||
public AStarInfo (
|
||||
DisplayMisoScene scene, int tilewid, int tilehei, Traverser trav,
|
||||
DisplayMisoScene scene, int tilewid, int tilehei, Object trav,
|
||||
int destx, int desty)
|
||||
{
|
||||
// save off references
|
||||
@@ -284,11 +283,7 @@ class AStarInfo
|
||||
*/
|
||||
protected boolean isTraversable (int x, int y)
|
||||
{
|
||||
if (isCoordinateValid(x, y)) {
|
||||
BaseTile tile = scene.getBaseTile(x, y);
|
||||
return (tile == null) || trav.canTraverse(tile);
|
||||
}
|
||||
return true;
|
||||
return isCoordinateValid(x, y) && scene.canTraverse(trav, x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: IsoUtil.java,v 1.41 2002/12/05 23:06:30 mdb Exp $
|
||||
// $Id: IsoUtil.java,v 1.42 2003/01/13 22:53:56 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene.util;
|
||||
|
||||
@@ -17,7 +17,6 @@ import com.threerings.util.DirectionUtil;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.scene.IsoSceneViewModel;
|
||||
import com.threerings.miso.scene.MisoCharacterSprite;
|
||||
import com.threerings.miso.scene.SceneObject;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user