DayZ 1.24
Loading...
Searching...
No Matches
Component.c
Go to the documentation of this file.
1
6const string COMP_NAME_NONE = "None";
7const int COMP_TYPE_UNDEFINED = -1;
12const int COMP_TYPE_COUNT = 4;
16{
17
18 //==========================================
19 // Variables Private Static
20 private static string m_CompNames[COMP_TYPE_COUNT];
21
22 //==========================================
23 // Variables Private
25
26 //==========================================
27
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 {
65 return false;
66
67 return true;
68 }
69
70
72 // LogErrorBadCompType
74 static void LogErrorBadCompType(int comp_type, string fnc_name)
75 {
76 string msg = "Bad parameter comp_type='" + comp_type.ToString() + "'. Parameter must be 0-" + (COMP_TYPE_COUNT - 1).ToString() + ". Returning component name 'None'.";
77 Debug.LogError(msg, "Component", "n/a", fnc_name);
78 }
79
81 // LogWarningAlredyExist
83 static void LogWarningAlredyExist(int comp_type, string fnc_name)
84 {
85 string msg = "Component '" + Component.GetNameByType(comp_type) + "' already exists!";
86 Debug.LogError(msg, "Component", "n/a", fnc_name);
87 }
88
89 //=======================================public
90 // SetParentEntityAI
91 //=============================================
96
97 //====================================protected
98 // Awake
99 //=============================================
101 {
102
103 }
104
105 //====================================protected
106 // Init
107 //=============================================
109 {
110
111 }
112
113 //=======================================public
114 // Log
115 //=============================================
116 void LogThis(string msg, string fnc_name = "n/a")
117 {
118 //Debug.Log(msg, GetCompName(), "n/a", fnc_name, m_ThisEntityAI.ToString());
119 }
120
121 //=======================================public
122 // LogWarning
123 //=============================================
124 void LogThisWarning(string msg, string fnc_name = "n/a")
125 {
126 Debug.LogWarning(msg, GetCompName(), "n/a", fnc_name, m_ThisEntityAI.ToString());
127 }
128
129 //=======================================public
130 // LogError
131 //=============================================
132 void LogThisError(string msg, string fnc_name = "n/a")
133 {
134 Debug.LogError(msg, GetCompName(), "n/a", fnc_name, m_ThisEntityAI.ToString());
135 }
136
137 //=======================================public
138 // GetType
139 //=============================================
140 string GetCompName()
141 {
142 return Component.GetNameByType(this.GetCompType());
143 }
144
145 //=======================================public
146 // GetType
147 //=============================================
149 {
150 return COMP_TYPE_UNDEFINED;
151 }
152
153 //=======================================public
154 // Event_OnItemAttached
155 //=============================================
157 {
158 LogThis("" + item + " -> " + slot_name, "Event_OnItemAttached");
159 //Debug.Log("Component=>Event_OnItemAttached: " + item + " -> " + slot_name, );
160 }
161
162 //=======================================public
163 // Event_OnItemDetached
164 //=============================================
166 {
167 LogThis("" + item + " <- " + slot_name, "Event_OnItemDetached");
168 //Log("Component=>Event_OnItemDetached: " + item + " <- " + slot_name );
169 }
170}
proto string ToString()
Shape DebugDirectionDraw(float distance=1)
EntityAI m_ThisEntityAI
Definition Component.c:24
void SetParentEntityAI(EntityAI e)
Definition Component.c:92
static void LogErrorBadCompType(int comp_type, string fnc_name)
Definition Component.c:74
static void LogWarningAlredyExist(int comp_type, string fnc_name)
Definition Component.c:83
string GetCompName()
Definition Component.c:140
void LogThis(string msg, string fnc_name="n/a")
Definition Component.c:116
static string GetNameByType(int comp_type)
Definition Component.c:48
void Event_OnInit()
Definition Component.c:108
void DebugDirectionDelete()
void DebugBBoxDelete()
void Event_OnItemDetached(EntityAI item, string slot_name)
Definition Component.c:165
void Event_OnFrame(IEntity other, float timeSlice)
static bool IsTypeExist(int comp_type)
Definition Component.c:62
void DebugDirectionSetColor(int color)
void LogThisWarning(string msg, string fnc_name="n/a")
Definition Component.c:124
int GetCompType()
Definition Component.c:148
void Event_OnAwake()
Definition Component.c:100
void LogThisError(string msg, string fnc_name="n/a")
Definition Component.c:132
Shape DebugBBoxDraw()
static string m_CompNames[COMP_TYPE_COUNT]
Definition Component.c:20
void DebugBBoxSetColor(int color)
static void Init()
Definition Component.c:37
void Event_OnItemAttached(EntityAI item, string slot_name)
Definition Component.c:156
Definition Debug.c:14
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:321
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:341
const int COMP_TYPE_ANIMAL_BLEEDING
Definition Component.c:11
const int COMP_TYPE_BODY_STAGING
Definition Component.c:10
const string COMP_NAME_NONE
Definition Component.c:6
const int COMP_TYPE_COUNT
Definition Component.c:12
const int COMP_TYPE_UNDEFINED
Definition Component.c:7
const int COMP_TYPE_ENERGY_MANAGER
Definition Component.c:9
const int COMP_TYPE_ETITY_DEBUG
Definition Component.c:8
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead