public override float RandomSelectionWeight(Pawn initiator, Pawn recipient) { if (!initiator.IsColonist || !recipient.IsColonist) { return(0f); } if (!PartyUtility.AcceptableGameConditionsToStartParty(initiator.Map)) { return(0f); } PsychologyPawn realRecipient = recipient as PsychologyPawn; PsychologyPawn realInitiator = initiator as PsychologyPawn; if (realRecipient == null || realInitiator == null) { return(0f); } if (!LovePartnerRelationUtility.LovePartnerRelationExists(initiator, recipient)) { return(0f); } if (realInitiator.psyche.lastDateTick >= Find.TickManager.TicksGame - GenDate.TicksPerDay * 7 || realRecipient.psyche.lastDateTick >= Find.TickManager.TicksGame - GenDate.TicksPerDay * 7) { return(0f); } if (initiator.health.summaryHealth.SummaryHealthPercent < 1f || recipient.health.summaryHealth.SummaryHealthPercent < 1f) { return(0f); } return(1.2f * realInitiator.psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic) * (1f - realInitiator.psyche.GetPersonalityRating(PersonalityNodeDefOf.Independent)) * realRecipient.psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic) * (1f - realRecipient.psyche.GetPersonalityRating(PersonalityNodeDefOf.Independent)) * RendezvousUtility.ColonySizeFactor(initiator)); }
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 bool ExtraSocialiteParties(VoluntarilyJoinableLordsStarter __instance) { //Transpiler? Map map = Traverse.Create(__instance).Field("map").GetValue <Map>(); if (!map.IsPlayerHome) { return(false); } int socialiteMod = 1 + map.mapPawns.FreeColonistsSpawned.Where(p => p.story.traits.HasTrait(TraitDefOfPsychology.Socialite)).Count(); if (Find.TickManager.TicksGame % (GenDate.TicksPerHour * 2) == 0) { if (Rand.MTBEventOccurs(40f, GenDate.TicksPerDay, (GenDate.TicksPerHour * 2f * (1 + (socialiteMod / (map.mapPawns.ColonistCount > 0 ? map.mapPawns.ColonistCount : 1)))))) { Traverse.Create(__instance).Field("startPartyASAP").SetValue(true); } if (Traverse.Create(__instance).Field("startPartyASAP").GetValue <bool>() && Find.TickManager.TicksGame - Traverse.Create(__instance).Field("lastLordStartTick").GetValue <int>() >= (int)(GenDate.TicksPerSeason * 2 / (1 + (socialiteMod / (map.mapPawns.ColonistCount > 0 ? map.mapPawns.ColonistCount : 1)))) && PartyUtility.AcceptableGameConditionsToStartParty(map)) { Traverse.Create(__instance).Method("TryStartParty", new object[] { }).GetValue(); } } return(false); }
public static bool ExtraSocialiteParties(VoluntarilyJoinableLordsStarter __instance) { //Transpiler? Map map = Traverse.Create(__instance).Field("map").GetValue <Map>(); if (map.IsPlayerHome) { return(false); } int socialiteMod = 1; IEnumerable <Pawn> allPawnsSpawned = map.mapPawns.FreeColonistsSpawned; foreach (Pawn pawn in allPawnsSpawned) { if (pawn.RaceProps.Humanlike && pawn.story.traits.HasTrait(TraitDefOfPsychology.Socialite)) { socialiteMod++; } } if (Find.TickManager.TicksGame % GenDate.TicksPerHour * 2 == 0) { if (Rand.MTBEventOccurs(40f, GenDate.TicksPerDay, (GenDate.TicksPerHour * 2f * socialiteMod))) { Traverse.Create(__instance).Field("startPartyASAP").SetValue(true); } if (Traverse.Create(__instance).Field("startPartyASAP").GetValue <bool>() && Find.TickManager.TicksGame - Traverse.Create(__instance).Field("lastLordStartTick").GetValue <int>() >= (int)(GenDate.TicksPerSeason * 2 / socialiteMod) && PartyUtility.AcceptableGameConditionsToStartParty(map)) { Traverse.Create(__instance).Method("TryStartParty", new object[] { }).GetValue(); } } return(false); }
public override float RandomSelectionWeight(Pawn initiator, Pawn recipient) { if (initiator.guest.IsPrisoner || recipient.guest.IsPrisoner) { return(0f); } PsychologyPawn realRecipient = recipient as PsychologyPawn; PsychologyPawn realInitiator = initiator as PsychologyPawn; if (realRecipient == null || realInitiator == null) { return(0f); } if (initiator.GetLord() != null || recipient.GetLord() != null) { return(0f); } if (initiator.Drafted || recipient.Drafted) { return(0f); } if (!PartyUtility.AcceptableGameConditionsToStartParty(initiator.Map)) { return(0f); } if (initiator.health.summaryHealth.SummaryHealthPercent < 1f || recipient.health.summaryHealth.SummaryHealthPercent < 1f) { return(0f); } if (initiator.Faction != recipient.Faction) { return(0f); } float initiatorFactor = 0f; float recipientFactor = 0f; if (initiator.relations.OpinionOf(recipient) > -20) { initiatorFactor = realInitiator.psyche.GetPersonalityRating(PersonalityNodeDefOf.Extroverted) + 0.15f + Mathf.InverseLerp(0f, 100f, initiator.relations.OpinionOf(recipient)); recipientFactor = realRecipient.psyche.GetPersonalityRating(PersonalityNodeDefOf.Friendly); } else if (initiator.relations.OpinionOf(recipient) <= -20) { initiatorFactor = Mathf.InverseLerp(0f, 0.4f, realInitiator.psyche.GetPersonalityRating(PersonalityNodeDefOf.Empathetic) - 0.6f); recipientFactor = realRecipient.psyche.GetPersonalityRating(PersonalityNodeDefOf.Trusting); } float scheduleFactor = 0f; if (initiator.GetTimeAssignment() == TimeAssignmentDefOf.Anything) { scheduleFactor = 0.33f; } else if (initiator.GetTimeAssignment() == TimeAssignmentDefOf.Joy) { scheduleFactor = 1f; } if (initiator.mindState.IsIdle && recipient.mindState.IsIdle && initiator.GetTimeAssignment() != TimeAssignmentDefOf.Work && recipient.GetTimeAssignment() != TimeAssignmentDefOf.Work) { scheduleFactor = 5f; } return(0.05f * initiatorFactor * recipientFactor * scheduleFactor * RendezvousUtility.ColonySizeFactor(initiator)); }