Ejemplo n.º 1
0
        private static void TrySpawnHive(Map map)
        {
            IntVec3 intVec3;

            if (!TryFindHiveSpawnCell(map, out intVec3))
            {
                return;
            }

            possibleSpawnCells.Remove(intVec3);
            Hive hive = (Hive)GenSpawn.Spawn(ThingMaker.MakeThing(ThingDefOf.Hive, null), intVec3, map, WipeMode.Vanish);

            hive.SetFaction(Faction.OfInsects, null);
            //hive.caveColony = true;

            (
                from x in hive.GetComps <CompSpawner>()
                where x.PropsSpawner.thingToSpawn == ThingDefOf.GlowPod
                select x
            ).First <CompSpawner>().TryDoSpawn();

            hive.PawnSpawner.SpawnPawnsUntilPoints(Rand.Range(200f, 500f));
            hive.PawnSpawner.canSpawnPawns = false;
            hive.GetComp <CompSpawnerHives>().canSpawnHives = false;
            hive.GetComp <CompSpawnerBugs>().SetActive(false);

            spawnedHives.Add(hive);
        }
        public override void Resolve(ResolveParams rp)
        {
            IntVec3 loc;

            if (!this.TryFindFirstHivePos(rp.rect, out loc))
            {
                return;
            }
            int? hivesCount = rp.hivesCount;
            int  num        = (hivesCount == null) ? SymbolResolver_Hives.DefaultHivesCountRange.RandomInRange : hivesCount.Value;
            Hive hive       = (Hive)ThingMaker.MakeThing(ThingDefOf.Hive, null);

            hive.SetFaction(Faction.OfInsects, null);
            if (rp.disableHives != null && rp.disableHives.Value)
            {
                hive.active = false;
            }
            hive = (Hive)GenSpawn.Spawn(hive, loc, BaseGen.globalSettings.map, WipeMode.Vanish);
            for (int i = 0; i < num - 1; i++)
            {
                Hive hive2;
                if (hive.GetComp <CompSpawnerHives>().TrySpawnChildHive(true, out hive2))
                {
                    hive = hive2;
                }
            }
        }
Ejemplo n.º 3
0
        static bool Prefix(SymbolResolver_Hives __instance, ResolveParams rp)
        {
            IntVec3  intVec3;
            Hive     hive;
            IntRange DefaultHivesCountRange = new IntRange(1, 3);

            if (!TryFindFirstHivePos(rp.rect, out intVec3))
            {
                return(false);
            }
            int? nullable = rp.hivesCount;
            int  num      = (!nullable.HasValue ? DefaultHivesCountRange.RandomInRange : nullable.Value);
            Hive hive1    = (Hive)ThingMaker.MakeThing(ThingDefOf.Hive, null);

            hive1.SetFaction(Faction.OfInsects, null);
            if (rp.disableHives.HasValue && rp.disableHives.Value)
            {
                hive1.CompDormant.ToSleep();
            }

            hive1 = (Hive)GenSpawn.Spawn(hive1, intVec3, BaseGen.globalSettings.map, WipeMode.Vanish);

            CompSpawnerBugs bugs = hive1.GetComp <CompSpawnerBugs>();

            if (bugs != null)
            {
                bugs.SetActive(false);
            }

            for (int i = 0; i < num - 1; i++)
            {
                if (hive1.GetComp <CompSpawnerHives>().TrySpawnChildHive(true, out hive))
                {
                    hive1 = hive;

                    CompSpawnerBugs bugs1 = hive.GetComp <CompSpawnerBugs>();

                    if (bugs1 != null)
                    {
                        bugs1.SetActive(false);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 4
0
 private void TrySpawnHive(Map map)
 {
     if (TryFindHiveSpawnCell(map, out IntVec3 spawnCell))
     {
         possibleSpawnCells.Remove(spawnCell);
         Hive hive = (Hive)GenSpawn.Spawn(ThingMaker.MakeThing(ThingDefOf.Hive), spawnCell, map);
         hive.SetFaction(Faction.OfInsects);
         hive.PawnSpawner.aggressive = false;
         (from x in hive.GetComps <CompSpawner>()
          where x.PropsSpawner.thingToSpawn == ThingDefOf.GlowPod
          select x).First().TryDoSpawn();
         hive.PawnSpawner.SpawnPawnsUntilPoints(Rand.Range(200f, 500f));
         hive.PawnSpawner.canSpawnPawns = false;
         hive.GetComp <CompSpawnerHives>().canSpawnHives = false;
         spawnedHives.Add(hive);
     }
 }
        // Token: 0x0600018B RID: 395 RVA: 0x0000EC70 File Offset: 0x0000CE70
        public override void Resolve(ResolveParams rp)
        {
            Map map = BaseGen.globalSettings.map;

            Rand.PushState();
            for (int i = 0; i < Rand.RangeInclusive(5, 20); i++)
            {
                Faction faction    = rp.faction;
                IntVec3 randomCell = rp.rect.RandomCell;
                bool    flag       = randomCell.Standable(map) && randomCell.GetFirstItem(map) == null && randomCell.GetFirstPawn(map) == null && randomCell.GetFirstBuilding(map) == null;
                if (flag)
                {
                    bool flag2 = Rand.RangeInclusive(1, 4) < 3;
                    if (flag2)
                    {
                        ThingDef hivedef = faction.HivedefsFor().RandomElement() ?? RimWorld.ThingDefOf.Hive;
                        Hive     hive    = (Hive)GenSpawn.Spawn(ThingMaker.MakeThing(hivedef, null), randomCell, map, WipeMode.Vanish);
                        hive.SetFaction(faction, null);
                        foreach (CompSpawner compSpawner in hive.GetComps <CompSpawner>())
                        {
                            if (compSpawner.PropsSpawner.thingToSpawn == RimWorld.ThingDefOf.InsectJelly)
                            {
                                compSpawner.TryDoSpawn();
                                break;
                            }
                        }
                    }
                    else
                    {
                        ThingDef hivedef = faction.HivedefsFor().RandomElement() ?? RimWorld.ThingDefOf.Hive;
                        Hive     hive2   = (Hive)GenSpawn.Spawn(ThingMaker.MakeThing(hivedef, null), randomCell, map, WipeMode.Vanish);
                        hive2.SetFaction(faction, null);
                        foreach (CompSpawner compSpawner2 in hive2.GetComps <CompSpawner>())
                        {
                            if (compSpawner2.PropsSpawner.thingToSpawn == RimWorld.ThingDefOf.InsectJelly)
                            {
                                compSpawner2.TryDoSpawn();
                                break;
                            }
                        }
                    }
                }
            }
            Rand.PopState();
        }
Ejemplo n.º 6
0
 public override void Resolve(ResolveParams rp)
 {
     if (TryFindFirstHivePos(rp.rect, out IntVec3 pos))
     {
         int? hivesCount = rp.hivesCount;
         int  num        = (!hivesCount.HasValue) ? DefaultHivesCountRange.RandomInRange : hivesCount.Value;
         Hive hive       = (Hive)ThingMaker.MakeThing(ThingDefOf.Hive);
         hive.SetFaction(Faction.OfInsects);
         if (rp.disableHives.HasValue && rp.disableHives.Value)
         {
             hive.active = false;
         }
         hive = (Hive)GenSpawn.Spawn(hive, pos, BaseGen.globalSettings.map);
         for (int i = 0; i < num - 1; i++)
         {
             if (hive.GetComp <CompSpawnerHives>().TrySpawnChildHive(ignoreRoofedRequirement: true, out Hive newHive))
             {
                 hive = newHive;
             }
         }
     }
 }
        public override void Resolve(ResolveParams rp)
        {
            if (!TryFindFirstHivePos(rp.rect, out var pos))
            {
                return;
            }
            int  num  = rp.hivesCount ?? DefaultHivesCountRange.RandomInRange;
            Hive hive = (Hive)ThingMaker.MakeThing(ThingDefOf.Hive);

            hive.SetFaction(Faction.OfInsects);
            if (rp.disableHives.HasValue && rp.disableHives.Value)
            {
                hive.CompDormant.ToSleep();
            }
            hive = (Hive)GenSpawn.Spawn(hive, pos, BaseGen.globalSettings.map);
            for (int i = 0; i < num - 1; i++)
            {
                if (hive.GetComp <CompSpawnerHives>().TrySpawnChildHive(ignoreRoofedRequirement: true, out var newHive))
                {
                    hive = newHive;
                }
            }
        }