@@ -97,14 +97,12 @@ protected virtual void ReinitializeProgressBars()
97
97
{
98
98
var clientId = progressTracker . Key ;
99
99
var progress = progressTracker . Value . Progress ;
100
- if ( clientId != NetworkManager . Singleton . LocalClientId )
100
+ if ( clientId != NetworkManager . Singleton . LocalClientId && m_ClientIdToProgressBarsIndex . ContainsKey ( clientId ) )
101
101
{
102
- if ( m_ClientIdToProgressBarsIndex . ContainsKey ( clientId ) )
103
- {
104
- progress . OnValueChanged -= ( value , newValue ) =>
105
- m_OtherPlayersProgressBars [ m_ClientIdToProgressBarsIndex [ clientId ] ] . value = newValue ;
106
- }
102
+ progress . OnValueChanged -= ( value , newValue ) =>
103
+ m_OtherPlayersProgressBars [ m_ClientIdToProgressBarsIndex [ clientId ] ] . value = newValue ;
107
104
}
105
+
108
106
}
109
107
// clear map
110
108
m_ClientIdToProgressBarsIndex . Clear ( ) ;
@@ -128,23 +126,21 @@ protected virtual void UpdateProgressBars(bool isInitializing)
128
126
{
129
127
var clientId = progressTracker . Key ;
130
128
var progress = progressTracker . Value . Progress ;
131
- if ( clientId != NetworkManager . Singleton . LocalClientId )
129
+ if ( clientId != NetworkManager . Singleton . LocalClientId && ! m_ClientIdToProgressBarsIndex . ContainsKey ( clientId ) )
132
130
{
133
- if ( ! m_ClientIdToProgressBarsIndex . ContainsKey ( clientId ) )
131
+ if ( m_ClientIdToProgressBarsIndex . Count < m_OtherPlayersProgressBars . Count )
132
+ {
133
+ m_ClientIdToProgressBarsIndex [ clientId ] = m_ClientIdToProgressBarsIndex . Count ;
134
+
135
+ // set progress bar to 0 if initializing, else set it to its last known value
136
+ m_OtherPlayersProgressBars [ m_ClientIdToProgressBarsIndex [ clientId ] ] . value = isInitializing ? 0 : progress . Value ;
137
+ progress . OnValueChanged += ( value , newValue ) =>
138
+ m_OtherPlayersProgressBars [ m_ClientIdToProgressBarsIndex [ clientId ] ] . value = newValue ;
139
+ m_OtherPlayersProgressBars [ m_ClientIdToProgressBarsIndex [ clientId ] ] . gameObject . SetActive ( true ) ;
140
+ }
141
+ else
134
142
{
135
- if ( m_ClientIdToProgressBarsIndex . Count < m_OtherPlayersProgressBars . Count )
136
- {
137
- m_ClientIdToProgressBarsIndex [ clientId ] = m_ClientIdToProgressBarsIndex . Count ;
138
- // set progress bar to 0 if initializing, else set it to its last known value
139
- m_OtherPlayersProgressBars [ m_ClientIdToProgressBarsIndex [ clientId ] ] . value = isInitializing ? 0 : progress . Value ;
140
- progress . OnValueChanged += ( value , newValue ) =>
141
- m_OtherPlayersProgressBars [ m_ClientIdToProgressBarsIndex [ clientId ] ] . value = newValue ;
142
- m_OtherPlayersProgressBars [ m_ClientIdToProgressBarsIndex [ clientId ] ] . gameObject . SetActive ( true ) ;
143
- }
144
- else
145
- {
146
- throw new Exception ( "There are not enough progress bars to track the progress of all the players." ) ;
147
- }
143
+ throw new Exception ( "There are not enough progress bars to track the progress of all the players." ) ;
148
144
}
149
145
}
150
146
}
0 commit comments