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
22
28{
29public:
30#pragma region static_functions
31
32#pragma endregion
33
36 auto operator=(const PlayerJoinScene&) -> PlayerJoinScene& = default;
37 ~PlayerJoinScene() override = default;
38 PlayerJoinScene(PlayerJoinScene&& other) noexcept;
39 auto operator=(PlayerJoinScene&& other) noexcept -> PlayerJoinScene& = default;
40
41#pragma region overriden_functions
42
43 auto clone() const -> std::unique_ptr<GameObject> override
44 {
45 return std::make_unique<PlayerJoinScene>(*this);
46 }
47
48 auto componentShowMenu() -> void override;
49 auto onUpdate(float dt) -> void override;
50
51 auto endWindow() -> void override
52 {
53 } // for debug ImGUI
54 auto onRender() -> void override;
55 auto onEnterEngine() -> void override;
56 auto load(const Stream& stream) -> void override;
57 auto save(Stream& stream) const -> void override;
58
59 friend auto to_json(json& j, const PlayerJoinScene& n) -> void;
60 friend auto from_json(const json& j, PlayerJoinScene& n) -> void;
61
62
63#pragma endregion
64
65#pragma region PlayerJoinScene_functions
66
67#pragma endregion
68
69#pragma region messaging_functions
70
71 auto linkMessages() -> void;
72
73
75 auto receiveSelectPressed(const Message* message) -> Message;
76
78 auto receiveSelectClicked(const Message* message) -> Message;
79
81 auto receiveDeselect(const Message* message) -> Message;
82
84 auto GoToGameplayButtonPressed(const Message* message) -> Message;
85
87 auto receivePauseKeyPressed(const Message* message) -> Message;
88
89#pragma endregion
90
91private:
92#pragma region member_variables
93
95 std::vector<int> availablePlayerSlots;
96
98 std::vector<int> currentPlayers;
99
102
103
104#pragma endregion
105
106#pragma region helper_functions
107
109 auto attemptToAddPlayer(const Message* message) -> Message;
110
111#pragma endregion
112
113#pragma region static_variables
114
115#pragma endregion
116
117};
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
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:23
Component that handles players connecting / disconnecting input devices in the "connect controllers" ...
Definition PlayerJoinScene.h:28
std::vector< int > availablePlayerSlots
Vector used to see what slots for players to join.
Definition PlayerJoinScene.h:95
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:101
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:282
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:98
auto clone() const -> std::unique_ptr< GameObject > override
makes a copy a GameObject even if it's held polymorphically
Definition PlayerJoinScene.h:43
auto onRender() -> void override
called every frame after update has been called for every object.
Definition PlayerJoinScene.cpp:117
auto receivePauseKeyPressed(const Message *message) -> Message
Takes the player back to Main Menu.
Definition PlayerJoinScene.cpp:275
auto endWindow() -> void override
currently unused, but intended to but was assumed to be necessary for a proper ImGui editor
Definition PlayerJoinScene.h:51
auto operator=(const PlayerJoinScene &) -> PlayerJoinScene &=default
Definition Message.h:34