wyvern.kernel.maps
Class MapCell

java.lang.Object
  extended bywyvern.kernel.maps.MapCell
All Implemented Interfaces:
Cell

public final class MapCell
extends java.lang.Object
implements Cell

This class implements a Cell using a linked list.

Version:
1.0, Nov 22, 1997
Author:
Steve Yegge

Constructor Summary
MapCell()
           
 
Method Summary
 void add(GameObject obj)
          Adds the specified object to the end of this cell.
protected  void addGroupable(GameObject item)
          Adds a groupable item to the bag.
 boolean contains(GameObject obj)
          Tests to see if the specified object is a object in this cell.
 java.util.List getItems()
           
 java.util.List getItemsNonNull()
           
 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.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MapCell

public MapCell()
Method Detail

add

public void add(GameObject obj)
Description copied from interface: Cell
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.

Specified by:
add in interface Cell
Parameters:
obj - the object to be added

contains

public boolean contains(GameObject obj)
Description copied from interface: Cell
Tests to see if the specified object is a object in this cell.

Specified by:
contains in interface Cell
Parameters:
obj - the object to search for
Returns:
true if the object is found in the cell

objectAt

public GameObject objectAt(int index)
Description copied from interface: Cell
Returns the object at the specified index.

Specified by:
objectAt in interface Cell

iterator

public java.util.Iterator iterator()
Description copied from interface: Cell
Returns an Iterator over the objects in the cell.

Specified by:
iterator in interface Cell

objects

public java.util.List objects()
Description copied from interface: Cell
Returns a List of the objects in the Cell.

Specified by:
objects in interface Cell

isEmpty

public boolean isEmpty()
Description copied from interface: Cell
Tests if this cell has no objects.

Specified by:
isEmpty in interface Cell

insert

public void insert(int index,
                   GameObject obj)
Description copied from interface: Cell
Inserts the specified object into this cell at the specified index.

Specified by:
insert in interface Cell

removeAll

public void removeAll()
Description copied from interface: Cell
Removes all objects from this cell.

Specified by:
removeAll in interface Cell

remove

public GameObject remove(int index)
Description copied from interface: Cell
Deletes the object at the specified index.

Specified by:
remove in interface Cell

remove

public boolean remove(GameObject obj)
Description copied from interface: Cell
Removes the specified object from the cell.

Specified by:
remove in interface 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)
Description copied from interface: Cell
Replaces the object at the specified index.

Specified by:
setObjectAt in interface Cell
Parameters:
index - the index to insert at
obj - the object to insert
Returns:
the object that was at that index, if any

size

public int size()
Description copied from interface: Cell
Returns the number of objects in this cell.

Specified by:
size in interface Cell

toString

public java.lang.String toString()

addGroupable

protected void addGroupable(GameObject item)
Adds a groupable item to the bag. Checks to see if another item of that type is in the bag, and if so, groups them. If not, it simply adds the item to the bag.

Parameters:
item - the groupable item. Someone must have already ascertained that the item has the "groupable" property, since we don't check here.

getItemsNonNull

public java.util.List getItemsNonNull()

getItems

public java.util.List getItems()

setTerrain

public void setTerrain(Terrain t)
Description copied from interface: Cell
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.

Specified by:
setTerrain in interface Cell

getTerrain

public Terrain getTerrain()
Description copied from interface: Cell
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.

Specified by:
getTerrain in interface Cell
Returns:
the Terrain that's been set in this cell via setTerrain()

getProperties

public PropertyList getProperties()
Description copied from interface: Cell
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.

Specified by:
getProperties in interface Cell
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()
Description copied from interface: Cell
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.

Specified by:
getPropertyList in interface Cell
Returns:
the PropertyList for this cell. Creates one if necessary.