Made MisoTileSet an interface.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@449 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2001-10-12 00:43:04 +00:00
parent 6638380a4d
commit 15eca5d163
3 changed files with 63 additions and 44 deletions
@@ -1,46 +1,9 @@
//
// $Id: BaseTileSet.java,v 1.2 2001/10/11 00:41:27 shaper Exp $
// $Id: BaseTileSet.java,v 1.3 2001/10/12 00:43:04 shaper Exp $
package com.threerings.miso.tile;
import com.threerings.media.tile.*;
import com.threerings.miso.scene.MisoScene;
/**
* 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 TileSetImpl
public interface MisoTileSet
{
/** The miso scene layer the tiles are intended for. */
public int layer;
/** Whether each tile is passable. */
public int passable[];
public Tile createTile (int tid)
{
// only create miso tiles for the base layer
if (layer != MisoScene.LAYER_BASE) {
return super.createTile(tid);
}
return new MisoTile(tsid, tid);
}
protected void populateTile (Tile tile)
{
super.populateTile(tile);
if (tile instanceof MisoTile) {
// set the tile's passability, defaulting to passable if this
// tileset has no passability specified
((MisoTile)tile).passable =
(passable == null || (passable[tile.tid] == 1));
}
}
public int getLayerIndex ();
}
@@ -0,0 +1,56 @@
//
// $Id: MisoTileSetImpl.java,v 1.1 2001/10/12 00:43:04 shaper Exp $
package com.threerings.miso.tile;
import com.threerings.media.tile.*;
import com.threerings.miso.scene.MisoScene;
/**
* 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 MisoTileSetImpl
extends TileSetImpl
implements MisoTileSet
{
/** The miso scene layer the tiles are intended for. */
public int layer;
/** Whether each tile is passable. */
public int passable[];
// documentation inherited
public Tile createTile (int tid)
{
// only create miso tiles for the base layer
if (layer != MisoScene.LAYER_BASE) {
return super.createTile(tid);
}
return new MisoTile(tsid, tid);
}
// documentation inherited
protected void populateTile (Tile tile)
{
super.populateTile(tile);
if (tile instanceof MisoTile) {
// set the tile's passability, defaulting to passable if this
// tileset has no passability specified
((MisoTile)tile).passable =
(passable == null || (passable[tile.tid] == 1));
}
}
// documentation inherited
public int getLayerIndex ()
{
return layer;
}
}
@@ -1,5 +1,5 @@
//
// $Id: XMLMisoTileSetParser.java,v 1.2 2001/10/11 00:41:27 shaper Exp $
// $Id: XMLMisoTileSetParser.java,v 1.3 2001/10/12 00:43:04 shaper Exp $
package com.threerings.miso.tile;
@@ -24,7 +24,7 @@ public class XMLMisoTileSetParser extends XMLTileSetParser
if (qName.equals("tileset")) {
String val = attributes.getValue("layer");
((MisoTileSet)_tset).layer = MisoSceneUtil.getLayerIndex(val);
((MisoTileSetImpl)_tset).layer = MisoSceneUtil.getLayerIndex(val);
}
}
@@ -34,13 +34,13 @@ public class XMLMisoTileSetParser extends XMLTileSetParser
super.finishElement(qName, str);
if (qName.equals("passable")) {
((MisoTileSet)_tset).passable = StringUtil.parseIntArray(str);
((MisoTileSetImpl)_tset).passable = StringUtil.parseIntArray(str);
}
}
// documentation inherited
protected TileSetImpl createTileSet ()
{
return new MisoTileSet();
return new MisoTileSetImpl();
}
}