protected static void ReimburseMoveOutRental(ManagerMoney manager, Lot lot, Household resident, ref int totalAdjustment) { if (lot == null) { return; } switch (lot.ResidentialLotSubType) { case ResidentialLotSubType.kEP1_PlayerOwnable: case ResidentialLotSubType.kEP10_PrivateLot: return; } if (resident == null) { return; } Household owner = manager.GetDeedOwner(lot); if (owner == null) { return; } int adjustment = ManagerLot.GetUnfurnishedLotCost(lot, 0); totalAdjustment -= adjustment; manager.AdjustFunds(resident, "RentalAdjustment", -adjustment); }
public static void PurchaseRentalLot(ManagerMoney manager, Sim buyer, Lot lot) { int cost = GetPurchaseLotCost(lot); Household buyerHouse = buyer.SimDescription.Household; int lotCost = lot.Cost; int loan = lotCost - buyerHouse.FamilyFunds; if (loan > 0) { manager.AdjustFunds(buyerHouse, "Loan", loan); } try { if (TravelUtil.CompleteLocationHomePurchase(buyer, lot)) { int difference = lotCost - cost; manager.AdjustFunds(buyerHouse, "Expense", difference); manager.AdjustAccounting(buyerHouse, "Expense", cost); manager.AdjustAccounting(buyerHouse, "PropertyBought", -cost); if (Common.IsAwayFromHomeworld()) { return; } } } finally { if (loan > 0) { manager.AdjustFunds(buyerHouse, "Loan", -loan); } } PropertyData data = buyer.Household.RealEstateManager.FindProperty(lot); if (data == null) { throw new NullReferenceException("data"); } data.mStoredValue = cost; manager.Lots.ClearWorth(lot); Household resident = lot.Household; if (resident == null) { return; } manager.AdjustFunds(resident, "PropertySold", cost); }
public bool Perform(ManagerMoney manager, Sim sim, int delta, string key) { mManager = manager; mSim = sim; mDelta = delta; mKey = key; return(Perform()); }
public static void SellRentalLot(ManagerMoney manager, Sim seller, Lot lot) { PropertyData data = seller.Household.RealEstateManager.FindProperty(lot); if (data == null) { return; } int cost = data.TotalValue; // There is a prompt in SellHome() if (SimTypes.IsSelectable(seller)) { data.SellHome(seller); if (seller.Household.RealEstateManager.FindProperty(lot) != null) { return; } } else { data.Owner.SellProperty(data, false); if (seller.Household != null) { foreach (Sim sim in seller.Household.AllActors) { sim.ResetMapTagManager(); } } } manager.Lots.ClearWorth(lot); Household sellerHouse = seller.SimDescription.Household; manager.AdjustAccounting(sellerHouse, "Income", -cost); manager.AdjustAccounting(sellerHouse, "PropertySold", cost); if (Common.IsAwayFromHomeworld()) { return; } Household resident = lot.Household; if (resident == null) { return; } // Family living on lot buys the lot manager.AdjustFunds(resident, "PropertyBought", -cost); }
public void OnFundChanged(ManagerMoney manager, FamilyFundsChangedEvent e, string key) { sTracer.Perform(manager, e.Actor as Sim, (int)e.Delta, key); if (sTracer.mReservingSimDisposed) { Household house = e.Actor.Household; if (house != null) { house.mFamilyFunds -= (int)e.Delta; } } else if (manager.DebuggingEnabled) { if (!sTracer.mIgnore) { Common.DebugException(e.Actor, null, new Common.StringBuilder(sTracer.ToString()), new Exception()); } } }
public override bool IsHit(SimScoringParameters parameters) { ManagerMoney money = StoryProgression.Main.Money; bool allow = false; using (NetWorthOption.CacheValue cache = new NetWorthOption.CacheValue(money, parameters.Actor.Household)) { allow = money.Allow(money, parameters.Actor, true); if (allow) { SimData data = StoryProgression.Main.GetData(parameters.Actor); if (data != null) { if ((!data.GetValue <AllowMoneyOption, bool>())) { return(false); } } } return(allow); } }
protected override bool PrivateUpdate(ScenarioFrame frame) { Household house = Sim.Household; Sim sim = Sim.CreatedSim; Dictionary <SimDescription, float> inheritors = Deaths.GetInheritors(Sim, GetValue <InheritCashScenario.InheritorsOption, ManagerDeath.Inheritors>(), false); List <Sim> choices = new List <Sim>(); foreach (SimDescription other in inheritors.Keys) { if (other.CreatedSim == null) { continue; } if (!other.ChildOrAbove) { continue; } choices.Add(other.CreatedSim); } if (choices.Count == 0) { foreach (Sim other in HouseholdsEx.AllHumans(house)) { if (other == sim) { continue; } choices.Add(other); } if (choices.Count == 0) { IncStat("No Choices"); return(false); } } bool found = false; if (HouseholdsEx.NumHumans(house) == 1) { if (house.RealEstateManager.AllProperties.Count > 0) { Dictionary <Household, Sim> houses = new Dictionary <Household, Sim>(); foreach (Sim choice in choices) { if (choice.Household == null) { continue; } houses[choice.Household] = choice; } if (houses.Count > 0) { List <KeyValuePair <Household, Sim> > houseChoices = new List <KeyValuePair <Household, Sim> >(houses); foreach (PropertyData data in house.RealEstateManager.AllProperties) { KeyValuePair <Household, Sim> choice = RandomUtil.GetRandomObjectFromList(houseChoices); ManagerMoney.TransferProperty(house, choice.Key, data); mInheritors[choice.Value.SimDescription] = true; IncStat("Property Transferred"); found = true; } } } } if (!SimTypes.IsSelectable(Sim)) { Lots.PackupVehicles(sim, (HouseholdsEx.NumHumans(house) > 1)); foreach (GameObject obj in Inventories.QuickFind <GameObject>(sim.Inventory)) { Sim choice = RandomUtil.GetRandomObjectFromList(choices); if ((obj is INotTransferableOnDeath) || (obj is IHiddenInInventory) || (obj is DeathFlower) || (obj is Diploma)) { IncStat("NonTrans " + obj.GetLocalizedName()); continue; } found = true; if (Inventories.TryToMove(obj, choice)) { IncStat("Transferred " + obj.GetLocalizedName()); mInheritors[choice.SimDescription] = true; } else { IncStat("Unremovable " + obj.GetLocalizedName()); } } } Writing oldSkill = Sim.SkillManager.GetSkill <Writing>(SkillNames.Writing); if (oldSkill != null) { Writing.RoyaltyAlarm alarm = oldSkill.mRoyaltyAlarm; if (alarm != null) { List <Sim> royaltyChoices = new List <Sim>(choices); while (royaltyChoices.Count > 0) { Sim choice = RandomUtil.GetRandomObjectFromList(royaltyChoices); royaltyChoices.Remove(choice); Writing newSkill = choice.SkillManager.GetSkill <Writing>(SkillNames.Writing); if ((newSkill != null) && (newSkill.mRoyaltyAlarm != null)) { continue; } newSkill = choice.SkillManager.AddElement(SkillNames.Writing) as Writing; if (newSkill != null) { alarm.RemoveRoyaltyAlarm(); alarm.mAlarmHandle = AlarmManager.Global.AddAlarmDay(Writing.kRoyaltyPayHour, DaysOfTheWeek.Sunday, new AlarmTimerCallback(alarm.AlarmCallBack), "Royalty Alarm", AlarmType.AlwaysPersisted, newSkill.SkillOwner); alarm.mSkill = newSkill; newSkill.mRoyaltyAlarm = alarm; IncStat("Transferred Royalties"); mInheritors[choice.SimDescription] = true; found = true; } break; } } } if (!found) { return(false); } return(mInheritors.Count > 0); }
protected override bool PrivateUpdate(ScenarioFrame frame) { List <PropertyData> properties = new List <PropertyData>(); int max = Maximum; int min = Minimum; foreach (PropertyData property in Sim.Household.RealEstateManager.AllProperties) { int cost = GetCost(property); if (cost <= 0) { continue; } if (cost < min) { continue; } if (cost > max) { continue; } properties.Add(property); } if (properties.Count == 0) { return(false); } mFail = IsFail(Sim, Target); if (!mFail) { PropertyData choice = RandomUtil.GetRandomObjectFromList(properties); mObjectName = choice.LocalizedName; mObjectValue = GetCost(choice); if (ActualTransfer) { ManagerMoney.TransferProperty(Sim.Household, Target.Household, choice); } else { Money.AdjustFunds(Target, "PropertyTransfer", -mObjectValue); Money.AdjustFunds(Sim, "PropertyTransfer", mObjectValue); } if (Delta < 0) { TraitFunctions.ItemStolenCallback(Target.Household, Origin.FromTheft); foreach (Sim sim in HouseholdsEx.AllSims(Target.Household)) { EventTracker.SendEvent(EventTypeId.kWasRobbed, sim); } } } if (Delta < 0) { if (OnInvestigateScenario != null) { OnInvestigateScenario(this, frame); } } return(true); }
public bool Perform(ManagerMoney manager, Sim sim, int delta, string key) { mManager = manager; mSim = sim; mDelta = delta; mKey = key; return Perform(); }