/// <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 }); }
/// <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); }