3 protected static float m_Distance = 30;
4 protected static Object m_Selected =
null;
6 protected TextListboxWidget m_VicinityListbox;
7 protected ButtonWidget m_WatchItem;
11 protected ref ContextMenu m_ContextMenu;
15 m_VicinityListbox = TextListboxWidget.Cast(root.FindAnyWidget(
"VicinityListbox"));
16 m_WatchItem = ButtonWidget.Cast(root.FindAnyWidget(
"WatchItemButton"));
22 m_ContextMenu.Init(root.FindAnyWidget(
"VicinityContextMenu"),
true);
30 override void OnSelected()
44 GetGame().GetObjectsAtPosition3D(playerPos, radius, objects,cargo);
45 m_VicinityListbox.ClearItems();
46 m_VicinityItems.Clear();
48 if (m_Selected && objects.Find(m_Selected) == -1)
50 objects.Insert(m_Selected);
56 foreach (
int x,
Object obj:objects)
58 int dist =
vector.Distance(playerPos, obj.GetPosition()) * 1000;
60 while (objectsMap.Contains(dist))
62 objectsMap.Insert(dist, obj);
63 distances.Insert(dist);
68 foreach (
int dst:distances)
70 Object o = objectsMap.Get(dst);
76 m_VicinityItems.Insert(o);
77 int indx = m_VicinityListbox.AddItem(o.GetType(),
null,0,-1);
78 float distanceMeters = dst / 1000;
79 m_VicinityListbox.SetItem(indx, distanceMeters.ToString(),
null,1);
84 m_VicinityListbox.SelectRow(indx);
94 int row = m_VicinityListbox.GetSelectedRow();
97 if (m_VicinityItems.IsValidIndex(row))
99 m_Selected = m_VicinityItems.Get(row);
105 m_ContextMenu.BuildContextMenu(entity, m_VicinityListbox,
this);
116 override bool OnClick(
Widget w,
int x,
int y,
int button)
118 super.OnClick(w,
x,
y,button);
122 int row = m_VicinityListbox.GetSelectedRow();
123 if (w == m_WatchItem)
125 if (m_VicinityItems.IsValidIndex(row))
129 PluginDeveloper.SetDeveloperItemClientEx(m_Selected);
138 override bool OnChange(
Widget w,
int x,
int y,
bool finished)
140 super.OnChange(w,
x,
y, finished);
152 void OnSelectAction(
EntityAI ent,
int actionId)