Exemplo n.º 1
0
        public override bool Run()
        {
            try
            {
                if (AskToBehaveEx.SatisfiesLikingGate(Actor, Target))
                {
                    VisitSituation situation = Target.GetSituationOfType <VisitSituation>();
                    if (situation != null)
                    {
                        VisitSituation.TimeForGuestToLeave child = situation.Child as VisitSituation.TimeForGuestToLeave;
                        if (child != null)
                        {
                            situation.SetState(new VisitSituation.Socializing(situation));
                        }
                    }

                    return(true);
                }
                else
                {
                    return(base.Run());
                }
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Exemplo n.º 2
0
        public override bool Run()
        {
            try
            {
                if (SatisfiesLikingGate(Actor, Target))
                {
                    VisitSituation situation = Target.GetSituationOfType <VisitSituation>();
                    if (situation != null)
                    {
                        VisitSituation.GuestBehavingInappropriately child = situation.Child as VisitSituation.GuestBehavingInappropriately;
                        if (child != null)
                        {
                            child.mOnlyOneHostResponds = Actor;

                            situation.SetState(new VisitSituation.Socializing(situation));
                        }
                    }

                    return(true);
                }
                else
                {
                    return(base.Run());
                }
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Exemplo n.º 3
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            if (mPush)
            {
                Sim createdSim = Job.OwnerDescription.CreatedSim;
                if (createdSim != null)
                {
                    if ((SimTypes.IsSelectable(Job.OwnerDescription)) || (!NpcParty.IsHostAtNpcParty(createdSim)))
                    {
                        foreach (InteractionInstance instance in createdSim.InteractionQueue.InteractionList)
                        {
                            if (instance is ICountsAsWorking)
                            {
                                IncStat("Already Queued");
                                return(false);
                            }
                        }

                        VisitSituation.AnnounceTimeToGoToWork(createdSim);
                        createdSim.InteractionQueue.Add(CareerPushScenario.GetWorkInteraction(Job));
                    }
                }

                if (GetValue <AllowGoHomePushOption, bool>(Sim))
                {
                    Manager.AddAlarm(new GoHomePushScenario(Sim));
                }
            }
            return(true);
        }
Exemplo n.º 4
0
 private bool TooLate()
 {
     if (!VisitSituation.IsTooLateToVisit())
     {
         return(false);
     }
     return(true);
 }
        // Methods
        public override bool Run()
        {
            Debugger debugger = HomeBartender.debugger;

            debugger.Debug(base.Actor, "Trying to activate role");
            try
            {
                Role assignedRole = base.Actor.SimDescription.AssignedRole;
                if ((assignedRole != null) && assignedRole.IsActive)
                {
                    debugger.Debug(base.Actor, "Role is active");
                    Lot        target           = null;
                    GameObject roleGivingObject = assignedRole.RoleGivingObject as GameObject;
                    if (roleGivingObject != null)
                    {
                        target = roleGivingObject.LotCurrent;
                    }

                    if (target != null)
                    {
                        debugger.Debug(base.Actor, "Lot is found");
                        InteractionInstance instance = null;
                        if (target.IsCommunityLot)
                        {
                            instance = VisitCommunityLot.Singleton
                                       .CreateInstance(target, base.Actor, base.GetPriority(), false, false);
                            debugger.Debug(base.Actor, "going to community");
                        }
                        else
                        {
                            instance = GoToLot.Singleton
                                       .CreateInstance(target, base.Actor, base.GetPriority(), false, false);
                            // Greet to get inside, visitsituation to really do something inside
                            debugger.Debug(base.Actor, "going to residential");
                            if (VisitSituation.FindVisitSituationInvolvingGuest(base.Actor) == null)
                            {
                                VisitSituation.Create(base.Actor, target);
                            }
                            base.Actor.GreetSimOnLot(target);
                        }
                        debugger.Debug(base.Actor, "instance created");
                        if (base.TryPushAsContinuation(instance))
                        {
                            assignedRole.UpdateFulfillingLot(target.LotId);
                            debugger.Debug(base.Actor, "Sim is coming! " + Actor.FullName);
                            return(true);
                        }
                    }
                    assignedRole.UpdateFulfillingLot(0L);
                }
            }
            catch (Exception ex)
            {
                debugger.DebugError(base.Actor, "Cannot take role sims to role lot", ex);
            }
            return(false);
        }
Exemplo n.º 6
0
        public override bool Run()
        {
            try
            {
                if (Target.Parent != null)
                {
                    Target.UnParent();
                }

                Household household = Target.LotCurrent.Household;

                Target.FadeOut(true);
                Target.RemoveFromUseList(base.Actor);
                Target.RemoveFromWorld();

                if (Actor.Inventory.CanAdd(Target))
                {
                    Actor.Inventory.TryToAdd(Target, false);
                }
                else
                {
                    Actor.Household.SharedFamilyInventory.Inventory.TryToAdd(Target, false);

                    Common.Notify(Common.Localize("Swipe:FamilyInventory", Actor.IsFemale, new object[] { Actor, Target }));
                }

                if ((household != null) && (household.Sims.Count > 0x0))
                {
                    TraitFunctions.ItemStolenCallback(household, Origin.FromTheft);
                    Target.SetStealActors(Actor, RandomUtil.GetRandomObjectFromList <Sim>(household.Sims));
                }
                else
                {
                    Target.SetStealActors(Actor, null);
                }

                foreach (Situation situation in Actor.Autonomy.SituationComponent.Situations)
                {
                    VisitSituation situation2 = situation as VisitSituation;
                    if (situation2 != null)
                    {
                        situation2.GuestStartingInappropriateAction(base.Actor, TraitTuning.KleptomaniacStealingInnapropriateness);
                    }
                }

                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Exemplo n.º 7
0
        public virtual void OnGuestHasArrived(Sim sim)
        {
            if (!SomeGuestsHaveArrived)
            {
                EventTracker.SendEvent(new PartyEvent(EventTypeId.kPartyBegan, Host, Host.SimDescription, this));
            }
            SomeGuestsHaveArrived = true;

            StoryProgression.Main.Situations.GreetSimOnLot(sim.SimDescription, Lot);

            VisitSituation.SetVisitToGreeted(sim);
        }
        private void LetSimIn(Sim s)
        {
            VisitSituation visitSituation = VisitSituation.FindVisitSituationInvolvingGuest(s);

            if (visitSituation != null)
            {
                VisitSituation.SetVisitToGreeted(s);
                VisitSituation.OnInvitedIn(s);
                visitSituation.AllowedToStayOver = true;
                visitSituation.SetStateSocializing();
            }
        }
Exemplo n.º 9
0
        private void CheckIfGuestsNeedToGoHome()
        {
            List <Sim> simsToGoHome = new List <Sim>();

            foreach (Sim sim in Guests)
            {
                bool flag = VisitSituation.IsGuestAllowedToStayOver(sim);
                if (sim.MoodManager.IsInStrongNegativeMood || (!flag && (sim.BuffManager.HasElement(BuffNames.Tired) || sim.BuffManager.HasElement(BuffNames.Exhausted))))
                {
                    AddSimToGoHome(sim, simsToGoHome);
                }

                if (sim.SimDescription.ChildOrBelow && (SimClock.Hours24 >= GetParams().HourAtWhichChildrenGoHome))
                {
                    AddSimToGoHome(sim, simsToGoHome);
                    foreach (Genealogy genealogy in sim.Genealogy.Parents)
                    {
                        SimDescription simDescription = genealogy.SimDescription;
                        if (simDescription != null)
                        {
                            Sim createdSim = simDescription.CreatedSim;
                            if ((createdSim != null) && Guests.Contains(createdSim))
                            {
                                AddSimToGoHome(createdSim, simsToGoHome);
                            }
                        }
                    }
                }

                float       delta = sim.MoodManager.MoodValue * GetParams().MoodToTimeMod;
                DateAndTime time;
                if (!flag && mTimeForSimToLeave.TryGetValue(sim.ObjectId, out time))
                {
                    time = SimClock.Add(time, TimeUnit.Minutes, delta);
                    if (time.CompareTo(SimClock.CurrentTime()) < 0x0)
                    {
                        AddSimToGoHome(sim, simsToGoHome);
                    }
                    else
                    {
                        mTimeForSimToLeave[sim.ObjectId] = time;
                    }
                }
            }
            foreach (Sim sim3 in simsToGoHome)
            {
                if (sim3.LotCurrent == Lot)
                {
                    MakeGuestGoHome(sim3);
                }
            }
        }
Exemplo n.º 10
0
        // Methods
        public override bool Run()
        {
            try
            {
                Role assignedRole = base.Actor.SimDescription.AssignedRole;
                if ((assignedRole != null) && assignedRole.IsActive)
                {
                    Lot             target = null;
                    DrunkardsBottle bottle = assignedRole.RoleGivingObject as DrunkardsBottle;
                    if (bottle != null)
                    {
                        target = bottle.GetTargetLot();
                    }

                    if (target != null)
                    {
                        InteractionInstance instance = null;
                        if (target.IsCommunityLot)
                        {
                            instance = VisitCommunityLot.Singleton
                                       .CreateInstance(target, base.Actor, base.GetPriority(), false, false);
                        }
                        else
                        {
                            instance = GoToLot.Singleton
                                       .CreateInstance(target, base.Actor, base.GetPriority(), false, false);
                            // Greet to get inside, visitsituation to really do something inside

                            if (VisitSituation.FindVisitSituationInvolvingGuest(base.Actor) == null)
                            {
                                VisitSituation.Create(base.Actor, target);
                            }
                            base.Actor.GreetSimOnLot(target);
                        }

                        if (base.TryPushAsContinuation(instance))
                        {
                            assignedRole.UpdateFulfillingLot(target.LotId);
                            return(true);
                        }
                    }
                    assignedRole.UpdateFulfillingLot(0L);
                }
            }
            catch (Exception ex)
            {
                Message.Sender.ShowError(base.Actor, "Cannot take role sims to role lot", false, ex);
            }
            return(false);
        }
Exemplo n.º 11
0
        public static bool AdoptFrankenSim(Sim creator, Sim frankenSim)
        {
            //if (creator.Household.CanAddSpeciesToHousehold(CASAgeGenderFlags.Human))
            {
                string         str   = "AdoptFrankenSim";
                InventingSkill skill = creator.SkillManager.GetSkill <InventingSkill>(SkillNames.Inventing);
                if ((skill != null) && skill.OppKnowFrankensimRecipeCompleted)
                {
                    str = "AdoptFrankenSimAgain";
                }

                SimDescription simDescription = frankenSim.SimDescription;
                if (TwoButtonDialog.Show(Localization.LocalizeString("Gameplay/Objects/HobbiesSkills/Inventing/InventionWorkbench:" + str, new object[] { creator }), Localization.LocalizeString("Gameplay/Objects/HobbiesSkills/Inventing/InventionWorkbench:AdoptFrankenSimYes", new object[0x0]), Localization.LocalizeString("Gameplay/Objects/HobbiesSkills/Inventing/InventionWorkbench:AdoptFrankenSimNo", new object[0x0])))
                {
                    VisitSituation situation = VisitSituation.FindVisitSituationInvolvingGuest(frankenSim);
                    if (situation != null)
                    {
                        situation.Exit();
                    }

                    Household.NpcHousehold.Remove(simDescription);
                    creator.Household.Add(simDescription);
                    string str2 = StringInputDialog.Show(Localization.LocalizeString("Gameplay/Objects/HobbiesSkills/Inventing/InventionWorkbench:AdoptFrankenSimNameTitle", new object[0x0]), Localization.LocalizeString("Gameplay/Objects/HobbiesSkills/Inventing/InventionWorkbench:AdoptFrankenSimNamePrompt", new object[] { creator }), frankenSim.FirstName);
                    if (!string.IsNullOrEmpty(str2))
                    {
                        simDescription.FirstName = str2;
                    }

                    frankenSim.OnBecameSelectable();
                    return(true);
                }

                Household.NpcHousehold.Remove(simDescription);
                Household household = Household.Create();
                household.Name = simDescription.LastName;
                household.Add(simDescription);
                household.FindSuitableVirtualHome();
                creator.ShowTNSIfSelectable(Localization.LocalizeString("Gameplay/Objects/HobbiesSkills/Inventing/InventionWorkbench:SimBotNotAdopted", new object[] { creator }), StyledNotification.NotificationStyle.kGameMessagePositive, frankenSim.ObjectId);
                Sim.MakeSimGoHome(frankenSim, false);
                return(false);
            }

            /*
             * string message = Localization.LocalizeString("Gameplay/Objects/HobbiesSkills/Inventing/InventionWorkbench:AdoptFrankenFullHousehold", new object[] { creator });
             * creator.ShowTNSIfSelectable(message, StyledNotification.NotificationStyle.kGameMessageNegative);
             * Sim.MakeSimGoHome(frankenSim, false);
             * return false;
             */
        }
Exemplo n.º 12
0
        // Methods
        public override bool Run()
        {
            try
            {
                Role assignedRole = base.Actor.SimDescription.AssignedRole;
                if ((assignedRole != null) && assignedRole.IsActive)
                {
                    Lot        target           = null;
                    GameObject roleGivingObject = assignedRole.RoleGivingObject as GameObject;
                    if (roleGivingObject != null)
                    {
                        target = roleGivingObject.LotCurrent;
                    }

                    if (target != null)
                    {
                        InteractionInstance instance = null;
                        if (target.IsCommunityLot)
                        {
                            instance = VisitCommunityLot.Singleton
                                       .CreateInstance(target, base.Actor, base.GetPriority(), false, false);
                        }
                        else
                        {
                            instance = GoToLot.Singleton
                                       .CreateInstance(target, base.Actor, base.GetPriority(), false, false);
                            // Greet to get inside, visitsituation to really do something inside

                            if (VisitSituation.FindVisitSituationInvolvingGuest(base.Actor) == null)
                            {
                                VisitSituation.Create(base.Actor, target);
                            }
                            base.Actor.GreetSimOnLot(target);
                        }
                        if (base.TryPushAsContinuation(instance))
                        {
                            assignedRole.UpdateFulfillingLot(target.LotId);
                            return(true);
                        }
                    }
                    assignedRole.UpdateFulfillingLot(0L);
                }
            }
            catch (Exception ex)
            {
            }
            return(false);
        }
Exemplo n.º 13
0
        public static bool PreRouteNearEntranceAndIntoBuilding(GoToSchoolInRabbitHole ths, bool canUseCar, Route.RouteMetaType routeMetaType, OnChangeOutfit changedOutfitFunc)
        {
            try
            {
                // From GoToSchoolInRabbitHole

                GoToSchoolInRabbitHole.Definition interactionDefinition = ths.InteractionDefinition as GoToSchoolInRabbitHole.Definition;
                if ((interactionDefinition != null) && (interactionDefinition.PlayerChosenVehicle != null))
                {
                    ths.Actor.SetReservedVehicle(interactionDefinition.PlayerChosenVehicle);
                }

                bool success = false;

                School school = ths.Actor.School;
                if (school != null)
                {
                    SimOutfit outfit;
                    if (school.TryGetUniformForCurrentLevel(out outfit))
                    {
                        if (ApplyOccupationUniform(ths.Actor.SimDescription, outfit))
                        {
                            success = true;
                        }
                    }
                }

                if ((!success) && (changedOutfitFunc != null))
                {
                    changedOutfitFunc();
                }

                VisitSituation.OnSimLeavingLot(ths.Actor);

                // From RabbitHoleInteraction<TActor, TRabbitHole>
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(ths.Actor, ths.Target, e);
                return(false);
            }
        }
Exemplo n.º 14
0
            public void Cleanup()
            {
                if (this.mProfessional != 0)
                {
                    SimDescription desc = SimDescription.Find(this.mProfessional);
                    if (desc != null && desc.CreatedSim != null)
                    {
                        VisitSituation.MakeSimExitToYard(desc.CreatedSim.LotCurrent, desc.CreatedSim);
                        Sim.MakeSimGoHome(desc.CreatedSim, false, new InteractionPriority(InteractionPriorityLevel.UserDirected));
                    }
                }

                if (this.mRequester != 0)
                {
                    KamaSimtra.Settings.sRequests.Remove(this.mRequester);
                }
            }
Exemplo n.º 15
0
        public static IEnumerable <InteractionObjectPair> GetAllInteractionsForSim(SocialComponent ths, Sim actor, bool isAutonomous)
        {
            if ((ths.mSim.IsPerformingAService && !VisitSituation.IsSocializing(ths.mSim)) && !(ths.mSim.Service is Butler))
            {
                sMsg += Common.NewLine + "Service";

                return(ths.GetAllServiceInteractions(actor));
            }
            List <InteractionObjectPair> list = new List <InteractionObjectPair>();

            if (isAutonomous)
            {
                sMsg += Common.NewLine + "Autonomous";

                list.AddRange(ths.GetAllInteractionsForAutonomy(actor));
                return(list);
            }
            if ((ths.mSim.Posture is ISeatedSocialPosture) && (actor.Posture is ISeatedSocialPosture))
            {
                Relationship relationship = Relationship.Get(ths.mSim, actor, false);
                if ((relationship == null) || (relationship.LTR.CurrentLTR == LongTermRelationshipTypes.Stranger))
                {
                    sMsg += Common.NewLine + "New Conversation";

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

                    list.AddRange(ths.SocialsForGreeting(actor, ths.mSim));
                    return(list);
                }

                sMsg += Common.NewLine + "Empty";

                return(new List <InteractionObjectPair>());
            }

            sMsg += Common.NewLine + "PieMenu";

            list.AddRange(GetAllInteractionsForPieMenu(ths, actor));
            return(list);
        }
Exemplo n.º 16
0
            protected bool OnAddInteractionToGoOutside(StackTrace trace, StackFrame frame)
            {
                mFail   = true;
                mIgnore = true;

                if (mActor != null)
                {
                    VisitSituation visit = mActor.GetSituationOfType <VisitSituation>();
                    if (visit != null)
                    {
                        VisitSituation.GuestLeftAlone child = visit.Child as VisitSituation.GuestLeftAlone;
                        if (child != null)
                        {
                            AlarmManager.Global.RemoveAlarm(child.mRemindGuestToGoOutside);
                            child.mRemindGuestToGoOutside = AlarmHandle.kInvalidHandle;
                        }
                    }
                }

                return(true);
            }
Exemplo n.º 17
0
            protected override void OnPerform()
            {
                mScenario.IncStat("PopulatePartyTask");

                mParty.mPlaceNpcGuestsFunction = null;
                mParty.SomeGuestsHaveArrived   = true;

                Lot lotHome = mParty.Host.LotHome;

                GatheringScenario.PushBuffetInteractions(mScenario, mParty.Host.SimDescription, lotHome);

                List <Sim> sims = new List <Sim>(HouseholdsEx.AllSims(lotHome.Household));

                SimDescription host = mParty.Host.SimDescription;

                foreach (SimDescription sim in mParty.GuestDescriptions)
                {
                    if (!NpcParty.NpcGuestTest(sim, host))
                    {
                        continue;
                    }

                    if (!mScenario.Situations.Allow(mScenario, sim))
                    {
                        mScenario.IncStat("NpcParty Push User Denied");
                        continue;
                    }

                    Sim createdSim = sim.CreatedSim;
                    if (createdSim == null)
                    {
                        createdSim = Instantiation.PerformOffLot(sim, lotHome, null);
                    }

                    if (createdSim != null)
                    {
                        if (createdSim.LotCurrent != lotHome)
                        {
                            if (!mScenario.Situations.PushVisit(mScenario, sim, lotHome))
                            {
                                mScenario.IncStat("NpcParty Push Fail");
                                continue;
                            }
                        }

                        mParty.Guests.Add(createdSim);
                        createdSim.AssignRole(mParty);

                        VisitSituation.SetVisitToGreeted(createdSim);

                        sims.Add(createdSim);
                    }
                }

                foreach (Sim sim in sims)
                {
                    if (sim.LotCurrent == lotHome)
                    {
                        sim.Motives.SetMax(CommodityKind.Energy);
                        sim.Motives.SetMax(CommodityKind.Hygiene);

                        sim.PushSwitchToOutfitInteraction(Sims3.Gameplay.Actors.Sim.ClothesChangeReason.Force, mParty.ClothingStyle);
                    }
                }

                EventTracker.SendEvent(new PartyEvent(EventTypeId.kPartyBegan, mParty.Host, host, mParty));

                mParty.SetState(new NpcParty.Happening(mParty));
            }
Exemplo n.º 18
0
        public override bool Run()
        {
            try
            {
                IWooHooDefinition definition = InteractionDefinition as IWooHooDefinition;

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

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

                AllInOneBathroom.WoohooInAllInOneBathroomB entry = AllInOneBathroom.WoohooInAllInOneBathroomB.Singleton.CreateInstance(Actor, Target, GetPriority(), Autonomous, CancellableByPlayer) as AllInOneBathroom.WoohooInAllInOneBathroomB;
                entry.TryForBaby = TryForBaby;
                entry.LinkedInteractionInstance = this;
                Target.InteractionQueue.Add(entry);
                Actor.SynchronizationLevel  = Sim.SyncLevel.Started;
                Actor.SynchronizationTarget = Target;
                Actor.SynchronizationRole   = Sim.SyncRole.Initiator;
                if (!WoohooObject.SimLine.WaitForTurn(this, SimQueue.WaitBehavior.Default, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), 10f))
                {
                    return(false);
                }

                if (!Actor.RouteToSlotAndCheckInUse(WoohooObject, Slot.RoutingSlot_1))
                {
                    return(false);
                }

                StandardEntry();
                WoohooObject.AddToUseList(Actor);
                WoohooObject.AddToUseList(Target);
                BeginCommodityUpdates();

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

                EnterStateMachine("AllInOneBathroom", "Enter", "x");
                SetActor("bathroom", WoohooObject);
                SetActor("y", Target);
                AddOneShotScriptEventHandler(0x64, AnimationCallback);
                AddOneShotScriptEventHandler(0x65, AnimationCallback);
                RockGemMetalBase.HandleNearbyWoohoo(Actor, RockGemMetalBase.HowMuchWooHoo.MoreWoohoo);

                if (mReactToSocialBroadcasterActor == null)
                {
                    mReactToSocialBroadcasterActor = new ReactionBroadcaster(Actor, Conversation.ReactToSocialParams, SocialComponentEx.ReactToJealousEventHigh);
                }

                if (mReactToSocialBroadcasterTarget == null)
                {
                    mReactToSocialBroadcasterTarget = new ReactionBroadcaster(Target, Conversation.ReactToSocialParams, SocialComponentEx.ReactToJealousEventHigh);
                }

                Animate("x", "WooHoo");

                List <Sim> exceptions = new List <Sim>();
                exceptions.Add(Target);
                WoohooObject.PushSimsFromFootprint(0x31229a4d, Actor, exceptions, true);
                WoohooObject.PushSimsFromFootprint(0x31229a4e, Actor, exceptions, true);
                Animate("x", "Exit");

                RockGemMetalBase.HandleNearbyWoohoo(Actor, RockGemMetalBase.HowMuchWooHoo.LessWoohoo);

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

                if (CommonPregnancy.IsSuccess(Actor, Target, Autonomous, definition.GetStyle(this)))
                {
                    Pregnancy pregnancy = CommonPregnancy.Impregnate(Actor, Target, Autonomous, definition.GetStyle(this));
                    if (pregnancy != null)
                    {
                        if (RandomUtil.RandomChance(AllInOneBathroom.kChanceOfHydrophobicTrait))
                        {
                            pregnancy.SetForcedBabyTrait(TraitNames.Hydrophobic);
                        }
                    }
                }

                WoohooObject.RemoveFromUseList(Actor);
                WoohooObject.RemoveFromUseList(Target);
                WoohooObject.SimLine.RemoveFromQueue(Actor);
                EndCommodityUpdates(true);
                StandardExit();

                EventTracker.SendEvent(EventTypeId.kWooHooInAllInOneBathroom, Actor, Target);

                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);
                }

                Relationship.Get(Actor, Target, true).LTR.UpdateLiking(AllInOneBathroom.kLTRGainFromWoohooInAllInOneBathroom);
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception exception)
            {
                Common.Exception(Actor, Target, exception);
                return(false);
            }
        }
Exemplo n.º 19
0
        protected bool Test(Sim sim, List <InteractionDefinition> interactions)
        {
            if (InteractionsEx.HasInteraction <ICountsAsWorking>(sim))
            {
                IncStat("At Work");
                return(false);
            }
            else if (Situations.HasInteraction(sim, interactions, true))
            {
                IncStat("At Work");
                return(false);
            }
            else
            {
                if (Situations.DebuggingLevel >= Common.DebugLevel.High)
                {
                    if (sim.InteractionQueue == null)
                    {
                        IncStat("Interaction Queue = null");
                    }
                    else
                    {
                        if (sim.InteractionQueue.Count == 0)
                        {
                            IncStat("Interaction Queue empty");
                        }
                        else
                        {
                            foreach (InteractionInstance instance2 in sim.InteractionQueue.InteractionList)
                            {
                                IncStat("Interaction: " + instance2.ToString());
                            }
                        }
                    }
                }

                VisitSituation.AnnounceTimeToGoToWork(sim);

                if (SimTypes.IsSpecial(Sim))
                {
                    IncStat("Special Pushed to Work");
                }
                else
                {
                    IncStat("Pushed to Work");
                }

                try
                {
                    // Don't queue stomp on their birthday
                    if (sim.SimDescription.YearsSinceLastAgeTransition != 0)
                    {
                        sim.InteractionQueue.CancelAllInteractions();

                        IncStat("Queue Stomped");

                        if ((!SimTypes.IsSelectable(sim.SimDescription)) && (sim.LotCurrent != null) && (sim.LotCurrent.CanSimTreatAsHome(sim)))
                        {
                            Callbox callbox = sim.LotHome.FindCallbox();
                            if (callbox != null)
                            {
                                Vector3 fwd = Vector3.Invalid;
                                Vector3 pos = Vector3.Invalid;

                                World.FindGoodLocationParams fglParams = new World.FindGoodLocationParams(callbox.Position);
                                fglParams.BooleanConstraints = FindGoodLocationBooleans.Routable | FindGoodLocationBooleans.PreferEmptyTiles;
                                if (GlobalFunctions.FindGoodLocation(sim, fglParams, out pos, out fwd))
                                {
                                    sim.ResetBindPoseWithRotation();
                                    sim.SetPosition(pos);
                                    sim.SetForward(fwd);
                                    sim.RemoveFromWorld();
                                    sim.AddToWorld();
                                    sim.SetHiddenFlags(HiddenFlags.Nothing);
                                    sim.SetOpacity(1f, 0f);

                                    IncStat("Bounce to Mailbox");
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Common.DebugException(sim, e);

                    IncStat("Cancel Fail");
                }

                sim.InteractionQueue.RemoveGoHomeInteractions(true);

                return(true);
            }
        }
Exemplo n.º 20
0
        public override bool Run()
        {
            try
            {
                IWooHooDefinition definition = InteractionDefinition as IWooHooDefinition;

                if ((mGypsyCaravan == null) || (mOtherWooHoo == null))
                {
                    return(false);
                }
                if (!mGypsyCaravan.SimLine.WaitForTurn(this, SimQueue.WaitBehavior.Default, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), 10f))
                {
                    return(false);
                }

                mGypsyCaravan.SimLine.RemoveFromQueue(Actor);
                if (!mGypsyCaravan.RouteNearEntranceAndEnterRabbitHole(Actor, null, null, false, Route.RouteMetaType.GoRabbitHole, true))
                {
                    return(false);
                }

                StandardEntry();
                BeginCommodityUpdates();
                EnterStateMachine("GypsyCaravanWoohoo", "WoohooEnter", "y");
                SetActor("caravan", mGypsyCaravan);
                AddPersistentScriptEventHandler(0x65, HideSim);
                AddOneShotScriptEventHandler(0x66, ShowX);
                AddOneShotScriptEventHandler(0x67, ShowY);
                Animate("y", "GetInY");
                mIsInCaravan = true;

                while (!mOtherWooHoo.mIsInCaravan)
                {
                    if ((Target.InteractionQueue.GetCurrentInteraction() != mOtherWooHoo) || Target.HasExitReason(ExitReason.Canceled))
                    {
                        Actor.SetOpacity(1f, 0f);
                        Animate("y", "WoohooExit");
                        mCurrentStateMachine.RemoveEventHandler(HideSim);
                        mCurrentStateMachine.RemoveEventHandler(ShowX);
                        mCurrentStateMachine.RemoveEventHandler(ShowY);
                        mGypsyCaravan.RemoveFromUseList(Actor);
                        EndCommodityUpdates(false);
                        StandardExit();
                        return(false);
                    }
                    SpeedTrap.Sleep(0xa);
                }

                mGypsyCaravan.TurnOnWooHooEffect();
                AnimateJoinSims("WooHoo");
                CommonWoohoo.RunPostWoohoo(Actor, Target, mGypsyCaravan, definition.GetStyle(this), definition.GetLocation(mGypsyCaravan), true);

                if (RandomUtil.RandomChance(GypsyCaravan.kFortuneToldSleepWear))
                {
                    if (Woohooer.Settings.mNakedOutfitGypsyCaravan)
                    {
                        if (!Actor.OccultManager.DisallowClothesChange())
                        {
                            Actor.SwitchToOutfitWithoutSpin(OutfitCategories.Naked);
                        }

                        if (!Target.OccultManager.DisallowClothesChange())
                        {
                            Target.SwitchToOutfitWithoutSpin(OutfitCategories.Naked);
                        }
                    }
                    else
                    {
                        if (!Actor.OccultManager.DisallowClothesChange())
                        {
                            Actor.SwitchToOutfitWithoutSpin(OutfitCategories.Sleepwear);
                        }

                        if (!Target.OccultManager.DisallowClothesChange())
                        {
                            Target.SwitchToOutfitWithoutSpin(OutfitCategories.Sleepwear);
                        }
                    }
                }
                else if (RandomUtil.RandomChance(GypsyCaravan.kFortuneToldSinged))
                {
                    if (!Actor.OccultManager.DisallowClothesChange())
                    {
                        Actor.SwitchToOutfitWithoutSpin(OutfitCategories.Singed);
                    }

                    if (!Target.OccultManager.DisallowClothesChange())
                    {
                        Target.SwitchToOutfitWithoutSpin(OutfitCategories.Singed);
                    }
                }

                mCurrentStateMachine.RemoveEventHandler(HideSim);
                mGypsyCaravan.TurnOffWooHooEffect();
                mGypsyCaravan.ExitRabbitHoleAndRouteAway(Actor);

                if (CommonPregnancy.IsSuccess(Actor, Target, Autonomous, definition.GetStyle(this)))
                {
                    CommonPregnancy.Impregnate(Actor, Target, Autonomous, definition.GetStyle(this));
                }

                VisitSituation situation  = VisitSituation.FindVisitSituationInvolvingGuest(Actor);
                VisitSituation situation2 = VisitSituation.FindVisitSituationInvolvingGuest(Target);
                if ((situation != null) && (situation2 != null))
                {
                    situation.GuestStartingInappropriateAction(Actor, GypsyCaravan.kAppropriatenessPenalty);
                    situation2.GuestStartingInappropriateAction(Target, GypsyCaravan.kAppropriatenessPenalty);
                }

                EventTracker.SendEvent(EventTypeId.kWooHooedInTheVardo, Actor, mOtherWooHoo.Actor);

                mIsInCaravan = false;
                EndCommodityUpdates(true);
                StandardExit();
                mCurrentStateMachine.RemoveEventHandler(ShowX);
                mCurrentStateMachine.RemoveEventHandler(ShowY);
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception exception)
            {
                Common.Exception(Actor, Target, exception);
                return(false);
            }
        }
Exemplo n.º 21
0
        public override bool Run()
        {
            try
            {
                int num;
                if ((WoohooObject == null) || !WoohooObject.CanWooHooIn())
                {
                    return(false);
                }
                if (!SafeToSync())
                {
                    return(false);
                }

                LeafPile.WoohooInPileOrStackB entry = LeafPile.WoohooInPileOrStackB.Singleton.CreateInstance(Actor, Target, GetPriority(), Autonomous, CancellableByPlayer) as LeafPile.WoohooInPileOrStackB;
                entry.LinkedInteractionInstance = this;
                if (!Target.InteractionQueue.Add(entry))
                {
                    Common.DebugNotify("LeafPileBaseWoohoo Add Fail");
                    return(false);
                }

                Actor.SynchronizationLevel  = Sim.SyncLevel.Started;
                Actor.SynchronizationTarget = Target;
                Actor.SynchronizationRole   = Sim.SyncRole.Initiator;
                if (!WoohooObject.SimLine.WaitForTurn(this, SimQueue.WaitBehavior.Default, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), 10f))
                {
                    return(false);
                }

                Slot[] routingSlots = WoohooObject.GetRoutingSlots();
                if (!Actor.RouteToSlotListAndCheckInUse(WoohooObject, routingSlots, out num))
                {
                    return(false);
                }

                if (!WoohooObject.CanWooHooIn())
                {
                    return(false);
                }

                CommonWoohoo.TestNakedOutfit(UsingNakedOutfit, Actor, Target);

                mActorXRoutingSlot = routingSlots[num];
                StandardEntry();
                WoohooObject.AddToUseList(Actor);
                WoohooObject.AddToUseList(Target);
                BeginCommodityUpdates();
                EnterStateMachine(WoohooObject.JazzFileName, "Enter", "x");
                AddOneShotScriptEventHandler(0x65, PlayEffectsHandlerX);
                AddOneShotScriptEventHandler(0x78, AnimCallbackSimX);
                SetActor(WoohooObject.JazzObjectName, WoohooObject);
                Animate("x", "GetInStackX");
                WoohooObject.SimLine.RemoveFromQueue(Actor);
                if (!Actor.WaitForSynchronizationLevelWithSim(Target, Sim.SyncLevel.Routed, 30f))
                {
                    AddOneShotScriptEventHandler(0x65, PlayEffectsHandlerX);
                    AddOneShotScriptEventHandler(0x66, PlayEffectsHandlerX);
                    AddOneShotScriptEventHandler(0x6e, AnimCallbackSimX);
                    AddOneShotScriptEventHandler(0x79, AnimCallbackSimX);
                    Animate("x", "GetOut");
                    Animate("x", "Exit");
                    WoohooObject.RemoveFromUseList(Actor);
                    WoohooObject.RemoveFromUseList(Target);
                    EndCommodityUpdates(false);
                    StandardExit();
                    return(false);
                }

                mActorYRoutingSlot = (Slot)(LinkedInteractionInstance as LeafPile.WoohooInPileOrStackB).RoutedSlot;

                RockGemMetalBase.HandleNearbyWoohoo(Actor, RockGemMetalBase.HowMuchWooHoo.MoreWoohoo);
                SetActor("y", Target);
                EnterState("y", "Enter");
                AddOneShotScriptEventHandler(0x65, PlayEffectsHandlerY);
                AddOneShotScriptEventHandler(0x78, AnimCallbackSimY);
                Animate("y", "GetInStackY");
                if (mReactToSocialBroadcasterActor == null)
                {
                    mReactToSocialBroadcasterActor = new ReactionBroadcaster(Actor, Conversation.ReactToSocialParams, SocialComponentEx.ReactToJealousEventHigh);
                    CommonWoohoo.CheckForWitnessedCheating(Actor, Target, true);
                }

                if (mReactToSocialBroadcasterTarget == null)
                {
                    mReactToSocialBroadcasterTarget = new ReactionBroadcaster(Target, Conversation.ReactToSocialParams, SocialComponentEx.ReactToJealousEventHigh);
                    CommonWoohoo.CheckForWitnessedCheating(Target, Actor, true);
                }

                AnimateJoinSims("Woohoo");
                (WoohooObject as GameObject).PushSimsFromFootprint((uint)mActorXRoutingSlot, Actor, null, true);
                AddOneShotScriptEventHandler(0x65, PlayEffectsHandlerX);
                AddOneShotScriptEventHandler(0x66, PlayEffectsHandlerX);
                AddOneShotScriptEventHandler(0x6e, AnimCallbackSimX);
                AddOneShotScriptEventHandler(0x79, AnimCallbackSimX);
                AnimateJoinSims("GetOutX");
                List <Sim> exceptions = new List <Sim>();
                exceptions.Add(Actor);
                (WoohooObject as GameObject).PushSimsFromFootprint((uint)mActorYRoutingSlot, Target, exceptions, true);
                if (mActorYRoutingSlot == mActorXRoutingSlot)
                {
                    Actor.Wander(1f, 2f, false, RouteDistancePreference.PreferFurthestFromRouteOrigin, true);
                }
                AddOneShotScriptEventHandler(0x65, PlayEffectsHandlerY);
                AddOneShotScriptEventHandler(0x66, PlayEffectsHandlerY);
                AddOneShotScriptEventHandler(0x6e, AnimCallbackSimY);
                AddOneShotScriptEventHandler(0x79, AnimCallbackSimY);
                AnimateJoinSims("GetOutY");
                AnimateJoinSims("Exit");
                RockGemMetalBase.HandleNearbyWoohoo(Actor, RockGemMetalBase.HowMuchWooHoo.LessWoohoo);

                IWooHooDefinition definition = InteractionDefinition as IWooHooDefinition;

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

                if (CommonPregnancy.IsSuccess(Actor, Target, Autonomous, definition.GetStyle(this)))
                {
                    Pregnancy pregnancy = CommonPregnancy.Impregnate(Actor, Target, Autonomous, definition.GetStyle(this));
                    if (pregnancy != null)
                    {
                        if (RandomUtil.RandomChance(WoohooObject.ChanceBabyGetsLovesOutdoorsTrait))
                        {
                            pregnancy.SetForcedBabyTrait(TraitNames.LovesTheOutdoors);
                        }
                    }
                }

                WoohooObject.RemoveFromUseList(Actor);
                WoohooObject.RemoveFromUseList(Target);
                EndCommodityUpdates(true);
                StandardExit();

                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 (RandomUtil.RandomChance(WoohooObject.ChanceGetRollInHayBuff))
                {
                    Actor.BuffManager.AddElement(BuffNames.RolledInTheHay, Origin.FromWooHooInHayStack);
                    Target.BuffManager.AddElement(BuffNames.RolledInTheHay, Origin.FromWooHooInHayStack);
                }

                Relationship.Get(Actor, Target, true).LTR.UpdateLiking(WoohooObject.LTRGain);
                EventTracker.SendEvent(WoohooObject.WooHooEventID, Actor, Target);
                EventTracker.SendEvent(WoohooObject.WooHooEventID, Target, Actor);
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception exception)
            {
                Common.Exception(Actor, Target, exception);
                return(false);
            }
        }
Exemplo n.º 22
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);
            }
Exemplo n.º 23
0
        public override bool Run()
        {
            try
            {
                IWooHooDefinition definition = InteractionDefinition as IWooHooDefinition;

                if ((mWardrobe == null) || (mOtherWooHoo == null))
                {
                    return(false);
                }

                if (!mWardrobe.SimLine.WaitForTurn(this, SimQueue.WaitBehavior.Default, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), 10f))
                {
                    return(false);
                }

                mWardrobe.SimLine.RemoveFromQueue(Actor);
                if (!Actor.RouteToSlotAndCheckInUse(mWardrobe, Slot.RoutingSlot_0))
                {
                    return(false);
                }

                OutfitCategories currentOutfitCategory = Actor.CurrentOutfitCategory;
                int currentOutfitIndex = Actor.CurrentOutfitIndex;
                StandardEntry();
                BeginCommodityUpdates();
                mWardrobe.AddToUseList(Actor);
                EnterStateMachine("wardrobewoohoo", "Enter", "y");
                SetActor("dresserWardrobe", mWardrobe);
                AddPersistentScriptEventHandler(0x65, HideSim);
                AddOneShotScriptEventHandler(0x66, ShowX);
                AddOneShotScriptEventHandler(0x67, ShowY);
                Animate("y", "GetInY");
                mIsInWardrobe = true;
                while (!mOtherWooHoo.mIsInWardrobe)
                {
                    if (Target.InteractionQueue.GetCurrentInteraction() != mOtherWooHoo)
                    {
                        Actor.SetOpacity(0f, 0f);
                        SpeedTrap.Sleep(0x1);
                        Actor.SetPosition(mWardrobe.GetPositionOfSlot(Slot.RoutingSlot_1));
                        Actor.SetForward(mWardrobe.GetForwardOfSlot(Slot.RoutingSlot_1));
                        Animate("y", "Exit");
                        mCurrentStateMachine.RemoveEventHandler(HideSim);
                        mCurrentStateMachine.RemoveEventHandler(ShowX);
                        mCurrentStateMachine.RemoveEventHandler(ShowY);
                        mWardrobe.RemoveFromUseList(Actor);
                        EndCommodityUpdates(false);
                        StandardExit();
                        return(false);
                    }
                    SpeedTrap.Sleep(0xa);
                }

                if (((Actor.OccultManager != null) && !Actor.OccultManager.DisallowClothesChange()) && !Actor.DoesSimHaveTransformationBuff())
                {
                    List <OutfitCategories> randomList = new List <OutfitCategories>(Wardrobe.kPossibleOutfitsAfterWooHoo);
                    randomList.Remove(Actor.CurrentOutfitCategory);

                    if (Woohooer.Settings.mNakedOutfitWardrobe)
                    {
                        randomList.Add(OutfitCategories.Naked);
                    }

                    Actor.SwitchToOutfitWithSpin(Sim.ClothesChangeReason.Force, RandomUtil.GetRandomObjectFromList(randomList));
                }

                AnimateJoinSims("WooHoo");
                mCurrentStateMachine.RemoveEventHandler(HideSim);
                Target.SetPosition(mWardrobe.GetPositionOfSlot(Slot.RoutingSlot_2));
                Target.SetForward(mWardrobe.GetForwardOfSlot(Slot.RoutingSlot_2));
                Actor.SetPosition(mWardrobe.GetPositionOfSlot(Slot.RoutingSlot_1));
                Actor.SetForward(mWardrobe.GetForwardOfSlot(Slot.RoutingSlot_1));
                mCurrentStateMachine.RequestState(false, "x", "GetOutX");
                mCurrentStateMachine.RequestState(true, "y", "GetOutX");
                mCurrentStateMachine.RequestState(false, "x", "GetOutY");
                mCurrentStateMachine.RequestState(true, "y", "GetOutY");

                if (CommonPregnancy.IsSuccess(Actor, Target, Autonomous, definition.GetStyle(this)))
                {
                    CommonPregnancy.Impregnate(Actor, Target, Autonomous, definition.GetStyle(this));
                }

                VisitSituation situation  = VisitSituation.FindVisitSituationInvolvingGuest(Actor);
                VisitSituation situation2 = VisitSituation.FindVisitSituationInvolvingGuest(Target);
                if ((situation != null) && (situation2 != null))
                {
                    situation.GuestStartingInappropriateAction(Actor, Wardrobe.kAppropriatenessPenalty);
                    situation2.GuestStartingInappropriateAction(Target, Wardrobe.kAppropriatenessPenalty);
                }

                Actor.BuffManager.AddElement(BuffNames.ClothesEncounters, Origin.FromWooHooInWardrobe);
                Target.BuffManager.AddElement(BuffNames.ClothesEncounters, Origin.FromWooHooInWardrobe);

                mCurrentStateMachine.RequestState(false, "x", "Exit");
                mCurrentStateMachine.RequestState(true, "y", "Exit");
                mIsInWardrobe = false;

                EventTracker.SendEvent(EventTypeId.kWoohooInWardrobe, Actor, Target);

                mWardrobe.RemoveFromUseList(Actor);
                EndCommodityUpdates(true);
                StandardExit();
                mCurrentStateMachine.RemoveEventHandler(ShowX);
                mCurrentStateMachine.RemoveEventHandler(ShowY);
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception exception)
            {
                Common.Exception(Actor, Target, exception);
                return(false);
            }
        }
Exemplo n.º 24
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);
            }
        }
Exemplo n.º 25
0
        public override bool Run()
        {
            VisitSituation.OnSimLeavingLot(this.Actor);
            Lot lot = this.Actor.SimDescription.VirtualLotHome;

            if (lot == null)
            {
                List <Lot> list = new List <Lot>();
                foreach (object obj in LotManager.AllLotsWithoutCommonExceptions)
                {
                    Lot lot2 = (Lot)obj;
                    if (lot2 != this.Actor.LotCurrent && lot2.LotId != 18446744073709551615UL)
                    {
                        list.Add(lot2);
                    }
                }
                if (list.Count > 0)
                {
                    lot = RandomUtil.GetRandomObjectFromList <Lot>(list);
                }
            }
            GroupingSituation.RemoveSimFromGroupSituation(this.Actor);
            if (this.Actor.LotCurrent.CommercialLotSubType == CommercialLotSubType.kEP10_Resort && this.Actor.IsHuman && this.Actor.SimDescription.ChildOrAbove && (this.Actor.SimDescription.AssignedRole == null || this.Actor.SimDescription.AssignedRole.Type != Role.RoleType.Paparazzi))
            {
                IResortTower[] objects = this.Actor.LotCurrent.GetObjects <IResortTower>();
                if (objects.Length > 0)
                {
                    IResortTower        randomObjectFromList = RandomUtil.GetRandomObjectFromList <IResortTower>(objects);
                    InteractionInstance instance             = randomObjectFromList.GetEnterTowerDefinition().CreateInstance(randomObjectFromList, this.Actor, new InteractionPriority(InteractionPriorityLevel.UserDirected), base.Autonomous, false);
                    if (this.Actor.InteractionQueue.PushAsContinuation(instance, false))
                    {
                        return(true);
                    }
                }
            }
            InteractionInstance interactionInstance = null;

            if (lot != null)
            {
                DGSGoToVirtualHomeInternal goToVirtualHomeInternal;
                if (this.SuccessCallbackForSequence != null || this.FailureCallbackForSequence != null)
                {
                    goToVirtualHomeInternal = (DGSGoToVirtualHomeInternal.Singleton.CreateInstanceWithCallbacks(lot, this.Actor, this.Actor.InheritedPriority(), base.Autonomous, base.CancellableByPlayer, null, this.SuccessCallbackForSequence, this.FailureCallbackForSequence) as DGSGoToVirtualHomeInternal);
                }
                else
                {
                    goToVirtualHomeInternal = (DGSGoToVirtualHomeInternal.Singleton.CreateInstance(lot, this.Actor, this.Actor.InheritedPriority(), base.Autonomous, base.CancellableByPlayer) as DGSGoToVirtualHomeInternal);
                }
                goToVirtualHomeInternal.SimWalkStyle = this.SimWalkStyle;
                if (base.TryPushAsContinuation(goToVirtualHomeInternal))
                {
                    interactionInstance = goToVirtualHomeInternal;
                }
            }
            if (lot == null || interactionInstance == null || !this.Actor.InteractionQueue.HasInteraction(interactionInstance))
            {
                SimDescription simDescription = this.Actor.SimDescription;
                if (simDescription.Household != null && simDescription.Household.IsTouristHousehold)
                {
                    Sim.GoToVirtualHome.SendTouristHome(simDescription);
                }
                else
                {
                    if (DGSCommon.IsExtKillSimNiecAndYLevel(Actor))
                    {
                        return(true);
                    }
                    this.Actor.FadeOut(true, true);
                }
                Simulator.Sleep(uint.MaxValue);
            }
            return(true);
        }
Exemplo n.º 26
0
        public static void OnAlarm()
        {
            if (sFirstAlarm)
            {
                sFirstAlarm = false;
                StyledNotification.Show(new StyledNotification.Format("Work Pusher Activated", ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kSystemMessage));
            }

            int iJobSync = 0, iSchoolSync = 0;
            int iJobTwoHourPush = 0, iSchoolTwoHourPush = 0;

            string sJobNames = null, sSchoolNames = null;

            DateAndTime NowTime     = SimClock.CurrentTime();
            DateAndTime TwoHourTime = SimClock.CurrentTime();

            TwoHourTime.Ticks += SimClock.ConvertToTicks(2f, TimeUnit.Hours);

            List <Sim> sims = new List <Sim>(Sims3.Gameplay.Queries.GetObjects <Sim>());

            foreach (Sim sim in sims)
            {
                if (sim.CareerManager == null)
                {
                    continue;
                }

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

                if (sim.Household.IsServiceNpcHousehold)
                {
                    continue;
                }

                {
                    Career job = sim.Job;
                    if (job != null)
                    {
                        float fPrevValue = job.HoursUntilWork;

                        job.SetHoursUntilWork();

                        if (fPrevValue > job.HoursUntilWork + 1f)
                        {
                            iJobSync++;
                        }

                        if (job.ShouldBeAtWork(NowTime))
                        {
                            sCarPoolers.Remove(sim);

                            InteractionInstance instance = job.CreateWorkInteractionInstance();
                            if (instance != null)
                            {
                                if ((((AutonomyRestrictions.GetLevel() >= AutonomyLevel.Two) && kPushActive) || sim.IsNPC) &&
                                    (!sim.InteractionQueue.HasInteractionOfType(instance.InteractionDefinition)))
                                {
                                    VisitSituation.AnnounceTimeToGoToWork(sim);

                                    sim.InteractionQueue.CancelAllInteractions();

                                    sim.InteractionQueue.Add(instance);

                                    sJobNames += "\n" + sim.Name;
                                }
                            }
                        }
                        else
                        {
                            if ((!sCarPoolers.ContainsKey(sim)) &&
                                (job.CurLevel != null) &&
                                (job.ShouldBeAtWork(TwoHourTime)))
                            {
                                // Check to see if the timer is already running, and if so, don't bother
                                if ((job.mRegularWorkDayGoToWorkHandle == AlarmHandle.kInvalidHandle) ||
                                    (AlarmManager.Global.GetTimeLeft(job.mRegularWorkDayGoToWorkHandle, TimeUnit.Minutes) <= 0))
                                {
                                    iJobTwoHourPush++;

                                    if (job.mRegularWorkDayTwoHoursBeforeStartHandle != AlarmHandle.kInvalidHandle)
                                    {
                                        AlarmManager.Global.RemoveAlarm(job.mRegularWorkDayTwoHoursBeforeStartHandle);
                                        job.mRegularWorkDayTwoHoursBeforeStartHandle = AlarmHandle.kInvalidHandle;
                                    }

                                    if ((!sim.IsSelectable || !job.CarpoolEnabled) || !job.CurLevel.HasCarpool)
                                    {
                                        InteractionInstance instance = job.CreateWorkInteractionInstance();
                                        if ((instance != null) &&
                                            (!sim.InteractionQueue.HasInteractionOfType(instance.InteractionDefinition)))
                                        {
                                            sim.InteractionQueue.CancelAllInteractions();
                                        }

                                        float num  = ((job.CurLevel.StartTime - NowTime.Hour) + 24f) % 24f;
                                        float time = num - job.AverageTimeToReachWork;
                                        if (time < 0f)
                                        {
                                            time = 0f;
                                        }
                                        job.mRegularWorkDayGoToWorkHandle = AlarmManager.Global.AddAlarm(time, TimeUnit.Hours, new AlarmTimerCallback(job.RegularWorkDayGoToWorkHandle), "Career: time to push go to work", AlarmType.AlwaysPersisted, job.OwnerDescription);
                                    }
                                    else
                                    {
                                        sCarPoolers.Add(sim, true);

                                        StyledNotification.Format format = new StyledNotification.Format(Localization.LocalizeString("Gameplay/Objects/Vehicles/CarpoolManager:CarpoolComing", new object[] { sim }), ObjectGuid.InvalidObjectGuid, sim.ObjectId, StyledNotification.NotificationStyle.kGameMessagePositive);
                                        StyledNotification.Show(format, job.CareerIconColored);
                                    }
                                }
                            }
                        }
                    }
                }

                {
                    School school = sim.CareerManager.School;
                    if (school != null)
                    {
                        float fPrevValue = school.HoursUntilWork;

                        school.SetHoursUntilWork();

                        if (fPrevValue > school.HoursUntilWork + 1f)
                        {
                            iSchoolSync++;
                        }

                        if (school.ShouldBeAtWork(NowTime))
                        {
                            sBusPoolers.Remove(sim);

                            InteractionInstance instance = school.CreateWorkInteractionInstance();
                            if (instance != null)
                            {
                                if ((((AutonomyRestrictions.GetLevel() >= AutonomyLevel.Two) && kPushActive) || sim.IsNPC) &&
                                    (!sim.InteractionQueue.HasInteractionOfType(instance.InteractionDefinition)))
                                {
                                    VisitSituation.AnnounceTimeToGoToWork(sim);

                                    sim.InteractionQueue.CancelAllInteractions();

                                    sim.InteractionQueue.Add(instance);

                                    sSchoolNames += "\n" + sim.Name;
                                }
                            }
                        }
                        else
                        {
                            if ((!sBusPoolers.ContainsKey(sim)) &&
                                (school.ShouldBeAtWork(TwoHourTime)))
                            {
                                // Check to see if the timer is already running, and if so, don't bother
                                if ((school.mRegularWorkDayGoToWorkHandle == AlarmHandle.kInvalidHandle) ||
                                    (AlarmManager.Global.GetTimeLeft(school.mRegularWorkDayGoToWorkHandle, TimeUnit.Minutes) <= 0))
                                {
                                    iSchoolTwoHourPush++;

                                    if (school.mRegularWorkDayTwoHoursBeforeStartHandle != AlarmHandle.kInvalidHandle)
                                    {
                                        AlarmManager.Global.RemoveAlarm(school.mRegularWorkDayTwoHoursBeforeStartHandle);
                                        school.mRegularWorkDayTwoHoursBeforeStartHandle = AlarmHandle.kInvalidHandle;
                                    }

                                    if (school.PickUpCarpool != null)
                                    {
                                        sBusPoolers.Add(sim, true);

                                        school.PickUpCarpool.TryShowTNS(sim, Localization.LocalizeString("Gameplay/Objects/Vehicles/CarpoolManager:SchoolBusComing", new object[] { sim }), Localization.LocalizeString("Ui/Tooltip/Hud/School:SchoolBusArrives", new object[] { SimClockUtils.GetText((int)(school.CurLevel.StartTime - 1f), 0) }));
                                    }
                                    else
                                    {
                                        InteractionInstance instance = school.CreateWorkInteractionInstance();
                                        if ((instance != null) &&
                                            (!sim.InteractionQueue.HasInteractionOfType(instance.InteractionDefinition)))
                                        {
                                            sim.InteractionQueue.CancelAllInteractions();
                                        }

                                        float num  = ((school.CurLevel.StartTime - NowTime.Hour) + 24f) % 24f;
                                        float time = num - school.AverageTimeToReachWork;
                                        if (time < 0f)
                                        {
                                            time = 0f;
                                        }
                                        school.mRegularWorkDayGoToWorkHandle = AlarmManager.Global.AddAlarm(time, TimeUnit.Hours, new AlarmTimerCallback(school.RegularWorkDayGoToWorkHandle), "Career: time to push go to work", AlarmType.AlwaysPersisted, school.OwnerDescription);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            bool bShow = false;

            string msg = "Work Pusher:";

            if (iJobSync > 0)
            {
                msg  += "\nWork Alarms Resync'd: " + iJobSync.ToString();
                bShow = true;
            }
            if (iJobTwoHourPush > 0)
            {
                msg  += "\nWork Two Hour Alarms: " + iJobTwoHourPush.ToString();
                bShow = true;
            }
            if (sJobNames != null)
            {
                msg  += "\nPushed to Work: " + sJobNames;
                bShow = true;
            }
            if (iSchoolSync > 0)
            {
                msg  += "\nSchool Alarms Resync'd: " + iSchoolSync.ToString();
                bShow = true;
            }
            if (iSchoolTwoHourPush > 0)
            {
                msg  += "\nSchool Two Hour Alarms: " + iSchoolTwoHourPush.ToString();
                bShow = true;
            }
            if (sSchoolNames != null)
            {
                msg  += "\nPushed to School: " + sSchoolNames;// iSchoolCount.ToString();
                bShow = true;
            }

            if ((bShow) && (sVerbose))
            {
                StyledNotification.Show(new StyledNotification.Format(msg, ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kSystemMessage));
            }
        }