예제 #1
0
        public static Composite InteractWithLabelOnGroundOpenable(Func <LabelOnGround> labelToOpenDel)
        {
            return(new Decorator(delegate
            {
                var labelOnGround = labelToOpenDel();

                if (labelOnGround != null && !CommonBehavior.DoCombat() && !CommonBehavior.DoLooting())
                {
                    return true;
                }
                return false;
            },
                                 new PrioritySelector(
                                     CommonBehavior.MoveTo(x => labelToOpenDel()?.ItemOnGround?.GridPos, x => labelToOpenDel()?.ItemOnGround?.Pos,
                                                           CommonBehavior.OpenablesMovementSpec),
                                     new Action(delegate
            {
                var label = labelToOpenDel();
                var chestComponent = label?.ItemOnGround.GetComponent <Chest>();
                if (chestComponent != null && chestComponent.IsStrongbox == true && chestComponent.IsLocked == true)
                {
                    ControlTimer.Restart();
                    while (ControlTimer.ElapsedMilliseconds < 3500 && chestComponent?.IsLocked == true)
                    {
                        Thread.Sleep(150);
                        Mouse.SetCursorPosAndLeftOrRightClick(label, Latency);
                    }
                    return RunStatus.Failure;
                }
                else if (chestComponent != null && chestComponent.IsStrongbox == false && chestComponent.DestroyingAfterOpen == true)
                {
                    ControlTimer.Restart();
                    while (ControlTimer.ElapsedMilliseconds < 3500 && label != null)
                    {
                        Thread.Sleep(150);
                        Mouse.SetCursorPosAndLeftOrRightClick(label, Latency);
                    }
                    return RunStatus.Failure;
                }
                else
                {
                    ControlTimer.Restart();
                    while (ControlTimer.ElapsedMilliseconds < 3500 && label != null)
                    {
                        Thread.Sleep(150);
                        Mouse.SetCursorPosAndLeftOrRightClick(label, Latency);
                    }
                    return RunStatus.Failure;
                }
            }))));
        }