Esempio n. 1
0
        /// <summary>
        /// 返回对于指定建筑,在标准状态下,需要多少对应资质以达到 50% / 100% 工作效率
        /// </summary>
        /// <param name="partId"></param>
        /// <param name="placeId"></param>
        /// <param name="buildingIndex"></param>
        /// <param name="withAdjacentBedrooms"></param>
        /// <param name="getStandardAttrValue">是否返回标准化的能力值</param>
        /// <returns></returns>
        public static int[] GetRequiredAttributeValues(int partId, int placeId, int buildingIndex,
                                                       bool withAdjacentBedrooms = true, bool getStandardAttrValue = false)
        {
            int[] building       = DateFile.instance.homeBuildingsDate[partId][placeId][buildingIndex];
            int   baseBuildingId = building[0];
            int   requiredAttrId = int.Parse(DateFile.instance.basehomePlaceDate[baseBuildingId][33]);

            if (requiredAttrId == 0)
            {
                return new int[] { 0, 0 }
            }
            ;

            int mood        = HumanResource.STANDARD_MOOD;
            int scaledFavor = Original.GetScaledFavor(HumanResource.STANDARD_FAVOR_LEVEL);

            scaledFavor = Original.AdjustScaledFavorWithMood(scaledFavor, mood);

            int workDifficulty = Original.GetWorkDifficulty(partId, placeId, buildingIndex);

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

            int requiredHalfAttrValue = Mathf.Max(workDifficulty * 100 / Mathf.Max(scaledFavor, 0) - adjacentAttrBonus, 0);
            int requiredFullAttrValue = Mathf.Max(workDifficulty * 200 / Mathf.Max(scaledFavor, 0) - adjacentAttrBonus, 0);

            if (!getStandardAttrValue)
            {
                requiredHalfAttrValue = Original.FromStandardAttrValue(requiredAttrId, requiredHalfAttrValue);

                requiredFullAttrValue = Original.FromStandardAttrValue(requiredAttrId, requiredFullAttrValue);
            }

            return(new int[] { requiredHalfAttrValue, requiredFullAttrValue });
        }
Esempio n. 2
0
        /// <summary>
        /// 返回建筑安排工作人员的优先级。优先级越高,越优先安排高能力的工作人员。
        /// 返回值越大,优先级越高;为负数时(因用户配置而排除),不参与人员分配。
        /// 目前固定优先级为:厢房 > 病坊、密医 > 收获人才建筑 > 收获资源建筑 > 收获物品建筑 > 收获蛐蛐建筑
        /// 同一类别中,工作难度越高,优先级越高
        /// </summary>
        /// <param name="partId"></param>
        /// <param name="placeId"></param>
        /// <param name="buildingIndex"></param>
        /// <returns></returns>
        private static int GetBuildingWorkingPriority(int partId, int placeId, int buildingIndex)
        {
            int[] building       = DateFile.instance.homeBuildingsDate[partId][placeId][buildingIndex];
            int   baseBuildingId = building[0];

            int basePriority;

            if (baseBuildingId == BASE_BUILDING_ID_BEDROOM)
            {
                basePriority = 6;
            }
            else if (baseBuildingId == BASE_BUILDING_ID_HOSPITAL || baseBuildingId == BASE_BUILDING_ID_DETOXIFICATION)
            {
                basePriority = 5;
            }
            else
            {
                var harvestTypes = HumanResource.buildingsHarvestTypes[baseBuildingId];
                if (harvestTypes.Contains(HARVEST_TYPE_CHARACTER))
                {
                    basePriority = 4;
                }
                else if (harvestTypes.Contains(HARVEST_TYPE_RESOURCE))
                {
                    basePriority = 3;
                }
                else if (harvestTypes.Contains(HARVEST_TYPE_ITEM))
                {
                    basePriority = 2;
                }
                else
                {
                    basePriority = 1;
                }
            }

            int workDifficulty = Original.GetWorkDifficulty(partId, placeId, buildingIndex);
            int priority       = basePriority * WORKING_PRIORITY_STEP_SIZE + workDifficulty;

            return(priority);
        }
Esempio n. 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);
        }