2012-06-29 16:44:26 +02:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
// This file is part of Remere's Map Editor
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2020-07-30 11:42:28 -03:00
|
|
|
// Remere's Map Editor is free software: you can redistribute it and/or modify
|
2012-06-29 16:44:26 +02:00
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
2016-09-29 19:24:45 -03:00
|
|
|
//
|
2020-07-30 11:42:28 -03:00
|
|
|
// Remere's Map Editor is distributed in the hope that it will be useful,
|
2012-06-29 16:44:26 +02:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2020-07-30 11:42:28 -03:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2012-06-29 16:44:26 +02:00
|
|
|
// GNU General Public License for more details.
|
2016-09-29 19:24:45 -03:00
|
|
|
//
|
2012-06-29 16:44:26 +02:00
|
|
|
// You should have received a copy of the GNU General Public License
|
2020-07-30 11:42:28 -03:00
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2012-06-29 16:44:26 +02:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
|
|
#include "tile.h"
|
2021-05-25 00:29:12 -03:00
|
|
|
#include "spawn_monster.h"
|
2012-06-29 16:44:26 +02:00
|
|
|
|
2023-10-09 23:02:37 -03:00
|
|
|
SpawnMonster::SpawnMonster(int size) :
|
|
|
|
|
size(0),
|
2023-10-09 19:12:16 -07:00
|
|
|
selected(false) {
|
2023-10-09 23:02:37 -03:00
|
|
|
setSize(size);
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
SpawnMonster* SpawnMonster::deepCopy() const {
|
2023-10-09 23:02:37 -03:00
|
|
|
SpawnMonster* copy = new SpawnMonster(size);
|
|
|
|
|
copy->selected = selected;
|
|
|
|
|
return copy;
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
void SpawnsMonster::addSpawnMonster(Tile* tile) {
|
2021-05-25 00:29:12 -03:00
|
|
|
ASSERT(tile->spawnMonster);
|
2014-03-01 14:44:11 +01:00
|
|
|
|
2021-05-25 00:29:12 -03:00
|
|
|
auto it = spawnsMonster.insert(tile->getPosition());
|
2014-03-01 14:44:11 +01:00
|
|
|
ASSERT(it.second);
|
2012-06-29 16:44:26 +02:00
|
|
|
}
|
|
|
|
|
|
2021-05-25 00:29:12 -03:00
|
|
|
void SpawnsMonster::removeSpawnMonster(Tile* tile) {
|
|
|
|
|
ASSERT(tile->spawnMonster);
|
|
|
|
|
spawnsMonster.erase(tile->getPosition());
|
2012-06-29 16:44:26 +02:00
|
|
|
#if 0
|
2021-05-25 00:29:12 -03:00
|
|
|
SpawnMonsterPositionList::iterator iter = begin();
|
2012-06-29 16:44:26 +02:00
|
|
|
while(iter != end()) {
|
|
|
|
|
if(*iter == tile->getPosition()) {
|
2021-05-25 00:29:12 -03:00
|
|
|
spawnsMonster.erase(iter);
|
2012-06-29 16:44:26 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
++iter;
|
|
|
|
|
}
|
|
|
|
|
ASSERT(false);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 19:12:16 -07:00
|
|
|
std::ostream &operator<<(std::ostream &os, const SpawnMonster &spawnMonster) {
|
2021-05-25 00:29:12 -03:00
|
|
|
os << &spawnMonster << ":: -> " << spawnMonster.getSize() << std::endl;
|
2012-06-29 16:44:26 +02:00
|
|
|
return os;
|
|
|
|
|
}
|