Example #1
0
 public BlueprintDataProvider()
 {
     _blueprintNames = BinaryBlueprintInspector
                       .FindAllBlueprints()
                       .Select(b => b.Deserialize().name)
                       .ToArray();
 }
        public static void Generate()
        {
            checkCanGenerate();

            Debug.Log("Generating...");

            var codeGenerators     = GetCodeGenerators();
            var codeGeneratorNames = codeGenerators.Select(cg => cg.Name).ToArray();
            var config             = new CodeGeneratorConfig(EntitasPreferences.LoadConfig(), codeGeneratorNames);

            var enabledCodeGeneratorNames = config.enabledCodeGenerators;
            var enabledCodeGenerators     = codeGenerators
                                            .Where(type => enabledCodeGeneratorNames.Contains(type.Name))
                                            .Select(type => (ICodeGenerator)Activator.CreateInstance(type))
                                            .ToArray();

            var blueprintNames = BinaryBlueprintInspector.FindAllBlueprints()
                                 .Select(b => b.Deserialize().name)
                                 .ToArray();

            var assembly       = Assembly.GetAssembly(typeof(Entity));
            var generatedFiles = TypeReflectionCodeGenerator.Generate(assembly, config.pools,
                                                                      blueprintNames, config.generatedFolderPath, enabledCodeGenerators);

            foreach (var file in generatedFiles)
            {
                Debug.Log(file.generatorName + ": " + file.fileName);
            }

            var totalGeneratedFiles = generatedFiles.Select(file => file.fileName).Distinct().Count();

            Debug.Log("Generated " + totalGeneratedFiles + " files.");

            AssetDatabase.Refresh();
        }