actionturnonwhileonground.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. class ActionTurnOnWhileOnGround: ActionInteractBase
  2. {
  3. void ActionTurnOnWhileOnGround()
  4. {
  5. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENDOORFW;
  6. m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
  7. m_Text = "#switch_on";
  8. }
  9. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  10. {
  11. EntityAI target_entity = EntityAI.Cast( target.GetObject() );
  12. InventoryLocation loc = new InventoryLocation;
  13. target_entity.GetInventory().GetCurrentInventoryLocation(loc);
  14. return ( player.IsAlive() && target_entity.HasEnergyManager() && target_entity.GetCompEM().CanSwitchOn() && target_entity.GetCompEM().CanWork() && loc.GetType() == InventoryLocationType.GROUND );
  15. }
  16. override void OnExecuteServer( ActionData action_data )
  17. {
  18. EntityAI target_entity = EntityAI.Cast( action_data.m_Target.GetObject() );
  19. if ( target_entity.GetCompEM().CanWork() )
  20. {
  21. target_entity.GetCompEM().SwitchOn();
  22. InformPlayers( action_data.m_Player, action_data.m_Target, UA_FINISHED ); //Success
  23. }
  24. else
  25. {
  26. InformPlayers( action_data.m_Player, action_data.m_Target, UA_FAILED ); //No power
  27. }
  28. }
  29. };