muffin v6.12
This commit is contained in:
parent
060278c1b7
commit
155fbee291
59 changed files with 40083 additions and 58104 deletions
|
@ -14,8 +14,12 @@ using Dalamud.Plugin.Services;
|
|||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Character;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Control;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Fate;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Object;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.UI;
|
||||
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
||||
using FFXIVClientStructs.FFXIV.Client.System.String;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
using LLib.GameUI;
|
||||
|
@ -540,4 +544,73 @@ internal sealed class GameFunctions
|
|||
_logger.LogInformation("Unlocked unlock links: {UnlockedUnlockLinks}", string.Join(", ", list));
|
||||
return list;
|
||||
}
|
||||
|
||||
public unsafe bool SyncToFate(uint fateId)
|
||||
{
|
||||
IPlayerCharacter localPlayer = _clientState.LocalPlayer;
|
||||
if (localPlayer == null)
|
||||
{
|
||||
_logger.LogWarning("Cannot sync to FATE: LocalPlayer is null");
|
||||
return false;
|
||||
}
|
||||
FateManager* ptr = FateManager.Instance();
|
||||
if (ptr == null || ptr->CurrentFate == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
FateContext* currentFate = ptr->CurrentFate;
|
||||
byte maxLevel = currentFate->MaxLevel;
|
||||
if (localPlayer.Level <= maxLevel)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Syncing to FATE {FateId} (max level {MaxLevel})", currentFate->FateId, maxLevel);
|
||||
ExecuteCommand("/lsync");
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
_logger.LogError(exception, "Failed to sync to FATE {FateId}", fateId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe ushort GetCurrentFateId()
|
||||
{
|
||||
FateManager* ptr = FateManager.Instance();
|
||||
if (ptr == null || ptr->CurrentFate == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return ptr->CurrentFate->FateId;
|
||||
}
|
||||
|
||||
private unsafe void ExecuteCommand(string command)
|
||||
{
|
||||
try
|
||||
{
|
||||
UIModule* uIModule = Framework.Instance()->GetUIModule();
|
||||
if (uIModule == null)
|
||||
{
|
||||
_logger.LogError("UIModule is null, cannot execute command: {Command}", command);
|
||||
return;
|
||||
}
|
||||
Utf8String utf8String = new Utf8String(command);
|
||||
try
|
||||
{
|
||||
uIModule->ProcessChatBoxEntry(&utf8String, (nint)utf8String.StringLength);
|
||||
_logger.LogDebug("Executed chat command: {Command}", command);
|
||||
}
|
||||
finally
|
||||
{
|
||||
((IDisposable)utf8String/*cast due to .constrained prefix*/).Dispose();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
_logger.LogError(exception, "Failed to execute command: {Command}", command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue