Brunot
Loading...
Searching...
No Matches
Scene.h
Go to the documentation of this file.
1// File: Scene.h
2// Description: Component that marks the scene SceneManager uses this to identify scenes
3// Author(s): Aidan Hartman (aidan.hartman@digipen.edu) Basic Implementation
4// Marcelo Escamilla (marcelo.escamilla@digipen.edu) JSON Serialization
5// 2025 / 10 / 20
6// (C) Digipen 2025
7// // ____ __ __ __
8// // /\__ _\/\ \ /\ \/\ \
9// // \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
10// // \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
11// // \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
12// // \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
13// // \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
14#pragma once
15
16#include "Framework/Component.h"
17
18#include <stack>
19
20#include "System/SceneManager.h"
21
22
23class Scene : public Component
24{
25public:
26 Scene();
27 explicit Scene(std::string name);
28
29 Scene(const Scene&) = default;
30 auto operator=(const Scene&) -> Scene& = default;
31 ~Scene() override;
32 Scene(Scene&& other) noexcept = default;
33 auto operator=(Scene&& other) noexcept -> Scene& = default;
34
35 auto clone() const -> std::unique_ptr<GameObject> override;
36
37 auto componentShowMenu() -> void override;
38 auto onUpdate(float dt) -> void override;
39 auto onRender() -> void override;
40 auto onEnterEngine() -> void override;
41 auto load(Stream& stream) -> void override;
42 auto save(Stream& stream) const -> void override;
43
44 auto endWindow() -> void override
45 {
46 } // for debug ImGUI
47
48 [[nodiscard]] auto name() const -> const std::string&;
49 auto name(const std::string& name) -> void;
50
51 auto activate() -> void;
52 auto deactivate() -> void;
53
59 auto applyState(SceneState newState) -> SceneState;
60
61 auto pushState(SceneState newState) -> void;
62
63 auto popState() -> void;
64
65 friend auto to_json(json& j, const Scene& p) -> void;
66 friend auto from_json(const json& j, Scene& p) -> void;
67
68 auto getParentScene() const -> Scene*;
69
70private:
71 std::string _name;
73 Scene* parentScene = nullptr;
74 bool _pausesOtherScenes = false;
75 bool _mainScene = false;
76 bool _alwaysRenders = false;
77 bool _registered = false;
78
79 auto updateParent() -> void;
80
81};
auto to_json(json &j, const AudioObject &a) -> void
Definition AudioObject.cpp:376
auto from_json(const json &j, AudioObject &a) -> void
Definition AudioObject.cpp:387
sys::Json Stream
Definition AudioObject.h:20
The base class for components, holding all of their shared All components should inherit from this.
nlohmann::json json
Definition Json.cpp:19
Component(ComponentTypeEnum type, const char *typeName)
Definition Component.cpp:72
GameObject(std::string typeName, gobj::Type parentType, gobj::Type type)
constructor for gameobject.
Definition GameObject.cpp:23
Definition Scene.h:24
auto onRender() -> void override
called every frame after update has been called for every object.
Definition Scene.cpp:114
bool _alwaysRenders
Definition Scene.h:76
auto save(Stream &stream) const -> void override
Implementations will load the state of a GameObject to a th::Json object.
Definition Scene.cpp:129
auto onUpdate(float dt) -> void override
called once every frame.
Definition Scene.cpp:108
auto activate() -> void
Definition Scene.cpp:144
Scene(Scene &&other) noexcept=default
auto popState() -> void
Definition Scene.cpp:255
auto operator=(Scene &&other) noexcept -> Scene &=default
auto name() const -> const std::string &
Definition Scene.cpp:134
bool _mainScene
Definition Scene.h:75
auto updateParent() -> void
Definition Scene.cpp:271
std::stack< SceneState > stack
Definition Scene.h:72
bool _pausesOtherScenes
Definition Scene.h:74
Scene * parentScene
Definition Scene.h:73
~Scene() override
Definition Scene.cpp:38
auto componentShowMenu() -> void override
Definition Scene.cpp:51
auto onEnterEngine() -> void override
hook that is called when a GameObject enters the Engine tree.
Definition Scene.cpp:118
auto applyState(SceneState newState) -> SceneState
sets the state of the scene (updating, rendering, and receiving Messages)
Definition Scene.cpp:203
auto load(Stream &stream) -> void override
Implementations will load the state of a GameObject from a th::Json Object.
Definition Scene.cpp:124
auto endWindow() -> void override
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
Definition Scene.h:44
Scene(const Scene &)=default
Scene()
Definition Scene.cpp:27
auto operator=(const Scene &) -> Scene &=default
auto deactivate() -> void
Definition Scene.cpp:176
auto clone() const -> std::unique_ptr< GameObject > override
makes a copy a GameObject even if it's held polymorphically
Definition Scene.cpp:46
auto pushState(SceneState newState) -> void
Definition Scene.cpp:243
bool _registered
Definition Scene.h:77
auto getParentScene() const -> Scene *
Definition Scene.cpp:266
std::string _name
Definition Scene.h:71
Definition SceneManager.h:24