Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
battery9v.c
Go to the documentation of this file.
2 {
3  private int m_Efficiency0To10; // Synchronized variable
4  static private float m_EfficiencyDecayStart = 0.1; // At this % of maximum energy the output of the battery starts to weaken.
5 
6  void Battery9V()
7  {
8  m_Efficiency0To10 = 10;
9  RegisterNetSyncVariableInt("m_Efficiency0To10");
10  }
11 
13  float GetEfficiency0To1()
14  {
15  return m_Efficiency0To10 / 10;
16  }
17 
19  float GetEfficiencyDecayStart()
20  {
21  return m_EfficiencyDecayStart;
22  }
23 
24 
25  override void OnEnergyConsumed()
26  {
27  super.OnEnergyConsumed();
28 
29  if (GetGame().IsServer())
30  {
31  float energyCoef = GetCompEM().GetEnergy0To1();
32 
33  if (energyCoef < m_EfficiencyDecayStart && m_EfficiencyDecayStart > 0)
34  {
35  m_Efficiency0To10 = Math.Round((energyCoef / m_EfficiencyDecayStart) * 10);
36  SetSynchDirty();
37  }
38  }
39  }
40 
41  // Not needed right now, but it will be useful if we add rechargable batteries.
42  override void OnEnergyAdded()
43  {
44  super.OnEnergyAdded();
45 
46  if (GetGame().IsServer())
47  {
48  float energyCoef = GetCompEM().GetEnergy0To1();
49  if (energyCoef < m_EfficiencyDecayStart && m_EfficiencyDecayStart > 0)
50  {
51  m_Efficiency0To10 = Math.Round((energyCoef / m_EfficiencyDecayStart) * 10);
52  SetSynchDirty();
53  }
54  else
55  {
56  m_Efficiency0To10 = 10;
57  SetSynchDirty();
58  }
59  }
60  }
61 
62  override void SetActions()
63  {
64  super.SetActions();
65 
67  }
68 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
Battery9V
Definition: battery9v.c:1
ActionMeasureBattery
Definition: actionmeasurebattery.c:1
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
Math
Definition: enmath.c:6