44 m_coordinate(coordinate),
60 (*it)->onCellDeleted(
this);
78 for (std::list<Instance*>::const_iterator it = instances.begin(); it != instances.end(); ++it) {
79 std::pair<std::set<Instance*>::iterator,
bool> ret =
m_instances.insert(*it);
81 if ((*it)->isVisitor()) {
82 uint16_t visitorRadius = (*it)->getVisitorRadius();
83 std::vector<Cell*> cells;
84 std::vector<Cell*> cellsExt;
85 switch((*it)->getVisitorShape()) {
88 (visitorRadius*2)+1, (visitorRadius*2)+1);
90 Rect sizeExt(size.
x-1, size.
y-1, size.
w+2, size.
h+2);
103 for (std::vector<Cell*>::iterator szit = cellsExt.begin(); szit != cellsExt.end(); ++szit) {
105 for (std::vector<Cell*>::iterator sit = cells.begin(); sit != cells.end(); ++sit) {
108 (*szit)->addVisitorInstance(*it);
114 const std::vector<Instance*>& cv = (*szit)->getVisitorInstances();
122 if ((*it)->isSpecialCost()) {
123 cache->
registerCost((*it)->getCostId(), (*it)->getCost());
126 if ((*it)->getObject()->getArea() !=
"") {
136 std::pair<std::set<Instance*>::iterator,
bool> ret =
m_instances.insert(instance);
141 std::vector<Cell*> cells;
142 std::vector<Cell*> cellsExt;
146 (visitorRadius*2)+1, (visitorRadius*2)+1);
148 Rect sizeExt(size.
x-1, size.
y-1, size.
w+2, size.
h+2);
161 for (std::vector<Cell*>::iterator szit = cellsExt.begin(); szit != cellsExt.end(); ++szit) {
163 for (std::vector<Cell*>::iterator sit = cells.begin(); sit != cells.end(); ++sit) {
166 (*szit)->addVisitorInstance(instance);
172 const std::vector<Instance*>& cv = (*szit)->getVisitorInstances();
198 FL_ERR(
_log,
"Tried to remove an instance from cell, but given instance could not be found.");
204 std::vector<Cell*> cells;
208 (visitorRadius*2)+1, (visitorRadius*2)+1);
220 for (std::vector<Cell*>::iterator it = cells.begin(); it != cells.end(); ++it) {
221 (*it)->removeVisitorInstance(instance);
222 const std::vector<Instance*>& cv = (*it)->getVisitorInstances();
242 std::vector<Cell*>::iterator it =
m_neighbors.begin();
261 uint8_t stackpos = (*it)->getCellStackPosition();
262 if (stackpos < pos) {
266 if (
m_coordinate.
z < (*it)->getLocationRef().getLayerCoordinates().z && (*it)->getObject()->isStatic()) {
267 m_coordinate.
z = (*it)->getLocationRef().getLayerCoordinates().z;
269 if ((*it)->getCellStackPosition() > pos) {
270 pos = (*it)->getCellStackPosition();
271 if ((*it)->isBlocking()) {
272 if (!(*it)->getObject()->isStatic()) {
283 if (!(*it)->getObject()->isStatic()) {
313 }
else if (visitors && instances) {
315 std::vector<Instance*>::iterator visit =
m_visitors.begin();
317 std::set<Instance*>::iterator insfind =
m_instances.find(*visit);
319 uint16_t visitorRadius = (*visit)->getVisitorRadius();
320 std::vector<Cell*> cells;
321 std::vector<Cell*> cellsExt;
322 switch((*visit)->getVisitorShape()) {
325 (visitorRadius*2)+1, (visitorRadius*2)+1);
327 Rect sizeExt(size.
x-1, size.
y-1, size.
w+2, size.
h+2);
341 for (std::vector<Cell*>::iterator szit = cellsExt.begin(); szit != cellsExt.end(); ++szit) {
343 for (std::vector<Cell*>::iterator sit = cells.begin(); sit != cells.end(); ++sit) {
346 (*szit)->addVisitorInstance(*visit);
352 const std::vector<Instance*>& cv = (*szit)->getVisitorInstances();
392 std::vector<Instance*>::iterator it =
m_visitors.begin();
394 if (*it == instance) {
402 std::vector<Instance*>::iterator it =
m_visitors.begin();
404 if (*it == instance) {
552 std::vector<Cell*>::iterator it =
m_neighbors.begin();
577 if (*it == listener) {
585 std::vector<Cell*>::iterator it =
m_neighbors.begin();
601 if (*it == listener) {
616 (*i)->onInstanceEnteredCell(
this, instance);
630 (*i)->onInstanceExitedCell(
this, instance);
644 (*i)->onBlockingChangedCell(
this,
m_type, blocks);
void setZoneProtected(bool protect)
Mark zone on this cell as protected.
double getSpeedMultiplier(Cell *cell)
Returns speed multiplier for the cell.
double getCostMultiplier()
Returns the current cell cost.
Layer * m_layer
target layer
std::vector< Instance * > m_visitors
contains visitor instances
double getCostMultiplier(Cell *cell)
Returns cost multiplier for the cell.
bool isNeighbor(Cell *cell)
Called to check if given cell is a neighbor.
std::vector< CellChangeListener * > m_changeListeners
change listener
void setSpeedMultiplier(Cell *cell, double multi)
Sets speed multiplier for the cell.
bool m_difflayer
is target on another layer
void callOnInstanceEntered(Instance *instance)
Called when a instance entered this cell.
void addInstance(Instance *instance)
Adds a instance to this cell.
static const double MIN_CELL_Z
T h
Height of the rectangle.
const std::string & getCostId()
Returns cost id.
Layer * getLayer()
Returns the current layer.
bool isDefaultSpeed(Cell *cell)
Gets if cell uses default speed multiplier.
void removeTransition(Cell *cell)
Removes a cell as transition.
double getSpeedMultiplier()
Returns the current cell speed.
const std::vector< Instance * > & getVisitorInstances()
Returns all visitor instances on this cell.
void callOnInstanceExited(Instance *instance)
Called when a instance exited this cell.
Listener interface for changes happening on a cell.
std::set< Instance * > m_instances
void removeCellFromCost(Cell *cell)
Removes a cell from costs.
CellVisualEffect m_fowType
visual cell status
std::vector< Cell * > getCellsInRect(const Rect &rec)
Returns all cells in the rect.
A CellCache is an abstract depiction of one or a few layers and contains additional information...
void addInstances(const std::list< Instance * > &instances)
Adds instances to this cell.
void setSpeedMultiplier(double multi)
Changes the cell speed.
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.
CellCache * getCellCache()
Returns the CellCache of this layer.
void setCellType(CellTypeInfo type)
Sets blocker type.
void setBlockingUpdate(bool update)
static Logger _log(LM_AUDIO)
void registerCost(const std::string &costId, double cost)
Adds a cost with the given id and value.
void removeInstance(Instance *instance)
Removes a instance from this cell.
int32_t getCellId()
Returns the cell identifier.
void resetSpeedMultiplier(Cell *cell)
Resets the speed multiplier for the cell.
void addChangeListener(CellChangeListener *listener)
Adds new cell change listener.
bool defaultCost()
Returns if cell use default cost.
void resetCostMultiplier()
Resets the cell cost to default, 1.0.
void removeCell(Cell *cell)
Removes a cell from this zone.
void deleteTransition()
Removes the transistion from Cell and CellCache.
bool isSpecialCost()
Returns true if instance or object have special cost otherwise false.
void onCellDeleted(Cell *cell)
Called when a cell gets deleted on this cell.
void removeCellFromArea(Cell *cell)
Removes the cell from all areas.
void setFowUpdate(bool update)
#define FL_ERR(logger, msg)
Listener interface for deletions happening on a cell, used for transistions.
void setZone(Zone *zone)
Sets zone.
Simple class to hold the data for transistions.
void addNeighbor(Cell *cell)
Adds a neighbor cell to this cell.
int32_t m_coordId
holds coordinate as a unique integer id
static bool Equal(T _val1, T _val2)
Object * getObject()
Gets object where this instance is instantiated from.
Cell * getCell(const ModelCoordinate &mc)
Returns cell on this coordinate.
const std::set< Instance * > & getInstances()
Returns all instances on this cell.
void addVisitorInstance(Instance *instance)
Adds a instance as visitor to this cell.
bool isZoneProtected()
Returns whether the zone on this cell is protected.
CellTypeInfo getCellType()
Returns blocker type.
TransitionInfo * m_transition
Pointer to Transistion.
Layer * m_layer
parent layer
const std::vector< Cell * > & getNeighbors()
Returns the layer coordinates of this cell.
void removeDeleteListener(CellDeleteListener *listener)
Removes cell delete listener.
A basic cell on a CellCache.
void updateCellInfo()
Called to update cell data.
Cell(int32_t coordint, ModelCoordinate coordinate, Layer *layer)
Constructor.
CellVisualEffect getFoWType()
Returns the cell visual.
void changeInstance(Instance *instance)
Changes a instance on this cell.
const ModelCoordinate getLayerCoordinates() const
Returns the layer coordinates of this cell.
Zone * getZone()
Returns zone.
VisitorShapeInfo getVisitorShape()
Gets the shape type for a visitor.
void updateCellBlockingInfo()
void setFoWType(CellVisualEffect type)
Sets the cell visual.
void addCellToArea(const std::string &id, Cell *cell)
Adds a cell to a specific area group.
void setCellId(int32_t id)
Sets the cell identifier.
void setCostMultiplier(double multi)
Changes the cell cost.
std::vector< Cell * > getCellsInCircle(const ModelCoordinate ¢er, uint16_t radius)
Returns all cells in the circle.
ModelCoordinate m_coordinate
holds coordinate
CellTypeInfo m_type
CellType.
double getCost()
Returns cost value.
const std::string & getArea() const
Gets the area id that the instances of this object adds to their cells.
void setInserted(bool inserted)
Mark cell as inserted.
void removeCell(Cell *cell)
Removes cell from CellCache.
void removeVisitorInstance(Instance *instance)
Removes the visitor instance from this cell.
std::vector< Cell * > m_neighbors
neighbor cells
void createTransition(Layer *layer, const ModelCoordinate &mc, bool immediate=false)
Creates a transistion from this cell to the given layer and coordinates.
void resetNeighbors()
Removes all neighbors from cell.
std::vector< CellDeleteListener * > m_deleteListeners
delete listener
bool m_inserted
already inserted
void addTransition(Cell *cell)
Adds a cell as transition.
TransitionInfo * getTransition()
Returns the transition.
bool isInserted()
Returns whether the cell is part of a zone.
uint16_t getVisitorRadius()
Gets the visitor range.
bool isVisitor()
If instance is a visitor it returns true otherwise false.
bool defaultSpeed()
Returns if cell use default speed.
T w
Width of the rectangle.
void addDeleteListener(CellDeleteListener *listener)
Adds new cell delete listener.
void resetZone()
Resets zone.
An Instance is an "instantiation" of an Object at a Location.
bool m_immediate
use immediate
void resetCostMultiplier(Cell *cell)
Resets the cost multiplier for the cell.
A Zone is an abstract depiction of a CellCache or of a part of it.
ModelCoordinate m_mc
target coordinates
void removeChangeListener(CellChangeListener *listener)
Removes cell change listener.
void setCostMultiplier(Cell *cell, double multi)
Sets cost multiplier for the cell.
void callOnBlockingChanged(bool blocks)
Called when the blocking property of this cell changed.
void resetSpeedMultiplier()
Resets the cell speed to default, 1.0.