punish v6.8.18.0
This commit is contained in:
commit
e786325cda
322 changed files with 554232 additions and 0 deletions
53
LLib/LLib.GameUI/LAddon.cs
Normal file
53
LLib/LLib.GameUI/LAddon.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Dalamud.Game.NativeWrapper;
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
|
||||
namespace LLib.GameUI;
|
||||
|
||||
public static class LAddon
|
||||
{
|
||||
private const int UnitListCount = 18;
|
||||
|
||||
public unsafe static AtkUnitBase* GetAddonById(uint id)
|
||||
{
|
||||
AtkUnitList* ptr = &AtkStage.Instance()->RaptureAtkUnitManager->AtkUnitManager.DepthLayerOneList;
|
||||
for (int i = 0; i < 18; i++)
|
||||
{
|
||||
AtkUnitList* ptr2 = ptr + i;
|
||||
foreach (int item in Enumerable.Range(0, Math.Min(ptr2->Count, ptr2->Entries.Length)))
|
||||
{
|
||||
AtkUnitBase* value = ptr2->Entries[item].Value;
|
||||
if (value != null && value->Id == id)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public unsafe static bool TryGetAddonByName<T>(this IGameGui gameGui, string addonName, out T* addonPtr) where T : unmanaged
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(gameGui, "gameGui");
|
||||
ArgumentException.ThrowIfNullOrEmpty(addonName, "addonName");
|
||||
AtkUnitBasePtr addonByName = gameGui.GetAddonByName(addonName);
|
||||
if (!addonByName.IsNull)
|
||||
{
|
||||
addonPtr = (T*)addonByName.Address;
|
||||
return true;
|
||||
}
|
||||
addonPtr = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public unsafe static bool IsAddonReady(AtkUnitBase* addon)
|
||||
{
|
||||
if (addon->IsVisible)
|
||||
{
|
||||
return addon->UldManager.LoadedState == AtkLoadState.Loaded;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue