private static int CalculateGarrisonChangeInternal( Settlement settlement, StatExplainer explanation = null) { ExplainedNumber result = new ExplainedNumber(0.0f, explanation, (TextObject)null); if (settlement.IsTown || settlement.IsCastle) { double loyalty = (double)settlement.Town.Loyalty; if (settlement.IsStarving) { float foodChange = settlement.Town.FoodChange; int num = !settlement.Town.Owner.IsStarving || (double)foodChange >= -19.0 ? 0 : (int)(((double)foodChange + 10.0) * SubModule.Settings.garrisonFoodConsumpetionMultiplier / 10.0); result.Add((float)num, LightSettlementGarrisonModel._foodShortageText); } if (settlement.Town.GarrisonParty != null && ((double)settlement.Town.GarrisonParty.Party.NumberOfHealthyMembers + (double)result.ResultNumber) / (double)settlement.Town.GarrisonParty.Party.PartySizeLimit > (double)settlement.Town.GarrisonParty.PaymentRatio) { int num = 0; do { ++num; }while (((double)settlement.Town.GarrisonParty.Party.NumberOfHealthyMembers + (double)result.ResultNumber - (double)num) / (double)settlement.Town.GarrisonParty.Party.PartySizeLimit >= (double)settlement.Town.GarrisonParty.PaymentRatio && (double)settlement.Town.GarrisonParty.Party.NumberOfHealthyMembers + (double)result.ResultNumber - (double)num > 0.0 && num < 20); result.Add((float)-num, LightSettlementGarrisonModel._paymentIsLess); } } LightSettlementGarrisonModel.GetSettlementGarrisonChangeDueToIssues(settlement, ref result); return((int)result.ResultNumber); }
private static int CalculateGarrisonChangeInternal(Settlement settlement, StatExplainer?explanation = null) { ExplainedNumber explainedNumber = new ExplainedNumber(0f, explanation, null); bool flag = settlement.IsTown || settlement.IsCastle; if (flag) { double num = (double)settlement.Town.Loyalty; bool isStarving = settlement.IsStarving; if (isStarving) { float foodChange = settlement.Town.FoodChange; int num2 = (!settlement.Town.Owner.IsStarving || (double)foodChange >= -19.0) ? 0 : ((int)(((double)foodChange + 10.0) * (double)SubModule.Settings.GarrisonFoodConsumpetionMultiplier / 10.0)); explainedNumber.Add((float)num2, LightSettlementGarrisonModel._foodShortageText, null); } bool flag2 = settlement.Town.GarrisonParty != null && ((double)settlement.Town.GarrisonParty.Party.NumberOfHealthyMembers + (double)explainedNumber.ResultNumber) / (double)settlement.Town.GarrisonParty.Party.PartySizeLimit > (double)settlement.Town.GarrisonParty.PaymentRatio; if (flag2) { int num3 = 0; do { num3++; }while ((settlement is not null && settlement.Town.GarrisonParty is not null) && (((double)settlement.Town.GarrisonParty.Party.NumberOfHealthyMembers + (double)explainedNumber.ResultNumber - (double)num3) / (double)settlement.Town.GarrisonParty.Party.PartySizeLimit >= (double)settlement.Town.GarrisonParty.PaymentRatio && (double)settlement.Town.GarrisonParty.Party.NumberOfHealthyMembers + (double)explainedNumber.ResultNumber - (double)num3 > 0.0 && num3 < 20)); explainedNumber.Add((float)(-(float)num3), LightSettlementGarrisonModel._paymentIsLess, null); } } if (settlement is not null) { LightSettlementGarrisonModel.GetSettlementGarrisonChangeDueToIssues(settlement, ref explainedNumber); } return((int)explainedNumber.ResultNumber); }