private static void FillWindow(Rect windowRect)
        {
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.InspectRoomStats, KnowledgeAmount.FrameDisplayed);
            Text.Font = GameFont.Small;
            float curY = 12f;
            int   dividingLinesSeen = 0;

            if (ShouldShowBeauty())
            {
                DrawDividingLineIfNecessary();
                float beauty = BeautyUtility.AverageBeautyPerceptible(UI.MouseCell(), Find.CurrentMap);
                Rect  rect   = new Rect(22f, curY, windowRect.width - 24f - 10f, 100f);
                GUI.color = BeautyDrawer.BeautyColor(beauty, 40f);
                Widgets.Label(rect, "BeautyHere".Translate() + ": " + beauty.ToString("F1"));
                curY += 25f;
            }
            if (ShouldShowRoomStats())
            {
                DrawDividingLineIfNecessary();
                DoRoomInfo(UI.MouseCell().GetRoom(Find.CurrentMap, RegionType.Set_All), ref curY, windowRect);
            }
            GUI.color = Color.white;
            void DrawDividingLineIfNecessary()
            {
                dividingLinesSeen++;
                if (dividingLinesSeen > 1)
                {
                    curY     += 5f;
                    GUI.color = new Color(1f, 1f, 1f, 0.4f);
                    Widgets.DrawLineHorizontal(12f, curY, windowRect.width - 24f);
                    GUI.color = Color.white;
                    curY     += 8f;
                }
            }
        }
예제 #2
0
        private static void FillWindow(Rect windowRect)
        {
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.InspectRoomStats, KnowledgeAmount.FrameDisplayed);
            Text.Font = GameFont.Small;
            float num  = 18f;
            bool  flag = ShouldShowBeauty();

            if (flag)
            {
                float beauty = BeautyUtility.AverageBeautyPerceptible(UI.MouseCell(), Find.CurrentMap);
                Rect  rect   = new Rect(18f, num, windowRect.width - 36f, 100f);
                GUI.color = BeautyDrawer.BeautyColor(beauty, 40f);
                Widgets.Label(rect, "BeautyHere".Translate() + ": " + beauty.ToString("F1"));
                num += 25f;
            }
            if (ShouldShowRoomStats())
            {
                if (flag)
                {
                    num      += 5f;
                    GUI.color = new Color(1f, 1f, 1f, 0.4f);
                    Widgets.DrawLineHorizontal(18f, num, windowRect.width - 36f);
                    GUI.color = Color.white;
                    num      += 8f;
                }
                Room room  = UI.MouseCell().GetRoom(Find.CurrentMap, RegionType.Set_All);
                Rect rect2 = new Rect(18f, num, windowRect.width - 36f, 100f);
                GUI.color = Color.white;
                Widgets.Label(rect2, GetRoomRoleLabel(room));
                num          += 25f;
                Text.WordWrap = false;
                for (int i = 0; i < DefDatabase <RoomStatDef> .AllDefsListForReading.Count; i++)
                {
                    RoomStatDef roomStatDef = DefDatabase <RoomStatDef> .AllDefsListForReading[i];
                    if (!roomStatDef.isHidden || DebugViewSettings.showAllRoomStats)
                    {
                        float stat = room.GetStat(roomStatDef);
                        RoomStatScoreStage scoreStage = roomStatDef.GetScoreStage(stat);
                        if (room.Role.IsStatRelated(roomStatDef))
                        {
                            GUI.color = RelatedStatColor;
                        }
                        else
                        {
                            GUI.color = Color.gray;
                        }
                        Rect rect3 = new Rect(rect2.x, num, 100f, 23f);
                        Widgets.Label(rect3, roomStatDef.LabelCap);
                        Rect   rect4 = new Rect(rect3.xMax + 35f, num, 50f, 23f);
                        string label = roomStatDef.ScoreToString(stat);
                        Widgets.Label(rect4, label);
                        Rect rect5 = new Rect(rect4.xMax + 35f, num, 160f, 23f);
                        Widgets.Label(rect5, (scoreStage != null) ? scoreStage.label : string.Empty);
                        num += 25f;
                    }
                }
                Text.WordWrap = true;
            }
            GUI.color = Color.white;
        }
예제 #3
0
        public static void BeautyOnGUI()
        {
            if (!Find.PlaySettings.showBeauty)
            {
                return;
            }
            if (!Gen.MouseCell().InBounds() || Gen.MouseCell().Fogged())
            {
                return;
            }
            BeautyDrawer.tempCountedThings.Clear();
            BeautyUtility.FillBeautyRelevantCells(Gen.MouseCell());
            for (int i = 0; i < BeautyUtility.beautyRelevantCells.Count; i++)
            {
                IntVec3 intVec = BeautyUtility.beautyRelevantCells[i];
                float   num    = BeautyUtility.CellBeauty(intVec, BeautyDrawer.tempCountedThings);
                if (num != 0f)
                {
                    Vector3 v = GenWorldUI.LabelDrawPosFor(intVec);
                    GenWorldUI.DrawThingLabel(v, Mathf.RoundToInt(num).ToStringCached(), BeautyDrawer.BeautyColor(num));
                }
            }
            Text.Font = GameFont.Medium;
            Rect  rect   = new Rect(Event.current.mousePosition.x + 19f, Event.current.mousePosition.y + 19f, 100f, 100f);
            float beauty = BeautyUtility.AverageBeautyPerceptible(Gen.MouseCell());

            GUI.color = BeautyDrawer.BeautyColor(beauty);
            Widgets.Label(rect, beauty.ToString("F1"));
            GUI.color = Color.white;
        }
예제 #4
0
 private void Finished()
 {
     if (PsycheHelper.PsychologyEnabled(mayor) && PsycheHelper.PsychologyEnabled(constituent))
     {
         if (this.ticksInSameRoom > 0)
         {
             if (this.complaint)
             {
                 ThoughtDef complaintDef = new ThoughtDef();
                 complaintDef.label        = "MayorComplaint";
                 complaintDef.durationDays = 1f + 4f * this.mayor.GetStatValue(StatDefOf.SocialImpact);
                 //Constituent thought duration affected by mayor's Social stat
                 complaintDef.thoughtClass            = typeof(Thought_MemoryDynamic);
                 complaintDef.stackedEffectMultiplier = 1f;
                 complaintDef.stackLimit = 999;
                 ThoughtStage complaintStage = new ThoughtStage();
                 float        complaintMood  = 18f * (PsycheHelper.Comp(mayor).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Empathetic) - 0.33f);
                 //Base complaint mood determined by mayor's Empathetic trait
                 complaintMood *= (float)this.ticksInSameRoom / (float)GenDate.TicksPerHour;
                 //Length of meeting also affects mood
                 complaintMood *= (complaintMood < 0f ? Mathf.Lerp(1.25f, 0.75f, PsycheHelper.Comp(constituent).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Polite)) : 1f);
                 //Negative meeting thoughts (unempathetic mayors) mitigated by mayor's politeness
                 complaintMood += (BeautyUtility.AverageBeautyPerceptible(this.constituent.Position, this.constituent.Map) / 10f);
                 //Beauty of the room has a net positive effect on the thought
                 complaintMood *= 0.75f + (PsycheHelper.Comp(constituent).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Judgmental) / 2f);
                 //Constituent's Judgmental trait changes how much the thought affects them
                 complaintStage.label          = "ComplaintLabel".Translate();
                 complaintStage.description    = "ComplaintDesc".Translate();
                 complaintStage.baseMoodEffect = Mathf.RoundToInt(complaintMood);
                 complaintDef.defName          = this.constituent.GetHashCode() + "MayorComplaint" + complaintStage.baseMoodEffect;
                 complaintDef.stages.Add(complaintStage);
                 if (complaintStage.baseMoodEffect != 0)
                 {
                     this.constituent.needs.mood.thoughts.memories.TryGainMemory(complaintDef, this.mayor);
                 }
             }
             ThoughtDef visitDef = new ThoughtDef();
             visitDef.label        = "MayorVisited";
             visitDef.durationDays = 0.75f + 2f * (1f - PsycheHelper.Comp(mayor).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Independent));
             //Mayor thought duration affected by mayor's Independent trait
             visitDef.thoughtClass            = typeof(Thought_MemoryDynamic);
             visitDef.stackedEffectMultiplier = 1f;
             visitDef.stackLimit = 999;
             ThoughtStage stage = new ThoughtStage();
             float        mood  = 7f * (complaint ? -0.5f - (1f - this.constituent.needs.mood.CurLevel) : 0.1f + (this.constituent.needs.mood.CurLevel * 0.65f));
             //Base visit mood determined by the mood level of the constituent
             mood *= (float)this.ticksInSameRoom / (float)GenDate.TicksPerHour;
             //Length of meeting also affects mood
             mood *= (mood < 0f ? Mathf.Lerp(1.25f, 0.75f, PsycheHelper.Comp(constituent).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Polite)) : 1f);
             //Negative meeting thoughts (unhappy constituents) mitigated by constituent's politeness
             mood *= 0.5f + (1f - PsycheHelper.Comp(this.mayor).Psyche.GetPersonalityRating(PersonalityNodeDefOf.LaidBack));
             //Mayor's Laid-Back trait strongly impacts how much the thought affects them
             stage.label          = "VisitLabel".Translate();
             stage.description    = "VisitDesc".Translate();
             stage.baseMoodEffect = Mathf.RoundToInt(mood);
             visitDef.defName     = this.mayor.GetHashCode() + "MayorVisited" + stage.baseMoodEffect;
             visitDef.stages.Add(stage);
             if (stage.baseMoodEffect != 0)
             {
                 this.mayor.needs.mood.thoughts.memories.TryGainMemory(visitDef, this.constituent);
             }
             InteractionDef endConversation = new InteractionDef();
             endConversation.defName = "EndConversation";
             FieldInfo     RuleStrings     = typeof(RulePack).GetField("rulesStrings", BindingFlags.Instance | BindingFlags.NonPublic);
             RulePack      goodbyeTextInit = new RulePack();
             List <string> text            = new List <string>(1);
             if (complaint)
             {
                 text.Add("r_logentry->" + "Complained".Translate());
             }
             else
             {
                 text.Add("r_logentry->" + "Supported".Translate());
             }
             RuleStrings.SetValue(goodbyeTextInit, text);
             endConversation.logRulesInitiator = goodbyeTextInit;
             FieldInfo Symbol = typeof(InteractionDef).GetField("symbol", BindingFlags.Instance | BindingFlags.NonPublic);
             Symbol.SetValue(endConversation, Symbol.GetValue(InteractionDefOfPsychology.HangOut));
             PlayLogEntry_InteractionConversation log = new PlayLogEntry_InteractionConversation(endConversation, this.constituent, this.mayor, new List <RulePackDef>());
             Find.PlayLog.Add(log);
             MoteMaker.MakeInteractionBubble(this.mayor, this.constituent, InteractionDefOf.Chitchat.interactionMote, InteractionDefOf.Chitchat.Symbol);
         }
     }
 }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            // Set fail conditions
            this.EndOnDespawnedOrNull(TargetIndex.A, JobCondition.Incompletable);

            // Reference the tick manager so Find isn't constantly called
            TickManager tickMan = Find.TickManager;

            // Go to the bench
            yield return(Toils_Goto.GotoCell(BenchInd, PathEndMode.OnCell));

            // Set up the toil
            JobDef joyJob = DefDatabase <JobDef> .GetNamed("ZEN_SitAtScenicBench");

            Toil sitAtBench = new Toil()
            {
                socialMode = RandomSocialMode.Normal,
                initAction = () => { surroundingBeauty = BeautyUtility.AverageBeautyPerceptible(pawn.Position, Map); },
                tickAction = () => {
                    pawn.needs.joy.GainJoy(joyJob.joyGainRate * 0.000144f, joyJob.joyKind);
                    pawn.needs.joy.GainJoy(Mathf.Min(Mathf.Max(surroundingBeauty / 2f, 0.3f), 2.5f) * 0.000144f, joyJob.joyKind);
                    // Gain comfort from sitting on the bench
                    pawn.GainComfortFromCellIfPossible();

                    // Occasionally look in a different direction, observing the surroundings
                    if (tickMan.TicksGame % 250 == 0)
                    {
                        pawn.rotationTracker.FaceCell(GenAdj.RandomAdjacentCellCardinal(pawn.Position));
                    }

                    // End this job once the pawn has maxed out their joy
                    if (pawn.needs.joy.CurLevel > 0.9999f)
                    {
                        pawn.jobs.curDriver.EndJobWith(JobCondition.Succeeded);
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Delay,
                defaultDuration     = job.def.joyDuration
            };

            sitAtBench.AddFinishAction(() => {
                Thought_Memory memory;
                // If the scenery was very beautiful, give a better memory,
                if (surroundingBeauty > 5f)
                {
                    memory = (Thought_Memory)ThoughtMaker.MakeThought(ThoughtDef.Named("ZEN_EnjoyedBeautifulScenery"));
                }
                // or if the scenery was okay, give a normal memory,
                else if (surroundingBeauty > 0)
                {
                    memory = (Thought_Memory)ThoughtMaker.MakeThought(ThoughtDef.Named("ZEN_EnjoyedScenery"));
                }
                // otherwise, give a bad memory
                else
                {
                    memory = (Thought_Memory)ThoughtMaker.MakeThought(ThoughtDef.Named("ZEN_DidNotEnjoyScenery"));
                }
                pawn.needs.mood.thoughts.memories.TryGainMemory(memory);
            });

            // Sit at the bench, enjoying the scenery
            yield return(sitAtBench);
        }
        private static void DrawInfoWindow()
        {
            Room room      = UI.MouseCell().GetRoom(Find.VisibleMap, RegionType.Set_All);
            bool roomValid = room != null && room.Role != RoomRoleDefOf.None;

            Text.Font = GameFont.Small;
            Vector2 mousePosition  = Event.current.mousePosition;
            float   x              = mousePosition.x;
            Vector2 mousePosition2 = Event.current.mousePosition;
            Rect    windowRect     = new Rect(x, mousePosition2.y, 416f, 36f);

            windowRect.height += 25f;
            if (roomValid)
            {
                windowRect.height += 13f;
                windowRect.height += 23f;
                windowRect.height += (float)((float)EnvironmentInspectDrawer.DisplayedRoomStatsCount * 25.0);
            }
            windowRect.x += 26f;
            windowRect.y += 26f;
            if (windowRect.xMax > (float)UI.screenWidth)
            {
                windowRect.x -= (float)(windowRect.width + 52.0);
            }
            if (windowRect.yMax > (float)UI.screenHeight)
            {
                windowRect.y -= (float)(windowRect.height + 52.0);
            }
            Find.WindowStack.ImmediateWindow(74975, windowRect, WindowLayer.Super, delegate
            {
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.InspectRoomStats, KnowledgeAmount.FrameDisplayed);
                Text.Font    = GameFont.Small;
                float num    = 18f;
                float beauty = BeautyUtility.AverageBeautyPerceptible(UI.MouseCell(), Find.VisibleMap);
                Rect rect    = new Rect(18f, num, (float)(windowRect.width - 36.0), 100f);
                GUI.color    = BeautyDrawer.BeautyColor(beauty, 40f);
                Widgets.Label(rect, "BeautyHere".Translate() + ": " + beauty.ToString("F1"));
                num = (float)(num + 25.0);
                if (roomValid)
                {
                    num       = (float)(num + 5.0);
                    GUI.color = new Color(1f, 1f, 1f, 0.4f);
                    Widgets.DrawLineHorizontal(18f, num, (float)(windowRect.width - 36.0));
                    GUI.color  = Color.white;
                    num        = (float)(num + 8.0);
                    Rect rect2 = new Rect(18f, num, (float)(windowRect.width - 36.0), 100f);
                    GUI.color  = Color.white;
                    Widgets.Label(rect2, EnvironmentInspectDrawer.GetRoomRoleLabel(room));
                    num           = (float)(num + 25.0);
                    Text.WordWrap = false;
                    for (int i = 0; i < DefDatabase <RoomStatDef> .AllDefsListForReading.Count; i++)
                    {
                        RoomStatDef roomStatDef = DefDatabase <RoomStatDef> .AllDefsListForReading[i];
                        if (!roomStatDef.isHidden || DebugViewSettings.showAllRoomStats)
                        {
                            float stat = room.GetStat(roomStatDef);
                            RoomStatScoreStage scoreStage = roomStatDef.GetScoreStage(stat);
                            if (room.Role.IsStatRelated(roomStatDef))
                            {
                                GUI.color = EnvironmentInspectDrawer.RelatedStatColor;
                            }
                            else
                            {
                                GUI.color = Color.gray;
                            }
                            Rect rect3 = new Rect(rect2.x, num, 100f, 23f);
                            Widgets.Label(rect3, roomStatDef.LabelCap);
                            Rect rect4   = new Rect((float)(rect3.xMax + 35.0), num, 50f, 23f);
                            string label = roomStatDef.ScoreToString(stat);
                            Widgets.Label(rect4, label);
                            Rect rect5 = new Rect((float)(rect4.xMax + 35.0), num, 160f, 23f);
                            Widgets.Label(rect5, (scoreStage != null) ? scoreStage.label : string.Empty);
                            num = (float)(num + 25.0);
                        }
                    }
                    Text.WordWrap = true;
                }
                GUI.color = Color.white;
            }, true, false, 1f);
        }