Application

Static class managing application state and configuration.

using Xengine.Core;

Properties

PropertyTypeDescription
NamestringApplication name
VersionstringApplication version
IsInitializedboolTrue after Initialize() called
IsRunningboolTrue while engine is running
IsEditorboolTrue if running in editor
IsHeadlessboolTrue if running without display
IsDebugboolTrue if debug mode enabled
IsFocusedboolTrue if window has focus
WantsExitboolTrue if exit requested
DataPathstringPath to data directory
ConfigPathstringPath to config directory

Events

EventDescription
OnInitializeFired after initialization
OnShutdownFired before shutdown
OnFocusChangedFired when window focus changes

Methods

Initialize

public static void Initialize(ApplicationConfig config)

Initialize the application with the given configuration.

RequestExit

public static void RequestExit()

Request application to exit gracefully.

if (RaylibInput.IsKeyPressed(KeyCode.Escape))
    Application.RequestExit();

Shutdown

public static void Shutdown()

Shutdown the application immediately.

ApplicationConfig

Configuration class for initializing the application:

PropertyTypeDefaultDescription
Namestring?nullApplication name
DataPathstring?nullCustom data directory
ConfigPathstring?nullCustom config directory
IsEditorboolfalseRunning in editor mode
IsHeadlessboolfalseNo display mode
IsDebugboolfalseEnable debug features
TargetFrameRateint60Target FPS
VSyncbooltrueEnable V-Sync
WindowWidthint1280Window width in pixels
WindowHeightint720Window height in pixels
WindowTitlestring"Xengine"Window title
FullscreenboolfalseFullscreen mode

Example

var config = new ApplicationConfig
{
    Name = "My Game",
    WindowWidth = 1920,
    WindowHeight = 1080,
    WindowTitle = "My Awesome Game",
    IsDebug = true
};

using var engine = new Engine(config);
engine.Initialize();

// Application is now initialized
Log.Info($"Running: {Application.Name}");
Log.Info($"Data path: {Application.DataPath}");

engine.Run();