Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more PPatchManager patches #525

Merged
merged 1 commit into from
Nov 21, 2024
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
20 changes: 19 additions & 1 deletion PLibCore/PatchManager/PPatchManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ private static void Initialize_Postfix() {
Instance?.InvokeAllProcess(RunAt.AfterDbInit, null);
}

private static void PostProcess_Prefix() {
Instance?.InvokeAllProcess(RunAt.BeforeDbPostProcess, null);
}

private static void PostProcess_Postfix() {
Instance?.InvokeAllProcess(RunAt.AfterDbPostProcess, null);
}

private static void Instance_Postfix() {
bool load = false;
if (Instance != null)
Expand All @@ -87,6 +95,10 @@ private static void MainMenu_OnSpawn_Postfix() {
Instance?.InvokeAllProcess(RunAt.InMainMenu, null);
}

private static void DetailsScreen_OnPrefabInit_Postfix() {
Instance?.InvokeAllProcess(RunAt.OnDetailsScreenInit, null);
}

public override Version Version => VERSION;

/// <summary>
Expand Down Expand Up @@ -147,7 +159,7 @@ public PPatchManager(Harmony harmony) {
GetNameSafe());
}
this.harmony = harmony;
patches = new Dictionary<uint, PrivateRunList>(8);
patches = new Dictionary<uint, PrivateRunList>(11);
InstanceData = patches;
}

Expand All @@ -168,6 +180,8 @@ public override void Initialize(Harmony plibInstance) {
// Db
plibInstance.Patch(typeof(Db), nameof(Db.Initialize), prefix: PatchMethod(nameof(
Initialize_Prefix)), postfix: PatchMethod(nameof(Initialize_Postfix)));
plibInstance.Patch(typeof(Db), nameof(Db.PostProcess), prefix: PatchMethod(nameof(
PostProcess_Prefix)), postfix: PatchMethod(nameof(PostProcess_Postfix)));

// Game
plibInstance.Patch(typeof(Game), "DestroyInstances", postfix: PatchMethod(nameof(
Expand All @@ -182,6 +196,10 @@ public override void Initialize(Harmony plibInstance) {
// MainMenu
plibInstance.Patch(typeof(MainMenu), "OnSpawn", postfix: PatchMethod(
nameof(MainMenu_OnSpawn_Postfix)));

// DetailsScreen
plibInstance.Patch(typeof(DetailsScreen), "OnPrefabInit", postfix: PatchMethod(
nameof(DetailsScreen_OnPrefabInit_Postfix)));
}

public override void PostInitialize(Harmony plibInstance) {
Expand Down
15 changes: 15 additions & 0 deletions PLibCore/PatchManager/RunAt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ public static class RunAt {
/// </summary>
public const uint AfterLayerableLoad = 7U;

/// <summary>
/// Runs immediately before Db.PostProcess.
/// </summary>
public const uint BeforeDbPostProcess = 8U;

/// <summary>
/// Runs immediately after Db.PostProcess.
/// </summary>
public const uint AfterDbPostProcess = 9U;

/// <summary>
/// Runs when DetailsScreen.OnPrefabInit has completed.
/// </summary>
public const uint OnDetailsScreenInit = 10U;

/// <summary>
/// The string equivalents of each constant for debugging.
/// </summary>
Expand Down