public static Pawn FindAttractivePawn(Pawn w***e, out int price) { price = 0; if (w***e == null || xxx.is_asexual(w***e)) { if (RJWSettings.DebugWhoring) { Log.Message($" {xxx.get_pawnname(w***e)} is asexual, abort"); } return(null); } //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); FindAttractivePawnHelper client = new FindAttractivePawnHelper { w***e = w***e }; price = WhoringHelper.PriceOfWhore(w***e); int priceOfWhore = price; IntVec3 pos = w***e.Position; IEnumerable <Pawn> potentialClients = w***e.Map.mapPawns.AllPawnsSpawned; potentialClients = potentialClients.Where(x => x != w***e && !x.IsForbidden(w***e) && !x.HostileTo(w***e) && !x.IsPrisoner && x.Position.DistanceTo(pos) < 100 && w***e.CanReserveAndReach(x, PathEndMode.ClosestTouch, Danger.Some, 1) && xxx.is_healthy_enough(x)); potentialClients = potentialClients.Except(potentialClients.Where(client.TraitCheckFail)); if (!potentialClients.Any()) { return(null); } if (RJWSettings.DebugWhoring) { Log.Message($" FindAttractivePawn number of all potential clients {potentialClients.Count()}"); } List <Pawn> valid_targets = new List <Pawn>(); foreach (Pawn target in potentialClients) { if (xxx.can_path_to_target(w***e, target.Position)) { valid_targets.Add(target); } } IEnumerable <Pawn> guestsSpawned = valid_targets.Where(x => x.Faction != w***e.Faction && WhoringHelper.CanAfford(x, w***e, priceOfWhore) && !MemoryChecker(x, ThoughtDef.Named("RJWFailedSolicitation")) && x != LovePartnerRelationUtility.ExistingLovePartner(w***e)); if (guestsSpawned.Any()) { if (RJWSettings.DebugWhoring) { Log.Message($" FindAttractivePawn number of all acceptable Guests {guestsSpawned.Count()}"); } return(guestsSpawned.RandomElement()); } return(null); //use casual sex for colonist hooking if (RJWSettings.DebugWhoring) { Log.Message($" FindAttractivePawn found no guests, trying colonists"); } if (!WhoringHelper.WillPawnTryHookup(w***e)) // will hookup colonists? { return(null); } IEnumerable <Pawn> freeColonists = valid_targets.Where(x => x.Faction == w***e.Faction && Roll_to_skip(x, w***e)); if (RJWSettings.DebugWhoring) { Log.Message($" FindAttractivePawn number of free colonists {freeColonists.Count()}"); } freeColonists = freeColonists.Where(x => client.RelationCheckPass(x) && !MemoryChecker(x, ThoughtDef.Named("RJWTurnedDownWhore"))); if (freeColonists.Any()) { if (RJWSettings.DebugWhoring) { Log.Message($" FindAttractivePawn number of all acceptable Colonists {freeColonists.Count()}"); } return(freeColonists.RandomElement()); } return(null); }
public static Pawn FindAttractivePawn(Pawn p1, out int price) { price = 0; if (p1 == null) { //--Log.Message("[RJW] JobGiver_WhoreInvitingVisitors::FindAttractivePawn - p1 is null"); return(null); } FindAttractivePawnHelper findPawnHelper = new FindAttractivePawnHelper { p1 = p1 }; if (xxx.RomanceDiversifiedIsActive && findPawnHelper.p1.story.traits.HasTrait(xxx.asexual)) { return(null); } price = xxx.PriceOfWhore(p1); int priceOfWhore = price; IEnumerable <Pawn> guestsSpawned = p1.Map.mapPawns.AllPawnsSpawned; guestsSpawned = (guestsSpawned.Except(guestsSpawned.Where(findPawnHelper.TraitCheckFail)).Where(findPawnHelper.FactionCheckPass)); if (guestsSpawned.Count() > 0) { guestsSpawned = guestsSpawned.Where((x => !x.Position.IsForbidden(p1) && (!LovePartnerRelationUtility.HasAnyLovePartner(x) || x != LovePartnerRelationUtility.ExistingLovePartner(p1)) && Roll_to_skip(x, p1) && xxx.CanAfford(x, p1, priceOfWhore) && p1.CanReserve(x, 1, 0))); } Pawn whoreTarget = null; if (guestsSpawned.Count() > 0) { guestsSpawned.TryRandomElement(out whoreTarget); } if (whoreTarget != null) { return(whoreTarget); } //--Log.Message("[RJW] JobGiver_WhoreInvitingVisitors::FindAttractivePawn - found no visitors"); if (!xxx.WillPawnTryHookup(p1)) { return(null); } whoreTarget = null; IEnumerable <Pawn> freeColonistsSpawned = findPawnHelper.p1.Map.mapPawns.FreeColonistsSpawned; freeColonistsSpawned = (freeColonistsSpawned.Except(freeColonistsSpawned.Where(findPawnHelper.TraitCheckFail)).Where(x => findPawnHelper.RelationCheckPass(x) && !x.Position.IsForbidden(p1) && Roll_to_skip(x, p1) && p1.CanReserve(x, 1, 0))); if (freeColonistsSpawned == null || !freeColonistsSpawned.Any()) { return(null); } freeColonistsSpawned.TryRandomElement(out whoreTarget); if (whoreTarget == null) { return(null); } if (p1.relations.SecondaryRomanceChanceFactor(whoreTarget) < 0.05f) { return(null); } return(whoreTarget); }