예제 #1
0
        private bool TrySpawnPowerTransmittingBuildingNear(IntVec3 position, Map map, Faction faction, ThingDef def, out Building newBuilding, Predicate <IntVec3> extraValidator = null)
        {
            TraverseParms traverseParams = TraverseParms.For(TraverseMode.PassAllDestroyableThings, Danger.Deadly, false);
            IntVec3       loc;

            if (RCellFinder.TryFindRandomCellNearWith(position, delegate(IntVec3 x)
            {
                if (!x.Standable(map) || x.Roofed(map) || !this.EverPossibleToTransmitPowerAt(x, map))
                {
                    return(false);
                }
                if (!map.reachability.CanReach(position, x, PathEndMode.OnCell, traverseParams))
                {
                    return(false);
                }
                CellRect.CellRectIterator iterator = GenAdj.OccupiedRect(x, Rot4.North, def.size).GetIterator();
                while (!iterator.Done())
                {
                    IntVec3 c = iterator.Current;
                    if (!c.InBounds(map) || c.Roofed(map) || c.GetEdifice(map) != null || c.GetFirstItem(map) != null || c.GetTransmitter(map) != null)
                    {
                        return(false);
                    }
                    iterator.MoveNext();
                }
                return(extraValidator == null || extraValidator(x));
            }, map, out loc, 8, 2147483647))
            {
                newBuilding = (Building)GenSpawn.Spawn(ThingMaker.MakeThing(def, null), loc, map, Rot4.North, WipeMode.Vanish, false);
                newBuilding.SetFaction(faction, null);
                return(true);
            }
            newBuilding = null;
            return(false);
        }
 protected override Job TryGiveJob(Pawn pawn)
 {
     if (Rand.Value < 1f && RCellFinder.TryFindRandomCellNearWith(pawn.Position, (IntVec3 pos) => pos.GetTerrain(pawn.Map).extinguishesFire, pawn.Map, out var result, 5, MaxDistance.RandomInRange))
     {
         return(JobMaker.MakeJob(JobDefOf.Goto, result));
     }
     return(null);
 }
예제 #3
0
        public static bool TryFindRandomCellNearTheCenterOfTheMapWith(Predicate <IntVec3> validator, Map map, out IntVec3 result)
        {
            IntVec3 size  = map.Size;
            int     x     = size.x;
            IntVec3 size2 = map.Size;
            int     startingSearchRadius = Mathf.Clamp(Mathf.Max(x, size2.z) / 20, 3, 25);

            return(RCellFinder.TryFindRandomCellNearWith(map.Center, validator, map, out result, startingSearchRadius, 2147483647));
        }
        // Token: 0x060004D1 RID: 1233 RVA: 0x0003100C File Offset: 0x0002F40C
        protected override Job TryGiveJob(Pawn pawn)
        {
            float   Searchradius = HuntingRange;
            IntVec3 c            = IntVec3.Invalid;

            if (XenomorphKidnapUtility.TryFindGoodKidnapVictim(pawn, Searchradius, out Pawn t, null) && !GenAI.InDangerousCombat(pawn))
            {
                if (XenomorphKidnapUtility.TryFindGoodHiveLoc(pawn, t, out c))
                {
                    ThingDef namedA   = XenomorphDefOf.RRY_Xenomorph_Humanoid_Cocoon;
                    ThingDef namedB   = XenomorphDefOf.RRY_Xenomorph_Animal_Cocoon;
                    bool     selected = pawn.Map != null?Find.Selector.SelectedObjects.Contains(pawn) && (Prefs.DevMode) : false;

                    if (c != IntVec3.Invalid && t != null && pawn.CanReach(c, PathEndMode.ClosestTouch, Danger.Deadly, true, TraverseMode.PassAllDestroyableThings))
                    {
                        Predicate <IntVec3> validator = delegate(IntVec3 y)
                        {
                            bool adjacent = c.AdjacentTo8WayOrInside(y);
                            bool filled   = y.Filled(pawn.Map);
                            bool edifice  = y.GetEdifice(pawn.Map).DestroyedOrNull();
                            bool building = y.GetFirstBuilding(pawn.Map).DestroyedOrNull();
                            bool thingA   = y.GetFirstThing(pawn.Map, namedA).DestroyedOrNull();
                            bool thingB   = y.GetFirstThing(pawn.Map, namedB).DestroyedOrNull();
                            //Log.Message(string.Format("{0} {1} {2} {3} {4} {5}", y, !adjacent, !filled, edifice, building, thing));
                            return(!adjacent && !filled && edifice && building && thingA && thingB);
                        };

                        bool b = RCellFinder.TryFindRandomCellNearWith(c, validator, pawn.Map, out IntVec3 lc, 6, 12);

                        return(new Job(XenomorphDefOf.RRY_Job_XenomorphKidnap)
                        {
                            targetA = t,
                            targetB = lc,
                            count = 1
                        });
                    }
                    else
                    {
                        if (Find.Selector.SelectedObjects.Contains(pawn))
                        {
                            Log.Message(string.Format("{0} something went wrong", this));
                        }
                    }
                }
                else
                {
                    if (Find.Selector.SelectedObjects.Contains(pawn))
                    {
                        Log.Message(string.Format("{0} No Cocooning spot Found", this));
                    }
                }
            }
 protected override Job TryGiveJob(Pawn pawn)
 {
     if (Rand.Value < 1f)
     {
         IntVec3             position  = pawn.Position;
         Predicate <IntVec3> validator = (IntVec3 pos) => pos.GetTerrain(pawn.Map).extinguishesFire;
         Map         map = pawn.Map;
         IntVec3     c;
         ref IntVec3 result        = ref c;
         int         randomInRange = this.MaxDistance.RandomInRange;
         if (RCellFinder.TryFindRandomCellNearWith(position, validator, map, out result, 5, randomInRange))
         {
             return(new Job(JobDefOf.Goto, c));
         }
     }
        // Token: 0x060004D1 RID: 1233 RVA: 0x0003100C File Offset: 0x0002F40C
        protected override Job TryGiveJob(Pawn pawn)
        {
            float   Searchradius = HuntingRange;
            Map     map          = pawn.Map;
            IntVec3 c            = IntVec3.Invalid;
            Pawn    Victim       = null;

            if (!pawn.isXenomorph(out Comp_Xenomorph xenomorph) || map == null)
            {
                return(null);
            }
            MapComponent_HiveGrid hiveGrid = pawn.Map.HiveGrid();

            /*
             * if (GenAI.InDangerousCombat(pawn))
             * {
             *  Log.Warning(string.Format("{0} is InDangerousCombat", pawn.NameShortColored));
             * }
             */
            if (XenomorphKidnapUtility.TryFindGoodKidnapVictim(pawn, Searchradius, out Victim, null, forceRoofed, allowCocooned, minRadius, allowHosts) && !GenAI.InDangerousCombat(pawn))
            {
                if (xenomorph.HiveLoc.IsValid && xenomorph.HiveLoc.InBounds(map) && xenomorph.HiveLoc != IntVec3.Zero)
                {
                    c = xenomorph.HiveLoc;
                }

                /*
                 * else
                 * if (!hiveGrid.Hivelist.NullOrEmpty())
                 * {
                 *  c = hiveGrid.Hivelist.RandomElement().Position;
                 * }
                 * else
                 * if (!hiveGrid.HiveLoclist.NullOrEmpty())
                 * {
                 *  c = hiveGrid.HiveLoclist.RandomElement();
                 * }
                 * else
                 */
                bool selected = pawn.Map != null?Find.Selector.SelectedObjects.Contains(pawn) && (Prefs.DevMode) : false;

                if (c != IntVec3.Invalid && Victim != null && pawn.CanReach(c, PathEndMode.ClosestTouch, Danger.Deadly, true, TraverseMode.PassAllDestroyableThings))
                {
                    Predicate <IntVec3> validator = delegate(IntVec3 y)
                    {
                        bool roofed   = (y.Roofed(pawn.Map) && this.forceRoofed) || !this.forceRoofed;
                        bool adjacent = c.AdjacentTo8WayOrInside(y);
                        bool filled   = y.Filled(pawn.Map);
                        bool edifice  = y.GetEdifice(pawn.Map).DestroyedOrNull();
                        bool building = y.GetFirstBuilding(pawn.Map).DestroyedOrNull();
                        bool thingA   = y.GetThingList(pawn.Map).Any(x => x.GetType() == typeof(Building_XenoEgg) && x.GetType() == typeof(Building_XenomorphCocoon) && x.GetType() == typeof(HiveLike));
                        //    Log.Message(string.Format("{0}, adjacent: {1}, filled: {2}, edifice: {3}, building: {4}", y, !adjacent, !filled, edifice, building));
                        return(!adjacent && !filled && edifice && building && !thingA && roofed && pawn.CanReserveAndReach(y, PathEndMode.OnCell, Danger.Deadly, layer: ReservationLayerDefOf.Floor));
                    };
                    if (pawn.GetLord() != null && pawn.GetLord() is Lord lord)
                    {
                        //    Log.Message(string.Format("TryFindGoodHiveLoc pawn.GetLord() != null"));
                    }
                    else
                    {
                        //   Log.Message(string.Format("TryFindGoodHiveLoc pawn.GetLord() == null"));
                    }
                    if (pawn.mindState.duty.def != XenomorphDefOf.RRY_Xenomorph_DefendAndExpandHive && pawn.mindState.duty.def != XenomorphDefOf.RRY_Xenomorph_DefendHiveAggressively)
                    {
                        pawn.mindState.duty = new PawnDuty(XenomorphDefOf.RRY_Xenomorph_DefendAndExpandHive, c, 40f);
                    }
                    if (RCellFinder.TryFindRandomCellNearWith(c, validator, pawn.Map, out IntVec3 lc, 2, 8))
                    {
                        return(new Job(XenomorphDefOf.RRY_Job_Xenomorph_Kidnap)
                        {
                            targetA = Victim,
                            targetB = lc,
                            targetC = lc.RandomAdjacentCell8Way(),
                            count = 1
                        });
                    }
                }
                else
                {
                    Log.Error("No suitable hive location found");
                    //   if (Find.Selector.SelectedObjects.Contains(pawn)) Log.Message(string.Format("{0} something went wrong", this));
                }
            }
            else
            {
                //    Log.Error("No suitable Victim found");
            }
            return(null);
        }
        // Token: 0x06000424 RID: 1060 RVA: 0x0002CE84 File Offset: 0x0002B284
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (pawn.Map == null || pawn.Map != Find.CurrentMap)
            {
                return(null);
            }
            IntVec3          c            = IntVec3.Invalid;
            CompXenoEggLayer compEggLayer = pawn.TryGetComp <CompXenoEggLayer>();

            if (compEggLayer == null || !compEggLayer.CanLayNow)
            {
                return(null);
            }
            ThingDef namedA = XenomorphDefOf.RRY_Xenomorph_Humanoid_Cocoon;
            ThingDef namedB = XenomorphDefOf.RRY_Xenomorph_Animal_Cocoon;

            if (XenomorphKidnapUtility.TryFindGoodHiveLoc(pawn, out c))
            {
                bool selected = pawn.Map != null?Find.Selector.SelectedObjects.Contains(pawn) && (Prefs.DevMode) : false;

                if (c != IntVec3.Invalid && pawn.CanReach(c, PathEndMode.ClosestTouch, Danger.Deadly, true, TraverseMode.PassAllDestroyableThings))
                {
                    Predicate <IntVec3> validator = delegate(IntVec3 y)
                    {
                        bool adjacent = c.AdjacentTo8WayOrInside(y);
                        bool filled   = y.Filled(pawn.Map);
                        bool edifice  = y.GetEdifice(pawn.Map).DestroyedOrNull();
                        bool building = y.GetFirstBuilding(pawn.Map).DestroyedOrNull();
                        bool thingA   = y.GetFirstThing(pawn.Map, namedA).DestroyedOrNull();
                        bool thingB   = y.GetFirstThing(pawn.Map, namedB).DestroyedOrNull();
                        return(!adjacent && !filled && edifice && building && thingA && thingB);
                    };

                    bool b = RCellFinder.TryFindRandomCellNearWith(c, validator, pawn.Map, out IntVec3 lc, 6, 12);

                    List <Thing> egglist = pawn.Map.listerThings.ThingsOfDef(XenomorphDefOf.RRY_EggXenomorphFertilized).FindAll(x => lc.InHorDistOf(x.Position, 9));
                    bool         eggflag = egglist.CountAllowNull() < 40;
                    return(new Job(XenomorphDefOf.RRY_Job_LayXenomorphEgg, lc));
                }
                else
                {
                    if (Find.Selector.SelectedObjects.Contains(pawn))
                    {
                        Log.Message(string.Format("{0} something went wrong", this));
                    }
                }
            }
            else
            {
                if (Find.Selector.SelectedObjects.Contains(pawn))
                {
                    Log.Message(string.Format("{0} No Egglaying spot Found", this));
                }
                c = pawn.Position;
                Predicate <IntVec3> validator = delegate(IntVec3 y)
                {
                    bool adjacent = c.AdjacentTo8WayOrInside(y);
                    bool filled   = y.Filled(pawn.Map);
                    bool edifice  = y.GetEdifice(pawn.Map).DestroyedOrNull();
                    bool building = y.GetFirstBuilding(pawn.Map).DestroyedOrNull();
                    bool thingA   = y.GetFirstThing(pawn.Map, namedA).DestroyedOrNull();
                    bool thingB   = y.GetFirstThing(pawn.Map, namedB).DestroyedOrNull();
                    return(!adjacent && !filled && edifice && building && thingA && thingB);
                };

                bool b = RCellFinder.TryFindRandomCellNearWith(c, validator, pawn.Map, out IntVec3 lc, 6, 12);

                List <Thing> egglist = pawn.Map.listerThings.ThingsOfDef(XenomorphDefOf.RRY_EggXenomorphFertilized).FindAll(x => lc.InHorDistOf(x.Position, 9));
                bool         eggflag = egglist.CountAllowNull() < 40;
                return(new Job(XenomorphDefOf.RRY_Job_LayXenomorphEgg, lc));
            }
            return(null);
        }
        // Token: 0x0600041E RID: 1054 RVA: 0x0002CA54 File Offset: 0x0002AE54

        protected override Job TryGiveJob(Pawn pawn)
        {
            if (!pawn.isXenomorph(out Comp_Xenomorph _Xenomorph))
            {
                return(null);
            }
            if (pawn.def != XenomorphRacesDefOf.RRY_Xenomorph_Queen && pawn.def != XenomorphRacesDefOf.RRY_Xenomorph_Drone && pawn.def != XenomorphRacesDefOf.RRY_Xenomorph_Predalien)
            {
                return(null);
            }
            Map     map        = pawn.Map;
            IntVec3 pos        = pawn.Position;
            IntVec3 HiveCenter = _Xenomorph.HiveLoc;
            Region  region     = pawn.GetRegion(RegionType.Set_Passable);

            if (region == null)
            {
                return(null);
            }
            if (HiveCenter == pawn.InteractionCell)
            {
                return(null);
            }
            bool centerNode   = HiveCenter.GetFirstThing(pawn.Map, XenomorphDefOf.RRY_Xenomorph_Hive) != null;
            bool centerChild  = HiveCenter.GetFirstThing(pawn.Map, XenomorphDefOf.RRY_Xenomorph_Hive_Child) != null;
            bool centerSlime  = HiveCenter.GetFirstThing(pawn.Map, XenomorphDefOf.RRY_Xenomorph_Hive_Slime) != null;
            bool centerFilled = HiveCenter.Filled(pawn.Map);

            if (centerNode)
            {
                MiningRange = 6;
            }
            else
            {
                MiningRange = 3;
                if (!centerChild)
                {
                    if (pawn.def == XenomorphRacesDefOf.RRY_Xenomorph_Queen || pawn.def == XenomorphRacesDefOf.RRY_Xenomorph_Drone)
                    {
                        if (!centerNode)
                        {
                            IntVec3 c = HiveCenter;
                            if (c.InBounds(pawn.Map) && c.Roofed(pawn.Map) && pawn.CanReserveAndReach(c, PathEndMode.OnCell, Danger.Deadly))
                            {
                                return(new Job(XenomorphDefOf.RRY_Job_Xenomorph_Construct_Hive_Node, c)
                                {
                                    ignoreDesignations = false
                                });
                            }
                        }
                        return(null);
                    }
                }
            }
            if (!centerChild)
            {
                foreach (var structure in HiveStructure.HiveStruct(HiveCenter).Where(x => x.GetThingList(map).Any(z => !z.def.defName.Contains("RRY_Xenomorph_Hive")) && x.DistanceTo(HiveCenter) <= MiningRange && pawn.CanReserveAndReach(x, PathEndMode.OnCell, Danger.Deadly, layer: ReservationLayerDefOf.Floor) && x.GetFirstBuilding(map) == null))
                {
                    return(new Job(XenomorphDefOf.RRY_Job_Xenomorph_Construct_Hive_Wall, structure)
                    {
                        ignoreDesignations = false
                    });
                }
                foreach (var structure in HiveStructure.HiveWallGen(HiveCenter, MiningRange).Where(x => x.GetThingList(map).Any(z => !z.def.defName.Contains("RRY_Xenomorph_Hive")) && x.DistanceTo(HiveCenter) <= MiningRange + 2 && pawn.CanReserveAndReach(x, PathEndMode.OnCell, Danger.Deadly, layer: ReservationLayerDefOf.Floor) && x.GetFirstBuilding(map) == null))
                {
                    return(new Job(XenomorphDefOf.RRY_Job_Xenomorph_Construct_Hive_Wall, structure)
                    {
                        ignoreDesignations = false
                    });
                }
                Predicate <IntVec3> validator2 = delegate(IntVec3 y)
                {
                    bool roofed = (y.Roofed(pawn.Map));
                    bool result = !roofed && XenomorphUtil.DistanceBetween(y, HiveCenter) <= MiningRange && pawn.CanReserveAndReach(y, PathEndMode.OnCell, Danger.Deadly, layer: ReservationLayerDefOf.Ceiling);
                    return(result);
                };
                if (RCellFinder.TryFindRandomCellNearWith(HiveCenter, validator2, pawn.Map, out IntVec3 c2, MiningRange, MiningRange))
                {
                    if (c2.InBounds(pawn.Map) && pawn.CanReserveAndReach(c2, PathEndMode.OnCell, Danger.Deadly))
                    {
                        return(new Job(XenomorphDefOf.RRY_Job_Xenomorph_Construct_Hive_Roof, c2)
                        {
                            ignoreDesignations = false
                        });
                    }
                }
            }
            return(null);
        }
예제 #9
0
        // Token: 0x06000424 RID: 1060 RVA: 0x0002CE84 File Offset: 0x0002B284
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (pawn.Map == null || pawn.Map != Find.CurrentMap)
            {
                return(null);
            }
            IntVec3          c            = IntVec3.Invalid;
            CompXenoEggLayer compEggLayer = pawn.TryGetComp <CompXenoEggLayer>();

            if (compEggLayer == null || !compEggLayer.CanLayNow)
            {
                return(null);
            }
            if (!pawn.isXenomorph(out Comp_Xenomorph xenomorph))
            {
                return(null);
            }
            else
            {
                c = xenomorph.HiveLoc;
                bool selected = pawn.Map != null?Find.Selector.SelectedObjects.Contains(pawn) && (Prefs.DevMode) : false;

                if (pawn.CanReach(c, PathEndMode.ClosestTouch, Danger.Deadly, true, TraverseMode.PassAllDestroyableThingsNotWater))
                {
                    using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, c, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassAllDestroyableThings, false), PathEndMode.OnCell))
                    {
                        IntVec3 cellBeforeBlocker;
                        Thing   thing = pawnPath.FirstBlockingBuilding(out cellBeforeBlocker, pawn);
                        if (thing != null)
                        {
                            Job job = DigUtility.PassBlockerJob(pawn, thing, cellBeforeBlocker, true, true);
                            if (job != null)
                            {
                                return(job);
                            }
                        }
                    }
                    Log.Message("queen can reach eggsite");
                    Predicate <IntVec3> validator = delegate(IntVec3 y)
                    {
                        bool adjacent = c.AdjacentTo8WayOrInside(y);
                        bool filled   = y.Filled(pawn.Map);
                        bool edifice  = y.GetEdifice(pawn.Map).DestroyedOrNull();
                        bool building = y.GetFirstBuilding(pawn.Map).DestroyedOrNull();
                        bool thingA   = y.GetFirstThing(pawn.Map, namedA).DestroyedOrNull();
                        bool thingB   = y.GetFirstThing(pawn.Map, namedB).DestroyedOrNull();
                        return(!adjacent && !filled && edifice && building && thingA && thingB);
                    };

                    bool b = RCellFinder.TryFindRandomCellNearWith(c, validator, pawn.Map, out IntVec3 lc, 6, 12);

                    List <Thing> egglist = pawn.Map.listerThings.ThingsOfDef(XenomorphDefOf.RRY_EggXenomorphFertilized).FindAll(x => lc.InHorDistOf(x.Position, 9));
                    bool         eggflag = egglist.CountAllowNull() < 40;
                    if (pawn.GetLord() == null)
                    {
                        //    Log.Message(string.Format("XenoLord TryFindGoodHiveLoc for {0} Cell Found: {1}, Allow: Fogged, Digging", pawn.LabelShortCap, c));
                        LordJob newJob = new LordJob_DefendAndExpandHiveLike(false, pawn.Faction, c, 40f);
                        pawn.CreateNewLord(c, newJob);
                    }
                    return(new Job(XenomorphDefOf.RRY_Job_Xenomorph_LayEgg, lc));
                }
                else
                {
                    Log.Warning("queen couldnt reach eggsite");
                }
                if (XenomorphKidnapUtility.TryFindGoodHiveLoc(pawn, out c))
                {
                    if (c != IntVec3.Invalid && pawn.CanReach(c, PathEndMode.ClosestTouch, Danger.Deadly, true, TraverseMode.PassAllDestroyableThings))
                    {
                        Predicate <IntVec3> validator = delegate(IntVec3 y)
                        {
                            bool adjacent = c.AdjacentTo8WayOrInside(y);
                            bool filled   = y.Filled(pawn.Map);
                            bool edifice  = y.GetEdifice(pawn.Map).DestroyedOrNull();
                            bool building = y.GetFirstBuilding(pawn.Map).DestroyedOrNull();
                            bool thingA   = y.GetFirstThing(pawn.Map, namedA).DestroyedOrNull();
                            bool thingB   = y.GetFirstThing(pawn.Map, namedB).DestroyedOrNull();
                            return(!adjacent && !filled && edifice && building && thingA && thingB);
                        };

                        bool b = RCellFinder.TryFindRandomCellNearWith(c, validator, pawn.Map, out IntVec3 lc, 6, 12);

                        List <Thing> egglist = pawn.Map.listerThings.ThingsOfDef(XenomorphDefOf.RRY_EggXenomorphFertilized).FindAll(x => lc.InHorDistOf(x.Position, 9));
                        bool         eggflag = egglist.CountAllowNull() < 40;
                        return(new Job(XenomorphDefOf.RRY_Job_Xenomorph_LayEgg, lc));
                    }
                    else
                    {
                        if (pawn.jobs.debugLog)
                        {
                            pawn.jobs.DebugLogEvent(string.Format("{0} something went wrong", this));
                        }
                    }
                }
                else
                {
                    if (pawn.jobs.debugLog)
                    {
                        pawn.jobs.DebugLogEvent(string.Format("{0} No Egglaying spot Found", this));
                    }
                    c = pawn.Position;
                    Predicate <IntVec3> validator = delegate(IntVec3 y)
                    {
                        bool adjacent = c.AdjacentTo8WayOrInside(y);
                        bool filled   = y.Filled(pawn.Map);
                        bool edifice  = y.GetEdifice(pawn.Map).DestroyedOrNull();
                        bool building = y.GetFirstBuilding(pawn.Map).DestroyedOrNull();
                        bool thingA   = y.GetFirstThing(pawn.Map, namedA).DestroyedOrNull();
                        bool thingB   = y.GetFirstThing(pawn.Map, namedB).DestroyedOrNull();
                        return(!adjacent && !filled && edifice && building && thingA && thingB);
                    };

                    bool b = RCellFinder.TryFindRandomCellNearWith(c, validator, pawn.Map, out IntVec3 lc, 6, 12);

                    List <Thing> egglist = pawn.Map.listerThings.ThingsOfDef(XenomorphDefOf.RRY_EggXenomorphFertilized).FindAll(x => lc.InHorDistOf(x.Position, 9));
                    bool         eggflag = egglist.CountAllowNull() < 40;
                    return(new Job(XenomorphDefOf.RRY_Job_Xenomorph_LayEgg, lc));
                }
            }
            return(null);
        }
예제 #10
0
        // Token: 0x060004D1 RID: 1233 RVA: 0x0003100C File Offset: 0x0002F40C
        protected override Job TryGiveJob(Pawn pawn)
        {
            float   Searchradius = MaxRange;
            IntVec3 c            = IntVec3.Invalid;

            if (Searchradius == 0)
            {
                if (pawn.mindState.duty != null)
                {
                    if (pawn.mindState.duty.focus.Cell.GetThingList(pawn.Map).Any(x => x.def == XenomorphDefOf.RRY_Xenomorph_Hive))
                    {
                        Searchradius = 7f;
                    }
                    if (pawn.mindState.duty.focus.Cell.GetThingList(pawn.Map).Any(x => x.def == XenomorphDefOf.RRY_Xenomorph_Hive_Child))
                    {
                        Searchradius = 3f;
                    }
                    if (pawn.mindState.duty.focus.Cell.GetThingList(pawn.Map).Any(x => x.def == XenomorphDefOf.RRY_Xenomorph_Hive_Slime))
                    {
                        Searchradius = 5f;
                    }
                }
            }
            if (XenomorphKidnapUtility.TryFindGoodKidnapVictim(pawn, Searchradius, out Pawn t, null, this.forceRoofed, true, MinRange) && !GenAI.InDangerousCombat(pawn))
            {
                if (XenomorphKidnapUtility.TryFindGoodHiveLoc(pawn, out c, t, true, !this.forceRoofed, this.forceCanDig))
                {
                    ThingDef namedA   = XenomorphDefOf.RRY_Xenomorph_Cocoon_Humanoid;
                    ThingDef namedB   = XenomorphDefOf.RRY_Xenomorph_Cocoon_Animal;
                    bool     selected = pawn.Map != null?Find.Selector.SelectedObjects.Contains(pawn) && (Prefs.DevMode) : false;

                    if (c != IntVec3.Invalid && t != null && pawn.CanReach(c, PathEndMode.ClosestTouch, Danger.Deadly, true, TraverseMode.PassAllDestroyableThings))
                    {
                        Predicate <IntVec3> validator = delegate(IntVec3 y)
                        {
                            bool roofed   = (y.Roofed(pawn.Map) && this.forceRoofed) || !this.forceRoofed;
                            bool adjacent = c.AdjacentTo8WayOrInside(y);
                            bool filled   = y.Filled(pawn.Map);
                            bool edifice  = y.GetEdifice(pawn.Map).DestroyedOrNull();
                            bool building = y.GetFirstBuilding(pawn.Map).DestroyedOrNull();
                            bool thingA   = y.GetFirstThing(pawn.Map, namedA).DestroyedOrNull();
                            bool thingB   = y.GetFirstThing(pawn.Map, namedB).DestroyedOrNull();
                            if (pawn.jobs.debugLog)
                            {
                                pawn.jobs.DebugLogEvent(string.Format("{0}, adjacent: {1}, filled: {2}, edifice: {3}, building: {4}", y, !adjacent, !filled, edifice, building));
                            }
                            return(!adjacent && !filled && edifice && building && thingA && thingB && roofed);
                        };
                        if (pawn.GetLord() != null && pawn.GetLord() is Lord lord)
                        {
                            if (pawn.jobs.debugLog)
                            {
                                pawn.jobs.DebugLogEvent(string.Format("TryFindGoodHiveLoc pawn.GetLord() != null"));
                            }
                        }
                        else
                        {
                            if (pawn.jobs.debugLog)
                            {
                                pawn.jobs.DebugLogEvent(string.Format("TryFindGoodHiveLoc pawn.GetLord() == null"));
                            }
                        }
                        if (pawn.mindState.duty.def != XenomorphDefOf.RRY_Xenomorph_DefendAndExpandHive && pawn.mindState.duty.def != XenomorphDefOf.RRY_Xenomorph_DefendHiveAggressively)
                        {
                            pawn.mindState.duty = new PawnDuty(XenomorphDefOf.RRY_Xenomorph_DefendAndExpandHive, c, 40f);
                        }
                        if (RCellFinder.TryFindRandomCellNearWith(c, validator, pawn.Map, out IntVec3 lc, 2, 6))
                        {
                            return(new Job(XenomorphDefOf.RRY_Job_Xenomorph_Kidnap)
                            {
                                targetA = t,
                                targetB = lc,
                                count = 1
                            });
                        }
                    }
                    else
                    {
                        if (pawn.jobs.debugLog)
                        {
                            pawn.jobs.DebugLogEvent(string.Format("{0} something went wrong", this));
                        }
                    }
                }
                else
                {
                    if (pawn.jobs.debugLog)
                    {
                        pawn.jobs.DebugLogEvent(string.Format("{0} No Cocooning spot Found", this));
                    }
                }
            }