actiontakematerialtohandsswitch.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //!DEPRECATED
  2. class ActionTakeMaterialToHandsSwitch: ActionSingleUseBase
  3. {
  4. void ActionTakeMaterialToHandsSwitch()
  5. {
  6. m_Text = "#switch_to_next_material";
  7. }
  8. override void CreateConditionComponents()
  9. {
  10. m_ConditionItem = new CCINotPresent;
  11. m_ConditionTarget = new CCTNonRuined( UAMaxDistances.BASEBUILDING );
  12. }
  13. override bool IsInstant()
  14. {
  15. return true;
  16. }
  17. override bool RemoveForceTargetAfterUse()
  18. {
  19. return false;
  20. }
  21. override bool UseAcknowledgment()
  22. {
  23. return true;
  24. }
  25. override typename GetInputType()
  26. {
  27. return InteractActionInput;
  28. }
  29. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  30. {
  31. EntityAI target_entity = EntityAI.Cast( target.GetObject() );
  32. if ( target_entity && target_entity.CanUseConstruction() )
  33. {
  34. BaseBuildingBase base_building = BaseBuildingBase.Cast( target_entity );
  35. if(!base_building.IsPlayerInside(player,""))
  36. return false;
  37. ConstructionActionData construction_action_data = player.GetConstructionActionData();
  38. string main_part_name = target_entity.GetActionComponentName( target.GetComponentIndex() );
  39. construction_action_data.RefreshAttachmentsToDetach( target_entity, main_part_name );
  40. if ( construction_action_data.GetAttachmentsToDetachCount() > 1 )
  41. {
  42. return true;
  43. }
  44. }
  45. return false;
  46. }
  47. override void Start( ActionData action_data )
  48. {
  49. super.Start( action_data );
  50. //set next index
  51. ConstructionActionData construction_action_data = action_data.m_Player.GetConstructionActionData();
  52. construction_action_data.SetNextAttachmentIndex();
  53. }
  54. }