DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ Event_OnAwake()

override void ComponentEnergyManager::Event_OnAwake ( )
inlineprotected

См. определение в файле ComponentEnergyManager.c строка 178

179 {
180 if (!m_ThisEntityAI)
181 return;
182
183 string cfg_item = "CfgVehicles " + m_ThisEntityAI.GetType();
184 string cfg_energy_manager = cfg_item + " EnergyManager ";
185
186 // Read all config parameters
187 m_EnergyUsage = g_Game.ConfigGetFloat(cfg_energy_manager + "energyUsagePerSecond");
188 bool switch_on = g_Game.ConfigGetFloat(cfg_energy_manager + "switchOnAtSpawn");
189 m_AutoSwitchOff = g_Game.ConfigGetFloat(cfg_energy_manager + "autoSwitchOff");
190 m_HasElectricityIcon = g_Game.ConfigGetFloat(cfg_energy_manager + "hasIcon");
191 m_AutoSwitchOffWhenInCargo = g_Game.ConfigGetFloat(cfg_energy_manager + "autoSwitchOffWhenInCargo");
192
193 m_EnergyAtSpawn = g_Game.ConfigGetFloat(cfg_energy_manager + "energyAtSpawn");
195 m_EnergyStorageMax = g_Game.ConfigGetFloat(cfg_energy_manager + "energyStorageMax");
196 m_ReduceMaxEnergyByDamageCoef = g_Game.ConfigGetFloat(cfg_energy_manager + "reduceMaxEnergyByDamageCoef");
197 m_SocketsCount = g_Game.ConfigGetFloat(cfg_energy_manager + "powerSocketsCount");
198
199 m_IsPassiveDevice = g_Game.ConfigGetFloat(cfg_energy_manager + "isPassiveDevice");
200 m_CordLength = g_Game.ConfigGetFloat(cfg_energy_manager + "cordLength");
201 m_PlugType = g_Game.ConfigGetFloat(cfg_energy_manager + "plugType");
202
203 m_AttachmentActionType = g_Game.ConfigGetFloat(cfg_energy_manager + "attachmentAction");
204 m_WetnessExposure = g_Game.ConfigGetFloat(cfg_energy_manager + "wetnessExposure");
205
206 float update_interval = g_Game.ConfigGetFloat(cfg_energy_manager + "updateInterval");
207
208 m_ConvertEnergyToQuantity = g_Game.ConfigGetFloat(cfg_energy_manager + "convertEnergyToQuantity");
209
210
211 // Check if energy->quantity converion is configured properly
212 float cfg_max_quantity = g_Game.ConfigGetFloat (cfg_item + " varQuantityMax");
213
214 if (m_ConvertEnergyToQuantity && cfg_max_quantity <= 0)
215 {
216 string error = "Error! Item " + m_ThisEntityAI.GetType() + " has invalid configuration of the energy->quantity conversion feature. To fix this, add 'varQuantityMax' parameter with value higher than 0 to the item's config. Then make sure to re-build the PBO containing this item!";
217 Error(error);
219 }
220 else
221 {
223 {
226
227 m_UpdateQuantityTimer.Run( 0.3 , this, "OnEnergyAdded", NULL, false);
228 }
229 }
230
231 // Set update interval
232 if ( update_interval <= 0 )
233 update_interval = DEFAULT_UPDATE_INTERVAL;
234
235 SetUpdateInterval( update_interval );
236
237 // If energyAtSpawn is present, then use its value for energyStorageMax if that cfg param is not present (for convenience's sake)
238 string cfg_check_energy_limit = cfg_energy_manager + "energyStorageMax";
239
240 if ( !g_Game.ConfigIsExisting (cfg_check_energy_limit) && m_Energy > 0 )
241 {
243 }
244
245 // Fill m_CompatiblePlugTypes
246 string cfg_check_plug_types = cfg_energy_manager + "compatiblePlugTypes";
247
248 if ( g_Game.ConfigIsExisting (cfg_check_plug_types) )
249 {
251 g_Game.ConfigGetIntArray(cfg_check_plug_types, m_CompatiblePlugTypes);
252 }
253
254 if (GetSocketsCount() > 0)
255 m_PluggedDevices = new array<EntityAI>;
256
257 if ( m_CordLength < 0 )
258 {
259 m_CordLength = 0;
260 string error_message_cord = "Warning! " + m_ThisEntityAI.GetType() + ": config parameter 'cordLength' is less than 0! Cord length should not be negative!";
261 DPrint(error_message_cord);
262 }
263
264 if (GetSocketsCount() > 0)
265 {
266 m_DeviceByPlugSelection = new map<string,EntityAI>;
267 // Prepare the m_DeviceByPlugSelection
268 string cfg_animation_sources = "cfgVehicles " + m_ThisEntityAI.GetType() + " " + "AnimationSources ";
269 int animation_sources_count = g_Game.ConfigGetChildrenCount(cfg_animation_sources);
270
271 for (int i_selection = 0; i_selection < animation_sources_count; i_selection++)
272 {
273 // TO DO: This could be optimized so not all selections on item are considered as plug/socket selections.
274 string selection;
275 g_Game.ConfigGetChildName(cfg_animation_sources, i_selection, selection);
276 m_DeviceByPlugSelection.Set(selection, NULL);
277 }
278 }
279
280
281
282 // Prepare sockets
284 {
286 string error_message_sockets = "Error! " + m_ThisEntityAI.GetType() + ": config parameter 'powerSocketsCount' is higher than the current limit (" + MAX_SOCKETS_COUNT.ToString() + ")! Raise the limit (constant MAX_SOCKETS_COUNT) or decrease the powerSocketsCount parameter for this device!";
287 DPrint(error_message_sockets);
288 }
289
290 m_Sockets[MAX_SOCKETS_COUNT]; // Handles selections for plugs in the sockets. Feel free to change the limit if needed.
291
292 g_Game.ConfigGetText(cfg_energy_manager + "cordTextureFile", m_CordTextureFile);
293
294 if ( switch_on )
295 {
296 SwitchOn();
297 }
298
299 for ( int i = 0; i <= GetSocketsCount(); ++i )
300 {
301 m_ThisEntityAI.HideSelection ( SOCKET_ + i.ToString() + _PLUGGED );
302 }
303
304 // Show/hide inventory sockets
306 if ( GetSocketsCount() > 0 && IsPlugCompatible(PLUG_COMMON_APPLIANCE) && m_ThisEntityAI.GetType() != "MetalWire" ) // metal wire filter is hopefully temporal.
307 {
309 }
310
312
313 m_ThisEntityAI.HideSelection( SEL_CORD_PLUGGED );
314
315
316 #ifdef DIAG_DEVELOPER
317 g_Game.m_EnergyManagerArray.Insert( this );
318 #endif
319 }
const int PLUG_COMMON_APPLIANCE
DayZGame g_Game
Определения DayZGame.c:3942
EntityAI m_ThisEntityAI
Определения Component.c:24
void SwitchOn()
Energy manager: Switches ON the device so it starts doing its work if it has enough energy.
Определения ComponentEnergyManager.c:384
static const string SOCKET_
Определения ComponentEnergyManager.c:62
float m_WetnessExposure
Определения ComponentEnergyManager.c:56
bool m_ConvertEnergyToQuantity
Определения ComponentEnergyManager.c:36
float m_EnergyAtSpawn
Определения ComponentEnergyManager.c:50
ref Timer m_UpdateQuantityTimer
Определения ComponentEnergyManager.c:74
bool m_HasElectricityIcon
Определения ComponentEnergyManager.c:33
static const string _PLUGGED
Определения ComponentEnergyManager.c:63
void SetUpdateInterval(float value)
Energy manager: Sets the interval of the OnWork(...) calls. Changing this value does not change the r...
Определения ComponentEnergyManager.c:740
const float DEFAULT_UPDATE_INTERVAL
Определения ComponentEnergyManager.c:20
ref array< EntityAI > m_PluggedDevices
Определения ComponentEnergyManager.c:70
const int MAX_SOCKETS_COUNT
Определения ComponentEnergyManager.c:77
float m_ReduceMaxEnergyByDamageCoef
Определения ComponentEnergyManager.c:52
ref TIntArray m_CompatiblePlugTypes
Определения ComponentEnergyManager.c:68
EntityAI m_Sockets[MAX_SOCKETS_COUNT]
Определения ComponentEnergyManager.c:78
ref map< string, EntityAI > m_DeviceByPlugSelection
Определения ComponentEnergyManager.c:71
int m_AttachmentActionType
Определения ComponentEnergyManager.c:44
bool m_ShowSocketsInInventory
Определения ComponentEnergyManager.c:32
static const string SEL_CORD_PLUGGED
Определения ComponentEnergyManager.c:65
bool m_AutoSwitchOffWhenInCargo
Определения ComponentEnergyManager.c:34
float m_EnergyStorageMax
Определения ComponentEnergyManager.c:51
bool IsPlugCompatible(int plug_ID)
Energy manager: Checks if the given plug is compatible with this device's socket. Used by CanReceiveP...
Определения ComponentEnergyManager.c:985
string m_CordTextureFile
Определения ComponentEnergyManager.c:59
int GetSocketsCount()
Energy manager: Returns the count of power sockets (whenever used or not)
Определения ComponentEnergyManager.c:1147
bool HasEnoughStoredEnergy()
Energy manager: Returns true if this device has enough of stored energy for its own use.
Определения ComponentEnergyManager.c:944
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
proto void DPrint(string var)
Prints content of variable to console/log. Should be used for critical messages so it will appear in ...
array< int > TIntArray
Определения EnScript.c:714
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/DayZ/tools/tools.c:8

Перекрестные ссылки _PLUGGED, CALL_CATEGORY_SYSTEM, DEFAULT_UPDATE_INTERVAL, DPrint(), Error(), g_Game, GetSocketsCount(), HasEnoughStoredEnergy(), IsPlugCompatible(), m_AttachmentActionType, m_AutoSwitchOff, m_AutoSwitchOffWhenInCargo, m_CanWork, m_CompatiblePlugTypes, m_ConvertEnergyToQuantity, m_CordLength, m_CordTextureFile, m_DeviceByPlugSelection, m_Energy, m_EnergyAtSpawn, m_EnergyStorageMax, m_EnergyUsage, m_HasElectricityIcon, m_IsPassiveDevice, m_PluggedDevices, m_PlugType, m_ReduceMaxEnergyByDamageCoef, m_ShowSocketsInInventory, m_Sockets, m_SocketsCount, Component::m_ThisEntityAI, m_UpdateQuantityTimer, m_WetnessExposure, MAX_SOCKETS_COUNT, PLUG_COMMON_APPLIANCE, SEL_CORD_PLUGGED, SetUpdateInterval(), SOCKET_ и SwitchOn().