Brunot
Loading...
Searching...
No Matches
PlayerJoinScene.h
Go to the documentation of this file.
1
10// ____ __ __ __
11// /\__ _\/\ \ /\ \/\ \
12// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
13// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
14// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
15// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
16// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
17
18#pragma once
19#include "Framework/Component.h"
20
21struct Message;
23
29{
30public:
31#pragma region static_functions
32 static auto getEnum() -> ComponentTypeEnum
33 {
34 return cPlayerJoinScene;
35 }
36 static auto bindLuaTypes(sol::state& lua) -> void {}
37
38
39#pragma endregion
40
43 auto operator=(const PlayerJoinScene&) -> PlayerJoinScene& = default;
44 ~PlayerJoinScene() override = default;
45 PlayerJoinScene(PlayerJoinScene&& other) noexcept;
46 auto operator=(PlayerJoinScene&& other) noexcept -> PlayerJoinScene& = default;
47
48#pragma region overriden_functions
49
50 auto clone() const -> std::unique_ptr<GameObject> override
51 {
52 return std::make_unique<PlayerJoinScene>(*this);
53 }
54
55 auto componentShowMenu() -> void override;
56 auto onUpdate(float dt) -> void override;
57
58 auto endWindow() -> void override
59 {
60 } // for debug ImGUI
61 auto onRender() -> void override;
62 auto onEnterEngine() -> void override;
63 auto load(const Stream& stream) -> void override;
64 auto save(Stream& stream) const -> void override;
65
66 friend auto to_json(json& j, const PlayerJoinScene& n) -> void;
67 friend auto from_json(const json& j, PlayerJoinScene& n) -> void;
68
69
70#pragma endregion
71
72#pragma region PlayerJoinScene_functions
73
74#pragma endregion
75
76#pragma region messaging_functions
77
78 auto linkMessages() -> void;
79
80
82 auto receiveSelectPressed(const Message* message) -> Message;
83
85 auto receiveSelectClicked(const Message* message) -> Message;
86
88 auto receiveDeselect(const Message* message) -> Message;
89
91 auto GoToGameplayButtonPressed(const Message* message) -> Message;
92
94 auto receivePauseKeyPressed(const Message* message) -> Message;
95
96#pragma endregion
97
98private:
99#pragma region member_variables
100
102 std::vector<int> availablePlayerSlots;
103
105 std::vector<int> currentPlayers;
106
109
110
111#pragma endregion
112
113#pragma region helper_functions
114
116 auto attemptToAddPlayer(const Message* message) -> Message;
117
118#pragma endregion
119
120#pragma region static_variables
121
122#pragma endregion
123
124};
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
A derived version of selector that only selects from Input if the inputtingDeviceID matches a value i...
Definition FilteredSelector.h:33
GameObject(std::string typeName, gobj::Type parentType, gobj::Type type)
constructor for gameobject.
Definition GameObject.cpp:24
Component that handles players connecting / disconnecting input devices in the "connect controllers" ...
Definition PlayerJoinScene.h:29
std::vector< int > availablePlayerSlots
Vector used to see what slots for players to join.
Definition PlayerJoinScene.h:102
FilteredSelector * gameplayButtonSelector
The invisible selector that sits on the button to go to the gameplay scene. Cached so we don't need t...
Definition PlayerJoinScene.h:108
auto linkMessages() -> void
Definition PlayerJoinScene.cpp:160
auto onEnterEngine() -> void override
hook that is called when a GameObject enters the Engine tree.
Definition PlayerJoinScene.cpp:121
auto receiveSelectClicked(const Message *message) -> Message
Joins the Mouse to the game.
Definition PlayerJoinScene.cpp:202
auto GoToGameplayButtonPressed(const Message *message) -> Message
Takes the player to the gameplay scene.
Definition PlayerJoinScene.cpp:248
auto onUpdate(float dt) -> void override
called once every frame.
Definition PlayerJoinScene.cpp:112
friend auto to_json(json &j, const PlayerJoinScene &n) -> void
Definition PlayerJoinScene.cpp:145
auto save(Stream &stream) const -> void override
Implementations will load the state of a GameObject to a th::Json object.
Definition PlayerJoinScene.cpp:140
auto receiveSelectPressed(const Message *message) -> Message
Joins Keys/Controllers to the game.
Definition PlayerJoinScene.cpp:197
auto load(const Stream &stream) -> void override
Implementations will load the state of a GameObject from a th::Json Object.
Definition PlayerJoinScene.cpp:135
PlayerJoinScene()
Definition PlayerJoinScene.cpp:42
friend auto from_json(const json &j, PlayerJoinScene &n) -> void
Definition PlayerJoinScene.cpp:152
auto receiveDeselect(const Message *message) -> Message
Removes whoever deselected from the game.
Definition PlayerJoinScene.cpp:207
~PlayerJoinScene() override=default
auto attemptToAddPlayer(const Message *message) -> Message
Helper function so we don't have to copy-paste code between receiveSelectPressed and receiveSelectCli...
Definition PlayerJoinScene.cpp:281
auto componentShowMenu() -> void override
Definition PlayerJoinScene.cpp:63
auto operator=(PlayerJoinScene &&other) noexcept -> PlayerJoinScene &=default
std::vector< int > currentPlayers
Vector used to track the order of when inputting devices join.
Definition PlayerJoinScene.h:105
auto clone() const -> std::unique_ptr< GameObject > override
makes a copy a GameObject even if it's held polymorphically
Definition PlayerJoinScene.h:50
static auto getEnum() -> ComponentTypeEnum
Definition PlayerJoinScene.h:32
auto onRender() -> void override
called every frame after update has been called for every object.
Definition PlayerJoinScene.cpp:117
static auto bindLuaTypes(sol::state &lua) -> void
Definition PlayerJoinScene.h:36
auto receivePauseKeyPressed(const Message *message) -> Message
Takes the player back to Main Menu.
Definition PlayerJoinScene.cpp:274
auto endWindow() -> void override
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
Definition PlayerJoinScene.h:58
auto operator=(const PlayerJoinScene &) -> PlayerJoinScene &=default
Definition Message.h:35