rainprocurementmanager.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //!DEPRECATED, done through the RainProcurementHandler / component instead
  2. class RainProcurementManager
  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. void RainProcurementManager( ItemBase procuring_item )
  9. {
  10. m_ProcuringItem = procuring_item;
  11. }
  12. // ----------------------------------------------------------------------------------------
  13. void InitRainProcurement()
  14. {
  15. m_IsUnderRoof = MiscGameplayFunctions.IsUnderRoof(m_ProcuringItem);
  16. //m_ProcuringItem.SetQuantity(0); /*set to 0 for debug purposses*/
  17. if ( !m_IsUnderRoof )
  18. {
  19. m_UpdateTimer = new Timer();
  20. m_UpdateTimer.Run( 10, this, "RainProcurementCheck", NULL, true );
  21. }
  22. }
  23. // ----------------------------------------------------------------------------------------
  24. void RainProcurementCheck()
  25. {
  26. float rain_intensity = GetGame().GetWeather().GetRain().GetActual();
  27. float fill_per_update = RAIN_COEFFICIENT * rain_intensity;
  28. if ( rain_intensity > 0 )
  29. {
  30. if ( m_ProcuringItem.GetQuantity() < m_ProcuringItem.GetQuantityMax() )
  31. {
  32. Liquid.FillContainerEnviro( m_ProcuringItem, LIQUID_FRESHWATER, fill_per_update );
  33. //Print( "Quantity of " + m_ProcuringItem + " is: " + m_ProcuringItem.GetQuantity() );
  34. }
  35. else
  36. {
  37. //Print("vesel full");
  38. StopRainProcurement();
  39. }
  40. }
  41. }
  42. // ----------------------------------------------------------------------------------------
  43. /*bool IsUnderRoof()
  44. {
  45. vector minMax[2];
  46. m_ProcuringItem.GetCollisionBox(minMax);
  47. vector size = Vector(0,0,0);
  48. size[1] = minMax[1][1] - minMax[0][1];
  49. vector from = m_ProcuringItem.GetPosition() + size;
  50. vector ceiling = "0 20 0";
  51. vector to = from + ceiling;
  52. vector contact_pos;
  53. vector contact_dir;
  54. int contact_component;
  55. return DayZPhysics.RaycastRV( from, to, contact_pos, contact_dir, contact_component, NULL, NULL, m_ProcuringItem );
  56. }*/
  57. // ----------------------------------------------------------------------------------------
  58. bool IsRunning()
  59. {
  60. return m_UpdateTimer != null;
  61. }
  62. void StopRainProcurement()
  63. {
  64. if( !m_IsUnderRoof )
  65. {
  66. m_UpdateTimer.Stop();
  67. }
  68. }
  69. };