feat: initial DX12 foundation framework
This commit is contained in:
51
Engine/EngineAPI/ScriptComponent.h
Normal file
51
Engine/EngineAPI/ScriptComponent.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @file ScriptComponent.h
|
||||
* @brief 脚本组件句柄定义。
|
||||
* @details
|
||||
* 该文件提供脚本组件在 ECS 中的强类型 ID 封装,用于:
|
||||
* - 标识实体绑定的脚本组件实例;
|
||||
* - 与组件系统统一的有效性检查;
|
||||
* - 在不暴露内部存储结构的前提下传递脚本组件引用。
|
||||
*/
|
||||
#pragma once
|
||||
#include "..\Components\ComponentsCommon.h"
|
||||
|
||||
|
||||
namespace XEngine::script {
|
||||
/**
|
||||
* @brief 脚本组件强类型标识符。
|
||||
*/
|
||||
DEFINE_TYPED_ID(script_id);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 脚本组件句柄对象。
|
||||
*/
|
||||
class component final
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief 由脚本组件 ID 构造句柄。
|
||||
* @param id 脚本组件 ID。
|
||||
*/
|
||||
constexpr explicit component(script_id id) : _id{ id } {}
|
||||
/**
|
||||
* @brief 构造无效脚本组件句柄。
|
||||
*/
|
||||
constexpr component() : _id{ id::invalid_id } {}
|
||||
/**
|
||||
* @brief 获取脚本组件 ID。
|
||||
* @return 组件 ID。
|
||||
*/
|
||||
constexpr script_id get_id() const { return _id; }
|
||||
/**
|
||||
* @brief 判断句柄是否有效。
|
||||
* @return 有效返回 true。
|
||||
*/
|
||||
constexpr bool is_valid() const { return id::is_valid(_id); }
|
||||
|
||||
private:
|
||||
script_id _id;
|
||||
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user