public static bool KinseyException(ref Pawn pawn, PawnGenerationRequest request) { if (PsycheHelper.PsychologyEnabled(pawn)) { if (PsychologyBase.ActivateKinsey()) { while (PsycheHelper.Comp(pawn).Sexuality.kinseyRating > 2 && !request.AllowGay) { PsycheHelper.Comp(pawn).Sexuality.GenerateSexuality(); } if (LovePartnerRelationUtility.HasAnyLovePartnerOfTheSameGender(pawn) || LovePartnerRelationUtility.HasAnyExLovePartnerOfTheSameGender(pawn)) { while (PsycheHelper.Comp(pawn).Sexuality.kinseyRating < 2) { PsycheHelper.Comp(pawn).Sexuality.GenerateSexuality(); } } else if (LovePartnerRelationUtility.HasAnyLovePartnerOfTheOppositeGender(pawn) || LovePartnerRelationUtility.HasAnyExLovePartnerOfTheOppositeGender(pawn)) { while (PsycheHelper.Comp(pawn).Sexuality.kinseyRating > 4) { PsycheHelper.Comp(pawn).Sexuality.GenerateSexuality(); } } } } return(true); }
public override void Tick() { base.Tick(); if (!LovePartnerRelationUtility.LovePartnerRelationExists(this.pawn, this.partner)) { this.pawn.health.RemoveHediff(this); } else if (Find.TickManager.TicksGame >= this.day && GenLocalDate.HourOfDay(this.pawn) == this.hour) { if (this.pawn.GetTimeAssignment() != TimeAssignmentDefOf.Work && this.partner.GetTimeAssignment() != TimeAssignmentDefOf.Work && !this.pawn.Drafted && !this.partner.Drafted && PartyUtility.AcceptableGameConditionsToStartParty(this.pawn.Map) && this.pawn.Map == this.partner.Map) { pawn.jobs.StopAll(); if (pawn.Awake() && partner.Awake()) { LordMaker.MakeNewLord(this.pawn.Faction, new LordJob_Date(this.pawn, this.partner), this.pawn.Map, new Pawn[] { this.pawn, this.partner }); } else if (pawn.Awake()) { this.pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.MissedDate, this.partner); } else { this.partner.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.MissedDate, this.pawn); } } else { this.pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.DateCancelled); this.partner.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.DateCancelled); } this.pawn.health.RemoveHediff(this); } }
public static void PsychologyFormula(ref float __result, Pawn generated, Pawn other, PawnGenerationRequest request, bool ex) { /* Throw away the existing result and substitute our own formula. */ float sexualityFactor = 1f; PsychologyPawn realGenerated = generated as PsychologyPawn; PsychologyPawn realOther = other as PsychologyPawn; if (PsychologyBase.ActivateKinsey() && realGenerated != null && realOther != null && realGenerated.sexuality != null && realOther.sexuality != null) { float kinsey = 3 - realGenerated.sexuality.kinseyRating; float kinsey2 = 3 - realOther.sexuality.kinseyRating; float h**o = (generated.gender == other.gender) ? 1f : -1f; sexualityFactor *= Mathf.InverseLerp(3f, 0f, kinsey * h**o); sexualityFactor *= Mathf.InverseLerp(3f, 0f, kinsey2 * h**o); } else { sexualityFactor = (generated.gender != other.gender) ? 1f : 0.01f; } float existingExLoverFactor = 1f; if (ex) { int exLovers = 0; List <DirectPawnRelation> directRelations = other.relations.DirectRelations; for (int i = 0; i < directRelations.Count; i++) { if (LovePartnerRelationUtility.IsExLovePartnerRelation(directRelations[i].def)) { exLovers++; } } existingExLoverFactor = Mathf.Pow(0.2f, (float)exLovers); } else if (LovePartnerRelationUtility.HasAnyLovePartner(other)) { __result = 0f; return; } float generationChanceAgeFactor = Traverse.Create(typeof(LovePartnerRelationUtility)).Method("GetGenerationChanceAgeFactor", new[] { typeof(Pawn) }).GetValue <float>(new object[] { generated }); float generationChanceAgeFactor2 = Traverse.Create(typeof(LovePartnerRelationUtility)).Method("GetGenerationChanceAgeFactor", new[] { typeof(Pawn) }).GetValue <float>(new object[] { other }); float generationChanceAgeGapFactor = Traverse.Create(typeof(LovePartnerRelationUtility)).Method("GetGenerationChanceAgeGapFactor", new[] { typeof(Pawn), typeof(Pawn), typeof(bool) }).GetValue <float>(new object[] { generated, other, ex }); float incestFactor = 1f; if (generated.GetRelations(other).Any((PawnRelationDef x) => x.familyByBloodRelation)) { incestFactor = 0.01f; } float melaninFactor; if (request.FixedMelanin.HasValue) { melaninFactor = ChildRelationUtility.GetMelaninSimilarityFactor(request.FixedMelanin.Value, other.story.melanin); } else { melaninFactor = PawnSkinColors.GetMelaninCommonalityFactor(other.story.melanin); } __result = existingExLoverFactor * sexualityFactor * generationChanceAgeFactor * generationChanceAgeFactor2 * generationChanceAgeGapFactor * incestFactor * melaninFactor; }
public static bool NewSelectionWeight(InteractionWorker_Breakup __instance, ref float __result, Pawn initiator, Pawn recipient) { /* Also this one. */ if (!LovePartnerRelationUtility.LovePartnerRelationExists(initiator, recipient)) { __result = 0f; return(false); } else if (initiator.story.traits.HasTrait(TraitDefOfPsychology.Codependent)) { __result = 0f; return(false); } float chance = 0.02f; float romanticFactor = 1f; if (PsycheHelper.PsychologyEnabled(initiator)) { chance = 0.05f; romanticFactor = Mathf.InverseLerp(1.05f, 0f, PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic)); } float opinionFactor = Mathf.InverseLerp(100f, -100f, (float)initiator.relations.OpinionOf(recipient)); float spouseFactor = 1f; if (initiator.relations.DirectRelationExists(PawnRelationDefOf.Spouse, recipient)) { spouseFactor = 0.4f; } __result = chance * romanticFactor * opinionFactor * spouseFactor; return(false); }
protected override Job TryGiveJob(Pawn pawn) { if (pawn.AnimalOrWildMan()) { return(null); } if (!pawn.IsColonist) { return(null); } if (pawn.Drafted) { return(null); } if (pawn.Downed) { return(null); } if (HealthAIUtility.ShouldSeekMedicalRest(pawn)) { return(null); } CompMilkableHumanoid compMilk = pawn.TryGetComp <CompMilkableHumanoid>(); if (compMilk == null) { return(null); } if (!compMilk.ActiveAndCanBeMilked) { return(null); } if (!compMilk.MilkProps.canMilkThemselves) { return(null); } Pawn lover = LovePartnerRelationUtility.ExistingLovePartner(pawn); if (lover != null) { if (pawn.Faction == lover.Faction) { if (!lover.Drafted && !lover.Downed && !HealthAIUtility.ShouldSeekMedicalRest(lover)) { return(null); } } } return(new Job(MilkyDefOf.MilkySelf)); }
internal static float _RandomSelectionWeight(this InteractionWorker_RomanceAttempt _this, Pawn initiator, Pawn recipient) { PsychologyPawn realInitiator = initiator as PsychologyPawn; //Lovers won't romance each other if (LovePartnerRelationUtility.LovePartnerRelationExists(initiator, recipient)) { return(0f); } //Codependents won't romance anyone if they are in a relationship if (LovePartnerRelationUtility.HasAnyLovePartner(initiator) && initiator.story.traits.HasTrait(TraitDefOfPsychology.Codependent)) { return(0f); } //No one will romance someone they find less than 25% attractive float num = initiator.relations.SecondaryRomanceChanceFactor(recipient); if (num < 0.25f) { return(0f); } //No one will romance someone they have less than +5 opinion of int num2 = initiator.relations.OpinionOf(recipient); if (num2 < 5) { return(0f); } //Only lechers will romance someone that has less than +5 opinion of them if (recipient.relations.OpinionOf(initiator) < 5 && !initiator.story.traits.HasTrait(TraitDefOfPsychology.Lecher)) { return(0f); } //A pawn with +50 or more opinion of their lover will not hit on other pawns unless they are lecherous or polygamous (and their lover is also polygamous). float num3 = 1f; Pawn pawn = LovePartnerRelationUtility.ExistingMostLikedLovePartner(initiator, false); if (pawn != null && !initiator.story.traits.HasTrait(TraitDefOfPsychology.Lecher) && (!initiator.story.traits.HasTrait(TraitDefOfPsychology.Polygamous) && !pawn.story.traits.HasTrait(TraitDefOfPsychology.Polygamous))) { float value = (float)initiator.relations.OpinionOf(pawn); num3 = Mathf.InverseLerp(50f, -50f, value); } //Straight women are 15% as likely to romance anyone. float num4 = (!initiator.story.traits.HasTrait(TraitDefOf.Gay)) ? ((initiator.gender != Gender.Female) ? 1f : 0.15f) : 1f; float num5 = Mathf.InverseLerp(0.25f, 1f, num); float num6 = Mathf.InverseLerp(5f, 100f, (float)num2); //People who have hit on someone in the past and been rejected because of their sexuality will rarely attempt to hit on them again. float num7 = (realInitiator != null && realInitiator.sexuality.IncompatibleSexualityKnown(recipient)) ? 0.05f : 1f; //Only lechers will try to romance someone in a stable relationship. float num8 = 1f; Pawn pawn2 = LovePartnerRelationUtility.ExistingMostLikedLovePartner(recipient, false); if (pawn2 != null && !initiator.story.traits.HasTrait(TraitDefOfPsychology.Lecher)) { int value = recipient.relations.OpinionOf(pawn2); num8 = Mathf.InverseLerp(5f, -100f, (float)value); } return(1.15f * num3 * num4 * num5 * num6 * num3 * num7 * num8); }
private static bool TryFindMarriageSeeker(out Pawn marriageSeeker) => (from x in Find.WorldPawns.AllPawnsAlive where x.Faction != null && !x.Faction.def.hidden && !x.Faction.def.permanentEnemy && !x.Faction.IsPlayer && x.Faction.PlayerGoodwill <= 50 && !x.Faction.defeated && x.Faction.def.techLevel <= TechLevel.Medieval && x.Faction.leader != null && !x.Faction.leader.IsPrisoner && !x.Faction.leader.Spawned && !x.IsPrisoner && !x.Spawned && x.relations != null && x.RaceProps.Humanlike && !SettlementUtility.IsPlayerAttackingAnySettlementOf(faction : x.Faction) && !PeaceTalksExist(faction : x.Faction) && (!LovePartnerRelationUtility.HasAnyLovePartner(pawn : x) || LovePartnerRelationUtility.ExistingMostLikedLovePartner(p : x, allowDead : false)?.Faction == Faction.OfPlayer) select x).TryRandomElement(result : out marriageSeeker); //todo: make more likely to select hostile.
public override float OpinionOffset() { if (ThoughtUtility.ThoughtNullified(pawn, def)) { return(0f); } return(LovePartnerRelationUtility.IncestOpinionOffsetFor(otherPawn, pawn)); }
// // Methods // // EdB: Copy of CreateRelation() with changes to assign the other pawn's mother or father to this sibling if // they exist. The logic that's in there already seems to take this into account, but doing it this // results in more predictable behavior in the context of Prepare Carefully customization. public override void CreateRelation(Pawn generated, Pawn other, ref PawnGenerationRequest request) { // EdB: Added this block to immediately assign the other pawn's parent to the sibling. bool otherPawnHasMother = other.GetMother() != null; bool otherPawnHasFather = other.GetFather() != null; if (generated.GetMother() != null && generated.GetFather() != null && !otherPawnHasMother && !otherPawnHasFather) { other.SetMother(generated.GetMother()); other.SetFather(generated.GetFather()); return; } // EdB: This is the end of the change. Everything after this is the original implementation. bool flag = other.GetMother() != null; bool flag2 = other.GetFather() != null; bool flag3 = Rand.Value < 0.85f; if (flag && LovePartnerRelationUtility.HasAnyLovePartner(other.GetMother())) { flag3 = false; } if (flag2 && LovePartnerRelationUtility.HasAnyLovePartner(other.GetFather())) { flag3 = false; } if (!flag) { Pawn newMother = PawnRelationWorker_Sibling.GenerateParent(generated, other, Gender.Female, request, flag3); other.SetMother(newMother); } generated.SetMother(other.GetMother()); if (!flag2) { Pawn newFather = PawnRelationWorker_Sibling.GenerateParent(generated, other, Gender.Male, request, flag3); other.SetFather(newFather); } generated.SetFather(other.GetFather()); if (!flag || !flag2) { bool flag4 = other.GetMother().story.traits.HasTrait(TraitDefOf.Gay) || other.GetFather().story.traits.HasTrait(TraitDefOf.Gay); if (flag4) { other.GetFather().relations.AddDirectRelation(PawnRelationDefOf.ExLover, other.GetMother()); } else if (flag3) { other.GetFather().relations.AddDirectRelation(PawnRelationDefOf.Spouse, other.GetMother()); } else { LovePartnerRelationUtility.GiveRandomExLoverOrExSpouseRelation(other.GetFather(), other.GetMother()); } } PawnRelationWorker_Sibling.ResolveMyName(ref request, generated); PawnRelationWorker_Sibling.ResolveMySkinColor(ref request, generated); }
private bool TryFindBetrothed(out Pawn betrothed) { return((from potentialPartners in PawnsFinder .AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonistsAndPrisoners_NoCryptosleep where !LovePartnerRelationUtility.HasAnyLovePartner(potentialPartners) || LovePartnerRelationUtility.ExistingMostLikedLovePartner(potentialPartners, false) == marriageSeeker select potentialPartners).TryRandomElementByWeight( marriageSeeker2 => marriageSeeker.relations.SecondaryLovinChanceFactor(marriageSeeker2), out betrothed)); }
private static bool ShowHeart(float x, float y, Pawn pawn) { Texture2D iconFor; if (pawn == null || !pawn.IsColonist) { return(false); } DirectPawnRelation directPawnRelation = LovePartnerRelationUtility.ExistingMostLikedLovePartnerRel(pawn, false); if (directPawnRelation == null || directPawnRelation.otherPawn == null) { iconFor = null; } else if (!directPawnRelation.otherPawn.IsColonist || directPawnRelation.otherPawn.IsWorldPawn() || !directPawnRelation.otherPawn.relations.everSeenByPlayer) { iconFor = null; } else if (pawn.ownership?.OwnedBed != null && pawn.ownership?.OwnedBed == directPawnRelation.otherPawn.ownership?.OwnedBed) { iconFor = Textures.BondIcon; } else { iconFor = Textures.BondBrokenIcon; } if (iconFor != null) { Vector2 iconSize = new Vector2(iconFor.width, iconFor.height) * resizeHeart; Rect drawRect = new Rect(x, y, iconSize.x, iconSize.y); TooltipHandler.TipRegion(drawRect, directPawnRelation.otherPawn.LabelCap); if (iconFor == Textures.BondBrokenIcon) // if its a broken heart - allow them to click on the broken heart to assign the missing partner to the bed { if (Widgets.ButtonImage(drawRect, iconFor, Color.white, Color.red, true)) { if (pawn.ownership?.OwnedBed?.SleepingSlotsCount >= 2) { pawn.ownership.OwnedBed.GetComp <CompAssignableToPawn>().TryAssignPawn(directPawnRelation.otherPawn); return(true); } } } else { GUI.DrawTexture(drawRect, iconFor); } } return(false); }
//Use this check when p is in the same faction as the w***e internal bool RelationCheckPass(Pawn p) { if (xxx.isSingleOrPartnerNotHere(p) || (Rand.Value < 0.9f)) { if (p != LovePartnerRelationUtility.ExistingLovePartner(p1)) { return((p != p1) & (p.Map == p1.Map) && (p.Faction == p1.Faction) && p.IsColonist && xxx.IsHookupAppealing(p1, p)); } } return(false); }
internal bool RelationCheckPass(Pawn client) { //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); if (xxx.isSingleOrPartnerNotHere(client) || xxx.is_lecher(client) || Rand.Value < 0.9f) { if (client != LovePartnerRelationUtility.ExistingLovePartner(w***e)) { //Exception for prisoners to account for PrisonerWhoreSexualEmergencyTree, which allows prisoners to try to hook up with anyone who's around (mostly other prisoners or warden) return((client != w***e) & (client.Map == w***e.Map) && (client.Faction == w***e.Faction || w***e.IsPrisoner) && (client.IsColonist || w***e.IsPrisoner) && WhoringHelper.IsHookupAppealing(w***e, client)); } } return(false); }
// Token: 0x06000C80 RID: 3200 RVA: 0x0003DF08 File Offset: 0x0003C108 internal static void _Interacted(this InteractionWorker_RomanceAttempt _this, Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks) { if (Rand.Value < _SuccessChance(_this, initiator, recipient)) { List <Pawn> list; _BreakLoverAndFianceRelations(_this, initiator, out list); List <Pawn> list2; _BreakLoverAndFianceRelations(_this, recipient, out list2); for (int i = 0; i < list.Count; i++) { _TryAddCheaterThought(_this, list[i], initiator); } for (int j = 0; j < list2.Count; j++) { _TryAddCheaterThought(_this, list2[j], recipient); } initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.ExLover, recipient); initiator.relations.AddDirectRelation(PawnRelationDefOf.Lover, recipient); TaleRecorder.RecordTale(TaleDefOf.BecameLover, new object[] { initiator, recipient }); initiator.needs.mood.thoughts.memories.RemoveSocialMemoryThoughts(ThoughtDefOf.BrokeUpWithMe, recipient); recipient.needs.mood.thoughts.memories.RemoveSocialMemoryThoughts(ThoughtDefOf.BrokeUpWithMe, initiator); initiator.needs.mood.thoughts.memories.RemoveSocialMemoryThoughts(ThoughtDefOfPsychology.BrokeUpWithMeCodependent, recipient); recipient.needs.mood.thoughts.memories.RemoveSocialMemoryThoughts(ThoughtDefOfPsychology.BrokeUpWithMeCodependent, initiator); initiator.needs.mood.thoughts.memories.RemoveSocialMemoryThoughts(ThoughtDefOf.FailedRomanceAttemptOnMe, recipient); recipient.needs.mood.thoughts.memories.RemoveSocialMemoryThoughts(ThoughtDefOf.FailedRomanceAttemptOnMe, initiator); if (initiator.IsColonist || recipient.IsColonist) { var _SendNewLoversLetter = typeof(InteractionWorker_RomanceAttempt).GetMethod("SendNewLoversLetter", BindingFlags.Instance | BindingFlags.NonPublic); if (_SendNewLoversLetter != null) { _SendNewLoversLetter.Invoke(_this, new object[] { initiator, recipient, list, list2 }); } else { Log.ErrorOnce("Unable to reflect InteractionWorker_RomanceAttempt.SendNewLoversLetter!", 305432421); } } extraSentencePacks.Add(RulePackDefOf.Sentence_RomanceAttemptAccepted); LovePartnerRelationUtility.TryToShareBed(initiator, recipient); } else { initiator.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOf.RebuffedMyRomanceAttempt, recipient); recipient.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOf.FailedRomanceAttemptOnMe, initiator); extraSentencePacks.Add(RulePackDefOf.Sentence_RomanceAttemptRejected); } }
// LovePartnerRelationUtility.LovePartnerRelationGenerationChance, but with the gender and sexuality code removed. public static float LovePartnerRelationGenerationChance(Pawn generated, Pawn other, PawnGenerationRequest request, bool ex) { if (generated.ageTracker.AgeBiologicalYearsFloat < 14f) { return(0f); } if (other.ageTracker.AgeBiologicalYearsFloat < 14f) { return(0f); } var num = 1f; if (ex) { var num2 = 0; var directRelations = other.relations.DirectRelations; foreach (var directPawnRelation in directRelations) { if (LovePartnerRelationUtility.IsExLovePartnerRelation(directPawnRelation.def)) { num2++; } } num = Mathf.Pow(0.2f, num2); } else if (LovePartnerRelationUtility.HasAnyLovePartner(other)) { return(0f); } var generationChanceAgeFactor = GetGenerationChanceAgeFactor(generated); var generationChanceAgeFactor2 = GetGenerationChanceAgeFactor(other); var generationChanceAgeGapFactor = GetGenerationChanceAgeGapFactor(generated, other, ex); var num3 = 1f; if (generated.GetRelations(other).Any(x => x.familyByBloodRelation)) { num3 = 0.01f; } var num4 = request.FixedMelanin.HasValue ? ChildRelationUtility.GetMelaninSimilarityFactor(request.FixedMelanin.Value, other.story.melanin) : PawnSkinColors.GetMelaninCommonalityFactor(other.story.melanin); return(num * generationChanceAgeFactor * generationChanceAgeFactor2 * generationChanceAgeGapFactor * num3 * num4); }
protected override float MtbHours(Pawn pawn) { if (pawn.CurrentBed() == null) { return(-1f); } Pawn partnerInMyBed = LovePartnerRelationUtility.GetPartnerInMyBed(pawn); if (partnerInMyBed == null) { return(-1f); } return(LovePartnerRelationUtility.GetLovinMtbHours(pawn, partnerInMyBed)); }
public static void CancelJob(ref Job __result, Pawn pawn) { Pawn partner = LovePartnerRelationUtility.GetPartnerInMyBed(pawn); if (PsycheHelper.PsychologyEnabled(pawn) && PsycheHelper.PsychologyEnabled(partner) && PsychologyBase.ActivateKinsey()) { float random = Rand.ValueSeeded((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 2) * 60) * 391)); float random2 = Rand.ValueSeeded((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(partner) + GenLocalDate.Year(partner) + (int)(GenLocalDate.DayPercent(partner) * 2) * 60) * 391)); if (random > PsycheHelper.Comp(pawn).Sexuality.AdjustedSexDrive&& random2 > PsycheHelper.Comp(partner).Sexuality.AdjustedSexDrive) { __result = null; } } }
protected override ThoughtState CurrentStateInternal(Pawn p) { DirectPawnRelation directPawnRelation = LovePartnerRelationUtility.ExistingMostLikedLovePartnerRel(p, false); if (directPawnRelation == null) { return(false); } if (!directPawnRelation.otherPawn.IsColonist || directPawnRelation.otherPawn.IsWorldPawn() || !directPawnRelation.otherPawn.relations.everSeenByPlayer) { return(false); } if (p.relations.OpinionOf(directPawnRelation.otherPawn) <= 0) { return(false); } Building_Bed bed = p.ownership.OwnedBed; if (bed != null) { Room bedRoom = bed.GetRoom(RegionType.Set_Passable); if (bedRoom != null) { if (bedRoom.Role == RoomRoleDefOf.Barracks || bedRoom.Role == RoomRoleDefOf.Bedroom) { List <Thing> containedAndAdjacentThings = bedRoom.ContainedAndAdjacentThings; for (int i = 0; i < containedAndAdjacentThings.Count; i++) { Thing thing = containedAndAdjacentThings[i]; Building_Bed otherBed = thing as Building_Bed; if (otherBed != null) { for (int j = 0; j < otherBed.owners.Count; j++) { Pawn owner = otherBed.owners[j]; if (owner == directPawnRelation.otherPawn) { return(false); } } } } } } } return(true); }
private static bool ShowHeart(float x, float y, Pawn pawn) { Texture2D iconFor; if (pawn == null || !pawn.IsColonist) { return(false); } DirectPawnRelation directPawnRelation = LovePartnerRelationUtility.ExistingMostLikedLovePartnerRel(pawn, false); if (directPawnRelation == null || directPawnRelation.otherPawn == null) { iconFor = null; } else if (!directPawnRelation.otherPawn.IsColonist || directPawnRelation.otherPawn.IsWorldPawn() || !directPawnRelation.otherPawn.relations.everSeenByPlayer) { iconFor = null; } else if (pawn.ownership?.OwnedBed != null && pawn.ownership?.OwnedBed == directPawnRelation.otherPawn.ownership?.OwnedBed) { iconFor = Textures.BondIcon; } else { iconFor = Textures.BondBrokenIcon; } if (iconFor != null) { Vector2 iconSize = new Vector2(iconFor.width, iconFor.height) * resizeHeart; Rect drawRect = new Rect(x, y, iconSize.x, iconSize.y); TooltipHandler.TipRegion(drawRect, directPawnRelation.otherPawn.LabelCap); GUI.DrawTexture(drawRect, iconFor); if (iconFor == Textures.BondBrokenIcon && Mouse.IsOver(drawRect) && Input.GetMouseButtonDown(0)) { if (pawn.ownership?.OwnedBed?.SleepingSlotsCount >= 2) { pawn.ownership.OwnedBed.GetComp <CompAssignableToPawn>().TryAssignPawn(directPawnRelation.otherPawn); return(true); } } } return(false); }
public static void CurrentStateInternal(ref ThoughtState __result, Pawn p) { DirectPawnRelation directPawnRelation = LovePartnerRelationUtility.ExistingMostLikedLovePartnerRel(p, false); bool multiplePartners = (from r in p.relations.PotentiallyRelatedPawns where LovePartnerRelationUtility.LovePartnerRelationExists(p, r) select r).Count() > 1; bool partnerBedInRoom = (from t in p.ownership.OwnedBed.GetRoom().ContainedBeds where t.AssignedPawns.Contains(directPawnRelation.otherPawn) select t).Count() > 0; if (directPawnRelation != null && p.ownership.OwnedBed != null && p.story.traits.HasTrait(TraitDefOfPsychology.Polygamous) && multiplePartners && partnerBedInRoom) { __result = false; } }
public static void CancelJob(ref Job __result, Pawn pawn) { Pawn partnerInMyBed = LovePartnerRelationUtility.GetPartnerInMyBed(pawn); PsychologyPawn realPawn = pawn as PsychologyPawn; PsychologyPawn realPartner = partnerInMyBed as PsychologyPawn; if (realPawn != null && realPartner != null && PsychologyBase.ActivateKinsey() && realPawn.sexuality != null && realPartner.sexuality != null) { float random = Rand.ValueSeeded((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 2) * 60) * 391)); if (random > realPawn.sexuality.AdjustedSexDrive && random > realPartner.sexuality.AdjustedSexDrive) { __result = null; } } }
// Copied private static IEnumerable <Pawn> GetOwnersInternal(Room room) { // Extracted room types if (room.TouchesMapEdge || room.IsHuge || WrongRoomType(room)) { yield break; } Pawn pawn = null; Pawn secondOwner = null; foreach (Building_Bed containedBed in room.ContainedBeds) { if (containedBed.def.building.bed_humanlike) { foreach (var owner in containedBed.Owners()) { if (pawn == null) { pawn = owner; } else { if (secondOwner != null) { yield break; } secondOwner = owner; } } } } if (pawn != null) { if (secondOwner == null) { yield return(pawn); } else if (LovePartnerRelationUtility.LovePartnerRelationExists(pawn, secondOwner)) { yield return(pawn); yield return(secondOwner); } } }
// Token: 0x06000C7E RID: 3198 RVA: 0x0003DCB8 File Offset: 0x0003BEB8 internal static float _RandomSelectionWeight(this InteractionWorker_RomanceAttempt _this, Pawn initiator, Pawn recipient) { if (LovePartnerRelationUtility.LovePartnerRelationExists(initiator, recipient)) { return(0f); } if (LovePartnerRelationUtility.HasAnyLovePartner(initiator) && initiator.story.traits.HasTrait(TraitDefOfPsychology.Codependent)) { return(0f); } float num = initiator.relations.AttractionTo(recipient); int num2 = initiator.relations.OpinionOf(recipient); if (!initiator.story.traits.HasTrait(TraitDefOfPsychology.Lecher)) { if (num < 0.25f) { return(0f); } if (num2 < 5) { return(0f); } if (recipient.relations.OpinionOf(initiator) < 5) { return(0f); } } else { num = 0.25f; num2 = 5; } float num3 = 1f; Pawn pawn = LovePartnerRelationUtility.ExistingMostLikedLovePartner(initiator, false); if (pawn != null) { float value = (float)initiator.relations.OpinionOf(pawn); num3 = Mathf.InverseLerp(50f, -50f, value); } float num4 = (initiator.gender != Gender.Female) ? 1f : 0.125f; float num5 = Mathf.InverseLerp(0.25f, 1f, num); float num6 = Mathf.InverseLerp(5f, 100f, (float)num2); float num7 = (initiator.story.traits.HasTrait(TraitDefOfPsychology.Lecher)) ? 0.25f : 0f; return(1.15f * num4 * num5 * num6 * num3 + num7); }
protected override ThoughtState CurrentStateInternal(Pawn p) { if (!p.Spawned) { return(ThoughtState.Inactive); } if (!p.RaceProps.Humanlike) { return(ThoughtState.Inactive); } if (!p.story.traits.HasTrait(TraitDefOfPsychology.Codependent)) { return(ThoughtState.Inactive); } if (!LovePartnerRelationUtility.HasAnyLovePartner(p)) { return(ThoughtState.ActiveAtStage(0)); } else { Pawn lover = p.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Lover, null); if (lover == null) { lover = p.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Fiance, null); if (lover == null) { lover = p.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Spouse, null); } if (lover == null) { throw new NotImplementedException(); } if (lover.Dead == false) { return(ThoughtState.ActiveAtStage(2)); } else { return(ThoughtState.ActiveAtStage(3)); } } else { return(ThoughtState.ActiveAtStage(1)); } } }
public override void PostMake() { base.PostMake(); if (pawn.InBed()) { Pawn partner = LovePartnerRelationUtility.GetPartnerInMyBed(pawn); Building_Bed bed = pawn.CurrentBed(); if (partner != null) { pawn.mindState.awokeVoluntarily = true; partner.mindState.awokeVoluntarily = true; Job lovin = new Job(JobDefOf.Lovin, partner, bed); pawn.jobs.StartJob(lovin, JobCondition.InterruptForced, null, false, true, null); } } pawn.health.RemoveHediff(this); return; }
public static bool WillPawnTryHookup(Pawn target) { if (target.story.traits.HasTrait(TraitDefOf.Asexual)) { return(false); } Pawn lover = LovePartnerRelationUtility.ExistingMostLikedLovePartner(target, false); if (lover == null) { return(true); } float num = target.relations.OpinionOf(lover); float num2 = Mathf.InverseLerp(30f, -80f, num); if (xxx.is_prude(target)) { num2 = 0f; } else if (xxx.is_lecher(target)) { //Lechers are always up for it. num2 = Mathf.InverseLerp(100f, 50f, num); } else if (target.Map == lover.Map) { //Less likely to cheat if the lover is on the same map. num2 = Mathf.InverseLerp(70f, 15f, num); } //else default values if (xxx.is_frustrated(target)) { num2 *= 1.8f; } else if (xxx.is_hornyorfrustrated(target)) { num2 *= 1.4f; } num2 /= 1.5f; //Rand.PopState(); //Rand.PushState(RJW_Multiplayer.PredictableSeed()); return(Rand.Range(0f, 1f) < num2); }
public static bool PawnIsInLoveBed(Pawn p) { Building_Bed Bed = p.CurrentBed(); if (Bed == null) { return(false); } for (int i = 0; i < Bed.OwnersForReading.Count; i++) { if (LovePartnerRelationUtility.LovePartnerRelationExists(p, Bed.OwnersForReading[i])) { return(true); } } return(false); }
// Token: 0x06000052 RID: 82 RVA: 0x00005688 File Offset: 0x00003888 public static Pawn GetCondomPartnerInMyBed(Pawn pawn, Building_Bed LovinBed) { if (LovinBed.SleepingSlotsCount <= 1) { return(null); } if (!LovePartnerRelationUtility.HasAnyLovePartner(pawn)) { return(null); } foreach (Pawn curOccupant in LovinBed.CurOccupants) { if (curOccupant != pawn && LovePartnerRelationUtility.LovePartnerRelationExists(pawn, curOccupant)) { return(curOccupant); } } return(null); }
internal static float _RandomSelectionWeight(this InteractionWorker_Breakup _this, Pawn initiator, Pawn recipient) { if (!LovePartnerRelationUtility.LovePartnerRelationExists(initiator, recipient)) { return(0f); } else if (initiator.story.traits.HasTrait(TraitDefOfPsychology.Codependent)) { return(0f); } float num = Mathf.InverseLerp(100f, -100f, (float)initiator.relations.OpinionOf(recipient)); float num2 = 1f; if (initiator.relations.DirectRelationExists(PawnRelationDefOf.Spouse, recipient)) { num2 = 0.4f; } return(0.02f * num * num2); }
public override void Tick() { base.Tick(); if (!LovePartnerRelationUtility.LovePartnerRelationExists(this.pawn, this.partner)) { this.pawn.health.RemoveHediff(this); } else if (Find.TickManager.TicksAbs >= this.day && GenLocalDate.HourOfDay(this.pawn) == this.hour) { if (ShouldStartDate(pawn, partner) && ShouldStartDate(partner, pawn)) { pawn.jobs.StopAll(); partner.jobs.StopAll(); if (pawn.GetLord() != null) { pawn.GetLord().Notify_PawnLost(pawn, PawnLostCondition.ForcedToJoinOtherLord); } if (partner.GetLord() != null) { partner.GetLord().Notify_PawnLost(partner, PawnLostCondition.ForcedToJoinOtherLord); } if (pawn.Awake() && partner.Awake()) { LordMaker.MakeNewLord(this.pawn.Faction, new LordJob_Date(this.pawn, this.partner), this.pawn.Map, new Pawn[] { this.pawn, this.partner }); } else if (pawn.Awake()) { this.pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.MissedDate, this.partner); } else if (partner.Awake()) { this.partner.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.MissedDate, this.pawn); } } else { this.pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.DateCancelled); this.partner.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.DateCancelled); } this.pawn.health.RemoveHediff(this); } }