DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ComponentsBank.c
См. документацию.
2{
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
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}
Empty
Определения Hand_States.c:14
void SetParentEntityAI(EntityAI e)
Определения Component.c:94
static void LogErrorBadCompType(int comp_type, string fnc_name)
Определения Component.c:76
static void LogWarningAlredyExist(int comp_type, string fnc_name)
Определения Component.c:85
static string GetNameByType(int comp_type)
Определения Component.c:48
void Event_OnInit()
Определения Component.c:110
static bool IsTypeExist(int comp_type)
Определения Component.c:62
void Event_OnAwake()
Определения Component.c:102
Определения Component.c:16
Component GetComponent(int comp_type, string extended_class_name="")
Определения ComponentsBank.c:11
bool IsComponentAlreadyExist(int comp_type)
Определения ComponentsBank.c:72
ref Component m_Components[COMP_TYPE_COUNT]
Определения ComponentsBank.c:4
void ComponentsBank(EntityAI entity_parent)
Определения ComponentsBank.c:6
bool DeleteComponent(int comp_type)
Определения ComponentsBank.c:27
EntityAI m_EntityParent
Определения ComponentsBank.c:3
Component CreateComponent(int comp_type, string extended_class_name="")
Определения ComponentsBank.c:38
Определения Building.c:6
const int COMP_TYPE_COUNT
Определения Component.c:12
proto native ToType()
Returns internal type representation. Can be used in runtime, or cached in variables and used for fas...