public void TicksTheInterruptBranchTheSpecifiedNumberOfTimes()
            {
                var model = new ModelInterrupter(null,
                    new ModelSuccess(null)
                    {
                        Interrupter = new InterrupterBranchTask(null)
                    }) {NumInterrupterBranchTicks = 10};

                var context = new BasicContext();
                var executor = new ExecutionInterrupter(model, new BTExecutor(model, context), null);
                executor.Spawn(context);

                executor.Interrupt(Status.Success);

                Assert.AreEqual(10, TestInterrupterExecutor.RecordedTicks);
            }
Exemplo n.º 2
0
        /**
         * Unregisters an ExecutionInterrupter from this BTExecutor.
         *
         * @param interrupter
         *            the ExecutionInterrupter to unregister.
         */
        public void UnregisterInterrupter(ExecutionInterrupter interrupter)
        {
            if (_interrupters.ContainsKey((ModelInterrupter) interrupter.ModelTask) == false)
                return;

            _interrupters.Remove((ModelInterrupter) interrupter.ModelTask);
        }
Exemplo n.º 3
0
        /**
         * Registers an ExecutionInterrupter with this BTExecutor.
         *
         * @param interrupter
         *            the ExecutionInterrupter to register.
         */
        public void RegisterInterrupter(ExecutionInterrupter interrupter)
        {
            if (_interrupters.ContainsKey((ModelInterrupter) interrupter.ModelTask))
                return;

            _interrupters.Add((ModelInterrupter) interrupter.ModelTask, interrupter);
        }