ShitEngine 1.4.2
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
载入中...
搜索中...
未找到
ComponentRef< T > 模板类 参考

可序列化的组件引用(存 UUID,懒解析,自动失效) 更多...

#include <ComponentRef.h>

Public 成员函数

 ComponentRef ()=default
T * get () const
 解析引用(当前场景的 uuid 索引查找 + 类型校验) 目标组件已移除/对象已销毁/类型不符/跨场景时返回 nullptr。
T * operator-> () const
 便捷解引用(目标失效返回 nullptr,调用前可判空)
 operator bool () const
 引用当前是否有效
uint64_t uuid () const
 目标组件 UUID(0 = 空引用;编辑器/序列化用)
void setUuid (uint64_t uuid)
 设置引用目标(传入 0 清空引用;编辑器拖拽赋引用用)
bool operator== (const ComponentRef &other) const
bool operator!= (const ComponentRef &other) const

详细描述

template<typename T>
class Shit::ComponentRef< T >

可序列化的组件引用(存 UUID,懒解析,自动失效)

模板参数
T目标组件类型(须继承 Component 的反射类型)

构造及析构函数说明

◆ ComponentRef()

template<typename T>
ComponentRef ( )
default

成员函数说明

◆ get()

template<typename T>
T * get ( ) const
inline

解析引用(当前场景的 uuid 索引查找 + 类型校验) 目标组件已移除/对象已销毁/类型不符/跨场景时返回 nullptr。

◆ operator bool()

template<typename T>
operator bool ( ) const
inlineexplicit

引用当前是否有效

◆ operator!=()

template<typename T>
bool operator!= ( const ComponentRef< T > & other) const
inline

◆ operator->()

template<typename T>
T * operator-> ( ) const
inline

便捷解引用(目标失效返回 nullptr,调用前可判空)

◆ operator==()

template<typename T>
bool operator== ( const ComponentRef< T > & other) const
inline

◆ setUuid()

template<typename T>
void setUuid ( uint64_t uuid)
inline

设置引用目标(传入 0 清空引用;编辑器拖拽赋引用用)

◆ uuid()

template<typename T>
uint64_t uuid ( ) const
inline

目标组件 UUID(0 = 空引用;编辑器/序列化用)


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