Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
rainprocurementmanager.c
Go to the documentation of this file.
3 {
4  protected ItemBase m_ProcuringItem;
5  protected int m_IsUnderRoof;
6  protected ref Timer m_UpdateTimer;
7  protected const int RAIN_COEFFICIENT = 10;
8 
9  void RainProcurementManager( ItemBase procuring_item )
10  {
11  m_ProcuringItem = procuring_item;
12  }
13 
14  // ----------------------------------------------------------------------------------------
15  void InitRainProcurement()
16  {
17  m_IsUnderRoof = MiscGameplayFunctions.IsUnderRoof(m_ProcuringItem);
18 
19  //m_ProcuringItem.SetQuantity(0); /*set to 0 for debug purposses*/
20 
21  if ( !m_IsUnderRoof )
22  {
23  m_UpdateTimer = new Timer();
24  m_UpdateTimer.Run( 10, this, "RainProcurementCheck", NULL, true );
25  }
26  }
27 
28  // ----------------------------------------------------------------------------------------
29  void RainProcurementCheck()
30  {
31  float rain_intensity = GetGame().GetWeather().GetRain().GetActual();
32  float fill_per_update = RAIN_COEFFICIENT * rain_intensity;
33 
34  if ( rain_intensity > 0 )
35  {
36  if ( m_ProcuringItem.GetQuantity() < m_ProcuringItem.GetQuantityMax() )
37  {
38  Liquid.FillContainerEnviro( m_ProcuringItem, LIQUID_WATER, fill_per_update );
39 
40  //Print( "Quantity of " + m_ProcuringItem + " is: " + m_ProcuringItem.GetQuantity() );
41  }
42  else
43  {
44  //Print("vesel full");
45  StopRainProcurement();
46  }
47  }
48  }
49 
50  // ----------------------------------------------------------------------------------------
51  /*bool IsUnderRoof()
52  {
53  vector minMax[2];
54  m_ProcuringItem.GetCollisionBox(minMax);
55 
56  vector size = Vector(0,0,0);
57  size[1] = minMax[1][1] - minMax[0][1];
58 
59  vector from = m_ProcuringItem.GetPosition() + size;
60  vector ceiling = "0 20 0";
61  vector to = from + ceiling;
62  vector contact_pos;
63  vector contact_dir;
64 
65  int contact_component;
66 
67  return DayZPhysics.RaycastRV( from, to, contact_pos, contact_dir, contact_component, NULL, NULL, m_ProcuringItem );
68  }*/
69 
70  // ----------------------------------------------------------------------------------------
71  bool IsRunning()
72  {
73  return m_UpdateTimer != null;
74  }
75 
76  void StopRainProcurement()
77  {
78  if( !m_IsUnderRoof )
79  {
80  m_UpdateTimer.Stop();
81  }
82 
83  }
84 };
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
LIQUID_WATER
const int LIQUID_WATER
Definition: constants.c:505
RainProcurementManager
DEPRECATED, done through the RainProcurementHandler / component instead.
Definition: rainprocurementmanager.c:2
Liquid
Definition: liquid.c:1
Timer
Definition: dayzplayerimplement.c:62
m_UpdateTimer
protected ref Timer m_UpdateTimer
Definition: radialmenu.c:20