Table of Contents

Class GameManagerExtension

Namespace
Hi3Helper.Plugin.Core.Utility
Assembly
Hi3Helper.Plugin.Core.dll

This extension provides a method to launch the game using the plugin's game launch mechanism if available.

public static class GameManagerExtension
Inheritance
GameManagerExtension
Inherited Members

Remarks

This extension IS ONLY SUPPOSEDLY BE USED by the launcher, NOT by the plugin.

Methods

IsGameRunning(RunGameFromGameManagerContext, out bool, out DateTime, out Exception?)

Check if the game from the current IGameManager is running or not.

public static bool IsGameRunning(this GameManagerExtension.RunGameFromGameManagerContext context, out bool isGameRunning, out DateTime gameStartTime, out Exception? errorException)

Parameters

context GameManagerExtension.RunGameFromGameManagerContext

The context to launch the game from IGameManager.

isGameRunning bool

Whether the game is currently running or not.

gameStartTime DateTime

The date time stamp of when the process was started.

errorException Exception

Represents an exception from HRESULT of the plugin's function.

Returns

bool

To find the actual return value, please use isGameRunning out-argument.

Returns false if the plugin doesn't have game launch mechanism (or API Standard is equal or lower than v0.1.0).
Otherwise, true if the plugin supports game launch mechanism.

KillRunningGame(RunGameFromGameManagerContext, out bool, out DateTime, out Exception?)

Kill the process of the currently running game.

public static bool KillRunningGame(this GameManagerExtension.RunGameFromGameManagerContext context, out bool wasGameRunning, out DateTime gameStartTime, out Exception? errorException)

Parameters

context GameManagerExtension.RunGameFromGameManagerContext

The context to launch the game from IGameManager.

wasGameRunning bool

Whether to indicate that the game was running or not.

gameStartTime DateTime

The date time stamp of when the process was started.

errorException Exception

Represents an exception from HRESULT of the plugin's function.

Returns

bool

To find the actual return value, please use wasGameRunning out-argument.

Returns false if the plugin doesn't have game launch mechanism (or API Standard is equal or lower than v0.1.0).
Otherwise, true if the plugin supports game launch mechanism.

RunGameFromGameManagerAsync(RunGameFromGameManagerContext, string?, bool, ProcessPriorityClass, CancellationToken)

Asynchronously launch the game using plugin's built-in game launch mechanism and wait until the game exit.

public static Task<(bool IsSuccess, Exception? Error)> RunGameFromGameManagerAsync(this GameManagerExtension.RunGameFromGameManagerContext context, string? startArgument = null, bool isRunBoosted = false, ProcessPriorityClass processPriority = ProcessPriorityClass.Normal, CancellationToken token = default)

Parameters

context GameManagerExtension.RunGameFromGameManagerContext

The context to launch the game from IGameManager.

startArgument string

The additional argument string to run the game executable (Default: null).

isRunBoosted bool

Based on PriorityBoostEnabled, boost the process temporarily when the game window is focused (Default: false).

processPriority ProcessPriorityClass

Based on PriorityClass, run the game process with specific priority (Default: Normal).

token CancellationToken

Cancellation token to pass into the plugin's game launch mechanism.
If cancellation is requested, it will cancel the awaiting but not killing the game process.

Returns

Task<(bool IsSuccess, Exception Error)>

Returns IsSuccess=false if the plugin doesn't have game launch mechanism (or API Standard is equal or lower than v0.1.0), hence fallback to launcher's game launch mechanism.
Otherwise, IsSuccess=true if the plugin does support game launch mechanism and the game ran successfully or await process is cancelled.

StartResizableWindowHookAsync(RunGameFromGameManagerContext, string?, int?, int?, string?, CancellationToken)

Asynchronously hook to the game process making the window resizable and wait until the game exit.

public static Task<(bool IsSuccess, Exception? Error)> StartResizableWindowHookAsync(this GameManagerExtension.RunGameFromGameManagerContext context, string? executableName = null, int? height = null, int? width = null, string? executableDirectory = null, CancellationToken token = default)

Parameters

context GameManagerExtension.RunGameFromGameManagerContext

The context to launch the game from IGameManager.

executableName string

The name of the game executable.

height int?

Height of the host screen.

width int?

Width of the host screen.

executableDirectory string

The path to the directory where the game executable is located.

token CancellationToken

Cancellation token to pass into the plugin's game launch mechanism.
If cancellation is requested, it will cancel the awaiting but not killing the game process.

Returns

Task<(bool IsSuccess, Exception Error)>

Returns IsSupported.false if the plugin's API Standard is equal or lower than v0.1.3 or if this method isn't overriden.
Otherwise, IsSupported.true if the plugin supports game launch mechanism and this method.

WaitRunningGameAsync(RunGameFromGameManagerContext, CancellationToken)

Asynchronously wait currently running game until it exit.

public static Task<(bool IsSuccess, Exception? Error)> WaitRunningGameAsync(this GameManagerExtension.RunGameFromGameManagerContext context, CancellationToken token)

Parameters

context GameManagerExtension.RunGameFromGameManagerContext

The context to launch the game from IGameManager.

token CancellationToken

Cancellation token to pass into the plugin's game launch mechanism.
If cancellation is requested, it will cancel the awaiting but not killing the game process.

Returns

Task<(bool IsSuccess, Exception Error)>

Returns IsSuccess=false if the plugin doesn't have game launch mechanism (or API Standard is equal or lower than v0.1.0), hence fallback to launcher's game launch mechanism.
Otherwise, IsSuccess=true if the plugin does support game launch mechanism and the game ran successfully.