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:
Walter Korman
2001-10-08 21:04:26 +00:00
parent d7fb56d203
commit 95ba5ef9cf
14 changed files with 293 additions and 213 deletions
@@ -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();
}
}