2017-09-02 03:45:06 -04:00
|
|
|
|
2014-02-20 09:38:37 -05:00
|
|
|
// MapManager.h
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-09-11 17:20:49 -04:00
|
|
|
#include "FunctionRef.h"
|
2014-02-20 09:38:37 -05:00
|
|
|
#include "Map.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-09-11 17:20:49 -04:00
|
|
|
using cMapCallback = cFunctionRef<bool(cMap &)>;
|
2014-02-20 09:38:37 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-23 05:55:55 -05:00
|
|
|
// tolua_begin
|
2014-02-20 09:38:37 -05:00
|
|
|
|
|
|
|
/** Manages the in-game maps of a single world - Thread safe. */
|
|
|
|
class cMapManager
|
|
|
|
{
|
|
|
|
public:
|
2014-02-23 05:55:55 -05:00
|
|
|
// tolua_end
|
2014-02-20 09:38:37 -05:00
|
|
|
|
|
|
|
cMapManager(cWorld * a_World);
|
|
|
|
|
2014-10-20 16:55:07 -04:00
|
|
|
/** Returns the map with the specified ID, nullptr if out of range.
|
2015-03-21 10:18:17 -04:00
|
|
|
WARNING: The returned map object is not thread safe. */
|
2014-02-20 09:38:37 -05:00
|
|
|
cMap * GetMapData(unsigned int a_ID);
|
|
|
|
|
2014-10-20 16:55:07 -04:00
|
|
|
/** Creates a new map. Returns nullptr on error */
|
2015-05-19 14:32:10 -04:00
|
|
|
cMap * CreateMap(int a_CenterX, int a_CenterY, unsigned int a_Scale = 3);
|
2014-02-20 09:38:37 -05:00
|
|
|
|
|
|
|
/** Calls the callback for the map with the specified ID.
|
2014-07-17 10:33:09 -04:00
|
|
|
Returns true if the map was found and the callback called, false if map not found.
|
2015-03-21 10:18:17 -04:00
|
|
|
Callback return value is ignored. */
|
2017-09-11 17:20:49 -04:00
|
|
|
bool DoWithMap(UInt32 a_ID, cMapCallback a_Callback); // Exported in ManualBindings.cpp
|
2014-02-20 09:38:37 -05:00
|
|
|
|
2015-06-30 10:50:15 -04:00
|
|
|
/** Ticks each registered map */
|
|
|
|
void TickMaps(void);
|
2014-02-20 09:38:37 -05:00
|
|
|
|
|
|
|
/** Loads the map data from the disk */
|
|
|
|
void LoadMapData(void);
|
|
|
|
|
|
|
|
/** Saves the map data to the disk */
|
|
|
|
void SaveMapData(void);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
typedef std::vector<cMap> cMapList;
|
|
|
|
|
|
|
|
cCriticalSection m_CS;
|
|
|
|
|
|
|
|
cMapList m_MapData;
|
|
|
|
|
|
|
|
cWorld * m_World;
|
|
|
|
|
2014-07-17 13:13:23 -04:00
|
|
|
}; // tolua_export
|
2014-02-20 09:38:37 -05:00
|
|
|
|
|
|
|
|
|
|
|
|