forked from liza/Questionable
Fix certain kinds of interactions
This commit is contained in:
parent
e72a57fff4
commit
4b75388ddc
@ -1,5 +1,5 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>3.5</Version>
|
||||
<Version>3.6</Version>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
@ -72,9 +72,10 @@ internal static class Interact
|
||||
GameFunctions gameFunctions,
|
||||
ICondition condition,
|
||||
ILogger<DoInteract> logger)
|
||||
: TaskExecutor<Task>
|
||||
: TaskExecutor<Task>, IConditionChangeAware
|
||||
{
|
||||
private bool _needsUnmount;
|
||||
private EInteractionState _interactionState = EInteractionState.None;
|
||||
private DateTime _continueAt = DateTime.MinValue;
|
||||
|
||||
public Quest? Quest => Task.Quest;
|
||||
@ -111,9 +112,7 @@ internal static class Interact
|
||||
|
||||
if (gameObject.IsTargetable && HasAnyMarker(gameObject))
|
||||
{
|
||||
ProgressContext =
|
||||
InteractionProgressContext.FromActionUseOrDefault(() => gameFunctions.InteractWith(gameObject));
|
||||
_continueAt = DateTime.Now.AddSeconds(0.5);
|
||||
TriggerInteraction(gameObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -148,7 +147,7 @@ internal static class Interact
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ProgressContext != null && ProgressContext.WasSuccessful())
|
||||
if (ProgressContext != null && (ProgressContext.WasSuccessful() || _interactionState == EInteractionState.InteractionConfirmed))
|
||||
return ETaskResult.TaskComplete;
|
||||
|
||||
if (InteractionType == EInteractionType.Gather && condition[ConditionFlag.Gathering])
|
||||
@ -159,12 +158,24 @@ internal static class Interact
|
||||
if (gameObject == null || !gameObject.IsTargetable || !HasAnyMarker(gameObject))
|
||||
return ETaskResult.StillRunning;
|
||||
|
||||
ProgressContext =
|
||||
InteractionProgressContext.FromActionUseOrDefault(() => gameFunctions.InteractWith(gameObject));
|
||||
_continueAt = DateTime.Now.AddSeconds(0.5);
|
||||
TriggerInteraction(gameObject);
|
||||
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)
|
||||
{
|
||||
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;
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,8 @@ internal sealed class CreationUtilsComponent
|
||||
#endif
|
||||
|
||||
#if false
|
||||
unsafe {
|
||||
unsafe
|
||||
{
|
||||
var questManager = QuestManager.Instance();
|
||||
if (questManager != null)
|
||||
{
|
||||
@ -134,7 +135,8 @@ internal sealed class CreationUtilsComponent
|
||||
#endif
|
||||
|
||||
#if false
|
||||
unsafe {
|
||||
unsafe
|
||||
{
|
||||
var director = UIState.Instance()->DirectorTodo.Director;
|
||||
if (director != null)
|
||||
{
|
||||
@ -143,15 +145,25 @@ internal sealed class CreationUtilsComponent
|
||||
ImGui.Text($"Ico: {director->IconId}");
|
||||
if (director->EventHandlerInfo != null)
|
||||
{
|
||||
ImGui.Text($" EHI CI: {director->EventHandlerInfo->EventId.ContentId}");
|
||||
ImGui.Text($" EHI EI: {director->EventHandlerInfo->EventId.Id}");
|
||||
ImGui.Text($" EHI EEI: {director->EventHandlerInfo->EventId.EntryId}");
|
||||
ImGui.Text($" EHI F: {director->EventHandlerInfo->Flags}");
|
||||
ImGui.Text($" EHI CI: {director->Info.EventId.ContentId}");
|
||||
ImGui.Text($" EHI EI: {director->Info.EventId.Id}");
|
||||
ImGui.Text($" EHI EEI: {director->Info.EventId.EntryId}");
|
||||
ImGui.Text($" EHI F: {director->Info.Flags}");
|
||||
}
|
||||
}
|
||||
}
|
||||
#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)
|
||||
{
|
||||
DrawTargetDetails(_targetManager.Target);
|
||||
|
Loading…
Reference in New Issue
Block a user