private HiveLike SpawnHiveLikeCluster(int hiveCount, Map map, bool ignoreRoofedRequirement = false, bool allowUnreachable = false, float modifier = 1)
        {
            ;
            IntVec3           loc      = intVec;
            ThingDef_HiveLike thingDef = (ThingDef_HiveLike)this.def.mechClusterBuilding;
            HiveLike          hivelike = (HiveLike)ThingMaker.MakeThing(thingDef, null);

            GenSpawn.Spawn(ThingMaker.MakeThing(hivelike.Def.TunnelDef, null), loc, map);
            hivelike.SetFaction(hivelike.OfFaction, null);
            IncidentWorker_Xenomorph_Hivelike.SpawnItemInstantly(hivelike);
            for (int i = 0; i < hiveCount - 1; i++)
            {
                CompSpawnerHiveLikes c = hivelike.GetComp <CompSpawnerHiveLikes>();
                if (hivelike.Spawned && hivelike.GetComp <CompSpawnerHiveLikes>().TrySpawnChildHiveLike(modifier, modifier, out HiveLike hivelike2, ignoreRoofedRequirement, allowUnreachable))
                {
                    IncidentWorker_Xenomorph_Hivelike.SpawnItemInstantly(hivelike2);
                    hivelike = hivelike2;
                }
            }
            return(hivelike);
        }
Esempio n. 2
0
        private HiveLike SpawnHiveLikeCluster(int hiveCount, Map map)
        {
            ;
            IntVec3           loc      = DropCellFinder.RandomDropSpot(map);
            ThingDef_HiveLike thingDef = (ThingDef_HiveLike)this.def.shipPart;
            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: 0x0600118A RID: 4490 RVA: 0x00084ED4 File Offset: 0x000832D4
        private void TrySpawnHive(Map map)
        {
            IntVec3 intVec;

            if (!this.TryFindHiveSpawnCell(map, out intVec))
            {
                return;
            }
            this.possibleSpawnCells.Remove(intVec);
            HiveLike hive = (HiveLike)GenSpawn.Spawn(ThingMaker.MakeThing(XenomorphDefOf.RRY_Xenomorph_Hive, null), intVec, map, WipeMode.Vanish);

            hive.SetFaction(Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph), null);
            hive.caveColony = true;

            /*
             * (from x in hive.GetComps<CompSpawner>()
             * where x.PropsSpawner.thingToSpawn == ThingDefOf.GlowPod
             * select x).First<CompSpawner>().TryDoSpawn();
             */
            hive.SpawnPawnsUntilPoints(Rand.Range(200f, 500f));
            hive.canSpawnPawns = false;
            hive.GetComp <CompSpawnerHiveLikes>().canSpawnHiveLikes = false;
            this.spawnedHives.Add(hive);
        }
Esempio n. 4
0
 // 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();
         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 IntVec3 c, 999999))
         {
             FilthMaker.TryMakeFilth(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);
                 hive.InitialPawnsPoints    = hivePoints / 2;
                 hive.MaxSpawnedPawnsPoints = hivePoints;
                 if (parentHiveLike != null)
                 {
                     parentHiveLike.childHiveLikes.Add(hive);
                 }
                 foreach (CompXenomorph_SpawnerLike compSpawner in hive.GetComps <CompXenomorph_SpawnerLike>())
                 {
                     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;
                     if (!source.TryRandomElement(out PawnKindDef 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);
                 }
             }
         }
     }
 }