wyvern.kernel.maps
Interface Cell

All Known Implementing Classes:
MapCell

public interface Cell

This is the interface to the "buckets" used for storing objects at map locations. Regardless of the type of bucket used, the interface is the same. Clients of the map never manipulate Cell implementations directly.

Version:
1.0, Aug 15, 1997
Author:
Steve Yegge

Method Summary
 void add(GameObject obj)
          Adds the specified object to the end of this cell.
 boolean contains(GameObject obj)
          Tests to see if the specified object is a object in this cell.
 PropertyList getProperties()
          Returns the PropertyList for this cell.
 PropertyList getPropertyList()
          Creates a PropertyList for this Cell, if necessary, and returns it.
 Terrain getTerrain()
          Returns the Terrain set for this cell, if it has one.
 void insert(int index, GameObject obj)
          Inserts the specified object into this cell at the specified index.
 boolean isEmpty()
          Tests if this cell has no objects.
 java.util.Iterator iterator()
          Returns an Iterator over the objects in the cell.
 GameObject objectAt(int index)
          Returns the object at the specified index.
 java.util.List objects()
          Returns a List of the objects in the Cell.
 boolean remove(GameObject obj)
          Removes the specified object from the cell.
 GameObject remove(int index)
          Deletes the object at the specified index.
 void removeAll()
          Removes all objects from this cell.
 GameObject setObjectAt(int index, GameObject obj)
          Replaces the object at the specified index.
 void setTerrain(Terrain t)
          Sets the Terrain for this cell.
 int size()
          Returns the number of objects in this cell.
 

Method Detail

add

public void add(GameObject obj)
Adds the specified object to the end of this cell. If the object is groupable, and there is a matching object in the cell already, combines the object into the group.

Parameters:
obj - the object to be added

contains

public boolean contains(GameObject obj)
Tests to see if the specified object is a object in this cell.

Parameters:
obj - the object to search for
Returns:
true if the object is found in the cell

objectAt

public GameObject objectAt(int index)
Returns the object at the specified index.


objects

public java.util.List objects()
Returns a List of the objects in the Cell.


iterator

public java.util.Iterator iterator()
Returns an Iterator over the objects in the cell.


isEmpty

public boolean isEmpty()
Tests if this cell has no objects.


insert

public void insert(int index,
                   GameObject obj)
Inserts the specified object into this cell at the specified index.


removeAll

public void removeAll()
Removes all objects from this cell.


remove

public GameObject remove(int index)
Deletes the object at the specified index.


remove

public boolean remove(GameObject obj)
Removes the specified object from the cell.

Parameters:
obj - the object to remove. Does nothing if the obj isn't in the cell already.
Returns:
true if the list contained the object

setObjectAt

public GameObject setObjectAt(int index,
                              GameObject obj)
Replaces the object at the specified index.

Parameters:
index - the index to insert at
obj - the object to insert
Returns:
the object that was at that index, if any
Throws:
java.lang.IndexOutOfBoundsException - if specified index is out of range (i.e. index < 0 || index >= size());

size

public int size()
Returns the number of objects in this cell.


setTerrain

public void setTerrain(Terrain t)
Sets the Terrain for this cell. The Terrain reference is NOT kept in the object list for the cell - you have to call getTerrain() separately to get the Terrain.


getTerrain

public Terrain getTerrain()
Returns the Terrain set for this cell, if it has one. If not, the map should default to the default terrain, or some other dynamically-computed terrain.

Returns:
the Terrain that's been set in this cell via setTerrain()

getProperties

public PropertyList getProperties()
Returns the PropertyList for this cell. The PropertyList is, by definition, transient - the properties never get written out to the map file. It's strictly for use by runtime game-engine code.

Returns:
the PropertyList for this cell. Returns null if nobody has set any properties on the cell. If you want to set a property, call getPropertyList() instead.

getPropertyList

public PropertyList getPropertyList()
Creates a PropertyList for this Cell, if necessary, and returns it. You can set properties on the list directly, and then query the cell later to see if it has the property you're looking for.

Returns:
the PropertyList for this cell. Creates one if necessary.