This commit is contained in:
2023-11-15 23:13:22 -06:00
parent d8bc1d0fe3
commit 04dbead9a2
19 changed files with 330 additions and 25 deletions

View File

@@ -5,7 +5,8 @@
#include "assert/assert.hpp"
#include "util/Flag.hpp"
#include "SceneComponent.hpp"
#include "scene/Scene.hpp"
#include "game/Game.hpp"
using namespace Dawn;
@@ -46,6 +47,16 @@ std::shared_ptr<SceneItem> SceneComponent::getItem() {
return this->item.lock();
}
std::shared_ptr<Scene> SceneComponent::getScene() {
auto item = this->getItem();
return item->getScene();
}
std::shared_ptr<Game> SceneComponent::getGame() {
auto scene = this->getScene();
return scene->getGame();
}
SceneComponent::~SceneComponent() {
if(Flag::isOn<uint_fast8_t>(
sceneComponentState,

View File

@@ -10,6 +10,8 @@
#define SCENE_COMPONENT_STATE_DISPOSED 0x02
namespace Dawn {
class Game;
class Scene;
class SceneItem;
class SceneComponent : std::enable_shared_from_this<SceneComponent> {
@@ -50,6 +52,20 @@ namespace Dawn {
*/
std::shared_ptr<SceneItem> getItem();
/**
* Returns the scene that this scene component belongs to.
*
* @return Reference to the scene that this component belongs to.
*/
std::shared_ptr<Scene> getScene();
/**
* Returns the game that this scene component belongs to.
*
* @return Reference to the game that this component belongs to.
*/
std::shared_ptr<Game> getGame();
/**
* Disposes this scene component.
*/