using System; using Microsoft.Xna.Framework; namespace MonoGame.Extended.Screens; /// /// Represents an abstract base class for game screens that can be managed by a . /// /// /// /// Screens provide a way to organize game logic into discrete states such as menus, gameplay, loading screens, /// or different game areas. /// /// /// When screen are used with a , multiple screens can be active /// simultaneously in the manager's screen stack based on their and /// properties. /// /// public abstract class Screen : IDisposable { /// /// Gets the that manages this screen or if the /// screen is not managed. /// public ScreenManager ScreenManager { get; internal set; } /// /// Gets a value indicating whether this screen is currently the active screen. /// public bool IsActive { get; internal set; } /// /// Gets or sets a value indicating whether this screen should continue to update when it is not the active screen. /// /// /// This property allows background screens to continue processing logic even when they are not the topmost /// screen in the screen stack of a screen manager. This is useful for scenarios were persistent game systems /// should run regardless of screen state. /// public bool UpdateWhenInactive { get; set; } /// /// Gets or sets a value indicating whether this screen should continue to draw when it is not the active screen. /// /// /// This property allows background screens to continue rendering even when they are not the topmost screen /// in the screen stack of a screen manager. This is useful for creating layered visual effects where multiple /// screens nee dto be visible simultaneously such as a game world visible behind a semi-transparent menu or /// overlay. /// public bool DrawWhenInactive { get; set; } /// /// Releases all resources used by the screen. /// /// /// The base implementation does nothing. /// public virtual void Dispose() { } /// /// Initializes the screen. /// /// /// When the screen is added to a , this method will be called automatically /// when the screen is first shown. /// The base implementation does nothing. /// public virtual void Initialize() { } /// /// Loads content and resources needed by the screen. /// /// /// When the screen is added to a , this method will be called automatically /// after when the screen is first shown. /// The base implementation does nothing. /// public virtual void LoadContent() { } /// /// Unloads content and resources used by the screen. /// /// /// When the screen is added to a , this method is called automatically when /// the screen is closed. /// The base implementation does nothing. /// public virtual void UnloadContent() { } /// /// Updates the screen's logic. /// /// Provides a snapshot of timing values. /// /// When added to a , this method is called automatically every frame when /// either the or properties are . /// public abstract void Update(GameTime gameTime); /// /// Draws the screen's visual content. /// /// Provides a snapshot of timing values. /// /// When added to a , this method is called automatically every frame when /// either the or properties are . /// public abstract void Draw(GameTime gameTime); }