private HorrorHive SpawnHiveCluster(int hiveCount, Map map) { IntVec3 loc; if (!InfestationCellFinder.TryFindCell(out loc, map)) { return(null); } HorrorHive hive = (HorrorHive)GenSpawn.Spawn(ThingMaker.MakeThing(ThingDef.Named("HorrorHive"), null), loc, map); hive.SetFaction(Find.FactionManager.FirstFactionOfDef(FactionDef.Named("Horrors"))); return(hive); }
public bool TrySpawnChildHive(bool ignoreRoofedRequirement, out HorrorHive newHive) { if (!this.CanSpawnChildHive) { newHive = null; return(false); } IntVec3 invalid = IntVec3.Invalid; for (int i = 0; i < 3; i++) { float minDist = this.Props.HiveSpawnPreferredMinDist; if (i == 1) { minDist = 0f; } else { if (i == 2) { newHive = null; return(false); } } if (CellFinder.TryFindRandomReachableCellNear(this.parent.Position, this.parent.Map, this.Props.HiveSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), (IntVec3 c) => this.CanSpawnHiveAt(c, minDist, ignoreRoofedRequirement), null, out invalid, 999999)) { break; } } newHive = (HorrorHive)GenSpawn.Spawn(this.parent.def, invalid, this.parent.Map); if (newHive.Faction != this.parent.Faction) { newHive.SetFaction(this.parent.Faction, null); } HorrorHive hive = this.parent as HorrorHive; if (hive != null) { newHive.active = hive.active; } this.CalculateNextHiveSpawnTick(); return(true); }