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 static auto bindLuaTypes(sol::state& lua) -> void;
27 static auto getEnum() -> ComponentTypeEnum
28 {
29 return cScene;
30 }
31 Scene();
32 explicit Scene(std::string name);
33
34 Scene(const Scene&) = default;
35 auto operator=(const Scene&) -> Scene& = default;
36 ~Scene() override;
37 Scene(Scene&& other) noexcept = default;
38 auto operator=(Scene&& other) noexcept -> Scene& = default;
39
40 auto clone() const -> std::unique_ptr<GameObject> override;
41
42 auto componentShowMenu() -> void override;
43 auto onUpdate(float dt) -> void override;
44 auto onRender() -> void override;
45 auto onEnterEngine() -> void override;
46 auto load(const Stream& stream) -> void override;
47 auto save(Stream& stream) const -> void override;
48
49 auto endWindow() -> void override
50 {
51 } // for debug ImGUI
52
53 [[nodiscard]] auto name() const -> const std::string&;
54 auto name(const std::string& name) -> void;
55
56 auto activate() -> void;
57 auto deactivate() -> void;
58
64 auto applyState(SceneState newState) -> SceneState;
65
66 auto pushState(SceneState newState) -> void;
67
68 auto popState() -> void;
69
70 friend auto to_json(json& j, const Scene& p) -> void;
71 friend auto from_json(const json& j, Scene& p) -> void;
72
73 auto getParentScene() const -> Scene*;
74
75
76private:
77 std::string _name;
79 Scene* parentScene = nullptr;
80 bool _pausesOtherScenes = false;
81 bool _mainScene = false;
82 bool _alwaysRenders = false;
83 bool _registered = false;
84
85 auto updateParent() -> void;
86
87};
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
ComponentTypeEnum
This enum lists out every type of component we have.
Definition Component.h:39
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:24
Definition Scene.h:24
auto onRender() -> void override
called every frame after update has been called for every object.
Definition Scene.cpp:115
static auto bindLuaTypes(sol::state &lua) -> void
Definition Scene.cpp:290
bool _alwaysRenders
Definition Scene.h:82
auto save(Stream &stream) const -> void override
Implementations will load the state of a GameObject to a th::Json object.
Definition Scene.cpp:130
auto onUpdate(float dt) -> void override
called once every frame.
Definition Scene.cpp:109
auto activate() -> void
Definition Scene.cpp:145
Scene(Scene &&other) noexcept=default
auto popState() -> void
Definition Scene.cpp:256
auto operator=(Scene &&other) noexcept -> Scene &=default
auto name() const -> const std::string &
Definition Scene.cpp:135
bool _mainScene
Definition Scene.h:81
auto updateParent() -> void
Definition Scene.cpp:272
std::stack< SceneState > stack
Definition Scene.h:78
bool _pausesOtherScenes
Definition Scene.h:80
Scene * parentScene
Definition Scene.h:79
~Scene() override
Definition Scene.cpp:39
auto load(const Stream &stream) -> void override
Implementations will load the state of a GameObject from a th::Json Object.
Definition Scene.cpp:125
auto componentShowMenu() -> void override
Definition Scene.cpp:52
auto onEnterEngine() -> void override
hook that is called when a GameObject enters the Engine tree.
Definition Scene.cpp:119
auto applyState(SceneState newState) -> SceneState
sets the state of the scene (updating, rendering, and receiving Messages)
Definition Scene.cpp:204
auto endWindow() -> void override
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
Definition Scene.h:49
Scene(const Scene &)=default
Scene()
Definition Scene.cpp:28
auto operator=(const Scene &) -> Scene &=default
static auto getEnum() -> ComponentTypeEnum
Definition Scene.h:27
auto deactivate() -> void
Definition Scene.cpp:177
auto clone() const -> std::unique_ptr< GameObject > override
makes a copy a GameObject even if it's held polymorphically
Definition Scene.cpp:47
auto pushState(SceneState newState) -> void
Definition Scene.cpp:244
bool _registered
Definition Scene.h:83
auto getParentScene() const -> Scene *
Definition Scene.cpp:267
std::string _name
Definition Scene.h:77
Definition SceneManager.h:25