The base Action class. A simple, easy to use, way to execute actions, and return their status of execution. These are normally considered 'atoms' in that they are executed in their entirety.
Inheritance: Composite
Esempio n. 1
0
        protected override Composite CreateBehavior()
        {
            var turnIn = new ActionRunCoroutine(r => TurnInLeve(NpcId));
            var update = new Action(r => done = true);

            return new PrioritySelector(turnIn, update);
        }
Esempio n. 2
0
        public void Init()
        {
             c5 = new IterComp(5, RunStatus.Success);
             c10 = new IterComp(10, RunStatus.Success);

             r1 = new Repeater(c5);
             r2 = new Repeater(c10);

             fixedAction = new TreeSharp.Action((TreeSharp.ActionDelegate)DoNothing);
             fixedRepeater = new Repeater(fixedAction, FIXED_REPEATER_COUNT);
        }
Esempio n. 3
0
 public static Composite ChangeJob()
 {
     var closewindow = new Action(a => CraftingLog.Close());
     var wait = new Sleep(4000);
     var windowcheck = new Decorator(condition => CraftingLog.IsOpen, closewindow);
     var changegearset = new Action(a =>
     {
         Logging.Write("Changing to gearset number: " + Crafty.OrderForm.GetJobGearSet(CraftyComposite.GetJob()));
         ChatManager.SendChat("/gs change " + Crafty.OrderForm.GetJobGearSet(CraftyComposite.GetJob()));
     });
     return new Sequence(windowcheck, wait, changegearset);
 }
Esempio n. 4
0
 public void SimpleActionTest()
 {
     int x = 0;
     const int count = 23;
     TreeSharp.Action action = new TreeSharp.Action(
         delegate(object context)
     {
         x++;
     });
     Repeater actionRepeater = new Repeater(action);
     actionRepeater.Start(null);
     for (int i = 0; i < count; i++)
         actionRepeater.Tick(null);
     
     Assert.AreEqual<int>(count, x);
 }
Esempio n. 5
0
 /// <summary>
 /// Casts a spell and executes <paramref name="onSuccess"/> if successful.
 /// This method will not log anything by default.
 /// </summary>
 /// <param name="spell">Id of the spell to cast.</param>
 /// <param name="conditions">Conditions to test before casting.</param>
 /// <param name="onSuccess">Action to run on success.</param>
 /// <returns><see cref="Decorator"/> that casts a spell and performs a custom action.</returns>
 public static Composite Cast(int spell, CanRunDecoratorDelegate conditions, Action onSuccess)
 {
     return new Decorator(ret => conditions(ret) && SpellManager.CanCast(spell) && SpellManager.Cast(spell), onSuccess);
 }