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);
        }
示例#2
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);
                };
            }
        }
示例#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
        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);
        }
示例#5
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();
 }
示例#6
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();
 }
示例#7
0
 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);
 }
示例#8
0
        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;
        }
示例#9
0
        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);
        }
示例#10
0
 public static float BeautyAt(int index)
 {
     return(BeautyUtility.CellBeauty(Find.CurrentMap.cellIndices.IndexToCell(index), Find.CurrentMap));
 }