Beispiel #1
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);
                    }
                }
            }
        }
Beispiel #2
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;
                    }
                }
            }
        }
Beispiel #3
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);
        }
Beispiel #4
0
        public string Dump()
        {
            StringBuilder builder = new StringBuilder();

            Dictionary <ulong, List <SimDescription> > sims = SimListing.AllSims <SimDescription>(null, true);

            foreach (KeyValuePair <ulong, List <DiseaseVector> > simPair in mVectors)
            {
                if (simPair.Value.Count == 0)
                {
                    continue;
                }

                List <SimDescription> choices;
                if (!sims.TryGetValue(simPair.Key, out choices))
                {
                    continue;
                }

                builder.Append(Common.NewLine + choices[0].FullName);

                foreach (DiseaseVector vector in simPair.Value)
                {
                    builder.Append(Common.NewLine + " " + vector.UnlocalizedName);
                }
            }

            return(builder.ToString());
        }
Beispiel #5
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;
             *  }
             * }*/
        }
Beispiel #6
0
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("CleanupTraits");

            foreach (List <SimDescription> sims in SimListing.AllSims <SimDescription>(null, true).Values)
            {
                foreach (SimDescription sim in sims)
                {
                    if (sim.TraitManager == null)
                    {
                        continue;
                    }

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

                    foreach (KeyValuePair <ulong, Trait> trait in sim.TraitManager.mValues)
                    {
                        if (TraitManager.sDictionary.ContainsKey(trait.Key))
                        {
                            continue;
                        }

                        remove.Add(trait.Key);
                    }

                    foreach (ulong trait in remove)
                    {
                        sim.TraitManager.mValues.Remove(trait);

                        Overwatch.Log(" Removed: " + sim.FullName);
                    }
                }
            }
        }
Beispiel #7
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);
        }
Beispiel #8
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);
        }
Beispiel #9
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            Common.StringBuilder builder = new Common.StringBuilder();

            Dictionary <ulong, List <SimDescription> > allSims = SimListing.AllSims <SimDescription>(null, true);

            foreach (VectorBooter.Data vector in VectorBooter.Vectors)
            {
                Dictionary <string, List <SimDescription> > stages = new Dictionary <string, List <SimDescription> >();

                foreach (KeyValuePair <ulong, List <DiseaseVector> > sims in Vector.Settings.AllVectors)
                {
                    List <SimDescription> choices;
                    if (!allSims.TryGetValue(sims.Key, out choices))
                    {
                        continue;
                    }

                    SimDescription sim = choices[0];

                    foreach (DiseaseVector disease in sims.Value)
                    {
                        if (disease.Guid != vector.Guid)
                        {
                            continue;
                        }

                        string key = disease.StageName + " " + disease.Strain;

                        List <SimDescription> value;
                        if (!stages.TryGetValue(key, out value))
                        {
                            value = new List <SimDescription>();
                            stages.Add(key, value);
                        }

                        value.Add(sim);
                    }
                }

                string result = Common.NewLine + vector.Guid;

                foreach (KeyValuePair <string, List <SimDescription> > stage in stages)
                {
                    result += Common.NewLine + " " + stage.Key + " : " + stage.Value.Count;

                    foreach (SimDescription sim in stage.Value)
                    {
                        result += Common.NewLine + "  " + sim.FullName;
                    }
                }

                builder.Append(result);
            }

            Common.DebugWriteLog(builder);

            return(OptionResult.SuccessRetain);
        }
Beispiel #10
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);
            }
        }
        protected override void Perform(SimDescription obj, object parent, FieldInfo field)
        {
            //if (obj.IsValidDescription) return;

            if (mSims == null)
            {
                mSims = SimListing.AllSims <SimDescription>(null, true);
            }

            // All residents, ancestors, and urnstone sims are considered valid
            if (mSims.ContainsKey(obj.SimDescriptionId))
            {
                return;
            }

            GameObjectReference reference = ObjectLookup.GetReference(new ReferenceWrapper(obj));

            if (!DereferenceManager.Perform(obj, reference, false, false))
            {
                return;
            }

            DereferenceManager.Perform(obj, reference, true, false);

            string fullName = obj.FullName;

            if (!string.IsNullOrEmpty(fullName))
            {
                fullName = fullName.Trim();
            }

            if (!string.IsNullOrEmpty(fullName))
            {
                bool found = false;
                foreach (List <SimDescription> list in mSims.Values)
                {
                    foreach (SimDescription sim in list)
                    {
                        if (sim.FullName == fullName)
                        {
                            found = true;
                            break;
                        }
                    }
                }

                if (!found)
                {
                    if (reference.Count > 0)
                    {
                        ErrorTrap.LogCorrection("SimDescription Removed: " + fullName);
                    }
                    else
                    {
                        ErrorTrap.DebugLogCorrection("Zero Reference SimDescription Removed: " + fullName);
                    }
                }
            }
        }
        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);
            }
        }
Beispiel #13
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);
        }
Beispiel #14
0
        protected static void PreReturnHome(Dictionary <ulong, List <ConsignedObjectProxy> > list)
        {
            Dictionary <ulong, SimDescription> sims = SimListing.GetSims <SimDescription>(null, false);

            foreach (KeyValuePair <ulong, List <ConsignedObjectProxy> > pair in list)
            {
                SimDescription description = null;
                sims.TryGetValue(pair.Key, out description);
                if (description != null)
                {
                    Sim createdSim = description.CreatedSim;

                    Inventory familyInventory = null;
                    if ((description.Household != null) && (description.Household.SharedFamilyInventory != null))
                    {
                        familyInventory = description.Household.SharedFamilyInventory.Inventory;
                    }

                    foreach (ConsignedObjectProxy obj in pair.Value)
                    {
                        if (obj.Object == null)
                        {
                            continue;
                        }

                        if ((createdSim == null) || !Inventories.TryToMove(obj.Object, createdSim))
                        {
                            if (familyInventory != null)
                            {
                                familyInventory.TryToAdd(obj.Object);
                            }
                            else
                            {
                                obj.Object.Destroy();
                            }
                        }
                    }
                }
                else
                {
                    foreach (ConsignedObjectProxy obj3 in pair.Value)
                    {
                        if (obj3.Object == null)
                        {
                            continue;
                        }

                        obj3.Object.Destroy();
                    }
                }
            }
        }
Beispiel #15
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);
                }
            }
        }
Beispiel #16
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);
            }
        }
Beispiel #17
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);
            }
        }
Beispiel #18
0
        public static List <string> GetAllCriteriaOptions(string criteria, IMiniSimDescription actor)
        {
            List <string> results = new List <string>();

            SimSelection.ICriteria pick = null;

            foreach (SimSelection.ICriteria crit in SelectionOption.List)
            {
                if (crit.Name == criteria)
                {
                    pick = crit;
                    break;
                }
            }

            if (pick != null)
            {
                if (actor == null && PlumbBob.SelectedActor != null)
                {
                    actor = PlumbBob.SelectedActor.SimDescription.GetMiniSimDescription();
                }

                List <IMiniSimDescription> picks = new List <IMiniSimDescription>();
                foreach (List <IMiniSimDescription> sims in SimListing.AllSims(actor, false).Values)
                {
                    foreach (IMiniSimDescription sim in sims)
                    {
                        if (SimSelection.IsSpecial(sim))
                        {
                            continue;
                        }

                        picks.Add(sim);
                    }
                }

                List <ICommonOptionItem> options = pick.GetOptions(actor, new List <SimSelection.ICriteria>(), picks);

                foreach (ICommonOptionItem opt in options)
                {
                    results.Add(opt.Name);
                }
            }

            return(results);
        }
Beispiel #19
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);
                }
            }
Beispiel #20
0
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("CleanupRelationships");

            Dictionary <ulong, List <SimDescription> > lookup = SimListing.AllSims <SimDescription>(null, true);

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

            foreach (KeyValuePair <SimDescription, Dictionary <SimDescription, Relationship> > relationsA in Relationship.sAllRelationships)
            {
                if (!lookup.ContainsKey(relationsA.Key.SimDescriptionId))
                {
                    removeA.Add(relationsA.Key);
                }
                else
                {
                    List <SimDescription> removeB = new List <SimDescription>();

                    foreach (KeyValuePair <SimDescription, Relationship> relationB in relationsA.Value)
                    {
                        if (!lookup.ContainsKey(relationB.Key.SimDescriptionId))
                        {
                            removeB.Add(relationB.Key);
                        }
                    }

                    foreach (SimDescription remove in removeB)
                    {
                        Relationship.sAllRelationships.Remove(remove);

                        Overwatch.Log(" Removed B: " + remove.FullName);
                    }
                }
            }

            foreach (SimDescription remove in removeA)
            {
                Relationship.sAllRelationships.Remove(remove);

                Overwatch.Log(" Removed A: " + remove.FullName);
            }
        }
Beispiel #21
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");
                }
            }
        }
Beispiel #22
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);
        }
Beispiel #23
0
            public void CleanupSims()
            {
                Dictionary <ulong, List <SimDescription> > allSims = SimListing.AllSims <SimDescription>(null, true);

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

                foreach (ulong sim in mTested.Keys)
                {
                    if (allSims.ContainsKey(sim))
                    {
                        continue;
                    }

                    remove.Add(sim);
                }

                foreach (ulong sim in remove)
                {
                    mTested.Remove(sim);
                }

                remove.Clear();
                foreach (ulong sim in mOutfitCount.Keys)
                {
                    if (allSims.ContainsKey(sim))
                    {
                        continue;
                    }

                    remove.Add(sim);
                }

                foreach (ulong sim in remove)
                {
                    mOutfitCount.Remove(sim);
                }
            }
Beispiel #24
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);
                }
            }
        }
Beispiel #25
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);
                }
            }
        }
Beispiel #26
0
        protected static void Consign(Dictionary <ulong, List <ConsignedObjectProxy> > lookup, Dictionary <ObjectGuid, float> consignAttempts, float[] consignmentPrices, float madeGoodSaleThreshold, float reputationBonusForPositiveFeedback, Curve qualityVsReputationCurve, float sellXItemsOpportunityReputationGainMultiplier, int consignmentLifespan, float dailyNumberOfAttemptsDecrement, Curve reputationVsStoreFeeCurve, int numberOfTopSellingItems, float makeXSimoleonsOpportunityConsignmentFeeMultiplier)
        {
            if (lookup != null)
            {
                Dictionary <ulong, SimDescription> sims = SimListing.GetSims <SimDescription>(null, false);

                foreach (ulong num in lookup.Keys)
                {
                    SimDescription desc = null;
                    sims.TryGetValue(num, out desc);
                    if ((desc != null) && (desc.CreatedSim != null))// && desc.CreatedSim.IsInActiveHousehold)
                    {
                        Consignment consignment = desc.SkillManager.AddElement(SkillNames.Consignment) as Consignment;

                        bool unsold = false;

                        int totalSale = 0x0;

                        List <Pair <int, IGameObject> > list = new List <Pair <int, IGameObject> >();

                        bool bornSalesmanAdded = false;

                        string displayName = null;

                        List <ConsignedObjectProxy> list2 = lookup[num];

                        int index = 0x0;
                        while (index < list2.Count)
                        {
                            ConsignedObjectProxy local1 = list2[index];
                            local1.Age++;

                            float chance = 0;

                            try
                            {
                                if (list2[index].Object != null)
                                {
                                    chance = list2[index].GetChanceOfSale(desc.CreatedSim);
                                }
                                else
                                {
                                    list2.RemoveAt(index);
                                    continue;
                                }
                            }
                            catch (Exception e)
                            {
                                Common.DebugException("Consignment Section A", e);
                                chance = 1f;
                            }

                            if (RandomUtil.RandomChance01(chance))
                            {
                                if (list2[index].Age >= consignmentPrices.Length)
                                {
                                    list2[index].Age = consignmentPrices.Length - 1;
                                }

                                int valueOfSale = list2[index].GetValueOfSale(desc);
                                totalSale += valueOfSale;

                                float quality = list2[index].GetQuality();

                                try
                                {
                                    if ((((float)valueOfSale) / ((float)list2[index].Object.Value)) >= madeGoodSaleThreshold)
                                    {
                                        desc.CreatedSim.BuffManager.AddElement(BuffNames.MadeGoodSale, Origin.None);
                                    }

                                    if (!bornSalesmanAdded && (((desc.TraitManager.HasElement(TraitNames.BornSalesman) && (quality >= TraitTuning.BornSalesmanQualityMinimumThresholdForPositiveFeedback)) && RandomUtil.InterpolatedChance(TraitTuning.BornSalesmanQualityMinimumThresholdForPositiveFeedback, 1f, TraitTuning.BornSalesmanQualityMinimumChanceOfPositiveFeedback, TraitTuning.BornSalesmanQualityMaximumChanceOfPositiveFeedback, quality)) || ((!desc.TraitManager.HasElement(TraitNames.BornSalesman) && (quality >= ConsignmentRegister.kQualityMinimumThreshold)) && RandomUtil.InterpolatedChance(ConsignmentRegister.kQualityMinimumThreshold, 1f, ConsignmentRegister.kQualityMinimumChanceOfPositiveFeedback, ConsignmentRegister.kQualityMaximumChanceOfPositiveFeedback, quality))))
                                    {
                                        bornSalesmanAdded = true;
                                        displayName       = list2[index].DisplayName;
                                        consignment.TrackReputationChange(reputationBonusForPositiveFeedback);
                                    }

                                    float reputationChange = qualityVsReputationCurve.Fx(quality);
                                    if (consignment.OppItemsSoldLifetimeOpportunityCompleted && (reputationChange > 0f))
                                    {
                                        reputationChange *= sellXItemsOpportunityReputationGainMultiplier;
                                    }

                                    if (desc.TraitManager.HasElement(TraitNames.BornSalesman) && (reputationChange > 0f))
                                    {
                                        reputationChange *= TraitTuning.BornSalesmanReputationOnSaleBonusMultiplier;
                                    }

                                    consignment.TrackConsignmentSale(list2[index].Object, valueOfSale, reputationChange);
                                }
                                catch (Exception e)
                                {
                                    Common.DebugException("Consignment Section B", e);
                                }

                                list.Add(new Pair <int, IGameObject>(valueOfSale, list2[index].Object));

                                EventTracker.SendEvent(EventTypeId.kSoldConsignedObject, desc.CreatedSim);

                                GameObject obj2 = list2[index].Object as GameObject;
                                if (obj2 != null)
                                {
                                    Consignments.NotifySell(desc, obj2, valueOfSale);
                                }
                                list2.RemoveAt(index);
                            }
                            else if (list2[index].Age >= consignmentLifespan)
                            {
                                unsold = true;
                                consignment.TrackConsignmentReturn();

                                if (desc.CreatedSim.Inventory.ValidForThisInventory(list2[index].Object))
                                {
                                    Inventories.TryToMove(list2[index].Object, desc.CreatedSim);
                                }
                                else
                                {
                                    desc.CreatedSim.Household.SharedFamilyInventory.Inventory.TryToAdd(list2[index].Object);
                                }

                                list2[index].Object.EnableInteractions();
                                list2.RemoveAt(index);
                            }
                            else
                            {
                                index++;
                            }
                        }

                        DisplayStory(desc, list, totalSale, unsold, displayName, reputationVsStoreFeeCurve, numberOfTopSellingItems, makeXSimoleonsOpportunityConsignmentFeeMultiplier);
                    }
                }
            }

            foreach (ObjectGuid guid in new List <ObjectGuid>(consignAttempts.Keys))
            {
                float attempts = consignAttempts[guid];

                consignAttempts[guid] = Math.Max((float)0f, (float)(attempts - dailyNumberOfAttemptsDecrement));
            }
        }
Beispiel #27
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            SimSelection.CriteriaSelection.Results uncheckedCriteria = new SimSelection.CriteriaSelection(Name, SelectionCriteria.SelectionOption.List).SelectMultiple(20);
            if (uncheckedCriteria.Count == 0)
            {
                if (uncheckedCriteria.mOkayed)
                {
                    return(OptionResult.SuccessClose);
                }
                else
                {
                    return(OptionResult.Failure);
                }
            }

            bool showSpecial = false;

            foreach (SimSelection.ICriteria crit in uncheckedCriteria)
            {
                if (crit is SimTypeOr)
                {
                    showSpecial = true;
                    break;
                }
            }

            Sim sim = parameters.mActor as Sim;

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

            foreach (List <IMiniSimDescription> sims in SimListing.AllSims <IMiniSimDescription>(sim.SimDescription, showSpecial).Values)
            {
                if (!showSpecial)
                {
                    sims.RemoveAll((e) => { return(SimSelection.IsSpecial(e)); });
                }

                simsList.AddRange(sims);
            }

            List <SimSelection.ICriteria> criteria = new List <SimSelection.ICriteria> ();

            foreach (SimSelection.ICriteria crit in uncheckedCriteria)
            {
                // Update changes the sims list, so we need a new copy for each call
                List <IMiniSimDescription> newList = new List <IMiniSimDescription>(simsList);
                if (crit.Update(sim.SimDescription, uncheckedCriteria, newList, false) != SimSelection.UpdateResult.Failure)
                {
                    criteria.Add(crit);
                }
            }

            string name = null;

            while (true)
            {
                name = StringInputDialog.Show(Name, Common.Localize("SaveFilterSetting:Prompt"), name, 256, StringInputDialog.Validation.None);
                if (string.IsNullOrEmpty(name))
                {
                    return(OptionResult.Failure);
                }

                if (callingMod != string.Empty)
                {
                    name = callingMod + "." + name;
                }

                if (Find(name) == null)
                {
                    break;
                }
                else if (AcceptCancelDialog.Show(Common.Localize("SaveFilterSetting:Exists")))
                {
                    Delete(name);
                    break;
                }
            }

            NRaas.MasterController.Settings.mFilters.Add(new SavedFilter(name, criteria));

            SimpleMessageDialog.Show(Name, Common.Localize("SaveFilterSetting:Success"));
            return(OptionResult.SuccessRetain);
        }
Beispiel #28
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;
                }
            }
        }
Beispiel #29
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);
            }
        }
        public void FilterSims(ICollection <ICriteria> fullCriteria, IEnumerable <ICriteria> savedFilters, bool automatic, out bool canceled)
        {
            bool showSpecial = false;

            IEnumerable <ICriteria> criteria = null;

            canceled = false;

            bool manual = false;

            if (fullCriteria != null)
            {
                if (fullCriteria.Count > 1)
                {
                    List <ICriteria> allCriteria = new List <ICriteria>(fullCriteria);

                    if (savedFilters != null)
                    {
                        allCriteria.AddRange(savedFilters);
                    }

                    if (!automatic)
                    {
                        CriteriaSelection.Results results = new CriteriaSelection(Title, allCriteria).SelectMultiple();

                        criteria = results;

                        canceled = !results.mOkayed;
                    }
                    else
                    {
                        criteria = allCriteria;
                    }

                    manual = true;
                }
                else
                {
                    criteria = new List <ICriteria>(fullCriteria);
                }
            }
            else
            {
                showSpecial = true;
            }

            if (criteria == null)
            {
                criteria = new List <ICriteria>();
            }

            criteria = AlterCriteria(criteria, manual, canceled);

            foreach (ICriteria crit in criteria)
            {
                if (crit.IsSpecial)
                {
                    showSpecial = true;
                }
            }

            List <T> chosen = new List <T>();

            foreach (List <T> sims in SimListing.AllSims(mMe, showSpecial).Values)
            {
                foreach (T sim in sims)
                {
                    if (!showSpecial)
                    {
                        if (IsSpecial(sim))
                        {
                            continue;
                        }
                    }

                    if (!Allow(sim))
                    {
                        continue;
                    }

                    chosen.Add(sim);
                }
            }

            List <ICriteria> delayed = new List <ICriteria>();

            foreach (ICriteria crit in criteria)
            {
                if (crit.Update(mMe, criteria, chosen, false) == UpdateResult.Delay)
                {
                    delayed.Add(crit);
                }
            }

            foreach (ICriteria crit in delayed)
            {
                crit.Update(mMe, criteria, chosen, true);
            }

            if (chosen.Count == 0)
            {
                mItems = null;
            }
            else
            {
                mItems = chosen;
            }
        }