88namespace SER . ContextSystem . Contexts . Control . Loops ;
99
1010[ UsedImplicitly ]
11- public class ForeverLoopContext : StatementContext , IKeywordContext
11+ public class ForeverLoopContext : LoopContext , IKeywordContext
1212{
1313 private readonly Result _mainErr = "Cannot create 'forever' loop." ;
14- private bool _skipChild = false ;
14+
15+ public override Dictionary < IExtendableStatement . Signal , Func < IEnumerator < float > > > RegisteredSignals { get ; } =
16+ new ( ) ;
1517
16- public string KeywordName => "forever" ;
17- public string Description => "Makes the code inside the statement run indefinitely." ;
18- public string [ ] Arguments => [ ] ;
18+ public override string KeywordName => "forever" ;
19+ public override string Description => "Makes the code inside the statement run indefinitely." ;
20+ public override string [ ] Arguments => [ ] ;
1921
2022 public override TryAddTokenRes TryAddToken ( BaseToken token )
2123 {
@@ -33,27 +35,18 @@ protected override IEnumerator<float> Execute()
3335 {
3436 foreach ( var coro in Children . Select ( child => child . ExecuteBaseContext ( ) ) )
3537 {
38+ if ( ExitLoop ) yield break ;
39+
3640 while ( coro . MoveNext ( ) )
3741 {
3842 yield return coro . Current ;
3943 }
4044
41- if ( ! _skipChild ) continue ;
45+ if ( ! SkipThisIteration ) continue ;
4246
43- _skipChild = false ;
47+ SkipThisIteration = false ;
4448 break ;
4549 }
4650 }
4751 }
48-
49- protected override void OnReceivedControlMessageFromChild ( ParentContextControlMessage msg )
50- {
51- if ( msg == ParentContextControlMessage . LoopContinue )
52- {
53- _skipChild = true ;
54- return ;
55- }
56-
57- ParentContext ? . SendControlMessage ( msg ) ;
58- }
5952}
0 commit comments