Beispiel #1
0
        private void DrawButtons()
        {
            Rect rect;

            rect = new Rect(17f, 25f, 120f, 25f);
            if (Widgets.ButtonText(rect, "Discover", true, false, true))
            {
                CultKnowledge.DiscoverRandomDeity();
            }

            rect = new Rect(17f, 50f, 120f, 25f);
            if (Widgets.ButtonText(rect, "Research test", true, false, true))
            {
                Find.ResearchManager.ResearchPerformed(100f / 0.00825f, null);
                //CultKnowledge.ExposeToHorror();
                //Find.ResearchManager.FinishProject(CultsDefOf.Cults_ForbiddenSculptures, true, null);
            }

            rect = new Rect(17f, 75f, 120f, 25f);
            if (Widgets.ButtonText(rect, " Cast spell ", true, false, true))
            {
                SpellDef def = DefDatabase <SpellDef> .GetNamed(CultKnowledge.selectedDeity.spells[1].defName);

                def.CastSpell();
            }
        }
Beispiel #2
0
        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);
        }
 // on research finish
 private static void Prefix(ref ResearchProjectDef proj) // on research finish "event"
 {
     CultKnowledge.DiscoverRandomDeity();
 }