/// <summary>
        /// 计算指定人员对于指定厢房的统合能力值
        ///
        /// 统合能力值 = SUM(MIN(标准化的能力值 / 标准化的标准状态满效率能力值, ATTR_INTEGRATION_THRESHOLD))
        /// </summary>
        /// <param name="attrs">指定人员的能力字典</param>
        /// <param name="relatedBuildings">指定厢房的辅助建筑列表,不能含有厢房</param>
        /// <returns></returns>
        private static float GetIntegratedAttrValue(Dictionary <int, int> attrs, List <BuildingWorkInfo> relatedBuildings)
        {
            float integratedAttrValue = 0.0f;

            foreach (var info in relatedBuildings)
            {
                int   standardAttrValue            = Original.ToStandardAttrValue(info.requiredAttrId, attrs[info.requiredAttrId]);
                int   standardFullWorkingAttrValue = Original.ToStandardAttrValue(info.requiredAttrId, info.fullWorkingAttrValue);
                float attrRatio = (float)standardAttrValue / standardFullWorkingAttrValue;
                integratedAttrValue += Mathf.Min(attrRatio, ATTR_INTEGRATION_THRESHOLD);
            }

            return(integratedAttrValue);
        }
Exemple #2
0
        /// <summary>
        /// 获取邻接厢房对指定建筑的能力加成
        /// </summary>
        /// <param name="partId"></param>
        /// <param name="placeId"></param>
        /// <param name="buildingIndex"></param>
        /// <param name="requiredAttrId"></param>
        /// <returns></returns>
        private static int GetAdjacentAttrBonus(int partId, int placeId, int buildingIndex, int requiredAttrId)
        {
            int totalAdjacentAttrValue = 0;

            foreach (int adjacentBuildingIndex in Bedroom.GetAdjacentBedrooms(partId, placeId, buildingIndex))
            {
                if (!DateFile.instance.actorsWorkingDate.ContainsKey(partId) ||
                    !DateFile.instance.actorsWorkingDate[partId].ContainsKey(placeId) ||
                    !DateFile.instance.actorsWorkingDate[partId][placeId].ContainsKey(adjacentBuildingIndex))
                {
                    continue;
                }

                int adjacentActorId = DateFile.instance.actorsWorkingDate[partId][placeId][adjacentBuildingIndex];

                int adjacentAttrValue = (requiredAttrId > 0) ? int.Parse(DateFile.instance.GetActorDate(adjacentActorId, requiredAttrId)) : 0;
                adjacentAttrValue = Original.ToStandardAttrValue(requiredAttrId, adjacentAttrValue);

                totalAdjacentAttrValue += adjacentAttrValue;
            }

            return(totalAdjacentAttrValue);
        }
Exemple #3
0
        /// <summary>
        /// 获取指定人物在指定建筑内的工作效率
        /// 大部分照抄 HomeSystem::GetBuildingLevelPct 方法
        /// </summary>
        /// <param name="partId"></param>
        /// <param name="placeId"></param>
        /// <param name="buildingIndex"></param>
        /// <param name="actorId"></param>
        /// <param name="withAdjacentBedrooms"></param>
        /// <returns></returns>
        public static int GetWorkEffectiveness(int partId, int placeId, int buildingIndex, int actorId, bool withAdjacentBedrooms = true)
        {
            int[] building       = DateFile.instance.homeBuildingsDate[partId][placeId][buildingIndex];
            int   baseBuildingId = building[0];
            int   requiredAttrId = int.Parse(DateFile.instance.basehomePlaceDate[baseBuildingId][33]);
            int   mood           = int.Parse(DateFile.instance.GetActorDate(actorId, 4, addValue: false));
            int   favorLevel     = DateFile.instance.GetActorFavor(false, DateFile.instance.MianActorID(), actorId, getLevel: true);
            int   scaledFavor    = Original.GetScaledFavor(favorLevel);

            scaledFavor = Original.AdjustScaledFavorWithMood(scaledFavor, mood);

            int attrValue = (requiredAttrId > 0) ? int.Parse(DateFile.instance.GetActorDate(actorId, requiredAttrId)) : 0;

            attrValue = Original.ToStandardAttrValue(requiredAttrId, attrValue);

            int adjacentAttrBonus = withAdjacentBedrooms ?
                                    Original.GetAdjacentAttrBonus(partId, placeId, buildingIndex, requiredAttrId) : 0;

            int scaledAttrValue   = (attrValue + adjacentAttrBonus) * Mathf.Max(scaledFavor, 0) / 100;
            int workDifficulty    = Original.GetWorkDifficulty(partId, placeId, buildingIndex);
            int workEffectiveness = Mathf.Clamp(scaledAttrValue * 100 / workDifficulty, 50, 200);

            return(workEffectiveness);
        }