AcTools.Utils.FileUtils.GetCarDirectory C# (CSharp) Method

GetCarDirectory() public static method

public static GetCarDirectory ( string acRoot, string carName ) : string
acRoot string
carName string
return string
        public static string GetCarDirectory(string acRoot, string carName) {
            return Path.Combine(GetCarsDirectory(acRoot), carName);
        }

Usage Example

Example #1
0
        public static bool FixBlurredWheels(string acRoot, string carName)
        {
            var kn5File = FileUtils.GetMainCarFilename(acRoot, carName);

            var kn5    = Kn5.FromFile(kn5File);
            var wheels = 0;

            string[] normalRims;
            string[] blurredRims;
            try {
                var normalRimsList  = new List <string>();
                var blurredRimsList = new List <string>();
                foreach (var section in new IniFile(FileUtils.GetCarDirectory(acRoot, carName), "blurred_objects.ini").Values)
                {
                    if (Math.Abs(section.GetDouble("MIN_SPEED", 0d)) < 0.001)
                    {
                        normalRimsList.Add(section.GetPossiblyEmpty("NAME"));
                    }
                    else
                    {
                        blurredRimsList.Add(section.GetPossiblyEmpty("NAME"));
                    }
                }

                normalRims  = normalRimsList.ToArray();
                blurredRims = blurredRimsList.ToArray();
            } catch (Exception) {
                normalRims  = new [] { "RIM_LF", "RIM_RF", "RIM_LR", "RIM_RR" };
                blurredRims = new [] { "RIM_BLUR_LF", "RIM_BLUR_RF", "RIM_BLUR_LR", "RIM_BLUR_RR" };
            }

            foreach (var node in kn5.Nodes.Where(node => node.NodeClass == Kn5NodeClass.Base))
            {
                if (!node.Active && normalRims.Contains(node.Name))
                {
                    node.Active = true;
                    wheels++;
                }
                else if (node.Active && blurredRims.Contains(node.Name))
                {
                    node.Active = false;
                    wheels++;
                }
            }

            if (wheels == 0)
            {
                return(false);
            }

            FileUtils.Recycle(kn5File);
            kn5.SaveAll(kn5File);
            return(true);
        }