Beispiel #1
0
        public static void RegenerateDescendants()
        {
            if (!GameUtils.IsFutureWorld() || Traveler.Settings.mDisableDescendants)
            {
                return;
            }

            try
            {
                OccultProcessed.Clear();

                foreach (FutureDescendantService.FutureDescendantHouseholdInfo info in FutureDescendantService.sPersistableData.ActiveDescendantHouseholdsInfo)
                {
                    if (info.HasAncestorFromHousehold(Household.ActiveHousehold) && info.DescendantHousehold != null)
                    {
                        Annihilation.Cleanse(info.DescendantHousehold);
                    }
                }

                PostFutureWorldLoadProcess(GetInstance());
            }
            catch (Exception e)
            {
                Common.Exception("RegenerateDescendants", e);
            }
        }
Beispiel #2
0
        protected override bool Run(MiniSimDescription me, bool singleSelection)
        {
            if (!Prompt(me))
            {
                return(false);
            }

            Annihilation.Cleanse(me);
            return(true);
        }
Beispiel #3
0
        public static void WipeDescendants()
        {
            if (FutureDescendantService.sPersistableData == null)
            {
                return;
            }

            if (Household.ActiveHousehold == null)
            {
                return;
            }

            foreach (FutureDescendantService.FutureDescendantHouseholdInfo info in FutureDescendantService.sPersistableData.ActiveDescendantHouseholdsInfo)
            {
                if (info.HasAncestorFromHousehold(Household.ActiveHousehold))
                {
                    FutureDescendantService.sPersistableData.InvalidDescendantHouseholdsInfo.Add(info);

                    if (info.DescendantHousehold != null && !GameUtils.IsFutureWorld())
                    {
                        foreach (ulong id in info.mHouseholdMembers)
                        {
                            MiniSimDescription mini = MiniSims.Find(id);
                            if (mini != null)
                            {
                                foreach (SimDescription desc in Household.ActiveHousehold.AllSimDescriptions)
                                {
                                    mini.RemoveMiniRelatioship(desc.SimDescriptionId);
                                }
                            }
                        }
                    }

                    if (info.DescendantHousehold != null && GameUtils.IsFutureWorld())
                    {
                        Annihilation.Cleanse(info.DescendantHousehold);
                    }
                }
            }

            foreach (FutureDescendantService.FutureDescendantHouseholdInfo info in FutureDescendantService.sPersistableData.InvalidDescendantHouseholdsInfo)
            {
                FutureDescendantService.sPersistableData.ActiveDescendantHouseholdsInfo.Remove(info);
            }

            if (GameUtils.IsFutureWorld())
            {
                // will axe map tags
                GetInstance().RemoveInactiveDescendantHouseholds();
            }
        }
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("CleanupFakeMetaAutonomy");

            if (FakeMetaAutonomy.mToDestroy != null)
            {
                foreach (SimDescription sim in new List <SimDescription>(FakeMetaAutonomy.mToDestroy))
                {
                    if (Annihilation.Cleanse(sim))
                    {
                        Overwatch.Log("Destroyed: " + sim.FullName);

                        FakeMetaAutonomy.mToDestroy.Remove(sim);
                    }
                }
            }

            if ((FakeMetaAutonomy.Instance != null) && (FakeMetaAutonomy.Instance.mPool != null))
            {
                int index = 0;
                while (index < FakeMetaAutonomy.Instance.mPool.Count)
                {
                    SimDescription sim = FakeMetaAutonomy.Instance.mPool[index];

                    bool keep = true;
                    if (sim == null)
                    {
                        keep = false;
                    }
                    else if (sim.Genealogy == null)
                    {
                        keep = false;
                    }

                    if (keep)
                    {
                        index++;
                    }
                    else
                    {
                        Overwatch.Log("Removed: " + sim.FullName);

                        FakeMetaAutonomy.Instance.mPool.RemoveAt(index);
                    }
                }
            }
        }
Beispiel #5
0
        protected override void PrivatePerformAction(bool prompt)
        {
            try
            {
                Overwatch.Log("Kill All Homeless");

                if ((!prompt) || (AcceptCancelDialog.Show(Common.Localize("KillAllHomeless:Prompt"))))
                {
                    List <Household> list = new List <Household>();
                    int iSimCount         = 0;

                    foreach (Household household in Household.sHouseholdList)
                    {
                        if (household.IsSpecialHousehold)
                        {
                            continue;
                        }

                        if (household.InWorld)
                        {
                            continue;
                        }

                        if (Households.IsPassport(household))
                        {
                            continue;
                        }

                        if (Households.IsRole(household))
                        {
                            continue;
                        }

                        if (Households.IsLunarCycleZombie(household))
                        {
                            continue;
                        }

                        if (Households.IsActiveDaycare(household))
                        {
                            continue;
                        }

                        iSimCount += Households.NumSims(household);
                        list.Add(household);
                    }

                    foreach (Household household in list)
                    {
                        Annihilation.Cleanse(household);
                    }

                    if (iSimCount > 0)
                    {
                        Overwatch.AlarmNotify(Common.Localize("KillAllHomeless:Success", false, new object[] { iSimCount }));
                    }
                }
            }
            catch (Exception exception)
            {
                Common.Exception(Name, exception);
            }
        }
Beispiel #6
0
        public static bool AttemptServiceDisposal(SimDescription sim, bool oldAge, string reason)
        {
            if (sim == null)
            {
                return(false);
            }

            bool hasChildren = (Relationships.GetChildren(sim).Count > 0);

            if (!oldAge)
            {
                if (hasChildren)
                {
                    return(false);
                }

                if ((sim.IsHuman) && (sim.TeenOrAbove))
                {
                    bool found = false;
                    foreach (SimDescription other in Households.Humans(sim.Household))
                    {
                        if (other == sim)
                        {
                            continue;
                        }

                        if (other.TeenOrAbove)
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        return(false);
                    }
                }

                foreach (Household house in Household.GetHouseholdsLivingInWorld())
                {
                    if (Notifications.HasSignificantRelationship(house, sim))
                    {
                        return(false);
                    }
                }
            }

            if (hasChildren)
            {
                if (!Annihilation.Perform(sim, false))
                {
                    return(false);
                }

                if (Common.kDebugging)
                {
                    Common.DebugNotify("Disposed: " + sim.FullName + " (" + sim.Species + ")" + Common.NewLine + reason);
                }
            }
            else
            {
                if (!Annihilation.Cleanse(sim))
                {
                    return(false);
                }

                if (Common.kDebugging)
                {
                    Common.DebugNotify("Cleansed: " + sim.FullName + " (" + sim.Species + ")" + Common.NewLine + reason);
                }
            }

            return(true);
        }
Beispiel #7
0
 protected override bool Run(MiniSimDescription me, bool singleSelection)
 {
     return(Annihilation.Cleanse(me));
 }
        public static void RunStatic()
        {
            if (!GameUtils.IsInstalled(ProductVersion.EP11))
            {
                return;
            }

            Overwatch.Log("CleanupFutureDescendantService");

            FutureDescendantService instance = FutureDescendantService.GetInstance();

            if (instance != null)
            {
                List <ulong> removeFromMap        = new List <ulong>();
                List <ulong> simsToPossiblyVanish = new List <ulong>();
                List <ulong> simsToKeep           = new List <ulong>();
                Dictionary <ulong, FutureDescendantService.FutureDescendantHouseholdInfo> houses = new Dictionary <ulong, FutureDescendantService.FutureDescendantHouseholdInfo>();

                foreach (ulong num in FutureDescendantService.sPersistableData.DescendantHouseholdsMap.Keys)
                {
                    bool flag = false;
                    IMiniSimDescription ancestorSim = SimDescription.GetIMiniSimDescription(num);
                    if (ancestorSim == null)
                    {
                        flag = true;
                        removeFromMap.Add(num);
                    }

                    foreach (FutureDescendantService.FutureDescendantHouseholdInfo info in FutureDescendantService.sPersistableData.DescendantHouseholdsMap[num])
                    {
                        Household descendantHousehold = info.DescendantHousehold;

                        if (descendantHousehold != null)
                        {
                            if (!houses.ContainsKey(info.mHouseholdId))
                            {
                                houses.Add(info.mHouseholdId, info);
                            }

                            foreach (SimDescription desc in descendantHousehold.SimDescriptions)
                            {
                                if (flag)
                                {
                                    if (!simsToKeep.Contains(desc.SimDescriptionId))
                                    {
                                        simsToPossiblyVanish.Add(desc.SimDescriptionId);
                                    }
                                }
                                else
                                {
                                    if (simsToPossiblyVanish.Contains(desc.SimDescriptionId))
                                    {
                                        simsToPossiblyVanish.Remove(desc.SimDescriptionId);
                                    }
                                    simsToKeep.Add(desc.SimDescriptionId);
                                }
                            }
                        }
                    }
                }

                foreach (ulong num in removeFromMap)
                {
                    FutureDescendantService.sPersistableData.DescendantHouseholdsMap.Remove(num);

                    Overwatch.Log(" Missing Removed: " + num);
                }

                if (!GameUtils.IsFutureWorld())
                {
                    // because sims can possibly be deleted beyond here and I don't believe you can delete sims who are minisims while in the homeworld?
                    return;
                }
                else
                {
                    // this causes a script error if it deletes Sims while cleanup of relationships is running so let that run and come back in a bit...
                    if (!wasRescheduled)
                    {
                        new Common.AlarmTask(10, TimeUnit.Minutes, RunStatic);
                        wasRescheduled = true;
                        return;
                    }
                }

                Dictionary <ulong, SimDescription> sims = SimListing.GetResidents(false);
                foreach (SimDescription sim in sims.Values)
                {
                    if (sim.TraitManager == null)
                    {
                        continue;
                    }

                    foreach (KeyValuePair <ulong, Trait> trait in sim.TraitManager.mValues)
                    {
                        if ((trait.Value.Guid == TraitNames.DescendantHiddenTrait) && (!simsToKeep.Contains(sim.SimDescriptionId)) && (sim.Household != null && !sim.Household.IsActive))
                        {
                            simsToPossiblyVanish.Add(sim.SimDescriptionId);
                            break;
                        }
                    }
                }

                foreach (ulong desc in simsToPossiblyVanish)
                {
                    IMiniSimDescription mini = SimDescription.GetIMiniSimDescription(desc);
                    if (mini != null)
                    {
                        Annihilation.Cleanse(mini);

                        if (houses.ContainsKey(mini.LotHomeId))
                        {
                            houses[mini.LotHomeId].mHouseholdMembers.Remove(desc);
                        }
                    }

                    Overwatch.Log(" Annihilated: " + mini.FullName);
                }

                FutureDescendantService.sPersistableData.ActiveDescendantHouseholdsInfo = new List <FutureDescendantService.FutureDescendantHouseholdInfo>();
                foreach (KeyValuePair <ulong, FutureDescendantService.FutureDescendantHouseholdInfo> houseInfo in houses)
                {
                    Household house = houseInfo.Value.DescendantHousehold;
                    if ((house != null) && (houseInfo.Value.mHouseholdMembers.Count == 0))
                    {
                        Annihilation.Cleanse(house);
                        Overwatch.Log(" Annihilated household: " + house.Name);
                    }
                    else
                    {
                        FutureDescendantService.sPersistableData.ActiveDescendantHouseholdsInfo.Add(houseInfo.Value);
                    }
                }

                FutureDescendantService.sPersistableData.InvalidDescendantHouseholdsInfo.Clear();
                houses = null;
                simsToPossiblyVanish = null;
                simsToKeep           = null;
            }
        }