Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SimplePreload.c
Go to the documentation of this file.
2 {
3  static const int PRELOAD_FRAME_TIME_MS = 100;
4  static const int MIN_DURATION_MS = 1000;
5  ref LoadingAnim m_LoadingAnim;
6  vector m_Position;
7  float m_fDuration;
8  int m_iMaxDuration;
9 
10  void SimplePreload()
11  {
12  Print("SimplePreload: preload started.", LogLevel.VERBOSE);
13  }
14 
15  void ~SimplePreload()
16  {
17  if (m_LoadingAnim)
18  m_LoadingAnim.Hide();
19  Print("SimplePreload: preload finished (took: " + Math.Round(m_fDuration) + "s).", LogLevel.VERBOSE);
20  }
21 
22  bool Update(float timeSlice)
23  {
24  m_fDuration += timeSlice;
25 
26  if (g_Game.IsPreloadFinished() && (m_fDuration >= (MIN_DURATION_MS * 0.001)))
27  {
28  return true;
29  }
30 
31  if (m_LoadingAnim)
32  {
33  float progress = Math.Min(m_fDuration / MIN_DURATION_MS * 0.001, 1.0);
34  m_LoadingAnim.Update(timeSlice, progress, progress);
35  }
36  return false;
37  }
38 
39  static SimplePreload Preload(vector position, float radius = 500, int max_duration_ms = 20000)
40  {
41  if (g_Game.BeginPreload(g_Game.GetWorld(), position, radius, max_duration_ms / 1000))
42  {
43  // there is a lot of resoruces to be loaded, show loading anim
44  SimplePreload preload = new SimplePreload();
45  preload.m_LoadingAnim = g_Game.CreateLoadingAnim(g_Game.GetWorkspace());
46  preload.m_LoadingAnim.Show();
47  preload.m_iMaxDuration = max_duration_ms;
48  preload.m_Position = position;
49  return preload;
50  }
51 
52  return null;
53  }
54 };
m_fDuration
float m_fDuration
Definition: SendGoalMessage.c:437
SimplePreload
Definition: SimplePreload.c:1
position
vector position
Definition: SCR_DestructibleTreeV2.c:30