using Daybreak.API.Interop.GuildWars; using System.Diagnostics.CodeAnalysis; namespace Daybreak.API.Extensions; public static unsafe class GameContextExtensions { public static bool TryGetPlayerId( this WrappedPointer gameContext, [NotNullWhen(true)] out uint? playerId) { playerId = 0; if (gameContext.IsNull || gameContext.Pointer->WorldContext is null || gameContext.Pointer->WorldContext->PlayerControlledChar is null) { return false; } playerId = gameContext.Pointer->WorldContext->PlayerControlledChar->AgentId; return true; } public static bool TryGetBuildContext( this WrappedPointer gameContext, [NotNullWhen(true)] out GuildWarsArray? skillbars, [NotNullWhen(true)] out GuildWarsArray? attributes, [NotNullWhen(true)] out GuildWarsArray? professions, [NotNullWhen(true)] out GuildWarsArray? unlockedSkills) { skillbars = default; attributes = default; professions = default; unlockedSkills = default; if (gameContext.IsNull || gameContext.Pointer->WorldContext is null) { return false; } skillbars = gameContext.Pointer->WorldContext->Skillbars; attributes = gameContext.Pointer->WorldContext->Attributes; professions = gameContext.Pointer->WorldContext->Professions; unlockedSkills = gameContext.Pointer->WorldContext->UnlockedCharacterSkills; return true; } public static bool TryGetPlayerParty( this WrappedPointer gameContext, [NotNullWhen(true)] out uint? partyId, [NotNullWhen(true)] out GuildWarsArray? players, [NotNullWhen(true)] out GuildWarsArray? heroes, [NotNullWhen(true)] out GuildWarsArray? henchmen) { partyId = default; players = default; heroes = default; henchmen = default; if (gameContext.IsNull || gameContext.Pointer->PartyContext is null) { return false; } partyId = gameContext.Pointer->PartyContext->PlayerParty->PartyId; players = gameContext.Pointer->PartyContext->PlayerParty->Players; heroes = gameContext.Pointer->PartyContext->PlayerParty->Heroes; henchmen = gameContext.Pointer->PartyContext->PlayerParty->Henchmen; return true; } public static bool TryGetHeroFlags( this WrappedPointer gameContext, [NotNullWhen(true)]out GuildWarsArray? heroFlags) { heroFlags = default; if (gameContext.IsNull || gameContext.Pointer->WorldContext is null) { return false; } heroFlags = gameContext.Pointer->WorldContext->HeroFlags; return true; } public static bool TryGetAccountContext( this WrappedPointer gameContext, out WrappedPointer accountContext) { accountContext = default; if (gameContext.IsNull || gameContext.Pointer->AccountContext is null) { return false; } accountContext = gameContext.Pointer->AccountContext; return true; } }