mirror of
https://github.com/gwdevhub/Daybreak.git
synced 2026-07-15 15:19:57 +00:00
97fed608d2
* Improve GWCA bindings generator based on headers * Move all structs to gwca * Progress * Complete parser work * More generator adjustments * GWCA fixes * GWCA improvements * GWCA fixes * GWCA fixes * GWCA fixes * GWCA fixes * Fix API usage of GWCA * Update GWCA --------- Co-authored-by: Alexandru Macocian <amacocian@microsoft.com>
38 lines
1.4 KiB
C#
38 lines
1.4 KiB
C#
using Daybreak.API.Services.Interop;
|
|
using Daybreak.Shared.Models.Api;
|
|
using System.Core.Extensions;
|
|
using System.Extensions.Core;
|
|
|
|
namespace Daybreak.API.Services;
|
|
|
|
public sealed class LoginService(
|
|
GameThreadService gameThreadService,
|
|
GameContextService gameContextService,
|
|
ILogger<LoginService> logger)
|
|
{
|
|
private readonly GameThreadService gameThreadService = gameThreadService.ThrowIfNull();
|
|
private readonly GameContextService gameContextService = gameContextService.ThrowIfNull();
|
|
private readonly ILogger<LoginService> logger = logger.ThrowIfNull();
|
|
|
|
public Task<LoginInfo?> GetLoginInformation(CancellationToken cancellationToken)
|
|
{
|
|
var scopedLogger = this.logger.CreateScopedLogger();
|
|
return this.gameThreadService.QueueOnGameThread(() =>
|
|
{
|
|
unsafe
|
|
{
|
|
var gameContext = this.gameContextService.GetGameContext();
|
|
if (gameContext.IsNull || gameContext.Pointer->Character is null)
|
|
{
|
|
scopedLogger.LogError("Game context is not initialized");
|
|
return default;
|
|
}
|
|
|
|
var playerName = new string(gameContext.Pointer->Character->PlayerName);
|
|
var email = new string(gameContext.Pointer->Character->PlayerEmail);
|
|
return new LoginInfo(email, playerName);
|
|
}
|
|
}, cancellationToken);
|
|
}
|
|
}
|