actionfillbottlebase.c 3.9 KB

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