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
5 changes: 0 additions & 5 deletions StarMap.Core/ModLoaderPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public static void Patch(ModManager modManager)
public static void Unload()
{
_modManager = null;
//MainScreen.Screens = [];
_harmony?.UnpatchAll();
}

Expand All @@ -34,10 +33,6 @@ public static void OnLoadMod(this Mod __instance)
public static void AfterLoad()
{
_modManager?.OnAllModsLoaded();
/*var screens = MainScreen.Screens.ToList();
screens.Insert(MainScreen.Screens.Length - 1, new ModManagerScreen(_modManager));

MainScreen.Screens = screens.ToArray();*/
_harmony?.UnpatchAll(_harmony.Id);
}
}
Expand Down
7 changes: 6 additions & 1 deletion StarMap.Core/ModManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public void DeInit() {

public void LoadMod(Mod mod)
{
if (!Directory.Exists(mod.DirectoryPath)) return;
var fullPath = Path.GetFullPath(mod.DirectoryPath);
var filePath = Path.Combine(fullPath, $"{mod.Name}.dll");
var folderExists = Directory.Exists(fullPath);
var fileExists = File.Exists(filePath);

if (!folderExists || !fileExists) return;

var modLoadContext = new ModAssemblyLoadContext(mod, _coreAssemblyLoadContext);
var modAssembly = modLoadContext.LoadFromAssemblyName(new AssemblyName() { Name = mod.Name });
Expand Down
15 changes: 12 additions & 3 deletions StarMap.Core/StarMap.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,23 @@

<ItemGroup>
<PackageReference Include="Lib.Harmony" Version="2.4.1" />
<PackageReference Include="StarMap.KSA.Dummy" Version="1.0.4">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\StarMap.API\StarMap.API.csproj" />
<ProjectReference Include="..\StarMap.Types\StarMap.Types.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Debug'">
<Reference Include="..\..\Import\KSA.dll">
<ExcludeAssets>runtime</ExcludeAssets>
</Reference>
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' != 'Debug'">
<PackageReference Include="StarMap.KSA.Dummy" Version="1.0.4">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions StarMap/GameSurveyer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
Debug.Assert(_game is not null, "Load needs to be called before running game");

string[] args = [];
Directory.SetCurrentDirectory(Path.GetDirectoryName(_gameLocation));

Check warning on line 49 in StarMap/GameSurveyer.cs

View workflow job for this annotation

GitHub Actions / preview

Possible null reference argument for parameter 'path' in 'void Directory.SetCurrentDirectory(string path)'.

Check warning on line 49 in StarMap/GameSurveyer.cs

View workflow job for this annotation

GitHub Actions / preview

Possible null reference argument for parameter 'path' in 'void Directory.SetCurrentDirectory(string path)'.

Check warning on line 49 in StarMap/GameSurveyer.cs

View workflow job for this annotation

GitHub Actions / release

Possible null reference argument for parameter 'path' in 'void Directory.SetCurrentDirectory(string path)'.
_game.EntryPoint!.Invoke(null, [args]);
}

Expand Down
Loading