public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { if (t == null || pawn == null) { return(false); } if (t is Pawn pawn2 && pawn != pawn2 && (forced || canAutoLove(pawn, pawn2)) && !pawn2.Downed && !pawn2.Drafted && !pawn.Drafted && PawnHelper.is_human(pawn) && PawnHelper.is_human(pawn2) && PawnHelper.IsNotWoohooing(pawn) && PawnHelper.IsNotWoohooing(pawn2)) { LocalTargetInfo target = pawn2; if (!pawn.CanReserve(target, 1, -1, null, forced)) { return(false); } bed = BetterBedFinder.DoBetterBedFinder(pawn, pawn2); return(bed != null); } return(false); }
public static IEnumerable <Toil> MakePartnerWoohoo(Pawn pawn, Pawn mate, Building_Bed bed) { int tick = 400; void NewFunction() { if (PawnHelper.IsNotWoohooing(mate)) { /* Log.Message("Asking for love job"); */ Job newJob = new Job(Constants.JobWooHooRecieve, pawn, bed) { playerForced = true //its important }; mate.jobs.StartJob(newJob, JobCondition.InterruptForced); /* Log.Message("Make Lover Go To Bed"); */ //mate.jobs.StartJob(, JobCondition.InterruptForced); } else { /* Log.Message("Partner already doin it"); */ } } Toil t = new Toil() { socialMode = RandomSocialMode.Off, tickAction = NewFunction, initAction = NewFunction }; t.AddEndCondition(() => PawnHelper.IsNotWoohooing(mate) && (tick--) > 0 ? JobCondition.Ongoing : JobCondition.Succeeded); yield return(t); }
protected override IEnumerable <Toil> MakeNewToils() { //Pawn mate = TargetA.Thing as Pawn; //Building_Bed bed = TargetB.Thing as Building_Bed; Pawn mate; Building_Bed bed; if (TargetA != null && TargetA.Thing != null && (mate = TargetA.Thing as Pawn) != null && TargetB != null && TargetB.Thing != null && (bed = TargetB.Thing as Building_Bed) != null && pawn != null && PawnHelper.is_human(pawn) && PawnHelper.is_human(mate) && !bed.IsBurning() ) { //everything is in order then } else { Log.Error("[" + pawn.Name + "] can't woohoo right.", true); EndJobWith(JobCondition.Errored); return(null); } if (pawn == mate) { throw new Exception("You cant WooHoo Alone and Together with yourself"); } var hookupBedManager = new HookupBedManager(bed); bool partnerSaidYes; IEnumerable <Toil> toilsAskForWoohoo; if (PawnHelper.IsNotWoohooing(mate)) { pawn.records.Increment(Constants.CountAskedForWoohoo); mate.records.Increment(Constants.CountGotAskedToWooHoo); partnerSaidYes = AskPartner(pawn, mate); toilsAskForWoohoo = WoohooManager.ToilsAskForWoohoo(pawn, mate, bed, partnerSaidYes, hookupBedManager); } else { /* Log.Message("Partner already woohooin, dont need to ask."); */ partnerSaidYes = true; toilsAskForWoohoo = nothing(); } ///Log.Message("[WooHoo]Toils Ongoing: ["+r.Count()+"]"); if (partnerSaidYes) { toilsAskForWoohoo = toilsAskForWoohoo?.Union(WoohooManager.MakePartnerWoohoo(pawn, mate, bed)) .Union(WoohooManager.AnimateLovin(pawn, mate, bed)) .Union(MakeMyLoveToils(pawn, mate)) .Union( WoohooManager.AnimateLovin(pawn, mate, bed, null , 500) ); } else { mate.records.Increment(Constants.CountGotAskedToWooHooSaidNo); } toilsAskForWoohoo = toilsAskForWoohoo?.Union(hookupBedManager.GiveBackToil()); /* Log.Message("[WooHoo]Toils: ["+r.Count()+"]"); */ PawnHelper.DelayNextWooHoo(pawn); return(toilsAskForWoohoo); }