Public Member Functions

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)
std::list< Instance * > getInstancesIn (Rect &rec)
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 94 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 42 of file layer.cpp.

FIFE::Layer::~Layer (  ) 

Destructs a Layer instance

Definition at line 55 of file layer.cpp.


Member Function Documentation

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

Adds new change listener

Parameters:
listener to add

Definition at line 288 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 90 of file layer.cpp.

References FIFE::Instance::isActive(), and FIFE::Instance::setLocation().

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

Check object visibility

See also:
setObjectsVisible

Definition at line 212 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 241 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

Definition at line 69 of file layer.cpp.

References FIFE::Instance::isActive().

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 64 of file layer.cpp.

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

Remove an instance from the layer

Definition at line 116 of file layer.cpp.

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

Get the Cellgrid

Returns:
pointer to a valid cellgrid

Definition at line 121 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 246 of file layer.h.

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

Get the id of this layer.

Definition at line 108 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 143 of file layer.cpp.

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

Get the list of instances on this layer

Definition at line 156 of file layer.h.

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 153 of file layer.cpp.

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 163 of file layer.cpp.

std::list< Instance * > FIFE::Layer::getInstancesIn ( Rect rec  ) 

Returns instances that match given rect.

Parameters:
rec rect where to fetch instances from

Definition at line 182 of file layer.cpp.

References FIFE::RectType< T >::h, FIFE::RectType< T >::w, FIFE::RectType< T >::x, and FIFE::RectType< T >::y.

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

Get the instance tree.

Returns:
this layers instance tree.

Definition at line 130 of file layer.h.

uint8_t FIFE::Layer::getLayerTransparency (  ) 

Returns the layer's transparency value

Definition at line 233 of file layer.cpp.

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

Get the map this layer is contained in

Definition at line 116 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 190 of file layer.cpp.

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

Gets pathing strategy for the layer

See also:
PathingStrategy

Definition at line 227 of file layer.h.

bool FIFE::Layer::hasInstances (  )  const

Check existance of objects on this layer

Returns:
True, if objects exist.

Definition at line 60 of file layer.cpp.

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

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

Definition at line 241 of file layer.h.

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

Removes associated change listener

Parameters:
listener to remove

Definition at line 292 of file layer.cpp.

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

Set the Cellgrid

Definition at line 125 of file layer.h.

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

Sets the identifier for this layer.

Definition at line 112 of file layer.h.

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

Set object visibility

Definition at line 225 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 229 of file layer.cpp.

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

Sets pathing strategy for the layer

See also:
PathingStrategy

Definition at line 222 of file layer.h.

void FIFE::Layer::toggleInstancesVisible (  ) 

Toggle object visibility

See also:
setObjectsVisible

Definition at line 237 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 254 of file layer.cpp.


The documentation for this class was generated from the following files: