Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
component.c
Go to the documentation of this file.
1
6
const
string
COMP_NAME_NONE
=
"None"
;
7
const
int
COMP_TYPE_UNDEFINED
= -1;
8
const
int
COMP_TYPE_ETITY_DEBUG
= 0;
9
const
int
COMP_TYPE_ENERGY_MANAGER
= 1;
10
const
int
COMP_TYPE_BODY_STAGING
= 2;
11
const
int
COMP_TYPE_ANIMAL_BLEEDING
= 3;
12
const
int
COMP_TYPE_COUNT
= 4;
14
15
class
Component
16
{
17
18
//==========================================
19
// Variables Private Static
20
private
static
string
m_CompNames
[
COMP_TYPE_COUNT
];
21
22
//==========================================
23
// Variables Private
24
protected
EntityAI
m_ThisEntityAI
;
25
26
//==========================================
27
28
void
Event_OnFrame
(
IEntity
other,
float
timeSlice);
29
Shape
DebugBBoxDraw
();
30
void
DebugBBoxSetColor
(
int
color);
31
void
DebugBBoxDelete
();
32
Shape
DebugDirectionDraw
(
float
distance = 1);
33
void
DebugDirectionSetColor
(
int
color);
34
void
DebugDirectionDelete
();
35
36
// Methods Public Static
37
static
void
Init
()
38
{
39
m_CompNames
[
COMP_TYPE_ETITY_DEBUG
] =
"ComponentEntityDebug"
;
40
m_CompNames
[
COMP_TYPE_ENERGY_MANAGER
] =
"ComponentEnergyManager"
;
41
m_CompNames
[
COMP_TYPE_BODY_STAGING
] =
"ComponentBodyStaging"
;
42
m_CompNames
[
COMP_TYPE_ANIMAL_BLEEDING
] =
"ComponentAnimalBleeding"
;
43
}
44
46
// GetNameByType
48
static
string
GetNameByType
(
int
comp_type)
49
{
50
if
(
IsTypeExist
(comp_type) ==
false
)
51
{
52
LogErrorBadCompType
(comp_type,
"Component->GetNameByType()"
);
53
return
"None"
;
54
}
55
56
return
m_CompNames
[comp_type];
57
}
58
60
// IsTypeExist
62
static
bool
IsTypeExist
(
int
comp_type)
63
{
64
if
( comp_type < 0 || comp_type >=
COMP_TYPE_COUNT
)
65
{
66
return
false
;
67
}
68
69
return
true
;
70
}
71
72
74
// LogErrorBadCompType
76
static
void
LogErrorBadCompType
(
int
comp_type,
string
fnc_name)
77
{
78
string
msg =
"Bad parameter comp_type='"
+comp_type.ToString()+
"'. Parameter must be 0-"
+(
COMP_TYPE_COUNT
- 1).
ToString
()+
". Returning component name 'None'."
;
79
Debug
.
LogError
(msg,
"Component"
,
"n/a"
, fnc_name);
80
}
81
83
// LogWarningAlredyExist
85
static
void
LogWarningAlredyExist
(
int
comp_type,
string
fnc_name)
86
{
87
string
msg =
"Component '"
+
Component
.
GetNameByType
(comp_type)+
"' already exists!"
;
88
Debug
.
LogError
(msg,
"Component"
,
"n/a"
, fnc_name);
89
}
90
91
//=======================================public
92
// SetParentEntityAI
93
//=============================================
94
void
SetParentEntityAI
(
EntityAI
e)
95
{
96
m_ThisEntityAI
= e;
97
}
98
99
//====================================protected
100
// Awake
101
//=============================================
102
void
Event_OnAwake
()
103
{
104
105
}
106
107
//====================================protected
108
// Init
109
//=============================================
110
void
Event_OnInit
()
111
{
112
113
}
114
115
//=======================================public
116
// Log
117
//=============================================
118
void
LogThis
(
string
msg,
string
fnc_name =
"n/a"
)
119
{
120
//Debug.Log(msg, GetCompName(), "n/a", fnc_name, m_ThisEntityAI.ToString());
121
}
122
123
//=======================================public
124
// LogWarning
125
//=============================================
126
void
LogThisWarning
(
string
msg,
string
fnc_name =
"n/a"
)
127
{
128
Debug
.
LogWarning
(msg,
GetCompName
(),
"n/a"
, fnc_name,
m_ThisEntityAI
.ToString());
129
}
130
131
//=======================================public
132
// LogError
133
//=============================================
134
void
LogThisError
(
string
msg,
string
fnc_name =
"n/a"
)
135
{
136
Debug
.
LogError
(msg,
GetCompName
(),
"n/a"
, fnc_name,
m_ThisEntityAI
.ToString());
137
}
138
139
//=======================================public
140
// GetType
141
//=============================================
142
string
GetCompName
()
143
{
144
return
Component
.
GetNameByType
(this.
GetCompType
());
145
}
146
147
//=======================================public
148
// GetType
149
//=============================================
150
int
GetCompType
()
151
{
152
return
COMP_TYPE_UNDEFINED;
153
}
154
155
//=======================================public
156
// Event_OnItemAttached
157
//=============================================
158
void
Event_OnItemAttached
(
EntityAI
item,
string
slot_name)
159
{
160
LogThis
(
""
+ item +
" -> "
+ slot_name,
"Event_OnItemAttached"
);
161
//Debug.Log("Component=>Event_OnItemAttached: " + item + " -> " + slot_name, );
162
}
163
164
//=======================================public
165
// Event_OnItemDetached
166
//=============================================
167
void
Event_OnItemDetached
(
EntityAI
item,
string
slot_name)
168
{
169
LogThis
(
""
+ item +
" <- "
+ slot_name,
"Event_OnItemDetached"
);
170
//Log("Component=>Event_OnItemDetached: " + item + " <- " + slot_name );
171
}
172
}
Component
Definition
component.c:16
Component::GetNameByType
static string GetNameByType(int comp_type)
Definition
component.c:48
Component::Init
static void Init()
Definition
component.c:37
Component::LogThisError
void LogThisError(string msg, string fnc_name="n/a")
Definition
component.c:134
Component::GetCompName
string GetCompName()
Definition
component.c:142
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::DebugBBoxDraw
Shape DebugBBoxDraw()
Component::m_CompNames
static string m_CompNames[COMP_TYPE_COUNT]
Definition
component.c:20
Component::Event_OnFrame
void Event_OnFrame(IEntity other, float timeSlice)
Component::DebugBBoxSetColor
void DebugBBoxSetColor(int color)
Component::DebugDirectionDraw
Shape DebugDirectionDraw(float distance=1)
Component::Event_OnInit
void Event_OnInit()
Definition
component.c:110
Component::m_ThisEntityAI
EntityAI m_ThisEntityAI
Definition
component.c:24
Component::DebugDirectionDelete
void DebugDirectionDelete()
Component::LogThis
void LogThis(string msg, string fnc_name="n/a")
Definition
component.c:118
Component::DebugBBoxDelete
void DebugBBoxDelete()
Component::Event_OnItemDetached
void Event_OnItemDetached(EntityAI item, string slot_name)
Definition
component.c:167
Component::Event_OnAwake
void Event_OnAwake()
Definition
component.c:102
Component::GetCompType
int GetCompType()
Definition
component.c:150
Component::Event_OnItemAttached
void Event_OnItemAttached(EntityAI item, string slot_name)
Definition
component.c:158
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
Component::DebugDirectionSetColor
void DebugDirectionSetColor(int color)
Component::LogThisWarning
void LogThisWarning(string msg, string fnc_name="n/a")
Definition
component.c:126
Debug
Definition
debug.c:2
Debug::LogError
static void LogError(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message as error message.
Definition
debug.c:305
Debug::LogWarning
static void LogWarning(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message as warning message.
Definition
debug.c:290
EntityAI
Definition
inventoryitem.c:2
IEntity
Internal ancestor of all Entity implementations.
Definition
enentity.c:165
ToString
proto string ToString()
COMP_TYPE_ANIMAL_BLEEDING
const int COMP_TYPE_ANIMAL_BLEEDING
Definition
component.c:11
COMP_TYPE_BODY_STAGING
const int COMP_TYPE_BODY_STAGING
Definition
component.c:10
COMP_NAME_NONE
const string COMP_NAME_NONE
Definition
component.c:6
COMP_TYPE_COUNT
const int COMP_TYPE_COUNT
Definition
component.c:12
COMP_TYPE_UNDEFINED
const int COMP_TYPE_UNDEFINED
Definition
component.c:7
COMP_TYPE_ENERGY_MANAGER
const int COMP_TYPE_ENERGY_MANAGER
Definition
component.c:9
COMP_TYPE_ETITY_DEBUG
const int COMP_TYPE_ETITY_DEBUG
Definition
component.c:8
Shape
class DiagMenu Shape
Instance of created debug visualizer.
Games
Dayz
scripts
3_game
tools
component.c
Generated by
1.17.0