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_BallisticData.c
Go to the documentation of this file.
1
class
SCR_BallisticData
:
ScriptAndConfig
2
{
3
static
ref array<ref SCR_BallisticData> s_aBallistics;
4
static
bool
s_bWaitingForEndOfTheGame;
5
16
protected
ref array<ref array<float>>
m_aBallisticValues
;
17
protected
ResourceName
m_sProjectilePrefabName
;
18
protected
bool
m_bDirectFireMode
;
19
protected
int
m_iRangeStep
;
20
protected
float
m_fProjectileInitSpeedCoef
;
21
protected
ref
map<int, int>
m_mDistances
;
22
23
//------------------------------------------------------------------------------------------------
24
int
GetNumberOfEntries
()
25
{
26
if
(!
m_aBallisticValues
)
27
return
0;
28
29
return
m_aBallisticValues
.Count();
30
}
31
32
//------------------------------------------------------------------------------------------------
36
int
GetValues
(
int
id
, out array<float> values)
37
{
38
if
(!
m_aBallisticValues
.IsIndexValid(
id
))
39
return
0;
40
41
values =
m_aBallisticValues
[
id
];
42
return
values.Count();
43
}
44
45
46
//------------------------------------------------------------------------------------------------
50
void
SetValues
(
int
id
, notnull array<float> newValues)
51
{
52
if
(!
m_aBallisticValues
.IsIndexValid(
id
))
53
return
;
54
55
m_aBallisticValues
[
id
] = newValues;
56
}
57
58
//------------------------------------------------------------------------------------------------
63
array<float>
GetBallisticValuesForClosestRange
(
int
range, out
int
id
= -1)
64
{
65
if
(
m_iRangeStep
== 0 || !
m_aBallisticValues
||
m_aBallisticValues
.IsEmpty())
66
return
null;
67
68
range =
Math
.Round(range /
m_iRangeStep
) *
m_iRangeStep
;
69
if
(
m_mDistances
.Contains(range))
70
return
GetBallisticValuesForRange
(range,
id
);
71
72
if
(range <=
m_aBallisticValues
[0][0])
73
{
74
id
= 0;
75
return
m_aBallisticValues
[0];
76
}
77
78
id
=
m_aBallisticValues
.Count() - 1;
79
return
m_aBallisticValues
[
id
];
80
}
81
82
//------------------------------------------------------------------------------------------------
89
array<float>
GetBallisticValuesForClosestAngle
(
float
angle, out
int
id
= -1,
float
epsilon = 0.1,
float
epsilonStep = 2,
float
maxEpsilon = 1000)
90
{
91
if
(epsilon > maxEpsilon)
92
{
93
angle = -1;
94
id
= -1;
95
return
null;
96
}
97
98
foreach
(
int
i, array<float> entry :
m_aBallisticValues
)
99
{
100
if
(
float
.AlmostEqual(entry[1], angle, epsilon))
101
{
102
angle = entry[0];
103
id
= i;
104
return
entry;
105
}
106
}
107
108
return
GetBallisticValuesForClosestAngle
(angle,
id
, epsilon * epsilonStep, epsilonStep, maxEpsilon);
109
}
110
111
//------------------------------------------------------------------------------------------------
115
array<float>
GetBallisticValuesForRange
(
int
range, out
int
id
= -1)
116
{
117
if
(!
m_mDistances
.Contains(range))
118
return
null;
119
120
id
=
m_mDistances
.Get(range);
121
return
m_aBallisticValues
[
id
];
122
}
123
124
//------------------------------------------------------------------------------------------------
125
ResourceName
GetProjectileName
()
126
{
127
return
m_sProjectilePrefabName
;
128
}
129
130
//------------------------------------------------------------------------------------------------
131
int
GetRangeStep
()
132
{
133
return
m_iRangeStep
;
134
}
135
136
//------------------------------------------------------------------------------------------------
137
float
GetProjectileInitSpeedCoef
()
138
{
139
return
m_fProjectileInitSpeedCoef
;
140
}
141
142
//------------------------------------------------------------------------------------------------
143
bool
IsForDirectFireMode
()
144
{
145
return
m_bDirectFireMode
;
146
}
147
148
//------------------------------------------------------------------------------------------------
149
// constructor
154
void
SCR_BallisticData
(notnull array<ref array<float>> ballisticValues,
string
projectilePrefab,
bool
directFireMode,
int
rangeStep,
float
speedCoef)
155
{
156
m_aBallisticValues
= ballisticValues;
157
if
(!
m_aBallisticValues
&&
m_aBallisticValues
.IsEmpty())
158
return
;
159
160
m_mDistances
=
new
map<int, int>
();
161
foreach
(
int
i, array<float> ballistics :
m_aBallisticValues
)
162
{
163
m_mDistances
.Insert(ballistics[0], i);
164
}
165
166
m_sProjectilePrefabName
= projectilePrefab;
167
m_bDirectFireMode
= directFireMode;
168
m_iRangeStep
= rangeStep;
169
m_fProjectileInitSpeedCoef
= speedCoef;
170
SubscribeToGameEndEvent
();
171
}
172
173
//------------------------------------------------------------------------------------------------
174
static
void
SubscribeToGameEndEvent
()
175
{
176
if
(s_bWaitingForEndOfTheGame)
177
return
;
178
179
SCR_BaseGameMode
gameMode =
SCR_BaseGameMode
.Cast(
GetGame
().
GetGameMode
());
180
if
(!gameMode)
181
return
;
182
183
s_bWaitingForEndOfTheGame =
true
;
184
gameMode.
GetOnGameEnd
().Insert(
ReleaseData
);
185
}
186
187
//------------------------------------------------------------------------------------------------
189
protected
static
void
ReleaseData
()
190
{
191
s_aBallistics = null;
192
s_bWaitingForEndOfTheGame =
false
;
193
SCR_BaseGameMode
gameMode =
SCR_BaseGameMode
.Cast(
GetGame
().
GetGameMode
());
194
gameMode.
GetOnGameEnd
().Remove(
ReleaseData
);
195
}
196
}
id
AddonBuildInfoTool id
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition
SCR_BaseGameModeComponent.c:15
Math
Definition
Math.c:13
ResourceName
Definition
ResourceName.c:13
SCR_BallisticData::m_bDirectFireMode
bool m_bDirectFireMode
Definition
SCR_BallisticData.c:18
SCR_BallisticData::GetProjectileInitSpeedCoef
float GetProjectileInitSpeedCoef()
Definition
SCR_BallisticData.c:137
SCR_BallisticData::GetNumberOfEntries
int GetNumberOfEntries()
Definition
SCR_BallisticData.c:24
SCR_BallisticData::m_mDistances
ref map< int, int > m_mDistances
Definition
SCR_BallisticData.c:21
SCR_BallisticData::GetBallisticValuesForClosestAngle
array< float > GetBallisticValuesForClosestAngle(float angle, out int id=-1, float epsilon=0.1, float epsilonStep=2, float maxEpsilon=1000)
Definition
SCR_BallisticData.c:89
SCR_BallisticData::ReleaseData
static void ReleaseData()
Clears static data to ensure that it doesnt persist over multiple sessions, and thus doesnt grow unex...
Definition
SCR_BallisticData.c:189
SCR_BallisticData::GetRangeStep
int GetRangeStep()
Definition
SCR_BallisticData.c:131
SCR_BallisticData::GetValues
int GetValues(int id, out array< float > values)
Definition
SCR_BallisticData.c:36
SCR_BallisticData::m_fProjectileInitSpeedCoef
float m_fProjectileInitSpeedCoef
Definition
SCR_BallisticData.c:20
SCR_BallisticData::GetProjectileName
ResourceName GetProjectileName()
Definition
SCR_BallisticData.c:125
SCR_BallisticData::m_iRangeStep
int m_iRangeStep
Definition
SCR_BallisticData.c:19
SCR_BallisticData::IsForDirectFireMode
bool IsForDirectFireMode()
Definition
SCR_BallisticData.c:143
SCR_BallisticData::m_sProjectilePrefabName
ResourceName m_sProjectilePrefabName
Definition
SCR_BallisticData.c:17
SCR_BallisticData::SCR_BallisticData
void SCR_BallisticData(notnull array< ref array< float > > ballisticValues, string projectilePrefab, bool directFireMode, int rangeStep, float speedCoef)
Definition
SCR_BallisticData.c:154
SCR_BallisticData::m_aBallisticValues
ref array< ref array< float > > m_aBallisticValues
Definition
SCR_BallisticData.c:16
SCR_BallisticData::SetValues
void SetValues(int id, notnull array< float > newValues)
Definition
SCR_BallisticData.c:50
SCR_BallisticData::SubscribeToGameEndEvent
static void SubscribeToGameEndEvent()
Definition
SCR_BallisticData.c:174
SCR_BallisticData::GetBallisticValuesForRange
array< float > GetBallisticValuesForRange(int range, out int id=-1)
Definition
SCR_BallisticData.c:115
SCR_BallisticData::GetBallisticValuesForClosestRange
array< float > GetBallisticValuesForClosestRange(int range, out int id=-1)
Definition
SCR_BallisticData.c:63
SCR_BaseGameMode
Definition
SCR_BaseGameMode.c:139
SCR_BaseGameMode::GetOnGameEnd
ScriptInvoker GetOnGameEnd()
Definition
SCR_BaseGameMode.c:589
ScriptAndConfig
Definition
Types.c:124
map
Definition
Types.c:486
scripts
Game
Components
Gadgets
Configs
SCR_BallisticData.c
Generated by
1.17.0