public bool IsRightSpot(TargetInfo x) { var maxRange = 10; GenDraw.DrawRadiusRing(pawn.Position, maxRange); return(maxRange >= pawn.Position.DistanceTo(x.Cell) && DropCellFinder.IsGoodDropSpot(x.Cell, x.Map, true, true, true)); }
private static IntVec3 FindViableDropSpotCenter(Map map) { const int viableCenterSearchRadius = 50; var center = map.Center; foreach (var c in GenRadial.RadialCellsAround(center, viableCenterSearchRadius, true)) { if (DropCellFinder.IsGoodDropSpot(c, map, false, false)) { return(c); } } return(center); }
// Token: 0x0600000B RID: 11 RVA: 0x000022B8 File Offset: 0x000004B8 internal static TargetingParameters ForJetPacksDestination() { TargetingParameters targetingParameters = new TargetingParameters { canTargetLocations = true, canTargetSelf = false, canTargetPawns = false, canTargetFires = false, canTargetBuildings = false, canTargetItems = false, validator = ((TargetInfo x) => DropCellFinder.IsGoodDropSpot(x.Cell, x.Map, true, Command_JetPack.JPRoofPunch, true)) }; return(targetingParameters); }
public static void SpawnArtilleryStrike(Map map, IntVec3 targetPosition, ArtilleryStrikeDef StrikeDef, Thing instigator = null, ThingDef weaponDef = null, bool warnFail = false) { for (int i = 0; i < StrikeDef.ordnance.Count; i++) { ThingDef ordnance = StrikeDef.ordnance[i]; IntVec3 strikeLoc = targetPosition; if (Rand.Chance(0.9f) || !DropCellFinder.IsGoodDropSpot(targetPosition, map, true, true)) { if (!OrdnanceStrikeCellFinder.TryFindStrikeLocNear(targetPosition, map, out strikeLoc, true, true, true)) { if (warnFail) { Log.Warning("Artillery Strike: " + StrikeDef.LabelCap + " Target: " + targetPosition + " Failed to find location"); } break; } } ArtilleryIncoming ordnanceIncoming = ArtilleryStrikeMaker.MakeSkyfaller(OrdnanceUtility.ArtilleryStrike, ordnance); GenPlace.TryPlaceThing(ordnanceIncoming, strikeLoc, map, ThingPlaceMode.Near, null, null, default(Rot4)); } }
public TargetingParameters ForShip(Faction faction) => new TargetingParameters() { canTargetLocations = true, canTargetSelf = false, canTargetPawns = false, canTargetFires = false, canTargetBuildings = false, canTargetItems = false, validator = targetInfo => { Mod.SetDropCellCheckEnabled(false); var goodDropSpot = DropCellFinder.IsGoodDropSpot(targetInfo.Cell, targetInfo.Map, false, true); Mod.SetDropCellCheckEnabled(true); var shielded = new FieldQuery(targetInfo.Map) .FriendlyTo(faction, true) .Intersects(PositionUtility.ToVector3(targetInfo.Cell)) .Get() .Any(); return(!shielded && goodDropSpot); } };
private static bool AnyAdjacentGoodDropSpot(IntVec3 c, Map map, bool allowFogged, bool canRoofPunch) { return(DropCellFinder.IsGoodDropSpot(c + IntVec3.North, map, allowFogged, canRoofPunch) || DropCellFinder.IsGoodDropSpot(c + IntVec3.East, map, allowFogged, canRoofPunch) || DropCellFinder.IsGoodDropSpot(c + IntVec3.South, map, allowFogged, canRoofPunch) || DropCellFinder.IsGoodDropSpot(c + IntVec3.West, map, allowFogged, canRoofPunch)); }
public static bool TryFindShipDropSpotNear(ShipBase ship, IntVec3 center, Map map, out IntVec3 result, bool allowFogged, bool canRoofPunch) { if (DebugViewSettings.drawDestSearch) { map.debugDrawer.FlashCell(center, 1f, "center"); } Predicate <IntVec3> validatingExistingShips = (IntVec3 c) => { Vector3 drawSize = ship.def.graphicData.drawSize; List <Thing> ships = map.listerThings.AllThings.FindAll(x => x is ShipBase_Traveling || x is ShipBase); for (int i = 0; i < ships.Count; i++) { if (ships[i].Position.InHorDistOf(c, Math.Max(drawSize.x, drawSize.z))) { return(false); } } return(true); }; Predicate <IntVec3> validator = (IntVec3 c) => validatingExistingShips(c) && DropCellFinder.IsGoodDropSpot(c, map, allowFogged, canRoofPunch) && map.reachability.CanReach(center, c, PathEndMode.OnCell, TraverseMode.PassDoors, Danger.Deadly); int num = 5; while (!CellFinder.TryFindRandomCellNear(center, map, num, validator, out result)) { num += 3; if (num > 29) { result = center; Log.Error("NoDropPoint found"); return(false); } } return(true); }
protected override void ScatterAt(IntVec3 c, Map map, GenStepParams parms, int stackCount = 1) { Log.Message("Horrors: Initiating Hive Spawn"); var noiseArray = new double[map.Size.x, map.Size.z]; var caveNoise = GeneratePerlinNoiseForCaves(map); Log.Message("Horrors: Noise Generated Successfully"); Log.Message("Horrors: Stepping through noise grid"); for (var i = 0; i < map.Size.x; i++) { for (var n = 0; n < map.Size.z; n++) { noiseArray[i, n] = caveNoise.layeredNoise(Convert.ToDouble(i) / 10, Convert.ToDouble(n) / 10); } } Log.Message("Horrors: Digging out tunnels"); for (var i = 0; i < map.Size.x; i++) { for (var n = 0; n < map.Size.z; n++) { var loc = new IntVec3(i, 0, n); if (CoverUtility.TotalSurroundingCoverScore(loc, map) > 0.2) { GenSpawn.Spawn(ThingDef.Named("HorrorWeb"), loc, map); } if (!(noiseArray[i, n] > 0.5)) { continue; } if (loc.GetEdifice(map) != null) { loc.GetEdifice(map).Destroy(DestroyMode.KillFinalize); } if (map.fogGrid.IsFogged(loc)) { map.fogGrid.Unfog(loc); } // map.terrainGrid.SetTerrain(loc, TerrainDef.Named("FloorWebs")); } } Log.Message("Horrors: Generating Hive Rect"); var rect = new CellRect(0, 0, 0, 0); Faction faction; if (map.info.parent?.Faction == null || map.info.parent.Faction == Faction.OfPlayer) { faction = Find.FactionManager.RandomEnemyFaction(); } else { faction = map.info.parent.Faction; } rect = rect.ExpandedBy(4); rect.ClipInsideMap(map); var resolveParams = default(ResolveParams); resolveParams.rect = rect; resolveParams.faction = faction; BaseGen.globalSettings.map = map; Log.Message("Horrors: Validating Spawns"); bool Validator(IntVec3 p) { return(DropCellFinder.IsGoodDropSpot(p, map, true, true)); } // Pawns var queenPawn = PawnGenerator.GeneratePawn(PawnKindDef.Named("Pirate"), faction); Log.Message("Horrors: Spawning Sinkhole"); CellFinder.TryFindRandomCellNear(map.Center, map, 20, Validator, out var cellReturned); GenSpawn.Spawn(ThingDef.Named("SinkHole"), map.Center, map); Log.Message("Horrors: Spawning Sinkhole"); CellFinder.TryFindRandomCellNear(map.Center, map, 20, Validator, out cellReturned); GenSpawn.Spawn(ThingDef.Named("SinkHole"), cellReturned, map); Log.Message("Horrors: Spawning Sinkhole"); CellFinder.TryFindRandomCellNear(map.Center, map, 20, Validator, out cellReturned); GenSpawn.Spawn(ThingDef.Named("SinkHole"), cellReturned, map); Log.Message("Horrors: Spawning Sinkhole"); CellFinder.TryFindRandomCellNear(map.Center, map, 20, Validator, out cellReturned); GenSpawn.Spawn(ThingDef.Named("SinkHole"), cellReturned, map); Log.Message("Horrors: Spawning Sinkhole"); CellFinder.TryFindRandomCellNear(map.Center, map, 20, Validator, out cellReturned); var queen = GenSpawn.Spawn(queenPawn, cellReturned, map); var pawnToSpawn = PawnGenerator.GeneratePawn(PawnKindDef.Named("BroodLord"), faction); GenSpawn.Spawn(pawnToSpawn, cellReturned, map); pawnToSpawn.training.Train(TrainableDefOf.Obedience, (Pawn)queen); }
public static bool IsGoodDropSpot(IntVec3 c, Map map, bool allowFogged, bool canRoofPunch) { return(DropCellFinder.IsGoodDropSpot(c, map, allowFogged, canRoofPunch) && !Mod.ShieldManager.ImpactShield(map, Common.ToVector2(c))); }
public static bool TryFindShipDropSpotNear(ShipBase ship, IntVec3 center, Map map, out IntVec3 result, bool allowFogged, bool canRoofPunch) { if (DebugViewSettings.drawDestSearch) { map.debugDrawer.FlashCell(center, 1f, "center"); } Predicate <IntVec3> validatingExistingShips = (IntVec3 c) => { Vector2 drawSize = ship.def.graphicData.drawSize; List <Thing> ships = map.listerThings.AllThings.FindAll(x => x is ShipBase_Traveling || x.GetType().IsAssignableFrom(typeof(ShipBase))); for (int i = 0; i < ships.Count; i++) { if (GenAdj.OccupiedRect(ships[i]).Overlaps(GenAdj.OccupiedRect(ship).ExpandedBy(1))) { return(false); } } return(true); }; Predicate <IntVec3> validator = (IntVec3 c) => validatingExistingShips(c) && DropCellFinder.IsGoodDropSpot(c, map, allowFogged, canRoofPunch) && map.reachability.CanReach(center, c, PathEndMode.OnCell, TraverseMode.PassDoors, Danger.Deadly) && GenAdj.OccupiedRect(c, ship.Rotation, ship.def.Size).InBounds(map); int num = 5; while (!CellFinder.TryFindRandomCellNear(center, map, num, validator, out result)) { num += 3; if (num > 29) { result = center; Log.Error("NoDropPoint found"); return(false); } } return(true); }