Exemple #1
0
        private IEnumerable <NavMeshCell> CellsAnalyze(Vector2 pos, Geometry.Polygon poly) // Credits to Hellsing
        {
            var sourceGrid = pos.ToNavMeshCell();
            var GridSize   = 50f;
            var startPos   = new NavMeshCell(sourceGrid.GridX - (short)Math.Floor(GridSize / 2f), sourceGrid.GridY - (short)Math.Floor(GridSize / 2f));

            var cells = new List <NavMeshCell> {
                startPos
            };

            for (var y = startPos.GridY; y < startPos.GridY + GridSize; y++)
            {
                for (var x = startPos.GridX; x < startPos.GridX + GridSize; x++)
                {
                    if (x == startPos.GridX && y == startPos.GridY)
                    {
                        continue;
                    }
                    if (x == sourceGrid.GridX && y == sourceGrid.GridY)
                    {
                        cells.Add(sourceGrid);
                    }
                    else
                    {
                        cells.Add(new NavMeshCell(x, y));
                    }
                }
            }

            return(cells.Where(c => poly.IsInside(c.WorldPosition) && (c.WorldPosition.IsBuilding() || c.WorldPosition.IsWall())));
        }
    public static NavigationIsland[] GetPath(Vector3 a, Vector3 b)
    {
        NavigationIsland start = NavMeshCell.GetIslandFromPosition(NavigationMesh.mainMesh, a);

        if (start == null)
        {
            return(new NavigationIsland[] { });
        }

        NavigationIsland end = NavMeshCell.GetIslandFromPosition(NavigationMesh.mainMesh, b);

        if (end == null)
        {
            return(new NavigationIsland[] { });
        }

        var output = AStar.FindRoute(
            start,
            end,
            (x, y) => Vector3.Distance(x.center, y.center),
            (x, y) => Vector3.Distance(x.center, y.center),
            x => x.GetConnectedIslands());

        return(output.ToArray());
    }
 public static IEnumerable <NavCellController> GetCellsInBounds(Bounds bounds, NavigationMesh mesh)
 {
     foreach (var element in NavMeshCell.GetCellsInBounds(mesh, bounds))
     {
         yield return(element.controller);
     }
 }
    public Dictionary <NavQuad, NavigationIsland> GenerateIslands(NavMeshCell cell)
    {
        FindIslands(cell);
        LinkIslands();

        return(quadsToIslands);
    }
    private void FindIslands(NavMeshCell cell)
    {
        Color[] colors = new Color[] { Color.red, Color.green, Color.blue, Color.yellow, Color.cyan, Color.magenta };
        int     index  = 0;

        Queue <NavQuad>   nodes        = new Queue <NavQuad>(quadsTolinks.Keys);
        HashSet <NavQuad> visitedNodes = new HashSet <NavQuad>();

        while (nodes.Count > 0)
        {
            var next = nodes.Dequeue();
            if (visitedNodes.Contains(next))
            {
                continue;
            }

            NavigationIsland island = new NavigationIsland(cell);
            islands.Add(island);

            foreach (var node in GraphSearch.BreathFirstSearch(next, GetAdjacentNodesForIslandSearch))
            {
                visitedNodes.Add(node);
                quadsToIslands.Add(node, island);
                int i = index;
            }
            index++;
            index %= colors.Length;
        }
    }
Exemple #6
0
        // credits to hellsing (Dev-a-lot)
        private static IEnumerable <NavMeshCell> CellsAnalyze(Vector3 pos)
        {
            var sourceGrid = pos.ToNavMeshCell();
            var startPos   = new NavMeshCell(sourceGrid.GridX - (short)Math.Floor(15f), sourceGrid.GridY - (short)Math.Floor(15f));

            var cells = new List <NavMeshCell> {
                startPos
            };

            for (var y = startPos.GridY; y < startPos.GridY + 15; y++)
            {
                for (var x = startPos.GridX; x < startPos.GridX + 15; x++)
                {
                    if (x == startPos.GridX && y == startPos.GridY)
                    {
                        continue;
                    }
                    if (x == sourceGrid.GridX && y == sourceGrid.GridY)
                    {
                        cells.Add(sourceGrid);
                    }
                    else
                    {
                        cells.Add(new NavMeshCell(x, y));
                    }
                }
            }
            return(cells.Where(c => c.WorldPosition.IsGrass()));
        }
    private void Update()
    {
        var path = Navigation.GetPath(a.transform.position, b.transform.position);

        foreach (var element in path)
        {
            DebugDraw.Cross(element.center, Quaternion.identity, 1f);
        }

        foreach (var(a, b) in path.ForeachElementAndNext())
        {
            Debug.DrawLine(a.center, b.center);
        }

        var islandA = NavMeshCell.GetIslandFromPosition(NavigationMesh.mainMesh, a.transform.position);
        var islandB = NavMeshCell.GetIslandFromPosition(NavigationMesh.mainMesh, b.transform.position);

        if (islandA != null)
        {
            DebugDraw.Cross(islandA.center, Quaternion.identity, 1f, Color.red);
        }

        if (islandB != null)
        {
            DebugDraw.Cross(islandB.center, Quaternion.identity, 1f, Color.red);
        }
    }
Exemple #8
0
        public static Vector3 GetValidCastSpot(this Vector3 castPosition)
        {
            // If the position is not a wall then return the input position
            var flags = castPosition.ToNavMeshCell().CollFlags;

            if (!flags.HasFlag(CollisionFlags.Wall) && !flags.HasFlag(CollisionFlags.Building))
            {
                return(castPosition);
            }

            const int    maxRange = 20;
            const double step     = 2 * Math.PI / 20;

            var start        = new Vector2(castPosition.ToNavMeshCell().GridX, castPosition.ToNavMeshCell().GridY);
            var checkedCells = new HashSet <Vector2>();

            // Get all directions
            var directions = new List <Vector2>();

            for (var theta = 0d; theta <= 2 * Math.PI + step; theta += step)
            {
                directions.Add((new Vector2((short)(start.X + Math.Cos(theta)), (short)(start.Y - Math.Sin(theta))) - start).Normalized());
            }

            var validPositions = new HashSet <Vector3>();

            for (var range = 1; range < maxRange; range++)
            {
                // ReSharper disable once LoopCanBePartlyConvertedToQuery
                foreach (var direction in directions)
                {
                    // Get the position to check
                    var end       = start + range * direction;
                    var testPoint = new Vector2((short)end.X, (short)end.Y);
                    if (checkedCells.Contains(testPoint))
                    {
                        continue;
                    }
                    checkedCells.Add(testPoint);

                    // Check the position for wall flags
                    flags = new NavMeshCell((short)testPoint.X, (short)testPoint.Y).CollFlags;
                    if (!flags.HasFlag(CollisionFlags.Wall) && !flags.HasFlag(CollisionFlags.Building))
                    {
                        // Add the position to the valid positions set
                        validPositions.Add(NavMesh.GridToWorld((short)testPoint.X, (short)testPoint.Y));
                    }
                }

                if (validPositions.Count > 0)
                {
                    // Return the closest position to the initial wall position
                    return(validPositions.OrderBy(o => o.Distance(start, true)).First());
                }
            }

            // Nothing found return input
            return(castPosition);
        }
        public static Vector3 GetClosestWardSpot(this Vector3 wallPosition)
        {
            // If the position is not a wall then return the input position
            var flags = wallPosition.ToNavMeshCell().CollFlags;
            if (!flags.HasFlag(CollisionFlags.Wall) && !flags.HasFlag(CollisionFlags.Building))
            {
                return wallPosition;
            }

            const int maxRange = 10;
            const double step = 2 * Math.PI / 20;

            var start = new Vector2(wallPosition.ToNavMeshCell().GridX, wallPosition.ToNavMeshCell().GridY);
            var checkedCells = new HashSet<Vector2>();

            // Get all directions
            var directions = new List<Vector2>();
            for (var theta = 0d; theta <= 2 * Math.PI + step; theta += step)
            {
                directions.Add((new Vector2((short) (start.X + Math.Cos(theta)), (short) (start.Y - Math.Sin(theta))) - start).Normalized());
            }

            var validPositions = new HashSet<Vector3>();
            for (var range = 1; range < maxRange; range++)
            {
                foreach (var direction in directions)
                {
                    // Get the position to check
                    var end = start + range * direction;
                    var testPoint = new Vector2((short) end.X, (short) end.Y);
                    if (checkedCells.Contains(testPoint))
                    {
                        continue;
                    }
                    checkedCells.Add(testPoint);

                    // Check the position for wall flags
                    flags = new NavMeshCell((short) testPoint.X, (short) testPoint.Y).CollFlags;
                    if (!flags.HasFlag(CollisionFlags.Wall) && !flags.HasFlag(CollisionFlags.Building))
                    {
                        // Add the position to the valid positions set
                        validPositions.Add(NavMesh.GridToWorld((short) testPoint.X, (short) testPoint.Y));
                    }
                }

                if (validPositions.Count > 0)
                {
                    // Return the closest position to the initial wall position
                    return validPositions.OrderBy(o => o.Distance(start, true)).First();
                }
            }

            // Nothing found return input
            return wallPosition;
        }
        public static Vector3 GetValidCastSpot(Vector3 castPosition)
        {
            var flags = castPosition.ToNavMeshCell().CollFlags;

            if (!flags.HasFlag(CollisionFlags.Wall) && !flags.HasFlag(CollisionFlags.Building))
            {
                return(castPosition);
            }

            const int    maxRange = 20;
            const double step     = 2 * Math.PI / 20;

            var start        = new Vector2(castPosition.ToNavMeshCell().GridX, castPosition.ToNavMeshCell().GridY);
            var checkedCells = new HashSet <Vector2>();

            var directions = new List <Vector2>();

            for (var theta = 0d; theta <= 2 * Math.PI + step; theta += step)
            {
                directions.Add((new Vector2((short)(start.X + Math.Cos(theta)), (short)(start.Y - Math.Sin(theta))) - start).Normalized());
            }

            var validPositions = new HashSet <Vector3>();

            for (var range = 1; range < maxRange; range++)
            {
                foreach (var direction in directions)
                {
                    var end       = start + range * direction;
                    var testPoint = new Vector2((short)end.X, (short)end.Y);
                    if (checkedCells.Contains(testPoint))
                    {
                        continue;
                    }
                    checkedCells.Add(testPoint);

                    flags = new NavMeshCell((short)testPoint.X, (short)testPoint.Y).CollFlags;
                    if (!flags.HasFlag(CollisionFlags.Wall) && !flags.HasFlag(CollisionFlags.Building))
                    {
                        validPositions.Add(NavMesh.GridToWorld((short)testPoint.X, (short)testPoint.Y));
                    }
                }

                if (validPositions.Count > 0)
                {
                    return(validPositions.OrderBy(o => o.Distance(start, true)).First());
                }
            }

            return(castPosition);
        }
Exemple #11
0
    public void Invalidate()
    {
        foreach (var cell in containingCells)
        {
            cell.Invalidate();
        }
        containingCells = new List <NavMeshCell>();
        var collider = gameObject.GetComponent <Collider>();

        foreach (var cell in NavMeshCell.GetCellsInBounds(NavigationMesh.mainMesh, collider.bounds))
        {
            containingCells.Add(cell);
            cell.Invalidate();
        }
    }
Exemple #12
0
        public override void Execute()
        {
            if (!Q.IsReady())
            {
                return;
            }

            var sourceGrid = Me.Position.ToNavMeshCell();
            var gridSize   = 80;
            var startPos   = new NavMeshCell(sourceGrid.GridX - (short)Math.Floor(gridSize / 2f),
                                             sourceGrid.GridY - (short)Math.Floor(gridSize / 2f));

            var cells = new List <NavMeshCell> {
                startPos
            };

            for (var y = startPos.GridY; y < startPos.GridY + gridSize; y++)
            {
                for (var x = startPos.GridX; x < startPos.GridX + gridSize; x++)
                {
                    if (x == startPos.GridX && y == startPos.GridY)
                    {
                        continue;
                    }
                    if (x == sourceGrid.GridX && y == sourceGrid.GridY)
                    {
                        cells.Add(sourceGrid);
                    }
                    else
                    {
                        cells.Add(new NavMeshCell(x, y));
                    }
                }
            }

            var walls = cells.Where(w => w.CollFlags.HasFlag(CollisionFlags.Wall) || w.CollFlags.HasFlag(CollisionFlags.Building));

            var bestWall =
                walls.Where(w => w.WorldPosition.IsInRange(Me, Q.Range)).OrderByDescending(w => w.WorldPosition.Distance(Me)).ThenBy(w => w.WorldPosition.Distance(Game.CursorPos))
                .FirstOrDefault();

            if (bestWall == null)
            {
                return;
            }
            Q.Cast(bestWall.WorldPosition);
        }
Exemple #13
0
        internal static NavigationSafety CalculateSafety(this NavMeshCell cell)
        {
            if (cell.CollFlags.HasFlag(CollisionFlags.Grass))
            {
                return(NavigationSafety.Grass);
            }
            //Cell & Turret stuff
            var enemyTurret =
                EntityManager.Turrets.Enemies.Where(turret => !turret.IsDead)
                .OrderBy(turret => turret.Distance(Player.Instance))
                .FirstOrDefault();

            if (cell.WorldPosition.IsInRange(enemyTurret, 900))
            {
                if (EntityManager.MinionsAndMonsters.AlliedMinions.Count(ally => ally.IsInRange(enemyTurret, 900)) > 3)
                {
                    return(NavigationSafety.Average);
                }
                if (EntityManager.Heroes.Allies.Count(ally => ally.IsInRange(enemyTurret, 900)) > 3)
                {
                    return(NavigationSafety.Safe);
                }
                if (EntityManager.Heroes.Allies.Count(ally => ally.IsInRange(enemyTurret, 900)) > 1)
                {
                    return(NavigationSafety.Average);
                }
                if (enemyTurret.CountEnemiesInRange(900) > 2)
                {
                    return(NavigationSafety.VeryDangerous);
                }
                return(NavigationSafety.Danger);
            }
            //Ally and Enemy Count
            if (EntityManager.Heroes.Allies.Count(a => a.Distance(cell.WorldPosition) < 500)
                < cell.WorldPosition.CountEnemiesInRange(500))
            {
                return(NavigationSafety.Danger);
            }
            if (EntityManager.Heroes.Allies.Count(a => a.Distance(cell.WorldPosition) < 500)
                == cell.WorldPosition.CountEnemiesInRange(500))
            {
                return(NavigationSafety.Average);
            }
            return(NavigationSafety.Safe);
        }
Exemple #14
0
        private static void Game_OnTick(EventArgs args)
        {
            //if(Environment.TickCount < LastRun + 5000)return;

            var sourceGrid = Game.CursorPos.ToNavMeshCell();
            var gridSize   = 50;
            var startPos   = new NavMeshCell(sourceGrid.GridX - (short)Math.Floor(gridSize / 2f),
                                             sourceGrid.GridY - (short)Math.Floor(gridSize / 2f));

            var cells = new List <NavMeshCell> {
                startPos
            };

            for (var y = startPos.GridY; y < startPos.GridY + gridSize; y++)
            {
                for (var x = startPos.GridX; x < startPos.GridX + gridSize; x++)
                {
                    if (x == startPos.GridX && y == startPos.GridY)
                    {
                        continue;
                    }
                    if (x == sourceGrid.GridX && y == sourceGrid.GridY)
                    {
                        cells.Add(sourceGrid);
                    }
                    else
                    {
                        cells.Add(new NavMeshCell(x, y));
                    }
                }
            }

            var walls = cells.Where(w => w.CollFlags.HasFlag(CollisionFlags.Wall)).Select(w => w.WorldPosition);

            var goodWalls = walls.Where(w => !Walls.Contains(w));

            Walls.AddRange(goodWalls);

            LastRun = Environment.TickCount;
        }
Exemple #15
0
        private static IEnumerable <NavMeshCell> CellsAnalyze(Vector2 pos, EloBuddy.SDK.Geometry.Polygon poly)
        {
            var sourceGrid = pos.ToNavMeshCell();
            var cellCount  = 50f;
            var startPos   = new NavMeshCell(sourceGrid.GridX - (short)Math.Floor(cellCount), sourceGrid.GridY - (short)Math.Floor(cellCount));

            var cells = new List <NavMeshCell> {
                startPos
            };

            for (var y = startPos.GridY; y < startPos.GridY + cellCount; y++)
            {
                for (var x = startPos.GridX; x < startPos.GridX + cellCount; x++)
                {
                    if (x == startPos.GridX && y == startPos.GridY)
                    {
                        continue;
                    }
                    if (x == sourceGrid.GridX && y == sourceGrid.GridY)
                    {
                        if (poly.IsInside(sourceGrid.WorldPosition))
                        {
                            cells.Add(sourceGrid);
                        }
                    }
                    else
                    {
                        if (poly.IsInside(new NavMeshCell(x, y).WorldPosition))
                        {
                            cells.Add(new NavMeshCell(x, y));
                        }
                    }
                }
            }
            return(cells.Where(c => c.WorldPosition.IsBuilding() || c.WorldPosition.IsWall()));
        }
Exemple #16
0
        private static void OnDraw(EventArgs args)
        {
            const float analyzeRange = 500;

            #region Visualize Game Grid

            if (ShowGrid)
            {
                var sourceGrid = Game.CursorPos.ToNavMeshCell();
                var startPos = new NavMeshCell(sourceGrid.GridX - (short) Math.Floor(GridSize / 2f), sourceGrid.GridY - (short) Math.Floor(GridSize / 2f));

                var cells = new List<NavMeshCell> { startPos };
                for (var y = startPos.GridY; y < startPos.GridY + GridSize; y++)
                {
                    for (var x = startPos.GridX; x < startPos.GridX + GridSize; x++)
                    {
                        if (x == startPos.GridX && y == startPos.GridY)
                        {
                            continue;
                        }
                        if (x == sourceGrid.GridX && y == sourceGrid.GridY)
                        {
                            cells.Add(sourceGrid);
                        }
                        else
                        {
                            cells.Add(new NavMeshCell(x, y));
                        }
                    }
                }

                foreach (var cell in cells.OrderBy(o => o.CollFlags))
                {
                    var color = Color.AntiqueWhite;
                    if (cell.CollFlags.HasFlag(CollisionFlags.Wall))
                    {
                        color = Color.DodgerBlue;
                    }
                    else if (cell.CollFlags.HasFlag(CollisionFlags.Grass))
                    {
                        color = Color.LimeGreen;
                    }
                    else if (cell.CollFlags.HasFlag((CollisionFlags) 256))
                    {
                        color = Color.Yellow;
                    }

                    var world2D = cell.WorldPosition.To2D();

                    Line.DrawLine(color,
                        cell.WorldPosition,
                        (world2D + new Vector2(NavMesh.CellWidth, 0)).To3DWorld(),
                        (world2D + new Vector2(NavMesh.CellWidth, NavMesh.CellHeight)).To3DWorld(),
                        (world2D + new Vector2(0, NavMesh.CellHeight)).To3DWorld(),
                        cell.WorldPosition);
                }
            }

            #endregion

            #region Mouse Analyzing

            if (ShowMouseLines)
            {
                Line.DrawLine(Color.GhostWhite, new Vector2(Game.CursorPos2D.X, 0), new Vector2(Game.CursorPos2D.X, Drawing.Height));
                Line.DrawLine(Color.GhostWhite, new Vector2(0, Game.CursorPos2D.Y), new Vector2(Drawing.Width, Game.CursorPos2D.Y));
            }

            if (ShowMouse)
            {
                Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 0), Color.Orange, string.Format("Screen Position: X:{0} Y:{1}", Game.CursorPos2D.X, Game.CursorPos2D.Y), 10);
                Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 20), Color.Orange, string.Format("Game Position: X:{0} Y:{1} Z:{2}",
                    Math.Round(Game.CursorPos.X), Math.Round(Game.CursorPos.Y), Math.Round(Game.CursorPos.Z)), 10);
                var navMeshCell = Game.CursorPos.ToNavMeshCell();
                Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 40), Color.Orange, string.Format("NavMesh Position: X:{0} Y:{1}",
                    navMeshCell.GridX, navMeshCell.GridY), 10);

                Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 60), Color.NavajoWhite, string.Format("Collision flags: {0}", navMeshCell.CollFlags), 10);
            }

            if (ObjectNames)
            {
                Circle.Draw(SharpDX.Color.Red, analyzeRange, Game.CursorPos);
            }

            #endregion

            #region Object Analyzing

            foreach (var obj in (HeroesOnly ? ObjectManager.Get<AIHeroClient>() : ObjectManager.Get<GameObject>()).Where(o => o.VisibleOnScreen))
            {
                var i = 0;
                const int step = 20;

                var baseObject = obj as Obj_AI_Base;

                #region Near Mouse Analyzing

                if (ObjectNames && obj.IsInRange(Game.CursorPos, analyzeRange))
                {
                    Drawing.DrawText(obj.Position.WorldToScreen() + new Vector2(0, i), Color.Orange, "General info", 10);
                    i += step;

                    var data = new Dictionary<string, object>
                    {
                        { "System.Type", obj.GetType().Name },
                        { "GameObjectType", obj.Type },
                        { "Name", obj.Name },
                        { "Position", obj.Position }
                    };
                    foreach (var dataEntry in data)
                    {
                        Drawing.DrawText(obj.Position.WorldToScreen() + new Vector2(0, i), Color.NavajoWhite, string.Format("{0}: {1}", dataEntry.Key, dataEntry.Value), 10);
                        i += step;
                    }
                    Circle.Draw(SharpDX.Color.DarkRed, obj.BoundingRadius, obj.Position);
                }

                #endregion

                #region General Properties

                if (ShowGeneral && baseObject != null)
                {
                    var data = new Dictionary<string, object>
                    {
                        { "BaseSkinName", baseObject.BaseSkinName },
                        { "Model", baseObject.Model },
                        { "Health", baseObject.Health },
                        { "Mana", baseObject.Mana },
                        { "BoundingRadius", baseObject.BoundingRadius },
                        { "IsValid", baseObject.IsValid },
                        { "IsVisible", baseObject.IsVisible },
                        { "IsTargetable", baseObject.IsTargetable },
                        { "IsDead", baseObject.IsDead }
                    };

                    Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.Orange, "General properties", 10);
                    i += step;
                    foreach (var dataEntry in data)
                    {
                        Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.NavajoWhite, string.Format("{0}: {1}", dataEntry.Key, dataEntry.Value), 10);
                        i += step;
                    }
                }

                #endregion

                #region Buffs

                if (ShowBuffs && baseObject != null)
                {
                    Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.Orange, "Buffs", 10);
                    i += step;
                    foreach (var buff in baseObject.Buffs.Where(o => o.IsValid()))
                    {
                        if (ShowBuffsAdv)
                        {
                            var endTime = Math.Max(0, buff.EndTime - Game.Time);
                            Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.NavajoWhite,
                                string.Format(BuffsFormatAdvanced, buff.DisplayName, buff.Name, buff.Caster.Name, buff.SourceName, buff.Count,
                                    endTime > 1000 ? "Infinite" : Convert.ToString(endTime, CultureInfo.InvariantCulture), buff.Name), 10);
                        }
                        else
                        {
                            Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.NavajoWhite,
                                string.Format(BuffsFormatNormal, buff.DisplayName, buff.Caster.Name, buff.Count), 10);
                        }
                        i += step;
                    }
                }

                #endregion

                #region Auto Attack Damage

                if (ShowAaDamage && baseObject != null && baseObject.IsTargetableToTeam && !baseObject.IsAlly)
                {
                    var damageWithPassive = Player.Instance.GetAutoAttackDamage(baseObject, true);
                    var damageWithoutPassive = Player.Instance.GetAutoAttackDamage(baseObject);
                    var difference = Math.Round(damageWithPassive - damageWithoutPassive);
                    Drawing.DrawText(baseObject.HPBarPosition, Color.NavajoWhite, string.Format("Damage: {0} ({1})", damageWithPassive, string.Concat(difference > 0 ? "+" : "", difference)),
                        10);
                }

                #endregion

                #region Azir Soldiers

                if (Player.Instance.Hero == Champion.Azir && AnalyzeAzir)
                {
                    foreach (var soldier in Orbwalker.AzirSoldiers)
                    {
                        Circle.Draw(SharpDX.Color.DarkRed, soldier.BoundingRadius, soldier.Position);
                        Drawing.DrawText(soldier.Position.WorldToScreen(), Color.NavajoWhite, string.Format("Type: {0} | Name: {1}", soldier.GetType().Name, soldier.Name), 10);

                        Drawing.DrawText(soldier.Position.WorldToScreen() + new Vector2(0, 20), Color.NavajoWhite,
                            string.Format("Buffs: {0}", string.Join(" | ", soldier.Buffs.Select(o => string.Format("{0} ({1}x - {2})", o.DisplayName, o.Count, o.SourceName)))), 10);

                        Circle.Draw(SharpDX.Color.LawnGreen, 275, soldier.Position);
                        Drawing.DrawLine(Player.Instance.Position.WorldToScreen(), Player.Instance.Position.Extend(soldier, Player.Instance.AttackRange).To3DWorld().WorldToScreen(), 3,
                            Color.OrangeRed);

                        if (Orbwalker.ValidAzirSoldiers.Any(o => o.IdEquals(soldier)))
                        {
                            Circle.Draw(SharpDX.Color.AliceBlue, 500, soldier.Position);

                            foreach (var enemy in EntityManager.MinionsAndMonsters.Combined.Where(unit => unit.Team != Player.Instance.Team && unit.IsValidTarget()).Cast<Obj_AI_Base>()
                                .Concat(EntityManager.Heroes.Enemies.Where(o => o.IsValidTarget())).Where(enemy => enemy.IsInRange(soldier, 275 + enemy.BoundingRadius)))
                            {
                                Circle.Draw(SharpDX.Color.Red, enemy.BoundingRadius, enemy.Position);
                            }
                        }
                    }
                }

                #endregion
            }

            #endregion
        }
Exemple #17
0
        public static void DrawGrid(EventArgs args)
        {
            if (!Program._drawGrid) return;
            const int GridSize = 10;
            var sourceGrid = _Player.Position.ToNavMeshCell();

            var startPos = new NavMeshCell(sourceGrid.GridX - GridSize, sourceGrid.GridY - GridSize);

            var cells = new List<NavMeshCell> { };
            for (var y = startPos.GridY; y < startPos.GridY + 2*GridSize; y++)
            {
                for (var x = startPos.GridX; x < startPos.GridX + 2*GridSize; x++)
                {
                    cells.Add(new NavMeshCell(x, y));
                    //if (x == startPos.GridX && y == startPos.GridY)
                    //{
                    //    continue;
                    //}
                    //if (x == sourceGrid.GridX && y == sourceGrid.GridY)
                    //{
                    //    cells.Add(sourceGrid);
                    //}
                    //else
                    //{
                    //    cells.Add(new NavMeshCell(x, y));
                    //}
                }
            }

            foreach (var cell in cells)
            {
                //hotfix
                var world2D = (new Vector2(cell.GridX * NavMesh.CellWidth, cell.GridY * NavMesh.CellWidth)).To3DWorld().To2D();
                var color = Color.AntiqueWhite;
                var flags = NavMesh.GetCollisionFlags(world2D);
                if (flags.HasFlag(CollisionFlags.Wall))
                {
                    color = Color.DodgerBlue;
                }
                else if (flags.HasFlag(CollisionFlags.Grass))
                {
                    color = Color.LimeGreen;
                }
                else if (flags.HasFlag(CollisionFlags.Prop))
                {
                    color = Color.BlueViolet;
                }
                else if (flags.HasFlag((CollisionFlags)256))
                {
                    color = Color.Yellow;
                }

                //var world2D = cell.WorldPosition.To2D();

                if (cell.GridX == sourceGrid.GridX && cell.GridY == sourceGrid.GridY)
                {
                    color = Color.Black;
                    //Helpers.DebugMsg(world2D.ToString(), Color.Green);
                    //Helpers.DebugMsg(Game.CursorPos.ToString(), Color.CornflowerBlue);
                    //Helpers.DebugMsg(flags.ToString(), Color.AliceBlue);
                }
                //Helpers.DebugMsg(flags.ToString(), Color.AliceBlue);

                Line.DrawLine(color,
                    world2D.To3DWorld(),
                    (world2D + new Vector2(NavMesh.CellWidth, 0)).To3DWorld(),
                    (world2D + new Vector2(NavMesh.CellWidth, NavMesh.CellHeight)).To3DWorld(),
                    (world2D + new Vector2(0, NavMesh.CellHeight)).To3DWorld(),
                    world2D.To3DWorld());

            }
        }
Exemple #18
0
        private static void OnDraw(EventArgs args)
        {
            const float analyzeRange = 500;

            #region Visualize Game Grid

            if (ShowGrid)
            {
                var sourceGrid = Game.CursorPos.ToNavMeshCell();
                var startPos   = new NavMeshCell(sourceGrid.GridX - (short)Math.Floor(GridSize / 2f), sourceGrid.GridY - (short)Math.Floor(GridSize / 2f));

                var cells = new List <NavMeshCell> {
                    startPos
                };
                for (var y = startPos.GridY; y < startPos.GridY + GridSize; y++)
                {
                    for (var x = startPos.GridX; x < startPos.GridX + GridSize; x++)
                    {
                        if (x == startPos.GridX && y == startPos.GridY)
                        {
                            continue;
                        }
                        if (x == sourceGrid.GridX && y == sourceGrid.GridY)
                        {
                            cells.Add(sourceGrid);
                        }
                        else
                        {
                            cells.Add(new NavMeshCell(x, y));
                        }
                    }
                }

                foreach (var cell in cells.OrderBy(o => o.CollFlags))
                {
                    var color = Color.AntiqueWhite;
                    if (cell.CollFlags.HasFlag(CollisionFlags.Wall))
                    {
                        color = Color.DodgerBlue;
                    }
                    else if (cell.CollFlags.HasFlag(CollisionFlags.Grass))
                    {
                        color = Color.LimeGreen;
                    }
                    else if (cell.CollFlags.HasFlag((CollisionFlags)256))
                    {
                        color = Color.Yellow;
                    }

                    var world2D = cell.WorldPosition.To2D();

                    Line.DrawLine(color,
                                  cell.WorldPosition,
                                  (world2D + new Vector2(NavMesh.CellWidth, 0)).To3DWorld(),
                                  (world2D + new Vector2(NavMesh.CellWidth, NavMesh.CellHeight)).To3DWorld(),
                                  (world2D + new Vector2(0, NavMesh.CellHeight)).To3DWorld(),
                                  cell.WorldPosition);
                }
            }

            #endregion

            #region Mouse Analyzing

            if (ShowMouseLines)
            {
                Line.DrawLine(Color.GhostWhite, new Vector2(Game.CursorPos2D.X, 0), new Vector2(Game.CursorPos2D.X, Drawing.Height));
                Line.DrawLine(Color.GhostWhite, new Vector2(0, Game.CursorPos2D.Y), new Vector2(Drawing.Width, Game.CursorPos2D.Y));
            }

            if (ShowMouse)
            {
                Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 0), Color.Orange, string.Format("Screen Position: X:{0} Y:{1}", Game.CursorPos2D.X, Game.CursorPos2D.Y), 10);
                Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 20), Color.Orange, string.Format("Game Position: X:{0} Y:{1} Z:{2}",
                                                                                                     Math.Round(Game.CursorPos.X), Math.Round(Game.CursorPos.Y), Math.Round(Game.CursorPos.Z)), 10);
                var navMeshCell = Game.CursorPos.ToNavMeshCell();
                Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 40), Color.Orange, string.Format("NavMesh Position: X:{0} Y:{1}",
                                                                                                     navMeshCell.GridX, navMeshCell.GridY), 10);

                Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 60), Color.NavajoWhite, string.Format("Collision flags: {0}", navMeshCell.CollFlags), 10);
            }

            if (ObjectNames)
            {
                Circle.Draw(SharpDX.Color.Red, analyzeRange, Game.CursorPos);
            }

            #endregion

            #region Object Analyzing

            foreach (var obj in (HeroesOnly ? ObjectManager.Get <AIHeroClient>() : ObjectManager.Get <GameObject>()).Where(o => o.VisibleOnScreen))
            {
                var       i    = 0;
                const int step = 20;

                var baseObject = obj as Obj_AI_Base;

                #region Near Mouse Analyzing

                if (ObjectNames && obj.IsInRange(Game.CursorPos, analyzeRange))
                {
                    Drawing.DrawText(obj.Position.WorldToScreen() + new Vector2(0, i), Color.Orange, "General info", 10);
                    i += step;

                    var data = new Dictionary <string, object>
                    {
                        { "System.Type", obj.GetType().Name },
                        { "GameObjectType", obj.Type },
                        { "Name", obj.Name },
                        { "Position", obj.Position }
                    };
                    foreach (var dataEntry in data)
                    {
                        Drawing.DrawText(obj.Position.WorldToScreen() + new Vector2(0, i), Color.NavajoWhite, string.Format("{0}: {1}", dataEntry.Key, dataEntry.Value), 10);
                        i += step;
                    }
                    Circle.Draw(SharpDX.Color.DarkRed, obj.BoundingRadius, obj.Position);
                }

                #endregion

                #region General Properties

                if (ShowGeneral && baseObject != null)
                {
                    var data = new Dictionary <string, object>
                    {
                        { "BaseSkinName", baseObject.BaseSkinName },
                        { "Model", baseObject.Model },
                        { "Health", baseObject.Health },
                        { "Mana", baseObject.Mana },
                        { "BoundingRadius", baseObject.BoundingRadius },
                        { "IsValid", baseObject.IsValid },
                        { "IsVisible", baseObject.IsVisible },
                        { "IsTargetable", baseObject.IsTargetable },
                        { "IsDead", baseObject.IsDead },
                        { "IsHPBarRendered", baseObject.IsHPBarRendered }
                    };

                    Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.Orange, "General properties", 10);
                    i += step;
                    foreach (var dataEntry in data)
                    {
                        Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.NavajoWhite, string.Format("{0}: {1}", dataEntry.Key, dataEntry.Value), 10);
                        i += step;
                    }
                }

                #endregion

                #region Buffs

                if (ShowBuffs && baseObject != null)
                {
                    Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.Orange, "Buffs", 10);
                    i += step;
                    foreach (var buff in baseObject.Buffs.Where(o => o.IsValid()))
                    {
                        if (ShowBuffsAdv)
                        {
                            var endTime = Math.Max(0, buff.EndTime - Game.Time);
                            Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.NavajoWhite,
                                             string.Format(BuffsFormatAdvanced, buff.DisplayName, buff.Name, buff.Caster.Name, buff.SourceName, buff.Count,
                                                           endTime > 1000 ? "Infinite" : Convert.ToString(endTime, CultureInfo.InvariantCulture), buff.Name), 10);
                        }
                        else
                        {
                            Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.NavajoWhite,
                                             string.Format(BuffsFormatNormal, buff.DisplayName, buff.Caster.Name, buff.Count), 10);
                        }
                        i += step;
                    }
                }

                #endregion

                #region Auto Attack Damage

                if (!Bootstrap.IsSpectatorMode)
                {
                    if (ShowAaDamage && baseObject != null && baseObject.IsTargetableToTeam && !baseObject.IsAlly)
                    {
                        var damageWithPassive    = Player.Instance.GetAutoAttackDamage(baseObject, true);
                        var damageWithoutPassive = Player.Instance.GetAutoAttackDamage(baseObject);
                        var difference           = Math.Round(damageWithPassive - damageWithoutPassive);
                        Drawing.DrawText(baseObject.HPBarPosition, Color.NavajoWhite, string.Format("Damage: {0} ({1})", damageWithPassive, string.Concat(difference > 0 ? "+" : "", difference)),
                                         10);
                    }
                }

                #endregion

                #region Azir Soldiers

                if (!Bootstrap.IsSpectatorMode)
                {
                    if (Player.Instance.Hero == Champion.Azir && AnalyzeAzir)
                    {
                        foreach (var soldier in Orbwalker.AzirSoldiers)
                        {
                            Circle.Draw(SharpDX.Color.DarkRed, soldier.BoundingRadius, soldier.Position);
                            Drawing.DrawText(soldier.Position.WorldToScreen(), Color.NavajoWhite, string.Format("Type: {0} | Name: {1}", soldier.GetType().Name, soldier.Name), 10);

                            Drawing.DrawText(soldier.Position.WorldToScreen() + new Vector2(0, 20), Color.NavajoWhite,
                                             string.Format("Buffs: {0}", string.Join(" | ", soldier.Buffs.Select(o => string.Format("{0} ({1}x - {2})", o.DisplayName, o.Count, o.SourceName)))), 10);

                            Circle.Draw(SharpDX.Color.LawnGreen, 275, soldier.Position);
                            Drawing.DrawLine(Player.Instance.Position.WorldToScreen(), Player.Instance.Position.Extend(soldier, Player.Instance.AttackRange).To3DWorld().WorldToScreen(), 3,
                                             Color.OrangeRed);

                            if (Orbwalker.ValidAzirSoldiers.Any(o => o.IdEquals(soldier)))
                            {
                                Circle.Draw(SharpDX.Color.AliceBlue, 500, soldier.Position);

                                foreach (var enemy in EntityManager.MinionsAndMonsters.Combined.Where(unit => unit.Team != Player.Instance.Team && unit.IsValidTarget()).Cast <Obj_AI_Base>()
                                         .Concat(EntityManager.Heroes.Enemies.Where(o => o.IsValidTarget())).Where(enemy => enemy.IsInRange(soldier, 275 + enemy.BoundingRadius)))
                                {
                                    Circle.Draw(SharpDX.Color.Red, enemy.BoundingRadius, enemy.Position);
                                }
                            }
                        }
                    }
                }

                #endregion
            }

            #endregion
        }
Exemple #19
0
        private static void Main(string[] args)
        {
            Loading.OnLoadingComplete += delegate
            {
                #region Menu Creation

                // Setup a menu
                Menu = MainMenu.AddMenu("Dev-a-lot", "devalot");

                Menu.AddGroupLabel("General GameObject analyzing");
                Menu.Add("general", new CheckBox("General properties", false)).CurrentValue = false;
                Menu.Add("heroes", new CheckBox("Heroes only"));
                Menu.Add("buffs", new CheckBox("Show buffs", false)).CurrentValue = false;
                Menu.Add("buffs+", new CheckBox("Show more buff info", false));
                Menu.Add("autoAttack", new CheckBox("Show auto attack damage", false)).CurrentValue = false;
                if (Player.Instance.Hero == Champion.Azir)
                {
                    Menu.Add("azir", new CheckBox("Analyze Azir soldiers", false));
                }

                Menu.AddGroupLabel("Near mouse analyzing");
                Menu.Add("objectNames", new CheckBox("General info about object", false));
                Menu.Add("mouse", new CheckBox("Show info about mouse position", false));
                Menu.Add("mouseLines", new CheckBox("Show mouse coordinate lines", false));
                Menu.Add("grid", new CheckBox("Visualize game grid", false));
                Menu.Add("gridSize", new Slider("Grid size {0} x {0}", 11, 1, 55)).OnValueChange += delegate { OnMouseMove(null); };

                #endregion

                // Initialize other things
                EventVerifier.Initialize();
                PropertyVerifier.Initialize();

                // Listen to all required events
                Messages.RegisterEventHandler <Messages.MouseMove>(OnMouseMove);

                #region Drawing

                Drawing.OnDraw += delegate
                {
                    #region Visualize Game Grid

                    if (ShowGrid)
                    {
                        var sourceGrid = Game.CursorPos.ToNavMeshCell();
                        var startPos   = new NavMeshCell(sourceGrid.GridX - (short)Math.Floor(GridSize / 2f), sourceGrid.GridY - (short)Math.Floor(GridSize / 2f));

                        var cells = new List <NavMeshCell> {
                            startPos
                        };
                        for (var y = startPos.GridY; y < startPos.GridY + GridSize; y++)
                        {
                            for (var x = startPos.GridX; x < startPos.GridX + GridSize; x++)
                            {
                                if (x == startPos.GridX && y == startPos.GridY)
                                {
                                    continue;
                                }
                                if (x == sourceGrid.GridX && y == sourceGrid.GridY)
                                {
                                    cells.Add(sourceGrid);
                                }
                                else
                                {
                                    cells.Add(new NavMeshCell(x, y));
                                }
                            }
                        }

                        foreach (var cell in cells.OrderBy(o => o.CollFlags))
                        {
                            var color = Color.AntiqueWhite;
                            if (cell.CollFlags.HasFlag(CollisionFlags.Wall))
                            {
                                color = Color.DodgerBlue;
                            }
                            else if (cell.CollFlags.HasFlag(CollisionFlags.Grass))
                            {
                                color = Color.LimeGreen;
                            }
                            else if (cell.CollFlags.HasFlag((CollisionFlags)256))
                            {
                                color = Color.Yellow;
                            }

                            var world2D = cell.WorldPosition.To2D();

                            Line.DrawLine(color,
                                          cell.WorldPosition,
                                          (world2D + new Vector2(NavMesh.CellWidth, 0)).To3DWorld(),
                                          (world2D + new Vector2(NavMesh.CellWidth, NavMesh.CellHeight)).To3DWorld(),
                                          (world2D + new Vector2(0, NavMesh.CellHeight)).To3DWorld(),
                                          cell.WorldPosition);
                        }
                    }

                    #endregion

                    if (ShowMouseLines)
                    {
                        Line.DrawLine(Color.GhostWhite, new Vector2(Game.CursorPos2D.X, 0), new Vector2(Game.CursorPos2D.X, Drawing.Height));
                        Line.DrawLine(Color.GhostWhite, new Vector2(0, Game.CursorPos2D.Y), new Vector2(Drawing.Width, Game.CursorPos2D.Y));
                    }

                    if (ShowMouse)
                    {
                        Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 0), Color.Orange, string.Format("Screen Position: X:{0} Y:{1}", Game.CursorPos2D.X, Game.CursorPos2D.Y), 10);
                        Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 20), Color.Orange, string.Format("Game Position: X:{0} Y:{1} Z:{2}",
                                                                                                             Math.Round(Game.CursorPos.X), Math.Round(Game.CursorPos.Y), Math.Round(Game.CursorPos.Z)), 10);
                        var navMeshCell = Game.CursorPos.ToNavMeshCell();
                        Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 40), Color.Orange, string.Format("NavMesh Position: X:{0} Y:{1}",
                                                                                                             navMeshCell.GridX, navMeshCell.GridY), 10);

                        Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 60), Color.NavajoWhite, string.Format("Collision flags: {0}", navMeshCell.CollFlags), 10);
                    }

                    const float analyzeRange = 500;
                    if (ObjectNames)
                    {
                        Circle.Draw(SharpDX.Color.Red, analyzeRange, Game.CursorPos);
                    }

                    foreach (var obj in (HeroesOnly ? ObjectManager.Get <AIHeroClient>() : ObjectManager.Get <GameObject>()).Where(o => o.VisibleOnScreen))
                    {
                        var       i    = 0;
                        const int step = 20;

                        var baseObject = obj as Obj_AI_Base;

                        if (ObjectNames && obj.IsInRange(Game.CursorPos, analyzeRange))
                        {
                            Drawing.DrawText(obj.Position.WorldToScreen() + new Vector2(0, i), Color.Orange, "General info", 10);
                            i += step;

                            var data = new Dictionary <string, object>
                            {
                                { "System.Type", obj.GetType().Name },
                                { "GameObjectType", obj.Type },
                                { "Name", obj.Name },
                                { "Position", obj.Position }
                            };
                            foreach (var dataEntry in data)
                            {
                                Drawing.DrawText(obj.Position.WorldToScreen() + new Vector2(0, i), Color.NavajoWhite, string.Format("{0}: {1}", dataEntry.Key, dataEntry.Value), 10);
                                i += step;
                            }
                            Circle.Draw(SharpDX.Color.DarkRed, obj.BoundingRadius, obj.Position);
                        }

                        if (ShowGeneral && baseObject != null)
                        {
                            var data = new Dictionary <string, object>
                            {
                                { "Health", baseObject.Health },
                                { "Mana", baseObject.Mana },
                                { "BoundingRadius", baseObject.BoundingRadius },
                                { "IsValid", baseObject.IsValid },
                                { "IsVisible", baseObject.IsVisible },
                                { "IsTargetable", baseObject.IsTargetable },
                                { "IsDead", baseObject.IsDead }
                            };

                            Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.Orange, "General properties", 10);
                            i += step;
                            foreach (var dataEntry in data)
                            {
                                Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.NavajoWhite, string.Format("{0}: {1}", dataEntry.Key, dataEntry.Value), 10);
                                i += step;
                            }
                        }

                        if (ShowBuffs && baseObject != null)
                        {
                            Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.Orange, "Buffs", 10);
                            i += step;
                            foreach (var buff in baseObject.Buffs.Where(o => o.IsValid()))
                            {
                                if (ShowBuffsAdv)
                                {
                                    var endTime = Math.Max(0, buff.EndTime - Game.Time);
                                    Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.NavajoWhite,
                                                     string.Format(BuffsFormatAdvanced, buff.DisplayName, buff.Name, buff.Caster.Name, buff.SourceName, buff.Count,
                                                                   endTime > 1000 ? "Infinite" : Convert.ToString(endTime, CultureInfo.InvariantCulture), buff.Name), 10);
                                }
                                else
                                {
                                    Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.NavajoWhite,
                                                     string.Format(BuffsFormatNormal, buff.DisplayName, buff.Caster.Name, buff.Count), 10);
                                }
                                i += step;
                            }
                        }

                        if (ShowAaDamage && baseObject != null && baseObject.IsTargetableToTeam && !baseObject.IsAlly)
                        {
                            var damageWithPassive    = Player.Instance.GetAutoAttackDamage(baseObject, true);
                            var damageWithoutPassive = Player.Instance.GetAutoAttackDamage(baseObject);
                            var difference           = Math.Round(damageWithPassive - damageWithoutPassive);
                            Drawing.DrawText(baseObject.HPBarPosition, Color.NavajoWhite, string.Format("Damage: {0} ({1})", damageWithPassive, string.Concat(difference > 0 ? "+" : "", difference)),
                                             10);
                        }
                    }

                    if (Player.Instance.Hero == Champion.Azir && AnalyzeAzir)
                    {
                        foreach (var soldier in Orbwalker.AzirSoldiers)
                        {
                            Circle.Draw(SharpDX.Color.DarkRed, soldier.BoundingRadius, soldier.Position);
                            Drawing.DrawText(soldier.Position.WorldToScreen(), Color.NavajoWhite, string.Format("Type: {0} | Name: {1}", soldier.GetType().Name, soldier.Name), 10);

                            Drawing.DrawText(soldier.Position.WorldToScreen() + new Vector2(0, 20), Color.NavajoWhite,
                                             string.Format("Buffs: {0}", string.Join(" | ", soldier.Buffs.Select(o => string.Format("{0} ({1}x - {2})", o.DisplayName, o.Count, o.SourceName)))), 10);

                            Circle.Draw(SharpDX.Color.LawnGreen, 275, soldier.Position);
                            Drawing.DrawLine(Player.Instance.Position.WorldToScreen(), Player.Instance.Position.Extend(soldier, Player.Instance.AttackRange).To3DWorld().WorldToScreen(), 3,
                                             Color.OrangeRed);

                            if (Orbwalker.ValidAzirSoldiers.Any(o => o.IdEquals(soldier)))
                            {
                                Circle.Draw(SharpDX.Color.AliceBlue, 500, soldier.Position);

                                foreach (var enemy in EntityManager.MinionsAndMonsters.Combined.Where(unit => unit.Team != Player.Instance.Team && unit.IsValidTarget()).Cast <Obj_AI_Base>()
                                         .Concat(EntityManager.Heroes.Enemies.Where(o => o.IsValidTarget())).Where(enemy => enemy.IsInRange(soldier, 275 + enemy.BoundingRadius)))
                                {
                                    Circle.Draw(SharpDX.Color.Red, enemy.BoundingRadius, enemy.Position);
                                }
                            }
                        }
                    }
                };

                #endregion
            };
        }
    private void privFillCells()
    {
        // Get viewport
        float viewPortBottom = viewPort.GetBottom();
        float viewPortTop    = viewPort.GetTop();
        float viewPortLeft   = viewPort.GetLeft();
        float viewPortRight  = viewPort.GetRight();

        // Clear out-of-bound cells
        for (int i = 0; i < cells.Count; i++)
        {
            if (!cells[i].IsContained(viewPortTop, viewPortBottom, viewPortLeft, viewPortRight))
            {
                //Destroy(cells[i].gameObject);
                cells[i].gameObject.SetActive(false);
                cellsPool.Add(cells[i]);
                cells.RemoveAt(i);
                i--;
            }
        }

        // Fill cells
        float cellDimWorld   = baseCellDim / 100.0f;
        float vp_rightAlign  = viewPort.GetRightAlign(baseCellDim);
        float vp_leftAlign   = viewPort.GetLeftAlign(baseCellDim);
        float vp_topAlign    = viewPort.GetTopAlign(baseCellDim);
        float vp_bottomAlign = viewPort.GetBottomAlign(baseCellDim);
        int   numCell_width  = Mathf.RoundToInt((vp_rightAlign - vp_leftAlign) / cellDimWorld);
        int   numCell_height = Mathf.RoundToInt((vp_topAlign - vp_bottomAlign) / cellDimWorld);
        int   totalNumCells  = numCell_height * numCell_width;

        for (int i = 0; i < numCell_width; i++)
        {
            for (int j = 0; j < numCell_height; j++)
            {
                // Cell position in world
                Vector2 cellPos  = new Vector2(vp_leftAlign + i * cellDimWorld + cellDimWorld / 2.0f, vp_topAlign - j * cellDimWorld - cellDimWorld / 2.0f);
                Vector2 cellSize = new Vector2(cellDimWorld - CELL_DETECT_GAP_TOLERANCE, cellDimWorld - CELL_DETECT_GAP_TOLERANCE);

                // Spawn a new cell if not present
                Collider2D hitCell = Physics2D.OverlapBox(cellPos, cellSize, 0.0f, cellLayerMask);
                if (hitCell == null)
                {
                    // Instantiate color
                    Color cellColor = Color.white;

                    // Detect terrain collision
                    Collider2D hitTerrain = Physics2D.OverlapBox(cellPos, cellSize, 0.0f, terrainLayerMask);
                    if (hitTerrain != null)
                    {
                        cellColor = Color.red;
                    }

                    // Spawn cell
                    GameObject  newCell      = null;
                    NavMeshCell newCell_cell = null;
                    if (cellsPool.Count > 0) // Fetch from pool
                    {
                        newCell_cell = cellsPool[0];
                        newCell      = newCell_cell.gameObject;
                        newCell.SetActive(true);
                        newCell.transform.position = cellPos;
                        cellsPool.RemoveAt(0);
                    }
                    else // Pool dry
                    {
                        newCell      = Instantiate(NavMeshTemplate, cellPos, Quaternion.identity, poolBranch);
                        newCell_cell = newCell.GetComponent <NavMeshCell>();
                    }
                    cells.Add(newCell_cell);
                    newCell_cell.SetDimension(baseCellDim);
                    newCell.GetComponent <SpriteRenderer>().color = cellColor;
                }
            }
        }
    }
Exemple #21
0
        private static void Main(string[] args)
        {
            Loading.OnLoadingComplete += delegate
            {
                #region Menu Creation

                // Setup a menu
                Menu = MainMenu.AddMenu("Dev-a-lot", "devalot");

                Menu.AddGroupLabel("General GameObject analyzing");
                Menu.Add("general", new CheckBox("General properties", false)).CurrentValue = false;
                Menu.Add("heroes", new CheckBox("Heroes only"));
                Menu.Add("buffs", new CheckBox("Show buffs", false)).CurrentValue = false;
                Menu.Add("buffs+", new CheckBox("Show more buff info", false));
                Menu.Add("autoAttack", new CheckBox("Show auto attack damage", false)).CurrentValue = false;
                if (Player.Instance.Hero == Champion.Azir)
                {
                    Menu.Add("azir", new CheckBox("Analyze Azir soldiers", false));
                }

                Menu.AddGroupLabel("Near mouse analyzing");
                Menu.Add("objectNames", new CheckBox("General info about object", false));
                Menu.Add("mouse", new CheckBox("Show info about mouse position", false));
                Menu.Add("mouseLines", new CheckBox("Show mouse coordinate lines", false));
                Menu.Add("grid", new CheckBox("Visualize game grid", false));
                Menu.Add("gridSize", new Slider("Grid size {0} x {0}", 11, 1, 55)).OnValueChange += delegate { OnMouseMove(null); };

                #endregion

                // Initialize other things
                EventVerifier.Initialize();
                PropertyVerifier.Initialize();

                // Listen to all required events
                Messages.RegisterEventHandler<Messages.MouseMove>(OnMouseMove);

                #region Drawing

                Drawing.OnEndScene += delegate
                {
                    #region Visualize Game Grid

                    if (ShowGrid)
                    {
                        //if (!Program._drawGrid) return;
                        const int GridSize = 10;
                        var sourceGrid = Game.CursorPos.ToNavMeshCell();

                        var startPos = new NavMeshCell(sourceGrid.GridX - GridSize, sourceGrid.GridY - GridSize);

                        var cells = new List<NavMeshCell> { };
                        for (var y = startPos.GridY; y < startPos.GridY + 2*GridSize; y++)
                        {
                            for (var x = startPos.GridX; x < startPos.GridX + 2*GridSize; x++)
                            {
                                cells.Add(new NavMeshCell(x, y));
                                //if (x == startPos.GridX && y == startPos.GridY)
                                //{
                                //    continue;
                                //}
                                //if (x == sourceGrid.GridX && y == sourceGrid.GridY)
                                //{
                                //    cells.Add(sourceGrid);
                                //}
                                //else
                                //{
                                //    cells.Add(new NavMeshCell(x, y));
                                //}
                            }
                        }

                        foreach (var cell in cells)
                        {
                            //hotfix
                            var world2D = (new Vector2(cell.GridX * NavMesh.CellWidth, cell.GridY * NavMesh.CellWidth)).To3DWorld().To2D();
                            var color = Color.AntiqueWhite;
                            var flags = NavMesh.GetCollisionFlags(world2D);
                            if (flags.HasFlag(CollisionFlags.Wall))
                            {
                                color = Color.DodgerBlue;
                            }
                            else if (flags.HasFlag(CollisionFlags.Grass))
                            {
                                color = Color.LimeGreen;
                            }
                            else if (flags.HasFlag(CollisionFlags.Prop))
                            {
                                color = Color.BlueViolet;
                            }
                            else if (flags.HasFlag((CollisionFlags)256))
                            {
                                color = Color.Yellow;
                            }

                            //var world2D = cell.WorldPosition.To2D();

                            if (cell.GridX == sourceGrid.GridX && cell.GridY == sourceGrid.GridY)
                            {
                                color = Color.Black;
                                //Helpers.DebugMsg(world2D.ToString(), Color.Green);
                                //Helpers.DebugMsg(Game.CursorPos.ToString(), Color.CornflowerBlue);
                                //Helpers.DebugMsg(flags.ToString(), Color.AliceBlue);
                            }
                            //Helpers.DebugMsg(flags.ToString(), Color.AliceBlue);

                            Line.DrawLine(color,
                                world2D.To3DWorld(),
                                (world2D + new Vector2(NavMesh.CellWidth, 0)).To3DWorld(),
                                (world2D + new Vector2(NavMesh.CellWidth, NavMesh.CellHeight)).To3DWorld(),
                                (world2D + new Vector2(0, NavMesh.CellHeight)).To3DWorld(),
                                world2D.To3DWorld());

                        }
                    }

                    #endregion

                    if (ShowMouseLines)
                    {
                        Line.DrawLine(Color.GhostWhite, new Vector2(Game.CursorPos2D.X, 0), new Vector2(Game.CursorPos2D.X, Drawing.Height));
                        Line.DrawLine(Color.GhostWhite, new Vector2(0, Game.CursorPos2D.Y), new Vector2(Drawing.Width, Game.CursorPos2D.Y));
                    }

                    if (ShowMouse)
                    {
                        Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 0), Color.Orange, string.Format("Screen Position: X:{0} Y:{1}", Game.CursorPos2D.X, Game.CursorPos2D.Y), 10);
                        Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 20), Color.Orange, string.Format("Game Position: X:{0} Y:{1} Z:{2}",
                            Math.Round(Game.CursorPos.X), Math.Round(Game.CursorPos.Y), Math.Round(Game.CursorPos.Z)), 10);
                        var navMeshCell = Game.CursorPos.ToNavMeshCell();
                        Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 40), Color.Orange, string.Format("NavMesh Position: X:{0} Y:{1}",
                            navMeshCell.GridX, navMeshCell.GridY), 10);

                        Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 60), Color.NavajoWhite, string.Format("Collision flags: {0}", navMeshCell.CollFlags), 10);

                    }

                    const float analyzeRange = 500;
                    if (ObjectNames)
                    {
                        Circle.Draw(SharpDX.Color.Red, analyzeRange, Game.CursorPos);
                    }

                    foreach (var obj in (HeroesOnly ? ObjectManager.Get<AIHeroClient>() : ObjectManager.Get<GameObject>()).Where(o => o.VisibleOnScreen))
                    {
                        var i = 0;
                        const int step = 20;

                        var baseObject = obj as Obj_AI_Base;

                        if (ObjectNames && obj.IsInRange(Game.CursorPos, analyzeRange))
                        {
                            Drawing.DrawText(obj.Position.WorldToScreen() + new Vector2(0, i), Color.Orange, "General info", 10);
                            i += step;

                            var data = new Dictionary<string, object>
                            {
                                { "System.Type", obj.GetType().Name },
                                { "GameObjectType", obj.Type },
                                { "Name", obj.Name },
                                { "Position", obj.Position }
                            };
                            foreach (var dataEntry in data)
                            {
                                Drawing.DrawText(obj.Position.WorldToScreen() + new Vector2(0, i), Color.NavajoWhite, string.Format("{0}: {1}", dataEntry.Key, dataEntry.Value), 10);
                                i += step;
                            }
                            Circle.Draw(SharpDX.Color.DarkRed, obj.BoundingRadius, obj.Position);
                        }

                        if (ShowGeneral && baseObject != null)
                        {
                            var data = new Dictionary<string, object>
                            {
                                { "BaseSkinName", baseObject.BaseSkinName },
                                { "Model", baseObject.Model },
                                { "Health", baseObject.Health },
                                { "Mana", baseObject.Mana },
                                { "BoundingRadius", baseObject.BoundingRadius },
                                { "IsValid", baseObject.IsValid },
                                { "IsVisible", baseObject.IsVisible },
                                { "IsTargetable", baseObject.IsTargetable },
                                { "IsDead", baseObject.IsDead }
                            };

                            Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.Orange, "General properties", 10);
                            i += step;
                            foreach (var dataEntry in data)
                            {
                                Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.NavajoWhite, string.Format("{0}: {1}", dataEntry.Key, dataEntry.Value), 10);
                                i += step;
                            }
                        }

                        if (ShowBuffs && baseObject != null)
                        {
                            Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.Orange, "Buffs", 10);
                            i += step;
                            foreach (var buff in baseObject.Buffs.Where(o => o.IsValid()))
                            {
                                if (ShowBuffsAdv)
                                {
                                    var endTime = Math.Max(0, buff.EndTime - Game.Time);
                                    Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.NavajoWhite,
                                        string.Format(BuffsFormatAdvanced, buff.DisplayName, buff.Name, buff.Caster.Name, buff.SourceName, buff.Count,
                                            endTime > 1000 ? "Infinite" : Convert.ToString(endTime, CultureInfo.InvariantCulture), buff.Name), 10);
                                }
                                else
                                {
                                    Drawing.DrawText(baseObject.Position.WorldToScreen() + new Vector2(0, i), Color.NavajoWhite,
                                        string.Format(BuffsFormatNormal, buff.DisplayName, buff.Caster.Name, buff.Count), 10);
                                }
                                i += step;
                            }
                        }

                        if (ShowAaDamage && baseObject != null && baseObject.IsTargetableToTeam && !baseObject.IsAlly)
                        {
                            var damageWithPassive = Player.Instance.GetAutoAttackDamage(baseObject, true);
                            var damageWithoutPassive = Player.Instance.GetAutoAttackDamage(baseObject);
                            var difference = Math.Round(damageWithPassive - damageWithoutPassive);
                            Drawing.DrawText(baseObject.HPBarPosition, Color.NavajoWhite, string.Format("Damage: {0} ({1})", damageWithPassive, string.Concat(difference > 0 ? "+" : "", difference)),
                                10);
                        }
                    }

                    if (Player.Instance.Hero == Champion.Azir && AnalyzeAzir)
                    {
                        foreach (var soldier in Orbwalker.AzirSoldiers)
                        {
                            Circle.Draw(SharpDX.Color.DarkRed, soldier.BoundingRadius, soldier.Position);
                            Drawing.DrawText(soldier.Position.WorldToScreen(), Color.NavajoWhite, string.Format("Type: {0} | Name: {1}", soldier.GetType().Name, soldier.Name), 10);

                            Drawing.DrawText(soldier.Position.WorldToScreen() + new Vector2(0, 20), Color.NavajoWhite,
                                string.Format("Buffs: {0}", string.Join(" | ", soldier.Buffs.Select(o => string.Format("{0} ({1}x - {2})", o.DisplayName, o.Count, o.SourceName)))), 10);

                            Circle.Draw(SharpDX.Color.LawnGreen, 275, soldier.Position);
                            Drawing.DrawLine(Player.Instance.Position.WorldToScreen(), Player.Instance.Position.Extend(soldier, Player.Instance.AttackRange).To3DWorld().WorldToScreen(), 3,
                                Color.OrangeRed);

                            if (Orbwalker.ValidAzirSoldiers.Any(o => o.IdEquals(soldier)))
                            {
                                Circle.Draw(SharpDX.Color.AliceBlue, 500, soldier.Position);

                                foreach (var enemy in EntityManager.MinionsAndMonsters.Combined.Where(unit => unit.Team != Player.Instance.Team && unit.IsValidTarget()).Cast<Obj_AI_Base>()
                                    .Concat(EntityManager.Heroes.Enemies.Where(o => o.IsValidTarget())).Where(enemy => enemy.IsInRange(soldier, 275 + enemy.BoundingRadius)))
                                {
                                    Circle.Draw(SharpDX.Color.Red, enemy.BoundingRadius, enemy.Position);
                                }
                            }
                        }
                    }
                };

                #endregion
            };
        }
Exemple #22
0
 public NavigationIsland(NavMeshCell cell)
 {
     this.cell = cell;
 }
Exemple #23
0
        private static void Main(string[] args)
        {
            Loading.OnLoadingComplete += delegate
            {
                // Setup a menu
                Menu = MainMenu.AddMenu("Dev-a-lot", "devalot");

                Menu.AddGroupLabel("General");
                Menu.Add("general", new CheckBox("Show general info", false));
                Menu.Add("buffs", new CheckBox("Show buffs", false));
                Menu.Add("autoAttack", new CheckBox("Show auto attack damage", false));
                if (Player.Instance.Hero == Champion.Azir)
                {
                    Menu.Add("azir", new CheckBox("Analyze Azir soldiers", false));
                }

                Menu.AddGroupLabel("Near mouse analyzing");
                Menu.Add("objectNames", new CheckBox("Show object names and types", false));
                Menu.Add("onlyBase", new CheckBox("Only analyze Obj_AI_Base"));
                Menu.Add("mouse", new CheckBox("Show info about mouse position", false));
                Menu.Add("mouseLines", new CheckBox("Show mouse coordinate lines", false));
                Menu.Add("grid", new CheckBox("Visualize game grid", false));
                Menu.Add("gridSize", new Slider("Grid size {0} x {0}", 11, 1, 55));

                Menu.AddGroupLabel("Core event property stress tests, no use for addon devs");
                Menu.AddLabel("This will create a folder on your desktop called 'Test Results'");
                Menu.Add("basicAttack", new CheckBox("Obj_AI_Base.OnBasicAttack", false)).CurrentValue = false;
                Menu.Add("spellCast", new CheckBox("Obj_AI_Base.OnSpellCast", false)).CurrentValue = false;
                Menu.Add("processSpell", new CheckBox("Obj_AI_Base.OnProcessSpellCast", false)).CurrentValue = false;
                Menu.Add("stopCast", new CheckBox("Spellbook.OnStopCast", false)).CurrentValue = false;
                Menu.Add("newPath", new CheckBox("Obj_AI_Base.OnNewPath", false)).CurrentValue = false;
                Menu.Add("animation", new CheckBox("Obj_AI_Base.OnPlayAnimation", false)).CurrentValue = false;
                Menu.Add("create", new CheckBox("GameObject.OnCreate", false)).CurrentValue = false;
                Menu.Add("delete", new CheckBox("GameObject.OnDelete", false)).CurrentValue = false;
                Menu.Add("buffGain", new CheckBox("Obj_AI_Base.OnBuffGain", false)).CurrentValue = false;
                Menu.Add("buffLose", new CheckBox("Obj_AI_Base.OnBuffLose", false)).CurrentValue = false;

                Obj_AI_Base.OnBasicAttack += delegate(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs eventArgs)
                {
                    if (BasicAttack)
                    {
                        OnProcessSpellCast(sender, eventArgs);
                    }
                };
                Obj_AI_Base.OnSpellCast += delegate(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs eventArgs)
                {
                    if (SpellCast)
                    {
                        OnProcessSpellCast(sender, eventArgs);
                    }
                };
                Obj_AI_Base.OnProcessSpellCast += delegate(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs eventArgs)
                {
                    if (ProcessSpell)
                    {
                        OnProcessSpellCast(sender, eventArgs);
                    }
                };

                Obj_AI_Base.OnBuffGain += OnBuffGain;
                Obj_AI_Base.OnBuffLose += OnBuffLose;
                Obj_AI_Base.OnNewPath += OnNewPath;
                Obj_AI_Base.OnPlayAnimation += OnPlayAnimation;

                Spellbook.OnStopCast += OnStopCast;

                GameObject.OnCreate += OnCreate;
                GameObject.OnDelete += OnDelete;

                Drawing.OnDraw += delegate
                {
                    if (ShowGrid)
                    {
                        var sourceGrid = Game.CursorPos.ToNavMeshCell();
                        var startPos = new NavMeshCell(sourceGrid.GridX - (short) Math.Floor(GridSize / 2f), sourceGrid.GridY - (short) Math.Floor(GridSize / 2f));

                        var cells = new List<NavMeshCell> { startPos };
                        for (var y = startPos.GridY; y < startPos.GridY + GridSize; y++)
                        {
                            for (var x = startPos.GridX; x < startPos.GridX + GridSize; x++)
                            {
                                if (x == startPos.GridX && y == startPos.GridY)
                                {
                                    continue;
                                }
                                if (x == sourceGrid.GridX && y == sourceGrid.GridY)
                                {
                                    cells.Add(sourceGrid);
                                }
                                else
                                {
                                    cells.Add(new NavMeshCell(x, y));
                                }
                            }
                        }

                        foreach (var cell in cells.OrderBy(o => o.CollFlags))
                        {
                            var color = Color.AntiqueWhite;
                            if (cell.CollFlags.HasFlag(CollisionFlags.Wall))
                            {
                                color = Color.DodgerBlue;
                            }
                            else if (cell.CollFlags.HasFlag(CollisionFlags.Grass))
                            {
                                color = Color.LimeGreen;
                            }
                            else if (cell.CollFlags.HasFlag((CollisionFlags) 256))
                            {
                                color = Color.Yellow;
                            }
                            else if (cell.CollFlags.HasFlag(CollisionFlags.Prop))
                            {
                                color = Color.SaddleBrown;
                            }

                            var world2D = cell.WorldPosition.To2D();

                            Line.DrawLine(color,
                                cell.WorldPosition,
                                (world2D + new Vector2(NavMesh.CellWidth, 0)).To3DWorld(),
                                (world2D + new Vector2(NavMesh.CellWidth, NavMesh.CellHeight)).To3DWorld(),
                                (world2D + new Vector2(0, NavMesh.CellHeight)).To3DWorld(),
                                cell.WorldPosition);
                        }
                    }

                    if (ShowMouseLines)
                    {
                        Line.DrawLine(Color.GhostWhite, new Vector2(Game.CursorPos2D.X, 0), new Vector2(Game.CursorPos2D.X, Drawing.Height));
                        Line.DrawLine(Color.GhostWhite, new Vector2(0, Game.CursorPos2D.Y), new Vector2(Drawing.Width, Game.CursorPos2D.Y));
                    }

                    if (ShowMouse)
                    {
                        Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 0), Color.Orange, string.Format("Screen Position: X:{0} Y:{1}", Game.CursorPos2D.X, Game.CursorPos2D.Y), 10);
                        Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 20), Color.Orange, string.Format("Game Position: X:{0} Y:{1} Z:{2}",
                            Math.Round(Game.CursorPos.X), Math.Round(Game.CursorPos.Y), Math.Round(Game.CursorPos.Z)), 10);
                        var navMeshCell = Game.CursorPos.ToNavMeshCell();
                        Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 40), Color.Orange, string.Format("NavMesh Position: X:{0} Y:{1}",
                            navMeshCell.GridX, navMeshCell.GridY), 10);

                        Drawing.DrawText(Game.CursorPos2D + new Vector2(40, 60), Color.NavajoWhite, string.Format("Collision flags: {0}", navMeshCell.CollFlags), 10);
                    }

                    if (ShowBuffs || ShowGeneral)
                    {
                        foreach (var hero in EntityManager.Heroes.AllHeroes.Where(o => o.VisibleOnScreen))
                        {
                            var i = 0;
                            const int step = 20;

                            if (ShowGeneral)
                            {
                                var data = new Dictionary<string, object>
                                {
                                    { "IsValid", hero.IsValid },
                                    { "IsVisible", hero.IsVisible },
                                    { "IsTargetable", hero.IsTargetable },
                                    { "IsDead", hero.IsDead }
                                };

                                Drawing.DrawText(hero.Position.WorldToScreen() + new Vector2(0, i), Color.Orange, "General properties", 10);
                                i += step;
                                foreach (var dataEntry in data)
                                {
                                    Drawing.DrawText(hero.Position.WorldToScreen() + new Vector2(0, i), Color.NavajoWhite, string.Format("{0}: {1}", dataEntry.Key, dataEntry.Value), 10);
                                    i += step;
                                }
                            }

                            if (ShowBuffs)
                            {
                                Drawing.DrawText(hero.Position.WorldToScreen() + new Vector2(0, i), Color.Orange, "Buffs", 10);
                                i += step;
                                foreach (var buff in hero.Buffs.Where(o => o.IsValid()))
                                {
                                    Drawing.DrawText(hero.Position.WorldToScreen() + new Vector2(0, i), Color.NavajoWhite,
                                        string.Format("DisplayName: {0} | Caster: {1} | Count: {2}", buff.DisplayName, buff.SourceName, buff.Count), 10);
                                    i += step;
                                }
                            }
                        }
                    }

                    if (ShowAaDamage)
                    {
                        foreach (
                            var unit in
                                EntityManager.MinionsAndMonsters.AllEntities.Where(unit => unit.Team != Player.Instance.Team && unit.IsValidTarget() && unit.IsHPBarRendered)
                                    .Concat(EntityManager.Heroes.Enemies.Where(o => o.IsValidTarget() && o.IsHPBarRendered && o.VisibleOnScreen)))
                        {
                            var damageWithPassive = Player.Instance.GetAutoAttackDamage(unit, true);
                            var damageWithoutPassive = Player.Instance.GetAutoAttackDamage(unit);
                            var difference = Math.Round(damageWithPassive - damageWithoutPassive);
                            Drawing.DrawText(unit.HPBarPosition, Color.NavajoWhite, string.Format("Damage: {0} ({1})", damageWithPassive, string.Concat(difference > 0 ? "+" : "", difference)), 10);
                        }
                    }

                    if (ObjectNames)
                    {
                        const float range = 500;
                        Circle.Draw(SharpDX.Color.Red, range, Game.CursorPos);

                        foreach (var obj in (OnlyBase ? ObjectManager.Get<Obj_AI_Base>() : ObjectManager.Get<GameObject>()).Where(o => o.IsInRange(Game.CursorPos, range)))
                        {
                            Circle.Draw(SharpDX.Color.DarkRed, obj.BoundingRadius, obj.Position);
                            Drawing.DrawText(obj.Position.WorldToScreen(), Color.NavajoWhite, string.Format("Type: {0} | Name: {1}", obj.GetType().Name, obj.Name), 10);

                            var baseObject = obj as Obj_AI_Base;
                            if (baseObject != null)
                            {
                                Drawing.DrawText(obj.Position.WorldToScreen() + new Vector2(0, 20), Color.NavajoWhite,
                                    string.Format("Buffs: {0}", string.Join(" | ", baseObject.Buffs.Select(o => string.Format("{0} ({1}x - {2})", o.DisplayName, o.Count, o.SourceName)))), 10);
                            }
                        }
                    }

                    if (Player.Instance.Hero == Champion.Azir && AnalyzeAzir)
                    {
                        foreach (var soldier in Orbwalker.AzirSoldiers)
                        {
                            Circle.Draw(SharpDX.Color.DarkRed, soldier.BoundingRadius, soldier.Position);
                            Drawing.DrawText(soldier.Position.WorldToScreen(), Color.NavajoWhite, string.Format("Type: {0} | Name: {1}", soldier.GetType().Name, soldier.Name), 10);

                            Drawing.DrawText(soldier.Position.WorldToScreen() + new Vector2(0, 20), Color.NavajoWhite,
                                string.Format("Buffs: {0}", string.Join(" | ", soldier.Buffs.Select(o => string.Format("{0} ({1}x - {2})", o.DisplayName, o.Count, o.SourceName)))), 10);

                            Circle.Draw(SharpDX.Color.LawnGreen, 275, soldier.Position);
                            Drawing.DrawLine(Player.Instance.Position.WorldToScreen(), Player.Instance.Position.Extend(soldier, Player.Instance.AttackRange).To3DWorld().WorldToScreen(), 3,
                                Color.OrangeRed);

                            if (Orbwalker.ValidAzirSoldiers.Any(o => o.IdEquals(soldier)))
                            {
                                Circle.Draw(SharpDX.Color.AliceBlue, 500, soldier.Position);

                                foreach (var enemy in EntityManager.MinionsAndMonsters.AllEntities.Where(unit => unit.Team != Player.Instance.Team && unit.IsValidTarget())
                                    .Concat(EntityManager.Heroes.Enemies.Where(o => o.IsValidTarget())).Where(enemy => enemy.IsInRange(soldier, 275 + enemy.BoundingRadius)))
                                {
                                    Circle.Draw(SharpDX.Color.Red, enemy.BoundingRadius, enemy.Position);
                                }
                            }
                        }
                    }
                };

                return;

                Game.OnUpdate += delegate
                {
                    using (var writer = File.CreateText(Path.Combine(ResultPath, "ObjectManager.MissileClient.txt")))
                    {
                        writer.WriteLine("----------------------------------------------------------------------------------");
                        writer.WriteLine("OnUpdate, analysing all MissileClient properties in ObjectManager...");
                        writer.WriteLine("----------------------------------------------------------------------------------");
                        writer.Flush();
                        foreach (var obj in ObjectManager.Get<MissileClient>())
                        {
                            writer.WriteLine("Checking if current unit is valid");
                            writer.Flush();
                            if (true)
                            {
                                writer.Write(" - Object type: ");
                                writer.Flush();
                                writer.WriteLine(obj.GetType().Name);
                                writer.WriteLine("----------------------------------------------------------------------------------");
                                writer.WriteLine("Analyzing all public properties of " + obj.GetType().Name);
                                writer.WriteLine("----------------------------------------------------------------------------------");
                                writer.Flush();
                                foreach (var propertyInfo in obj.GetType().GetProperties().Where(propertyInfo => propertyInfo.CanRead && propertyInfo.GetGetMethod() != null))
                                {
                                    writer.Write(" - " + propertyInfo.Name + ": ");
                                    writer.Flush();
                                    writer.WriteLine(propertyInfo.GetValue(obj));
                                    writer.Flush();
                                }
                                writer.WriteLine("----------------------------------------------------------------------------------");
                                writer.WriteLine("All properties analyzed, analyzing underlaying SData");
                                writer.WriteLine("----------------------------------------------------------------------------------");
                                writer.Flush();
                                foreach (var propertyInfo in obj.SData.GetType().GetProperties().Where(propertyInfo => propertyInfo.CanRead && propertyInfo.GetGetMethod() != null))
                                {
                                    writer.Write(" - " + propertyInfo.Name + ": ");
                                    writer.Flush();
                                    writer.WriteLine(propertyInfo.GetValue(obj.SData, null));
                                    writer.Flush();
                                }
                                writer.WriteLine("----------------------------------------------------------------------------------");
                                writer.WriteLine("Analyzing of " + obj.GetType().Name + " complete!");
                                writer.WriteLine("----------------------------------------------------------------------------------");
                                writer.WriteLine();
                            }
                        }
                        writer.WriteLine("----------------------------------------------------------------------------------");
                        writer.WriteLine("Analyzing ObjectManager complete!");
                        writer.WriteLine("----------------------------------------------------------------------------------");
                    }
                };
            };
        }