public BulletThreat(BulletPathCalculation parentCalculation)
 {
     ParentCalculation = parentCalculation;
 }
        private static void DoBulletPathCalculations(GameState gameState,
                                                     TurnCalculationCache turnCalcCache, List <BulletPathCalculation> bulletPathCalculations,
                                                     int bulletIndex, MobileState bulletState)
        {
            BulletPathCalculation bulletPathCalc = new BulletPathCalculation
            {
                Bullet      = Game.Current.Elements[bulletIndex] as Bullet,
                BulletState = bulletState
            };

            bulletPathCalculations.Add(bulletPathCalc);

            BulletPathPoint[] bulletPathPoints = new BulletPathPoint[500];
            int bulletPathPointCount           = 0;

            Cell         cell = turnCalcCache.CellMatrix[bulletState.Pos];
            Line <Point> pointsInBulletPath = cell.LineFromCellToEdgeOfBoardByDirection[(int)bulletState.Dir];
            int          tickOffset         = 0;

            for (int i = 1; i < pointsInBulletPath.Length; i++)
            {
                Point bulletPoint     = pointsInBulletPath[i];
                Cell  bulletPointCell = turnCalcCache.CellMatrix[bulletPoint];
                if (!bulletPointCell.IsValid)
                {
                    break;
                }

                if (gameState.Walls[bulletPoint])
                {
                    bulletPathCalc.TicksTillBulletDestroyed = tickOffset;
                    break;
                }
                TankLocation tankLoc    = turnCalcCache.TankLocationMatrix[bulletPoint];
                Rectangle    dangerArea = tankLoc.TankBody;

                BulletPathPoint bulletPathPoint = new BulletPathPoint
                {
                    BulletPoint   = pointsInBulletPath[i],
                    DangerArea    = dangerArea,
                    Tick          = gameState.Tick + tickOffset,
                    TicksToEscape = tickOffset,
                    MovementPhase = (i - 1) % 2
                };
                bulletPathPoints[bulletPathPointCount] = bulletPathPoint;
                bulletPathPointCount++;
                for (int p = 0; p < Constants.PLAYERS_PER_GAME; p++)
                {
                    Base @base = Game.Current.Players[p].Base;
                    if (bulletPoint == @base.Pos)
                    {
                        bulletPathCalc.BaseThreatened           = @base;
                        bulletPathCalc.TicksTillBulletDestroyed = tickOffset;
                    }
                }
                if (i % 2 == 0)
                {
                    tickOffset++;
                }
            }

            Array.Resize(ref bulletPathPoints, bulletPathPointCount);
            bulletPathCalc.BulletPathPoints = bulletPathPoints;
        }