@@ -21,13 +21,15 @@ public sealed class FleeGoal : GoapGoal, IRouteProvider
2121 private readonly PlayerReader playerReader ;
2222 private readonly Navigation navigation ;
2323 private readonly AddonBits bits ;
24+ private readonly CastingHandler castingHandler ;
2425
2526 private readonly SafeSpotCollector safeSpotCollector ;
2627
2728 private Vector3 [ ] MapPoints = [ ] ;
2829
2930 public FleeGoal ( ILogger < CombatGoal > logger , ConfigurableInput input ,
3031 Wait wait , PlayerReader playerReader , AddonBits bits ,
32+ CastingHandler castingHandler ,
3133 ClassConfiguration classConfiguration , Navigation playerNavigation ,
3234 ClassConfiguration classConfig ,
3335 SafeSpotCollector safeSpotCollector )
@@ -40,6 +42,7 @@ public FleeGoal(ILogger<CombatGoal> logger, ConfigurableInput input,
4042 this . playerReader = playerReader ;
4143 this . navigation = playerNavigation ;
4244 this . bits = bits ;
45+ this . castingHandler = castingHandler ;
4346
4447 this . classConfig = classConfig ;
4548
@@ -105,16 +108,37 @@ public override void OnExit()
105108
106109 navigation . Stop ( ) ;
107110 navigation . StopMovement ( ) ;
108- }
109111
110- public override void Update ( )
111- {
112112 if ( bits . Target ( ) )
113113 {
114114 input . PressClearTarget ( ) ;
115115 }
116+ }
116117
118+ public override void Update ( )
119+ {
117120 wait . Update ( ) ;
118121 navigation . Update ( ) ;
122+
123+ // first element is skipped
124+ // its part of the Goal Custom Condition
125+ ReadOnlySpan < KeyAction > span = Keys ;
126+ for ( int i = 1 ; i < span . Length ; i ++ )
127+ {
128+ KeyAction keyAction = span [ i ] ;
129+
130+ if ( castingHandler . SpellInQueue ( ) && ! keyAction . BaseAction )
131+ {
132+ continue ;
133+ }
134+
135+ if ( castingHandler . CastIfReady ( keyAction ,
136+ keyAction . Interrupts . Count > 0
137+ ? keyAction . CanBeInterrupted
138+ : bits . Combat ) )
139+ {
140+ break ;
141+ }
142+ }
119143 }
120144}
0 commit comments