Table of Contents

Class GameSystemBase

Namespace
Stride.Games
Assembly
Stride.Games.dll

Base class for a Game System.

public abstract class GameSystemBase : ComponentBase, IDisposable, ICollectorHolder, IGameSystemBase, IComponent, IReferencable, IUpdateable, IDrawable, IContentable
Inheritance
object
GameSystemBase
Implements
Derived
Inherited Members
Extension Methods

Remarks

A Game System is a component that can be used to manage game logic, resources, or other systems within the Game. For example, it can be used to manage audio, input, or other subsystems.

Game Systems are typically added to the GameBase class and are initialized when the game starts. If the Game System needs to be updated or drawn, it can implement the IUpdateable and IDrawable interfaces respectively.

Constructors

GameSystemBase(IServiceRegistry)

Initializes a new instance of the GameSystemBase class.

protected GameSystemBase(IServiceRegistry registry)

Parameters

registry IServiceRegistry

The registry.

Remarks

The GameSystem is expecting the following services to be registered: IGame and IContentManager.

Properties

Content

Gets the content manager. This value can be null in a mock environment.

protected IContentManager? Content { get; }

Property Value

IContentManager

The content.

DrawOrder

Gets the draw order relative to other Game Components. IDrawable components with a lower value are drawn first.

public int DrawOrder { get; set; }

Property Value

int

Enabled

Gets a value indicating whether the game component's Update method should be called by Update(GameTime).

public bool Enabled { get; set; }

Property Value

bool

true if update is enabled; otherwise, false.

Game

Gets the Game associated with this GameSystemBase. This value can be null in a mock environment.

public GameBase? Game { get; }

Property Value

GameBase

The game.

Remarks

This value can be null

GraphicsDevice

Gets the Graphics Device.

protected GraphicsDevice GraphicsDevice { get; }

Property Value

GraphicsDevice

The Graphics Device. This can be null if it has not been initialized yet.

Services

Gets the services registry.

[NotNull]
public IServiceRegistry Services { get; }

Property Value

IServiceRegistry

The services registry.

UpdateOrder

Gets the update order relative to other game components. Lower values are updated first.

public int UpdateOrder { get; set; }

Property Value

int

The update order.

Visible

Gets a value indicating whether the Game Component's Draw(GameTime) method should be called by Draw(GameTime).

public bool Visible { get; set; }

Property Value

bool

true if the Game Component is visible and should be drawn; otherwise, false.

Methods

BeginDraw()

Starts the drawing of the Game Component. It prepares the drawable component for rendering and determines whether a following Draw(GameTime) and EndDraw() call should occur.

public virtual bool BeginDraw()

Returns

bool

true if Draw(GameTime) should be called; false otherwise.

Draw(GameTime)

Draws the Game Component.

public virtual void Draw(GameTime gameTime)

Parameters

gameTime GameTime

The current timing information.

EndDraw()

Ends the drawing of the Game Component.

public virtual void EndDraw()

Remarks

This method must be preceeded by calls to Draw(GameTime) and BeginDraw().

Exceptions

GraphicsDeviceException

The Game Device this Game Component is using to draw itself is not in a valid state to end drawing, or it is not available.

Initialize()

Initializes the Game System.

public virtual void Initialize()

Remarks

This method is called when the component is added to the Game. This can be used for tasks like querying for services the component needs and setting up non-graphics resources (as here the Graphics Device may have not been initialized yet).

InitializeGraphicsDeviceService()

Initializes the Graphics Device Service if it has not been initialized.

protected void InitializeGraphicsDeviceService()

Remarks

Upon returning from this method, the IGraphicsDeviceService may be available to get the GraphicsDevice, so that the Game System can use it if it is initialized.

LoadContent()

protected virtual void LoadContent()

OnDrawOrderChanged(object, EventArgs)

Method that is called when the DrawOrder property changes. Raises the DrawOrderChanged event.

protected virtual void OnDrawOrderChanged(object source, EventArgs e)

Parameters

source object

The source of the event.

e EventArgs

An EventArgs that contains the event data.

OnUpdateOrderChanged(object, EventArgs)

protected virtual void OnUpdateOrderChanged(object source, EventArgs e)

Parameters

source object
e EventArgs

UnloadContent()

protected virtual void UnloadContent()

Update(GameTime)

This method is called when this game component is updated.

public virtual void Update(GameTime gameTime)

Parameters

gameTime GameTime

The current timing.

Events

DrawOrderChanged

Occurs when the DrawOrder property changes.

public event EventHandler<EventArgs> DrawOrderChanged

Event Type

EventHandler<EventArgs>

EnabledChanged

Occurs when the Enabled property changes.

public event EventHandler<EventArgs> EnabledChanged

Event Type

EventHandler<EventArgs>

UpdateOrderChanged

Occurs when the UpdateOrder property changes.

public event EventHandler<EventArgs> UpdateOrderChanged

Event Type

EventHandler<EventArgs>

VisibleChanged

Occurs when the Visible property changes.

public event EventHandler<EventArgs> VisibleChanged

Event Type

EventHandler<EventArgs>