Пример #1
0
        private static void LoadBaseTrack(int index, string courseDirectory, string name)
        {
            string trackDirectory = Path.Combine(courseDirectory, name);

            Console.WriteLine("Loading {0}...", trackDirectory);

            // Load the normal Muunt file.
            string courseMuuntPath = Path.Combine(trackDirectory, "course_muunt.byaml");

            if (File.Exists(courseMuuntPath))
            {
                _coursesNormal[index] = new CourseDefinition(courseMuuntPath);
            }

            // Load the 200cc Muunt file.
            string cc200MuuntPath = Path.Combine(trackDirectory, "course_muunt_200.byaml");

            if (File.Exists(cc200MuuntPath))
            {
                _courses200[index] = new CourseDefinition(cc200MuuntPath);
            }

            // Load the battle Muunt file.
            string battleMuuntPath = Path.Combine(trackDirectory, "battle_muunt.byaml");

            if (File.Exists(battleMuuntPath))
            {
                _coursesBattle[index] = new CourseDefinition(battleMuuntPath);
            }
        }
Пример #2
0
 private static int GetMuuntObjectCount(CourseDefinition muunt, int objId)
 {
     if (muunt == null)
     {
         return(-1);
     }
     return(muunt.Objs.Count(obj => obj.ObjId == objId));
 }
Пример #3
0
 private CourseDefinitionRefDTO MapCourseDefinitionRef(CourseDefinition courseDef)
 {
     return(new CourseDefinitionRefDTO {
         Id = courseDef.Id,
         Name = courseDef.Name,
         Acronym = courseDef.Acronym,
         Slug = courseDef.Slug
     });
 }
Пример #4
0
        public static void LoadMuunt(string fileName)
        {
            LoadObjectDB($"{GlobalSettingsMK8.MarioKart8Path}\\Data\\objflow.byaml");

            CourseDefinition course = new CourseDefinition(fileName);

            foreach (var obj in course.Objs)
            {
                LoadMapObject(obj);
            }
        }
Пример #5
0
        // ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------

        private static int Main(string[] args)
        {
            // Parse the parameters and validate them.
            if (!ParseParameters(args))
            {
                PrintHelp();
                return(-1);
            }
            if (!File.Exists(_fileName))
            {
                Console.Error.WriteLine($"File '{_fileName}' does not exist.");
                return(-1);
            }

            // Load the BYAML file.
            Console.WriteLine("Loading course...");
            CourseDefinition course = new CourseDefinition(_fileName);

            // Remove all EnemyPath and LapPath instances.
            Console.WriteLine("Removing Lakitu...");
            course.EnemyPaths = null;
            course.LapPaths   = null;

            // Remove all Objs which required an EnemyPath or LapPath (they might crash the game without them).
            for (int i = course.Objs.Count - 1; i >= 0; i--)
            {
                Obj obj = course.Objs[i];
                if (obj.EnemyPath1 != null || obj.EnemyPath2 != null || obj.LapPath != null)
                {
                    course.Objs.RemoveAt(i);
                }
            }

            // Make a backup of the original BYAML file.
            string backupFileName = Path.ChangeExtension(_fileName, "orig.byaml");

            if (!File.Exists(backupFileName))
            {
                Console.WriteLine("No backup found, creating '" + backupFileName + "'...");
                File.Copy(_fileName, backupFileName);
            }

            //// Overwrite the provided file.
            Console.Write("Storing new BYAML...");
            course.Save(_fileName);
            Console.WriteLine(" done.");

            return(0);
        }
Пример #6
0
        public CourseDefinitionDTO MapDefinition(CourseDefinition model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            return(new CourseDefinitionDTO {
                Id = model.Id,
                Year = model.Year.Id,
                Semester = model.Semester,
                Name = model.Name,
                Acronym = model.Acronym
            });
        }
Пример #7
0
 private static void WriteOutputCsv(string csvPath)
 {
     // Write the output CSV.
     using (StreamWriter writer = new StreamWriter(new FileStream(csvPath, FileMode.Create, FileAccess.Write,
                                                                  FileShare.Read)))
     {
         // Go through each track object.
         foreach (ObjDefinition entry in _objDb.Definitions)
         {
             // Get generic object information.
             List <string> resNames = entry.ResNames;
             if (resNames == null)
             {
                 resNames = new List <string>();
             }
             writer.Write(String.Join(";", entry.MgrId, entry.ObjId, entry.Label,
                                      String.Join("|", resNames), entry.AiReact, entry.PathType, entry.VR));
             writer.Write(";");
             // Get track usage counters (querying only normal or 200cc files at the moment).
             List <int> trackUsageCounts = new List <int>(_coursesNormal.Length);
             for (int i = 0; i < _coursesNormal.Length; i++)
             {
                 CourseDefinition course = _courses200[i];
                 if (course == null)
                 {
                     course = _coursesNormal[i];
                 }
                 trackUsageCounts.Add(GetMuuntObjectCount(course, entry.ObjId));
             }
             // Get the names of the tracks using this object the most.
             List <string> maxUseTrackNames = new List <string>();
             int           maxUseCount      = trackUsageCounts.Max();
             if (maxUseCount > 0)
             {
                 for (int i = 0; i < trackUsageCounts.Count; i++)
                 {
                     if (trackUsageCounts[i] == maxUseCount)
                     {
                         maxUseTrackNames.Add(GetTrackName(i));
                     }
                 }
             }
             writer.Write(String.Join("|", maxUseTrackNames));
             writer.Write(";");
             writer.WriteLine(String.Join(";", trackUsageCounts));
         }
     }
 }
Пример #8
0
        // ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------

        private static int Main(string[] args)
        {
            // Parse the parameters and validate them.
            if (!ParseParameters(args))
            {
                PrintHelp();
                return(-1);
            }
            if (!File.Exists(_fileName))
            {
                Console.Error.WriteLine($"File '{_fileName}' does not exist.");
                return(-1);
            }
            if (!File.Exists(_fileName200))
            {
                Console.Error.WriteLine($"File '{_fileName200}' does not exist.");
                return(-1);
            }

            // Load the BYAML files.
            Console.WriteLine($"Loading {Path.GetFileName(_fileName)}...");
            CourseDefinition course = new CourseDefinition(_fileName);

            Console.WriteLine($"Loading {Path.GetFileName(_fileName200)}...");
            CourseDefinition course200 = new CourseDefinition(_fileName200);

            // Check if the 200 BYAML has any Adjuster200cc objects at all.
            List <Obj> adjusters = course200.Objs.Where(x => x.ObjId == _adjusterID).ToList();

            if (adjusters.Count == 0)
            {
                Console.WriteLine("No Adjuster200cc objects found in 200cc BYAML, nothing to do.");
                return(0);
            }

            // Add the adjusters to the normal BYAML and the Name and ID lists.
            course.Objs.AddRange(adjusters);
            course.MapObjIdList.Add(_adjusterID);
            course.MapObjResList.Add(_adjusterName);

            // Overwrite the 200cc BYAML.
            Console.WriteLine($"Creating new {_fileName200}...");
            course.Save(_fileName200);
            return(0);
        }