Expaneded the lua API for Regions
I've added lua hooks for both pager functor classes. Hopefully, I haven't missed any corner cases, because it took me a while to hunt everything down. One issue is that the map's save directory needs to be set in the Format class, but it'll do for now. I'll review this again when I've got more than one map running at one time. There should be enough here for a lua-driven map generator to be implemented, even if it's a bit rough. I think I'll test this out in the editor eventually, but getting the base branch's network map code going comes first. The current process is extremely convulted, so I need to document everything that I've done so far, including C++ and lua functions.
This commit is contained in:
@@ -43,6 +43,7 @@ public:
|
||||
virtual Region* SaveRegion(int x, int y) = 0;
|
||||
virtual Region* CreateRegion(int x, int y) = 0;
|
||||
virtual void UnloadRegion(int x, int y) = 0;
|
||||
virtual void UnloadAll() = 0;
|
||||
|
||||
//accessors
|
||||
//NOTE: don't change the sizes mid-program, it will cause issues
|
||||
@@ -69,7 +70,9 @@ public:
|
||||
{
|
||||
//EMPTY
|
||||
}
|
||||
~RegionPager() = default;
|
||||
~RegionPager() {
|
||||
UnloadAll();
|
||||
}
|
||||
|
||||
Region* LoadRegion(int x, int y) {
|
||||
//snap the coords
|
||||
@@ -78,7 +81,7 @@ public:
|
||||
|
||||
//load the region if possible
|
||||
Region* ptr = nullptr;
|
||||
format.Load(&ptr, x, y);
|
||||
format.Load(&ptr, regionWidth, regionHeight, regionDepth, x, y);
|
||||
if (ptr) {
|
||||
regionList.push_back(ptr);
|
||||
return ptr;
|
||||
@@ -130,6 +133,12 @@ public:
|
||||
++it;
|
||||
}
|
||||
}
|
||||
void UnloadAll() {
|
||||
for (auto& it : regionList) {
|
||||
generator.Unload(it);
|
||||
}
|
||||
regionList.clear();
|
||||
}
|
||||
|
||||
//accessors
|
||||
MapGenerator* GetGenerator() { return &generator; }
|
||||
|
||||
Reference in New Issue
Block a user