WaypointManager is no longer a Singleton, wrote waypoint API outline

I'm planning on giving each room it's own waypoint manager, so it can
compare it's waypoints against the characters in that room alone. If it
turns out to be a good pattern, I'll do thae same for monsters.
This commit is contained in:
Kayne Ruse
2015-01-09 13:21:09 +11:00
parent be67906218
commit b391dde089
8 changed files with 146 additions and 38 deletions
+37 -12
View File
@@ -21,34 +21,59 @@
*/
#include "waypoint_manager.hpp"
int WaypointManager::Create() {
//TODO
int WaypointManager::Create(Vector2 origin, BoundingBox bounds) {
//implicitly creates the element
WaypointData& waypointData = elementMap[counter];
waypointData.origin = origin;
waypointData.bounds = bounds;
return counter++;
}
void WaypointManager::Unload(int uid) {
//TODO
elementMap.erase(uid);
}
void WaypointManager::UnloadAll() {
//TODO
elementMap.clear();
}
void WaypointManager::UnloadIf(std::function<bool(std::pair<const int, WaypointData const&>)> fn) {
//TODO
std::map<int, WaypointData>::iterator it = elementMap.begin();
while (it != elementMap.end()) {
if (fn(*it)) {
it = elementMap.erase(it);
}
else {
++it;
}
}
}
WaypointData* WaypointManager::Get(int uid) {
//TODO
std::map<int, WaypointData>::iterator it = elementMap.find(uid);
if (it == elementMap.end()) {
return nullptr;
}
return &it->second;
}
int WaypointManager::GetLoadedCount() {
//TODO
}
int WaypointManager::GetTotalCount() {
//TODO
return elementMap.size();
}
std::map<int, WaypointData>* WaypointManager::GetContainer() {
//TODO
return &elementMap;
}
//hooks
lua_State* WaypointManager::SetLuaState(lua_State* L) {
return lua = L;
}
lua_State* WaypointManager::GetLuaState() {
return lua;
}