AdEvade.AdEvade.Game_OnIssueOrder C# (CSharp) Method

Game_OnIssueOrder() private method

private Game_OnIssueOrder ( Obj_AI_Base hero, PlayerIssueOrderEventArgs args ) : void
hero Obj_AI_Base
args PlayerIssueOrderEventArgs
return void
        private void Game_OnIssueOrder(Obj_AI_Base hero, PlayerIssueOrderEventArgs args)
        {

            if (!hero.IsMe)
                return;

            if (!Situation.ShouldDodge())
                return;
            //DebugIssueOrders(args);

            if (args.Order == GameObjectOrder.MoveTo)
            {
                //movement block code goes in here
                if (IsDodging && SpellDetector.Spells.Count > 0)
                {
                    ConsoleDebug.WriteLineColor("Issue Order detected while spells exist", ConsoleColor.Yellow);
                    CheckHeroInDanger();

                    LastBlockedUserMoveTo = new EvadeCommand
                    {
                        Order = EvadeOrderCommand.MoveTo,
                        TargetPosition = args.TargetPosition.To2D(),
                        Timestamp = EvadeUtils.TickCount,
                        IsProcessed = false,
                    };

                    args.Process = false; //Block the command
                    ConsoleDebug.WriteLineColor("   Blocked Movement Command", ConsoleColor.Red);
                }
                else
                {
                    var movePos = args.TargetPosition.To2D();
                    var extraDelay = Config.Properties.GetInt(ConfigValue.ExtraPingBuffer);
                    if (EvadeHelper.CheckMovePath(movePos, Game.Ping + extraDelay))
                    {
                        ConsoleDebug.WriteLineColor("Move Path is colliding with spell", ConsoleColor.Yellow);
                        /*if (() Properties.Properties.Data["AllowCrossing"].Cast<CheckBox>().CurrentValue)
                        {
                            var extraDelayBuffer = () Properties.Properties.Data["ExtraPingBuffer"]
                                 + 30;
                            var extraDist = () Properties.Properties.Data["ExtraCPADistance"]
                                 + 10;

                            var tPosInfo = EvadeHelper.CanHeroWalkToPos(movePos, GameData.HeroInfo.moveSpeed, extraDelayBuffer + Game.Ping, extraDist);

                            if (tPosInfo.posDangerLevel == 0)
                            {
                                lastPosInfo = tPosInfo;
                                return;
                            }
                        }*/

                        LastBlockedUserMoveTo = new EvadeCommand
                        {
                            Order = EvadeOrderCommand.MoveTo,
                            TargetPosition = args.TargetPosition.To2D(),
                            Timestamp = EvadeUtils.TickCount,
                            IsProcessed = false,
                        };

                        args.Process = false; //Block the command
                        ConsoleDebug.WriteLineColor("   Blocked Movement Command", ConsoleColor.Red);
                        if (EvadeUtils.TickCount - LastMovementBlockTime < 500 && LastMovementBlockPos.Distance(args.TargetPosition) < 100)
                        {
                            return;
                        }

                        LastMovementBlockPos = args.TargetPosition;
                        LastMovementBlockTime = EvadeUtils.TickCount;

                        var posInfo = EvadeHelper.GetBestPositionMovementBlock(movePos);
                        if (posInfo != null)
                        {
                            EvadeCommand.MoveTo(posInfo.Position);
                        }
                        return;
                    }
                    else
                    {
                        LastBlockedUserMoveTo.IsProcessed = true;
                    }
                }
            }
            else //need more logic
            {
                if (IsDodging)
                {
                    args.Process = false; //Block the command
                    ConsoleDebug.WriteLineColor("   Blocked IssueOrder(" + args.Order + ") Command", ConsoleColor.Red);
                }
                else
                {
                    if (args.Order == GameObjectOrder.AttackUnit)
                    {
                        var target = args.Target;
                        if (target != null && target.GetType() == typeof(Obj_AI_Base))
                        {
                            var baseTarget = (Obj_AI_Base)target;
                            if (baseTarget.IsValid())
                                if (GameData.HeroInfo.ServerPos2D.Distance(baseTarget.ServerPosition.To2D()) > GameData.MyHero.AttackRange + GameData.HeroInfo.BoundingRadius + baseTarget.BoundingRadius)
                                {
                                    var movePos = args.TargetPosition.To2D();
                                    var extraDelay = Config.Properties.GetInt(ConfigValue.ExtraPingBuffer);
                                    if (EvadeHelper.CheckMovePath(movePos, Game.Ping + extraDelay))
                                    {
                                        args.Process = false; //Block the command
                                        ConsoleDebug.WriteLineColor("   Blocked Attack Unit Command", ConsoleColor.Red);
                                        return;
                                    }
                                }
                        }
                    }
                }
            }

            if (args.Process == true)
            {
                LastIssueOrderGameTime = Game.Time * 1000;
                LastIssueOrderTime = EvadeUtils.TickCount;
                LastIssueOrderArgs = args;

                if (args.Order == GameObjectOrder.MoveTo)
                {
                    LastMoveToPosition = args.TargetPosition.To2D();
                    LastMoveToServerPos = GameData.MyHero.ServerPosition.To2D();
                }

                if (args.Order == GameObjectOrder.Stop)
                {
                    LastStopPosition = GameData.MyHero.ServerPosition.To2D();
                }
            }
        }