Begin the documentation
This commit is contained in:
@ -21,10 +21,31 @@ namespace Dawn {
|
||||
std::weak_ptr<Scene> scene;
|
||||
sceneitemid_t id;
|
||||
|
||||
/**
|
||||
* Constructor for a SceneItem. Scene Items should only be called and
|
||||
* initialized by the scene itself.
|
||||
*
|
||||
* @param scene Weak pointer to the Scene that this SceneItem belongs to.
|
||||
* @param id Scene Item ID that the Scene assigned this SceneItem.
|
||||
*/
|
||||
SceneItem(std::weak_ptr<Scene> scene, sceneitemid_t id);
|
||||
|
||||
|
||||
/**
|
||||
* Called by the Scene the frame after we were constructed so we can begin
|
||||
* existing.
|
||||
*/
|
||||
void init();
|
||||
|
||||
/**
|
||||
* Adds a component to this scene item. Components will only have their
|
||||
* init methods invoked on the first frame we enter the scene. If you add
|
||||
* a component to this item after this time you will either need to try
|
||||
* manually invoking its' init method, or ensure the component is aware of
|
||||
* the entire SceneItem lifecycle and listen for added callbacks.
|
||||
*
|
||||
* @tparam T Type of component being added to this scene item.
|
||||
* @return A shared pointer to the newly added component.
|
||||
*/
|
||||
template<class T>
|
||||
std::shared_ptr<T> addComponent() {
|
||||
auto component = std::make_shared<T>(weak_from_this());
|
||||
@ -32,6 +53,14 @@ namespace Dawn {
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a component attached to this SceneItem. This method will return
|
||||
* either a shared pointer to the component, or nullptr if the item does
|
||||
* not have the queried component.
|
||||
*
|
||||
* @tparam T Type of component to be fetched.
|
||||
* @return A shared pointer to the component, or nullptr if not found.
|
||||
*/
|
||||
template<class T>
|
||||
std::shared_ptr<T> getComponent() {
|
||||
auto it = this->components.begin();
|
||||
@ -43,6 +72,9 @@ namespace Dawn {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy this SceneItem.
|
||||
*/
|
||||
~SceneItem();
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user