FIFE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cell.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2013 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 // Standard C++ library includes
23 
24 // 3rd party library includes
25 
26 // FIFE includes
27 // These includes are split up in two parts, separated by one empty line
28 // First block: files included from the FIFE root src directory
29 // Second block: files included from the same folder
30 #include "util/log/logger.h"
31 #include "view/visual.h"
32 
33 #include "cell.h"
34 #include "cellcache.h"
35 #include "instance.h"
36 #include "layer.h"
37 
38 namespace FIFE {
39 
40  static Logger _log(LM_STRUCTURES);
41 
42  Cell::Cell(int32_t coordint, ModelCoordinate coordinate, Layer* layer):
43  m_coordId(coordint),
44  m_coordinate(coordinate),
45  m_layer(layer),
46  m_zone(NULL),
47  m_transition(NULL),
48  m_inserted(false),
49  m_protect(false),
50  m_type(CTYPE_NO_BLOCKER),
51  m_fowType(CELLV_CONCEALED) {
52  }
53 
55  // calls CellDeleteListener, e.g. for transition
56  if (!m_deleteListeners.empty()) {
57  std::vector<CellDeleteListener*>::iterator it = m_deleteListeners.begin();
58  for (; it != m_deleteListeners.end(); ++it) {
59  if (*it) {
60  (*it)->onCellDeleted(this);
61  }
62  }
63  }
64  // remove cell from zone
65  if (m_zone) {
66  m_zone->removeCell(this);
67  }
68  // delete m_transition;
69  if (m_transition) {
71  }
72  // remove cell from cache (costs, narrow, area)
74  }
75 
76  void Cell::addInstances(const std::list<Instance*>& instances) {
77  CellCache* cache = m_layer->getCellCache();
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);
80  if (ret.second) {
81  if ((*it)->isVisitor()) {
82  uint16_t visitorRadius = (*it)->getVisitorRadius();
83  std::vector<Cell*> cells;
84  std::vector<Cell*> cellsExt;
85  switch((*it)->getVisitorShape()) {
86  case ITYPE_QUAD_SHAPE: {
87  Rect size(m_coordinate.x-visitorRadius, m_coordinate.y-visitorRadius,
88  (visitorRadius*2)+1, (visitorRadius*2)+1);
89  cells = cache->getCellsInRect(size);
90  Rect sizeExt(size.x-1, size.y-1, size.w+2, size.h+2);
91  cellsExt = cache->getCellsInRect(sizeExt);
92  }
93  break;
94 
95  case ITYPE_CIRCLE_SHAPE: {
96  cells = cache->getCellsInCircle(m_coordinate, visitorRadius);
97  cellsExt = cache->getCellsInCircle(m_coordinate, visitorRadius+1);
98  }
99  break;
100 
101  default: continue;
102  }
103  for (std::vector<Cell*>::iterator szit = cellsExt.begin(); szit != cellsExt.end(); ++szit) {
104  bool found = false;
105  for (std::vector<Cell*>::iterator sit = cells.begin(); sit != cells.end(); ++sit) {
106  if (*sit == *szit) {
107  found = true;
108  (*szit)->addVisitorInstance(*it);
109  (*szit)->setFoWType(CELLV_REVEALED);
110  break;
111  }
112  }
113  if (!found) {
114  const std::vector<Instance*>& cv = (*szit)->getVisitorInstances();
115  if (cv.empty()) {
116  (*szit)->setFoWType(CELLV_MASKED);
117  }
118  }
119  }
120  cache->setFowUpdate(true);
121  }
122  if ((*it)->isSpecialCost()) {
123  cache->registerCost((*it)->getCostId(), (*it)->getCost());
124  cache->addCellToCost((*it)->getCostId(), this);
125  }
126  if ((*it)->getObject()->getArea() != "") {
127  cache->addCellToArea((*it)->getObject()->getArea(), this);
128  }
130  }
131  }
133  }
134 
135  void Cell::addInstance(Instance* instance) {
136  std::pair<std::set<Instance*>::iterator, bool> ret = m_instances.insert(instance);
137  if (ret.second) {
138  CellCache* cache = m_layer->getCellCache();
139  if (instance->isVisitor()) {
140  uint16_t visitorRadius = instance->getVisitorRadius();
141  std::vector<Cell*> cells;
142  std::vector<Cell*> cellsExt;
143  switch(instance->getVisitorShape()) {
144  case ITYPE_QUAD_SHAPE: {
145  Rect size(m_coordinate.x-visitorRadius, m_coordinate.y-visitorRadius,
146  (visitorRadius*2)+1, (visitorRadius*2)+1);
147  cells = cache->getCellsInRect(size);
148  Rect sizeExt(size.x-1, size.y-1, size.w+2, size.h+2);
149  cellsExt = cache->getCellsInRect(sizeExt);
150  }
151  break;
152 
153  case ITYPE_CIRCLE_SHAPE: {
154  cells = cache->getCellsInCircle(m_coordinate, visitorRadius);
155  cellsExt = cache->getCellsInCircle(m_coordinate, visitorRadius+1);
156  }
157  break;
158 
159  default: break;
160  }
161  for (std::vector<Cell*>::iterator szit = cellsExt.begin(); szit != cellsExt.end(); ++szit) {
162  bool found = false;
163  for (std::vector<Cell*>::iterator sit = cells.begin(); sit != cells.end(); ++sit) {
164  if (*sit == *szit) {
165  found = true;
166  (*szit)->addVisitorInstance(instance);
167  (*szit)->setFoWType(CELLV_REVEALED);
168  break;
169  }
170  }
171  if (!found) {
172  const std::vector<Instance*>& cv = (*szit)->getVisitorInstances();
173  if (cv.empty()) {
174  (*szit)->setFoWType(CELLV_MASKED);
175  }
176  }
177  }
178  cache->setFowUpdate(true);
179  }
180  if (instance->isSpecialCost()) {
181  cache->registerCost(instance->getCostId(), instance->getCost());
182  cache->addCellToCost(instance->getCostId(), this);
183  }
184  if (instance->getObject()->getArea() != "") {
185  cache->addCellToArea(instance->getObject()->getArea(), this);
186  }
187  callOnInstanceEntered(instance);
189  }
190  }
191 
192  void Cell::changeInstance(Instance* instance) {
194  }
195 
196  void Cell::removeInstance(Instance* instance) {
197  if (m_instances.erase(instance) == 0) {
198  FL_ERR(_log, "Tried to remove an instance from cell, but given instance could not be found.");
199  return;
200  }
201  CellCache* cache = m_layer->getCellCache();
202  if (instance->isVisitor()) {
203  uint16_t visitorRadius = instance->getVisitorRadius();
204  std::vector<Cell*> cells;
205  switch(instance->getVisitorShape()) {
206  case ITYPE_QUAD_SHAPE: {
207  Rect size(m_coordinate.x-visitorRadius, m_coordinate.y-visitorRadius,
208  (visitorRadius*2)+1, (visitorRadius*2)+1);
209  cells = cache->getCellsInRect(size);
210  }
211  break;
212 
213  case ITYPE_CIRCLE_SHAPE: {
214  cells = cache->getCellsInCircle(m_coordinate, visitorRadius);
215  }
216  break;
217 
218  default: break;
219  }
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();
223  if (!cv.empty()) {
224  (*it)->setFoWType(CELLV_REVEALED);
225  } else {
226  (*it)->setFoWType(CELLV_MASKED);
227  }
228  }
229  cache->setFowUpdate(true);
230  }
231  if (instance->isSpecialCost()) {
232  cache->removeCellFromCost(instance->getCostId(), this);
233  }
234  if (instance->getObject()->getArea() != "") {
235  cache->removeCellFromArea(instance->getObject()->getArea(), this);
236  }
237  callOnInstanceExited(instance);
239  }
240 
241  bool Cell::isNeighbor(Cell* cell) {
242  std::vector<Cell*>::iterator it = m_neighbors.begin();
243  for (; it != m_neighbors.end(); ++it) {
244  if (*it == cell) {
245  return true;
246  }
247  }
248  return false;
249  }
250 
252  CellTypeInfo old_type = m_type;
254  if (!m_instances.empty()) {
255  int32_t pos = -1;
256  bool cellblock = (m_type == CTYPE_CELL_NO_BLOCKER || m_type == CTYPE_CELL_BLOCKER);
257  for (std::set<Instance*>::iterator it = m_instances.begin(); it != m_instances.end(); ++it) {
258  if (cellblock) {
259  continue;
260  }
261  uint8_t stackpos = (*it)->getCellStackPosition();
262  if (stackpos < pos) {
263  continue;
264  }
265  // update cell z
266  if (m_coordinate.z < (*it)->getLocationRef().getLayerCoordinates().z && (*it)->getObject()->isStatic()) {
267  m_coordinate.z = (*it)->getLocationRef().getLayerCoordinates().z;
268  }
269  if ((*it)->getCellStackPosition() > pos) {
270  pos = (*it)->getCellStackPosition();
271  if ((*it)->isBlocking()) {
272  if (!(*it)->getObject()->isStatic()) {
274  } else {
276  }
277  } else {
279  }
280  } else {
281  // if positions are equal then static_blockers win
282  if ((*it)->isBlocking() && m_type != CTYPE_STATIC_BLOCKER) {
283  if (!(*it)->getObject()->isStatic()) {
285  } else {
287  }
288  }
289  }
290  }
291  } else {
294  }
295  }
297  m_coordinate.z = 0;
298  }
299 
300  if (old_type != m_type) {
301  bool block = (m_type == CTYPE_STATIC_BLOCKER ||
304  callOnBlockingChanged(block);
305  }
306  }
307 
309  bool visitors = !m_visitors.empty();
310  bool instances = !m_instances.empty();
311  if (!visitors && !instances && m_fowType == CELLV_REVEALED) {
313  } else if (visitors && instances) {
314  CellCache* cache = m_layer->getCellCache();
315  std::vector<Instance*>::iterator visit = m_visitors.begin();
316  for (; visit != m_visitors.end(); ++visit) {
317  std::set<Instance*>::iterator insfind = m_instances.find(*visit);
318  if (insfind != m_instances.end()) {
319  uint16_t visitorRadius = (*visit)->getVisitorRadius();
320  std::vector<Cell*> cells;
321  std::vector<Cell*> cellsExt;
322  switch((*visit)->getVisitorShape()) {
323  case ITYPE_QUAD_SHAPE: {
324  Rect size(m_coordinate.x-visitorRadius, m_coordinate.y-visitorRadius,
325  (visitorRadius*2)+1, (visitorRadius*2)+1);
326  cells = cache->getCellsInRect(size);
327  Rect sizeExt(size.x-1, size.y-1, size.w+2, size.h+2);
328  cellsExt = cache->getCellsInRect(sizeExt);
329  }
330  break;
331 
332  case ITYPE_CIRCLE_SHAPE: {
333  cells = cache->getCellsInCircle(m_coordinate, visitorRadius);
334  cellsExt = cache->getCellsInCircle(m_coordinate, visitorRadius+1);
335  }
336  break;
337 
338  default: continue;
339  }
340 
341  for (std::vector<Cell*>::iterator szit = cellsExt.begin(); szit != cellsExt.end(); ++szit) {
342  bool found = false;
343  for (std::vector<Cell*>::iterator sit = cells.begin(); sit != cells.end(); ++sit) {
344  if (*sit == *szit) {
345  found = true;
346  (*szit)->addVisitorInstance(*visit);
347  (*szit)->setFoWType(CELLV_REVEALED);
348  break;
349  }
350  }
351  if (!found) {
352  const std::vector<Instance*>& cv = (*szit)->getVisitorInstances();
353  if (cv.empty()) {
354  (*szit)->setFoWType(CELLV_MASKED);
355  }
356  }
357  }
358  }
359  }
360  }
361  }
362 
366 
367  if (!m_deleteListeners.empty()) {
368  m_deleteListeners.erase(
369  std::remove(m_deleteListeners.begin(), m_deleteListeners.end(),
370  (CellDeleteListener*)NULL), m_deleteListeners.end());
371  }
372  if (!m_changeListeners.empty()) {
373  m_changeListeners.erase(
374  std::remove(m_changeListeners.begin(), m_changeListeners.end(),
375  (CellChangeListener*)NULL), m_changeListeners.end());
376  }
377  }
378 
380  m_fowType = type;
381  }
382 
384  return m_fowType;
385  }
386 
388  if (m_visitors.empty()) {
389  m_visitors.push_back(instance);
390  return;
391  }
392  std::vector<Instance*>::iterator it = m_visitors.begin();
393  for (; it != m_visitors.end(); ++it) {
394  if (*it == instance) {
395  return;
396  }
397  }
398  m_visitors.push_back(instance);
399  }
400 
402  std::vector<Instance*>::iterator it = m_visitors.begin();
403  for (; it != m_visitors.end(); ++it) {
404  if (*it == instance) {
405  m_visitors.erase(it);
406  break;
407  }
408  }
409  }
410 
411  const std::vector<Instance*>& Cell::getVisitorInstances() {
412  return m_visitors;
413  }
414 
416  return m_layer->getCellCache()->isDefaultCost(this);
417  }
418 
419  void Cell::setCostMultiplier(double multi) {
420  m_layer->getCellCache()->setCostMultiplier(this, multi);
421  }
422 
424  return m_layer->getCellCache()->getCostMultiplier(this);
425  }
426 
429  }
430 
432  return m_layer->getCellCache()->isDefaultSpeed(this);
433  }
434 
435  void Cell::setSpeedMultiplier(double multi) {
436  m_layer->getCellCache()->setSpeedMultiplier(this, multi);
437  }
438 
440  return m_layer->getCellCache()->getSpeedMultiplier(this);
441  }
442 
445  }
446 
448  return m_zone;
449  }
450 
451  void Cell::setZone(Zone* zone) {
452  m_zone = zone;
453  }
454 
456  m_inserted = false;
457  m_zone = NULL;
458  }
459 
461  return m_inserted;
462  }
463 
464  void Cell::setInserted(bool inserted) {
465  m_inserted = inserted;
466  }
467 
469  return m_protect;
470  }
471 
472  void Cell::setZoneProtected(bool protect) {
473  m_protect = protect;
474  }
475 
477  return m_type;
478  }
479 
481  m_type = type;
482  }
483 
484  const std::set<Instance*>& Cell::getInstances() {
485  return m_instances;
486  }
487 
488  void Cell::setCellId(int32_t id) {
489  m_coordId = id;
490  }
491 
492  int32_t Cell::getCellId() {
493  return m_coordId;
494  }
495 
497  return m_coordinate;
498  }
499 
500  void Cell::addNeighbor(Cell* cell) {
501  m_neighbors.push_back(cell);
502  }
503 
504  const std::vector<Cell*>& Cell::getNeighbors() {
505  return m_neighbors;
506  }
507 
509  m_neighbors.clear();
510  if (m_transition) {
512  if (cache) {
513  Cell* cell = cache->getCell(m_transition->m_mc);
514  if (cell) {
515  m_neighbors.push_back(cell);
516  }
517  }
518  }
519  }
520 
522  return m_layer;
523  }
524 
525  void Cell::createTransition(Layer* layer, const ModelCoordinate& mc, bool immediate) {
526  TransitionInfo* trans = new TransitionInfo(layer);
527  // if layers are the same then it's a portal
528  if (layer != m_layer) {
529  trans->m_difflayer = true;
530  }
531  trans->m_immediate = immediate;
532  trans->m_mc = mc;
533 
535 
536  m_transition = trans;
537 
538  Cell* c = layer->getCellCache()->getCell(mc);
539  if (c) {
540  m_neighbors.push_back(c);
541  c->addDeleteListener(this);
543  } else {
544  delete m_transition;
545  m_transition = NULL;
546  }
547  }
548 
550  if (m_transition) {
552  std::vector<Cell*>::iterator it = m_neighbors.begin();
553  for (; it != m_neighbors.end(); ++it) {
554  if (*it == oldc) {
555  m_neighbors.erase(it);
556  break;
557  }
558  }
559  oldc->removeDeleteListener(this);
561  delete m_transition;
562  m_transition = NULL;
563  }
564  }
565 
567  return m_transition;
568  }
569 
571  m_deleteListeners.push_back(listener);
572  }
573 
575  std::vector<CellDeleteListener*>::iterator it = m_deleteListeners.begin();
576  for (; it != m_deleteListeners.end(); ++it) {
577  if (*it == listener) {
578  *it = NULL;
579  break;
580  }
581  }
582  }
583 
584  void Cell::onCellDeleted(Cell* cell) {
585  std::vector<Cell*>::iterator it = m_neighbors.begin();
586  for (; it != m_neighbors.end(); ++it) {
587  if (*it == cell) {
589  break;
590  }
591  }
592  }
593 
595  m_changeListeners.push_back(listener);
596  }
597 
599  std::vector<CellChangeListener*>::iterator it = m_changeListeners.begin();
600  for (; it != m_changeListeners.end(); ++it) {
601  if (*it == listener) {
602  *it = NULL;
603  break;
604  }
605  }
606  }
607 
609  if (m_changeListeners.empty()) {
610  return;
611  }
612 
613  std::vector<CellChangeListener*>::iterator i = m_changeListeners.begin();
614  while (i != m_changeListeners.end()) {
615  if (*i) {
616  (*i)->onInstanceEnteredCell(this, instance);
617  }
618  ++i;
619  }
620  }
621 
623  if (m_changeListeners.empty()) {
624  return;
625  }
626 
627  std::vector<CellChangeListener*>::iterator i = m_changeListeners.begin();
628  while (i != m_changeListeners.end()) {
629  if (*i) {
630  (*i)->onInstanceExitedCell(this, instance);
631  }
632  ++i;
633  }
634  }
635 
636  void Cell::callOnBlockingChanged(bool blocks) {
637  if (m_changeListeners.empty()) {
638  return;
639  }
640 
641  std::vector<CellChangeListener*>::iterator i = m_changeListeners.begin();
642  while (i != m_changeListeners.end()) {
643  if (*i) {
644  (*i)->onBlockingChangedCell(this, m_type, blocks);
645  }
646  ++i;
647  }
648  }
649 } // FIFE
void setZoneProtected(bool protect)
Mark zone on this cell as protected.
Definition: cell.cpp:472
double getSpeedMultiplier(Cell *cell)
Returns speed multiplier for the cell.
Definition: cellcache.cpp:1213
double getCostMultiplier()
Returns the current cell cost.
Definition: cell.cpp:423
Layer * m_layer
target layer
Definition: cell.h:85
std::vector< Instance * > m_visitors
contains visitor instances
Definition: cell.h:426
double getCostMultiplier(Cell *cell)
Returns cost multiplier for the cell.
Definition: cellcache.cpp:1183
bool isNeighbor(Cell *cell)
Called to check if given cell is a neighbor.
Definition: cell.cpp:241
std::vector< CellChangeListener * > m_changeListeners
change listener
Definition: cell.h:435
void setSpeedMultiplier(Cell *cell, double multi)
Sets speed multiplier for the cell.
Definition: cellcache.cpp:1204
bool m_difflayer
is target on another layer
Definition: cell.h:91
void callOnInstanceEntered(Instance *instance)
Called when a instance entered this cell.
Definition: cell.cpp:608
void addInstance(Instance *instance)
Adds a instance to this cell.
Definition: cell.cpp:135
static const double MIN_CELL_Z
Definition: cell.h:48
T h
Height of the rectangle.
Definition: rect.h:93
const std::string & getCostId()
Returns cost id.
Definition: instance.cpp:985
Layer * getLayer()
Returns the current layer.
Definition: cell.cpp:521
bool isDefaultSpeed(Cell *cell)
Gets if cell uses default speed multiplier.
Definition: cellcache.cpp:1196
void removeTransition(Cell *cell)
Removes a cell as transition.
Definition: cellcache.cpp:1230
double getSpeedMultiplier()
Returns the current cell speed.
Definition: cell.cpp:439
const std::vector< Instance * > & getVisitorInstances()
Returns all visitor instances on this cell.
Definition: cell.cpp:411
void callOnInstanceExited(Instance *instance)
Called when a instance exited this cell.
Definition: cell.cpp:622
Listener interface for changes happening on a cell.
Definition: cell.h:110
T x
The X Coordinate.
Definition: rect.h:84
std::set< Instance * > m_instances
Definition: cell.h:423
void removeCellFromCost(Cell *cell)
Removes a cell from costs.
Definition: cellcache.cpp:1047
CellVisualEffect m_fowType
visual cell status
Definition: cell.h:420
std::vector< Cell * > getCellsInRect(const Rect &rec)
Returns all cells in the rect.
Definition: cellcache.cpp:911
A CellCache is an abstract depiction of one or a few layers and contains additional information...
Definition: cellcache.h:111
void addInstances(const std::list< Instance * > &instances)
Adds instances to this cell.
Definition: cell.cpp:76
void setSpeedMultiplier(double multi)
Changes the cell speed.
Definition: cell.cpp:435
void addCellToCost(const std::string &costId, Cell *cell)
Assigns a cell to a cost identifier.
Definition: cellcache.cpp:1027
bool isDefaultCost(Cell *cell)
Gets if cell uses default cost multiplier.
Definition: cellcache.cpp:1166
CellCache * getCellCache()
Returns the CellCache of this layer.
Definition: layer.cpp:453
void setCellType(CellTypeInfo type)
Sets blocker type.
Definition: cell.cpp:480
void setBlockingUpdate(bool update)
Definition: cellcache.cpp:1528
static Logger _log(LM_AUDIO)
void registerCost(const std::string &costId, double cost)
Adds a cost with the given id and value.
Definition: cellcache.cpp:980
void removeInstance(Instance *instance)
Removes a instance from this cell.
Definition: cell.cpp:196
int32_t getCellId()
Returns the cell identifier.
Definition: cell.cpp:492
void resetSpeedMultiplier(Cell *cell)
Resets the speed multiplier for the cell.
Definition: cellcache.cpp:1222
void addChangeListener(CellChangeListener *listener)
Adds new cell change listener.
Definition: cell.cpp:594
bool defaultCost()
Returns if cell use default cost.
Definition: cell.cpp:415
void resetCostMultiplier()
Resets the cell cost to default, 1.0.
Definition: cell.cpp:427
void removeCell(Cell *cell)
Removes a cell from this zone.
Definition: cellcache.cpp:277
void deleteTransition()
Removes the transistion from Cell and CellCache.
Definition: cell.cpp:549
bool isSpecialCost()
Returns true if instance or object have special cost otherwise false.
Definition: instance.cpp:565
void onCellDeleted(Cell *cell)
Called when a cell gets deleted on this cell.
Definition: cell.cpp:584
void removeCellFromArea(Cell *cell)
Removes the cell from all areas.
Definition: cellcache.cpp:1413
void setFowUpdate(bool update)
Definition: cellcache.cpp:1532
#define FL_ERR(logger, msg)
Definition: logger.h:73
Listener interface for deletions happening on a cell, used for transistions.
Definition: cell.h:98
unsigned char uint8_t
Definition: core.h:38
void setZone(Zone *zone)
Sets zone.
Definition: cell.cpp:451
Simple class to hold the data for transistions.
Definition: cell.h:82
void addNeighbor(Cell *cell)
Adds a neighbor cell to this cell.
Definition: cell.cpp:500
int32_t m_coordId
holds coordinate as a unique integer id
Definition: cell.h:396
static bool Equal(T _val1, T _val2)
Definition: fife_math.h:286
Object * getObject()
Gets object where this instance is instantiated from.
Definition: instance.cpp:280
Cell * getCell(const ModelCoordinate &mc)
Returns cell on this coordinate.
Definition: cellcache.cpp:706
const std::set< Instance * > & getInstances()
Returns all instances on this cell.
Definition: cell.cpp:484
void addVisitorInstance(Instance *instance)
Adds a instance as visitor to this cell.
Definition: cell.cpp:387
bool isZoneProtected()
Returns whether the zone on this cell is protected.
Definition: cell.cpp:468
uint8_t CellTypeInfo
Definition: cell.h:65
CellTypeInfo getCellType()
Returns blocker type.
Definition: cell.cpp:476
TransitionInfo * m_transition
Pointer to Transistion.
Definition: cell.h:408
A basic layer on a map.
Definition: layer.h:98
Layer * m_layer
parent layer
Definition: cell.h:402
const std::vector< Cell * > & getNeighbors()
Returns the layer coordinates of this cell.
Definition: cell.cpp:504
void removeDeleteListener(CellDeleteListener *listener)
Removes cell delete listener.
Definition: cell.cpp:574
A basic cell on a CellCache.
Definition: cell.h:136
unsigned short uint16_t
Definition: core.h:39
T y
The Y Coordinate.
Definition: rect.h:87
uint8_t CellVisualEffect
Definition: cell.h:78
bool m_protect
protected
Definition: cell.h:414
void updateCellInfo()
Called to update cell data.
Definition: cell.cpp:363
Cell(int32_t coordint, ModelCoordinate coordinate, Layer *layer)
Constructor.
Definition: cell.cpp:42
CellVisualEffect getFoWType()
Returns the cell visual.
Definition: cell.cpp:383
void changeInstance(Instance *instance)
Changes a instance on this cell.
Definition: cell.cpp:192
const ModelCoordinate getLayerCoordinates() const
Returns the layer coordinates of this cell.
Definition: cell.cpp:496
Zone * getZone()
Returns zone.
Definition: cell.cpp:447
VisitorShapeInfo getVisitorShape()
Gets the shape type for a visitor.
Definition: instance.cpp:545
void updateCellBlockingInfo()
Definition: cell.cpp:251
void setFoWType(CellVisualEffect type)
Sets the cell visual.
Definition: cell.cpp:379
void addCellToArea(const std::string &id, Cell *cell)
Adds a cell to a specific area group.
Definition: cellcache.cpp:1402
void setCellId(int32_t id)
Sets the cell identifier.
Definition: cell.cpp:488
void setCostMultiplier(double multi)
Changes the cell cost.
Definition: cell.cpp:419
std::vector< Cell * > getCellsInCircle(const ModelCoordinate &center, uint16_t radius)
Returns all cells in the circle.
Definition: cellcache.cpp:928
ModelCoordinate m_coordinate
holds coordinate
Definition: cell.h:399
CellTypeInfo m_type
CellType.
Definition: cell.h:417
A 3D Point.
Definition: point.h:202
double getCost()
Returns cost value.
Definition: instance.cpp:978
void updateCellFowInfo()
Definition: cell.cpp:308
const std::string & getArea() const
Gets the area id that the instances of this object adds to their cells.
Definition: object.cpp:334
void setInserted(bool inserted)
Mark cell as inserted.
Definition: cell.cpp:464
Zone * m_zone
parent Zone
Definition: cell.h:405
void removeCell(Cell *cell)
Removes cell from CellCache.
Definition: cellcache.cpp:721
void removeVisitorInstance(Instance *instance)
Removes the visitor instance from this cell.
Definition: cell.cpp:401
std::vector< Cell * > m_neighbors
neighbor cells
Definition: cell.h:429
void createTransition(Layer *layer, const ModelCoordinate &mc, bool immediate=false)
Creates a transistion from this cell to the given layer and coordinates.
Definition: cell.cpp:525
void resetNeighbors()
Removes all neighbors from cell.
Definition: cell.cpp:508
std::vector< CellDeleteListener * > m_deleteListeners
delete listener
Definition: cell.h:432
bool m_inserted
already inserted
Definition: cell.h:411
void addTransition(Cell *cell)
Adds a cell as transition.
Definition: cellcache.cpp:1226
~Cell()
Destructor.
Definition: cell.cpp:54
TransitionInfo * getTransition()
Returns the transition.
Definition: cell.cpp:566
bool isInserted()
Returns whether the cell is part of a zone.
Definition: cell.cpp:460
uint16_t getVisitorRadius()
Gets the visitor range.
Definition: instance.cpp:553
bool isVisitor()
If instance is a visitor it returns true otherwise false.
Definition: instance.cpp:537
bool defaultSpeed()
Returns if cell use default speed.
Definition: cell.cpp:431
T w
Width of the rectangle.
Definition: rect.h:90
void addDeleteListener(CellDeleteListener *listener)
Adds new cell delete listener.
Definition: cell.cpp:570
void resetZone()
Resets zone.
Definition: cell.cpp:455
An Instance is an &quot;instantiation&quot; of an Object at a Location.
Definition: instance.h:97
bool m_immediate
use immediate
Definition: cell.h:93
void resetCostMultiplier(Cell *cell)
Resets the cost multiplier for the cell.
Definition: cellcache.cpp:1192
A Zone is an abstract depiction of a CellCache or of a part of it.
Definition: cellcache.h:50
ModelCoordinate m_mc
target coordinates
Definition: cell.h:89
void removeChangeListener(CellChangeListener *listener)
Removes cell change listener.
Definition: cell.cpp:598
void setCostMultiplier(Cell *cell, double multi)
Sets cost multiplier for the cell.
Definition: cellcache.cpp:1174
void callOnBlockingChanged(bool blocks)
Called when the blocking property of this cell changed.
Definition: cell.cpp:636
void resetSpeedMultiplier()
Resets the cell speed to default, 1.0.
Definition: cell.cpp:443