179 {
181 return;
182
184 string cfg_energy_manager = cfg_item + " EnergyManager ";
185
186
188 bool switch_on =
g_Game.ConfigGetFloat(cfg_energy_manager +
"switchOnAtSpawn");
192
198
202
205
206 float update_interval =
g_Game.ConfigGetFloat(cfg_energy_manager +
"updateInterval");
207
209
210
211
212 float cfg_max_quantity =
g_Game.ConfigGetFloat (cfg_item +
" varQuantityMax");
213
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!";
219 }
220 else
221 {
223 {
226
228 }
229 }
230
231
232 if ( update_interval <= 0 )
234
236
237
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
246 string cfg_check_plug_types = cfg_energy_manager + "compatiblePlugTypes";
247
248 if (
g_Game.ConfigIsExisting (cfg_check_plug_types) )
249 {
252 }
253
256
258 {
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
265 {
267
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
274 string selection;
275 g_Game.ConfigGetChildName(cfg_animation_sources, i_selection, selection);
277 }
278 }
279
280
281
282
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
291
293
294 if ( switch_on )
295 {
297 }
298
300 {
302 }
303
304
307 {
309 }
310
312
314
315
316 #ifdef DIAG_DEVELOPER
317 g_Game.m_EnergyManagerArray.Insert(
this );
318 #endif
319 }
void SwitchOn()
Energy manager: Switches ON the device so it starts doing its work if it has enough energy.
static const string SOCKET_
bool m_ConvertEnergyToQuantity
ref Timer m_UpdateQuantityTimer
bool m_HasElectricityIcon
static const string _PLUGGED
void SetUpdateInterval(float value)
Energy manager: Sets the interval of the OnWork(...) calls. Changing this value does not change the r...
const float DEFAULT_UPDATE_INTERVAL
ref array< EntityAI > m_PluggedDevices
const int MAX_SOCKETS_COUNT
float m_ReduceMaxEnergyByDamageCoef
ref TIntArray m_CompatiblePlugTypes
EntityAI m_Sockets[MAX_SOCKETS_COUNT]
ref map< string, EntityAI > m_DeviceByPlugSelection
int m_AttachmentActionType
bool m_ShowSocketsInInventory
static const string SEL_CORD_PLUGGED
bool m_AutoSwitchOffWhenInCargo
bool IsPlugCompatible(int plug_ID)
Energy manager: Checks if the given plug is compatible with this device's socket. Used by CanReceiveP...
int GetSocketsCount()
Energy manager: Returns the count of power sockets (whenever used or not)
bool HasEnoughStoredEnergy()
Energy manager: Returns true if this device has enough of stored energy for its own use.
void Error(string err)
Messagebox with error message.
proto void DPrint(string var)
Prints content of variable to console/log. Should be used for critical messages so it will appear in ...