Dayz Explorer 1.28.160049
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
28 void Event_OnFrame(IEntity other, float timeSlice);
30 void DebugBBoxSetColor(int color);
32 Shape DebugDirectionDraw(float distance = 1);
33 void DebugDirectionSetColor(int color);
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 //=============================================
95 {
97 }
98
99 //====================================protected
100 // Awake
101 //=============================================
103 {
104
105 }
106
107 //====================================protected
108 // Init
109 //=============================================
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 //=============================================
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}
Shape DebugDirectionDraw(float distance=1)
EntityAI m_ThisEntityAI
Definition component.c:24
void SetParentEntityAI(EntityAI e)
Definition component.c:94
static void LogErrorBadCompType(int comp_type, string fnc_name)
Definition component.c:76
static void LogWarningAlredyExist(int comp_type, string fnc_name)
Definition component.c:85
string GetCompName()
Definition component.c:142
void LogThis(string msg, string fnc_name="n/a")
Definition component.c:118
static string GetNameByType(int comp_type)
Definition component.c:48
void Event_OnInit()
Definition component.c:110
void DebugDirectionDelete()
void DebugBBoxDelete()
void Event_OnItemDetached(EntityAI item, string slot_name)
Definition component.c:167
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:126
int GetCompType()
Definition component.c:150
void Event_OnAwake()
Definition component.c:102
void LogThisError(string msg, string fnc_name="n/a")
Definition component.c:134
Shape DebugBBoxDraw()
void DebugBBoxSetColor(int color)
static void Init()
Definition component.c:37
void Event_OnItemAttached(EntityAI item, string slot_name)
Definition component.c:158
Definition debug.c:2
proto string ToString()
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