Ejemplo n.º 1
0
        public WrappedDirect(ParameterizedConfig cfg, Parameter.Direct direct, WrappedChoice parentChoice = null, ArgumentMap args = null)
        {
            Config       = cfg;
            BaseDirect   = direct;
            ParentChoice = parentChoice;
            Arguments    = args;

            foreach (string path in direct.paths)
            {
                TraverseDirectPath(path);
            }
        }
        /// <summary>
        /// Assuming this is a <see cref="ModelConfig"/> storing textures, this will try to find the textures from its parameters. Additionally, it will find the default texture of the model.
        /// </summary>
        /// <param name="cfg"></param>
        /// <param name="defaultTextureFromVisibleMesh"></param>
        /// <returns></returns>
        public static (List <string>, string) FindTexturesAndActiveFromDirects(ModelConfig cfg, string defaultTextureFromVisibleMesh)
        {
            SKAnimatorToolsProxy.SetProgressState(ProgressBarState.ExtraWork);

            List <string> retn = new List <string>();

            if (cfg.implementation is Imported imported)
            {
                (string[], string)info = GetDefaultTexturesAndActive(imported, defaultTextureFromVisibleMesh);
                retn.AddRange(info.Item1);
                defaultTextureFromVisibleMesh = info.Item2;
            }


            SKAnimatorToolsProxy.IncrementEnd(cfg.parameters.Length);
            foreach (Parameter param in cfg.parameters)
            {
                if (param is Parameter.Choice choice)
                {
                    WrappedChoice         wChoice  = new WrappedChoice(cfg, choice);
                    ParameterizedConfig[] variants = wChoice.CreateVariantsFromOptions();

                    foreach (ParameterizedConfig variant in variants)
                    {
                        // Each variant is now a dupe of cfg with the given variant information applied to it.
                        if (variant is ModelConfig mdlVariant)
                        {
                            // This should always be true but it's just here for sanity checking.
                            if (mdlVariant.implementation is Imported subImported)
                            {
                                (string[], string)info = GetDefaultTexturesAndActive(subImported, defaultTextureFromVisibleMesh);
                                // retn.AddRange(GetDefaultTextures(subImported));
                                retn.AddRange(info.Item1);
                                defaultTextureFromVisibleMesh = info.Item2;                                 // If it couldn't be found, the method returns what is input.
                                // As such, this will remain unchanged.
                            }
                        }
                    }
                }
                SKAnimatorToolsProxy.IncrementProgress();
            }

            SKAnimatorToolsProxy.SetProgressState(ProgressBarState.OK);
            return(retn, defaultTextureFromVisibleMesh);
        }
        /// <summary>
        /// Construct a new <see cref="WrappedChoiceOption"/> from the given parent <see cref="WrappedChoice"/> and the given option within said choice.
        /// </summary>
        /// <param name="choice"></param>
        /// <param name="option"></param>
        /// <param name="args"></param>
        public WrappedChoiceOption(WrappedChoice choice, Parameter.Choice.Option option, ArgumentMap args = null)
        {
            Name         = option.name;
            ParentChoice = choice;
            BaseOption   = option;
            Arguments    = args ?? option.arguments;
            // _arguments was exposed via an IL edit that I did. This is not possible under normal OOO behavior.
            // I aim to undo this soon as a method is better for the sake of uniformity.

            List <WrappedDirect> newDirects = new List <WrappedDirect>();

            foreach (Parameter.Direct direct in choice.BaseChoice.directs)
            {
                Parameter.Direct newDirect = (Parameter.Direct)direct.clone();                 // Thank god for their DeepObject class.
                newDirects.Add(new WrappedDirect(choice.Config, newDirect, choice, Arguments));
            }
            Directs = newDirects.ToArray();
        }
        /// <summary>
        /// Assuming this is a <see cref="ModelConfig"/> storing textures, this will try to find the textures from its parameters.
        /// </summary>
        /// <param name="cfg"></param>
        /// <returns></returns>
        public static List <string> FindTexturesFromDirects(ModelConfig cfg)
        {
            SKAnimatorToolsProxy.SetProgressState(ProgressBarState.ExtraWork);

            List <string> retn = new List <string>();

            if (cfg.implementation is Imported imported)
            {
                retn.AddRange(GetDefaultTextures(imported).ToList());
            }

            SKAnimatorToolsProxy.IncrementEnd(cfg.parameters.Length);
            foreach (Parameter param in cfg.parameters)
            {
                if (param is Parameter.Choice choice)
                {
                    WrappedChoice         wChoice  = new WrappedChoice(cfg, choice);
                    ParameterizedConfig[] variants = wChoice.CreateVariantsFromOptions();
                    foreach (ParameterizedConfig variant in variants)
                    {
                        // Each variant is now a dupe of cfg with the given variant information applied to it.
                        if (variant is ModelConfig mdlVariant)
                        {
                            // This should always be true but it's just here for sanity checking.
                            if (mdlVariant.implementation is Imported subImported)
                            {
                                retn.AddRange(GetDefaultTextures(subImported));
                            }
                        }
                    }
                }
                SKAnimatorToolsProxy.IncrementProgress();
            }

            SKAnimatorToolsProxy.SetProgressState(ProgressBarState.OK);
            return(retn);
        }