actionunlockdoors.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 = ActionUnlockDoorsCB;
  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( !IsBuilding(target) ) return false;
  27. if( !IsInReach(player, target, UAMaxDistances.DEFAULT) ) return false;
  28. Building building;
  29. ToolBase tool;
  30. if (Class.CastTo(building, target.GetObject())&& Class.CastTo(tool, item))
  31. {
  32. int doorIndex = building.GetDoorIndex(target.GetComponentIndex());
  33. if (doorIndex != -1 && tool.GetKeyCompatibilityType() & building.GetLockCompatibilityType(doorIndex))
  34. return building.IsDoorLocked(doorIndex);
  35. }
  36. return false;
  37. }
  38. protected void UnlockDoor(ActionTarget target)
  39. {
  40. Building building;
  41. if ( Class.CastTo(building, target.GetObject()) )
  42. {
  43. int doorIndex = building.GetDoorIndex(target.GetComponentIndex());
  44. if ( doorIndex != -1 )
  45. {
  46. building.UnlockDoor(doorIndex);
  47. }
  48. }
  49. }
  50. override void OnFinishProgressServer( ActionData action_data )
  51. {
  52. UnlockDoor(action_data.m_Target);
  53. //Damage the Lockpick
  54. MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, APPLIED_DMG);
  55. }
  56. override bool IsLockTargetOnUse()
  57. {
  58. return false;
  59. }
  60. };