fix gpose world stuff
This commit is contained in:
@@ -127,17 +127,18 @@ public sealed partial class CharaDataManager : DisposableMediatorSubscriberBase
|
||||
{
|
||||
return UiBlockingComputation = DataApplicationTask = Task.Run(async () =>
|
||||
{
|
||||
var charaName = await _dalamudUtilService.RunOnFrameworkThread(() => _dalamudUtilService.GposeTargetGameObject?.Name.TextValue).ConfigureAwait(false)
|
||||
?? string.Empty;
|
||||
var obj = await _dalamudUtilService.GetGposeTargetGameObjectAsync().ConfigureAwait(false);
|
||||
var charaName = obj?.Name.TextValue ?? string.Empty;
|
||||
if (string.IsNullOrEmpty(charaName)) return;
|
||||
|
||||
await ApplyCharaData(dataMetaInfoDto, charaName).ConfigureAwait(false);
|
||||
});
|
||||
}
|
||||
|
||||
public void ApplyOwnDataToGposeTarget(CharaDataFullExtendedDto dataDto)
|
||||
public async Task ApplyOwnDataToGposeTarget(CharaDataFullExtendedDto dataDto)
|
||||
{
|
||||
var charaName = _dalamudUtilService.GposeTargetGameObject?.Name.TextValue ?? string.Empty;
|
||||
var chara = await _dalamudUtilService.GetGposeTargetGameObjectAsync().ConfigureAwait(false);
|
||||
var charaName = chara?.Name.TextValue ?? string.Empty;
|
||||
CharaDataDownloadDto downloadDto = new(dataDto.Id, dataDto.Uploader)
|
||||
{
|
||||
CustomizeData = dataDto.CustomizeData,
|
||||
@@ -164,7 +165,7 @@ public sealed partial class CharaDataManager : DisposableMediatorSubscriberBase
|
||||
{
|
||||
return UiBlockingComputation = Task.Run(async () =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(pose.PoseData) || !CanApplyInGpose(out _)) return;
|
||||
if (string.IsNullOrEmpty(pose.PoseData) || !(await CanApplyInGpose().ConfigureAwait(false)).CanApply) return;
|
||||
var gposeChara = await _dalamudUtilService.GetGposeCharacterFromObjectTableByNameAsync(targetName, true).ConfigureAwait(false);
|
||||
if (gposeChara == null) return;
|
||||
|
||||
@@ -179,9 +180,11 @@ public sealed partial class CharaDataManager : DisposableMediatorSubscriberBase
|
||||
{
|
||||
return UiBlockingComputation = Task.Run(async () =>
|
||||
{
|
||||
if (CanApplyInGpose(out var chara))
|
||||
var apply = await CanApplyInGpose().ConfigureAwait(false);
|
||||
|
||||
if (apply.CanApply)
|
||||
{
|
||||
await ApplyPoseData(pose, chara).ConfigureAwait(false);
|
||||
await ApplyPoseData(pose, apply.TargetName).ConfigureAwait(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -190,7 +193,8 @@ public sealed partial class CharaDataManager : DisposableMediatorSubscriberBase
|
||||
{
|
||||
return UiBlockingComputation = Task.Run(async () =>
|
||||
{
|
||||
if (pose.WorldData == default || !CanApplyInGpose(out _)) return;
|
||||
var apply = await CanApplyInGpose().ConfigureAwait(false);
|
||||
if (pose.WorldData == default || !(await CanApplyInGpose().ConfigureAwait(false)).CanApply) return;
|
||||
var gposeChara = await _dalamudUtilService.GetGposeCharacterFromObjectTableByNameAsync(targetName, true).ConfigureAwait(false);
|
||||
if (gposeChara == null) return;
|
||||
|
||||
@@ -206,9 +210,10 @@ public sealed partial class CharaDataManager : DisposableMediatorSubscriberBase
|
||||
{
|
||||
return UiBlockingComputation = Task.Run(async () =>
|
||||
{
|
||||
if (CanApplyInGpose(out var chara))
|
||||
var apply = await CanApplyInGpose().ConfigureAwait(false);
|
||||
if (apply.CanApply)
|
||||
{
|
||||
await ApplyPoseData(pose, chara).ConfigureAwait(false);
|
||||
await ApplyPoseData(pose, apply.TargetName).ConfigureAwait(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -239,19 +244,21 @@ public sealed partial class CharaDataManager : DisposableMediatorSubscriberBase
|
||||
});
|
||||
}
|
||||
|
||||
public bool CanApplyInGpose(out string targetName)
|
||||
public async Task<(bool CanApply, string TargetName)> CanApplyInGpose()
|
||||
{
|
||||
bool canApply = _dalamudUtilService.IsInGpose && _dalamudUtilService.GposeTargetGameObject != null
|
||||
&& _dalamudUtilService.GposeTargetGameObject.ObjectKind == Dalamud.Game.ClientState.Objects.Enums.ObjectKind.Player;
|
||||
var obj = await _dalamudUtilService.GetGposeTargetGameObjectAsync().ConfigureAwait(false);
|
||||
string targetName = string.Empty;
|
||||
bool canApply = _dalamudUtilService.IsInGpose && obj != null
|
||||
&& obj.ObjectKind == Dalamud.Game.ClientState.Objects.Enums.ObjectKind.Player;
|
||||
if (canApply)
|
||||
{
|
||||
targetName = _dalamudUtilService.GposeTargetGameObject!.Name.TextValue;
|
||||
targetName = obj!.Name.TextValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetName = "Invalid Target";
|
||||
}
|
||||
return canApply;
|
||||
return (canApply, targetName);
|
||||
}
|
||||
|
||||
public void CancelDataApplication()
|
||||
@@ -483,11 +490,12 @@ public sealed partial class CharaDataManager : DisposableMediatorSubscriberBase
|
||||
});
|
||||
}
|
||||
|
||||
public void McdfApplyToGposeTarget()
|
||||
public async Task McdfApplyToGposeTarget()
|
||||
{
|
||||
if (CanApplyInGpose(out string target))
|
||||
var apply = await CanApplyInGpose().ConfigureAwait(false);
|
||||
if (apply.CanApply)
|
||||
{
|
||||
McdfApplyToTarget(target);
|
||||
McdfApplyToTarget(apply.TargetName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -681,7 +689,7 @@ public sealed partial class CharaDataManager : DisposableMediatorSubscriberBase
|
||||
_dalamudUtilService.GposeTarget = (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)newActor.Address;
|
||||
}
|
||||
|
||||
McdfApplyToGposeTarget();
|
||||
await McdfApplyToGposeTarget().ConfigureAwait(false);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -698,10 +706,11 @@ public sealed partial class CharaDataManager : DisposableMediatorSubscriberBase
|
||||
{
|
||||
UiBlockingComputation = Task.Run(async () =>
|
||||
{
|
||||
if (CanApplyInGpose(out var gposeTarget))
|
||||
var apply = await CanApplyInGpose().ConfigureAwait(false);
|
||||
if (apply.CanApply)
|
||||
{
|
||||
await ApplyPoseData(value, gposeTarget).ConfigureAwait(false);
|
||||
await ApplyWorldDataToTarget(value, gposeTarget).ConfigureAwait(false);
|
||||
await ApplyPoseData(value, apply.TargetName).ConfigureAwait(false);
|
||||
await ApplyWorldDataToTarget(value, apply.TargetName).ConfigureAwait(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -152,7 +152,17 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
get => TargetSystem.Instance()->GPoseTarget;
|
||||
set => TargetSystem.Instance()->GPoseTarget = value;
|
||||
}
|
||||
public unsafe Dalamud.Game.ClientState.Objects.Types.IGameObject? GposeTargetGameObject => GposeTarget == null ? null : _objectTable[GposeTarget->ObjectIndex];
|
||||
|
||||
private unsafe bool HasGposeTarget => GposeTarget != null;
|
||||
private unsafe int GPoseTargetIdx => !HasGposeTarget ? -1 : GposeTarget->ObjectIndex;
|
||||
|
||||
public async Task<IGameObject?> GetGposeTargetGameObjectAsync()
|
||||
{
|
||||
if (!HasGposeTarget)
|
||||
return null;
|
||||
|
||||
return await _framework.RunOnFrameworkThread(() => _objectTable[GPoseTargetIdx]).ConfigureAwait(true);
|
||||
}
|
||||
public bool IsAnythingDrawing { get; private set; } = false;
|
||||
public bool IsInCutscene { get; private set; } = false;
|
||||
public bool IsInGpose { get; private set; } = false;
|
||||
|
||||
Reference in New Issue
Block a user