private static int StraightLineDistToUnroofed(IntVec3 cell, Map map)
        {
            int num = int.MaxValue;
            int i   = 0;

            while (i < 4)
            {
                Rot4    rot        = new Rot4(i);
                IntVec3 facingCell = rot.FacingCell;
                int     num2       = 0;
                int     num3;
                for (;;)
                {
                    IntVec3 intVec = cell + facingCell * num2;
                    if (!intVec.InBounds(map))
                    {
                        goto Block_1;
                    }
                    num3 = num2;
                    if (InfestationCellFinder.NoRoofAroundAndWalkable(intVec, map))
                    {
                        break;
                    }
                    num2++;
                }
IL_74:
                if (num3 < num)
                {
                    num = num3;
                }
                i++;
                continue;
Block_1:
                num3 = int.MaxValue;
                goto IL_74;
            }
            int result;

            if (num == 2147483647)
            {
                result = map.Size.x;
            }
            else
            {
                result = num;
            }
            return(result);
        }
Exemplo n.º 2
0
        private static void CalculateTraversalDistancesToUnroofed(Map map)
        {
            InfestationCellFinder.tempUnroofedRegions.Clear();
            for (int i = 0; i < map.Size.z; i++)
            {
                for (int j = 0; j < map.Size.x; j++)
                {
                    IntVec3 intVec = new IntVec3(j, 0, i);
                    Region  region = intVec.GetRegion(map, RegionType.Set_Passable);
                    if (region != null && InfestationCellFinder.NoRoofAroundAndWalkable(intVec, map))
                    {
                        InfestationCellFinder.tempUnroofedRegions.Add(region);
                    }
                }
            }
            Dijkstra <Region> .Run(InfestationCellFinder.tempUnroofedRegions, (Region x) => x.Neighbors, (Region a, Region b) => Mathf.Sqrt((float)a.extentsClose.CenterCell.DistanceToSquared(b.extentsClose.CenterCell)), InfestationCellFinder.regionsDistanceToUnroofed, null);

            InfestationCellFinder.tempUnroofedRegions.Clear();
        }
Exemplo n.º 3
0
        private static int StraightLineDistToUnroofed(IntVec3 cell, Map map)
        {
            int num = 2147483647;
            int i   = 0;

            while (i < 4)
            {
                Rot4    rot        = new Rot4(i);
                IntVec3 facingCell = rot.FacingCell;
                int     num2       = 0;
                int     num3;
                while (true)
                {
                    IntVec3 intVec = cell + facingCell * num2;
                    if (!intVec.InBounds(map))
                    {
                        goto Block_1;
                    }
                    num3 = num2;
                    if (InfestationCellFinder.NoRoofAroundAndWalkable(intVec, map))
                    {
                        break;
                    }
                    num2++;
                }
IL_6F:
                if (num3 < num)
                {
                    num = num3;
                }
                i++;
                continue;
Block_1:
                num3 = 2147483647;
                goto IL_6F;
            }
            if (num == 2147483647)
            {
                return(map.Size.x);
            }
            return(num);
        }
Exemplo n.º 4
0
        private static int StraightLineDistToUnroofed(IntVec3 cell, Map map)
        {
            int num = 2147483647;

            for (int i = 0; i < 4; i++)
            {
                int     num2       = 0;
                IntVec3 facingCell = new Rot4(i).FacingCell;
                int     num3       = 0;
                while (true)
                {
                    IntVec3 intVec = cell + facingCell * num3;
                    if (!intVec.InBounds(map))
                    {
                        num2 = 2147483647;
                    }
                    else
                    {
                        num2 = num3;
                        if (!InfestationCellFinder.NoRoofAroundAndWalkable(intVec, map))
                        {
                            num3++;
                            continue;
                        }
                    }
                    break;
                }
                if (num2 < num)
                {
                    num = num2;
                }
            }
            if (num == 2147483647)
            {
                IntVec3 size = map.Size;
                return(size.x);
            }
            return(num);
        }
Exemplo n.º 5
0
        private static void CalculateTraversalDistancesToUnroofed(Map map)
        {
            InfestationCellFinder.tempUnroofedRegions.Clear();
            int num = 0;

            while (true)
            {
                int     num2 = num;
                IntVec3 size = map.Size;
                if (num2 < size.z)
                {
                    int num3 = 0;
                    while (true)
                    {
                        int     num4  = num3;
                        IntVec3 size2 = map.Size;
                        if (num4 < size2.x)
                        {
                            IntVec3 intVec = new IntVec3(num3, 0, num);
                            Region  region = intVec.GetRegion(map, RegionType.Set_Passable);
                            if (region != null && InfestationCellFinder.NoRoofAroundAndWalkable(intVec, map))
                            {
                                InfestationCellFinder.tempUnroofedRegions.Add(region);
                            }
                            num3++;
                            continue;
                        }
                        break;
                    }
                    num++;
                    continue;
                }
                break;
            }
            Dijkstra <Region> .Run(InfestationCellFinder.tempUnroofedRegions, (Region x) => x.Neighbors, (Region a, Region b) => Mathf.Sqrt((float)a.extentsClose.CenterCell.DistanceToSquared(b.extentsClose.CenterCell)), InfestationCellFinder.regionsDistanceToUnroofed, null);

            InfestationCellFinder.tempUnroofedRegions.Clear();
        }