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

◆ Event_OnAwake()

override void ComponentEnergyManager::Event_OnAwake ( )
inlineprotected

300 ms

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

173 {
174 if (!m_ThisEntityAI)
175 return;
176
177 string cfg_item = "CfgVehicles " + m_ThisEntityAI.GetType();
178 string cfg_energy_manager = cfg_item + " EnergyManager ";
179
180 // Read all config parameters
181 m_EnergyUsage = g_Game.ConfigGetFloat(cfg_energy_manager + "energyUsagePerSecond");
182 bool switch_on = g_Game.ConfigGetFloat(cfg_energy_manager + "switchOnAtSpawn");
183 m_AutoSwitchOff = g_Game.ConfigGetFloat(cfg_energy_manager + "autoSwitchOff");
184 m_HasElectricityIcon = g_Game.ConfigGetFloat(cfg_energy_manager + "hasIcon");
185 m_AutoSwitchOffWhenInCargo = g_Game.ConfigGetFloat(cfg_energy_manager + "autoSwitchOffWhenInCargo");
186
187 m_EnergyAtSpawn = g_Game.ConfigGetFloat(cfg_energy_manager + "energyAtSpawn");
189 m_EnergyStorageMax = g_Game.ConfigGetFloat(cfg_energy_manager + "energyStorageMax");
190 m_ReduceMaxEnergyByDamageCoef = g_Game.ConfigGetFloat(cfg_energy_manager + "reduceMaxEnergyByDamageCoef");
191 m_SocketsCount = g_Game.ConfigGetFloat(cfg_energy_manager + "powerSocketsCount");
192
193 m_IsPassiveDevice = g_Game.ConfigGetFloat(cfg_energy_manager + "isPassiveDevice");
194 m_CordLength = g_Game.ConfigGetFloat(cfg_energy_manager + "cordLength");
195 m_PlugType = g_Game.ConfigGetFloat(cfg_energy_manager + "plugType");
196
197 m_AttachmentActionType = g_Game.ConfigGetFloat(cfg_energy_manager + "attachmentAction");
198 m_WetnessExposure = g_Game.ConfigGetFloat(cfg_energy_manager + "wetnessExposure");
199
200 float update_interval = g_Game.ConfigGetFloat(cfg_energy_manager + "updateInterval");
201
202 m_ConvertEnergyToQuantity = g_Game.ConfigGetFloat(cfg_energy_manager + "convertEnergyToQuantity");
203
204
205 // Check if energy->quantity converion is configured properly
206 float cfg_max_quantity = g_Game.ConfigGetFloat (cfg_item + " varQuantityMax");
207
208 if (m_ConvertEnergyToQuantity && cfg_max_quantity <= 0)
209 {
210 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!";
211 Error(error);
213 }
214 else
215 {
217 {
218 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(OnEnergyAdded, 300);
219 }
220 }
221
222 // Set update interval
223 if ( update_interval <= 0 )
224 update_interval = DEFAULT_UPDATE_INTERVAL;
225
226 SetUpdateInterval( update_interval );
227
228 // If energyAtSpawn is present, then use its value for energyStorageMax if that cfg param is not present (for convenience's sake)
229 string cfg_check_energy_limit = cfg_energy_manager + "energyStorageMax";
230
231 if ( !g_Game.ConfigIsExisting (cfg_check_energy_limit) && m_Energy > 0 )
232 {
234 }
235
236 // Fill m_CompatiblePlugTypes
237 string cfg_check_plug_types = cfg_energy_manager + "compatiblePlugTypes";
238
239 if ( g_Game.ConfigIsExisting (cfg_check_plug_types) )
240 {
242 g_Game.ConfigGetIntArray(cfg_check_plug_types, m_CompatiblePlugTypes);
243 }
244
245 if (GetSocketsCount() > 0)
246 m_PluggedDevices = new array<EntityAI>;
247
248 if ( m_CordLength < 0 )
249 {
250 m_CordLength = 0;
251 string error_message_cord = "Warning! " + m_ThisEntityAI.GetType() + ": config parameter 'cordLength' is less than 0! Cord length should not be negative!";
252 DPrint(error_message_cord);
253 }
254
255 if (GetSocketsCount() > 0)
256 {
257 m_DeviceByPlugSelection = new map<string,EntityAI>;
258 // Prepare the m_DeviceByPlugSelection
259 string cfg_animation_sources = "cfgVehicles " + m_ThisEntityAI.GetType() + " " + "AnimationSources ";
260 int animation_sources_count = g_Game.ConfigGetChildrenCount(cfg_animation_sources);
261
262 for (int i_selection = 0; i_selection < animation_sources_count; i_selection++)
263 {
264 // TO DO: This could be optimized so not all selections on item are considered as plug/socket selections.
265 string selection;
266 g_Game.ConfigGetChildName(cfg_animation_sources, i_selection, selection);
267 m_DeviceByPlugSelection.Set(selection, NULL);
268 }
269 }
270
271
272
273 // Prepare sockets
275 {
277 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!";
278 DPrint(error_message_sockets);
279 }
280
281 m_Sockets[MAX_SOCKETS_COUNT]; // Handles selections for plugs in the sockets. Feel free to change the limit if needed.
282
283 g_Game.ConfigGetText(cfg_energy_manager + "cordTextureFile", m_CordTextureFile);
284
285 if ( switch_on )
286 {
287 SwitchOn();
288 }
289
290 for ( int i = 0; i <= GetSocketsCount(); ++i )
291 {
292 m_ThisEntityAI.HideSelection ( SOCKET_ + i.ToString() + _PLUGGED );
293 }
294
295 // Show/hide inventory sockets
297 if ( GetSocketsCount() > 0 && IsPlugCompatible(PLUG_COMMON_APPLIANCE) && m_ThisEntityAI.GetType() != "MetalWire" ) // metal wire filter is hopefully temporal.
298 {
300 }
301
303
304 m_ThisEntityAI.HideSelection( SEL_CORD_PLUGGED );
305
306
307 #ifdef DIAG_DEVELOPER
308 g_Game.m_EnergyManagerArray.Insert( this );
309 #endif
310 }
const int PLUG_COMMON_APPLIANCE
DayZGame g_Game
Определения DayZGame.c:4074
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:371
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
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:727
void OnEnergyAdded()
Energy manager: Called when energy was added on this device.
Определения ComponentEnergyManager.c:1511
const float DEFAULT_UPDATE_INTERVAL
Определения ComponentEnergyManager.c:20
ref array< EntityAI > m_PluggedDevices
Определения ComponentEnergyManager.c:70
const int MAX_SOCKETS_COUNT
Определения ComponentEnergyManager.c:73
float m_ReduceMaxEnergyByDamageCoef
Определения ComponentEnergyManager.c:52
ref TIntArray m_CompatiblePlugTypes
Определения ComponentEnergyManager.c:68
EntityAI m_Sockets[MAX_SOCKETS_COUNT]
Определения ComponentEnergyManager.c:74
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:972
string m_CordTextureFile
Определения ComponentEnergyManager.c:59
int GetSocketsCount()
Energy manager: Returns the count of power sockets (whenever used or not)
Определения ComponentEnergyManager.c:1134
bool HasEnoughStoredEnergy()
Energy manager: Returns true if this device has enough of stored energy for its own use.
Определения ComponentEnergyManager.c:931
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:733
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_WetnessExposure, MAX_SOCKETS_COUNT, OnEnergyAdded(), PLUG_COMMON_APPLIANCE, SEL_CORD_PLUGGED, SetUpdateInterval(), SOCKET_ и SwitchOn().