Exemple #1
0
        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);
                };
            }
        }
        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);
        }
Exemple #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;
        }
Exemple #4
0
 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();
 }
Exemple #5
0
 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();
 }