Files
Cubed/include/Cubed/gameplay/block.hpp
zhenyan121 322fb2fea0 refactor(localization): switch block translations to item naming
Remove the `name_key` field from block definitions and use item-based
localization keys (`item.*.name`) for inventory display. Item data now
stores the localized name at load time.
2026-08-05 15:42:53 +08:00

68 lines
1.8 KiB
C++

#pragma once
#include <glad/glad.h>
#include <glm/glm.hpp>
#include <optional>
#include <string>
#include <vector>
namespace Cubed {
using BlockType = uint8_t;
using OptionalBlockVectorArray =
std::array<std::optional<std::vector<BlockType>>, 4>;
struct BlockTexture {
std::string name;
unsigned id;
std::vector<GLuint> texture;
};
struct Block : public BlockTexture {};
struct BlockRenderData {
std::vector<bool> draw_face;
unsigned block_id;
BlockRenderData() = default;
BlockRenderData(const BlockRenderData&) = default;
BlockRenderData& operator=(const BlockRenderData&) = default;
BlockRenderData(BlockRenderData&& data)
: draw_face(std::move(data.draw_face)), block_id(data.block_id) {}
BlockRenderData& operator=(BlockRenderData&& data) {
draw_face = std::move(data.draw_face);
block_id = data.block_id;
return *this;
}
};
struct LookBlock {
glm::ivec3 pos;
glm::ivec3 normal;
};
struct BlockData {
std::string name;
BlockType id = 0;
bool is_liquid = false;
bool is_gas = false;
bool is_passable = false;
bool is_cross_plane = false;
bool is_transparent = false;
bool is_discard = false;
bool is_blend = false;
bool is_transitional = false;
float roughness = 1.0f;
BlockData(std::string_view b_name, BlockType b_id, bool liquid,
bool passable, bool cross_plane, bool transparent, bool gas,
bool discard, bool blend, bool transitional, float r)
: name(b_name), id(b_id), is_liquid(liquid), is_gas(gas),
is_passable(passable), is_cross_plane(cross_plane),
is_transparent(transparent), is_discard(discard), is_blend(blend),
is_transitional(transitional), roughness(r) {}
BlockData() { name = ""; }
};
} // namespace Cubed