private static int PrivateGetHouseholdFunds(GameEntryMovingModel ths, bool isSource) { Household targetHousehold = null; if (ths.mTargetLot != null) { targetHousehold = ths.mTargetLot.Household; } if (isSource) { return GetHouseholdFunds( ths, ths.mSourceSimList, ths.mSourceHousehold, ths.mSourceHousehold.LotHome, ths.mSourceHousehold.FamilyFunds, ths.mTargetSimList, targetHousehold, ths.mTargetLot, ths.mTargetHouseholdFunds ); } else { return GetHouseholdFunds( ths, ths.mTargetSimList, targetHousehold, ths.mTargetLot, ths.mTargetHouseholdFunds, ths.mSourceSimList, ths.mSourceHousehold, ths.mSourceHousehold.LotHome, ths.mSourceHousehold.FamilyFunds ); } }
public static int GetHouseholdFunds(GameEntryMovingModel ths, bool isSource) { int funds = PrivateGetHouseholdFunds(ths, isSource); if ((ths.mTargetLot != null) && (ths.mTargetLot.Household == null)) { float totalFunds = PrivateGetHouseholdFunds(ths, true) + PrivateGetHouseholdFunds(ths, false); float factor = isSource ? 1f : 0f; if (totalFunds != 0) { factor = (funds / totalFunds); } if (factor > 1f) { factor = 1f; } funds -= (int)(Mover.GetLotCost(ths.mTargetLot) * factor); } return funds; }
private static int GetHouseholdFunds(GameEntryMovingModel ths, Dictionary<ISimDescription, bool> sourceSimList, Household sourceHousehold, Lot sourceLot, int sourceHouseholdFunds, Dictionary<ISimDescription, bool> targetSimList, Household targetHousehold, Lot targetLot, int targetHouseholdFunds) { Common.StringBuilder msg = new Common.StringBuilder("HouseholdFunds"); try { if (Households.NumHumans(sourceSimList.Keys) == 0x0) { msg += Common.NewLine + "No Source"; return 0x0; } int originalTargetSims = 0x0; if (targetHousehold != null) { originalTargetSims = Households.NumHumans(targetHousehold); } int numTargetSimsStaying = Households.NumHumans(targetSimList.Keys); msg += Common.NewLine + "Orig Targets: " + originalTargetSims; msg += Common.NewLine + "Stay Targets: " + numTargetSimsStaying; if (numTargetSimsStaying == 0x0) // Must be actual sims, not just humans { // No sims in target household, so all of them must be in the source int value = sourceHouseholdFunds + targetHouseholdFunds; if ((targetSimList.Count > 0x0) || (targetLot == null) || (targetHousehold == null)) { msg += Common.NewLine + "A: " + value; } else if (ths.mPackFurniture) { // Taking Furniture if (!Mover.Settings.mFreeRealEstate) { value += Lots.GetUnfurnishedCost(targetLot); } msg += Common.NewLine + "B: " + value; } else { // Selling Furniture value += Mover.GetLotCost(targetLot); msg += Common.NewLine + "C: " + value; } return value; } else if (numTargetSimsStaying == originalTargetSims) { msg += Common.NewLine + "D: " + sourceHouseholdFunds; // No change in the number of target sims that have moved return sourceHouseholdFunds; } float movePerPersonPercentage = (Mover.Settings.mMovePerPersonPercentage / 100f); int maxMoneyTransferred = Mover.Settings.mMaxMoneyTransferred; msg += Common.NewLine + "Move Percent: " + movePerPersonPercentage; msg += Common.NewLine + "Max Transfer: " + maxMoneyTransferred; int num5 = 0x0; if (numTargetSimsStaying > originalTargetSims) { msg += Common.NewLine + "Staying > Original"; // Sims added to target household, and removed from source if ((sourceHousehold != null) && (Households.NumHumans(sourceHousehold) > 0)) { movePerPersonPercentage = Math.Min(movePerPersonPercentage, 1f / Households.NumHumans(sourceHousehold)); msg += Common.NewLine + "Adj Percent: " + movePerPersonPercentage; int funds = sourceHousehold.FamilyFunds; if (sourceHousehold.LotHome != null) { funds += Mover.GetLotCost(sourceHousehold.LotHome); } if (funds > SimDescription.kSimoleonThresholdForBeingRich) { maxMoneyTransferred = Mover.Settings.mMaxMoneyTransferredRich; msg += Common.NewLine + "Adj Transfer: " + maxMoneyTransferred; } } num5 = (int)(((numTargetSimsStaying - originalTargetSims) * movePerPersonPercentage) * sourceHouseholdFunds); msg += Common.NewLine + "A: " + num5; if (maxMoneyTransferred > 0) { num5 = Math.Min(num5, maxMoneyTransferred); msg += Common.NewLine + "B: " + num5; } num5 = Math.Max(num5, Math.Min(Mover.Settings.mMinMoneyTransferred, sourceHouseholdFunds)); msg += Common.NewLine + "Min Transfer: " + Mover.Settings.mMinMoneyTransferred; msg += Common.NewLine + "Source Funds: " + sourceHouseholdFunds; msg += Common.NewLine + "C: " + num5; if (num5 > sourceHouseholdFunds) { num5 = sourceHouseholdFunds; msg += Common.NewLine + "D: " + num5; } msg += Common.NewLine + "E: " + (sourceHouseholdFunds - num5).ToString(); return (sourceHouseholdFunds - num5); } else { // Sims removed from target household, and added to source if ((targetHousehold != null) && (Households.NumHumans(targetHousehold) > 0)) { movePerPersonPercentage = Math.Min(movePerPersonPercentage, 1f / Households.NumHumans(targetHousehold)); msg += Common.NewLine + "Adj Percent: " + movePerPersonPercentage; int funds = targetHousehold.FamilyFunds; if (targetHousehold.LotHome != null) { funds += Mover.GetLotCost(targetHousehold.LotHome); } if (funds > SimDescription.kSimoleonThresholdForBeingRich) { maxMoneyTransferred = Mover.Settings.mMaxMoneyTransferredRich; msg += Common.NewLine + "Adj Transfer: " + maxMoneyTransferred; } } num5 = (int)(((originalTargetSims - numTargetSimsStaying) * movePerPersonPercentage) * targetHouseholdFunds); msg += Common.NewLine + "A: " + num5; if (maxMoneyTransferred > 0) { num5 = Math.Min(num5, maxMoneyTransferred); msg += Common.NewLine + "B: " + num5; } num5 = Math.Max(num5, Math.Min(Mover.Settings.mMinMoneyTransferred, targetHouseholdFunds)); msg += Common.NewLine + "Min Transfer: " + Mover.Settings.mMinMoneyTransferred; msg += Common.NewLine + "Target Funds: " + targetHouseholdFunds; msg += Common.NewLine + "C: " + num5; if (num5 > targetHouseholdFunds) { num5 = targetHouseholdFunds; msg += Common.NewLine + "D: " + num5; } msg += Common.NewLine + "E: " + (sourceHouseholdFunds + num5).ToString(); return (sourceHouseholdFunds + num5); } } finally { Common.DebugNotify(msg); } }