Example #1
0
        public override bool Run()
        {
            try
            {
                if (Target is Sim)
                {
                    Perform((Target as Sim).SimDescription, true);
                }
                else
                {
                    foreach (SimDescription sim in SimListing.GetResidents(false).Values)
                    {
                        if (SimTypes.InServicePool(sim))
                        {
                            continue;
                        }

                        Perform(sim, false);
                    }
                }
            }
            catch (Exception exception)
            {
                Common.Exception(Actor, Target, exception);
            }
            return(true);
        }
Example #2
0
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("CleanupCompletedOpportunities");

            Dictionary <ulong, SimDescription> sims = SimListing.GetResidents(false);

            foreach (SimDescription sim in sims.Values)
            {
                if (sim.Household == null)
                {
                    continue;
                }

                if (sim.CreatedSim == null)
                {
                    continue;
                }

                if (sim.CreatedSim.OpportunityManager == null)
                {
                    continue;
                }

                foreach (Opportunity opp in sim.CreatedSim.OpportunityManager.List)
                {
                    if (sim.Household.mCompletedHouseholdOpportunities.Remove((ulong)opp.Guid))
                    {
                        Overwatch.Log("Removed Opportunity: " + opp.Guid);
                    }
                }
            }
        }
Example #3
0
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("CleanupAging");

            new Common.AlarmTask(4, TimeUnit.Hours, OnCheckAging, 4, TimeUnit.Hours);

            Dictionary <SimDescription, AgingData> agingData = new Dictionary <SimDescription, AgingData>();

            Dictionary <ulong, SimDescription> sims = SimListing.GetResidents(false);

            foreach (SimDescription sim in sims.Values)
            {
                if (sim.AgingState != null)
                {
                    agingData.Add(sim, new AgingData(sim.AgingState));
                }

                AgingManager.Singleton.RemoveSimDescription(sim);
            }

            RemoveDanglingAgeUpAlarms();

            foreach (SimDescription sim in sims.Values)
            {
                if (sim.AgingEnabled)
                {
                    if ((SimTypes.InServicePool(sim, Sims3.Gameplay.Services.ServiceType.GrimReaper)) || (sim.IsRaccoon) || (sim.IsDeer))
                    {
                        sim.AgingEnabled = false;
                    }
                    else
                    {
                        AgingManager.Singleton.AddSimDescription(sim);

                        if ((sim.AgingState != null) && (agingData.ContainsKey(sim)))
                        {
                            agingData[sim].Reset(sim, sim.AgingState);
                        }
                    }
                }
                else
                {
                    if (sim.AgingState == null)
                    {
                        sim.AgingState = new AgingState(sim);
                    }
                }
            }

            /*
             * if (!GameStates.IsOnVacation)
             * {
             *  foreach (MiniSimDescription description in MiniSimDescription.GetVacationWorldSimDescriptions())
             *  {
             *      if (description.mDeathStyle != SimDescription.DeathType.None) continue;
             *
             *      description.mbAgingEnabled = true;
             *  }
             * }*/
        }
Example #4
0
        public static List <MiniSimDescription> GetVacationWorldSimDescriptions()
        {
            Dictionary <ulong, SimDescription> allSims = SimListing.GetResidents(false);

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

            if (MiniSimDescription.sMiniSims != null)
            {
                WorldName currentWorld = GameUtils.GetCurrentWorld();

                foreach (MiniSimDescription description in MiniSimDescription.sMiniSims.Values)
                {
                    // Added to allow for Traveler miniSims
                    if ((description.HomeWorld == WorldName.UserCreated) && (currentWorld == WorldName.UserCreated))
                    {
                        if (allSims.ContainsKey(description.SimDescriptionId))
                        {
                            continue;
                        }

                        list.Add(description);
                    }
                    else if (GameUtils.GetWorldType(description.HomeWorld) == WorldType.Vacation)
                    {
                        list.Add(description);
                    }
                    else if (GameUtils.GetWorldType(description.HomeWorld) == WorldType.Future)
                    {
                        list.Add(description);
                    }
                }
            }
            return(list);
        }
Example #5
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (!ApplyAll)
            {
                List <Item> allOptions = GetOptions(me);

                Dictionary <ulong, SimDescription> sims = SimListing.GetResidents(false);

                foreach (Item option in allOptions)
                {
                    foreach (SimDescription sim in sims.Values)
                    {
                        if (option.Test(sim, false, me))
                        {
                            option.IncCount();
                        }
                    }
                }

                Item choice = new CommonSelection <Item>(Name, me.FullName, allOptions, Auxillary).SelectSingle();
                if (choice == null)
                {
                    return(false);
                }

                mChoice = choice;
            }

            mChoice.Perform(me, ApplyAll);
            return(true);
        }
Example #6
0
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("FixActiveTopics");

            Dictionary <ulong, SimDescription> sims = SimListing.GetResidents(false);

            foreach (SimDescription sim in sims.Values)
            {
                if (sim.CreatedSim == null)
                {
                    continue;
                }
                if (sim.SkillManager == null)
                {
                    continue;
                }

                foreach (Skill skill in sim.SkillManager.List)
                {
                    if (skill.SkillLevel < 1)
                    {
                        continue;
                    }
                    switch (skill.Guid)
                    {
                    // Not sure why these don't work on their own, it may be the active
                    // topic limit. Either way readding them should troop the limit and fix
                    // them if they are truly broken
                    case SkillNames.Bartending:
                        ActiveTopic.AddToSim(sim.CreatedSim, "Bartending Skill");
                        Overwatch.Log("Readded Active Topic - Bartending Skill: " + sim.FullName);
                        break;

                    case SkillNames.Charisma:
                        ActiveTopic.AddToSim(sim.CreatedSim, "Smooth Recovery");
                        Overwatch.Log("Readded Active Topic - Charisma Skill: " + sim.FullName);
                        break;

                    case SkillNames.Logic:
                        if (skill.SkillLevel >= LogicSkill.kSkillLevelForSchoolTutor)
                        {
                            ActiveTopic.AddToSim(sim.CreatedSim, "Logic Skill");
                            Overwatch.Log("Readded Active Topic - Logic Skill: " + sim.FullName);
                        }
                        break;

                    case SkillNames.MartialArts:
                        ActiveTopic.AddToSim(sim.CreatedSim, "Martial Arts Skill");
                        Overwatch.Log("Readded Active Topic - Martial Arts Skill: " + sim.FullName);
                        break;

                    // hopelessly broken regardless
                    case SkillNames.Science:
                        ActiveTopic.AddToSim(sim.CreatedSim, "Science Skill");
                        Overwatch.Log("Readded Active Topic - Science Skill: " + sim.FullName);
                        break;
                    }
                }
            }
        }
Example #7
0
        public static void GenerateMoneyGraphData()
        {
            moneyGraph.Clear();

            int max = 0;
            int min = 0;
            Dictionary <ulong, int> cashInfo = new Dictionary <ulong, int>();

            foreach (KeyValuePair <ulong, SimDescription> val in SimListing.GetResidents(false))
            {
                if (!SimTypes.IsSpecial(val.Value) && val.Value.Household != null)
                {
                    //Common.Notify("GenerateMoneyGraph: Working on " + val.Value.FullName + "(" + val.Value.SimDescriptionId + ")");
                    int debtnum = 0;
                    if (sGetDebtAndNetworth.Valid)
                    {
                        //Common.Notify("Pulling debt");
                        string debt = string.Empty;
                        debt = sGetDebtAndNetworth.Invoke <string>(new object[] { val.Value, 1 });

                        //Common.Notify("Debt returned: " + debt);

                        if (debt != string.Empty)
                        {
                            Match match = Regex.Match(debt, @"(\d+)");
                            if (match.Success)
                            {
                                debtnum = int.Parse(match.Groups[1].Value);
                                //Common.Notify("Found debt: " + debtnum);
                            }
                        }
                    }

                    int cash = val.Value.Household.FamilyFunds - debtnum - val.Value.Household.UnpaidBills;
                    //Common.Notify("Cash: " + cash + "FF: " + val.Value.Household.FamilyFunds + " UB: " + val.Value.Household.UnpaidBills);
                    cashInfo.Add(val.Value.SimDescriptionId, cash);

                    if (cash > max)
                    {
                        max = cash;
                    }

                    if (cash < min || min == 0)
                    {
                        min = cash;
                    }
                }
            }

            foreach (KeyValuePair <ulong, int> vals in cashInfo)
            {
                int   townWealthPercent = (vals.Value - min);
                float twp = townWealthPercent / (max - min) * 100;
                townWealthPercent = (int)Math.Floor(twp);

                //Common.Notify("TWP (" + vals.Key + "): " + townWealthPercent + " Value: " + vals.Value + " min: " + min + " max: " + max);
                moneyGraph.Add(vals.Key, townWealthPercent);
            }
        }
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("CleanupOpportunityHistory");

            Dictionary <ulong, SimDescription> sims = SimListing.GetResidents(false);

            foreach (SimDescription sim in sims.Values)
            {
                Corrections.CleanupOpportunities(sim, true, Overwatch.Log);
            }
        }
Example #9
0
        public static bool OnTestForVampires(SimScenarioFilter.Parameters personality, SimDescription actor, SimDescription potential)
        {
            foreach (SimDescription sim in SimListing.GetResidents(false).Values)
            {
                if (SimTypes.IsOccult(sim, OccultTypes.Vampire))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #10
0
        public void OnWorldLoadFinished()
        {
            new Common.ImmediateEventListener(EventTypeId.kSocialInteraction, OnSocialEvent);
            new Common.ImmediateEventListener(EventTypeId.kRelationshipLTRChanged, OnLTRChanged);

            sPreviousState.Clear();

            foreach (SimDescription sim in SimListing.GetResidents(false).Values)
            {
                foreach (Relationship relation in Relationship.Get(sim))
                {
                    SetPreviousState(sim, relation.GetOtherSimDescription(sim), relation.CurrentLTR);
                }
            }
        }
Example #11
0
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("CleanupDnPExportData");

            foreach (SimDescription sim in SimListing.GetResidents(true).Values)
            {
                if (sim.DnPExportData == null)
                {
                    continue;
                }

                sim.DnPExportData = null;

                Overwatch.Log("  Data removed " + sim.FullName);
            }
        }
Example #12
0
        protected static void OnCheckAging()
        {
            AgingManager manager = AgingManager.Singleton;

            Dictionary <ulong, SimDescription> sims = SimListing.GetResidents(false);

            foreach (SimDescription sim in sims.Values)
            {
                if (IsOldEnoughToAge(manager, sim.AgingState))
                {
                    continue;
                }

                manager.CancelAgingAlarmsForSim(sim.AgingState);
            }
        }
Example #13
0
            protected override void OnPerform()
            {
                if (GameUtils.IsUniversityWorld())
                {
                    return;
                }

                Corrections.CleanupAcademics(null);

                Dictionary <ulong, SimDescription> sims = SimListing.GetResidents(false);

                List <ulong> remove = new List <ulong>();

                Household.ReportCardHelper reportCardHelper = null;

                foreach (KeyValuePair <ulong, AcademicController> controller in sControllers)
                {
                    bool success = false;

                    SimDescription sim;
                    if (sims.TryGetValue(controller.Key, out sim))
                    {
                        if (controller.Value.IncrementOneDay(sim, ref reportCardHelper))
                        {
                            success = true;
                        }
                    }

                    if (!success)
                    {
                        remove.Add(controller.Key);
                    }
                }

                if (reportCardHelper != null)
                {
                    float time = SimClock.HoursUntil(Household.kWhenReportCardArrives);
                    AlarmManager.Global.AddAlarm(time, TimeUnit.Hours, reportCardHelper.ReportCardArrives, "Report Card Arrives", AlarmType.AlwaysPersisted, Sim.ActiveActor);
                }

                foreach (ulong value in remove)
                {
                    sControllers.Remove(value);
                }
            }
Example #14
0
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("CleanupBrokenSkills");

            Dictionary <ulong, SimDescription> sims = SimListing.GetResidents(true);

            foreach (SimDescription sim in sims.Values)
            {
                Corrections.CleanupBrokenSkills(sim, Overwatch.Log);
            }

            if (GameUtils.IsInstalled(ProductVersion.EP5))
            {
                if (SkillManager.sPetSkillFatigueTuning.Count == 0)
                {
                    SkillManager.ParsePetSkillFatigueRates(XmlDbData.ReadData("Skills"));

                    Overwatch.Log("Loaded Missing Pet Fatigue Rates");
                }
            }
        }
Example #15
0
        protected static bool IsInvolvedInPregnancy(SimDescription sim)
        {
            if (sim.IsPregnant)
            {
                return(true);
            }

            foreach (SimDescription other in SimListing.GetResidents(false).Values)
            {
                if (!other.IsPregnant)
                {
                    continue;
                }

                if (other.Pregnancy.DadDescriptionId == sim.SimDescriptionId)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #16
0
        public void OnWorldLoadFinished()
        {
            new Common.DelayedEventListener(EventTypeId.kEventCareerHired, OnHired);

            if (AcademicCareer.GlobalTermLength == AcademicCareer.TermLength.kInvalid)
            {
                AcademicCareer.GlobalTermLength = AcademicCareer.TermLength.kOneWeek;
            }

            foreach (SimDescription sim in SimListing.GetResidents(false).Values)
            {
                if (sim.OccupationAsAcademicCareer == null)
                {
                    continue;
                }

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

                AddAcademic(sim, AcademicCareer.GlobalTermLength);
            }

            new AlarmTask();

            if (!GameUtils.IsUniversityWorld())
            {
                AnnexEx.OnWorldLoadFinished();

                foreach (Stadium stadium in Sims3.Gameplay.Queries.GetObjects <Stadium>())
                {
                    stadium.RabbitHoleProxy.MetaAds.Add(new InteractionObjectPair(Stadium.PlayCollegiateSport.Singleton, stadium.RabbitHoleProxy));
                    stadium.AddInteraction(Stadium.PlayCollegiateSport.Singleton);
                }
            }
        }
Example #17
0
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("CleanupCelebrityLevel");

            CelebrityLevelStaticData topLevel = null;

            if (CelebrityUtil.sCelebrityLevelData != null)
            {
                topLevel = CelebrityUtil.sCelebrityLevelData[CelebrityManager.HighestLevel];
            }

            foreach (SimDescription sim in SimListing.GetResidents(true).Values)
            {
                if (sim.CelebrityManager == null)
                {
                    sim.Fixup();
                }

                if (topLevel != null)
                {
                    if (sim.CelebrityManager.Points > topLevel.GoalPoints)
                    {
                        sim.CelebrityManager.mPoints = topLevel.GoalPoints;

                        Overwatch.Log("Celebrity Points Reset: " + sim.FullName);
                    }
                }

                if (sim.CelebrityLevel > CelebrityManager.HighestLevel)
                {
                    sim.CelebrityManager.mLevel = CelebrityManager.HighestLevel;

                    Overwatch.Log("Celebrity Level Reset: " + sim.FullName);
                }
            }
        }
Example #18
0
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("CleanupTimers");

            Dictionary <DateAndTime, Dictionary <MethodInfo, Dictionary <ReferenceWrapper, bool> > > lookup = new Dictionary <DateAndTime, Dictionary <MethodInfo, Dictionary <ReferenceWrapper, bool> > >();

            Dictionary <AlarmHandle, AlarmManager> remove = new Dictionary <AlarmHandle, AlarmManager>();

            Dictionary <AlarmManager, bool> managers = new Dictionary <AlarmManager, bool>();

            managers.Add(AlarmManager.Global, true);

            foreach (Lot lot in LotManager.AllLots)
            {
                if (lot.mSavedData.mAlarmManager == null)
                {
                    continue;
                }

                if (managers.ContainsKey(lot.AlarmManager))
                {
                    continue;
                }

                managers.Add(lot.AlarmManager, true);
            }

            Dictionary <ulong, SimDescription> sims = SimListing.GetResidents(true);

            foreach (AlarmManager manager in managers.Keys)
            {
                foreach (KeyValuePair <AlarmHandle, List <AlarmManager.Timer> > list in manager.mTimers)
                {
                    foreach (AlarmManager.Timer timer in list.Value)
                    {
                        bool removed = false;

                        SimDescription sim = timer.ObjectRef as SimDescription;
                        if (sim != null)
                        {
                            if (!sim.IsValidDescription)
                            {
                                remove[list.Key] = manager;

                                Overwatch.Log(" Invalid Sim " + sim.FullName);
                                removed = true;
                            }
                        }
                        else
                        {
                            GameObject gameObject = timer.ObjectRef as GameObject;
                            if (gameObject != null)
                            {
                                if (gameObject.HasBeenDestroyed)
                                {
                                    remove[list.Key] = manager;

                                    Overwatch.Log(" Destroyed Object " + gameObject.GetType());
                                    removed = true;
                                }
                            }
                        }

                        AlarmTimerCallback callback = timer.CallBack;

                        if (callback == null)
                        {
                            remove[list.Key] = manager;

                            Overwatch.Log(" Removed Empty Alarm");
                            removed = true;
                        }
                        else
                        {
                            Writing.RoyaltyAlarm royaltyAlarm = callback.Target as Writing.RoyaltyAlarm;
                            if (royaltyAlarm != null)
                            {
                                string reason = null;
                                if ((royaltyAlarm.mSkill == null) || (royaltyAlarm.mSkill.SkillOwner == null))
                                {
                                    reason = "No Skill";
                                }
                                else if (!royaltyAlarm.mSkill.SkillOwner.IsValidDescription)
                                {
                                    reason = "Bad Sim";
                                }
                                else if (royaltyAlarm.mSkill.SkillOwner.SkillManager == null)
                                {
                                    reason = "No Manager";
                                }
                                else
                                {
                                    Writing skill = royaltyAlarm.mSkill.SkillOwner.SkillManager.GetSkill <Writing>(SkillNames.Writing);
                                    if (skill != royaltyAlarm.mSkill)
                                    {
                                        reason = "Not Royalty Skill";
                                    }
                                    else if (skill.mRoyaltyAlarm != royaltyAlarm)
                                    {
                                        reason = "Not Royalty Alarm";
                                    }
                                }

                                if (reason != null)
                                {
                                    remove[list.Key] = manager;

                                    Overwatch.Log(" Invalid Royalty Alarm: " + reason);
                                    removed = true;
                                }
                            }
                            else
                            {
                                MethodInfo info = typeof(LunarCycleManager).GetMethod("PossiblySpawnZombie", BindingFlags.Static | BindingFlags.NonPublic);
                                if (callback.Method == info)
                                {
                                    if (LunarCycleManager.mZombieAlarm != timer.Handle)
                                    {
                                        remove[list.Key] = manager;

                                        Overwatch.Log(" Invalid Zombie Alarm");
                                        removed = true;
                                    }
                                }
                                else
                                {
                                    info = typeof(MeteorShower).GetMethod("RandomMeteorShowerCallback", BindingFlags.Static | BindingFlags.Public);
                                    if (callback.Method == info)
                                    {
                                        if (MeteorShower.RandomMeteorShowerAlarmHandler != timer.Handle)
                                        {
                                            remove[list.Key] = manager;

                                            Overwatch.Log(" Invalid Meteor Shower Alarm");
                                            removed = true;
                                        }
                                    }
                                }
                            }

                            if (!removed)
                            {
                                Dictionary <MethodInfo, Dictionary <ReferenceWrapper, bool> > methods;
                                if (!lookup.TryGetValue(timer.AlarmDateAndTime, out methods))
                                {
                                    methods = new Dictionary <MethodInfo, Dictionary <ReferenceWrapper, bool> >();
                                    lookup[timer.AlarmDateAndTime] = methods;
                                }

                                Dictionary <ReferenceWrapper, bool> objects;
                                if (!methods.TryGetValue(callback.Method, out objects))
                                {
                                    objects = new Dictionary <ReferenceWrapper, bool>();
                                    methods[callback.Method] = objects;
                                }

                                ReferenceWrapper reference = new ReferenceWrapper(callback.Target);

                                if (objects.ContainsKey(reference))
                                {
                                    remove[list.Key] = manager;

                                    Overwatch.Log(" Removed Duplicate Alarm: " + timer.AlarmDateAndTime + " " + callback.Method + " (" + callback.Target + ")");
                                }
                                else
                                {
                                    objects[reference] = true;
                                }
                            }
                        }
                    }
                }
            }

            foreach (KeyValuePair <AlarmHandle, AlarmManager> handle in remove)
            {
                handle.Value.RemoveAlarm(handle.Key);
            }

            // cleanup trick or treating fail
            HolidayManager instance = HolidayManager.Instance;

            if (instance != null && AlarmManager.Global != null)
            {
                if (!instance.IsFallHoliday && TrickOrTreatSituation.NPCTrickOrTreatAlarm != AlarmHandle.kInvalidHandle)
                {
                    Overwatch.Log("Cleaned up run away trick or treat alarm");
                    AlarmManager.Global.RemoveAlarm(TrickOrTreatSituation.NPCTrickOrTreatAlarm);
                    TrickOrTreatSituation.NPCTrickOrTreatAlarm = AlarmHandle.kInvalidHandle;
                }
            }
        }
        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;
            }
        }
Example #20
0
        public override bool InRabbitHole()
        {
            try
            {
                if (!AcceptCancelDialog.Show(Common.Localize("Matchmaker:Prompt", Actor.IsFemale, new object[] { Woohooer.Settings.mMatchmakerCost })))
                {
                    return(false);
                }

                List <SimDescription> actors = new List <SimDescription>();
                actors.Add(Actor.SimDescription);
                actors.AddRange(Households.Pets(Actor.Household));

                SimDescription actor = Actor.SimDescription;
                if (actors.Count > 0)
                {
                    actor = new ActorSelection(Common.Localize("Matchmaker:Choices"), actor, actors).SelectSingle();
                    if (actor == null)
                    {
                        return(false);
                    }
                }

                SimSelection selection = new SimSelection(Common.Localize("Matchmaker:MenuName"), actor, SimListing.GetResidents(false).Values, SimSelection.Type.Matchmaker, 0);
                if (selection.IsEmpty)
                {
                    Common.Notify(Common.Localize("Matchmaker:NoChoices", Actor.IsFemale));
                    return(false);
                }

                SimDescription choice = selection.SelectSingle();
                if (choice == null)
                {
                    Common.Notify(Common.Localize("Matchmaker:NoSelect", Actor.IsFemale));
                    return(false);
                }

                if (!CelebrityManager.TryModifyFundsWithCelebrityDiscount(Actor, Target, Woohooer.Settings.mMatchmakerCost, true))
                {
                    Common.Notify(Common.Localize("Matchmaker:CannotPay", Actor.IsFemale));
                    return(false);
                }

                Relationship relation = Relationship.Get(actor, choice, true);
                if (relation != null)
                {
                    relation.MakeAcquaintances();
                }

                if (actor.IsHuman)
                {
                    Common.Notify(choice.CreatedSim, Common.Localize("Matchmaker:Success", Actor.IsFemale, choice.IsFemale, new object[] { choice }));
                }
                else
                {
                    SimDescription owner = null;
                    if (!choice.Household.IsSpecialHousehold)
                    {
                        owner = SimTypes.HeadOfFamily(choice.Household);
                    }

                    if (owner == null)
                    {
                        owner = choice;
                    }

                    relation = Relationship.Get(Actor.SimDescription, owner, true);
                    if (relation != null)
                    {
                        relation.MakeAcquaintances();
                    }

                    Common.Notify(choice.CreatedSim, Common.Localize("Matchmaker:SuccessPet", Actor.IsFemale, choice.IsFemale, new object[] { choice }));
                }
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Example #21
0
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("CleanupShortTermContext");

            foreach (SimDescription sim in SimListing.GetResidents(true).Values)
            {
                try
                {
                    foreach (Relationship relation in Relationship.Get(sim))
                    {
                        List <CommodityTypes> removeCommodity = new List <CommodityTypes>();

                        foreach (KeyValuePair <CommodityTypes, Dictionary <SimDescription, float> > commodity in relation.STC.mAsymmetricStcProgress)
                        {
                            List <SimDescription> remove = new List <SimDescription>();

                            foreach (KeyValuePair <SimDescription, float> value in commodity.Value)
                            {
                                if (value.Value == 0)
                                {
                                    remove.Add(value.Key);
                                }
                            }

                            if (remove.Count == commodity.Value.Count)
                            {
                                commodity.Value.Clear();

                                removeCommodity.Add(commodity.Key);

                                Overwatch.Log("Zero Size Commodity Dropped: " + sim.FullName);
                            }
                            else if (remove.Count > 0)
                            {
                                Overwatch.Log(remove.Count + " Zero Value STC Dropped: " + sim.FullName);

                                foreach (SimDescription other in remove)
                                {
                                    commodity.Value.Remove(other);
                                }
                            }
                        }

                        if (removeCommodity.Count == relation.STC.mAsymmetricStcProgress.Count)
                        {
                            relation.STC.mAsymmetricStcProgress.Clear();
                        }
                        else
                        {
                            foreach (CommodityTypes commodity in removeCommodity)
                            {
                                relation.STC.mAsymmetricStcProgress.Remove(commodity);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(sim, e);
                }
            }
        }
Example #22
0
        public override bool BeforeEnteringRabbitHole()
        {
            mDonors = new List <SimDescription>();

            Dictionary <ulong, SimDescription> .Enumerator residentSims = SimListing.GetResidents(true).GetEnumerator();

            while (residentSims.MoveNext())
            {
                SimDescription sim = residentSims.Current.Value;

                if (sim.IsHuman && !(sim.IsRobot || sim.IsMummy) && sim.Gender == Actor.SimDescription.Gender)
                {
                    mDonors.Add(sim);
                }
            }

            mChance     = kChanceToSteal;
            mMaxSamples = kSamplesToSteal;

            if (Actor.IsSimBot)
            {
                if (Actor.TraitManager.HasElement(TraitNames.Burglar))
                {
                    mChance += kBonusToSteal;
                    mMaxSamples++;
                }

                if (Actor.TraitManager.HasElement(TraitNames.Clumsy))
                {
                    mChance -= kPenaltyToSteal;
                    mMaxSamples--;
                }

                if (Actor.TraitManager.HasElement(TraitNames.Evil))
                {
                    mChance += kBonusToSteal;
                }

                if (Actor.TraitManager.HasElement(TraitNames.Kleptomaniac))
                {
                    mChance += kBonusToSteal;
                    mMaxSamples++;
                }

                if (Actor.TraitManager.HasElement(TraitNames.Loser))
                {
                    mChance -= kPenaltyToSteal;
                    mMaxSamples--;
                }

                if (Actor.TraitManager.HasElement(TraitNames.Lucky))
                {
                    mChance += kBonusToSteal;
                }

                if (Actor.TraitManager.HasElement(TraitNames.Unlucky))
                {
                    mChance -= kPenaltyToSteal;
                }
            }

            if (Actor.IsEP11Bot)
            {
                if (Actor.TraitManager.HasElement(TraitNames.EfficientChip))
                {
                    mMaxSamples++;
                }

                if (Actor.TraitManager.HasElement(TraitNames.EvilChip))
                {
                    mChance += kBonusToSteal;
                }

                if (Actor.TraitManager.HasElement(TraitNames.FearOfHumansChip))
                {
                    mChance -= kPenaltyToSteal;
                    mMaxSamples--;
                }

                if (Actor.TraitManager.HasElement(TraitNames.SentienceChip))
                {
                    mChance += kBonusToSteal;
                }
            }

            return(base.BeforeEnteringRabbitHole());
        }
Example #23
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            SavedFilter filter;

            SimSelection.ICriteria criteria = null;
            if (mFilter != string.Empty && mCriteria != string.Empty)
            {
                filter = MasterController.GetFilter(mFilter);

                if (filter == null)
                {
                    return(OptionResult.Failure);
                }

                foreach (SimSelection.ICriteria crit in filter.Elements)
                {
                    if (crit.GetType().Name == mCriteria)
                    {
                        criteria = crit;
                        break;
                    }
                }

                if (criteria == null)
                {
                    return(OptionResult.Failure);
                }
            }
            else
            {
                SimSelection.ICriteria selection = base.RunFilterSelection(string.Empty);
                if (selection == null)
                {
                    return(OptionResult.Failure);
                }

                filter = MasterController.GetFilter(selection.Name);

                if (filter == null)
                {
                    return(OptionResult.Failure);
                }

                List <string> nonexistingCrit = new List <string>();

                foreach (SimSelection.ICriteria crit in SelectionOption.List)
                {
                    foreach (SimSelection.ICriteria crit2 in filter.Elements)
                    {
                        if (crit.Name == crit2.Name)
                        {
                            goto Skip;
                        }
                    }

                    nonexistingCrit.Add(crit.GetType().Name);

                    Skip :;
                }

                base.mForbiddenCrit.AddRange(nonexistingCrit);

                List <SimSelection.ICriteria> selCrit = base.RunCriteriaSelection(parameters, 1, false);

                if (selCrit.Count == 0)
                {
                    return(OptionResult.Failure);
                }

                foreach (SimSelection.ICriteria crit in filter.Elements)
                {
                    if (crit.Name == selCrit[0].Name)
                    {
                        criteria = crit;
                        break;
                    }
                }
            }

            if (!SelectionOption.StringList.ContainsKey(criteria.GetType().Name))
            {
                return(OptionResult.Failure);
            }

            List <IMiniSimDescription>         sims      = new List <IMiniSimDescription>();
            Dictionary <ulong, SimDescription> residents = SimListing.GetResidents(false);

            foreach (KeyValuePair <ulong, SimDescription> sim in residents)
            {
                sims.Add(sim.Value as IMiniSimDescription);
            }

            List <ICommonOptionItem> options = SelectionOption.StringList[criteria.GetType().Name].GetOptions(null, filter.Elements, sims);

            List <ICommonOptionItem> existingOptions = criteria.GetOptions(null, filter.Elements, sims);

            if (options == null || existingOptions == null)
            {
                return(OptionResult.Failure);
            }

            List <Item>   opts           = new List <Item>();
            List <string> existingByName = new List <string>();

            foreach (ICommonOptionItem opt2 in existingOptions)
            {
                existingByName.Add(opt2.Name);
            }

            foreach (ICommonOptionItem opt in options)
            {
                if (existingByName.Contains(opt.Name))
                {
                    continue;
                }

                opts.Add(new Item(opt));
            }

            CommonSelection <Item> .Results optSelection = new CommonSelection <Item>(Name, opts).SelectMultiple(20);

            if (optSelection == null || optSelection.Count == 0)
            {
                return(OptionResult.Failure);
            }

            foreach (Item item in optSelection)
            {
                existingOptions.Add(item.mOption);
            }

            criteria.SetOptions(existingOptions);

            return(OptionResult.SuccessRetain);
        }
Example #24
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (!ApplyAll)
            {
                mAdoptionParams = AdoptionDialog.Show(Common.Localize(GetTitlePrefix() + ":Prompt", me.IsFemale, new object[] { me }));
                if (mAdoptionParams.mCancelled)
                {
                    return(false);
                }
            }

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

            foreach (SimDescription sim in SimListing.GetResidents(true).Values)
            {
                if (!sim.IsHuman)
                {
                    continue;
                }

                residents.Add(sim);
            }

            SimDescription dad = RandomUtil.GetRandomObjectFromList(residents);
            SimDescription mom = RandomUtil.GetRandomObjectFromList(residents);

            SimDescription newKid = null;

            if ((dad != null) && (mom != null))
            {
                if (dad.CelebrityManager == null)
                {
                    dad.Fixup();
                }

                if (mom.CelebrityManager == null)
                {
                    mom.Fixup();
                }

                newKid = Genetics.MakeDescendant(dad, mom, mAdoptionParams.mAge, mAdoptionParams.mIsFemale ? CASAgeGenderFlags.Female : CASAgeGenderFlags.Male, 100, new Random(), false, false, true);
            }
            else
            {
                SimUtils.SimCreationSpec spec = new SimUtils.SimCreationSpec();
                spec.Gender = mAdoptionParams.mIsFemale ? CASAgeGenderFlags.Female : CASAgeGenderFlags.Male;
                spec.Age    = mAdoptionParams.mAge;
                spec.Normalize();
                newKid = spec.Instantiate();
            }

            if (newKid == null)
            {
                Common.Notify(Common.Localize(GetTitlePrefix() + ":Failure"));
                return(false);
            }

            string genderName = null;

            if (newKid.IsFemale)
            {
                genderName = Common.Localize("BabyGender:Female");
            }
            else
            {
                genderName = Common.Localize("BabyGender:Male");
            }

            string name = StringInputDialog.Show(Name, Common.Localize("InstaBaby:NamePrompt", newKid.IsFemale, new object[0]), newKid.FirstName);

            if (!string.IsNullOrEmpty(name))
            {
                newKid.FirstName = name;
            }

            newKid.LastName = me.LastName;

            me.Household.Add(newKid);

            newKid.WasAdopted = true;

            Sim adoptedChild = Instantiation.Perform(newKid, null);

            if (adoptedChild != null)
            {
                ResetSimTask.UpdateInterface(adoptedChild);

                SocialWorkerAdoptionSituation.InstantiateNewKid instantiateNewKid = new SocialWorkerAdoptionSituation.InstantiateNewKid();

                instantiateNewKid.AssignTraits(adoptedChild);

                instantiateNewKid.GiveImaginaryFriendDoll(newKid);

                me.Genealogy.AddChild(newKid.Genealogy);

                if (me.CreatedSim != null)
                {
                    ActiveTopic.AddToSim(me.CreatedSim, "Recently Had Baby");

                    EventTracker.SendEvent(EventTypeId.kAdoptedChild, me.CreatedSim, adoptedChild);
                    EventTracker.SendEvent(EventTypeId.kNewOffspring, me.CreatedSim, adoptedChild);
                    EventTracker.SendEvent(EventTypeId.kParentAdded, adoptedChild, me.CreatedSim);
                }

                MidlifeCrisisManager.OnHadChild(me);

                Genealogy spouse = me.Genealogy.Spouse;
                if (spouse != null)
                {
                    spouse.AddChild(newKid.Genealogy);

                    SimDescription spouseDesc = spouse.SimDescription;
                    if (spouseDesc != null)
                    {
                        MidlifeCrisisManager.OnHadChild(spouseDesc);

                        if (spouseDesc.CreatedSim != null)
                        {
                            ActiveTopic.AddToSim(spouseDesc.CreatedSim, "Recently Had Baby");

                            EventTracker.SendEvent(EventTypeId.kAdoptedChild, spouseDesc.CreatedSim, adoptedChild);
                            EventTracker.SendEvent(EventTypeId.kNewOffspring, spouseDesc.CreatedSim, adoptedChild);
                            EventTracker.SendEvent(EventTypeId.kParentAdded, adoptedChild, spouseDesc.CreatedSim);
                        }
                    }
                }

                EventTracker.SendEvent(EventTypeId.kChildBornOrAdopted, null, adoptedChild);
            }

            return(true);
        }
Example #25
0
        protected override void PrivatePerformAction(bool prompt)
        {
            Overwatch.Log(Name);

            Dictionary <IGameObject, bool> outOfWorldObjects = new Dictionary <IGameObject, bool>();

            Dictionary <ObjectGuid, bool> reservedObjects = new Dictionary <ObjectGuid, bool>();

            foreach (ParkingSpace space in Sims3.Gameplay.Queries.GetObjects <ParkingSpace>())
            {
                Vehicle vehicle = space.GetContainedVehicle();
                if (vehicle == null && space.ReservedVehicle != null)
                {
                    space.mReservedVehicle = null;
                }

                if (vehicle == null)
                {
                    continue;
                }

                if (!RetainOnLot(space))
                {
                    continue;
                }

                reservedObjects[vehicle.ObjectId] = true;
            }

            foreach (MooringPost post in Sims3.Gameplay.Queries.GetObjects <MooringPost>())
            {
                Vehicle vehicle = post.GetContainedVehicle();
                if (vehicle == null)
                {
                    continue;
                }

                if (!RetainOnLot(post))
                {
                    continue;
                }

                reservedObjects[vehicle.ObjectId] = true;
            }

            foreach (BikeRack rack in Sims3.Gameplay.Queries.GetObjects <BikeRack>())
            {
                if (!RetainOnLot(rack))
                {
                    continue;
                }

                foreach (Bicycle bike in rack.GetContainedBikes())
                {
                    reservedObjects[bike.ObjectId] = true;
                }
            }

            foreach (SimDescription sim in SimListing.GetResidents(false).Values)
            {
                if (sim.BoardingSchool != null)
                {
                    AddOutOfWorldObjects(outOfWorldObjects, sim.BoardingSchool.mInventoryItems);
                }

                if (sim.mInventoryItemsWhileInPassport != null)
                {
                    AddOutOfWorldObjects(outOfWorldObjects, sim.mInventoryItemsWhileInPassport);
                }

                Sim createdSim = sim.CreatedSim;
                if (createdSim != null)
                {
                    PoliceStation.GoToJail interaction = createdSim.CurrentInteraction as PoliceStation.GoToJail;
                    if ((interaction != null) && (interaction.mInmatesObjects != null))
                    {
                        foreach (IGameObject obj in interaction.mInmatesObjects)
                        {
                            outOfWorldObjects[obj] = true;
                        }
                    }

                    Vehicle reserved = createdSim.GetReservedVehicle();
                    if (reserved != null)
                    {
                        reservedObjects[reserved.ObjectId] = true;
                    }
                }

                ObjectGuid preferred = sim.mPreferredVehicleGuid;
                if (preferred != ObjectGuid.InvalidObjectGuid)
                {
                    reservedObjects[preferred] = true;
                }
            }

            if (ParentsLeavingTownSituation.sAdultsInventories != null)
            {
                foreach (List <InventoryItem> list in ParentsLeavingTownSituation.sAdultsInventories.Values)
                {
                    AddOutOfWorldObjects(outOfWorldObjects, list);
                }
            }

            int count = 0;

            foreach (Vehicle vehicle in Sims3.Gameplay.Queries.GetObjects <Vehicle>())
            {
                if (outOfWorldObjects.ContainsKey(vehicle))
                {
                    continue;
                }

                if (vehicle.HasFlags(GameObject.FlagField.IsStolen))
                {
                    continue;
                }

                if (reservedObjects.ContainsKey(vehicle.ObjectId))
                {
                    continue;
                }

                if ((!vehicle.InInventory) && (vehicle.Driver != null) && (!vehicle.Driver.HasBeenDestroyed))
                {
                    if (vehicle.Driver.LotCurrent == vehicle.LotCurrent)
                    {
                        continue;
                    }

                    if (vehicle.Driver.IsPerformingAService)
                    {
                        continue;
                    }
                }

                // Temporary until further review can be done
                if (vehicle is CarUFO)
                {
                    continue;
                }

                if (vehicle is WindSurfboard)
                {
                    // These vehicles can be placed on the ground, so don't require a parent
                    continue;
                }

                if (vehicle is MagicBroom)
                {
                    if (vehicle.InInventory)
                    {
                        continue;
                    }

                    if (vehicle.Parent is BroomStand)
                    {
                        continue;
                    }
                }
                else
                {
                    IOwnableVehicle ownableVehicle = vehicle as IOwnableVehicle;
                    if (ownableVehicle != null)
                    {
                        if (ownableVehicle.PendingUse)
                        {
                            continue;
                        }

                        CarOwnable carOwnable = vehicle as CarOwnable;
                        if (carOwnable != null)
                        {
                            if (!carOwnable.GeneratedOwnableForNpc)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            BoatOwnable boatOwnable = vehicle as BoatOwnable;
                            if (boatOwnable != null)
                            {
                                if (!boatOwnable.GeneratedOwnableForNpc)
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                if (ownableVehicle.InInventory)
                                {
                                    continue;
                                }
                            }
                        }
                    }

                    if ((vehicle is FoodTruckBase) || (vehicle is CarService))
                    {
                        if (vehicle.InWorld)
                        {
                            continue;
                        }
                    }
                }

                if ((vehicle.InWorld) && (vehicle.InUse))
                {
                    bool found = false;

                    foreach (Sim sim in vehicle.ActorsUsingMe)
                    {
                        if (!sim.HasBeenDestroyed)
                        {
                            found = true;
                            break;
                        }
                    }

                    if (found)
                    {
                        continue;
                    }
                }

                string parentSpace = null;
                if (vehicle.Parent != null)
                {
                    parentSpace = vehicle.Parent.GetType().ToString();
                    if (parentSpace.Contains("GalleryShopParkingSpace") || parentSpace.Contains("StoreSetParkingSpace"))
                    {
                        continue;
                    }
                }

                {
                    string catalogName = vehicle.CatalogName;

                    bool inInventory = vehicle.InInventory;

                    vehicle.UnParent();

                    IUsesParkingSpace parker = vehicle as IUsesParkingSpace;

                    if (parker != null)
                    {
                        ParkingSpace space = vehicle.Parent as ParkingSpace;
                        if (space != null)
                        {
                            space.UnReserveSpot(parker);
                        }
                        else
                        {
                            MooringPost post = vehicle.Parent as MooringPost;
                            if (post != null)
                            {
                                post.UnReserveSpot(parker as Boat);
                            }
                        }
                    }

                    vehicle.Destroy();

                    if (!(vehicle is LightweightTaxi))
                    {
                        count++;
                        Overwatch.Log("Towed " + catalogName);

                        if (inInventory)
                        {
                            Overwatch.Log(" Was InInventory");
                        }

                        if (!string.IsNullOrEmpty(parentSpace))
                        {
                            Overwatch.Log(" Space: " + parentSpace);
                        }
                    }
                }
            }

            if ((count > 0) || (prompt))
            {
                Overwatch.AlarmNotify(Common.Localize("CleanupVehicles:Complete", false, new object[] { count }));
            }
        }
Example #26
0
        public override void Startup()
        {
            Common.StringBuilder msg = new Common.StringBuilder("LiveModeStateEx:Startup" + Common.NewLine);
            Traveler.InsanityWriteLog(msg);

            try
            {
                UIManager.BlackBackground(false);

                msg += "A1";
                Traveler.InsanityWriteLog(msg);

                // StateMachineState:Startup()
                mBaseCallFlag |= BaseCallFlag.kStartup;

                // InWorldSubState:Startup()
                while (sDelayNextStateStartupCount > 0x0)
                {
                    SpeedTrap.Sleep();
                }

                msg += "A2";
                Traveler.InsanityWriteLog(msg);

                EventTracker.SendEvent(new InWorldSubStateEvent(this, true));

                //base.Startup();

                msg += "A3";
                Traveler.InsanityWriteLog(msg);

                ShowUI(true);

                if (CameraController.IsMapViewModeEnabled() && !TutorialModel.Singleton.IsTutorialRunning())
                {
                    CameraController.EnableCameraMapView(true);
                }

                msg += "B";
                Traveler.InsanityWriteLog(msg);

                CASExitLoadScreen.Close();

                bool traveling = false;
                if (GameStates.IsTravelling)
                {
                    if (GameStates.sTravelData == null)
                    {
                        GameStates.ClearTravelStatics();
                    }
                    else
                    {
                        traveling = true;
                        GameStatesEx.OnArrivalAtVacationWorld();
                    }
                }

                msg += "C";
                Traveler.InsanityWriteLog(msg);

                if (GameStates.sNextSimToSelect != null)
                {
                    DreamCatcher.SelectNoLotCheckImmediate(GameStates.sNextSimToSelect, true, true);
                    GameStates.sNextSimToSelect = null;
                }

                msg += "D";
                Traveler.InsanityWriteLog(msg);

                bool flag2 = false;
                if (LoadingScreenController.Instance != null)
                {
                    if ((GameStates.IsPerfTestRunning || (CommandLine.FindSwitch("campos") != null)) || (CommandLine.FindSwitch("camtarget") != null))
                    {
                        msg += "D1";
                        Traveler.InsanityWriteLog(msg);

                        GameUtils.EnableSceneDraw(true);
                        LoadingScreenController.Unload();
                    }
                    else if (traveling)
                    {
                        msg += "D2";
                        Traveler.InsanityWriteLog(msg);

                        uint customFlyThroughIndex = CameraController.GetCustomFlyThroughIndex();
                        if (GameStates.IsNewGame && (customFlyThroughIndex != 0x0))
                        {
                            msg += "D3";
                            Traveler.InsanityWriteLog(msg);

                            WaitForLotLoad(true, false);
                            ShowUI(false);
                            ShowMaptags(false);

                            msg += "D4";
                            Traveler.InsanityWriteLog(msg);

                            AudioManager.MusicMode = MusicMode.Flyby;
                            CameraController.OnCameraFlyThroughFinishedCallback += OnCameraFlyThroughFinishedEvent;
                            CameraController.StartFlyThrough(customFlyThroughIndex, false);
                            flag2 = true;

                            msg += "D5";
                            Traveler.InsanityWriteLog(msg);

                            GameUtils.EnableSceneDraw(true);
                            LoadingScreenController.Unload();
                            while (LoadingScreenController.Instance != null)
                            {
                                Sleep(0.0);
                            }
                        }
                        else
                        {
                            msg += "D6";
                            Traveler.InsanityWriteLog(msg);

                            WaitForLotLoad(true, true);
                            Camera.SetView(CameraView.SimView, true, true);
                        }
                    }
                    else
                    {
                        msg += "D7";
                        Traveler.InsanityWriteLog(msg);

                        Camera.RestorePersistedState();

                        msg += "D8";
                        Traveler.InsanityWriteLog(msg);

                        WaitForLotLoad(false, true);
                    }
                }
                else if (traveling)
                {
                    msg += "D9";
                    Traveler.InsanityWriteLog(msg);

                    WaitForLotLoad(!GameUtils.IsUniversityWorld(), true);
                    Camera.SetView(CameraView.SimView, true, true);
                }

                msg += "E";
                Traveler.InsanityWriteLog(msg);

                UserToolUtils.UserToolGeneric(0xc8, new ResourceKey(0x0L, 0x0, 0x0));
                if (!flag2)
                {
                    GameUtils.Unpause();
                }

                if (AudioManager.MusicMode != MusicMode.Flyby)
                {
                    AudioManager.MusicMode = MusicMode.None;
                }

                msg += "F";
                Traveler.InsanityWriteLog(msg);

                InWorldSubState.EdgeScrollCheck();
                InWorldSubState.OpportunityDialogCheck();

                try
                {
                    DreamsAndPromisesManager.ValidateLifetimeWishes();
                }
                catch (Exception e)
                {
                    Common.Exception(msg, e);
                }

                LifeEventManager.ValidatePendingLifeEvents();
                if (GameUtils.IsInstalled(ProductVersion.EP9))
                {
                    Tutorialette.TriggerLesson(Lessons.Degrees, Sim.ActiveActor);
                }

                if (GameUtils.GetCurrentWorldType() == WorldType.Base)
                {
                    Tutorialette.TriggerLesson(Lessons.Traveling, Sim.ActiveActor);
                }

                if (Sims3.Gameplay.ActiveCareer.ActiveCareer.ActiveCareerShowGeneralLesson)
                {
                    Tutorialette.TriggerLesson(Lessons.Professions, Sim.ActiveActor);
                }

                msg += "G";
                Traveler.InsanityWriteLog(msg);

                Tutorialette.TriggerLesson(Lessons.AgingStageLengths, Sim.ActiveActor);

                Sim selectedActor = PlumbBob.SelectedActor;
                if (selectedActor != null)
                {
                    // Custom
                    if (GameStates.sMovingWorldData != null)
                    {
                        WorldData.MergeFromCrossWorldData();
                    }

                    if (selectedActor.LotHome != null)
                    {
                        if (selectedActor.LotHome.HasVirtualResidentialSlots)
                        {
                            Tutorialette.TriggerLesson(Lessons.ApartmentLiving, selectedActor);
                        }
                    }
                    else
                    {
                        Lot lot = Helpers.TravelUtilEx.FindLot();
                        if (lot != null)
                        {
                            lot.MoveIn(selectedActor.Household);

                            foreach (SimDescription sim in Households.All(selectedActor.Household))
                            {
                                if (sim.CreatedSim == null)
                                {
                                    FixInvisibleTask.Perform(sim, false);
                                }
                                else
                                {
                                    bool replace = (sim.CreatedSim == selectedActor);

                                    ResetSimTask.Perform(sim.CreatedSim, false);

                                    if (replace)
                                    {
                                        selectedActor = sim.CreatedSim;
                                    }
                                }
                            }

                            msg += "MoveIn";
                        }
                    }

                    if (selectedActor.Household != null)
                    {
                        foreach (SimDescription description in Households.Humans(selectedActor.Household))
                        {
                            // Custom
                            if (GameStates.sMovingWorldData != null)
                            {
                                CrossWorldControl.Restore(description);
                            }

                            if (description.Child || description.Teen)
                            {
                                Tutorialette.TriggerLesson(Lessons.Pranks, null);
                                break;
                            }
                        }
                    }

                    if (selectedActor.BuffManager != null)
                    {
                        BuffMummysCurse.BuffInstanceMummysCurse element = selectedActor.BuffManager.GetElement(BuffNames.MummysCurse) as BuffMummysCurse.BuffInstanceMummysCurse;
                        if (element != null)
                        {
                            BuffMummysCurse.SetCursedScreenFX(element.CurseStage, false);
                        }
                    }

                    if (selectedActor.CareerManager != null)
                    {
                        selectedActor.CareerManager.UpdateCareerUI();
                    }

                    if (Traveler.Settings.mAllowSpawnWeatherStone && GameUtils.IsInstalled(ProductVersion.EP7) && GameUtils.IsInstalled(ProductVersion.EP8))
                    {
                        Sims3.Gameplay.UI.Responder.Instance.TrySpawnWeatherStone();
                    }
                }

                msg += "H";
                Traveler.InsanityWriteLog(msg);

                // Custom
                if (GameStates.sMovingWorldData != null)
                {
                    GameStatesEx.UpdateMiniSims(GameStatesEx.GetAllSims());

                    foreach (SimDescription sim in Households.All(Household.ActiveHousehold))
                    {
                        MiniSimDescription miniSim = MiniSimDescription.Find(sim.SimDescriptionId);
                        if (miniSim != null)
                        {
                            miniSim.Instantiated = true;
                            if (miniSim.HomeWorld != GameUtils.GetCurrentWorld())
                            {
                                miniSim.HomeWorld = GameUtils.GetCurrentWorld();
                            }
                        }

                        if (sim.HomeWorld != GameUtils.GetCurrentWorld())
                        {
                            sim.HomeWorld = GameUtils.GetCurrentWorld();
                        }
                    }
                }

                GameStates.SetupPostMoveData();
                GameStates.ClearMovingData();
                MovingWorldsWizardCheck();

                // Custom
                Household.IsTravelImport = false;

                InWorldSubStateEx.PlaceLotWizardCheck(this);

                msg += "I";
                Traveler.InsanityWriteLog(msg);

                foreach (Sim sim in LotManager.Actors)
                {
                    try
                    {
                        if (sim.HasBeenDestroyed)
                        {
                            continue;
                        }

                        OccultManager occultManager = sim.OccultManager;
                        if (occultManager != null)
                        {
                            occultManager.RestoreOccultIfNecessary();
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, null, msg, e);
                    }
                }

                msg += "J";
                Traveler.InsanityWriteLog(msg);

                // Custom
                foreach (SimDescription description in SimListing.GetResidents(false).Values)
                {
                    if (description.LotHome == null)
                    {
                        continue;
                    }

                    MiniSimDescription miniSimDescription = description.GetMiniSimDescription();
                    if (miniSimDescription != null)
                    {
                        miniSimDescription.LotHomeId = description.LotHome.LotId;
                    }
                }

                msg += "K";
                Traveler.InsanityWriteLog(msg);
            }
            catch (Exception e)
            {
                Traveler.InsanityException(msg, e);
            }
            finally
            {
                CASExitLoadScreen.Close();
            }
        }
Example #27
0
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("CleanupServicePools");

            Dictionary <ulong, SimDescription> allSims = SimListing.GetResidents(false);

            for (int j = Services.AllServices.Count - 1; j >= 0; j--)
            {
                Service service = Services.AllServices[j];
                if (service == null)
                {
                    Services.AllServices.RemoveAt(j);

                    Overwatch.Log("Empty Service Removed");
                }
                else if (service.Pool == null)
                {
                    service.mPool = new List <SimDescription>();

                    Overwatch.Log("Missing Pool Added " + service.GetType());
                }
                else
                {
                    for (int i = service.mPool.Count - 1; i >= 0; i--)
                    {
                        SimDescription sim = service.mPool[i];
                        if ((sim == null) || (!sim.IsValidDescription) || (sim.Household == null))
                        {
                            service.mPool.RemoveAt(i);

                            Overwatch.Log("Bogus Service Removed " + service.GetType());
                        }

                        /* Not valid to do
                         * else if (sim.Service != service)
                         * {
                         *  sim.Service = service;
                         *
                         *  Overwatch.Log("Bogus Service Reset " + sim.FullName);
                         * }
                         */
                    }
                }

                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 (!allSims.ContainsKey(info.Value.CurrentSimDescriptionID))
                            {
                                remove.Add(info.Key);

                                Overwatch.Log("Bogus Worker Removed " + service.GetType());
                            }
                        }

                        foreach (ObjectGuid rem in remove)
                        {
                            resortWorker.mWorkerInfo[rem] = new ResortWorker.WorkerInfo();
                        }
                    }
                }
            }
        }
Example #28
0
        public void OnWorldLoadFinished()
        {
            Dictionary <BookWrittenData, bool> existing = new Dictionary <BookWrittenData, bool>();

            foreach (BookWritten book in Sims3.Gameplay.Queries.GetObjects <BookWritten>())
            {
                BookWrittenData bookData = book.Data as BookWrittenData;
                if (bookData == null)
                {
                    continue;
                }

                existing[bookData] = true;
            }

            List <string> remove = new List <string>();

            foreach (SimDescription sim in SimListing.GetResidents(true).Values)
            {
                if (sim.SkillManager == null)
                {
                    continue;
                }

                Writing skill = sim.SkillManager.GetSkill <Writing>(SkillNames.Writing);
                if (skill == null)
                {
                    continue;
                }

                if (skill.WrittenBookDataList == null)
                {
                    continue;
                }

                foreach (WrittenBookData book in skill.WrittenBookDataList.Values)
                {
                    book.Author = sim.FullName;

                    string id = book.Title + book.Author;

                    BookWrittenData bookData;
                    if (!BookData.BookWrittenDataList.TryGetValue(id, out bookData))
                    {
                        // Constructor auto-adds to dictionary
                        bookData = new BookWrittenData(book, true);
                    }

                    existing[bookData] = true;
                }
            }

            RemoveWrittenData("General");
            RemoveWrittenData("All");

            List <StoreItem> general = null, all = null;

            Bookstore.mItemDictionary.TryGetValue("General", out general);
            Bookstore.mItemDictionary.TryGetValue("All", out all);

            List <WorldType> worldTypes = new List <WorldType>();

            worldTypes.Add(GameUtils.GetCurrentWorldType());

            Writing stateSkill = new Writing();

            foreach (KeyValuePair <string, BookWrittenData> pair in BookData.BookWrittenDataList)
            {
                BookWrittenData data = pair.Value;

                if (!existing.ContainsKey(pair.Value))
                {
                    remove.Add(pair.Key);
                    continue;
                }
                else if ((string.IsNullOrEmpty(data.Title)) || (string.IsNullOrEmpty(data.Author)))
                {
                    remove.Add(pair.Key);
                    continue;
                }

                string geoState, materialState;
                stateSkill.GetGeoAndMaterialStates(data.Genre, out geoState, out materialState);

                if (string.IsNullOrEmpty(data.GeometryState))
                {
                    data.GeometryState = geoState;
                }

                if (string.IsNullOrEmpty(data.MaterialState))
                {
                    data.MaterialState = materialState;
                }

                ThumbnailKey thumb = new ThumbnailKey(new ResourceKey((ulong)ResourceUtils.XorFoldHashString32("book_standard"), 0x1661233, 0x1), ThumbnailSize.Medium, ResourceUtils.HashString32(data.GeometryState), ResourceUtils.HashString32(data.MaterialState));

                BookGeneralStoreItem item = new BookGeneralStoreItem(data.Title + " - " + data.Author, (float)data.Value, data, thumb, data.GenerateUIStoreItemID(), new CreateObjectCallback(CreateBookWrittenCallback), new ProcessObjectCallback(ProcessBookWrittenCallback), data.AllowedWorlds, worldTypes, data.Author, data.Title, data.Length, data.GenreString);

                general.Add(item);
                all.Add(item);
            }

            foreach (string id in remove)
            {
                BookData.BookWrittenDataList.Remove(id);

                BooterLogger.AddTrace("Removed: " + id);
            }
        }