Esempio n. 1
0
        private static void HerdBehaviorCallback()
        {
            try
            {
                using (BaseWorldReversion reversion = new BaseWorldReversion())
                {
                    PetPool pool;
                    if (!PetPoolManager.TryGetPetPool(PetPoolType.WildHorse, out pool))
                    {
                        return;
                    }

                    WildHorsePool ths = pool as WildHorsePool;

                    ths.HerdBehaviorCallback();
                }
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception("HerdBehaviorCallback", e);
            }
        }
Esempio n. 2
0
            public bool Apply(SimDescription me)
            {
                if (me.CreatedSim == Sim.ActiveActor)
                {
                    LotManager.SelectNextSim();
                }

                Household house = me.Household;

                if (house != null)
                {
                    house.Remove(me, !house.IsServiceNpcHousehold);
                }

                try
                {
                    if (PetPoolManager.AddPet(Value, me))
                    {
                        return(true);
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(me, e);

                    if ((house != null) && (me.Household == null))
                    {
                        house.Add(me);
                    }
                }

                return(false);
            }
Esempio n. 3
0
            public override bool Test(Sim a, EquestrianCenter target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                PetPool pool;

                if (!PetPoolManager.TryGetPetPool(PetPoolType.BuySellHorse, out pool, false))
                {
                    greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(EquestrianCenter.BuyHorse.LocalizeString(a.IsFemale, "PoolEmpty", new object[0x0]));
                    return(false);
                }

                /*
                 * if (!a.Household.CanAddSpeciesToHousehold(CASAgeGenderFlags.Horse, 0x1, true))
                 * {
                 *  greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(EquestrianCenter.BuyHorse.LocalizeString(a.IsFemale, "TooManyPetsInHousehold", new object[0x0]));
                 *  return false;
                 * }
                 */

                Lot lotHome = a.LotHome;

                if ((lotHome != null) && lotHome.HasVirtualResidentialSlots)
                {
                    greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(PetAdoption.LocalizeString(a.IsFemale, "CannotAdoptHorse", new object[0]));
                    return(false);
                }

                return(true);
            }
Esempio n. 4
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);
        }
Esempio n. 5
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. 6
0
        public static void StartAlarm()
        {
            PetPool pool;

            if ((!Sims3.SimIFace.Environment.HasEditInGameModeSwitch) && PetPoolManager.TryGetPetPool(PetPoolType.WildHorse, out pool))
            {
                WildHorsePool pool2 = pool as WildHorsePool;
                if (pool2 != null)
                {
                    pool2.mWildHorseInstantiationInProgress = false;

                    AlarmManager.Global.RemoveAlarm(WildHorsePool.mHerdBehaviorAlarm);
                    WildHorsePool.mHerdBehaviorAlarm = AlarmManager.Global.AddAlarmRepeating(WildHorsePool.kHerdBehaviorFrequency, TimeUnit.Minutes, HerdBehaviorCallback, WildHorsePool.kHerdBehaviorFrequency, TimeUnit.Minutes, "WildHorseHerdBehavior", AlarmType.NeverPersisted, Household.PetHousehold);

                    AlarmManager.Global.AlarmWillYield(WildHorsePool.mHerdBehaviorAlarm);

                    WildHorsePool.sTimestampSinceLastLotChange = SimClock.CurrentTime();
                }
            }
        }
Esempio n. 7
0
        public static void AlterPetPool()
        {
            if (!GameUtils.IsInstalled(ProductVersion.EP5))
            {
                return;
            }

            Common.StringBuilder msg = new Common.StringBuilder();

            foreach (KeyValuePair <PetPoolType, PetPoolConfig> element in PetPoolManager.sPetConfigManager)
            {
                msg += Common.NewLine + element.Key;

                int poolSize = Settings.GetMaximumPoolSize(element.Key);
                if (poolSize == -1)
                {
                    continue;
                }

                msg += Common.NewLine + " Maximum: " + poolSize;

                element.Value.mEP5Range[1]        = poolSize;
                element.Value.mEP5Range[2]        = poolSize;
                element.Value.mOtherWorldRange[1] = poolSize;
                element.Value.mOtherWorldRange[2] = poolSize;

                List <SimDescription> destroyed = PetPoolManager.GetPetsByType(element.Key);

                int remove = PetPoolManager.GetPoolSize(element.Key) - poolSize;

                msg += Common.NewLine + " Remove: " + remove;

                if (remove > 0)
                {
                    PetPoolManager.RefreshPool(element.Key, remove);

                    List <SimDescription> remaining = PetPoolManager.GetPetsByType(element.Key);
                    if (remaining != null)
                    {
                        foreach (SimDescription remain in remaining)
                        {
                            destroyed.Remove(remain);
                        }
                    }

                    int destroyedCount = 0;
                    foreach (SimDescription destroy in destroyed)
                    {
                        if (ServiceCleanup.AttemptServiceDisposal(destroy, false, "Too Many " + element.Key))
                        {
                            destroyedCount++;
                        }
                        else
                        {
                            Household.PetHousehold.Add(destroy);
                        }
                    }

                    msg += Common.NewLine + " Destroyed: " + destroyedCount;
                }

                PetPool pool;
                if (PetPoolManager.TryGetPetPool(element.Key, out pool))
                {
                    if (pool.mSimDescriptionIds == null)
                    {
                        // Setting this off null will ensure that MaximumThresholdReached() returns TRUE for a size of "0"
                        pool.mSimDescriptionIds = new List <ulong>();

                        msg += Common.NewLine + " Repooled";
                    }
                }
            }

            Common.DebugNotify(msg);
        }
Esempio n. 8
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. 9
0
        public static bool Perform(SimDescription sim, bool cleanse)
        {
            if (sim == null)
            {
                return(false);
            }

            Common.StringBuilder msg = new Common.StringBuilder("Perform" + Common.NewLine);

            Household house = sim.Household;

            try
            {
                Sim createdSim = sim.CreatedSim;

                if (createdSim != null)
                {
                    createdSim.ReservedVehicle = null;
                }

                if (PetAdoption.sNeighborAdoption != null)
                {
                    if (PetAdoption.sNeighborAdoption.mMother == sim)
                    {
                        try
                        {
                            PetAdoption.ResetNeighborAdoption();
                        }
                        catch (Exception e)
                        {
                            Common.Exception(sim, e);
                        }
                        finally
                        {
                            PetAdoption.sNeighborAdoption = null;
                        }
                    }
                    else
                    {
                        PetAdoption.sNeighborAdoption.mPetsToAdopt.Remove(sim);
                    }
                }

                foreach (Service service in Services.AllServices)
                {
                    try
                    {
                        if (service == null)
                        {
                            continue;
                        }

                        msg += Common.NewLine + "Service: " + service.GetType();

                        if (sim.CreatedSim != null)
                        {
                            service.RemoveAssignment(sim.CreatedSim);
                        }

                        service.RemovePreferredSim(sim);

                        service.mPool.Remove(sim);

                        ResortWorker resortWorker = service as ResortWorker;
                        if (resortWorker != null)
                        {
                            if (resortWorker.mWorkerInfo != null)
                            {
                                List <ObjectGuid> remove = new List <ObjectGuid>();

                                foreach (KeyValuePair <ObjectGuid, ResortWorker.WorkerInfo> info in resortWorker.mWorkerInfo)
                                {
                                    if ((info.Value.CurrentSimDescriptionID == sim.SimDescriptionId) ||
                                        (info.Value.DesiredSimDescriptionID == sim.SimDescriptionId))
                                    {
                                        remove.Add(info.Key);
                                    }
                                }

                                foreach (ObjectGuid rem in remove)
                                {
                                    resortWorker.mWorkerInfo[rem] = new ResortWorker.WorkerInfo();
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, null, msg, e);
                    }
                }

                msg += Common.NewLine + "A";

                List <Household> houses = new List <Household>();
                if (house != null)
                {
                    houses.Add(house);
                }

                foreach (Household check in Household.sHouseholdList)
                {
                    if (check == house)
                    {
                        continue;
                    }

                    if (check.Contains(sim))
                    {
                        houses.Add(check);
                    }
                }

                foreach (Household remove in houses)
                {
                    Household.HouseholdSimsChangedCallback changedCallback = null;

                    try
                    {
                        changedCallback             = remove.HouseholdSimsChanged;
                        remove.HouseholdSimsChanged = null;

                        remove.Remove(sim, !remove.IsSpecialHousehold);
                    }
                    finally
                    {
                        remove.HouseholdSimsChanged = changedCallback;
                    }
                }

                msg += Common.NewLine + "B";

                try
                {
                    if (cleanse)
                    {
                        if (sim.LifeEventManager != null)
                        {
                            sim.LifeEventManager.Purge();
                        }
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(sim, null, msg, e);
                }

                msg += Common.NewLine + "C";

                RemoveSimDescriptionRelationships(sim);

                msg += Common.NewLine + "D";

                PetPoolManager.RemoveIdFromPool(sim.SimDescriptionId);

                msg += Common.NewLine + "E";

                try
                {
                    if (sim.CareerManager != null)
                    {
                        sim.CareerManager.LeaveAllJobs(Career.LeaveJobReason.kDied);
                    }
                }
                catch (Exception e)
                {
                    sim.CareerManager.mJob    = null;
                    sim.CareerManager.mSchool = null;

                    Common.Exception(sim, null, msg, e);
                }

                msg += Common.NewLine + "F";

                if (sim.CASGenealogy == null)
                {
                    // Necessary to stop an error in MidLifeCrisisManager
                    sim.mGenealogy = new Genealogy(sim);
                }

                msg += Common.NewLine + "G";

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

                    sim.Partner = null;
                }
                catch (Exception e)
                {
                    Common.Exception(sim, null, msg, e);
                }

                msg += Common.NewLine + "H";

                if (sim.DeathStyle != SimDescription.DeathType.None)
                {
                    // Passing in a household can invoke the social worker, so don't bother
                    Urnstone.FinalizeSimDeath(sim, null /*house*/);
                }

                msg += Common.NewLine + "I";

                Urnstone urnstone = Urnstones.FindGhostsGrave(sim);

                msg += Common.NewLine + "J";

                if ((cleanse) && (urnstone != null))
                {
                    if (urnstone.InInventory)
                    {
                        Inventory inventory = Inventories.ParentInventory(urnstone);
                        if (inventory != null)
                        {
                            inventory.RemoveByForce(urnstone);
                        }
                    }

                    if (urnstone.DeadSimsDescription != null)
                    {
                        urnstone.DeadSimsDescription.Fixup();
                    }

                    try
                    {
                        urnstone.Dispose();
                    }
                    catch (Exception e)
                    {
                        Common.DebugException(sim, null, msg, e);
                    }

                    urnstone.Destroy();
                }

                msg += Common.NewLine + "K";

                if ((FakeMetaAutonomy.Instance != null) && (FakeMetaAutonomy.Instance.mPool != null))
                {
                    FakeMetaAutonomy.Instance.mPool.Remove(sim);
                }

                msg += Common.NewLine + "L";

                if (Sims3.Gameplay.Services.FakeMetaAutonomy.mToDestroy != null)
                {
                    Sims3.Gameplay.Services.FakeMetaAutonomy.mToDestroy.Remove(sim);
                }

                msg += Common.NewLine + "M";

                if ((houses.Contains(Household.ActiveHousehold)) && (sim.CreatedSim != null))
                {
                    HudModel model = HudController.Instance.Model as HudModel;

                    foreach (SimInfo info in model.mSimList)
                    {
                        if (info.mGuid == sim.CreatedSim.ObjectId)
                        {
                            model.RemoveSimInfo(info);
                            model.mSimList.Remove(info);
                            break;
                        }
                    }
                }

                msg += Common.NewLine + "N";

                try
                {
                    if (sim.AssignedRole != null)
                    {
                        sim.AssignedRole.RemoveSimFromRole();
                    }
                }
                catch (Exception e)
                {
                    Common.DebugException(sim, null, msg, e);

                    sim.AssignedRole = null;
                }

                msg += Common.NewLine + "O1";

                if ((CarNpcManager.Singleton != null) && (CarNpcManager.Singleton.NpcDriversManager != null))
                {
                    foreach (Stack <SimDescription> stack in CarNpcManager.Singleton.NpcDriversManager.mDescPools)
                    {
                        if (stack == null)
                        {
                            continue;
                        }

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

                        bool found = false;
                        foreach (SimDescription stackSim in stack)
                        {
                            if (stackSim == sim)
                            {
                                found = true;
                            }
                            else
                            {
                                sims.Add(stackSim);
                            }
                        }

                        if (found)
                        {
                            stack.Clear();

                            foreach (SimDescription stackSim in sims)
                            {
                                stack.Push(stackSim);
                            }
                        }
                    }
                }

                msg += Common.NewLine + "O2";

                if (cleanse)
                {
                    sim.Dispose();
                }

                msg += Common.NewLine + "P";

                if ((house != null) && (createdSim != null))
                {
                    house.OnMemberChanged(sim, createdSim);
                }
                return(true);
            }
            catch (Exception e)
            {
                Common.Exception(sim, null, msg, e);

                if (house != null)
                {
                    Household.HouseholdSimsChangedCallback changedCallback = null;

                    try
                    {
                        changedCallback            = house.HouseholdSimsChanged;
                        house.HouseholdSimsChanged = null;

                        house.Add(sim);
                    }
                    finally
                    {
                        house.HouseholdSimsChanged = changedCallback;
                    }
                }
                return(false);
            }
        }
Esempio n. 10
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);
            }
        }
Esempio n. 11
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (!ApplyAll)
            {
                List <IApplyOptionItem> services = new List <IApplyOptionItem>();

                foreach (ServiceType type in Enum.GetValues(typeof(ServiceType)))
                {
                    int count = 0;

                    bool found = false;

                    foreach (Service service in Services.AllServices)
                    {
                        if (service.ServiceType == type)
                        {
                            count = service.mPool.Count;

                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        continue;
                    }

                    services.Add(new StatusServiceType.Item(type, count));
                }

                foreach (PetPoolType type in Enum.GetValues(typeof(PetPoolType)))
                {
                    if (PetPoolManager.IsPoolFull(type))
                    {
                        continue;
                    }

                    int count = PetPoolManager.GetPoolSize(type);

                    services.Add(new StatusPetPool.Item(type, count));
                }

                if (GameUtils.IsInstalled(ProductVersion.EP10))
                {
                    services.Add(new MermaidServiceItem(CommonSpace.Helpers.Households.NumSims(Household.MermaidHousehold)));
                }

                IApplyOptionItem selection = new CommonSelection <IApplyOptionItem>(Name, me.FullName, services).SelectSingle();
                if (selection == null)
                {
                    return(false);
                }

                mPool = selection;
            }

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

            list.Add(me);

            if (!AddSim.TestForRemainingActive(list))
            {
                Common.Notify(Common.Localize("AddSim:ActiveFail"));
                return(false);
            }

            mPool.Apply(me);
            return(true);
        }