Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
componententitydebug.c
Go to the documentation of this file.
1 class ComponentEntityDebug extends Component
2 {
3 
4  protected Shape m_DebugShapeBBox;
5  protected Shape m_DebugShapeDirection;
6  protected float m_DebugShapeDirectionDist;
7 
8  // -------------------------------------------------------------------------
9  override Shape DebugBBoxDraw()
10  {
11  #ifndef DEVELOPER
12  return null;
13  #endif
14 
15  if ( m_DebugShapeBBox )
16  m_DebugShapeBBox.Destroy();
17 
18  vector min_max[2];
19 
20  if (!m_ThisEntityAI.GetCollisionBox(min_max))
21  return null;
22 
23  m_DebugShapeBBox = Debug.DrawBox(min_max[0], min_max[1]);
24 
25  GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(OnDrawing, 0, true);
26 
27  m_ThisEntityAI.SetEventMask(EntityEvent.FRAME);
28 
29  return null;
30  }
31 
32  // -------------------------------------------------------------------------
33  override void DebugBBoxSetColor(int color)
34  {
35  if ( m_DebugShapeBBox )
36  {
37  m_DebugShapeBBox.SetColor(color);
38  }
39  }
40 
41  // -------------------------------------------------------------------------
42  override void DebugBBoxDelete()
43  {
44  #ifndef DEVELOPER
45  return;
46  #endif
47 
48  if ( m_DebugShapeBBox )
49  {
50  m_DebugShapeBBox.Destroy();
51  m_DebugShapeBBox = null;
52  }
53 
54  if ( !m_DebugShapeDirection && !m_DebugShapeBBox )
55  {
56  GetGame().GetCallQueue(CALL_CATEGORY_GUI).Remove(OnDrawing);
57  }
58  }
59 
60  // -------------------------------------------------------------------------
61  override Shape DebugDirectionDraw(float distance = 1)
62  {
63  #ifndef DEVELOPER
64  return null;
65  #endif
66 
67  if ( m_DebugShapeDirection )
68  {
69  m_DebugShapeDirection.Destroy();
70  }
71 
72  vector p1 = "0 0 0";
73  vector p2 = m_ThisEntityAI.GetDirection() * m_DebugShapeDirectionDist;
74  m_DebugShapeDirectionDist = distance;
75  m_DebugShapeDirection = Debug.DrawArrow(p1, p2);
76 
77  GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(OnDrawing, 0, true);
78 
79  m_ThisEntityAI.SetEventMask(EntityEvent.FRAME);
80  return null;
81  }
82 
83  // -------------------------------------------------------------------------
84  override void DebugDirectionDelete()
85  {
86  #ifndef DEVELOPER
87  return;
88  #endif
89 
90  if ( m_DebugShapeDirection )
91  {
92  m_DebugShapeDirection.Destroy();
93  m_DebugShapeDirection = null;
94  }
95 
96  if ( !m_DebugShapeDirection && !m_DebugShapeBBox )
97  {
98  GetGame().GetCallQueue(CALL_CATEGORY_GUI).Remove(OnDrawing);
99  }
100  }
101 
102  void OnDrawing()
103  {
104  #ifndef DEVELOPER
105  return;
106  #endif
107 
108  if ( m_DebugShapeBBox || m_DebugShapeDirection )
109  {
110  vector mat[4];
111  m_ThisEntityAI.GetTransform(mat);
112 
113  if ( m_DebugShapeBBox )
114  {
115  m_DebugShapeBBox.SetMatrix(mat);
116  }
117 
118  if ( m_DebugShapeDirection )
119  {
120  m_DebugShapeDirection.SetMatrix(mat);
121  }
122  }
123  }
124 }
GetGame
proto native CGame GetGame()
Component
Definition: componententitydebug.c:1
CALL_CATEGORY_GUI
const int CALL_CATEGORY_GUI
Definition: tools.c:9
vector
Definition: enconvert.c:105
Debug
Definition: debug.c:13
EntityEvent
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition: enentity.c:44
Shape
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead