Game.PSI.NotificationSystem
Assembly: Assembly-CSharp (game/mod runtime)
Namespace: Game.PSI
Type: public static class
Base: System.Object
Summary:
NotificationSystem is a static helper that bridges game logic and the notification UI layer (NotificationUISystem). It allows code to bind a NotificationUISystem instance, push and remove notifications with optional localized titles/text, thumbnails, progress state, and click callbacks, and query whether a notification exists. All operations are no-ops if no UI is bound (safe null checks are used).
Fields
private static NotificationUISystem s_System
Holds the currently bound NotificationUISystem instance used to display and manage notifications. Set via BindUI and cleared via UnbindUI. Methods use null-conditional access so calls are safe when no UI is bound.
Properties
- None. (This static helper exposes only methods and a private backing field.)
Constructors
- None. (This is a static class — no instance constructors. There is no static constructor defined in the source.)
Methods
-
public static void BindUI(NotificationUISystem value)
Binds the provided NotificationUISystem instance so subsequent Push/Pop/Exist calls will forward to the UI implementation. Replace or set the UI instance with this call. -
public static void UnbindUI()
Unbinds the current NotificationUISystem by clearing the internal reference. After calling this, Push/Pop/Exist will do nothing or return false. -
public static void Push(string identifier, LocalizedString? title = null, LocalizedString? text = null, string titleId = null, string textId = null, string thumbnail = null, ProgressState? progressState = null, int? progress = null, Action onClicked = null)
Adds or updates a notification with the given identifier. Parameters: - identifier: unique key for the notification (used to update or remove it).
- title / text: optional pre-constructed LocalizedString for title and body.
- titleId / textId: optional localization keys; used to obtain LocalizedString via NotificationUISystem.GetTitle/GetText when title/text arguments are null.
- thumbnail: optional thumbnail asset id/path.
- progressState: optional state representing progress (e.g., determinate/indeterminate/none — defined by ProgressState).
- progress: optional progress value (usually percent or 0..100).
-
onClicked: optional callback invoked when the notification is clicked in the UI. If no UI is bound, this method does nothing.
-
public static void Pop(string identifier, float delay = 0f, LocalizedString? title = null, LocalizedString? text = null, string titleId = null, string textId = null, string thumbnail = null, ProgressState? progressState = null, int? progress = null, Action onClicked = null)
Requests removal of the notification identified by identifier, optionally after delay seconds. The other parameters mirror Push and are forwarded to the UI to provide context or for matching. If no UI is bound, this method does nothing. -
public static bool Exist(string identifier)
Returns true if a notification with the given identifier exists in the bound NotificationUISystem; otherwise false. If no UI is bound, returns false.
Usage Example
// Bind the UI system (typically done when the notification UI is created)
NotificationSystem.BindUI(myNotificationUISystem);
// Push a notification using localization keys
NotificationSystem.Push(
identifier: "mod.update_available",
titleId: "MOD_UPDATE_TITLE",
textId: "MOD_UPDATE_TEXT",
thumbnail: "Textures/Icons/update",
progressState: ProgressState.None,
onClicked: () => {
// open mod page or show details
}
);
// Update progress on an existing notification
NotificationSystem.Push(
identifier: "mod.download",
titleId: "DOWNLOAD_TITLE",
textId: "DOWNLOAD_TEXT",
progressState: ProgressState.Determinate,
progress: 42
);
// Remove (pop) a notification immediately or with delay
NotificationSystem.Pop("mod.update_available"); // immediate
NotificationSystem.Pop("mod.download", delay: 2.5f); // remove after 2.5 seconds
// Query existence
bool exists = NotificationSystem.Exist("mod.download");
// Unbind when UI is destroyed
NotificationSystem.UnbindUI();
Notes: - The class uses NotificationUISystem.GetTitle/GetText(titleId/textId) to resolve localization keys when LocalizedString parameters are not supplied. - All calls are safe to make even when no NotificationUISystem is bound because the code uses null-conditional operator (?.). - onClicked is executed by the UI layer when the user interacts with the notification; ensure any captured state remains valid.