public static void MakeTunnelAt(IntVec3 c, Map map, List <Thing> info)
        {
            ThingDef TunnelDef = DefDatabase <ThingDef> .GetNamed("TunnelerDef");

            TunnelRaidSpawner tunnelSpawner = (TunnelRaidSpawner)ThingMaker.MakeThing(TunnelDef, null);

            foreach (Thing item in info)
            {
                tunnelSpawner.GetDirectlyHeldThings().TryAddOrTransfer(item, false);
            }
            GenSpawn.Spawn(tunnelSpawner, c, map);
        }
        // Token: 0x06002762 RID: 10082 RVA: 0x0012C458 File Offset: 0x0012A858
        public static void MakeTunnelAt(IntVec3 c, Map map, ActiveDropPodInfo info, Faction faction = null)
        {
            ThingDef TunnelDef = ThingDefOf.Tunneler_OgsOld_ExtraHives;
            //    Log.Message(string.Format("making tunnelSpawner: {0}, @: {1}, {2}, {3}", TunnelDef, c, map, info.innerContainer.ContentsString));
            TunnelRaidSpawner tunnelSpawner = (TunnelRaidSpawner)ThingMaker.MakeThing(TunnelDef, null);

            if (tunnelSpawner.SpawnedFaction == null)
            {
                tunnelSpawner.SpawnedFaction = faction;
                if (tunnelSpawner.SpawnedFaction != null)
                {
                    //    Log.Message("tunnelSpawner.Faction set " + tunnelSpawner.SpawnedFaction.Name);
                }
            }
            foreach (Thing item in info.innerContainer)
            {
                tunnelSpawner.GetDirectlyHeldThings().TryAddOrTransfer(item, false);
            }
            GenSpawn.Spawn(tunnelSpawner, c, map);
        }
Beispiel #3
0
        // Token: 0x06003C6A RID: 15466 RVA: 0x0013F378 File Offset: 0x0013D578
        public override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map = (Map)parms.target;
            IntVec3 intVec;

            if (def.mechClusterBuilding == null)
            {
                return(false);
            }
            if (!def.mechClusterBuilding.HasModExtension <HiveDefExtension>())
            {
                return(false);
            }
            ThingDef         hiveDef = def.mechClusterBuilding;
            HiveDefExtension hive    = hiveDef.GetModExtension <HiveDefExtension>();
            Faction          faction = null;

            if (parms.faction != null)
            {
                faction = parms.faction;
            }
            else
            {
                if (hive.Faction != null)
                {
                    IEnumerable <Faction> factions = CandidateFactions(map, hive.Faction.defName);
                    if (!factions.EnumerableNullOrEmpty())
                    {
                        faction = factions.RandomElement();
                    }
                    else
                    {
                        faction = Find.FactionManager.FirstFactionOfDef(hive.Faction);
                    }
                }
                else
                {
                    return(false);
                }
            }
            if (!this.TryFindCell(out intVec, map))
            {
                return(false);
            }
            List <Thing> list = new List <Thing>();

            //	Log.Message("TunnelRaidSpawner");
            TunnelRaidSpawner tunnelHiveSpawner = (TunnelRaidSpawner)ThingMaker.MakeThing(ThingDefOf.Tunneler_OgsOld_ExtraHives, null);

            tunnelHiveSpawner.spawnHive = false;
            Rand.PushState();
            tunnelHiveSpawner.initialPoints = Mathf.Max(parms.points * Rand.Range(0.3f, 0.6f), 200f);
            Rand.PopState();
            tunnelHiveSpawner.spawnedByInfestationThingComp = true;
            tunnelHiveSpawner.ResultSpawnDelay   = new FloatRange(0.1f, 0.5f);
            tunnelHiveSpawner.spawnablePawnKinds = faction.def.pawnGroupMakers.Where(x => x.kindDef == RimWorld.PawnGroupKindDefOf.Combat || x.kindDef == PawnGroupKindDefOf.Tunneler_OgsOld_ExtraHives).RandomElement().options;
            if (tunnelHiveSpawner.SpawnedFaction == null)
            {
                if (faction != null)
                {
                    //	Log.Message(faction.Name);
                    tunnelHiveSpawner.SpawnedFaction = faction;
                }
            }
            //	Log.Message("TunnelRaidSpawner "+ tunnelHiveSpawner.Faction);
            list.Add(tunnelHiveSpawner);
            List <Thing> outThings;

            Generate(out outThings);
            list.AddRange(outThings);
            SkyfallerMaker.SpawnSkyfaller(ThingDefOf.InfestedMeteoriteIncoming_OgsOld_ExtraHives, list, intVec, map);
            LetterDef baseLetterDef = list[list.Count - 1].def.building.isResourceRock ? LetterDefOf.PositiveEvent : LetterDefOf.NeutralEvent;
            string    str           = string.Format(this.def.letterText, list[list.Count - 1].def.label).CapitalizeFirst();

            base.SendStandardLetter(this.def.letterLabel + ": " + list[list.Count - 1].def.LabelCap, str, baseLetterDef, parms, new TargetInfo(intVec, map, false), Array.Empty <NamedArgument>());
            return(true);
        }