actionbreaklongwoodenstick.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. class ActionBreakLongWoodenStickCB : ActionContinuousBaseCB
  2. {
  3. private const float TIME_TO_BREAK_STICKS = 5.0;
  4. override void CreateActionComponent()
  5. {
  6. //float adjusted_time = m_ActionData.m_Player.GetSoftSkillsManager().AdjustCraftingTime(TIME_TO_BREAK_STICKS,UASoftSkillsWeight.ROUGH_HIGH);
  7. m_ActionData.m_ActionComponent = new CAContinuousTime(TIME_TO_BREAK_STICKS);
  8. }
  9. };
  10. class ActionBreakLongWoodenStick: ActionContinuousBase
  11. {
  12. void ActionBreakLongWoodenStick()
  13. {
  14. m_CallbackClass = ActionBreakLongWoodenStickCB;
  15. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_CRAFTING;
  16. m_FullBody = true;
  17. m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
  18. m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_HIGH;
  19. m_Text = "#STR_split0";
  20. }
  21. override void CreateConditionComponents()
  22. {
  23. m_ConditionItem = new CCINonRuined;
  24. m_ConditionTarget = new CCTNone;
  25. }
  26. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  27. {
  28. if (item.IsEmpty() && (!item.GetCompEM() || !item.GetCompEM().IsWorking()))
  29. {
  30. return true;
  31. }
  32. else
  33. {
  34. return false;
  35. }
  36. }
  37. override bool HasTarget()
  38. {
  39. return false;
  40. }
  41. override void OnFinishProgressServer( ActionData action_data )
  42. {
  43. ItemBase startingItem = action_data.m_MainItem;
  44. BreakLongWoodenStick lambda = new BreakLongWoodenStick(action_data.m_MainItem, "WoodenStick", action_data.m_Player, 3);
  45. action_data.m_Player.ServerReplaceItemInHandsWithNew(lambda);
  46. if (LongWoodenStick.Cast(startingItem) == null) // case if it is a broom
  47. {
  48. EntityAI longStick = action_data.m_Player.SpawnEntityOnGroundPos("LongWoodenStick", action_data.m_Player.GetPosition());
  49. ItemBase item_result;
  50. Class.CastTo(item_result, longStick);
  51. MiscGameplayFunctions.TransferItemProperties(action_data.m_MainItem, item_result);
  52. }
  53. }
  54. };
  55. class BreakLongWoodenStick : ReplaceItemWithNewLambdaBase
  56. {
  57. int m_ItemCount;
  58. void BreakLongWoodenStick(EntityAI old_item, string new_item_type, PlayerBase player, int count)
  59. {
  60. m_ItemCount = count;
  61. }
  62. override void CopyOldPropertiesToNew(notnull EntityAI old_item, EntityAI new_item)
  63. {
  64. super.CopyOldPropertiesToNew(old_item, new_item);
  65. ItemBase sticks;
  66. Class.CastTo(sticks, new_item);
  67. ItemBase ingredient;
  68. Class.CastTo(ingredient, old_item);
  69. MiscGameplayFunctions.TransferItemProperties(ingredient, sticks);
  70. sticks.SetQuantity(m_ItemCount);
  71. }
  72. };