示例#1
0
        public override void Generate(Map map)
        {
            Log.Message("hey2");
            if (!Find.World.grid[map.Tile].biome.Equals(BiomeDef.Named("Caves")))
            {
                RocksFromGrid.baseGenstep.Generate(map);
                return;
            }
            MapGenFloatGrid elevation = MapGenerator.Elevation;
            int             x         = map.Size.x;
            int             z         = map.Size.z;

            int[,] array           = MapGen.GenMap(x, z, 5, 0.5);
            RocksFromGrid.RiverMap = MapGen.GenRiver(x, z, null);
            foreach (IntVec3 current in map.AllCells)
            {
                if (array[current.x, current.z] == 1 && RocksFromGrid.RiverMap[current.x, current.z] == 0)
                {
                    GenSpawn.Spawn(GenStep_RocksFromGrid.RockDefAt(current), current, map);
                }
                map.roofGrid.SetRoof(current, RoofDefOf.RoofRockThick);
            }
        }
示例#2
0
 private static float getValue(IntVec3 coords, int width, int height, ModuleBase perlin, bool maxForOutOfBounds = true)
 {
     return(MapGen.getValue(coords.x, coords.z, width, height, perlin, maxForOutOfBounds));
 }
示例#3
0
        public static int[,] GenRiver(int width, int height, ModuleBase moduleBase = null)
        {
            int[,] array = new int[width, height];
            if (moduleBase == null)
            {
                moduleBase = new Perlin(0.020999999729877948, 2.1, 0.6, 7, Rand.Range(0, 2147483647), QualityMode.High);
                moduleBase = new ScaleBias(0.5, 0.5, moduleBase);
            }
            int     num       = 0;
            int     num2      = 0;
            float   num3      = 3.40282347E+38f;
            IntVec3 direction = IntVec3.Invalid;
            IntVec3 intVec    = IntVec3.Invalid;
            IntVec3 intVec2   = IntVec3.Invalid;

            for (int i = 0; i < width; i++)
            {
                float value = MapGen.getValue(i, 0, width, height, moduleBase, true);
                if (value < num3)
                {
                    num       = i;
                    num2      = 0;
                    num3      = value;
                    direction = IntVec3.North;
                    intVec    = IntVec3.East;
                    intVec2   = IntVec3.West;
                }
                value = MapGen.getValue(i, height - 1, width, height, moduleBase, true);
                if (value < num3)
                {
                    num       = i;
                    num2      = height - 1;
                    num3      = value;
                    direction = IntVec3.South;
                    intVec    = IntVec3.East;
                    intVec2   = IntVec3.West;
                }
            }
            for (int j = 0; j < height; j++)
            {
                float value2 = MapGen.getValue(0, j, width, height, moduleBase, true);
                if (value2 < num3)
                {
                    num       = 0;
                    num2      = j;
                    num3      = value2;
                    direction = IntVec3.East;
                    intVec    = IntVec3.North;
                    intVec2   = IntVec3.South;
                }
                value2 = MapGen.getValue(width - 1, j, width, height, moduleBase, true);
                if (value2 < num3)
                {
                    num       = width - 1;
                    num2      = j;
                    num3      = value2;
                    direction = IntVec3.West;
                    intVec    = IntVec3.North;
                    intVec2   = IntVec3.South;
                }
            }
            while (num >= 0 && num2 >= 0 && num < width && num2 < height)
            {
                IntVec3 intVec3 = new IntVec3(num, 0, num2);
                foreach (IntVec3 current in new List <IntVec3>
                {
                    intVec3,
                    intVec3 + intVec,
                    intVec3 + intVec2,
                    intVec3 + intVec + intVec,
                    intVec3 + intVec2 + intVec2
                })
                {
                    int x = current.x;
                    int z = current.z;
                    if (x >= 0 && z >= 0 && x < width && z < height)
                    {
                        array[x, z] = 1;
                    }
                }
                IntVec3 minNeighbor = MapGen.getMinNeighbor(num, num2, direction, intVec, intVec2, array, width, height, moduleBase);
                num  = minNeighbor.x;
                num2 = minNeighbor.z;
            }
            return(array);
        }