Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_SightsZoomFOVInfo.c
Go to the documentation of this file.
1
/*
2
Scripted fov info class basing fovs on given zoom info.
3
Variable zoom.
4
*/
5
6
class
SCR_SightsZoomFOVInfo
:
SCR_BaseVariableSightsFOVInfo
7
{
8
[
Attribute
(
"1"
,
UIWidgets
.Auto,
desc
:
"Initial zoom that can be static or scaled up"
,
params
:
"0.1 100 0.1"
)]
9
protected
float
m_fBaseZoom
;
10
11
[
Attribute
(
"0"
,
UIWidgets
.Auto,
desc
:
"Max zoom, smaller zoomMax than baseZoom will result in static zoom"
,
params
:
"0.1 100 0.1"
)]
12
protected
float
m_fZoomMax
;
13
14
[
Attribute
(
"0.5"
,
UIWidgets
.Slider,
desc
:
"Zoom step size, will automatically set step count"
,
params
:
"0.1 5 0.1"
)]
15
protected
float
m_fStepZoomSize
;
16
17
[
Attribute
(
"6.0"
,
UIWidgets
.Slider,
desc
:
"Interpolation speed."
,
params
:
"0 100 0.1"
)]
18
protected
float
m_fInterpolationSpeed
;
19
20
protected
ref array<float>
m_aFOVs
=
new
array<float>;
21
protected
int
m_iStepsCount
= 1;
22
24
protected
float
m_fCurrentFOV
;
25
27
protected
int
m_iCurrentIndex
= 0;
28
29
protected
ref
ScriptInvoker<float, float>
event_OnZoomChanged
;
30
31
//------------------------------------------------------------------------------------------------
33
override
int
GetCount
() {
return
m_aFOVs
.Count(); }
34
35
//------------------------------------------------------------------------------------------------
37
override
int
GetCurrentIndex
() {
return
m_iCurrentIndex
; }
38
39
//------------------------------------------------------------------------------------------------
44
override
void
SetIndex
(
int
index
)
45
{
46
m_iCurrentIndex
=
index
;
47
InvokeOnZoomChanged(
GetCurrentZoom
(),
m_aFOVs
[
m_iCurrentIndex
]);
48
}
49
50
//------------------------------------------------------------------------------------------------
51
protected
override
void
OnInit
(
IEntity
owner,
BaseSightsComponent
sights)
52
{
53
// Initialize to default (first available) value
54
if
(
GetCount
() > 0)
55
{
56
SetIndex
(0);
57
m_fCurrentFOV
=
m_aFOVs
[0];
58
}
59
else
60
{
61
m_fCurrentFOV
=
SCR_2DOpticsComponent
.
CalculateZoomFOV
(
m_fBaseZoom
);
62
}
63
}
64
65
//------------------------------------------------------------------------------------------------
72
protected
override
void
OnUpdate
(
IEntity
owner,
BaseSightsComponent
sights,
float
timeSlice)
73
{
74
if
(!
m_aFOVs
.IsIndexValid(
m_iCurrentIndex
))
75
return
;
76
77
float
target =
m_aFOVs
[
m_iCurrentIndex
];
78
79
float
t = timeSlice *
m_fInterpolationSpeed
;
80
if
(t > 1.0)
81
t = 1.0;
82
if
(t < 0.0)
83
t = 0.0;
84
85
m_fCurrentFOV
=
Math
.Lerp(
m_fCurrentFOV
, target, t);
86
}
87
88
//------------------------------------------------------------------------------------------------
93
protected
override
float
GetCurrentFOV
()
94
{
95
return
m_fCurrentFOV
;
96
}
97
98
//------------------------------------------------------------------------------------------------
100
array<float>
ZoomsToArray
()
101
{
102
array<float> zooms =
new
array<float>;
103
104
// Single zoom
105
if
(
m_fBaseZoom
==
m_fZoomMax
||
m_fBaseZoom
>
m_fZoomMax
)
106
{
107
zooms.Insert(
m_fBaseZoom
);
108
return
zooms;
109
}
110
111
// Count steps
112
int
count = (
m_fZoomMax
-
m_fBaseZoom
) /
m_fStepZoomSize
;
113
114
// Create variable zooms
115
for
(
int
i = 0; i <= count; i++)
116
{
117
float
zoom =
GetZoom
(i, count);
118
zooms.Insert(zoom);
119
}
120
121
m_iStepsCount
= zooms.Count();
122
return
zooms;
123
}
124
125
//------------------------------------------------------------------------------------------------
127
void
InsertFov
(
float
fov)
128
{
129
m_aFOVs
.Insert(fov);
130
}
131
132
//------------------------------------------------------------------------------------------------
133
int
GetStepsCount
()
134
{
135
return
m_iStepsCount
;
136
}
137
138
//------------------------------------------------------------------------------------------------
139
void
SetCurrentFov
(
float
fov)
140
{
141
m_fCurrentFOV
= fov;
142
}
143
144
//------------------------------------------------------------------------------------------------
145
protected
float
GetZoom
(
int
i,
int
count)
146
{
147
if
(i < 0)
148
i = 0;
149
150
return
m_fBaseZoom
+ i *
m_fStepZoomSize
;
151
}
152
153
//------------------------------------------------------------------------------------------------
154
float
GetCurrentZoom
()
155
{
156
// TODO just check this with Jakub Werner as whether its good or nicht,
157
// ich have to say that das ist nicht gut, das ist nicht gut Hans!
158
159
int
count =
m_aFOVs
.Count();
160
161
if
(count == 0)
162
return
m_fBaseZoom
;
163
164
return
GetZoom
(
m_iCurrentIndex
, count);
165
}
166
167
//------------------------------------------------------------------------------------------------
168
float
GetBaseZoom
()
169
{
170
int
count =
m_aFOVs
.Count();
171
if
(count > 0)
172
return
GetZoom
(0, count);
173
174
return
1.0;
175
}
176
177
//------------------------------------------------------------------------------------------------
184
override
float
GetBaseFOV
()
185
{
186
if
(!
m_aFOVs
.IsEmpty())
187
return
m_aFOVs
[0];
188
189
return
m_fCurrentFOV
;
190
}
191
192
//------------------------------------------------------------------------------------------------
194
override
bool
IsAdjusting
()
195
{
196
if
(!
m_aFOVs
.IsIndexValid(
m_iCurrentIndex
))
197
return
false
;
198
199
return
!
float
.AlmostEqual(
m_fCurrentFOV
,
m_aFOVs
[
m_iCurrentIndex
]);
200
}
201
202
void
ForceUpdate
(
IEntity
owner,
BaseSightsComponent
sights,
float
timeSlice)
203
{
204
OnUpdate
(owner, sights, timeSlice);
205
}
206
207
//------------------------------------------------------------------------------------------------
208
// Invoker API
209
//------------------------------------------------------------------------------------------------
210
211
//------------------------------------------------------------------------------------------------\
212
ScriptInvoker GetEventOnZoomChanged()
213
{
214
if
(!
event_OnZoomChanged
)
215
event_OnZoomChanged
=
new
ScriptInvoker
();
216
217
return
event_OnZoomChanged
;
218
}
219
220
//------------------------------------------------------------------------------------------------\
221
protected void InvokeOnZoomChanged(float zoom, float fov)
222
{
223
if
(
event_OnZoomChanged
)
224
event_OnZoomChanged
.Invoke(zoom, fov);
225
}
226
};
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition
SCR_DestructionSynchronizationComponent.c:17
OnUpdate
override void OnUpdate()
Definition
SCR_MapMarkerSquadLeader.c:333
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
params
category params
Definition
SCR_SpherePointGeneratorPreviewComponent.c:21
BaseSightsComponent
Definition
BaseSightsComponent.c:13
IEntity
Definition
IEntity.c:13
Math
Definition
Math.c:13
SCR_2DOpticsComponent
Definition
SCR_2DOpticsComponent.c:294
SCR_2DOpticsComponent::CalculateZoomFOV
static float CalculateZoomFOV(float magnification)
Return camera FOV for given magnification. Focus FOV is used as reference 1x magnification.
Definition
SCR_2DOpticsComponent.c:614
SCR_BaseVariableSightsFOVInfo
Definition
SCR_BaseVariableSightsFOVInfo.c:2
SCR_SightsZoomFOVInfo
Definition
SCR_SightsZoomFOVInfo.c:7
SCR_SightsZoomFOVInfo::OnUpdate
override void OnUpdate(IEntity owner, BaseSightsComponent sights, float timeSlice)
Definition
SCR_SightsZoomFOVInfo.c:72
SCR_SightsZoomFOVInfo::OnInit
override void OnInit(IEntity owner, BaseSightsComponent sights)
Definition
SCR_SightsZoomFOVInfo.c:51
SCR_SightsZoomFOVInfo::ZoomsToArray
array< float > ZoomsToArray()
Get array of each zoom based on min-max and steps in between.
Definition
SCR_SightsZoomFOVInfo.c:100
SCR_SightsZoomFOVInfo::m_fStepZoomSize
float m_fStepZoomSize
Definition
SCR_SightsZoomFOVInfo.c:15
SCR_SightsZoomFOVInfo::GetZoom
float GetZoom(int i, int count)
Definition
SCR_SightsZoomFOVInfo.c:145
SCR_SightsZoomFOVInfo::SetCurrentFov
void SetCurrentFov(float fov)
Definition
SCR_SightsZoomFOVInfo.c:139
SCR_SightsZoomFOVInfo::IsAdjusting
override bool IsAdjusting()
Returns true when current FOV of the optic does not match the target FOV.
Definition
SCR_SightsZoomFOVInfo.c:194
SCR_SightsZoomFOVInfo::ForceUpdate
void ForceUpdate(IEntity owner, BaseSightsComponent sights, float timeSlice)
Definition
SCR_SightsZoomFOVInfo.c:202
SCR_SightsZoomFOVInfo::m_fInterpolationSpeed
float m_fInterpolationSpeed
Definition
SCR_SightsZoomFOVInfo.c:18
SCR_SightsZoomFOVInfo::GetBaseZoom
float GetBaseZoom()
Definition
SCR_SightsZoomFOVInfo.c:168
SCR_SightsZoomFOVInfo::GetCurrentFOV
override float GetCurrentFOV()
Definition
SCR_SightsZoomFOVInfo.c:93
SCR_SightsZoomFOVInfo::m_iStepsCount
int m_iStepsCount
Definition
SCR_SightsZoomFOVInfo.c:21
SCR_SightsZoomFOVInfo::GetCurrentZoom
float GetCurrentZoom()
Definition
SCR_SightsZoomFOVInfo.c:154
SCR_SightsZoomFOVInfo::m_fCurrentFOV
float m_fCurrentFOV
Immediate field of view value.
Definition
SCR_SightsZoomFOVInfo.c:24
SCR_SightsZoomFOVInfo::SetIndex
override void SetIndex(int index)
Definition
SCR_SightsZoomFOVInfo.c:44
SCR_SightsZoomFOVInfo::GetBaseFOV
override float GetBaseFOV()
Definition
SCR_SightsZoomFOVInfo.c:184
SCR_SightsZoomFOVInfo::event_OnZoomChanged
ref ScriptInvoker< float, float > event_OnZoomChanged
Definition
SCR_SightsZoomFOVInfo.c:29
SCR_SightsZoomFOVInfo::InsertFov
void InsertFov(float fov)
Add new fov based on reticle range and zoom.
Definition
SCR_SightsZoomFOVInfo.c:127
SCR_SightsZoomFOVInfo::m_fBaseZoom
float m_fBaseZoom
Definition
SCR_SightsZoomFOVInfo.c:9
SCR_SightsZoomFOVInfo::GetStepsCount
int GetStepsCount()
Definition
SCR_SightsZoomFOVInfo.c:133
SCR_SightsZoomFOVInfo::GetCurrentIndex
override int GetCurrentIndex()
Returns currently selected element or -1 if none.
Definition
SCR_SightsZoomFOVInfo.c:37
SCR_SightsZoomFOVInfo::m_aFOVs
ref array< float > m_aFOVs
Definition
SCR_SightsZoomFOVInfo.c:20
SCR_SightsZoomFOVInfo::GetCount
override int GetCount()
Returns the number of available elements.
Definition
SCR_SightsZoomFOVInfo.c:33
SCR_SightsZoomFOVInfo::m_iCurrentIndex
int m_iCurrentIndex
Currently selected FOV or 0 (as base fov) if none.
Definition
SCR_SightsZoomFOVInfo.c:27
SCR_SightsZoomFOVInfo::m_fZoomMax
float m_fZoomMax
Definition
SCR_SightsZoomFOVInfo.c:12
UIWidgets
Definition
attributes.c:40
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
ScriptInvoker
ScriptInvokerBase< func > ScriptInvoker
Definition
tools.c:134
scripts
Game
Weapon
Sights
SightsFOVInfo
SCR_SightsZoomFOVInfo.c
Generated by
1.17.0