actionturnonheadtorch.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. class ActionTurnOnHeadtorch: ActionBase
  2. {
  3. void ActionTurnOnHeadtorch()
  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. Headtorch_ColorBase headtorch;
  30. headtorch = Headtorch_ColorBase.Cast(target.GetObject());
  31. if ( !headtorch )
  32. return false;
  33. if ( headtorch.HasEnergyManager() && headtorch.GetCompEM().CanSwitchOn() && headtorch.GetCompEM().CanWork() ) //TODO review conditions for turning off
  34. {
  35. return true;
  36. }
  37. return false;
  38. }
  39. override void Start( ActionData action_data )
  40. {
  41. super.Start( action_data );
  42. Headtorch_ColorBase headtorch;
  43. headtorch = Headtorch_ColorBase.Cast(action_data.m_Target.GetObject());
  44. if ( headtorch.HasEnergyManager() )
  45. {
  46. if ( headtorch.GetCompEM().CanWork() )
  47. {
  48. headtorch.GetCompEM().SwitchOn();
  49. }
  50. }
  51. }
  52. };