-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Slight changes to make patches easier to handle
- Patches will now load automatically without having to reference them in a list. - The game will now check if the required patches folder exists before loading. - Paths have been moved to the Master class to keep consistency with the rest of the code.
- Loading branch information
Showing
5 changed files
with
68 additions
and
55 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using Verse; | ||
|
||
namespace GameClient | ||
{ | ||
public static class CompatibilityManager | ||
{ | ||
public static void LoadAllPatchedAssemblies() | ||
{ | ||
string[] allCompatibilitiesToLoad = CompatibilityManagerHelper.GetAllPatchedMods(); | ||
|
||
foreach (string compatibility in allCompatibilitiesToLoad) | ||
{ | ||
string compatibilityName = Path.GetFileNameWithoutExtension(compatibility); | ||
|
||
if (LoadedModManager.RunningModsListForReading.Any(mod => mod.Name == compatibilityName)) | ||
{ | ||
try | ||
{ | ||
Assembly assembly = Assembly.LoadFrom(compatibility); | ||
Type toUse = typeof(CompatibilityManager); | ||
|
||
MethodInfo methodInfo = toUse.GetMethod(compatibilityName, BindingFlags.NonPublic | BindingFlags.Static); | ||
methodInfo.Invoke(compatibilityName, null); | ||
|
||
Master.loadedCompatibilityPatches.Add(compatibilityName, assembly); | ||
Logger.Message($"Loaded patch for '{compatibilityName}'"); | ||
} | ||
catch (Exception ex){ Logger.Error($"Failed to load patch for '{compatibilityName}' because :\n{ex}"); } | ||
} | ||
} | ||
} | ||
|
||
//Entry point for the soon-to-come SOS2 patch | ||
|
||
private static void SOS2Patch() | ||
{ | ||
Logger.Warning("Loaded!"); | ||
} | ||
} | ||
|
||
public static class CompatibilityManagerHelper | ||
{ | ||
public static readonly string fileExtension = ".dll"; | ||
|
||
public static string[] GetAllPatchedMods() | ||
{ | ||
return Directory.GetFiles(Master.compatibilityPatchesFolderPath) | ||
.Where(fetch => fetch.EndsWith(fileExtension)).ToArray(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters