actionturnoffspotlight.c 824 B

12345678910111213141516171819202122232425262728293031
  1. class ActionTurnOffSpotlight: ActionInteractBase
  2. {
  3. void ActionTurnOffSpotlight()
  4. {
  5. m_Text = "#switch_off";
  6. }
  7. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  8. {
  9. Object targetObject = target.GetObject();
  10. string selection = targetObject.GetActionComponentName(target.GetComponentIndex());
  11. ItemBase target_IB = ItemBase.Cast( target.GetObject() );
  12. if ( selection == Spotlight.SEL_REFLECTOR_COMP_U && target_IB.HasEnergyManager() && target_IB.GetCompEM().CanSwitchOff() )
  13. {
  14. return true;
  15. }
  16. return false;
  17. }
  18. override void OnExecuteServer( ActionData action_data )
  19. {
  20. Object targetObject = action_data.m_Target.GetObject();
  21. if ( targetObject )
  22. {
  23. EntityAI target_EAI = EntityAI.Cast( targetObject );
  24. target_EAI.GetCompEM().SwitchOff();
  25. }
  26. }
  27. };