5 [
Attribute(
desc:
"Show waypoint lines when a group or a waypoint has one of these states.", uiwidget: UIWidgets.Flags, enums: ParamEnumArray.FromEnum(
EEditableEntityState))]
9 protected ref Color m_LineColor;
11 [
Attribute(defvalue:
string.Format(
"%1", ShapeFlags.VISIBLE | ShapeFlags.NOZBUFFER | ShapeFlags.ONCE),
desc:
"Shape flags of lines.", uiwidget: UIWidgets.Flags, enums: ParamEnumArray.FromEnum(ShapeFlags))]
12 protected ShapeFlags m_ShapeFlags;
14 protected ref map<SCR_EditableEntityComponent, int> m_Groups =
new map<SCR_EditableEntityComponent, int>();
15 protected int m_iLineColorPacked;
18 protected void OnMenuUpdate(
float timeSlice)
21 SCR_EditableWaypointComponent waypoint;
29 for (
int i = 0, count = group.GetChildrenCount(
true); i < count; i++)
31 child = group.GetChild(i);
35 waypoint = SCR_EditableWaypointComponent.Cast(child);
36 prevWaypoint = waypoint.GetPrevWaypoint();
38 if (!waypoint.GetPos(pos1) || !prevWaypoint.GetPos(pos2))
41 points = {pos1, pos2};
42 Shape.CreateLines(m_iLineColorPacked, m_ShapeFlags, points, 2);
47 #ifdef WAYPOINT_LINES_DEBUG
49 DbgUI.Text(m_Groups.Count().ToString());
55 protected void OnChanged(
EEditableEntityState state, set<SCR_EditableEntityComponent> entitiesInsert, set<SCR_EditableEntityComponent> entitiesRemove)
57 #ifdef WAYPOINT_LINES_DEBUG
67 group = entity.GetAIGroup();
72 if (!m_Groups.Find(group, groupTokens))
77 m_Groups.Remove(group);
79 m_Groups.Set(group, groupTokens);
81 #ifdef WAYPOINT_LINES_DEBUG
82 entity.Log(stateName +
": " + groupTokens.ToString(),
true, LogLevel.WARNING);
93 group = entity.GetAIGroup();
98 m_Groups.Find(group, groupTokens);
101 m_Groups.Set(group, groupTokens);
103 #ifdef WAYPOINT_LINES_DEBUG
104 entity.Log(stateName +
": " + groupTokens.ToString(),
true);
111 override void HandlerAttachedScripted(Widget w)
114 if (!entitiesManager)
117 m_iLineColorPacked = m_LineColor.PackToInt();
121 set<SCR_EditableEntityComponent> entities =
new set<SCR_EditableEntityComponent>();
122 array<int> states = {};
123 for (
int i = 0, count =
SCR_Enum.BitToIntArray(m_States, states); i < count; i++)
126 filter = entitiesManager.GetFilter(state);
130 filter.GetEntities(entities);
131 filter.GetOnChanged().Insert(OnChanged);
132 OnChanged(state, entities,
null);
137 menu.GetOnMenuUpdate().Insert(OnMenuUpdate);
141 override void HandlerDeattached(Widget w)
144 if (!entitiesManager)
149 array<int> states = {};
150 for (
int i = 0, count =
SCR_Enum.BitToIntArray(m_States, states); i < count; i++)
153 filter = entitiesManager.GetFilter(state);
157 filter.GetOnChanged().Remove(OnChanged);
162 menu.GetOnMenuUpdate().Remove(OnMenuUpdate);