public override void CompTickRare() { HorrorDen hive = this.parent as HorrorDen; if ((hive == null || hive.active) && Find.TickManager.TicksGame >= this.nextHiveSpawnTick) { HorrorDen hive2; if (this.TrySpawnChildHive(false, out hive2)) { hive2.nextPawnSpawnTick = Find.TickManager.TicksGame + Rand.Range(150, 350); Messages.Message("MessageHiveReproduced".Translate(), hive2, MessageTypeDefOf.NegativeEvent); } else { this.CalculateNextHiveSpawnTick(); } } }
public bool TrySpawnChildHive(bool ignoreRoofedRequirement, out HorrorDen 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 = (HorrorDen)GenSpawn.Spawn(ThingDef.Named("HorrorDen"), invalid, this.parent.Map); if (newHive.Faction != this.parent.Faction) { newHive.SetFaction(this.parent.Faction, null); } this.CalculateNextHiveSpawnTick(); return(true); }