Ejemplo n.º 1
0
        private bool InRangeOfTarget(BoardCell curCell)
        {
            if (curCell == this.destCell && this.minShooterRange == 0u)
            {
                return(true);
            }
            int x;
            int z;

            if (this.melee && this.destCell != null)
            {
                x = this.destCell.X;
                z = this.destCell.Z;
            }
            else
            {
                if (this.targetCell == null)
                {
                    return(false);
                }
                x = this.targetCell.X;
                z = this.targetCell.Z;
            }
            int halfWidthForOffset = BoardUtils.GetHalfWidthForOffset(this.TroopWidth);
            int num  = curCell.X + halfWidthForOffset;
            int num2 = curCell.Z + halfWidthForOffset;
            int num3 = num - x;
            int num4 = num3 + ((num3 <= 0) ? -1 : 1);
            int num5 = num2 - z;
            int num6 = num5 + ((num5 <= 0) ? -1 : 1);
            int num7 = num4 * num4 + num6 * num6;

            num7 = num7;
            int num8 = num3 * num3 + num5 * num5;

            num8 = num8;
            uint num9  = this.maxShooterRange * this.maxShooterRange;
            uint num10 = this.minShooterRange * this.minShooterRange;

            if (this.isHealer)
            {
                num7 += (int)(num9 / 2u);
            }
            else if (this.targetInRangeModifier > 0u)
            {
                num9 /= this.targetInRangeModifier;
            }
            if ((long)num7 < (long)((ulong)num9) && (long)num8 >= (long)((ulong)num10))
            {
                BoardCell boardCell = BoardUtils.WhereDoesLineCrossFlag(Service.BoardController.Board, num, num2, x, z, 64u);
                return(boardCell == null);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public LinkedList <Entity> GetBlockingEntities(uint targetId, out LinkedList <Entity> wallListForCrushing)
        {
            HashSet <uint>        entityIds             = new HashSet <uint>();
            LinkedList <Entity>   linkedList            = new LinkedList <Entity>();
            LinkedList <Entity>   linkedList2           = new LinkedList <Entity>();
            BoardCellDynamicArray boardCellDynamicArray = new BoardCellDynamicArray(64);

            for (int i = 0; i < this.pathCells.Length; i++)
            {
                BoardCell boardCell = this.pathCells.Array[i];
                int       num       = (!this.NoWall || this.crushesWalls) ? boardCell.Clearance : boardCell.ClearanceNoWall;
                if (num < this.TroopWidth)
                {
                    int x;
                    int y;
                    if (i == 0)
                    {
                        if (this.pathCells.Length <= 1)
                        {
                            break;
                        }
                        x = boardCell.X * 2 - this.pathCells.Array[1].X;
                        y = boardCell.Z * 2 - this.pathCells.Array[1].Z;
                    }
                    else
                    {
                        x = this.pathCells.Array[i - 1].X;
                        y = this.pathCells.Array[i - 1].Z;
                    }
                    this.RasterCrossSection(x, y, boardCell.X, boardCell.Z, this.TroopWidth, ref boardCellDynamicArray);
                }
            }
            for (int j = 0; j < boardCellDynamicArray.Length; j++)
            {
                this.AddEntitiesOnCellToBlockingList(boardCellDynamicArray.Array[j], targetId, entityIds, linkedList, linkedList2, true);
            }
            if (!this.melee)
            {
                boardCellDynamicArray.Clear();
                int         num2 = 0;
                int         num3 = 0;
                int         halfWidthForOffset = BoardUtils.GetHalfWidthForOffset(this.TroopWidth);
                BoardCell   boardCell2         = this.pathCells.Array[this.pathCells.Length - 1];
                int         num4        = boardCell2.X + halfWidthForOffset;
                int         num5        = boardCell2.Z + halfWidthForOffset;
                SmartEntity smartEntity = null;
                bool        flag        = true;
                if (this.isTargetShield)
                {
                    foreach (BoardItem current in this.targetCell.Children)
                    {
                        if (GameUtils.IsEntityShieldGenerator((SmartEntity)current.Data))
                        {
                            smartEntity = (SmartEntity)current.Data;
                            break;
                        }
                    }
                    if (smartEntity == null)
                    {
                        Service.Logger.Error("Pathing believes target is shield generator, however targetCell does not have shield generator entity.");
                    }
                    else
                    {
                        flag = Service.ShieldController.IsPositionUnderShield(num4, num5, smartEntity);
                    }
                }
                this.RasterLine(num4, num5, this.targetCell.X, this.targetCell.Z, ref boardCellDynamicArray, out num2, out num3);
                for (int k = 0; k < boardCellDynamicArray.Length - 1; k++)
                {
                    if (this.isTargetShield && !flag && Service.ShieldController.IsPositionUnderShield(boardCellDynamicArray.Array[k].X, boardCellDynamicArray.Array[k].Z, smartEntity))
                    {
                        break;
                    }
                    this.AddEntitiesOnCellToBlockingList(boardCellDynamicArray.Array[k], targetId, entityIds, linkedList, linkedList2, false);
                }
            }
            wallListForCrushing = linkedList2;
            return(linkedList);
        }
Ejemplo n.º 3
0
        public LinkedList <Entity> GetBlockingEntities(uint targetId, out LinkedList <Entity> wallListForCrushing)
        {
            HashSet <uint>             entityIds   = new HashSet <uint>();
            LinkedList <Entity>        linkedList  = new LinkedList <Entity>();
            LinkedList <Entity>        linkedList2 = new LinkedList <Entity>();
            List <BoardCell <Entity> > list        = new List <BoardCell <Entity> >();

            for (int i = 0; i < this.pathCells.Count; i++)
            {
                BoardCell <Entity> boardCell = this.pathCells[i];
                int num = (this.NoWall && !this.crushesWalls) ? boardCell.ClearanceNoWall : boardCell.Clearance;
                if (num < this.TroopWidth)
                {
                    int x;
                    int y;
                    if (i == 0)
                    {
                        if (this.pathCells.Count <= 1)
                        {
                            break;
                        }
                        x = boardCell.X * 2 - this.pathCells[1].X;
                        y = boardCell.Z * 2 - this.pathCells[1].Z;
                    }
                    else
                    {
                        x = this.pathCells[i - 1].X;
                        y = this.pathCells[i - 1].Z;
                    }
                    this.RasterCrossSection(x, y, boardCell.X, boardCell.Z, this.TroopWidth, list);
                }
            }
            for (int j = 0; j < list.Count; j++)
            {
                this.AddEntitiesOnCellToBlockingList(list[j], targetId, entityIds, linkedList, linkedList2, true);
            }
            if (!this.melee)
            {
                list.Clear();
                int         num2 = 0;
                int         num3 = 0;
                int         halfWidthForOffset = BoardUtils.GetHalfWidthForOffset(this.TroopWidth);
                int         num4        = this.pathCells[this.pathCells.Count - 1].X + halfWidthForOffset;
                int         num5        = this.pathCells[this.pathCells.Count - 1].Z + halfWidthForOffset;
                SmartEntity smartEntity = null;
                bool        flag        = true;
                if (this.isTargetShield)
                {
                    using (IEnumerator <BoardItem <Entity> > enumerator = this.targetCell.Children.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            BoardItem <Entity> current = enumerator.get_Current();
                            if (GameUtils.IsEntityShieldGenerator((SmartEntity)current.Data))
                            {
                                smartEntity = (SmartEntity)current.Data;
                                break;
                            }
                        }
                    }
                    if (smartEntity == null)
                    {
                        Service.Get <StaRTSLogger>().Error("Pathing believes target is shield generator, however targetCell does not have shield generator entity.");
                    }
                    else
                    {
                        flag = Service.Get <ShieldController>().IsPositionUnderShield(num4, num5, smartEntity);
                    }
                }
                this.RasterLine(num4, num5, this.targetCell.X, this.targetCell.Z, list, out num2, out num3);
                int num6 = 0;
                while (num6 < list.Count - 1 && (!this.isTargetShield || flag || !Service.Get <ShieldController>().IsPositionUnderShield(list[num6].X, list[num6].Z, smartEntity)))
                {
                    this.AddEntitiesOnCellToBlockingList(list[num6], targetId, entityIds, linkedList, linkedList2, false);
                    num6++;
                }
            }
            wallListForCrushing = linkedList2;
            return(linkedList);
        }