123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- class ComponentEntityDebug extends Component
- {
-
- protected Shape m_DebugShapeBBox;
- protected Shape m_DebugShapeDirection;
- protected float m_DebugShapeDirectionDist;
- // -------------------------------------------------------------------------
- override Shape DebugBBoxDraw()
- {
- #ifndef DEVELOPER
- return null;
- #endif
-
- if ( m_DebugShapeBBox )
- m_DebugShapeBBox.Destroy();
-
- vector min_max[2];
-
- if (!m_ThisEntityAI.GetCollisionBox(min_max))
- return null;
-
- m_DebugShapeBBox = Debug.DrawBox(min_max[0], min_max[1]);
-
- GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(OnDrawing, 0, true);
-
- m_ThisEntityAI.SetEventMask(EntityEvent.FRAME);
- return null;
- }
- // -------------------------------------------------------------------------
- override void DebugBBoxSetColor(int color)
- {
- if ( m_DebugShapeBBox )
- {
- m_DebugShapeBBox.SetColor(color);
- }
- }
- // -------------------------------------------------------------------------
- override void DebugBBoxDelete()
- {
- #ifndef DEVELOPER
- return;
- #endif
-
- if ( m_DebugShapeBBox )
- {
- m_DebugShapeBBox.Destroy();
- m_DebugShapeBBox = null;
- }
-
- if ( !m_DebugShapeDirection && !m_DebugShapeBBox )
- {
- GetGame().GetCallQueue(CALL_CATEGORY_GUI).Remove(OnDrawing);
- }
- }
- // -------------------------------------------------------------------------
- override Shape DebugDirectionDraw(float distance = 1)
- {
- #ifndef DEVELOPER
- return null;
- #endif
-
- if ( m_DebugShapeDirection )
- {
- m_DebugShapeDirection.Destroy();
- }
-
- vector p1 = "0 0 0";
- vector p2 = m_ThisEntityAI.GetDirection() * m_DebugShapeDirectionDist;
- m_DebugShapeDirectionDist = distance;
- m_DebugShapeDirection = Debug.DrawArrow(p1, p2);
-
- GetGame().GetCallQueue(CALL_CATEGORY_GUI).CallLater(OnDrawing, 0, true);
-
- m_ThisEntityAI.SetEventMask(EntityEvent.FRAME);
- return null;
- }
- // -------------------------------------------------------------------------
- override void DebugDirectionDelete()
- {
- #ifndef DEVELOPER
- return;
- #endif
-
- if ( m_DebugShapeDirection )
- {
- m_DebugShapeDirection.Destroy();
- m_DebugShapeDirection = null;
- }
-
- if ( !m_DebugShapeDirection && !m_DebugShapeBBox )
- {
- GetGame().GetCallQueue(CALL_CATEGORY_GUI).Remove(OnDrawing);
- }
- }
- void OnDrawing()
- {
- #ifndef DEVELOPER
- return;
- #endif
-
- if ( m_DebugShapeBBox || m_DebugShapeDirection )
- {
- vector mat[4];
- m_ThisEntityAI.GetTransform(mat);
-
- if ( m_DebugShapeBBox )
- {
- m_DebugShapeBBox.SetMatrix(mat);
- }
-
- if ( m_DebugShapeDirection )
- {
- m_DebugShapeDirection.SetMatrix(mat);
- }
- }
- }
- }
|