Added mapType to BaseGenerator
This commit is contained in:
@@ -21,7 +21,8 @@
|
|||||||
*/
|
*/
|
||||||
#include "base_generator.hpp"
|
#include "base_generator.hpp"
|
||||||
|
|
||||||
BaseGenerator::BaseGenerator() {
|
BaseGenerator::BaseGenerator(MapType t) {
|
||||||
|
mapType = t;
|
||||||
for (int i = 0; i < MAP_WIDTH; i++) {
|
for (int i = 0; i < MAP_WIDTH; i++) {
|
||||||
for (int j = 0; j < MAP_HEIGHT; j++) {
|
for (int j = 0; j < MAP_HEIGHT; j++) {
|
||||||
chunks[i][j].type = TerrainType::NONE;
|
chunks[i][j].type = TerrainType::NONE;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#ifndef BASEGENERATOR_HPP_
|
#ifndef BASEGENERATOR_HPP_
|
||||||
#define BASEGENERATOR_HPP_
|
#define BASEGENERATOR_HPP_
|
||||||
|
|
||||||
|
#include "map_type.hpp"
|
||||||
#include "chunk_data.hpp"
|
#include "chunk_data.hpp"
|
||||||
|
|
||||||
#include "lua/lua.hpp"
|
#include "lua/lua.hpp"
|
||||||
@@ -31,17 +32,22 @@ constexpr int MAP_HEIGHT = 256;
|
|||||||
|
|
||||||
class BaseGenerator {
|
class BaseGenerator {
|
||||||
public:
|
public:
|
||||||
BaseGenerator();
|
|
||||||
virtual ~BaseGenerator();
|
virtual ~BaseGenerator();
|
||||||
|
|
||||||
//accessors and mutators
|
//accessors and mutators
|
||||||
virtual ChunkData* GetChunk(int x, int y) { return &chunks[x][y]; }
|
virtual ChunkData* GetChunk(int x, int y) { return &chunks[x][y]; }
|
||||||
|
|
||||||
|
MapType GetMapType() { return mapType; }
|
||||||
|
|
||||||
lua_State* SetLuaState(lua_State* L) { return luaState = L; }
|
lua_State* SetLuaState(lua_State* L) { return luaState = L; }
|
||||||
lua_State* GetLuaState() { return luaState; }
|
lua_State* GetLuaState() { return luaState; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
BaseGenerator() = delete;
|
||||||
|
BaseGenerator(MapType t);
|
||||||
|
|
||||||
ChunkData chunks[MAP_WIDTH][MAP_HEIGHT];
|
ChunkData chunks[MAP_WIDTH][MAP_HEIGHT];
|
||||||
|
MapType mapType = MapType::NONE;
|
||||||
lua_State* luaState = nullptr;
|
lua_State* luaState = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "caves_generator.hpp"
|
#include "caves_generator.hpp"
|
||||||
|
|
||||||
CavesGenerator::CavesGenerator() {
|
CavesGenerator::CavesGenerator() : BaseGenerator(MapType::CAVES) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,6 @@
|
|||||||
|
|
||||||
#include "base_generator.hpp"
|
#include "base_generator.hpp"
|
||||||
|
|
||||||
#define CAVES_GENERATOR_PSEUDOINDEX "CavesGenerator"
|
|
||||||
|
|
||||||
class CavesGenerator : public BaseGenerator {
|
class CavesGenerator : public BaseGenerator {
|
||||||
public:
|
public:
|
||||||
CavesGenerator();
|
CavesGenerator();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "forests_generator.hpp"
|
#include "forests_generator.hpp"
|
||||||
|
|
||||||
ForestsGenerator::ForestsGenerator() {
|
ForestsGenerator::ForestsGenerator() : BaseGenerator(MapType::FORESTS) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,6 @@
|
|||||||
|
|
||||||
#include "base_generator.hpp"
|
#include "base_generator.hpp"
|
||||||
|
|
||||||
#define FORESTS_GENERATOR_PSEUDOINDEX "ForestsGenerator"
|
|
||||||
|
|
||||||
class ForestsGenerator : public BaseGenerator {
|
class ForestsGenerator : public BaseGenerator {
|
||||||
public:
|
public:
|
||||||
ForestsGenerator();
|
ForestsGenerator();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "overworld_generator.hpp"
|
#include "overworld_generator.hpp"
|
||||||
|
|
||||||
OverworldGenerator::OverworldGenerator() {
|
OverworldGenerator::OverworldGenerator() : BaseGenerator(MapType::OVERWORLD) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,6 @@
|
|||||||
|
|
||||||
#include "base_generator.hpp"
|
#include "base_generator.hpp"
|
||||||
|
|
||||||
#define OVERWORLD_GENERATOR_PSEUDOINDEX "OverworldGenerator"
|
|
||||||
|
|
||||||
class OverworldGenerator : public BaseGenerator {
|
class OverworldGenerator : public BaseGenerator {
|
||||||
public:
|
public:
|
||||||
OverworldGenerator();
|
OverworldGenerator();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "ruins_generator.hpp"
|
#include "ruins_generator.hpp"
|
||||||
|
|
||||||
RuinsGenerator::RuinsGenerator() {
|
RuinsGenerator::RuinsGenerator() : BaseGenerator(MapType::RUINS) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,6 @@
|
|||||||
|
|
||||||
#include "base_generator.hpp"
|
#include "base_generator.hpp"
|
||||||
|
|
||||||
#define RUINS_GENERATOR_PSEUDOINDEX "RuinsGenerator"
|
|
||||||
|
|
||||||
class RuinsGenerator : public BaseGenerator {
|
class RuinsGenerator : public BaseGenerator {
|
||||||
public:
|
public:
|
||||||
RuinsGenerator();
|
RuinsGenerator();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "towers_generator.hpp"
|
#include "towers_generator.hpp"
|
||||||
|
|
||||||
TowersGenerator::TowersGenerator() {
|
TowersGenerator::TowersGenerator() : BaseGenerator(MapType::TOWERS) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,6 @@
|
|||||||
|
|
||||||
#include "base_generator.hpp"
|
#include "base_generator.hpp"
|
||||||
|
|
||||||
#define TOWERS_GENERATOR_PSEUDOINDEX "TowersGenerator"
|
|
||||||
|
|
||||||
class TowersGenerator : public BaseGenerator {
|
class TowersGenerator : public BaseGenerator {
|
||||||
public:
|
public:
|
||||||
TowersGenerator();
|
TowersGenerator();
|
||||||
|
|||||||
@@ -23,11 +23,12 @@
|
|||||||
#define MAPTYPE_HPP_
|
#define MAPTYPE_HPP_
|
||||||
|
|
||||||
enum class MapType {
|
enum class MapType {
|
||||||
OVERWORLD = 0,
|
NONE,
|
||||||
RUINS = 1,
|
OVERWORLD,
|
||||||
TOWERS = 2,
|
RUINS,
|
||||||
FORESTS = 3,
|
TOWERS,
|
||||||
CAVES = 4,
|
FORESTS,
|
||||||
|
CAVES,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user