Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class GameObject: public Object
- {
- public:
- GameObject(std::string objectName);
- ~GameObject(void);
- Component * AddComponent(std::string name);
- Component * AddComponent(Component componentType);
- Component * GetComponent (std::string TypeName);
- Component * GetComponent (<Component Type Here>);
- private:
- std::map<std::string,Component*> m_components;
- };
- GameObject * warship = new GameObject("myLovelyWarship");
- MeshRenderer * meshRenderer = warship->AddComponent(MeshRenderer);
- MeshRenderer * meshRenderer = warship->AddComponent("MeshRenderer");
- class ComponentFactory
- {
- public:
- static Component * CreateComponent(const std::string &compTyp)
- {
- if(compTyp == "MeshRenderer")
- return new MeshRenderer;
- if(compTyp == "Collider")
- return new Collider;
- return NULL;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement