Ejemplo n.º 1
0
        public static PetPoolType GetPetPool(SimDescription sim, out bool noPool)
        {
            noPool = false;

            if (!GameUtils.IsInstalled(ProductVersion.EP5))
            {
                return(PetPoolType.None);
            }

            if (sim.IsHuman)
            {
                return(PetPoolType.None);
            }

            List <PetPoolType> check = new List <PetPoolType>();

            switch (sim.Species)
            {
            case CASAgeGenderFlags.Horse:
                check.Add(PetPoolType.AdoptHorse);
                check.Add(PetPoolType.BuySellHorse);
                check.Add(PetPoolType.WildHorse);
                check.Add(PetPoolType.Stallion);
                check.Add(PetPoolType.Unicorn);
                break;

            case CASAgeGenderFlags.Cat:
                check.Add(PetPoolType.AdoptCat);
                check.Add(PetPoolType.StrayCat);
                break;

            case CASAgeGenderFlags.LittleDog:
            case CASAgeGenderFlags.Dog:
                check.Add(PetPoolType.AdoptDog);
                check.Add(PetPoolType.StrayDog);
                break;
            }

            if (check.Count == 0)
            {
                noPool = true;
            }
            else
            {
                foreach (PetPoolType type in check)
                {
                    if (PetPoolManager.IsPetInPoolType(sim, type))
                    {
                        return(type);
                    }
                }
            }

            return(PetPoolType.None);
        }
Ejemplo n.º 2
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();
     }
 }
Ejemplo n.º 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);
                }
            }
        }