actiondisinfectplantbit.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // TO DO: Remove this script!
  2. class ActionDisinfectPlantBitCB : ActionSingleUseBaseCB
  3. {
  4. override void CreateActionComponent()
  5. {
  6. m_ActionData.m_ActionComponent = new CASingleUseQuantity(UAQuantityConsumed.GARDEN_DISINFECT_PLANT);
  7. }
  8. };
  9. class ActionDisinfectPlantBit: ActionSingleUseBase
  10. {
  11. void ActionDisinfectPlantBit()
  12. {
  13. m_CallbackClass = ActionDisinfectPlantBitCB;
  14. m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_LOW;
  15. m_Text = "#apply";
  16. }
  17. override void CreateConditionComponents()
  18. {
  19. m_ConditionItem = new CCINonRuined;
  20. m_ConditionTarget = new CCTNonRuined(UAMaxDistances.DEFAULT);
  21. }
  22. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  23. {
  24. Object targetObject = target.GetObject();
  25. if ( targetObject != NULL && targetObject.IsInherited(PlantBase) && !item.IsDamageDestroyed() )
  26. {
  27. PlantBase plant = PlantBase.Cast( targetObject );
  28. if (plant.IsSprayable())
  29. {
  30. if ( item.GetQuantity() > 0 )
  31. {
  32. return true;
  33. }
  34. }
  35. }
  36. return false;
  37. }
  38. override void OnExecuteServer( ActionData action_data )
  39. {
  40. Object targetObject = action_data.m_Target.GetObject();
  41. if ( targetObject != NULL && targetObject.IsInherited(PlantBase) )
  42. {
  43. PlantBase plant = PlantBase.Cast( targetObject );
  44. Param1<float> nacdata = Param1<float>.Cast( action_data.m_ActionComponent.GetACData() );
  45. SendMessageToClient(action_data.m_Player, plant.StopInfestation( nacdata.param1 ));
  46. }
  47. }
  48. };