Example #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;
                }
            }
        }
Example #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);
        }
        public static void Postfix(GenStep_CaveHives __instance, Map map)
        {
            ModExt_Biome_FeatureControl extFtControl = map.Biome.GetModExtension <ModExt_Biome_FeatureControl>();

            if (extFtControl != null && extFtControl.overwriteHives == HiveOverwriteType.AddActive)
            {
                List <Hive> spawnedHives  = Traverse.Create(__instance).Field("spawnedHives").GetValue <List <Hive> >();
                Hive        lastAddedHive = spawnedHives.Last();
                lastAddedHive.canSpawnPawns = true;
                lastAddedHive.GetComp <CompSpawnerHives>().canSpawnHives = true;
            }
        }
Example #5
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);
     }
 }