diff --git a/src/content/Content.cpp b/src/content/Content.cpp index 677258ad..98affbbf 100644 --- a/src/content/Content.cpp +++ b/src/content/Content.cpp @@ -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 blocks, ContentUnitDefs items, ContentUnitDefs entities, + ContentUnitDefs generators, UptrsMap packs, UptrsMap blockMaterials, UptrsMap 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]); diff --git a/src/content/Content.hpp b/src/content/Content.hpp index 9a802d43..8e152a51 100644 --- a/src/content/Content.hpp +++ b/src/content/Content.hpp @@ -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 blocks; ContentUnitDefs items; ContentUnitDefs entities; + ContentUnitDefs generators; std::unique_ptr const drawGroups; ResourceIndicesSet resourceIndices {}; @@ -206,6 +202,7 @@ public: ContentUnitDefs blocks, ContentUnitDefs items, ContentUnitDefs entities, + ContentUnitDefs generators, UptrsMap packs, UptrsMap blockMaterials, UptrsMap skeletons, diff --git a/src/content/ContentBuilder.cpp b/src/content/ContentBuilder.cpp index 4bf194bc..b637532e 100644 --- a/src/content/ContentBuilder.cpp +++ b/src/content/ContentBuilder.cpp @@ -72,6 +72,7 @@ std::unique_ptr ContentBuilder::build() { blocks.build(), items.build(), entities.build(), + generators.build(), std::move(packs), std::move(blockMaterials), std::move(skeletons), diff --git a/src/content/ContentBuilder.hpp b/src/content/ContentBuilder.hpp index cd652883..22610eee 100644 --- a/src/content/ContentBuilder.hpp +++ b/src/content/ContentBuilder.hpp @@ -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 @@ -59,6 +60,7 @@ public: ContentUnitBuilder blocks {allNames, ContentType::BLOCK}; ContentUnitBuilder items {allNames, ContentType::ITEM}; ContentUnitBuilder entities {allNames, ContentType::ENTITY}; + ContentUnitBuilder generators {allNames, ContentType::GENERATOR}; ResourceIndicesSet resourceIndices {}; ~ContentBuilder(); diff --git a/src/content/content_fwd.hpp b/src/content/content_fwd.hpp index b1618593..076a433f 100644 --- a/src/content/content_fwd.hpp +++ b/src/content/content_fwd.hpp @@ -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 }; diff --git a/src/world/generator/GeneratorDef.hpp b/src/world/generator/GeneratorDef.hpp new file mode 100644 index 00000000..fa26787f --- /dev/null +++ b/src/world/generator/GeneratorDef.hpp @@ -0,0 +1,10 @@ +#pragma once + +#include + +#include "typedefs.hpp" + +struct GeneratorDef { + std::string name; + scriptenv env; +};