actionturnoffweaponflashlight.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. class ActionTurnOffWeaponFlashlight: ActionSingleUseBase
  2. {
  3. ItemBase m_flashlight;
  4. void ActionTurnOffWeaponFlashlight()
  5. {
  6. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_ITEM_OFF;//CMD_ACTIONMOD_INTERACTONCE
  7. m_Text = "#switch_off";
  8. }
  9. override void CreateConditionComponents()
  10. {
  11. m_ConditionItem = new CCINonRuined;
  12. m_ConditionTarget = new CCTNone;
  13. }
  14. override bool HasTarget()
  15. {
  16. return false;
  17. }
  18. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  19. {
  20. if ( item.IsInherited(Rifle_Base) )
  21. {
  22. //m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_LIGHTFLARE;
  23. m_flashlight = ItemBase.Cast(item.FindAttachmentBySlotName("weaponFlashlight"));
  24. }
  25. else if (item.IsInherited(Pistol_Base))
  26. {
  27. //m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_LITCHEMLIGHT;
  28. m_flashlight = ItemBase.Cast(item.FindAttachmentBySlotName("pistolFlashlight"));
  29. }
  30. else //is not valid item
  31. return false;
  32. if ( m_flashlight && m_flashlight.HasEnergyManager() && m_flashlight.GetCompEM().CanSwitchOff() ) //TODO review conditions for turning off
  33. {
  34. return true;
  35. }
  36. return false;
  37. }
  38. override void OnExecuteServer( ActionData action_data )
  39. {
  40. if ( m_flashlight.HasEnergyManager() )
  41. {
  42. if ( m_flashlight.GetCompEM().IsSwitchedOn() )
  43. {
  44. m_flashlight.GetCompEM().SwitchOff();
  45. }
  46. Weapon_Base.Cast(action_data.m_MainItem).FlashlightOff(); //currently seems to be doing nothing
  47. }
  48. }
  49. };