actionlockdoors.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. class ActionLockDoorsCB : ActionContinuousBaseCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.LOCK);
  6. }
  7. };
  8. class ActionLockDoors: ActionContinuousBase
  9. {
  10. protected const float APPLIED_DMG = 6;
  11. void ActionLockDoors()
  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_SpecialtyWeight = UASoftSkillsWeight.PRECISE_HIGH;
  18. m_Text = "#lock_door";
  19. }
  20. override void CreateConditionComponents()
  21. {
  22. m_ConditionItem = new CCINonRuined;
  23. m_ConditionTarget = new CCTCursor;
  24. }
  25. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  26. {
  27. if( !IsBuilding(target) ) return false;
  28. if( !IsInReach(player, target, UAMaxDistances.DEFAULT) ) return false;
  29. Building building;
  30. ToolBase tool;
  31. if (Class.CastTo(building, target.GetObject())&& Class.CastTo(tool, item))
  32. {
  33. int doorIndex = building.GetDoorIndex(target.GetComponentIndex());
  34. if (doorIndex != -1 && tool.GetKeyCompatibilityType() & building.GetLockCompatibilityType(doorIndex))
  35. return building.CanDoorBeLocked(doorIndex);
  36. }
  37. return false;
  38. }
  39. protected void LockDoor(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.LockDoor(doorIndex);
  48. }
  49. }
  50. }
  51. override void OnFinishProgressServer( ActionData action_data )
  52. {
  53. LockDoor(action_data.m_Target);
  54. MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, APPLIED_DMG);
  55. }
  56. override bool IsLockTargetOnUse()
  57. {
  58. return false;
  59. }
  60. };