我最近被分配到一個基於實體組件系統的框架。由於我沒有經歷過這個問題,我有一個簡單的問題: 我可以假設,一個實體最多可以有每種類型的一個組件?我的意思是這樣的:ECS-實體可以有多個給定類型的組件
int COMPONENT_COUNT; //number of different components available
class Entity
{
COMPONENT* component_list[COMPONENT_COUNT];
}
然後添加成分會像
component_list[component.id]=&component; //can't add more components of this type
那是一個正確的假設?當一個實體需要兩個或更多相同類型的組件時,我想不出任何情況。