Exemplo n.º 1
0
        public static void TransitionToEditTown()
        {
            try
            {
                if (PlumbBob.Singleton == null)
                {
                    PlumbBob.Startup();
                }

                PlumbBob.DoSelectActor(null, true);

                GameStates.TransitionToEditTown();
            }
            catch (Exception e)
            {
                Common.Exception("TransitionToEditTown", e);
            }
        }
Exemplo n.º 2
0
        public static void _OnObjectPendingDestruction(object sender, EventArgs e)
        {
            if (sender == null)
            {
                return;
            }

            if (sCurrentSimTwo != null && (sCurrentSimTwo.ObjectId.mValue == 0 || !NFinalizeDeath.GameObjectIsValid(sCurrentSimTwo.ObjectId.mValue)))
            {
                sCurrentSimTwo = null;
            }

            World.OnObjectPendingDestructionEventArgs onObjectPendingDestructionEventArgs = e as World.OnObjectPendingDestructionEventArgs;
            if (onObjectPendingDestructionEventArgs == null || sCurrentSim == null || !(onObjectPendingDestructionEventArgs.ObjectId == sCurrentSim.ObjectId))
            {
                return;
            }

            LotManager.SelectNextSim();

            if (sCurrentSim == null || !(onObjectPendingDestructionEventArgs.ObjectId == sCurrentSim.ObjectId))
            {
                return;
            }

            bool y = false;

            if (!PlumbBob.DoSelectActor(null, true))
            {
                var p = sCurrentSimTwo;
                sCurrentSimTwo = null;
                y = PlumbBob.DoSelectActor(p, true);
            }

            if (!y)
            {
                sCurrentSim = null;
                if (PlumbBob.sSingleton != null)
                {
                    PlumbBob.sSingleton.mSelectedActor = null;
                }
            }
        }
Exemplo n.º 3
0
        public static Sim Perform(Sim sim, bool fadeOut)
        {
            if (sim == null)
            {
                return(null);
            }

            try
            {
                SimDescription simDesc = sim.SimDescription;

                if (Simulator.GetProxy(sim.ObjectId) == null)
                {
                    if (simDesc != null)
                    {
                        sim.Destroy();
                    }

                    //sim.mSimDescription = null;
                    return(null);
                }

                if (simDesc == null)
                {
                    sim.mSimDescription = new SimDescription();

                    sim.Destroy();
                    return(null);
                }

                if (sim.LotHome != null)
                {
                    simDesc.IsZombie = false;

                    if (simDesc.CreatedSim != sim)
                    {
                        sim.Destroy();

                        simDesc.CreatedSim = null;

                        return(null);
                    }
                    else
                    {
                        Bed     myBed     = null;
                        BedData myBedData = null;

                        foreach (Bed bed in sim.LotHome.GetObjects <Bed>())
                        {
                            myBedData = bed.GetPartOwnedBy(sim);
                            if (myBedData != null)
                            {
                                myBed = bed;
                                break;
                            }
                        }

                        ResetPosture(sim);

                        if (simDesc.TraitManager == null)
                        {
                            simDesc.mTraitManager = new TraitManager();
                        }

                        try
                        {
                            simDesc.Fixup();

                            Corrections.CleanupBrokenSkills(simDesc, null);

                            ResetCareer(simDesc);

                            simDesc.ClearSpecialFlags();

                            if (simDesc.Pregnancy == null)
                            {
                                try
                                {
                                    if (simDesc.mMaternityOutfits == null)
                                    {
                                        simDesc.mMaternityOutfits = new OutfitCategoryMap();
                                    }
                                    simDesc.SetPregnancy(0, false);

                                    simDesc.ClearMaternityOutfits();
                                }
                                catch (Exception e)
                                {
                                    Common.Exception(sim, null, "Pregnancy", e);
                                }
                            }

                            if (sim.CurrentCommodityInteractionMap == null)
                            {
                                try
                                {
                                    LotManager.PlaceObjectOnLot(sim, sim.ObjectId);

                                    if (sim.CurrentCommodityInteractionMap == null)
                                    {
                                        sim.ChangeCommodityInteractionMap(sim.LotHome.Map);
                                    }
                                }
                                catch (Exception e)
                                {
                                    Common.Exception(sim, null, "ChangeCommodityInteractionMap", e);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Common.Exception(sim, null, "Fixup", e);
                        }

                        ResetSituations(sim);

                        CleanupSlots(sim);

                        ResetInventory(sim);

                        if (fadeOut)
                        {
                            bool active = (Sim.ActiveActor == sim);

                            if (sSimReset.Valid)
                            {
                                sSimReset.Invoke <bool>(new object[] { simDesc.SimDescriptionId });
                            }

                            ResetRouting(sim);

                            using (CreationProtection protection = new CreationProtection(simDesc, sim, false, true, false))
                            {
                                sim.Destroy();

                                Common.Sleep();

                                sim = FixInvisibleTask.InstantiateAtHome(simDesc, null);
                            }

                            if (sim != null)
                            {
                                if (active)
                                {
                                    try
                                    {
                                        foreach (Sim member in Households.AllSims(sim.Household))
                                        {
                                            if (member.CareerManager == null)
                                            {
                                                continue;
                                            }

                                            Occupation occupation = member.CareerManager.Occupation;
                                            if (occupation == null)
                                            {
                                                continue;
                                            }

                                            occupation.FormerBoss = null;
                                        }

                                        using (DreamCatcher.HouseholdStore store = new DreamCatcher.HouseholdStore(sim.Household, true))
                                        {
                                            PlumbBob.DoSelectActor(sim, true);
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        Common.Exception(sim, null, "DoSelectActor", e);
                                    }
                                }

                                if ((myBed != null) && (myBedData != null))
                                {
                                    if (!(myBed is BedMultiPart) || (myBed is BedMultiPart && ((sim.Partner != null) && (sim.Partner.CreatedSim != null))))
                                    {
                                        myBed.ClaimOwnership(sim, myBedData);
                                    }
                                    else
                                    {
                                        HandleDoubleBed(sim, myBed, myBedData);
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (sim.Inventory == null)
                            {
                                sim.AddComponent <InventoryComponent>(new object[0x0]);
                            }

                            if (Instantiation.AttemptToPutInSafeLocation(sim, false))
                            {
                                ResetRouting(sim);

                                sim.SetObjectToReset();

                                // This is necessary to clear certain types of interactions
                                //   (it is also called in SetObjectToReset(), though doesn't always work there)
                                if (sim.InteractionQueue != null)
                                {
                                    sim.InteractionQueue.OnReset();
                                }
                            }
                        }

                        ResetSkillModifiers(simDesc);

                        ResetRole(sim);

                        if (simDesc.IsEnrolledInBoardingSchool())
                        {
                            simDesc.BoardingSchool.OnRemovedFromSchool();
                        }

                        MiniSimDescription miniSim = MiniSimDescription.Find(simDesc.SimDescriptionId);
                        if (miniSim != null)
                        {
                            miniSim.Instantiated = true;
                        }

                        UpdateInterface(sim);

                        return(sim);
                    }
                }
                else if (simDesc.Service is Butler)
                {
                    if (Instantiation.AttemptToPutInSafeLocation(sim, true))
                    {
                        sim.Motives.RecreateMotives(sim);
                        sim.SetObjectToReset();
                    }

                    return(sim);
                }
                else if (simDesc.IsImaginaryFriend)
                {
                    OccultImaginaryFriend friend;
                    if (OccultImaginaryFriend.TryGetOccultFromSim(sim, out friend))
                    {
                        if (Simulator.GetProxy(friend.mDollId) != null)
                        {
                            friend.TurnBackIntoDoll(OccultImaginaryFriend.Destination.Owner);

                            return(null);
                        }
                    }
                }
                else if (simDesc.IsBonehilda)
                {
                    foreach (BonehildaCoffin coffin in Sims3.Gameplay.Queries.GetObjects <BonehildaCoffin>())
                    {
                        if (coffin.mBonehilda == simDesc)
                        {
                            coffin.mBonehildaSim = null;
                            break;
                        }
                    }
                }

                if (fadeOut)
                {
                    sim.Destroy();
                }

                return(null);
            }
            catch (Exception exception)
            {
                Common.Exception(sim, exception);
                return(sim);
            }
        }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 5
0
        public override void LoadUI()
        {
            Common.StringBuilder msg = new Common.StringBuilder("LiveModeStateEx:LoadUI" + Common.NewLine);

            try
            {
                bool reset = false;

                Sim selectedActor = PlumbBob.SelectedActor;
                if (selectedActor != null)
                {
                    msg += Common.NewLine + "SelectedActor: " + selectedActor.FullName;

                    // Elements used by HudModel:Initialize()
                    if (selectedActor.SkillManager == null)
                    {
                        reset = true;
                        msg  += Common.NewLine + "SkillManager: null";
                    }
                    else if (selectedActor.SocialComponent == null)
                    {
                        reset = true;
                        msg  += Common.NewLine + "SocialComponent: null";
                    }
                    else if (selectedActor.CareerManager == null)
                    {
                        reset = true;
                        msg  += Common.NewLine + "CareerManager: null";
                    }
                    else if (selectedActor.TraitManager == null)
                    {
                        reset = true;
                        msg  += Common.NewLine + "TraitManager: null";
                    }
                    else if (selectedActor.SimDescription == null)
                    {
                        reset = true;
                        msg  += Common.NewLine + "SimDescription: null";
                    }
                    else if (selectedActor.InteractionQueue == null)
                    {
                        reset = true;
                        msg  += Common.NewLine + "InteractionQueue: null";
                    }
                    else if (selectedActor.OccultManager == null)
                    {
                        reset = true;
                        msg  += Common.NewLine + "OccultManager: null";
                    }
                    else if (selectedActor.CelebrityManager == null)
                    {
                        reset = true;
                        msg  += Common.NewLine + "CelebrityManager: null";
                    }
                }
                else
                {
                    msg += Common.NewLine + "No SelectedActor";
                }

                if (reset)
                {
                    msg += Common.NewLine + "Perform Reset";

                    selectedActor = ResetSimTask.Perform(selectedActor, false);

                    if (selectedActor == null)
                    {
                        PlumbBob.DoSelectActor(null, true);
                    }
                    else
                    {
                        DreamCatcher.SelectNoLotCheckImmediate(selectedActor, false, true);
                    }
                }

                base.LoadUI();

                /*
                 * // From LiveModeState:LoadUI
                 * mMapTagController = new MapTagControllerEx();
                 * Simulator.AddObject(mMapTagController);
                 * HudController.Load();*/
            }
            catch (Exception e)
            {
                Traveler.InsanityException(msg, e);
            }
        }