even more steps sounds test
This commit is contained in:
parent
015b1c2ed7
commit
90f3373f46
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"material": "base:grass",
|
||||||
"texture-faces": [
|
"texture-faces": [
|
||||||
"grass_side",
|
"grass_side",
|
||||||
"grass_side",
|
"grass_side",
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
"pane",
|
"pane",
|
||||||
"pane"
|
"pane"
|
||||||
],
|
],
|
||||||
|
"material": "base:wood",
|
||||||
"model": "aabb",
|
"model": "aabb",
|
||||||
"hitbox": [0.0, 0.0, 0.0, 1.0, 1.0, 0.2],
|
"hitbox": [0.0, 0.0, 0.0, 1.0, 1.0, 0.2],
|
||||||
"light-passing": true,
|
"light-passing": true,
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
{
|
{
|
||||||
"texture": "planks"
|
"texture": "planks",
|
||||||
|
"material": "base:wood"
|
||||||
}
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"material": "base:wood",
|
||||||
"texture-faces": [
|
"texture-faces": [
|
||||||
"wood",
|
"wood",
|
||||||
"wood",
|
"wood",
|
||||||
|
|||||||
@ -80,7 +80,13 @@ void AssetsLoader::addDefaults(AssetsLoader& loader, const Content* content) {
|
|||||||
loader.add(ASSET_TEXTURE, TEXTURES_FOLDER"/misc/moon.png", "misc/moon");
|
loader.add(ASSET_TEXTURE, TEXTURES_FOLDER"/misc/moon.png", "misc/moon");
|
||||||
loader.add(ASSET_TEXTURE, TEXTURES_FOLDER"/misc/sun.png", "misc/sun");
|
loader.add(ASSET_TEXTURE, TEXTURES_FOLDER"/misc/sun.png", "misc/sun");
|
||||||
loader.add(ASSET_TEXTURE, TEXTURES_FOLDER"/gui/crosshair.png", "gui/crosshair");
|
loader.add(ASSET_TEXTURE, TEXTURES_FOLDER"/gui/crosshair.png", "gui/crosshair");
|
||||||
|
|
||||||
|
// (test code)
|
||||||
|
// TODO: remove
|
||||||
loader.add(ASSET_SOUND, SOUNDS_FOLDER"/steps/grass.ogg", "steps/grass");
|
loader.add(ASSET_SOUND, SOUNDS_FOLDER"/steps/grass.ogg", "steps/grass");
|
||||||
|
loader.add(ASSET_SOUND, SOUNDS_FOLDER"/steps/stone.ogg", "steps/stone");
|
||||||
|
loader.add(ASSET_SOUND, SOUNDS_FOLDER"/steps/wood.ogg", "steps/wood");
|
||||||
|
loader.add(ASSET_SOUND, SOUNDS_FOLDER"/steps/ground.ogg", "steps/ground");
|
||||||
|
|
||||||
addLayouts(0, "core", loader.getPaths()->getMainRoot()/fs::path("layouts"), loader);
|
addLayouts(0, "core", loader.getPaths()->getMainRoot()/fs::path("layouts"), loader);
|
||||||
for (auto& entry : content->getPacks()) {
|
for (auto& entry : content->getPacks()) {
|
||||||
|
|||||||
@ -249,6 +249,9 @@ speakerid_t audio::play(
|
|||||||
int priority,
|
int priority,
|
||||||
int channel
|
int channel
|
||||||
) {
|
) {
|
||||||
|
if (sound == nullptr) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (!sound->variants.empty()) {
|
if (!sound->variants.empty()) {
|
||||||
size_t index = rand() % (sound->variants.size() + 1);
|
size_t index = rand() % (sound->variants.size() + 1);
|
||||||
if (index < sound->variants.size()) {
|
if (index < sound->variants.size()) {
|
||||||
|
|||||||
@ -144,6 +144,8 @@ void ContentLoader::loadBlock(Block& def, std::string name, fs::path file) {
|
|||||||
def.model = BlockModel::none;
|
def.model = BlockModel::none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
root->str("material", def.material);
|
||||||
|
|
||||||
// rotation profile
|
// rotation profile
|
||||||
std::string profile = "none";
|
std::string profile = "none";
|
||||||
root->str("rotation", profile);
|
root->str("rotation", profile);
|
||||||
|
|||||||
@ -1,11 +1,17 @@
|
|||||||
#include "LevelFrontend.h"
|
#include "LevelFrontend.h"
|
||||||
|
|
||||||
#include "../world/Level.h"
|
|
||||||
#include "../assets/Assets.h"
|
|
||||||
#include "../graphics/Atlas.h"
|
|
||||||
#include "BlocksPreview.h"
|
#include "BlocksPreview.h"
|
||||||
#include "ContentGfxCache.h"
|
#include "ContentGfxCache.h"
|
||||||
|
|
||||||
|
#include "../audio/audio.h"
|
||||||
|
#include "../world/Level.h"
|
||||||
|
#include "../voxels/Block.h"
|
||||||
|
#include "../assets/Assets.h"
|
||||||
|
#include "../graphics/Atlas.h"
|
||||||
|
|
||||||
|
#include "../logic/LevelController.h"
|
||||||
|
#include "../logic/PlayerController.h"
|
||||||
|
|
||||||
LevelFrontend::LevelFrontend(Level* level, Assets* assets)
|
LevelFrontend::LevelFrontend(Level* level, Assets* assets)
|
||||||
: level(level),
|
: level(level),
|
||||||
assets(assets),
|
assets(assets),
|
||||||
@ -13,6 +19,29 @@ LevelFrontend::LevelFrontend(Level* level, Assets* assets)
|
|||||||
blocksAtlas(BlocksPreview::build(contentCache.get(), assets, level->content)) {
|
blocksAtlas(BlocksPreview::build(contentCache.get(), assets, level->content)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LevelFrontend::observe(LevelController* controller) {
|
||||||
|
controller->getPlayerController()->listenBlockInteraction(
|
||||||
|
[=](Player*, glm::ivec3 pos, const Block* def, BlockInteraction type) {
|
||||||
|
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));
|
||||||
|
audio::play(
|
||||||
|
sound,
|
||||||
|
glm::vec3(),
|
||||||
|
true,
|
||||||
|
0.333f,
|
||||||
|
1.0f,
|
||||||
|
false,
|
||||||
|
audio::PRIORITY_LOW,
|
||||||
|
audio::get_channel_index("regular")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
LevelFrontend::~LevelFrontend() {
|
LevelFrontend::~LevelFrontend() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@ class Level;
|
|||||||
class Assets;
|
class Assets;
|
||||||
class BlocksPreview;
|
class BlocksPreview;
|
||||||
class ContentGfxCache;
|
class ContentGfxCache;
|
||||||
|
class LevelController;
|
||||||
|
|
||||||
class LevelFrontend {
|
class LevelFrontend {
|
||||||
Level* level;
|
Level* level;
|
||||||
@ -18,6 +19,8 @@ public:
|
|||||||
LevelFrontend(Level* level, Assets* assets);
|
LevelFrontend(Level* level, Assets* assets);
|
||||||
~LevelFrontend();
|
~LevelFrontend();
|
||||||
|
|
||||||
|
void observe(LevelController* controller);
|
||||||
|
|
||||||
Level* getLevel() const;
|
Level* getLevel() const;
|
||||||
Assets* getAssets() const;
|
Assets* getAssets() const;
|
||||||
ContentGfxCache* getContentGfxCache() const;
|
ContentGfxCache* getContentGfxCache() const;
|
||||||
|
|||||||
@ -100,24 +100,7 @@ LevelScreen::LevelScreen(Engine* engine, Level* level) : Screen(engine) {
|
|||||||
worldRenderer = std::make_unique<WorldRenderer>(engine, frontend.get(), controller->getPlayer());
|
worldRenderer = std::make_unique<WorldRenderer>(engine, frontend.get(), controller->getPlayer());
|
||||||
hud = std::make_unique<Hud>(engine, frontend.get(), controller->getPlayer());
|
hud = std::make_unique<Hud>(engine, frontend.get(), controller->getPlayer());
|
||||||
|
|
||||||
controller->getPlayerController()->listenBlockInteraction(
|
frontend->observe(controller.get());
|
||||||
[=](Player*, glm::ivec3 pos, const Block* def, BlockInteraction type) {
|
|
||||||
if (type != BlockInteraction::step) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto sound = assets->getSound("steps/grass");
|
|
||||||
audio::play(
|
|
||||||
sound,
|
|
||||||
glm::vec3(),
|
|
||||||
true,
|
|
||||||
1.0f,
|
|
||||||
1.0f,
|
|
||||||
false,
|
|
||||||
audio::PRIORITY_LOW,
|
|
||||||
audio::get_channel_index("regular")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
backlight = settings.graphics.backlight;
|
backlight = settings.graphics.backlight;
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,8 @@ inline constexpr uint FACE_PZ = 5;
|
|||||||
|
|
||||||
inline constexpr uint BLOCK_AABB_GRID = 16;
|
inline constexpr uint BLOCK_AABB_GRID = 16;
|
||||||
|
|
||||||
|
inline std::string DEFAULT_MATERIAL = "base:stone";
|
||||||
|
|
||||||
struct block_funcs_set {
|
struct block_funcs_set {
|
||||||
bool init: 1;
|
bool init: 1;
|
||||||
bool update: 1;
|
bool update: 1;
|
||||||
@ -96,6 +98,8 @@ public:
|
|||||||
std::vector<glm::vec3> modelExtraPoints = {}; //initially made for tetragons
|
std::vector<glm::vec3> modelExtraPoints = {}; //initially made for tetragons
|
||||||
std::vector<UVRegion> modelUVs = {}; // boxes' tex-UVs also there
|
std::vector<UVRegion> modelUVs = {}; // boxes' tex-UVs also there
|
||||||
|
|
||||||
|
std::string material = DEFAULT_MATERIAL;
|
||||||
|
|
||||||
/// @brief Light emission R, G, B, S (sky lights: sun, moon, radioactive clouds)
|
/// @brief Light emission R, G, B, S (sky lights: sun, moon, radioactive clouds)
|
||||||
uint8_t emission[4] {0, 0, 0, 0};
|
uint8_t emission[4] {0, 0, 0, 0};
|
||||||
/// @brief Influences visible block sides for transparent blocks
|
/// @brief Influences visible block sides for transparent blocks
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user