private void bindTrackGroupControls(CutsceneWrapper cutscene, List <SidebarControl> newSidebarControls, List <SidebarControl> removedSidebarControls, List <TrackItemControl> newTimelineControls, List <TrackItemControl> removedTimelineControls) { if (cutscene.HasChanged) { foreach (TrackGroupWrapper wrapper in cutscene.TrackGroups) { TrackGroupControl control = null; if (!this.trackGroupBinding.TryGetValue(wrapper, out control)) { Type type = typeof(TrackGroupControl); int num2 = 0x7fffffff; foreach (Type type2 in DirectorControlHelper.GetAllSubTypes(typeof(TrackGroupControl))) { Type c = null; foreach (CutsceneTrackGroupAttribute attribute in type2.GetCustomAttributes(typeof(CutsceneTrackGroupAttribute), true)) { if (attribute != null) { c = attribute.TrackGroupType; } } if (c == wrapper.Behaviour.GetType()) { type = type2; num2 = 0; break; } if (wrapper.Behaviour.GetType().IsSubclassOf(c)) { Type baseType = wrapper.Behaviour.GetType(); int num5 = 0; while ((baseType != null) && (baseType != c)) { baseType = baseType.BaseType; num5++; } if (num5 <= num2) { num2 = num5; type = type2; } } } control = (TrackGroupControl)Activator.CreateInstance(type); control.TrackGroup = wrapper; control.DirectorControl = this; control.Initialize(); control.SetExpandedFromEditorPrefs(); newSidebarControls.Add(control); this.trackGroupBinding.Add(wrapper, control); } } List <TrackGroupWrapper> list = new List <TrackGroupWrapper>(); foreach (TrackGroupWrapper wrapper2 in this.trackGroupBinding.Keys) { bool flag = false; foreach (TrackGroupWrapper wrapper3 in cutscene.TrackGroups) { if (wrapper2.Equals(wrapper3)) { flag = true; break; } } if (!flag) { removedSidebarControls.Add(this.trackGroupBinding[wrapper2]); list.Add(wrapper2); } } foreach (TrackGroupWrapper wrapper4 in list) { this.trackGroupBinding.Remove(wrapper4); } SortedDictionary <int, TrackGroupWrapper> dictionary = new SortedDictionary <int, TrackGroupWrapper>(); List <TrackGroupWrapper> list2 = new List <TrackGroupWrapper>(); foreach (TrackGroupWrapper wrapper5 in this.trackGroupBinding.Keys) { if ((wrapper5.Ordinal >= 0) && !dictionary.ContainsKey(wrapper5.Ordinal)) { dictionary.Add(wrapper5.Ordinal, wrapper5); } else { list2.Add(wrapper5); } } int num = 0; using (SortedDictionary <int, TrackGroupWrapper> .ValueCollection.Enumerator enumerator4 = dictionary.Values.GetEnumerator()) { while (enumerator4.MoveNext()) { enumerator4.Current.Ordinal = num; num++; } } using (List <TrackGroupWrapper> .Enumerator enumerator3 = list2.GetEnumerator()) { while (enumerator3.MoveNext()) { enumerator3.Current.Ordinal = num; num++; } } cutscene.HasChanged = false; } foreach (TrackGroupWrapper wrapper6 in this.trackGroupBinding.Keys) { this.trackGroupBinding[wrapper6].BindTrackControls(wrapper6, newSidebarControls, removedSidebarControls, newTimelineControls, removedTimelineControls); } }
private void bindTrackGroupControls(CutsceneWrapper cutscene, List <SidebarControl> newSidebarControls, List <SidebarControl> removedSidebarControls, List <TrackItemControl> newTimelineControls, List <TrackItemControl> removedTimelineControls) { if (cutscene.HasChanged) { foreach (TrackGroupWrapper current in cutscene.TrackGroups) { TrackGroupControl trackGroupControl = null; if (!trackGroupBinding.TryGetValue(current, out trackGroupControl)) { Type[] arg_5F_0 = DirectorControlHelper.GetAllSubTypes(typeof(TrackGroupControl)); Type type = typeof(TrackGroupControl); int num = 2147483647; Type[] array = arg_5F_0; for (int i = 0; i < array.Length; i++) { Type type2 = array[i]; Type type3 = null; object[] customAttributes = type2.GetCustomAttributes(typeof(CutsceneTrackGroupAttribute), true); for (int j = 0; j < customAttributes.Length; j++) { CutsceneTrackGroupAttribute cutsceneTrackGroupAttribute = (CutsceneTrackGroupAttribute)customAttributes[j]; if (cutsceneTrackGroupAttribute != null) { type3 = cutsceneTrackGroupAttribute.TrackGroupType; } } if (type3 == current.Behaviour.GetType()) { type = type2; break; } if (current.Behaviour.GetType().IsSubclassOf(type3)) { Type type4 = current.Behaviour.GetType(); int num2 = 0; while (type4 != null && type4 != type3) { type4 = type4.BaseType; num2++; } if (num2 <= num) { num = num2; type = type2; } } } trackGroupControl = (TrackGroupControl)Activator.CreateInstance(type); trackGroupControl.TrackGroup = current; trackGroupControl.DirectorControl = this; trackGroupControl.Initialize(); trackGroupControl.SetExpandedFromEditorPrefs(); newSidebarControls.Add(trackGroupControl); trackGroupBinding.Add(current, trackGroupControl); } } List <TrackGroupWrapper> list = new List <TrackGroupWrapper>(); foreach (TrackGroupWrapper current2 in this.trackGroupBinding.Keys) { bool flag = false; foreach (TrackGroupWrapper current3 in cutscene.TrackGroups) { if (current2.Equals(current3)) { flag = true; break; } } if (!flag) { removedSidebarControls.Add(trackGroupBinding[current2]); list.Add(current2); } } foreach (TrackGroupWrapper current4 in list) { trackGroupBinding.Remove(current4); } SortedDictionary <int, TrackGroupWrapper> sortedDictionary = new SortedDictionary <int, TrackGroupWrapper>(); List <TrackGroupWrapper> list2 = new List <TrackGroupWrapper>(); foreach (TrackGroupWrapper current5 in this.trackGroupBinding.Keys) { if (current5.Ordinal >= 0 && !sortedDictionary.ContainsKey(current5.Ordinal)) { sortedDictionary.Add(current5.Ordinal, current5); } else { list2.Add(current5); } } int num3 = 0; using (SortedDictionary <int, TrackGroupWrapper> .ValueCollection.Enumerator enumerator4 = sortedDictionary.Values.GetEnumerator()) { while (enumerator4.MoveNext()) { enumerator4.Current.Ordinal = num3; num3++; } } using (List <TrackGroupWrapper> .Enumerator enumerator3 = list2.GetEnumerator()) { while (enumerator3.MoveNext()) { enumerator3.Current.Ordinal = num3; num3++; } } cutscene.HasChanged = false; } foreach (var current6 in trackGroupBinding.Keys) { trackGroupBinding[current6].BindTrackControls(current6, newSidebarControls, removedSidebarControls, newTimelineControls, removedTimelineControls); } }