FIFE::Layer Class Reference

#include <layer.h>

Inheritance diagram for FIFE::Layer:
Inheritance graph
[legend]
Collaboration diagram for FIFE::Layer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Layer (const std::string &identifier, Map *map, CellGrid *grid)
 ~Layer ()
const std::string & getId () const
void setId (const std::string &id)
MapgetMap () const
CellGrid * getCellGrid () const
void setCellGrid (CellGrid *grid)
InstanceTree * getInstanceTree (void) const
bool hasInstances () const
InstancecreateInstance (Object *object, const ModelCoordinate &p, const std::string &id="")
InstancecreateInstance (Object *object, const ExactModelCoordinate &p, const std::string &id="")
bool addInstance (Instance *instance, const ExactModelCoordinate &p)
void deleteInstance (Instance *object)
const std::vector< Instance * > & getInstances () const
std::vector< Instance * > getInstances (const std::string &id)
std::vector< Instance * > getInstancesAt (Location &loc, bool use_exactcoordinates=false)
InstancegetInstance (const std::string &identifier)
void setInstancesVisible (bool vis)
void setLayerTransparency (uint8_t transparency)
uint8_t getLayerTransparency ()
void getMinMaxCoordinates (ModelCoordinate &min, ModelCoordinate &max, const Layer *layer=0) const
bool cellContainsBlockingInstance (const ModelCoordinate &cellCoordinate)
void toggleInstancesVisible ()
bool areInstancesVisible () const
bool update ()
void setPathingStrategy (PathingStrategy strategy)
PathingStrategy getPathingStrategy () const
void addChangeListener (LayerChangeListener *listener)
void removeChangeListener (LayerChangeListener *listener)
bool isChanged ()
std::vector< Instance * > & getChangedInstances ()

Detailed Description

A basic layer on a map

Definition at line 92 of file layer.h.


Constructor & Destructor Documentation

FIFE::Layer::Layer ( const std::string &  identifier,
Map map,
CellGrid *  grid 
)

Constructor Layers are created by calling addLayer from map, thus this method should really be called only by map or test code

Definition at line 43 of file layer.cpp.

FIFE::Layer::~Layer (  ) 

Destructs a Layer instance

Definition at line 56 of file layer.cpp.


Member Function Documentation

void FIFE::Layer::addChangeListener ( LayerChangeListener listener  ) 

Adds new change listener

Parameters:
listener to add

Definition at line 256 of file layer.cpp.

bool FIFE::Layer::addInstance ( Instance instance,
const ExactModelCoordinate p 
)

Add a valid instance at a specific position. This is temporary. It will be moved to a higher level later so that we can ensure that each Instance only lives in one layer.

Definition at line 88 of file layer.cpp.

bool FIFE::Layer::areInstancesVisible (  )  const [inline]

Check object visibility

See also:
setObjectsVisible

Definition at line 205 of file layer.h.

bool FIFE::Layer::cellContainsBlockingInstance ( const ModelCoordinate cellCoordinate  ) 

Determines if a given cell on the layer contains a blocking instance

Parameters:
cellCoordinate A const reference to a model coordinate of the cell in question.
Returns:
A boolean, true if it is blocked false otherwise.

Definition at line 221 of file layer.cpp.

Instance* FIFE::Layer::createInstance ( Object object,
const ExactModelCoordinate p,
const std::string &  id = "" 
)

Add an instance of an object at a specific position

Instance * FIFE::Layer::createInstance ( Object object,
const ModelCoordinate p,
const std::string &  id = "" 
)

Add an instance of an object at a specific position

Definition at line 65 of file layer.cpp.

void FIFE::Layer::deleteInstance ( Instance object  ) 

Remove an instance from the layer

Definition at line 110 of file layer.cpp.

CellGrid* FIFE::Layer::getCellGrid (  )  const [inline]

Get the Cellgrid

Returns:
a valid cellgrid

Definition at line 119 of file layer.h.

std::vector<Instance*>& FIFE::Layer::getChangedInstances (  )  [inline]

Returns instances that were changed during previous update round.

Note:
does not contain created or deleted instances

Definition at line 239 of file layer.h.

const std::string& FIFE::Layer::getId (  )  const [inline]

Get the id of this layer.

Definition at line 106 of file layer.h.

Instance * FIFE::Layer::getInstance ( const std::string &  identifier  ) 

Get the first instance on this layer with the given identifier.

Definition at line 129 of file layer.cpp.

std::vector< Instance * > FIFE::Layer::getInstances ( const std::string &  id  ) 

Get the list of instances on this layer with the given identifier.

Definition at line 139 of file layer.cpp.

const std::vector<Instance*>& FIFE::Layer::getInstances (  )  const [inline]

Get the list of instances on this layer

Definition at line 154 of file layer.h.

std::vector< Instance * > FIFE::Layer::getInstancesAt ( Location &  loc,
bool  use_exactcoordinates = false 
)

Returns instances that match given location.

Parameters:
loc location where to fetch instances from
use_exactcoordinates if true, comparison is done using exact coordinates. if not, cell coordinates are used

Definition at line 149 of file layer.cpp.

InstanceTree* FIFE::Layer::getInstanceTree ( void   )  const [inline]

Get the instance tree.

Returns:
this layers instance tree.

Definition at line 128 of file layer.h.

uint8_t FIFE::Layer::getLayerTransparency (  ) 

Returns the layer's transparency value

Definition at line 213 of file layer.cpp.

Map* FIFE::Layer::getMap (  )  const [inline]

Get the map this layer is contained in

Definition at line 114 of file layer.h.

void FIFE::Layer::getMinMaxCoordinates ( ModelCoordinate min,
ModelCoordinate max,
const Layer layer = 0 
) const

Retrieves the minimum/maximum coordinates of instances on the layer.

Parameters:
min A reference to a ModelCoordinate that will hold the minimum coordinate.
max A reference to a ModelCoordinate that will hold the maximum coordinate.
layer A pointer to another layer that can be used to cast coordinates bettween layers.

Definition at line 168 of file layer.cpp.

PathingStrategy FIFE::Layer::getPathingStrategy (  )  const [inline]

Gets pathing strategy for the layer

See also:
PathingStrategy

Definition at line 220 of file layer.h.

bool FIFE::Layer::hasInstances (  )  const

Check existance of objects on this layer

Returns:
True, if objects exist.

Definition at line 61 of file layer.cpp.

bool FIFE::Layer::isChanged (  )  [inline]

Returns true, if layer information was changed during previous update round

Definition at line 234 of file layer.h.

void FIFE::Layer::removeChangeListener ( LayerChangeListener listener  ) 

Removes associated change listener

Parameters:
listener to remove

Definition at line 260 of file layer.cpp.

void FIFE::Layer::setCellGrid ( CellGrid *  grid  )  [inline]

Set the Cellgrid

Definition at line 123 of file layer.h.

void FIFE::Layer::setId ( const std::string &  id  )  [inline]

Sets the identifier for this layer.

Definition at line 110 of file layer.h.

void FIFE::Layer::setInstancesVisible ( bool  vis  ) 

Set object visibility

Definition at line 205 of file layer.cpp.

void FIFE::Layer::setLayerTransparency ( uint8_t  transparency  ) 

Sets the transparency of all instances on the layer. 0=opaque, 255=transparent transparency Transparency value from 0-255.

Definition at line 209 of file layer.cpp.

void FIFE::Layer::setPathingStrategy ( PathingStrategy  strategy  )  [inline]

Sets pathing strategy for the layer

See also:
PathingStrategy

Definition at line 215 of file layer.h.

void FIFE::Layer::toggleInstancesVisible (  ) 

Toggle object visibility

See also:
setObjectsVisible

Definition at line 217 of file layer.cpp.

bool FIFE::Layer::update (  ) 

Called periodically to update events on layer

Returns:
true if layer was changed since the last update, false otherwise

Definition at line 233 of file layer.cpp.


The documentation for this class was generated from the following files:
Generated by  doxygen 1.6.2-20100208