Game.SceneFlow.EngagementScreen
Assembly: Game (inferred)
Namespace: Game.SceneFlow
Type: class
Base: FullScreenOverlay
Summary:
Represents the initial "engagement" overlay screen (the press-any-key / start-game screen). It activates the engagement overlay UI, creates an input action scoped to continue the screen, blocks input to the rest of the game via an overlay barrier, then waits for player input. On input it either starts an interactive sign-in flow (if the user is not signed in) or attempts to associate the input device with the current user. The screen loops until the flow completes or is cancelled via the provided CancellationToken.
Fields
- (No private fields declared in this class)
This class does not declare any private fields itself. It uses inherited members (for example m_Done and m_CompletedEvent) from its FullScreenOverlay base class to track completion and signal input waits.
Properties
-
protected override OverlayScreen overlayScreen => OverlayScreen.Engagement
Specifies which overlay screen this class activates. This override returns OverlayScreen.Engagement so that the engagement UI is shown while this screen is active. -
protected override string actionA => "AnyKey"
Defines the input action name used to continue from the engagement screen. It uses the "AnyKey" action binding. -
protected override string continueDisplayProperty => "Start Game"
Provides the display text property (e.g., label or localized key) shown for the continue action in the overlay UI. Here it is "Start Game".
Constructors
- (implicit)
public EngagementScreen()
No explicit constructor is defined; the default parameterless constructor is used.
Methods
public override async Task Execute(GameManager manager, CancellationToken token)
Main async execution entry point for the engagement overlay. Behavior summary:- Creates an EnabledActionScoped (named "Engagement") for the continue action so the overlay shows the continue prompt and input is routed correctly.
- Creates an overlay barrier via Game.Input.InputManager.instance.CreateOverlayBarrier("EngagementScreen") to prevent other input handling while the overlay is active.
- Activates the engagement overlay through manager.userInterface.overlayBindings.ActivateScreenScoped.
- Enters a loop (while !m_Done):
- Waits for input by calling IScreenState.WaitForInput(continueAction, null, m_CompletedEvent, token).
- Awaits the returned Task<(bool ok, InputDevice device)>.
- If the wait task completes successfully:
- If the platform user is not signed in (PlatformManager.instance.isUserSignedIn == false), starts sign-in via PlatformManager.instance.SignIn(SignInOptions.WithUI, UserChangingCallback). Sets m_Done true only if sign-in succeeded (SignInFlags.Success).
- If the platform user is already signed in, attempts to associate the received input device via PlatformManager.instance.AssociateDevice(device) and sets m_Done based on the result.
- If the wait task was canceled/faulted (not IsCompletedSuccessfully), sets m_Done = true to exit.
- The method uses using() blocks to ensure disposable scoped objects are cleaned up (EnabledActionScoped, overlay barrier, overlay activation).
- The method honors the provided CancellationToken for cancellation.
- Local helper: a nested method UserChangingCallback(Task signInTask) calls new WaitScreen().Execute(manager, token, signInTask) to show a wait/progress screen while sign-in completes.
Notes and implementation details: - The class relies on PlatformManager for sign-in and device association, IScreenState for normalized input waiting, and Game.Input API for creating overlay barriers and action scoping. - HandleScreenChange referenced when constructing EnabledActionScoped is expected to be provided by the base class (FullScreenOverlay) or surrounding infrastructure. - The nested UserChangingCallback invokes WaitScreen().Execute without awaiting it (it forwards the sign-in Task to the wait screen).
Usage Example
// Typical invocation from scene flow / state manager:
var engagement = new Game.SceneFlow.EngagementScreen();
await engagement.Execute(manager, cancellationToken);
Additional notes: - The Execute method is async and should be awaited; cancellation via the passed CancellationToken will break the waiting loop. - Because the class uses platform sign-in flows and device association, mod code should be careful when invoking or altering PlatformManager flows to avoid unexpected UI or account interactions.