예제 #1
0
        public void MakeStepByKey(int key)
        {
            DateTime startTime;
            int      attempts    = 0;
            int      maxAttempts = 10;

            bool moveRequestFailed = false;

            do
            {
                bool moveRequestSent = false;
                do
                {
                    api.NotifyAction();
                    this.api.ClientWindow.PressKey((KeyCode)key);

                    journal.When <Events.PlayerMoveRequestedEvent>(request =>
                    {
                        moveRequestSent = true;
                    })
                    .WhenTimeout(() =>
                    {
                        moveRequestSent = false;
                    })
                    .WaitAny(TimeSpan.FromSeconds(1));
                } while (!moveRequestSent);

                startTime = DateTime.UtcNow;

                journal.When <Events.PlayerMoveRejectedEvent>(p =>
                {
                    moveRequestFailed = true;
                })
                .When <Events.PlayerMoveAcceptedEvent>(p =>
                {
                    moveRequestFailed = false;
                })
                .WhenTimeout(() => {
                    if (attempts > maxAttempts)
                    {
                        throw new InjectionException("Cannot walk");
                    }
                    moveRequestFailed = true;
                })
                .WaitAny(TimeSpan.FromSeconds(30));

                api.Wait(25);
                attempts++;
            } while (moveRequestFailed);

            var endTime     = DateTime.UtcNow;
            var minDuration = TimeSpan.FromMilliseconds(150);
            var duration    = endTime - startTime;

            if (duration < minDuration)
            {
                api.Wait((int)(minDuration - duration).TotalMilliseconds);
            }
        }
예제 #2
0
        public void Grab(int amount, int id)
        {
            var objId = (ObjectId)id;

            if (amount <= 0)
            {
                amount = api.Items[objId]?.Amount ?? 0;
            }

            api.DragItem((uint)id, amount);

            var targetContainerId = receiveingContainerId ?? api.Me.BackPack.Id;

            api.DropItem((uint)id, targetContainerId);

            if (grabDelay.HasValue)
            {
                api.Wait(grabDelay.Value);
            }
        }
예제 #3
0
 public void Wait(int ms) => infusionApi.Wait(ms);