actionturnoffhelmetflashlight.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. class ActionTurnOffHelmetFlashlight: ActionBase
  2. {
  3. void ActionTurnOffHelmetFlashlight()
  4. {
  5. }
  6. override bool IsInstant()
  7. {
  8. return true;
  9. }
  10. override bool HasTarget()
  11. {
  12. return true;
  13. }
  14. override bool UseMainItem()
  15. {
  16. return false;
  17. }
  18. override void CreateConditionComponents()
  19. {
  20. m_ConditionItem = new CCINone;
  21. m_ConditionTarget = new CCTNonRuined(UAMaxDistances.DEFAULT);
  22. }
  23. override typename GetInputType()
  24. {
  25. return ToggleLightsActionInput;
  26. }
  27. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  28. {
  29. Switchable_Base light;
  30. Mich2001Helmet helmet;
  31. helmet = Mich2001Helmet.Cast(target.GetObject());
  32. if ( !helmet )
  33. return false;
  34. light = Switchable_Base.Cast(helmet.FindAttachmentBySlotName("helmetFlashlight"));
  35. if ( !light )
  36. return false;
  37. if ( light.HasEnergyManager() && light.GetCompEM().CanSwitchOff() ) //TODO review conditions for turning off
  38. {
  39. return true;
  40. }
  41. return false;
  42. }
  43. override void Start( ActionData action_data )
  44. {
  45. super.Start( action_data );
  46. Switchable_Base light;// = Switchable_Base.Cast(action_data.m_MainItem.FindAttachmentBySlotName("helmetFlashlight"));
  47. Mich2001Helmet helmet;
  48. helmet = Mich2001Helmet.Cast(action_data.m_Target.GetObject());
  49. light = Switchable_Base.Cast(helmet.FindAttachmentBySlotName("helmetFlashlight"));
  50. if ( light.HasEnergyManager() )
  51. {
  52. if ( light.GetCompEM().IsSwitchedOn() )
  53. {
  54. light.GetCompEM().SwitchOff();
  55. }
  56. }
  57. }
  58. };