Even more shared pointers.

This commit is contained in:
2023-11-10 22:33:21 -06:00
parent 732a90931c
commit 085facd079
19 changed files with 89 additions and 80 deletions

View File

@ -9,15 +9,15 @@ using namespace Dawn;
DawnGame::DawnGame(const std::weak_ptr<DawnHost> host) :
host(host),
renderManager(),
inputManager(this),
saveManager(this)
{
renderManager = std::make_shared<RenderManager>();
}
int32_t DawnGame::init() {
this->assetManager.init();
this->renderManager.init(weak_from_this());
this->renderManager->init(weak_from_this());
this->scene = dawnGameGetInitialScene(this);
@ -31,10 +31,9 @@ int32_t DawnGame::update(float_t delta) {
if(this->scene != nullptr) this->scene->update();
this->renderManager.update();
this->renderManager->update();
if(this->sceneToCutTo != nullptr) {
delete this->scene;
this->scene = nullptr;
this->scene = this->sceneToCutTo;
this->sceneToCutTo = nullptr;
@ -47,7 +46,7 @@ int32_t DawnGame::update(float_t delta) {
return DAWN_GAME_UPDATE_RESULT_SUCCESS;
}
void DawnGame::sceneCutover(Scene *scene) {
void DawnGame::sceneCutover(std::shared_ptr<Scene> scene) {
if(scene == nullptr) scene = this->scene;
this->sceneToCutTo = scene;
}

View File

@ -24,15 +24,15 @@ namespace Dawn {
class DawnGame : public std::enable_shared_from_this<DawnGame> {
private:
Scene *sceneToCutTo = nullptr;
std::shared_ptr<Scene> sceneToCutTo;
bool_t closeRequested = false;
public:
const std::weak_ptr<DawnHost> host;
Scene *scene = nullptr;
std::shared_ptr<Scene> scene;
AssetManager assetManager;
TimeManager timeManager;
RenderManager renderManager;
std::shared_ptr<RenderManager> renderManager;
InputManager inputManager;
SaveManager saveManager;
@ -75,7 +75,7 @@ namespace Dawn {
*
* @param scene Scene to cut over to.
*/
void sceneCutover(Scene *scene);
void sceneCutover(std::shared_ptr<Scene> scene);
/**
* Gracefully requests that the game should be closed as soon as possible.
@ -90,5 +90,5 @@ namespace Dawn {
* @param game Game that is requesting this scene.
* @return Pointer to a scene that you wish to have as the default scene.
*/
Scene * dawnGameGetInitialScene(DawnGame *game);
std::shared_ptr<Scene> dawnGameGetInitialScene(DawnGame *game);
}