Dalamud v12
#Dalamud #XIVLauncher #FF14
What's New in Dalamud v12 (draft) | Dalamud
リリース日: Patch 7.2 (2025/4)
Dalamud API Level 12 の破壊的変更
! 実行中のスレッドの assertion が入った
IObjectTable 自体や IClientState のいくつかのフィールド (IClientState.LocalPlayer など) はメインスレッドからのみ触れるように制約が追加された
上記にアクセスするには、(たぶん) ゲームのメインスレッドで動かす必要がある
AetheryteLinkInChat も壊れた
AetheryteLinkInChat テレポが正常に動作しない · Issue #695 · SlashNephy/Divination
Dalamud API 12 ではメインスレッドで処理を実行するのにいくつか API が用意されていて、以下のものが使える
IFramework.Run
https://github.com/goatcorp/Dalamud/blob/81ced564d6f964321d6d6a59544ad12c01fefdaf/Dalamud/Game/Framework.cs#L134
Task の結果を await で取得してよい
渡す Action に async callback を渡せる
code:csharp
public async Task<bool> Teleport(Aetheryte aetheryte)
{
return await framework.Run(async () => await TeleportInternal(aetheryte));
}
特に async callback の中で await しないと、実行スレッドがメインスレッドに確定しないので注意が必要
IFramework.RunOnFrameworkThread
https://github.com/goatcorp/Dalamud/blob/81ced564d6f964321d6d6a59544ad12c01fefdaf/Dalamud/Game/Framework.cs#L166
Task の結果を await で取得してはいけない
渡す Action には async callback を使えない
code:csharp
private Task<bool> ExecuteTeleport(Aetheryte aetheryte)
{
return framework.RunOnFrameworkThread(() => ExecuteTeleportInternal(aetheryte));
}
RunOnFrameworkThread の返り値は await してはいけないので、.ContinueWith でチェインしていくことになる
code:csharp
ExecuteTeleport(aetheryte).ContinueWith(task =>
{
// task の結果に応じてなんかする
});
IFramework.RunOnTicks
https://github.com/goatcorp/Dalamud/blob/81ced564d6f964321d6d6a59544ad12c01fefdaf/Dalamud/Game/Framework.cs#L199
RunOnFrameworkThread と同じ性質を持つ
用途不明、RunOnFrameworkThread と比べると delay, delayTicks が増えているので、高度にスケジューリングしたいときに使いそう
こいつらの使い分けがむずい
IFramework interfaceや、それぞれの Run~ メソッドのコメントに思想が書いてある
https://github.com/goatcorp/Dalamud/blob/81ced564d6f964321d6d6a59544ad12c01fefdaf/Dalamud/Plugin/Services/IFramework.cs#L27