.. _stdlib_decs: ===================================== DECS、Daslang 实体组件系统 ===================================== .. include:: detail/decs.rst DECS 模块实现了 Daslang 实体组件系统的低级功能。 所有函数和符号都在 “decs” 模块中,使用 require 来访问它。 :: require daslib/decs 一般情况下,没有 boost 包的模块是不使用的:: require daslib/desc_boost ++++++++++++ 类型别名 ++++++++++++ .. _alias-ComponentHash: .. das:attribute:: ComponentHash = uint64 ECS 组件类型的哈希值 .. _alias-TypeHash: .. das:attribute:: TypeHash = uint64 单个类型的哈希值 .. _alias-DeferEval: .. das:attribute:: DeferEval = lambda<(var act:DeferAction):void> Lambda 保存延迟作。通常是创建或销毁实体。 .. _alias-ComponentMap: .. das:attribute:: ComponentMap = array 单个实体的组件值表。 .. _alias-PassFunction: .. das:attribute:: PassFunction = function 构成 individual pass 的回调之一。 .. _struct-decs-CTypeInfo: .. das:attribute:: CTypeInfo CTypeInfo 字段是 +-----------+-----------------------------------------------------------------------------------------------------------+ +basicType + :ref:`rtti::Type ` + +-----------+-----------------------------------------------------------------------------------------------------------+ +mangledName+string + +-----------+-----------------------------------------------------------------------------------------------------------+ +fullName +string + +-----------+-----------------------------------------------------------------------------------------------------------+ +hash + :ref:`TypeHash ` + +-----------+-----------------------------------------------------------------------------------------------------------+ +size +uint + +-----------+-----------------------------------------------------------------------------------------------------------+ +eraser +function<(arr:array):void> + +-----------+-----------------------------------------------------------------------------------------------------------+ +clonner +function<(dst:array;src:array const):void> + +-----------+-----------------------------------------------------------------------------------------------------------+ +serializer +function<(arch: :ref:`archive::Archive ` ;arr:array;name:string const):void>+ +-----------+-----------------------------------------------------------------------------------------------------------+ +dumper +function<(elem:void? const):string> + +-----------+-----------------------------------------------------------------------------------------------------------+ +mkTypeInfo +function<> + +-----------+-----------------------------------------------------------------------------------------------------------+ +gc +function<(src:array):lambda<>> + +-----------+-----------------------------------------------------------------------------------------------------------+ 键入单个组件子类型的信息。 由类型名称和特定于类型的例程集合组成,用于在其生命周期、序列化等期间控制类型值。 .. _struct-decs-Component: .. das:attribute:: Component Component 字段是 +--------+------------------------------------------------+ +name +string + +--------+------------------------------------------------+ +hash + :ref:`ComponentHash ` + +--------+------------------------------------------------+ +stride +int + +--------+------------------------------------------------+ +data +array + +--------+------------------------------------------------+ +info + :ref:`decs::CTypeInfo ` + +--------+------------------------------------------------+ +gc_dummy+lambda<> + +--------+------------------------------------------------+ 单个 ECS 组件。包含组件名称、数据和数据布局。 .. _struct-decs-EntityId: .. das:attribute:: EntityId EntityId 字段是 +----------+----+ +id +uint+ +----------+----+ +generation+int + +----------+----+ 实体的唯一标识符。由 id (数据数组中的索引) 和 generation 组成。 .. _struct-decs-Archetype: .. das:attribute:: Archetype Archetype 字段是 +----------+-------------------------------------------------------+ +hash + :ref:`ComponentHash ` + +----------+-------------------------------------------------------+ +components+array< :ref:`decs::Component ` >+ +----------+-------------------------------------------------------+ +size +int + +----------+-------------------------------------------------------+ +eidIndex +int + +----------+-------------------------------------------------------+ ECS 原型。Archetype 是组件的独特组合。 .. _struct-decs-ComponentValue: .. das:attribute:: ComponentValue ComponentValue 字段是 +----+------------------------------------------------+ +name+string + +----+------------------------------------------------+ +info+ :ref:`decs::CTypeInfo ` + +----+------------------------------------------------+ +data+float4[4] + +----+------------------------------------------------+ 创建或转换期间组件的值。 .. _struct-decs-EcsRequestPos: .. das:attribute:: EcsRequestPos EcsRequestPos 字段是 +----+------+ +file+string+ +----+------+ +line+uint + +----+------+ ECS 请求在代码中的位置(源文件和行号)。 .. _struct-decs-EcsRequest: .. das:attribute:: EcsRequest EcsRequest 字段是 +----------+--------------------------------------------------------+ +hash + :ref:`ComponentHash ` + +----------+--------------------------------------------------------+ +req +array + +----------+--------------------------------------------------------+ +reqn +array + +----------+--------------------------------------------------------+ +archetypes+array + +----------+--------------------------------------------------------+ +at + :ref:`decs::EcsRequestPos ` + +----------+--------------------------------------------------------+ 单个 ESC 请求。包含必需组件列表、需要缺少的组件列表。 缓存与请求匹配的原型列表。 .. _struct-decs-DecsState: .. das:attribute:: DecsState DecsState 字段是 +------------------+---------------------------------------------------------------------------------------------+ +archetypeLookup +table< :ref:`ComponentHash ` ;int> + +------------------+---------------------------------------------------------------------------------------------+ +allArchetypes +array< :ref:`decs::Archetype ` > + +------------------+---------------------------------------------------------------------------------------------+ +entityFreeList +array< :ref:`decs::EntityId ` > + +------------------+---------------------------------------------------------------------------------------------+ +entityLookup +array` ;index:int>>+ +------------------+---------------------------------------------------------------------------------------------+ +componentTypeCheck+table` > + +------------------+---------------------------------------------------------------------------------------------+ +ecsQueries +array< :ref:`decs::EcsRequest ` > + +------------------+---------------------------------------------------------------------------------------------+ +queryLookup +table< :ref:`ComponentHash ` ;int> + +------------------+---------------------------------------------------------------------------------------------+ ECS 系统的整个状态。 包括原型、实体和实体自由列表、实体 lokup 表、所有原型和原型查找等。 .. _struct-decs-DecsPass: .. das:attribute:: DecsPass DecsPass 字段是 +-----+-------------------------------------------------+ +name +string + +-----+-------------------------------------------------+ +calls+array< :ref:`PassFunction ` >+ +-----+-------------------------------------------------+ ECS 系统更新的单独通道。 包含通道名称和所有通道 calblack 的列表。 +++++++++++++++++++++ 比较和访问 +++++++++++++++++++++ * :ref:`== (a:decs::EntityId const implicit;b:decs::EntityId const implicit) : bool ` * :ref:`\!= (a:decs::EntityId const implicit;b:decs::EntityId const implicit) : bool ` * :ref:`. (cmp:array\ -const;name:string const) : decs::ComponentValue& ` .. _function-_at_decs_c__c__eq__eq__CIS_ls_decs_c__c_EntityId_gr__CIS_ls_decs_c__c_EntityId_gr_: .. das:function:: operator ==(a: EntityId const implicit; b: EntityId const implicit) == returns bool +--------+-------------------------------------------------------------+ +argument+argument type + +========+=============================================================+ +a + :ref:`decs::EntityId ` const implicit+ +--------+-------------------------------------------------------------+ +b + :ref:`decs::EntityId ` const implicit+ +--------+-------------------------------------------------------------+ 实体 ID 的相等运算符。 .. _function-_at_decs_c__c__ex__eq__CIS_ls_decs_c__c_EntityId_gr__CIS_ls_decs_c__c_EntityId_gr_: .. das:function:: operator !=(a: EntityId const implicit; b: EntityId const implicit) != returns bool +--------+-------------------------------------------------------------+ +argument+argument type + +========+=============================================================+ +a + :ref:`decs::EntityId ` const implicit+ +--------+-------------------------------------------------------------+ +b + :ref:`decs::EntityId ` const implicit+ +--------+-------------------------------------------------------------+ 实体 ID 的不等运算符。 .. _function-_at_decs_c__c_._Y_ls_ComponentMap_gr_1_ls_S_ls_decs_c__c_ComponentValue_gr__gr_A_Cs: .. das:function:: operator .(cmp: ComponentMap; name: string const) . returns :ref:`decs::ComponentValue ` & +--------+------------------------------------------+ +argument+argument type + +========+==========================================+ +cmp + :ref:`ComponentMap ` + +--------+------------------------------------------+ +name +string const + +--------+------------------------------------------+ 按名称访问组件值。例如:: create_entity <| @ ( eid, cmp ) cmp.pos := float3(i) // same as cmp |> set("pos",float3(i)) ++++++++++++++++++++++ 访问 (get/set/clone) ++++++++++++++++++++++ * :ref:`clone (cv:decs::ComponentValue -const;val:decs::EntityId const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:bool const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:range const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:urange const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:range64 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:urange64 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:string const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:int const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:int8 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:int16 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:int64 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:int2 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:int3 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:int4 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:uint const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:uint8 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:uint16 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:uint64 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:uint2 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:uint3 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:uint4 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:float const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:float2 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:float3 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:float4 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:math::float3x3 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:math::float3x4 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:math::float4x4 const) : void ` * :ref:`clone (cv:decs::ComponentValue -const;val:double const) : void ` * :ref:`clone (dst:decs::Component -const;src:decs::Component const) : void ` * :ref:`has (arch:decs::Archetype const;name:string const) : bool ` * :ref:`has (cmp:array\ -const;name:string const) : bool ` * :ref:`remove (cmp:array\ -const;name:string const) : void ` * :ref:`set (cv:decs::ComponentValue -const;val:auto const) : auto ` * :ref:`get (arch:decs::Archetype const;name:string const;value:auto(TT) const) : auto ` * :ref:`get (cmp:array\ -const;name:string const;value:auto(TT) -const) : auto ` * :ref:`set (cmp:array\ -const;name:string const;value:auto(TT) const) : auto ` .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__CS_ls_decs_c__c_EntityId_gr_: .. das:function:: clone(cv: ComponentValue; val: EntityId const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val + :ref:`decs::EntityId ` const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Cb: .. das:function:: clone(cv: ComponentValue; val: bool const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +bool const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Cr: .. das:function:: clone(cv: ComponentValue; val: range const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +range const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Cz: .. das:function:: clone(cv: ComponentValue; val: urange const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +urange const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Cr64: .. das:function:: clone(cv: ComponentValue; val: range64 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +range64 const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Cz64: .. das:function:: clone(cv: ComponentValue; val: urange64 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +urange64 const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Cs: .. das:function:: clone(cv: ComponentValue; val: string const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +string const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Ci: .. das:function:: clone(cv: ComponentValue; val: int const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +int const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Ci8: .. das:function:: clone(cv: ComponentValue; val: int8 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +int8 const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Ci16: .. das:function:: clone(cv: ComponentValue; val: int16 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +int16 const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Ci64: .. das:function:: clone(cv: ComponentValue; val: int64 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +int64 const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Ci2: .. das:function:: clone(cv: ComponentValue; val: int2 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +int2 const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Ci3: .. das:function:: clone(cv: ComponentValue; val: int3 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +int3 const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Ci4: .. das:function:: clone(cv: ComponentValue; val: int4 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +int4 const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Cu: .. das:function:: clone(cv: ComponentValue; val: uint const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +uint const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Cu8: .. das:function:: clone(cv: ComponentValue; val: uint8 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +uint8 const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Cu16: .. das:function:: clone(cv: ComponentValue; val: uint16 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +uint16 const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Cu64: .. das:function:: clone(cv: ComponentValue; val: uint64 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +uint64 const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Cu2: .. das:function:: clone(cv: ComponentValue; val: uint2 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +uint2 const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Cu3: .. das:function:: clone(cv: ComponentValue; val: uint3 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +uint3 const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Cu4: .. das:function:: clone(cv: ComponentValue; val: uint4 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +uint4 const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Cf: .. das:function:: clone(cv: ComponentValue; val: float const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +float const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Cf2: .. das:function:: clone(cv: ComponentValue; val: float2 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +float2 const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Cf3: .. das:function:: clone(cv: ComponentValue; val: float3 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +float3 const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Cf4: .. das:function:: clone(cv: ComponentValue; val: float4 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +float4 const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__CH_ls_math_c__c_float3x3_gr_: .. das:function:: clone(cv: ComponentValue; val: float3x3 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val + :ref:`math::float3x3 ` const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__CH_ls_math_c__c_float3x4_gr_: .. das:function:: clone(cv: ComponentValue; val: float3x4 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val + :ref:`math::float3x4 ` const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__CH_ls_math_c__c_float4x4_gr_: .. das:function:: clone(cv: ComponentValue; val: float4x4 const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val + :ref:`math::float4x4 ` const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_ComponentValue_gr__Cd: .. das:function:: clone(cv: ComponentValue; val: double const) +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +double const + +--------+----------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_clone_S_ls_decs_c__c_Component_gr__CS_ls_decs_c__c_Component_gr_: .. das:function:: clone(dst: Component; src: Component const) +--------+------------------------------------------------------+ +argument+argument type + +========+======================================================+ +dst + :ref:`decs::Component ` + +--------+------------------------------------------------------+ +src + :ref:`decs::Component ` const+ +--------+------------------------------------------------------+ 克隆组件值。 .. _function-_at_decs_c__c_has_CS_ls_decs_c__c_Archetype_gr__Cs: .. das:function:: has(arch: Archetype const; name: string const) has returns bool +--------+------------------------------------------------------+ +argument+argument type + +========+======================================================+ +arch + :ref:`decs::Archetype ` const+ +--------+------------------------------------------------------+ +name +string const + +--------+------------------------------------------------------+ 如果 object 指定了 subobjec,则返回 true。 .. _function-_at_decs_c__c_has_Y_ls_ComponentMap_gr_1_ls_S_ls_decs_c__c_ComponentValue_gr__gr_A_Cs: .. das:function:: has(cmp: ComponentMap; name: string const) has returns bool +--------+------------------------------------------+ +argument+argument type + +========+==========================================+ +cmp + :ref:`ComponentMap ` + +--------+------------------------------------------+ +name +string const + +--------+------------------------------------------+ 如果 object 指定了 subobjec,则返回 true。 .. _function-_at_decs_c__c_remove_Y_ls_ComponentMap_gr_1_ls_S_ls_decs_c__c_ComponentValue_gr__gr_A_Cs: .. das:function:: remove(cmp: ComponentMap; name: string const) +--------+------------------------------------------+ +argument+argument type + +========+==========================================+ +cmp + :ref:`ComponentMap ` + +--------+------------------------------------------+ +name +string const + +--------+------------------------------------------+ 从组件映射中删除特定值。 .. _function-_at_decs_c__c_set_S_ls_decs_c__c_ComponentValue_gr__C.: .. das:function:: set(cv: ComponentValue; val: auto const) set returns auto +--------+----------------------------------------------------------+ +argument+argument type + +========+==========================================================+ +cv + :ref:`decs::ComponentValue ` + +--------+----------------------------------------------------------+ +val +auto const + +--------+----------------------------------------------------------+ 设置由 name 和 type 指定的组件值。 如果 value 已存在,则将其覆盖。如果已经存在的值类型不相同 - panic。 overwrite insert new one .. _function-_at_decs_c__c_get_CS_ls_decs_c__c_Archetype_gr__Cs_CY_ls_TT_gr_.: .. das:function:: get(arch: Archetype const; name: string const; value: auto(TT) const) get returns auto +--------+------------------------------------------------------+ +argument+argument type + +========+======================================================+ +arch + :ref:`decs::Archetype ` const+ +--------+------------------------------------------------------+ +name +string const + +--------+------------------------------------------------------+ +value +auto(TT) const + +--------+------------------------------------------------------+ 获取由 name 和 type 指定的组件值。 如果 name 匹配,但 type 不匹配,则会 panic。 .. _function-_at_decs_c__c_get_Y_ls_ComponentMap_gr_1_ls_S_ls_decs_c__c_ComponentValue_gr__gr_A_Cs_Y_ls_TT_gr_.: .. das:function:: get(cmp: ComponentMap; name: string const; value: auto(TT)) get returns auto +--------+------------------------------------------+ +argument+argument type + +========+==========================================+ +cmp + :ref:`ComponentMap ` + +--------+------------------------------------------+ +name +string const + +--------+------------------------------------------+ +value +auto(TT) + +--------+------------------------------------------+ 获取由 name 和 type 指定的组件值。 如果 name 匹配,但 type 不匹配,则会 panic。 .. _function-_at_decs_c__c_set_Y_ls_ComponentMap_gr_1_ls_S_ls_decs_c__c_ComponentValue_gr__gr_A_Cs_CY_ls_TT_gr_.: .. das:function:: set(cmp: ComponentMap; name: string const; value: auto(TT) const) set returns auto +--------+------------------------------------------+ +argument+argument type + +========+==========================================+ +cmp + :ref:`ComponentMap ` + +--------+------------------------------------------+ +name +string const + +--------+------------------------------------------+ +value +auto(TT) const + +--------+------------------------------------------+ 设置由 name 和 type 指定的组件值。 如果 value 已存在,则将其覆盖。如果已经存在的值类型不相同 - panic。 overwrite insert new one +++++++++++++++++++++++ Deubg 和序列化 +++++++++++++++++++++++ * :ref:`describe (info:decs::CTypeInfo const) : string ` * :ref:`serialize (arch:archive::Archive -const;src:decs::Component -const) : void ` * :ref:`finalize (cmp:decs::Component -const) : void ` * :ref:`debug_dump () : void ` .. _function-_at_decs_c__c_describe_CS_ls_decs_c__c_CTypeInfo_gr_: .. das:function:: describe(info: CTypeInfo const) describe returns string +--------+------------------------------------------------------+ +argument+argument type + +========+======================================================+ +info + :ref:`decs::CTypeInfo ` const+ +--------+------------------------------------------------------+ 返回类型的文本说明。 .. _function-_at_decs_c__c_serialize_S_ls_archive_c__c_Archive_gr__S_ls_decs_c__c_Component_gr_: .. das:function:: serialize(arch: Archive; src: Component) +--------+--------------------------------------------------+ +argument+argument type + +========+==================================================+ +arch + :ref:`archive::Archive ` + +--------+--------------------------------------------------+ +src + :ref:`decs::Component ` + +--------+--------------------------------------------------+ 序列化组件值。 .. _function-_at_decs_c__c_finalize_S_ls_decs_c__c_Component_gr_: .. das:function:: finalize(cmp: Component) +--------+------------------------------------------------+ +argument+argument type + +========+================================================+ +cmp + :ref:`decs::Component ` + +--------+------------------------------------------------+ 删除组件。 .. _function-_at_decs_c__c_debug_dump: .. das:function:: debug_dump() 打印出 ECS 系统的状态。 debug(arch) ++++++ Stages ++++++ * :ref:`register_decs_stage_call (name:string const;pcall:function\ const) : void ` * :ref:`decs_stage (name:string const) : void ` * :ref:`commit () : void ` .. _function-_at_decs_c__c_register_decs_stage_call_Cs_CY_ls_PassFunction_gr_1_ls_v_gr__at__at_: .. das:function:: register_decs_stage_call(name: string const; pcall: PassFunction) +--------+------------------------------------------+ +argument+argument type + +========+==========================================+ +name +string const + +--------+------------------------------------------+ +pcall + :ref:`PassFunction ` + +--------+------------------------------------------+ 注册单个传递回调。这是一个低级函数,由 decs_boost 宏使用。 insert new one .. _function-_at_decs_c__c_decs_stage_Cs: .. das:function:: decs_stage(name: string const) +--------+-------------+ +argument+argument type+ +========+=============+ +name +string const + +--------+-------------+ 调用特定的 ECS pass。 `commit` 在调用之前和之后调用。 .. _function-_at_decs_c__c_commit: .. das:function:: commit() 完成所有延迟的作。 ++++++++++++++++ 延迟操作 ++++++++++++++++ * :ref:`update_entity (entityid:decs::EntityId const implicit;blk:lambda\<(eid:decs::EntityId const;var cmp:array\ -const):void\> -const) : void ` * :ref:`create_entity (blk:lambda\<(eid:decs::EntityId const;var cmp:array\ -const):void\> -const) : decs::EntityId ` * :ref:`delete_entity (entityid:decs::EntityId const implicit) : void ` .. _function-_at_decs_c__c_update_entity_CIS_ls_decs_c__c_EntityId_gr__N_ls_eid;cmp_gr_0_ls_CS_ls_decs_c__c_EntityId_gr_;Y_ls_ComponentMap_gr_1_ls_S_ls_decs_c__c_ComponentValue_gr__gr_A_gr_1_ls_v_gr__at_: .. das:function:: update_entity(entityid: EntityId const implicit; blk: lambda<(eid:EntityId const;var cmp:array):void>) +--------+----------------------------------------------------------------------------------------------------------------------+ +argument+argument type + +========+======================================================================================================================+ +entityid+ :ref:`decs::EntityId ` const implicit + +--------+----------------------------------------------------------------------------------------------------------------------+ +blk +lambda<(eid: :ref:`decs::EntityId ` const;cmp: :ref:`ComponentMap ` ):void>+ +--------+----------------------------------------------------------------------------------------------------------------------+ 创建延迟作以更新由 id 指定的实体。 .. _function-_at_decs_c__c_create_entity_N_ls_eid;cmp_gr_0_ls_CS_ls_decs_c__c_EntityId_gr_;Y_ls_ComponentMap_gr_1_ls_S_ls_decs_c__c_ComponentValue_gr__gr_A_gr_1_ls_v_gr__at_: .. das:function:: create_entity(blk: lambda<(eid:EntityId const;var cmp:array):void>) create_entity returns :ref:`decs::EntityId ` +--------+----------------------------------------------------------------------------------------------------------------------+ +argument+argument type + +========+======================================================================================================================+ +blk +lambda<(eid: :ref:`decs::EntityId ` const;cmp: :ref:`ComponentMap ` ):void>+ +--------+----------------------------------------------------------------------------------------------------------------------+ 创建延迟作以创建实体。 .. _function-_at_decs_c__c_delete_entity_CIS_ls_decs_c__c_EntityId_gr_: .. das:function:: delete_entity(entityid: EntityId const implicit) +--------+-------------------------------------------------------------+ +argument+argument type + +========+=============================================================+ +entityid+ :ref:`decs::EntityId ` const implicit+ +--------+-------------------------------------------------------------+ 创建延迟作以删除由 id 指定的实体。 ++++++++++++ GC 和 reset ++++++++++++ * :ref:`restart () : void ` * :ref:`before_gc () : void ` * :ref:`after_gc () : void ` .. _function-_at_decs_c__c_restart: .. das:function:: restart() 通过擦除所有延迟的作和整个状态来重新启动 ECS。 .. _function-_at_decs_c__c_before_gc: .. das:function:: before_gc() 在垃圾回收之前调用的低级回调。 这是 `live` 通常使用的低级函数。 .. _function-_at_decs_c__c_after_gc: .. das:function:: after_gc() 在垃圾回收后调用的低级回调。 这是 `live` 通常使用的低级函数。 +++++++++ 迭代 +++++++++ * :ref:`for_each_archetype (erq:decs::EcsRequest -const;blk:block\<(arch:decs::Archetype const):void\> const) : void ` * :ref:`for_eid_archetype (eid:decs::EntityId const implicit;hash:uint64 const;erq:function\ -const;blk:block\<(arch:decs::Archetype const;index:int const):void\> const) : bool const ` * :ref:`for_each_archetype (hash:uint64 const;erq:function\ -const;blk:block\<(arch:decs::Archetype const):void\> const) : void ` * :ref:`for_each_archetype_find (hash:uint64 const;erq:function\ -const;blk:block\<(arch:decs::Archetype const):bool\> const) : bool const ` * :ref:`decs_array (atype:auto(TT) const;src:array\ const;capacity:int const) : auto ` * :ref:`get_ro (arch:decs::Archetype const;name:string const;value:auto(TT) const[]) : array\ const ` * :ref:`get_ro (arch:decs::Archetype const;name:string const;value:auto(TT) const) : array\ const ` * :ref:`get_default_ro (arch:decs::Archetype const;name:string const;value:auto(TT) const) : iterator\ ` * :ref:`get_optional (arch:decs::Archetype const;name:string const;value:auto(TT)? const) : iterator\ ` .. _function-_at_decs_c__c_for_each_archetype_S_ls_decs_c__c_EcsRequest_gr__CN_ls_arch_gr_0_ls_CS_ls_decs_c__c_Archetype_gr__gr_1_ls_v_gr__builtin_: .. das:function:: for_each_archetype(erq: EcsRequest; blk: block<(arch:Archetype const):void> const) +--------+-------------------------------------------------------------------------------+ +argument+argument type + +========+===============================================================================+ +erq + :ref:`decs::EcsRequest ` + +--------+-------------------------------------------------------------------------------+ +blk +block<(arch: :ref:`decs::Archetype ` const):void> const+ +--------+-------------------------------------------------------------------------------+ 为请求可处理的每个原型的每个实体调用 block。 请求由指定的函数返回。 .. _function-_at_decs_c__c_for_eid_archetype_CIS_ls_decs_c__c_EntityId_gr__CY_ls_ComponentHash_gr_u64_1_ls_S_ls_decs_c__c_EcsRequest_gr__gr__at__at__CN_ls_arch;index_gr_0_ls_CS_ls_decs_c__c_Archetype_gr_;Ci_gr_1_ls_v_gr__builtin_: .. das:function:: for_eid_archetype(eid: EntityId const implicit; hash: ComponentHash; erq: function; blk: block<(arch:Archetype const;index:int const):void> const) for_eid_archetype returns bool const +--------+-----------------------------------------------------------------------------------------------+ +argument+argument type + +========+===============================================================================================+ +eid + :ref:`decs::EntityId ` const implicit + +--------+-----------------------------------------------------------------------------------------------+ +hash + :ref:`ComponentHash ` + +--------+-----------------------------------------------------------------------------------------------+ +erq +function<> + +--------+-----------------------------------------------------------------------------------------------+ +blk +block<(arch: :ref:`decs::Archetype ` const;index:int const):void> const+ +--------+-----------------------------------------------------------------------------------------------+ 为给定请求的特定实体 ID 调用 block。 请求由指定的函数返回。 .. _function-_at_decs_c__c_for_each_archetype_CY_ls_ComponentHash_gr_u64_1_ls_S_ls_decs_c__c_EcsRequest_gr__gr__at__at__CN_ls_arch_gr_0_ls_CS_ls_decs_c__c_Archetype_gr__gr_1_ls_v_gr__builtin_: .. das:function:: for_each_archetype(hash: ComponentHash; erq: function; blk: block<(arch:Archetype const):void> const) +--------+-------------------------------------------------------------------------------+ +argument+argument type + +========+===============================================================================+ +hash + :ref:`ComponentHash ` + +--------+-------------------------------------------------------------------------------+ +erq +function<> + +--------+-------------------------------------------------------------------------------+ +blk +block<(arch: :ref:`decs::Archetype ` const):void> const+ +--------+-------------------------------------------------------------------------------+ 为请求可处理的每个原型的每个实体调用 block。 请求由指定的函数返回。 .. _function-_at_decs_c__c_for_each_archetype_find_CY_ls_ComponentHash_gr_u64_1_ls_S_ls_decs_c__c_EcsRequest_gr__gr__at__at__CN_ls_arch_gr_0_ls_CS_ls_decs_c__c_Archetype_gr__gr_1_ls_b_gr__builtin_: .. das:function:: for_each_archetype_find(hash: ComponentHash; erq: function; blk: block<(arch:Archetype const):bool> const) for_each_archetype_find returns bool const +--------+-------------------------------------------------------------------------------+ +argument+argument type + +========+===============================================================================+ +hash + :ref:`ComponentHash ` + +--------+-------------------------------------------------------------------------------+ +erq +function<> + +--------+-------------------------------------------------------------------------------+ +blk +block<(arch: :ref:`decs::Archetype ` const):bool> const+ +--------+-------------------------------------------------------------------------------+ 为请求可处理的每个原型的每个实体调用 block。 请求由指定的函数返回。 如果 block 返回 true,则停止迭代。 [template(atype)] .. _function-_at_decs_c__c_decs_array_CY_ls_TT_gr_._C1_ls_u8_gr_A_Ci: .. das:function:: decs_array(atype: auto(TT) const; src: array const; capacity: int const) decs_array returns auto +--------+------------------+ +argument+argument type + +========+==================+ +atype +auto(TT) const + +--------+------------------+ +src +array const+ +--------+------------------+ +capacity+int const + +--------+------------------+ 低级函数返回给定特定类型组件的组件的临时数组。 .. _function-_at_decs_c__c_get_ro_CS_ls_decs_c__c_Archetype_gr__Cs_C_lb_-1_rb_Y_ls_TT_gr_.: .. das:function:: get_ro(arch: Archetype const; name: string const; value: auto(TT) const[]) get_ro returns array const +--------+------------------------------------------------------+ +argument+argument type + +========+======================================================+ +arch + :ref:`decs::Archetype ` const+ +--------+------------------------------------------------------+ +name +string const + +--------+------------------------------------------------------+ +value +auto(TT) const[-1] + +--------+------------------------------------------------------+ 返回给定常规组件的特定名称和组件类型的组件的 const 临时数组。 .. _function-_at_decs_c__c_get_ro_CS_ls_decs_c__c_Archetype_gr__Cs_CY_ls_TT_gr_._%_ls__ex_()_gr_: .. das:function:: get_ro(arch: Archetype const; name: string const; value: auto(TT) const) get_ro returns array const +--------+------------------------------------------------------+ +argument+argument type + +========+======================================================+ +arch + :ref:`decs::Archetype ` const+ +--------+------------------------------------------------------+ +name +string const + +--------+------------------------------------------------------+ +value +auto(TT) const + +--------+------------------------------------------------------+ 返回给定常规组件的特定名称和组件类型的组件的 const 临时数组。 .. _function-_at_decs_c__c_get_default_ro_CS_ls_decs_c__c_Archetype_gr__Cs_CY_ls_TT_gr_.: .. das:function:: get_default_ro(arch: Archetype const; name: string const; value: auto(TT) const) get_default_ro returns iterator +--------+------------------------------------------------------+ +argument+argument type + +========+======================================================+ +arch + :ref:`decs::Archetype ` const+ +--------+------------------------------------------------------+ +name +string const + +--------+------------------------------------------------------+ +value +auto(TT) const + +--------+------------------------------------------------------+ 返回给定特定名称和组件类型的组件的 const 迭代器。 如果未找到 component - iterator 将 keepp 返回指定的值。 .. _function-_at_decs_c__c_get_optional_CS_ls_decs_c__c_Archetype_gr__Cs_C1_ls_Y_ls_TT_gr_._gr__qm_: .. das:function:: get_optional(arch: Archetype const; name: string const; value: auto(TT)? const) get_optional returns iterator +--------+------------------------------------------------------+ +argument+argument type + +========+======================================================+ +arch + :ref:`decs::Archetype ` const+ +--------+------------------------------------------------------+ +name +string const + +--------+------------------------------------------------------+ +value +auto(TT)? const + +--------+------------------------------------------------------+ 返回给定特定名称和组件类型的组件的 const 迭代器。 如果未找到 component - iterator 将 keepp 返回 component 类型的默认值。 +++++++ Request +++++++ * :ref:`EcsRequestPos (at:rtti::LineInfo const) : decs::EcsRequestPos ` * :ref:`verify_request (erq:decs::EcsRequest -const) : tuple\ ` * :ref:`compile_request (erq:decs::EcsRequest -const) : void ` * :ref:`lookup_request (erq:decs::EcsRequest -const) : int ` .. _function-_at_decs_c__c_EcsRequestPos_CH_ls_rtti_c__c_LineInfo_gr_: .. das:function:: EcsRequestPos(at: LineInfo const) EcsRequestPos returns :ref:`decs::EcsRequestPos ` +--------+----------------------------------------------------+ +argument+argument type + +========+====================================================+ +at + :ref:`rtti::LineInfo ` const+ +--------+----------------------------------------------------+ 从 rtti::LineInfo 构造 EcsRequestPos。 .. _function-_at_decs_c__c_verify_request_S_ls_decs_c__c_EcsRequest_gr_: .. das:function:: verify_request(erq: EcsRequest) verify_request returns tuple +--------+--------------------------------------------------+ +argument+argument type + +========+==================================================+ +erq + :ref:`decs::EcsRequest ` + +--------+--------------------------------------------------+ 验证 ESC 请求。返回一对布尔值(true 表示正常)和错误消息。 这几乎查询了所有内容 假设 require_not 通常更短 .. _function-_at_decs_c__c_compile_request_S_ls_decs_c__c_EcsRequest_gr_: .. das:function:: compile_request(erq: EcsRequest) +--------+--------------------------------------------------+ +argument+argument type + +========+==================================================+ +erq + :ref:`decs::EcsRequest ` + +--------+--------------------------------------------------+ 通过创建请求哈希来编译 ESC 请求。 .. _function-_at_decs_c__c_lookup_request_S_ls_decs_c__c_EcsRequest_gr_: .. das:function:: lookup_request(erq: EcsRequest) lookup_request returns int +--------+--------------------------------------------------+ +argument+argument type + +========+==================================================+ +erq + :ref:`decs::EcsRequest ` + +--------+--------------------------------------------------+ 在请求缓存中查找 ESC 请求。