/// <summary>
        /// Returns a list of Track types that are associated with the given Track Group.
        /// </summary>
        /// <param name="trackGroup">The track group to be inspected</param>
        /// <returns>A list of track types that meet the genre criteria of the given track group.</returns>
        public static List <Type> GetAllowedTrackTypes(TrackGroup trackGroup)
        {
            // Get all the allowed Genres for this track group
            TimelineTrackGenre[] genres = new TimelineTrackGenre[0];

            TrackGroupAttribute[] tga = ReflectionHelper.GetCustomAttributes <TrackGroupAttribute>(trackGroup.GetType(), true);
            for (int i = 0; i < tga.Length; i++)
            {
                if (tga[i] != null)
                {
                    genres = tga[i].AllowedTrackGenres;
                    break;
                }
            }

            Type[]      subTypes          = DirectorRuntimeHelper.GetAllSubTypes(typeof(TimelineTrack));
            List <Type> allowedTrackTypes = new List <Type>();

            for (int i = 0; i < subTypes.Length; i++)
            {
                TimelineTrackAttribute[] customAttributes = ReflectionHelper.GetCustomAttributes <TimelineTrackAttribute>(subTypes[i], true);
                for (int j = 0; j < customAttributes.Length; j++)
                {
                    if (customAttributes[j] != null)
                    {
                        for (int k = 0; k < customAttributes[j].TrackGenres.Length; k++)
                        {
                            TimelineTrackGenre genre = customAttributes[j].TrackGenres[k];
                            for (int l = 0; l < genres.Length; l++)
                            {
                                if (genre == genres[l])
                                {
                                    allowedTrackTypes.Add(subTypes[i]);
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }

            return(allowedTrackTypes);
        }
Beispiel #2
0
        /// <summary>
        /// Returns a list of Track types that are associated with the given Track Group.
        /// </summary>
        /// <param name="trackGroup">The track group to be inspected</param>
        /// <returns>A list of track types that meet the genre criteria of the given track group.</returns>
        public static List <Type> GetAllowedTrackTypes(TrackGroup trackGroup)
        {
            // Get all the allowed Genres for this track group
            TimelineTrackGenre[] genres = new TimelineTrackGenre[0];
            MemberInfo           info   = trackGroup.GetType();

            foreach (TrackGroupAttribute attribute in info.GetCustomAttributes(typeof(TrackGroupAttribute), true))
            {
                if (attribute != null)
                {
                    genres = attribute.AllowedTrackGenres;
                    break;
                }
            }

            List <Type> allowedTrackTypes = new List <Type>();

            foreach (Type type in DirectorRuntimeHelper.GetAllSubTypes(typeof(TimelineTrack)))
            {
                foreach (TimelineTrackAttribute attribute in type.GetCustomAttributes(typeof(TimelineTrackAttribute), true))
                {
                    if (attribute != null)
                    {
                        foreach (TimelineTrackGenre genre in attribute.TrackGenres)
                        {
                            foreach (TimelineTrackGenre genre2 in genres)
                            {
                                if (genre == genre2)
                                {
                                    allowedTrackTypes.Add(type);
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }

            return(allowedTrackTypes);
        }
        /// <summary>
        /// Returns a list of Track types that are associated with the given Track Group.
        /// </summary>
        /// <param name="trackGroup">The track group to be inspected</param>
        /// <returns>A list of track types that meet the genre criteria of the given track group.</returns>
        public static List<Type> GetAllowedTrackTypes(TrackGroup trackGroup)
        {
            // Get all the allowed Genres for this track group
            TimelineTrackGenre[] genres = new TimelineTrackGenre[0];
            MemberInfo info = trackGroup.GetType();
            foreach (TrackGroupAttribute attribute in info.GetCustomAttributes(typeof(TrackGroupAttribute), true))
            {
                if (attribute != null)
                {
                    genres = attribute.AllowedTrackGenres;
                    break;
                }
            }

            List<Type> allowedTrackTypes = new List<Type>();
            foreach (Type type in DirectorRuntimeHelper.GetAllSubTypes(typeof(TimelineTrack)))
            {
                foreach (TimelineTrackAttribute attribute in type.GetCustomAttributes(typeof(TimelineTrackAttribute), true))
                {
                    if (attribute != null)
                    {
                        foreach (TimelineTrackGenre genre in attribute.TrackGenres)
                        {
                            foreach (TimelineTrackGenre genre2 in genres)
                            {
                                if (genre == genre2)
                                {
                                    allowedTrackTypes.Add(type);
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }

            return allowedTrackTypes;
        }
Beispiel #4
0
        /// <summary>
        /// Returns a list of Track types that are associated with the given Track Group.
        /// </summary>
        /// <param name="trackGroup">The track group to be inspected</param>
        /// <returns>A list of track types that meet the genre criteria of the given track group.</returns>
        public static List <Type> GetAllowedTrackTypes(TrackGroup trackGroup)
        {
            var         trackGroupType = trackGroup.GetType();
            List <Type> allowedTrackTypes;

            if (_DicAllowedTrackTypes.TryGetValue(trackGroupType, out allowedTrackTypes))
            {
                return(allowedTrackTypes);
            }
#if BakeReflection
            // Get all the allowed Genres for this track group
            TimelineTrackGenre[] genres = new TimelineTrackGenre[0];

            TrackGroupAttribute[] tga = ReflectionHelper.GetCustomAttributes <TrackGroupAttribute>(trackGroupType, true);
            for (int i = 0; i < tga.Length; i++)
            {
                if (tga[i] != null)
                {
                    genres = tga[i].AllowedTrackGenres;
                    break;
                }
            }

            Type[] subTypes = GetAllSubTypes(typeof(TimelineTrack));
            allowedTrackTypes = new List <Type>();
            for (int i = 0; i < subTypes.Length; i++)
            {
                TimelineTrackAttribute[] customAttributes;

                var subType = subTypes[i];
                List <TimelineTrackAttribute> cache = null;
                if (_CacheTLTAttribute.TryGetValue(subType, out cache))
                {
                    //Debug.Log("++++" + trackGroupType.Name);
                    customAttributes = cache.ToArray();
                }
                else
                {
                    //Debug.Log(trackGroupType.Name);
                    customAttributes = ReflectionHelper.GetCustomAttributes <TimelineTrackAttribute>(subType, true);
                    _CacheTLTAttribute.Add(subType, new List <TimelineTrackAttribute>(customAttributes));
                }

                for (int j = 0; j < customAttributes.Length; j++)
                {
                    if (customAttributes[j] != null)
                    {
                        for (int k = 0; k < customAttributes[j].TrackGenres.Length; k++)
                        {
                            TimelineTrackGenre genre = customAttributes[j].TrackGenres[k];
                            for (int l = 0; l < genres.Length; l++)
                            {
                                if (genre == genres[l])
                                {
                                    allowedTrackTypes.Add(subType);
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }

            _DicAllowedTrackTypes.Add(trackGroupType, allowedTrackTypes);
#endif
            return(allowedTrackTypes);
        }
Beispiel #5
0
 /// <summary>
 /// Attribute for Track Groups.
 /// </summary>
 /// <param name="label">The name of this track group.</param>
 /// <param name="TrackGenres">The Genre of this track.</param>
 /// <param name="AllowedItemGenres">The Genres allowed to be contained in this track.</param>
 public TimelineTrackAttribute(string label, TimelineTrackGenre TrackGenre, params TrackItemGenre[] AllowedItemGenres)
 {
     this.label = label;
     this.trackGenres.Add(TrackGenre);
     this.itemGenres.AddRange(AllowedItemGenres);
 }
Beispiel #6
0
        public static List <Type> GetAllowedTrackTypes(TrackGroup trackGroup)
        {
#if PROFILE_FILE
            Profiler.BeginSample("DirectorRuntimeHelper.GetAllowedTrackTypes");
#endif // PROFILE_FILE
            // Get all the allowed Genres for this track group
            var         t = trackGroup.GetType();
            List <Type> allowedTrackTypes = null;
            if (_allowedTrackTypes.TryGetValue(t, out allowedTrackTypes))
            {
#if PROFILE_FILE
                Profiler.EndSample();
#endif // PROFILE_FILE
                return(allowedTrackTypes);
            }

            TimelineTrackGenre[] genres = new TimelineTrackGenre[0];
            var list   = ReflectionHelper.GetCustomAttributes <TrackGroupAttribute>(t, true);
            var length = list.Length;
            for (var i = 0; i < length; i++)
            {
                var attribute = list[i];

                if (attribute != null)
                {
                    genres = attribute.AllowedTrackGenres;
                    break;
                }
            }

            allowedTrackTypes = new List <Type>();
            var typeList = DirectorRuntimeHelper.GetAllSubTypes(typeof(TimelineTrack));
            length = typeList.Length;
            var lengthGenres = genres.Length;
            for (var i = 0; i < length; i++)
            {
                var type    = typeList[i];
                var list2   = ReflectionHelper.GetCustomAttributes <TimelineTrackAttribute>(type, true);
                var length2 = list2.Length;
                for (var j = 0; j < length2; j++)
                {
                    var attribute = list2[j];
                    if (attribute != null)
                    {
                        var list3   = attribute.TrackGenres;
                        var length3 = list3.Length;
                        for (var k = 0; k < length3; k++)
                        {
                            for (var x = 0; x < lengthGenres; x++)
                            {
                                if (list3[k] == genres[x])
                                {
                                    allowedTrackTypes.Add(type);
                                    break;
                                }
                            }
                        }

                        break;
                    }
                }
            }

            _allowedTrackTypes[t] = allowedTrackTypes;
#if PROFILE_FILE
            Profiler.EndSample();
#endif // PROFILE_FILE

            return(allowedTrackTypes);
        }
Beispiel #7
0
        /// <summary>
        /// Returns a list of Track types that are associated with the given Track Group.
        /// </summary>
        /// <param name="trackGroup">The track group to be inspected</param>
        /// <returns>A list of track types that meet the genre criteria of the given track group.</returns>
        public static List <Type> GetAllowedTrackTypes(TrackGroup trackGroup)
        {
            // Get all the allowed Genres for this track group
            TimelineTrackGenre[] genres = new TimelineTrackGenre[0];
            MemberInfo           info   = trackGroup.GetType();
            {
                var __array1       = info.GetCustomAttributes(typeof(TrackGroupAttribute), true);
                var __arrayLength1 = __array1.Length;
                for (int __i1 = 0; __i1 < __arrayLength1; ++__i1)
                {
                    var attribute = (TrackGroupAttribute)__array1[__i1];
                    {
                        if (attribute != null)
                        {
                            genres = attribute.AllowedTrackGenres;
                            break;
                        }
                    }
                }
            }
            List <Type> allowedTrackTypes = new List <Type>();

            {
                var __array2       = DirectorRuntimeHelper.GetAllSubTypes(typeof(TimelineTrack));
                var __arrayLength2 = __array2.Length;
                for (int __i2 = 0; __i2 < __arrayLength2; ++__i2)
                {
                    var type = (Type)__array2[__i2];
                    {
                        {
                            var __array9       = type.GetCustomAttributes(typeof(TimelineTrackAttribute), true);
                            var __arrayLength9 = __array9.Length;
                            for (int __i9 = 0; __i9 < __arrayLength9; ++__i9)
                            {
                                var attribute = (TimelineTrackAttribute)__array9[__i9];
                                {
                                    if (attribute != null)
                                    {
                                        {
                                            // foreach(var genre in attribute.TrackGenres)
                                            var __enumerator15 = (attribute.TrackGenres).GetEnumerator();
                                            while (__enumerator15.MoveNext())
                                            {
                                                var genre = (TimelineTrackGenre)__enumerator15.Current;
                                                {
                                                    {
                                                        var __array18       = genres;
                                                        var __arrayLength18 = __array18.Length;
                                                        for (int __i18 = 0; __i18 < __arrayLength18; ++__i18)
                                                        {
                                                            var genre2 = (TimelineTrackGenre)__array18[__i18];
                                                            {
                                                                if (genre == genre2)
                                                                {
                                                                    allowedTrackTypes.Add(type);
                                                                    break;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(allowedTrackTypes);
        }