Beispiel #1
0
        public void DebugLoadFileShape(string shapeFilePath)
        {
            var output        = @"G:\NickProd\Farming Simulator 19\Temp";
            var gameDirectory = GamePaths.GetGamePath(FarmSimulatorVersion.FarmingSimulator2017);
            var realtive      = Path.GetRelativePath(gameDirectory, shapeFilePath);
            var shapeFile     = new ShapeFile(shapeFilePath);
            var index         = 0;

            try
            {
                shapeFile.ReadKnowTypes()
                .ForEach((v, i) => index = i);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            //shapeFile.ReadRawNamedShape()
            //         .ForEach(
            //             v =>
            //             {
            //                 var dirOutName = Path.Combine(output, realtive);
            //                 if (!Directory.Exists(dirOutName))
            //                 {
            //                     Directory.CreateDirectory(dirOutName);
            //                 }
            //                 File.WriteAllBytes(Path.Combine(dirOutName, $"[{v.Id}]_{FileTools.CleanFileName(v.Name)}.bin"), v.RawData);
            //             });
        }
Beispiel #2
0
        private static void ExtractFile(CommandLineOptions options)
        {
            var file = new ShapeFile(options.File, Logger);

            string folder;

            if (options.CreateDir)
            {
                folder = Path.Combine(options.Out, "extract_" + Path.GetFileName(file.FilePath));
            }
            else
            {
                folder = options.Out;
            }

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            foreach (var shape in file.ReadKnowTypes(ShapeType.Shape).OfType <Shape>())
            {
                //if (options.DumpBinary)
                //{
                //    var binFileName = $"shape_{shape.Name}.bin";
                //    File.WriteAllBytes(Path.Combine(folder, CleanFileName(binFileName)), shape.RawData);
                //}

                //var mdlFileName = Path.Combine(folder, CleanFileName(shape.Name + ".obj"));

                //var objfile = shape.ToObj();
                //objfile.Name = Path.GetFileName(file.FilePath).Replace(".i3d.shapes", "");
                //var dataBlob = objfile.ExportToBlob();

                //if (File.Exists(mdlFileName))
                //    File.Delete(mdlFileName);

                //File.WriteAllBytes(mdlFileName, dataBlob);
            }
        }
 /// <summary>
 /// Read all <see cref="NavMesh"/>.
 /// </summary>
 /// <param name="shapeFile"><inheritdoc cref="ShapeFile"/></param>
 /// <returns>Collection <see cref="NavMesh"/>.</returns>
 public static IEnumerable <NavMesh> ReadNavMesh(this ShapeFile shapeFile)
 {
     return(shapeFile.ReadKnowTypes(ShapeType.NavMesh)
            .OfType <NavMesh>());
 }
 /// <summary>
 /// Read all <see cref="Spline"/>.
 /// </summary>
 /// <param name="shapeFile"><inheritdoc cref="ShapeFile"/></param>
 /// <returns>Collection <see cref="Spline"/>.</returns>
 public static IEnumerable <Spline> ReadSplines(this ShapeFile shapeFile)
 {
     return(shapeFile.ReadKnowTypes(ShapeType.Spline)
            .OfType <Spline>());
 }