block materials loading

This commit is contained in:
MihailRis
2024-03-09 03:36:08 +03:00
parent 90f3373f46
commit f4cc413f61
11 changed files with 144 additions and 40 deletions
+12 -8
View File
@@ -8,16 +8,17 @@
#include "../voxels/Block.h"
#include "../assets/Assets.h"
#include "../graphics/Atlas.h"
#include "../content/Content.h"
#include "../logic/LevelController.h"
#include "../logic/PlayerController.h"
LevelFrontend::LevelFrontend(Level* level, Assets* assets)
: level(level),
assets(assets),
contentCache(std::make_unique<ContentGfxCache>(level->content, assets)),
blocksAtlas(BlocksPreview::build(contentCache.get(), assets, level->content)) {
}
: level(level),
assets(assets),
contentCache(std::make_unique<ContentGfxCache>(level->content, assets)),
blocksAtlas(BlocksPreview::build(contentCache.get(), assets, level->content))
{}
void LevelFrontend::observe(LevelController* controller) {
controller->getPlayerController()->listenBlockInteraction(
@@ -25,9 +26,12 @@ void LevelFrontend::observe(LevelController* controller) {
if (type != BlockInteraction::step) {
return;
}
// (test code)
// TODO: replace with BlockMaterial properties access
auto sound = assets->getSound("steps/"+def->material.substr(def->material.find(':')+1));
auto material = level->content->findBlockMaterial(def->material);
if (material == nullptr) {
return;
}
auto sound = assets->getSound(material->stepsSound);
audio::play(
sound,
glm::vec3(),