Skip to content

Commit

Permalink
Merge pull request #645 from Xian55/feature/644
Browse files Browse the repository at this point in the history
FleeGoal: Add the ability to use custom `KeyAction(s)` during goal execution.
  • Loading branch information
Xian55 authored Dec 21, 2024
2 parents de8fd0e + 86b7009 commit 2b26f68
Showing 1 changed file with 27 additions and 3 deletions.
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;
}
}
}
}

0 comments on commit 2b26f68

Please sign in to comment.