8 protected bool m_bRotateWithTarget;
14 private ResourceName m_Layout;
16 protected IEntity m_Target;
17 protected SCR_AttachEntity m_AttachHelper;
18 protected bool m_bAttachChanged;
19 private Widget m_Widget;
20 protected ref ScriptInvoker m_OnAttachChange =
new ScriptInvoker();
26 bool AttachTo(IEntity target)
29 if (!target || target ==
m_Target || !
SCR_Enum.HasFlag(target.GetFlags(), EntityFlags.TRACEABLE))
44 EntitySpawnParams spawnParams =
new EntitySpawnParams;
45 spawnParams.Transform[3] =
m_Target.CoordToParent(vector.Zero);
46 m_AttachHelper = SCR_AttachEntity.Cast(
GetGame().
SpawnEntity(SCR_AttachEntity, camera.GetWorld(), spawnParams));
49 m_AttachHelper.EOnPostFrame(m_AttachHelper, 0);
50 camera.AttachTo(m_AttachHelper);
52 m_bAttachChanged =
true;
54 m_OnAttachChange.Invoke(
true,
m_Target);
72 m_OnAttachChange.Invoke(
false,
m_Target);
78 delete m_AttachHelper;
80 m_bAttachChanged =
true;
88 ScriptInvoker GetOnAttachChange()
90 return m_OnAttachChange;
98 data.m_aValues = {m_AttachType};
106 if (
data.m_Target && m_AttachType ==
data.m_aValues[0])
107 AttachTo(
data.m_Target);
117 if (!param.isManualInputEnabled)
120 m_Widget.SetVisible(
false);
126 switch (m_AttachType)
130 if (param.isManualInputEnabled &&
GetInputManager().GetActionTriggered(
"ManualCameraAttach"))
132 param.GetCursorWorldPos();
133 if (!AttachTo(param.target))
157 if (m_bAttachChanged)
159 m_bAttachChanged =
false;
164 camera.GetLocalTransform(param.transform);
165 camera.GetLocalTransform(param.transformOriginal);
166 param.isDirty =
true;
170 m_Widget.SetVisible(
m_Target !=
null);
176 m_Widget.SetVisible(
true);
177 vector screenPos = m_Widget.GetWorkspace().ProjWorldToScreen(m_AttachHelper.GetOrigin(), param.world);
178 if (screenPos[2] > 0)
179 FrameSlot.SetPos(m_Widget, screenPos[0], screenPos[1]);
184 override bool EOnCameraInit()
191 override void EOnCameraExit()
194 m_Widget.RemoveFromHierarchy();
196 delete m_AttachHelper;
200 class SCR_AttachEntityClass : GenericEntityClass
223 SetEventMask(EntityEvent.POSTFRAME);
224 SetFlags(EntityFlags.ACTIVE);
236 m_Target.GetWorldTransform(transform);
237 SetWorldTransform(transform);
241 SetOrigin(
m_Target.GetWorldTransformAxis(3));