初步完成Component/ComponentManager的定义
This commit is contained in:
parent
b05538b501
commit
6d211b3840
2
CMCore
2
CMCore
@ -1 +1 @@
|
|||||||
Subproject commit b78d31d8a01ff4e7e86bf433f9046a3f783d63fa
|
Subproject commit 3b3f6e7e12a67701e143dc0415acbef2d592083b
|
@ -29,34 +29,19 @@ namespace hgl::graph
|
|||||||
Data=cd;
|
Data=cd;
|
||||||
Manager=cm;
|
Manager=cm;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Component()=default;
|
virtual ~Component()=default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void Update(const double delta_time)=0;
|
virtual void Update(const double delta_time)=0;
|
||||||
|
|
||||||
|
public: //事件
|
||||||
|
|
||||||
virtual void OnFocusLost(){} ///<焦点丢失事件
|
virtual void OnFocusLost(){} ///<焦点丢失事件
|
||||||
virtual void OnFocusGained(){} ///<焦点获得事件
|
virtual void OnFocusGained(){} ///<焦点获得事件
|
||||||
};//class Component
|
};//class Component
|
||||||
|
|
||||||
//Component *CreateComponent(const ObjectBaseInfo &,ComponentData *);
|
|
||||||
|
|
||||||
//template<typename T,typename ...ARGS> inline T *NewComponentSCL(const SourceCodeLocation &scl,ARGS...args)
|
|
||||||
//{
|
|
||||||
// static size_t new_count=0;
|
|
||||||
// ObjectBaseInfo obi;
|
|
||||||
|
|
||||||
// obi.hash_code =GetTypeHash<T>();
|
|
||||||
// obi.unique_id =new_count;
|
|
||||||
// obi.scl =scl;
|
|
||||||
|
|
||||||
// ++new_count;
|
|
||||||
// T *obj=new T(obi);
|
|
||||||
// return obj;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//#define NewComponent(T,...) NewComponentSCL<T>(HGL_SOURCE_LOCATION __VA_OPT__(,) __VA_ARGS__)
|
|
||||||
|
|
||||||
class ComponentManager
|
class ComponentManager
|
||||||
{
|
{
|
||||||
SortedSet<Component *> ComponentSet;
|
SortedSet<Component *> ComponentSet;
|
||||||
@ -71,6 +56,22 @@ namespace hgl::graph
|
|||||||
|
|
||||||
virtual Component * CreateComponent(SceneNode *,ComponentData *)=0;
|
virtual Component * CreateComponent(SceneNode *,ComponentData *)=0;
|
||||||
|
|
||||||
virtual int GetComponentCount()const=0;
|
int GetComponentCount()const{return ComponentSet.GetCount();}
|
||||||
|
|
||||||
|
virtual void UpdateComponents(const double delta_time)
|
||||||
|
{
|
||||||
|
Component **cc=ComponentSet.GetData();
|
||||||
|
|
||||||
|
for(int i=0;i<ComponentSet.GetCount();i++)
|
||||||
|
cc[i]->Update(delta_time);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void JoinComponent(Component *c){if(!c)return;ComponentSet.Add(c);}
|
||||||
|
virtual void UnjonComponent(Component *c){if(!c)return;ComponentSet.Delete(c);}
|
||||||
|
|
||||||
|
public: //事件
|
||||||
|
|
||||||
|
virtual void OnFocusLost(){} ///<焦点丢失事件
|
||||||
|
virtual void OnFocusGained(){} ///<焦点获得事件
|
||||||
};//class ComponentManager
|
};//class ComponentManager
|
||||||
}//namespace hgl::graph
|
}//namespace hgl::graph
|
||||||
|
Loading…
x
Reference in New Issue
Block a user