28#include "Components/CComponentSystem.h"
29#include "Components/CNullComponent.h"
30#include "Components/CDependentComponent.h"
31#include "Transform/CTransformEuler.h"
32#include "Transform/CTransformMatrix.h"
33#include "Serializable/CObjectSerializable.h"
51 class SKYLICHT_API CGameObject
53 friend class CDependentComponent;
56 std::string m_objectID;
59 std::wstring m_defaultName;
69 bool m_enableEditorChange;
70 bool m_enableEditorSelect;
71 bool m_enableEndUpdate;
76 CGameObject* m_parent;
81 std::string m_tagDataString;
83 std::vector<CComponentSystem*> m_components;
89 std::string m_templateId;
90 std::string m_templateAsset;
91 std::string m_templateObjectId;
92 bool m_templateChanged;
95 CGameObject(CGameObject* parent,
CZone* zone);
97 virtual ~CGameObject();
105 void destroyEntity();
107 void updateEntityParent();
109 virtual void setID(
const char*
id)
114 inline std::string& getID()
119 inline const wchar_t* getName()
121 return m_name.c_str();
124 const char* getNameA();
126 inline const wchar_t* getDefaultName()
128 return m_defaultName.c_str();
131 inline void setName(
const wchar_t* lpName)
135 if (m_defaultName == L
"")
136 m_defaultName = lpName;
139 void setName(
const char* lpName);
141 inline bool isTemplateAsset()
143 return !m_templateAsset.empty();
146 inline const char* getTemplateAsset()
148 return m_templateAsset.c_str();
151 inline void setTemplateAsset(
const char* asset)
153 m_templateAsset = asset;
156 inline void unpackTemplate()
158 m_templateAsset.clear();
159 m_templateId.clear();
162 inline const char* getTemplateID()
164 return m_templateId.c_str();
167 inline void setTemplateID(
const char*
id)
172 inline const char* getTemplateObjectID()
174 return m_templateObjectId.c_str();
177 inline void setTemplateObjectID(
const char*
id)
179 m_templateObjectId = id;
182 inline bool isTemplateObject()
184 return !m_templateId.empty();
187 CGameObject* getParentTemplate();
189 virtual void setTemplateChanged(
bool b);
191 inline bool isTemplateChanged()
193 return m_templateChanged;
196 inline CGameObject* getParent()
201 inline CZone* getZone()
208 inline void setParent(CGameObject* p)
227 return m_transformEuler;
232 return m_transformMatrix;
235 void setupMatrixTransform();
237 void setupEulerTransform();
251 inline bool isEnable()
256 inline bool isEnableEndUpdate()
258 return m_enableEndUpdate;
261 inline bool isVisible()
268 inline bool isSelfLock()
273 virtual void setEnable(
bool b)
278 virtual void setEnableEndUpdate(
bool b)
280 m_enableEndUpdate = b;
283 virtual void setStatic(
bool b)
288 virtual bool isStatic()
293 inline void setLock(
bool b)
298 virtual void setVisible(
bool b);
300 inline bool isContainer()
302 return m_isContainer;
305 void setCullingLayer(
u32 layer);
307 void setCullingLayerOnOff(
u32 value,
bool on);
309 inline u32 getCullingLayer()
311 return m_cullingLayer;
314 inline void setEditorObject(
bool b)
319 inline bool isEditorObject()
321 return m_editorObject;
324 inline void tagData(
void* data)
329 inline void tagData(
int data)
334 inline void tagData(std::string& s)
339 inline void* getTagData()
344 inline int getTagDataInt()
349 const char* getTagDataString()
351 return m_tagDataString.c_str();
354 virtual void updateObject();
356 virtual void endUpdate();
358 virtual void remove();
367 bool removeComponent();
371 void releaseAllComponent();
377 inline std::vector<CComponentSystem*>& getListComponent()
384 inline int getComponentCount()
386 return (
int)m_components.size();
391 return m_components[i];
398 int getSerializableComponentCount();
404 void sortComponent(std::vector<std::string>& templateOrder);
406 inline void enableEditorChange(
bool b)
408 m_enableEditorChange = b;
411 inline void enableEditorSelect(
bool b)
413 m_enableEditorSelect = b;
416 inline bool isEnableEditorChange()
418 return m_enableEditorChange;
421 inline bool isEnableEditorSelect()
423 return m_enableEditorSelect;
426 void startComponent();
432 DECLARE_GETTYPENAME(CGameObject)
436 typedef std::vector<CGameObject*> ArrayGameObject;
437 typedef std::vector<CGameObject*>::iterator ArrayGameObjectIter;
440 typedef std::vector<CComponentSystem*> ArrayComponent;
441 typedef std::vector<CComponentSystem*>::iterator ArrayComponentIter;
444 T* CGameObject::addComponent()
446 T* newComp =
new T();
448 if (compSystem == NULL)
450 char exceptionInfo[512];
451 sprintf(exceptionInfo,
"CGameObject::addComponent %s must inherit CComponentSystem",
typeid(T).name());
452 os::Printer::log(exceptionInfo);
457 m_components.push_back(compSystem);
459 compSystem->setOwner(
this);
460 compSystem->initComponent();
462 CDependentComponent::createGetInstance()->createDependentComponent(compSystem);
467 T* CGameObject::getComponent()
469 ArrayComponentIter i = m_components.begin(), end = m_components.end();
472 T* c =
dynamic_cast<T*
>(*i);
481 bool CGameObject::removeComponent()
483 ArrayComponentIter i = m_components.begin(), end = m_components.end();
486 T* c =
dynamic_cast<T*
>(*i);
489 m_components.erase(i);
This is an abstract class that describes a component that is called to update continuously....
Definition CComponentSystem.h:43
This is the object class that describes an entity.
Definition CEntity.h:58
This object class manages all entities within a scene.
Definition CEntityManager.h:89
Definition CObjectSerializable.h:36
This object class manages all other objects, it represents the data of a scene.
Definition CScene.h:103
It's the primary container object for the CScene; all CGameObject have a CZone as their root parent.
Definition CZone.h:37
Quaternion class for representing rotations.
Definition quaternion.h:27
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition matrix4.h:2241
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58