Example #1
0
 public static SimSelection Create(string title, SimDescription me)
 {
     SimSelection selection = new SimSelection(title, me);
     bool canceled;
     selection.FilterSims(new List<ICriteria>(), null, true, out canceled);
     return selection;
 }
Example #2
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            Sim actorSim = parameters.mActor as Sim;

            SimSelection sims = SimSelection.Create(Name, actorSim.SimDescription);

            if (sims.IsEmpty)
            {
                Common.Notify(Common.Localize(GetTitlePrefix() + ":None"));
                return(OptionResult.Failure);
            }

            SimSelection.Results selection = sims.SelectMultiple();
            if ((selection == null) || (selection.Count == 0))
            {
                return(OptionResult.Failure);
            }

            foreach (SimDescription sim in selection)
            {
                sim.AssignedRole.RemoveSimFromRole();
            }

            return(OptionResult.SuccessRetain);
        }
Example #3
0
        public static List <IMiniSimDescription> GetSimsMatchingFilterAsMinis(string name, ulong sim)
        {
            List <IMiniSimDescription> results = new List <IMiniSimDescription>();

            SavedFilter filter = GetFilter(name);

            if (sim == 0 && PlumbBob.SelectedActor != null)
            {
                sim = PlumbBob.SelectedActor.SimDescription.SimDescriptionId;
            }

            if (filter != null && sim != 0)
            {
                bool okayed;
                IMiniSimDescription mini = SimDescription.Find(sim);
                if (mini != null)
                {
                    List <SimSelection.ICriteria> crit = new List <SimSelection.ICriteria>();
                    crit.Add(new SavedFilter.Item(filter));

                    SimSelection selection = SimSelection.Create("", mini, null, crit, true, false, out okayed);
                    if (selection.All != null && selection.All.Count > 0)
                    {
                        results.AddRange(selection.All);
                    }
                }
            }

            return(results);
        }
Example #4
0
        public static SimDescription GetChoices(Sim actor, string title)
        {
            List <SimDescription> choices = GetChoices(actor);

            if (choices.Count == 0)
            {
                Common.Notify(actor, Common.Localize("Tantraport:NoChoices"));
                return(null);
            }

            bool           okayed;
            SimDescription result = new SimSelection(title, actor.SimDescription, choices, SimSelection.Type.Tantraport, 0).SelectSingle(out okayed);

            if (!okayed)
            {
                return(null);
            }

            if (result == null)
            {
                result = RandomUtil.GetRandomObjectFromList(choices);
            }

            return(result);
        }
Example #5
0
        public override bool ManualSetup(StoryProgressionObject manager)
        {
            if (!base.ManualSetup(manager))
            {
                return(false);
            }

            int originalID = Scenarios.TrackingID;

            Scenarios.TrackingID = ID;

            SimSelection sim = new SimSelection(this);

            try
            {
                if (!sim.Perform())
                {
                    if (!AcceptCancelDialog.Show(Common.Localize("FireScenario:ApplyAll")))
                    {
                        return(false);
                    }
                }

                Scenarios.WriteTrack(false);
            }
            finally
            {
                Scenarios.TrackingID = originalID;
            }

            Sim = sim.SimDescription;
            return(true);
        }
Example #6
0
        protected override OptionResult Run(GameHitParameters <Lot> parameters)
        {
            Sim actorSim = parameters.mActor as Sim;

            SimSelection selection = new SimSelection(Name, actorSim.SimDescription, mType);

            if (selection.IsEmpty)
            {
                Common.Notify(Common.Localize(GetTitlePrefix() + ":NoChoices"));
                return(OptionResult.Failure);
            }

            SimDescription sim = selection.SelectSingle();

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

            SimDescription existing;

            if (sim.CreatedByService.mPreferredServiceNpc.TryGetValue(parameters.mTarget.Household.HouseholdId, out existing))
            {
                if (existing.CreatedSim != null)
                {
                    ServiceSituation.Fire(existing.CreatedSim, parameters.mTarget.Household.Sims[0]);  // Human
                }
            }

            sim.CreatedByService.mPreferredServiceNpc[parameters.mTarget.Household.HouseholdId] = sim;

            Common.Notify(Common.Localize(GetTitlePrefix() + ":Success", sim.IsFemale, new object[] { sim, parameters.mTarget.Household.Name }));
            return(OptionResult.SuccessRetain);
        }
Example #7
0
            public static SimSelection Create(SimIDOption option)
            {
                SimSelection selection = new SimSelection(option);
                bool         canceled;

                selection.FilterSims(new List <ICriteria>(), null, true, out canceled);
                return(selection);
            }
Example #8
0
        public List <IMiniSimDescription> GetSelection(IMiniSimDescription me, string title, ICollection <SimSelection.ICriteria> criteria, int maxSelection, bool canApplyAll, out bool okayed)
        {
            okayed = false;

            bool         criteriaCanceled;
            SimSelection sims = SimSelection.Create(title, me, this, criteria, true, canApplyAll, out criteriaCanceled);

            if (sims.IsEmpty)
            {
                SimpleMessageDialog.Show(title, Common.Localize("SimSelection:NoChoices"));
                return(null);
            }

            okayed = true;

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

            if (sims.All.Count == 1)
            {
                results.AddRange(sims.All);
            }
            else
            {
                if ((ApplyAll) || ((AllSimsOnFilterCancel) && (criteriaCanceled)))
                {
                    if (!PerformApplyAll(title, sims.All, results))
                    {
                        okayed = false;
                    }

                    mAskedAndAnswered = true;
                }
                else
                {
                    SimSelection.Results choices = sims.SelectMultiple(maxSelection);

                    okayed = choices.mOkayed;
                    results.AddRange(choices);

                    if ((results.Count == 0) && (okayed) && (sims.All.Count > 1) && (maxSelection <= sims.All.Count))
                    {
                        if (!PerformApplyAll(title, sims.All, results))
                        {
                            okayed = false;
                        }
                    }

                    if ((canApplyAll) && (results.Count == sims.All.Count))
                    {
                        mAskedAndAnswered = true;
                        mApplyAll         = true;
                    }
                }
            }

            return(results);
        }
Example #9
0
            public static SimSelection Create(string title, string subTitle, SimDescription me)
            {
                SimSelection selection = new SimSelection(title, subTitle, me);

                bool canceled = false;

                selection.FilterSims(null, null, false, out canceled);

                return(selection);
            }
Example #10
0
        public override bool Run()
        {
            try
            {
                List <SimDescription> sims = new List <SimDescription>();

                foreach (Sim sim in Actor.LotCurrent.GetObjects <Sim>())
                {
                    if (sim == Actor)
                    {
                        continue;
                    }

                    if (sim.RoomId != Actor.RoomId)
                    {
                        continue;
                    }

                    sims.Add(sim.SimDescription);
                }

                SimSelection   selection = new SimSelection(Common.Localize("ScanRoom:MenuName"), Actor.SimDescription, sims, SimSelection.Type.ScanRoom, -1000);
                SimDescription choice    = selection.SelectSingle();

                if (selection.IsEmpty)
                {
                    Common.Notify(Common.Localize("ScanRoom:Failure"));
                    return(false);
                }

                if (choice != null)
                {
                    if (Actor.IsHuman)
                    {
                        Actor.InteractionQueue.PushAsContinuation(new SocialInteractionA.Definition("Flirt", null, null, false), choice.CreatedSim, true);
                    }
                    else
                    {
                        Actor.InteractionQueue.PushAsContinuation(new SocialInteractionA.Definition("Pet Socialize", null, null, false), choice.CreatedSim, true);
                    }
                }

                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Example #11
0
            public static SimSelection Create(string title, string subTitle, SimDescription me, Role.RoleType type)
            {
                SimSelection selection = new SimSelection(title, subTitle, me, type);

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

                foreach (IRoleCriteria crit in Common.DerivativeSearch.Find <IRoleCriteria>())
                {
                    criteria.Add(crit);
                }

                bool canceled;

                selection.FilterSims(criteria, null, false, out canceled);
                return(selection);
            }
Example #12
0
        protected SimDescription GetSelection()
        {
            if (Sim.ActiveActor == null)
            {
                return(null);
            }

            SimSelection sims = SimSelection.Create(this);

            if (sims.IsEmpty)
            {
                SimpleMessageDialog.Show(Name, StoryProgression.Localize("SimID:Error"));
                return(null);
            }

            return(sims.SelectSingle());
        }
Example #13
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            Sim actorSim = parameters.mActor as Sim;

            if (parameters.mTarget != null)
            {
                SimSelection sims = SimSelection.Create("", Name, actorSim.SimDescription, parameters.mTarget);
                if (sims.IsEmpty)
                {
                    return(OptionResult.Failure);
                }

                sims.SelectSingle();
            }

            return(OptionResult.SuccessClose);
        }
Example #14
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);
        }
Example #15
0
        protected SimDescription PrivateRun(IActor actor, Role.RoleType type, GameObjectHit hit)
        {
            Sim actorSim = actor as Sim;

            sFailureConditions = null;

            SimSelection sims = SimSelection.Create(Register.GetRoleName(type), Name, actorSim.SimDescription, type);

            if (sims.IsEmpty)
            {
                if (!string.IsNullOrEmpty(sFailureConditions))
                {
                    Common.DebugNotify(sFailureConditions);

                    Common.DebugWriteLog(sFailureConditions);
                }

                SimpleMessageDialog.Show(Name, Register.Localize("Select:Error"));
                return(null);
            }

            SimDescription sim = sims.SelectSingle();

            if (sim != null)
            {
                if (sim.CreatedByService != null)
                {
                    sim.CreatedByService.EndService(sim);
                }

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

                if (CriteriaItem.HasRealJob(sim))
                {
                    if (AcceptCancelDialog.Show(Common.Localize(GetTitlePrefix() + ":EmployedPrompt", sim.IsFemale, new object[] { sim })))
                    {
                        sim.Occupation.RetireNoConfirmation();
                    }
                }
            }

            return(sim);
        }
Example #16
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            Sim actorSim = parameters.mActor as Sim;

            SimSelection sims = SimSelection.Create("", Name, actorSim.SimDescription);

            if (sims.IsEmpty)
            {
                return(OptionResult.Failure);
            }

            SimSelection.Results results = sims.SelectMultiple();
            foreach (SimDescription desc in results)
            {
                Tagger.Settings.mTaggedSims.Remove(desc.SimDescriptionId);
            }

            return(OptionResult.SuccessClose);
        }
Example #17
0
        public virtual List <SimSelection.ICriteria> RunCriteriaSelection(GameHitParameters <GameObject> parameters, int maxSelection, bool withOptions)
        {
            List <SimSelection.ICriteria> selCrit = new List <SimSelection.ICriteria>();

            if (mForbiddenCrit.Count > 0)
            {
                foreach (SimSelection.ICriteria critItem in SelectionCriteria.SelectionOption.List)
                {
                    if (!mForbiddenCrit.Contains(critItem.GetType().Name))
                    {
                        selCrit.Add(critItem);
                    }
                }
            }
            else
            {
                selCrit = SelectionCriteria.SelectionOption.List;
            }

            SimSelection.CriteriaSelection.Results uncheckedCriteria = new SimSelection.CriteriaSelection(Name, selCrit).SelectMultiple(maxSelection);
            if (uncheckedCriteria.Count == 0)
            {
                if (uncheckedCriteria.mOkayed)
                {
                    return(selCrit);
                }
                else
                {
                    return(selCrit);
                }
            }

            bool showSpecial = false;

            foreach (SimSelection.ICriteria crit in uncheckedCriteria)
            {
                Common.Notify("Selected: " + crit.GetType().Name);
                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)
            {
                if (withOptions)
                {
                    // 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, false, false) != SimSelection.UpdateResult.Failure)
                    {
                        Common.Notify("Adding: " + crit.GetType().Name);
                        criteria.Add(crit);
                    }
                }
                else
                {
                    criteria.Add(crit);
                }
            }

            return(criteria);
        }
Example #18
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);
        }
Example #19
0
        public override bool InRabbitHole()
        {
            try
            {
                ActiveStage.Start();

                SimDescription choice = null;

                if (mMaster)
                {
                    if (!AcceptCancelDialog.Show(Common.Localize("Rendezvous:Prompt", Actor.IsFemale, new object[] { KamaSimtra.Settings.mRendezvousCostPerLevel })))
                    {
                        return(false);
                    }

                    Dictionary <int, List <SimDescription> > potentials = KamaSimtra.GetPotentials(Woohooer.Settings.AllowTeen(true));

                    List <SimDescription> choices = new List <SimDescription>();
                    for (int i = 1; i <= 10; i++)
                    {
                        List <SimDescription> fullList;
                        if (!potentials.TryGetValue(i, out fullList))
                        {
                            continue;
                        }

                        bool needFemale = false;

                        if (Actor.SimDescription.CanAutonomouslyBeRomanticWithGender(CASAgeGenderFlags.Male))
                        {
                            if (Actor.SimDescription.CanAutonomouslyBeRomanticWithGender(CASAgeGenderFlags.Female))
                            {
                                if (RandomUtil.CoinFlip())
                                {
                                    needFemale = true;
                                }
                            }
                            else
                            {
                                needFemale = false;
                            }
                        }
                        else if (Actor.SimDescription.CanAutonomouslyBeRomanticWithGender(CASAgeGenderFlags.Female))
                        {
                            needFemale = true;
                        }
                        else
                        {
                            needFemale = !Actor.IsFemale;
                        }

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

                        foreach (SimDescription sim in fullList)
                        {
                            if (sim.IsFemale != needFemale)
                            {
                                continue;
                            }

                            if (sim.Household == Actor.Household)
                            {
                                continue;
                            }

                            string reason;
                            GreyedOutTooltipCallback callback = null;
                            if (!CommonSocials.CanGetRomantic(Actor.SimDescription, sim, false, true, true, ref callback, out reason))
                            {
                                if (callback != null)
                                {
                                    Common.DebugNotify(sim.FullName + Common.NewLine + callback());
                                }
                                continue;
                            }

                            if (choices.Contains(sim))
                            {
                                continue;
                            }

                            randomList.Add(sim);
                        }

                        if (randomList.Count > 0)
                        {
                            choices.Add(RandomUtil.GetRandomObjectFromList(randomList));
                        }
                    }

                    if (choices.Count == 0)
                    {
                        Common.Notify(Common.Localize("Rendezvous:NoneAvailable", Actor.IsFemale));
                        return(false);
                    }

                    choice = new SimSelection(Common.Localize("Rendezvous:MenuName"), Actor.SimDescription, choices, SimSelection.Type.Rendezvous, -1000).SelectSingle();
                    if (choice == null)
                    {
                        Common.Notify(Common.Localize("Rendezvous:NoSelect", Actor.IsFemale));
                        return(false);
                    }

                    if (Instantiation.PerformOffLot(choice, Target.LotCurrent, null) == null)
                    {
                        Common.Notify(Common.Localize("Rendezvous:BadSim", Actor.IsFemale, new object[] { choice }));
                        return(false);
                    }

                    Rendezvous interaction = Singleton.CreateInstance(Target, choice.CreatedSim, new InteractionPriority(InteractionPriorityLevel.UserDirected), false, true) as Rendezvous;
                    interaction.mMaster = false;
                    interaction.LinkedInteractionInstance = this;

                    choice.CreatedSim.InteractionQueue.CancelAllInteractions();
                    if (!choice.CreatedSim.InteractionQueue.AddNext(interaction))
                    {
                        Common.Notify(Common.Localize("Rendezvous:BadSim", Actor.IsFemale, new object[] { choice }));
                        return(false);
                    }

                    if (!DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), WaitPeriodLoop, null))
                    {
                        Common.Notify(Common.Localize("Rendezvous:BadSim", Actor.IsFemale, new object[] { choice }));
                        return(false);
                    }

                    if (!mBegin)
                    {
                        Common.Notify(Common.Localize("Rendezvous:BadSim", Actor.IsFemale, new object[] { choice }));
                        return(false);
                    }
                    else
                    {
                        Actor.ClearExitReasons();

                        TimedStage stage = new TimedStage(GetInteractionName(), KamaSimtra.Settings.mRendezvousDuration, false, false, true);
                        Stages      = new List <Stage>(new Stage[] { stage });
                        ActiveStage = stage;
                        ActiveStage.Start();
                    }
                }
                else
                {
                    Rendezvous interaction = LinkedInteractionInstance as Rendezvous;
                    if (interaction == null)
                    {
                        return(false);
                    }

                    interaction.mBegin = true;
                }

                if (mMaster)
                {
                    if (!CelebrityManager.TryModifyFundsWithCelebrityDiscount(Actor, Target, KamaSimtra.Settings.mRendezvousCostPerLevel * choice.SkillManager.GetSkillLevel(KamaSimtra.StaticGuid), true))
                    {
                        Common.Notify(Common.Localize("Rendezvous:CannotPay", Actor.IsFemale));
                        return(false);
                    }

                    Common.Notify(choice.CreatedSim, Common.Localize("Rendezvous:Success", Actor.IsFemale, choice.IsFemale, new object[] { choice }));

                    KamaSimtra skill = KamaSimtra.EnsureSkill(Actor);
                    if (skill != null)
                    {
                        skill.RendezvousActive = true;
                    }
                }

                BeginCommodityUpdates();
                bool succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));
                EndCommodityUpdates(succeeded);

                if (KamaSimtra.Settings.mRandomRendezvousMoodlet)
                {
                    Actor.BuffManager.AddElement(RandomUtil.GetRandomObjectFromList(sRandomBuffs), WoohooBuffs.sWoohooOrigin);
                }

                if (mMaster)
                {
                    CommonWoohoo.WoohooLocation location = CommonWoohoo.WoohooLocation.RabbitHole;

                    List <WoohooLocationControl> choices = CommonWoohoo.GetValidLocations(Actor.SimDescription);
                    if (choices.Count > 0)
                    {
                        location = RandomUtil.GetRandomObjectFromList(choices).Location;
                    }

                    CommonWoohoo.RunPostWoohoo(Actor, choice.CreatedSim, Target, CommonWoohoo.WoohooStyle.Safe, location, false);
                }

                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Example #20
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            //if (!UIUtils.IsOkayToStartModalDialog()) return false;

            bool hasExclusiveAccess;
            Lot  partyVenue = GetVenue(parameters.mActor, out hasExclusiveAccess);

            float            num2;
            OutfitCategories formalwear;

            Sims3.Gameplay.Situations.Party party = null;
            bool isPartyAtHome = (partyVenue == parameters.mActor.LotHome);

            if (partyVenue == null)
            {
                return(OptionResult.Failure);
            }
            if (!parameters.mActor.IsSelectable)
            {
                return(OptionResult.Failure);
            }

            PartyPickerDialog.PartyType partyTypes = PartyPickerDialog.PartyType.kAll;

            // Keep as GameUtils
            if (GameUtils.IsOnVacation())
            {
                partyTypes &= ~PartyPickerDialog.PartyType.kBirthday;
            }

            if (partyVenue.LastDiedSim == null)
            {
                partyTypes &= ~PartyPickerDialog.PartyType.kFuneral;
            }

            Sim actorSim = parameters.mActor as Sim;

            Political job = actorSim.Occupation as Political;

            if ((job == null) || (!job.HasCampaignMoneyMetric()))
            {
                partyTypes &= ~PartyPickerDialog.PartyType.kCampaign;
            }

            partyTypes &= ~PartyPickerDialog.PartyType.kWedding;

            foreach (Sim sim in CommonSpace.Helpers.Households.AllSims(parameters.mActor.Household))
            {
                if (sim.IsEngaged)
                {
                    partyTypes |= PartyPickerDialog.PartyType.kWedding;
                    break;
                }
            }

            if (!GameUtils.IsInstalled(ProductVersion.EP4))
            {
                partyTypes &= ~PartyPickerDialog.PartyType.kBachelorParty;
                partyTypes &= ~PartyPickerDialog.PartyType.kChildSlumberParty;
                partyTypes &= ~PartyPickerDialog.PartyType.kTeenParty;
                partyTypes &= ~PartyPickerDialog.PartyType.kTeenSlumberParty;
            }
            else
            {
                if (isPartyAtHome)
                {
                    if (!actorSim.SimDescription.Child)
                    {
                        partyTypes &= ~PartyPickerDialog.PartyType.kChildSlumberParty;
                    }

                    if (!actorSim.SimDescription.Teen)
                    {
                        partyTypes &= ~PartyPickerDialog.PartyType.kTeenParty;
                        partyTypes &= ~PartyPickerDialog.PartyType.kTeenSlumberParty;
                    }
                }
                else
                {
                    partyTypes &= ~PartyPickerDialog.PartyType.kChildSlumberParty;
                    partyTypes &= ~PartyPickerDialog.PartyType.kTeenParty;
                    partyTypes &= ~PartyPickerDialog.PartyType.kTeenSlumberParty;
                }
            }

            partyTypes &= ~PartyPickerDialog.PartyType.kPoolParty;
            partyTypes &= ~PartyPickerDialog.PartyType.kFeastParty;
            partyTypes &= ~PartyPickerDialog.PartyType.kCostumeParty;
            partyTypes &= ~PartyPickerDialog.PartyType.kGiftGivingParty;
            if (GameUtils.IsInstalled(ProductVersion.EP8) /*&& isPartyAtHome*/)
            {
                partyTypes |= PartyPickerDialog.PartyType.kFeastParty;
                partyTypes |= PartyPickerDialog.PartyType.kCostumeParty;
                partyTypes |= PartyPickerDialog.PartyType.kGiftGivingParty;
                //if (PoolParty.CanSimThrowPoolParty(actorSim))
                if (partyVenue.GetSwimmingPoolCount() > 0)
                {
                    partyTypes |= PartyPickerDialog.PartyType.kPoolParty;
                }
            }

            partyTypes &= ~PartyPickerDialog.PartyType.kJuiceKeggerParty;
            partyTypes &= ~PartyPickerDialog.PartyType.kBonfire;
            partyTypes &= ~PartyPickerDialog.PartyType.kTailgatingParty;
            partyTypes &= ~PartyPickerDialog.PartyType.kVideoGameLANParty;
            partyTypes &= ~PartyPickerDialog.PartyType.kMasqueradeBall;
            partyTypes &= ~PartyPickerDialog.PartyType.kVictoryParty;

            if (GameUtils.IsInstalled(ProductVersion.EP9))
            {
                partyTypes |= PartyPickerDialog.PartyType.kTailgatingParty;
                partyTypes |= PartyPickerDialog.PartyType.kVideoGameLANParty;
                partyTypes |= PartyPickerDialog.PartyType.kMasqueradeBall;
                partyTypes |= PartyPickerDialog.PartyType.kVictoryParty;

                if (JuiceKeggerParty.CanSimThrowJuiceKeggerParty(actorSim))
                {
                    partyTypes |= PartyPickerDialog.PartyType.kJuiceKeggerParty;
                }

                if (BonfireParty.CanSimThrowBonfire(actorSim))
                {
                    partyTypes |= PartyPickerDialog.PartyType.kBonfire;
                }
            }

            bool         criteriaCanceled;
            SimSelection list = SimSelection.Create(Common.Localize("Party:SelectTitle"), actorSim.SimDescription, this, GetCriteria(parameters), false, false, out criteriaCanceled);

            if (list.IsEmpty)
            {
                SimpleMessageDialog.Show(Common.LocalizeEAString("Gameplay/Objects/Electronics/Phone/CallThrowParty:NoSimsWT"), Common.LocalizeEAString(parameters.mActor.IsFemale, "Gameplay/Objects/Electronics/Phone/CallThrowParty:NoSims", new object[] { parameters.mActor }), ModalDialog.PauseMode.PauseSimulator);
                return(OptionResult.Failure);
            }

            float openHour    = -1f;
            float closingHour = -1f;

            PartyPickerDialog.PartyInfo info = PartyPickerDialogEx.Show(partyTypes, list.GetPickerInfo(), parameters.mActor.GetThumbnailKey(), isPartyAtHome, 25, -1, openHour, closingHour, PartyPickerDialog.ClothingType.kNone, actorSim.IsFemale);
            if ((info == null) || (info.PartyType == PartyPickerDialog.PartyType.kNone))
            {
                return(OptionResult.Failure);
            }

            float hoursPassedOfDay = SimClock.HoursPassedOfDay;

            if (hoursPassedOfDay > info.Time)
            {
                num2 = 24f - (hoursPassedOfDay - info.Time);
            }
            else
            {
                num2 = info.Time - hoursPassedOfDay;
            }
            if (num2 < 1f)
            {
                num2 += 24f;
            }
            long        ticks            = SimClock.ConvertToTicks(num2, TimeUnit.Hours);
            DateAndTime startTime        = SimClock.CurrentTime() + new DateAndTime(ticks);
            bool        bHostIsLegendary = actorSim.HasTrait(TraitNames.LegendaryHost);
            float       fMaxLTR          = 0f;
            LTRData     data             = LTRData.Get(LongTermRelationshipTypes.Friend);

            if (data != null)
            {
                fMaxLTR = data.Liking - 1;
            }
            List <SimDescription> simList = new List <SimDescription>();

            foreach (object obj2 in info.SimList)
            {
                SimDescription simDescription = obj2 as SimDescription;
                if ((simDescription != null) && CanSimBeInvitedToParty(simDescription, partyVenue, actorSim, fMaxLTR, bHostIsLegendary, true))
                {
                    if (!simList.Contains(simDescription))
                    {
                        simList.Add(simDescription);
                        if (simDescription.TraitManager.HasElement(TraitNames.PartyAnimal))
                        {
                            Sim createdSim = simDescription.CreatedSim;
                            if (createdSim != null)
                            {
                                TraitTipsManager.ShowTraitTip(13271263770231522640L, createdSim, TraitTipsManager.TraitTipCounterIndex.PartyAnimal, TraitTipsManager.kPartyAnimalCountOfParties);
                            }
                        }
                        if (simDescription.IsCelebrity)
                        {
                            EventTracker.SendEvent(EventTypeId.kPartyInviteCeleb, parameters.mActor);
                        }
                    }

                    bool bShouldMatchAge = (simDescription.Age == actorSim.SimDescription.Age) && ((simDescription.Teen) || (simDescription.Child));
                    if (!hasExclusiveAccess && RandomUtil.RandomChance(HouseParty.HousePartyParams.PercentageChanceOfBringingAFriend))
                    {
                        SimDescription friend = SocialComponent.FindFriendNotInList(simDescription, simList, parameters.mActor.LotHome, bShouldMatchAge);
                        if ((friend != null) && CanSimBeInvitedToParty(friend, partyVenue, null, 0f, false, false))
                        {
                            simList.Add(friend);
                        }
                    }
                }
            }

            DateAndTime time = startTime;

            time.Ticks -= SimClock.ConvertToTicks(Sims3.Gameplay.Situations.Party.HoursToStartRentBeforePartyStart, TimeUnit.Hours);
            if (time.CompareTo(SimClock.CurrentTime()) < 0)
            {
                time = SimClock.Add(SimClock.CurrentTime(), TimeUnit.Minutes, 2f);
            }

            if ((partyVenue != parameters.mActor.LotHome) && !RentScheduler.Instance.RentLot(partyVenue, actorSim, time, simList, hasExclusiveAccess))
            {
                SimpleMessageDialog.Show(string.Empty, Phone.Call.LocalizeCallString("ThrowParty", "CantRent", new object[] { parameters.mActor }), ModalDialog.PauseMode.PauseSimulator);
                return(OptionResult.Failure);
            }

            switch (info.ClothingType)
            {
            case PartyPickerDialog.ClothingType.kFormal:
                formalwear = OutfitCategories.Formalwear;
                break;

            case PartyPickerDialog.ClothingType.kCasual:
                formalwear = OutfitCategories.Everyday;
                break;

            case PartyPickerDialog.ClothingType.kSwimwear:
                formalwear = OutfitCategories.Swimwear;
                break;

            case PartyPickerDialog.ClothingType.kCostumes:
                formalwear = OutfitCategories.Everyday;
                break;

            default:
                formalwear = OutfitCategories.Everyday;
                break;
            }

            float infoTime = info.Time;

            switch (info.PartyType)
            {
            case PartyPickerDialog.PartyType.kCampaign:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:FundraiserTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:FundraiserStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new CampaignFundraiser(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewFundraiser, parameters.mActor);
                break;

            case PartyPickerDialog.PartyType.kBirthday:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:BirthdayTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:BirthdayStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new BirthdayParty(partyVenue, actorSim, simList, formalwear, startTime);
                break;

            case PartyPickerDialog.PartyType.kWedding:
                string messageText = string.Empty;
                if (GameUtils.IsInstalled(ProductVersion.EP4))
                {
                    messageText = Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:WeddingStartWithArch", new object[] { infoTime });
                }
                else
                {
                    messageText = Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:WeddingStart", new object[] { infoTime });
                }

                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:WeddingTitle"), messageText, ModalDialog.PauseMode.PauseSimulator);

                EnsureFianceeIsInvitedToWeddingParty(actorSim, simList);

                party = new WeddingParty(partyVenue, actorSim, simList, formalwear, startTime);
                break;

            case PartyPickerDialog.PartyType.kFuneral:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:FuneralTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:FuneralStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new Funeral(partyVenue, actorSim, simList, formalwear, startTime);
                break;

            case PartyPickerDialog.PartyType.kBachelorParty:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:BachelorPartyTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:BachelorStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new BachelorParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewBachelorParty, actorSim);
                actorSim.SimDescription.SetHadBachelorParty();
                break;

            case PartyPickerDialog.PartyType.kTeenParty:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:TeenPartyTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:TeenStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new TeenParty(partyVenue, actorSim, simList, formalwear, startTime);
                break;

            case PartyPickerDialog.PartyType.kChildSlumberParty:
            case PartyPickerDialog.PartyType.kTeenSlumberParty:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:SlumberPartyTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:SlumberStart", new object[] { infoTime, actorSim }), ModalDialog.PauseMode.PauseSimulator);
                party = new SlumberParty(partyVenue, actorSim, simList, formalwear, startTime);
                break;

            case PartyPickerDialog.PartyType.kCostumeParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:CostumePartyTitle", new object[0x0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:CostumePartyStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new CostumeParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kCostumePartyScheduled, actorSim);
                break;

            case PartyPickerDialog.PartyType.kGiftGivingParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:GiftGivingPartyTitle", new object[0x0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:GiftGivingPartyStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new GiftGivingParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kGiftGivingPartyScheduled, actorSim);
                break;

            case PartyPickerDialog.PartyType.kPoolParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:PoolPartyTitle", new object[0x0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:PoolPartyStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new PoolParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kSchedulePoolParty, actorSim);
                break;

            case PartyPickerDialog.PartyType.kFeastParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:FeastPartyTitle", new object[0x0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situation/Party:FeastPartyStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new FeastParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kFeastPartyScheduled, actorSim);
                break;

            case PartyPickerDialog.PartyType.kJuiceKeggerParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:JuiceKeggerPartyTitle", new object[0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:JuiceKeggerStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new JuiceKeggerParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewJuiceKeggerParty, actorSim);
                break;

            case PartyPickerDialog.PartyType.kTailgatingParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:TailgatingPartyTitle", new object[0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:TailgatingStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new TailgatingParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewTailgatingParty, actorSim);
                break;

            case PartyPickerDialog.PartyType.kBonfire:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:BonfireTitle", new object[0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:BonfireStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new BonfireParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewBonfireParty, actorSim);
                break;

            case PartyPickerDialog.PartyType.kVideoGameLANParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:VideoGameLANPartyTitle", new object[0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:VideoGameLANStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new VideoGameLANParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewVideoGameLANParty, actorSim);
                break;

            case PartyPickerDialog.PartyType.kMasqueradeBall:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:MasqueradeBallTitle", new object[0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:MasqueradeStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new MasqueradeBall(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewMasqueradeBall, actorSim);
                break;

            case PartyPickerDialog.PartyType.kVictoryParty:
                SimpleMessageDialog.Show(Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:VictoryPartyTitle", new object[0]), Localization.LocalizeString(actorSim.IsFemale, "Gameplay/Situations/Party:VictoryStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new VictoryParty(partyVenue, actorSim, simList, formalwear, startTime);
                EventTracker.SendEvent(EventTypeId.kThrewVictoryParty, actorSim);
                break;

            default:
                SimpleMessageDialog.Show(Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:GenericTitle"), Common.LocalizeEAString(actorSim.IsFemale, "Gameplay/Situations/Party:HouseStart", new object[] { infoTime }), ModalDialog.PauseMode.PauseSimulator);
                party = new HouseParty(partyVenue, actorSim, simList, formalwear, startTime);
                break;
            }

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

            foreach (SimDescription sim in party.GuestDescriptions)
            {
                Instantiation.EnsureInstantiate(sim, party.Lot);
            }

            EventTracker.SendEvent(new PartyEvent(EventTypeId.kThrewParty, actorSim, actorSim.SimDescription, party));
            if (actorSim.HasTrait(TraitNames.PartyAnimal))
            {
                TraitTipsManager.ShowTraitTip(13271263770231522640L, actorSim, TraitTipsManager.TraitTipCounterIndex.PartyAnimal, TraitTipsManager.kPartyAnimalCountOfParties);
            }
            return(OptionResult.SuccessClose);
        }
Example #21
0
        // settled on a seperate interface within attraction profiles to set certain criteria as random which will use the above to pull the options allowing users to allow/disallow criteria. Problems begin with localization of values when handling them as strings. I'll deal with that later.
        public static string CreateFilterWithCriteria(string callingNamespace, IMiniSimDescription actor, List <SimSelection.ICriteriaCreation> creationData)
        {
            if (creationData == null)
            {
                Common.Notify("Creation Data null");
                return(string.Empty);
            }

            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 <SimSelection.ICriteria> finalCriteria = new List <SimSelection.ICriteria>();

            foreach (SimSelection.ICriteriaCreation cData in creationData)
            {
                List <SimSelection.ICriteria> validCriteria = new List <SimSelection.ICriteria>();

                List <string> forbiddenCrit = new List <string>();
                if (cData.RandomCriteria && cData.ForbiddenRandomCriteria != null)
                {
                    forbiddenCrit = cData.ForbiddenRandomCriteria;
                }

                foreach (SimSelection.ICriteria crit in SelectionOption.List)
                {
                    if (crit.Name == cData.CriteriaName)
                    {
                        validCriteria.Add(crit);
                        break;
                    }

                    if (!forbiddenCrit.Contains(crit.Name))
                    {
                        validCriteria.Add(crit);
                    }
                }

                SimSelection.ICriteria pickedCritera = null;
                if (validCriteria.Count == 1)
                {
                    pickedCritera = validCriteria[0];
                }
                else
                {
                    int loop = 0;
                    while (true)
                    {
                        if (loop > 4)
                        {
                            break;
                        }

                        pickedCritera = RandomUtil.GetRandomObjectFromList <SimSelection.ICriteria>(validCriteria);

                        if (finalCriteria.Contains(pickedCritera))
                        {
                            loop++;
                            continue;
                        }
                    }
                }

                if (pickedCritera == null)
                {
                    Common.Notify("pickedCriteria was null");
                    continue;
                }

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

                if (criteriaOptions == null || criteriaOptions.Count == 0)
                {
                    Common.Notify("criteriaOptions null or 0");
                    continue;
                }

                List <string> forbiddenOptions = new List <string>();
                if (cData.RandomOptions && cData.ForbiddenRandomOptions != null)
                {
                    forbiddenOptions = cData.ForbiddenRandomOptions;
                }

                List <ICommonOptionItem> finalOptions       = new List <ICommonOptionItem>();
                List <ICommonOptionItem> validRandomOptions = new List <ICommonOptionItem>();

                foreach (ICommonOptionItem opt in criteriaOptions)
                {
                    if (cData.CriteriaOptions != null && cData.CriteriaOptions.Contains(opt.Name) && !finalOptions.Contains(opt))
                    {
                        finalOptions.Add(opt);

                        if (validRandomOptions.Contains(opt))
                        {
                            validRandomOptions.Remove(opt);
                        }

                        continue;
                    }

                    if (cData.RandomOptions && !forbiddenOptions.Contains(opt.Name) && !finalOptions.Contains(opt))
                    {
                        validRandomOptions.Add(opt);
                    }
                }

                if (validRandomOptions.Count > 0)
                {
                    List <ICommonOptionItem> pickedRandomOptions = new List <ICommonOptionItem>();
                    if (cData.MinMaxRandomOptions != null || cData.MinMaxRandomOptions.Length == 2)
                    {
                        int numOpt = RandomUtil.GetInt(cData.MinMaxRandomOptions[0], cData.MinMaxRandomOptions[1]);

                        if (numOpt != 0)
                        {
                            while (true)
                            {
                                if (validRandomOptions.Count == 0 || pickedRandomOptions.Count == numOpt)
                                {
                                    break;
                                }

                                ICommonOptionItem opt = RandomUtil.GetRandomObjectFromList <ICommonOptionItem>(validRandomOptions);

                                if (opt != null)
                                {
                                    pickedRandomOptions.Add(opt);
                                    validRandomOptions.Remove(opt);
                                }
                            }
                        }

                        finalOptions.AddRange(pickedRandomOptions);
                    }
                }

                pickedCritera.SetOptions(finalOptions);

                finalCriteria.Add(pickedCritera);
            }

            if (finalCriteria.Count > 0)
            {
                string filterName;

                while (true)
                {
                    filterName = callingNamespace + ".SimAttractionFilter" + RandomGen.NextDouble();

                    if (GetFilter(filterName) != null)
                    {
                        continue;
                    }
                    else
                    {
                        MasterController.Settings.mFilters.Add(new SavedFilter(filterName, finalCriteria));
                        break;
                    }
                }

                return(filterName);
            }

            return(string.Empty);
        }
Example #22
0
        // this needs to be updated to use the cleaner ICreationData interface
        public static string CreateAndReturnRandomFilter(string callingNamespace, IMiniSimDescription actor, List <string> forbiddenCrit, Dictionary <string, string> forbiddenOptions, int[] minMaxCrit, Dictionary <string, int[]> minMaxOptions)
        {
            List <SimSelection.ICriteria> validCriteria = new List <SimSelection.ICriteria>();

            foreach (SimSelection.ICriteria crit in SelectionOption.List)
            {
                if (!forbiddenCrit.Contains(crit.Name))
                {
                    validCriteria.Add(crit);
                }
            }

            if (validCriteria.Count == 0)
            {
                return(string.Empty);
            }

            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);
                }
            }

            if (picks.Count == 0)
            {
                return(string.Empty);
            }

            if (minMaxCrit.Length < 2)
            {
                minMaxCrit[0] = 1;
                minMaxCrit[1] = 2;
            }

            int critpicks = RandomUtil.GetInt(minMaxCrit[0], minMaxCrit[1]);

            Common.Notify("Picking " + critpicks + " from " + validCriteria.Count);

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

            if (validCriteria.Count == critpicks)
            {
                finalPicks = validCriteria;
            }
            else
            {
                while (true)
                {
                    if (validCriteria.Count < critpicks && finalPicks.Count == validCriteria.Count)
                    {
                        break;
                    }

                    if (finalPicks.Count < critpicks)
                    {
                        SimSelection.ICriteria critpick = RandomUtil.GetRandomObjectFromList <SimSelection.ICriteria>(validCriteria);
                        if (!finalPicks.Contains(critpick))
                        {
                            finalPicks.Add(critpick);
                        }
                        continue;
                    }

                    break;
                }
            }

            bool failed = false;

            foreach (SimSelection.ICriteria crit2 in finalPicks)
            {
                Common.Notify("Picked " + crit2.Name);
                List <ICommonOptionItem> finalOpts = new List <ICommonOptionItem>();
                List <ICommonOptionItem> opts      = crit2.GetOptions(actor, finalPicks, picks);

                if (opts != null && opts.Count > 0)
                {
                    Common.Notify("Opts not null");
                    int optpicks = 0;

                    if (minMaxOptions.ContainsKey(crit2.Name) && minMaxOptions[crit2.Name].Length > 1)
                    {
                        optpicks = RandomUtil.GetInt(minMaxOptions[crit2.Name][0], minMaxOptions[crit2.Name][1]);
                    }
                    else
                    {
                        optpicks = 1;
                    }

                    Common.Notify("Picking " + optpicks + " from " + opts.Count);

                    if (opts.Count == optpicks)
                    {
                        finalOpts = opts;
                    }
                    else
                    {
                        while (true)
                        {
                            if (opts.Count < optpicks && finalOpts.Count == opts.Count)
                            {
                                break;
                            }

                            if (finalOpts.Count < optpicks)
                            {
                                ICommonOptionItem opt     = RandomUtil.GetRandomObjectFromList <ICommonOptionItem>(opts);
                                ITestableOption   testOpt = opt as ITestableOption;
                                if (!finalOpts.Contains(opt) && (!forbiddenOptions.ContainsKey(crit2.Name) || (testOpt != null && !forbiddenOptions[crit2.Name].Contains(testOpt.OptionName))))
                                {
                                    // test if this gives me the name, if so we can revert the changes to ITestableOption
                                    Common.Notify("Picked " + opt.Name);
                                    finalOpts.Add(opt);
                                }
                                continue;
                            }
                            break;
                        }
                    }

                    crit2.SetOptions(finalOpts);
                }
                else
                {
                    failed = true;
                    break;
                }
            }

            if (failed)
            {
                Common.Notify("Failed");
                return(string.Empty);
            }

            string filterName;

            while (true)
            {
                filterName = callingNamespace + ".SimAttractionFilter" + RandomGen.NextDouble();

                if (GetFilter(filterName) != null)
                {
                    continue;
                }
                else
                {
                    MasterController.Settings.mFilters.Add(new SavedFilter(filterName, finalPicks));
                    break;
                }
            }

            Common.Notify("Set and returning filter " + filterName);

            return(filterName);
        }
Example #23
0
        public List <LotHouseItem> GetSelection(SimDescription me, string title, List <SimSelection.ICriteria> criteria, int maxSelection, out bool okayed)
        {
            okayed = false;

            bool         criteriaCanceled;
            SimSelection sims = SimSelection.Create(title, me, this, criteria, true, false, out criteriaCanceled);

            if (sims.IsEmpty)
            {
                SimpleMessageDialog.Show(title, Common.Localize("HouseholdInteraction:NoChoices"));
                return(null);
            }

            Dictionary <Lot, bool>       lotLookup   = new Dictionary <Lot, bool>();
            Dictionary <Household, bool> houseLookup = new Dictionary <Household, bool>();

            List <LotHouseItem> houses = new List <LotHouseItem>();

            foreach (IMiniSimDescription miniSim in sims.All)
            {
                SimDescription sim = miniSim as SimDescription;
                if (sim == null)
                {
                    continue;
                }

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

                if (sim.Household.IsPreviousTravelerHousehold)
                {
                    continue;
                }

                if ((sim.LotHome != null) && (!lotLookup.ContainsKey(sim.LotHome)))
                {
                    lotLookup.Add(sim.LotHome, true);
                }

                if (houseLookup.ContainsKey(sim.Household))
                {
                    continue;
                }
                houseLookup.Add(sim.Household, true);

                if (!Allow(GetLot(sim), sim.Household))
                {
                    continue;
                }

                houses.Add(new LotHouseItem(sim.LotHome, sim.Household, GetCount(sim.LotHome, sim.Household)));
            }

            foreach (Lot lot in LotManager.AllLots)
            {
                if (lotLookup.ContainsKey(lot))
                {
                    continue;
                }
                lotLookup.Add(lot, true);

                if (!Allow(lot, null))
                {
                    continue;
                }

                houses.Add(new LotHouseItem(lot, null, GetCount(lot, null)));
            }

            if (houses.Count == 1)
            {
                return(houses);
            }
            else
            {
                if ((AllSimsOnFilterCancel) && (criteriaCanceled))
                {
                    return(houses);
                }
                else
                {
                    if (CanApplyAll())
                    {
                        houses.Add(new LotHouseItem(null, null, 0));
                    }

                    CommonSelection <LotHouseItem> .Results selection = new CommonSelection <LotHouseItem>(title, houses, new LotTypeColumn()).SelectMultiple(maxSelection);

                    okayed = selection.mOkayed;

                    if ((selection.Count == 0) && (okayed))
                    {
                        return(houses);
                    }
                    else
                    {
                        foreach (LotHouseItem item in selection)
                        {
                            if (item.IsAll)
                            {
                                return(houses);
                            }
                        }

                        return(new List <LotHouseItem>(selection));
                    }
                }
            }
        }
Example #24
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 #25
0
        public override bool Run()
        {
            SimDescription hooker = null;

            Definition def = base.InteractionDefinition as Definition;

            if (def == null)
            {
                return(false);
            }

            try
            {
                StandardEntry();
                if (!Target.StartComputing(this, SurfaceHeight.Table, true))
                {
                    StandardExit();
                    return(false);
                }

                Target.StartVideo(Computer.VideoType.Chat);
                base.AnimateSim("GenericTyping");

                bool succeeded = true;
                if (base.DoTimedLoop(Computer.CheckWeather.kTimeToBrowse, ~(ExitReason.Replan | ExitReason.PlayIdle | ExitReason.ObjectStateChanged | ExitReason.MidRoutePushRequested | ExitReason.MaxSkillPointsReached | ExitReason.BuffFailureState | ExitReason.MoodFailure)))
                {
                    Dictionary <int, SimDescription> potentials = GetPotentials(Actor);

                    if (potentials.Values.Count > 0)
                    {
                        if (!def.mRandom)
                        {
                            hooker = new SimSelection(Common.Localize("OrderServices:Title"), Actor.SimDescription, potentials.Values, SimSelection.Type.ProfessionalServices, -1000).SelectSingle();
                            if (hooker == null)
                            {
                                Common.Notify(Common.Localize("Rendezvous:NoSelect", Actor.IsFemale));
                                succeeded = false;
                            }
                        }
                        else
                        {
                            int val = 0;
                            if (Actor.IsSelectable)
                            {
                                string text = StringInputDialog.Show(Common.Localize("OrderServices:Title"), Common.Localize("OrderServices:Prompt"), val.ToString());
                                if (string.IsNullOrEmpty(text))
                                {
                                    succeeded = false;
                                }

                                if (!int.TryParse(text, out val))
                                {
                                    SimpleMessageDialog.Show(Common.Localize("OrderServices:Title"), Common.Localize("Numeric:Error"));
                                    succeeded = false;
                                }
                            }
                            else
                            {
                                val = Actor.FamilyFunds * 2 / 100;
                            }

                            if (val > Actor.FamilyFunds || val < Actor.FamilyFunds)
                            {
                                if (Actor.IsSelectable)
                                {
                                    Common.Notify(Common.Localize("OrderServices:NoFunds", Actor.IsFemale));
                                }
                                succeeded = false;
                            }

                            if (succeeded)
                            {
                                // how much sexy can we afford?
                                bool allAbove = false;
                                foreach (SimDescription sim in potentials.Values)
                                {
                                    KamaSimtra skill = sim.SkillManager.GetSkill <KamaSimtra>(KamaSimtra.StaticGuid);
                                    if (skill == null)
                                    {
                                        continue;
                                    }

                                    if (skill.GetPayment() > Actor.FamilyFunds)
                                    {
                                        allAbove = true;
                                    }
                                    else
                                    {
                                        allAbove = false;
                                    }

                                    if (skill.GetPayment() > val)
                                    {
                                        continue;
                                    }
                                    hooker = sim;
                                }

                                if (hooker == null)
                                {
                                    if (!allAbove)
                                    {
                                        if (Actor.IsSelectable)
                                        {
                                            Common.Notify(Common.Localize("OrderServices:StopBeingCheap"));
                                        }
                                        succeeded = false;
                                    }
                                    else
                                    {
                                        if (Actor.IsSelectable)
                                        {
                                            Common.Notify(Common.Localize("OrderServices:NoFunds", Actor.IsFemale));
                                        }
                                        succeeded = false;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Common.Notify(Common.Localize("OrderServices:NoChoices", Actor.IsFemale));
                        succeeded = false;
                    }
                }

                if (succeeded && hooker != null)
                {
                    GetSimToLotEx(hooker, Actor.LotHome, def.mRandom);
                }

                Target.StopComputing(this, Computer.StopComputingAction.TurnOff, false);
                StandardExit();
                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Example #26
0
        public override bool ManualSetup(StoryProgressionObject manager)
        {
            if (!base.ManualSetup(manager)) return false;

            int originalID = Scenarios.TrackingID;
            Scenarios.TrackingID = ID;

            SimSelection sim = new SimSelection(this);
            try
            {
                if (!sim.Perform())
                {
                    if (!AcceptCancelDialog.Show(Common.Localize("FireScenario:ApplyAll")))
                    {
                        return false;
                    }
                }

                Scenarios.WriteTrack(false);
            }
            finally
            {
                Scenarios.TrackingID = originalID;
            }

            Sim = sim.SimDescription;
            return true;
        }