public override string GetReport()
        {
            if (base.Map.gameConditionManager.ConditionIsActive(GameConditionDefOf.Eclipse))
            {
                return("Sunbathing");
            }
            if (base.Map.gameConditionManager.ConditionIsActive(GameConditionDefOf.Aurora))
            {
                return("Sunbathing");
            }
            float num = GenCelestial.CurCelestialSunGlow(base.Map);

            if (num < 0.1f)
            {
                return("Sunbathing");
            }
            if (num >= 0.65f)
            {
                return("Sunbathing");
            }
            if (GenLocalDate.DayPercent(this.pawn) < 0.5f)
            {
                return("Sunbathing");
            }
            return("Sunbathing");
        }
Esempio n. 2
0
    public override string GetReport()
    {
        if (Map.gameConditionManager.ConditionIsActive(GameConditionDefOf.Eclipse))
        {
            return("Brrr.OohEclipse".Translate());
        }

        if (Map.gameConditionManager.ConditionIsActive(GameConditionDefOf.Aurora))
        {
            return("Brrr.OohAurora".Translate());
        }

        var num = GenCelestial.CurCelestialSunGlow(Map);

        if (num < 0.1f)
        {
            return("Brrr.OohStarGazing".Translate());
        }

        if (num >= 0.65f)
        {
            return("Brrr.OohClouds".Translate());
        }

        if (GenLocalDate.DayPercent(pawn) < 0.5f)
        {
            return("Brrr.OohSunrise".Translate());
        }

        return("Brrr.OohSunset".Translate());
    }
Esempio n. 3
0
        public static void Postfix(ref Zone_Growing __instance, ref string __result)
        {
            var   plantDef = __instance.GetPlantDefToGrow();
            var   thePlant = plantDef.plant;
            int   totalYield = 0, maxYield = 0, num = 0, numGrowing = 0;
            float totalGrowthRemaining = 0f;


            foreach (Thing thing in __instance.AllContainedThings)
            {
                if (thing.def == plantDef && thing is Plant plant)
                {
                    ++num;
                    totalYield += plant.YieldNow();
                    if (plant.Growth < 0.95f && !plant.YIResting() && plant.GrowthRateFactor_Light > .001f)
                    {
                        ++numGrowing;
                        totalGrowthRemaining += plant.YIActualGrowthTime();
                    }
                }
            }

            maxYield = (int)thePlant.harvestYield;
            float efficiency = maxYield / thePlant.growDays;

            __result += "\n" + "YI.InspectYields".Translate(new object[] { totalYield.ToString(), (maxYield * num).ToString() });
            __result += "\n" + "YI.Efficiency".Translate(efficiency.ToString("0.##"));

            // If is resting period, we dont show the line.
            if (GenLocalDate.DayPercent(__instance.Map) < 0.25f || GenLocalDate.DayPercent(__instance.Map) > 0.8f)
            {
                __result += "\n" + "YI.GrowthRemaining".Translate((totalGrowthRemaining / numGrowing).ToString("0.##"));
            }
        }
Esempio n. 4
0
        public override Job TryGiveJob(Pawn pawn)
        {
            Need_Rest need = pawn.needs.rest;

            if (need == null || need.CurLevelPercentage > this.def.restRequirement)
            {
                return(null);
            }

            float dayP = GenLocalDate.DayPercent(pawn.Map);

            if (dayP < 0.42f && dayP > 0.7f)
            {
                return(null);
            }

            Building_Bed bed = RestUtility.FindBedFor(pawn);

            if (bed != null)
            {
                return(new Job(IdleJobDefOf.IdleJob_TakeNap, bed)
                {
                    locomotionUrgency = LocomotionUrgency.Walk
                });
            }

            return(null);
        }
Esempio n. 5
0
        public override void RechargeEnergyNeed(Pawn targetPawn)
        {
            bool isNight = GenLocalDate.DayPercent(targetPawn) < 0.2f || GenLocalDate.DayPercent(targetPawn) > 0.7f;

            if (isNight)
            {
                return;
            }

            if (targetPawn.InContainerEnclosed)
            {
                return;
            }

            if (!targetPawn.IsCaravanMember() && targetPawn.Position.Roofed(targetPawn.Map))
            {
                return;
            }

            Need_Energy energyNeed = targetPawn.needs.TryGetNeed <Need_Energy>();

            if (energyNeed != null)
            {
                energyNeed.CurLevel += EnergyProps.passiveEnergyGeneration;
            }
        }
 protected override bool Satisfied(Pawn pawn)
 {
     if (GenLocalDate.DayPercent(pawn) > 0.024 && GenLocalDate.DayPercent(pawn) < 0.048)
     {
         return(true);
     }
     return(false);
 }
Esempio n. 7
0
 // RimWorld.JobDriver_Skygaze
 public static void Vamp_QuitWatchingSunrisesAlreadyJeez(JobDriver_Skygaze __instance, ref string __result)
 {
     if (__instance.pawn is Pawn p && p.IsVampire())
     {
         if (GenLocalDate.DayPercent(p) < 0.5f)
         {
             __instance.EndJobWith(JobCondition.InterruptForced);
         }
     }
 }
Esempio n. 8
0
    private float AYGrowthPerTick(Plant plant)
    {
        if (plant.LifeStage != PlantLifeStage.Growing || GenLocalDate.DayPercent(plant) < 0.25f ||
            GenLocalDate.DayPercent(plant) > 0.8f)
        {
            return(0f);
        }

        return(1f / (60000f * plant.def.plant.growDays) * plant.GrowthRate * 500f);
    }
Esempio n. 9
0
        // Token: 0x06000013 RID: 19 RVA: 0x00002E14 File Offset: 0x00001014
        private float AYGrowthPerTick(Plant tree)
        {
            if (tree.LifeStage != PlantLifeStage.Growing || GenLocalDate.DayPercent(tree) < 0.25f ||
                GenLocalDate.DayPercent(tree) > 0.8f)
            {
                return(0f);
            }

            return(1f / (60000f * tree.def.plant.growDays) * tree.GrowthRate * 400f);
        }
Esempio n. 10
0
        public override float Multiplier()
        {
            float distanceFromMidday = Mathf.Abs(0.45f - GenLocalDate.DayPercent(pawn.Map));

            if (distanceFromMidday > 0.5f)
            {
                distanceFromMidday = 1.0f - distanceFromMidday;
            }
            float m = distanceFromMidday * 4 - 1f;

            return(m < 0 ? m * def.negativeMultiplier : m *def.positiveMultiplier);
        }
Esempio n. 11
0
        private void CheckDesignateFlick()
        {
            if (!enabled || !parent.Spawned)
            {
                return;
            }

            if (GenDate.DaysPassed > this.currDaysPassed)
            {
                hasFlickedOnToday   = false;
                hasFlickedOffToday  = false;
                this.currDaysPassed = GenDate.DaysPassed;
            }

            bool?wantsFlickOn = null;

            if (!hasFlickedOnToday && GenLocalDate.DayPercent(this.parent.Map) > this.Props.flickOnPercent)
            {
                wantsFlickOn      = true;
                hasFlickedOnToday = true;
            }
            if (!hasFlickedOffToday && GenLocalDate.DayPercent(this.parent.Map) > this.Props.flickOffPercent)
            {
                wantsFlickOn       = false;
                hasFlickedOffToday = true;
            }

            if (wantsFlickOn == null)
            {
                return;
            }


            var curState = flickableComp.SwitchIsOn;

            if (flickableComp.WantsFlick())
            {
                curState = !curState;
            }

            if (curState != wantsFlickOn)
            {
                var field = typeof(CompFlickable).GetField("wantSwitchOn", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField);
                field.SetValue(flickableComp, wantsFlickOn);
                FlickUtility.UpdateFlickDesignation(this.parent);
            }
        }
Esempio n. 12
0
        // Token: 0x06000087 RID: 135 RVA: 0x000056D0 File Offset: 0x000038D0
        public override void RechargeEnergyNeed(Pawn targetPawn)
        {
            bool flag  = GenLocalDate.DayPercent(targetPawn) < 0.2f || GenLocalDate.DayPercent(targetPawn) > 0.7f;
            bool flag2 = flag;

            if (!flag2)
            {
                bool inContainerEnclosed = targetPawn.InContainerEnclosed;
                if (!inContainerEnclosed)
                {
                    bool flag3 = !targetPawn.IsCaravanMember() && targetPawn.Position.Roofed(targetPawn.Map);
                    if (!flag3)
                    {
                        Need_Energy need_Energy = targetPawn.needs.TryGetNeed <Need_Energy>();
                        need_Energy.CurLevel += base.EnergyProps.passiveEnergyGeneration;
                    }
                }
            }
        }
Esempio n. 13
0
        public static void AppendPsychologyThoughts(TaleNewsPawnDied __instance, Pawn recipient)
        {
            var victim = __instance.Victim;

            // Psychology did a lot of work to exclude thoughts from Bleeding Heart.

            if (recipient.Faction == victim.Faction)
            {
                new IndividualThoughtToAdd(Psycho_ThoughtDefOf.WitnessedDeathAllyBleedingHeart, recipient).Add();
            }
            else if (victim.Faction == null || victim.Faction.HostileTo(recipient.Faction) ||
                     recipient.story.traits.HasTrait(Psycho_TraitDefOf.BleedingHeart))
            {
                new IndividualThoughtToAdd(Psycho_ThoughtDefOf.WitnessedDeathNonAllyBleedingHeart, recipient).Add();
            }

            var traitsDisallowDesensitization = recipient.story.traits.HasTrait(Psycho_TraitDefOf.BleedingHeart) ||
                                                recipient.story.traits.HasTrait(TraitDefOf.Psychopath) ||
                                                recipient.story.traits.HasTrait(TraitDefOf.Bloodlust) ||
                                                recipient.story.traits.HasTrait(Psycho_TraitDefOf.Desensitized);
            // ALL PRAISE GOD RANDY OUR ONE TRUE LORD
            var randyAllowsDesensitization = (recipient.GetHashCode() ^ ((GenLocalDate.DayOfYear(recipient) +
                                                                          GenLocalDate.Year(recipient) +
                                                                          ((int)(GenLocalDate.DayPercent(recipient) *
                                                                                 5f) * 60)) * 391)) % 1000 == 0;

            // No Bleeding Heart + No Psychopath + No Bloodlust + No Desensitised + Random Genner
            if (traitsDisallowDesensitization || !randyAllowsDesensitization)
            {
                return;
            }

            // Gain Desensitized
            recipient.story.traits.GainTrait(new Trait(Psycho_TraitDefOf.Desensitized));
            recipient.needs.mood.thoughts.memories.TryGainMemory(Psycho_ThoughtDefOf.RecentlyDesensitized);
        }
Esempio n. 14
0
        public static void AppendPsychologyThoughts(Pawn victim, DamageInfo?dinfo, PawnDiedOrDownedThoughtsKind thoughtsKind, ref List <IndividualThoughtToAdd> outIndividualThoughts, ref List <ThoughtDef> outAllColonistsThoughts)
        {
            bool flag  = dinfo.HasValue && dinfo.Value.Def.execution;
            bool flag2 = victim.IsPrisonerOfColony && !victim.guilt.IsGuilty && !victim.InAggroMentalState;
            bool flag3 = dinfo.HasValue && dinfo.Value.Def.ExternalViolenceFor(victim) && dinfo.Value.Instigator != null && dinfo.Value.Instigator is Pawn;

            if (flag3)
            {
                Pawn pawn = (Pawn)dinfo.Value.Instigator;
                if (!pawn.Dead && pawn.needs.mood != null && pawn.story != null && pawn != victim)
                {
                    if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Died && victim.HostileTo(pawn))
                    {
                        if (victim.Faction != null && victim.Faction.HostileTo(pawn.Faction) && !flag2)
                        {
                            outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.KilledHumanlikeEnemy, pawn, victim, 1f, 1f));
                        }
                    }
                }
            }
            if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Died && victim.Spawned)
            {
                List <Pawn> allPawnsSpawned = victim.Map.mapPawns.AllPawnsSpawned;
                for (int i = 0; i < allPawnsSpawned.Count; i++)
                {
                    Pawn pawn2 = allPawnsSpawned[i];
                    if (pawn2 != victim && pawn2.needs.mood != null)
                    {
                        if (!flag && (pawn2.MentalStateDef != MentalStateDefOf.SocialFighting || ((MentalState_SocialFighting)pawn2.MentalState).otherPawn != victim))
                        {
                            if (pawn2.Position.InHorDistOf(victim.Position, 12f) && GenSight.LineOfSight(victim.Position, pawn2.Position, victim.Map, false) && pawn2.Awake() && pawn2.health.capacities.CapableOf(PawnCapacityDefOf.Sight))
                            {
                                if (pawn2.Faction == victim.Faction)
                                {
                                    outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.WitnessedDeathAllyBleedingHeart, pawn2, null, 1f, 1f));
                                }
                                else if (victim.Faction == null || (!victim.Faction.HostileTo(pawn2.Faction) || pawn2.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart)))
                                {
                                    outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.WitnessedDeathNonAllyBleedingHeart, pawn2, null, 1f, 1f));
                                }
                                if (!pawn2.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart) && !pawn2.story.traits.HasTrait(TraitDefOf.Psychopath) && !pawn2.story.traits.HasTrait(TraitDefOf.Bloodlust) && !pawn2.story.traits.HasTrait(TraitDefOfPsychology.Desensitized))
                                {
                                    if (((pawn2.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn2) + GenLocalDate.Year(pawn2) + (int)(GenLocalDate.DayPercent(pawn2) * 5) * 60) * 391) % 1000) == 0)
                                    {
                                        pawn2.story.traits.GainTrait(new Trait(TraitDefOfPsychology.Desensitized));
                                        pawn2.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.RecentlyDesensitized, null);
                                    }
                                }
                            }
                            else if (victim.Faction == Faction.OfPlayer && victim.Faction == pawn2.Faction && victim.HostFaction != pawn2.Faction)
                            {
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.KnowColonistDiedBleedingHeart, pawn2, null, 1f, 1f));
                            }
                            if (flag2 && pawn2.Faction == Faction.OfPlayer && !pawn2.IsPrisoner)
                            {
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.KnowPrisonerDiedInnocentBleedingHeart, pawn2, null, 1f, 1f));
                            }
                        }
                    }
                }
            }
            if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Banished && victim.IsColonist)
            {
                outAllColonistsThoughts.Add(ThoughtDefOfPsychology.ColonistAbandonedBleedingHeart);
            }
            if (thoughtsKind == PawnDiedOrDownedThoughtsKind.BanishedToDie)
            {
                if (victim.IsColonist)
                {
                    outAllColonistsThoughts.Add(ThoughtDefOfPsychology.ColonistAbandonedToDieBleedingHeart);
                }
                else if (victim.IsPrisonerOfColony)
                {
                    outAllColonistsThoughts.Add(ThoughtDefOfPsychology.PrisonerAbandonedToDieBleedingHeart);
                }
            }
        }
Esempio n. 15
0
        public static void CancelJob(ref Job __result, Pawn pawn)
        {
            Pawn partner = LovePartnerRelationUtility.GetPartnerInMyBed(pawn);

            if (PsycheHelper.PsychologyEnabled(pawn) && PsycheHelper.PsychologyEnabled(partner) && PsychologyBase.ActivateKinsey())
            {
                float random  = Rand.ValueSeeded((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 2) * 60) * 391));
                float random2 = Rand.ValueSeeded((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(partner) + GenLocalDate.Year(partner) + (int)(GenLocalDate.DayPercent(partner) * 2) * 60) * 391));
                if (random > PsycheHelper.Comp(pawn).Sexuality.AdjustedSexDrive&& random2 > PsycheHelper.Comp(partner).Sexuality.AdjustedSexDrive)
                {
                    __result = null;
                }
            }
        }
Esempio n. 16
0
 public static bool YIIsRestingPeriod(this Thing thing) => GenLocalDate.DayPercent(thing) < 0.25f || GenLocalDate.DayPercent(thing) > 0.8f;
Esempio n. 17
0
 internal static bool DayTime(Map map)
 {
     return (GenLocalDate.DayPercent(map) >= 0.25f && GenLocalDate.DayPercent(map) <= 0.8f);
 }
Esempio n. 18
0
        public override void Tick()
        {
            base.Tick();
            switch ((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 5) * 60) * 391) % (50 * (13 - ((this.CurStageIndex + 1) * 2))))
            {
            case 0:
                panic          = true;
                this.Severity += 0.00000002f;
                if (pawn.Spawned && pawn.RaceProps.Humanlike)
                {
                    if (pawn.jobs.curJob.def != JobDefOf.FleeAndCower && !pawn.jobs.curDriver.asleep)
                    {
                        pawn.jobs.StartJob(new Job(JobDefOf.FleeAndCower, pawn.Position), JobCondition.InterruptForced, null, false, true, null);
                    }
                    else if (pawn.jobs.curDriver.asleep)
                    {
                        pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.DreamNightmare);
                    }
                }
                break;

            default:
                panic = false;
                break;
            }
        }
Esempio n. 19
0
        private static void _AppendThoughts_Humanlike(Pawn victim, DamageInfo?dinfo, Hediff hediff, PawnDiedOrDownedThoughtsKind thoughtsKind, List <IndividualThoughtToAdd> outIndividualThoughts, List <ThoughtDef> outAllColonistsThoughts)
        {
            var  IsExecution        = typeof(PawnDiedOrDownedThoughtsUtility).GetMethod("IsExecution", BindingFlags.Static | BindingFlags.NonPublic);
            var  IsInnocentPrisoner = typeof(PawnDiedOrDownedThoughtsUtility).GetMethod("IsInnocentPrisoner", BindingFlags.Static | BindingFlags.NonPublic);
            bool flag  = (bool)IsExecution.Invoke(null, new object[] { dinfo, hediff });
            bool flag2 = (bool)IsInnocentPrisoner.Invoke(null, new object[] { victim });
            bool flag3 = dinfo.HasValue && dinfo.Value.Def.externalViolence && dinfo.Value.Instigator != null && dinfo.Value.Instigator is Pawn;

            if (flag3)
            {
                Pawn pawn = (Pawn)dinfo.Value.Instigator;
                if (!pawn.Dead && pawn.needs.mood != null && pawn.story != null && pawn != victim)
                {
                    if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Died)
                    {
                        outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.KilledHumanlikeBloodlust, pawn, null, 1f, 1f));
                    }
                    if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Died && victim.HostileTo(pawn))
                    {
                        if (victim.Faction != null && PawnUtility.IsFactionLeader(victim) && victim.Faction.HostileTo(pawn.Faction))
                        {
                            outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.DefeatedHostileFactionLeader, pawn, victim, 1f, 1f));
                        }
                        else if (victim.Faction != null && victim.Faction.HostileTo(pawn.Faction) && !flag2)
                        {
                            outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.KilledHumanlikeEnemy, pawn, victim, 1f, 1f));
                        }
                        if (victim.kindDef.combatPower > 250f)
                        {
                            outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.DefeatedMajorEnemy, pawn, victim, 1f, 1f));
                        }
                    }
                }
            }
            if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Died && victim.Spawned)
            {
                List <Pawn> allPawnsSpawned = victim.Map.mapPawns.AllPawnsSpawned;
                for (int i = 0; i < allPawnsSpawned.Count; i++)
                {
                    Pawn pawn2 = allPawnsSpawned[i];
                    if (pawn2 != victim && pawn2.needs.mood != null)
                    {
                        if (!flag && (pawn2.MentalStateDef != MentalStateDefOf.SocialFighting || ((MentalState_SocialFighting)pawn2.MentalState).otherPawn != victim))
                        {
                            if (pawn2.Position.InHorDistOf(victim.Position, 12f) && GenSight.LineOfSight(victim.Position, pawn2.Position, victim.Map, false) && pawn2.Awake() && pawn2.health.capacities.CapableOf(PawnCapacityDefOf.Sight))
                            {
                                if (pawn2.Faction == victim.Faction)
                                {
                                    outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.WitnessedDeathAlly, pawn2, null, 1f, 1f));
                                    outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.WitnessedDeathAllyBleedingHeart, pawn2, null, 1f, 1f));
                                }
                                else if (victim.Faction == null || (!victim.Faction.HostileTo(pawn2.Faction) || pawn2.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart)))
                                {
                                    outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.WitnessedDeathNonAlly, pawn2, null, 1f, 1f));
                                    outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.WitnessedDeathNonAllyBleedingHeart, pawn2, null, 1f, 1f));
                                }
                                if (pawn2.relations.FamilyByBlood.Contains(victim))
                                {
                                    outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.WitnessedDeathFamily, pawn2, null, 1f, 1f));
                                }
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.WitnessedDeathBloodlust, pawn2, null, 1f, 1f));
                                if (!pawn2.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart) && !pawn2.story.traits.HasTrait(TraitDefOf.Psychopath) && !pawn2.story.traits.HasTrait(TraitDefOf.Bloodlust) && !pawn2.story.traits.HasTrait(TraitDefOfPsychology.Desensitized))
                                {
                                    if (((pawn2.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn2) + GenLocalDate.Year(pawn2) + (int)(GenLocalDate.DayPercent(pawn2) * 5) * 60) * 391) % 1000) == 0)
                                    {
                                        pawn2.story.traits.GainTrait(new Trait(TraitDefOfPsychology.Desensitized));
                                        pawn2.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOfPsychology.RecentlyDesensitized, null);
                                    }
                                }
                            }
                            else if (victim.Faction == Faction.OfPlayer && victim.Faction == pawn2.Faction && victim.HostFaction != pawn2.Faction)
                            {
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.KnowColonistDied, pawn2, null, 1f, 1f));
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.KnowColonistDiedBleedingHeart, pawn2, null, 1f, 1f));
                            }
                            if (flag2 && pawn2.Faction == Faction.OfPlayer && !pawn2.IsPrisoner)
                            {
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.KnowPrisonerDiedInnocent, pawn2, null, 1f, 1f));
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOfPsychology.KnowPrisonerDiedInnocentBleedingHeart, pawn2, null, 1f, 1f));
                            }
                        }
                    }
                }
            }
            if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Abandoned && victim.IsColonist)
            {
                outAllColonistsThoughts.Add(ThoughtDefOf.ColonistAbandoned);
                outAllColonistsThoughts.Add(ThoughtDefOfPsychology.ColonistAbandonedBleedingHeart);
            }
            if (thoughtsKind == PawnDiedOrDownedThoughtsKind.AbandonedToDie)
            {
                if (victim.IsColonist)
                {
                    outAllColonistsThoughts.Add(ThoughtDefOf.ColonistAbandonedToDie);
                    outAllColonistsThoughts.Add(ThoughtDefOfPsychology.ColonistAbandonedToDieBleedingHeart);
                }
                else if (victim.IsPrisonerOfColony)
                {
                    outAllColonistsThoughts.Add(ThoughtDefOf.PrisonerAbandonedToDie);
                    outAllColonistsThoughts.Add(ThoughtDefOfPsychology.PrisonerAbandonedToDieBleedingHeart);
                }
            }
        }
Esempio n. 20
0
        public static void Postfix(Plant __instance, ref string __result)
        {
            StringBuilder          stringBuilder      = new StringBuilder();
            CompHarvestableReagent harvestableReagent = __instance.GetComp <CompHarvestableReagent>();

            if (__instance.LifeStage == PlantLifeStage.Growing)
            {
                if (harvestableReagent != null && !harvestableReagent.IsSecondaryHarvest)
                {
                    stringBuilder.AppendLine("Reagent".Translate());
                }

                stringBuilder.AppendLine("PercentGrowth".Translate(new object[]
                {
                    (__instance.Growth + 0.0001f).ToStringPercent()
                }));
                stringBuilder.AppendLine("GrowthRate".Translate() + ": " + __instance.GrowthRate.ToStringPercent());
                if (!__instance.Blighted)
                {
                    if (GenLocalDate.DayPercent(__instance) < 0.25f || GenLocalDate.DayPercent(__instance) > 0.8f)
                    {
                        stringBuilder.AppendLine("PlantResting".Translate());
                    }
                    if (!(__instance.GrowthRateFactor_Light > 0.001f))
                    {
                        stringBuilder.AppendLine("PlantNeedsLightLevel".Translate() + ": " + __instance.def.plant.growMinGlow.ToStringPercent());
                    }
                    float growthRateFactor_Temperature = __instance.GrowthRateFactor_Temperature;
                    if (growthRateFactor_Temperature < 0.99f)
                    {
                        if (growthRateFactor_Temperature < 0.01f)
                        {
                            stringBuilder.AppendLine("OutOfIdealTemperatureRangeNotGrowing".Translate());
                        }
                        else
                        {
                            stringBuilder.AppendLine("OutOfIdealTemperatureRange".Translate(new object[]
                            {
                                Mathf.RoundToInt(growthRateFactor_Temperature * 100f).ToString()
                            }));
                        }
                    }
                }
            }
            else if (__instance.LifeStage == PlantLifeStage.Mature)
            {
                if (__instance.HarvestableNow)
                {
                    stringBuilder.AppendLine("ReadyToHarvest".Translate());
                }
                else
                {
                    stringBuilder.AppendLine("Mature".Translate());
                }
            }
            if (__instance.DyingBecauseExposedToLight)
            {
                stringBuilder.AppendLine("DyingBecauseExposedToLight".Translate());
            }
            if (__instance.Blighted)
            {
                stringBuilder.AppendLine("Blighted".Translate() + " (" + __instance.Blight.Severity.ToStringPercent() + ")");
            }

            if (harvestableReagent != null && harvestableReagent.IsSecondaryHarvest)
            {
                ComposeReagentString(ref stringBuilder, harvestableReagent);
            }

            __result = stringBuilder.ToString().TrimEndNewlines();
        }
Esempio n. 21
0
        public static bool Prefix(
            Rect dateRect,
            ref List <string> ___seasonsCached,
            ref int ___dateStringDay,
            ref Season ___dateStringSeason,
            ref Quadrum ___dateStringQuadrum,
            ref int ___dateStringYear,
            ref string ___dateString
            )
        {
            Vector2 vector2;

            if (WorldRendererUtility.WorldRenderedNow && Find.WorldSelector.selectedTile >= 0)
            {
                vector2 = Find.WorldGrid.LongLatOf(Find.WorldSelector.selectedTile);
            }
            else if (WorldRendererUtility.WorldRenderedNow && Find.WorldSelector.NumSelectedObjects > 0)
            {
                vector2 = Find.WorldGrid.LongLatOf(Find.WorldSelector.FirstSelectedObject.Tile);
            }
            else
            {
                if (Find.CurrentMap == null)
                {
                    return(false);
                }
                vector2 = Find.WorldGrid.LongLatOf(Find.CurrentMap.Tile);
            }

            var num1     = GenDate.DayOfTwelfth(Find.TickManager.TicksAbs, vector2.x);
            var season   = GenDate.Season(Find.TickManager.TicksAbs, vector2);
            var quadrum1 = GenDate.Quadrum(Find.TickManager.TicksAbs, vector2.x);
            var num2     = GenDate.Year(Find.TickManager.TicksAbs, vector2.x);
            var str      = true ? ___seasonsCached[(int)season] : "";

            if (num1 != ___dateStringDay || season != ___dateStringSeason || quadrum1 != ___dateStringQuadrum || num2 != ___dateStringYear)
            {
                ___dateString        = GenDate.DateReadoutStringAt(Find.TickManager.TicksAbs, vector2);
                ___dateStringDay     = num1;
                ___dateStringSeason  = season;
                ___dateStringQuadrum = quadrum1;
                ___dateStringYear    = num2;
            }

            var userTime = "";

            if (!BetterTimeFormatMod.UpdateTime)
            {
                userTime = BetterTimeFormatMod.settings.timeFormat;
                var dayPercent = GenLocalDate.DayPercent(Find.CurrentMap);

                if (BetterTimeFormatMod.UpdateHours)
                {
                    var hours = Math.Floor(dayPercent * 24);
                    if (BetterTimeFormatMod.settings.twelveHourFormat)
                    {
                        hours = dayPercent < 0.6 ? hours : hours - 12;
                    }

                    userTime = userTime.ReplaceFirst("HH", $"{hours,0:00}");
                    userTime = userTime.ReplaceFirst("H", $"{hours,0}");
                }

                if (BetterTimeFormatMod.UpdateMinutes)
                {
                    var minutes = Math.Floor(dayPercent * 24 % 1 * 60);
                    userTime = userTime.ReplaceFirst("MM", $"{minutes,0:00}");
                    userTime = userTime.ReplaceFirst("M", $"{minutes,0:0}");
                }

                if (BetterTimeFormatMod.UpdateSeconds)
                {
                    var seconds = Math.Floor(dayPercent * 24 % 1 * 60 % 1 * 60);
                    userTime = userTime.ReplaceFirst("SS", $"{seconds,0:00}");
                    userTime = userTime.ReplaceFirst("S", $"{seconds,0:0}");
                }

                if (BetterTimeFormatMod.settings.twelveHourFormat)
                {
                    var notation = dayPercent < 0.5 ? BetterTimeFormatMod.settings.amString : BetterTimeFormatMod.settings.pmString;
                    userTime = userTime.ReplaceFirst("N", notation);
                }
            }

            Text.Font = GameFont.Small;
            var num3 =
                Mathf.Max(Mathf.Max(Text.CalcSize(userTime).x, Text.CalcSize(___dateString).x), Text.CalcSize(str).x) + 7f;

            dateRect.xMin = dateRect.xMax - num3;
            if (Mouse.IsOver(dateRect))
            {
                Widgets.DrawHighlight(dateRect);
            }
            GUI.BeginGroup(dateRect);
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperRight;
            var rect = dateRect.AtZero();

            rect.xMax -= 7f;
            Widgets.Label(rect, userTime);
            rect.yMin += 26f;
            Widgets.Label(rect, ___dateString);
            rect.yMin += 26f;
            if (!str.NullOrEmpty())
            {
                Widgets.Label(rect, str);
            }
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.EndGroup();
            if (!Mouse.IsOver(dateRect))
            {
                return(false);
            }
            var stringBuilder = new StringBuilder();

            for (var index2 = 0; index2 < 4; ++index2)
            {
                var quadrum2 = (Quadrum)index2;
                stringBuilder.AppendLine(quadrum2.Label() + " - " + quadrum2.GetSeason(vector2.y).LabelCap());
            }

            var taggedString = "DateReadoutTip".Translate(GenDate.DaysPassed, 15, (NamedArgument)season.LabelCap(), 15,
                                                          (NamedArgument)GenDate.Quadrum(GenTicks.TicksAbs, vector2.x).Label(), (NamedArgument)stringBuilder.ToString());

            TooltipHandler.TipRegion(dateRect, new TipSignal(taggedString, 86423));

            return(false);
        }
        internal static void _ObserveSurroundingThings(this PawnObserver _this)
        {
            Pawn pawn = _this.GetPawn();

            if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Sight))
            {
                return;
            }
            Room room = RoomQuery.RoomAt(pawn);
            int  num  = 0;

            while ((float)num < 100f)
            {
                IntVec3 c = pawn.Position + GenRadial.RadialPattern[num];
                if (c.InBounds(pawn.Map))
                {
                    if (RoomQuery.RoomAt(c, pawn.Map) == room)
                    {
                        List <Thing> thingList = c.GetThingList(pawn.Map);
                        for (int i = 0; i < thingList.Count; i++)
                        {
                            IThoughtGiver thoughtGiver = thingList[i] as IThoughtGiver;
                            if (thoughtGiver != null)
                            {
                                Thought_Memory thought_Memory = thoughtGiver.GiveObservedThought();
                                if (thought_Memory != null)
                                {
                                    if (thought_Memory.def == ThoughtDefOf.ObservedLayingCorpse)
                                    {
                                        if (!pawn.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart) && !pawn.story.traits.HasTrait(TraitDefOf.Psychopath) && !pawn.story.traits.HasTrait(TraitDefOf.Bloodlust) && !pawn.story.traits.HasTrait(TraitDefOfPsychology.Desensitized))
                                        {
                                            if (((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 5) * 60) * 391) % 1000) == 0)
                                            {
                                                pawn.story.traits.GainTrait(new Trait(TraitDefOfPsychology.Desensitized));
                                                pawn.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOfPsychology.RecentlyDesensitized, null);
                                            }
                                        }
                                    }
                                    pawn.needs.mood.thoughts.memories.TryGainMemoryThought(thought_Memory, null);
                                }
                            }
                        }
                    }
                }
                num++;
            }
        }
Esempio n. 23
0
        public static void CancelJob(ref Job __result, Pawn pawn)
        {
            Pawn           partnerInMyBed = LovePartnerRelationUtility.GetPartnerInMyBed(pawn);
            PsychologyPawn realPawn       = pawn as PsychologyPawn;
            PsychologyPawn realPartner    = partnerInMyBed as PsychologyPawn;

            if (realPawn != null && realPartner != null && PsychologyBase.ActivateKinsey() && realPawn.sexuality != null && realPartner.sexuality != null)
            {
                float random = Rand.ValueSeeded((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 2) * 60) * 391));
                if (random > realPawn.sexuality.AdjustedSexDrive && random > realPartner.sexuality.AdjustedSexDrive)
                {
                    __result = null;
                }
            }
        }
        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            switch ((p.GetHashCode() ^ (GenLocalDate.DayOfYear(p) + GenLocalDate.Year(p) + (int)(GenMath.RoundTo(GenLocalDate.DayPercent(p), 0.25f) * 10) * 60) * 391) % 12)
            {
            case 0:
                return((p.story.traits.DegreeOfTrait(SyrTraitDefOf.Neurotic) == 2) ? ThoughtState.ActiveAtStage(0) : ThoughtState.Inactive);

            case 1:
                return(ThoughtState.ActiveAtStage(1));

            case 2:
                return(ThoughtState.ActiveAtStage(1));

            case 3:
                return(ThoughtState.ActiveAtStage(2));

            case 4:
                return(ThoughtState.ActiveAtStage(2));

            case 5:
                return(ThoughtState.Inactive);

            case 6:
                return(ThoughtState.Inactive);

            case 7:
                return(ThoughtState.ActiveAtStage(3));

            case 8:
                return(ThoughtState.ActiveAtStage(3));

            case 9:
                return(ThoughtState.ActiveAtStage(4));

            case 10:
                return(ThoughtState.ActiveAtStage(4));

            case 11:
                return((p.story.traits.DegreeOfTrait(SyrTraitDefOf.Neurotic) == 2) ? ThoughtState.ActiveAtStage(5) : ThoughtState.Inactive);

            default:
                throw new NotImplementedException();
            }
        }
Esempio n. 25
0
        /// Create a report on sanity loss.
        /// Shows a letter to the player that displays along these lines.
        ///
        /// SANITY LOSS REPORT
        /// Sanity Loss
        ///
        /// Some colonists have experienced a fevered nightmare.
        /// In it they saw visions of a blackened creature whose monstrous forehead
        /// shone in moonlight and whose vile hooves surely pawed hellish oozes miles
        /// below the surface with eyes hidden, leering, and waiting.
        ///
        /// Afflicted colonists.
        /// (+7% difficulty modifier)
        /// - Dave experienced +30% sanity loss.
        /// - Jerry experienced +25% sanity loss.
        /// - Steely Dan resisted with iron will.
        public static void ApplySanityLossAndShowReport(List <Pawn> pawns, FloatRange lossRange,
                                                        float difficultyModifier, string dreamOverride = "")
        {
            if (!pawns.NullOrEmpty())
            {
                var target = new GlobalTargetInfo();
                var s      = new StringBuilder();
                var map    = pawns[0]?.MapHeld;
                if (map != null)
                {
                    ///
                    /// Prefix
                    ///
                    string dream = GenLocalDate.DayPercent(map) < 0.2f || GenLocalDate.DayPercent(map) > 0.7f
                        ? "HPLovecraft_Daydream".Translate()
                        : "HPLovecraft_Nightmare".Translate();
                    if (dreamOverride != "")
                    {
                        dream = dreamOverride.Translate();
                    }

                    if ((pawns?.Count ?? 0) > 1)
                    {
                        s.AppendLine("HPLovecraft_SanityLossPrefixPlural".Translate(dream));
                    }
                    else if ((pawns?.Count ?? 0) == 1)
                    {
                        s.AppendLine(
                            "HPLovecraft_SanityLossPrefix".Translate(new object[] { pawns[0].LabelShort, dream }));
                    }
                    else
                    {
                        Log.Message("Can't choose sanity loss prefix. This should never happen.");
                    }

                    ///
                    /// Flavor Text
                    ///
                    var flavorKey = "HPLovecraft_SanityLossFlavorText" + new IntRange(1, 13).RandomInRange;
                    s.AppendLine(flavorKey.Translate());

                    /// Seperator
                    s.AppendLine();

                    ///
                    /// Inidividual Reports
                    ///
                    s.AppendLine("HPLovecraft_AfflictedColonists".Translate());
                    s.AppendLine(
                        "HPLovecraft_DifficultyModifier".Translate((int)(difficultyModifier * 100))
                        .ToString());     //0.07 => 7
                    foreach (var p in pawns)
                    {
                        if (!target.HasThing)
                        {
                            target = new GlobalTargetInfo(p);
                        }

                        if (p?.story?.traits?.GetTrait(TraitDefOf.Nerves) is Trait t && t.Degree == 2)
                        {
                            s.AppendLine("  -" + "HPLovecraft_SanityLossResistedWithIronWill".Translate(p.LabelShort));
                        }
                        else
                        {
                            var sanityLossToApply = lossRange.RandomInRange + difficultyModifier;
                            s.AppendLine("  -" + "HPLovecraft_ExperiencedSanityLoss".Translate(new object[]
                                                                                               { p.LabelShort, (int)(sanityLossToApply * 100) }));
                            Utility.ApplySanityLoss(p, sanityLossToApply);
                        }
                    }
                }
Esempio n. 26
0
 public static Thought_Memory AddDesensitizedChance(Thought_Memory thought_Memory, Pawn pawn)
 {
     if (thought_Memory != null && thought_Memory.def == ThoughtDefOf.ObservedLayingCorpse)
     {
         if (!pawn.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart) && !pawn.story.traits.HasTrait(TraitDefOf.Psychopath) && !pawn.story.traits.HasTrait(TraitDefOf.Bloodlust) && !pawn.story.traits.HasTrait(TraitDefOfPsychology.Desensitized))
         {
             if (((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 5) * 60) * 391) % 1000) == 0)
             {
                 pawn.story.traits.GainTrait(new Trait(TraitDefOfPsychology.Desensitized));
                 pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.RecentlyDesensitized);
             }
         }
     }
     return(thought_Memory);
 }
Esempio n. 27
0
        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            switch ((p.GetHashCode() ^ (GenLocalDate.DayOfYear(p) + GenLocalDate.Year(p) + (int)(GenLocalDate.DayPercent(p) * 10) * 60) * 391) % 12)
            {
            case 0:
                return(ThoughtState.ActiveAtStage(0));

            case 1:
                return(ThoughtState.ActiveAtStage(1));

            case 2:
                return(ThoughtState.ActiveAtStage(1));

            case 3:
                return(ThoughtState.ActiveAtStage(2));

            case 4:
                return(ThoughtState.ActiveAtStage(2));

            case 5:
                return(ThoughtState.Inactive);

            case 6:
                return(ThoughtState.Inactive);

            case 7:
                return(ThoughtState.ActiveAtStage(3));

            case 8:
                return(ThoughtState.ActiveAtStage(3));

            case 9:
                return(ThoughtState.ActiveAtStage(4));

            case 10:
                return(ThoughtState.ActiveAtStage(4));

            case 11:
                return(ThoughtState.ActiveAtStage(5));

            default:
                throw new NotImplementedException();
            }
        }
Esempio n. 28
0
        private void DoTimeBar(Rect rect)
        {
            // set up rects
            Rect bar     = TimeBarRect;
            Rect buttons = new Rect(rect.xMin, bar.yMin + bar.height / 3f, bar.xMin - rect.xMin, bar.height * 2 / 3f);
            Rect button  = new Rect(buttons.xMax - buttons.height * 2f, buttons.yMin, buttons.height, buttons.height);

            // split the available area into rects. bottom 2/3's are used for 'buttons', with text for times.
            float hourWidth         = bar.width / GenDate.HoursPerDay;
            float barheight         = bar.height * 2 / 3f;
            float timeIndicatorSize = bar.height * 2 / 3f;
            float lastLabelPosition = 0f;
            Rect  hourRect          = new Rect(bar.xMin, bar.yMax - barheight, hourWidth, barheight);

            // draw buttons
            TooltipHandler.TipRegion(button, "WorkTab.SelectWholeDayTip".Translate());
            if (Widgets.ButtonImage(button, PrioritiesWholeDay, Color.white, GenUI.MouseoverColor))
            {
                SelectWholeDay();
            }
            button.x -= button.height + Constants.Margin;
            TooltipHandler.TipRegion(button, "WorkTab.SelectCurrentHourTip".Translate());
            if (Widgets.ButtonImage(button, Now, Color.white, GenUI.MouseoverColor))
            {
                AddSelectedHour(GenLocalDate.HourOfDay(Find.VisibleMap), true);
            }

            // draw first tick
            GUI.color = Color.grey;
            Widgets.DrawLineVertical(hourRect.xMin, hourRect.yMin + hourRect.height * 1 / 2f, hourRect.height * 1 / 2f);

            // draw horizontal line ( y - 1 because canvas gets clipped on bottom )
            Widgets.DrawLineHorizontal(bar.xMin, bar.yMax - 1, bar.width);
            GUI.color = Color.white;

            // label and rect
            string label;
            Rect   labelRect;

            for (int hour = 0; hour < GenDate.HoursPerDay; hour++)
            {
                bool selected = SelectedHours.Contains(hour);
                bool focused  = hour == VisibleHour;

                // print major tick
                GUI.color = Color.grey;
                Widgets.DrawLineVertical(hourRect.xMax, hourRect.yMin + hourRect.height * 1 / 2f, hourRect.height * 1 / 2f);

                // print minor ticks
                Widgets.DrawLineVertical(hourRect.xMin + hourRect.width * 1 / 4f, hourRect.yMin + hourRect.height * 3 / 4f, hourRect.height * 1 / 4f);
                Widgets.DrawLineVertical(hourRect.xMin + hourRect.width * 2 / 4f, hourRect.yMin + hourRect.height * 3 / 4f, hourRect.height * 1 / 4f);
                Widgets.DrawLineVertical(hourRect.xMin + hourRect.width * 3 / 4f, hourRect.yMin + hourRect.height * 3 / 4f, hourRect.height * 1 / 4f);
                GUI.color = Color.white;

                // create and draw labelrect - but only if the last label isn't too close
                if (hourRect.xMin - lastLabelPosition > MinTimeBarLabelSpacing)
                {
                    label       = hour.FormatHour();
                    labelRect   = new Rect(0f, bar.yMin + bar.height * 1 / 3f, label.NoWrapWidth(), bar.height * 2 / 3f);
                    labelRect.x = hourRect.xMin - labelRect.width / 2f;
                    UIUtilities.Label(labelRect, label, Color.grey, GameFont.Tiny, TextAnchor.UpperCenter);

                    lastLabelPosition = labelRect.xMax;
                }

                // draw hour rect with mouseover + interactions
                Widgets.DrawHighlightIfMouseover(hourRect);

                // set/remove focus (LMB and any other MB respectively)
                if (Mouse.IsOver(hourRect))
                {
                    if (Input.GetMouseButton(0))
                    {
                        AddSelectedHour(hour, Event.current.shift);
                    }

                    if (Input.GetMouseButton(1))
                    {
                        RemoveSelectedHour(hour);
                    }

                    // handle tooltip
                    var selectedString = selected
                                                      ? "WorkTab.Selected".Translate()
                                                      : "WorkTab.NotSelected".Translate();
                    var interactionString = "";
                    if (selected)
                    {
                        interactionString += "WorkTab.RightClickToDeselect".Translate();
                        if (focused)
                        {
                            interactionString += "\n" + "WorkTab.ClickToFocus".Translate();
                        }
                    }
                    else
                    {
                        interactionString += "WorkTab.ClickToSelect".Translate();
                    }

                    TooltipHandler.TipRegion(hourRect,
                                             "WorkTab.SchedulerHourTip".Translate(hour.FormatHour(),
                                                                                  (hour + 1 % GenDate.HoursPerDay).FormatHour(),
                                                                                  selectedString,
                                                                                  interactionString));
                }

                // if this is currently the 'main' timeslot, and not the actual time, draw an eye
                if (focused && hour != GenLocalDate.HourOfDay(Find.VisibleMap))
                {
                    Rect eyeRect = new Rect(hourRect.center.x - timeIndicatorSize * 1 / 2f, hourRect.yMax - timeIndicatorSize - hourRect.height * 1 / 6f, timeIndicatorSize, timeIndicatorSize);
                    GUI.DrawTexture(eyeRect, PinEye);
                }

                // also highlight all selected timeslots
                if (selected)
                {
                    Widgets.DrawHighlightSelected(hourRect);
                }

                // advance rect
                hourRect.x += hourRect.width;
            }

            // draw final label
            label       = 0.FormatHour();
            labelRect   = new Rect(0f, bar.yMin + bar.height * 1 / 3f, label.NoWrapWidth(), bar.height * 2 / 3f);
            labelRect.x = hourRect.xMin - labelRect.width / 2f;
            UIUtilities.Label(labelRect, label, Color.grey, GameFont.Tiny, TextAnchor.UpperCenter);

            // draw current time indicator
            float curTimeX    = GenLocalDate.DayPercent(Find.VisibleMap) * bar.width;
            Rect  curTimeRect = new Rect(bar.xMin + curTimeX - timeIndicatorSize * 1 / 2f, hourRect.yMax - timeIndicatorSize - hourRect.height * 1 / 6f, timeIndicatorSize, timeIndicatorSize);

            GUI.DrawTexture(curTimeRect, PinClock);
        }
Esempio n. 29
0
        public static void DesensitizeViaCorpse(PawnObserver __instance)
        {
            Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Sight))
            {
                return;
            }
            RoomGroup roomGroup = pawn.GetRoomGroup();
            Map       map       = pawn.Map;
            int       num       = 0;

            while ((float)num < 100f)
            {
                IntVec3 intVec = pawn.Position + GenRadial.RadialPattern[num];
                if (intVec.InBounds(map))
                {
                    if (intVec.GetRoomGroup(map) == roomGroup)
                    {
                        if (GenSight.LineOfSight(intVec, pawn.Position, map, true, null, 0, 0))
                        {
                            List <Thing> thingList = intVec.GetThingList(map);
                            for (int i = 0; i < thingList.Count; i++)
                            {
                                IThoughtGiver thoughtGiver = thingList[i] as IThoughtGiver;
                                if (thoughtGiver != null)
                                {
                                    Thought_Memory thought_Memory = thoughtGiver.GiveObservedThought();
                                    if (thought_Memory != null && thought_Memory.def == ThoughtDefOf.ObservedLayingCorpse)
                                    {
                                        if (!pawn.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart) && !pawn.story.traits.HasTrait(TraitDefOf.Psychopath) && !pawn.story.traits.HasTrait(TraitDefOf.Bloodlust) && !pawn.story.traits.HasTrait(TraitDefOfPsychology.Desensitized))
                                        {
                                            if (((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 5) * 60) * 391) % 1000) == 0)
                                            {
                                                pawn.story.traits.GainTrait(new Trait(TraitDefOfPsychology.Desensitized));
                                                pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.RecentlyDesensitized, null);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                num++;
            }
        }