com.threerings.miso.data
Class MisoSceneModel

java.lang.Object
  extended by com.threerings.io.SimpleStreamableObject
      extended by com.threerings.miso.data.MisoSceneModel
All Implemented Interfaces:
com.threerings.io.Streamable, Cloneable
Direct Known Subclasses:
SimpleMisoSceneModel, SparseMisoSceneModel, VirtualMisoSceneModel

public abstract class MisoSceneModel
extends com.threerings.io.SimpleStreamableObject
implements Cloneable

Contains basic information for a miso scene model that is shared among the specialized model implementations.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.threerings.io.Streamable
com.threerings.io.Streamable.Closure
 
Constructor Summary
MisoSceneModel()
          Creates a completely uninitialized model suitable for little more than unserialization.
 
Method Summary
abstract  boolean addObject(ObjectInfo info)
          Adds an object to this scene.
 MisoSceneModel clone()
           
abstract  int getBaseTileId(int x, int y)
          Returns the fully qualified tile id of the base tile at the specified coordinates.
 int getDefaultBaseTileSet()
          Scene models can return a default tileset to be used when no base tile data exists for a particular tile.
abstract  void getObjects(Rectangle region, ObjectSet set)
          Populates the supplied object set with info on all objects whose origin falls in the requested region.
abstract  boolean removeObject(ObjectInfo info)
          Removes the specified object from the scene.
abstract  boolean setBaseTile(int fqTileId, int x, int y)
          Updates the tile at the specified location in the base layer.
 void setDefaultBaseTileSet(int tileSetId)
          Updates the default base tileset id for this scene.
abstract  void updateObject(ObjectInfo info)
          Updates an object in this scene.
 
Methods inherited from class com.threerings.io.SimpleStreamableObject
toString, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MisoSceneModel

public MisoSceneModel()
Creates a completely uninitialized model suitable for little more than unserialization.

Method Detail

getBaseTileId

public abstract int getBaseTileId(int x,
                                  int y)
Returns the fully qualified tile id of the base tile at the specified coordinates. -1 will be returned if there is no tile at the specified coordinate.


setBaseTile

public abstract boolean setBaseTile(int fqTileId,
                                    int x,
                                    int y)
Updates the tile at the specified location in the base layer.

Note that if there are fringe tiles associated with this scene, calling this method may result in the surrounding fringe tiles being cleared and subsequently recalculated. This should not be called on a displaying scene unless you know what you are doing.

Parameters:
fqTileId - the fully-qualified tile id (@see TileUtil#getFQTileId}) of the tile to set.
x - the x-coordinate of the tile to set.
y - the y-coordinate of the tile to set.
Returns:
false if the specified tile coordinates are outside of the scene and the tile was not saved, true otherwise.

setDefaultBaseTileSet

public void setDefaultBaseTileSet(int tileSetId)
Updates the default base tileset id for this scene.


getDefaultBaseTileSet

public int getDefaultBaseTileSet()
Scene models can return a default tileset to be used when no base tile data exists for a particular tile.


getObjects

public abstract void getObjects(Rectangle region,
                                ObjectSet set)
Populates the supplied object set with info on all objects whose origin falls in the requested region.


addObject

public abstract boolean addObject(ObjectInfo info)
Adds an object to this scene.

Returns:
true if the object was added, false if the add was rejected due to being a duplicate.

updateObject

public abstract void updateObject(ObjectInfo info)
Updates an object in this scene.


removeObject

public abstract boolean removeObject(ObjectInfo info)
Removes the specified object from the scene.

Returns:
true if it was removed, false if the object was not in the scene.

clone

public MisoSceneModel clone()
Overrides:
clone in class Object