1 [
EntityEditorProps(
category:
"GameScripted/Utility", description:
"Editor comment, for leaving notes in the editor", sizeMin:
"-1 -1 -1", sizeMax:
"1 1 1", visible:
false, dynamicBox:
true)]
8 [
Attribute(
"New comment", UIWidgets.EditBoxMultiline,
"Write any comment you wish")]
11 [
Attribute(
"0.2", UIWidgets.EditBox,
"Text size in meters")]
14 [
Attribute(
"1 1 1", UIWidgets.ColorPicker,
"Text color")]
17 [
Attribute(
"0", UIWidgets.Slider,
"Text transparency",
"0 1 0.05")]
20 [
Attribute(
"0", UIWidgets.CheckBox,
"If true, text is scaled by distance from camera")]
21 bool m_ScaleByDistance;
23 [
Attribute(
"0", UIWidgets.CheckBox,
"If true, text will face the camera")]
26 [
Attribute(
"0", UIWidgets.CheckBox,
"If true, text will be visible over everything")]
27 bool m_VisibleOverall;
29 [
Attribute(
"0", UIWidgets.CheckBox,
"If true, text will be visible even ingame")]
32 [
Attribute(
"0", UIWidgets.CheckBox,
"If true, text will have a darkened background plane for easier visibility")]
33 bool m_TextBackground;
35 [
Attribute(
"0 0 0", UIWidgets.ColorPicker,
"Background color")]
36 vector m_BackgroundColor;
38 [
Attribute(
"0.5", UIWidgets.Slider,
"Background transparency",
"0 1 0.05")]
39 float m_BackgroundTransparency;
42 private void DrawComment()
44 float textWidthScale = 0.7;
47 GetWorld().GetCurrentCamera(textMat);
51 textMat[0] = GetTransformAxis(0);
52 textMat[1] = GetTransformAxis(1);
53 textMat[2] = GetTransformAxis(2);
57 if (m_ScaleByDistance)
59 distScale = vector.Distance(textMat[3],
GetOrigin()) * 0.1;
60 distScale = Math.Clamp(distScale, 0.5, 10);
63 float textEndSize = (m_Size * distScale) / vector.Distance(textMat[3],
GetOrigin());
64 if (textEndSize < 0.005)
67 textMat[3] =
GetOrigin() - textMat[1] * m_Size * distScale * 0.5;
68 ShapeFlags flags = ShapeFlags.ONCE | ShapeFlags.TRANSP;
70 flags |= ShapeFlags.NOZBUFFER;
71 if (m_Transparency > 0)
72 flags |= ShapeFlags.TRANSP;
75 m_fWB_Width = m_Comment.Length() * m_Size * distScale * textWidthScale;
76 m_fWB_Height = m_Size * distScale;
80 int dtFlags = DebugTextFlags.CENTER | DebugTextFlags.ONCE;
82 dtFlags |= DebugTextFlags.FACE_CAMERA;
84 GetWorldTransform(mat);
86 if (m_ScaleByDistance)
91 bgColor = ARGBF(1 - m_BackgroundTransparency, m_BackgroundColor[0], m_BackgroundColor[1], m_BackgroundColor[2]);
93 bgColor = ARGBF(0, 0, 0, 0);
94 DebugTextWorldSpace.CreateInWorld(GetWorld(), m_Comment, dtFlags, mat, size, ARGBF(1 - m_Transparency,
m_Color[0],
m_Color[1],
m_Color[2]), bgColor);
98 float m_fWB_Width = 1;
99 float m_fWB_Height = 1;
101 override void _WB_GetBoundBox(inout vector min, inout vector max, IEntitySource src)
105 min = Vector(m_fWB_Width * -0.5, m_fWB_Height * -0.5, m_fWB_Width * -0.5);
106 max = Vector(m_fWB_Width * 0.5, m_fWB_Height * 0.5, m_fWB_Width * 0.5);
110 min = Vector(m_fWB_Width * -0.5, m_fWB_Height * -0.5, m_fWB_Height * 0.25 * -0.5);
111 max = Vector(m_fWB_Width * 0.5, m_fWB_Height * 0.5, m_fWB_Height * 0.25 * 0.5);
116 override void _WB_AfterWorldUpdate(
float timeSlice)
118 WorldEditorAPI api = _WB_GetEditorAPI();
122 IEntitySource src = api.EntityToSource(
this);
126 if (api.IsEntityLayerVisible(src.GetSubScene(), src.GetLayerID()))
132 override void EOnFrame(IEntity owner,
float timeSlice)
140 if (m_VisibleIngame && RplSession.Mode() != RplMode.Dedicated)
142 SetEventMask(EntityEvent.FRAME);
147 world.RegisterEntityToBeUpdatedWhileGameIsPaused(
this);
155 world.UnregisterEntityToBeUpdatedWhileGameIsPaused(
this);