Exemplo n.º 1
0
        public static void OnMarried(Sim actor, Sim target, string interaction, ActiveTopic topic, InteractionInstance i)
        {
            try
            {
                string failReason = null;
                if ((actor.Household == target.Household) || (!MovingSituation.MovingInProgress && ((Household.ActiveHousehold == null) || InWorldSubState.IsEditTownValid(Household.ActiveHousehold.LotHome, ref failReason))))
                {
                    Sim         actorSim;
                    Sim         targetSim;
                    BuffManager actorBuffManager  = actor.BuffManager;
                    BuffManager targetBuffManager = target.BuffManager;

                    actorBuffManager.AddElement(BuffNames.JustMarried, Origin.FromSocialization);
                    targetBuffManager.AddElement(BuffNames.JustMarried, Origin.FromSocialization);

                    BuffJustMarried.BuffInstanceJustMarried element = actorBuffManager.GetElement(BuffNames.JustMarried) as BuffJustMarried.BuffInstanceJustMarried;
                    if (element != null)
                    {
                        element.CreateGiftAlarm(actorBuffManager);
                    }

                    actorBuffManager.RemoveElement(BuffNames.NewlyEngaged);
                    actorBuffManager.RemoveElement(BuffNames.ParentsBlessing);
                    targetBuffManager.RemoveElement(BuffNames.NewlyEngaged);
                    targetBuffManager.RemoveElement(BuffNames.ParentsBlessing);

                    ActiveTopic.AddToSim(actor, "Wedding");
                    ActiveTopic.AddToSim(target, "Wedding");
                    Relationship relationship = Relationship.Get(actor, target, true);
                    relationship.LTR.RemoveInteractionBit(LongTermRelationship.InteractionBits.Divorce);
                    relationship.LTR.AddInteractionBit(LongTermRelationship.InteractionBits.Marry);
                    if (actor.IsNPC && !target.IsNPC)
                    {
                        actorSim  = target;
                        targetSim = actor;
                    }
                    else if (!actor.IsNPC && target.IsNPC)
                    {
                        actorSim  = actor;
                        targetSim = target;
                    }
                    else
                    {
                        SimDescription proposerDesc = relationship.ProposerDesc;
                        actorSim = (proposerDesc == null) ? null : proposerDesc.CreatedSim;
                        if (actorSim == null)
                        {
                            if (RandomUtil.CoinFlip())
                            {
                                actorSim = actor;
                            }
                            else
                            {
                                actorSim = target;
                            }
                        }

                        targetSim = target;
                        if (actorSim == target)
                        {
                            targetSim = actor;
                        }
                    }

                    SocialCallback.GiveDaysOffIfRequired(actorSim, targetSim);
                    MidlifeCrisisManager.OnBecameMarried(actor.SimDescription, target.SimDescription);

                    relationship.SetMarriedInGame();

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

                    if (sStoryProgressionHandleMarriageName.Valid)
                    {
                        sStoryProgressionHandleMarriageName.Invoke <bool>(new object[] { actorSim.SimDescription, targetSim.SimDescription });
                    }
                    else
                    {
                        targetSim.SimDescription.LastName = actorSim.SimDescription.LastName;
                        foreach (Genealogy genealogy in targetSim.Genealogy.Children)
                        {
                            SimDescription simDescription = genealogy.SimDescription;
                            if (((simDescription != null) && simDescription.TeenOrBelow) && (simDescription.CreatedSim != null))
                            {
                                simDescription.LastName = actorSim.SimDescription.LastName;
                            }
                        }
                    }

                    actor.Genealogy.Marry(target.Genealogy);
                    OnMoveInWith(actor, target, interaction, topic, i);
                    SocialCallback.EndServiceForActor(actor);
                    SocialCallback.EndServiceForActor(target);

                    actorBuffManager.RemoveElement(BuffNames.MissedWedding);
                    targetBuffManager.RemoveElement(BuffNames.MissedWedding);
                }
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(actor, target, e);
            }
        }
Exemplo n.º 2
0
        public bool BumpToHighestState(Common.IStatGenerator stats, SimDescription a, SimDescription b)
        {
            while (BumpToHigherState(stats, a, b))
            {
                ;
            }

            if ((!a.IsMarried) && (!b.IsMarried))
            {
                IncStat("BumpUp: Not Married");
                stats.IncStat("BumpUp: Not Married");
                return(false);
            }

            if (a.CreatedSim != null)
            {
                a.CreatedSim.BuffManager.AddElement(BuffNames.JustMarried, Origin.FromSocialization);
                a.CreatedSim.BuffManager.RemoveElement(BuffNames.NewlyEngaged);
                ActiveTopic.AddToSim(a.CreatedSim, "Wedding");
            }

            if (b.CreatedSim != null)
            {
                b.CreatedSim.BuffManager.AddElement(BuffNames.JustMarried, Origin.FromSocialization);
                b.CreatedSim.BuffManager.RemoveElement(BuffNames.NewlyEngaged);
                ActiveTopic.AddToSim(b.CreatedSim, "Wedding");
            }

            if ((a.CreatedSim != null) && (b.CreatedSim != null))
            {
                SocialCallback.GiveDaysOffIfRequired(a.CreatedSim, b.CreatedSim);
            }

            a.Genealogy.Marry(b.Genealogy);

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

            if (relationship != null)
            {
                MidlifeCrisisManager.OnBecameMarried(a, b);

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

                relationship.SetMarriedInGame();

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

                return(true);
            }
            else
            {
                IncStat("BumpUp: Relation Fail");
                stats.IncStat("BumpUp: Relation Fail");
                return(false);
            }
        }