swiftlys2/docs/api/ai/
API Reference › Menu

IMenuService

Interface
Namespace: SwiftlyS2.Shared.Menu · Assembly: SwiftlyS2.CS2.dll
public interface IMenuService

A plugin's entry point into the menu framework.

Each plugin gets its own instance over shared, core-owned registries. Everything created or registered through it is attributed to that plugin and released when the plugin unloads, so one plugin unloading never disturbs another plugin's menus.

View source

Properties

Actions

The catalogue of bindable actions.

IMenuActionRegistry Actions { get; }
Property Value

Renderers

The catalogue of renderers and component specialisations.

IMenuRendererRegistry Renderers { get; }
Property Value

Methods

CloseAll()

Closes every open menu belonging to this plugin.

void CloseAll()

CloseFor(IPlayer)

Closes a player's open menu when it belongs to this plugin.

void CloseFor(IPlayer player)
Parameters
  • playerIPlayerThe player to close for.

CreateMenu(string)

Starts building a menu.

IMenuBuilder CreateMenu(string id)
Parameters
  • idstringThe menu id, also used as its keybind configuration scope. Namespacing it with the plugin id, such as "myplugin.shop" , keeps server configuration files readable.
Returns
A builder for the new menu.

GetSession(IPlayer)

Gets the session for whatever menu a player currently has open.

IMenuSession? GetSession(IPlayer player)
Parameters
  • playerIPlayerThe player to look up.
Returns
The session, or null when no menu is open.

A player has at most one open menu at a time, across every plugin.