Last Evil
此社区中心标记为“仅限成人”。您看到此中心是因为您已将偏好设置为允许此类内容。

Last Evil

Install Mod Manager App
lirmont  [开发者] 2021 年 12 月 15 日 下午 7:15
Technical Details About How to Patch Unity Mod Manager for Last Evil
The Unity Mod Manager source code is located at:
For UnityModManager, Retarget for .NET Framework 4

Open "UnityModManager.sln".
Right-click the "UnityModManager" project.
Change "Target framework" to ".NET Framework 4".
Save project.
Right-click "References".
Click "Add Reference...".
Click "Browse...".
Navigate to the .NET DLLs in Last Evil's game folder (ex: E:\SteamLibrary\steamapps\common\LastEvil\LastEvil_Data\Managed).
Add these 10:
  1. Assembly-CSharp.dll
  2. UnityEngine.dll
  3. UnityEngine.CoreModule.dll
  4. UnityEngine.IMGUIModule
  5. UnityEngine.InputLegacyModule.dll
  6. UnityEngine.TextRenderingModule.dll
  7. UnityEngine.UI.dll
  8. UnityEngine.UIModule.dll
  9. UnityEngine.UnityWebRequestModule.dll
  10. UnityEngine.UnityWebRequestWWWModule.dll

Take-away: now code can be written to address the parts of Last Evil that deal with Steam workshop mods and the "Mod Manager" button.


Change ModManager.cs

Around line 1084, there's a function with signature:
private static void _Start()

Delete the code between:
Logger.Log("Parsing mods."); // and if (mods.Count > 0)

Replace it with:
Dictionary<string, ModEntry> mods = new Dictionary<string, ModEntry>();
int countMods = 0;
if (Directory.Exists(modsPath))
{
countMods += LoadModsFromDirectory(modsPath, mods);
}
else
{
Logger.Log("Directory '" + modsPath + "' not exists.");
}

List<string> workshopMods = LastEvilLib.SingletonBase<LEModManager>.Instance.WorkshopMods;
if (workshopMods != null && workshopMods.Count > 0)
{
for (int i = 0; i < workshopMods.Count; i++)
{
countMods += LoadModsFromDirectory(workshopMods[i], mods);
}
}

Add this function somewhere in the UnityModManager class (like after _Start):
private static int LoadModsFromDirectory(string address, Dictionary<string, ModEntry> mods) { int count = 0; string[] directories = Directory.GetDirectories(address); foreach (string text in directories) { string text2 = Path.Combine(text, Config.ModInfo); if (!File.Exists(Path.Combine(text, Config.ModInfo))) { text2 = Path.Combine(text, Config.ModInfo.ToLower()); } if (!File.Exists(text2)) { continue; } count++; Logger.Log("Reading file '" + text2 + "'."); try { ModInfo modInfo = File.ReadAllText(text2).FromJson<ModInfo>(); if (string.IsNullOrEmpty(modInfo.Id)) { Logger.Error("Id is null."); continue; } if (mods.ContainsKey(modInfo.Id)) { Logger.Error("Id '" + modInfo.Id + "' already uses another mod."); continue; } if (string.IsNullOrEmpty(modInfo.AssemblyName)) { modInfo.AssemblyName = modInfo.Id + ".dll"; } ModEntry value = new ModEntry(modInfo, text + Path.DirectorySeparatorChar); mods.Add(modInfo.Id, value); } catch (Exception exception) { Logger.Error("Error parsing file '" + text2 + "'."); Debug.LogException(exception); } } return count; }


Change UI.cs

Around line 860, there's a method with signature:
public void ToggleWindow(bool open)

Comment out or delete the two lines near the top that track first launch:
// if (open) // mFirstLaunched = true;

I didn't look at why, but failing to do this makes the "Mod Manager" only able to open the pop-up window once (though it can still be opened with CTRL+F10 in that scenario).


Build the UnityModManger.dll

Build the project.
Right-click the "UnityModManger" project.
Pick "Open Folder in File Explorer".
Navigate to "bin" then "Release" (or "Debug" if that's what you built).
Take the now-patched "UnityModManager.dll" and "UnityModManager.xml" and use them in place of the ones that come with the non-Last Evil-specific UMM release.

Patching done.
最后由 lirmont 编辑于; 2021 年 12 月 15 日 下午 7:21