FIFE
be64c707dea6b3250bd4355bf5c825d25920087d
|
A basic cell on a CellCache. More...
#include <cell.h>
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... | |
Zone * | getZone () |
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... | |
Layer * | getLayer () |
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... | |
TransitionInfo * | getTransition () |
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... | |
Layer * | m_layer |
parent layer More... | |
Zone * | m_zone |
parent Zone More... | |
TransitionInfo * | m_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... | |
FIFE::Cell::Cell | ( | int32_t | coordint, |
ModelCoordinate | coordinate, | ||
Layer * | layer | ||
) |
FIFE::Cell::~Cell | ( | ) |
Destructor.
Definition at line 52 of file cell.cpp.
References deleteTransition(), FIFE::Layer::getCellCache(), m_deleteListeners, m_layer, m_transition, m_zone, FIFE::Zone::removeCell(), and FIFE::CellCache::removeCell().
void FIFE::Cell::addChangeListener | ( | CellChangeListener * | listener | ) |
Adds new cell change listener.
listener | A pointer to the listener. |
Definition at line 408 of file cell.cpp.
References m_changeListeners.
Referenced by FIFE::CellCache::addNarrowCell(), and FIFE::Trigger::assign().
void FIFE::Cell::addDeleteListener | ( | CellDeleteListener * | listener | ) |
Adds new cell delete listener.
listener | A pointer to the listener. |
Definition at line 384 of file cell.cpp.
References m_deleteListeners.
Referenced by createTransition().
void FIFE::Cell::addInstance | ( | Instance * | instance | ) |
Adds a instance to this cell.
instance | A pointer to the instance. |
Definition at line 95 of file cell.cpp.
References FIFE::CellCache::addCellToArea(), FIFE::CellCache::addCellToCost(), callOnInstanceEntered(), FIFE::Object::getArea(), FIFE::Layer::getCellCache(), FIFE::Instance::getCost(), FIFE::Instance::getCostId(), FIFE::Instance::getObject(), FIFE::Instance::getSpeed(), FIFE::Instance::isSpecialCost(), FIFE::Instance::isSpecialSpeed(), m_instances, m_layer, FIFE::CellCache::registerCost(), FIFE::CellCache::setSpeedMultiplier(), and updateCellBlockingInfo().
Referenced by FIFE::CellCacheChangeListener::onInstanceCreate(), and FIFE::CellCacheChangeListener::onLayerChanged().
void FIFE::Cell::addInstances | ( | const std::list< Instance *> & | instances | ) |
Adds instances to this cell.
instances | A 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().
void FIFE::Cell::addNeighbor | ( | Cell * | cell | ) |
Adds a neighbor cell to this cell.
cell | A pointer to the cell that should added as neighbor. |
Definition at line 314 of file cell.cpp.
References m_neighbors.
void FIFE::Cell::callOnBlockingChanged | ( | bool | blocks | ) |
Called when the blocking property of this cell changed.
blocks | A boolean, true mark the cell as blocker. |
Definition at line 450 of file cell.cpp.
References m_changeListeners, and m_type.
Referenced by updateCellBlockingInfo().
void FIFE::Cell::callOnInstanceEntered | ( | Instance * | instance | ) |
Called when a instance entered this cell.
instance | A pointer to the instance which will be entered. |
Definition at line 422 of file cell.cpp.
References m_changeListeners.
Referenced by addInstance(), and addInstances().
void FIFE::Cell::callOnInstanceExited | ( | Instance * | instance | ) |
Called when a instance exited this cell.
instance | A pointer to the instance which will be exited. |
Definition at line 436 of file cell.cpp.
References m_changeListeners.
Referenced by removeInstance().
void FIFE::Cell::changeInstance | ( | Instance * | instance | ) |
Changes a instance on this cell.
instance | A pointer to the instance. |
Definition at line 114 of file cell.cpp.
References updateCellBlockingInfo().
Referenced by FIFE::CellCacheChangeListener::onLayerChanged().
void FIFE::Cell::createTransition | ( | Layer * | layer, |
const ModelCoordinate & | mc, | ||
bool | immediate = false |
||
) |
Creates a transistion from this cell to the given layer and coordinates.
layer | A pointer to the layer whereto the transition takes. |
mc | A const reference to a ModelCoordinate whereto the transition takes. |
immediate | A 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().
bool FIFE::Cell::defaultCost | ( | ) |
Returns if cell use default cost.
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().
bool FIFE::Cell::defaultSpeed | ( | ) |
Returns if cell use default speed.
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().
void FIFE::Cell::deleteTransition | ( | ) |
Removes the transistion from Cell and CellCache.
Definition at line 363 of file cell.cpp.
References FIFE::CellCache::getCell(), FIFE::Layer::getCellCache(), FIFE::TransitionInfo::m_layer, m_layer, FIFE::TransitionInfo::m_mc, m_neighbors, m_transition, removeDeleteListener(), and FIFE::CellCache::removeTransition().
Referenced by createTransition(), onCellDeleted(), and ~Cell().
int32_t FIFE::Cell::getCellId | ( | ) |
CellTypeInfo FIFE::Cell::getCellType | ( | ) |
Returns blocker type.
Definition at line 290 of file cell.cpp.
References m_type.
Referenced by FIFE::Layer::cellContainsBlockingInstance(), FIFE::CellCache::createCells(), FIFE::CellCache::getBlockingCellsInRect(), FIFE::CellCache::getCellsInLine(), FIFE::MapSaver::save(), FIFE::CellCache::splitZone(), FIFE::SingleLayerSearch::updateSearch(), and FIFE::MultiLayerSearch::updateSearch().
double FIFE::Cell::getCostMultiplier | ( | ) |
Returns the current cell cost.
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().
const std::set< Instance * > & FIFE::Cell::getInstances | ( | ) |
Returns all instances on this cell.
Definition at line 298 of file cell.cpp.
References m_instances.
Referenced by FIFE::Layer::getBlockingInstances(), and FIFE::MapSaver::save().
Layer * FIFE::Cell::getLayer | ( | ) |
Returns the current 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().
const ModelCoordinate FIFE::Cell::getLayerCoordinates | ( | ) | const |
Returns the layer coordinates of this cell.
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().
const std::vector< Cell * > & FIFE::Cell::getNeighbors | ( | ) |
Returns the layer coordinates of this cell.
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().
double FIFE::Cell::getSpeedMultiplier | ( | ) |
Returns the current cell speed.
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().
TransitionInfo * FIFE::Cell::getTransition | ( | ) |
Returns 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().
Zone * FIFE::Cell::getZone | ( | ) |
Returns zone.
Definition at line 261 of file cell.cpp.
References m_zone.
Referenced by FIFE::Zone::addCell(), FIFE::CellCache::createCells(), FIFE::ZoneCellChangeListener::onBlockingChangedCell(), FIFE::MultiLayerSearch::searchBetweenTargetsMap(), FIFE::MultiLayerSearch::searchBetweenTargetsNeighbor(), FIFE::RoutePather::solveRoute(), and FIFE::CellCache::splitZone().
bool FIFE::Cell::isInserted | ( | ) |
Returns whether the cell is part of a zone.
Definition at line 274 of file cell.cpp.
References m_inserted.
Referenced by FIFE::CellCache::createCells(), and FIFE::CellCache::splitZone().
bool FIFE::Cell::isNeighbor | ( | Cell * | cell | ) |
Called to check if given cell is a neighbor.
cell | A pointer to cell. |
Definition at line 147 of file cell.cpp.
References m_neighbors.
bool FIFE::Cell::isZoneProtected | ( | ) |
Returns whether the zone on this cell is protected.
Definition at line 282 of file cell.cpp.
References m_protect.
Referenced by FIFE::MultiLayerSearch::MultiLayerSearch(), FIFE::RoutePather::solveRoute(), and FIFE::CellCache::splitZone().
|
virtual |
Called when a cell gets deleted on this cell.
If a delete listener was added.
cell | A pointer to the cell which will be deleted. |
Implements FIFE::CellDeleteListener.
Definition at line 398 of file cell.cpp.
References deleteTransition(), and m_neighbors.
void FIFE::Cell::removeChangeListener | ( | CellChangeListener * | listener | ) |
Removes cell change listener.
listener | A pointer to the listener. |
Definition at line 412 of file cell.cpp.
References m_changeListeners.
Referenced by FIFE::Trigger::remove().
void FIFE::Cell::removeDeleteListener | ( | CellDeleteListener * | listener | ) |
Removes cell delete listener.
listener | A pointer to the listener. |
Definition at line 388 of file cell.cpp.
References m_deleteListeners.
Referenced by deleteTransition().
void FIFE::Cell::removeInstance | ( | Instance * | instance | ) |
Removes a instance from this cell.
instance | A pointer to the instance. |
Definition at line 118 of file cell.cpp.
References FIFE::_log, callOnInstanceExited(), FL_ERR, FIFE::Object::getArea(), FIFE::Layer::getCellCache(), FIFE::Instance::getCostId(), FIFE::Instance::getObject(), FIFE::Instance::isSpecialCost(), FIFE::Instance::isSpecialSpeed(), m_instances, m_layer, FIFE::CellCache::removeCellFromArea(), FIFE::CellCache::removeCellFromCost(), FIFE::CellCache::resetSpeedMultiplier(), FIFE::CellCache::setSpeedMultiplier(), and updateCellBlockingInfo().
Referenced by FIFE::CellCacheChangeListener::onInstanceDelete(), FIFE::CellCacheChangeListener::onLayerChanged(), and FIFE::CellCache::removeInteractOnRuntime().
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().
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().
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().
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.
void FIFE::Cell::setCellId | ( | int32_t | id | ) |
Sets the cell identifier.
id | A 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().
void FIFE::Cell::setCellType | ( | CellTypeInfo | type | ) |
Sets blocker type.
Definition at line 294 of file cell.cpp.
References m_type.
Referenced by FIFE::MapLoader::load().
void FIFE::Cell::setCostMultiplier | ( | double | multi | ) |
Changes the cell cost.
multi | A 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().
void FIFE::Cell::setInserted | ( | bool | inserted | ) |
Mark cell as inserted.
inserted | A 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().
void FIFE::Cell::setSpeedMultiplier | ( | double | multi | ) |
Changes the cell speed.
multi | A 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().
void FIFE::Cell::setZone | ( | Zone * | zone | ) |
Sets zone.
zone | A pointer to the zone. |
Definition at line 265 of file cell.cpp.
References m_zone.
Referenced by FIFE::Zone::addCell().
void FIFE::Cell::setZoneProtected | ( | bool | protect | ) |
Mark zone on this cell as protected.
protect | A boolean, true marks the cell as inserted. |
Definition at line 286 of file cell.cpp.
References m_protect.
Referenced by FIFE::ZoneCellChangeListener::onBlockingChangedCell().
|
private |
Definition at line 157 of file cell.cpp.
References callOnBlockingChanged(), FIFE::CTYPE_CELL_BLOCKER, FIFE::CTYPE_CELL_NO_BLOCKER, FIFE::CTYPE_DYNAMIC_BLOCKER, FIFE::CTYPE_NO_BLOCKER, FIFE::CTYPE_STATIC_BLOCKER, FIFE::Math< T >::Equal(), FIFE::Layer::getCellCache(), m_coordinate, m_instances, m_layer, m_type, FIFE::MIN_CELL_Z, FIFE::CellCache::setBlockingUpdate(), and FIFE::PointType3D< T >::z.
Referenced by addInstance(), addInstances(), changeInstance(), removeInstance(), and updateCellInfo().
void FIFE::Cell::updateCellInfo | ( | ) |
Called to update cell data.
Definition at line 214 of file cell.cpp.
References m_changeListeners, m_deleteListeners, and updateCellBlockingInfo().
|
private |
change listener
Definition at line 390 of file cell.h.
Referenced by addChangeListener(), callOnBlockingChanged(), callOnInstanceEntered(), callOnInstanceExited(), removeChangeListener(), and updateCellInfo().
|
private |
holds coordinate as a unique integer id
Definition at line 357 of file cell.h.
Referenced by getCellId(), and setCellId().
|
private |
holds coordinate
Definition at line 360 of file cell.h.
Referenced by getLayerCoordinates(), and updateCellBlockingInfo().
|
private |
delete listener
Definition at line 387 of file cell.h.
Referenced by addDeleteListener(), removeDeleteListener(), updateCellInfo(), and ~Cell().
|
private |
already inserted
Definition at line 372 of file cell.h.
Referenced by isInserted(), resetZone(), and setInserted().
|
private |
Definition at line 381 of file cell.h.
Referenced by addInstance(), addInstances(), getInstances(), removeInstance(), and updateCellBlockingInfo().
|
private |
parent layer
Definition at line 363 of file cell.h.
Referenced by addInstance(), addInstances(), createTransition(), defaultCost(), defaultSpeed(), deleteTransition(), getCostMultiplier(), getLayer(), getSpeedMultiplier(), removeInstance(), resetCostMultiplier(), resetSpeedMultiplier(), setCostMultiplier(), setSpeedMultiplier(), updateCellBlockingInfo(), and ~Cell().
|
private |
neighbor cells
Definition at line 384 of file cell.h.
Referenced by addNeighbor(), createTransition(), deleteTransition(), getNeighbors(), isNeighbor(), onCellDeleted(), and resetNeighbors().
|
private |
protected
Definition at line 375 of file cell.h.
Referenced by isZoneProtected(), and setZoneProtected().
|
private |
Pointer to Transistion.
Definition at line 369 of file cell.h.
Referenced by createTransition(), deleteTransition(), getTransition(), resetNeighbors(), and ~Cell().
|
private |
CellType.
Definition at line 378 of file cell.h.
Referenced by callOnBlockingChanged(), getCellType(), setCellType(), and updateCellBlockingInfo().
|
private |