/// <summary>Looks at a player's future nodes.</summary> public Element IsTravelingToAttribute(ActionSet actionSet, Element targetPlayer, Element attribute) { IndexReference result = actionSet.VarCollection.Assign("Lookahead: Result", actionSet.IsGlobal, true); actionSet.AddAction(result.SetVariable(new V_False())); IndexReference look = actionSet.VarCollection.Assign("Pathfind: Lookahead", actionSet.IsGlobal, true); actionSet.AddAction(look.SetVariable(Current.Get(targetPlayer))); // Get the path. actionSet.AddAction(Element.Part <A_While>(Element.Part <V_And>(new V_Compare( look.GetVariable(), Operators.GreaterThanOrEqual, new V_Number(0) ), !result.Get()))); actionSet.AddAction(result.SetVariable(new V_Compare(attribute, Operators.Equal, AttributeArray.Get(targetPlayer)[look.Get()]))); actionSet.AddAction(look.SetVariable(ParentArray.Get(targetPlayer)[look.Get()] - 1)); actionSet.AddAction(new A_End()); return(result.Get()); }
/// <summary>Gets the next pathfinding attribute.</summary> public Element NextSegmentAttribute(Element player) => Element.TernaryConditional( Element.Part <V_And>(IsPathfinding(player), new V_Compare(Current.GetVariable(player), Operators.NotEqual, new V_Number(-1))), AttributeArray.Get(player)[Current.Get(player)], new V_Number(-1) );