173 {
175 return;
176
178 string cfg_energy_manager = cfg_item + " EnergyManager ";
179
180
182 bool switch_on =
g_Game.ConfigGetFloat(cfg_energy_manager +
"switchOnAtSpawn");
186
192
196
199
200 float update_interval =
g_Game.ConfigGetFloat(cfg_energy_manager +
"updateInterval");
201
203
204
205
206 float cfg_max_quantity =
g_Game.ConfigGetFloat (cfg_item +
" varQuantityMax");
207
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!";
213 }
214 else
215 {
217 {
219 }
220 }
221
222
223 if ( update_interval <= 0 )
225
227
228
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
237 string cfg_check_plug_types = cfg_energy_manager + "compatiblePlugTypes";
238
239 if (
g_Game.ConfigIsExisting (cfg_check_plug_types) )
240 {
243 }
244
247
249 {
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
256 {
258
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
265 string selection;
266 g_Game.ConfigGetChildName(cfg_animation_sources, i_selection, selection);
268 }
269 }
270
271
272
273
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
282
284
285 if ( switch_on )
286 {
288 }
289
291 {
293 }
294
295
298 {
300 }
301
303
305
306
307 #ifdef DIAG_DEVELOPER
308 g_Game.m_EnergyManagerArray.Insert(
this );
309 #endif
310 }
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
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...
void OnEnergyAdded()
Energy manager: Called when energy was added on this device.
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 ...