DayZ 1.24
Loading...
Searching...
No Matches
ComponentEntityDebug.c
Go to the documentation of this file.
2{
3
6 protected float m_DebugShapeDirectionDist;
7
8 // -------------------------------------------------------------------------
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 m_DebugShapeBBox.SetColor(color);
37 }
38
39 // -------------------------------------------------------------------------
40 override void DebugBBoxDelete()
41 {
42#ifndef DEVELOPER
43 return;
44#endif
45
46 if (m_DebugShapeBBox)
47 {
48 m_DebugShapeBBox.Destroy();
49 m_DebugShapeBBox = null;
50 }
51
52 if (!m_DebugShapeDirection && !m_DebugShapeBBox)
53 GetGame().GetCallQueue(CALL_CATEGORY_GUI).Remove(OnDrawing);
54 }
55
56 // -------------------------------------------------------------------------
57 override Shape DebugDirectionDraw(float distance = 1)
58 {
59#ifndef DEVELOPER
60 return null;
61#endif
62
63 if (m_DebugShapeDirection)
64 m_DebugShapeDirection.Destroy();
65
66 vector p1 = "0 0 0";
67 vector p2 = m_ThisEntityAI.GetDirection() * m_DebugShapeDirectionDist;
68 m_DebugShapeDirectionDist = distance;
69 m_DebugShapeDirection = Debug.DrawArrow(p1, p2);
70
71 GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(OnDrawing, 0, true);
72
73 m_ThisEntityAI.SetEventMask(EntityEvent.FRAME);
74 return null;
75 }
76
77 // -------------------------------------------------------------------------
78 override void DebugDirectionDelete()
79 {
80#ifndef DEVELOPER
81 return;
82#endif
83
84 if (m_DebugShapeDirection)
85 {
86 m_DebugShapeDirection.Destroy();
87 m_DebugShapeDirection = null;
88 }
89
90 if (!m_DebugShapeDirection && !m_DebugShapeBBox)
91 GetGame().GetCallQueue(CALL_CATEGORY_GUI).Remove(OnDrawing);
92 }
93
94 void OnDrawing()
95 {
96#ifndef DEVELOPER
97 return;
98#endif
99
100 if (m_DebugShapeBBox || m_DebugShapeDirection)
101 {
102 vector mat[4];
103 m_ThisEntityAI.GetTransform(mat);
104
105 if (m_DebugShapeBBox)
106 m_DebugShapeBBox.SetMatrix(mat);
107
108 if (m_DebugShapeDirection)
109 m_DebugShapeDirection.SetMatrix(mat);
110 }
111 }
112}
override void DebugBBoxDelete()
override void DebugDirectionDelete()
override Shape DebugDirectionDraw(float distance=1)
Shape m_DebugShapeDirection
override Shape DebugBBoxDraw()
override void DebugBBoxSetColor(int color)
float m_DebugShapeDirectionDist
Definition Debug.c:14
static Shape DrawBox(vector pos1, vector pos2, int color=0x1fff7f7f)
Definition Debug.c:401
static Shape DrawArrow(vector from, vector to, float size=0.5, int color=0xFFFFFFFF, int flags=0)
Definition Debug.c:511
proto native CGame GetGame()
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition EnEntity.c:44
const int CALL_CATEGORY_GUI
Definition tools.c:9