6[
EntityEditorProps(
category:
"GameScripted/Helpers", description:
"Allows debug shapes to be rendered. Only spawn one-instance.")]
13 [
Attribute(
desc:
"Limit amount of shapes drawn per tag. Older shapes get thrown out of draw list.", defvalue:
"10000",
category:
"Limits",
params:
"0 inf")]
16 protected static SCR_DebugShapeHelperComponent s_Instance;
17 protected static int s_iShapeLimit = 10000;
18 protected static bool s_bKeepDrawList;
22 protected static const int DEFAULT_COLOUR = MakeTransparent(
Color.YELLOW);
27 protected static const string DEBUG_TAG =
"SCR_DebugShapeHelperComponent";
38 static void CreateFloorCeilingTraceShapes(
World world,
vector startPos,
TraceParam traceParam,
vector floorPos,
vector ceilingPos,
bool enoughSpace,
string text =
"",
string tag =
"")
40 string shapeTag =
string.Format(
"%1_%2", DEBUG_TAG, tag);
41 SCR_DebugShapeHelperComponent.AddSphere(startPos, 0.1,
Color.VIOLET, DEFAULT_SHAPE_FLAGS_NOZWRITE, tag: shapeTag);
43 SCR_DebugShapeHelperComponent.AddText(world, startPos, text, tag: shapeTag);
48 SCR_DebugShapeHelperComponent.AddBox(
Vector(floorPos[0] + traceBox.Mins[0], floorPos[1], floorPos[2] + traceBox.Mins[2]),
Vector(ceilingPos[0] + traceBox.Maxs[0], ceilingPos[1], ceilingPos[2] + traceBox.Maxs[2]), SCR_DebugShapeHelperComponent.GetColorBasedOnSuccess(enoughSpace), DEFAULT_SHAPE_FLAGS_NOZWRITE, tag: shapeTag);
52 TraceSphere traceSphere = TraceSphere.Cast(traceParam);
55 int color = SCR_DebugShapeHelperComponent.GetColorBasedOnSuccess(enoughSpace);
56 vector sphereOffset =
Vector(0, traceSphere.Radius, 0);
57 SCR_DebugShapeHelperComponent.AddCylinderBetween(floorPos + sphereOffset, ceilingPos - sphereOffset, traceSphere.Radius, color, DEFAULT_SHAPE_FLAGS_NOZWRITE, tag: shapeTag);
58 SCR_DebugShapeHelperComponent.AddSphere(floorPos + sphereOffset, traceSphere.Radius, color, DEFAULT_SHAPE_FLAGS_NOZWRITE, tag: shapeTag);
59 SCR_DebugShapeHelperComponent.AddSphere(ceilingPos - sphereOffset, traceSphere.Radius, color, DEFAULT_SHAPE_FLAGS_NOZWRITE, tag: shapeTag);
69 static void AddSphere(vector center,
float radius,
int color,
ShapeFlags shapeFlags = DEFAULT_SHAPE_FLAGS,
string tag =
"")
71 Shape shape = Shape.CreateSphere(
86 static void AddCylinderBetween(vector bottom, vector top,
float radius,
int color,
ShapeFlags shapeFlags = DEFAULT_SHAPE_FLAGS,
string tag =
"")
88 AddCylinder(0.5 * (bottom + top), radius, top[1] - bottom[1], color, shapeFlags, tag);
97 static void AddCylinder(vector center,
float radius,
float length,
int color,
ShapeFlags shapeFlags = DEFAULT_SHAPE_FLAGS,
string tag =
"")
99 Shape shape = Shape.CreateCylinder(
106 AddShape(shape, tag);
114 static void AddBox(vector mins, vector maxs,
int color,
ShapeFlags shapeFlags = DEFAULT_TRIS_FLAGS,
string tag =
"")
118 Vector(mins[0], mins[1], mins[2]),
119 Vector(maxs[0], mins[1], mins[2]),
120 Vector(mins[0], maxs[1], mins[2]),
122 Vector(maxs[0], maxs[1], mins[2]),
123 Vector(mins[0], maxs[1], mins[2]),
124 Vector(maxs[0], mins[1], mins[2]),
126 Vector(mins[0], mins[1], maxs[2]),
127 Vector(maxs[0], mins[1], maxs[2]),
128 Vector(mins[0], maxs[1], maxs[2]),
130 Vector(maxs[0], maxs[1], maxs[2]),
131 Vector(mins[0], maxs[1], maxs[2]),
132 Vector(maxs[0], mins[1], maxs[2]),
134 Vector(mins[0], mins[1], mins[2]),
135 Vector(mins[0], mins[1], maxs[2]),
136 Vector(mins[0], maxs[1], mins[2]),
138 Vector(mins[0], maxs[1], maxs[2]),
139 Vector(mins[0], maxs[1], mins[2]),
140 Vector(mins[0], mins[1], maxs[2]),
142 Vector(maxs[0], mins[1], mins[2]),
143 Vector(maxs[0], mins[1], maxs[2]),
144 Vector(maxs[0], maxs[1], mins[2]),
146 Vector(maxs[0], maxs[1], maxs[2]),
147 Vector(maxs[0], maxs[1], mins[2]),
148 Vector(maxs[0], mins[1], maxs[2]),
150 Vector(mins[0], mins[1], mins[2]),
151 Vector(maxs[0], mins[1], mins[2]),
152 Vector(mins[0], mins[1], maxs[2]),
154 Vector(maxs[0], mins[1], maxs[2]),
155 Vector(mins[0], mins[1], maxs[2]),
156 Vector(maxs[0], mins[1], mins[2]),
158 Vector(mins[0], maxs[1], mins[2]),
159 Vector(maxs[0], maxs[1], mins[2]),
160 Vector(mins[0], maxs[1], maxs[2]),
162 Vector(maxs[0], maxs[1], maxs[2]),
163 Vector(mins[0], maxs[1], maxs[2]),
164 Vector(maxs[0], maxs[1], mins[2]),
166 Shape shape = Shape.CreateTris(
172 AddShape(shape, tag);
181 static void AddBoxWithTransform(vector mins, vector maxs, vector ownerTransform[4],
int color,
ShapeFlags shapeFlags = DEFAULT_TRIS_FLAGS,
string tag =
"")
186 Vector(mins[0], mins[1], mins[2]),
187 Vector(maxs[0], mins[1], mins[2]),
188 Vector(mins[0], maxs[1], mins[2]),
190 Vector(maxs[0], maxs[1], mins[2]),
191 Vector(mins[0], maxs[1], mins[2]),
192 Vector(maxs[0], mins[1], mins[2]),
194 Vector(mins[0], mins[1], maxs[2]),
195 Vector(maxs[0], mins[1], maxs[2]),
196 Vector(mins[0], maxs[1], maxs[2]),
198 Vector(maxs[0], maxs[1], maxs[2]),
199 Vector(mins[0], maxs[1], maxs[2]),
200 Vector(maxs[0], mins[1], maxs[2]),
202 Vector(mins[0], mins[1], mins[2]),
203 Vector(mins[0], mins[1], maxs[2]),
204 Vector(mins[0], maxs[1], mins[2]),
206 Vector(mins[0], maxs[1], maxs[2]),
207 Vector(mins[0], maxs[1], mins[2]),
208 Vector(mins[0], mins[1], maxs[2]),
210 Vector(maxs[0], mins[1], mins[2]),
211 Vector(maxs[0], mins[1], maxs[2]),
212 Vector(maxs[0], maxs[1], mins[2]),
214 Vector(maxs[0], maxs[1], maxs[2]),
215 Vector(maxs[0], maxs[1], mins[2]),
216 Vector(maxs[0], mins[1], maxs[2]),
218 Vector(mins[0], mins[1], mins[2]),
219 Vector(maxs[0], mins[1], mins[2]),
220 Vector(mins[0], mins[1], maxs[2]),
222 Vector(maxs[0], mins[1], maxs[2]),
223 Vector(mins[0], mins[1], maxs[2]),
224 Vector(maxs[0], mins[1], mins[2]),
226 Vector(mins[0], maxs[1], mins[2]),
227 Vector(maxs[0], maxs[1], mins[2]),
228 Vector(mins[0], maxs[1], maxs[2]),
230 Vector(maxs[0], maxs[1], maxs[2]),
231 Vector(mins[0], maxs[1], maxs[2]),
232 Vector(maxs[0], maxs[1], mins[2]),
237 for (
int i = 0; i < 36; i++)
239 mesh[i] = mesh[i].Multiply4(ownerTransform);
242 Shape shape = Shape.CreateTris(
248 AddShape(shape, tag);
255 static void AddText(World world, vector origin,
string text,
ShapeFlags shapeFlags = DEFAULT_TEXT_FLAGS,
string tag =
"")
257 Managed shape = DebugTextWorldSpace.Create(
261 origin[0], origin[1], origin[2],
263 bgColor: Color.BLACK,
266 AddShape(shape, tag);
273 static void AddShape(notnull Managed shape,
string tag =
"")
278 array<ref Managed> shapes;
279 if (!s_mTaggedShapes.Find(tag, shapes))
282 s_mTaggedShapes.Insert(tag, shapes);
284 shapes.Insert(shape);
285 while (shapes.Count() > s_iShapeLimit)
295 static int MakeTransparent(
int color)
298 Color.UnpackInt(color, a, r, g, b);
300 return ARGB(a, r, g, b);
307 static int GetColorBasedOnSuccess(
bool success)
310 return MakeTransparent(Color.GREEN);
312 return MakeTransparent(Color.RED);
319 static float GetDebugRadiusFromTraceParam(TraceParam traceParam)
321 TraceSphere traceSphere = TraceSphere.Cast(traceParam);
323 return traceSphere.Radius;
324 TraceBox traceBox = TraceBox.Cast(traceParam);
326 return Math.Max(traceBox.Maxs[0] - traceBox.Mins[0], traceBox.Maxs[2] - traceBox.Mins[2]);
327 PrintFormat(
"[SCR_DebugShapeHelperComponent] GetDebugRadiusFromTraceParam has no case for TraceParam of type %1", traceParam.Type(),
LogLevel.WARNING);
335 static void RemoveShape(notnull Managed shape,
string tag =
"")
337 array<ref Managed> shapes;
338 if (s_mTaggedShapes.Find(tag, shapes))
339 shapes.RemoveItem(shape);
345 static void RemoveTag(
string tag)
347 array<ref Managed> shapes;
348 if (!s_mTaggedShapes.Find(tag, shapes))
351 s_mTaggedShapes.Remove(tag);
359 s_mTaggedShapes.Clear();
366 s_bKeepDrawList =
false;
370 s_iShapeLimit =
Math.Max(0, m_iShapeLimit);
380 if (!s_bKeepDrawList)
401 if (key ==
"m_iShapeLimit")
403 s_bKeepDrawList =
true;
407 if (key ==
"Enabled")
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
override void _WB_OnInit(IEntity owner, inout vector mat[4], IEntitySource src)
override bool _WB_OnKeyChanged(IEntity owner, BaseContainer src, string key, BaseContainerList ownerContainers, IEntity parent)
Any property value has been changed. You can use editor API here and do some additional edit actions ...
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_SpawnerSlotManagerClass s_Instance
Class used for managing changes and removals of slots present in world.
static bool IsEmptyOrWhiteSpace(string input)
LogLevel
Enum with severity of the logging message.
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute
proto native vector Vector(float x, float y, float z)
proto native void Clear()
Remove all calls from list.
proto int ARGB(int a, int r, int g, int b)