private static void CalculateColumnsSizes(Room room) { RoomStatsDrawer.statLabelColumnWidth = 0f; RoomStatsDrawer.scoreColumnWidth = 0f; RoomStatsDrawer.scoreStageLabelColumnWidth = 0f; for (int i = 0; i < DefDatabase <RoomStatDef> .AllDefsListForReading.Count; i++) { RoomStatDef roomStatDef = DefDatabase <RoomStatDef> .AllDefsListForReading[i]; if (!roomStatDef.isHidden) { RoomStatsDrawer.statLabelColumnWidth = Mathf.Max(RoomStatsDrawer.statLabelColumnWidth, Text.CalcSize(roomStatDef.LabelCap).x); float stat = room.GetStat(roomStatDef); string label = roomStatDef.GetScoreStage(stat).label; RoomStatsDrawer.scoreStageLabelColumnWidth = Mathf.Max(RoomStatsDrawer.scoreStageLabelColumnWidth, Text.CalcSize(label).x); string text; if (roomStatDef.displayRounded) { text = Mathf.RoundToInt(stat).ToString(); } else { text = stat.ToString("0.##"); } RoomStatsDrawer.scoreColumnWidth = Mathf.Max(RoomStatsDrawer.scoreColumnWidth, Text.CalcSize(text).x); } } RoomStatsDrawer.scoreColumnWidth = Mathf.Max(RoomStatsDrawer.scoreColumnWidth, 40f); }
private static void ApplyScores(EStatType statType) { RoomStatDef rsd = Utils.GetDefByDefName <RoomStatDef>(statType.RoomStatDefName()); if (rsd != null) { for (int i = 0; i < SE_Settings.Settings.StatData[statType].Count; i++) { rsd.scoreStages[i + 1].minScore = SE_Settings.Settings.StatData[statType][i].Value; } } }
private bool IsStatValidForRoom(RoomStatDef statDef, Room room) { if (statDef.isHidden) { return(false); } if (statDef == RoomStatDefOf.Cleanliness && room.Role.Worker is RoomRoleWorker_Kitchen) { return(true); } return(room.Role.IsStatRelated(statDef)); }
internal void Iterate() { ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.InspectRoomStats, KnowledgeAmount.GuiFrame); Text.Font = GameFont.Small; float num = 19f; Rect rect = new Rect(19f, num, this.windowRect.width - 38f, 100f); GUI.color = Color.white; Widgets.Label(rect, RoomStatsDrawer.GetRoomRoleLabel(this.room)); num += 25f; for (int i = 0; i < DefDatabase <RoomStatDef> .AllDefsListForReading.Count; i++) { RoomStatDef roomStatDef = DefDatabase <RoomStatDef> .AllDefsListForReading[i]; if (!roomStatDef.isHidden) { float stat = this.room.GetStat(roomStatDef); RoomStatScoreStage scoreStage = roomStatDef.GetScoreStage(stat); if (this.room.Role.IsStatRelated(roomStatDef)) { GUI.color = RoomStatsDrawer.RelatedStatColor; } else { GUI.color = Color.gray; } Rect rect2 = new Rect(rect.x, num, RoomStatsDrawer.statLabelColumnWidth, 23f); Widgets.Label(rect2, roomStatDef.LabelCap); Rect rect3 = new Rect(rect2.xMax + 35f, num, RoomStatsDrawer.scoreColumnWidth, 23f); string label; if (roomStatDef.displayRounded) { label = Mathf.RoundToInt(stat).ToString(); } else { label = stat.ToString("0.##"); } Widgets.Label(rect3, label); Rect rect4 = new Rect(rect3.xMax + 35f, num, RoomStatsDrawer.scoreStageLabelColumnWidth, 23f); Widgets.Label(rect4, scoreStage.label); num += 25f; } } GUI.color = Color.white; }
private static void InitGameData() { ThingCategoryDefOf.Apparel = new ThingCategoryDef(); //OutfitDatabase needs this SpecialThingFilterDefOf.AllowNonDeadmansApparel = new SpecialThingFilterDef(); var drugDef = new ThingDef { category = ThingCategory.Item, ingestible = new IngestibleProperties { drugCategory = DrugCategory.Social } }; DefDatabase <ThingDef> .AllDefsListForReading.Add(drugDef); ThingDefOf.Beer = drugDef; ThingDefOf.SmokeleafJoint = drugDef; Current.Game = new Game(); Current.Game.World = new RimWorld.Planet.World(); Current.Game.World.uniqueIDsManager = new UniqueIDsManager(); //Current.Game.World.grid = new RimWorld.Planet.WorldGrid(); //Current.Game.World.grid.tiles.Add(new RimWorld.Planet.Tile()); var roomDef = new RoomStatDef(); DefDatabase <RoomStatDef> .AllDefsListForReading.Add(roomDef); //For RegionMaker }
public static void RoomStatsOnGUI() { RoomStatsDrawer.Anonymous temp = new RoomStatsDrawer.Anonymous(); if (!RoomStatsDrawer.ShouldShowRoomStats) { return; } temp.room = Gen.MouseCell().GetRoom(); Text.Font = GameFont.Small; RoomStatsDrawer.CalculateColumnsSizes(temp.room); temp.windowRect = new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 108f + RoomStatsDrawer.statLabelColumnWidth + RoomStatsDrawer.scoreColumnWidth + RoomStatsDrawer.scoreStageLabelColumnWidth, (float)(65 + RoomStatsDrawer.DisplayedRoomStatsCount * 25)); RoomStatsDrawer.Anonymous temp5 = temp; temp5.windowRect.x = temp5.windowRect.x + 5f; RoomStatsDrawer.Anonymous temp2 = temp; temp2.windowRect.y = temp2.windowRect.y + 5f; if (temp.windowRect.xMax > (float)Screen.width) { RoomStatsDrawer.Anonymous temp3 = temp; temp3.windowRect.x = temp3.windowRect.x - (temp.windowRect.width + 10f); } if (temp.windowRect.yMax > (float)Screen.height) { RoomStatsDrawer.Anonymous temp4 = temp; temp4.windowRect.y = temp4.windowRect.y - (temp.windowRect.height + 10f); } Find.WindowStack.ImmediateWindow(74975, temp.windowRect, WindowLayer.Super, delegate { ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.InspectRoomStats, KnowledgeAmount.GuiFrame); Text.Font = GameFont.Small; float num = 19f; Rect rect = new Rect(19f, num, temp.windowRect.width - 38f, 100f); GUI.color = Color.white; Widgets.Label(rect, RoomStatsDrawer.GetRoomRoleLabel(temp.room)); num += 25f; for (int i = 0; i < DefDatabase <RoomStatDef> .AllDefsListForReading.Count; i++) { RoomStatDef roomStatDef = DefDatabase <RoomStatDef> .AllDefsListForReading[i]; if (!roomStatDef.isHidden) { float stat = temp.room.GetStat(roomStatDef); RoomStatScoreStage scoreStage = roomStatDef.GetScoreStage(stat); if (temp.room.Role.IsStatRelated(roomStatDef)) { GUI.color = RoomStatsDrawer.RelatedStatColor; } else { GUI.color = Color.gray; } Rect rect2 = new Rect(rect.x, num, RoomStatsDrawer.statLabelColumnWidth, 23f); Widgets.Label(rect2, roomStatDef.LabelCap); Rect rect3 = new Rect(rect2.xMax + 35f, num, RoomStatsDrawer.scoreColumnWidth, 23f); string label; if (roomStatDef.displayRounded) { label = Mathf.RoundToInt(stat).ToString(); } else { label = stat.ToString("0.##"); } Widgets.Label(rect3, label); Rect rect4 = new Rect(rect3.xMax + 35f, num, RoomStatsDrawer.scoreStageLabelColumnWidth, 23f); Widgets.Label(rect4, scoreStage.label); num += 25f; } } GUI.color = Color.white; }, true, false, 1f); }
public static bool IsRoomTooNice(this Room room, Pawn pawn) { RoomStatDef roomStatDef = RoomStatDefOf.Impressiveness; return(IsRoomTooNiceByStat(room, pawn, roomStatDef)); }
public static bool IsRoomTooNiceByStat(this Room room, Pawn pawn, RoomStatDef roomStatDef) { int scoreStageIndex = roomStatDef.GetScoreStageIndex(room.GetStat(roomStatDef)); return(scoreStageIndex > pawn.MinWantedNice()); }