1
0
Fork 0

Fix certain kinds of interactions

master v3.6
Liza 2024-09-20 21:52:46 +02:00
parent e72a57fff4
commit 4b75388ddc
Signed by: liza
GPG Key ID: 7199F8D727D55F67
3 changed files with 60 additions and 15 deletions

View File

@ -1,5 +1,5 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<Version>3.5</Version> <Version>3.6</Version>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -72,9 +72,10 @@ internal static class Interact
GameFunctions gameFunctions, GameFunctions gameFunctions,
ICondition condition, ICondition condition,
ILogger<DoInteract> logger) ILogger<DoInteract> logger)
: TaskExecutor<Task> : TaskExecutor<Task>, IConditionChangeAware
{ {
private bool _needsUnmount; private bool _needsUnmount;
private EInteractionState _interactionState = EInteractionState.None;
private DateTime _continueAt = DateTime.MinValue; private DateTime _continueAt = DateTime.MinValue;
public Quest? Quest => Task.Quest; public Quest? Quest => Task.Quest;
@ -111,9 +112,7 @@ internal static class Interact
if (gameObject.IsTargetable && HasAnyMarker(gameObject)) if (gameObject.IsTargetable && HasAnyMarker(gameObject))
{ {
ProgressContext = TriggerInteraction(gameObject);
InteractionProgressContext.FromActionUseOrDefault(() => gameFunctions.InteractWith(gameObject));
_continueAt = DateTime.Now.AddSeconds(0.5);
return true; return true;
} }
@ -148,7 +147,7 @@ internal static class Interact
} }
else else
{ {
if (ProgressContext != null && ProgressContext.WasSuccessful()) if (ProgressContext != null && (ProgressContext.WasSuccessful() || _interactionState == EInteractionState.InteractionConfirmed))
return ETaskResult.TaskComplete; return ETaskResult.TaskComplete;
if (InteractionType == EInteractionType.Gather && condition[ConditionFlag.Gathering]) if (InteractionType == EInteractionType.Gather && condition[ConditionFlag.Gathering])
@ -159,12 +158,24 @@ internal static class Interact
if (gameObject == null || !gameObject.IsTargetable || !HasAnyMarker(gameObject)) if (gameObject == null || !gameObject.IsTargetable || !HasAnyMarker(gameObject))
return ETaskResult.StillRunning; return ETaskResult.StillRunning;
ProgressContext = TriggerInteraction(gameObject);
InteractionProgressContext.FromActionUseOrDefault(() => gameFunctions.InteractWith(gameObject));
_continueAt = DateTime.Now.AddSeconds(0.5);
return ETaskResult.StillRunning; return ETaskResult.StillRunning;
} }
private void TriggerInteraction(IGameObject gameObject)
{
ProgressContext =
InteractionProgressContext.FromActionUseOrDefault(() =>
{
if (gameFunctions.InteractWith(gameObject))
_interactionState = EInteractionState.InteractionTriggered;
else
_interactionState = EInteractionState.None;
return _interactionState != EInteractionState.None;
});
_continueAt = DateTime.Now.AddSeconds(0.5);
}
private unsafe bool HasAnyMarker(IGameObject gameObject) private unsafe bool HasAnyMarker(IGameObject gameObject)
{ {
if (Task.SkipMarkerCheck || gameObject.ObjectKind != ObjectKind.EventNpc) if (Task.SkipMarkerCheck || gameObject.ObjectKind != ObjectKind.EventNpc)
@ -173,5 +184,27 @@ internal static class Interact
var gameObjectStruct = (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)gameObject.Address; var gameObjectStruct = (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)gameObject.Address;
return gameObjectStruct->NamePlateIconId != 0; return gameObjectStruct->NamePlateIconId != 0;
} }
public void OnConditionChange(ConditionFlag flag, bool value)
{
if (ProgressContext != null && (ProgressContext.WasInterrupted() || ProgressContext.WasSuccessful()))
return;
logger.LogDebug("Condition change: {Flag} = {Value}", flag, value);
if (_interactionState == EInteractionState.InteractionTriggered &&
flag is ConditionFlag.OccupiedInQuestEvent or ConditionFlag.OccupiedInEvent &&
value)
{
logger.LogInformation("Interaction was most likely triggered");
_interactionState = EInteractionState.InteractionConfirmed;
}
}
private enum EInteractionState
{
None,
InteractionTriggered,
InteractionConfirmed,
}
} }
} }

View File

@ -120,7 +120,8 @@ internal sealed class CreationUtilsComponent
#endif #endif
#if false #if false
unsafe { unsafe
{
var questManager = QuestManager.Instance(); var questManager = QuestManager.Instance();
if (questManager != null) if (questManager != null)
{ {
@ -134,7 +135,8 @@ internal sealed class CreationUtilsComponent
#endif #endif
#if false #if false
unsafe { unsafe
{
var director = UIState.Instance()->DirectorTodo.Director; var director = UIState.Instance()->DirectorTodo.Director;
if (director != null) if (director != null)
{ {
@ -143,15 +145,25 @@ internal sealed class CreationUtilsComponent
ImGui.Text($"Ico: {director->IconId}"); ImGui.Text($"Ico: {director->IconId}");
if (director->EventHandlerInfo != null) if (director->EventHandlerInfo != null)
{ {
ImGui.Text($" EHI CI: {director->EventHandlerInfo->EventId.ContentId}"); ImGui.Text($" EHI CI: {director->Info.EventId.ContentId}");
ImGui.Text($" EHI EI: {director->EventHandlerInfo->EventId.Id}"); ImGui.Text($" EHI EI: {director->Info.EventId.Id}");
ImGui.Text($" EHI EEI: {director->EventHandlerInfo->EventId.EntryId}"); ImGui.Text($" EHI EEI: {director->Info.EventId.EntryId}");
ImGui.Text($" EHI F: {director->EventHandlerInfo->Flags}"); ImGui.Text($" EHI F: {director->Info.Flags}");
} }
} }
} }
#endif #endif
#if false
unsafe
{
var actionManager = ActionManager.Instance();
ImGui.Text(
$"A1: {actionManager->CastActionId} ({actionManager->LastUsedActionSequence} → {actionManager->LastHandledActionSequence})");
ImGui.Text($"A2: {actionManager->CastTimeElapsed} / {actionManager->CastTimeTotal}");
}
#endif
if (_targetManager.Target != null) if (_targetManager.Target != null)
{ {
DrawTargetDetails(_targetManager.Target); DrawTargetDetails(_targetManager.Target);