コード例 #1
0
        //force=true: do it even if there is no desired change, required for updating physics.rbz after an NGP plugin download/update
        private void CopyNGPPhysics(bool replaceSchoolFiles, bool force)
        {
            for (int i = 0; i < 8; i++)
            {
                if (!force && DesiredCarList[i].Equals(CurrentCarList[i]))
                {
                    continue;
                }
                Car c = DesiredCarList[i];

                //if it is a car unknown in carList.ini skip it
                if (c.physics == null)
                {
                    continue;
                }

                //copy NGP physics if it exists
                string sourceFolder = "RBRCIT\\physics\\" + c.physics;
                string destFolder   = "Physics\\" + PhysicsFolders[i];

                if (Directory.Exists(sourceFolder))
                {
                    if (Directory.Exists(destFolder))
                    {
                        HelperFunctions.DirectoryDeleteAllFilesRecursively(destFolder);
                    }
                    HelperFunctions.DirectoryCopy(sourceFolder, destFolder);
                }
            }

            //special handling for school car
            if (replaceSchoolFiles)
            {
                File.Copy("RBRCIT\\physics\\" + DesiredCarList[5].physics + "\\setups\\d_gravel.lsp", "Physics\\school\\gravel.lsp", true);
                File.Copy("RBRCIT\\physics\\" + DesiredCarList[5].physics + "\\setups\\d_gravel.lsp", "Physics\\school\\sfgravel.lsp", true);
                File.Copy("RBRCIT\\physics\\" + DesiredCarList[5].physics + "\\setups\\d_tarmac.lsp", "Physics\\school\\tarmac.lsp", true);

                string[] lines = File.ReadAllLines("Physics\\school\\sfgravel.lsp");
                int      j     = 0;
                foreach (string line in lines)
                {
                    if (line.Contains("FrontRollBarStiffness"))
                    {
                        lines[j] = "   FrontRollBarStiffness\t\t\t0";
                    }
                    if (line.Contains("RearRollBarStiffness"))
                    {
                        lines[j] = "   RearRollBarStiffness\t\t\t\t0";
                    }
                    j++;
                }
                File.WriteAllLines("Physics\\school\\sfgravel.lsp", lines);
            }
            else
            {
                HelperFunctions.DirectoryCopy("RBRCIT\\physics\\school", "Physics\\school");
            }

            //create physics.rbz from subfolder
            ZipManager.CreateFromDirectory("Physics", "physics.rbz", true);
        }