using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; namespace MonoGame.Extended.Screens; /// /// Provides an abstract base class for game screens that require access to core game services and components. /// /// /// /// The class extends by providing convenient access to commonly /// used game services such as the content manager, graphics device, and service container. This eliminates /// the need for derived screens to manually access these services through the game instance. /// /// public abstract class GameScreen : Screen { /// /// Gets the game instance associated with this screen that provides access to core services and components. /// public Game Game { get; } /// /// Gets the content manager for loading game assets. /// public ContentManager Content => Game.Content; /// /// Gets the graphics device for rendering operations. /// public GraphicsDevice GraphicsDevice => Game.GraphicsDevice; /// /// Gets the service container for accessing registered game services. /// public GameServiceContainer Services => Game.Services; /// /// Initializes a new instance of the class. /// /// The game instance that provides access to core services. /// /// Thrown when is . /// protected GameScreen(Game game) { ArgumentNullException.ThrowIfNull(game); Game = game; } }