22 #ifndef FIFE_CELLCACHE_H
23 #define FIFE_CELLCACHE_H
79 const std::set<Cell*>&
getCells()
const;
165 const std::vector<std::vector<Cell*> >&
getCells();
283 void registerCost(
const std::string& costId,
double cost);
294 double getCost(
const std::string& costId);
320 void addCellsToCost(
const std::string& costId,
const std::vector<Cell*>& cells);
343 std::vector<Cell*>
getCostCells(
const std::string& costId);
465 const std::vector<Zone*>&
getZones();
537 void addCellsToArea(
const std::string&
id,
const std::vector<Cell*>& cells);
570 std::vector<std::string>
getAreas();
void removeCellsFromCost(const std::string &costId, const std::vector< Cell * > &cells)
Removes cells from a cost identifier.
void removeZone(Zone *zone)
Removes zone.
uint32_t getHeight()
Returns height of the CellCache.
void setStaticSize(bool staticSize)
Sets the cache size to static so that automatic resize is disabled.
StringCellMultimap::iterator StringCellIterator
double getSpeedMultiplier(Cell *cell)
Returns speed multiplier for the cell.
uint32_t m_width
cache width
void removeInteractOnRuntime(Layer *interact)
Removes a interact layer from the CellCache on runtime and sets all needed layer properties.
bool isUpdated()
Gets whether the CellCache need to be updated.
void unregisterCost(const std::string &costId)
Removes a cost with the given id.
Layer * m_layer
walkable layer
double getCostMultiplier(Cell *cell)
Returns cost multiplier for the cell.
int32_t convertCoordToInt(const ModelCoordinate &coord) const
Convertes coordinate to unique identifier.
void addCell(Cell *cell)
Adds a cell to this zone.
void setSpeedMultiplier(Cell *cell, double multi)
Sets speed multiplier for the cell.
void resize()
Checks the layer size and if the size is different with current size then the cache size is adjusted...
int32_t getMaxNeighborZ()
Gets maximal z range for neighbors.
std::vector< std::string > getCellCosts(Cell *cell)
Returns cost identifiers for cell.
uint32_t next(octet_iterator &it, octet_iterator end)
bool isDefaultSpeed(Cell *cell)
Gets if cell uses default speed multiplier.
void removeTransition(Cell *cell)
Removes a cell as transition.
bool isCellInArea(const std::string &id, Cell *cell)
Returns true if cell is part of the area, otherwise false.
std::set< Cell * > m_cells
cells in the zone
Layer * getLayer()
Returns layer.
Listener interface for changes happening on a cell.
std::set< Cell * > m_narrowCells
special cells which are monitored (zone split and merge)
void setSearchNarrowCells(bool search)
Sets if narrow cells should be searched automatic.
void removeCellFromCost(Cell *cell)
Removes a cell from costs.
std::vector< Cell * > getCellsInRect(const Rect &rec)
Returns all cells in the rect.
StringCellMultimap m_costsToCells
holds cells for each cost
StringCellMultimap m_cellAreas
areas with assigned cells
A CellCache is an abstract depiction of one or a few layers and contains additional information...
bool m_updated
need update
bool m_blockingUpdate
indicates blocking update
void resetNarrowCells()
Resets narrow cells.
void setDefaultCostMultiplier(double multi)
Sets default cost for this CellCache.
const std::set< Cell * > & getCells() const
Returns all cells of this zone.
void addCellToCost(const std::string &costId, Cell *cell)
Assigns a cell to a cost identifier.
bool isDefaultCost(Cell *cell)
Gets if cell uses default cost multiplier.
void addCellsToArea(const std::string &id, const std::vector< Cell * > &cells)
Adds few cell to a specific area group.
void setBlockingUpdate(bool update)
std::vector< std::vector< Cell * > > m_cells
Base class for all fife classes Used e.g.
void registerCost(const std::string &costId, double cost)
Adds a cost with the given id and value.
std::vector< Cell * > getCellsInLine(const ModelCoordinate &pt1, const ModelCoordinate &pt2, bool blocker=false)
Returns all cells in the line.
void resetSpeedMultiplier(Cell *cell)
Resets the speed multiplier for the cell.
bool existsCost(const std::string &costId)
Returns if the cost for the given id exists.
double m_defaultCostMulti
default cost
uint32_t getCellCount() const
Returns the number of cells.
std::vector< Cell * > getCostCells(const std::string &costId)
Returns cells for a cost identifier.
void removeCell(Cell *cell)
Removes a cell from this zone.
void setSize(const Rect &rec)
Sets CellCache size.
uint32_t getId() const
Returns the zone identifier.
std::vector< Zone * > m_zones
zones
void removeArea(const std::string &id)
Removes a area.
void removeCellFromArea(Cell *cell)
Removes the cell from all areas.
void setFowUpdate(bool update)
int32_t m_neighborZ
max z value for neighbors
const std::vector< Zone * > & getZones()
Returns zones of this CellCache.
ModelCoordinate convertIntToCoord(const int32_t cell) const
Convertes unique identifier to coordinate.
std::map< Cell *, double > m_speedMultipliers
holds default speed multiplier, only if it is not default(1.0)
void resetCells()
Remove all cells from zone but does not alter the cells.
void unregisterAllCosts()
Removes all costs.
double getAdjacentCost(const ModelCoordinate &adjacent, const ModelCoordinate &next)
Returns cost for movement between these two adjacent coordinates.
std::map< std::string, double > m_costsTable
holds cost table
const Rect & getSize()
Returns CellCache size.
bool isInCellCache(const Location &location) const
Checks whether the location is in CellCache range.
double getDefaultSpeedMultiplier()
Gets default speed for this CellCache.
void removeCellsFromArea(const std::string &id, const std::vector< Cell * > &cells)
Removes few cells from a area.
Cell * getCell(const ModelCoordinate &mc)
Returns cell on this coordinate.
CellCache(Layer *layer)
Constructor.
std::list< std::string > getCosts()
Returns all registered cost ids.
Zone * createZone()
Creates zone.
std::vector< Cell * > getTransitionCells(Layer *layer=NULL)
Returns transistion cells of this CellCache.
void addCellsToCost(const std::string &costId, const std::vector< Cell * > &cells)
Assigns cells to a cost identifier.
void setUpdated(bool updated)
Sets whether the CellCache need to be updated.
bool existsCostForCell(const std::string &costId, Cell *cell)
Gets if cell is assigned to cost identifier.
void splitZone(Cell *cell)
Splits zone on the cell.
Listener interface for changes happening on a layer.
bool m_searchNarrow
is automatic seach enabled
CellChangeListener * m_cellZoneListener
listener for zones
double m_defaultSpeedMulti
default speed
std::vector< std::string > getCellAreas(Cell *cell)
Returns all areas of a cell.
A basic cell on a CellCache.
void forceUpdate()
Updates all cells.
void createCells()
Creates cells for this CellCache based on the size of the assigned layer.
void addCell(Cell *cell)
Adds cell to this CellCache.
LayerChangeListener * m_cellListener
change listener
bool getCellSpeedMultiplier(const ModelCoordinate &cell, double &multiplier)
Returns speed value from cell.
Rect m_size
Rect holds the min and max size x = min.x, w = max.x, y = min.y, h = max.y.
Zone * getZone(uint32_t id)
Gets zone by identifier.
std::vector< Cell * > getAreaCells(const std::string &id)
Returns all cells of an area.
void setDefaultSpeedMultiplier(double multi)
Sets default speed for this CellCache.
std::map< Cell *, double > m_costMultipliers
holds default cost multiplier, only if it is not default(1.0)
uint32_t m_height
cache height
std::multimap< std::string, Cell * > StringCellMultimap
void mergeZones(Zone *zone1, Zone *zone2)
Merges two zones to one.
bool m_fowUpdate
indicates fow update
bool isStaticSize()
Returns if the cache size is static.
void removeNarrowCell(Cell *cell)
Removes cell from narrow cells.
void addCellToArea(const std::string &id, Cell *cell)
Adds a cell to a specific area group.
Rect calculateCurrentSize()
Returns the current size.
std::vector< Cell * > getCellsInCircle(const ModelCoordinate ¢er, uint16_t radius)
Returns all cells in the circle.
void mergeZone(Zone *zone)
Merge two zones to one.
LayerChangeListener * getCellCacheChangeListener()
Returns change listener.
void setSizeUpdate(bool update)
void removeCell(Cell *cell)
Removes cell from CellCache.
const std::vector< std::vector< Cell * > > & getCells()
Returns all cells of this CellCache.
void addTransition(Cell *cell)
Adds a cell as transition.
Cell * createCell(const ModelCoordinate &mc)
Creates cell on this CellCache.
std::pair< StringCellIterator, StringCellIterator > StringCellPair
bool m_staticSize
is automatic size update enabled/disabled
Zone(uint32_t id)
Constructor.
void addNarrowCell(Cell *cell)
Adds cell to narrow cells.
std::vector< std::string > getAreas()
Returns all area ids.
bool m_sizeUpdate
indicates size update
double getCost(const std::string &costId)
Returns the cost value for the given id.
const std::set< Cell * > & getNarrowCells()
Returns narrow cells.
double getDefaultCostMultiplier()
Gets default cost for this CellCache.
void setMaxNeighborZ(int32_t z)
Sets maximal z range for neighbors.
uint32_t getWidth()
Returns width of the CellCache.
bool existsArea(const std::string &id)
Checks whether the area exists.
std::vector< Cell * > getTransitionCells(Layer *layer=NULL)
Returns transistion cells of this zone.
std::vector< Cell * > m_transitions
cells with transitions
int32_t getMaxIndex() const
Returns the number of cells on this CellCache.
bool isSearchNarrowCells()
Gets if narrow cells should be searched automatic.
void resetCostMultiplier(Cell *cell)
Resets the cost multiplier for the cell.
void addInteractOnRuntime(Layer *interact)
Adds a interact layer to the CellCache on runtime and sets all needed layer properties.
A Zone is an abstract depiction of a CellCache or of a part of it.
void setCostMultiplier(Cell *cell, double multi)
Sets cost multiplier for the cell.
void reset()
Resets the CellCache.