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:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user