Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
building.c
Go to the documentation of this file.
1 typedef Param1<int> DoorStartParams;
3 typedef Param1<int> DoorLockParams;
4 
5 class Building extends EntityAI
6 {
7  proto native int GetLaddersCount();
8  proto native vector GetLadderPosTop(int ladderIndex);
9  proto native vector GetLadderPosBottom(int ladderIndex);
10 
12  proto native int GetDoorIndex(int componentIndex);
13 
15  proto native int GetDoorCount();
16 
18  proto native bool IsDoorOpen(int index);
19 
21  proto native bool IsDoorOpening(int index);
22 
24  proto native bool IsDoorOpeningAjar(int index);
25 
27  proto native bool IsDoorClosing(int index);
28 
30  proto native bool IsDoorOpened(int index);
31 
33  proto native bool IsDoorOpenedAjar(int index);
34 
36  proto native bool IsDoorClosed(int index);
37 
39  proto native bool IsDoorLocked(int index);
40 
42  proto native void PlayDoorSound(int index);
43 
45  proto native void OpenDoor(int index);
46 
48  proto native void CloseDoor(int index);
49 
51  proto native void LockDoor(int index, bool force = false);
52 
54  proto native void UnlockDoor(int index);
55 
57  proto native vector GetDoorSoundPos(int index);
58 
60  proto native float GetDoorSoundDistance(int index);
61 
63  proto native void OutputDoorLog();
64 
66  int GetNearestDoorBySoundPos(vector position)
67  {
68  float smallestDist = float.MAX;
69  int nearestDoor = -1;
70 
71  int count = GetDoorCount();
72  for (int i = 0; i < count; i++)
73  {
74  float dist = vector.DistanceSq(GetDoorSoundPos(i), position);
75  if (dist < smallestDist)
76  {
77  nearestDoor = i;
78  smallestDist = dist;
79  }
80  }
81 
82  return nearestDoor;
83  }
84 
86  void OnDoorOpenStart(DoorStartParams params)
87  {
88  }
89 
91  void OnDoorOpenFinish(DoorFinishParams params)
92  {
93  }
94 
96  void OnDoorOpenAjarStart(DoorStartParams params)
97  {
98  }
99 
101  void OnDoorOpenAjarFinish(DoorFinishParams params)
102  {
103  }
104 
106  void OnDoorCloseStart(DoorStartParams params)
107  {
108  }
109 
111  void OnDoorCloseFinish(DoorFinishParams params)
112  {
113  }
114 
116  void OnDoorLocked(DoorLockParams params)
117  {
118  }
119 
121  void OnDoorUnlocked(DoorLockParams params)
122  {
123  }
124 
125  bool CanDoorBeOpened(int doorIndex, bool checkIfLocked = false)
126  {
127  if (IsDoorOpen(doorIndex))
128  return false;
129 
130  if (checkIfLocked)
131  {
132  if (IsDoorLocked(doorIndex))
133  return false;
134  }
135  else
136  {
137  if (!IsDoorLocked(doorIndex))
138  return false;
139  }
140  return true;
141  }
142 
143  bool CanDoorBeClosed(int doorIndex)
144  {
145  return IsDoorOpen(doorIndex);
146  }
147 
149  bool CanDoorBeLocked(int doorIndex)
150  {
151  return (!IsDoorOpen(doorIndex) && !IsDoorLocked(doorIndex));
152  }
153 
154  override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
155  {
156  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_OUTPUT_LOG, "Output Door Log", FadeColors.LIGHT_GREY));
157  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, " --- ", FadeColors.LIGHT_GREY));
158 
159  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_PLAY_DOOR_SOUND, "Play Door Sound", FadeColors.LIGHT_GREY));
160  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_OPEN_DOOR, "Open Door", FadeColors.LIGHT_GREY));
161  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_CLOSE_DOOR, "Close Door", FadeColors.LIGHT_GREY));
162  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_LOCK_DOOR, "Lock Door", FadeColors.LIGHT_GREY));
163  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.BUILDING_UNLOCK_DOOR, "Unlock Door", FadeColors.LIGHT_GREY));
164  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, " --- ", FadeColors.LIGHT_GREY));
165 
166  super.GetDebugActions(outputList);
167  }
168 
169  override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
170  {
171  if (super.OnAction(action_id, player, ctx))
172  return true;
173 
174  switch (action_id)
175  {
176  case EActions.BUILDING_PLAY_DOOR_SOUND:
177  PlayDoorSound(GetNearestDoorBySoundPos(player.GetPosition()));
178  return true;
179  }
180 
181  if (!GetGame().IsServer())
182  return false;
183 
184  switch (action_id)
185  {
186  case EActions.BUILDING_OUTPUT_LOG:
187  OutputDoorLog();
188  return true;
189  case EActions.BUILDING_OPEN_DOOR:
190  OpenDoor(GetNearestDoorBySoundPos(player.GetPosition()));
191  return true;
192  case EActions.BUILDING_CLOSE_DOOR:
193  CloseDoor(GetNearestDoorBySoundPos(player.GetPosition()));
194  return true;
195  case EActions.BUILDING_LOCK_DOOR:
196  LockDoor(GetNearestDoorBySoundPos(player.GetPosition()));
197  return true;
198  case EActions.BUILDING_UNLOCK_DOOR:
199  UnlockDoor(GetNearestDoorBySoundPos(player.GetPosition()));
200  return true;
201  }
202 
203  return false;
204  }
205 
206  override bool IsBuilding()
207  {
208  return true;
209  }
210 
211  override bool CanObstruct()
212  {
213  return true;
214  }
215 
216  override bool IsHealthVisible()
217  {
218  return false;
219  }
220 
222 
223  void Building()
224  {
226  g_Game.ConfigGetIntArray("cfgVehicles " +GetType() + " InteractActions", m_InteractActions);
227  }
228 
229  override bool IsInventoryVisible()
230  {
231  return false;
232  }
233 
234  override int GetMeleeTargetType()
235  {
236  return EMeleeTargetType.NONALIGNABLE;
237  }
238 };
Param2
Definition: ppeconstants.c:66
GetGame
proto native CGame GetGame()
DoorFinishParams
Param2< int, bool > DoorFinishParams
Definition: building.c:2
DoorLockParams
Param1< int > DoorLockParams
Definition: building.c:3
IsInventoryVisible
class PASBroadcaster extends AdvancedCommunication IsInventoryVisible
Definition: advancedcommunication.c:135
m_InteractActions
ref TIntArray m_InteractActions
Definition: itembase.c:85
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
TIntArray
array< int > TIntArray
Definition: enscript.c:687
vector
Definition: enconvert.c:105
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
GetDebugActions
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Definition: edible_base.c:744
EActions
EActions
Definition: eactions.c:1
OnAction
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Definition: edible_base.c:755
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
CanObstruct
override bool CanObstruct()
Definition: basebuildingbase.c:82
IsBuilding
protected bool IsBuilding(ActionTarget target)
Definition: actionbase.c:918
SAT_DEBUG_ACTION
const int SAT_DEBUG_ACTION
Definition: constants.c:424
TSelectableActionInfoWithColor
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition: entityai.c:97
EntityAI
Definition: building.c:5
DoorStartParams
Param1< int > DoorStartParams
Definition: building.c:1
GetType
override int GetType()
Definition: huddebugwincharagents.c:49
EMeleeTargetType
EMeleeTargetType
Definition: emeleetargettype.c:1