actionunlockdoors.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. class ActionUnlockDoorsCB : ActionContinuousBaseCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.UNLOCK);
  6. }
  7. };
  8. class ActionUnlockDoors: ActionContinuousBase
  9. {
  10. protected const float APPLIED_DMG = 6;
  11. void ActionUnlockDoors()
  12. {
  13. m_CallbackClass = ActionLockDoorsCB;
  14. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_INTERACT;
  15. m_FullBody = true;
  16. m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
  17. m_Text = "#unlock";
  18. }
  19. override void CreateConditionComponents()
  20. {
  21. m_ConditionItem = new CCINonRuined;
  22. m_ConditionTarget = new CCTCursor;
  23. }
  24. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  25. {
  26. if( !target ) return false;
  27. //if( IsDamageDestroyed(action_data.m_Target) ) return false;
  28. if( !IsBuilding(target) ) return false;
  29. if( !IsInReach(player, target, UAMaxDistances.DEFAULT) ) return false;
  30. Building building;
  31. if( Class.CastTo(building, target.GetObject()) )
  32. {
  33. int doorIndex = building.GetDoorIndex(target.GetComponentIndex());
  34. if ( doorIndex != -1 )
  35. return building.IsDoorLocked(doorIndex);
  36. }
  37. return false;
  38. }
  39. protected void UnlockDoor(ActionTarget target)
  40. {
  41. Building building;
  42. if ( Class.CastTo(building, target.GetObject()) )
  43. {
  44. int doorIndex = building.GetDoorIndex(target.GetComponentIndex());
  45. if ( doorIndex != -1 )
  46. {
  47. building.UnlockDoor(doorIndex);
  48. }
  49. }
  50. }
  51. override void OnFinishProgressServer( ActionData action_data )
  52. {
  53. UnlockDoor(action_data.m_Target);
  54. //Damage the Lockpick
  55. MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, APPLIED_DMG);
  56. }
  57. override bool IsLockTargetOnUse()
  58. {
  59. return false;
  60. }
  61. };