public static bool TryFindBestItemToSteal(IntVec3 root, Map map, float maxDist, out Thing item, Pawn thief, List <Thing> disallowed = null) { if (thief != null && !thief.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { item = null; return(false); } if ((thief != null && !map.reachability.CanReachMapEdge(thief.Position, TraverseParms.For(thief, Danger.Some, TraverseMode.ByPawn, false))) || (thief == null && !map.reachability.CanReachMapEdge(root, TraverseParms.For(TraverseMode.PassDoors, Danger.Some, false)))) { item = null; return(false); } Predicate <Thing> predicate = (Thing t) => (thief == null || thief.CanReserve(t, 1, -1, null, false)) && (disallowed == null || !disallowed.Contains(t)) && t.def.stealable && !t.IsBurning(); ThingRequest thingReq = ThingRequest.ForGroup(ThingRequestGroup.HaulableEverOrMinifiable); PathEndMode peMode = PathEndMode.ClosestTouch; TraverseParms traverseParams = TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Some, false); Predicate <Thing> validator = predicate; if (StealAIUtility.< > f__mg$cache0 == null) { StealAIUtility.< > f__mg$cache0 = new Func <Thing, float>(StealAIUtility.GetValue); } item = GenClosest.ClosestThing_Regionwise_ReachablePrioritized(root, map, thingReq, peMode, traverseParams, maxDist, validator, StealAIUtility.< > f__mg$cache0, 15, 15); if (item != null && StealAIUtility.GetValue(item) < 320f) { item = null; } return(item != null); }
private static float TotalMarketValueAround(IntVec3 center, Map map, int pawnsCount) { if (center.Impassable(map)) { return(0f); } float num = 0f; tmpToSteal.Clear(); for (int i = 0; i < pawnsCount; i++) { IntVec3 intVec = center + GenRadial.RadialPattern[i]; if (!intVec.InBounds(map) || intVec.Impassable(map) || !GenSight.LineOfSight(center, intVec, map)) { intVec = center; } if (StealAIUtility.TryFindBestItemToSteal(intVec, map, 7f, out var item, null, tmpToSteal)) { num += StealAIUtility.GetValue(item); tmpToSteal.Add(item); } } tmpToSteal.Clear(); return(num); }
public static bool TryFindBestItemToSteal(IntVec3 root, Map map, float maxDist, out Thing item, Pawn thief, List <Thing> disallowed = null) { bool result; if (thief != null && !thief.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { item = null; result = false; } else if ((thief != null && !map.reachability.CanReachMapEdge(thief.Position, TraverseParms.For(thief, Danger.Some, TraverseMode.ByPawn, false))) || (thief == null && !map.reachability.CanReachMapEdge(root, TraverseParms.For(TraverseMode.PassDoors, Danger.Some, false)))) { item = null; result = false; } else { Predicate <Thing> validator = (Thing t) => (thief == null || thief.CanReserve(t, 1, -1, null, false)) && (disallowed == null || !disallowed.Contains(t)) && t.def.stealable && !t.IsBurning(); item = GenClosest.ClosestThing_Regionwise_ReachablePrioritized(root, map, ThingRequest.ForGroup(ThingRequestGroup.HaulableEverOrMinifiable), PathEndMode.ClosestTouch, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Some, false), maxDist, validator, (Thing x) => StealAIUtility.GetValue(x), 15, 15); if (item != null && StealAIUtility.GetValue(item) < 320f) { item = null; } result = (item != null); } return(result); }
private static float TotalMarketValueAround(IntVec3 center, Map map, int pawnsCount) { if (center.Impassable(map)) { return(0f); } float num = 0f; StealAIDebugDrawer.tmpToSteal.Clear(); for (int i = 0; i < pawnsCount; i++) { IntVec3 intVec = center + GenRadial.RadialPattern[i]; if (!intVec.InBounds(map) || intVec.Impassable(map) || !GenSight.LineOfSight(center, intVec, map, false, null, 0, 0)) { intVec = center; } Thing thing = default(Thing); if (StealAIUtility.TryFindBestItemToSteal(intVec, map, 7f, out thing, (Pawn)null, StealAIDebugDrawer.tmpToSteal)) { num += StealAIUtility.GetValue(thing); StealAIDebugDrawer.tmpToSteal.Add(thing); } } StealAIDebugDrawer.tmpToSteal.Clear(); return(num); }
public static bool TryFindBestItemToSteal(IntVec3 root, Map map, float maxDist, out Thing item, Pawn thief, List <Thing> disallowed = null) { if (thief != null && !thief.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { item = null; return(false); } if (thief != null && !map.reachability.CanReachMapEdge(thief.Position, TraverseParms.For(thief, Danger.Some, TraverseMode.ByPawn, false))) { goto IL_009d; } if (thief == null && !map.reachability.CanReachMapEdge(root, TraverseParms.For(TraverseMode.PassDoors, Danger.Some, false))) { goto IL_009d; } Predicate <Thing> validator = delegate(Thing t) { if (thief != null && !thief.CanReserve(t, 1, -1, null, false)) { return(false); } if (disallowed != null && disallowed.Contains(t)) { return(false); } if (!t.def.stealable) { return(false); } if (t.IsBurning()) { return(false); } return(true); }; item = GenClosest.ClosestThing_Regionwise_ReachablePrioritized(root, map, ThingRequest.ForGroup(ThingRequestGroup.HaulableEverOrMinifiable), PathEndMode.ClosestTouch, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Some, false), maxDist, validator, StealAIUtility.GetValue, 15, 15); if (item != null && StealAIUtility.GetValue(item) < 320.0) { item = null; } return(item != null); IL_009d: item = null; return(false); }
public static float TotalMarketValueAround(List <Pawn> pawns) { float num = 0f; StealAIUtility.tmpToSteal.Clear(); for (int i = 0; i < pawns.Count; i++) { Thing thing = default(Thing); if (pawns[i].Spawned && StealAIUtility.TryFindBestItemToSteal(pawns[i].Position, pawns[i].Map, 7f, out thing, pawns[i], StealAIUtility.tmpToSteal)) { num += StealAIUtility.GetValue(thing); StealAIUtility.tmpToSteal.Add(thing); } } StealAIUtility.tmpToSteal.Clear(); return(num); }
private static float <TryFindBestItemToSteal> m__0(Thing x) { return(StealAIUtility.GetValue(x)); }