Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
componentsbank.c
Go to the documentation of this file.
1
class
ComponentsBank
2
{
3
private
EntityAI
m_EntityParent
;
4
private
ref
Component
m_Components
[
COMP_TYPE_COUNT
];
5
6
void
ComponentsBank
(
EntityAI
entity_parent)
7
{
8
m_EntityParent
= entity_parent;
9
}
10
11
Component
GetComponent
(
int
comp_type,
string
extended_class_name=
""
)
12
{
13
if
( !
Component
.
IsTypeExist
(comp_type) )
14
{
15
Component
.
LogErrorBadCompType
(comp_type,
"EntityAI.GetComponent(int comp_type)"
);
16
return
NULL;
17
}
18
19
if
( !
IsComponentAlreadyExist
(comp_type) )
20
{
21
CreateComponent
(comp_type, extended_class_name);
22
}
23
24
return
m_Components
[comp_type];
25
}
26
27
bool
DeleteComponent
(
int
comp_type)
28
{
29
if
(
IsComponentAlreadyExist
(comp_type) )
30
{
31
m_Components
[comp_type] = NULL;
32
return
true
;
33
}
34
35
return
false
;
36
}
37
38
private
Component
CreateComponent
(
int
comp_type,
string
extended_class_name=
""
)
39
{
40
if
( !
Component
.
IsTypeExist
(comp_type) )
41
{
42
Component
.
LogErrorBadCompType
(comp_type,
"EntityAI->CreateComponent(int comp_type)"
);
43
return
NULL;
44
}
45
46
if
(
IsComponentAlreadyExist
(comp_type) )
47
{
48
Component
.
LogWarningAlredyExist
(comp_type,
"EntityAI->CreateComponent(int comp_type)"
);
49
return
m_Components
[comp_type];
50
}
51
52
53
string
clas_name = extended_class_name;
54
55
if
( clas_name ==
string
.
Empty
)
56
{
57
clas_name =
Component
.
GetNameByType
(comp_type);
58
}
59
60
Component
comp =
Component
.Cast(clas_name.
ToType
().Spawn());
61
62
comp.
SetParentEntityAI
(
m_EntityParent
);
63
comp.
Event_OnAwake
();
64
65
m_Components
[comp_type] = comp;
66
67
comp.
Event_OnInit
();
68
69
return
comp;
70
}
71
72
bool
IsComponentAlreadyExist
(
int
comp_type)
73
{
74
if
(
m_Components
[comp_type] != NULL )
75
{
76
return
true
;
77
}
78
79
return
false
;
80
}
81
}
Component
Definition
component.c:16
Component::GetNameByType
static string GetNameByType(int comp_type)
Definition
component.c:48
Component::SetParentEntityAI
void SetParentEntityAI(EntityAI e)
Definition
component.c:94
Component::LogWarningAlredyExist
static void LogWarningAlredyExist(int comp_type, string fnc_name)
Definition
component.c:85
Component::Event_OnInit
void Event_OnInit()
Definition
component.c:110
Component::Event_OnAwake
void Event_OnAwake()
Definition
component.c:102
Component::LogErrorBadCompType
static void LogErrorBadCompType(int comp_type, string fnc_name)
Definition
component.c:76
Component::IsTypeExist
static bool IsTypeExist(int comp_type)
Definition
component.c:62
ComponentsBank::ComponentsBank
void ComponentsBank(EntityAI entity_parent)
Definition
componentsbank.c:6
ComponentsBank::IsComponentAlreadyExist
bool IsComponentAlreadyExist(int comp_type)
Definition
componentsbank.c:72
ComponentsBank::m_Components
ref Component m_Components[COMP_TYPE_COUNT]
Definition
componentsbank.c:4
ComponentsBank::CreateComponent
Component CreateComponent(int comp_type, string extended_class_name="")
Definition
componentsbank.c:38
ComponentsBank::GetComponent
Component GetComponent(int comp_type, string extended_class_name="")
Definition
componentsbank.c:11
ComponentsBank::DeleteComponent
bool DeleteComponent(int comp_type)
Definition
componentsbank.c:27
ComponentsBank::m_EntityParent
EntityAI m_EntityParent
Definition
componentsbank.c:3
EntityAI
Definition
inventoryitem.c:2
COMP_TYPE_COUNT
const int COMP_TYPE_COUNT
Definition
component.c:12
string::ToType
proto native ToType()
Returns internal type representation.
Empty
Empty
Definition
hand_states.c:14
Games
Dayz
scripts
3_game
tools
componentsbank.c
Generated by
1.17.0