pass game args

This commit is contained in:
JohnCorby 2022-02-06 23:54:52 -08:00
parent 83fca7d31f
commit 9bd3ce25a9
2 changed files with 13 additions and 2 deletions

View File

@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using static EntitlementsManager;
@ -25,6 +26,8 @@ namespace EpicRerouter.ExeSide
Console.WriteLine($"version = {Version}");
var managedDir = args[2];
Console.WriteLine($"managed dir = {managedDir}");
var gameArgs = args.Skip(3).ToArray();
Console.WriteLine($"game args = {string.Join(", ", gameArgs)}");
Console.WriteLine();
AppDomain.CurrentDomain.AssemblyResolve += (_, e) =>

View File

@ -1,6 +1,8 @@
using HarmonyLib;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEngine;
using static EntitlementsManager;
@ -31,6 +33,8 @@ namespace EpicRerouter.ModSide
Log($"process path = {processPath}");
var gamePath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(typeof(EpicPlatformManager).Assembly.Location)!, ".."));
Log($"game path = {gamePath}");
var workingDirectory = Path.Combine(gamePath, "Plugins", "x86_64");
Log($"working dir = {workingDirectory}");
var args = new[]
{
Application.productName,
@ -38,11 +42,15 @@ namespace EpicRerouter.ModSide
Path.Combine(gamePath, "Managed")
};
Log($"args = {args.Join()}");
var gameArgs = Environment.GetCommandLineArgs();
Log($"game args = {gameArgs.Join()}");
var process = Process.Start(new ProcessStartInfo
{
FileName = processPath,
WorkingDirectory = Path.Combine(gamePath, "Plugins", "x86_64"),
Arguments = args.Join(x => $"\"{x}\"", " "),
WorkingDirectory = workingDirectory,
Arguments = args
.Concat(gameArgs)
.Join(x => $"\"{x}\"", " "),
UseShellExecute = false
});
process!.WaitForExit();