Exemple #1
0
        public static LongTermRelationshipTypes NextNegativeEnemyState(LongTermRelationshipTypes currentState)
        {
            switch (currentState)
            {
            case LongTermRelationshipTypes.OldFriend:
            case LongTermRelationshipTypes.BestFriend:
            case LongTermRelationshipTypes.BestFriendsForever:
            case LongTermRelationshipTypes.Partner:
            case LongTermRelationshipTypes.Fiancee:
            case LongTermRelationshipTypes.Spouse:
                return(LongTermRelationshipTypes.Friend);

            case LongTermRelationshipTypes.RomanticInterest:
            case LongTermRelationshipTypes.Friend:
            case LongTermRelationshipTypes.GoodFriend:
                return(LongTermRelationshipTypes.Acquaintance);

            case LongTermRelationshipTypes.Ex:
            case LongTermRelationshipTypes.ExSpouse:
            case LongTermRelationshipTypes.Stranger:
            case LongTermRelationshipTypes.Acquaintance:
            case LongTermRelationshipTypes.DistantFriend:
                return(LongTermRelationshipTypes.Enemy);

            case LongTermRelationshipTypes.OldEnemies:
            case LongTermRelationshipTypes.Enemy:
            case LongTermRelationshipTypes.Disliked:
                return(LongTermRelationshipTypes.Undefined);
            }
            return(LongTermRelationshipTypes.Undefined);
        }
        protected static void AddKey(ShortTermContextTypes stc, LongTermRelationshipTypes ltr, bool isActive, string key)
        {
            Dictionary <LongTermRelationshipTypes, Dictionary <bool, List <string> > > ltrList;

            if (!ActionAvailabilityData.sStcInteractions.TryGetValue(stc, out ltrList))
            {
                return;
            }

            Dictionary <bool, List <string> > activeList;

            if (!ltrList.TryGetValue(ltr, out activeList))
            {
                activeList = new Dictionary <bool, List <string> >();
                ltrList.Add(ltr, activeList);
            }

            List <string> keyList;

            if (!activeList.TryGetValue(isActive, out keyList))
            {
                keyList = new List <string>();
                activeList.Add(isActive, keyList);
            }

            if (!keyList.Contains(key))
            {
                keyList.Add(key);
            }
        }
Exemple #3
0
        protected static void ForceChangeState(Relationship relation, LongTermRelationshipTypes state)
        {
            LongTermRelationship.InteractionBits bits = relation.LTR.LTRInteractionBits & (LongTermRelationship.InteractionBits.HaveBeenBestFriends | LongTermRelationship.InteractionBits.HaveBeenFriends | LongTermRelationship.InteractionBits.HaveBeenPartners);

            relation.LTR.ForceChangeState(state);
            relation.LTR.AddInteractionBit(bits);
        }
Exemple #4
0
        public void LikingChange()
        {
            // This seems awfully complicated. Do you need all this to update a
            // relationship and display the icon?
            Relationship relationship            = Relationship.Get(Actor, Target, createIfNone: true);
            LongTermRelationshipTypes currentLTR = relationship.CurrentLTR;

            relationship.LTR.UpdateLiking(kLikingPenaltyPetFight);
            LongTermRelationshipTypes currentLTR2 = relationship.CurrentLTR;

            SocialComponent.SetSocialFeedbackForActorAndTarget(CommodityTypes.Friendly,
                                                               Actor, Target, true, 0, currentLTR, currentLTR2);
        }
        public override bool AfterExitingRabbitHole()
        {
            // This seems awfully complicated. Do you need all this to update a
            // relationship and display the icon?
            Relationship relationship            = Relationship.Get(Actor, mPet, createIfNone: true);
            LongTermRelationshipTypes currentLTR = relationship.CurrentLTR;

            relationship.LTR.UpdateLiking(EWTakePetToVetWounds.kLTRBoostOfVetVisit);
            LongTermRelationshipTypes currentLTR2 = relationship.CurrentLTR;

            SocialComponent.SetSocialFeedbackForActorAndTarget(CommodityTypes.Friendly,
                                                               Actor, mPet, true, 0, currentLTR, currentLTR2);
            return(base.AfterExitingRabbitHole());
        }
        public void DoLtrAdjustment(bool goodReaction)
        {
            float        num          = !goodReaction ? (0f - kLtrLossForFail) : kLtrGainForSuccess;
            Relationship relationship = Relationship.Get(Actor, mMedicineCat,
                                                         createIfNone: true);
            LongTermRelationshipTypes currentLTR = relationship.CurrentLTR;
            float currentLTRLiking = relationship.CurrentLTRLiking;

            relationship.LTR.UpdateLiking(num);
            LongTermRelationshipTypes currentLTR2 = relationship.CurrentLTR;
            float currentLTRLiking2 = relationship.CurrentLTRLiking;
            bool  isPositive        = currentLTRLiking2 >= currentLTRLiking;

            SocialComponent.SetSocialFeedbackForActorAndTarget(CommodityTypes.Friendly,
                                                               Actor, mMedicineCat, isPositive, 0, currentLTR, currentLTR2);
        }
Exemple #7
0
        protected static void Perform(Relationship relation, LongTermRelationshipTypes newState)
        {
            if (relation.CurrentLTR == newState)
            {
                return;
            }

            LongTermRelationshipTypes oldState = relation.CurrentLTR;

            LTRData data = LTRData.Get(newState);

            if (data == null)
            {
                return;
            }

            bool  isChangingWorlds = GameStates.sIsChangingWorlds;
            float liking           = relation.LTR.Liking;

            try
            {
                GameStates.sIsChangingWorlds = true;

                relation.LTR.ChangeBitsForState(newState);
                relation.LTR.ChangeState(newState);
            }
            finally
            {
                relation.LTR.mLiking         = liking;
                GameStates.sIsChangingWorlds = isChangingWorlds;
            }

            switch (newState)
            {
            case LongTermRelationshipTypes.Partner:
            case LongTermRelationshipTypes.Fiancee:
            case LongTermRelationshipTypes.Spouse:
                relation.SimDescriptionA.SetPartner(relation.SimDescriptionB);
                break;
            }

            relation.LTR.UpdateUI();

            SetPreviousState(relation.SimDescriptionA, relation.SimDescriptionB, newState);
            SetPreviousState(relation.SimDescriptionB, relation.SimDescriptionA, newState);
        }
Exemple #8
0
        protected static void SetPreviousState(SimDescription a, SimDescription b, LongTermRelationshipTypes type)
        {
            if ((!a.Teen) && (!b.Teen))
            {
                return;
            }

            Dictionary <ulong, LongTermRelationshipTypes> otherSims;

            if (!sPreviousState.TryGetValue(a.SimDescriptionId, out otherSims))
            {
                otherSims = new Dictionary <ulong, LongTermRelationshipTypes>();
                sPreviousState[a.SimDescriptionId] = otherSims;
            }

            otherSims[b.SimDescriptionId] = type;
        }
Exemple #9
0
        public static LongTermRelationshipTypes NextPositiveRomanceState(LongTermRelationshipTypes currentState)
        {
            switch (currentState)
            {
            case LongTermRelationshipTypes.RomanticInterest:
                return(LongTermRelationshipTypes.Partner);

            case LongTermRelationshipTypes.Partner:
                return(LongTermRelationshipTypes.Fiancee);

            case LongTermRelationshipTypes.Fiancee:
                return(LongTermRelationshipTypes.Spouse);

            case LongTermRelationshipTypes.Spouse:
                return(LongTermRelationshipTypes.Undefined);

            default:
                return(LongTermRelationshipTypes.RomanticInterest);
            }
        }
Exemple #10
0
        public void AfterAttack()
        {
            // This seems awfully complicated. Do you need all this to update a
            // relationship and display the icon?
            Relationship relationship            = Relationship.Get(Actor, Target, createIfNone: true);
            LongTermRelationshipTypes currentLTR = relationship.CurrentLTR;

            relationship.LTR.UpdateLiking(kLikingPenaltyPetHumanAttack);
            LongTermRelationshipTypes currentLTR2 = relationship.CurrentLTR;

            SocialComponent.SetSocialFeedbackForActorAndTarget(CommodityTypes.Insulting,
                                                               Actor, Target, false, 0, currentLTR, currentLTR2);

            if (Actor.TraitManager.HasElement(TraitNames.AggressivePet))
            {
                Actor.Motives.SetDecay(CommodityKind.Fun, decay: true);
                Actor.Motives.SetValue(CommodityKind.Fun, Actor.Motives.GetValue(CommodityKind.Fun) +
                                       PetSocialTunables.kAttackShredFunUpdate);
            }
        }
Exemple #11
0
        public static LongTermRelationshipTypes NextNegativeRomanceState(LongTermRelationshipTypes currentState)
        {
            switch (currentState)
            {
            case LongTermRelationshipTypes.Partner:
            case LongTermRelationshipTypes.Fiancee:
                return(LongTermRelationshipTypes.Ex);

            case LongTermRelationshipTypes.Spouse:
                return(LongTermRelationshipTypes.ExSpouse);

            case LongTermRelationshipTypes.Acquaintance:
                return(LongTermRelationshipTypes.Stranger);

            case LongTermRelationshipTypes.Stranger:
                return(LongTermRelationshipTypes.Undefined);

            default:
                return(LongTermRelationshipTypes.Acquaintance);
            }
        }
Exemple #12
0
        protected static void ForceChangeState(Relationship relation, LongTermRelationshipTypes state)
        {
            LongTermRelationship.InteractionBits bits = relation.LTR.LTRInteractionBits & (LongTermRelationship.InteractionBits.HaveBeenBestFriends | LongTermRelationship.InteractionBits.HaveBeenFriends | LongTermRelationship.InteractionBits.HaveBeenPartners);

            LTRData data = LTRData.Get(state);

            if (relation.LTR.RelationshipIsInappropriate(data))
            {
                relation.LTR.ChangeBitsForState(state);
                relation.LTR.ChangeState(state);
                relation.LTR.UpdateUI();
            }
            else
            {
                relation.LTR.ForceChangeState(state);
            }

            if (state == LongTermRelationshipTypes.Spouse)
            {
                relation.SimDescriptionA.Genealogy.Marry(relation.SimDescriptionB.Genealogy);

                MidlifeCrisisManager.OnBecameMarried(relation.SimDescriptionA, relation.SimDescriptionB);

                relation.LTR.RemoveInteractionBit(LongTermRelationship.InteractionBits.Divorce);
                relation.LTR.AddInteractionBit(LongTermRelationship.InteractionBits.Marry);

                relation.SetMarriedInGame();

                if (SeasonsManager.Enabled)
                {
                    relation.WeddingAnniversary      = new WeddingAnniversary(SeasonsManager.CurrentSeason, (int)SeasonsManager.DaysElapsed);
                    relation.WeddingAnniversary.SimA = relation.SimDescriptionA;
                    relation.WeddingAnniversary.SimB = relation.SimDescriptionB;
                    relation.WeddingAnniversary.CreateAlarm();
                }
            }

            relation.LTR.AddInteractionBit(bits);
        }
        protected static void AddKey(ShortTermContextTypes stc, LongTermRelationshipTypes ltr, bool isActive, string key)
        {
            Dictionary<LongTermRelationshipTypes, Dictionary<bool, List<string>>> ltrList;
            if (!ActionAvailabilityData.sStcInteractions.TryGetValue(stc, out ltrList)) return;

            Dictionary<bool, List<string>> activeList;
            if (!ltrList.TryGetValue(ltr, out activeList))
            {
                activeList = new Dictionary<bool, List<string>>();
                ltrList.Add(ltr, activeList);
            }

            List<string> keyList;
            if (!activeList.TryGetValue(isActive, out keyList))
            {
                keyList = new List<string>();
                activeList.Add(isActive, keyList);
            }

            if (!keyList.Contains(key))
            {
                keyList.Add(key);
            }
        }
Exemple #14
0
        public static List<SocialInteractionCandidate> Get(string name, Sim actor, Sim target, ShortTermContextTypes stc, LongTermRelationshipTypes group, bool isActive, ActiveTopic topic, bool isAutonomous)
        {
            sMsg += Common.NewLine + "GetActionAvailability " + name + " " + stc + " " + group + " " + isActive;

            Dictionary<LongTermRelationshipTypes, Dictionary<bool, List<string>>> dictionary;
            if (ActionAvailabilityData.sStcInteractions.TryGetValue(stc, out dictionary))
            {
                return GetInternal(name, actor, target, group, isActive, topic, isAutonomous, dictionary);
            }
            else
            {
                sMsg += Common.NewLine + " Empty";
            }
            return new List<SocialInteractionCandidate>();
        }
Exemple #15
0
        private static List<SocialInteractionCandidate> GetInternal(string name, Sim actor, Sim target, LongTermRelationshipTypes group, bool isActive, ActiveTopic topic, bool isAutonomous, Dictionary<LongTermRelationshipTypes, Dictionary<bool, List<string>>> interactionCategories)
        {
            Dictionary<bool, List<string>> dictionary;
            List<string> list2;
            bool flag = interactionCategories.TryGetValue(group, out dictionary);
            if (!flag)
            {
                sMsg += Common.NewLine + " Try Default";

                group = LongTermRelationshipTypes.Default;
                flag = interactionCategories.TryGetValue(group, out dictionary);
            }
            List<SocialInteractionCandidate> list = new List<SocialInteractionCandidate>();
            if (flag && dictionary.TryGetValue(isActive, out list2))
            {
                sMsg += Common.NewLine + " Choices = " + list2.Count;

                foreach (string str in list2)
                {
                    ActionData data = ActionData.Get(str);
                    GreyedOutTooltipCallback greyedOutTooltipCallback = null;

                    InteractionTestResult result = data.Test(actor, target, isAutonomous, topic, ref greyedOutTooltipCallback);

                    sMsg += Common.NewLine + "  " + str + " = " + result;

                    if ((IUtil.IsPass(result) || (greyedOutTooltipCallback != null)) || Sims3.Gameplay.UI.PieMenu.PieMenuShowFailureReason)
                    {
                        list.Add(new SocialInteractionCandidate(str, data.GetParentMenu(actor, target), topic));
                    }
                }
            }
            return list;
        }
Exemple #16
0
        public bool BumpToLowerState(Common.IStatGenerator stats, SimDescription a, SimDescription b, bool story)
        {
            if (a.Partner == b)
            {
                if ((!AllowBreakup(this, a, Managers.Manager.AllowCheck.None)) || (!AllowBreakup(this, b, Managers.Manager.AllowCheck.None)))
                {
                    IncStat("BumpDown: Breakup: User Denied");
                    stats.IncStat("BumpDown: Breakup: User Denied");
                    return(false);
                }

                SetElapsedTime <DayOfLastPartnerOption>(a);
                SetElapsedTime <DayOfLastPartnerOption>(b);

                try
                {
                    a.Partner = null;
                }
                catch (Exception e)
                {
                    Common.DebugException(a, e);
                }

                try
                {
                    b.Partner = null;
                }
                catch (Exception e)
                {
                    Common.DebugException(b, e);
                }

                if ((a.CreatedSim != null) && (a.CreatedSim.BuffManager != null))
                {
                    a.CreatedSim.BuffManager.RemoveElement(BuffNames.NewlyEngaged);
                    a.CreatedSim.BuffManager.RemoveElement(BuffNames.FirstKiss);
                    a.CreatedSim.BuffManager.RemoveElement(BuffNames.FirstRomance);
                    a.CreatedSim.BuffManager.RemoveElement(BuffNames.JustMarried);
                    a.CreatedSim.BuffManager.RemoveElement(BuffNames.WeddingDay);
                }

                if ((b.CreatedSim != null) && (b.CreatedSim.BuffManager != null))
                {
                    b.CreatedSim.BuffManager.RemoveElement(BuffNames.NewlyEngaged);
                    b.CreatedSim.BuffManager.RemoveElement(BuffNames.FirstKiss);
                    b.CreatedSim.BuffManager.RemoveElement(BuffNames.FirstRomance);
                    b.CreatedSim.BuffManager.RemoveElement(BuffNames.JustMarried);
                    b.CreatedSim.BuffManager.RemoveElement(BuffNames.WeddingDay);
                }

                if (story)
                {
                    Stories.PrintStory(this, "Breakup", new object[] { a, b }, null);
                }
            }

            Relationship relation = ManagerSim.GetRelationship(a, b);

            if (relation != null)
            {
                LongTermRelationshipTypes currentState = relation.LTR.CurrentLTR;

                LongTermRelationshipTypes nextState = ChangeRelationship.NextNegativeRomanceState(currentState, relation.IsPetToPetRelationship);
                if (nextState != LongTermRelationshipTypes.Undefined)
                {
                    float liking = relation.LTR.Liking;

                    AddStat("BumpDown: Pre", liking);
                    stats.AddStat("BumpDown: Pre", liking);

                    ForceChangeState(relation, nextState);

                    int score = AddScoring("BumpDown: Hate Loss", ScoringLookup.GetScore("HateRomanceLoss", b));
                    if ((SimTypes.IsSelectable(a)) || (SimTypes.IsSelectable(b)) || (stats.AddScoring("BumpDown: Hate Loss", score) <= 0))
                    {
                        if (liking > relation.LTR.Liking)
                        {
                            try
                            {
                                relation.LTR.SetLiking(liking);
                            }
                            catch (Exception e)
                            {
                                Common.DebugException(a, b, e);

                                IncStat("BumpDown: Reset Liking Fail");
                                stats.IncStat("BumpDown: Reset Liking Fail");
                            }
                        }
                    }

                    AddStat("BumpDown: Post", relation.LTR.Liking);
                    stats.AddStat("BumpDown: Post", relation.LTR.Liking);

                    IncStat("BumpDown " + relation.LTR.CurrentLTR);
                    stats.IncStat("BumpDown " + relation.LTR.CurrentLTR);
                }
            }
            return(true);
        }
Exemple #17
0
        public bool BumpToHigherState(Common.IStatGenerator stats, SimDescription a, SimDescription b)
        {
            Relationship relation = ManagerSim.GetRelationship(a, b);

            if (relation == null)
            {
                IncStat("BumpUp: Bad Relation");
                stats.IncStat("BumpUp: Bad Relation");
                return(false);
            }

            LongTermRelationshipTypes currentState = relation.LTR.CurrentLTR;

            LongTermRelationshipTypes nextState = ChangeRelationship.NextPositiveRomanceState(currentState, relation.IsPetToPetRelationship);

            if (nextState == LongTermRelationshipTypes.Undefined)
            {
                IncStat("BumpUp: No Next Level");
                stats.IncStat("BumpUp: No Next Level");
                return(false);
            }

            if (currentState == LongTermRelationshipTypes.RomanticInterest)
            {
                if (Flirts.IsCloselyRelated(a, b))
                {
                    IncStat("BumpUp: Related");
                    stats.IncStat("BumpUp: Related");
                    return(false);
                }

                if ((!GetValue <AllowSteadyOption, bool>(a)) || (!GetValue <AllowSteadyOption, bool>(b)))
                {
                    IncStat("BumpUp: Steady Denied");
                    stats.IncStat("BumpUp: Steady Denied");
                    return(false);
                }

                if (!DumpOtherRomances(stats, a, b))
                {
                    return(false);
                }
                if (!DumpOtherRomances(stats, b, a))
                {
                    return(false);
                }

                if ((a.Partner != b) || (b.Partner != a))
                {
                    try
                    {
                        a.SetPartner(b);

                        SetElapsedTime <DayOfLastPartnerOption>(a);
                        SetElapsedTime <DayOfLastPartnerOption>(b);

                        SetElapsedTime <DayOfLastRomanceOption>(a);
                        SetElapsedTime <DayOfLastRomanceOption>(b);
                    }
                    catch (Exception e)
                    {
                        Common.DebugException(a, b, e);
                    }
                }
            }
            else if (currentState == LongTermRelationshipTypes.Partner)
            {
                if ((a.TeenOrBelow) || (b.TeenOrBelow))
                {
                    if ((!GetValue <AllowMarriageOption, bool>(a)) || (!GetValue <AllowMarriageOption, bool>(b)))
                    {
                        IncStat("BumpUp: Marriage Denied");
                        stats.IncStat("BumpUp: Marriage Denied");
                        return(false);
                    }
                    else if (GetValue <MarriageScenario.AllowTeenOnlyOnPregnancyOption, bool>())
                    {
                        if ((!a.IsPregnant) && (!b.IsPregnant))
                        {
                            IncStat("BumpUp: Non-Pregnant Marriage Denied");
                            stats.IncStat("BumpUp: Non-Pregnant Marriage Denied");
                            return(false);
                        }
                    }
                }

                relation.ProposerDesc = a;
            }

            float liking = relation.LTR.Liking;

            ForceChangeState(relation, nextState);

            if (liking > relation.LTR.Liking)
            {
                relation.LTR.SetLiking(liking);
            }

            if (currentState == relation.LTR.CurrentLTR)
            {
                IncStat("Invalid: " + currentState);
                stats.IncStat("Invalid: " + currentState);
                return(false);
            }

            IncStat("BumpUp: " + currentState + " to " + relation.LTR.CurrentLTR);
            stats.IncStat("BumpUp: " + currentState + " to " + relation.LTR.CurrentLTR);
            return(true);
        }
Exemple #18
0
        protected static void OnSocialEvent(Event e)
        {
            using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration TeenAdultControl:OnSocialEvent"))
            {
                SocialEvent socialEvent = e as SocialEvent;
                if ((socialEvent != null) && (socialEvent.WasAccepted))
                {
                    Common.StringBuilder msg = new Common.StringBuilder("TeenAdult:OnSocialEvent");

                    Sim actor  = socialEvent.Actor as Sim;
                    Sim target = socialEvent.TargetObject as Sim;

                    if ((actor == null) || (target == null))
                    {
                        return;
                    }

                    if ((!actor.SimDescription.Teen) || (actor.SimDescription.Teen == target.SimDescription.Teen))
                    {
                        return;
                    }

                    msg += Common.NewLine + actor.FullName;
                    msg += Common.NewLine + target.FullName;
                    msg += Common.NewLine + socialEvent.SocialName;

                    Relationship relation = Relationship.Get(actor, target, false);
                    if (relation == null)
                    {
                        return;
                    }

                    LongTermRelationshipTypes newState = LongTermRelationshipTypes.Undefined;

                    switch (socialEvent.SocialName)
                    {
                    case "Propose Going Steady":
                        if ((actor.Partner != target.SimDescription) || (target.Partner != actor.SimDescription))
                        {
                            Relationships.SetPartner(actor.SimDescription, target.SimDescription);

                            newState = LongTermRelationshipTypes.Partner;
                        }
                        break;

                    case "Propose Marriage":
                        newState = LongTermRelationshipTypes.Fiancee;
                        break;

                    case "Have Private Wedding":
                    case "Get Married Using Wedding Arch":
                        newState = LongTermRelationshipTypes.Spouse;
                        break;

                    case "Lets Just Be Friends":
                    case "Break Up":
                        newState = LongTermRelationshipTypes.Ex;

                        SetPreviousState(actor.SimDescription, target.SimDescription, newState);
                        SetPreviousState(target.SimDescription, actor.SimDescription, newState);
                        break;

                    case "Divorce":
                        newState = LongTermRelationshipTypes.ExSpouse;

                        SetPreviousState(actor.SimDescription, target.SimDescription, newState);
                        SetPreviousState(target.SimDescription, actor.SimDescription, newState);
                        break;

                    default:
                        if (!relation.AreRomantic())
                        {
                            List <SocialRuleRHS> list = SocialRuleRHS.Get(socialEvent.SocialName);
                            if (list != null)
                            {
                                bool romantic = false;

                                foreach (SocialRuleRHS rhs in list)
                                {
                                    if ((rhs.InteractionBitsAdded & LongTermRelationship.InteractionBits.Romantic) == LongTermRelationship.InteractionBits.Romantic)
                                    {
                                        romantic = true;
                                        break;
                                    }
                                }

                                if (romantic)
                                {
                                    msg += Common.NewLine + "A";

                                    newState = LongTermRelationshipTypes.RomanticInterest;
                                }
                            }
                        }
                        else
                        {
                            msg += Common.NewLine + "C";

                            newState = relation.CurrentLTR;
                        }
                        break;
                    }

                    msg += Common.NewLine + newState;

                    if (newState != LongTermRelationshipTypes.Undefined)
                    {
                        Perform(relation, newState);
                    }

                    //Common.DebugStackLog(msg);
                }
            }
        }
Exemple #19
0
        protected static bool BumpUp(SimDescription a, SimDescription b, bool prompt, bool romantic)
        {
            Relationship relation = Relationship.Get(a, b, true);

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

            LongTermRelationshipTypes currentState = relation.LTR.CurrentLTR;

            LongTermRelationshipTypes nextState = LongTermRelationshipTypes.Undefined;

            if (romantic)
            {
                nextState = NextPositiveRomanceState(currentState);
            }
            else
            {
                nextState = NextPositiveFriendState(currentState);
            }

            if (nextState == LongTermRelationshipTypes.Undefined)
            {
                if (prompt)
                {
                    SimpleMessageDialog.Show(Common.Localize("Romance:BumpUpTitle"), Common.Localize("Romance:TooHigh"));
                }
                return(false);
            }

            /*
             * if (relation.LTR.RelationshipIsInappropriate(LTRData.Get(nextState)))
             * {
             *  if (prompt)
             *  {
             *      SimpleMessageDialog.Show(Common.Localize("Romance:BumpUpTitle"), Common.Localize ("Romance:Improper", new object[] { Common.LocalizeStatus (a, b, nextState) }));
             *  }
             *  return false;
             * }
             */

            if ((romantic) && (a.Genealogy.IsBloodRelated(b.Genealogy)))
            {
                if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:BloodPrompt", a.IsFemale, new object [] { a, b }))))
                {
                    return(false);
                }
            }

            if ((currentState == LongTermRelationshipTypes.RomanticInterest) && (romantic))
            {
                if ((a.Partner != null) && (a.Partner != b))
                {
                    if ((b.Partner != null) && (b.Partner != a))
                    {
                        if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:DualPartnerPrompt", a.IsFemale, new object[] { a, b }))))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:PartnerPrompt", a.IsFemale, new object[] { a }))))
                        {
                            return(false);
                        }
                    }
                }
                else if ((b.Partner != null) && (b.Partner != a))
                {
                    if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:PartnerPrompt", b.IsFemale, new object[] { b }))))
                    {
                        return(false);
                    }
                }

                if (a.Partner != null)
                {
                    BumpDown(a, a.Partner, false, true);
                }

                if (b.Partner != null)
                {
                    BumpDown(b, b.Partner, false, true);
                }

                if (a.TraitManager == null)
                {
                    a.Fixup();
                }

                if (b.TraitManager == null)
                {
                    b.Fixup();
                }

                Relationships.SetPartner(a, b);
            }

            ForceChangeState(relation, nextState);

            if (relation.LTR.CurrentLTR == LongTermRelationshipTypes.BestFriendsForever)
            {
                bool isPetBFF = ((!a.IsHuman) || (!b.IsHuman));

                a.HasBFF = true;
                b.HasBFF = true;
                FindAndRemoveBFF(a, b, isPetBFF);
                FindAndRemoveBFF(b, a, isPetBFF);
            }

            if (currentState == relation.LTR.CurrentLTR)
            {
                return(false);
            }

            StyledNotification.Format format = new StyledNotification.Format(Common.Localize("Romance:Success", a.IsFemale, new object[] { a, b, LocalizeStatus(a, b, relation.LTR.CurrentLTR) }), StyledNotification.NotificationStyle.kGameMessagePositive);
            format.mTNSCategory = NotificationManager.TNSCategory.Lessons;
            StyledNotification.Show(format);
            return(true);
        }
Exemple #20
0
        public static List <SocialInteractionCandidate> GetSocialsForSTC(CommodityTypes commodity, Sim actor, Sim target, Relationship r, Conversation c, bool isAutonomous)
        {
            ShortTermContextTypes             types2;
            List <SocialInteractionCandidate> list3;
            LongTermRelationshipTypes         stranger = LongTermRelationshipTypes.Stranger;

            if (r != null)
            {
                stranger = r.LTR.CurrentLTR;
            }
            bool flag = (r != null) && ((r.STC == null) || (commodity == r.STC.CurrentCommodity));

            if (!SocialComponent.SocialCommodityIsAvailable(commodity, target, actor, r))
            {
                sMsg += Common.NewLine + "Denied";
                return(null);
            }
            if (flag)
            {
                bool flag2;
                types2 = Conversation.GetCurrentSTC(actor, target, r, c, out flag2);

                sMsg += Common.NewLine + "CurrentSTC " + types2 + " " + r.STC.CurrentCommodity;
            }
            else
            {
                types2 = STCData.FirstSTC(commodity);

                sMsg += Common.NewLine + "FirstSTC " + types2 + " " + r.STC.CurrentCommodity;
            }

            List <SocialInteractionCandidate> collection = Get("1", actor, target, types2, stranger, true, null, isAutonomous);

            if ((isAutonomous && (r != null)) && (r.STC.CurrentCommodity == commodity))
            {
                ShortTermContextTypes types4;
                collection = new List <SocialInteractionCandidate>(collection);
                ShortTermContextTypes types3 = STCData.PreviousSTC(types2);
                do
                {
                    collection.AddRange(Get("2", actor, target, types3, stranger, true, null, isAutonomous));

                    types4 = types3;
                    types3 = STCData.PreviousSTC(types3);
                }while (types4 != types3);
            }
            if (isAutonomous)
            {
                goto Label_014C;
            }
            ShortTermContextTypes stc = STCData.FirstSTC(commodity);

Label_00C4:
            List <SocialInteractionCandidate> traitList = Get("3", actor, target, stc, stranger, true, null, isAutonomous);

            foreach (SocialInteractionCandidate candidate in traitList)
            {
                ActionData action = ActionData.Get(candidate.Name);
                if (Conversation.SimHasTraitEncouragingOrRequiringSocial(actor, action))
                {
                    if (stc != STCData.FirstSTC(commodity))
                    {
                        candidate.OnlyAppearsInTraitMenu = true;
                    }
                    collection.Add(candidate);
                }
            }
            ShortTermContextTypes types6 = STCData.NextSTC(stc);

            if (types6 != stc)
            {
                stc = types6;
                goto Label_00C4;
            }
Label_014C:
            sMsg += Common.NewLine + "Final = " + collection.Count;

            list3 = new List <SocialInteractionCandidate>();
            foreach (SocialInteractionCandidate candidate2 in collection)
            {
                sMsg += Common.NewLine + "Test " + candidate2.Name;

                ActionData data2 = ActionData.Get(candidate2.Name);
                if (flag || !data2.DoesSocialOnlyAppearWhenSTCIsCurrent)
                {
                    sMsg += Common.NewLine + " Added " + candidate2.Name;

                    list3.Add(candidate2);
                }
            }
            return(list3);
        }
Exemple #21
0
        protected static bool BumpDown(SimDescription a, SimDescription b, bool prompt, bool romantic)
        {
            Relationship relation = Relationship.Get(a, b, true);

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

            LongTermRelationshipTypes currentState = relation.LTR.CurrentLTR;

            LongTermRelationshipTypes nextState = LongTermRelationshipTypes.Undefined;

            if (romantic)
            {
                nextState = NextNegativeRomanceState(currentState);
            }
            else
            {
                nextState = NextNegativeEnemyState(currentState);
            }

            if (nextState == LongTermRelationshipTypes.Undefined)
            {
                if (prompt)
                {
                    SimpleMessageDialog.Show(Common.Localize("Romance:BumpDownTitle"), Common.Localize("Romance:TooLow"));
                }
                return(false);
            }

            /*
             * if (relation.LTR.RelationshipIsInappropriate(LTRData.Get(nextState)))
             * {
             *  if (prompt)
             *  {
             *      SimpleMessageDialog.Show(Common.Localize("Romance:BumpDownTitle"), Common.Localize ("Romance:Improper", new object[] { Common.LocalizeStatus (a, b, nextState) }));
             *  }
             *  return false;
             * }
             */

            if ((a.Partner == b) || (b.Partner == a))
            {
                try
                {
                    a.Partner = null;
                }
                catch
                { }

                try
                {
                    b.Partner = null;
                }
                catch
                { }
            }

            ForceChangeState(relation, nextState);

            if (nextState == LongTermRelationshipTypes.Stranger)
            {
                Relationship.RemoveRelationship(relation);
            }
            else
            {
                if (currentState == relation.LTR.CurrentLTR)
                {
                    return(false);
                }
            }

            StyledNotification.Format format = new StyledNotification.Format(Common.Localize("Romance:Success", a.IsFemale, new object[] { a, b, LocalizeStatus(a, b, nextState) }), StyledNotification.NotificationStyle.kGameMessagePositive);
            format.mTNSCategory = NotificationManager.TNSCategory.Lessons;
            StyledNotification.Show(format);
            return(true);
        }
Exemple #22
0
        public override bool Run()
        {
            try
            {
                if (!(Actor.Posture is FairyHouse.FairyHousePosture))
                {
                    return(false);
                }

                mLinkedActor = LinkedInteractionInstance.InstanceActor;
                if (!StartSync(mIsMaster))
                {
                    if (!Target.IsNextInteractionAFairyHouseInteraction(Actor))
                    {
                        Target.PushGetOutAsContinuation(Actor);
                    }
                    return(false);
                }

                StandardEntry(false);
                BeginCommodityUpdates();
                mCurrentStateMachine = Actor.Posture.CurrentStateMachine;
                if (mIsMaster)
                {
                    SetActorAndEnter("y", Actor, "WooHoo");
                    SetActorAndEnter("fairyHouse", Target, "Enter");
                    RockGemMetalBase.HandleNearbyWoohoo(Target, RockGemMetalBase.HowMuchWooHoo.MoreWoohoo);
                    Animate("fairyHouse", "WooHoo");
                    Animate("fairyHouse", "Exit");

                    IWooHooDefinition definition = InteractionDefinition as IWooHooDefinition;

                    CommonWoohoo.RunPostWoohoo(Actor, mLinkedActor, Target, definition.GetStyle(this), definition.GetLocation(Target), true);

                    if (CommonPregnancy.IsSuccess(Actor, mLinkedActor, Autonomous, definition.GetStyle(this)))
                    {
                        CommonPregnancy.Impregnate(Actor, mLinkedActor, Autonomous, definition.GetStyle(this));
                    }
                }
                else
                {
                    DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));
                }

                EventTracker.SendEvent(EventTypeId.kWooHooedInTheFairyHouse, Actor, mLinkedActor);
                EndCommodityUpdates(true);
                StandardExit(false, false);
                FinishLinkedInteraction(mIsMaster);
                WaitForSyncComplete();

                LongTermRelationshipTypes longTermRelationship = Relationship.GetLongTermRelationship(Actor, mLinkedActor);
                Relationship relationship = Relationship.Get(Actor, mLinkedActor, true);
                if (mIsMaster && (relationship != null))
                {
                    relationship.LTR.UpdateLiking(FairyHouse.kLTRIncreaseOnWoohoo);
                    LongTermRelationshipTypes currentLTR = relationship.CurrentLTR;
                    SocialComponent.SetSocialFeedback(CommodityTypes.Friendly, Actor, true, 0x0, longTermRelationship, currentLTR);
                    SocialComponent.SetSocialFeedback(CommodityTypes.Friendly, mLinkedActor, true, 0x0, longTermRelationship, currentLTR);
                }

                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception exception)
            {
                Common.Exception(Actor, Target, exception);
                return(false);
            }
        }
Exemple #23
0
        private static List <SocialInteractionCandidate> GetInternal(string name, Sim actor, Sim target, LongTermRelationshipTypes group, bool isActive, ActiveTopic topic, bool isAutonomous, Dictionary <LongTermRelationshipTypes, Dictionary <bool, List <string> > > interactionCategories)
        {
            Dictionary <bool, List <string> > dictionary;
            List <string> list2;
            bool          flag = interactionCategories.TryGetValue(group, out dictionary);

            if (!flag)
            {
                sMsg += Common.NewLine + " Try Default";

                group = LongTermRelationshipTypes.Default;
                flag  = interactionCategories.TryGetValue(group, out dictionary);
            }
            List <SocialInteractionCandidate> list = new List <SocialInteractionCandidate>();

            if (flag && dictionary.TryGetValue(isActive, out list2))
            {
                sMsg += Common.NewLine + " Choices = " + list2.Count;

                foreach (string str in list2)
                {
                    ActionData data = ActionData.Get(str);
                    GreyedOutTooltipCallback greyedOutTooltipCallback = null;

                    InteractionTestResult result = data.Test(actor, target, isAutonomous, topic, ref greyedOutTooltipCallback);

                    sMsg += Common.NewLine + "  " + str + " = " + result;

                    if ((IUtil.IsPass(result) || (greyedOutTooltipCallback != null)) || Sims3.Gameplay.UI.PieMenu.PieMenuShowFailureReason)
                    {
                        list.Add(new SocialInteractionCandidate(str, data.GetParentMenu(actor, target), topic));
                    }
                }
            }
            return(list);
        }
Exemple #24
0
        // From Conversation
        public static List <SocialInteractionCandidate> GetSocialsForSTC(CommodityTypes commodity, Sim actor, Sim target, Relationship r, Conversation c, bool isAutonomous, ref string msg)
        {
            using (Common.TestSpan span = new Common.TestSpan(TimeSpanLogger.Bin, "GetSocialsForSTC: " + commodity, Common.DebugLevel.Stats))
            {
                ShortTermContextTypes             str2;
                List <SocialInteractionCandidate> list3;
                LongTermRelationshipTypes         group = LongTermRelationshipTypes.Stranger;
                if (r != null)
                {
                    group = r.LTR.CurrentLTR;
                }
                bool flag = (r != null) && ((r.STC == null) || (commodity == r.STC.CurrentCommodity));
                if (!SocialComponent.SocialCommodityIsAvailable(commodity, target, actor, r))
                {
                    return(null);
                }
                if (flag)
                {
                    bool flag2;
                    str2 = Conversation.GetCurrentSTC(actor, target, r, c, out flag2);
                }
                else
                {
                    str2 = STCData.FirstSTC(commodity);
                }
                List <SocialInteractionCandidate> collection = ActionAvailabilityData.Get(actor, target, str2, group, true, null, isAutonomous);
                if ((isAutonomous && (r != null)) && (r.STC.CurrentCommodity == commodity))
                {
                    ShortTermContextTypes str4;
                    collection = new List <SocialInteractionCandidate>(collection);
                    ShortTermContextTypes str3 = STCData.PreviousSTC(str2);
                    do
                    {
                        collection.AddRange(ActionAvailabilityData.Get(actor, target, str3, group, true, null, isAutonomous));
                        str4 = str3;
                        str3 = STCData.PreviousSTC(str3);
                    }while (!(str4 == str3));
                }
                if (isAutonomous)
                {
                    goto Label_0167;
                }
                ShortTermContextTypes category = STCData.FirstSTC(commodity);
Label_00D5:
                msg += Common.NewLine + "GetSocialsForSTC " + category;

                foreach (SocialInteractionCandidate candidate in Get(actor, target, category, group, true, null, isAutonomous, ref msg))
                {
                    ActionData action = ActionData.Get(candidate.Name);
                    if (Conversation.SimHasTraitEncouragingOrRequiringSocial(actor, action))
                    {
                        if (category != STCData.FirstSTC(commodity))
                        {
                            candidate.OnlyAppearsInTraitMenu = true;
                        }

                        collection.Add(candidate);
                    }
                }
                ShortTermContextTypes str6 = STCData.NextSTC(category);
                if (str6 != category)
                {
                    category = str6;
                    goto Label_00D5;
                }
Label_0167:
                msg += Common.NewLine + "Collection " + collection.Count;

                list3 = new List <SocialInteractionCandidate>();
                foreach (SocialInteractionCandidate candidate2 in collection)
                {
                    ActionData data2 = ActionData.Get(candidate2.Name);
                    if (flag || !data2.DoesSocialOnlyAppearWhenSTCIsCurrent)
                    {
                        msg += Common.NewLine + " " + candidate2.Name;

                        list3.Add(candidate2);
                    }
                }
                return(list3);
            }
        }
Exemple #25
0
        protected static void Perform(Relationship relation, LongTermRelationshipTypes newState)
        {
            if (relation.CurrentLTR == newState) return;

            LongTermRelationshipTypes oldState = relation.CurrentLTR;

            LTRData data = LTRData.Get(newState);
            if (data == null) return;

            bool isChangingWorlds = GameStates.sIsChangingWorlds;
            float liking = relation.LTR.Liking;
            try
            {
                GameStates.sIsChangingWorlds = true;

                relation.LTR.ChangeBitsForState(newState);
                relation.LTR.ChangeState(newState);
            }
            finally
            {
                relation.LTR.mLiking = liking;
                GameStates.sIsChangingWorlds = isChangingWorlds;
            }

            switch (newState)
            {
                case LongTermRelationshipTypes.Partner:
                case LongTermRelationshipTypes.Fiancee:
                case LongTermRelationshipTypes.Spouse:
                    relation.SimDescriptionA.SetPartner(relation.SimDescriptionB);
                    break;
            }

            relation.LTR.UpdateUI();

            SetPreviousState(relation.SimDescriptionA, relation.SimDescriptionB, newState);
            SetPreviousState(relation.SimDescriptionB, relation.SimDescriptionA, newState);
        }
Exemple #26
0
        protected static bool BumpUp(SimDescription a, SimDescription b, bool prompt, bool romantic)
        {
            Relationship relation = Relationship.Get(a, b, true);

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

            LongTermRelationshipTypes currentState = relation.LTR.CurrentLTR;

            LongTermRelationshipTypes nextState = LongTermRelationshipTypes.Undefined;

            if (romantic)
            {
                nextState = NextPositiveRomanceState(currentState);
            }
            else
            {
                nextState = NextPositiveFriendState(currentState);
            }

            if (nextState == LongTermRelationshipTypes.Undefined)
            {
                if (prompt)
                {
                    SimpleMessageDialog.Show(Common.Localize("Romance:BumpUpTitle"), Common.Localize("Romance:TooHigh"));
                }
                return(false);
            }

            /*
             * if (relation.LTR.RelationshipIsInappropriate(LTRData.Get(nextState)))
             * {
             *  if (prompt)
             *  {
             *      SimpleMessageDialog.Show(Common.Localize("Romance:BumpUpTitle"), Common.Localize ("Romance:Improper", new object[] { Common.LocalizeStatus (a, b, nextState) }));
             *  }
             *  return false;
             * }
             */

            if ((romantic) && (a.Genealogy.IsBloodRelated(b.Genealogy)))
            {
                if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:BloodPrompt", a.IsFemale, new object [] { a, b }))))
                {
                    return(false);
                }
            }

            if ((currentState == LongTermRelationshipTypes.RomanticInterest) && (romantic))
            {
                if ((a.Partner != null) && (a.Partner != b))
                {
                    if ((b.Partner != null) && (b.Partner != a))
                    {
                        if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:DualPartnerPrompt", a.IsFemale, new object[] { a, b }))))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:PartnerPrompt", a.IsFemale, new object[] { a }))))
                        {
                            return(false);
                        }
                    }
                }
                else if ((b.Partner != null) && (b.Partner != a))
                {
                    if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:PartnerPrompt", b.IsFemale, new object[] { b }))))
                    {
                        return(false);
                    }
                }

                if (a.Partner != null)
                {
                    BumpDown(a, a.Partner, false, true);
                }

                if (b.Partner != null)
                {
                    BumpDown(b, b.Partner, false, true);
                }

                if (a.TraitManager == null)
                {
                    a.Fixup();
                }

                if (b.TraitManager == null)
                {
                    b.Fixup();
                }

                Relationships.SetPartner(a, b);
            }

            ForceChangeState(relation, nextState);

            if (romantic)
            {
                if (prompt && relation.RomanceVisibilityState != null)
                {
                    long time = 0;
                    relation.TryGetActiveRomanceStartTime(out time);

                    int days = 0;
                    if (time != 0)
                    {
                        days = (int)SimClock.ElapsedTime(TimeUnit.Days, new DateAndTime(time));
                    }

                    string text = StringInputDialog.Show(Common.Localize("Romance:StartTime"), Common.Localize("Romance:StartPrompt", a.IsFemale, new object[] { a, b, SimClock.ElapsedCalendarDays() }), days.ToString());
                    if (string.IsNullOrEmpty(text))
                    {
                        return(false);
                    }

                    int mValue = 0;
                    if (!int.TryParse(text, out mValue) || mValue > SimClock.ElapsedCalendarDays())
                    {
                        SimpleMessageDialog.Show(Common.Localize("Romance:StartTime"), Common.Localize("Numeric:ErrorInputIgnored"));
                    }
                    else
                    {
                        relation.RomanceVisibilityState.mStartTime = SimClock.Subtract(SimClock.CurrentTime(), TimeUnit.Days, (float)mValue);
                    }
                }
            }

            if (relation.LTR.CurrentLTR == LongTermRelationshipTypes.BestFriendsForever)
            {
                bool isPetBFF = ((!a.IsHuman) || (!b.IsHuman));

                a.HasBFF = true;
                b.HasBFF = true;
                FindAndRemoveBFF(a, b, isPetBFF);
                FindAndRemoveBFF(b, a, isPetBFF);
            }

            if (currentState == relation.LTR.CurrentLTR)
            {
                return(false);
            }

            StyledNotification.Format format = new StyledNotification.Format(Common.Localize("Romance:Success", a.IsFemale, new object[] { a, b, LocalizeStatus(a, b, relation.LTR.CurrentLTR) }), StyledNotification.NotificationStyle.kGameMessagePositive);
            format.mTNSCategory = NotificationManager.TNSCategory.Lessons;
            StyledNotification.Show(format);
            return(true);
        }
Exemple #27
0
        public static bool CheckCheating(Sim observer, Sim actor, Sim target, JealousyLevel jealousyLevel)
        {
            if (CommonSocials.IsPolyamorous(actor.SimDescription, target.SimDescription, observer.SimDescription))
            {
                return(false);
            }

            if (target.HasTrait(TraitNames.NoJealousy))
            {
                return(false);
            }

            if (!actor.HasTrait(TraitNames.NoJealousy) && (jealousyLevel != JealousyLevel.None))
            {
                foreach (Situation situation in actor.Autonomy.SituationComponent.Situations)
                {
                    if (situation.DoesSituationRuleOutJealousy(observer, actor, target, jealousyLevel))
                    {
                        return(false);
                    }
                }

                Relationship relationship = Relationship.Get(observer, actor, false);
                if (relationship != null)
                {
                    if (!LTRData.Get(relationship.LTR.CurrentLTR).IsRomantic)
                    {
                        if ((actor.Partner != null) && (actor.Partner != target.SimDescription))
                        {
                            bool         flag          = observer.Genealogy.IsBloodRelated(actor.Partner.Genealogy);
                            Relationship relationship2 = Relationship.Get(observer.SimDescription, actor.Partner, false);
                            if (relationship2 != null)
                            {
                                LTRData data2 = LTRData.Get(relationship2.LTR.CurrentLTR);
                                flag |= data2.IsFriendly;
                            }

                            if (flag)
                            {
                                SocialComponent.OnSomeoneICareAboutWasCheatedOn(observer, actor.Partner, actor.SimDescription, target.SimDescription, jealousyLevel);
                                return(true);
                            }
                        }
                    }
                    else
                    {
                        // Custom
                        switch (jealousyLevel)
                        {
                        case JealousyLevel.Medium:
                        case JealousyLevel.High:
                            GreyedOutTooltipCallback greyedOutTooltipCallback = null;
                            if (CommonSocials.TestAllowBreakup(actor, true, ref greyedOutTooltipCallback))
                            {
                                RomanceVisibilityState.PushAccuseSimOfBetrayal(observer, actor);
                            }
                            return(true);
                        }

                        LongTermRelationshipTypes longTermRelationship = Relationship.GetLongTermRelationship(observer, actor);
                        SocialComponent.PlayReactionAndUpdateRelationshipOnJealousy(observer, actor.SimDescription, target.SimDescription, jealousyLevel);
                        LongTermRelationshipTypes currentLTR = Relationship.GetLongTermRelationship(observer, actor);
                        SocialComponent.SetSocialFeedback(CommodityTypes.Insulting, observer, false, 0x0, longTermRelationship, currentLTR);
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemple #28
0
        protected static void OnLTRChanged(Event e)
        {
            using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration TeenAdultControl:OnLTRChanged"))
            {
                if (!sInLTRChanged)
                {
                    try
                    {
                        sInLTRChanged = true;

                        RelationshipLTRChangedEvent ltrEvent = e as RelationshipLTRChangedEvent;
                        if ((ltrEvent != null) && (ltrEvent.OldLTR != ltrEvent.RelationshipState))
                        {
                            Common.StringBuilder msg = new Common.StringBuilder("TeenAdult:OnLTRChanged");

                            Relationship relation = ltrEvent.Relationship;

                            SimDescription descA = relation.SimDescriptionA;
                            SimDescription descB = relation.SimDescriptionB;

                            bool perform = false;

                            LTRData oldLTR = LTRData.Get(ltrEvent.OldLTR);
                            if (oldLTR != null)
                            {
                                if (LongTermRelationship.RelationshipIsInappropriate(oldLTR, descA, descB, ltrEvent.OldLTR))
                                {
                                    perform = true;
                                }
                            }

                            LongTermRelationshipTypes wasRel = ltrEvent.RelationshipState;

                            msg += Common.NewLine + relation.SimDescriptionA.FullName;
                            msg += Common.NewLine + relation.SimDescriptionB.FullName;
                            msg += Common.NewLine + "Old: " + ltrEvent.OldLTR;
                            msg += Common.NewLine + "Was: " + wasRel;
                            msg += Common.NewLine + "Perform: " + perform;

                            if ((perform) && (descA.IsHuman) && (descB.IsHuman))
                            {
                                if (((descA.Teen) && (descB.YoungAdultOrAbove)) || ((descB.Teen) && (descA.YoungAdultOrAbove)))
                                {
                                    sTracer.Perform();

                                    if (sTracer.mRevert)
                                    {
                                        Perform(relation, ltrEvent.OldLTR);

                                        msg += Common.NewLine + "Now: " + ltrEvent.RelationshipState;
                                    }

                                    if (!sTracer.mIgnore)
                                    {
                                        msg += Common.NewLine + sTracer;

                                        Common.DebugStackLog(msg);
                                    }
                                }
                            }
                        }
                    }
                    finally
                    {
                        sInLTRChanged = false;
                    }
                }
            }
        }
Exemple #29
0
 public NewLevel(LongTermRelationshipTypes state, bool up, bool romantic)
 {
     mState    = state;
     mUp       = up;
     mRomantic = romantic;
 }
Exemple #30
0
 protected static string LocalizeStatus(SimDescription a, SimDescription b, LongTermRelationshipTypes state)
 {
     return(LTRData.Get(state).GetName(a, b));
 }
Exemple #31
0
        protected static void SetPreviousState(SimDescription a, SimDescription b, LongTermRelationshipTypes type)
        {
            if ((!a.Teen) && (!b.Teen)) return;

            Dictionary<ulong,LongTermRelationshipTypes> otherSims;
            if (!sPreviousState.TryGetValue(a.SimDescriptionId, out otherSims))
            {
                otherSims = new Dictionary<ulong, LongTermRelationshipTypes>();
                sPreviousState[a.SimDescriptionId] = otherSims;
            }

            otherSims[b.SimDescriptionId] = type;
        }
Exemple #32
0
        private static bool RelationshipIsInappropriate(LTRData data, IMiniSimDescription a, IMiniSimDescription b, LongTermRelationshipTypes currentLTR)
        {
            if (!data.IsRomantic)
            {
                return(false);
            }

            if ((a.ChildOrBelow) || (b.ChildOrBelow))
            {
                return(true);
            }

            return(false);
        }
Exemple #33
0
        public static List <SocialInteractionCandidate> Get(Sim actor, Sim target, ShortTermContextTypes category, LongTermRelationshipTypes group, bool isActive, ActiveTopic topic, bool isAutonomous, ref string msg)
        {
            Dictionary <LongTermRelationshipTypes, Dictionary <bool, List <string> > > dictionary;
            List <SocialInteractionCandidate> list = new List <SocialInteractionCandidate>();

            if (ActionAvailabilityData.sStcInteractions.TryGetValue(category, out dictionary))
            {
                Dictionary <bool, List <string> > dictionary2;
                List <string> list2;
                bool          flag = dictionary.TryGetValue(group, out dictionary2);
                if (!flag)
                {
                    group = LongTermRelationshipTypes.Default;
                    flag  = dictionary.TryGetValue(group, out dictionary2);
                }
                if (!flag || !dictionary2.TryGetValue(isActive, out list2))
                {
                    msg += Common.NewLine + "Get Fail 1 " + category;
                    return(list);
                }

                msg += Common.NewLine + "Get Found " + category + " " + list2.Count;

                foreach (string str in list2)
                {
                    ActionData data = ActionData.Get(str);
                    GreyedOutTooltipCallback greyedOutTooltipCallback = null;

                    InteractionTestResult result = data.Test(actor, target, isAutonomous, topic, ref greyedOutTooltipCallback);

                    msg += Common.NewLine + " " + str + " " + result;

                    if ((IUtil.IsPass(result) || (greyedOutTooltipCallback != null)) || Sims3.Gameplay.UI.PieMenu.PieMenuShowFailureReason)
                    {
                        list.Add(new SocialInteractionCandidate(str, data.GetParentMenu(actor, target), topic));
                    }
                }
            }
            else
            {
                msg += Common.NewLine + "Get Fail 2 " + category;
            }

            return(list);
        }
Exemple #34
0
        protected override bool Run(SimDescription a, SimDescription b)
        {
            Relationship relation = Relationship.Get(a, b, true);

            if (relation == null)
            {
                return(true);
            }

            LongTermRelationshipTypes currentState = relation.LTR.CurrentLTR;

            List <NewLevel> allOptions = new List <NewLevel>();

            int count = 0;

            LongTermRelationshipTypes newState = NextNegativeEnemyState(currentState);

            while ((count < 25) && (newState != LongTermRelationshipTypes.Undefined))
            {
                count++;

                LTRData level = LTRData.Get(newState);
                if ((level != null) && (!RelationshipIsInappropriate(relation.LTR, level)))
                {
                    allOptions.Insert(0, new NewLevel(newState, false, false));
                }

                newState = NextNegativeEnemyState(newState);
            }

            if (SimTypes.IsEquivalentSpecies(a, b))
            {
                newState = NextNegativeRomanceState(currentState);
                while ((count < 25) && (newState != LongTermRelationshipTypes.Undefined))
                {
                    count++;

                    LTRData level = LTRData.Get(newState);
                    if ((level != null) && (!RelationshipIsInappropriate(relation.LTR, level)))
                    {
                        allOptions.Insert(0, new NewLevel(newState, false, true));
                    }

                    newState = NextNegativeRomanceState(newState);
                }
            }

            allOptions.Add(new NewLevel(currentState, true, false));

            newState = NextPositiveFriendState(currentState);
            while ((count < 25) && (newState != LongTermRelationshipTypes.Undefined))
            {
                count++;

                LTRData level = LTRData.Get(newState);
                if ((level != null) && (!RelationshipIsInappropriate(relation.LTR, level)))
                {
                    allOptions.Add(new NewLevel(newState, true, false));
                }

                newState = NextPositiveFriendState(newState);
            }

            if (SimTypes.IsEquivalentSpecies(a, b))
            {
                newState = NextPositiveRomanceState(currentState);
                while ((count < 25) && (newState != LongTermRelationshipTypes.Undefined))
                {
                    count++;

                    LTRData level = LTRData.Get(newState);
                    if ((level != null) && (!RelationshipIsInappropriate(relation.LTR, level)))
                    {
                        allOptions.Add(new NewLevel(newState, true, true));
                    }

                    newState = NextPositiveRomanceState(newState);
                }
            }

            Dictionary <LongTermRelationshipTypes, bool> states = new Dictionary <LongTermRelationshipTypes, bool>();

            List <NewLevel> options = new List <NewLevel>();

            foreach (NewLevel level in allOptions)
            {
                if (level.mState == LongTermRelationshipTypes.Undefined)
                {
                    continue;
                }

                if (states.ContainsKey(level.mState))
                {
                    continue;
                }
                states.Add(level.mState, true);

                count++;

                level.Count = count;

                options.Add(level);
            }

            NewLevel choice = new RelationshipSelection(a.FullName, options, a, b).SelectSingle();

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

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

            if (choice.mState == currentState)
            {
                return(true);
            }

            Dictionary <LongTermRelationshipTypes, bool> lookup = new Dictionary <LongTermRelationshipTypes, bool>();

            lookup.Add(relation.LTR.CurrentLTR, true);

            bool bFirst = true;

            if (choice.mUp)
            {
                int recurseCount = 0;
                while ((recurseCount < 25) && (BumpUp(a, b, bFirst, choice.mRomantic)))
                {
                    recurseCount++;

                    if (choice.mState == relation.LTR.CurrentLTR)
                    {
                        return(true);
                    }

                    if (lookup.ContainsKey(relation.LTR.CurrentLTR))
                    {
                        return(true);
                    }
                    lookup.Add(relation.LTR.CurrentLTR, true);

                    bFirst = false;
                }
            }
            else
            {
                int recurseCount = 0;
                while ((recurseCount < 25) && (BumpDown(a, b, bFirst, choice.mRomantic)))
                {
                    recurseCount++;

                    if (choice.mState == relation.LTR.CurrentLTR)
                    {
                        return(true);
                    }

                    if (lookup.ContainsKey(relation.LTR.CurrentLTR))
                    {
                        return(true);
                    }
                    lookup.Add(relation.LTR.CurrentLTR, true);

                    bFirst = false;
                }
            }

            return(true);
        }
Exemple #35
0
        public static List <SocialInteractionCandidate> Get(string name, Sim actor, Sim target, ShortTermContextTypes stc, LongTermRelationshipTypes group, bool isActive, ActiveTopic topic, bool isAutonomous)
        {
            sMsg += Common.NewLine + "GetActionAvailability " + name + " " + stc + " " + group + " " + isActive;

            Dictionary <LongTermRelationshipTypes, Dictionary <bool, List <string> > > dictionary;

            if (ActionAvailabilityData.sStcInteractions.TryGetValue(stc, out dictionary))
            {
                return(GetInternal(name, actor, target, group, isActive, topic, isAutonomous, dictionary));
            }
            else
            {
                sMsg += Common.NewLine + " Empty";
            }
            return(new List <SocialInteractionCandidate>());
        }
Exemple #36
0
        public static List<SocialInteractionCandidate> Get(Sim actor, Sim target, ShortTermContextTypes category, LongTermRelationshipTypes group, bool isActive, ActiveTopic topic, bool isAutonomous, ref string msg)
        {
            Dictionary<LongTermRelationshipTypes, Dictionary<bool, List<string>>> dictionary;
            List<SocialInteractionCandidate> list = new List<SocialInteractionCandidate>();

            if (ActionAvailabilityData.sStcInteractions.TryGetValue(category, out dictionary))
            {
                Dictionary<bool, List<string>> dictionary2;
                List<string> list2;
                bool flag = dictionary.TryGetValue(group, out dictionary2);
                if (!flag)
                {
                    group = LongTermRelationshipTypes.Default;
                    flag = dictionary.TryGetValue(group, out dictionary2);
                }
                if (!flag || !dictionary2.TryGetValue(isActive, out list2))
                {
                    msg += Common.NewLine + "Get Fail 1 " + category;
                    return list;
                }

                msg += Common.NewLine + "Get Found " + category + " " + list2.Count;

                foreach (string str in list2)
                {
                    ActionData data = ActionData.Get(str);
                    GreyedOutTooltipCallback greyedOutTooltipCallback = null;

                    InteractionTestResult result = data.Test(actor, target, isAutonomous, topic, ref greyedOutTooltipCallback);

                    msg += Common.NewLine + " " + str + " " + result;

                    if ((IUtil.IsPass(result) || (greyedOutTooltipCallback != null)) || Sims3.Gameplay.UI.PieMenu.PieMenuShowFailureReason)
                    {
                        list.Add(new SocialInteractionCandidate(str, data.GetParentMenu(actor, target), topic));
                    }
                }
            }
            else
            {
                msg += Common.NewLine + "Get Fail 2 " + category;
            }

            return list;
        }