static void Postfix(Map map, GenStepParams parms)
        {
            // check if it's our biome. If not, skip the patch
            if (map.Biome.defName != "RockMoonBiome")
            {
                return;
            }

            // Map generation is based mostly on these two grids. We're making custom grids.
            MapGenFloatGrid fertility = MapGenerator.Fertility;
            MapGenFloatGrid elevation = MapGenerator.Elevation;

            // the size of terrain features. Smaller numbers = bigger terrain features. Vanilla = 0.021
            float mountainSize = Rand.Range(0.025f, 0.035f);

            // Overall shape. Smaller numbers = smoother. Vanilla = 2.0
            float mountainSmoothness = Rand.Range(0.0f, 1.0f);

            // the overal shape of the mountains and map features
            ModuleBase elevationGrid = new Perlin(mountainSize, mountainSmoothness, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.High);

            // Make the mountains bigger
            double elevationScaling = 1.25f;

            elevationGrid = new Multiply(elevationGrid, new Const(elevationScaling));

            // By setting fertility = elevation, we ensure that the shape of the terrain will follow the shape of the mountains
            foreach (IntVec3 tile in map.AllCells)
            {
                fertility[tile] = elevationGrid.GetValue(tile);
            }

            // This changes the relative amount of light and dark mountains
            float offset = 0.4f;

            // Skews the grid towards the center to create a "sea"
            IntVec3 center    = map.Center;
            int     size      = map.Size.x / 2;
            float   seaAmount = 2.0f;

            foreach (IntVec3 tile in map.AllCells)
            {
                float distance = (float)Math.Sqrt(Math.Pow(tile.x - center.x, 2) + Math.Pow(tile.z - center.z, 2));
                //float difference = seaAmount * distance / size - 0.5f;
                float difference = Math.Min(1, difference = seaAmount * distance / size - 0.5f);

                fertility[tile] += difference;

                // use Abs so that there's mountains on both ends of the grid.
                elevation[tile] = Mathf.Abs(fertility[tile] - offset);
            }
        }
Esempio n. 2
0
        public override void Generate(Map map, GenStepParams parms)
        {
            int num = 0;

            for (int i = (int)(GenLocalDate.Twelfth(map) - 2); i <= (int)GenLocalDate.Twelfth(map); i++)
            {
                int num2 = i;
                if (num2 < 0)
                {
                    num2 += 12;
                }
                Twelfth twelfth = (Twelfth)num2;
                if (GenTemperature.AverageTemperatureAtTileForTwelfth(map.Tile, twelfth) < 0f)
                {
                    num++;
                }
            }
            float num3 = 0f;

            switch (num)
            {
            case 0:
                return;

            case 1:
                num3 = 0.3f;
                break;

            case 2:
                num3 = 0.7f;
                break;

            case 3:
                num3 = 1f;
                break;
            }
            if (map.mapTemperature.SeasonalTemp > 0f)
            {
                num3 *= 0.4f;
            }
            if ((double)num3 < 0.3)
            {
                return;
            }
            foreach (IntVec3 allCell in map.AllCells)
            {
                if (!allCell.Roofed(map))
                {
                    map.steadyEnvironmentEffects.AddFallenSnowAt(allCell, num3);
                }
            }
        }
        public override void Generate(Map map, GenStepParams parms)
        {
            var s = new Stencil(map);

            s = s.Bound(s.MinX, s.MaxZ - Mathf.RoundToInt(map.Size.x * HeightRatio), s.MaxX, s.MaxZ)
                .Center();

            // Clear area
            s.Expand(0, 3, 0, 0).ClearThingsInBounds();

            // Courtyard floor
            s.FillTerrain(BaseGenUtility.RandomHightechFloorDef());

            // Outer floor
            s.Bound(0, s.MinZ - 1, 0, s.MinZ - 8).SetTerrain(GenCity.RandomFloor(map));

            // Outer barricade
            s.Fill(s.MinX, s.MinZ - 7, s.MaxX, s.MinZ - 7, ThingDefOf.Barricade, GenCity.RandomStuff(ThingDefOf.Barricade, map), IsValidBarricadeTile);

            // Outer wall
            var wallStuff = BaseGenUtility.RandomHightechWallStuff();
            var doorX     = s.MinX + map.Size.x / 2;

            s.Fill(s.MinX, s.MinZ - 3, doorX - 1, s.MinZ, ThingDefOf.Wall, wallStuff);
            s.Fill(doorX + 1, s.MinZ - 3, s.MaxX, s.MinZ, ThingDefOf.Wall, wallStuff);
            s.Bound(doorX, s.MinZ - 3, doorX, s.MinZ)
            .Fill(ThingDefOf.Door, wallStuff);

            // Inner keep
            s = s.Expand(-marginRange.RandomInRange, -marginRange.RandomInRange, -marginRange.RandomInRange, -marginRange.RandomInRange);

            var genStep = (GenStep_Buildings)buildingGenStepDef.genStep;

            genStep.GenerateRect(s);

            // Mechanoids
            var mechs = PawnGroupMakerUtility.GeneratePawns(new PawnGroupMakerParms {
                groupKind = PawnGroupKindDefOf.Combat,
                tile      = map.Tile,
                faction   = Faction.OfMechanoids,
                points    = 10000,
            });

            foreach (var mech in mechs)
            {
                GenSpawn.Spawn(mech, GenCity.FindPawnSpot(s.Bound(-5, -5, 5, 5).MoveRand().pos, map), map);
                mech.SetFactionDirect(map.ParentFaction);
                mech.Name = new NameSingle(mechanoidNames[Rand.Range(0, mechanoidNames.Count)] + " #" + Rand.RangeInclusive(10, 40));
            }

            //TODO throne room
        }
        /*protected override void ScatterAt(IntVec3 loc, Map map, int count = 1)
         * {
         *  if(map.GetComponent<BetharianDeposits>() is BetharianDeposits betharianDeposits)
         *  {
         *      int numCells = Mathf.CeilToInt((float)this.GetScatterLumpSizeRange().RandomInRange * LumpSizeFactor);
         *      foreach (IntVec3 c2 in GenAdj.OccupiedRect(loc, Rot4.Random, new IntVec2(5, 5)))
         *      //foreach (IntVec3 c2 in GridShapeMaker.IrregularLump(loc, map, numCells))
         *      {
         *          //map.deepResourceGrid.SetAt(c2, thingDef, thingDef.deepCountPerCell);
         *          betharianDeposits.grid.SetStrengthAt(c2, 1);
         *      }
         *  }
         * }*/

        protected override void ScatterAt(IntVec3 loc, Map map, GenStepParams parms, int count = 1)
        {
            if (map.GetComponent <BetharianDeposits>() is BetharianDeposits betharianDeposits)
            {
                int numCells = Mathf.CeilToInt((float)this.GetScatterLumpSizeRange().RandomInRange *LumpSizeFactor);
                foreach (IntVec3 c2 in GenAdj.OccupiedRect(loc, Rot4.Random, new IntVec2(5, 5)))
                //foreach (IntVec3 c2 in GridShapeMaker.IrregularLump(loc, map, numCells))
                {
                    //map.deepResourceGrid.SetAt(c2, thingDef, thingDef.deepCountPerCell);
                    betharianDeposits.grid.SetStrengthAt(c2, 1);
                }
            }
        }
        protected override void ScatterAt(IntVec3 loc, Map map, GenStepParams parms, int count = 1)
        {
            int length = Rand.RangeInclusive(3, 5);

            for (int i = 0; i < length; i++)
            {
                Pawn pawn = PawnGenerator.GeneratePawn(VFEV_DefOf.VFEV_Njorun);
                GenSpawn.Spawn(pawn, loc, map, WipeMode.Vanish);
                pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, false, false, null, false);
            }
            MapGenerator.rootsToUnfog.Add(loc);
            MapGenerator.SetVar <CellRect>("RectOfInterest", CellRect.CenteredOn(loc, 1, 1));
        }
Esempio n. 6
0
        public override void Generate(Map map, GenStepParams parms)
        {
            base.Generate(map, parms);
            this.baseResolveParams.rect = new CellRect(0, 0, map.Size.x, map.Size.z);
            BaseGen.symbolStack.Push("toxicFalloutCityBaseLGE", this.baseResolveParams);
            BaseGen.Generate();

            //after generation spawn permanent toxic fallout
            GameCondition falloutCondition = GameConditionMaker.MakeCondition(GameConditionDefOf.ToxicFallout);

            falloutCondition.Permanent = true;
            map.GameConditionManager.RegisterCondition(falloutCondition);
        }
Esempio n. 7
0
        public override void Generate(Map map, GenStepParams parms)
        {
            DeepProfiler.Start("GenerateInitialFogGrid");
            map.fogGrid.SetAllFogged();
            FloodFillerFog.FloodUnfog(MapGenerator.PlayerStartSpot, map);
            List <IntVec3> rootsToUnfog = MapGenerator.rootsToUnfog;

            for (int i = 0; i < rootsToUnfog.Count; i++)
            {
                FloodFillerFog.FloodUnfog(rootsToUnfog[i], map);
            }
            DeepProfiler.End();
        }
        protected override void ScatterAt(IntVec3 loc, Map map, GenStepParams parms, int count = 1)
        {
            CGO.factionSettlement = map.ParentFaction.def.GetModExtension <CustomGenOption>();

            if (CGO.factionSettlement.symbolResolver == null)
            {
                GenStepUtils.Generate(map, loc, CGO.factionSettlement);
            }
            else
            {
                GenStepUtils.Generate(map, loc, CGO.factionSettlement, CGO.factionSettlement.symbolResolver);
            }
        }
Esempio n. 9
0
        protected override void ScatterAt(IntVec3 pos, Map map, GenStepParams parms, int count)
        {
            var s = new Stencil(map);

            s = s.BoundTo(CellRect.FromLimits(pos, s.bounds.RandomCell));
            var stuff = GenCity.RandomWallStuff(map);

            for (var dir = 0; dir < 4; dir++)
            {
                var sDir = s.Rotate(dir);
                sDir.Fill(sDir.MinX, sDir.MaxZ, sDir.MaxX, sDir.MaxZ, ThingDefOf.Wall, stuff, IsValidTile);
            }
        }
Esempio n. 10
0
        public override void Generate(Map map, GenStepParams parms)
        {
            Log.Message("[Biomes! Core] Generating an island");

            // if the island didn't specify any shapes, all shapes are valid.
            List <IslandShape> allowedShapes = map.Biome.GetModExtension <BiomesMap>().islandShapes;

            if (allowedShapes.NullOrEmpty())
            {
                allowedShapes = new List <IslandShape>();
                foreach (IslandShape s in Enum.GetValues(typeof(IslandShape)))
                {
                    allowedShapes.Add(s);
                }
            }

            //pick and run a random allowable shape
            IslandShape shape = allowedShapes.RandomElement();

            switch (shape)
            {
            case IslandShape.Smooth:
                new GenStep_IslandShape_Smooth().Generate(map, parms);
                break;

            case IslandShape.Rough:
                new GenStep_IslandShape_Rough().Generate(map, parms);
                break;

            case IslandShape.Crescent:
                new GenStep_IslandShape_Crescent().Generate(map, parms);
                break;

            case IslandShape.Pair:
                new GenStep_IslandShape_Pair().Generate(map, parms);
                break;

            case IslandShape.Cluster:
                new GenStep_IslandShape_Cluster().Generate(map, parms);
                break;

            case IslandShape.Broken:
                new GenStep_IslandShape_Broken().Generate(map, parms);
                break;

            // rough islands are probably the best default island shape
            default:
                new GenStep_IslandShape_Rough().Generate(map, parms);
                break;
            }
        }
        public static bool Prefix(IntVec3 c, Map map, GenStepParams parms, int stackCount = 1)
        {
            /* if (VFECore.VFEGlobal.settings.enableLog)
             * {
             *  Log.Message("Testing defs");
             *  foreach (SymbolDef def in DefDatabase<SymbolDef>.AllDefs)
             *  {
             *      if (def.isTerrain && def.terrainDef == null)
             *          Log.Error("Found invalid terrain def: " + def.defName);
             *      else if (def.isPawn && def.pawnKindDefNS == null)
             *          Log.Error("Found invalid pawn def: " + def.defName);
             *      else if (!def.isTerrain && !def.isPawn && def.thingDef == null)
             *          Log.Error("Found invalid thing def: " + def.defName);
             *  }
             * } */

            if (map.ParentFaction != null && map.ParentFaction.def.HasModExtension <FactionSettlement>())
            {
                FactionSettlement factionSettlement = map.ParentFaction.def.GetModExtension <FactionSettlement>();

                if (factionSettlement.symbolResolver == null)
                {
                    GenStepPatchesUtils.Generate(map, c, factionSettlement);
                }
                else
                {
                    GenStepPatchesUtils.Generate(map, c, factionSettlement, factionSettlement.symbolResolver);
                }

                return(false);
            }
            else if (Find.World.worldObjects.AllWorldObjects.Find(o => o.Tile == map.Tile && o.def.HasModExtension <KCSG.FactionSettlement>()) is WorldObject worldObject)
            {
                FactionSettlement factionSettlement = worldObject.def.GetModExtension <FactionSettlement>();

                if (factionSettlement.symbolResolver == null)
                {
                    GenStepPatchesUtils.Generate(map, c, factionSettlement);
                }
                else
                {
                    GenStepPatchesUtils.Generate(map, c, factionSettlement, factionSettlement.symbolResolver);
                }

                return(false);
            }
            else
            {
                return(true);
            }
        }
        public override void Generate(Map map, GenStepParams parms)
        {
            base.Generate(map, parms);

            var faction = GenCity.RandomCityFaction(f => f.PlayerGoodwill > -50);

            for (var i = 0; i < innocentPawns; i++)
            {
                var pawn = GenCity.SpawnInhabitant(CellRect.WholeMap(map).RandomCell, map, new LordJob_ExitMapBest());
                pawn.SetFactionDirect(faction);
            }

            // map.weatherManager.curWeather = DefDatabase<WeatherDef>.GetNamed("Fog");
        }
Esempio n. 13
0
        static bool Prefix(Map map, GenStepParams parms)
        {
            // solid cave roof for caverns
            if (map.Biome.HasModExtension <BiomesMap>())
            {
                if (map.Biome.GetModExtension <BiomesMap>().isCavern)
                {
                    new RocksFromGrid_Cavern().Generate(map, parms);
                    return(false);
                }
            }

            return(true);
        }
        public override void Generate(Map map, GenStepParams parms)
        {
            if (map.Biome != Util_CaveBiome.CaveBiomeDef)
            {
                // Nothing to do in other biomes.
                return;
            }
            // To avoid starting with standard Clear weather, immediately force to reselect a cave biome weather.
            map.weatherDecider.StartNextWeather();

            GameCondition condition = GameConditionMaker.MakeConditionPermanent(Util_CaveBiome.CaveEnvironmentGameConditionDef);

            map.gameConditionManager.RegisterCondition(condition);
        }
        public override void Generate(Map map, GenStepParams parms)
        {
            var decay         = this.decay.RandomInRange;
            var corpseChance  = this.corpseChance.RandomInRange;
            var maxItemValue  = this.maxItemValue.RandomInRange;
            var _currentThing = (Thing)null;

            foreach (var pos in map.cellsInRandomOrder.GetAll())
            {
                try {
                    var things = pos.GetThingList(map);
                    for (var i = things.Count - 1; i >= 0; i--)
                    {
                        var thing = things[i];
                        _currentThing = thing;
                        if ((thing.MarketValue > maxItemValue || ShouldDestroy(thing, decay)) && !thing.Destroyed)
                        {
                            if (thing is Pawn pawn && !pawn.Faction.IsPlayer && Rand.Chance(corpseChance))
                            {
                                pawn.equipment.DestroyAllEquipment();
                                foreach (var apparel in pawn.apparel.WornApparel)
                                {
                                    if (apparel.MarketValue > maxItemValue * 2)
                                    {
                                        pawn.apparel.Remove(apparel);
                                    }
                                }
                                pawn.Kill(null);
                                pawn.Corpse.timeOfDeath -= Rand.RangeInclusive(10, 500) * 1000;
                            }
                            else
                            {
                                thing.Destroy();
                            }
                            GenLeaving.DropFilthDueToDamage(thing, thing.MaxHitPoints);
                        }
                        else
                        {
                            if (thing is Building_Bed bed)
                            {
                                bed.SetFactionDirect(null);
                            }
                            if (Rand.Chance(decay * decay))
                            {
                                thing.HitPoints = (int)(thing.MaxHitPoints * (1 - Rand.Value * decay));
                            }
                        }
                    }
                }
        public override void Generate(Map map, GenStepParams parms)
        {
            //make everything of evelation 0.9 so rocks will be placed there
            MapGenFloatGrid elevation = MapGenerator.Elevation;

            foreach (IntVec3 intVec in map.AllCells)
            {
                elevation[intVec] = 0.9f;
            }
            MapGenFloatGrid fertility = MapGenerator.Fertility;

            foreach (IntVec3 intVec2 in map.AllCells)
            {
                fertility[intVec2] = 0f;
            }

            //clear a edge as entry
            IntVec3 edgePoint = CellFinder.RandomEdgeCell(map);

            foreach (IntVec3 intVec3 in GenRadial.RadialCellsAround(edgePoint, 8f, true))
            {
                elevation[intVec3] = 0.1f;
            }

            //Create caves. This and the called methods are copied from the vanilla genstep_caves
            this.directionNoise = new Perlin(0.0020500000100582838, 2.0, 0.5, 4, Rand.Int, QualityMode.Medium);
            BoolGrid       visited = new BoolGrid(map);
            List <IntVec3> group   = new List <IntVec3>();

            foreach (IntVec3 intVec in map.AllCells)
            {
                if (!visited[intVec] && this.IsRock(intVec, elevation, map))
                {
                    group.Clear();
                    map.floodFiller.FloodFill(intVec, (IntVec3 x) => this.IsRock(x, elevation, map), delegate(IntVec3 x)
                    {
                        visited[x] = true;
                        group.Add(x);
                    }, int.MaxValue, false, null);
                    this.Trim(group, map);
                    this.RemoveSmallDisconnectedSubGroups(group, map);
                    if (group.Count >= 300)
                    {
                        this.DoOpenTunnels(group, map);
                        this.DoClosedTunnels(group, map);
                    }
                }
            }
        }
Esempio n. 17
0
        protected override void ScatterAt(IntVec3 loc, Map map, GenStepParams parms, int count = 1)
        {
            Pawn pawn = PawnGenerator.GeneratePawn(VFEV_DefOf.VFEV_Mech_Odin, Faction.OfMechanoids);

            List <Pawn> pawns = new List <Pawn>();
            var         lord  = new LordJob_AssaultColony(Faction.OfMechanoids, false, true, true, true, true);

            GenSpawn.Spawn(pawn, loc, map, WipeMode.Vanish);
            pawns.Add(pawn);
            LordMaker.MakeNewLord(Faction.OfMechanoids, lord, map, pawns);


            MapGenerator.rootsToUnfog.Add(loc);
            MapGenerator.SetVar <CellRect>("RectOfInterest", CellRect.CenteredOn(loc, 1, 1));
        }
Esempio n. 18
0
        protected override void ScatterAt(IntVec3 loc, Map map, GenStepParams parms, int count = 1)
        {
            WorldObject worldO = Find.World.worldObjects.AllWorldObjects.Find(o => o.Tile == map.Tile && o.def.HasModExtension <CustomGenOption>());

            CGO.factionSettlement = worldO.def.GetModExtension <CustomGenOption>();

            if (CGO.factionSettlement.symbolResolver == null)
            {
                GenStepUtils.Generate(map, loc, CGO.factionSettlement);
            }
            else
            {
                GenStepUtils.Generate(map, loc, CGO.factionSettlement, CGO.factionSettlement.symbolResolver);
            }
        }
        public override void Generate(Map map, GenStepParams parms)
        {
            ModuleBase tunnels = new Perlin(0.024, 2.2, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);

            tunnels = new ScaleBias(0.5, 0.5, tunnels);

            ModuleBase noise = new Perlin(0.02, 1.5, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.Medium);

            MapGenFloatGrid elevation = MapGenerator.Elevation;

            foreach (IntVec3 cell in map.AllCells)
            {
                elevation[cell] = 0.53f + 2f * Math.Abs(tunnels.GetValue(cell) - 0.5f) + 0.10f * noise.GetValue(cell);
            }
        }
        private static bool Prefix(IntVec3 c, Map map, GenStepParams parms, int stackCount = 1)
        {
            bool result;

            if (map.Parent.Faction.def == PurpleIvyDefOf.Genny)
            {
                GenStep_AlienLair.DoScatterAt(c, map, parms, stackCount);
                result = false;
            }
            else
            {
                result = true;
            }
            return(result);
        }
        public override void Generate(Map map, GenStepParams parms)
        {
            map.regionAndRoomUpdater.Enabled = false;
            float currentPlantDensity             = map.wildPlantSpawner.CurrentPlantDensity;
            float currentWholeMapNumDesiredPlants = map.wildPlantSpawner.CurrentWholeMapNumDesiredPlants;

            foreach (IntVec3 c in map.cellsInRandomOrder.GetAll())
            {
                if (!Rand.Chance(0.001f))
                {
                    map.wildPlantSpawner.CheckSpawnWildPlantAt(c, currentPlantDensity, currentWholeMapNumDesiredPlants, true);
                }
            }
            map.regionAndRoomUpdater.Enabled = true;
        }
        private IEnumerable <Pawn> GeneratePawns(GenStepParams parms, Map map, Faction faction)
        {
            float points = (parms.sitePart == null) ? defaultPointsRange.RandomInRange : parms.sitePart.parms.threatPoints;
            PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms();

            pawnGroupMakerParms.groupKind = PawnGroupKindDefOf.Combat;
            pawnGroupMakerParms.tile      = map.Tile;
            pawnGroupMakerParms.faction   = faction;
            pawnGroupMakerParms.points    = points;
            if (parms.sitePart != null)
            {
                pawnGroupMakerParms.seed = SeedPart;
            }
            return(PawnGroupMakerUtility.GeneratePawns(pawnGroupMakerParms, true));
        }
Esempio n. 23
0
        protected override void ScatterAt(IntVec3 c, Map map, GenStepParams parms, int stackCount = 1)
        {
            ThingDef thingDef = ChooseThingDef();

            if (thingDef != null)
            {
                int numCells = (forcedLumpSize > 0) ? forcedLumpSize : thingDef.building.mineableScatterLumpSizeRange.RandomInRange;
                recentLumpCells.Clear();
                foreach (IntVec3 item in GridShapeMaker.IrregularLump(c, map, numCells))
                {
                    GenSpawn.Spawn(thingDef, item, map);
                    recentLumpCells.Add(item);
                }
            }
        }
        private IEnumerable <Pawn> GeneratePawns(GenStepParams parms, Map map)
        {
            float points = (parms.siteCoreOrPart == null) ? this.defaultPointsRange.RandomInRange : parms.siteCoreOrPart.parms.threatPoints;
            PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms();

            pawnGroupMakerParms.groupKind = PawnGroupKindDefOf.Combat;
            pawnGroupMakerParms.tile      = map.Tile;
            pawnGroupMakerParms.faction   = Faction.OfMechanoids;
            pawnGroupMakerParms.points    = points;
            if (parms.siteCoreOrPart != null)
            {
                pawnGroupMakerParms.seed = new int?(SleepingMechanoidsSitePartUtility.GetPawnGroupMakerSeed(parms.siteCoreOrPart.parms));
            }
            return(PawnGroupMakerUtility.GeneratePawns(pawnGroupMakerParms, true));
        }
Esempio n. 25
0
 // Token: 0x0600001C RID: 28 RVA: 0x00002B78 File Offset: 0x00000D78
 public override void Generate(Map map, GenStepParams parms)
 {
     //map.regionAndRoomUpdater.Enabled = false;
     //foreach (IntVec3 intVec in map.AllCells)
     //{
     //    ThingDef def = GenStep_RocksFromGrid.RockDefAt(intVec);
     //    GenSpawn.Spawn(def, intVec, map, WipeMode.Vanish);
     //    map.roofGrid.SetRoof(intVec, RoofDefOf.RoofRockThick);
     //}
     //GenStep_ScatterLumpsMineable genStep_ScatterLumpsMineable = new GenStep_ScatterLumpsMineable();
     //float num = 16f;
     //genStep_ScatterLumpsMineable.countPer10kCellsRange = new FloatRange(num, num);
     //genStep_ScatterLumpsMineable.Generate(map, default(GenStepParams));
     //map.regionAndRoomUpdater.Enabled = true;
 }
Esempio n. 26
0
        public override void Generate(Map map, GenStepParams parms)
        {
            int num       = 0;
            var mapParent = map.Parent as MapParent_ZLevel;

            if (mapParent.hasCaves)
            {
                int infestationCount = 0;
                if (mapParent.TotalInfestations != null && mapParent.TotalInfestations.Count > 0)
                {
                    infestationCount = mapParent.TotalInfestations.Count;
                }
                var index = 0;
                while (true)
                {
                    if (!map.wildAnimalSpawner.AnimalEcosystemFull)
                    {
                        num++;
                        if (num >= 10000)
                        {
                            break;
                        }
                        IntVec3 loc = IntVec3.Invalid;
                        if (infestationCount > 0 && index < infestationCount && CellFinder.TryFindRandomCellNear
                                (mapParent.TotalInfestations[index].infestationPlace, map, 100,
                                (IntVec3 c) => c.Walkable(map), out loc))
                        {
                            ZLogger.Message("Found loc: " + loc
                                            + " origin place: " + mapParent.TotalInfestations[index].infestationPlace);
                            index++;
                        }
                        else
                        {
                            loc = RCellFinder.RandomAnimalSpawnCell_MapGen(map);
                        }
                        if (!map.wildAnimalSpawner.SpawnRandomWildAnimalAt(loc))
                        {
                            ZLogger.Message("Spawning in loc: " + loc);
                            return;
                        }
                        ZLogger.Message("Spawning in loc: " + loc);
                        continue;
                    }
                    return;
                }
                Log.Error("Too many iterations.");
            }
        }
Esempio n. 27
0
        static void Postfix(Map map, GenStepParams parms)
        {
            if (!map.Biome.HasModExtension <BiomesMap>())
            {
                return;
            }
            BiomesMap biomesMap = map.Biome.GetModExtension <BiomesMap>();

            if (!biomesMap.isValley)
            {
                return;
            }
            MapGenFloatGrid elevation = MapGenerator.Elevation;
            BiomesMap       valleyMap = map.Biome.GetModExtension <BiomesMap>();
            IntVec3         center    = map.Center;
            float           size      = (map.Size.x * map.Size.y) / 2f;
            Random          random    = new Random();
            int             valleyDirectionDecider = random.Next(1, 2);
            float           distance  = 0;
            float           distance2 = 0;
            float           distance3 = 0;

            int valleyType = Rand.Range(0, 2);

            foreach (IntVec3 current in map.AllCells)
            {
                //distance = (float)Math.Sqrt(Math.Pow(current.x - center.x, 2) + Math.Pow(current.z - center.z, 2))
                distance = (float)Math.Sqrt(Math.Pow(current.x - center.x, 2) + Math.Pow(current.z - center.z, 2));

                switch (valleyType)
                {
                case 0:
                    distance2 = (float)Math.Sqrt(Math.Pow(current.z - center.z, 2));
                    break;

                case 1:
                    distance2 = (float)Math.Sqrt(Math.Pow(current.x - center.x, 2));
                    break;

                case 2:
                    distance2 = (float)Math.Sqrt(Math.Pow(current.x - center.x, 2));
                    break;
                }
                distance3 = distance + (distance2 * 1.3f);
                //distance3 = Rand.Range(distance, distance2);
                elevation[current] *= (Math.Min(Rand.Range(valleyMap.minHillEdgeMultiplier, valleyMap.maxHillEdgeMultiplier), Rand.Range(valleyMap.minHillEncroachment, valleyMap.maxHillEncroachment) * 2) * distance3 / size);
            }
        }
Esempio n. 28
0
        protected override void ScatterAt(IntVec3 loc, Map map, GenStepParams parms, int count = 1)
        {
            Faction  faction  = (map.ParentFaction != null && map.ParentFaction != Faction.OfPlayer) ? map.ParentFaction : Find.FactionManager.RandomEnemyFaction();
            CellRect rect     = CellRect.CenteredOn(loc, 10, 10).ClipInsideMap(map);
            SitePart sitePart = currentParams.sitePart;

            sitePart.conditionCauserWasSpawned = true;
            ResolveParams resolveParams = default(ResolveParams);

            resolveParams.rect            = rect;
            resolveParams.faction         = faction;
            resolveParams.conditionCauser = sitePart.conditionCauser;
            RimWorld.BaseGen.BaseGen.globalSettings.map = map;
            RimWorld.BaseGen.BaseGen.symbolStack.Push("conditionCauserRoom", resolveParams);
            RimWorld.BaseGen.BaseGen.Generate();
        }
Esempio n. 29
0
        public override void Generate(Map map, GenStepParams parms)
        {
            var waterGrid = map.GetComponent <MapComponent_DeepWaterGrid>();

            MizuUtility.GenerateUndergroundWaterGrid(
                map,
                waterGrid,
                basePoolNum,
                minWaterPoolNum,
                baseRainFall,
                basePlantDensity,
                literPerCell,
                poolCellRange,
                baseRegenRateRange,
                rainRegenRatePerCell);
        }
        protected override void ScatterAt(IntVec3 loc, Map map, GenStepParams parms, int count = 1)
        {
            var  component = map.info.parent.GetComponent <DownedT5AndroidComp>();
            Pawn newThing;

            if (component != null && component.pawn.Any)
            {
                newThing = component.pawn.Take(component.pawn[0]);
            }
            else
            {
                newThing = DownedT5Utility.GenerateT5(map.Tile);
            }
            GenSpawn.Spawn(newThing, loc, map);
            MapGenerator.rootsToUnfog.Add(loc);
        }