Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FleeGoal: Add the ability to use custom KeyAction(s) during goal execution. #645

Merged
merged 1 commit into from
Dec 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions Core/Goals/FleeGoal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ public sealed class FleeGoal : GoapGoal, IRouteProvider
private readonly PlayerReader playerReader;
private readonly Navigation navigation;
private readonly AddonBits bits;
private readonly CastingHandler castingHandler;

private readonly SafeSpotCollector safeSpotCollector;

private Vector3[] MapPoints = [];

public FleeGoal(ILogger<CombatGoal> logger, ConfigurableInput input,
Wait wait, PlayerReader playerReader, AddonBits bits,
CastingHandler castingHandler,
ClassConfiguration classConfiguration, Navigation playerNavigation,
ClassConfiguration classConfig,
SafeSpotCollector safeSpotCollector)
Expand All @@ -40,6 +42,7 @@ public FleeGoal(ILogger<CombatGoal> logger, ConfigurableInput input,
this.playerReader = playerReader;
this.navigation = playerNavigation;
this.bits = bits;
this.castingHandler = castingHandler;

this.classConfig = classConfig;

Expand Down Expand Up @@ -105,16 +108,37 @@ public override void OnExit()

navigation.Stop();
navigation.StopMovement();
}

public override void Update()
{
if (bits.Target())
{
input.PressClearTarget();
}
}

public override void Update()
{
wait.Update();
navigation.Update();

// first element is skipped
// its part of the Goal Custom Condition
ReadOnlySpan<KeyAction> span = Keys;
for (int i = 1; i < span.Length; i++)
{
KeyAction keyAction = span[i];

if (castingHandler.SpellInQueue() && !keyAction.BaseAction)
{
continue;
}

if (castingHandler.CastIfReady(keyAction,
keyAction.Interrupts.Count > 0
? keyAction.CanBeInterrupted
: bits.Combat))
{
break;
}
}
}
}