Game.SceneFlow.SplashScreenSequence
Assembly: Assembly-CSharp (game assembly)
Namespace: Game.SceneFlow
Type: class
Base: IScreenState
Summary:
Handles the startup splash-screen sequence shown by the game. The sequence activates overlay screens in order, waits for either a fixed delay (4 seconds) or user input (the "Skip" action) to proceed, then deactivates each splash. Execution is cancellable via a CancellationToken. The implementation also temporarily adjusts input association while splash screens are displayed (so that input is not associated with a user during splashes such as piracy/ photosensitivity disclaimers).
Fields
private const string kSkipSplashKeyAction
Used as the name of the input action bound to skipping/toggling splash screens ("Skip"). The class enables an EnabledActionScoped with this action name to detect skip input during the splash sequence.
Properties
- This class does not declare any public properties.
Constructors
public SplashScreenSequence()
No explicit constructor is defined in the source; the class uses the default parameterless constructor.
Methods
-
private Task WaitForCompletion(TimeSpan delay, InputAction anyKey, CancellationToken token)
Returns a Task that completes when either the provided delay expires or input is received. Internally uses Task.WhenAny between Task.Delay(delay, token) and IScreenState.WaitForInput(anyKey, ...). Used to implement "wait 4 seconds or until skip key pressed" behavior. -
public async Task Execute(GameManager manager, CancellationToken token)
Main entry point to run the splash screen sequence. Behavior summary: - Creates an EnabledActionScoped for the "Skip" action so key presses can be observed and routed to HandleScreenChange.
- Creates an overlay barrier via InputManager.instance.CreateOverlayBarrier("SplashScreenSequence") to prevent overlays from being interfered with by other input/UI flow.
- Obtains the overlay bindings from manager.userInterface.overlayBindings and the sequence of splash overlays from GetSplashSequence().
- Iterates each splash:
- Activates the first splash, or swaps previous->next for subsequent splashes.
- Waits up to 4 seconds or until skip input via WaitForCompletion.
- Deactivates the splash and checks for cancellation.
- After the splash sequence it performs a short yield loop (60 iterations) before finishing.
- The method is cancellable via the supplied CancellationToken.
The method defines a local static function HandleScreenChange(OverlayScreen screen) which is called by EnabledActionScoped when the active overlay screen changes. HandleScreenChange: - Disassociates input actions from the user while on splash screens and disclaimers (Splash1..4, PiracyDisclaimer, PhotosensitivityDisclaimer). - Re-associates actions when overlays are None or Loading. - Returns a boolean indicating whether the EnabledActionScoped should remain enabled for the provided screen (true for Splash1..3 and Splash4; false otherwise).
private IEnumerable<OverlayScreen> GetSplashSequence()
Returns the hard-coded sequence of overlays to show: Splash1, Splash2, Splash4. (Note: Splash3 is not yielded; the sequence can be modified here if additional/ different splash screens are desired.)
Usage Example
// Simple usage: run the splash-screen sequence (e.g., from startup flow)
var sequence = new SplashScreenSequence();
using var cts = new CancellationTokenSource();
// Assuming `gameManager` is the current GameManager instance:
await sequence.Execute(gameManager, cts.Token);
// To cancel the sequence from elsewhere:
// cts.Cancel();