Exemple #1
0
        public static bool ExportHouseholdForTravel(Household household)
        {
            try
            {
                foreach (Sim sim in Households.AllSims(household))
                {
                    sim.SetObjectToReset();

                    DreamCatcher.PruneDreamManager(sim);
                }

                Common.Sleep();

                ulong id = DownloadContent.GenerateGUID();
                HouseholdContentsProxy householdContents = new HouseholdContentsProxy(household);
                householdContents.Contents.ContentId = id;
                if (DownloadContent.StoreHouseholdContents(householdContents, id))
                {
                    DownloadContent.ExportLotContentsToTravelBin(id);
                    return(true);
                }
            }
            catch (Exception e)
            {
                Common.Exception("ExportHouseholdForTravel", e);
            }

            return(false);
        }
Exemple #2
0
        public static void AddSims(Household ths, List <Sim> sims, Household oldHousehold, bool bDeleteHouseholdIfEmpty, bool willBeActive, bool dreamCatcher)
        {
            bool isActive = ths.IsActive || willBeActive;

            List <SimDescription> existing = new List <SimDescription>(Households.All(ths));

            foreach (Sim sim in sims)
            {
                try
                {
                    SimDescription simDescription = sim.SimDescription;
                    if (simDescription.ServiceHistory != ServiceType.None)
                    {
                        ths.AddServiceUniform(simDescription.ServiceHistory);
                    }

                    if (isActive)
                    {
                        /*
                         * if (((!simDescription.IsMummy && !simDescription.IsFrankenstein) && (!simDescription.IsImaginaryFriend && !sim.IsActiveFirefighter)) && simDescription.ReplaceHiddenCasParts())
                         * {
                         *  sim.PushSwitchToOutfitInteraction(Sim.ClothesChangeReason.Force, OutfitCategories.Everyday);
                         * }
                         */

                        if (simDescription.CreatedByService != null)
                        {
                            simDescription.CreatedByService.OnMoveInActiveHousehold(sim);
                        }
                    }

                    if (oldHousehold != null)
                    {
                        oldHousehold.RemoveSim(sim, false, bDeleteHouseholdIfEmpty);
                    }

                    if (sim.Household != ths)
                    {
                        ths.Add(simDescription);
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(sim, e);
                }
            }

            if ((ths.LotHome != null) && (ths.LotHome.IsApartmentLot))
            {
                if (isActive)
                {
                    foreach (SimDescription member in existing)
                    {
                        Household.RoommateManager.AddRoommate(member, ths);
                    }

                    Household.RoommateManager.StartAcceptingRoommates(8, ths);
                }
                else
                {
                    Household.RoommateManager.MakeAllRoommatesSelectable(ths);
                }
            }

            ths.AddWardrobeToWardrobe(oldHousehold.Wardrobe);
            ths.AddServiceUniforms(oldHousehold.mServiceUniforms);

            foreach (Sim sim2 in sims)
            {
                DreamCatcher.AdjustSelectable(sim2.SimDescription, isActive, dreamCatcher);
            }
        }
Exemple #3
0
        public AddSims(Household house, IEnumerable <IMiniSimDescription> miniSims, bool overStuff, bool transferFunds, bool dreamCatcher)
        {
            mOldMembers = new List <SimDescription>(CommonSpace.Helpers.Households.All(house));

            foreach (IMiniSimDescription iMiniSim in new List <IMiniSimDescription>(miniSims))
            {
                if (overStuff)
                {
                    if (iMiniSim.IsHuman)
                    {
                        if (CommonSpace.Helpers.Households.NumHumansIncludingPregnancy(house) >= 8)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (CommonSpace.Helpers.Households.NumPetsIncludingPregnancy(house) >= 6)
                        {
                            continue;
                        }
                    }
                }

                MiniSimDescription miniSim = null;

                bool lastActiveSim = false;

                SimDescription sim = iMiniSim as SimDescription;
                if (sim == null)
                {
                    miniSim = iMiniSim as MiniSimDescription;
                    if (miniSim == null)
                    {
                        continue;
                    }

                    sim = MiniSims.UnpackSimAndUpdateRel(miniSim);
                    if (sim == null)
                    {
                        continue;
                    }
                }
                else if (sim.CreatedSim == Sim.ActiveActor)
                {
                    if (Households.NumSims(sim.Household) == 1)
                    {
                        lastActiveSim = true;
                    }
                    else
                    {
                        LotManager.SelectNextSim();
                    }
                }

                Household oldHouse = sim.Household;
                if (oldHouse != null)
                {
                    if (oldHouse == Household.ActiveHousehold)
                    {
                        Household.RoommateManager.RemoveRoommateInternal(sim);
                    }

                    if ((transferFunds) && (oldHouse.NumMembers == 1))
                    {
                        int funds = oldHouse.FamilyFunds;

                        if (oldHouse.LotHome != null)
                        {
                            funds += oldHouse.LotHome.Cost;
                        }

                        house.ModifyFamilyFunds(funds);

                        Households.TransferData(house, oldHouse);
                    }

                    house.AddWardrobeToWardrobe(oldHouse.Wardrobe);
                    house.AddServiceUniforms(oldHouse.mServiceUniforms);

                    oldHouse.Remove(sim, !oldHouse.IsSpecialHousehold);

                    if (PetAdoption.sNeighborAdoption != null)
                    {
                        PetAdoption.sNeighborAdoption.mPetsToAdopt.Remove(sim);
                    }

                    if (sim.CreatedSim != null)
                    {
                        oldHouse.GetCaregiverRoutingMonitor(sim.CreatedSim.LotCurrent, true);
                    }
                }

                if ((oldHouse != null) && (!mOldHouses.ContainsKey(oldHouse)))
                {
                    mOldHouses.Add(oldHouse, true);
                }

                mNewMembers.Add(sim);

                if (house.Name == null)
                {
                    house.Name = sim.LastName;
                }

                if ((sim.IsDead) && (!sim.IsPlayableGhost))
                {
                    Urnstone grave = Urnstones.CreateGrave(sim, false);
                    if (grave != null)
                    {
                        Urnstones.GhostToPlayableGhost(grave, house, house.LotHome.EntryPoint());
                    }
                }
                else
                {
                    // Must be performed or the Household:Add() will bounce
                    if (!sim.IsValidDescription)
                    {
                        sim.Fixup();
                    }

                    MiniSims.ProtectedAddHousehold(house, sim);

                    if (sim.IsPet)
                    {
                        foreach (PetPoolType type in Enum.GetValues(typeof(PetPoolType)))
                        {
                            if (PetPoolManager.IsPetInPoolType(sim, type))
                            {
                                PetPoolManager.RemovePet(type, sim, true);
                            }
                        }
                    }

                    if ((CarNpcManager.Singleton != null) && (CarNpcManager.Singleton.NpcDriversManager != null))
                    {
                        if (CarNpcManager.Singleton.NpcDriversManager.mDescPools != null)
                        {
                            for (int i = 0; i < CarNpcManager.Singleton.NpcDriversManager.mDescPools.Length; i++)
                            {
                                Stack <SimDescription> stack = CarNpcManager.Singleton.NpcDriversManager.mDescPools[i];
                                if (stack == null)
                                {
                                    continue;
                                }

                                List <SimDescription> list = new List <SimDescription>();

                                foreach (SimDescription stackSim in stack)
                                {
                                    if (stackSim == sim)
                                    {
                                        while (stack.Count > 0)
                                        {
                                            list.Add(stack.Pop());
                                        }

                                        list.Remove(sim);

                                        for (int j = list.Count - 1; j >= 0; j--)
                                        {
                                            stack.Push(list[j]);
                                        }
                                    }
                                }
                            }
                        }

                        if ((sim.CreatedSim != null) && (CarNpcManager.Singleton.NpcDriversManager.mNpcDrivers != null))
                        {
                            CarNpcManager.Singleton.NpcDriversManager.mNpcDrivers.Remove(sim.CreatedSim);
                        }
                    }
                }

                if (house.LotHome != null)
                {
                    Instantiation.EnsureInstantiate(sim, house.LotHome);
                }

                if (miniSim != null)
                {
                    (Sims3.Gameplay.UI.Responder.Instance.HudModel as HudModel).OnSimCurrentWorldChanged(true, miniSim);

                    AgingManager.Singleton.AddSimDescription(sim);

                    sim.AgingState.MergeTravelInformation(miniSim);

                    sim.SetFlags(SimDescription.FlagField.AgingEnabled, true);
                }

                try
                {
                    if (sim.Service != null)
                    {
                        sim.Service.EndService(sim);
                    }

                    if (sim.CreatedSim != null)
                    {
                        sim.CreatedSim.BuffManager.RemoveElement(BuffNames.StrayPet);

                        DreamCatcher.AdjustSelectable(sim, sim.Household == Household.ActiveHousehold, dreamCatcher);

                        sim.CreatedSim.SetObjectToReset();

                        sim.CreatedSim.Motives.RecreateMotives(sim.CreatedSim);

                        Sim.MakeSimGoHome(sim.CreatedSim, false);

                        if (lastActiveSim)
                        {
                            PlumbBob.DoSelectActor(sim.CreatedSim, false);
                        }
                    }
                }
                catch (Exception e)
                {
                    Common.DebugException(sim, e);
                }
            }
        }