// RimWorld.ScenPart_PlayerPawnsArriveMethod public static bool GenerateIntoMap(ScenPart_PlayerPawnsArriveMethod __instance, Map map) { if (currentlyGenerating) { return(true); } currentlyGenerating = true; if (Find.GameInitData != null) { var REScenarios = new List <string> { "Resident Evil", "Resident Evil - Umbrella Corp", "Resident Evil - Naked Brutality" }; if (REScenarios.Any(x => x == Find.Scenario.name)) { startingPawns = new List <Pawn>(Find.GameInitData.startingAndOptionalPawns); var fac = startingPawns.First().Faction; var pos = startingPawns.First().Position; if (Find.Scenario.name == "Resident Evil - Umbrella Corp") { ScenarioGen.CreateBase(fac, pos, map); currentlyGenerating = false; return(false); } else if (Find.Scenario.name == "Resident Evil") { ScenarioGen.CreateOutpost(fac, pos, map); currentlyGenerating = false; return(true); } } } return(true); }
public DungeonGenerator(Faction fac, IntVec3 pos, Map newMap, int numOfLayers) { map = newMap; maxDepth = numOfLayers; int maxX = map.Center.x * 2; int maxZ = map.Center.z * 2; int xDiff = (int)(maxX * 0.1f); int zDiff = (int)(maxZ * 0.1f); debugMap = new char[map.Size.z, map.Size.x]; for (int z = 0; z < map.Size.z; z++) { for (int x = 0; x < map.Size.x; x++) { debugMap[z, x] = '.'; } } foreach (IntVec3 unusedCell in map.AllCells) { if (cellPainter.ContainsKey(unusedCell)) { continue; } cellPainter.Add(unusedCell, SpawnType.Nothing); } CellRect newRect = new CellRect(xDiff, zDiff, maxX - (xDiff), maxZ - (zDiff)); CreateDungeonLayers(1, numOfLayers, baseRoot, newRect); CreateDungeonHallways(baseRoot); var rooms = GetLeaves(baseRoot, new List <DungeonNode>()); var startingRoom = rooms.FirstOrDefault(x => x.cells.Width >= 24 && x.cells.Height >= 24); if (startingRoom == null) { startingRoom = rooms.Last(); } foreach (var node in rooms) { RoomGeneration(node, node == startingRoom); } foreach (var node in hallwaysAndRooms) { for (int i = 0; i < 4; i++) { TryMakeADoor(node); } } PaintAll(); var roomsInRandomOrder = rooms.InRandomOrder(); ScenarioGen.CreateStartingArea(fac, map, pos, startingRoomRect); ApplyRoomDefsToRooms(roomsInRandomOrder.ToList()); StringBuilder s = new StringBuilder(); for (int x2 = map.Size.x - 1; x2 > 1; x2--) { for (int z2 = 0; z2 < map.Size.z; z2++) { s.Append(debugMap[z2, x2]); } s.AppendLine(); } Log.Message(s.ToString()); }
public override void StartedNewGame() { Log.Message("Started new game"); var REScenarios = new List <string> { "Resident Evil", "Resident Evil - Umbrella Corp", "Resident Evil - Naked Brutality" }; if (REScenarios.Any(x => x == Find.Scenario.name)) { var map = underground == null?HarmonyPatches.startingPawns.First().Map : underground; var pos = HarmonyPatches.startingPawns.First().Position; foreach (Pawn startingAndOptionalPawn in HarmonyPatches.startingPawns) { if (startingAndOptionalPawn.Spawned) { //Give K9 backstory characters a Doberman. if (startingAndOptionalPawn.Spawned && startingAndOptionalPawn.story != null && startingAndOptionalPawn.story.childhood != null && startingAndOptionalPawn.story.childhood.title == "Police Cadet (K9)") { var pawn = PawnGenerator.GeneratePawn(PawnKindDef.Named("RE_DobermanPinscherKind"), startingAndOptionalPawn.Faction); GenPlace.TryPlaceThing(pawn, startingAndOptionalPawn.PositionHeld, startingAndOptionalPawn.MapHeld, ThingPlaceMode.Near); pawn.training.Train(TrainableDefOf.Obedience, startingAndOptionalPawn, true); pawn.playerSettings.Master = startingAndOptionalPawn; } //All characters start off aggressive startingAndOptionalPawn.playerSettings.hostilityResponse = HostilityResponseMode.Attack; if (Find.Scenario.name == "Resident Evil") { ScenarioGen.CreateBeds(startingAndOptionalPawn, startingAndOptionalPawn.Map, ThingDefOf.Bedroll, ThingDefOf.Cloth); } } else { //Spawn dead bodies of other STARS members in the map. CellFinder.TryFindBestPawnStandCell(startingAndOptionalPawn, out IntVec3 spot); GenPlace.TryPlaceThing(startingAndOptionalPawn, spot, Find.AnyPlayerHomeMap, ThingPlaceMode.Near); startingAndOptionalPawn.Kill(null); } } Current.Game.CurrentMap = map; //FloodFillerFog.FloodUnfog(pos, map); } }