Brunot
Loading...
Searching...
No Matches
Component.h
Go to the documentation of this file.
1
12// ____ __ __ __
13// /\__ _\/\ \ /\ \/\ \
14// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
15// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
16// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
17// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
18// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
19
20
21#pragma once
22#include "GameObject.h"
23
24
25class Entity;
26
27class Component : public GameObject
28{
29public:
34 enum ComponentTypeEnum : unsigned short
35 {
37 cPhysics = 100,
40 cCollider = 400,
41 cSprite = 500,
42 cBehavior = 600,
43 cTable = 650,
44 cCard = 700,
45 cDeck = 750,
46 cPlayer = 800,
47 cBoard = 850,
48 cScene = 900,
59 cFlags = 1000,
61 cMenu = 1200,
64 cMenuItem = 1500,
66 cSelector = 1600,
67 cButton = 1700,
68 };
69
70
71 auto getType() const -> ComponentTypeEnum
72 {
73 return type;
74 }
75
76 [[nodiscard]] auto getKey() const -> Key override;
77
78 friend auto to_json(json& j, const Component& obj) -> void;
79
80 auto showMenu() -> void override;
81
82 virtual auto componentShowMenu() -> void
83 {
84 };
85
91 auto getEntityParent() const -> Entity*;
92
93protected:
94 // Put as protected so Components that inherit can call this constructor
102 auto getComponentJson() const -> json;
103
109 auto getChildren() const -> std::shared_ptr<std::vector<GameObject*>> override;
110
111private:
113};
114
115// Component Namespace
116namespace cmpnt
117{
118
119
120struct Sorter
121{
122 auto operator()(const Component* left, const Component* right) const -> bool
123 {
124 return left->getType() < right->getType();
125 }
126};
127
128}
auto to_json(json &j, const AudioObject &a) -> void
Definition AudioObject.cpp:376
the base class for the engine, most things inherit from this.
nlohmann::json json
Definition Json.cpp:19
Definition Component.h:28
virtual auto componentShowMenu() -> void
Definition Component.h:82
auto getType() const -> ComponentTypeEnum
Definition Component.h:71
auto getComponentJson() const -> json
Definition Component.cpp:94
ComponentTypeEnum type
Definition Component.h:112
auto getChildren() const -> std::shared_ptr< std::vector< GameObject * > > override
override for component to return a vector of no children
Definition Component.cpp:101
auto showMenu() -> void override
Called before update each frame, for calling ImGui editor code relevant to the gameObject.
Definition Component.cpp:30
ComponentTypeEnum
This enum lists out every type of component we have.
Definition Component.h:35
@ cDeck
Definition Component.h:45
@ cTutorialScene
Definition Component.h:55
@ cEntityMover
Definition Component.h:63
@ cMainScene
Definition Component.h:50
@ cCollider
Definition Component.h:40
@ cCreditsScene
Definition Component.h:54
@ cMenuPosition
Definition Component.h:65
@ cPhysics
Definition Component.h:37
@ cPlayer
Definition Component.h:46
@ cMenuItem
Definition Component.h:64
@ cBoard
Definition Component.h:47
@ cScene
Definition Component.h:48
@ cOptionsScene
Definition Component.h:53
@ cActionProxy
Definition Component.h:62
@ cButton
Definition Component.h:67
@ cAnimation
Definition Component.h:38
@ cSelector
Definition Component.h:66
@ cTable
Definition Component.h:43
@ cErrorType
Definition Component.h:36
@ cSplashScreenScene
Definition Component.h:57
@ cMenu
Definition Component.h:61
@ cFlags
Definition Component.h:59
@ cBackground
Definition Component.h:56
@ cWinScreenScene
Definition Component.h:58
@ cMainMenuScene
Definition Component.h:51
@ cTransform
Definition Component.h:39
@ cBehavior
Definition Component.h:42
@ cCard
Definition Component.h:44
@ cSelectable
Definition Component.h:60
@ cPauseScene
Definition Component.h:49
@ cConfirmDestructiveActionScene
Definition Component.h:52
@ cSprite
Definition Component.h:41
Component(ComponentTypeEnum type, const char *typeName)
Definition Component.cpp:72
auto getEntityParent() const -> Entity *
gets the parent as an Entity.
Definition Component.cpp:106
auto getKey() const -> Key override
Generates a unique Key that corresponds to the GameObject.
Definition Component.cpp:25
Definition Entity.h:33
the base class for the engine, most things inherit from this.
Definition GameObject.h:77
std::string typeName
the typeName of a GameObject.
Definition GameObject.h:527
GameObject(std::string typeName, gobj::Type parentType, gobj::Type type)
constructor for gameobject.
Definition GameObject.cpp:23
Definition Component.cpp:81
Definition Component.h:121
auto operator()(const Component *left, const Component *right) const -> bool
Definition Component.h:122