Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_RestrictionZoneWarningHUDComponent.c
Go to the documentation of this file.
2{
3 [Attribute("Holds array of warning info's to display the proper warning visuals.")]
4 protected ref array<ref SCR_RestrictionZoneWarningInfo> m_aWarningUIInfos; //~ Add new entries in SCR_HUDManagerComponent on PlayerController
5
6 [Attribute("Icon")]
7 protected string m_sIconWidgetName;
8
9 [Attribute("Warning")]
10 protected string m_sWarningWidgetName;
11
12 [Attribute("Explanation")]
13 protected string m_sExplanationWidgetName;
14
15 [Attribute("WarningZoneDistanceVisuals")]
17
18 [Attribute("WarningVisualsHolder")]
20
21 [Attribute("0.05", desc: "If zone is active how fast does the zone visuals update depending on the distance? In seconds.")]
23
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")]
26
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")]
29
30 [Attribute("0.4", desc: "The minimum opacity of the warning text", uiwidget: UIWidgets.Slider, params: "0 1 0.00001")]
32
35
37
39 protected float m_fWarningRadiusSq;
40 protected float m_fZoneMinusWarningSq;
41
42
48 void ShowZoneWarning(bool show, ERestrictionZoneWarningType warningType, vector zoneCenter, float warningRadiusSq, float zoneRadiusSq, float speed = UIConstants.FADE_RATE_DEFAULT)
49 {
50 if (!show)
51 {
52 if (m_bShown)
53 GetGame().GetCallqueue().Remove(UpdateVisualWarning);
54
55 Show(false, speed);
56 return;
57 }
58
59 m_vZoneCenter = zoneCenter;
60 m_fWarningRadiusSq = warningRadiusSq;
61 m_fZoneMinusWarningSq = zoneRadiusSq - warningRadiusSq;
62
63 if (m_iCurrentDisplayedWarning != warningType)
64 {
66 {
67 if (warningInfo.m_iWarningType == warningType)
68 {
69 if (warningInfo.m_UIInfo)
70 {
71 warningInfo.m_UIInfo.SetIconTo(ImageWidget.Cast(m_wRoot.FindAnyWidget(m_sIconWidgetName)));
72 warningInfo.m_UIInfo.SetNameTo(TextWidget.Cast(m_wRoot.FindAnyWidget(m_sWarningWidgetName)));
73 warningInfo.m_UIInfo.SetDescriptionTo(TextWidget.Cast(m_wRoot.FindAnyWidget(m_sExplanationWidgetName)));
74 }
75 break;
76 }
77 }
78 }
79
80 m_iCurrentDisplayedWarning = warningType;
81
82 if (!m_bShown)
83 GetGame().GetCallqueue().CallLater(UpdateVisualWarning, m_fWarningVisualsUpdateTime * 1000, true);
84
85 Show(true, speed);
86
87 }
88
89 protected void UpdateVisualWarning()
90 {
92 vector playerPosition = playerEntity.GetOrigin();
93
94 //~ Calculate opacity Strenght depending on distance
95 float opacityCalc = ((vector.DistanceSqXZ(playerPosition, m_vZoneCenter) - m_fWarningRadiusSq) / m_fZoneMinusWarningSq) + m_fMinWarningDistanceVisualsOpacity;
97
98 float ratio = 0;
99 CameraManager cameraManager = GetGame().GetCameraManager();
100 if (cameraManager)
101 {
102 CameraBase camera = cameraManager.CurrentCamera();
103 if (camera)
104 {
105 //~ Calculate opacity multiplier depending on where the player is looking (Looking towards center == less opacity)
106 vector cameraTransform[4];
107 camera.GetWorldTransform(cameraTransform);
108
109 //~ Grab the ratio between zone and center. Looking at zone == 1 and looking fully away from zone == -1
110 ratio = vector.DotXZ((m_vZoneCenter - playerPosition).Normalized(), cameraTransform[2]);
111 }
112 }
113
114 //~ If looking less the 180 degrees towards the center start reducing the opacity using a multiplier
115 float opacityLookDirectionMultiplier = 1;
116 if (ratio > 0)
117 opacityLookDirectionMultiplier = 1 - ratio;
118
119 //~ Set final Opacity
120 m_WarningZoneDistanceVisuals.SetOpacity(opacity * opacityLookDirectionMultiplier);
121
122 //~ Warning visuals opacity
123 if (opacityLookDirectionMultiplier > m_fWarningVisualsMinOpacity)
124 m_WarningVisualsHolder.SetOpacity(opacityLookDirectionMultiplier);
125 else
127 }
128
129
130 override event void OnStartDraw(IEntity owner)
131 {
132 super.OnStartDraw(owner);
133
134 if (!m_wRoot)
135 return;
136
138 {
140 {
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);
143 }
144
147
149 m_WarningZoneDistanceVisuals.SetOpacity(0);
150 else
151 Print("'SCR_RestrictionZoneWarningHUDComponent' could not find m_WarningZoneDistanceVisuals. This will break the zone restriction warning!", LogLevel.ERROR);
152
154 m_WarningVisualsHolder.SetOpacity(0);
155 else
156 Print("'SCR_RestrictionZoneWarningHUDComponent' could not find m_WarningVisualsHolder. This will break the zone restriction warning!", LogLevel.ERROR);
157 }
158 }
159
160
162 {
163 if (m_bShown)
164 GetGame().GetCallqueue().Remove(UpdateVisualWarning);
165 }
166};
167
173{
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))]
175 ERestrictionZoneWarningType m_iWarningType;
176
177 [Attribute(desc: "UI info to dictate what to display in warning")]
178 ref SCR_UIInfo m_UIInfo;
179}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
class SCR_CampaignHintStorage SCR_BaseContainerCustomTitleEnum(EHint, "m_eHintId")
Widget m_wRoot
bool m_bShown
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external vector GetOrigin()
Definition Math.c:13
static IEntity GetLocalControlledEntity()
ref array< ref SCR_RestrictionZoneWarningInfo > m_aWarningUIInfos
void ShowZoneWarning(bool show, ERestrictionZoneWarningType warningType, vector zoneCenter, float warningRadiusSq, float zoneRadiusSq, float speed=UIConstants.FADE_RATE_DEFAULT)
override void Show()
Definition gameLib.c:262
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute