Example #1
0
        public override bool Run()
        {
            mCurrentStateMachine.SetActor("y", Target);
            mCurrentStateMachine.EnterState("x", "Enter");
            AnimateSim("HaveBaby");
            Actor.SimDescription.SetPregnancy(1f - (float)BabyIndex / (float)TotalCount);
            AnimateSim("Exit");
            Pregnancy.MakeBabyVisible(Target);
            ChildUtils.CarryChild(Actor, Target, true);

            return(true);
        }
Example #2
0
        public override bool Run()
        {
            // Switch out the state machine used by CarryingChildPosture to my custom one
            StateMachineClient feedMachine = AcquireBreastfeedStateMachine(Actor, Target);

            ChildUtils.StartCarry(Actor, Target, feedMachine, false);

            SocialInteractionB interactionB = new CarriedChildInteractionB.Definition("BeGivenBottle")
                                              .CreateInstance(Actor, Target, GetPriority(), EffectivelyAutonomous, CancellableByPlayer) as SocialInteractionB;

            if (!ChildUtils.StartInteractionWithCarriedChild(this, interactionB))
            {
                return(false);
            }

            BeginCommodityUpdates();

            if (Loader.kEnableBreastFeedCensor)
            {
                mCensorEnabled = true;
                Actor.EnableCensor(CensorType.FullBody);
            }

            Actor.CarryingChildPosture.AnimateInteractionWithCarriedChild("Nurse");

            Actor.CarryingChildPosture.AnimateInteractionWithCarriedChild("Exit");

            Target.Motives.SetMax(CommodityKind.Hunger);
            Actor.GetRelationship(Target, true).LTR.UpdateLiking(kLTRIncreaseFromNursing);
            EndCommodityUpdates(true);
            ApplyBuffs();
            DoPostFeed();

            FinishLinkedInteraction();
            WaitForSyncComplete(3);  // Not sure why the ChildUtils finish method did not work here.

            // Restore the EA's child carry state machine (JAZZ script "CarryToddler")
            StateMachineClient carryMachine = ChildUtils.AcquireCarryStateMachine(Actor, Target);

            ChildUtils.StartCarry(Actor, Target, carryMachine, false);

            Cleanup();
            return(true);
        }
Example #3
0
            public override InteractionInstance CreateInstance(ref InteractionInstanceParameters parameters)
            {
                InteractionInstance interaction = base.CreateInstance(ref parameters);

                if (Posture != CommodityKind.Standing)
                {
                    ChildUtils.SetPosturePrecondition(interaction, Posture, PostureChecks);
                    return(interaction);
                }
                if (parameters.Actor.Posture.Satisfies(CommodityKind.CarryingChild, null))
                {
                    ChildUtils.SetPosturePrecondition(interaction, CommodityKind.CarryingChild, PostureChecks);
                    return(interaction);
                }
                if (parameters.Actor.Posture is SimCarryingObjectPosture)
                {
                    ChildUtils.SetPosturePrecondition(interaction, CommodityKind.CarryingObject, new CommodityKind[] { CommodityKind.CarryingObject });
                }
                return(interaction);
            }
        public override bool Run()
        {
            Hospital hospital = RabbitHole.GetClosestRabbitHoleOfType(RabbitHoleType.Hospital,
                                                                      Target.Position) as Hospital;

            if (hospital != null)
            {
                Actor.RouteTurnToFace(Target.Position);
                EWGoToVet interactionInstance = EWGoToVet.Singleton.CreateInstance(hospital, Actor,
                                                                                   new InteractionPriority(InteractionPriorityLevel.High), isAutonomous: false,
                                                                                   cancellableByPlayer: true) as EWGoToVet;
                interactionInstance.mPet = Target;

                if ((Target.IsCat || Target.IsLittleDog))
                {
                    ChildUtils.SetPosturePrecondition(interactionInstance, CommodityKind.CarryingPet, new CommodityKind[0]);
                    PickUpPet pickUp = PickUpPet.Singleton.CreateInstance(Target, Actor, new InteractionPriority(InteractionPriorityLevel.High),
                                                                          false, true) as PickUpPet;
                    Actor.InteractionQueue.TryPushAsContinuation(this, pickUp);
                    Actor.InteractionQueue.TryPushAsContinuation(pickUp, interactionInstance);
                }
                else
                {
                    SocialInteractionA greetPet = new SocialInteractionA.Definition("Let Sniff Hand", new string[0],
                                                                                    null, false).CreateInstance(Target, Actor, new InteractionPriority(InteractionPriorityLevel.High),
                                                                                                                false, true) as SocialInteractionA;
                    Actor.InteractionQueue.TryPushAsContinuation(this, greetPet);
                    Actor.InteractionQueue.TryPushAsContinuation(greetPet, interactionInstance);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #5
0
            protected bool Run(Sim client, Sim solicitor)
            {
                bool flag3 = false;

                ObjectGuid bedId = new ObjectGuid();

                #region Initialize relationship data

                //Increase the relationship for a moment, so sims can relax on the same bed
                Relationship rRelationship = Relationship.Get(base.Actor, base.Target, true);
                float        originalLTR   = 0;
                Boolean      changeLTR     = false;
                Boolean      lover         = false;

                Boolean clientHasLFMoodlet    = CommonMethods.HasMoodlet(client, BuffNames.LostAFriend, Origin.FromSocialization);
                Boolean soliciterHasLFMoodlet = CommonMethods.HasMoodlet(solicitor, BuffNames.LostAFriend, Origin.FromSocialization);

                #endregion

                try
                {
                    this.Actor.GreetSimOnMyLotIfPossible(this.Target);
                    if (StartBedCuddleA.GetCuddleType(this.Actor, this.Target) == StartBedCuddleA.CuddleType.CuddleTargetOnDifferentBed)
                    {
                        ChildUtils.SetPosturePrecondition(this, CommodityKind.Relaxing, new CommodityKind[]
                        {
                            CommodityKind.NextToTarget
                        });
                        this.Actor.InteractionQueue.PushAsContinuation(this, true);
                        return(true);
                    }
                    if (!this.Actor.Posture.Satisfies(CommodityKind.Relaxing, null))
                    {
                        return(false);
                    }
                    if (!base.SafeToSync())
                    {
                        return(false);
                    }
                    BedMultiPart bedMultiPart = this.Actor.Posture.Container as BedMultiPart;

                    bedId = bedMultiPart.ObjectId;

                    if (this.IsMaster && this.ReturnInstance == null)
                    {
                        base.EnterStateMachine("BedSocials", "FromRelax", "x", "y");
                        base.AddPersistentScriptEventHandler(0u, new SacsEventHandler(this.EventCallbackChangeVisibility));
                        base.SetActor("bed", bedMultiPart);
                        BedData partSimIsIn = bedMultiPart.PartComp.GetPartSimIsIn(this.Actor);
                        partSimIsIn.SetPartParameters(this.mCurrentStateMachine);
                        WooHoo wooHoo = base.InteractionDefinition.CreateInstance(this.Actor, this.Target, base.GetPriority(), false, base.CancellableByPlayer) as WooHoo;
                        wooHoo.IsMaster = false;
                        wooHoo.LinkedInteractionInstance = this;
                        ChildUtils.SetPosturePrecondition(wooHoo, CommodityKind.Relaxing, new CommodityKind[]
                        {
                            CommodityKind.NextToTarget
                        });
                        this.Target.InteractionQueue.AddNext(wooHoo);
                        if (this.Target.Posture.Container != this.Actor.Posture.Container)
                        {
                            this.Actor.LookAtManager.SetInteractionLookAt(this.Target, 200, LookAtJointFilter.TorsoBones);
                            this.Actor.Posture.CurrentStateMachine.RequestState("x", "callOver");
                        }
                        this.Actor.SynchronizationLevel  = Sim.SyncLevel.Started;
                        this.Actor.SynchronizationTarget = this.Target;
                        this.Actor.SynchronizationRole   = Sim.SyncRole.Initiator;
                        if (!base.StartSync(this.IsMaster))
                        {
                            return(false);
                        }
                        if (!this.Actor.WaitForSynchronizationLevelWithSim(this.Target, Sim.SyncLevel.Routed, 30f))
                        {
                            return(false);
                        }
                        base.StartSocialContext();
                    }
                    else
                    {
                        if (!base.StartSync(this.IsMaster))
                        {
                            return(false);
                        }
                    }
                    base.StandardEntry(false);
                    base.BeginCommodityUpdates();
                    if (this.IsMaster)
                    {
                        if (!bedMultiPart.InherentlyProvidesPrivacy)
                        {
                            this.mSituation = new WooHoo.WooHooPrivacySituation(this);
                            if (!this.mSituation.Start())
                            {
                                base.FinishLinkedInteraction();
                                base.PostLoop();
                                if (this.ReturnInstance == null)
                                {
                                    InteractionInstance instance = BedRelax.Singleton.CreateInstance(this.Actor.Posture.Container, this.Actor, base.GetPriority(), true, true);
                                    this.Actor.InteractionQueue.PushAsContinuation(instance, true);
                                }
                                else
                                {
                                    base.DoResume();
                                }
                                WooHoo wooHoo2 = this.LinkedInteractionInstance as WooHoo;
                                if (wooHoo2 != null)
                                {
                                    if (this.ReturnInstance == null)
                                    {
                                        InteractionInstance instance2 = BedRelax.Singleton.CreateInstance(this.Target.Posture.Container, this.Target, base.GetPriority(), true, true);
                                        this.Target.InteractionQueue.PushAsContinuation(instance2, true);
                                    }
                                    else
                                    {
                                        wooHoo2.DoResume();
                                    }
                                    wooHoo2.Failed = true;
                                }
                                base.WaitForSyncComplete();
                                base.EndCommodityUpdates(false);
                                base.StandardExit(false, false);
                                return(false);
                            }
                        }
                        this.Actor.LookAtManager.ClearInteractionLookAt();
                        this.Target.LookAtManager.ClearInteractionLookAt();
                        if (this.ReturnInstance != null)
                        {
                            this.ReturnInstance.EnsureMaster();
                            this.mCurrentStateMachine = this.ReturnInstance.mCurrentStateMachine;
                        }
                        base.StartSocial(this.SocialName);
                        base.InitiateSocialUI(this.Actor, this.Target);
                        this.Rejected = false;
                        (this.LinkedInteractionInstance as WooHoo).Rejected = this.Rejected;
                        if (this.Rejected)
                        {
                            if (this.Actor.Posture.Container == this.Target.Posture.Container)
                            {
                                ThoughtBalloonManager.BalloonData balloonData = new ThoughtBalloonManager.DoubleBalloonData("balloon_woohoo", "balloon_question");
                                balloonData.BalloonType = ThoughtBalloonTypes.kSpeechBalloon;
                                this.Actor.ThoughtBalloonManager.ShowBalloon(balloonData);
                                base.AddOneShotScriptEventHandler(404u, new SacsEventHandler(this.ShowRejectBalloonAndEnqueueRouteAway));
                                this.mCurrentStateMachine.RequestState(false, "x", "WooHooReject");
                                this.mCurrentStateMachine.RequestState(true, "y", "WooHooReject");
                                this.mCurrentStateMachine.RequestState(true, null, "ToRelax");
                            }
                            this.Actor.BuffManager.AddElement(BuffNames.WalkOfShame, Origin.FromRejectedWooHooOffHome);
                        }
                        else
                        {
                            if (this.BabyMade())
                            {
                                this.mCurrentStateMachine.AddOneShotScriptEventHandler(110u, new SacsEventHandler(this.EventCallbackPlayBabySound));
                            }
                            this.mCurrentStateMachine.AddOneShotScriptEventHandler(110u, new SacsEventHandler(this.EventCallbackChangeClothes));
                            string wooHooEffectName = bedMultiPart.TuningBed.WooHooEffectName;
                            if (!string.IsNullOrEmpty(wooHooEffectName))
                            {
                                this.mWooHooEffect = VisualEffect.Create(wooHooEffectName);
                                this.mWooHooEffect.ParentTo(bedMultiPart, Slots.Hash("_FX_0"));
                                base.AddOneShotScriptEventHandler(200u, new SacsEventHandler(this.EventCallbackWooHoo));
                                base.AddOneShotScriptEventHandler(201u, new SacsEventHandler(this.EventCallbackWooHoo));
                            }
                            this.mHelperX = new Sim.SwitchOutfitHelper(this.Actor, Sim.ClothesChangeReason.GoingToBed);
                            this.mHelperY = new Sim.SwitchOutfitHelper(this.Target, Sim.ClothesChangeReason.GoingToBed);
                            this.mHelperX.Start();
                            this.mHelperY.Start();
                            this.mJealousyAlarm = AlarmManager.Global.AddAlarm(WooHoo.kJealousyBroadcasterDelay, TimeUnit.Minutes, new AlarmTimerCallback(this.StartJealousyBroadcaster), "StartJealousyBroadcaster", AlarmType.DeleteOnReset, bedMultiPart);
                            bedMultiPart.PreWooHooBehavior(this.Actor, this.Target, this);
                            this.mCurrentStateMachine.RequestState(false, "x", "WooHoo");
                            this.mCurrentStateMachine.RequestState(true, "y", "WooHoo");
                            bedMultiPart.PostWooHooBehavior(this.Actor, this.Target, this);
                            Relationship relationship = Relationship.Get(this.Actor, this.Target, true);
                            relationship.STC.Update(this.Actor, this.Target, CommodityTypes.Amorous, WooHoo.kSTCIncreaseAfterWoohoo);
                            InteractionInstance nextInteraction = this.Actor.InteractionQueue.GetNextInteraction();
                            bool flag  = nextInteraction != null;
                            bool flag2 = flag && nextInteraction.PosturePreconditions != null && nextInteraction.PosturePreconditions.ContainsPosture(CommodityKind.Sleeping);
                            nextInteraction = this.Target.InteractionQueue.GetNextInteraction();
                            flag            = (flag || nextInteraction != null);
                            flag2           = (flag2 && nextInteraction != null && nextInteraction.PosturePreconditions != null && nextInteraction.PosturePreconditions.ContainsPosture(CommodityKind.Sleeping));
                            if ((this.mSituation != null && this.mSituation.SomeoneDidIntrude) || (flag && !flag2))
                            {
                                this.SleepAfter = false;
                            }
                            else
                            {
                                this.SleepAfter = (BedSleep.CanSleep(this.Actor, true) && BedSleep.CanSleep(this.Target, true));
                            }
                            (this.LinkedInteractionInstance as WooHoo).SleepAfter = this.SleepAfter;
                            if (this.SleepAfter)
                            {
                                this.mCurrentStateMachine.RequestState(null, "ToSleep");
                            }
                            else
                            {
                                this.mCurrentStateMachine.RequestState(null, "ToRelax");
                                bedMultiPart.PartComp.GetPartSimIsIn(this.Actor).BedMade  = true;
                                bedMultiPart.PartComp.GetPartSimIsIn(this.Target).BedMade = true;
                            }
                            SocialCallback.RunPostWoohoo(this.Actor, this.Target, bedMultiPart);
                            if (bedMultiPart is BedDoubleHover)
                            {
                                this.Actor.BuffManager.AddElement(BuffNames.MeterHighClub, Origin.FromWooHooOnHoverBed);
                                this.Target.BuffManager.AddElement(BuffNames.MeterHighClub, Origin.FromWooHooOnHoverBed);
                            }
                        }
                        base.FinishSocial(this.SocialName, true);
                        this.CleanupSituation();
                        this.Actor.AddExitReason(ExitReason.Finished);
                    }
                    else
                    {
                        bedMultiPart = (this.Target.Posture.Container as BedMultiPart);
                        if (bedMultiPart == null)
                        {
                            return(false);
                        }
                        PartComponent <BedData> partComp = bedMultiPart.PartComp;
                        if (partComp.GetSimInOtherPart(this.Target) == null)
                        {
                            BedData otherPart = partComp.GetOtherPart(partComp.GetPartSimIsIn(this.Target));
                            int     num;
                            if (!this.Actor.RouteToSlotListAndCheckInUse(bedMultiPart, otherPart.RoutingSlot, out num))
                            {
                                this.Actor.AddExitReason(ExitReason.RouteFailed);
                                return(false);
                            }
                            this.Actor.SynchronizationLevel = Sim.SyncLevel.Routed;
                            if (this.Rejected)
                            {
                                this.Actor.PlaySoloAnimation("a2a_bed_relax_cuddle_reject_standing_y", true);
                                this.Actor.RouteAway(WooHoo.kMinDistanceToMoveAwayWhenRejected, WooHoo.kMaxDistanceToMoveAwayWhenRejected, true, new InteractionPriority(InteractionPriorityLevel.Zero), false, true, true, RouteDistancePreference.NoPreference);
                                return(true);
                            }
                            if (!otherPart.RelaxOnBed(this.Actor, "Enter_BedRelax_" + otherPart.StateNameSuffix))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            this.Actor.SynchronizationLevel = Sim.SyncLevel.Routed;
                        }
                        base.DoLoop(ExitReason.Default);
                        if (!this.Actor.HasExitReason(ExitReason.Finished))
                        {
                            base.PostLoop();
                            base.WaitForMasterInteractionToFinish();
                        }
                    }
                    base.PostLoop();
                    base.WaitForSyncComplete();
                    flag3 = true;// !this.Failed && !this.Rejected;
                    base.EndCommodityUpdates(flag3);
                    base.StandardExit(false, false);

                    if (flag3)
                    {
                        VisitSituation visitSituation  = VisitSituation.FindVisitSituationInvolvingGuest(this.Actor);
                        VisitSituation visitSituation2 = VisitSituation.FindVisitSituationInvolvingGuest(this.Target);
                        if (visitSituation != null && visitSituation2 != null)
                        {
                            visitSituation.GuestStartingInappropriateAction(this.Actor, 3.5f);
                            visitSituation2.GuestStartingInappropriateAction(this.Target, 3.5f);
                        }
                    }
                    if (flag3 && this.SleepAfter)
                    {
                        bedMultiPart.GetPartContaining(this.Actor).StateMachine = null;
                        if (!this.Actor.InteractionQueue.HasInteractionOfType(BedSleep.Singleton))
                        {
                            InteractionInstance instance3 = BedSleep.Singleton.CreateInstance(bedMultiPart, this.Actor, base.GetPriority(), base.Autonomous, base.CancellableByPlayer);
                            this.Actor.InteractionQueue.PushAsContinuation(instance3, true);
                        }
                        VisitSituation visitSituation3 = VisitSituation.FindVisitSituationInvolvingGuest(this.Target);
                        if (visitSituation3 != null && this.Actor.IsAtHome)
                        {
                            SocialCallback.OnStayOver(this.Actor, this.Target, false);
                        }
                        else
                        {
                            visitSituation3 = VisitSituation.FindVisitSituationInvolvingGuest(this.Actor);
                            if (visitSituation3 != null && this.Target.IsAtHome)
                            {
                                SocialCallback.OnStayOver(this.Target, this.Actor, false);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    StyledNotification.Show(new StyledNotification.Format(ex.ToString(), StyledNotification.NotificationStyle.kGameMessageNegative));
                }
                finally
                {
                    try
                    {
                        if (flag3)
                        {
                            #region Ge Payed and such

                            CommonMethods.HandlePostWoohoo(client, solicitor, bedId);

                            #endregion
                        }
                        #region Restore LTR

                        if (rRelationship != null && changeLTR)
                        {
                            rRelationship.LTR.SetLiking(originalLTR);
                            //Remove the lost friend moodlets if we didn't have them before, but have them now
                            if (!clientHasLFMoodlet && CommonMethods.HasMoodlet(client, BuffNames.LostAFriend, Origin.FromSocialization))
                            {
                                client.BuffManager.RemoveElement(BuffNames.LostAFriend);
                            }
                            if (!soliciterHasLFMoodlet && CommonMethods.HasMoodlet(solicitor, BuffNames.LostAFriend, Origin.FromSocialization))
                            {
                                solicitor.BuffManager.RemoveElement(BuffNames.LostAFriend);
                            }

                            //If we were not lovers, before but are now, remove the icon
                            if (lover)
                            {
                                rRelationship.LTR.RemoveInteractionBit(LongTermRelationship.InteractionBits.Romantic);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        StyledNotification.Show(new StyledNotification.Format("finally: " + ex.Message, StyledNotification.NotificationStyle.kGameMessageNegative));
                    }


                    #endregion
                }
                return(flag3);
            }
Example #6
0
        public override bool InRabbitHole()
        {
            try
            {
                Journalism job = OmniCareer.Career <Journalism>(Actor.Occupation);

                bool flag = (job != null) && job.CanReviewRabbitHole(Target);
                if (!flag)
                {
                    Sim sim = FamilyMemberOfSportsPlayer(Actor, false);
                    if (sim != null)
                    {
                        if (base.Actor == sim)
                        {
                            SimpleMessageDialog.Show(LocalizeString(Actor.SimDescription, "FreeGameTitle", new object[0x0]), LocalizeString(sim.SimDescription, "FreeGameForSportsPlayer", new object[] { sim }));
                        }
                        else
                        {
                            SimpleMessageDialog.Show(LocalizeString(Actor.SimDescription, "FreeGameTitle", new object[0x0]), LocalizeString(sim.SimDescription, "FreeGame", new object[] { base.Actor, sim }));
                        }
                    }
                    else
                    {
                        if (Actor.FamilyFunds < Stadium.AttendGame.kCostToAttendGame)
                        {
                            return(false);
                        }
                        Actor.ModifyFunds(-(int)Stadium.AttendGame.kCostToAttendGame);
                    }
                }
                ConfigureInteraction();
                StartStages();
                BeginCommodityUpdates();

                bool succeeded = false;

                try
                {
                    succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), new Interaction <Sim, Stadium> .InsideLoopFunction(WatchGameLoop), null);
                }
                finally
                {
                    EndCommodityUpdates(succeeded);
                }

                if (succeeded)
                {
                    EventTracker.SendEvent(new AttendedShowEvent(ShowVenue.ShowTypes.kStadiumGame, Actor));
                    EventTracker.SendEvent(EventTypeId.kWatchedStadiumGame, Actor, Target);
                    ChildUtils.AddBuffToParentAndChild(Actor, BuffNames.SawGreatGame, (Origin)(0x8bfc0021188986e0L));
                    if (flag)
                    {
                        job.RabbitHolesReviewed.Add(new Journalism.ReviewedRabbitHole(Target, ShowVenue.ShowTypes.kStadiumGame));
                    }
                }
                return(succeeded);
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Example #7
0
            protected override void OnPerform()
            {
                Dictionary <Sim, Vector3> lastOnLotPositions = new Dictionary <Sim, Vector3>();

                CaregiverRoutingMonitor monitor = new CaregiverRoutingMonitor(mHouse, mHouse.LotHome);

                bool stopMonitoring;
                Sim  arbitraryChild;
                int  caregiverCount;

                if (mHouse.LotHome == null)
                {
                    return;
                }
                else if (CaregiverRoutingMonitor.EnoughCaregiversRemain(mHouse, mHouse.LotHome, lastOnLotPositions, true, out stopMonitoring, out caregiverCount, out arbitraryChild))
                {
                    return;
                }
                else
                {
                    foreach (IBonehildaCoffin coffin in mHouse.LotHome.GetObjects <IBonehildaCoffin>())
                    {
                        if (coffin.isActiveAndNoBonehilda())
                        {
                            coffin.ForceSpawn();
                            return;
                        }
                    }

                    //Common.DebugNotify(delegate { return mHouse.Name + " " + caregiverCount; });

                    bool flag2      = CaregiverRoutingMonitor.IsLotHomeOrDaycareForHousehold(mHouse, mHouse.LotHome);
                    Sim  closestSim = null;

                    List <Sim> list = new List <Sim>(mHouse.Sims);
                    DaycareWorkdaySituation daycareWorkdaySituationForLot = DaycareWorkdaySituation.GetDaycareWorkdaySituationForLot(mHouse.LotHome);
                    if ((daycareWorkdaySituationForLot != null) && daycareWorkdaySituationForLot.IsServingHousehold(mHouse))
                    {
                        list.AddRange(daycareWorkdaySituationForLot.Daycare.OwnerDescription.Household.Sims);
                    }

                    float minDistance = float.MaxValue;

                    foreach (Sim sim3 in list)
                    {
                        if (sim3.SimDescription.TeenOrAbove)
                        {
                            Vector3 vector;
                            if (monitor.IsReturningToLotInQuestion(sim3, arbitraryChild))
                            {
                                return;
                            }

                            if (sim3.IsRouting && lastOnLotPositions.TryGetValue(sim3, out vector))
                            {
                                float distance = (sim3.Position - vector).LengthSqr();
                                if (distance < minDistance)
                                {
                                    minDistance = distance;
                                    closestSim  = sim3;
                                }
                            }
                        }
                    }

                    if (closestSim == null)
                    {
                        foreach (Sim sim4 in list)
                        {
                            if (sim4.SimDescription.TeenOrAbove)
                            {
                                float distance = (sim4.Position - arbitraryChild.Position).LengthSqr();
                                if (distance < minDistance)
                                {
                                    minDistance = distance;
                                    closestSim  = sim4;
                                }
                            }
                        }
                    }

                    bool flag3;
                    bool flag4;
                    bool flag5;
                    if (closestSim != null)
                    {
                        flag3 = false;
                        flag4 = false;
                        InteractionInstance headInteraction = closestSim.InteractionQueue.GetHeadInteraction();
                        if (headInteraction != null)
                        {
                            flag4 = !headInteraction.CancellableByPlayer;
                        }

                        flag5 = true;
                        foreach (Sim sim5 in mHouse.Sims)
                        {
                            if ((sim5.LotCurrent == mHouse.LotHome) && (sim5.SimDescription.ToddlerOrBelow) && (sim5.CurrentInteraction is AgeUp))
                            {
                                flag5 = false;
                                break;
                            }
                        }
                    }
                    else
                    {
                        return;
                    }

                    if (flag5)
                    {
                        if ((!GoHere.Settings.mInactiveChildrenAsActive) && (closestSim.IsNPC || CaregiverRoutingMonitor.TreatPlayerSimsLikeNPCs))
                        {
                            if ((caregiverCount == 0x0) && (!GoHere.Settings.mAllowChildHomeAlone))
                            {
                                Common.FunctionTask.Perform(monitor.DematerializeChildren);
                            }

                            return;
                        }
                        else if (!GoHere.Settings.mAllowChildHomeAlone)
                        {
                            if ((mHouse != Household.ActiveHousehold) || mHouse.AutoBabysitter || flag4)
                            {
                                flag3 = true;

                                if (mHouse == Household.ActiveHousehold)
                                {
                                    string str;
                                    if (flag2)
                                    {
                                        str = ChildUtils.Localize(arbitraryChild.SimDescription.IsFemale, "AutoNannyTns", new object[] { arbitraryChild });
                                    }
                                    else
                                    {
                                        str = ChildUtils.Localize(arbitraryChild.SimDescription.IsFemale, "AutoNannyAwayFromHomeTns", new object[] { arbitraryChild });
                                    }

                                    StyledNotification.Format format = new StyledNotification.Format(str, closestSim.ObjectId, arbitraryChild.ObjectId, StyledNotification.NotificationStyle.kSimTalking);
                                    StyledNotification.Show(format);
                                }
                            }
                            else
                            {
                                string str2;
                                if (flag2)
                                {
                                    str2 = ChildUtils.Localize(arbitraryChild.SimDescription.IsFemale, "NeedNannyDialogMessage", new object[] { arbitraryChild });
                                }
                                else
                                {
                                    str2 = ChildUtils.Localize(arbitraryChild.SimDescription.IsFemale, "NeedNannyAwayFromHomeDialogMessage", new object[] { arbitraryChild });
                                }

                                flag3 = TwoButtonDialog.Show(str2, ChildUtils.Localize(arbitraryChild.SimDescription.IsFemale, "NeedNannyDialogYes", new object[0x0]), ChildUtils.Localize(arbitraryChild.SimDescription.IsFemale, "NeedNannyDialogNo", new object[0x0]));
                            }
                        }
                        else
                        {
                            flag3 = true;
                            flag5 = true;
                            flag2 = true;
                        }
                    }

                    if (!flag5 || !flag3)
                    {
                        Vector3 position;
                        if (!lastOnLotPositions.TryGetValue(closestSim, out position))
                        {
                            position = Vector3.Invalid;
                        }
                        monitor.PushGoBackIfNeeded(closestSim, position);
                    }
                    else
                    {
                        if (!flag2)
                        {
                            foreach (Sim sim6 in mHouse.LotHome.GetSims())
                            {
                                if (sim6.SimDescription.TeenOrAbove && !sim6.IsRouting)
                                {
                                    flag3 = false;
                                    break;
                                }
                            }
                        }

                        if ((GoHere.Settings.mInactiveChildrenAsActive) || ((flag3 && !closestSim.IsNPC) && !CaregiverRoutingMonitor.TreatPlayerSimsLikeNPCs))
                        {
                            InitiateCaregiving(mHouse);
                        }
                    }
                }
            }
Example #8
0
        public override bool InRabbitHole()
        {
            string msg = "HaveAlienBabyHospital.InRabbitHole" + Common.NewLine;

            bool result;

            try
            {
                while (!Actor.WaitForExitReason(Sim.kWaitForExitReasonDefaultTime, ExitReason.CanceledByScript) && !BabyShouldBeBorn)
                {
                }

                msg += "A";

                if (!BabyShouldBeBorn && Actor.HasExitReason(ExitReason.CanceledByScript))
                {
                    result = false;
                }
                else
                {
                    msg += "B";

                    AlienPregnancyProxy pregnancy = new AlienPregnancyProxy(Actor.SimDescription.Pregnancy);

                    if (Actor.IsSelectable)
                    {
                        Sims3.Gameplay.Gameflow.Singleton.DisableSave(this, "Gameplay/ActorSystems/Pregnancy:DisableSave");
                    }

                    mNewborns = pregnancy.CreateNewborns(Pregnancy.HaveBabyHospital.kBonusMoodPointsForHospitalBirth, Actor.IsSelectable, false);

                    for (int i = 0; i < mNewborns.Count; i++)
                    {
                        Relationship.Get(Actor, mNewborns[i], true).LTR.ForceChangeState(LongTermRelationshipTypes.Friend);
                    }

                    msg += "C";

                    Actor.SimDescription.SetPregnancy(0f);
                    List <Sim> followers = SimFollowers;
                    pregnancy.PregnancyComplete(mNewborns, followers);

                    msg += "D";

                    SpeedTrap.Sleep(0u);
                    List <Sim> list2 = new List <Sim>();
                    list2.Add(Actor);

                    if (followers != null)
                    {
                        foreach (Sim sim in followers)
                        {
                            if (sim.SimDescription.TeenOrAbove && sim.GetObjectInRightHand() == null)
                            {
                                list2.Add(sim);
                            }
                        }
                    }

                    msg += "E";

                    if (mNewborns.Count <= list2.Count)
                    {
                        for (int i = 0; i < mNewborns.Count; i++)
                        {
                            Sim     target  = list2[i];
                            Posture posture = target.Posture;
                            target.Posture = null;
                            Sim actor = mNewborns[i];
                            InteractionInstance entry = Pregnancy.PregnancyPlaceholderInteraction.Singleton.CreateInstance(target, actor,
                                                                                                                           new InteractionPriority(InteractionPriorityLevel.Zero), false, false);
                            actor.InteractionQueue.Add(entry);

                            while (actor.CurrentInteraction != entry && actor.InteractionQueue.HasInteraction(entry))
                            {
                                SpeedTrap.Sleep();
                            }

                            try
                            {
                                ChildUtils.CarryChild(target, actor, false);
                            }
                            catch (Exception e)
                            {
                                Common.Exception(actor, target, e);
                            }

                            target.Posture = posture;
                            AddFollower(mNewborns[i]);
                        }
                    }
                    else
                    {
                        BabyBasket basket = GlobalFunctions.CreateObject("BabyBasket", Vector3.OutOfWorld, 0, Vector3.UnitZ) as BabyBasket;
                        basket.AddBabiesToBasket(mNewborns);
                        CarrySystem.EnterWhileHolding(Actor, basket);
                        CarrySystem.VerifyAnimationParent(basket, Actor);
                    }

                    msg += "F";

                    if (Actor.IsSelectable)
                    {
                        OccultImaginaryFriend.DeliverDollToHousehold(mNewborns);
                    }

                    result = true;
                }
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, msg, e);
                result = false;
            }

            Common.DebugNotify(msg);

            return(result);
        }
Example #9
0
        public override bool Run()
        {
            try
            {
                Actor.GreetSimOnMyLotIfPossible(Target);

                if (StartBedCuddleA.GetCuddleType(Actor, Target) == StartBedCuddleA.CuddleType.CuddleTargetOnDifferentBed)
                {
                    ChildUtils.SetPosturePrecondition(this, CommodityKind.Relaxing, new CommodityKind[] { CommodityKind.NextToTarget });
                    Actor.InteractionQueue.PushAsContinuation(this, true);

                    return(true);
                }

                BedMultiPart container = null;

                try
                {
                    if (Actor.Posture == null)
                    {
                        return(false);
                    }

                    if (!Actor.Posture.Satisfies(CommodityKind.Relaxing, null))
                    {
                        return(false);
                    }

                    if (!SafeToSync())
                    {
                        return(false);
                    }

                    container = Actor.Posture.Container as BedMultiPart;

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

                    if (IsMaster && ReturnInstance == null)
                    {
                        EnterStateMachine("BedSocials", "FromRelax", "x", "y");
                        AddPersistentScriptEventHandler(0x0, EventCallbackChangeVisibility);
                        SetActor("bed", container);
                        container.PartComp.GetPartSimIsIn(Actor).SetPartParameters(mCurrentStateMachine);
                        WooHoo interaction = InteractionDefinition.CreateInstance(Actor, Target, GetPriority(), false, CancellableByPlayer) as WooHoo;
                        interaction.IsMaster = false;
                        interaction.LinkedInteractionInstance = this;
                        ChildUtils.SetPosturePrecondition(interaction, CommodityKind.Relaxing, new CommodityKind[] { CommodityKind.NextToTarget });
                        Target.InteractionQueue.AddNext(interaction);

                        if (Target.Posture.Container != Actor.Posture.Container)
                        {
                            Actor.LookAtManager.SetInteractionLookAt(Target, 0xc8, LookAtJointFilter.TorsoBones);
                            Actor.Posture.CurrentStateMachine.RequestState("x", "callOver");
                        }

                        Actor.SynchronizationLevel  = Sim.SyncLevel.Started;
                        Actor.SynchronizationTarget = Target;
                        Actor.SynchronizationRole   = Sim.SyncRole.Initiator;

                        if (!StartSync(IsMaster))
                        {
                            return(false);
                        }

                        if (!Actor.WaitForSynchronizationLevelWithSim(Target, Sim.SyncLevel.Routed, 30f))
                        {
                            return(false);
                        }

                        Actor.SocialComponent.StartSocializingWith(Target);
                    }
                    else if (!StartSync(IsMaster))
                    {
                        return(false);
                    }
                }
                catch (ResetException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    Common.DebugException(Actor, Target, e);
                    return(false);
                }

                StandardEntry(false);
                BeginCommodityUpdates();
                bool succeeded = false;

                try
                {
                    if (IsMaster)
                    {
                        if (CommonWoohoo.NeedPrivacy(container.InherentlyProvidesPrivacy, Actor, Target))
                        {
                            mSituation = new WooHooPrivacySituation(this);

                            if (!mSituation.Start())
                            {
                                FinishLinkedInteraction();
                                PostLoop();

                                if (ReturnInstance == null)
                                {
                                    InteractionInstance instance = BedRelax.Singleton.CreateInstance(Actor.Posture.Container, Actor, GetPriority(), true, true);
                                    Actor.InteractionQueue.PushAsContinuation(instance, true);
                                }
                                else
                                {
                                    DoResume();
                                }

                                WooHoo linkedInteractionInstance = LinkedInteractionInstance as WooHoo;

                                if (linkedInteractionInstance != null)
                                {
                                    if (ReturnInstance == null)
                                    {
                                        InteractionInstance instance2 = BedRelax.Singleton.CreateInstance(Target.Posture.Container, Target, GetPriority(), true, true);
                                        Target.InteractionQueue.PushAsContinuation(instance2, true);
                                    }
                                    else
                                    {
                                        linkedInteractionInstance.DoResume();
                                    }

                                    linkedInteractionInstance.Failed = true;
                                }

                                WaitForSyncComplete();

                                return(false);
                            }
                        }

                        IWooHooDefinition definition = InteractionDefinition as IWooHooDefinition;
                        Actor.LookAtManager.ClearInteractionLookAt();
                        Target.LookAtManager.ClearInteractionLookAt();

                        if (ReturnInstance != null)
                        {
                            ReturnInstance.EnsureMaster();
                            mCurrentStateMachine = ReturnInstance.mCurrentStateMachine;
                        }

                        StartSocial(CommonSurrogate.GetSocialName(definition.GetStyle(this)));
                        InitiateSocialUI(Actor, Target);
                        WooHoo linked = LinkedInteractionInstance as WooHoo;

                        if (linked != null)
                        {
                            linked.Rejected = Rejected;
                        }

                        if (Rejected)
                        {
                            if (Actor.Posture.Container == Target.Posture.Container)
                            {
                                ThoughtBalloonManager.BalloonData bd = new ThoughtBalloonManager.DoubleBalloonData("balloon_woohoo", "balloon_question");
                                bd.BalloonType = ThoughtBalloonTypes.kSpeechBalloon;
                                Actor.ThoughtBalloonManager.ShowBalloon(bd);
                                AddOneShotScriptEventHandler(0x194, ShowRejectBalloonAndEnqueueRouteAway);
                                mCurrentStateMachine.RequestState(false, "x", "WooHooReject");
                                mCurrentStateMachine.RequestState(true, "y", "WooHooReject");
                                mCurrentStateMachine.RequestState(true, null, "ToRelax");
                            }
                        }
                        else
                        {
                            mCurrentStateMachine.AddOneShotScriptEventHandler(0x6e, OnPregnancyEvent);
                            mCurrentStateMachine.AddOneShotScriptEventHandler(0x6e, EventCallbackChangeClothes);
                            string wooHooEffectName = container.TuningBed.WooHooEffectName;

                            if (!string.IsNullOrEmpty(wooHooEffectName))
                            {
                                mWooHooEffect = VisualEffect.Create(wooHooEffectName);
                                mWooHooEffect.ParentTo(container, Slots.Hash("_FX_0"));
                                AddOneShotScriptEventHandler(0xc8, EventCallbackWooHoo);
                                AddOneShotScriptEventHandler(0xc9, EventCallbackWooHoo);
                            }

                            if (container is BedDreamPod)
                            {
                                AddOneShotScriptEventHandler(0xc8, EventCallbackDreamPodWooHoo);
                                AddOneShotScriptEventHandler(0xc9, EventCallbackDreamPodWooHoo);
                            }

                            Sim.ClothesChangeReason reason = Sim.ClothesChangeReason.GoingToBed;

                            if ((Woohooer.Settings.mNakedOutfitBed) && (!container.IsOutside))
                            {
                                reason = Sim.ClothesChangeReason.GoingToBathe;
                                Woohooer.Settings.AddChange(Actor);
                                Woohooer.Settings.AddChange(Target);
                            }

                            mHelperX = new Sim.SwitchOutfitHelper(Actor, reason);
                            mHelperY = new Sim.SwitchOutfitHelper(Target, reason);
                            mHelperX.Start();
                            mHelperY.Start();
                            mJealousyAlarm = AlarmManager.Global.AddAlarm(kJealousyBroadcasterDelay, TimeUnit.Minutes, StartJealousyBroadcaster, "StartJealousyBroadcaster", AlarmType.DeleteOnReset, container);
                            container.PreWooHooBehavior(Actor, Target, this);
                            mCurrentStateMachine.RequestState(false, "x", "WooHoo");
                            mCurrentStateMachine.RequestState(true, "y", "WooHoo");
                            container.PostWooHooBehavior(Actor, Target, this);
                            Relationship.Get(Actor, Target, true).STC.Update(Actor, Target, CommodityTypes.Amorous, kSTCIncreaseAfterWoohoo);

                            if (CanSleep(Actor, container))
                            {
                                SleepAfter = true;
                            }
                            else
                            {
                                SleepAfter = false;
                                container.PartComp.GetPartSimIsIn(Actor).BedMade = true;
                            }

                            if (CanSleep(Target, container))
                            {
                                (LinkedInteractionInstance as WooHoo).SleepAfter = true;
                            }
                            else
                            {
                                (LinkedInteractionInstance as WooHoo).SleepAfter  = false;
                                container.PartComp.GetPartSimIsIn(Target).BedMade = true;
                            }

                            /*
                             * if (SleepAfter)
                             * {
                             *  mCurrentStateMachine.RequestState(null, "ToSleep");
                             * }
                             * else*/
                            {
                                mCurrentStateMachine.RequestState(null, "ToRelax");
                            }

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

                            if (container is BedDoubleHover)
                            {
                                Actor.BuffManager.AddElement(BuffNames.MeterHighClub, Origin.FromWooHooOnHoverBed);
                                Target.BuffManager.AddElement(BuffNames.MeterHighClub, Origin.FromWooHooOnHoverBed);
                            }

                            if (container is BedDreamPod)
                            {
                                Actor.BuffManager.AddElement(BuffNames.DoubleDreaming, Origin.FromWooHooInDreamPod);
                                Target.BuffManager.AddElement(BuffNames.DoubleDreaming, Origin.FromWooHooInDreamPod);
                            }
                        }

                        FinishSocial(CommonSurrogate.GetSocialName(definition.GetStyle(this)), true);
                        CleanupSituation();
                        Actor.AddExitReason(ExitReason.Finished);
                    }
                    else
                    {
                        container = Target.Posture.Container as BedMultiPart;

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

                        PartComponent <BedData> partComp = container.PartComp;

                        if (partComp.GetSimInOtherPart(Target) == null)
                        {
                            int     num;
                            BedData otherPart = partComp.GetOtherPart(partComp.GetPartSimIsIn(Target));

                            if (!Actor.RouteToSlotListAndCheckInUse(container, otherPart.RoutingSlot, out num))
                            {
                                Actor.AddExitReason(ExitReason.RouteFailed);
                                return(false);
                            }

                            Actor.SynchronizationLevel = Sim.SyncLevel.Routed;

                            if (Rejected)
                            {
                                Actor.PlaySoloAnimation("a2a_bed_relax_cuddle_reject_standing_y", true);
                                Actor.RouteAway(kMinDistanceToMoveAwayWhenRejected, kMaxDistanceToMoveAwayWhenRejected, true,
                                                new InteractionPriority(InteractionPriorityLevel.Zero), false, true, true, RouteDistancePreference.NoPreference);

                                return(true);
                            }

                            if (!otherPart.RelaxOnBed(Actor, "Enter_BedRelax_" + otherPart.StateNameSuffix))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            Actor.SynchronizationLevel = Sim.SyncLevel.Routed;
                        }

                        DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));

                        if (!Actor.HasExitReason(ExitReason.Finished))
                        {
                            PostLoop();
                            WaitForMasterInteractionToFinish();
                        }
                    }

                    PostLoop();
                    WaitForSyncComplete();

                    succeeded = !Failed && !Rejected;
                }
                finally
                {
                    EndCommodityUpdates(succeeded);
                    StandardExit(false, false);
                }

                if (succeeded)
                {
                    VisitSituation situation  = VisitSituation.FindVisitSituationInvolvingGuest(Actor);
                    VisitSituation situation2 = VisitSituation.FindVisitSituationInvolvingGuest(Target);

                    if (situation != null && situation2 != null)
                    {
                        situation.GuestStartingInappropriateAction(Actor, 3.5f);
                        situation2.GuestStartingInappropriateAction(Target, 3.5f);
                    }
                }

                if (succeeded && SleepAfter)
                {
                    if (!Actor.InteractionQueue.HasInteractionOfType(BedSleep.Singleton))
                    {
                        InteractionInstance instance = BedSleep.Singleton.CreateInstance(container, Actor, GetPriority(), Autonomous, CancellableByPlayer);
                        Actor.InteractionQueue.PushAsContinuation(instance, true);
                    }

                    if (VisitSituation.FindVisitSituationInvolvingGuest(Target) != null && Actor.IsAtHome)
                    {
                        SocialCallback.OnStayOver(Actor, Target, false);
                    }
                    else if (VisitSituation.FindVisitSituationInvolvingGuest(Actor) != null && Target.IsAtHome)
                    {
                        SocialCallback.OnStayOver(Target, Actor, false);
                    }
                }
                else if (!IsOwner(Actor, container))
                {
                    InteractionInstance instance = Actor.Posture.GetStandingTransition();

                    if (instance != null)
                    {
                        Actor.InteractionQueue.Add(instance);
                    }
                }

                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Woohooer.Settings.AddChange(Actor);
                Woohooer.Settings.AddChange(Target);
                Common.Exception(Actor, Target, e);

                return(false);
            }
        }
Example #10
0
        public override bool Run()
        {
            try
            {
                if (!Target.RouteSimToMeAndCheckInUse(Actor) || !HarvestPlant.HarvestTest(Target, Actor))
                {
                    return(false);
                }

                Target.RemoveHarvestStateTimeoutAlarm();
                StandardEntry();
                BeginCommodityUpdates();
                Soil dummyIk = null;
                StateMachineClient client = null;

                bool allowChild = false;

                if (Actor.SimDescription.YoungAdultOrAbove)
                {
                    allowChild = true;
                }
                else if ((Actor.SimDescription.Teen) && (Woohooer.Settings.mUnlockTeenActions))
                {
                    allowChild = true;
                }

                if ((!Autonomous) && (allowChild) && RandomUtil.RandomChance01(kChanceToHavePlantSimBaby))
                {
                    client   = Target.CreateStateMachine(Actor, out dummyIk);
                    mDummyIk = dummyIk;
                    Sim newBorn = GetNewBorn();
                    Relationship.Get(Actor, newBorn, true).LTR.ForceChangeState(LongTermRelationshipTypes.Friend);
                    if (newBorn.BridgeOrigin != null)
                    {
                        newBorn.BridgeOrigin.MakeRequest();
                        newBorn.BridgeOrigin = null;
                    }

                    if (client != null)
                    {
                        IGameObject actor = GlobalFunctions.CreateObjectOutOfWorld("plantSimHarvestable", ProductVersion.EP9, "Sims3.Gameplay.Core.Null", null);
                        client.SetActor("harvestable", actor);
                        client.SetActor("y", newBorn);
                        client.EnterState("x", "Enter Standing");
                        Target.SetGrowthState(PlantGrowthState.Planted);
                        client.RequestState("x", "HaveAPlantSimBaby");
                        Pregnancy.MakeBabyVisible(newBorn);
                        client.RequestState("x", "Exit Standing");
                        actor.RemoveFromWorld();
                        actor.Destroy();
                    }

                    if (Actor.IsSelectable)
                    {
                        OccultImaginaryFriend.DeliverDollToHousehold(new List <Sim>(new Sim[] { newBorn }));
                    }

                    ChildUtils.CarryChild(Actor, newBorn, true);
                    EventTracker.SendEvent(EventTypeId.kBornFromTheSoil, newBorn);
                }
                else
                {
                    client   = Target.CreateStateMachine(Actor, out dummyIk);
                    mDummyIk = dummyIk;
                    bool hasHarvested = true;
                    if (Actor.IsInActiveHousehold)
                    {
                        hasHarvested = false;
                        foreach (SimDescription description in Actor.Household.SimDescriptions)
                        {
                            Gardening skill = description.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);
                            if ((skill != null) && skill.HasHarvested())
                            {
                                hasHarvested = true;
                                break;
                            }
                        }
                    }

                    IGameObject obj3 = GlobalFunctions.CreateObjectOutOfWorld("plantForbiddenFruit", ProductVersion.EP9, "Sims3.Gameplay.Core.Null", null);
                    if (client != null)
                    {
                        client.SetActor("harvestable", obj3);
                        client.EnterState("x", "Enter Standing");
                        client.RequestState("x", "HaveAFruit");
                    }
                    Target.DoHarvest(Actor, hasHarvested, null);
                    Target.SetGrowthState(PlantGrowthState.Planted);
                    if (client != null)
                    {
                        client.RequestState("x", "Exit Standing");
                    }
                    obj3.RemoveFromWorld();
                    obj3.Destroy();
                }

                EndCommodityUpdates(true);
                StandardExit();
                Target.RemoveFromWorld();
                Target.Destroy();
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Example #11
0
        public override bool InRabbitHole()
        {
            string msg = "HaveAlienBabyHosptial:InRabbitHole" + "\n";

            try
            {
                while (!Actor.WaitForExitReason(Sim.kWaitForExitReasonDefaultTime, ExitReason.CanceledByScript))
                {
                    if (BabyShouldBeBorn)
                    {
                        break;
                    }
                }

                msg += "A";

                if (!BabyShouldBeBorn && Actor.HasExitReason(ExitReason.CanceledByScript))
                {
                    return(false);
                }

                msg += "B";

                Pregnancy pregnancy    = Actor.SimDescription.Pregnancy;
                bool      isSelectable = Actor.IsSelectable;
                Sims3.Gameplay.Gameflow.Singleton.DisableSave(this, "Gameplay/ActorSystems/Pregnancy:DisableSave");
                mNewborns = new PregnancyProxy(pregnancy).CreateNewborns(Pregnancy.HaveBabyHospital.kBonusMoodPointsForHospitalBirth, isSelectable, false);

                msg += "C";

                Actor.SimDescription.SetPregnancy(0f);
                List <Sim> simFollowers = SimFollowers;
                new PregnancyProxy(pregnancy).PregnancyComplete(mNewborns, simFollowers);

                /*
                 * if (mNewborns.Count == 4)
                 * {
                 *  Actor.BuffManager.RemoveElement(BuffNames.ItsABoy);
                 *  Actor.BuffManager.AddElement(CommonPregnancy.sItsQuadruplets, Origin.FromNewBaby);
                 * }
                 */

                msg += "D";

                Simulator.Sleep(0u);
                //SpeedTrap.Sleep(0x0);

                List <Sim> list2 = new List <Sim>();
                list2.Add(Actor);

                if (simFollowers != null)
                {
                    foreach (Sim sim in simFollowers)
                    {
                        if (sim.SimDescription.TeenOrAbove && sim.GetObjectInRightHand() == null)
                        {
                            list2.Add(sim);
                        }
                    }
                }

                msg += "E";

                if (mNewborns.Count <= list2.Count)
                {
                    for (int i = 0; i < mNewborns.Count; i++)
                    {
                        Sim     target  = list2[i];
                        Posture posture = target.Posture;
                        target.Posture = null;
                        Sim actor = mNewborns[i];
                        InteractionInstance entry = Pregnancy.PregnancyPlaceholderInteraction.Singleton.CreateInstance(target, actor,
                                                                                                                       new InteractionPriority(InteractionPriorityLevel.Zero), false, false);
                        actor.InteractionQueue.Add(entry);

                        while (actor.CurrentInteraction != entry && actor.InteractionQueue.HasInteraction(entry))
                        {
                            Simulator.Sleep(0u);
                            //SpeedTrap.Sleep();
                        }

                        try
                        {
                            ChildUtils.CarryChild(target, actor, false);
                        }
                        catch (Exception e)
                        {
                            Logger.WriteExceptionLog(e, this, "HaveAlienBabyHospital.Run() Error - CarryChild()");
                        }

                        target.Posture = posture;
                        AddFollower(mNewborns[i]);
                    }
                }
                else
                {
                    BabyBasket basket = GlobalFunctions.CreateObject("BabyBasket", Vector3.OutOfWorld, 0, Vector3.UnitZ) as BabyBasket;
                    basket.AddBabiesToBasket(mNewborns);
                    CarrySystem.EnterWhileHolding(Actor, basket);
                    CarrySystem.VerifyAnimationParent(basket, Actor);
                }

                msg += "F";

                if (Actor.IsSelectable)
                {
                    OccultImaginaryFriend.DeliverDollToHousehold(mNewborns);
                }

                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Logger.WriteExceptionLog(e, this, "HaveAlienBabyHospital.Run() Error");
                return(false);
            }
        }
Example #12
0
        public override bool InRabbitHole()
        {
            string msg = "HaveBabyHospitalEx:InRabbitHole" + Common.NewLine;

            try
            {
                while (!Actor.WaitForExitReason(Sim.kWaitForExitReasonDefaultTime, ExitReason.CanceledByScript))
                {
                    if (BabyShouldBeBorn && (((mDad == null) || !(mDad.CurrentInteraction is Pregnancy.GoToHospital)) || ((SimFollowers != null) && SimFollowers.Contains(mDad))))
                    {
                        break;
                    }
                }

                msg += "A";

                if (!BabyShouldBeBorn && Actor.HasExitReason(ExitReason.CanceledByScript))
                {
                    return(false);
                }

                msg += "B";

                Pregnancy pregnancy = Actor.SimDescription.Pregnancy;
                if (pregnancy != null)
                {
                    // Custom
                    HaveBabyHomeEx.EnsureForeignFather(pregnancy);
                }

                bool isSelectable = Actor.IsSelectable;
                //if (isSelectable)
                //{
                Sims3.Gameplay.Gameflow.Singleton.DisableSave(this, "Gameplay/ActorSystems/Pregnancy:DisableSave");
                //mNewborns = CreateNewborns(new HaveBabyHomeEx.PregnancyProxy(pregnancy), kBonusMoodPointsForHospitalBirth, isSelectable, false);
                mNewborns = new Proxies.PregnancyProxy(pregnancy).CreateNewborns(kBonusMoodPointsForHospitalBirth, isSelectable, false);
                // }
                // else
                // {
                //   try
                // {
                //   Simulator.YieldingDisabled = true;
                //mNewborns = CreateNewborns(new HaveBabyHomeEx.PregnancyProxy(pregnancy), kBonusMoodPointsForHospitalBirth, isSelectable, false); - was commented
                // mNewborns = new Proxies.PregnancyProxy(pregnancy).CreateNewborns(kBonusMoodPointsForHospitalBirth, isSelectable, false);
                // }
                //// finally
                // {
                //     Simulator.YieldingDisabled = false;
                // }
                // }

                msg += "C";

                Sim dad = Actor.SimDescription.Pregnancy.mDad;

                Actor.SimDescription.SetPregnancy(0f);
                List <Sim> simFollowers = SimFollowers;
                Actor.SimDescription.Pregnancy.PregnancyComplete(mNewborns, simFollowers);

                if (mNewborns.Count == 4)
                {
                    Actor.BuffManager.RemoveElement(BuffNames.ItsABoy);
                    Actor.BuffManager.AddElement(CommonPregnancy.sItsQuadruplets, Origin.FromNewBaby);

                    if (dad != null)
                    {
                        dad.BuffManager.RemoveElement(BuffNames.ItsABoy);
                        dad.BuffManager.AddElement(CommonPregnancy.sItsQuadruplets, Origin.FromNewBaby);
                    }
                }

                msg += "D";

                SpeedTrap.Sleep(0x0);

                List <Sim> list2 = new List <Sim>();
                list2.Add(Actor);

                if (simFollowers != null)
                {
                    foreach (Sim sim in simFollowers)
                    {
                        if (sim.SimDescription.TeenOrAbove && (sim.GetObjectInRightHand() == null))
                        {
                            list2.Add(sim);
                        }
                    }
                }

                msg += "E";

                if (mNewborns.Count <= list2.Count)
                {
                    for (int i = 0x0; i < mNewborns.Count; i++)
                    {
                        Sim     target  = list2[i];
                        Posture posture = target.Posture;
                        target.Posture = null;
                        Sim actor = mNewborns[i];
                        InteractionInstance entry = Pregnancy.PregnancyPlaceholderInteraction.Singleton.CreateInstance(target, actor, new InteractionPriority(InteractionPriorityLevel.Zero), false, false);
                        actor.InteractionQueue.Add(entry);

                        while ((actor.CurrentInteraction != entry) && actor.InteractionQueue.HasInteraction(entry))
                        {
                            SpeedTrap.Sleep();
                        }

                        try
                        {
                            ChildUtils.CarryChild(target, actor, false);
                        }
                        catch (Exception e)
                        {
                            Common.Exception(actor, target, e);
                        }

                        target.Posture = posture;
                        AddFollower(mNewborns[i]);
                    }
                }
                else
                {
                    BabyBasket basket = GlobalFunctions.CreateObject("BabyBasket", Vector3.OutOfWorld, 0x0, Vector3.UnitZ) as BabyBasket;
                    basket.AddBabiesToBasket(mNewborns);
                    CarrySystem.EnterWhileHolding(Actor, basket);
                    CarrySystem.VerifyAnimationParent(basket, Actor);
                }

                msg += "F";

                if (Actor.IsSelectable)
                {
                    OccultImaginaryFriend.DeliverDollToHousehold(mNewborns);
                }
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, msg, e);
                return(false);
            }
        }
Example #13
0
        public override bool Run()
        {
            try
            {
                Definition interactionDefinition = InteractionDefinition as Definition;
                if (interactionDefinition != null)
                {
                    mLookForAutonomousActionsUponArrival = interactionDefinition.mLookForAutonomousActionsUponArrival;
                }
                else
                {
                    mLookForAutonomousActionsUponArrival = true;
                }

                if ((Target.CommercialLotSubType == CommercialLotSubType.kEP10_Resort) &&
                    (Actor.IsHuman) &&
                    (Actor.SimDescription.ChildOrAbove) &&
                    (Actor.LotHome == null) &&
                    (Autonomous) &&
                    (NumFollowers == 0) &&
                    (Actor.GetSituationOfType <Situation>() == null) &&
                    (!Actor.SimDescription.HasActiveRole) &&
                    (Actor.Service == null))
                {
                    IResortTower[] objects = Target.GetObjects <IResortTower>();
                    if (objects.Length > 0)
                    {
                        IResortTower        randomObjectFromList = RandomUtil.GetRandomObjectFromList <IResortTower>(objects);
                        InteractionInstance instance             = randomObjectFromList.GetExitTowerDefinition().CreateInstance(randomObjectFromList, Actor, new InteractionPriority(InteractionPriorityLevel.Autonomous), Autonomous, false);
                        if (Actor.InteractionQueue.PushAsContinuation(instance, false))
                        {
                            if (!Actor.Household.IsServiceNpcHousehold)
                            {
                                foreach (SimDescription description in Actor.Household.SimDescriptions)
                                {
                                    if ((description.IsHuman && description.ChildOrAbove) && (description.CreatedSim == null))
                                    {
                                        Sim actor = description.InstantiateOffScreen(Target);
                                        InteractionInstance entry = randomObjectFromList.GetExitTowerDefinition().CreateInstance(randomObjectFromList, actor, new InteractionPriority(InteractionPriorityLevel.Autonomous), Autonomous, false);
                                        actor.InteractionQueue.Add(entry);
                                    }
                                }
                            }
                            return(true);
                        }
                    }
                }

                if ((Target.CommercialLotSubType == CommercialLotSubType.kEP10_Diving) && Actor.SimDescription.Child)
                {
                    return(false);
                }

                if (!CarpoolManager.WaitForCarpool(Actor))
                {
                    return(false);
                }

                if (ShouldReenqueueWithStandingPrecondition())
                {
                    ChildUtils.SetPosturePrecondition(this, CommodityKind.Standing, new CommodityKind[0x0]);
                    return(Actor.InteractionQueue.PushAsContinuation(this, false));
                }

                if (mFollowers == null)
                {
                    if (InteractionDefinition is DateDefinition)
                    {
                        mFollowers = new List <Sim>();
                    }
                    else
                    {
                        mFollowers = GetFollowers(Actor);
                        if (Actor.IsNPC)
                        {
                            if (mFollowers.Count == 0)
                            {
                                Sim sim;
                                if (HorseManager.NpcShouldRideHorse(Actor, out sim))
                                {
                                    mFollowers.Add(sim);
                                }
                            }
                            else if ((Autonomous && RandomUtil.RandomChance01(Sim.GoForWalkWithDog.kChanceOfAutonomousDogWalk)) && sAcceptableCommercialLotSubTypes.Contains(Target.CommercialLotSubType))
                            {
                                foreach (Sim sim2 in new List <Sim>(mFollowers))
                                {
                                    if (Sim.GoForWalkWithDog.ActorCanWalkTarget(Actor, sim2))
                                    {
                                        InteractionInstance entry = Sim.GoForWalkWithDog.Singleton.CreateInstance(sim2, Actor, GetPriority(), true, false);
                                        (entry as Sim.GoForWalkWithDog).TargetLot = Target;
                                        Actor.InteractionQueue.AddNext(entry);
                                        return(true);
                                    }
                                }
                            }

                            foreach (Sim sim3 in new List <Sim>(mFollowers))
                            {
                                GroupingSituation.StartGroupingSituation(Actor, sim3, false);
                            }
                        }
                        else
                        {
                            GroupingSituation situationOfType = Actor.GetSituationOfType <GroupingSituation>();
                            if ((situationOfType != null) && !situationOfType.ConfirmLeaveGroup(Actor, "Gameplay/Situations/GroupingSituation:ContinueVisitAloneInteraction"))
                            {
                                return(false);
                            }
                        }
                    }
                }

                if (Sim.SwitchToFormalOutfitIfCocktail(Actor, Target))
                {
                    foreach (Sim sim in new List <Sim> (mFollowers))
                    {
                        sim.OutfitCategoryToUseForRoutingOffLot = OutfitCategories.Formalwear;
                    }
                }

                Occupation occupation = Actor.Occupation;
                if (((occupation != null) && (occupation.ActiveCareerLotID == Target.LotId)) && occupation.IsAllowedToWork())
                {
                    Actor.Occupation.EnsureSimHasOccupationOutfit();
                    if (Actor.Posture == Actor.Standing)
                    {
                        Actor.SwitchToOutfitWithSpin(Sim.ClothesChangeReason.GoingToWork);
                    }
                    else
                    {
                        OutfitCategories categories;
                        Actor.GetOutfitForClothingChange(Sim.ClothesChangeReason.GoingToWork, out categories);
                        Actor.OutfitCategoryToUseForRoutingOffLot = categories;
                    }
                }

                bool flag2 = false;

                MetaAutonomyVenueType metaAutonomyVenueType = Target.LotCurrent.GetMetaAutonomyVenueType();

                // Custom
                if ((mFollowers.Count == 0) && (GoHereEx.Teleport.Perform(Actor, Target, true)))
                {
                    flag2 = true;
                }
                else
                {
                    Door door = Target.FindFrontDoor();
                    if (door != null)
                    {
                        bool wantToBeOutside = true;
                        if (Target.IsOpenVenue())
                        {
                            wantToBeOutside = false;
                        }

                        Route r = null;
                        Target.RouteToFrontDoor(Actor, Sim.MinDistanceFromDoorWhenVisiting, Sim.MaxDistanceFromDoorWhenGoingInside, ref door, wantToBeOutside, ref r, false);
                        if (r != null)
                        {
                            r.DoRouteFail = false;
                            flag2         = GoHereSpace.Helpers.SimRoutingComponentEx.DoRouteWithFollowers(Actor.SimRoutingComponent, r, mFollowers);
                            Lot.ValidateFollowers(mFollowers);
                        }
                    }
                }

                if (!flag2)
                {
                    Actor.RemoveExitReason(ExitReason.RouteFailed);
                    Route route = Actor.CreateRoute();
                    if (Autonomous && mLookForAutonomousActionsUponArrival)
                    {
                        bool flag4 = RandomUtil.RandomChance(Lot.ChanceOfGoingToCommunityLotByCar);
                        if (!flag4)
                        {
                            route.SetOption(Route.RouteOption.EnablePlanningAsCar, flag4);
                        }
                    }
                    route.SetRouteMetaType(Route.RouteMetaType.GoCommunityLot);

                    if ((metaAutonomyVenueType == MetaAutonomyVenueType.Diving) && Actor.SimDescription.IsMermaid)
                    {
                        Lot lotCurrent = Actor.LotCurrent;
                        if ((lotCurrent != null) && lotCurrent.IsHouseboatLot())
                        {
                            route.SetOption2(Sims3.SimIFace.Route.RouteOption2.EnablePlanningAsBoat, true);
                        }
                    }

                    Target.PlanToLotEx(route);
                    if (!route.PlanResult.Succeeded())
                    {
                        foreach (Shell shell in Target.GetObjects <Shell>())
                        {
                            route = shell.GetRouteToShell(Actor);
                            if (route.PlanResult.Succeeded())
                            {
                                break;
                            }
                        }
                    }

                    // Custom Function
                    flag2 = GoHereSpace.Helpers.SimRoutingComponentEx.DoRouteWithFollowers(Actor.SimRoutingComponent, route, mFollowers);
                    Lot.ValidateFollowers(mFollowers);
                }

                if (flag2)
                {
                    NumSuccess++;
                    if (Autonomous)
                    {
                        Target.MakeSimDoSomethingAfterArrivingAtVenue(metaAutonomyVenueType, Actor);
                        if (mFollowers != null)
                        {
                            foreach (Sim sim3 in new List <Sim>(mFollowers))
                            {
                                Target.MakeSimDoSomethingAfterArrivingAtVenue(metaAutonomyVenueType, sim3);
                            }
                        }
                    }

                    // Custom check
                    if ((!GoHere.Settings.DisallowAutoGroup(Actor)) &&
                        (Actor.Household != null) &&
                        (!GroupingSituation.DoesGroupingSituationExistForFamily(Actor)))
                    {
                        bool selectable = false;

                        if (SimTypes.IsSelectable(Actor))
                        {
                            selectable = true;
                        }
                        else
                        {
                            foreach (Sim follower in new List <Sim>(mFollowers))
                            {
                                if (SimTypes.IsSelectable(follower))
                                {
                                    selectable = true;
                                    break;
                                }
                            }
                        }

                        // Stop the romantic prompt from appearing
                        GroupingSituation situation = Actor.GetSituationOfType <GroupingSituation>();
                        if (situation != null)
                        {
                            if (situation.Participants == null)
                            {
                                situation.Exit();
                            }

                            if (!selectable)
                            {
                                situation.RomanticGrouping = false;
                            }
                        }

                        GroupingSituation.StartGroupingSitatuationWithFollowers(Actor, mFollowers);
                    }
                    return(flag2);
                }

                if (((Actor.ExitReason & ExitReason.HigherPriorityNext) == ExitReason.None) && ((Actor.ExitReason & ExitReason.UserCanceled) == ExitReason.None))
                {
                    NumFail++;
                }
                return(flag2);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Example #14
0
        public override bool RunFromInventory()
        {
            if (this.mResearchStation == null)
            {
                IResearchStation[]      objects = Sims3.Gameplay.Queries.GetObjects <IResearchStation>(base.Actor.LotCurrent);
                List <IResearchStation> list    = base.Actor.LotCurrent.GetObjects <IResearchStation>(p => !p.Repairable.Broken);
                if (objects.Length < 1)
                {
                    base.Actor.AddExitReason(ExitReason.FailedToStart);
                    return(false);
                }
                if (list.Count < 1)
                {
                    base.Actor.AddExitReason(ExitReason.FailedToStart);
                    return(false);
                }
                this.mResearchStation = objects[0];
            }
            if (!base.Actor.RouteToSlotAndCheckInUse(this.mResearchStation, Slot.RoutingSlot_0))
            {
                return(false);
            }
            GameObject mResearchStation = this.mResearchStation as GameObject;

            if (mResearchStation != null)
            {
                mResearchStation.EnableFootprintAndPushSims(ScientificSample.kScienceStationFootprintHash, base.Actor);
            }
            this.mVialsToUse = new List <ScientificSample>();
            base.Target.SetGeometryState(ScientificSample.kGeoStateInUse);
            base.Target.CreateClonesForInteraction(this.mVialsToUse, base.Actor);
            base.StandardEntry();
            base.BeginCommodityUpdates();
            if (base.Actor.TraitManager.HasElement(TraitNames.AntiTV))
            {
                base.Actor.BuffManager.AddElementPaused(BuffNames.AntiTV, Origin.FromScienceEquipment);
            }
            base.EnterStateMachine("ScienceStation", "EnterScienceStation", "x");
            base.AddOneShotScriptEventHandler(0x65, new SacsEventHandler(this.OnPlaceTargetOnTray));
            base.AddOneShotScriptEventHandler(0x66, new SacsEventHandler(this.OnRemoveTargetOnTray));
            base.AddOneShotScriptEventHandler(0x6f, new SacsEventHandler(this.OnStartStationLaser));
            base.AddOneShotScriptEventHandler(0xde, new SacsEventHandler(this.OnStopStationLaser));
            base.AddOneShotScriptEventHandler(0x20c, new SacsEventHandler(this.OnCloneSpawn));
            base.SetActor("researchStation", this.mResearchStation);
            base.Actor.Inventory.TryToRemove(base.Target);
            base.AnimateSim("PerformExperiment");
            bool succeeded = this.DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached | ExitReason.Canceled), new InteractionInstance.InsideLoopFunction(this.LoopDel), base.mCurrentStateMachine);

            if (base.Target.ScientificSampleType == ScientificSample.SampleType.Dna)
            {
                // custom
                this.DetermineHumanOutcomeEx(succeeded);
            }
            else
            {
                this.DetermineObjectOutcome(succeeded);
            }
            base.EndCommodityUpdates(succeeded);
            base.StandardExit();
            if (this.mCloneSim != null)
            {
                if (this.mCloneSim.Household != base.Actor.Household)
                {
                    this.mCloneSim.SimDescription.FirstName = StringInputDialog.Show(Localization.LocalizeString("Gameplay/Objects/RabbitHoles/ScienceLab:NameCloneTitle", new object[0]), Localization.LocalizeString("Gameplay/Objects/RabbitHoles/ScienceLab:NameCloneDesc", new object[0]), string.Empty, CASBasics.GetMaxNameLength(), StringInputDialog.Validation.SimNameText);
                    CarryingChildPosture posture = base.Actor.Posture as CarryingChildPosture;
                    if (posture != null)
                    {
                        base.Actor.InteractionQueue.AddNext(PutDownChild.Singleton.CreateInstance(posture.Child, base.Actor, new InteractionPriority(InteractionPriorityLevel.High), base.Autonomous, false));
                    }
                    SocialWorkerChildAbuse.Instance.MakeServiceRequest(base.Actor.LotCurrent, true, this.mCloneSim.ObjectId, true);
                }
                else
                {
                    this.mCloneSim.SimDescription.FirstName = StringInputDialog.Show(Localization.LocalizeString("Gameplay/Objects/RabbitHoles/ScienceLab:NameCloneTitle", new object[0]), Localization.LocalizeString("Gameplay/Objects/RabbitHoles/ScienceLab:NameCloneDesc", new object[0]), string.Empty, CASBasics.GetMaxNameLength(), StringInputDialog.Validation.SimNameText);
                    ScientificSample.DnaSampleSubject subject = base.Target.Subject as ScientificSample.DnaSampleSubject;
                    if (subject != null)
                    {
                        this.mCloneSim.SimDescription.LastName = subject.Subject.LastName;
                    }
                    else
                    {
                        this.mCloneSim.SimDescription.LastName = base.Actor.LastName;
                    }
                }
                ChildUtils.FinishObjectInteractionWithChild(this, this.mCloneSim);
            }
            return(succeeded);
        }
Example #15
0
        public void DetermineHumanOutcomeEx(bool succeeded)
        {
            this.DeleteVialsInCentrifuge();
            ScientificSample.DnaSampleSubject subject = base.Target.Subject as ScientificSample.DnaSampleSubject;
            bool         flag    = false;
            ScienceSkill element = (ScienceSkill)base.Actor.SkillManager.GetElement(SkillNames.Science);

            if (succeeded)
            {
                bool flag3;
                bool flag2 = RandomUtil.RandomChance01(kSuccessChance);
                if (flag2)
                {
                    flag3 = RandomUtil.RandomChance01(kEpicSuccessChance);
                }
                else
                {
                    flag3 = RandomUtil.RandomChance01(kEpicFailureChance);
                }
                if (((subject == null) /*|| !base.Actor.Household.CanAddSpeciesToHousehold(CASAgeGenderFlags.None | CASAgeGenderFlags.Human)*/) || GameUtils.IsUniversityWorld())
                {
                    flag2 = false;
                    flag3 = true;
                }
                if (flag2)
                {
                    string name = string.Empty;
                    if (flag3)
                    {
                        this.CreateBaby();
                        SetupPerfectCloneChildTraits(this.mCloneSim.SimDescription, this.mCloneSim, subject.Subject);
                        name = "SimCloneEpicSuccess";
                    }
                    else
                    {
                        this.CreateBaby();
                        SetupCloneTraitsFromArray(this.mCloneSim.SimDescription, this.mCloneSim, subject.Subject, kGoodCloneTraitNames);
                        name = "SimCloneSuccess";
                    }
                    if (element != null)
                    {
                        element.AddObjectsCreated();
                    }
                    flag = true;
                    base.Actor.ShowTNSIfSelectable(LocalizeString(base.Actor.IsFemale, name, new object[] { base.Actor, subject.Subject }), StyledNotification.NotificationStyle.kGameMessagePositive);
                    EventTracker.SendEvent(new SimDescriptionTargetEvent(EventTypeId.kClonedSim, base.Actor, subject.Subject));
                }
                else if (flag3)
                {
                    if (this.mCloneSim != null)
                    {
                        this.mCloneSim.Destroy();
                        this.mCloneSim          = null;
                        this.mReplacementObject = null;
                    }
                    base.Actor.BuffManager.AddElement(BuffNames.MinorSetback, Origin.FromFailedExperiment);
                    BuffSinged.SingeViaInteraction(this, Origin.FromFailedExperiment);
                    base.AnimateSim("ExperimentRareEpicFail");
                    base.Actor.ShowTNSIfSelectable(LocalizeString(base.Actor.IsFemale, "SimCloneEpicFail", new object[] { base.Actor, subject.Subject }), StyledNotification.NotificationStyle.kGameMessageNegative);
                    if (element != null)
                    {
                        element.AddEpicFail();
                    }
                }
                else
                {
                    this.CreateBaby();
                    SetupCloneTraitsFromArray(this.mCloneSim.SimDescription, this.mCloneSim, subject.Subject, kBadCloneTraitNames);
                    flag = true;
                    VisualEffect.FireOneShotEffect("ep9ScienceCloneBaby_main", this.mResearchStation, unchecked ((Slot)(-1474234202)), VisualEffect.TransitionType.HardTransition);
                    base.Actor.ShowTNSIfSelectable(LocalizeString(base.Actor.IsFemale, "SimCloneFail", new object[] { base.Actor, subject.Subject }), StyledNotification.NotificationStyle.kGameMessageNegative);
                    EventTracker.SendEvent(new SimDescriptionTargetEvent(EventTypeId.kClonedSim, base.Actor, subject.Subject));
                    if (element != null)
                    {
                        element.AddObjectsCreated();
                    }
                }
            }
            else
            {
                if (this.mCloneSim != null)
                {
                    this.mCloneSim.Destroy();
                    this.mCloneSim          = null;
                    this.mReplacementObject = null;
                }
                base.Actor.BuffManager.AddElement(BuffNames.Mourning, unchecked ((Origin)(-8359806666160896151L)));
                BuffSinged.SingeViaInteraction(this, Origin.FromFailedExperiment);
                base.AnimateSim("ExperimentRareEpicFail");
                base.Actor.ShowTNSIfSelectable(LocalizeString(base.Actor.IsFemale, "SimCloneEpicFail", new object[] { base.Actor, subject.Subject }), StyledNotification.NotificationStyle.kGameMessageNegative);
                if (element != null)
                {
                    element.AddEpicFail();
                }
            }
            if (flag)
            {
                base.SetActorAndEnter("y", this.mCloneSim, "NewBabyCloneEnter");
                base.AnimateJoinSims("CloneBabySuccessExit");
                ChildUtils.CarryChild(base.Actor, this.mCloneSim, false);
                this.mReplacementObject = null;
                this.mCloneSim.EnableInteractions(InteractionsDisabledType.All);
            }
        }
Example #16
0
        public override bool Run()
        {
            try
            {
                Actor.GreetSimOnMyLotIfPossible(Target);
                if (GetCuddleType(Actor, Target) == CuddleType.CuddleTargetOnDifferentBed)
                {
                    ChildUtils.SetPosturePrecondition(this, CommodityKind.Relaxing, new CommodityKind[] { CommodityKind.NextToTarget });
                    Actor.InteractionQueue.PushAsContinuation(this, true);
                    return(true);
                }

                if (!SafeToSync())
                {
                    return(false);
                }

                // Custom
                mReactToSocialBroadcaster = new ReactionBroadcaster(Actor, Conversation.ReactToSocialParams, SocialComponentEx.ReactToJealousEventMedium);
                //SocialComponent.SendCheatingEvents(Actor, Target, !Rejected);

                StartBedCuddleB entry = StartBedCuddleB.Singleton.CreateInstance(Actor, Target, GetPriority(), false, CancellableByPlayer) as StartBedCuddleB;
                LinkedInteractionInstance = entry;
                Target.InteractionQueue.Add(entry);
                if (Target.Posture.Container != Actor.Posture.Container)
                {
                    Actor.LookAtManager.SetInteractionLookAt(Target, 0xc8, LookAtJointFilter.TorsoBones);
                    Actor.Posture.CurrentStateMachine.RequestState("x", "callOver");
                }

                Actor.SynchronizationLevel  = Sim.SyncLevel.Started;
                Actor.SynchronizationTarget = Target;
                Actor.SynchronizationRole   = Sim.SyncRole.Initiator;
                if (!Actor.WaitForSynchronizationLevelWithSim(Target, Sim.SyncLevel.Started, Bed.kTimeToWaitForOtherToArriveForCuddling))
                {
                    return(false);
                }

                Actor.Posture.CurrentStateMachine.RequestState("x", "ExitRelaxing");
                StartSocial("Cuddle");
                entry.Rejected             = Rejected;
                Actor.SynchronizationLevel = Sim.SyncLevel.Routed;
                if (!Actor.WaitForSynchronizationLevelWithSim(Target, Sim.SyncLevel.Routed, Bed.kTimeToWaitForOtherToArriveForCuddling))
                {
                    return(false);
                }

                if (Rejected)
                {
                    if (Actor.Posture.Container == Target.Posture.Container)
                    {
                        BedMultiPart container   = Actor.Posture.Container as BedMultiPart;
                        BedData      partSimIsIn = container.PartComp.GetPartSimIsIn(Actor);
                        EnterStateMachine("BedSocials", "FromRelax", "x", "y");
                        mCurrentStateMachine.EnterState("y", "FromRelax");
                        mCurrentStateMachine.EnterState("bed", "FromRelax");
                        SetActor("bed", container);
                        partSimIsIn.SetPartParameters(mCurrentStateMachine);
                        mCurrentStateMachine.RequestState(false, "x", "CuddleReject");
                        mCurrentStateMachine.RequestState(false, "bed", "CuddleReject");
                        mCurrentStateMachine.RequestState(true, "y", "CuddleReject");
                        mCurrentStateMachine.RequestState(null, "ToRelax");
                        Target.RouteAway(kMinDistanceToMoveAwayWhenRejected, kMaxDistanceToMoveAwayWhenRejected, true, new InteractionPriority(InteractionPriorityLevel.Zero), false, true, true, RouteDistancePreference.NoPreference);
                    }
                    else
                    {
                        Actor.Posture.CurrentStateMachine.RequestState(true, "x", "CallOverReject");
                    }
                    return(false);
                }

                if (!Actor.WaitForSynchronizationLevelWithSim(Target, Sim.SyncLevel.Completed, Bed.kTimeToWaitForOtherToArriveForCuddling))
                {
                    return(false);
                }

                InteractionPriority priority = new InteractionPriority(InteractionPriorityLevel.Zero);
                CuddleRelaxing      relaxing = CuddleRelaxing.Singleton.CreateInstance(Target, Actor, priority, false, CancellableByPlayer) as CuddleRelaxing;
                relaxing.IsMaster = true;
                relaxing.AdoptSocialEffect(this);
                CuddleRelaxing relaxing2 = CuddleRelaxing.Singleton.CreateInstance(Actor, Target, priority, false, CancellableByPlayer) as CuddleRelaxing;
                relaxing2.IsMaster = false;
                relaxing.LinkedInteractionInstance = relaxing2;
                EventTracker.SendEvent(new SocialEvent(EventTypeId.kSocialInteraction, Actor, Target, "Cuddle", false, !Rejected, false, CommodityTypes.Undefined));
                EventTracker.SendEvent(new SocialEvent(EventTypeId.kSocialInteraction, Target, Actor, "Cuddle", true, !Rejected, false, CommodityTypes.Undefined));
                Actor.InteractionQueue.Add(relaxing);
                Target.InteractionQueue.Add(relaxing2);
                return(!Rejected);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }