Exemplo n.º 1
0
        protected override void RunImpl()
        {
            var typeGenerator                  = new UnityTypeGenerator();
            var enumGenerator                  = new UnityEnumGenerator();
            var eventGenerator                 = new UnityEventGenerator();
            var commandPayloadGenerator        = new UnityCommandPayloadGenerator();
            var blittableComponentGenerator    = new UnityComponentDataGenerator();
            var nonBlittableComponentGenerator = new UnityComponentGenerator();
            var componentConversionGenerator   = new UnityComponentConversionGenerator();

            foreach (var enumType in enumsToGenerate)
            {
                var fileName = Path.ChangeExtension(enumType.name, fileExtension);
                var enumCode = enumGenerator.Generate(enumType, package);
                Content.Add(Path.Combine(relativeOutputPath, fileName), enumCode);
            }

            foreach (var type in typesToGenerate)
            {
                var fileName = Path.ChangeExtension(type.Name, fileExtension);
                var typeCode = typeGenerator.Generate(type, package, enumSet);
                Content.Add(Path.Combine(relativeOutputPath, fileName), typeCode);
            }

            foreach (var component in componentsToGenerate)
            {
                var componentFileName = Path.ChangeExtension(component.Name, fileExtension);
                var componentCode     = component.IsBlittable
                    ? blittableComponentGenerator.Generate(component, package)
                    : nonBlittableComponentGenerator.Generate(component, package);
                Content.Add(Path.Combine(relativeOutputPath, componentFileName), componentCode);

                if (component.CommandDefinitions.Count > 0)
                {
                    var commandPayloadsFileName =
                        Path.ChangeExtension($"{component.Name}CommandPayloads", fileExtension);
                    var commandPayloadCode =
                        commandPayloadGenerator.Generate(component, package);
                    Content.Add(Path.Combine(relativeOutputPath, commandPayloadsFileName), commandPayloadCode);
                }

                if (component.EventDefinitions.Count > 0)
                {
                    var eventsFileName = Path.ChangeExtension($"{component.Name}Events", fileExtension);
                    var eventsCode     = eventGenerator.Generate(component, package);
                    Content.Add(Path.Combine(relativeOutputPath, eventsFileName), eventsCode);
                }

                var conversionFileName       = Path.ChangeExtension($"{component.Name}Translation", fileExtension);
                var componentTranslationCode = componentConversionGenerator.Generate(component, package, enumSet);
                Content.Add(Path.Combine(relativeOutputPath, conversionFileName), componentTranslationCode);
            }
        }
Exemplo n.º 2
0
        protected override void RunImpl()
        {
            var typeGenerator                          = new UnityTypeGenerator();
            var enumGenerator                          = new UnityEnumGenerator();
            var eventGenerator                         = new UnityEventGenerator();
            var commandPayloadGenerator                = new UnityCommandPayloadGenerator();
            var commandComponentsGenerator             = new UnityCommandComponentsGenerator();
            var blittableComponentGenerator            = new UnityComponentDataGenerator();
            var componentConversionGenerator           = new UnityComponentConversionGenerator();
            var referenceTypeProviderGenerator         = new UnityReferenceTypeProviderGenerator();
            var commandStorageGenerator                = new UnityCommandStorageGenerator();
            var gameObjectComponentDispatcherGenerator = new UnityGameObjectComponentDispatcherGenerator();
            var gameObjectCommandHandlersGenerator     = new UnityGameObjectCommandHandlersGenerator();
            var readerWriterGenerator                  = new UnityReaderWriterGenerator();

            foreach (var enumType in enumsToGenerate)
            {
                var fileName = Path.ChangeExtension(enumType.name, fileExtension);
                var enumCode = enumGenerator.Generate(enumType, package);
                Content.Add(Path.Combine(relativeOutputPath, fileName), enumCode);
            }

            foreach (var type in typesToGenerate)
            {
                var fileName = Path.ChangeExtension(type.Name, fileExtension);
                var typeCode = typeGenerator.Generate(type, package, enumSet);
                Content.Add(Path.Combine(relativeOutputPath, fileName), typeCode);
            }

            foreach (var component in componentsToGenerate)
            {
                var componentFileName = Path.ChangeExtension(component.Name, fileExtension);
                var componentCode     = blittableComponentGenerator.Generate(component, package, enumSet);
                Content.Add(Path.Combine(relativeOutputPath, componentFileName), componentCode);

                if (component.CommandDefinitions.Count > 0)
                {
                    var commandPayloadsFileName =
                        Path.ChangeExtension($"{component.Name}CommandPayloads", fileExtension);
                    var commandPayloadCode =
                        commandPayloadGenerator.Generate(component, package);
                    Content.Add(Path.Combine(relativeOutputPath, commandPayloadsFileName), commandPayloadCode);

                    var commandComponentsFileName =
                        Path.ChangeExtension($"{component.Name}CommandComponents", fileExtension);
                    var commandComponentsCode =
                        commandComponentsGenerator.Generate(component, package);
                    Content.Add(Path.Combine(relativeOutputPath, commandComponentsFileName), commandComponentsCode);

                    var commandStorageFileName =
                        Path.ChangeExtension($"{component.Name}CommandStorage", fileExtension);
                    var commandStorageCode = commandStorageGenerator.Generate(component, package);
                    Content.Add(Path.Combine(relativeOutputPath, commandStorageFileName), commandStorageCode);
                }

                if (component.EventDefinitions.Count > 0)
                {
                    var eventsFileName = Path.ChangeExtension($"{component.Name}Events", fileExtension);
                    var eventsCode     = eventGenerator.Generate(component, package);
                    Content.Add(Path.Combine(relativeOutputPath, eventsFileName), eventsCode);
                }

                var conversionFileName       = Path.ChangeExtension($"{component.Name}Translation", fileExtension);
                var componentTranslationCode = componentConversionGenerator.Generate(component, package, enumSet);
                Content.Add(Path.Combine(relativeOutputPath, conversionFileName), componentTranslationCode);

                var referenceProviderFileName        = Path.ChangeExtension($"{component.Name}Providers", fileExtension);
                var referenceProviderTranslationCode =
                    referenceTypeProviderGenerator.Generate(component, package, enumSet);
                Content.Add(Path.Combine(relativeOutputPath, referenceProviderFileName),
                            referenceProviderTranslationCode);

                var gameObjectComponentDispatcherFileName =
                    Path.ChangeExtension($"{component.Name}GameObjectComponentDispatcher", fileExtension);
                var gameObjectComponentDispatcherCode =
                    gameObjectComponentDispatcherGenerator.Generate(component, package, enumSet);
                Content.Add(Path.Combine(relativeOutputPath, gameObjectComponentDispatcherFileName),
                            gameObjectComponentDispatcherCode);

                var readerWriterFileName =
                    Path.ChangeExtension($"{component.Name}ReaderWriter", fileExtension);
                var readerWriterCode =
                    readerWriterGenerator.Generate(component, package, enumSet);
                Content.Add(Path.Combine(relativeOutputPath, readerWriterFileName), readerWriterCode);

                if (component.CommandDefinitions.Count > 0)
                {
                    var monobehaviourCommandHandlerFileName =
                        Path.ChangeExtension($"{component.Name}MonoBehaviourCommandHandlers", fileExtension);
                    var monobehaviourCommandHandlerCode =
                        gameObjectCommandHandlersGenerator.Generate(component, package);
                    Content.Add(Path.Combine(relativeOutputPath, monobehaviourCommandHandlerFileName),
                                monobehaviourCommandHandlerCode);
                }
            }
        }