using System; using System.Collections.Generic; using FFXIVClientStructs.FFXIV.Client.Game.Control; using FFXIVClientStructs.FFXIV.Client.Game.UI; using InteropGenerator.Runtime; namespace LLib.GameData; public static class PlayerStateHelper { public unsafe static string GetCharacterName() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return string.Empty; } return ptr->CharacterNameString; } public unsafe static string GetOnlineId() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return string.Empty; } return ptr->OnlineIdString; } public unsafe static byte GetCurrentClassJobId() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0; } return ptr->CurrentClassJobId; } public unsafe static byte GetRace() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0; } return ptr->Race; } public unsafe static byte GetSex() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0; } return ptr->Sex; } public unsafe static byte GetTribe() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0; } return ptr->Tribe; } public unsafe static byte GetMaxExpansion() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0; } return ptr->MaxExpansion; } public unsafe static byte GetStartTown() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0; } return ptr->StartTown; } public unsafe static byte GetFirstClass() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0; } return ptr->FirstClass; } public unsafe static short GetClassJobLevel(int expArrayIndex) { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0; } return ptr->ClassJobLevels[expArrayIndex]; } public unsafe static int GetClassJobExperience(int expArrayIndex) { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0; } return ptr->ClassJobExperience[expArrayIndex]; } public unsafe static uint GetFreeAetheryteId() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0u; } return ptr->FreeAetheryteId; } public unsafe static uint GetFreeAetherytePSPlusId() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0u; } return ptr->FreeAetherytePSPlus; } public unsafe static uint GetFreeAetheryteNSOId() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0u; } return ptr->FreeAetheryteNSO; } public static bool IsFreeAetheryte(uint aetheryteId) { if (GetFreeAetheryteId() != aetheryteId && GetFreeAetherytePSPlusId() != aetheryteId) { return GetFreeAetheryteNSOId() == aetheryteId; } return true; } public unsafe static bool IsFavouriteAetheryte(uint aetheryteId) { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return false; } for (int i = 0; i < ptr->FavouriteAetheryteCount; i++) { if (ptr->FavouriteAetherytes[i] == aetheryteId) { return true; } } return false; } public unsafe static List GetFavouriteAetherytes() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return new List(); } List list = new List(); for (int i = 0; i < ptr->FavouriteAetheryteCount; i++) { ushort num = ptr->FavouriteAetherytes[i]; if (num != 0) { list.Add(num); } } return list; } public unsafe static uint GetHomeAetheryteId() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0u; } return ptr->HomeAetheryteId; } public unsafe static bool HasFavouriteSlotAvailable() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return false; } for (int i = 0; i < ptr->FavouriteAetheryteCount; i++) { if (ptr->FavouriteAetherytes[i] == 0) { return true; } } return false; } public unsafe static bool IsMentor() { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsMentor(); } return false; } public unsafe static bool IsBattleMentor() { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsBattleMentor(); } return false; } public unsafe static bool IsTradeMentor() { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsTradeMentor(); } return false; } public unsafe static bool IsNovice() { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsNovice(); } return false; } public unsafe static bool IsReturner() { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsReturner(); } return false; } public unsafe static byte GetMentorVersion() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0; } return ptr->MentorVersion; } public unsafe static bool IsPlayerStateFlagSet(PlayerStateFlag flag) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsPlayerStateFlagSet(flag); } return false; } public unsafe static byte GetBeastTribeRank(byte alliedSocietyId) { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0; } return ptr->GetBeastTribeRank(alliedSocietyId); } public unsafe static int GetCurrentPose(EmoteController.PoseType poseType) { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0; } return ptr->CurrentPose(poseType); } public unsafe static byte GetGoldSaucerContentStatus() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0; } return ptr->GoldSaucerContentStatus; } public unsafe static uint GetActiveFestivalId(int index) { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0u; } return ptr->ActiveFestivalIds[index]; } public unsafe static uint GetActiveFestivalPhase(int index) { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0u; } return ptr->ActiveFestivalPhases[index]; } public unsafe static bool IsMeister(uint classJobId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsMeisterFlag(classJobId); } return false; } public unsafe static bool IsMeisterWithSoulStone(uint classJobId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsMeisterFlagAndHasSoulStoneEquipped(classJobId); } return false; } public unsafe static bool IsMeisterMaxCount() { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsMeisterFlagMaxCount(); } return false; } public unsafe static byte GetMeisterFlag() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0; } return ptr->MeisterFlag; } public unsafe static byte GetDeliveryLevel() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0; } return ptr->DeliveryLevel; } public unsafe static int GetPenaltyTimestamp(int index) { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0; } return ptr->PenaltyTimestamps[index]; } public static int GetDutyFinderPenaltyTimestamp() { return GetPenaltyTimestamp(0); } public unsafe static bool IsMountUnlocked(uint mountId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsMountUnlocked(mountId); } return false; } public unsafe static bool IsAnyMountUnlocked() { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->NumOwnedMounts > 0; } return false; } public unsafe static bool IsOrnamentUnlocked(uint ornamentId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsOrnamentUnlocked(ornamentId); } return false; } public unsafe static bool IsGlassesUnlocked(ushort glassesId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsGlassesUnlocked(glassesId); } return false; } public unsafe static bool IsOrchestrionRollUnlocked(uint rollId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsOrchestrionRollUnlocked(rollId); } return false; } public unsafe static bool IsFramersKitUnlocked(uint kitId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsFramersKitUnlocked(kitId); } return false; } public unsafe static bool IsMcGuffinUnlocked(uint id) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsMcGuffinUnlocked(id); } return false; } public unsafe static bool IsDungeonCompleted(uint dungeonId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->CompletedDungeonsBitArray, dungeonId); } return false; } public unsafe static bool IsRaidCompleted(uint raidId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->CompletedRaidsBitArray, raidId); } return false; } public unsafe static bool IsTrialCompleted(uint trialId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->CompletedTrialsBitArray, trialId); } return false; } public unsafe static bool IsFrontlineCompleted(uint frontlineId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->CompletedFrontlinesBitArray, frontlineId); } return false; } public unsafe static bool IsCrystallineConflictCompleted(uint id) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->CompletedCrystallineConflictsBitArray, id); } return false; } public unsafe static bool IsGuildOrderCompleted(uint orderId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->CompletedGuildOrdersBitArray, orderId); } return false; } public unsafe static bool IsMaskedCarnivaleCompleted(uint stageId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->CompletedMaskedCarnivaleBitArray, stageId); } return false; } public unsafe static bool IsMiscContentCompleted(uint contentId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->CompletedMiscContentBitArray, contentId); } return false; } public unsafe static bool IsBeginnerTrainingCompleted(uint trainingId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->CompletedBeginnerTrainingBitArray, trainingId); } return false; } public unsafe static bool IsVVDNotebookContentCompleted(uint contentId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->CompletedVVDNotebookContentsBitArray, contentId); } return false; } public unsafe static bool IsDungeonUnlocked(uint dungeonId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->UnlockedDungeonsBitArray, dungeonId); } return false; } public unsafe static bool IsRaidUnlocked(uint raidId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->UnlockedRaidsBitArray, raidId); } return false; } public unsafe static bool IsTrialUnlocked(uint trialId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->UnlockedTrialsBitArray, trialId); } return false; } public unsafe static bool IsFrontlineUnlocked(uint frontlineId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->UnlockedFrontlinesBitArray, frontlineId); } return false; } public unsafe static bool IsCrystallineConflictUnlocked(uint id) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->UnlockedCrystallineConflictsBitArray, id); } return false; } public unsafe static bool IsGuildOrderUnlocked(uint orderId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->UnlockedGuildOrdersBitArray, orderId); } return false; } public unsafe static bool IsMiscContentUnlocked(uint contentId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->UnlockedMiscContentBitArray, contentId); } return false; } public unsafe static bool IsSpecialContentUnlocked(uint contentId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->UnlockedSpecialContentBitArray, contentId); } return false; } public unsafe static bool IsFishCaught(uint fishId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsFishCaught(fishId); } return false; } public unsafe static bool IsSpearfishCaught(uint fishId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsSpearfishCaught(fishId); } return false; } public unsafe static bool IsFishingSpotUnlocked(uint spotId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->UnlockedFishingSpotsBitArray, spotId); } return false; } public unsafe static bool IsSpearfishingNotebookUnlocked(uint notebookId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->UnlockedSpearfishingNotebooksBitArray, notebookId); } return false; } public unsafe static bool IsSecretRecipeBookUnlocked(uint bookId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsSecretRecipeBookUnlocked(bookId); } return false; } public unsafe static bool IsFolkloreBookUnlocked(uint bookId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsFolkloreBookUnlocked(bookId); } return false; } public unsafe static bool IsAdventureComplete(uint adventureId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsAdventureComplete(adventureId); } return false; } public unsafe static bool IsBotanistFolkloreTomeUnlocked(uint tomeId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->UnlockedBotanistFolkloreTomesBitArray, tomeId); } return false; } public unsafe static bool IsMinerFolkloreTomeUnlocked(uint tomeId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->UnlockedMinerFolkloreTomesBitArray, tomeId); } return false; } public unsafe static bool IsFishingFolkloreTomeUnlocked(uint tomeId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return GetBitSafe(ptr->UnlockedFishingFolkloreTomesBitArray, tomeId); } return false; } public unsafe static bool IsAetherCurrentUnlocked(uint aetherCurrentId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsAetherCurrentUnlocked(aetherCurrentId); } return false; } public unsafe static bool IsAetherCurrentZoneComplete(uint compFlgSetId) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsAetherCurrentZoneComplete(compFlgSetId); } return false; } public unsafe static bool IsWeeklyBingoExpired() { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsWeeklyBingoExpired(); } return false; } public unsafe static long GetWeeklyBingoExpireTimestamp() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0L; } return ptr->GetWeeklyBingoExpireUnixTimestamp(); } public unsafe static DateTime GetWeeklyBingoExpireDateTime() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return DateTime.MinValue; } return ptr->WeeklyBingoExpireDateTime; } public unsafe static uint GetWeeklyBingoExpMultiplier() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0u; } return ptr->GetWeeklyBingoExpMultiplier(); } public unsafe static PlayerState.WeeklyBingoTaskStatus GetWeeklyBingoTaskStatus(int index) { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return PlayerState.WeeklyBingoTaskStatus.Open; } return ptr->GetWeeklyBingoTaskStatus(index); } public unsafe static bool IsWeeklyBingoStickerPlaced(int index) { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->IsWeeklyBingoStickerPlaced(index); } return false; } public unsafe static int GetWeeklyBingoNumPlacedStickers() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0; } return ptr->WeeklyBingoNumPlacedStickers; } public unsafe static uint GetWeeklyBingoNumSecondChancePoints() { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0u; } return ptr->WeeklyBingoNumSecondChancePoints; } public unsafe static bool HasWeeklyBingoJournal() { PlayerState* ptr = PlayerState.Instance(); if (ptr != null) { return ptr->HasWeeklyBingoJournal; } return false; } public unsafe static bool IsRouletteComplete(byte rouletteId) { InstanceContent* ptr = InstanceContent.Instance(); if (ptr != null) { return ptr->IsRouletteComplete(rouletteId); } return false; } public unsafe static uint GetContentValue(uint key) { PlayerState* ptr = PlayerState.Instance(); if (ptr == null) { return 0u; } return ptr->GetContentValue(key); } private static bool GetBitSafe(BitArray bitArray, uint index) { bool value; return bitArray.TryGet((int)index, out value) && value; } }