rle.core.board
Class Board

java.lang.Object
  extended by rle.core.vm.PlugInBase
      extended by rle.core.board.Board
All Implemented Interfaces:
PlugIn

public class Board
extends PlugInBase

A Board's sole function is to track the location of the various Thing's in the player's environment. Listeners may register to receive notification when Things change locations via the addBoardListener() method.


Field Summary
protected  RLRectangle bounds
          We store the bounds instead of just the size because RLRectangle has some useful methods, especially contains().
protected  java.util.HashSet<Creature> creatures
           
protected  java.util.HashSet<Item> items
           
protected  int level
           
protected  java.util.TreeSet<Thing>[][] stuff
           
protected  java.util.Comparator stuffComparator
          The comparator used to sort Things stored at individual locations on the Board.
protected  java.util.HashSet<Terrain> terrains
           
protected  java.util.HashSet<Thing> things
           
 
Fields inherited from class rle.core.vm.PlugInBase
config, context, parameters
 
Constructor Summary
Board()
           
 
Method Summary
 void addBoardListener(BoardListener listener)
          Add a BoardListener that will be notified of all property changes
 boolean contains(RLPoint p)
          Return whether a RLPoint is contained in this Board.
 Creature creature(RLPoint p)
          Return the creature at p, if any.
 java.util.Set<Creature> creatures()
          Retrieve the creatures in this Board.
 int getHeight()
          The height of this Board.
 int getLevel()
           
 int getWidth()
          The width of this Board.
 Inventory inventory(RLPoint p)
          Return an Inventory representing the items at p.
 boolean isDay()
           
 Item item(RLPoint p)
           
 java.util.Set<Item> items()
          Retrieve the items in this Board.
 java.util.Set<Item> items(Locator l)
           
 java.util.Set<Item> items(RLPoint p)
           
 void place(Thing t, Locator l)
          Associate Thing t with Locator l.
 void place(Thing t, RLPoint p)
          Convenience method to place a thing without explicitly creating a locator.
 void remove(Thing t)
          Remove.
 void removeBoardListener(BoardListener listener)
          Remove a BoardListener that was to be notified of all property changes
 void setBounds(RLRectangle r)
          Change the dimensions of this Board.
 void setConfig(InfoView view)
          Overridden to allocate structures based on board height and width from the VariantMgr.
 void setDay(boolean b)
           
 void setLevel(int level)
           
 Terrain terrain(RLPoint p)
          Return the terrain at p, if any.
 java.util.Set<Terrain> terrains()
          Retrieve the terrains in this Board.
 java.util.List<Terrain> terrains(Locator loc)
          Return the terrains intersecting a Locator.
 java.util.Set<Thing> things()
          All Thing's on the board.
 java.util.TreeSet<Thing> things(Locator loc)
          Return the things intersecting a Locator.
 java.util.TreeSet<Thing> things(RLPoint p)
          Return the Things intersecting a particular point.
 
Methods inherited from class rle.core.vm.PlugInBase
config, getContext, getParameters, paramMap, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bounds

protected RLRectangle bounds
We store the bounds instead of just the size because RLRectangle has some useful methods, especially contains().


level

protected int level

stuff

protected java.util.TreeSet<Thing>[][] stuff

things

protected java.util.HashSet<Thing> things

items

protected java.util.HashSet<Item> items

creatures

protected java.util.HashSet<Creature> creatures

terrains

protected java.util.HashSet<Terrain> terrains

stuffComparator

protected java.util.Comparator stuffComparator
The comparator used to sort Things stored at individual locations on the Board.

Constructor Detail

Board

public Board()
Method Detail

getLevel

public int getLevel()

setLevel

public void setLevel(int level)

getWidth

public int getWidth()
The width of this Board.

Returns:

getHeight

public int getHeight()
The height of this Board.

Returns:

contains

public boolean contains(RLPoint p)
Return whether a RLPoint is contained in this Board.


setConfig

public void setConfig(InfoView view)
Overridden to allocate structures based on board height and width from the VariantMgr.

Specified by:
setConfig in interface PlugIn
Overrides:
setConfig in class PlugInBase

setBounds

public void setBounds(RLRectangle r)
Change the dimensions of this Board. All existing Things will be lost.


things

public java.util.Set<Thing> things()
All Thing's on the board.


items

public java.util.Set<Item> items()
Retrieve the items in this Board.


creatures

public java.util.Set<Creature> creatures()
Retrieve the creatures in this Board.


terrains

public java.util.Set<Terrain> terrains()
Retrieve the terrains in this Board.


remove

public void remove(Thing t)
Remove.


place

public void place(Thing t,
                  RLPoint p)
Convenience method to place a thing without explicitly creating a locator. Calling this method is the same as place(t,new Locator(this,p,t.getSize()));


isDay

public boolean isDay()

setDay

public void setDay(boolean b)

place

public void place(Thing t,
                  Locator l)
Associate Thing t with Locator l.


creature

public Creature creature(RLPoint p)
Return the creature at p, if any.


item

public Item item(RLPoint p)

items

public java.util.Set<Item> items(Locator l)

items

public java.util.Set<Item> items(RLPoint p)

inventory

public Inventory inventory(RLPoint p)
Return an Inventory representing the items at p.


terrain

public Terrain terrain(RLPoint p)
Return the terrain at p, if any.


terrains

public java.util.List<Terrain> terrains(Locator loc)
Return the terrains intersecting a Locator.


things

public java.util.TreeSet<Thing> things(RLPoint p)
Return the Things intersecting a particular point.


things

public java.util.TreeSet<Thing> things(Locator loc)
Return the things intersecting a Locator.


addBoardListener

public void addBoardListener(BoardListener listener)
Add a BoardListener that will be notified of all property changes

Parameters:
listener -

removeBoardListener

public void removeBoardListener(BoardListener listener)
Remove a BoardListener that was to be notified of all property changes

Parameters:
listener -