载入中...
搜索中...
未找到
eve::voxel::CubeTypeRegistry类 参考

#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 CubeTypefind (const std::string &name) const
 按名字返回 0 度变体;未找到返回 nullptr。
 
const CubeTypefind (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 CubeTypeRegistryempty ()
 进程级空注册表(默认参数与向后兼容回退用)。
 

详细描述

在文件 CubeTypeRegistry.h18 行定义.

构造及析构函数说明

◆ CubeTypeRegistry()

eve::voxel::CubeTypeRegistry::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.cpp49 行定义.

引用了 eve::voxel::CubeType::id, type , 以及 v.

被这些函数引用 loadFromJson().

◆ clear()

void eve::voxel::CubeTypeRegistry::clear ( )

在文件 CubeTypeRegistry.cpp117 行定义.

◆ count()

int eve::voxel::CubeTypeRegistry::count ( ) const
inline

命名的方块类型数量(不含方向变体)。

在文件 CubeTypeRegistry.h48 行定义.

◆ empty()

const CubeTypeRegistry & eve::voxel::CubeTypeRegistry::empty ( )
static

进程级空注册表(默认参数与向后兼容回退用)。

在文件 CubeTypeRegistry.cpp47 行定义.

◆ find() [1/2]

const CubeType * eve::voxel::CubeTypeRegistry::find ( const std::string &  name) const

按名字返回 0 度变体;未找到返回 nullptr。

在文件 CubeTypeRegistry.cpp98 行定义.

引用了 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

按类型 id 返回变体(含方向变体);未找到返回 nullptr。

在文件 CubeTypeRegistry.cpp104 行定义.

引用了 id.

◆ 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.cpp71 行定义.

引用了 add(), error, n, eve::voxel::CubeType::name, eve::json::Document::parse(), eve::json::Document::root() , 以及 eve::json::Document::valid().

◆ variantCount()

int eve::voxel::CubeTypeRegistry::variantCount ( ) const
inline

类型总数(含方向变体,不含空气占位)。

在文件 CubeTypeRegistry.h50 行定义.

◆ variantId()

uint8_t eve::voxel::CubeTypeRegistry::variantId ( const std::string &  name,
int  orientation 
) const

名字 + orientation(0..3) 对应的具体类型 id;非方向性类型忽略 orientation。

在文件 CubeTypeRegistry.cpp109 行定义.

引用了 eve::voxel::CubeType::directional, eve::voxel::CubeType::id , 以及 name.

被这些函数引用 eve::voxel::VoxelWorld::setVoxelByName().


该类的文档由以下文件生成: