コード例 #1
0
 // Token: 0x060004C6 RID: 1222 RVA: 0x00030C6C File Offset: 0x0002F06C
 public static HiveLike FindMyTunnel(Pawn pawn)
 {
     if (pawn.def == XenomorphRacesDefOf.RRY_Xenomorph_Queen)
     {
         if (XenomorphUtil.HivelikesPresent(pawn.Map))
         {
             HiveLike hive = (HiveLike)XenomorphUtil.ClosestReachableHivelike(pawn);
             if (!hive.hasQueen)
             {
                 if (hive.Lord != null && hive.Lord != pawn.GetLord())
                 {
                     pawn.SwitchToLord(hive.Lord);
                 }
                 return((HiveLike)XenomorphUtil.ClosestReachableHivelike(pawn));
             }
         }
     }
     if (pawn.GetLord() != null && pawn.GetLord() is Lord lord)
     {
         if (lord.LordJob is LordJob_DefendAndExpandHiveLike hivejob)
         {
             if (lord.CurLordToil is LordToil_DefendAndExpandHiveLike hivetoil)
             {
                 if (hivetoil.Data.assignedHiveLikes.TryGetValue(pawn) != null)
                 {
                     return(hivetoil.Data.assignedHiveLikes.TryGetValue(pawn));
                 }
             }
         }
         else if (lord.CurLordToil is LordToil_DefendHiveLikeAggressively hivetoilA)
         {
             if (hivetoilA.Data.assignedHiveLikes.TryGetValue(pawn) != null)
             {
                 return(hivetoilA.Data.assignedHiveLikes.TryGetValue(pawn));
             }
         }
         else
         {
             if (XenomorphUtil.HivelikesPresent(pawn.Map))
             {
                 HiveLike hive = (HiveLike)XenomorphUtil.ClosestReachableHivelike(pawn);
                 if (hive.Lord != null && hive.Lord != pawn.GetLord())
                 {
                     pawn.SwitchToLord(hive.Lord);
                 }
                 return((HiveLike)XenomorphUtil.ClosestReachableHivelike(pawn));
             }
         }
     }
     return(null);
 }
コード例 #2
0
        // Token: 0x060028F1 RID: 10481 RVA: 0x00136C04 File Offset: 0x00135004
        public void Hatch()
        {
            try
            {
                PawnKindDef hatchKindDef = Rand.Chance(royalProgress) && !QueenPresent && !XenomorphUtil.HivelikesPresent(MyMap) && !RoyalPresent ? XenomorphDefOf.RRY_Xenomorph_RoyaleHugger : this.Props.hatcherPawn;
#if DEBUG
                //    Log.Message(string.Format("hatchKindDef: {0}", hatchKindDef));
#endif
                PawnGenerationRequest request = new PawnGenerationRequest(hatchKindDef, this.hatcheeFaction, PawnGenerationContext.NonPlayer, -1, false, true, false, false, true, false, 1f, false, true, true, false, false, false, false, null, null, null, null, null, null, null, null);
                for (int i = 0; i < this.parent.stackCount; i++)
                {
                    Pawn pawn = PawnGenerator.GeneratePawn(request);
                    if (PawnUtility.TrySpawnHatchedOrBornPawn(pawn, this.parent))
                    {
                        if (pawn != null)
                        {
                            if (this.hatcheeParent != null)
                            {
                                if (pawn.playerSettings != null && this.hatcheeParent.playerSettings != null && this.hatcheeParent.Faction == this.hatcheeFaction)
                                {
                                    pawn.playerSettings.AreaRestriction = this.hatcheeParent.playerSettings.AreaRestriction;
                                }
                                if (pawn.RaceProps.IsFlesh)
                                {
                                    pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, this.hatcheeParent);
                                }
                            }
                            if (this.otherParent != null && (this.hatcheeParent == null || this.hatcheeParent.gender != this.otherParent.gender) && pawn.RaceProps.IsFlesh)
                            {
                                pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, this.otherParent);
                            }
                        }
                        if (this.parent.Spawned)
                        {
                            FilthMaker.MakeFilth(MyPos, MyMap, ThingDefOf.Filth_AmnioticFluid, 1);
                        }
                    }
                    else
                    {
                        Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard);
                    }
                }
            }
            finally
            {
                this.parent.Destroy(DestroyMode.Vanish);
            }
        }
コード例 #3
0
        // Token: 0x060028F0 RID: 10480 RVA: 0x00136BB0 File Offset: 0x00134FB0
        public override void CompTick()
        {
            if (!this.TemperatureDamaged)
            {
                //Log.Message(string.Format("!this.TemperatureDamaged"));
                float ambientTemperature = this.parent.AmbientTemperature;
                float num = 1f / (this.Props.hatcherDaystoHatch * 60000f);
                if (ambientTemperature > -20f)
                {
                    //    Log.Message(string.Format("ambientTemperature > -20"));
                    if (this.gestateProgress < 1f)
                    {
                        this.gestateProgress += num;
                        //    Log.Message(string.Format("gestateProgress: {0}", gestateProgress));
                    }
                    else if (this.royalProgress < 1f && !QueenPresent && !RoyalPresent && (!RoyalEggPresent || (RoyalEggPresent && this.royalProgress > 0f)) && !XenomorphUtil.HivelikesPresent(MyMap))
                    {
                        this.royalProgress += num;
                    }
                }
                if (Find.TickManager.TicksGame % 250 + (Rand.RangeInclusive(0, 10) * 100) == 0)
                {
                    this.CompTickRare();

                    if (this.gestateProgress >= 1f && (this.royalProgress == 0f || this.royalProgress >= 1f))
                    {
                        bool selected = Find.Selector.SingleSelectedThing == this.parent && false;
                        //    if (selected) Log.Message(string.Format("{0} @ {1}, Can hatch?: {2}, Will hatch?: {3}", this.parent.Label, MyPos, canHatch, willHatch));
                        if (this.canHatch && this.willHatch && ambientTemperature > -20f)
                        {
                            this.Hatch();
                        }
                    }
                }
            }
        }
コード例 #4
0
        public void XenoLordTick()
        {
            if (map != null)
            {
                IntVec3            c             = IntVec3.Invalid;
                Lord               lord          = null;
                List <Lord>        Hivelords     = new List <Lord>();
                Lord               Hivelord      = null;
                LordJob            Hivejob       = null;
                Pawn               Hivequeen     = null;
                IEnumerable <Lord> lords         = pawn.Map.lordManager.lords.Where(x => x.faction == pawn.Faction);
                bool               isDefendPoint = pawn.GetLord() != null?pawn.GetLord().LordJob is LordJob_DefendPoint : false;

                bool isAssaultColony = pawn.GetLord() != null?pawn.GetLord().LordJob is LordJob_AssaultColony : false;

                bool hostsPresent    = map.mapPawns.AllPawnsSpawned.Any(x => x.isPotentialHost() && !x.isCocooned() && IsAcceptablePreyFor(pawn, x, true));
                bool LordReplaceable = (isDefendPoint || (isAssaultColony && !hostsPresent));
                //   Log.Message(string.Format("LordReplaceable: {0}, isDefendPoint: {1}, isAssaultColony: {2}, hostsPresent: {3}", LordReplaceable, isDefendPoint, isAssaultColony, !hostsPresent));
                if (lords.Count() != 0 && ((pawn.GetLord() != null && LordReplaceable) || pawn.GetLord() == null))
                {
                    foreach (var l in lords)
                    {
                        if (l != null)
                        {
                            if (XenomorphUtil.HivelikesPresent(map))
                            {
                                if (l.LordJob is LordJob_DefendAndExpandHiveLike j)
                                {
                                    Hivelord = l;
                                    Hivejob  = j;
                                    if (l.ownedPawns.Any(x => x.kindDef == QueenDef))
                                    {
                                        Hivequeen = l.ownedPawns.Find(x => x.kindDef == QueenDef);
                                    }
                                    if (pawn.kindDef != XenomorphDefOf.RRY_Xenomorph_Queen || (pawn.kindDef == XenomorphDefOf.RRY_Xenomorph_Queen && Hivequeen != null))
                                    {
                                        Hivelords.Add(l);
                                    }
                                }
                            }
                            else if (XenomorphUtil.HiveSlimePresent(map))
                            {
                                if (l.LordJob is LordJob_DefendHiveLoc j)
                                {
                                    Hivelord = l;
                                    Hivejob  = j;
                                    if (l.ownedPawns.Any(x => x.kindDef == QueenDef))
                                    {
                                        Hivequeen = l.ownedPawns.Find(x => x.kindDef == QueenDef);
                                    }
                                    if (pawn.kindDef != XenomorphDefOf.RRY_Xenomorph_Queen || (pawn.kindDef == XenomorphDefOf.RRY_Xenomorph_Queen && Hivequeen != null))
                                    {
                                        Hivelords.Add(l);
                                    }
                                }
                            }
                        }
                        else
                        {
                            /*
                             * lord = l;
                             * lord.AddPawn(pawn);
                             * pawn.mindState.duty = lord.ownedPawns.FindAll(x => x.mindState.duty != null && x != pawn).RandomElement().mindState.duty;
                             * break;
                             */
                        }
                    }
                }
                if (pawn.GetLord() != null && LordReplaceable)
                {
                    lord = pawn.GetLord();
                    if (lord.ownedPawns.Count == 0)
                    {
                        Log.Message(string.Format("got no pawns, wtf?"));
                    }
                    if (lord.ownedPawns.Count == 1)
                    {
                    }
                    if (c == IntVec3.Invalid && XenomorphUtil.HivelikesPresent(map))
                    {
                        c = !XenomorphUtil.ClosestReachableHivelike(pawn).DestroyedOrNull() ? XenomorphUtil.ClosestReachableHivelike(pawn).Position : IntVec3.Invalid;
                    }
                    if (c == IntVec3.Invalid && XenomorphUtil.EggsPresent(map))
                    {
                        c = !XenomorphUtil.ClosestReachableEgg(pawn).DestroyedOrNull() ? XenomorphUtil.ClosestReachableEgg(pawn).Position : IntVec3.Invalid;
                    }
                    if (c == IntVec3.Invalid && XenomorphUtil.CocoonsPresent(map, XenomorphDefOf.RRY_Xenomorph_Humanoid_Cocoon))
                    {
                        c = !XenomorphUtil.ClosestReachableCocoon(pawn, XenomorphDefOf.RRY_Xenomorph_Humanoid_Cocoon).DestroyedOrNull() ? XenomorphUtil.ClosestReachableCocoon(pawn, XenomorphDefOf.RRY_Xenomorph_Humanoid_Cocoon).Position : IntVec3.Invalid;
                    }
                    if (c == IntVec3.Invalid && XenomorphUtil.CocoonsPresent(map, XenomorphDefOf.RRY_Xenomorph_Animal_Cocoon))
                    {
                        c = !XenomorphUtil.ClosestReachableCocoon(pawn, XenomorphDefOf.RRY_Xenomorph_Animal_Cocoon).DestroyedOrNull() ? XenomorphUtil.ClosestReachableCocoon(pawn, XenomorphDefOf.RRY_Xenomorph_Animal_Cocoon).Position : IntVec3.Invalid;
                    }
                    if (c == IntVec3.Invalid)
                    {
                        if (InfestationLikeCellFinder.TryFindCell(out c, pawn.Map, false))
                        {
                            if (Prefs.DevMode)
                            {
                                ThingDef td = XenomorphDefOf.RRY_Filth_Slime;
                                GenSpawn.Spawn(td, c, pawn.Map);
                                Find.LetterStack.ReceiveLetter(string.Format("Lord Created"), string.Format("@: {0} ", c), LetterDefOf.NegativeEvent, c.GetFirstThing(pawn.Map, td), null, null);
                            }
                        }
                        if (pawn.CanReach(c, PathEndMode.OnCell, Danger.Deadly, true))
                        {
                            c = RCellFinder.RandomWanderDestFor(pawn, c, 3f, null, Danger.Some);
                        }
                        else
                        {
                            c = RCellFinder.RandomWanderDestFor(pawn, pawn.Position, 3f, null, Danger.Some);
                        }
                    }
                    if (c != IntVec3.Invalid)
                    {
                        LordJob newJob;
                        if (XenomorphUtil.HivelikesPresent(map))
                        {
                            newJob = new LordJob_DefendAndExpandHiveLike(false);
                        }
                        else
                        {
                            newJob = new LordJob_DefendHiveLoc(parent.Faction, c);
                        }
                        if (LordReplaceable)
                        {
                            if (!Hivelords.NullOrEmpty())
                            {
                                Hivelord = Hivelords.RandomElement();
                                SwitchToLord(Hivelord);
                                CreateNewLord(pawn, c, newJob);
                            }
                            else
                            {
                                CreateNewLord(pawn, c, newJob);
                            }
                            if (HiveLoc == IntVec3.Invalid)
                            {
                                HiveLoc = c;
                            }
                        }
                    }
                }
                else if (c == IntVec3.Invalid && (pawn.GetLord() != null && pawn.GetLord().LordJob is LordJob LordJob))
                {
                    lord = pawn.GetLord();
                    c    = LordJob.lord.Graph.StartingToil.FlagLoc;
                    if (c == IntVec3.Invalid)
                    {
                        c = LordJob.lord.CurLordToil.FlagLoc;
                    }
                }
                else if (pawn.GetLord() == null)
                {
                    if (!Hivelords.NullOrEmpty())
                    {
                        Hivelord = Hivelords.RandomElement();
                        SwitchToLord(Hivelord);
                    }
                }
                if (pawn.GetLord() != null)
                {
                    List <Pawn> list = pawn.GetLord().ownedPawns.Where(x => x.mindState.duty != null).ToList();
                    if (pawn.GetLord() != null && pawn.mindState.duty == null && !list.NullOrEmpty())
                    {
                        pawn.mindState.duty = list.RandomElement().mindState.duty;
                    }
                }
            }
        }
コード例 #5
0
        public static bool TryFindGoodHiveLoc(Pawn pawn, Pawn victim, out IntVec3 c, bool AllowHiveShip = false)
        {
            Map map = pawn.Map;

            c = IntVec3.Invalid;
            bool selected = map != null?Find.Selector.SelectedObjects.Contains(pawn) && (Prefs.DevMode) : false;

            ThingDef named = victim.RaceProps.Humanlike ? XenomorphDefOf.RRY_Xenomorph_Humanoid_Cocoon : XenomorphDefOf.RRY_Xenomorph_Animal_Cocoon;

            if (AllowHiveShip)
            {
                hiveshippresent          = XenomorphUtil.HiveShipPresent(map);
                hiveshipReachable        = !XenomorphUtil.ClosestReachableHiveShip(pawn).DestroyedOrNull();
                closestreachablehiveship = XenomorphUtil.ClosestReachableHiveShip(pawn);
                if (c == IntVec3.Invalid && hiveshippresent && hiveshipReachable)
                {
                    if (Prefs.DevMode && DebugSettings.godMode)
                    {
                        Log.Message(string.Format("(c == IntVec3.Invalid && hiveshippresent && hiveshipReachable)"));
                    }
                    c = closestreachablehiveship.Position;
                    if (Prefs.DevMode && DebugSettings.godMode)
                    {
                        Log.Message(string.Format("(c == {0})", c));
                    }
                    return(true);
                }
            }

            hivelikesPresent         = XenomorphUtil.HivelikesPresent(map);
            hivelikesReachable       = !XenomorphUtil.ClosestReachableHivelike(pawn).DestroyedOrNull();
            closestReachableHivelike = XenomorphUtil.ClosestReachableHivelike(pawn);
            if ((hivelikesPresent && hivelikesReachable))
            {
                List <ThingDef_HiveLike> hivedefs = DefDatabase <ThingDef_HiveLike> .AllDefsListForReading.FindAll(x => x.Faction == pawn.Faction.def);

                if (XenomorphUtil.TotalSpawnedHivelikeCount(map) > 0)
                {
                    if (XenomorphUtil.TotalSpawnedParentHivelikeCount(map) > 0)
                    {
                        hiveThing = XenomorphUtil.TotalSpawnedParentHivelikeCount(map) > 1 ? XenomorphUtil.SpawnedParentHivelikes(map).RandomElement() : XenomorphUtil.ClosestReachableHivelike(pawn, XenomorphUtil.SpawnedParentHivelikes(map));
                        c         = hiveThing.Position;
                        if (c != IntVec3.Invalid)
                        {
                            return(true);
                        }
                    }

                    /*
                     * if (XenomorphUtil.TotalSpawnedChildHivelikeCount(map) > 0)
                     * {
                     *  hiveThing = XenomorphUtil.TotalSpawnedParentHivelikeCount(map) > 1 ? XenomorphUtil.SpawnedParentHivelikes(map).RandomElement() : XenomorphUtil.ClosestReachableHivelike(pawn, XenomorphUtil.SpawnedParentHivelikes(map));
                     *  c = hiveThing.Position;
                     *  return true;
                     * }
                     */
                }
            }

            hiveslimepresent          = XenomorphUtil.HiveSlimePresent(map);
            hiveslimeReachable        = !XenomorphUtil.ClosestReachableHiveSlime(pawn).DestroyedOrNull();
            closestreachablehiveslime = XenomorphUtil.ClosestReachableHiveSlime(pawn);
            if (c == IntVec3.Invalid && hiveslimepresent && hiveslimeReachable)
            {
                c = closestreachablehiveslime.Position;
                if (c != IntVec3.Invalid)
                {
                    return(true);
                }
            }

            eggsPresent         = XenomorphUtil.EggsPresent(map);
            eggsReachable       = !XenomorphUtil.ClosestReachableEgg(pawn).DestroyedOrNull();
            closestReachableEgg = XenomorphUtil.ClosestReachableEgg(pawn);
            if (c == IntVec3.Invalid && (eggsPresent && eggsReachable && XenomorphUtil.SpawnedEggsNeedHosts(map).Count > 0))
            {
                eggThing = XenomorphUtil.SpawnedEggsNeedHosts(map).Count > 1 ? XenomorphUtil.SpawnedEggsNeedHosts(map).RandomElement() : XenomorphUtil.ClosestReachableEggNeedsHost(pawn);
                c        = eggThing.Position;
                if (c != IntVec3.Invalid)
                {
                    return(true);
                }
            }

            cocoonsPresent         = XenomorphUtil.CocoonsPresent(map, named);
            cocoonsReachable       = !XenomorphUtil.ClosestReachableCocoon(pawn, named).DestroyedOrNull();
            closestReachableCocoon = XenomorphUtil.ClosestReachableCocoon(pawn, named);
            if (c == IntVec3.Invalid && cocoonsPresent && cocoonsReachable)
            {
                c = closestReachableCocoon.Position;
                if (c != IntVec3.Invalid)
                {
                    return(true);
                }
            }

            if (c == IntVec3.Invalid)
            {
                if (!InfestationLikeCellFinder.TryFindCell(out c, map, false))
                {
                    if (!RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn))
                    {
                        return(false);
                    }
                    if (c != IntVec3.Invalid)
                    {
                        return(true);
                    }
                }
                else
                {
                    if (pawn.GetLord() != null && pawn.GetLord() is Lord lord)
                    {
                        Log.Message(string.Format("TryFindGoodHiveLoc pawn.GetLord() != null"));
                    }

                    if (pawn.mindState.duty.def != OGHiveLikeDefOf.RRY_DefendAndExpandHiveLike && pawn.mindState.duty.def != OGHiveLikeDefOf.RRY_DefendHiveLikeAggressively)
                    {
                        pawn.mindState.duty = new PawnDuty(OGHiveLikeDefOf.RRY_DefendAndExpandHiveLike, c, 40f);

                        c = RCellFinder.RandomWanderDestFor(pawn, c, 5f, null, Danger.Some);
                        return(true);
                    }
                    else
                    {
                        c = RCellFinder.RandomWanderDestFor(pawn, c, 5f, null, Danger.Some);
                        return(true);
                    }
                }
            }
            return(false);
        }