1//////////////////////////////////////////////////////////////////////
2// This file is part of Remere's Map Editor
3//////////////////////////////////////////////////////////////////////
4// Remere's Map Editor is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Remere's Map Editor is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//////////////////////////////////////////////////////////////////////
17
18#ifndef RME_SPAWN_H_
19#define RME_SPAWN_H_
20
21class Tile;
22
23class Spawn {
24public:
25 Spawn(int size = 3) :
26 size(0), selected(false) {
27 setSize(size);
28 }
29 ~Spawn() { }
30
31 Spawn* deepCopy() {
32 Spawn* copy = newd Spawn(size);
33 copy->selected = selected;
34 return copy;
35 }
36
37 bool isSelected() const {
38 return selected;
39 }
40 void select() {
41 selected = true;
42 }
43 void deselect() {
44 selected = false;
45 }
46
47 // Does not compare selection!
48 bool operator==(const Spawn& other) {
49 return size == other.size;
50 }
51 bool operator!=(const Spawn& other) {
52 return size != other.size;
53 }
54
55 void setSize(int newsize) {
56 ASSERT(size < 100);
57 size = newsize;
58 }
59 int getSize() const {
60 return size;
61 }
62
63protected:
64 int size;
65 bool selected;
66};
67
68typedef std::set<Position> SpawnPositionList;
69typedef std::list<Spawn*> SpawnList;
70
71class Spawns {
72public:
73 Spawns();
74 ~Spawns();
75
76 void addSpawn(Tile* tile);
77 void removeSpawn(Tile* tile);
78
79 SpawnPositionList::iterator begin() {
80 return spawns.begin();
81 }
82 SpawnPositionList::const_iterator begin() const {
83 return spawns.begin();
84 }
85 SpawnPositionList::iterator end() {
86 return spawns.end();
87 }
88 SpawnPositionList::const_iterator end() const {
89 return spawns.end();
90 }
91 void erase(SpawnPositionList::iterator iter) {
92 spawns.erase(iter);
93 }
94 SpawnPositionList::iterator find(Position& pos) {
95 return spawns.find(pos);
96 }
97
98private:
99 SpawnPositionList spawns;
100};
101
102#endif
103