2022-11-06 16:59:30 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <modules/Maps.h>
|
|
|
|
#include <df/coord.h>
|
|
|
|
#include <df/tiletype.h>
|
2022-11-21 13:39:26 -07:00
|
|
|
#include <modules/EventManager.h> //hash functions (they should probably get moved at this point, the ones that aren't specifically for EM anyway)
|
2022-11-06 16:59:30 -07:00
|
|
|
|
2022-11-21 13:39:26 -07:00
|
|
|
#include <unordered_map>
|
2022-11-06 16:59:30 -07:00
|
|
|
|
|
|
|
class TileCache {
|
|
|
|
private:
|
|
|
|
TileCache() = default;
|
2022-11-21 13:39:26 -07:00
|
|
|
std::unordered_map<df::coord, df::tiletype> locations;
|
2022-11-06 16:59:30 -07:00
|
|
|
public:
|
|
|
|
static TileCache& Get() {
|
|
|
|
static TileCache instance;
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cache(const df::coord &pos, df::tiletype type) {
|
|
|
|
locations.emplace(pos, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
void uncache(const df::coord &pos) {
|
|
|
|
locations.erase(pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasChanged(const df::coord &pos, const df::tiletype &type) {
|
2022-11-21 13:39:26 -07:00
|
|
|
return locations.count(pos) && type != locations[pos];
|
2022-11-06 16:59:30 -07:00
|
|
|
}
|
|
|
|
};
|