public bool TrySpawnChildHive(bool ignoreRoofedRequirement, out Hive newHive)
        {
            bool result;

            if (!this.CanSpawnChildHive)
            {
                newHive = null;
                result  = false;
            }
            else
            {
                IntVec3 loc = CompSpawnerHives.FindChildHiveLocation(this.parent.Position, this.parent.Map, this.parent.def, this.Props, ignoreRoofedRequirement);
                if (!loc.IsValid)
                {
                    newHive = null;
                    result  = false;
                }
                else
                {
                    newHive = (Hive)GenSpawn.Spawn(this.parent.def, loc, this.parent.Map, WipeMode.FullRefund);
                    if (newHive.Faction != this.parent.Faction)
                    {
                        newHive.SetFaction(this.parent.Faction, null);
                    }
                    Hive hive = this.parent as Hive;
                    if (hive != null)
                    {
                        newHive.active = hive.active;
                    }
                    this.CalculateNextHiveSpawnTick();
                    result = true;
                }
            }
            return(result);
        }
        public bool TrySpawnChildHive(bool ignoreRoofedRequirement, out Hive newHive)
        {
            if (!this.CanSpawnChildHive)
            {
                newHive = null;
                return(false);
            }
            IntVec3 loc = CompSpawnerHives.FindChildHiveLocation(this.parent.Position, this.parent.Map, this.parent.def, this.Props, ignoreRoofedRequirement, false);

            if (!loc.IsValid)
            {
                newHive = null;
                return(false);
            }
            newHive = (Hive)ThingMaker.MakeThing(this.parent.def, null);
            if (newHive.Faction != this.parent.Faction)
            {
                newHive.SetFaction(this.parent.Faction, null);
            }
            Hive hive = this.parent as Hive;

            if (hive != null)
            {
                newHive.active = hive.active;
            }
            GenSpawn.Spawn(newHive, loc, this.parent.Map, WipeMode.FullRefund);
            this.CalculateNextHiveSpawnTick();
            return(true);
        }
示例#3
0
        public static Thing SpawnTunnels(int hiveCount, Map map, bool spawnAnywhereIfNoGoodCell = false, bool ignoreRoofedRequirement = false, string questTag = null)
        {
            if (!InfestationCellFinder.TryFindCell(out var cell, map))
            {
                if (!spawnAnywhereIfNoGoodCell)
                {
                    return(null);
                }
                if (!RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith(delegate(IntVec3 x)
                {
                    if (!x.Standable(map) || x.Fogged(map))
                    {
                        return(false);
                    }
                    bool flag = false;
                    int num = GenRadial.NumCellsInRadius(3f);
                    for (int j = 0; j < num; j++)
                    {
                        IntVec3 c = x + GenRadial.RadialPattern[j];
                        if (c.InBounds(map))
                        {
                            RoofDef roof = c.GetRoof(map);
                            if (roof != null && roof.isThickRoof)
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                    return(flag ? true : false);
                }, map, out cell))
                {
                    return(null);
                }
            }
            Thing thing = GenSpawn.Spawn(ThingMaker.MakeThing(ThingDefOf.TunnelHiveSpawner), cell, map, WipeMode.FullRefund);

            QuestUtility.AddQuestTag(thing, questTag);
            for (int i = 0; i < hiveCount - 1; i++)
            {
                cell = CompSpawnerHives.FindChildHiveLocation(thing.Position, map, ThingDefOf.Hive, ThingDefOf.Hive.GetCompProperties <CompProperties_SpawnerHives>(), ignoreRoofedRequirement, allowUnreachable: true);
                if (cell.IsValid)
                {
                    thing = GenSpawn.Spawn(ThingMaker.MakeThing(ThingDefOf.TunnelHiveSpawner), cell, map, WipeMode.FullRefund);
                    QuestUtility.AddQuestTag(thing, questTag);
                }
            }
            return(thing);
        }
示例#4
0
        private Thing SpawnTunnels(int hiveCount, Map map)
        {
            if (!InfestationCellFinder.TryFindCell(out IntVec3 cell, map))
            {
                return(null);
            }
            Thing thing = GenSpawn.Spawn(ThingMaker.MakeThing(ThingDefOf.TunnelHiveSpawner), cell, map, WipeMode.FullRefund);

            for (int i = 0; i < hiveCount - 1; i++)
            {
                cell = CompSpawnerHives.FindChildHiveLocation(thing.Position, map, ThingDefOf.Hive, ThingDefOf.Hive.GetCompProperties <CompProperties_SpawnerHives>(), ignoreRoofedRequirement: false, allowUnreachable: true);
                if (cell.IsValid)
                {
                    thing = GenSpawn.Spawn(ThingMaker.MakeThing(ThingDefOf.TunnelHiveSpawner), cell, map, WipeMode.FullRefund);
                }
            }
            return(thing);
        }
示例#5
0
        private Thing SpawnTunnels(int hiveCount, Map map)
        {
            IntVec3 loc;

            if (!InfestationCellFinder.TryFindCell(out loc, map))
            {
                return(null);
            }
            Thing thing = GenSpawn.Spawn(ThingMaker.MakeThing(ThingDefOf.TunnelHiveSpawner, null), loc, map, WipeMode.FullRefund);

            for (int i = 0; i < hiveCount - 1; i++)
            {
                loc = CompSpawnerHives.FindChildHiveLocation(thing.Position, map, ThingDefOf.Hive, ThingDefOf.Hive.GetCompProperties <CompProperties_SpawnerHives>(), false, true);
                if (loc.IsValid)
                {
                    thing = GenSpawn.Spawn(ThingMaker.MakeThing(ThingDefOf.TunnelHiveSpawner, null), loc, map, WipeMode.FullRefund);
                }
            }
            return(thing);
        }