Skylicht Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
Components
CComponentSystem.h
1
/*
2
!@
3
MIT License
4
5
Copyright (c) 2019 Skylicht Technology CO., LTD
6
7
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8
(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10
subject to the following conditions:
11
12
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20
This file is part of the "Skylicht Engine".
21
https://github.com/skylicht-lab/skylicht-engine
22
!#
23
*/
24
25
#pragma once
26
27
#include "Utils/CActivator.h"
28
#include "Serializable/CObjectSerializable.h"
29
#include "Serializable/CArraySerializable.h"
30
#include "CComponentCategory.h"
31
32
#define USE_COMPONENT(component) int component##_used = Skylicht::CComponentSystem::useComponent(new component())
33
#define USE_NAMESPACE_COMPONENT(name, component) int name##_used = Skylicht::CComponentSystem::useComponent(new component())
34
35
namespace
Skylicht
36
{
37
class
CGameObject
;
38
class
CDependentComponent
;
39
42
class
SKYLICHT_API CComponentSystem :
public
IActivatorObject
43
{
44
protected
:
45
CGameObject* m_gameObject;
46
47
void
setOwner(CGameObject* obj)
48
{
49
m_gameObject = obj;
50
}
51
52
bool
m_enable;
53
bool
m_serializable;
54
55
std::vector<CComponentSystem*> m_linkComponent;
56
57
public
:
58
59
static
int
useComponent(CComponentSystem* used);
60
61
public
:
62
friend
class
CGameObject;
63
friend
class
CDependentComponent;
64
65
CComponentSystem();
66
67
virtual
~CComponentSystem();
68
69
const
char
* getName();
70
71
virtual
void
reset();
72
73
virtual
void
initComponent() = 0;
74
75
virtual
void
startComponent();
76
77
virtual
void
updateComponent() = 0;
78
79
virtual
void
endUpdate();
80
81
virtual
void
onEnable(
bool
b);
82
83
virtual
void
onUpdateCullingLayer(u32 mask);
84
85
virtual
CObjectSerializable
* createSerializable();
86
87
virtual
void
loadSerializable(
CObjectSerializable
*
object
);
88
89
void
setEnable(
bool
b);
90
91
inline
bool
isEnable()
92
{
93
return
m_enable;
94
}
95
96
inline
CGameObject* getGameObject()
97
{
98
return
m_gameObject;
99
}
100
101
inline
void
setEnableSerializable(
bool
b)
102
{
103
m_serializable = b;
104
}
105
106
inline
bool
isSerializable()
107
{
108
return
m_serializable;
109
}
110
111
inline
void
addLinkComponent(CComponentSystem* comp)
112
{
113
if
(comp->getGameObject() == m_gameObject)
114
m_linkComponent.push_back(comp);
115
}
116
117
inline
void
removeAllLink()
118
{
119
m_linkComponent.clear();
120
}
121
122
DECLARE_GETTYPENAME(CComponentSystem)
123
};
124
}
Skylicht::CDependentComponent
Definition
CDependentComponent.h:36
Skylicht::CGameObject
This object class stores information for a GameObject.
Definition
CGameObject.h:52
Skylicht::CObjectSerializable
Definition
CObjectSerializable.h:36
Skylicht::IActivatorObject
Base interface for objects created by CActivator.
Definition
CActivator.h:55
Skylicht
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition
AudioDebugLog.h:29
Generated by
1.17.0