This reference is aimed at how to structure a basic Patchwork project.
Patchwork includes a generic launcher, which can be used for any Patchwork project. The launcher requires:
AppInfoFactory
library that describes your application; andPatchInfo
libraries for your patches.The first library is used to set up the launcher.
The second or additional libraries are used by the launcher to patch Assembly-CSharp.dll
in the game's Managed
directory.
AppInfoDLLProj
.Patchwork.Attributes
. Recommendation: Use the compiled DLL, not the project.AppInfoDLL.cs
.AppInfoFactory
and add the [AppInfoFactory]
attribute to the class.Within AppInfoDLL.cs
should be the following code:
using System.Linq;
using Patchwork.AutoPatching;
using System.IO;
namespace AppInfoDLLProj
{
[AppInfoFactory]
public class AppInfoDLL : AppInfoFactory
{
public override AppInfo CreateInfo(DirectoryInfo folderInfo)
{
var appInfo = new AppInfo
{
AppName = "Pillars of Eternity II",
AppVersion = "1.0.0.0",
BaseDirectory = folderInfo
};
string appPath = Combine(appInfo.BaseDirectory.ToString(), "PillarsOfEternityII.exe");
appInfo.Executable = new FileInfo(appPath);
return appInfo;
}
public static string Combine(params string[] paths)
{
string current = paths.Aggregate(@"", Path.Combine);
return current;
}
}
}
Patchwork.Attributes
. Recommendation: Use the compiled DLL, not the project.PatchAssemblyInfo
.IPatchInfo
and add the assembly attribute [assembly: PatchAssembly]
.Within PatchAssemblyInfo.cs
should be the following code:
using System.IO;
using System.Linq;
using Patchwork;
using Patchwork.AutoPatching;
[assembly: PatchAssembly]
namespace DeadfireMods
{
[PatchInfo]
public class PatchAssemblyInfo : IPatchInfo
{
public string PatchVersion { get; } = "1.0.0.000";
public string Requirements { get; } = "None";
public string PatchName { get; } = "DeadfireMods";
public FileInfo GetTargetFile(AppInfo app)
{
string file = Combine(app.BaseDirectory.FullName, "PillarsOfEternityII_Data", "Managed", "Assembly-CSharp.dll");
return new FileInfo(file);
}
public string CanPatch(AppInfo app)
{
return null;
}
public static string Combine(params string[] paths)
{
string current = paths.Aggregate(@"", Path.Combine);
return current;
}
}
}
Structure and implement your patches as desired, adding more references as needed.