#include <CubeTypeRegistry.h>
Public 成员函数 | |
| CubeTypeRegistry ()=default | |
| uint8_t | add (const CubeType &type) |
| 注册一个方块类型,返回其基础类型 id(0 保留给空气)。 方向性方块会按 orientation ∈ {0,1,2,3} 绕 Y 轴旋转 faceTex, 展开成 4 个连续的具体类型变体;基础 id 指向 0 度变体。 | |
| int | loadFromJson (const std::string &json, std::string *error=nullptr) |
| 从 JSON 数组或单对象批量注册,返回成功数量。 元素形如: { "name": "furnace", "faceTex": [4, 4, 4, 4, 5, 4], "directional": true, "composeGroup": "furnace", "connects": false } | |
| const CubeType * | find (const std::string &name) const |
| 按名字返回 0 度变体;未找到返回 nullptr。 | |
| const CubeType * | find (uint8_t id) const |
| 按类型 id 返回变体(含方向变体);未找到返回 nullptr。 | |
| uint8_t | variantId (const std::string &name, int orientation) const |
| 名字 + orientation(0..3) 对应的具体类型 id;非方向性类型忽略 orientation。 | |
| int | count () const |
| 命名的方块类型数量(不含方向变体)。 | |
| int | variantCount () const |
| 类型总数(含方向变体,不含空气占位)。 | |
| void | clear () |
静态 Public 成员函数 | |
| static const CubeTypeRegistry & | empty () |
| 进程级空注册表(默认参数与向后兼容回退用)。 | |
详细描述
在文件 CubeTypeRegistry.h 第 18 行定义.
构造及析构函数说明
◆ CubeTypeRegistry()
|
default |
成员函数说明
◆ add()
| uint8_t eve::voxel::CubeTypeRegistry::add | ( | const CubeType & | type | ) |
注册一个方块类型,返回其基础类型 id(0 保留给空气)。 方向性方块会按 orientation ∈ {0,1,2,3} 绕 Y 轴旋转 faceTex, 展开成 4 个连续的具体类型变体;基础 id 指向 0 度变体。
在文件 CubeTypeRegistry.cpp 第 49 行定义.
引用了 eve::voxel::CubeType::id, type , 以及 v.
被这些函数引用 loadFromJson().
◆ clear()
| void eve::voxel::CubeTypeRegistry::clear | ( | ) |
在文件 CubeTypeRegistry.cpp 第 117 行定义.
◆ count()
|
inline |
命名的方块类型数量(不含方向变体)。
在文件 CubeTypeRegistry.h 第 48 行定义.
◆ empty()
|
static |
进程级空注册表(默认参数与向后兼容回退用)。
在文件 CubeTypeRegistry.cpp 第 47 行定义.
◆ find() [1/2]
| const CubeType * eve::voxel::CubeTypeRegistry::find | ( | const std::string & | name | ) | const |
按名字返回 0 度变体;未找到返回 nullptr。
在文件 CubeTypeRegistry.cpp 第 98 行定义.
引用了 name.
被这些函数引用 eve::voxel::VoxelWorld::getCubeTypeName(), eve::voxel::resolveFaceTex() , 以及 eve::voxel::VoxelWorld::setVoxelByName().
◆ find() [2/2]
| const CubeType * eve::voxel::CubeTypeRegistry::find | ( | uint8_t | id | ) | const |
◆ loadFromJson()
| int eve::voxel::CubeTypeRegistry::loadFromJson | ( | const std::string & | json, |
| std::string * | error = nullptr |
||
| ) |
从 JSON 数组或单对象批量注册,返回成功数量。 元素形如: { "name": "furnace", "faceTex": [4, 4, 4, 4, 5, 4], "directional": true, "composeGroup": "furnace", "connects": false }
在文件 CubeTypeRegistry.cpp 第 71 行定义.
引用了 add(), error, n, eve::voxel::CubeType::name, eve::json::Document::parse(), eve::json::Document::root() , 以及 eve::json::Document::valid().
◆ variantCount()
|
inline |
类型总数(含方向变体,不含空气占位)。
在文件 CubeTypeRegistry.h 第 50 行定义.
◆ variantId()
| uint8_t eve::voxel::CubeTypeRegistry::variantId | ( | const std::string & | name, |
| int | orientation | ||
| ) | const |
名字 + orientation(0..3) 对应的具体类型 id;非方向性类型忽略 orientation。
在文件 CubeTypeRegistry.cpp 第 109 行定义.
引用了 eve::voxel::CubeType::directional, eve::voxel::CubeType::id , 以及 name.
该类的文档由以下文件生成:
- src/modules/voxel/CubeTypeRegistry.h
- src/modules/voxel/CubeTypeRegistry.cpp