Пример #1
0
        public static bool ProtectedAddHousehold(Household house, SimDescription sim)
        {
            if ((house == null) || (sim == null))
            {
                return(false);
            }

            SimDescription altered = null;

            if (house.AllSimDescriptions.Count > 0)
            {
                altered = house.AllSimDescriptions[0];
            }
            else
            {
                altered = sim;
            }

            using (HomeworldReversion reversion = new HomeworldReversion(altered))
            {
                if (sim.GetMiniSimForProtection() == null)
                {
                    MiniSims.EnsureProperHomeworld(sim.SimDescriptionId);
                }

                house.Add(sim);
            }

            return(true);
        }
Пример #2
0
        public static ThumbnailKey GetThumbnailKey(IMiniSimDescription ths, ThumbnailSize size, int thumbIndex)
        {
            try
            {
                if (ths == null)
                {
                    return(ThumbnailKey.kInvalidThumbnailKey);
                }

                MiniSimDescription miniSim = ths as MiniSimDescription;
                if (miniSim != null)
                {
                    if (!ThumbnailManager.KeyExistsInDB(miniSim.mThumbKey))
                    {
                        SimDescription sim = MiniSims.UnpackSim(miniSim);

                        ThumbnailKey thumbnailKey = sim.GetThumbnailKey(ThumbnailSize.Large, 0x0);

                        try
                        {
                            sim.Dispose(false, true);
                        }
                        catch (Exception e)
                        {
                            Common.Exception(sim, e);
                        }

                        return(thumbnailKey);
                    }

                    return(miniSim.mThumbKey);
                }
                else if ((ths.CASGenealogy == null) || (ths.CASGenealogy.IsAlive()))
                {
                    return(ths.GetThumbnailKey(size, thumbIndex));
                }
                else
                {
                    return(ths.GetDeceasedThumbnailKey(size, thumbIndex));
                }
            }
            catch (Exception e)
            {
                Common.Exception(ths.FullName, e);
                return(ThumbnailKey.kInvalidThumbnailKey);
            }
        }
Пример #3
0
            protected override void OnPerform()
            {
                Common.DebugNotify("StartGraduationCeremonyTask:OnPerform");

                if (mThs.IsAGraduationCeremonyInProgressAndIfNecessaryStartOne())
                {
                    foreach (SimDescription sim in new List <SimDescription>(mThs.mGraduatingSims.Keys))
                    {
                        try
                        {
                            Instantiation.PerformOffLot(sim, mThs.RabbitHoleProxy.LotCurrent, null);

                            if ((sim.CreatedSim != null) && (sim.CreatedSim.InteractionQueue != null))
                            {
                                sim.CreatedSim.ShowTNSIfSelectable(TNSNames.CollegeGraduationStarting, null, sim.CreatedSim, new object[] { sim.CreatedSim });
                                Annex.UniversityGraduationCeremony entry = Annex.UniversityGraduationCeremony.Singleton.CreateInstance(mThs, sim.CreatedSim, new InteractionPriority(InteractionPriorityLevel.High), false, true) as Annex.UniversityGraduationCeremony;
                                sim.CreatedSim.InteractionQueue.AddNext(entry);
                                ActiveTopic.RemoveTopicFromSim(sim.CreatedSim, "University Graduation");
                            }
                        }
                        catch (Exception e)
                        {
                            Common.Exception(sim, e);
                        }
                    }

                    Dictionary <ulong, SimDescription> loadedSims = SimListing.GetResidents(false);

                    foreach (MiniSimDescription sim in new List <MiniSimDescription>(mThs.mForeignVisitors))
                    {
                        try
                        {
                            // Custom
                            //   EA Standard attempts to reimport existing sims without checking
                            SimDescription local;
                            if (loadedSims.TryGetValue(sim.SimDescriptionId, out local))
                            {
                                if (!mThs.mLocalVisitors.Contains(local))
                                {
                                    mThs.mLocalVisitors.Add(local);
                                }
                            }
                            else
                            {
                                SimDescription simDescription = MiniSims.UnpackSimAndUpdateRel(sim);
                                if (simDescription != null)
                                {
                                    Household.CreateTouristHousehold();
                                    Household.TouristHousehold.AddTemporary(simDescription);
                                    sim.Instantiated = true;
                                    (Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).OnSimCurrentWorldChanged(true, sim);

                                    if (simDescription.AgingState != null)
                                    {
                                        simDescription.AgingState.MergeTravelInformation(sim);
                                    }

                                    mThs.mLocalVisitors.Add(simDescription);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Common.Exception(sim, e);
                        }
                    }

                    Dictionary <SimDescription, bool> performed = new Dictionary <SimDescription, bool>();

                    foreach (SimDescription sim in new List <SimDescription>(mThs.mLocalVisitors))
                    {
                        try
                        {
                            if (mThs.mGraduatingSims.ContainsKey(sim))
                            {
                                continue;
                            }

                            if (performed.ContainsKey(sim))
                            {
                                continue;
                            }
                            performed[sim] = true;

                            Instantiation.PerformOffLot(sim, mThs.RabbitHoleProxy.LotCurrent, null);

                            if ((sim.CreatedSim != null) && (sim.CreatedSim.InteractionQueue != null))
                            {
                                InteractionInstance instance = Annex.AttendGraduationCeremony.Singleton.CreateInstance(mThs, sim.CreatedSim, new InteractionPriority(InteractionPriorityLevel.High), true, true);
                                sim.CreatedSim.InteractionQueue.AddNext(instance);
                            }
                        }
                        catch (Exception e)
                        {
                            Common.Exception(sim, e);
                        }
                    }
                }
            }
Пример #4
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);
                }
            }
        }