Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
rainprocurementcomponent.c
Go to the documentation of this file.
2 {
3  protected ItemBase m_ProcuringItem;
4  protected RainProcurementHandler m_Handler;
5  protected bool m_IsUnderRoof;
6  protected bool m_IsActive;
7  protected int m_UpdateCounter;
8  protected const int UPDATE_ROOFCHECK_COUNT = 3; //do roofcheck every n updates
9 
10  void RainProcurementComponentBase(ItemBase procuringItem)
11  {
12  m_ProcuringItem = procuringItem;
13  Reset();
14  m_Handler = MissionBaseWorld.Cast(GetGame().GetMission()).GetRainProcurementHandler();
15  }
16 
18  void StartRainProcurement()
19  {
20  #ifdef SERVER
21  Reset();
22  SetActive(true);
23  m_Handler.QueueStart(this);
24  #endif
25  }
26 
28  void StopRainProcurement()
29  {
30  #ifdef SERVER
31  if (IsActive())
32  {
33  SetActive(false);
34  m_Handler.QueueStop(this);
35  }
36  #endif
37  }
38 
39  void OnUpdate(float deltaTime, float amount)
40  {
41  m_UpdateCounter++;
42  if (m_UpdateCounter == 0 || m_UpdateCounter == UPDATE_ROOFCHECK_COUNT)
43  {
44  m_UpdateCounter = 0;
45  UpdateIsUnderRoof();
46  }
47  ProcureLiquid(amount);
48  }
49 
50  protected void Reset()
51  {
52  m_UpdateCounter = -1;
53  }
54 
55  protected void ProcureLiquid(float amountBase, int liquidType = LIQUID_WATER)
56  {
57  if (!m_IsUnderRoof)
58  {
59  float actualAmount = amountBase * GetBaseLiquidAmount();
60  Liquid.FillContainerEnviro(m_ProcuringItem, liquidType, actualAmount);
61  }
62  }
63 
64  protected void UpdateIsUnderRoof()
65  {
66  m_IsUnderRoof = MiscGameplayFunctions.IsUnderRoof(m_ProcuringItem);
67  }
68 
70  float GetBaseLiquidAmount()
71  {
72  return GameConstants.LIQUID_RAIN_AMOUNT_COEF_BASE;
73  }
74 
75  bool IsActive()
76  {
77  return m_IsActive;
78  }
79 
80  void SetActive(bool run)
81  {
82  //resets times on start
83  if (run)
84  Reset();
85  m_IsActive = run;
86  }
87 };
88 
ItemBase
Definition: inventoryitem.c:730
RainProcurementComponentBarrel
Definition: rainprocurementcomponent.c:89
GetGame
proto native CGame GetGame()
Managed
TODO doc.
Definition: enscript.c:117
LIQUID_WATER
const int LIQUID_WATER
Definition: constants.c:505
m_IsActive
bool m_IsActive
Definition: modifierbase.c:20
MissionBaseWorld
Definition: missionbase.c:1
m_Handler
protected UIScriptedMenu m_Handler
Definition: errorproperties.c:42
RainProcurementComponentBase
Definition: rainprocurementcomponent.c:1
RainProcurementHandler
Definition: rainprocurementhandler.c:1
GameConstants
Definition: constants.c:612
Liquid
Definition: liquid.c:1