Пример #1
0
        public bool MoveSim(SimDescription sim, Household moveTo)
        {
            if (sim.Household == moveTo)
            {
                return(true);
            }

            if (sim.Household != null)
            {
                if (sim.CreatedSim != null)
                {
                    try
                    {
                        if ((sim.CreatedSim.Autonomy != null) && (sim.CreatedSim.Autonomy.Motives == null))
                        {
                            sim.CreatedSim.Autonomy.RecreateAllMotives();

                            IncStat("Motives Recreated");
                        }

                        if (sim.CreatedSim.LotCurrent == null)
                        {
                            sim.CreatedSim.InternalOnSetLotCurrent(null);
                        }
                    }
                    catch (Exception e)
                    {
                        Common.DebugException(sim, e);

                        Sims.Reset(sim);
                    }
                }

                Household oldHouse = sim.Household;

                ProcessAbandonHouse(oldHouse, moveTo);

                sim.Household.Remove(sim);

                foreach (SimDescription member in HouseholdsEx.All(oldHouse))
                {
                    GetData(member).InvalidateCache();
                }
            }

            moveTo.Add(sim);

            foreach (SimDescription member in HouseholdsEx.All(moveTo))
            {
                GetData(member).InvalidateCache();
            }

            ManagerSim.ForceRecount();

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

            Sims.Instantiate(sim, moveTo.LotHome, true);

            return(sim.Household == moveTo);
        }
Пример #2
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            ManagerSim.ForceRecount();
            return(true);
        }
Пример #3
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (base.PrivateUpdate(frame))
            {
                List <ISimDescription> sims = new List <ISimDescription>();

                Household house = null;

                foreach (SimDescription sim in Movers)
                {
                    house = sim.Household;

                    sims.Add(sim);
                }

                if (house != null)
                {
                    Vector2 fundsRange = GetValue <CashRangeOption, Vector2>();

                    int funds = (int)RandomUtil.GetFloat(fundsRange.x, fundsRange.y);
                    if (funds == 0)
                    {
                        if (house.FamilyFunds <= 0)
                        {
                            house.ModifyFamilyFunds(CASLogic.GetHouseholdStartingFunds(sims));
                        }
                    }
                    else
                    {
                        house.SetFamilyFunds(funds, false);
                    }

                    Options.StampImmigrantHousehold(house);
                }

                if (OnAfterMoveIn != null)
                {
                    OnAfterMoveIn(this, frame);
                }

                ManagerSim.ForceRecount();
                return(true);
            }

            foreach (SimDescription sim in Movers)
            {
                sim.Dispose();
            }

            return(false);
        }
Пример #4
0
        public bool EliminateHousehold(string storyName, Household me)
        {
            if (SimTypes.IsService(me))
            {
                return(false);
            }

            if (!GameStates.IsLiveState)
            {
                IncStat("Mode Save");
                return(false);
            }

            if (AlarmManager.Global == null)
            {
                IncStat("No Alarm Manager");
                return(false);
            }

            if (Deaths == null)
            {
                IncStat("No Death Manager");
                return(false);
            }

            foreach (SimDescription sim in new List <SimDescription>(me.AllSimDescriptions))
            {
                Deaths.CleansingKill(sim, false);
            }

            me.Destroy();

            try
            {
                me.Dispose();
            }
            catch (Exception e)
            {
                Common.DebugException(me.Name, e);

                Household.sHouseholdList.Remove(me);
            }

            AddSuccess("Household Eliminated");

            IncStat("Household Eliminated: " + me.Name + Common.NewLine + "Story: " + storyName, Common.DebugLevel.High);

            ManagerSim.ForceRecount();
            return(true);
        }
Пример #5
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (OnInheritCashScenario != null)
            {
                OnInheritCashScenario(this, frame);
            }

            if (OnPropagateMournScenario != null)
            {
                OnPropagateMournScenario(this, frame);
            }

            if (OnFuneralScenario != null)
            {
                OnFuneralScenario(this, frame);
            }

            ManagerSim.ForceRecount();

            Manager.AddAlarm(new SimDisposedScenario(Sim));
            return(true);
        }
Пример #6
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);
                }
            }
        }
Пример #7
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);
        }