Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AdjustSpeedManualCameraComponent.c
Go to the documentation of this file.
1
2
4[BaseContainerProps(), SCR_BaseManualCameraComponentTitle()]
6{
7 [Attribute("0.1")]
8 protected float m_fMinMultiplier;
9
10 [Attribute("16")]
11 protected float m_fMaxMultiplier;
12
13 [Attribute(params: "layout")]
15
16 [Attribute("3")]
17 protected float m_fLayoutDuration;
18
19 protected float m_fMultiplier = 1;
21 protected float m_fWidgetAlpha;
23
24 //------------------------------------------------------------------------------------------------
31
32 //------------------------------------------------------------------------------------------------
33 protected void OnInputDeviceIsGamepad(bool isGamepad)
34 {
35 m_fMultiplier = 1;
36 m_OnSpeedChange.Invoke(m_fMultiplier, false);
37 m_Widget.SetVisible(false);
38 }
39
40 //------------------------------------------------------------------------------------------------
41 protected void ManualCameraSpeedReset(float value, EActionTrigger trigger)
42 {
43 if (!IsEnabled() || !(GetCameraEntity().GetCameraParam().flag & EManualCameraFlag.ROTATE)) return;
44
45 m_fMultiplier = 1;
46 m_OnSpeedChange.Invoke(m_fMultiplier, true);
48 }
49
50 //------------------------------------------------------------------------------------------------
51 protected void UpdateWidget()
52 {
53 if (!m_Widget) return;
54
55
56 // if min value is very low, e.g. 0.001, then the hardcoded decimal value will not display all data,
57 // so we dynamically adjust the displayed precision as we go below 1.0, based on min value
58 int dec = 10;
59 if (m_fMinMultiplier > 0 && m_fMultiplier < 1.0)
60 dec = Math.Round(1.0 / Math.Clamp(m_fMinMultiplier, 0.0, 1.0));
61
62 m_Widget.SetTextFormat("#AR-ValueUnit_Short_Multiplier", Math.Round(m_fMultiplier * dec) / dec);
63 m_Widget.SetVisible(true);
65 }
66
67 //------------------------------------------------------------------------------------------------
68 protected void FadeOutWidget(float timeSlice)
69 {
70 if (!m_Widget || !m_Widget.IsVisible()) return;
71
72 m_fWidgetAlpha -= timeSlice;
73 if (m_fWidgetAlpha > 0)
74 {
75 m_Widget.SetOpacity(Math.Clamp(m_fWidgetAlpha, 0, 1));
76 }
77 else
78 {
79 m_Widget.SetVisible(false);
80 }
81 }
82
83 //------------------------------------------------------------------------------------------------
85 {
86 data.m_aValues = {m_fMultiplier};
87 }
88
89 //------------------------------------------------------------------------------------------------
91 {
92 if (data.m_aValues && !data.m_aValues.IsEmpty())
93 {
94 m_fMultiplier = data.m_aValues[0];
95 m_OnSpeedChange.Invoke(m_fMultiplier, true);
96 }
97 }
98
99 //------------------------------------------------------------------------------------------------
101 {
102 if (!param.isManualInputEnabled)
103 {
104 if (m_Widget)
105 m_Widget.SetVisible(false);
106
107 return;
108 }
109
110 //--- Adjust
111 if (param.flag & EManualCameraFlag.ROTATE)
112 {
113 float inputValue = GetInputManager().GetActionValue("ManualCameraSpeedAdjust");
114 if (inputValue != 0)
115 {
116 inputValue = Math.Clamp(1 + inputValue * param.timeSlice, 0.5, 2);
118 m_OnSpeedChange.Invoke(m_fMultiplier, true);
119 UpdateWidget();
120 }
121 }
122
123 //--- Apply
124 param.multiplier *= m_fMultiplier;
125
126 //--- Visualize
128 }
129
130 //------------------------------------------------------------------------------------------------
131 override bool EOnCameraInit()
132 {
133 if (m_fMinMultiplier > 1 || m_fMaxMultiplier < 1)
134 {
135 Print("Value range in SCR_AdjustSpeedManualCameraComponent must contain 1!", LogLevel.ERROR);
136 }
137 GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
138
139 GetInputManager().AddActionListener("ManualCameraSpeedReset", EActionTrigger.DOWN, ManualCameraSpeedReset);
140
141 m_Widget = TextWidget.Cast(GetCameraEntity().CreateCameraWidget(m_Layout, false));
142 return true;
143 }
144
145 //------------------------------------------------------------------------------------------------
146 override void EOnCameraExit()
147 {
148 GetGame().OnInputDeviceIsGamepadInvoker().Remove(OnInputDeviceIsGamepad);
149
150 GetInputManager().RemoveActionListener("ManualCameraSpeedReset", EActionTrigger.DOWN, ManualCameraSpeedReset);
151
152 if (m_Widget) m_Widget.RemoveFromHierarchy();
153 }
154}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Get all prefabs that have the spawner data
Definition Math.c:13
Adjusting speed at small increments for manual camera.
override void EOnCameraSave(SCR_ManualCameraComponentSave data)
override void EOnCameraLoad(SCR_ManualCameraComponentSave data)
override void EOnCameraFrame(SCR_ManualCameraParam param)
void ManualCameraSpeedReset(float value, EActionTrigger trigger)
Parent class from which all SCR_ManualCamera components inherit.
Parameter for carrying information between individual camera components.
float timeSlice
Frame time slice.
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
EActionTrigger
EManualCameraFlag
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134