11
15
// You should have received a copy of the GNU General Public License
12
16
// along with this program; if not, write to the Free Software
13
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15
20
#ifndef TEMPLELIST_H
16
21
#define TEMPLELIST_H
18
23
#include <sigc++/trackable.h>
19
#include "ObjectList.h"
24
#include "LocationList.h"
20
25
#include "temple.h"
22
/** The templelist just keeps track of the temples located on the game map. It
23
* is also implemented as a singleton since many classes use it for looking up
27
class Templelist : public ObjectList<Temple>, public sigc::trackable
27
//! A list of Temple objects on the game map.
29
* The templelist keeps track of the temples located on the game map. It
30
* is implemented as a singleton because many classes use it for looking
33
class Templelist : public LocationList<Temple>, public sigc::trackable
30
//! Return the singleton instance. Create a new one if needed.
36
//! Return the singleton instance. Create a new one if needed.
31
37
static Templelist* getInstance();
33
//! Load the singleton instance with the given savegame
39
//! Load the temple list from an opened saved-game file.
41
* @param helper The opened saved-game file to load the list of
44
* @return The list of temples.
34
46
static Templelist* getInstance(XML_Helper* helper);
36
//! Explicitely delete the singleton instance
48
//! Explicitly delete the singleton instance.
37
49
static void deleteInstance();
40
//! Saves the game data. See XML_Helper for details.
51
//! Saves the temple data to an opened saved-game file.
41
52
bool save(XML_Helper* helper) const;
43
// Find the nearest temple
44
Temple* getNearestTemple(const Vector<int>& pos);
45
Temple* getNearestTemple(const Vector<int>& pos, int dist);
54
//! Find the nearest temple that is not obscured by fog.
56
* Scan through all temples, searching for the closest one that is
57
* not covered by fog-of-war on a hidden map.
59
* @param pos The position to find the nearest temple from.
61
* @return A pointer to the nearest temple that is not obscured by fog.
46
63
Temple* getNearestVisibleTemple(const Vector<int>& pos);
65
//! Find the nearest temple that is unobscured and is not too far away.
67
* Scan through all the temples, searching for the closest one that
68
* is not covered by fog-of-war on a hidden map, but is not farther
69
* away than a given distance.
71
* @param pos The position to find the nearest temple from.
72
* @param dist The number of tiles away that is deemed "too far".
74
* @return A pointer to the nearest temple that is not obscured by fog
75
* and is within the prescribed number of tiles. Returns NULL
76
* if no temple could be found.
47
78
Temple* getNearestVisibleTemple(const Vector<int>& pos, int dist);
50
//! Default constructor
81
//! Default constructor.
53
//! Loading constructor
84
//! Loading constructor.
86
* Load the list of temples from an opened saved-game file.
88
* @param helper The opened saved-game file to load the temples from.
54
90
Templelist(XML_Helper* helper);
57
//! Callback for loading
93
//! Callback for loading temple objects from opened saved game files.
58
94
bool load(std::string tag, XML_Helper* helper);
96
//! A static pointer for the singleton instance.
60
97
static Templelist* s_instance;