Class GameManagerExtension
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
contextGameManagerExtension.RunGameFromGameManagerContextThe context to launch the game from IGameManager.
isGameRunningboolWhether the game is currently running or not.
gameStartTimeDateTimeThe date time stamp of when the process was started.
errorExceptionExceptionRepresents an exception from HRESULT of the plugin's function.
Returns
- bool
To find the actual return value, please use
isGameRunningout-argument.Returns
falseif the plugin doesn't have game launch mechanism (or API Standard is equal or lower than v0.1.0).
Otherwise,trueif 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
contextGameManagerExtension.RunGameFromGameManagerContextThe context to launch the game from IGameManager.
wasGameRunningboolWhether to indicate that the game was running or not.
gameStartTimeDateTimeThe date time stamp of when the process was started.
errorExceptionExceptionRepresents an exception from HRESULT of the plugin's function.
Returns
- bool
To find the actual return value, please use
wasGameRunningout-argument.Returns
falseif the plugin doesn't have game launch mechanism (or API Standard is equal or lower than v0.1.0).
Otherwise,trueif 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
contextGameManagerExtension.RunGameFromGameManagerContextThe context to launch the game from IGameManager.
startArgumentstringThe additional argument string to run the game executable (Default: null).
isRunBoostedboolBased on PriorityBoostEnabled, boost the process temporarily when the game window is focused (Default: false).
processPriorityProcessPriorityClassBased on PriorityClass, run the game process with specific priority (Default: Normal).
tokenCancellationTokenCancellation 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=falseif 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=trueif 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
contextGameManagerExtension.RunGameFromGameManagerContextThe context to launch the game from IGameManager.
executableNamestringThe name of the game executable.
heightint?Height of the host screen.
widthint?Width of the host screen.
executableDirectorystringThe path to the directory where the game executable is located.
tokenCancellationTokenCancellation 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.falseif the plugin's API Standard is equal or lower than v0.1.3 or if this method isn't overriden.
Otherwise,IsSupported.trueif 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
contextGameManagerExtension.RunGameFromGameManagerContextThe context to launch the game from IGameManager.
tokenCancellationTokenCancellation 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=falseif 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=trueif the plugin does support game launch mechanism and the game ran successfully.