예제 #1
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if ((mMoveInWith == null) || (!House.Contains(mMoveInWith)))
            {
                mMoveInWith = SimTypes.HeadOfFamily(House);
            }

            List <SimDescription> movers = GetMovers(House, true);

            AddStat("Movers", movers.Count);

            foreach (SimDescription sim in movers)
            {
                int funds = 0, debt = 0;

                if ((!SimTypes.IsSpecial(sim)) && (!Household.RoommateManager.IsNPCRoommate(sim)))
                {
                    int count = HouseholdsEx.NumHumans(sim.Household);
                    if (count > 0)
                    {
                        funds = sim.FamilyFunds / count;

                        Money.AdjustFunds(sim, "MoveOut", -funds);
                    }

                    if (count == 1)
                    {
                        debt += GetValue <DebtOption, int>(sim.Household);

                        SetValue <DebtOption, int>(sim.Household, 0);

                        funds += Households.Assets(sim);
                    }
                }

                AddStat("New Funds", funds);

                Money.AdjustFunds(House, "MoveIn", funds);

                AddValue <DebtOption, int>(House, debt);

                Households.MoveSim(sim, House);
            }

            mMovers = movers;
            return(true);
        }
예제 #2
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (Sim.CreatedSim == null)
            {
                Sims.Instantiate(Sim, Sim.LotHome, false);
            }

            if (Target.CreatedSim == null)
            {
                Sims.Instantiate(Target, Target.LotHome, false);
            }

            if ((Sim.CreatedSim == null) || (Target.CreatedSim == null))
            {
                IncStat("Uninstantiated");
                return(false);
            }
            else
            {
                if (Sim.IsRobot)
                {
                    if ((Sim.LotHome == null) ||
                        ((Sim.LotHome.CountObjects <BotMakingStation> () + Sim.LotHome.CountObjects <InventionWorkbench>()) == 0))
                    {
                        IncStat("No Workbench");
                        return(false);
                    }

                    SimDescription child = null;
                    if (Sim.IsFrankenstein)
                    {
                        bool reward = Sim.OccultManager.mIsLifetimeReward;

                        if ((Target.IsFrankenstein) && (RandomUtil.CoinFlip()))
                        {
                            reward = Target.OccultManager.mIsLifetimeReward;
                        }

                        Sim childSim = OccultFrankenstein.CreateFrankenStein(Sim.CreatedSim, CASAgeGenderFlags.None, reward);
                        if (childSim == null)
                        {
                            IncStat("Creation Fail");
                            return(false);
                        }

                        child = childSim.SimDescription;
                    }
                    else
                    {
                        child = OccultRobot.MakeRobot(CASAgeGenderFlags.Adult, CASAgeGenderFlags.None, RobotForms.MaxType);
                        if (child == null)
                        {
                            IncStat("Creation Fail");
                            return(false);
                        }

                        CASRobotData supernaturalData = child.SupernaturalData as CASRobotData;
                        if (supernaturalData != null)
                        {
                            supernaturalData.CreatorSim = Sim.SimDescriptionId;

                            int quality = 0;
                            int count   = 0;

                            CASRobotData parentData = Sim.SupernaturalData as CASRobotData;
                            if (parentData != null)
                            {
                                quality = parentData.BotQualityLevel;
                                count++;
                            }

                            parentData = Target.SupernaturalData as CASRobotData;
                            if (parentData != null)
                            {
                                quality += parentData.BotQualityLevel;
                                count++;
                            }

                            if (count == 2)
                            {
                                quality /= count;
                            }

                            supernaturalData.BotQualityLevel = quality;
                        }
                    }

                    if (child.Genealogy.Parents.Count == 0)
                    {
                        Sim.Genealogy.AddChild(child.Genealogy);
                    }

                    Target.Genealogy.AddChild(child.Genealogy);

                    if (!Households.MoveSim(child, Sim.Household))
                    {
                        IncStat("Move Fail");

                        Deaths.CleansingKill(child, true);

                        return(false);
                    }

                    return(true);
                }
                else if (Target.IsRobot)
                {
                    IncStat("Simbot Partner");
                    return(false);
                }
                else
                {
                    if (CommonSpace.Helpers.Pregnancies.Start(Sim.CreatedSim, Target, false) != null)
                    {
                        ManagerSim.ForceRecount();

                        if (Sim.IsHuman)
                        {
                            if (OnGatheringScenario != null)
                            {
                                OnGatheringScenario(this, frame);
                            }
                        }

                        if ((!Sim.IsHuman) && (Sim.Partner != Target))
                        {
                            if ((GetValue <AllowMarriageOption, bool>(Sim)) && (GetValue <AllowMarriageOption, bool>(Target)))
                            {
                                if ((Romances.AllowBreakup(this, Sim, Managers.Manager.AllowCheck.None)) && (Romances.AllowBreakup(this, Target, Managers.Manager.AllowCheck.None)))
                                {
                                    RemoveAllPetMateFlags(Sim);
                                    RemoveAllPetMateFlags(Target);
                                    Relationship.Get(Sim, Target, false).LTR.AddInteractionBit(LongTermRelationship.InteractionBits.Marry);
                                }
                            }
                        }
                    }
                    return(true);
                }
            }
        }
예제 #3
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            ManagerLot.FindLotFlags flags = Inspect;
            if (CheapestHome)
            {
                flags |= ManagerLot.FindLotFlags.CheapestHome;
            }

            Lot lot = Lots.FindLot(this, mMovers, MaximumLoan, flags, OnLotPriceCheck);

            if (lot == null)
            {
                IncStat("No Lot");
                return(false);
            }
            else if (lot.Household != null)
            {
                IncStat("Occupied");
                return(false);
            }

            int lotCost = Lots.GetLotCost(lot);

            AddStat("Lot Cost", lotCost);

            List <SimDescription> sims = new List <SimDescription>(mMovers);

            Dictionary <Household, bool> oldHouses = new Dictionary <Household, bool>();

            House = null;

            foreach (SimDescription sim in sims)
            {
                if (House == null)
                {
                    if (SimTypes.IsSpecial(sim))
                    {
                        break;
                    }
                    else if (HouseholdsEx.NumSims(sim.Household) == sims.Count)
                    {
                        House = sim.Household;
                    }
                }
                else if (House != sim.Household)
                {
                    House = null;
                    break;
                }
            }

            int newFunds = 0;

            Lot oldLot = null;

            mNewHouse = false;
            if (House == null)
            {
                House = Household.Create();
                House.ModifyFamilyFunds(-House.FamilyFunds);

                House.SetName(sims[0].LastName);

                SetValue <AcountingOption, AccountingData>(House, new AccountingData());

                mNewHouse = true;
            }
            else if (House.LotHome != null)
            {
                oldLot = House.LotHome;

                newFunds = Lots.GetLotCost(House.LotHome);

                Lots.ProcessAbandonLot(oldLot);

                House.MoveOut();
            }

            if (OnPresetLotHome != null)
            {
                OnPresetLotHome(lot, House);
            }
            lot.MoveIn(House);

            ManagerSim.ForceRecount();

            Money.AdjustFunds(House, "SellLot", newFunds);

            AddStat("New Home Funds", House.FamilyFunds);

            SetValue <InspectedOption, bool>(House, false);

            if (mNewHouse)
            {
                foreach (SimDescription sim in sims)
                {
                    if (sim.Household != null)
                    {
                        AdjustFundsMoveInLot(sim, oldHouses);
                    }

                    Households.MoveSim(sim, House);

                    if (sim.IsMale)
                    {
                        House.Name = sim.LastName;
                    }
                }
            }

            if (OnLotPriceCheck(this, lot, newFunds, newFunds) != ManagerLot.CheckResult.IgnoreCost)
            {
                PayForMoveInLot(oldHouses, lotCost);
            }

            AddStat("Remaining Funds", House.FamilyFunds);

            foreach (SimDescription sim in sims)
            {
                Sims.Instantiate(sim, lot, true);
            }

            EventTracker.SendEvent(new HouseholdUpdateEvent(EventTypeId.kFamilyMovedInToNewHouse, House));

            if ((oldLot != null) && (GetValue <NotifyOnMoveOption, bool>(House)))
            {
                if (AcceptCancelDialog.Show(Common.Localize("NotifyOnMove:Prompt", false, new object[] { oldLot.Name, oldLot.Address })))
                {
                    if (CameraController.IsMapViewModeEnabled())
                    {
                        Sims3.Gameplay.Core.Camera.ToggleMapView();
                    }

                    Camera.FocusOnLot(oldLot.LotId, 0f);
                }
            }

            SetValue <NotifyOnMoveOption, bool>(House, false);

            return(true);
        }
예제 #4
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (mNewSim != null)
            {
                mSpecies = mNewSim.Species;
            }

            if (HouseholdsEx.IsFull(this, Sim.Household, mSpecies, 0, true, true))
            {
                IncStat("Full");
                return(false);
            }

            bool created = false;

            if (mNewSim == null)
            {
                using (SimFromBin <ManagerLot> simBin = new SimFromBin <ManagerLot>(this, Lots))
                {
                    CASAgeGenderFlags gender = BabyGenderScenario.GetGenderByFirstBorn(Manager, GetValue <ImmigrateScenario.GenderOption, BabyGenderScenario.FirstBornGender>(), false);

                    mNewSim = simBin.CreateNewSim(Ages, gender, mSpecies);
                    created = true;
                }
            }

            if (mNewSim != null)
            {
                if (Households.MoveSim(mNewSim, Sim.Household))
                {
                    mNewSim.LastName   = Sim.LastName;
                    mNewSim.WasAdopted = true;

                    Relationship relation = ManagerSim.GetRelationship(Sim, mNewSim);
                    if (relation != null)
                    {
                        relation.LTR.SetLiking(Delta);
                    }

                    Relationships.CheckAddHumanParentFlagOnAdoption(Sim, mNewSim);

                    if (Sim.Partner != null)
                    {
                        Relationships.CheckAddHumanParentFlagOnAdoption(Sim.Partner, mNewSim);
                    }

                    if (SimTypes.IsEquivalentSpecies(mNewSim, Sim))
                    {
                        Sim.Genealogy.AddChild(mNewSim.Genealogy);
                    }

                    UpdateDayOfLastOption(Sim);

                    if ((Sim.Partner != null) && (Sim.IsMarried))
                    {
                        if (SimTypes.IsEquivalentSpecies(mNewSim, Sim))
                        {
                            Sim.Partner.Genealogy.AddChild(mNewSim.Genealogy);
                        }

                        UpdateDayOfLastOption(Sim.Partner);
                    }
                    return(true);
                }
                else if (created)
                {
                    mNewSim.Dispose();
                    mNewSim = null;
                }
            }

            IncStat("No New Sim");
            return(false);
        }