actionclosedoors.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. class ActionCloseDoors: ActionInteractBase
  2. {
  3. ref NoiseParams m_NoisePar;
  4. void ActionCloseDoors()
  5. {
  6. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENDOORFW;
  7. m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
  8. m_Text = "#close";
  9. }
  10. override void CreateConditionComponents()
  11. {
  12. m_ConditionItem = new CCINone();
  13. m_ConditionTarget = new CCTCursor();
  14. }
  15. override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
  16. {
  17. if (!target)
  18. return false;
  19. if (!IsBuilding(target))
  20. return false;
  21. Building building;
  22. if (Class.CastTo(building, target.GetObject()))
  23. {
  24. int doorIndex = building.GetDoorIndex(target.GetComponentIndex());
  25. if (doorIndex != -1)
  26. {
  27. if (!IsInReach(player, target, UAMaxDistances.DEFAULT))
  28. return false;
  29. return building.CanDoorBeClosed(doorIndex);
  30. }
  31. }
  32. return false;
  33. }
  34. override void OnStartServer(ActionData action_data)
  35. {
  36. super.OnStartServer(action_data);
  37. Building building;
  38. if (Class.CastTo(building, action_data.m_Target.GetObject()))
  39. {
  40. int doorIndex = building.GetDoorIndex(action_data.m_Target.GetComponentIndex());
  41. if (doorIndex != -1)
  42. {
  43. if (building.CanDoorBeClosed(doorIndex))
  44. {
  45. building.CloseDoor(doorIndex);
  46. }
  47. }
  48. }
  49. }
  50. override void OnEndServer(ActionData action_data)
  51. {
  52. super.OnEndServer(action_data);
  53. m_NoisePar = new NoiseParams();
  54. m_NoisePar.LoadFromPath("CfgVehicles SurvivorBase NoiseActionDefault");
  55. NoiseSystem noise = GetGame().GetNoiseSystem();
  56. if (noise)
  57. {
  58. if (action_data.m_Player)
  59. noise.AddNoisePos(action_data.m_Player, action_data.m_Target.GetObject().GetPosition(), m_NoisePar, NoiseAIEvaluate.GetNoiseReduction(GetGame().GetWeather()));
  60. }
  61. }
  62. override bool IsLockTargetOnUse()
  63. {
  64. return false;
  65. }
  66. }