From e8db7eeded49f5a261413e7f8eb62428d19ddfe3 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Thu, 15 Dec 2016 22:04:54 +1100 Subject: [PATCH] Finished draft of Region-Pager-Base.md --- Home.md | 2 +- Region-Pager-Base.md | 87 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 Region-Pager-Base.md diff --git a/Home.md b/Home.md index 6ccd449..d2960db 100644 --- a/Home.md +++ b/Home.md @@ -14,7 +14,7 @@ This is a breakdown of each class, it's methods and it's APIs, for quick lookup. * [Region](Region) * [Region API](Region-API) -* Region Pager Base +* [Region Pager Base](Region-Pager-Base) * Region Pager Lua * Region Pager API * Tile Sheet diff --git a/Region-Pager-Base.md b/Region-Pager-Base.md new file mode 100644 index 0000000..7085045 --- /dev/null +++ b/Region-Pager-Base.md @@ -0,0 +1,87 @@ +# Methods + +```C++ +Region::type_t SetTile(int x, int y, int z, Region::type_t v); +``` + +This takes an `x`, `y`, and `z` zero indexed parameter, indicating a tile in the map, and a layer. `v` is the new value for that tile. This function retreives a region with `GetRegion`, then it calls that region's `SetTile`. + +```C++ +Region::type_t GetTile(int x, int y, int z); +``` + +This takes an `x`, `y`, and `z` zero indexed parameter, indicating a tile in the map, and a layer. It will return that Region::tile_t. This function retreives a region with `GetRegion`, then it calls that region's `GetTile`. + +```C++ +bool SetSolid(int x, int y, int b); +``` + +This takes an `x` and `y` zero indexed parameter, indicating a tile in the map. `b` indicates whether it should be solid (true) or not (false). This function retreives a region with `GetRegion`, then it calls that region's `SetSolid`. + +```C++ +bool GetSolid(int x, int y); +``` + +This takes an `x` and `y` zero indexed parameter, indicating a tile in the map. It returns whether it's solid (true) or not (false). This function retreives a region with `GetRegion`, then it calls that region's `GetSolid`. + +```C++ +Region* GetRegion(int x, int y); +``` + +This is the universal function for accessing a region object. You can pass any integer value as `x` and `y`, and the correct region will be retrieved. First, it calls `FindRegion`. If that fails, it calls `LoadRegion`. Finally, if that fails, it calls `CreateRegion` as a last resort. Therefore, this will always return a `Region` object. + +```C++ +Region* FindRegion(int x, int y); +``` + +`x` and `y` must be multiples of `REGION_WIDTH` and `REGION_HEIGHT` respectfully. It will retrieve any existing region with the coordiantes `x` and `y`, or it will return `nullptr`. + +```C++ +Region* PushRegion(Region* const); +``` + +This will push any `Region` object into the RegionPagerBase. + +```C++ +Region* LoadRegion(int x, int y); +``` + +This will fail, and return nullptr. It's intended for overwriting by RegionPagerLua. + +```C++ +Region* SaveRegion(int x, int y); +``` + +This will fail, and return nullptr. It's intended for overwriting by RegionPagerLua. + +```C++ +Region* CreateRegion(int x, int y); +``` + +This will create a `Region` object with the coordinates `x` and `y`, add it to the RegionPagerBase, and return it. If an object with those coordinates already exist, it will throw an exception. + +```C++ +void UnloadIf(std::function fn); +``` + +This takes a function with the prototype `bool f(Region const&)` as a parameter. Each `Region` object that causes that function to return true will be destroyed and removed from the RegionPagerBase. + +```C++ +void UnloadAll(); +``` + +This will destroy and unload all `Region` objects. + +```C++ +void ForEach(std::function fn); +``` + +This takes a function with the prototype `void f(Region&)` as a parameter, and passes each `Region` object to it. This is used for applying a certain function to each object inside RegionPagerLua. + +```C++ +std::list* GetContainer(); +``` + +This is an OO-breaking utility function, allowing access to the internal container which holds the Region objects. + +This method is not officially supported. \ No newline at end of file