// Token: 0x060029E3 RID: 10723 RVA: 0x0013D300 File Offset: 0x0013B700 public bool TrySpawnChildHiveLike(bool ignoreRoofedRequirement, out HiveLike newHiveLike) { if (!this.CanSpawnChildHiveLike) { newHiveLike = null; return(false); } IntVec3 loc = CompSpawner_HiveLike_CrashedShipPart.FindChildHiveLocation(this.parent.Position, this.parent.Map, this.parent.def, this.Props, true, false); if (!loc.IsValid) { newHiveLike = null; return(false); } newHiveLike = (HiveLike)ThingMaker.MakeThing(this.parent.def, null); if (newHiveLike.Faction != this.parent.Faction) { newHiveLike.SetFaction(this.parent.Faction, null); } HiveLike hivelike = this.parent as HiveLike; if (hivelike != null) { newHiveLike.active = hivelike.active; } GenSpawn.Spawn(newHiveLike.Def.TunnelDef, loc, this.parent.Map, WipeMode.FullRefund); this.CalculateNextHiveLikeSpawnTick(); return(true); }
private HiveLike SpawnHiveLikeCluster(int hiveCount, Map map) { ; IntVec3 loc = DropCellFinder.RandomDropSpot(map); ThingDef_HiveLike thingDef = (ThingDef_HiveLike)this.def.mechClusterBuilding; HiveLike hivelike = (HiveLike)ThingMaker.MakeThing(thingDef, null); GenSpawn.Spawn(ThingMaker.MakeThing(hivelike.OfTunnel, null), loc, map); hivelike.SetFaction(hivelike.OfFaction, null); IncidentWorker_Hivelike.SpawnItemInstantly(hivelike); for (int i = 0; i < hiveCount - 1; i++) { HiveLike hivelike2; CompSpawnerHiveLikes c = hivelike.GetComp <CompSpawnerHiveLikes>(); if (hivelike.Spawned && hivelike.GetComp <CompSpawnerHiveLikes>().TrySpawnChildHiveLike(true, out hivelike2)) { IncidentWorker_Hivelike.SpawnItemInstantly(hivelike2); hivelike = hivelike2; } } return(hivelike); }
// Token: 0x06002627 RID: 9767 RVA: 0x00122210 File Offset: 0x00120610 public override void Tick() { if (base.Spawned) { HiveLike hive = (HiveLike)ThingMaker.MakeThing(hiveDef, null); this.sustainer.Maintain(); Vector3 vector = base.Position.ToVector3Shifted(); IntVec3 c; ResetStaticData(); if (Rand.MTBEventOccurs(FilthSpawnMTB, 1f, 1.TicksToSeconds()) && CellFinder.TryFindRandomReachableCellNear(base.Position, base.Map, TunnelHiveLikeSpawner.FilthSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out c, 999999)) { FilthMaker.MakeFilth(c, base.Map, filthTypes.RandomElement <ThingDef>(), 1); } if (Rand.MTBEventOccurs(DustMoteSpawnMTB, 1f, 1.TicksToSeconds())) { MoteMaker.ThrowDustPuffThick(new Vector3(vector.x, 0f, vector.z) { y = AltitudeLayer.MoteOverhead.AltitudeFor() }, base.Map, Rand.Range(1.5f, 3f), new Color(1f, 1f, 1f, 2.5f)); } if (this.secondarySpawnTick <= Find.TickManager.TicksGame) { this.sustainer.End(); Map map = base.Map; IntVec3 position = base.Position; this.Destroy(DestroyMode.Vanish); if (this.spawnHive) { if (Def.strikespreexplode) { FireEvent(map, position); EventDraw(map, position); } if (Def.explodesprespawn) { GenExplosion.DoExplosion(position, map, Def.blastradius, Def.damageDef, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false); } hive = (HiveLike)GenSpawn.Spawn(ThingMaker.MakeThing(hiveDef, null), position, map, WipeMode.Vanish); hive.SetFaction(faction, null); foreach (CompSpawnerLike compSpawner in hive.GetComps <CompSpawnerLike>()) { if (compSpawner.PropsSpawner.thingToSpawn == ThingDefOf.InsectJelly) { compSpawner.TryDoSpawn(); break; } } } if (this.hivePoints > 0f) { this.hivePoints = Mathf.Max(this.hivePoints, pawnKinds.Min((PawnKindDef x) => x.combatPower)); float pointsLeft = this.hivePoints; List <Pawn> list = new List <Pawn>(); int num = 0; while (pointsLeft > 0f) { num++; if (num > 1000) { Log.Error("Too many iterations.", false); break; } IEnumerable <PawnKindDef> source = from x in pawnKinds where x.combatPower <= pointsLeft select x; PawnKindDef pawnKindDef; if (!source.TryRandomElement(out pawnKindDef)) { break; } Pawn pawn = PawnGenerator.GeneratePawn(pawnKindDef, faction); GenSpawn.Spawn(pawn, CellFinder.RandomClosewalkCellNear(position, map, 2, null), map, WipeMode.Vanish); pawn.mindState.spawnedByInfestationThingComp = this.spawnedByInfestationThingComp; list.Add(pawn); pointsLeft -= pawnKindDef.combatPower; } if (list.Any <Pawn>()) { LordMaker.MakeNewLord(faction, new LordJob_AssaultColony(faction, true, false, false, false, true), map, list); } } } } }