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

◆ UpdateBattery()

void Car::UpdateBattery ( ItemBase battery)
inlineprotected

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

2443 {
2444 if (!battery)
2445 {
2446 m_BatteryTimer = 0;
2447 return;
2448 }
2449
2450 // unlikely
2451 if (m_BatteryTimer < 0)
2452 {
2453 m_BatteryTimer = 0;
2454 }
2455
2456 bool engineOn = EngineIsOn();
2457 bool lightsOn = LightIsOn();
2458
2459 if (engineOn)
2460 {
2461 // alternator
2462 battery.GetCompEM().ConsumeEnergy(GetBatteryRechargeRate() * m_BatteryTimer);
2463 }
2464 else if (!engineOn && lightsOn)
2465 {
2466 battery.GetCompEM().ConsumeEnergy(GetBatteryRuntimeConsumption() * m_BatteryTimer);
2467 }
2468
2469 if (lightsOn && battery.GetCompEM().GetEnergy() <= 0)
2470 {
2471 // lights currently don't automatically turn back on if the headlight was last turned on, so we just keep them on if the engine is on
2472 if (!engineOn)
2473 {
2474 LightOff();
2475 }
2476 }
2477
2478 m_BatteryTimer = 0;
2479 }
proto native bool EngineIsOn()
Returns true when engine is running, false otherwise.
float GetBatteryRechargeRate()
Определения CarScript.c:2432
float GetBatteryRuntimeConsumption()
Определения CarScript.c:2427
float m_BatteryTimer
Определения CarScript.c:133

Перекрестные ссылки EngineIsOn(), GetBatteryRechargeRate(), GetBatteryRuntimeConsumption() и m_BatteryTimer.

Используется в EEItemDetached(), OnEngineStart(), OnEngineStop() и OnUpdate().