mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 13:01:49 +00:00
change: skeletons are assets now, not content units
This commit is contained in:
parent
587c140a6b
commit
42c4716be2
17 changed files with 144 additions and 120 deletions
|
|
@ -8,7 +8,6 @@
|
|||
#include "items/ItemDef.hpp"
|
||||
#include "logic/scripting/scripting.hpp"
|
||||
#include "objects/EntityDef.hpp"
|
||||
#include "objects/rigging.hpp"
|
||||
#include "voxels/Block.hpp"
|
||||
#include "world/generator/VoxelFragment.hpp"
|
||||
#include "world/generator/GeneratorDef.hpp"
|
||||
|
|
@ -33,7 +32,6 @@ Content::Content(
|
|||
ContentUnitDefs<GeneratorDef> generators,
|
||||
UptrsMap<std::string, ContentPackRuntime> packs,
|
||||
UptrsMap<std::string, BlockMaterial> blockMaterials,
|
||||
UptrsMap<std::string, rigging::SkeletonConfig> skeletons,
|
||||
ResourceIndicesSet resourceIndices,
|
||||
dv::value defaults,
|
||||
std::unordered_map<std::string, int> tags
|
||||
|
|
@ -41,7 +39,6 @@ Content::Content(
|
|||
: indices(std::move(indices)),
|
||||
packs(std::move(packs)),
|
||||
blockMaterials(std::move(blockMaterials)),
|
||||
skeletons(std::move(skeletons)),
|
||||
defaults(std::move(defaults)),
|
||||
tags(std::move(tags)),
|
||||
blocks(std::move(blocks)),
|
||||
|
|
@ -56,23 +53,6 @@ Content::Content(
|
|||
|
||||
Content::~Content() = default;
|
||||
|
||||
const rigging::SkeletonConfig* Content::getSkeleton(const std::string& id
|
||||
) const {
|
||||
auto found = skeletons.find(id);
|
||||
if (found == skeletons.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
return found->second.get();
|
||||
}
|
||||
|
||||
const rigging::SkeletonConfig& Content::requireSkeleton(const std::string& id) const {
|
||||
auto skeleton = getSkeleton(id);
|
||||
if (skeleton == nullptr) {
|
||||
throw std::runtime_error("skeleton '" + id + "' not loaded");
|
||||
}
|
||||
return *skeleton;
|
||||
}
|
||||
|
||||
const BlockMaterial* Content::findBlockMaterial(const std::string& id) const {
|
||||
auto found = blockMaterials.find(id);
|
||||
if (found == blockMaterials.end()) {
|
||||
|
|
@ -104,8 +84,3 @@ const UptrsMap<std::string, BlockMaterial>& Content::getBlockMaterials() const {
|
|||
const UptrsMap<std::string, ContentPackRuntime>& Content::getPacks() const {
|
||||
return packs;
|
||||
}
|
||||
|
||||
const UptrsMap<std::string, rigging::SkeletonConfig>& Content::getSkeletons(
|
||||
) const {
|
||||
return skeletons;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,6 @@ struct ItemDef;
|
|||
struct EntityDef;
|
||||
struct GeneratorDef;
|
||||
|
||||
namespace rigging {
|
||||
class SkeletonConfig;
|
||||
}
|
||||
|
||||
class namereuse_error : public std::runtime_error {
|
||||
ContentType type;
|
||||
public:
|
||||
|
|
@ -183,7 +179,6 @@ class Content {
|
|||
std::unique_ptr<ContentIndices> indices;
|
||||
UptrsMap<std::string, ContentPackRuntime> packs;
|
||||
UptrsMap<std::string, BlockMaterial> blockMaterials;
|
||||
UptrsMap<std::string, rigging::SkeletonConfig> skeletons;
|
||||
dv::value defaults = nullptr;
|
||||
std::unordered_map<std::string, int> tags;
|
||||
public:
|
||||
|
|
@ -203,7 +198,6 @@ public:
|
|||
ContentUnitDefs<GeneratorDef> generators,
|
||||
UptrsMap<std::string, ContentPackRuntime> packs,
|
||||
UptrsMap<std::string, BlockMaterial> blockMaterials,
|
||||
UptrsMap<std::string, rigging::SkeletonConfig> skeletons,
|
||||
ResourceIndicesSet resourceIndices,
|
||||
dv::value defaults,
|
||||
std::unordered_map<std::string, int> tags
|
||||
|
|
@ -230,13 +224,10 @@ public:
|
|||
return found->second;
|
||||
}
|
||||
|
||||
const rigging::SkeletonConfig* getSkeleton(const std::string& id) const;
|
||||
const rigging::SkeletonConfig& requireSkeleton(const std::string& id) const;
|
||||
const BlockMaterial* findBlockMaterial(const std::string& id) const;
|
||||
const ContentPackRuntime* getPackRuntime(const std::string& id) const;
|
||||
ContentPackRuntime* getPackRuntime(const std::string& id);
|
||||
|
||||
const UptrsMap<std::string, BlockMaterial>& getBlockMaterials() const;
|
||||
const UptrsMap<std::string, ContentPackRuntime>& getPacks() const;
|
||||
const UptrsMap<std::string, rigging::SkeletonConfig>& getSkeletons() const;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,17 +1,11 @@
|
|||
#include "ContentBuilder.hpp"
|
||||
|
||||
#include "objects/rigging.hpp"
|
||||
|
||||
ContentBuilder::~ContentBuilder() = default;
|
||||
|
||||
void ContentBuilder::add(std::unique_ptr<ContentPackRuntime> pack) {
|
||||
packs[pack->getId()] = std::move(pack);
|
||||
}
|
||||
|
||||
void ContentBuilder::add(std::unique_ptr<rigging::SkeletonConfig> skeleton) {
|
||||
skeletons[skeleton->getName()] = std::move(skeleton);
|
||||
}
|
||||
|
||||
BlockMaterial& ContentBuilder::createBlockMaterial(const std::string& id) {
|
||||
blockMaterials[id] = std::make_unique<BlockMaterial>();
|
||||
auto& material = *blockMaterials[id];
|
||||
|
|
@ -98,7 +92,6 @@ std::unique_ptr<Content> ContentBuilder::build() {
|
|||
generators.build(),
|
||||
std::move(packs),
|
||||
std::move(blockMaterials),
|
||||
std::move(skeletons),
|
||||
std::move(resourceIndices),
|
||||
std::move(defaults),
|
||||
std::move(tags.map)
|
||||
|
|
|
|||
|
|
@ -85,7 +85,6 @@ struct TagsIndices {
|
|||
|
||||
class ContentBuilder {
|
||||
UptrsMap<std::string, BlockMaterial> blockMaterials;
|
||||
UptrsMap<std::string, rigging::SkeletonConfig> skeletons;
|
||||
UptrsMap<std::string, ContentPackRuntime> packs;
|
||||
std::unordered_map<std::string, ContentType> allNames;
|
||||
public:
|
||||
|
|
@ -100,7 +99,6 @@ public:
|
|||
~ContentBuilder();
|
||||
|
||||
void add(std::unique_ptr<ContentPackRuntime> pack);
|
||||
void add(std::unique_ptr<rigging::SkeletonConfig> skeleton);
|
||||
|
||||
BlockMaterial& createBlockMaterial(const std::string& id);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,14 +3,12 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <glm/glm.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#include "loading/ContentUnitLoader.hpp"
|
||||
#include "ContentBuilder.hpp"
|
||||
#include "ContentPack.hpp"
|
||||
#include "debug/Logger.hpp"
|
||||
#include "logic/scripting/scripting.hpp"
|
||||
#include "objects/rigging.hpp"
|
||||
#include "util/listutil.hpp"
|
||||
#include "util/stringutil.hpp"
|
||||
#include "engine/EnginePaths.hpp"
|
||||
|
|
@ -399,16 +397,6 @@ void ContentLoader::load() {
|
|||
}
|
||||
}
|
||||
|
||||
// Load skeletons
|
||||
io::path skeletonsDir = folder / "skeletons";
|
||||
foreach_file(skeletonsDir, [this](const io::path& file) {
|
||||
std::string name = pack->id + ":" + file.stem();
|
||||
std::string text = io::read_string(file);
|
||||
builder.add(
|
||||
rigging::SkeletonConfig::parse(text, file.string(), name)
|
||||
);
|
||||
});
|
||||
|
||||
// Process content.json and load defined content units
|
||||
auto contentFile = pack->getContentFile();
|
||||
if (io::exists(contentFile)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue