44 lines
1019 B
C++
44 lines
1019 B
C++
// Copyright (c) 2022 Dominic Masters
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
#pragma once
|
|
#include "SceneItem.hpp"
|
|
|
|
namespace Dawn {
|
|
class DawnGame;
|
|
|
|
class Scene :
|
|
public std::enable_shared_from_this<Scene>
|
|
{
|
|
private:
|
|
sceneitemid_t nextId;
|
|
std::map<sceneitemid_t,std::shared_ptr<SceneItem>> items;
|
|
std::map<sceneitemid_t,std::shared_ptr<SceneItem>> itemsNotInitialized;
|
|
|
|
public:
|
|
std::weak_ptr<DawnGame> game;
|
|
|
|
Scene(std::weak_ptr<DawnGame> game);
|
|
|
|
void update();
|
|
|
|
std::shared_ptr<SceneItem> createSceneItem();
|
|
|
|
void removeSceneItem(SceneItem *item);
|
|
|
|
template<class T>
|
|
std::shared_ptr<T> findComponent() {
|
|
auto it = this->items.begin();
|
|
while(it != this->items.end()) {
|
|
auto component = it->second->getComponent<T>();
|
|
if(component != nullptr) return component;
|
|
++it;
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
~Scene();
|
|
};
|
|
} |