123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- class ActionOpenDoors: ActionInteractBase
- {
- ref NoiseParams m_NoisePar;
-
- void ActionOpenDoors()
- {
- m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENDOORFW;
- m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
- m_Text = "#open";
- }
- override void CreateConditionComponents()
- {
- m_ConditionItem = new CCINone();
- m_ConditionTarget = new CCTCursor();
- }
- protected bool CheckIfDoorIsLocked()
- {
- return true;
- }
-
- protected bool CreatesNoise()
- {
- return true;
- }
- override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
- {
- if (!target)
- return false;
- if (!IsBuilding(target))
- return false;
- Building building;
- if (Class.CastTo(building, target.GetObject()))
- {
- int doorIndex = building.GetDoorIndex(target.GetComponentIndex());
- if (doorIndex != -1)
- {
- if (!IsInReach(player, target, UAMaxDistances.DEFAULT))
- return false;
-
- return building.CanDoorBeOpened(doorIndex, CheckIfDoorIsLocked());
- }
- }
- return false;
- }
-
- override void OnStartServer(ActionData action_data)
- {
- super.OnStartServer(action_data);
-
- Building building;
- if (Class.CastTo(building, action_data.m_Target.GetObject()))
- {
- int doorIndex = building.GetDoorIndex(action_data.m_Target.GetComponentIndex());
- if (doorIndex != -1)
- {
- if (building.CanDoorBeOpened(doorIndex, CheckIfDoorIsLocked()))
- {
- building.OpenDoor(doorIndex);
- }
- }
- }
- }
-
- override void OnEndServer(ActionData action_data)
- {
- super.OnEndServer(action_data);
-
- m_NoisePar = new NoiseParams();
- m_NoisePar.LoadFromPath("CfgVehicles SurvivorBase NoiseActionDefault");
- NoiseSystem noise = GetGame().GetNoiseSystem();
- if (noise && CreatesNoise())
- {
- if (action_data.m_Player)
- noise.AddNoisePos(action_data.m_Player, action_data.m_Target.GetObject().GetPosition(), m_NoisePar, NoiseAIEvaluate.GetNoiseReduction(GetGame().GetWeather()));
- }
- }
-
- override bool IsLockTargetOnUse()
- {
- return false;
- }
- }
- class ActionLockedDoors : ActionOpenDoors
- {
- override bool CheckIfDoorIsLocked()
- {
- return false;
- }
-
- override protected bool CreatesNoise()
- {
- return false;
- }
- };
|