public override Evaluation GetStage(Building_BaseAltar altar) { CongregationParms parms = altar.congregationParms; if (parms.preacher == null) { return(null); } Spirituality need = parms.preacher.needs.TryGetNeed <Spirituality>(); float skill = 0.0f; if (need != null) { skill = need.CurLevelPercentage; } if (skill > .7f) { return(evaluations[3]); } else if (skill > .5f) { return(evaluations[2]); } else if (skill > .3f) { return(evaluations[1]); } else { return(evaluations[0]); } }
protected override IEnumerable <Toil> MakeNewToils() { JobDriver_CultResearch jobDriver_Research = this; this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); Toil research = new Toil(); research.tickAction = delegate { Pawn actor = research.actor; float statValue = actor.GetStatValue(StatDefOf.ResearchSpeed); statValue *= jobDriver_Research.TargetThingA.GetStatValue(StatDefOf.ResearchSpeedFactor); Find.ResearchManager.ResearchPerformed(statValue, actor); actor.skills.Learn(SkillDefOf.Intellectual, 0.1f); actor.GainComfortFromCellIfPossible(chairsOnly: true); // -- new code -- if (Find.ResearchManager.currentProj != null && Find.ResearchManager.currentProj.HasModExtension <ForbiddenResearchExtension>()) { Spirituality need = pawn.needs.TryGetNeed <Spirituality>(); if (need != null) { need.Gain(); } } // --- ------ --- }; research.FailOn(() => jobDriver_Research.Project == null); research.FailOn(() => !jobDriver_Research.Project.CanBeResearchedAt(jobDriver_Research.ResearchBench, ignoreResearchBenchPowerStatus: false)); // -- new code -- research.FailOn(() => !Find.ResearchManager.currentProj.HasModExtension <ForbiddenResearchExtension>() && jobDriver_Research.ResearchBench.def.defName == "Cults_OccultResearchBench" ); // --- ------ --- research.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); research.WithEffect(EffecterDefOf.Research, TargetIndex.A); research.WithProgressBar(TargetIndex.A, () => jobDriver_Research.Project?.ProgressPercent ?? 0f); research.defaultCompleteMode = ToilCompleteMode.Delay; research.defaultDuration = 4000; research.activeSkill = (() => SkillDefOf.Intellectual); yield return(research); yield return(Toils_General.Wait(2)); }
protected override IEnumerable <Toil> MakeNewToils() { this.rotateToFace = altarIndex; this.FailOnDespawnedOrNull(TargetIndex.B); this.FailOn(() => CultKnowledge.selectedDeity == null); this.AddFinishAction(() => { /* * Log.Message("Clearing reservation"); * this.pawn.ClearAllReservations(); * //if(this.TargetA.Cell.GetEdifice(this.pawn.Map) == null) return; // ?? * if (this.pawn.Map.reservationManager.ReservedBy(this.TargetA.Cell.GetEdifice(this.pawn.Map), this.pawn)) * { * Log.Message("Clearing reservation"); * this.pawn.ClearAllReservations(); * } */ /* * if (this.TargetC.Cell.GetEdifice(this.pawn.Map) != null) * { * if (this.pawn.Map.reservationManager.ReservedBy(this.TargetC.Cell.GetEdifice(this.pawn.Map), this.pawn)) * this.pawn.ClearAllReservations(); // this.pawn.Map.reservationManager.Release(this.TargetC.Cell.GetEdifice(this.pawn.Map), pawn); * } */ }); Toil worship = new Toil(); worship.defaultCompleteMode = ToilCompleteMode.Delay; worship.WithProgressBarToilDelay(TargetIndex.A, false, -0.5f); worship.defaultDuration = 500; worship.initAction = delegate { }; worship.tickAction = delegate { pawn.GainComfortFromCellIfPossible(); Spirituality need = pawn.needs.TryGetNeed <Spirituality>(); CultKnowledge.GiveFavor(CultKnowledge.selectedDeity, 0.0001f); if (need != null) { need.Gain(); } }; worship.AddFinishAction(delegate { float chance = 0.1f; //CultKnowledge.selectedDeity.discoveryChance; if (Rand.Range(0.0f, 1.0f) < chance) { CultKnowledge.DiscoverRandomDeity(); } }); yield return(Toils_Reserve.Reserve(spotIndex, 1, -1)); yield return(Toils_Goto.GotoCell(spotIndex, PathEndMode.OnCell)); yield return(worship); }