/// <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> /// 计算心情和好感相对标准状态的工作效率差值(差值大的优先休息) /// 注意,此处只关心心情和好感,不关心资质 /// 返回值小于 0 时,说明工作效率已经超过标准状态 /// </summary> /// <param name="actorId"></param> /// <returns></returns> private static int GetLackedMoodAndFavor(int actorId) { int currMood = int.Parse(DateFile.instance.GetActorDate(actorId, 4, addValue: false)); int currFavorLevel = DateFile.instance.GetActorFavor(false, DateFile.instance.MianActorID(), actorId, getLevel: true); int currScaledFavor = Original.GetScaledFavor(currFavorLevel); currScaledFavor = Original.AdjustScaledFavorWithMood(currScaledFavor, currMood); int standardMood = STANDARD_MOOD; int standardScaledFavor = Original.GetScaledFavor(STANDARD_FAVOR_LEVEL); standardScaledFavor = Original.AdjustScaledFavorWithMood(standardScaledFavor, standardMood); return(standardScaledFavor - currScaledFavor); }
/// <summary> /// 计算指定地区的工作人员统计信息 /// </summary> /// <param name="partId"></param> /// <param name="placeId"></param> /// <returns></returns> public static WorkerStats GetWorkerStats(int partId, int placeId) { int mainActorId = DateFile.instance.MianActorID(); List <int> workerIds = Original.GetWorkerIds(partId, placeId); var stats = new WorkerStats(); foreach (int workerId in workerIds) { stats.avgHealthInjury += 1f - TaiwuCommon.GetInjuryRate(workerId); stats.avgHealthCirculating += 1f - TaiwuCommon.GetCirculatingBlockingRate(workerId); stats.avgHealthPoison += 1f - TaiwuCommon.GetPoisoningRate(workerId); stats.avgHealthLifespan += 1f - TaiwuCommon.GetLifespanDamageRate(workerId); int mood = int.Parse(DateFile.instance.GetActorDate(workerId, 4, false)); int favor = DateFile.instance.GetActorFavor(false, mainActorId, workerId); int favorLevel = DateFile.instance.GetActorFavor(false, mainActorId, workerId, getLevel: true); int scaledFavor = Original.GetScaledFavor(favorLevel); scaledFavor = Original.AdjustScaledFavorWithMood(scaledFavor, mood); stats.avgMood += mood; stats.avgFriendliness += favor; stats.avgWorkMotivation += Mathf.Max(scaledFavor, 0) / 100f; } if (workerIds.Count > 0) { stats.nWorkers = workerIds.Count; stats.avgHealthInjury /= workerIds.Count; stats.avgHealthCirculating /= workerIds.Count; stats.avgHealthPoison /= workerIds.Count; stats.avgHealthLifespan /= workerIds.Count; stats.avgCompositeHealth = (stats.avgHealthInjury + stats.avgHealthCirculating + stats.avgHealthPoison + stats.avgHealthLifespan) / 4; stats.avgMood /= workerIds.Count; stats.avgFriendliness /= workerIds.Count; stats.avgWorkMotivation /= workerIds.Count; } return(stats); }
/// <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); }