static void Postfix(OgsOld_ExtraHives.TunnelHiveSpawner __instance, Type lordJobType, List <Pawn> list)
 {
     if (__instance.SpawnedFaction != null)
     {
         if (__instance.SpawnedFaction.def.defName.Contains("MuvLuv_BETA"))
         {
             //    Log.Message("BETA from " + __instance.SpawnedFaction.Name + " spawning with "+ lordJobType.Name+" Lord");
         }
     }
 }
        public static Thing SpawnTunnels(ThingDef hiveDef, int hiveCount, Map map, IntVec3 cell, bool spawnAnywhereIfNoGoodCell = false, bool ignoreRoofedRequirement = false, string questTag = null, Faction faction = null)
        {
            ThingDef         HiveDef   = hiveDef ?? RimWorld.ThingDefOf.Hive;
            HiveDefExtension HiveExt   = HiveDef.GetModExtension <HiveDefExtension>();
            ThingDef         TunnelDef = HiveExt?.TunnelDef ?? RimWorld.ThingDefOf.TunnelHiveSpawner;
            HiveDefExtension extension = HiveDef.GetModExtension <HiveDefExtension>();

            if (extension != null && extension.TunnelDef != null)
            {
                TunnelDef = extension.TunnelDef;
            }
            Thing             thing       = GenSpawn.Spawn(ThingMaker.MakeThing(TunnelDef), cell, map, WipeMode.FullRefund);
            TunnelHiveSpawner hiveSpawner = thing as TunnelHiveSpawner;

            if (hiveSpawner != null)
            {
                if (hiveSpawner.faction == null && faction != null)
                {
                    hiveSpawner.faction = faction;
                }
            }
            if (hiveSpawner.SpawnedFaction != null)
            {
                //	Log.Message(hiveSpawner.Faction.def.defName + ": " + hiveSpawner.faction);
            }
            QuestUtility.AddQuestTag(thing, questTag);
            CompSpawnerHives spawnerHives = thing.TryGetComp <CompSpawnerHives>();

            if (spawnerHives?.Props.tunnelDef != null)
            {
                TunnelDef = spawnerHives.Props.tunnelDef;
            }
            for (int i = 0; i < hiveCount - 1; i++)
            {
                cell = CompSpawnerHives.FindChildHiveLocation(thing.Position, map, HiveDef, HiveDef.GetCompProperties <CompProperties_SpawnerHives>(), ignoreRoofedRequirement, allowUnreachable: true);
                if (cell.IsValid)
                {
                    thing       = GenSpawn.Spawn(ThingMaker.MakeThing(TunnelDef), cell, map, WipeMode.FullRefund);
                    hiveSpawner = thing as TunnelHiveSpawner;
                    if (hiveSpawner != null)
                    {
                        if (hiveSpawner.faction == null && faction != null)
                        {
                            hiveSpawner.faction = faction;
                        }
                    }
                    if (hiveSpawner.SpawnedFaction != null)
                    {
                        //	Log.Message(hiveSpawner.Faction.def.defName + ": " + hiveSpawner.faction);
                    }
                    QuestUtility.AddQuestTag(thing, questTag);
                }
            }
            return(thing);
        }
Ejemplo n.º 3
0
        // Token: 0x06005333 RID: 21299 RVA: 0x001BD108 File Offset: 0x001BB308
        public bool TrySpawnChildHive(bool ignoreRoofedRequirement, out Hive newHive)
        {
            if (!this.CanSpawnChildHive)
            {
                newHive = null;
                return(false);
            }
            HiveDefExtension ext = null;

            if (this.parent.def.HasModExtension <HiveDefExtension>())
            {
                ext = this.parent.def.GetModExtension <HiveDefExtension>();
            }
            ThingDef thingDef = Props.hiveDef ?? this.parent.def;
            IntVec3  loc      = CompSpawnerHives.FindChildHiveLocation(this.parent.OccupiedRect().AdjacentCells.RandomElement(), this.parent.Map, thingDef, this.Props, ignoreRoofedRequirement, false, CurrentRadius);

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

            if (hive != null)
            {
                if (hive.CompDormant.Awake)
                {
                    newHive.CompDormant.WakeUp();
                }
                newHive.questTags = hive.questTags;
            }
            if (newHive.Ext?.TunnelDef != null)
            {
                TunnelHiveSpawner tunnel = (TunnelHiveSpawner)ThingMaker.MakeThing(newHive.Ext.TunnelDef, null);
                tunnel.hive = newHive;
                GenSpawn.Spawn(tunnel, loc, this.parent.Map, WipeMode.FullRefund);
                this.CalculateNextHiveSpawnTick();
            }
            else
            {
                GenSpawn.Spawn(newHive, loc, this.parent.Map, WipeMode.FullRefund);
                this.CalculateNextHiveSpawnTick();
            }
            return(true);
        }
Ejemplo n.º 4
0
        // Token: 0x06003E46 RID: 15942 RVA: 0x00148B70 File Offset: 0x00146D70
        public override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

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

            if (hive == null)
            {
                return(false);
            }
            HiveDefExtension ext = def.mechClusterBuilding.GetModExtension <HiveDefExtension>();

            if (parms.faction == null)
            {
                try
                {
                    parms.faction = Find.FactionManager.AllFactions.Where(x => x.def.defName.Contains(ext.Faction.defName)) /*.Where(x => (float)GenDate.DaysPassed >= x.def.earliestRaidDays)*/.RandomElement();
                    //	Log.Message(parms.faction.def.defName);
                }
                catch (System.Exception)
                {
                    parms.faction = Find.FactionManager.FirstFactionOfDef(ext.Faction);
                }
            }
            ThingDef tunnelDef = hive.TunnelDef ?? RimWorld.ThingDefOf.TunnelHiveSpawner;

            IncidentWorker_DeepDrillInfestation.tmpDrills.Clear();
            DeepDrillInfestationIncidentUtility.GetUsableDeepDrills(map, IncidentWorker_DeepDrillInfestation.tmpDrills);
            Thing deepDrill;

            if (!IncidentWorker_DeepDrillInfestation.tmpDrills.TryRandomElement(out deepDrill))
            {
                return(false);
            }
            IntVec3 intVec = CellFinder.FindNoWipeSpawnLocNear(deepDrill.Position, map, tunnelDef, Rot4.North, 2, (IntVec3 x) => x.Walkable(map) && x.GetFirstThing(map, deepDrill.def) == null && x.GetFirstThingWithComp <ThingComp>(map) == null && x.GetFirstThing(map, RimWorld.ThingDefOf.Hive) == null && x.GetFirstThing(map, RimWorld.ThingDefOf.TunnelHiveSpawner) == null);

            if (intVec == deepDrill.Position)
            {
                return(false);
            }
            TunnelHiveSpawner tunnelHiveSpawner = (TunnelHiveSpawner)ThingMaker.MakeThing(tunnelDef, null);

            tunnelHiveSpawner.spawnHive = false;
            Rand.PushState();
            tunnelHiveSpawner.initialPoints = Mathf.Clamp(parms.points * Rand.Range(0.3f, 0.6f), 200f, 1000f);
            Rand.PopState();
            tunnelHiveSpawner.spawnedByInfestationThingComp = true;
            GenSpawn.Spawn(tunnelHiveSpawner, intVec, map, WipeMode.FullRefund);
            deepDrill.TryGetComp <CompCreatesInfestations>().Notify_CreatedInfestation();
            base.SendStandardLetter(parms, new TargetInfo(tunnelHiveSpawner.Position, map, false), Array.Empty <NamedArgument>());
            return(true);
        }
        public static Thing SpawnTunnels(ThingDef hiveDef, int hiveCount, Map map, bool spawnAnywhereIfNoGoodCell = false, bool ignoreRoofedRequirement = false, string questTag = null, Faction faction = null)
        {
            ThingDef         HiveDef   = hiveDef ?? RimWorld.ThingDefOf.Hive;
            HiveDefExtension HiveExt   = HiveDef.GetModExtension <HiveDefExtension>();
            ThingDef         TunnelDef = HiveExt?.TunnelDef ?? RimWorld.ThingDefOf.TunnelHiveSpawner;

            if (!InfestationCellFinder.TryFindCell(out IntVec3 cell, map, HiveExt))
            {
                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);
                }
            }
            HiveDefExtension extension = HiveDef.GetModExtension <HiveDefExtension>();

            if (extension != null && extension.TunnelDef != null)
            {
                TunnelDef = extension.TunnelDef;
            }
            Thing             thing       = GenSpawn.Spawn(ThingMaker.MakeThing(TunnelDef), cell, map, WipeMode.FullRefund);
            TunnelHiveSpawner hiveSpawner = thing as TunnelHiveSpawner;

            if (hiveSpawner != null)
            {
                if (hiveSpawner.faction == null && faction != null)
                {
                    hiveSpawner.faction = faction;
                }
            }
            if (hiveSpawner.SpawnedFaction != null)
            {
                //	Log.Message(hiveSpawner.Faction.def.defName + ": " + hiveSpawner.faction);
            }
            QuestUtility.AddQuestTag(thing, questTag);
            for (int i = 0; i < hiveCount - 1; i++)
            {
                cell = CompSpawnerHives.FindChildHiveLocation(thing.Position, map, HiveDef, HiveDef.GetCompProperties <CompProperties_SpawnerHives>(), ignoreRoofedRequirement, allowUnreachable: true);
                if (cell.IsValid)
                {
                    thing       = GenSpawn.Spawn(ThingMaker.MakeThing(TunnelDef), cell, map, WipeMode.FullRefund);
                    hiveSpawner = thing as TunnelHiveSpawner;
                    if (hiveSpawner != null)
                    {
                        if (hiveSpawner.faction == null && faction != null)
                        {
                            hiveSpawner.faction = faction;
                        }
                    }
                    if (hiveSpawner.SpawnedFaction != null)
                    {
                        //	Log.Message(hiveSpawner.Faction.def.defName+": "+ hiveSpawner.faction);
                    }
                    QuestUtility.AddQuestTag(thing, questTag);
                }
            }
            return(thing);
        }