Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions StarMap.Loader/GameSurveyer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ internal class GameSurveyer : IDisposable
private readonly IGameFacade _facade;
private readonly AssemblyLoadContext _gameAssemblyContext;
private readonly string _gameLocation;
private readonly string[] _args;

private Assembly? _game;
private IStarMapCore? _core;

public GameSurveyer(IGameFacade facade, AssemblyLoadContext alc, string location)
public GameSurveyer(IGameFacade facade, AssemblyLoadContext alc, string location, string[] args)
{
_facade = facade;
_gameAssemblyContext = alc;
_gameLocation = location;
_args = args;
}

public bool TryLoadCoreAndGame()
Expand Down Expand Up @@ -51,9 +53,7 @@ public void RunGame()
{
Debug.Assert(_game is not null, "Load needs to be called before running game");

string[] args = [];

_game.EntryPoint!.Invoke(null, [args]);
_game.EntryPoint!.Invoke(null, [_args]);
}

public void Dispose()
Expand Down
4 changes: 2 additions & 2 deletions StarMap.Loader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static void SoleModeInner()

var gameAssemblyContext = new GameAssemblyLoadContext(gameConfig.GameLocation);
var dumbFacade = new SoloGameFacade();
using var gameSurveyer = new GameSurveyer(dumbFacade, gameAssemblyContext, gameConfig.GameLocation);
using var gameSurveyer = new GameSurveyer(dumbFacade, gameAssemblyContext, gameConfig.GameLocation, gameConfig.GameArguments);
if (!gameSurveyer.TryLoadCoreAndGame())
{
Console.WriteLine("StarMap - Unable to load mod manager and game in solo mode.");
Expand All @@ -55,7 +55,7 @@ static async Task MainInner(string pipeName)

var gameLocation = await facade.Connect();
var gameAssemblyContext = new GameAssemblyLoadContext(Path.GetFullPath(gameLocation));
var gameSurveyer = new GameSurveyer(facade, gameAssemblyContext, gameLocation);
var gameSurveyer = new GameSurveyer(facade, gameAssemblyContext, gameLocation, []);
if (!gameSurveyer.TryLoadCoreAndGame()) return;

gameSurveyer.RunGame();
Expand Down
4 changes: 4 additions & 0 deletions StarMap.Types/LoaderConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ public bool TryLoadConfig()
}

GameLocation = path;

GameArguments = config.GameArguments;

return true;
}

public string GameLocation { get; set; } = "";
public string RepositoryLocation { get; set; } = "";
public string[] GameArguments { get; set; } = [];
}
}
Loading