actiondismantleoven.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. class ActionDismantleOvenCB : ActionContinuousBaseCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousTime( UATimeSpent.DEFAULT_DECONSTRUCT );
  6. }
  7. }
  8. class ActionDismantleOven: ActionContinuousBase
  9. {
  10. void ActionDismantleOven()
  11. {
  12. m_CallbackClass = ActionDismantleOvenCB;
  13. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_CRAFTING;
  14. m_FullBody = true;
  15. m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
  16. m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_HIGH;
  17. m_Text = "#dismantle_oven";
  18. }
  19. override void CreateConditionComponents()
  20. {
  21. m_ConditionTarget = new CCTNonRuined( UAMaxDistances.DEFAULT );
  22. m_ConditionItem = new CCINotPresent;
  23. }
  24. override typename GetInputType()
  25. {
  26. return ContinuousInteractActionInput;
  27. }
  28. /*override bool HasProgress()
  29. {
  30. return false;
  31. }*/
  32. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  33. {
  34. //Action not allowed if player has broken legs
  35. if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
  36. return false;
  37. Object target_object = target.GetObject();
  38. if ( target_object && target_object.IsFireplace() )
  39. {
  40. FireplaceBase fireplace_target = FireplaceBase.Cast( target_object );
  41. if ( fireplace_target.IsBaseFireplace() && fireplace_target.CanDismantleOven() )
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. override void OnFinishProgressServer( ActionData action_data )
  49. {
  50. Object target_object = action_data.m_Target.GetObject();
  51. FireplaceBase fireplace_target = FireplaceBase.Cast( target_object );
  52. if ( fireplace_target.CanDismantleOven() )
  53. {
  54. ItemBase attached_item = ItemBase.Cast( fireplace_target.GetAttachmentByType( fireplace_target.ATTACHMENT_STONES ) );
  55. // for backward compatibility - for the cases built before slot locking was commented out for the stone att slot
  56. InventoryLocation inventory_location = new InventoryLocation;
  57. attached_item.GetInventory().GetCurrentInventoryLocation( inventory_location );
  58. fireplace_target.GetInventory().SetSlotLock( inventory_location.GetSlot(), false );
  59. //set oven state
  60. fireplace_target.SetOvenState( false );
  61. // extend lifetime (either back to stone circle lifetime or standard fireplace one)
  62. if ( fireplace_target.HasStoneCircle() )
  63. {
  64. fireplace_target.SetLifetimeMax( FireplaceBase.LIFETIME_FIREPLACE_STONE_CIRCLE );
  65. }
  66. else
  67. {
  68. fireplace_target.SetLifetimeMax( 10800 );
  69. }
  70. }
  71. }
  72. }