1 [
EntityEditorProps(
category:
"GameScripted/Test", description:
"Entity that fires raycasts to a target", color:
"0 0 255 255")]
18 private void DBG_Line()
24 int shapeFlags = ShapeFlags.NOOUTLINE;
25 Shape s = Shape.CreateLines(ARGBF(1, 1, 1, 1), shapeFlags, p, 2);
26 m_aDbgShapes.Insert(s);
29 private void DBG_Sphere(vector pos,
int color)
32 Math3D.MatrixIdentity4(matx);
34 int shapeFlags = ShapeFlags.NOOUTLINE|ShapeFlags.NOZBUFFER|ShapeFlags.TRANSP;
35 Shape s = Shape.CreateSphere(color, shapeFlags, pos, 0.05);
37 m_aDbgShapes.Insert(s);
40 private void DoTraceLine()
42 autoptr TraceParam param =
new TraceParam;
44 param.Flags = TraceFlags.ENTS | TraceFlags.WORLD;
45 param.LayerMask = TRACE_LAYER_MASK;
46 param.Start = m_vRCStart;
52 private void DoTraceSphere()
54 autoptr TraceSphere param =
new TraceSphere;
56 param.Flags = TraceFlags.ENTS | TraceFlags.WORLD;
57 param.LayerMask = TRACE_LAYER_MASK;
58 param.Start = m_vRCStart;
65 private void TraceResult(TraceParam param)
67 float hit = GetWorld().TraceMove(param,
null);
73 Print(
"| " +
GetName() +
" results" );
74 Print(
"|_ Entity: " + param.TraceEnt);
75 Print(
"|_ Collider: " + param.ColliderName);
79 vector hitPos = m_vRCStart + vector.Forward * (hit * RAY_LENGTH);
80 DBG_Sphere(hitPos, ARGBF(0.5, 1, 0, 0));
83 void DoRaycast(
int typeOfRayCast)
85 switch (typeOfRayCast)
99 override void EOnFrame(IEntity owner,
float timeSlice)
101 m_fTime += timeSlice;
103 if (m_fTime > MEASURE_INTERVAL)
105 m_aDbgShapes.Clear();
107 DoRaycast(m_iTypeOfRaycast);
110 DBG_Sphere(m_vRCStart, ARGBF(1, 1, 1, 1));
111 DBG_Sphere(m_vRCEnd, ARGBF(1, 1, 1, 1));
120 SetEventMask(EntityEvent.FRAME);
121 SetFlags(EntityFlags.ACTIVE,
false);
124 GetWorldTransform(worldMat);
126 m_vRCStart = worldMat[3];
127 m_vRCEnd = m_vRCStart + vector.Forward * RAY_LENGTH;
129 m_aDbgShapes =
new array<ref Shape>;
137 private const int TRACE_LAYER_MASK = EPhysicsLayerDefs.Projectile;
138 private const float MEASURE_INTERVAL = 1.0;
139 private const float RAY_LENGTH = 3.0;
140 private float m_fTime;
142 private vector m_vRCStart;
143 private vector m_vRCEnd;
146 private ref array<ref Shape> m_aDbgShapes;