Separate the notion of tile passability from tile objects since
passability is specific to the miso layer. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@405 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: DisplayMisoSceneImpl.java,v 1.37 2001/09/28 01:46:10 mdb Exp $
|
||||
// $Id: DisplayMisoSceneImpl.java,v 1.38 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -10,12 +10,12 @@ import java.util.List;
|
||||
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.media.tile.Tile;
|
||||
import com.threerings.media.tile.TileManager;
|
||||
import com.threerings.whirled.data.Scene;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.scene.util.ClusterUtil;
|
||||
import com.threerings.miso.tile.MisoTile;
|
||||
|
||||
/**
|
||||
* A scene object represents the data model corresponding to a single
|
||||
@@ -47,8 +47,8 @@ public class MisoSceneImpl implements EditableMisoScene
|
||||
_clusters = new ArrayList();
|
||||
_portals = new ArrayList();
|
||||
|
||||
_tiles = new Tile[_model.scenewid][_model.scenehei][NUM_LAYERS];
|
||||
_deftile = _tilemgr.getTile(deftsid, deftid);
|
||||
_tiles = new MisoTile[_model.scenewid][_model.scenehei][NUM_LAYERS];
|
||||
_deftile = (MisoTile)_tilemgr.getTile(deftsid, deftid);
|
||||
for (int xx = 0; xx < _model.scenewid; xx++) {
|
||||
for (int yy = 0; yy < _model.scenehei; yy++) {
|
||||
for (int ii = 0; ii < NUM_LAYERS; ii++) {
|
||||
@@ -73,7 +73,7 @@ public class MisoSceneImpl implements EditableMisoScene
|
||||
public MisoSceneImpl (IsoSceneViewModel model, TileManager tilemgr,
|
||||
String name, ArrayList locations,
|
||||
ArrayList clusters, ArrayList portals,
|
||||
Tile[][][] tiles)
|
||||
MisoTile[][][] tiles)
|
||||
{
|
||||
_model = model;
|
||||
_tilemgr = tilemgr;
|
||||
@@ -110,13 +110,13 @@ public class MisoSceneImpl implements EditableMisoScene
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public Tile[][][] getTiles ()
|
||||
public MisoTile[][][] getTiles ()
|
||||
{
|
||||
return _tiles;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public Tile getDefaultTile ()
|
||||
public MisoTile getDefaultTile ()
|
||||
{
|
||||
return _deftile;
|
||||
}
|
||||
@@ -261,7 +261,7 @@ public class MisoSceneImpl implements EditableMisoScene
|
||||
protected int _version;
|
||||
|
||||
/** The tiles comprising the scene. */
|
||||
public Tile[][][] _tiles;
|
||||
public MisoTile[][][] _tiles;
|
||||
|
||||
/** The default entrance portal. */
|
||||
protected Portal _entrance;
|
||||
@@ -276,7 +276,7 @@ public class MisoSceneImpl implements EditableMisoScene
|
||||
protected ArrayList _portals;
|
||||
|
||||
/** The default tile for the base layer in the scene. */
|
||||
protected Tile _deftile;
|
||||
protected MisoTile _deftile;
|
||||
|
||||
/** The iso scene view data model. */
|
||||
protected IsoSceneViewModel _model;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
//
|
||||
// $Id: MisoScene.java,v 1.3 2001/10/05 23:58:36 mdb Exp $
|
||||
// $Id: MisoScene.java,v 1.4 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.threerings.media.tile.Tile;
|
||||
import com.threerings.miso.tile.MisoTile;
|
||||
|
||||
/**
|
||||
* A scene object represents the data model corresponding to a single
|
||||
@@ -42,12 +42,12 @@ public interface MisoScene
|
||||
/**
|
||||
* Return the tiles that comprise this scene.
|
||||
*/
|
||||
public Tile[][][] getTiles ();
|
||||
public MisoTile[][][] getTiles ();
|
||||
|
||||
/**
|
||||
* Return the default tile for the base layer of the scene.
|
||||
*/
|
||||
public Tile getDefaultTile ();
|
||||
public MisoTile getDefaultTile ();
|
||||
|
||||
/**
|
||||
* Return the locations in this scene. The locations list should
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//
|
||||
// $Id: Traverser.java,v 1.2 2001/08/16 23:14:21 mdb Exp $
|
||||
// $Id: Traverser.java,v 1.3 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
import com.threerings.media.tile.Tile;
|
||||
import com.threerings.miso.tile.MisoTile;
|
||||
|
||||
/**
|
||||
* The <code>Traverser</code> interface should be implemented by
|
||||
@@ -21,5 +21,5 @@ public interface Traverser
|
||||
*
|
||||
* @return whether the tile is traversable.
|
||||
*/
|
||||
public boolean canTraverse (Tile tile);
|
||||
public boolean canTraverse (MisoTile tile);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
//
|
||||
// $Id: AStarPathUtil.java,v 1.4 2001/08/23 00:55:30 shaper Exp $
|
||||
// $Id: AStarPathUtil.java,v 1.5 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene.util;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.*;
|
||||
|
||||
import com.threerings.media.tile.Tile;
|
||||
import com.threerings.media.util.MathUtil;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.scene.Traverser;
|
||||
import com.threerings.miso.tile.MisoTile;
|
||||
|
||||
/**
|
||||
* The <code>AStarPathUtil</code> class provides a facility for
|
||||
@@ -43,7 +43,7 @@ public class AStarPathUtil
|
||||
* @return the list of points in the path.
|
||||
*/
|
||||
public static List getPath (
|
||||
Tile tiles[][][], int tilewid, int tilehei, Traverser trav,
|
||||
MisoTile tiles[][][], int tilewid, int tilehei, Traverser trav,
|
||||
int ax, int ay, int bx, int by)
|
||||
{
|
||||
AStarInfo info = new AStarInfo(tiles, tilewid, tilehei, trav, bx, by);
|
||||
@@ -198,7 +198,7 @@ public class AStarPathUtil
|
||||
class AStarInfo
|
||||
{
|
||||
/** The array of tiles being traversed. */
|
||||
public Tile tiles[][][];
|
||||
public MisoTile tiles[][][];
|
||||
|
||||
/** The tile array dimensions. */
|
||||
public int tilewid, tilehei;
|
||||
@@ -219,7 +219,7 @@ class AStarInfo
|
||||
public int destx, desty;
|
||||
|
||||
public AStarInfo (
|
||||
Tile tiles[][][], int tilewid, int tilehei, Traverser trav,
|
||||
MisoTile tiles[][][], int tilewid, int tilehei, Traverser trav,
|
||||
int destx, int desty)
|
||||
{
|
||||
// save off references
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// $Id: BaseTile.java,v 1.1 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.tile;
|
||||
|
||||
import com.threerings.media.tile.Tile;
|
||||
|
||||
/**
|
||||
* The miso tile class extends the base tile class to add support for
|
||||
* tile passability.
|
||||
*
|
||||
* @see MisoTileSet
|
||||
*/
|
||||
public class MisoTile extends Tile
|
||||
{
|
||||
/** Whether the tile is passable. */
|
||||
public boolean passable;
|
||||
|
||||
public MisoTile (int tsid, int tid)
|
||||
{
|
||||
super(tsid, tid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// $Id: BaseTileSet.java,v 1.1 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.tile;
|
||||
|
||||
import com.threerings.media.tile.*;
|
||||
|
||||
/**
|
||||
* The miso tile set class extends the base tile set class to add
|
||||
* support for tile passability. Passability is used to determine
|
||||
* whether {@link com.threerings.miso.scene.Traverser} objects can
|
||||
* traverse a particular tile in a {@link
|
||||
* com.threerings.miso.scene.MisoScene}.
|
||||
*/
|
||||
public class MisoTileSet extends TileSet
|
||||
{
|
||||
public MisoTileSet ()
|
||||
{
|
||||
_model = new MisoTileSetModel();
|
||||
}
|
||||
|
||||
public Tile createTile (int tid)
|
||||
{
|
||||
MisoTile tile = new MisoTile(_model.tsid, tid);
|
||||
|
||||
// set the tile's passability, defaulting to passable if this
|
||||
// tileset has no passability specified
|
||||
int passable[] = ((MisoTileSetModel)_model).passable;
|
||||
tile.passable = (passable == null || (passable[tid] == 1));
|
||||
|
||||
return tile;
|
||||
}
|
||||
|
||||
protected static class MisoTileSetModel extends TileSetModel
|
||||
{
|
||||
/** Whether each tile is passable. */
|
||||
public int passable[];
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: EditableTileSetManager.java,v 1.10 2001/08/29 18:41:46 shaper Exp $
|
||||
// $Id: EditableTileSetManager.java,v 1.11 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.tile;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class EditableTileSetManager extends TileSetManagerImpl
|
||||
String fname = config.getValue(TILESETS_KEY, (String)null);
|
||||
ArrayList tilesets = null;
|
||||
try {
|
||||
tilesets = new XMLTileSetParser().loadTileSets(fname);
|
||||
tilesets = new XMLMisoTileSetParser().loadTileSets(fname);
|
||||
} catch (IOException ioe) {
|
||||
Log.warning("Exception loading tileset [fname=" + fname +
|
||||
", ioe=" + ioe + "].");
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// $Id: XMLMisoTileSetParser.java,v 1.1 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.tile;
|
||||
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.media.tile.*;
|
||||
|
||||
/**
|
||||
* Extends the base XML tile set parser to construct {@link
|
||||
* MisoTileSet} tilesets that provide additional functionality
|
||||
* specific to the miso layer.
|
||||
*/
|
||||
public class XMLMisoTileSetParser extends XMLTileSetParser
|
||||
{
|
||||
protected void finishElement (String qName, String str)
|
||||
{
|
||||
super.finishElement(qName, str);
|
||||
|
||||
if (qName.equals("passable")) {
|
||||
((MisoTileSet.MisoTileSetModel)_model).passable =
|
||||
StringUtil.parseIntArray(str);
|
||||
}
|
||||
}
|
||||
|
||||
protected TileSet createTileSet ()
|
||||
{
|
||||
return new MisoTileSet();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: XMLSceneParser.java,v 1.16 2001/09/21 02:30:35 mdb Exp $
|
||||
// $Id: XMLSceneParser.java,v 1.17 2001/10/08 21:04:25 shaper Exp $
|
||||
|
||||
package com.threerings.miso.scene.xml;
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.threerings.media.tile.*;
|
||||
|
||||
import com.threerings.miso.Log;
|
||||
import com.threerings.miso.scene.*;
|
||||
import com.threerings.miso.tile.MisoTile;
|
||||
|
||||
/**
|
||||
* Parse an XML scene description file and construct a scene object.
|
||||
@@ -103,7 +104,9 @@ public class XMLSceneParser extends DefaultHandler
|
||||
public void characters (char ch[], int start, int length)
|
||||
{
|
||||
// bail if we're not within a meaningful tag
|
||||
if (_tag == null) return;
|
||||
if (_tag == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
_chars.append(ch, start, length);
|
||||
}
|
||||
@@ -131,7 +134,7 @@ public class XMLSceneParser extends DefaultHandler
|
||||
|
||||
// create the tile objects in the tile array
|
||||
for (int xx = 0; xx < vals.length; xx += 2) {
|
||||
Tile tile = _tilemgr.getTile(vals[xx], vals[xx + 1]);
|
||||
MisoTile tile = (MisoTile)_tilemgr.getTile(vals[xx], vals[xx + 1]);
|
||||
info.tiles[xx / 2][info.rownum][info.lnum] = tile;
|
||||
}
|
||||
}
|
||||
@@ -162,7 +165,7 @@ public class XMLSceneParser extends DefaultHandler
|
||||
|
||||
// create the tile objects in the tile array
|
||||
for (int xx = 0; xx < vals.length; xx += 2) {
|
||||
Tile tile = _tilemgr.getTile(vals[xx], vals[xx + 1]);
|
||||
MisoTile tile = (MisoTile)_tilemgr.getTile(vals[xx], vals[xx + 1]);
|
||||
int xidx = info.colstart + (xx / 2);
|
||||
info.tiles[xidx][info.rownum][info.lnum] = tile;
|
||||
}
|
||||
@@ -234,7 +237,9 @@ public class XMLSceneParser extends DefaultHandler
|
||||
protected ArrayList toPortalList (ArrayList locs, String[] vals)
|
||||
{
|
||||
// make sure we have an appropriate number of values
|
||||
if ((vals.length % 2) != 0) return null;
|
||||
if ((vals.length % 2) != 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// read in all of the portals
|
||||
ArrayList portals = new ArrayList();
|
||||
@@ -342,7 +347,7 @@ public class XMLSceneParser extends DefaultHandler
|
||||
public ArrayList clusters;
|
||||
|
||||
/** The tile array. */
|
||||
public Tile[][][] tiles;
|
||||
public MisoTile[][][] tiles;
|
||||
|
||||
/** The current layer number being processed. */
|
||||
public int lnum;
|
||||
@@ -359,7 +364,7 @@ public class XMLSceneParser extends DefaultHandler
|
||||
public SceneInfo ()
|
||||
{
|
||||
int width = _model.scenewid, height = _model.scenehei;
|
||||
tiles = new Tile[width][height][MisoScene.NUM_LAYERS];
|
||||
tiles = new MisoTile[width][height][MisoScene.NUM_LAYERS];
|
||||
clusters = new ArrayList();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user