actionplacefireplaceintobarrel.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. class ActionPlaceFireplaceIntoBarrel: ActionSingleUseBase
  2. {
  3. void ActionPlaceFireplaceIntoBarrel()
  4. {
  5. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENDOORFW;
  6. m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
  7. m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_LOW;
  8. m_Text = "#place_object";
  9. }
  10. override void CreateConditionComponents()
  11. {
  12. m_ConditionItem = new CCINonRuined;
  13. m_ConditionTarget = new CCTNonRuined( UAMaxDistances.DEFAULT );
  14. }
  15. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  16. {
  17. Object target_object = target.GetObject();
  18. if ( target_object && target_object.IsInherited( BarrelHoles_ColorBase ) )
  19. {
  20. BarrelHoles_ColorBase fireplace_barrel = BarrelHoles_ColorBase.Cast( target_object );
  21. if ( fireplace_barrel.IsOpen() && fireplace_barrel.GetInventory().AttachmentCount() == 0 && fireplace_barrel.IsCargoEmpty() )
  22. {
  23. return true;
  24. }
  25. }
  26. return false;
  27. }
  28. override void OnExecuteServer( ActionData action_data )
  29. {
  30. ClearInventoryReservationEx(action_data);
  31. FireplaceBase fireplace_in_hands = FireplaceBase.Cast( action_data.m_MainItem );
  32. BarrelHoles_ColorBase fireplace_barrel = BarrelHoles_ColorBase.Cast( action_data.m_Target.GetObject() );
  33. auto lambda = new MoveEquipToExistingItemAndDestroyOldRootLambda(fireplace_in_hands, "", action_data.m_Player, fireplace_barrel);
  34. action_data.m_Player.ServerReplaceItemInHandsWithNewElsewhere(lambda);
  35. }
  36. }