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

◆ Event_OnAwake()

override void ComponentEnergyManager::Event_OnAwake ( )
inlineprotected

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

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 = GetGame().ConfigGetFloat(cfg_energy_manager + "energyUsagePerSecond");
182 bool switch_on = GetGame().ConfigGetFloat(cfg_energy_manager + "switchOnAtSpawn");
183 m_AutoSwitchOff = GetGame().ConfigGetFloat(cfg_energy_manager + "autoSwitchOff");
184 m_HasElectricityIcon = GetGame().ConfigGetFloat(cfg_energy_manager + "hasIcon");
185 m_AutoSwitchOffWhenInCargo = GetGame().ConfigGetFloat(cfg_energy_manager + "autoSwitchOffWhenInCargo");
186
187 m_EnergyAtSpawn = GetGame().ConfigGetFloat(cfg_energy_manager + "energyAtSpawn");
189 m_EnergyStorageMax = GetGame().ConfigGetFloat(cfg_energy_manager + "energyStorageMax");
190 m_ReduceMaxEnergyByDamageCoef = GetGame().ConfigGetFloat(cfg_energy_manager + "reduceMaxEnergyByDamageCoef");
191 m_SocketsCount = GetGame().ConfigGetFloat(cfg_energy_manager + "powerSocketsCount");
192
193 m_IsPassiveDevice = GetGame().ConfigGetFloat(cfg_energy_manager + "isPassiveDevice");
194 m_CordLength = GetGame().ConfigGetFloat(cfg_energy_manager + "cordLength");
195 m_PlugType = GetGame().ConfigGetFloat(cfg_energy_manager + "plugType");
196
197 m_AttachmentActionType = GetGame().ConfigGetFloat(cfg_energy_manager + "attachmentAction");
198 m_WetnessExposure = GetGame().ConfigGetFloat(cfg_energy_manager + "wetnessExposure");
199
200 float update_interval = GetGame().ConfigGetFloat(cfg_energy_manager + "updateInterval");
201
202 m_ConvertEnergyToQuantity = GetGame().ConfigGetFloat(cfg_energy_manager + "convertEnergyToQuantity");
203
204
205 // Check if energy->quantity converion is configured properly
206 float cfg_max_quantity = GetGame().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 {
220
221 m_UpdateQuantityTimer.Run( 0.3 , this, "OnEnergyAdded", NULL, false);
222 }
223 }
224
225 // Set update interval
226 if ( update_interval <= 0 )
227 update_interval = DEFAULT_UPDATE_INTERVAL;
228
229 SetUpdateInterval( update_interval );
230
231 // If energyAtSpawn is present, then use its value for energyStorageMax if that cfg param is not present (for convenience's sake)
232 string cfg_check_energy_limit = cfg_energy_manager + "energyStorageMax";
233
234 if ( !GetGame().ConfigIsExisting (cfg_check_energy_limit) && m_Energy > 0 )
235 {
237 }
238
239 // Fill m_CompatiblePlugTypes
240 string cfg_check_plug_types = cfg_energy_manager + "compatiblePlugTypes";
241
242 if ( GetGame().ConfigIsExisting (cfg_check_plug_types) )
243 {
245 GetGame().ConfigGetIntArray(cfg_check_plug_types, m_CompatiblePlugTypes);
246 }
247
248 if (GetSocketsCount() > 0)
249 m_PluggedDevices = new array<EntityAI>;
250
251 if ( m_CordLength < 0 )
252 {
253 m_CordLength = 0;
254 string error_message_cord = "Warning! " + m_ThisEntityAI.GetType() + ": config parameter 'cordLength' is less than 0! Cord length should not be negative!";
255 DPrint(error_message_cord);
256 }
257
258 if (GetSocketsCount() > 0)
259 {
261 // Prepare the m_DeviceByPlugSelection
262 string cfg_animation_sources = "cfgVehicles " + m_ThisEntityAI.GetType() + " " + "AnimationSources ";
263 int animation_sources_count = GetGame().ConfigGetChildrenCount(cfg_animation_sources);
264
265 for (int i_selection = 0; i_selection < animation_sources_count; i_selection++)
266 {
267 // TO DO: This could be optimized so not all selections on item are considered as plug/socket selections.
268 string selection;
269 GetGame().ConfigGetChildName(cfg_animation_sources, i_selection, selection);
270 m_DeviceByPlugSelection.Set(selection, NULL);
271 }
272 }
273
274
275
276 // Prepare sockets
278 {
280 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!";
281 DPrint(error_message_sockets);
282 }
283
284 m_Sockets[MAX_SOCKETS_COUNT]; // Handles selections for plugs in the sockets. Feel free to change the limit if needed.
285
286 GetGame().ConfigGetText(cfg_energy_manager + "cordTextureFile", m_CordTextureFile);
287
288 if ( switch_on )
289 {
290 SwitchOn();
291 }
292
293 for ( int i = 0; i <= GetSocketsCount(); ++i )
294 {
295 m_ThisEntityAI.HideSelection ( SOCKET_ + i.ToString() + _PLUGGED );
296 }
297
298 // Show/hide inventory sockets
300 if ( GetSocketsCount() > 0 && IsPlugCompatible(PLUG_COMMON_APPLIANCE) && m_ThisEntityAI.GetType() != "MetalWire" ) // metal wire filter is hopefully temporal.
301 {
303 }
304
306
307 m_ThisEntityAI.HideSelection( SEL_CORD_PLUGGED );
308
309
310 #ifdef DIAG_DEVELOPER
311 GetGame().m_EnergyManagerArray.Insert( this );
312 #endif
313 }
const int PLUG_COMMON_APPLIANCE
Определения _constants.c:25
map
Определения ControlsXboxNew.c:4
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native float ConfigGetFloat(string path)
Get float value from config on path.
proto native void ConfigGetIntArray(string path, out TIntArray values)
Get array of integers from config on path.
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
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:375
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:723
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:947
string m_CordTextureFile
Определения ComponentEnergyManager.c:59
int GetSocketsCount()
Energy manager: Returns the count of power sockets (whenever used or not)
Определения ComponentEnergyManager.c:1102
bool HasEnoughStoredEnergy()
Energy manager: Returns true if this device has enough of stored energy for its own use.
Определения ComponentEnergyManager.c:906
proto native CGame GetGame()
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:687
const int CALL_CATEGORY_SYSTEM
Определения tools.c:8

Перекрестные ссылки _PLUGGED, CALL_CATEGORY_SYSTEM, CGame::ConfigGetChildName(), CGame::ConfigGetChildrenCount(), CGame::ConfigGetFloat(), CGame::ConfigGetIntArray(), CGame::ConfigGetText(), DEFAULT_UPDATE_INTERVAL, DPrint(), Error(), GetGame(), 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().