Add files via upload
This commit is contained in:
@@ -7,7 +7,6 @@ struct voxel;
|
|||||||
class Content;
|
class Content;
|
||||||
|
|
||||||
class WorldGenerator {
|
class WorldGenerator {
|
||||||
protected:
|
|
||||||
blockid_t const idStone;
|
blockid_t const idStone;
|
||||||
blockid_t const idDirt;
|
blockid_t const idDirt;
|
||||||
blockid_t const idGrassBlock;
|
blockid_t const idGrassBlock;
|
||||||
@@ -20,7 +19,7 @@ protected:
|
|||||||
blockid_t const idBazalt;
|
blockid_t const idBazalt;
|
||||||
public:
|
public:
|
||||||
WorldGenerator(const Content* content);
|
WorldGenerator(const Content* content);
|
||||||
virtual void generate(voxel* voxels, int x, int z, int seed);
|
void generate(voxel* voxels, int x, int z, int seed);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* VOXELS_WORLDGENERATOR_H_ */
|
#endif /* VOXELS_WORLDGENERATOR_H_ */
|
||||||
@@ -318,6 +318,10 @@ const char* Window::getClipboardText() {
|
|||||||
return glfwGetClipboardString(window);
|
return glfwGetClipboardString(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::setClipboardText(const char* text) {
|
||||||
|
glfwSetClipboardString(window, text);
|
||||||
|
}
|
||||||
|
|
||||||
bool Window::tryToMaximize(GLFWwindow* window, GLFWmonitor* monitor) {
|
bool Window::tryToMaximize(GLFWwindow* window, GLFWmonitor* monitor) {
|
||||||
glm::ivec4 windowFrame(0);
|
glm::ivec4 windowFrame(0);
|
||||||
glm::ivec4 workArea(0);
|
glm::ivec4 workArea(0);
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ public:
|
|||||||
static void setBgColor(glm::vec4 color);
|
static void setBgColor(glm::vec4 color);
|
||||||
static double time();
|
static double time();
|
||||||
static const char* getClipboardText();
|
static const char* getClipboardText();
|
||||||
|
static void setClipboardText(const char* text);
|
||||||
static DisplaySettings* getSettings();
|
static DisplaySettings* getSettings();
|
||||||
|
|
||||||
static void setBlendMode(blendmode mode);
|
static void setBlendMode(blendmode mode);
|
||||||
|
|||||||
+21
-50
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include "Level.h"
|
#include "Level.h"
|
||||||
#include "../files/WorldFiles.h"
|
#include "../files/WorldFiles.h"
|
||||||
#include "../world/WorldTypes.h"
|
|
||||||
#include "../content/Content.h"
|
#include "../content/Content.h"
|
||||||
#include "../content/ContentLUT.h"
|
#include "../content/ContentLUT.h"
|
||||||
#include "../voxels/Chunk.h"
|
#include "../voxels/Chunk.h"
|
||||||
@@ -35,23 +34,6 @@ World::World(
|
|||||||
wfile = new WorldFiles(directory, settings.debug);
|
wfile = new WorldFiles(directory, settings.debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
World::World(
|
|
||||||
std::string name,
|
|
||||||
std::string type,
|
|
||||||
fs::path directory,
|
|
||||||
uint64_t seed,
|
|
||||||
EngineSettings& settings,
|
|
||||||
const Content* content,
|
|
||||||
const std::vector<ContentPack> packs)
|
|
||||||
: name(name),
|
|
||||||
type(type),
|
|
||||||
seed(seed),
|
|
||||||
settings(settings),
|
|
||||||
content(content),
|
|
||||||
packs(packs) {
|
|
||||||
wfile = new WorldFiles(directory, settings.debug);
|
|
||||||
}
|
|
||||||
|
|
||||||
World::~World(){
|
World::~World(){
|
||||||
delete wfile;
|
delete wfile;
|
||||||
}
|
}
|
||||||
@@ -83,13 +65,12 @@ void World::write(Level* level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Level* World::create(std::string name,
|
Level* World::create(std::string name,
|
||||||
std::string type,
|
|
||||||
fs::path directory,
|
fs::path directory,
|
||||||
uint64_t seed,
|
uint64_t seed,
|
||||||
EngineSettings& settings,
|
EngineSettings& settings,
|
||||||
const Content* content,
|
const Content* content,
|
||||||
const std::vector<ContentPack>& packs) {
|
const std::vector<ContentPack>& packs) {
|
||||||
auto world = new World(name, type, directory, seed, settings, content, packs);
|
auto world = new World(name, directory, seed, settings, content, packs);
|
||||||
auto level = new Level(world, content, settings);
|
auto level = new Level(world, content, settings);
|
||||||
auto inventory = level->player->getInventory();
|
auto inventory = level->player->getInventory();
|
||||||
inventory->setId(world->getNextInventoryId());
|
inventory->setId(world->getNextInventoryId());
|
||||||
@@ -150,55 +131,45 @@ uint64_t World::getSeed() const {
|
|||||||
return seed;
|
return seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string World::getType() const {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<ContentPack>& World::getPacks() const {
|
const std::vector<ContentPack>& World::getPacks() const {
|
||||||
return packs;
|
return packs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::deserialize(dynamic::Map* root) {
|
void World::deserialize(dynamic::Map* root) {
|
||||||
name = root->getStr("name", name);
|
name = root->getStr("name", name);
|
||||||
type = root->getStr("type", type);
|
|
||||||
seed = root->getInt("seed", seed);
|
seed = root->getInt("seed", seed);
|
||||||
|
|
||||||
if(type == "") {
|
auto verobj = root->map("version");
|
||||||
type = WorldTypes::getDefaultWorldType();
|
if (verobj) {
|
||||||
}
|
int major=0, minor=-1;
|
||||||
|
verobj->num("major", major);
|
||||||
|
verobj->num("minor", minor);
|
||||||
|
std::cout << "world version: " << major << "." << minor << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
auto verobj = root->map("version");
|
auto timeobj = root->map("time");
|
||||||
if (verobj) {
|
if (timeobj) {
|
||||||
int major=0, minor=-1;
|
timeobj->num("day-time", daytime);
|
||||||
verobj->num("major", major);
|
timeobj->num("day-time-speed", daytimeSpeed);
|
||||||
verobj->num("minor", minor);
|
|
||||||
std::cout << "world version: " << major << "." << minor << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto timeobj = root->map("time");
|
|
||||||
if (timeobj) {
|
|
||||||
timeobj->num("day-time", daytime);
|
|
||||||
timeobj->num("day-time-speed", daytimeSpeed);
|
|
||||||
timeobj->num("total-time", totalTime);
|
timeobj->num("total-time", totalTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
nextInventoryId = root->getNum("next-inventory-id", 2);
|
nextInventoryId = root->getNum("next-inventory-id", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<dynamic::Map> World::serialize() const {
|
std::unique_ptr<dynamic::Map> World::serialize() const {
|
||||||
auto root = std::make_unique<dynamic::Map>();
|
auto root = std::make_unique<dynamic::Map>();
|
||||||
|
|
||||||
auto& versionobj = root->putMap("version");
|
auto& versionobj = root->putMap("version");
|
||||||
versionobj.put("major", ENGINE_VERSION_MAJOR);
|
versionobj.put("major", ENGINE_VERSION_MAJOR);
|
||||||
versionobj.put("minor", ENGINE_VERSION_MINOR);
|
versionobj.put("minor", ENGINE_VERSION_MINOR);
|
||||||
|
|
||||||
root->put("name", name);
|
root->put("name", name);
|
||||||
root->put("type", type);
|
root->put("seed", seed);
|
||||||
root->put("seed", seed);
|
|
||||||
|
|
||||||
auto& timeobj = root->putMap("time");
|
auto& timeobj = root->putMap("time");
|
||||||
timeobj.put("day-time", daytime);
|
timeobj.put("day-time", daytime);
|
||||||
timeobj.put("day-time-speed", daytimeSpeed);
|
timeobj.put("day-time-speed", daytimeSpeed);
|
||||||
timeobj.put("total-time", totalTime);
|
timeobj.put("total-time", totalTime);
|
||||||
|
|
||||||
root->put("next-inventory-id", nextInventoryId);
|
root->put("next-inventory-id", nextInventoryId);
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ public:
|
|||||||
|
|
||||||
class World : public Serializable {
|
class World : public Serializable {
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string type;
|
|
||||||
uint64_t seed;
|
uint64_t seed;
|
||||||
EngineSettings& settings;
|
EngineSettings& settings;
|
||||||
const Content* const content;
|
const Content* const content;
|
||||||
@@ -53,15 +52,6 @@ public:
|
|||||||
EngineSettings& settings,
|
EngineSettings& settings,
|
||||||
const Content* content,
|
const Content* content,
|
||||||
std::vector<ContentPack> packs);
|
std::vector<ContentPack> packs);
|
||||||
|
|
||||||
World(std::string name,
|
|
||||||
std::string type,
|
|
||||||
fs::path directory,
|
|
||||||
uint64_t seed,
|
|
||||||
EngineSettings& settings,
|
|
||||||
const Content* content,
|
|
||||||
std::vector<ContentPack> packs);
|
|
||||||
|
|
||||||
~World();
|
~World();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,7 +77,6 @@ public:
|
|||||||
* Create new world
|
* Create new world
|
||||||
* @param name internal world name
|
* @param name internal world name
|
||||||
* @param directory root world directory
|
* @param directory root world directory
|
||||||
* @param type of the world
|
|
||||||
* @param seed world generation seed
|
* @param seed world generation seed
|
||||||
* @param settings current engine settings
|
* @param settings current engine settings
|
||||||
* @param content current engine Content instance
|
* @param content current engine Content instance
|
||||||
@@ -96,7 +85,6 @@ public:
|
|||||||
* @return Level instance containing World instance
|
* @return Level instance containing World instance
|
||||||
*/
|
*/
|
||||||
static Level* create(std::string name,
|
static Level* create(std::string name,
|
||||||
std::string type,
|
|
||||||
fs::path directory,
|
fs::path directory,
|
||||||
uint64_t seed,
|
uint64_t seed,
|
||||||
EngineSettings& settings,
|
EngineSettings& settings,
|
||||||
@@ -136,8 +124,6 @@ public:
|
|||||||
/** Get world generation seed */
|
/** Get world generation seed */
|
||||||
uint64_t getSeed() const;
|
uint64_t getSeed() const;
|
||||||
|
|
||||||
/** Get world type */
|
|
||||||
std::string getType() const;
|
|
||||||
/**
|
/**
|
||||||
* Get vector of all content-packs installed in world
|
* Get vector of all content-packs installed in world
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user