示例#1
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            Household house = GetData <StoredNetWorthSimData>(Sim).Household;

            int iTotalWorth = GetData <StoredNetWorthSimData>(Sim).NetWorth;

            iTotalWorth -= GetValue <DebtOption, int>(house);

            SetValue <DebtOption, int>(house, 0);

            if (iTotalWorth <= 0)
            {
                IncStat("Inherit Cash: Poor");
                return(false);
            }

            Dictionary <SimDescription, float> inheritors = Deaths.GetInheritors(Sim, GetValue <InheritorsOption, ManagerDeath.Inheritors>(), true);

            float fTotal = 0f;

            foreach (KeyValuePair <SimDescription, float> fraction in inheritors)
            {
                fTotal += fraction.Value;
            }

            AddStat("Worth", iTotalWorth);
            AddStat("Inheritors", inheritors.Count);
            AddStat("Split", fTotal);

            bool simMatches = (Deaths.MatchesAlertLevel(Sim)) || (Money.MatchesAlertLevel(Sim));

            foreach (KeyValuePair <SimDescription, float> inheritor in inheritors)
            {
                int iInheritance = (int)(iTotalWorth * (inheritor.Value / fTotal));

                if (iInheritance <= 0)
                {
                    continue;
                }

                SimDescription child = inheritor.Key;
                if (child.Household == null)
                {
                    continue;
                }

                Money.AdjustFunds(child, "Inheritance", iInheritance);

                if ((simMatches) || (Deaths.MatchesAlertLevel(child)) || (Money.MatchesAlertLevel(child)))
                {
                    mInheritance.Add(child, iInheritance);
                }
            }

            return(mInheritance.Count > 0);
        }
示例#2
0
        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);
        }