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)->isSpecialSpeed()) {
129 if ((*it)->getObject()->getArea() !=
"") {
139 std::pair<std::set<Instance*>::iterator,
bool> ret =
m_instances.insert(instance);
144 std::vector<Cell*> cells;
145 std::vector<Cell*> cellsExt;
149 (visitorRadius*2)+1, (visitorRadius*2)+1);
151 Rect sizeExt(size.
x-1, size.
y-1, size.
w+2, size.
h+2);
164 for (std::vector<Cell*>::iterator szit = cellsExt.begin(); szit != cellsExt.end(); ++szit) {
166 for (std::vector<Cell*>::iterator sit = cells.begin(); sit != cells.end(); ++sit) {
169 (*szit)->addVisitorInstance(instance);
175 const std::vector<Instance*>& cv = (*szit)->getVisitorInstances();
204 FL_ERR(
_log,
"Tried to remove an instance from cell, but given instance could not be found.");
210 std::vector<Cell*> cells;
214 (visitorRadius*2)+1, (visitorRadius*2)+1);
226 for (std::vector<Cell*>::iterator it = cells.begin(); it != cells.end(); ++it) {
227 (*it)->removeVisitorInstance(instance);
228 const std::vector<Instance*>& cv = (*it)->getVisitorInstances();
244 std::set<Instance*>::iterator it =
m_instances.begin();
246 if ((*it)->isSpecialSpeed()) {
261 std::vector<Cell*>::iterator it =
m_neighbors.begin();
280 uint8_t stackpos = (*it)->getCellStackPosition();
281 if (stackpos < pos) {
285 if (
m_coordinate.
z < (*it)->getLocationRef().getLayerCoordinates().z && (*it)->getObject()->isStatic()) {
286 m_coordinate.
z = (*it)->getLocationRef().getLayerCoordinates().z;
288 if ((*it)->getCellStackPosition() > pos) {
289 pos = (*it)->getCellStackPosition();
290 if ((*it)->isBlocking()) {
291 if (!(*it)->getObject()->isStatic()) {
302 if (!(*it)->getObject()->isStatic()) {
332 }
else if (visitors && instances) {
334 std::vector<Instance*>::iterator visit =
m_visitors.begin();
336 std::set<Instance*>::iterator insfind =
m_instances.find(*visit);
338 uint16_t visitorRadius = (*visit)->getVisitorRadius();
339 std::vector<Cell*> cells;
340 std::vector<Cell*> cellsExt;
341 switch((*visit)->getVisitorShape()) {
344 (visitorRadius*2)+1, (visitorRadius*2)+1);
346 Rect sizeExt(size.
x-1, size.
y-1, size.
w+2, size.
h+2);
360 for (std::vector<Cell*>::iterator szit = cellsExt.begin(); szit != cellsExt.end(); ++szit) {
362 for (std::vector<Cell*>::iterator sit = cells.begin(); sit != cells.end(); ++sit) {
365 (*szit)->addVisitorInstance(*visit);
371 const std::vector<Instance*>& cv = (*szit)->getVisitorInstances();
411 std::vector<Instance*>::iterator it =
m_visitors.begin();
413 if (*it == instance) {
421 std::vector<Instance*>::iterator it =
m_visitors.begin();
423 if (*it == instance) {
571 std::vector<Cell*>::iterator it =
m_neighbors.begin();
596 if (*it == listener) {
604 std::vector<Cell*>::iterator it =
m_neighbors.begin();
620 if (*it == listener) {
635 (*i)->onInstanceEnteredCell(
this, instance);
649 (*i)->onInstanceExitedCell(
this, instance);
663 (*i)->onBlockingChangedCell(
this,
m_type, blocks);
void setZoneProtected(bool protect)
Mark zone on this cell as protected.
std::string getArea() const
Gets the area id that the instances of this object adds to their cells.
double getSpeedMultiplier(Cell *cell)
Returns speed multiplier for the cell.
std::string getCostId()
Returns cost id.
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.
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.
bool isSpecialSpeed()
Returns true if instance or object have special speed modifier otherwise false.
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.
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.
double getSpeed()
Returns speed modifier.
void resetSpeedMultiplier()
Resets the cell speed to default, 1.0.