Exemplo n.º 1
0
 private bool <Tick> m__0(MentalBreakDef x)
 {
     return(x.Worker.BreakCanOccur(this.pawn));
 }
Exemplo n.º 2
0
 private float <Tick> m__1(MentalBreakDef x)
 {
     return(x.Worker.CommonalityFor(this.pawn));
 }
Exemplo n.º 3
0
        public virtual void Tick()
        {
            this.ageTicks++;
            if (this.def.hediffGivers != null && this.pawn.IsHashIntervalTick(60))
            {
                for (int i = 0; i < this.def.hediffGivers.Count; i++)
                {
                    this.def.hediffGivers[i].OnIntervalPassed(this.pawn, this);
                }
            }
            if (this.Visible && !this.visible)
            {
                this.visible = true;
                if (this.def.taleOnVisible != null)
                {
                    TaleRecorder.RecordTale(this.def.taleOnVisible, this.pawn, this.def);
                }
            }
            HediffStage curStage = this.CurStage;

            if (curStage != null)
            {
                if (curStage.hediffGivers != null && this.pawn.IsHashIntervalTick(60))
                {
                    for (int j = 0; j < curStage.hediffGivers.Count; j++)
                    {
                        curStage.hediffGivers[j].OnIntervalPassed(this.pawn, this);
                    }
                }
                if (curStage.mentalStateGivers != null && this.pawn.IsHashIntervalTick(60) && !this.pawn.InMentalState)
                {
                    for (int k = 0; k < curStage.mentalStateGivers.Count; k++)
                    {
                        MentalStateGiver mentalStateGiver = curStage.mentalStateGivers[k];
                        if (Rand.MTBEventOccurs(mentalStateGiver.mtbDays, 60000f, 60f))
                        {
                            this.pawn.mindState.mentalStateHandler.TryStartMentalState(mentalStateGiver.mentalState, null, false, false, null);
                        }
                    }
                }
                MentalBreakDef mentalBreakDef = default(MentalBreakDef);
                if (curStage.mentalBreakMtbDays > 0.0 && this.pawn.IsHashIntervalTick(60) && !this.pawn.InMentalState && Rand.MTBEventOccurs(curStage.mentalBreakMtbDays, 60000f, 60f) && (from x in DefDatabase <MentalBreakDef> .AllDefsListForReading
                                                                                                                                                                                           where x.Worker.BreakCanOccur(this.pawn)
                                                                                                                                                                                           select x).TryRandomElementByWeight <MentalBreakDef>((Func <MentalBreakDef, float>)((MentalBreakDef x) => x.Worker.CommonalityFor(this.pawn)), out mentalBreakDef))
                {
                    mentalBreakDef.Worker.TryStart(this.pawn, null, false);
                }
                if (curStage.vomitMtbDays > 0.0 && this.pawn.IsHashIntervalTick(600) && Rand.MTBEventOccurs(curStage.vomitMtbDays, 60000f, 600f) && this.pawn.Spawned && this.pawn.Awake())
                {
                    this.pawn.jobs.StartJob(new Job(JobDefOf.Vomit), JobCondition.InterruptForced, null, true, true, null, null, false);
                }
                Thought_Memory th = default(Thought_Memory);
                if (curStage.forgetMemoryThoughtMtbDays > 0.0 && this.pawn.needs.mood != null && this.pawn.IsHashIntervalTick(400) && Rand.MTBEventOccurs(curStage.forgetMemoryThoughtMtbDays, 60000f, 400f) && ((IEnumerable <Thought_Memory>) this.pawn.needs.mood.thoughts.memories.Memories).TryRandomElement <Thought_Memory>(out th))
                {
                    this.pawn.needs.mood.thoughts.memories.RemoveMemory(th);
                }
                if (!this.recordedTale && curStage.tale != null)
                {
                    TaleRecorder.RecordTale(curStage.tale, this.pawn);
                    this.recordedTale = true;
                }
                if (curStage.destroyPart && this.Part != null && this.Part != this.pawn.RaceProps.body.corePart)
                {
                    this.pawn.health.AddHediff(HediffDefOf.MissingBodyPart, this.Part, null);
                }
                if (curStage.deathMtbDays > 0.0 && this.pawn.IsHashIntervalTick(200) && Rand.MTBEventOccurs(curStage.deathMtbDays, 60000f, 200f))
                {
                    bool    flag    = PawnUtility.ShouldSendNotificationAbout(this.pawn);
                    Caravan caravan = this.pawn.GetCaravan();
                    this.pawn.Kill(null, null);
                    if (flag)
                    {
                        this.pawn.health.NotifyPlayerOfKilled(null, this, caravan);
                    }
                }
            }
        }