2[
EntityEditorProps(
category:
"GameScripted/Editor", description:
"Core Editor manager", color:
"251 91 0 255", dynamicBox:
true)]
10 private vector m_vSlotSize;
13 private bool m_bIsRectangle;
16 private float m_fRefreshRate;
19 private bool m_bCompositionSearched;
25 private ref
Shape m_Shape;
29 protected bool InArea(
vector pos)
32 float sizeX = m_vSlotSize[0];
33 float sizeY = m_vSlotSize[1];
34 float sizeZ = m_vSlotSize[2];
38 return (pos[0] > -sizeX && pos[0] < sizeX) && (pos[2] > -sizeZ && pos[2] < sizeZ);
42 return Vector(pos[0], 0, pos[2]).Length() < sizeX;
47 protected bool FindComposition()
49 if (m_bCompositionSearched)
51 if (m_CompositionSource)
57 m_bCompositionSearched =
true;
59 WorldEditor worldEditor = Workbench.GetModule(WorldEditor);
63 WorldEditorAPI worldEditorAPI = worldEditor.GetApi();
67 for (
int i = 0, containersCount = worldEditor.GetNumContainers(); i < containersCount; i++)
69 IEntitySource entitySource = IEntitySource.Cast(worldEditor.GetContainer(i));
70 if (!entitySource || entitySource.GetSubScene() != worldEditorAPI.GetCurrentSubScene() || entitySource.GetLayerID() != worldEditorAPI.GetCurrentEntityLayerId())
74 m_CompositionSource = entitySource;
78 if (!m_CompositionSource)
80 Print(
"Cannot find the composition, no entities are present in the current layer.",
LogLevel.WARNING);
84 m_Title.SetText(m_CompositionSource.GetResourceName());
90 protected void ProcessEntities(IEntitySource entitySource, out
int count)
92 IEntitySource childSource;
94 vector boundMin, boundMax;
95 vector boundPoints[8];
96 WorldEditorAPI worldEditorAPI = ((WorldEditor)Workbench.GetModule(WorldEditor)).GetApi();
97 for (
int i = 0, countChildren = entitySource.GetNumChildren(); i < countChildren; i++)
99 childSource = entitySource.GetChild(i);
100 child = worldEditorAPI.SourceToEntity(childSource);
129 ProcessEntities(childSource, count);
136 return EEntityFrameUpdateSpecs.CALL_WHEN_ENTITY_VISIBLE;
142 if (!FindComposition())
155 ProcessEntities(m_CompositionSource, count);
156 m_Text.SetText(
string.Format(
"Entities: %1", count));
163 void SCR_CompositionValidationEntity(IEntitySource src,
IEntity parent)
165 m_Title = DebugTextScreenSpace.Create(
GetWorld(),
"",
DebugTextFlags.FACE_CAMERA, 10, 10, 20,
ARGBF(1, 1, 1, 1),
ARGBF(1, 0, 0, 0));
166 m_Text = DebugTextScreenSpace.Create(
GetWorld(),
"",
DebugTextFlags.FACE_CAMERA, 10, 33, 14,
ARGBF(1, 1, 1, 1),
ARGBF(1, 0, 0, 0));
178 void ~SCR_CompositionValidationEntity()
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
enum EVehicleType IEntity
event void _WB_AfterWorldUpdate(float timeSlice)
Called after updating world in Workbench. The entity must be visible in frustum, selected or named....
event int _WB_GetAfterWorldUpdateSpecs(IEntitySource src)
Called after _WB_OnInit or also later when editor needs to know whether _WB_AfterWorldUpdate needs to...
proto external vector GetOrigin()
proto external void GetBounds(out vector mins, out vector maxs)
proto external BaseWorld GetWorld()
proto external vector CoordToParent(vector coord)
proto external vector CoordToLocal(vector coord)
Instance of created debug visualizer.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
SCR_FieldOfViewSettings Attribute
proto native vector Vector(float x, float y, float z)
proto int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.