FIFE 2008.0
FIFE::Layer Class Reference

#include <layer.h>

Inheritance diagram for FIFE::Layer:
Collaboration diagram for FIFE::Layer:

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 93 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:
listenerto add

Definition at line 271 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 91 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 206 of file layer.h.

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

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

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

Definition at line 236 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 70 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 65 of file layer.cpp.

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

Remove an instance from the layer

Definition at line 117 of file layer.cpp.

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

Get the Cellgrid

Returns:
a valid cellgrid

Definition at line 120 of file layer.h.

Referenced by FIFE::Camera::getCellImageDimensions(), and FIFE::CellSelectionRenderer::render().

Here is the caller graph for this function:

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 240 of file layer.h.

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

Get the id of this layer.

Definition at line 107 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 144 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 154 of file layer.cpp.

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

Get the list of instances on this layer

Definition at line 155 of file layer.h.

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

Returns instances that match given location.

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

Definition at line 164 of file layer.cpp.

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

Get the instance tree.

Returns:
this layers instance tree.

Definition at line 129 of file layer.h.

uint8_t FIFE::Layer::getLayerTransparency ( )

Returns the layer's transparency value

Definition at line 228 of file layer.cpp.

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

Get the map this layer is contained in

Definition at line 115 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:
minA reference to a ModelCoordinate that will hold the minimum coordinate.
maxA reference to a ModelCoordinate that will hold the maximum coordinate.
layerA pointer to another layer that can be used to cast coordinates bettween layers.

Definition at line 183 of file layer.cpp.

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

Gets pathing strategy for the layer

See also:
PathingStrategy

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

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

Removes associated change listener

Parameters:
listenerto remove

Definition at line 275 of file layer.cpp.

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

Set the Cellgrid

Definition at line 124 of file layer.h.

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

Sets the identifier for this layer.

Definition at line 111 of file layer.h.

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

Set object visibility

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

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

Sets pathing strategy for the layer

See also:
PathingStrategy

Definition at line 216 of file layer.h.

void FIFE::Layer::toggleInstancesVisible ( )

Toggle object visibility

See also:
setObjectsVisible

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


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Enumerations Enumerator