Skip to content

Implement Sequential Hooking and Notification for Multiplayer Button Click#44

Merged
Extremelyd1 merged 4 commits intoExtremelyd1:mainfrom
Liparakis:main
Mar 28, 2026
Merged

Implement Sequential Hooking and Notification for Multiplayer Button Click#44
Extremelyd1 merged 4 commits intoExtremelyd1:mainfrom
Liparakis:main

Conversation

@Liparakis
Copy link
Copy Markdown
Contributor

Problem

Lack of Interception Logic: There was no built-in mechanism for external addons to react to or intercept the "Start Multiplayer" button click.

Solution

IUiManager.cs: Defined a two-tier API for multiplayer button interactions:

  • MultiplayerButtonPressed: A standard C# event for fire-and-forget notifications (logging, non-blocking UI effects).
  • RegisterMultiplayerMenuHook: A registration method for "middleware" style hooks. Each hook receives a continuation callback, allowing it to explicitly control when (or if) the menu transition proceeds.

UiManager.cs: Implemented a sequential execution chain (_multiplayerMenuChain).

  • Hook Chaining: Each newly registered hook wraps the previous chain, ensuring that hooks execute in sequence (last-registered first).
  • Execution Flow: When the button is clicked, the notification event is fired immediately, followed by the first hook in the chain. The core transition to the multiplayer menu (GoToMultiplayerMenu) is only executed at the very end of this chain, provided all hooks have called their respective continuations.

Copy link
Copy Markdown
Owner

@Extremelyd1 Extremelyd1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the simple PR!
Couple of easy to click suggestions. The rest looks good.


/// <summary>
/// Fired when the multiplayer button is pressed, before any blocking hooks run.
/// Use this for fire-and-forget reactions such as logging or showing a notification?
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Use this for fire-and-forget reactions such as logging or showing a notification?
/// Use this for fire-and-forget reactions such as logging or showing a notification.

/// </summary>
private void OnMultiplayerMenuRequested() {
MultiplayerButtonPressed?.Invoke();
_multiplayerMenuChain();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_multiplayerMenuChain();
_multiplayerMenuChain.Invoke();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer explicitly calling .Invoke on Action types to avoid confusion of whether this is an action or a method.

@Liparakis Liparakis requested a review from Extremelyd1 March 28, 2026 20:26
@Extremelyd1 Extremelyd1 merged commit 4d6c01f into Extremelyd1:main Mar 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants