Skip to content

Game.SceneFlow.FullScreenOverlay

Assembly:
{{ YOUR_INFO: Assembly not specified in the provided file. This type is part of the game's SceneFlow code — include the mod assembly name or core game assembly when documenting for your project. }}

Namespace: Game.SceneFlow

Type: abstract class

Base: IScreenState

Summary:
{{ YOUR_INFO: FullScreenOverlay is a base class for full-screen overlay screen states (for example pause screens, modal dialogs, loading overlays) in the SceneFlow system. It centralizes common behavior such as named input actions (AnyKey / Continue / Cancel), a completion event, a done flag, and default display properties/priorities for continue/cancel actions. Subclasses provide the specific overlay type via the abstract overlayScreen property and implement the overlay lifecycle by overriding Execute. The class also offers HandleScreenChange which toggles input associations when the overlay becomes active or inactive. }}


Fields

  • protected const string kEngagementAnyKeyAction
    {{ YOUR_INFO: Constant string with value "AnyKey". Used to identify a general "any key" engagement action. }}

  • protected const string kEngagementContinueAction
    {{ YOUR_INFO: Constant string with value "Continue". Used to identify the continue/confirm action. }}

  • protected const string kEngagementCancelAction
    {{ YOUR_INFO: Constant string with value "Cancel". Used to identify the cancel/back action. }}

  • protected Action m_CompletedEvent
    {{ YOUR_INFO: Protected event-like delegate that derived classes can invoke when the overlay finishes. Consumers can attach handlers to be notified of completion. }}

  • protected bool m_Done
    {{ YOUR_INFO: Flag indicating the overlay has finished/should be closed. Derived classes typically set this to true when the overlay's work is complete. }}

Properties

  • protected abstract OverlayScreen overlayScreen { get; }
    {{ YOUR_INFO: Required override in derived classes to indicate which OverlayScreen enum value this overlay represents (e.g., OverlayScreen.Pause). Used by HandleScreenChange to detect activation. }}

  • protected virtual string actionA { get; }
    {{ YOUR_INFO: Default action name for the primary action. Returns "Continue" by default. Subclasses can override to change the action used for the primary engagement. }}

  • protected virtual string actionB { get; }
    {{ YOUR_INFO: Default action name for the secondary action. Returns "Cancel" by default. Subclasses can override to change the action used for the secondary engagement. }}

  • protected virtual string continueDisplayProperty { get; }
    {{ YOUR_INFO: Optional UI display property name for the continue action. Default is null. Override to provide a localized display string or property key. }}

  • protected virtual string cancelDisplayProperty { get; }
    {{ YOUR_INFO: Optional UI display property name for the cancel action. Default is null. Override to provide a localized display string or property key. }}

  • protected virtual int continueDisplayPriority { get; }
    {{ YOUR_INFO: Display priority for the continue action. Default is 20. Can be overridden to influence ordering/visibility in UI. }}

  • protected virtual int cancelDisplayPriority { get; }
    {{ YOUR_INFO: Display priority for the cancel action. Default is 20. Can be overridden to influence ordering/visibility in UI. }}

Constructors

  • public FullScreenOverlay()
    {{ YOUR_INFO: No explicit constructor is declared in the source file; a default parameterless constructor is provided by the compiler. As an abstract class, it is intended to be subclassed. }}

Methods

  • protected virtual bool HandleScreenChange(OverlayScreen screen)
    {{ YOUR_INFO: Called to handle changes to the active overlay screen. If the provided screen equals this.overlayScreen, input is disassociated from the player (InputManager.instance.AssociateActionsWithUser(false)) so overlay actions are not bound to the normal player input. If the screen is OverlayScreen.None or OverlayScreen.Loading, input association is restored (AssociateActionsWithUser(true)). Returns true when the provided screen matches this.overlayScreen (i.e., the overlay is active). This method can be overridden by subclasses to customize activation behavior. }}

  • public abstract Task Execute(GameManager manager, CancellationToken token)
    {{ YOUR_INFO: The main lifecycle method that derived classes must implement. Execute should contain the overlay's asynchronous logic (show UI, wait for user input or other conditions, set m_Done and/or invoke m_CompletedEvent when finished). The CancellationToken should be observed to support cancellation by the caller. }}

Usage Example

public class PauseOverlay : FullScreenOverlay
{
    protected override OverlayScreen overlayScreen => OverlayScreen.Pause;

    // Optionally override displays/priorities:
    protected override string continueDisplayProperty => "HUD_CONTINUE";
    protected override string cancelDisplayProperty => "HUD_EXIT_TO_MENU";

    public override async Task Execute(GameManager manager, CancellationToken token)
    {
        // Example: mark overlay as active, wait until done or canceled.
        m_Done = false;

        // Optionally subscribe to completion
        m_CompletedEvent += () => Console.WriteLine("Pause overlay completed.");

        // Simple loop that waits until m_Done is set or cancellation requested.
        while (!m_Done && !token.IsCancellationRequested)
        {
            // Let the scheduler run other tasks / frames
            await Task.Yield();

            // Keep input association state in sync with the manager's current overlay.
            HandleScreenChange(manager.CurrentOverlay);
        }

        // Notify listeners
        m_CompletedEvent?.Invoke();
    }
}

{{ YOUR_INFO: The example shows how to implement a concrete full-screen overlay. In a real mod, you would show/hide UI elements, register input handlers for actionA/actionB (using names like kEngagementContinueAction / kEngagementCancelAction or the actionA/actionB properties), and set m_Done when the user confirms/cancels. Always honor the CancellationToken and use HandleScreenChange to let the base class manage input association state. }}