Dawn/src/dawn/scene/SceneItemComponent.hpp
2023-02-18 21:10:14 -08:00

73 lines
2.0 KiB
C++

// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "dawnlibs.hpp"
#include "display/Transform.hpp"
namespace Dawn {
class SceneItem;
class Scene;
class DawnGame;
class SceneItemComponent {
public:
SceneItem *item;
Transform *transform;
bool_t hasInitialized = false;
/**
* Constructs a new SceneItemComponent. Components are attached to
* SceneItems and will be individual responsibility components, and must
* communicate to other items/components using methods and events.
*
* @param item Scene Item thsi component belongs to.
*/
SceneItemComponent(SceneItem *item);
/**
* Requested on the first frame that the parent scene item has become
* active, after all of my dependencies are ready.
*/
void init();
/**
* Optionally return all dependencies for this component to wait for init
* for before the component will be initialized.
*
* @return Array of dependencies.
*/
virtual std::vector<SceneItemComponent*> getDependencies();
/**
* Shorthand to return the scene that this component's item belongs to.
* @return The current scene.
*/
Scene * getScene();
/**
* Shorthand to return the game that this scene belongs to.
* @return The current game.
*/
DawnGame * getGame();
/**
* Same as init, but intended for your subclass to override.
*/
virtual void onStart();
/**
* Intended for subclasses to detect when they need to clean themselves up
* but before anything has been completely free'd from memory.
*/
virtual void onDispose();
/**
* Cleanup the SceneItemComponent.
*/
~SceneItemComponent();
};
}