Class UnrealHookClient
Unreal Hook Client that uses protobuf to send and receive messages.
Inherited Members
Namespace: Microsoft.XboxStudios.UnrealToolkit.Bifrost.Proto.HookClient
Assembly: UnrealToolkit.Bifrost.Proto.HookClient.dll
Syntax
public class UnrealHookClient : IUnrealToolkitHookClient, IUnrealGameHooks, IUnrealPlayerHooks, IDisposable
Remarks
Initializes a new instance of the UnrealHookClient class.
Constructors
View SourceUnrealHookClient(IClient<IMessage>, ILogger<UnrealHookClient>)
Unreal Hook Client that uses protobuf to send and receive messages.
Declaration
public UnrealHookClient(IClient<IMessage> client, ILogger<UnrealHookClient> logger)
Parameters
Type | Name | Description |
---|---|---|
IClient<IMessage> | client | The client to use to connect to the game application. |
ILogger<UnrealHookClient> | logger | The logger for this class. |
Remarks
Initializes a new instance of the UnrealHookClient class.
Properties
View SourceClient
Gets the Bifrost protobuf client used to execute hooks and listen to game events.
Declaration
public IClient<IMessage> Client { get; }
Property Value
Type | Description |
---|---|
IClient<IMessage> |
Logger
Gets the logger.
Declaration
protected ILogger<UnrealHookClient> Logger { get; }
Property Value
Type | Description |
---|---|
ILogger<UnrealHookClient> |
Methods
View SourceConnectAsync(CancellationToken)
Connects the hook client if necessary.
Declaration
public Task ConnectAsync(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | A cancellation token for the operation. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public virtual void Dispose()
ExecuteCommandAsync(string, CancellationToken)
Executes a console command in the game client.
Declaration
public Task<string> ExecuteCommandAsync(string command, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | command | Command to execute (includes arguments). |
CancellationToken | cancellationToken | A cancellation token for the operation. |
Returns
Type | Description |
---|---|
Task<string> | Output of the command (if any). |
GetActorPropertiesAsync(string?, string?, IEnumerable<string>, CancellationToken)
Retrieves property values for all actors matching the given query.
Declaration
public Task<IEnumerable<(string ResultClass, string ResultName, KeyValuePair<string, object> Properties)>> GetActorPropertiesAsync(string? className, string? objectName, IEnumerable<string> properties, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | className | The class name of actors to look for. |
string | objectName | The name of actors to look for. |
IEnumerable<string> | properties | The properties to retrieve. |
CancellationToken | cancellationToken | A cancellation token for the operation. |
Returns
Type | Description |
---|---|
Task<IEnumerable<(string ResultClass, string ResultName, KeyValuePair<string, object> Properties)>> | A Task that contains an enumeration of each matching actor and property value. |
GetAutoCompleteCommandsAsync(CancellationToken)
Gets the auto complete data from the console in game.
Declaration
public Task<IEnumerable<(string Command, string Description)>> GetAutoCompleteCommandsAsync(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | A cancellation token for the operation. |
Returns
Type | Description |
---|---|
Task<IEnumerable<(string Command, string Description)>> | List of console commands from the console auto complete. |
GetCurrentMapAsync(CancellationToken)
Get some data of the current map.
Declaration
public Task<(string Name, string Url)> GetCurrentMapAsync(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | A cancellation token for the operation. |
Returns
Type | Description |
---|---|
Task<(string Name, string Url)> | Data of the current map. |
GetObjectPropertiesAsync(string?, string?, IEnumerable<string>, CancellationToken)
Retrieves property values for all objects matching the given query.
Declaration
public Task<IEnumerable<(string ResultClass, string ResultName, KeyValuePair<string, object> Properties)>> GetObjectPropertiesAsync(string? className, string? objectName, IEnumerable<string> properties, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | className | The class name of objects to look for. |
string | objectName | The name of objects to look for. |
IEnumerable<string> | properties | The properties to retrieve. |
CancellationToken | cancellationToken | A cancellation token for the operation. |
Returns
Type | Description |
---|---|
Task<IEnumerable<(string ResultClass, string ResultName, KeyValuePair<string, object> Properties)>> | A Task that contains an enumeration of each matching object and property value. |
GetPlayerLocationAsync(int, CancellationToken)
Get the location of the player in the specified index.
Declaration
public Task<Vector3> GetPlayerLocationAsync(int index, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
int | index | Index of the player. |
CancellationToken | cancellationToken | A cancellation token for the operation. |
Returns
Type | Description |
---|---|
Task<Vector3> | Location of the player. |
GetPlayerRotationAsync(int, CancellationToken)
Get the rotation of the player in the specified index.
Declaration
public Task<Rotation3> GetPlayerRotationAsync(int index, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
int | index | Index of the player. |
CancellationToken | cancellationToken | A cancellation token for the operation. |
Returns
Type | Description |
---|---|
Task<Rotation3> | Rotation of the player. |
GetScreenshotAsync(bool, CancellationToken)
Gets a screenshot which was previously captured via TakeScreenshotAsync(bool, CancellationToken).
Declaration
public Task<(int Width, int Height, byte[] Image)> GetScreenshotAsync(bool keepData = false, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
bool | keepData | Whether or not to delete the captured data and free game memory. |
CancellationToken | cancellationToken | A cancellation token for the operation. |
Returns
Type | Description |
---|---|
Task<(int Width, int Height, byte[] Image)> | The screenshot width, height, and data in RGB 3 bytes-per-pixel format. |
LoadMapAsync(string, CancellationToken)
Load the specified map.
Declaration
public Task LoadMapAsync(string mapFilePath, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | mapFilePath | The path to the map. |
CancellationToken | cancellationToken | A cancellation token for the operation. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
SetPlayerLocationAsync(int, Vector3, CancellationToken)
Set the location of the player in the specified index.
Declaration
public Task SetPlayerLocationAsync(int index, Vector3 location, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
int | index | Index of the player. |
Vector3 | location | New location. |
CancellationToken | cancellationToken | A cancellation token for the operation. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
SetPlayerRotationAsync(int, Rotation3, CancellationToken)
Set the rotation of the player in the specified index.
Declaration
public Task SetPlayerRotationAsync(int index, Rotation3 rotation, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
int | index | Index of the player. |
Rotation3 | rotation | New rotation. |
CancellationToken | cancellationToken | A cancellation token for the operation. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
TakeAndGetScreenshotAsync(bool, bool, CancellationToken)
Takes and retrieves a screenshot of the game client viewport.
Declaration
public Task<(int Width, int Height, byte[] Image)> TakeAndGetScreenshotAsync(bool showUI = false, bool keepData = false, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
bool | showUI | Whether or not to show game UI and messages. This controls Unreal's UI and custom UI may not be affected. |
bool | keepData | Whether or not to delete the captured data and free game memory. |
CancellationToken | cancellationToken | A cancellation token for the operation. |
Returns
Type | Description |
---|---|
Task<(int Width, int Height, byte[] Image)> | The screenshot width, height, and data in RGB 3 bytes-per-pixel format. |
TakeScreenshotAsync(bool, CancellationToken)
Takes a screenshot of the game client viewport.
Declaration
public Task TakeScreenshotAsync(bool showUI = false, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
bool | showUI | Whether or not to show game UI and messages. This controls Unreal's UI and custom UI may not be affected. |
CancellationToken | cancellationToken | A cancellation token for the operation. |
Returns
Type | Description |
---|---|
Task | A Task that completes when the screenshot has been taken. |
TeleportPlayerAsync(int, Vector3, Rotation3, bool, CancellationToken)
Teleport the player in the specified index to a certain location
and rotation in the current map.
SetPlayerLocationAndRotation
, this method
can check for clipping issues.
Declaration
public Task TeleportPlayerAsync(int index, Vector3 location, Rotation3 rotation, bool enforceNotClipping, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
int | index | Index of the player to teleport. |
Vector3 | location | Location to teleport the player to. |
Rotation3 | rotation | Rotation to place the player in. |
bool | enforceNotClipping | Indicates if the teleport should be done no matter what. If set to true the engine will look for and adjust or fail due to clipping issues. If set to false, clipping issues may happen. |
CancellationToken | cancellationToken | A cancellation token for the operation. |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |