示例#1
0
        public RoomStat GetPrimaryStat()
        {
            if (_primaryStat != null)
            {
                return(_primaryStat);
            }

            if (Stats.Count == 1)
            {
                _primaryStat = Stats.First();
                return(_primaryStat);
            }

            _primaryStat = Stats.FirstOrDefault(s => s.StatDef == RoomStatDefOf.Impressiveness);
            if (_primaryStat != null)
            {
                return(_primaryStat);
            }

            // No obvious primary stat.
            // Create an average of the stats to serve as primary, with a resolution of 12.
            var averageOfStatFractions = Stats.Average(s => (float)s.CurrentLevel / s.MaxLevel);

            _primaryStat = new RoomStat()
            {
                CurrentLevel = (int)averageOfStatFractions * 12,
                MaxLevel     = 12
            };

            return(_primaryStat);
        }
示例#2
0
        private List <RoomStat> GetRoomStats(Room room)
        {
            var stats = new List <RoomStat>();

            foreach (var statDef in DefDatabase <RoomStatDef> .AllDefsListForReading)
            {
                if (!IsStatValidForRoom(statDef, room))
                {
                    continue;
                }

                var stat = room.GetStat(statDef);
                RoomStatScoreStage scoreStage = statDef.GetScoreStage(stat);
                var roomStat = new RoomStat()
                {
                    StatDef         = statDef,
                    CurrentLevel    = statDef.GetScoreStageIndex(stat),
                    MaxLevel        = statDef.scoreStages.Count,
                    RawCurrentLevel = statDef.ScoreToString(stat),
                    ValueLabel      = scoreStage != null ? scoreStage.label : string.Empty
                };

                if (roomStat.MaxLevel > MaxStatSize)
                {
                    MaxStatSize = roomStat.MaxLevel;
                }

                stats.Add(roomStat);
            }

            if (stats.Count > MaxStatCount)
            {
                MaxStatCount = stats.Count;
            }

            return(stats);
        }