Exemple #1
0
        private static void CalculateDistanceToColonyBuildingGrid(Map map)
        {
            if (distToColonyBuilding == null)
            {
                distToColonyBuilding = new ByteGrid(map);
            }
            else if (!distToColonyBuilding.MapSizeMatches(map))
            {
                distToColonyBuilding.ClearAndResizeTo(map);
            }
            distToColonyBuilding.Clear(byte.MaxValue);
            tmpColonyBuildingsLocs.Clear();
            List <Building> allBuildingsColonist = map.listerBuildings.allBuildingsColonist;

            for (int i = 0; i < allBuildingsColonist.Count; i++)
            {
                tmpColonyBuildingsLocs.Add(allBuildingsColonist[i].Position);
            }
            Dijkstra <IntVec3> .Run(tmpColonyBuildingsLocs, (IntVec3 x) => DijkstraUtility.AdjacentCellsNeighborsGetter(x, map), (IntVec3 a, IntVec3 b) => (a.x == b.x || a.z == b.z)? 1f : 1.41421354f, tmpDistanceResult);

            for (int j = 0; j < tmpDistanceResult.Count; j++)
            {
                distToColonyBuilding[tmpDistanceResult[j].Key] = (byte)Mathf.Min(tmpDistanceResult[j].Value, 254.999f);
            }
        }
Exemple #2
0
        public static bool CalculateDistanceToColonyBuildingGrid(Map map)
        {
            List <IntVec3> tmpColonyBuildingsLocs = new List <IntVec3>();
            List <KeyValuePair <IntVec3, float> > tmpDistanceResult = new List <KeyValuePair <IntVec3, float> >();
            ByteGrid distToColonyBuilding = new ByteGrid(map);

            distToColonyBuilding.Clear(byte.MaxValue);
            tmpColonyBuildingsLocs.Clear();
            List <Building> allBuildingsColonist = map.listerBuildings.allBuildingsColonist;

            for (int i = 0; i < allBuildingsColonist.Count; i++)
            {
                tmpColonyBuildingsLocs.Add(allBuildingsColonist[i].Position);
            }

            Dijkstra <IntVec3> .Run(tmpColonyBuildingsLocs, (IntVec3 x) => DijkstraUtility.AdjacentCellsNeighborsGetter(x, map), (IntVec3 a, IntVec3 b) => (a.x == b.x || a.z == b.z)? 1f : 1.41421354f, tmpDistanceResult);

            for (int j = 0; j < tmpDistanceResult.Count; j++)
            {
                distToColonyBuilding[tmpDistanceResult[j].Key] = (byte)Mathf.Min(tmpDistanceResult[j].Value, 254.999f);
            }
            distToColonyBuildingField = distToColonyBuilding;
            return(false);
        }
Exemple #3
0
        // Token: 0x06003696 RID: 13974 RVA: 0x001A188C File Offset: 0x0019FC8C
        private static void CalculateDistanceToColonyBuildingGrid(Map map)
        {
            if (InfestationLikeCellFinder.distToColonyBuilding == null)
            {
                InfestationLikeCellFinder.distToColonyBuilding = new ByteGrid(map);
            }
            else if (!InfestationLikeCellFinder.distToColonyBuilding.MapSizeMatches(map))
            {
                InfestationLikeCellFinder.distToColonyBuilding.ClearAndResizeTo(map);
            }
            InfestationLikeCellFinder.distToColonyBuilding.Clear(byte.MaxValue);
            InfestationLikeCellFinder.tmpColonyBuildingsLocs.Clear();
            List <Building> allBuildingsColonist = map.listerBuildings.allBuildingsColonist;

            for (int i = 0; i < allBuildingsColonist.Count; i++)
            {
                InfestationLikeCellFinder.tmpColonyBuildingsLocs.Add(allBuildingsColonist[i].Position);
            }
            Dijkstra <IntVec3> .Run(InfestationLikeCellFinder.tmpColonyBuildingsLocs, (IntVec3 x) => DijkstraUtility.AdjacentCellsNeighborsGetter(x, map), delegate(IntVec3 a, IntVec3 b)
            {
                if (a.x == b.x || a.z == b.z)
                {
                    return(1f);
                }
                return(1.41421354f);
            }, InfestationLikeCellFinder.tmpDistanceResult, null);

            for (int j = 0; j < InfestationLikeCellFinder.tmpDistanceResult.Count; j++)
            {
                InfestationLikeCellFinder.distToColonyBuilding[InfestationLikeCellFinder.tmpDistanceResult[j].Key] = (byte)Mathf.Min(InfestationLikeCellFinder.tmpDistanceResult[j].Value, 254.999f);
            }
        }