protected override bool CanFireNowSub(IncidentParms parms) { Map map = (Map)parms.target; IntVec3 cell; if (base.CanFireNowSub(parms) && HiveUtility.TotalSpawnedHivesCount(map) < 30) { return(InfestationCellFinder.TryFindCell(out cell, map)); } return(false); }
private Thing SpawnTunnels(int hiveCount, Map map) { IntVec3 loc; if (!InfestationCellFinder.TryFindCell(out loc, map)) { return(null); } Thing thing = GenSpawn.Spawn(ThingMaker.MakeThing(ThingDefOf.TunnelHiveSpawner, null), loc, map, WipeMode.FullRefund); for (int i = 0; i < hiveCount - 1; i++) { loc = CompSpawnerHives.FindChildHiveLocation(thing.Position, map, ThingDefOf.Hive, ThingDefOf.Hive.GetCompProperties <CompProperties_SpawnerHives>(), false, true); if (loc.IsValid) { thing = GenSpawn.Spawn(ThingMaker.MakeThing(ThingDefOf.TunnelHiveSpawner, null), loc, map, WipeMode.FullRefund); } } return(thing); }
private Hive SpawnHiveCluster(int hiveCount, Map map) { IntVec3 loc = default(IntVec3); if (!InfestationCellFinder.TryFindCell(out loc, map)) { return(null); } Hive hive = (Hive)GenSpawn.Spawn(ThingMaker.MakeThing(ThingDefOf.Hive, null), loc, map); hive.SetFaction(Faction.OfInsects, null); IncidentWorker_Infestation.SpawnInsectJellyInstantly(hive); for (int i = 0; i < hiveCount - 1; i++) { Hive hive2 = default(Hive); if (hive.GetComp <CompSpawnerHives>().TrySpawnChildHive(false, out hive2)) { IncidentWorker_Infestation.SpawnInsectJellyInstantly(hive2); hive = hive2; } } return(hive); }
// Token: 0x06000424 RID: 1060 RVA: 0x0002CE84 File Offset: 0x0002B284 protected override Job TryGiveJob(Pawn pawn) { CompXenoEggLayer compEggLayer = pawn.TryGetComp <CompXenoEggLayer>(); if (compEggLayer == null || !compEggLayer.CanLayNow) { return(null); } IntVec3 c; if (pawn.GetLord() != null && pawn.GetLord().LordJob is LordJob_DefendBase lordjob) { c = lordjob.lord.Graph.StartingToil.FlagLoc; c = RCellFinder.RandomWanderDestFor(pawn, c, 5f, null, Danger.Some); } else { Thing thing = GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForDef(XenomorphDefOf.RRY_EggXenomorphFertilized), PathEndMode.OnCell, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), 9999f, null, null, 0, -1, false, RegionType.Set_Passable, false); if (thing == null) { c = RCellFinder.RandomWanderDestFor(pawn, pawn.Position, 5f, null, Danger.Some); } else { InfestationCellFinder.TryFindCell(out c, pawn.Map); if (pawn.CanReach(c, PathEndMode.OnCell, Danger.Deadly)) { c = RCellFinder.RandomWanderDestFor(pawn, c, 3f, null, Danger.Some); } else { c = RCellFinder.RandomWanderDestFor(pawn, thing.Position, 3f, null, Danger.Some); } } } return(new Job(XenomorphDefOf.RRY_Job_LayXenomorphEgg, c)); }
// Token: 0x0600368B RID: 13963 RVA: 0x001A0E1C File Offset: 0x0019F21C public static bool TryFindCell(out IntVec3 cell, out IntVec3 locationC, Map map, bool allowFogged = true) { ThingDef namedA = XenomorphDefOf.RRY_Xenomorph_Humanoid_Cocoon; ThingDef namedB = XenomorphDefOf.RRY_Xenomorph_Animal_Cocoon; InfestationLikeCellFinder.CalculateLocationCandidates(map, allowFogged); Predicate <IntVec3> validator = delegate(IntVec3 y) { bool score = InfestationLikeCellFinder.GetScoreAt(y, map, allowFogged) > 0f; bool XenohiveA = y.GetFirstThing(map, XenomorphDefOf.RRY_XenomorphHive) == null; bool XenohiveB = y.GetFirstThing(map, XenomorphDefOf.RRY_XenomorphHive_Child) == null; bool filled = y.Filled(map); bool edifice = y.GetEdifice(map).DestroyedOrNull(); bool building = y.GetFirstBuilding(map).DestroyedOrNull(); bool thingA = y.GetFirstThing(map, namedA).DestroyedOrNull(); bool thingB = y.GetFirstThing(map, namedB).DestroyedOrNull(); Log.Message(string.Format("Cell: {0}, score: {1}, XenohiveA: {2}, XenohiveB: {3}, !filled: {4}, edifice: {5}, building: {6}, thingA: {7}, thingB: {8}\nResult: {9}", y, GetScoreAt(y, map, allowFogged), XenohiveA, XenohiveB, !filled, edifice, building, thingA, thingB, score && XenohiveA && XenohiveB && !filled && edifice && building && thingA && thingB)); return(score && XenohiveA && XenohiveB && !filled && edifice && building && thingA && thingB); }; if (!InfestationLikeCellFinder.locationCandidates.TryRandomElementByWeight((InfestationLikeCellFinder.LocationCandidate x) => x.score, out LocationCandidate locationCandidate)) { cell = IntVec3.Invalid; locationC = IntVec3.Invalid; if (!InfestationCellFinder.TryFindCell(out cell, map)) { cell = IntVec3.Invalid; return(false); } } locationC = locationCandidate.cell; cell = CellFinder.FindNoWipeSpawnLocNear(locationCandidate.cell, map, XenomorphDefOf.RRY_XenomorphHive, Rot4.North, 2, (IntVec3 x) => InfestationLikeCellFinder.GetScoreAt(x, map, allowFogged) > 0f && x.GetFirstThing(map, XenomorphDefOf.RRY_XenomorphHive) == null && x.GetFirstThing(map, OGHiveLikeDefOf.TunnelHiveLikeSpawner) == null && x.GetFirstThing(map, XenomorphDefOf.RRY_Xenomorph_Humanoid_Cocoon) == null && x.GetFirstThing(map, XenomorphDefOf.RRY_Xenomorph_Animal_Cocoon) == null); ThingDef td = XenomorphDefOf.RRY_Hive_Slime; GenSpawn.Spawn(td, cell, map); return(true); }
// Token: 0x0600368B RID: 13963 RVA: 0x001A0E1C File Offset: 0x0019F21C public static bool TryFindCell(out IntVec3 cell, out IntVec3 locationC, Map map, bool allowFogged = false, bool allowUnroofed = false, bool allowDigging = false, bool forceNew = false) { InfestationLikeCellFinder.CalculateLocationCandidates(map, allowFogged, allowUnroofed, allowDigging, forceNew); if (!forceNew) { // Log.Message("exsisting hivelocs allowed"); if (!map.HiveGrid().Hivelist.NullOrEmpty()) { cell = map.HiveGrid().Hivelist.RandomElement().Position; locationC = map.HiveGrid().Hivelist.RandomElement().Position; return(true); } if (!map.HiveGrid().HiveLoclist.NullOrEmpty()) { cell = map.HiveGrid().HiveLoclist.RandomElement(); locationC = map.HiveGrid().HiveLoclist.RandomElement(); return(true); } } Predicate <IntVec3> validator = delegate(IntVec3 y) { if (y.GetTerrain(map).HasTag("Water") || y.InNoBuildEdgeArea(map)) { return(false); } bool roofed = (!allowUnroofed && y.Roofed(map)) || allowUnroofed; bool score = InfestationLikeCellFinder.GetScoreAt(y, map, allowFogged, allowUnroofed, allowDigging) > 0f; bool XenohiveA = y.GetFirstThing(map, XenomorphDefOf.RRY_Xenomorph_Hive) == null; bool XenohiveB = y.GetFirstThing(map, XenomorphDefOf.RRY_Xenomorph_Hive_Child) == null; bool filled = y.Filled(map) && !allowDigging; bool edifice = y.GetEdifice(map).DestroyedOrNull() || allowDigging; bool building = y.GetFirstBuilding(map).DestroyedOrNull() || allowDigging; bool thing = !y.GetThingList(map).Any(x => x.GetType() == typeof(Building_XenomorphCocoon) || x.GetType() == typeof(Building_XenoEgg) || x.GetType() == typeof(HiveLike)) || !forceNew; bool result = score && XenohiveA && XenohiveB && !filled && edifice && building && thing && roofed; return(result); }; if (!InfestationLikeCellFinder.locationCandidates.Where(y => validator(y.cell)).TryRandomElementByWeight((InfestationLikeCellFinder.LocationCandidate x) => x.score, out LocationCandidate locationCandidate)) { // Log.Message(string.Format("Cant find any suitable location candidates")); cell = IntVec3.Invalid; if (!InfestationCellFinder.TryFindCell(out cell, map)) { if (!map.HiveGrid().PotentialHiveLoclist.NullOrEmpty()) { if (map.HiveGrid().PotentialHiveLoclist.Any(x => (x.X < 50 || x.Z < 50) && (!forceNew || !x.HiveLoc.GetThingList(map).Any(y => y.GetType() == typeof(HiveLike))))) { // Log.Message(string.Format("PotentialHiveLoclist location candidates 50 {0}", forceNew)); cell = map.HiveGrid().PotentialHiveLoclist.Where(x => (x.X < 50 || x.Z < 50) && (!forceNew || !x.HiveLoc.GetThingList(map).Any(y => y.GetType() == typeof(HiveLike)))).RandomElement().HiveLoc; locationC = cell; } else if (map.HiveGrid().PotentialHiveLoclist.Any(x => (x.X < 75 || x.Z < 75) && (!forceNew || !x.HiveLoc.GetThingList(map).Any(y => y.GetType() == typeof(HiveLike))))) { // Log.Message(string.Format("PotentialHiveLoclist location candidates 75 {0}", forceNew)); cell = map.HiveGrid().PotentialHiveLoclist.Where(x => (x.X < 75 || x.Z < 75) && (!forceNew || !x.HiveLoc.GetThingList(map).Any(y => y.GetType() == typeof(HiveLike)))).RandomElement().HiveLoc; locationC = cell; } else { // Log.Message(string.Format("PotentialHiveLoclist location candidates {0}", forceNew)); cell = map.HiveGrid().PotentialHiveLoclist.Where(x => (!forceNew || !x.HiveLoc.GetThingList(map).Any(y => y.GetType() == typeof(HiveLike)))).RandomElement().HiveLoc; locationC = cell; } return(true); } cell = IntVec3.Invalid; locationC = IntVec3.Invalid; return(false); } } locationC = locationCandidate.cell; cell = CellFinder.FindNoWipeSpawnLocNear(locationCandidate.cell, map, XenomorphDefOf.RRY_Xenomorph_Hive, Rot4.North, 2, validator); ThingDef td = XenomorphDefOf.RRY_Xenomorph_Hive_Slime; GenSpawn.Spawn(td, cell, map); return(true); }
protected override bool CanFireNowSub(IncidentParms parms) { Map map = (Map)parms.target; IntVec3 intVec; return(base.CanFireNowSub(parms) && HivesUtility.TotalSpawnedHivesCount(map) < 30 && InfestationCellFinder.TryFindCell(out intVec, map)); }
protected override bool CanFireNowSub(IIncidentTarget target) { Map map = (Map)target; IntVec3 intVec = default(IntVec3); return(base.CanFireNowSub(target) && HivesUtility.TotalSpawnedHivesCount(map) < 30 && InfestationCellFinder.TryFindCell(out intVec, map)); }