

Definition at line 14 of file MarkMask.h.
Public Member Functions | |
| MarkMask (Cube *model, Field *field) | |
| Cube::t_models | getResist (Dir::eDir dir) const |
| Return others which resist us to move this direction. | |
| Cube::t_models | getPlacedResist (const V2 &loc) const |
| Return others which resist at given location. | |
| void | mask () |
| Write our position to the field. | |
| void | unmask () |
| Clear our position from the field. | |
| Dir::eDir | getBorderDir () const |
| Returns dir to out of room. | |
|
||||||||||||
|
Definition at line 18 of file MarkMask.cpp. 00019 {
00020 m_model = model;
00021 m_field = field;
00022 }
|
|
|
Returns dir to out of room. The direction must be without resist.
Definition at line 104 of file MarkMask.cpp. 00105 {
00106 V2 loc = m_model->getLocation();
00107 const Shape *shape = m_model->shape();
00108 Shape::const_iterator end = shape->marksEnd();
00109 for (Shape::const_iterator i = shape->marksBegin(); i != end; ++i) {
00110 V2 mark = loc.plus(*i);
00111 if (mark.getX() == 0 && isBorderDir(Dir::DIR_LEFT)) {
00112 return Dir::DIR_LEFT;
00113 }
00114 else if (mark.getX() == m_field->getW() - 1 &&
00115 isBorderDir(Dir::DIR_RIGHT))
00116 {
00117 return Dir::DIR_RIGHT;
00118 }
00119 else if (mark.getY() == 0 && isBorderDir(Dir::DIR_UP)) {
00120 return Dir::DIR_UP;
00121 }
00122 else if (mark.getY() == m_field->getH() - 1 &&
00123 isBorderDir(Dir::DIR_DOWN))
00124 {
00125 return Dir::DIR_DOWN;
00126 }
00127 }
00128
00129 return Dir::DIR_NO;
00130 }
|
|
|
Return others which resist at given location. Pointers to NULL and own model are not included.
Definition at line 46 of file MarkMask.cpp. 00047 {
00048 Cube::t_models models;
00049 const Shape *shape = m_model->shape();
00050 Shape::const_iterator end = shape->marksEnd();
00051 for (Shape::const_iterator i = shape->marksBegin(); i != end; ++i) {
00052 V2 mark = loc.plus(*i);
00053
00054 Cube *resist = m_field->getModel(mark);
00055 if (NULL != resist && m_model != resist) {
00056 models.push_back(resist);
00057 }
00058 }
00059
00060 std::sort(models.begin(), models.end());
00061 Cube::t_models::iterator last = std::unique(models.begin(), models.end());
00062 models.erase(last, models.end());
00063
00064 return models;
00065 }
|
|
|
Return others which resist us to move this direction. Pointers to NULL and own model are not included.
Definition at line 31 of file MarkMask.cpp. 00032 {
00033 V2 shift = Dir::dir2xy(dir);
00034 V2 shift_loc = shift.plus(m_model->getLocation());
00035
00036 return getPlacedResist(shift_loc);
00037 }
|
|
|
Write our position to the field.
Definition at line 71 of file MarkMask.cpp. 00072 {
00073 writeModel(m_model);
00074 }
|
|
|
Clear our position from the field.
Definition at line 80 of file MarkMask.cpp. 00081 {
00082 writeModel(NULL);
00083 }
|
1.4.2