actionworldliquidactionswitch.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //can be eventually extended to allow switching for multiple action types?
  2. //!DEPRECATED
  3. class ActionWorldLiquidActionSwitch: ActionSingleUseBase
  4. {
  5. bool m_switch_to;
  6. void ActionWorldLiquidActionSwitch()
  7. {
  8. m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_PRONE;
  9. }
  10. override void CreateConditionComponents()
  11. {
  12. m_ConditionItem = new CCINonRuined;
  13. m_ConditionTarget = new CCTNonRuined(UAMaxDistances.DEFAULT);
  14. }
  15. /*override string GetText()
  16. {
  17. //return "#switch_to" + " " + m_switch_to;
  18. if (!m_switch_to)
  19. return "#switch_to_liquid_drain";
  20. return "#switch_to_liquid_pour";
  21. }*/
  22. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  23. {
  24. ItemBase target_item = ItemBase.Cast(target.GetObject());
  25. if (Barrel_ColorBase.Cast(target_item) && !target_item.IsOpen())
  26. return false;
  27. if ( target_item && item && Liquid.CanFillContainer( item, target_item.GetLiquidType(),true ) && Liquid.CanFillContainer( target_item, item.GetLiquidType(), true ) && !GetGame().IsInventoryOpen() ) //TODO find better condition than IsKindOf
  28. {
  29. if ( target_item.GetQuantity() > target_item.GetQuantityMin() && item.GetQuantity() < item.GetQuantityMax() && !player.GetLiquidTendencyDrain() && Liquid.CanFillContainer( item, target_item.GetLiquidType() ) )
  30. {
  31. if ( Liquid.CanFillContainer( target_item, item.GetLiquidType() ) )
  32. {
  33. m_switch_to = 0;//"#liquid_drain";
  34. return true;
  35. }
  36. else
  37. {
  38. player.SetLiquidTendencyDrain(true);
  39. return false;
  40. }
  41. }
  42. if ( item.GetQuantity() > item.GetQuantityMin() && target_item.GetQuantity() < target_item.GetQuantityMax() && player.GetLiquidTendencyDrain() && Liquid.CanFillContainer( target_item, item.GetLiquidType() ) )
  43. {
  44. if ( Liquid.CanFillContainer( item, target_item.GetLiquidType() ) )
  45. {
  46. m_switch_to = 1;//"#liquid_pour";
  47. return true;
  48. }
  49. else
  50. {
  51. player.SetLiquidTendencyDrain(false);
  52. return false;
  53. }
  54. }
  55. }
  56. return false;
  57. }
  58. override void Start( ActionData action_data ) //Setup on start of action
  59. {
  60. super.Start( action_data );
  61. bool state;
  62. state = action_data.m_Player.GetLiquidTendencyDrain();
  63. action_data.m_Player.SetLiquidTendencyDrain(!state);
  64. //Print(action_data.m_Player.GetLiquidTendencyDrain());
  65. }
  66. override bool IsLocal()
  67. {
  68. return true;
  69. }
  70. override bool IsInstant()
  71. {
  72. return true;
  73. }
  74. override bool RemoveForceTargetAfterUse()
  75. {
  76. return false;
  77. }
  78. };