public static bool Prefix(GenStep_CaveHives __instance, Map map) { ModExt_Biome_FeatureControl extFtControl = map.Biome.GetModExtension <ModExt_Biome_FeatureControl>(); if (extFtControl != null && extFtControl.overwriteHives == HiveOverwriteType.Remove) { return(false); } return(true); }
public static void Postfix(GenStep_CaveHives __instance, Map map) { ModExt_Biome_FeatureControl extFtControl = map.Biome.GetModExtension <ModExt_Biome_FeatureControl>(); if (extFtControl != null && extFtControl.overwriteHives == HiveOverwriteType.AddActive) { List <Hive> spawnedHives = Traverse.Create(__instance).Field("spawnedHives").GetValue <List <Hive> >(); Hive lastAddedHive = spawnedHives.Last(); lastAddedHive.canSpawnPawns = true; lastAddedHive.GetComp <CompSpawnerHives>().canSpawnHives = true; } }
public static void Postfix(GenStep_CaveHives __instance, Map map) { ModExt_Biome_FeatureControl extFtControl = map.Biome.GetModExtension <ModExt_Biome_FeatureControl>(); if (extFtControl != null && (extFtControl.overwriteHives == HiveOverwriteType.Add || extFtControl.overwriteHives == HiveOverwriteType.AddActive)) { int hiveCount = map.ScaleValueOnSize(extFtControl.additionalHivesScaling); Traverse trav = Traverse.Create(__instance).Method("TrySpawnHive", new object[] { map }); for (int i = 0; i < hiveCount; i++) { trav.GetValue(); } } }
static bool Prefix(GenStep_CaveHives __instance, Map map, GenStepParams parms) { Func <Thing, bool> func = null; if (!Find.Storyteller.difficulty.allowCaveHives) { return(false); } MapGenFloatGrid caves = MapGenerator.Caves; MapGenFloatGrid elevation = MapGenerator.Elevation; float single = 0.7f; int num = 0; rockCells.Clear(); foreach (IntVec3 allCell in map.AllCells) { if (elevation[allCell] > single) { rockCells.Add(allCell); } if (caves[allCell] <= 0f) { continue; } num++; } List <IntVec3> list = map.AllCells.Where <IntVec3>((IntVec3 c) => { IEnumerable <Thing> things = map.thingGrid.ThingsAt(c); if (func == null) { func = (Thing thing) => thing.Faction != null; } return(things.Any <Thing>(func)); }).ToList <IntVec3>(); GenMorphology.Dilate(list, 50, map, null); HashSet <IntVec3> intVec3s = new HashSet <IntVec3>(list); int num1 = GenMath.RoundRandom((float)num / 1000f); GenMorphology.Erode(rockCells, 10, map, null); possibleSpawnCells.Clear(); for (int i = 0; i < rockCells.Count; i++) { if (caves[rockCells[i]] > 0f && !intVec3s.Contains(rockCells[i])) { possibleSpawnCells.Add(rockCells[i]); } } spawnedHives.Clear(); for (int j = 0; j < num1; j++) { TrySpawnHive(map); } spawnedHives.Clear(); return(false); }