actioninstallsparkplug.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. This is a generic user action for attaching sparkplug on any EntityAI object. The receiver must have a "sparkplug" selection in its View Geometry that the action_data.m_Player can look at.
  3. */
  4. //!DEPRECATED
  5. class ActionInsertSparkplug: ActionSingleUseBase
  6. {
  7. void ActionInsertSparkplug()
  8. {
  9. }
  10. override void CreateConditionComponents()
  11. {
  12. m_ConditionItem = new CCINonRuined;
  13. m_ConditionTarget = new CCTNonRuined(UAMaxDistances.DEFAULT);
  14. m_Text = "#attach";
  15. }
  16. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  17. {
  18. EntityAI target_EAI = EntityAI.Cast( target.GetObject() );
  19. string selection = target_EAI.GetActionComponentName(target.GetComponentIndex());
  20. if ( selection == "sparkplug" && target_EAI.GetInventory().CanAddAttachment(item) )
  21. {
  22. return true;
  23. }
  24. return false;
  25. }
  26. override void OnExecuteServer( ActionData action_data )
  27. {
  28. EntityAI target_EAI = EntityAI.Cast( action_data.m_Target.GetObject() ); // cast to ItemBase
  29. target_EAI.LocalTakeEntityAsAttachment (action_data.m_MainItem);
  30. }
  31. override void OnExecuteClient( ActionData action_data )
  32. {
  33. EntityAI target_EAI = EntityAI.Cast( action_data.m_Target.GetObject() ); // cast to ItemBase
  34. target_EAI.LocalTakeEntityAsAttachment (action_data.m_MainItem);
  35. }
  36. };