public override float GetScore(Room room)
        {
            float num  = 0f;
            int   num2 = 0;

            RoomStatWorker_Beauty.countedThings.Clear();
            foreach (IntVec3 cell in room.Cells)
            {
                num += BeautyUtility.CellBeauty(cell, room.Map, RoomStatWorker_Beauty.countedThings);
                num2++;
            }
            RoomStatWorker_Beauty.countedAdjCells.Clear();
            List <Thing> containedAndAdjacentThings = room.ContainedAndAdjacentThings;

            for (int i = 0; i < containedAndAdjacentThings.Count; i++)
            {
                Thing thing = containedAndAdjacentThings[i];
                if (thing.GetRoom(RegionType.Set_Passable) != room && !RoomStatWorker_Beauty.countedAdjCells.Contains(thing.Position))
                {
                    num += BeautyUtility.CellBeauty(thing.Position, room.Map, RoomStatWorker_Beauty.countedThings);
                    RoomStatWorker_Beauty.countedAdjCells.Add(thing.Position);
                }
            }
            RoomStatWorker_Beauty.countedThings.Clear();
            if (num2 == 0)
            {
                return(0f);
            }
            return(num / RoomStatWorker_Beauty.CellCountCurve.Evaluate((float)num2));
        }
        public static float AverageBeautyPerceptible(IntVec3 root, Map map)
        {
            float result;

            if (!root.IsValid || !root.InBounds(map))
            {
                result = 0f;
            }
            else
            {
                BeautyUtility.tempCountedThings.Clear();
                float num  = 0f;
                int   num2 = 0;
                BeautyUtility.FillBeautyRelevantCells(root, map);
                for (int i = 0; i < BeautyUtility.beautyRelevantCells.Count; i++)
                {
                    num += BeautyUtility.CellBeauty(BeautyUtility.beautyRelevantCells[i], map, BeautyUtility.tempCountedThings);
                    num2++;
                }
                BeautyUtility.tempCountedThings.Clear();
                if (num2 == 0)
                {
                    result = 0f;
                }
                else
                {
                    result = num / (float)num2;
                }
            }
            return(result);
        }
 public float CurrentInstantBeauty()
 {
     if (!pawn.SpawnedOrAnyParentSpawned)
     {
         return(0.5f);
     }
     return(BeautyUtility.AverageBeautyPerceptible(pawn.PositionHeld, pawn.MapHeld));
 }
        public static float CellBeauty(IntVec3 c, Map map, List <Thing> countedThings = null)
        {
            float        num  = 0f;
            float        num2 = 0f;
            bool         flag = false;
            List <Thing> list = map.thingGrid.ThingsListAt(c);

            for (int i = 0; i < list.Count; i++)
            {
                Thing thing = list[i];
                if (BeautyUtility.BeautyRelevant(thing.def.category))
                {
                    if (countedThings != null)
                    {
                        if (countedThings.Contains(thing))
                        {
                            goto IL_EE;
                        }
                        countedThings.Add(thing);
                    }
                    SlotGroup slotGroup = thing.GetSlotGroup();
                    if (slotGroup == null || !slotGroup.parent.IgnoreStoredThingsBeauty)
                    {
                        float num3 = thing.GetStatValue(StatDefOf.Beauty, true);
                        if (thing is Filth && !map.roofGrid.Roofed(c))
                        {
                            num3 *= 0.3f;
                        }
                        if (thing.def.Fillage == FillCategory.Full)
                        {
                            flag  = true;
                            num2 += num3;
                        }
                        else
                        {
                            num += num3;
                        }
                    }
                }
                IL_EE :;
            }
            float result;

            if (flag)
            {
                result = num2;
            }
            else
            {
                num   += map.terrainGrid.TerrainAt(c).GetStatValueAbstract(StatDefOf.Beauty, null);
                result = num;
            }
            return(result);
        }
        public float CurrentInstantBeauty()
        {
            float result;

            if (!this.pawn.SpawnedOrAnyParentSpawned)
            {
                result = 0.5f;
            }
            else
            {
                result = BeautyUtility.AverageBeautyPerceptible(this.pawn.PositionHeld, this.pawn.MapHeld);
            }
            return(result);
        }
Example #6
0
        public static float AverageBeautyPerceptible(IntVec3 root, Map map)
        {
            BeautyUtility.tempCountedThings.Clear();
            float num  = 0f;
            int   num2 = 0;

            BeautyUtility.FillBeautyRelevantCells(root, map);
            for (int i = 0; i < BeautyUtility.beautyRelevantCells.Count; i++)
            {
                num += BeautyUtility.CellBeauty(BeautyUtility.beautyRelevantCells[i], map, BeautyUtility.tempCountedThings);
                num2++;
            }
            num /= (float)num2;
            BeautyUtility.tempCountedThings.Clear();
            return(num);
        }