コード例 #1
0
        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);
        }
コード例 #2
0
        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
        private void Activate()
        {
            this.active            = true;
            this.nextPawnSpawnTick = Find.TickManager.TicksGame + Rand.Range(200, 400);
            CompSpawnerHives comp = base.GetComp <CompSpawnerHives>();

            if (comp != null)
            {
                comp.CalculateNextHiveSpawnTick();
            }
        }
コード例 #4
0
        private void Activate()
        {
            this.active = true;
            this.CalculateNextPawnSpawnTick();
            CompSpawnerHives comp = base.GetComp <CompSpawnerHives>();

            if (comp != null)
            {
                comp.CalculateNextHiveSpawnTick();
            }
        }
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
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);
        }
コード例 #8
0
        public static IntVec3 FindChildHiveLocation(IntVec3 pos, Map map, ThingDef parentDef, CompProperties_SpawnerHives props, bool ignoreRoofedRequirement)
        {
            IntVec3 intVec = IntVec3.Invalid;

            for (int i = 0; i < 2; i++)
            {
                float minDist = props.HiveSpawnPreferredMinDist;
                if (i == 1)
                {
                    minDist = 0f;
                }
                if (CellFinder.TryFindRandomReachableCellNear(pos, map, props.HiveSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), (IntVec3 c) => CompSpawnerHives.CanSpawnHiveAt(c, map, pos, parentDef, minDist, ignoreRoofedRequirement), null, out intVec, 999999))
                {
                    intVec = CellFinder.FindNoWipeSpawnLocNear(intVec, map, parentDef, Rot4.North, 2, (IntVec3 c) => CompSpawnerHives.CanSpawnHiveAt(c, map, pos, parentDef, minDist, ignoreRoofedRequirement));
                    break;
                }
            }
            return(intVec);
        }