Esempio n. 1
0
 // Token: 0x06006FB8 RID: 28600 RVA: 0x0026CC7C File Offset: 0x0026BC7C
 private void CleanupAndDestroyDeadSim(bool forceCleanup)
 {
     if (this.mDeathEffect != null)
     {
         this.mDeathEffect.Stop();
         this.mDeathEffect = null;
     }
     this.Target.ClearReferenceList();
     if (this.mSituation.LastSimOfHousehold == null || this.mSituation.LastSimOfHousehold != this.Target || forceCleanup)
     {
         if (this.Target.Household == null || this.Target.Household.IsPetHousehold)
         {
             SimDescription    simDescription = this.Target.SimDescription;
             PetPoolType       petPoolType    = PetPoolType.None;
             CASAgeGenderFlags species        = simDescription.Species;
             if (species <= CASAgeGenderFlags.Cat)
             {
                 if (species != CASAgeGenderFlags.Horse)
                 {
                     if (species == CASAgeGenderFlags.Cat)
                     {
                         petPoolType = PetPoolType.StrayCat;
                     }
                 }
                 else if (simDescription.IsUnicorn)
                 {
                     petPoolType = PetPoolType.Unicorn;
                 }
                 else
                 {
                     petPoolType = PetPoolType.WildHorse;
                 }
             }
             else if (species == CASAgeGenderFlags.Dog || species == CASAgeGenderFlags.LittleDog)
             {
                 petPoolType = PetPoolType.StrayDog;
             }
             if (PetPoolManager.IsPetInPoolType(simDescription, petPoolType))
             {
                 PetPoolManager.RemovePet(petPoolType, simDescription);
             }
         }
         this.mGrave.GhostCleanup(this.Target, true);
         if (this.Target.Autonomy != null)
         {
             this.Target.Autonomy.DecrementAutonomyDisabled();
         }
         this.Target.SimDescription.ShowSocialsOnSim = true;
         if (!this.mWasMemberOfActiveHousehold && Household.ActiveHousehold != null && this.Actor.LotCurrent != Household.ActiveHousehold.LotHome)
         {
             this.mGrave.FadeOut(false, 5f, new AlarmTimerCallback(this.HandleNPCGrave));
         }
         this.Target.Destroy();
     }
 }
Esempio n. 2
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);
                }
            }
        }
Esempio n. 3
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (mNewSim != null)
            {
                return(base.PrivateUpdate(frame));
            }

            if (GetValue <PetAdoptionScenario.UsePetPoolOption, bool>())
            {
                PetPoolType poolType = PetPoolType.None;
                switch (Species)
                {
                case CASAgeGenderFlags.Dog:
                case CASAgeGenderFlags.LittleDog:
                    poolType = PetPoolType.AdoptDog;
                    break;

                case CASAgeGenderFlags.Cat:
                    poolType = PetPoolType.AdoptCat;
                    break;

                case CASAgeGenderFlags.Horse:
                    poolType = PetPoolType.AdoptHorse;
                    break;
                }

                List <SimDescription> choices = PetPoolManager.GetPetsByType(poolType);
                if ((choices != null) && (choices.Count > 0))
                {
                    CASAgeGenderFlags ages = Ages;
                    for (int i = choices.Count - 1; i >= 0; i--)
                    {
                        if ((ages & choices[i].Age) != choices[i].Age)
                        {
                            choices.RemoveAt(i);
                        }
                        else if (choices[i].Species != Species)
                        {
                            choices.RemoveAt(i);
                        }
                    }

                    if (choices.Count == 0)
                    {
                        IncStat("No Matching In Pool");
                    }
                    else
                    {
                        mNewSim = RandomUtil.GetRandomObjectFromList(choices);

                        PetPoolManager.RemovePet(poolType, mNewSim, true);
                    }

                    return(base.PrivateUpdate(frame));
                }
                else
                {
                    IncStat("Pool Empty: " + poolType);
                }
            }

            if (Manager.GetValue <ScheduledImmigrationScenario.GaugeOption, int>() > 0)
            {
                return(base.PrivateUpdate(frame));
            }
            else
            {
                IncStat("Immigration Disabled");
                return(false);
            }
        }