3 [
Attribute(
"#AR-Endscreen_RestartTimer_Format-UC",
desc:
"Restart timer format %1 is the time")]
6 [
Attribute(
desc:
"Widget name of restart timer text. Leave empty to take root as the TextWidget")]
7 protected string m_sRestartTimerName;
10 protected bool m_bEnableCountDownSfx;
12 [
Attribute(
"1",
desc:
"Start timer on init, note that it will be hidden if the game has not ended or it is not set up correctly")]
13 protected bool m_bStartOnInit;
16 protected float m_fAutoReloadDelay = -1;
17 protected WorldTimestamp m_GameEndTimeStamp =
null;
18 protected int m_iPreviousRestartTime;
22 protected TextWidget m_wRestartTimer;
25 protected const int UPDATE_TIME = 100;
34 return m_fAutoReloadDelay > 0;
40 if (!m_sRestartTimerName.IsEmpty())
41 m_wRestartTimer = TextWidget.Cast(
m_wRoot.FindAnyWidget(m_sRestartTimerName));
43 m_wRestartTimer = TextWidget.Cast(
m_wRoot);
56 m_fAutoReloadDelay = gameMode.GetAutoReloadDelay();
57 m_GameEndTimeStamp = gameMode.GetGameEndTimeStamp();
63 void StartTimer(
bool checkIfValid =
true)
65 if (checkIfValid && !IsValid())
73 protected void UpdateTimer()
75 if (!
m_World || !m_wRestartTimer)
79 OnTimeUpdate(Math.Clamp(m_fAutoReloadDelay - ((
m_World.GetLocalTimestamp().DiffMilliseconds(m_GameEndTimeStamp)) * 0.001), 0,
float.MAX));
83 protected void OnTimeUpdate(
float currentRestartTimer)
86 if ((
int)currentRestartTimer == m_iPreviousRestartTime)
90 m_iPreviousRestartTime = currentRestartTimer;
94 if (currentRestartTimer < 60)
101 if (m_bEnableCountDownSfx)
103 if ((
int)currentRestartTimer > 0)
117 override void HandlerAttached(Widget w)
119 super.HandlerAttached(w);
128 else if (m_bStartOnInit)
133 override void HandlerDeattached(Widget w)
135 super.HandlerDeattached(w);
137 if (m_fAutoReloadDelay <= 0)
140 GetGame().GetCallqueue().Remove(UpdateTimer);