XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
UTF-8
using Newtonsoft.Json;
using SpaceEngineersBlueprintEditor.SpaceEngineersCore;
using System.Diagnostics;
using VRage.Game;
using System.Runtime.CompilerServices;
using RuntimeGameAssemblyLoader = SpaceEngineersBlueprintEditor.GameAssemblyLoader.GameAssemblyLoader;

namespace SpaceEngineersBlueprintEditor.Test;

internal class Program
{
    [SMTest]
    public static void TestMethod()
    {
        var gameRoot = RuntimeGameAssemblyLoader.EnsureInitialized();
        RunTest(gameRoot);
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    private static void RunTest(string gameRoot)
    {
        Initializer.Initialize(
            Path.Combine(gameRoot, "Content"),
            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SpaceEngineers"));
        var blueprint = SpaceEngineerDefinitions.Load<MyObjectBuilder_Definitions>(@"C:\Users\XFEstudio\AppData\Roaming\SpaceEngineers\Blueprints\local\寰宇号(大型武装殖民飞船)[Infinity Edition] V6_8_6\bp.sbc");
        var process = new Process();
        process.StartInfo.FileName = @"C:\Users\XFEstudio\Desktop\work\C#\GitHub\XFEstudio\SpaceEngineersBlueprintEditor\SpaceEngineersBlueprintEditor.BlueprintConverter\bin\Debug\net48\SpaceEngineersBlueprintEditor.BlueprintConverter.exe";
        var jsonString = JsonConvert.SerializeObject(blueprint, new JsonSerializerSettings
        {
            TypeNameHandling = TypeNameHandling.Auto
        });
        File.WriteAllText("TestJson", jsonString);
        process.StartInfo.RedirectStandardInput = true;
        process.StartInfo.RedirectStandardOutput = true;
        process.StartInfo.RedirectStandardError = true;
        process.StartInfo.ArgumentList.Add("TestJson");
        process.StartInfo.UseShellExecute = false;
        process.StartInfo.CreateNoWindow = false;
        process.Start();
        do
        {
            try
            {
                Console.Write((char)process.StandardOutput.Read());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
        while (!process.HasExited);
    }
}