add core:obstacle block & move cameras from base to core & add new generator
This commit is contained in:
@@ -17,6 +17,7 @@ inline constexpr bool ENGINE_DEBUG_BUILD = true;
|
||||
inline const std::string ENGINE_VERSION_STRING = "0.23";
|
||||
|
||||
inline constexpr blockid_t BLOCK_AIR = 0;
|
||||
inline constexpr blockid_t BLOCK_OBSTACLE = 1;
|
||||
inline constexpr itemid_t ITEM_EMPTY = 0;
|
||||
inline constexpr entityid_t ENTITY_NONE = 0;
|
||||
|
||||
|
||||
@@ -528,6 +528,18 @@ void ContentLoader::load() {
|
||||
}
|
||||
}
|
||||
|
||||
fs::path resourcesFile = folder / fs::u8path("resources.json");
|
||||
if (fs::exists(resourcesFile)) {
|
||||
auto resRoot = files::read_json(resourcesFile);
|
||||
for (const auto& [key, arr] : resRoot.asObject()) {
|
||||
if (auto resType = ResourceType_from(key)) {
|
||||
loadResources(*resType, arr);
|
||||
} else {
|
||||
logger.warning() << "unknown resource type: " << key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!fs::is_regular_file(pack->getContentFile())) return;
|
||||
|
||||
auto root = files::read_json(pack->getContentFile());
|
||||
@@ -723,18 +735,6 @@ void ContentLoader::load() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fs::path resourcesFile = folder / fs::u8path("resources.json");
|
||||
if (fs::exists(resourcesFile)) {
|
||||
auto resRoot = files::read_json(resourcesFile);
|
||||
for (const auto& [key, arr] : resRoot.asObject()) {
|
||||
if (auto resType = ResourceType_from(key)) {
|
||||
loadResources(*resType, arr);
|
||||
} else {
|
||||
logger.warning() << "unknown resource type: " << key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ContentLoader::loadResources(ResourceType type, const dv::value& list) {
|
||||
|
||||
+25
-10
@@ -12,17 +12,19 @@
|
||||
|
||||
// All in-game definitions (blocks, items, etc..)
|
||||
void corecontent::setup(EnginePaths* paths, ContentBuilder* builder) {
|
||||
Block& block = builder->blocks.create("core:air");
|
||||
block.replaceable = true;
|
||||
block.drawGroup = 1;
|
||||
block.lightPassing = true;
|
||||
block.skyLightPassing = true;
|
||||
block.obstacle = false;
|
||||
block.selectable = false;
|
||||
block.model = BlockModel::none;
|
||||
block.pickingItem = "core:empty";
|
||||
{
|
||||
Block& block = builder->blocks.create(CORE_AIR);
|
||||
block.replaceable = true;
|
||||
block.drawGroup = 1;
|
||||
block.lightPassing = true;
|
||||
block.skyLightPassing = true;
|
||||
block.obstacle = false;
|
||||
block.selectable = false;
|
||||
block.model = BlockModel::none;
|
||||
block.pickingItem = CORE_EMPTY;
|
||||
}
|
||||
|
||||
ItemDef& item = builder->items.create("core:empty");
|
||||
ItemDef& item = builder->items.create(CORE_EMPTY);
|
||||
item.iconType = item_icon_type::none;
|
||||
|
||||
auto bindsFile = paths->getResourcesFolder()/fs::path("bindings.toml");
|
||||
@@ -31,4 +33,17 @@ void corecontent::setup(EnginePaths* paths, ContentBuilder* builder) {
|
||||
bindsFile.u8string(), files::read_string(bindsFile)
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
Block& block = builder->blocks.create(CORE_OBSTACLE);
|
||||
for (uint i = 0; i < 6; i++) {
|
||||
block.textureFaces[i] = "obstacle";
|
||||
}
|
||||
block.hitboxes = {AABB()};
|
||||
ItemDef& item = builder->items.create(CORE_OBSTACLE+".item");
|
||||
item.iconType = item_icon_type::block;
|
||||
item.icon = CORE_OBSTACLE;
|
||||
item.placingBlock = CORE_OBSTACLE;
|
||||
item.caption = block.caption;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <string>
|
||||
|
||||
inline const std::string CORE_EMPTY = "core:empty";
|
||||
inline const std::string CORE_OBSTACLE = "core:obstacle";
|
||||
inline const std::string CORE_AIR = "core:air";
|
||||
|
||||
inline const std::string TEXTURE_NOTFOUND = "notfound";
|
||||
|
||||
@@ -286,7 +286,8 @@ std::unique_ptr<GeneratorScript> scripting::load_generator(
|
||||
lua::pop(L);
|
||||
|
||||
uint biomeParameters = root["biome_parameters"].asInteger();
|
||||
uint seaLevel = root["sea_level"].asInteger();
|
||||
uint seaLevel = 0;
|
||||
root.at("sea_level").get(seaLevel);
|
||||
|
||||
std::vector<Biome> biomes;
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@ Player::Player(
|
||||
position(position),
|
||||
inventory(std::move(inv)),
|
||||
eid(eid),
|
||||
camera(level->getCamera("base:first-person")),
|
||||
spCamera(level->getCamera("base:third-person-front")),
|
||||
tpCamera(level->getCamera("base:third-person-back")),
|
||||
camera(level->getCamera("core:first-person")),
|
||||
spCamera(level->getCamera("core:third-person-front")),
|
||||
tpCamera(level->getCamera("core:third-person-back")),
|
||||
currentCamera(camera) {
|
||||
camera->setFov(glm::radians(90.0f));
|
||||
spCamera->setFov(glm::radians(90.0f));
|
||||
|
||||
Reference in New Issue
Block a user