Esempio n. 1
0
 private void DoGoto(Token token, GotoAction action)
 {
     stateStack.Push(action.State);
     if (OnGoto != null)
     {
         OnGoto(this, new GotoEventArgs(action.Symbol, stateStack.Peek()));
     }
 }
Esempio n. 2
0
                                        private static async void Entry(LineAction _, GotoAction @goto)                                                                   
                                        {
await _();                                    Console.WriteLine("Hello");
await _();                                    Console.Write("Keep going? ");
await _();                                    string line = Console.ReadLine();
await _();                                    if (line == "y") {
await _();                                        await @goto(19);
await _();                                    }
await _();                                    Console.WriteLine("Finished!");
                                        }
Esempio n. 3
0
 private static async void Entry(LineAction _, GotoAction @goto)
 {
     await _();                                    Console.WriteLine("Hello");
     await _();                                    Console.Write("Keep going? ");
     await _();                                    string line = Console.ReadLine();
     await _();                                    if (line == "y")
     {
         await _();                                        await @goto(19);
         await _();
     }
     await _();                                    Console.WriteLine("Finished!");
 }
Esempio n. 4
0
    public override bool Do(Model model, Entity e)
    {
        // TODO: Do not run macro if dangerous!
        if (GotoAction.AnyEnemiesInSight(model, e))
        {
            // No op.
            model.CoolerApiEvent(-1, "Print", "Cancelling Move. (Saw Enemy!)");
            return(true);
        }

        (int x, int y)targetPos = GetTargetPos(e.position);
        if (!model.CanWalkFromTo(e.position, targetPos))
        {
            return(true); // do nothing.
        }

        (int x, int y)oldTarget = targetPos;

        (int x, int y)nextTarget = (
            (targetPos.x - e.position.x) + oldTarget.x,
            (targetPos.y - e.position.y) + oldTarget.y
            );

        this.limit--;
        if (this.limit > 0)
        {
            this.SetTarget(nextTarget);
            e.queuedAction = this;
        }

        model.CoolerApiEvent(-1, "SmallWait");
        // target would be the new one lol
        bool success = new MoveAction().SetTarget(oldTarget).Do(model, e);

        // api.ApiEvent(new ModelEvent(-1, "Wait")); // painfully slow. see GotoAction.
        return(success);
    }