update ComponentManager
This commit is contained in:
parent
0f3b5ca473
commit
b90642fd15
|
|
@ -33,12 +33,23 @@ Component* ComponentManager::AddComponent(ComponentPtr component)
|
|||
{
|
||||
KGE_ASSERT(component && "AddComponent failed, NULL pointer exception");
|
||||
|
||||
if (component)
|
||||
{
|
||||
size_t hash = std::hash<String>{}(component->GetName());
|
||||
AddComponent(hash, component);
|
||||
}
|
||||
return component.Get();
|
||||
}
|
||||
|
||||
Component* ComponentManager::AddComponent(size_t index, ComponentPtr component)
|
||||
{
|
||||
KGE_ASSERT(component && "AddComponent failed, NULL pointer exception");
|
||||
|
||||
if (component)
|
||||
{
|
||||
component->InitComponent(target_);
|
||||
|
||||
size_t hash = std::hash<String>{}(component->GetName());
|
||||
components_.insert(std::make_pair(hash, component));
|
||||
components_.insert(std::make_pair(index, component));
|
||||
}
|
||||
return component.Get();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,12 @@ public:
|
|||
/// @param component 组件
|
||||
Component* AddComponent(ComponentPtr component);
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 添加组件
|
||||
/// @param index 索引值
|
||||
/// @param component 组件
|
||||
Component* AddComponent(size_t index, ComponentPtr component);
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 获取组件
|
||||
Component* GetComponent(const String& name);
|
||||
|
|
|
|||
Loading…
Reference in New Issue