// Token: 0x06000393 RID: 915 RVA: 0x000245C8 File Offset: 0x000229C8 protected override IEnumerable <Toil> MakeNewToils() { this.FailOnIncapable(PawnCapacityDefOf.Manipulation); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); Toil prepare = Toils_General.Wait(this.useDuration, TargetIndex.None); prepare.NPCWithProgressBarToilDelay(TargetIndex.A, false, -0.5f); prepare.FailOnDespawnedNullOrForbidden(TargetIndex.A); prepare.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); prepare.WithEffect(EffecterDefOf.Vomit, TargetIndex.A); prepare.PlaySustainerOrSound(() => SoundDefOf.Vomit); yield return(prepare); Toil use = new Toil(); use.initAction = delegate() { Pawn actor = use.actor; MyDef = XenomorphDefOf.RRY_Xenomorph_Hive; Thing thing = ThingMaker.MakeThing(MyDef); HiveLike hive = (HiveLike)thing; GenSpawn.Spawn(thing, TargetA.Cell, actor.Map, Rot4.South, WipeMode.FullRefund, false); }; use.defaultCompleteMode = ToilCompleteMode.Instant; yield return(use); yield break; }
// Token: 0x06000E64 RID: 3684 RVA: 0x0006B8B4 File Offset: 0x00069CB4 protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; int hivelikeCount = Mathf.Max(GenMath.RoundRandom(parms.points / 220f), 1); if (def.tags.Contains("TunnelLike")) { //Log.Message(string.Format("TunnelLike")); TunnelHiveLikeSpawner t = null; int num; for (int i = Mathf.Max(GenMath.RoundRandom(parms.points / 220f), 1); i > 0; i -= num) { num = Mathf.Min(3, i); t = this.SpawnTunnelLikeCluster(num, map); } base.SendStandardLetter(t, null, new string[0]); } else { //Log.Message(string.Format("HiveLike")); HiveLike t = null; int num; for (int i = Mathf.Max(GenMath.RoundRandom(parms.points / 400f), 1); i > 0; i -= num) { num = Mathf.Min(3, i); t = this.SpawnHiveLikeCluster(num, map); } base.SendStandardLetter(t, null, new string[0]); } Find.TickManager.slower.SignalForceNormalSpeedShort(); return(true); }
// Token: 0x0600041B RID: 1051 RVA: 0x0002C940 File Offset: 0x0002AD40 protected override Job TryGiveJob(Pawn pawn) { Room room = pawn.GetRoom(RegionType.Set_Passable); int num = 0; while ((float)num < JobGiver_MaintainHiveLikes.CellsInScanRadius) { IntVec3 intVec = pawn.Position + GenRadial.RadialPattern[num]; if (intVec.InBounds(pawn.Map)) { if (intVec.GetRoom(pawn.Map, RegionType.Set_Passable) == room) { HiveLike hivelike = (HiveLike)pawn.Map.thingGrid.ThingAt(intVec, ThingDefOf.Hive); if (hivelike != null && pawn.CanReserve(hivelike, 1, -1, null, false)) { CompMaintainable compMaintainable = hivelike.TryGetComp <CompMaintainable>(); if (compMaintainable.CurStage != MaintainableStage.Healthy) { if (!this.onlyIfDamagingState || compMaintainable.CurStage == MaintainableStage.Damaging) { return(new Job(JobDefOf.Maintain, hivelike)); } } } } } num++; } return(null); }
// Token: 0x060029CA RID: 10698 RVA: 0x0013C760 File Offset: 0x0013AB60 private void TickInterval(int interval) { if (!this.parent.Spawned) { return; } HiveLike hive = this.parent as HiveLike; if (hive != null) { if (!hive.active) { return; } } else if (this.parent.Position.Fogged(this.parent.Map)) { return; } if (this.PropsSpawner.requiresPower && !this.PowerOn) { return; } this.ticksUntilSpawn -= interval; this.CheckShouldSpawn(); }
// Token: 0x06000420 RID: 1056 RVA: 0x0002CD30 File Offset: 0x0002B130 protected override IntVec3 GetWanderRoot(Pawn pawn) { HiveLike hivelike = pawn.mindState.duty.focus.Thing as HiveLike; if (hivelike == null || !hivelike.Spawned) { return(pawn.Position); } return(hivelike.Position); }
// Token: 0x06000416 RID: 1046 RVA: 0x0002C898 File Offset: 0x0002AC98 protected override IntVec3 GetFlagPosition(Pawn pawn) { HiveLike hivelike = pawn.mindState.duty.focus.Thing as HiveLike; if (hivelike != null && hivelike.Spawned) { return(hivelike.Position); } return(pawn.Position); }
// Token: 0x06000860 RID: 2144 RVA: 0x00047694 File Offset: 0x00045A94 public override void UpdateAllDuties() { base.FilterOutUnspawnedHiveLikes(); for (int i = 0; i < this.lord.ownedPawns.Count; i++) { HiveLike hiveFor = (HiveLike)base.GetHiveLikeFor(this.lord.ownedPawns[i]); PawnDuty duty = new PawnDuty(DutyDefOf.DefendAndExpandHive, hiveFor, this.distToHiveToAttack); this.lord.ownedPawns[i].mindState.duty = duty; } }
// Token: 0x06000420 RID: 1056 RVA: 0x0002CD30 File Offset: 0x0002B130 protected override IntVec3 GetWanderRoot(Pawn pawn) { if (pawn.isXenomorph()) { HiveLike hivelike = pawn.mindState.duty != null && pawn.mindState.duty.focus != null ? pawn.mindState.duty.focus.Thing as HiveLike : null; if (hivelike != null) { return(hivelike.Position); } /* * if (hivelike==null) * { * hivelike = FindClosestHiveLike(pawn); * } */ if (hivelike == null || !hivelike.Spawned) { if (XenomorphUtil.HivelikesPresent(pawn.Map)) { return(XenomorphUtil.ClosestReachableHivelike(pawn).Position); } if (!XenomorphKidnapUtility.hiveslimepresent) { if (XenomorphKidnapUtility.TryFindGoodHiveLoc(pawn, out IntVec3 c)) { return(c); } } else if (!XenomorphUtil.ClosestReachableHiveSlime(pawn).DestroyedOrNull()) { return(XenomorphUtil.ClosestReachableHiveSlime(pawn).Position); } return(pawn.Position); } // Log.Message(string.Format("JobGiver_WanderHiveLike hivelike.Position: {0}", hivelike.Position)); return(hivelike.Position); } else if (pawn.isNeomorph()) { Corpse corpse = (Corpse)GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForGroup(ThingRequestGroup.Corpse), PathEndMode.Touch, TraverseParms.For(pawn, Danger.Deadly), 20f); if (corpse != null) { return(corpse.Position); } return(pawn.Position); } else { return(pawn.Position); } }
private static void SpawnItemInstantly(HiveLike hive) { CompXenomorph_SpawnerLike compSpawner = (CompXenomorph_SpawnerLike)hive.AllComps.Find(delegate(ThingComp x) { CompXenomorph_SpawnerLike compSpawner2 = x as CompXenomorph_SpawnerLike; return(compSpawner2 != null && compSpawner2.PropsSpawner.thingToSpawn == ThingDefOf.InsectJelly); }); if (compSpawner != null) { compSpawner.TryDoSpawn(); } }
// Token: 0x0600041B RID: 1051 RVA: 0x0002C940 File Offset: 0x0002AD40 protected override Job TryGiveJob(Pawn pawn) { ThingDef hiveDef = null; List <ThingDef_HiveLike> hivedefs = DefDatabase <ThingDef_HiveLike> .AllDefsListForReading.FindAll(x => x.Faction == pawn.Faction.def); foreach (ThingDef_HiveLike hivedef in hivedefs) { if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("JobGiver_MaintainHiveLikes found hiveDef: {0} for {1}", hiveDef, pawn)); } if (hivedef.Faction == pawn.Faction.def) { hiveDef = hivedef; if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("JobGiver_MaintainHiveLikes set hiveDef: {0} for {1}", hiveDef, pawn)); } break; } } Room room = pawn.GetRoom(RegionType.Set_Passable); int num = 0; while ((float)num < JobGiver_MaintainHiveLikes.CellsInScanRadius) { IntVec3 intVec = pawn.Position + GenRadial.RadialPattern[num]; if (intVec.InBounds(pawn.Map)) { if (intVec.GetRoom(pawn.Map, RegionType.Set_Passable) == room) { HiveLike hivelike = (HiveLike)pawn.Map.thingGrid.ThingAt(intVec, hiveDef); if (hivelike != null && pawn.CanReserve(hivelike, 1, -1, null, false)) { CompMaintainableLike compMaintainable = hivelike.TryGetComp <CompMaintainableLike>(); if (compMaintainable != null && compMaintainable.CurStage != MaintainableStage.Healthy) { if (!this.onlyIfDamagingState || compMaintainable.CurStage == MaintainableStage.Damaging) { return(new Job(XenomorphDefOf.RRY_Job_Xenomorph_MaintainHive, hivelike)); } } } } } num++; } return(null); }
// Token: 0x06000420 RID: 1056 RVA: 0x0002CD30 File Offset: 0x0002B130 protected override IntVec3 GetWanderRoot(Pawn pawn) { HiveLike hivelike = pawn.mindState.duty.focus.Thing as HiveLike; if (hivelike == null) { hivelike = FindClosestEgg(pawn); } if (hivelike == null || !hivelike.Spawned) { // Log.Message(string.Format("JobGiver_WanderHiveLike pawn.Position: {0}", pawn.Position)); return(pawn.Position); } // Log.Message(string.Format("JobGiver_WanderHiveLike hivelike.Position: {0}", hivelike.Position)); return(hivelike.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: 0x06000865 RID: 2149 RVA: 0x000477A4 File Offset: 0x00045BA4 public override void UpdateAllDuties() { base.FilterOutUnspawnedHiveLikes(); for (int i = 0; i < this.lord.ownedPawns.Count; i++) { HiveLike hiveFor = base.GetHiveLikeFor(this.lord.ownedPawns[i]); PawnDuty duty; if (hiveFor.parentHiveLike != null) { duty = new PawnDuty(OGHiveLikeDefOf.RRY_DefendHiveLikeAggressively, hiveFor.parentHiveLike, this.distToHiveToAttack); } else { duty = new PawnDuty(OGHiveLikeDefOf.RRY_DefendHiveLikeAggressively, hiveFor, this.distToHiveToAttack); } this.lord.ownedPawns[i].mindState.duty = duty; } }
// Token: 0x0600268A RID: 9866 RVA: 0x00124ABC File Offset: 0x00122EBC public static void Notify_HiveLikeDespawned(HiveLike hivelike, Map map) { int num = GenRadial.NumCellsInRadius(2f); for (int i = 0; i < num; i++) { IntVec3 c = hivelike.Position + GenRadial.RadialPattern[i]; if (c.InBounds(map)) { List <Thing> thingList = c.GetThingList(map); for (int j = 0; j < thingList.Count; j++) { if (thingList[j].Faction == hivelike.OfFaction && !HiveLikeUtility.AnyHiveLikePreventsClaiming(thingList[j])) { thingList[j].SetFaction(null, null); } } } } }
private HiveLike SpawnHiveLikeCluster(int hiveCount, Map map, bool ignoreRoofedRequirement = false, bool allowUnreachable = false, float modifier = 1) { ; IntVec3 loc = intVec; ThingDef_HiveLike thingDef = (ThingDef_HiveLike)this.def.mechClusterBuilding; HiveLike hivelike = (HiveLike)ThingMaker.MakeThing(thingDef, null); GenSpawn.Spawn(ThingMaker.MakeThing(hivelike.Def.TunnelDef, null), loc, map); hivelike.SetFaction(hivelike.OfFaction, null); IncidentWorker_Xenomorph_Hivelike.SpawnItemInstantly(hivelike); for (int i = 0; i < hiveCount - 1; i++) { CompSpawnerHiveLikes c = hivelike.GetComp <CompSpawnerHiveLikes>(); if (hivelike.Spawned && hivelike.GetComp <CompSpawnerHiveLikes>().TrySpawnChildHiveLike(modifier, modifier, out HiveLike hivelike2, ignoreRoofedRequirement, allowUnreachable)) { IncidentWorker_Xenomorph_Hivelike.SpawnItemInstantly(hivelike2); hivelike = hivelike2; } } return(hivelike); }
private HiveLike SpawnHiveLikeCluster(int hiveCount, Map map) { ; IntVec3 loc = DropCellFinder.RandomDropSpot(map); ThingDef_HiveLike thingDef = (ThingDef_HiveLike)this.def.shipPart; HiveLike hivelike = (HiveLike)ThingMaker.MakeThing(thingDef, null); GenSpawn.Spawn(ThingMaker.MakeThing(hivelike.OfTunnel, null), loc, map); hivelike.SetFaction(hivelike.OfFaction, null); IncidentWorker_Hivelike.SpawnItemInstantly(hivelike); for (int i = 0; i < hiveCount - 1; i++) { HiveLike hivelike2; CompSpawnerHiveLikes c = hivelike.GetComp <CompSpawnerHiveLikes>(); if (hivelike.Spawned && hivelike.GetComp <CompSpawnerHiveLikes>().TrySpawnChildHiveLike(true, out hivelike2)) { IncidentWorker_Hivelike.SpawnItemInstantly(hivelike2); hivelike = hivelike2; } } return(hivelike); }
// 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: 0x0600118A RID: 4490 RVA: 0x00084ED4 File Offset: 0x000832D4 private void TrySpawnHive(Map map) { IntVec3 intVec; if (!this.TryFindHiveSpawnCell(map, out intVec)) { return; } this.possibleSpawnCells.Remove(intVec); HiveLike hive = (HiveLike)GenSpawn.Spawn(ThingMaker.MakeThing(XenomorphDefOf.RRY_Xenomorph_Hive, null), intVec, map, WipeMode.Vanish); hive.SetFaction(Find.FactionManager.FirstFactionOfDef(XenomorphDefOf.RRY_Xenomorph), null); hive.caveColony = true; /* * (from x in hive.GetComps<CompSpawner>() * where x.PropsSpawner.thingToSpawn == ThingDefOf.GlowPod * select x).First<CompSpawner>().TryDoSpawn(); */ hive.SpawnPawnsUntilPoints(Rand.Range(200f, 500f)); hive.canSpawnPawns = false; hive.GetComp <CompSpawnerHiveLikes>().canSpawnHiveLikes = false; this.spawnedHives.Add(hive); }
// Token: 0x0600041E RID: 1054 RVA: 0x0002CA54 File Offset: 0x0002AE54 protected override Job TryGiveJob(Pawn pawn) { List <IntVec3> HiveStruct = new List <IntVec3>() { // Support Collums // Cardinals new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 3, z = pawn.mindState.duty.focus.Cell.z }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x - 3, z = pawn.mindState.duty.focus.Cell.z }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x, z = pawn.mindState.duty.focus.Cell.z + 3 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x, z = pawn.mindState.duty.focus.Cell.z - 3 }, // Corners new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 2, z = pawn.mindState.duty.focus.Cell.z + 2 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x - 2, z = pawn.mindState.duty.focus.Cell.z + 2 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 2, z = pawn.mindState.duty.focus.Cell.z - 2 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x - 2, z = pawn.mindState.duty.focus.Cell.z - 2 } }; List <IntVec3> HiveWalls = new List <IntVec3>() { // Exterior Walls new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 6, z = pawn.mindState.duty.focus.Cell.z + 1 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 6, z = pawn.mindState.duty.focus.Cell.z + 2 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 6, z = pawn.mindState.duty.focus.Cell.z + 3 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 6, z = pawn.mindState.duty.focus.Cell.z + 4 }, // new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 6, z = pawn.mindState.duty.focus.Cell.z + -1 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 6, z = pawn.mindState.duty.focus.Cell.z + -2 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 6, z = pawn.mindState.duty.focus.Cell.z + -3 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + -6, z = pawn.mindState.duty.focus.Cell.z + -4 }, // new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + -6, z = pawn.mindState.duty.focus.Cell.z + 1 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + -6, z = pawn.mindState.duty.focus.Cell.z + 2 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + -6, z = pawn.mindState.duty.focus.Cell.z + 3 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + -6, z = pawn.mindState.duty.focus.Cell.z + 4 }, // new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + -6, z = pawn.mindState.duty.focus.Cell.z + -1 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + -6, z = pawn.mindState.duty.focus.Cell.z + -2 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + -6, z = pawn.mindState.duty.focus.Cell.z + -3 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + -6, z = pawn.mindState.duty.focus.Cell.z + -4 }, // new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 1, z = pawn.mindState.duty.focus.Cell.z + 6 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 2, z = pawn.mindState.duty.focus.Cell.z + 6 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 3, z = pawn.mindState.duty.focus.Cell.z + 6 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 4, z = pawn.mindState.duty.focus.Cell.z + 6 }, // new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + -1, z = pawn.mindState.duty.focus.Cell.z + 6 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + -2, z = pawn.mindState.duty.focus.Cell.z + 6 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + -3, z = pawn.mindState.duty.focus.Cell.z + 6 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + -4, z = pawn.mindState.duty.focus.Cell.z + 6 }, // new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 1, z = pawn.mindState.duty.focus.Cell.z + -6 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 2, z = pawn.mindState.duty.focus.Cell.z + -6 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 3, z = pawn.mindState.duty.focus.Cell.z + -6 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 4, z = pawn.mindState.duty.focus.Cell.z + -6 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + -1, z = pawn.mindState.duty.focus.Cell.z + -6 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + -2, z = pawn.mindState.duty.focus.Cell.z + -6 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + -3, z = pawn.mindState.duty.focus.Cell.z + -6 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + -4, z = pawn.mindState.duty.focus.Cell.z + -6 }, // }; Region region = pawn.GetRegion(RegionType.Set_Passable); if (region == null) { return(null); } if (pawn.mindState.duty.focus.Cell == pawn.InteractionCell) { return(null); } bool flag1 = pawn.mindState.duty.focus.Cell.GetFirstThing(pawn.Map, XenomorphDefOf.RRY_XenomorphHive) != null; bool flag2 = pawn.mindState.duty.focus.Cell.GetFirstThing(pawn.Map, XenomorphDefOf.RRY_XenomorphHive_Child) != null; bool flag3 = pawn.mindState.duty.focus.Cell.GetFirstThing(pawn.Map, XenomorphDefOf.RRY_Hive_Slime) != null; if (pawn.GetLord() is Lord L && L != null) { if ((L.CurLordToil is LordToil_DefendAndExpandHiveLike || L.CurLordToil is LordToil_DefendHiveLikeAggressively) && L.CurLordToil is LordToil_HiveLikeRelated THL) { if (THL != null) { if (THL.Data != null) { HiveLike hive = THL.Data.assignedHiveLikes.TryGetValue(pawn); if (hive != null) { flag1 = hive.def == XenomorphDefOf.RRY_XenomorphHive; flag2 = hive.def == XenomorphDefOf.RRY_XenomorphHive_Child; } } } } } if ((!flag1 && !flag2 && !flag3)) { return(null); } if (flag2) { MiningRange = 3; } for (int i = 0; i < 40; i++) { IntVec3 randomCell = HiveStruct.RandomElement(); for (int j = 0; j < 4; j++) { IntVec3 c = randomCell;// + GenAdj.CardinalDirections[j]; if (c.InBounds(pawn.Map) && c.Roofed(pawn.Map)) { Building edifice = c.GetEdifice(pawn.Map); if (edifice == null && XenomorphUtil.DistanceBetween(c, pawn.mindState.duty.focus.Cell) <= MiningRange) { return(new Job(XenomorphDefOf.RRY_Job_ConstructHiveWall, c) { ignoreDesignations = true }); } /* * else if (edifice==null) * { * if (!pillarLoc.Contains(edifice.Position)) * { * return new Job(JobDefOf.Mine, edifice) * { * ignoreDesignations = true * }; * } * } */ } } if (flag1) { randomCell = HiveWalls.RandomElement(); for (int j = 0; j < 4; j++) { IntVec3 c = randomCell;// + GenAdj.CardinalDirections[j]; if (c.InBounds(pawn.Map) && c.Roofed(pawn.Map)) { Building edifice = c.GetEdifice(pawn.Map); if (edifice == null && XenomorphUtil.DistanceBetween(c, pawn.mindState.duty.focus.Cell) <= MiningRange) { return(new Job(XenomorphDefOf.RRY_Job_ConstructHiveWall, c) { ignoreDesignations = false }); } /* * else if (edifice==null) * { * if (!pillarLoc.Contains(edifice.Position)) * { * return new Job(JobDefOf.Mine, edifice) * { * ignoreDesignations = true * }; * } * } */ } } } } return(null); }
// Token: 0x060005B7 RID: 1463 RVA: 0x00037A28 File Offset: 0x00035E28 protected override Job TryGiveJob(Pawn pawn) { Job job = null; bool healthy = (pawn.health.summaryHealth.SummaryHealthPercent > 0.75f && pawn.health.hediffSet.BleedRateTotal < 0.15f); if (!healthy) { return(job); } 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) { hive = hivetoil.Data.assignedHiveLikes.TryGetValue(pawn); } } } else if (lord.CurLordToil is LordToil_DefendHiveLikeAggressively hivetoilA) { if (hivetoilA.Data.assignedHiveLikes.TryGetValue(pawn) != null) { hive = hivetoilA.Data.assignedHiveLikes.TryGetValue(pawn); } } } // bool aggressive; Comp_Xenomorph _Xenomorph = pawn.TryGetComp <Comp_Xenomorph>(); if (pawn.TryGetAttackVerb(null, false) == null) { return(job); } Pawn pawn2 = null; if (hive != null) { if (_Xenomorph != null) { if (!hive.hiveDormant) { pawn2 = _Xenomorph.BestPawnToHuntForPredator(pawn, false, true); requireLOS = false; HuntingRange = 40; } else { HuntingRange = 20; } } else { } } if (pawn2 == null) { pawn2 = this.FindPawnTarget(pawn); } if (pawn2 != null) { if (pawn2.isPotentialHost()) { if (pawn.CanReach(pawn2, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn)) { job = this.MeleeAttackJob(pawn, pawn2); } else { using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, pawn2.Position, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassDoors, true), PathEndMode.OnCell)) { if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("pawnPath.TotalCost: {0}", pawnPath.TotalCost)); } if (!pawnPath.Found) { if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("pawnPath.Found NOT Found")); } job = null; } else if (!pawnPath.TryFindLastCellBeforeBlockingDoor(pawn, out IntVec3 loc)) { if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("pawnPath.TryFindLastCellBeforeBlockingDoor NOT Found")); } // Log.Error(pawn + " did TryFindLastCellBeforeDoor but found none when it should have been one. Target: " + pawn2.LabelCap, false); job = null; } /* * else * { * if (pawn.jobs.debugLog) pawn.jobs.DebugLogEvent(string.Format("pawnPath.TryFindLastCellBeforeBlockingDoor NOT Found")); * IntVec3 randomCell = CellFinder.RandomRegionNear(loc.GetRegion(pawn.Map, RegionType.Set_Passable), 9, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, true), null, null, RegionType.Set_Passable).RandomCell; * if (randomCell == pawn.Position) * { * job = new Job(JobDefOf.Wait, 30, false); * } * else * { * job = new Job(JobDefOf.Goto, randomCell); * } * } */ } } } if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("{0}: {1} Job Found: {2}: {3}", this, pawn, job != null, job)); } } else { if (pawn.jobs.debugLog) { pawn.jobs.DebugLogEvent(string.Format("{0}: {1} No target Found: {2}: {3}", this, pawn, job != null, job)); } } return(job); }
// Token: 0x06000860 RID: 2144 RVA: 0x00047694 File Offset: 0x00045A94 public override void UpdateAllDuties() { QueenPresent = XenomorphUtil.QueenPresent(Map, out Pawn Queen); if (QueenPresent) { if (this.Data.HiveQueen.DestroyedOrNull()) { this.Data.HiveQueen = Queen; } } eggsPresent = XenomorphUtil.EggsPresent(Map); base.FilterOutUnspawnedHiveLikes(); for (int i = 0; i < this.lord.ownedPawns.Count; i++) { Pawn pawn = this.lord.ownedPawns[i]; PawnDuty duty; if (XenomorphUtil.HivelikesPresent(Map)) { HiveLike hiveFor = base.GetHiveLikeFor(this.lord.ownedPawns[i]); if (hiveFor.parentHiveLike != null) { duty = new PawnDuty(OGHiveLikeDefOf.RRY_DefendAndExpandHiveLike, hiveFor.parentHiveLike, this.distToHiveToAttack); this.Data.HiveLoc = hiveFor.parentHiveLike.Position; } else if (hiveFor != null) { duty = new PawnDuty(OGHiveLikeDefOf.RRY_DefendAndExpandHiveLike, hiveFor, this.distToHiveToAttack); this.Data.HiveLoc = hiveFor.Position; } else { // Log.Message(string.Format("hives present but not found, we dun f****d up boss")); duty = null; } } else { if (XenomorphUtil.HiveSlimePresent(Map)) { duty = new PawnDuty(OGHiveLikeDefOf.RRY_DefendAndExpandHiveLike, XenomorphUtil.ClosestReachableHiveSlime(pawn), this.distToHiveToAttack); this.Data.HiveLoc = XenomorphUtil.ClosestReachableHiveSlime(pawn).Position; } else if (XenomorphKidnapUtility.TryFindGoodHiveLoc(pawn, out IntVec3 c)) { duty = new PawnDuty(OGHiveLikeDefOf.RRY_DefendAndExpandHiveLike, c, this.distToHiveToAttack); this.Data.HiveLoc = c; } else { duty = null; } /* * ThingDef named = pawn.RaceProps.Humanlike ? XenomorphDefOf.RRY_Xenomorph_Humanoid_Cocoon : XenomorphDefOf.RRY_Xenomorph_Animal_Cocoon; * cocoonsPresent = XenomorphUtil.CocoonsPresent(pawn.Map, named); * eggsReachable = !XenomorphUtil.ClosestReachableEgg(pawn).DestroyedOrNull(); * closestReachableEgg = XenomorphUtil.ClosestReachableEgg(pawn); * * hivelikesReachable = !XenomorphUtil.ClosestReachableHivelike(pawn).DestroyedOrNull(); * closestReachableHivelike = XenomorphUtil.ClosestReachableHivelike(pawn); * * cocoonsReachable = !XenomorphUtil.ClosestReachableCocoon(pawn, named).DestroyedOrNull(); * closestReachableCocoon = XenomorphUtil.ClosestReachableCocoon(pawn, named); * * if (XenomorphUtil.EggsPresent(Map)) * { * // Log.Message(string.Format("eggsPresent: {0}", closestReachableEgg.Position)); * duty = new PawnDuty(OGHiveLikeDefOf.RRY_DefendAndExpandHiveLike, closestReachableEgg, this.distToHiveToAttack); * } * else if (cocoonsPresent) * { * // Log.Message(string.Format("cocoonsPresent: {0}", closestReachableCocoon.Position)); * duty = new PawnDuty(OGHiveLikeDefOf.RRY_DefendAndExpandHiveLike, closestReachableCocoon, this.distToHiveToAttack); * } * else if (myFocus.Cell != IntVec3.Zero) * { * // Log.Message(string.Format("myFocus {0}", myFocus.Cell)); * duty = new PawnDuty(OGHiveLikeDefOf.RRY_DefendAndExpandHiveLike, myFocus, this.distToHiveToAttack); * } * else if (InfestationLikeCellFinder.TryFindCell(out IntVec3 c, Map, false)) * { * // Log.Message(string.Format("InfestationLikeCellFinder: {0}", c)); * duty = new PawnDuty(OGHiveLikeDefOf.RRY_DefendAndExpandHiveLike, c, this.distToHiveToAttack); * } * else * { * // Log.Message(string.Format("pawn: {0}", pawn.Position)); * duty = new PawnDuty(OGHiveLikeDefOf.RRY_DefendAndExpandHiveLike, pawn, this.distToHiveToAttack); * } */ } this.lord.ownedPawns[i].mindState.duty = duty; if (duty != null) { if (duty.focus != null && duty.focus != IntVec3.Invalid && duty.focus != IntVec3.Zero) { myFocus = duty.focus; } } } }
// Token: 0x06002627 RID: 9767 RVA: 0x00122210 File Offset: 0x00120610 public override void Tick() { if (base.Spawned) { HiveLike hive = (HiveLike)ThingMaker.MakeThing(hiveDef, null); this.sustainer.Maintain(); Vector3 vector = base.Position.ToVector3Shifted(); ResetStaticData(); if (Rand.MTBEventOccurs(FilthSpawnMTB, 1f, 1.TicksToSeconds()) && CellFinder.TryFindRandomReachableCellNear(base.Position, base.Map, TunnelHiveLikeSpawner.FilthSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out IntVec3 c, 999999)) { FilthMaker.TryMakeFilth(c, base.Map, filthTypes.RandomElement <ThingDef>(), 1); } if (Rand.MTBEventOccurs(DustMoteSpawnMTB, 1f, 1.TicksToSeconds())) { MoteMaker.ThrowDustPuffThick(new Vector3(vector.x, 0f, vector.z) { y = AltitudeLayer.MoteOverhead.AltitudeFor() }, base.Map, Rand.Range(1.5f, 3f), new Color(1f, 1f, 1f, 2.5f)); } if (this.secondarySpawnTick <= Find.TickManager.TicksGame) { this.sustainer.End(); Map map = base.Map; IntVec3 position = base.Position; this.Destroy(DestroyMode.Vanish); if (this.spawnHive) { if (Def.strikespreexplode) { FireEvent(map, position); EventDraw(map, position); } if (Def.explodesprespawn) { GenExplosion.DoExplosion(position, map, Def.blastradius, Def.damageDef, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false); } hive = (HiveLike)GenSpawn.Spawn(ThingMaker.MakeThing(hiveDef, null), position, map, WipeMode.Vanish); hive.SetFaction(faction, null); hive.InitialPawnsPoints = hivePoints / 2; hive.MaxSpawnedPawnsPoints = hivePoints; if (parentHiveLike != null) { parentHiveLike.childHiveLikes.Add(hive); } foreach (CompXenomorph_SpawnerLike compSpawner in hive.GetComps <CompXenomorph_SpawnerLike>()) { if (compSpawner.PropsSpawner.thingToSpawn == ThingDefOf.InsectJelly) { compSpawner.TryDoSpawn(); break; } } } if (this.hivePoints > 0f) { this.hivePoints = Mathf.Max(this.hivePoints, pawnKinds.Min((PawnKindDef x) => x.combatPower)); float pointsLeft = this.hivePoints; List <Pawn> list = new List <Pawn>(); int num = 0; while (pointsLeft > 0f) { num++; if (num > 1000) { // Log.Error("Too many iterations.", false); break; } IEnumerable <PawnKindDef> source = from x in pawnKinds where x.combatPower <= pointsLeft select x; if (!source.TryRandomElement(out PawnKindDef pawnKindDef)) { break; } Pawn pawn = PawnGenerator.GeneratePawn(pawnKindDef, faction); GenSpawn.Spawn(pawn, CellFinder.RandomClosewalkCellNear(position, map, 2, null), map, WipeMode.Vanish); pawn.mindState.spawnedByInfestationThingComp = this.spawnedByInfestationThingComp; list.Add(pawn); pointsLeft -= pawnKindDef.combatPower; } if (list.Any <Pawn>()) { LordMaker.MakeNewLord(faction, new LordJob_AssaultColony(faction, true, false, false, false, true), map, list); } } } } }
// Token: 0x060005B7 RID: 1463 RVA: 0x00037A28 File Offset: 0x00035E28 protected override Job TryGiveJob(Pawn 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) { hive = hivetoil.Data.assignedHiveLikes.TryGetValue(pawn); } } } if (lord.CurLordToil is LordToil_DefendHiveLikeAggressively hivetoilA) { if (hivetoilA.Data.assignedHiveLikes.TryGetValue(pawn) != null) { hive = hivetoilA.Data.assignedHiveLikes.TryGetValue(pawn); } } } bool aggressive; Comp_Xenomorph _Xenomorph = pawn.TryGetComp <Comp_Xenomorph>(); if (pawn.TryGetAttackVerb(null, false) == null) { return(null); } Pawn pawn2 = null; if (_Xenomorph != null && hive.hiveDormant) { pawn2 = _Xenomorph.BestPawnToHuntForPredator(pawn, false, true); } if (pawn2 == null) { pawn2 = this.FindPawnTarget(pawn); } if (pawn2 == null) { return(null); } if (!pawn2.isPotentialHost()) { return(null); } if (pawn2 != null && pawn.CanReach(pawn2, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn)) { return(this.MeleeAttackJob(pawn, pawn2)); } if (pawn2 != null) { using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, pawn2.Position, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.PassDoors, true), PathEndMode.OnCell)) { if (!pawnPath.Found) { return(null); } if (!pawnPath.TryFindLastCellBeforeBlockingDoor(pawn, out IntVec3 loc)) { // Log.Error(pawn + " did TryFindLastCellBeforeDoor but found none when it should have been one. Target: " + pawn2.LabelCap, false); return(null); } IntVec3 randomCell = CellFinder.RandomRegionNear(loc.GetRegion(pawn.Map, RegionType.Set_Passable), 9, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, true), null, null, RegionType.Set_Passable).RandomCell; if (randomCell == pawn.Position) { return(new Job(JobDefOf.Wait, 30, false)); } return(new Job(JobDefOf.Goto, randomCell)); } } return(null); }
// Token: 0x0600041E RID: 1054 RVA: 0x0002CA54 File Offset: 0x0002AE54 protected override Job TryGiveJob(Pawn pawn) { if (pawn.Map == null) { // Log.Message("map == null"); return(null); } Map map = pawn.Map; if (!pawn.isXenomorph(out Comp_Xenomorph _Xenomorph)) { // Log.Message("not xenomorph"); return(null); } IntVec3 HiveCenter = IntVec3.Invalid; if (_Xenomorph.HiveLoc.IsValid && _Xenomorph.HiveLoc.InBounds(map) && _Xenomorph.HiveLoc != IntVec3.Zero) { HiveCenter = _Xenomorph.HiveLoc; } else { // Log.Message(string.Format("not _Xenomorph.HiveLoc({0})", _Xenomorph.HiveLoc)); return(null); } Region region = pawn.GetRegion(RegionType.Set_Passable); if (region == null) { return(null); } bool flag1 = HiveCenter.GetFirstThing(pawn.Map, XenomorphDefOf.RRY_Xenomorph_Hive) != null; bool flag2 = HiveCenter.GetFirstThing(pawn.Map, XenomorphDefOf.RRY_Xenomorph_Hive_Child) != null; bool flag3 = HiveCenter.GetFirstThing(pawn.Map, XenomorphDefOf.RRY_Xenomorph_Hive_Slime) != null; if (pawn.GetLord() is Lord L && L != null) { if ((L.CurLordToil is LordToil_DefendAndExpandHiveLike || L.CurLordToil is LordToil_DefendHiveLikeAggressively) && L.CurLordToil is LordToil_HiveLikeRelated THL) { if (THL != null) { if (THL.Data != null) { HiveLike hive = THL.Data.assignedHiveLikes.TryGetValue(pawn); if (hive != null) { flag1 = hive.def == XenomorphDefOf.RRY_Xenomorph_Hive; flag2 = hive.def == XenomorphDefOf.RRY_Xenomorph_Hive_Child; } } } } } if (flag1) { MiningRange = 7; } else if (flag2) { MiningRange = 3; } else { MiningRange = 5; } if (!pawn.CanReachMapEdge()) { MiningRange = 10; } for (int i = 0; i < GenRadial.NumCellsInRadius(MiningRange); i++) { IntVec3 c = HiveCenter + GenRadial.RadialPattern[i]; if (!HiveStructure.HiveStruct(HiveCenter).Contains(c) && !HiveStructure.HiveWalls(HiveCenter).Contains(c) && pawn.CanReach(c, PathEndMode.ClosestTouch, Danger.Deadly)) { Building edifice = c.GetEdifice(pawn.Map); if (edifice != null && edifice.def.size == IntVec2.One && edifice.def != ThingDefOf.CollapsedRocks && edifice.def != XenomorphDefOf.RRY_Xenomorph_Hive_Wall && pawn.CanReserveAndReach(edifice, PathEndMode.ClosestTouch, Danger.Deadly, 1, 1) && XenomorphUtil.DistanceBetween(edifice.Position, HiveCenter) <= MiningRange) { bool xenobuilding = edifice.GetType() != typeof(Building_XenoEgg) && edifice.GetType() != typeof(Building_XenomorphCocoon) && edifice.GetType() != typeof(HiveLike); if (xenobuilding) { return(new Job(JobDefOf.Mine, edifice) { ignoreDesignations = true }); } } } } return(null); }
// Token: 0x0600041E RID: 1054 RVA: 0x0002CA54 File Offset: 0x0002AE54 protected override Job TryGiveJob(Pawn pawn) { Map map = pawn.Map; List <IntVec3> pillarLoc = new List <IntVec3>() { // Cardinals new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 3, z = pawn.mindState.duty.focus.Cell.z }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x - 3, z = pawn.mindState.duty.focus.Cell.z }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x, z = pawn.mindState.duty.focus.Cell.z + 3 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x, z = pawn.mindState.duty.focus.Cell.z - 3 }, // Corners new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 2, z = pawn.mindState.duty.focus.Cell.z + 2 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x - 2, z = pawn.mindState.duty.focus.Cell.z + 2 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x + 2, z = pawn.mindState.duty.focus.Cell.z - 2 }, new IntVec3 { x = pawn.mindState.duty.focus.Cell.x - 2, z = pawn.mindState.duty.focus.Cell.z - 2 } }; Region region = pawn.GetRegion(RegionType.Set_Passable); bool flag1 = pawn.mindState.duty.focus.Cell.GetFirstThing(pawn.Map, XenomorphDefOf.RRY_XenomorphHive) != null; bool flag2 = pawn.mindState.duty.focus.Cell.GetFirstThing(pawn.Map, XenomorphDefOf.RRY_XenomorphHive_Child) != null; bool flag3 = pawn.mindState.duty.focus.Cell.GetFirstThing(pawn.Map, XenomorphDefOf.RRY_Hive_Slime) != null; if (pawn.GetLord() is Lord L && L != null) { if ((L.CurLordToil is LordToil_DefendAndExpandHiveLike || L.CurLordToil is LordToil_DefendHiveLikeAggressively) && L.CurLordToil is LordToil_HiveLikeRelated THL) { if (THL != null) { if (THL.Data != null) { HiveLike hive = THL.Data.assignedHiveLikes.TryGetValue(pawn); if (hive != null) { flag1 = hive.def == XenomorphDefOf.RRY_XenomorphHive; flag2 = hive.def == XenomorphDefOf.RRY_XenomorphHive_Child; } } } } } if (region == null) { return(null); } if (flag2) { MiningRange = 3; } for (int i = 0; i < GenRadial.NumCellsInRadius(MiningRange); i++) { IntVec3 c = pawn.mindState.duty.focus.Cell + GenRadial.RadialPattern[MiningRange]; if (!pillarLoc.Contains(c)) { Building edifice = c.GetEdifice(pawn.Map); if (edifice != null && (edifice.def.passability == Traversability.Impassable /* || edifice.def.IsDoor */) && edifice.def.size == IntVec2.One && edifice.def != ThingDefOf.CollapsedRocks && edifice.def != XenomorphDefOf.RRY_Xenomorph_HiveWall && pawn.CanReserve(edifice, 1, -1, null, false) && XenomorphUtil.DistanceBetween(edifice.Position, pawn.mindState.duty.focus.Cell) <= MiningRange) { if (!pillarLoc.Contains(edifice.Position)) { return(new Job(JobDefOf.Mine, edifice) { ignoreDesignations = true }); } } } } return(null); }