Esempio n. 1
0
        /// <summary>
        /// Gets all available types, custom and vanilla for a given typename
        /// </summary>
        /// <param name="typename"></param>
        /// <returns></returns>
        public static IEnumerable <Type> GetAvailableTypes(string typename)
        {
            var availableTypes = new List <Type>();

            if (AssemblyDictionary.TypeExists(typename))
            {
                availableTypes.Add(AssemblyDictionary.GetTypeByName(typename));
                var subclasses = AssemblyDictionary.GetSubClassesOf(AssemblyDictionary.GetTypeByName(typename));
                availableTypes.AddRange(subclasses);

                // check if subclasses exist in custom assemblies
                var ssubclasses = CR2WManager.GetSubClassesOf(AssemblyDictionary.GetTypeByName(typename));
                availableTypes.AddRange(ssubclasses);
            }
            else if (CR2WManager.TypeExists(typename))
            {
                availableTypes.Add(CR2WManager.GetTypeByName(typename));
                var subclasses = CR2WManager.GetSubClassesOf(CR2WManager.GetTypeByName(typename));
                availableTypes.AddRange(subclasses);

                // check if subclasses exist in main assembly
                var ssubclasses = AssemblyDictionary.GetSubClassesOf(CR2WManager.GetTypeByName(typename));
                availableTypes.AddRange(ssubclasses);
            }
            else
            {
                //MainController.LogString(
                //    "No such type exists. Make sure you have all custom types in a .ws file inside the modproject.",
                //    Logtype.Error);
                return(null);
            }

            return(availableTypes.Distinct());
        }
Esempio n. 2
0
        public IEnumerable <ICR2WExport> GetReferenceChunks()
        {
            var refType = AssemblyDictionary.GetTypeByName(ReferenceType);
            var types   = AssemblyDictionary.GetSubClassesOf(refType)
                          .Select(_ => _.Name).ToList();

            return(Cr2wFile.Chunks.Where(cr2WExport => types.Contains(cr2WExport.REDType)).ToList());
        }