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,
61 cFlags = 1000,
63 cMenu = 1200,
66 cMenuItem = 1500,
68 cSelector = 1600,
69 cButton = 1700,
70 cParticleGenerator = 2500, // keep after anything that would trigger particles
71 };
72
73
74 auto getType() const -> ComponentTypeEnum
75 {
76 return type;
77 }
78
79 [[nodiscard]] auto getKey() const -> Key override;
80
81 friend auto to_json(json& j, const Component& obj) -> void;
82
83 auto showMenu() -> void override;
84
85 virtual auto componentShowMenu() -> void
86 {
87 };
88
94 auto getEntityParent() const -> Entity*;
95
96protected:
97 // Put as protected so Components that inherit can call this constructor
105 auto getComponentJson() const -> json;
106
112 auto getChildren() const -> std::shared_ptr<std::vector<GameObject*>> override;
113
114private:
116};
117
118// Component Namespace
119namespace cmpnt
120{
121
122
123struct Sorter
124{
125 auto operator()(const Component* left, const Component* right) const -> bool
126 {
127 return left->getType() < right->getType();
128 }
129};
130
131}
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:85
auto getType() const -> ComponentTypeEnum
Definition Component.h:74
auto getComponentJson() const -> json
Definition Component.cpp:94
ComponentTypeEnum type
Definition Component.h:115
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
@ cPlayerCountScene
Definition Component.h:59
@ cTutorialScene
Definition Component.h:55
@ cEntityMover
Definition Component.h:65
@ cMainScene
Definition Component.h:50
@ cCollider
Definition Component.h:40
@ cCreditsScene
Definition Component.h:54
@ cMenuPosition
Definition Component.h:67
@ cPhysics
Definition Component.h:37
@ cPlayer
Definition Component.h:46
@ cMenuItem
Definition Component.h:66
@ cBoard
Definition Component.h:47
@ cScene
Definition Component.h:48
@ cOptionsScene
Definition Component.h:53
@ cActionList
Definition Component.h:64
@ cButton
Definition Component.h:69
@ cAnimation
Definition Component.h:38
@ cSelector
Definition Component.h:68
@ cTable
Definition Component.h:43
@ cErrorType
Definition Component.h:36
@ cParticleGenerator
Definition Component.h:70
@ cSplashScreenScene
Definition Component.h:57
@ cMenu
Definition Component.h:63
@ cFlags
Definition Component.h:61
@ 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
@ cPlayerJoinScene
Definition Component.h:60
@ cSelectable
Definition Component.h:62
@ 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:39
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:545
GameObject(std::string typeName, gobj::Type parentType, gobj::Type type)
constructor for gameobject.
Definition GameObject.cpp:23
Definition Component.cpp:81
Definition Component.h:124
auto operator()(const Component *left, const Component *right) const -> bool
Definition Component.h:125