Example #1
0
 private bool TryDeductFunds(TattooChair ths, Sim giver, Sim receiver)
 {
     if (giver == receiver)
     {
         if (giver.FamilyFunds >= Tattooing.kCostTattooSelf)
         {
             receiver.ModifyFunds(-Tattooing.kCostTattooSelf);
             return(true);
         }
         return(false);
     }
     if (giver == ths.GetTattooArtist())
     {
         if (!CelebrityManager.TryModifyFundsWithCelebrityDiscount(receiver, giver, Tattooing.kCostTattooFromTattooArtist, true))
         {
             return(false);
         }
         return(true);
     }
     if (!CelebrityManager.TryModifyFundsWithCelebrityDiscount(receiver, giver, Tattooing.kCostTattooFromSim, true))
     {
         return(false);
     }
     return(true);
 }
Example #2
0
        public static void FalselyAccuseCheck(CelebrityManager This)
        {
            if (This.OwnerSim != null && !CantBeDisgraced(This) && !This.OwnerSim.IsSelectable)
            {
                Sim ownerSim = This.OwnerSim;
                if (This.Owner == null)
                {
                    return;
                }
                float num = 0f;

                List <IMiniRelationship> miniRelationships = Relationship.GetMiniRelationships(This.Owner);
                foreach (IMiniRelationship item in miniRelationships)
                {
                    switch (item.CurrentLTR)
                    {
                    case LongTermRelationshipTypes.Enemy:
                    case LongTermRelationshipTypes.OldEnemies:
                        num += 1f;
                        break;
                    }
                }
                float val = CelebrityManager.kBaseAccusationChance[This.Level - 1] + num * CelebrityManager.kPerEnemyAccusationChance[This.Level - 1];
                if (RandomUtil.RandomChance01(Math.Min(val, CelebrityManager.kMaxAccusationChance[This.Level - 1])))
                {
                    ownerSim.AddAlarm(RandomUtil.GetFloat(CelebrityManager.kFalselyAccuseMinDelay, CelebrityManager.kFalselyAccuseMaxDelay), TimeUnit.Minutes, This.TriggerFalseAccusation, "CelebrityManager: False Accusation delay alarm", AlarmType.AlwaysPersisted);
                }
            }
        }
            // Methods
            public override bool Test(Sim a, MusicalInstrument target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                try
                {
                    if (target.ActorsUsingMe.Count == 0x0)
                    {
                        return(false);
                    }
                    Sim          sim          = target.ActorsUsingMe[0x0];
                    Relationship relationship = Relationship.Get(a, sim, false);
                    if ((relationship != null) && (relationship.LTR.CurrentLTR == LongTermRelationshipTypes.Enemy))
                    {
                        return(false);
                    }
                    if (target.ActorsUsingMe.Contains(a))
                    {
                        return(false);
                    }

                    return(CelebrityManager.CanSocialize(a, sim));
                }
                catch (ResetException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    Common.Exception(a, target, e);
                    return(false);
                }
            }
Example #4
0
        public override bool InRabbitHole()
        {
            try
            {
                bool tookSemaphore = mTookSemaphore;
                GiveTattooEx.DisplayCAS(base.Actor, ref tookSemaphore);
                mTookSemaphore = tookSemaphore;

                if (!CelebrityManager.TryModifyFundsWithCelebrityDiscount(Actor, Target, Tattooing.kCostTattooDaySpa, true))
                {
                    return(false);
                }

                EventTracker.SendEvent(EventTypeId.kGotTattoo, Actor);
                Actor.BuffManager.AddElement(BuffNames.FightThePower, Origin.FromTattoo);
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Example #5
0
            public override bool Test(Sim a, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                try
                {
                    if (a == target)
                    {
                        return(false);
                    }

                    if (!Woohooer.Settings.mAllowTeenSkinnyDip)
                    {
                        if (target.SimDescription.TeenOrBelow)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if (target.SimDescription.ChildOrBelow)
                        {
                            return(false);
                        }
                    }

                    if (!CelebrityManager.CanSocialize(a, target))
                    {
                        return(false);
                    }

                    if (target.SimDescription.IsVisuallyPregnant)
                    {
                        greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(Localization.LocalizeString(target.IsFemale, "Gameplay/Actors/Sim:PregnantFailure", new object[0]));
                        return(false);
                    }

                    SwimmingInPool posture = a.Posture as SwimmingInPool;
                    SwimmingInPool pool2   = target.Posture as SwimmingInPool;
                    if (posture == null)
                    {
                        return(false);
                    }

                    if ((pool2 != null) && (pool2.ContainerPool == posture.ContainerPool))
                    {
                        return(false);
                    }

                    if (!Pool.SimOutfitSupportsSkinnyDipping(target, ref greyedOutTooltipCallback))
                    {
                        return(false);
                    }
                    return(true);
                }
                catch (Exception e)
                {
                    Common.Exception(a, target, e);
                    return(false);
                }
            }
Example #6
0
 public static bool CantBeDisgraced(CelebrityManager This)
 {
     if (This.Level >= 1)
     {
         if (This.mClearNameCooldown > 0f)
         {
             return(SimClock.ElapsedTime(TimeUnit.Minutes) - This.mClearNameCooldown < CelebrityManager.kCooldownAfterClearingName);
         }
         return(false);
     }
     return(true);
 }
Example #7
0
            public override bool Test(Sim a, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                try
                {
                    if (a == target)
                    {
                        return(false);
                    }

                    if (Woohooer.Settings.mAllowTeenSkinnyDip)
                    {
                        if (target.SimDescription.ChildOrBelow)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if (target.SimDescription.TeenOrBelow)
                        {
                            return(false);
                        }
                    }

                    if (!CelebrityManager.CanSocialize(a, target))
                    {
                        return(false);
                    }

                    SwimmingInPool posture = a.Posture as SwimmingInPool;
                    SwimmingInPool pool2   = target.Posture as SwimmingInPool;
                    if (posture == null)
                    {
                        return(false);
                    }
                    if ((pool2 != null) && (pool2.ContainerPool == posture.ContainerPool))
                    {
                        return(false);
                    }

                    if (!Pool.SimOutfitSupportsSkinnyDipping(target, ref greyedOutTooltipCallback))
                    {
                        return(false);
                    }
                    return(true);
                }
                catch (Exception e)
                {
                    Common.Exception(a, target, e);
                    return(false);
                }
            }
Example #8
0
            public override bool Test(Sim a, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                try
                {
                    SimDescription simDescription = target.SimDescription;
                    if (a == target)
                    {
                        return(false);
                    }

                    if (simDescription.ChildOrBelow || !target.IsHuman)
                    {
                        return(false);
                    }

                    /*
                     * if (simDescription.IsVisuallyPregnant)
                     * {
                     *  return false;
                     * }
                     */

                    if (!CelebrityManager.CanSocialize(a, target))
                    {
                        return(false);
                    }

                    if (simDescription.HasActiveRole && ((simDescription.AssignedRole.Type == Role.RoleType.Bartender) || (simDescription.AssignedRole.Type == Role.RoleType.Bouncer)))
                    {
                        return(false);
                    }

                    if (!(a.Posture is HotTubPosture))
                    {
                        return(false);
                    }

                    if (target.CurrentOutfitCategory == OutfitCategories.SkinnyDippingTowel)
                    {
                        greyedOutTooltipCallback = new GreyedOutTooltipCallback(new GrayedOutTooltipHelper(target.IsFemale, "ClothesStolenTooltip", null).GetTooltip);
                        return(false);
                    }
                    return(true);
                }
                catch (Exception e)
                {
                    Common.Exception(a, target, e);
                    return(false);
                }
            }
Example #9
0
        private static List <InteractionObjectPair> SocialsForNewConversation(SocialComponent ths, Sim actor, Sim target, bool isAutonomous)
        {
            string msg = null;

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

            string[]                 path     = new string[0x0];
            InteractionPriority      priority = new InteractionPriority(isAutonomous ? InteractionPriorityLevel.Autonomous : InteractionPriorityLevel.UserDirected);
            GreyedOutTooltipCallback greyedOutTooltipCallback = null;

            foreach (string str in CelebrityManager.CanSocialize(actor, target) ? new string[] { "Greet Friendly", "Greet Insulting" } : new string[] { "Greet Celebrity" })
            {
                InteractionObjectPair         iop        = new InteractionObjectPair(new SocialInteractionA.Definition(str, path, null, false), target);
                InteractionInstanceParameters parameters = new InteractionInstanceParameters(iop, actor, priority, isAutonomous, true);

                InteractionTestResult result = iop.InteractionDefinition.Test(ref parameters, ref greyedOutTooltipCallback);

                msg += Common.NewLine + "A " + str + " " + iop.InteractionDefinition.GetType().ToString() + " " + result;

                if (result == InteractionTestResult.Pass)
                {
                    list.Add(iop);
                }
            }
            foreach (SocialInteractionCandidate candidate in Conversation.GetActiveTopicInteractions(Relationship.GetLongTermRelationship(actor, target), actor, target, null, isAutonomous))
            {
                if (candidate.Topic.Data.AvailableWhenConversationStarts)
                {
                    InteractionObjectPair         pair2       = new InteractionObjectPair(new SocialInteractionA.Definition(candidate.Name, path, null, false), target);
                    InteractionInstanceParameters parameters2 = new InteractionInstanceParameters(pair2, actor, priority, isAutonomous, true);

                    InteractionTestResult result = pair2.InteractionDefinition.Test(ref parameters2, ref greyedOutTooltipCallback);

                    msg += Common.NewLine + "B " + candidate.Name + " " + pair2.InteractionDefinition.GetType().ToString() + " " + result;

                    if (result == InteractionTestResult.Pass)
                    {
                        list.Add(pair2);
                    }
                }
            }

            Common.WriteLog(msg);

            return(list);
        }
Example #10
0
        public ulong _NMakeUniqueID()
        {
            if (runI)
            {
                return(0);
            }

            //ulong id = mSimDescriptionId;

            try
            {
                for (int i = 0; i < 500 && !IsSimDescriptionIdUnique(safeID); i++)
                {
                    safeID++;
                }
                //id = safeID;
            }
            catch (Exception)
            {
                safeID += 10; //id = safeID;
            }


            if (safeID != mSimDescriptionId)
            {
                mOldSimDescriptionId = mSimDescriptionId;
            }

            mSimDescriptionId = safeID;

            if (CelebrityManager != null)
            {
                CelebrityManager.ResetOwnerSimDescription(mSimDescriptionId);
            }
            if (PetManager != null)
            {
                PetManager.ResetOwnerSimDescription(mSimDescriptionId);
            }
            if (TraitChipManager != null)
            {
                TraitChipManager.ResetOwnerSimDescription(mSimDescriptionId);
            }

            return(mSimDescriptionId);
        }
Example #11
0
        public static IEnumerable <InteractionObjectPair> GetAllInteractionsForPieMenu(SocialComponent ths, Sim actor)
        {
            Sim          mSim = ths.mSim;
            Relationship r    = Relationship.Get(mSim, actor, false);

            if ((r == null) || (r.LTR.CurrentLTR == LongTermRelationshipTypes.Stranger))
            {
                sMsg += Common.NewLine + "NewConversation2";

                return(SocialsForNewConversation(ths, actor, mSim, false));
            }
            if (ths.mSim.NeedsToBeGreeted(actor))
            {
                sMsg += Common.NewLine + "Greeting2";

                return(ths.SocialsForGreeting(actor, ths.mSim));
            }
            LTRData           data            = LTRData.Get(r.LTR.CurrentLTR);
            bool              flag            = false;
            GroupingSituation situationOfType = actor.GetSituationOfType <GroupingSituation>();

            if (situationOfType != null)
            {
                flag = situationOfType.IsSimInGroup(mSim);
            }
            DateAndTime whenLastTalked = Relationship.GetWhenLastTalked(actor, mSim);

            if (((!flag && (actor.Conversation == null)) && ((actor.Household != mSim.Household) && (data.HowWellWeKnowEachOther <= 0x1))) && (SimClock.ElapsedTime(TimeUnit.Hours, whenLastTalked) > 24f))
            {
                sMsg += Common.NewLine + "NewConversation3";

                return(SocialsForNewConversation(ths, actor, mSim, false));
            }
            if (!CelebrityManager.CanSocialize(actor, mSim))
            {
                sMsg += Common.NewLine + "Impress";

                return(SocialComponent.SocialsForImpressCelebrity(actor, mSim));
            }

            sMsg += Common.NewLine + "All";

            return(GetUnfilteredSocials(ths, actor, mSim, r));
        }
Example #12
0
            public override InteractionTestResult Test(ref InteractionInstanceParameters parameters, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                InteractionTestResult result = base.Test(ref parameters, ref greyedOutTooltipCallback);

                if (result == InteractionTestResult.Def_TestFailed)
                {
                    Sim actor  = parameters.Actor as Sim;
                    Sim target = parameters.Target as Sim;

                    if (!actor.SimDescription.IsVampire)
                    {
                        return(InteractionTestResult.Def_TestFailed);
                    }
                    else if (!actor.Posture.AllowsNormalSocials() || !target.Posture.AllowsNormalSocials())
                    {
                        return(InteractionTestResult.GenericFail);
                    }
                    else if ((actor.Posture is SwimmingInPool) || (target.Posture is SwimmingInPool))
                    {
                        return(InteractionTestResult.Social_TargetInPool);
                    }
                    else if (Relationship.AreStrangers(actor, target) || target.NeedsToBeGreeted(actor))
                    {
                        return(InteractionTestResult.Social_TargetIsUngreetedOnCurrentLot);
                    }
                    else if (!CelebrityManager.CanSocialize(actor, target))
                    {
                        return(InteractionTestResult.Social_TargetCannotBeSocializedWith);
                    }
                    else if (GetYouShouldTargets(actor, target).Count == 0x0)
                    {
                        greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(YouShould.LocalizeString("InteractionUnavailable", new object[0x0]));
                        return(InteractionTestResult.GenericFail);
                    }

                    return(InteractionTestResult.Pass);
                }

                return(result);
            }
Example #13
0
        public bool RunPaymentBehavior(out int tipAmount)
        {
            tipAmount = 0;
            Sim instanceActor = this.LinkedInteractionInstance.InstanceActor;
            int num           = BarProfessional.GetCost(DrinkDescription, this.Target.LotCurrent.GetMetaAutonomyType, this.Actor, this.Target, true) * 1;

            if (num == 0)
            {
                return(true);
            }
            float celebrityDiscount = this.Actor.CelebrityManager.GetCelebrityDiscount(true);

            tipAmount = GetTipAmount(this.Actor, instanceActor, this.Target.LotCurrent.GetMetaAutonomyType, DrinkDescription);
            if (Bartending.HasTabOpen(this.Actor, this.Target.LotCurrent))
            {
                Bartending.AddToTab(this.Target.LotCurrent, num);
                if (this.Actor.IsSelectable)
                {
                    this.Actor.ModifyFunds(-tipAmount);
                }
            }
            else
            {
                if (this.Actor.IsSelectable)
                {
                    if (num > this.Actor.FamilyFunds)
                    {
                        this.Actor.ShowTNSIfSelectable(BarProfessional.LocalizeString(this.Actor.IsFemale, "CantPayForDrink", new object[0]), StyledNotification.NotificationStyle.kSimTalking, instanceActor.ObjectId, this.Actor.ObjectId);
                        return(false);
                    }
                    int cost = num + tipAmount;
                    if (!CelebrityManager.TryModifyFundsWithCelebrityDiscount(this.Actor, this.Target, cost, celebrityDiscount, true))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Example #14
0
            protected override ManagerStory.Story PrintFormattedStory(StoryProgressionObject manager, string text, string summaryKey, object[] parameters, string[] extended, ManagerStory.StoryLogging logging)
            {
                if (SimTypes.IsSelectable(Sim))
                {
                    return(null);
                }

                if (mOldLevel >= Sim.CelebrityLevel)
                {
                    return(null);
                }

                if ((Sim.CelebrityLevel <= 1) && (!GetValue <ShowFirstLevelOption, bool>()))
                {
                    IncStat("First Level Denied");
                    return(null);
                }

                CelebrityManager celebrityManager = Sim.CelebrityManager;

                CelebrityLevelStaticData currentLevelStaticData = celebrityManager.GetCurrentLevelStaticData();

                if (currentLevelStaticData != null)
                {
                    string levelUpTnsLocalizationKey = currentLevelStaticData.LevelUpTnsLocalizationKey;
                    if (levelUpTnsLocalizationKey != null)
                    {
                        text = CelebrityManager.LocalizeSpreadsheetString(Sim.IsFemale, levelUpTnsLocalizationKey, new object[] { celebrityManager.LevelName, Sim });
                    }
                }

                if (extended == null)
                {
                    extended = new string[] { EAText.GetNumberString(Sim.CelebrityLevel) };
                }

                return(base.PrintFormattedStory(manager, text, "0x635e705292bc4b00", parameters, extended, logging));
            }
Example #15
0
        public static void CalculateAttractionScore(Relationship ths, bool displayNotice)
        {
            if (ths == null)
            {
                return;
            }

            ths.AttractionScore = 0;

            //if (ths.AttractionScore == float.PositiveInfinity)
            {
                SimDescription simA = ths.SimDescriptionA;
                SimDescription simB = ths.SimDescriptionB;
                if ((simA != null) && (simB != null) && (simA.IsHuman) && (simB.IsHuman))
                {
                    string reason;
                    GreyedOutTooltipCallback greyedOutTooltipCallback = null;
                    if (CommonSocials.CanGetRomantic(simA, simB, true, false, true, ref greyedOutTooltipCallback, out reason))
                    {
                        float score = RandomUtil.GetFloat(Relationship.kBaseRandomAttraction[0x0], Relationship.kBaseRandomAttraction[0x1]);

                        score += Woohooer.Settings.mAttractionBaseChanceScoringV3[PersistedSettings.GetSpeciesIndex(simA)];

                        float origScore = score;
                        float highScore = 0f;
                        float newScore  = 0f;

                        switch (ths.LTR.CurrentLTR)
                        {
                        case LongTermRelationshipTypes.Spouse:
                        case LongTermRelationshipTypes.Fiancee:
                            if (score > 0)
                            {
                                score *= 2;
                            }
                            else
                            {
                                score = 0;
                            }
                            break;
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        Relationship.AttractionType attractionType = Relationship.AttractionType.None;
                        foreach (Trait traitA in simA.TraitManager.List)
                        {
                            if (traitA.IsReward)
                            {
                                continue;
                            }

                            foreach (Trait traitB in simB.TraitManager.List)
                            {
                                if (traitB.IsReward)
                                {
                                    continue;
                                }

                                if (traitA.TraitGuid == traitB.TraitGuid)
                                {
                                    score += Relationship.kTraitModifier;
                                }
                                else if (TraitManager.DoTraitsConflict(traitA.Guid, traitB.Guid))
                                {
                                    score -= Relationship.kTraitModifier;
                                }
                            }
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Trait, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Trait;
                        }

                        Occupation occupation = simA.Occupation;
                        if (occupation != null)
                        {
                            score += occupation.CareerLevel * Relationship.kCareerBonusPerLevel;
                        }

                        Occupation occupation2 = simB.Occupation;
                        if (occupation2 != null)
                        {
                            score += occupation2.CareerLevel * Relationship.kCareerBonusPerLevel;
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Career, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Career;
                        }

                        foreach (Skill skill in simA.SkillManager.List)
                        {
                            score += skill.SkillLevel * Relationship.kSkillBonusPerLevel;
                        }

                        foreach (Skill skill2 in simB.SkillManager.List)
                        {
                            score += skill2.SkillLevel * Relationship.kSkillBonusPerLevel;
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Skill, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Skill;
                        }

                        List <OccultTypes> listA = OccultTypeHelper.CreateList(simA);
                        List <OccultTypes> listB = OccultTypeHelper.CreateList(simB);

                        foreach (OccultTypes typeA in listA)
                        {
                            if (listB.Contains(typeA))
                            {
                                score += Relationship.kBonusForMatchingOccult;
                            }
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Occult, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Occult;
                        }

                        CelebrityManager celebrityManagerA = simA.CelebrityManager;
                        if (celebrityManagerA != null)
                        {
                            score += celebrityManagerA.Level * Relationship.kCelebrityBonusPerLevel;
                        }

                        CelebrityManager celebrityManagerB = simB.CelebrityManager;
                        if (celebrityManagerB != null)
                        {
                            score += celebrityManagerB.Level * Relationship.kCelebrityBonusPerLevel;
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Celebrity, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Celebrity;
                        }

                        if (simA.Zodiac == simB.Zodiac)
                        {
                            score += Relationship.kMatchingSignsBonus;
                        }

                        if (simA.FavoriteColor == simB.FavoriteColor)
                        {
                            score += Relationship.kMatchingSignsBonus / 2;
                        }

                        if (simA.FavoriteFood == simB.FavoriteFood)
                        {
                            score += Relationship.kMatchingSignsBonus / 2;
                        }

                        if (simA.FavoriteMusic == simB.FavoriteMusic)
                        {
                            score += Relationship.kMatchingSignsBonus / 2;
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Astro, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Astro;
                        }

                        int familyFundsA = 0;

                        Household house = simA.Household;
                        if (house != null)
                        {
                            familyFundsA = house.FamilyFunds;
                        }

                        if (familyFundsA >= Relationship.kAttractedMoneyAmounts[0x2])
                        {
                            score += Relationship.kAttractedMoneyBonuses[0x2];
                        }
                        else if (familyFundsA >= Relationship.kAttractedMoneyAmounts[0x1])
                        {
                            score += Relationship.kAttractedMoneyBonuses[0x1];
                        }
                        else if (familyFundsA >= Relationship.kAttractedMoneyAmounts[0x0])
                        {
                            score += Relationship.kAttractedMoneyBonuses[0x0];
                        }

                        int familyFundsB = 0;

                        house = simB.Household;
                        if (house != null)
                        {
                            familyFundsB = house.FamilyFunds;
                        }
                        if (familyFundsB >= Relationship.kAttractedMoneyAmounts[0x2])
                        {
                            score += Relationship.kAttractedMoneyBonuses[0x2];
                        }
                        else if (familyFundsB >= Relationship.kAttractedMoneyAmounts[0x1])
                        {
                            score += Relationship.kAttractedMoneyBonuses[0x1];
                        }
                        else if (familyFundsB >= Relationship.kAttractedMoneyAmounts[0x0])
                        {
                            score += Relationship.kAttractedMoneyBonuses[0x0];
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Money, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Money;
                        }

                        foreach (TraitNames trait in sAttractionTraits)
                        {
                            if (simA.HasTrait(trait))
                            {
                                score += Relationship.kAttractionLifetimeRewardBonus;
                            }

                            if (simB.HasTrait(trait))
                            {
                                score += Relationship.kAttractionLifetimeRewardBonus;
                            }
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Attractive, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Attractive;
                        }

                        BuffManager buffManagerA = null;
                        if (simA.CreatedSim != null)
                        {
                            buffManagerA = simA.CreatedSim.BuffManager;
                        }

                        BuffManager buffManagerB = null;
                        if (simB.CreatedSim != null)
                        {
                            buffManagerB = simB.CreatedSim.BuffManager;
                        }

                        foreach (BuffNames posBuff in Relationship.kPositiveBuffList)
                        {
                            if ((buffManagerA != null) && (buffManagerA.HasElement(posBuff)))
                            {
                                score += Relationship.kPerBuffModifier;
                            }
                            if ((buffManagerB != null) && (buffManagerB.HasElement(posBuff)))
                            {
                                score += Relationship.kPerBuffModifier;
                            }
                        }

                        foreach (BuffNames negBuff in Relationship.kNegativeBuffList)
                        {
                            if ((buffManagerA != null) && (buffManagerA.HasElement(negBuff)))
                            {
                                score -= Relationship.kPerBuffModifier;
                            }
                            if ((buffManagerB != null) && (buffManagerB.HasElement(negBuff)))
                            {
                                score -= Relationship.kPerBuffModifier;
                            }
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Buffs, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Buffs;
                        }

                        score += simA.Fitness * 25;
                        score += simB.Fitness * 25;

                        if (simA.Weight < 0)
                        {
                            score += 25 - simA.Weight * -25;
                        }
                        else
                        {
                            score += 25 - simA.Weight * 25;
                        }

                        if (simB.Weight < 0)
                        {
                            score += 25 - simB.Weight * -25;
                        }
                        else
                        {
                            score += 25 - simB.Weight * 25;
                        }

                        int ageA = 0;
                        switch (simA.Age)
                        {
                        case CASAgeGenderFlags.Teen:
                            ageA = 1;
                            break;

                        case CASAgeGenderFlags.YoungAdult:
                            ageA = 2;
                            break;

                        case CASAgeGenderFlags.Adult:
                            ageA = 3;
                            break;

                        case CASAgeGenderFlags.Elder:
                            ageA = 4;
                            break;
                        }

                        int ageB = 0;
                        switch (simB.Age)
                        {
                        case CASAgeGenderFlags.Teen:
                            ageB = 1;
                            break;

                        case CASAgeGenderFlags.YoungAdult:
                            ageB = 2;
                            break;

                        case CASAgeGenderFlags.Adult:
                            ageB = 3;
                            break;

                        case CASAgeGenderFlags.Elder:
                            ageB = 4;
                            break;
                        }

                        score -= Math.Abs(ageA - ageB) * 25;

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Physical, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Physical;
                        }

                        ths.AttractionScore = score;

                        if (Common.kDebugging)
                        {
                            Common.DebugNotify(simA.FullName + Common.NewLine + simB.FullName + Common.NewLine + "Attraction: " + score + Common.NewLine + attractionType);
                        }

                        if ((ths.AreAttracted) && ((SimTypes.IsSelectable(simA)) || (SimTypes.IsSelectable(simB))))
                        {
                            if (AttractionHelper.TestEnableAttractionNPCController(ths))
                            {
                                if (ths.AttractionNPCController == null)
                                {
                                    ths.AttractionNPCController = new AttractionNPCBehaviorController(ths);
                                }
                            }
                            else
                            {
                                if (ths.AttractionNPCController != null)
                                {
                                    ths.AttractionNPCController.Dispose();
                                }
                            }

                            switch (ths.LTR.CurrentLTR)
                            {
                            case LongTermRelationshipTypes.Spouse:
                            case LongTermRelationshipTypes.Fiancee:
                            case LongTermRelationshipTypes.Ex:
                            case LongTermRelationshipTypes.ExSpouse:
                            case LongTermRelationshipTypes.Partner:
                            case LongTermRelationshipTypes.RomanticInterest:
                                break;

                            default:
                                if (displayNotice)
                                {
                                    Sim createdSimA = simA.CreatedSim;
                                    Sim createdSimB = simB.CreatedSim;
                                    if ((createdSimA != null) && (createdSimB != null))
                                    {
                                        if ((createdSimA.LotCurrent == createdSimB.LotCurrent) && (createdSimA.RoomId == createdSimB.RoomId))
                                        {
                                            VisualEffect effect = VisualEffect.Create("ep8AttractionSystem");
                                            createdSimB.ParentHeadlineFx(effect);
                                            effect.SubmitOneShotEffect(VisualEffect.TransitionType.SoftTransition);

                                            VisualEffect effect2 = VisualEffect.Create("ep8AttractionSystem");
                                            createdSimA.ParentHeadlineFx(effect2);
                                            effect2.SubmitOneShotEffect(VisualEffect.TransitionType.SoftTransition);

                                            ThoughtBalloonManager.BalloonData bd = new ThoughtBalloonManager.BalloonData(createdSimA.GetThumbnailKey());
                                            bd.BalloonType = ThoughtBalloonTypes.kSpeechBalloon;
                                            createdSimB.ThoughtBalloonManager.ShowBalloon(bd);

                                            ThoughtBalloonManager.BalloonData data2 = new ThoughtBalloonManager.BalloonData(createdSimB.GetThumbnailKey());
                                            data2.BalloonType = ThoughtBalloonTypes.kSpeechBalloon;
                                            createdSimA.ThoughtBalloonManager.ShowBalloon(data2);

                                            TNSNames reasonTNS = ths.GetReasonTNS(attractionType);
                                            if (reasonTNS != TNSNames.None)
                                            {
                                                Sim target = createdSimB.IsSelectable ? createdSimB : createdSimA;
                                                Sim actor  = (createdSimB == target) ? createdSimA : createdSimB;
                                                target.ShowTNSIfSelectable(reasonTNS, actor, target, new object[] { actor, target });
                                            }

                                            EventTracker.SendEvent(EventTypeId.kMeetAttractiveSim, createdSimB);
                                            EventTracker.SendEvent(EventTypeId.kMeetAttractiveSim, createdSimA);
                                            Audio.StartObjectSound(createdSimB.IsSelectable ? createdSimB.ObjectId : createdSimA.ObjectId, "sting_attraction", false);
                                        }
                                    }
                                }
                                break;
                            }
                        }
                        else if (ths.AttractionNPCController != null)
                        {
                            ths.AttractionNPCController.Dispose();
                        }
                    }
                    else
                    {
                        if (greyedOutTooltipCallback != null)
                        {
                            Common.DebugNotify(simA.FullName + Common.NewLine + simB.FullName + Common.NewLine + greyedOutTooltipCallback());
                        }
                    }
                }
            }

            if (ths.AttractionNPCController != null)
            {
                ths.AttractionNPCController.Dispose();
            }
        }
Example #16
0
        public static bool SetActiveActor(Sim actor, bool force)
        {
            if (NiecHelperSituation.__acorewIsnstalled__)
            {
                if (!Instantiator.kDontCallDGSACore && NFinalizeDeath.RUNIACORE != null)
                {
                    NFinalizeDeath.RUNIACORE(false);
                }
                else
                {
                    NFinalizeDeath.CheckNHSP();
                }
            }

            if (ShouldCheckTwoPlayer())
            {
                return(false);
            }

            if (!force && actor != null && !actor.IsSelectable)
            {
                return(false);
            }

            if (NiecHelperSituation.__acorewIsnstalled__)
            {
                if (!Sims3.Gameplay.GameStates.IsGameShuttingDown && !force && actor == null)
                {
                    return(false);
                }
            }

            try
            {
                throw new Exception("DEBUG SetActiveActor(Sim actor, bool force): " + (Type.GetType("Sims3.Gameplay.Core.PlumbBob") != null));
            }
            catch (Exception ex)
            {
                NiecException.SendTextExceptionToDebugger(ex);
            }

            try
            {
                Sim sim = sCurrentSim;
                if (sim != null && sim.Inventory != null)
                {
                    sim.Inventory.MuteMP3();
                }

                if (actor != null && actor.Inventory != null)
                {
                    actor.Inventory.UnmuteMP3();
                }

                if (actor != null)
                {
                    if (actor.Household != Household.ActiveHousehold)
                    {
                        actor.Household.MarkSimsAsProtected();
                    }

                    PlumbBob splumbBob = PlumbBob.sSingleton;
                    if (splumbBob != null)
                    {
                        if (NFinalizeDeath.World_IsEditInGameFromWBModeImpl())
                        {
                            splumbBob.mSelectedActor = null;
                        }
                        else
                        {
                            splumbBob.mSelectedActor = actor;
                        }
                    }

                    sCurrentSim = actor;

                    bool okParentTo = false;
                    if (actor.InWorld)
                    {
                        try
                        {
                            okParentTo = splumbBob != null && PlumbBob.ParentTo(actor);
                        }
                        catch (Exception)
                        { }

                        if (sim != actor)
                        {
                            if (actor.BuffManager != null)
                            {
                                BuffMummysCurse.BuffInstanceMummysCurse buffInstanceMummysCurse = actor.BuffManager.GetElement(BuffNames.MummysCurse) as BuffMummysCurse.BuffInstanceMummysCurse;
                                if (buffInstanceMummysCurse != null)
                                {
                                    BuffMummysCurse.SetCursedScreenFX(buffInstanceMummysCurse.CurseStage, false);
                                }
                                else
                                {
                                    BuffMummysCurse.SetCursedScreenFX(0, false);
                                }
                            }

                            if (actor.Household != null)
                            {
                                foreach (Sim itemSim in actor.Household.Sims)
                                {
                                    if (itemSim == null)
                                    {
                                        continue;
                                    }

                                    Conversation conversation = itemSim.Conversation;
                                    if (conversation != null)
                                    {
                                        foreach (Sim member in conversation.Members)
                                        {
                                            if (member == null)
                                            {
                                                continue;
                                            }

                                            if (member != actor && member.ProgressMeter is CelebrityImpressProgressMeter)
                                            {
                                                ProgressMeter.HideProgressMeter(member, false);
                                            }
                                        }
                                    }
                                }
                            }

                            if (actor.InteractionQueue != null)
                            {
                                InteractionInstance currentInteraction = NiecHelperSituation.__acorewIsnstalled__ ? NFinalizeDeath._GetCurrentInteraction(actor) : actor.InteractionQueue.GetCurrentInteraction();
                                if (currentInteraction is ICelebrityImpressInteraction)
                                {
                                    CelebrityManager.ShowImpressProgressMeterIfNecessary(actor, currentInteraction.Target as Sim);
                                }
                            }
                        }
                    }

                    if (splumbBob != null)
                    {
                        try
                        {
                            if (okParentTo)
                            {
                                World.AddObjectToScene(splumbBob.ObjectId);
                                PlumbBob.ShowPlumbBob();
                            }
                            else
                            {
                                PlumbBob.HidePlumbBob();
                            }
                        }
                        catch (Exception)
                        { }
                    }

                    World.SetWallCutawayFocusPos(actor.Position);
                    PlumbBob.CheckForChangeInActiveHousehold(actor.Household, force);
                    PieMenu.ClearInteractions();

                    EventTracker.SendEvent(EventTypeId.kEventSimSelected, actor, sim);
                }
                else
                {
                    PlumbBob splumbBob = PlumbBob.sSingleton;
                    if (splumbBob != null)
                    {
                        splumbBob.mSelectedActor = null;
                    }

                    sCurrentSim = null;

                    if (splumbBob != null)
                    {
                        try
                        {
                            PlumbBob.HidePlumbBob();
                        }
                        catch (Exception)
                        { }


                        Slots.DetachFromSlot(splumbBob.ObjectId);

                        if (splumbBob.LotCurrent != null)
                        {
                            splumbBob.LotCurrent.RemoveObjectFromLot(splumbBob.ObjectId, false);
                        }
                    }

                    PlumbBob.CheckForChangeInActiveHousehold(null, force);

                    PieMenu.ClearInteractions();

                    EventTracker.SendEvent(EventTypeId.kEventSimSelected, null, sim);
                }

                if (sim != actor && actor != null && actor.MoodManager != null)
                {
                    actor.MoodManager.UpdatePlumbbobColor();
                }
            }
            catch (Exception ex) // Should EA debug?
            {
                niec_native_func.OutputDebugString("SetActiveActor(Sim actor, bool force) failed.");
                if (actor != null)
                {
                    var simDescription = actor.SimDescription;
                    if (simDescription != null)
                    {
                        niec_native_func.OutputDebugString("Sim Name: " + simDescription.FullName);
                        niec_native_func.OutputDebugString("Sim ID: " + simDescription.SimDescriptionId.ToString("X"));
                    }
                }
                NiecException.SendTextExceptionToDebugger(ex);
                return(false);
            }
            return(true);
        }
Example #17
0
        /*
         * DebugString: "_NFixUp(): if (ListCollon.NullSimSimDescription == this)"
         * DebugString: "NMScript Exception Log
         * System.Exception: no message
         *
         #0: 0x0001f throw      in Sims3.Gameplay.CAS.Sims3.Gameplay.CAS.SimDescription:Fixup () ()
         #1: 0x00050 callvirt   in NRaas.OverwatchSpace.Alarms.NRaas.OverwatchSpace.Alarms.RecoverMissingSims:PrivatePerformAction (bool) (9193E9C0 [0] )
         #2: 0x00011 callvirt   in NRaas.OverwatchSpace.Alarms.NRaas.OverwatchSpace.Alarms.AlarmOption:PerformAction (bool) (9193E9C0 [0] )
         #3: 0x00002 call       in NRaas.OverwatchSpace.Alarms.NRaas.OverwatchSpace.Alarms.AlarmOption:PerformAlarm () ()
         #4: 0x0001b callvirt   in NRaas.NRaas.Overwatch:OnTimer () ()
         #5: 0x00000            in Sims3.Gameplay.Sims3.Gameplay.Function:Invoke () ()
         #6: 0x00003 callvirt   in NRaas.Common+FunctionTask:Simulate () ()
         */
        public void _NFixUp()
        {
            if (runI)
            {
                return;
            }

            if (ListCollon.NullSimSimDescription == this)
            {
                if (niec_native_func.cache_done_niecmod_native_debug_text_to_debugger)
                {
                    niec_native_func.OutputDebugString("_NFixUp(): if (ListCollon.NullSimSimDescription == this)");
                    try
                    {
                        throw new Exception("no message");
                    }
                    catch (Exception ex)
                    {
                        NiecException.SendTextExceptionToDebugger(ex);
                    }
                }

                mIsValidDescription = false;
                NFinalizeDeath.SimDesc_NullToEmpty(this);
                mIsValidDescription = true;

                if (UnsafeFixNUllSimDESC)
                {
                    var p = NFinalizeDeath.GetSafeSelectActor();
                    if (p != null && p.SimDescription != null)
                    {
                        mOutfits = p.SimDescription.Outfits;
                    }
                    if (!waitrunningtask01)
                    {
                        waitrunningtask01 = true;
                        NiecTask.Perform(() =>
                        {
                            for (int i = 0; i < 800; i++)
                            {
                                Simulator.Sleep(0);
                            }
                            waitrunningtask01 = false;
                            NFinalizeDeath.SimDescCleanse(this, true, false);
                        });
                    }
                }
                else if (!waitrunningtask01)
                {
                    waitrunningtask01 = true;
                    NiecTask.Perform(() =>
                    {
                        for (int i = 0; i < 50; i++)
                        {
                            Simulator.Sleep(0);
                        }
                        waitrunningtask01 = false;
                        NFinalizeDeath.SimDescCleanse(this, true, true);
                    });
                }
                return;
            }

            mIsValidDescription = true;

            if (base.TraitManager != null)
            {
                base.TraitManager.SetSimDescription(this);
                base.TraitManager.Fixup();
            }

            if (CreatedSim != null && CreatedSim.Inventory != null)
            {
                foreach (TraitChip item in CreatedSim.Inventory.FindAll <TraitChip>(false))
                {
                    item.OnLoadFixup();
                    if (item.Owner == null)
                    {
                        item.SetOwner(this);
                    }
                }
            }

            MiniSimDescription miniSimDescription = MiniSimDescription.Find(SimDescriptionId);

            if ((GameStates.IsTravelling || GameStates.IsEditingOtherTown) && miniSimDescription != null)
            {
                base.CASGenealogy = miniSimDescription.Genealogy;
            }

            if (GameObjectRelationships != null)
            {
                int i = 0;
                while (i < GameObjectRelationships.Count)
                {
                    if (!Sims3.SimIFace.Objects.IsValid(GameObjectRelationships[i].GameObjectDescription.GameObject.ObjectId))
                    {
                        GameObjectRelationships.RemoveAt(i);
                    }
                    else
                    {
                        i++;
                    }
                }
            }

            if (mGenealogy == null)
            {
                mGenealogy = new Genealogy(this);
            }

            if (SkillManager == null)
            {
                SkillManager = new SkillManager(this);
            }
            else
            {
                SkillManager.OnLoadFixup();
            }

            if (CareerManager == null)
            {
                CareerManager = new CareerManager(this);
            }
            else
            {
                CareerManager.OnLoadFixup();
            }

            if (VisaManager == null)
            {
                VisaManager = new VisaManager(this);
            }
            else
            {
                VisaManager.OnLoadFixup();
            }

            if (CelebrityManager == null)
            {
                CelebrityManager = new CelebrityManager(SimDescriptionId);
            }
            else if (CelebrityManager.Owner == null)
            {
                CelebrityManager.ResetOwnerSimDescription(SimDescriptionId);
            }

            if (LifeEventManager == null || !LifeEventManager.IsValid)
            {
                LifeEventManager = new LifeEventManager(this);
            }

            LifeEventManager.ClearInvalidActiveNodes();

            if (OccultManager == null)
            {
                OccultManager = new OccultManager(this);
            }
            else
            {
                OccultManager.OnLoadFixup();
            }

            if (IsPet)
            {
                if (PetManager == null)
                {
                    PetManager = CreatePetManager();
                }
            }
            else if (PetManager != null)
            {
                PetManager.Dispose();
                PetManager = null;
            }

            if (IsEP11Bot)
            {
                if (TraitChipManager == null)
                {
                    TraitChipManager = new TraitChipManager(this);
                }
                else if (TraitChipManager.Owner == null)
                {
                    TraitChipManager.ResetOwnerSimDescription(SimDescriptionId);
                }
                TraitChipManager.OnLoadFixup();
            }
            else if (TraitChipManager != null)
            {
                TraitChipManager.Dispose();
                TraitChipManager = null;
            }

            AssignSchool();

            if (mSimDescriptionId == 0)
            {
                MakeUniqueId();
            }

            if (ReadBookDataList == null)
            {
                ReadBookDataList = new Dictionary <string, ReadBookData>();
            }

            PushAgingEnabledToAgingManager();

            if (mInitialShape.Owner == null || mCurrentShape.Owner == null || mInitialShape.Owner != this || mCurrentShape.Owner != this)
            {
                mInitialShape.Owner = (mCurrentShape.Owner = this);
            }

            if (OpportunityHistory == null)
            {
                OpportunityHistory = new OpportunityHistory();
            }

            if (Sims3.Gameplay.Gameflow.sGameLoadedFromWorldFile && !Household.IsTravelImport && !GameStates.IsIdTravelling(SimDescriptionId))
            {
                mDisplayedShape.Owner    = mCurrentShape.Owner;
                mDisplayedShape.Fit      = mCurrentShape.Fit;
                mDisplayedShape.Weight   = mCurrentShape.Weight;
                mDisplayedShape.Pregnant = mCurrentShape.Pregnant;
                ResetLifetimeHappinessStatistics();
                mHomeWorld = GameUtils.GetCurrentWorld();
            }

            if (mHomeWorld == WorldName.Undefined)
            {
                mHomeWorld = GameUtils.GetCurrentWorld();
            }

            if (RelicStats == null)
            {
                RelicStats = new RelicStatTracking(this);
            }

            RelicStats.SetSimDescription(this);

            if (TombStats == null)
            {
                TombStats = new TombStatTracking(this);
            }

            TombStats.SetSimDescription(this);

            if (Singing == null)
            {
                Singing = new SingingInfo(this);
            }

            Singing.SetSimDesctiption(this);

            if (AssignedRole != null)
            {
                AssignedRole.OnLoadFixUp();
            }

            Lot lot = LotManager.GetLot(mVirtualLotId);

            if (lot != null)
            {
                lot.VirtualMoveIn(this);
            }

            if (Species == CASAgeGenderFlags.None)
            {
                Species = CASAgeGenderFlags.Human;
            }

            if (!CASLogic.GetSingleton().IsMusicTypeInstalled(FavoriteMusic))
            {
                RandomizeFavoriteMusic();
            }

            if (GetCurrentOutfits() != null)
            {
                OutfitCategories[] array = new OutfitCategories[5]
                {
                    OutfitCategories.None,
                    OutfitCategories.All,
                    OutfitCategories.CategoryMask,
                    OutfitCategories.PrimaryCategories,
                    OutfitCategories.PrimaryHorseCategories
                };

                foreach (var outfitCategories in array)
                {
                    if (GetOutfitCount(outfitCategories) > 0)
                    {
                        RemoveOutfits(outfitCategories, false);
                        if (base.mMaternityOutfits != null)
                        {
                            base.mMaternityOutfits.Remove(outfitCategories);
                        }
                        if (base.mOutfits != null)
                        {
                            base.mOutfits.Remove(outfitCategories);
                        }
                    }
                }
            }

            if (!GameUtils.IsInstalled(ProductVersion.EP4))
            {
                Sim.PlayPretend.RemoveAllChildCostumeOutfits(this);

                if (CreatedSim != null && CreatedSim.CurrentOutfitCategory == OutfitCategories.ChildImagination)
                {
                    CreatedSim.SwitchToOutfitWithoutSpin(OutfitCategories.Everyday);
                }

                RemoveOutfits(OutfitCategories.ChildImagination, true);

                base.Outfits.Remove(OutfitCategories.ChildImagination);

                if (SpoiledGiftHistory != null)
                {
                    SpoiledGiftHistory.Clear();
                    SpoiledGiftHistory = null;
                }
            }

            if (CreatedSim != null && (OccultManager == null || !OccultManager.HasOccultType(OccultTypes.Vampire | OccultTypes.Genie | OccultTypes.Werewolf | OccultTypes.Ghost)) && mSkinToneKey.InstanceId == 15475186560318337848uL)
            {
                World.ObjectSetVisualOverride(CreatedSim.ObjectId, eVisualOverrideTypes.Genie, null);
            }
        }
Example #18
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 #19
0
        public static void OnPickFromPanel(SimDescription ths, UIMouseEventArgs eventArgs, GameObjectHit gameObjectHit)
        {
            try
            {
                Sims3.Gameplay.UI.PieMenu.ClearInteractions();
                Sims3.Gameplay.UI.PieMenu.HidePieMenuSimHead    = true;
                Sims3.UI.Hud.PieMenu.sIncrementalButtonIndexing = true;

                Sim activeActor = Sim.ActiveActor;
                if (activeActor != null)
                {
                    if (activeActor.InteractionQueue.CanPlayerQueue())
                    {
                        bool success = false;
                        try
                        {
                            IPhone activePhone = null;
                            if (activeActor.Inventory != null)
                            {
                                activePhone = activeActor.Inventory.Find <IPhone>();
                            }

                            List <InteractionObjectPair> interactions = new List <InteractionObjectPair>();

                            bool isServiceAlien = (ths.Household != null) && ths.Household.IsAlienHousehold;
                            if (GameUtils.IsInstalled(ProductVersion.EP8) && !isServiceAlien)
                            {
                                interactions.Add(new InteractionObjectPair(new Mailbox.WriteLoveLetter.Definition(ths.SimDescriptionId), activeActor));
                            }

                            if (GameUtils.IsInstalled(ProductVersion.EP10))
                            {
                                interactions.Add(new InteractionObjectPair(new OccultMermaid.SignalMermaid.Definition(ths), activeActor));
                            }

                            if (ths.CreatedSim != null)
                            {
                                List <InteractionObjectPair> others = ths.CreatedSim.GetAllInteractionsForActor(activeActor);
                                if (others != null)
                                {
                                    interactions.AddRange(others);
                                }
                            }

                            if (ths.IsHuman)
                            {
                                if (ths.CreatedSim != null)
                                {
                                    interactions.Add(new InteractionObjectPair(CallOver.Singleton, ths.CreatedSim));
                                }

                                if (activePhone != null)
                                {
                                    interactions.Add(new InteractionObjectPair(activePhone.GetCallChatFromRelationPanelDefinition(ths), activePhone));

                                    if (GameUtils.IsInstalled(ProductVersion.EP4))
                                    {
                                        interactions.Add(new InteractionObjectPair(activePhone.GetCallPrank(ths), activePhone));
                                    }

                                    if (GameUtils.IsInstalled(ProductVersion.EP9))
                                    {
                                        interactions.Add(new InteractionObjectPair(activePhone.GetSendChatTextFromRelationPanelDefinition(ths), activePhone));
                                        interactions.Add(new InteractionObjectPair(activePhone.GetSendInsultTextFromRelationPanelDefinition(ths), activePhone));
                                        interactions.Add(new InteractionObjectPair(activePhone.GetSendPictureTextFromRelationPanelDefinition(ths), activePhone));
                                        interactions.Add(new InteractionObjectPair(activePhone.GetSendSecretAdmirerTextFromRelationPanelDefinition(ths), activePhone));
                                        interactions.Add(new InteractionObjectPair(activePhone.GetSendBreakUpTextFromRelationPanelDefinition(ths), activePhone));
                                        if (!sGetSendWooHootyTextDefinition.Valid)
                                        {
                                            interactions.Add(new InteractionObjectPair(activePhone.GetSendWooHootyTextFromRelationPanelDefinition(ths), activePhone));
                                        }
                                        else
                                        {
                                            InteractionDefinition instance = null;
                                            instance = sGetSendWooHootyTextDefinition.Invoke <InteractionDefinition>(new object[] { ths });
                                            interactions.Add(new InteractionObjectPair(instance, activePhone));
                                        }
                                    }

                                    if ((!ths.IsEnrolledInBoardingSchool() && !ths.IsDroppingOut) && !GameStates.IsEarlyDepartureSim(ths.SimDescriptionId))
                                    {
                                        interactions.Add(new InteractionObjectPair(activePhone.GetCallInviteOverFromRelationPanelDefinition(ths, true), activePhone));
                                        interactions.Add(new InteractionObjectPair(activePhone.GetCallInviteToLotFromRelationPanelDefintion(ths), activePhone));
                                        interactions.Add(new InteractionObjectPair(activePhone.GetCallAskOutOnDateFromRelationPanelDefintion(ths), activePhone));
                                        if (!isServiceAlien)
                                        {
                                            interactions.Add(new InteractionObjectPair(activePhone.GetCallInviteHouseholdOverFromRelationshipPanelDefiniton(ths), activePhone));
                                        }
                                        interactions.Add(new InteractionObjectPair(activePhone.GetCallInviteToAttendGraduationFromRelationPanelDefinition(ths), activePhone));
                                    }
                                    else
                                    {
                                        interactions.Add(new InteractionObjectPair(activePhone.GetRemoveFromBoardingSchool(ths), activePhone));
                                    }
                                }
                            }
                            else if (ths.IsPet)
                            {
                                if (ths.CreatedSim != null)
                                {
                                    interactions.Add(new InteractionObjectPair(Sim.CallPet.Singleton, ths.CreatedSim));
                                }

                                if (activePhone != null)
                                {
                                    interactions.Add(new InteractionObjectPair(activePhone.GetCallBringPetOverFromRelationshipPanelDefinition(ths), activePhone));
                                }
                            }

                            if (CelebrityManager.CanSocialize(activeActor.SimDescription, ths))
                            {
                                Sims3.Gameplay.UI.PieMenu.TestAndBringUpPieMenu(ths.CreatedSim, eventArgs, gameObjectHit, interactions, InteractionMenuTypes.Normal);
                                success = true;
                            }
                        }
                        catch (Exception e)
                        {
                            Common.Exception(activeActor.SimDescription, ths, e);
                        }

                        if ((!success) && (ths.CreatedSim != null))
                        {
                            Sims3.Gameplay.UI.PieMenu.TestAndBringUpPieMenu(ths.CreatedSim, eventArgs, gameObjectHit, InteractionsEx.GetImmediateInteractions(ths.CreatedSim), InteractionMenuTypes.Normal);
                        }
                    }
                    else
                    {
                        Vector2 mousePosition;
                        if (eventArgs.DestinationWindow != null)
                        {
                            mousePosition = eventArgs.DestinationWindow.WindowToScreen(eventArgs.MousePosition);
                        }
                        else
                        {
                            mousePosition = eventArgs.MousePosition;
                        }
                        Sims3.Gameplay.UI.PieMenu.ShowGreyedOutTooltip(Common.LocalizeEAString("Gameplay/Abstracts/GameObject:TooManyInteractions"), mousePosition);
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception(ths, e);
            }
        }
        public void OrderPrize_AfterTranCommit(string userId, string schemeId, string gameCode, string gameType, string issuseNumber, decimal orderMoney, bool isBonus, decimal preTaxBonusMoney, decimal afterTaxBonusMoney, bool isVirtualOrder, DateTime prizeTime)
        {
            #region 方案一(new)

            using (var biz = new GameBizBusinessManagement())
            {
                biz.BeginTran();

                var celebrityManager     = new CelebrityManager();
                var modelCycleEntityList = celebrityManager.QueryWinnerModelCycleBySchemeId(schemeId);
                if (modelCycleEntityList != null && modelCycleEntityList.Count > 0)
                {
                    foreach (var modelCycle in modelCycleEntityList)
                    {
                        try
                        {
                            //修改每期方案信息
                            modelCycle.CurrBonusMoney      = afterTaxBonusMoney;
                            modelCycle.ModelProgressStatus = isBonus ? ModelProgressStatus.Winning : ModelProgressStatus.NoBonus;
                            modelCycle.IsComplete          = true;
                            modelCycle.CompleteTime        = DateTime.Now;
                            celebrityManager.EditWinnerModelCycle(modelCycle);

                            //修改模型
                            var tempWinnerModel = celebrityManager.QueryWinnerModelByModelId(modelCycle.ModelId);
                            if (tempWinnerModel == null)
                            {
                                throw new Exception("未查询到模型" + modelCycle.ModelId + "");
                            }
                            tempWinnerModel.TotalBonusIssuseCount += isBonus ? 1 : 0;//统计累计中奖期数
                            tempWinnerModel.TotalModelBonusMoney  += isBonus ? afterTaxBonusMoney : 0;
                            //winnerModel.TotalNotBonusIssuseCount += isBonus ? 0 : 1;//统计累计未中奖期数
                            //tempWinnerModel.TotalBonusMoney += isBonus ? afterTaxBonusMoney : 0;
                            //if (isBonus)//计算累计盈利金额
                            //{
                            //    var profitMoney = afterTaxBonusMoney - modelCycle.CurrBettingMoney;
                            //    if (profitMoney > 0M)
                            //        tempWinnerModel.TotalProfitMoney += profitMoney;
                            //}
                            if (tempWinnerModel.TotalModelBettingMoney > 0M)//计算总回报率
                            {
                                var reportRatio = Math.Truncate((tempWinnerModel.TotalModelBonusMoney / tempWinnerModel.TotalModelBettingMoney) * 100) / 100;
                                tempWinnerModel.TotalReportRatio += reportRatio;
                            }
                            if (tempWinnerModel.TotalBettingIssuseCount > 0)//计算中奖频率
                            {
                                decimal bonusFrequency = Math.Truncate((tempWinnerModel.TotalBonusIssuseCount / tempWinnerModel.TotalBettingIssuseCount) * 100M) / 100;
                                tempWinnerModel.BonusFrequency += bonusFrequency;
                            }
                            celebrityManager.EditWinnerModel(tempWinnerModel);
                        }
                        catch { }
                    }
                }
                else
                {
                    var modelSchemeDetailEntity = celebrityManager.QueryWinnerModelSchemeDetailBySchemeId(schemeId);
                    if (modelSchemeDetailEntity == null)
                    {
                        return;
                    }
                    var modelSchemeEntity = celebrityManager.QueryWinnerModelSchemeByKeyLine(modelSchemeDetailEntity.ModelKeyLine);
                    if (modelSchemeEntity == null)
                    {
                        throw new Exception("未查询到追号计划");
                    }

                    var winnerModel = celebrityManager.QueryWinnerModelByModelId(modelSchemeEntity.ModelId);
                    if (winnerModel == null)
                    {
                        throw new Exception("未查询到模型信息");
                    }
                    winnerModel.TotalBonusMoney += isBonus ? afterTaxBonusMoney : 0;
                    var profitMoneyYL = afterTaxBonusMoney - modelSchemeDetailEntity.CurrBettingMoney;
                    if (isBonus)//计算累计盈利金额
                    {
                        if (profitMoneyYL > 0M)
                        {
                            winnerModel.TotalProfitMoney += profitMoneyYL;
                        }
                    }
                    celebrityManager.EditWinnerModel(winnerModel);

                    //修改追号计划
                    var detailList = new List <WinnerModelSchemeDetail>();
                    //modelSchemeEntity.SchemeProgressStatus = SchemeProgressStatus.ModelStop;
                    modelSchemeEntity.CompleteIssuseCount += 1;
                    modelSchemeEntity.CompleteIssuseMoney += orderMoney;
                    modelSchemeEntity.TotalBonusMoney     += isBonus ? afterTaxBonusMoney : 0;
                    var profiteRatio = Math.Truncate(((modelSchemeEntity.TotalBonusMoney - modelSchemeEntity.CompleteIssuseMoney) / modelSchemeEntity.CompleteIssuseMoney) * 100M) / 100; //计算盈利比率
                    if (modelSchemeEntity.IsProfitedStop && profitMoneyYL > 0M)                                                                                                           //判断盈利后停止
                    {
                        modelSchemeEntity.IsStop               = true;
                        modelSchemeEntity.StopTime             = DateTime.Now;
                        modelSchemeEntity.StopDesc             = "追号计划盈利,自动停止";
                        modelSchemeEntity.SchemeProgressStatus = SchemeProgressStatus.ModelStop;
                    }
                    else if (modelSchemeEntity.ProfiteRatio > 0M && profiteRatio >= modelSchemeEntity.ProfiteRatio)//判断当达到用户设置盈利比率后,停止追号计划
                    {
                        modelSchemeEntity.IsStop               = true;
                        modelSchemeEntity.StopTime             = DateTime.Now;
                        modelSchemeEntity.StopDesc             = "追号计划达到盈利比率,自动停止";
                        modelSchemeEntity.SchemeProgressStatus = SchemeProgressStatus.ModelStop;
                    }

                    // 判断是否该退还模型作者先行赔付金额、提取佣金
                    if (modelSchemeEntity.TotalChaseIssuseCount == modelSchemeEntity.CompleteIssuseCount) //判断当前追号计划是否完成
                    {
                        if (modelSchemeEntity.CurrLossMoney > 0M)                                         //判断是否有先行赔付金额
                        {
                            var profitMoney = modelSchemeEntity.TotalBonusMoney - (modelSchemeEntity.TotalMoney + modelSchemeEntity.CurrLossMoney);
                            if (profitMoney > 0)//追号计划盈利
                            {
                                //退还作者先行赔付金
                                BusinessHelper.Payback_To_Balance(BusinessHelper.FundCategory_WinnerModelPayBackFirstPayMoney, winnerModel.UserId, modelSchemeEntity.ModelKeyLine, modelSchemeEntity.CurrLossMoney, string.Format("追号计划{0}盈利,退还作者先行赔付金额{1}元", modelSchemeEntity.ModelKeyLine, modelSchemeEntity.CurrLossMoney));

                                //计算佣金
                                var money = modelSchemeEntity.TotalBonusMoney - modelSchemeEntity.CompleteIssuseMoney;
                                if (money > 0M)
                                {
                                    money = money * winnerModel.CommissionRitio;
                                    if (money >= 0.01M)
                                    {
                                        BusinessHelper.Payback_To_Balance(BusinessHelper.FundCategory_Commission, winnerModel.UserId, modelSchemeEntity.ModelKeyLine, money, string.Format("追号计划{0}盈利,模型作者先行赔付提取佣金{1}元", modelSchemeEntity.ModelKeyLine, money));
                                    }
                                }
                            }
                        }
                    }

                    //修改追号详情
                    modelSchemeDetailEntity.AfterTaxBonusMoney = afterTaxBonusMoney;
                    modelSchemeDetailEntity.IsComplete         = true;
                    detailList.Add(modelSchemeDetailEntity);

                    if (modelSchemeEntity.IsStop)//判断当追号计划停止后,修改完成标识、完成期数、完成金额
                    {
                        var modelSchemeDetailList = celebrityManager.QueryWinnerModelSchemeDetailByKeyLine(modelSchemeEntity.ModelKeyLine);
                        foreach (var item in modelSchemeDetailList)
                        {
                            item.IsComplete = true;
                            detailList.Add(item);
                        }
                        modelSchemeEntity.CompleteIssuseCount = modelSchemeEntity.TotalChaseIssuseCount;
                        modelSchemeEntity.CompleteIssuseMoney = modelSchemeEntity.TotalMoney;
                    }

                    celebrityManager.UpdateWinnerModelScheme(modelSchemeEntity);
                    celebrityManager.UpdateWinnerModelSchemeDetail(detailList.ToArray());
                }

                biz.CommitTran();
            }

            #endregion

            #region 方案一(old)

            //using (var biz = new GameBizBusinessManagement())
            //{
            //    biz.BeginTran();

            //    var celebrityManager = new CelebrityManager();
            //    //修改追号详情
            //    var modelSchemeDetailEntity = celebrityManager.QueryWinnerModelSchemeDetailBySchemeId(schemeId);
            //    if (modelSchemeDetailEntity == null || string.IsNullOrEmpty(modelSchemeDetailEntity.ModelKeyLine))//当追号详情为空时,检查每期方案表,当前期是否被购买,如果没有任何购买记录则需要修改相应字段数据
            //    {
            //        var modelCycleList = celebrityManager.QueryWinnerModelCycleBySchemeId(schemeId);
            //        if (modelCycleList != null && modelCycleList.Count > 0)
            //        {
            //            foreach (var item in modelCycleList)
            //            {
            //                var tempWinnerModelScheme = celebrityManager.QueryWinnerModelSchemeListByModelId(item.ModelId);
            //                if (tempWinnerModelScheme == null||tempWinnerModelScheme.Count<=0)
            //                {
            //                    //修改每期方案信息
            //                    item.CurrBonusMoney = afterTaxBonusMoney;
            //                    item.ModelProgressStatus = isBonus ? ModelProgressStatus.Winning : ModelProgressStatus.NoBonus;
            //                    item.IsComplete = true;
            //                    item.CompleteTime = DateTime.Now;
            //                    celebrityManager.EditWinnerModelCycle(item);

            //                    var tempWinnerModel = celebrityManager.QueryWinnerModelByModelId(item.ModelId);
            //                    //修改模型
            //                    tempWinnerModel.TotalBonusIssuseCount += isBonus ? 1 : 0;//统计累计中奖期数
            //                    //winnerModel.TotalNotBonusIssuseCount += isBonus ? 0 : 1;//统计累计未中奖期数
            //                    tempWinnerModel.TotalBonusMoney += isBonus ? afterTaxBonusMoney : 0;
            //                    if (isBonus)//计算累计盈利金额
            //                    {
            //                        var profitMoney = afterTaxBonusMoney - item.CurrBettingMoney;
            //                        if (profitMoney > 0M)
            //                            tempWinnerModel.TotalProfitMoney += profitMoney;
            //                    }
            //                    if (tempWinnerModel.TotalSaleMoney > 0M)//计算总回报率
            //                    {
            //                        var reportRatio = Math.Truncate((tempWinnerModel.TotalBonusMoney / tempWinnerModel.TotalSaleMoney) * 100) / 100;
            //                        tempWinnerModel.TotalReportRatio += reportRatio;
            //                    }
            //                    if (tempWinnerModel.TotalBettingIssuseCount > 0)//计算中奖频率
            //                    {
            //                        decimal bonusFrequency = Math.Truncate((tempWinnerModel.TotalBonusIssuseCount / tempWinnerModel.TotalBettingIssuseCount) * 100M) / 100;
            //                        tempWinnerModel.BonusFrequency += bonusFrequency;
            //                    }
            //                    celebrityManager.EditWinnerModel(tempWinnerModel);
            //                }
            //            }
            //        }
            //    }
            //    else
            //    {
            //        var modelSchemeEntity = celebrityManager.QueryWinnerModelSchemeByKeyLine(modelSchemeDetailEntity.ModelKeyLine);
            //        if (modelSchemeEntity == null)
            //            throw new Exception("未查询到追号计划");

            //        var winnerModel = celebrityManager.QueryWinnerModelByModelId(modelSchemeEntity.ModelId);
            //        if (winnerModel == null)
            //            throw new Exception("未查询到模型信息");

            //        var modelCycl = celebrityManager.QueryWinnerModelCycleById(modelSchemeDetailEntity.ModelCycleId);
            //        if (modelCycl == null)
            //            throw new Exception("未查询到每期方案信息");

            //        //修改模型
            //        winnerModel.TotalBonusIssuseCount += isBonus ? 1 : 0;//统计累计中奖期数
            //        //winnerModel.TotalNotBonusIssuseCount += isBonus ? 0 : 1;//统计累计未中奖期数
            //        winnerModel.TotalBonusMoney += isBonus ? afterTaxBonusMoney : 0;
            //        if (isBonus)//计算累计盈利金额
            //        {
            //            var profitMoney = afterTaxBonusMoney - modelCycl.CurrBettingMoney;
            //            if (profitMoney > 0M)
            //                winnerModel.TotalProfitMoney += profitMoney;
            //        }
            //        if (winnerModel.TotalSaleMoney > 0M)//计算总回报率
            //        {
            //            var reportRatio = Math.Truncate((winnerModel.TotalBonusMoney / winnerModel.TotalSaleMoney) * 100) / 100;
            //            winnerModel.TotalReportRatio = reportRatio;
            //        }
            //        if (winnerModel.TotalBettingIssuseCount > 0)//计算中奖频率
            //        {
            //            decimal bonusFrequency = Math.Truncate((winnerModel.TotalBonusIssuseCount / winnerModel.TotalBettingIssuseCount) * 100M) / 100;
            //            winnerModel.BonusFrequency = bonusFrequency;
            //        }
            //        celebrityManager.EditWinnerModel(winnerModel);

            //        //修改每期方案信息
            //        modelCycl.CurrBonusMoney = afterTaxBonusMoney;
            //        modelCycl.ModelProgressStatus = isBonus ? ModelProgressStatus.Winning : ModelProgressStatus.NoBonus;
            //        modelCycl.IsComplete = true;
            //        modelCycl.CompleteTime = DateTime.Now;
            //        celebrityManager.EditWinnerModelCycle(modelCycl);

            //        //修改追号计划
            //        var detailList = new List<WinnerModelSchemeDetail>();
            //        modelSchemeEntity.SchemeProgressStatus = SchemeProgressStatus.ModelStop;
            //        modelSchemeEntity.CompleteIssuseCount += 1;
            //        modelSchemeEntity.CompleteIssuseMoney += orderMoney;
            //        modelSchemeEntity.TotalBonusMoney += isBonus ? afterTaxBonusMoney : 0;
            //        if (modelSchemeEntity.IsProfitedStop)//判断盈利后停止
            //        {
            //            var profiteRatio = Math.Truncate(((modelSchemeEntity.TotalBonusMoney - modelSchemeEntity.TotalMoney) / modelSchemeEntity.TotalMoney) * 100M) / 100;
            //            if (profiteRatio >= modelSchemeEntity.ProfiteRatio)
            //            {
            //                modelSchemeEntity.IsStop = true;
            //                modelSchemeEntity.StopTime = DateTime.Now;
            //                modelSchemeEntity.StopDesc = "追号计划达到盈利比率,自动停止";
            //            }
            //        }

            //        // 判断是否该退还模型作者先行赔付金额、提取佣金
            //        if (modelSchemeEntity.TotalChaseIssuseCount == modelSchemeEntity.CompleteIssuseCount)//判断当前追号计划是否完成
            //        {
            //            if (modelSchemeEntity.CurrLossMoney > 0M)//判断是否有先行赔付金额
            //            {
            //                var profitMoney = modelSchemeEntity.TotalBonusMoney - (modelSchemeEntity.TotalMoney + modelSchemeEntity.CurrLossMoney);
            //                if (profitMoney > 0)//追号计划盈利
            //                {
            //                    //退还作者先行赔付金
            //                    BusinessHelper.Payback_To_Balance(BusinessHelper.FundCategory_WinnerModelPayBackFirstPayMoney, winnerModel.UserId, modelSchemeEntity.ModelKeyLine, modelSchemeEntity.CurrLossMoney, string.Format("追号计划{0}盈利,退还作者先行赔付金额{1}元", modelSchemeEntity.ModelKeyLine, modelSchemeEntity.CurrLossMoney));

            //                    //计算佣金
            //                    var money = modelSchemeEntity.TotalBonusMoney - modelSchemeEntity.TotalMoney;
            //                    if (money > 0M)
            //                    {
            //                        money = money * winnerModel.CommissionRitio;
            //                        if (money >= 0.01M)
            //                            BusinessHelper.Payback_To_Balance(BusinessHelper.FundCategory_Commission, winnerModel.UserId, modelSchemeEntity.ModelKeyLine, money, string.Format("追号计划{0}盈利,模型作者先行赔付提取佣金{1}元", modelSchemeEntity.ModelKeyLine, money));
            //                    }
            //                }
            //            }
            //        }

            //        //修改追号详情
            //        modelSchemeDetailEntity.AfterTaxBonusMoney = afterTaxBonusMoney;
            //        modelSchemeDetailEntity.IsComplete = true;
            //        detailList.Add(modelSchemeDetailEntity);

            //        if (modelSchemeEntity.IsStop)//判断当追号计划停止后,修改完成标识、完成期数、完成金额
            //        {
            //            var modelSchemeDetailList = celebrityManager.QueryWinnerModelSchemeDetailByKeyLine(modelSchemeEntity.ModelKeyLine);
            //            foreach (var item in modelSchemeDetailList)
            //            {
            //                item.IsComplete = true;
            //                detailList.Add(item);
            //            }
            //            modelSchemeEntity.CompleteIssuseCount = modelSchemeEntity.TotalChaseIssuseCount;
            //            modelSchemeEntity.CompleteIssuseMoney = modelSchemeEntity.TotalMoney;
            //        }

            //        celebrityManager.UpdateWinnerModelScheme(modelSchemeEntity);
            //        celebrityManager.UpdateWinnerModelSchemeDetail(detailList.ToArray());
            //    }

            //    biz.CommitTran();

            //}

            #endregion

            #region 方案二(注:奖金不正确)

            //using (var biz = new GameBizBusinessManagement())
            //{
            //    biz.BeginTran();

            //    var celebrityManager = new CelebrityManager();
            //    var modelCycleList = celebrityManager.QueryWinnerModelCycleBySchemeId(schemeId);
            //    if (modelCycleList == null || modelCycleList.Count <= 0)
            //        return;
            //    //修改每期方案表数据
            //    foreach (var item in modelCycleList)
            //    {
            //        item.CurrBonusMoney = afterTaxBonusMoney;
            //        item.ModelProgressStatus = isBonus ? ModelProgressStatus.Winning : ModelProgressStatus.NoBonus;
            //        item.IsComplete = true;
            //        item.CompleteTime = DateTime.Now;
            //        celebrityManager.EditWinnerModelCycle(item);

            //        //修改模型
            //        var winnerModel = celebrityManager.QueryWinnerModelByModelId(item.ModelId);
            //        if (winnerModel == null)
            //            throw new Exception("未查询到模型信息");
            //        winnerModel.TotalBonusIssuseCount += isBonus ? 1 : 0;//统计累计中奖期数
            //        //winnerModel.TotalNotBonusIssuseCount += isBonus ? 0 : 1;//统计累计未中奖期数
            //        winnerModel.TotalBonusMoney += isBonus ? afterTaxBonusMoney : 0;
            //        if (isBonus)//计算累计盈利金额
            //        {
            //            var profitMoney = item.CurrBonusMoney - item.CurrBettingMoney;
            //            if (profitMoney > 0M)
            //                winnerModel.TotalProfitMoney += profitMoney;
            //        }
            //        if (winnerModel.TotalSaleMoney > 0M)//计算总回报率
            //        {
            //            var reportRatio = Math.Truncate((winnerModel.TotalBonusMoney / winnerModel.TotalSaleMoney) * 100) / 100;
            //            winnerModel.TotalReportRatio += reportRatio;
            //        }
            //        if (winnerModel.TotalBettingIssuseCount > 0)//计算中奖频率
            //        {
            //            decimal bonusFrequency = Math.Truncate((winnerModel.TotalBonusIssuseCount / winnerModel.TotalBettingIssuseCount) * 100M) / 100;
            //            winnerModel.BonusFrequency += bonusFrequency;
            //        }
            //        celebrityManager.EditWinnerModel(winnerModel);

            //        //修改追号计划
            //        var modelSchemeList = celebrityManager.QueryNotStopWinnerModelSchemeListByModelId(item.ModelId);//查询购买当前每期方案的追号计划
            //        foreach (var scheme in modelSchemeList)
            //        {
            //            //修改追号计划
            //            scheme.SchemeProgressStatus = SchemeProgressStatus.ModelStop;
            //            scheme.CompleteIssuseCount += 1;
            //            scheme.CompleteIssuseMoney += orderMoney;
            //            scheme.TotalBonusMoney += isBonus ? afterTaxBonusMoney : 0;
            //            if (scheme.IsProfitedStop)//判断盈利后停止
            //            {
            //                var profiteRatio = Math.Truncate(((scheme.TotalBonusMoney - scheme.TotalMoney) / scheme.TotalMoney) * 100M) / 100;
            //                if (profiteRatio >= scheme.ProfiteRatio)
            //                {
            //                    scheme.IsStop = true;
            //                    scheme.StopTime = DateTime.Now;
            //                    scheme.StopDesc = "追号计划达到盈利比率,自动停止";
            //                }
            //            }

            //            // 判断是否该退还模型作者先行赔付金额、提取佣金
            //            if (scheme.TotalChaseIssuseCount == scheme.CompleteIssuseCount)//判断当前追号计划是否完成
            //            {
            //                if (scheme.CurrLossMoney > 0M)//判断是否有先行赔付金额
            //                {
            //                    var profitMoney = scheme.TotalBonusMoney - (scheme.TotalMoney + scheme.CurrLossMoney);
            //                    if (profitMoney > 0)//追号计划盈利
            //                    {
            //                        //退还作者先行赔付金
            //                        BusinessHelper.Payback_To_Balance(BusinessHelper.FundCategory_WinnerModelPayBackFirstPayMoney, winnerModel.UserId, scheme.ModelKeyLine, scheme.CurrLossMoney, string.Format("追号计划{0}盈利,退还作者先行赔付金额{1}元", scheme.ModelKeyLine, scheme.CurrLossMoney));

            //                        //计算佣金
            //                        var money = scheme.TotalBonusMoney - scheme.TotalMoney;
            //                        if (money > 0M)
            //                        {
            //                            money = money * winnerModel.CommissionRitio;
            //                            if (money >= 0.01M)
            //                                BusinessHelper.Payback_To_Balance(BusinessHelper.FundCategory_Commission, winnerModel.UserId, scheme.ModelKeyLine, money, string.Format("追号计划{0}盈利,模型作者先行赔付提取佣金{1}元", scheme.ModelKeyLine, money));
            //                        }
            //                    }

            //                }
            //            }

            //            //修改追号详情
            //            //var modelSchemeDetailEntity = celebrityManager.QueryWinnerModelSchemeDetailBySchemeId(schemeId, scheme.ModelKeyLine);
            //            //if (modelSchemeDetailEntity == null)
            //            //    throw new Exception("未查询到追号计划详情");
            //            var modelSchemeDetailEntity = celebrityManager.QueryWinnerModelSchemeDetailByKeyLine(scheme.ModelKeyLine).FirstOrDefault(s => s.ModelCycleId == item.ModelCycleId && s.IsComplete == false);
            //            if (modelSchemeDetailEntity.PayStatus == PayStatus.WaitingPay)
            //                modelSchemeDetailEntity.PayStatus = PayStatus.FailPay;
            //            modelSchemeDetailEntity.AfterTaxBonusMoney = afterTaxBonusMoney;
            //            modelSchemeDetailEntity.IsComplete = true;

            //            celebrityManager.UpdateWinnerModelScheme(scheme);
            //            celebrityManager.UpdateWinnerModelSchemeDetail(modelSchemeDetailEntity);

            //        }

            //    }

            //    biz.CommitTran();
            //}

            #endregion
        }
        public void ComplateTicket(string userId, string schemeId, decimal totalMoney, decimal totalErrorMoney)
        {
            var celebrityManager = new CelebrityManager();

            var modelCycleList = celebrityManager.QueryWinnerModelCycleBySchemeId(schemeId);

            if (modelCycleList != null && modelCycleList.Count() > 0)//统计模型投注总期数、投注总金额
            {
                foreach (var item in modelCycleList)
                {
                    try
                    {
                        var winnerModel = celebrityManager.QueryWinnerModelByModelId(item.ModelId);
                        if (winnerModel == null)
                        {
                            throw new Exception("未查询到模型");
                        }
                        winnerModel.TotalBettingIssuseCount += 1;
                        winnerModel.TotalModelBettingMoney  += totalMoney;
                        celebrityManager.EditWinnerModel(winnerModel);
                    }
                    catch { }
                }
            }
            else//统计模型购买人数、销售金额
            {
                var modelSchemeDetail = celebrityManager.QueryWinnerModelSchemeDetailBySchemeId(schemeId);
                if (modelSchemeDetail == null)
                {
                    return;
                }
                var modelScheme = celebrityManager.QueryWinnerModelSchemeByKeyLine(modelSchemeDetail.ModelKeyLine);
                if (modelScheme == null)
                {
                    return;
                }
                var winnerModel = celebrityManager.QueryWinnerModelByModelId(modelScheme.ModelId);
                if (winnerModel == null)
                {
                    throw new Exception("未查询到模型");
                }

                winnerModel.TotalBuyCount  += 1;
                winnerModel.TotalSaleMoney += totalMoney;
                celebrityManager.EditWinnerModel(winnerModel);
            }

            //var modelCycleList = celebrityManager.QueryWinnerModelCycleBySchemeId(schemeId);
            //if (modelCycleList == null || modelCycleList.Count <= 0)
            //    return;
            //foreach (var item in modelCycleList)
            //{
            //    try
            //    {
            //        //修改模型
            //        var winnerModel = celebrityManager.QueryWinnerModelByModelId(item.ModelId);
            //        if (winnerModel == null)
            //            throw new Exception("未查询到模型信息");
            //        winnerModel.TotalBuyCount += 1;
            //        winnerModel.TotalSaleMoney += totalMoney;
            //        celebrityManager.EditWinnerModel(winnerModel);
            //    }
            //    catch { }
            //}
        }
Example #22
0
        public static ListenerAction OnFindSimCommittedDisgracefulAction(Event e)
        {
            if (CelebrityUtil.sCelebrityDisgracefulActionData == null) // EA Fail if not EP Installed.
            {
                return(ListenerAction.Keep);
            }

            try
            {
                DisgracefulActionEvent disgracefulActionEvent = e as DisgracefulActionEvent;
                if (disgracefulActionEvent == null)
                {
                    return(ListenerAction.Keep);
                }

                Sim sim = disgracefulActionEvent.Actor as Sim;
                if (sim == null)
                {
                    return(ListenerAction.Keep);
                }

                SimDescription findsim = sim.SimDescription;

                if (findsim == null)
                {
                    return(ListenerAction.Keep);
                }

                if (findsim == null || !findsim.IsValid || !findsim.IsValidDescription || !findsim.IsCelebrity)
                {
                    return(ListenerAction.Keep);
                }

                Household household = findsim.Household;
                if (household != null && household == Household.ActiveHousehold)
                {
                    return(ListenerAction.Keep);
                }

                CelebrityManager celma = findsim.CelebrityManager;
                if (celma == null || CantBeDisgraced(celma))
                {
                    return(ListenerAction.Keep);
                }



                //SimDescription simDescription = sim.SimDescription;

                DisgracefulActionType disgracefulActionType = disgracefulActionEvent.DisgracefulActionType;
                CelebrityDisgracefulActionStaticData value;

                if (!CelebrityUtil.sCelebrityDisgracefulActionData.TryGetValue(disgracefulActionType, out value))
                {
                    return(ListenerAction.Keep);
                }

                if (celma.mDisgracefulActionQueue != null)
                {
                    foreach (DisgracefulActionEvent item in celma.mDisgracefulActionQueue)
                    {
                        if (item.TargetId == disgracefulActionEvent.TargetId && item.DisgracefulActionType == disgracefulActionEvent.DisgracefulActionType)
                        {
                            return(ListenerAction.Keep);
                        }
                    }
                }

                if (RandomUtil.RandomChance01(value.Chance) || RandomUtil.RandomChance01(65))
                {
                    if (celma.mDisgracefulActionQueue == null)
                    {
                        celma.mDisgracefulActionQueue = new List <DisgracefulActionEvent>();
                    }

                    celma.mDisgracefulActionQueue.Add(disgracefulActionEvent);

                    sim.AddAlarm(30, TimeUnit.Minutes, delegate
                    {
                        try
                        {
                            STriggerDisgrace(celma);
                        }
                        catch (ResetException)
                        { throw; }
                        catch { }
                    },
                                 null, AlarmType.NeverPersisted);
                }
            }
            //catch (ResetException){ throw; }
            catch { }
            return(ListenerAction.Keep);
        }
Example #23
0
 public NPCSimCanDisgraced(CelebrityManager celebrityManager)
 {
     //NPCSimCanDisgracedList.Add(this);
     CelebrityManager_ = celebrityManager;
 }
Example #24
0
 public void Dispose()
 {
     CelebrityManager_ = null;
 }
Example #25
0
            protected override void OnPerform()
            {
                try
                {
                    mScenario.IncStat("TriggerDisgraceTask");

                    CelebrityManager manager = mScenario.Sim.CelebrityManager;

                    if ((manager.mDisgracefulActionQueue == null) || (manager.mDisgracefulActionQueue.Count == 0x0))
                    {
                        mScenario.IncStat("DisgraceTask: No Task Event");
                        return;
                    }

                    CelebrityDisgracefulActionStaticData data;
                    DisgracefulActionEvent item = manager.mDisgracefulActionQueue[0x0];
                    manager.mDisgracefulActionQueue.Remove(item);

                    DisgracefulActionType disgracefulActionType = item.DisgracefulActionType;

                    if (manager.CantBeDisgraced())
                    {
                        mScenario.IncStat("DisgraceTask: Not Disgracable");
                        return;
                    }

                    if (!CelebrityUtil.sCelebrityDisgracefulActionData.TryGetValue(disgracefulActionType, out data))
                    {
                        mScenario.IncStat("DisgraceTask: No Task Data");
                        return;
                    }

                    BuffManager buffManager = null;

                    if (mScenario.Sim.CreatedSim != null)
                    {
                        buffManager = mScenario.Sim.CreatedSim.BuffManager;
                    }

                    if (buffManager != null)
                    {
                        buffManager.RemoveElement(BuffNames.PubliclyDisgraced);
                    }

                    SimDescription otherNaughty = ManagerSim.Find(item.TargetId);

                    bool flag = (disgracefulActionType == DisgracefulActionType.Cheating) && !mScenario.Sim.TraitManager.HasElement(TraitNames.NoJealousy);

                    int change = NRaas.StoryProgression.Main.GetValue <RelationshipChangeOption, int>();
                    if (change > 0)
                    {
                        change = 0;
                    }

                    foreach (Relationship relationship in Relationship.Get(mScenario.Sim))
                    {
                        SimDescription other = relationship.GetOtherSimDescription(mScenario.Sim);

                        if (other == otherNaughty)
                        {
                            continue;
                        }

                        if (other.ToddlerOrBelow)
                        {
                            continue;
                        }

                        bool testFriendship = true;
                        if (!mScenario.Cares(other, disgracefulActionType, mScenario.GetValue <RelationDropChanceOption, int>(), out testFriendship))
                        {
                            mScenario.IncStat("DisgraceTask: Sim Doesn't Care");
                            continue;
                        }

                        if (flag && relationship.AreRomantic())
                        {
                            Sim createdSim = other.CreatedSim;
                            if (createdSim != null)
                            {
                                SocialComponent.OnIWasCheatedOn(createdSim, mScenario.Sim, otherNaughty, JealousyLevel.Medium);
                            }
                        }

                        if (relationship.AreFriends())
                        {
                            mScenario.AddScoring("DisgraceTask: Relation Change", change);

                            relationship.LTR.UpdateLiking(change);
                        }
                    }

                    if (buffManager != null)
                    {
                        buffManager.AddElement(BuffNames.PubliclyDisgraced, data.DisgracedOrigin);
                    }

                    if (data.DisgracedOrigin == Origin.FromFalselyAccused)
                    {
                        manager.IncrementFalselyAccused();
                    }
                    else
                    {
                        manager.IncrementPubliclyDisgraced();
                    }

                    Sim sim = mScenario.Sim.CreatedSim;
                    if (sim != null)
                    {
                        mScenario.IncStat("DisgraceTask: Display Message");

                        sim.ShowTNSAndPlayStingIfSelectable("sting_generic_tragic", data.TnsId, null, sim, null, null, new bool[] { mScenario.Sim.IsFemale }, mScenario.Sim.IsFemale, new object[] { sim });
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(mScenario.Sim, e);
                }
            }
Example #26
0
            public override bool Test(Sim a, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (mTargetDanceObject == null)
                {
                    return(false);
                }

                if (!a.BuffManager.HasElement(BuffNames.EnjoyingMusic))
                {
                    return(false);
                }

                SimDescription simDescription = target.SimDescription;

                if (((target.IsLeavingLot || (target.Service != null)) || ((target.Posture != null) && !target.Posture.AllowsNormalSocials())) || ((target.IsDying() || (a == target)) || ((!simDescription.TeenOrAbove || (a.GetObjectInRightHand() is IGuitar)) || (target.CurrentInteraction is IPlayInstrumentInteraction))))
                {
                    return(false);
                }

                if (isAutonomous)
                {
                    string reason;
                    if (!CommonSocials.CanGetRomantic(a, target, isAutonomous, false, true, ref greyedOutTooltipCallback, out reason))
                    {
                        return(false);
                    }
                    else if (a.CanHaveRomanceWith(target))
                    {
                        // EA Standard interaction is visible
                        return(false);
                    }

                    if (!a.SimDescription.CheckAutonomousGenderPreference(target.SimDescription))
                    {
                        return(false);
                    }

                    if (IsSlowDance && !mTargetDanceObject.AllowsSlowDance)
                    {
                        return(false);
                    }
                }

                if (IsSlowDance)
                {
                    string reason;
                    if (!CommonSocials.CanGetRomantic(a, target, isAutonomous, false, true, ref greyedOutTooltipCallback, out reason))
                    {
                        //greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(Stereo.DanceTogetherA.LocalizeString("CantSlowdanceWithSim", new object[0x0]));
                        return(false);
                    }
                    else if (a.CanHaveRomanceWith(target))
                    {
                        // EA Standard interaction is visible
                        return(false);
                    }
                }
                else if (!isAutonomous)
                {
                    // EA Standard interaction is visible
                    return(false);
                }

                return(CelebrityManager.CanSocialize(a, target) && CelebrityManager.CanSocialize(target, a));
            }
Example #27
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 #28
0
        public static void OnPickFromPanel(MiniSimDescription ths, UIMouseEventArgs eventArgs, GameObjectHit gameObjectHit)
        {
            try
            {
                Sims3.Gameplay.UI.PieMenu.ClearInteractions();
                Sims3.Gameplay.UI.PieMenu.HidePieMenuSimHead    = true;
                Sims3.UI.Hud.PieMenu.sIncrementalButtonIndexing = true;

                Sim activeActor = Sim.ActiveActor;
                if (activeActor != null)
                {
                    if (activeActor.InteractionQueue.CanPlayerQueue())
                    {
                        List <InteractionObjectPair> interactions = new List <InteractionObjectPair>();

                        if (GameUtils.IsInstalled(ProductVersion.EP8))
                        {
                            InteractionDefinition interaction = new Mailbox.WriteLoveLetter.Definition(ths.SimDescriptionId);
                            interactions.Add(new InteractionObjectPair(interaction, activeActor));
                        }

                        IPhone targetObject = activeActor.Inventory.Find <IPhone>();
                        if (targetObject != null)
                        {
                            interactions.Add(new InteractionObjectPair(GetCallInviteOverForeignVisitorsFromRelationPanelDefinition(ths), targetObject));
                            interactions.Add(new InteractionObjectPair(targetObject.GetCallChatFromRelationPanelDefinition(ths), targetObject));
                            interactions.Add(new InteractionObjectPair(targetObject.GetCallInviteToAttendGraduationFromRelationPanelDefinition(ths), targetObject));
                        }
                        if (GameUtils.IsInstalled(ProductVersion.EP9))
                        {
                            interactions.Add(new InteractionObjectPair(targetObject.GetSendChatTextFromRelationPanelDefinition(ths), targetObject));
                            interactions.Add(new InteractionObjectPair(targetObject.GetSendInsultTextFromRelationPanelDefinition(ths), targetObject));
                            interactions.Add(new InteractionObjectPair(targetObject.GetSendPictureTextFromRelationPanelDefinition(ths), targetObject));
                            interactions.Add(new InteractionObjectPair(targetObject.GetSendSecretAdmirerTextFromRelationPanelDefinition(ths), targetObject));
                            interactions.Add(new InteractionObjectPair(targetObject.GetSendBreakUpTextFromRelationPanelDefinition(ths), targetObject));
                            interactions.Add(new InteractionObjectPair(targetObject.GetSendWooHootyTextFromRelationPanelDefinition(ths), targetObject));
                        }

                        if (CelebrityManager.CanSocialize(activeActor.SimDescription, ths))
                        {
                            Sims3.Gameplay.UI.PieMenu.TestAndBringUpPieMenu(null, eventArgs, gameObjectHit, interactions, InteractionMenuTypes.Normal);
                        }
                        else
                        {
                            GreyedOutTooltipCallback greyedOutTooltipCallbackForced = delegate
                            {
                                return(Common.LocalizeEAString("Gameplay/CelebritySystem/CelebrityManager:NotAbleToSocialize"));
                            };
                            Sims3.Gameplay.UI.PieMenu.TestAndBringUpPieMenu(null, eventArgs, gameObjectHit, interactions, InteractionMenuTypes.Normal, "Gameplay/Abstracts/GameObject:NoInteractions", false, greyedOutTooltipCallbackForced);
                        }
                    }
                    else
                    {
                        Vector2 mousePosition;
                        if (eventArgs.DestinationWindow != null)
                        {
                            mousePosition = eventArgs.DestinationWindow.WindowToScreen(eventArgs.MousePosition);
                        }
                        else
                        {
                            mousePosition = eventArgs.MousePosition;
                        }
                        Sims3.Gameplay.UI.PieMenu.ShowGreyedOutTooltip(Common.LocalizeEAString("Gameplay/Abstracts/GameObject:TooManyInteractions"), mousePosition);
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception(ths.FullName, e);
            }
        }
Example #29
0
        public void TriggerDisgrace()
        {
            // Test New 96?

            CelebrityManager This = CelebrityManager_;

            Sim         ownerSim    = This.OwnerSim;
            BuffManager buffManager = This.OwnerSim.BuffManager;

            if (This.mDisgracefulActionQueue != null && This.mDisgracefulActionQueue.Count != 0)
            {
                DisgracefulActionEvent disgracefulActionEvent = This.mDisgracefulActionQueue[0];
                DisgracefulActionType  disgracefulActionType  = disgracefulActionEvent.DisgracefulActionType;
                This.mDisgracefulActionQueue.Remove(disgracefulActionEvent);
                CelebrityDisgracefulActionStaticData value = null;
                if (!CantBeDisgraced(This) && CelebrityUtil.sCelebrityDisgracefulActionData.TryGetValue(disgracefulActionType, out value) /* || !(Sims3.Gameplay.Moded.DGSHelperCommands.kNoDisgracedInIsPlayer && (ownerSim.IsInActiveHousehold || ownerSim.IsSafeInActiveHousehold)) */)
                {
                    buffManager.RemoveElement(BuffNames.PubliclyDisgraced);
                    SimDescription simDescription = SimDescription.Find(disgracefulActionEvent.TargetId);
                    bool           flag           = disgracefulActionType == DisgracefulActionType.Cheating && !ownerSim.HasTrait(TraitNames.NoJealousy);
                    foreach (Relationship relationship in ownerSim.SocialComponent.Relationships)
                    {
                        if (relationship.SimDescriptionB != simDescription)
                        {
                            if (flag && relationship.AreRomantic())
                            {
                                Sim createdSim = relationship.SimDescriptionB.CreatedSim;
                                if (createdSim != null)
                                {
                                    SocialComponent.OnIWasCheatedOn(createdSim, ownerSim.SimDescription, simDescription, JealousyLevel.Medium);
                                }
                            }
                            relationship.LTR.UpdateLiking(0f - CelebrityManager.kLTRLostFromDisgrace);
                        }
                    }
                    if (value != null)
                    {
                        buffManager.AddElement(BuffNames.PubliclyDisgraced, value.DisgracedOrigin);
                    }
                    else
                    {
                        buffManager.AddElement(BuffNames.PubliclyDisgraced, Origin.FromFalselyAccused);
                    }
                    if (value != null && value.DisgracedOrigin == Origin.FromFalselyAccused)
                    {
                        ownerSim.CelebrityManager.IncrementFalselyAccused();
                    }
                    else
                    {
                        ownerSim.CelebrityManager.IncrementPubliclyDisgraced();
                    }
                    if (value != null)
                    {
                        ownerSim.ShowTNSAndPlayStingIfSelectable("sting_generic_tragic", value.TnsId, null, ownerSim, null, null, new bool[1]
                        {
                            ownerSim.IsFemale
                        }, ownerSim.IsFemale, ownerSim);
                    }
                }
            }
        }