Beispiel #1
0
        public void OnWorldLoadFinished()
        {
            Overwatch.Log("CleanupCauseEffect");

            CauseEffectService instance = CauseEffectService.GetInstance();

            if (instance != null)
            {
                ulong timeTravelerSimID = instance.GetTimeTravelerSimID();
                if (MiniSimDescription.Find(timeTravelerSimID) == null)
                {
                    CauseEffectService.sPersistableData.TimeTravelerSimID = 0;

                    Overwatch.Log(" Removed Corrupt Time Traveler Referece");
                }

                List <ITimeStatueUiData> timeStatueData = instance.GetTimeAlmanacTimeStatueData();
                if (timeStatueData != null)
                {
                    foreach (ITimeStatueUiData data in timeStatueData)
                    {
                        TimeStatueRecordData record = data as TimeStatueRecordData;
                        if (record == null)
                        {
                            continue;
                        }

                        if (MiniSimDescription.Find(record.mRecordHolderId) == null)
                        {
                            record.mRecordHolderId = 0;

                            Overwatch.Log(" Removed Corrupt Record Holder Referece");
                        }
                    }
                }
            }
        }
Beispiel #2
0
            public static void Perform()
            {
                Dictionary <ulong, bool> taxiDrivers = new Dictionary <ulong, bool>();
                List <ulong>             paps        = new List <ulong>();

                if ((CarNpcManager.Singleton != null) && (CarNpcManager.Singleton.NpcDriversManager != null))
                {
                    for (int i = 0; i < CarNpcManager.Singleton.NpcDriversManager.mDescPools.Length; i++)
                    {
                        Stack <SimDescription> stack = CarNpcManager.Singleton.NpcDriversManager.mDescPools[i];

                        if (stack == null)
                        {
                            continue;
                        }

                        NpcDriversManager.NpcDrivers type = (NpcDriversManager.NpcDrivers)(i + 0x95d01441);

                        while (stack.Count > 10)
                        {
                            SimDescription sim = stack.Pop();

                            try
                            {
                                AttemptServiceDisposal(sim, false, "Too Many " + type);
                            }
                            catch (Exception e)
                            {
                                Common.Exception(sim, e);
                            }
                        }

                        foreach (SimDescription sim in stack)
                        {
                            if (taxiDrivers.ContainsKey(sim.SimDescriptionId))
                            {
                                continue;
                            }

                            taxiDrivers.Add(sim.SimDescriptionId, true);
                        }
                    }
                }

                Dictionary <ulong, bool> statueSims = new Dictionary <ulong, bool>();

                CauseEffectService instance = CauseEffectService.GetInstance();

                if (instance != null)
                {
                    statueSims[instance.GetTimeTravelerSimID()] = true;

                    List <ITimeStatueUiData> timeStatueData = instance.GetTimeAlmanacTimeStatueData();
                    if (timeStatueData != null)
                    {
                        foreach (ITimeStatueUiData data in timeStatueData)
                        {
                            TimeStatueRecordData record = data as TimeStatueRecordData;
                            if (record == null)
                            {
                                continue;
                            }

                            statueSims[record.mRecordHolderId] = true;
                        }
                    }
                }

                foreach (SimDescription sim in new List <SimDescription> (Households.All(Household.NpcHousehold)))
                {
                    try
                    {
                        if (SimTypes.IsDead(sim))
                        {
                            continue;
                        }

                        if (taxiDrivers.ContainsKey(sim.SimDescriptionId))
                        {
                            continue;
                        }

                        CommonCorrections(sim);

                        if (SimTypes.InServicePool(sim, ServiceType.GrimReaper))
                        {
                            continue;
                        }

                        if (statueSims.ContainsKey(sim.SimDescriptionId))
                        {
                            continue;
                        }

                        uint spanLevel = 0;
                        OptionsModel.GetOptionSetting("AgingInterval", out spanLevel);

                        float averageElderAge = AgingManager.Singleton.GetAverageSimLifespanInDays((int)spanLevel);

                        ServiceType type = ServiceType.None;
                        if (sim.CreatedByService != null)
                        {
                            type = sim.CreatedByService.ServiceType;
                        }

                        if (AgingManager.Singleton.GetCurrentAgeInDays(sim) > averageElderAge)
                        {
                            if (sim.LotHome == null)
                            {
                                bool isRole = sim.AssignedRole != null;
                                AttemptServiceDisposal(sim, true, "Too Old " + (!isRole ? type.ToString() : sim.AssignedRole.Type.ToString()));
                            }
                        }

                        if (sim.AssignedRole != null && sim.AssignedRole is RolePaparazzi)
                        {
                            paps.Add(sim.SimDescriptionId);
                        }

                        if (sim.AssignedRole != null)
                        {
                            continue;
                        }

                        if (SimTypes.IsOccult(sim, OccultTypes.ImaginaryFriend))
                        {
                            bool found = false;
                            foreach (ImaginaryDoll doll in Sims3.Gameplay.Queries.GetObjects <ImaginaryDoll>())
                            {
                                if (sim.SimDescriptionId == doll.mLiveStateSimDescId)
                                {
                                    found = true;
                                    break;
                                }
                            }

                            if (found)
                            {
                                continue;
                            }

                            AttemptServiceDisposal(sim, false, "Imaginary");
                        }
                        else if (SimTypes.IsOccult(sim, OccultTypes.Genie))
                        {
                            bool found = false;
                            foreach (GenieLamp lamp in Sims3.Gameplay.Queries.GetObjects <GenieLamp>())
                            {
                                if (sim == lamp.mGenieDescription)
                                {
                                    found = true;
                                    break;
                                }
                            }

                            if (found)
                            {
                                continue;
                            }

                            AttemptServiceDisposal(sim, false, "Genie");
                        }
                        else if (sim.IsBonehilda)
                        {
                            bool found = false;
                            foreach (BonehildaCoffin coffin in Sims3.Gameplay.Queries.GetObjects <BonehildaCoffin>())
                            {
                                if (sim == coffin.mBonehilda)
                                {
                                    found = true;
                                    break;
                                }
                            }

                            if (found)
                            {
                                continue;
                            }

                            AttemptServiceDisposal(sim, false, "BoneHilda");
                        }
                        else if ((sim.AssignedRole == null) && (!SimTypes.InServicePool(sim)))
                        {
                            AttemptServiceDisposal(sim, false, "No Purpose");
                        }
                        else if ((type != ServiceType.None) && (sim.Age & ServiceNPCSpecifications.GetAppropriateAges(type.ToString())) == CASAgeGenderFlags.None)
                        {
                            AttemptServiceDisposal(sim, false, "Wrong Age " + type);
                        }
                        else if (!ServiceNPCSpecifications.ShouldUseServobot(type.ToString()) && sim.IsEP11Bot)
                        {
                            AttemptServiceDisposal(sim, false, "Not EP11 Bot " + type);
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, e);
                    }
                }

                // kill extra paps
                if (paps.Count > Register.Settings.mMaximumPaparazzi)
                {
                    int count = paps.Count;
                    while (count > Register.Settings.mMaximumPaparazzi && count > 0)
                    {
                        SimDescription sim = SimDescription.Find(paps[0]);
                        if (sim != null)
                        {
                            AttemptServiceDisposal(sim, false, "Too many Paparazzi");
                        }

                        paps.Remove(paps[0]);
                        count = count - 1;
                    }
                }

                foreach (SimDescription sim in new List <SimDescription> (Households.All(Household.PetHousehold)))
                {
                    try
                    {
                        if (SimTypes.IsDead(sim))
                        {
                            continue;
                        }

                        CommonCorrections(sim);

                        if ((sim.IsDeer) || (sim.IsRaccoon))
                        {
                            if (sim.AssignedRole == null)
                            {
                                AttemptServiceDisposal(sim, false, "Roleless");
                            }
                            else if (sim.Elder)
                            {
                                AttemptServiceDisposal(sim, true, "Elder");
                            }
                        }
                        else
                        {
                            bool        noPool;
                            PetPoolType pool = SimTypes.GetPetPool(sim, out noPool);

                            if ((!noPool) && (pool == PetPoolType.None))
                            {
                                AttemptServiceDisposal(sim, false, "Not Pooled");
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, e);
                    }
                }
            }