// Token: 0x0600368E RID: 13966 RVA: 0x001A127C File Offset: 0x0019F67C private static void CalculateLocationCandidates(Map map, bool allowFogged = false, bool allowUnroofed = false, bool allowDigging = false, bool forceNew = false) { int minscore = (allowUnroofed ? 0 : (allowDigging ? 15000 : 10000)); MapComponent_HiveGrid hiveGrid = map.HiveGrid(); InfestationLikeCellFinder.locationCandidates.Clear(); InfestationLikeCellFinder.CalculateTraversalDistancesToUnroofed(map); InfestationLikeCellFinder.CalculateClosedAreaSizeGrid(map); InfestationLikeCellFinder.CalculateDistanceToColonyBuildingGrid(map); for (int i = 0; i < map.Size.z; i++) { for (int j = 0; j < map.Size.x; j++) { IntVec3 cell = new IntVec3(j, 0, i); if (!forceNew || !(hiveGrid.Hivelist.Any(x => x.Position == cell) || hiveGrid.hiveLoclist.Any(x => x == cell))) { } float scoreAt = InfestationLikeCellFinder.GetScoreAt(cell, map, allowFogged, allowUnroofed, allowDigging); // allowFogged if (scoreAt > minscore) { // Log.Message(string.Format("scoreAt {0} == {1}", cell, scoreAt)); InfestationLikeCellFinder.locationCandidates.Add(new InfestationLikeCellFinder.LocationCandidate(cell, scoreAt)); } } } }
// Token: 0x06002673 RID: 9843 RVA: 0x001240D8 File Offset: 0x001224D8 public override void SpawnSetup(Map map, bool respawningAfterLoad) { if (!PlayerKnowledgeDatabase.IsComplete(XenomorphConceptDefOf.RRY_Concept_HiveLike) && this.def == XenomorphDefOf.RRY_Xenomorph_Hive) { LessonAutoActivator.TeachOpportunity(XenomorphConceptDefOf.RRY_Concept_HiveLike, OpportunityType.Important); } base.SpawnSetup(map, respawningAfterLoad); if (base.Faction == null) { this.SetFaction(OfFaction, null); } if (this.getsQueen && hiveNode) { Pawn newQueen = PawnGenerator.GeneratePawn(new PawnGenerationRequest(XenomorphDefOf.RRY_Xenomorph_Queen, factionInt)); this.innerContainer.TryAdd(newQueen); } if (!respawningAfterLoad && this.active && canSpawnPawns) { this.SpawnInitialPawns(); } else { spawnablePawnKinds = OfPawnKinds; } MapComponent_HiveGrid hiveGrid = map.HiveGrid(); if (hiveGrid != null) { if (this.def == XenomorphDefOf.RRY_Xenomorph_Hive) { if (!hiveGrid.Hivelist.Contains(this)) { hiveGrid.Hivelist.Add(this); } if (!hiveGrid.HiveLoclist.Contains(this.Position)) { hiveGrid.HiveLoclist.Add(this.Position); } } if (this.def == XenomorphDefOf.RRY_Xenomorph_Hive_Child) { if (!hiveGrid.Hivelist.Contains(this)) { hiveGrid.Hivelist.Add(this); } if (!hiveGrid.HiveLoclist.Contains(this.Position)) { hiveGrid.HiveLoclist.Add(this.Position); } } } }
// Token: 0x06000865 RID: 2149 RVA: 0x000477A4 File Offset: 0x00045BA4 public override void UpdateAllDuties() { base.FilterOutUnspawnedHiveLikes(); MapComponent_HiveGrid hive = Map.GetComponent <MapComponent_HiveGrid>(); if (!hive.Hivelist.NullOrEmpty() && !hive.HiveLoclist.NullOrEmpty()) { } else { if (XenomorphKidnapUtility.TryFindGoodHiveLoc(lord.ownedPawns.RandomElement(), out _, null, true, false, true)) { } else if (XenomorphKidnapUtility.TryFindGoodHiveLoc(lord.ownedPawns.RandomElement(), out _, null, true, true, true)) { } } for (int i = 0; i < this.lord.ownedPawns.Count; i++) { PawnDuty duty; if (!hive.Hivelist.NullOrEmpty()) { HiveLike hiveFor = base.GetHiveLikeFor(this.lord.ownedPawns[i]); if (hiveFor.parentHiveLike != null) { duty = new PawnDuty(XenomorphDefOf.RRY_Xenomorph_DefendHiveAggressively, hiveFor.parentHiveLike, this.distToHiveToAttack); } else { duty = new PawnDuty(XenomorphDefOf.RRY_Xenomorph_DefendHiveAggressively, hiveFor, this.distToHiveToAttack); } } else if (!hive.HiveLoclist.NullOrEmpty()) { IntVec3 hiveloc = hive.HiveLoclist.RandomElement(); duty = new PawnDuty(XenomorphDefOf.RRY_Xenomorph_DefendHiveAggressively, hiveloc, this.distToHiveToAttack); } else { duty = new PawnDuty(XenomorphDefOf.RRY_Xenomorph_AssaultColony_CutPower); } this.lord.ownedPawns[i].mindState.duty = duty; } }
// Token: 0x06000860 RID: 2144 RVA: 0x00047694 File Offset: 0x00045A94 public override void UpdateAllDuties() { MapComponent_HiveGrid hive = Map.GetComponent <MapComponent_HiveGrid>(); base.FilterOutUnspawnedHiveLikes(); for (int i = 0; i < this.lord.ownedPawns.Count; i++) { Pawn p = this.lord.ownedPawns[i]; HiveLike hiveFor = base.GetHiveLikeFor(p); PawnDuty duty = null; if (hive.HiveGuardlist.Contains(p)) { if (hiveFor.hasQueen) { duty = new PawnDuty(XenomorphDefOf.RRY_Xenomorph_DefendHiveLoc, hiveFor, 16f); } else { } } else if (hive.HiveWorkerlist.Contains(p)) { if (hive.potentialHosts.Any(x => !x.isCocooned() && x.Downed)) { // duty = new PawnDuty(XenomorphDefOf.R, hiveFor, 16f); } } if (duty == null) { duty = new PawnDuty(XenomorphDefOf.RRY_Xenomorph_DefendAndExpandHive, hiveFor, this.distToHiveToAttack); } p.mindState.duty = duty; } }
// 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); }