FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
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 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 ()
 

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...
 
std::set< Instance * > m_instances
 
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 123 of file cell.h.

Constructor & Destructor Documentation

◆ Cell()

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.

◆ ~Cell()

Member Function Documentation

◆ addChangeListener()

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

Adds new cell change listener.

Parameters
listenerA pointer to the listener.
See also
CellChangeListener

Definition at line 408 of file cell.cpp.

References m_changeListeners.

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

+ Here is the caller graph for this function:

◆ addDeleteListener()

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

Adds new cell delete listener.

Parameters
listenerA pointer to the listener.

Definition at line 384 of file cell.cpp.

References m_deleteListeners.

Referenced by createTransition().

+ Here is the caller graph for this function:

◆ addInstance()

◆ addInstances()

void FIFE::Cell::addInstances ( const std::list< Instance *> &  instances)

Adds instances to this cell.

Parameters
instancesA const reference to list that contains instances.

Definition at line 74 of file cell.cpp.

References FIFE::CellCache::addCellToArea(), FIFE::CellCache::addCellToCost(), callOnInstanceEntered(), FIFE::Layer::getCellCache(), m_instances, m_layer, FIFE::CellCache::registerCost(), FIFE::CellCache::setSpeedMultiplier(), and updateCellBlockingInfo().

Referenced by FIFE::CellCache::addInteractOnRuntime(), FIFE::CellCache::createCells(), and FIFE::CellCache::resize().

+ Here is the caller graph for this function:

◆ addNeighbor()

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 314 of file cell.cpp.

References m_neighbors.

◆ callOnBlockingChanged()

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 450 of file cell.cpp.

References m_changeListeners, and m_type.

Referenced by updateCellBlockingInfo().

+ Here is the caller graph for this function:

◆ callOnInstanceEntered()

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 422 of file cell.cpp.

References m_changeListeners.

Referenced by addInstance(), and addInstances().

+ Here is the caller graph for this function:

◆ callOnInstanceExited()

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 436 of file cell.cpp.

References m_changeListeners.

Referenced by removeInstance().

+ Here is the caller graph for this function:

◆ changeInstance()

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

Changes a instance on this cell.

Parameters
instanceA pointer to the instance.

Definition at line 114 of file cell.cpp.

References updateCellBlockingInfo().

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

+ Here is the caller graph for this function:

◆ createTransition()

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 339 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:

◆ defaultCost()

bool FIFE::Cell::defaultCost ( )

Returns if cell use default cost.

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

Definition at line 229 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:

◆ defaultSpeed()

bool FIFE::Cell::defaultSpeed ( )

Returns if cell use default speed.

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

Definition at line 245 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:

◆ deleteTransition()

void FIFE::Cell::deleteTransition ( )

◆ getCellId()

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 306 of file cell.cpp.

References m_coordId.

◆ getCellType()

◆ getCostMultiplier()

double FIFE::Cell::getCostMultiplier ( )

Returns the current cell cost.

Returns
The currently used cost value as a double.

Definition at line 237 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:

◆ getInstances()

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 298 of file cell.cpp.

References m_instances.

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

+ Here is the caller graph for this function:

◆ getLayer()

Layer * FIFE::Cell::getLayer ( )

Returns the current layer.

Returns
A pointer to the currently used layer.

Definition at line 335 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:

◆ getLayerCoordinates()

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

Returns the layer coordinates of this cell.

Returns
A const reference to a ModelCoordinate.

Definition at line 310 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:

◆ getNeighbors()

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 318 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:

◆ getSpeedMultiplier()

double FIFE::Cell::getSpeedMultiplier ( )

Returns the current cell speed.

Returns
The currently used speed value as a double.

Definition at line 253 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:

◆ getTransition()

TransitionInfo * FIFE::Cell::getTransition ( )

Returns the transition.

Returns
A pointer to the transition.

Definition at line 380 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:

◆ getZone()

◆ isInserted()

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 274 of file cell.cpp.

References m_inserted.

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

+ Here is the caller graph for this function:

◆ isNeighbor()

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 147 of file cell.cpp.

References m_neighbors.

◆ isZoneProtected()

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 282 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:

◆ onCellDeleted()

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 398 of file cell.cpp.

References deleteTransition(), and m_neighbors.

◆ removeChangeListener()

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

Removes cell change listener.

Parameters
listenerA pointer to the listener.
See also
CellChangeListener

Definition at line 412 of file cell.cpp.

References m_changeListeners.

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

+ Here is the caller graph for this function:

◆ removeDeleteListener()

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

Removes cell delete listener.

Parameters
listenerA pointer to the listener.

Definition at line 388 of file cell.cpp.

References m_deleteListeners.

Referenced by deleteTransition().

+ Here is the caller graph for this function:

◆ removeInstance()

◆ resetCostMultiplier()

void FIFE::Cell::resetCostMultiplier ( )

Resets the cell cost to default, 1.0.

Definition at line 241 of file cell.cpp.

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

◆ resetNeighbors()

void FIFE::Cell::resetNeighbors ( )

Removes all neighbors from cell.

Definition at line 322 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:

◆ resetSpeedMultiplier()

void FIFE::Cell::resetSpeedMultiplier ( )

Resets the cell speed to default, 1.0.

Definition at line 257 of file cell.cpp.

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

◆ resetZone()

void FIFE::Cell::resetZone ( )

Resets zone.

Zone pointer is NULL and isInserted() returns false.

Definition at line 269 of file cell.cpp.

References m_inserted, and m_zone.

◆ setCellId()

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 302 of file cell.cpp.

References m_coordId.

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

+ Here is the caller graph for this function:

◆ setCellType()

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

Sets blocker type.

See also
CellType

Definition at line 294 of file cell.cpp.

References m_type.

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

+ Here is the caller graph for this function:

◆ setCostMultiplier()

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 233 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:

◆ setInserted()

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 278 of file cell.cpp.

References m_inserted.

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

+ Here is the caller graph for this function:

◆ setSpeedMultiplier()

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 249 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:

◆ setZone()

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

Sets zone.

Parameters
zoneA pointer to the zone.

Definition at line 265 of file cell.cpp.

References m_zone.

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

+ Here is the caller graph for this function:

◆ setZoneProtected()

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 286 of file cell.cpp.

References m_protect.

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

+ Here is the caller graph for this function:

◆ updateCellBlockingInfo()

◆ updateCellInfo()

void FIFE::Cell::updateCellInfo ( )

Called to update cell data.

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

Definition at line 214 of file cell.cpp.

References m_changeListeners, m_deleteListeners, and updateCellBlockingInfo().

Member Data Documentation

◆ m_changeListeners

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

◆ m_coordId

int32_t FIFE::Cell::m_coordId
private

holds coordinate as a unique integer id

Definition at line 357 of file cell.h.

Referenced by getCellId(), and setCellId().

◆ m_coordinate

ModelCoordinate FIFE::Cell::m_coordinate
private

holds coordinate

Definition at line 360 of file cell.h.

Referenced by getLayerCoordinates(), and updateCellBlockingInfo().

◆ m_deleteListeners

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

delete listener

Definition at line 387 of file cell.h.

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

◆ m_inserted

bool FIFE::Cell::m_inserted
private

already inserted

Definition at line 372 of file cell.h.

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

◆ m_instances

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

◆ m_layer

◆ m_neighbors

std::vector<Cell*> FIFE::Cell::m_neighbors
private

neighbor cells

Definition at line 384 of file cell.h.

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

◆ m_protect

bool FIFE::Cell::m_protect
private

protected

Definition at line 375 of file cell.h.

Referenced by isZoneProtected(), and setZoneProtected().

◆ m_transition

TransitionInfo* FIFE::Cell::m_transition
private

Pointer to Transistion.

Definition at line 369 of file cell.h.

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

◆ m_type

CellTypeInfo FIFE::Cell::m_type
private

CellType.

Definition at line 378 of file cell.h.

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

◆ m_zone

Zone* FIFE::Cell::m_zone
private

parent Zone

Definition at line 366 of file cell.h.

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


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