diff --git a/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java b/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java index 489a57e67..ed1daade0 100644 --- a/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java +++ b/src/java/com/threerings/miso/client/DisplayMisoSceneImpl.java @@ -1,5 +1,5 @@ // -// $Id: DisplayMisoSceneImpl.java,v 1.49 2002/01/30 18:28:32 mdb Exp $ +// $Id: DisplayMisoSceneImpl.java,v 1.50 2002/02/06 17:13:06 mdb Exp $ package com.threerings.miso.scene; @@ -17,7 +17,6 @@ import com.threerings.media.tile.TileManager; import com.threerings.miso.Log; import com.threerings.miso.tile.BaseTile; import com.threerings.miso.tile.BaseTileLayer; -import com.threerings.miso.tile.ShadowTile; /** * The default implementation of the {@link DisplayMisoScene} interface. @@ -165,11 +164,10 @@ public class DisplayMisoSceneImpl // spot in the object layer ObjectTile otile = (ObjectTile)_tmgr.getTile(tsid, tid); _object.setTile(col, row, otile); - - // we have to generate a shadow for this object tile in the - // base layer so that we can prevent sprites from walking on - // the object - setObjectTileFootprint(otile, col, row, new ShadowTile(col, row)); + // generate a "shadow" for this object tile by toggling the + // "covered" flag on in all base tiles below it (to prevent + // sprites from walking on those tiles) + setObjectTileFootprint(otile, col, row, true); } } @@ -213,23 +211,27 @@ public class DisplayMisoSceneImpl } /** - * Place the given tile in the footprint of the object tile at the - * given coordinates in the scene. + * Sets the "covered" flag on all base tiles that are in the footprint + * of the specified object tile. * * @param otile the object tile whose footprint should be set. * @param x the tile x-coordinate. * @param y the tile y-coordinate. - * @param stamp the tile to place in the object footprint. + * @param covered whether or not the footprint is being covered or + * uncovered. */ protected void setObjectTileFootprint ( - ObjectTile otile, int x, int y, BaseTile stamp) + ObjectTile otile, int x, int y, boolean covered) { int endx = Math.max(0, (x - otile.getBaseWidth() + 1)); int endy = Math.max(0, (y - otile.getBaseHeight() + 1)); for (int xx = x; xx >= endx; xx--) { for (int yy = y; yy >= endy; yy--) { - _base.setTile(xx, yy, stamp); + BaseTile tile = _base.getTile(xx, yy); + if (tile != null) { + tile.setCovered(covered); + } } } diff --git a/src/java/com/threerings/miso/client/IsoSceneView.java b/src/java/com/threerings/miso/client/IsoSceneView.java index ecb3161b1..b7d5e8530 100644 --- a/src/java/com/threerings/miso/client/IsoSceneView.java +++ b/src/java/com/threerings/miso/client/IsoSceneView.java @@ -1,5 +1,5 @@ // -// $Id: IsoSceneView.java,v 1.89 2002/01/31 17:43:57 shaper Exp $ +// $Id: IsoSceneView.java,v 1.90 2002/02/06 17:13:06 mdb Exp $ package com.threerings.miso.scene; @@ -37,7 +37,6 @@ import com.threerings.miso.scene.DirtyItemList.DirtyItem; import com.threerings.miso.scene.util.AStarPathUtil; import com.threerings.miso.scene.util.IsoUtil; import com.threerings.miso.tile.BaseTileLayer; -import com.threerings.miso.tile.ShadowTile; /** * The iso scene view provides an isometric view of a particular @@ -124,7 +123,7 @@ public class IsoSceneView implements SceneView // clear all dirty lists and tile array clearDirtyRegions(); - // generate all object shadow tiles and polygons + // generate all object tile polygons initAllObjectBounds(); // invalidate the entire screen as there's a new scene in town diff --git a/src/java/com/threerings/miso/tile/BaseTile.java b/src/java/com/threerings/miso/tile/BaseTile.java index 7b438ddf0..df9aa65d4 100644 --- a/src/java/com/threerings/miso/tile/BaseTile.java +++ b/src/java/com/threerings/miso/tile/BaseTile.java @@ -1,5 +1,5 @@ // -// $Id: BaseTile.java,v 1.3 2001/11/27 22:17:42 mdb Exp $ +// $Id: BaseTile.java,v 1.4 2002/02/06 17:13:06 mdb Exp $ package com.threerings.miso.tile; @@ -37,7 +37,7 @@ public class BaseTile extends Tile */ public boolean isPassable () { - return _passable; + return _passable && !_covered; } /** @@ -49,6 +49,19 @@ public class BaseTile extends Tile _passable = passable; } + /** + * Sets whether this tile is currently covered by the footprint of an + * object tile or not. When it is covered, it can't be walked on by + * character sprites. + */ + public void setCovered (boolean covered) + { + _covered = covered; + } + /** Whether the tile is passable. */ protected boolean _passable = true; + + /** Whether the tile is covered by an object tile. */ + protected boolean _covered = true; } diff --git a/src/java/com/threerings/miso/tile/ShadowTile.java b/src/java/com/threerings/miso/tile/ShadowTile.java deleted file mode 100644 index b5780e22a..000000000 --- a/src/java/com/threerings/miso/tile/ShadowTile.java +++ /dev/null @@ -1,39 +0,0 @@ -// -// $Id: ShadowTile.java,v 1.4 2001/11/27 22:17:42 mdb Exp $ - -package com.threerings.miso.tile; - -import java.awt.Graphics2D; -import java.awt.Shape; - -/** - * The shadow tile extends base tile to provide an always-impassable tile - * that has no display image. Shadow tiles are intended for placement in - * the footprint of {@link com.threerings.media.tile.ObjectTile} objects. - */ -public class ShadowTile extends BaseTile -{ - /** The scene coordinates of the shadow tile's parent object tile. */ - public int ox, oy; - - /** - * Constructs a shadow tile. - */ - public ShadowTile (int x, int y) - { - super(null); - - // save the coordinates of our parent object tile - ox = x; - oy = y; - - // shadow tiles are always impassable - _passable = false; - } - - // documentation inherited - public void paint (Graphics2D gfx, Shape dest) - { - // paint nothing as we're naught but a measly shadow of a tile - } -} diff --git a/src/java/com/threerings/miso/tools/EditableMisoSceneImpl.java b/src/java/com/threerings/miso/tools/EditableMisoSceneImpl.java index 0eda7f143..cb82a92af 100644 --- a/src/java/com/threerings/miso/tools/EditableMisoSceneImpl.java +++ b/src/java/com/threerings/miso/tools/EditableMisoSceneImpl.java @@ -1,5 +1,5 @@ // -// $Id: EditableMisoSceneImpl.java,v 1.8 2002/02/02 01:09:53 mdb Exp $ +// $Id: EditableMisoSceneImpl.java,v 1.9 2002/02/06 17:13:06 mdb Exp $ package com.threerings.miso.scene.tools; @@ -10,7 +10,6 @@ import com.threerings.media.tile.Tile; import com.threerings.media.tile.TileManager; import com.threerings.miso.tile.BaseTile; -import com.threerings.miso.tile.ShadowTile; import com.threerings.miso.scene.DisplayMisoSceneImpl; import com.threerings.miso.scene.MisoSceneModel; @@ -93,20 +92,18 @@ public class EditableMisoSceneImpl public void setObjectTile (int x, int y, ObjectTile tile, int fqTileId) { ObjectTile prev = _object.getTile(x, y); - // clear out any previous tile so that shadow tiles are properly - // removed + // clear out any previous tile to ensure that everything is + // properly cleaned up if (prev != null) { clearObjectTile(x, y); } + // stick the new object into the layer _object.setTile(x, y, tile); - // set the footprint in the base layer - setObjectTileFootprint(tile, x, y, new ShadowTile(x, y)); + // toggle the "covered" flag on in all base tiles below this + // object tile + setObjectTileFootprint(tile, x, y, true); // stick this value into our non-sparse object layer _objectTileIds[_model.width*y + x] = fqTileId; - // we don't have to worry about setting the footprint in the model - // because footprints are always inferred from the contents of the - // object layer and the base layer in the model can simply contain - // the default tiles } // documentation inherited from interface @@ -136,8 +133,9 @@ public class EditableMisoSceneImpl { ObjectTile tile = _object.getTile(x, y); if (tile != null) { - // clear the footprint in the base layer - setObjectTileFootprint(tile, x, y, _defaultBaseTile); + // toggle the "covered" flag off on the base tiles in this + // object tile's footprint + setObjectTileFootprint(tile, x, y, false); // clear out the tile itself _object.setTile(x, y, null); }