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; }
private float AverageBeautyPerceptible(IntVec3 root, Map map) { List <Thing> tempCountedThings = new List <Thing>(); float beauty = 0f; int cells = 0; BeautyUtility.FillBeautyRelevantCells(root, map); List <IntVec3> beautyCells = BeautyUtility.beautyRelevantCells; for (int i = 0; i < beautyCells.Count; i++) { // Get the beauty for this cell beauty += BeautyUtility.CellBeauty(beautyCells[i], map, tempCountedThings); // Add +1 beauty for any plant that doesn't already have beauty Plant plant = beautyCells[i].GetPlant(Map); if (plant != null && plant.GetStatValue(StatDefOf.Beauty) <= 0) { beauty += 1f; } // Add +1 beauty for any water cells if (beautyCells[i].GetTerrain(map).tags.Contains("Water")) { beauty += 1f; } // Add +2 beauty for moving water (rivers) if (beautyCells[i].GetTerrain(map).tags.Contains("River")) { beauty += 2f; } cells++; } // Divide beauty by the number of cells scanned to get the average beauty /= cells; return(beauty); }
public static bool AverageBeautyPerceptible(ref float __result, IntVec3 root, Map map) { if (!root.IsValid || !root.InBounds(map)) { __result = 0.0f; return(false); } //BeautyUtility.tempCountedThings.Clear(); List <Thing> tempCountedThings = new List <Thing>(); float num1 = 0.0f; int num2 = 0; FillBeautyRelevantCells(root, map); IntVec3 cells; for (int index = 0; index < BeautyUtility.beautyRelevantCells.Count; ++index) { try { cells = BeautyUtility.beautyRelevantCells[index]; } catch (ArgumentOutOfRangeException) { break; } num1 += BeautyUtility.CellBeauty(cells, map, tempCountedThings); ++num2; } //BeautyUtility.tempCountedThings.Clear(); __result = num2 == 0 ? 0.0f : num1 / (float)num2; return(false); }
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; }
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; } } }
public BeautyOverlay(bool useAverage) { CreateMappedColors(); _useAverage = useAverage; if (!_useAverage) { _beautyFactor = 10f; _beautyCalculation = (root, map) => BeautyUtility.CellBeauty(root, map); } else // calculate average beauty; used for pawn beauty need but VERY VERY SLOW ! { _beautyFactor = 1f; _beautyCalculation = (root, map) => { float beauty = 0f; int count = 0; BeautyUtility.FillBeautyRelevantCells(root, map); foreach (var cell in BeautyUtility.beautyRelevantCells) { beauty += BeautyUtility.CellBeauty(cell, map, _countedThingList); count++; } _countedThingList.Clear(); return(count == 0 ? float.MinValue : beauty / count); }; } }
public static bool CellBeauty(ref float __result, IntVec3 c, Map map, List <Thing> countedThings = null) { float num1 = 0.0f; float num2 = 0.0f; bool flag = false; if (map == null) //added { __result = 0f; return(false); } ThingGrid thingGrid = map.thingGrid; if (thingGrid == null) //added { __result = 0f; return(false); } List <Thing> thingList = thingGrid.ThingsListAt(c); //changed for (int index = 0; index < thingList.Count; ++index) { Thing thing = thingList[index]; if (BeautyUtility.BeautyRelevant(thing.def.category)) { if (countedThings != null) { if (!countedThings.Contains(thing)) { countedThings.Add(thing); } else { continue; } } SlotGroup slotGroup = thing.GetSlotGroup(); if (slotGroup == null || slotGroup.parent == thing || !slotGroup.parent.IgnoreStoredThingsBeauty) { float statValue = thing.GetStatValue(StatDefOf.Beauty); if (thing is Filth && !map.roofGrid.Roofed(c)) { statValue *= 0.3f; } if (thing.def.Fillage == FillCategory.Full) { flag = true; num2 += statValue; } else { num1 += statValue; } } } } __result = flag ? num2 : num1 + map.terrainGrid.TerrainAt(c).GetStatValueAbstract(StatDefOf.Beauty); return(false); }
public static void Postfix(Thing t, Map ___map) { if (___map == Find.CurrentMap) { if (BeautyUtility.BeautyRelevant(t.def.category)) { BaseOverlay.SetDirty(typeof(BeautyOverlay)); } } }
public static void DrawBeautyAroundMouse() { BeautyUtility.FillBeautyRelevantCells(UI.MouseCell(), Find.VisibleMap); for (int i = 0; i < BeautyUtility.beautyRelevantCells.Count; i++) { IntVec3 intVec = BeautyUtility.beautyRelevantCells[i]; float num = BeautyUtility.CellBeauty(intVec, Find.VisibleMap, BeautyDrawer.beautyCountedThings); if (num != 0f) { Vector3 v = GenMapUI.LabelDrawPosFor(intVec); GenMapUI.DrawThingLabel(v, Mathf.RoundToInt(num).ToStringCached(), BeautyDrawer.BeautyColor(num, 8f)); } } BeautyDrawer.beautyCountedThings.Clear(); }
private static void DrawBeautyAroundMouse() { if (!Find.PlaySettings.showBeauty) { return; } BeautyUtility.FillBeautyRelevantCells(UI.MouseCell(), Find.CurrentMap); for (int i = 0; i < BeautyUtility.beautyRelevantCells.Count; i++) { IntVec3 intVec = BeautyUtility.beautyRelevantCells[i]; float num = BeautyUtility.CellBeauty(intVec, Find.CurrentMap, beautyCountedThings); if (num != 0f) { GenMapUI.DrawThingLabel((Vector3)GenMapUI.LabelDrawPosFor(intVec), Mathf.RoundToInt(num).ToStringCached(), BeautyColor(num, 8f)); } } beautyCountedThings.Clear(); }
public float WindowViewBeauty(Building_Window window) { if (window != null && window.open && window.isFacingSet && window.view.Count > 0) { IEnumerable <IntVec3> view = window.view; float result = 0; List <Thing> counted = new List <Thing>(); foreach (IntVec3 c in view) { var things = window.Map.thingGrid.ThingsListAt(c).Except(counted); var skipped = things.Where(FilterOut); result += BeautyUtility.CellBeauty(c, window.Map, skipped.Union(counted).ToList()); counted.AddRange(things); } return(result); } return(0f); }
public void GetBeauty() { CachedBeauty = 0f; if (state == State.Closed || ElifsDecorationsSettings.BeautyEnabled) { return; } var things = new List <Thing>(); foreach (var cell in WindowUtility.GetWindowCells(Parent, true).Except(Parent.Cells)) { CachedBeauty += BeautyUtility.CellBeauty(cell, Parent.Map, things); } CachedBeauty *= .9f; }
public static bool AverageBeautyPerceptible(ref float __result, IntVec3 root, Map map) { if (!root.IsValid || !root.InBounds(map)) { __result = 0.0f; return(false); } tempCountedThings.Clear(); float num = 0.0f; int num2 = 0; List <IntVec3> beautyRelevantCells = FillBeautyRelevantCells(root, map); for (int i = 0; i < beautyRelevantCells.Count; i++) { num += BeautyUtility.CellBeauty(beautyRelevantCells[i], map, tempCountedThings); num2++; } __result = num2 == 0 ? 0.0f : num / num2; return(false); }
public static float BeautyAt(int index) { return(BeautyUtility.CellBeauty(Find.CurrentMap.cellIndices.IndexToCell(index), Find.CurrentMap)); }
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); }