I've been recently assigned to code a Entity-component-system based framework.
(最近,我被分配去编写一个基于实体组件系统的框架的代码。)
As I'm not experienced in that matter, I have a simple question: Can I assume, that an entity can have maximum of one component of each type? (因为我没有这方面的经验,所以我有一个简单的问题:我可以假设一个实体最多可以具有每种类型的一个组件吗?)
I mean like: (我的意思是:)
int COMPONENT_COUNT; //number of different components available
class Entity
{
COMPONENT* component_list[COMPONENT_COUNT];
}
then adding a component would be like
(然后添加一个组件就像)
component_list[component.id]=&component; //can't add more components of this type
Is that a correct assumption?
(这是正确的假设吗?)
I can't think of any situation when an entity would need two or more components of the same type. (当一个实体需要两个或多个相同类型的组件时,我想不出任何情况。)
ask by Oti translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…