12 protected ResourceName m_WidgetPrefab;
15 protected ResourceName m_SlotWidgetPrefab;
17 protected bool m_bCanUpdate;
18 protected WorkspaceWidget m_Workspace;
20 protected ref map<SCR_EditableEntityComponent, SCR_EditableEntitySceneSlotUIComponent> m_EntitySlots =
new map<SCR_EditableEntityComponent, SCR_EditableEntitySceneSlotUIComponent>;
21 protected ref map<SCR_EditableEntityComponent, Widget> m_EntityWidgets =
new map<SCR_EditableEntityComponent, Widget>;
23 protected void OnEditorPingAction(
float value, EActionTrigger reason)
27 protected void OnEditorPingUnlimitedOnlyAction(
float value, EActionTrigger reason)
31 protected void SendPing(
bool unlimitedOnly)
38 if (!target || !target.GetPos(
position))
41 WorkspaceWidget workspace =
GetGame().GetWorkspace();
42 if (!workspace)
return;
48 int screenW = workspace.GetWidth();
49 int screenH = workspace.GetHeight();
51 BaseWorld world =
GetGame().GetWorld();
53 vector startPos = workspace.ProjScreenToWorld(workspace.DPIUnscale(screenW / 2), workspace.DPIUnscale(screenH / 2), outDir, world);
56 autoptr TraceParam trace =
new TraceParam();
57 trace.Start = startPos;
58 trace.End = startPos + outDir;
59 trace.Flags = TraceFlags.WORLD | TraceFlags.OCEAN | TraceFlags.ENTS;
61 float traceDis = world.TraceMove(trace,
null);
64 if (!target && traceDis == 1)
return;
66 position = startPos + outDir * traceDis;
69 m_PingManager.SendPing(unlimitedOnly,
position, target);
77 if (!m_EntitySlots.Find(pingEntity, slot))
80 if (!slotWidget)
return;
85 slot.InitSlot(pingEntity);
86 m_EntitySlots.Insert(pingEntity, slot);
90 slot.DeleteWidget(
null);
91 Widget entityWidget = slot.CreateWidget(pingEntity, m_WidgetPrefab);
92 m_EntityWidgets.Insert(pingEntity, entityWidget);
98 if (m_EntityWidgets.Find(pingEntity, entityWidget))
100 m_EntityWidgets.Remove(pingEntity);
104 if (m_EntitySlots.Find(pingEntity, slot))
108 slot.DeleteWidget(
null);
112 if (!slot || slot.IsEmpty())
114 m_EntitySlots.Remove(pingEntity);
115 m_bCanUpdate = !m_EntitySlots.IsEmpty();
120 override event void UpdateValues(IEntity owner,
float timeSlice)
129 vector posCenter = Vector(screenW / 2, screenH / 2, 0);
131 vector transformCam[4];
132 GetGame().GetWorld().GetCurrentCamera(transformCam);
133 vector posCam = transformCam[3];
137 entitySlot.UpdateSlot(screenW, screenH, posCenter, posCam);
140 override event void OnStartDraw(IEntity owner)
142 super.OnStartDraw(owner);
148 if (editorManagerCore) editorManagerCore.Event_OnEditorManagerInitOwner.Insert(OnStartDraw);
154 if (editorManagerCore) editorManagerCore.Event_OnEditorManagerInitOwner.Remove(OnStartDraw);
158 if (!m_PingManager)
return;
160 m_PingManager.GetOnPingEntityRegister().Insert(OnPingEntityRegister);
161 m_PingManager.GetOnPingEntityUnregister().Insert(OnPingEntityUnregister);
165 InputManager inputManager =
GetGame().GetInputManager();
168 inputManager.AddActionListener(
"EditorPing", EActionTrigger.DOWN, OnEditorPingAction);
169 inputManager.AddActionListener(
"EditorPingUnlimitedOnly", EActionTrigger.DOWN, OnEditorPingUnlimitedOnlyAction);
172 override event void OnStopDraw(IEntity owner)
174 super.OnStopDraw(owner);
177 for (
int i = 0, count = m_EntitySlots.Count(); i < count; i++)
179 OnPingEntityUnregister(0, m_EntitySlots.GetKey(0));
184 m_PingManager.GetOnPingEntityRegister().Remove(OnPingEntityRegister);
185 m_PingManager.GetOnPingEntityUnregister().Remove(OnPingEntityUnregister);
188 InputManager inputManager =
GetGame().GetInputManager();
191 inputManager.RemoveActionListener(
"EditorPing", EActionTrigger.DOWN, OnEditorPingAction);
192 inputManager.RemoveActionListener(
"EditorPingUnlimitedOnly", EActionTrigger.DOWN, OnEditorPingUnlimitedOnlyAction);