Removed the ShadowTile and replaced it with facilities in the BaseTile to
"cover" a tile with an object tile. While a tile is covered, it is impassable. This allows us to have base tiles under object tile footprints that are rendered, but not traversable by character sprites. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@944 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -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;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
@@ -17,7 +17,6 @@ import com.threerings.media.tile.TileManager;
|
|||||||
import com.threerings.miso.Log;
|
import com.threerings.miso.Log;
|
||||||
import com.threerings.miso.tile.BaseTile;
|
import com.threerings.miso.tile.BaseTile;
|
||||||
import com.threerings.miso.tile.BaseTileLayer;
|
import com.threerings.miso.tile.BaseTileLayer;
|
||||||
import com.threerings.miso.tile.ShadowTile;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default implementation of the {@link DisplayMisoScene} interface.
|
* The default implementation of the {@link DisplayMisoScene} interface.
|
||||||
@@ -165,11 +164,10 @@ public class DisplayMisoSceneImpl
|
|||||||
// spot in the object layer
|
// spot in the object layer
|
||||||
ObjectTile otile = (ObjectTile)_tmgr.getTile(tsid, tid);
|
ObjectTile otile = (ObjectTile)_tmgr.getTile(tsid, tid);
|
||||||
_object.setTile(col, row, otile);
|
_object.setTile(col, row, otile);
|
||||||
|
// generate a "shadow" for this object tile by toggling the
|
||||||
// we have to generate a shadow for this object tile in the
|
// "covered" flag on in all base tiles below it (to prevent
|
||||||
// base layer so that we can prevent sprites from walking on
|
// sprites from walking on those tiles)
|
||||||
// the object
|
setObjectTileFootprint(otile, col, row, true);
|
||||||
setObjectTileFootprint(otile, col, row, new ShadowTile(col, row));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,23 +211,27 @@ public class DisplayMisoSceneImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Place the given tile in the footprint of the object tile at the
|
* Sets the "covered" flag on all base tiles that are in the footprint
|
||||||
* given coordinates in the scene.
|
* of the specified object tile.
|
||||||
*
|
*
|
||||||
* @param otile the object tile whose footprint should be set.
|
* @param otile the object tile whose footprint should be set.
|
||||||
* @param x the tile x-coordinate.
|
* @param x the tile x-coordinate.
|
||||||
* @param y the tile y-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 (
|
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 endx = Math.max(0, (x - otile.getBaseWidth() + 1));
|
||||||
int endy = Math.max(0, (y - otile.getBaseHeight() + 1));
|
int endy = Math.max(0, (y - otile.getBaseHeight() + 1));
|
||||||
|
|
||||||
for (int xx = x; xx >= endx; xx--) {
|
for (int xx = x; xx >= endx; xx--) {
|
||||||
for (int yy = y; yy >= endy; yy--) {
|
for (int yy = y; yy >= endy; yy--) {
|
||||||
_base.setTile(xx, yy, stamp);
|
BaseTile tile = _base.getTile(xx, yy);
|
||||||
|
if (tile != null) {
|
||||||
|
tile.setCovered(covered);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
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.AStarPathUtil;
|
||||||
import com.threerings.miso.scene.util.IsoUtil;
|
import com.threerings.miso.scene.util.IsoUtil;
|
||||||
import com.threerings.miso.tile.BaseTileLayer;
|
import com.threerings.miso.tile.BaseTileLayer;
|
||||||
import com.threerings.miso.tile.ShadowTile;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The iso scene view provides an isometric view of a particular
|
* 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
|
// clear all dirty lists and tile array
|
||||||
clearDirtyRegions();
|
clearDirtyRegions();
|
||||||
|
|
||||||
// generate all object shadow tiles and polygons
|
// generate all object tile polygons
|
||||||
initAllObjectBounds();
|
initAllObjectBounds();
|
||||||
|
|
||||||
// invalidate the entire screen as there's a new scene in town
|
// invalidate the entire screen as there's a new scene in town
|
||||||
|
|||||||
@@ -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;
|
package com.threerings.miso.tile;
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ public class BaseTile extends Tile
|
|||||||
*/
|
*/
|
||||||
public boolean isPassable ()
|
public boolean isPassable ()
|
||||||
{
|
{
|
||||||
return _passable;
|
return _passable && !_covered;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,6 +49,19 @@ public class BaseTile extends Tile
|
|||||||
_passable = passable;
|
_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. */
|
/** Whether the tile is passable. */
|
||||||
protected boolean _passable = true;
|
protected boolean _passable = true;
|
||||||
|
|
||||||
|
/** Whether the tile is covered by an object tile. */
|
||||||
|
protected boolean _covered = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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;
|
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.media.tile.TileManager;
|
||||||
|
|
||||||
import com.threerings.miso.tile.BaseTile;
|
import com.threerings.miso.tile.BaseTile;
|
||||||
import com.threerings.miso.tile.ShadowTile;
|
|
||||||
|
|
||||||
import com.threerings.miso.scene.DisplayMisoSceneImpl;
|
import com.threerings.miso.scene.DisplayMisoSceneImpl;
|
||||||
import com.threerings.miso.scene.MisoSceneModel;
|
import com.threerings.miso.scene.MisoSceneModel;
|
||||||
@@ -93,20 +92,18 @@ public class EditableMisoSceneImpl
|
|||||||
public void setObjectTile (int x, int y, ObjectTile tile, int fqTileId)
|
public void setObjectTile (int x, int y, ObjectTile tile, int fqTileId)
|
||||||
{
|
{
|
||||||
ObjectTile prev = _object.getTile(x, y);
|
ObjectTile prev = _object.getTile(x, y);
|
||||||
// clear out any previous tile so that shadow tiles are properly
|
// clear out any previous tile to ensure that everything is
|
||||||
// removed
|
// properly cleaned up
|
||||||
if (prev != null) {
|
if (prev != null) {
|
||||||
clearObjectTile(x, y);
|
clearObjectTile(x, y);
|
||||||
}
|
}
|
||||||
|
// stick the new object into the layer
|
||||||
_object.setTile(x, y, tile);
|
_object.setTile(x, y, tile);
|
||||||
// set the footprint in the base layer
|
// toggle the "covered" flag on in all base tiles below this
|
||||||
setObjectTileFootprint(tile, x, y, new ShadowTile(x, y));
|
// object tile
|
||||||
|
setObjectTileFootprint(tile, x, y, true);
|
||||||
// stick this value into our non-sparse object layer
|
// stick this value into our non-sparse object layer
|
||||||
_objectTileIds[_model.width*y + x] = fqTileId;
|
_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
|
// documentation inherited from interface
|
||||||
@@ -136,8 +133,9 @@ public class EditableMisoSceneImpl
|
|||||||
{
|
{
|
||||||
ObjectTile tile = _object.getTile(x, y);
|
ObjectTile tile = _object.getTile(x, y);
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
// clear the footprint in the base layer
|
// toggle the "covered" flag off on the base tiles in this
|
||||||
setObjectTileFootprint(tile, x, y, _defaultBaseTile);
|
// object tile's footprint
|
||||||
|
setObjectTileFootprint(tile, x, y, false);
|
||||||
// clear out the tile itself
|
// clear out the tile itself
|
||||||
_object.setTile(x, y, null);
|
_object.setTile(x, y, null);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user