From 15eca5d1630408bf25018dd620af46b05e5106fd Mon Sep 17 00:00:00 2001 From: Walter Korman Date: Fri, 12 Oct 2001 00:43:04 +0000 Subject: [PATCH] Made MisoTileSet an interface. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@449 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/miso/tile/BaseTileSet.java | 43 +------------- .../threerings/miso/tile/MisoTileSetImpl.java | 56 +++++++++++++++++++ .../tile/tools/xml/XMLMisoTileSetParser.java | 8 +-- 3 files changed, 63 insertions(+), 44 deletions(-) create mode 100644 src/java/com/threerings/miso/tile/MisoTileSetImpl.java diff --git a/src/java/com/threerings/miso/tile/BaseTileSet.java b/src/java/com/threerings/miso/tile/BaseTileSet.java index f308bdf70..ce757acfa 100644 --- a/src/java/com/threerings/miso/tile/BaseTileSet.java +++ b/src/java/com/threerings/miso/tile/BaseTileSet.java @@ -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 (); } diff --git a/src/java/com/threerings/miso/tile/MisoTileSetImpl.java b/src/java/com/threerings/miso/tile/MisoTileSetImpl.java new file mode 100644 index 000000000..27c7b3699 --- /dev/null +++ b/src/java/com/threerings/miso/tile/MisoTileSetImpl.java @@ -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; + } +} diff --git a/src/java/com/threerings/miso/tile/tools/xml/XMLMisoTileSetParser.java b/src/java/com/threerings/miso/tile/tools/xml/XMLMisoTileSetParser.java index 8a82ca1bc..f73a7856f 100644 --- a/src/java/com/threerings/miso/tile/tools/xml/XMLMisoTileSetParser.java +++ b/src/java/com/threerings/miso/tile/tools/xml/XMLMisoTileSetParser.java @@ -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(); } }