public override void Tick(int currentTick) { if (currentTick % 60 == 0) { //colonyPawns = Find.VisibleMap.mapPawns.FreeColonists.ToList(); PawnFinder.Update(); } }
static List <Pawn> GetNearbyPawns(IntVec3 root, Map map, ThingRequest thingReq, PathEndMode peMode, TraverseParms traverseParams, float maxDistance = 9999f, Predicate <Thing> validator = null, IEnumerable <Thing> customGlobalSearchSet = null, int searchRegionsMin = 0, int searchRegionsMax = -1, bool forceGlobalSearch = false, RegionType traversableRegionTypes = RegionType.Set_Passable, bool ignoreEntirelyForbiddenRegions = false) { Predicate <Thing> validator2 = (Thing t) => map.reachability.CanReach(root, t, peMode, traverseParams) && (validator == null || validator(t)); IEnumerable <Thing> searchSet = customGlobalSearchSet ?? map.listerThings.ThingsMatching(thingReq); var pawns = PawnFinder.FindPawns(root, searchSet, maxDistance, validator2, null); Log.Message("Pawns : " + pawns.Count()); return(pawns); }
protected override Job TryGiveJob(Pawn pawn) { var failconditions = pawn.gender != Gender.Male || !pawn.IsColonist; if (failconditions) { Log.Message("Failed : " + pawn.Name.ToStringShort); return(null); } var nearbyPawns = PawnFinder.GetNearbyPawns(pawn); var females = nearbyPawns.Where(x => x.gender == Gender.Female && x.CanCasuallyInteractNow()); if (females.Count() == 0) { return(null); } var female = females.MinBy(x => NeedUtil.GetSexNeed(x).CurLevelPercentage); if (female == null) { Log.Message("Cant find other pawn"); return(null); } failconditions = (NeedUtil.GetSexNeed(pawn).CurLevelPercentage > sexTrigger && pawn.needs.TryGetNeed <Need_Bladder>().CurLevelPercentage > maxBladder && NeedUtil.GetSexNeed(female).CurLevelPercentage > sexTrigger); if (failconditions) { return(null); } Log.Message("Found other pawn"); return(new Job(DefDatabase <JobDef> .GetNamed("HaveSex"), female)); }