7 [
Attribute(
"{2229B9CC8917D3A3}UI/layouts/Map/MapLocationHint.layout",
params:
"et class=layout")]
8 protected ResourceName m_sUIHintLayout;
9 protected Widget m_wUIHintLayout;
12 protected string m_sMapLocationHintWidgetName1;
14 protected string m_sMapLocationHintWidgetName2;
16 protected TextWidget m_wUIHintText;
17 protected TextWidget m_wUIHintText2;
22 protected int m_iGridSizeX;
23 protected int m_iGridSizeY;
25 protected const float angleA = 0.775;
26 protected const float angleB = 0.325;
29 override void EOnInit(IEntity owner)
31 if (!
GetGame().InPlayMode() || !m_WorldDirections)
37 GetGame().GetWorldEntity().GetWorldBounds(mins, maxs);
39 m_iGridSizeX = maxs[0]/3;
40 m_iGridSizeY = maxs[2]/3;
43 protected void ShowMapHint(MapConfiguration config)
46 if (SCR_DeployMenuMain.GetDeployMenu())
48 m_wUIHintLayout =
GetGame().GetWorkspace().CreateWidgets(m_sUIHintLayout);
51 m_wUIHintText = TextWidget.Cast(m_wUIHintLayout.FindAnyWidget(m_sMapLocationHintWidgetName1));
52 m_wUIHintText2= TextWidget.Cast(m_wUIHintLayout.FindAnyWidget(m_sMapLocationHintWidgetName2));
53 CalculateClosestLocation();
54 GetGame().GetCallqueue().CallLater(CalculateClosestLocation,10000,
true);
57 protected void HideMapHint(MapConfiguration config)
60 m_wUIHintLayout.RemoveFromHierarchy();
61 m_wUIHintLayout =
null;
63 m_wUIHintText2 =
null;
64 GetGame().GetCallqueue().Remove(CalculateClosestLocation);
67 protected void CalculateClosestLocation()
72 ChimeraCharacter player = ChimeraCharacter.Cast(
SCR_PlayerController.GetLocalControlledEntity());
77 m_wUIHintLayout.RemoveFromHierarchy();
78 m_wUIHintLayout =
null;
82 vector posPlayer = player.GetOrigin();
88 SCR_MapDescriptorComponent mapDescr = SCR_MapDescriptorComponent.Cast(nearestLocation.FindComponent(SCR_MapDescriptorComponent));
89 string closestLocationName;
93 closestLocationName = item.GetDisplayName();
95 vector lastLocationPos = nearestLocation.GetOrigin();
96 float lastDistance = vector.DistanceSqXZ(lastLocationPos, posPlayer);
99 vector result = posPlayer - lastLocationPos;
102 float angle1 = vector.DotXZ(result,vector.Forward);
103 float angle2 = vector.DotXZ(result,vector.Right);
107 if (angle1 >= angleA)
108 closeLocationAzimuth =
"#AR-MapLocationHint_DirectionNorth";
109 if (angle1 < angleA && angle1 >= angleB )
110 closeLocationAzimuth =
"#AR-MapLocationHint_DirectionNorthEast";
111 if (angle1 < angleB && angle1 >=-angleB)
112 closeLocationAzimuth =
"#AR-MapLocationHint_DirectionEast";
113 if (angle1 < -angleB && angle1 >=-angleA)
114 closeLocationAzimuth =
"#AR-MapLocationHint_DirectionSouthEast";
115 if (angle1 < -angleA)
116 closeLocationAzimuth =
"#AR-MapLocationHint_DirectionSouth";
120 if (angle1 >= angleA)
121 closeLocationAzimuth =
"#AR-MapLocationHint_DirectionNorth";
122 if (angle1 < angleA && angle1 >= angleB )
123 closeLocationAzimuth =
"#AR-MapLocationHint_DirectionNorthWest";
124 if (angle1 < angleB && angle1 >=-angleB)
125 closeLocationAzimuth =
"#AR-MapLocationHint_DirectionWest";
126 if (angle1 < -angleB && angle1 >=-angleA)
127 closeLocationAzimuth =
"#AR-MapLocationHint_DirectionSouthWest";
128 if (angle1 < -angleA)
129 closeLocationAzimuth =
"#AR-MapLocationHint_DirectionSouth";
132 int playerGridPositionX = posPlayer[0]/m_iGridSizeX;
133 int playerGridPositionY = posPlayer[2]/m_iGridSizeY;
135 int playerGridID = GetGridIndex(playerGridPositionX,playerGridPositionY);
136 m_wUIHintText.SetTextFormat(m_WorldDirections.GetPlayerPositionHint(), m_WorldDirections.GetQuadHint(playerGridID));
137 if (lastDistance < 40000)
138 m_wUIHintText2.SetTextFormat(
"#AR-MapLocationHint_PlayerPositionNear", closestLocationName);
141 m_wUIHintText2.SetVisible(!closestLocationName.IsEmpty());
142 m_wUIHintText2.SetTextFormat(closeLocationAzimuth, closestLocationName);
146 protected int GetGridIndex(
int x,
int y)
154 SetEventMask(EntityEvent.INIT);
162 [
Attribute(
"#AR-MapLocationHint_PlayerPositionIslandName")]
165 [
Attribute(
desc:
"Description of given quad. Order: SW, S, SE, W, C, E, NW, N, NE",
params:
"MaxSize=9")]
166 protected ref array<LocalizedString> m_aQuadHints;
171 return m_sPlayerPositionHint;
176 if (!m_aQuadHints.IsIndexValid(
index))
179 return m_aQuadHints[
index];