add GeneratorDef

This commit is contained in:
MihailRis 2024-08-14 01:23:14 +03:00
parent cae314bc36
commit 5fa6b14f05
6 changed files with 22 additions and 9 deletions

View File

@ -10,6 +10,7 @@
#include "objects/EntityDef.hpp"
#include "objects/rigging.hpp"
#include "voxels/Block.hpp"
#include "world/generator/GeneratorDef.hpp"
#include "ContentPack.hpp"
ContentIndices::ContentIndices(
@ -28,6 +29,7 @@ Content::Content(
ContentUnitDefs<Block> blocks,
ContentUnitDefs<ItemDef> items,
ContentUnitDefs<EntityDef> entities,
ContentUnitDefs<GeneratorDef> generators,
UptrsMap<std::string, ContentPackRuntime> packs,
UptrsMap<std::string, BlockMaterial> blockMaterials,
UptrsMap<std::string, rigging::SkeletonConfig> skeletons,
@ -40,6 +42,7 @@ Content::Content(
blocks(std::move(blocks)),
items(std::move(items)),
entities(std::move(entities)),
generators(std::move(generators)),
drawGroups(std::move(drawGroups)) {
for (size_t i = 0; i < RESOURCE_TYPES_COUNT; i++) {
this->resourceIndices[i] = std::move(resourceIndices[i]);

View File

@ -19,6 +19,7 @@ class Block;
struct BlockMaterial;
struct ItemDef;
struct EntityDef;
struct GeneratorDef;
namespace rigging {
class SkeletonConfig;
@ -34,6 +35,8 @@ constexpr const char* ContentType_name(ContentType type) {
return "item";
case ContentType::ENTITY:
return "entity";
case ContentType::GENERATOR:
return "generator";
default:
return "unknown";
}
@ -65,14 +68,6 @@ public:
return defs[id];
}
[[deprecated]]
inline T* getWriteable(blockid_t id) const { // TODO: remove
if (id >= defs.size()) {
return nullptr;
}
return defs[id];
}
inline const T& require(blockid_t id) const {
return *defs.at(id);
}
@ -197,6 +192,7 @@ public:
ContentUnitDefs<Block> blocks;
ContentUnitDefs<ItemDef> items;
ContentUnitDefs<EntityDef> entities;
ContentUnitDefs<GeneratorDef> generators;
std::unique_ptr<DrawGroups> const drawGroups;
ResourceIndicesSet resourceIndices {};
@ -206,6 +202,7 @@ public:
ContentUnitDefs<Block> blocks,
ContentUnitDefs<ItemDef> items,
ContentUnitDefs<EntityDef> entities,
ContentUnitDefs<GeneratorDef> generators,
UptrsMap<std::string, ContentPackRuntime> packs,
UptrsMap<std::string, BlockMaterial> blockMaterials,
UptrsMap<std::string, rigging::SkeletonConfig> skeletons,

View File

@ -72,6 +72,7 @@ std::unique_ptr<Content> ContentBuilder::build() {
blocks.build(),
items.build(),
entities.build(),
generators.build(),
std::move(packs),
std::move(blockMaterials),
std::move(skeletons),

View File

@ -8,6 +8,7 @@
#include "ContentPack.hpp"
#include "items/ItemDef.hpp"
#include "objects/EntityDef.hpp"
#include "world/generator/GeneratorDef.hpp"
#include "voxels/Block.hpp"
template <class T>
@ -59,6 +60,7 @@ public:
ContentUnitBuilder<Block> blocks {allNames, ContentType::BLOCK};
ContentUnitBuilder<ItemDef> items {allNames, ContentType::ITEM};
ContentUnitBuilder<EntityDef> entities {allNames, ContentType::ENTITY};
ContentUnitBuilder<GeneratorDef> generators {allNames, ContentType::GENERATOR};
ResourceIndicesSet resourceIndices {};
~ContentBuilder();

View File

@ -5,7 +5,7 @@
class Content;
class ContentPackRuntime;
enum class ContentType { NONE, BLOCK, ITEM, ENTITY };
enum class ContentType { NONE, BLOCK, ITEM, ENTITY, GENERATOR };
enum class ResourceType : size_t { CAMERA, LAST = CAMERA };

View File

@ -0,0 +1,10 @@
#pragma once
#include <string>
#include "typedefs.hpp"
struct GeneratorDef {
std::string name;
scriptenv env;
};