actionfillbottlebase.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. class ActionFillBottleBaseCB : ActionContinuousBaseCB
  2. {
  3. private int m_liquid_type;
  4. private float m_BaseFillQuantity;
  5. override void CreateActionComponent()
  6. {
  7. m_liquid_type = ActionFillBottleBase.Cast(m_ActionData.m_Action).GetLiquidType(m_ActionData.m_Player, m_ActionData.m_Target, m_ActionData.m_MainItem);
  8. if (m_liquid_type == LIQUID_GASOLINE)
  9. {
  10. m_BaseFillQuantity = UAQuantityConsumed.FUEL;
  11. }
  12. else if (m_liquid_type == LIQUID_SNOW)
  13. {
  14. m_BaseFillQuantity = UAQuantityConsumed.FILL_SNOW;
  15. }
  16. else
  17. {
  18. m_BaseFillQuantity = UAQuantityConsumed.FILL_LIQUID;
  19. }
  20. m_ActionData.m_ActionComponent = new CAContinuousFill(m_BaseFillQuantity, m_liquid_type);
  21. }
  22. };
  23. class ActionFillBottleBase: ActionContinuousBase
  24. {
  25. private const float WATER_DEPTH = 0.5;
  26. private const string ALLOWED_WATER_SURFACES = string.Format("%1|%2|%3", UAWaterType.FRESH, UAWaterType.STILL, UAWaterType.SNOW);
  27. protected int m_AllowedLiquidMask;
  28. void ActionFillBottleBase()
  29. {
  30. m_CallbackClass = ActionFillBottleBaseCB;
  31. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_FILLBOTTLEPOND;
  32. m_FullBody = true;
  33. m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
  34. m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_LOW;
  35. m_Text = "#fill";
  36. m_AllowedLiquidMask = LIQUID_GROUP_DRINKWATER | LIQUID_GASOLINE;
  37. m_AllowedLiquidMask &= ~LIQUID_SNOW;
  38. }
  39. override void CreateConditionComponents()
  40. {
  41. m_ConditionItem = new CCINonRuined();
  42. m_ConditionTarget = new CCTNone()
  43. }
  44. override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
  45. {
  46. Object targetObject = target.GetObject();
  47. if (targetObject)
  48. {
  49. if (vector.DistanceSq(player.GetPosition(), targetObject.GetPosition()) > UAMaxDistances.DEFAULT * UAMaxDistances.DEFAULT)
  50. return false;
  51. }
  52. else
  53. {
  54. CCTWaterSurfaceEx waterCheck = new CCTWaterSurfaceEx(UAMaxDistances.DEFAULT, m_AllowedLiquidMask);
  55. if (!waterCheck.Can(player, target))
  56. return false;
  57. }
  58. int liquidType = GetLiquidType(player, target, item);
  59. if (item.GetQuantity() > item.GetQuantityMin())
  60. liquidType = Liquid.TranslateLiquidType(liquidType);
  61. return liquidType != LIQUID_NONE && Liquid.CanFillContainer(item,liquidType);
  62. }
  63. override bool ActionConditionContinue(ActionData action_data)
  64. {
  65. return action_data.m_MainItem.GetQuantity() < action_data.m_MainItem.GetQuantityMax();
  66. }
  67. override protected int GetStanceMask(PlayerBase player)
  68. {
  69. vector water_info = HumanCommandSwim.WaterLevelCheck(player, player.GetPosition());
  70. if (water_info[1] > WATER_DEPTH)
  71. {
  72. return DayZPlayerConstants.STANCEMASK_ERECT;
  73. }
  74. else
  75. {
  76. return DayZPlayerConstants.STANCEMASK_CROUCH;
  77. }
  78. }
  79. override protected int GetActionCommandEx(ActionData actionData)
  80. {
  81. int commandUID = DayZPlayerConstants.CMD_ACTIONFB_FILLBOTTLEPOND;
  82. if (actionData.m_Target.GetObject())
  83. {
  84. commandUID = DayZPlayerConstants.CMD_ACTIONFB_FILLBOTTLEWELL;
  85. }
  86. return commandUID;
  87. }
  88. int GetLiquidType(PlayerBase player, ActionTarget target, ItemBase item)
  89. {
  90. int liquidType = LIQUID_NONE;
  91. if ( target.GetObject() )
  92. {
  93. liquidType = target.GetObject().GetLiquidSourceType();
  94. }
  95. else
  96. {
  97. string surfaceType;
  98. vector hit_pos = target.GetCursorHitPos();
  99. GetGame().SurfaceGetType3D(hit_pos[0], hit_pos[1], hit_pos[2], surfaceType);
  100. if (surfaceType == "")
  101. {
  102. if ( hit_pos[1] <= g_Game.SurfaceGetSeaLevel() + 0.001 )
  103. {
  104. liquidType = LIQUID_SALTWATER;
  105. }
  106. }
  107. else
  108. {
  109. liquidType = SurfaceInfo.GetByName(surfaceType).GetLiquidType();
  110. }
  111. }
  112. return liquidType & m_AllowedLiquidMask;
  113. }
  114. void SetupStance(PlayerBase player)
  115. {
  116. //returns in format (totalWaterDepth, characterDepht, 0)
  117. vector water_info = HumanCommandSwim.WaterLevelCheck(player, player.GetPosition());
  118. if (water_info[1] > WATER_DEPTH)
  119. {
  120. m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
  121. }
  122. else
  123. {
  124. m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
  125. }
  126. }
  127. override bool IsLockTargetOnUse()
  128. {
  129. return false;
  130. }
  131. // deprecated
  132. private const int ALLOWED_LIQUID;
  133. }