private void CalculateRanks(float totalRanks, bool current = false, bool projected = false) { bool distributionValid = false; if (Aspects != null) { int count = 0; CalculationSet currentAspect = new CalculationSet(0, 0, 0); CalculationSet projectedAspect = new CalculationSet(0, 0, 0); foreach (KeyValuePair <int, INEAspect> aspect in Aspects) { if (aspect.Value != null) { if (current) { currentAspect.SumDistribution += aspect.Value.Current.Distribution; } if (projected) { projectedAspect.SumDistribution += aspect.Value.Projected.Distribution; } count++; } } bool currentDistributed = currentAspect.SumDistribution > 0; bool projectedDistributed = projectedAspect.SumDistribution > 0; if (currentDistributed || projectedDistributed) { distributionValid = true; foreach (KeyValuePair <int, INEAspect> aspect in Aspects) { if (aspect.Value != null) { if (currentDistributed) { aspect.Value.Current.Ratio = aspect.Value.Current.Distribution / currentAspect.SumDistribution; currentAspect.SumWeightedRatios += Mathf.Pow(aspect.Value.Current.Ratio, INE.Char.WeightPower); } if (projectedDistributed) { aspect.Value.Projected.Ratio = aspect.Value.Projected.Distribution / projectedAspect.SumDistribution; projectedAspect.SumWeightedRatios += Mathf.Pow(aspect.Value.Projected.Ratio, INE.Char.WeightPower); } } } float evenRankPower = INE.Char.EvenRankPower(count); float evenWeightFactor = Mathf.Log(INE.Char.EvenWeightedRatio * Mathf.Pow(count, INE.Char.WeightPower)); if (currentDistributed) { float currentWeightFactor = Mathf.Log(currentAspect.SumWeightedRatios * Mathf.Pow(count, INE.Char.WeightPower)); float rankPower = evenWeightFactor > currentWeightFactor ? evenRankPower : INE.Char.UnevenRankPower; currentAspect.RankMultiplier = Mathf.Pow(evenWeightFactor / currentWeightFactor, rankPower); } if (projectedDistributed) { float projectedWeightFactor = Mathf.Log(projectedAspect.SumWeightedRatios * Mathf.Pow(count, INE.Char.WeightPower)); float rankPower = evenWeightFactor > projectedWeightFactor ? evenRankPower : INE.Char.UnevenRankPower; projectedAspect.RankMultiplier = Mathf.Pow(evenWeightFactor / projectedWeightFactor, rankPower); } } if (current) { CurrentRankBonus = currentAspect.RankMultiplier; } if (projected) { ProjectedRankBonus = projectedAspect.RankMultiplier; } foreach (KeyValuePair <int, INEAspect> aspect in Aspects) { if (current) { aspect.Value.Current.Rank = Mathf.FloorToInt(aspect.Value.Modifier * (currentAspect.RankMultiplier * aspect.Value.Current.Ratio * totalRanks + INE.Char.BaseAspect)); } if (projected) { aspect.Value.Projected.Rank = Mathf.FloorToInt(aspect.Value.Modifier * (projectedAspect.RankMultiplier * aspect.Value.Projected.Ratio * totalRanks + INE.Char.BaseAspect)); } } } DistributionValid = distributionValid; }
public GarageBuilder WithCalculationSet(CalculationSet calculationSet) { PropertyBag.CalculationSets.Add(calculationSet); return(this); }