3 [
Attribute(
"Holds array of warning info's to display the proper warning visuals.")]
4 protected ref array<ref SCR_RestrictionZoneWarningInfo> m_aWarningUIInfos;
7 protected string m_sIconWidgetName;
10 protected string m_sWarningWidgetName;
13 protected string m_sExplanationWidgetName;
16 protected string m_sWarningZoneDistanceVisualsName;
19 protected string m_sWarningVisualsHolderName;
21 [
Attribute(
"0.05",
desc:
"If zone is active how fast does the zone visuals update depending on the distance? In seconds.")]
22 protected float m_fWarningVisualsUpdateTime;
24 [
Attribute(
"0",
desc:
"Min waning visuals opacity. Opacity becomes stronger when moving closer to edge of the zone.", uiwidget: UIWidgets.Slider,
params:
"0 1 0.00001")]
25 protected float m_fMinWarningDistanceVisualsOpacity;
27 [
Attribute(
"1",
desc:
"Max waning visuals opacity. Opacity becomes stronger when moving closer to edge of the zone.", uiwidget: UIWidgets.Slider,
params:
"0 1 0.00001")]
28 protected float m_fMaxWarningDistanceVisualsOpacity;
30 [
Attribute(
"0.4",
desc:
"The minimum opacity of the warning text", uiwidget: UIWidgets.Slider,
params:
"0 1 0.00001")]
31 protected float m_fWarningVisualsMinOpacity;
33 protected Widget m_WarningZoneDistanceVisuals;
34 protected Widget m_WarningVisualsHolder;
38 protected vector m_vZoneCenter;
39 protected float m_fWarningRadiusSq;
40 protected float m_fZoneMinusWarningSq;
53 GetGame().GetCallqueue().Remove(UpdateVisualWarning);
59 m_vZoneCenter = zoneCenter;
60 m_fWarningRadiusSq = warningRadiusSq;
61 m_fZoneMinusWarningSq = zoneRadiusSq - warningRadiusSq;
63 if (m_iCurrentDisplayedWarning != warningType)
67 if (warningInfo.m_iWarningType == warningType)
69 if (warningInfo.m_UIInfo)
72 warningInfo.m_UIInfo.SetNameTo(TextWidget.Cast(
m_wRoot.FindAnyWidget(m_sWarningWidgetName)));
73 warningInfo.m_UIInfo.SetDescriptionTo(TextWidget.Cast(
m_wRoot.FindAnyWidget(m_sExplanationWidgetName)));
80 m_iCurrentDisplayedWarning = warningType;
83 GetGame().GetCallqueue().CallLater(UpdateVisualWarning, m_fWarningVisualsUpdateTime * 1000,
true);
89 protected void UpdateVisualWarning()
92 vector playerPosition = playerEntity.GetOrigin();
95 float opacityCalc = ((vector.DistanceSqXZ(playerPosition, m_vZoneCenter) - m_fWarningRadiusSq) / m_fZoneMinusWarningSq) + m_fMinWarningDistanceVisualsOpacity;
96 float opacity = Math.Clamp(opacityCalc, m_fMinWarningDistanceVisualsOpacity, m_fMaxWarningDistanceVisualsOpacity);
99 CameraManager cameraManager =
GetGame().GetCameraManager();
102 CameraBase camera = cameraManager.CurrentCamera();
106 vector cameraTransform[4];
107 camera.GetWorldTransform(cameraTransform);
110 ratio = vector.DotXZ((m_vZoneCenter - playerPosition).Normalized(), cameraTransform[2]);
115 float opacityLookDirectionMultiplier = 1;
117 opacityLookDirectionMultiplier = 1 - ratio;
120 m_WarningZoneDistanceVisuals.SetOpacity(opacity * opacityLookDirectionMultiplier);
123 if (opacityLookDirectionMultiplier > m_fWarningVisualsMinOpacity)
124 m_WarningVisualsHolder.SetOpacity(opacityLookDirectionMultiplier);
126 m_WarningVisualsHolder.SetOpacity(m_fWarningVisualsMinOpacity);
130 override event void OnStartDraw(IEntity owner)
132 super.OnStartDraw(owner);
137 if (!m_WarningZoneDistanceVisuals)
139 if (m_fMinWarningDistanceVisualsOpacity > m_fMaxWarningDistanceVisualsOpacity)
141 Print(
"'SCR_RestrictionZoneWarningHUDComponent' m_fMinWarningDistanceVisualsOpacity is greater then m_fMaxWarningDistanceVisualsOpacity! This should never be greater then max and is set the same.", LogLevel.WARNING);
142 m_fMinWarningDistanceVisualsOpacity = m_fMaxWarningDistanceVisualsOpacity;
145 m_WarningZoneDistanceVisuals =
m_wRoot.FindAnyWidget(m_sWarningZoneDistanceVisualsName);
146 m_WarningVisualsHolder =
m_wRoot.FindAnyWidget(m_sWarningVisualsHolderName);
148 if (m_WarningZoneDistanceVisuals)
149 m_WarningZoneDistanceVisuals.SetOpacity(0);
151 Print(
"'SCR_RestrictionZoneWarningHUDComponent' could not find m_WarningZoneDistanceVisuals. This will break the zone restriction warning!", LogLevel.ERROR);
153 if (m_WarningVisualsHolder)
154 m_WarningVisualsHolder.SetOpacity(0);
156 Print(
"'SCR_RestrictionZoneWarningHUDComponent' could not find m_WarningVisualsHolder. This will break the zone restriction warning!", LogLevel.ERROR);
164 GetGame().GetCallqueue().Remove(UpdateVisualWarning);
174 [
Attribute(
"0",
desc:
"Which warning UIinfo needs to be shown on the screen as defined in 'SCR_RestrictionZoneWarningHUDComponent'", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(
ERestrictionZoneWarningType))]
177 [
Attribute(
desc:
"UI info to dictate what to display in warning")]