public static bool TryFindDropSpotNear(IntVec3 center, Map map, out IntVec3 result, bool allowFogged, bool canRoofPunch) { if (DebugViewSettings.drawDestSearch) { map.debugDrawer.FlashCell(center, 1f, "center", 50); } Predicate <IntVec3> validator = delegate(IntVec3 c) { if (!DropCellFinder.IsGoodDropSpot(c, map, allowFogged, canRoofPunch)) { return(false); } if (!map.reachability.CanReach(center, c, PathEndMode.OnCell, TraverseMode.PassDoors, Danger.Deadly)) { return(false); } return(true); }; int num = 5; while (true) { if (CellFinder.TryFindRandomCellNear(center, map, num, validator, out result)) { return(true); } num += 3; if (num > 16) { break; } } result = center; return(false); }
public static TargetingParameters ForDropPodsDestination() { TargetingParameters targetingParameters = new TargetingParameters(); targetingParameters.canTargetLocations = true; targetingParameters.canTargetSelf = false; targetingParameters.canTargetPawns = false; targetingParameters.canTargetFires = false; targetingParameters.canTargetBuildings = false; targetingParameters.canTargetItems = false; targetingParameters.validator = ((TargetInfo x) => DropCellFinder.IsGoodDropSpot(x.Cell, x.Map, false, true)); return(targetingParameters); }
public static TargetingParameters ForDropPodsDestination() { return(new TargetingParameters { canTargetLocations = true, canTargetSelf = false, canTargetPawns = false, canTargetFires = false, canTargetBuildings = false, canTargetItems = false, validator = (TargetInfo x) => DropCellFinder.IsGoodDropSpot(x.Cell, x.Map, allowFogged: false, canRoofPunch: true) }); }
public static bool TryFindDropSpotNear(IntVec3 center, Map map, out IntVec3 result, bool allowFogged, bool canRoofPunch, bool willExplode) { if (DebugViewSettings.drawDestSearch) { map.debugDrawer.FlashCell(center, 1f, "center", 50); } Predicate <IntVec3> validator = (IntVec3 c) => DropCellFinder.IsGoodDropSpot(c, map, allowFogged, canRoofPunch) && map.reachability.CanReach(center, c, PathEndMode.OnCell, TraverseMode.PassDoors, Danger.Deadly) && (!willExplode || !SkyfallerUtility.CanPossiblyFallOnColonist(ThingDefOf.ExplosiveDropPodIncoming, c, map)); int num = 5; while (!CellFinder.TryFindRandomCellNear(center, map, num, validator, out result, -1)) { num += 3; if (num > 16) { result = center; return(false); } } return(true); }
private IntVec3 GetSpawnPosition() { if (!Props.dropInPods) { return(parent.Position); } Predicate <IntVec3> validator = delegate(IntVec3 c) { if (!DropCellFinder.IsGoodDropSpot(c, parent.MapHeld, allowFogged: false, canRoofPunch: true)) { return(false); } float num = c.DistanceTo(parent.Position); return(num >= (float)Props.pawnSpawnRadius.min && num <= (float)Props.pawnSpawnRadius.max); }; if (CellFinder.TryFindRandomCellNear(parent.Position, parent.MapHeld, Props.pawnSpawnRadius.max, validator, out IntVec3 result)) { return(result); } return(IntVec3.Invalid); }
public static IntVec3 TradeDropSpot(Map map) { IEnumerable <Building> collection = from b in map.listerBuildings.allBuildingsColonist where b.def.IsCommsConsole select b; IEnumerable <Building> enumerable = from b in map.listerBuildings.allBuildingsColonist where b.def.IsOrbitalTradeBeacon select b; Building building = enumerable.FirstOrDefault((Building b) => !map.roofGrid.Roofed(b.Position) && DropCellFinder.AnyAdjacentGoodDropSpot(b.Position, map, false, false)); IntVec3 position; if (building != null) { position = building.Position; IntVec3 result; if (!DropCellFinder.TryFindDropSpotNear(position, map, out result, false, false)) { Log.Error("Could find no good TradeDropSpot near dropCenter " + position + ". Using a random standable unfogged cell.", false); result = CellFinderLoose.RandomCellWith((IntVec3 c) => c.Standable(map) && !c.Fogged(map), map, 1000); } return(result); } List <Building> list = new List <Building>(); list.AddRange(enumerable); list.AddRange(collection); list.RemoveAll(delegate(Building b) { CompPowerTrader compPowerTrader = b.TryGetComp <CompPowerTrader>(); return(compPowerTrader != null && !compPowerTrader.PowerOn); }); Predicate <IntVec3> validator = (IntVec3 c) => DropCellFinder.IsGoodDropSpot(c, map, false, false); if (!list.Any <Building>()) { list.AddRange(map.listerBuildings.allBuildingsColonist); list.Shuffle <Building>(); if (!list.Any <Building>()) { return(CellFinderLoose.RandomCellWith(validator, map, 1000)); } } int num = 8; while (true) { for (int i = 0; i < list.Count; i++) { IntVec3 position2 = list[i].Position; if (CellFinder.TryFindRandomCellNear(position2, map, num, validator, out position, -1)) { return(position); } } num = Mathf.RoundToInt((float)num * 1.1f); if (num > map.Size.x) { goto Block_9; } } return(position); Block_9: Log.Error("Failed to generate trade drop center. Giving random.", false); return(CellFinderLoose.RandomCellWith(validator, map, 1000)); }
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)); }
private static bool <ForDropPodsDestination> m__3(TargetInfo x) { return(DropCellFinder.IsGoodDropSpot(x.Cell, x.Map, false, true)); }