FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
FIFE::Cell Class Reference

A basic cell on a CellCache. More...

#include <cell.h>

+ Inheritance diagram for FIFE::Cell:
+ Collaboration diagram for FIFE::Cell:

Public Member Functions

 Cell (int32_t coordint, ModelCoordinate coordinate, Layer *layer)
 Constructor. More...
 
 ~Cell ()
 Destructor. More...
 
void addInstances (const std::list< Instance * > &instances)
 Adds instances to this cell. More...
 
void addInstance (Instance *instance)
 Adds a instance to this cell. More...
 
void changeInstance (Instance *instance)
 Changes a instance on this cell. More...
 
void removeInstance (Instance *instance)
 Removes a instance from this cell. More...
 
bool isNeighbor (Cell *cell)
 Called to check if given cell is a neighbor. More...
 
void updateCellInfo ()
 Called to update cell data. More...
 
bool defaultCost ()
 Returns if cell use default cost. More...
 
void setCostMultiplier (double multi)
 Changes the cell cost. More...
 
double getCostMultiplier ()
 Returns the current cell cost. More...
 
void resetCostMultiplier ()
 Resets the cell cost to default, 1.0. More...
 
bool defaultSpeed ()
 Returns if cell use default speed. More...
 
void setSpeedMultiplier (double multi)
 Changes the cell speed. More...
 
double getSpeedMultiplier ()
 Returns the current cell speed. More...
 
void resetSpeedMultiplier ()
 Resets the cell speed to default, 1.0. More...
 
ZonegetZone ()
 Returns zone. More...
 
void setZone (Zone *zone)
 Sets zone. More...
 
void resetZone ()
 Resets zone. More...
 
bool isInserted ()
 Returns whether the cell is part of a zone. More...
 
void setInserted (bool inserted)
 Mark cell as inserted. More...
 
bool isZoneProtected ()
 Returns whether the zone on this cell is protected. More...
 
void setZoneProtected (bool protect)
 Mark zone on this cell as protected. More...
 
CellTypeInfo getCellType ()
 Returns blocker type. More...
 
void setCellType (CellTypeInfo type)
 Sets blocker type. More...
 
const std::set< Instance * > & getInstances ()
 Returns all instances on this cell. More...
 
void setCellId (int32_t id)
 Sets the cell identifier. More...
 
int32_t getCellId ()
 Returns the cell identifier. More...
 
const ModelCoordinate getLayerCoordinates () const
 Returns the layer coordinates of this cell. More...
 
void addNeighbor (Cell *cell)
 Adds a neighbor cell to this cell. More...
 
const std::vector< Cell * > & getNeighbors ()
 Returns the layer coordinates of this cell. More...
 
void resetNeighbors ()
 Removes all neighbors from cell. More...
 
LayergetLayer ()
 Returns the current layer. More...
 
void createTransition (Layer *layer, const ModelCoordinate &mc, bool immediate=false)
 Creates a transistion from this cell to the given layer and coordinates. More...
 
void deleteTransition ()
 Removes the transistion from Cell and CellCache. More...
 
TransitionInfogetTransition ()
 Returns the transition. More...
 
void setFoWType (CellVisualEffect type)
 Sets the cell visual. More...
 
CellVisualEffect getFoWType ()
 Returns the cell visual. More...
 
void addVisitorInstance (Instance *instance)
 Adds a instance as visitor to this cell. More...
 
void removeVisitorInstance (Instance *instance)
 Removes the visitor instance from this cell. More...
 
const std::vector< Instance * > & getVisitorInstances ()
 Returns all visitor instances on this cell. More...
 
void addDeleteListener (CellDeleteListener *listener)
 Adds new cell delete listener. More...
 
void removeDeleteListener (CellDeleteListener *listener)
 Removes cell delete listener. More...
 
void onCellDeleted (Cell *cell)
 Called when a cell gets deleted on this cell. More...
 
void addChangeListener (CellChangeListener *listener)
 Adds new cell change listener. More...
 
void removeChangeListener (CellChangeListener *listener)
 Removes cell change listener. More...
 
void callOnInstanceEntered (Instance *instance)
 Called when a instance entered this cell. More...
 
void callOnInstanceExited (Instance *instance)
 Called when a instance exited this cell. More...
 
void callOnBlockingChanged (bool blocks)
 Called when the blocking property of this cell changed. More...
 
- Public Member Functions inherited from FIFE::FifeClass
 FifeClass ()
 
virtual ~FifeClass ()
 
fifeid_t getFifeId ()
 Gets unique id of this instance inside the engine. More...
 
- Public Member Functions inherited from FIFE::CellDeleteListener
virtual ~CellDeleteListener ()
 

Private Member Functions

void updateCellBlockingInfo ()
 
void updateCellFowInfo ()
 

Private Attributes

int32_t m_coordId
 holds coordinate as a unique integer id More...
 
ModelCoordinate m_coordinate
 holds coordinate More...
 
Layerm_layer
 parent layer More...
 
Zonem_zone
 parent Zone More...
 
TransitionInfom_transition
 Pointer to Transistion. More...
 
bool m_inserted
 already inserted More...
 
bool m_protect
 protected More...
 
CellTypeInfo m_type
 CellType. More...
 
CellVisualEffect m_fowType
 visual cell status More...
 
std::set< Instance * > m_instances
 
std::vector< Instance * > m_visitors
 contains visitor instances More...
 
std::vector< Cell * > m_neighbors
 neighbor cells More...
 
std::vector< CellDeleteListener * > m_deleteListeners
 delete listener More...
 
std::vector< CellChangeListener * > m_changeListeners
 change listener More...
 

Detailed Description

A basic cell on a CellCache.

Definition at line 136 of file cell.h.

Constructor & Destructor Documentation

FIFE::Cell::Cell ( int32_t  coordint,
ModelCoordinate  coordinate,
Layer layer 
)

Constructor.

Parameters
coordintA integer value that represents the cell identifier. Based on coordinates.
coordinateA ModelCoordinate that specifies the coordinates of the cell.
layerA pointer to the layer which is associated with the cell.

Definition at line 42 of file cell.cpp.

Member Function Documentation

void FIFE::Cell::addChangeListener ( CellChangeListener listener)

Adds new cell change listener.

Parameters
listenerA pointer to the listener.
See also
CellChangeListener

Definition at line 613 of file cell.cpp.

References m_changeListeners.

Referenced by FIFE::CellCache::addNarrowCell(), and FIFE::Trigger::assign().

+ Here is the caller graph for this function:

void FIFE::Cell::addDeleteListener ( CellDeleteListener listener)

Adds new cell delete listener.

Parameters
listenerA pointer to the listener.

Definition at line 589 of file cell.cpp.

References m_deleteListeners.

Referenced by createTransition().

+ Here is the caller graph for this function:

void FIFE::Cell::addNeighbor ( Cell cell)

Adds a neighbor cell to this cell.

Parameters
cellA pointer to the cell that should added as neighbor.

Definition at line 519 of file cell.cpp.

References m_neighbors.

void FIFE::Cell::addVisitorInstance ( Instance instance)

Adds a instance as visitor to this cell.

Instance visitor radius is then used e.g. for Fog of War.

Parameters
instanceA pointer to the instance.

Definition at line 406 of file cell.cpp.

References m_visitors.

void FIFE::Cell::callOnBlockingChanged ( bool  blocks)

Called when the blocking property of this cell changed.

Parameters
blocksA boolean, true mark the cell as blocker.
See also
CellChangeListener

Definition at line 655 of file cell.cpp.

References m_changeListeners, and m_type.

Referenced by updateCellBlockingInfo().

+ Here is the caller graph for this function:

void FIFE::Cell::callOnInstanceEntered ( Instance instance)

Called when a instance entered this cell.

Parameters
instanceA pointer to the instance which will be entered.
See also
CellChangeListener

Definition at line 627 of file cell.cpp.

References m_changeListeners.

Referenced by addInstance(), and addInstances().

+ Here is the caller graph for this function:

void FIFE::Cell::callOnInstanceExited ( Instance instance)

Called when a instance exited this cell.

Parameters
instanceA pointer to the instance which will be exited.
See also
CellChangeListener

Definition at line 641 of file cell.cpp.

References m_changeListeners.

Referenced by removeInstance().

+ Here is the caller graph for this function:

void FIFE::Cell::changeInstance ( Instance instance)

Changes a instance on this cell.

Parameters
instanceA pointer to the instance.

Definition at line 198 of file cell.cpp.

References updateCellBlockingInfo().

Referenced by FIFE::CellCacheChangeListener::onLayerChanged().

+ Here is the caller graph for this function:

void FIFE::Cell::createTransition ( Layer layer,
const ModelCoordinate mc,
bool  immediate = false 
)

Creates a transistion from this cell to the given layer and coordinates.

Parameters
layerA pointer to the layer whereto the transition takes.
mcA const reference to a ModelCoordinate whereto the transition takes.
immediateA boolean, true means the transition is always used, if false the transistion is only used if it is a part of the path e.g. as an abbreviation.

Definition at line 544 of file cell.cpp.

References addDeleteListener(), FIFE::CellCache::addTransition(), deleteTransition(), FIFE::CellCache::getCell(), FIFE::Layer::getCellCache(), FIFE::TransitionInfo::m_difflayer, FIFE::TransitionInfo::m_immediate, m_layer, FIFE::TransitionInfo::m_mc, m_neighbors, and m_transition.

Referenced by FIFE::MapLoader::load().

+ Here is the caller graph for this function:

bool FIFE::Cell::defaultCost ( )

Returns if cell use default cost.

Returns
True if the cell use the default cost, otherwise false.

Definition at line 434 of file cell.cpp.

References FIFE::Layer::getCellCache(), FIFE::CellCache::isDefaultCost(), and m_layer.

Referenced by FIFE::CellCache::getAdjacentCost(), and FIFE::MapSaver::save().

+ Here is the caller graph for this function:

bool FIFE::Cell::defaultSpeed ( )

Returns if cell use default speed.

Returns
True if the cell use the default speed, otherwise false.

Definition at line 450 of file cell.cpp.

References FIFE::Layer::getCellCache(), FIFE::CellCache::isDefaultSpeed(), and m_layer.

Referenced by FIFE::CellCache::getCellSpeedMultiplier(), and FIFE::MapSaver::save().

+ Here is the caller graph for this function:

void FIFE::Cell::deleteTransition ( )
int32_t FIFE::Cell::getCellId ( )

Returns the cell identifier.

Returns
A unique int value that is used as identifier. Based on the cell position.

Definition at line 511 of file cell.cpp.

References m_coordId.

CellTypeInfo FIFE::Cell::getCellType ( )
double FIFE::Cell::getCostMultiplier ( )

Returns the current cell cost.

Returns
The currently used cost value as a double.

Definition at line 442 of file cell.cpp.

References FIFE::Layer::getCellCache(), FIFE::CellCache::getCostMultiplier(), and m_layer.

Referenced by FIFE::CellCache::getAdjacentCost(), and FIFE::MapSaver::save().

+ Here is the caller graph for this function:

CellVisualEffect FIFE::Cell::getFoWType ( )

Returns the cell visual.

See also
CellVisualType

Definition at line 402 of file cell.cpp.

References m_fowType.

Referenced by FIFE::InstanceRenderer::renderAlreadySorted(), FIFE::InstanceRenderer::renderUnsorted(), and FIFE::MapSaver::save().

+ Here is the caller graph for this function:

const std::set< Instance * > & FIFE::Cell::getInstances ( )

Returns all instances on this cell.

Returns
A const reference to a set that refer to the instances on this cell.

Definition at line 503 of file cell.cpp.

References m_instances.

Referenced by FIFE::Layer::getBlockingInstances(), and FIFE::MapSaver::save().

+ Here is the caller graph for this function:

Layer * FIFE::Cell::getLayer ( )

Returns the current layer.

Returns
A pointer to the currently used layer.

Definition at line 540 of file cell.cpp.

References m_layer.

Referenced by FIFE::RoutePather::followRoute(), FIFE::MultiLayerSearch::searchBetweenTargetsMap(), FIFE::SingleLayerSearch::updateSearch(), and FIFE::MultiLayerSearch::updateSearch().

+ Here is the caller graph for this function:

const ModelCoordinate FIFE::Cell::getLayerCoordinates ( ) const

Returns the layer coordinates of this cell.

Returns
A const reference to a ModelCoordinate.

Definition at line 515 of file cell.cpp.

References m_coordinate.

Referenced by FIFE::CellCache::addCell(), FIFE::RoutePather::followRoute(), FIFE::CellCache::resize(), FIFE::MapSaver::save(), FIFE::MultiLayerSearch::searchBetweenTargetsMap(), FIFE::SingleLayerSearch::updateSearch(), and FIFE::MultiLayerSearch::updateSearch().

+ Here is the caller graph for this function:

const std::vector< Cell * > & FIFE::Cell::getNeighbors ( )

Returns the layer coordinates of this cell.

Returns
A const reference to a set of all neighbor cells.

Definition at line 523 of file cell.cpp.

References m_neighbors.

Referenced by FIFE::CellCache::createCells(), FIFE::MultiLayerSearch::MultiLayerSearch(), FIFE::ZoneCellChangeListener::onBlockingChangedCell(), FIFE::RoutePather::solveRoute(), FIFE::CellCache::splitZone(), FIFE::SingleLayerSearch::updateSearch(), and FIFE::MultiLayerSearch::updateSearch().

+ Here is the caller graph for this function:

double FIFE::Cell::getSpeedMultiplier ( )

Returns the current cell speed.

Returns
The currently used speed value as a double.

Definition at line 458 of file cell.cpp.

References FIFE::Layer::getCellCache(), FIFE::CellCache::getSpeedMultiplier(), and m_layer.

Referenced by FIFE::CellCache::getCellSpeedMultiplier(), and FIFE::MapSaver::save().

+ Here is the caller graph for this function:

TransitionInfo * FIFE::Cell::getTransition ( )

Returns the transition.

Returns
A pointer to the transition.

Definition at line 585 of file cell.cpp.

References m_transition.

Referenced by FIFE::RoutePather::followRoute(), FIFE::MapSaver::save(), FIFE::MultiLayerSearch::searchBetweenTargetsMap(), and FIFE::MultiLayerSearch::searchBetweenTargetsNeighbor().

+ Here is the caller graph for this function:

const std::vector< Instance * > & FIFE::Cell::getVisitorInstances ( )

Returns all visitor instances on this cell.

Returns
A const reference to a set of all visitor instances.

Definition at line 430 of file cell.cpp.

References m_visitors.

bool FIFE::Cell::isInserted ( )

Returns whether the cell is part of a zone.

Returns
True if the cell is inserted into a zone, otherwise false.

Definition at line 479 of file cell.cpp.

References m_inserted.

Referenced by FIFE::CellCache::createCells(), and FIFE::CellCache::splitZone().

+ Here is the caller graph for this function:

bool FIFE::Cell::isNeighbor ( Cell cell)

Called to check if given cell is a neighbor.

Parameters
cellA pointer to cell.
Returns
True if cell is a neighbor, otherwise false.

Definition at line 260 of file cell.cpp.

References m_neighbors.

bool FIFE::Cell::isZoneProtected ( )

Returns whether the zone on this cell is protected.

Returns
True if the zone is protected, otherwise false.

Definition at line 487 of file cell.cpp.

References m_protect.

Referenced by FIFE::MultiLayerSearch::MultiLayerSearch(), FIFE::RoutePather::solveRoute(), and FIFE::CellCache::splitZone().

+ Here is the caller graph for this function:

void FIFE::Cell::onCellDeleted ( Cell cell)
virtual

Called when a cell gets deleted on this cell.

If a delete listener was added.

Parameters
cellA pointer to the cell which will be deleted.
See also
CellDeleteListener

Implements FIFE::CellDeleteListener.

Definition at line 603 of file cell.cpp.

References deleteTransition(), and m_neighbors.

void FIFE::Cell::removeChangeListener ( CellChangeListener listener)

Removes cell change listener.

Parameters
listenerA pointer to the listener.
See also
CellChangeListener

Definition at line 617 of file cell.cpp.

References m_changeListeners.

Referenced by FIFE::Trigger::remove().

+ Here is the caller graph for this function:

void FIFE::Cell::removeDeleteListener ( CellDeleteListener listener)

Removes cell delete listener.

Parameters
listenerA pointer to the listener.

Definition at line 593 of file cell.cpp.

References m_deleteListeners.

Referenced by deleteTransition().

+ Here is the caller graph for this function:

void FIFE::Cell::removeVisitorInstance ( Instance instance)

Removes the visitor instance from this cell.

Parameters
instanceA pointer to the instance.

Definition at line 420 of file cell.cpp.

References m_visitors.

void FIFE::Cell::resetCostMultiplier ( )

Resets the cell cost to default, 1.0.

Definition at line 446 of file cell.cpp.

References FIFE::Layer::getCellCache(), m_layer, and FIFE::CellCache::resetCostMultiplier().

void FIFE::Cell::resetNeighbors ( )

Removes all neighbors from cell.

Definition at line 527 of file cell.cpp.

References FIFE::CellCache::getCell(), FIFE::Layer::getCellCache(), FIFE::TransitionInfo::m_layer, FIFE::TransitionInfo::m_mc, m_neighbors, and m_transition.

Referenced by FIFE::CellCache::resize().

+ Here is the caller graph for this function:

void FIFE::Cell::resetSpeedMultiplier ( )

Resets the cell speed to default, 1.0.

Definition at line 462 of file cell.cpp.

References FIFE::Layer::getCellCache(), m_layer, and FIFE::CellCache::resetSpeedMultiplier().

void FIFE::Cell::resetZone ( )

Resets zone.

Zone pointer is NULL and isInserted() returns false.

Definition at line 474 of file cell.cpp.

References m_inserted, and m_zone.

void FIFE::Cell::setCellId ( int32_t  id)

Sets the cell identifier.

Parameters
idA unique int value that is used as identifier. Based on the cell position.

Definition at line 507 of file cell.cpp.

References m_coordId.

Referenced by FIFE::CellCache::resize().

+ Here is the caller graph for this function:

void FIFE::Cell::setCellType ( CellTypeInfo  type)

Sets blocker type.

See also
CellType

Definition at line 499 of file cell.cpp.

References m_type.

Referenced by FIFE::MapLoader::load().

+ Here is the caller graph for this function:

void FIFE::Cell::setCostMultiplier ( double  multi)

Changes the cell cost.

Parameters
multiA double its value is used instead of the default cost.

Definition at line 438 of file cell.cpp.

References FIFE::Layer::getCellCache(), m_layer, and FIFE::CellCache::setCostMultiplier().

Referenced by FIFE::MapLoader::load().

+ Here is the caller graph for this function:

void FIFE::Cell::setFoWType ( CellVisualEffect  type)

Sets the cell visual.

See also
CellVisualType

Definition at line 398 of file cell.cpp.

References m_fowType.

Referenced by FIFE::MapLoader::load().

+ Here is the caller graph for this function:

void FIFE::Cell::setInserted ( bool  inserted)

Mark cell as inserted.

Parameters
insertedA boolean, true marks the cell as inserted, false as not inserted.

Definition at line 483 of file cell.cpp.

References m_inserted.

Referenced by FIFE::CellCache::createCells(), and FIFE::CellCache::splitZone().

+ Here is the caller graph for this function:

void FIFE::Cell::setSpeedMultiplier ( double  multi)

Changes the cell speed.

Parameters
multiA double its value is used instead of the default speed.

Definition at line 454 of file cell.cpp.

References FIFE::Layer::getCellCache(), m_layer, and FIFE::CellCache::setSpeedMultiplier().

Referenced by FIFE::MapLoader::load().

+ Here is the caller graph for this function:

void FIFE::Cell::setZone ( Zone zone)

Sets zone.

Parameters
zoneA pointer to the zone.

Definition at line 470 of file cell.cpp.

References m_zone.

Referenced by FIFE::Zone::addCell().

+ Here is the caller graph for this function:

void FIFE::Cell::setZoneProtected ( bool  protect)

Mark zone on this cell as protected.

Parameters
protectA boolean, true marks the cell as inserted.

Definition at line 491 of file cell.cpp.

References m_protect.

Referenced by FIFE::ZoneCellChangeListener::onBlockingChangedCell().

+ Here is the caller graph for this function:

void FIFE::Cell::updateCellInfo ( )

Called to update cell data.

Returns
True if cell was changed since the last update, false otherwise.

Definition at line 382 of file cell.cpp.

References m_changeListeners, m_deleteListeners, updateCellBlockingInfo(), and updateCellFowInfo().

Member Data Documentation

std::vector<CellChangeListener*> FIFE::Cell::m_changeListeners
private
int32_t FIFE::Cell::m_coordId
private

holds coordinate as a unique integer id

Definition at line 396 of file cell.h.

Referenced by getCellId(), and setCellId().

ModelCoordinate FIFE::Cell::m_coordinate
private

holds coordinate

Definition at line 399 of file cell.h.

Referenced by addInstance(), addInstances(), getLayerCoordinates(), removeInstance(), updateCellBlockingInfo(), and updateCellFowInfo().

std::vector<CellDeleteListener*> FIFE::Cell::m_deleteListeners
private

delete listener

Definition at line 432 of file cell.h.

Referenced by addDeleteListener(), removeDeleteListener(), updateCellInfo(), and ~Cell().

CellVisualEffect FIFE::Cell::m_fowType
private

visual cell status

Definition at line 420 of file cell.h.

Referenced by getFoWType(), setFoWType(), and updateCellFowInfo().

bool FIFE::Cell::m_inserted
private

already inserted

Definition at line 411 of file cell.h.

Referenced by isInserted(), resetZone(), and setInserted().

std::set<Instance*> FIFE::Cell::m_instances
private
std::vector<Cell*> FIFE::Cell::m_neighbors
private

neighbor cells

Definition at line 429 of file cell.h.

Referenced by addNeighbor(), createTransition(), deleteTransition(), getNeighbors(), isNeighbor(), onCellDeleted(), and resetNeighbors().

bool FIFE::Cell::m_protect
private

protected

Definition at line 414 of file cell.h.

Referenced by isZoneProtected(), and setZoneProtected().

TransitionInfo* FIFE::Cell::m_transition
private

Pointer to Transistion.

Definition at line 408 of file cell.h.

Referenced by createTransition(), deleteTransition(), getTransition(), resetNeighbors(), and ~Cell().

CellTypeInfo FIFE::Cell::m_type
private

CellType.

Definition at line 417 of file cell.h.

Referenced by callOnBlockingChanged(), getCellType(), setCellType(), and updateCellBlockingInfo().

std::vector<Instance*> FIFE::Cell::m_visitors
private

contains visitor instances

Definition at line 426 of file cell.h.

Referenced by addVisitorInstance(), getVisitorInstances(), removeVisitorInstance(), and updateCellFowInfo().

Zone* FIFE::Cell::m_zone
private

parent Zone

Definition at line 405 of file cell.h.

Referenced by getZone(), resetZone(), setZone(), and ~Cell().


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