Beispiel #1
0
        protected static void OnSocialEvent(Event e)
        {
            using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration AttractionHelper:OnSocialEvent"))
            {
                if (Common.AssemblyCheck.IsInstalled("NRaasChemistry"))
                {
                    return;
                }

                SocialEvent socialEvent = e as SocialEvent;
                if ((socialEvent != null) && (socialEvent.WasAccepted))
                {
                    Sim actor  = socialEvent.Actor as Sim;
                    Sim target = socialEvent.TargetObject as Sim;

                    if ((actor != null) && (target != null))
                    {
                        bool      created   = false;
                        LastCheck lastCheck = GetLastCheck(actor.SimDescription.SimDescriptionId, target.SimDescription.SimDescriptionId, true, out created);

                        if (created)
                        {
                            SetLastCheck(target.SimDescription.SimDescriptionId, actor.SimDescription.SimDescriptionId, lastCheck);
                        }

                        bool force = false;
                        if ((!lastCheck.mAttractionNotice) && ((SimTypes.IsSelectable(actor)) || (SimTypes.IsSelectable(target))))
                        {
                            force = true;
                        }

                        if ((force) || ((lastCheck.mTime + SimClock.kSimulatorTicksPerSimDay) > SimClock.CurrentTicks))
                        {
                            lastCheck.mTime = SimClock.CurrentTicks;

                            Relationship relation = Relationship.Get(actor, target, false);
                            if (relation != null)
                            {
                                RelationshipEx.CalculateAttractionScore(relation, !lastCheck.mAttractionNotice);

                                if ((SimTypes.IsSelectable(actor)) || (SimTypes.IsSelectable(target)))
                                {
                                    lastCheck.mAttractionNotice = true;
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        protected static void OnRecalulateDesire()
        {
            try
            {
                List <Sim> sims = new List <Sim>();
                foreach (Sim sim in LotManager.Actors)
                {
                    try
                    {
                        if (sim.InteractionQueue == null)
                        {
                            continue;
                        }

                        if (sim.InteractionQueue.GetCurrentInteraction() is SocialInteraction)
                        {
                            continue;
                        }

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

                        if (sim.Autonomy.SituationComponent == null)
                        {
                            continue;
                        }

                        if (sim.Autonomy.SituationComponent.mSituations == null)
                        {
                            continue;
                        }

                        if (sim.Autonomy.SituationComponent.mSituations.Count > 0)
                        {
                            ScoringLookup.IncStat("STC Desire In Situation");
                            continue;
                        }

                        sims.Add(sim);
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, e);
                    }
                }

                foreach (Sim sim in sims)
                {
                    try
                    {
                        SocialComponent social = sim.SocialComponent;
                        if (social == null)
                        {
                            continue;
                        }

                        social.mShortTermDesireToSocializeWith.Clear();

                        if (!Woohooer.Settings.UsingTraitScoring)
                        {
                            continue;
                        }

                        if (sim.Autonomy.Actor == null)
                        {
                            continue;
                        }

                        if (!sim.Autonomy.ShouldRunLocalAutonomy)
                        {
                            continue;
                        }

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

                        if (sim.LotCurrent.IsWorldLot)
                        {
                            continue;
                        }

                        SpeedTrap.Sleep();

                        if (!WoohooScoring.TestScoringNormal(sim, null, "InterestInRomance", true))
                        {
                            ScoringLookup.IncStat("STC Desire Fail");
                            continue;
                        }

                        ScoringLookup.IncStat("STC Desire Success");

                        List <Sim> others = new List <Sim>(sim.LotCurrent.GetAllActors());
                        foreach (Sim other in others)
                        {
                            if (sim == other)
                            {
                                continue;
                            }

                            string reason;
                            GreyedOutTooltipCallback callback = null;
                            if (!CommonSocials.CanGetRomantic(sim, other, true, false, true, ref callback, out reason))
                            {
                                continue;
                            }

                            int std = (int)(RelationshipEx.GetAttractionScore(sim.SimDescription, other.SimDescription, false) * 2);

                            ScoringLookup.AddStat("Desire " + sim.FullName, std);

                            social.AddShortTermDesireToSocializeWith(other, std);

                            SpeedTrap.Sleep();
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, e);
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception("STCDesire:OnRecalculateDesire", e);
            }
        }