protected override bool CanFireNowSub(IncidentParms parms) { var target = parms.target; var map = (Map)target; return(base.CanFireNowSub(parms) && HorrorHivesUtility.TotalSpawnedHivesCount(map) < 30 && InfestationCellFinder.TryFindCell(out _, map)); }
public bool DeterminSpot() { Map map = parms.target as Map; IncidentInterceptorUtility.IsIntercepting_InfestationCell = GeneratorPatchFlag.Generate; if (!InfestationCellFinder.TryFindCell(out loc, parms.target as Map)) { return(false); } lookTargets = new TargetInfo(loc, map, false); return(true); }
private HorrorHive SpawnHiveCluster(int hiveCount, Map map) { IntVec3 loc; if (!InfestationCellFinder.TryFindCell(out loc, map)) { return(null); } HorrorHive hive = (HorrorHive)GenSpawn.Spawn(ThingMaker.MakeThing(ThingDef.Named("HorrorHive"), null), loc, map); hive.SetFaction(Find.FactionManager.FirstFactionOfDef(FactionDef.Named("Horrors"))); return(hive); }
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 Lord CreateNewLord(Pawn pawn) { IntVec3 c; 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(LordMaker.MakeNewLord(parent.Faction, new LordJob_DefendBase(parent.Faction, c), parent.Map, null)); }
public static bool TryFindGoodHiveLoc(Pawn pawn, out IntVec3 c, Pawn victim = null, bool allowFogged = false, bool allowUnroofed = false, bool allowDigging = false) { Map map = pawn.Map; c = IntVec3.Invalid; if (map == null) { return false; } if (!pawn.isXenomorph(out Comp_Xenomorph _Xenomorph)) { return false; } else { c = _Xenomorph.HiveLoc; } MapComponent_HiveGrid hiveGrid = pawn.Map.GetComponent<MapComponent_HiveGrid>(); bool selected = map != null ? Find.Selector.SelectedObjects.Contains(pawn) && (Prefs.DevMode) : false; Predicate<IntVec3> validatora = delegate (IntVec3 y) { if (y.GetTerrain(map).HasTag("Water")) { return false; } bool roofed = (!allowUnroofed && y.Roofed(map)) || allowUnroofed; bool score = InfestationLikeCellFinder.GetScoreAt(y, map, allowFogged, allowUnroofed, allowDigging) > 0f;; 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).All(x => x.GetType() != typeof(Building_XenomorphCocoon) && x.GetType() != typeof(Building_XenoEgg) && x.GetType() != typeof(HiveLike)); bool r = score && !filled && edifice && building && thing && roofed; return r; }; /* if (validatora (_Xenomorph.HiveLoc)) { c = _Xenomorph.HiveLoc; } else if (hiveGrid.Hivelist.NullOrEmpty()) { Log.Warning("no hives present"); if (!hiveGrid.HiveLoclist.NullOrEmpty()) { // Log.Message("hivelocs present"); c = hiveGrid.HiveLoclist.RandomElement(); // return true; } else { Log.Warning("no hivelocs present"); } } else { // Log.Message("hives present"); c = hiveGrid.Hivelist.RandomElement().Position; // return true; } */ if (c == IntVec3.Invalid || c.x < 1 || c.z < 1 || c == IntVec3.Zero || c.InNoBuildEdgeArea(map) || c.InNoZoneEdgeArea(map) || c.GetTerrain(map).HasTag("Water")) { if (!InfestationLikeCellFinder.TryFindCell(out c, out IntVec3 lc, map, allowFogged, allowUnroofed, allowDigging)) { // Log.Message(string.Format("Cant find suitable hive location, defaulting to map edge")); if (!InfestationCellFinder.TryFindCell(out c, map)) { // Log.Message(string.Format("Cant find suitable hive location, defaulting to map edge")); if (!RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn)) { // Log.Message(string.Format("Cant find spot near map edge")); } else { // Log.Message(string.Format("RCellFinder: {0}", c)); } } else { // Log.Message(string.Format("InfestationCellFinder: {0}", c)); } } else { // Log.Message(string.Format("InfestationLikeCellFinder: {0}", c)); } }
protected override bool CanFireNowSub(IncidentParms parms) { Map map = (Map)parms.target; IntVec3 intVec; return(base.CanFireNowSub(parms) && HiveUtility.TotalSpawnedHivesCount(map) < 30 && InfestationCellFinder.TryFindCell(out intVec, map)); }
public static Map GetMap(bool mustBeInfestable = false, int?preferMapWithMinFreeColonists = null) { int minCount = preferMapWithMinFreeColonists ?? 1; IntVec3 cell; IEnumerable <Map> source = Find.Maps.Where((Map x) => x.IsPlayerHome && x != null && (!mustBeInfestable || InfestationCellFinder.TryFindCell(out cell, x))); if (!source.Where((Map x) => x.mapPawns.FreeColonists.Count >= minCount).TryRandomElement(out var result)) { source.Where((Map x) => x.mapPawns.FreeColonists.Any()).TryRandomElement(out result); } return(result); }